Commit MetaInfo

Revisionbf68a6b3409cf381c814d799086187e4ffcdbbb8 (tree)
Time2022-04-28 09:59:33
AuthorAdam Kaminski <kaminskiadam9@gmai...>
CommiterAdam Kaminski

Log Message

Replaced GAMEMODE_ParserMustGetEnumName with the more generalized FScanner::MustGetEnumName.

Change Summary

Incremental Difference

diff -r df1b67d20883 -r bf68a6b3409c src/gamemode.cpp
--- a/src/gamemode.cpp Tue Apr 26 17:57:00 2022 -0400
+++ b/src/gamemode.cpp Wed Apr 27 20:59:33 2022 -0400
@@ -121,21 +121,6 @@
121121
122122 //*****************************************************************************
123123 //
124-int GAMEMODE_ParserMustGetEnumName ( FScanner &sc, const char *EnumName, const char *FlagPrefix, int (*GetValueFromName) ( const char *Name ), const bool StringAlreadyParse = false )
125-{
126- if ( StringAlreadyParse == false )
127- sc.MustGetString ();
128- FString flagname = FlagPrefix;
129- flagname += sc.String;
130- flagname.ToUpper();
131- const int flagNum = GetValueFromName ( flagname.GetChars() );
132- if ( flagNum == -1 )
133- sc.ScriptError ( "Unknown %s '%s', on line %d in GAMEMODE.", EnumName, sc.String, sc.Line );
134- return flagNum;
135-}
136-
137-//*****************************************************************************
138-//
139124 FFlagCVar *GAMEMODE_ParserMustGetFlagset ( FScanner &sc, const GAMEMODE_e GameMode, FLAGSET_e &Flagset )
140125 {
141126 sc.MustGetString();
@@ -184,11 +169,11 @@
184169
185170 if (0 == stricmp (sc.String, "removeflag"))
186171 {
187- g_GameModes[GameMode].ulFlags &= ~GAMEMODE_ParserMustGetEnumName( sc, "flag", "GMF_", GetValueGMF );
172+ g_GameModes[GameMode].ulFlags &= ~sc.MustGetEnumName( "flag", "GMF_", GetValueGMF );
188173 }
189174 else if (0 == stricmp (sc.String, "addflag"))
190175 {
191- g_GameModes[GameMode].ulFlags |= GAMEMODE_ParserMustGetEnumName( sc, "flag", "GMF_", GetValueGMF );
176+ g_GameModes[GameMode].ulFlags |= sc.MustGetEnumName( "flag", "GMF_", GetValueGMF );
192177 }
193178 else if (0 == stricmp (sc.String, "name"))
194179 {
@@ -340,7 +325,7 @@
340325 }
341326 else
342327 {
343- GAMEMODE_e GameMode = static_cast<GAMEMODE_e>( GAMEMODE_ParserMustGetEnumName( sc, "gamemode", "GAMEMODE_", GetValueGAMEMODE_e, true ) );
328+ GAMEMODE_e GameMode = static_cast<GAMEMODE_e>( sc.MustGetEnumName( "gamemode", "GAMEMODE_", GetValueGAMEMODE_e, true ));
344329 GAMEMODE_ParseGamemodeInfoLump ( sc, GameMode );
345330 }
346331 }
diff -r df1b67d20883 -r bf68a6b3409c src/sc_man.cpp
--- a/src/sc_man.cpp Tue Apr 26 17:57:00 2022 -0400
+++ b/src/sc_man.cpp Wed Apr 27 20:59:33 2022 -0400
@@ -947,6 +947,34 @@
947947
948948 //==========================================================================
949949 //
950+// [AK] FScanner :: MustGetEnumName
951+//
952+//==========================================================================
953+
954+int FScanner::MustGetEnumName(const char *EnumName, const char *FlagPrefix, int (*GetValueFromName) (const char *Name), const bool StringAlreadyParse)
955+{
956+ if (StringAlreadyParse == false)
957+ MustGetString();
958+
959+ FString flagname = FlagPrefix;
960+ flagname += String;
961+ flagname.ToUpper();
962+
963+ const int flagNum = GetValueFromName (flagname.GetChars());
964+
965+ if (flagNum == -1)
966+ {
967+ char pszLumpName[9];
968+ pszLumpName[8] = 0;
969+ Wads.GetLumpName (pszLumpName, LumpNum);
970+ ScriptError ("Unknown %s '%s', on line %d in %s.", EnumName, String, Line, pszLumpName);
971+ }
972+
973+ return flagNum;
974+}
975+
976+//==========================================================================
977+//
950978 // a class that remembers a parser position
951979 //
952980 //==========================================================================
diff -r df1b67d20883 -r bf68a6b3409c src/sc_man.h
--- a/src/sc_man.h Tue Apr 26 17:57:00 2022 -0400
+++ b/src/sc_man.h Wed Apr 27 20:59:33 2022 -0400
@@ -63,6 +63,9 @@
6363
6464 bool isText();
6565
66+ // [AK] Gets the enumeration of the parsed string by searching through a string table, using the given "GetValueFrom" function.
67+ int MustGetEnumName(const char *EnumName, const char *FlagPrefix, int (*GetValueFromName) (const char *Name), const bool StringAlreadyParse = false);
68+
6669 // Members ------------------------------------------------------
6770 char *String;
6871 int StringLen;
Show on old repository browser