mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-07 18:31:37 +00:00
TITANIC: Added new TTstringNode and TTsynonymNode classes
This commit is contained in:
parent
a223309934
commit
3a464e8770
@ -466,6 +466,7 @@ MODULE_OBJS := \
|
||||
true_talk/tt_npc_script.o \
|
||||
true_talk/tt_scripts.o \
|
||||
true_talk/tt_string.o \
|
||||
true_talk/tt_string_node.o \
|
||||
true_talk/tt_talker.o \
|
||||
true_talk/tt_title_script.o \
|
||||
true_talk/tt_word.o
|
||||
|
@ -42,6 +42,8 @@ public:
|
||||
CFileReader();
|
||||
|
||||
void reset(CScriptHandler *owner, int val1, int val2);
|
||||
|
||||
bool is18Equals(int val) const { return _field18 == val; }
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
@ -66,6 +66,10 @@ void TTString::operator=(const TTString &str) {
|
||||
}
|
||||
|
||||
void TTString::operator=(const CString &str) {
|
||||
operator=(str.c_str());
|
||||
}
|
||||
|
||||
void TTString::operator=(const char *str) {
|
||||
// Delete old string reference, if any
|
||||
if (_data && --_data->_referenceCount == 0)
|
||||
delete _data;
|
||||
|
@ -51,6 +51,7 @@ public:
|
||||
|
||||
void operator=(const TTString &str);
|
||||
void operator=(const CString &str);
|
||||
void operator=(const char *str);
|
||||
|
||||
/**
|
||||
* Returns true if the string is valid
|
||||
|
74
engines/titanic/true_talk/tt_string_node.cpp
Normal file
74
engines/titanic/true_talk/tt_string_node.cpp
Normal file
@ -0,0 +1,74 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/textconsole.h"
|
||||
#include "titanic/true_talk/tt_string_node.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
TTstringNode::TTstringNode() : _pPrior(nullptr), _pNext(nullptr),
|
||||
_field14(0), _mode(0), _field1C(0) {
|
||||
}
|
||||
|
||||
void TTstringNode::initialize(int mode) {
|
||||
_mode = mode;
|
||||
_field14 = 0;
|
||||
|
||||
if (_string.isValid()) {
|
||||
_field1C = 0;
|
||||
} else {
|
||||
_field1C = 11;
|
||||
warning("TTstringNode::initialize has bad subobj");
|
||||
}
|
||||
}
|
||||
|
||||
void TTstringNode::addNode(TTstringNode *newNode) {
|
||||
TTstringNode *tail = getTail();
|
||||
tail->_pNext = newNode;
|
||||
newNode->_pPrior = this;
|
||||
}
|
||||
|
||||
TTstringNode *TTstringNode::getTail() const {
|
||||
if (_pNext == nullptr)
|
||||
return nullptr;
|
||||
|
||||
TTstringNode *node = _pNext;
|
||||
while (node->_pNext)
|
||||
node = node->_pNext;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
TTsynonymNode::TTsynonymNode() : TTstringNode() {
|
||||
}
|
||||
|
||||
TTsynonymNode::TTsynonymNode(int mode, const char *str, int val2) :
|
||||
TTstringNode() {
|
||||
_string = str;
|
||||
initialize(mode);
|
||||
_field14 = val2;
|
||||
}
|
||||
|
||||
|
||||
} // End of namespace Titanic
|
65
engines/titanic/true_talk/tt_string_node.h
Normal file
65
engines/titanic/true_talk/tt_string_node.h
Normal file
@ -0,0 +1,65 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_TT_STRING_NODE_H
|
||||
#define TITANIC_TT_STRING_NODE_H
|
||||
|
||||
#include "titanic/true_talk/tt_string.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class TTstringNode {
|
||||
private:
|
||||
/**
|
||||
* Returns the final node at the end of the linked list of nodes
|
||||
*/
|
||||
TTstringNode *getTail() const;
|
||||
protected:
|
||||
/**
|
||||
* Initializes state for the node
|
||||
*/
|
||||
void initialize(int mode);
|
||||
public:
|
||||
TTstringNode *_pPrior;
|
||||
TTstringNode *_pNext;
|
||||
TTString _string;
|
||||
int _field14;
|
||||
int _mode;
|
||||
int _field1C;
|
||||
public:
|
||||
TTstringNode();
|
||||
|
||||
/**
|
||||
* Links the passed node to this node as a linked list
|
||||
*/
|
||||
void addNode(TTstringNode *newNode);
|
||||
};
|
||||
|
||||
class TTsynonymNode : public TTstringNode {
|
||||
public:
|
||||
TTsynonymNode();
|
||||
TTsynonymNode(int mode, const char *str, int val2);
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_TT_STRING_NODE_H */
|
@ -21,16 +21,38 @@
|
||||
*/
|
||||
|
||||
#include "titanic/true_talk/tt_word.h"
|
||||
#include "titanic/true_talk/tt_string_node.h"
|
||||
#include "titanic/titanic.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
TTword::TTword(TTString &str, int mode, int val2) : _string(str),
|
||||
_wordMode(mode), _field1C(val2), _fieldC(0), _field10(0),
|
||||
_wordMode(mode), _field1C(val2), _fieldC(0), _synP(nullptr),
|
||||
_field20(0), _field24(0), _field28(0) {
|
||||
_status = str.getStatus() == SS_VALID ? SS_VALID : SS_5;
|
||||
}
|
||||
|
||||
int TTword::readSyn(SimpleFile *file) {
|
||||
CString str;
|
||||
int mode, val1;
|
||||
|
||||
if (!file->scanf("%s %d %d", &str, &mode, &val1))
|
||||
return 8;
|
||||
if (!testFileHandle(file))
|
||||
return 5;
|
||||
|
||||
// Create new synanym node
|
||||
TTsynonymNode *synNode = new TTsynonymNode(mode, str.c_str(), val1);
|
||||
|
||||
if (_synP) {
|
||||
// A synonym already exists, so add new one as a tail
|
||||
// at the end of the linked list of synonyms
|
||||
_synP->addNode(synNode);
|
||||
} else {
|
||||
// Very first synonym, so set it
|
||||
_synP = synNode;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -62,6 +84,14 @@ uint TTword::readNumber(const char *str) {
|
||||
return numValue;
|
||||
}
|
||||
|
||||
bool TTword::testFileHandle(SimpleFile *file) const {
|
||||
if (g_vm->_fileReader.is18Equals(3))
|
||||
return true;
|
||||
|
||||
// TODO: Figure out why original compares passed file handle against specific values
|
||||
return true;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
TTword1::TTword1(TTString &str, int val1, int val2, int val3) :
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include "titanic/support/simple_file.h"
|
||||
#include "titanic/true_talk/tt_string.h"
|
||||
#include "titanic/true_talk/tt_string_node.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
@ -32,7 +33,7 @@ class TTword {
|
||||
protected:
|
||||
TTString _string;
|
||||
int _fieldC;
|
||||
int _field10;
|
||||
TTsynonymNode *_synP;
|
||||
TTStringStatus _status;
|
||||
int _wordMode;
|
||||
int _field1C;
|
||||
@ -44,9 +45,14 @@ protected:
|
||||
* Read in a number
|
||||
*/
|
||||
uint readNumber(const char *str);
|
||||
|
||||
bool testFileHandle(SimpleFile *file) const;
|
||||
public:
|
||||
TTword(TTString &str, int mode, int val2);
|
||||
|
||||
/**
|
||||
* Read in a synonym for the given word
|
||||
*/
|
||||
int readSyn(SimpleFile *file);
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user