• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Please help diagnose/fix desyncs

Status
Not open for further replies.
Level 12
Joined
Jun 12, 2010
Messages
413
Hello everyone, so this is basically my last resort, as I have tried everything that I could to get rid of desyncs, but it's all been for naught.

First, a bit of background: I develop my map mainly in the 1.29 World Editor, using WEX. I've been using w3x2lni and GitHub for version control for the past few months (which has made my workflow much more efficient). Thus, my releases are usually made using Editor Version 6060 and optimized to the SLK format defined by w3x2lni. I've tried releasing versions that were not optimized and were saved with 1.31, but it didn't change a thing (see below).

My map is a sandbox roleplaying map, so the most important feature is pretty much allowing players to modify units visually in any way that they want, and to offer a vast amount of custom models for both troops/heroes and decorations.

Unfortunately, this kind of map usually has many problems with desyncs, crashes and the like. I’ve taken a number of precautions to avoid the same fate, but no matter all the caution I exercise, my map is no different.

I think that I've mostly fixed the crashes that used to happen randomly. I've always thought that they were because of some corrupted models, and when I found out about the MDX Sanity Checker, I set out to remove as many errors and warnings as I could from the 2000+ imports inside of the map. It seems that sometimes players still crash, but I've only had 1 reliable crash report since I sanitzed the models.

Anyway, the nature of the desyncs is basically random. I tried replicating everything that has been reported to have occured before a desync, and it has never been reproduceable. Usually it's just a single player that desyncs, sometimes two. Usually once per game, sometimes 2 or 3 times. Sometimes, no desyncs happen at all. They don't exactly make the map unplayable, especially since you can save stuff and load it pretty quickly in a new game, but they are VERY frustrating.


Here are the things I have tried to do to fix desyncs:
  • Went through pretty much all of my code and searched for desyncs. At the moment, I cannot find any more desyncs that could be caused by code.
  • Removed all locally created strings. Some local strings may still be created if the player is using a non-english installation of wc3, though.
  • Stopped optimizing the map using SLK.
  • Saved the map using the 1.31 Editor.
  • Reduced maximum player count from 24 to 12.
  • Reduced the tileset from 16 textures to 15, fixing possibly corrupted tiles.


Even if you don't know or don't have the time to look through my map to see exactly what's wrong, if you have any idea of something that could cause a desync that is not related to JASS code, that would already be a big help!


Download link for latest version of the map (at the time of this post): Download

Link to war3map.j. It's a bit hard to read in a few places, since there is a lot of translation from vJass.

Here are links to the Libraries that execute local client code:

Save System (this uses Preload natives to save stuff locally. Mostly in the SaveIO library, though the LoadRequest function in SaveNLoad.j (for legacy saves made before patch 1.31) also executes local code.
Camera Commands (some variables are set locally, and the camera values are also set locally)
Periodic Hint System (has a local boolean variable that can be changed with a command to enable/disable tips)
AutoRectEnvironment (allows for players to define a custom terrain fog that is limited only to a certain rect in the map. The local player's current camera position is used to determine the current fog.)
Search Commands (these allow players to search for a certain builder by name and select it. The only functions executed locally are SelectUnit and ClearSelection)
Rotate Command (this command sets the parameters for a certain ability and sets the ability's Tooltip and ExtendedTooltip locally)
First/Third Person Camera System (this has been disabled while I test for desync causes, so it can't really be the culprit)
 
Level 10
Joined
Dec 11, 2009
Messages
234
From my experience, the cause of desyncs may be very strange and reside in unexpected places.
For example:
JASS:
// this works fine
set k = GetRandomInt(0,9)
if isLocalPlayer[i] then
	call StartSound(snd[k])
endif

// this will cause desync
if isLocalPlayer[i] then
	call StartSound(snd[GetRandomInt(0,9)])
endif
I needed 2 weeks to catch this shit and I was ripping my hair out in the end.

However, if desyncs are random and non-replicatable and happening to 1 player at a time, it's probably have something to do with WC3 itself and it's internal memory after playing other maps, etc. If that's the case, only Blizzard can fix that.
 
Level 12
Joined
Jun 12, 2010
Messages
413
That desync is pretty clear if you understand how random number generators work. You are desyncing the sequence of random numbers by generating a number for 1 player only. Whenever the game needs a new random number for all players, the player who generated 1 extra number will get a different result.

But that kind of requires knowing how random number generators work, if you don't that would take forever to debug. If it's something in my map's code that is causing a desync, it's probably a similar situation: some obscure mechanic that I have no idea could desync. I've checked the code so many times, it's hard to think it's something that I would know.

I would normally blame people not restarting, but I have reliable reports from people in the discord server that had indeed restarted wc3 before playing :wsad:
 
Level 10
Joined
Dec 11, 2009
Messages
234
That desync is pretty clear if you understand how random number generators work.
Yea, I didn't know that back then.

I would normally blame people not restarting, but I have reliable reports from people in the discord server that had indeed restarted wc3 before playing
In that case I guess the only thing left is to start disabling chunks of code (somehow still making it somewhat playable, if possible) to catch a lion in the desert. That's how I caught mine.
 
Level 12
Joined
Feb 27, 2019
Messages
399
Conditions of type "Player slot comparison" used too often also leads to desync, but I don't know why...
For example in my map when I used it in frequent triggers (ex: periodic, selection events, ...) to check if a player slot was different from "left", I had tons of desync.

In final, I only use them in triggers executed once or a few times.
 
Status
Not open for further replies.
Top