TDATA.CPP 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919
  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/TDATA.CPP 1 3/03/97 10:25a 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 : TDATA.CPP *
  26. * *
  27. * Programmer : Joe L. Bostic *
  28. * *
  29. * Start Date : May 2, 1994 *
  30. * *
  31. * Last Update : July 19, 1996 [JLB] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * TerrainTypeClass::As_Reference -- Fetches a reference to the terrain type object specified*
  36. * TerrainTypeClass::Create_And_Place -- Creates and places terrain object on map. *
  37. * TerrainTypeClass::Create_On_Of -- Creates a terrain object from type. *
  38. * TerrainTypeClass::Display -- Display a generic terrain object. *
  39. * TerrainTypeClass::From_Name -- Convert name to terrain type. *
  40. * TerrainTypeClass::Init -- Loads terrain object shape files. *
  41. * TerrainTypeClass::Init_Heap -- Initialize the terrain object heap. *
  42. * TerrainTypeClass::Occupy_List -- Returns with the occupy list for the terrain object type.*
  43. * TerrainTypeClass::One_Time -- Performs any special one time processing for terrain types. *
  44. * TerrainTypeClass::Overlap_List -- Fetches the overlap list for the terrain type. *
  45. * TerrainTypeClass::Prep_For_Add -- Prepares to add terrain object. *
  46. * TerrainTypeClass::TerrainTypeClass -- The general constructor for the terrain type objects*
  47. * TerrainTypeClass::operator delete -- Returns a terrain type object back to the mem pool. *
  48. * TerrainTypeClass::operator new -- Allocates a terrain type object from special pool. *
  49. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  50. #include "function.h"
  51. #include "terrain.h"
  52. #include "type.h"
  53. static short const _List000011101000[] = {MAP_CELL_W, MAP_CELL_W+1, MAP_CELL_W+2, MAP_CELL_W*2, REFRESH_EOL};
  54. static short const _List000110[] = {MAP_CELL_W, MAP_CELL_W+1, REFRESH_EOL};
  55. static short const _List001011100110[] = {2, MAP_CELL_W, MAP_CELL_W+1, MAP_CELL_W+2, MAP_CELL_W*2+1, MAP_CELL_W*2+2, REFRESH_EOL};
  56. static short const _List0010[] = {MAP_CELL_W, REFRESH_EOL};
  57. static short const _List0011[] = {MAP_CELL_W, MAP_CELL_W+1, REFRESH_EOL};
  58. static short const _List001[] = {2, REFRESH_EOL};
  59. static short const _List010110[] = {1, MAP_CELL_W, MAP_CELL_W+1, REFRESH_EOL};
  60. static short const _List01[] = {1, REFRESH_EOL};
  61. static short const _List11[] = {0, 1, REFRESH_EOL};
  62. static short const _List1001[] = {0, MAP_CELL_W+1, REFRESH_EOL};
  63. static short const _List1010[] = {0, MAP_CELL_W, REFRESH_EOL};
  64. static short const _List101001[] = {0, 2, MAP_CELL_W+2, REFRESH_EOL};
  65. static short const _List10[] = {0, REFRESH_EOL};
  66. static short const _List110000011001[] = {0, 1, MAP_CELL_W+3, MAP_CELL_W*2, MAP_CELL_W*2+3, REFRESH_EOL};
  67. static short const _List110001[] = {0, 1, MAP_CELL_W+2, REFRESH_EOL};
  68. static short const _List1100[] = {0, 1, REFRESH_EOL};
  69. static short const _List110110[] = {0, 1, MAP_CELL_W, MAP_CELL_W+1, REFRESH_EOL};
  70. static short const _List1101[] = {0, 1, MAP_CELL_W+1, REFRESH_EOL};
  71. static short const _List1111[] = {0, 1, MAP_CELL_W, MAP_CELL_W+1, REFRESH_EOL};
  72. static short const _List111000010110[] = {0, 1, 2, MAP_CELL_W+3, MAP_CELL_W*2+1, MAP_CELL_W*2+2, REFRESH_EOL};
  73. static TerrainTypeClass const Mine(
  74. TERRAIN_MINE,
  75. THEATERF_TEMPERATE|THEATERF_SNOW,
  76. XYP_COORD(12,24), // Center base coordinate offset.
  77. true, // Is it immune to normal combat damage?
  78. false, // Is based on the water?
  79. "MINE",
  80. TXT_ORE_MINE,
  81. (short const *)_List10,
  82. NULL
  83. );
  84. static TerrainTypeClass const Boxes01(
  85. TERRAIN_BOXES01,
  86. THEATERF_INTERIOR,
  87. XYP_COORD(12,24), // Center base coordinate offset.
  88. true, // Is it immune to normal combat damage?
  89. false, // Is based on the water?
  90. "BOXES01",
  91. TXT_CRATES,
  92. (short const *)_List10,
  93. NULL
  94. );
  95. static TerrainTypeClass const Boxes02(
  96. TERRAIN_BOXES02,
  97. THEATERF_INTERIOR,
  98. XYP_COORD(12,24), // Center base coordinate offset.
  99. true, // Is it immune to normal combat damage?
  100. false, // Is based on the water?
  101. "BOXES02",
  102. TXT_CRATES,
  103. (short const *)_List10,
  104. NULL
  105. );
  106. static TerrainTypeClass const Boxes03(
  107. TERRAIN_BOXES03,
  108. THEATERF_INTERIOR,
  109. XYP_COORD(12,24), // Center base coordinate offset.
  110. true, // Is it immune to normal combat damage?
  111. false, // Is based on the water?
  112. "BOXES03",
  113. TXT_CRATES,
  114. (short const *)_List10,
  115. NULL
  116. );
  117. static TerrainTypeClass const Boxes04(
  118. TERRAIN_BOXES04,
  119. THEATERF_INTERIOR,
  120. XYP_COORD(12,24), // Center base coordinate offset.
  121. true, // Is it immune to normal combat damage?
  122. false, // Is based on the water?
  123. "BOXES04",
  124. TXT_CRATES,
  125. (short const *)_List10,
  126. NULL
  127. );
  128. static TerrainTypeClass const Boxes05(
  129. TERRAIN_BOXES05,
  130. THEATERF_INTERIOR,
  131. XYP_COORD(12,24), // Center base coordinate offset.
  132. true, // Is it immune to normal combat damage?
  133. false, // Is based on the water?
  134. "BOXES05",
  135. TXT_CRATES,
  136. (short const *)_List10,
  137. NULL
  138. );
  139. static TerrainTypeClass const Boxes06(
  140. TERRAIN_BOXES06,
  141. THEATERF_INTERIOR,
  142. XYP_COORD(12,24), // Center base coordinate offset.
  143. true, // Is it immune to normal combat damage?
  144. false, // Is based on the water?
  145. "BOXES06",
  146. TXT_CRATES,
  147. (short const *)_List10,
  148. NULL
  149. );
  150. static TerrainTypeClass const Boxes07(
  151. TERRAIN_BOXES07,
  152. THEATERF_INTERIOR,
  153. XYP_COORD(12,24), // Center base coordinate offset.
  154. true, // Is it immune to normal combat damage?
  155. false, // Is based on the water?
  156. "BOXES07",
  157. TXT_CRATES,
  158. (short const *)_List10,
  159. NULL
  160. );
  161. static TerrainTypeClass const Boxes08(
  162. TERRAIN_BOXES08,
  163. THEATERF_INTERIOR,
  164. XYP_COORD(12,24), // Center base coordinate offset.
  165. true, // Is it immune to normal combat damage?
  166. false, // Is based on the water?
  167. "BOXES08",
  168. TXT_CRATES,
  169. (short const *)_List10,
  170. NULL
  171. );
  172. static TerrainTypeClass const Boxes09(
  173. TERRAIN_BOXES09,
  174. THEATERF_INTERIOR,
  175. XYP_COORD(12,24), // Center base coordinate offset.
  176. true, // Is it immune to normal combat damage?
  177. false, // Is based on the water?
  178. "BOXES09",
  179. TXT_CRATES,
  180. (short const *)_List10,
  181. NULL
  182. );
  183. static TerrainTypeClass const Ice01(
  184. TERRAIN_ICE01,
  185. THEATERF_SNOW,
  186. XYP_COORD(24,24), // Center base coordinate offset.
  187. true, // Is it immune to normal combat damage?
  188. true, // Is based on the water?
  189. "ICE01",
  190. TXT_ICE,
  191. (short const *)_List1111,
  192. NULL
  193. );
  194. static TerrainTypeClass const Ice02(
  195. TERRAIN_ICE02,
  196. THEATERF_SNOW,
  197. XYP_COORD(12,24), // Center base coordinate offset.
  198. true, // Is it immune to normal combat damage?
  199. true, // Is based on the water?
  200. "ICE02",
  201. TXT_ICE,
  202. (short const *)_List1010,
  203. NULL
  204. );
  205. static TerrainTypeClass const Ice03(
  206. TERRAIN_ICE03,
  207. THEATERF_SNOW,
  208. XYP_COORD(24,12), // Center base coordinate offset.
  209. true, // Is it immune to normal combat damage?
  210. true, // Is based on the water?
  211. "ICE03",
  212. TXT_ICE,
  213. (short const *)_List11,
  214. NULL
  215. );
  216. static TerrainTypeClass const Ice04(
  217. TERRAIN_ICE04,
  218. THEATERF_SNOW,
  219. XYP_COORD(12,12), // Center base coordinate offset.
  220. true, // Is it immune to normal combat damage?
  221. true, // Is based on the water?
  222. "ICE04",
  223. TXT_ICE,
  224. (short const *)_List10,
  225. NULL
  226. );
  227. static TerrainTypeClass const Ice05(
  228. TERRAIN_ICE05,
  229. THEATERF_SNOW,
  230. XYP_COORD(12,12), // Center base coordinate offset.
  231. true, // Is it immune to normal combat damage?
  232. true, // Is based on the water?
  233. "ICE05",
  234. TXT_ICE,
  235. (short const *)_List10,
  236. NULL
  237. );
  238. static TerrainTypeClass const Tree1Class(
  239. TERRAIN_TREE1,
  240. THEATERF_TEMPERATE|THEATERF_SNOW,
  241. XYP_COORD(11,41), // Center base coordinate offset.
  242. false, // Is it immune to normal combat damage?
  243. false, // Is based on the water?
  244. "T01",
  245. TXT_TREE,
  246. (short const *)_List0010,
  247. (short const *)_List1001
  248. );
  249. static TerrainTypeClass const Tree2Class(
  250. TERRAIN_TREE2,
  251. THEATERF_TEMPERATE|THEATERF_SNOW,
  252. XYP_COORD(11,44), // Center base coordinate offset.
  253. false, // Is it immune to normal combat damage?
  254. false, // Is based on the water?
  255. "T02",
  256. TXT_TREE,
  257. (short const *)_List0010,
  258. (short const *)_List1001
  259. );
  260. static TerrainTypeClass const Tree3Class(
  261. TERRAIN_TREE3,
  262. THEATERF_TEMPERATE|THEATERF_SNOW,
  263. XYP_COORD(12,45), // Center base coordinate offset.
  264. false, // Is it immune to normal combat damage?
  265. false, // Is based on the water?
  266. "T03",
  267. TXT_TREE,
  268. (short const *)_List0010,
  269. (short const *)_List1001
  270. );
  271. static TerrainTypeClass const Tree5Class(
  272. TERRAIN_TREE5,
  273. THEATERF_TEMPERATE|THEATERF_SNOW,
  274. XYP_COORD(15,41), // Center base coordinate offset.
  275. false, // Is it immune to normal combat damage?
  276. false, // Is based on the water?
  277. "T05",
  278. TXT_TREE,
  279. (short const *)_List0010,
  280. (short const *)_List1001
  281. );
  282. static TerrainTypeClass const Tree6Class(
  283. TERRAIN_TREE6,
  284. THEATERF_TEMPERATE|THEATERF_SNOW,
  285. XYP_COORD(16,37), // Center base coordinate offset.
  286. false, // Is it immune to normal combat damage?
  287. false, // Is based on the water?
  288. "T06",
  289. TXT_TREE,
  290. (short const *)_List0010,
  291. (short const *)_List1001
  292. );
  293. static TerrainTypeClass const Tree7Class(
  294. TERRAIN_TREE7,
  295. THEATERF_TEMPERATE|THEATERF_SNOW,
  296. XYP_COORD(15,41), // Center base coordinate offset.
  297. false, // Is it immune to normal combat damage?
  298. false, // Is based on the water?
  299. "T07",
  300. TXT_TREE,
  301. (short const *)_List0010,
  302. (short const *)_List1001
  303. );
  304. static TerrainTypeClass const Tree8Class(
  305. TERRAIN_TREE8,
  306. THEATERF_TEMPERATE|THEATERF_SNOW,
  307. XYP_COORD(14,22), // Center base coordinate offset.
  308. false, // Is it immune to normal combat damage?
  309. false, // Is based on the water?
  310. "T08",
  311. TXT_TREE,
  312. (short const *)_List10,
  313. (short const *)_List01
  314. );
  315. static TerrainTypeClass const Tree10Class(
  316. TERRAIN_TREE10,
  317. THEATERF_TEMPERATE|THEATERF_SNOW,
  318. XYP_COORD(25,43), // Center base coordinate offset.
  319. false, // Is it immune to normal combat damage?
  320. false, // Is based on the water?
  321. "T10",
  322. TXT_TREE,
  323. (short const *)_List0011,
  324. (short const *)_List1100
  325. );
  326. static TerrainTypeClass const Tree11Class(
  327. TERRAIN_TREE11,
  328. THEATERF_TEMPERATE|THEATERF_SNOW,
  329. XYP_COORD(23,44), // Center base coordinate offset.
  330. false, // Is it immune to normal combat damage?
  331. false, // Is based on the water?
  332. "T11",
  333. TXT_TREE,
  334. (short const *)_List0011,
  335. (short const *)_List1100
  336. );
  337. static TerrainTypeClass const Tree12Class(
  338. TERRAIN_TREE12,
  339. THEATERF_TEMPERATE|THEATERF_SNOW,
  340. XYP_COORD(14,36), // Center base coordinate offset.
  341. false, // Is it immune to normal combat damage?
  342. false, // Is based on the water?
  343. "T12",
  344. TXT_TREE,
  345. (short const *)_List0010,
  346. (short const *)_List1001
  347. );
  348. static TerrainTypeClass const Tree13Class(
  349. TERRAIN_TREE13,
  350. THEATERF_TEMPERATE|THEATERF_SNOW,
  351. XYP_COORD(19,40), // Center base coordinate offset.
  352. false, // Is it immune to normal combat damage?
  353. false, // Is based on the water?
  354. "T13",
  355. TXT_TREE,
  356. (short const *)_List0010,
  357. (short const *)_List1101
  358. );
  359. static TerrainTypeClass const Tree14Class(
  360. TERRAIN_TREE14,
  361. THEATERF_TEMPERATE|THEATERF_SNOW,
  362. XYP_COORD(19,40), // Center base coordinate offset.
  363. false, // Is it immune to normal combat damage?
  364. false, // Is based on the water?
  365. "T14",
  366. TXT_TREE,
  367. (short const *)_List0011,
  368. (short const *)_List1100
  369. );
  370. static TerrainTypeClass const Tree15Class(
  371. TERRAIN_TREE15,
  372. THEATERF_TEMPERATE|THEATERF_SNOW,
  373. XYP_COORD(19,40), // Center base coordinate offset.
  374. false, // Is it immune to normal combat damage?
  375. false, // Is based on the water?
  376. "T15",
  377. TXT_TREE,
  378. (short const *)_List0011,
  379. (short const *)_List1100
  380. );
  381. static TerrainTypeClass const Tree16Class(
  382. TERRAIN_TREE16,
  383. THEATERF_TEMPERATE|THEATERF_SNOW,
  384. XYP_COORD(13,36), // Center base coordinate offset.
  385. false, // Is it immune to normal combat damage?
  386. false, // Is based on the water?
  387. "T16",
  388. TXT_TREE,
  389. (short const *)_List0010,
  390. (short const *)_List1001
  391. );
  392. static TerrainTypeClass const Tree17Class(
  393. TERRAIN_TREE17,
  394. THEATERF_TEMPERATE|THEATERF_SNOW,
  395. XYP_COORD(18,44), // Center base coordinate offset.
  396. false, // Is it immune to normal combat damage?
  397. false, // Is based on the water?
  398. "T17",
  399. TXT_TREE,
  400. (short const *)_List0010,
  401. (short const *)_List1001
  402. );
  403. static TerrainTypeClass const Clump1Class(
  404. TERRAIN_CLUMP1,
  405. THEATERF_TEMPERATE|THEATERF_SNOW,
  406. XYP_COORD(28,41), // Center base coordinate offset.
  407. true, // Is it immune to normal combat damage?
  408. false, // Is based on the water?
  409. "TC01",
  410. TXT_TREE,
  411. (short const *)_List000110,
  412. (short const *)_List110001
  413. );
  414. static TerrainTypeClass const Clump2Class(
  415. TERRAIN_CLUMP2,
  416. THEATERF_TEMPERATE|THEATERF_SNOW,
  417. XYP_COORD(38,41), // Center base coordinate offset.
  418. true, // Is it immune to normal combat damage?
  419. false, // Is based on the water?
  420. "TC02",
  421. TXT_TREE,
  422. (short const *)_List010110,
  423. (short const *)_List101001
  424. );
  425. static TerrainTypeClass const Clump3Class(
  426. TERRAIN_CLUMP3,
  427. THEATERF_TEMPERATE|THEATERF_SNOW,
  428. XYP_COORD(33,35), // Center base coordinate offset.
  429. true, // Is it immune to normal combat damage?
  430. false, // Is based on the water?
  431. "TC03",
  432. TXT_TREE,
  433. (short const *)_List110110,
  434. (short const *)_List001
  435. );
  436. static TerrainTypeClass const Clump4Class(
  437. TERRAIN_CLUMP4,
  438. THEATERF_TEMPERATE|THEATERF_SNOW,
  439. XYP_COORD(44,49), // Center base coordinate offset.
  440. true, // Is it immune to normal combat damage?
  441. false, // Is based on the water?
  442. "TC04",
  443. TXT_TREE,
  444. (short const *)_List000011101000,
  445. (short const *)_List111000010110
  446. );
  447. static TerrainTypeClass const Clump5Class(
  448. TERRAIN_CLUMP5,
  449. THEATERF_TEMPERATE|THEATERF_SNOW,
  450. XYP_COORD(49,58), // Center base coordinate offset.
  451. true, // Is it immune to normal combat damage?
  452. false, // Is based on the water?
  453. "TC05",
  454. TXT_TREE,
  455. (short const *)_List001011100110,
  456. (short const *)_List110000011001
  457. );
  458. /***********************************************************************************************
  459. * TerrainTypeClass::TerrainTypeClass -- The general constructor for the terrain type objects. *
  460. * *
  461. * This is the constructor for terrain type objects. It is only used to construct the *
  462. * static (constant) terrain type objects. *
  463. * *
  464. * INPUT: see below.. *
  465. * *
  466. * OUTPUT: none *
  467. * *
  468. * WARNINGS: none *
  469. * *
  470. * HISTORY: *
  471. * 07/19/1994 JLB : Created. *
  472. *=============================================================================================*/
  473. TerrainTypeClass::TerrainTypeClass(
  474. TerrainType terrain,
  475. int theater,
  476. COORDINATE centerbase,
  477. bool is_immune,
  478. bool is_water,
  479. char const * ininame,
  480. int fullname,
  481. short const * occupy,
  482. short const * overlap) :
  483. ObjectTypeClass(RTTI_TERRAINTYPE,
  484. int(terrain),
  485. true,
  486. true,
  487. false,
  488. false,
  489. true,
  490. is_immune,
  491. true,
  492. fullname,
  493. ininame),
  494. Type(terrain),
  495. CenterBase(centerbase),
  496. Theater(theater),
  497. IsWaterBased(is_water),
  498. Occupy(occupy),
  499. Overlap(overlap)
  500. {
  501. MaxStrength = 800;
  502. Armor = ARMOR_WOOD;
  503. }
  504. /***********************************************************************************************
  505. * TerrainTypeClass::operator new -- Allocates a terrain type object from special pool. *
  506. * *
  507. * This routine will allocated a terrain type class object from the memory pool set up *
  508. * for that purpose. *
  509. * *
  510. * INPUT: none *
  511. * *
  512. * OUTPUT: Returns with a pointer to the freshly allocated terrain type object block. If *
  513. * there was insufficient memory, then NULL is returned. *
  514. * *
  515. * WARNINGS: none *
  516. * *
  517. * HISTORY: *
  518. * 07/19/1996 JLB : Created. *
  519. *=============================================================================================*/
  520. void * TerrainTypeClass::operator new(size_t)
  521. {
  522. return(TerrainTypes.Alloc());
  523. }
  524. /***********************************************************************************************
  525. * TerrainTypeClass::operator delete -- Returns a terrain type object back to the mem pool. *
  526. * *
  527. * This routine will return the supplied terrain type object back to the special memory *
  528. * pool for whence it was originally allocated. *
  529. * *
  530. * INPUT: pointer -- Pointer to the terrain type object to return to the memory pool. *
  531. * *
  532. * OUTPUT: none *
  533. * *
  534. * WARNINGS: none *
  535. * *
  536. * HISTORY: *
  537. * 07/19/1996 JLB : Created. *
  538. *=============================================================================================*/
  539. void TerrainTypeClass::operator delete(void * pointer)
  540. {
  541. TerrainTypes.Free((TerrainTypeClass *)pointer);
  542. }
  543. /***********************************************************************************************
  544. * TerrainTypeClass::Init_Heap -- Initialize the terrain object heap. *
  545. * *
  546. * This routine preallocates the terrain type objects in the memory pool. It must be called *
  547. * before the terrain type object data can be filled in. *
  548. * *
  549. * INPUT: none *
  550. * *
  551. * OUTPUT: none *
  552. * *
  553. * WARNINGS: This must be called only once and before the rules.ini file is processed. *
  554. * *
  555. * HISTORY: *
  556. * 07/19/1996 JLB : Created. *
  557. *=============================================================================================*/
  558. void TerrainTypeClass::Init_Heap(void)
  559. {
  560. /*
  561. ** These terrain type class objects must be allocated in the exact order that they
  562. ** are specified in the TerrainType enumeration. This is necessary because the heap
  563. ** allocation block index serves double duty as the type number index.
  564. */
  565. new TerrainTypeClass(Tree1Class); // TERRAIN_TREE1
  566. new TerrainTypeClass(Tree2Class); // TERRAIN_TREE2
  567. new TerrainTypeClass(Tree3Class); // TERRAIN_TREE3
  568. new TerrainTypeClass(Tree5Class); // TERRAIN_TREE5
  569. new TerrainTypeClass(Tree6Class); // TERRAIN_TREE6
  570. new TerrainTypeClass(Tree7Class); // TERRAIN_TREE7
  571. new TerrainTypeClass(Tree8Class); // TERRAIN_TREE8
  572. new TerrainTypeClass(Tree10Class); // TERRAIN_TREE10
  573. new TerrainTypeClass(Tree11Class); // TERRAIN_TREE11
  574. new TerrainTypeClass(Tree12Class); // TERRAIN_TREE12
  575. new TerrainTypeClass(Tree13Class); // TERRAIN_TREE13
  576. new TerrainTypeClass(Tree14Class); // TERRAIN_TREE14
  577. new TerrainTypeClass(Tree15Class); // TERRAIN_TREE15
  578. new TerrainTypeClass(Tree16Class); // TERRAIN_TREE16
  579. new TerrainTypeClass(Tree17Class); // TERRAIN_TREE17
  580. new TerrainTypeClass(Clump1Class); // TERRAIN_CLUMP1
  581. new TerrainTypeClass(Clump2Class); // TERRAIN_CLUMP2
  582. new TerrainTypeClass(Clump3Class); // TERRAIN_CLUMP3
  583. new TerrainTypeClass(Clump4Class); // TERRAIN_CLUMP4
  584. new TerrainTypeClass(Clump5Class); // TERRAIN_CLUMP5
  585. new TerrainTypeClass(Ice01); // TERRAIN_ICE01
  586. new TerrainTypeClass(Ice02); // TERRAIN_ICE02
  587. new TerrainTypeClass(Ice03); // TERRAIN_ICE03
  588. new TerrainTypeClass(Ice04); // TERRAIN_ICE04
  589. new TerrainTypeClass(Ice05); // TERRAIN_ICE05
  590. new TerrainTypeClass(Boxes01); // TERRAIN_BOXES01
  591. new TerrainTypeClass(Boxes02); // TERRAIN_BOXES02
  592. new TerrainTypeClass(Boxes03); // TERRAIN_BOXES03
  593. new TerrainTypeClass(Boxes04); // TERRAIN_BOXES04
  594. new TerrainTypeClass(Boxes05); // TERRAIN_BOXES05
  595. new TerrainTypeClass(Boxes06); // TERRAIN_BOXES06
  596. new TerrainTypeClass(Boxes07); // TERRAIN_BOXES07
  597. new TerrainTypeClass(Boxes08); // TERRAIN_BOXES08
  598. new TerrainTypeClass(Boxes09); // TERRAIN_BOXES09
  599. new TerrainTypeClass(Mine); // TERRAIN_MINE
  600. }
  601. /***********************************************************************************************
  602. * TerrainTypeClass::One_Time -- Performs any special one time processing for terrain types. *
  603. * *
  604. * This routine will perform any special one time processing needed for the terrain *
  605. * object types. Typically, this would load up artwork for terrain objects that have *
  606. * artwork independant of the theater they appear in. *
  607. * *
  608. * INPUT: none *
  609. * *
  610. * OUTPUT: none *
  611. * *
  612. * WARNINGS: none *
  613. * *
  614. * HISTORY: *
  615. * 07/19/1996 JLB : Created. *
  616. *=============================================================================================*/
  617. void TerrainTypeClass::One_Time(void)
  618. {
  619. }
  620. /***********************************************************************************************
  621. * TerrainTypeClass::Init -- Loads terrain object shape files. *
  622. * *
  623. * This routine is used to load up the terrain object shape files. *
  624. * The shape files loaded depends on theater. *
  625. * *
  626. * INPUT: theater -- The theater to load the terrain shape data for. *
  627. * *
  628. * OUTPUT: none *
  629. * *
  630. * WARNINGS: none *
  631. * *
  632. * HISTORY: *
  633. * 05/16/1994 JLB : Created. *
  634. *=============================================================================================*/
  635. void TerrainTypeClass::Init(TheaterType theater)
  636. {
  637. if (theater != LastTheater) {
  638. for (TerrainType index = TERRAIN_FIRST; index < TERRAIN_COUNT; index++) {
  639. TerrainTypeClass const & terrain = As_Reference(index);
  640. char fullname[_MAX_FNAME+_MAX_EXT];
  641. /*
  642. ** Clear any existing shape pointer. All terrain is theater specific, thus if
  643. ** it isn't loaded in this routine, it shouldn't exist at all.
  644. */
  645. ((void const *&)terrain.ImageData) = NULL;
  646. if (terrain.Theater & (1 << theater)) {
  647. /*
  648. ** Load in the appropriate object shape data.
  649. */
  650. _makepath(fullname, NULL, NULL, terrain.IniName, Theaters[theater].Suffix);
  651. ((void const *&)terrain.ImageData) = MFCD::Retrieve(fullname);
  652. IsTheaterShape = true; //Let Build_Frame know that this is a theater specific shape
  653. if (terrain.RadarIcon != NULL) delete[] (char *)terrain.RadarIcon;
  654. ((void const *&)terrain.RadarIcon) = Get_Radar_Icon(terrain.Get_Image_Data(), 0, 1, 3);
  655. IsTheaterShape = false;
  656. }
  657. }
  658. }
  659. }
  660. /***********************************************************************************************
  661. * TerrainTypeClass::From_Name -- Convert name to terrain type. *
  662. * *
  663. * This routine is used to convert a text name into the matching *
  664. * terrain type number. This is used during scenario initialization. *
  665. * *
  666. * INPUT: name -- The name to convert. *
  667. * *
  668. * OUTPUT: Returns the TerrainType that matches the name specified. If *
  669. * no match was found, then TERRAIN_NONE is returned. *
  670. * *
  671. * WARNINGS: none *
  672. * *
  673. * HISTORY: *
  674. * 05/16/1994 JLB : Created. *
  675. *=============================================================================================*/
  676. TerrainType TerrainTypeClass::From_Name(char const * name)
  677. {
  678. TerrainType index;
  679. if (name != NULL) {
  680. for (index = TERRAIN_FIRST; index < TERRAIN_COUNT; index++) {
  681. if (stricmp(name, As_Reference(index).IniName) == 0) {
  682. return(index);
  683. }
  684. }
  685. }
  686. return(TERRAIN_NONE);
  687. }
  688. #ifdef SCENARIO_EDITOR
  689. /***********************************************************************************************
  690. * TerrainTypeClass::Display -- Display a generic terrain object. *
  691. * *
  692. * This routine is used to display a generic terrain object. Typical *
  693. * use is during scenario editing. *
  694. * *
  695. * INPUT: x,y -- Pixel coordinates to display object at (centered). *
  696. * *
  697. * window-- The window to display the object within. *
  698. * *
  699. * OUTPUT: none *
  700. * *
  701. * WARNINGS: none *
  702. * *
  703. * HISTORY: *
  704. * 05/16/1994 JLB : Created. *
  705. *=============================================================================================*/
  706. void TerrainTypeClass::Display(int x, int y, WindowNumberType window, HousesType) const
  707. {
  708. IsTheaterShape = true;
  709. CC_Draw_Shape(Get_Image_Data(), 0, x, y, window, SHAPE_NORMAL|SHAPE_CENTER|SHAPE_WIN_REL);
  710. IsTheaterShape = false;
  711. }
  712. /***********************************************************************************************
  713. * TerrainTypeClass::Prep_For_Add -- Prepares to add terrain object. *
  714. * *
  715. * Submits all of the valid terrain objects to the scenario editor for possible selection *
  716. * and subsequent placement on the map. All terrain objects, that have a valid shape *
  717. * file available, are added. *
  718. * *
  719. * INPUT: none *
  720. * *
  721. * OUTPUT: none *
  722. * *
  723. * WARNINGS: none *
  724. * *
  725. * HISTORY: *
  726. * 05/23/1994 JLB : Created. *
  727. *=============================================================================================*/
  728. void TerrainTypeClass::Prep_For_Add(void)
  729. {
  730. for (TerrainType index = TERRAIN_FIRST; index < TERRAIN_COUNT; index++) {
  731. if (As_Reference(index).Get_Image_Data()) {
  732. Map.Add_To_List(&As_Reference(index));
  733. }
  734. }
  735. }
  736. #endif
  737. /***********************************************************************************************
  738. * TerrainTypeClass::Create_And_Place -- Creates and places terrain object on map. *
  739. * *
  740. * This support routine is used by the scenario editor to add a terrain object to the map. *
  741. * *
  742. * INPUT: cell -- The cell to place the terrain object in. *
  743. * *
  744. * OUTPUT: bool; Was the placement successful? *
  745. * *
  746. * WARNINGS: none *
  747. * *
  748. * HISTORY: *
  749. * 05/28/1994 JLB : Created. *
  750. *=============================================================================================*/
  751. bool TerrainTypeClass::Create_And_Place(CELL cell, HousesType ) const
  752. {
  753. if (new TerrainClass(Type, cell)) {
  754. return(true);
  755. }
  756. return(false);
  757. }
  758. /***********************************************************************************************
  759. * TerrainTypeClass::Create_On_Of -- Creates a terrain object from type. *
  760. * *
  761. * This is used to create a terrain object by using the terrain type as a guide. This *
  762. * routine is typically used by the scenario editor in order to place a terrain object *
  763. * onto the map. *
  764. * *
  765. * INPUT: none *
  766. * *
  767. * OUTPUT: Returns with a pointer to the created terrain object or NULL if one couldn't be *
  768. * created. *
  769. * *
  770. * WARNINGS: none *
  771. * *
  772. * HISTORY: *
  773. * 07/19/1994 JLB : Created. *
  774. *=============================================================================================*/
  775. ObjectClass * TerrainTypeClass::Create_One_Of(HouseClass *) const
  776. {
  777. return(new TerrainClass(Type, -1));
  778. }
  779. /***********************************************************************************************
  780. * TerrainTypeClass::Occupy_List -- Returns with the occupy list for the terrain object type. *
  781. * *
  782. * This routine will return with the occupy list for the terrain object type. If there is *
  783. * no occupy list for this terrain object type, then a special zero length occupy list *
  784. * pointer is returned. *
  785. * *
  786. * INPUT: none *
  787. * *
  788. * OUTPUT: Returns with a pointer to the terrain object's occupy list. A zero length list is *
  789. * returned in the case of no occupy list. *
  790. * *
  791. * WARNINGS: none *
  792. * *
  793. * HISTORY: *
  794. * 09/20/1995 JLB : Created. *
  795. *=============================================================================================*/
  796. short const * TerrainTypeClass::Occupy_List(bool ) const
  797. {
  798. if (Occupy != NULL) return(Occupy);
  799. static short const _simple[1] = {
  800. REFRESH_EOL
  801. };
  802. return(&_simple[0]);
  803. }
  804. /***********************************************************************************************
  805. * TerrainTypeClass::Overlap_List -- Fetches the overlap list for the terrain type. *
  806. * *
  807. * This routine will return with the overlap list for the terrain object type. If there *
  808. * is no overlap list for the terrain object, then a null length list is returned in order *
  809. * to ensure that a non-null pointer is returned. *
  810. * *
  811. * INPUT: none *
  812. * *
  813. * OUTPUT: Returns with a pointer to the overlap list for this object type. A special zero *
  814. * length list pointer is returned if there is no overlap list associated with the *
  815. * object type. *
  816. * *
  817. * WARNINGS: none *
  818. * *
  819. * HISTORY: *
  820. * 09/20/1995 JLB : Created. *
  821. *=============================================================================================*/
  822. short const * TerrainTypeClass::Overlap_List(void) const
  823. {
  824. if (Overlap != NULL) return(Overlap);
  825. static short const _simple[1] = {
  826. REFRESH_EOL
  827. };
  828. return(&_simple[0]);
  829. }
  830. /***********************************************************************************************
  831. * TerrainTypeClass::As_Reference -- Fetches a reference to the terrain type object specified. *
  832. * *
  833. * Use this routine to convert the terrain type number into a reference to a terrain *
  834. * type class object. *
  835. * *
  836. * INPUT: type -- The terrain type number to convert. *
  837. * *
  838. * OUTPUT: Returns with a reference to the terrain type class object that is referred to by *
  839. * the terrain type number. *
  840. * *
  841. * WARNINGS: Be sure that the terrain type number is valid. Using an invalid value causes *
  842. * undefined behavior. *
  843. * *
  844. * HISTORY: *
  845. * 07/19/1996 JLB : Created. *
  846. *=============================================================================================*/
  847. TerrainTypeClass & TerrainTypeClass::As_Reference(TerrainType type)
  848. {
  849. return(*TerrainTypes.Ptr(type));
  850. }
  851. COORDINATE TerrainTypeClass::Coord_Fixup(COORDINATE coord) const
  852. {
  853. return Coord_Whole(coord);
  854. }