1
0
mirror of https://github.com/acemod/ACE3.git synced 2024-08-30 18:23:18 +00:00

Merge pull request from KoffeinFlummi/pre-postInit-module-exec

Pre-postInit module execution
This commit is contained in:
Glowbal 2015-03-22 22:33:32 +01:00
commit c7b505a31c
11 changed files with 143 additions and 13 deletions

@ -6,8 +6,10 @@ class CfgVehicles {
class ArgumentsBaseUnits {
};
};
class ACE_Module;
// TODO localization for all the modules
class ACE_moduleMedicalSettings: Module_F {
class ACE_moduleMedicalSettings: ACE_Module {
scope = 2;
displayName = "Medical Settings [ACE]";
icon = QUOTE(PATHTOF(ui\moduleIcon.paa));
@ -129,7 +131,7 @@ class CfgVehicles {
};
};
class ACE_moduleTreatmentConfiguration: Module_F {
class ACE_moduleTreatmentConfiguration: ACE_Module {
scope = 2;
displayName = "Treatment Configuration [ACE]";
icon = QUOTE(PATHTOF(ui\moduleIcon.paa));

@ -218,19 +218,21 @@ if (isNil QGVAR(level)) then {
}, 0, []] call CBA_fnc_addPerFrameHandler;
// broadcast injuries to JIP clients in a MP session
if (isMultiplayer and GVAR(level) >= 2) then {
if (isMultiplayer) then {
[QGVAR(onPlayerConnected), "onPlayerConnected", {
if (isNil QGVAR(InjuredCollection)) then {
GVAR(InjuredCollection) = [];
};
if (GVAR(level) >= 2) then {
if (isNil QGVAR(InjuredCollection)) then {
GVAR(InjuredCollection) = [];
};
{
_unit = _x;
_openWounds = _unit getvariable [QGVAR(openWounds), []];
{
["medical_propagateWound", [_id], [_unit, _x]] call EFUNC(common,targetEvent);
}foreach _openWounds;
}foreach GVAR(InjuredCollection);
_unit = _x;
_openWounds = _unit getvariable [QGVAR(openWounds), []];
{
["medical_propagateWound", [_id], [_unit, _x]] call EFUNC(common,targetEvent);
}foreach _openWounds;
}foreach GVAR(InjuredCollection);
};
}, []] call BIS_fnc_addStackedEventHandler;
};

@ -5,7 +5,7 @@ class CfgPatches {
units[] = {"ACE_medicalSupplyCrate", "ACE_fieldDressingItem", "ACE_packingBandageItem", "ACE_elasticBandageItem", "ACE_tourniquetItem", "ACE_morphineItem", "ACE_atropineItem", "ACE_epinephrineItem", "ACE_plasmaIVItem", "ACE_bloodIVItem", "ACE_salineIVItem", "ACE_quikclotItem", "ACE_personalAidKitItem", "ACE_surgicalKitItem", "ACE_bodyBagItem"};
weapons[] = {"ACE_fieldDressing", "ACE_packingBandage", "ACE_elasticBandage", "ACE_tourniquet", "ACE_morphine", "ACE_atropine", "ACE_epinephrine", "ACE_plasmaIV", "ACE_plasmaIV_500", "ACE_plasmaIV_250", "ACE_bloodIV", "ACE_bloodIV_500", "ACE_bloodIV_250", "ACE_salineIV", "ACE_salineIV_500", "ACE_salineIV_250", "ACE_quikclot", "ACE_personalAidKit", "ACE_surgicalKit", "ACE_bodyBag"};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {ace_common, ace_interaction};
requiredAddons[] = {ace_common, ace_interaction, ace_modules};
author[] = {"Glowbal", "KoffienFlummi"};
authorUrl = "";
VERSION_CONFIG;

@ -0,0 +1 @@
z\ace\addons\modules

@ -0,0 +1,13 @@
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};
class Extended_PostInit_EventHandlers {
class _ACE_modules { // using a _ so it is the first postInit to be executed
init = QUOTE(call COMPILE_FILE(XEH_postInit));
};
};

@ -0,0 +1,44 @@
#include "script_component.hpp"
// TODO This is a basic and limited implementation that mimics some of the functionality from the A3 module framework, but not all of it.
// We have to execute this in the postInit XEH because on object init, the parameters of the modules are not yet available. They are if we execute it at the start of postInit execution.
{
[_x] call {
private ["_logic", "_logicType", "_config", "_isGlobal", "_isDisposable", "_isPersistent","_function"];
_logic = _this select 0;
_logicType = typeof _logic;
_logic hideobject true;
if (_logic getvariable [QGVAR(initalized), false]) exitwith {};
_config = (configFile >> "CfgVehicles" >> _logicType);
if !(isClass _config) exitwith {};
// isGlobal = 1;
_isGlobal = getNumber (_config >> "isGlobal") > 0;
_isDisposable = getNumber (_config >> "isDisposable") > 0;
_isPersistent = getNumber (_config >> "isPersistent") > 0 || getnumber (_config >> "isGlobal") > 1;
_function = getText (_config >> "function");
if (isnil _function) then {
_function = compile _function;
} else {
_function = missionNamespace getvariable _function;
};
if (_isGlobal) then {
[_logic, [], true] call _function;
} else {
if (isServer) then {
[_logic, [], true] call _function;
};
};
if !(_isPersistent) then {
_logic setvariable [QGVAR(initalized), true];
};
if (_isDisposable) then {
deleteVehicle _logic;
};
};
}foreach GVAR(moduleInitCollection);

@ -0,0 +1,8 @@
#include "script_component.hpp"
ADDON = false;
PREP(moduleInit);
GVAR(moduleInitCollection) = [];
ADDON = true;

28
addons/modules/config.cpp Normal file

@ -0,0 +1,28 @@
#include "script_component.hpp"
class CfgPatches {
class ADDON {
units[] = {};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_common"};
author[] = {"Glowbal"};
authorUrl = "";
VERSION_CONFIG;
};
};
class CfgVehicles {
class Logic;
class Module_F: Logic {
class ArgumentsBaseUnits {
};
};
class ACE_Module: Module_F {
class EventHandlers {
init = QUOTE(_this call DFUNC(moduleInit));
};
};
};
#include "CfgEventHandlers.hpp"

@ -0,0 +1,19 @@
/*
* Author: Glowbal
* IV Treatment local callback
*
* Arguments:
* 0: The logic object <OBJECT>
*
*
* Return Value:
* nil
*
* Public: No
*/
#include "script_component.hpp"
if ((_this select 0) isKindOf "Module_F") then {
GVAR(moduleInitCollection) pushback (_this select 0);
};

@ -0,0 +1 @@
#include "\z\ace\addons\modules\script_component.hpp"

@ -0,0 +1,12 @@
#define COMPONENT modules
#include "\z\ace\addons\main\script_mod.hpp"
#ifdef DEBUG_ENABLED_MODULES
#define DEBUG_MODE_FULL
#endif
#ifdef DEBUG_SETTINGS_MODULES
#define DEBUG_SETTINGS DEBUG_SETTINGS_MODULES
#endif
#include "\z\ace\addons\main\script_macros.hpp"