Skip to content

Commit fa8333c

Browse files
committed
Adds case to fixup the loaded Rules data due to the change to the default engineer capture values.
1 parent 536649a commit fa8333c

File tree

2 files changed

+96
-3
lines changed

2 files changed

+96
-3
lines changed

src/extensions/rules/rulesext.cpp

+95-2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "wwcrc.h"
3838
#include "noinit.h"
3939
#include "swizzle.h"
40+
#include "addon.h"
4041
#include "vinifera_saveload.h"
4142
#include "asserthandler.h"
4243
#include "debughandler.h"
@@ -78,6 +79,18 @@ RulesClassExtension::RulesClassExtension(const RulesClass *this_ptr) :
7879
IsShowSuperWeaponTimers(true)
7980
{
8081
//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.
8194
}
8295

8396

@@ -276,7 +289,7 @@ void RulesClassExtension::Process(CCINIClass &ini)
276289
/**
277290
* Fixup various inconsistencies in the original INI files.
278291
*/
279-
Fixups();
292+
Fixups(ini);
280293
}
281294

282295

@@ -520,8 +533,87 @@ void RulesClassExtension::Check()
520533
*
521534
* @author: CCHyper
522535
*/
523-
void RulesClassExtension::Fixups()
536+
void RulesClassExtension::Fixups(CCINIClass &ini)
524537
{
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+
525617
HouseTypeClass *housetype = HouseTypes[HOUSE_NOD];
526618
if (housetype) {
527619

@@ -583,4 +675,5 @@ void RulesClassExtension::Fixups()
583675

584676
}
585677

678+
DEBUG_INFO("Rules::Fixups(exit)\n");
586679
}

src/extensions/rules/rulesext.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class RulesClassExtension final : public GlobalExtensionClass<RulesClass>
6767

6868
private:
6969
void Check();
70-
void Fixups();
70+
void Fixups(CCINIClass &ini);
7171

7272
public:
7373
/**

0 commit comments

Comments
 (0)