1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2025-03-08 06:45:12 +01:00

Replace roomnames/hiddennames/glitchnames with const char*

Since those are all downstream recipients of either static storage or
memory that doesn't move for the duration of the custom level, it's okay
to make these be `const char*`s without having to redo any of the RAII
memory management.

mapclass::currentarea() is included in this as well. I also cleaned up
Tower.cpp's headers to fix some transitive includes because I was
removing UtilityClass.h includes from all other level files too.

The "Untitled room" names no longer show any coordinates, because doing
so would require complicated memory management that's completely
unneeded. No one will ever see them, and if they do they already know
they have a problem anyway. The only time they might be able to see them
is if they corrupted the areamap, but this was only possible in 2.2 and
previous by dying outside the room deaths array in Outside Dimension
VVVVVV, which has since been patched out. Besides, sometimes the
"Untitled room" gets overwritten by something else anyway (especially in
Finalclass.cpp), so it really, really doesn't matter.
This commit is contained in:
Misa 2021-09-12 12:48:15 -07:00
parent a10342f5e6
commit a50e8ecf48
14 changed files with 69 additions and 80 deletions

View file

@ -3,7 +3,6 @@
#include "Game.h" #include "Game.h"
#include "Entity.h" #include "Entity.h"
#include "MakeAndPlay.h" #include "MakeAndPlay.h"
#include "UtilityClass.h"
const short* finalclass::loadlevel(int rx, int ry) const short* finalclass::loadlevel(int rx, int ry)
{ {
@ -14,8 +13,6 @@ const short* finalclass::loadlevel(int rx, int ry)
warpx = false; warpx = false;
warpy = false; warpy = false;
roomname = "Untitled room ["+help.String(rx) + "," + help.String(ry)+"]";
switch(t) switch(t)
{ {
#if !defined(MAKEANDPLAY) #if !defined(MAKEANDPLAY)

View file

@ -1,14 +1,12 @@
#ifndef FINALCLASS_H #ifndef FINALCLASS_H
#define FINALCLASS_H #define FINALCLASS_H
#include <string>
class finalclass class finalclass
{ {
public: public:
const short* loadlevel(int rx, int ry); const short* loadlevel(int rx, int ry);
std::string roomname; const char* roomname;
bool warpx, warpy; bool warpx, warpy;
}; };

View file

@ -3934,7 +3934,7 @@ void Game::gethardestroom(void)
{ {
hardestroomdeaths = currentroomdeaths; hardestroomdeaths = currentroomdeaths;
hardestroom = map.roomname; hardestroom = map.roomname;
if (map.roomname == "glitch") if (SDL_strcmp(map.roomname, "glitch") == 0)
{ {
if (roomx == 42 && roomy == 51) if (roomx == 42 && roomy == 51)
{ {
@ -3949,7 +3949,7 @@ void Game::gethardestroom(void)
hardestroom = "The Untouchavles"; hardestroom = "The Untouchavles";
} }
} }
else if (map.roomname == "change") else if (SDL_strcmp(map.roomname, "change") == 0)
{ {
if (roomx == 45 && roomy == 51) hardestroom =map.specialnames[3]; if (roomx == 45 && roomy == 51) hardestroom =map.specialnames[3];
if (roomx == 46 && roomy == 51) hardestroom =map.specialnames[4]; if (roomx == 46 && roomy == 51) hardestroom =map.specialnames[4];
@ -3957,7 +3957,7 @@ void Game::gethardestroom(void)
if (roomx == 50 && roomy == 53) hardestroom =map.specialnames[6]; if (roomx == 50 && roomy == 53) hardestroom =map.specialnames[6];
if (roomx == 50 && roomy == 54) hardestroom = map.specialnames[7]; if (roomx == 50 && roomy == 54) hardestroom = map.specialnames[7];
} }
else if (map.roomname == "") else if (SDL_strcmp(map.roomname, "") == 0)
{ {
hardestroom = map.hiddenname; hardestroom = map.hiddenname;
} }

View file

@ -3,7 +3,6 @@
#include "Game.h" #include "Game.h"
#include "Entity.h" #include "Entity.h"
#include "MakeAndPlay.h" #include "MakeAndPlay.h"
#include "UtilityClass.h"
const short* labclass::loadlevel(int rx, int ry) const short* labclass::loadlevel(int rx, int ry)
{ {
@ -25,7 +24,7 @@ const short* labclass::loadlevel(int rx, int ry)
t = rx + (ry * 100); t = rx + (ry * 100);
const short* result; const short* result;
rcol = 0; rcol = 0;
roomname = "Untitled room ["+help.String(rx) + "," + help.String(ry)+"]"; roomname = "";
switch(t) switch(t)
{ {

View file

@ -1,14 +1,12 @@
#ifndef LABCLASS_H #ifndef LABCLASS_H
#define LABCLASS_H #define LABCLASS_H
#include <string>
class labclass class labclass
{ {
public: public:
const short* loadlevel(int rx, int ry); const short* loadlevel(int rx, int ry);
std::string roomname; const char* roomname;
int rcol; int rcol;
}; };
#endif /* LABCLASS_H */ #endif /* LABCLASS_H */

View file

@ -84,6 +84,9 @@ mapclass::mapclass(void)
roomtexton = false; roomtexton = false;
nexttowercolour_set = false; nexttowercolour_set = false;
roomname = "";
hiddenname = "";
} }
//Areamap starts at 100,100 and extends 20x20 //Areamap starts at 100,100 and extends 20x20
@ -164,159 +167,159 @@ void mapclass::transformname(int t)
{ {
case 3: case 3:
//Television Newsveel -> The 9 O'Clock News //Television Newsveel -> The 9 O'Clock News
if (specialnames[3] == "Television Newsveel") if (SDL_strcmp(specialnames[3], "Television Newsveel") == 0)
{ {
specialnames[3] = "Television Newsvel"; specialnames[3] = "Television Newsvel";
} }
else if (specialnames[3] == "Television Newsvel") else if (SDL_strcmp(specialnames[3], "Television Newsvel") == 0)
{ {
specialnames[3] = "TelevisvonvNewsvel"; specialnames[3] = "TelevisvonvNewsvel";
} }
else if (specialnames[3] == "TelevisvonvNewsvel") else if (SDL_strcmp(specialnames[3], "TelevisvonvNewsvel") == 0)
{ {
specialnames[3] = "TvlvvvsvonvNevsvel"; specialnames[3] = "TvlvvvsvonvNevsvel";
} }
else if (specialnames[3] == "TvlvvvsvonvNevsvel") else if (SDL_strcmp(specialnames[3], "TvlvvvsvonvNevsvel") == 0)
{ {
specialnames[3] = "vvvvvvsvovvNe svel"; specialnames[3] = "vvvvvvsvovvNe svel";
} }
else if (specialnames[3] == "vvvvvvsvovvNe svel") else if (SDL_strcmp(specialnames[3], "vvvvvvsvovvNe svel") == 0)
{ {
specialnames[3] = "vhv vvv'vvovv vevl"; specialnames[3] = "vhv vvv'vvovv vevl";
} }
else if (specialnames[3] == "vhv vvv'vvovv vevl") else if (SDL_strcmp(specialnames[3], "vhv vvv'vvovv vevl") == 0)
{ {
specialnames[3] = "vhv V v'Cvovv vewv"; specialnames[3] = "vhv V v'Cvovv vewv";
} }
else if (specialnames[3] == "vhv V v'Cvovv vewv") else if (SDL_strcmp(specialnames[3], "vhv V v'Cvovv vewv") == 0)
{ {
specialnames[3] = "vhe 9 v'Cvovv vewv"; specialnames[3] = "vhe 9 v'Cvovv vewv";
} }
else if (specialnames[3] == "vhe 9 v'Cvovv vewv") else if (SDL_strcmp(specialnames[3], "vhe 9 v'Cvovv vewv") == 0)
{ {
specialnames[3] = "vhe 9 v'Cvovv Newv"; specialnames[3] = "vhe 9 v'Cvovv Newv";
} }
else if (specialnames[3] == "vhe 9 v'Cvovv Newv") else if (SDL_strcmp(specialnames[3], "vhe 9 v'Cvovv Newv") == 0)
{ {
specialnames[3] = "The 9 O'Cvovk Newv"; specialnames[3] = "The 9 O'Cvovk Newv";
} }
else if (specialnames[3] == "The 9 O'Cvovk Newv") else if (SDL_strcmp(specialnames[3], "The 9 O'Cvovk Newv") == 0)
{ {
specialnames[3] = "The 9 O'Clock News"; specialnames[3] = "The 9 O'Clock News";
} }
break; break;
case 4: case 4:
//Vwitched -> Dial M for Murder //Vwitched -> Dial M for Murder
if (specialnames[4] == "Vwitched") if (SDL_strcmp(specialnames[4], "Vwitched") == 0)
{ {
specialnames[4] = "Vwitvhed"; specialnames[4] = "Vwitvhed";
} }
else if (specialnames[4] == "Vwitvhed") else if (SDL_strcmp(specialnames[4], "Vwitvhed") == 0)
{ {
specialnames[4] = "vVwivcvedv"; specialnames[4] = "vVwivcvedv";
} }
else if (specialnames[4] == "vVwivcvedv") else if (SDL_strcmp(specialnames[4], "vVwivcvedv") == 0)
{ {
specialnames[4] = "vvvwMvcvMdvv"; specialnames[4] = "vvvwMvcvMdvv";
} }
else if (specialnames[4] == "vvvwMvcvMdvv") else if (SDL_strcmp(specialnames[4], "vvvwMvcvMdvv") == 0)
{ {
specialnames[4] = "DvvvwMvfvvMdvvv"; specialnames[4] = "DvvvwMvfvvMdvvv";
} }
else if (specialnames[4] == "DvvvwMvfvvMdvvv") else if (SDL_strcmp(specialnames[4], "DvvvwMvfvvMdvvv") == 0)
{ {
specialnames[4] = "Dvav Mvfvr Mdvvvv"; specialnames[4] = "Dvav Mvfvr Mdvvvv";
} }
else if (specialnames[4] == "Dvav Mvfvr Mdvvvv") else if (SDL_strcmp(specialnames[4], "Dvav Mvfvr Mdvvvv") == 0)
{ {
specialnames[4] = "Diav M for Mdrver"; specialnames[4] = "Diav M for Mdrver";
} }
else if (specialnames[4] == "Diav M for Mdrver") else if (SDL_strcmp(specialnames[4], "Diav M for Mdrver") == 0)
{ {
specialnames[4] = "Dial M for Murder"; specialnames[4] = "Dial M for Murder";
} }
break; break;
case 5: case 5:
//Gvnsmoke -> Gunsmoke 1966 //Gvnsmoke -> Gunsmoke 1966
if (specialnames[5] == "Gvnsmoke") if (SDL_strcmp(specialnames[5], "Gvnsmoke") == 0)
{ {
specialnames[5] = "Gvnsmove"; specialnames[5] = "Gvnsmove";
} }
else if (specialnames[5] == "Gvnsmove") else if (SDL_strcmp(specialnames[5], "Gvnsmove") == 0)
{ {
specialnames[5] = "Gvnvmovevv"; specialnames[5] = "Gvnvmovevv";
} }
else if (specialnames[5] == "Gvnvmovevv") else if (SDL_strcmp(specialnames[5], "Gvnvmovevv") == 0)
{ {
specialnames[5] = "Gunvmove1vv6"; specialnames[5] = "Gunvmove1vv6";
} }
else if (specialnames[5] == "Gunvmove1vv6") else if (SDL_strcmp(specialnames[5], "Gunvmove1vv6") == 0)
{ {
specialnames[5] = "Vunsmoke 19v6"; specialnames[5] = "Vunsmoke 19v6";
} }
else if (specialnames[5] == "Vunsmoke 19v6") else if (SDL_strcmp(specialnames[5], "Vunsmoke 19v6") == 0)
{ {
specialnames[5] = "Gunsmoke 1966"; specialnames[5] = "Gunsmoke 1966";
} }
break; break;
case 6: case 6:
//Please enjoy these repeats -> In the Margins //Please enjoy these repeats -> In the Margins
if (specialnames[6] == "Please enjoy these repeats") if (SDL_strcmp(specialnames[6], "Please enjoy these repeats") == 0)
{ {
specialnames[6] = "Please envoy theve repeats"; specialnames[6] = "Please envoy theve repeats";
} }
else if (specialnames[6] == "Please envoy theve repeats") else if (SDL_strcmp(specialnames[6], "Please envoy theve repeats") == 0)
{ {
specialnames[6] = "Plse envoy tse rvpvas"; specialnames[6] = "Plse envoy tse rvpvas";
} }
else if (specialnames[6] == "Plase envoy these rvpeas") else if (SDL_strcmp(specialnames[6], "Plase envoy these rvpeas") == 0)
{ {
specialnames[6] = "Plse envoy tse rvpvas"; specialnames[6] = "Plse envoy tse rvpvas";
} }
else if (specialnames[6] == "Plse envoy tse rvpvas") else if (SDL_strcmp(specialnames[6], "Plse envoy tse rvpvas") == 0)
{ {
specialnames[6] = "Vl envoy te rvevs"; specialnames[6] = "Vl envoy te rvevs";
} }
else if (specialnames[6] == "Vl envoy te rvevs") else if (SDL_strcmp(specialnames[6], "Vl envoy te rvevs") == 0)
{ {
specialnames[6] = "Vv evo tv vevs"; specialnames[6] = "Vv evo tv vevs";
} }
else if (specialnames[6] == "Vv evo tv vevs") else if (SDL_strcmp(specialnames[6], "Vv evo tv vevs") == 0)
{ {
specialnames[6] = "Iv vhv Mvrvivs"; specialnames[6] = "Iv vhv Mvrvivs";
} }
else if (specialnames[6] == "Iv vhv Mvrvivs") else if (SDL_strcmp(specialnames[6], "Iv vhv Mvrvivs") == 0)
{ {
specialnames[6] = "In the Margins"; specialnames[6] = "In the Margins";
} }
break; break;
case 7: case 7:
//Try Jiggling the Antenna -> Heaven's Gate //Try Jiggling the Antenna -> Heaven's Gate
if (specialnames[7] == "Try Jiggling the Antenna") if (SDL_strcmp(specialnames[7], "Try Jiggling the Antenna") == 0)
{ {
specialnames[7] = "Try Viggling the Antenna"; specialnames[7] = "Try Viggling the Antenna";
} }
else if (specialnames[7] == "Try Viggling the Antenna") else if (SDL_strcmp(specialnames[7], "Try Viggling the Antenna") == 0)
{ {
specialnames[7] = "TryJivglvng theAvtevna"; specialnames[7] = "TryJivglvng theAvtevna";
} }
else if (specialnames[7] == "TryJivglvng theAvtevna") else if (SDL_strcmp(specialnames[7], "TryJivglvng theAvtevna") == 0)
{ {
specialnames[7] = "Tvvivglvng thAvtvvv"; specialnames[7] = "Tvvivglvng thAvtvvv";
} }
else if (specialnames[7] == "Tvvivglvng thAvtvvv") else if (SDL_strcmp(specialnames[7], "Tvvivglvng thAvtvvv") == 0)
{ {
specialnames[7] = "Vvvgglvnv tvnvva"; specialnames[7] = "Vvvgglvnv tvnvva";
} }
else if (specialnames[7] == "Vvvgglvnv tvnvva") else if (SDL_strcmp(specialnames[7], "Vvvgglvnv tvnvva") == 0)
{ {
specialnames[7] = "Vvavvnvs vvtv"; specialnames[7] = "Vvavvnvs vvtv";
} }
else if (specialnames[7] == "Vvavvnvs vvtv") else if (SDL_strcmp(specialnames[7], "Vvavvnvs vvtv") == 0)
{ {
specialnames[7] = "Veavvn's Gvte"; specialnames[7] = "Veavvn's Gvte";
} }
else if (specialnames[7] == "Veavvn's Gvte") else if (SDL_strcmp(specialnames[7], "Veavvn's Gvte") == 0)
{ {
specialnames[7] = "Heaven's Gate"; specialnames[7] = "Heaven's Gate";
} }
@ -331,10 +334,10 @@ void mapclass::transformname(int t)
} }
} }
std::string mapclass::getglitchname(int x, int y) const char* mapclass::getglitchname(int x, int y)
{ {
//Returns the name in the final area. //Returns the name in the final area.
if (roomname == "glitch") if (SDL_strcmp(roomname, "glitch") == 0)
{ {
//8 Cases! //8 Cases!
//First, the three "glitches" //First, the three "glitches"
@ -371,7 +374,7 @@ std::string mapclass::getglitchname(int x, int y)
else return "The Untouchavles"; else return "The Untouchavles";
} }
} }
else if (roomname == "change") else if (SDL_strcmp(roomname, "change") == 0)
{ {
if (finalstretch) if (finalstretch)
{ {
@ -1282,7 +1285,7 @@ void mapclass::spawncompanion(void)
} }
} }
std::string mapclass::currentarea(int t) const char* mapclass::currentarea(int t)
{ {
switch(t) switch(t)
{ {
@ -1811,7 +1814,7 @@ void mapclass::loadlevel(int rx, int ry)
break; break;
} }
roomname = room->roomname; roomname = room->roomname.c_str();
extrarow = 1; extrarow = 1;
const int* tmap = cl.loadlevel(rx, ry); const int* tmap = cl.loadlevel(rx, ry);
SDL_memcpy(contents, tmap, sizeof(contents)); SDL_memcpy(contents, tmap, sizeof(contents));
@ -1921,7 +1924,7 @@ void mapclass::loadlevel(int rx, int ry)
Roomtext text; Roomtext text;
text.x = ex / 8; text.x = ex / 8;
text.y = ey / 8; text.y = ey / 8;
text.text = ent.scriptname; text.text = ent.scriptname.c_str();
roomtext.push_back(text); roomtext.push_back(text);
break; break;
} }

View file

@ -15,7 +15,7 @@
struct Roomtext struct Roomtext
{ {
int x, y; int x, y;
std::string text; const char* text;
}; };
class mapclass class mapclass
@ -35,7 +35,7 @@ public:
void transformname(int t); void transformname(int t);
std::string getglitchname(int x, int y); const char* getglitchname(int x, int y);
void initmapdata(void); void initmapdata(void);
void initcustommapdata(void); void initcustommapdata(void);
@ -83,7 +83,7 @@ public:
void spawncompanion(void); void spawncompanion(void);
std::string currentarea(int t); const char* currentarea(int t);
void loadlevel(int rx, int ry); void loadlevel(int rx, int ry);
@ -107,8 +107,8 @@ public:
bool warpy; bool warpy;
std::string roomname; const char* roomname;
std::string hiddenname; const char* hiddenname;
//Special tower stuff //Special tower stuff
bool towermode; bool towermode;
@ -135,10 +135,10 @@ public:
int customzoom; int customzoom;
bool customshowmm; bool customshowmm;
std::string specialnames[8]; const char* specialnames[8];
int glitchmode; int glitchmode;
int glitchdelay; int glitchdelay;
std::string glitchname; const char* glitchname;
//final level colour cycling stuff //final level colour cycling stuff
bool final_colormode; bool final_colormode;

View file

@ -1,15 +1,13 @@
#ifndef OTHERLEVEL_H #ifndef OTHERLEVEL_H
#define OTHERLEVEL_H #define OTHERLEVEL_H
#include <string>
class otherlevelclass class otherlevelclass
{ {
public: public:
const short* loadlevel(int rx, int ry); const short* loadlevel(int rx, int ry);
std::string roomname; const char* roomname;
std::string hiddenname; const char* hiddenname;
int roomtileset; int roomtileset;
}; };

View file

@ -1739,7 +1739,7 @@ void gamerender(void)
graphics.bprint(46, 6, game.timestring(), 196, 196, 196); graphics.bprint(46, 6, game.timestring(), 196, 196, 196);
} }
if(map.extrarow==0 || (map.custommode && map.roomname!="")) if(map.extrarow==0 || (map.custommode && SDL_strcmp(map.roomname, "") != 0))
{ {
graphics.footerrect.y = 230; graphics.footerrect.y = 230;
if (graphics.translucentroomname) if (graphics.translucentroomname)
@ -2017,7 +2017,7 @@ void maprender(void)
//draw screen alliteration //draw screen alliteration
//Roomname: //Roomname:
if (map.hiddenname != "") if (SDL_strcmp(map.hiddenname, "") != 0)
{ {
graphics.Print(5, 2, map.hiddenname, 196, 196, 255 - help.glow, true); graphics.Print(5, 2, map.hiddenname, 196, 196, 255 - help.glow, true);
} }

View file

@ -3,7 +3,6 @@
#include "Game.h" #include "Game.h"
#include "Entity.h" #include "Entity.h"
#include "MakeAndPlay.h" #include "MakeAndPlay.h"
#include "UtilityClass.h"
const short* spacestation2class::loadlevel(int rx, int ry) const short* spacestation2class::loadlevel(int rx, int ry)
{ {
@ -17,7 +16,7 @@ const short* spacestation2class::loadlevel(int rx, int ry)
t = rx + (ry * 100); t = rx + (ry * 100);
const short* result; const short* result;
roomname = "Untitled room ["+help.String(rx) + "," + help.String(ry)+"]"; roomname = "Untitled room";
switch(t) switch(t)
{ {

View file

@ -1,13 +1,11 @@
#ifndef SPACESTATION2_H #ifndef SPACESTATION2_H
#define SPACESTATION2_H #define SPACESTATION2_H
#include <string>
class spacestation2class class spacestation2class
{ {
public: public:
const short* loadlevel(int rx, int ry); const short* loadlevel(int rx, int ry);
std::string roomname; const char* roomname;
}; };
#endif /* SPACESTATION2_H */ #endif /* SPACESTATION2_H */

View file

@ -1,7 +1,9 @@
#include "Tower.h" #include "Tower.h"
#include <SDL_stdinc.h>
#include <stddef.h>
#include "MakeAndPlay.h" #include "MakeAndPlay.h"
#include "UtilityClass.h"
towerclass::towerclass(void) towerclass::towerclass(void)
{ {

View file

@ -3,7 +3,6 @@
#include "Game.h" #include "Game.h"
#include "Entity.h" #include "Entity.h"
#include "MakeAndPlay.h" #include "MakeAndPlay.h"
#include "UtilityClass.h"
const short* warpclass::loadlevel(int rx, int ry) const short* warpclass::loadlevel(int rx, int ry)
{ {
@ -20,7 +19,7 @@ const short* warpclass::loadlevel(int rx, int ry)
warpx = false; warpx = false;
warpy = false; warpy = false;
roomname = "Untitled room ["+help.String(rx) + "," + help.String(ry)+"]"; roomname = "Untitled room";
switch(t) switch(t)
{ {

View file

@ -1,13 +1,11 @@
#ifndef WARPCLASS_H #ifndef WARPCLASS_H
#define WARPCLASS_H #define WARPCLASS_H
#include <string>
class warpclass class warpclass
{ {
public: public:
const short* loadlevel(int rx, int ry); const short* loadlevel(int rx, int ry);
std::string roomname; const char* roomname;
int rcol; int rcol;
bool warpx, warpy; bool warpx, warpy;
}; };