Skip to content

Add CGameConfig for managing settings via config.ini, including l…#25

Merged
Mosch0512 merged 7 commits intomainfrom
configini
Feb 4, 2026
Merged

Add CGameConfig for managing settings via config.ini, including l…#25
Mosch0512 merged 7 commits intomainfrom
configini

Conversation

@Mosch0512
Copy link
Owner

…ogin credentials, encrypted password handling, and server configurations. Replaces registry dependency.

@gemini-code-assist
Copy link

Summary of Changes

Hello @Mosch0512, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors how game settings are managed by introducing a dedicated CGameConfig class. This change transitions the application from storing configuration data in the Windows Registry to using a config.ini file, enhancing the maintainability and portability of settings. It also integrates secure handling for sensitive information like login passwords through encryption, and centralizes access to all configurable parameters.

Highlights

  • Configuration Management Refactor: Introduced a new CGameConfig class to centralize and manage all game settings, moving away from disparate configuration methods.
  • Registry Deprecation: Replaced the reliance on the Windows Registry for storing game settings with a config.ini file, improving portability and ease of access.
  • Secure Login Credential Handling: Implemented encrypted storage for login passwords within the config.ini file, utilizing Windows Data Protection API (DPAPI) and hex encoding for enhanced security.
  • Centralized Settings Access: Consolidated various game settings, including window dimensions, display mode, graphics options, audio preferences, login credentials, and server connection details, under the unified CGameConfig system.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/source/GameConfig.cpp
    • Added new file implementing the CGameConfig singleton class.
    • Implemented Load() and Save() methods for reading and writing various game settings (window, graphics, audio, login, connection) to config.ini.
    • Included helper functions (BinaryToHex, HexToBinary) for converting binary data to hex strings and vice-versa, primarily for encrypted password handling.
    • Provided private helper functions (ReadInt, WriteInt, ReadBool, WriteBool, ReadString, WriteString) that wrap Windows INI API calls.
  • src/source/GameConfig.h
    • Added new header file declaring the CGameConfig class and its public interface.
    • Defined the singleton pattern for CGameConfig via GetInstance().
    • Declared getters and setters for all managed game configuration properties.
    • Included declarations for static binary conversion helpers and private INI file operation helpers.
    • Defined default values for configuration members and introduced a global macro g_GameConfig for convenient access.
  • src/source/LoginWin.cpp
    • Included GameConfig.h to integrate the new configuration system.
    • Modified the 'Remember Me' checkbox logic to immediately persist its state to config.ini using g_GameConfig.SetRememberMe() and g_GameConfig.Save().
    • Refactored RequestLogin() to remove direct Windows Registry interactions for saving login ID and password.
    • Updated password saving: passwords are now encrypted using CryptProtectData, converted to a hex string via CGameConfig::BinaryToHex, and stored in config.ini using g_GameConfig.SetEncryptedPassword().
  • src/source/Winmain.cpp
    • Included GameConfig.h to utilize the new configuration system.
    • Modified DestroyWindow() to save the volume level to config.ini via g_GameConfig.SetVolumeLevel() and g_GameConfig.Save(), replacing Registry writes.
    • Updated WinMain() to load all game settings from config.ini using g_GameConfig.Load() at startup.
    • Adjusted server connection logic to retrieve server IP and port from config.ini if not specified via command-line arguments.
    • Replaced extensive Registry reading logic for window, audio, graphics, login, and language settings with calls to g_GameConfig getters.
    • Refactored password decryption to use g_GameConfig.GetEncryptedPassword() and CGameConfig::HexToBinary before CryptUnprotectData.
    • Removed the switch statement that previously determined window dimensions based on a resolution index, as these are now directly loaded from CGameConfig.
    • Corrected a mouse button state update in WndProc from MouseRButton = false; to MouseMButton = false;.
Activity
  • This pull request introduces a new feature and refactors existing code. No specific review comments or activities have been recorded yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a CGameConfig class to manage game settings using an INI file, which is a great improvement over using the Windows Registry. The implementation is mostly solid, but I've found a few areas for improvement regarding robustness, security, and code clarity.

My main points are:

  • The method for locating config.ini should be made more robust by using the executable's path instead of the current working directory.
  • There's a security issue in how the password length is calculated before encryption, which could lead to information leakage.
  • I've also pointed out some leftover debugging code, an incorrect comment, and an opportunity to make the hex-to-binary conversion safer.

Overall, this is a valuable change that modernizes configuration management. Addressing these points will make it even better.

@Mosch0512 Mosch0512 force-pushed the configini branch 2 times, most recently from 41e69c6 to 40a2eda Compare February 3, 2026 17:34
@Mosch0512
Copy link
Owner Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a CGameConfig class to manage game settings from a config.ini file, which is a great improvement over using the Windows Registry. The implementation is solid, including the use of CryptProtectData for password encryption. I've identified several areas for improvement regarding robustness, efficiency, maintainability, and privacy. My suggestions include making the string reading more robust, refactoring for better code clarity, improving the save logic efficiency, and addressing the storage of the login ID in plaintext.

@Mosch0512
Copy link
Owner Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a CGameConfig class to manage application settings through a config.ini file, effectively replacing the previous dependency on the Windows Registry. This is a significant improvement for portability and ease of configuration. The changes include handling login credentials with encryption, server configurations, and various UI settings. Additionally, a widespread refactoring was done to replace MAX_ID_SIZE with the more descriptive MAX_USERNAME_SIZE across the codebase. While the implementation is solid, I've identified a critical bug related to a key name mismatch and a few other areas for improvement to enhance correctness and maintainability.

@Mosch0512
Copy link
Owner Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a CGameConfig class to manage settings via config.ini, replacing the previous Windows Registry dependency. This is an excellent change that improves the application's portability and simplifies configuration management. The introduction of GameConfig and GameConfigConstants is well-implemented. The widespread renaming of MAX_ID_SIZE to MAX_USERNAME_SIZE also enhances code clarity. I've identified a couple of minor areas for improvement to ensure correctness and maintainability. Overall, this is a strong and valuable contribution.

….ini`, adding encrypted credential support, logging updates, and replacing registry dependency.
@Mosch0512 Mosch0512 merged commit b51fe03 into main Feb 4, 2026
2 checks passed
@Mosch0512 Mosch0512 deleted the configini branch February 4, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant