Commit 7113abcc authored by Razer's avatar Razer
Browse files

Added libredex pluginlist search path

parent 5d78675a
......@@ -9,6 +9,10 @@
* https://www.bistudio.com/monetization/
*/
// Allows recompile
// ["apmsDB"] call BASE_fnc_compileCfg;
params [["_order",[],[[]]]];
_MasterObject = bis_functions_mainscope;
_request = ["GetCfgFile",["configfiles",_order]];
......@@ -17,7 +21,7 @@ _configEntries = [_request] call DB_fnc_sendRequest;
// Handle missing plugin.cfg files
{
if(_x isEqualType "") then {
diag_log format ["<PluginManager>: WARNING: Unable find file: %1.cfg",_order select _forEachIndex];
diag_log format ["<PluginManager>: WARNING: Unable find config file: %1.cfg",_order select _forEachIndex];
diag_log _x;
// Replace "error" with empty array
......@@ -46,7 +50,7 @@ if(_pwDataIndex != -1 && {_index != -1}) then {
_password = ((_configEntries select _pwDataIndex) select _index) select 1;
if(_lockServer) then {
if(_password serverCommand "#lock") then {
if(_password != "SERVER_COMMAND_PASSWORD_HERE" && {_password serverCommand "#lock"}) then {
uiSleep 1;
diag_log "<PluginManager>: INFO: Server Locked!";
} else {
......@@ -76,8 +80,7 @@ _cfg = configFile >> "Plugins";
// Check required plugins
_missingPlugins = [];
_requiredPlugins = getArray(_config >> "requiredPlugins");
_requiredPlugins apply {
(getArray(_config >> "requiredPlugins")) apply {
if(_x isEqualType []) then { // is array (Version check)
// (Required Plugin (Required)) / (Required Min Version (Required)) / (Required Max Version (Optional))
_x params [["_rp","",[""]],["_rvmin",-1],["_rvmax",-1]];
......
......@@ -9,7 +9,7 @@
* https://www.bistudio.com/monetization/
*/
[] spawn { // Move to a scheduled for faster execution
[] spawn { // Move to a scheduled for faster execution (Because unscheduled is already too busy handling arma/other mod preInit functions)
BASE_var_MapEditsDone = false;
BASE_var_serverReady = false;
......@@ -20,75 +20,71 @@
//--- compile initialization list of files | get PluginList.cfg from DLL
_request = ["GetInitOrder",[]];
_order = [_request] call DB_fnc_sendRequest;
if (isNil "_order") exitWith {
for "_i" from 1 to 8 do {
diag_log "<PluginManager>: ERROR: APMSDB PLUGIN NOT FOUND!";
};
_order = [_request] call (missionNamespace getVariable ["DB_fnc_sendRequest",{for "_i" from 1 to 10 do {diag_log "<PluginManager>: ERROR: APMSDB PLUGIN NOT FOUND! (ApmsDB.pbo)"}}]);;
if (isNil "_order" || {_order isEqualType [] && {(_order select 0) isEqualType "" && {_order select 0 == "error"}}}) exitWith {}; // error already logged to rpt
if (_order isEqualTo []) exitWith {
for "_i" from 1 to 10 do {diag_log formatText ["ERROR: LIBREDEX EXTENSION NOT FOUND!"]};
diag_log "<PluginManager>: ERROR: MAKE SURE YOU HAVE PLACED 'LIBREDEX' EXTENSION INSIDE YOUR SERVER FOLDER!";
};
_entryCount = [];
_tagList = [];
_blockList = [];
_password = "";
_apmsPath = "";
if(_order isEqualTo "") then {
// Remove apms server mod path from _order
if (count _order > 1 && {((_order select 0) isEqualType []) && {(_order select 1) isEqualType []}}) then {
_apmsPath = (_order select 0) select 0;
_order = _order select 1; // Select order array
};
// Compile CFG.s and lock server (Requires libredex)
_entryCount = [_order] call BASE_fnc_compileCfg;
// Add tags later
_pluginList = _order apply {[_x]};
[] spawn {
for "_i" from 1 to 8 do {
diag_log "<PluginManager>: ERROR: LIBREDEX EXTENSION NOT FOUND!";
sleep 0.2;
// Get the tag list so that order is defined by PluginList.cfg
("true" configClasses (configFile >> "Plugins")) apply {
_thisName = configName _x;
//--- Check if plugin is defined in pluginList.cfg
if ((_order findIf {(toLower _x) == toLower(_thisName)}) != -1) then {
//--- Make sure tag exists
_tag = (getText(_x >> "tag"));
if(_tag == "") exitWith {
diag_log formatText ["ERROR: Tag not defined for plugin: %1, in plugins config.cpp!",_thisName];
};
diag_log "<PluginManager>: ERROR: MAKE SURE YOU HAVE PLACED 'LIBREDEX' EXTENSION INSIDE YOUR SERVER FOLDER!";
};
// If libredex is not working, then get the enabled plugins by this way
_order = ("true" configClasses (configFile >> "Plugins")); // Its wrong order but its still something -
_tagList = _order apply {(getText(_x >> "tag"))};
} else {
// Compile CFG.s and lock server (Requires libredex)
_entryCount = call BASE_fnc_compileCfg;
// Get the tag list so that order is defined by PluginList.cfg
_cfg = configFile >> "Plugins";
_order apply {
_cfgEntry = _cfg >> _x;
if(isClass _cfgEntry) then {
_tag = (GetText(_cfgEntry >> "tag"));
if(_tag == "") exitWith {
for "_i" from 1 to 5 do {
diag_log format ["<PluginManager>: ERROR: Tag not defined for plugin: %1, in plugins config.cpp!",_x];
};
};
//--- Make sure plugin tag is not already in use
_index = _tagList find _tag;
if(_index != -1) then {
for "_i" from 1 to 5 do {
_usedPlugin = _order select _index;
diag_log format ["<PluginManager>: ERROR: Cannot use TAG: %1, for plugin: %2. Already defined for plugin: %3!",_tag,_x,_usedPlugin];
};
_tagList pushBack ""; // pushBack empty string to keep the rest of the indexes right
} else {
_tagList pushBack _tag;
};
} else {
//--- Make sure plugin tag is not already in use
_tagIndex = _pluginList findIf {count _x == 2 && {_x select 1 == _tag}};
if(_tagIndex != -1) then {
for "_i" from 1 to 5 do {
diag_log format ["<PluginManager>: WARNING: 'Class Plugins' not defined for plugin: %1, in plugins config.cpp!",_x];
_usedPlugin = _order select _tagIndex;
diag_log formatText ["ERROR: Cannot use tag: %1 for plugin: %2. Already defined for plugin: %3!",_tag,_thisName,_usedPlugin];
};
_tagList pushBack ""; // pushBack empty string to keep the rest of the indexes right
} else {
_tagList pushBack _tag;
};
_index = _pluginList findIf {_x select 0 == _thisName};
if (_index != -1) then {
_pluginList set [_index,[_thisName,_tag]];
};
} else {
//--- Plugin is not defined in pluginList.cfg
diag_log formatText ["WARNING: Plugin %1 not defined in PluginList.cfg!",_thisName];
};
};
diag_log format["<PluginManager>: Loading %1 plugins...",count(_order)];
// TODO Check if plugin is defined in pluginlist.cfg but doesent exist in configs (Addon .pbo missing)
// Create broadcasted PluginList (Make sure tag list is in right order)
BASE_var_pluginList = [];
{
BASE_var_pluginList pushBack [_x,_tagList select _forEachIndex];
} forEach _order;
// Create broadcasted PluginList
BASE_var_pluginList = +(_pluginList);
publicVariable "BASE_var_pluginList";
// GET FUNCTIONS FOR CLIENTS AND SERVER
......@@ -141,10 +137,13 @@
// Add plugin list
diag_log formatText ["==================================================================================="];
uiSleep 0.5; // Wait for the "mission id" message to disappear
if (_apmsPath != "") then {diag_log formatText ["Loading plugins from:: %1",_apmsPath]};
diag_log formatText ["Loading %1 plugins...",count(_order)];
diag_log formatText ["|=================================================================================|"];
diag_log formatText ["| Plugin List |"];
diag_log formatText ["|=================================================================================|"];
diag_log formatText ["| Tag | Name | Version | Server | Client | Configs |"];
diag_log formatText ["| Tag | Name | Version | Server | Global | Configs |"];
diag_log formatText ["| | | | Functions | Functions | |"];
diag_log formatText ["|-------------------------------------|---------|-----------|---------------------|"];
{
......@@ -171,10 +170,10 @@
diag_log formatText ["|%1%2 |%3%4 | %5%6 | %7%8 | %9%10 | %11%12 |",_a,_tag,_b,_name,_c,_versionString,_d,_serverFuncCount,_e,_clientFuncCount,_f,_configCount];
} forEach BASE_var_pluginList;
diag_log formatText ["==================================================================================="];
diag_log formatText ["|=================================================================================|"];
diag_log format ["<PluginManager>: Server function count: %1",count(BASE_var_functions_server)];
diag_log format ["<PluginManager>: Client function count: %1",count(BASE_var_functions_client)];
diag_log formatText ["Server function count: %1",count(BASE_var_functions_server)];
diag_log formatText ["Client function count: %1",count(BASE_var_functions_client)];
// this variable is used in the Mission file to broadcast the client functions
......
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