|
37 | 37 | #include "wwcrc.h"
|
38 | 38 | #include "noinit.h"
|
39 | 39 | #include "swizzle.h"
|
| 40 | +#include "addon.h" |
40 | 41 | #include "vinifera_saveload.h"
|
41 | 42 | #include "asserthandler.h"
|
42 | 43 | #include "debughandler.h"
|
@@ -78,6 +79,18 @@ RulesClassExtension::RulesClassExtension(const RulesClass *this_ptr) :
|
78 | 79 | IsShowSuperWeaponTimers(true)
|
79 | 80 | {
|
80 | 81 | //if (this_ptr) EXT_DEBUG_TRACE("RulesClassExtension::RulesClassExtension - 0x%08X\n", (uintptr_t)(ThisPtr));
|
| 82 | + |
| 83 | + /** |
| 84 | + * Due to the changes made when addressing issues #632, 633, and 635, we |
| 85 | + * need change the default engineer capture values. These values are from |
| 86 | + * Red Alert 1, and they match the expected hardcoded behavior of the |
| 87 | + * Multi Engineer logic in the release version of Tiberian Sun. |
| 88 | + * |
| 89 | + * Fixing the default values here ensures Multi-Engineer works in Tiberian Sun |
| 90 | + * without manually fixing up the ini data (which is required for Firestorm). |
| 91 | + */ |
| 92 | + This()->EngineerDamage = 1.0f / 3; // Amount of damage an engineer does. |
| 93 | + This()->EngineerCaptureLevel = This()->ConditionRed; // Building damage level before engineer can capture. |
81 | 94 | }
|
82 | 95 |
|
83 | 96 |
|
@@ -276,7 +289,7 @@ void RulesClassExtension::Process(CCINIClass &ini)
|
276 | 289 | /**
|
277 | 290 | * Fixup various inconsistencies in the original INI files.
|
278 | 291 | */
|
279 |
| - Fixups(); |
| 292 | + Fixups(ini); |
280 | 293 | }
|
281 | 294 |
|
282 | 295 |
|
@@ -520,8 +533,87 @@ void RulesClassExtension::Check()
|
520 | 533 | *
|
521 | 534 | * @author: CCHyper
|
522 | 535 | */
|
523 |
| -void RulesClassExtension::Fixups() |
| 536 | +void RulesClassExtension::Fixups(CCINIClass &ini) |
524 | 537 | {
|
| 538 | + DEBUG_INFO("Rules::Fixups(enter)\n"); |
| 539 | + |
| 540 | + /** |
| 541 | + * These are the CRC values for the unmodified ini files, TS2.03EN. |
| 542 | + */ |
| 543 | + static const int Unmodified_RuleINI_CRC = 0x9F3ECD2A; |
| 544 | + static const int Unmodified_FSRuleINI_CRC = 0xA0738E22; |
| 545 | + |
| 546 | + /** |
| 547 | + * Constant values to change to. |
| 548 | + */ |
| 549 | + /*static*/ const float CorrectEngineerDamage = 1.0f / 3; // Amount of damage an engineer does. |
| 550 | + /*static*/ const float CorrectEngineerCaptureLevel = This()->ConditionRed; // Building damage level before engineer can capture. |
| 551 | + |
| 552 | + /** |
| 553 | + * Fetch the unique crc values for both rule databases. |
| 554 | + */ |
| 555 | + int rule_crc = RuleINI->Get_Unique_ID(); |
| 556 | + DEV_DEBUG_INFO("Rules: RuleINI CRC = %lX\n", rule_crc); |
| 557 | + |
| 558 | + int fsrule_crc = FSRuleINI.Get_Unique_ID(); |
| 559 | + if (Addon_Installed(ADDON_FIRESTORM)) { |
| 560 | + DEV_DEBUG_INFO("Rules: FSRuleINI CRC = %lX\n", fsrule_crc); |
| 561 | + } |
| 562 | + |
| 563 | + /** |
| 564 | + * Check to see if the ini files have been modified. |
| 565 | + */ |
| 566 | + bool rule_unmodified = false; |
| 567 | + if (rule_crc == Unmodified_RuleINI_CRC) { |
| 568 | + DEBUG_INFO("Rules: RuleINI is unmodified (version 2.03).\n"); |
| 569 | + rule_unmodified = true; |
| 570 | + } |
| 571 | + bool fsrule_unmodified = false; |
| 572 | + if (Addon_Installed(ADDON_FIRESTORM)) { |
| 573 | + if (fsrule_crc == Unmodified_FSRuleINI_CRC) { |
| 574 | + DEBUG_INFO("Rules: FSRuleINI is unmodified (version 2.03).\n"); |
| 575 | + fsrule_unmodified = true; |
| 576 | + } |
| 577 | + } |
| 578 | + |
| 579 | + /** |
| 580 | + * Detect which unmodified ini file we are currently processing. |
| 581 | + */ |
| 582 | + bool is_ruleini = false; |
| 583 | + if (ini.Get_Unique_ID() == Unmodified_RuleINI_CRC) { |
| 584 | + DEV_DEBUG_INFO("Rules: Current INI is RuleINI.\n"); |
| 585 | + is_ruleini = true; |
| 586 | + } |
| 587 | + bool is_fsruleini = false; |
| 588 | + if (Addon_Installed(ADDON_FIRESTORM) && ini.Get_Unique_ID() == Unmodified_FSRuleINI_CRC) { |
| 589 | + DEV_DEBUG_INFO("Rules: Current INI is FSRuleINI.\n"); |
| 590 | + is_fsruleini = true; |
| 591 | + } |
| 592 | + |
| 593 | + /** |
| 594 | + * Fix up the multi engineer values if we have possibly detected the original, unmodified ini databases. |
| 595 | + * |
| 596 | + * Match criteria; |
| 597 | + * - Are we currently processing FSRuleINI? |
| 598 | + * - EngineerCaptureLevel is "1.0" |
| 599 | + * - EngineerDamage is "0.0" |
| 600 | + */ |
| 601 | + if (is_fsruleini) { |
| 602 | + |
| 603 | + if (This()->EngineerCaptureLevel == 1.0f && This()->EngineerDamage == 0.0f) { |
| 604 | + |
| 605 | + DEBUG_WARNING("Rules: EngineerCaptureLevel is '%.2f', changing to '%.2f'!\n", This()->EngineerDamage, CorrectEngineerCaptureLevel); |
| 606 | + DEBUG_WARNING("Rules: Please consider changing EngineerCaptureLevel to %.2f!\n", CorrectEngineerCaptureLevel); |
| 607 | + This()->EngineerCaptureLevel = CorrectEngineerCaptureLevel; |
| 608 | + |
| 609 | + DEBUG_WARNING("Rules: EngineerDamage is '%.2f', changing to '%.2f'!\n", This()->EngineerDamage, CorrectEngineerDamage); |
| 610 | + DEBUG_WARNING("Rules: Please consider changing EngineerDamage to %.2f!\n", CorrectEngineerDamage); |
| 611 | + This()->EngineerDamage = CorrectEngineerDamage; |
| 612 | + |
| 613 | + } |
| 614 | + |
| 615 | + } |
| 616 | + |
525 | 617 | HouseTypeClass *housetype = HouseTypes[HOUSE_NOD];
|
526 | 618 | if (housetype) {
|
527 | 619 |
|
@@ -583,4 +675,5 @@ void RulesClassExtension::Fixups()
|
583 | 675 |
|
584 | 676 | }
|
585 | 677 |
|
| 678 | + DEBUG_INFO("Rules::Fixups(exit)\n"); |
586 | 679 | }
|
0 commit comments