aboutsummaryrefslogtreecommitdiff
path: root/games/openbor4432
diff options
context:
space:
mode:
authorJan Beich <jbeich@FreeBSD.org>2017-05-09 20:57:05 +0000
committerJan Beich <jbeich@FreeBSD.org>2017-05-09 20:57:05 +0000
commit68a8fbed3e6fb7060797f900405452eac95d1c11 (patch)
tree7406297ed136a6b92280eff13ef6a79b4fbb6826 /games/openbor4432
parent309e6c96ce6aef149ad5f9b53b1832abd3c2f879 (diff)
downloadports-68a8fbed3e6fb7060797f900405452eac95d1c11.tar.gz
ports-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
Notes
Notes: svn path=/head/; revision=440514
Diffstat (limited to 'games/openbor4432')
-rw-r--r--games/openbor4432/Makefile12
-rw-r--r--games/openbor4432/distinfo3
-rw-r--r--games/openbor4432/files/patch-openbor.c93
-rw-r--r--games/openbor4432/files/patch-sdl_menu.c13
-rw-r--r--games/openbor4432/files/patch-sdl_sdlport.c30
-rw-r--r--games/openbor4432/files/patch-source_gamelib_packfile.c13
-rw-r--r--games/openbor4432/files/patch-source_gamelib_packfile.h13
-rw-r--r--games/openbor4432/files/patch-source_ramlib_ram.c190
-rw-r--r--games/openbor4432/files/patch-source_scriptlib_Parser.c13
9 files changed, 380 insertions, 0 deletions
diff --git a/games/openbor4432/Makefile b/games/openbor4432/Makefile
new file mode 100644
index 000000000000..0f4d9029ae61
--- /dev/null
+++ b/games/openbor4432/Makefile
@@ -0,0 +1,12 @@
+# $FreeBSD$
+
+PORTVERSION= 4432
+PKGNAMESUFFIX= ${PORTVERSION}
+
+MASTERDIR= ${.CURDIR}/../openbor
+PATCHDIR= ${.CURDIR}/files
+DISTINFO_FILE= ${.CURDIR}/distinfo
+
+GH_TAGNAME= ba1eb4f
+
+.include "${MASTERDIR}/Makefile"
diff --git a/games/openbor4432/distinfo b/games/openbor4432/distinfo
new file mode 100644
index 000000000000..c7c141e71833
--- /dev/null
+++ b/games/openbor4432/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1485387608
+SHA256 (DCurrent-openbor-4432-ba1eb4f_GH0.tar.gz) = 0c26130127d1ec1d98c6c5e68b38a11df3e405ed7e43b7c61762f6ae862538c5
+SIZE (DCurrent-openbor-4432-ba1eb4f_GH0.tar.gz) = 6087650
diff --git a/games/openbor4432/files/patch-openbor.c b/games/openbor4432/files/patch-openbor.c
new file mode 100644
index 000000000000..1cab90006f74
--- /dev/null
+++ b/games/openbor4432/files/patch-openbor.c
@@ -0,0 +1,93 @@
+Fix potential crashes found by ASan/Clang/GCC
+Fix an infinite loop in lcmScriptDeleteMain()
+Avoid accidental rounding from abs()
+
+--- openbor.c.orig 2016-12-22 13:02:02 UTC
++++ openbor.c
+@@ -5810,7 +5810,7 @@ s_collision_attack **collision_alloc_att
+ size_t alloc_size;
+
+ // Get amount of memory we'll need.
+- alloc_size = sizeof(*result);
++ alloc_size = max_collisons * sizeof(*result);
+
+ // Allocate memory and get pointer.
+ result = malloc(alloc_size);
+@@ -5859,7 +5859,7 @@ s_collision_body **collision_alloc_body_
+ size_t alloc_size;
+
+ // Get amount of memory we'll need.
+- alloc_size = sizeof(*result);
++ alloc_size = max_collisons * sizeof(*result);
+
+ // Allocate memory and get pointer.
+ result = malloc(alloc_size);
+@@ -8204,7 +8204,8 @@ size_t lcmScriptCopyBuffer(ArgList *argl
+
+ size_t lcmScriptDeleteMain(char **buf)
+ {
+- size_t len = 0, i = 0;
++ size_t len = 0;
++ long i = 0;
+ ptrdiff_t pos = 0;
+ char *newbuf = NULL;
+
+@@ -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.
+@@ -21710,8 +21716,8 @@ int reset_backpain(entity *ent)
+ if (ent->normaldamageflipdir == DIRECTION_RIGHT) ent->direction = DIRECTION_RIGHT;
+ else ent->direction = DIRECTION_LEFT;
+
+- if(ent->direction == DIRECTION_RIGHT) ent->velocity.x = -1*abs(ent->velocity.x);
+- else ent->velocity.x = abs(ent->velocity.x);
++ if(ent->direction == DIRECTION_RIGHT) ent->velocity.x = -1*ABS(ent->velocity.x);
++ else ent->velocity.x = ABS(ent->velocity.x);
+
+ return 1;
+ }
+@@ -25831,7 +25837,7 @@ int common_try_wander(entity *target, in
+ mod = -mod;
+ }
+ //if ((self->sortid / 100) % 2)
+- if (abs(rand32()) % 2)
++ if (rand32() % 2)
+ {
+ mod = 3 - mod;
+ }
+@@ -34607,7 +34612,7 @@ void keyboard_setup(int player)
+ strncpy(buttonnames[SDID_SPECIAL], "Special", 16);
+ strncpy(buttonnames[SDID_START], "Start", 16);
+ strncpy(buttonnames[SDID_SCREENSHOT], "Screenshot", 16);
+- strncpy(buttonnames[SDID_ESC], "Exit", 16);
++ //strncpy(buttonnames[SDID_ESC], "Exit", 16);
+
+ savesettings();
+ bothnewkeys = 0;
diff --git a/games/openbor4432/files/patch-sdl_menu.c b/games/openbor4432/files/patch-sdl_menu.c
new file mode 100644
index 000000000000..023fb8417e64
--- /dev/null
+++ b/games/openbor4432/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/openbor4432/files/patch-sdl_sdlport.c b/games/openbor4432/files/patch-sdl_sdlport.c
new file mode 100644
index 000000000000..8a143220a1c5
--- /dev/null
+++ b/games/openbor4432/files/patch-sdl_sdlport.c
@@ -0,0 +1,30 @@
+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,8 @@
+ #include "ram.h"
+ #include "video.h"
+ #include "menu.h"
++#include <sys/stat.h>
++#include <err.h>
+ #include <time.h>
+ #include <unistd.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/openbor4432/files/patch-source_gamelib_packfile.c b/games/openbor4432/files/patch-source_gamelib_packfile.c
new file mode 100644
index 000000000000..0faad2e22e68
--- /dev/null
+++ b/games/openbor4432/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/openbor4432/files/patch-source_gamelib_packfile.h b/games/openbor4432/files/patch-source_gamelib_packfile.h
new file mode 100644
index 000000000000..210607cc776c
--- /dev/null
+++ b/games/openbor4432/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/openbor4432/files/patch-source_ramlib_ram.c b/games/openbor4432/files/patch-source_ramlib_ram.c
new file mode 100644
index 000000000000..5a32a492ed5c
--- /dev/null
+++ b/games/openbor4432/files/patch-source_ramlib_ram.c
@@ -0,0 +1,190 @@
+Implement Linux-like memory stats for BSDs
+
+--- source/ramlib/ram.c.orig 2015-04-18 21:21:56 UTC
++++ source/ramlib/ram.c
+@@ -25,6 +25,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>
+@@ -48,7 +63,10 @@
+
+ static u64 systemRam = 0x00000000;
+
+-#if !(defined(WIN) || defined(LINUX) || defined(DARWIN))
++#if !(defined(WIN) || defined(LINUX) || defined(DARWIN) || \
++ defined(__DragonFly__) || defined(__FreeBSD__) || \
++ defined(__FreeBSD_kernel__) || defined(__NetBSD__) || \
++ defined(__OpenBSD__))
+ static unsigned long elfOffset = 0x00000000;
+ static unsigned long stackSize = 0x00000000;
+ #endif
+@@ -56,7 +74,10 @@ static unsigned long stackSize = 0x00000
+ /////////////////////////////////////////////////////////////////////////////
+ // Symbols
+
+-#if !(defined(WIN) || defined(LINUX) || defined(DARWIN))
++#if !(defined(WIN) || defined(LINUX) || defined(DARWIN) || \
++ defined(__DragonFly__) || defined(__FreeBSD__) || \
++ defined(__FreeBSD_kernel__) || defined(__NetBSD__) || \
++ defined(__OpenBSD__))
+ #if (__GNUC__ > 3)
+ extern unsigned long _end;
+ extern unsigned long _start;
+@@ -93,6 +114,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);
+@@ -133,11 +197,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);
+@@ -180,7 +262,10 @@ void setSystemRam()
+ stackSize = 0x00000000;
+ systemRam = getFreeRam(BYTES);
+ #endif
+-#if !(defined(WIN) || defined(LINUX) || defined(DARWIN) || defined(SYMBIAN))
++#if !(defined(WIN) || defined(LINUX) || defined(DARWIN) || defined(SYMBIAN) || \
++ defined(__DragonFly__) || defined(__FreeBSD__) || \
++ defined(__FreeBSD_kernel__) || defined(__NetBSD__) || \
++ defined(__OpenBSD__))
+ stackSize = (int)&_end - (int)&_start + ((int)&_start - elfOffset);
+ #endif
+ getRamStatus(BYTES);
+@@ -212,6 +297,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/openbor4432/files/patch-source_scriptlib_Parser.c b/games/openbor4432/files/patch-source_scriptlib_Parser.c
new file mode 100644
index 000000000000..6e0cf39629c0
--- /dev/null
+++ b/games/openbor4432/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 ))