diff options
| author | Garrett Cox <garrettjcox@gmail.com> | 2024-01-16 00:23:04 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-15 19:23:04 -0500 |
| commit | b4d8c2159ef21585da6355d5bea178805ec93186 (patch) | |
| tree | 96025fc4b563cb27ff2d9cdf30fd967fa98a8903 | |
| parent | aaf3714f239b80e86ad508b1a715506589624ef2 (diff) | |
Moar text fixes (#5)
| -rw-r--r-- | ZAPD/ZTextMM.cpp | 58 |
1 files changed, 20 insertions, 38 deletions
diff --git a/ZAPD/ZTextMM.cpp b/ZAPD/ZTextMM.cpp index 9903b31..f9e8100 100644 --- a/ZAPD/ZTextMM.cpp +++ b/ZAPD/ZTextMM.cpp @@ -65,50 +65,32 @@ void ZTextMM::ParseMM() msgPtr += 11; unsigned char c = rawData[msgPtr]; - unsigned int extra = 0; - bool stop = false; - bool shouldTerminateOnNull = parent->GetName() == "staff_message_data_static"; - // Continue parsing until we are told to stop and all extra bytes are read - while (( (c != '\0' || !shouldTerminateOnNull) && !stop) || extra > 0) - { + // Read until end marker (0xBF) + while (true) { msgEntry.msg += c; - msgPtr++; - // Some control codes require reading extra bytes - if (extra == 0) - { - // End marker, so stop this message and do not read anything else - if (c == 0xBF) - { - stop = true; - } - else if (c == 0x05 || c == 0x13 || c == 0x0E || c == 0x0C || c == 0x1E || - c == 0x06 || c == 0x14) - { - extra = 1; - } - // "Continue to new text ID", so stop this message and read two more bytes for the - // text ID - else if (c == 0x07) - { - extra = 2; - stop = true; - } - else if (c == 0x12 || c == 0x11) - { - extra = 2; - } - else if (c == 0x15) - { - extra = 3; - } + if (c == 0xBF) { // End marker + break; } - else - { - extra--; + + switch (c) { + case 0x14: // Print: xx Spaces + msgEntry.msg += rawData[msgPtr + 1]; + msgPtr++; + break; + case 0x1B: // Delay for xxxx Before Printing Remaining Text + case 0x1C: // Keep Text on Screen for xxxx Before Closing + case 0x1D: // Delay for xxxx Before Ending Conversation + case 0x1E: // Play Sound Effect xxxx + case 0x1F: // Delay for xxxx Before Resuming Text Flow + msgEntry.msg += rawData[msgPtr + 1]; + msgEntry.msg += rawData[msgPtr + 2]; + msgPtr += 2; + break; } + msgPtr++; c = rawData[msgPtr]; } |
