From 865bd06845e47897e50b79206cf54439dfef3f04 Mon Sep 17 00:00:00 2001 From: Walter van Niftrik Date: Sat, 26 Mar 2016 09:44:40 +0100 Subject: ADL: Move room-local commands into base class --- engines/adl/adl.cpp | 5 +++++ engines/adl/adl.h | 15 ++++++++++++++- engines/adl/hires2.cpp | 7 ------- engines/adl/hires2.h | 13 ------------- 4 files changed, 19 insertions(+), 21 deletions(-) (limited to 'engines') diff --git a/engines/adl/adl.cpp b/engines/adl/adl.cpp index d95cfd519b..90606f761d 100644 --- a/engines/adl/adl.cpp +++ b/engines/adl/adl.cpp @@ -274,6 +274,11 @@ void AdlEngine::readCommands(Common::ReadStream &stream, Commands &commands) { } void AdlEngine::checkInput(byte verb, byte noun) { + // Try room-local command list first + if (doOneCommand(_roomData.commands, verb, noun)) + return; + + // If no match was found, try the global list if (!doOneCommand(_roomCommands, verb, noun)) printMessage(_messageIds.dontUnderstand); } diff --git a/engines/adl/adl.h b/engines/adl/adl.h index 731b7e3078..d21bd7b7a3 100644 --- a/engines/adl/adl.h +++ b/engines/adl/adl.h @@ -164,6 +164,17 @@ struct State { typedef Common::List Commands; typedef Common::HashMap WordMap; +struct Picture2 { + byte nr; + DataBlockPtr data; +}; + +struct RoomData { + Common::String description; + Common::Array pictures; + Commands commands; +}; + class AdlEngine : public Engine { public: virtual ~AdlEngine(); @@ -189,7 +200,7 @@ protected: void loadWords(Common::ReadStream &stream, WordMap &map) const; void readCommands(Common::ReadStream &stream, Commands &commands); - virtual void checkInput(byte verb, byte noun); + void checkInput(byte verb, byte noun); virtual void setupOpcodeTables(); virtual bool matchesCurrentPic(byte pic) const; @@ -266,6 +277,8 @@ protected: // lists Commands _roomCommands; Commands _globalCommands; + // Data related to the current room + RoomData _roomData; WordMap _verbs; WordMap _nouns; diff --git a/engines/adl/hires2.cpp b/engines/adl/hires2.cpp index 5e3da007a9..3543c92ba4 100644 --- a/engines/adl/hires2.cpp +++ b/engines/adl/hires2.cpp @@ -243,13 +243,6 @@ void HiRes2Engine::printMessage(uint idx, bool wait) { printString(_messages[idx - 1]); } -void HiRes2Engine::checkInput(byte verb, byte noun) { - if (doOneCommand(_roomData.commands, verb, noun)) - return; - - AdlEngine::checkInput(verb, noun); -} - Engine *HiRes2Engine_create(OSystem *syst, const AdlGameDescription *gd) { return new HiRes2Engine(syst, gd); } diff --git a/engines/adl/hires2.h b/engines/adl/hires2.h index a9a4caa97d..0281a7993d 100644 --- a/engines/adl/hires2.h +++ b/engines/adl/hires2.h @@ -50,17 +50,6 @@ namespace Adl { #define IDI_HR2_MSG_ITEM_NOT_HERE 4 #define IDI_HR2_MSG_THANKS_FOR_PLAYING 239 -struct Picture2 { - byte nr; - DataBlockPtr data; -}; - -struct RoomData { - Common::String description; - Common::Array pictures; - Commands commands; -}; - class HiRes2Engine : public AdlEngine_v2 { public: HiRes2Engine(OSystem *syst, const AdlGameDescription *gd) : AdlEngine_v2(syst, gd) { } @@ -75,14 +64,12 @@ private: void drawItem(const Item &item, const Common::Point &pos) const; void showRoom(); void printMessage(uint idx, bool wait); - void checkInput(byte verb, byte noun); void loadRoom(byte roomNr); DataBlockPtr readDataBlockPtr(Common::ReadStream &f) const; void readPictureMeta(Common::ReadStream &f, Picture2 &pic) const; DiskImage_DSK _disk; - RoomData _roomData; Common::Array _itemPics; }; -- cgit v1.2.3