In Godot, the assert will not execute after the game is exported as a release version.
Program execution statements should not be placed inside an alert; otherwise, the program will not execute in the release version.
Expected Behavior
The item images are displayed in the release version of the game.
Current Behavior
I found that the "item" images in my game disappeared in the release version, while other images displayed normally.
After debugging, I discovered that in the parse function of ItemProtoset, test_json_conv.data was not null in the debug version but was null in the release version.
Then, outputting test_json_conv.parse(json) == OK returned true, indicating that the JSON parsed correctly.
Possible Solution
-
Next, I changed the original code snippet at item_protoset.gd
assert(test_json_conv.parse(json) == OK, "Failed to parse JSON!")to the revised code snippet:
var error = test_json_conv.parse(json) assert(error == OK, "Failed to parse JSON!")
The game then displayed item images correctly in the release version.
I apologize for the typo; please consider "alert" as "assert".
Many inventory operations were also affected by this issue, and I manually replaced all assert statements with the revised operation mentioned above. The game is now running smoothly.
This is a very good point, I think there's a lot of bad assert usage in the code. I'll have to go through all of them and make corrections.
Fixed in https://github.com/peter-kish/gloot/pull/221