BGforgeNet / Fallout2_Restoration_Project

Fallout 2 Restoration Project, updated
https://forums.bgforge.net/viewforum.php?f=39
542 stars 37 forks source link

Fix VC Entrance_Door_Ptr #260

Closed ptuchster closed 4 months ago

ptuchster commented 6 months ago

Fix an annoying crash with a kind of "An illegal instruction was executed at address ..." when entering Vault City (may be other locations too, but this is the first I faced during my play).

Background: The error bothers a lot of players, but seems tweakable for Windows users. For Mac/Linux wine players, this is not an option.

Debug of the crash:

...
Error during execution: External variable Entrance_Door_Ptr does not exist

Current script: scripts\vientdor.int, procedure map_update_p_proc

I'm not a fallout resource expert, but looks like the problem was with the lack of exporting this var. I have started with Fallout Explorer (or something cheat) to move the dude to the Vault City Downtown. This worked. But every time I tried to enter the courtyard, the game crashed. After a quick src examination, the solution came up. Built and tested through GitHub actions, no more errors for VC.

Tested on Fallout 2 GOG 1.02d RP 2.3.3u28 sfall 4.4.0.1

mods (pretty standard for clean gog + RP installation through exe):

cassidy_head.dat
cassidy_voice_joey_bracken_hq.dat
f2_res.dat
npc_armor.dat
party_orders.dat
rpu.dat
rpu_enhanced_worldmap.dat
rpu_extended_flamer.dat
rpu_improved_mysterious_stranger.dat
rpu_rifle_animations.dat
rpu_wakizashi_animations.dat

Runtime: mac on m2 crossover with win10 bottle (crossover uses their own fork of wine, so results can be different for vanilla wine)

The only problem observed is that if I try to load fo2tweaks.dat and healing_revision enabled, this will crash with an error in the corresponding global script. But this is another story.

UPD:

One more similar bug was found for the Abbey entrance and included in this PR. After that, I checked all the cities available. Seems no more problems like this. Only one, not related to the original problem, with the village between VC and Gecko (I don't remember it in the original game.), and yet have no idea about the nature of this error in the context of the game, probably one of the mod problem again:

Script Error: scripts\bcdalia.int: op_elevation: obj is NULLScript Error: scripts\bcdalia.int: op_critter_add_trait: obj is NULLScript Error: scripts\bcdalia.int: op_critter_add_trait: obj is NULLScript Error: scripts\vcgenvil.int: op_tile_num: obj is NULLScript Error: scripts\vcgenvil.int: op_critter_add_trait: obj is NULLScript Error: scripts\bczeke.int: op_elevation: obj is NULLScript Error: scripts\bczeke.int: op_critter_add_trait: obj is NULLScript Error: scripts\bczeke.int: op_critter_add_trait: obj is NULLScript Error: scripts\vcgenvil.int: op_tile_num: obj is NULLScript Error: scripts\vcgenvil.int: op_critter_add_trait: obj is NULLScript Error: scripts\vcgenvil.int: op_tile_num: obj is NULLScript Error: scripts\vcgenvil.int: op_critter_add_trait: obj is NULLScript Error: scripts\vcconnar.int: op_critter_add_trait: obj is NULLScript Error: scripts\vcconnar.int: op_critter_attempt_placement: obj is NULL
Error during execution: 
Stack underflow short.
Current script: scripts\vcconnar.int, procedure map_enter_p_proc
burner1024 commented 6 months ago

Interesting, but I'm also on Linux and could not reproduce the linked issue. Do you have a savegame and a sure way to reproduce, for posterity?

ptuchster commented 6 months ago

@burner1024 Here you are, you can try, but looks like this is a crossover wine issue πŸ€·πŸ»β€β™‚οΈ This save: finish start trial, and just moved char over VC. If you are using f2tweaks - W + enter city (without it you have to move classic way. Let me create new one on next tile on map). My original setup without those changes crashes. With the new build everything ok.

SLOT07.zip

ptuchster commented 6 months ago

@burner1024 this one is easier and can be used without the f2tweaks.

SLOT07.zip

burner1024 commented 5 months ago

Still no crash for me. I do see Error during execution: External variable Entrance_Door_Ptr does not exist in the log when entering VC courtyard.

There is also

Script Error: scripts\vientdor.int: op_add_timer_event: pobj is NULL!Script Error: scripts\vientdor.int: op_obj_close: obj is NULLScript Error: scripts\vientdor.int: op_obj_lock: obj is NULL
Script Error: scripts\vientdor.int: op_add_timer_event: pobj is NULL!

This is quite strange. vientdor is the downtown door.

$ grep -R Entrance_Door_Ptr scripts_src/
scripts_src/valtcity/vientdor.ssl:import variable Entrance_Door_Ptr;
scripts_src/valtcity/vientdor.ssl:   Entrance_Door_Ptr:=self_obj;
scripts_src/valtcity/vcgatgrd.ssl:import variable Entrance_Door_Ptr;
scripts_src/valtcity/vcgatgrd.ssl:   if ( ( not( obj_is_open( Entrance_Door_Ptr ) ) ) and
scripts_src/valtcity/vcgatgrd.ssl:       obj_unlock(Entrance_Door_Ptr);
scripts_src/valtcity/vcgatgrd.ssl:       obj_open(Entrance_Door_Ptr);
scripts_src/valtcity/vcgatgrd.ssl:   else if ( ( obj_is_open( Entrance_Door_Ptr ) ) and
scripts_src/valtcity/vcgatgrd.ssl:       obj_unlock(Entrance_Door_Ptr);
scripts_src/valtcity/vcgatgrd.ssl:       obj_close(Entrance_Door_Ptr);
scripts_src/valtcity/vcgatgrd.ssl:        obj_unlock( Entrance_Door_Ptr );
scripts_src/valtcity/vcgatgrd.ssl:        obj_open( Entrance_Door_Ptr );
scripts_src/valtcity/vcgatgrd.ssl:        rm_timer_event( Entrance_Door_Ptr );
scripts_src/valtcity/vcgatgrd.ssl:        add_timer_event(Entrance_Door_Ptr,game_ticks(10),1);
scripts_src/valtcity/vcgatgrd.ssl:   obj_close( Entrance_Door_Ptr );
scripts_src/valtcity/vcgatgrd.ssl:   obj_lock( Entrance_Door_Ptr );
scripts_src/valtcity/vcgatgrd.ssl:   obj_close( Entrance_Door_Ptr );
scripts_src/valtcity/vcgatgrd.ssl:   obj_lock( Entrance_Door_Ptr );
scripts_src/valtcity/vcgatgrd.ssl:   obj_close( Entrance_Door_Ptr );
scripts_src/valtcity/vcgatgrd.ssl:   obj_lock( Entrance_Door_Ptr );
scripts_src/valtcity/vcgatgrd.ssl:   obj_close( Entrance_Door_Ptr );
scripts_src/valtcity/vcgatgrd.ssl:   obj_lock( Entrance_Door_Ptr );
scripts_src/valtcity/vcgatgrd.ssl:   obj_close( Entrance_Door_Ptr );
scripts_src/valtcity/vcgatgrd.ssl:   obj_lock( Entrance_Door_Ptr );
scripts_src/valtcity/vcgatgrd.ssl:   obj_close( Entrance_Door_Ptr );
scripts_src/valtcity/vcgatgrd.ssl:   obj_lock( Entrance_Door_Ptr );
scripts_src/valtcity/vcgatgrd.ssl:   obj_close( Entrance_Door_Ptr );
scripts_src/valtcity/vcgatgrd.ssl:   obj_lock( Entrance_Door_Ptr );
scripts_src/sierra/wientdor.ssl:import variable Entrance_Door_Ptr;
scripts_src/sierra/wientdor.ssl:   Entrance_Door_Ptr:=self_obj;
scripts_src/sierra/wihowitz.ssl:import variable Entrance_Door_Ptr;
scripts_src/sierra/wihowitz.ssl:   door_tile:=tile_num(Entrance_Door_Ptr);
scripts_src/maps/depolv1.ssl:export variable Entrance_Door_Ptr;
scripts_src/maps/vctydwtn.ssl:export variable Entrance_Door_Ptr;
scripts_src/arroyo/aitemdor.ssl://   Entrance_Door_Ptr:=self_obj;

It is only referenced in vientdor and vcgatgrd (which is the downtown door guard script, vcgatgrd critters are not present in the courtyard).

Somehow vientdor gets called on courtyard area, although it's not present there. I vaguely recall a similar issue but can't find it now. I think it was an improper map file. Maybe vault village one?

ptuchster commented 5 months ago

Again, I am not a resource guru, just want to Play with no errors πŸ˜… But here is another thought: the courtyard door also needs to be guarded. There are some circumstances when you can be exiled from VC forever and can't enter it if I remember correctly. Probably var/script mismatch at first place?

ptuchster commented 5 months ago

Another thought: I saw that vc courtyard script says β€œ Map Script for Sierra Army Base, Outside area”. Probably copy paste problem, and unneccesarry initialize left somewhere?

burner1024 commented 5 months ago

The outer gate is never locked, but there are circumstances when its guards will shoot on sight. Copy paste is annoying, but doesn't look like it's the problem here. Let's keep this open, it needs more investigating.

ptuchster commented 5 months ago

Found one more similar issue with the 2nd location of NCR

burner1024 commented 4 months ago
  1. The issue is caused by "ghost" objects in corresponding .map file. It's not visible in normal map editor, and I'm not sure how'd they get there. Maybe a bug in the original Mapper, or someone used DIMS mapper, or even hex editor?
  2. Because it's not visible in Mapper, it's not easy to clean it from the map file.
  3. Also not clear why it causes crashes on some systems and doesn't on others.
  4. I'm pretty sure there are more cases like this.
  5. I had hoped to do a systemic sweep by utilizing Kaitai to describe .map file format, verify all data, and set up automatic tests as well. Unfortunately, Kaitai only supports deserialization, and I didn't find a solid alternative supporting both deserialization and serialization. Additionally, .map turned out to be quite convoluted. While it's still something I'd like to have, for the time being workarounds will have to suffice.
  6. Thank you for the PR.
RomanTruba commented 4 months ago

Seems like I faced it in #268