
All checks were successful
Build / Build (push) Successful in 26s
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.
37 lines
1.0 KiB
Plaintext
37 lines
1.0 KiB
Plaintext
#include "..\script_component.hpp"
|
|
|
|
/*
|
|
* Function: forge_server_db_fnc_saveToTemp
|
|
* Author: J. Schmidt
|
|
*
|
|
* Description:
|
|
* Saves data to temporary mission store (not persisted between sessions)
|
|
*
|
|
* Arguments:
|
|
* 0: _name - Store name <STRING>
|
|
* 1: _key - Key to save under <STRING>
|
|
* 2: _keyField - Field of the key to update <STRING>
|
|
* 3: _data - Data to save <STRING, ARRAY, NUMBER, BOOLEAN, HASHMAP>
|
|
*
|
|
* Return Value:
|
|
* Success <BOOL>
|
|
*/
|
|
|
|
params [["_name", "", [""]], ["_key", "", [""]], ["_keyField", "", [""]], ["_data", nil, ["", [], 0, true, createHashMap]]];
|
|
|
|
if (_name isEqualTo "" || _key isEqualTo "" || isNil "_data") exitWith { ERROR_MSG("Store name, key and, or data cannot be empty"); false };
|
|
|
|
private _store = missionNamespace getVariable [_name, createHashMap];
|
|
|
|
if (_keyField isEqualTo "") then {
|
|
_store set [_key, _data];
|
|
} else {
|
|
private _keyData = _store get _key;
|
|
|
|
_keyData set [_keyField, _data];
|
|
_store set [_key, _keyData];
|
|
};
|
|
|
|
missionNamespace setVariable [_name, _store];
|
|
|
|
true |