summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelle Raaijmakers <jelle@gmta.nl>2022-08-31 14:21:06 +0200
committerLinus Groh <mail@linusgroh.de>2022-08-31 14:25:15 +0100
commitfa2ece11834177102647b9b46e30bc623871616d (patch)
treeff8262540429e8fa841135fb171ab5a30663bea9
parentb057a2d82befb4c53539d9fdf81131eb930c59b6 (diff)
downloadserenity-fa2ece11834177102647b9b46e30bc623871616d.zip
Ports: Tidy up Quake2 platform patch
There were a lot of unrelated formatting changes in the patch, which is now shrunk by roughly 60%.
-rw-r--r--Ports/quake2/patches/0001-Add-SerenityOS-platform-support.patch509
1 files changed, 38 insertions, 471 deletions
diff --git a/Ports/quake2/patches/0001-Add-SerenityOS-platform-support.patch b/Ports/quake2/patches/0001-Add-SerenityOS-platform-support.patch
index bbbcf5ece5..cfcc71f851 100644
--- a/Ports/quake2/patches/0001-Add-SerenityOS-platform-support.patch
+++ b/Ports/quake2/patches/0001-Add-SerenityOS-platform-support.patch
@@ -1,21 +1,21 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jelle Raaijmakers <jelle@gmta.nl>
-Date: Wed, 31 Aug 2022 13:22:33 +0200
+Date: Wed, 31 Aug 2022 14:15:48 +0200
Subject: [PATCH] Add SerenityOS platform support
Co-Authored-By: Jesse Buhagiar <jooster669@gmail.com>
---
- CMakeLists.txt | 9 --
- README.md | 32 ++--
- src/CMakeLists.txt | 71 +++------
- src/linux/glw_linux.h | 2 +-
- src/linux/net_udp.c | 2 +-
- src/linux/q_shlinux.c | 36 +++--
- src/linux/rw_sdl.c | 9 +-
- src/linux/snd_sdl.c | 4 +-
- src/linux/sys_linux.c | 354 +++++++++++++++++++++---------------------
- src/linux/vid_so.c | 11 +-
- 10 files changed, 252 insertions(+), 278 deletions(-)
+ CMakeLists.txt | 9 -----
+ README.md | 32 ++++++++-------
+ src/CMakeLists.txt | 33 ++--------------
+ src/linux/glw_linux.h | 2 +-
+ src/linux/net_udp.c | 2 +-
+ src/linux/q_shlinux.c | 36 +++++++++--------
+ src/linux/rw_sdl.c | 9 ++++-
+ src/linux/snd_sdl.c | 2 +-
+ src/linux/sys_linux.c | 90 +++++++++++++++++++++----------------------
+ src/linux/vid_so.c | 9 +++--
+ 10 files changed, 99 insertions(+), 125 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 45d107b..49d329b 100644
@@ -79,7 +79,7 @@ index d86b324..1b119bf 100644
+set gl_driver "libgl.so.serenity"
+```
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
-index d8ea312..7ed0d8a 100644
+index d8ea312..fcf320f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -2,23 +2,7 @@ set (quake_resource_libdir ${CMAKE_INSTALL_PREFIX}/lib/quake2sdl)
@@ -133,57 +133,14 @@ index d8ea312..7ed0d8a 100644
add_library (ref-softsdl SHARED
ref_soft/r_aclip.c
-@@ -109,31 +85,30 @@ add_library (ref-softsdl SHARED
- set_target_properties (ref-softsdl PROPERTIES OUTPUT_NAME ref_softsdl PREFIX "")
-
- if (WITH_QMAX)
-- set (GL_DIR ref_candygl)
-+ set (GL_DIR ref_candygl)
- else (WITH_QMAX)
-- set (GL_DIR ref_gl)
-+ set (GL_DIR ref_gl)
- endif (WITH_QMAX)
-
- add_library (ref-sdlgl SHARED
-- ${GL_DIR}/gl_draw.c
-- ${GL_DIR}/gl_image.c
-- ${GL_DIR}/gl_light.c
-- ${GL_DIR}/gl_mesh.c
-- ${GL_DIR}/gl_model.c
-- ${GL_DIR}/gl_rmain.c
-- ${GL_DIR}/gl_rmisc.c
-- ${GL_DIR}/gl_rsurf.c
-- ${GL_DIR}/gl_warp.c
-- linux/qgl_linux.c
-- game/q_shared.c
-- linux/q_shlinux.c
-- linux/glob.c
-- linux/rw_sdl.c
-- linux/rw_linux.c
+@@ -130,7 +106,6 @@ add_library (ref-sdlgl SHARED
+ linux/glob.c
+ linux/rw_sdl.c
+ linux/rw_linux.c
- linux/joystick.c
--)
-+ ${GL_DIR}/gl_draw.c
-+ ${GL_DIR}/gl_image.c
-+ ${GL_DIR}/gl_light.c
-+ ${GL_DIR}/gl_mesh.c
-+ ${GL_DIR}/gl_model.c
-+ ${GL_DIR}/gl_rmain.c
-+ ${GL_DIR}/gl_rmisc.c
-+ ${GL_DIR}/gl_rsurf.c
-+ ${GL_DIR}/gl_warp.c
-+ linux/qgl_linux.c
-+ game/q_shared.c
-+ linux/q_shlinux.c
-+ linux/glob.c
-+ linux/rw_sdl.c
-+ linux/rw_linux.c
-+ )
+ )
if (WITH_QMAX)
-- target_link_libraries (ref-sdlgl ${JPEG_LIBRARY})
-+ target_link_libraries (ref-sdlgl ${JPEG_LIBRARY})
- endif (WITH_QMAX)
- target_compile_definitions (ref-sdlgl PRIVATE -DOPENGL)
- set_target_properties (ref-sdlgl PROPERTIES OUTPUT_NAME ref_sdlgl PREFIX "")
+ target_link_libraries (ref-sdlgl ${JPEG_LIBRARY})
diff --git a/src/linux/glw_linux.h b/src/linux/glw_linux.h
index 4994129..9b0cd6b 100644
--- a/src/linux/glw_linux.h
@@ -293,18 +250,9 @@ index 460e28a..2e5a82f 100644
+ // Noop
+}
diff --git a/src/linux/snd_sdl.c b/src/linux/snd_sdl.c
-index b9ae691..5c66159 100644
+index b9ae691..a2b4755 100644
--- a/src/linux/snd_sdl.c
+++ b/src/linux/snd_sdl.c
-@@ -2,7 +2,7 @@
- snd_sdl.c
-
- Sound code taken from SDLQuake and modified to work with Quake2
-- Robert Bäuml 2001-12-25
-+ Robert B�uml 2001-12-25
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
@@ -25,7 +25,7 @@
$Id: snd_sdl.c,v 1.2 2002/02/09 20:29:38 relnev Exp $
*/
@@ -315,7 +263,7 @@ index b9ae691..5c66159 100644
#include "../client/client.h"
#include "../client/snd_loc.h"
diff --git a/src/linux/sys_linux.c b/src/linux/sys_linux.c
-index 9d12722..a437f61 100644
+index 9d12722..4e3b425 100644
--- a/src/linux/sys_linux.c
+++ b/src/linux/sys_linux.c
@@ -27,8 +27,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@@ -327,164 +275,25 @@ index 9d12722..a437f61 100644
#include <sys/stat.h>
#include <string.h>
#include <ctype.h>
-@@ -43,7 +41,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- cvar_t *nostdout;
-
--unsigned sys_frame_time;
-+unsigned sys_frame_time;
-
- uid_t saved_euid;
- qboolean stdin_active = true;
-@@ -54,78 +52,78 @@ qboolean stdin_active = true;
-
- void Sys_ConsoleOutput (char *string)
- {
-- if (nostdout && nostdout->value)
-- return;
-+ if (nostdout && nostdout->value)
-+ return;
-
-- fputs(string, stdout);
-+ fputs(string, stdout);
- }
-
- void Sys_Printf (char *fmt, ...)
- {
-- va_list argptr;
-- char text[1024];
-- unsigned char *p;
--
-- va_start (argptr,fmt);
-- vsnprintf (text,1024,fmt,argptr);
-- va_end (argptr);
--
-- if (nostdout && nostdout->value)
-- return;
--
-- for (p = (unsigned char *)text; *p; p++) {
-- *p &= 0x7f;
-- if ((*p > 128 || *p < 32) && *p != 10 && *p != 13 && *p != 9)
-- printf("[%02x]", *p);
-- else
-- putc(*p, stdout);
-- }
-+ va_list argptr;
-+ char text[1024];
-+ unsigned char *p;
-+
-+ va_start (argptr,fmt);
-+ vsnprintf (text,1024,fmt,argptr);
-+ va_end (argptr);
-+
-+ if (nostdout && nostdout->value)
-+ return;
-+
-+ for (p = (unsigned char *)text; *p; p++) {
-+ *p &= 0x7f;
-+ if ((*p > 128 || *p < 32) && *p != 10 && *p != 13 && *p != 9)
-+ printf("[%02x]", *p);
-+ else
-+ putc(*p, stdout);
-+ }
- }
-
- void Sys_Quit (void)
+@@ -86,7 +84,7 @@ void Sys_Quit (void)
{
-- CL_Shutdown ();
-- Qcommon_Shutdown ();
+ CL_Shutdown ();
+ Qcommon_Shutdown ();
- fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
-- _exit(0);
-+ CL_Shutdown ();
-+ Qcommon_Shutdown ();
-+ //fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
-+ _exit(0);
- }
-
- void Sys_Init(void)
- {
- #if id386
--// Sys_SetFPCW();
-+// Sys_SetFPCW();
- #endif
++ //fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
+ _exit(0);
}
- void Sys_Error (char *error, ...)
- {
-- va_list argptr;
-- char string[1024];
-+ va_list argptr;
-+ char string[1024];
+@@ -103,7 +101,7 @@ void Sys_Error (char *error, ...)
+ char string[1024];
// change stdin to non blocking
- fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
+ //fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
-- CL_Shutdown ();
-- Qcommon_Shutdown ();
-+ CL_Shutdown ();
-+ Qcommon_Shutdown ();
-
-- va_start (argptr,error);
-- vsnprintf (string,1024,error,argptr);
-- va_end (argptr);
-- fprintf(stderr, "Error: %s\n", string);
-+ va_start (argptr,error);
-+ vsnprintf (string,1024,error,argptr);
-+ va_end (argptr);
-+ fprintf(stderr, "Error: %s\n", string);
-
-- _exit (1);
-+ _exit (1);
-
- }
-
- void Sys_Warn (char *warning, ...)
- {
-- va_list argptr;
-- char string[1024];
-+ va_list argptr;
-+ char string[1024];
-
-- va_start (argptr,warning);
-- vsnprintf (string,1024,warning,argptr);
-- va_end (argptr);
-- fprintf(stderr, "Warning: %s", string);
-+ va_start (argptr,warning);
-+ vsnprintf (string,1024,warning,argptr);
-+ va_end (argptr);
-+ fprintf(stderr, "Warning: %s", string);
- }
-
- /*
-@@ -135,53 +133,53 @@ Sys_FileTime
- returns -1 if not present
- ============
- */
--int Sys_FileTime (char *path)
-+int Sys_FileTime (char *path)
- {
-- struct stat buf;
--
-- if (stat (path,&buf) == -1)
-- return -1;
--
-- return buf.st_mtime;
-+ struct stat buf;
-+
-+ if (stat (path,&buf) == -1)
-+ return -1;
-+
-+ return buf.st_mtime;
- }
-
- void floating_point_exception_handler(int whatever)
- {
--// Sys_Warn("floating point exception\n");
-- signal(SIGFPE, floating_point_exception_handler);
-+// Sys_Warn("floating point exception\n");
-+ signal(SIGFPE, floating_point_exception_handler);
- }
+ CL_Shutdown ();
+ Qcommon_Shutdown ();
+@@ -153,35 +151,35 @@ void floating_point_exception_handler(int whatever)
char *Sys_ConsoleInput(void)
{
@@ -549,101 +358,9 @@ index 9d12722..a437f61 100644
}
/*****************************************************************************/
-@@ -195,9 +193,9 @@ Sys_UnloadGame
- */
- void Sys_UnloadGame (void)
- {
-- if (game_library)
-- dlclose (game_library);
-- game_library = NULL;
-+ if (game_library)
-+ dlclose (game_library);
-+ game_library = NULL;
- }
-
- /*
-@@ -210,7 +208,7 @@ Loads the game dll
- void *Sys_GetGameAPI (void *parms)
- {
- void *(*GetGameAPI) (void *);
--
-+
- FILE *fp;
- char name[MAX_OSPATH];
- char *path;
-@@ -233,33 +231,33 @@ void *Sys_GetGameAPI (void *parms)
- if (!path)
- return NULL; // couldn't find one anywhere
- snprintf (name, MAX_OSPATH, "%s/%s", path, gamename);
--
-+
- /* skip it if it just doesn't exist */
- fp = fopen(name, "rb");
- if (fp == NULL)
- continue;
- fclose(fp);
--
-+
- game_library = dlopen (name, RTLD_NOW);
- if (game_library)
- {
- Com_MDPrintf ("LoadLibrary (%s)\n",name);
- break;
-- }
-- else
-+ }
-+ else
- {
- Com_Printf ("LoadLibrary (%s):", name);
--
-+
- path = dlerror();
- str_p = strchr(path, ':'); // skip the path (already shown)
- if (str_p == NULL)
- str_p = path;
- else
- str_p++;
--
-+
- Com_Printf ("%s\n", str_p);
--
-- return NULL;
-+
-+ return NULL;
- }
- }
-
-@@ -267,7 +265,7 @@ void *Sys_GetGameAPI (void *parms)
-
- if (!GetGameAPI)
- {
-- Sys_UnloadGame ();
-+ Sys_UnloadGame ();
- return NULL;
- }
-
-@@ -283,97 +281,97 @@ void Sys_AppActivate (void)
- void Sys_SendKeyEvents (void)
- {
- #ifndef DEDICATED_ONLY
-- if (KBD_Update_fp)
-- KBD_Update_fp();
-+ if (KBD_Update_fp)
-+ KBD_Update_fp();
- #endif
-
-- // grab frame time
-- sys_frame_time = Sys_Milliseconds();
-+ // grab frame time
-+ sys_frame_time = Sys_Milliseconds();
- }
-
- /*****************************************************************************/
-
- int main (int argc, char **argv)
+@@ -297,23 +295,23 @@ int main (int argc, char **argv)
{
-- int time, oldtime, newtime;
-+ int time, oldtime, newtime;
+ int time, oldtime, newtime;
- // go back to real user for config loads
- saved_euid = geteuid();
@@ -656,8 +373,7 @@ index 9d12722..a437f61 100644
+
+ printf ("Quake 2 -- Version %s Serenity\n", "0.1");
-- Qcommon_Init(argc, argv);
-+ Qcommon_Init(argc, argv);
+ Qcommon_Init(argc, argv);
- fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
+ //fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
@@ -677,156 +393,13 @@ index 9d12722..a437f61 100644
+ while (1)
+ {
// find time spent rendering last frame
-- do {
-- newtime = Sys_Milliseconds ();
-- time = newtime - oldtime;
-- } while (time < 1);
-- Qcommon_Frame (time);
-- oldtime = newtime;
-- }
-+ do {
-+ newtime = Sys_Milliseconds ();
-+ time = newtime - oldtime;
-+ } while (time < 1);
-+ Qcommon_Frame (time);
-+ oldtime = newtime;
-+ }
- }
-
- #if 0
- void Sys_CopyProtect(void)
- {
-- FILE *mnt;
-- struct mntent *ent;
-- char path[MAX_OSPATH];
-- struct stat st;
-- qboolean found_cd = false;
--
-- static qboolean checked = false;
--
-- if (checked)
-- return;
--
-- if ((mnt = setmntent("/etc/mtab", "r")) == NULL)
-- Com_Error(ERR_FATAL, "Can't read mount table to determine mounted cd location.");
--
-- while ((ent = getmntent(mnt)) != NULL) {
-- if (strcmp(ent->mnt_type, "iso9660") == 0) {
-- // found a cd file system
-- found_cd = true;
-- sprintf(path, "%s/%s", ent->mnt_dir, "install/data/quake2.exe");
-- if (stat(path, &st) == 0) {
-- // found it
-- checked = true;
-- endmntent(mnt);
-- return;
-- }
-- sprintf(path, "%s/%s", ent->mnt_dir, "Install/Data/quake2.exe");
-- if (stat(path, &st) == 0) {
-- // found it
-- checked = true;
-- endmntent(mnt);
-- return;
-- }
-- sprintf(path, "%s/%s", ent->mnt_dir, "quake2.exe");
-- if (stat(path, &st) == 0) {
-- // found it
-- checked = true;
-- endmntent(mnt);
-- return;
-- }
-- }
-- }
-- endmntent(mnt);
--
-- if (found_cd)
-- Com_Error (ERR_FATAL, "Could not find a Quake2 CD in your CD drive.");
-- Com_Error (ERR_FATAL, "Unable to find a mounted iso9660 file system.\n"
-- "You must mount the Quake2 CD in a cdrom drive in order to play.");
-+ FILE *mnt;
-+ struct mntent *ent;
-+ char path[MAX_OSPATH];
-+ struct stat st;
-+ qboolean found_cd = false;
-+
-+ static qboolean checked = false;
-+
-+ if (checked)
-+ return;
-+
-+ if ((mnt = setmntent("/etc/mtab", "r")) == NULL)
-+ Com_Error(ERR_FATAL, "Can't read mount table to determine mounted cd location.");
-+
-+ while ((ent = getmntent(mnt)) != NULL) {
-+ if (strcmp(ent->mnt_type, "iso9660") == 0) {
-+ // found a cd file system
-+ found_cd = true;
-+ sprintf(path, "%s/%s", ent->mnt_dir, "install/data/quake2.exe");
-+ if (stat(path, &st) == 0) {
-+ // found it
-+ checked = true;
-+ endmntent(mnt);
-+ return;
-+ }
-+ sprintf(path, "%s/%s", ent->mnt_dir, "Install/Data/quake2.exe");
-+ if (stat(path, &st) == 0) {
-+ // found it
-+ checked = true;
-+ endmntent(mnt);
-+ return;
-+ }
-+ sprintf(path, "%s/%s", ent->mnt_dir, "quake2.exe");
-+ if (stat(path, &st) == 0) {
-+ // found it
-+ checked = true;
-+ endmntent(mnt);
-+ return;
-+ }
-+ }
-+ }
-+ endmntent(mnt);
-+
-+ if (found_cd)
-+ Com_Error (ERR_FATAL, "Could not find a Quake2 CD in your CD drive.");
-+ Com_Error (ERR_FATAL, "Unable to find a mounted iso9660 file system.\n"
-+ "You must mount the Quake2 CD in a cdrom drive in order to play.");
- }
- #endif
-
-@@ -386,19 +384,19 @@ Sys_MakeCodeWriteable
- void Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length)
- {
-
-- int r;
-- unsigned long addr;
-- int psize = getpagesize();
-+ int r;
-+ unsigned long addr;
-+ int psize = getpagesize();
-
-- addr = (startaddr & ~(psize-1)) - psize;
-+ addr = (startaddr & ~(psize-1)) - psize;
-
--// fprintf(stderr, "writable code %lx(%lx)-%lx, length=%lx\n", startaddr,
--// addr, startaddr+length, length);
-+// fprintf(stderr, "writable code %lx(%lx)-%lx, length=%lx\n", startaddr,
-+// addr, startaddr+length, length);
-
-- r = mprotect((char*)addr, length + startaddr - addr + psize, 7);
-+ r = mprotect((char*)addr, length + startaddr - addr + psize, 7);
-
-- if (r < 0)
-- Sys_Error("Protection change failed\n");
-+ if (r < 0)
-+ Sys_Error("Protection change failed\n");
-
- }
-
+ do {
+ newtime = Sys_Milliseconds ();
diff --git a/src/linux/vid_so.c b/src/linux/vid_so.c
-index a060303..d456865 100644
+index a060303..fa326b5 100644
--- a/src/linux/vid_so.c
+++ b/src/linux/vid_so.c
-@@ -140,12 +140,12 @@ typedef struct vidmode_s
+@@ -140,7 +140,7 @@ typedef struct vidmode_s
vidmode_t vid_modes[] =
{
@@ -835,12 +408,6 @@ index a060303..d456865 100644
{ "Mode 1: 400x300", 400, 300, 1 },
{ "Mode 2: 512x384", 512, 384, 2 },
{ "Mode 3: 640x480", 640, 480, 3 },
- { "Mode 4: 800x600", 800, 600, 4 },
-- { "Mode 5: 960x720", 960, 720, 5 },
-+ { "Mode 5: 960x720", 960, 3720, 5 },
- { "Mode 6: 1024x768", 1024, 768, 6 },
- { "Mode 7: 1152x864", 1152, 864, 7 },
- { "Mode 8: 1280x1024", 1280, 1024, 8 },
@@ -239,8 +239,11 @@ qboolean VID_LoadRefresh( char *name )
//regain root
seteuid(saved_euid);