CELL.H 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. /*
  2. ** Command & Conquer(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /* $Header: F:\projects\c&c\vcs\code\cell.h_v 2.20 16 Oct 1995 16:45:36 JOE_BOSTIC $ */
  19. /***********************************************************************************************
  20. *** 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 ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Command & Conquer *
  24. * *
  25. * File Name : CELL.H *
  26. * *
  27. * Programmer : Joe L. Bostic *
  28. * *
  29. * Start Date : April 29, 1994 *
  30. * *
  31. * Last Update : April 29, 1994 [JLB] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #ifndef CELL_H
  37. #define CELL_H
  38. #include "building.h"
  39. #include "unit.h"
  40. #include "template.h"
  41. /****************************************************************************
  42. ** Each cell on the map is controlled by the following structure.
  43. */
  44. class CellClass
  45. {
  46. public:
  47. /*
  48. ** Does this cell need to be updated on the radar map? If something changes in the cell
  49. ** that might change the radar map imagery, then this flag will be set. It gets cleared
  50. ** when the cell graphic is updated to the radar map.
  51. */
  52. unsigned IsPlot:1;
  53. /*
  54. ** Does this cell contain the special placement cursor graphic? This graphic is
  55. ** present when selecting a site for building placement.
  56. */
  57. unsigned IsCursorHere:1;
  58. /*
  59. ** Is this cell mapped by the player? A mapped cell is visible. An unmapped cell
  60. ** is covered in a dark shroud. In addition to visibility, mapped cells are the only
  61. ** legal place for transports to land.
  62. */
  63. unsigned IsMapped:1;
  64. /*
  65. ** If any part of this cell is visible (even just peeking out from under the shadow),
  66. ** this this flag will be true. Mapped cells always have this flag set, but unmapped
  67. ** cells might not -- it depends on where the shadow edge is located.
  68. */
  69. unsigned IsVisible:1;
  70. /*
  71. ** Every cell can be assigned a trigger. The same trigger can be assigned to
  72. ** multiple cells. This bitflag indicates whether this cell has a trigger.
  73. ** The trigger pointers for all cells must be stored elsewhere.
  74. */
  75. unsigned IsTrigger:1;
  76. /*
  77. ** Every cell can be assigned a waypoint. A waypoint can only be assigned
  78. ** to one cell, and vice-versa. This bit simply indicates whether this
  79. ** cell is assigned a waypoint or not.
  80. */
  81. unsigned IsWaypoint:1;
  82. /*
  83. ** Is this cell currently under the radar map cursor? If so then it
  84. ** needs to be updated whenever the map is updated.
  85. */
  86. unsigned IsRadarCursor:1;
  87. /*
  88. ** If this cell contains a house flag, then this will be true. The actual house
  89. ** flag it contains is specified by the Owner field.
  90. */
  91. unsigned IsFlagged:1;
  92. /*
  93. ** This contains the icon number and set to use for the base
  94. ** of the terrain. All rendering on an icon occurs AFTER the icon
  95. ** specified by this element is rendered. It is the lowest of the low.
  96. */
  97. TemplateType TType;
  98. unsigned char TIcon;
  99. /*
  100. ** The second layer of 'terrain' icons is represented by a simple
  101. ** type number and a value byte. This is sufficient for handling
  102. ** concrete and walls.
  103. */
  104. OverlayType Overlay;
  105. unsigned char OverlayData;
  106. /*
  107. ** This is used to specify any special 'stain' overlay icon. This
  108. ** typically includes infantry bodies or other temporary marks.
  109. */
  110. SmudgeType Smudge;
  111. unsigned char SmudgeData;
  112. /*
  113. ** Smudges and walls need to record ownership values. For walls, this
  114. ** allows adjacent building placement logic to work. For smudges, it
  115. ** allows building over smudges that are no longer attached to buildings
  116. ** in addition to fixing the adjacent placement logic.
  117. */
  118. HousesType Owner;
  119. /*
  120. ** This flag tells you what type of infantry currently occupy the
  121. ** cell or are moving into it.
  122. */
  123. HousesType InfType;
  124. /*
  125. ** These point to the object(s) that are located in this cell or overlap
  126. ** this cell.
  127. */
  128. ObjectClass *OccupierPtr;
  129. ObjectClass *Overlapper[3];
  130. /*
  131. ** This array of bit flags is used to indicate which sub positions
  132. ** within the cell are either occupied or are soon going to be
  133. ** occupied. For vehicles, the cells that the vehicle is passing over
  134. ** will be flagged with the vehicle bit. For infantry, the the sub
  135. ** position the infantry is stopped at or headed toward will be marked.
  136. ** The sub positions it passes over will NOT be marked.
  137. */
  138. union {
  139. struct {
  140. unsigned Center:1;
  141. unsigned NW:1;
  142. unsigned NE:1;
  143. unsigned SW:1;
  144. unsigned SE:1;
  145. unsigned Vehicle:1; // Reserved for vehicle occupation.
  146. unsigned Monolith:1; // Some immovable blockage is in cell.
  147. unsigned Building:1; // A building of some time (usually blocks movement).
  148. } Occupy;
  149. unsigned char Composite;
  150. } Flag;
  151. //----------------------------------------------------------------
  152. CellClass(void);
  153. ~CellClass(void) {};
  154. int operator == (CellClass const & cell) const {return &cell == this;};
  155. /*
  156. ** Query functions.
  157. */
  158. ObjectClass * Cell_Occupier(void) const;
  159. static int Spot_Index(COORDINATE coord);
  160. bool Is_Spot_Free(int spot_index) const {return (! (Flag.Composite & (1 << spot_index)) ); }
  161. COORDINATE Closest_Free_Spot(COORDINATE coord, bool any=false) const;
  162. COORDINATE Free_Spot(void) const {return Closest_Free_Spot(Cell_Coord());};
  163. bool Is_Generally_Clear(void) const;
  164. TARGET As_Target(void) const {return ::As_Target(Cell_Number());};
  165. BuildingClass * Cell_Building(void) const;
  166. CellClass const & Adjacent_Cell(FacingType face) const;
  167. CellClass & Adjacent_Cell(FacingType face) {return (CellClass &)((*((CellClass const *)this)).Adjacent_Cell(face));};
  168. COORDINATE Cell_Coord(void) const;
  169. int Cell_Color(bool override=false) const;
  170. CELL Cell_Number(void) const;
  171. LandType Land_Type(void) const {return Land;};
  172. ObjectClass * Cell_Find_Object(RTTIType rtti) const;
  173. ObjectClass * Cell_Object(int x=0, int y=0) const;
  174. TechnoClass * Cell_Techno(int x=0, int y=0) const;
  175. TerrainClass * Cell_Terrain(void) const;
  176. UnitClass * Cell_Unit(void) const;
  177. InfantryClass * Cell_Infantry(void) const;
  178. TriggerClass * Get_Trigger(void) const;
  179. int Clear_Icon(void) const;
  180. bool Goodie_Check(FootClass * object);
  181. ObjectClass * Fetch_Occupier(void) const;
  182. /*
  183. ** Object placement and removal flag operations.
  184. */
  185. void Occupy_Down(ObjectClass * object);
  186. void Occupy_Up(ObjectClass * object);
  187. void Overlap_Down(ObjectClass * object);
  188. void Overlap_Up(ObjectClass * object);
  189. bool Flag_Place(HousesType house);
  190. bool Flag_Remove(void);
  191. /*
  192. ** File I/O.
  193. */
  194. bool Should_Save(void) const;
  195. bool Save(FileClass & file);
  196. bool Load(FileClass & file);
  197. void Code_Pointers(void);
  198. void Decode_Pointers(void);
  199. /*
  200. ** Display and rendering controls.
  201. */
  202. void Draw_It(int x, int y, int draw_flags = 0) const;
  203. void Redraw_Objects(bool forced=false);
  204. void Shimmer(void);
  205. /*
  206. ** Maintenance calculation support.
  207. */
  208. long Tiberium_Adjust(bool pregame=false);
  209. void Wall_Update(void);
  210. void Concrete_Calc(void);
  211. void Recalc_Attributes(void);
  212. int Reduce_Tiberium(int levels);
  213. int Reduce_Wall(int damage);
  214. void Incoming(COORDINATE threat=0, bool forced = false);
  215. void Adjust_Threat(HousesType house, int threat_value);
  216. int operator != (CellClass const &) const {return 0;};
  217. int Validate(void) const;
  218. private:
  219. CellClass (CellClass const &) {};
  220. LandType Land; // The land type of this cell.
  221. };
  222. #endif