VDATA.CPP 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  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/VDATA.CPP 1 3/03/97 10:26a 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 : VDATA.CPP *
  26. * *
  27. * Programmer : Joe L. Bostic *
  28. * *
  29. * Start Date : 03/13/96 *
  30. * *
  31. * Last Update : July 9, 1996 [JLB] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * VesselTypeClass::As_Reference -- Converts a vessel type into a VesselTypeClass reference. *
  36. * VesselTypeClass::Create_And_Place -- Creates a vessel and places it at location. *
  37. * VesselTypeClass::Create_One_Of -- Creates a vessel object that matches this vessel type. *
  38. * VesselTypeClass::Dimensions -- Fetches the pixel width and height of this vessel type. *
  39. * VesselTypeClass::Display -- Displays a generic representation of this vessel type. *
  40. * VesselTypeClass::From_Name -- Converts a name into a vessel type. *
  41. * VesselTypeClass::Init_Heap -- Initialize the vessel heap. *
  42. * VesselTypeClass::One_Time -- Performs one time initialization for vessel types. *
  43. * VesselTypeClass::Overlap_List -- Figures the overlap list for the vessel type. *
  44. * VesselTypeClass::Prep_For_Add -- Adds vessel types to the scenario editor object list. *
  45. * VesselTypeClass::Turret_Adjust -- Adjust turret offset according to facing specified. *
  46. * VesselTypeClass::VesselTypeClass -- Constructor for naval vessel types. *
  47. * VesselTypeClass::Who_Can_Build_Me -- Fetches pointer to available factory for this vessel.*
  48. * VesselTypeClass::operator delete -- Returns a vessel type object back to the memory pool. *
  49. * VesselTypeClass::operator new -- Allocate a vessel type object from the special memory poo*
  50. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  51. #include "function.h"
  52. // Submarine
  53. static VesselTypeClass const VesselSubmarine(
  54. VESSEL_SS,
  55. TXT_SS, // NAME: Text name of this unit type.
  56. "SS", // NAME: Text name of this unit type.
  57. ANIM_FBALL1, // EXPLOSION: Type of explosion when destroyed.
  58. 0x0000, // Vertical offset.
  59. 0x0000, // Primary weapon offset along turret centerline.
  60. 0x0000, // Primary weapon lateral offset along turret centerline.
  61. 0x0000, // Secondary weapon offset along turret centerline.
  62. 0x0000, // Secondary weapon lateral offset along turret centerling.
  63. false, // Only has eight facings?
  64. true, // Always use the given name for the vehicle?
  65. false, // Is it equipped with a combat turret?
  66. 8, // Rotation stages.
  67. 14 // Turret center offset along body centerline.
  68. );
  69. // Destroyer
  70. static VesselTypeClass const VesselDestroyer(
  71. VESSEL_DD,
  72. TXT_DD, // NAME: Text name of this unit type.
  73. "DD", // NAME: Text name of this unit type.
  74. ANIM_FBALL1, // EXPLOSION: Type of explosion when destroyed.
  75. 0x0000, // Vertical offset.
  76. 0x0000, // Primary weapon offset along turret centerline.
  77. 0x0000, // Primary weapon lateral offset along turret centerline.
  78. 0x0000, // Secondary weapon offset along turret centerline.
  79. 0x0000, // Secondary weapon lateral offset along turret centerling.
  80. false, // Only has eight facings?
  81. true, // Always use the given name for the vehicle?
  82. true, // Is it equipped with a combat turret?
  83. 8, // Rotation stages.
  84. 14 // Turret center offset along body centerline.
  85. );
  86. // Cruiser
  87. static VesselTypeClass const VesselCruiser(
  88. VESSEL_CA,
  89. TXT_CA, // NAME: Text name of this unit type.
  90. "CA", // NAME: Text name of this unit type.
  91. ANIM_FBALL1, // EXPLOSION: Type of explosion when destroyed.
  92. 0x0000, // Vertical offset.
  93. 0x0000, // Primary weapon offset along turret centerline.
  94. 0x0000, // Primary weapon lateral offset along turret centerline.
  95. 0x0000, // Secondary weapon offset along turret centerline.
  96. 0x0000, // Secondary weapon lateral offset along turret centerling.
  97. false, // Only has eight facings?
  98. true, // Always use the given name for the vehicle?
  99. true, // Is it equipped with a combat turret?
  100. 8, // Rotation stages.
  101. 14 // Turret center offset along body centerline.
  102. );
  103. // Transport
  104. static VesselTypeClass const VesselTransport(
  105. VESSEL_TRANSPORT,
  106. TXT_TRANSPORT, // NAME: Text name of this unit type.
  107. "LST", // NAME: Text name of this unit type.
  108. ANIM_FBALL1, // EXPLOSION: Type of explosion when destroyed.
  109. 0x0000, // Vertical offset.
  110. 0x0000, // Primary weapon offset along turret centerline.
  111. 0x0000, // Primary weapon lateral offset along turret centerline.
  112. 0x0000, // Secondary weapon offset along turret centerline.
  113. 0x0000, // Secondary weapon lateral offset along turret centerling.
  114. false, // Only has eight facings?
  115. true, // Always use the given name for the vehicle?
  116. false, // Is it equipped with a combat turret?
  117. 0, // Rotation stages.
  118. 0 // Turret center offset along body centerline.
  119. );
  120. // Gun Boat
  121. static VesselTypeClass const VesselPTBoat(
  122. VESSEL_PT,
  123. TXT_PT, // NAME: Text name of this unit type.
  124. "PT", // NAME: Text name of this unit type.
  125. ANIM_FBALL1, // EXPLOSION: Type of explosion when destroyed.
  126. 0x0000, // Vertical offset.
  127. 0x0000, // Primary weapon offset along turret centerline.
  128. 0x0000, // Primary weapon lateral offset along turret centerline.
  129. 0x0000, // Secondary weapon offset along turret centerline.
  130. 0x0000, // Secondary weapon lateral offset along turret centerling.
  131. false, // Only has eight facings?
  132. true, // Always use the given name for the vehicle?
  133. true, // Is it equipped with a combat turret?
  134. 8, // Rotation stages.
  135. 14 // Turret center offset along body centerline.
  136. );
  137. #ifdef FIXIT_CSII // checked - ajw 9/28/98
  138. // Missile Submarine
  139. static VesselTypeClass const VesselMissileSubmarine(
  140. VESSEL_MISSILESUB,
  141. TXT_MISSILESUB, // NAME: Text name of this unit type.
  142. "MSUB", // NAME: Text name of this unit type.
  143. ANIM_FBALL1, // EXPLOSION: Type of explosion when destroyed.
  144. 0x0000, // Vertical offset.
  145. 0x0000, // Primary weapon offset along turret centerline.
  146. 0x0000, // Primary weapon lateral offset along turret centerline.
  147. 0x0000, // Secondary weapon offset along turret centerline.
  148. 0x0000, // Secondary weapon lateral offset along turret centerling.
  149. false, // Only has eight facings?
  150. true, // Always use the given name for the vehicle?
  151. false, // Is it equipped with a combat turret?
  152. 8, // Rotation stages.
  153. 14 // Turret center offset along body centerline.
  154. );
  155. #endif
  156. #ifdef FIXIT_CARRIER // checked - ajw 9/28/98
  157. // Transport
  158. static VesselTypeClass const VesselCarrier(
  159. VESSEL_CARRIER,
  160. TXT_CARRIER, // NAME: Text name of this unit type.
  161. "CARR", // NAME: Text name of this unit type.
  162. ANIM_FBALL1, // EXPLOSION: Type of explosion when destroyed.
  163. 0x0000, // Vertical offset.
  164. 0x0000, // Primary weapon offset along turret centerline.
  165. 0x0000, // Primary weapon lateral offset along turret centerline.
  166. 0x0000, // Secondary weapon offset along turret centerline.
  167. 0x0000, // Secondary weapon lateral offset along turret centerling.
  168. false, // Only has eight facings?
  169. true, // Always use the given name for the vehicle?
  170. false, // Is it equipped with a combat turret?
  171. 0, // Rotation stages.
  172. 0 // Turret center offset along body centerline.
  173. );
  174. #endif
  175. /***********************************************************************************************
  176. * VesselTypeClass::VesselTypeClass -- Constructor for unit types. *
  177. * *
  178. * This is the constructor for the vessel static data. Each vessels is assign a specific *
  179. * variation. This class elaborates what the variation actually is. *
  180. * *
  181. * INPUT: bla bla bla... see below *
  182. * *
  183. * OUTPUT: none *
  184. * *
  185. * WARNINGS: none *
  186. * *
  187. * HISTORY: *
  188. * 03/14/1996 JLB : Created *
  189. *=============================================================================================*/
  190. VesselTypeClass::VesselTypeClass(
  191. VesselType type,
  192. int name,
  193. char const * ininame,
  194. AnimType exp,
  195. int verticaloffset,
  196. int primaryoffset,
  197. int primarylateral,
  198. int secondaryoffset,
  199. int secondarylateral,
  200. bool is_eight,
  201. bool is_nominal,
  202. bool is_turret_equipped,
  203. int rotation,
  204. int toffset
  205. ) :
  206. TechnoTypeClass(
  207. RTTI_VESSELTYPE,
  208. int(type),
  209. name,
  210. ininame,
  211. REMAP_NORMAL,
  212. verticaloffset,
  213. primaryoffset,
  214. primarylateral,
  215. secondaryoffset,
  216. secondarylateral,
  217. is_nominal,
  218. false,
  219. true,
  220. true,
  221. false,
  222. false,
  223. false,
  224. is_turret_equipped,
  225. true,
  226. true,
  227. rotation,
  228. SPEED_FLOAT
  229. ),
  230. IsPieceOfEight(is_eight),
  231. Type(type),
  232. TurretOffset(toffset),
  233. Mission(MISSION_GUARD),
  234. Explosion(exp),
  235. MaxSize(0)
  236. {
  237. /*
  238. ** Forced vessel overrides from the default.
  239. */
  240. IsCrew = false;
  241. Speed = SPEED_FLOAT;
  242. IsScanner = true;
  243. }
  244. /***********************************************************************************************
  245. * VesselTypeClass::operator new -- Allocate a vessel type object from the special memory pool *
  246. * *
  247. * This will allocate a vessel type class object from the memory pool. *
  248. * *
  249. * INPUT: none *
  250. * *
  251. * OUTPUT: Returns with a pointer to the allocated vessel type class object. If memory in the *
  252. * special heap has been exhaused, then NULL will be returned. *
  253. * *
  254. * WARNINGS: none *
  255. * *
  256. * HISTORY: *
  257. * 07/09/1996 JLB : Created. *
  258. *=============================================================================================*/
  259. void * VesselTypeClass::operator new(size_t)
  260. {
  261. return(VesselTypes.Alloc());
  262. }
  263. /***********************************************************************************************
  264. * VesselTypeClass::operator delete -- Returns a vessel type object back to the memory pool. *
  265. * *
  266. * This will return a previously allocated vessel object back to the special pool from *
  267. * whence it was originally allocated. *
  268. * *
  269. * INPUT: pointer -- Pointer to the vessel type object to return to the pool. *
  270. * *
  271. * OUTPUT: none *
  272. * *
  273. * WARNINGS: none *
  274. * *
  275. * HISTORY: *
  276. * 07/09/1996 JLB : Created. *
  277. *=============================================================================================*/
  278. void VesselTypeClass::operator delete(void * pointer)
  279. {
  280. VesselTypes.Free((VesselTypeClass *)pointer);
  281. }
  282. /***********************************************************************************************
  283. * VesselTypeClass::Init_Heap -- Initialize the vessel heap. *
  284. * *
  285. * This will pre-allocate all the vessel types required. *
  286. * *
  287. * INPUT: none *
  288. * *
  289. * OUTPUT: none *
  290. * *
  291. * WARNINGS: Only call this routine once and do so before processing the rules.ini file. *
  292. * *
  293. * HISTORY: *
  294. * 07/09/1996 JLB : Created. *
  295. *=============================================================================================*/
  296. void VesselTypeClass::Init_Heap(void)
  297. {
  298. /*
  299. ** These vessel type class objects must be allocated in the exact order that they
  300. ** are specified in the VesselType enumeration. This is necessary because the heap
  301. ** allocation block index serves double duty as the type number index.
  302. */
  303. new VesselTypeClass(VesselSubmarine); // VESSEL_SS
  304. new VesselTypeClass(VesselDestroyer); // VESSEL_DD
  305. new VesselTypeClass(VesselCruiser); // VESSEL_CA
  306. new VesselTypeClass(VesselTransport); // VESSEL_TRANSPORT
  307. new VesselTypeClass(VesselPTBoat); // VESSEL_PT
  308. #ifdef FIXIT_CSII // checked - ajw 9/28/98
  309. new VesselTypeClass(VesselMissileSubmarine); // VESSEL_MISSILESUB
  310. #endif
  311. #ifdef FIXIT_CARRIER // checked - ajw 9/28/98
  312. new VesselTypeClass(VesselCarrier); // VESSEL_CARRIER
  313. #endif
  314. }
  315. /***********************************************************************************************
  316. * VesselTypeClass::As_Reference -- Converts a vessel type into a VesselTypeClass reference. *
  317. * *
  318. * This routine will fetch a reference to the vessel type that corresponds to the vessel *
  319. * type specified. *
  320. * *
  321. * INPUT: type -- The vessel type number to convert. *
  322. * *
  323. * OUTPUT: Returns with a reference to the vessel type class that corresponds to the vessel *
  324. * type specified. *
  325. * *
  326. * WARNINGS: none *
  327. * *
  328. * HISTORY: *
  329. * 03/20/1996 JLB : Created. *
  330. *=============================================================================================*/
  331. VesselTypeClass & VesselTypeClass::As_Reference(VesselType type)
  332. {
  333. return(*VesselTypes.Ptr(type));
  334. }
  335. #ifdef NEVER
  336. /***********************************************************************************************
  337. * VesselTypeClass::Who_Can_Build_Me -- Fetches pointer to available factory for this vessel. *
  338. * *
  339. * Use this routine to fetch a pointer to the vessel factory that can build this vessel *
  340. * type. *
  341. * *
  342. * INPUT: intheory -- If true, then this indicates that if the factory is currently *
  343. * busy doing other things, this won't make in ineligible for searching. *
  344. * Typical use of this is by the sidebar logic which needs only to know *
  345. * if theoretical production is allowed. *
  346. * *
  347. * legal -- If true, then the buildings are checked for specific legality when *
  348. * being scanned. For building placement, this is usually false, for *
  349. * sidebar button adding, this is usually true. *
  350. * *
  351. * house -- The owner of the unit to be produced. This has an effect of legality. *
  352. * *
  353. * OUTPUT: Returns with a pointer to the factory (building) that can produce this vessel type.*
  354. * *
  355. * WARNINGS: none *
  356. * *
  357. * HISTORY: *
  358. * 03/20/1996 JLB : Created. *
  359. *=============================================================================================*/
  360. BuildingClass * VesselTypeClass::Who_Can_Build_Me(bool intheory, bool legal, HousesType house) const
  361. {
  362. BuildingClass * anybuilding = NULL;
  363. for (int index = 0; index < Buildings.Count(); index++) {
  364. BuildingClass * building = Buildings.Ptr(index);
  365. assert(building != NULL);
  366. if ( !building->IsInLimbo &&
  367. building->House->Class->House == house &&
  368. building->Class->ToBuild == RTTI_VESSELTYPE &&
  369. building->Mission != MISSION_DECONSTRUCTION &&
  370. ((1L << building->ActLike) & Ownable) &&
  371. (!legal || building->House->Can_Build(Type, building->ActLike)) &&
  372. (intheory || !building->In_Radio_Contact())) {
  373. if (building->IsLeader) return(building);
  374. anybuilding = building;
  375. }
  376. }
  377. return(anybuilding);
  378. }
  379. #endif
  380. /***********************************************************************************************
  381. * VesselTypeClass::Display -- Displays a generic representation of this vessel type. *
  382. * *
  383. * This routine is used by the scenario editor to display a representation of this *
  384. * vessel type in the object placement dialog. *
  385. * *
  386. * INPUT: x,y -- Pixel coordinate to render the center of this vessel type to. *
  387. * *
  388. * window -- The window to clip the shape to. The pixel coordinates are relative *
  389. * to this window. *
  390. * *
  391. * house -- The owner of the vessel. This is used to give the vessel its color. *
  392. * *
  393. * OUTPUT: none *
  394. * *
  395. * WARNINGS: none *
  396. * *
  397. * HISTORY: *
  398. * 03/20/1996 JLB : Created. *
  399. *=============================================================================================*/
  400. #ifdef SCENARIO_EDITOR
  401. void VesselTypeClass::Display(int x, int y, WindowNumberType window, HousesType ) const
  402. {
  403. int shape = 0;
  404. void const * ptr = Get_Cameo_Data();
  405. if (ptr == NULL) {
  406. ptr = Get_Image_Data();
  407. shape = Rotation/6;
  408. }
  409. CC_Draw_Shape(ptr, shape, x, y, window, SHAPE_CENTER|SHAPE_WIN_REL);
  410. }
  411. /***********************************************************************************************
  412. * VesselTypeClass::Prep_For_Add -- Adds vessel types to the scenario editor object list. *
  413. * *
  414. * This routine is called when the scenario editor needs to obtain a list of the *
  415. * vessel object that can be placed down. It will submit all the vessel types that can *
  416. * be placed down. *
  417. * *
  418. * INPUT: none *
  419. * *
  420. * OUTPUT: none *
  421. * *
  422. * WARNINGS: none *
  423. * *
  424. * HISTORY: *
  425. * 03/20/1996 JLB : Created. *
  426. *=============================================================================================*/
  427. void VesselTypeClass::Prep_For_Add(void)
  428. {
  429. for (VesselType index = VESSEL_FIRST; index < VESSEL_COUNT; index++) {
  430. if (As_Reference(index).Get_Image_Data() != NULL) {
  431. Map.Add_To_List(&As_Reference(index));
  432. }
  433. }
  434. }
  435. #endif //SCENARIO_EDITOR
  436. /***********************************************************************************************
  437. * VesselTypeClass::Create_One_Of -- Creates a vessel object that matches this vessel type. *
  438. * *
  439. * This routine is called when the type of vessel is known (by way of a VesselTypeClass) *
  440. * and a corresponding vessel object needs to be created. *
  441. * *
  442. * INPUT: house -- Pointer to the owner that this vessel will be assigned to. *
  443. * *
  444. * OUTPUT: Returns with a pointer to the vessel object created. If no vessel could be *
  445. * created, then NULL is returned. *
  446. * *
  447. * WARNINGS: The vessel is created in a limbo state. It must first be placed down upon *
  448. * the map before it starts to function. *
  449. * *
  450. * HISTORY: *
  451. * 03/20/1996 JLB : Created. *
  452. *=============================================================================================*/
  453. ObjectClass * VesselTypeClass::Create_One_Of(HouseClass * house) const
  454. {
  455. return(new VesselClass(Type, house->Class->House));
  456. }
  457. /***********************************************************************************************
  458. * VesselTypeClass::Create_And_Place -- Creates a vessel and places it at location. *
  459. * *
  460. * This routine is used to create a vessel and then place it down upon the *
  461. * map. *
  462. * *
  463. * INPUT: cell -- The location to place this vessel down upon. *
  464. * *
  465. * house -- The house to assign this vessel's ownership to. *
  466. * *
  467. * OUTPUT: bool; Was the vessel successfully created and placed down upon the map? *
  468. * *
  469. * WARNINGS: none *
  470. * *
  471. * HISTORY: *
  472. * 03/20/1996 JLB : Created. *
  473. *=============================================================================================*/
  474. bool VesselTypeClass::Create_And_Place(CELL cell, HousesType house) const
  475. {
  476. VesselClass * unit = new VesselClass(Type, house);
  477. if (unit != NULL) {
  478. return(unit->Unlimbo(Cell_Coord(cell), Random_Pick(DIR_N, DIR_MAX)));
  479. }
  480. delete unit;
  481. return(false);
  482. }
  483. /***********************************************************************************************
  484. * VesselTypeClass::Dimensions -- Fetches the pixel width and height of this vessel type. *
  485. * *
  486. * This routine is used to fetch the width and height of this vessel type. These dimensions *
  487. * are not specific to any particular facing. Rather, they are only for the generic vessel *
  488. * size. *
  489. * *
  490. * INPUT: width, height -- Reference to the integers that are to be initialized with the *
  491. * pixel width and height of this vessel type. *
  492. * *
  493. * OUTPUT: none *
  494. * *
  495. * WARNINGS: none *
  496. * *
  497. * HISTORY: *
  498. * 03/20/1996 JLB : Created. *
  499. *=============================================================================================*/
  500. void VesselTypeClass::Dimensions(int & width, int & height) const
  501. {
  502. width = 48;
  503. height = 48;
  504. }
  505. /***********************************************************************************************
  506. * VesselTypeClass::One_Time -- Performs one time initialization for vessel types. *
  507. * *
  508. * This routine will load in the vessel shape data. It should be called only once at the *
  509. * beginning of the game. *
  510. * *
  511. * INPUT: none *
  512. * *
  513. * OUTPUT: none *
  514. * *
  515. * WARNINGS: Only call this once. *
  516. * *
  517. * HISTORY: *
  518. * 03/20/1996 JLB : Created. *
  519. *=============================================================================================*/
  520. void VesselTypeClass::One_Time(void)
  521. {
  522. for (VesselType index = VESSEL_FIRST; index < VESSEL_COUNT; index++) {
  523. char fullname[_MAX_FNAME+_MAX_EXT];
  524. char buffer[_MAX_FNAME];
  525. VesselTypeClass const & uclass = As_Reference(index);
  526. #ifdef FIXIT_CARRIER // checked - ajw 9/28/98
  527. if (uclass.Level != -1 || index==VESSEL_CARRIER) {
  528. #else
  529. if (uclass.Level != -1) {
  530. #endif
  531. // if (uclass.IsBuildable) {
  532. /*
  533. ** Fetch the supporting data files for the unit.
  534. */
  535. sprintf(buffer, "%sICON", uclass.Graphic_Name());
  536. _makepath(fullname, NULL, NULL, buffer, ".SHP");
  537. ((void const *&)uclass.CameoData) = MFCD::Retrieve(fullname);
  538. }
  539. /*
  540. ** Fetch a pointer to the unit's shape data.
  541. */
  542. _makepath(fullname, NULL, NULL, uclass.Graphic_Name(), ".SHP");
  543. ((void const *&)uclass.ImageData) = MFCD::Retrieve(fullname);
  544. ((int &)uclass.MaxSize) = 26;
  545. }
  546. }
  547. /***********************************************************************************************
  548. * VesselTypeClass::Turret_Adjust -- Adjust turret offset according to facing specified. *
  549. * *
  550. * This routine will determine the pixel adjustment necessary for a turret. The direction *
  551. * specified is what the vessel body is facing. *
  552. * *
  553. * INPUT: dir -- The presumed direction of the body facing for the vessel. *
  554. * *
  555. * x,y -- The center pixel position for the vessel. These values should be *
  556. * adjusted (they are references) to match the adjusted offset for the *
  557. * turret. *
  558. * *
  559. * OUTPUT: none *
  560. * *
  561. * WARNINGS: none *
  562. * *
  563. * HISTORY: *
  564. * 03/20/1996 JLB : Created. *
  565. *=============================================================================================*/
  566. void VesselTypeClass::Turret_Adjust(DirType dir, int & x, int & y) const
  567. {
  568. short xx = x;
  569. short yy = y;
  570. switch (Type) {
  571. case VESSEL_CA:
  572. Normal_Move_Point(xx, yy, dir, 22);
  573. x = xx;
  574. y = yy-4;
  575. break;
  576. case VESSEL_PT:
  577. Normal_Move_Point(xx, yy, dir, 14);
  578. x = xx;
  579. y = yy+1;
  580. break;
  581. case VESSEL_DD:
  582. Normal_Move_Point(xx, yy, dir+DIR_S, 8);
  583. x = xx;
  584. y = yy-4;
  585. break;
  586. }
  587. }
  588. /***********************************************************************************************
  589. * VesselTypeClass::Overlap_List -- Figures the overlap list for the vessel type. *
  590. * *
  591. * This routine will return the overlap list for a vessel that is sitting still in the *
  592. * center of a cell. *
  593. * *
  594. * INPUT: none *
  595. * *
  596. * OUTPUT: Returns with a pointer to the overlap list that this vessel would use. *
  597. * *
  598. * WARNINGS: none *
  599. * *
  600. * HISTORY: *
  601. * 03/20/1996 JLB : Created. *
  602. *=============================================================================================*/
  603. short const * VesselTypeClass::Overlap_List(void) const
  604. {
  605. static short const _ship[] = {-3, -2, -1, 1, 2, 3,
  606. -MAP_CELL_W, -(MAP_CELL_W+1), -(MAP_CELL_W-1), -(MAP_CELL_W+2), -(MAP_CELL_W-2),
  607. +MAP_CELL_W, +(MAP_CELL_W+1), +(MAP_CELL_W-1), +(MAP_CELL_W+2), +(MAP_CELL_W-2),
  608. REFRESH_EOL};
  609. // static short const _ship[] = {-1, 1,
  610. // -MAP_CELL_W, -(MAP_CELL_W+1), -(MAP_CELL_W-1),
  611. // +MAP_CELL_W, +(MAP_CELL_W+1), +(MAP_CELL_W-1),
  612. // REFRESH_EOL};
  613. return(&_ship[0]);
  614. }
  615. /***********************************************************************************************
  616. * VesselTypeClass::From_Name -- Converts a name into a vessel type. *
  617. * *
  618. * Use this routine to convert an ASCII version of a vessel type into the corresponding *
  619. * VesselType id value. Typical use of this would be to parse the INI file. *
  620. * *
  621. * INPUT: name -- Pointer to the ASCII name to be converted into a vessel type. *
  622. * *
  623. * OUTPUT: Returns with the vessel type number that matches the string specified. *
  624. * *
  625. * WARNINGS: none *
  626. * *
  627. * HISTORY: *
  628. * 03/20/1996 JLB : Created. *
  629. *=============================================================================================*/
  630. VesselType VesselTypeClass::From_Name(char const * name)
  631. {
  632. if (name != NULL) {
  633. for (VesselType classid = VESSEL_FIRST; classid < VESSEL_COUNT; classid++) {
  634. if (stricmp(As_Reference(classid).IniName, name) == 0) {
  635. return(classid);
  636. }
  637. }
  638. }
  639. return(VESSEL_NONE);
  640. }
  641. /***********************************************************************************************
  642. * VesselTypeClass::Max_Pips -- Fetches the maximum pips allowed for this vessel. *
  643. * *
  644. * This routine will determine the number of pips (maximum) allowed for this unit type. *
  645. * Typically, this is the number of passengers allowed. *
  646. * *
  647. * INPUT: none *
  648. * *
  649. * OUTPUT: Returns with the maximum number of pips allowed for this vessel type. *
  650. * *
  651. * WARNINGS: none *
  652. * *
  653. * HISTORY: *
  654. * 06/01/1996 BWG : Created. *
  655. *=============================================================================================*/
  656. int VesselTypeClass::Max_Pips(void) const
  657. {
  658. return(Max_Passengers());
  659. }