diff options
| author | fusion32 <marcopuzziello@gmail.com> | 2026-04-16 07:21:23 -0300 |
|---|---|---|
| committer | fusion32 <marcopuzziello@gmail.com> | 2026-04-16 07:34:02 -0300 |
| commit | a9f70ed1f12ac451f28ae82c270c74b31bd764d6 (patch) | |
| tree | 5d6fcc16e9ed3186c4d17a525b146d714d41cd99 /src/crnonpl.cc | |
| parent | f9beda08323beddac2b7b362371c5d4eca374f34 (diff) | |
| download | game-a9f70ed1f12ac451f28ae82c270c74b31bd764d6.tar.gz game-a9f70ed1f12ac451f28ae82c270c74b31bd764d6.zip | |
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.
Diffstat (limited to 'src/crnonpl.cc')
| -rw-r--r-- | src/crnonpl.cc | 13 |
1 files changed, 7 insertions, 6 deletions
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; } |
