Memory fixes, high number of savegame slot fixes, and requestor fixes and rework #1389
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Checklist
Description
This PR fixes memory issues that occurred with savegames as well as a 64 savegame slot limit due to
int32_t gf_param = gf_option & ((1 << 6) - 1);
which was due to the bitflow operations in the gameflow. There is a second small commit to fix two small memory leaks in the gameflow as well.The memory leak occurred if the number of savegame slots was over 16. Requestor's
item_flags
max value was 16 which was less than the default savegame amount in TR1X. Reworked much of the requestor code to account for this. Also reworked theitem_texts
to be safer.The 64 slot limit was fixed by reworking the
GAMEFLOW_OPTION
s to no longer use bit shifting. This PR introduces a new gameflow info struct that contains that information. It's a new global struct and changed the phasers, so they don't return. But it seemed necessary since some of the issue was only being able to return one value.This will need heavily tested, but lmk if you think the code changes look good before I ask for testing help. I'm surprised we didn't have more issues reported because the memory was severely corrupted. Maybe it only really showed up badly when I started testing with a really high number of savegames.
Also, there is a memory leak in
packer.c
, but I was unable to fix it. TheTEX_INFO *info = Memory_Alloc(sizeof(TEX_INFO));
are never freed, and there is some pointer to malloc'd pointer stuff going on in there.