1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
//=======================================================================================//
#include "replay/replayutils.h"
#include "dbg.h"
#include "strtools.h"
#include "qlimits.h"
#include "filesystem.h"
#include "replay/replaytime.h"
#include "fmtstr.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
//----------------------------------------------------------------------------------------
static char gs_szGameDir[MAX_OSPATH];
//----------------------------------------------------------------------------------------
void Replay_GetFirstAvailableFilename( char *pDst, int nDstLen, const char *pIdealFilename, const char *pExt,
const char *pFilePath, int nStartIndex )
{
// Strip extension from ideal filename
char szIdealFilename[ MAX_OSPATH ];
V_StripExtension( pIdealFilename, szIdealFilename, sizeof( szIdealFilename ) );
int i = nStartIndex;
while ( 1 )
{
V_strncpy( pDst, szIdealFilename, nDstLen );
V_strcat( pDst, Replay_va( "_%i%s", i, pExt ), nDstLen );
// Get a potential working path/filename
CFmtStr fmtTestFilename(
"%s%c%s",
pFilePath,
CORRECT_PATH_SEPARATOR,
pDst
);
// Make sure slashes are correct for platform
V_FixSlashes( fmtTestFilename.Access() );
// Fix up double slashes
V_FixDoubleSlashes( fmtTestFilename.Access() );
if ( !g_pFullFileSystem->FileExists( fmtTestFilename ) )
break;
++i;
}
}
//----------------------------------------------------------------------------------------
void Replay_ConstructReplayFilenameString( CUtlString &strOut, const char *pReplaySubDir, const char *pFilename, const char *pGameDir )
{
// Construct full filename
strOut.Format( "%s%creplays%c%s%c%s", pGameDir,
CORRECT_PATH_SEPARATOR, CORRECT_PATH_SEPARATOR, pReplaySubDir,
CORRECT_PATH_SEPARATOR, pFilename
);
}
//----------------------------------------------------------------------------------------
char *Replay_va( const char *format, ... )
{
va_list argptr;
static char string[8][512];
static int curstring = 0;
curstring = ( curstring + 1 ) % 8;
va_start (argptr, format);
Q_vsnprintf( string[curstring], sizeof( string[curstring] ), format, argptr );
va_end (argptr);
return string[curstring];
}
//----------------------------------------------------------------------------------------
void Replay_SetGameDir( const char *pGameDir )
{
V_strcpy( gs_szGameDir, pGameDir );
}
//----------------------------------------------------------------------------------------
const char *Replay_GetGameDir()
{
return gs_szGameDir;
}
//----------------------------------------------------------------------------------------
const char *Replay_GetBaseDir()
{
return Replay_va(
"%s%creplays%c",
Replay_GetGameDir(),
CORRECT_PATH_SEPARATOR,
CORRECT_PATH_SEPARATOR
);
}
//----------------------------------------------------------------------------------------
void Replay_GetAutoName( wchar_t *pDest, int nDestSize, const char *pMapName )
{
// Get date/time
CReplayTime now;
now.InitDateAndTimeToNow();
// Convert map name to unicode
wchar_t wszMapName[256];
extern vgui::ILocalize *g_pVGuiLocalize;
g_pVGuiLocalize->ConvertANSIToUnicode( pMapName, wszMapName, sizeof( wszMapName ) );
// Get localized date as string
const wchar_t *pLocalizedDate = CReplayTime::GetLocalizedDate( g_pVGuiLocalize, now, true );
// Create title
g_pVGuiLocalize->ConstructString( pDest, nDestSize, L"%s1: %s2", 2, wszMapName, pLocalizedDate );
}
//----------------------------------------------------------------------------------------
|