@@ -30,6 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030
3131#if defined(BUILD_ENGINE)
3232#include " minizip/unzip.h"
33+ #include " DaemonEmbedded/EngineMedia.h"
3334#endif
3435
3536#ifdef BUILD_VM
@@ -129,6 +130,15 @@ static Cvar::Cvar<bool> fs_legacypaks("fs_legacypaks", "also load pk3s, ignoring
129130static Cvar::Cvar<int > fs_maxSymlinkDepth (" fs_maxSymlinkDepth" , " max depth of symlinks in zip paks (0 means disabled)" , Cvar::NONE, 1 );
130131static Cvar::Cvar<std::string> fs_pakprefixes (" fs_pakprefixes" , " prefixes to look for paks to load" , 0 , " " );
131132
133+ const PakInfo builtinPak =
134+ {
135+ " *builtin" ,
136+ ENGINE_VERSION,
137+ 0 ,
138+ pakType_t::PAK_BUILTIN,
139+ " *builtin" ,
140+ };
141+
132142bool UseLegacyPaks ()
133143{
134144 return fs_legacypaks.Get ();
@@ -1258,6 +1268,7 @@ static void InternalLoadPak(
12581268 offset_t depsOffset = 0 ;
12591269 ZipArchive zipFile;
12601270 bool isLegacy = pak.version .empty ();
1271+ bool isBuiltin = pak.type == pakType_t::PAK_BUILTIN;
12611272
12621273 // Check if this pak has already been loaded to avoid recursive dependencies
12631274 for (auto & x: loadedPaks) {
@@ -1279,6 +1290,8 @@ static void InternalLoadPak(
12791290 } else {
12801291 fsLogs.WithoutSuppression ().Notice (" Loading legacy pakdir '%s'..." , pak.path .c_str ());
12811292 }
1293+ } else if (pak.type == pakType_t::PAK_BUILTIN ) {
1294+ fsLogs.WithoutSuppression ().Notice (" Loading builtin pak '%s'..." , pak.path .c_str ());
12821295 } else {
12831296 ASSERT_UNREACHABLE ();
12841297 }
@@ -1369,6 +1382,10 @@ static void InternalLoadPak(
13691382 }, err);
13701383 if (err)
13711384 return ;
1385+ } else if (pak.type == pakType_t::PAK_BUILTIN) {
1386+ for ( auto it : EngineMedia::FileMap ) {
1387+ fileMap.emplace (it.first , std::pair<uint32_t , offset_t >(loadedPaks.size () - 1 , 0 ));
1388+ }
13721389 } else {
13731390 ASSERT_UNREACHABLE ();
13741391 }
@@ -1388,8 +1405,8 @@ static void InternalLoadPak(
13881405
13891406 loadedPak.pathPrefix = pathPrefix;
13901407
1391- // Legacy paks don't have version neither checksum
1392- if (!isLegacy) {
1408+ // Legacy and builtin paks don't have version neither checksum
1409+ if (!isLegacy && !isBuiltin ) {
13931410 // If an explicit checksum was requested, verify that the pak we loaded is the one we are expecting
13941411 if (expectedChecksum && realChecksum != *expectedChecksum) {
13951412 SetErrorCodeFilesystem (err, filesystem_error::wrong_pak_checksum, pak.path );
@@ -1589,6 +1606,8 @@ std::string ReadFile(Str::StringRef path, std::error_code& err)
15891606 return " " ;
15901607
15911608 return out;
1609+ } else if (pak.type == pakType_t::PAK_BUILTIN) {
1610+ return EngineMedia::ReadFile (it->first );
15921611 }
15931612
15941613 ASSERT_UNREACHABLE ();
@@ -2660,6 +2679,13 @@ static const PakInfo* FindPakNoPrefix(Str::StringRef name)
26602679
26612680const PakInfo* FindPak (Str::StringRef name)
26622681{
2682+ #if defined(BUILD_ENGINE)
2683+ if (name == builtinPak.name )
2684+ {
2685+ return &builtinPak;
2686+ }
2687+ #endif
2688+
26632689 Cmd::Args pakprefixes (Cvar::GetValue (" fs_pakprefixes" ));
26642690 for (const std::string &pakprefix: pakprefixes)
26652691 {
0 commit comments