[Scummvm-tracker] [ScummVM :: Bugs] #15382: ADL: HIRES5: Crash printing an apparently corrupt string

ScummVM :: Bugs trac at scummvm.org
Fri Sep 27 09:14:59 UTC 2024


#15382: ADL: HIRES5: Crash printing an apparently corrupt string
-------------------------+---------------------------------------------
Reporter:  eriktorbjorn  |       Owner:  (none)
    Type:  defect        |      Status:  new
Priority:  normal        |   Component:  Engine: ADL
 Version:                |  Resolution:
Keywords:                |        Game:  Hi-Res Adventure #5: Time Zone
-------------------------+---------------------------------------------
Comment (by eriktorbjorn):

 For the second case, it actually prints two messages:

 {{{
 IF
         ROOM == 73
         && SAID(42/LOCK    , 65/GATE    )
         && GET_ITEM_ROOM(46/KEY     /A SKELETON KEY) == CARRYING
         && VARS[13] == 1
 THEN
         PRINT(172/<corrupted string>)
         PRINT(204/O.K. )
         VARS[13] = 0
 END
 }}}

 So maybe something like this would be enough? I've never used `SharedPtr`
 myself, but it seems to work for me:

 {{{
 diff --git a/engines/adl/adl.cpp b/engines/adl/adl.cpp
 index 79f55f782f4..c60be6419c3 100644
 --- a/engines/adl/adl.cpp
 +++ b/engines/adl/adl.cpp
 @@ -444,6 +444,15 @@ Command &AdlEngine::getCommand(Commands &commands,
 uint idx) {
         error("Command %d not found", idx);
  }

 +void AdlEngine::removeMessage(uint idx) {
 +       if (_messages[idx]) {
 +               _messages[idx].reset();
 +               return;
 +       }
 +
 +       error("Message %d not found", idx);
 +}
 +
  void AdlEngine::checkInput(byte verb, byte noun) {
         // Try room-local command list first
         if (doOneCommand(_roomData.commands, verb, noun))
 diff --git a/engines/adl/adl.h b/engines/adl/adl.h
 index a749c65a690..cea2313c8d5 100644
 @@ -297,6 +297,7 @@ protected:
         void readCommands(Common::ReadStream &stream, Commands &commands);
         void removeCommand(Commands &commands, uint idx);
         Command &getCommand(Commands &commands, uint idx);
 +       void removeMessage(uint idx);
         void checkInput(byte verb, byte noun);
         virtual bool isInputValid(byte verb, byte noun, bool &is_any);
         virtual bool isInputValid(const Commands &commands, byte verb,
 byte noun, bool &is_any);
 diff --git a/engines/adl/hires5.cpp b/engines/adl/hires5.cpp
 index 8a14b0ab24f..1f1b9de7d89 100644
 --- a/engines/adl/hires5.cpp
 +++ b/engines/adl/hires5.cpp
 @@ -371,6 +371,14 @@ void HiRes5Engine::applyRegionWorkarounds() {
                 // of the script.
                 removeCommand(_roomCommands, 0);
                 break;
 +       case 40:
 +               // Locking the gate prints a missing message, followed by
 +               // "O.K.". Maybe there was supposed to be a more elaborate
 +               // message, in the style of the one printed when you
 unlock
 +               // the gate. But "O.K." should be enough, so we remove the
 +               // first one.
 +               removeMessage(172);
 +               break;
         default:
                 break;
         }
 }}}
-- 
Ticket URL: <https://bugs.scummvm.org/ticket/15382#comment:2>
ScummVM :: Bugs <https://bugs.scummvm.org>
ScummVM


More information about the Scummvm-tracker mailing list