Add an input mask for setting of gear messages. Intended for intercepting user messages. This is totally untested. I don't think it should desync but seriously needs a lot of testing. Esp the doPut behaviour.
--- a/hedgewars/uCommandHandlers.pas Mon Dec 13 18:13:42 2010 -0500
+++ b/hedgewars/uCommandHandlers.pas Mon Dec 13 19:00:03 2010 -0500
@@ -155,7 +155,7 @@
if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
bShowFinger:= false;
with CurrentHedgehog^.Gear^ do
- Message:= Message or gmLeft
+ Message:= Message or (gmLeft and InputMask)
end;
procedure chLeft_m(var s: shortstring);
@@ -164,7 +164,7 @@
if CheckNoTeamOrHH then exit;
if not CurrentTeam^.ExtDriven then SendIPC('l');
with CurrentHedgehog^.Gear^ do
- Message:= Message and not gmLeft
+ Message:= Message and not (gmLeft and InputMask)
end;
procedure chRight_p(var s: shortstring);
@@ -175,7 +175,7 @@
if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
bShowFinger:= false;
with CurrentHedgehog^.Gear^ do
- Message:= Message or gmRight
+ Message:= Message or (gmRight and InputMask)
end;
procedure chRight_m(var s: shortstring);
@@ -184,7 +184,7 @@
if CheckNoTeamOrHH then exit;
if not CurrentTeam^.ExtDriven then SendIPC('r');
with CurrentHedgehog^.Gear^ do
- Message:= Message and not gmRight
+ Message:= Message and not (gmRight and InputMask)
end;
procedure chUp_p(var s: shortstring);
@@ -195,7 +195,7 @@
if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
bShowFinger:= false;
with CurrentHedgehog^.Gear^ do
- Message:= Message or gmUp
+ Message:= Message or (gmUp and InputMask)
end;
procedure chUp_m(var s: shortstring);
@@ -204,7 +204,7 @@
if CheckNoTeamOrHH then exit;
if not CurrentTeam^.ExtDriven then SendIPC('u');
with CurrentHedgehog^.Gear^ do
- Message:= Message and not gmUp
+ Message:= Message and not (gmUp and InputMask);
end;
procedure chDown_p(var s: shortstring);
@@ -215,7 +215,7 @@
if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
bShowFinger:= false;
with CurrentHedgehog^.Gear^ do
- Message:= Message or gmDown
+ Message:= Message or (gmDown and InputMask)
end;
procedure chDown_m(var s: shortstring);
@@ -224,7 +224,7 @@
if CheckNoTeamOrHH then exit;
if not CurrentTeam^.ExtDriven then SendIPC('d');
with CurrentHedgehog^.Gear^ do
- Message:= Message and not gmDown
+ Message:= Message and not (gmDown and InputMask)
end;
procedure chPrecise_p(var s: shortstring);
@@ -235,7 +235,7 @@
if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
bShowFinger:= false;
with CurrentHedgehog^.Gear^ do
- Message:= Message or gmPrecise
+ Message:= Message or (gmPrecise and InputMask);
end;
procedure chPrecise_m(var s: shortstring);
@@ -244,7 +244,7 @@
if CheckNoTeamOrHH then exit;
if not CurrentTeam^.ExtDriven then SendIPC('z');
with CurrentHedgehog^.Gear^ do
- Message:= Message and not gmPrecise
+ Message:= Message and not (gmPrecise and InputMask);
end;
procedure chLJump(var s: shortstring);
@@ -255,7 +255,7 @@
if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
bShowFinger:= false;
with CurrentHedgehog^.Gear^ do
- Message:= Message or gmLJump
+ Message:= Message or (gmLJump and InputMask)
end;
procedure chHJump(var s: shortstring);
@@ -266,7 +266,7 @@
if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
bShowFinger:= false;
with CurrentHedgehog^.Gear^ do
- Message:= Message or gmHJump
+ Message:= Message or (gmHJump and InputMask)
end;
procedure chAttack_p(var s: shortstring);
@@ -282,7 +282,7 @@
begin
FollowGear:= CurrentHedgehog^.Gear;
if not CurrentTeam^.ExtDriven then SendIPC('A');
- Message:= Message or gmAttack
+ Message:= Message or (gmAttack and InputMask)
end
end
end;
@@ -295,7 +295,7 @@
begin
if not CurrentTeam^.ExtDriven and
((Message and gmAttack) <> 0) then SendIPC('a');
- Message:= Message and not gmAttack
+ Message:= Message and not (gmAttack and InputMask)
end
end;
@@ -307,7 +307,7 @@
if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
bShowFinger:= false;
with CurrentHedgehog^.Gear^ do
- Message:= Message or gmSwitch
+ Message:= Message or (gmSwitch and InputMask)
end;
procedure chNextTurn(var s: shortstring);
@@ -330,7 +330,7 @@
bShowFinger:= false;
with CurrentHedgehog^.Gear^ do
begin
- Message:= Message or gmTimer;
+ Message:= Message or (gmTimer and InputMask);
MsgParam:= byte(s[1]) - ord('0')
end
end;
@@ -346,7 +346,7 @@
bShowFinger:= false;
with CurrentHedgehog^.Gear^ do
begin
- Message:= Message or gmSlot;
+ Message:= Message or (gmSlot and InputMask);
MsgParam:= slot
end
end;
@@ -361,7 +361,7 @@
with CurrentHedgehog^.Gear^ do
begin
- Message:= Message or gmWeapon;
+ Message:= Message or (gmWeapon and InputMask);
MsgParam:= byte(s[1]);
end;
end;
@@ -376,7 +376,7 @@
with CurrentHedgehog^.Gear^ do
begin
- Message:= Message or gmAnimate;
+ Message:= Message or (gmAnimate and InputMask);
MsgParam:= byte(s[1])
end
end;
--- a/hedgewars/uIO.pas Mon Dec 13 18:13:42 2010 -0500
+++ b/hedgewars/uIO.pas Mon Dec 13 19:00:03 2010 -0500
@@ -405,7 +405,7 @@
{$IFDEF DEBUGFILE}AddFilelog('put: ' + inttostr(TargetPoint.X) + ', ' + inttostr(TargetPoint.Y));{$ENDIF}
State:= State and not gstHHChooseTarget;
if (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AttackingPut) <> 0 then
- Message:= Message or gmAttack;
+ Message:= Message or (gmAttack and InputMask);
end
else
if CurrentTeam^.ExtDriven then
--- a/hedgewars/uScript.pas Mon Dec 13 18:13:42 2010 -0500
+++ b/hedgewars/uScript.pas Mon Dec 13 19:00:03 2010 -0500
@@ -116,6 +116,15 @@
lc_bnot := 1;
end;
+function lc_setinputmask(L : Plua_State) : LongInt; Cdecl;
+var gear : PGear;
+begin
+ if lua_gettop(L) <> 1 then
+ LuaError('Lua: Wrong number of parameters passed to SetInputMask!')
+ else InputMask:= lua_tointeger(L, 1);
+ lc_setinputmask:= 0
+end;
+
function lc_writelntoconsole(L : Plua_State) : LongInt; Cdecl;
begin
if lua_gettop(L) = 1 then
@@ -1417,6 +1426,7 @@
lua_register(luaState, 'band', @lc_band);
lua_register(luaState, 'bor', @lc_bor);
lua_register(luaState, 'bnot', @lc_bnot);
+lua_register(luaState, 'SetInputMask', @lc_setinputmask);
lua_register(luaState, 'AddGear', @lc_addgear);
lua_register(luaState, 'DeleteGear', @lc_deletegear);
lua_register(luaState, 'AddVisualGear', @lc_addvisualgear);
--- a/hedgewars/uVariables.pas Mon Dec 13 18:13:42 2010 -0500
+++ b/hedgewars/uVariables.pas Mon Dec 13 19:00:03 2010 -0500
@@ -43,6 +43,7 @@
GameState : TGameState;
GameType : TGameType;
+ InputMask : LongWord;
GameFlags : Longword;
TrainingFlags : Longword;
TurnTimeLeft : Longword;
@@ -2157,6 +2158,7 @@
cWaterLine := LAND_HEIGHT;
cGearScrEdgesDist := 240;
+ InputMask := $FFFFFFFF;
GameFlags := 0;
TrainingFlags := 0;
TurnTimeLeft := 0;