diff --git a/=BTC=co@30_Hearts_and_Minds.Altis/core/def/param.hpp b/=BTC=co@30_Hearts_and_Minds.Altis/core/def/param.hpp index 59aa923ab..9dd7fb519 100644 --- a/=BTC=co@30_Hearts_and_Minds.Altis/core/def/param.hpp +++ b/=BTC=co@30_Hearts_and_Minds.Altis/core/def/param.hpp @@ -202,4 +202,4 @@ class Params { texts[]={"Civilian (A3)","Afghan (@Ericj_Taliban)"}; default = 0; }; -}; +}; \ No newline at end of file diff --git a/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/common/show_hint.sqf b/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/common/show_hint.sqf index eb4070377..ee9e02175 100644 --- a/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/common/show_hint.sqf +++ b/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/common/show_hint.sqf @@ -38,4 +38,7 @@ switch (_type) do { case 10 : { hint "Database deleted!"; }; + case 11 : { + hint ("Game not " + (_this select 1) + " because @iniDB isn't lauched server side!"); + }; }; \ No newline at end of file diff --git a/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/compile.sqf b/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/compile.sqf index baabcfc41..ee060365d 100644 --- a/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/compile.sqf +++ b/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/compile.sqf @@ -41,8 +41,10 @@ if (isServer) then { btc_fnc_data_spawn_group = compile preprocessFile "core\fnc\data\spawn_group.sqf"; //DB + if (isClass(configFile >> "cfgPatches" >> "inidbi2")) then {OO_fnc_inidbi = ["new", format ["btc_hm_%1",worldName]] call OO_INIDBI}; btc_fnc_db_save = compile preprocessFile "core\fnc\db\save.sqf"; btc_fnc_db_delete = compile preprocessFile "core\fnc\db\delete.sqf"; + btc_fnc_db_save_array = compile preprocessFile "core\fnc\db\save_array.sqf"; //EH //btc_fnc_eh_helo_respawn = compile preprocessFile "core\fnc\eh\helo_respawn.sqf"; diff --git a/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/data/get_group.sqf b/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/data/get_group.sqf index bdb39d821..95babfd5d 100644 --- a/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/data/get_group.sqf +++ b/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/data/get_group.sqf @@ -7,7 +7,7 @@ _units = units _group; _type_db = 0; _array_pos = []; _array_type = []; -_side = side (leader _group); +_side = str(side (leader _group)); _array_dam = []; _behaviour = [behaviour (leader _group),combatMode _group,formation _group]; _array_wp = []; diff --git a/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/data/spawn_group.sqf b/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/data/spawn_group.sqf index fb5b3b8f1..001714e72 100644 --- a/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/data/spawn_group.sqf +++ b/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/data/spawn_group.sqf @@ -4,7 +4,21 @@ private ["_type","_array_pos","_array_type","_side","_array_dam","_behaviour","_ _type = _this select 0; _array_pos = _this select 1; _array_type = _this select 2; -_side = _this select 3; +switch (_this select 3) do +{ + case "CIV": + { + _side = civilian; + }; + case "UNKNOWN": + { + _side = sideUnknown; + }; + default + { + _side = call compile (_this select 3); + }; +}; _array_dam = _this select 4; _behaviour = _this select 5; _array_wp = _this select 6; @@ -75,7 +89,7 @@ if (_type == 5) then { while {Alive _suicider && !isNull _suicider && !_cond} do { sleep 5; if (count (getpos _suicider nearEntities ["SoldierWB", 25]) > 0) then {_cond = true;_suicider spawn btc_fnc_ied_suicider_active}; - }; + }; }; }; diff --git a/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/db/delete.sqf b/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/db/delete.sqf index f473a57c9..70f95c027 100644 --- a/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/db/delete.sqf +++ b/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/db/delete.sqf @@ -1,19 +1,6 @@ -private ["_name"]; +if !(isClass(configFile >> "cfgPatches" >> "inidbi2")) exitWith {[[11, "deleted"],"btc_fnc_show_hint"] spawn BIS_fnc_MP;}; -_name = worldName; - -profileNamespace setVariable [format ["btc_hm_%1_date",_name],nil]; -profileNamespace setVariable [format ["btc_hm_%1_cities",_name],nil]; -profileNamespace setVariable [format ["btc_hm_%1_ho",_name],nil]; -profileNamespace setVariable [format ["btc_hm_%1_ho_sel",_name],nil]; -profileNamespace setVariable [format ["btc_hm_%1_cache",_name],nil]; -profileNamespace setVariable [format ["btc_hm_%1_rep",_name],nil]; -profileNamespace setVariable [format ["btc_hm_%1_fobs",_name],nil]; -profileNamespace setVariable [format ["btc_hm_%1_vehs",_name],nil]; -profileNamespace setVariable [format ["btc_hm_%1_objs",_name],nil]; -profileNamespace setVariable [format ["btc_hm_%1_db",_name],nil]; - -saveProfileNamespace; +"delete" call OO_fnc_inidbi; [[10],"btc_fnc_show_hint"] spawn BIS_fnc_MP; \ No newline at end of file diff --git a/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/db/load.sqf b/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/db/load.sqf index 6f6984b79..d99fcac73 100644 --- a/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/db/load.sqf +++ b/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/db/load.sqf @@ -1,14 +1,18 @@ +if !(isClass(configFile >> "cfgPatches" >> "inidbi2")) exitWith {[[11, "loaded"],"btc_fnc_show_hint"] spawn BIS_fnc_MP;}; -private ["_name","_cities_status","_array_ho","_ho","_array_cache","_fobs","_fobs_loaded","_vehs","_objs"]; +private ["_name","_cities_status","_array_ho","_ho","_array_cache","_fobs","_fobs_loaded","_vehs","_objs","_data_units"]; -_name = worldName; - -setDate (profileNamespace getVariable [format ["btc_hm_%1_date",_name],date]); +setDate (["read", ["mission_Param", "date", date]] call OO_fnc_inidbi); //CITIES -_cities_status = profileNamespace getVariable [format ["btc_hm_%1_cities",_name],[]]; -//diag_log format ["_cities_status: %1",_cities_status]; +_nb_cities_status = ((["read", ["cities", "nb_cities_status", [0]]] call OO_fnc_inidbi) select 0) - 1; +_cities_status = []; +for "_i" from 0 to _nb_cities_status do { + _cities_status append (["read", ["cities", format ["cities_status_%1",_i], [] ]] call OO_fnc_inidbi); +}; +_nb_cities_data_units = ["read", ["cities", "nb_cities_data_units", [[],[]] ]] call OO_fnc_inidbi; +//diag_log format ["_cities_status: %1",_cities_status]; { /* _city_status pushBack (_x getVariable "id"); @@ -26,17 +30,31 @@ _cities_status = profileNamespace getVariable [format ["btc_hm_%1_cities",_name] */ - private ["_id","_city"]; + private ["_id","_city","_element"]; _id = _x select 0; _city = btc_city_all select _id; _city setVariable ["initialized",(_x select 1)]; _city setVariable ["spawn_more",(_x select 2)]; _city setVariable ["occupied",(_x select 3)]; - _city setVariable ["data_units",(_x select 4)]; - _city setVariable ["has_ho",(_x select 5)]; - _city setVariable ["ho_units_spawned",(_x select 6)]; - _city setVariable ["ieds",(_x select 7)]; + + _element = (_nb_cities_data_units select 1) select ((_nb_cities_data_units select 0) find _id); + _data_units = []; + if (_element > 0) then { + for "_i" from 0 to _element do { + _data_units append (["read", ["cities", format ["city_%1_data_units_%2",_id,_i], [] ]] call OO_fnc_inidbi); + }; + }; + { + if ((_x select 0) isEqualTo 3) then { + _x set [7,([_x select 7,3] call btc_fnc_getHouses) select 0]; + }; + } forEach _data_units; + _city setVariable ["data_units",_data_units]; + + _city setVariable ["has_ho",(_x select 4)]; + _city setVariable ["ho_units_spawned",(_x select 5)]; + _city setVariable ["ieds",(_x select 6)]; if (btc_debug) then {//_debug @@ -65,7 +83,7 @@ _cities_status = profileNamespace getVariable [format ["btc_hm_%1_cities",_name] } foreach (_x getVariable ["markers",[]]); _data pushback (_cache_markers); */ -_array_ho = profileNamespace getVariable [format ["btc_hm_%1_ho",_name],[]]; +_array_ho = ["read", ["cities", "ho", [] ]] call OO_fnc_inidbi; { private ["_pos","_hideout","_markers"]; @@ -79,7 +97,10 @@ _array_ho = profileNamespace getVariable [format ["btc_hm_%1_ho",_name],[]]; _hideout setVariable ["id",(_x select 1)]; _hideout setVariable ["rinf_time",(_x select 2)]; _hideout setVariable ["cap_time",(_x select 3)]; - _hideout setVariable ["assigned_to",(_x select 4)]; + _city = btc_city_all select 0; + _city_pos = _pos distance (getpos _city); + {if ((_pos distance (getpos _x)) < _city_pos) then {_city = _x; _city_pos = _pos distance (getpos _city);}} forEach btc_city_all; + _hideout setVariable ["assigned_to", _city]; _hideout addEventHandler ["HandleDamage", btc_fnc_mil_hd_hideout]; @@ -91,7 +112,7 @@ _array_ho = profileNamespace getVariable [format ["btc_hm_%1_ho",_name],[]]; _marker setMarkerSize [0.5, 0.5]; _marker setMarkerColor "ColorRed"; _markers pushBack _marker; - } foreach (_x select 5); + } foreach (_x select 4); _hideout setVariable ["markers",_markers]; @@ -106,20 +127,24 @@ _array_ho = profileNamespace getVariable [format ["btc_hm_%1_ho",_name],[]]; if (btc_debug_log) then {diag_log format ["btc_fnc_mil_create_hideout: _this = %1 ; POS %2 ID %3",_x,_pos,btc_hideouts_id];}; btc_hideouts_id = btc_hideouts_id + 1; - btc_hideouts = btc_hideouts + [_hideout]; + btc_hideouts pushBack _hideout; } foreach _array_ho; -_ho = profileNamespace getVariable [format ["btc_hm_%1_ho_sel",_name],objNull]; -btc_hq setVariable ["info_hideout",_ho]; - -if (count btc_hideouts == 0) then {[] execVM "core\fnc\common\final_phase.sqf";}; +if (btc_hideouts isEqualTo []) then { + [] execVM "core\fnc\common\final_phase.sqf"; + btc_hq setVariable ["info_hideout",objNull]; +} else { + _ho = btc_hideouts select 0; + _id_inidbi = ["read", ["cities", "ho_sel", 0]] call OO_fnc_inidbi; + {if ((_x getVariable ["id",0]) isEqualTo _id_inidbi) exitWith {_ho = _x}} forEach btc_hideouts; + btc_hq setVariable ["info_hideout",_ho]; +}; //CACHE - btc_cache_cities = + btc_city_all; btc_cache_markers = []; -_array_cache = profileNamespace getVariable [format ["btc_hm_%1_cache",_name],[]]; +_array_cache = ["read", ["cities", "cache", [] ]] call OO_fnc_inidbi; btc_cache_pos = _array_cache select 0; btc_cache_n = _array_cache select 1; @@ -137,7 +162,7 @@ btc_cache_obj addEventHandler ["HandleDamage", btc_fnc_cache_hd_cache]; _marker setMarkerText (_x select 1); _marker setMarkerSize [0.5, 0.5]; _marker setMarkerColor "ColorRed"; - btc_cache_markers = btc_cache_markers + [_marker]; + btc_cache_markers pushBack _marker; } foreach (_array_cache select 3); if (btc_debug_log) then {diag_log format ["CACHE SPAWNED: ID %1 POS %2",btc_cache_n,btc_cache_pos];}; @@ -152,12 +177,11 @@ if (btc_debug) then { }; //REP -btc_global_reputation = profileNamespace getVariable [format ["btc_hm_%1_rep",_name],0]; +btc_global_reputation = ["read", ["cities", "rep", 0 ]] call OO_fnc_inidbi; //FOB -_fobs = profileNamespace getVariable [format ["btc_hm_%1_fobs",_name],[]]; +_fobs = ["read", ["base", "fobs", [] ]] call OO_fnc_inidbi; _fobs_loaded = [[],[]]; - { private ["_pos","_fob_structure","_flag"]; _pos = (_x select 1); @@ -187,7 +211,7 @@ btc_fobs = _fobs_loaded; {deleteVehicle _x} foreach btc_vehicles; btc_vehicles = []; -_vehs = profileNamespace getVariable [format ["btc_hm_%1_vehs",_name],[]]; +_vehs = ["read", ["base", "vehs", [] ]] call OO_fnc_inidbi; /* {diag_log format ["0: %1",(_x select 0)]; diag_log format ["1: %1",(_x select 1)]; @@ -272,7 +296,7 @@ diag_log format ["5: %1",(_x select 5)]; _array_obj pushBack _data; */ //btc_log_obj_created = []; -_objs = profileNamespace getVariable [format ["btc_hm_%1_objs",_name],[]]; +_objs = ["read", ["base", "objs", [] ]] call OO_fnc_inidbi; { private ["_obj","_cont","_weap","_mags","_items"]; _obj = (_x select 0) createVehicle (_x select 1); @@ -282,12 +306,6 @@ _objs = profileNamespace getVariable [format ["btc_hm_%1_objs",_name],[]]; _obj setPosASL (_x select 1); if ((_x select 3) != "") then {_obj setVariable ["ace_rearm_magazineClass",(_x select 3),true]}; { - /*private "_l"; - _l = _x createVehicle [0,0,0]; - btc_log_obj_created = btc_log_obj_created + [_l]; - btc_curator addCuratorEditableObjects [[_l], false]; - [_l,_obj] call btc_fnc_log_server_load;*/ - //NEW private ["_type","_cargo_obj","_l","_weap_obj","_mags_obj","_items_obj"]; //{_cargo pushBack [(typeOf _x),[getWeaponCargo _x,getMagazineCargo _x,getItemCargo _x]]} foreach (_x getVariable ["cargo",[]]); _type = _x select 0; @@ -337,4 +355,4 @@ _objs = profileNamespace getVariable [format ["btc_hm_%1_objs",_name],[]]; _obj addItemCargoGlobal[((_items select 0) select _i),((_items select 1) select _i)]; }; }; -} foreach _objs; +} foreach _objs; \ No newline at end of file diff --git a/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/db/load_old.sqf b/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/db/load_old.sqf new file mode 100644 index 000000000..a92218bfc --- /dev/null +++ b/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/db/load_old.sqf @@ -0,0 +1,335 @@ + +private ["_name","_cities_status","_array_ho","_ho","_array_cache","_fobs","_fobs_loaded","_vehs","_objs"]; + +_name = worldName; + +setDate (profileNamespace getVariable [format ["btc_hm_%1_date",_name],date]); + +//CITIES +_cities_status = profileNamespace getVariable [format ["btc_hm_%1_cities",_name],[]]; +//diag_log format ["_cities_status: %1",_cities_status]; + +{ +/* + _city_status pushBack (_x getVariable "id"); + + _city_status pushBack (_x getVariable "initialized"); + + _city_status pushBack (_x getVariable "spawn_more"); + _city_status pushBack (_x getVariable "occupied"); + + _city_status pushBack (_x getVariable "data_units"); + + _city_status pushBack (_x getVariable ["has_ho",false]); + _city_status pushBack (_x getVariable ["ho_units_spawned",false]); + _city_status pushBack (_x getVariable ["ieds",[]]); +*/ + + + private ["_id","_city"]; + _id = _x select 0; + _city = btc_city_all select _id; + + _city setVariable ["initialized",(_x select 1)]; + _city setVariable ["spawn_more",(_x select 2)]; + _city setVariable ["occupied",(_x select 3)]; + _city setVariable ["data_units",(_x select 4)]; + _city setVariable ["has_ho",(_x select 5)]; + _city setVariable ["ho_units_spawned",(_x select 6)]; + _city setVariable ["ieds",(_x select 7)]; + + if (btc_debug) then {//_debug + + if (_city getVariable ["occupied",false]) then {(_city getVariable ["marker",""]) setmarkercolor "colorRed";} else {(_city getVariable ["marker",""]) setmarkercolor "colorGreen";}; + (_city getVariable ["marker",""]) setmarkertext format ["loc_%3 %1 %2 - [%4]",(_city getVariable "name"),_city getVariable "type",_id,(_x select 3)]; + + diag_log format ["ID: %1",_id]; + diag_log format ["data_city: %1",_x]; + diag_log format ["LOAD: %1 - %2",_id,(_x select 3)]; + }; +} foreach _cities_status; + +//HIDEOUT +/* + _data pushBack (getPos _x); + _data pushBack (_x getVariable ["id",0]); + _data pushBack (_x getVariable ["rinf_time",0]); + _data pushBack (_x getVariable ["cap_time",0]); + _data pushBack (_x getVariable ["assigned_to",objNull]); + + _cache_markers = []; + { + _data = []; + _data pushback (getMarkerPos _x); + _data pushback (markerText _x); + } foreach (_x getVariable ["markers",[]]); + _data pushback (_cache_markers); +*/ +_array_ho = profileNamespace getVariable [format ["btc_hm_%1_ho",_name],[]]; + +{ + private ["_pos","_hideout","_markers"]; + + _pos = (_x select 0); + + [_pos,(random 360),btc_composition_hideout] call btc_fnc_create_composition; + + _hideout = nearestObject [_pos, "C_supplyCrate_F"]; + clearWeaponCargoGlobal _hideout;clearItemCargoGlobal _hideout;clearMagazineCargoGlobal _hideout; + _hideout setVariable ["id",(_x select 1)]; + _hideout setVariable ["rinf_time",(_x select 2)]; + _hideout setVariable ["cap_time",(_x select 3)]; + _hideout setVariable ["assigned_to",(_x select 4)]; + + _hideout addEventHandler ["HandleDamage", btc_fnc_mil_hd_hideout]; + + _markers = []; + { + _marker = createmarker [format ["%1", (_x select 0)], (_x select 0)]; + _marker setmarkertype "hd_warning"; + _marker setMarkerText (_x select 1); + _marker setMarkerSize [0.5, 0.5]; + _marker setMarkerColor "ColorRed"; + _markers pushBack _marker; + } foreach (_x select 5); + + _hideout setVariable ["markers",_markers]; + + if (btc_debug) then { + //Marker + createmarker [format ["btc_hideout_%1", _pos], _pos]; + format ["btc_hideout_%1", _pos] setmarkertype "mil_unknown"; + format ["btc_hideout_%1", _pos] setMarkerText format ["Hideout %1", btc_hideouts_id]; + format ["btc_hideout_%1", _pos] setMarkerSize [0.8, 0.8]; + }; + + if (btc_debug_log) then {diag_log format ["btc_fnc_mil_create_hideout: _this = %1 ; POS %2 ID %3",_x,_pos,btc_hideouts_id];}; + + btc_hideouts_id = btc_hideouts_id + 1; + btc_hideouts = btc_hideouts + [_hideout]; +} foreach _array_ho; + +_ho = profileNamespace getVariable [format ["btc_hm_%1_ho_sel",_name],objNull]; +btc_hq setVariable ["info_hideout",_ho]; + +if (count btc_hideouts == 0) then {[] execVM "core\fnc\common\final_phase.sqf";}; + +//CACHE + +btc_cache_cities = + btc_city_all; +btc_cache_markers = []; + +_array_cache = profileNamespace getVariable [format ["btc_hm_%1_cache",_name],[]]; + +btc_cache_pos = _array_cache select 0; +btc_cache_n = _array_cache select 1; +btc_cache_info = _array_cache select 2; + +btc_cache_obj = btc_cache_type createVehicle btc_cache_pos; +btc_cache_obj setPosATL (_array_cache select 0); +clearWeaponCargoGlobal btc_cache_obj;clearItemCargoGlobal btc_cache_obj;clearMagazineCargoGlobal btc_cache_obj; +btc_cache_obj addEventHandler ["HandleDamage", btc_fnc_cache_hd_cache]; + +{ + private ["_marker"]; + _marker = createmarker [format ["%1", (_x select 0)], (_x select 0)]; + _marker setmarkertype "hd_unknown"; + _marker setMarkerText (_x select 1); + _marker setMarkerSize [0.5, 0.5]; + _marker setMarkerColor "ColorRed"; + btc_cache_markers = btc_cache_markers + [_marker]; +} foreach (_array_cache select 3); + +if (btc_debug_log) then {diag_log format ["CACHE SPAWNED: ID %1 POS %2",btc_cache_n,btc_cache_pos];}; + +if (btc_debug) then { + player sideChat format ["Cache spawned in %1",btc_cache_pos]; + //Marker + createmarker [format ["%1", btc_cache_pos], btc_cache_pos]; + format ["%1", btc_cache_pos] setmarkertype "mil_unknown"; + format ["%1", btc_cache_pos] setMarkerText format ["Cache %1", btc_cache_n]; + format ["%1", btc_cache_pos] setMarkerSize [0.8, 0.8]; +}; + +//REP +btc_global_reputation = profileNamespace getVariable [format ["btc_hm_%1_rep",_name],0]; + +//FOB +_fobs = profileNamespace getVariable [format ["btc_hm_%1_fobs",_name],[]]; +_fobs_loaded = []; + +{ + private ["_pos"]; + _pos = (_x select 1); + createmarker [(_x select 0), _pos]; + (_x select 0) setMarkerSize [1,1]; + (_x select 0) setMarkerType "hd_flag"; + (_x select 0) setMarkerText (_x select 0); + (_x select 0) setMarkerColor "ColorBlue"; + (_x select 0) setMarkerShape "ICON"; + {createVehicle [_x, _pos, [], 0, "NONE"];} foreach [btc_fob_structure,btc_fob_flag]; + _fobs_loaded pushBack (_x select 0); +} foreach _fobs; + +btc_fobs = _fobs_loaded; + +//VEHICLES +/* _data pushBack (typeOf _x); + _data pushBack (getPos _x); + _data pushBack (getDir _x); + _data pushBack (fuel _x); + _data pushBack (damage _x); + _data pushBack (_x getVariable ["cargo",[]];); +*/ + +{deleteVehicle _x} foreach btc_vehicles; +btc_vehicles = []; + +_vehs = profileNamespace getVariable [format ["btc_hm_%1_vehs",_name],[]]; +/* +{diag_log format ["0: %1",(_x select 0)]; +diag_log format ["1: %1",(_x select 1)]; +diag_log format ["2: %1",(_x select 2)]; +diag_log format ["3: %1",(_x select 3)]; +diag_log format ["4: %1",(_x select 4)]; +diag_log format ["5: %1",(_x select 5)]; +{diag_log format ["5: %1",_x];} foreach (_x select 5)} foreach _vehs; +*/ +{ + private ["_veh","_cont","_weap","_mags","_items"]; + _veh = (_x select 0) createVehicle (_x select 1); + btc_vehicles pushBack _veh; + _veh addEventHandler ["Killed", {_this call btc_fnc_eh_veh_killed}]; + _veh setVariable ["btc_dont_delete",true]; + _veh setDir (_x select 2); + _veh setFuel (_x select 3); + _veh setDamage (_x select 4); + { + private ["_type","_cargo_obj","_obj","_weap_obj","_mags_obj","_items_obj"]; + //{_cargo pushBack [(typeOf _x),[getWeaponCargo _x,getMagazineCargo _x,getItemCargo _x]]} foreach (_x getVariable ["cargo",[]]); + _type = _x select 0; + _cargo_obj = _x select 1; + _obj = _type createVehicle [0,0,0]; + btc_log_obj_created = btc_log_obj_created + [_obj]; + btc_curator addCuratorEditableObjects [[_obj], false]; + clearWeaponCargoGlobal _obj;clearItemCargoGlobal _obj;clearMagazineCargoGlobal _obj; + _weap_obj = _cargo_obj select 0; + if (count _weap_obj > 0) then { + for "_i" from 0 to ((count (_weap_obj select 0)) - 1) do { + _obj addWeaponCargoGlobal[((_weap_obj select 0) select _i),((_weap_obj select 1) select _i)]; + }; + }; + _mags_obj = _cargo_obj select 1; + if (count _mags_obj > 0) then { + for "_i" from 0 to ((count (_mags_obj select 0)) - 1) do { + _obj addMagazineCargoGlobal[((_mags_obj select 0) select _i),((_mags_obj select 1) select _i)]; + }; + }; + _items_obj = _cargo_obj select 2; + if (count _items_obj > 0) then { + for "_i" from 0 to ((count (_items_obj select 0)) - 1) do { + _obj addItemCargoGlobal[((_items_obj select 0) select _i),((_items_obj select 1) select _i)]; + }; + }; + [_obj,_veh] call btc_fnc_log_server_load; + } foreach (_x select 5); + _cont = (_x select 6); + clearWeaponCargoGlobal _veh;clearItemCargoGlobal _veh;clearMagazineCargoGlobal _veh; + _weap = _cont select 0; + if (count _weap > 0) then { + for "_i" from 0 to ((count (_weap select 0)) - 1) do { + _veh addWeaponCargoGlobal[((_weap select 0) select _i),((_weap select 1) select _i)]; + }; + }; + _mags = _cont select 1; + if (count _mags > 0) then { + for "_i" from 0 to ((count (_mags select 0)) - 1) do { + _veh addMagazineCargoGlobal[((_mags select 0) select _i),((_mags select 1) select _i)]; + }; + }; + _items = _cont select 2; + if (count _items > 0) then { + for "_i" from 0 to ((count (_items select 0)) - 1) do { + _veh addItemCargoGlobal[((_items select 0) select _i),((_items select 1) select _i)]; + }; + }; +} foreach _vehs; + +//Objs +/* + if (!isNil {_x getVariable "loaded"}) exitWith {}; + _data = []; + _data pushBack (typeOf _x); + _data pushBack (getPosASL _x); + _data pushBack (getDir _x); + _cargo = []; + {_cargo pushBack (typeOf _x)} foreach (_x getVariable ["cargo",[]]); + _data pushBack _cargo; + _array_obj pushBack _data; + _array_obj pushBack _data; +*/ +//btc_log_obj_created = []; +_objs = profileNamespace getVariable [format ["btc_hm_%1_objs",_name],[]]; +{ + private ["_obj","_cont","_weap","_mags","_items"]; + _obj = (_x select 0) createVehicle (_x select 1); + btc_log_obj_created = btc_log_obj_created + [_obj]; + btc_curator addCuratorEditableObjects [[_obj], false]; + _obj setDir (_x select 2); + _obj setPosASL (_x select 1); + { + /*private "_l"; + _l = _x createVehicle [0,0,0]; + btc_log_obj_created = btc_log_obj_created + [_l]; + btc_curator addCuratorEditableObjects [[_l], false]; + [_l,_obj] call btc_fnc_log_server_load;*/ + //NEW + private ["_type","_cargo_obj","_l","_weap_obj","_mags_obj","_items_obj"]; + //{_cargo pushBack [(typeOf _x),[getWeaponCargo _x,getMagazineCargo _x,getItemCargo _x]]} foreach (_x getVariable ["cargo",[]]); + _type = _x select 0; + _cargo_obj = _x select 1; + _l = _type createVehicle [0,0,0]; + btc_log_obj_created = btc_log_obj_created + [_l]; + btc_curator addCuratorEditableObjects [[_l], false]; + clearWeaponCargoGlobal _l;clearItemCargoGlobal _l;clearMagazineCargoGlobal _l; + _weap_obj = _cargo_obj select 0; + if (count _weap_obj > 0) then { + for "_i" from 0 to ((count (_weap_obj select 0)) - 1) do { + _l addWeaponCargoGlobal[((_weap_obj select 0) select _i),((_weap_obj select 1) select _i)]; + }; + }; + _mags_obj = _cargo_obj select 1; + if (count _mags_obj > 0) then { + for "_i" from 0 to ((count (_mags_obj select 0)) - 1) do { + _l addMagazineCargoGlobal[((_mags_obj select 0) select _i),((_mags_obj select 1) select _i)]; + }; + }; + _items_obj = _cargo_obj select 2; + if (count _items_obj > 0) then { + for "_i" from 0 to ((count (_items_obj select 0)) - 1) do { + _l addItemCargoGlobal[((_items_obj select 0) select _i),((_items_obj select 1) select _i)]; + }; + }; + [_l,_obj] call btc_fnc_log_server_load; + } foreach (_x select 3); + _cont = (_x select 4); + clearWeaponCargoGlobal _obj;clearItemCargoGlobal _obj;clearMagazineCargoGlobal _obj; + _weap = _cont select 0; + if (count _weap > 0) then { + for "_i" from 0 to ((count (_weap select 0)) - 1) do { + _obj addWeaponCargoGlobal[((_weap select 0) select _i),((_weap select 1) select _i)]; + }; + }; + _mags = _cont select 1; + if (count _mags > 0) then { + for "_i" from 0 to ((count (_mags select 0)) - 1) do { + _obj addMagazineCargoGlobal[((_mags select 0) select _i),((_mags select 1) select _i)]; + }; + }; + _items = _cont select 2; + if (count _items > 0) then { + for "_i" from 0 to ((count (_items select 0)) - 1) do { + _obj addItemCargoGlobal[((_items select 0) select _i),((_items select 1) select _i)]; + }; + }; +} foreach _objs; \ No newline at end of file diff --git a/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/db/save.sqf b/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/db/save.sqf index cb4c128db..cfa6fe874 100644 --- a/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/db/save.sqf +++ b/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/db/save.sqf @@ -1,19 +1,15 @@ -/* -profileNamespace setVariable ["var_kills",10000]; -saveProfileNamespace; -_playerKills = profileNamespace getVariable "var_kills";*/ +if !(isClass(configFile >> "cfgPatches" >> "inidbi2")) exitWith {[[11, "saved"],"btc_fnc_show_hint"] spawn BIS_fnc_MP;}; -call btc_fnc_db_delete; +"delete" call OO_fnc_inidbi; -private ["_cities_status","_fobs","_name","_array_ho","_data","_array_cache","_array_veh","_array_obj","_cargo","_cont"]; +private ["_cities_status","_fobs","_city_status","_array_ho","_data","_ho_markers","_array_cache","_array_veh","_cargo","_array_obj","_marker","_data_units"]; hint "saving..."; [[8],"btc_fnc_show_hint"] spawn BIS_fnc_MP; btc_db_is_saving = true; -_name = worldName; -profileNamespace setVariable [format ["btc_hm_%1_date",_name],date]; +["write", ["mission_Param", "date", date]] call OO_fnc_inidbi; for "_i" from 0 to (count btc_city_all - 1) do { private "_s"; @@ -22,12 +18,16 @@ for "_i" from 0 to (count btc_city_all - 1) do { }; hint "saving...2"; //City status +hint "saving City status"; _cities_status = []; +_nb_cities_data_units = [[],[]]; { //[151,false,false,true,false,false,[]] + private ["_id"]; _city_status = []; - _city_status pushBack (_x getVariable "id"); - + _id = (_x getVariable "id"); + _city_status pushBack _id ; + (_nb_cities_data_units select 0) pushBack _id; //_city_status pushBack (_x getVariable "name"); _city_status pushBack (_x getVariable "initialized"); @@ -35,7 +35,13 @@ _cities_status = []; _city_status pushBack (_x getVariable "spawn_more"); _city_status pushBack (_x getVariable "occupied"); - _city_status pushBack (_x getVariable "data_units"); + _data_units = +(_x getVariable "data_units"); + { + if ((_x select 0) isEqualTo 3) then { + _x set [7,getPos (_x select 7)]; + }; + } forEach _data_units; + (_nb_cities_data_units select 1) pushBack ([_data_units,"cities",format ["city_%1_data_units",(_city_status select 0)]] call btc_fnc_db_save_array); _city_status pushBack (_x getVariable ["has_ho",false]); _city_status pushBack (_x getVariable ["ho_units_spawned",false]); @@ -44,9 +50,14 @@ _cities_status = []; _cities_status pushBack _city_status; //diag_log format ["SAVE: %1 - %2",(_x getVariable "id"),(_x getVariable "occupied")]; } foreach btc_city_all; -profileNamespace setVariable [format ["btc_hm_%1_cities",_name],_cities_status]; +["write", ["cities", "nb_cities_data_units", _nb_cities_data_units]] call OO_fnc_inidbi; + +_nb_cities_status = [[_cities_status,"cities","cities_status"] call btc_fnc_db_save_array]; +["write", ["cities", "nb_cities_status", _nb_cities_status]] call OO_fnc_inidbi; + //HIDEOUT +hint "saving HIDEOUT"; _array_ho = []; { _data = []; @@ -54,7 +65,6 @@ _array_ho = []; _data pushBack (_x getVariable ["id",0]); _data pushBack (_x getVariable ["rinf_time",0]); _data pushBack (_x getVariable ["cap_time",0]); - _data pushBack (_x getVariable ["assigned_to",objNull]); _ho_markers = []; { @@ -67,11 +77,12 @@ _array_ho = []; diag_log format ["HO %1 DATA %2",_x,_data]; _array_ho pushBack _data; } foreach btc_hideouts; -profileNamespace setVariable [format ["btc_hm_%1_ho",_name],_array_ho]; +["write", ["cities", "ho", _array_ho]] call OO_fnc_inidbi; -profileNamespace setVariable [format ["btc_hm_%1_ho_sel",_name],(btc_hq getVariable ["info_hideout",objNull])]; +["write", ["cities", "ho_sel", (btc_hq getVariable ["info_hideout",objNull]) getVariable ["id",0] ]] call OO_fnc_inidbi; //CACHE +hint "saving CACHE"; _array_cache = []; _array_cache pushback (getposATL btc_cache_obj); _array_cache pushback (btc_cache_n); @@ -84,10 +95,11 @@ _cache_markers = []; _cache_markers pushBack _data; } foreach btc_cache_markers; _array_cache pushback (_cache_markers); -profileNamespace setVariable [format ["btc_hm_%1_cache",_name],_array_cache]; +["write", ["cities", "cache", _array_cache]] call OO_fnc_inidbi; //rep status -profileNamespace setVariable [format ["btc_hm_%1_rep",_name],btc_global_reputation]; +["write", ["cities", "rep", btc_global_reputation]] call OO_fnc_inidbi; + //FOBS _fobs = [[],[]]; { @@ -95,8 +107,7 @@ _fobs = [[],[]]; _pos = getMarkerPos _x; (_fobs select 0) pushBack [_x,_pos]; } foreach (btc_fobs select 0); -(_fobs select 1) append (btc_fobs select 1); -profileNamespace setVariable [format ["btc_hm_%1_fobs",_name],_fobs]; +["write", ["base", "fobs", _fobs]] call OO_fnc_inidbi; //Vehicles status _array_veh = []; @@ -104,7 +115,10 @@ _array_veh = []; private ["_data","_cargo","_cont"]; _data = []; _data pushBack (typeOf _x); - _data pushBack (getPos _x); + + _pos = getPos _x; + _data pushBack ([_pos select 0, _pos select 1, [0,_pos select 2] select ((_pos select 1) < 0) ]); + _data pushBack (getDir _x); _data pushBack (fuel _x); _data pushBack (damage _x); @@ -116,7 +130,7 @@ _array_veh = []; _array_veh pushBack _data; //diag_log format ["VEH %1 DATA %2",_x,_data]; } foreach btc_vehicles; -profileNamespace setVariable [format ["btc_hm_%1_vehs",_name],_array_veh]; +["write", ["base", "vehs", _array_veh]] call OO_fnc_inidbi; //Objects status _array_obj = []; @@ -136,11 +150,8 @@ _array_obj = []; _array_obj pushBack _data; }; } foreach btc_log_obj_created; -profileNamespace setVariable [format ["btc_hm_%1_objs",_name],_array_obj]; +["write", ["base", "objs", _array_obj]] call OO_fnc_inidbi; -// -profileNamespace setVariable [format ["btc_hm_%1_db",_name],true]; -saveProfileNamespace; hint "saving...3"; [[9],"btc_fnc_show_hint"] spawn BIS_fnc_MP; diff --git a/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/db/save_array.sqf b/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/db/save_array.sqf new file mode 100644 index 000000000..8b339a586 --- /dev/null +++ b/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/db/save_array.sqf @@ -0,0 +1,37 @@ + +private ["_array_to_save","_section","_key","_number_of_array","_step","_temp_save","_size_temp_array"]; + +_array_to_save = _this select 0; +_section = _this select 1; +_key = _this select 2; + +_step = count _array_to_save; +_number_of_array = 0; + +while {!(_array_to_save isEqualTo [])} do { + if (_step isEqualTo 0) exitWith { + hint "Error Array too big"; + _nb_cities_array ="Error Array too big"; + }; + + _temp_save = +_array_to_save; + _temp_save resize _step; + _size_temp_array = count (str(_temp_save)); + switch (_size_temp_array < 8100) do { + case true: + { + ["write", [_section, format ["%1_%2",_key,_number_of_array], _temp_save]] call OO_fnc_inidbi; + _array_to_save deleteRange [0,_step]; + if (count _array_to_save < _step) then {_step = count _array_to_save}; + _number_of_array = _number_of_array + 1; + }; + default + { + player sideChat str(_size_temp_array/8100); + player sideChat str(_step); + _step = floor(_step/ (_size_temp_array/8100)); + player sideChat str(_step); + }; + }; +}; +_number_of_array \ No newline at end of file diff --git a/=BTC=co@30_Hearts_and_Minds.Altis/core/init_server.sqf b/=BTC=co@30_Hearts_and_Minds.Altis/core/init_server.sqf index 20fc61834..1a1bbf810 100644 --- a/=BTC=co@30_Hearts_and_Minds.Altis/core/init_server.sqf +++ b/=BTC=co@30_Hearts_and_Minds.Altis/core/init_server.sqf @@ -1,8 +1,9 @@ + +private ["_Initialisation"]; + call compile preprocessFile "core\fnc\city\init.sqf"; -if (btc_db_load && {profileNamespace getVariable [format ["btc_hm_%1_db",worldName],false]}) then { - call compile preprocessFile "core\fnc\db\load.sqf"; -} else { +_Initialisation = { for "_i" from 1 to btc_hideout_n do {[] call btc_fnc_mil_create_hideout;}; setTimeMultiplier btc_p_acctime; @@ -12,4 +13,18 @@ if (btc_db_load && {profileNamespace getVariable [format ["btc_hm_%1_db",worldNa [] spawn {{waitUntil {!isNull _x};_x addMPEventHandler ["MPKilled", {if (isServer) then {_this call btc_fnc_eh_veh_killed};}];} foreach btc_vehicles;}; }; +if (btc_db_load && isClass(configFile >> "cfgPatches" >> "inidbi2")) then { + if ("exists" call OO_fnc_inidbi) then { + call compile preprocessFile "core\fnc\db\load.sqf"; + } else { + if (profileNamespace getVariable [format ["btc_hm_%1_db",worldName],false]) then { + call compile preprocessFile "core\fnc\db\load_old.sqf"; + } else { + [] call _Initialisation; + }; + }; +} else { + [] call _Initialisation; +}; + {[_x,30,false] spawn btc_fnc_eh_veh_add_respawn;} forEach btc_helo; \ No newline at end of file