SIDEBARGlyphx.CPP 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821
  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: F:\projects\c&c\vcs\code\sidebar.cpv 2.13 02 Aug 1995 17:03:22 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 : SIDEBARGlyphx.CPP *
  22. * *
  23. * Programmer : Steve Tall *
  24. * *
  25. * Start Date : March 14th, 2019 *
  26. * *
  27. * Last Update : March 14th, 2019 *
  28. * *
  29. *---------------------------------------------------------------------------------------------*
  30. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  31. #include "function.h"
  32. #include "SidebarGlyphx.h"
  33. /*
  34. ** ST - 3/14/2019 10:49AM
  35. **
  36. ** We are going to need one sidebar per player for multiplayer with GlyphX. We can't have different maps / cell arrays per
  37. ** player though, so SidebarClass being in the middle of the map/display class hierarchy is a problem.
  38. **
  39. ** All the class static data will have to be made non-static so we can have multiple instances.
  40. **
  41. ** So, this is a stub sidebar class with the functionality we need just to support the exporting of production data to the
  42. ** GlyphX client.
  43. **
  44. **
  45. */
  46. /***********************************************************************************************
  47. * SidebarGlyphxClass::SidebarGlyphxClass -- Default constructor for the sidebar. *
  48. * *
  49. * Constructor for the sidebar handler. It basically sets up the sidebar to the empty *
  50. * condition. *
  51. * *
  52. * INPUT: none *
  53. * *
  54. * OUTPUT: none *
  55. * *
  56. * WARNINGS: none *
  57. * *
  58. * HISTORY: *
  59. * 11/17/1994 JLB : Created. *
  60. *=============================================================================================*/
  61. SidebarGlyphxClass::SidebarGlyphxClass(void)
  62. {
  63. //IsRepairActive = false;
  64. //IsUpgradeActive = false;
  65. //IsDemolishActive = false;
  66. }
  67. /***********************************************************************************************
  68. * SidebarGlyphxClass::Init_Clear -- Sets sidebar to a known (and deactivated) state *
  69. * *
  70. * INPUT: none *
  71. * *
  72. * OUTPUT: none *
  73. * *
  74. * WARNINGS: none *
  75. * *
  76. * HISTORY: *
  77. * 12/24/1994 JLB : Created. *
  78. *=============================================================================================*/
  79. void SidebarGlyphxClass::Init_Clear(HouseClass *player_ptr)
  80. {
  81. SidebarPlayerPtr = player_ptr;
  82. //IsRepairActive = false;
  83. //IsUpgradeActive = false;
  84. //IsDemolishActive = false;
  85. Column[0].Set_Parent_Sidebar(this);
  86. Column[1].Set_Parent_Sidebar(this);
  87. Column[0].Init_Clear();
  88. Column[1].Init_Clear();
  89. //Activate(false);
  90. }
  91. /***********************************************************************************************
  92. * SidebarGlyphxClass::Init_IO -- Adds buttons to the button list *
  93. * *
  94. * INPUT: none *
  95. * *
  96. * OUTPUT: none *
  97. * *
  98. * WARNINGS: none *
  99. * *
  100. * HISTORY: *
  101. * 12/24/1994 JLB : Created. *
  102. *=============================================================================================*/
  103. void SidebarGlyphxClass::Init_IO(void)
  104. {
  105. /*
  106. ** If a game was loaded & the sidebar was enabled, pop it up now
  107. */
  108. //if (IsSidebarActive) {
  109. // IsSidebarActive = false;
  110. // Activate(1);
  111. //}
  112. }
  113. /***********************************************************************************************
  114. * SidebarGlyphxClass::Which_Column -- Determines which column a given type should appear. *
  115. * *
  116. * Use this function to resolve what column the specified object type should be placed *
  117. * into. *
  118. * *
  119. * INPUT: otype -- Pointer to the object type class of the object in question. *
  120. * *
  121. * OUTPUT: Returns with the column number that the object should be placed in. *
  122. * *
  123. * WARNINGS: none *
  124. * *
  125. * HISTORY: *
  126. * 01/01/1995 JLB : Created. *
  127. *=============================================================================================*/
  128. int SidebarGlyphxClass::Which_Column(RTTIType type)
  129. {
  130. if (type == RTTI_BUILDINGTYPE || type == RTTI_BUILDING) {
  131. return(0);
  132. }
  133. return(1);
  134. }
  135. /***********************************************************************************************
  136. * SidebarGlyphxClass::Factory_Link -- Links a factory to a sidebar strip. *
  137. * *
  138. * This routine will link the specified factory to the sidebar strip. A factory must be *
  139. * linked to the sidebar so that as the factory production progresses, the sidebar will *
  140. * show the production progress. *
  141. * *
  142. * INPUT: factory -- The factory number to attach. *
  143. * *
  144. * type -- The object type number. *
  145. * *
  146. * id -- The object sub-type number. *
  147. * *
  148. * OUTPUT: Was the factory successfully attached to the sidebar strip? *
  149. * *
  150. * WARNINGS: none *
  151. * *
  152. * HISTORY: *
  153. * 05/19/1995 JLB : Created. *
  154. *=============================================================================================*/
  155. bool SidebarGlyphxClass::Factory_Link(int factory, RTTIType type, int id)
  156. {
  157. return(Column[Which_Column(type)].Factory_Link(factory, type, id));
  158. }
  159. /***********************************************************************************************
  160. * SidebarGlyphxClass::Add -- Adds a game object to the sidebar list. *
  161. * *
  162. * This routine is used to add a game object to the sidebar. Call this routine when a *
  163. * factory type building is created. It handles the case of adding an item that has already *
  164. * been added -- it just ignores it. *
  165. * *
  166. * INPUT: object -- Pointer to the object that is being added. *
  167. * *
  168. * OUTPUT: bool; Was the object added to the sidebar? *
  169. * *
  170. * WARNINGS: none *
  171. * *
  172. * HISTORY: *
  173. * 11/17/1994 JLB : Created. *
  174. *=============================================================================================*/
  175. bool SidebarGlyphxClass::Add(RTTIType type, int id, bool via_capture)
  176. {
  177. int column;
  178. /*
  179. ** Add the sidebar only if we're not in editor mode.
  180. */
  181. if (!Debug_Map) {
  182. column = Which_Column(type);
  183. if (Column[column].Add(type, id, via_capture)) {
  184. //Activate(1);
  185. return(true);
  186. }
  187. return(false);
  188. }
  189. return(false);
  190. }
  191. /***********************************************************************************************
  192. * SidebarGlyphxClass::AI -- Handles player clicking on sidebar area. *
  193. * *
  194. * This routine handles the processing necessary when the player clicks on the sidebar. *
  195. * Typically, this is selection of the item to build. *
  196. * *
  197. * INPUT: input -- Reference to the keyboard input value. *
  198. * *
  199. * x,y -- Mouse coordinates at time of input. *
  200. * *
  201. * OUTPUT: bool; Was the click handled? *
  202. * *
  203. * WARNINGS: none *
  204. * *
  205. * HISTORY: *
  206. * 10/28/94 JLB : Created. *
  207. * 11/11/1994 JLB : Processes input directly. *
  208. * 12/26/1994 JLB : Uses factory manager class for construction handling. *
  209. * 12/31/1994 JLB : Simplified to use the sidebar strip class handlers. *
  210. * 12/31/1994 JLB : Uses mouse coordinate parameters. *
  211. * 06/27/1995 JLB : <TAB> key toggles sidebar. *
  212. *=============================================================================================*/
  213. void SidebarGlyphxClass::AI(KeyNumType & input, int x, int y)
  214. {
  215. if (!Debug_Map) {
  216. Column[0].AI(input, x, y);
  217. Column[1].AI(input, x, y);
  218. }
  219. }
  220. /***********************************************************************************************
  221. * SidebarGlyphxClass::Recalc -- Examines the sidebar data and updates it as necessary. *
  222. * *
  223. * Occasionally a factory gets destroyed. This routine must be called in such a case *
  224. * because it might be possible that sidebar object need to be removed. This routine will *
  225. * examine all existing objects in the sidebar class and if no possible factory can *
  226. * produce it, then it will be removed. *
  227. * *
  228. * INPUT: none *
  229. * *
  230. * OUTPUT: none *
  231. * *
  232. * WARNINGS: This routine is exhaustive and thus time consuming. Only call it when really *
  233. * necessary. Such as when a factory is destroyed rather than when a non-factory *
  234. * is destroyed. *
  235. * *
  236. * HISTORY: *
  237. * 11/30/1994 JLB : Created. *
  238. *=============================================================================================*/
  239. void SidebarGlyphxClass::Recalc(void)
  240. {
  241. Column[0].Recalc();
  242. Column[1].Recalc();
  243. }
  244. /***********************************************************************************************
  245. * SidebarGlyphxClass::StripClass::StripClass -- Default constructor for the side strip class. *
  246. * *
  247. * This constructor is used to reset the side strip to default empty state. *
  248. * *
  249. * INPUT: none *
  250. * *
  251. * OUTPUT: none *
  252. * *
  253. * WARNINGS: none *
  254. * *
  255. * HISTORY: *
  256. * 12/31/1994 JLB : Created. *
  257. *=============================================================================================*/
  258. SidebarGlyphxClass::StripClass::StripClass(void)
  259. {
  260. IsBuilding = false;
  261. BuildableCount = 0;
  262. for (int index = 0; index < MAX_BUILDABLES; index++) {
  263. Buildables[index].BuildableID = 0;
  264. Buildables[index].BuildableType = RTTI_NONE;
  265. Buildables[index].Factory = -1;
  266. Buildables[index].BuildableViaCapture = false;
  267. }
  268. ParentSidebar = NULL;
  269. }
  270. /***********************************************************************************************
  271. * SidebarGlyphxClass::StripClass::Init_Clear -- Sets sidebar to a known (and deactivated) state*
  272. * *
  273. * INPUT: none *
  274. * *
  275. * OUTPUT: none *
  276. * *
  277. * WARNINGS: none *
  278. * *
  279. * HISTORY: *
  280. * 12/24/1994 JLB : Created. *
  281. *=============================================================================================*/
  282. void SidebarGlyphxClass::StripClass::Init_Clear(void)
  283. {
  284. IsBuilding = false;
  285. BuildableCount = 0;
  286. /*
  287. ** Since we're resetting the strips, clear out all the buildables & factory pointers.
  288. */
  289. for (int index = 0; index < MAX_BUILDABLES; index++) {
  290. Buildables[index].BuildableID = 0;
  291. Buildables[index].BuildableType = RTTI_NONE;
  292. Buildables[index].Factory = -1;
  293. Buildables[index].BuildableViaCapture = false;
  294. }
  295. }
  296. /***********************************************************************************************
  297. * SidebarGlyphxClass::StripClass::Add -- Add an object to the side strip. *
  298. * *
  299. * Use this routine to add a buildable object to the side strip. *
  300. * *
  301. * INPUT: object -- Pointer to the object type that can be built and is to be added to *
  302. * the side strip. *
  303. * *
  304. * OUTPUT: bool; Was the object successfully added to the side strip? Failure could be the *
  305. * result of running out of room in the side strip array or the object might *
  306. * already be in the list. *
  307. * *
  308. * WARNINGS: none. *
  309. * *
  310. * HISTORY: *
  311. * 12/31/1994 JLB : Created. *
  312. *=============================================================================================*/
  313. bool SidebarGlyphxClass::StripClass::Add(RTTIType type, int id, bool via_capture)
  314. {
  315. if (BuildableCount <= MAX_BUILDABLES) {
  316. for (int index = 0; index < BuildableCount; index++) {
  317. if (Buildables[index].BuildableType == type && Buildables[index].BuildableID == id) {
  318. return(false);
  319. }
  320. }
  321. if (!ScenarioInit && type != RTTI_SPECIAL) {
  322. Speak(VOX_NEW_CONSTRUCT);
  323. }
  324. Buildables[BuildableCount].BuildableType = type;
  325. Buildables[BuildableCount].BuildableID = id;
  326. Buildables[BuildableCount].Factory = -1;
  327. Buildables[BuildableCount].BuildableViaCapture = via_capture;
  328. BuildableCount++;
  329. return(true);
  330. }
  331. return(false);
  332. }
  333. /***********************************************************************************************
  334. * SidebarGlyphxClass::StripClass::AI -- Input and AI processing for the side strip. *
  335. * *
  336. * The side strip AI processing is performed by this function. This function not only *
  337. * checks for player input, but also handles any graphic logic updating necessary as a *
  338. * result of flashing or construction animation. *
  339. * *
  340. * INPUT: input -- The player input code. *
  341. * *
  342. * x,y -- Mouse coordinate to use. *
  343. * *
  344. * OUTPUT: bool; Did the AI detect that it will need a rendering change? If this routine *
  345. * returns true, then the Draw_It function should be called at the *
  346. * earliest opportunity. *
  347. * *
  348. * WARNINGS: none *
  349. * *
  350. * HISTORY: *
  351. * 12/31/1994 JLB : Created. *
  352. * 12/31/1994 JLB : Uses mouse coordinate parameters. *
  353. *=============================================================================================*/
  354. bool SidebarGlyphxClass::StripClass::AI(KeyNumType & input, int , int )
  355. {
  356. /*
  357. ** This is needed as it's where units get queued for structure exit. ST -3/14/2019 12:03PM
  358. */
  359. if (IsBuilding) {
  360. for (int index = 0; index < BuildableCount; index++) {
  361. int factoryid = Buildables[index].Factory;
  362. if (factoryid != -1) {
  363. FactoryClass * factory = Factories.Raw_Ptr(factoryid);
  364. if (factory && (factory->Has_Changed() || factory->Is_Blocked())) {
  365. if (factory->Has_Completed()) {
  366. /*
  367. ** Construction has been completed. Announce this fact to the player and
  368. ** try to get the object to automatically leave the factory. Buildings are
  369. ** the main exception to the ability to leave the factory under their own
  370. ** power.
  371. */
  372. TechnoClass * pending = factory->Get_Object();
  373. if (pending) {
  374. switch (pending->What_Am_I()) {
  375. case RTTI_VESSEL:
  376. case RTTI_UNIT:
  377. case RTTI_AIRCRAFT:
  378. OutList.Add(EventClass(EventClass::PLACE, pending->What_Am_I(), -1));
  379. if (!factory->Is_Blocked()) {
  380. Speak(VOX_UNIT_READY);
  381. }
  382. break;
  383. case RTTI_BUILDING:
  384. if (!factory->Is_Blocked()) {
  385. Speak(VOX_CONSTRUCTION);
  386. }
  387. break;
  388. case RTTI_INFANTRY:
  389. OutList.Add(EventClass(EventClass::PLACE, pending->What_Am_I(), -1));
  390. if (!factory->Is_Blocked()) {
  391. Speak(VOX_UNIT_READY);
  392. }
  393. break;
  394. }
  395. }
  396. }
  397. }
  398. }
  399. }
  400. }
  401. return(false);
  402. }
  403. /***********************************************************************************************
  404. * SidebarGlyphxClass::StripClass::Recalc -- Revalidates the current sidebar list of objects. *
  405. * *
  406. * This routine will revalidate all the buildable objects in the sidebar. This routine *
  407. * comes in handy when a factory has been destroyed, and the sidebar needs to reflect any *
  408. * change that this requires. It checks every object to see if there is a factory available *
  409. * that could produce it. If none can be found, then the object is removed from the *
  410. * sidebar. *
  411. * *
  412. * INPUT: none *
  413. * *
  414. * OUTPUT: bool; The sidebar has changed as a result of this call? *
  415. * *
  416. * WARNINGS: none *
  417. * *
  418. * HISTORY: *
  419. * 01/19/1995 JLB : Created. *
  420. * 06/26/1995 JLB : Doesn't collapse sidebar when buildables removed. *
  421. *=============================================================================================*/
  422. bool SidebarGlyphxClass::StripClass::Recalc(void)
  423. {
  424. int ok;
  425. if (Debug_Map || !BuildableCount) {
  426. return(false);
  427. }
  428. /*
  429. ** Sweep through all objects listed in the sidebar. If any of those object can
  430. ** not be created -- even in theory -- then they must be removed form the sidebar and
  431. ** any current production must be abandoned.
  432. */
  433. for (int index = 0; index < BuildableCount; index++) {
  434. TechnoTypeClass const * tech = Fetch_Techno_Type(Buildables[index].BuildableType, Buildables[index].BuildableID);
  435. if (tech) {
  436. ok = tech->Who_Can_Build_Me(true, false, ParentSidebar->SidebarPlayerPtr->Class->House) != NULL;
  437. } else {
  438. if ((unsigned)Buildables[index].BuildableID < SPC_COUNT) {
  439. ok = ParentSidebar->SidebarPlayerPtr->SuperWeapon[Buildables[index].BuildableID].Is_Present();
  440. } else {
  441. ok = false;
  442. }
  443. }
  444. if (!ok) {
  445. /*
  446. ** Removes this entry from the list.
  447. */
  448. if (BuildableCount > 1 && index < BuildableCount-1) {
  449. memcpy(&Buildables[index], &Buildables[index+1], sizeof(Buildables[0])*((BuildableCount-index)-1));
  450. }
  451. BuildableCount--;
  452. index--;
  453. Buildables[BuildableCount].BuildableID = 0;
  454. Buildables[BuildableCount].BuildableType = RTTI_NONE;
  455. Buildables[BuildableCount].Factory = -1;
  456. Buildables[BuildableCount].BuildableViaCapture = false;
  457. }
  458. }
  459. return(false);
  460. }
  461. /***********************************************************************************************
  462. * SidebarGlyphxClass::StripClass::Factory_Link -- Links a factory to a sidebar button. *
  463. * *
  464. * This routine will link the specified factory to this sidebar strip. The exact button to *
  465. * link to is determined from the object type and id specified. A linked button is one that *
  466. * will show appropriate construction animation (clock shape) that matches the state of *
  467. * the factory. *
  468. * *
  469. * INPUT: factory -- The factory number to link to the sidebar. *
  470. * *
  471. * type -- The object type that this factory refers to. *
  472. * *
  473. * id -- The object sub-type that this factory refers to. *
  474. * *
  475. * OUTPUT: Was the factory successfully attached? Failure would indicate that there is no *
  476. * object of the specified type and sub-type in the sidebar list. *
  477. * *
  478. * WARNINGS: none *
  479. * *
  480. * HISTORY: *
  481. * 05/18/1995 JLB : Created. *
  482. *=============================================================================================*/
  483. bool SidebarGlyphxClass::StripClass::Factory_Link(int factory, RTTIType type, int id)
  484. {
  485. for (int index = 0; index < BuildableCount; index++) {
  486. if (Buildables[index].BuildableType == type && Buildables[index].BuildableID == id) {
  487. Buildables[index].Factory = factory;
  488. IsBuilding = true;
  489. return(true);
  490. }
  491. }
  492. return(false);
  493. }
  494. /***********************************************************************************************
  495. * SidebarGlyphxClass::Abandon_Production -- Stops production of the object specified. *
  496. * *
  497. * This routine is used to abandon production of the object specified. The factory will *
  498. * be completely disabled by this call. *
  499. * *
  500. * INPUT: type -- The object type that is to be abandoned. The sub-type is not needed *
  501. * since it is presumed there can be only one type in production at any *
  502. * one time. *
  503. * *
  504. * factory -- The factory number that is doing the production. *
  505. * *
  506. * OUTPUT: Was the factory successfully abandoned? *
  507. * *
  508. * WARNINGS: none *
  509. * *
  510. * HISTORY: *
  511. * 05/18/1995 JLB : Created. *
  512. *=============================================================================================*/
  513. bool SidebarGlyphxClass::Abandon_Production(RTTIType type, int factory)
  514. {
  515. return(Column[Which_Column(type)].Abandon_Production(factory));
  516. }
  517. /***********************************************************************************************
  518. * SidebarGlyphxClass::StripClass::Abandon_Produ -- Abandons production associated with sidebar. *
  519. * *
  520. * Production of the object associated with this sidebar is abandoned when this routine is *
  521. * called. *
  522. * *
  523. * INPUT: factory -- The factory index that is to be suspended. *
  524. * *
  525. * OUTPUT: Was the production abandonment successful? *
  526. * *
  527. * WARNINGS: none *
  528. * *
  529. * HISTORY: *
  530. * 05/18/1995 JLB : Created. *
  531. * 08/06/1995 JLB : More intelligent abandon logic for multiple factories. *
  532. *=============================================================================================*/
  533. bool SidebarGlyphxClass::StripClass::Abandon_Production(int factory)
  534. {
  535. bool noprod = true;
  536. bool abandon = false;
  537. for (int index = 0; index < BuildableCount; index++) {
  538. if (Buildables[index].Factory == factory) {
  539. Factories.Raw_Ptr(factory)->Abandon();
  540. Buildables[index].Factory = -1;
  541. abandon = true;
  542. } else {
  543. if (Buildables[index].Factory != -1) {
  544. noprod = false;
  545. }
  546. }
  547. }
  548. /*
  549. ** If there is no production whatsoever on this strip, then flag it so.
  550. */
  551. if (noprod) {
  552. IsBuilding = false;
  553. }
  554. return(abandon);
  555. }
  556. /***********************************************************************************************
  557. * SidebarGlyphxClass::Code_Pointers -- Converts classes pointers to savable representation *
  558. * *
  559. * INPUT: none *
  560. * *
  561. * OUTPUT: none *
  562. * *
  563. * WARNINGS: none *
  564. * *
  565. * HISTORY: *
  566. * 9/25/2019 5:36PM ST : Created. *
  567. *=============================================================================================*/
  568. void SidebarGlyphxClass::Code_Pointers(void)
  569. {
  570. if (SidebarPlayerPtr) {
  571. ((HouseClass *&)SidebarPlayerPtr) = (HouseClass *)SidebarPlayerPtr->Class->House;
  572. } else {
  573. ((HouseClass *&)SidebarPlayerPtr) = (HouseClass *)HOUSE_NONE;
  574. }
  575. }
  576. /***********************************************************************************************
  577. * SidebarGlyphxClass::Decode_Pointers -- Converts classes savable representation to run-time *
  578. * *
  579. * INPUT: none *
  580. * *
  581. * OUTPUT: none *
  582. * *
  583. * WARNINGS: none *
  584. * *
  585. * HISTORY: *
  586. * 9/25/2019 5:36PM ST : Created. *
  587. *=============================================================================================*/
  588. void SidebarGlyphxClass::Decode_Pointers(void)
  589. {
  590. if (*((HousesType*)&SidebarPlayerPtr) == HOUSE_NONE) {
  591. SidebarPlayerPtr = NULL;
  592. } else {
  593. ((HouseClass *&)SidebarPlayerPtr) = HouseClass::As_Pointer(*((HousesType*)&SidebarPlayerPtr));
  594. }
  595. }
  596. /***********************************************************************************************
  597. * SidebarGlyphxClass::Load -- Loads from a save game file. *
  598. * *
  599. * INPUT: file -- The file to read the data from. *
  600. * *
  601. * OUTPUT: true = success, false = failure *
  602. * *
  603. * WARNINGS: none *
  604. * *
  605. * HISTORY: *
  606. * 9/26/2019 10:57AM ST : Created. *
  607. *=============================================================================================*/
  608. bool SidebarGlyphxClass::Load(Straw &file)
  609. {
  610. ::new (this) SidebarGlyphxClass();
  611. //bool ok = Read_Object(this, sizeof(*this), file, false);
  612. if (file.Get(this, sizeof(*this)) != sizeof(*this)) {
  613. return false;
  614. }
  615. Column[0].Set_Parent_Sidebar(this);
  616. Column[1].Set_Parent_Sidebar(this);
  617. return true;
  618. }
  619. /***********************************************************************************************
  620. * SidebarGlyphxClass::Save -- Write to a save game file. *
  621. * *
  622. * INPUT: file -- The file to write the data to. *
  623. * *
  624. * OUTPUT: true = success, false = failure *
  625. * *
  626. * WARNINGS: none *
  627. * *
  628. * HISTORY: *
  629. * 9/26/2019 10:57AM ST : Created. *
  630. *=============================================================================================*/
  631. bool SidebarGlyphxClass::Save(Pipe &file)
  632. {
  633. //return(Write_Object(this, sizeof(*this), file));
  634. file.Put(this, sizeof(*this));
  635. return true;
  636. }
  637. extern SidebarGlyphxClass *Get_Current_Context_Sidebar(HouseClass *player_ptr);
  638. void Sidebar_Glyphx_Init_Clear(HouseClass *player_ptr)
  639. {
  640. SidebarGlyphxClass *sidebar = Get_Current_Context_Sidebar(player_ptr);
  641. if (sidebar) {
  642. sidebar->Init_Clear(player_ptr);
  643. }
  644. }
  645. void Sidebar_Glyphx_Init_IO(HouseClass *player_ptr)
  646. {
  647. SidebarGlyphxClass *sidebar = Get_Current_Context_Sidebar(player_ptr);
  648. if (sidebar) {
  649. sidebar->Init_IO();
  650. }
  651. }
  652. bool Sidebar_Glyphx_Abandon_Production(RTTIType type, int factory, HouseClass *player_ptr)
  653. {
  654. SidebarGlyphxClass *sidebar = Get_Current_Context_Sidebar(player_ptr);
  655. if (sidebar) {
  656. return sidebar->Abandon_Production(type, factory);
  657. }
  658. return false;
  659. }
  660. bool Sidebar_Glyphx_Add(RTTIType type, int id, HouseClass *player_ptr, bool via_capture)
  661. {
  662. SidebarGlyphxClass *sidebar = Get_Current_Context_Sidebar(player_ptr);
  663. if (sidebar) {
  664. return sidebar->Add(type, id, via_capture);
  665. }
  666. return false;
  667. }
  668. void Sidebar_Glyphx_Recalc(HouseClass *player_ptr)
  669. {
  670. SidebarGlyphxClass *sidebar = Get_Current_Context_Sidebar(player_ptr);
  671. if (sidebar) {
  672. sidebar->Recalc();
  673. }
  674. }
  675. void Sidebar_Glyphx_AI(HouseClass *player_ptr, KeyNumType & input)
  676. {
  677. SidebarGlyphxClass *sidebar = Get_Current_Context_Sidebar(player_ptr);
  678. if (sidebar) {
  679. sidebar->AI(input, 0, 0);
  680. }
  681. }
  682. bool Sidebar_Glyphx_Factory_Link(int factory, RTTIType type, int id, HouseClass *player_ptr)
  683. {
  684. SidebarGlyphxClass *sidebar = Get_Current_Context_Sidebar(player_ptr);
  685. if (sidebar) {
  686. return sidebar->Factory_Link(factory, type, id);
  687. }
  688. return false;
  689. }
  690. bool Sidebar_Glyphx_Save(Pipe &file, SidebarGlyphxClass *sidebar)
  691. {
  692. if (sidebar) {
  693. return sidebar->Save(file);
  694. }
  695. return false;
  696. }
  697. bool Sidebar_Glyphx_Load(Straw &file, SidebarGlyphxClass *sidebar)
  698. {
  699. if (sidebar) {
  700. return sidebar->Load(file);
  701. }
  702. return false;
  703. }
  704. void Sidebar_Glyphx_Code_Pointers(SidebarGlyphxClass *sidebar)
  705. {
  706. if (sidebar) {
  707. sidebar->Code_Pointers();
  708. }
  709. }
  710. void Sidebar_Glyphx_Decode_Pointers(SidebarGlyphxClass *sidebar)
  711. {
  712. if (sidebar) {
  713. sidebar->Decode_Pointers();
  714. }
  715. }