# HG changeset patch # User unc0rr # Date 1379793297 -14400 # Node ID 901e363d5837243f36b9ea4a277f86e42affc727 # Parent 4cbc9a8fd559ff7ed383b7d9e42ce543550c1a63 Finish rework of default binds system. Default binds now work even before first turn. diff -r 4cbc9a8fd559 -r 901e363d5837 hedgewars/hwengine.pas --- a/hedgewars/hwengine.pas Sat Sep 21 22:32:01 2013 +0400 +++ b/hedgewars/hwengine.pas Sat Sep 21 23:54:57 2013 +0400 @@ -71,6 +71,7 @@ end; gsStart: begin + SetDefaultBinds; if HasBorder then DisableSomeWeapons; AddClouds; diff -r 4cbc9a8fd559 -r 901e363d5837 hedgewars/uInputHandler.pas --- a/hedgewars/uInputHandler.pas Sat Sep 21 22:32:01 2013 +0400 +++ b/hedgewars/uInputHandler.pas Sat Sep 21 23:54:57 2013 +0400 @@ -314,8 +314,6 @@ DefaultBinds[KeyNameToCode('j0a1d')]:= '+down'; for i:= 1 to 10 do DefaultBinds[KeyNameToCode('f'+IntToStr(i))]:= 'slot '+IntToStr(i); for i:= 1 to 5 do DefaultBinds[KeyNameToCode(IntToStr(i))]:= 'timer '+IntToStr(i); - -SetDefaultBinds(); end; procedure SetBinds(var binds: TBinds); diff -r 4cbc9a8fd559 -r 901e363d5837 hedgewars/uTeams.pas --- a/hedgewars/uTeams.pas Sat Sep 21 22:32:01 2013 +0400 +++ b/hedgewars/uTeams.pas Sat Sep 21 23:54:57 2013 +0400 @@ -363,7 +363,7 @@ inc(TeamsCount); for t:= 0 to cKbdMaxIndex do - team^.Binds[t]:= ''; + team^.Binds[t]:= DefaultBinds[t]; c:= Pred(ClansCount); while (c >= 0) and (ClansArray[c]^.Color <> TeamColor) do dec(c); @@ -607,7 +607,7 @@ inc(i, 3) end; end; - + if i < length(l) then begin l:= copy(l, i + 1, length(l) - i); @@ -618,7 +618,7 @@ end end end; - + pfsClose(f) end end; @@ -666,7 +666,7 @@ procedure chBind(var id: shortstring); var KeyName, Modifier, tmp: shortstring; - b: LongInt; + i, b: LongInt; begin KeyName:= ''; Modifier:= ''; @@ -691,7 +691,17 @@ if b = 0 then OutError(errmsgUnknownVariable + ' "' + id + '"', false) else + begin + // add bind: first check if this cmd is already bound, and remove old bind + i:= cKbdMaxIndex; + repeat + dec(i) + until (i < 0) or (CurrentTeam^.Binds[i] = KeyName); + if (i >= 0) then + CurrentTeam^.Binds[i]:= ''; + CurrentTeam^.Binds[b]:= KeyName; + end end; procedure chTeamGone(var s:shortstring); diff -r 4cbc9a8fd559 -r 901e363d5837 tools/hashTest.hs --- a/tools/hashTest.hs Sat Sep 21 22:32:01 2013 +0400 +++ b/tools/hashTest.hs Sat Sep 21 23:54:57 2013 +0400 @@ -44,7 +44,9 @@ didIunderstand' = do a <- liftM lines getContents + print $ length a print . IS.size . IS.fromList . map (testHash . map fromEnum) $ a where - testHash s = let l = length s in + testHash s = let l = length s in ( (s !! (l - 2) * s !! 1) + s !! (l - 1) - s !! 0 + ) `mod` 256