Commit fdeaf29c authored by Razer's avatar Razer
Browse files

Update world variable functionality

parent cdd5b060
/*
* Desolation Redux
* http://desolationredux.com/
* © 2016 - 2020 Desolation Dev Team
*
* This work is licensed under the Arma Public License Share Alike (APL-SA) + Bohemia monetization rights.
* To view a copy of this license, visit:
* https://www.bistudio.com/community/licenses/arma-public-license-share-alike/
* https://www.bistudio.com/monetization/
*/
if!(isNull DB_var_worldDataObject) exitWith {DB_var_worldDataObject};
// Local server object
private _obj = createSimpleObject ["Sign_Arrow_F",[0,0,0],true];
[_obj,1,101] call DB_fnc_registerObject;
// Save variable thats used to check for world data object
private _oUID = _obj getVariable ["oUUID",""];
if(_oUID == "") exitWith {objNull};
_obj setVariable [("_SVAR_worldDataObject_"+toLower(_oUID)),true];
// Delete object from DB_var_Objects so it wont get removed/updated automatically
private _index = DB_var_ObjectUUIDS find _oUID;
if(_index == -1) exitWith {objNull};
DB_var_ObjectUUIDS deleteAt _index;
DB_var_Objects deleteAt _index;
diag_log "<ApmsDB>: INFO: Created new world data object!";
DB_var_worldDataObject = _obj;
_obj
\ No newline at end of file
......@@ -47,16 +47,7 @@ if(_object isEqualTo objNull) then {
objNull;
};
case 1: { // Simple object
// Check if world data object or not (and make sure it already doesent exist)
if ((isNull DB_var_worldDataObject) && {[("_SVAR_worldDataObject_"+toLower(_object_uuid)),true] in _variables}) then {
diag_log "<ApmsDB>: INFO: Restored world data object!";
private _objectTMP = createSimpleObject [_classname,(ATLToASL _position),true]; // Local to server
DB_var_worldDataObject = _objectTMP;
_objectTMP
} else {
createSimpleObject [_classname,(ATLToASL _position)];
};
createSimpleObject [_classname,(ATLToASL _position)];
};
case 2: {
_classname createVehicle _position;
......
......@@ -12,10 +12,10 @@
#include "constants.hpp"
// Set variables
DB_var_worldVariables = [];
DB_var_clanList = [];
DB_var_Objects = [];
DB_var_ObjectUUIDS = [];
DB_var_worldDataObject = objNull;
DB_var_restoreObjectInProgress = true;
DB_var_savingObjects = true;
DB_var_runObjectMon = true;
......@@ -45,12 +45,12 @@ if(_worldUUID == "") then {
diag_log ("<ApmsDB>: INFO: World UUID: " + _worldUUID);
// Check server name lenght
_serverName = (serverName splitString " ") joinString ""; // Remove whitespaces
if(count _serverName > 45) then {
_serverName = serverName;
if(count _serverName > 256) then {
for "_i" from 1 to 5 do {
diag_log "<ApmsDB>: ERROR: SERVER NAME TOO LONG. MAX CHARS ALLOWED 45!";
diag_log "<ApmsDB>: WARNING: SERVER NAME TOO LONG. MAX LENGHT ALLOWED 256!";
};
_serverName = _serverName select [0,45];
_serverName = _serverName select [0,256];
};
_request = [PROTOCOL_DBCALL_FUNCTION_EXECUTE_INIT_DB,[
PROTOCOL_DBCALL_ARGUMENT_WORLDUUID,_worldUUID,
......@@ -59,6 +59,19 @@ _request = [PROTOCOL_DBCALL_FUNCTION_EXECUTE_INIT_DB,[
]];
[_request] call DB_fnc_sendRequest;
// Restore world variables
DB_var_worldVariables = call BASE_fnc_createNamespace;
_request = [PROTOCOL_DBCALL_FUNCTION_GET_WORLD_VARIABLES,[PROTOCOL_DBCALL_ARGUMENT_WORLDUUID,_worldUUID]];
_variables = [_request] call DB_fnc_sendRequest;
_variables apply {
_x params ["_varName","_varData","_global"];
if (!(isNil "_global") && {_global isEqualTo true}) then {
DB_var_worldVariables setVariable [_varName,_varData,true];
} else {
DB_var_worldVariables setVariable [_varName,_varData];
};
};
// Restore DB Objects
_restoreObjects = (call compile (["RestoreObjects","DB"] call BASE_fnc_getCfgValue));
if(_restoreObjects) then {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment