From d9cff81b63d8f442e2933060a3c723dea41dcf57 Mon Sep 17 00:00:00 2001 From: maru Date: Tue, 31 Oct 2023 08:54:54 -0400 Subject: [PATCH] Update Game_Map GetWidth/GetHeight calls --- src/multiplayer/game_multiplayer.cpp | 32 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/multiplayer/game_multiplayer.cpp b/src/multiplayer/game_multiplayer.cpp index 52ec906cd..59c5af5ae 100644 --- a/src/multiplayer/game_multiplayer.cpp +++ b/src/multiplayer/game_multiplayer.cpp @@ -83,11 +83,11 @@ static bool MovePlayerToPos(Game_PlayerOther& player, int x, int y) { int dy = y - player.GetY(); int adx = abs(dx); int ady = abs(dy); - if (Game_Map::LoopHorizontal() && adx == Game_Map::GetWidth() - 1) { + if (Game_Map::LoopHorizontal() && adx == Gake_Map::GetTilesX() - 1) { dx = dx > 0 ? -1 : 1; adx = 1; } - if (Game_Map::LoopVertical() && ady == Game_Map::GetHeight() - 1) { + if (Game_Map::LoopVertical() && ady == Gake_Map::GetTilesY() - 1) { dy = dy > 0 ? -1 : 1; ady = 1; } @@ -269,15 +269,15 @@ void Game_Multiplayer::InitConnection() { connection.RegisterHandler("m", [this] (MovePacket& p) { if (players.find(p.id) == players.end()) return; auto& player = players[p.id]; - int x = Utils::Clamp(p.x, 0, Game_Map::GetWidth() - 1); - int y = Utils::Clamp(p.y, 0, Game_Map::GetHeight() - 1); + int x = Utils::Clamp(p.x, 0, Gake_Map::GetTilesX() - 1); + int y = Utils::Clamp(p.y, 0, Gake_Map::GetTilesY() - 1); player.mvq.emplace_back(x, y); }); connection.RegisterHandler("jmp", [this] (JumpPacket& p) { if (players.find(p.id) == players.end()) return; auto& player = players[p.id]; - int x = Utils::Clamp(p.x, 0, Game_Map::GetWidth() - 1); - int y = Utils::Clamp(p.y, 0, Game_Map::GetHeight() - 1); + int x = Utils::Clamp(p.x, 0, Gake_Map::GetTilesX() - 1); + int y = Utils::Clamp(p.y, 0, Gake_Map::GetTilesY() - 1); auto rc = player.ch->Jump(x, y); if (rc) { player.ch->SetMaxStopCount(player.ch->GetMaxStopCountForStep(player.ch->GetMoveFrequency())); @@ -342,24 +342,24 @@ void Game_Multiplayer::InitConnection() { int ox = player.ch->GetX(); int oy = player.ch->GetY(); - int hmw = Game_Map::GetWidth() / 2; - int hmh = Game_Map::GetHeight() / 2; + int hmw = Gake_Map::GetTilesX() / 2; + int hmh = Gake_Map::GetTilesY() / 2; int rx; int ry; if (Game_Map::LoopHorizontal() && px - ox >= hmw) { - rx = Game_Map::GetWidth() - (px - ox); + rx = Gake_Map::GetTilesX() - (px - ox); } else if (Game_Map::LoopHorizontal() && px - ox < hmw * -1) { - rx = Game_Map::GetWidth() + (px - ox); + rx = Gake_Map::GetTilesX() + (px - ox); } else { rx = px - ox; } if (Game_Map::LoopVertical() && py - oy >= hmh) { - ry = Game_Map::GetHeight() - (py - oy); + ry = Gake_Map::GetTilesY() - (py - oy); } else if (Game_Map::LoopVertical() && py - oy < hmh * -1) { - ry = Game_Map::GetHeight() + (py - oy); + ry = Gake_Map::GetTilesY() + (py - oy); } else { ry = py - oy; } @@ -381,13 +381,13 @@ void Game_Multiplayer::InitConnection() { auto modify_args = [] (PicturePacket& pa) { if (Game_Map::LoopHorizontal()) { - int alt_map_x = pa.map_x + Game_Map::GetWidth() * TILE_SIZE * TILE_SIZE; + int alt_map_x = pa.map_x + Gake_Map::GetTilesX() * TILE_SIZE * TILE_SIZE; if (std::abs(pa.map_x - Game_Map::GetPositionX()) > std::abs(alt_map_x - Game_Map::GetPositionX())) { pa.map_x = alt_map_x; } } if (Game_Map::LoopVertical()) { - int alt_map_y = pa.map_y + Game_Map::GetHeight() * TILE_SIZE * TILE_SIZE; + int alt_map_y = pa.map_y + Gake_Map::GetTilesY() * TILE_SIZE * TILE_SIZE; if (std::abs(pa.map_y - Game_Map::GetPositionY()) > std::abs(alt_map_y - Game_Map::GetPositionY())) { pa.map_y = alt_map_y; } @@ -830,7 +830,7 @@ void Game_Multiplayer::Update() { if (x == x2) { int y2 = ch2->GetY(); if (y == 0) { - if (Game_Map::LoopVertical() && y2 == Game_Map::GetHeight() - 1) { + if (Game_Map::LoopVertical() && y2 == Gake_Map::GetTilesY() - 1) { overlap = true; break; } @@ -844,7 +844,7 @@ void Game_Multiplayer::Update() { auto& player = Main_Data::game_player; if (x == player->GetX()) { if (y == 0) { - if (Game_Map::LoopVertical() && player->GetY() == Game_Map::GetHeight() - 1) { + if (Game_Map::LoopVertical() && player->GetY() == Gake_Map::GetTilesY() - 1) { overlap = true; } } else if (player->GetY() == y - 1) {