@@ -483,6 +483,8 @@ public void OnPluginStart()
483483
484484 // commands
485485 RegAdminCmd (" sm_deletereplay" , Command_DeleteReplay , ADMFLAG_RCON , " Open replay deletion menu." );
486+ RegAdminCmd (" sm_playreplayfile" , Command_PlayReplayFile , ADMFLAG_RCON , " Start a replay from file. Usage: sm_playreplayfile <path>" );
487+ RegAdminCmd (" sm_replayfileinfo" , Command_ReplayFileInfo , ADMFLAG_RCON , " Prints a replay-file's header to console. Usage: sm_replayfileinfo <path>" );
486488 RegConsoleCmd (" sm_replay" , Command_Replay , " Opens the central bot menu. For admins: 'sm_replay stop' to stop the playback." );
487489
488490 // database
@@ -2886,6 +2888,75 @@ public void Shavit_OnWRDeleted(int style, int id, int track, int accountid, cons
28862888 DeleteReplay (style , track , accountid , mapname );
28872889}
28882890
2891+ Action Command_ReplayFileInfo (int client , int args )
2892+ {
2893+ if (args == 0 )
2894+ {
2895+ Shavit_PrintToChat (client , " %T " , " ArgumentsMissing" , client , " sm_replayfileinfo <path>" );
2896+ return Plugin_Handled ;
2897+ }
2898+
2899+ char sPath [PLATFORM_MAX_PATH ];
2900+ GetCmdArgString (sPath , sizeof (sPath ));
2901+
2902+ if (! FileExists (sPath ))
2903+ {
2904+ Shavit_PrintToChat (client , " %T " , " ReplayFileNotFound" , client , sPath );
2905+ return Plugin_Handled ;
2906+ }
2907+
2908+ replay_header_t aHeader ;
2909+ File hFile = ReadReplayHeader (sPath , aHeader , - 1 , - 1 );
2910+ if (hFile == null )
2911+ {
2912+ Shavit_PrintToChat (client , " %T " , " FailedToReadReplayHeader" , client );
2913+ return Plugin_Handled ;
2914+ }
2915+ delete hFile ;
2916+
2917+ int iFileSize = FileSize (sPath );
2918+
2919+ PrintToConsole (client , " %T " , " ReplayFileInfo" , client , sPath , iFileSize ,
2920+ aHeader .sReplayFormat , aHeader .iReplayVersion , aHeader .sMap , aHeader .iStyle , aHeader .iTrack , aHeader .iPreFrames , aHeader .iFrameCount ,
2921+ aHeader .fTime , aHeader .iSteamID , aHeader .iPostFrames , aHeader .fTickrate , aHeader .fZoneOffset [0 ], aHeader .fZoneOffset [1 ], aHeader .iTimestamp );
2922+
2923+ return Plugin_Handled ;
2924+ }
2925+
2926+ Action Command_PlayReplayFile (int client , int args )
2927+ {
2928+ if (args == 0 )
2929+ {
2930+ Shavit_PrintToChat (client , " %T " , " ArgumentsMissing" , client , " sm_playreplayfile <path>" );
2931+ return Plugin_Handled ;
2932+ }
2933+
2934+ char sPath [PLATFORM_MAX_PATH ];
2935+ GetCmdArgString (sPath , sizeof (sPath ));
2936+
2937+ if (! FileExists (sPath ))
2938+ {
2939+ Shavit_PrintToChat (client , " %T " , " ReplayFileNotFound" , client , sPath );
2940+ return Plugin_Handled ;
2941+ }
2942+
2943+ replay_header_t aHeader ;
2944+ File hFile = ReadReplayHeader (sPath , aHeader );
2945+ if (hFile == null )
2946+ {
2947+ Shavit_PrintToChat (client , " %T " , " FailedToReadHeader" , client );
2948+ return Plugin_Handled ;
2949+ }
2950+ delete hFile ;
2951+
2952+ if (Shavit_StartReplayFromFile (aHeader .iStyle , aHeader .iTrack , - 1.0 , client , - 1 , Replay_Dynamic , true , sPath ) == 0 )
2953+ {
2954+ Shavit_PrintToChat (client , " %T " , " FailedToCreateReplay" , client );
2955+ }
2956+
2957+ return Plugin_Handled ;
2958+ }
2959+
28892960public Action Command_DeleteReplay (int client , int args )
28902961{
28912962 if (! IsValidClient (client ))
0 commit comments