From 441d168d3782683acd4ec05535d2b73afb1c86f5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 12 Jun 2016 09:03:46 -0400 Subject: TITANIC: Replace NPC proc23 methods with a single getMapping --- engines/titanic/true_talk/barbot_script.cpp | 5 ----- engines/titanic/true_talk/barbot_script.h | 1 - engines/titanic/true_talk/bellbot_script.cpp | 5 ----- engines/titanic/true_talk/bellbot_script.h | 1 - engines/titanic/true_talk/deskbot_script.cpp | 5 ----- engines/titanic/true_talk/deskbot_script.h | 1 - engines/titanic/true_talk/doorbot_script.cpp | 5 ----- engines/titanic/true_talk/doorbot_script.h | 1 - engines/titanic/true_talk/liftbot_script.cpp | 5 ----- engines/titanic/true_talk/liftbot_script.h | 1 - engines/titanic/true_talk/maitred_script.cpp | 5 ----- engines/titanic/true_talk/maitred_script.h | 1 - engines/titanic/true_talk/parrot_script.cpp | 7 ------- engines/titanic/true_talk/parrot_script.h | 1 - engines/titanic/true_talk/succubus_script.cpp | 5 ----- engines/titanic/true_talk/succubus_script.h | 1 - engines/titanic/true_talk/tt_npc_script.cpp | 18 ++++++++++++------ engines/titanic/true_talk/tt_npc_script.h | 2 +- 18 files changed, 13 insertions(+), 57 deletions(-) (limited to 'engines') diff --git a/engines/titanic/true_talk/barbot_script.cpp b/engines/titanic/true_talk/barbot_script.cpp index e66c17b1bd..cfde44df9f 100644 --- a/engines/titanic/true_talk/barbot_script.cpp +++ b/engines/titanic/true_talk/barbot_script.cpp @@ -229,11 +229,6 @@ int BarbotScript::proc23() const { return 0; } -const int *BarbotScript::getTablePtr(int id) { - warning("TODO"); - return nullptr; -} - int BarbotScript::proc25(int val1, int val2, TTroomScript *roomScript, TTsentence *sentence) const { warning("TODO"); return 0; diff --git a/engines/titanic/true_talk/barbot_script.h b/engines/titanic/true_talk/barbot_script.h index 526cf71a60..1d73094660 100644 --- a/engines/titanic/true_talk/barbot_script.h +++ b/engines/titanic/true_talk/barbot_script.h @@ -70,7 +70,6 @@ public: virtual int proc21(int v1, int v2, int v3); virtual int proc22(int id) const; virtual int proc23() const; - virtual const int *getTablePtr(int id); virtual int proc25(int val1, int val2, TTroomScript *roomScript, TTsentence *sentence) const; virtual void proc26(int v1, const TTsentenceEntry *entry, TTroomScript *roomScript, TTsentence *sentence); virtual void proc32(); diff --git a/engines/titanic/true_talk/bellbot_script.cpp b/engines/titanic/true_talk/bellbot_script.cpp index 3e75fce15b..a13f9d6106 100644 --- a/engines/titanic/true_talk/bellbot_script.cpp +++ b/engines/titanic/true_talk/bellbot_script.cpp @@ -89,11 +89,6 @@ int BellbotScript::proc23() const { return 0; } -const int *BellbotScript::getTablePtr(int id) { - warning("TODO"); - return nullptr; -} - int BellbotScript::proc25(int val1, int val2, TTroomScript *roomScript, TTsentence *sentence) const { warning("TODO"); return 0; diff --git a/engines/titanic/true_talk/bellbot_script.h b/engines/titanic/true_talk/bellbot_script.h index 0dcdbfe29f..b21d689b71 100644 --- a/engines/titanic/true_talk/bellbot_script.h +++ b/engines/titanic/true_talk/bellbot_script.h @@ -61,7 +61,6 @@ public: virtual int proc21(int v1, int v2, int v3); virtual int proc22(int id) const; virtual int proc23() const; - virtual const int *getTablePtr(int id); virtual int proc25(int val1, int val2, TTroomScript *roomScript, TTsentence *sentence) const; virtual void proc26(int v1, const TTsentenceEntry *entry, TTroomScript *roomScript, TTsentence *sentence); virtual int proc36(int val) const; diff --git a/engines/titanic/true_talk/deskbot_script.cpp b/engines/titanic/true_talk/deskbot_script.cpp index 54e22a9602..ca000a4c28 100644 --- a/engines/titanic/true_talk/deskbot_script.cpp +++ b/engines/titanic/true_talk/deskbot_script.cpp @@ -90,11 +90,6 @@ int DeskbotScript::proc23() const { return 0; } -const int *DeskbotScript::getTablePtr(int id) { - warning("TODO"); - return nullptr; -} - int DeskbotScript::proc25(int val1, int val2, TTroomScript *roomScript, TTsentence *sentence) const { warning("TODO"); return 0; diff --git a/engines/titanic/true_talk/deskbot_script.h b/engines/titanic/true_talk/deskbot_script.h index d0d1f8abab..f685b7a9ca 100644 --- a/engines/titanic/true_talk/deskbot_script.h +++ b/engines/titanic/true_talk/deskbot_script.h @@ -56,7 +56,6 @@ public: virtual int proc21(int v1, int v2, int v3); virtual int proc22(int id) const; virtual int proc23() const; - virtual const int *getTablePtr(int id); virtual int proc25(int val1, int val2, TTroomScript *roomScript, TTsentence *sentence) const; virtual void proc26(int v1, const TTsentenceEntry *entry, TTroomScript *roomScript, TTsentence *sentence); virtual int proc36(int val) const; diff --git a/engines/titanic/true_talk/doorbot_script.cpp b/engines/titanic/true_talk/doorbot_script.cpp index 7689fc2c04..0db75474eb 100644 --- a/engines/titanic/true_talk/doorbot_script.cpp +++ b/engines/titanic/true_talk/doorbot_script.cpp @@ -144,11 +144,6 @@ int DoorbotScript::proc23() const { return 0; } -const int *DoorbotScript::getTablePtr(int id) { - warning("TODO"); - return nullptr; -} - int DoorbotScript::proc25(int val1, int val2, TTroomScript *roomScript, TTsentence *sentence) const { warning("TODO"); return 0; diff --git a/engines/titanic/true_talk/doorbot_script.h b/engines/titanic/true_talk/doorbot_script.h index 97d42e39b3..f50fa28f12 100644 --- a/engines/titanic/true_talk/doorbot_script.h +++ b/engines/titanic/true_talk/doorbot_script.h @@ -67,7 +67,6 @@ public: virtual int proc21(int v1, int v2, int v3); virtual int proc22(int id) const; virtual int proc23() const; - virtual const int *getTablePtr(int id); virtual int proc25(int val1, int val2, TTroomScript *roomScript, TTsentence *sentence) const; virtual void proc26(int v1, const TTsentenceEntry *entry, TTroomScript *roomScript, TTsentence *sentence); virtual void proc32(); diff --git a/engines/titanic/true_talk/liftbot_script.cpp b/engines/titanic/true_talk/liftbot_script.cpp index 21bdbdde92..e911fe181e 100644 --- a/engines/titanic/true_talk/liftbot_script.cpp +++ b/engines/titanic/true_talk/liftbot_script.cpp @@ -121,11 +121,6 @@ int LiftbotScript::proc23() const { return 0; } -const int *LiftbotScript::getTablePtr(int id) { - warning("TODO"); - return nullptr; -} - int LiftbotScript::proc25(int val1, int val2, TTroomScript *roomScript, TTsentence *sentence) const { warning("TODO"); return 0; diff --git a/engines/titanic/true_talk/liftbot_script.h b/engines/titanic/true_talk/liftbot_script.h index 67565f44a3..b2662b1206 100644 --- a/engines/titanic/true_talk/liftbot_script.h +++ b/engines/titanic/true_talk/liftbot_script.h @@ -64,7 +64,6 @@ public: virtual int proc21(int v1, int v2, int v3); virtual int proc22(int id) const; virtual int proc23() const; - virtual const int *getTablePtr(int id); virtual int proc25(int val1, int val2, TTroomScript *roomScript, TTsentence *sentence) const; virtual void proc26(int v1, const TTsentenceEntry *entry, TTroomScript *roomScript, TTsentence *sentence); virtual void proc32(); diff --git a/engines/titanic/true_talk/maitred_script.cpp b/engines/titanic/true_talk/maitred_script.cpp index 92966adeaf..998048f272 100644 --- a/engines/titanic/true_talk/maitred_script.cpp +++ b/engines/titanic/true_talk/maitred_script.cpp @@ -94,11 +94,6 @@ int MaitreDScript::proc23() const { return 0; } -const int *MaitreDScript::getTablePtr(int id) { - warning("TODO"); - return nullptr; -} - int MaitreDScript::proc25(int val1, int val2, TTroomScript *roomScript, TTsentence *sentence) const { warning("TODO"); return 0; diff --git a/engines/titanic/true_talk/maitred_script.h b/engines/titanic/true_talk/maitred_script.h index 27c72f1585..c210f71a7d 100644 --- a/engines/titanic/true_talk/maitred_script.h +++ b/engines/titanic/true_talk/maitred_script.h @@ -58,7 +58,6 @@ public: virtual int proc21(int v1, int v2, int v3); virtual int proc22(int id) const; virtual int proc23() const; - virtual const int *getTablePtr(int id); virtual int proc25(int val1, int val2, TTroomScript *roomScript, TTsentence *sentence) const; virtual void proc26(int v1, const TTsentenceEntry *entry, TTroomScript *roomScript, TTsentence *sentence); }; diff --git a/engines/titanic/true_talk/parrot_script.cpp b/engines/titanic/true_talk/parrot_script.cpp index 8e88e58810..358c943cc4 100644 --- a/engines/titanic/true_talk/parrot_script.cpp +++ b/engines/titanic/true_talk/parrot_script.cpp @@ -104,17 +104,10 @@ ScriptChangedResult ParrotScript::scriptChanged(TTscriptBase *roomScript, uint i } int ParrotScript::proc23() const { - warning("TODO"); return 0; } -const int *ParrotScript::getTablePtr(int id) { - warning("TODO"); - return nullptr; -} - int ParrotScript::proc25(int val1, int val2, TTroomScript *roomScript, TTsentence *sentence) const { - warning("TODO"); return 0; } diff --git a/engines/titanic/true_talk/parrot_script.h b/engines/titanic/true_talk/parrot_script.h index 02ec4e967b..921dc22df4 100644 --- a/engines/titanic/true_talk/parrot_script.h +++ b/engines/titanic/true_talk/parrot_script.h @@ -53,7 +53,6 @@ public: virtual ScriptChangedResult scriptChanged(TTscriptBase *roomScript, uint id); virtual int proc23() const; - virtual const int *getTablePtr(int id); virtual int proc25(int val1, int val2, TTroomScript *roomScript, TTsentence *sentence) const; virtual void proc26(int v1, const TTsentenceEntry *entry, TTroomScript *roomScript, TTsentence *sentence); }; diff --git a/engines/titanic/true_talk/succubus_script.cpp b/engines/titanic/true_talk/succubus_script.cpp index cb1b0356ab..cb1c12f580 100644 --- a/engines/titanic/true_talk/succubus_script.cpp +++ b/engines/titanic/true_talk/succubus_script.cpp @@ -94,11 +94,6 @@ int SuccUBusScript::proc23() const { return 0; } -const int *SuccUBusScript::getTablePtr(int id) { - warning("TODO"); - return nullptr; -} - int SuccUBusScript::proc25(int val1, int val2, TTroomScript *roomScript, TTsentence *sentence) const { warning("TODO"); return 0; diff --git a/engines/titanic/true_talk/succubus_script.h b/engines/titanic/true_talk/succubus_script.h index 9787b2cbcf..c5ba51ee1c 100644 --- a/engines/titanic/true_talk/succubus_script.h +++ b/engines/titanic/true_talk/succubus_script.h @@ -56,7 +56,6 @@ public: virtual int proc21(int v1, int v2, int v3); virtual int proc23() const; - virtual const int *getTablePtr(int id); virtual int proc25(int val1, int val2, TTroomScript *roomScript, TTsentence *sentence) const; virtual void proc26(int v1, const TTsentenceEntry *entry, TTroomScript *roomScript, TTsentence *sentence); }; diff --git a/engines/titanic/true_talk/tt_npc_script.cpp b/engines/titanic/true_talk/tt_npc_script.cpp index 0de460cce3..1ee5785907 100644 --- a/engines/titanic/true_talk/tt_npc_script.cpp +++ b/engines/titanic/true_talk/tt_npc_script.cpp @@ -343,6 +343,12 @@ int TTnpcScript::proc23() const { return 0; } +const TTscriptMapping *TTnpcScript::getMapping(int index) { + if (index >= 0 && index < (int)_mappings.size()) + return &_mappings[index]; + return nullptr; +} + int TTnpcScript::proc25(int val1, int val2, TTroomScript *roomScript, TTsentence *sentence) const { return 0; } @@ -594,21 +600,21 @@ uint TTnpcScript::getDialogueId(uint tagId) { tagId = getRangeValue(tagId); oldTagId = proc23(); - int v21 = proc21(origId, tagId, oldTagId); - if (!v21) + uint newId = proc21(origId, tagId, oldTagId); + if (!newId) return 0; int idx = 0; - const int *tableP; + const TTscriptMapping *tableP; for (;;) { - tableP = getTablePtr(idx++); + tableP = getMapping(idx++); if (!tableP) return 0; - if (*tableP == v21) + if (tableP->_id == newId) break; } - uint newVal = tableP[oldTagId + 1]; + uint newVal = tableP->_values[oldTagId]; idx = 0; int *arrP = &_array[26]; diff --git a/engines/titanic/true_talk/tt_npc_script.h b/engines/titanic/true_talk/tt_npc_script.h index b143af66da..d7cec8d6d8 100644 --- a/engines/titanic/true_talk/tt_npc_script.h +++ b/engines/titanic/true_talk/tt_npc_script.h @@ -309,7 +309,7 @@ public: virtual int proc21(int v1, int v2, int v3); virtual int proc22(int id) const; virtual int proc23() const; - virtual const int *getTablePtr(int id) = 0; + virtual const TTscriptMapping *getMapping(int index); virtual int proc25(int val1, int val2, TTroomScript *roomScript, TTsentence *sentence) const; virtual void proc26(int v1, const TTsentenceEntry *entry, TTroomScript *roomScript, TTsentence *sentence); virtual void save(SimpleFile *file); -- cgit v1.2.3