Advertisement
illwieckz

daemon legacy pak empty version string

Mar 26th, 2017
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.91 KB | None | 0 0
  1. // ==== Daemon:src/common/FileSystem.cpp ====
  2.  
  3. // Pak zip and directory extensions
  4. #define LEGACY_PAK_ZIP_EXT ".pk3"
  5. #define LEGACY_PAK_DIR_EXT ".pk3dir/"
  6. #define PAK_ZIP_EXT ".dpk"
  7. #define PAK_DIR_EXT ".dpkdir/"
  8.  
  9. // Add a pak to the list of available paks
  10. static void AddPak(pakType_t type, Str::StringRef filename, Str::StringRef basePath)
  11. {
  12.     std::string fullPath = Path::Build(basePath, filename);
  13.  
  14.     if (!UseLegacyPaks()) {
  15.         size_t suffixLen = type == pakType_t::PAK_DIR ? strlen(PAK_DIR_EXT) : strlen(PAK_ZIP_EXT);
  16.     } else {
  17.         size_t suffixLen = type == pakType_t::PAK_DIR ? strlen(LEGACY_PAK_DIR_EXT) : strlen(LEGACY_PAK_ZIP_EXT);
  18.     }
  19.     std::string name, version;
  20.     Util::optional<uint32_t> checksum;
  21.     if (!ParsePakName(filename.begin(), filename.end() - suffixLen, name, version, checksum) || (type == pakType_t::PAK_DIR && checksum)) {
  22.         if (!UseLegacyPaks()) {
  23.             fsLogs.Warn("Invalid pak name: %s", fullPath);
  24.             return;
  25.         } else {
  26.             fsLogs.Notice("Loading legacy pak: %s", fullPath);
  27.             name = filename.substr(0, filename.size() - suffixLen);
  28.             // prefer versioned dpk over legacy pk3 if pak name collides, uses the smallest version string available
  29.             // 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
  30.             version = "";
  31.         }
  32.     }
  33.  
  34.     availablePaks.push_back({std::move(name), std::move(version), checksum, type, std::move(fullPath)});
  35. }
  36.  
  37. // ==== Daemon:src/engine/server/sv_client.cpp ====
  38.  
  39. /*
  40. ==================
  41. SV_WriteDownloadToClient
  42.  
  43. Check to see if the client wants a file, open it if needed and start pumping the client
  44. Fill up msg with data
  45. ==================
  46. */
  47. void SV_WriteDownloadToClient( client_t *cl, msg_t *msg )
  48. {
  49.             if ( version.compare("") == 0 ) {
  50.                 // legacy pak
  51.                 std::string pakName = name + ".pk3";
  52.             } else {
  53.                 // versionned pak
  54.                 std::string pakName = name + "_" + version + ".dpk";
  55.             }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement