View Issue Details

IDProjectCategoryView StatusLast Update
0031515RunnerHTML5Public2019-11-28 11:52
ReporterYellowAfterlifeAssigned ToLuke Brown 
PriorityVery LowSeverityC - GeneralReproducibility100%
Status ResolvedResolutionFixed 
PlatformHTML5OSWindows 10 ProOS Version>=18362
Product Version2.2.4 
Target Version2.3.0Fixed in Version2.3.0 
Summary0031515: HTML5: asset_get_index has some suspicious broken trailing code
DescriptionWhile looking at something else I stumbled upon this:
function asset_get_index(_P3) {
    _P3 = yyGetString(_P3);
    var _o4 = -1;
    if ((_o4 = _fF(_P3, _Xz.GMObjects)) >= 0) {
        return _o4;
    } else if ((_o4 = _fF(_P3, _Xz.GMRooms)) >= 0) {
        return _o4;
    } else ... bunch more of these
    -- attention to the following: --
    var _jF = Object.getOwnPropertyNames(g_pBuiltIn);
    for (var i = 0; i > _jF; i++) {
        if (_jF[i] == _P3) {
            return i;
        }
    }
    return -1;
}

There are at least a couple issues with this:
- comparing array (instead of array.length) to a number
- doing i > val instead of i < val
- field order for getOwnPropertyNames is not warranted
- property names inside g_pBuiltIn are obfuscated on release
- g_pBuiltIn contains built-in variables (like room_width/height), not assets

The code seems to be like this even in the oldest version of GM:S that I have access to (1.4.1773 / Sep 2017) so it seems plausible that this is a relic of a time long gone. Have a look at what might have been the purpose of this on a slow day.
Tagsfunctions, html5
1.4 Found In
2.x Runtime Found In9.9.1.1624
2.x Runtime Verified In

Activities

Luke Brown

2019-11-22 15:29

Developer   ~0065147

Seems as though when the code was ported from the cpp runner but really the cpp runner and the html5 runner shouldn't have been trying to check constants.

The reason the cpp runner was checking this originally seems to be simply that the "asset_get_index" function redirects to "Code_Constant_Find" which i suspect was used because it similarly checks all the resources and returns their index before checking the builtin constants (which is the part that was then also copied over into the HTML5 runner).

I've removed the part which checks for constants from the HTML5 runner and copied only the relevant part into the "asset_get_index" for the cpp runner. The original cpp function "Code_Constant_Find" doesn't seem to be used anywhere else, so we can probably remove this too.

Luke Brown

2019-11-22 16:15

Developer   ~0065149

fixed in gitlab