CARRY.CPP 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. ** Command & Conquer Red Alert(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /* $Header: /CounterStrike/CARRY.CPP 1 3/03/97 10:24a Joe_bostic $ */
  19. /***********************************************************************************************
  20. *** 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 ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Command & Conquer *
  24. * *
  25. * File Name : CARRY.CPP *
  26. * *
  27. * Programmer : Joe L. Bostic *
  28. * *
  29. * Start Date : 02/26/96 *
  30. * *
  31. * Last Update : May 10, 1996 [JLB] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * CarryoverClass::CarryoverClass -- Constructor for carry over objects. *
  36. * CarryoverClass::Create -- Creates a carried over object. *
  37. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  38. #include "function.h"
  39. /***********************************************************************************************
  40. * CarryoverClass::CarryoverClass -- Constructor for carry over objects. *
  41. * *
  42. * This is the constructor for a carry over object. Such an object is used to record the *
  43. * object that will be "carried over" into a new scenario at some future time. *
  44. * *
  45. * INPUT: techno -- Pointer to the object that will be carried over. *
  46. * *
  47. * OUTPUT: none *
  48. * *
  49. * WARNINGS: none *
  50. * *
  51. * HISTORY: *
  52. * 05/10/1996 JLB : Created. *
  53. *=============================================================================================*/
  54. CarryoverClass::CarryoverClass(TechnoClass * techno) :
  55. RTTI(RTTI_NONE),
  56. Cell(0),
  57. Strength(0),
  58. House(HOUSE_NONE)
  59. {
  60. if (techno) {
  61. RTTI = techno->What_Am_I();
  62. switch (RTTI) {
  63. case RTTI_UNIT:
  64. Type.Unit = ((UnitClass *)techno)->Class->Type;
  65. break;
  66. case RTTI_BUILDING:
  67. Type.Building = ((BuildingClass *)techno)->Class->Type;
  68. break;
  69. case RTTI_INFANTRY:
  70. Type.Infantry = ((InfantryClass *)techno)->Class->Type;
  71. break;
  72. case RTTI_VESSEL:
  73. Type.Vessel = ((VesselClass *)techno)->Class->Type;
  74. break;
  75. default:
  76. break;
  77. }
  78. House = techno->Owner();
  79. Strength = techno->Strength;
  80. Cell = Coord_Cell(techno->Coord);
  81. }
  82. }
  83. /***********************************************************************************************
  84. * CarryoverClass::Create -- Creates a carried over object. *
  85. * *
  86. * Use this routine to convert a carried over object into an actual object that will be *
  87. * placed on the map. *
  88. * *
  89. * INPUT: none *
  90. * *
  91. * OUTPUT: bool; Was the object successfully created and placed on the map? *
  92. * *
  93. * WARNINGS: This routine might not place the object if the old map location was invalid *
  94. * or there are other barriers to the object's creation and placement. *
  95. * *
  96. * HISTORY: *
  97. * 05/10/1996 JLB : Created. *
  98. *=============================================================================================*/
  99. bool CarryoverClass::Create(void) const
  100. {
  101. TechnoClass * techno = 0;
  102. TechnoTypeClass const * ttype = 0;
  103. switch (RTTI) {
  104. case RTTI_UNIT:
  105. ttype = &UnitTypeClass::As_Reference(Type.Unit);
  106. techno = new UnitClass(Type.Unit, House);
  107. break;
  108. case RTTI_INFANTRY:
  109. ttype = &InfantryTypeClass::As_Reference(Type.Infantry);
  110. techno = new InfantryClass(Type.Infantry, House);
  111. break;
  112. case RTTI_BUILDING:
  113. ttype = &BuildingTypeClass::As_Reference(Type.Building);
  114. techno = new BuildingClass(Type.Building, House);
  115. break;
  116. case RTTI_VESSEL:
  117. ttype = &VesselTypeClass::As_Reference(Type.Vessel);
  118. techno = new VesselClass(Type.Vessel, House);
  119. break;
  120. }
  121. if (techno) {
  122. bool oldscen = ScenarioInit;
  123. techno->Strength = Strength;
  124. if (RTTI == RTTI_INFANTRY) {
  125. ScenarioInit = 0;
  126. }
  127. techno->Unlimbo(Cell_Coord(Cell));
  128. if (RTTI == RTTI_INFANTRY) {
  129. ScenarioInit = oldscen;
  130. }
  131. }
  132. return(false);
  133. }