diff options
Diffstat (limited to 'src/fios.cpp')
-rw-r--r-- | src/fios.cpp | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/src/fios.cpp b/src/fios.cpp index ffbe57375..e948b5680 100644 --- a/src/fios.cpp +++ b/src/fios.cpp @@ -561,8 +561,9 @@ void FiosGetHeightmapList(SaveLoadDialogMode mode) /** Basic data to distinguish a scenario. Used in the server list window */ struct ScenarioIdentifier { - uint32 scenid; ///< ID for the scenario (generated by content) - uint8 md5sum[16]; ///< MD5 checksum of file + uint32 scenid; ///< ID for the scenario (generated by content). + uint8 md5sum[16]; ///< MD5 checksum of file. + char filename[MAX_PATH]; ///< filename of the file. bool operator == (const ScenarioIdentifier &other) const { @@ -606,6 +607,7 @@ public: int fret = fscanf(f, "%i", &id.scenid); FioFCloseFile(f); if (fret != 1) return false; + strecpy(id.filename, filename, lastof(id.filename)); Md5 checksum; uint8 buffer[1024]; @@ -638,24 +640,34 @@ public: static ScenarioScanner _scanner; /** - * Check whether we've got a given scenario based on its unique ID. - * @param ci the content info to compare it to - * @param md5sum whether to look at the md5sum or the id - * @return true if we've got the scenario + * Find a given scenario based on its unique ID. + * @param ci The content info to compare it to. + * @param md5sum Whether to look at the md5sum or the id. + * @return The filename of the file, else \c NULL. */ -bool HasScenario(const ContentInfo *ci, bool md5sum) +const char *FindScenario(const ContentInfo *ci, bool md5sum) { _scanner.Scan(false); for (ScenarioIdentifier *id = _scanner.Begin(); id != _scanner.End(); id++) { - if (md5sum ? - (memcmp(id->md5sum, ci->md5sum, sizeof(id->md5sum)) == 0) : - (id->scenid == ci->unique_id)) { - return true; + if (md5sum ? (memcmp(id->md5sum, ci->md5sum, sizeof(id->md5sum)) == 0) + : (id->scenid == ci->unique_id)) { + return id->filename; } } - return false; + return NULL; +} + +/** + * Check whether we've got a given scenario based on its unique ID. + * @param ci The content info to compare it to. + * @param md5sum Whether to look at the md5sum or the id. + * @return True iff we've got the scenario. + */ +bool HasScenario(const ContentInfo *ci, bool md5sum) +{ + return (FindScenario(ci, md5sum) != NULL); } /** |