fixes to chat input history: remember all inputs, don not remember duplicates
authorsheepluva
Tue, 18 Nov 2014 01:51:40 +0100
changeset 10513 58fa783e0cfd
parent 10512 25021aac078e
child 10514 a1423588a4e4
fixes to chat input history: remember all inputs, don not remember duplicates
hedgewars/uChat.pas
--- a/hedgewars/uChat.pas	Mon Nov 17 23:23:10 2014 +0100
+++ b/hedgewars/uChat.pas	Tue Nov 18 01:51:40 2014 +0100
@@ -268,6 +268,13 @@
     c, t: LongInt;
     x: byte;
 begin
+if s <> LocalStrs[localLastStr] then
+    begin
+    // put in input history
+    localLastStr:= (localLastStr + 1) mod MaxStrIndex;
+    LocalStrs[localLastStr]:= s;
+    end;
+
 t:= LocalTeam;
 x:= 0;
 if (s[1] = '"') and (s[Length(s)] = '"')
@@ -295,10 +302,6 @@
 
 if (s[1] = '/') then
     begin
-    // put in input history
-    localLastStr:= (localLastStr + 1) mod MaxStrIndex;
-    LocalStrs[localLastStr]:= s;
-
     // These 3 are same as above, only are to make the hedgehog say it on next attack
     if (copy(s, 2, 4) = 'hsa ') then
         begin
@@ -498,11 +501,7 @@
     if copy(s, 1, 4) = '/me ' then
         s:= #2 + '* ' + UserNick + ' ' + copy(s, 5, Length(s) - 4)
     else
-        begin
-        localLastStr:= (localLastStr + 1) mod MaxStrIndex;
-        LocalStrs[localLastStr]:= s;
         s:= #1 + UserNick + ': ' + s;
-        end;
 
     AddChatString(s)
 end;