aboutsummaryrefslogtreecommitdiffstats
path: root/games/openbor3979
diff options
context:
space:
mode:
authorJan Beich <jbeich@FreeBSD.org>2017-05-10 04:57:05 +0800
committerJan Beich <jbeich@FreeBSD.org>2017-05-10 04:57:05 +0800
commit68a8fbed3e6fb7060797f900405452eac95d1c11 (patch)
tree7406297ed136a6b92280eff13ef6a79b4fbb6826 /games/openbor3979
parent309e6c96ce6aef149ad5f9b53b1832abd3c2f879 (diff)
downloadfreebsd-ports-gnome-68a8fbed3e6fb7060797f900405452eac95d1c11.tar.gz
freebsd-ports-gnome-68a8fbed3e6fb7060797f900405452eac95d1c11.tar.zst
freebsd-ports-gnome-68a8fbed3e6fb7060797f900405452eac95d1c11.zip
games/openbor: update to 3.0.r4504
- Add old slaves for some games (e.g. Ghosts'n Demons) based on http://www.chronocrash.com/forum/index.php?topic=2360.0 - Annotate .desktop file with build version - Drop v3.0 from package version - s/module/game/ in pkg-message for less ambiguity Changes: https://github.com/DCurrent/openbor/compare/ba1eb4f...4dfdb66
Diffstat (limited to 'games/openbor3979')
-rw-r--r--games/openbor3979/Makefile12
-rw-r--r--games/openbor3979/distinfo3
-rw-r--r--games/openbor3979/files/patch-openbor.c34
-rw-r--r--games/openbor3979/files/patch-sdl_menu.c13
-rw-r--r--games/openbor3979/files/patch-sdl_sdlport.c31
-rw-r--r--games/openbor3979/files/patch-source_gamelib_packfile.c13
-rw-r--r--games/openbor3979/files/patch-source_gamelib_packfile.h13
-rw-r--r--games/openbor3979/files/patch-source_ramlib_ram.c224
-rw-r--r--games/openbor3979/files/patch-source_scriptlib_Parser.c13
9 files changed, 356 insertions, 0 deletions
diff --git a/games/openbor3979/Makefile b/games/openbor3979/Makefile
new file mode 100644
index 000000000000..d6b332322d88
--- /dev/null
+++ b/games/openbor3979/Makefile
@@ -0,0 +1,12 @@
+# $FreeBSD$
+
+PORTVERSION= 3979
+PKGNAMESUFFIX= ${PORTVERSION}
+
+MASTERDIR= ${.CURDIR}/../openbor
+PATCHDIR= ${.CURDIR}/files
+DISTINFO_FILE= ${.CURDIR}/distinfo
+
+GH_TAGNAME= 2bcf25b
+
+.include "${MASTERDIR}/Makefile"
diff --git a/games/openbor3979/distinfo b/games/openbor3979/distinfo
new file mode 100644
index 000000000000..b1883f9ba7e4
--- /dev/null
+++ b/games/openbor3979/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1377224669
+SHA256 (DCurrent-openbor-3979-2bcf25b_GH0.tar.gz) = 089a07e7a2ac921167687f8b21d637f85f1e6fcd56862f3d63be54e333358cc5
+SIZE (DCurrent-openbor-3979-2bcf25b_GH0.tar.gz) = 5683070
diff --git a/games/openbor3979/files/patch-openbor.c b/games/openbor3979/files/patch-openbor.c
new file mode 100644
index 000000000000..de51625b0b02
--- /dev/null
+++ b/games/openbor3979/files/patch-openbor.c
@@ -0,0 +1,34 @@
+Fix potential crashes found by ASan/Clang/GCC
+
+--- openbor.c.orig 2016-12-22 13:02:02 UTC
++++ openbor.c
+@@ -13933,7 +13933,7 @@ void generate_basemap(int map_index, flo
+
+ void load_level(char *filename)
+ {
+- char *buf;
++ char *buf = NULL;
+ size_t size, len, sblen;
+ ptrdiff_t pos, oldpos;
+ char *command;
+@@ -15210,6 +15210,11 @@ void bar(int x, int y, int value, int ma
+ return;
+ }
+
++ if (value < 0)
++ {
++ value = 0;
++ }
++
+ if (value > maxvalue)
+ {
+ value = maxvalue;
+@@ -20471,7 +20476,7 @@ void common_dot()
+ entity *eOpp; //Owner of dot effect.
+ s_collision_attack attack; //Attack struct.
+
+- for(iIndex = 0; iIndex <= MAX_DOTS; iIndex++) //Loop through all DOT indexes.
++ for(iIndex = 0; iIndex < MAX_DOTS; iIndex++) //Loop through all DOT indexes.
+ {
+ iDot_time = self->dot_time[iIndex]; //Get expire time.
+ iDot_cnt = self->dot_cnt[iIndex]; //Get next tick time.
diff --git a/games/openbor3979/files/patch-sdl_menu.c b/games/openbor3979/files/patch-sdl_menu.c
new file mode 100644
index 000000000000..023fb8417e64
--- /dev/null
+++ b/games/openbor3979/files/patch-sdl_menu.c
@@ -0,0 +1,13 @@
+Don't crash with empty Paks/ directory.
+
+--- sdl/menu.c.orig 2015-04-18 21:21:56 UTC
++++ sdl/menu.c
+@@ -747,7 +747,7 @@ void Menu()
+ }
+ freeAllLogs();
+ termMenu();
+- if(ctrl == 2)
++ if(dListTotal == 0 || ctrl == 2)
+ {
+ if (filelist)
+ {
diff --git a/games/openbor3979/files/patch-sdl_sdlport.c b/games/openbor3979/files/patch-sdl_sdlport.c
new file mode 100644
index 000000000000..ca62da11fbed
--- /dev/null
+++ b/games/openbor3979/files/patch-sdl_sdlport.c
@@ -0,0 +1,31 @@
+Store settings under ~/.openbor instead of current directory
+
+--- sdl/sdlport.c.orig 2015-04-18 21:21:56 UTC
++++ sdl/sdlport.c
+@@ -11,6 +11,9 @@
+ #include "ram.h"
+ #include "video.h"
+ #include "menu.h"
++#include <sys/stat.h>
++#include <err.h>
++#include <unistd.h>
+
+ #ifdef DARWIN
+ #include <CoreFoundation/CoreFoundation.h>
+@@ -103,6 +105,16 @@ int main(int argc, char *argv[])
+ #ifdef ANDROID
+ dirExists(rootDir, 1);
+ chdir(rootDir);
++#else
++ if(!getenv("OPENBOR_USE_CURDIR"))
++ {
++ if (chdir(getenv("HOME")) != 0)
++ err(1, "cannot cd to $HOME");
++ if (mkdir(".openbor", 0755) != 0 && errno != EEXIST)
++ err(1, "cannot mkdir $HOME/.openbor");
++ if (chdir(".openbor") != 0)
++ err(1, "cannot cd to $HOME/.openbor");
++ }
+ #endif
+ dirExists(paksDir, 1);
+ dirExists(savesDir, 1);
diff --git a/games/openbor3979/files/patch-source_gamelib_packfile.c b/games/openbor3979/files/patch-source_gamelib_packfile.c
new file mode 100644
index 000000000000..0faad2e22e68
--- /dev/null
+++ b/games/openbor3979/files/patch-source_gamelib_packfile.c
@@ -0,0 +1,13 @@
+Reset seek position for BGM with more than 64 tracks
+
+--- source/gamelib/packfile.c.orig 2015-04-18 21:22:03 UTC
++++ source/gamelib/packfile.c
+@@ -1399,7 +1399,7 @@ void packfile_music_read(fileliststruct
+ getBasePath(packfile, filelist[i].filename, 1);
+ if(stristr(packfile, ".pak"))
+ {
+- memset(filelist[i].bgmTracks, 0, 256);
++ memset(filelist[i].bgmTracks, 0, sizeof(filelist[i].bgmTracks));
+ filelist[i].nTracks = 0;
+ fd = fopen(packfile, "rb");
+ if(fd == NULL)
diff --git a/games/openbor3979/files/patch-source_gamelib_packfile.h b/games/openbor3979/files/patch-source_gamelib_packfile.h
new file mode 100644
index 000000000000..210607cc776c
--- /dev/null
+++ b/games/openbor3979/files/patch-source_gamelib_packfile.h
@@ -0,0 +1,13 @@
+Don't crash with > 80 tracks.
+
+--- source/gamelib/packfile.h.orig 2015-04-18 21:22:03 UTC
++++ source/gamelib/packfile.h
+@@ -42,7 +42,7 @@ typedef struct fileliststruct
+ {
+ char filename[128];
+ int nTracks;
+- char bgmFileName[80][256];
++ char bgmFileName[256][80];
+ int bgmTrack;
+ unsigned int bgmTracks[256];
+ #ifdef SDL
diff --git a/games/openbor3979/files/patch-source_ramlib_ram.c b/games/openbor3979/files/patch-source_ramlib_ram.c
new file mode 100644
index 000000000000..7fadd8587473
--- /dev/null
+++ b/games/openbor3979/files/patch-source_ramlib_ram.c
@@ -0,0 +1,224 @@
+Implement Linux-like memory stats for BSDs
+
+--- source/ramlib/ram.c.orig 2013-12-29 14:05:10 UTC
++++ source/ramlib/ram.c
+@@ -27,6 +27,21 @@
+ #include <mach/task.h>
+ #include <mach/mach.h>
+ #include <mach/mach_init.h>
++#elif defined(__DragonFly__) || defined(__FreeBSD__) || \
++ defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__)
++#include <sys/types.h>
++#include <sys/sysctl.h>
++#include <unistd.h>
++# if defined(__DragonFly__)
++#include <sys/kinfo.h> // struct kinfo_proc
++#include <sys/vmmeter.h> // struct vmstats
++# elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
++#include <sys/user.h> // struct kinfo_proc
++# elif defined(__NetBSD__)
++#include <uvm/uvm_extern.h> // struct uvmexp_sysctl
++# elif defined(__OpenBSD__)
++#include <uvm/uvmexp.h> // struct uvmexp
++# endif
+ #elif LINUX
+ #include <sys/sysinfo.h>
+ #include <unistd.h>
+@@ -54,12 +69,22 @@ static u64 systemRam = 0x00000000;
+ #ifndef WIN
+ #ifndef XBOX
+ #ifndef LINUX
++#ifndef __DragonFly__
++#ifndef __FreeBSD__
++#ifndef __FreeBSD_kernel__
++#ifndef __NetBSD__
++#ifndef __OpenBSD__
+ static unsigned long elfOffset = 0x00000000;
+ static unsigned long stackSize = 0x00000000;
+ #endif
+ #endif
+ #endif
+ #endif
++#endif
++#endif
++#endif
++#endif
++#endif
+
+ /////////////////////////////////////////////////////////////////////////////
+ // Symbols
+@@ -68,6 +93,11 @@ static unsigned long stackSize = 0x00000
+ #ifndef WIN
+ #ifndef XBOX
+ #ifndef LINUX
++#ifndef __DragonFly__
++#ifndef __FreeBSD__
++#ifndef __FreeBSD_kernel__
++#ifndef __NetBSD__
++#ifndef __OpenBSD__
+ #if (__GNUC__ > 3)
+ extern unsigned long _end;
+ extern unsigned long _start;
+@@ -81,6 +111,11 @@ extern unsigned long start;
+ #endif
+ #endif
+ #endif
++#endif
++#endif
++#endif
++#endif
++#endif
+
+ /////////////////////////////////////////////////////////////////////////////
+ // Functions
+@@ -107,6 +142,49 @@ u64 getFreeRam(int byte_size)
+ return 0;
+ }
+ return (u64)(((vms.inactive_count + vms.free_count) * size) / byte_size);
++#elif defined(__DragonFly__)
++ struct vmstats vms;
++ size_t sz = sizeof(vms);
++ if (sysctlbyname("vm.vmstats", &vms, &sz, NULL, 0))
++ {
++ return 0;
++ }
++ return (u64)((vms.v_free_count + vms.v_inactive_count
++ + vms.v_cache_count) * getpagesize()) / byte_size;
++#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
++ u_int v_free_count, v_inactive_count, v_cache_count;
++ size_t sz = sizeof(u_int);
++ v_free_count = v_inactive_count = v_cache_count = 0;
++ sysctlbyname("vm.stats.vm.v_free_count",
++ &v_free_count, &sz, NULL, 0);
++ sysctlbyname("vm.stats.vm.v_inactive_count",
++ &v_inactive_count, &sz, NULL, 0);
++ sysctlbyname("vm.stats.vm.v_cache_count",
++ &v_cache_count, &sz, NULL, 0);
++ return (u64)((v_free_count + v_inactive_count + v_cache_count)
++ * getpagesize()) / byte_size;
++#elif defined(__NetBSD__) || defined(__OpenBSD__)
++# if defined(__NetBSD__)
++#undef VM_UVMEXP
++#define VM_UVMEXP VM_UVMEXP2
++#define uvmexp uvmexp_sysctl
++# else
++#define filepages vnodepages
++#define execpages vtextpages
++# endif
++ int mib[] = {
++ CTL_VM,
++ VM_UVMEXP,
++ };
++ u_int miblen = sizeof(mib) / sizeof(mib[0]);
++ struct uvmexp uvmexp;
++ size_t sz = sizeof(uvmexp);
++ if (sysctl(mib, miblen, &uvmexp, &sz, NULL, 0))
++ {
++ return 0;
++ }
++ return (u64)((uvmexp.free + uvmexp.inactive + uvmexp.filepages
++ + uvmexp.execpages) * uvmexp.pagesize) / byte_size;
+ #elif LINUX
+ struct sysinfo info;
+ sysinfo(&info);
+@@ -147,11 +225,29 @@ void setSystemRam()
+ stat.dwLength = sizeof(MEMORYSTATUS);
+ GlobalMemoryStatus(&stat);
+ systemRam = stat.dwTotalPhys;
+-#elif DARWIN
+- u64 mem;
+- size_t len = sizeof(mem);
+- sysctlbyname("hw.memsize", &mem, &len, NULL, 0);
+- systemRam = mem;
++#elif defined(DARWIN) || defined(__DragonFly__) || defined(__FreeBSD__) || \
++ defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__)
++# if defined(HW_MEMSIZE) || defined(HW_PHYSMEM64)
++ uint64_t physmem;
++# else
++ u_long physmem;
++# endif
++ int mib[] = {
++ CTL_HW,
++# if defined(HW_MEMSIZE)
++ HW_MEMSIZE,
++# elif defined(HW_PHYSMEM64)
++ HW_PHYSMEM64,
++# else
++ HW_PHYSMEM,
++# endif
++ };
++ size_t sz = sizeof(physmem);
++ if (sysctl(mib, 2, &physmem, &sz, NULL, 0))
++ {
++ physmem = 0;
++ }
++ systemRam = physmem;
+ #elif LINUX
+ struct sysinfo info;
+ sysinfo(&info);
+@@ -199,12 +295,22 @@ void setSystemRam()
+ #ifndef XBOX
+ #ifndef LINUX
+ #ifndef SYMBIAN
++#ifndef __DragonFly__
++#ifndef __FreeBSD__
++#ifndef __FreeBSD_kernel__
++#ifndef __NetBSD__
++#ifndef __OpenBSD__
+ stackSize = (int)&_end - (int)&_start + ((int)&_start - elfOffset);
+ #endif
+ #endif
+ #endif
+ #endif
+ #endif
++#endif
++#endif
++#endif
++#endif
++#endif
+ getRamStatus(BYTES);
+ }
+
+@@ -234,6 +340,42 @@ u64 getUsedRam(int byte_size)
+ return 0;
+ }
+ return info.resident_size / byte_size;
++#elif defined(__DragonFly__) || defined(__FreeBSD__) || \
++ defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__)
++# if defined(__NetBSD__)
++#undef KERN_PROC
++#define KERN_PROC KERN_PROC2
++#define KINFO_PROC struct kinfo_proc2
++# else
++#define KINFO_PROC struct kinfo_proc
++# endif
++# if defined(__DragonFly__)
++#define KP_RSS(kp) (kp.kp_vm_rssize * getpagesize())
++# elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
++#define KP_RSS(kp) (kp.ki_rssize * getpagesize())
++# elif defined(__NetBSD__)
++#define KP_RSS(kp) (kp.p_vm_rssize * getpagesize())
++# elif defined(__OpenBSD__)
++#define KP_RSS(kp) (kp.p_vm_rssize * getpagesize())
++# endif
++ int mib[] = {
++ CTL_KERN,
++ KERN_PROC,
++ KERN_PROC_PID,
++ getpid(),
++# if defined(__NetBSD__) || defined(__OpenBSD__)
++ sizeof(KINFO_PROC),
++ 1,
++# endif
++ };
++ u_int miblen = sizeof(mib) / sizeof(mib[0]);
++ KINFO_PROC kp;
++ size_t sz = sizeof(KINFO_PROC);
++ if (sysctl(mib, miblen, &kp, &sz, NULL, 0))
++ {
++ return 0;
++ }
++ return (u64)KP_RSS(kp) / byte_size;
+ #elif LINUX
+ unsigned long vm = 0;
+ FILE *file = fopen("/proc/self/statm", "r");
diff --git a/games/openbor3979/files/patch-source_scriptlib_Parser.c b/games/openbor3979/files/patch-source_scriptlib_Parser.c
new file mode 100644
index 000000000000..6e0cf39629c0
--- /dev/null
+++ b/games/openbor3979/files/patch-source_scriptlib_Parser.c
@@ -0,0 +1,13 @@
+Make room for terminating NUL added by sprintf()
+
+--- source/scriptlib/Parser.c.orig 2016-12-15 02:16:03 UTC
++++ source/scriptlib/Parser.c
+@@ -1828,7 +1828,7 @@ void Parser_Mult_expr2(Parser *pparser )
+
+ void Parser_Unary_expr(Parser *pparser )
+ {
+- static CHAR buf[MAX_TOKEN_LENGTH + 1];
++ static CHAR buf[MAX_TOKEN_LENGTH + 2];
+ Instruction *pInstruction = NULL;
+
+ if (ParserSet_First(&(pparser->theParserSet), postfix_expr, pparser->theNextToken.theType ))