Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: Change profileNamespace DB to inidbi2 #112

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b4bdf45
Add: inidb into DB save.sqf
Vdauphin Jan 17, 2016
2df99bd
FIX: private variable missing
Vdauphin Jan 17, 2016
fc24a7c
FIX: compile take string not code
Vdauphin Jan 17, 2016
aa78ad7
FIX: change DB name
Vdauphin Jan 17, 2016
9d013c8
Add: iniDB for load
Vdauphin Jan 17, 2016
c06406b
FIX: inidb can't take object parameter for assigned_to and ho_sel
Vdauphin Jan 18, 2016
1a6e3fc
FIX: distance
Vdauphin Jan 18, 2016
8bd1408
FIX: side is save as string not object
Vdauphin Jan 19, 2016
b2eda14
FIXsss
Vdauphin Jan 24, 2016
f661e59
Add Load big array
Vdauphin Jan 24, 2016
c7d3c08
FIX: increament big array
Vdauphin Jan 24, 2016
3870678
Add: btc_fnc_db_save_array to save big array
Vdauphin Jan 24, 2016
ad4790c
Add: btc_fnc_db_save_array return the number of key created
Vdauphin Jan 24, 2016
869ce7e
Add: load big array
Vdauphin Jan 26, 2016
dd1e4a8
Add: Check if iniDB is present server side
Vdauphin Jan 30, 2016
d009ac3
FIX: can't compile string
Vdauphin Jan 30, 2016
0861a25
FIX: rtp output when iniDB presence test
Vdauphin Jan 31, 2016
3f51ffa
Add: FOB save
Vdauphin Jan 31, 2016
90519f2
FIXsss : objects
Vdauphin Jan 31, 2016
db2350c
Add: Final phase support
Vdauphin Jan 31, 2016
95e9980
FIX: improve saving big array
Vdauphin Feb 1, 2016
5c1a2e7
FIX: private entry
Vdauphin Feb 8, 2016
5361161
Add: 30 slots migration
Vdauphin Feb 21, 2016
418fc80
Merge remote-tracking branch 'refs/remotes/origin/master_daily' into …
Vdauphin May 1, 2016
af95d58
FIX: init_server and load old DB
Vdauphin May 5, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion =BTC=co@30_Hearts_and_Minds.Altis/core/def/param.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,4 @@ class Params {
texts[]={"Civilian (A3)","Afghan (@Ericj_Taliban)"};
default = 0;
};
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
};
};
2 changes: 2 additions & 0 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/compile.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
18 changes: 16 additions & 2 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/data/spawn_group.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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};
};
};
};
};

Expand Down
17 changes: 2 additions & 15 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/db/delete.sqf
Original file line number Diff line number Diff line change
@@ -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;
86 changes: 52 additions & 34 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/db/load.sqf
Original file line number Diff line number Diff line change
@@ -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");
Expand All @@ -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

Expand Down Expand Up @@ -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"];
Expand All @@ -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];

Expand All @@ -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];

Expand All @@ -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;
Expand All @@ -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];};
Expand All @@ -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);
Expand Down Expand Up @@ -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)];
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Loading