[Server Demos] Fixed automatically recording server-side demos

[Server Demos] Fixed automatically recording server-side demos

diff --git a/src/docs/Changelog b/src/docs/Changelog
index 1eb197f..122eb6a 100644
--- a/src/docs/Changelog
+++ b/src/docs/Changelog
@@ -1,11 +1,12 @@
 2021-04-11 dGr8LookinSparky <hissparkyness@gmail.com>
-	* [client]Fix the mouse sensitivity for when cl_mouseAccel is disabled.
+	* [Client]Fix the mouse sensitivity for when cl_mouseAccel is disabled.
 
 2021-04-11 Dusan Jocic <dusanjocic@msn>
 	* [Console] Fixed problems with console tab and input
 	* [Console] Specify console tab to dump in the log file
 	* [SoundSystem] Don't play sound while minimized
 	* [SoundSystem] Don't play sound even if application is unfocused
+	* [Server Demos] Fixed automatically recording server-side demos
 
 2021-04-10 Dusan Jocic <dusanjocic@msn>
 	* [Libraries] Cleaning
diff --git a/src/engine/API/FileSystem_api.hpp b/src/engine/API/FileSystem_api.hpp
index d005db8..6268000 100644
--- a/src/engine/API/FileSystem_api.hpp
+++ b/src/engine/API/FileSystem_api.hpp
@@ -161,6 +161,8 @@ public:
     virtual pointer GetGameDir( void ) = 0;
     virtual bool IsFileEmpty( valueType* filename ) = 0;
     virtual valueType* GetFullGamePath( valueType* filename ) = 0;
+    virtual void Rmdir( pointer osPath, bool recursive ) = 0;
+    virtual void HomeRmdir( pointer homePath, bool recursive ) = 0;
 };
 
 extern idFileSystem* fileSystem;
diff --git a/src/engine/API/cgame_api.hpp b/src/engine/API/cgame_api.hpp
index 8ce3e80..931bb77 100644
--- a/src/engine/API/cgame_api.hpp
+++ b/src/engine/API/cgame_api.hpp
@@ -32,7 +32,7 @@
 #define CGAME_IMPORT_API_VERSION 5
 #define CAM_PRIMARY 0
 
-#define CMD_BACKUP 64
+#define CMD_BACKUP 512
 #define CMD_MASK ( CMD_BACKUP - 1 )
 // allow a lot of command backups for very fast systems
 // multiple commands may be combined into a single packet, so this
@@ -85,11 +85,7 @@ struct cgameImports_t
     void ( *AddReliableCommand )( pointer cmd );
     void ( *Cvar_LatchedVariableStringBuffer )( pointer var_name, valueType* buffer, uint64 bufsize );
     void ( *CL_TranslateString )( pointer string, valueType* dest_buffer );
-    void ( *CL_DemoName )( valueType* buffer, sint size );
     void ( *Com_GetHunkInfo )( sint* hunkused, sint* hunkexpected );
-    sint( *DemoPos )( void );
-    void ( *DemoName )( valueType* buffer, sint size );
-    demoState_t ( *DemoState )( void );
     uint64( *Hunk_MemoryRemaining )( void );
     void ( *Key_GetBindingByString )( pointer binding, sint* key1, sint* key2 );
     void ( *Key_SetBinding )( sint keynum, pointer binding );
diff --git a/src/engine/API/serverDemo_api.hpp b/src/engine/API/serverDemo_api.hpp
deleted file mode 100644
index 10824b0..0000000
--- a/src/engine/API/serverDemo_api.hpp
+++ /dev/null
@@ -1,50 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////////////
-// Copyright(C) 2011 - 2021 Dusan Jocic <dusanjocic@msn.com>
-//
-// This file is part of OpenWolf.
-//
-// OpenWolf is free software; you can redistribute it
-// and / or modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the License,
-// or (at your option) any later version.
-//
-// OpenWolf is distributed in the hope that it will be
-// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with OpenWolf; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110 - 1301  USA
-//
-// -------------------------------------------------------------------------------------
-// File name:   serverDemo_api.hpp
-// Created:     11/24/2018
-// Compilers:   Microsoft (R) C/C++ Optimizing Compiler Version 19.26.28806 for x64,
-//              gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0
-// Description:
-// -------------------------------------------------------------------------------------
-////////////////////////////////////////////////////////////////////////////////////////
-
-#ifndef __SERVERDEMO_API_H__
-#define __SERVERDEMO_API_H__
-
-//
-// idServerWorldSystem
-//
-class idServerDemoSystem
-{
-public:
-    virtual void DemoWriteServerCommand( pointer str ) = 0;
-    virtual void DemoWriteGameCommand( sint cmd, pointer str ) = 0;
-    virtual void DemoWriteFrame( void ) = 0;
-    virtual void DemoReadFrame( void ) = 0;
-    virtual void DemoStartRecord( void ) = 0;
-    virtual void DemoStopRecord( void ) = 0;
-    virtual void DemoStartPlayback( void ) = 0;
-    virtual void DemoStopPlayback( void ) = 0;
-};
-
-extern idServerDemoSystem* serverDemoSystem;
-
-#endif //!__SERVERWORLD_API_H__
diff --git a/src/engine/API/serverGame_api.hpp b/src/engine/API/serverGame_api.hpp
index c7d051a..1eb2c2f 100644
--- a/src/engine/API/serverGame_api.hpp
+++ b/src/engine/API/serverGame_api.hpp
@@ -134,7 +134,6 @@ public:
     virtual sharedEntity_t* GEntityForSvEntity( svEntity_t* svEnt ) = 0;
     virtual void RestartGameProgs( void ) = 0;
     virtual playerState_t* GameClientNum( sint num ) = 0;
-    virtual sint DemoWriteCommand( sint cmd, pointer str ) = 0;
 };
 
 extern idServerGameSystem* serverGameSystem;
diff --git a/src/engine/API/sgame_api.hpp b/src/engine/API/sgame_api.hpp
index fa33678..0cf2f8f 100644
--- a/src/engine/API/sgame_api.hpp
+++ b/src/engine/API/sgame_api.hpp
@@ -78,7 +78,7 @@ struct gameImports_t
     idServerMainSystem* serverMainSystem;
     idCmdBufferSystem* cmdBufferSystem;
     idCmdSystem* cmdSystem;
-    idServerDemoSystem* serverDemoSystem;
+    
     idSystem* idsystem;
     idParseSystem* parseSystem;
 };
@@ -139,7 +139,6 @@ sfxHandle_t trap_RegisterSound( pointer sample );
 sint trap_GetSoundLength( sfxHandle_t sfxHandle );
 sfxHandle_t trap_S_RegisterSound( pointer sample );
 sint trap_S_SoundDuration( sfxHandle_t handle );
-void trap_DemoCommand( demoCommand_t cmd, pointer string );
 
 //
 // idGame
@@ -158,7 +157,6 @@ public:
     virtual void RunFrame( sint levelTime ) = 0;
     virtual bool ConsoleCommand( void ) = 0;
     virtual bool SnapshotCallback( sint entityNum, sint clientNum ) = 0;
-    virtual void GameDemoCommand( sint arg0 ) = 0;
 };
 
 extern idSGame* sgame;
diff --git a/src/engine/client/cl_main.cpp b/src/engine/client/cl_main.cpp
index 71cd9d4..1882ba0 100644
--- a/src/engine/client/cl_main.cpp
+++ b/src/engine/client/cl_main.cpp
@@ -327,15 +327,19 @@ void CL_StopRecord_f( void )
 CL_DemoFilename
 ==================
 */
-void CL_DemoFilename( sint number, valueType* fileName )
+void CL_DemoFilename( valueType* buf, sint bufSize )
 {
-    if( number < 0 || number > 9999 )
-    {
-        Q_vsprintf_s( fileName, MAX_OSPATH, MAX_OSPATH, "demo9999" );	// fretn - removed .tga
-        return;
-    }
+    time_t rawtime;
+    
+    // should really only reach ~19 chars
+    valueType timeStr[32] = { 0 };
     
-    Q_vsprintf_s( fileName, MAX_OSPATH, MAX_OSPATH, "demo%04i", number );
+    ::time( &rawtime );
+    
+    // or gmtime
+    ::strftime( timeStr, sizeof( timeStr ), "%Y-%m-%d_%H-%M-%S", localtime( &rawtime ) );
+    
+    Q_vsprintf_s( buf, bufSize, bufSize, "demo%s", timeStr );
 }
 
 /*
@@ -351,7 +355,7 @@ Begins recording a demo from the current position
 static valueType     demoName[MAX_QPATH];	// compiler bug workaround
 void CL_Record_f( void )
 {
-    valueType            name[MAX_OSPATH];
+    valueType            name[MAX_OSPATH], extension[32];
     sint             len;
     valueType*           s;
     
@@ -373,7 +377,6 @@ void CL_Record_f( void )
         return;
     }
     
-    
     // ATVI Wolfenstein Misc #479 - changing this to a warning
     // sync 0 doesn't prevent recording, so not forcing it off .. everyone does g_sync 1 ; record ; g_sync 0 ..
     if( networkSystem->IsLocalAddress( clc.serverAddress ) && !cvarSystem->VariableValue( "g_synchronousClients" ) )
@@ -385,23 +388,19 @@ void CL_Record_f( void )

[... diff too long, it was truncated ...]

GitHub
sha: cbd7840a