- improved handling of HUDMSG_TYPEON

This includes the following changes
* Validation of serialized values
* Proper fix for message cut off after an empty line, part of https://forum.zdoom.org/viewtopic.php?t=63935, which appeared to be broken again with dbf06fc
* No crash with an empty HUD message, https://forum.zdoom.org/viewtopic.php?t=63761 and https://forum.zdoom.org/viewtopic.php?t=64569
This commit is contained in:
alexey.lysiuk 2019-05-04 13:26:36 +03:00
parent dbf06fc9ca
commit a33fae19dd

View file

@ -737,8 +737,21 @@ void DHUDMessageTypeOnFadeOut::Serialize(FSerializer &arc)
Super::Serialize (arc); Super::Serialize (arc);
arc("typeontime", TypeOnTime) arc("typeontime", TypeOnTime)
("currline", CurrLine) ("currline", CurrLine)
("linevisible", LineVisible) ("linevisible", LineVisible);
("linelen", LineLen);
if (arc.isReading())
{
if (CurrLine < NumLines)
{
LineLen = (int)Lines[CurrLine].Text.Len();
}
else
{
LineLen = CurrLine = 0;
}
clamp(LineVisible, 0, LineLen);
}
} }
//============================================================================ //============================================================================
@ -749,7 +762,7 @@ void DHUDMessageTypeOnFadeOut::Serialize(FSerializer &arc)
bool DHUDMessageTypeOnFadeOut::Tick () bool DHUDMessageTypeOnFadeOut::Tick ()
{ {
if (LineLen > 0 && !Super::Tick ()) if (NumLines > 0 && !Super::Tick ())
{ {
if (State == 3) if (State == 3)
{ {
@ -820,7 +833,7 @@ void DHUDMessageTypeOnFadeOut::ScreenSizeChanged ()
if (State == 3) if (State == 3)
{ {
CurrLine = 0; CurrLine = 0;
LineLen = Lines.Size() > 0 ? (int)Lines[0].Text.Len() : 0; LineLen = NumLines > 0 ? (int)Lines[0].Text.Len() : 0;
Tics = (int)(charCount * TypeOnTime) - 1; Tics = (int)(charCount * TypeOnTime) - 1;
Tick (); Tick ();
} }