Jump to content


Photo

ds_map_copy broken in HTML5


  • Please log in to reply
2 replies to this topic

#1 locohost

locohost

    GMC Member

  • GMC Member
  • 459 posts
  • Version:GM:Studio

Posted 25 May 2012 - 06:04 PM

/*
        Example of JSON in sCallbackResult...
        {
            "Game": {
                "0": {
                    "GameID": "5",
                    "ArmyPoints": "1000",
                    "HowManyOpponents": "1",
                    "CreatorID": "1"
                }
            }
        }
        */
        // Parse the JSON result
        map = ds_map_create();
        map = json_decode(sCallbackResult);
        
        if (ds_map_exists(map,'default')) {
            show_message('Bad JSON result: ' + ds_map_find_value(map,'default'));
        }
        // Create temp maps
        var mGame; mGame = ds_map_create();
        ds_map_copy(mGame, ds_map_find_value(ds_map_find_value(map,'Game'),'0'));
        //show_message('Map size: ' + string(ds_map_size(ds_map_find_value(ds_map_find_value(map,'Game'),'0'))));
        show_message('Map size: ' + string(ds_map_size(mGame)));

When the above code runs, the script simply hangs and never completes. If you change the comments to not use the mGame map that is supposed to be populated from a ds_map_copy, you see the message box and it shows size=4 as expected. What is wrong with ds_map_copy here? :confused:

Thanks for your help :smile:
  • 0

#2 YellowAfterlife

YellowAfterlife

    GMC Member

  • Global Moderators
  • 3493 posts
  • Version:GM:Studio

Posted 25 May 2012 - 08:19 PM

ds_map_copy is slightly broken in current version of GameMaker:Studio JavaScript 'engine'. Reported that to bug tracker.
And by 'slightly' I mean that it causes JavaScript exception and crashes either entire game or script you're trying to run.
If things cannot wait, iterate through map with use of ds_map_find_first/ds_map_find_next/ds_map_exists.
  • 1

#3 locohost

locohost

    GMC Member

  • GMC Member
  • 459 posts
  • Version:GM:Studio

Posted 25 May 2012 - 08:29 PM

ds_map_copy is slightly broken in current version of GameMaker:Studio JavaScript 'engine'. Reported that to bug tracker.
And by 'slightly' I mean that it causes JavaScript exception and crashes either entire game or script you're trying to run.
If things cannot wait, iterate through map with use of ds_map_find_first/ds_map_find_next/ds_map_exists.


I always find find the broken functions :wacko:

I worked around ds_map_copy with simply...

var mGame; mGame = ds_map_find_value(ds_map_find_value(map,'Game'),'0');

I was trying to shorten the syntax for drilling down into json_decode nested maps 3 and 4 levels. Don't even need to use ds_map_copy for this. Not sure why I didn't think of this sooner :blush:

Thanks for the reply :smile:
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users