ScummVM API documentation
band.h
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 modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (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, see <http://www.gnu.org/licenses/>.
19
*
20
*
21
* Based on the original sources
22
* Faery Tale II -- The Halls of the Dead
23
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
24
*/
25
26
#ifndef SAGA2_BAND_H
27
#define SAGA2_BAND_H
28
29
namespace
Saga2
{
30
31
class
Actor;
32
class
Band;
33
34
/* ===================================================================== *
35
Function prototypes
36
* ===================================================================== */
37
38
// Allocate a new band
39
Band *newBand();
40
Band *newBand(BandID
id
);
41
42
// Delete a previously allocated band
43
void
deleteBand(Band *p);
44
45
// Get a band's ID given its address
46
BandID getBandID(Band *b);
47
// Get a band's address given its ID
48
Band *getBandAddress(BandID
id
);
49
50
// Initialize the band list
51
void
initBands();
52
void
saveBands(
Common::OutSaveFile
*outS);
53
void
loadBands(
Common::InSaveFile
*in, int32 chunkSize);
54
// Cleanup the band list
55
void
cleanupBands();
56
57
/* ===================================================================== *
58
BandList class
59
* ===================================================================== */
60
61
// Manages the memory used for the Band's. There will only be one
62
// global instantiation of this class
63
class
BandList
{
64
public
:
65
enum
{
66
kNumBands = 32
67
};
68
69
Band
*_list[kNumBands];
70
71
// Constructor -- initial construction
72
BandList
();
73
74
// Destructor
75
~
BandList
();
76
77
void
read(
Common::InSaveFile
*in);
78
79
// Return the number of bytes necessary to archive this task list
80
// in a buffer
81
int32 archiveSize();
82
83
void
write(
Common::MemoryWriteStreamDynamic
*out);
84
85
// Place a Band from the inactive list into the active
86
// list.
87
Band
*newBand();
88
Band
*newBand(BandID
id
);
89
90
void
addBand(
Band
*band);
91
92
// Place a Band back into the inactive list.
93
void
deleteBand(
Band
*p);
94
95
// Return the specified Band's ID
96
BandID getBandID(
Band
*b) {
97
for
(
int
i = 0; i < kNumBands; i++)
98
if
(_list[i] == b)
99
return
i;
100
101
error
(
"BandList::getBandID(): Unknown band"
);
102
}
103
104
// Return a pointer to a Band given a BandID
105
Band
*getBandAddress(BandID
id
) {
106
assert(
id
>= 0 &&
id
< kNumBands);
107
return
_list[id];
108
}
109
};
110
111
/* ===================================================================== *
112
Band class
113
* ===================================================================== */
114
115
class
Band
{
116
enum
{
117
kMaxBandMembers = 32
118
};
119
120
Actor
*_leader;
121
122
int16 _memberCount;
123
Actor
*_members[kMaxBandMembers];
124
125
public
:
126
127
Band
();
128
Band
(
Actor
*l);
129
130
Band
(
Common::InSaveFile
*in);
131
132
~
Band
() { deleteBand(
this
); }
133
134
// Return the number of bytes needed to archive this object in a
135
// buffer
136
int32 archiveSize();
137
138
void
write(
Common::MemoryWriteStreamDynamic
*out);
139
140
Actor
*getLeader() {
141
return
_leader;
142
}
143
144
bool
add(
Actor
*newMember) {
145
if
(_memberCount <
ARRAYSIZE
(_members)) {
146
_members[_memberCount++] = newMember;
147
return
true
;
148
}
else
149
return
false
;
150
}
151
152
void
remove
(
Actor
*member) {
153
int
i;
154
155
for
(i = 0; i < _memberCount; i++) {
156
if
(_members[i] == member) {
157
_memberCount--;
158
159
for
(; i < _memberCount; i++)
160
_members[i] = _members[i + 1];
161
162
break
;
163
}
164
}
165
}
166
167
void
remove
(
int
index) {
168
assert(index < _memberCount);
169
170
int
i;
171
172
_memberCount--;
173
174
for
(i = index; i < _memberCount; i++)
175
_members[i] = _members[i + 1];
176
}
177
178
int
size() {
179
return
_memberCount;
180
}
181
Actor
*
const
&operator [](
int
index) {
182
return
_members[index];
183
}
184
};
185
186
}
// end of namespace Saga2
187
188
#endif
ARRAYSIZE
#define ARRAYSIZE(x)
Definition:
util.h:91
Common::OutSaveFile
Definition:
savefile.h:54
Saga2
Definition:
actor.h:32
Common::MemoryWriteStreamDynamic
Definition:
memstream.h:194
Common::SeekableReadStream
Definition:
stream.h:745
Saga2::Actor
Definition:
actor.h:589
Saga2::Band
Definition:
band.h:115
error
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Saga2::BandList
Definition:
band.h:63
engines
saga2
band.h
Generated on Sat Aug 31 2024 09:16:10 for ScummVM API documentation by
1.8.13