DEADSOFTWARE

`Grid.forEachInAABB()`: no more callbacks
[d2df-sdl.git] / src / game / g_game.pas
index b1f5f9fe1955f1f85dac4e02ba05345d9bd298f0..6cbd3e4eddfab3d676657a20e6e71619ce551f12 100644 (file)
@@ -22,7 +22,7 @@ uses
   SysUtils, Classes,
   MAPDEF,
   g_basic, g_player, e_graphics, g_res_downloader,
-  g_sound, g_gui, utils, md5, xprofiler;
+  g_sound, g_gui, utils, md5, mempool, xprofiler;
 
 type
   TGameSettings = record
@@ -310,6 +310,7 @@ var
   gVotesEnabled: Boolean = True;
   gEvents: Array of TGameEvent;
   gDelayedEvents: Array of TDelayedEvent;
+  gUseChatSounds: Boolean = True;
   gChatSounds: Array of TChatSound;
 
   // move button values:
@@ -1540,6 +1541,8 @@ var
   reliableUpdate: Boolean;
 begin
   g_ResetDynlights();
+  framePool.reset();
+
 // Ïîðà âûêëþ÷àòü èãðó:
   if gExit = EXIT_QUIT then
     Exit;
@@ -6958,25 +6961,40 @@ begin
 end;
 
 procedure g_Game_ChatSound(Text: String; Taunt: Boolean = True);
+const
+  punct: Array[0..13] of String =
+  ('.', ',', ':', ';', '!', '?', '(', ')', '''', '"', '/', '\', '*', '^');
 var
   i, j: Integer;
   ok: Boolean;
   fpText: String;
 
+  function IsPunctuation(S: String): Boolean;
+  var
+    i: Integer;
+  begin
+    Result := False;
+    if Length(S) <> 1 then
+      Exit;
+    for i := Low(punct) to High(punct) do
+      if S = punct[i] then
+      begin
+        Result := True;
+        break;
+      end;
+  end;
   function FilterPunctuation(S: String): String;
+  var
+    i: Integer;
   begin
-    S := StringReplace(S, '.', ' ', [rfReplaceAll]);
-    S := StringReplace(S, ',', ' ', [rfReplaceAll]);
-    S := StringReplace(S, ':', ' ', [rfReplaceAll]);
-    S := StringReplace(S, ';', ' ', [rfReplaceAll]);
-    S := StringReplace(S, '!', ' ', [rfReplaceAll]);
-    S := StringReplace(S, '?', ' ', [rfReplaceAll]);
+    for i := Low(punct) to High(punct) do
+      S := StringReplace(S, punct[i], ' ', [rfReplaceAll]);
     Result := S;
   end;
 begin
-  g_Sound_PlayEx('SOUND_GAME_RADIO');
+  ok := False;
 
-  if Taunt and (gChatSounds <> nil) and (Pos(': ', Text) > 0) then
+  if gUseChatSounds and Taunt and (gChatSounds <> nil) and (Pos(': ', Text) > 0) then
   begin
     // remove player name
     Delete(Text, 1, Pos(': ', Text) + 2 - 1);
@@ -6989,10 +7007,7 @@ begin
       ok := True;
       for j := 0 to Length(gChatSounds[i].Tags) - 1 do
       begin
-        if gChatSounds[i].FullWord and
-        (gChatSounds[i].Tags[j] <> '.') and (gChatSounds[i].Tags[j] <> ',') and
-        (gChatSounds[i].Tags[j] <> ':') and (gChatSounds[i].Tags[j] <> ';') and
-        (gChatSounds[i].Tags[j] <> '!') and (gChatSounds[i].Tags[j] <> '?') then
+        if gChatSounds[i].FullWord and (not IsPunctuation(gChatSounds[i].Tags[j])) then
           ok := Pos(' ' + gChatSounds[i].Tags[j] + ' ', fpText) > 0
         else
           ok := Pos(gChatSounds[i].Tags[j], Text) > 0;
@@ -7006,6 +7021,8 @@ begin
       end;
     end;
   end;
+  if not ok then
+    g_Sound_PlayEx('SOUND_GAME_RADIO');
 end;
 
 procedure g_Game_Announce_GoodShot(SpawnerUID: Word);