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

Memory fixes, high number of savegame slot fixes, and requestor fixes and rework #1389

Closed
wants to merge 2 commits into from

Conversation

walkawayy
Copy link
Collaborator

@walkawayy walkawayy commented Jun 24, 2024

Checklist

  • I have read the coding conventions
  • I have added a changelog entry about what my pull request accomplishes, or it is an internal change

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 the item_texts to be safer.

The 64 slot limit was fixed by reworking the GAMEFLOW_OPTIONs 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. The TEX_INFO *info = Memory_Alloc(sizeof(TEX_INFO)); are never freed, and there is some pointer to malloc'd pointer stuff going on in there.

@walkawayy walkawayy added the TR1X bug A bug with TR1X label Jun 24, 2024
@walkawayy walkawayy added this to the 4.2 milestone Jun 24, 2024
@walkawayy walkawayy requested review from rr- and lahm86 June 24, 2024 02:12
@walkawayy walkawayy self-assigned this Jun 24, 2024
@walkawayy walkawayy changed the title Gameflow rework Memory fixes, high number of savegame slot fixes, and requestor rework Jun 24, 2024
@walkawayy walkawayy changed the title Memory fixes, high number of savegame slot fixes, and requestor rework Memory fixes, high number of savegame slot fixes, and requestor fixes and rework Jun 24, 2024
Copy link
Collaborator

@rr- rr- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's break this into smaller PRs – one for the requestor changes; one for gameflow changes; one for the memory leaks that can be merged immediately.

src/global/types.h Show resolved Hide resolved
src/game/phase/phase_pause.h Show resolved Hide resolved
@walkawayy walkawayy added Invalid This doesn't seem right and removed TR1X bug A bug with TR1X labels Jun 27, 2024
@walkawayy walkawayy marked this pull request as draft June 27, 2024 02:15
@walkawayy walkawayy closed this Jul 2, 2024
@walkawayy walkawayy deleted the gameflow-rework branch July 25, 2024 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Invalid This doesn't seem right
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants