3 Commits

Author SHA1 Message Date
NyakoFox
9bcade9776 Add statedelay argument to gamestate command
The `gamestate` command has an argument to set the gamestate, but the
statedelay was always set to 0, despite the statedelay being an
important part of the gamestate system. This commit adds an optional
argument to set the statedelay.
2026-02-25 20:32:55 -05:00
NyakoFox
deeed00c95 Make sure special roomnames have enough text
There's another crash, which is indexing out of bounds if there's
not enough text. This adds simple bounds checks for them.
2026-02-16 11:42:43 -05:00
NyakoFox
11b660abb0 Fix empty roomnames potentially crashing the game
TinyXML2 seems to sometimes return NULL when an element has either no
text or whitespace, instead of returning an empty string. Why it does
this, I'm not sure, but I have recently learned from Dav999 that it
will crash the game. Great.
2026-02-16 11:42:43 -05:00
3 changed files with 19 additions and 4 deletions

View File

@@ -1392,6 +1392,10 @@ next:
{
name.text.push_back(std::string(text));
}
else
{
name.text.push_back(std::string(""));
}
}
else
{
@@ -1409,6 +1413,10 @@ next:
{
name.text.push_back(std::string(text));
}
else
{
name.text.push_back(std::string(""));
}
}
}
}

View File

@@ -222,11 +222,11 @@ void mapclass::updateroomnames(void)
if (rx == roomname->x && ry == roomname->y && (roomname->flag == -1 || (INBOUNDS_ARR(roomname->flag, obj.flags) && obj.flags[roomname->flag])))
{
roomname_special = true;
if (roomname->type == RoomnameType_STATIC)
if (roomname->type == RoomnameType_STATIC && roomname->text.size() >= 1)
{
setroomname(roomname->text[0].c_str());
}
if (roomname->type == RoomnameType_GLITCH)
if (roomname->type == RoomnameType_GLITCH && roomname->text.size() >= 2)
{
roomname->delay--;
if (roomname->delay <= 0)
@@ -240,7 +240,7 @@ void mapclass::updateroomnames(void)
}
setroomname(roomname->text[roomname->progress].c_str());
}
if (roomname->type == RoomnameType_TRANSFORM)
if (roomname->type == RoomnameType_TRANSFORM && roomname->text.size() >= 1)
{
roomname->delay--;
if (roomname->delay <= 0)

View File

@@ -1346,7 +1346,14 @@ void scriptclass::run(void)
{
// Allow the gamestate command to bypass statelock, at least for now
game.state = ss_toi(words[1]);
game.statedelay = 0;
if (argexists[2])
{
game.statedelay = ss_toi(words[2]);
}
else
{
game.statedelay = 0;
}
}
else if (words[0] == "textboxactive")
{