From a9f70ed1f12ac451f28ae82c270c74b31bd764d6 Mon Sep 17 00:00:00 2001 From: fusion32 Date: Thu, 16 Apr 2026 07:21:23 -0300 Subject: small change to monster talking Monsters will prefix their lines with "#Y" when they're supposed to yell. The minotaur mage from the leaked files uses a "#W" prefix which is either a mistake or some removed feature? Either way, it wouldn't be a problem with the original binary because it would only check for a leading "#" before removing a three character prefix. --- src/crnonpl.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/crnonpl.cc b/src/crnonpl.cc index 1522cab..ec6af03 100644 --- a/src/crnonpl.cc +++ b/src/crnonpl.cc @@ -2392,13 +2392,14 @@ void TMonster::IdleStimulus(void){ int TalkNr = random(1, RaceData[this->Race].Talks); const char *Text = GetDynamicString(*RaceData[this->Race].Talk.at(TalkNr)); if(Text != 0 && Text[0] != 0){ - // TODO(fusion): We were only checking for a `#` but it could be - // problematic for any two character nul terminated string, since - // adding 3 would make it point out of bounds. Poor string management - // is a recurring theme. + // NOTE(fusion): The original would only check for a leading '#' before + // advancing 3 characters. This would be a problem for any 2 character + // string since we'd end up pointing beyond the null terminator. int Mode = TALK_ANIMAL_LOW; - if(Text[0] == '#' && (Text[1] == 'y' || Text[1] == 'Y') && Text[2] == ' '){ - Mode = TALK_ANIMAL_LOUD; + if(Text[0] == '#' && Text[1] != 0 && Text[2] == ' '){ + if(Text[1] == 'y' || Text[1] == 'Y'){ + Mode = TALK_ANIMAL_LOUD; + } Text += 3; } -- cgit v1.2.3