mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 06:53:58 +00:00
- made all references to the GameNames array an inline function call to allow easier modification later
- changed all parsers that check for the current game to use the same function for the game check. - fixed: The TEAMINFO parser handled 'game Any' incorrectly. SVN r2934 (trunk)
This commit is contained in:
parent
dd17c35d89
commit
352a926ddf
13 changed files with 37 additions and 104 deletions
|
@ -1877,7 +1877,7 @@ void D_DoomMain (void)
|
|||
gameinfo.gametype = iwad_info->gametype;
|
||||
gameinfo.flags = iwad_info->flags;
|
||||
|
||||
GameConfig->DoGameSetup (GameNames[gameinfo.gametype]);
|
||||
GameConfig->DoGameSetup (GameName());
|
||||
|
||||
if (!(gameinfo.flags & GI_SHAREWARE) && !Args->CheckParm("-noautoload"))
|
||||
{
|
||||
|
@ -1910,7 +1910,7 @@ void D_DoomMain (void)
|
|||
D_AddConfigWads (allwads, "Global.Autoload");
|
||||
|
||||
// Add game-specific wads
|
||||
file = GameNames[gameinfo.gametype];
|
||||
file = GameName();
|
||||
file += ".Autoload";
|
||||
D_AddConfigWads (allwads, file);
|
||||
|
||||
|
@ -1925,7 +1925,7 @@ void D_DoomMain (void)
|
|||
|
||||
// Run automatically executed files
|
||||
execFiles = new DArgs;
|
||||
GameConfig->AddAutoexec (execFiles, GameNames[gameinfo.gametype]);
|
||||
GameConfig->AddAutoexec (execFiles, GameName());
|
||||
D_MultiExec (execFiles, true);
|
||||
|
||||
// Run .cfg files at the start of the command line.
|
||||
|
@ -2145,7 +2145,7 @@ void D_DoomMain (void)
|
|||
|
||||
StartScreen->Progress ();
|
||||
|
||||
Printf ("R_Init: Init %s refresh subsystem.\n", GameNames[gameinfo.gametype]);
|
||||
Printf ("R_Init: Init %s refresh subsystem.\n", GameName());
|
||||
StartScreen->LoadingStatus ("Loading graphics", 0x3f);
|
||||
R_Init ();
|
||||
|
||||
|
|
|
@ -199,27 +199,11 @@ static void ParseLock(FScanner &sc)
|
|||
keynum = sc.Number;
|
||||
|
||||
sc.MustGetString();
|
||||
if (sc.Compare("DOOM"))
|
||||
if (!sc.Compare("{"))
|
||||
{
|
||||
if (gameinfo.gametype != GAME_Doom) keynum=-1;
|
||||
if (!CheckGame(sc.String, false)) keynum = -1;
|
||||
sc.MustGetStringName("{");
|
||||
}
|
||||
else if (sc.Compare("HERETIC"))
|
||||
{
|
||||
if (gameinfo.gametype != GAME_Heretic) keynum=-1;
|
||||
}
|
||||
else if (sc.Compare("HEXEN"))
|
||||
{
|
||||
if (gameinfo.gametype != GAME_Hexen) keynum=-1;
|
||||
}
|
||||
else if (sc.Compare("STRIFE"))
|
||||
{
|
||||
if (gameinfo.gametype != GAME_Strife) keynum=-1;
|
||||
}
|
||||
else if (sc.Compare("CHEX"))
|
||||
{
|
||||
if (gameinfo.gametype != GAME_Chex) keynum=-1;
|
||||
}
|
||||
else sc.UnGet();
|
||||
|
||||
ignorekey = true;
|
||||
if (keynum > 0 && keynum < 255)
|
||||
|
@ -239,7 +223,6 @@ static void ParseLock(FScanner &sc)
|
|||
sc.ScriptError("Lock index %d out of range", keynum);
|
||||
}
|
||||
|
||||
sc.MustGetStringName("{");
|
||||
while (!sc.CheckString("}"))
|
||||
{
|
||||
sc.MustGetString();
|
||||
|
|
12
src/gi.h
12
src/gi.h
|
@ -135,4 +135,16 @@ struct gameinfo_t
|
|||
|
||||
extern gameinfo_t gameinfo;
|
||||
|
||||
inline const char *GameName()
|
||||
{
|
||||
return GameNames[gameinfo.gametype];
|
||||
}
|
||||
|
||||
inline bool CheckGame(const char *string, bool chexisdoom)
|
||||
{
|
||||
int test = gameinfo.gametype;
|
||||
if (test == GAME_Chex && chexisdoom) test = GAME_Doom;
|
||||
return !stricmp(string, GameNames[test]);
|
||||
}
|
||||
|
||||
#endif //__GI_H__
|
||||
|
|
|
@ -48,10 +48,10 @@ static void LoadKeys (const char *modname, bool dbl)
|
|||
{
|
||||
char section[64];
|
||||
|
||||
if (GameNames[gameinfo.gametype] == NULL)
|
||||
if (GameName() == NULL)
|
||||
return;
|
||||
|
||||
mysnprintf (section, countof(section), "%s.%s%sBindings", GameNames[gameinfo.gametype], modname,
|
||||
mysnprintf (section, countof(section), "%s.%s%sBindings", GameName(), modname,
|
||||
dbl ? ".Double" : ".");
|
||||
|
||||
FKeyBindings *bindings = dbl? &DoubleBindings : &Bindings;
|
||||
|
|
|
@ -375,9 +375,9 @@ bool M_SaveDefaults (const char *filename)
|
|||
GameConfig->ChangePathName (filename);
|
||||
}
|
||||
GameConfig->ArchiveGlobalData ();
|
||||
if (GameNames[gameinfo.gametype] != NULL)
|
||||
if (GameName() != NULL)
|
||||
{
|
||||
GameConfig->ArchiveGameData (GameNames[gameinfo.gametype]);
|
||||
GameConfig->ArchiveGameData (GameName());
|
||||
}
|
||||
success = GameConfig->WriteConfigFile ();
|
||||
if (filename != NULL)
|
||||
|
@ -619,7 +619,7 @@ static bool FindFreeName (FString &fullname, const char *extension)
|
|||
|
||||
for (i = 0; i <= 9999; i++)
|
||||
{
|
||||
const char *gamename = GameNames[gameinfo.gametype];
|
||||
const char *gamename = GameName();
|
||||
|
||||
time_t now;
|
||||
tm *tm;
|
||||
|
|
|
@ -960,6 +960,6 @@ CCMD(reset2defaults)
|
|||
CCMD(reset2saved)
|
||||
{
|
||||
GameConfig->DoGlobalSetup ();
|
||||
GameConfig->DoGameSetup (GameNames[gameinfo.gametype]);
|
||||
GameConfig->DoGameSetup (GameName());
|
||||
R_SetViewSize (screenblocks);
|
||||
}
|
||||
|
|
|
@ -112,20 +112,16 @@ static void SkipSubBlock(FScanner &sc)
|
|||
|
||||
static bool CheckSkipGameBlock(FScanner &sc)
|
||||
{
|
||||
int filter = 0;
|
||||
bool filter = false;
|
||||
sc.MustGetStringName("(");
|
||||
do
|
||||
{
|
||||
sc.MustGetString();
|
||||
if (sc.Compare("Doom")) filter |= GAME_Doom;
|
||||
if (sc.Compare("Heretic")) filter |= GAME_Heretic;
|
||||
if (sc.Compare("Hexen")) filter |= GAME_Hexen;
|
||||
if (sc.Compare("Strife")) filter |= GAME_Strife;
|
||||
if (sc.Compare("Chex")) filter |= GAME_Chex;
|
||||
filter |= CheckGame(sc.String, false);
|
||||
}
|
||||
while (sc.CheckString(","));
|
||||
sc.MustGetStringName(")");
|
||||
if (!(gameinfo.gametype & filter))
|
||||
if (!filter)
|
||||
{
|
||||
SkipSubBlock(sc);
|
||||
return true;
|
||||
|
|
|
@ -332,31 +332,10 @@ static void ParseOuter (FScanner &sc)
|
|||
break;
|
||||
|
||||
case OUT_IFDOOM:
|
||||
if (!(gameinfo.gametype & GAME_DoomChex))
|
||||
{
|
||||
ifskip = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case OUT_IFHERETIC:
|
||||
if (gameinfo.gametype != GAME_Heretic)
|
||||
{
|
||||
ifskip = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case OUT_IFHEXEN:
|
||||
if (gameinfo.gametype != GAME_Hexen)
|
||||
{
|
||||
ifskip = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case OUT_IFSTRIFE:
|
||||
if (gameinfo.gametype != GAME_Strife)
|
||||
{
|
||||
ifskip = true;
|
||||
}
|
||||
ifskip = !CheckGame(sc.String+2, true);
|
||||
break;
|
||||
|
||||
case OUT_ENDIF:
|
||||
|
|
|
@ -1449,7 +1449,7 @@ public:
|
|||
floordrop = true;
|
||||
break;
|
||||
default:
|
||||
Printf("Unknown namespace %s. Using defaults for %s\n", sc.String, GameNames[gameinfo.gametype]);
|
||||
Printf("Unknown namespace %s. Using defaults for %s\n", sc.String, GameName());
|
||||
switch (gameinfo.gametype)
|
||||
{
|
||||
default: // Shh, GCC
|
||||
|
|
|
@ -1301,31 +1301,10 @@ static void S_AddSNDINFO (int lump)
|
|||
break;
|
||||
|
||||
case SI_IfDoom: //also Chex
|
||||
if (!(gameinfo.gametype & GAME_DoomChex))
|
||||
{
|
||||
skipToEndIf = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case SI_IfStrife:
|
||||
if (gameinfo.gametype != GAME_Strife)
|
||||
{
|
||||
skipToEndIf = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case SI_IfHeretic:
|
||||
if (gameinfo.gametype != GAME_Heretic)
|
||||
{
|
||||
skipToEndIf = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case SI_IfHexen:
|
||||
if (gameinfo.gametype != GAME_Hexen)
|
||||
{
|
||||
skipToEndIf = true;
|
||||
}
|
||||
skipToEndIf = !CheckGame(sc.String+3, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -231,7 +231,7 @@ void FStringTable::LoadLanguage (int lumpnum, DWORD code, bool exactMatch, int p
|
|||
sc.MustGetStringName("ifgame");
|
||||
sc.MustGetStringName("(");
|
||||
sc.MustGetString();
|
||||
skip |= !sc.Compare(GameNames[gameinfo.gametype]);
|
||||
skip |= !sc.Compare(GameName());
|
||||
sc.MustGetStringName(")");
|
||||
sc.MustGetString();
|
||||
|
||||
|
|
|
@ -113,7 +113,6 @@ enum ETeamOptions
|
|||
|
||||
FTeam::FTeam ()
|
||||
{
|
||||
m_GameFilter = 0;
|
||||
m_iPlayerColor = 0;
|
||||
m_iPlayerCount = 0;
|
||||
m_iScore = 0;
|
||||
|
@ -162,6 +161,7 @@ void FTeam::ParseTeamInfo ()
|
|||
void FTeam::ParseTeamDefinition (FScanner &Scan)
|
||||
{
|
||||
FTeam Team;
|
||||
int valid = -1;
|
||||
Scan.MustGetString ();
|
||||
Team.m_Name = Scan.String;
|
||||
Scan.MustGetStringName ("{");
|
||||
|
@ -174,23 +174,9 @@ void FTeam::ParseTeamDefinition (FScanner &Scan)
|
|||
{
|
||||
case TEAMINFO_Game:
|
||||
Scan.MustGetString ();
|
||||
|
||||
if (!stricmp (Scan.String, "Doom"))
|
||||
Team.m_GameFilter |= GAME_Doom;
|
||||
else if (!stricmp (Scan.String, "Heretic"))
|
||||
Team.m_GameFilter |= GAME_Heretic;
|
||||
else if (!stricmp (Scan.String, "Hexen"))
|
||||
Team.m_GameFilter |= GAME_Hexen;
|
||||
else if (!stricmp (Scan.String, "Raven"))
|
||||
Team.m_GameFilter |= GAME_Raven;
|
||||
else if (!stricmp (Scan.String, "Strife"))
|
||||
Team.m_GameFilter |= GAME_Strife;
|
||||
else if (!stricmp (Scan.String, "Chex"))
|
||||
Team.m_GameFilter |= GAME_Chex;
|
||||
else if (!stricmp (Scan.String, "Any"))
|
||||
Team.m_GameFilter |= GAME_Any;
|
||||
else
|
||||
Scan.ScriptError ("ParseTeamDefinition: Unknown game type '%s'.\n", Scan.String);
|
||||
if (Scan.Compare("Any")) valid = 1;
|
||||
else if (CheckGame(Scan.String, false)) valid = 1;
|
||||
else if (valid == -1) valid = 0;
|
||||
break;
|
||||
|
||||
case TEAMINFO_PlayerColor:
|
||||
|
@ -236,8 +222,7 @@ void FTeam::ParseTeamDefinition (FScanner &Scan)
|
|||
}
|
||||
}
|
||||
|
||||
if (Team.m_GameFilter == 0 || Team.m_GameFilter & gameinfo.gametype)
|
||||
Teams.Push (Team);
|
||||
if (valid) Teams.Push (Team);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -64,7 +64,6 @@ private:
|
|||
void ClearTeams ();
|
||||
|
||||
FString m_Name;
|
||||
BYTE m_GameFilter;
|
||||
int m_iPlayerColor;
|
||||
FString m_TextColor;
|
||||
FString m_Logo;
|
||||
|
|
Loading…
Reference in a new issue