Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==== Daemon:src/common/FileSystem.cpp ====
- // Pak zip and directory extensions
- #define LEGACY_PAK_ZIP_EXT ".pk3"
- #define LEGACY_PAK_DIR_EXT ".pk3dir/"
- #define PAK_ZIP_EXT ".dpk"
- #define PAK_DIR_EXT ".dpkdir/"
- // Add a pak to the list of available paks
- static void AddPak(pakType_t type, Str::StringRef filename, Str::StringRef basePath)
- {
- std::string fullPath = Path::Build(basePath, filename);
- if (!UseLegacyPaks()) {
- size_t suffixLen = type == pakType_t::PAK_DIR ? strlen(PAK_DIR_EXT) : strlen(PAK_ZIP_EXT);
- } else {
- size_t suffixLen = type == pakType_t::PAK_DIR ? strlen(LEGACY_PAK_DIR_EXT) : strlen(LEGACY_PAK_ZIP_EXT);
- }
- std::string name, version;
- Util::optional<uint32_t> checksum;
- if (!ParsePakName(filename.begin(), filename.end() - suffixLen, name, version, checksum) || (type == pakType_t::PAK_DIR && checksum)) {
- if (!UseLegacyPaks()) {
- fsLogs.Warn("Invalid pak name: %s", fullPath);
- return;
- } else {
- fsLogs.Notice("Loading legacy pak: %s", fullPath);
- name = filename.substr(0, filename.size() - suffixLen);
- // prefer versioned dpk over legacy pk3 if pak name collides, uses the smallest version string available
- // this version can't be found in standard dpk, so we can also uses this value to test later if it's a legacy pk3
- version = "";
- }
- }
- availablePaks.push_back({std::move(name), std::move(version), checksum, type, std::move(fullPath)});
- }
- // ==== Daemon:src/engine/server/sv_client.cpp ====
- /*
- ==================
- SV_WriteDownloadToClient
- Check to see if the client wants a file, open it if needed and start pumping the client
- Fill up msg with data
- ==================
- */
- void SV_WriteDownloadToClient( client_t *cl, msg_t *msg )
- {
- …
- if ( version.compare("") == 0 ) {
- // legacy pak
- std::string pakName = name + ".pk3";
- } else {
- // versionned pak
- std::string pakName = name + "_" + version + ".dpk";
- }
- …
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement