Skip to content

fix: refactor and clean up code across multiple files - #72

Open
Niravanaa wants to merge 1 commit into
developfrom
fix/memory-leaks
Open

fix: refactor and clean up code across multiple files#72
Niravanaa wants to merge 1 commit into
developfrom
fix/memory-leaks

Conversation

@Niravanaa

Copy link
Copy Markdown
Collaborator

🛠 Proposed Changes:

This PR improves code safety, memory management, and precision by initializing pointers, cleaning up dynamic allocations, refining type usage, and enhancing UI component flexibility.

📝 Details:

  • Updated logging function in Global.h to use localtime_s for safer time handling.
  • Initialized pointers to nullptr in EndScreenState.h, IntroState.h, MainGameState.h, MapEditorState.h, MapSelectState.h, OptionsState.h, and TitleState.h to prevent potential dereferencing of uninitialized pointers.
  • Added destructor to Tower class to manage memory for critterTargettingStrategy.
  • Changed return types of getBuyingCost and getTotalTowersPlaced to const in Tower and TowerGroup classes respectively.
  • Updated ParallaxBackground and ParallaxLayer to use float instead of int for dimensions and positions, improving precision.
  • Removed unnecessary dynamic memory allocations and replaced them with stack allocations where applicable.
  • Cleaned up memory management in various classes, ensuring proper deletion of dynamically allocated objects.
  • Adjusted volume slider constructor to accept float parameters for position.

- Updated logging function in Global.h to use localtime_s for safer time handling.
- Initialized pointers to nullptr in EndScreenState.h, IntroState.h, MainGameState.h, MapEditorState.h, MapSelectState.h, OptionsState.h, and TitleState.h to prevent potential dereferencing of uninitialized pointers.
- Added destructor to Tower class to manage memory for critterTargettingStrategy.
- Changed return types of getBuyingCost and getTotalTowersPlaced to const in Tower and TowerGroup classes respectively.
- Updated ParallaxBackground and ParallaxLayer to use float instead of int for dimensions and positions, improving precision.
- Removed unnecessary dynamic memory allocations and replaced them with stack allocations where applicable.
- Cleaned up memory management in various classes, ensuring proper deletion of dynamically allocated objects.
- Adjusted volume slider constructor to accept float parameters for position.
@Niravanaa Niravanaa self-assigned this Apr 13, 2025
@Niravanaa

Niravanaa commented Apr 13, 2025

Copy link
Copy Markdown
Collaborator Author

One thing to note is that when calling delete critter upon the death or the entry of a critter at the exit of the map, certain critters are spawned with different sprite animations overlayed.

For example, the FastCritter, which should just be a bee, has the slime texture rendered under-neath it in wave 2 .

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.

1 participant