- removed the last static character arrays from FLevelLocals.

This commit is contained in:
Christoph Oelckers 2014-05-13 23:16:13 +02:00
parent e49e926bd9
commit 24886b6734
18 changed files with 61 additions and 74 deletions

View file

@ -986,14 +986,10 @@ CCMD(nextmap)
TEXTCOLOR_NORMAL " is for single-player only.\n"); TEXTCOLOR_NORMAL " is for single-player only.\n");
return; return;
} }
char *next = NULL;
if (*level.nextmap) if (level.NextMap.Len() > 0 && level.NextMap.Compare("enDSeQ", 6))
next = level.nextmap;
if (next != NULL && strncmp(next, "enDSeQ", 6))
{ {
G_DeferedInitNew(next); G_DeferedInitNew(level.NextMap);
} }
else else
{ {
@ -1016,12 +1012,9 @@ CCMD(nextsecret)
} }
char *next = NULL; char *next = NULL;
if (*level.secretmap) if (level.NextSecretMap.Len() > 0 && level.NextSecretMap.Compare("enDSeQ", 6))
next = level.secretmap;
if (next != NULL && strncmp(next, "enDSeQ", 6))
{ {
G_DeferedInitNew(next); G_DeferedInitNew(level.NextSecretMap);
} }
else else
{ {
@ -1107,8 +1100,8 @@ static void PrintSecretString(const char *string, bool thislevel)
CCMD(secret) CCMD(secret)
{ {
const char *mapname = argv.argc() < 2? level.mapname : argv[1]; const char *mapname = argv.argc() < 2? level.MapName.GetChars() : argv[1];
bool thislevel = !stricmp(mapname, level.mapname); bool thislevel = !stricmp(mapname, level.MapName);
bool foundsome = false; bool foundsome = false;
int lumpno=Wads.CheckNumForName("SECRETS"); int lumpno=Wads.CheckNumForName("SECRETS");

View file

@ -2573,7 +2573,7 @@ static void RunScript(BYTE **stream, APlayerPawn *pawn, int snum, int argn, int
arg[i] = argval; arg[i] = argval;
} }
} }
P_StartScript(pawn, NULL, snum, level.mapname, arg, MIN<int>(countof(arg), argn), ACS_NET | always); P_StartScript(pawn, NULL, snum, level.MapName, arg, MIN<int>(countof(arg), argn), ACS_NET | always);
} }
void Net_SkipCommand (int type, BYTE **stream) void Net_SkipCommand (int type, BYTE **stream)

View file

@ -202,15 +202,13 @@ void FScriptLoader::ParseInfoCmd(char *line, FString &scriptsrc)
{ {
sc.MustGetStringName("="); sc.MustGetStringName("=");
sc.MustGetString(); sc.MustGetString();
strncpy(level.nextmap, sc.String, 8); level.NextMap = sc.String;
level.nextmap[8]=0;
} }
else if (sc.Compare("nextsecret")) else if (sc.Compare("nextsecret"))
{ {
sc.MustGetStringName("="); sc.MustGetStringName("=");
sc.MustGetString(); sc.MustGetString();
strncpy(level.secretmap, sc.String, 8); level.NextSecretMap = sc.String;
level.secretmap[8]=0;
} }
else if (sc.Compare("drown")) else if (sc.Compare("drown"))
{ {

View file

@ -1621,7 +1621,7 @@ void G_DoReborn (int playernum, bool freshbot)
{ // Reload the level from scratch { // Reload the level from scratch
bool indemo = demoplayback; bool indemo = demoplayback;
BackupSaveName = ""; BackupSaveName = "";
G_InitNew (level.mapname, false); G_InitNew (level.MapName, false);
demoplayback = indemo; demoplayback = indemo;
// gameaction = ga_loadlevel; // gameaction = ga_loadlevel;
} }
@ -2027,7 +2027,7 @@ static void PutSaveComment (FILE *file)
// Get level name // Get level name
//strcpy (comment, level.level_name); //strcpy (comment, level.level_name);
mysnprintf(comment, countof(comment), "%s - %s", level.mapname, level.LevelName.GetChars()); mysnprintf(comment, countof(comment), "%s - %s", level.MapName.GetChars(), level.LevelName.GetChars());
len = (WORD)strlen (comment); len = (WORD)strlen (comment);
comment[len] = '\n'; comment[len] = '\n';
@ -2088,7 +2088,7 @@ void G_DoSaveGame (bool okForQuicksave, FString filename, const char *descriptio
M_AppendPNGText (stdfile, "Engine", GAMESIG); M_AppendPNGText (stdfile, "Engine", GAMESIG);
M_AppendPNGText (stdfile, "ZDoom Save Version", SAVESIG); M_AppendPNGText (stdfile, "ZDoom Save Version", SAVESIG);
M_AppendPNGText (stdfile, "Title", description); M_AppendPNGText (stdfile, "Title", description);
M_AppendPNGText (stdfile, "Current Map", level.mapname); M_AppendPNGText (stdfile, "Current Map", level.MapName);
PutSaveWads (stdfile); PutSaveWads (stdfile);
PutSaveComment (stdfile); PutSaveComment (stdfile);
@ -2289,7 +2289,7 @@ void G_BeginRecording (const char *startmap)
if (startmap == NULL) if (startmap == NULL)
{ {
startmap = level.mapname; startmap = level.MapName;
} }
demo_p = demobuffer; demo_p = demobuffer;

View file

@ -88,7 +88,7 @@ void AHeresiarch::Die (AActor *source, AActor *inflictor, int dmgflags)
if (script != 0) if (script != 0)
{ {
P_StartScript (this, NULL, script, level.mapname, NULL, 0, 0); P_StartScript (this, NULL, script, level.MapName, NULL, 0, 0);
} }
} }

View file

@ -445,10 +445,7 @@ void G_InitNew (const char *mapname, bool bTitleLevel)
bglobal.Init (); bglobal.Init ();
} }
if (mapname != level.mapname) level.MapName = mapname;
{
strcpy (level.mapname, mapname);
}
if (bTitleLevel) if (bTitleLevel)
{ {
gamestate = GS_TITLELEVEL; gamestate = GS_TITLELEVEL;
@ -491,9 +488,9 @@ void G_ChangeLevel(const char *levelname, int position, int flags, int nextSkill
{ {
// end the game // end the game
levelname = NULL; levelname = NULL;
if (!strncmp(level.nextmap, "enDSeQ",6)) if (!level.NextMap.Compare("enDSeQ",6))
{ {
levelname = level.nextmap; // If there is already an end sequence please leave it alone! nextlevel = level.NextMap; // If there is already an end sequence please leave it alone!
} }
else else
{ {
@ -596,18 +593,18 @@ void G_ChangeLevel(const char *levelname, int position, int flags, int nextSkill
const char *G_GetExitMap() const char *G_GetExitMap()
{ {
return level.nextmap; return level.NextMap;
} }
const char *G_GetSecretExitMap() const char *G_GetSecretExitMap()
{ {
const char *nextmap = level.nextmap; const char *nextmap = level.NextMap;
if (level.secretmap[0] != 0) if (level.NextSecretMap.Len() > 0)
{ {
if (P_CheckMapData(level.secretmap)) if (P_CheckMapData(level.NextSecretMap))
{ {
nextmap = level.secretmap; nextmap = level.NextSecretMap;
} }
} }
return nextmap; return nextmap;
@ -641,7 +638,7 @@ void G_DoCompleted (void)
if (gamestate == GS_TITLELEVEL) if (gamestate == GS_TITLELEVEL)
{ {
strncpy (level.mapname, nextlevel, 255); level.MapName = nextlevel;
G_DoLoadLevel (startpos, false); G_DoLoadLevel (startpos, false);
startpos = 0; startpos = 0;
viewactive = true; viewactive = true;
@ -650,20 +647,20 @@ void G_DoCompleted (void)
// [RH] Mark this level as having been visited // [RH] Mark this level as having been visited
if (!(level.flags & LEVEL_CHANGEMAPCHEAT)) if (!(level.flags & LEVEL_CHANGEMAPCHEAT))
FindLevelInfo (level.mapname)->flags |= LEVEL_VISITED; FindLevelInfo (level.MapName)->flags |= LEVEL_VISITED;
if (automapactive) if (automapactive)
AM_Stop (); AM_Stop ();
wminfo.finished_ep = level.cluster - 1; wminfo.finished_ep = level.cluster - 1;
wminfo.LName0 = TexMan[TexMan.CheckForTexture(level.info->PName, FTexture::TEX_MiscPatch)]; wminfo.LName0 = TexMan[TexMan.CheckForTexture(level.info->PName, FTexture::TEX_MiscPatch)];
wminfo.current = level.mapname; wminfo.current = level.MapName;
if (deathmatch && if (deathmatch &&
(dmflags & DF_SAME_LEVEL) && (dmflags & DF_SAME_LEVEL) &&
!(level.flags & LEVEL_CHANGEMAPCHEAT)) !(level.flags & LEVEL_CHANGEMAPCHEAT))
{ {
wminfo.next = level.mapname; wminfo.next = level.MapName;
wminfo.LName1 = wminfo.LName0; wminfo.LName1 = wminfo.LName0;
} }
else else
@ -850,7 +847,7 @@ void G_DoLoadLevel (int position, bool autosave)
"\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36" "\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36"
"\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n" "\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n"
TEXTCOLOR_BOLD "%s - %s\n\n", TEXTCOLOR_BOLD "%s - %s\n\n",
level.mapname, level.LevelName.GetChars()); level.MapName.GetChars(), level.LevelName.GetChars());
if (wipegamestate == GS_LEVEL) if (wipegamestate == GS_LEVEL)
wipegamestate = GS_FORCEWIPE; wipegamestate = GS_FORCEWIPE;
@ -899,7 +896,7 @@ void G_DoLoadLevel (int position, bool autosave)
} }
level.maptime = 0; level.maptime = 0;
P_SetupLevel (level.mapname, position); P_SetupLevel (level.MapName, position);
AM_LevelInit(); AM_LevelInit();
@ -1056,7 +1053,7 @@ void G_DoWorldDone (void)
} }
else else
{ {
strncpy (level.mapname, nextlevel, 255); level.MapName = nextlevel;
} }
G_StartTravel (); G_StartTravel ();
G_DoLoadLevel (startpos, true); G_DoLoadLevel (startpos, true);
@ -1217,7 +1214,7 @@ void G_InitLevelLocals ()
level.flags = 0; level.flags = 0;
level.flags2 = 0; level.flags2 = 0;
info = FindLevelInfo (level.mapname); info = FindLevelInfo (level.MapName);
level.info = info; level.info = info;
level.skyspeed1 = info->skyspeed1; level.skyspeed1 = info->skyspeed1;
@ -1274,10 +1271,8 @@ void G_InitLevelLocals ()
level.musicorder = info->musicorder; level.musicorder = info->musicorder;
level.LevelName = level.info->LookupLevelName(); level.LevelName = level.info->LookupLevelName();
strncpy (level.nextmap, info->nextmap, 10); level.NextMap = info->nextmap;
level.nextmap[10] = 0; level.NextSecretMap = info->secretmap;
strncpy (level.secretmap, info->secretmap, 10);
level.secretmap[10] = 0;
compatflags.Callback(); compatflags.Callback();
compatflags2.Callback(); compatflags2.Callback();

View file

@ -391,9 +391,9 @@ struct FLevelLocals
int levelnum; int levelnum;
int lumpnum; int lumpnum;
FString LevelName; FString LevelName;
char mapname[256]; // the lump name (E1M1, MAP01, etc) FString MapName; // the lump name (E1M1, MAP01, etc)
char nextmap[11]; // go here when using the regular exit FString NextMap; // go here when using the regular exit
char secretmap[11]; // map to go to when used secret exit FString NextSecretMap; // map to go to when used secret exit
EMapType maptype; EMapType maptype;
DWORD flags; DWORD flags;

View file

@ -830,7 +830,7 @@ class CommandDrawString : public SBarInfoCommand
if(level.lumpnum != cache) if(level.lumpnum != cache)
{ {
cache = level.lumpnum; cache = level.lumpnum;
str = level.mapname; str = level.MapName;
str.ToUpper(); str.ToUpper();
RealignString(); RealignString();
} }

View file

@ -131,7 +131,7 @@ void ST_FormatMapName(FString &mapname, const char *mapnamecolor)
if (am_showmaplabel == 1 || (am_showmaplabel == 2 && !ishub)) if (am_showmaplabel == 1 || (am_showmaplabel == 2 && !ishub))
{ {
mapname << level.mapname << ": "; mapname << level.MapName << ": ";
} }
mapname << mapnamecolor << level.LevelName; mapname << mapnamecolor << level.LevelName;
} }

View file

@ -6981,7 +6981,7 @@ scriptwait:
break; break;
case PRINTNAME_LEVEL: case PRINTNAME_LEVEL:
work += level.mapname; work += level.MapName;
break; break;
case PRINTNAME_SKILL: case PRINTNAME_SKILL:
@ -8950,7 +8950,7 @@ EXTERN_CVAR (Bool, sv_cheats)
int P_StartScript (AActor *who, line_t *where, int script, const char *map, const int *args, int argcount, int flags) int P_StartScript (AActor *who, line_t *where, int script, const char *map, const int *args, int argcount, int flags)
{ {
if (map == NULL || 0 == strnicmp (level.mapname, map, 8)) if (map == NULL || 0 == strnicmp (level.MapName, map, 8))
{ {
FBehavior *module = NULL; FBehavior *module = NULL;
const ScriptPtr *scriptdata; const ScriptPtr *scriptdata;
@ -9003,17 +9003,17 @@ int P_StartScript (AActor *who, line_t *where, int script, const char *map, cons
return false; return false;
} }
void P_SuspendScript (int script, char *map) void P_SuspendScript (int script, const char *map)
{ {
if (strnicmp (level.mapname, map, 8)) if (strnicmp (level.MapName, map, 8))
addDefered (FindLevelInfo (map), acsdefered_t::defsuspend, script, NULL, 0, NULL); addDefered (FindLevelInfo (map), acsdefered_t::defsuspend, script, NULL, 0, NULL);
else else
SetScriptState (script, DLevelScript::SCRIPT_Suspended); SetScriptState (script, DLevelScript::SCRIPT_Suspended);
} }
void P_TerminateScript (int script, char *map) void P_TerminateScript (int script, const char *map)
{ {
if (strnicmp (level.mapname, map, 8)) if (strnicmp (level.MapName, map, 8))
addDefered (FindLevelInfo (map), acsdefered_t::defterminate, script, NULL, 0, NULL); addDefered (FindLevelInfo (map), acsdefered_t::defterminate, script, NULL, 0, NULL);
else else
SetScriptState (script, DLevelScript::SCRIPT_PleaseRemove); SetScriptState (script, DLevelScript::SCRIPT_PleaseRemove);

View file

@ -1644,7 +1644,7 @@ FUNC(LS_ACS_Execute)
if (arg1 == 0) if (arg1 == 0)
{ {
mapname = level.mapname; mapname = level.MapName;
} }
else if ((info = FindLevelByNum(arg1)) != NULL) else if ((info = FindLevelByNum(arg1)) != NULL)
{ {
@ -1667,7 +1667,7 @@ FUNC(LS_ACS_ExecuteAlways)
if (arg1 == 0) if (arg1 == 0)
{ {
mapname = level.mapname; mapname = level.MapName;
} }
else if ((info = FindLevelByNum(arg1)) != NULL) else if ((info = FindLevelByNum(arg1)) != NULL)
{ {
@ -1707,7 +1707,7 @@ FUNC(LS_ACS_ExecuteWithResult)
int args[4] = { arg1, arg2, arg3, arg4 }; int args[4] = { arg1, arg2, arg3, arg4 };
int flags = (backSide ? ACS_BACKSIDE : 0) | ACS_ALWAYS | ACS_WANTRESULT; int flags = (backSide ? ACS_BACKSIDE : 0) | ACS_ALWAYS | ACS_WANTRESULT;
return P_StartScript (it, ln, arg0, level.mapname, args, 4, flags); return P_StartScript (it, ln, arg0, level.MapName, args, 4, flags);
} }
FUNC(LS_ACS_Suspend) FUNC(LS_ACS_Suspend)
@ -1716,7 +1716,7 @@ FUNC(LS_ACS_Suspend)
level_info_t *info; level_info_t *info;
if (arg1 == 0) if (arg1 == 0)
P_SuspendScript (arg0, level.mapname); P_SuspendScript (arg0, level.MapName);
else if ((info = FindLevelByNum (arg1)) ) else if ((info = FindLevelByNum (arg1)) )
P_SuspendScript (arg0, info->mapname); P_SuspendScript (arg0, info->mapname);
@ -1729,7 +1729,7 @@ FUNC(LS_ACS_Terminate)
level_info_t *info; level_info_t *info;
if (arg1 == 0) if (arg1 == 0)
P_TerminateScript (arg0, level.mapname); P_TerminateScript (arg0, level.MapName);
else if ((info = FindLevelByNum (arg1)) ) else if ((info = FindLevelByNum (arg1)) )
P_TerminateScript (arg0, info->mapname); P_TerminateScript (arg0, info->mapname);

View file

@ -3559,7 +3559,7 @@ void P_FreeExtraLevelData()
// //
// [RH] position indicates the start spot to spawn at // [RH] position indicates the start spot to spawn at
void P_SetupLevel (char *lumpname, int position) void P_SetupLevel (const char *lumpname, int position)
{ {
cycle_t times[20]; cycle_t times[20];
FMapThing *buildthings; FMapThing *buildthings;

View file

@ -103,7 +103,7 @@ bool P_CheckMapData(const char * mapname);
// [RH] The only parameter used is mapname, so I removed playermask and skill. // [RH] The only parameter used is mapname, so I removed playermask and skill.
// On September 1, 1998, I added the position to indicate which set // On September 1, 1998, I added the position to indicate which set
// of single-player start spots should be spawned in the level. // of single-player start spots should be spawned in the level.
void P_SetupLevel (char *mapname, int position); void P_SetupLevel (const char *mapname, int position);
void P_FreeLevelData(); void P_FreeLevelData();
void P_FreeExtraLevelData(); void P_FreeExtraLevelData();

View file

@ -902,8 +902,8 @@ bool EV_TeleportSector (int tag, int source_tid, int dest_tid, bool fog, int gro
#define ACS_NET 8 #define ACS_NET 8
int P_StartScript (AActor *who, line_t *where, int script, const char *map, const int *args, int argcount, int flags); int P_StartScript (AActor *who, line_t *where, int script, const char *map, const int *args, int argcount, int flags);
void P_SuspendScript (int script, char *map); void P_SuspendScript (int script, const char *map);
void P_TerminateScript (int script, char *map); void P_TerminateScript (int script, const char *map);
void P_DoDeferedScripts (void); void P_DoDeferedScripts (void);
// //

View file

@ -484,7 +484,7 @@ static bool Cht_ChangeStartSpot (cheatseq_t *cheat)
{ {
char cmd[64]; char cmd[64];
mysnprintf (cmd, countof(cmd), "changemap %s %c", level.mapname, cheat->Args[0]); mysnprintf (cmd, countof(cmd), "changemap %s %c", level.MapName.GetChars(), cheat->Args[0]);
C_DoCommand (cmd); C_DoCommand (cmd);
return true; return true;
} }

View file

@ -408,12 +408,13 @@ static void StoreLevelStats()
{ {
for(i=0;i<LevelData.Size();i++) for(i=0;i<LevelData.Size();i++)
{ {
if (!stricmp(LevelData[i].levelname, level.mapname)) break; if (!stricmp(LevelData[i].levelname, level.MapName)) break;
} }
if (i==LevelData.Size()) if (i==LevelData.Size())
{ {
LevelData.Reserve(1); LevelData.Reserve(1);
strcpy(LevelData[i].levelname, level.mapname); strncpy(LevelData[i].levelname, level.MapName, 8);
LevelData[i].levelname[8] = 0;
} }
LevelData[i].totalkills = level.total_monsters; LevelData[i].totalkills = level.total_monsters;
LevelData[i].killcount = level.killed_monsters; LevelData[i].killcount = level.killed_monsters;

View file

@ -1061,11 +1061,7 @@ void DoomSpecificInfo (char *buffer, size_t bufflen)
} }
else else
{ {
char name[9]; buffer += mysnprintf (buffer, buffend - buffer, "\r\n\r\nCurrent map: %s", level.MapName.GetChars());
strncpy (name, level.mapname, 8);
name[8] = 0;
buffer += mysnprintf (buffer, buffend - buffer, "\r\n\r\nCurrent map: %s", name);
if (!viewactive) if (!viewactive)
{ {

View file

@ -252,9 +252,13 @@ public:
int Compare (const FString &other) const { return strcmp (Chars, other.Chars); } int Compare (const FString &other) const { return strcmp (Chars, other.Chars); }
int Compare (const char *other) const { return strcmp (Chars, other); } int Compare (const char *other) const { return strcmp (Chars, other); }
int Compare(const FString &other, int len) const { return strncmp(Chars, other.Chars, len); }
int Compare(const char *other, int len) const { return strncmp(Chars, other, len); }
int CompareNoCase (const FString &other) const { return stricmp (Chars, other.Chars); } int CompareNoCase (const FString &other) const { return stricmp (Chars, other.Chars); }
int CompareNoCase (const char *other) const { return stricmp (Chars, other); } int CompareNoCase (const char *other) const { return stricmp (Chars, other); }
int CompareNoCase(const FString &other, int len) const { return strnicmp(Chars, other.Chars, len); }
int CompareNoCase(const char *other, int len) const { return strnicmp(Chars, other, len); }
protected: protected:
const FStringData *Data() const { return (FStringData *)Chars - 1; } const FStringData *Data() const { return (FStringData *)Chars - 1; }