trying to unbreak hog speech
authornemo
Sun, 05 Dec 2010 23:50:04 -0500
changeset 4467 adedeec8f18f
parent 4466 8ee58126f7bf
child 4468 0758b19bc99b
trying to unbreak hog speech
hedgewars/uChat.pas
hedgewars/uGears.pas
hedgewars/uIO.pas
--- a/hedgewars/uChat.pas	Sun Dec 05 23:08:57 2010 -0500
+++ b/hedgewars/uChat.pas	Sun Dec 05 23:50:04 2010 -0500
@@ -181,51 +181,42 @@
 visibleCount:= cnt;
 end;
 
+procedure SendHogSpeech(s: shortstring);
+begin
+SendIPC('h' + s);
+ParseCommand('/hogsay '+s, true)
+end;
+
 procedure AcceptChatString(s: shortstring);
 var i: TWave;
     c, t: LongInt;
+    x: byte;
 begin
 t:= LocalTeam;
-if not CurrentTeam^.ExtDriven and
-   ((s[1] = '"') and (s[Length(s)] = '"') or
-    (s[1] = '''') and (s[Length(s)] = '''') or
-    (s[1] = '-') and (s[Length(s)] = '-')) then
+x:= 0;
+if (s[1] = '"') and (s[Length(s)] = '"') then x:= 1
+else if (s[1] = '''') and (s[Length(s)] = '''') then x:= 2
+else if (s[1] = '-') and (s[Length(s)] = '-') then x:= 3;
+if not CurrentTeam^.ExtDriven and (x <> 0) then
     for c:= 0 to Pred(TeamsCount) do
         if (TeamsArray[c] = CurrentTeam) then t:= c;
-// "Make hedgehog say something"
-if (s[1] = '"') and (s[Length(s)] = '"') then
+
+if x <> 0 then
     begin
     if t = -1 then
         ParseCommand('/say ' + copy(s, 2, Length(s)-2), true)
     else
-        ParseCommand('/hogsay '#1 + char(t) + copy(s, 2, Length(s)-2), true);
+        SendHogSpeech(char(x) + char(t) + copy(s, 2, Length(s)-2));
     exit
     end;
-// 'Make hedgehog think something'
-if (s[1] = '''') and (s[Length(s)] = '''') then
-    begin
-    if t = -1 then
-        ParseCommand('/say ' + copy(s, 2, Length(s)-2), true)
-    else
-        ParseCommand('/hogsay '#2 + char(t) + copy(s, 2, Length(s)-2), true);
-    exit
-    end;
-// -Make hedgehog yell something-
-if (s[1] = '-') and (s[Length(s)] = '-') then
-    begin
-    if t = -1 then
-        ParseCommand('/say ' + copy(s, 2, Length(s)-2), true)
-    else
-        ParseCommand('/hogsay '#3 + char(t) + copy(s, 2, Length(s)-2), true);
-    exit
-    end;
+
 // These 3 are same as above, only are to make the hedgehog say it on next attack
 if (s[1] = '/') and (copy(s, 1, 5) = '/hsa ') then
     begin
     if CurrentTeam^.ExtDriven then
         ParseCommand('/say ' + copy(s, 6, Length(s)-5), true)
     else
-        ParseCommand('/hogsay '#4 + copy(s, 6, Length(s)-5), true);
+        SendHogSpeech(#4 + copy(s, 6, Length(s)-5));
     exit
     end;
 if (s[1] = '/') and (copy(s, 1, 5) = '/hta ') then
@@ -233,7 +224,7 @@
     if CurrentTeam^.ExtDriven then
         ParseCommand('/say ' + copy(s, 6, Length(s)-5), true)
     else
-        ParseCommand('/hogsay '#5 + copy(s, 6, Length(s)-5), true);
+        SendHogSpeech(#5 + copy(s, 6, Length(s)-5));
     exit
     end;
 if (s[1] = '/') and (copy(s, 1, 5) = '/hya ') then
@@ -241,7 +232,7 @@
     if CurrentTeam^.ExtDriven then
         ParseCommand('/say ' + copy(s, 6, Length(s)-5), true)
     else
-        ParseCommand('/hogsay '#6 + copy(s, 6, Length(s)-5), true);
+        SendHogSpeech(#6 + copy(s, 6, Length(s)-5));
     exit
     end;
 
--- a/hedgewars/uGears.pas	Sun Dec 05 23:08:57 2010 -0500
+++ b/hedgewars/uGears.pas	Sun Dec 05 23:50:04 2010 -0500
@@ -1764,8 +1764,6 @@
         exit
         end;
 
-    SendIPC('h' + s);
-
     if (x < 4) and (TeamsArray[t] <> nil) then
         begin
             // if team matches current hedgehog team, default to current hedgehog
--- a/hedgewars/uIO.pas	Sun Dec 05 23:08:57 2010 -0500
+++ b/hedgewars/uIO.pas	Sun Dec 05 23:50:04 2010 -0500
@@ -285,6 +285,7 @@
     and (tmpflag or (headcmd^.cmd = '#')) // '#' is the only cmd which can be sent within same tick after 'N'
     and ((GameTicks = hiTicks shl 16 + headcmd^.loTime)
         or (headcmd^.cmd = 's') // for these commands time is not specified
+        or (headcmd^.cmd = 'h') // seems the hedgewars protocol does not allow remote synced commands
         or (headcmd^.cmd = '#')
         or (headcmd^.cmd = 'b')
         or (headcmd^.cmd = 'F')) do