CELL.H (12177B)
1 // 2 // Copyright 2020 Electronic Arts Inc. 3 // 4 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free 5 // software: you can redistribute it and/or modify it under the terms of 6 // the GNU General Public License as published by the Free Software Foundation, 7 // either version 3 of the License, or (at your option) any later version. 8 9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 10 // in the hope that it will be useful, but with permitted additional restrictions 11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 12 // distributed with this program. You should have received a copy of the 13 // GNU General Public License along with permitted additional restrictions 14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection 15 16 /* $Header: /CounterStrike/CELL.H 1 3/03/97 10:24a Joe_bostic $ */ 17 /*********************************************************************************************** 18 *** 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 *** 19 *********************************************************************************************** 20 * * 21 * Project Name : Command & Conquer * 22 * * 23 * File Name : CELL.H * 24 * * 25 * Programmer : Joe L. Bostic * 26 * * 27 * Start Date : April 29, 1994 * 28 * * 29 * Last Update : April 29, 1994 [JLB] * 30 * * 31 *---------------------------------------------------------------------------------------------* 32 * Functions: * 33 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 34 35 #ifndef CELL_H 36 #define CELL_H 37 38 #include "building.h" 39 #include "unit.h" 40 #include "template.h" 41 42 43 /**************************************************************************** 44 ** Each cell on the map is controlled by the following structure. 45 */ 46 class CellClass 47 { 48 public: 49 /* 50 ** This is the ID number of this cell. By placing the ID number here, it doesn't have 51 ** be calculated. Calculating this number requires a divide and would occur about 52 ** 5.72031 bijillion times per second. 53 */ 54 short ID; 55 56 /* 57 ** Does this cell need to be updated on the radar map? If something changes in the cell 58 ** that might change the radar map imagery, then this flag will be set. It gets cleared 59 ** when the cell graphic is updated to the radar map. 60 */ 61 unsigned IsPlot:1; 62 63 /* 64 ** Does this cell contain the special placement cursor graphic? This graphic is 65 ** present when selecting a site for building placement. 66 */ 67 unsigned IsCursorHere:1; 68 69 /* 70 ** A mapped cell has some portion of it visible. Maybe it has a shroud piece 71 ** over it and maybe not. 72 */ 73 unsigned IsMapped:1; 74 75 /* 76 ** A visible cell means that it is completely visible with no shroud over 77 ** it at all. 78 */ 79 unsigned IsVisible:1; 80 81 /* 82 ** Every cell can be assigned a waypoint. A waypoint can only be assigned 83 ** to one cell, and vice-versa. This bit simply indicates whether this 84 ** cell is assigned a waypoint or not. 85 */ 86 unsigned IsWaypoint:1; 87 88 /* 89 ** Is this cell currently under the radar map cursor? If so then it 90 ** needs to be updated whenever the map is updated. 91 */ 92 unsigned IsRadarCursor:1; 93 94 /* 95 ** If this cell contains a house flag, then this will be true. The actual house 96 ** flag it contains is specified by the Owner field. 97 */ 98 unsigned IsFlagged:1; 99 100 /* 101 ** This is a working flag used to help keep track of what cells should be 102 ** shrouded. By using this flag it allows a single pass through the map 103 ** cells for determining shadow regrowth logic. 104 */ 105 unsigned IsToShroud:1; 106 107 /* 108 ** This records the movement zone for this map. Movement zones share the 109 ** same number if they are contiguous (terrain consideration only). There 110 ** are basically two kinds of zones. The difference being determined by 111 ** walls that can be crushed by movement. A vehicle that can crush walls 112 ** will only consider the CrushZone. All other terrestrial travellers will 113 ** use the normal Zone. 114 */ 115 unsigned char Zones[MZONE_COUNT]; 116 117 /* 118 ** This field controls whether an area is being jammed by a gap 119 ** generator. 120 */ 121 unsigned short Jammed; 122 123 /* 124 ** This is the trigger ID for any trigger that might be attached to 125 ** this cell. 126 */ 127 CCPtr<TriggerClass> Trigger; 128 129 /* 130 ** This contains the icon number and set to use for the base 131 ** of the terrain. All rendering on an icon occurs AFTER the icon 132 ** specified by this element is rendered. It is the lowest of the low. 133 */ 134 TemplateType TType; 135 unsigned char TIcon; 136 137 /* 138 ** The second layer of 'terrain' icons is represented by a simple 139 ** type number and a value byte. This is sufficient for handling 140 ** concrete and walls. 141 */ 142 OverlayType Overlay; 143 unsigned char OverlayData; 144 145 /* 146 ** This is used to specify any special 'stain' overlay icon. This 147 ** typically includes infantry bodies or other temporary marks. 148 */ 149 SmudgeType Smudge; 150 unsigned char SmudgeData; 151 152 /* 153 ** Smudges and walls need to record ownership values. For walls, this 154 ** allows adjacent building placement logic to work. For smudges, it 155 ** allows building over smudges that are no longer attached to buildings 156 ** in addition to fixing the adjacent placement logic. 157 */ 158 HousesType Owner; 159 160 /* 161 ** This flag tells you what type of infantry currently occupy the 162 ** cell or are moving into it. 163 */ 164 HousesType InfType; 165 166 /* 167 ** These point to the object(s) that are located in this cell or overlap 168 ** this cell. 169 */ 170 private: 171 ObjectClass * OccupierPtr; 172 173 public: 174 #ifdef SORTDRAW 175 ObjectClass * Overlapper[10]; 176 #else 177 ObjectClass * Overlapper[6]; 178 #endif 179 180 181 /* 182 ** Per-player view of whether a cell is mapped. One bit for each house type. ST - 8/2/2019 3:00PM 183 */ 184 unsigned int IsMappedByPlayerMask; 185 186 /* 187 ** Per-player view of whether a cell is visible. One bit for each house type. ST - 8/2/2019 3:00PM 188 */ 189 unsigned int IsVisibleByPlayerMask; 190 191 192 /* 193 ** This array of bit flags is used to indicate which sub positions 194 ** within the cell are either occupied or are soon going to be 195 ** occupied. For vehicles, the cells that the vehicle is passing over 196 ** will be flagged with the vehicle bit. For infantry, the the sub 197 ** position the infantry is stopped at or headed toward will be marked. 198 ** The sub positions it passes over will NOT be marked. 199 */ 200 union { 201 struct { 202 unsigned Center:1; 203 unsigned NW:1; 204 unsigned NE:1; 205 unsigned SW:1; 206 unsigned SE:1; 207 unsigned Vehicle:1; // Reserved for vehicle occupation. 208 unsigned Monolith:1; // Some immovable blockage is in cell. 209 unsigned Building:1; // A building of some time (usually blocks movement). 210 } Occupy; 211 unsigned char Composite; 212 } Flag; 213 214 //---------------------------------------------------------------- 215 CellClass(void); 216 CellClass(NoInitClass const & x) : Trigger(x) {} 217 ~CellClass(void) {OccupierPtr=0;} 218 219 int operator == (CellClass const & cell) const {return &cell == this;} 220 221 /* 222 ** Query functions. 223 */ 224 bool Can_Tiberium_Germinate(void) const; 225 bool Can_Tiberium_Grow(void) const; 226 bool Can_Tiberium_Spread(void) const; 227 bool Is_Bridge_Here(void) const; 228 RTTIType What_Am_I(void) const {return(RTTI_CELL);} 229 BuildingClass * Cell_Building(void) const; 230 CELL Cell_Number(void) const {return(ID);} 231 COORDINATE Cell_Coord(void) const; 232 COORDINATE Closest_Free_Spot(COORDINATE coord, bool any=false) const; 233 COORDINATE Free_Spot(void) const {return Closest_Free_Spot(Cell_Coord());} 234 CellClass * Adjacent_Cell(FacingType face) {return (CellClass *)((*((CellClass const *)this)).Adjacent_Cell(face));} 235 CellClass const * Adjacent_Cell(FacingType face) const; 236 InfantryClass * Cell_Infantry(void) const; 237 LandType Land_Type(void) const {return((OverrideLand != LAND_NONE) ? OverrideLand : Land);} 238 ObjectClass * Cell_Find_Object(RTTIType rtti) const; 239 ObjectClass * Cell_Object(int x=0, int y=0) const; 240 ObjectClass * Cell_Occupier(void) const {return(OccupierPtr);} 241 ObjectClass * Fetch_Occupier(void) const; 242 TARGET As_Target(void) const {return ::As_Target(Cell_Number());} 243 TechnoClass * Cell_Techno(int x=0, int y=0) const; 244 TerrainClass * Cell_Terrain(void) const; 245 UnitClass * Cell_Unit(void) const; 246 VesselClass * Cell_Vessel(void) const; 247 bool Goodie_Check(FootClass * object); 248 bool Is_Clear_To_Build(SpeedType loco = SPEED_TRACK) const; 249 bool Is_Clear_To_Move(SpeedType loco, bool ignoreinfantry, bool ignorevehicles, int zone=-1, MZoneType check=MZONE_NORMAL) const; 250 bool Is_Spot_Free(int spot_index) const {return (! (Flag.Composite & (1 << spot_index)) ); } 251 int Cell_Color(bool override=false) const; 252 int Clear_Icon(void) const; 253 static int Spot_Index(COORDINATE coord); 254 bool Get_Template_Info(char *template_name, int &icon, void *&image_data); 255 256 257 /* 258 ** Object placement and removal flag operations. 259 */ 260 void Occupy_Down(ObjectClass * object); 261 void Occupy_Up(ObjectClass * object); 262 void Overlap_Down(ObjectClass * object); 263 void Overlap_Up(ObjectClass * object); 264 bool Flag_Place(HousesType house); 265 bool Flag_Remove(void); 266 void Flag_Update(void); 267 void Flag_Create(void); 268 void Flag_Destroy(void); 269 270 /* 271 ** File I/O. 272 */ 273 bool Should_Save(void) const; 274 bool Save(Pipe & file) const; 275 bool Load(Straw & file); 276 void Code_Pointers(void); 277 void Decode_Pointers(void); 278 279 /* 280 ** Display and rendering controls. 281 */ 282 void Draw_It(int x, int y, bool objects=false) const; 283 void Redraw_Objects(bool forced=false); 284 void Shimmer(void); 285 286 /* 287 ** Maintenance calculation support. 288 */ 289 bool Grow_Tiberium(void); 290 bool Spread_Tiberium(bool forced=false); 291 long Tiberium_Adjust(bool pregame=false); 292 void Wall_Update(void); 293 void Concrete_Calc(void); 294 void Recalc_Attributes(void); 295 int Reduce_Tiberium(int levels); 296 int Reduce_Wall(int damage); 297 void Incoming(COORDINATE threat=0, bool forced=false, bool nokidding=false); 298 void Adjust_Threat(HousesType house, int threat_value); 299 300 int operator != (CellClass const &) const {return 0;} 301 302 303 /* 304 ** Additional per-player functionality is needed for multiplayer. ST - 8/2/2019 3:01PM 305 */ 306 void Set_Mapped(HousesType house, bool set = true); 307 void Set_Mapped(HouseClass *player, bool set = true); 308 bool Is_Mapped(HousesType house) const; 309 bool Is_Mapped(HouseClass *player) const; 310 void Set_Visible(HousesType house, bool set = true); 311 void Set_Visible(HouseClass *player, bool set = true); 312 bool Is_Visible(HousesType house) const; 313 bool Is_Visible(HouseClass *player) const; 314 bool Is_Jamming(HousesType house) const; 315 bool Is_Jamming(HouseClass *player) const; 316 317 /* 318 ** Override land type to fix passability issues on some maps 319 */ 320 void Override_Land_Type(LandType type); 321 322 private: 323 CellClass (CellClass const &) ; 324 325 LandType Land; // The land type of this cell. 326 327 LandType OverrideLand; // The overriden land type of this cell. 328 329 /* 330 ** Points to the flag animation on this cell in CTF games. 331 */ 332 AnimClass* CTFFlag; 333 334 /* 335 ** Some additional padding in case we need to add data to the class and maintain backwards compatibility for save/load 336 */ 337 unsigned char SaveLoadPadding[28]; 338 }; 339 340 #endif