Skip to content
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

Refactor Configuration and Connection Handling for Consistency #268

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

stevewgr
Copy link
Member

Description

This pull request refactors configuration and connection string handling across the project to improve maintainability, readability, and portability. Key changes include:

  • Centralized Configuration Management: Introduced a unified ini file management class using the SimpleIni library, replacing redundant implementations and simplifying ini file handling across components.
  • Thread-Safe Ini Parsing with Hot Reloading: The new ini parser is implemented in a thread-safe manner, supporting hot-reloading to reflect changes in configuration files.
  • Enhanced Connection String Handling: Simplified and standardized connection string logic with lazy loading for efficiency and renamed variables for improved clarity.
  • Cross-Platform Compatibility: Prepared the codebase for future portability by replacing platform-specific approaches with a centralized, consistent solution.
  • Codebase Cleanup: Removed unused ini files and updated project files to reflect these changes.

These updates lay the groundwork for a more maintainable and portable codebase, ensuring consistency across all server components while improving runtime efficiency and adaptability.

This change updates the LoginServer connection string to be loaded
from server.ini instead of Version.ini. This ensures all server files
share a unified configuration source, improving maintainability.

This adjustment also fixes twostars changes in PR #226.

Future improvements to better structure sections across server files
will follow in a separate commit.
This change introduces src/common/Ini.cpp and Ini.h to centralize
configuration management. Redundant ini file handling code has been
removed, such as in AIServer/Ini.cpp and Ini.h, reducing duplication
and improving maintainability.

Key changes:
- New centralized ini file handling in src/common.
- Updates to vcxproj files to reference the new implementation.
- Modifications across multiple components to use the shared logic.

This refactor prepares the codebase for future portability, enabling
a smoother transition to a cross-platform library in place of Windows
APIs for ini file management.
This change centralizes connection string construction, ensuring it
is done in one place for consistency and maintainability. It also
implements lazy loading to defer construction until needed, improving
performance by reducing redundant computations.

Key changes:
- Refactored connection string logic across multiple components.
- Updated AIServerDlg, AujardDlg, DBAgent, and others to use the new
  centralized implementation.
- Ensured a cleaner and more efficient mechanism for managing
  connection strings.

This simplifies the codebase and optimizes runtime efficiency, making
future changes easier to manage.
This update standardizes the naming of connection strings across various
server components for improved readability and consistency. Changes
include renaming connection strings in files like AIServerDlg, MagicTableSet,
and MakeItemTableSet, among others. The concise naming improves code
clarity and adheres to the project's conventions.
This update introduces a unified ini file management class to ensure
cross-platform compatibility and consistent behavior across the project.
The changes leverage the SimpleIni library, which was added by updating
the vendor submodule.

Key changes:
- Refactored and enhanced src/common/Ini.cpp and Ini.h for centralized
  ini file handling.
- Updated various vcxproj files (e.g., KnightOnLine, AIServer, Aujard)
  to integrate the new implementation.
- Simplified and standardized ini file logic to replace platform-specific
  handling.

This improvement sets the stage for portable and maintainable configuration
management across all components.
@stevewgr stevewgr mentioned this pull request Nov 20, 2024
4 tasks
@stevewgr stevewgr marked this pull request as draft November 20, 2024 19:19
@stevewgr stevewgr marked this pull request as ready for review November 20, 2024 19:19
if (iServerCount > 0) {
iServer = rand() % iServerCount;
szServerIpAddr = vIpAddrs[rand() % iServerCount];

Choose a reason for hiding this comment

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

Do we need to add srand(static_cast<unsigned>(time(0))); before this line to get a different value every time?

Copy link

@SeniourMarquies SeniourMarquies left a comment

Choose a reason for hiding this comment

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

The CIni class is impressive in its functionality, efficiently handling configuration tasks while ensuring cross-platform compatibility through the use of SimpleIni. Additionally, employing the Singleton design pattern enhances build performance by reducing overhead.

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.

2 participants