CARRY.CPP 7.2 KB

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