ODATA.CPP (52858B)
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/ODATA.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 : ODATA.CPP * 24 * * 25 * Programmer : Joe L. Bostic * 26 * * 27 * Start Date : May 16, 1994 * 28 * * 29 * Last Update : August 14, 1996 [JLB] * 30 * * 31 *---------------------------------------------------------------------------------------------* 32 * Functions: * 33 * OverlayTypeClass::As_Reference -- Fetch a reference to the overlay type specified. * 34 * OverlayTypeClass::Coord_Fixup -- Adjust the coord to be legal for assignment. * 35 * OverlayTypeClass::Create_And_Place -- Creates and places a overlay object on the map. * 36 * OverlayTypeClass::Create_One_Of -- Creates an object of this overlay type. * 37 * OverlayTypeClass::Display -- Displays a generic representation of overlay. * 38 * OverlayTypeClass::Draw_It -- Draws the overlay image at location specified. * 39 * OverlayTypeClass::From_Name -- Determine overlay from ASCII name. * 40 * OverlayTypeClass::Init -- Initialize the overlay graphic data per theater. * 41 * OverlayTypeClass::Init_Heap -- Initialize the overlay type class heap. * 42 * OverlayTypeClass::Occupy_List -- Determines occupation list. * 43 * OverlayTypeClass::One_Time -- Loads all the necessary general overlay shape data. * 44 * OverlayTypeClass::OverlayTypeClass -- Constructor for overlay type objects. * 45 * OverlayTypeClass::Prep_For_Add -- Prepares to add overlay to scenario. * 46 * OverlayTypeClass::Radar_Icon -- Gets a pointer to the radar icons * 47 * OverlayTypeClass::operator delete -- Returns an overlay type object back to the pool. * 48 * OverlayTypeClass::operator new -- Allocate an overlay type class object from pool. * 49 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 50 51 #include "function.h" 52 #include "type.h" 53 54 55 static OverlayTypeClass const Sandbag( 56 OVERLAY_SANDBAG_WALL, // Overlay type number. 57 "SBAG", // INI name of overlay. 58 TXT_SANDBAG_WALL, // Full name of overlay. 59 LAND_WALL, // What kind of ground is it? 60 1, // If this is a wall, how many damage levels? 61 20, // If this is a wall, how many damage points can it take per level? 62 true, // Visible on the radar map? 63 false, // Is it a wooden overlay (affected by fire)? 64 true, // Targetable as a destroyable overlay? 65 true, // Crushable by tracked vehicle? 66 false, // Is this harvestable Tiberium? 67 false, // Stops low level bullets in flight? 68 false, // Theater specific art? 69 true, // Is this a wall type? 70 false // Is this a crate? 71 ); 72 static OverlayTypeClass const Cyclone( 73 OVERLAY_CYCLONE_WALL, // Overlay type number. 74 "CYCL", // INI name of overlay. 75 TXT_CYCLONE_WALL, // Full name of overlay. 76 LAND_WALL, // What kind of ground is it? 77 2, // If this is a wall, how many damage levels? 78 10, // If this is a wall, how many damage points can it take per level? 79 true, // Visible on the radar map? 80 false, // Is it a wooden overlay (affected by fire)? 81 true, // Targetable as a destroyable overlay? 82 true, // Crushable by tracked vehicle? 83 false, // Is this harvestable Tiberium? 84 false, // Stops low level bullets in flight? 85 false, // Theater specific art? 86 true, // Is this a wall type? 87 false // Is this a crate? 88 ); 89 static OverlayTypeClass const Brick( 90 OVERLAY_BRICK_WALL, // Overlay type number. 91 "BRIK", // INI name of overlay. 92 TXT_BRICK_WALL, // Full name of overlay. 93 LAND_WALL, // What kind of ground is it? 94 3, // If this is a wall, how many damage levels? 95 70, // If this is a wall, how many damage points can it take per level? 96 true, // Visible on the radar map? 97 false, // Is it a wooden overlay (affected by fire)? 98 true, // Targetable as a destroyable overlay? 99 false, // Crushable by tracked vehicle? 100 false, // Is this harvestable Tiberium? 101 true, // Stops low level bullets in flight? 102 false, // Theater specific art? 103 true, // Is this a wall type? 104 false // Is this a crate? 105 ); 106 static OverlayTypeClass const Barbwire( 107 OVERLAY_BARBWIRE_WALL, // Overlay type number. 108 "BARB", // INI name of overlay. 109 TXT_BARBWIRE_WALL, // Full name of overlay. 110 LAND_WALL, // What kind of ground is it? 111 1, // If this is a wall, how many damage levels? 112 2, // If this is a wall, how many damage points can it take per level? 113 true, // Visible on the radar map? 114 false, // Is it a wooden overlay (affected by fire)? 115 true, // Targetable as a destroyable overlay? 116 true, // Crushable by tracked vehicle? 117 false, // Is this harvestable Tiberium? 118 false, // Stops low level bullets in flight? 119 false, // Theater specific art? 120 true, // Is this a wall type? 121 false // Is this a crate? 122 ); 123 static OverlayTypeClass const Wood( 124 OVERLAY_WOOD_WALL, // Overlay type number. 125 "WOOD", // INI name of overlay. 126 TXT_WOOD_WALL, // Full name of overlay. 127 LAND_WALL, // What kind of ground is it? 128 1, // If this is a wall, how many damage levels? 129 2, // If this is a wall, how many damage points can it take per level? 130 true, // Visible on the radar map? 131 true, // Is it a wooden overlay (affected by fire)? 132 true, // Targetable as a destroyable overlay? 133 true, // Crushable by tracked vehicle? 134 false, // Is this harvestable Tiberium? 135 false, // Stops low level bullets in flight? 136 false, // Theater specific art? 137 true, // Is this a wall type? 138 false // Is this a crate? 139 ); 140 static OverlayTypeClass const Fence( 141 OVERLAY_FENCE, // Overlay type number. 142 "FENC", // INI name of overlay. 143 TXT_FENCE, // Full name of overlay. 144 LAND_WALL, // What kind of ground is it? 145 2, // If this is a wall, how many damage levels? 146 10, // If this is a wall, how many damage points can it take per level? 147 true, // Visible on the radar map? 148 false, // Is it a wooden overlay (affected by fire)? 149 true, // Targetable as a destroyable overlay? 150 true, // Crushable by tracked vehicle? 151 false, // Is this harvestable Tiberium? 152 false, // Stops low level bullets in flight? 153 false, // Theater specific art? 154 true, // Is this a wall type? 155 false // Is this a crate? 156 ); 157 158 static OverlayTypeClass const Gold1( 159 OVERLAY_GOLD1, // Overlay type number. 160 "GOLD01", // INI name of overlay. 161 TXT_GOLD, // Full name of overlay. 162 LAND_TIBERIUM, // What kind of ground is it? 163 0, // If this is a wall, how many damage levels? 164 0, // If this is a wall, how many damage points can it take per level? 165 true, // Visible on the radar map? 166 false, // Is it a wooden overlay (affected by fire)? 167 false, // Targetable as a destroyable overlay? 168 false, // Crushable by tracked vehicle? 169 true, // Is this harvestable Tiberium? 170 false, // Stops low level bullets in flight? 171 true, // Theater specific art? 172 false, // Is this a wall type? 173 false // Is this a crate? 174 ); 175 static OverlayTypeClass const Gold2( 176 OVERLAY_GOLD2, // Overlay type number. 177 "GOLD02", // INI name of overlay. 178 TXT_GOLD, // Full name of overlay. 179 LAND_TIBERIUM, // What kind of ground is it? 180 0, // If this is a wall, how many damage levels? 181 0, // If this is a wall, how many damage points can it take per level? 182 true, // Visible on the radar map? 183 false, // Is it a wooden overlay (affected by fire)? 184 false, // Targetable as a destroyable overlay? 185 false, // Crushable by tracked vehicle? 186 true, // Is this harvestable Tiberium? 187 false, // Stops low level bullets in flight? 188 true, // Theater specific art? 189 false, // Is this a wall type? 190 false // Is this a crate? 191 ); 192 static OverlayTypeClass const Gold3( 193 OVERLAY_GOLD3, // Overlay type number. 194 "GOLD03", // INI name of overlay. 195 TXT_GOLD, // Full name of overlay. 196 LAND_TIBERIUM, // What kind of ground is it? 197 0, // If this is a wall, how many damage levels? 198 0, // If this is a wall, how many damage points can it take per level? 199 true, // Visible on the radar map? 200 false, // Is it a wooden overlay (affected by fire)? 201 false, // Targetable as a destroyable overlay? 202 false, // Crushable by tracked vehicle? 203 true, // Is this harvestable Tiberium? 204 false, // Stops low level bullets in flight? 205 true, // Theater specific art? 206 false, // Is this a wall type? 207 false // Is this a crate? 208 ); 209 static OverlayTypeClass const Gold4( 210 OVERLAY_GOLD4, // Overlay type number. 211 "GOLD04", // INI name of overlay. 212 TXT_GOLD, // Full name of overlay. 213 LAND_TIBERIUM, // What kind of ground is it? 214 0, // If this is a wall, how many damage levels? 215 0, // If this is a wall, how many damage points can it take per level? 216 true, // Visible on the radar map? 217 false, // Is it a wooden overlay (affected by fire)? 218 false, // Targetable as a destroyable overlay? 219 false, // Crushable by tracked vehicle? 220 true, // Is this harvestable Tiberium? 221 false, // Stops low level bullets in flight? 222 true, // Theater specific art? 223 false, // Is this a wall type? 224 false // Is this a crate? 225 ); 226 227 static OverlayTypeClass const Gems1( 228 OVERLAY_GEMS1, // Overlay type number. 229 "GEM01", // INI name of overlay. 230 TXT_GEMS, // Full name of overlay. 231 LAND_TIBERIUM, // What kind of ground is it? 232 0, // If this is a wall, how many damage levels? 233 0, // If this is a wall, how many damage points can it take per level? 234 true, // Visible on the radar map? 235 false, // Is it a wooden overlay (affected by fire)? 236 false, // Targetable as a destroyable overlay? 237 false, // Crushable by tracked vehicle? 238 true, // Is this harvestable Tiberium? 239 false, // Stops low level bullets in flight? 240 true, // Theater specific art? 241 false, // Is this a wall type? 242 false // Is this a crate? 243 ); 244 static OverlayTypeClass const Gems2( 245 OVERLAY_GEMS2, // Overlay type number. 246 "GEM02", // INI name of overlay. 247 TXT_GEMS, // Full name of overlay. 248 LAND_TIBERIUM, // What kind of ground is it? 249 0, // If this is a wall, how many damage levels? 250 0, // If this is a wall, how many damage points can it take per level? 251 true, // Visible on the radar map? 252 false, // Is it a wooden overlay (affected by fire)? 253 false, // Targetable as a destroyable overlay? 254 false, // Crushable by tracked vehicle? 255 true, // Is this harvestable Tiberium? 256 false, // Stops low level bullets in flight? 257 true, // Theater specific art? 258 false, // Is this a wall type? 259 false // Is this a crate? 260 ); 261 static OverlayTypeClass const Gems3( 262 OVERLAY_GEMS3, // Overlay type number. 263 "GEM03", // INI name of overlay. 264 TXT_GEMS, // Full name of overlay. 265 LAND_TIBERIUM, // What kind of ground is it? 266 0, // If this is a wall, how many damage levels? 267 0, // If this is a wall, how many damage points can it take per level? 268 true, // Visible on the radar map? 269 false, // Is it a wooden overlay (affected by fire)? 270 false, // Targetable as a destroyable overlay? 271 false, // Crushable by tracked vehicle? 272 true, // Is this harvestable Tiberium? 273 false, // Stops low level bullets in flight? 274 true, // Theater specific art? 275 false, // Is this a wall type? 276 false // Is this a crate? 277 ); 278 static OverlayTypeClass const Gems4( 279 OVERLAY_GEMS4, // Overlay type number. 280 "GEM04", // INI name of overlay. 281 TXT_GEMS, // Full name of overlay. 282 LAND_TIBERIUM, // What kind of ground is it? 283 0, // If this is a wall, how many damage levels? 284 0, // If this is a wall, how many damage points can it take per level? 285 true, // Visible on the radar map? 286 false, // Is it a wooden overlay (affected by fire)? 287 false, // Targetable as a destroyable overlay? 288 false, // Crushable by tracked vehicle? 289 true, // Is this harvestable Tiberium? 290 false, // Stops low level bullets in flight? 291 true, // Theater specific art? 292 false, // Is this a wall type? 293 false // Is this a crate? 294 ); 295 static OverlayTypeClass const V12( 296 OVERLAY_V12, // Overlay type number. 297 "V12", // INI name of overlay. 298 TXT_CIV12, // Full name of overlay. 299 LAND_ROCK, // What kind of ground is it? 300 0, // If this is a wall, how many damage levels? 301 0, // If this is a wall, how many damage points can it take per level? 302 false, // Visible on the radar map? 303 false, // Is it a wooden overlay (affected by fire)? 304 false, // Targetable as a destroyable overlay? 305 true, // Crushable by tracked vehicle? 306 false, // Is this harvestable Tiberium? 307 false, // Stops low level bullets in flight? 308 true, // Theater specific art? 309 false, // Is this a wall type? 310 false // Is this a crate? 311 ); 312 static OverlayTypeClass const V13( 313 OVERLAY_V13, // Overlay type number. 314 "V13", // INI name of overlay. 315 TXT_CIV13, // Full name of overlay. 316 LAND_ROCK, // What kind of ground is it? 317 0, // If this is a wall, how many damage levels? 318 0, // If this is a wall, how many damage points can it take per level? 319 false, // Visible on the radar map? 320 false, // Is it a wooden overlay (affected by fire)? 321 false, // Targetable as a destroyable overlay? 322 true, // Crushable by tracked vehicle? 323 false, // Is this harvestable Tiberium? 324 false, // Stops low level bullets in flight? 325 true, // Theater specific art? 326 false, // Is this a wall type? 327 false // Is this a crate? 328 ); 329 static OverlayTypeClass const V14( 330 OVERLAY_V14, // Overlay type number. 331 "V14", // INI name of overlay. 332 TXT_CIV14, // Full name of overlay. 333 LAND_ROCK, // What kind of ground is it? 334 0, // If this is a wall, how many damage levels? 335 0, // If this is a wall, how many damage points can it take per level? 336 false, // Visible on the radar map? 337 false, // Is it a wooden overlay (affected by fire)? 338 false, // Targetable as a destroyable overlay? 339 true, // Crushable by tracked vehicle? 340 false, // Is this harvestable Tiberium? 341 false, // Stops low level bullets in flight? 342 true, // Theater specific art? 343 false, // Is this a wall type? 344 false // Is this a crate? 345 ); 346 static OverlayTypeClass const V15( 347 OVERLAY_V15, // Overlay type number. 348 "V15", // INI name of overlay. 349 TXT_CIV15, // Full name of overlay. 350 LAND_ROCK, // What kind of ground is it? 351 0, // If this is a wall, how many damage levels? 352 0, // If this is a wall, how many damage points can it take per level? 353 false, // Visible on the radar map? 354 false, // Is it a wooden overlay (affected by fire)? 355 false, // Targetable as a destroyable overlay? 356 true, // Crushable by tracked vehicle? 357 false, // Is this harvestable Tiberium? 358 false, // Stops low level bullets in flight? 359 true, // Theater specific art? 360 false, // Is this a wall type? 361 false // Is this a crate? 362 ); 363 static OverlayTypeClass const V16( 364 OVERLAY_V16, // Overlay type number. 365 "V16", // INI name of overlay. 366 TXT_CIV16, // Full name of overlay. 367 LAND_ROCK, // What kind of ground is it? 368 0, // If this is a wall, how many damage levels? 369 0, // If this is a wall, how many damage points can it take per level? 370 false, // Visible on the radar map? 371 false, // Is it a wooden overlay (affected by fire)? 372 false, // Targetable as a destroyable overlay? 373 true, // Crushable by tracked vehicle? 374 false, // Is this harvestable Tiberium? 375 false, // Stops low level bullets in flight? 376 true, // Theater specific art? 377 false, // Is this a wall type? 378 false // Is this a crate? 379 ); 380 static OverlayTypeClass const V17( 381 OVERLAY_V17, // Overlay type number. 382 "V17", // INI name of overlay. 383 TXT_CIV17, // Full name of overlay. 384 LAND_ROCK, // What kind of ground is it? 385 0, // If this is a wall, how many damage levels? 386 0, // If this is a wall, how many damage points can it take per level? 387 false, // Visible on the radar map? 388 false, // Is it a wooden overlay (affected by fire)? 389 false, // Targetable as a destroyable overlay? 390 true, // Crushable by tracked vehicle? 391 false, // Is this harvestable Tiberium? 392 false, // Stops low level bullets in flight? 393 true, // Theater specific art? 394 false, // Is this a wall type? 395 false // Is this a crate? 396 ); 397 static OverlayTypeClass const V18( 398 OVERLAY_V18, // Overlay type number. 399 "V18", // INI name of overlay. 400 TXT_CIV18, // Full name of overlay. 401 LAND_ROCK, // What kind of ground is it? 402 0, // If this is a wall, how many damage levels? 403 0, // If this is a wall, how many damage points can it take per level? 404 false, // Visible on the radar map? 405 false, // Is it a wooden overlay (affected by fire)? 406 false, // Targetable as a destroyable overlay? 407 true, // Crushable by tracked vehicle? 408 false, // Is this harvestable Tiberium? 409 false, // Stops low level bullets in flight? 410 true, // Theater specific art? 411 false, // Is this a wall type? 412 false // Is this a crate? 413 ); 414 static OverlayTypeClass const FlagSpot( 415 OVERLAY_FLAG_SPOT, // Overlay type number. 416 "FPLS", // INI name of overlay. 417 TXT_FLAG_SPOT, // Full name of overlay. 418 LAND_CLEAR, // What kind of ground is it? 419 0, // If this is a wall, how many damage levels? 420 0, // If this is a wall, how many damage points can it take per level? 421 true, // Visible on the radar map? 422 false, // Is it a wooden overlay (affected by fire)? 423 false, // Targetable as a destroyable overlay? 424 false, // Crushable by tracked vehicle? 425 false, // Is this harvestable Tiberium? 426 false, // Stops low level bullets in flight? 427 false, // Theater specific art? 428 false, // Is this a wall type? 429 false // Is this a crate? 430 ); 431 static OverlayTypeClass const WoodCrate( 432 OVERLAY_WOOD_CRATE, // Overlay type number. 433 "WCRATE", // INI name of overlay. 434 TXT_WOOD_CRATE, // Full name of overlay. 435 LAND_CLEAR, // What kind of ground is it? 436 0, // If this is a wall, how many damage levels? 437 0, // If this is a wall, how many damage points can it take per level? 438 false, // Visible on the radar map? 439 false, // Is it a wooden overlay (affected by fire)? 440 false, // Targetable as a destroyable overlay? 441 false, // Crushable by tracked vehicle? 442 false, // Is this harvestable Tiberium? 443 false, // Stops low level bullets in flight? 444 false, // Theater specific art? 445 false, // Is this a wall type? 446 true // Is this a crate? 447 ); 448 static OverlayTypeClass const WaterCrate( 449 OVERLAY_WATER_CRATE, // Overlay type number. 450 "WWCRATE", // INI name of overlay. 451 TXT_WATER_CRATE, // Full name of overlay. 452 LAND_WATER, // What kind of ground is it? 453 0, // If this is a wall, how many damage levels? 454 0, // If this is a wall, how many damage points can it take per level? 455 false, // Visible on the radar map? 456 false, // Is it a wooden overlay (affected by fire)? 457 false, // Targetable as a destroyable overlay? 458 false, // Crushable by tracked vehicle? 459 false, // Is this harvestable Tiberium? 460 false, // Stops low level bullets in flight? 461 false, // Theater specific art? 462 false, // Is this a wall type? 463 true // Is this a crate? 464 ); 465 static OverlayTypeClass const SteelCrate( 466 OVERLAY_STEEL_CRATE, // Overlay type number. 467 "SCRATE", // INI name of overlay. 468 TXT_STEEL_CRATE, // Full name of overlay. 469 LAND_CLEAR, // What kind of ground is it? 470 0, // If this is a wall, how many damage levels? 471 0, // If this is a wall, how many damage points can it take per level? 472 false, // Visible on the radar map? 473 false, // Is it a wooden overlay (affected by fire)? 474 false, // Targetable as a destroyable overlay? 475 false, // Crushable by tracked vehicle? 476 false, // Is this harvestable Tiberium? 477 false, // Stops low level bullets in flight? 478 false, // Theater specific art? 479 false, // Is this a wall type? 480 true // Is this a crate? 481 ); 482 483 484 /*********************************************************************************************** 485 * OverlayTypeClass::OverlayTypeClass -- Constructor for overlay type objects. * 486 * * 487 * This is the constructor for the overlay types. * 488 * * 489 * INPUT: see below... * 490 * * 491 * OUTPUT: none * 492 * * 493 * WARNINGS: none * 494 * * 495 * HISTORY: * 496 * 07/29/1994 JLB : Created. * 497 *=============================================================================================*/ 498 OverlayTypeClass::OverlayTypeClass( 499 OverlayType iconset, 500 char const * ininame, 501 int fullname, 502 LandType ground, 503 int damagelevels, 504 int damagepoints, 505 bool isradarvisible, 506 bool iswooden, 507 bool istarget, 508 bool iscrushable, 509 bool istiberium, 510 bool high, 511 bool theater, 512 bool walltype, 513 bool iscrate) : 514 ObjectTypeClass(RTTI_OVERLAYTYPE, 515 int(iconset), 516 false, 517 true, 518 false, 519 istarget, 520 true, 521 false, 522 false, 523 fullname, 524 ininame), 525 Type(iconset), 526 Land(ground), 527 DamageLevels(damagelevels), 528 DamagePoints(damagepoints), 529 IsTheater(theater), 530 IsWall(walltype), 531 IsHigh(high), 532 IsTiberium(istiberium), 533 IsWooden(iswooden), 534 IsCrate(iscrate), 535 IsRadarVisible(isradarvisible) 536 { 537 IsCrushable = iscrushable; 538 } 539 540 541 /*********************************************************************************************** 542 * OverlayTypeClass::operator new -- Allocate an overlay type class object from pool. * 543 * * 544 * This will allocate an overlay type class object from the special memory pool that is * 545 * for that purpose. * 546 * * 547 * INPUT: none * 548 * * 549 * OUTPUT: Returns with a pointer to the overlay type class object allocated. If there is * 550 * insufficient memory to fulfill the request, then NULL is returned. * 551 * * 552 * WARNINGS: none * 553 * * 554 * HISTORY: * 555 * 07/09/1996 JLB : Created. * 556 *=============================================================================================*/ 557 void * OverlayTypeClass::operator new(size_t) 558 { 559 return(OverlayTypes.Alloc()); 560 } 561 562 563 /*********************************************************************************************** 564 * OverlayTypeClass::operator delete -- Returns an overlay type object back to the pool. * 565 * * 566 * This will return a previously allcoated overaly type object to the special memory * 567 * pool that it was allocated from. * 568 * * 569 * INPUT: pointer -- Pointer to the overlay type class object to return the memory pool. * 570 * * 571 * OUTPUT: none * 572 * * 573 * WARNINGS: none * 574 * * 575 * HISTORY: * 576 * 07/09/1996 JLB : Created. * 577 *=============================================================================================*/ 578 void OverlayTypeClass::operator delete(void * pointer) 579 { 580 OverlayTypes.Free((OverlayTypeClass *)pointer); 581 } 582 583 584 /*********************************************************************************************** 585 * OverlayTypeClass::Init_Heap -- Initialize the overlay type class heap. * 586 * * 587 * This will initialize the overlay type heap by pre-allocated all overlay types known * 588 * to exist. * 589 * * 590 * INPUT: none * 591 * * 592 * OUTPUT: none * 593 * * 594 * WARNINGS: It should be called once and before the rules.ini file is processed. * 595 * * 596 * HISTORY: * 597 * 07/09/1996 JLB : Created. * 598 *=============================================================================================*/ 599 void OverlayTypeClass::Init_Heap(void) 600 { 601 /* 602 ** These overlay type class objects must be allocated in the exact order that they 603 ** are specified in the OverlayType enumeration. This is necessary because the heap 604 ** allocation block index serves double duty as the type number index. 605 */ 606 new OverlayTypeClass(Sandbag); // OVERLAY_SANDBAG_WALL 607 new OverlayTypeClass(Cyclone); // OVERLAY_CYCLONE_WALL 608 new OverlayTypeClass(Brick); // OVERLAY_BRICK_WALL 609 new OverlayTypeClass(Barbwire); // OVERLAY_BARBWIRE_WALL 610 new OverlayTypeClass(Wood); // OVERLAY_WOOD_WALL 611 new OverlayTypeClass(Gold1); // OVERLAY_GOLD1 612 new OverlayTypeClass(Gold2); // OVERLAY_GOLD2 613 new OverlayTypeClass(Gold3); // OVERLAY_GOLD3 614 new OverlayTypeClass(Gold4); // OVERLAY_GOLD4 615 new OverlayTypeClass(Gems1); // OVERLAY_GEMS1 616 new OverlayTypeClass(Gems2); // OVERLAY_GEMS2 617 new OverlayTypeClass(Gems3); // OVERLAY_GEMS3 618 new OverlayTypeClass(Gems4); // OVERLAY_GEMS4 619 new OverlayTypeClass(V12); // OVERLAY_V12 620 new OverlayTypeClass(V13); // OVERLAY_V13 621 new OverlayTypeClass(V14); // OVERLAY_V14 622 new OverlayTypeClass(V15); // OVERLAY_V15 623 new OverlayTypeClass(V16); // OVERLAY_V16 624 new OverlayTypeClass(V17); // OVERLAY_V17 625 new OverlayTypeClass(V18); // OVERLAY_V18 626 new OverlayTypeClass(FlagSpot); // OVERLAY_FLAG_SPOT 627 new OverlayTypeClass(WoodCrate); // OVERLAY_WOOD_CRATE 628 new OverlayTypeClass(SteelCrate); // OVERLAY_STEEL_CRATE 629 new OverlayTypeClass(Fence); // OVERLAY_FENCE 630 new OverlayTypeClass(WaterCrate); // OVERLAY_WATER_CRATE 631 } 632 633 634 /*********************************************************************************************** 635 * OverlayTypeClass::One_Time -- Loads all the necessary general overlay shape data. * 636 * * 637 * This routine should be called once when the game first starts. It will establish * 638 * pointers to the graphic data of the overlay objects. * 639 * * 640 * INPUT: none * 641 * * 642 * OUTPUT: none * 643 * * 644 * WARNINGS: none * 645 * * 646 * HISTORY: * 647 * 08/12/1994 JLB : Created. * 648 *=============================================================================================*/ 649 void OverlayTypeClass::One_Time(void) 650 { 651 } 652 653 654 /*********************************************************************************************** 655 * OverlayTypeClass::From_Name -- Determine overlay from ASCII name. * 656 * * 657 * This routine is used to determine the overlay number given only * 658 * an ASCII representation. The scenario loader uses this routine * 659 * to construct the map from the INI control file. * 660 * * 661 * INPUT: name -- Pointer to the ASCII name of the overlay. * 662 * * 663 * OUTPUT: Returns with the overlay number. If the name had no match, * 664 * then returns with OVERLAY_NONE. * 665 * * 666 * WARNINGS: none * 667 * * 668 * HISTORY: * 669 * 05/23/1994 JLB : Created. * 670 *=============================================================================================*/ 671 OverlayType OverlayTypeClass::From_Name(char const * name) 672 { 673 if (name != NULL) { 674 for (OverlayType index = OVERLAY_FIRST; index < OVERLAY_COUNT; index++) { 675 if (stricmp(As_Reference(index).IniName, name) == 0) { 676 return(index); 677 } 678 } 679 } 680 return(OVERLAY_NONE); 681 } 682 683 684 /*********************************************************************************************** 685 * OverlayTypeClass::Occupy_List -- Determines occupation list. * 686 * * 687 * This routine is used to examine the overlay map and build an * 688 * occupation list. This list is used to render a overlay cursor as * 689 * well as placement of icon numbers. * 690 * * 691 * INPUT: placement -- Is this for placement legality checking only? The normal condition * 692 * is for marking occupation flags. * 693 * * 694 * OUTPUT: Returns with a pointer to the overlay occupation list. * 695 * * 696 * WARNINGS: The return pointer is valid only until the next time that * 697 * this routine is called. * 698 * * 699 * HISTORY: * 700 * 05/23/1994 JLB : Created. * 701 *=============================================================================================*/ 702 short const * OverlayTypeClass::Occupy_List(bool) const 703 { 704 static short _simple[] = {0, REFRESH_EOL}; 705 706 return(_simple); 707 } 708 709 710 /*************************************************************************** 711 * OverlayTypeClass::Radar_Icon -- Gets a pointer to the radar icons * 712 * * 713 * * 714 * INPUT: * 715 * * 716 * OUTPUT: * 717 * * 718 * WARNINGS: * 719 * * 720 * HISTORY: * 721 * 04/19/1995 PWG : Created. * 722 *=========================================================================*/ 723 unsigned char * OverlayTypeClass::Radar_Icon(int data) const 724 { 725 unsigned char * icon = (unsigned char *)Get_Radar_Data(); // Get pointer to radar icons 726 if (icon != NULL) icon += (data * 9) + 2; // move icon ptr to correct icon 727 return(icon); // Return the correct icon 728 } 729 730 731 #ifdef SCENARIO_EDITOR 732 /*********************************************************************************************** 733 * OverlayTypeClass::Display -- Displays a generic representation of overlay. * 734 * * 735 * This routine is used to display a generic view of the overlay * 736 * object. This is necessary for selection in the scenario editor. * 737 * * 738 * INPUT: x,y -- The coordinates to center the display about. * 739 * * 740 * window-- The window to base the coordinates upon. * 741 * * 742 * OUTPUT: none * 743 * * 744 * WARNINGS: none * 745 * * 746 * HISTORY: * 747 * 05/23/1994 JLB : Created. * 748 *=============================================================================================*/ 749 void OverlayTypeClass::Display(int x, int y, WindowNumberType window, HousesType ) const 750 { 751 if (Get_Image_Data() != NULL) { 752 int frame = 0; 753 754 if (IsTiberium) { 755 frame = 7; 756 } 757 if (Type == OVERLAY_GEMS1 || Type == OVERLAY_GEMS2 || Type == OVERLAY_GEMS3 || Type == OVERLAY_GEMS4) { 758 frame = 2; 759 } 760 761 IsTheaterShape = IsTheater; 762 CC_Draw_Shape(Get_Image_Data(), frame, x, y, window, SHAPE_NORMAL|SHAPE_CENTER|SHAPE_WIN_REL); 763 IsTheaterShape = false; 764 } 765 } 766 767 768 /*********************************************************************************************** 769 * OverlayTypeClass::Prep_For_Add -- Prepares to add overlay to scenario. * 770 * * 771 * This routine prepares a list of overlay objects so that the * 772 * scenario editor can use this list to display a dialog box. The * 773 * selection of a overlay object will allow its placement upon the * 774 * map. * 775 * * 776 * INPUT: none * 777 * * 778 * OUTPUT: none * 779 * * 780 * WARNINGS: none * 781 * * 782 * HISTORY: * 783 * 08/06/1994 JLB : Created * 784 *=============================================================================================*/ 785 void OverlayTypeClass::Prep_For_Add(void) 786 { 787 for (OverlayType index = OVERLAY_FIRST; index < OVERLAY_COUNT; index++) { 788 OverlayTypeClass const & overlay = As_Reference(index); 789 if (overlay.Get_Image_Data() != NULL && 790 !overlay.IsWall && 791 (!overlay.IsTiberium || index == OVERLAY_GOLD1 || index == OVERLAY_GEMS1)) { 792 793 Map.Add_To_List(&overlay); 794 } 795 } 796 } 797 #endif 798 799 800 /*********************************************************************************************** 801 * OverlayTypeClass::Create_And_Place -- Creates and places a overlay object on the map. * 802 * * 803 * This support routine is used by the scenario editor to add a overlay object to the map * 804 * and to the game. * 805 * * 806 * INPUT: cell -- The cell to place the overlay object. * 807 * * 808 * OUTPUT: bool; Was the overlay object placed successfully? * 809 * * 810 * WARNINGS: none * 811 * * 812 * HISTORY: * 813 * 05/28/1994 JLB : Created. * 814 *=============================================================================================*/ 815 bool OverlayTypeClass::Create_And_Place(CELL cell, HousesType ) const 816 { 817 if (new OverlayClass(Type, cell)) { 818 return(true); 819 } 820 return(false); 821 } 822 823 824 /*********************************************************************************************** 825 * OverlayTypeClass::Create_One_Of -- Creates an object of this overlay type. * 826 * * 827 * This routine will create an object of this type. For certain overlay objects, such * 828 * as walls, it is actually created as a building. The "building" wall is converted into * 829 * a overlay at the moment of placing down on the map. * 830 * * 831 * INPUT: none * 832 * * 833 * OUTPUT: Returns with a pointer to the appropriate object for this overlay type. * 834 * * 835 * WARNINGS: none * 836 * * 837 * HISTORY: * 838 * 06/18/1994 JLB : Created. * 839 *=============================================================================================*/ 840 ObjectClass * OverlayTypeClass::Create_One_Of(HouseClass *) const 841 { 842 return(new OverlayClass(Type, -1)); 843 } 844 845 846 /*********************************************************************************************** 847 * OverlayTypeClass::Draw_It -- Draws the overlay image at location specified. * 848 * * 849 * This routine will draw the overlay shape at the coordinates specified. It is presumed * 850 * that all the underlying layers have already been rendered by the time this routine is * 851 * called. * 852 * * 853 * INPUT: x, y -- Coordinate (upper left) of cell where overlay image is to be drawn. * 854 * * 855 * data -- Cell specific data that controls the imagery of the overlay. * 856 * * 857 * OUTPUT: none * 858 * * 859 * WARNINGS: none * 860 * * 861 * HISTORY: * 862 * 08/12/1994 JLB : Created. * 863 *=============================================================================================*/ 864 void OverlayTypeClass::Draw_It(int x, int y, int data) const 865 { 866 IsTheaterShape = IsTheater; 867 CC_Draw_Shape(Get_Image_Data(), data, Map.TacPixelX+x+(CELL_PIXEL_W>>1), Map.TacPixelY+y+(CELL_PIXEL_H>>1), WINDOW_MAIN, SHAPE_CENTER|SHAPE_WIN_REL|SHAPE_GHOST, NULL, Map.UnitShadow); 868 IsTheaterShape = false; 869 } 870 871 872 /*********************************************************************************************** 873 * OverlayTypeClass::Init -- Initialize the overlay graphic data per theater. * 874 * * 875 * This routine will update the overlay graphic data according to the theater specified. * 876 * It is typically called when the scenario is first loaded (theater change). * 877 * * 878 * INPUT: theater -- The theater to load specific data for. * 879 * * 880 * OUTPUT: none * 881 * * 882 * WARNINGS: none * 883 * * 884 * HISTORY: * 885 * 09/01/1994 JLB : Created. * 886 *=============================================================================================*/ 887 void OverlayTypeClass::Init(TheaterType theater) 888 { 889 if (theater != LastTheater) { 890 891 for (OverlayType index = OVERLAY_FIRST; index < OVERLAY_COUNT; index++) { 892 OverlayTypeClass & overlay = As_Reference(index); 893 char fullname[_MAX_FNAME+_MAX_EXT]; // Fully constructed iconset name. 894 895 if (overlay.IsTheater) { 896 _makepath(fullname, NULL, NULL, overlay.IniName, Theaters[theater].Suffix); 897 } else { 898 _makepath(fullname, NULL, NULL, overlay.IniName, ".SHP"); 899 } 900 overlay.ImageData = MFCD::Retrieve(fullname); 901 902 IsTheaterShape = overlay.IsTheater; //Tell Build_Frame if this is a theater specific shape 903 if (overlay.RadarIcon != NULL) delete[] (char *)overlay.RadarIcon; 904 overlay.RadarIcon = Get_Radar_Icon(overlay.Get_Image_Data(), 0, -1, 3); 905 IsTheaterShape = false; 906 } 907 } 908 } 909 910 911 /*********************************************************************************************** 912 * OverlayTypeClass::As_Reference -- Fetch a reference to the overlay type specified. * 913 * * 914 * Use this routine to get a reference that corresponds to the overlay type. * 915 * * 916 * INPUT: type -- The overlay type to fetch a reference to. * 917 * * 918 * OUTPUT: Returns with a reference to the overlay type specified. * 919 * * 920 * WARNINGS: Be sure that the overlay type specified is legal. Illegal type value will * 921 * result in undefined behavior. * 922 * * 923 * HISTORY: * 924 * 07/09/1996 JLB : Created. * 925 *=============================================================================================*/ 926 OverlayTypeClass & OverlayTypeClass::As_Reference(OverlayType type) 927 { 928 return(*OverlayTypes.Ptr(type)); 929 } 930 931 932 /*********************************************************************************************** 933 * OverlayTypeClass::Coord_Fixup -- Adjust the coord to be legal for assignment. * 934 * * 935 * This will adjust the coordinate specified so that it will be of legal format to * 936 * assign as the coordinate of an overlay. Overlays are always relative to the upper left * 937 * corner of the cell, so this routine drops the fractional cell components. * 938 * * 939 * INPUT: coord -- The coordinate to fixup to be legal for assignment. * 940 * * 941 * OUTPUT: Returns with a properly fixed up coordinate. * 942 * * 943 * WARNINGS: none * 944 * * 945 * HISTORY: * 946 * 08/14/1996 JLB : Created. * 947 *=============================================================================================*/ 948 COORDINATE OverlayTypeClass::Coord_Fixup(COORDINATE coord) const 949 { 950 return Coord_Whole(coord); 951 }