1 /* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 *
21 */
22
23 #include "titanic/true_talk/tt_response.h"
24
25 namespace Titanic {
26
TTresponse(const TTstring & src)27 TTresponse::TTresponse(const TTstring &src) : _field0(0), _text(src),
28 _dialogueId(0), _nextP(nullptr), _linkP(nullptr) {
29 }
30
TTresponse(int dialogueId,int val2)31 TTresponse::TTresponse(int dialogueId, int val2) : _field0(val2), _text(" "),
32 _dialogueId(dialogueId), _nextP(nullptr), _linkP(nullptr) {
33 }
34
TTresponse(const TTresponse * src)35 TTresponse::TTresponse(const TTresponse *src) : _field0(src->_field0),
36 _text(src->_text), _dialogueId(src->_dialogueId), _nextP(src->_nextP),
37 _linkP(src->_linkP) {
38 }
39
~TTresponse()40 TTresponse::~TTresponse() {
41 // Iterate through destroying any successive linked response items
42 TTresponse *nextP;
43 for (TTresponse *currP = _nextP; currP; currP = nextP) {
44 // Get the following response and detach it from the current one,
45 // so that when the current is destroyed, it will only destroy itself
46 nextP = currP->_nextP;
47 currP->_nextP = nullptr;
48 delete currP;
49 }
50 }
51
appendResponse(int id)52 TTresponse *TTresponse::appendResponse(int id) {
53 TTresponse *resp = new TTresponse(id, 3);
54 _nextP = resp;
55 return resp;
56 }
57
copyChain() const58 TTresponse *TTresponse::copyChain() const {
59 TTresponse *returnResponseP = new TTresponse(this);
60
61 for (TTresponse *srcP = _nextP, *destP = returnResponseP;
62 srcP; srcP = srcP->_nextP, destP = destP->_nextP) {
63 destP->_nextP = new TTresponse(*srcP);
64 }
65
66 return returnResponseP;
67 }
68
addLink(TTresponse * item)69 void TTresponse::addLink(TTresponse *item) {
70 TTresponse *currP = this;
71 while (currP->_linkP)
72 currP = currP->_linkP;
73
74 currP->_linkP = item;
75 }
76
77 } // End of namespace Titanic
78