char filename [MAX_OSPATH];
char shortname [MAX_QPATH];
filedesc_t handle;
- int ignorecase; ///< PK3 ignores case
+ qbool ignorecase; ///< PK3 ignores case
int numfiles;
qbool vpack;
qbool dlcache;
void FS_Ls_f(cmd_state_t *cmd);
void FS_Which_f(cmd_state_t *cmd);
-static searchpath_t *FS_FindFile (const char *name, int* index, qbool quiet);
+static searchpath_t *FS_FindFile (const char *name, int *index, const char **canonicalname, qbool quiet);
static packfile_t* FS_AddFileToPack (const char* name, pack_t* pack,
fs_offset_t offset, fs_offset_t packsize,
fs_offset_t realsize, int flags);
*already_loaded = false;
// then find the real name...
- search = FS_FindFile(pakfile, &index, true);
+ search = FS_FindFile(pakfile, &index, NULL, true);
if(!search || search->pack)
{
Con_Printf("could not find pak \"%s\"\n", pakfile);
and the file index in the package if relevant
====================
*/
-static searchpath_t *FS_FindFile (const char *name, int* index, qbool quiet)
+static searchpath_t *FS_FindFile (const char *name, int *index, const char **canonicalname, qbool quiet)
{
searchpath_t *search;
pack_t *pak;
if (index != NULL)
*index = -1;
+ if (canonicalname)
+ *canonicalname = NULL;
return NULL;
}
if (!quiet && developer_extra.integer)
- Con_DPrintf("FS_FindFile: %s in %s\n",
- pak->files[middle].name, pak->filename);
+ Con_DPrintf("FS_FindFile: %s in %s\n", pak->files[middle].name, pak->filename);
if (index != NULL)
*index = middle;
+ if (canonicalname)
+ *canonicalname = pak->files[middle].name;
return search;
}
if (index != NULL)
*index = -1;
+ if (canonicalname)
+ *canonicalname = name;
return search;
}
}
if (index != NULL)
*index = -1;
+ if (canonicalname)
+ *canonicalname = NULL;
return NULL;
}
searchpath_t *search;
int pack_ind;
- search = FS_FindFile (filename, &pack_ind, quiet);
+ search = FS_FindFile (filename, &pack_ind, NULL, quiet);
// Not found?
if (search == NULL)
searchpath_t *search;
char fullpath[MAX_OSPATH];
- search = FS_FindFile (filename, NULL, true);
+ search = FS_FindFile (filename, NULL, NULL, true);
if(!search)
return FS_FILETYPE_NONE;
FS_FileExists
Look for a file in the packages and in the filesystem
+Returns its canonical name (VFS path with correct capitalisation) if found, else NULL.
+If the file is found outside a pak, this will be the same pointer as passed in.
==================
*/
-qbool FS_FileExists (const char *filename)
+const char *FS_FileExists (const char *filename)
{
- return (FS_FindFile (filename, NULL, true) != NULL);
+ const char *canonicalname;
+
+ return FS_FindFile(filename, NULL, &canonicalname, true) ? canonicalname : NULL;
}
return;
}
filename = Cmd_Argv(cmd, 1);
- sp = FS_FindFile(filename, &index, true);
+ sp = FS_FindFile(filename, &index, NULL, true);
if (!sp) {
Con_Printf("%s isn't anywhere\n", filename);
return;
const char *FS_WhichPack(const char *filename)
{
int index;
- searchpath_t *sp = FS_FindFile(filename, &index, true);
+ searchpath_t *sp = FS_FindFile(filename, &index, NULL, true);
if(sp && sp->pack)
return sp->pack->shortname;
else if(sp)
#define FS_FILETYPE_NONE 0
#define FS_FILETYPE_FILE 1
#define FS_FILETYPE_DIRECTORY 2
-int FS_FileType (const char *filename); // the file can be into a package
-int FS_SysFileType (const char *filename); // only look for files outside of packages
-
-qbool FS_FileExists (const char *filename); // the file can be into a package
-qbool FS_SysFileExists (const char *filename); // only look for files outside of packages
+/// Look for a file in the packages and in the filesystem
+int FS_FileType (const char *filename);
+/// Look for a file in the filesystem only
+int FS_SysFileType (const char *filename);
+
+/// Look for a file in the packages and in the filesystem
+/// Returns its canonical name (same case as used in the pack) if found, else NULL.
+/// If the file is found outside a pak, this will be the same pointer as passed in.
+const char *FS_FileExists (const char *filename);
+/// Look for a file in the filesystem only
+qbool FS_SysFileExists (const char *filename);
unsigned char *FS_Deflate(const unsigned char *data, size_t size, size_t *deflated_size, int level, mempool_t *mempool);
unsigned char *FS_Inflate(const unsigned char *data, size_t size, size_t *inflated_size, mempool_t *mempool);
LHNETADDRESS_ToString(LHNET_AddressFromSocket(mysocket), myaddressstring, sizeof(myaddressstring), true);
MSG_WriteString(&sv_message, myaddressstring);
MSG_WriteString(&sv_message, hostname.string);
- MSG_WriteString(&sv_message, sv.name);
+ MSG_WriteString(&sv_message, sv.worldbasename);
// How many clients are there?
for (i = 0, numclients = 0;i < svs.maxclients;i++)
if (svs.clients[i].active)
/// collision culling data
world_t world;
- /// map name
- char name[64]; // %s followed by entrance name
// variants of map name
char worldbasename[MAX_QPATH]; // %s
char worldname[MAX_QPATH]; // maps/%s.bsp
if(host.hook.ToggleMenu)
host.hook.ToggleMenu();
- dp_strlcpy(mapname, sv.name, sizeof(mapname));
+ dp_strlcpy(mapname, sv.worldbasename, sizeof(mapname));
SV_SpawnServer(mapname);
if(sv.active && host.hook.ConnectLocal != NULL)
print ("host: %s\n", Cvar_VariableString (&cvars_all, "hostname", CF_SERVER));
print ("version: %s\n", engineversion);
print ("protocol: %i (%s)\n", Protocol_NumberForEnum(sv.protocol), Protocol_NameForEnum(sv.protocol));
- print ("map: %s\n", sv.name);
+ print ("map: %s\n", sv.worldbasename);
print ("timing: %s\n", SV_TimingReport(vabuf, sizeof(vabuf)));
print ("players: %i active (%i max)\n\n", players, svs.maxclients);
char *entities;
model_t *worldmodel;
char modelname[sizeof(sv.worldname)];
+ const char *canonicalname;
char vabuf[1024];
Con_Printf("SpawnServer: %s\n", map);
dpsnprintf (modelname, sizeof(modelname), "maps/%s.bsp", map);
- if (!FS_FileExists(modelname))
+ if (!(canonicalname = FS_FileExists(modelname)))
{
dpsnprintf (modelname, sizeof(modelname), "maps/%s", map);
- if (!FS_FileExists(modelname))
+ if (!(canonicalname = FS_FileExists(modelname)))
{
- Con_Printf("SpawnServer: no map file named %s\n", modelname);
+ Con_Printf(CON_ERROR "SpawnServer: no map file named %s.bsp\n", modelname);
return;
}
}
+ // if it's not in a pak canonicalname will be the same pointer as modelname
+ // if it's in a pak canonicalname may differ by case
+ if (modelname != canonicalname)
+ dp_strlcpy(modelname, canonicalname, sizeof(modelname));
// SV_LockThreadMutex();
worldmodel = Mod_ForName(modelname, false, developer.integer > 0, NULL);
if (!worldmodel || !worldmodel->TraceBox)
{
- Con_Printf("Couldn't load map %s\n", modelname);
+ Con_Printf(CON_ERROR "Couldn't load map %s\n", modelname);
if(!host_isclient.integer)
Sys_MakeProcessMean();
sv.active = true;
// set level base name variables for later use
- dp_strlcpy (sv.name, map, sizeof (sv.name));
dp_strlcpy(sv.worldname, modelname, sizeof(sv.worldname));
FS_StripExtension(sv.worldname, sv.worldnamenoextension, sizeof(sv.worldnamenoextension));
- dp_strlcpy(sv.worldbasename, !strncmp(sv.worldnamenoextension, "maps/", 5) ? sv.worldnamenoextension + 5 : sv.worldnamenoextension, sizeof(sv.worldbasename));
+ dp_strlcpy(sv.worldbasename, !strncasecmp(sv.worldnamenoextension, "maps/", 5) ? sv.worldnamenoextension + 5 : sv.worldnamenoextension, sizeof(sv.worldbasename));
+// dp_strlcpy(sv.name, sv.worldbasename, sizeof (sv.name)); // TODO can we just remove this now?
//Cvar_SetQuick(&sv_worldmessage, sv.worldmessage); // set later after QC is spawned
Cvar_SetQuick(&sv_worldname, sv.worldname);
Cvar_SetQuick(&sv_worldnamenoextension, sv.worldnamenoextension);
sv.models[i+1] = Mod_ForName (sv.model_precache[i+1], false, false, sv.worldname);
}
if(i < sv.worldmodel->brush.numsubmodels)
- Con_Printf("Too many submodels (MAX_MODELS is %i)\n", MAX_MODELS);
+ Con_Printf(CON_WARN "Too many submodels (MAX_MODELS is %i)\n", MAX_MODELS);
//
// load the rest of the entities
else
PRVM_serverglobalfloat(deathmatch) = deathmatch.integer;
- PRVM_serverglobalstring(mapname) = PRVM_SetEngineString(prog, sv.name);
+ PRVM_serverglobalstring(mapname) = PRVM_SetEngineString(prog, sv.worldbasename);
// serverflags are for cross level information (sigils)
PRVM_serverglobalfloat(serverflags) = svs.serverflags;
for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
FS_Printf(f, "%f\n", svs.clients[0].spawn_parms[i]);
FS_Printf(f, "%d\n", current_skill);
- FS_Printf(f, "%s\n", sv.name);
+ FS_Printf(f, "%s\n", sv.worldbasename);
FS_Printf(f, "%f\n",sv.time);
}
else