/
HOUSE.CPP
8232 lines (7307 loc) · 336 KB
/
HOUSE.CPP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
// software: you can redistribute it and/or modify it under the terms of
// the GNU General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/* $Header: /counterstrike/HOUSE.CPP 4 3/13/97 7:11p Steve_tall $ */
/***********************************************************************************************
*** 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 ***
***********************************************************************************************
* *
* Project Name : Command & Conquer *
* *
* File Name : HOUSE.CPP *
* *
* Programmer : Joe L. Bostic *
* *
* Start Date : May 21, 1994 *
* *
* Last Update : November 4, 1996 [JLB] *
* *
*---------------------------------------------------------------------------------------------*
* Functions: *
* HouseClass::AI -- Process house logic. *
* HouseClass::AI_Aircraft -- Determines what aircraft to build next. *
* HouseClass::AI_Attack -- Handles offensive attack logic. *
* HouseClass::AI_Base_Defense -- Handles maintaining a strong base defense. *
* HouseClass::AI_Building -- Determines what building to build. *
* HouseClass::AI_Fire_Sale -- Check for and perform a fire sale. *
* HouseClass::AI_Infantry -- Determines the infantry unit to build. *
* HouseClass::AI_Money_Check -- Handles money production logic. *
* HouseClass::AI_Power_Check -- Handle the power situation. *
* HouseClass::AI_Unit -- Determines what unit to build next. *
* HouseClass::Abandon_Production -- Abandons production of item type specified. *
* HouseClass::Active_Add -- Add an object to active duty for this house. *
* HouseClass::Active_Remove -- Remove this object from active duty for this house. *
* HouseClass::Adjust_Capacity -- Adjusts the house Tiberium storage capacity. *
* HouseClass::Adjust_Drain -- Adjust the power drain value of the house. *
* HouseClass::Adjust_Power -- Adjust the power value of the house. *
* HouseClass::Adjust_Threat -- Adjust threat for the region specified. *
* HouseClass::As_Pointer -- Converts a house number into a house object pointer. *
* HouseClass::Assign_Handicap -- Assigns the specified handicap rating to the house. *
* HouseClass::Attacked -- Lets player know if base is under attack. *
* HouseClass::Available_Money -- Fetches the total credit worth of the house. *
* HouseClass::Begin_Production -- Starts production of the specified object type. *
* HouseClass::Blowup_All -- blows up everything *
* HouseClass::Can_Build -- General purpose build legality checker. *
* HouseClass::Clobber_All -- removes all objects for this house *
* HouseClass::Computer_Paranoid -- Cause the computer players to becom paranoid. *
* HouseClass::Debug_Dump -- Dumps the house status data to the mono screen. *
* HouseClass::Detach -- Removes specified object from house tracking systems. *
* HouseClass::Do_All_To_Hunt -- Send all units to hunt. *
* HouseClass::Does_Enemy_Building_Exist -- Checks for enemy building of specified type. *
* HouseClass::Expert_AI -- Handles expert AI processing. *
* HouseClass::Factory_Count -- Fetches the number of factories for specified type. *
* HouseClass::Factory_Counter -- Fetches a pointer to the factory counter value. *
* HouseClass::Fetch_Factory -- Finds the factory associated with the object type specified. *
* HouseClass::Find_Build_Location -- Finds a suitable building location. *
* HouseClass::Find_Building -- Finds a building of specified type. *
* HouseClass::Find_Cell_In_Zone -- Finds a legal placement cell within the zone. *
* HouseClass::Find_Juicy_Target -- Finds a suitable field target. *
* HouseClass::Fire_Sale -- Cause all buildings to be sold. *
* HouseClass::Flag_Attach -- Attach flag to specified cell (or thereabouts). *
* HouseClass::Flag_Attach -- Attaches the house flag the specified unit. *
* HouseClass::Flag_Remove -- Removes the flag from the specified target. *
* HouseClass::Flag_To_Die -- Flags the house to blow up soon. *
* HouseClass::Flag_To_Lose -- Flags the house to die soon. *
* HouseClass::Flag_To_Win -- Flags the house to win soon. *
* HouseClass::Get_Quantity -- Fetches the total number of aircraft of the specified type. *
* HouseClass::Get_Quantity -- Gets the quantity of the building type specified. *
* HouseClass::Harvested -- Adds Tiberium to the harvest storage. *
* HouseClass::HouseClass -- Constructor for a house object. *
* HouseClass::Init -- init's in preparation for new scenario *
* HouseClass::Init_Data -- Initializes the multiplayer color data. *
* HouseClass::Is_Allowed_To_Ally -- Determines if this house is allied to make allies. *
* HouseClass::Is_Ally -- Checks to see if the object is an ally. *
* HouseClass::Is_Ally -- Determines if the specified house is an ally. *
* HouseClass::Is_Hack_Prevented -- Is production of the specified type and id prohibted? *
* HouseClass::Is_No_YakMig -- Determines if no more yaks or migs should be allowed. *
* HouseClass::MPlayer_Defeated -- multiplayer; house is defeated *
* HouseClass::Make_Ally -- Make the specified house an ally. *
* HouseClass::Make_Enemy -- Make an enemy of the house specified. *
* HouseClass::Manual_Place -- Inform display system of building placement mode. *
* HouseClass::One_Time -- Handles one time initialization of the house array. *
* HouseClass::Place_Object -- Places the object (building) at location specified. *
* HouseClass::Place_Special_Blast -- Place a special blast effect at location specified. *
* HouseClass::Power_Fraction -- Fetches the current power output rating. *
* HouseClass::Production_Begun -- Records that production has begun. *
* HouseClass::Read_INI -- Reads house specific data from INI. *
* HouseClass::Recalc_Attributes -- Recalcs all houses existence bits. *
* HouseClass::Recalc_Center -- Recalculates the center point of the base. *
* HouseClass::Refund_Money -- Refunds money to back to the house. *
* HouseClass::Remap_Table -- Fetches the remap table for this house object. *
* HouseClass::Sell_Wall -- Tries to sell the wall at the specified location. *
* HouseClass::Set_Factory -- Assign specified factory to house tracking. *
* HouseClass::Silo_Redraw_Check -- Flags silos to be redrawn if necessary. *
* HouseClass::Special_Weapon_AI -- Fires special weapon. *
* HouseClass::Spend_Money -- Removes money from the house. *
* HouseClass::Suggest_New_Building -- Examines the situation and suggests a building. *
* HouseClass::Suggest_New_Object -- Determine what would the next buildable object be. *
* HouseClass::Suggested_New_Team -- Determine what team should be created. *
* HouseClass::Super_Weapon_Handler -- Handles the super weapon charge and discharge logic. *
* HouseClass::Suspend_Production -- Temporarily puts production on hold. *
* HouseClass::Tally_Score -- Fills in the score system for this round *
* HouseClass::Tiberium_Fraction -- Calculates the tiberium fraction of capacity. *
* HouseClass::Tracking_Add -- Informs house of new inventory item. *
* HouseClass::Tracking_Remove -- Remove object from house tracking system. *
* HouseClass::Where_To_Go -- Determines where the object should go and wait. *
* HouseClass::Which_Zone -- Determines what zone a coordinate lies in. *
* HouseClass::Which_Zone -- Determines which base zone the specified cell lies in. *
* HouseClass::Which_Zone -- Determines which base zone the specified object lies in. *
* HouseClass::Write_INI -- Writes the house data to the INI database. *
* HouseClass::Zone_Cell -- Finds the cell closest to the center of the zone. *
* HouseClass::delete -- Deallocator function for a house object. *
* HouseClass::new -- Allocator for a house class. *
* HouseClass::operator HousesType -- Conversion to HousesType operator. *
* HouseClass::~HouseClass -- Default destructor for a house object. *
* HouseStaticClass::HouseStaticClass -- Default constructor for house static class. *
* HouseClass::AI_Raise_Power -- Try to raise power levels by selling off buildings. *
* HouseClass::AI_Raise_Money -- Raise emergency cash by selling buildings. *
* HouseClass::Random_Cell_In_Zone -- Find a (technically) legal cell in the zone specified. *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "function.h"
#include "vortex.h"
//#include "WolDebug.h"
/*
** New sidebar for GlyphX multiplayer. ST - 8/7/2019 10:10AM
*/
#include "SidebarGlyphx.h"
TFixedIHeapClass<HouseClass::BuildChoiceClass> HouseClass::BuildChoice;
int TFixedIHeapClass<HouseClass::BuildChoiceClass>::Save(Pipe &) const
{
return(true);
}
int TFixedIHeapClass<HouseClass::BuildChoiceClass>::Load(Straw &)
{
return(0);
}
void TFixedIHeapClass<HouseClass::BuildChoiceClass>::Code_Pointers(void)
{
}
void TFixedIHeapClass<HouseClass::BuildChoiceClass>::Decode_Pointers(void)
{
}
extern bool RedrawOptionsMenu;
/***********************************************************************************************
* HouseClass::operator HousesType -- Conversion to HousesType operator. *
* *
* This operator will automatically convert from a houses class object into the HousesType *
* enumerated value. *
* *
* INPUT: none *
* *
* OUTPUT: Returns with the object's HousesType value. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 01/23/1995 JLB : Created. *
*=============================================================================================*/
HouseClass::operator HousesType(void) const
{
assert(Houses.ID(this) == ID);
return(Class->House);
}
/***********************************************************************************************
* HouseClass::Tiberium_Fraction -- Calculates the tiberium fraction of capacity. *
* *
* This will calculate the current tiberium (gold) load as a ratio of the maximum storage *
* capacity. *
* *
* INPUT: none *
* *
* OUTPUT: Returns the current tiberium storage situation as a ratio of load over capacity. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 07/31/1996 JLB : Created. *
*=============================================================================================*/
fixed HouseClass::Tiberium_Fraction(void) const
{
if (Tiberium == 0) {
return(0);
}
return(fixed(Tiberium, Capacity));
}
/***********************************************************************************************
* HouseClass::As_Pointer -- Converts a house number into a house object pointer. *
* *
* Use this routine to convert a house number into the house pointer that it represents. *
* A simple index into the Houses template array is not sufficient, since the array order *
* is arbitrary. An actual scan through the house object is required in order to find the *
* house object desired. *
* *
* INPUT: house -- The house type number to look up. *
* *
* OUTPUT: Returns with a pointer to the house object that the house number represents. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 01/23/1995 JLB : Created. *
*=============================================================================================*/
HouseClass * HouseClass::As_Pointer(HousesType house)
{
if (house != HOUSE_NONE) {
for (int index = 0; index < Houses.Count(); index++) {
if (Houses.Ptr(index)->Class->House == house) {
return(Houses.Ptr(index));
}
}
}
return(0);
}
/***********************************************************************************************
* HouseClass::One_Time -- Handles one time initialization of the house array. *
* *
* This basically calls the constructor for each of the houses in the game. All other *
* data specific to the house is initialized when the scenario is loaded. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: Only call this ONCE at the beginning of the game. *
* *
* HISTORY: *
* 12/09/1994 JLB : Created. *
*=============================================================================================*/
void HouseClass::One_Time(void)
{
BuildChoice.Set_Heap(STRUCT_COUNT);
}
/***********************************************************************************************
* HouseClass::Assign_Handicap -- Assigns the specified handicap rating to the house. *
* *
* The handicap rating will affect combat, movement, and production for the house. It can *
* either make it more or less difficult for the house (controlled by the handicap value). *
* *
* INPUT: handicap -- The handicap value to assign to this house. The default value for *
* a house is DIFF_NORMAL. *
* *
* OUTPUT: Returns with the old handicap value. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 07/09/1996 JLB : Created. *
* 10/22/1996 JLB : Uses act like value for multiplay only. *
*=============================================================================================*/
DiffType HouseClass::Assign_Handicap(DiffType handicap)
{
DiffType old = Difficulty;
Difficulty = handicap;
if (Session.Type != GAME_NORMAL) {
HouseTypeClass const * hptr = &HouseTypeClass::As_Reference(ActLike);
FirepowerBias = hptr->FirepowerBias * Rule.Diff[handicap].FirepowerBias;
GroundspeedBias = hptr->GroundspeedBias * Rule.Diff[handicap].GroundspeedBias * Rule.GameSpeedBias;
AirspeedBias = hptr->AirspeedBias * Rule.Diff[handicap].AirspeedBias * Rule.GameSpeedBias;
ArmorBias = hptr->ArmorBias * Rule.Diff[handicap].ArmorBias;
ROFBias = hptr->ROFBias * Rule.Diff[handicap].ROFBias;
CostBias = hptr->CostBias * Rule.Diff[handicap].CostBias;
RepairDelay = Rule.Diff[handicap].RepairDelay;
BuildDelay = Rule.Diff[handicap].BuildDelay;
BuildSpeedBias = hptr->BuildSpeedBias * Rule.Diff[handicap].BuildSpeedBias * Rule.GameSpeedBias;
} else {
FirepowerBias = Rule.Diff[handicap].FirepowerBias;
GroundspeedBias = Rule.Diff[handicap].GroundspeedBias * Rule.GameSpeedBias;
AirspeedBias = Rule.Diff[handicap].AirspeedBias * Rule.GameSpeedBias;
ArmorBias = Rule.Diff[handicap].ArmorBias;
ROFBias = Rule.Diff[handicap].ROFBias;
CostBias = Rule.Diff[handicap].CostBias;
RepairDelay = Rule.Diff[handicap].RepairDelay;
BuildDelay = Rule.Diff[handicap].BuildDelay;
BuildSpeedBias = Rule.Diff[handicap].BuildSpeedBias * Rule.GameSpeedBias;
}
return(old);
}
#ifdef CHEAT_KEYS
void HouseClass::Print_Zone_Stats(int x, int y, ZoneType zone, MonoClass * mono) const
{
mono->Set_Cursor(x, y);
mono->Printf("A:%-5d I:%-5d V:%-5d", ZoneInfo[zone].AirDefense, ZoneInfo[zone].InfantryDefense, ZoneInfo[zone].ArmorDefense);
}
/***********************************************************************************************
* HouseClass::Debug_Dump -- Dumps the house status data to the mono screen. *
* *
* This utility function will output the current status of the house class to the mono *
* screen. Through this information bugs may be fixed or detected. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 05/31/1994 JLB : Created. *
*=============================================================================================*/
void HouseClass::Debug_Dump(MonoClass * mono) const
{
mono->Set_Cursor(0, 0);
mono->Print(Text_String(TXT_DEBUG_HOUSE));
mono->Set_Cursor(1, 1);mono->Printf("[%d]%14.14s", Class->House, Name());
mono->Set_Cursor(20, 1);mono->Printf("[%d]%13.13s", ActLike, HouseTypeClass::As_Reference(ActLike).Name());
mono->Set_Cursor(39, 1);mono->Printf("%2d", Control.TechLevel);
mono->Set_Cursor(45, 1);mono->Printf("%2d", Difficulty);
mono->Set_Cursor(52, 1);mono->Printf("%2d", State);
mono->Set_Cursor(58, 1);mono->Printf("%2d", Blockage);
mono->Set_Cursor(65, 1);mono->Printf("%2d", IQ);
mono->Set_Cursor(72, 1);mono->Printf("%5d", (long)RepairTimer);
mono->Set_Cursor(1, 3);mono->Printf("%08X", AScan);
mono->Set_Cursor(10, 3);mono->Printf("%8.8s", (BuildAircraft == AIRCRAFT_NONE) ? " " : AircraftTypeClass::As_Reference(BuildAircraft).Graphic_Name());
mono->Set_Cursor(21, 3);mono->Printf("%3d", CurAircraft);
mono->Set_Cursor(27, 3);mono->Printf("%8d", Credits);
mono->Set_Cursor(37, 3);mono->Printf("%5d", Power);
mono->Set_Cursor(45, 3);mono->Printf("%04X", RadarSpied);
mono->Set_Cursor(52, 3);mono->Printf("%5d", PointTotal);
mono->Set_Cursor(62, 3);mono->Printf("%5d", (long)TeamTime);
mono->Set_Cursor(71, 3);mono->Printf("%5d", (long)AlertTime);
mono->Set_Cursor(1, 5);mono->Printf("%08X", BScan);
mono->Set_Cursor(10, 5);mono->Printf("%8.8s", (BuildStructure == STRUCT_NONE) ? " " : BuildingTypeClass::As_Reference(BuildStructure).Graphic_Name());
mono->Set_Cursor(21, 5);mono->Printf("%3d", CurBuildings);
mono->Set_Cursor(27, 5);mono->Printf("%8d", Tiberium);
mono->Set_Cursor(37, 5);mono->Printf("%5d", Drain);
mono->Set_Cursor(44, 5);mono->Printf("%16.16s", QuarryName[PreferredTarget]);
mono->Set_Cursor(62, 5);mono->Printf("%5d", (long)TriggerTime);
mono->Set_Cursor(71, 5);mono->Printf("%5d", (long)BorrowedTime);
mono->Set_Cursor(1, 7);mono->Printf("%08X", UScan);
mono->Set_Cursor(10, 7);mono->Printf("%8.8s", (BuildUnit == UNIT_NONE) ? " " : UnitTypeClass::As_Reference(BuildUnit).Graphic_Name());
mono->Set_Cursor(21, 7);mono->Printf("%3d", CurUnits);
mono->Set_Cursor(27, 7);mono->Printf("%8d", Control.InitialCredits);
mono->Set_Cursor(38, 7);mono->Printf("%5d", UnitsLost);
mono->Set_Cursor(44, 7);mono->Printf("%08X", Allies);
mono->Set_Cursor(71, 7);mono->Printf("%5d", (long)Attack);
mono->Set_Cursor(1, 9);mono->Printf("%08X", IScan);
mono->Set_Cursor(10, 9);mono->Printf("%8.8s", (BuildInfantry == INFANTRY_NONE) ? " " : InfantryTypeClass::As_Reference(BuildInfantry).Graphic_Name());
mono->Set_Cursor(21, 9);mono->Printf("%3d", CurInfantry);
mono->Set_Cursor(27, 9);mono->Printf("%8d", Capacity);
mono->Set_Cursor(38, 9);mono->Printf("%5d", BuildingsLost);
mono->Set_Cursor(45, 9);mono->Printf("%4d", Radius / CELL_LEPTON_W);
mono->Set_Cursor(71, 9);mono->Printf("%5d", (long)AITimer);
mono->Set_Cursor(1, 11);mono->Printf("%08X", VScan);
mono->Set_Cursor(10, 11);mono->Printf("%8.8s", (BuildVessel == VESSEL_NONE) ? " " : VesselTypeClass::As_Reference(BuildVessel).Graphic_Name());
mono->Set_Cursor(21, 11);mono->Printf("%3d", CurVessels);
mono->Set_Cursor(54, 11);mono->Printf("%04X", Coord_Cell(Center));
mono->Set_Cursor(71, 11);mono->Printf("%5d", (long)DamageTime);
for (int index = 0; index < ARRAY_SIZE(Scen.GlobalFlags); index++) {
mono->Set_Cursor(1+index, 15);
if (Scen.GlobalFlags[index] != 0) {
mono->Print("1");
} else {
mono->Print("0");
}
if (index >= 24) break;
}
if (Enemy != HOUSE_NONE) {
char const * name = "";
name = HouseClass::As_Pointer(Enemy)->Name();
mono->Set_Cursor(53, 15);mono->Printf("[%d]%21.21s", Enemy, HouseTypeClass::As_Reference(Enemy).Name());
}
Print_Zone_Stats(27, 11, ZONE_NORTH, mono);
Print_Zone_Stats(27, 13, ZONE_CORE, mono);
Print_Zone_Stats(27, 15, ZONE_SOUTH, mono);
Print_Zone_Stats(1, 13, ZONE_WEST, mono);
Print_Zone_Stats(53, 13, ZONE_EAST, mono);
mono->Fill_Attrib(1, 17, 12, 1, IsActive ? MonoClass::INVERSE : MonoClass::NORMAL);
mono->Fill_Attrib(1, 18, 12, 1, IsHuman ? MonoClass::INVERSE : MonoClass::NORMAL);
mono->Fill_Attrib(1, 19, 12, 1, IsPlayerControl ? MonoClass::INVERSE : MonoClass::NORMAL);
mono->Fill_Attrib(1, 20, 12, 1, IsAlerted ? MonoClass::INVERSE : MonoClass::NORMAL);
mono->Fill_Attrib(1, 21, 12, 1, IsDiscovered ? MonoClass::INVERSE : MonoClass::NORMAL);
mono->Fill_Attrib(1, 22, 12, 1, IsMaxedOut ? MonoClass::INVERSE : MonoClass::NORMAL);
mono->Fill_Attrib(14, 17, 12, 1, IsDefeated ? MonoClass::INVERSE : MonoClass::NORMAL);
mono->Fill_Attrib(14, 18, 12, 1, IsToDie ? MonoClass::INVERSE : MonoClass::NORMAL);
mono->Fill_Attrib(14, 19, 12, 1, IsToWin ? MonoClass::INVERSE : MonoClass::NORMAL);
mono->Fill_Attrib(14, 20, 12, 1, IsToLose ? MonoClass::INVERSE : MonoClass::NORMAL);
mono->Fill_Attrib(14, 21, 12, 1, IsCivEvacuated ? MonoClass::INVERSE : MonoClass::NORMAL);
mono->Fill_Attrib(14, 22, 12, 1, IsRecalcNeeded ? MonoClass::INVERSE : MonoClass::NORMAL);
mono->Fill_Attrib(27, 17, 12, 1, IsVisionary ? MonoClass::INVERSE : MonoClass::NORMAL);
mono->Fill_Attrib(27, 18, 12, 1, IsTiberiumShort ? MonoClass::INVERSE : MonoClass::NORMAL);
mono->Fill_Attrib(27, 19, 12, 1, IsSpied ? MonoClass::INVERSE : MonoClass::NORMAL);
mono->Fill_Attrib(27, 20, 12, 1, IsThieved ? MonoClass::INVERSE : MonoClass::NORMAL);
mono->Fill_Attrib(27, 21, 12, 1, IsGPSActive ? MonoClass::INVERSE : MonoClass::NORMAL);
mono->Fill_Attrib(27, 22, 12, 1, IsStarted ? MonoClass::INVERSE : MonoClass::NORMAL);
mono->Fill_Attrib(40, 17, 12, 1, IsResigner ? MonoClass::INVERSE : MonoClass::NORMAL);
mono->Fill_Attrib(40, 18, 12, 1, IsGiverUpper ? MonoClass::INVERSE : MonoClass::NORMAL);
mono->Fill_Attrib(40, 19, 12, 1, IsBuiltSomething ? MonoClass::INVERSE : MonoClass::NORMAL);
mono->Fill_Attrib(40, 20, 12, 1, IsBaseBuilding ? MonoClass::INVERSE : MonoClass::NORMAL);
}
#endif
/***********************************************************************************************
* HouseClass::new -- Allocator for a house class. *
* *
* This is the allocator for a house class. Since there can be only *
* one of each type of house, this is allocator has restricted *
* functionality. Any attempt to allocate a house structure for a *
* house that already exists, just returns a pointer to the previously *
* allocated house. *
* *
* INPUT: house -- The house to allocate a class object for. *
* *
* OUTPUT: Returns with a pointer to the allocated class object. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 05/22/1994 JLB : Created. *
*=============================================================================================*/
void * HouseClass::operator new(size_t)
{
void * ptr = Houses.Allocate();
if (ptr) {
((HouseClass *)ptr)->IsActive = true;
}
return(ptr);
}
/***********************************************************************************************
* HouseClass::delete -- Deallocator function for a house object. *
* *
* This function marks the house object as "deallocated". Such a *
* house object is available for reallocation later. *
* *
* INPUT: ptr -- Pointer to the house object to deallocate. *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 05/22/1994 JLB : Created. *
*=============================================================================================*/
void HouseClass::operator delete(void * ptr)
{
if (ptr) {
((HouseClass *)ptr)->IsActive = false;
}
Houses.Free((HouseClass *)ptr);
}
/***********************************************************************************************
* HouseClass::HouseClass -- Constructor for a house object. *
* *
* This function is the constructor and it marks the house object *
* as being allocated. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 05/22/1994 JLB : Created. *
*=============================================================================================*/
#define VOX_NOT_READY VOX_NONE
HouseClass::HouseClass(HousesType house) :
RTTI(RTTI_HOUSE),
ID(Houses.ID(this)),
Class(HouseTypes.Ptr(house)),
Difficulty(Scen.CDifficulty),
FirepowerBias(1),
GroundspeedBias(1),
AirspeedBias(1),
ArmorBias(1),
ROFBias(1),
CostBias(1),
BuildSpeedBias(1),
RepairDelay(0),
BuildDelay(0),
ActLike(Class->House),
IsHuman(false),
WasHuman(false),
IsPlayerControl(false),
IsStarted(false),
IsAlerted(false),
IsBaseBuilding(false),
IsDiscovered(false),
IsMaxedOut(false),
IsDefeated(false),
IsToDie(false),
IsToLose(false),
IsToWin(false),
IsCivEvacuated(false),
IsRecalcNeeded(true),
IsVisionary(false),
IsTiberiumShort(false),
IsSpied(false),
IsThieved(false),
IsGPSActive(false),
IsBuiltSomething(false),
IsResigner(false),
IsGiverUpper(false),
IsParanoid(false),
IsToLook(true),
IsQueuedMovementToggle(false),
DidRepair(false),
IQ(Control.IQ),
State(STATE_BUILDUP),
JustBuiltStructure(STRUCT_NONE),
JustBuiltInfantry(INFANTRY_NONE),
JustBuiltUnit(UNIT_NONE),
JustBuiltAircraft(AIRCRAFT_NONE),
JustBuiltVessel(VESSEL_NONE),
Blockage(0),
RepairTimer(0),
AlertTime(0),
BorrowedTime(0),
BScan(0),
ActiveBScan(0),
OldBScan(0),
UScan(0),
ActiveUScan(0),
OldUScan(0),
IScan(0),
ActiveIScan(0),
OldIScan(0),
AScan(0),
ActiveAScan(0),
OldAScan(0),
VScan(0),
ActiveVScan(0),
OldVScan(0),
CreditsSpent(0),
HarvestedCredits(0),
StolenBuildingsCredits(0),
CurUnits(0),
CurBuildings(0),
CurInfantry(0),
CurVessels(0),
CurAircraft(0),
Tiberium(0),
Credits(0),
Capacity(0),
AircraftTotals(NULL),
InfantryTotals(NULL),
UnitTotals(NULL),
BuildingTotals(NULL),
VesselTotals(NULL),
DestroyedAircraft(NULL),
DestroyedInfantry(NULL),
DestroyedUnits(NULL),
DestroyedBuildings(NULL),
DestroyedVessels(NULL),
CapturedBuildings(NULL),
TotalCrates(NULL),
AircraftFactories(0),
InfantryFactories(0),
UnitFactories(0),
BuildingFactories(0),
VesselFactories(0),
Power(0),
Drain(0),
AircraftFactory(-1),
InfantryFactory(-1),
UnitFactory(-1),
BuildingFactory(-1),
VesselFactory(-1),
Radar(RADAR_NONE),
FlagLocation(TARGET_NONE),
FlagHome(0),
UnitsLost(0),
BuildingsLost(0),
WhoLastHurtMe(house),
StartLocationOverride(-1),
Center(0),
Radius(0),
LATime(0),
LAType(RTTI_NONE),
LAZone(ZONE_NONE),
LAEnemy(HOUSE_NONE),
ToCapture(TARGET_NONE),
RadarSpied(0),
PointTotal(0),
PreferredTarget(QUARRY_ANYTHING),
ScreenShakeTime(0),
Attack(0),
Enemy(HOUSE_NONE),
AITimer(0),
UnitToTeleport(0),
BuildStructure(STRUCT_NONE),
BuildUnit(UNIT_NONE),
BuildInfantry(INFANTRY_NONE),
BuildAircraft(AIRCRAFT_NONE),
BuildVessel(VESSEL_NONE),
NukeDest(0),
Allies(0),
DamageTime(TICKS_PER_MINUTE * Rule.DamageDelay),
TeamTime(TICKS_PER_MINUTE * Rule.TeamDelay),
TriggerTime(0),
SpeakAttackDelay(1),
SpeakPowerDelay(1),
SpeakMoneyDelay(1),
SpeakMaxedDelay(1),
RemapColor(Class->RemapColor),
DebugUnlockBuildables(false)
{
/*
** Explicit in-place construction of the super weapons is
** required here because the default constructor for super
** weapons must serve as a no-initialization constructor (save/load reasons).
*/
new (&SuperWeapon[SPC_NUCLEAR_BOMB]) SuperClass(TICKS_PER_MINUTE * Rule.NukeTime, true, VOX_ABOMB_PREPPING, VOX_ABOMB_READY, VOX_NOT_READY, VOX_INSUFFICIENT_POWER);
new (&SuperWeapon[SPC_SONAR_PULSE]) SuperClass(TICKS_PER_MINUTE * Rule.SonarTime, false, VOX_NONE, VOX_SONAR_AVAILABLE, VOX_NOT_READY, VOX_NOT_READY);
new (&SuperWeapon[SPC_CHRONOSPHERE]) SuperClass(TICKS_PER_MINUTE * Rule.ChronoTime, true, VOX_CHRONO_CHARGING, VOX_CHRONO_READY, VOX_NOT_READY, VOX_INSUFFICIENT_POWER);
new (&SuperWeapon[SPC_PARA_BOMB]) SuperClass(TICKS_PER_MINUTE * Rule.ParaBombTime, false, VOX_NONE, VOX_NONE, VOX_NOT_READY, VOX_NOT_READY);
new (&SuperWeapon[SPC_PARA_INFANTRY]) SuperClass(TICKS_PER_MINUTE * Rule.ParaInfantryTime, false, VOX_NONE, VOX_NONE, VOX_NOT_READY, VOX_NOT_READY);
new (&SuperWeapon[SPC_SPY_MISSION]) SuperClass(TICKS_PER_MINUTE * Rule.SpyTime, false, VOX_NONE, VOX_SPY_PLANE, VOX_NOT_READY, VOX_NOT_READY);
new (&SuperWeapon[SPC_IRON_CURTAIN]) SuperClass(TICKS_PER_MINUTE * Rule.IronCurtainTime, true, VOX_IRON_CHARGING, VOX_IRON_READY, VOX_NOT_READY, VOX_INSUFFICIENT_POWER);
new (&SuperWeapon[SPC_GPS]) SuperClass(TICKS_PER_MINUTE * Rule.GPSTime, true, VOX_NONE, VOX_NONE, VOX_NOT_READY, VOX_INSUFFICIENT_POWER);
memset(UnitsKilled, '\0', sizeof(UnitsKilled));
memset(BuildingsKilled, '\0', sizeof(BuildingsKilled));
memset(BQuantity, '\0', sizeof(BQuantity));
memset(UQuantity, '\0', sizeof(UQuantity));
memset(IQuantity, '\0', sizeof(IQuantity));
memset(AQuantity, '\0', sizeof(AQuantity));
memset(VQuantity, '\0', sizeof(VQuantity));
strcpy(IniName, Text_String(TXT_COMPUTER)); // Default computer name.
HouseTriggers[house].Clear();
memset((void *)&Regions[0], 0x00, sizeof(Regions));
Make_Ally(house);
Assign_Handicap(Scen.CDifficulty);
/*
** Set the time of the first AI attack.
*/
Attack = Rule.AttackDelay * Random_Pick(TICKS_PER_MINUTE/2, TICKS_PER_MINUTE*2);
Init_Unit_Trackers();
}
/***********************************************************************************************
* HouseClass::~HouseClass -- House class destructor *
* *
* *
* *
* INPUT: Nothing *
* *
* OUTPUT: Nothing *
* *
* WARNINGS: None *
* *
* HISTORY: *
* 8/6/96 4:48PM ST : Created *
*=============================================================================================*/
HouseClass::~HouseClass (void)
{
Class = 0;
Free_Unit_Trackers();
}
/***********************************************************************************************
* HouseStaticClass::HouseStaticClass -- Default constructor for house static class. *
* *
* This is the default constructor that initializes all the values to their default *
* settings. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 07/31/1996 JLB : Created. *
*=============================================================================================*/
HouseStaticClass::HouseStaticClass(void) :
IQ(0),
TechLevel(1),
Allies(0),
MaxUnit(Rule.UnitMax/6),
MaxBuilding(Rule.BuildingMax/6),
MaxInfantry(Rule.InfantryMax/6),
MaxVessel(Rule.VesselMax/6),
MaxAircraft(Rule.UnitMax/6),
InitialCredits(0),
Edge(SOURCE_NORTH)
{
}
/***********************************************************************************************
* HouseClass::Can_Build -- General purpose build legality checker. *
* *
* This routine is called when it needs to be determined if the specified object type can *
* be built by this house. Production and sidebar maintenance use this routine heavily. *
* *
* INPUT: type -- Pointer to the type of object that legality is to be checked for. *
* *
* house -- This is the house to check for legality against. Note that this might *
* not be 'this' house since the check could be from a captured factory. *
* Captured factories build what the original owner of them could build. *
* *
* OUTPUT: Can the specified object be built? *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 07/04/1995 JLB : Created. *
* 08/12/1995 JLB : Updated for GDI building sandbag walls in #9. *
* 10/23/1996 JLB : Hack to allow Tanya to both sides in multiplay. *
* 11/04/1996 JLB : Computer uses prerequisite record. *
*=============================================================================================*/
bool HouseClass::Can_Build(ObjectTypeClass const * type, HousesType house) const
{
assert(Houses.ID(this) == ID);
assert(type != NULL);
/*
** An object with a prohibited tech level availability will never be allowed, regardless
** of who requests it.
*/
if (((TechnoTypeClass const *)type)->Level == -1) return(false);
#ifdef FIXIT_CSII // checked - ajw 9/28/98
/*
** If this is a CounterStrike II-only unit, and we're playing a multiplayer
** game in 'downshifted' mode against CounterStrike or Red Alert, then
** don't allow building this unit.
*/
if (!NewUnitsEnabled) {
switch(type->What_Am_I()) {
case RTTI_INFANTRYTYPE:
if ( ((InfantryTypeClass *)type)->ID >= INFANTRY_RA_COUNT)
return(false);
break;
case RTTI_UNITTYPE:
if ( ((UnitTypeClass *)type)->ID >= UNIT_RA_COUNT)
return(false);
break;
case RTTI_VESSELTYPE:
if ( ((VesselTypeClass *)type)->ID >= VESSEL_RA_COUNT)
return(false);
break;
default:
break;
}
}
#endif
/*
** The computer can always build everything.
*/
if (!IsHuman && Session.Type == GAME_NORMAL) return(true);
/*
** Special hack to get certain objects to exist for both sides in the game.
*/
int own = type->Get_Ownable();
/*
** Check to see if this owner can build the object type specified.
*/
if (((1L << house) & own) == 0) {
return(false);
}
/*
** Perform some equivalency fixups for the building existence flags.
*/
long flags = ActiveBScan;
/*
** The computer records prerequisite buildings because it can't relay on the
** sidebar to keep track of this information.
*/
if (!IsHuman) {
flags = OldBScan;
}
int pre = ((TechnoTypeClass const *)type)->Prerequisite;
/*
** Advanced power also serves as a prerequisite for normal power.
*/
if (flags & STRUCTF_ADVANCED_POWER) flags |= STRUCTF_POWER;
/*
** Either tech center counts as a prerequisite.
*/
if (Session.Type != GAME_NORMAL) {
if ((flags & (STRUCTF_SOVIET_TECH|STRUCTF_ADVANCED_TECH)) != 0) flags |= STRUCTF_SOVIET_TECH|STRUCTF_ADVANCED_TECH;
}
int level = Control.TechLevel;
#ifdef CHEAT_KEYS
if (Debug_Cheat) {
level = 98;
pre = 0;
}
#endif
// ST - 8/23/2019 4:53PM
if (DebugUnlockBuildables) {
level = 98;
pre = 0;
}
/*
** See if the prerequisite requirements have been met.
*/
return((pre & flags) == pre && ((TechnoTypeClass const *)type)->Level <= (unsigned)level);
}
/***************************************************************************
* HouseClass::Init -- init's in preparation for new scenario *
* *
* INPUT: *
* none. *
* *
* OUTPUT: *
* none. *
* *
* WARNINGS: *
* none. *
* *
* HISTORY: *
* 12/07/1994 BR : Created. *
* 12/17/1994 JLB : Resets tracker bits. *
*=========================================================================*/
void HouseClass::Init(void)
{
Houses.Free_All();
for (HousesType index = HOUSE_FIRST; index < HOUSE_COUNT; index++) {
HouseTriggers[index].Clear();
}
}
// Object selection list is switched with player context for GlyphX. ST - 8/7/2019 10:11AM
extern void Logic_Switch_Player_Context(HouseClass *house);
extern bool MPSuperWeaponDisable;
/***********************************************************************************************
* HouseClass::AI -- Process house logic. *
* *
* This handles the AI for the house object. It should be called once per house per game *
* tick. It processes all house global tasks such as low power damage accumulation and *
* house specific trigger events. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 12/27/1994 JLB : Created. *
* 07/17/1995 JLB : Limits EVA speaking unless the player can do something. *
*=============================================================================================*/
extern void Recalculate_Placement_Distances();
void HouseClass::AI(void)
{
assert(Houses.ID(this) == ID);
// Set PlayerPtr to be this house. ST - 8/7/2019 10:12AM
Logic_Switch_Player_Context(this);
/*
** If base building has been turned on by a trigger, then force the house to begin
** production and team creation as well. This is also true if the IQ is high enough to
** being base building.
*/
if (!IsHuman && (IsBaseBuilding || IQ >= Rule.IQProduction)) {
IsBaseBuilding = true;
IsStarted = true;
IsAlerted = true;
}
/*
** Check to see if the house wins.
*/
if (Session.Type == GAME_NORMAL && IsToWin && BorrowedTime == 0 && Blockage <= 0) {
IsToWin = false;
if (this == PlayerPtr) {
PlayerWins = true;
} else {
PlayerLoses = true;
}
}
/*
** Check to see if the house loses.
*/
if (Session.Type == GAME_NORMAL && IsToLose && BorrowedTime == 0) {
IsToLose = false;
if (this == PlayerPtr) {
PlayerLoses = true;
} else {
PlayerWins = true;
}
}
/*
** Check to see if all objects of this house should be blown up.
*/
if (IsToDie && BorrowedTime == 0) {
IsToDie = false;
Blowup_All();
if (Session.Type == GAME_GLYPHX_MULTIPLAYER) {
MPlayer_Defeated();
}
}
/*
** Double check power values to correct illegal conditions. It is possible to
** get a power output of negative (one usually) as a result of damage sustained
** and the fixed point fractional math involved with power adjustments. If the
** power rating drops below zero, then make it zero.
*/
Power = max(Power, 0);
Drain = max(Drain, 0);
/*
** If the base has been alerted to the enemy and should be attacking, then
** see if the attack timer has expired. If it has, then create the attack
** teams.
*/
if (IsAlerted && AlertTime == 0) {
/*
** Adjusted to reduce maximum number of teams created.
*/
int maxteams = Random_Pick(2, (int)(((Control.TechLevel-1)/3)+1));
for (int index = 0; index < maxteams; index++) {
TeamTypeClass const * ttype = Suggested_New_Team(true);
if (ttype != NULL) {
ScenarioInit++;
ttype->Create_One_Of();
ScenarioInit--;
}
}
AlertTime = Rule.AutocreateTime * Random_Pick(TICKS_PER_MINUTE/2, TICKS_PER_MINUTE*2);
// int mintime = Rule.AutocreateTime * (TICKS_PER_MINUTE/2);
// int maxtime = Rule.AutocreateTime * (TICKS_PER_MINUTE*2);
// AlertTime = Random_Pick(mintime, maxtime);
}
/*
** If this house's flag waypoint is a valid cell, see if there's