This repository was archived by the owner on Feb 27, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 511
/
Copy pathCELL.H
253 lines (222 loc) · 9.12 KB
/
CELL.H
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
/*
** Command & Conquer(tm)
** Copyright 2025 Electronic Arts Inc.
**
** 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 3 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, see <http://www.gnu.org/licenses/>.
*/
/* $Header: F:\projects\c&c\vcs\code\cell.h_v 2.20 16 Oct 1995 16:45:36 JOE_BOSTIC $ */
/***********************************************************************************************
*** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
***********************************************************************************************
* *
* Project Name : Command & Conquer *
* *
* File Name : CELL.H *
* *
* Programmer : Joe L. Bostic *
* *
* Start Date : April 29, 1994 *
* *
* Last Update : April 29, 1994 [JLB] *
* *
*---------------------------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef CELL_H
#define CELL_H
#include "building.h"
#include "unit.h"
#include "template.h"
/****************************************************************************
** Each cell on the map is controlled by the following structure.
*/
class CellClass
{
public:
/*
** Does this cell need to be updated on the radar map? If something changes in the cell
** that might change the radar map imagery, then this flag will be set. It gets cleared
** when the cell graphic is updated to the radar map.
*/
unsigned IsPlot:1;
/*
** Does this cell contain the special placement cursor graphic? This graphic is
** present when selecting a site for building placement.
*/
unsigned IsCursorHere:1;
/*
** Is this cell mapped by the player? A mapped cell is visible. An unmapped cell
** is covered in a dark shroud. In addition to visibility, mapped cells are the only
** legal place for transports to land.
*/
unsigned IsMapped:1;
/*
** If any part of this cell is visible (even just peeking out from under the shadow),
** this this flag will be true. Mapped cells always have this flag set, but unmapped
** cells might not -- it depends on where the shadow edge is located.
*/
unsigned IsVisible:1;
/*
** Every cell can be assigned a trigger. The same trigger can be assigned to
** multiple cells. This bitflag indicates whether this cell has a trigger.
** The trigger pointers for all cells must be stored elsewhere.
*/
unsigned IsTrigger:1;
/*
** Every cell can be assigned a waypoint. A waypoint can only be assigned
** to one cell, and vice-versa. This bit simply indicates whether this
** cell is assigned a waypoint or not.
*/
unsigned IsWaypoint:1;
/*
** Is this cell currently under the radar map cursor? If so then it
** needs to be updated whenever the map is updated.
*/
unsigned IsRadarCursor:1;
/*
** If this cell contains a house flag, then this will be true. The actual house
** flag it contains is specified by the Owner field.
*/
unsigned IsFlagged:1;
/*
** This contains the icon number and set to use for the base
** of the terrain. All rendering on an icon occurs AFTER the icon
** specified by this element is rendered. It is the lowest of the low.
*/
TemplateType TType;
unsigned char TIcon;
/*
** The second layer of 'terrain' icons is represented by a simple
** type number and a value byte. This is sufficient for handling
** concrete and walls.
*/
OverlayType Overlay;
unsigned char OverlayData;
/*
** This is used to specify any special 'stain' overlay icon. This
** typically includes infantry bodies or other temporary marks.
*/
SmudgeType Smudge;
unsigned char SmudgeData;
/*
** Smudges and walls need to record ownership values. For walls, this
** allows adjacent building placement logic to work. For smudges, it
** allows building over smudges that are no longer attached to buildings
** in addition to fixing the adjacent placement logic.
*/
HousesType Owner;
/*
** This flag tells you what type of infantry currently occupy the
** cell or are moving into it.
*/
HousesType InfType;
/*
** These point to the object(s) that are located in this cell or overlap
** this cell.
*/
ObjectClass *OccupierPtr;
ObjectClass *Overlapper[3];
/*
** This array of bit flags is used to indicate which sub positions
** within the cell are either occupied or are soon going to be
** occupied. For vehicles, the cells that the vehicle is passing over
** will be flagged with the vehicle bit. For infantry, the the sub
** position the infantry is stopped at or headed toward will be marked.
** The sub positions it passes over will NOT be marked.
*/
union {
struct {
unsigned Center:1;
unsigned NW:1;
unsigned NE:1;
unsigned SW:1;
unsigned SE:1;
unsigned Vehicle:1; // Reserved for vehicle occupation.
unsigned Monolith:1; // Some immovable blockage is in cell.
unsigned Building:1; // A building of some time (usually blocks movement).
} Occupy;
unsigned char Composite;
} Flag;
//----------------------------------------------------------------
CellClass(void);
~CellClass(void) {};
int operator == (CellClass const & cell) const {return &cell == this;};
/*
** Query functions.
*/
ObjectClass * Cell_Occupier(void) const;
static int Spot_Index(COORDINATE coord);
bool Is_Spot_Free(int spot_index) const {return (! (Flag.Composite & (1 << spot_index)) ); }
COORDINATE Closest_Free_Spot(COORDINATE coord, bool any=false) const;
COORDINATE Free_Spot(void) const {return Closest_Free_Spot(Cell_Coord());};
bool Is_Generally_Clear(void) const;
TARGET As_Target(void) const {return ::As_Target(Cell_Number());};
BuildingClass * Cell_Building(void) const;
CellClass const & Adjacent_Cell(FacingType face) const;
CellClass & Adjacent_Cell(FacingType face) {return (CellClass &)((*((CellClass const *)this)).Adjacent_Cell(face));};
COORDINATE Cell_Coord(void) const;
int Cell_Color(bool override=false) const;
CELL Cell_Number(void) const;
LandType Land_Type(void) const {return Land;};
ObjectClass * Cell_Find_Object(RTTIType rtti) const;
ObjectClass * Cell_Object(int x=0, int y=0) const;
TechnoClass * Cell_Techno(int x=0, int y=0) const;
TerrainClass * Cell_Terrain(void) const;
UnitClass * Cell_Unit(void) const;
InfantryClass * Cell_Infantry(void) const;
TriggerClass * Get_Trigger(void) const;
int Clear_Icon(void) const;
bool Goodie_Check(FootClass * object);
ObjectClass * Fetch_Occupier(void) const;
/*
** Object placement and removal flag operations.
*/
void Occupy_Down(ObjectClass * object);
void Occupy_Up(ObjectClass * object);
void Overlap_Down(ObjectClass * object);
void Overlap_Up(ObjectClass * object);
bool Flag_Place(HousesType house);
bool Flag_Remove(void);
/*
** File I/O.
*/
bool Should_Save(void) const;
bool Save(FileClass & file);
bool Load(FileClass & file);
void Code_Pointers(void);
void Decode_Pointers(void);
/*
** Display and rendering controls.
*/
void Draw_It(int x, int y, int draw_flags = 0) const;
void Redraw_Objects(bool forced=false);
void Shimmer(void);
/*
** Maintenance calculation support.
*/
long Tiberium_Adjust(bool pregame=false);
void Wall_Update(void);
void Concrete_Calc(void);
void Recalc_Attributes(void);
int Reduce_Tiberium(int levels);
int Reduce_Wall(int damage);
void Incoming(COORDINATE threat=0, bool forced = false);
void Adjust_Threat(HousesType house, int threat_value);
int operator != (CellClass const &) const {return 0;};
int Validate(void) const;
private:
CellClass (CellClass const &) {};
LandType Land; // The land type of this cell.
};
#endif