Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Quality Structures

Descriptive error messages and better error handling for GameMaker data structure functions · By YellowAfterlife

Does not work on 2022.1 project

A topic by PolyCrunch Games created Jun 18, 2022 Views: 200 Replies: 4
Viewing posts 1 to 4

Hi, I was trying to find a memory leak and I was surprised there wasn't any native tool to help with this in GM. But for a change, YAL to the rescue and found this tool. However when I tried to drop the yyp project to migrate it, it told me: 

Either this is a 2.3 project or JSON is malformed: Invalid char 125 at position 106
Got an error: System.NullReferenceException: Cannot access field 'resources' of null.
   at haxe.lang.Runtime.slowGetField(Object obj, String field, Boolean throwErrors)
   at haxe.lang.Runtime.getField(Object obj, String field, Int32 fieldHash, Boolean throwErrors)
   at GMCompFix.__hx_ctor__GMCompFix(GMCompFix __hx_this, String path)
   at GMCompFix..ctor(String path)
   at GMCompFix.main()
Called from haxe.lang.Runtime.slowGetField (null line 0)
Called from haxe.lang.Runtime.getField (null line 0)
Called from GMCompFix.__hx_ctor__GMCompFix (null line 0)
Called from GMCompFix..ctor (null line 0)
Called from GMCompFix.main (null line 0)
Press any key to exit.
Developer

Released an update.

The extension itself is unaffected, only the code replacer tool (and it will likely break again sometime as GameMaker now updates at a much greater pace)

Thanks for the update. Converter worked. Will see if I can find the memory leak. Although from what I saw from the profiler yesterday morning, not 100% sure it's a memory leak, because when leaving the room, memory drops back to before entering the room.

It's a pity you don't sell more of this package. I don't think most GameMaker users know how dangerous the ds_* can be, even when you just do a genuine mistake.

Thanks again for everything, especially GMLive and GMEdit which is my daily driver IDE.

Hi YAL,

I came to conclusion it's impossible to convert a project unless it's small one.

I would have loved to know about this tool before because GameMaker data structures are insanely unsafe. You should really upsell it with your other products e.g. GMLive and GMEdit, when GameMaker uses inevitably encounter your great tools when starting in GameMaker :)

I took some notes about the converter, but do not fix any for me.

1) pre-increment not handled properly as it was in front of a qs_function e.g. if (--qs_.....).

2) pre-increment was not changed too

e.g.

 list = global.notificationsFramesLeft[playerIndex];
--list[| i];

3) json_decode not changed to qs_json_decode

4) ds_exists not changed to qs_exists

5) when accessing ds_maps from os_get_info() or async_load events should not be changed to qs. You would get errors like this:

trying to index a variable which is not an array
 at gml_Script_qs_debug_dump (line 4) -        var l_meta = argument0[0];
############################################################################################
gml_Script_qs_debug_dump (line 4)
gml_Script_qs_impl_map_mismatch (line 2) - show_error("Expected a map, got " + qs_debug_dump(argument0), true);
gml_Script_qs_map_find_value (line 9) - } else qs_impl_map_mismatch(argument0);
...

6) instance_place_list expects a ds_list so that causes a problem too

Developer

You can edit the rules in compfix.gml to add any missing functions or generally change code generation. Not sure if the replacer tool supports prefix operators - it’s a bit of a tricky topic and wasn’t needed for the original implementation (which was made for replacing variables like layer).

async_load is trickier - since GM creates it by itself, there’s not really much to replace. On one-off basis you could run qs_json_decode(json_encode(thing))