OBJECT.CPP 143 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505
  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. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. /* $Header: /CounterStrike/OBJECT.CPP 1 3/03/97 10:25a Joe_bostic $ */
  15. /***********************************************************************************************
  16. *** 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 ***
  17. ***********************************************************************************************
  18. * *
  19. * Project Name : Command & Conquer *
  20. * *
  21. * File Name : OBJECT.CPP *
  22. * *
  23. * Programmer : Joe L. Bostic *
  24. * *
  25. * Start Date : April 29, 1994 *
  26. * *
  27. * Last Update : October 6, 1996 [JLB] *
  28. * *
  29. *---------------------------------------------------------------------------------------------*
  30. * Functions: *
  31. * ObjectClass::AI -- Handles generic object AI processing. *
  32. * ObjectClass::Active_Click_With -- Dispatches action on the object specified. *
  33. * ObjectClass::Active_Click_With -- Dispatches action on the specified cell. *
  34. * ObjectClass::Attach_Trigger -- Attach specified trigger to object. *
  35. * ObjectClass::Can_Demolish -- Queries whether this object can be sold back. *
  36. * ObjectClass::Can_Player_Fire -- Can the player give this object an attack mission? *
  37. * ObjectClass::Can_Player_Move -- Can the player give this object a movement mission? *
  38. * ObjectClass::Can_Repair -- Queries whether this object can be repaired. *
  39. * ObjectClass::Catch_Fire -- Called when animation is attached to this object. *
  40. * ObjectClass::Center_Coord -- Fetches the center coordinate for the object. *
  41. * ObjectClass::Clicked_As_Target -- Triggers target selection animation. *
  42. * ObjectClass::Debug_Dump -- Displays status of the object class to the mono monitor. *
  43. * ObjectClass::Detach -- Detach the specified target from this object. *
  44. * ObjectClass::Detach_All -- Removes the object from all tracking systems. *
  45. * ObjectClass::Do_Shimmer -- Shimmers this object if it is cloaked. *
  46. * ObjectClass::Docking_Coord -- Fetches the coordinate to dock at this object. *
  47. * ObjectClass::Exit_Coord -- Return with the exit coordinate for this object. *
  48. * ObjectClass::Exit_Object -- Causes the specified object to leave this object. *
  49. * ObjectClass::Fire_Coord -- Fetches the coordinate a projectile will launch from. *
  50. * ObjectClass::Fire_Out -- Informs object that attached animation has finished. *
  51. * ObjectClass::Get_Mission -- Fetches the current mission of this object. *
  52. * ObjectClass::Get_Ownable -- Fetches the house owner legality options for this object. *
  53. * ObjectClass::Hidden -- Called when this object becomes hidden from the player. *
  54. * ObjectClass::In_Range -- Determines if the coordinate is within weapon range. *
  55. * ObjectClass::In_Which_Layer -- Fetches what layer this object is located in. *
  56. * ObjectClass::Init -- Initializes the basic object system. *
  57. * ObjectClass::Limbo -- Brings the object into a state of limbo. *
  58. * ObjectClass::Look -- Called when this object needs to reveal terrain. *
  59. * ObjectClass::Mark -- Handles basic marking logic. *
  60. * ObjectClass::Mark_For_Redraw -- Marks object and system for redraw. *
  61. * ObjectClass::Move -- Moves (by force) the object in the desired direction. *
  62. * ObjectClass::Name -- Fetches the identification name of this object. *
  63. * ObjectClass::ObjectClass -- Default constructor for objects. *
  64. * ObjectClass::Paradrop -- Unlimbos object in paradrop mode. *
  65. * ObjectClass::Passive_Click_With -- Right mouse button click process. *
  66. * ObjectClass::Receive_Message -- Processes an incoming radio message. *
  67. * ObjectClass::Record_The_Kill -- Records this object as killed by the specified object. *
  68. * ObjectClass::Render -- Displays the object onto the map. *
  69. * ObjectClass::Render_Coord -- Fetches the coordinate to draw this object at. *
  70. * ObjectClass::Repair -- Handles object repair control. *
  71. * ObjectClass::Revealed -- Reveals this object to the house specified. *
  72. * ObjectClass::Scatter -- Tries to scatter this object. *
  73. * ObjectClass::Select -- Try to make this object the "selected" object. *
  74. * ObjectClass::Sell_Back -- Sells the object -- if possible. *
  75. * ObjectClass::Sort_Y -- Returns the coordinate used for display order sorting. *
  76. * ObjectClass::Take_Damage -- Applies damage to the object. *
  77. * ObjectClass::Target_Coord -- Fetches the coordinate if this object is a target. *
  78. * ObjectClass::Unlimbo -- Brings the object into the game system. *
  79. * ObjectClass::Unselect -- This will un-select the object if it was selected. *
  80. * ObjectClass::Value -- Fetches the target value of this object. *
  81. * ObjectClass::Weapon_Range -- Returns the weapon range for the weapon specified. *
  82. * ObjectClass::What_Action -- Determines what action to perform on specified object. *
  83. * ObjectClass::What_Action -- Returns with the action to perform for this object. *
  84. * ObjectTypeClass::Cost_Of -- Returns the cost to buy this unit. *
  85. * ObjectTypeClass::Dimensions -- Gets the dimensions of the object in pixels. *
  86. * ObjectTypeClass::Get_Cameo_Data -- Fetches pointer to cameo data for this object type. *
  87. * ObjectTypeClass::Max_Pips -- Fetches the maximum pips allowed for this object. *
  88. * ObjectTypeClass::ObjectTypeClass -- Normal constructor for object type class objects. *
  89. * ObjectTypeClass::Occupy_List -- Returns with simple occupation list for object. *
  90. * ObjectTypeClass::One_Time -- Handles one time processing for object types. *
  91. * ObjectTypeClass::Overlap_List -- Returns a pointer to a simple overlap list. *
  92. * ObjectTypeClass::Time_To_Build -- Fetches the time to construct this object. *
  93. * ObjectTypeClass::Who_Can_Build_Me -- Determine what building can build this object type. *
  94. * ObjectTypeClass::Who_Can_Build_Me -- Finds the factory building that can build this object*
  95. * ObjectClass::Get_Image_Data -- Fetches the image data to use for this object. *
  96. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  97. #include "function.h"
  98. /*
  99. ** Selected objects have a special marking box around them. This is the shapes that are
  100. ** used for this purpose.
  101. */
  102. void const * ObjectTypeClass::SelectShapes = 0;
  103. void const * ObjectTypeClass::PipShapes = 0;
  104. /***********************************************************************************************
  105. * ObjectClass::ObjectClass -- Default constructor for objects. *
  106. * *
  107. * This is the default constructor for objects. It is called as an inherent part of the *
  108. * construction process for all the normal game objects instantiated. It serves merely to *
  109. * initialize the object values to a common (default) state. *
  110. * *
  111. * INPUT: none *
  112. * *
  113. * OUTPUT: none *
  114. * *
  115. * WARNINGS: Objects always start in a state of limbo. They must be Unlimbo()ed before they *
  116. * can be used. *
  117. * *
  118. * HISTORY: *
  119. * 09/24/1994 JLB : Created. *
  120. *=============================================================================================*/
  121. ObjectClass::ObjectClass(RTTIType rtti, int id) :
  122. AbstractClass(rtti, id),
  123. IsDown(false),
  124. IsToDamage(false),
  125. IsToDisplay(false),
  126. IsInLimbo(true),
  127. IsSelected(false),
  128. IsAnimAttached(false),
  129. IsFalling(false),
  130. Riser(0),
  131. Next(0),
  132. Trigger(NULL),
  133. Strength(255),
  134. IsSelectedMask(0) // Mask showing who has selected this object
  135. {
  136. }
  137. /***********************************************************************************************
  138. * ObjectClass::Get_Image_Data -- Fetches the image data to use for this object. *
  139. * *
  140. * This routine will return with a pointer to the image data that should be used when *
  141. * this object is drawn. *
  142. * *
  143. * INPUT: none *
  144. * *
  145. * OUTPUT: Returns with a pointer to the shape data for this object. *
  146. * *
  147. * WARNINGS: none *
  148. * *
  149. * HISTORY: *
  150. * 08/06/1996 JLB : Created. *
  151. *=============================================================================================*/
  152. void const * ObjectClass::Get_Image_Data(void) const
  153. {
  154. return(Class_Of().Get_Image_Data());
  155. }
  156. /***********************************************************************************************
  157. * ObjectClass::Name -- Fetches the identification name of this object. *
  158. * *
  159. * This routine will return a pointer to the identifier name for this object. This name *
  160. * is usually short and is used in the INI files to identify this object. *
  161. * *
  162. * INPUT: none *
  163. * *
  164. * OUTPUT: Returns with a pointer to the text identifier name of this object. *
  165. * *
  166. * WARNINGS: none *
  167. * *
  168. * HISTORY: *
  169. * 07/29/1996 JLB : Created. *
  170. *=============================================================================================*/
  171. char const * ObjectClass::Name(void) const
  172. {
  173. return(Class_Of().Name());
  174. }
  175. /***********************************************************************************************
  176. * ObjectClass::Exit_Coord -- Return with the exit coordinate for this object. *
  177. * *
  178. * Ths exit coordinate is the location that a piggy back or newly produced object will *
  179. * appear at when it exits this object. Transports and factory buildings will utilize this *
  180. * routine. *
  181. * *
  182. * INPUT: none *
  183. * *
  184. * OUTPUT: Returns with the coordinate that an object will appear at when exiting this *
  185. * object. *
  186. * *
  187. * WARNINGS: none *
  188. * *
  189. * HISTORY: *
  190. * 07/29/1996 JLB : Created. *
  191. *=============================================================================================*/
  192. COORDINATE ObjectClass::Exit_Coord(void) const
  193. {
  194. return(Center_Coord());
  195. }
  196. /***********************************************************************************************
  197. * ObjectClass::AI -- Handles generic object AI processing. *
  198. * *
  199. * This routine is used to handle the AI processing that occurs for all object types. *
  200. * Typically, this isn't much, but there is the concept of falling that all objects can *
  201. * be subjected to (e.g., grenades). *
  202. * *
  203. * INPUT: none *
  204. * *
  205. * OUTPUT: none *
  206. * *
  207. * WARNINGS: none *
  208. * *
  209. * HISTORY: *
  210. * 02/07/1996 JLB : Created. *
  211. *=============================================================================================*/
  212. void ObjectClass::AI(void)
  213. {
  214. assert(this != 0);
  215. assert(IsActive);
  216. /*
  217. ** Falling logic is handled here.
  218. */
  219. if (IsFalling) {
  220. LayerType layer = In_Which_Layer();
  221. Height += Riser;
  222. if (Height <= 0) {
  223. Height = 0;
  224. IsFalling = false;
  225. Per_Cell_Process(PCP_END);
  226. Shorten_Attached_Anims(this);
  227. }
  228. if (IsAnimAttached) {
  229. Riser -= 1;
  230. Riser = max(Riser, -3);
  231. } else {
  232. Riser -= Rule.Gravity;
  233. // Riser -= GRAVITY;
  234. Riser = max(Riser, -100);
  235. }
  236. if (layer != In_Which_Layer()) {
  237. Map.Remove(this, layer);
  238. Map.Submit(this, In_Which_Layer());
  239. if (Class_Of().IsFootprint) {
  240. if (In_Which_Layer() == LAYER_GROUND) {
  241. Map.Place_Down(Coord_Cell(Center_Coord()), this);
  242. } else {
  243. Map.Pick_Up(Coord_Cell(Center_Coord()), this);
  244. }
  245. }
  246. }
  247. }
  248. }
  249. /***********************************************************************************************
  250. * ObjectClass::What_Action -- Determines what action to perform on specified object. *
  251. * *
  252. * This routine will return that action that this object could perform if the mouse were *
  253. * clicked over the object specified. *
  254. * *
  255. * INPUT: object -- Pointer to the object to check this object against when determining *
  256. * the action to perform. *
  257. * *
  258. * OUTPUT: It returns that action that will be performed if the mouse were clicked over the *
  259. * object. Since non-derived objects cannot do anything, and cannot even be *
  260. * instantiated, this routine will always return ACTION_NONE. *
  261. * *
  262. * WARNINGS: none *
  263. * *
  264. * HISTORY: *
  265. * 07/19/1995 JLB : Created. *
  266. *=============================================================================================*/
  267. ActionType ObjectClass::What_Action(ObjectClass const *) const
  268. {
  269. assert(this != 0);
  270. assert(IsActive);
  271. return(ACTION_NONE);
  272. }
  273. /***********************************************************************************************
  274. * ObjectClass::What_Action -- Returns with the action to perform for this object. *
  275. * *
  276. * This routine is called when information on a potential action if the mouse were clicked *
  277. * on the cell specified. This routine merely serves as a virtual placeholder so that *
  278. * object types that can actually perform some action will override this routine to provide *
  279. * true functionality. *
  280. * *
  281. * INPUT: cell -- The cell that the mouse is over and might be clicked on. *
  282. * *
  283. * OUTPUT: Returns with the action that this object would try to perform if the mouse were *
  284. * clicked. Since objects at this level have no ability to do anything, this routine *
  285. * will always returns ACTION_NONE unless it is overridden. *
  286. * *
  287. * WARNINGS: none *
  288. * *
  289. * HISTORY: *
  290. * 08/13/1995 JLB : Created. *
  291. *=============================================================================================*/
  292. ActionType ObjectClass::What_Action(CELL) const
  293. {
  294. assert(this != 0);
  295. assert(IsActive);
  296. return(ACTION_NONE);
  297. }
  298. /***********************************************************************************************
  299. * ObjectClass::In_Which_Layer -- Fetches what layer this object is located in. *
  300. * *
  301. * The default layer for object location is the LAYER_GROUND. Aircraft will override this *
  302. * routine and make adjustments as necessary according to the aircraft's altitude. *
  303. * *
  304. * INPUT: none *
  305. * *
  306. * OUTPUT: Returns with the layer that this object is located in. *
  307. * *
  308. * WARNINGS: none *
  309. * *
  310. * HISTORY: *
  311. * 08/13/1995 JLB : Created. *
  312. *=============================================================================================*/
  313. LayerType ObjectClass::In_Which_Layer(void) const
  314. {
  315. assert(this != 0);
  316. assert(IsActive);
  317. if (Height < (FLIGHT_LEVEL - (FLIGHT_LEVEL/3))) {
  318. return(LAYER_GROUND);
  319. }
  320. return(LAYER_TOP);
  321. }
  322. /***********************************************************************************************
  323. * ObjectClass::Get_Ownable -- Fetches the house owner legality options for this object. *
  324. * *
  325. * This routine will return the ownable bits for this object. Objects at this level can't *
  326. * really be owned by anyone, but return the full spectrum of legality just to be safe. *
  327. * *
  328. * INPUT: none *
  329. * *
  330. * OUTPUT: Returns with the ownable flags (as a combined bitfield) for this object. *
  331. * *
  332. * WARNINGS: none *
  333. * *
  334. * HISTORY: *
  335. * 08/13/1995 JLB : Created. *
  336. *=============================================================================================*/
  337. int ObjectClass::Get_Ownable(void) const
  338. {
  339. assert(this != 0);
  340. assert(IsActive);
  341. return(HOUSEF_ALLIES | HOUSEF_SOVIET | HOUSEF_OTHERS);
  342. }
  343. /***********************************************************************************************
  344. * ObjectClass::Can_Repair -- Queries whether this object can be repaired. *
  345. * *
  346. * Most objects cannot be repaired. This routine defaults to returning "false", but is *
  347. * overridden by derived functions defined by object types that can support repair. *
  348. * *
  349. * INPUT: none *
  350. * *
  351. * OUTPUT: Can this object be repaired? *
  352. * *
  353. * WARNINGS: none *
  354. * *
  355. * HISTORY: *
  356. * 08/13/1995 JLB : Created. *
  357. *=============================================================================================*/
  358. bool ObjectClass::Can_Repair(void) const
  359. {
  360. assert(this != 0);
  361. assert(IsActive);
  362. return(false);
  363. }
  364. /***********************************************************************************************
  365. * ObjectClass::Can_Demolish -- Queries whether this object can be sold back. *
  366. * *
  367. * This routine is used to determine if this object can be sold. Most objects cannot be *
  368. * but for those objects that can, this routine will be overridden as necessary. *
  369. * *
  370. * INPUT: none *
  371. * *
  372. * OUTPUT: Can this object be sold back? Typically, the answer is no. *
  373. * *
  374. * WARNINGS: none *
  375. * *
  376. * HISTORY: *
  377. * 08/13/1995 JLB : Created. *
  378. *=============================================================================================*/
  379. bool ObjectClass::Can_Demolish(void) const
  380. {
  381. assert(this != 0);
  382. assert(IsActive);
  383. return(false);
  384. }
  385. bool ObjectClass::Can_Demolish_Unit(void) const
  386. {
  387. assert(this != 0);
  388. assert(IsActive);
  389. return(false);
  390. }
  391. bool ObjectClass::Can_Capture(void) const
  392. {
  393. assert(this != 0);
  394. assert(IsActive);
  395. return(false);
  396. }
  397. /***********************************************************************************************
  398. * ObjectClass::Can_Player_Fire -- Can the player give this object an attack mission? *
  399. * *
  400. * This routine is used to determine if attacking is an option under player control with *
  401. * respect to this unit. This routine will be overridden as necessary for those objects *
  402. * that have the ability to attack. *
  403. * *
  404. * INPUT: none *
  405. * *
  406. * OUTPUT: Can this object be given an attack order by the player? *
  407. * *
  408. * WARNINGS: none *
  409. * *
  410. * HISTORY: *
  411. * 08/13/1995 JLB : Created. *
  412. *=============================================================================================*/
  413. bool ObjectClass::Can_Player_Fire(void) const
  414. {
  415. assert(this != 0);
  416. assert(IsActive);
  417. return(false);
  418. }
  419. /***********************************************************************************************
  420. * ObjectClass::Can_Player_Move -- Can the player give this object a movement mission? *
  421. * *
  422. * This routine is used to determine if the player has the ability to command this object *
  423. * with a movement mission. This routine will be overridden as necessary to support this *
  424. * ability. *
  425. * *
  426. * INPUT: none *
  427. * *
  428. * OUTPUT: Can this object be given a movement mission by the player? *
  429. * *
  430. * WARNINGS: none *
  431. * *
  432. * HISTORY: *
  433. * 08/13/1995 JLB : Created. *
  434. *=============================================================================================*/
  435. bool ObjectClass::Can_Player_Move(void) const
  436. {
  437. assert(this != 0);
  438. assert(IsActive);
  439. return(false);
  440. }
  441. /***********************************************************************************************
  442. * ObjectClass::Target_Coord -- Fetches the coordinate if this object is a target. *
  443. * *
  444. * When the coordinate to use when firing at this object is needed, this routine will *
  445. * provide it. Normal objects just use the center of the object for this, but there are *
  446. * some more sophisticated objects that are not fired upon the center. *
  447. * *
  448. * INPUT: none *
  449. * *
  450. * OUTPUT: Returns with the coordinate to fire at if this object is a target. *
  451. * *
  452. * WARNINGS: none *
  453. * *
  454. * HISTORY: *
  455. * 08/13/1995 JLB : Created. *
  456. *=============================================================================================*/
  457. COORDINATE ObjectClass::Target_Coord(void) const
  458. {
  459. assert(this != 0);
  460. assert(IsActive);
  461. return(Coord_Add(XY_Coord(0, -Height), Center_Coord()));
  462. // return(Center_Coord());
  463. }
  464. /***********************************************************************************************
  465. * ObjectClass::Center_Coord -- Fetches the center coordinate for the object. *
  466. * *
  467. * This routine will return the center coordinate for the object. The center coordinate is *
  468. * typically the coordinate recorded in the object structure. Exceptions to this include *
  469. * the trees and other terrain elements. *
  470. * *
  471. * INPUT: none *
  472. * *
  473. * OUTPUT: Returns the coordinate that is considered the center point of this object. *
  474. * *
  475. * WARNINGS: none *
  476. * *
  477. * HISTORY: *
  478. * 09/21/1995 JLB : Created. *
  479. *=============================================================================================*/
  480. COORDINATE ObjectClass::Center_Coord(void) const
  481. {
  482. assert(this != 0);
  483. assert(IsActive);
  484. return(Coord);
  485. }
  486. /***********************************************************************************************
  487. * ObjectClass::Render_Coord -- Fetches the coordinate to draw this object at. *
  488. * *
  489. * This routine will return the coordinate to base the drawing of this object's graphic *
  490. * at. This is adjusted according to the nature of the graphic associated with this *
  491. * object. *
  492. * *
  493. * INPUT: none *
  494. * *
  495. * OUTPUT: Returns the coordinate to draw the graphic of this object at. *
  496. * *
  497. * WARNINGS: none *
  498. * *
  499. * HISTORY: *
  500. * 09/21/1995 JLB : Created. *
  501. *=============================================================================================*/
  502. COORDINATE ObjectClass::Render_Coord(void) const
  503. {
  504. assert(this != 0);
  505. assert(IsActive);
  506. return(Center_Coord());
  507. }
  508. /***********************************************************************************************
  509. * ObjectClass::Docking_Coord -- Fetches the coordinate to dock at this object. *
  510. * *
  511. * This routine returns the coordinate that a potential docking object should home in on. *
  512. * Typically, this the center of the object, but in certain cases it is adjusted off center *
  513. * according to the object type. An example of this would be the airfield. *
  514. * *
  515. * INPUT: none *
  516. * *
  517. * OUTPUT: Returns with the coordinate that a docking object should head for. *
  518. * *
  519. * WARNINGS: none *
  520. * *
  521. * HISTORY: *
  522. * 09/21/1995 JLB : Created. *
  523. *=============================================================================================*/
  524. COORDINATE ObjectClass::Docking_Coord(void) const
  525. {
  526. assert(this != 0);
  527. assert(IsActive);
  528. return(Center_Coord());
  529. }
  530. /***********************************************************************************************
  531. * ObjectClass::Sort_Y -- Returns the coordinate used for display order sorting. *
  532. * *
  533. * This routine will return the value to be used for object sorting. The sorting ensures *
  534. * that the object are rendered from a top to bottom order. Certain object use a sorting *
  535. * value different from their center coordinate. This is true if the object "touches the *
  536. * ground" at a point that is different from the object's center point. *
  537. * *
  538. * INPUT: none *
  539. * *
  540. * OUTPUT: Returns with the value to use as the Y sorting value. *
  541. * *
  542. * WARNINGS: none *
  543. * *
  544. * HISTORY: *
  545. * 09/21/1995 JLB : Created. *
  546. *=============================================================================================*/
  547. COORDINATE ObjectClass::Sort_Y(void) const
  548. {
  549. assert(this != 0);
  550. assert(IsActive);
  551. return(Coord);
  552. }
  553. /***********************************************************************************************
  554. * ObjectClass::Fire_Coord -- Fetches the coordinate a projectile will launch from. *
  555. * *
  556. * For those objects that fire, the coordinate that the projectile it launches will appear *
  557. * at the location specified by the return value from this function. *
  558. * *
  559. * INPUT: which -- Which weapon to consider when determining fire coordinate? *
  560. * 0: primary weapon *
  561. * 1: secondary weapon *
  562. * *
  563. * OUTPUT: Returns with the coordinate that a launched projectile will appear at if this *
  564. * object were to fire the weapon specified. *
  565. * *
  566. * WARNINGS: none *
  567. * *
  568. * HISTORY: *
  569. * 09/21/1995 JLB : Created. *
  570. *=============================================================================================*/
  571. FireDataType ObjectClass::Fire_Data(int which) const
  572. {
  573. assert(this != 0);
  574. assert(IsActive);
  575. return{Fire_Coord(which),0};
  576. }
  577. COORDINATE ObjectClass::Fire_Coord(int ) const
  578. {
  579. assert(this != 0);
  580. assert(IsActive);
  581. return(Coord);
  582. }
  583. /***********************************************************************************************
  584. * ObjectClass::Record_The_Kill -- Records this object as killed by the specified object. *
  585. * *
  586. * This routine is called when this object is killed. If the source of the death is known, *
  587. * then a pointer to the responsible object is provided as a parameter. *
  588. * *
  589. * INPUT: source -- Pointer to the cause of this unit's death. *
  590. * *
  591. * OUTPUT: none *
  592. * *
  593. * WARNINGS: none *
  594. * *
  595. * HISTORY: *
  596. * 09/21/1995 JLB : Created. *
  597. *=============================================================================================*/
  598. void ObjectClass::Record_The_Kill(TechnoClass * )
  599. {
  600. assert(this != 0);
  601. assert(IsActive);
  602. }
  603. /***********************************************************************************************
  604. * ObjectClass::Do_Shimmer -- Shimmers this object if it is cloaked. *
  605. * *
  606. * When an object is cloaked, there are several conditions that would cause it to shimmer *
  607. * and thus reveal itself. When such a condition arrises, this function is called. If the *
  608. * object is cloaked, then it will shimmer. At this derivation level, cloaking is *
  609. * undefined. Objects that can cloak will override this function as necessary. *
  610. * *
  611. * INPUT: none *
  612. * *
  613. * OUTPUT: none *
  614. * *
  615. * WARNINGS: none *
  616. * *
  617. * HISTORY: *
  618. * 09/21/1995 JLB : Created. *
  619. *=============================================================================================*/
  620. void ObjectClass::Do_Shimmer(void)
  621. {
  622. assert(this != 0);
  623. assert(IsActive);
  624. }
  625. /***********************************************************************************************
  626. * ObjectClass::Exit_Object -- Causes the specified object to leave this object. *
  627. * *
  628. * This routine is called, typically, by a transport building type that requires an object *
  629. * to leave it. This routine will place the object at a suitable location or return *
  630. * a value indicating why not. *
  631. * *
  632. * INPUT: object -- Pointer to the object that wishes to leave this object. *
  633. * *
  634. * OUTPUT: Returns the success value of the attempt: *
  635. * 0: Object could not be placed -- ever *
  636. * 1: Object placement is temporarily delayed -- try again later. *
  637. * 2: Object placement proceeded normally *
  638. * *
  639. * WARNINGS: none *
  640. * *
  641. * HISTORY: *
  642. * 09/21/1995 JLB : Created. *
  643. *=============================================================================================*/
  644. int ObjectClass::Exit_Object(TechnoClass *)
  645. {
  646. assert(this != 0);
  647. assert(IsActive);
  648. return(0);
  649. }
  650. /***********************************************************************************************
  651. * ObjectClass::Hidden -- Called when this object becomes hidden from the player. *
  652. * *
  653. * This routine is called when the object becomes hidden from the player. It can result in *
  654. * lost targeting and tracking abilities with respect to the hidden object. *
  655. * *
  656. * INPUT: none *
  657. * *
  658. * OUTPUT: none *
  659. * *
  660. * WARNINGS: none *
  661. * *
  662. * HISTORY: *
  663. * 09/21/1995 JLB : Created. *
  664. *=============================================================================================*/
  665. void ObjectClass::Hidden(void)
  666. {
  667. assert(this != 0);
  668. assert(IsActive);
  669. }
  670. /***********************************************************************************************
  671. * ObjectClass::Look -- Called when this object needs to reveal terrain. *
  672. * *
  673. * This routine is called when the object needs to look around the terrain. For player *
  674. * owned objects, the terrain is revealed. For non-player objects, not effect occurs. *
  675. * *
  676. * INPUT: incremental -- If true, then the looking algorithm will only examine the edges *
  677. * of the sight range. This is more efficient and work well if the *
  678. * object has only moved one cell since the last time it has performed *
  679. * the look operation. *
  680. * *
  681. * OUTPUT: none *
  682. * *
  683. * WARNINGS: This can be a time consuming operation. Call only when necessary. *
  684. * *
  685. * HISTORY: *
  686. * 09/21/1995 JLB : Created. *
  687. *=============================================================================================*/
  688. void ObjectClass::Look(bool )
  689. {
  690. assert(this != 0);
  691. assert(IsActive);
  692. }
  693. /***********************************************************************************************
  694. * ObjectClass::Active_Click_With -- Dispatches action on the object specified. *
  695. * *
  696. * This routine is called when this object is selected and the mouse was clicked on the *
  697. * tactical map. An action is required from the object. The object that the mouse was *
  698. * over and the tentative action to perform are provided as parameters. *
  699. * *
  700. * INPUT: action -- The requested action to perform with the object specified. *
  701. * *
  702. * object -- The object that the action should be performed on. This object is *
  703. * what the mouse was over when the click occurred. *
  704. * *
  705. * OUTPUT: none *
  706. * *
  707. * WARNINGS: none *
  708. * *
  709. * HISTORY: *
  710. * 09/21/1995 JLB : Created. *
  711. *=============================================================================================*/
  712. void ObjectClass::Active_Click_With(ActionType , ObjectClass *)
  713. {
  714. assert(this != 0);
  715. assert(IsActive);
  716. }
  717. /***********************************************************************************************
  718. * ObjectClass::Active_Click_With -- Dispatches action on the specified cell. *
  719. * *
  720. * This routine will dispatch the action requested upon the cell specified. It is called *
  721. * when the mouse is clicked over a cell while this object is selected. *
  722. * *
  723. * INPUT: action -- The action to perform. *
  724. * *
  725. * cell -- The location (cell) to perform this action upon. *
  726. * *
  727. * OUTPUT: none *
  728. * *
  729. * WARNINGS: none *
  730. * *
  731. * HISTORY: *
  732. * 09/21/1995 JLB : Created. *
  733. *=============================================================================================*/
  734. void ObjectClass::Active_Click_With(ActionType , CELL )
  735. {
  736. assert(this != 0);
  737. assert(IsActive);
  738. }
  739. /***********************************************************************************************
  740. * ObjectClass::Clicked_As_Target -- Triggers target selection animation. *
  741. * *
  742. * This routine is called when this object is the target of some player click action. *
  743. * For more sophisticated object, this will trigger the object to begin flashing a few *
  744. * times. At this level, no action is performed. *
  745. * *
  746. * INPUT: flashes -- The requested number of times to flash this object. *
  747. * *
  748. * OUTPUT: none *
  749. * *
  750. * WARNINGS: none *
  751. * *
  752. * HISTORY: *
  753. * 09/21/1995 JLB : Created. *
  754. *=============================================================================================*/
  755. void ObjectClass::Clicked_As_Target(HousesType house, int) // 2019/09/20 JAS - Added record of who clicked on the object
  756. {
  757. assert(this != 0);
  758. assert(IsActive);
  759. }
  760. /***********************************************************************************************
  761. * ObjectClass::In_Range -- Determines if the coordinate is within weapon range. *
  762. * *
  763. * This routine will determine if the specified coordinate is within weapon range. *
  764. * *
  765. * INPUT: coord -- The coordinate to check to see if it is within weapon range. *
  766. * *
  767. * which -- The weapon to check against. *
  768. * 0: primary weapon *
  769. * 1: secondary weapon *
  770. * *
  771. * OUTPUT: bool; Is the specified coordinate within weapon range for the weapon type *
  772. * specified? *
  773. * *
  774. * WARNINGS: none *
  775. * *
  776. * HISTORY: *
  777. * 09/21/1995 JLB : Created. *
  778. *=============================================================================================*/
  779. bool ObjectClass::In_Range(COORDINATE , int) const
  780. {
  781. assert(this != 0);
  782. assert(IsActive);
  783. return(false);
  784. }
  785. /***********************************************************************************************
  786. * ObjectClass::Weapon_Range -- Returns the weapon range for the weapon specified. *
  787. * *
  788. * This routine will return the weapon range according to the type of weapon specified. *
  789. * *
  790. * INPUT: which -- The weapon to fetch the range from. *
  791. * 0: primary weapon *
  792. * 1: secondary weapon *
  793. * *
  794. * OUTPUT: Returns with the range (in leptons) of the weapon specified. *
  795. * *
  796. * WARNINGS: none *
  797. * *
  798. * HISTORY: *
  799. * 09/21/1995 JLB : Created. *
  800. *=============================================================================================*/
  801. int ObjectClass::Weapon_Range(int) const
  802. {
  803. assert(this != 0);
  804. assert(IsActive);
  805. return(0);
  806. }
  807. /***********************************************************************************************
  808. * ObjectClass::Scatter -- Tries to scatter this object. *
  809. * *
  810. * This routine is used when the object should scatter from its current location. It *
  811. * applies to units that have the ability to move. *
  812. * *
  813. * INPUT: coord -- The source of the threat that is causing the scatter. *
  814. * *
  815. * forced-- Whether this scatter attempt is serious and scattering should occur *
  816. * regardless of what is doing now. *
  817. * *
  818. * OUTPUT: none *
  819. * *
  820. * WARNINGS: This may or may not cause the object to scatter. It is merely a request to the *
  821. * object that it would be good if it were to scatter. *
  822. * *
  823. * HISTORY: *
  824. * 09/21/1995 JLB : Created. *
  825. *=============================================================================================*/
  826. void ObjectClass::Scatter(COORDINATE , bool, bool)
  827. {
  828. assert(this != 0);
  829. assert(IsActive);
  830. }
  831. /***********************************************************************************************
  832. * ObjectClass::Catch_Fire -- Called when animation is attached to this object. *
  833. * *
  834. * This routine is called when an animation is attached to this object. It might be a *
  835. * fire animation (hence the name), but it might also be smoke or any other animation *
  836. * as well. *
  837. * *
  838. * INPUT: none *
  839. * *
  840. * OUTPUT: bool; Was the object caught on fire by this routine? Actually, this is really *
  841. * the answer to this question; "Is this animation attaching to this object *
  842. * that doesn't already have an animation attached?" *
  843. * *
  844. * WARNINGS: none *
  845. * *
  846. * HISTORY: *
  847. * 09/21/1995 JLB : Created. *
  848. *=============================================================================================*/
  849. bool ObjectClass::Catch_Fire(void)
  850. {
  851. assert(this != 0);
  852. assert(IsActive);
  853. return false;
  854. }
  855. /***********************************************************************************************
  856. * ObjectClass::Fire_Out -- Informs object that attached animation has finished. *
  857. * *
  858. * This routine is called if there is an attached animation on this object and that *
  859. * animation has finished. Typically, this is necessary for when trees are on fire. *
  860. * *
  861. * INPUT: none *
  862. * *
  863. * OUTPUT: none *
  864. * *
  865. * WARNINGS: none *
  866. * *
  867. * HISTORY: *
  868. * 07/24/1995 JLB : Created. *
  869. *=============================================================================================*/
  870. void ObjectClass::Fire_Out(void)
  871. {
  872. assert(this != 0);
  873. assert(IsActive);
  874. }
  875. /***********************************************************************************************
  876. * ObjectClass::Value -- Fetches the target value of this object. *
  877. * *
  878. * This routine will return the target value of this object. The higher the number, the *
  879. * better the object will be as a target. This routine is called when searching for *
  880. * targets. Generic objects have no target potential, and this routine returns zero to *
  881. * reflect that. Other object types will override this routine to return the appropriate *
  882. * target value. *
  883. * *
  884. * INPUT: none *
  885. * *
  886. * OUTPUT: Returns with the value of this object as a target. Higher values mean better *
  887. * target. *
  888. * *
  889. * WARNINGS: none *
  890. * *
  891. * HISTORY: *
  892. * 07/24/1995 JLB : Created. *
  893. *=============================================================================================*/
  894. int ObjectClass::Value(void) const
  895. {
  896. assert(this != 0);
  897. assert(IsActive);
  898. return(0);
  899. }
  900. /***********************************************************************************************
  901. * ObjectClass::Get_Mission -- Fetches the current mission of this object. *
  902. * *
  903. * Generic objects don't have a mission, so this routine will just return MISSION_NONE. *
  904. * However, techno objects do have a mission and this routine is overloaded to handle *
  905. * those objects in order to return the correct mission value. *
  906. * *
  907. * INPUT: none *
  908. * *
  909. * OUTPUT: Returns with the current mission being followed by this object. *
  910. * *
  911. * WARNINGS: none *
  912. * *
  913. * HISTORY: *
  914. * 07/24/1995 JLB : Created. *
  915. *=============================================================================================*/
  916. MissionType ObjectClass::Get_Mission(void) const
  917. {
  918. assert(this != 0);
  919. assert(IsActive);
  920. return(MISSION_NONE);
  921. }
  922. /***********************************************************************************************
  923. * ObjectClass::Repair -- Handles object repair control. *
  924. * *
  925. * This routine will control object repair mode. At the object level, no repair is *
  926. * possible, so it is expected that any object that can repair will override this function *
  927. * as necessary. *
  928. * *
  929. * INPUT: control -- The repair control parameter. *
  930. * 0 = turn repair off *
  931. * 1 = turn repair on *
  932. * -1 = toggle repair state *
  933. * *
  934. * OUTPUT: none *
  935. * *
  936. * WARNINGS: none *
  937. * *
  938. * HISTORY: *
  939. * 07/24/1995 JLB : Created. *
  940. *=============================================================================================*/
  941. void ObjectClass::Repair(int )
  942. {
  943. assert(this != 0);
  944. assert(IsActive);
  945. }
  946. /***********************************************************************************************
  947. * ObjectClass::Sell_Back -- Sells the object -- if possible. *
  948. * *
  949. * This routine is called to sell back the object. Override this routine for the more *
  950. * sophisticated objects that can actually be sold back. Normal objects can't be sold and *
  951. * this routine does nothing as a consequence. *
  952. * *
  953. * INPUT: control -- How to control the sell state of this object. *
  954. * 0 = stop selling. *
  955. * 1 = start selling. *
  956. * -1 = toggle selling state. *
  957. * *
  958. * OUTPUT: none *
  959. * *
  960. * WARNINGS: none *
  961. * *
  962. * HISTORY: *
  963. * 07/19/1995 JLB : Created. *
  964. *=============================================================================================*/
  965. void ObjectClass::Sell_Back(int )
  966. {
  967. assert(this != 0);
  968. assert(IsActive);
  969. }
  970. /***********************************************************************************************
  971. * ObjectClass::Move -- Moves (by force) the object in the desired direction. *
  972. * *
  973. * This routine will instantly move the object one cell in the specified direction. It *
  974. * moves the object by force. This is typically ONLY used by the scenario editor *
  975. * process. *
  976. * *
  977. * INPUT: facing -- The direction to move the object. *
  978. * *
  979. * OUTPUT: none *
  980. * *
  981. * WARNINGS: Naturally, this can cause illegal placement situations -- use with caution. *
  982. * *
  983. * HISTORY: *
  984. * 06/19/1994 JLB : Created. *
  985. *=============================================================================================*/
  986. void ObjectClass::Move(FacingType facing)
  987. {
  988. assert(this != 0);
  989. assert(IsActive);
  990. COORDINATE coord;
  991. Mark(MARK_UP);
  992. coord = Adjacent_Cell(Coord, facing);
  993. if (Can_Enter_Cell(Coord_Cell(coord)) == MOVE_OK) {
  994. Coord = coord;
  995. }
  996. Mark(MARK_DOWN);
  997. }
  998. // Object selection list is switched with player context for GlyphX. ST - 4/17/2019 9:42AM
  999. extern void Logic_Switch_Player_Context(ObjectClass *object);
  1000. /***********************************************************************************************
  1001. * ObjectClass::Unselect -- This will un-select the object if it was selected. *
  1002. * *
  1003. * This routine brings a currently selected object into an unselected state. This is *
  1004. * needed when another object becomes selected as well as if the object is destroyed. *
  1005. * *
  1006. * INPUT: none *
  1007. * *
  1008. * OUTPUT: none *
  1009. * *
  1010. * WARNINGS: none *
  1011. * *
  1012. * HISTORY: *
  1013. * 06/19/1994 JLB : Created. *
  1014. *=============================================================================================*/
  1015. void ObjectClass::Unselect(void)
  1016. {
  1017. assert(this != 0);
  1018. assert(IsActive);
  1019. //if (IsSelected) {
  1020. // Updated to function for multiplayer - 6/26/2019 JAS
  1021. if (Is_Selected_By_Player()) {
  1022. if (In_Which_Layer() == LAYER_GROUND) Mark(MARK_OVERLAP_UP);
  1023. IsSelected = false;
  1024. // Updated to function for multiplayer - 6/26/2019 JAS
  1025. Set_Unselected_By_Player();
  1026. if (In_Which_Layer() == LAYER_GROUND) Mark(MARK_OVERLAP_DOWN);
  1027. }
  1028. }
  1029. /***********************************************************************************************
  1030. * ObjectClass::Unselect_All_Players -- This will un-select the object if it was selected *
  1031. * from all players *
  1032. * *
  1033. * This routine brings a currently selected object into an unselected state for all players.*
  1034. * This is needed when the object is destroyed. *
  1035. * *
  1036. * INPUT: none *
  1037. * *
  1038. * OUTPUT: none *
  1039. * *
  1040. * WARNINGS: none *
  1041. * *
  1042. * HISTORY: *
  1043. * 06/25/2019 JAS : Created. *
  1044. *=============================================================================================*/
  1045. void ObjectClass::Unselect_All_Players(void)
  1046. {
  1047. CurrentObject.Delete_All(this);
  1048. if (In_Which_Layer() == LAYER_GROUND) {
  1049. Mark(MARK_OVERLAP_UP);
  1050. }
  1051. IsSelected = false;
  1052. IsSelectedMask = 0;
  1053. if (In_Which_Layer() == LAYER_GROUND) {
  1054. Mark(MARK_OVERLAP_DOWN);
  1055. }
  1056. }
  1057. /***********************************************************************************************
  1058. * ObjectClass::Unselect_All_Players_Except_Owner -- This will un-select the object if it was *
  1059. * selected for all players except for the object's owner *
  1060. * *
  1061. * This routine brings a currently selected object into an unselected state for all players.*
  1062. * This is needed when the object cloaks. *
  1063. * *
  1064. * INPUT: none *
  1065. * *
  1066. * OUTPUT: none *
  1067. * *
  1068. * WARNINGS: none *
  1069. * *
  1070. * HISTORY: *
  1071. * 06/28/2019 JAS : Created. *
  1072. *=============================================================================================*/
  1073. void ObjectClass::Unselect_All_Players_Except_Owner(void)
  1074. {
  1075. CurrentObject.Delete_All_Except(this, Owner());
  1076. if (In_Which_Layer() == LAYER_GROUND) {
  1077. Mark(MARK_OVERLAP_UP);
  1078. }
  1079. int owner_mask = 1 << Owner();
  1080. if (IsSelectedMask & owner_mask)
  1081. {
  1082. IsSelected = true;
  1083. IsSelectedMask = owner_mask;
  1084. }
  1085. else
  1086. {
  1087. IsSelected = false;
  1088. IsSelectedMask = 0;
  1089. }
  1090. if (In_Which_Layer() == LAYER_GROUND) {
  1091. Mark(MARK_OVERLAP_DOWN);
  1092. }
  1093. }
  1094. /***********************************************************************************************
  1095. * ObjectClass::Select -- Try to make this object the "selected" object. *
  1096. * *
  1097. * This routine is used to make this object into the one that is "selected". A selected *
  1098. * object usually displays a floating bar graph and is available to be given orders from *
  1099. * the player's I/O. *
  1100. * *
  1101. * INPUT: allow_mixed -- Allow a mix of player and non-player controlled units? *
  1102. * *
  1103. * OUTPUT: none *
  1104. * *
  1105. * WARNINGS: none *
  1106. * *
  1107. * HISTORY: *
  1108. * 06/19/1994 JLB : Created. *
  1109. * 06/12/1995 JLB : Cannot select a loaner object. *
  1110. * 07/23/1995 JLB : Adds to head or tail depending on leader type flag. *
  1111. *=============================================================================================*/
  1112. bool ObjectClass::Select(bool allow_mixed)
  1113. {
  1114. assert(this != 0);
  1115. assert(IsActive);
  1116. //if (!Debug_Map && (IsSelected || !Class_Of().IsSelectable)) {
  1117. // return(false);
  1118. //}
  1119. // Updated to function for multiplayer - 6/26/2019 JAS
  1120. if (!Debug_Map && (Is_Selected_By_Player() || !Class_Of().IsSelectable)) {
  1121. return(false);
  1122. }
  1123. if (!Debug_Map && Can_Player_Move() && Is_Techno() && ((TechnoClass *)this)->IsALoaner) {
  1124. return(false);
  1125. }
  1126. /*
  1127. ** Don't allow selection if the object is still in the air.
  1128. */
  1129. if (Height > 0 && (What_Am_I() == RTTI_UNIT || What_Am_I() == RTTI_VESSEL || What_Am_I() == RTTI_INFANTRY)) {
  1130. return(false);
  1131. }
  1132. /*
  1133. ** Don't allow selection of object when in building placement mode.
  1134. */
  1135. if (Map.PendingObject) {
  1136. return(false);
  1137. }
  1138. if (!allow_mixed) {
  1139. /*
  1140. ** If selecting an object of a different house than the player's, make sure that
  1141. ** the entire selection list is cleared.
  1142. */
  1143. for (int i = 0; i < CurrentObject.Count(); i++) {
  1144. HouseClass * tryhptr = HouseClass::As_Pointer(Owner());
  1145. HouseClass * oldhptr = HouseClass::As_Pointer(CurrentObject[i]->Owner());
  1146. // if (Owner() != CurrentObject[0]->Owner() || CurrentObject[0]->Owner() != PlayerPtr->Class->House) {
  1147. if (oldhptr->IsPlayerControl != tryhptr->IsPlayerControl) {
  1148. Unselect_All();
  1149. break;
  1150. }
  1151. }
  1152. }
  1153. if (In_Which_Layer() == LAYER_GROUND) Mark(MARK_OVERLAP_UP);
  1154. //IsSelected = true;
  1155. // Updated to function for multiplayer - 6/26/2019 JAS
  1156. Set_Selected_By_Player();
  1157. if (In_Which_Layer() == LAYER_GROUND) Mark(MARK_OVERLAP_DOWN);
  1158. return(true);
  1159. }
  1160. /***********************************************************************************************
  1161. * ObjectClass::Render -- Displays the object onto the map. *
  1162. * *
  1163. * This routine will determine the location of the object and if it is roughly on the *
  1164. * visible screen, it will display it. Not displaying objects that are not on the screen *
  1165. * will save valuable time. *
  1166. * *
  1167. * INPUT: bool; Should the render be forced regardless of whether the object is flagged to *
  1168. * be redrawn? *
  1169. * *
  1170. * OUTPUT: bool; Was the draw code called for this object? *
  1171. * *
  1172. * WARNINGS: none *
  1173. * *
  1174. * HISTORY: *
  1175. * 06/19/1994 JLB : Created. *
  1176. *=============================================================================================*/
  1177. bool ObjectClass::Render(bool forced) const
  1178. {
  1179. assert(this != 0);
  1180. assert(IsActive);
  1181. int x, y;
  1182. COORDINATE coord = Render_Coord();
  1183. CELL cell = Coord_Cell(coord);
  1184. if (Debug_Map || Debug_Unshroud || ((forced || IsToDisplay) && IsDown && !IsInLimbo)) {
  1185. const_cast<ObjectClass*>(this)->IsToDisplay = false; // added const_cast ST - 5/9/2019
  1186. if (Map.Coord_To_Pixel(coord, x, y)) {
  1187. /*
  1188. ** Draw the object itself
  1189. */
  1190. Draw_It(x, y, WINDOW_TACTICAL);
  1191. #ifdef SCENARIO_EDITOR
  1192. /*
  1193. ** Draw the trigger attached to the object. Draw_It is window-
  1194. ** relative, so add the window's x-coord to 'x'.
  1195. */
  1196. if (Debug_Map && Trigger.Is_Valid()) {
  1197. Fancy_Text_Print(Trigger->Class->IniName,
  1198. x + (WinX), y,
  1199. &ColorRemaps[PCOLOR_RED], TBLACK,
  1200. TPF_CENTER | TPF_NOSHADOW | TPF_6POINT);
  1201. }
  1202. #endif
  1203. return(true);
  1204. }
  1205. }
  1206. return(false);
  1207. }
  1208. #ifdef CHEAT_KEYS
  1209. /***********************************************************************************************
  1210. * ObjectClass::Debug_Dump -- Displays status of the object class to the mono monitor. *
  1211. * *
  1212. * This routine is used to display the current status of the object class to the mono *
  1213. * monitor. *
  1214. * *
  1215. * INPUT: none *
  1216. * *
  1217. * OUTPUT: none *
  1218. * *
  1219. * WARNINGS: none *
  1220. * *
  1221. * HISTORY: *
  1222. * 06/02/1994 JLB : Created. *
  1223. *=============================================================================================*/
  1224. void ObjectClass::Debug_Dump(MonoClass * mono) const
  1225. {
  1226. mono->Set_Cursor(1, 1);mono->Printf("%-18.18s", Text_String(Full_Name()));
  1227. if (Next != NULL) {
  1228. mono->Set_Cursor(20, 5);mono->Printf("%08X", Next->As_Target());
  1229. }
  1230. if (Trigger.Is_Valid()) {
  1231. mono->Text_Print(Trigger->Class->IniName, 11, 3);
  1232. }
  1233. mono->Set_Cursor(34, 1);mono->Printf("%3d", Strength);
  1234. mono->Fill_Attrib(1, 13, 12, 1, IsDown ? MonoClass::INVERSE : MonoClass::NORMAL);
  1235. mono->Fill_Attrib(1, 14, 12, 1, IsToDamage ? MonoClass::INVERSE : MonoClass::NORMAL);
  1236. mono->Fill_Attrib(1, 15, 12, 1, IsToDisplay ? MonoClass::INVERSE : MonoClass::NORMAL);
  1237. mono->Fill_Attrib(1, 16, 12, 1, IsInLimbo ? MonoClass::INVERSE : MonoClass::NORMAL);
  1238. // Updated to function for multiplayer - 6/26/2019 JAS
  1239. mono->Fill_Attrib(1, 17, 12, 1, Is_Selected_By_Player() ? MonoClass::INVERSE : MonoClass::NORMAL);
  1240. mono->Fill_Attrib(14, 13, 12, 1, IsAnimAttached ? MonoClass::INVERSE : MonoClass::NORMAL);
  1241. mono->Set_Cursor(23, 14);mono->Printf("%d", Riser);
  1242. mono->Fill_Attrib(14, 12, 14, 1, IsFalling ? MonoClass::INVERSE : MonoClass::NORMAL);
  1243. AbstractClass::Debug_Dump(mono);
  1244. }
  1245. #endif
  1246. /***********************************************************************************************
  1247. * ObjectClass::Mark_For_Redraw -- Marks object and system for redraw. *
  1248. * *
  1249. * This routine will mark the object and inform the display system *
  1250. * that appropriate rendering is needed. Whenever it is determined *
  1251. * that an object needs to be redrawn, call this routine. *
  1252. * *
  1253. * INPUT: none *
  1254. * *
  1255. * OUTPUT: none *
  1256. * *
  1257. * WARNINGS: This is a subordinate function to the function Mark(). If an object needs to *
  1258. * be redrawn it is probably better to call the function Mark(MARK_CHANGE) rather *
  1259. * than this function. This function does not inform the map system that *
  1260. * overlapping objects are to be redrawn and thus unless you are really sure that *
  1261. * this routine should be called, don't. *
  1262. * *
  1263. * HISTORY: *
  1264. * 05/08/1994 JLB : Created. *
  1265. * 12/23/1994 JLB : Flags map and flags unit only. *
  1266. *=============================================================================================*/
  1267. void ObjectClass::Mark_For_Redraw(void)
  1268. {
  1269. assert(this != 0);
  1270. assert(IsActive);
  1271. if (!IsToDisplay) {
  1272. IsToDisplay = true;
  1273. /*
  1274. ** This tells the map rendering logic to "go through the motions" and call the
  1275. ** rendering function. In the rendering function, it will sort out what gets
  1276. ** rendered and what doesn't.
  1277. */
  1278. Map.Flag_To_Redraw(false);
  1279. }
  1280. }
  1281. /***********************************************************************************************
  1282. * ObjectClass::Limbo -- Brings the object into a state of limbo. *
  1283. * *
  1284. * An object brought into a state of limbo by this routine can be safely deleted. This *
  1285. * routine will remove the object from all game lists and tracking systems. It is called *
  1286. * prior to deleting the object or placing the object "on ice". *
  1287. * *
  1288. * INPUT: none *
  1289. * *
  1290. * OUTPUT: bool; Was the object successfully placed in limbo? *
  1291. * *
  1292. * WARNINGS: none *
  1293. * *
  1294. * HISTORY: *
  1295. * 09/24/1994 JLB : Created. *
  1296. *=============================================================================================*/
  1297. bool ObjectClass::Limbo(void)
  1298. {
  1299. assert(this != 0);
  1300. assert(IsActive);
  1301. if (GameActive && !IsInLimbo) {
  1302. //Unselect();
  1303. // Updated to function for multiplayer - 6/26/2019 JAS
  1304. Unselect_All_Players();
  1305. Detach_All();
  1306. Mark(MARK_UP);
  1307. /*
  1308. ** Remove the object from the appropriate display list.
  1309. */
  1310. Map.Remove(this, In_Which_Layer());
  1311. /*
  1312. ** Remove the object from the logic processing list.
  1313. */
  1314. if (Class_Of().IsSentient) {
  1315. Logic.Delete(this);
  1316. }
  1317. Hidden();
  1318. IsInLimbo = true;
  1319. IsToDisplay = false;
  1320. return(true);
  1321. }
  1322. return(false);
  1323. }
  1324. /***********************************************************************************************
  1325. * ObjectClass::Unlimbo -- Brings the object into the game system. *
  1326. * *
  1327. * This routine will place the object into the game tracking and display systems. It is *
  1328. * called as a consequence of creating the object. Every game object must be unlimboed at *
  1329. * some point. *
  1330. * *
  1331. * INPUT: coord -- The coordinate to place the object into the game system. *
  1332. * *
  1333. * dir (optional) -- initial facing direction for this object *
  1334. * *
  1335. * OUTPUT: bool; Was the game object successfully unlimboed? *
  1336. * *
  1337. * WARNINGS: none *
  1338. * *
  1339. * HISTORY: *
  1340. * 09/24/1994 JLB : Created. *
  1341. * 12/23/1994 JLB : Sets object strength. *
  1342. *=============================================================================================*/
  1343. bool ObjectClass::Unlimbo(COORDINATE coord, DirType )
  1344. {
  1345. assert(this != 0);
  1346. assert(IsActive);
  1347. if (GameActive && IsInLimbo && !IsDown) {
  1348. if (ScenarioInit || Can_Enter_Cell(Coord_Cell(coord), FACING_NONE) == MOVE_OK) {
  1349. IsInLimbo = false;
  1350. IsToDisplay = false;
  1351. Coord = Class_Of().Coord_Fixup(coord);
  1352. if (Mark(MARK_DOWN)) {
  1353. if (IsActive) {
  1354. /*
  1355. ** Add the object to the appropriate map layer. This layer is used
  1356. ** for rendering purposes.
  1357. */
  1358. if (In_Which_Layer() != LAYER_NONE) {
  1359. Map.Submit(this, In_Which_Layer());
  1360. }
  1361. if (Class_Of().IsSentient) {
  1362. Logic.Submit(this);
  1363. }
  1364. }
  1365. return(true);
  1366. }
  1367. }
  1368. }
  1369. return(false);
  1370. }
  1371. /***********************************************************************************************
  1372. * ObjectClass::Detach -- Detach the specified target from this object. *
  1373. * *
  1374. * This routine is called when the object (as specified) is to be removed from the game *
  1375. * engine and thus, all references to it must be severed. Typically, the only thing *
  1376. * checked for at this level is the attached trigger. *
  1377. * *
  1378. * INPUT: target -- The target that will be removed from the game system. *
  1379. * *
  1380. * OUTPUT: none *
  1381. * *
  1382. * WARNINGS: none *
  1383. * *
  1384. * HISTORY: *
  1385. * 07/29/1996 JLB : Created. *
  1386. *=============================================================================================*/
  1387. void ObjectClass::Detach(TARGET target, bool )
  1388. {
  1389. if (Trigger.Is_Valid() && Is_Target_Trigger(target) && Trigger->As_Target() == target) {
  1390. Attach_Trigger(NULL);
  1391. }
  1392. }
  1393. /***********************************************************************************************
  1394. * ObjectClass::Detach_All -- Removes the object from all tracking systems. *
  1395. * *
  1396. * This routine will take the object and see that it is removed from all miscellaneous *
  1397. * tracking systems in the game. This operation is vital when deleting an object. It is *
  1398. * necessary so that when the object is removed from the game, existing game objects won't *
  1399. * be referencing a now invalid game object. This typically affects the targeting *
  1400. * and navigation computers of other game objects. *
  1401. * *
  1402. * INPUT: none *
  1403. * *
  1404. * OUTPUT: none *
  1405. * *
  1406. * WARNINGS: none *
  1407. * *
  1408. * HISTORY: *
  1409. * 09/24/1994 JLB : Created. *
  1410. *=============================================================================================*/
  1411. void ObjectClass::Detach_All(bool all)
  1412. {
  1413. assert(this != 0);
  1414. assert(IsActive);
  1415. /*
  1416. ** Unselect this object if it was selected.
  1417. */
  1418. //if (all || Owner() != PlayerPtr->Class->House) {
  1419. // Unselect();
  1420. //}
  1421. //Added some error handling incase there was an issue removing the object - JAS 6/28/2019
  1422. if (all) {
  1423. //Unselect();
  1424. // Updated to function for multiplayer - 6/28/2019 JAS
  1425. Unselect_All_Players();
  1426. }
  1427. else
  1428. {
  1429. Unselect_All_Players_Except_Owner();
  1430. }
  1431. //End of change - JAS 6/28/2019
  1432. Map.Detach(this);
  1433. /*
  1434. ** Remove from targeting computers.
  1435. */
  1436. Detach_This_From_All(As_Target(), all);
  1437. }
  1438. /***********************************************************************************************
  1439. * ObjectClass::Receive_Message -- Processes an incoming radio message. *
  1440. * *
  1441. * Any radio message received that applies to objects in general are handled by this *
  1442. * routine. Typically, this is the "redraw" message, which occurs when another object is *
  1443. * loading or unloading and thus overlapping. *
  1444. * *
  1445. * INPUT: message -- The message received. *
  1446. * *
  1447. * OUTPUT: Returns with the appropriate radio response. If the message was recognized, then *
  1448. * RADIO_ROGER is returned, otherwise, just RADIO_STATIC is returned. *
  1449. * *
  1450. * WARNINGS: none *
  1451. * *
  1452. * HISTORY: *
  1453. * 09/24/1994 JLB : Created. *
  1454. *=============================================================================================*/
  1455. RadioMessageType ObjectClass::Receive_Message(RadioClass *, RadioMessageType message, long & )
  1456. {
  1457. assert(this != 0);
  1458. assert(IsActive);
  1459. switch (message) {
  1460. /*
  1461. ** This message serves as a rendering convenience. It lets the system
  1462. ** know that there might be a visual conflict and the unit in radio
  1463. ** contact should be redrawn. This typically occurs when a vehicle
  1464. ** is being unloaded from a hover lander.
  1465. */
  1466. case RADIO_REDRAW:
  1467. Mark(MARK_CHANGE);
  1468. return(RADIO_ROGER);
  1469. default:
  1470. break;
  1471. }
  1472. return(RADIO_STATIC);
  1473. }
  1474. /***********************************************************************************************
  1475. * ObjectClass::Take_Damage -- Applies damage to the object. *
  1476. * *
  1477. * This routine applies damage to the object according to the damage parameters. It handles *
  1478. * reducing the strength of the object and also returns the result of that damage. The *
  1479. * result value can be examined to determine if the object was destroyed, greatly damaged, *
  1480. * or other results. *
  1481. * *
  1482. * INPUT: damage -- Reference to the damage number to apply. This number will be adjusted *
  1483. * according to defensive armor and distance. Examine this value after *
  1484. * the call to determine the actual amount of damage applied. *
  1485. * *
  1486. * distance -- The distance (in leptons) from the center of the damage causing *
  1487. * explosion to the object itself. *
  1488. * *
  1489. * warhead -- The warhead type that is causing the damage. *
  1490. * *
  1491. * source -- The perpetrator of this damage. *
  1492. * *
  1493. * forced -- Is the damage forced upon the object regardless of whether it *
  1494. * is normally immune? *
  1495. * *
  1496. * OUTPUT: Returns the ResultType that indicates what the affect of the damage was. *
  1497. * *
  1498. * WARNINGS: none *
  1499. * *
  1500. * HISTORY: *
  1501. * 11/29/1994 JLB : Created. *
  1502. * 12/27/1994 JLB : Trigger event processing for attacked or destroyed. *
  1503. * 01/01/1995 JLB : Reduces damage greatly depending on range. *
  1504. *=============================================================================================*/
  1505. ResultType ObjectClass::Take_Damage(int & damage, int distance, WarheadType warhead, TechnoClass * source, bool forced)
  1506. {
  1507. assert(this != 0);
  1508. assert(IsActive);
  1509. ResultType result = RESULT_NONE;
  1510. int oldstrength = Strength;
  1511. if (oldstrength && damage != 0 && (forced || !Class_Of().IsImmune)) {
  1512. int maxstrength = Class_Of().MaxStrength;
  1513. /*
  1514. ** Modify damage based on the warhead type and the armor of the object. This results
  1515. ** in a reduced damage value, but never below 1 damage point. Unless
  1516. ** it's forced damage, in which case we want full damage.
  1517. */
  1518. if (!forced /*&& damage > 0*/) {
  1519. damage = Modify_Damage(damage, warhead, Class_Of().Armor, distance);
  1520. /*
  1521. ** Special hack to ensure that dogs only do damage to intended victim and no
  1522. ** damage to others.
  1523. */
  1524. if (source && source->What_Am_I() == RTTI_INFANTRY && ((InfantryClass *)source)->Class->IsDog) {
  1525. if (source->TarCom == As_Target()) {
  1526. damage = Strength;
  1527. } else {
  1528. damage = 0;
  1529. }
  1530. }
  1531. }
  1532. if (damage == 0) return(RESULT_NONE);
  1533. /*
  1534. ** Are we healing/repairing? If so, add strength, but in
  1535. ** any case, return that no damage was done.
  1536. */
  1537. if (damage < 0) {
  1538. #ifdef FIXIT_CSII // checked - ajw 9/28/98
  1539. if (What_Am_I() == RTTI_INFANTRY || What_Am_I() == RTTI_UNIT || What_Am_I() == RTTI_AIRCRAFT) {
  1540. #else
  1541. if (What_Am_I() == RTTI_INFANTRY) {
  1542. #endif
  1543. Clicked_As_Target(PlayerPtr->Class->House, 7); // 2019/09/20 JAS - Added record of who clicked on the object
  1544. Strength -= damage;
  1545. if (Strength > maxstrength) {
  1546. Strength = maxstrength;
  1547. }
  1548. }
  1549. return(RESULT_NONE);
  1550. }
  1551. /*
  1552. ** At this point, we KNOW that at least light damage has occurred.
  1553. */
  1554. result = RESULT_LIGHT;
  1555. /*
  1556. ** A non-fatal blow has occurred. Check to see if the object transitioned to below
  1557. ** half strength or if it is now down to one hit point.
  1558. */
  1559. if (oldstrength > damage) {
  1560. if (oldstrength >= (maxstrength >> 1) && (oldstrength-damage) < (maxstrength >> 1)) {
  1561. result = RESULT_HALF;
  1562. }
  1563. } else {
  1564. /*
  1565. ** When an object is damaged to destruction, it will instead stop at one
  1566. ** damage point. This will prolong the damage state as well as
  1567. ** give greater satisfaction when it is finally destroyed.
  1568. */
  1569. damage = oldstrength;
  1570. }
  1571. /*
  1572. ** Apply the damage to the object.
  1573. */
  1574. Strength = oldstrength - damage;
  1575. /*
  1576. ** Check to see if the object is majorly damaged or destroyed.
  1577. */
  1578. switch (Strength) {
  1579. case 0:
  1580. Record_The_Kill(source);
  1581. result = RESULT_DESTROYED;
  1582. if (this->Is_Techno()) {
  1583. if (this == ::As_Object(((TechnoClass *)this)->House->UnitToTeleport)) ((TechnoClass *)this)->House->UnitToTeleport = 0;
  1584. }
  1585. Detach_All();
  1586. break;
  1587. case 1:
  1588. result = RESULT_MAJOR;
  1589. break;
  1590. default:
  1591. break;
  1592. }
  1593. /*
  1594. ** Handle any trigger event associated with this object.
  1595. */
  1596. if (source && Trigger.Is_Valid() && result != RESULT_DESTROYED) {
  1597. Trigger->Spring(TEVENT_ATTACKED, this);
  1598. }
  1599. /*
  1600. ** If any damage was assessed and this object is selected, then flag
  1601. ** the object to be redrawn so that the health bar will be updated.
  1602. */
  1603. //if (result != RESULT_NONE && IsSelected) {
  1604. // Updated to function for multiplayer - 6/26/2019 JAS
  1605. if (result != RESULT_NONE && Is_Selected_By_Player()) {
  1606. Mark(MARK_CHANGE);
  1607. }
  1608. }
  1609. /*
  1610. ** Return with the result of the damage taken.
  1611. */
  1612. return(result);
  1613. }
  1614. /***********************************************************************************************
  1615. * ObjectClass::Mark -- Handles basic marking logic. *
  1616. * *
  1617. * This routine handles the base logic for marking an object up or down on the map. It *
  1618. * manages the IsDown flag as well as flagging the object to be redrawn if necessary. *
  1619. * Whenever an object is to be marked, it should call this base class function first. If *
  1620. * this function returns true, then the higher level function should proceed with its own *
  1621. * logic. *
  1622. * *
  1623. * INPUT: mark -- The marking method to use for this object. It can be either MARK_DOWN, *
  1624. * MARK_UP, or MARK_CHANGE. *
  1625. * *
  1626. * OUTPUT: bool; Was the object marked successfully? *
  1627. * *
  1628. * WARNINGS: none *
  1629. * *
  1630. * HISTORY: *
  1631. * 01/23/1995 JLB : Created. *
  1632. *=============================================================================================*/
  1633. bool ObjectClass::Mark(MarkType mark)
  1634. {
  1635. assert(this != 0);
  1636. assert(IsActive);
  1637. if (!IsInLimbo && IsActive) {
  1638. /*
  1639. ** A mark for change is always successful UNLESS the object
  1640. ** is not placed down or has already been flagged as changed
  1641. ** this game frame.
  1642. */
  1643. if (mark == MARK_CHANGE || mark == MARK_CHANGE_REDRAW) {
  1644. if (IsToDisplay && mark != MARK_CHANGE_REDRAW) return(false);
  1645. if (IsDown) {
  1646. Mark_For_Redraw();
  1647. return(true);
  1648. }
  1649. return(false);
  1650. }
  1651. /*
  1652. ** Handle adding or removing the object in the cells' overlap lists
  1653. */
  1654. if (mark == MARK_OVERLAP_UP) {
  1655. if (IsDown == true) {
  1656. if (Class_Of().IsFootprint) {
  1657. Map.Overlap_Up(Coord_Cell(Coord), this);
  1658. }
  1659. Mark_For_Redraw();
  1660. return(true);
  1661. }
  1662. }
  1663. if (mark == MARK_OVERLAP_DOWN) {
  1664. if (IsDown == true) {
  1665. if (Class_Of().IsFootprint) {
  1666. Map.Overlap_Down(Coord_Cell(Coord), this);
  1667. }
  1668. Mark_For_Redraw();
  1669. return(true);
  1670. }
  1671. }
  1672. /*
  1673. ** It is important to know whether the object is a techno class
  1674. ** or not to see if we have to adjust the regional threat ratings
  1675. */
  1676. int threat = 0;
  1677. HousesType house = HOUSE_NONE;
  1678. CELL cell = 0;
  1679. TechnoClass * tech;
  1680. if (Is_Techno()) {
  1681. tech = (TechnoClass *)this;
  1682. threat = tech->Risk();
  1683. house = tech->Owner();
  1684. cell = Coord_Cell(Coord);
  1685. } else {
  1686. tech = NULL;
  1687. }
  1688. /*
  1689. ** Marking down is only successful if the object isn't already
  1690. ** placed down.
  1691. */
  1692. if (mark == MARK_DOWN && !IsDown) {
  1693. if (tech && Session.Type == GAME_NORMAL && In_Which_Layer() == LAYER_GROUND) {
  1694. Map[cell].Adjust_Threat(house, threat);
  1695. }
  1696. IsDown = true;
  1697. Mark_For_Redraw();
  1698. return(true);
  1699. }
  1700. /*
  1701. ** Lifting up is only successful if the object isn't already
  1702. ** lifted up from the map.
  1703. */
  1704. if (mark == MARK_UP && IsDown) {
  1705. if (tech && Session.Type == GAME_NORMAL && In_Which_Layer() == LAYER_GROUND) {
  1706. Map[cell].Adjust_Threat(house, -threat);
  1707. }
  1708. if (Class_Of().IsFootprint) {
  1709. Map.Overlap_Up(Coord_Cell(Coord), this);
  1710. }
  1711. IsDown = false;
  1712. return(true);
  1713. }
  1714. }
  1715. return(false);
  1716. }
  1717. /***********************************************************************************************
  1718. * ObjectClass::Init -- Initializes the basic object system. *
  1719. * *
  1720. * This routine should be called when the basic object system needs to be initialized. This *
  1721. * occurs when the scenario is about to be loaded. *
  1722. * *
  1723. * INPUT: none *
  1724. * *
  1725. * OUTPUT: none *
  1726. * *
  1727. * WARNINGS: none *
  1728. * *
  1729. * HISTORY: *
  1730. * 01/23/1995 JLB : Created. *
  1731. *=============================================================================================*/
  1732. void ObjectClass::Init(void)
  1733. {
  1734. CurrentObject.Clear_All();
  1735. }
  1736. /***********************************************************************************************
  1737. * ObjectClass::Revealed -- Reveals this object to the house specified. *
  1738. * *
  1739. * This routine is called when this object gets revealed to the house specified. *
  1740. * *
  1741. * INPUT: house -- Pointer to the house that this object is being revealed to. *
  1742. * *
  1743. * OUTPUT: Was this object revealed for the first time to this house? Generic objects always *
  1744. * return true unless an invalid house pointer was specified. *
  1745. * *
  1746. * WARNINGS: none *
  1747. * *
  1748. * HISTORY: *
  1749. * 07/19/1995 JLB : Created. *
  1750. *=============================================================================================*/
  1751. bool ObjectClass::Revealed(HouseClass * house)
  1752. {
  1753. assert(this != 0);
  1754. assert(IsActive);
  1755. return(house != NULL);
  1756. }
  1757. /***********************************************************************************************
  1758. * ObjectClass::Set_Selected_By_Player -- Set this object as selected by the given player or *
  1759. * the default player. *
  1760. * *
  1761. * INPUT: Player pointer *
  1762. * *
  1763. * OUTPUT: *
  1764. * *
  1765. * WARNINGS: none *
  1766. * *
  1767. * HISTORY: *
  1768. * 6/25/2019 - JAS *
  1769. *=============================================================================================*/
  1770. void ObjectClass::Set_Selected_By_Player(HouseClass *player)
  1771. {
  1772. if (!player || !player->Class) {
  1773. player = PlayerPtr;
  1774. }
  1775. HousesType house = player->Class->House;
  1776. if (((TechnoTypeClass const &)Class_Of()).IsLeader) {
  1777. CurrentObject.Add_Head(house, this);
  1778. }
  1779. else {
  1780. CurrentObject.Add(house, this);
  1781. }
  1782. int shift = (int)house;
  1783. IsSelectedMask |= (1 << shift);
  1784. if (Session.Type == GAME_NORMAL && player == PlayerPtr) {
  1785. IsSelected = true;
  1786. }
  1787. }
  1788. /***********************************************************************************************
  1789. * ObjectClass::Set_Unselected_By_Player -- Set this object as unselected by the given player *
  1790. * orthe default player. *
  1791. * *
  1792. * INPUT: Player pointer *
  1793. * *
  1794. * OUTPUT: *
  1795. * *
  1796. * WARNINGS: none *
  1797. * *
  1798. * HISTORY: *
  1799. * 6/25/2019 - JAS *
  1800. *=============================================================================================*/
  1801. void ObjectClass::Set_Unselected_By_Player(HouseClass *player)
  1802. {
  1803. if (!player || !player->Class) {
  1804. player = PlayerPtr;
  1805. }
  1806. HousesType house = player->Class->House;
  1807. CurrentObject.Delete(house, this);
  1808. int shift = (int)house;
  1809. IsSelectedMask &= ~(1 << shift);
  1810. if (Session.Type == GAME_NORMAL && player == PlayerPtr) {
  1811. IsSelected = false;
  1812. }
  1813. }
  1814. /***********************************************************************************************
  1815. * ObjectClass::Is_Selected_By_Player -- Has this object been selected by the given player *
  1816. * *
  1817. * INPUT: Player pointer *
  1818. * *
  1819. * OUTPUT: True if selected by that player *
  1820. * *
  1821. * WARNINGS: none *
  1822. * *
  1823. * HISTORY: *
  1824. * 6/25/2019 - JAS *
  1825. *=============================================================================================*/
  1826. bool ObjectClass::Is_Selected_By_Player(HouseClass *player) const
  1827. {
  1828. if (player && player->Class) {
  1829. int shift = (int)player->Class->House;
  1830. return (IsSelectedMask & (1 << shift)) ? true : false;
  1831. }
  1832. else {
  1833. int shift = (int)PlayerPtr->Class->House;
  1834. return (IsSelectedMask & (1 << shift)) ? true : false;
  1835. }
  1836. return false;
  1837. }
  1838. /***********************************************************************************************
  1839. * ObjectClass::Paradrop -- Unlimbos object in paradrop mode. *
  1840. * *
  1841. * Call this routine as a replacement for Unlimbo() if the object is to be paradropped onto *
  1842. * the playing field. *
  1843. * *
  1844. * INPUT: coord -- The desired landing coordinate to give the dropping unit. *
  1845. * *
  1846. * OUTPUT: bool; Was the object successfully unlimboed and has begun paradropping? *
  1847. * *
  1848. * WARNINGS: The unit may not be successful in paradropping if the desired destination *
  1849. * location cannot be occupied by the object. *
  1850. * *
  1851. * HISTORY: *
  1852. * 02/07/1996 JLB : Created. *
  1853. *=============================================================================================*/
  1854. bool ObjectClass::Paradrop(COORDINATE coord)
  1855. {
  1856. assert(this != 0);
  1857. assert(IsActive);
  1858. Height = FLIGHT_LEVEL;
  1859. IsFalling = true;
  1860. if (Unlimbo(coord, DIR_S)) {
  1861. AnimClass * anim = NULL;
  1862. if (What_Am_I() == RTTI_BULLET) {
  1863. anim = new AnimClass(ANIM_PARA_BOMB, Coord_Move(Center_Coord(), DIR_N, 0x0030 + Height));
  1864. } else {
  1865. anim = new AnimClass(ANIM_PARACHUTE, Coord_Move(Center_Coord(), DIR_N, 0x0030 + Height));
  1866. }
  1867. /*
  1868. ** If the animation was created, then attach it to this object.
  1869. */
  1870. if (anim != NULL) {
  1871. anim->Attach_To(this);
  1872. }
  1873. return(true);
  1874. }
  1875. return(false);
  1876. }
  1877. /***********************************************************************************************
  1878. * ObjectClass::Attach_Trigger -- Attach specified trigger to object. *
  1879. * *
  1880. * This routine is used to attach the specified trigger to the object. *
  1881. * *
  1882. * INPUT: trigger -- Pointer to the trigger to attach. If any existing trigger is desired *
  1883. * to be detached, then pass NULL to this routine. *
  1884. * *
  1885. * OUTPUT: bool; Was the trigger attached? *
  1886. * *
  1887. * WARNINGS: none *
  1888. * *
  1889. * HISTORY: *
  1890. * 05/06/1996 JLB : Created. *
  1891. *=============================================================================================*/
  1892. bool ObjectClass::Attach_Trigger(TriggerClass * trigger)
  1893. {
  1894. if (Trigger.Is_Valid()) {
  1895. TriggerClass * tptr = Trigger;
  1896. tptr->AttachCount--;
  1897. Trigger = NULL;
  1898. }
  1899. if (trigger) {
  1900. Trigger = trigger;
  1901. trigger->AttachCount++;
  1902. return(true);
  1903. }
  1904. return(false);
  1905. }
  1906. // These can't be made inline (for various reasons).
  1907. short const * ObjectClass::Occupy_List(bool placement) const {return(Class_Of().Occupy_List(placement));};
  1908. short const * ObjectClass::Overlap_List(bool ) const {return(Class_Of().Overlap_List());};
  1909. BuildingClass * ObjectClass::Who_Can_Build_Me(bool intheory, bool legal) const {return(Class_Of().Who_Can_Build_Me(intheory, legal, Owner()));};
  1910. fixed ObjectClass::Health_Ratio(void) const {return(fixed(Strength, Class_Of().MaxStrength));};
  1911. int ObjectClass::Full_Name(void) const {return Class_Of().Full_Name();};
  1912. //**********************************************************************************************
  1913. // MODULE SEPARATION -- ObjectTypeClass member functions follow.
  1914. //**********************************************************************************************
  1915. /***********************************************************************************************
  1916. * ObjectTypeClass::ObjectTypeClass -- Normal constructor for object type class objects. *
  1917. * *
  1918. * This is the base constructor that is used when constructing the object type classes. *
  1919. * Every tangible game piece type calls this constructor for the ObjectTypeClass. This *
  1920. * class holds static information that is common to objects in general. *
  1921. * *
  1922. * INPUT: see below... *
  1923. * *
  1924. * OUTPUT: none *
  1925. * *
  1926. * WARNINGS: none *
  1927. * *
  1928. * HISTORY: *
  1929. * 03/23/1995 JLB : Created. *
  1930. *=============================================================================================*/
  1931. ObjectTypeClass::ObjectTypeClass(
  1932. RTTIType rtti,
  1933. int id,
  1934. bool is_sentient,
  1935. bool is_stealthy,
  1936. bool is_selectable,
  1937. bool is_legal_target,
  1938. bool is_insignificant,
  1939. bool is_immune,
  1940. bool is_footprint,
  1941. int name,
  1942. char const * ini) :
  1943. AbstractTypeClass(rtti, id, name, ini),
  1944. IsCrushable(false),
  1945. IsStealthy(is_stealthy),
  1946. IsSelectable(is_selectable),
  1947. IsLegalTarget(is_legal_target),
  1948. IsInsignificant(is_insignificant),
  1949. IsImmune(is_immune),
  1950. IsSentient(is_sentient),
  1951. IsFootprint(is_footprint),
  1952. Armor(ARMOR_NONE),
  1953. MaxStrength(0),
  1954. ImageData(0),
  1955. RadarIcon(0)
  1956. {
  1957. /*
  1958. ** Init the DimensionData rect. Not sure how this was ever working before without being allocated. It was just trashing
  1959. ** memory later on when the pointer was being dereferenced and written to without being initialized. ST - 8/14/2019 3:15PM
  1960. */
  1961. DimensionData = NULL;
  1962. }
  1963. /***********************************************************************************************
  1964. * ObjectTypeClass::Max_Pips -- Fetches the maximum pips allowed for this object. *
  1965. * *
  1966. * This routine will return the maximum number of pips that can be displayed for this *
  1967. * object. When dealing with generic objects, this value is always zero. *
  1968. * *
  1969. * INPUT: none *
  1970. * *
  1971. * OUTPUT: Returns with the number of pip boxes (empty or otherwise) to display. *
  1972. * *
  1973. * WARNINGS: none *
  1974. * *
  1975. * HISTORY: *
  1976. * 07/19/1995 JLB : Created. *
  1977. *=============================================================================================*/
  1978. int ObjectTypeClass::Max_Pips(void) const
  1979. {
  1980. return(0);
  1981. }
  1982. /***********************************************************************************************
  1983. * ObjectTypeClass::Dimensions -- Gets the dimensions of the object in pixels. *
  1984. * *
  1985. * This routine will fetch the dimensions of this object expressed as pixels width and *
  1986. * pixels height. This information can be used to intelligently update the clipping *
  1987. * rectangles. *
  1988. * *
  1989. * INPUT: width -- Reference to the width variable that will be filled in. *
  1990. * *
  1991. * height -- Reference to the height variable that will be filled in. *
  1992. * *
  1993. * OUTPUT: none *
  1994. * *
  1995. * WARNINGS: none *
  1996. * *
  1997. * HISTORY: *
  1998. * 07/19/1995 JLB : Created. *
  1999. *=============================================================================================*/
  2000. void ObjectTypeClass::Dimensions(int &width, int &height) const
  2001. {
  2002. width = 10;
  2003. height = 10;
  2004. }
  2005. /***********************************************************************************************
  2006. * ObjectTypeClass::Cost_Of -- Returns the cost to buy this unit. *
  2007. * *
  2008. * This routine will return the cost to purchase this unit. This routine is expected to be *
  2009. * overridden by the objects that can actually be purchased. All other object types can *
  2010. * simply return zero since this value won't be used. *
  2011. * *
  2012. * INPUT: none *
  2013. * *
  2014. * OUTPUT: Returns the cost of the object. *
  2015. * *
  2016. * WARNINGS: none *
  2017. * *
  2018. * HISTORY: *
  2019. * 07/19/1995 JLB : Created. *
  2020. *=============================================================================================*/
  2021. int ObjectTypeClass::Cost_Of(void) const
  2022. {
  2023. return(0);
  2024. }
  2025. /***********************************************************************************************
  2026. * ObjectTypeClass::Time_To_Build -- Fetches the time to construct this object. *
  2027. * *
  2028. * This routine will fetch the time in takes to construct this object. Objects that can *
  2029. * be constructed will override this routine in order to return a useful value. *
  2030. * *
  2031. * INPUT: none *
  2032. * *
  2033. * OUTPUT: Returns with the time units (arbitrary) that it takes to construct this object. *
  2034. * *
  2035. * WARNINGS: none *
  2036. * *
  2037. * HISTORY: *
  2038. * 07/19/1995 JLB : Created. *
  2039. *=============================================================================================*/
  2040. int ObjectTypeClass::Time_To_Build(HousesType ) const
  2041. {
  2042. return(0);
  2043. }
  2044. /***********************************************************************************************
  2045. * ObjectTypeClass::Get_Cameo_Data -- Fetches pointer to cameo data for this object type. *
  2046. * *
  2047. * This routine will return with the cameo data pointer for this object type. It is *
  2048. * expected that objects that can appear on the sidebar will override this routine in order *
  2049. * to provide proper cameo data pointer. *
  2050. * *
  2051. * INPUT: none *
  2052. * *
  2053. * OUTPUT: Returns with a pointer to the cameo shape data. *
  2054. * *
  2055. * WARNINGS: none *
  2056. * *
  2057. * HISTORY: *
  2058. * 07/19/1995 JLB : Created. *
  2059. *=============================================================================================*/
  2060. void const * ObjectTypeClass::Get_Cameo_Data(void) const
  2061. {
  2062. return(NULL);
  2063. }
  2064. /***********************************************************************************************
  2065. * ObjectTypeClass::Occupy_List -- Returns with simple occupation list for object. *
  2066. * *
  2067. * This routine returns a pointer to a simple occupation list for this object. Since at *
  2068. * this tier of the object class chain, the exact shape of the object is indeterminate, *
  2069. * this function merely returns a single cell occupation list. This actually works for *
  2070. * most vehicles. *
  2071. * *
  2072. * INPUT: none *
  2073. * *
  2074. * OUTPUT: Returns a pointer to a simple occupation list. *
  2075. * *
  2076. * WARNINGS: none *
  2077. * *
  2078. * HISTORY: *
  2079. * 05/28/1994 JLB : Created. *
  2080. *=============================================================================================*/
  2081. short const * ObjectTypeClass::Occupy_List(bool) const
  2082. {
  2083. static short const _list[] = {0, REFRESH_EOL};
  2084. return(_list);
  2085. }
  2086. /***********************************************************************************************
  2087. * ObjectTypeClass::Overlap_List -- Returns a pointer to a simple overlap list. *
  2088. * *
  2089. * This function returns a pointer to an overlap list for the object. An overlap list is *
  2090. * the offsets from the object's cell to get the cells the imagery overlaps, but is object *
  2091. * is not considered to occupy. Since at this stage, the overlap information is not *
  2092. * available, this function merely returns a pointer to an empty list. *
  2093. * *
  2094. * INPUT: none *
  2095. * *
  2096. * OUTPUT: Returns a pointer to the generic overlap list. *
  2097. * *
  2098. * WARNINGS: none *
  2099. * *
  2100. * HISTORY: *
  2101. * 05/28/1994 JLB : Created. *
  2102. *=============================================================================================*/
  2103. short const * ObjectTypeClass::Overlap_List(void) const
  2104. {
  2105. static short const _list[] = {REFRESH_EOL};
  2106. return(_list);
  2107. }
  2108. /***********************************************************************************************
  2109. * ObjectTypeClass::One_Time -- Handles one time processing for object types. *
  2110. * *
  2111. * This routine is used to handle the once per game processing required for object types. *
  2112. * This consists of loading any data and initializing any data tables the game requires. *
  2113. * *
  2114. * INPUT: none *
  2115. * *
  2116. * OUTPUT: none *
  2117. * *
  2118. * WARNINGS: This routine goes to disk. *
  2119. * *
  2120. * HISTORY: *
  2121. * 11/01/1994 JLB : Created. *
  2122. *=============================================================================================*/
  2123. void ObjectTypeClass::One_Time(void)
  2124. {
  2125. SelectShapes = MFCD::Retrieve("SELECT.SHP");
  2126. #ifndef NDEBUG
  2127. RawFileClass file("PIPS.SHP");
  2128. if (file.Is_Available()) {
  2129. PipShapes = Load_Alloc_Data(file);
  2130. } else {
  2131. PipShapes = MFCD::Retrieve("PIPS.SHP");
  2132. }
  2133. #else
  2134. PipShapes = MFCD::Retrieve("PIPS.SHP");
  2135. #endif
  2136. }
  2137. /***********************************************************************************************
  2138. * ObjectTypeClass::Who_Can_Build_Me -- Determine what building can build this object type. *
  2139. * *
  2140. * This routine will scan through all available factory buildings and determine which *
  2141. * is capable of building this object type. The scan can be controlled to scan for only *
  2142. * factory buildings that are free to produce now or those that could produce this *
  2143. * object type if conditions permit. *
  2144. * *
  2145. * INPUT: intheory -- Should the general (when conditions permit) case be examined to see *
  2146. * if a building could build this object type "in theory" even though it *
  2147. * might currently be otherwise occupied? *
  2148. * *
  2149. * legal -- Check for building prerequisite and technology level rules? Usually *
  2150. * this would be 'true' for human controlled requests and 'false' for *
  2151. * the computer. This is because the computer is usually not under *
  2152. * the normal restrictions that the player is under. *
  2153. * *
  2154. * OUTPUT: Returns with a pointer to the building that can produce the object of this *
  2155. * type. If no suitable factory building could be found, then NULL is returned. *
  2156. * *
  2157. * WARNINGS: none *
  2158. * *
  2159. * HISTORY: *
  2160. * 07/29/1996 JLB : Created. *
  2161. *=============================================================================================*/
  2162. BuildingClass * ObjectTypeClass::Who_Can_Build_Me(bool intheory, bool legal, HousesType house) const
  2163. {
  2164. BuildingClass * anybuilding = NULL;
  2165. if (!intheory && What_Am_I() == RTTI_AIRCRAFTTYPE && ((AircraftTypeClass*)this)->IsFixedWing) {
  2166. int num_builders = 0, num_fixed_wings = 0;
  2167. for (int index = 0; index < Buildings.Count(); index++) {
  2168. BuildingClass * building = Buildings.Ptr(index);
  2169. assert(building != NULL);
  2170. if ( !building->IsInLimbo &&
  2171. building->House->Class->House == house &&
  2172. building->Class->ToBuild == RTTI &&
  2173. building->Mission != MISSION_DECONSTRUCTION && building->MissionQueue != MISSION_DECONSTRUCTION &&
  2174. ((1L << building->ActLike) & Get_Ownable()) &&
  2175. (!legal || building->House->Can_Build(this, building->ActLike))) {
  2176. num_builders++;
  2177. }
  2178. }
  2179. for (int index = 0; index < Aircraft.Count(); index++) {
  2180. AircraftClass * aircraft = Aircraft.Ptr(index);
  2181. assert(aircraft != NULL);
  2182. if ( !aircraft->IsInLimbo &&
  2183. aircraft->House->Class->House == house &&
  2184. aircraft->Class->IsFixedWing) {
  2185. num_fixed_wings++;
  2186. }
  2187. }
  2188. if (num_fixed_wings >= num_builders) {
  2189. return NULL;
  2190. }
  2191. }
  2192. for (int index = 0; index < Buildings.Count(); index++) {
  2193. BuildingClass * building = Buildings.Ptr(index);
  2194. assert(building != NULL);
  2195. if ( !building->IsInLimbo &&
  2196. building->House->Class->House == house &&
  2197. building->Class->ToBuild == RTTI &&
  2198. building->Mission != MISSION_DECONSTRUCTION && building->MissionQueue != MISSION_DECONSTRUCTION &&
  2199. ((1L << building->ActLike) & Get_Ownable()) &&
  2200. (!legal || building->House->Can_Build(this, building->ActLike)) &&
  2201. (intheory || !building->In_Radio_Contact())) {
  2202. // BG: Hack so only kennels can build dogs, and no other, and barracks can
  2203. // only build humans and no other.
  2204. if (What_Am_I() == RTTI_INFANTRYTYPE) {
  2205. InfantryTypeClass * me = (InfantryTypeClass *)this;
  2206. if (me->IsDog) {
  2207. if (*building == STRUCT_KENNEL) {
  2208. if (building->IsLeader) return(building);
  2209. anybuilding = building;
  2210. }
  2211. } else {
  2212. if (*building != STRUCT_KENNEL) {
  2213. if (building->IsLeader) return(building);
  2214. anybuilding = building;
  2215. }
  2216. }
  2217. } else {
  2218. /*
  2219. ** HACK ALERT: Helipads can build aircraft and airstrips can build
  2220. ** fixed wing craft only.
  2221. */
  2222. if (What_Am_I() == RTTI_AIRCRAFTTYPE) {
  2223. AircraftTypeClass * air = (AircraftTypeClass *)this;
  2224. if ((*building == STRUCT_HELIPAD && !air->IsFixedWing) || (*building == STRUCT_AIRSTRIP && air->IsFixedWing)) {
  2225. if (building->IsLeader) return(building);
  2226. anybuilding = building;
  2227. }
  2228. } else {
  2229. if (building->IsLeader) return(building);
  2230. anybuilding = building;
  2231. }
  2232. }
  2233. }
  2234. }
  2235. return(anybuilding);
  2236. }