-
Notifications
You must be signed in to change notification settings - Fork 167
bugfix(namekeys): Remove hardcoded NameKeyIDs from dummy strings for modded files #2349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -508,6 +508,10 @@ void GameEngine::init() | |
| #endif///////////////////////////////////////////////////////////////////////////////////////////// | ||
|
|
||
|
|
||
| #if RETAIL_COMPATIBLE_CRC | ||
| if (xferCRC.getCRC() == 0xA1E7F8E6) TheNameKeyGenerator->verifyNameKeyID(1); | ||
| #endif | ||
|
|
||
| initSubsystem(TheScienceStore,"TheScienceStore", MSGNEW("GameEngineSubsystem") ScienceStore(), &xferCRC, "Data\\INI\\Default\\Science", "Data\\INI\\Science"); | ||
| initSubsystem(TheMultiplayerSettings,"TheMultiplayerSettings", MSGNEW("GameEngineSubsystem") MultiplayerSettings(), &xferCRC, "Data\\INI\\Default\\Multiplayer", "Data\\INI\\Multiplayer"); | ||
| initSubsystem(TheTerrainTypes,"TheTerrainTypes", MSGNEW("GameEngineSubsystem") TerrainTypeCollection(), &xferCRC, "Data\\INI\\Default\\Terrain", "Data\\INI\\Terrain"); | ||
|
|
@@ -524,6 +528,10 @@ void GameEngine::init() | |
| if (!TheAudio->isMusicAlreadyLoaded()) | ||
| setQuitting(TRUE); | ||
|
|
||
| #if RTS_ZEROHOUR && RETAIL_COMPATIBLE_CRC | ||
| TheNameKeyGenerator->syncNameKeyID(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of adding the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wanted a better place for a TSH comment that's not in the middle of an enormous function that's not really related. |
||
| #endif | ||
|
|
||
| #ifdef DUMP_PERF_STATS/////////////////////////////////////////////////////////////////////////// | ||
| GetPrecisionTimer(&endTime64);////////////////////////////////////////////////////////////////// | ||
| sprintf(Buf,"----------------------------------------------------------------------------After TheAudio = %f seconds",((double)(endTime64-startTime64)/(double)(freq64))); | ||
|
|
@@ -578,6 +586,10 @@ void GameEngine::init() | |
| #endif///////////////////////////////////////////////////////////////////////////////////////////// | ||
|
|
||
|
|
||
| #if RETAIL_COMPATIBLE_CRC | ||
| if (xferCRC.getCRC() == 0x6209AF6E) TheNameKeyGenerator->verifyNameKeyID(2265); | ||
| #endif | ||
|
|
||
| initSubsystem(TheUpgradeCenter,"TheUpgradeCenter", MSGNEW("GameEngineSubsystem") UpgradeCenter, &xferCRC, "Data\\INI\\Default\\Upgrade", "Data\\INI\\Upgrade"); | ||
| initSubsystem(TheGameClient,"TheGameClient", createGameClient(), nullptr); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -123,68 +123,49 @@ AsciiString NameKeyGenerator::keyToName(NameKeyType key) | |
| } | ||
|
|
||
| //------------------------------------------------------------------------------------------------- | ||
| #if RTS_ZEROHOUR && RETAIL_COMPATIBLE_CRC | ||
| // TheSuperHackers @info xezon 04/09/2025 This key reservation is required for CRC compatibility, | ||
| // because the name keys are somehow CRC relevant. It was originally used by the file exist cache | ||
| // of the file system in Zero Hour. | ||
| Bool NameKeyGenerator::addReservedKey() | ||
| #if RETAIL_COMPATIBLE_CRC | ||
| #if RTS_ZEROHOUR | ||
| // TheSuperHackers @bugfix Caball009 24/02/2026 Originally the game would hash three files | ||
| // for the file exist cache of the file system in Zero Hour. | ||
| // TheScienceStore and TheUpgradeCenter rely on having the exact same name key IDs across all clients. | ||
| // That means that we still need to hash 3 dummy strings to keep the name key IDs synchronized with retail. | ||
| void NameKeyGenerator::syncNameKeyID() | ||
| { | ||
| switch (m_nextID) | ||
| { | ||
| case 97: nameToLowercaseKeyImpl("Data\\English\\Language9x.ini"); return true; | ||
| case 98: nameToLowercaseKeyImpl("Data\\Audio\\Tracks\\English\\GLA_02.mp3"); return true; | ||
| case 99: nameToLowercaseKeyImpl("Data\\Audio\\Tracks\\GLA_02.mp3"); return true; | ||
| } | ||
| return false; | ||
| nameToKey("TSH_dummy_string_1"); | ||
| nameToKey("TSH_dummy_string_2"); | ||
| nameToKey("TSH_dummy_string_3"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest to preserve the original strings for context
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I can use the strings that were added in #1516. Those strings depend either on registry language and / or use sound track names that can be changed by mods, though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is mainly about preserving the context for what these strings are for the next person to look at it.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's fair. |
||
| } | ||
| #endif | ||
| void NameKeyGenerator::verifyNameKeyID(UnsignedInt expectedNextID) const | ||
| { | ||
| // this should only be called before the initialization of TheScienceStore and TheUpgradeCenter in GameEngine::init | ||
| DEBUG_ASSERTCRASH(expectedNextID == m_nextID, | ||
| ("Retail client expects items to start with name key ID %d for unmodded files, but starts with %d", expectedNextID, m_nextID)); | ||
| } | ||
| #endif | ||
|
|
||
| //------------------------------------------------------------------------------------------------- | ||
| NameKeyType NameKeyGenerator::nameToKey(const AsciiString& name) | ||
| { | ||
| const NameKeyType key = nameToKeyImpl(name); | ||
|
|
||
| #if RTS_ZEROHOUR && RETAIL_COMPATIBLE_CRC | ||
| while (addReservedKey()); | ||
| #endif | ||
|
|
||
| return key; | ||
| return nameToKeyImpl(name); | ||
| } | ||
|
|
||
| //------------------------------------------------------------------------------------------------- | ||
| NameKeyType NameKeyGenerator::nameToLowercaseKey(const AsciiString& name) | ||
| { | ||
| const NameKeyType key = nameToLowercaseKeyImpl(name); | ||
|
|
||
| #if RTS_ZEROHOUR && RETAIL_COMPATIBLE_CRC | ||
| while (addReservedKey()); | ||
| #endif | ||
|
|
||
| return key; | ||
| return nameToLowercaseKeyImpl(name); | ||
| } | ||
|
|
||
| //------------------------------------------------------------------------------------------------- | ||
| NameKeyType NameKeyGenerator::nameToKey(const char* name) | ||
| { | ||
| const NameKeyType key = nameToKeyImpl(name); | ||
|
|
||
| #if RTS_ZEROHOUR && RETAIL_COMPATIBLE_CRC | ||
| while (addReservedKey()); | ||
| #endif | ||
|
|
||
| return key; | ||
| return nameToKeyImpl(name); | ||
| } | ||
|
|
||
| //------------------------------------------------------------------------------------------------- | ||
| NameKeyType NameKeyGenerator::nameToLowercaseKey(const char *name) | ||
| { | ||
| const NameKeyType key = nameToLowercaseKeyImpl(name); | ||
|
|
||
| #if RTS_ZEROHOUR && RETAIL_COMPATIBLE_CRC | ||
| while (addReservedKey()); | ||
| #endif | ||
|
|
||
| return key; | ||
| return nameToLowercaseKeyImpl(name); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This means you can merge Four times. |
||
| } | ||
|
|
||
| //------------------------------------------------------------------------------------------------- | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use new line.
Multiple times.