From: Thomas Debesse Date: Sat, 24 Apr 2021 00:33:31 +0000 (+0200) Subject: vfs/dpk: properly find the dpkdir, even for maps not in maps/, typically mapmodel... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d1d8fd041cec01b7780e59e7ac19deab4730bb11;p=xonotic%2Fnetradiant.git vfs/dpk: properly find the dpkdir, even for maps not in maps/, typically mapmodel sources --- diff --git a/plugins/vfspk3/vfs.cpp b/plugins/vfspk3/vfs.cpp index 44c2ebb5..5871f991 100644 --- a/plugins/vfspk3/vfs.cpp +++ b/plugins/vfspk3/vfs.cpp @@ -347,6 +347,9 @@ static const char* GetLatestDpkPakVersion( const char* name ){ } // release string after using +// Note: it also contains the version string, +// for …/src/map-castle_src.dpkdir/maps/castle.map +// it will return map-castle_src static char* GetCurrentMapDpkPakName(){ char* mapdir; char* mapname; @@ -356,21 +359,27 @@ static char* GetCurrentMapDpkPakName(){ mapname = string_clone( GlobalRadiant().getMapName() ); mapnamelen = string_length( mapname ); - mapdir = strrchr( mapname, '/' ); - if ( mapdir ) { - mapdir -= 12; - if ( strncmp( mapdir, ".dpkdir/maps/", 13 ) == 0 ) { - *mapdir = '\0'; - mapdir = strrchr( mapname, '/' ); - if ( mapdir ) mapdir++; - else mapdir = mapname; - result = string_clone( mapdir ); + char pattern[] = ".dpkdir/"; + char* end = strstr( mapname, ".dpkdir/" ); + if ( end ) + { + end[ 0 ] = '\0'; + + mapdir = strrchr( mapname, '/' ); + if ( mapdir ) + { + mapdir++; + } + else + { + mapdir = mapname; } + + result = string_clone( mapdir ); } string_release( mapname, mapnamelen ); return result; - } // prevent loading duplicates or circular references