about summary refs log tree commit diff
path: root/pkgs/games/gog/albion/error-log-stderr.patch
diff options
context:
space:
mode:
authoraszlig <aszlig@nix.build>2018-02-19 04:32:32 +0100
committeraszlig <aszlig@nix.build>2018-02-21 20:38:34 +0100
commit77a0f47d06f3d21b78c7f34a129bc3f75d69fbf7 (patch)
treefe50abea68d2ce04b104058f097aa6aa89737bb2 /pkgs/games/gog/albion/error-log-stderr.patch
parent73b4b0bfb78998a53b73ce2501f4d2b8bc73198d (diff)
games/gog: Add statically recompiled Albion
We only fetch the data files from GOG here and use the port from
OpenPandora (https://repo.openpandora.org/?page=detail&app=albion_sr)
for the main game executable.

Instead of using the binaries of the static recompiler, this is
completely compiled from source and comes with a few changes in the form
of a few patches:

  config.patch:

    Hide the mouse cursor and set the default scaled resolution to
    1280x960 (the window can still be resized) in the default
    albion.cfg.

  error-log-stderr.patch:

    Whenever an error happens, the game usually creates a file called
    "error.log", which contains the actual error message. This patch
    makes sure the file isn't created but the error message is printed
    to stderr.

  scons.patch:

    Fixes a few SConstruct/SConscript files to use the builder's
    environment, so that it can find executables such as gcc.

  sdl2.patch:

    SDL 2 has dropped support for the keysym.unicode field at some
    point, so use keysym.sym instead. This has the disadvantage that it
    doesn't recognize key modifiers, so we might want to switch this to
    use the SDL_TEXTINPUT event.

  xdg-paths.patch:

    We want to use XDG_CONFIG_HOME and XDG_DATA_HOME instead of writing
    everything to one directory, so this patch makes sure that the paths
    are correctly read depending on whether its an XDG directory or one
    of the store paths of the game.

Signed-off-by: aszlig <aszlig@nix.build>
Diffstat (limited to 'pkgs/games/gog/albion/error-log-stderr.patch')
-rw-r--r--pkgs/games/gog/albion/error-log-stderr.patch100
1 files changed, 100 insertions, 0 deletions
diff --git a/pkgs/games/gog/albion/error-log-stderr.patch b/pkgs/games/gog/albion/error-log-stderr.patch
new file mode 100644
index 00000000..9819f1f1
--- /dev/null
+++ b/pkgs/games/gog/albion/error-log-stderr.patch
@@ -0,0 +1,100 @@
+diff --git a/games/Albion/SR-Main/Albion-proc-vfs.c b/games/Albion/SR-Main/Albion-proc-vfs.c
+index c3d2d4f..faa90e7 100644
+--- a/games/Albion/SR-Main/Albion-proc-vfs.c
++++ b/games/Albion/SR-Main/Albion-proc-vfs.c
+@@ -232,6 +232,8 @@ FILE *Game_fopen(const char *filename, const char *mode)
+     fprintf(stderr, "fopen: original name: %s\n", filename);
+ #endif
+ 
++    if (strcasecmp(filename, "error.log") == 0) return stderr;
++
+     vfs_err = vfs_get_real_name(filename, (char *) &temp_str, &realdir);
+ 
+ #if defined(__DEBUG__)
+@@ -260,6 +262,8 @@ int Game_open(const char *pathname, int flags, mode_t mode)
+     fprintf(stderr, "open: original name: %s\n", pathname);
+ #endif
+ 
++    if (strcasecmp(pathname, "error.log") == 0) return STDERR_FILENO;
++
+     vfs_err = vfs_get_real_name(pathname, (char *) &temp_str, &realdir);
+ 
+ #if defined(__DEBUG__)
+@@ -726,6 +730,16 @@ int Game_closedir(struct watcom_dirent *dirp)
+     return 0;
+ }
+ 
++int Game_close(int fd)
++{
++    return fd == STDERR_FILENO ? 0 : close(fd);
++}
++
++int Game_fclose(FILE *stream)
++{
++    return stream == stderr ? 0 : fclose(stream);
++}
++
+ static void Conv_find(struct watcom_find_t *buffer, struct watcom_dirent *direntp)
+ {
+     // file attributes
+diff --git a/games/Albion/SR-Main/Albion-proc-vfs.h b/games/Albion/SR-Main/Albion-proc-vfs.h
+index 0cf4491..2e16671 100644
+--- a/games/Albion/SR-Main/Albion-proc-vfs.h
++++ b/games/Albion/SR-Main/Albion-proc-vfs.h
+@@ -110,6 +110,8 @@ extern int Game_rename(const char *oldpath, const char *newpath);
+ extern struct watcom_dirent *Game_opendir(const char *dirname);
+ extern struct watcom_dirent *Game_readdir(struct watcom_dirent *dirp);
+ extern int Game_closedir(struct watcom_dirent *dirp);
++extern int Game_close(int fd);
++extern int Game_fclose(FILE *stream);
+ extern uint32_t Game_dos_findfirst(const char *path, const uint32_t attributes, struct watcom_find_t *buffer);
+ extern uint32_t Game_dos_findnext(struct watcom_find_t *buffer);
+ extern uint32_t Game_dos_findclose(struct watcom_find_t *buffer);
+diff --git a/games/Albion/SR-Main/x86/SR-asm-calls.asm b/games/Albion/SR-Main/x86/SR-asm-calls.asm
+index 3cb2cc8..e1741dc 100644
+--- a/games/Albion/SR-Main/x86/SR-asm-calls.asm
++++ b/games/Albion/SR-Main/x86/SR-asm-calls.asm
+@@ -71,6 +71,8 @@
+     %define Game_chdir _Game_chdir
+     %define close _close
+     %define Game_closedir _Game_closedir
++    %define Game_close _Game_close
++    %define Game_fclose _Game_fclose
+     %define ctime _ctime
+     %define Game_dos_findclose _Game_dos_findclose
+     %define Game_dos_findnext _Game_dos_findnext
+@@ -171,14 +173,14 @@ extern Game_WaitFor2ndVerticalRetrace
+ ; 1 param
+ extern asctime
+ extern Game_chdir
+-extern close
++extern Game_close
+ extern Game_closedir
+ extern ctime
+ extern Game_dos_findclose
+ extern Game_dos_findnext
+ extern Game_dos_getvect
+ extern Game_ExitMain_Asm
+-extern fclose
++extern Game_fclose
+ extern Game_filelength
+ extern free
+ extern ftime
+@@ -798,7 +800,7 @@ SR_j___close:
+ 
+ ; eax = int handle
+ 
+-        Game_Call_Asm_Reg1 close,'get_errno_val'
++        Game_Call_Asm_Reg1 Game_close,'get_errno_val'
+ 
+ ; end procedure SR___close
+ 
+@@ -875,7 +877,7 @@ SR_fclose:
+ 
+ ; eax = FILE *fp
+ 
+-        Game_Call_Asm_Reg1 fclose,'get_errno_val'
++        Game_Call_Asm_Reg1 Game_fclose,'get_errno_val'
+ 
+ ; end procedure SR_fclose
+