Skip to content

Commit

Permalink
Cleanup using SQFLint (#6485)
Browse files Browse the repository at this point in the history
* Use private
* Fix wrong spacing
* Fix wrong variable being used
* Cleanup empty line after header
* ace_common_fnc_getCountOfItem
* Remove useless _return variable
* Naming
  • Loading branch information
dedmen authored and kymckay committed Aug 2, 2018
1 parent 60a8158 commit 7a0a00e
Show file tree
Hide file tree
Showing 30 changed files with 102 additions and 28 deletions.
1 change: 1 addition & 0 deletions addons/common/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ PREP(fixLoweredRifleAnimation);
PREP(fixPosition);
PREP(getAllDefinedSetVariables);
PREP(getAwakeAnim);
PREP(getCountOfItem);
PREP(getDeathAnim);
PREP(getDefaultAnim);
PREP(getDefinedVariable);
Expand Down
31 changes: 31 additions & 0 deletions addons/common/functions/fnc_getCountOfItem.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include "script_component.hpp"
/*
* Author: Dedmen
* Return how many items of type _itemType the player has in his containers (Uniform, Vest, Backpack)
* Doesn't count assignedItems, weapons, weapon attachments, magazines in weapons
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Classname of item (Case-Sensitive) <STRING>
*
* Return Value:
* Item Count <NUMBER>
*
* Example:
* [bob, "FirstAidKit"] call ace_common_fnc_getCountOfItem
*
* Public: Yes
*/

params ["_unit", "_itemType"];

private _countItemsInContainer = {
(getItemCargo _this) params ["_itemTypes", "_itemCounts"];

private _index = _itemTypes find _itemType;
_itemCounts param [_index, 0]
};

((uniformContainer _unit) call _countItemsInContainer) +
((vestContainer _unit) call _countItemsInContainer) +
((backpackContainer _unit) call _countItemsInContainer)
2 changes: 1 addition & 1 deletion addons/medical/functions/fnc_addDamageToUnit.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "script_component.hpp"
/*
* Author: PabstMirror
* Manually Apply Damage to a unit (can cause lethal damage)
Expand All @@ -21,7 +22,6 @@
*/
// #define DEBUG_MODE_FULL
// #define DEBUG_TESTRESULTS
#include "script_component.hpp"

params [["_unit", objNull, [objNull]], ["_damageToAdd", -1, [0]], ["_bodyPart", "", [""]], ["_typeOfDamage", "", [""]], ["_instigator", objNull, [objNull]]];
TRACE_5("params",_unit,_damageToAdd,_bodyPart,_typeOfDamage,_instigator);
Expand Down
2 changes: 1 addition & 1 deletion addons/medical/functions/fnc_setUnconscious.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "script_component.hpp"
/*
* Author: Glowbal
* Sets a unit in the unconscious state.
Expand All @@ -19,7 +20,6 @@
* Public: yes
*/
// #define DEBUG_MODE_FULL
#include "script_component.hpp"

// only run this after the settings are initialized
if !(EGVAR(common,settingsInitFinished)) exitWith {
Expand Down
1 change: 1 addition & 0 deletions addons/medical_ai/functions/fnc_playTreatmentAnim.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*
* Public: No
*/

params ["_unit", "_isBandage", "_isSelfTreatment"];

if (vehicle _unit != _unit) exitWith {};
Expand Down
1 change: 0 additions & 1 deletion addons/medical_blood/functions/fnc_spurt.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*
* Public: No
*/

#define MAXIMUM_DROPS 4
#define DISTANCE_BETWEEN_DROPS 0.20
#define OFFSET 0.25
Expand Down
1 change: 0 additions & 1 deletion addons/medical_engine/functions/fnc_handleDamage.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
*
* Public: No
*/

// for travis
#define HIT_STRUCTURAL QGVAR($#structural)
#define HIT_CRASH QGVAR($#crash)
Expand Down
1 change: 1 addition & 0 deletions addons/medical_feedback/functions/fnc_effectBleeding.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Return Value:
* None
*/

params ["_enable", "_bloodloss"];
if (isNull findDisplay 46) exitWith {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Return Value:
* None
*/

params ["_enable", "_intensity"];

if ((!_enable) || {_intensity == 0}) exitWith {
Expand Down
1 change: 1 addition & 0 deletions addons/medical_feedback/functions/fnc_effectHeartBeat.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* Return Value:
* None
*/

params ["_heartRate"];

if (_heartRate == 0) exitWith {
Expand Down
1 change: 1 addition & 0 deletions addons/medical_feedback/functions/fnc_effectPain.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Return Value:
* None
*/

params ["_enable", "_intensity"];

if (!_enable || {_intensity == 0}) exitWith {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Return Value:
* None
*/

params ["_enable", "_mode"];

switch (_mode) do {
Expand Down
1 change: 0 additions & 1 deletion addons/medical_feedback/functions/fnc_playInjuredSound.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*
* Public: No
*/

#define TIME_OUT_HIT 1
#define TIME_OUT_MOAN 5

Expand Down
6 changes: 3 additions & 3 deletions addons/medical_gui/functions/fnc_handleUI_DisplayOptions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private _display = uiNamespace getVariable QGVAR(medicalMenu);
if (isNil "_display") exitWith {}; // no valid dialog present

if (_name isEqualTo "toggle") exitWith {
_newTarget = ACE_player;
private _newTarget = ACE_player;
//If we are on the player, and only if our old target is still valid, switch to it:
if ((GVAR(INTERACTION_TARGET) == ACE_player) &&
{[ACE_player, GVAR(INTERACTION_TARGET_PREVIOUS), ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)} &&
Expand Down Expand Up @@ -89,12 +89,12 @@ if (_name isEqualTo "triage") exitWith {

ctrlEnable [212, false];

_entries = [ACE_player, GVAR(INTERACTION_TARGET), _name] call FUNC(getTreatmentOptions);
private _entries = [ACE_player, GVAR(INTERACTION_TARGET), _name] call FUNC(getTreatmentOptions);

{
//player sidechat format["TRIGGERED: %1",_x];
if (_forEachIndex > END_IDC) exitWith {};
_ctrl = (_display displayCtrl (START_IDC + _forEachIndex));
private _ctrl = (_display displayCtrl (START_IDC + _forEachIndex));
if (!(_forEachIndex > AMOUNT_OF_ENTRIES)) then {
_ctrl ctrlSetText (_x select 0);
private _code = format ["ace_medical_menu_pendingReopen = true; call %1;", (_x select 3)];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*
* Public: No
*/

params ["_unit"];

private _startTime = _unit getVariable [QGVAR(cardiacArrestStart), CBA_missionTime];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*
* Public: No
*/

params ["_unit"];

(GVAR(fatalInjuryCondition) < 2) && {!(_unit getVariable [QGVAR(deathBlocked), false])}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*
* Public: No
*/

params ["_unit"];

[QEGVAR(medical,FatalInjuryInstantTransition), _unit] call CBA_fnc_localEvent;
15 changes: 13 additions & 2 deletions addons/medical_statemachine/functions/fnc_handleStateDefault.sqf
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@

#include "script_component.hpp"
/*
* Author: BaerMitUmlaut
*
*
* Arguments:
* 0: The Unit <OBJECT>
*
* Return Value:
* None
*
* Public: No
*/

params ["_unit", "_stateName"];
params ["_unit"];

// If the unit died the loop is finished
if (!alive _unit) exitWith {};
Expand Down
16 changes: 13 additions & 3 deletions addons/medical_statemachine/functions/fnc_handleStateInjured.sqf
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@

#include "script_component.hpp"
/*
* Author: BaerMitUmlaut
*
*
* Arguments:
* 0: The Unit <OBJECT>
*
* Return Value:
* None
*
* Public: No
*/

params ["_unit", "_stateName"];
params ["_unit"];

// If the unit died the loop is finished
if (!alive _unit) exitWith {};
Expand All @@ -19,4 +30,3 @@ private _painLevel = GET_PAIN_PERCEIVED(_unit);
if (_painLevel > 0) then {
[QEGVAR(medical,moan), [_unit, _painLevel]] call CBA_fnc_localEvent;
};

Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@

#include "script_component.hpp"
/*
* Author: BaerMitUmlaut
*
*
* Arguments:
* 0: The Unit <OBJECT>
*
* Return Value:
* None
*
* Public: No
*/

params ["_unit", "_stateName"];
params ["_unit"];

// If the unit died the loop is finished
if (!alive _unit) exitWith {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*
* Public: No
*/

params ["_unit"];

_unit setVariable [QEGVAR(medical,deathBlocked), true];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* Return Value:
* None
*/

params ["_unit", "_change", "_timeToMaxEffect", "_maxTimeInSystem"];

private _adjustments = _unit getVariable [VAR_HEART_RATE_ADJ,[]];
Expand Down
2 changes: 1 addition & 1 deletion addons/medical_treatment/functions/fnc_bodyCleanupLoop.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* None
*
* Example:
* call ACE_medical_fnc_bodyCleanupLoop
* call ACE_medical_treatment_fnc_bodyCleanupLoop
*
* Public: No
*/
Expand Down
4 changes: 2 additions & 2 deletions addons/medical_treatment/functions/fnc_checkItems.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

params ["_unit"];

private _countFirstAidKit = {_x == "FirstAidKit"} count items _unit;
private _countFirstAidKit = [_unit, "FirstAidKit"] call EFUNC(common,getCountOfItem);
_unit removeItems "FirstAidKit";

private _countMedikit = {_x == "Medikit"} count items _unit;
private _countMedikit = [_unit, "Medikit"] call EFUNC(common,getCountOfItem);
_unit removeItems "Medikit";

for "_i" from 1 to _countFirstAidKit do {
Expand Down
11 changes: 6 additions & 5 deletions addons/medical_treatment/functions/fnc_getTriageStatus.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
* Public: Yes
*/

private ["_unit","_return","_status"];
params ["_unit"];
_status = _unit getVariable [QEGVAR(medical,triageLevel), -1];
_return = switch (_status) do {

private _status = _unit getVariable [QEGVAR(medical,triageLevel), -1];

//return
switch (_status) do {
case 1: {[localize ELSTRING(medical_treatment,Triage_Status_Minor), 1, [0, 0.5, 0, 0.9]]};
case 2: {[localize ELSTRING(medical_treatment,Triage_Status_Delayed), 2, [0.7, 0.5, 0, 0.9]]};
case 3: {[localize ELSTRING(medical_treatment,Triage_Status_Immediate), 3, [0.4, 0.07, 0.07, 0.9]]};
case 4: {[localize ELSTRING(medical_treatment,Triage_Status_Deceased), 4, [0, 0, 0, 0.9]]};
default {[localize ELSTRING(medical_treatment,Triage_Status_None), 0, [0, 0, 0, 0.9]]};
};
_return
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

params ["_unit"];

private _vehicle = vehicle _unit;

if (_unit == _vehicle) exitWith {false};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* None
*
* Example:
* call ACE_medical_fnc_litterCleanupLoop
* call ACE_medical_treatment_fnc_litterCleanupLoop
*
* Public: No
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* None
*
* Example:
* [cursorTarget] call ace_medical_fnc_serverRemoveBody
* [cursorTarget] call ace_medical_treatment_fnc_serverRemoveBody
*
* Public: No
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ params ["_target"];

if (!alive _target) exitWith {};

_unit setVariable [VAR_PAIN, 0, true];
_unit setVariable [VAR_BLOOD_VOL, DEFAULT_BLOOD_VOLUME, true];
_target setVariable [VAR_PAIN, 0, true];
_target setVariable [VAR_BLOOD_VOL, DEFAULT_BLOOD_VOLUME, true];

// tourniquets
_target setVariable [VAR_TOURNIQUET, DEFAULT_TOURNIQUET_VALUES, true];
Expand Down
2 changes: 1 addition & 1 deletion addons/medical_vitals/functions/fnc_handleUnitVitals.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "script_component.hpp"
/*
* Author: Glowbal
* Updates the vitals. Called from the statemachine's onState functions.
Expand All @@ -14,7 +15,6 @@
* Public: No
*/
// #define DEBUG_MODE_FULL
#include "script_component.hpp"

params ["_unit"];

Expand Down

0 comments on commit 7a0a00e

Please sign in to comment.