mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 01:59:43 +01:00
Move roomchange off of Game
The purpose of this variable was to keep track of if gamelogic() called map.gotoroom() at any point during its execution. So map.gotoroom() always unconditionally set it to true, and then gamelogic() would check it later. Well, there's no need to put that in a global variable and do it like that! It makes it less clear when you do that. So what I've done instead is made a temporary macro wrapper around map.gotoroom() that also sets roomchange to true. I've also made it so any attempt to use map.gotoroom() directly results in failure (and since then using map.gotoroom() in the wrapper macro would also fail, I've had to make a gotoroom wrapper function around map.gotoroom() so the wrapper macro itself doesn't fail).
This commit is contained in:
parent
75ed9f9631
commit
7a598f5811
5 changed files with 31 additions and 26 deletions
|
@ -124,7 +124,6 @@ void Game::init(void)
|
|||
teleport = false;
|
||||
edteleportent = 0; //Added in the port!
|
||||
companion = 0;
|
||||
roomchange = false;
|
||||
|
||||
|
||||
quickrestartkludge = false;
|
||||
|
|
|
@ -384,7 +384,6 @@ public:
|
|||
float inertia;
|
||||
|
||||
int companion;
|
||||
bool roomchange;
|
||||
SDL_Rect teleblock;
|
||||
bool activetele;
|
||||
int readytotele;
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue