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