本文整理汇总了C++中FS_Gamedir函数的典型用法代码示例。如果您正苦于以下问题:C++ FS_Gamedir函数的具体用法?C++ FS_Gamedir怎么用?C++ FS_Gamedir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FS_Gamedir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SV_WriteLevelFile
void
SV_WriteLevelFile(void)
{
char name[MAX_OSPATH];
FILE *f;
Com_DPrintf("SV_WriteLevelFile()\n");
Com_sprintf(name, sizeof(name), "%s/save/current/%s.sv2",
FS_Gamedir(), sv.name);
f = fopen(name, "wb");
if (!f)
{
Com_Printf("Failed to open %s\n", name);
return;
}
fwrite(sv.configstrings, sizeof(sv.configstrings), 1, f);
CM_WritePortalState(f);
fclose(f);
Com_sprintf(name, sizeof(name), "%s/save/current/%s.sav",
FS_Gamedir(), sv.name);
ge->WriteLevel(name);
}
示例2: SV_WipeSavegame
/*
=====================
SV_WipeSavegame
Delete save/<XXX>/
=====================
*/
static void SV_WipeSavegame (const char *savename)
{
char name[MAX_OSPATH];
char *s;
Com_DPrintf("SV_WipeSaveGame(%s)\n", savename);
Com_sprintf (name, sizeof(name), "%s/save/%s/server.ssv", FS_Gamedir (), savename);
FS_RemoveFile(name);
Com_sprintf (name, sizeof(name), "%s/save/%s/game.ssv", FS_Gamedir (), savename);
FS_RemoveFile(name);
Com_sprintf (name, sizeof(name), "%s/save/%s/*.sav", FS_Gamedir (), savename);
s = Sys_FindFirst( name, 0, 0 );
while (s)
{
FS_RemoveFile(s);
s = Sys_FindNext( 0, 0 );
}
Sys_FindClose ();
Com_sprintf (name, sizeof(name), "%s/save/%s/*.sv2", FS_Gamedir (), savename);
s = Sys_FindFirst(name, 0, 0 );
while (s)
{
FS_RemoveFile(s);
s = Sys_FindNext( 0, 0 );
}
Sys_FindClose ();
}
示例3: binaryWrite
int binaryWrite(char *file, char *data, int bytenum)
{
char tmpfile[512];
char tmpfile2[512];
FILE *fh = NULL;
sprintf(tmpfile,"%s/%s.tmp2",FS_Gamedir(),file);
sprintf(tmpfile2,"%s/%s",FS_Gamedir(),file);
//Com_Printf("[mio] try to write %d bytes to %s..\n", bytenum, tmpfile);
fh = fopen(tmpfile,"wb");
if (!fh) return 1;
fwrite(data,1,bytenum,fh);
fclose(fh);
//CL_RestartFilesystem( false );
//Com_Printf("fetched 100 ok, rename time...\n");
//Com_Printf("rename %s to %s ..\n", tmpfile,tmpfile2);
if (rename(tmpfile,tmpfile2) == 0)
remove(tmpfile);
return 0;
}
示例4: SV_WipeSavegame
/*
=====================
SV_WipeSavegame
Delete save/<XXX>/
=====================
*/
void SV_WipeSavegame (char *savename)
{
char name[MAX_OSPATH];
char *s;
Com_DPrintf("SV_WipeSaveGame(%s)\n", savename);
Com_sprintf (name, sizeof(name), "%s/save/%s/server.ssv", FS_Gamedir (), savename);
remove (name);
Com_sprintf (name, sizeof(name), "%s/save/%s/game.ssv", FS_Gamedir (), savename);
remove (name);
// Knightmare- delete screenshot
Com_sprintf (name, sizeof(name), "%s/save/%s/shot.png", FS_Gamedir (), savename);
remove (name);
Com_sprintf (name, sizeof(name), "%s/save/%s/*.sav", FS_Gamedir (), savename);
s = Sys_FindFirst( name, 0, 0 );
while (s)
{
remove (s);
s = Sys_FindNext( 0, 0 );
}
Sys_FindClose ();
Com_sprintf (name, sizeof(name), "%s/save/%s/*.sv2", FS_Gamedir (), savename);
s = Sys_FindFirst(name, 0, 0 );
while (s)
{
remove (s);
s = Sys_FindNext( 0, 0 );
}
Sys_FindClose ();
}
示例5: CDAudio_Play2
void CDAudio_Play2(int track, qboolean looping)
{
HANDLE playingThread;
char filename[MAX_PATH];
struct ThreadArgList_t *tal;
if (!enabled)
return;
if (!cdValid)
{
CDAudio_GetAudioDiskInfo();
if (!cdValid)
return;
}
track = remap[track];
if (track < 1 || track > maxTrack)
{
Com_DPrintf("CDAudio: Bad track number %u.\n", track);
return;
}
if (playing)
{
if (playTrack == track)
return;
CDAudio_Stop();
}
tal = malloc(sizeof(struct ThreadArgList_t));
tal->playLooping = looping;
tal->playTrack = track;
sprintf(filename, "%s\\Track%03d.ogg", FS_Gamedir(), track);
if (!OpenOGG(filename, tal))
{
sprintf(filename, "%s\\Track%02d.ogg", FS_Gamedir(), track);
if (!OpenOGG(filename, tal))
{
Com_DPrintf("CDAudio: Cannot open Vorbis file \"%s\"", filename);
return;
}
}
playLooping = looping;
playTrack = track;
playing = true;
// force volume update
cdvolume = -1;
playingThread = (HANDLE)_beginthreadex(NULL, 0, PlayingThreadProc, tal, CREATE_SUSPENDED, NULL);
SetThreadPriority(playingThread, THREAD_PRIORITY_TIME_CRITICAL);
ResumeThread(playingThread);
}
示例6: R_ScreenShot_f
/*
-----------------------------------------------------------------------------
Function:
Parameters:
Returns:
Notes:
-----------------------------------------------------------------------------
*/
PRIVATE void R_ScreenShot_f( void )
{
W8 *buffer;
char picname[ 80 ];
char checkname[ MAX_OSPATH ];
int i;
FILE *f;
// create the scrnshots directory if it doesn't exist
my_snprintf( checkname, sizeof( checkname ), "%s/scrnshot", FS_Gamedir() );
FS_CreateDirectory( checkname );
//
// find a file name to save it to
//
my_strlcpy( picname, "scrn00.tga", sizeof( picname ) );
for( i = 0 ; i <= 99 ; ++i )
{
picname[ 4 ] = i / 10 + '0';
picname[ 5 ] = i % 10 + '0';
my_snprintf( checkname, sizeof( checkname ), "%s/scrnshot/%s", FS_Gamedir(), picname );
f = fopen( checkname, "rb" );
if( ! f )
{
break; // file doesn't exist
}
fclose( f );
}
if( i == 100 )
{
Com_Printf( "R_ScreenShot_f: Couldn't create a file\n" );
return;
}
buffer = MM_MALLOC( viddef.width * viddef.height * 3 );
pfglReadPixels( 0, 0, viddef.width, viddef.height, GL_RGB, GL_UNSIGNED_BYTE, buffer );
WriteTGA( checkname, 24, viddef.width, viddef.height, buffer, 1, 1 );
MM_FREE( buffer );
Com_Printf( "Wrote %s\n", picname );
}
示例7: SV_ReadLevelFile
void
SV_ReadLevelFile(void)
{
char name[MAX_OSPATH];
fileHandle_t f;
Com_DPrintf("SV_ReadLevelFile()\n");
Com_sprintf(name, sizeof(name), "save/current/%s.sv2", sv.name);
FS_FOpenFile(name, &f, FS_READ);
if (!f)
{
Com_Printf("Failed to open %s\n", name);
return;
}
FS_Read(sv.configstrings, sizeof(sv.configstrings), f);
CM_ReadPortalState(f);
FS_FCloseFile(f);
Com_sprintf(name, sizeof(name), "%s/save/current/%s.sav",
FS_Gamedir(), sv.name);
ge->ReadLevel(name);
}
示例8: SV_GameMap_f
/*
==================
SV_GameMap_f
Saves the state of the map just being exited and goes to a new map.
If the initial character of the map string is '*', the next map is
in a new unit, so the current savegame directory is cleared of
map files.
Example:
*inter.cin+jail
Clears the archived maps, plays the inter.cin cinematic, then
goes to map jail.bsp.
==================
*/
void SV_GameMap_f (void)
{
char *map;
int i;
client_t *cl;
qboolean *savedInuse;
if (Cmd_Argc() != 2)
{
Com_Printf ("USAGE: gamemap <map>\n");
return;
}
Com_DPrintf("SV_GameMap(%s)\n", Cmd_Argv(1));
FS_CreatePath (va("%s/save/current/", FS_Gamedir()));
// check for clearing the current savegame
map = Cmd_Argv(1);
if (map[0] == '*')
{
// wipe all the *.sav files
SV_WipeSavegame ("current");
}
else
{ // save the map just exited
if (sv.state == ss_game)
{
// clear all the client inuse flags before saving so that
// when the level is re-entered, the clients will spawn
// at spawn points instead of occupying body shells
savedInuse = malloc(maxclients->value * sizeof(qboolean));
for (i=0,cl=svs.clients ; i<maxclients->value; i++,cl++)
{
savedInuse[i] = cl->edict->inuse;
cl->edict->inuse = false;
}
SV_WriteLevelFile ();
// we must restore these for clients to transfer over correctly
for (i=0,cl=svs.clients ; i<maxclients->value; i++,cl++)
cl->edict->inuse = savedInuse[i];
free (savedInuse);
}
}
// start up the next map
SV_Map (false, Cmd_Argv(1), false );
// archive server state
strncpy (svs.mapcmd, Cmd_Argv(1), sizeof(svs.mapcmd)-1);
// copy off the level to the autosave slot
if (!dedicated->value)
{
SV_WriteServerFile (true);
SV_CopySaveGame ("current", "save0");
}
}
示例9: CL_WriteConfiguration
/*
* Writes key bindings and archived cvars to config.cfg
*/
void
CL_WriteConfiguration(void)
{
FILE *f;
char path[MAX_OSPATH];
if (cls.state == ca_uninitialized)
{
return;
}
Com_sprintf(path, sizeof(path), "%s/config.cfg", FS_Gamedir());
f = Q_fopen(path, "w");
if (!f)
{
Com_Printf("Couldn't write config.cfg.\n");
return;
}
fprintf(f, "// generated by quake, do not modify\n");
Key_WriteBindings(f);
fflush(f);
fclose(f);
Cvar_WriteVariables(path);
}
示例10: ConsoleLogfile
static void ConsoleLogfile (const char *msg)
{
// logfile
if (logfile_active && logfile_active->value)
{
char name[MAX_QPATH];
if (!logfile)
{
// ===
// jit -- allow multiple console logs for servers on multiple ports.
int port;
port = Cvar_Get("port", va("%i", PORT_SERVER), CVAR_NOSET)->value;
Com_sprintf(name, sizeof(name), "%s/qconsole%d.log", FS_Gamedir(), port);
// ===
if (logfile_active->value > 2)
logfile = fopen(name, "a");
else
logfile = fopen(name, "w");
}
if (logfile)
fprintf(logfile, "%s", msg);
if (logfile_active->value > 1)
fflush(logfile); // force it to save every time
}
}
示例11: Com_Printf
/*
* Both client and server can use this, and it will output
* to the apropriate place.
*/
void
Com_Printf(char *fmt, ...)
{
va_list argptr;
char msg[MAXPRINTMSG];
va_start(argptr, fmt);
vsnprintf(msg, MAXPRINTMSG, fmt, argptr);
va_end(argptr);
if (rd_target)
{
if ((strlen(msg) + strlen(rd_buffer)) > (rd_buffersize - 1))
{
rd_flush(rd_target, rd_buffer);
*rd_buffer = 0;
}
strcat(rd_buffer, msg);
return;
}
#ifndef DEDICATED_ONLY
Con_Print(msg);
#endif
/* also echo to debugging console */
Sys_ConsoleOutput(msg);
/* logfile */
if (logfile_active && logfile_active->value)
{
char name[MAX_QPATH];
if (!logfile)
{
Com_sprintf(name, sizeof(name), "%s/qconsole.log", FS_Gamedir());
if (logfile_active->value > 2)
{
logfile = fopen(name, "a");
}
else
{
logfile = fopen(name, "w");
}
}
if (logfile)
{
fprintf(logfile, "%s", msg);
}
if (logfile_active->value > 1)
{
fflush(logfile); /* force it to save every time */
}
}
}
示例12: SV_Loadgame_f
/*
* ============== SV_Loadgame_f
*
* ==============
*/
void
SV_Loadgame_f(void)
{
char name[MAX_OSPATH];
FILE *f;
char *dir;
if (Cmd_Argc() != 2) {
Com_Printf("USAGE: loadgame <directory>\n");
return;
}
Com_Printf("Loading game...\n");
dir = Cmd_Argv(1);
if (strstr(dir, "..") || strstr(dir, "/") || strstr(dir, "\\")) {
Com_Printf("Bad savedir.\n");
}
/* make sure the server.ssv file exists */
Com_sprintf(name, sizeof(name), "%s/save/%s/server.ssv", FS_Gamedir(), Cmd_Argv(1));
f = fopen(name, "rb");
if (!f) {
Com_Printf("No such savegame: %s\n", name);
return;
}
fclose(f);
SV_CopySaveGame(Cmd_Argv(1), "current");
SV_ReadServerFile();
/* go to the map */
sv.state = ss_dead; /* don't save current level when changing */
SV_Map(false, svs.mapcmd, true);
}
示例13: Maps_Scan
static void Maps_Scan( void)
{
int numFiles;
char findname[1024];
char **list;
int i;
Maps_Free();
Com_sprintf(findname, sizeof(findname), "%s/maps/*.bsp", FS_Gamedir());
list = FS_ListFiles( findname, &numFiles, 0, SFF_SUBDIR | SFF_HIDDEN | SFF_SYSTEM );
if( !list ) {
return;
}
for( i = 0; i < numFiles - 1; i++ ) {
if( map_count < MAX_MENU_MAPS ) {
list[i][strlen(list[i]) - 4] = 0;
if (strrchr( list[i], '/' ))
mapnames[map_count] = CopyString( strrchr( list[i], '/' ) + 1, TAG_MENU);
else
mapnames[map_count] = CopyString( list[i], TAG_MENU);
map_count++;
}
Z_Free( list[i] );
}
Z_Free( list );
}
示例14: CL_DownloadFileName
void CL_DownloadFileName(char *dest, int destlen, char *fn)
{
//if (strncmp(fn, "players", 7) == 0)
// Com_sprintf (dest, destlen, "%s/%s", BASEDIRNAME, fn);
//else
Com_sprintf (dest, destlen, "%s/%s", FS_Gamedir(), fn);
}
示例15: SV_CopySaveGame
/*
================
SV_CopySaveGame
================
*/
void SV_CopySaveGame (char *src, char *dst)
{
char name[MAX_OSPATH], name2[MAX_OSPATH];
int l, len;
char *found;
Com_DPrintf("SV_CopySaveGame(%s, %s)\n", src, dst);
SV_WipeSavegame (dst);
// copy the savegame over
Com_sprintf (name, sizeof(name), "%s/save/%s/server.ssv", FS_Gamedir(), src);
Com_sprintf (name2, sizeof(name2), "%s/save/%s/server.ssv", FS_Gamedir(), dst);
FS_CreatePath (name2);
CopyFile (name, name2);
Com_sprintf (name, sizeof(name), "%s/save/%s/game.ssv", FS_Gamedir(), src);
Com_sprintf (name2, sizeof(name2), "%s/save/%s/game.ssv", FS_Gamedir(), dst);
CopyFile (name, name2);
// Knightmare- copy screenshot
if (strcmp(dst, "kmq2save0")) // no screenshot for start of level autosaves
{
Com_sprintf (name, sizeof(name), "%s/save/%s/shot.jpg", FS_Gamedir(), src);
Com_sprintf (name2, sizeof(name2), "%s/save/%s/shot.jpg", FS_Gamedir(), dst);
CopyFile (name, name2);
}
Com_sprintf (name, sizeof(name), "%s/save/%s/", FS_Gamedir(), src);
len = strlen(name);
Com_sprintf (name, sizeof(name), "%s/save/%s/*.sav", FS_Gamedir(), src);
found = Sys_FindFirst(name, 0, 0 );
while (found)
{
// strncpy (name+len, found+len);
Q_strncpyz (name+len, found+len, sizeof(name)-len);
Com_sprintf (name2, sizeof(name2), "%s/save/%s/%s", FS_Gamedir(), dst, found+len);
CopyFile (name, name2);
// change sav to sv2
l = strlen(name);
// strncpy (name+l-3, "sv2");
Q_strncpyz (name+l-3, "sv2", sizeof(name)-l+3);
l = strlen(name2);
// strncpy (name2+l-3, "sv2");
Q_strncpyz (name2+l-3, "sv2", sizeof(name2)-l+3);
CopyFile (name, name2);
found = Sys_FindNext( 0, 0 );
}
Sys_FindClose ();
}