CARRY.CPP (7406B)
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: /CounterStrike/CARRY.CPP 1 3/03/97 10:24a 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 : CARRY.CPP * 24 * * 25 * Programmer : Joe L. Bostic * 26 * * 27 * Start Date : 02/26/96 * 28 * * 29 * Last Update : May 10, 1996 [JLB] * 30 * * 31 *---------------------------------------------------------------------------------------------* 32 * Functions: * 33 * CarryoverClass::CarryoverClass -- Constructor for carry over objects. * 34 * CarryoverClass::Create -- Creates a carried over object. * 35 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 36 37 38 #include "function.h" 39 40 41 /*********************************************************************************************** 42 * CarryoverClass::CarryoverClass -- Constructor for carry over objects. * 43 * * 44 * This is the constructor for a carry over object. Such an object is used to record the * 45 * object that will be "carried over" into a new scenario at some future time. * 46 * * 47 * INPUT: techno -- Pointer to the object that will be carried over. * 48 * * 49 * OUTPUT: none * 50 * * 51 * WARNINGS: none * 52 * * 53 * HISTORY: * 54 * 05/10/1996 JLB : Created. * 55 *=============================================================================================*/ 56 CarryoverClass::CarryoverClass(TechnoClass * techno) : 57 RTTI(RTTI_NONE), 58 Cell(0), 59 Strength(0), 60 House(HOUSE_NONE) 61 { 62 if (techno) { 63 RTTI = techno->What_Am_I(); 64 65 switch (RTTI) { 66 case RTTI_UNIT: 67 Type.Unit = ((UnitClass *)techno)->Class->Type; 68 break; 69 70 case RTTI_BUILDING: 71 Type.Building = ((BuildingClass *)techno)->Class->Type; 72 break; 73 74 case RTTI_INFANTRY: 75 Type.Infantry = ((InfantryClass *)techno)->Class->Type; 76 break; 77 78 case RTTI_VESSEL: 79 Type.Vessel = ((VesselClass *)techno)->Class->Type; 80 break; 81 82 default: 83 break; 84 } 85 86 House = techno->Owner(); 87 Strength = techno->Strength; 88 Cell = Coord_Cell(techno->Coord); 89 } 90 } 91 92 93 /*********************************************************************************************** 94 * CarryoverClass::Create -- Creates a carried over object. * 95 * * 96 * Use this routine to convert a carried over object into an actual object that will be * 97 * placed on the map. * 98 * * 99 * INPUT: none * 100 * * 101 * OUTPUT: bool; Was the object successfully created and placed on the map? * 102 * * 103 * WARNINGS: This routine might not place the object if the old map location was invalid * 104 * or there are other barriers to the object's creation and placement. * 105 * * 106 * HISTORY: * 107 * 05/10/1996 JLB : Created. * 108 *=============================================================================================*/ 109 bool CarryoverClass::Create(void) const 110 { 111 TechnoClass * techno = 0; 112 TechnoTypeClass const * ttype = 0; 113 114 switch (RTTI) { 115 case RTTI_UNIT: 116 ttype = &UnitTypeClass::As_Reference(Type.Unit); 117 techno = new UnitClass(Type.Unit, House); 118 break; 119 120 case RTTI_INFANTRY: 121 ttype = &InfantryTypeClass::As_Reference(Type.Infantry); 122 techno = new InfantryClass(Type.Infantry, House); 123 break; 124 125 case RTTI_BUILDING: 126 ttype = &BuildingTypeClass::As_Reference(Type.Building); 127 techno = new BuildingClass(Type.Building, House); 128 break; 129 130 case RTTI_VESSEL: 131 ttype = &VesselTypeClass::As_Reference(Type.Vessel); 132 techno = new VesselClass(Type.Vessel, House); 133 break; 134 } 135 136 if (techno) { 137 bool oldscen = ScenarioInit; 138 techno->Strength = Strength; 139 if (RTTI == RTTI_INFANTRY) { 140 ScenarioInit = 0; 141 } 142 techno->Unlimbo(Cell_Coord(Cell)); 143 if (RTTI == RTTI_INFANTRY) { 144 ScenarioInit = oldscen; 145 } 146 } 147 148 return(false); 149 } 150