1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-26 14:38:30 +02:00

Remove global 'temp' variable from titlerender.cpp

Just a miscellaneous code cleanup.

There's no glitches that take advantage of the previous situation,
namely that 'temp' was a global variable in Logic.cpp and editor.cpp.
Even if there were, it seems like it would easily lead to some undefined
behavior. So it's good to clean this up.
This commit is contained in:
Misa 2020-04-02 18:50:37 -07:00 committed by Ethan Lee
parent d3cdd33605
commit 04d14000ec
4 changed files with 17 additions and 24 deletions

View File

@ -2,7 +2,6 @@
#include "Script.h" #include "Script.h"
#include "Network.h" #include "Network.h"
extern int temp;
extern scriptclass script; extern scriptclass script;
void titlelogic() void titlelogic()
@ -678,7 +677,7 @@ void gamelogic()
if (map.final_colorframe == 1) if (map.final_colorframe == 1)
{ {
map.final_colorframedelay = 40; map.final_colorframedelay = 40;
temp = 1+int(fRandom() * 6); int temp = 1+int(fRandom() * 6);
if (temp == map.final_mapcol) temp = (temp + 1) % 6; if (temp == map.final_mapcol) temp = (temp + 1) % 6;
if (temp == 0) temp = 6; if (temp == 0) temp = 6;
map.changefinalcol(temp); map.changefinalcol(temp);
@ -686,7 +685,7 @@ void gamelogic()
else if (map.final_colorframe == 2) else if (map.final_colorframe == 2)
{ {
map.final_colorframedelay = 15; map.final_colorframedelay = 15;
temp = 1+int(fRandom() * 6); int temp = 1+int(fRandom() * 6);
if (temp == map.final_mapcol) temp = (temp + 1) % 6; if (temp == map.final_mapcol) temp = (temp + 1) % 6;
if (temp == 0) temp = 6; if (temp == 0) temp = 6;
map.changefinalcol(temp); map.changefinalcol(temp);

View File

@ -954,7 +954,7 @@ void editorclass::placetilelocal( int x, int y, int t )
int editorclass::base( int x, int y ) int editorclass::base( int x, int y )
{ {
//Return the base tile for the given tileset and colour //Return the base tile for the given tileset and colour
temp=x+(y*maxwidth); int temp=x+(y*maxwidth);
if(level[temp].tileset==0) //Space Station if(level[temp].tileset==0) //Space Station
{ {
if(level[temp].tilecol>=22) if(level[temp].tilecol>=22)
@ -992,7 +992,7 @@ int editorclass::base( int x, int y )
int editorclass::backbase( int x, int y ) int editorclass::backbase( int x, int y )
{ {
//Return the base tile for the background of the given tileset and colour //Return the base tile for the background of the given tileset and colour
temp=x+(y*maxwidth); int temp=x+(y*maxwidth);
if(level[temp].tileset==0) //Space Station if(level[temp].tileset==0) //Space Station
{ {
//Pick depending on tilecol //Pick depending on tilecol
@ -2074,8 +2074,6 @@ void fillboxabs( int x, int y, int x2, int y2, int c )
extern editorclass ed; extern editorclass ed;
extern int temp;
extern scriptclass script; extern scriptclass script;
void editorclass::generatecustomminimap() void editorclass::generatecustomminimap()
@ -5079,7 +5077,7 @@ void editorinput()
{ {
for(int i=0; i<40; i++) for(int i=0; i<40; i++)
{ {
temp=i+(ed.levx*40) + ed.vmult[j+(ed.levy*30)]; int temp=i+(ed.levx*40) + ed.vmult[j+(ed.levy*30)];
if(ed.contents[temp]>=3 && ed.contents[temp]<80) if(ed.contents[temp]>=3 && ed.contents[temp]<80)
{ {
//Fix spikes //Fix spikes
@ -5103,7 +5101,7 @@ void editorinput()
{ {
for(int i=0; i<40; i++) for(int i=0; i<40; i++)
{ {
temp=i+(ed.levx*40) + ed.vmult[j+(ed.levy*30)]; int temp=i+(ed.levx*40) + ed.vmult[j+(ed.levy*30)];
if(ed.contents[temp]>=3 && ed.contents[temp]<80) if(ed.contents[temp]>=3 && ed.contents[temp]<80)
{ {
//Fix spikes //Fix spikes
@ -5127,7 +5125,7 @@ void editorinput()
{ {
for(int i=0; i<40; i++) for(int i=0; i<40; i++)
{ {
temp=i+(ed.levx*40) + ed.vmult[j+(ed.levy*30)]; int temp=i+(ed.levx*40) + ed.vmult[j+(ed.levy*30)];
if(ed.contents[temp]>=3 && ed.contents[temp]<80) if(ed.contents[temp]>=3 && ed.contents[temp]<80)
{ {
//Fix spikes //Fix spikes
@ -5151,7 +5149,7 @@ void editorinput()
{ {
for(int i=0; i<40; i++) for(int i=0; i<40; i++)
{ {
temp=i+(ed.levx*40) + ed.vmult[j+(ed.levy*30)]; int temp=i+(ed.levx*40) + ed.vmult[j+(ed.levy*30)];
if(ed.contents[temp]>=3 && ed.contents[temp]<80) if(ed.contents[temp]>=3 && ed.contents[temp]<80)
{ {
//Fix spikes //Fix spikes
@ -5175,7 +5173,7 @@ void editorinput()
{ {
for(int i=0; i<40; i++) for(int i=0; i<40; i++)
{ {
temp=i+(ed.levx*40) + ed.vmult[j+(ed.levy*30)]; int temp=i+(ed.levx*40) + ed.vmult[j+(ed.levy*30)];
if(ed.contents[temp]>=3 && ed.contents[temp]<80) if(ed.contents[temp]>=3 && ed.contents[temp]<80)
{ {
//Fix spikes //Fix spikes

View File

@ -12,8 +12,6 @@
extern scriptclass script; extern scriptclass script;
int temp;
int tr; int tr;
int tg; int tg;
int tb; int tb;
@ -29,7 +27,7 @@ void titlerender()
tg = 164 - (help.glow / 2) - int(fRandom() * 4); tg = 164 - (help.glow / 2) - int(fRandom() * 4);
tb = 164 - (help.glow / 2) - int(fRandom() * 4); tb = 164 - (help.glow / 2) - int(fRandom() * 4);
temp = 50; int temp = 50;
graphics.drawsprite((160 - 96) + 0 * 32, temp, 23, tr, tg, tb); graphics.drawsprite((160 - 96) + 0 * 32, temp, 23, tr, tg, tb);
graphics.drawsprite((160 - 96) + 1 * 32, temp, 23, tr, tg, tb); graphics.drawsprite((160 - 96) + 1 * 32, temp, 23, tr, tg, tb);
graphics.drawsprite((160 - 96) + 2 * 32, temp, 23, tr, tg, tb); graphics.drawsprite((160 - 96) + 2 * 32, temp, 23, tr, tg, tb);
@ -57,7 +55,7 @@ void titlerender()
if (tb < 0) tb = 0; if (tb < 0) tb = 0;
if(tb>255) tb=255; if(tb>255) tb=255;
temp = 50; int temp = 50;
if(game.currentmenuname=="mainmenu") if(game.currentmenuname=="mainmenu")
{ {
@ -1209,7 +1207,7 @@ void gamecompleterender()
if (graphics.onscreen(220 + game.creditposition)) if (graphics.onscreen(220 + game.creditposition))
{ {
temp = 220 + game.creditposition; int temp = 220 + game.creditposition;
graphics.drawsprite((160 - 96) + 0 * 32, temp, 23, tr, tg, tb); graphics.drawsprite((160 - 96) + 0 * 32, temp, 23, tr, tg, tb);
graphics.drawsprite((160 - 96) + 1 * 32, temp, 23, tr, tg, tb); graphics.drawsprite((160 - 96) + 1 * 32, temp, 23, tr, tg, tb);
graphics.drawsprite((160 - 96) + 2 * 32, temp, 23, tr, tg, tb); graphics.drawsprite((160 - 96) + 2 * 32, temp, 23, tr, tg, tb);
@ -1753,7 +1751,7 @@ void maprender()
//draw screen alliteration //draw screen alliteration
//Roomname: //Roomname:
temp = map.area(game.roomx, game.roomy); int temp = map.area(game.roomx, game.roomy);
if (temp < 2 && !map.custommode && graphics.fademode==0) if (temp < 2 && !map.custommode && graphics.fademode==0)
{ {
if (game.roomx >= 102 && game.roomx <= 104 && game.roomy >= 110 && game.roomy <= 111) if (game.roomx >= 102 && game.roomx <= 104 && game.roomy >= 110 && game.roomy <= 111)
@ -2014,13 +2012,13 @@ void maprender()
{ {
if (map.showteleporters && map.explored[map.teleporters[i].x + (20 * map.teleporters[i].y)] > 0) if (map.showteleporters && map.explored[map.teleporters[i].x + (20 * map.teleporters[i].y)] > 0)
{ {
temp = 1126 + map.explored[map.teleporters[i].x + (20 * map.teleporters[i].y)]; int temp = 1126 + map.explored[map.teleporters[i].x + (20 * map.teleporters[i].y)];
if (graphics.flipmode) temp += 3; if (graphics.flipmode) temp += 3;
graphics.drawtile(40 + 3 + (map.teleporters[i].x * 12), 22 + (map.teleporters[i].y * 9), temp); graphics.drawtile(40 + 3 + (map.teleporters[i].x * 12), 22 + (map.teleporters[i].y * 9), temp);
} }
else if(map.showtargets && map.explored[map.teleporters[i].x+(20*map.teleporters[i].y)]==0) else if(map.showtargets && map.explored[map.teleporters[i].x+(20*map.teleporters[i].y)]==0)
{ {
temp = 1126 + map.explored[map.teleporters[i].x + (20 * map.teleporters[i].y)]; int temp = 1126 + map.explored[map.teleporters[i].x + (20 * map.teleporters[i].y)];
if (graphics.flipmode) temp += 3; if (graphics.flipmode) temp += 3;
graphics.drawtile(40 + 3 + (map.teleporters[i].x * 12), 22 + (map.teleporters[i].y * 9), temp); graphics.drawtile(40 + 3 + (map.teleporters[i].x * 12), 22 + (map.teleporters[i].y * 9), temp);
} }
@ -2032,7 +2030,7 @@ void maprender()
{ {
if (obj.collect[i] == 0) if (obj.collect[i] == 0)
{ {
temp = 1086; int temp = 1086;
if (graphics.flipmode) temp += 3; if (graphics.flipmode) temp += 3;
graphics.drawtile(40 + 3 + (map.shinytrinkets[i].x * 12), 22 + (map.shinytrinkets[i].y * 9), temp); graphics.drawtile(40 + 3 + (map.shinytrinkets[i].x * 12), 22 + (map.shinytrinkets[i].y * 9), temp);
} }
@ -2757,7 +2755,7 @@ void teleporterrender()
int tempy; int tempy;
//draw screen alliteration //draw screen alliteration
//Roomname: //Roomname:
temp = map.area(game.roomx, game.roomy); int temp = map.area(game.roomx, game.roomy);
if (temp < 2 && !map.custommode && graphics.fademode==0) if (temp < 2 && !map.custommode && graphics.fademode==0)
{ {
if (game.roomx >= 102 && game.roomx <= 104 && game.roomy >= 110 && game.roomy <= 111) if (game.roomx >= 102 && game.roomx <= 104 && game.roomy >= 110 && game.roomy <= 111)

View File

@ -8,8 +8,6 @@
#include "Map.h" #include "Map.h"
#include "Script.h" #include "Script.h"
extern int temp;
void titlerender(); void titlerender();
void towerrender(); void towerrender();