server/addons/db/XEH_preInit.sqf
Jacob Schmidt 5b30efa3b0
All checks were successful
Build / Build (push) Successful in 26s
feat: Refactor database system for improved persistence and functionality
This commit refactors the database system to improve persistence, functionality, and code clarity. The key changes include:

-   **Removed direct store access:** Removed `createStore`, `getFromStore`, and `getStore` PREP macros.
-   **Centralized store management:** Introduced a central store registry (`FORGE_STORE_REG`) managed by the database interface.
-   **Namespace-based persistence:** Stores are now persisted in mission and profile namespaces instead of a global store.
-   **Simplified load/save functions:** `loadFromMission`, `loadFromProfile`, `saveToMission`, `saveToProfile`, and `saveToTemp` functions are updated to use the new namespace-based persistence. They now accept a `keyField` parameter for retrieving specific fields within a key's data.
-   **Refactored `processDBRequest`:** Updated to handle new request types and parameters, aligning with the refactored load/save functions.
-   **Improved error handling:** Added more robust error handling and logging, including checks for empty store names and missing keys.
-   **Removed client registration:** Removed client registration and cleanup logic as it's no longer needed with the new persistence model.
-   **Updated `verifyDB`:** Simplified to directly return the store registry.
-   **Updated `initDB`:** Refactored to use a HashMap object for the store interface and added more database functions.
-   **Added .gitignore entries:** Added entries for Visual Studio and other common build artifacts.
-   **Updated `loadGameState` and `saveGameState`:** Updated to support loading and saving game state to either mission or profile namespace.
2025-04-05 14:16:35 -05:00

19 lines
530 B
Plaintext

#include "script_component.hpp"
ADDON = false;
PREP_RECOMPILE_START;
#include "XEH_PREP.hpp"
PREP_RECOMPILE_END;
SETMVAR(FORGE_STORE_REG,createHashMap);
// Process database requests
["forge_db_request", {
params ["_playerUID", "_type", "_name", "_key", "_keyField", "_data", "_requestID"];
private _result = [_type, _name, _key, _keyField, _data] call FUNC(processDBRequest);
["forge_db_response", [_playerUID, _type, _result, _requestID]] call CBA_fnc_globalEvent;
}] call CBA_fnc_addEventHandler;
ADDON = true;