bugfix(namekey): Remove hardcoded NameKeyIDs from dummy strings to work with modded files#2349
Conversation
|
| Filename | Overview |
|---|---|
| Generals/Code/GameEngine/Include/Common/NameKeyGenerator.h | Adds public syncNameKeyID() (ZH-only) and verifyNameKeyID() under RETAIL_COMPATIBLE_CRC guard; removes private addReservedKey() and *Impl() method declarations. Clean restructuring. |
| GeneralsMD/Code/GameEngine/Include/Common/NameKeyGenerator.h | Mirrors Generals header changes: adds public syncNameKeyID() (ZH-only) and verifyNameKeyID(), removes private addReservedKey() and *Impl() declarations. |
| Generals/Code/GameEngine/Source/Common/NameKeyGenerator.cpp | Replaces addReservedKey()/while-loop mechanism with direct syncNameKeyID() call; nameToKeyImpl/nameToLowercaseKeyImpl renamed to nameToKey/nameToLowercaseKey (removing the split). verifyNameKeyID() added as a DEBUG_ASSERTCRASH check. |
| GeneralsMD/Code/GameEngine/Source/Common/NameKeyGenerator.cpp | Identical structural changes to Generals counterpart. syncNameKeyID() and verifyNameKeyID() correctly introduced under appropriate preprocessor guards. |
| Generals/Code/GameEngine/Source/Common/GameEngine.cpp | Adds verifyNameKeyID() assertions at two checkpoints and a (dead-code) syncNameKeyID() call under RTS_ZEROHOUR guard. CRC/ID values for Generals are explicitly marked TODO-unverified by the author. |
| GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp | Adds verifyNameKeyID() assertions at two checkpoints and syncNameKeyID() call after TheAudio init. CRC/ID values appear correct for unmodded Zero Hour. |
Sequence Diagram
sequenceDiagram
participant GE as GameEngine::init()
participant NKG as NameKeyGenerator
participant CRC as xferCRC
GE->>NKG: (subsystems initialized, no CRC keys registered)
GE->>CRC: getCRC()
Note over GE,CRC: RETAIL_COMPATIBLE_CRC only
GE->>NKG: verifyNameKeyID(1) [if CRC matches]
GE->>GE: initSubsystem(TheScienceStore)
GE->>GE: initSubsystem(TheMultiplayerSettings)
GE->>GE: initSubsystem(TheTerrainTypes)
GE->>GE: initSubsystem(TheTerrainRoads)
GE->>GE: initSubsystem(TheGlobalLanguageData)
GE->>GE: initSubsystem(TheAudio)
GE->>NKG: syncNameKeyID() [RTS_ZEROHOUR && RETAIL_COMPATIBLE_CRC]
Note over NKG: nameToLowercaseKey("Data\\English\\Language9x.ini") → ID 97
Note over NKG: nameToLowercaseKey("Data\\Audio\\Tracks\\English\\GLA_02.mp3") → ID 98
Note over NKG: nameToLowercaseKey("Data\\Audio\\Tracks\\GLA_02.mp3") → ID 99
GE->>GE: initSubsystem(TheFunctionLexicon, ..., TheThingFactory)
GE->>CRC: getCRC()
Note over GE,CRC: RETAIL_COMPATIBLE_CRC only
GE->>NKG: verifyNameKeyID(1586/2265) [if CRC matches]
GE->>GE: initSubsystem(TheUpgradeCenter)
GE->>GE: initSubsystem(TheGameClient)
Last reviewed commit: ede0456
xezon
left a comment
There was a problem hiding this comment.
Looks plausible. Needs to be replicated to Generals.
|
Replicated in Generals, manually resolved merge conflicts.
|
|
Perhaps it's best to keep the issue open because it touches on a larger issue that this PR does not fix.
#1516 adds three strings with hardcoded name key IDs. This PR fixes the following issue:
I've added a second commit with debug assertions for the correct name key ID with unmodded files to help us detect undesirable additions or removals of name keys.
TODO: