KindOf.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /*
  2. ** Command & Conquer Generals(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. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: KindOf.h //////////////////////////////////////////////////////////////////////////
  24. // Author: Steven Johnson, Dec 2001
  25. // Desc:
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. #pragma once
  28. #ifndef __KINDOF_H_
  29. #define __KINDOF_H_
  30. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  31. #include "Lib/BaseType.h"
  32. #include "Common/BitFlags.h"
  33. //-------------------------------------------------------------------------------------------------
  34. /** Kind of flags for determining groups of things that belong together
  35. * NOTE: You *MUST* keep this in the same order as the KindOfNames[] below */
  36. //-------------------------------------------------------------------------------------------------
  37. enum KindOfType
  38. {
  39. KINDOF_INVALID = -1,
  40. KINDOF_FIRST = 0,
  41. KINDOF_OBSTACLE = KINDOF_FIRST, ///< an obstacle to land-based pathfinders
  42. KINDOF_SELECTABLE, ///< Selectable
  43. KINDOF_IMMOBILE, ///< fixed in location
  44. KINDOF_CAN_ATTACK, ///< can attack
  45. KINDOF_STICK_TO_TERRAIN_SLOPE, ///< should be stuck at ground level, aligned to terrain slope. requires that IMMOBILE bit is also set.
  46. KINDOF_CAN_CAST_REFLECTIONS, ///< can cast reflections in water
  47. KINDOF_SHRUBBERY, ///< tree, bush, etc.
  48. KINDOF_STRUCTURE, ///< structure of some sort (buildable or not)
  49. KINDOF_INFANTRY, ///< unit like soldier etc
  50. KINDOF_VEHICLE, ///< unit like tank, jeep, plane, helicopter, etc.
  51. KINDOF_AIRCRAFT, ///< unit like plane, helicopter, etc., that is predominantly a flyer. (hovercraft are NOT aircraft)
  52. KINDOF_HUGE_VEHICLE, ///< unit that is, technically, a vehicle, but WAY larger than normal (eg, Overlord)
  53. KINDOF_DOZER, ///< a dozer
  54. KINDOF_HARVESTER, ///< a harvester
  55. KINDOF_COMMANDCENTER, ///< a command center
  56. #ifdef ALLOW_SURRENDER
  57. KINDOF_PRISON, ///< a prison detention center kind of thing
  58. KINDOF_COLLECTS_PRISON_BOUNTY, ///< when prisoners are delivered to these, the player gets money
  59. KINDOF_POW_TRUCK, ///< a pow truck can pick up and return prisoners
  60. #endif
  61. KINDOF_LINEBUILD, ///< wall-type thing that is built in a line
  62. KINDOF_SALVAGER, ///< something that can create and use Salvage Crates
  63. KINDOF_WEAPON_SALVAGER, ///< subset of salvager that can get weapon upgrades from salvage
  64. KINDOF_TRANSPORT, ///< a true transport (has TransportContain)
  65. KINDOF_BRIDGE, ///< a Bridge. (special structure)
  66. KINDOF_LANDMARK_BRIDGE, ///< a landmark bridge (special bridge that isn't resizable)
  67. KINDOF_BRIDGE_TOWER, ///< a bridge tower that we can target for bridge destruction
  68. KINDOF_PROJECTILE, ///< Instead of being a ground or air unit, this object is special
  69. KINDOF_PRELOAD, ///< all model data will be preloaded even if not on map
  70. KINDOF_NO_GARRISON, ///< unit may not garrison bldgs, even if infantry bit is set
  71. KINDOF_WAVEGUIDE, ///< water wave object
  72. KINDOF_WAVE_EFFECT, ///< wave effect point
  73. KINDOF_NO_COLLIDE, ///< Never collide with or be collided with
  74. KINDOF_REPAIR_PAD, ///< is a repair pad object that can repair other machines
  75. KINDOF_HEAL_PAD, ///< is a heal pad object that can heal flesh and bone units
  76. KINDOF_STEALTH_GARRISON, /** enemy teams can't tell that unit is in building.. and if they
  77. garrison that building, they stealth unit will eject. */
  78. KINDOF_CASH_GENERATOR, ///< used to check if the unit generates cash... checked by cash hackers and whatever else comes up
  79. KINDOF_AIRFIELD, ///< unit has a runway that planes can takeoff/land on
  80. KINDOF_DRAWABLE_ONLY, ///< template is used only to create drawables (not Objects)
  81. KINDOF_MP_COUNT_FOR_VICTORY, ///< If a player loses all his buildings that have this kindof in a multiplayer game, he loses.
  82. KINDOF_REBUILD_HOLE, ///< a GLA rebuild hole
  83. KINDOF_SCORE, ///< Object counts for Multiplayer scores, and short-game calculations (for buildings)
  84. KINDOF_SCORE_CREATE, ///< Object only counts for multiplayer score for creation.
  85. KINDOF_SCORE_DESTROY, ///< Object only counts for multiplayer score for destruction.
  86. KINDOF_NO_HEAL_ICON, ///< do not ever display healing icons on these objects
  87. KINDOF_CAN_RAPPEL, ///< can rappel. duh.
  88. KINDOF_PARACHUTABLE, ///< parachutable object
  89. #ifdef ALLOW_SURRENDER
  90. KINDOF_CAN_SURRENDER, ///< object that can surrender
  91. #endif
  92. KINDOF_CAN_BE_REPULSED, ///< object that runs away from a repulsor object.
  93. KINDOF_MOB_NEXUS, ///< object that cooyrdinates the members of a mob (i.e. GLAInfantryAngryMob)
  94. KINDOF_IGNORED_IN_GUI, ///< object that is the members of a mob (i.e. GLAInfantryAngryMob)
  95. KINDOF_CRATE, ///< a bonus crate
  96. KINDOF_CAPTURABLE, ///< is "capturable" even if not an enemy (should generally be used only for structures, eg, Tech bldgs)
  97. KINDOF_CLEARED_BY_BUILD, ///< is auto-cleared from the map when built over via construction
  98. KINDOF_SMALL_MISSILE, ///< Missile object: ONLY USED FOR ANTI-MISSILE TARGETTING PURPOSES! Keep using PROJECTILE!
  99. KINDOF_ALWAYS_VISIBLE, ///< is never obscured by fog of war or shroud. mostly for UI feedback objects.
  100. KINDOF_UNATTACKABLE, ///< You cannot target this thing, it probably doesn't really exist
  101. KINDOF_MINE, ///< a landmine. (possibly also extend to Col. Burton timed charges?)
  102. KINDOF_CLEANUP_HAZARD, ///< radiation and bio-poison are samples of area conditions that can be cleaned up (or avoided)
  103. KINDOF_PORTABLE_STRUCTURE, ///< Flag to identify building like subobjects an Overlord is allowed to Contain.
  104. KINDOF_ALWAYS_SELECTABLE, ///< is never unselectable (even if effectively dead). mostly for UI feedback objects.
  105. KINDOF_ATTACK_NEEDS_LINE_OF_SIGHT, ///< Unit has to have clear line of sight (los) to attack.
  106. KINDOF_WALK_ON_TOP_OF_WALL, ///< Units can walk on top of a wall made of these kind of objects.
  107. KINDOF_DEFENSIVE_WALL, ///< wall can't be driven thru, even if crusher, so pathfinder must path around it
  108. KINDOF_FS_POWER, ///< Faction structure power building
  109. KINDOF_FS_FACTORY, ///< Faction structure power building
  110. KINDOF_FS_BASE_DEFENSE, ///< Faction structure base defense
  111. KINDOF_FS_TECHNOLOGY, ///< Faction structure technology building
  112. KINDOF_AIRCRAFT_PATH_AROUND, ///< Tall enough that aircraft need to path around this.
  113. KINDOF_LOW_OVERLAPPABLE, ///< When overlapped, things always overlap at a 'low' height rather than our object geom
  114. KINDOF_FORCEATTACKABLE, ///< unit is always attackable via force-attack, even if not selectable
  115. KINDOF_AUTO_RALLYPOINT, ///< When immobile-structure-object is selected, left clicking on ground will set new rally point without requiring command button.
  116. KINDOF_TECH_BUILDING, ///< Neutral tech building - Oil derrick, Hospital, Radio Station, Refinery.
  117. KINDOF_POWERED, ///< This object gets the Underpowered disabled condition when its owning player has power consumption exceed supply
  118. KINDOF_PRODUCED_AT_HELIPAD, ///< ugh... hacky fix for comanche. (srj)
  119. KINDOF_DRONE, ///< Object drone type -- used for filtering them out of battle plan bonuses and whatever else may come up.
  120. KINDOF_CAN_SEE_THROUGH_STRUCTURE,///< Structure does not block line of sight.
  121. KINDOF_BALLISTIC_MISSILE, ///< Large ballistic missiles that are specifically large enough to be targetted by base defenses.
  122. KINDOF_CLICK_THROUGH, ///< Objects with this will never be picked by mouse interactions!
  123. KINDOF_SUPPLY_SOURCE_ON_PREVIEW,///< Any thing that we can get "supplies" from that we want to show up on the map preview
  124. KINDOF_PARACHUTE, ///< it's a parachute
  125. KINDOF_GARRISONABLE_UNTIL_DESTROYED, ///< Object is capable of garrisoning troops until completely destroyed.
  126. KINDOF_BOAT, ///< It's a boat!
  127. KINDOF_IMMUNE_TO_CAPTURE, ///< Under no circumstances can this building ever be captured.
  128. KINDOF_HULK, ///< Hulk types so we can do special things to them via scripts or other things that may come up.
  129. KINDOF_SHOW_PORTRAIT_WHEN_CONTROLLED, ///< Only shows portraits when controlled.
  130. KINDOF_SPAWNS_ARE_THE_WEAPONS, ///< Evaluate the spawn slaves as this object's weapons.
  131. KINDOF_CANNOT_BUILD_NEAR_SUPPLIES, ///< you can't be built "too close" to anything that provides supplies
  132. KINDOF_SUPPLY_SOURCE, ///< this object provides supplies
  133. KINDOF_REVEAL_TO_ALL, ///< this object reveals shroud for all players
  134. KINDOF_DISGUISER, ///< This object has the ability to disguise.
  135. KINDOF_INERT, ///< this object shouldn't be considered for any sort of interaction with any player.
  136. KINDOF_HERO, ///< Any of the single-instance infantry, JarmenKell, BlackLotus, ColonelBurton
  137. KINDOF_IGNORES_SELECT_ALL, ///< Too late to figure out intelligently if something should respond to a Select All command
  138. KINDOF_DONT_AUTO_CRUSH_INFANTRY, ///< These units don't try to crush the infantry if ai.
  139. KINDOF_COUNT // total number of kindofs
  140. };
  141. typedef BitFlags<KINDOF_COUNT> KindOfMaskType;
  142. #define MAKE_KINDOF_MASK(k) KindOfMaskType(KindOfMaskType::kInit, (k))
  143. inline Bool TEST_KINDOFMASK(const KindOfMaskType& m, KindOfType t)
  144. {
  145. return m.test(t);
  146. }
  147. inline Bool TEST_KINDOFMASK_ANY(const KindOfMaskType& m, const KindOfMaskType& mask)
  148. {
  149. return m.anyIntersectionWith(mask);
  150. }
  151. inline Bool TEST_KINDOFMASK_MULTI(const KindOfMaskType& m, const KindOfMaskType& mustBeSet, const KindOfMaskType& mustBeClear)
  152. {
  153. return m.testSetAndClear(mustBeSet, mustBeClear);
  154. }
  155. inline Bool KINDOFMASK_ANY_SET(const KindOfMaskType& m)
  156. {
  157. return m.any();
  158. }
  159. inline void CLEAR_KINDOFMASK(KindOfMaskType& m)
  160. {
  161. m.clear();
  162. }
  163. inline void SET_ALL_KINDOFMASK_BITS(KindOfMaskType& m)
  164. {
  165. m.clear();
  166. m.flip();
  167. }
  168. inline void FLIP_KINDOFMASK(KindOfMaskType& m)
  169. {
  170. m.flip();
  171. }
  172. // defined in Common/System/Kindof.cpp
  173. extern KindOfMaskType KINDOFMASK_NONE; // inits to all zeroes
  174. #endif // __KINDOF_H_