From cdc5c8a35c600c2bd4e0ff1e0cd49f8ad203eea6 Mon Sep 17 00:00:00 2001 From: Joseph Pearson Date: Tue, 18 Nov 2014 16:38:10 -0600 Subject: [PATCH] -Added error handling for drawing of curator icons -Added check for damage from curator sources such as the howitzer, mortar, or rockets -Added error handling for drawing of player icons --- src/addons/cws_injury.pbo | Bin 178494 -> 178985 bytes .../cws_injury.pbo.chessmaster42.bisign | Bin 566 -> 566 bytes .../functions/common/fn_DrawCuratorIcons.sqf | 71 ++++++++++-------- .../functions/cws/fn_handleDamage.sqf | 15 +++- .../functions/loaders/fn_LoadCWS.sqf | 60 +++++++++------ 5 files changed, 85 insertions(+), 61 deletions(-) diff --git a/src/addons/cws_injury.pbo b/src/addons/cws_injury.pbo index 125906cae5faf9c3283f62bf07be1a033303339e..63aaf62b9b4c32aca793a7a1fba47ba9ca832afd 100644 GIT binary patch delta 4533 zcmZ`+X;2);6@EQj0tA+XWdjCj1Uk5vOG3AdKnKQ%V+E3<0}s2yGGcdzotYIvj=U(U zI3VFTQahe1DK7a)$|0AnOd`su#InnA#T8c)D^A5#iIK2fmBi)psfuGKPAac^c9sRp zKUm)T`n|7TfBkx<=edtFCO^semXcaE8TP)FcUH?wDGTY|CoetNOj7PUtb5nneN;oGa2LD_&j5#6T#fY+xhLuQ9$4j6ES7FWI`WR=kx&u!#DpZVRABsf*hqHru<=&ayowS8L>Ol?Mc86EviK@z-mH`?NYCQa>E0&tmDdx}zS zbO2nm_j#UA68iG!Q0=Yfsxwoj^8gOoTk1|MCaLsfeLg+fTuT4fT%X&f`6EHOSvGi) zil)N%asgQ4j=NL-#Z3Cbjw6gIT$@Ah+}SToyXHn(*_1{<-&sly($%}x92~>t^EIat zFr@(ah7ABkRZO_Xgz;&i5Yo5afp&<`YQV3U6VxQXtQ&By0G)`^%TwNC4r6$*kg?K3 zEi346cV#avW*ID^X`gpjcMCM2-%82u9MZskQ#pMym0AjE!|t5zKV;#4T^eqR=#r`F zEj~>(;1WZ1`KWSK?q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jDajKHgsi5sX3 zgmlK$GKvx&oZ>I*Flip`-Tc9Bc~RsU#DpJ}nL3X+SzIi18h>g60001h000210S!o* zMg(S?zw3^NRQ!`*z7*C9hmz2GS9(P7LqcqF8XM%#B%e|5zO@XhVQmgKfb(rmU<7X2 z)VTU1Lg7+0>WeWp1eaxm)Z_r`T>hCb3Kza$)e?^)gN!0$mK$Xhj4j)u5bEmfwl5b> zfhytU5>pq$ntx3)4X|M58u+s{fB*mhPNpM8B$^O%n1r$Zox?Cgl*nYb8Q`N48ufR~ z(iB6;ojt!XXfXrZeSdZK3-ARFgY{Z4LXh}=eaR#CA@0@%%bNv-$s-6t$liw7DfNr4 zLfQKdHeGXbX1~H_Nj8Crh=^a{S!`g_Zau&?>{5%9O%INsbo{=qQ~ToROT+xriG-KF AtN;K2 delta 406 zcmV;H0crlW1hxc_s(3PD>*Le&*MHPiuU0*w9{lhhso;W`~MQ} zZ^BGoHq&fPQ`J8D{w6TT{G2$#pE^nKAQHq>rQc?!R_jxg0E=c(GWe>CoVnGAj2SW4 zv;yPHH4Z;DU^V{F%!S}p9c2qR0=B<7gMLV&7L5f;biu_(6n_E&0001h0002mn;JAT zjMe*bWF@y!X};K)j0H5Z6~_D!Q$G(ME)}d78;1JzL20~uP|glKa0#QsXK{}4>!EAJp@$Z0uF%K>hSRp-);2e*q+mJ+6>$DPD|Y?8+UD@cFdob8Jol;1 zxfgr|k%ef~8Gk5mJa3mKUym6CfB*mhq51bX_GzmZz0SHaMdprmAHN8`W z0)6Ik%MQ8^ZbQ?++jpg33v_;$C%HZSeM@WgR1P2JomR|;sG}NC6zj A@c;k- diff --git a/src/addons/cws_injury/functions/common/fn_DrawCuratorIcons.sqf b/src/addons/cws_injury/functions/common/fn_DrawCuratorIcons.sqf index 0dc5830..b9e6aa4 100644 --- a/src/addons/cws_injury/functions/common/fn_DrawCuratorIcons.sqf +++ b/src/addons/cws_injury/functions/common/fn_DrawCuratorIcons.sqf @@ -11,42 +11,47 @@ cws_ais_debugging = false; //Iterate through all units in groups { { - if(isNil "_x") then { - //Do nothing - } else { + try { + if(isNil "_x") then { + throw "Unit is nil"; + }; if(isNull _x) then { - //Do nothing - } else { - if(alive _x) then { - if (_x getVariable ["cws_ais_aisInit", false]) then { - //Build the config for the icon - _unitDamage = [_x] call cws_fnc_GetUnitDamage; - _iconColor = [1, 1 - _unitDamage, 1 - _unitDamage, 0.5 + _unitDamage * 0.5]; - _pos = visiblePosition _x; - _pos set [2, (_pos select 2) + 4]; - _icon_size = 0.5; - _angle = 0; - _message = "CWS"; - _text_size = 0.025; - - //Add bleedout time if the unit is in agony - if(_x getVariable ["cws_ais_agony", false]) then { - _life_remaining = _x getVariable ["cws_ais_bleedout_time", 0]; - _message = _message + format[" (%1%2)", ceil (_life_remaining * 100), "%"]; - - //Add healing percentage if the unit is being healed - _healingProgress = _x getVariable ["cws_ais_healing_progress", 0]; - if(_healingProgress > 0) then { - _message = _message + format[" (%1%2)", ceil (_healingProgress * 100), "%"]; - _iconColor = [0, 1, 0, 1]; - }; - }; - - //Draw the icon in 3D space - drawIcon3D["a3\ui_f\data\map\MapControl\hospital_ca.paa", _iconColor, _pos, _icon_size, _icon_size, _angle, _message, 0, _text_size]; - }; + throw "Unit is null"; + }; + if(!alive _x) then { + throw "Unit is dead"; + }; + if (!(_x getVariable ["cws_ais_aisInit", false])) then { + throw "Unit is not running CWS"; + }; + + //Build the config for the icon + _unitDamage = [_x] call cws_fnc_GetUnitDamage; + _iconColor = [1, 1 - _unitDamage, 1 - _unitDamage, 0.5 + _unitDamage * 0.5]; + _pos = visiblePosition _x; + _pos set [2, (_pos select 2) + 4]; + _icon_size = 0.5; + _angle = 0; + _message = "CWS"; + _text_size = 0.025; + + //Add bleedout time if the unit is in agony + if(_x getVariable ["cws_ais_agony", false]) then { + _life_remaining = _x getVariable ["cws_ais_bleedout_time", 0]; + _message = _message + format[" (%1%2)", ceil (_life_remaining * 100), "%"]; + + //Add healing percentage if the unit is being healed + _healingProgress = _x getVariable ["cws_ais_healing_progress", 0]; + if(_healingProgress > 0) then { + _message = _message + format[" (%1%2)", ceil (_healingProgress * 100), "%"]; + _iconColor = [0, 1, 0, 1]; }; }; + + //Draw the icon in 3D space + drawIcon3D["a3\ui_f\data\map\MapControl\hospital_ca.paa", _iconColor, _pos, _icon_size, _icon_size, _angle, _message, 0, _text_size]; + } catch { + //Do nothing }; } forEach units _x; } forEach allGroups; diff --git a/src/addons/cws_injury/functions/cws/fn_handleDamage.sqf b/src/addons/cws_injury/functions/cws/fn_handleDamage.sqf index 25c6a08..f36d1b6 100644 --- a/src/addons/cws_injury/functions/cws/fn_handleDamage.sqf +++ b/src/addons/cws_injury/functions/cws/fn_handleDamage.sqf @@ -15,10 +15,17 @@ if(cws_ais_debugging) then { _scaled_damage = _damage / (cws_ais_rambofactor max 1); _agony = false; -//Stop any damage that doesn't have a source defined -//This is a known bug with HandleDamage EVH -//TODO - Check and see if this is still needed -if(isNull _source) exitWith {0}; +_curatorMunitions = ["ModuleOrdnanceMortar_F_ammo", "ModuleOrdnanceHowitzer_F_ammo", "ModuleOrdnanceRocket_F_Ammo"]; + +//Skip null source check if the ammo is from one of the Curator ordnance types +if(_ammo in _curatorMunitions) then { + //Do nothing +} else { + //Stop any damage that doesn't have a source defined + //This is a known bug with HandleDamage EVH + //TODO - Check and see if this is still needed + if(isNull _source) exitWith {0}; +}; //Skip over the unit if it's not local if(!local _unit) exitWith {0}; diff --git a/src/addons/cws_injury/functions/loaders/fn_LoadCWS.sqf b/src/addons/cws_injury/functions/loaders/fn_LoadCWS.sqf index ed7b460..388be73 100644 --- a/src/addons/cws_injury/functions/loaders/fn_LoadCWS.sqf +++ b/src/addons/cws_injury/functions/loaders/fn_LoadCWS.sqf @@ -101,32 +101,44 @@ if (cws_ais_show_3d_icons && (_unit == player)) then { _playerFaction = side player; { { - if(isNil "_x") then { - //Do nothing - } else { + try { + if(isNil "_x") then { + throw "Unit is nil"; + }; if(isNull _x) then { - //Do nothing - } else { - if(alive _x) then { - if((side _x) == _playerFaction) then { - _distance = ceil (_x distance player); - if (_distance < cws_ais_3d_icon_range && (_x getVariable ["cws_ais_agony", false])) then { - _message = format["%1 (%2m)", name _x, _distance]; - _icon_size = 0.5; - _text_size = 0.025; - _iconColor = [1,0,0,1]; - _pos = visiblePosition _x; - if(_player_is_medic) then { - _life_remaining = _x getVariable "cws_ais_bleedout_time"; - _message = _message + format[" (%1%2)", ceil (_life_remaining * 100), "%"]; - _icon_size = 1.0; - _text_size = 0.05; - }; - drawIcon3D["a3\ui_f\data\map\MapControl\hospital_ca.paa", _iconColor, _pos, _icon_size, _icon_size, 0, _message, 0, _text_size]; - }; - }; - }; + throw "Unit is null"; + }; + if(!alive _x) then { + throw "Unit is dead"; + }; + if (!(_x getVariable ["cws_ais_aisInit", false])) then { + throw "Unit is not running CWS"; + }; + if((side _x) != _playerFaction) then { + throw "Unit not on same side as player"; }; + if(!(_x getVariable ["cws_ais_agony", false])) then { + throw "Unit is not in agony"; + }; + _distance = ceil (_x distance player); + if (_distance >= cws_ais_3d_icon_range) then { + throw "Unit is too far away"; + }; + + _message = format["%1 (%2m)", name _x, _distance]; + _icon_size = 0.5; + _text_size = 0.025; + _iconColor = [1,0,0,1]; + _pos = visiblePosition _x; + if(_player_is_medic) then { + _life_remaining = _x getVariable "cws_ais_bleedout_time"; + _message = _message + format[" (%1%2)", ceil (_life_remaining * 100), "%"]; + _icon_size = 1.0; + _text_size = 0.05; + }; + drawIcon3D["a3\ui_f\data\map\MapControl\hospital_ca.paa", _iconColor, _pos, _icon_size, _icon_size, 0, _message, 0, _text_size]; + } catch { + //Do nothing }; } forEach units _x; } forEach allGroups;