// get the demo name
strlcpy (name, Cmd_Argv(1), sizeof (name));
- FS_DefaultExtension (name, ".dem", sizeof (name));
+ FS_SetExtension (name, ".dem", sizeof (name), true);
// start the map up
if (c > 2)
// open the demo file
strlcpy (name, Cmd_Argv(1), sizeof (name));
- FS_DefaultExtension (name, ".dem", sizeof (name));
+ FS_SetExtension (name, ".dem", sizeof (name), true);
f = FS_OpenVirtualFile(name, false);
if (!f)
{
/*
==================
-FS_DefaultExtension
+FS_SetExtension
==================
*/
-void FS_DefaultExtension (char *path, const char *extension, size_t size_path)
+void FS_SetExtension (char *path, const char *extension, size_t size_path, qboolean forceextension)
{
const char *src;
// (extension should include the .)
src = path + strlen(path) - 1;
- while (*src != '/' && src != path)
- {
- if (*src == '.')
- return; // it has an extension
+ while (*src != '/' && *src != '.' && src != path)
src--;
- }
+
+ if (*src == '.')
+ if(!forceextension || !strcasecmp(src, extension))
+ return; // it has an (or the) extension
strlcat (path, extension, size_path);
}
// ------ Other functions ------ //
void FS_StripExtension (const char *in, char *out, size_t size_out);
-void FS_DefaultExtension (char *path, const char *extension, size_t size_path);
+void FS_SetExtension (char *path, const char *extension, size_t size_path, qboolean forceextension);
#define FS_FILETYPE_NONE 0
#define FS_FILETYPE_FILE 1
}
strlcpy (name, Cmd_Argv(1), sizeof (name));
- FS_DefaultExtension (name, ".sav", sizeof (name));
+ FS_SetExtension (name, ".sav", sizeof (name), true);
Host_Savegame_to(prog, name);
}
}
strlcpy (filename, Cmd_Argv(1), sizeof(filename));
- FS_DefaultExtension (filename, ".sav", sizeof (filename));
+ FS_SetExtension (filename, ".sav", sizeof (filename), true);
Con_Printf("Loading game from %s...\n", filename);
return; // we already have a demo
strlcpy(name, filename, sizeof(name));
- FS_DefaultExtension(name, ".dem", sizeof(name));
+ FS_SetExtension(name, ".dem", sizeof(name), true);
Con_Printf("Recording demo for # %d (%s) to %s\n", PRVM_NUM_FOR_EDICT(client->edict), client->netaddress, name);