VDATA.CPP 40 KB

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