hedgewars/uInputHandler.pas
changeset 13131 f10f4bf5f84d
parent 13068 6369d148cfff
child 13132 52178e8ffdfc
equal deleted inserted replaced
13130:13b6f1621ef2 13131:f10f4bf5f84d
   669     Delete(KeyName, byte(KeyName[0]), 1);
   669     Delete(KeyName, byte(KeyName[0]), 1);
   670 b:= KeyNameToCode(id, Modifier);
   670 b:= KeyNameToCode(id, Modifier);
   671 if b = 0 then
   671 if b = 0 then
   672     OutError(errmsgUnknownVariable + ' "' + id + '"', false)
   672     OutError(errmsgUnknownVariable + ' "' + id + '"', false)
   673 else
   673 else
       
   674 begin
       
   675     // add bind: first check if this cmd is already bound, and remove old bind
       
   676     i:= Low(binds.binds);
       
   677     while (i <= High(binds.binds)) and (binds.binds[i] <> KeyName) do
       
   678         inc(i);
       
   679 
       
   680     if (i <= High(binds.binds)) then
   674     begin
   681     begin
   675     // add bind: first check if this cmd is already bound, and remove old bind
   682         code:= Low(binds.indices);
   676     code:= High(binds.binds);
   683         while (code <= High(binds.indices)) and (binds.indices[code] <> i) do
   677     repeat
   684             inc(code);
   678         dec(code)
   685 
   679     until (code < 0) or (binds.binds[code] = KeyName);
   686         checkFails(code <= High(binds.indices), 'binds registry inconsistency', true);
   680     if (code >= 0) then
   687 
   681     begin
   688         if allOk then
   682         i:= 0;
   689             binds.indices[code]:= 0
   683         while (i <= High(binds.indices)) and (binds.indices[i] <> code) do inc(i);
       
   684         checkFails(i <= High(binds.indices), 'binds registry inconsistency', true);
       
   685         binds.binds[i]:= '';
       
   686         binds.indices[code]:= 0
       
   687     end else
   690     end else
   688     begin
   691     begin
   689     inc(binds.lastIndex);
   692     inc(binds.lastIndex);
   690     checkFails(binds.lastIndex < High(binds.binds), 'too many binds', true);
   693     checkFails(binds.lastIndex < High(binds.binds), 'too many binds', true);
   691     i:= binds.lastIndex
   694     i:= binds.lastIndex