diff --git a/doomsday/engine/api/dd_share.h b/doomsday/engine/api/dd_share.h index 2fd1fdf8bf..def17d9bab 100644 --- a/doomsday/engine/api/dd_share.h +++ b/doomsday/engine/api/dd_share.h @@ -1727,7 +1727,7 @@ typedef struct serverinfo_s { char gameConfig[40]; char map[20]; char clientNames[128]; - unsigned int wadNumber; + unsigned int loadedFilesCRC; char iwad[32]; ///< Obsolete. char pwads[128]; int data[3]; diff --git a/doomsday/engine/include/filesys/fs_main.h b/doomsday/engine/include/filesys/fs_main.h index 59ee332bfd..d0490c0beb 100644 --- a/doomsday/engine/include/filesys/fs_main.h +++ b/doomsday/engine/include/filesys/fs_main.h @@ -272,6 +272,11 @@ namespace de /// Register the console commands, variables, etc..., of this module. static void consoleRegister(); + /** + * @post No more WADs will be loaded in startup mode. + */ + void endStartup(); + /** * @param name Unique symbolic name of this namespace. Must be at least * @c Namespace::min_name_length characters long. @@ -279,12 +284,6 @@ namespace de */ Namespace& createNamespace(String name, Namespace::Flags flags = 0); - /** - * Reset all the namespaces, returning them to an empty state and clearing - * any @ref ExtraPaths which have been registered since construction. - */ - void resetAllNamespaces(); - /** * Lookup a Namespace by symbolic name. * @@ -293,13 +292,14 @@ namespace de */ Namespace* namespaceByName(String name); - /// Returns the namespaces for efficient traversal. - Namespaces const& namespaces(); - /** - * @post No more WADs will be loaded in startup mode. + * Reset all the namespaces, returning them to an empty state and clearing + * any @ref ExtraPaths which have been registered since construction. */ - void endStartup(); + void resetAllNamespaces(); + + /// Returns the namespaces for efficient traversal. + Namespaces const& namespaces(); /** * Add a new path mapping from source to destination in the vfs. @@ -309,10 +309,8 @@ namespace de /** * Clears all virtual path mappings. - * - * @return This instance. */ - FS1& clearPathMappings(); + void clearPathMappings(); /** * Add a new lump mapping so that @a lumpName becomes visible at @a destination. @@ -324,13 +322,12 @@ namespace de * * @return This instance. */ - FS1& clearPathLumpMappings(); + void clearPathLumpMappings(); /** - * Reset known fileId records so that the next time checkFileId() is called for - * a filepath, it will pass. + * @return @c true if a file exists at @a path which can be opened for reading. */ - void resetFileIds(); + bool accessFile(Uri const& path); /** * Maintains a list of identifiers already seen. @@ -341,26 +338,28 @@ namespace de bool checkFileId(Uri const& path); /** - * @return @c true if a file exists at @a path which can be opened for reading. + * Reset known fileId records so that the next time checkFileId() is called for + * a filepath, it will pass. */ - bool accessFile(Uri const& path); + void resetFileIds(); /** * Indexes @a file (which must have been opened with this file system) into * this file system and adds it to the list of loaded files. * * @param file The file to index. Assumed to have not yet been indexed! - * - * @return This instance. */ - FS1& index(File1& file); + void index(File1& file); /** * Removes a file from any lump indexes. * * @param file File to remove from the index. */ - FS1& deindex(File1& file); + void deindex(File1& file); + + /// Clear all references to this file. + void releaseFile(File1& file); /** * Lookup a lump by name. @@ -425,9 +424,6 @@ namespace de */ FileHandle& openLump(File1& lump); - /// Clear all references to this file. - void releaseFile(File1& file); - /** * Find a single file. * @@ -529,11 +525,6 @@ namespace de */ void printDirectory(String path); - /** - * Calculate a CRC for the loaded file list. - */ - uint loadedFilesCRC(); - /** * Try to open the specified WAD archive into the auxiliary lump index. * @@ -546,11 +537,16 @@ namespace de */ void closeAuxiliaryPrimaryIndex(); + /** + * Calculate a CRC for the loaded file list. + */ + uint loadedFilesCRC(); + /** * Unload all files loaded after startup. * @return Number of files unloaded. */ - FS1& unloadAllNonStartupFiles(int* numUnloaded = 0); + int unloadAllNonStartupFiles(); private: struct Instance; @@ -599,7 +595,7 @@ void F_Shutdown(void); void F_EndStartup(void); -void F_UnloadAllNonStartupFiles(int* numUnloaded); +int F_UnloadAllNonStartupFiles(); void F_AddVirtualDirectoryMapping(char const* nativeSourcePath, char const* nativeDestinationPath); @@ -663,7 +659,7 @@ void F_UnlockLump(struct file1_s* file, int lumpIdx); */ void F_ComposePWADFileList(char* outBuf, size_t outBufSize, const char* delimiter); -uint F_CRCNumber(void); +uint F_LoadedFilesCRC(void); lumpnum_t F_OpenAuxiliary2(char const* nativePath, size_t baseOffset); lumpnum_t F_OpenAuxiliary(char const* nativePath/*, baseOffset = 0 */); diff --git a/doomsday/engine/src/filesys/fs_main.cpp b/doomsday/engine/src/filesys/fs_main.cpp index 381ee5328d..577c6be56d 100644 --- a/doomsday/engine/src/filesys/fs_main.cpp +++ b/doomsday/engine/src/filesys/fs_main.cpp @@ -460,7 +460,13 @@ FS1::~FS1() FS1::Namespace& FS1::createNamespace(String name, Namespace::Flags flags) { DENG_ASSERT(name.length() >= Namespace::min_name_length); - Namespace* fnamespace = new Namespace(name, flags); + + // Ensure this is a unique name. + Namespace* fnamespace = namespaceByName(name); + if(fnamespace) return *fnamespace; + + // Create a new namespace. + fnamespace = new Namespace(name, flags); d->namespaces.insert(name.toLower(), fnamespace); return *fnamespace; } @@ -518,7 +524,7 @@ static FS1::FileList::iterator findListFileByPath(FS1::FileList& list, String pa return i; } -FS1& FS1::index(de::File1& file) +void FS1::index(de::File1& file) { #ifdef DENG_DEBUG // Ensure this hasn't yet been indexed. @@ -560,14 +566,12 @@ FS1& FS1::index(de::File1& file) // Add a handle to the loaded files list. FileHandle* loadedFilesHndl = FileHandleBuilder::fromFile(file); d->loadedFiles.push_back(loadedFilesHndl); loadedFilesHndl->setList(reinterpret_cast(&d->loadedFiles)); - - return *this; } -FS1& FS1::deindex(de::File1& file) +void FS1::deindex(de::File1& file) { FileList::iterator found = findListFile(d->loadedFiles, file); - if(found == d->loadedFiles.end()) return *this; // Most peculiar.. + if(found == d->loadedFiles.end()) return; // Most peculiar.. QByteArray path = file.composePath().toUtf8(); d->releaseFileId(path.constData()); @@ -579,8 +583,6 @@ FS1& FS1::deindex(de::File1& file) d->loadedFiles.erase(found); delete *found; - - return *this; } de::File1& FS1::find(de::Uri const& search) @@ -701,7 +703,7 @@ static void printFileList(FS1::FileList& list) } #endif -FS1& FS1::unloadAllNonStartupFiles(int* retNumUnloaded) +int FS1::unloadAllNonStartupFiles() { #if _DEBUG // List all open files with their identifiers. @@ -734,8 +736,7 @@ FS1& FS1::unloadAllNonStartupFiles(int* retNumUnloaded) } #endif - if(retNumUnloaded) *retNumUnloaded = numUnloadedFiles; - return *this; + return numUnloadedFiles; } bool FS1::checkFileId(de::Uri const& path) @@ -1260,10 +1261,9 @@ void FS1::mapPathToLump(String lumpName, String destination) LOG_VERBOSE("Path \"%s\" now mapped to lump \"%s\"") << NativePath(ldm->first).pretty() << ldm->second; } -FS1& FS1::clearPathLumpMappings() +void FS1::clearPathLumpMappings() { d->lumpMappings.clear(); - return *this; } /// @return @c true iff the mapping matched the path. @@ -1313,10 +1313,9 @@ void FS1::mapPath(String source, String destination) << NativePath(pm->second).pretty() << NativePath(pm->first).pretty(); } -FS1& FS1::clearPathMappings() +void FS1::clearPathMappings() { d->pathMappings.clear(); - return *this; } void FS1::printDirectory(String path) @@ -1636,9 +1635,9 @@ void F_EndStartup(void) App_FileSystem()->endStartup(); } -void F_UnloadAllNonStartupFiles(int* numUnloaded) +int F_UnloadAllNonStartupFiles(void) { - App_FileSystem()->unloadAllNonStartupFiles(numUnloaded); + return App_FileSystem()->unloadAllNonStartupFiles(); } void F_AddVirtualDirectoryMapping(char const* nativeSourcePath, char const* nativeDestinationPath) @@ -2027,7 +2026,7 @@ void F_ComposePWADFileList(char* outBuf, size_t outBufSize, char const* delimite strncpy(outBuf, strUtf8.constData(), outBufSize); } -uint F_CRCNumber(void) +uint F_LoadedFilesCRC(void) { return App_FileSystem()->loadedFilesCRC(); } diff --git a/doomsday/engine/src/network/net_main.c b/doomsday/engine/src/network/net_main.c index 21d1a4c8a1..ef4af669a9 100644 --- a/doomsday/engine/src/network/net_main.c +++ b/doomsday/engine/src/network/net_main.c @@ -888,7 +888,7 @@ void Net_PrintServerInfo(int index, serverinfo_t *info) info->canJoin ? ' ' : '*', info->version, info->plugin, info->address, info->port); Con_Printf(" %s p:%ims %-40s\n", info->map, info->ping, info->description); - Con_Printf(" %s (crc:%x) %s\n", info->gameIdentityKey, info->wadNumber, info->gameConfig); + Con_Printf(" %s (crc:%x) %s\n", info->gameIdentityKey, info->loadedFilesCRC, info->gameConfig); // Optional: PWADs in use. if(info->pwads[0]) diff --git a/doomsday/engine/src/network/ui_mpi.c b/doomsday/engine/src/network/ui_mpi.c index e588ae7a78..f2f0d3d783 100644 --- a/doomsday/engine/src/network/ui_mpi.c +++ b/doomsday/engine/src/network/ui_mpi.c @@ -334,7 +334,7 @@ void MPIUpdateServerInfo(ui_object_t *ob) sprintf(warningString, "This server is using %x, " "but you have %x. " - "Errors may occur during game play.", info.wadNumber, myCrc); + "Errors may occur during game play.", info.loadedFilesCRC, myCrc); // Show IWAD warning? if(!(lst_found.count >= 1 && lst_found.selection >= 0 && @@ -469,7 +469,7 @@ void MPIUpdateServerList(void) memset(&info, 0, sizeof(info)); N_GetHostInfo(i, &info); MPIFormatServerInfo(lstit_found[i].text, &info); - lstit_found[i].data = info.wadNumber; + lstit_found[i].data = info.loadedFilesCRC; lstit_found[i].data2 = i; } lst_found.count = num; @@ -495,7 +495,7 @@ void MPIUpdateServerList(void) } MPIFormatServerInfo(lstit_found[k].text, &info); - lstit_found[k].data = info.wadNumber; + lstit_found[k].data = info.loadedFilesCRC; // Connection will be formed using this index. lstit_found[k].data2 = i; k++; @@ -656,7 +656,7 @@ void DD_NetSetup(int serverMode) UI_FlagGroup(ob_client, 4, UIF_HIDDEN, searchMode == SEARCH_MASTER); lst_found.selection = -1; lst_found.count = 0; - myCrc = F_CRCNumber(); + myCrc = F_LoadedFilesCRC(); UI_FlagGroup(ob_client, 5, UIF_DISABLED, true); // warnings UI_FlagGroup(ob_client, UIG_CONNECT, UIF_DISABLED, true); MPIUpdateServerList(); diff --git a/doomsday/engine/src/server/sv_main.c b/doomsday/engine/src/server/sv_main.c index 8c07ce2742..8062343d8f 100644 --- a/doomsday/engine/src/server/sv_main.c +++ b/doomsday/engine/src/server/sv_main.c @@ -118,7 +118,7 @@ void Sv_GetInfo(serverinfo_t* info) F_ComposePWADFileList(info->pwads, sizeof(info->pwads), ";"); // This should be a CRC number that describes all the loaded data. - info->wadNumber = F_CRCNumber(); + info->loadedFilesCRC = F_LoadedFilesCRC(); } /** @@ -136,7 +136,7 @@ size_t Sv_InfoToString(serverinfo_t* info, ddstring_t* msg) Str_Appendf(msg, "mode:%s\n", info->gameIdentityKey); Str_Appendf(msg, "setup:%s\n", info->gameConfig); Str_Appendf(msg, "iwad:%s\n", info->iwad); - Str_Appendf(msg, "wcrc:%i\n", info->wadNumber); + Str_Appendf(msg, "wcrc:%i\n", info->loadedFilesCRC); Str_Appendf(msg, "pwads:%s\n", info->pwads); Str_Appendf(msg, "map:%s\n", info->map); Str_Appendf(msg, "nump:%i\n", info->numPlayers); @@ -247,7 +247,7 @@ boolean Sv_StringToInfo(const char *valuePair, serverinfo_t *info) } else if(!strcmp(label, "wcrc")) { - info->wadNumber = strtol(value, 0, 0); + info->loadedFilesCRC = strtol(value, 0, 0); } else if(!strcmp(label, "pwads")) {