Refactor: Organization Store Initialization and Key Handling
All checks were successful
Build / Build (push) Successful in 27s

This commit refactors the organization store initialization and improves key handling within the organization store.

*   **Organization Store Initialization:** Changes the way the organization store interface is initialized by using `createHashMapObject` with a single declaration.
*   **Key Handling:** Improves the error message when an organization key is not found during the leave function, providing more context.
This commit is contained in:
Jacob Schmidt 2025-03-28 10:00:46 -05:00
parent 1b7875e813
commit 796ed59c16

View File

@ -14,7 +14,7 @@
* Organization interface <OBJECT>
*/
private _orgStoreDeclaration = [
private _orgStoreInterface = createHashMapObject [[
["#type", "IOrganizationStore"],
["#create", {
private _store = GETMVAR(FORGE_STORE_REG,nil);
@ -101,7 +101,7 @@ private _orgStoreDeclaration = [
if (_key == "") exitWith { ERROR_MSG("Key cannot be empty"); nil };
private _store = GETMVAR(FORGE_STORE_REG,nil);
private _org = _store call ["get", ["organizations", _key]]
private _org = _store call ["get", ["organizations", _key]];
if (isNil "_org") exitWith { ERROR_MSG_1("Organization with composite key %1 not found",_key); nil };
@ -117,7 +117,7 @@ private _orgStoreDeclaration = [
_store call ["delete", ["organizationNameIndex", _key]];
if (isNil "_key") exitWith { ERROR_MSG_1("Key for organization not found",_key); false };
if (isNil "_key") exitWith { ERROR_MSG_1("Key for organization not found: %1",_key); false };
_store call ["delete", ["organizations", _key]];
@ -128,8 +128,7 @@ private _orgStoreDeclaration = [
true
}]
];
]];
private _orgStoreInterface = createHashMapObject [_orgStoreDeclaration];
SETMVAR(FORGE_ORG_STORE_REG,_orgStoreInterface);
GETMVAR(FORGE_ORG_STORE_REG,nil)