From 0264c6d9469e0ab844cf5fdf5767340c46ff1b6a Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Tue, 14 Aug 2018 10:40:50 +0200 Subject: [PATCH 1/7] Remove DOGG compile time option. Having OGG optional only complicates things and is unnecessary now that the dependencies to libvorbis and libogg are gone. --- CMakeLists.txt | 5 ----- Makefile | 12 ------------ src/client/cl_cin.c | 2 -- src/client/cl_main.c | 3 +-- src/client/cl_network.c | 2 -- src/client/cl_parse.c | 2 -- src/client/cl_screen.c | 3 +-- src/client/cl_view.c | 4 +--- src/client/menu/menu.c | 14 -------------- src/client/sound/header/vorbis.h | 8 -------- src/client/sound/ogg.c | 5 ----- src/client/sound/openal.c | 2 -- src/client/sound/sdl.c | 2 -- src/client/sound/sound.c | 5 ----- src/common/filesystem.c | 6 ++---- src/common/frame.c | 5 ----- 16 files changed, 5 insertions(+), 75 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index afdaca9b..f3426ca3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,6 @@ string(REPLACE "-O3" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") # yquake2 compilation options option(ZIP_SUPPORT "ZIP support" ON) -option(OGG_SUPPORT "OGG Vorbis playback support (Music)" ON) option(OPENAL_SUPPORT "OpenAL support" ON) option(SYSTEMWIDE_SUPPORT "Enable systemwide installation of game assets" OFF) @@ -102,10 +101,6 @@ if(${ZIP_SUPPORT}) endif() endif() -if(${OGG_SUPPORT}) - add_definitions(-DOGG) -endif() - if(${OPENAL_SUPPORT}) find_package(OpenAL) diff --git a/Makefile b/Makefile index 576d1ee9..9d250bcc 100755 --- a/Makefile +++ b/Makefile @@ -25,10 +25,6 @@ # User configurable options # ------------------------- -# Enables OGG/Vorbis support. OGG/Vorbis files can be -# used as a substitute of CD audio playback. -WITH_OGG:=yes - # Enables the optional OpenAL sound system. # To use it your system needs libopenal.so.1 # or openal32.dll (we recommend openal-soft) @@ -337,10 +333,6 @@ build/client/%.o: %.c ${Q}mkdir -p $(@D) ${Q}$(CC) -c $(CFLAGS) $(SDLCFLAGS) $(INCLUDE) -o $@ $< -ifeq ($(WITH_OGG),yes) -release/yquake2.exe : CFLAGS += -DOGG -endif - ifeq ($(WITH_OPENAL),yes) release/yquake2.exe : CFLAGS += -DUSE_OPENAL -DDEFAULT_OPENAL_DRIVER='"openal32.dll"' -DDLOPEN_OPENAL endif @@ -372,10 +364,6 @@ endif release/quake2 : CFLAGS += -Wno-unused-result -ifeq ($(WITH_OGG),yes) -release/quake2 : CFLAGS += -DOGG -endif - ifeq ($(WITH_OPENAL),yes) ifeq ($(DLOPEN_OPENAL),yes) ifeq ($(YQ2_OSTYPE), OpenBSD) diff --git a/src/client/cl_cin.c b/src/client/cl_cin.c index 03662c8c..3551e974 100644 --- a/src/client/cl_cin.c +++ b/src/client/cl_cin.c @@ -630,9 +630,7 @@ SCR_PlayCinematic(char *arg) In_FlushQueue(); /* make sure background music is not playing */ -#ifdef OGG OGG_Stop(); -#endif cl.cinematicframe = 0; dot = strstr(arg, "."); diff --git a/src/client/cl_main.c b/src/client/cl_main.c index f8950047..0f6cdbe8 100644 --- a/src/client/cl_main.c +++ b/src/client/cl_main.c @@ -906,9 +906,8 @@ CL_Shutdown(void) Key_WriteConsoleHistory(); -#ifdef OGG OGG_Stop(); -#endif + S_Shutdown(); IN_Shutdown(); VID_Shutdown(); diff --git a/src/client/cl_network.c b/src/client/cl_network.c index 211446ad..df507b32 100644 --- a/src/client/cl_network.c +++ b/src/client/cl_network.c @@ -321,9 +321,7 @@ CL_Disconnect(void) SCR_StopCinematic(); -#ifdef OGG OGG_Stop(); -#endif if (cls.demorecording) { diff --git a/src/client/cl_parse.c b/src/client/cl_parse.c index 83758feb..acfb1c6a 100644 --- a/src/client/cl_parse.c +++ b/src/client/cl_parse.c @@ -1078,7 +1078,6 @@ CL_ParseConfigString(void) { CL_SetLightstyle(i - CS_LIGHTS); } -#ifdef OGG else if (i == CS_CDTRACK) { if (cl.refresh_prepped) @@ -1086,7 +1085,6 @@ CL_ParseConfigString(void) OGG_PlayTrack((int)strtol(cl.configstrings[CS_CDTRACK], (char **)NULL, 10)); } } -#endif else if ((i >= CS_MODELS) && (i < CS_MODELS + MAX_MODELS)) { if (cl.refresh_prepped) diff --git a/src/client/cl_screen.c b/src/client/cl_screen.c index cc6cf878..b0e2ca4f 100644 --- a/src/client/cl_screen.c +++ b/src/client/cl_screen.c @@ -567,9 +567,8 @@ SCR_BeginLoadingPlaque(void) { S_StopAllSounds(); cl.sound_prepped = false; /* don't play ambients */ -#ifdef OGG + OGG_Stop(); -#endif if (cls.disable_screen) { diff --git a/src/client/cl_view.c b/src/client/cl_view.c index 6d0333cd..914e31fc 100644 --- a/src/client/cl_view.c +++ b/src/client/cl_view.c @@ -361,10 +361,9 @@ CL_PrepRefresh(void) cl.refresh_prepped = true; cl.force_refdef = true; /* make sure we have a valid refdef */ -#if defined(OGG) + /* start the cd track */ int track = (int)strtol(cl.configstrings[CS_CDTRACK], (char **)NULL, 10); - /* start the cd track */ if (Cvar_VariableValue("ogg_shuffle")) { OGG_PlayTrack(track); @@ -373,7 +372,6 @@ CL_PrepRefresh(void) { OGG_PlayTrack(track); } -#endif } float diff --git a/src/client/menu/menu.c b/src/client/menu/menu.c index 52eaa12b..bea10657 100644 --- a/src/client/menu/menu.c +++ b/src/client/menu/menu.c @@ -1053,11 +1053,9 @@ static menulist_s s_options_lookstrafe_box; static menulist_s s_options_crosshair_box; static menuslider_s s_options_sfxvolume_slider; static menuslider_s s_options_haptic_slider; -#if defined(OGG) static menulist_s s_options_oggshuffle_box; static menuslider_s s_options_oggvolume_slider; static menulist_s s_options_oggenable_box; -#endif static menulist_s s_options_quality_list; static menulist_s s_options_console_action; @@ -1117,8 +1115,6 @@ static void ControlsSetMenuItemValues(void) { s_options_sfxvolume_slider.curvalue = Cvar_VariableValue("s_volume") * 10; - -#if defined(OGG) s_options_oggshuffle_box.curvalue = (Cvar_VariableValue("ogg_shuffle") != 0); s_options_oggvolume_slider.curvalue = Cvar_VariableValue("ogg_volume") * 10; s_options_oggenable_box.curvalue = (Cvar_VariableValue("ogg_enable") != 0); @@ -1134,7 +1130,6 @@ ControlsSetMenuItemValues(void) { s_options_oggshuffle_box.curvalue = 0; } -#endif s_options_quality_list.curvalue = (Cvar_VariableValue("s_loadas8bit") == 0); s_options_sensitivity_slider.curvalue = sensitivity->value * 2; @@ -1174,7 +1169,6 @@ UpdateVolumeFunc(void *unused) Cvar_SetValue("s_volume", s_options_sfxvolume_slider.curvalue / 10); } -#if defined(OGG) static void OGGShuffleFunc(void *unused) { @@ -1223,7 +1217,6 @@ EnableOGGMusic(void *unused) OGG_Shutdown(); } } -#endif extern void Key_ClearTyping(void); @@ -1280,8 +1273,6 @@ UpdateSoundQualityFunc(void *unused) static void Options_MenuInit(void) { - -#ifdef OGG static const char *ogg_music_items[] = { "disabled", @@ -1295,7 +1286,6 @@ Options_MenuInit(void) "enabled", 0 }; -#endif static const char *quality_items[] = { @@ -1334,7 +1324,6 @@ Options_MenuInit(void) s_options_sfxvolume_slider.minvalue = 0; s_options_sfxvolume_slider.maxvalue = 10; -#ifdef OGG s_options_oggvolume_slider.generic.type = MTYPE_SLIDER; s_options_oggvolume_slider.generic.x = 0; s_options_oggvolume_slider.generic.y = 10; @@ -1356,7 +1345,6 @@ Options_MenuInit(void) s_options_oggshuffle_box.generic.name = "Shuffle"; s_options_oggshuffle_box.generic.callback = OGGShuffleFunc; s_options_oggshuffle_box.itemnames = ogg_shuffle; -#endif s_options_quality_list.generic.type = MTYPE_SPINCONTROL; s_options_quality_list.generic.x = 0; @@ -1438,11 +1426,9 @@ Options_MenuInit(void) Menu_AddItem(&s_options_menu, (void *)&s_options_sfxvolume_slider); -#ifdef OGG Menu_AddItem(&s_options_menu, (void *)&s_options_oggvolume_slider); Menu_AddItem(&s_options_menu, (void *)&s_options_oggenable_box); Menu_AddItem(&s_options_menu, (void *)&s_options_oggshuffle_box); -#endif Menu_AddItem(&s_options_menu, (void *)&s_options_quality_list); Menu_AddItem(&s_options_menu, (void *)&s_options_sensitivity_slider); Menu_AddItem(&s_options_menu, (void *)&s_options_alwaysrun_box); diff --git a/src/client/sound/header/vorbis.h b/src/client/sound/header/vorbis.h index 48c0495a..d94e8cf3 100644 --- a/src/client/sound/header/vorbis.h +++ b/src/client/sound/header/vorbis.h @@ -22,16 +22,9 @@ * ======================================================================= */ -#ifdef OGG - #ifndef CL_SOUND_VORBIS_H #define CL_SOUND_VORBIS_H -/* The OGG codec can return the samples in a number - * of different formats, we use the standard signed - * short format. */ -#define OGG_SAMPLEWIDTH 2 - typedef enum { PLAY, @@ -47,4 +40,3 @@ void OGG_Stop(void); void OGG_Stream(void); #endif -#endif diff --git a/src/client/sound/ogg.c b/src/client/sound/ogg.c index fa332df7..830c5b94 100644 --- a/src/client/sound/ogg.c +++ b/src/client/sound/ogg.c @@ -27,8 +27,6 @@ * ======================================================================= */ -#ifdef OGG - #ifndef _WIN32 #include #endif @@ -624,6 +622,3 @@ OGG_Shutdown(void) ogg_started = false; } - -#endif /* OGG */ - diff --git a/src/client/sound/openal.c b/src/client/sound/openal.c index 1b97fc24..ac87544f 100644 --- a/src/client/sound/openal.c +++ b/src/client/sound/openal.c @@ -681,9 +681,7 @@ AL_Update(void) AL_AddLoopSounds(); /* add music */ -#ifdef OGG OGG_Stream(); -#endif AL_StreamUpdate(); AL_IssuePlaysounds(); diff --git a/src/client/sound/sdl.c b/src/client/sound/sdl.c index 470f2427..10c6abae 100644 --- a/src/client/sound/sdl.c +++ b/src/client/sound/sdl.c @@ -1168,10 +1168,8 @@ SDL_Update(void) Com_Printf("----(%i)---- painted: %i\n", total, paintedtime); } -#ifdef OGG /* stream music */ OGG_Stream(); -#endif if (!sound.buffer) { diff --git a/src/client/sound/sound.c b/src/client/sound/sound.c index 33d89b70..594c9456 100644 --- a/src/client/sound/sound.c +++ b/src/client/sound/sound.c @@ -1084,9 +1084,7 @@ S_Init(void) num_sfx = 0; paintedtime = 0; -#ifdef OGG OGG_Init(); -#endif Com_Printf("Sound sampling rate: %i\n", sound.speed); S_StopAllSounds(); @@ -1110,10 +1108,7 @@ S_Shutdown(void) } S_StopAllSounds(); - -#ifdef OGG OGG_Shutdown(); -#endif /* free all sounds */ for (i = 0, sfx = known_sfx; i < num_sfx; i++, sfx++) diff --git a/src/common/filesystem.c b/src/common/filesystem.c index 5ccd3f2c..6fb439bf 100644 --- a/src/common/filesystem.c +++ b/src/common/filesystem.c @@ -28,9 +28,7 @@ #include "header/common.h" #include "header/glob.h" -#ifdef OGG #include "../client/sound/header/vorbis.h" -#endif #ifdef ZIP #include "unzip/unzip.h" @@ -1576,7 +1574,7 @@ FS_BuildGameSpecificSearchPath(char *dir) // the gamedir has changed, so read in the corresponding configs Qcommon_ExecConfigs(false); -#if !defined(DEDICATED_ONLY) && defined(OGG) +#ifndef DEDICATED_ONLY // this function is called whenever the game cvar changes => the player wants to switch to another mod // in that case the list of music tracks needs to be loaded again (=> tracks are possibly from the new mod dir) OGG_InitTrackList(); @@ -1672,7 +1670,7 @@ FS_InitFilesystem(void) { FS_BuildGameSpecificSearchPath(fs_gamedirvar->string); } -#if !defined(DEDICATED_ONLY) && defined(OGG) +#ifndef DEDICATED_ONLY else { // no mod, but we still need to get the list of OGG tracks for background music diff --git a/src/common/frame.c b/src/common/frame.c index 4719c9dd..1cbb085d 100644 --- a/src/common/frame.c +++ b/src/common/frame.c @@ -102,11 +102,6 @@ Qcommon_Buildstring(void) #ifndef DEDICATED_ONLY printf("Client build options:\n"); -#ifdef OGG - printf(" + OGG/Vorbis\n"); -#else - printf(" - OGG/Vorbis\n"); -#endif #ifdef USE_OPENAL printf(" + OpenAL audio\n"); #else From daf3dc6f417c6aa4359d0a60dc043dc4f9b195e4 Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Tue, 14 Aug 2018 11:12:38 +0200 Subject: [PATCH 2/7] Remove ZIP compile time option. Having ZIP optional only complicates things and is unnecessary now that the dependency to zlib is gone. --- CMakeLists.txt | 16 ++++++------ Makefile | 32 ++++++----------------- src/client/vid/vid.c | 6 ----- src/common/filesystem.c | 56 ++++------------------------------------- src/common/frame.c | 5 ---- 5 files changed, 20 insertions(+), 95 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f3426ca3..bddb0f61 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,7 +36,6 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -fno-strict-aliasing -fwrap string(REPLACE "-O3" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") # yquake2 compilation options -option(ZIP_SUPPORT "ZIP support" ON) option(OPENAL_SUPPORT "OpenAL support" ON) option(SYSTEMWIDE_SUPPORT "Enable systemwide installation of game assets" OFF) @@ -75,6 +74,13 @@ if(${SYSTEMWIDE_SUPPORT}) add_definitions(-DSYSTEMWIDE) endif() +# We need to pass some options to minizip / unzip +add_definitions(-DNOUNCRYPT) + +if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux" OR NOT CMAKE_SYSTEM_NAME MATCHES "Windows") + add_definitions(-DIOAPI_NO_64) +endif() + # Required libraries to build the different components of the binaries. Find # them and add the include/linker directories and flags (in case the package # manager find it in a weird place) @@ -93,14 +99,6 @@ if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "FreeBSD") list(APPEND yquake2ServerLinkerFlags ${EXECINFO_LIBRARIES}) endif() -if(${ZIP_SUPPORT}) - add_definitions(-DZIP -DNOUNCRYPT) - - if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux" OR NOT CMAKE_SYSTEM_NAME MATCHES "Windows") - add_definitions(-DIOAPI_NO_64) - endif() -endif() - if(${OPENAL_SUPPORT}) find_package(OpenAL) diff --git a/Makefile b/Makefile index 9d250bcc..94a5cb6c 100755 --- a/Makefile +++ b/Makefile @@ -37,10 +37,6 @@ WITH_OPENAL:=yes # is ignored, OpenAL is always loaded at runtime. DLOPEN_OPENAL:=yes -# Enables opening of ZIP files (also known as .pk3 paks). -# Adds a dependency to libz -WITH_ZIP:=yes - # Enable systemwide installation of game assets WITH_SYSTEMWIDE:=no @@ -206,6 +202,9 @@ ZIPCFLAGS += -DIOAPI_NO_64 endif endif +# We don't support encrypted ZIP files. +ZIPCFLAGS += -DNOUNCRYPT + # ---------- # Extra CFLAGS for SDL @@ -289,7 +288,6 @@ config: @echo "Build configuration" @echo "============================" @echo "WITH_OPENAL = $(WITH_OPENAL)" - @echo "WITH_ZIP = $(WITH_ZIP)" @echo "WITH_SYSTEMWIDE = $(WITH_SYSTEMWIDE)" @echo "WITH_SYSTEMDIR = $(WITH_SYSTEMDIR)" @echo "============================" @@ -331,16 +329,12 @@ client: build/client/%.o: %.c @echo "===> CC $<" ${Q}mkdir -p $(@D) - ${Q}$(CC) -c $(CFLAGS) $(SDLCFLAGS) $(INCLUDE) -o $@ $< + ${Q}$(CC) -c $(CFLAGS) $(SDLCFLAGS) $(ZIPCFLAGS) $(INCLUDE) -o $@ $< ifeq ($(WITH_OPENAL),yes) release/yquake2.exe : CFLAGS += -DUSE_OPENAL -DDEFAULT_OPENAL_DRIVER='"openal32.dll"' -DDLOPEN_OPENAL endif -ifeq ($(WITH_ZIP),yes) -release/yquake2.exe : CFLAGS += -DZIP -DNOUNCRYPT -endif - release/yquake2.exe : LDFLAGS += -mwindows else # not Windows @@ -353,7 +347,7 @@ client: build/client/%.o: %.c @echo "===> CC $<" ${Q}mkdir -p $(@D) - ${Q}$(CC) -c $(CFLAGS) $(SDLCFLAGS) $(INCLUDE) -o $@ $< + ${Q}$(CC) -c $(CFLAGS) $(SDLCFLAGS) $(ZIPCFLAGS) $(INCLUDE) -o $@ $< ifeq ($(YQ2_OSTYPE), Darwin) build/client/%.o : %.m @@ -384,10 +378,6 @@ endif # Darwin endif # !DLOPEN_OPENAL endif # WITH_OPENAL -ifeq ($(WITH_ZIP),yes) -release/quake2 : CFLAGS += $(ZIPCFLAGS) -DZIP -DNOUNCRYPT -endif - ifeq ($(YQ2_OSTYPE), FreeBSD) release/quake2 : LDFLAGS += -Wl,-z,origin,-rpath='$$ORIGIN/lib' -lexecinfo else ifeq ($(YQ2_OSTYPE), Linux) @@ -423,14 +413,12 @@ server: build/server/%.o: %.c @echo "===> CC $<" ${Q}mkdir -p $(@D) - ${Q}$(CC) -c $(CFLAGS) $(INCLUDE) -o $@ $< + ${Q}$(CC) -c $(CFLAGS) $(ZIPCFLAGS) $(INCLUDE) -o $@ $< release/q2ded.exe : CFLAGS += -DDEDICATED_ONLY -ifeq ($(WITH_ZIP),yes) -release/q2ded.exe : CFLAGS += -DZIP -DNOUNCRYPT -endif else # not Windows + server: @echo "===> Building q2ded" ${Q}mkdir -p release @@ -439,14 +427,10 @@ server: build/server/%.o: %.c @echo "===> CC $<" ${Q}mkdir -p $(@D) - ${Q}$(CC) -c $(CFLAGS) $(INCLUDE) -o $@ $< + ${Q}$(CC) -c $(CFLAGS) $(ZIPCFLAGS) $(INCLUDE) -o $@ $< release/q2ded : CFLAGS += -DDEDICATED_ONLY -Wno-unused-result -ifeq ($(WITH_ZIP),yes) -release/q2ded : CFLAGS += $(ZIPCFLAGS) -DZIP -DNOUNCRYPT -endif - ifeq ($(YQ2_OSTYPE), FreeBSD) release/q2ded : LDFLAGS += -lexecinfo endif diff --git a/src/client/vid/vid.c b/src/client/vid/vid.c index 050a81f3..d9499ea3 100644 --- a/src/client/vid/vid.c +++ b/src/client/vid/vid.c @@ -35,10 +35,6 @@ // Screenshots // ----------- -#ifdef ZIP -// If we build with zip support, zlib is available and -// we can use that for better PNG compression. - #include "../../common/unzip/miniz.h" static unsigned char* @@ -64,8 +60,6 @@ compress_for_stbiw(unsigned char *data, int data_len, int *out_len, int quality) } #define STBIW_ZLIB_COMPRESS compress_for_stbiw -#endif - #define STB_IMAGE_WRITE_IMPLEMENTATION #include "header/stb_image_write.h" diff --git a/src/common/filesystem.c b/src/common/filesystem.c index 6fb439bf..ab94994f 100644 --- a/src/common/filesystem.c +++ b/src/common/filesystem.c @@ -27,12 +27,10 @@ #include "header/common.h" #include "header/glob.h" +#include "unzip/unzip.h" #include "../client/sound/header/vorbis.h" -#ifdef ZIP - #include "unzip/unzip.h" -#endif #define MAX_HANDLES 512 #define MAX_PAKS 100 @@ -48,9 +46,7 @@ typedef struct char name[MAX_QPATH]; fsMode_t mode; FILE *file; /* Only one will be used. */ -#ifdef ZIP unzFile *zip; /* (file or zip) */ -#endif } fsHandle_t; typedef struct fsLink_s @@ -73,9 +69,7 @@ typedef struct char name[MAX_OSPATH]; int numFiles; FILE *pak; -#ifdef ZIP unzFile *pk3; -#endif fsPackFile_t *files; } fsPack_t; @@ -89,9 +83,7 @@ typedef struct fsSearchPath_s typedef enum { PAK, -#ifdef ZIP PK3 -#endif } fsPackFormat_t; typedef struct @@ -108,11 +100,9 @@ fsSearchPath_t *fs_baseSearchPaths; /* Pack formats / suffixes. */ fsPackTypes_t fs_packtypes[] = { {"pak", PAK}, -#ifdef ZIP {"pk2", PK3}, {"pk3", PK3}, {"zip", PK3} -#endif }; char datadir[MAX_OSPATH]; @@ -140,7 +130,6 @@ fsRawPath_t *fs_rawPath; // -------- -#ifdef ZIP #if _WIN32 /* * We need some trickery to make minizip Unicode compatible... @@ -179,7 +168,6 @@ static voidpf ZCALLBACK fopen_file_func_utf(voidpf opaque, const char *filename, return file; } #endif -#endif // -------- @@ -316,11 +304,7 @@ FS_HandleForFile(const char *path, fileHandle_t *f) for (i = 0; i < MAX_HANDLES; i++, handle++) { - if ((handle->file == NULL) -#ifdef ZIP - && (handle->zip == NULL) -#endif - ) + if ((handle->file == NULL) && (handle->zip == NULL)) { Q_strlcpy(handle->name, path, sizeof(handle->name)); *f = i + 1; @@ -367,13 +351,11 @@ FS_FCloseFile(fileHandle_t f) { fclose(handle->file); } -#ifdef ZIP else if (handle->zip) { unzCloseCurrentFile(handle->zip); unzClose(handle->zip); } -#endif memset(handle, 0, sizeof(*handle)); } @@ -443,7 +425,6 @@ FS_FOpenFile(const char *name, fileHandle_t *f, qboolean gamedir_only) return pack->files[i].size; } } -#ifdef ZIP else if (pack->pk3) { /* PK3 */ @@ -468,7 +449,6 @@ FS_FOpenFile(const char *name, fileHandle_t *f, qboolean gamedir_only) unzClose(handle->zip); } } -#endif Com_Error(ERR_FATAL, "Couldn't reopen '%s'", pack->name); } @@ -539,12 +519,10 @@ FS_Read(void *buffer, int size, fileHandle_t f) { r = fread(buf, 1, remaining, handle->file); } -#ifdef ZIP else if (handle->zip) { r = unzReadCurrentFile(handle->zip, buf, remaining); } -#endif else { return 0; @@ -607,12 +585,10 @@ FS_FRead(void *buffer, int size, int count, fileHandle_t f) { r = fread(buf, 1, remaining, handle->file); } -#ifdef ZIP else if (handle->zip) { r = unzReadCurrentFile(handle->zip, buf, remaining); } -#endif else { return 0; @@ -759,9 +735,7 @@ FS_LoadPAK(const char *packPath) pack = Z_Malloc(sizeof(fsPack_t)); Q_strlcpy(pack->name, packPath, sizeof(pack->name)); pack->pak = handle; -#ifdef ZIP pack->pk3 = NULL; -#endif pack->numFiles = numFiles; pack->files = files; @@ -770,7 +744,6 @@ FS_LoadPAK(const char *packPath) return pack; } -#ifdef ZIP /* * Takes an explicit (not game tree related) path to a pack file. * @@ -844,7 +817,6 @@ FS_LoadPK3(const char *packPath) return pack; } -#endif /* * Allows enumerating all of the directories in the search path. @@ -909,11 +881,7 @@ FS_Path_f(void) for (i = 0, handle = fs_handles; i < MAX_HANDLES; i++, handle++) { - if ((handle->file != NULL) -#ifdef ZIP - || (handle->zip != NULL) -#endif - ) + if ((handle->file != NULL) || (handle->zip != NULL)) { Com_Printf("Handle %i: '%s'.\n", i + 1, handle->name); } @@ -925,11 +893,8 @@ FS_Path_f(void) } Com_Printf("----------------------\n"); -#ifdef ZIP + Com_Printf("%i files in PAK/PK2/PK3/ZIP files.\n", totalFiles); -#else - Com_Printf("%i files in PAK/PK2 files.\n", totalFiles); -#endif } /* @@ -1371,11 +1336,9 @@ FS_AddDirToSearchPath(char *dir, qboolean create) { case PAK: pack = FS_LoadPAK(path); break; -#ifdef ZIP case PK3: pack = FS_LoadPK3(path); break; -#endif } if (pack == NULL) @@ -1417,11 +1380,9 @@ FS_AddDirToSearchPath(char *dir, qboolean create) { case PAK: pack = FS_LoadPAK(list[j]); break; -#ifdef ZIP case PK3: pack = FS_LoadPK3(list[j]); break; -#endif } if (pack == NULL) @@ -1505,12 +1466,10 @@ FS_BuildGameSpecificSearchPath(char *dir) fclose(fs_searchPaths->pack->pak); } -#ifdef ZIP if (fs_searchPaths->pack->pk3) { unzClose(fs_searchPaths->pack->pk3); } -#endif Z_Free(fs_searchPaths->pack->files); Z_Free(fs_searchPaths->pack); @@ -1524,12 +1483,7 @@ FS_BuildGameSpecificSearchPath(char *dir) /* Close open files for game dir. */ for (i = 0; i < MAX_HANDLES; i++) { - if (strstr(fs_handles[i].name, dir) && - ((fs_handles[i].file != NULL) -#ifdef ZIP - || (fs_handles[i].zip != NULL) -#endif - )) + if (strstr(fs_handles[i].name, dir) && ((fs_handles[i].file != NULL) || (fs_handles[i].zip != NULL))) { FS_FCloseFile(i); } diff --git a/src/common/frame.c b/src/common/frame.c index 1cbb085d..a6332939 100644 --- a/src/common/frame.c +++ b/src/common/frame.c @@ -107,11 +107,6 @@ Qcommon_Buildstring(void) #else printf(" - OpenAL audio\n"); #endif -#ifdef ZIP - printf(" + Zip file support\n"); -#else - printf(" - Zip file support\n"); -#endif #endif printf("Platform: %s\n", YQ2OSTYPE); From cf09fb2a99a140c66874a5e7b5a42b3170f769af Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Tue, 14 Aug 2018 11:51:55 +0200 Subject: [PATCH 3/7] Remove support for static linked OpenAL. We haven't used that for years and it just complicates things. --- Makefile | 23 ++++------------------- src/client/sound/qal.c | 10 ++-------- 2 files changed, 6 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index 94a5cb6c..28737ed4 100755 --- a/Makefile +++ b/Makefile @@ -31,12 +31,6 @@ # installed WITH_OPENAL:=yes -# Enables optional runtime loading of OpenAL (dlopen or -# similar). If set to "no", the library is linked in at -# compile time in the normal way. On Windows this option -# is ignored, OpenAL is always loaded at runtime. -DLOPEN_OPENAL:=yes - # Enable systemwide installation of game assets WITH_SYSTEMWIDE:=no @@ -332,7 +326,7 @@ build/client/%.o: %.c ${Q}$(CC) -c $(CFLAGS) $(SDLCFLAGS) $(ZIPCFLAGS) $(INCLUDE) -o $@ $< ifeq ($(WITH_OPENAL),yes) -release/yquake2.exe : CFLAGS += -DUSE_OPENAL -DDEFAULT_OPENAL_DRIVER='"openal32.dll"' -DDLOPEN_OPENAL +release/yquake2.exe : CFLAGS += -DUSE_OPENAL -DDEFAULT_OPENAL_DRIVER='"openal32.dll"' endif release/yquake2.exe : LDFLAGS += -mwindows @@ -359,23 +353,14 @@ endif release/quake2 : CFLAGS += -Wno-unused-result ifeq ($(WITH_OPENAL),yes) -ifeq ($(DLOPEN_OPENAL),yes) ifeq ($(YQ2_OSTYPE), OpenBSD) -release/quake2 : CFLAGS += -DUSE_OPENAL -DDEFAULT_OPENAL_DRIVER='"libopenal.so"' -DDLOPEN_OPENAL +release/quake2 : CFLAGS += -DUSE_OPENAL -DDEFAULT_OPENAL_DRIVER='"libopenal.so"' else ifeq ($(YQ2_OSTYPE), Darwin) -release/quake2 : CFLAGS += -DUSE_OPENAL -DDEFAULT_OPENAL_DRIVER='"libopenal.dylib"' -I/usr/local/opt/openal-soft/include -DDLOPEN_OPENAL +release/quake2 : CFLAGS += -DUSE_OPENAL -DDEFAULT_OPENAL_DRIVER='"libopenal.dylib"' -I/usr/local/opt/openal-soft/include release/quake2 : LDFLAGS += -L/usr/local/opt/openal-soft/lib -rpath /usr/local/opt/openal-soft/lib else -release/quake2 : CFLAGS += -DUSE_OPENAL -DDEFAULT_OPENAL_DRIVER='"libopenal.so.1"' -DDLOPEN_OPENAL +release/quake2 : CFLAGS += -DUSE_OPENAL -DDEFAULT_OPENAL_DRIVER='"libopenal.so.1"' endif -else # !DLOPEN_OPENAL -release/quake2 : CFLAGS += -DUSE_OPENAL -release/quake2 : LDFLAGS += -lopenal -ifeq ($(YQ2_OSTYPE), Darwin) -release/quake2 : CFLAGS += -I/usr/local/opt/openal-soft/include -release/quake2 : LDFLAGS += -L/usr/local/opt/openal-soft/lib -rpath /usr/local/opt/openal-soft/lib -endif # Darwin -endif # !DLOPEN_OPENAL endif # WITH_OPENAL ifeq ($(YQ2_OSTYPE), FreeBSD) diff --git a/src/client/sound/qal.c b/src/client/sound/qal.c index 746c0757..fb624ba1 100644 --- a/src/client/sound/qal.c +++ b/src/client/sound/qal.c @@ -43,9 +43,7 @@ static ALCcontext *context; static ALCdevice *device; static cvar_t *al_device; -#ifdef DLOPEN_OPENAL static cvar_t *al_driver; -#endif static void *handle; /* Function pointers for OpenAL management */ @@ -341,7 +339,6 @@ QAL_Init() { al_device = Cvar_Get("al_device", "", CVAR_ARCHIVE); -#ifdef DLOPEN_OPENAL /* DEFAULT_OPENAL_DRIVER is defined at compile time via the compiler */ al_driver = Cvar_Get("al_driver", DEFAULT_OPENAL_DRIVER, CVAR_ARCHIVE); @@ -355,11 +352,8 @@ QAL_Init() Com_Printf("Loading %s failed! Disabling OpenAL.\n", al_driver->string); return false; } -# define ALSYMBOL(handle, sym) Sys_GetProcAddress(handle, #sym) -#else - handle = NULL; -# define ALSYMBOL(handle, sym) sym -#endif + + #define ALSYMBOL(handle, sym) Sys_GetProcAddress(handle, #sym) /* Connect function pointers to management functions */ qalcCreateContext = ALSYMBOL(handle, alcCreateContext); From 93aa8270adb1dbe5a954dc4f5ff3b7012f64c721 Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Tue, 14 Aug 2018 11:53:35 +0200 Subject: [PATCH 4/7] No need to print that the renderer as retexturing support. Retexturing support has been non-optional for years. --- src/client/refresh/gl1/gl1_main.c | 5 ----- src/client/refresh/gl3/gl3_main.c | 5 ----- 2 files changed, 10 deletions(-) diff --git a/src/client/refresh/gl1/gl1_main.c b/src/client/refresh/gl1/gl1_main.c index ed54b99a..ccef914d 100644 --- a/src/client/refresh/gl1/gl1_main.c +++ b/src/client/refresh/gl1/gl1_main.c @@ -1393,11 +1393,6 @@ RI_Init() R_Printf(PRINT_ALL, "Refresh: " REF_VERSION "\n"); R_Printf(PRINT_ALL, "Client: " YQ2VERSION "\n\n"); - /* Options */ - R_Printf(PRINT_ALL, "Refresher build options:\n"); - - R_Printf(PRINT_ALL, " + Retexturing support\n"); - Draw_GetPalette(); R_Register(); diff --git a/src/client/refresh/gl3/gl3_main.c b/src/client/refresh/gl3/gl3_main.c index e1a68d34..1990f071 100644 --- a/src/client/refresh/gl3/gl3_main.c +++ b/src/client/refresh/gl3/gl3_main.c @@ -435,11 +435,6 @@ GL3_Init(void) R_Printf(PRINT_ALL, "Refresh: " REF_VERSION "\n"); R_Printf(PRINT_ALL, "Client: " YQ2VERSION "\n\n"); - /* Options */ - R_Printf(PRINT_ALL, "Refresher build options:\n"); - R_Printf(PRINT_ALL, " + Retexturing support\n\n"); - - if(sizeof(float) != sizeof(GLfloat)) { // if this ever happens, things would explode because we feed vertex arrays and UBO data From f7e80c1428855fd924398281460a83d93861c110 Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Tue, 14 Aug 2018 15:01:45 +0200 Subject: [PATCH 5/7] General cleanup to the Makefile. --- Makefile | 112 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 67 insertions(+), 45 deletions(-) diff --git a/Makefile b/Makefile index 28737ed4..4654d9bf 100755 --- a/Makefile +++ b/Makefile @@ -2,17 +2,17 @@ # Makefile for the "Yamagi Quake 2 Client" # # # # Just type "make" to compile the # -# - SDL Client (quake2) # +# - Client (quake2) # # - Server (q2ded) # # - Quake II Game (baseq2) # +# - Renderer libraries (gl1, gl3, soft) # # # # Base dependencies: # # - SDL 2.0 # # - libGL # # # -# Further dependencies: # +# Optional dependencies: # # - OpenAL # -# - zlib # # # # Platforms: # # - FreeBSD # @@ -89,19 +89,22 @@ else YQ2_ARCH ?= $(shell uname -m | sed -e 's/i.86/i386/' -e 's/amd64/x86_64/' -e 's/^arm.*/arm/') endif +# On Windows / MinGW $(CC) is undefined by default. +ifeq ($(YQ2_OSTYPE),Windows) +CC := gcc +endif + # Detect the compiler ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1) COMPILER := clang -else ifeq ($(shell $(CC) -v 2>&1 | grep -c "gcc version"), 1) +COMPILERVER := $(shell $(CC) -dumpversion | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/') +else ifeq ($(shell $(CC) -v 2>&1 | grep -c -E "(gcc version|gcc-Version)"), 1) COMPILER := gcc +COMPILERVER := $(shell $(CC) -dumpversion | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/') else COMPILER := unknown endif -# Used to detect libraries. Override to foobar-linux-gnu-pkg-config when -# cross-compiling. -PKG_CONFIG ?= pkg-config - # ---------- # Base CFLAGS. @@ -121,6 +124,9 @@ PKG_CONFIG ?= pkg-config # # -MMD to generate header dependencies. (They cannot be # generated if building universal binaries on OSX) +# +# -fwrapv for defined integer wrapping. MSVC6 did this +# and the game code requires it. ifeq ($(YQ2_OSTYPE), Darwin) CFLAGS := -O2 -fno-strict-aliasing -fomit-frame-pointer \ -Wall -pipe -g -fwrapv @@ -132,11 +138,28 @@ endif # ---------- +# Switch of some annoying warnings. +ifeq ($(COMPILER), clang) + # -Wno-missing-braces because otherwise clang complains + # about totally valid 'vec3_t bla = {0}' constructs. + CFLAGS += -Wno-missing-braces +else ifeq ($(COMPILER), gcc) + # GCC 8.0 or higher. + ifeq ($(shell test $(COMPILERVER) -ge 80000; echo $$?),0) + # -Wno-format-truncation and -Wno-format-overflow + # because GCC spams about 50 false positives. + CFLAGS += -Wno-format-truncation -Wno-format-overflow + endif +endif + +# ---------- + # Defines the operating system and architecture CFLAGS += -DYQ2OSTYPE=\"$(YQ2_OSTYPE)\" -DYQ2ARCH=\"$(YQ2_ARCH)\" # ---------- +# Fore reproduceable builds, look here for details: # https://reproducible-builds.org/specs/source-date-epoch/ ifdef SOURCE_DATE_EPOCH CFLAGS += -DBUILD_DATE=\"$(shell date --utc --date="@${SOURCE_DATE_EPOCH}" +"%b %_d %Y" | sed -e 's/ /\\ /g')\" @@ -161,7 +184,7 @@ endif # ---------- -# Systemwide installation +# Systemwide installation. ifeq ($(WITH_SYSTEMWIDE),yes) CFLAGS += -DSYSTEMWIDE ifneq ($(WITH_SYSTEMDIR),"") @@ -171,14 +194,6 @@ endif # ---------- -# On Windows / MinGW $(CC) is -# undefined by default. -ifeq ($(YQ2_OSTYPE),Windows) -CC := gcc -endif - -# ---------- - # Just set IOAPI_NO_64 on everything that's not Linux or Windows, # otherwise minizip will use fopen64(), fseek64() and friends that # may be unavailable. This is - of course - not really correct, in @@ -201,7 +216,7 @@ ZIPCFLAGS += -DNOUNCRYPT # ---------- -# Extra CFLAGS for SDL +# Extra CFLAGS for SDL. SDLCFLAGS := $(shell sdl2-config --cflags) # ---------- @@ -219,7 +234,7 @@ endif # ---------- -# Extra includes for GLAD +# Local includes for GLAD. GLAD_INCLUDE = -Isrc/client/refresh/gl3/glad/include # ---------- @@ -237,13 +252,16 @@ else ifeq ($(YQ2_OSTYPE), Darwin) LDFLAGS := $(OSX_ARCH) -lm endif +# Keep symbols hidden. CFLAGS += -fvisibility=hidden LDFLAGS += -fvisibility=hidden -ifneq ($(YQ2_OSTYPE), $(filter $(YQ2_OSTYPE), Darwin OpenBSD)) -# for some reason the OSX & OpenBSD linker doesn't support this +ifneq ($(YQ2_OSTYPE), Darwin) +ifneq ($(YQ2_OSTYPE), OpenBSD) +# for some reason the OSX & OpenBSD linker doesn't support this... LDFLAGS += -Wl,--no-undefined endif +endif # ---------- @@ -254,11 +272,15 @@ else # not Darwin SDLLDFLAGS := $(shell sdl2-config --libs) endif # Darwin +# The renderer libs don't need libSDL2main, libmingw32 or -mwindows. +ifeq ($(YQ2_OSTYPE), Windows) +DLL_SDLLDFLAGS = $(subst -mwindows,,$(subst -lmingw32,,$(subst -lSDL2main,,$(SDLLDFLAGS)))) +endif + # ---------- # When make is invoked by "make VERBOSE=1" print # the compiler and linker commands. - ifdef VERBOSE Q := else @@ -289,8 +311,7 @@ config: # ---------- -# Special target to compile -# the icon on Windows +# Special target to compile the icon on Windows ifeq ($(YQ2_OSTYPE), Windows) icon: @echo "===> WR build/icon/icon.res" @@ -325,12 +346,12 @@ build/client/%.o: %.c ${Q}mkdir -p $(@D) ${Q}$(CC) -c $(CFLAGS) $(SDLCFLAGS) $(ZIPCFLAGS) $(INCLUDE) -o $@ $< +release/yquake2.exe : LDFLAGS += -mwindows + ifeq ($(WITH_OPENAL),yes) release/yquake2.exe : CFLAGS += -DUSE_OPENAL -DDEFAULT_OPENAL_DRIVER='"openal32.dll"' endif -release/yquake2.exe : LDFLAGS += -mwindows - else # not Windows client: @@ -338,16 +359,16 @@ client: ${Q}mkdir -p release $(MAKE) release/quake2 -build/client/%.o: %.c - @echo "===> CC $<" - ${Q}mkdir -p $(@D) - ${Q}$(CC) -c $(CFLAGS) $(SDLCFLAGS) $(ZIPCFLAGS) $(INCLUDE) -o $@ $< - ifeq ($(YQ2_OSTYPE), Darwin) build/client/%.o : %.m @echo "===> CC $<" ${Q}mkdir -p $(@D) ${Q}$(CC) $(OSX_ARCH) -x objective-c -c $< -o $@ +else +build/client/%.o: %.c + @echo "===> CC $<" + ${Q}mkdir -p $(@D) + ${Q}$(CC) -c $(CFLAGS) $(SDLCFLAGS) $(ZIPCFLAGS) $(INCLUDE) -o $@ $< endif release/quake2 : CFLAGS += -Wno-unused-result @@ -361,7 +382,11 @@ release/quake2 : LDFLAGS += -L/usr/local/opt/openal-soft/lib -rpath /usr/local/o else release/quake2 : CFLAGS += -DUSE_OPENAL -DDEFAULT_OPENAL_DRIVER='"libopenal.so.1"' endif -endif # WITH_OPENAL +endif + +ifeq ($(YQ2_OSTYPE), FreeBSD) +release/quake2 : LDFLAGS += -lexecinfo +endif ifeq ($(YQ2_OSTYPE), FreeBSD) release/quake2 : LDFLAGS += -Wl,-z,origin,-rpath='$$ORIGIN/lib' -lexecinfo @@ -433,10 +458,6 @@ ref_gl1: release/ref_gl1.dll : LDFLAGS += -lopengl32 -shared -# don't want the dll to link against libSDL2main or libmingw32, and no -mwindows either -# that's for the .exe only -DLL_SDLLDFLAGS = $(subst -mwindows,,$(subst -lmingw32,,$(subst -lSDL2main,,$(SDLLDFLAGS)))) - else ifeq ($(YQ2_OSTYPE), Darwin) ref_gl1: @@ -456,7 +477,7 @@ ref_gl1: release/ref_gl1.so : CFLAGS += -fPIC release/ref_gl1.so : LDFLAGS += -shared -lGL -endif # OS specific ref_gl1 shit +endif # OS specific ref_gl1 stuff build/ref_gl1/%.o: %.c @echo "===> CC $<" @@ -494,7 +515,7 @@ ref_gl3: release/ref_gl3.so : CFLAGS += -fPIC release/ref_gl3.so : LDFLAGS += -shared -endif # OS specific ref_gl3 shit +endif # OS specific ref_gl3 stuff build/ref_gl3/%.o: %.c @echo "===> CC $<" @@ -530,7 +551,7 @@ ref_soft: release/ref_soft.so : CFLAGS += -fPIC release/ref_soft.so : LDFLAGS += -shared -endif # OS specific ref_soft shit +endif # OS specific ref_soft stuff build/ref_soft/%.o: %.c @echo "===> CC $<" @@ -552,7 +573,9 @@ build/baseq2/%.o: %.c ${Q}$(CC) -c $(CFLAGS) $(INCLUDE) -o $@ $< release/baseq2/game.dll : LDFLAGS += -shared + else ifeq ($(YQ2_OSTYPE), Darwin) + game: @echo "===> Building baseq2/game.dylib" ${Q}mkdir -p release/baseq2 @@ -565,7 +588,9 @@ build/baseq2/%.o: %.c release/baseq2/game.dylib : CFLAGS += -fPIC release/baseq2/game.dylib : LDFLAGS += -shared + else # not Windows or Darwin + game: @echo "===> Building baseq2/game.so" ${Q}mkdir -p release/baseq2 @@ -868,7 +893,7 @@ endif # ---------- -# Rewrite pathes to our object directory +# Rewrite pathes to our object directory. CLIENT_OBJS = $(patsubst %,build/client/%,$(CLIENT_OBJS_)) REFGL1_OBJS = $(patsubst %,build/ref_gl1/%,$(REFGL1_OBJS_)) REFGL3_OBJS = $(patsubst %,build/ref_gl3/%,$(REFGL3_OBJS_)) @@ -878,7 +903,7 @@ GAME_OBJS = $(patsubst %,build/baseq2/%,$(GAME_OBJS_)) # ---------- -# Generate header dependencies +# Generate header dependencies. CLIENT_DEPS= $(CLIENT_OBJS:.o=.d) REFGL1_DEPS= $(REFGL1_OBJS:.o=.d) REFGL3_DEPS= $(REFGL3_OBJS:.o=.d) @@ -886,9 +911,7 @@ REFSOFT_DEPS= $(REFSOFT_OBJS:.o=.d) SERVER_DEPS= $(SERVER_OBJS:.o=.d) GAME_DEPS= $(GAME_OBJS:.o=.d) -# ---------- - -# Suck header dependencies in +# Suck header dependencies in. -include $(CLIENT_DEPS) -include $(REFGL1_DEPS) -include $(REFGL3_DEPS) @@ -903,7 +926,6 @@ release/yquake2.exe : $(CLIENT_OBJS) icon @echo "===> LD $@" ${Q}$(CC) build/icon/icon.res $(CLIENT_OBJS) $(LDFLAGS) $(SDLLDFLAGS) -o $@ $(Q)strip $@ -# the wrappper, quick'n'dirty release/quake2.exe : src/win-wrapper/wrapper.c icon $(Q)$(CC) -Wall -mwindows build/icon/icon.res src/win-wrapper/wrapper.c -o $@ $(Q)strip $@ From 692c544f3033ea1128e3af5639fa1526f49913eb Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Tue, 14 Aug 2018 15:29:41 +0200 Subject: [PATCH 6/7] Some modernizations to cmake. * Pass the same compiler flags like make. * Update FindSDL2. * Remove unneeded FindOggVorbis. There still some options missing, like the RPATHes or he ability to define the system wide installation directory. --- CMakeLists.txt | 41 +++++++----- stuff/cmake/modules/FindOggVorbis.cmake | 89 ------------------------- stuff/cmake/modules/FindSDL2.cmake | 34 +++++----- 3 files changed, 43 insertions(+), 121 deletions(-) delete mode 100644 stuff/cmake/modules/FindOggVorbis.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index bddb0f61..7905dc8a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,14 +1,14 @@ cmake_minimum_required(VERSION 3.0 FATAL_ERROR) -# Enforce "Debug" as standard build type +# Enforce "Debug" as standard build type. if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE) endif() -# CMake project configuration +# CMake project configuration. project(yquake2) -# Cmake module search path +# Cmake module search path. set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/stuff/cmake/modules ${CMAKE_MODULE_PATH}) if(YQUAKE2LIBS) @@ -22,24 +22,32 @@ if(YQUAKE2LIBS) set(ENV{SDL2DIR} ${YQUAKE2LIBS}) endif() -# Add extended path for FreeBSD and Homebrew on OS X +# Add extended path for FreeBSD and Homebrew on OS X. list(APPEND CMAKE_PREFIX_PATH /usr/local) -# Enforce compiler flags (GCC / Clang compatible, yquake2 -# won't build with another compiler anyways) +# Enforce compiler flags: # -Wall -> More warnings # -fno-strict-aliasing -> Quake 2 is far away from strict aliasing # -fwrapv -> Make signed integer overflows defined set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -fno-strict-aliasing -fwrapv") +# Switch of some annoying warnings +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-braces") +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + if (CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 8.0) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-format-truncation -Wno-format-overflow") + endif() +endif() + # Use -O2 as maximum optimization level. -O3 has it's problems with yquake2. string(REPLACE "-O3" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") -# yquake2 compilation options +# Compilation time options. option(OPENAL_SUPPORT "OpenAL support" ON) option(SYSTEMWIDE_SUPPORT "Enable systemwide installation of game assets" OFF) -# These variables will act as our list of include folders and linker flags +# These variables will act as our list of include folders and linker flags. set(yquake2IncludeDirectories) set(yquake2LinkerDirectories) set(yquake2LinkerFlags) @@ -58,23 +66,23 @@ set(SERVER_SRC_DIR ${SOURCE_DIR}/server) set(CLIENT_SRC_DIR ${SOURCE_DIR}/client) set(REF_SRC_DIR ${SOURCE_DIR}/client/refresh) -# Operating system +# Operating system. set(YQ2OSTYPE "${CMAKE_SYSTEM_NAME}" CACHE STRING "Override operation system type") add_definitions(-DYQ2OSTYPE="${YQ2OSTYPE}") -# Architecture string +# Architecture string. set(YQ2ARCH "${CMAKE_SYSTEM_PROCESSOR}" CACHE STRING "Override CPU architecture") string(REGEX REPLACE "amd64" "x86_64" ARCH ${YQ2ARCH}) string(REGEX REPLACE "i.86" "i386" ARCH ${ARCH}) string(REGEX REPLACE "^arm.*" "arm" ARCH ${ARCH}) add_definitions(-DYQ2ARCH="${ARCH}") -# Systemwide installation of game assets +# Systemwide installation of game assets. if(${SYSTEMWIDE_SUPPORT}) add_definitions(-DSYSTEMWIDE) endif() -# We need to pass some options to minizip / unzip +# We need to pass some options to minizip / unzip. add_definitions(-DNOUNCRYPT) if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux" OR NOT CMAKE_SYSTEM_NAME MATCHES "Windows") @@ -83,27 +91,29 @@ endif() # Required libraries to build the different components of the binaries. Find # them and add the include/linker directories and flags (in case the package -# manager find it in a weird place) +# manager find it in a weird place). find_package(SDL2 REQUIRED) list(APPEND yquake2IncludeDirectories "${SDL2_INCLUDE_DIR}/..") list(APPEND yquake2SDLLinkerFlags ${SDL2_LIBRARY}) +# We need an OpenGL implementation. set(OpenGL_GL_PREFERENCE GLVND) find_package(OpenGL REQUIRED) list(APPEND yquake2IncludeDirectories ${OPENGL_INCLUDE_DIR}) list(APPEND yquake2OpenGLLinkerFlags ${OPENGL_LIBRARIES}) +# FreeBSD needs libexecinfo. if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "FreeBSD") find_library(EXECINFO_LIBRARIES execinfo /usr/lib /usr/local/lib) list(APPEND yquake2ClientLinkerFlags ${EXECINFO_LIBRARIES}) list(APPEND yquake2ServerLinkerFlags ${EXECINFO_LIBRARIES}) endif() +# OpenAL support. if(${OPENAL_SUPPORT}) find_package(OpenAL) - # TODO: OS X is still missing here - if(${OPENAL_FOUND} AND NOT(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")) + if(${OPENAL_FOUND}) list(APPEND yquake2IncludeDirectories "${OPENAL_INCLUDE_DIR}") list(APPEND yquake2ClientLinkerFlags ${OPENAL_LIBRARY}) @@ -119,6 +129,7 @@ if(${OPENAL_SUPPORT}) endif() endif() +# General linker flags. if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") list(APPEND yquake2LinkerFlags "-lm -static-libgcc") else() diff --git a/stuff/cmake/modules/FindOggVorbis.cmake b/stuff/cmake/modules/FindOggVorbis.cmake deleted file mode 100644 index e72d849d..00000000 --- a/stuff/cmake/modules/FindOggVorbis.cmake +++ /dev/null @@ -1,89 +0,0 @@ -# - Try to find the OggVorbis libraries -# Once done this will define -# -# OGGVORBIS_FOUND - system has OggVorbis -# OGGVORBIS_VERSION - set either to 1 or 2 -# OGGVORBIS_INCLUDE_DIR - the OggVorbis include directory -# OGGVORBIS_LIBRARIES - The libraries needed to use OggVorbis -# OGG_LIBRARY - The Ogg library -# VORBIS_LIBRARY - The Vorbis library -# VORBISFILE_LIBRARY - The VorbisFile library -# VORBISENC_LIBRARY - The VorbisEnc library - -# Copyright (c) 2006, Richard Laerkaeng, -# -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - - -include (CheckLibraryExists) - -find_path(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h) -find_path(OGG_INCLUDE_DIR ogg/ogg.h) - -find_library(OGG_LIBRARY NAMES ogg) -find_library(VORBIS_LIBRARY NAMES vorbis) -find_library(VORBISFILE_LIBRARY NAMES vorbisfile) -find_library(VORBISENC_LIBRARY NAMES vorbisenc) - -mark_as_advanced(VORBIS_INCLUDE_DIR OGG_INCLUDE_DIR - OGG_LIBRARY VORBIS_LIBRARY VORBISFILE_LIBRARY VORBISENC_LIBRARY) - - -if (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBISENC_LIBRARY) - set(OGGVORBIS_FOUND TRUE) - - set(OGGVORBIS_LIBRARIES ${OGG_LIBRARY} ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARY} ${VORBISENC_LIBRARY}) - - set(_CMAKE_REQUIRED_LIBRARIES_TMP ${CMAKE_REQUIRED_LIBRARIES}) - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${OGGVORBIS_LIBRARIES}) - check_library_exists(vorbis vorbis_bitrate_addblock "" HAVE_LIBVORBISENC2) - set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_TMP}) - - if (HAVE_LIBVORBISENC2) - set (OGGVORBIS_VERSION 2) - else (HAVE_LIBVORBISENC2) - set (OGGVORBIS_VERSION 1) - endif (HAVE_LIBVORBISENC2) - -else (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBISENC_LIBRARY) - set (OGGVORBIS_VERSION) - set(OGGVORBIS_FOUND FALSE) -endif (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBISENC_LIBRARY) - - -if (OGGVORBIS_FOUND) - if (NOT OggVorbis_FIND_QUIETLY) - message(STATUS "Found OggVorbis: ${OGGVORBIS_LIBRARIES}") - endif (NOT OggVorbis_FIND_QUIETLY) -else (OGGVORBIS_FOUND) - if (OggVorbis_FIND_REQUIRED) - message(FATAL_ERROR "Could NOT find OggVorbis libraries") - endif (OggVorbis_FIND_REQUIRED) - if (NOT OggVorbis_FIND_QUITELY) - message(STATUS "Could NOT find OggVorbis libraries") - endif (NOT OggVorbis_FIND_QUITELY) -endif (OGGVORBIS_FOUND) - -#check_include_files(vorbis/vorbisfile.h HAVE_VORBISFILE_H) -#check_library_exists(ogg ogg_page_version "" HAVE_LIBOGG) -#check_library_exists(vorbis vorbis_info_init "" HAVE_LIBVORBIS) -#check_library_exists(vorbisfile ov_open "" HAVE_LIBVORBISFILE) -#check_library_exists(vorbisenc vorbis_info_clear "" HAVE_LIBVORBISENC) -#check_library_exists(vorbis vorbis_bitrate_addblock "" HAVE_LIBVORBISENC2) - -#if (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC) -# message(STATUS "Ogg/Vorbis found") -# set (VORBIS_LIBS "-lvorbis -logg") -# set (VORBISFILE_LIBS "-lvorbisfile") -# set (VORBISENC_LIBS "-lvorbisenc") -# set (OGGVORBIS_FOUND TRUE) -# if (HAVE_LIBVORBISENC2) -# set (HAVE_VORBIS 2) -# else (HAVE_LIBVORBISENC2) -# set (HAVE_VORBIS 1) -# endif (HAVE_LIBVORBISENC2) -#else (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC) -# message(STATUS "Ogg/Vorbis not found") -#endif (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC) - diff --git a/stuff/cmake/modules/FindSDL2.cmake b/stuff/cmake/modules/FindSDL2.cmake index 24ac5cae..464ca2d9 100644 --- a/stuff/cmake/modules/FindSDL2.cmake +++ b/stuff/cmake/modules/FindSDL2.cmake @@ -1,4 +1,4 @@ -# Locate SDL2 library + # This module defines # SDL2_LIBRARY, the name of the library to link against # SDL2_FOUND, if false, do not try to link to SDL2 @@ -65,9 +65,10 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) +# message("") + SET(SDL2_SEARCH_PATHS ~/Library/Frameworks - ~/dev/fakeroot /Library/Frameworks /usr/local /usr @@ -75,15 +76,7 @@ SET(SDL2_SEARCH_PATHS /opt/local # DarwinPorts /opt/csw # Blastwave /opt - - #Windows Search paths - "C:/Program Files (x86)/" - "C:/Program Files/" - "$ENV{ProgramFiles}/" - - "C:/fakeroot/" - "C:/dev/libs" - + ${SDL2_PATH} ) FIND_PATH(SDL2_INCLUDE_DIR SDL.h @@ -93,11 +86,17 @@ FIND_PATH(SDL2_INCLUDE_DIR SDL.h PATHS ${SDL2_SEARCH_PATHS} ) +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(PATH_SUFFIXES lib64 lib/x64 lib) +else() + set(PATH_SUFFIXES lib/x86 lib) +endif() + FIND_LIBRARY(SDL2_LIBRARY_TEMP NAMES SDL2 HINTS $ENV{SDL2DIR} - PATH_SUFFIXES lib64 lib + PATH_SUFFIXES ${PATH_SUFFIXES} PATHS ${SDL2_SEARCH_PATHS} ) @@ -111,7 +110,7 @@ IF(NOT SDL2_BUILDING_LIBRARY) NAMES SDL2main HINTS $ENV{SDL2DIR} - PATH_SUFFIXES lib64 lib + PATH_SUFFIXES ${PATH_SUFFIXES} PATHS ${SDL2_SEARCH_PATHS} ) ENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework") @@ -125,11 +124,10 @@ IF(NOT APPLE) FIND_PACKAGE(Threads) ENDIF(NOT APPLE) -# MinGW needs an additional library, mwindows -# It's total link flags should look like -lmingw32 -lSDL2main -lSDL2 -lmwindows -# (Actually on second look, I think it only needs one of the m* libraries.) +# MinGW needs an additional link flag, -mwindows +# It's total link flags should look like -lmingw32 -lSDL2main -lSDL2 -mwindows IF(MINGW) - SET(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW") + SET(MINGW32_LIBRARY mingw32 "-mwindows" CACHE STRING "mwindows for MinGW") ENDIF(MINGW) IF(SDL2_LIBRARY_TEMP) @@ -168,6 +166,8 @@ IF(SDL2_LIBRARY_TEMP) SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "") ENDIF(SDL2_LIBRARY_TEMP) +# message("") + INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR) From 1aef881f275478f441024c2bf8e87bfe0e343c72 Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Tue, 14 Aug 2018 15:35:51 +0200 Subject: [PATCH 7/7] Update the README to match reality. --- CONTRIBUTE | 4 ++-- README.md | 23 ++++++++--------------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/CONTRIBUTE b/CONTRIBUTE index afe7d959..b4c72b61 100644 --- a/CONTRIBUTE +++ b/CONTRIBUTE @@ -8,7 +8,7 @@ =============================================================================== -At this time there're no open tasks regaring Quake II. Nevertheless the hints +At this time there're no open tasks regaring Quake II. Nevertheless some hints for working with the code: - Sign up for a Github account and fork our yquake2 repository. This allows the @@ -22,7 +22,7 @@ for working with the code: it's still a disaster. Therefore: - Do only one change at a time! - Test after each change (play at least through base1.bsp) - - Commit early and commit often to create a fine grained history. This helps + - Commit early and commit often to create a fine grained history. This helps "git bisect" to find bugs and errors. - Do not try to clean up things or even rewrite code that you do not understand to 110%! Even small behavioral changes can introduce gameplay diff --git a/README.md b/README.md index 3ef7c5d7..4f739c5c 100644 --- a/README.md +++ b/README.md @@ -186,33 +186,26 @@ To compile Yamagi Quake II from source, you need the following dependencies, including development headers: - A GCC-compatible compiler like GCC, MinGW (see below) or Clang. -- GNU make or cmake. +- GNU make. - A libGL implementation with OpenGL system headers. - SDL 2.0. -- libogg, libvorbis and libvorbisfile. - A OpenAL implementation, openal-soft is highly recommended. -- zlib. - -Yamagi Quake II has 2 build systems: - -- A classic GNU Makefile. -- A CMakeFile. - -Both build system provide the same options and features, it's up to the user to -decide which one to use. +While Yamagi Quake II ships with an optional CMakeFile using GNU make for +release builds is highly recommended. The GNU Makefile offers more options +and is well tested. + #### On Linux distribution or BSD systems On debian based distributions (including Ubuntu and Mint) the dependencies can be installed with: `apt-get install build-essential libgl1-mesa-dev libsdl2-dev -libogg-dev libvorbis-dev libopenal-dev zlib1g-dev` +libopenal-dev` On OS X we recommend using Homebrew - https://brew.sh - to install the -dependencies: `brew install sdl2 libvorbis libogg openal-soft` +dependencies: `brew install sdl2 openal-soft` -On FreeBSD you'll need something like: `pkg install gmake libGL sdl2 libogg -libvorbis openal-soft` +On FreeBSD you'll need something like: `pkg install gmake libGL sdl2 openal-soft` #### On Windows