Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions src/g_statusbar/sbarinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ enum //Key words
SBARINFO_MUGSHOT,
SBARINFO_CREATEPOPUP,
SBARINFO_PROTRUSION,
SBARINFO_APPENDSTATUSBAR,
};

enum //Bar types
Expand Down Expand Up @@ -410,6 +411,7 @@ static const char *SBarInfoTopLevel[] =
"mugshot",
"createpopup",
"protrusion",
"appendstatusbar",
NULL
};

Expand Down Expand Up @@ -488,7 +490,9 @@ void SBarInfo::ParseSBarInfo(int lump)
continue;
}
int baselump = -2;
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;
Expand Down Expand Up @@ -629,6 +633,7 @@ void SBarInfo::ParseSBarInfo(int lump)
sc.MustGetToken(';');
break;
case SBARINFO_STATUSBAR:
case SBARINFO_APPENDSTATUSBAR:
{
if(!baseSet) //If the user didn't explicitly define a base, do so now.
gameType = GAME_Any;
Expand All @@ -638,11 +643,19 @@ void SBarInfo::ParseSBarInfo(int lump)
sc.MustGetToken(TK_Identifier);
barNum = sc.MustMatchString(StatusBars);
}
if (this->huds[barNum] != NULL)
// SBARINFO_APPENDSTATUSBAR shouldn't delete the old HUD if it exists.
if(command != SBARINFO_APPENDSTATUSBAR)
{
delete this->huds[barNum];
if (this->huds[barNum] != NULL)
{
delete this->huds[barNum];
}
this->huds[barNum] = new SBarInfoMainBlock(this);
}
else if(this->huds[barNum] == NULL)
{
sc.ScriptError("Status bar '%s' has not been created and cannot be appended to. Use 'StatusBar' instead.", StatusBars[barNum]);
}
this->huds[barNum] = new SBarInfoMainBlock(this);
if(barNum == STBAR_AUTOMAP)
{
automapbar = true;
Expand Down