Asynchronous Loading Map Data Problem... $dataMap is null when running game ONLINE

first of all i encounter some problem when using asynchronous load map data in my plugin...

http://forums.rpgmakerweb.com/index.php?/topic/50665-est-regionmaploader/

and the clone event also have that problem but Hudell is giving me some workaround it... (but this workaround doesn't work in regionmaploader)

this only happen when i upload my project in dropbox public folder (some people i know also upload it using regular webhoster and it's the same) then opening it in browser.

when changing the regionmapdata... then transfer to the map...   often...(90%)

it will throw TypeError: $dataMap is null

and console show this:

DATAMAPERROR.png


my suspicion it caused because of the asynchronous is not finised yet. it caused $dataMap not loaded yet when transfering... but i might be wrong.

also when i consult with Hudell about this... he also said:

In the DataManager class, the loadMapData and loadDataFile methods sets null to $dataMap, it will remain null until the map is finished loading. When playing locally, that happens in a split second, but online it takes time.
apparently... even when $dataMap is null. it still running the scene forcefully...

a bug in MV?

I also try to add some counters in callback method / onload method in the asynchronous load function. but when i use it inside Scene_Map.prototype.isReady... it doesn't work. the counter is correct. $dataMap also not null... but it crash after that.

i also try checking for $dataMap is null or not in Scene_Map.prototype.isReady and Game_Map.prototype.setup. it doesn't work either...

i also try adding 'while' that check that counter (do nothing). but inside while... the asynchronous stop executing... thus that counter never reduced and thus freeze the game...

i also read something about combining counter and listener... but i don't really understand yet how to use that since i'm new in JS so i might use it wrongly... for starter in what i add the listener to?

my question is... any way to 'wait' until all asynchronous finished in MV? btw i try interpreter wait and it also doesn't work  😛 .

once again... i'm new in JS. sorry if my code is still 'smell' like ruby. slowly learning how to adapt to JS.
Check out the Scene_Map object's .onMapLoaded function. It gets called when the dataMap has finished loading so you should be able to overload it and do whatever you want there.

Like this:

var _Scene_Map_onMapLoaded_base = Scene_Map.prototype.onMapLoaded;Scene_Map.prototype.onMapLoaded = function() { _Scene_Map_onMapLoaded_base.call(this); //Do stuff};This is how I've been doing it in my encounter plugin which edits encounter data on a per map basis. If you want to see exactly how I'm doing it, check the link in my sig.
Check out the Scene_Map object's .onMapLoaded function. It gets called when the dataMap has finished loading so you should be able to overload it and do whatever you want there.

Like this:

var _Scene_Map_onMapLoaded_base = Scene_Map.prototype.onMapLoaded;Scene_Map.prototype.onMapLoaded = function() { _Scene_Map_onMapLoaded_base.call(this); //Do stuff};This is how I've been doing it in my encounter plugin which edits encounter data on a per map basis. If you want to see exactly how I'm doing it, check the link in my sig.
thanks quick reply and for this info... will try it A.S.A.P

edit: unfortunately it doesn't work...

i try adding console.log("test") at the start of the function and it doesn't executed when error thrown.

so the error happen before reaching that function...
thanks quick reply and for this info... will try it A.S.A.P

edit: unfortunately it doesn't work...

i try adding console.log("test") at the start of the function and it doesn't executed when error thrown.

so the error happen before reaching that function...
When you talk about the error, you mean the one complaining that $dataMap is null, right? I can't tell you where in your script the error is happening, but if you can figure that out, you should be able to move the problematic code into the function I mentioned earlier and that should ensure that $dataMap is not null.

Original thread: https://forums.rpgmakerweb.com/threads/asynchronous-loading-map-data-problem-datamap-is-null-when-running-game-online.51693/