Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete critter from combat during _partyFixMultipleMembers #277

Merged
merged 3 commits into from
May 24, 2023

Conversation

roginvs
Copy link
Contributor

@roginvs roginvs commented Apr 29, 2023

This PR fixes an issue when we load a game with party member list, then add those critters into AI lists and then unallocate those objects.

Original game works fine but CE was crashing. Now it works.

@alexbatalov
Copy link
Owner

Do you have a failing save game so I can check why original game works?

@roginvs
Copy link
Contributor Author

roginvs commented Apr 30, 2023

I use Fallout: Nevada from Foxx 2.4.1 (https://vk.com/rebuild_by_foxx?w=wall-174451664_4921). Load this savegame SLOT10 Battle 1.tar.gz and attack someone.

NEVADA_FE.exe works even without SFall

@alexbatalov
Copy link
Owner

I've checked this save, there are no party members, so I cannot reproduce it. Do you have other failing save?

@roginvs
Copy link
Contributor Author

roginvs commented May 22, 2023

Did you actually tried to run it on Fallout Nevada or just inspected this save file? Here is a screenshot from debugging session. I took fresh install of Naveda from Foxx (link above), unpacked save game, compiled fallout2-ce from 2565900 (latest commit on this repository) and made a breakpoint

image

@alexbatalov
Copy link
Owner

This is an interesting case. First of all it does work on 2.0.3.3 (that's why I was not able to replicate it), but it crashes on 2.4.1, because there are changes in party.txt (more party members).

The real problem is the function itself, I've incorrectly decompiled in the first place. As you've already noted there is no such bug in the original game.

When an object is deleted, its node is dealloced. Iteration's gObjectFindLastObjectListNode becomes a dangling pointer. Which leads to a crash when objectFindNext is called. This behaviour is compiler-dependent, that's why simple _combat_delete_critter did the trick for you on Linux (I've checked on macOS and it also worked, but crashed on Windows where freed memory is immediately filled with 0xDDDDDDDD).

combat_delete_critter is indeed needed and in fact it is present in other places (primarily in scripting) where we're killing or otherwise destroying critters. combatai_delete_critter is called inside combat_delete_critter and therefore redundant.

@roginvs
Copy link
Contributor Author

roginvs commented May 24, 2023

Very good explanation, thanks!

@alexbatalov alexbatalov merged commit 70b0b61 into alexbatalov:main May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants