DavidJCobb / ReachVariantEditor

A tool for editing Halo: Reach game variants.
23 stars 9 forks source link

g'day, weird bug i ran into today #12

Closed Gamergotten closed 3 years ago

Gamergotten commented 3 years ago

while playing with some absurd bits of code i came across a random exception

if you try and nest a player and their biped in an if var reference it will compile that player to player[0] eg. if global.object[1].player[3].biped == global.object[1].player[3].biped then will compile to if global.object[1].player[0].biped == global.object[1].player[0].biped then RVT is fully capable of decompiling the correct player[] though as i was able to manually save a gamemode with the first bit of code applied and RVT would read it correctly (git wouldn't let me upload the .bin so heres the link instead: https://cdn.discordapp.com/attachments/831007456749551628/855449418052665424/HR_Slayer_fix.bin)

theres also a couple of other interesting things i've run into and since im here why not share them? RVT doesn't seem to have a character limit for team name strings, so saving a gamemode with an extra large team name string will cause the gamemode to become corrupt and screw up a fair amount of data, oh and also if you try and add another label past the limit in some modes it will cause RVT to crash. (happens with the mode i have linked) not really an RVT bug theres one that will cause mcc to be unable to read a gamemode, i can't quite remember what it is but i think it may be related to having more than one of the exact same string

anyhow thats all. add me back on discord :)

DavidJCobb commented 3 years ago

if global.object[1].player[3].biped == global.object[1].player[3].biped then

Issue confirmed in OpcodeArgValueObject::compile. We are attempting to use the property index when compiling, when we should instead be accessing the nested variable index.

Every parsed "variable reference" consists of a base variable (global.object[1]) and optionally a nested variable (player[3]), a property (biped), and an accessor (say, health). The former three values can all have indices -- even properties, because things like player.script_stat[n] are indexed properties. Even if a particular variable reference doesn't use certain fields, the data structure that we use to hold a variable reference while we're working with it -- after we've parsed it and before we've compiled it into script bytecode -- has those fields. They're typically initialized to zero or null as appropriate.

So if global.object[1].player[3].biped doesn't have a property index (i.e. it's not biped[n]), but we're checking the property index instead of the nested variable index (3), then we're going to get 0.

Good find. Fix implemented; it'll ship with the next update.

RVT doesn't seem to have a character limit for team name strings, so saving a gamemode with an extra large team name string will cause the gamemode to become corrupt and screw up a fair amount of data

Good catch. I'll work on it, but multi-line textboxes in Qt don't actually have a maximum length setting I can use, so I'll have to hack something together myself. Might take me some time to find an approach to that that doesn't suck (or settle for one that does). Surprisingly tricky; a robust approach to it is not as simple as just "delete the last characters in the text until it's less than X characters long" because what if, for example, someone pastes into the middle of the text?

if you try and add another label past the limit in some modes it will cause RVT to crash. (happens with the mode i have linked)

Confirmed. Fix implemented; it'll ship with the next update. Thank you for providing a test-case file.

add me back on discord :)

I usually prefer not to friend people I'm not relatively well acquainted with, and I forgot that you have to share a server in order to DM someone who isn't friended, so I initially rejected your request. I'm not sure why you're not on the Halo Mods server anymore, but if rejoining that or the official Halo server isn't an option, then I suppose you could send another request.

DavidJCobb commented 3 years ago

Should be fixed in v2.1.5.