1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
/* 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 "titanic/game/parrot/parrot_lobby_link_updater.h"
#include "titanic/titanic.h"
namespace Titanic {
BEGIN_MESSAGE_MAP(CParrotLobbyLinkUpdater, CParrotLobbyObject)
ON_MESSAGE(ActMsg)
END_MESSAGE_MAP()
/*------------------------------------------------------------------------*/
LinkUpdatorEntry::LinkUpdatorEntry() {
Common::fill(&_vals[0], &_vals[8], 0);
}
void LinkUpdatorEntry::load(Common::SeekableReadStream *s) {
_linkStr = readStringFromStream(s);
for (int idx = 0; idx < 8; ++idx)
_vals[idx] = s->readByte();
}
/*------------------------------------------------------------------------*/
void LinkUpdatorEntries::load(Common::SeekableReadStream *s, int count) {
resize(count);
for (int idx = 0; idx < count; ++idx)
(*this)[idx].load(s);
}
/*------------------------------------------------------------------------*/
CParrotLobbyLinkUpdater::CParrotLobbyLinkUpdater() : CParrotLobbyObject(), _fieldBC(1) {
Common::SeekableReadStream *s = g_vm->_filesManager->getResource("DATA/PARROT_LOBBY_LINK_UPDATOR");
_entries[0].load(s, 7);
_entries[1].load(s, 5);
_entries[2].load(s, 6);
_entries[3].load(s, 9);
_entries[4].load(s, 1);
delete s;
}
void CParrotLobbyLinkUpdater::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
CParrotLobbyObject::save(file, indent);
}
void CParrotLobbyLinkUpdater::load(SimpleFile *file) {
file->readNumber();
CParrotLobbyObject::load(file);
}
bool CParrotLobbyLinkUpdater::ActMsg(CActMsg *msg) {
if (msg->_action != "Refresh")
return false;
CNodeItem *node = findNode();
LinkUpdatorEntries *entriesP;
if (isEquals("ParrotLobbyUpdater_TOW")) {
entriesP = &_entries[4];
} else {
if (node->_nodeNumber > 3)
return true;
entriesP = &_entries[node->_nodeNumber];
}
int count = entriesP->size();
for (CTreeItem *item = node->getFirstChild(); item; item = item->scan(node)) {
CLinkItem *link = dynamic_cast<CLinkItem *>(item);
if (!link || count == 0)
continue;
CString linkName = link->getName();
char c = linkName.lastChar();
if (c >= 'a' && c <= 'd')
linkName.deleteLastChar();
for (uint idx = 0; idx < entriesP->size(); ++idx) {
const LinkUpdatorEntry &entry = (*entriesP)[idx];
if (entry._linkStr == linkName) {
int val = entry._vals[CParrotLobbyObject::_flags];
if (val)
linkName += (char)(0x60 + val);
link->_name = linkName;
break;
}
}
}
return true;
}
} // End of namespace Titanic
|