From 56c81ba5b6a1d9e91f9063561d21b7977d4112c1 Mon Sep 17 00:00:00 2001 From: AirwavesMan Date: Sat, 12 Sep 2020 14:40:57 +0200 Subject: [PATCH] Compile whole trading functions at start DB traders are no longer in. We can now compile all trading function directly at the start. This makes it easier for server admins to modify them. --- .../actions/AdvancedTrading/compiles.sqf | 85 +++++++++++++++++++ .../actions/AdvancedTrading/defaultInit.sqf | 39 --------- .../actions/AdvancedTrading/init.sqf | 67 +-------------- SQF/dayz_code/init/compiles.sqf | 4 +- SQF/dayz_code/stringtable.xml | 5 +- 5 files changed, 94 insertions(+), 106 deletions(-) create mode 100644 SQF/dayz_code/actions/AdvancedTrading/compiles.sqf delete mode 100644 SQF/dayz_code/actions/AdvancedTrading/defaultInit.sqf diff --git a/SQF/dayz_code/actions/AdvancedTrading/compiles.sqf b/SQF/dayz_code/actions/AdvancedTrading/compiles.sqf new file mode 100644 index 000000000..02525ffab --- /dev/null +++ b/SQF/dayz_code/actions/AdvancedTrading/compiles.sqf @@ -0,0 +1,85 @@ +#define STRINGIFY(x) #x +#define PATH(sub_path) STRINGIFY(\z\addons\dayz_code\actions\AdvancedTrading\functions\sub_path) +#define CPP compile preprocessFileLineNumbers + +private ["_tempGemList","_tempWorthList","_largest","_LargestGem"]; + +Z_SellingFrom = 2; +DZE_GemList = []; +DZE_GemWorthList = []; +Z_Selling = true; +Z_OriginalSellableArray = []; +Z_SellableArray = []; +Z_SellArray = []; +Z_OriginalBuyableArray = []; +Z_BuyableArray = []; +Z_BuyingArray = []; + +_tempGemList = []; +_tempWorthList = []; + +{ + _tempGemList set [(count _tempGemList), (_x select 0)]; + _tempWorthList set [(count _tempWorthList), (_x select 1)]; +} count DZE_GemWorthArray; + +for "_i" from 0 to ((count _tempGemList) - 1) do { + _largest = -1e9; + + { + _largest = _largest max _x; + } forEach _tempWorthList; + + _LargestGem = _tempGemList select (_tempWorthList find _largest); + _tempWorthList = _tempWorthList - [_largest]; + _tempGemList = _tempGemList - [_LargestGem]; + DZE_GemList set [(count DZE_GemList), _LargestGem]; + DZE_GemWorthList set [(count DZE_GemWorthList), _largest]; +}; + +Z_fillTradeTitle = CPP PATH(z_at_fillTradeTitle.sqf); +Z_clearLists = CPP PATH(z_at_clearLists.sqf); +Z_clearSellableList = CPP PATH(z_at_clearSellableList.sqf); +Z_clearBuyList = CPP PATH(z_at_clearBuyList.sqf); +Z_clearBuyingList = CPP PATH(z_at_clearBuyingList.sqf); +Z_fillCategories = CPP PATH(z_at_fillCategories.sqf); +Z_getItemInfo = CPP PATH(z_at_getItemInfo.sqf); +Z_getItemConfig = CPP PATH(z_at_getItemConfig.sqf); +Z_displayItemInfo = CPP PATH(z_at_displayItemInfo.sqf); +Z_displayWeaponInfo = CPP PATH(z_at_displayWeaponInfo.sqf); +Z_displayBackpackInfo = CPP PATH(z_at_displayBackpackInfo.sqf); +Z_displayVehicleInfo = CPP PATH(z_at_displayVehicleInfo.sqf); +Z_getContainer = CPP PATH(z_at_getContainer.sqf); +Z_getBackpackItems = CPP PATH(z_at_getBackpackItems.sqf); +Z_getVehicleItems = CPP PATH(z_at_getVehicleItems.sqf); +Z_getGearItems = CPP PATH(z_at_getGearItems.sqf); +Z_logTrade = CPP PATH(z_at_logTrade.sqf); +Z_filterList = CPP PATH(z_at_filterList.sqf); +Z_checkArrayInConfig = CPP PATH(z_at_checkArrayInConfig.sqf); +Z_calcPrice = CPP PATH(z_at_calcPrice.sqf); +Z_fillCategoryList = CPP PATH(z_at_fillCategoryList.sqf); +Z_fillSellList = CPP PATH(z_at_fillSellList.sqf); +Z_fillSellingList = CPP PATH(z_at_fillSellingList.sqf); +Z_pushItemToList = CPP PATH(z_at_pushItemToList.sqf); +Z_removeItemFromList = CPP PATH(z_at_removeItemFromList.sqf); +Z_pushAllToList = CPP PATH(z_at_pushAllToList.sqf); +Z_removeAllToList = CPP PATH(z_at_removeAllToList.sqf); +Z_SellItems = CPP PATH(z_at_sellItems.sqf); +Z_BuyItems = CPP PATH(z_at_buyItems.sqf); +Z_ChangeBuySell = CPP PATH(z_at_changeBuySell.sqf); +Z_removeAllFromBuyingList = CPP PATH(z_at_removeAllFromBuyingList.sqf); +Z_removeItemFromBuyingList = CPP PATH(z_at_removeItemFromBuyingList.sqf); +Z_toBuyingList = CPP PATH(z_at_toBuyingList.sqf); +Z_calcBuyableList = CPP PATH(z_at_calcBuyableList.sqf); +Z_fillBuyableList = CPP PATH(z_at_fillBuyableList.sqf); +Z_fillBuyingList = CPP PATH(z_at_fillBuyingList.sqf); +Z_displayFreeSpace = CPP PATH(z_at_displayFreeSpace.sqf); +Z_allowBuying = CPP PATH(z_at_allowBuying.sqf); +DZE_deleteTradedVehicle = CPP PATH(DZE_deleteTradedVehicle.sqf); +Z_checkCloseVehicle = CPP PATH(z_at_checkCloseVehicle.sqf); +Z_canAfford = CPP PATH(z_at_canAfford.sqf); +Z_calcFreeSpace = CPP PATH(z_at_calcFreeSpace.sqf); +Z_returnChange = CPP PATH(z_at_returnChange.sqf); +Z_payDefault = CPP PATH(z_at_payDefault.sqf); +z_calcCurrency = CPP PATH(z_at_calcCurrency.sqf); +ZUPA_fnc_removeWeaponsAndMagazinesCargo = CPP PATH(zupa_fnc_removeWeaponsAndMagazinesCargo.sqf); diff --git a/SQF/dayz_code/actions/AdvancedTrading/defaultInit.sqf b/SQF/dayz_code/actions/AdvancedTrading/defaultInit.sqf deleted file mode 100644 index 3452c0b08..000000000 --- a/SQF/dayz_code/actions/AdvancedTrading/defaultInit.sqf +++ /dev/null @@ -1,39 +0,0 @@ -#define STRINGIFY(x) #x -#define PATH(sub_path) STRINGIFY(\z\addons\dayz_code\actions\AdvancedTrading\functions\sub_path) -#define CPP compile preprocessFileLineNumbers - -private ["_tempGemList","_tempWorthList","_largest","_LargestGem"]; - -Z_SellingFrom = 2; -DZE_GemList = []; -DZE_GemWorthList = []; - -_tempGemList = []; -_tempWorthList = []; - -{ - _tempGemList set [(count _tempGemList), (_x select 0)]; - _tempWorthList set [(count _tempWorthList), (_x select 1)]; -} count DZE_GemWorthArray; - -for "_i" from 0 to ((count _tempGemList) - 1) do { - _largest = -1e9; - - { - _largest = _largest max _x; - } forEach _tempWorthList; - - _LargestGem = _tempGemList select (_tempWorthList find _largest); - _tempWorthList = _tempWorthList - [_largest]; - _tempGemList = _tempGemList - [_LargestGem]; - DZE_GemList set [(count DZE_GemList), _LargestGem]; - DZE_GemWorthList set [(count DZE_GemWorthList), _largest]; -}; - -Z_checkCloseVehicle = CPP PATH(z_at_checkCloseVehicle.sqf); -Z_canAfford = CPP PATH(z_at_canAfford.sqf); -Z_calcFreeSpace = CPP PATH(z_at_calcFreeSpace.sqf); -Z_returnChange = CPP PATH(z_at_returnChange.sqf); -Z_payDefault = CPP PATH(z_at_payDefault.sqf); -z_calcCurrency = CPP PATH(z_at_calcCurrency.sqf); -ZUPA_fnc_removeWeaponsAndMagazinesCargo = CPP PATH(zupa_fnc_removeWeaponsAndMagazinesCargo.sqf); diff --git a/SQF/dayz_code/actions/AdvancedTrading/init.sqf b/SQF/dayz_code/actions/AdvancedTrading/init.sqf index a6374fab1..c4dbf46b0 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/init.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/init.sqf @@ -1,6 +1,6 @@ -#define STRINGIFY(x) #x -#define PATH(sub_path) STRINGIFY(\z\addons\dayz_code\actions\AdvancedTrading\functions\sub_path) -#define CPP compile preprocessFileLineNumbers +if (dayz_actionInProgress) exitWith { localize "str_player_actionslimit" call dayz_rollingMessages; }; + +#include "\z\addons\dayz_code\actions\AdvancedTrading\functions\defines.hpp" disableSerialization; @@ -10,67 +10,6 @@ if (isNil "Z_traderData" or {count Z_traderData == 0}) exitWith { localize "STR_EPOCH_TRADE_ERROR" call dayz_rollingMessages; }; -if (dayz_actionInProgress) exitWith { localize "str_player_actionslimit" call dayz_rollingMessages; }; - -if (isNil "Z_AdvancedTradingInit") then { - - #include "\z\addons\dayz_code\actions\AdvancedTrading\functions\defines.hpp" - - /* Configs that needs to be defined but not changed in config file */ - - Z_Selling = true; - Z_OriginalSellableArray = []; - Z_SellableArray = []; - Z_SellArray = []; - Z_OriginalBuyableArray = []; - Z_BuyableArray = []; - Z_BuyingArray = []; - - /* end script config */ - - Z_fillTradeTitle = CPP PATH(z_at_fillTradeTitle.sqf); - Z_clearLists = CPP PATH(z_at_clearLists.sqf); - Z_clearSellableList = CPP PATH(z_at_clearSellableList.sqf); - Z_clearBuyList = CPP PATH(z_at_clearBuyList.sqf); - Z_clearBuyingList = CPP PATH(z_at_clearBuyingList.sqf); - Z_fillCategories = CPP PATH(z_at_fillCategories.sqf); - Z_getItemInfo = CPP PATH(z_at_getItemInfo.sqf); - Z_getItemConfig = CPP PATH(z_at_getItemConfig.sqf); - Z_displayItemInfo = CPP PATH(z_at_displayItemInfo.sqf); - Z_displayWeaponInfo = CPP PATH(z_at_displayWeaponInfo.sqf); - Z_displayBackpackInfo = CPP PATH(z_at_displayBackpackInfo.sqf); - Z_displayVehicleInfo = CPP PATH(z_at_displayVehicleInfo.sqf); - Z_getContainer = CPP PATH(z_at_getContainer.sqf); - Z_getBackpackItems = CPP PATH(z_at_getBackpackItems.sqf); - Z_getVehicleItems = CPP PATH(z_at_getVehicleItems.sqf); - Z_getGearItems = CPP PATH(z_at_getGearItems.sqf); - Z_logTrade = CPP PATH(z_at_logTrade.sqf); - Z_filterList = CPP PATH(z_at_filterList.sqf); - Z_checkArrayInConfig = CPP PATH(z_at_checkArrayInConfig.sqf); - Z_calcPrice = CPP PATH(z_at_calcPrice.sqf); - Z_fillCategoryList = CPP PATH(z_at_fillCategoryList.sqf); - Z_fillSellList = CPP PATH(z_at_fillSellList.sqf); - Z_fillSellingList = CPP PATH(z_at_fillSellingList.sqf); - Z_pushItemToList = CPP PATH(z_at_pushItemToList.sqf); - Z_removeItemFromList = CPP PATH(z_at_removeItemFromList.sqf); - Z_pushAllToList = CPP PATH(z_at_pushAllToList.sqf); - Z_removeAllToList = CPP PATH(z_at_removeAllToList.sqf); - Z_SellItems = CPP PATH(z_at_sellItems.sqf); - Z_BuyItems = CPP PATH(z_at_buyItems.sqf); - Z_ChangeBuySell = CPP PATH(z_at_changeBuySell.sqf); - Z_removeAllFromBuyingList = CPP PATH(z_at_removeAllFromBuyingList.sqf); - Z_removeItemFromBuyingList = CPP PATH(z_at_removeItemFromBuyingList.sqf); - Z_toBuyingList = CPP PATH(z_at_toBuyingList.sqf); - Z_calcBuyableList = CPP PATH(z_at_calcBuyableList.sqf); - Z_fillBuyableList = CPP PATH(z_at_fillBuyableList.sqf); - Z_fillBuyingList = CPP PATH(z_at_fillBuyingList.sqf); - Z_displayFreeSpace = CPP PATH(z_at_displayFreeSpace.sqf); - Z_allowBuying = CPP PATH(z_at_allowBuying.sqf); - DZE_deleteTradedVehicle = CPP PATH(DZE_deleteTradedVehicle.sqf); - - Z_AdvancedTradingInit = true; -}; - Z_Selling = true; // Always start menu in buy mode (flipped in z_at_changeBuySell.sqf on startup) Z_CategoryView = true; // Always start in category view Z_BuyingArray = []; diff --git a/SQF/dayz_code/init/compiles.sqf b/SQF/dayz_code/init/compiles.sqf index 20afedc14..8ae4f59d9 100644 --- a/SQF/dayz_code/init/compiles.sqf +++ b/SQF/dayz_code/init/compiles.sqf @@ -205,8 +205,8 @@ if (!isDedicated) then { fnc_setWeather = compile preprocessFileLineNumbers "\z\addons\dayz_code\system\weather\setWeather.sqf"; fnc_groundFog = compile preprocessFileLineNumbers "\z\addons\dayz_code\system\weather\groundFog.sqf"; - // Advanced trading default inits for maintaining, Advanced Trading and custom scripts to utilize gem based currency. - call compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\AdvancedTrading\defaultInit.sqf"; + // Compiles of all trading related functions + call compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\AdvancedTrading\compiles.sqf"; fnc_alertZombies = { private ["_unit","_pos","_dis","_sfx"]; diff --git a/SQF/dayz_code/stringtable.xml b/SQF/dayz_code/stringtable.xml index 73b215593..b0da4c14e 100644 --- a/SQF/dayz_code/stringtable.xml +++ b/SQF/dayz_code/stringtable.xml @@ -30223,7 +30223,10 @@ A blood bag filled with blood from a sheep. Eine Blutkonserve gefüllt mit dem Blut eines Schafes. - + + Weight + Gewicht +