• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

Could this be causing a desync?

Status
Not open for further replies.
Level 12
Joined
Dec 2, 2016
Messages
733
I've been getting desync's in my game around 30 mins +


Specifically the flame effect function. I didn't started getting desync's until I added that.

Basically when I type -c rug it adds the flame effect + the other effect to all the hero models and unit models. Basically can be about 10 units in the map. They keep that effect all game long. Also changes the units tint.


JASS:
library colorCmd requires libMisc, unitClassification, clanTag {


// Public Api
public struct ColorCmd {
  public static method decorateUnit(unit u) {
    integer pId = GetPlayerId(GetOwningPlayer(u));
    integer i = 0;
    integer color;
   string dev = GetPlayerName(Player(pId));
  

    if (!ClanTag.checkMember(pId, COLOR_ACCESS_1)&& dev != "[RG]RugarusVF") {
      if (players[pId].side == SIDE_MINION) {
        return;
      }
      color = 0;
    }
    else {
      for (COLOR_MAX >= i > 0) {
        if (ClanTag.checkMember(pId, color2Access[i]) || dev == "[RG]RugarusVF") {
          color = i;
          break;
        }
      }
    }

    if (players[pId].side == SIDE_HUMAN) {
      humanColors[color].recolorUnit(u);
  
    
    }
    else {
      vampireColors[color].recolorUnit(u);
    
    }
  
  }
}

function flameEffect() {
integer pId = GetPlayerId(GetOwningPlayer(GetEnumUnit()));
string dev = GetPlayerName(Player(pId));
 if (GetUnitTypeId(GetEnumUnit()) == 'E002' || GetUnitTypeId(GetEnumUnit()) == 'E001' || GetUnitTypeId(GetEnumUnit()) == 'U007' || GetUnitTypeId(GetEnumUnit()) == 'U008' || GetUnitTypeId(GetEnumUnit()) == 'AVFV') {
   AddSpecialEffectTargetUnitBJ("head", GetEnumUnit(), "Abilities\\Spells\\Human\\FlameStrike\\FlameStrikeDamageTarget.mdl");
   AddSpecialEffectTargetUnitBJ("head", GetEnumUnit(), "Abilities\\Weapons\\GargoyleMissile\\GargoyleMissile.mdl");
  
    }
    else if (GetUnitTypeId(GetEnumUnit()) == 'h010') {
    UnitRemoveAbilityBJ( 'A02B', GetEnumUnit());
    UnitAddAbilityBJ( 'A04B', GetEnumUnit());
    }
}



function onColor() -> boolean {
  string s = StringCase(GetEventPlayerChatString(), false);
  integer pId = GetPlayerId(GetTriggerPlayer());
  integer startPos;
  integer color;
  string dev = GetPlayerName(Player(pId));

  if (SubString(s, 0, 8) == "-colour ") {
    startPos = 8;
  }
  else if (SubString(s, 0, 7) == "-color ") {
    startPos = 7;
  }
  else if (SubString(s, 0, 3) == "-c ") {
    startPos = 3;
  }
  else {
    return false;
  }

  s = SubString(s, startPos, StringLength(s));
  if (s == "clear" || s == "none" || s == "black") {
    color = COLOR_DEFAULT;
  }
 
   else if (s == "rug" && dev =="[RG]RugarusVF") {
    color = COLOR_RUG;
     ForGroupBJ(GetUnitsInRectAll(GetEntireMapRect()),function flameEffect);
  
  
  }



  if (players[pId].side == SIDE_HUMAN) {
    humanColors[color].recolorUnit(players[pId].main);
  }
  else {
    vampireColors[color].recolorUnit(players[pId].main);
  }

  return false;
}

private function onInit() {
  trigger trg = CreateListedTrigger();
  integer i;


  humanColors[COLOR_RUG] = ARGB.create(255,3, 155,155);
 
 
  vampireColors[COLOR_RUG] = ARGB.create(255,3, 155,155);
 
  color2Access[COLOR_RUG] = COLOR_ACCESS_5;

  for (0 <= i <= 11) {
    TriggerRegisterPlayerChatEvent(trg, Player(i), "-colour", false);
    TriggerRegisterPlayerChatEvent(trg, Player(i), "-color", false);
    TriggerRegisterPlayerChatEvent(trg, Player(i), "-c", false);
  }

  TriggerAddCondition(trg, Condition(function onColor));
}

}
 
Level 12
Joined
Dec 2, 2016
Messages
733
JASS:
function flameEffect() {
integer pId = GetPlayerId(GetOwningPlayer(GetEnumUnit()));
string dev = GetPlayerName(Player(pId));
 if (GetUnitTypeId(GetEnumUnit()) == 'E002' || GetUnitTypeId(GetEnumUnit()) == 'E001' || GetUnitTypeId(GetEnumUnit()) == 'U007' || GetUnitTypeId(GetEnumUnit()) == 'U008' || GetUnitTypeId(GetEnumUnit()) == 'AVFV') {
   AddSpecialEffectTargetUnitBJ("head", GetEnumUnit(), "Abilities\\Spells\\Human\\FlameStrike\\FlameStrikeDamageTarget.mdl");
   AddSpecialEffectTargetUnitBJ("head", GetEnumUnit(), "Abilities\\Weapons\\GargoyleMissile\\GargoyleMissile.mdl");
  
    }
    else if (GetUnitTypeId(GetEnumUnit()) == 'h010') {
    UnitRemoveAbilityBJ( 'A02B', GetEnumUnit());
    UnitAddAbilityBJ( 'A04B', GetEnumUnit());
    }
}

^ Could this be causing desyncs?
 
Desync means something is not synchronized between players, which affects other players in different consequences. For example, Unit_1 is dead for Player1, but alive for Player2. This can't work very well, because the game can't now how to react, and so the player(s) will be thrown out of the game.

Basically, try not to change agents, locally. For example, adding ability, clear group, etc etc, should not happen for only one player, but for all the same.
Changing a button's name locally (string) would be okay, if the string is not used for other agent operations, and the button exists for all players.

By happen locally, it is meant that operations are inside a GetLocalPlayer() block, so they are executed only for 1 player:
.. code that is not inside those local blocks, won't cause desyncs. Look for code parts that use local blocks.
 
Level 12
Joined
Dec 2, 2016
Messages
733
Desync means something is not synchronized between players, which affects other players in different consequences. For example, Unit_1 is dead for Player1, but alive for Player2. This can't work very well, because the game can't now how to react, and so the player(s) will be thrown out of the game.

Basically, try not to change agents, locally. For example, adding ability, clear group, etc etc, should not happen for only one player, but for all the same.
Changing a button's name locally (string) would be okay, if the string is not used for other agent operations, and the button exists for all players.

By happen locally, it is meant that operations are inside a GetLocalPlayer() block, so they are executed only for 1 player:
.. code that is not inside those local blocks, won't cause desyncs. Look for code parts that use local blocks.

My function there replaces an ability for one team while the other team doesn't get their ability replaced via that chat command. The other team also doesn't have that ability. Could that cause it then? I also typed the chat command at the start of the game and the desync only happened around 40 mins +
 
The code removes and adds ability just normaly, not inside any locals block. It means it happens for all players, so it's no problem.

It would be a problem if for one player the ability gets removed, but it's still there for one other player. That would mean something critical isn't synced anymore. Try to understand the linked GetLocalPlayer() tutorials and search for such blocks.

Which wc3 version are you using? Newest PTR seemingly isn't stabil, some report.
 
Last edited:
Level 12
Joined
Dec 2, 2016
Messages
733
The code removes and adds ability just normaly, not inside any locals block. It means it happens for all players, so it's no problem.

It would be a problem if for one player the ability gets removed, but it's still there for one other player. That would mean something critical isn't synced anymore. Try to understand the linked GetLocalPlayer() tutorials and search for such blocks.

Which wc3 version are you using? Newest PTR seemingly isn't stabil, some report.

I'm using 1.29, hmm then not sure what's causing it.
 
Status
Not open for further replies.
Top