nipkownix / re4_tweaks

Fixes and tweaks for the "UHD" port of Resident Evil 4
zlib License
341 stars 32 forks source link

Command-line options #233

Open emoose opened 2 years ago

emoose commented 2 years ago

Describe the feature you'd like to see added

Might be nice if we could add some command-line options to the game, probably wouldn't be too difficult to add options for things like width/height/x/y, and maybe allow overriding some INI settings too. (eg --EnableFastMath=false)

What would be really nice is some way of adding options that interact with the game itself too, like -map r105 to make the game load straight into r105, -scene r100s44 to load up the r100s44 movie, -load 15 to load from slot 15, stuff like that.

That might be pretty far out right now though since we don't really know any methods for doing stuff like that atm... even just adding stuff like SkipIntroLogos was a little difficult because of how the game is programmed too, doubt it'd like us skipping the menu/save+load screens/etc entirely.

(though I think the GC debug might have had something that allowed devs to load straight into maps like that based on a config file, maybe whatever method that used could be transferred over somehow... I could be wrong about that though)

If we do figure out methods for that I imagine it might be possible to use them in-game too, maybe could even extend debug console to start accepting commands...

E: GC does have a ConfigSet func that reads some values from the debug/config.txt file, for room number it seems to just update something in pG with the number, guess it's probably not loading straight into it but just adjusting what the default level selected is (probably in that small menu that debug GC shows when starting new game)

emoose commented 2 years ago

Got something working for overriding INI settings, didn't take as much work as I'd thought: https://github.com/emoose/re4_tweaks/commit/2f325cdbcf6a9db491f6673286b64c0cb3c0c3eb

Can test it by running the game like bio4.exe -FOVAdditional 25 -EnableFastMath false

E: small update: https://github.com/emoose/re4_tweaks/commit/5bbfc599d87604953089f618ba939e78e57d016a

Removed the custom CommandLineToArgvA and used native windows CommandLineToArgvW instead (a little less efficient since it's using WideCharToMultiByte on all the cmd-line args, for each INI setting, but this reduces code size at least)

Now also allows boolean settings to be set to true if specified without a value too (so you could just use -EnableFastMath to set it to true, instead of always needing -EnableFastMath true)

E2: another update, made it a little more efficient by only converting value & the INI setting name to wide chars, instead of also converting all the cmd-line args for every setting: https://github.com/emoose/re4_tweaks/commit/b653351f422a74d39f625e25ad309732f00bc82d

Also noticed the "allows boolean settings to be set to true if specified without a value too" thing only works if the setting is the last param in the list... will need to figure something out for it (E: fixed it, luckily was pretty easy, just made it specifically check for false/0, anything else will be treated as true: https://github.com/emoose/re4_tweaks/commit/1294901d4cfc1999257c7bfd108b30b6ea41d6c3)

E3: ah forgot to add handling for invalid numbers etc, would just crash instead, fixed here: https://github.com/emoose/re4_tweaks/commit/097878bdda071cfda04a862fd17610c286e3b410 Build artifact can be found at https://github.com/emoose/re4_tweaks/actions/runs/2580177997

E4: trying to look into overriding games config.ini settings now, got something working but it's a little messy, gonna try finding a better way.. Also started having a look into how game loads into map etc last night, mapped out some structs for it, but now I tried opening IDA database today and it says it's corrupted 😭 😭 😭 Last backup was 9+ days ago, pour one out for all the functions/structs we lost... (was able to recover 90+ structs from it though luckily, but not sure how many funcs might have gone...)

E: no worries, luckily found that I'd made a hex rays .c file before the corruption, was able to rig something up to compare that against my non-corrupt version, and was eventually able to recover ~40 names 😸

nipkownix commented 2 years ago

Ah, I totally missed this one! Nice work so far.

nipkownix commented 2 years ago

My last commit probably broke a bunch of things in your fork, sorry. But on the bright side, now we have an Utils.cpp :p

emoose commented 2 years ago

Some ideas for more options we could add (besides options that just change existing INI/cfgMenu settings), will also need to try updating the old CmdIniReader stuff above soon too...

Just a param to enable the SkipIntroLogos stuff, I've replaced my dinput8.ini so many times with a vanilla one that doesn't have it set lol, command-line param should be able to help stop it getting overridden. (maybe wouldn't be needed if CmdIniReader stuff can be updated)

Instead of reading game data from BIO4, maybe could add a param that lets you specify a custom folder, so you could have a BIO4 and BIO4_HD next to each other, both sharing the same EXE & re4_tweaks install (or any other modded BIO4 folder), would probably be useful when debugging stuff, no idea how possible this would be though.

Override the "room save flag" used by the rooms RXXXInit function to load/save the state of the room (eg. chests opened, doors opened, etc), might be useful if we could override these flags when loading in with -room rXXX, not sure how possible it is though (also pretty sure there's 0 info about these flags anywhere atm...)

Set difficulty when loading straight into a room, since some mod authors might want to check stuff under different difficulties.

Add given weapon ID to inventory (or replace inventory with a pre-made one), would be useful when testing stuff with -room XX... So eg. you could run the game like -room R302 -weapon 44 -weapon 21 -weapon 55 -weapon 99 to load into R302 with those 4 weapons added. (maybe should add a map of ID -> names somewhere too, not that easy to remember those ID numbers :P)