mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2025-12-17 01:21:49 +01:00
Add alot of memory leak fixes
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "pch.h"
|
||||
#include "WorldGridManager.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "WorldTile.h"
|
||||
@@ -14,8 +15,29 @@ WorldGridManager::WorldGridManager() {
|
||||
|
||||
}
|
||||
WorldGridManager::~WorldGridManager() {
|
||||
for (size_t x { 0 }; x < WORLD_WIDTH; ++x) {
|
||||
for (size_t y { 0 }; y < WORLD_HEIGHT; ++y) {
|
||||
delete m_worldTiles[x][y];
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "Deleting static" << std::endl;
|
||||
delete Tiles::AIR;
|
||||
delete Tiles::DIRT;
|
||||
|
||||
delete Tiles::Hazards::LAVA;
|
||||
delete Tiles::Hazards::STONE;
|
||||
|
||||
delete Tiles::Ores::BRONZE;
|
||||
delete Tiles::Ores::GOLD;
|
||||
delete Tiles::Ores::IRON;
|
||||
|
||||
delete Tiles::Special::GRASS;
|
||||
delete Tiles::Special::HARD_LEFT;
|
||||
delete Tiles::Special::HARD_MIDDLE;
|
||||
delete Tiles::Special::HARD_RIGHT;
|
||||
}
|
||||
|
||||
surroundingTiles WorldGridManager::GetSurroundingTiles(const WorldTile* world_tile) {
|
||||
surroundingTiles tiles;
|
||||
Vector2f pos = world_tile->GetPosition();
|
||||
|
||||
@@ -72,6 +72,4 @@ public:
|
||||
|
||||
private:
|
||||
std::array<std::array<WorldTile *, WORLD_WIDTH>, WORLD_HEIGHT> m_worldTiles;
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -33,6 +33,10 @@ GroundTileType* getRandomGroundTile() {
|
||||
// This should never be reached if weights sum to 1.0
|
||||
return Tiles::AIR; // Default value
|
||||
}
|
||||
// void InitializeGroundTiles() {
|
||||
//
|
||||
// Tiles::AIR = new GroundTileType("", GroundTileTypes::Air);
|
||||
// }
|
||||
WorldTile::WorldTile(const Vector2f& position, GroundTileType* groundTileType, TextureManager* pTextureManager, WorldGridManager* pGridManager) : m_Position { position }, m_GroundTileType { groundTileType }, m_pGridManager { pGridManager } {
|
||||
// const std::string dirtPath = + "tiles/dirt/dirt" + std::to_string(utils::randRange(1, 5)) + ".png";
|
||||
// m_pTexture = new Texture(dirtPath);
|
||||
@@ -52,7 +56,6 @@ WorldTile::WorldTile(const Vector2f& position, GroundTileType* groundTileType, T
|
||||
m_pAllTexture = pTextureManager->GetTexture("tiles/dirt/sidepieces/all.png");
|
||||
}
|
||||
WorldTile::~WorldTile() {
|
||||
delete m_pTexture;
|
||||
}
|
||||
void WorldTile::Draw() {
|
||||
|
||||
|
||||
@@ -150,6 +150,8 @@ static std::map<GroundTileType *, float> GroundTileWeights {
|
||||
{ Tiles::Ores::IRON, 0.1f },
|
||||
};
|
||||
|
||||
void InitializeGroundTiles();
|
||||
|
||||
class WorldTile
|
||||
{
|
||||
public:
|
||||
@@ -197,7 +199,7 @@ private:
|
||||
|
||||
surroundingTiles m_SurroundingTiles;
|
||||
|
||||
std::vector<Texture *> m_SideTextures { 8, nullptr };
|
||||
std::vector<Texture*> m_SideTextures { 8, nullptr };
|
||||
|
||||
Texture* m_pAllTexture;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user