diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index a29d1c8f..2cd0b786 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -124,7 +124,6 @@ void Game::init(void) teleport = false; edteleportent = 0; //Added in the port! companion = 0; - roomchange = false; quickrestartkludge = false; diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index 2218d386..2de449b5 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -384,7 +384,6 @@ public: float inertia; int companion; - bool roomchange; SDL_Rect teleblock; bool activetele; int readytotele; diff --git a/desktop_version/src/Logic.cpp b/desktop_version/src/Logic.cpp index 4b1fe3cb..b25df018 100644 --- a/desktop_version/src/Logic.cpp +++ b/desktop_version/src/Logic.cpp @@ -120,9 +120,19 @@ void gamecompletelogic2(void) } } +static void gotoroom_wrapper(const int rx, const int ry) +{ + map.gotoroom(rx, ry); +} void gamelogic(void) { + bool roomchange = false; +#define GOTOROOM(rx, ry) \ + gotoroom_wrapper(rx, ry); \ + roomchange = true +#define gotoroom Do not use map.gotoroom directly. + /* Update old lerp positions of entities */ {size_t i; for (i = 0; i < obj.entities.size(); ++i) { @@ -1129,13 +1139,13 @@ void gamelogic(void) if (INBOUNDS_VEC(player, obj.entities) && game.door_down > -2 && obj.entities[player].yp >= 238) { obj.entities[player].yp -= 240; - map.gotoroom(game.roomx, game.roomy + 1); + GOTOROOM(game.roomx, game.roomy + 1); screen_transition = true; } if (INBOUNDS_VEC(player, obj.entities) && game.door_up > -2 && obj.entities[player].yp < -2) { obj.entities[player].yp += 240; - map.gotoroom(game.roomx, game.roomy - 1); + GOTOROOM(game.roomx, game.roomy - 1); screen_transition = true; } } @@ -1147,13 +1157,13 @@ void gamelogic(void) if (INBOUNDS_VEC(player, obj.entities) && game.door_left > -2 && obj.entities[player].xp < -14) { obj.entities[player].xp += 320; - map.gotoroom(game.roomx - 1, game.roomy); + GOTOROOM(game.roomx - 1, game.roomy); screen_transition = true; } if (INBOUNDS_VEC(player, obj.entities) && game.door_right > -2 && obj.entities[player].xp >= 308) { obj.entities[player].xp -= 320; - map.gotoroom(game.roomx + 1, game.roomy); + GOTOROOM(game.roomx + 1, game.roomy); screen_transition = true; } } @@ -1168,13 +1178,13 @@ void gamelogic(void) if (INBOUNDS_VEC(player, obj.entities) && game.door_left > -2 && obj.entities[player].xp < -14) { obj.entities[player].xp += 320; - map.gotoroom(48, 52); + GOTOROOM(48, 52); } if (INBOUNDS_VEC(player, obj.entities) && game.door_right > -2 && obj.entities[player].xp >= 308) { obj.entities[player].xp -= 320; obj.entities[player].yp -= (71*8); - map.gotoroom(game.roomx + 1, game.roomy+1); + GOTOROOM(game.roomx + 1, game.roomy+1); } } else @@ -1187,18 +1197,18 @@ void gamelogic(void) { obj.entities[player].xp += 320; obj.entities[player].yp -= (71 * 8); - map.gotoroom(50, 54); + GOTOROOM(50, 54); } else { obj.entities[player].xp += 320; - map.gotoroom(50, 53); + GOTOROOM(50, 53); } } if (INBOUNDS_VEC(player, obj.entities) && game.door_right > -2 && obj.entities[player].xp >= 308) { obj.entities[player].xp -= 320; - map.gotoroom(52, 53); + GOTOROOM(52, 53); } } } @@ -1229,12 +1239,12 @@ void gamelogic(void) { obj.entities[player].xp += 320; obj.entities[player].yp -= (671 * 8); - map.gotoroom(108, 109); + GOTOROOM(108, 109); } if (INBOUNDS_VEC(player, obj.entities) && game.door_right > -2 && obj.entities[player].xp >= 308) { obj.entities[player].xp -= 320; - map.gotoroom(110, 104); + GOTOROOM(110, 104); } } } @@ -1268,7 +1278,7 @@ void gamelogic(void) { obj.entities[i].yp = 225; } - map.gotoroom(119, 100); + GOTOROOM(119, 100); game.teleport = false; } else if (game.roomx == 119 && game.roomy == 100) @@ -1278,7 +1288,7 @@ void gamelogic(void) { obj.entities[i].yp = 225; } - map.gotoroom(119, 103); + GOTOROOM(119, 103); game.teleport = false; } else if (game.roomx == 119 && game.roomy == 103) @@ -1288,7 +1298,7 @@ void gamelogic(void) { obj.entities[i].xp = 0; } - map.gotoroom(116, 103); + GOTOROOM(116, 103); game.teleport = false; } else if (game.roomx == 116 && game.roomy == 103) @@ -1298,7 +1308,7 @@ void gamelogic(void) { obj.entities[i].yp = 225; } - map.gotoroom(116, 100); + GOTOROOM(116, 100); game.teleport = false; } else if (game.roomx == 116 && game.roomy == 100) @@ -1308,7 +1318,7 @@ void gamelogic(void) { obj.entities[i].xp = 0; } - map.gotoroom(114, 102); + GOTOROOM(114, 102); game.teleport = false; } else if (game.roomx == 114 && game.roomy == 102) @@ -1318,7 +1328,7 @@ void gamelogic(void) { obj.entities[i].yp = 225; } - map.gotoroom(113, 100); + GOTOROOM(113, 100); game.teleport = false; } else if (game.roomx == 116 && game.roomy == 104) @@ -1401,10 +1411,9 @@ void gamelogic(void) } } - if (game.roomchange) + if (roomchange) { //We've changed room? Let's bring our companion along! - game.roomchange = false; int i = obj.getplayer(); if (game.companion > 0 && INBOUNDS_VEC(i, obj.entities)) { @@ -1644,4 +1653,7 @@ void gamelogic(void) if (game.teleport_to_new_area) script.teleport(); + +#undef gotoroom +#undef GOTOROOM } diff --git a/desktop_version/src/Map.cpp b/desktop_version/src/Map.cpp index 09d2cd93..88ae3428 100644 --- a/desktop_version/src/Map.cpp +++ b/desktop_version/src/Map.cpp @@ -967,7 +967,6 @@ void mapclass::gotoroom(int rx, int ry) //Ok, what way are we moving? game.roomx = rx; game.roomy = ry; - game.roomchange = true; if (game.roomy < 10) { @@ -994,7 +993,6 @@ void mapclass::gotoroom(int rx, int ry) { game.roomx = rx; game.roomy = ry; - game.roomchange = true; if (game.roomx < 100) game.roomx = 100 + ed.mapwidth-1; if (game.roomy < 100) game.roomy = 100 + ed.mapheight-1; if (game.roomx > 100 + ed.mapwidth-1) game.roomx = 100; @@ -1005,7 +1003,6 @@ void mapclass::gotoroom(int rx, int ry) { game.roomx = rx; game.roomy = ry; - game.roomchange = true; if (game.roomx < 100) game.roomx = 119; if (game.roomy < 100) game.roomy = 119; if (game.roomx > 119) game.roomx = 100; diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index 678e39f1..7989ccf3 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -1572,7 +1572,6 @@ void scriptclass::run(void) game.gravitycontrol = 0; game.teleport = false; game.companion = 0; - game.roomchange = false; game.teleport_to_new_area = false; game.teleport_to_x = 0; game.teleport_to_y = 0; @@ -3386,7 +3385,6 @@ void scriptclass::hardreset(void) game.gravitycontrol = 0; game.teleport = false; game.companion = 0; - game.roomchange = false; if (!version2_2) { // Ironically, resetting more variables makes the janky fadeout system in glitchrunnermode even more glitchy