From 796ed59c166b274a36568456a3a26ada69159a55 Mon Sep 17 00:00:00 2001 From: Jacob Schmidt Date: Fri, 28 Mar 2025 10:00:46 -0500 Subject: [PATCH] Refactor: Organization Store Initialization and Key Handling 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. --- addons/org/functions/fnc_initOrgStore.sqf | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/addons/org/functions/fnc_initOrgStore.sqf b/addons/org/functions/fnc_initOrgStore.sqf index a90f517..0f0591a 100644 --- a/addons/org/functions/fnc_initOrgStore.sqf +++ b/addons/org/functions/fnc_initOrgStore.sqf @@ -14,7 +14,7 @@ * Organization interface */ -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) \ No newline at end of file