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