From 587d611dc8749d3c1e7c8d23c93e5780a7ac9f46 Mon Sep 17 00:00:00 2001 From: Persson-dev Date: Sun, 10 Oct 2021 12:24:27 +0200 Subject: [PATCH] refactor: removed obsolete map creation code --- src/game/World.cpp | 216 --------------------------------------------- 1 file changed, 216 deletions(-) diff --git a/src/game/World.cpp b/src/game/World.cpp index 6c6765e..5a6832d 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -60,7 +60,6 @@ bool World::loadMap(const protocol::WorldDataPacket* worldData) { } bool World::loadMapFromFile(const std::string& fileName) { -#if !WRITE_MAP DataBuffer buffer; if (!buffer.ReadFile(fileName)) { std::cerr << "Failed to load map from file " << fileName << " !\n"; @@ -87,221 +86,6 @@ bool World::loadMapFromFile(const std::string& fileName) { loadMap(&dataPacket); return true; - -#else - m_WalkablePalette = { 102, 102, 153 }; - - m_TowerPlacePalette[0] = { 204, 51, 0 }; - m_TowerPlacePalette[1] = { 255, 153, 0 }; - - WalkableTile walkableTileDown; // 1 - walkableTileDown.direction = Direction::PositiveY; - m_TilePalette.push_back(std::make_shared(walkableTileDown)); - - WalkableTile walkableTileUp; // 2 - walkableTileUp.direction = Direction::NegativeY; - m_TilePalette.push_back(std::make_shared(walkableTileUp)); - - WalkableTile walkableTileLeft; // 3 - walkableTileLeft.direction = Direction::NegativeX; - m_TilePalette.push_back(std::make_shared(walkableTileLeft)); - - WalkableTile walkableTileRight; // 4 - walkableTileRight.direction = Direction::PositiveX; - m_TilePalette.push_back(std::make_shared(walkableTileRight)); - - TowerTile redTile0; // 5 - redTile0.color_palette_ref = 0; - redTile0.team_owner = TeamColor::Red; - m_TilePalette.push_back(std::make_shared(redTile0)); - - TowerTile redTile1; // 6 - redTile1.color_palette_ref = 1; - redTile1.team_owner = TeamColor::Red; - m_TilePalette.push_back(std::make_shared(redTile1)); - - TowerTile blueTile0; // 7 - blueTile0.color_palette_ref = 0; - blueTile0.team_owner = TeamColor::Blue; - m_TilePalette.push_back(std::make_shared(blueTile0)); - - TowerTile blueTile1; // 8 - blueTile1.color_palette_ref = 1; - blueTile1.team_owner = TeamColor::Blue; - m_TilePalette.push_back(std::make_shared(blueTile1)); - - getRedTeam().getCastle().x = 58; - getRedTeam().getCastle().y = 43; - - getRedTeam().getSpawn().x = 13; - getRedTeam().getSpawn().y = 13; - getRedTeam().getSpawn().direction = Direction::PositiveY; - - m_SpawnColorPalette[(unsigned int)TeamColor::Red] = { 255, 0, 0 }; - - //Chunks - - Chunk chunk0; - for (int i = 0; i <= 6; i++) { - chunk0.palette.push_back(i); - } - chunk0.tiles = { - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,5,5,6,6,6,5,5,5,6,6,6,5,5,5,6, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,5,5,6,6,6,5,5,5,6,6,6,5,5,5,6, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,5,5,6,6,6,5,5,5,6,6,6,5,5,5,6, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,6,6,5,5,5,6,6,6,5,5,5,6,6,6,5, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,6,6,5,5,5,6,6,6,5,5,5,6,6,6,5, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,6,6,5,5,5,6,6,6,5,5,5,6,6,6,5, - 0,0,0,0,0,0,6,5,6,5,6,0,0,0,0,0,5,5,5,4,4,4,4,4,4,4,4,4,4,4,4,4, - 0,0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,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - }; - - m_Chunks.insert({ {0, 0}, std::make_shared(chunk0) }); - m_Chunks.insert({ {1, 0}, std::make_shared(chunk1) }); - m_Chunks.insert({ {1, 1}, std::make_shared(chunk2) }); - - - // blue map = same but with offset of 64 (in x coordinate) - - getBlueTeam().getCastle().x = 58 + 64; - getBlueTeam().getCastle().y = 43; - - getBlueTeam().getSpawn().x = 13 + 64; - getBlueTeam().getSpawn().y = 13; - getBlueTeam().getSpawn().direction = Direction::PositiveY; - - m_SpawnColorPalette[(unsigned int)TeamColor::Blue] = { 0, 0, 255 }; - - Chunk chunk01; - chunk01.palette = { 0, 1, 2, 3, 4, 7, 8 }; - - chunk01.tiles = chunk0.tiles; // the tiles indicies are the same, only the palette has changed - - - Chunk chunk11; - chunk11.palette = { 0, 1, 2, 3, 4, 7, 8 }; - - chunk11.tiles = chunk1.tiles; // the tiles indicies are the same, only the palette has changed - - - Chunk chunk21; - chunk21.palette = { 0, 1, 2, 3, 4, 7, 8 }; - - chunk21.tiles = chunk2.tiles; // the tiles indicies are the same, only the palette has changed - - m_Chunks.insert({ {2, 0}, std::make_shared(chunk01) }); - m_Chunks.insert({ {3, 0}, std::make_shared(chunk11) }); - m_Chunks.insert({ {3, 1}, std::make_shared(chunk21) }); - - return saveMap("tdmap_debug.tdmap"); -#endif - } bool World::saveMap(const std::string& fileName) const {