refactor: removed obsolete map creation code
This commit is contained in:
@@ -60,7 +60,6 @@ bool World::loadMap(const protocol::WorldDataPacket* worldData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool World::loadMapFromFile(const std::string& fileName) {
|
bool World::loadMapFromFile(const std::string& fileName) {
|
||||||
#if !WRITE_MAP
|
|
||||||
DataBuffer buffer;
|
DataBuffer buffer;
|
||||||
if (!buffer.ReadFile(fileName)) {
|
if (!buffer.ReadFile(fileName)) {
|
||||||
std::cerr << "Failed to load map from file " << fileName << " !\n";
|
std::cerr << "Failed to load map from file " << fileName << " !\n";
|
||||||
@@ -87,221 +86,6 @@ bool World::loadMapFromFile(const std::string& fileName) {
|
|||||||
loadMap(&dataPacket);
|
loadMap(&dataPacket);
|
||||||
|
|
||||||
return true;
|
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<WalkableTile>(walkableTileDown));
|
|
||||||
|
|
||||||
WalkableTile walkableTileUp; // 2
|
|
||||||
walkableTileUp.direction = Direction::NegativeY;
|
|
||||||
m_TilePalette.push_back(std::make_shared<WalkableTile>(walkableTileUp));
|
|
||||||
|
|
||||||
WalkableTile walkableTileLeft; // 3
|
|
||||||
walkableTileLeft.direction = Direction::NegativeX;
|
|
||||||
m_TilePalette.push_back(std::make_shared<WalkableTile>(walkableTileLeft));
|
|
||||||
|
|
||||||
WalkableTile walkableTileRight; // 4
|
|
||||||
walkableTileRight.direction = Direction::PositiveX;
|
|
||||||
m_TilePalette.push_back(std::make_shared<WalkableTile>(walkableTileRight));
|
|
||||||
|
|
||||||
TowerTile redTile0; // 5
|
|
||||||
redTile0.color_palette_ref = 0;
|
|
||||||
redTile0.team_owner = TeamColor::Red;
|
|
||||||
m_TilePalette.push_back(std::make_shared<TowerTile>(redTile0));
|
|
||||||
|
|
||||||
TowerTile redTile1; // 6
|
|
||||||
redTile1.color_palette_ref = 1;
|
|
||||||
redTile1.team_owner = TeamColor::Red;
|
|
||||||
m_TilePalette.push_back(std::make_shared<TowerTile>(redTile1));
|
|
||||||
|
|
||||||
TowerTile blueTile0; // 7
|
|
||||||
blueTile0.color_palette_ref = 0;
|
|
||||||
blueTile0.team_owner = TeamColor::Blue;
|
|
||||||
m_TilePalette.push_back(std::make_shared<TowerTile>(blueTile0));
|
|
||||||
|
|
||||||
TowerTile blueTile1; // 8
|
|
||||||
blueTile1.color_palette_ref = 1;
|
|
||||||
blueTile1.team_owner = TeamColor::Blue;
|
|
||||||
m_TilePalette.push_back(std::make_shared<TowerTile>(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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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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,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<Chunk>(chunk0) });
|
|
||||||
m_Chunks.insert({ {1, 0}, std::make_shared<Chunk>(chunk1) });
|
|
||||||
m_Chunks.insert({ {1, 1}, std::make_shared<Chunk>(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<Chunk>(chunk01) });
|
|
||||||
m_Chunks.insert({ {3, 0}, std::make_shared<Chunk>(chunk11) });
|
|
||||||
m_Chunks.insert({ {3, 1}, std::make_shared<Chunk>(chunk21) });
|
|
||||||
|
|
||||||
return saveMap("tdmap_debug.tdmap");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool World::saveMap(const std::string& fileName) const {
|
bool World::saveMap(const std::string& fileName) const {
|
||||||
|
|||||||
Reference in New Issue
Block a user