Index | Thread | Search

From:
Brad Smith <brad@comstyle.com>
Subject:
UPDATE: wargus
To:
ports@openbsd.org
Date:
Thu, 3 Sep 2026 02:54:01 -0400

Download raw body.

Thread
  • Brad Smith:

    UPDATE: wargus

Fix building on big endian archs.


Index: Makefile
===================================================================
RCS file: /cvs/ports/games/wargus/Makefile,v
retrieving revision 1.3
diff -u -p -u -p -r1.3 Makefile
--- Makefile	4 Mar 2026 10:21:05 -0000	1.3
+++ Makefile	3 Sep 2026 06:30:49 -0000
@@ -3,6 +3,7 @@ COMMENT=		Warcraft 2 Mod
 GH_ACCOUNT=		Wargus
 GH_PROJECT=		wargus
 GH_TAGNAME=		v3.3.2
+REVISION=		0
 CATEGORIES=		games
 
 HOMEPAGE=		http://stratagus.com/
@@ -33,7 +34,11 @@ MODCMAKE_POLICY_VERSION_OVERRIDE = Yes
 
 MODCMAKE_LDFLAGS+=	-L${LOCALBASE}/lib
 
-FIX_CRLF_FILES=		StormLib/src/FileStream.cpp
+FIX_CRLF_FILES=		StormLib/src/SBaseCommon.cpp \
+			StormLib/src/SFileAttributes.cpp \
+			StormLib/src/SFilePatchArchives.cpp \
+			StormLib/src/StormLib.h \
+			StormLib/src/StormPort.h \
 
 pre-configure:
 	find ${WRKSRC}/ -name "CMakeLists.txt" -type f -exec sed -i \
Index: patches/patch-StormLib_src_FileStream_cpp
===================================================================
RCS file: patches/patch-StormLib_src_FileStream_cpp
diff -N patches/patch-StormLib_src_FileStream_cpp
--- patches/patch-StormLib_src_FileStream_cpp	13 Feb 2025 20:49:41 -0000	1.1.1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,81 +0,0 @@
-Index: StormLib/src/FileStream.cpp
---- StormLib/src/FileStream.cpp.orig
-+++ StormLib/src/FileStream.cpp
-@@ -109,7 +109,7 @@ static bool BaseFile_Create(TFileStream * pStream)
-     {
-         intptr_t handle;
- 
--        handle = open(pStream->szFileName, O_RDWR | O_CREAT | O_TRUNC | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-+        handle = open(pStream->szFileName, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-         if(handle == -1)
-         {
-             pStream->Base.File.hFile = INVALID_HANDLE_VALUE;
-@@ -157,12 +157,12 @@ static bool BaseFile_Open(TFileStream * pStream, const
- 
- #if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX)
-     {
--        struct stat64 fileinfo;
-+        struct stat fileinfo;
-         int oflag = (dwStreamFlags & STREAM_FLAG_READ_ONLY) ? O_RDONLY : O_RDWR;
-         intptr_t handle;
- 
-         // Open the file
--        handle = open(szFileName, oflag | O_LARGEFILE);
-+        handle = open(szFileName, oflag);
-         if(handle == -1)
-         {
-             pStream->Base.File.hFile = INVALID_HANDLE_VALUE;
-@@ -171,7 +171,7 @@ static bool BaseFile_Open(TFileStream * pStream, const
-         }
- 
-         // Get the file size
--        if(fstat64(handle, &fileinfo) == -1)
-+        if(fstat(handle, &fileinfo) == -1)
-         {
-             pStream->Base.File.hFile = INVALID_HANDLE_VALUE;
-             dwLastError = errno;
-@@ -234,7 +234,7 @@ static bool BaseFile_Read(
-         // we have to update the file position   xxx
-         if(ByteOffset != pStream->Base.File.FilePos)
-         {
--            lseek64((intptr_t)pStream->Base.File.hFile, (off64_t)(ByteOffset), SEEK_SET);
-+            lseek((intptr_t)pStream->Base.File.hFile, (off_t)(ByteOffset), SEEK_SET);
-             pStream->Base.File.FilePos = ByteOffset;
-         }
- 
-@@ -305,7 +305,7 @@ static bool BaseFile_Write(TFileStream * pStream, ULON
-         // we have to update the file position
-         if(ByteOffset != pStream->Base.File.FilePos)
-         {
--            lseek64((intptr_t)pStream->Base.File.hFile, (off64_t)(ByteOffset), SEEK_SET);
-+            lseek((intptr_t)pStream->Base.File.hFile, (off_t)(ByteOffset), SEEK_SET);
-             pStream->Base.File.FilePos = ByteOffset;
-         }
- 
-@@ -366,7 +366,7 @@ static bool BaseFile_Resize(TFileStream * pStream, ULO
- 
- #if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX)
-     {
--        if(ftruncate64((intptr_t)pStream->Base.File.hFile, (off64_t)NewFileSize) == -1)
-+        if(ftruncate((intptr_t)pStream->Base.File.hFile, (off_t)NewFileSize) == -1)
-         {
-             dwLastError = errno;
-             return false;
-@@ -566,7 +566,7 @@ static bool BaseMap_Open(TFileStream * pStream, LPCTST
- 
- #elif defined(STORMLIB_HAS_MMAP)
- 
--    struct stat64 fileinfo;
-+    struct stat fileinfo;
-     intptr_t handle;
-     bool bResult = false;
- 
-@@ -575,7 +575,7 @@ static bool BaseMap_Open(TFileStream * pStream, LPCTST
-     if(handle != -1)
-     {
-         // Get the file size
--        if(fstat64(handle, &fileinfo) != -1)
-+        if(fstat(handle, &fileinfo) != -1)
-         {
-             pStream->Base.Map.pbFile = (LPBYTE)mmap(NULL, (size_t)fileinfo.st_size, PROT_READ, MAP_PRIVATE, handle, 0);
-             if(pStream->Base.Map.pbFile != NULL)
Index: patches/patch-StormLib_src_SBaseCommon_cpp
===================================================================
RCS file: patches/patch-StormLib_src_SBaseCommon_cpp
diff -N patches/patch-StormLib_src_SBaseCommon_cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-StormLib_src_SBaseCommon_cpp	3 Sep 2026 06:30:49 -0000
@@ -0,0 +1,40 @@
+- Apply StormLib big-endian build fixes to the vendored copy
+  cde1a0718a0058cc651ecd56ff8149fc39f624e9
+
+Index: StormLib/src/SBaseCommon.cpp
+--- StormLib/src/SBaseCommon.cpp.orig
++++ StormLib/src/SBaseCommon.cpp
+@@ -1915,7 +1915,7 @@ void ConvertTMPQHeader(void *header, uint16_t version)
+ 	TMPQHeader * theHeader = (TMPQHeader *)header;
+ 
+     // Swap header part version 1
+-    if(version == MPQ_FORMAT_VERSION_1)
++    if(version >= MPQ_FORMAT_VERSION_1)
+     {
+ 	    theHeader->dwID = SwapUInt32(theHeader->dwID);
+ 	    theHeader->dwHeaderSize = SwapUInt32(theHeader->dwHeaderSize);
+@@ -1928,21 +1928,21 @@ void ConvertTMPQHeader(void *header, uint16_t version)
+ 	    theHeader->dwBlockTableSize = SwapUInt32(theHeader->dwBlockTableSize);
+     }
+ 
+-	if(version == MPQ_FORMAT_VERSION_2)
++	if(version >= MPQ_FORMAT_VERSION_2)
+ 	{
+ 		theHeader->HiBlockTablePos64 = SwapUInt64(theHeader->HiBlockTablePos64);
+         theHeader->wHashTablePosHi = SwapUInt16(theHeader->wHashTablePosHi);
+ 		theHeader->wBlockTablePosHi = SwapUInt16(theHeader->wBlockTablePosHi);
+     }
+ 
+-    if(version == MPQ_FORMAT_VERSION_3)
++    if(version >= MPQ_FORMAT_VERSION_3)
+     {
+         theHeader->ArchiveSize64 = SwapUInt64(theHeader->ArchiveSize64);
+         theHeader->BetTablePos64 = SwapUInt64(theHeader->BetTablePos64);
+         theHeader->HetTablePos64 = SwapUInt64(theHeader->HetTablePos64);
+     }
+ 
+-    if(version == MPQ_FORMAT_VERSION_4)
++    if(version >= MPQ_FORMAT_VERSION_4)
+ 	{
+         theHeader->HashTableSize64    = SwapUInt64(theHeader->HashTableSize64);
+         theHeader->BlockTableSize64   = SwapUInt64(theHeader->BlockTableSize64);
Index: patches/patch-StormLib_src_SFileAttributes_cpp
===================================================================
RCS file: patches/patch-StormLib_src_SFileAttributes_cpp
diff -N patches/patch-StormLib_src_SFileAttributes_cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-StormLib_src_SFileAttributes_cpp	3 Sep 2026 06:30:49 -0000
@@ -0,0 +1,24 @@
+- Apply StormLib big-endian build fixes to the vendored copy
+  cde1a0718a0058cc651ecd56ff8149fc39f624e9
+
+Index: StormLib/src/SFileAttributes.cpp
+--- StormLib/src/SFileAttributes.cpp.orig
++++ StormLib/src/SFileAttributes.cpp
+@@ -180,7 +180,7 @@ static DWORD LoadAttributesFile(TMPQArchive * ha, LPBY
+         if((pbAttrPtr + cbArraySize) > pbAttrFileEnd)
+             return ERROR_FILE_CORRUPT;
+ 
+-        BSWAP_ARRAY32_UNSIGNED(ArrayCRC32, cbCRC32Size);
++        BSWAP_ARRAY32_UNSIGNED(ArrayCRC32, cbArraySize);
+         for(i = 0; i < dwAttributesEntries; i++)
+             ha->pFileTable[i].dwCrc32 = ArrayCRC32[i];
+         pbAttrPtr += cbArraySize;
+@@ -196,7 +196,7 @@ static DWORD LoadAttributesFile(TMPQArchive * ha, LPBY
+         if((pbAttrPtr + cbArraySize) > pbAttrFileEnd)
+             return ERROR_FILE_CORRUPT;
+ 
+-        BSWAP_ARRAY64_UNSIGNED(ArrayFileTime, cbFileTimeSize);
++        BSWAP_ARRAY64_UNSIGNED(ArrayFileTime, cbArraySize);
+         for(i = 0; i < dwAttributesEntries; i++)
+             ha->pFileTable[i].FileTime = ArrayFileTime[i];
+         pbAttrPtr += cbArraySize;
Index: patches/patch-StormLib_src_SFilePatchArchives_cpp
===================================================================
RCS file: patches/patch-StormLib_src_SFilePatchArchives_cpp
diff -N patches/patch-StormLib_src_SFilePatchArchives_cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-StormLib_src_SFilePatchArchives_cpp	3 Sep 2026 06:30:49 -0000
@@ -0,0 +1,15 @@
+- Apply StormLib big-endian build fixes to the vendored copy
+  cde1a0718a0058cc651ecd56ff8149fc39f624e9
+
+Index: StormLib/src/SFilePatchArchives.cpp
+--- StormLib/src/SFilePatchArchives.cpp.orig
++++ StormLib/src/SFilePatchArchives.cpp
+@@ -480,7 +480,7 @@ static bool IsMatchingPatchFile(
+         {
+             // Load the patch header
+             SFileReadFile(hFile, &PatchHeader, sizeof(MPQ_PATCH_HEADER), &dwTransferred, NULL);
+-            BSWAP_ARRAY32_UNSIGNED(pPatchHeader, sizeof(DWORD) * 6);
++            BSWAP_ARRAY32_UNSIGNED(&PatchHeader, sizeof(DWORD) * 6);
+ 
+             // If the file contains an incremental patch,
+             // compare the "MD5 before patching" with the base file MD5
Index: patches/patch-StormLib_src_StormLib_h
===================================================================
RCS file: patches/patch-StormLib_src_StormLib_h
diff -N patches/patch-StormLib_src_StormLib_h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-StormLib_src_StormLib_h	3 Sep 2026 06:30:49 -0000
@@ -0,0 +1,16 @@
+- Apply StormLib big-endian build fixes to the vendored copy
+  cde1a0718a0058cc651ecd56ff8149fc39f624e9
+
+Index: StormLib/src/StormLib.h
+--- StormLib/src/StormLib.h.orig
++++ StormLib/src/StormLib.h
+@@ -631,8 +631,8 @@ typedef struct _TMPQHash
+ 
+ #else
+ 
+-    BYTE   Platform;
+     BYTE   Reserved;
++    BYTE   Platform;
+     USHORT lcLocale;
+ 
+ #endif
Index: patches/patch-StormLib_src_StormPort_h
===================================================================
RCS file: patches/patch-StormLib_src_StormPort_h
diff -N patches/patch-StormLib_src_StormPort_h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-StormLib_src_StormPort_h	3 Sep 2026 06:30:49 -0000
@@ -0,0 +1,12 @@
+Index: StormLib/src/StormPort.h
+--- StormLib/src/StormPort.h.orig
++++ StormLib/src/StormPort.h
+@@ -359,7 +359,7 @@
+ #endif // !STORMLIB_WINDOWS
+ 
+ // 64-bit calls are supplied by "normal" calls on Mac
+-#if defined(STORMLIB_MAC)
++#if defined(STORMLIB_MAC) || defined(__OpenBSD__)
+   #define stat64  stat
+   #define fstat64 fstat
+   #define lseek64 lseek