diff --git a/src/g_statusbar/sbarinfo.cpp b/src/g_statusbar/sbarinfo.cpp index 13d77dbe6..e626efbd8 100644 --- a/src/g_statusbar/sbarinfo.cpp +++ b/src/g_statusbar/sbarinfo.cpp @@ -490,12 +490,9 @@ void SBarInfo::ParseSBarInfo(int lump) continue; } int baselump = -2; - FString SBarInfoTopLevelString; - if(sc.GetString(SBarInfoTopLevelString)) - { // Store the string if the next token is a string, and revert scanner state afterwards - sc.UnGet(); - } - switch(sc.MustMatchString(SBarInfoTopLevel)) + // Store the command, used for the switch statement and case SBARINFO_APPENDSTATUSBAR. + const int command = sc.MustMatchString(SBarInfoTopLevel); + switch(command) { case SBARINFO_BASE: baseSet = true; @@ -647,8 +644,7 @@ void SBarInfo::ParseSBarInfo(int lump) barNum = sc.MustMatchString(StatusBars); } // SBARINFO_APPENDSTATUSBAR shouldn't delete the old HUD if it exists. - const bool append = (SBarInfoTopLevelString.CompareNoCase("appendstatusbar") == 0); - if (!append) + if (command != SBARINFO_APPENDSTATUSBAR) { if (this->huds[barNum] != NULL) { @@ -656,6 +652,10 @@ void SBarInfo::ParseSBarInfo(int lump) } this->huds[barNum] = new SBarInfoMainBlock(this); } + else if (this->huds[barNum] == NULL) + { + sc.ScriptError( "AppendStatusBar can't be used on a HUD that doesn't exist yet." ); + } if(barNum == STBAR_AUTOMAP) { automapbar = true;