Fix cheat handling

This adds keydown handler for chat, map, and diary displays.
Additionally, this can be used to handle malicious chat input without a
delay by modifying the associated compile
This commit is contained in:
icomrade
2016-09-02 19:14:21 -04:00
parent 7be75c4674
commit d1d5fe54f3
50 changed files with 72 additions and 63 deletions

View File

@@ -1,5 +1,6 @@
class RscDisplayMainMap
{
onKeyDown = "if (!isNil 'DZE_FilterCheats') then {_this call DZE_FilterCheats;}; false";
class controls
{
delete CA_MainBackground;

View File

@@ -20,6 +20,7 @@ class IGUIBack;
class RscListBox;
class RscIGUIListBox;
class RscHTML;
class RscDisplayEmpty;
#include "CfgPlayerStats\defines.hpp"
#include "CfgPlayerStats\p__cover.hpp"
@@ -31,6 +32,19 @@ class RscHTML;
#include "CfgPlayerStats\p_murders.hpp"
#include "CfgPlayerStats\sound.hpp"
class RscDisplayMission: RscDisplayEmpty
{
access = 0;
idd = 46;
onKeyDown = "if (!isNil 'DZ_KeyDown_EH') then {_this call DZ_KeyDown_EH;};"; //assigned much quicker than executing keyDown.sqf
};
class RscDisplayChat
{
idd = 24;
onKeyDown = "if (!isNil 'DZE_FilterCheats') then {_this call DZE_FilterCheats;}; false";
class controls;
};
class RscPictureGUI
{
access = 0;
@@ -280,6 +294,7 @@ class RscDisplayMain : RscStandardDisplay
class RscDisplayDiary {
idd = 129;
movingEnable = 0;
onKeyDown = "if (!isNil 'DZE_FilterCheats') then {_this call DZE_FilterCheats;}; false";
class Controls {
delete Diary;

View File

@@ -347,25 +347,15 @@ if (isNil "keyboard_keys") then {
DIK_F3,DIK_F2,DIK_9,
DIK_8,DIK_7,DIK_6,DIK_5,DIK_4], _block] call _addArray;
(findDisplay 46) displayRemoveAllEventHandlers "KeyUp";
(findDisplay 46) displayRemoveAllEventHandlers "KeyDown";
(findDisplay 46) displayAddEventHandler ["KeyDown", preprocessFileLineNumbers (MISSION_ROOT+'keyboard.sqf')];
//(findDisplay 46) displayRemoveAllEventHandlers "KeyUp";
//(findDisplay 46) displayRemoveAllEventHandlers "KeyDown";
//(findDisplay 46) displayAddEventHandler ["KeyDown", preprocessFileLineNumbers (MISSION_ROOT+'keyboard.sqf')];
if (!isNil "bis_fnc_halo_keydown_eh") then {bis_fnc_halo_keydown_eh = (finddisplay 46) displayaddeventhandler ["keydown","_this call bis_fnc_halo_keydown;"];}; // halo in progress
//diag_log [diag_ticktime, __FILE__, "eh reset" ];
};
if (_dikCode == DIK_NUMPADMINUS && _shiftState) then {
call player_forceSave;
disableUserInput true;disableUserInput true;
[] spawn { //disable input, this is unfortunately the only way to stop cheat input
titleText ["DO NOT ENTER CHEATS, WAIT 5 SECONDS TO CONTINUE!", "PLAIN", 1];
uiSleep 5;
if (!r_player_unconsciousInputDisabled) then {
//weird disableuserInput behavior, enable input, disable and reenable to prevent the last key press being input after re-enable
disableUserInput false;disableUserInput true;disableUserInput false;disableUserInput false;
};
};
};
_this call DZE_FilterCheats;
if (r_player_unconsciousInputDisabled) exitWith {true};
_code = keyboard_keys select _dikCode;
if (!isNil "_code") then {

View File

@@ -633,6 +633,28 @@ local_spawnObjects = compile preprocessFileLineNumbers "\z\addons\dayz_code\comp
FNC_GetSetPos = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fnc_getSetPos.sqf";
FNC_GetPos = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fnc_getPos.sqf";
dayz_EjectPlayer = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\dze_ejectPlayer.sqf";
DZ_KeyDown_EH = compile preprocessFileLineNumbers (MISSION_ROOT+'keyboard.sqf');
DZE_FilterCheats = {
#define DIK_SUBTRACT 0x4A
#define DIK_NUMPADMINUS DIK_SUBTRACT
_dik = _this select 1;
_shift = _this select 2;
if (_dik == DIK_NUMPADMINUS && _shift) then {
call player_forceSave;
disableUserInput true;disableUserInput true;
[] spawn { //disable input, this is unfortunately the only way to stop cheat input
_testTime = diag_tickTime;
CheatsDisabled = _testTime;
titleText ["DO NOT ENTER CHEATS, WAIT 5 SECONDS TO CONTINUE!", "PLAIN", 1];
uiSleep 5;
if (!r_player_unconsciousInputDisabled && CheatsDisabled == _testTime) then {
//weird disableuserInput behavior, enable input, disable and reenable to prevent the last key press being input after re-enable
disableUserInput false;disableUserInput true;disableUserInput false;disableUserInput false;
};
};
};
};
player_sumMedical = {
private["_character","_wounds","_legs","_arms","_medical","_status"];
@@ -668,11 +690,11 @@ player_sumMedical = {
_medical
};
init_keyboard = {
/* init_keyboard = { //in Epoch we handle keypresses via config onKeyDown entries.
waituntil {!(isNull (findDisplay 46))};
keyboard_keys = nil;
[controlNull, 1, false,false,false] call compile preprocessFileLineNumbers (MISSION_ROOT+'keyboard.sqf');
};
}; */
dayz_reduceItems = {
private ["_item","_class","_amount","_qtyRemaining"];