Skip to content

Conversation

@xezon
Copy link

@xezon xezon commented Jan 26, 2026

This change merges the Registry code in GameEngine.

@xezon xezon added this to the Code foundation build up milestone Jan 26, 2026
@xezon xezon added Gen Relates to Generals ZH Relates to Zero Hour Unify Unifies code between Generals and Zero Hour labels Jan 26, 2026
@greptile-apps
Copy link

greptile-apps bot commented Jan 26, 2026

Greptile Overview

Greptile Summary

This PR successfully merges Registry code between Generals and GeneralsMD (Zero Hour) codebases by introducing conditional compilation using RTS_GENERALS and RTS_ZEROHOUR macros. The changes unify the registry access implementations while maintaining version-specific behavior.

Key changes:

  • Added GetStringFromGeneralsRegistry() function to Generals codebase (wrapped in #if RTS_ZEROHOUR) to allow Zero Hour builds to access the original Generals registry
  • Modified GetStringFromRegistry() and GetUnsignedIntFromRegistry() to use conditional compilation for version-specific registry paths
  • Wrapped GeneralsMD's existing GetStringFromGeneralsRegistry() in #if RTS_ZEROHOUR guard for consistency
  • Added explanatory comment about static variable memory leak in GetRegistryLanguage()

The conditional compilation approach is clean and follows the existing codebase patterns. The registry paths correctly distinguish between "Generals" and "Command and Conquer Generals Zero Hour" based on the build configuration.

Confidence Score: 5/5

  • This PR is safe to merge with no risks identified
  • The changes are straightforward refactoring that unifies existing code using well-established conditional compilation patterns. The logic remains identical to the original implementations, just reorganized with proper preprocessor guards. All custom instructions are properly followed, and the changes maintain backward compatibility while enabling code reuse.
  • No files require special attention

Important Files Changed

Filename Overview
Generals/Code/GameEngine/Include/Common/Registry.h Added GetStringFromGeneralsRegistry() declaration guarded by RTS_ZEROHOUR macro for cross-version registry access
Generals/Code/GameEngine/Source/Common/System/registry.cpp Unified registry code with conditional compilation for Generals vs Zero Hour registry paths, added GetStringFromGeneralsRegistry() implementation and explanatory comment
GeneralsMD/Code/GameEngine/Include/Common/Registry.h Wrapped GetStringFromGeneralsRegistry() declaration in RTS_ZEROHOUR guard for consistency
GeneralsMD/Code/GameEngine/Source/Common/System/registry.cpp Added conditional compilation for registry paths and wrapped GetStringFromGeneralsRegistry() in RTS_ZEROHOUR guard, unified with Generals version

Sequence Diagram

sequenceDiagram
    participant App as Application
    participant API as Registry API
    participant Helper as Registry Helper
    participant Win as Windows Registry

    Note over App,Win: Generals Build (RTS_GENERALS=1)
    App->>API: GetStringFromRegistry(path, key, val)
    API->>API: fullPath = "SOFTWARE\\EA\\Generals" + path
    API->>Helper: getStringFromRegistry(HKEY_LOCAL_MACHINE, fullPath, key, val)
    Helper->>Win: RegOpenKeyEx(HKEY_LOCAL_MACHINE)
    Win-->>Helper: SUCCESS/FAIL
    alt Success
        Helper-->>API: return TRUE
    else Fail
        API->>Helper: getStringFromRegistry(HKEY_CURRENT_USER, fullPath, key, val)
        Helper->>Win: RegOpenKeyEx(HKEY_CURRENT_USER)
        Win-->>Helper: SUCCESS/FAIL
        Helper-->>API: return TRUE/FALSE
    end
    API-->>App: return result

    Note over App,Win: Zero Hour Build (RTS_ZEROHOUR=1)
    App->>API: GetStringFromRegistry(path, key, val)
    API->>API: fullPath = "SOFTWARE\\EA\\ZH" + path
    API->>Helper: getStringFromRegistry(HKEY_LOCAL_MACHINE, fullPath, key, val)
    Helper->>Win: RegOpenKeyEx(HKEY_LOCAL_MACHINE)
    Win-->>Helper: SUCCESS/FAIL
    alt Success
        Helper-->>API: return TRUE
    else Fail
        API->>Helper: getStringFromRegistry(HKEY_CURRENT_USER, fullPath, key, val)
        Helper->>Win: RegOpenKeyEx(HKEY_CURRENT_USER)
        Win-->>Helper: SUCCESS/FAIL
        Helper-->>API: return TRUE/FALSE
    end
    API-->>App: return result

    Note over App,Win: Zero Hour accessing Generals registry
    App->>API: GetStringFromGeneralsRegistry(path, key, val)
    API->>API: fullPath = "SOFTWARE\\EA\\Generals" + path
    API->>Helper: getStringFromRegistry(HKEY_LOCAL_MACHINE, fullPath, key, val)
    Helper->>Win: RegOpenKeyEx(HKEY_LOCAL_MACHINE)
    Win-->>Helper: SUCCESS/FAIL
    alt Success
        Helper-->>API: return TRUE
    else Fail
        API->>Helper: getStringFromRegistry(HKEY_CURRENT_USER, fullPath, key, val)
        Helper->>Win: RegOpenKeyEx(HKEY_CURRENT_USER)
        Win-->>Helper: SUCCESS/FAIL
        Helper-->>API: return TRUE/FALSE
    end
    API-->>App: return result
Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gen Relates to Generals Unify Unifies code between Generals and Zero Hour ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant