DEADSOFTWARE

added centerprint command
[d2df-sdl.git] / src / game / g_game.pas
index d03d02a47f13494d22353492dc80ba35676346ce..23c09434500a78b91de1423888484296164d8a95 100644 (file)
@@ -1064,14 +1064,15 @@ begin
 
           SortGameStat(CustomStat.PlayerStat);
 
-          if gSaveStats or gScreenshotStats then
+          if (gSaveStats or gScreenshotStats) and (Length(gPlayers) > 1) then
           begin
             t := Now;
             if g_Game_IsNet then StatFilename := NetServerName else StatFilename := 'local';
             StatDate := FormatDateTime('yymmdd_hhnnss', t);
             StatFilename := StatFilename + '_' + CustomStat.Map + '_' + g_Game_ModeToText(CustomStat.GameMode);
             StatFilename := sanitizeFilename(StatFilename) + '_' + StatDate;
-            if gSaveStats then SaveGameStat(CustomStat, FormatDateTime('yyyy"/"mm"/"dd', t));
+            if gSaveStats then
+              SaveGameStat(CustomStat, FormatDateTime('yyyy"/"mm"/"dd', t));
           end;
 
           StatShotDone := False;
@@ -7245,6 +7246,30 @@ begin
       end else
         g_Console_Add(_lc[I_MSG_SERVERONLY]);
     end
+    else if cmd = 'centerprint' then
+    begin
+      if (Length(P) > 2) and (P[1] <> '') then
+      begin
+        chstr := '';
+        for a := 2 to High(P) do
+          chstr := chstr + P[a] + ' ';
+
+        if Length(chstr) > 200 then SetLength(chstr, 200);
+
+        if Length(chstr) < 1 then
+        begin
+          g_Console_Add('centerprint <timeout> <text>');
+          Exit;
+        end;
+
+        a := StrToIntDef(P[1], 100);
+        chstr := b_Text_Format(chstr);
+        g_Game_Message(chstr, a);
+        if g_Game_IsNet and g_Game_IsServer then
+          MH_SEND_GameEvent(NET_EV_BIGTEXT, a, chstr);
+      end
+      else g_Console_Add('centerprint <timeout> <text>');
+    end
     else if (cmd = 'overtime') and not g_Game_IsClient then
     begin
       if (Length(P) = 1) or (StrToIntDef(P[1], -1) <= 0) then