0.9.24 merge of physfs tweak
authornemo
Thu, 17 May 2018 20:04:39 -0400
changeset 13399 7b4726ef2308
parent 13397 ff1fb8757026 (current diff)
parent 13398 ae5d6448c5be (diff)
child 13401 a52b8b8cbac4
0.9.24 merge of physfs tweak
hedgewars/uScript.pas
--- a/hedgewars/uScript.pas	Wed May 16 19:36:49 2018 -0400
+++ b/hedgewars/uScript.pas	Thu May 17 20:04:39 2018 -0400
@@ -3478,7 +3478,7 @@
 if f = nil then
     exit;
 
-hedgewarsMountPackage(Str2PChar(copy(s, 1, length(s)-4)+'.hwp'));
+hedgewarsMountPackage(Str2PChar(copy(s, 3, length(s)-6)+'.hwp'));
 
 physfsReaderSetBuffer(@buf);
 if Pos('Locale/',s) <> 0 then
--- a/misc/libphysfs/archiver_zip.c	Wed May 16 19:36:49 2018 -0400
+++ b/misc/libphysfs/archiver_zip.c	Thu May 17 20:04:39 2018 -0400
@@ -468,6 +468,7 @@
     finfo->io = zip_get_io(origfinfo->io, NULL, finfo->entry);
     GOTO_IF_MACRO(!finfo->io, ERRPASS, failed);
 
+	initializeZStream(&finfo->stream);
     if (finfo->entry->compression_method != COMPMETH_NONE)
     {
         finfo->buffer = (PHYSFS_uint8 *) allocator.Malloc(ZIP_READBUFSIZE);
--- a/misc/libphyslayer/hwpacksmounter.c	Wed May 16 19:36:49 2018 -0400
+++ b/misc/libphyslayer/hwpacksmounter.c	Thu May 17 20:04:39 2018 -0400
@@ -37,20 +37,37 @@
 PHYSFS_DECL void hedgewarsMountPackage(char * fileName)
 {
     int fileNameLength = strlen(fileName);
+    int dirLength = 0;
     if (fileNameLength > 4)
         if (strcmp(fileName + fileNameLength - 4, ".hwp") == 0)
         {
             const char * dir = PHYSFS_getRealDir(fileName);
             if(dir)
             {
-                char * fullPath = (char *)malloc(strlen(dir) + fileNameLength + 2);
-                strcpy(fullPath, dir);
-                strcat(fullPath, "/");
-                strcat(fullPath, fileName);
+				dirLength = strlen(dir);
+				if (dirLength > 4)
+				{
+					if (strcmp(dir + dirLength - 4, ".hwp") == 0)
+					{
+						char * uniqName = (char *)malloc(strlen(dir) + fileNameLength + 2);
+						strcpy(uniqName, dir);
+						strcat(uniqName, ",");
+						strcat(uniqName, fileName);
+						PHYSFS_mountHandle(PHYSFS_openRead(fileName), uniqName, NULL, 0);
+						free(uniqName);
+					}
+					else
+					{
+						char * fullPath = (char *)malloc(strlen(dir) + fileNameLength + 2);
+						strcpy(fullPath, dir);
+						strcat(fullPath, "/");
+						strcat(fullPath, fileName);
 
-                PHYSFS_mount(fullPath, NULL, 0);
+						PHYSFS_mount(fullPath, NULL, 0);
 
-                free(fullPath);
+						free(fullPath);
+					}
+				}
             }
         }
 }