- 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
1 changed files with 17 additions and 4 deletions

View File

@ -737,8 +737,21 @@ void DHUDMessageTypeOnFadeOut::Serialize(FSerializer &arc)
Super::Serialize (arc);
arc("typeontime", TypeOnTime)
("currline", CurrLine)
("linevisible", LineVisible)
("linelen", LineLen);
("linevisible", LineVisible);
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 ()
{
if (LineLen > 0 && !Super::Tick ())
if (NumLines > 0 && !Super::Tick ())
{
if (State == 3)
{
@ -820,7 +833,7 @@ void DHUDMessageTypeOnFadeOut::ScreenSizeChanged ()
if (State == 3)
{
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;
Tick ();
}