From e57a6fbb13db4d1b4d66be3b752de995a36430ce Mon Sep 17 00:00:00 2001 From: mharis001 Date: Fri, 26 Apr 2019 15:35:12 -0400 Subject: [PATCH] Fixes and code review changes --- addons/medical_engine/script_macros_medical.hpp | 6 ++++-- .../functions/fnc_displayPatientInformation.sqf | 2 +- addons/medical_gui/functions/fnc_menuPFH.sqf | 4 ++-- .../medical_gui/functions/fnc_updateLogList.sqf | 4 ++-- .../medical_treatment/ACE_Medical_Treatment.hpp | 10 +++++----- .../functions/fnc_addToLog.sqf | 4 ++-- .../functions/fnc_canTreat.sqf | 8 +------- .../functions/fnc_checkBloodPressureLocal.sqf | 12 ++++++------ .../functions/fnc_checkPulseLocal.sqf | 12 ++++++------ .../functions/fnc_hasTourniquetAppliedTo.sqf | 2 +- .../functions/fnc_medicationLocal.sqf | 4 ++-- .../functions/fnc_onMedicationUsage.sqf | 8 ++++---- .../functions/fnc_treatment.sqf | 17 +++++------------ addons/medical_treatment/script_component.hpp | 4 +--- 14 files changed, 42 insertions(+), 55 deletions(-) diff --git a/addons/medical_engine/script_macros_medical.hpp b/addons/medical_engine/script_macros_medical.hpp index ef55cb2375..7c720a9a64 100644 --- a/addons/medical_engine/script_macros_medical.hpp +++ b/addons/medical_engine/script_macros_medical.hpp @@ -2,7 +2,6 @@ #define DISABLE_COMPILE_CACHE #define ENABLE_PERFORMANCE_COUNTERS - #define ALL_BODY_PARTS ["head", "body", "leftarm", "rightarm", "leftleg", "rightleg"] #define ALL_SELECTIONS ["head", "body", "hand_l", "hand_r", "leg_l", "leg_r"] #define ALL_HITPOINTS ["HitHead", "HitBody", "HitLeftArm", "HitRightArm", "HitLeftLeg", "HitRightLeg"] @@ -110,6 +109,10 @@ #define TRIAGE_TEXT_COLOR_IMMEDIATE 1, 1, 1, 1 #define TRIAGE_TEXT_COLOR_DECEASED 1, 1, 1, 1 +// Medical activity logs +#define MED_LOG_MAX_ENTRIES 8 +#define MED_LOG_VARNAME(type) (format [QEGVAR(medical,log_%1), type]) + // - Unit Variables ---------------------------------------------------- // These variables get stored in object space and used across components // Defined here for easy consistency with GETVAR/SETVAR (also a list for reference) @@ -129,7 +132,6 @@ #define VAR_IN_PAIN QEGVAR(medical,inPain) #define VAR_TOURNIQUET QEGVAR(medical,tourniquets) - // - Unit Functions --------------------------------------------------- // Retrieval macros for common unit values // Defined for easy consistency and speed diff --git a/addons/medical_gui/functions/fnc_displayPatientInformation.sqf b/addons/medical_gui/functions/fnc_displayPatientInformation.sqf index 25f87f93ce..ac76d34012 100644 --- a/addons/medical_gui/functions/fnc_displayPatientInformation.sqf +++ b/addons/medical_gui/functions/fnc_displayPatientInformation.sqf @@ -53,7 +53,7 @@ if (isNull _display) then { // Update activity log private _ctrlActivityLog = _display displayCtrl IDC_ACTIVITY; - private _activityLog = _target getVariable [QEGVAR(medical,logFile_activity_view), []]; + private _activityLog = _target getVariable [MED_LOG_VARNAME("activity"), []]; [_ctrlActivityLog, _activityLog] call FUNC(updateLogList); // Update triage status diff --git a/addons/medical_gui/functions/fnc_menuPFH.sqf b/addons/medical_gui/functions/fnc_menuPFH.sqf index 9d24ffd6d3..2a12ede13c 100644 --- a/addons/medical_gui/functions/fnc_menuPFH.sqf +++ b/addons/medical_gui/functions/fnc_menuPFH.sqf @@ -44,11 +44,11 @@ private _ctrlBodyImage = _display displayCtrl IDC_BODY_GROUP; // Update activity and quick view logs private _ctrlActivityLog = _display displayCtrl IDC_ACTIVITY; -private _activityLog = GVAR(target) getVariable [QEGVAR(medical,logFile_activity_view), []]; +private _activityLog = GVAR(target) getVariable [MED_LOG_VARNAME("activity"), []]; [_ctrlActivityLog, _activityLog] call FUNC(updateLogList); private _ctrlQuickView = _display displayCtrl IDC_QUICKVIEW; -private _quickView = GVAR(target) getVariable [QEGVAR(medical,logFile_quick_view), []]; +private _quickView = GVAR(target) getVariable [MED_LOG_VARNAME("quick_view"), []]; [_ctrlQuickView, _quickView] call FUNC(updateLogList); // Update triage status diff --git a/addons/medical_gui/functions/fnc_updateLogList.sqf b/addons/medical_gui/functions/fnc_updateLogList.sqf index 731b358796..fb83640698 100644 --- a/addons/medical_gui/functions/fnc_updateLogList.sqf +++ b/addons/medical_gui/functions/fnc_updateLogList.sqf @@ -21,7 +21,7 @@ params ["_ctrl", "_logs"]; lbClear _ctrl; { - _x params ["_message", "_moment", "", "_arguments"]; + _x params ["_message", "_timeStamp", "_arguments"]; // Localize message and arguments if (isLocalized _message) then { @@ -33,5 +33,5 @@ lbClear _ctrl; // Format message with arguments _message = format ([_message] + _arguments); - _ctrl lbAdd format ["%1 %2", _moment, _message]; + _ctrl lbAdd format ["%1 %2", _timeStamp, _message]; } forEach _logs; diff --git a/addons/medical_treatment/ACE_Medical_Treatment.hpp b/addons/medical_treatment/ACE_Medical_Treatment.hpp index d09713f0d2..19181287a8 100644 --- a/addons/medical_treatment/ACE_Medical_Treatment.hpp +++ b/addons/medical_treatment/ACE_Medical_Treatment.hpp @@ -582,7 +582,7 @@ class ADDON { timeInSystem = 1800; timeTillMaxEffect = 30; maxDose = 4; - incompatableMedication[] = {}; + incompatibleMedication[] = {}; viscosityChange = -10; }; class Epinephrine { @@ -593,7 +593,7 @@ class ADDON { timeInSystem = 120; timeTillMaxEffect = 10; maxDose = 10; - incompatableMedication[] = {}; + incompatibleMedication[] = {}; }; class Adenosine { painReduce = 0; @@ -603,7 +603,7 @@ class ADDON { timeInSystem = 120; timeTillMaxEffect = 15; maxDose = 6; - incompatableMedication[] = {}; + incompatibleMedication[] = {}; }; class Atropine { painReduce = 0; @@ -613,14 +613,14 @@ class ADDON { timeInSystem = 120; timeTillMaxEffect = 15; maxDose = 6; - incompatableMedication[] = {}; + incompatibleMedication[] = {}; }; class PainKillers { painReduce = 0.1; timeInSystem = 600; timeTillMaxEffect = 60; maxDose = 10; - incompatableMedication[] = {}; + incompatibleMedication[] = {}; viscosityChange = 5; }; }; diff --git a/addons/medical_treatment/functions/fnc_addToLog.sqf b/addons/medical_treatment/functions/fnc_addToLog.sqf index 917b9fbb72..b250fec9b1 100644 --- a/addons/medical_treatment/functions/fnc_addToLog.sqf +++ b/addons/medical_treatment/functions/fnc_addToLog.sqf @@ -27,10 +27,10 @@ if (!local _unit) exitWith { date params ["", "", "", "_hour", "_minute"]; private _timeStamp = format ["%1:%2", _hour, [_minute, 2] call CBA_fnc_formatNumber]; -private _logVarName = LOG_VARNAME(_logType); +private _logVarName = MED_LOG_VARNAME(_logType); private _log = _unit getVariable [_logVarName, []]; -if (count _log >= MAX_LOG_ENTRIES) then { +if (count _log >= MED_LOG_MAX_ENTRIES) then { _log deleteAt 0; }; diff --git a/addons/medical_treatment/functions/fnc_canTreat.sqf b/addons/medical_treatment/functions/fnc_canTreat.sqf index 2d4be68283..efb7778f09 100644 --- a/addons/medical_treatment/functions/fnc_canTreat.sqf +++ b/addons/medical_treatment/functions/fnc_canTreat.sqf @@ -33,13 +33,7 @@ isClass _config private _items = getArray (_config >> "items"); _items isEqualTo [] || {[_medic, _patient, _items] call FUNC(hasItem)} } && { - private _condition = getText (_config >> "condition"); - - if (isNil _condition) then { - _condition = compile _condition; - } else { - _condition = missionNamespace getVariable _condition; - }; + GET_FUNCTION(_condition,_config >> "condition"); if (_condition isEqualType {}) then { _condition = call _condition; diff --git a/addons/medical_treatment/functions/fnc_checkBloodPressureLocal.sqf b/addons/medical_treatment/functions/fnc_checkBloodPressureLocal.sqf index 87bff6aac5..5da7495f74 100644 --- a/addons/medical_treatment/functions/fnc_checkBloodPressureLocal.sqf +++ b/addons/medical_treatment/functions/fnc_checkBloodPressureLocal.sqf @@ -26,32 +26,32 @@ if (alive _patient && {!([_patient, _bodyPart] call FUNC(hasTourniquetAppliedTo) }; private _bloodPressureOutput = LSTRING(Check_Bloodpressure_Output_6); -private _logOutPut = LSTRING(Check_Bloodpressure_NoBloodpressure); +private _logOutput = LSTRING(Check_Bloodpressure_NoBloodpressure); _bloodPressure params ["_bloodPressureLow", "_bloodPressureHigh"]; if (_bloodPressureHigh > 20) then { if (_medic call FUNC(isMedic)) then { _bloodPressureOutput = LSTRING(Check_Bloodpressure_Output_1); - _logOutPut = format ["%1/%2", round _bloodPressureHigh, round _bloodPressureLow]; + _logOutput = format ["%1/%2", round _bloodPressureHigh, round _bloodPressureLow]; } else { if (_bloodPressureHigh > 20) then { _bloodPressureOutput = LSTRING(Check_Bloodpressure_Output_2); - _logOutPut = LSTRING(Check_Bloodpressure_Low); + _logOutput = LSTRING(Check_Bloodpressure_Low); if (_bloodPressureHigh > 100) then { _bloodPressureOutput = LSTRING(Check_Bloodpressure_Output_3); - _logOutPut = LSTRING(Check_Bloodpressure_Normal); + _logOutput = LSTRING(Check_Bloodpressure_Normal); if (_bloodPressureHigh > 160) then { _bloodPressureOutput = LSTRING(Check_Bloodpressure_Output_4); - _logOutPut = LSTRING(Check_Bloodpressure_High); + _logOutput = LSTRING(Check_Bloodpressure_High); }; }; }; }; }; -[_patient, "quick_view", LSTRING(Check_Bloodpressure_Log), [_medic call EFUNC(common,getName), _logOutPut]] call FUNC(addToLog); +[_patient, "quick_view", LSTRING(Check_Bloodpressure_Log), [_medic call EFUNC(common,getName), _logOutput]] call FUNC(addToLog); [QEGVAR(common,displayTextStructured), [[_bloodPressureOutput, _patient call EFUNC(common,getName), round _bloodPressureHigh, round _bloodPressureLow], 1.75, _medic], _medic] call CBA_fnc_targetEvent; diff --git a/addons/medical_treatment/functions/fnc_checkPulseLocal.sqf b/addons/medical_treatment/functions/fnc_checkPulseLocal.sqf index ad574e73a0..f386fa2c89 100644 --- a/addons/medical_treatment/functions/fnc_checkPulseLocal.sqf +++ b/addons/medical_treatment/functions/fnc_checkPulseLocal.sqf @@ -26,28 +26,28 @@ if (alive _patient && {!([_patient, _bodyPart] call FUNC(hasTourniquetAppliedTo) }; private _heartRateOutput = LSTRING(Check_Pulse_Output_5); -private _logOutPut = LSTRING(Check_Pulse_None); +private _logOutput = LSTRING(Check_Pulse_None); if (_heartRate > 1) then { if (_medic call FUNC(isMedic)) then { _heartRateOutput = LSTRING(Check_Pulse_Output_1); - _logOutPut = format ["%1", round _heartRate]; + _logOutput = format ["%1", round _heartRate]; } else { _heartRateOutput = LSTRING(Check_Pulse_Output_2); - _logOutPut = LSTRING(Check_Pulse_Weak); + _logOutput = LSTRING(Check_Pulse_Weak); if (_heartRate > 60) then { if (_heartRate > 100) then { _heartRateOutput = LSTRING(Check_Pulse_Output_3); - _logOutPut = LSTRING(Check_Pulse_Strong); + _logOutput = LSTRING(Check_Pulse_Strong); } else { _heartRateOutput = LSTRING(Check_Pulse_Output_4); - _logOutPut = LSTRING(Check_Pulse_Normal); + _logOutput = LSTRING(Check_Pulse_Normal); }; }; }; }; -[_patient, "quick_view", LSTRING(Check_Pulse_Log), [_medic call EFUNC(common,getName), _logOutPut]] call FUNC(addToLog); +[_patient, "quick_view", LSTRING(Check_Pulse_Log), [_medic call EFUNC(common,getName), _logOutput]] call FUNC(addToLog); [QEGVAR(common,displayTextStructured), [[_heartRateOutput, _patient call EFUNC(common,getName), round _heartRate], 1.5, _medic], _medic] call CBA_fnc_targetEvent; diff --git a/addons/medical_treatment/functions/fnc_hasTourniquetAppliedTo.sqf b/addons/medical_treatment/functions/fnc_hasTourniquetAppliedTo.sqf index a2a103432d..c8d2aa8e7b 100644 --- a/addons/medical_treatment/functions/fnc_hasTourniquetAppliedTo.sqf +++ b/addons/medical_treatment/functions/fnc_hasTourniquetAppliedTo.sqf @@ -8,7 +8,7 @@ * 1: Body Part * * Return Value: - * Has Tourniquet Applied + * Has Tourniquet Been Applied * * Example: * [player, "leftleg"] call ace_medical_treatment_fnc_hasTourniquetAppliedTo diff --git a/addons/medical_treatment/functions/fnc_medicationLocal.sqf b/addons/medical_treatment/functions/fnc_medicationLocal.sqf index 6a0fce8842..30b64860e6 100644 --- a/addons/medical_treatment/functions/fnc_medicationLocal.sqf +++ b/addons/medical_treatment/functions/fnc_medicationLocal.sqf @@ -63,7 +63,7 @@ private _viscosityChange = GET_NUMBER(_medicationConfig >> "viscosityChan private _hrIncreaseLow = GET_ARRAY(_medicationConfig >> "hrIncreaseLow",getArray (_defaultConfig >> "hrIncreaseLow")); private _hrIncreaseNormal = GET_ARRAY(_medicationConfig >> "hrIncreaseNormal",getArray (_defaultConfig >> "hrIncreaseNormal")); private _hrIncreaseHigh = GET_ARRAY(_medicationConfig >> "hrIncreaseHigh",getArray (_defaultConfig >> "hrIncreaseHigh")); -private _incompatableMedication = GET_ARRAY(_medicationConfig >> "incompatableMedication",getArray (_defaultConfig >> "incompatableMedication")); +private _incompatibleMedication = GET_ARRAY(_medicationConfig >> "incompatibleMedication",getArray (_defaultConfig >> "incompatibleMedication")); private _heartRate = GET_HEART_RATE(_patient); private _hrIncrease = [_hrIncreaseLow, _hrIncreaseNormal, _hrIncreaseHigh] select (floor ((0 max _heartRate min 110) / 55)); @@ -75,4 +75,4 @@ TRACE_3("adjustments",_heartRateChange,_painReduce,_viscosityChange); [_patient, _className, _timeTillMaxEffect, _timeInSystem, _heartRateChange, _painReduce, _viscosityChange] call EFUNC(medical_status,addMedicationAdjustment); // Check for medication compatiblity -[_patient, _className, _maxDose, _incompatableMedication] call FUNC(onMedicationUsage); +[_patient, _className, _maxDose, _incompatibleMedication] call FUNC(onMedicationUsage); diff --git a/addons/medical_treatment/functions/fnc_onMedicationUsage.sqf b/addons/medical_treatment/functions/fnc_onMedicationUsage.sqf index 219ad444cd..9784acb1ab 100644 --- a/addons/medical_treatment/functions/fnc_onMedicationUsage.sqf +++ b/addons/medical_treatment/functions/fnc_onMedicationUsage.sqf @@ -18,8 +18,8 @@ * Public: No */ -params ["_target", "_className", "_maxDosage", "_incompatabileMeds"]; -TRACE_4("onMedicationUsage",_target,_className,_maxDosage,_incompatabileMeds); +params ["_target", "_className", "_maxDosage", "_incompatibleMedication"]; +TRACE_4("onMedicationUsage",_target,_className,_maxDosage,_incompatibleMedication); private _fnc_getMedicationCount = { params ["_target", "_medication"]; @@ -51,9 +51,9 @@ if (_currentDose >= floor (_maxDosage + round(random(2))) && {_maxDosage >= 1}) if (_inSystem> _xLimit) then { _overdosedMedications pushBackUnique _xMed; }; -} forEach _incompatabileMeds; +} forEach _incompatibleMedication; -if ((count _overdosedMedications) > 0) then { +if !(_overdosedMedications isEqualTo []) then { private _medicationConfig = (configFile >> "ace_medical_treatment" >> "Medication"); private _onOverDose = getText (_medicationConfig >> "onOverDose"); if (isClass (_medicationConfig >> _className)) then { diff --git a/addons/medical_treatment/functions/fnc_treatment.sqf b/addons/medical_treatment/functions/fnc_treatment.sqf index 12a4f7c298..c16fd5ef77 100644 --- a/addons/medical_treatment/functions/fnc_treatment.sqf +++ b/addons/medical_treatment/functions/fnc_treatment.sqf @@ -30,23 +30,16 @@ if !(_this call FUNC(canTreat)) exitWith {false}; private _config = configFile >> QGVAR(actions) >> _classname; // Get treatment time from config, exit if treatment time is zero -// Supports number config entries and string entries of code or missionNamespace variables -private _treatmentTime = 0; - -if (isText (_config >> "treatmentTime")) then { - _treatmentTime = getText (_config >> "treatmentTime"); - - if (isNil _treatmentTime) then { - _treatmentTime = compile _treatmentTime; - } else { - _treatmentTime = missionNamespace getVariable _treatmentTime; - }; +private _treatmentTime = if (isText (_config >> "treatmentTime")) then { + GET_FUNCTION(_treatmentTime,_config >> "treatmentTime"); if (_treatmentTime isEqualType {}) then { _treatmentTime = call _treatmentTime; }; + + _treatmentTime } else { - _treatmentTime = getNumber (_config >> "treatmentTime"); + getNumber (_config >> "treatmentTime"); }; if (_treatmentTime == 0) exitWith {false}; diff --git a/addons/medical_treatment/script_component.hpp b/addons/medical_treatment/script_component.hpp index 61cb53fcb7..4343c04a29 100644 --- a/addons/medical_treatment/script_component.hpp +++ b/addons/medical_treatment/script_component.hpp @@ -17,6 +17,7 @@ #include "\z\ace\addons\medical_engine\script_macros_medical.hpp" #include "\z\ace\addons\main\script_macros.hpp" +// Returns a text config entry as compiled code or variable from missionNamespace #define GET_FUNCTION(var,cfg) \ private var = getText (cfg); \ if (isNil var) then { \ @@ -46,6 +47,3 @@ #define TREATMENT_LOCATIONS_ALL 4 #define LITTER_CLEANUP_CHECK_DELAY 30 - -#define MAX_LOG_ENTRIES 8 -#define LOG_VARNAME(type) (format [QEGVAR(medical,log_%1), type])