diff options
author | Paul Gilbert | 2011-10-12 21:12:34 +1100 |
---|---|---|
committer | Paul Gilbert | 2011-10-12 21:12:34 +1100 |
commit | 8a8fd94f100ec4e8891bf8c81a2c4de70d1bfd87 (patch) | |
tree | 685e739db6705f10eed8d83518d052373ea4b2ff | |
parent | 01666659264ece2cd33b0ecc53dd5fc8c3d7de5c (diff) | |
download | scummvm-rg350-8a8fd94f100ec4e8891bf8c81a2c4de70d1bfd87.tar.gz scummvm-rg350-8a8fd94f100ec4e8891bf8c81a2c4de70d1bfd87.tar.bz2 scummvm-rg350-8a8fd94f100ec4e8891bf8c81a2c4de70d1bfd87.zip |
TSAGE: Separated the NamedHotspot class into separate versions for Ringworld and Blue Force
This fixes bug #3422141, which was also caused by special checks introduced to try and handle Blue Force hotspots differently
-rw-r--r-- | engines/tsage/blue_force/blueforce_logic.cpp | 95 | ||||
-rw-r--r-- | engines/tsage/blue_force/blueforce_logic.h | 26 | ||||
-rw-r--r-- | engines/tsage/core.cpp | 106 | ||||
-rw-r--r-- | engines/tsage/core.h | 26 | ||||
-rw-r--r-- | engines/tsage/ringworld/ringworld_logic.cpp | 99 | ||||
-rw-r--r-- | engines/tsage/ringworld/ringworld_logic.h | 25 |
6 files changed, 245 insertions, 132 deletions
diff --git a/engines/tsage/blue_force/blueforce_logic.cpp b/engines/tsage/blue_force/blueforce_logic.cpp index b945343ce7..1c50e7f079 100644 --- a/engines/tsage/blue_force/blueforce_logic.cpp +++ b/engines/tsage/blue_force/blueforce_logic.cpp @@ -1278,6 +1278,101 @@ void BlueForceInvObjectList::alterInventory(int mode) { /*--------------------------------------------------------------------------*/ +NamedHotspot::NamedHotspot() : SceneHotspot() { + _resNum = 0; + _lookLineNum = _useLineNum = _talkLineNum = -1; +} + +bool NamedHotspot::startAction(CursorType action, Event &event) { + switch (action) { + case CURSOR_WALK: + // Nothing + return false; + case CURSOR_LOOK: + if (_lookLineNum == -1) + return SceneHotspot::startAction(action, event); + + SceneItem::display2(_resNum, _lookLineNum); + return true; + case CURSOR_USE: + if (_useLineNum == -1) + return SceneHotspot::startAction(action, event); + + SceneItem::display2(_resNum, _useLineNum); + return true; + case CURSOR_TALK: + if (_talkLineNum == -1) + return SceneHotspot::startAction(action, event); + + SceneItem::display2(_resNum, _talkLineNum); + return true; + default: + return SceneHotspot::startAction(action, event); + } +} + +void NamedHotspot::setDetails(int ys, int xs, int ye, int xe, const int resnum, const int lookLineNum, const int useLineNum) { + setBounds(ys, xe, ye, xs); + _resNum = resnum; + _lookLineNum = lookLineNum; + _useLineNum = useLineNum; + _talkLineNum = -1; + g_globals->_sceneItems.addItems(this, NULL); +} + +void NamedHotspot::setDetails(const Rect &bounds, int resNum, int lookLineNum, int talkLineNum, int useLineNum, int mode, SceneItem *item) { + setBounds(bounds); + _resNum = resNum; + _lookLineNum = lookLineNum; + _talkLineNum = talkLineNum; + _useLineNum = useLineNum; + + switch (mode) { + case 2: + g_globals->_sceneItems.push_front(this); + break; + case 4: + g_globals->_sceneItems.addBefore(item, this); + break; + case 5: + g_globals->_sceneItems.addAfter(item, this); + break; + default: + g_globals->_sceneItems.push_back(this); + break; + } +} + +void NamedHotspot::setDetails(int sceneRegionId, int resNum, int lookLineNum, int talkLineNum, int useLineNum, int mode) { + _sceneRegionId = sceneRegionId; + _resNum = resNum; + _lookLineNum = lookLineNum; + _talkLineNum = talkLineNum; + _useLineNum = useLineNum; + + // Handle adding hotspot to scene items list as necessary + switch (mode) { + case 2: + GLOBALS._sceneItems.push_front(this); + break; + case 3: + break; + default: + GLOBALS._sceneItems.push_back(this); + break; + } +} + +void NamedHotspot::synchronize(Serializer &s) { + SceneHotspot::synchronize(s); + s.syncAsSint16LE(_resNum); + s.syncAsSint16LE(_lookLineNum); + s.syncAsSint16LE(_useLineNum); + + if (g_vm->getGameID() == GType_BlueForce) + s.syncAsSint16LE(_talkLineNum); +} + } // End of namespace BlueForce } // End of namespace TsAGE diff --git a/engines/tsage/blue_force/blueforce_logic.h b/engines/tsage/blue_force/blueforce_logic.h index a39e19ae3d..8764d0b856 100644 --- a/engines/tsage/blue_force/blueforce_logic.h +++ b/engines/tsage/blue_force/blueforce_logic.h @@ -328,6 +328,32 @@ public: virtual Common::String getClassName() { return "BlueForceInvObjectList"; } }; +class NamedHotspot : public SceneHotspot { +public: + int _resNum, _lookLineNum, _useLineNum, _talkLineNum; + NamedHotspot(); + + + virtual bool startAction(CursorType action, Event &event); + virtual Common::String getClassName() { return "NamedHotspot"; } + virtual void synchronize(Serializer &s); + virtual void setDetails(int ys, int xs, int ye, int xe, const int resnum, const int lookLineNum, const int useLineNum); + virtual void setDetails(const Rect &bounds, int resNum, int lookLineNum, int talkLineNum, int useLineNum, int mode, SceneItem *item); + virtual void setDetails(int sceneRegionId, int resNum, int lookLineNum, int talkLineNum, int useLineNum, int mode); +}; + +class NamedHotspotExt : public NamedHotspot { +public: + int _flag; + NamedHotspotExt() { _flag = 0; } + + virtual Common::String getClassName() { return "NamedHotspot"; } + virtual void synchronize(Serializer &s) { + NamedHotspot::synchronize(s); + s.syncAsSint16LE(_flag); + } +}; + } // End of namespace BlueForce } // End of namespace TsAGE diff --git a/engines/tsage/core.cpp b/engines/tsage/core.cpp index 3441c81222..f4118cb45e 100644 --- a/engines/tsage/core.cpp +++ b/engines/tsage/core.cpp @@ -1731,112 +1731,6 @@ void SceneHotspot::doAction(int action) { /*--------------------------------------------------------------------------*/ -NamedHotspot::NamedHotspot() : SceneHotspot() { - _resNum = 0; - _lookLineNum = _useLineNum = _talkLineNum = -1; -} - -bool NamedHotspot::startAction(CursorType action, Event &event) { - switch (action) { - case CURSOR_WALK: - // Nothing - return false; - case CURSOR_LOOK: - if (g_vm->getGameID() == GType_Ringworld) { - if (_lookLineNum == -1) - doAction(action); - else - SceneItem::display(_resNum, _lookLineNum, SET_Y, 20, SET_WIDTH, 200, SET_EXT_BGCOLOR, 7, LIST_END); - } else - SceneItem::display2(_resNum, _lookLineNum); - return true; - case CURSOR_USE: - if (g_vm->getGameID() == GType_Ringworld) { - if (_useLineNum == -1) - doAction(action); - else - SceneItem::display(_resNum, _useLineNum, SET_Y, 20, SET_WIDTH, 200, SET_EXT_BGCOLOR, 7, LIST_END); - } else - SceneItem::display2(_resNum, _useLineNum); - return true; - case CURSOR_TALK: - if (g_vm->getGameID() == GType_Ringworld) { - if (_talkLineNum == -1) - doAction(action); - else - SceneItem::display2(_resNum, _talkLineNum); - } else - SceneItem::display(_resNum, _lookLineNum, SET_Y, 20, SET_WIDTH, 200, SET_EXT_BGCOLOR, 7, LIST_END); - return true; - default: - return SceneHotspot::startAction(action, event); - } -} - -void NamedHotspot::setDetails(int ys, int xs, int ye, int xe, const int resnum, const int lookLineNum, const int useLineNum) { - setBounds(ys, xe, ye, xs); - _resNum = resnum; - _lookLineNum = lookLineNum; - _useLineNum = useLineNum; - _talkLineNum = -1; - g_globals->_sceneItems.addItems(this, NULL); -} - -void NamedHotspot::setDetails(const Rect &bounds, int resNum, int lookLineNum, int talkLineNum, int useLineNum, int mode, SceneItem *item) { - setBounds(bounds); - _resNum = resNum; - _lookLineNum = lookLineNum; - _talkLineNum = talkLineNum; - _useLineNum = useLineNum; - - switch (mode) { - case 2: - g_globals->_sceneItems.push_front(this); - break; - case 4: - g_globals->_sceneItems.addBefore(item, this); - break; - case 5: - g_globals->_sceneItems.addAfter(item, this); - break; - default: - g_globals->_sceneItems.push_back(this); - break; - } -} - -void NamedHotspot::setDetails(int sceneRegionId, int resNum, int lookLineNum, int talkLineNum, int useLineNum, int mode) { - _sceneRegionId = sceneRegionId; - _resNum = resNum; - _lookLineNum = lookLineNum; - _talkLineNum = talkLineNum; - _useLineNum = useLineNum; - - // Handle adding hotspot to scene items list as necessary - switch (mode) { - case 2: - GLOBALS._sceneItems.push_front(this); - break; - case 3: - break; - default: - GLOBALS._sceneItems.push_back(this); - break; - } -} - -void NamedHotspot::synchronize(Serializer &s) { - SceneHotspot::synchronize(s); - s.syncAsSint16LE(_resNum); - s.syncAsSint16LE(_lookLineNum); - s.syncAsSint16LE(_useLineNum); - - if (g_vm->getGameID() == GType_BlueForce) - s.syncAsSint16LE(_talkLineNum); -} - -/*--------------------------------------------------------------------------*/ - void SceneObjectWrapper::setSceneObject(SceneObject *so) { _sceneObject = so; so->_strip = 1; diff --git a/engines/tsage/core.h b/engines/tsage/core.h index 5d26b14265..95eeba7526 100644 --- a/engines/tsage/core.h +++ b/engines/tsage/core.h @@ -445,32 +445,6 @@ public: virtual void doAction(int action); }; -class NamedHotspot : public SceneHotspot { -public: - int _resNum, _lookLineNum, _useLineNum, _talkLineNum; - NamedHotspot(); - - - virtual bool startAction(CursorType action, Event &event); - virtual Common::String getClassName() { return "NamedHotspot"; } - virtual void synchronize(Serializer &s); - virtual void setDetails(int ys, int xs, int ye, int xe, const int resnum, const int lookLineNum, const int useLineNum); - virtual void setDetails(const Rect &bounds, int resNum, int lookLineNum, int talkLineNum, int useLineNum, int mode, SceneItem *item); - virtual void setDetails(int sceneRegionId, int resNum, int lookLineNum, int talkLineNum, int useLineNum, int mode); -}; - -class NamedHotspotExt : public NamedHotspot { -public: - int _flag; - NamedHotspotExt() { _flag = 0; } - - virtual Common::String getClassName() { return "NamedHotspot"; } - virtual void synchronize(Serializer &s) { - NamedHotspot::synchronize(s); - s.syncAsSint16LE(_flag); - } -}; - enum AnimateMode {ANIM_MODE_NONE = 0, ANIM_MODE_1 = 1, ANIM_MODE_2 = 2, ANIM_MODE_3 = 3, ANIM_MODE_4 = 4, ANIM_MODE_5 = 5, ANIM_MODE_6 = 6, ANIM_MODE_7 = 7, ANIM_MODE_8 = 8, // Introduced in Blue Force diff --git a/engines/tsage/ringworld/ringworld_logic.cpp b/engines/tsage/ringworld/ringworld_logic.cpp index 3fb284f5da..38ce8954d2 100644 --- a/engines/tsage/ringworld/ringworld_logic.cpp +++ b/engines/tsage/ringworld/ringworld_logic.cpp @@ -572,6 +572,105 @@ void RingworldGame::rightClick() { delete dlg; } +/*--------------------------------------------------------------------------*/ + +NamedHotspot::NamedHotspot() : SceneHotspot() { + _resNum = 0; + _lookLineNum = _useLineNum = _talkLineNum = -1; +} + +void NamedHotspot::doAction(int action) { + switch (action) { + case CURSOR_WALK: + // Nothing + return; + case CURSOR_LOOK: + if (_lookLineNum == -1) + break; + + SceneItem::display(_resNum, _lookLineNum, SET_Y, 20, SET_WIDTH, 200, SET_EXT_BGCOLOR, 7, LIST_END); + break; + case CURSOR_USE: + if (_useLineNum == -1) + break; + + SceneItem::display(_resNum, _useLineNum, SET_Y, 20, SET_WIDTH, 200, SET_EXT_BGCOLOR, 7, LIST_END); + break; + case CURSOR_TALK: + if (_talkLineNum == -1) + break; + + SceneItem::display(_resNum, _lookLineNum, SET_Y, 20, SET_WIDTH, 200, SET_EXT_BGCOLOR, 7, LIST_END); + break; + default: + SceneHotspot::doAction(action); + break; + } +} + +void NamedHotspot::setDetails(int ys, int xs, int ye, int xe, const int resnum, const int lookLineNum, const int useLineNum) { + setBounds(ys, xe, ye, xs); + _resNum = resnum; + _lookLineNum = lookLineNum; + _useLineNum = useLineNum; + _talkLineNum = -1; + g_globals->_sceneItems.addItems(this, NULL); +} + +void NamedHotspot::setDetails(const Rect &bounds, int resNum, int lookLineNum, int talkLineNum, int useLineNum, int mode, SceneItem *item) { + setBounds(bounds); + _resNum = resNum; + _lookLineNum = lookLineNum; + _talkLineNum = talkLineNum; + _useLineNum = useLineNum; + + switch (mode) { + case 2: + g_globals->_sceneItems.push_front(this); + break; + case 4: + g_globals->_sceneItems.addBefore(item, this); + break; + case 5: + g_globals->_sceneItems.addAfter(item, this); + break; + default: + g_globals->_sceneItems.push_back(this); + break; + } +} + +void NamedHotspot::setDetails(int sceneRegionId, int resNum, int lookLineNum, int talkLineNum, int useLineNum, int mode) { + _sceneRegionId = sceneRegionId; + _resNum = resNum; + _lookLineNum = lookLineNum; + _talkLineNum = talkLineNum; + _useLineNum = useLineNum; + + // Handle adding hotspot to scene items list as necessary + switch (mode) { + case 2: + GLOBALS._sceneItems.push_front(this); + break; + case 3: + break; + default: + GLOBALS._sceneItems.push_back(this); + break; + } +} + +void NamedHotspot::synchronize(Serializer &s) { + SceneHotspot::synchronize(s); + s.syncAsSint16LE(_resNum); + s.syncAsSint16LE(_lookLineNum); + s.syncAsSint16LE(_useLineNum); + + if (g_vm->getGameID() == GType_BlueForce) + s.syncAsSint16LE(_talkLineNum); +} + + } // End of namespace Ringworld } // End of namespace TsAGE diff --git a/engines/tsage/ringworld/ringworld_logic.h b/engines/tsage/ringworld/ringworld_logic.h index 84816347af..6adc8c41da 100644 --- a/engines/tsage/ringworld/ringworld_logic.h +++ b/engines/tsage/ringworld/ringworld_logic.h @@ -157,6 +157,31 @@ public: virtual void rightClick(); }; +class NamedHotspot : public SceneHotspot { +public: + int _resNum, _lookLineNum, _useLineNum, _talkLineNum; + NamedHotspot(); + + virtual void doAction(int action); + virtual Common::String getClassName() { return "NamedHotspot"; } + virtual void synchronize(Serializer &s); + virtual void setDetails(int ys, int xs, int ye, int xe, const int resnum, const int lookLineNum, const int useLineNum); + virtual void setDetails(const Rect &bounds, int resNum, int lookLineNum, int talkLineNum, int useLineNum, int mode, SceneItem *item); + virtual void setDetails(int sceneRegionId, int resNum, int lookLineNum, int talkLineNum, int useLineNum, int mode); +}; + +class NamedHotspotExt : public NamedHotspot { +public: + int _flag; + NamedHotspotExt() { _flag = 0; } + + virtual Common::String getClassName() { return "NamedHotspot"; } + virtual void synchronize(Serializer &s) { + NamedHotspot::synchronize(s); + s.syncAsSint16LE(_flag); + } +}; + } // End of namespace Ringworld } // End of namespace TsAGE |