Skip to content

Commit

Permalink
db: Update to extDB3 (#241)
Browse files Browse the repository at this point in the history
* db: Update to extDB3

Next arma update will support 64-bit and as extDB2 can't be build in x64
(without changing its code), it's about time to support extDB3.

Also, extDB3 already supports linux and doesn't have any major issue.

* extdb: some more extDB2 comments
  • Loading branch information
danielstuart14 authored and BoGuu committed Jan 26, 2017
1 parent 13de8d0 commit 8de51bd
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
8 changes: 4 additions & 4 deletions Altis_Life.Altis/core/session/fn_requestReceived.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ if (!isServer && (!isNil "life_adminlevel" || !isNil "life_coplevel" || !isNil "
//Parse basic player information.
CASH = parseNumber (_this select 2);
BANK = parseNumber (_this select 3);
CONST(life_adminlevel,parseNumber (_this select 4));
CONST(life_adminlevel,(_this select 4));
if (LIFE_SETTINGS(getNumber,"donor_level") isEqualTo 1) then {
CONST(life_donorlevel,parseNumber (_this select 5));
CONST(life_donorlevel,(_this select 5));
} else {
CONST(life_donorlevel,0);
};
Expand All @@ -52,7 +52,7 @@ life_gear = _this select 8;
//Parse side specific information.
switch (playerSide) do {
case west: {
CONST(life_coplevel, parseNumber(_this select 7));
CONST(life_coplevel,(_this select 7));
CONST(life_medicLevel,0);
life_blacklisted = _this select 9;
if (LIFE_SETTINGS(getNumber,"save_playerStats") isEqualTo 1) then {
Expand Down Expand Up @@ -96,7 +96,7 @@ switch (playerSide) do {
};

case independent: {
CONST(life_medicLevel, parseNumber(_this select 7));
CONST(life_medicLevel,(_this select 7));
CONST(life_coplevel,0);
if (LIFE_SETTINGS(getNumber,"save_playerStats") isEqualTo 1) then {
life_hunger = ((_this select 9) select 0);
Expand Down
4 changes: 2 additions & 2 deletions life_hc/MySQL/General/fn_asyncCall.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if (_queryResult isEqualTo "[3]") then {

if (_queryResult isEqualTo "[5]") then {
_loop = true;
for "_i" from 0 to 1 step 0 do { // extDB2 returned that result is Multi-Part Message
for "_i" from 0 to 1 step 0 do { // extDB3 returned that result is Multi-Part Message
_queryResult = "";
for "_i" from 0 to 1 step 0 do {
_pipe = EXTDB format ["5:%1", _key];
Expand All @@ -45,7 +45,7 @@ if (_queryResult isEqualTo "[5]") then {
};
};
_queryResult = call compile _queryResult;
if ((_queryResult select 0) isEqualTo 0) exitWith {diag_log format ["extDB2: Protocol Error: %1", _queryResult]; []};
if ((_queryResult select 0) isEqualTo 0) exitWith {diag_log format ["extDB3: Protocol Error: %1", _queryResult]; []};
_return = (_queryResult select 1);
if (!_multiarr && count _return > 0) then {
_return = (_return select 0);
Expand Down
4 changes: 2 additions & 2 deletions life_hc/hc_macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
//Condition Macros
#define CONFIG_BOOL(NUMBER) [##NUMBER] call { _ret = false; if ((_this select 0) in [0,1] && (_this select 0) isEqualTo 1) then { _ret = true; }; _ret;}

// extDB2 Macros
#define EXTDB "extDB2" callExtension
// extDB3 Macros
#define EXTDB "extDB3" callExtension
#define EXTDB_SETTING(TYPE,SETTING) TYPE(missionConfigFile >> "CfgServer" >> SETTING)
#define EXTDB_FAILED(MESSAGE) \
life_HC_server_extDB_notLoaded = [true,##MESSAGE]; \
Expand Down
12 changes: 6 additions & 6 deletions life_hc/initHC.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ if (isNil {uiNamespace getVariable "life_sql_id"}) then {

try {
_result = EXTDB format ["9:ADD_DATABASE:%1",EXTDB_SETTING(getText,"DatabaseName")];
if (!(_result isEqualTo "[1]")) then {throw "extDB2: Error with Database Connection"};
_result = EXTDB format ["9:ADD_DATABASE_PROTOCOL:%2:SQL_RAW_V2:%1:ADD_QUOTES",FETCH_CONST(life_sql_id),EXTDB_SETTING(getText,"DatabaseName")];
if (!(_result isEqualTo "[1]")) then {throw "extDB2: Error with Database Connection"};
if (!(_result isEqualTo "[1]")) then {throw "extDB3: Error with Database Connection"};
_result = EXTDB format ["9:ADD_DATABASE_PROTOCOL:%2:SQL:%1:TEXT2",FETCH_CONST(life_sql_id),EXTDB_SETTING(getText,"DatabaseName")];
if (!(_result isEqualTo "[1]")) then {throw "extDB3: Error with Database Connection"};
} catch {
diag_log _exception;
_extDBNotLoaded = [true, _exception];
};

if (_extDBNotLoaded isEqualType []) exitWith {};
EXTDB "9:LOCK";
diag_log "extDB2: Connected to Database";
diag_log "extDB3: Connected to Database";
} else {
life_sql_id = uiNamespace getVariable "life_sql_id";
CONSTVAR(life_sql_id);
diag_log "extDB2: Still Connected to Database";
diag_log "extDB3: Still Connected to Database";
};

if (_extDBNotLoaded isEqualType []) then {
Expand All @@ -48,7 +48,7 @@ if (_extDBNotLoaded isEqualType []) then {
};
};

if (_extDBNotLoaded isEqualType []) exitWith {}; //extDB2-HC did not fully initialize so terminate the rest of the initialization process.
if (_extDBNotLoaded isEqualType []) exitWith {}; //extDB3-HC did not fully initialize so terminate the rest of the initialization process.

[] spawn {
for "_i" from 0 to 1 step 0 do {
Expand Down
4 changes: 2 additions & 2 deletions life_server/Functions/MySQL/fn_asyncCall.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if (_queryResult isEqualTo "[3]") then {

if (_queryResult isEqualTo "[5]") then {
_loop = true;
for "_i" from 0 to 1 step 0 do { // extDB2 returned that result is Multi-Part Message
for "_i" from 0 to 1 step 0 do { // extDB3 returned that result is Multi-Part Message
_queryResult = "";
for "_i" from 0 to 1 step 0 do {
_pipe = EXTDB format ["5:%1", _key];
Expand All @@ -45,7 +45,7 @@ if (_queryResult isEqualTo "[5]") then {
};
};
_queryResult = call compile _queryResult;
if ((_queryResult select 0) isEqualTo 0) exitWith {diag_log format ["extDB2: Protocol Error: %1", _queryResult]; []};
if ((_queryResult select 0) isEqualTo 0) exitWith {diag_log format ["extDB3: Protocol Error: %1", _queryResult]; []};
_return = (_queryResult select 1);
if (!_multiarr && count _return > 0) then {
_return = (_return select 0);
Expand Down
10 changes: 5 additions & 5 deletions life_server/init.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@ if (isNil {uiNamespace getVariable "life_sql_id"}) then {
uiNamespace setVariable ["life_sql_id",life_sql_id];
try {
_result = EXTDB format ["9:ADD_DATABASE:%1",EXTDB_SETTING(getText,"DatabaseName")];
if (!(_result isEqualTo "[1]")) then {throw "extDB2: Error with Database Connection"};
_result = EXTDB format ["9:ADD_DATABASE_PROTOCOL:%2:SQL_RAW_V2:%1:ADD_QUOTES",FETCH_CONST(life_sql_id),EXTDB_SETTING(getText,"DatabaseName")];
if (!(_result isEqualTo "[1]")) then {throw "extDB2: Error with Database Connection"};
if (!(_result isEqualTo "[1]")) then {throw "extDB3: Error with Database Connection"};
_result = EXTDB format ["9:ADD_DATABASE_PROTOCOL:%2:SQL:%1:TEXT2",FETCH_CONST(life_sql_id),EXTDB_SETTING(getText,"DatabaseName")];
if (!(_result isEqualTo "[1]")) then {throw "extDB3: Error with Database Connection"};
} catch {
diag_log _exception;
_extDBNotLoaded = [true, _exception];
};
if (_extDBNotLoaded isEqualType []) exitWith {};
EXTDB "9:LOCK";
diag_log "extDB2: Connected to Database";
diag_log "extDB3: Connected to Database";
} else {
life_sql_id = uiNamespace getVariable "life_sql_id";
CONSTVAR(life_sql_id);
diag_log "extDB2: Still Connected to Database";
diag_log "extDB3: Still Connected to Database";
};


Expand Down
2 changes: 1 addition & 1 deletion life_server/script_macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#define CONST(var1,var2) var1 = compileFinal (if (var2 isEqualType "") then {var2} else {str(var2)})
#define CONSTVAR(var) var = compileFinal (if (var isEqualType "") then {var} else {str(var)})
#define FETCH_CONST(var) (call var)
#define EXTDB "extDB2" callExtension
#define EXTDB "extDB3" callExtension
#define EXTDB_SETTING(TYPE,SETTING) TYPE(missionConfigFile >> "CfgServer" >> SETTING)
#define EXTDB_FAILED(MESSAGE) \
life_server_extDB_notLoaded = [true,##MESSAGE]; \
Expand Down

12 comments on commit 8de51bd

@Torndeco
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note:
TEXT2 Option wont be compatible with upcoming
https://community.bistudio.com/wiki/parseSimpleArray

@nanougames
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's broken, MresArray doesn't work, extDB3 transform ["test1","test2"] to ['test1','test2'], and we can't do _this select 0; because it's not an array.

@BoGuu
Copy link
Member

@BoGuu BoGuu commented on 8de51bd Jan 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Torndeco
Just seeing that command makes me excited. Going over to predefineds at some point anyway 👍

@nanougames
In what example (which query) is this not working? A couple of people have tested this, and although the goal was to never use raw SQL, it's a drop in replacement for the time being. I didn't think they had any issues.

@BradenM
Copy link

@BradenM BradenM commented on 8de51bd Jan 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be working fantastic for me. Only (possible) issue is that setting the ip address to 127.0.0.1 wouldn't work for some reason. extDB3: Failed to Connect to Database May have been just my setup but using the public IP worked fine. Good work guys, appreciate it!

@danielstuart14
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here 127.0.0.1 is working.
try: localhost

@BradenM
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danielstuart14 It seems to acting a little strange. Again, perhaps its an error on my part, but somehow the connection to the database (which is localhost) was dropped over night. Upon restart it would not reconnect. I tried localhost and the public IP but neither worked. When I set it to 127.0.0.1 however, it worked. I will definitely update you if it randomly drops again. When testing 127.0.0.1 I also set Thread = 2 as it was defaulting to 0 and the comment below claimed its minimum was 2. Maybe this has something to do with it?

Also, how big of an impact does thread have? Should a dedicated server just be set to 6? Thanks.

Thread = 2; ;; Option to force number of worker threads for extDB3. ;; Min = 2, Max = 6

@danielstuart14
Copy link
Contributor Author

@danielstuart14 danielstuart14 commented on 8de51bd Jan 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"0" means that it'll autodetect your cpu cores.
But basicaly, add one thread for each core (Or thread for each cpu thread, if you have a HT cpu).

Anyway, if it happens again, you can send me a message in discord.

@nanougames
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to select this information: ["K","G","V"], but with extDB3, I have ['K','G','V'], and this is not an array in Arma 3, we can't select 0, select 1, select 2...... Any idea? @danielstuart14 @BoGuu

@danielstuart14
Copy link
Contributor Author

@danielstuart14 danielstuart14 commented on 8de51bd Jan 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

['K','G','V'] is an array and can be selected.
As @Torndeco said, just "parseSimpleArray" that won't be compatible with apostrophes
About the apostrophes, for arma: '123' is a string as "123".

Also, are you using DB_fnc_mresToArray? It removes the accent (`) that may be added.

@porducel
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please any help me !

After last update i need update to extDB3 !

10:54:04 SteamAPI initialization failed. Steam features won't be accessible!
10:54:04 Source set
10:54:04 Initializing stats manager.
10:54:04 Stats config disabled.
10:54:04 sessionID: 55ccf4e464b116ca82610844d920d1f2ed4bdaad
10:54:04 ../lib/Network/networkServer.cpp ClearNetServer:NOT IMPLEMENTED - briefing!
Cannot open file '/home/steam/steamcmd/arma3/@extDB3\addons\extdb3'
10:54:04 Critical:Destroying running thread!
10:54:04 Critical:Destroying running thread!
10:54:04 Critical:Destroying running thread!
10:54:04 Critical:Destroying running thread!
10:54:04 Critical:Destroying running thread!
10:54:04 Critical:Destroying running thread!

i create a simbolic link
ln -s extDB3.pbo extdb3.pbo

but extDB3 not work

10:57:27 "---------------------------------------------------------------------"
Call extension 'extDB3' could not be found
10:57:27 "extDB3 Failed to Load, Check Requirements @ https://bitbucket.org/torndeco/extdb3/wiki/Installation"
10:57:27 ""
10:57:27 "If you are running this on a client, Battleye will random block extensions. Try Disable Battleye"
10:57:27 "---------------------------------------------------------------------"
10:57:27 "---------------------------------------------------------------------"

please help me !

@BradenM
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@porducel

The new arma update broke it on Linux. Just wait for a fix.

@BoGuu
Copy link
Member

@BoGuu BoGuu commented on 8de51bd Mar 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK perf v1 fixes this issue @porducel @BradenJM

Please sign in to comment.