sfall-team / sfall

sfall - Engine modifications for Fallout 2
https://sfall-team.github.io/sfall/
GNU General Public License v3.0
338 stars 40 forks source link

Car trunk proto gets reset on map change #547

Closed phobos2077 closed 1 month ago

phobos2077 commented 1 month ago

Caused by this commit: https://github.com/sfall-team/sfall/commit/6d432163ca8f5f7586093c31e712814b4ed85952.

To reproduce

  1. Clean RPU v29 installation.
  2. Update sfall to latest master ReleaseXP build.
  3. Create, compile and add following gl_test script to data/scripts folder:
#define DEFINE_METARULE_SET_CAR_CARRY_AMOUNT 52
#define set_car_carry_amount(VALUE)   metarule(DEFINE_METARULE_SET_CAR_CARRY_AMOUNT, VALUE)
#define DEFINE_METARULE_GET_CAR_CARRY_AMOUNT 53
#define car_carry_amount   metarule(DEFINE_METARULE_GET_CAR_CARRY_AMOUNT, 0)

procedure map_enter_p_proc begin
   display_msg("Car trunk size: " + car_carry_amount);
end

procedure start begin
   if not game_loaded then return;

   display_msg("Set super car truck size.");
   set_car_carry_amount((110 * car_carry_amount) / 100);
   display_msg("Car trunk size: " + car_carry_amount);
end
  1. Start a new game, take Narg.
  2. Enter the Temple.

Expected result

The log shows:

Set super car truck size.
Car trunk size: 275
...
Car trunk size: 275

Actual result:

The log shows:

Set super car truck size.
Car trunk size: 275
...
Car trunk size: 250
phobos2077 commented 1 month ago

Sometimes after sfall rebuild, it doesn't happen. But it should reproduce with this build from my drag skip branch: https://drive.google.com/file/d/12Q1IV9UeTHxlZhir48_8q5H-QRjAL6tm/view?usp=sharing

A fresh rebuild from the exact same source shows 1 byte diff from that dll with the bug. I've no idea what that is.

phobos2077 commented 1 month ago

This is insane, but I think it's a bug with Visual Studio. I tracked down the 1 byte diff to JG (7F) vs JNE (75) instructions in one of the hooks. I tested it by changing jg to jne, compiling the dll and seeing no change in binary comparison vs other build (with Beyond Compare).

Did a "clean build" and fresh rebuild - the dll diff got huge. Seems like VS doesn't "see" some changes in ASM code when doing incremental build.

phobos2077 commented 1 month ago

This clean rebuild doesn't trigger the issue. So it seems it was on my end after all. Closing.