mirror of
https://github.com/blendogames/thirtyflightsofloving.git
synced 2024-11-14 08:31:04 +00:00
Added Ethan Lee's Linux porting changes.
Moved loadingMessage, loadingMessages, and loadingPercent variables in client into client_static_t struct.
This commit is contained in:
parent
3956855f13
commit
4eea7036b8
46 changed files with 6600 additions and 305 deletions
77
Makefile
77
Makefile
|
@ -7,6 +7,7 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Modified by QuDos at http://qudos.quakedev.com
|
# Modified by QuDos at http://qudos.quakedev.com
|
||||||
|
# Modified even more by Ethan Lee at https://www.flibitijibibo.com/
|
||||||
#
|
#
|
||||||
|
|
||||||
# Check OS type.
|
# Check OS type.
|
||||||
|
@ -22,15 +23,16 @@ ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc/ -e s/sparc64/sp
|
||||||
|
|
||||||
BUILD_DATADIR=NO # Use DATADIR to read (data, renderers, etc.) and ~/.quake2 to write.
|
BUILD_DATADIR=NO # Use DATADIR to read (data, renderers, etc.) and ~/.quake2 to write.
|
||||||
BUILD_GAME=YES # game$(ARCH).so
|
BUILD_GAME=YES # game$(ARCH).so
|
||||||
BUILD_KMQUAKE2=YES # kmquake executable (uses OSS for cdrom and sound)
|
BUILD_KMQUAKE2=YES # kmquake client executable
|
||||||
BUILD_KMQUAKE2_DEDICATED=YES # build a dedicated kmquake2 server
|
BUILD_KMQUAKE2_DEDICATED=NO # build a dedicated kmquake2 server (set this to YES when it compiles again)
|
||||||
BUILD_KMQUAKE2_SDL=YES # kmquake2-sdl executable (uses SDL for cdrom and sound)
|
|
||||||
BUILD_LIBDIR=NO # Use LIBDIR to read data and renderers (independent from DATADIR).
|
BUILD_LIBDIR=NO # Use LIBDIR to read data and renderers (independent from DATADIR).
|
||||||
|
|
||||||
######################################
|
######################################
|
||||||
|
|
||||||
######################################
|
######################################
|
||||||
|
|
||||||
|
WINDOWNAME=KMQuake2
|
||||||
|
SAVENAME=quake2
|
||||||
VERSION=0.20
|
VERSION=0.20
|
||||||
MOUNT_DIR=.
|
MOUNT_DIR=.
|
||||||
BUILD_DEBUG_DIR=build_debug
|
BUILD_DEBUG_DIR=build_debug
|
||||||
|
@ -59,7 +61,7 @@ ifeq ($(OSTYPE),FreeBSD)
|
||||||
LDFLAGS=-lm -lz
|
LDFLAGS=-lm -lz
|
||||||
endif
|
endif
|
||||||
ifeq ($(OSTYPE),Linux)
|
ifeq ($(OSTYPE),Linux)
|
||||||
LDFLAGS=-lm -ldl -lz
|
LDFLAGS=-lm -lz -lminizip
|
||||||
endif
|
endif
|
||||||
|
|
||||||
#Ogg Vorbis support
|
#Ogg Vorbis support
|
||||||
|
@ -70,20 +72,14 @@ LDFLAGS += \
|
||||||
|
|
||||||
#LOCALBASE?=/usr
|
#LOCALBASE?=/usr
|
||||||
LOCALBASE?=/usr/local
|
LOCALBASE?=/usr/local
|
||||||
X11BASE?=/usr/X11R6
|
|
||||||
PREFIX?=$(LOCALBASE)
|
PREFIX?=$(LOCALBASE)
|
||||||
|
|
||||||
DATADIR?=$(LOCALBASE)/share/quake2
|
DATADIR?=$(LOCALBASE)/share/quake2
|
||||||
LIBDIR?=$(LOCALBASE)/lib/kmquake2
|
LIBDIR?=$(LOCALBASE)/lib/kmquake2
|
||||||
|
|
||||||
XCFLAGS=-I$(X11BASE)/include
|
SDL_CONFIG?=sdl2-config
|
||||||
GLCFLAGS=-I$(LOCALBASE)/include -I$(X11BASE)/include
|
|
||||||
GLXCFLAGS=-I$(LOCALBASE)/include -I$(X11BASE)/include -DOPENGL
|
|
||||||
GLXLDFLAGS=-L$(LOCALBASE)/lib -L$(X11BASE)/lib -lX11 -lXext -lXxf86dga -lXxf86vm -lGL -lGLU -lpng -ljpeg
|
|
||||||
|
|
||||||
SDL_CONFIG?=sdl-config
|
|
||||||
SDLCFLAGS=$(shell $(SDL_CONFIG) --cflags)
|
SDLCFLAGS=$(shell $(SDL_CONFIG) --cflags)
|
||||||
SDLLDFLAGS=$(shell $(SDL_CONFIG) --libs)
|
SDLLDFLAGS=$(shell $(SDL_CONFIG) --libs) -lpng -ljpeg -lcurl
|
||||||
SDLGLCFLAGS=$(SDLCFLAGS) -DOPENGL
|
SDLGLCFLAGS=$(SDLCFLAGS) -DOPENGL
|
||||||
SDLGLLDFLAGS=$(SDLLDFLAGS)
|
SDLGLLDFLAGS=$(SDLLDFLAGS)
|
||||||
|
|
||||||
|
@ -112,7 +108,7 @@ DO_CC=$(CC) $(CFLAGS) -I$(LOCALBASE)/include -o $@ -c $<
|
||||||
DO_DED_CC=$(CC) $(CFLAGS) -DDEDICATED_ONLY -o $@ -c $<
|
DO_DED_CC=$(CC) $(CFLAGS) -DDEDICATED_ONLY -o $@ -c $<
|
||||||
DO_DED_DEBUG_CC=$(CC) $(DEBUG_CFLAGS) -DDEDICATED_ONLY -o $@ -c $<
|
DO_DED_DEBUG_CC=$(CC) $(DEBUG_CFLAGS) -DDEDICATED_ONLY -o $@ -c $<
|
||||||
DO_SHLIB_CC=$(CC) $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $<
|
DO_SHLIB_CC=$(CC) $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $<
|
||||||
DO_GL_SHLIB_CC=$(CC) $(CFLAGS) $(SHLIBCFLAGS) $(GLCFLAGS) -o $@ -c $<
|
DO_GL_SHLIB_CC=$(CC) $(CFLAGS) $(SHLIBCFLAGS) $(SDLGLCFLAGS) -o $@ -c $<
|
||||||
DO_AS=$(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<
|
DO_AS=$(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<
|
||||||
DO_SHLIB_AS=$(CC) $(CFLAGS) $(SHLIBCFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<
|
DO_SHLIB_AS=$(CC) $(CFLAGS) $(SHLIBCFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<
|
||||||
|
|
||||||
|
@ -132,10 +128,6 @@ ifeq ($(strip $(BUILD_KMQUAKE2_DEDICATED)),YES)
|
||||||
TARGETS += $(BINDIR)/kmquake2_netserver
|
TARGETS += $(BINDIR)/kmquake2_netserver
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(strip $(BUILD_KMQUAKE2_SDL)),YES)
|
|
||||||
TARGETS+=$(BINDIR)/kmquake2-sdl
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(strip $(BUILD_GAME)),YES)
|
ifeq ($(strip $(BUILD_GAME)),YES)
|
||||||
TARGETS+=$(BINDIR)/baseq2/kmq2game$(ARCH).$(SHLIBEXT)
|
TARGETS+=$(BINDIR)/baseq2/kmq2game$(ARCH).$(SHLIBEXT)
|
||||||
endif
|
endif
|
||||||
|
@ -165,7 +157,7 @@ debug:
|
||||||
$(BUILD_DEBUG_DIR)/ref_gl \
|
$(BUILD_DEBUG_DIR)/ref_gl \
|
||||||
$(BUILD_DEBUG_DIR)/game
|
$(BUILD_DEBUG_DIR)/game
|
||||||
|
|
||||||
$(MAKE) targets BUILDDIR=$(BUILD_DEBUG_DIR) CFLAGS+="$(DEBUG_CFLAGS) -DKMQUAKE2_VERSION='\"$(VERSION) Debug\"'"
|
$(MAKE) targets BUILDDIR=$(BUILD_DEBUG_DIR) CFLAGS+="$(DEBUG_CFLAGS) -DKMQUAKE2_VERSION='\"$(VERSION) Debug\"' -DWINDOWNAME='\"$(WINDOWNAME)\"' -DSAVENAME='\"$(SAVENAME)\"'"
|
||||||
release:
|
release:
|
||||||
|
|
||||||
@-mkdir -p $(BUILD_RELEASE_DIR) \
|
@-mkdir -p $(BUILD_RELEASE_DIR) \
|
||||||
|
@ -193,7 +185,7 @@ QUAKE2_OBJS = \
|
||||||
$(BUILDDIR)/client/cl_event.o \
|
$(BUILDDIR)/client/cl_event.o \
|
||||||
$(BUILDDIR)/client/cl_http.o \
|
$(BUILDDIR)/client/cl_http.o \
|
||||||
$(BUILDDIR)/client/cl_input.o \
|
$(BUILDDIR)/client/cl_input.o \
|
||||||
$(BUILDDIR)/client/cl_inv.o \
|
$(BUILDDIR)/client/cl_hud.o \
|
||||||
$(BUILDDIR)/client/cl_keys.o \
|
$(BUILDDIR)/client/cl_keys.o \
|
||||||
$(BUILDDIR)/client/cl_lights.o \
|
$(BUILDDIR)/client/cl_lights.o \
|
||||||
$(BUILDDIR)/client/cl_loc.o \
|
$(BUILDDIR)/client/cl_loc.o \
|
||||||
|
@ -295,32 +287,20 @@ QUAKE2_OBJS = \
|
||||||
$(BUILDDIR)/ref_gl/r_upscale.o \
|
$(BUILDDIR)/ref_gl/r_upscale.o \
|
||||||
$(BUILDDIR)/ref_gl/r_vlights.o \
|
$(BUILDDIR)/ref_gl/r_vlights.o \
|
||||||
$(BUILDDIR)/ref_gl/r_warp.o \
|
$(BUILDDIR)/ref_gl/r_warp.o \
|
||||||
$(BUILDDIR)/ref_gl/gl_glx.o \
|
$(BUILDDIR)/ref_gl/gl_sdl.o \
|
||||||
\
|
\
|
||||||
$(BUILDDIR)/ref_gl/qgl_unix.o
|
$(BUILDDIR)/ref_gl/qgl_unix.o \
|
||||||
|
$(BUILDDIR)/client/cd_unix.o \
|
||||||
|
$(BUILDDIR)/client/snd_sdl.o
|
||||||
|
|
||||||
QUAKE2_AS_OBJS = \
|
QUAKE2_AS_OBJS = \
|
||||||
$(BUILDDIR)/client/snd_mixa.o
|
$(BUILDDIR)/client/snd_mixa.o
|
||||||
|
|
||||||
QUAKE2_LNX_OBJS = \
|
|
||||||
$(BUILDDIR)/client/cd_unix.o \
|
|
||||||
$(BUILDDIR)/client/snd_unix.o
|
|
||||||
|
|
||||||
QUAKE2_SDL_OBJS = \
|
|
||||||
$(BUILDDIR)/client/cd_sdl.o \
|
|
||||||
$(BUILDDIR)/client/snd_sdl.o
|
|
||||||
|
|
||||||
$(BINDIR)/kmquake2 : $(QUAKE2_OBJS) $(QUAKE2_AS_OBJS) $(QUAKE2_LNX_OBJS)
|
$(BINDIR)/kmquake2 : $(QUAKE2_OBJS) $(QUAKE2_AS_OBJS) $(QUAKE2_LNX_OBJS)
|
||||||
@echo
|
@echo
|
||||||
@echo "==================== Linking $@ ===================="
|
@echo "==================== Linking $@ ===================="
|
||||||
@echo
|
@echo
|
||||||
$(CC) $(CFLAGS) -o $@ $(QUAKE2_OBJS) $(QUAKE2_AS_OBJS) $(QUAKE2_LNX_OBJS) $(GLXLDFLAGS) $(LDFLAGS)
|
$(CC) $(CFLAGS) -o $@ $(QUAKE2_OBJS) $(QUAKE2_AS_OBJS) $(SDLLDFLAGS) $(LDFLAGS)
|
||||||
|
|
||||||
$(BINDIR)/kmquake2-sdl : $(QUAKE2_OBJS) $(QUAKE2_AS_OBJS) $(QUAKE2_SDL_OBJS)
|
|
||||||
@echo
|
|
||||||
@echo "==================== Linking $@ ===================="
|
|
||||||
@echo
|
|
||||||
$(CC) $(CFLAGS) -o $@ $(QUAKE2_OBJS) $(QUAKE2_AS_OBJS) $(QUAKE2_SDL_OBJS) $(GLXLDFLAGS) $(LDFLAGS) $(SDLLDFLAGS)
|
|
||||||
|
|
||||||
$(BUILDDIR)/client/cl_cin.o : $(CLIENT_DIR)/cl_cin.c
|
$(BUILDDIR)/client/cl_cin.o : $(CLIENT_DIR)/cl_cin.c
|
||||||
$(DO_CC)
|
$(DO_CC)
|
||||||
|
@ -349,7 +329,7 @@ $(BUILDDIR)/client/cl_http.o : $(CLIENT_DIR)/cl_http.c
|
||||||
$(BUILDDIR)/client/cl_input.o : $(CLIENT_DIR)/cl_input.c
|
$(BUILDDIR)/client/cl_input.o : $(CLIENT_DIR)/cl_input.c
|
||||||
$(DO_CC)
|
$(DO_CC)
|
||||||
|
|
||||||
$(BUILDDIR)/client/cl_inv.o : $(CLIENT_DIR)/cl_inv.c
|
$(BUILDDIR)/client/cl_hud.o : $(CLIENT_DIR)/cl_hud.c
|
||||||
$(DO_CC)
|
$(DO_CC)
|
||||||
|
|
||||||
$(BUILDDIR)/client/cl_keys.o : $(CLIENT_DIR)/cl_keys.c
|
$(BUILDDIR)/client/cl_keys.o : $(CLIENT_DIR)/cl_keys.c
|
||||||
|
@ -557,7 +537,7 @@ $(BUILDDIR)/client/snd_mixa.o : $(UNIX_DIR)/snd_mixa.s
|
||||||
$(DO_AS)
|
$(DO_AS)
|
||||||
|
|
||||||
$(BUILDDIR)/client/sys_unix.o : $(UNIX_DIR)/sys_unix.c
|
$(BUILDDIR)/client/sys_unix.o : $(UNIX_DIR)/sys_unix.c
|
||||||
$(DO_CC)
|
$(DO_CC) $(SDLCFLAGS)
|
||||||
|
|
||||||
$(BUILDDIR)/client/glob.o : $(UNIX_DIR)/glob.c
|
$(BUILDDIR)/client/glob.o : $(UNIX_DIR)/glob.c
|
||||||
$(DO_CC)
|
$(DO_CC)
|
||||||
|
@ -568,9 +548,6 @@ $(BUILDDIR)/client/in_unix.o : $(UNIX_DIR)/in_unix.c
|
||||||
$(BUILDDIR)/client/net_udp.o : $(UNIX_DIR)/net_udp.c
|
$(BUILDDIR)/client/net_udp.o : $(UNIX_DIR)/net_udp.c
|
||||||
$(DO_CC)
|
$(DO_CC)
|
||||||
|
|
||||||
$(BUILDDIR)/client/cd_sdl.o : $(UNIX_DIR)/cd_sdl.c
|
|
||||||
$(DO_CC) $(SDLCFLAGS)
|
|
||||||
|
|
||||||
$(BUILDDIR)/client/snd_sdl.o : $(UNIX_DIR)/snd_sdl.c
|
$(BUILDDIR)/client/snd_sdl.o : $(UNIX_DIR)/snd_sdl.c
|
||||||
$(DO_CC) $(SDLCFLAGS)
|
$(DO_CC) $(SDLCFLAGS)
|
||||||
|
|
||||||
|
@ -652,8 +629,8 @@ $(BUILDDIR)/ref_gl/r_vlights.o : $(REF_GL_DIR)/r_vlights.c
|
||||||
$(BUILDDIR)/ref_gl/r_warp.o : $(REF_GL_DIR)/r_warp.c
|
$(BUILDDIR)/ref_gl/r_warp.o : $(REF_GL_DIR)/r_warp.c
|
||||||
$(DO_GL_SHLIB_CC)
|
$(DO_GL_SHLIB_CC)
|
||||||
|
|
||||||
$(BUILDDIR)/ref_gl/gl_glx.o : $(UNIX_DIR)/gl_glx.c
|
$(BUILDDIR)/ref_gl/gl_sdl.o : $(UNIX_DIR)/gl_sdl.c
|
||||||
$(DO_GL_SHLIB_CC) $(GLXCFLAGS)
|
$(DO_GL_SHLIB_CC) $(SDLCFLAGS)
|
||||||
|
|
||||||
$(BUILDDIR)/ref_gl/qgl_unix.o : $(UNIX_DIR)/qgl_unix.c
|
$(BUILDDIR)/ref_gl/qgl_unix.o : $(UNIX_DIR)/qgl_unix.c
|
||||||
$(DO_GL_SHLIB_CC)
|
$(DO_GL_SHLIB_CC)
|
||||||
|
@ -866,25 +843,25 @@ GAME_OBJS = \
|
||||||
$(BINDIR)/baseq2/kmq2game$(ARCH).$(SHLIBEXT) : $(GAME_OBJS)
|
$(BINDIR)/baseq2/kmq2game$(ARCH).$(SHLIBEXT) : $(GAME_OBJS)
|
||||||
$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(GAME_OBJS) -lGL
|
$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(GAME_OBJS) -lGL
|
||||||
|
|
||||||
$(BUILDDIR)/game/acebot_ai.o : $(GAME_DIR)/acesrc/acebot_ai.c
|
$(BUILDDIR)/game/acebot_ai.o : $(GAME_DIR)/acebot_ai.c
|
||||||
$(DO_SHLIB_CC)
|
$(DO_SHLIB_CC)
|
||||||
|
|
||||||
$(BUILDDIR)/game/acebot_cmds.o : $(GAME_DIR)/acesrc/acebot_cmds.c
|
$(BUILDDIR)/game/acebot_cmds.o : $(GAME_DIR)/acebot_cmds.c
|
||||||
$(DO_SHLIB_CC)
|
$(DO_SHLIB_CC)
|
||||||
|
|
||||||
$(BUILDDIR)/game/acebot_compress.o : $(GAME_DIR)/acesrc/acebot_compress.c
|
$(BUILDDIR)/game/acebot_compress.o : $(GAME_DIR)/acebot_compress.c
|
||||||
$(DO_SHLIB_CC)
|
$(DO_SHLIB_CC)
|
||||||
|
|
||||||
$(BUILDDIR)/game/acebot_items.o : $(GAME_DIR)/acesrc/acebot_items.c
|
$(BUILDDIR)/game/acebot_items.o : $(GAME_DIR)/acebot_items.c
|
||||||
$(DO_SHLIB_CC)
|
$(DO_SHLIB_CC)
|
||||||
|
|
||||||
$(BUILDDIR)/game/acebot_movement.o : $(GAME_DIR)/acesrc/acebot_movement.c
|
$(BUILDDIR)/game/acebot_movement.o : $(GAME_DIR)/acebot_movement.c
|
||||||
$(DO_SHLIB_CC)
|
$(DO_SHLIB_CC)
|
||||||
|
|
||||||
$(BUILDDIR)/game/acebot_nodes.o : $(GAME_DIR)/acesrc/acebot_nodes.c
|
$(BUILDDIR)/game/acebot_nodes.o : $(GAME_DIR)/acebot_nodes.c
|
||||||
$(DO_SHLIB_CC)
|
$(DO_SHLIB_CC)
|
||||||
|
|
||||||
$(BUILDDIR)/game/acebot_spawn.o : $(GAME_DIR)/acesrc/acebot_spawn.c
|
$(BUILDDIR)/game/acebot_spawn.o : $(GAME_DIR)/acebot_spawn.c
|
||||||
$(DO_SHLIB_CC)
|
$(DO_SHLIB_CC)
|
||||||
|
|
||||||
$(BUILDDIR)/game/g_ai.o : $(GAME_DIR)/g_ai.c
|
$(BUILDDIR)/game/g_ai.o : $(GAME_DIR)/g_ai.c
|
||||||
|
|
|
@ -854,7 +854,7 @@ CL_DownloadFileName
|
||||||
*/
|
*/
|
||||||
void CL_DownloadFileName (char *dest, int destlen, const char *fn)
|
void CL_DownloadFileName (char *dest, int destlen, const char *fn)
|
||||||
{
|
{
|
||||||
if ( !stricmp(FS_Downloaddir(), FS_Gamedir()) ) // use basedir/gamedir if fs_downloaddir is the same as fs_gamedir
|
if ( !Q_stricmp(FS_Downloaddir(), FS_Gamedir()) ) // use basedir/gamedir if fs_downloaddir is the same as fs_gamedir
|
||||||
{
|
{
|
||||||
if (strncmp(fn, "players", 7) == 0)
|
if (strncmp(fn, "players", 7) == 0)
|
||||||
Com_sprintf (dest, destlen, "%s/%s", BASEDIRNAME, fn);
|
Com_sprintf (dest, destlen, "%s/%s", BASEDIRNAME, fn);
|
||||||
|
|
|
@ -1331,7 +1331,7 @@ void CL_AddPacketEntities (frame_t *frame)
|
||||||
drawEnt = false;
|
drawEnt = false;
|
||||||
}
|
}
|
||||||
if (!Q_strcasecmp((char *)ent.model, "models/objects/blaser/tris.md2")
|
if (!Q_strcasecmp((char *)ent.model, "models/objects/blaser/tris.md2")
|
||||||
|| ( !Q_strcasecmp((char *)ent.model, "models/objects/laser/tris.md2") && (ent.skinnum == 2) ) // skinnum 1 is blue blaster bolt
|
|| ( !Q_strcasecmp((char *)ent.model, "models/objects/laser/tris.md2") && (ent.skinnum == 2) ) // skinnum 2 is blue blaster bolt
|
||||||
&& !(effects & EF_BLASTER) && cl_add_particles->integer)
|
&& !(effects & EF_BLASTER) && cl_add_particles->integer)
|
||||||
{ // give the bolt a blue particle glow
|
{ // give the bolt a blue particle glow
|
||||||
CL_HyperBlasterEffect (cent->lerp_origin, ent.origin, s1->angles,
|
CL_HyperBlasterEffect (cent->lerp_origin, ent.origin, s1->angles,
|
||||||
|
@ -1339,7 +1339,7 @@ void CL_AddPacketEntities (frame_t *frame)
|
||||||
drawEnt = false;
|
drawEnt = false;
|
||||||
}
|
}
|
||||||
if (!Q_strcasecmp((char *)ent.model, "models/objects/rlaser/tris.md2")
|
if (!Q_strcasecmp((char *)ent.model, "models/objects/rlaser/tris.md2")
|
||||||
|| ( !Q_strcasecmp((char *)ent.model, "models/objects/laser/tris.md2") && (ent.skinnum == 3) ) // skinnum 1 is red blaster bolt
|
|| ( !Q_strcasecmp((char *)ent.model, "models/objects/laser/tris.md2") && (ent.skinnum == 3) ) // skinnum 3 is red blaster bolt
|
||||||
&& !(effects & EF_BLASTER) && cl_add_particles->integer)
|
&& !(effects & EF_BLASTER) && cl_add_particles->integer)
|
||||||
{ // give the bolt a red particle glow
|
{ // give the bolt a red particle glow
|
||||||
CL_HyperBlasterEffect (cent->lerp_origin, ent.origin, s1->angles,
|
CL_HyperBlasterEffect (cent->lerp_origin, ent.origin, s1->angles,
|
||||||
|
|
|
@ -852,7 +852,7 @@ static void CL_CheckAndQueueDownload (char *path)
|
||||||
f = fopen (gamePath, "rb");
|
f = fopen (gamePath, "rb");
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
if ( !stricmp(FS_Downloaddir(), FS_Gamedir()) ) // if fs_gamedir and fs_downloaddir are the same, don't bother trying fs_gamedir
|
if ( !Q_stricmp(FS_Downloaddir(), FS_Gamedir()) ) // if fs_gamedir and fs_downloaddir are the same, don't bother trying fs_gamedir
|
||||||
{
|
{
|
||||||
exists = false;
|
exists = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1970,7 +1970,7 @@ void SCR_DrawLoading (void)
|
||||||
qboolean simplePlaque = (scr_simple_loadscreen->integer != 0);
|
qboolean simplePlaque = (scr_simple_loadscreen->integer != 0);
|
||||||
|
|
||||||
if (!scr_draw_loading) {
|
if (!scr_draw_loading) {
|
||||||
loadingPercent = 0;
|
cls.loadingPercent = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1978,7 +1978,7 @@ void SCR_DrawLoading (void)
|
||||||
widescreen = (((float)viddef.width / (float)viddef.height) > STANDARD_ASPECT_RATIO);
|
widescreen = (((float)viddef.width / (float)viddef.height) > STANDARD_ASPECT_RATIO);
|
||||||
|
|
||||||
// loading a map...
|
// loading a map...
|
||||||
if (loadingMessage && cl.configstrings[CS_MODELS+1][0])
|
if (cls.loadingMessage && cl.configstrings[CS_MODELS+1][0])
|
||||||
{
|
{
|
||||||
// strncpy (mapfile, cl.configstrings[CS_MODELS+1] + 5); // skip "maps/"
|
// strncpy (mapfile, cl.configstrings[CS_MODELS+1] + 5); // skip "maps/"
|
||||||
Q_strncpyz (mapfile, sizeof(mapfile), cl.configstrings[CS_MODELS+1] + 5); // skip "maps/"
|
Q_strncpyz (mapfile, sizeof(mapfile), cl.configstrings[CS_MODELS+1] + 5); // skip "maps/"
|
||||||
|
@ -2091,21 +2091,21 @@ void SCR_DrawLoading (void)
|
||||||
SCREEN_HEIGHT*0.5 + (plaqueOffset + 48), MENU_FONT_SIZE, ALIGN_CENTER, loadMsg, FONT_SCREEN, 255); // was - MENU_FONT_SIZE*7.5
|
SCREEN_HEIGHT*0.5 + (plaqueOffset + 48), MENU_FONT_SIZE, ALIGN_CENTER, loadMsg, FONT_SCREEN, 255); // was - MENU_FONT_SIZE*7.5
|
||||||
}
|
}
|
||||||
if (drawLoadingMsg) {
|
if (drawLoadingMsg) {
|
||||||
loadMsg = va(S_COLOR_SHADOW"%s", loadingMessages);
|
loadMsg = va(S_COLOR_SHADOW"%s", cls.loadingMessages);
|
||||||
SCR_DrawString (SCREEN_WIDTH*0.5 - MENU_FONT_SIZE*stringLen(loadMsg)*0.5,
|
SCR_DrawString (SCREEN_WIDTH*0.5 - MENU_FONT_SIZE*stringLen(loadMsg)*0.5,
|
||||||
SCREEN_HEIGHT*0.5 + (plaqueOffset + 72), MENU_FONT_SIZE, ALIGN_CENTER, loadMsg, FONT_SCREEN, 255); // was - MENU_FONT_SIZE*4.5
|
SCREEN_HEIGHT*0.5 + (plaqueOffset + 72), MENU_FONT_SIZE, ALIGN_CENTER, loadMsg, FONT_SCREEN, 255); // was - MENU_FONT_SIZE*4.5
|
||||||
}
|
}
|
||||||
|
|
||||||
if (simplePlaque)
|
if (simplePlaque)
|
||||||
SCR_DrawLoadingTagProgress ("loading_bar", plaqueOffset, (int)loadingPercent);
|
SCR_DrawLoadingTagProgress ("loading_bar", plaqueOffset, (int)cls.loadingPercent);
|
||||||
else {
|
else {
|
||||||
SCR_DrawLoadingBar (SCREEN_WIDTH*0.5 - 180, SCREEN_HEIGHT - 20, 360, 15, (int)loadingPercent, 0.6);
|
SCR_DrawLoadingBar (SCREEN_WIDTH*0.5 - 180, SCREEN_HEIGHT - 20, 360, 15, (int)cls.loadingPercent, 0.6);
|
||||||
SCR_DrawAlertMessagePicture("loading", false, plaqueOffset);
|
SCR_DrawAlertMessagePicture("loading", false, plaqueOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {// just a plain old loading plaque
|
else {// just a plain old loading plaque
|
||||||
if (simplePlaque)
|
if (simplePlaque)
|
||||||
SCR_DrawLoadingTagProgress ("loading_bar", 0, (int)loadingPercent);
|
SCR_DrawLoadingTagProgress ("loading_bar", 0, (int)cls.loadingPercent);
|
||||||
else
|
else
|
||||||
SCR_DrawAlertMessagePicture("loading", true, 0);
|
SCR_DrawAlertMessagePicture("loading", true, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,8 +40,9 @@ cvar_t *cl_testblend;
|
||||||
|
|
||||||
cvar_t *cl_stats;
|
cvar_t *cl_stats;
|
||||||
|
|
||||||
cvar_t *hand;
|
extern cvar_t *hand;
|
||||||
|
|
||||||
|
vec3_t clientOrg; // lerped org of client for server->client side effects
|
||||||
|
|
||||||
int r_numdlights;
|
int r_numdlights;
|
||||||
dlight_t r_dlights[MAX_DLIGHTS];
|
dlight_t r_dlights[MAX_DLIGHTS];
|
||||||
|
@ -414,9 +415,9 @@ void CL_PrepRefresh (void)
|
||||||
SCR_BeginLoadingPlaque();
|
SCR_BeginLoadingPlaque();
|
||||||
|
|
||||||
// Knightmare- for Psychospaz's map loading screen
|
// Knightmare- for Psychospaz's map loading screen
|
||||||
loadingMessage = true;
|
cls.loadingMessage = true;
|
||||||
Com_sprintf (loadingMessages, sizeof(loadingMessages), S_COLOR_ALT"loading %s", cl.configstrings[CS_MODELS+1]);
|
Com_sprintf (cls.loadingMessages, sizeof(cls.loadingMessages), S_COLOR_ALT"loading %s", cl.configstrings[CS_MODELS+1]);
|
||||||
loadingPercent = 0.0f;
|
cls.loadingPercent = 0.0f;
|
||||||
// end Knightmare
|
// end Knightmare
|
||||||
|
|
||||||
// let the render dll load the map
|
// let the render dll load the map
|
||||||
|
@ -431,8 +432,8 @@ void CL_PrepRefresh (void)
|
||||||
Com_Printf (" \r");
|
Com_Printf (" \r");
|
||||||
|
|
||||||
// Knightmare- for Psychospaz's map loading screen
|
// Knightmare- for Psychospaz's map loading screen
|
||||||
Com_sprintf (loadingMessages, sizeof(loadingMessages), S_COLOR_ALT"loading models...");
|
Com_sprintf (cls.loadingMessages, sizeof(cls.loadingMessages), S_COLOR_ALT"loading models...");
|
||||||
loadingPercent += 20.0f;
|
cls.loadingPercent += 20.0f;
|
||||||
// end Knightmare
|
// end Knightmare
|
||||||
|
|
||||||
// precache status bar pics
|
// precache status bar pics
|
||||||
|
@ -462,7 +463,7 @@ void CL_PrepRefresh (void)
|
||||||
// Knightmare- for Psychospaz's map loading screen
|
// Knightmare- for Psychospaz's map loading screen
|
||||||
//only make max of 40 chars long
|
//only make max of 40 chars long
|
||||||
if (i > 1)
|
if (i > 1)
|
||||||
Com_sprintf (loadingMessages, sizeof(loadingMessages),
|
Com_sprintf (cls.loadingMessages, sizeof(cls.loadingMessages),
|
||||||
S_COLOR_ALT"loading %s", (strlen(pname)>40)? &pname[strlen(pname)-40]: pname);
|
S_COLOR_ALT"loading %s", (strlen(pname)>40)? &pname[strlen(pname)-40]: pname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,10 +490,10 @@ void CL_PrepRefresh (void)
|
||||||
if (pname[0] != '*')
|
if (pname[0] != '*')
|
||||||
Com_Printf (" \r");
|
Com_Printf (" \r");
|
||||||
// Knightmare- for Psychospaz's map loading screen
|
// Knightmare- for Psychospaz's map loading screen
|
||||||
loadingPercent += 40.0f/(float)max;
|
cls.loadingPercent += 40.0f/(float)max;
|
||||||
}
|
}
|
||||||
// Knightmare- for Psychospaz's map loading screen
|
// Knightmare- for Psychospaz's map loading screen
|
||||||
Com_sprintf (loadingMessages, sizeof(loadingMessages), S_COLOR_ALT"loading pics...");
|
Com_sprintf (cls.loadingMessages, sizeof(cls.loadingMessages), S_COLOR_ALT"loading pics...");
|
||||||
|
|
||||||
Com_Printf ("images\r", i);
|
Com_Printf ("images\r", i);
|
||||||
SCR_UpdateScreen ();
|
SCR_UpdateScreen ();
|
||||||
|
@ -508,7 +509,7 @@ void CL_PrepRefresh (void)
|
||||||
cl.image_precache[i] = R_DrawFindPic (cl.configstrings[OLD_CS_IMAGES+i]);
|
cl.image_precache[i] = R_DrawFindPic (cl.configstrings[OLD_CS_IMAGES+i]);
|
||||||
Sys_SendKeyEvents (); // pump message loop
|
Sys_SendKeyEvents (); // pump message loop
|
||||||
// Knightmare- for Psychospaz's map loading screen
|
// Knightmare- for Psychospaz's map loading screen
|
||||||
loadingPercent += 20.0f/(float)max;
|
cls.loadingPercent += 20.0f/(float)max;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -520,11 +521,11 @@ void CL_PrepRefresh (void)
|
||||||
cl.image_precache[i] = R_DrawFindPic (cl.configstrings[CS_IMAGES+i]);
|
cl.image_precache[i] = R_DrawFindPic (cl.configstrings[CS_IMAGES+i]);
|
||||||
Sys_SendKeyEvents (); // pump message loop
|
Sys_SendKeyEvents (); // pump message loop
|
||||||
// Knightmare- for Psychospaz's map loading screen
|
// Knightmare- for Psychospaz's map loading screen
|
||||||
loadingPercent += 20.0f/(float)max;
|
cls.loadingPercent += 20.0f/(float)max;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Knightmare- for Psychospaz's map loading screen
|
// Knightmare- for Psychospaz's map loading screen
|
||||||
Com_sprintf (loadingMessages, sizeof(loadingMessages), S_COLOR_ALT"loading players...");
|
Com_sprintf (cls.loadingMessages, sizeof(cls.loadingMessages), S_COLOR_ALT"loading players...");
|
||||||
|
|
||||||
Com_Printf (" \r");
|
Com_Printf (" \r");
|
||||||
|
|
||||||
|
@ -556,12 +557,12 @@ void CL_PrepRefresh (void)
|
||||||
Com_Printf (" \r");
|
Com_Printf (" \r");
|
||||||
|
|
||||||
// Knightmare- for Psychospaz's map loading screen
|
// Knightmare- for Psychospaz's map loading screen
|
||||||
loadingPercent += 20.0f/(float)max;
|
cls.loadingPercent += 20.0f/(float)max;
|
||||||
}
|
}
|
||||||
// Knightmare- for Psychospaz's map loading screen
|
// Knightmare- for Psychospaz's map loading screen
|
||||||
Com_sprintf (loadingMessages, sizeof(loadingMessages), S_COLOR_ALT"loading players...done");
|
Com_sprintf (cls.loadingMessages, sizeof(cls.loadingMessages), S_COLOR_ALT"loading players...done");
|
||||||
//hack hack hack - psychospaz
|
//hack hack hack - psychospaz
|
||||||
loadingPercent = 100.0f;
|
cls.loadingPercent = 100.0f;
|
||||||
|
|
||||||
// Knightmare - Vics fix to get rid of male/grunt flicker
|
// Knightmare - Vics fix to get rid of male/grunt flicker
|
||||||
// CL_LoadClientinfo (&cl.baseclientinfo, "unnamed\\male/grunt");
|
// CL_LoadClientinfo (&cl.baseclientinfo, "unnamed\\male/grunt");
|
||||||
|
@ -604,7 +605,7 @@ void CL_PrepRefresh (void)
|
||||||
CL_PlayBackgroundTrack ();
|
CL_PlayBackgroundTrack ();
|
||||||
|
|
||||||
// Knightmare- for Psychospaz's map loading screen
|
// Knightmare- for Psychospaz's map loading screen
|
||||||
loadingMessage = false;
|
cls.loadingMessage = false;
|
||||||
// Knightmare- close loading screen as soon as done
|
// Knightmare- close loading screen as soon as done
|
||||||
cls.disable_screen = false;
|
cls.disable_screen = false;
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ trace_t SV_Trace (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, edict_t *p
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
// added for Psychospaz's chasecam
|
// added for Psychospaz's chasecam
|
||||||
vec3_t clientOrg; //lerped org of client for server->client side effects
|
extern vec3_t clientOrg; //lerped org of client for server->client side effects
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -333,6 +333,10 @@ typedef struct
|
||||||
int disable_servercount; // when we receive a frame and cl.servercount
|
int disable_servercount; // when we receive a frame and cl.servercount
|
||||||
// > cls.disable_servercount, clear disable_screen
|
// > cls.disable_servercount, clear disable_screen
|
||||||
|
|
||||||
|
qboolean loadingMessage; // whether load message should appear
|
||||||
|
char loadingMessages[96];
|
||||||
|
float loadingPercent;
|
||||||
|
|
||||||
// connection information
|
// connection information
|
||||||
char servername[MAX_OSPATH]; // name of server from original connect
|
char servername[MAX_OSPATH]; // name of server from original connect
|
||||||
float connect_time; // for connection retransmits
|
float connect_time; // for connection retransmits
|
||||||
|
@ -908,13 +912,6 @@ extern struct model_s *gun_model;
|
||||||
|
|
||||||
extern foginfo_t r_foginfo; // Knightmare added
|
extern foginfo_t r_foginfo; // Knightmare added
|
||||||
|
|
||||||
|
|
||||||
qboolean loadingMessage;
|
|
||||||
|
|
||||||
char loadingMessages[96];
|
|
||||||
|
|
||||||
float loadingPercent;
|
|
||||||
|
|
||||||
float CalcFov (float fov_x, float width, float height);
|
float CalcFov (float fov_x, float width, float height);
|
||||||
void V_RenderView( float stereo_separation );
|
void V_RenderView( float stereo_separation );
|
||||||
void V_ClipCam (vec3_t start, vec3_t end, vec3_t newpos);
|
void V_ClipCam (vec3_t start, vec3_t end, vec3_t newpos);
|
||||||
|
|
|
@ -2058,7 +2058,7 @@ struct edict_s
|
||||||
#define FLASHLIGHT_ITEM "Cells"
|
#define FLASHLIGHT_ITEM "Cells"
|
||||||
|
|
||||||
// Knightmare- simulated pause for deathmatch
|
// Knightmare- simulated pause for deathmatch
|
||||||
qboolean paused;
|
extern qboolean paused;
|
||||||
|
|
||||||
|
|
||||||
//ZOID
|
//ZOID
|
||||||
|
|
|
@ -138,6 +138,9 @@ cvar_t *sv_step_fraction; // Knightmare- this was a define in p_view.c
|
||||||
|
|
||||||
cvar_t *g_showlogic; // Knightmare added
|
cvar_t *g_showlogic; // Knightmare added
|
||||||
|
|
||||||
|
// Knightmare- simulated pause for deathmatch
|
||||||
|
qboolean paused;
|
||||||
|
|
||||||
void SpawnEntities (char *mapname, char *entities, char *spawnpoint);
|
void SpawnEntities (char *mapname, char *entities, char *spawnpoint);
|
||||||
void ClientThink (edict_t *ent, usercmd_t *cmd);
|
void ClientThink (edict_t *ent, usercmd_t *cmd);
|
||||||
qboolean ClientConnect (edict_t *ent, char *userinfo);
|
qboolean ClientConnect (edict_t *ent, char *userinfo);
|
||||||
|
|
|
@ -315,7 +315,8 @@ __declspec( naked ) int Q_ftol( float f )
|
||||||
__asm ret
|
__asm ret
|
||||||
}
|
}
|
||||||
#pragma warning (default:4035)
|
#pragma warning (default:4035)
|
||||||
#else
|
//#else
|
||||||
|
#elif !defined(Q_ftol)
|
||||||
int Q_ftol( float f )
|
int Q_ftol( float f )
|
||||||
{
|
{
|
||||||
return (int)f;
|
return (int)f;
|
||||||
|
|
|
@ -83,9 +83,9 @@ typedef enum {false, true} qboolean;
|
||||||
typedef int64_t qint64;
|
typedef int64_t qint64;
|
||||||
typedef unsigned int64_t uint64;
|
typedef unsigned int64_t uint64;
|
||||||
#elif defined(__linux__) // Linux
|
#elif defined(__linux__) // Linux
|
||||||
# include <_G_config.h>
|
# include <stdint.h>
|
||||||
typedef _G_int64_t qint64;
|
typedef int64_t qint64;
|
||||||
typedef unsigned _G_int64_t uint64;
|
typedef uint64_t uint64;
|
||||||
#elif defined(__BEOS__) // Be
|
#elif defined(__BEOS__) // Be
|
||||||
# include <inttypes.h>
|
# include <inttypes.h>
|
||||||
typedef int64_t qint64;
|
typedef int64_t qint64;
|
||||||
|
|
|
@ -25,6 +25,7 @@ Other code by:
|
||||||
Dopefish
|
Dopefish
|
||||||
Dukey
|
Dukey
|
||||||
Echon
|
Echon
|
||||||
|
Ethan Lee
|
||||||
Frank Sapone
|
Frank Sapone
|
||||||
Fuh
|
Fuh
|
||||||
Harven
|
Harven
|
||||||
|
|
|
@ -866,13 +866,13 @@ char *Cmd_CompleteCommand (char *partial)
|
||||||
|
|
||||||
// check for exact match
|
// check for exact match
|
||||||
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
|
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
|
||||||
if (!_stricmp (partial,cmd->name))
|
if (!Q_stricmp (partial,cmd->name))
|
||||||
return cmd->name;
|
return cmd->name;
|
||||||
for (a=cmd_alias ; a ; a=a->next)
|
for (a=cmd_alias ; a ; a=a->next)
|
||||||
if (!_stricmp (partial, a->name))
|
if (!Q_stricmp (partial, a->name))
|
||||||
return a->name;
|
return a->name;
|
||||||
for (cvar=cvar_vars ; cvar ; cvar=cvar->next)
|
for (cvar=cvar_vars ; cvar ; cvar=cvar->next)
|
||||||
if (!_stricmp (partial,cvar->name))
|
if (!Q_stricmp (partial,cvar->name))
|
||||||
return cvar->name;
|
return cvar->name;
|
||||||
|
|
||||||
for (i=0; i<1024; i++)
|
for (i=0; i<1024; i++)
|
||||||
|
@ -936,13 +936,13 @@ qboolean Cmd_IsComplete (char *command)
|
||||||
|
|
||||||
// check for exact match
|
// check for exact match
|
||||||
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
|
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
|
||||||
if (!_stricmp (command,cmd->name))
|
if (!Q_stricmp (command,cmd->name))
|
||||||
return true;
|
return true;
|
||||||
for (a=cmd_alias ; a ; a=a->next)
|
for (a=cmd_alias ; a ; a=a->next)
|
||||||
if (!_stricmp (command, a->name))
|
if (!Q_stricmp (command, a->name))
|
||||||
return true;
|
return true;
|
||||||
for (cvar=cvar_vars ; cvar ; cvar=cvar->next)
|
for (cvar=cvar_vars ; cvar ; cvar=cvar->next)
|
||||||
if (!_stricmp (command,cvar->name))
|
if (!Q_stricmp (command,cvar->name))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -113,6 +113,7 @@ char *Cvar_VariableString (char *var_name)
|
||||||
/*
|
/*
|
||||||
============
|
============
|
||||||
Cvar_DefaultValue
|
Cvar_DefaultValue
|
||||||
|
|
||||||
Knightmare added
|
Knightmare added
|
||||||
============
|
============
|
||||||
*/
|
*/
|
||||||
|
@ -130,6 +131,7 @@ float Cvar_DefaultValue (char *var_name)
|
||||||
/*
|
/*
|
||||||
============
|
============
|
||||||
Cvar_DefaultInteger
|
Cvar_DefaultInteger
|
||||||
|
|
||||||
Knightmare added
|
Knightmare added
|
||||||
============
|
============
|
||||||
*/
|
*/
|
||||||
|
@ -147,6 +149,7 @@ int Cvar_DefaultInteger (char *var_name)
|
||||||
/*
|
/*
|
||||||
============
|
============
|
||||||
Cvar_DefaultString
|
Cvar_DefaultString
|
||||||
|
|
||||||
Knightmare added
|
Knightmare added
|
||||||
============
|
============
|
||||||
*/
|
*/
|
||||||
|
@ -164,6 +167,7 @@ char *Cvar_DefaultString (char *var_name)
|
||||||
/*
|
/*
|
||||||
============
|
============
|
||||||
Cvar_IsModified
|
Cvar_IsModified
|
||||||
|
|
||||||
Knightmare added
|
Knightmare added
|
||||||
============
|
============
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -2495,9 +2495,9 @@ void FS_CopyConfigsToSavegameDir (void)
|
||||||
// Don't copy default.cfg, autoexec.cfg, or configs written by other engines
|
// Don't copy default.cfg, autoexec.cfg, or configs written by other engines
|
||||||
// TODO: keep this up to date!
|
// TODO: keep this up to date!
|
||||||
// config.cfg, aprconfig.cfg, bqconfig.cfg, eglcfg.cfg, maxconfig.cfg, q2config.cfg, q2b_config.cfg, q2econfig.cfg, xpconfig.cfg, yq2.cfg
|
// config.cfg, aprconfig.cfg, bqconfig.cfg, eglcfg.cfg, maxconfig.cfg, q2config.cfg, q2b_config.cfg, q2econfig.cfg, xpconfig.cfg, yq2.cfg
|
||||||
if ( (strstr(cfgName, "config.cfg") && (stricmp(cfgName, "kmq2config.cfg") != 0)) ||
|
if ( (strstr(cfgName, "config.cfg") && (Q_stricmp(cfgName, "kmq2config.cfg") != 0)) ||
|
||||||
!stricmp(cfgName, "default.cfg") || !stricmp(cfgName, "autoexec.cfg") ||
|
!Q_stricmp(cfgName, "default.cfg") || !Q_stricmp(cfgName, "autoexec.cfg") ||
|
||||||
!stricmp(cfgName, "eglcfg.cfg") || !stricmp(cfgName, "yq2.cfg") ) {
|
!Q_stricmp(cfgName, "eglcfg.cfg") || !Q_stricmp(cfgName, "yq2.cfg") ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Com_sprintf (dstCfgPath, sizeof(dstCfgPath), "%s/%s", FS_SaveGameDir(), cfgName);
|
Com_sprintf (dstCfgPath, sizeof(dstCfgPath), "%s/%s", FS_SaveGameDir(), cfgName);
|
||||||
|
|
|
@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
#if defined (_MSC_VER) && (_MSC_VER <= 1200) // use older version of zlib for MSVC6
|
#if defined (_MSC_VER) && (_MSC_VER <= 1200) // use older version of zlib for MSVC6
|
||||||
#include "../include/zlibpng_vc6/unzip.h"
|
#include "../include/zlibpng_vc6/unzip.h"
|
||||||
#include "../include/zlibpng_vc6/zip.h"
|
#include "../include/zlibpng_vc6/zip.h"
|
||||||
|
@ -27,6 +28,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
#include "../include/zlibpng/unzip.h"
|
#include "../include/zlibpng/unzip.h"
|
||||||
#include "../include/zlibpng/zip.h"
|
#include "../include/zlibpng/zip.h"
|
||||||
#endif
|
#endif
|
||||||
|
#else // _WIN32
|
||||||
|
#include <minizip/unzip.h>
|
||||||
|
#include <minizip/zip.h>
|
||||||
|
#endif // _WIN32
|
||||||
|
|
||||||
#define BASEDIRNAME "baseq2"
|
#define BASEDIRNAME "baseq2"
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** qgl.h
|
** QGL.H
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __QGL_H__
|
#ifndef __QGL_H__
|
||||||
|
@ -31,12 +31,17 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__APPLE__) || (MACOSX)
|
||||||
|
# include <OpenGL/gl.h>
|
||||||
|
# include <OpenGL/glext.h>
|
||||||
|
#else
|
||||||
# include <GL/gl.h>
|
# include <GL/gl.h>
|
||||||
|
#endif /* __APPLE__ || MACOSX */
|
||||||
|
|
||||||
#ifdef __linux__
|
/*#ifdef __linux__
|
||||||
//#include <GL/fxmesa.h>
|
//#include <GL/fxmesa.h>
|
||||||
#include <GL/glx.h>
|
#include <GL/glx.h>
|
||||||
#endif
|
#endif */
|
||||||
|
|
||||||
qboolean QGL_Init( const char *dllname );
|
qboolean QGL_Init( const char *dllname );
|
||||||
void QGL_Shutdown( void );
|
void QGL_Shutdown( void );
|
||||||
|
@ -384,10 +389,10 @@ extern void ( APIENTRY * qglViewport )(GLint x, GLint y, GLsizei width, GLsizei
|
||||||
|
|
||||||
//extern void ( APIENTRY * qglPointParameterfEXT)( GLenum param, GLfloat value );
|
//extern void ( APIENTRY * qglPointParameterfEXT)( GLenum param, GLfloat value );
|
||||||
//extern void ( APIENTRY * qglPointParameterfvEXT)( GLenum param, const GLfloat *value );
|
//extern void ( APIENTRY * qglPointParameterfvEXT)( GLenum param, const GLfloat *value );
|
||||||
extern void ( APIENTRY * qglColorTableEXT)( int, int, int, int, int, const void * );
|
//extern void ( APIENTRY * qglColorTableEXT)( GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid * );
|
||||||
|
|
||||||
// Knightmare added
|
// Knightmare added
|
||||||
extern void ( APIENTRY * qglDrawRangeElementsEXT)( GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices );
|
extern void ( APIENTRY * qglDrawRangeElements)( GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices );
|
||||||
|
|
||||||
extern void ( APIENTRY * qglLockArraysEXT) (GLint start, GLsizei count);
|
extern void ( APIENTRY * qglLockArraysEXT) (GLint start, GLsizei count);
|
||||||
extern void ( APIENTRY * qglUnlockArraysEXT) (void);
|
extern void ( APIENTRY * qglUnlockArraysEXT) (void);
|
||||||
|
@ -493,7 +498,6 @@ extern void (*qfxMesaDestroyContext)(fxMesaContext ctx);
|
||||||
extern void (*qfxMesaMakeCurrent)(fxMesaContext ctx);
|
extern void (*qfxMesaMakeCurrent)(fxMesaContext ctx);
|
||||||
extern fxMesaContext (*qfxMesaGetCurrentContext)(void);
|
extern fxMesaContext (*qfxMesaGetCurrentContext)(void);
|
||||||
extern void (*qfxMesaSwapBuffers)(void);
|
extern void (*qfxMesaSwapBuffers)(void);
|
||||||
*/
|
|
||||||
|
|
||||||
// GLX Functions
|
// GLX Functions
|
||||||
extern XVisualInfo * (*qglXChooseVisual)( Display *dpy, int screen, int *attribList );
|
extern XVisualInfo * (*qglXChooseVisual)( Display *dpy, int screen, int *attribList );
|
||||||
|
@ -502,6 +506,7 @@ extern void (*qglXDestroyContext)( Display *dpy, GLXContext ctx );
|
||||||
extern Bool (*qglXMakeCurrent)( Display *dpy, GLXDrawable drawable, GLXContext ctx);
|
extern Bool (*qglXMakeCurrent)( Display *dpy, GLXDrawable drawable, GLXContext ctx);
|
||||||
extern void (*qglXCopyContext)( Display *dpy, GLXContext src, GLXContext dst, GLuint mask );
|
extern void (*qglXCopyContext)( Display *dpy, GLXContext src, GLXContext dst, GLuint mask );
|
||||||
extern void (*qglXSwapBuffers)( Display *dpy, GLXDrawable drawable );
|
extern void (*qglXSwapBuffers)( Display *dpy, GLXDrawable drawable );
|
||||||
|
*/
|
||||||
|
|
||||||
// 3dfxSetPaletteEXT shunt
|
// 3dfxSetPaletteEXT shunt
|
||||||
void Fake_glColorTableEXT( GLenum target, GLenum internalformat,
|
void Fake_glColorTableEXT( GLenum target, GLenum internalformat,
|
||||||
|
|
|
@ -591,11 +591,11 @@ based on code from BeefQuake R6
|
||||||
void R_BuildShadowVolume (maliasmodel_t *hdr, int meshnum, vec3_t light, float projectdistance, qboolean nocap)
|
void R_BuildShadowVolume (maliasmodel_t *hdr, int meshnum, vec3_t light, float projectdistance, qboolean nocap)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
BOOL triangleFacingLight[MD3_MAX_TRIANGLES];
|
|
||||||
vec3_t v0, v1, v2, v3;
|
vec3_t v0, v1, v2, v3;
|
||||||
float thisAlpha;
|
float thisAlpha;
|
||||||
maliasmesh_t mesh;
|
maliasmesh_t mesh;
|
||||||
maliasvertex_t *verts;
|
maliasvertex_t *verts;
|
||||||
|
qboolean triangleFacingLight[MD3_MAX_TRIANGLES];
|
||||||
|
|
||||||
mesh = hdr->meshes[meshnum];
|
mesh = hdr->meshes[meshnum];
|
||||||
|
|
||||||
|
@ -772,7 +772,7 @@ R_DrawShadowVolume
|
||||||
void R_DrawShadowVolume (void)
|
void R_DrawShadowVolume (void)
|
||||||
{
|
{
|
||||||
if (glConfig.drawRangeElements)
|
if (glConfig.drawRangeElements)
|
||||||
qglDrawRangeElementsEXT(GL_TRIANGLES, 0, shadow_va, shadow_index, GL_UNSIGNED_INT, indexArray);
|
qglDrawRangeElements(GL_TRIANGLES, 0, shadow_va, shadow_index, GL_UNSIGNED_INT, indexArray);
|
||||||
else
|
else
|
||||||
qglDrawElements(GL_TRIANGLES, shadow_index, GL_UNSIGNED_INT, indexArray);
|
qglDrawElements(GL_TRIANGLES, shadow_index, GL_UNSIGNED_INT, indexArray);
|
||||||
}
|
}
|
||||||
|
|
|
@ -546,7 +546,7 @@ void R_DrawAliasMD2VolumeShadow (dmd2_t *paliashdr, vec3_t bbox[8])
|
||||||
qglStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
|
qglStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
|
||||||
}
|
}
|
||||||
if (glConfig.drawRangeElements)
|
if (glConfig.drawRangeElements)
|
||||||
qglDrawRangeElementsEXT(GL_TRIANGLES, 0, md2shadow_va, md2shadow_index, GL_UNSIGNED_INT, indexArray);
|
qglDrawRangeElements(GL_TRIANGLES, 0, md2shadow_va, md2shadow_index, GL_UNSIGNED_INT, indexArray);
|
||||||
else
|
else
|
||||||
qglDrawElements(GL_TRIANGLES, md2shadow_index, GL_UNSIGNED_INT, indexArray);
|
qglDrawElements(GL_TRIANGLES, md2shadow_index, GL_UNSIGNED_INT, indexArray);
|
||||||
|
|
||||||
|
@ -562,7 +562,7 @@ void R_DrawAliasMD2VolumeShadow (dmd2_t *paliashdr, vec3_t bbox[8])
|
||||||
}
|
}
|
||||||
|
|
||||||
if (glConfig.drawRangeElements)
|
if (glConfig.drawRangeElements)
|
||||||
qglDrawRangeElementsEXT(GL_TRIANGLES, 0, md2shadow_va, md2shadow_index, GL_UNSIGNED_INT, indexArray);
|
qglDrawRangeElements(GL_TRIANGLES, 0, md2shadow_va, md2shadow_index, GL_UNSIGNED_INT, indexArray);
|
||||||
else
|
else
|
||||||
qglDrawElements(GL_TRIANGLES, md2shadow_index, GL_UNSIGNED_INT, indexArray);
|
qglDrawElements(GL_TRIANGLES, md2shadow_index, GL_UNSIGNED_INT, indexArray);
|
||||||
GL_UnlockArrays();
|
GL_UnlockArrays();
|
||||||
|
|
|
@ -247,12 +247,52 @@ void RB_DrawArrays (void)
|
||||||
if (rb_vertex == 0 || rb_index == 0) // nothing to render
|
if (rb_vertex == 0 || rb_index == 0) // nothing to render
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GL_LockArrays (rb_vertex);
|
// GL_LockArrays (rb_vertex);
|
||||||
if (glConfig.drawRangeElements)
|
if (glConfig.drawRangeElements)
|
||||||
qglDrawRangeElementsEXT(GL_TRIANGLES, 0, rb_vertex, rb_index, GL_UNSIGNED_INT, indexArray);
|
qglDrawRangeElements(GL_TRIANGLES, 0, rb_vertex, rb_index, GL_UNSIGNED_INT, indexArray);
|
||||||
else
|
else
|
||||||
qglDrawElements(GL_TRIANGLES, rb_index, GL_UNSIGNED_INT, indexArray);
|
qglDrawElements(GL_TRIANGLES, rb_index, GL_UNSIGNED_INT, indexArray);
|
||||||
GL_UnlockArrays ();
|
// GL_UnlockArrays ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=================
|
||||||
|
RB_DrawRangeArrays
|
||||||
|
=================
|
||||||
|
*/
|
||||||
|
void RB_DrawRangeArrays (unsigned start, unsigned end)
|
||||||
|
{
|
||||||
|
unsigned count;
|
||||||
|
|
||||||
|
if (rb_vertex == 0 || end == 0 || end <= start) // nothing to render
|
||||||
|
return;
|
||||||
|
|
||||||
|
count = end - start + 1;
|
||||||
|
|
||||||
|
// GL_LockArrays (rb_vertex);
|
||||||
|
if (glConfig.drawRangeElements)
|
||||||
|
qglDrawRangeElements(GL_TRIANGLES, 0, rb_vertex, count, GL_UNSIGNED_INT, &indexArray[start]);
|
||||||
|
else
|
||||||
|
qglDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_INT, &indexArray[start]);
|
||||||
|
// GL_UnlockArrays ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=================
|
||||||
|
RB_DrawPrimitiveArrays
|
||||||
|
=================
|
||||||
|
*/
|
||||||
|
void RB_DrawPrimitiveArrays (GLenum mode)
|
||||||
|
{
|
||||||
|
if (rb_vertex == 0 || rb_index == 0) // nothing to render
|
||||||
|
return;
|
||||||
|
|
||||||
|
// GL_LockArrays (rb_vertex);
|
||||||
|
if (glConfig.drawRangeElements)
|
||||||
|
qglDrawRangeElements(mode, 0, rb_vertex, rb_index, GL_UNSIGNED_INT, indexArray);
|
||||||
|
else
|
||||||
|
qglDrawElements(mode, rb_index, GL_UNSIGNED_INT, indexArray);
|
||||||
|
// GL_UnlockArrays ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -23,7 +23,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
// r_image.c
|
// r_image.c
|
||||||
|
|
||||||
#include "r_local.h"
|
#include "r_local.h"
|
||||||
//#include "r_cin.h"
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
#include "../include/jpeg/jpeglib.h"
|
#include "../include/jpeg/jpeglib.h"
|
||||||
#ifdef PNG_SUPPORT
|
#ifdef PNG_SUPPORT
|
||||||
#if defined (_MSC_VER) && (_MSC_VER <= 1200) // use older version of libpng for MSVC6
|
#if defined (_MSC_VER) && (_MSC_VER <= 1200) // use older version of libpng for MSVC6
|
||||||
|
@ -33,6 +35,19 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
#endif
|
#endif
|
||||||
#endif // PNG_SUPPORT
|
#endif // PNG_SUPPORT
|
||||||
|
|
||||||
|
#else // _WIN32
|
||||||
|
|
||||||
|
#include <jpeglib.h>
|
||||||
|
#ifdef PNG_SUPPORT
|
||||||
|
#include <png.h>
|
||||||
|
#endif // PNG_SUPPORT
|
||||||
|
|
||||||
|
#endif // _WIN32
|
||||||
|
|
||||||
|
#ifndef _WIN32 // Let's not use GLU on Linux/macOS -flibit
|
||||||
|
//#define USE_GLMIPMAP
|
||||||
|
#endif // _WIN32
|
||||||
|
|
||||||
image_t gltextures[MAX_GLTEXTURES];
|
image_t gltextures[MAX_GLTEXTURES];
|
||||||
int numgltextures;
|
int numgltextures;
|
||||||
int base_textureid; // gltextures[i] = base_textureid+i
|
int base_textureid; // gltextures[i] = base_textureid+i
|
||||||
|
@ -57,6 +72,7 @@ int gl_tex_alpha_format = 4;
|
||||||
int gl_filter_min = GL_LINEAR_MIPMAP_NEAREST;
|
int gl_filter_min = GL_LINEAR_MIPMAP_NEAREST;
|
||||||
int gl_filter_max = GL_LINEAR;
|
int gl_filter_max = GL_LINEAR;
|
||||||
|
|
||||||
|
#if 0
|
||||||
void GL_SetTexturePalette (unsigned palette[256])
|
void GL_SetTexturePalette (unsigned palette[256])
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -79,6 +95,7 @@ void GL_SetTexturePalette( unsigned palette[256] )
|
||||||
temptable );
|
temptable );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -1849,7 +1866,6 @@ GL_Upload32
|
||||||
Returns has_alpha
|
Returns has_alpha
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
//#define USE_GLMIPMAP
|
|
||||||
qboolean GL_Upload32 (unsigned *data, int width, int height, imagetype_t type)
|
qboolean GL_Upload32 (unsigned *data, int width, int height, imagetype_t type)
|
||||||
{
|
{
|
||||||
unsigned *scaled = NULL;
|
unsigned *scaled = NULL;
|
||||||
|
@ -2679,12 +2695,12 @@ void R_InitImages (void)
|
||||||
|
|
||||||
Draw_GetPalette ();
|
Draw_GetPalette ();
|
||||||
|
|
||||||
if (qglColorTableEXT)
|
/* if (qglColorTableEXT)
|
||||||
{
|
{
|
||||||
FS_LoadFile( "pics/16to8.dat", &glState.d_16to8table );
|
FS_LoadFile( "pics/16to8.dat", &glState.d_16to8table );
|
||||||
if ( !glState.d_16to8table )
|
if ( !glState.d_16to8table )
|
||||||
VID_Error( ERR_FATAL, "Couldn't load pics/16to8.pcx");
|
VID_Error( ERR_FATAL, "Couldn't load pics/16to8.pcx");
|
||||||
}
|
} */
|
||||||
|
|
||||||
if (glConfig.rendType == GLREND_VOODOO)
|
if (glConfig.rendType == GLREND_VOODOO)
|
||||||
//if ( glConfig.renderer & ( GL_RENDERER_VOODOO | GL_RENDERER_VOODOO2 ) )
|
//if ( glConfig.renderer & ( GL_RENDERER_VOODOO | GL_RENDERER_VOODOO2 ) )
|
||||||
|
|
|
@ -629,6 +629,8 @@ void RB_ModifyTextureCoords (float *inArray, float *inVerts, int numVerts, tcmod
|
||||||
qboolean RB_CheckArrayOverflow (int numVerts, int numIndex);
|
qboolean RB_CheckArrayOverflow (int numVerts, int numIndex);
|
||||||
void RB_RenderMeshGeneric (qboolean drawTris);
|
void RB_RenderMeshGeneric (qboolean drawTris);
|
||||||
void RB_DrawArrays (void);
|
void RB_DrawArrays (void);
|
||||||
|
void RB_DrawRangeArrays (unsigned start, unsigned end);
|
||||||
|
void RB_DrawPrimitiveArrays (GLenum mode);
|
||||||
void RB_DrawMeshTris (void);
|
void RB_DrawMeshTris (void);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -80,13 +80,13 @@ cvar_t *gl_driver;
|
||||||
cvar_t *gl_clear;
|
cvar_t *gl_clear;
|
||||||
|
|
||||||
// Psychospaz's console font size option
|
// Psychospaz's console font size option
|
||||||
cvar_t *con_font_size;
|
extern cvar_t *con_font_size;
|
||||||
cvar_t *con_font;
|
cvar_t *con_font;
|
||||||
cvar_t *scr_font;
|
cvar_t *scr_font;
|
||||||
cvar_t *ui_font;
|
cvar_t *ui_font;
|
||||||
cvar_t *alt_text_color;
|
extern cvar_t *alt_text_color;
|
||||||
|
|
||||||
cvar_t *scr_netgraph_pos;
|
extern cvar_t *scr_netgraph_pos;
|
||||||
|
|
||||||
cvar_t *r_norefresh;
|
cvar_t *r_norefresh;
|
||||||
cvar_t *r_drawentities;
|
cvar_t *r_drawentities;
|
||||||
|
@ -203,9 +203,9 @@ cvar_t *r_lockpvs;
|
||||||
|
|
||||||
cvar_t *r_3dlabs_broken;
|
cvar_t *r_3dlabs_broken;
|
||||||
|
|
||||||
cvar_t *vid_fullscreen;
|
extern cvar_t *vid_fullscreen;
|
||||||
cvar_t *vid_gamma;
|
extern cvar_t *vid_gamma;
|
||||||
cvar_t *vid_ref;
|
extern cvar_t *vid_ref;
|
||||||
|
|
||||||
// Changable color for r_clearcolor (enabled by gl_clar)
|
// Changable color for r_clearcolor (enabled by gl_clar)
|
||||||
cvar_t *r_clearcolor_r;
|
cvar_t *r_clearcolor_r;
|
||||||
|
@ -1458,10 +1458,10 @@ qboolean R_CheckGLExtensions (char *reason)
|
||||||
{
|
{
|
||||||
if (r_ext_draw_range_elements->integer)
|
if (r_ext_draw_range_elements->integer)
|
||||||
{
|
{
|
||||||
qglDrawRangeElementsEXT = (void *) qwglGetProcAddress("glDrawRangeElements");
|
qglDrawRangeElements = (void *) qwglGetProcAddress("glDrawRangeElements");
|
||||||
if (!qglDrawRangeElementsEXT)
|
if (!qglDrawRangeElements)
|
||||||
qglDrawRangeElementsEXT = (void *) qwglGetProcAddress("glDrawRangeElementsEXT");
|
qglDrawRangeElements = (void *) qwglGetProcAddress("glDrawRangeElementsEXT");
|
||||||
if (!qglDrawRangeElementsEXT)
|
if (!qglDrawRangeElements)
|
||||||
VID_Printf (PRINT_ALL, "..." S_COLOR_RED "glDrawRangeElements not properly supported!\n");
|
VID_Printf (PRINT_ALL, "..." S_COLOR_RED "glDrawRangeElements not properly supported!\n");
|
||||||
else {
|
else {
|
||||||
VID_Printf (PRINT_ALL, "...using glDrawRangeElements\n");
|
VID_Printf (PRINT_ALL, "...using glDrawRangeElements\n");
|
||||||
|
@ -1475,10 +1475,10 @@ qboolean R_CheckGLExtensions (char *reason)
|
||||||
{
|
{
|
||||||
if (r_ext_draw_range_elements->integer)
|
if (r_ext_draw_range_elements->integer)
|
||||||
{
|
{
|
||||||
qglDrawRangeElementsEXT = (void *) qwglGetProcAddress("glDrawRangeElementsEXT");
|
qglDrawRangeElements = (void *) qwglGetProcAddress("glDrawRangeElementsEXT");
|
||||||
if (!qglDrawRangeElementsEXT)
|
if (!qglDrawRangeElements)
|
||||||
qglDrawRangeElementsEXT = (void *) qwglGetProcAddress("glDrawRangeElements");
|
qglDrawRangeElements = (void *) qwglGetProcAddress("glDrawRangeElements");
|
||||||
if (!qglDrawRangeElementsEXT)
|
if (!qglDrawRangeElements)
|
||||||
VID_Printf (PRINT_ALL, "..." S_COLOR_RED "GL_EXT_draw_range_elements not properly supported!\n");
|
VID_Printf (PRINT_ALL, "..." S_COLOR_RED "GL_EXT_draw_range_elements not properly supported!\n");
|
||||||
else {
|
else {
|
||||||
VID_Printf (PRINT_ALL, "...enabling GL_EXT_draw_range_elements\n");
|
VID_Printf (PRINT_ALL, "...enabling GL_EXT_draw_range_elements\n");
|
||||||
|
|
|
@ -22,6 +22,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
// r_misc.c - particle image loading, and screenshots
|
// r_misc.c - particle image loading, and screenshots
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
#include "r_local.h"
|
#include "r_local.h"
|
||||||
#include "../include/jpeg/jpeglib.h" // Heffo - JPEG Screenshots
|
#include "../include/jpeg/jpeglib.h" // Heffo - JPEG Screenshots
|
||||||
#ifdef PNG_SUPPORT
|
#ifdef PNG_SUPPORT
|
||||||
|
@ -32,6 +34,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
#endif
|
#endif
|
||||||
#endif // PNG_SUPPORT
|
#endif // PNG_SUPPORT
|
||||||
|
|
||||||
|
#else // _WIN32
|
||||||
|
|
||||||
|
#include <jpeglib.h>
|
||||||
|
#ifdef PNG_SUPPORT
|
||||||
|
#include <png.h>
|
||||||
|
#endif // PNG_SUPPORT
|
||||||
|
|
||||||
|
#endif // _WIN32
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==================
|
==================
|
||||||
|
|
|
@ -213,7 +213,7 @@ vec3_t particle_up;
|
||||||
vec3_t particle_right;
|
vec3_t particle_right;
|
||||||
vec3_t particle_coord[4];
|
vec3_t particle_coord[4];
|
||||||
vec3_t ParticleVec[4];
|
vec3_t ParticleVec[4];
|
||||||
vec3_t shadelight;
|
extern vec3_t shadelight;
|
||||||
|
|
||||||
//===================================================
|
//===================================================
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,9 @@ written by Maxim Stepin (MaxSt). it is not 100% identical, but very similar.
|
||||||
#define uint32_t unsigned int
|
#define uint32_t unsigned int
|
||||||
#define uint64_t uint64
|
#define uint64_t uint64
|
||||||
|
|
||||||
|
#ifndef UINT64_C
|
||||||
#define UINT64_C(val) val##ui64
|
#define UINT64_C(val) val##ui64
|
||||||
|
#endif // UINT64_C
|
||||||
#define FIX(x) (int)((x) * (1 << 16))
|
#define FIX(x) (int)((x) * (1 << 16))
|
||||||
|
|
||||||
cvar_t *r_upscale_y;
|
cvar_t *r_upscale_y;
|
||||||
|
|
|
@ -33,9 +33,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
vec3_t vlightgrid[VLIGHT_GRIDSIZE_X][VLIGHT_GRIDSIZE_Y];
|
vec3_t vlightgrid[VLIGHT_GRIDSIZE_X][VLIGHT_GRIDSIZE_Y];
|
||||||
|
|
||||||
static vec3_t r_avertexnormals[NUMVERTEXNORMALS] = {
|
|
||||||
#include "anorms.h"
|
|
||||||
};
|
|
||||||
|
|
||||||
void VLight_InitAnormTable (void)
|
void VLight_InitAnormTable (void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,6 +30,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
#include "ui_local.h"
|
#include "ui_local.h"
|
||||||
|
|
||||||
static int m_main_cursor;
|
static int m_main_cursor;
|
||||||
|
int MainMenuMouseHover;
|
||||||
|
|
||||||
// for checking if quad cursor model is available
|
// for checking if quad cursor model is available
|
||||||
#define QUAD_CURSOR_MODEL "models/ui/quad_cursor.md2"
|
#define QUAD_CURSOR_MODEL "models/ui/quad_cursor.md2"
|
||||||
|
|
|
@ -31,8 +31,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
extern cvar_t *vid_ref;
|
extern cvar_t *vid_ref;
|
||||||
// these cvars are needed for checking if they've been modified
|
// these cvars are needed for checking if they've been modified
|
||||||
cvar_t *r_intensity;
|
//extern cvar_t *r_intensity;
|
||||||
cvar_t *r_font_upscale;
|
//extern cvar_t *r_font_upscale;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=======================================================================
|
=======================================================================
|
||||||
|
@ -222,7 +222,8 @@ static void M_AdvancedVideo_MenuSetValues (void)
|
||||||
static void M_AdvancedMenuApplyChanges (void *unused)
|
static void M_AdvancedMenuApplyChanges (void *unused)
|
||||||
{
|
{
|
||||||
// update for modified r_intensity and r_stencilTwoSide
|
// update for modified r_intensity and r_stencilTwoSide
|
||||||
if ( r_intensity->modified || r_font_upscale->modified )
|
// if ( r_intensity->modified || r_font_upscale->modified )
|
||||||
|
if ( Cvar_IsModified("r_intensity") || Cvar_IsModified("r_font_upscale") )
|
||||||
vid_ref->modified = true;
|
vid_ref->modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,8 +317,8 @@ void Menu_Video_Advanced_Init (void)
|
||||||
};
|
};
|
||||||
int y = 0;
|
int y = 0;
|
||||||
|
|
||||||
r_intensity = Cvar_Get ("r_intensity", "1", 0);
|
// r_intensity = Cvar_Get ("r_intensity", "1", 0);
|
||||||
r_font_upscale = Cvar_Get ("r_font_upscale", "1", 0);
|
// r_font_upscale = Cvar_Get ("r_font_upscale", "1", 0);
|
||||||
|
|
||||||
s_video_advanced_menu.x = SCREEN_WIDTH*0.5;
|
s_video_advanced_menu.x = SCREEN_WIDTH*0.5;
|
||||||
s_video_advanced_menu.y = SCREEN_HEIGHT*0.5 - 100;
|
s_video_advanced_menu.y = SCREEN_HEIGHT*0.5 - 100;
|
||||||
|
|
|
@ -552,7 +552,7 @@ extern char *ui_menu_drag_sound;
|
||||||
extern qboolean ui_entersound; // play after drawing a frame, so caching
|
extern qboolean ui_entersound; // play after drawing a frame, so caching
|
||||||
// won't disrupt the sound
|
// won't disrupt the sound
|
||||||
|
|
||||||
int MainMenuMouseHover;
|
extern int MainMenuMouseHover;
|
||||||
|
|
||||||
void Menu_Main_Draw (void);
|
void Menu_Main_Draw (void);
|
||||||
void UI_CheckMainMenuMouse (void);
|
void UI_CheckMainMenuMouse (void);
|
||||||
|
|
439
unix/gl_sdl.c
Normal file
439
unix/gl_sdl.c
Normal file
|
@ -0,0 +1,439 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "../renderer/r_local.h"
|
||||||
|
#include "../client/keys.h"
|
||||||
|
#include "../ui/ui_local.h"
|
||||||
|
|
||||||
|
#include <SDL.h>
|
||||||
|
#include "glw_unix.h"
|
||||||
|
|
||||||
|
glwstate_t glw_state;
|
||||||
|
|
||||||
|
int mx, my;
|
||||||
|
qboolean mouse_active = false;
|
||||||
|
|
||||||
|
int GLimp_Init(void *hinstance, void *wndproc)
|
||||||
|
{
|
||||||
|
/* No-op */
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLimp_Shutdown(void)
|
||||||
|
{
|
||||||
|
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||||
|
mouse_active = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLimp_BeginFrame(float camera_seperation)
|
||||||
|
{
|
||||||
|
/* No-op */
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLimp_EndFrame(void)
|
||||||
|
{
|
||||||
|
SDL_GL_SwapWindow(glw_state.glWindow);
|
||||||
|
}
|
||||||
|
|
||||||
|
int GLimp_SetMode(int *pwidth, int *pheight, int mode, dispType_t fullscreen)
|
||||||
|
{
|
||||||
|
int width, height;
|
||||||
|
if (!VID_GetModeInfo(&width, &height, mode))
|
||||||
|
{
|
||||||
|
Com_Printf(" invalid mode\n");
|
||||||
|
return rserr_invalid_mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fullscreen == dt_fullscreen)
|
||||||
|
{
|
||||||
|
/* Override the vidmode with the desktop resolution.
|
||||||
|
* If we wanted to be fancy we could use a faux-backbuffer to
|
||||||
|
* simulate lower resolutions, but the engine is smart and lets
|
||||||
|
* us override, so in 2021 let's just assume your PC can run
|
||||||
|
* Quake 2.
|
||||||
|
* -flibit
|
||||||
|
*/
|
||||||
|
SDL_DisplayMode mode;
|
||||||
|
SDL_SetWindowFullscreen(
|
||||||
|
glw_state.glWindow,
|
||||||
|
SDL_WINDOW_FULLSCREEN_DESKTOP
|
||||||
|
);
|
||||||
|
SDL_GetCurrentDisplayMode(
|
||||||
|
SDL_GetWindowDisplayIndex(glw_state.glWindow),
|
||||||
|
&mode
|
||||||
|
);
|
||||||
|
*pwidth = mode.w;
|
||||||
|
*pheight = mode.h;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SDL_SetWindowSize(glw_state.glWindow, width, height);
|
||||||
|
SDL_SetWindowBordered(
|
||||||
|
glw_state.glWindow,
|
||||||
|
fullscreen != dt_borderless
|
||||||
|
);
|
||||||
|
*pwidth = width;
|
||||||
|
*pheight = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_ShowWindow(glw_state.glWindow);
|
||||||
|
VID_NewWindow(*pwidth, *pheight);
|
||||||
|
return rserr_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdateGammaRamp(void)
|
||||||
|
{
|
||||||
|
/* Unsupported in 2021 */
|
||||||
|
}
|
||||||
|
|
||||||
|
char *Sys_GetClipboardData(void)
|
||||||
|
{
|
||||||
|
return SDL_GetClipboardText();
|
||||||
|
}
|
||||||
|
|
||||||
|
void IN_Activate(qboolean active)
|
||||||
|
{
|
||||||
|
if (active)
|
||||||
|
{
|
||||||
|
if (!mouse_active)
|
||||||
|
{
|
||||||
|
mx = my = 0;
|
||||||
|
SDL_SetRelativeMouseMode(SDL_TRUE);
|
||||||
|
mouse_active = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (mouse_active)
|
||||||
|
{
|
||||||
|
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||||
|
mouse_active = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* IN_Translate functions taken from yquake2 */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This creepy function translates SDL keycodes into
|
||||||
|
* the id Tech 2 engines interal representation.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
IN_TranslateSDLtoQ2Key(unsigned int keysym)
|
||||||
|
{
|
||||||
|
int key = 0;
|
||||||
|
|
||||||
|
/* These must be translated */
|
||||||
|
switch (keysym)
|
||||||
|
{
|
||||||
|
case SDLK_TAB:
|
||||||
|
key = K_TAB;
|
||||||
|
break;
|
||||||
|
case SDLK_RETURN:
|
||||||
|
key = K_ENTER;
|
||||||
|
break;
|
||||||
|
case SDLK_ESCAPE:
|
||||||
|
key = K_ESCAPE;
|
||||||
|
break;
|
||||||
|
case SDLK_BACKSPACE:
|
||||||
|
key = K_BACKSPACE;
|
||||||
|
break;
|
||||||
|
case SDLK_CAPSLOCK:
|
||||||
|
key = K_CAPSLOCK;
|
||||||
|
break;
|
||||||
|
case SDLK_PAUSE:
|
||||||
|
key = K_PAUSE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDLK_UP:
|
||||||
|
key = K_UPARROW;
|
||||||
|
break;
|
||||||
|
case SDLK_DOWN:
|
||||||
|
key = K_DOWNARROW;
|
||||||
|
break;
|
||||||
|
case SDLK_LEFT:
|
||||||
|
key = K_LEFTARROW;
|
||||||
|
break;
|
||||||
|
case SDLK_RIGHT:
|
||||||
|
key = K_RIGHTARROW;
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case SDLK_RALT:
|
||||||
|
case SDLK_LALT:
|
||||||
|
key = K_ALT;
|
||||||
|
break;
|
||||||
|
case SDLK_LCTRL:
|
||||||
|
case SDLK_RCTRL:
|
||||||
|
key = K_CTRL;
|
||||||
|
break;
|
||||||
|
case SDLK_LSHIFT:
|
||||||
|
case SDLK_RSHIFT:
|
||||||
|
key = K_SHIFT;
|
||||||
|
break;
|
||||||
|
case SDLK_INSERT:
|
||||||
|
key = K_INS;
|
||||||
|
break;
|
||||||
|
case SDLK_DELETE:
|
||||||
|
key = K_DEL;
|
||||||
|
break;
|
||||||
|
case SDLK_PAGEDOWN:
|
||||||
|
key = K_PGDN;
|
||||||
|
break;
|
||||||
|
case SDLK_PAGEUP:
|
||||||
|
key = K_PGUP;
|
||||||
|
break;
|
||||||
|
case SDLK_HOME:
|
||||||
|
key = K_HOME;
|
||||||
|
break;
|
||||||
|
case SDLK_END:
|
||||||
|
key = K_END;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDLK_F1:
|
||||||
|
key = K_F1;
|
||||||
|
break;
|
||||||
|
case SDLK_F2:
|
||||||
|
key = K_F2;
|
||||||
|
break;
|
||||||
|
case SDLK_F3:
|
||||||
|
key = K_F3;
|
||||||
|
break;
|
||||||
|
case SDLK_F4:
|
||||||
|
key = K_F4;
|
||||||
|
break;
|
||||||
|
case SDLK_F5:
|
||||||
|
key = K_F5;
|
||||||
|
break;
|
||||||
|
case SDLK_F6:
|
||||||
|
key = K_F6;
|
||||||
|
break;
|
||||||
|
case SDLK_F7:
|
||||||
|
key = K_F7;
|
||||||
|
break;
|
||||||
|
case SDLK_F8:
|
||||||
|
key = K_F8;
|
||||||
|
break;
|
||||||
|
case SDLK_F9:
|
||||||
|
key = K_F9;
|
||||||
|
break;
|
||||||
|
case SDLK_F10:
|
||||||
|
key = K_F10;
|
||||||
|
break;
|
||||||
|
case SDLK_F11:
|
||||||
|
key = K_F11;
|
||||||
|
break;
|
||||||
|
case SDLK_F12:
|
||||||
|
key = K_F12;
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case SDLK_KP_7:
|
||||||
|
key = K_KP_HOME;
|
||||||
|
break;
|
||||||
|
case SDLK_KP_8:
|
||||||
|
key = K_KP_UPARROW;
|
||||||
|
break;
|
||||||
|
case SDLK_KP_9:
|
||||||
|
key = K_KP_PGUP;
|
||||||
|
break;
|
||||||
|
case SDLK_KP_4:
|
||||||
|
key = K_KP_LEFTARROW;
|
||||||
|
break;
|
||||||
|
case SDLK_KP_5:
|
||||||
|
key = K_KP_5;
|
||||||
|
break;
|
||||||
|
case SDLK_KP_6:
|
||||||
|
key = K_KP_RIGHTARROW;
|
||||||
|
break;
|
||||||
|
case SDLK_KP_1:
|
||||||
|
key = K_KP_END;
|
||||||
|
break;
|
||||||
|
case SDLK_KP_2:
|
||||||
|
key = K_KP_DOWNARROW;
|
||||||
|
break;
|
||||||
|
case SDLK_KP_3:
|
||||||
|
key = K_KP_PGDN;
|
||||||
|
break;
|
||||||
|
case SDLK_KP_ENTER:
|
||||||
|
key = K_KP_ENTER;
|
||||||
|
break;
|
||||||
|
case SDLK_KP_0:
|
||||||
|
key = K_KP_INS;
|
||||||
|
break;
|
||||||
|
case SDLK_KP_PERIOD:
|
||||||
|
key = K_KP_DEL;
|
||||||
|
break;
|
||||||
|
case SDLK_KP_DIVIDE:
|
||||||
|
key = K_KP_SLASH;
|
||||||
|
break;
|
||||||
|
case SDLK_KP_MINUS:
|
||||||
|
key = K_KP_MINUS;
|
||||||
|
break;
|
||||||
|
case SDLK_KP_PLUS:
|
||||||
|
key = K_KP_PLUS;
|
||||||
|
break;
|
||||||
|
case SDLK_KP_MULTIPLY:
|
||||||
|
key = K_KP_MULT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HandleEvents(void)
|
||||||
|
{
|
||||||
|
int multiclicktime = 750;
|
||||||
|
SDL_Event evt;
|
||||||
|
while (SDL_PollEvent(&evt) == 1)
|
||||||
|
{
|
||||||
|
if (evt.type == SDL_QUIT)
|
||||||
|
{
|
||||||
|
Cbuf_ExecuteText(EXEC_NOW, "quit");
|
||||||
|
}
|
||||||
|
else if (evt.type == SDL_KEYDOWN || evt.type == SDL_KEYUP)
|
||||||
|
{
|
||||||
|
/* KEYDOWN/KEYUP events taken from yquake2 */
|
||||||
|
qboolean down = (evt.type == SDL_KEYDOWN);
|
||||||
|
|
||||||
|
/* workaround for AZERTY-keyboards, which don't have 1, 2, ..., 9, 0 in first row:
|
||||||
|
* always map those physical keys (scancodes) to those keycodes anyway
|
||||||
|
* see also https://bugzilla.libsdl.org/show_bug.cgi?id=3188 */
|
||||||
|
SDL_Scancode sc = evt.key.keysym.scancode;
|
||||||
|
|
||||||
|
if (sc >= SDL_SCANCODE_1 && sc <= SDL_SCANCODE_0)
|
||||||
|
{
|
||||||
|
/* Note that the SDL_SCANCODEs are SDL_SCANCODE_1, _2, ..., _9, SDL_SCANCODE_0
|
||||||
|
* while in ASCII it's '0', '1', ..., '9' => handle 0 and 1-9 separately
|
||||||
|
* (quake2 uses the ASCII values for those keys) */
|
||||||
|
int key = '0'; /* implicitly handles SDL_SCANCODE_0 */
|
||||||
|
|
||||||
|
if (sc <= SDL_SCANCODE_9)
|
||||||
|
{
|
||||||
|
key = '1' + (sc - SDL_SCANCODE_1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Key_Event(key, down, Sys_Milliseconds());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SDL_Keycode kc = evt.key.keysym.sym;
|
||||||
|
if(sc == SDL_SCANCODE_GRAVE && kc != '\'' && kc != '"')
|
||||||
|
{
|
||||||
|
// special case/hack: open the console with the "console key"
|
||||||
|
// (beneath Esc, left of 1, above Tab)
|
||||||
|
// but not if the keycode for this is a quote (like on Brazilian
|
||||||
|
// keyboards) - otherwise you couldn't type them in the console
|
||||||
|
if((evt.key.keysym.mod & (KMOD_CAPS|KMOD_SHIFT|KMOD_ALT|KMOD_CTRL|KMOD_GUI)) == 0)
|
||||||
|
{
|
||||||
|
// also, only do this if no modifiers like shift or AltGr or whatever are pressed
|
||||||
|
// so kc will most likely be the ascii char generated by this and can be ignored
|
||||||
|
// in case SDL_TEXTINPUT above (so we don't get ^ or whatever as text in console)
|
||||||
|
// (can't just check for mod == 0 because numlock is a KMOD too)
|
||||||
|
Key_Event('`', down, Sys_Milliseconds());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ((kc >= SDLK_SPACE) && (kc < SDLK_DELETE))
|
||||||
|
{
|
||||||
|
Key_Event(kc, down, false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int key = IN_TranslateSDLtoQ2Key(kc);
|
||||||
|
/* yquake2 has this, km does not
|
||||||
|
if(key == 0)
|
||||||
|
{
|
||||||
|
// fallback to scancodes if we don't know the keycode
|
||||||
|
key = IN_TranslateScancodeToQ2Key(sc);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
if(key != 0)
|
||||||
|
{
|
||||||
|
Key_Event(key, down, Sys_Milliseconds());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Com_DPrintf("Pressed unknown key with SDL_Keycode %d, SDL_Scancode %d.\n", kc, (int)sc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (evt.type == SDL_MOUSEMOTION)
|
||||||
|
{
|
||||||
|
if (mouse_active)
|
||||||
|
{
|
||||||
|
/* Relative should be on here */
|
||||||
|
mx += evt.motion.xrel;
|
||||||
|
my += evt.motion.yrel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (evt.type == SDL_MOUSEBUTTONDOWN)
|
||||||
|
{
|
||||||
|
int mouse_button = evt.button.button - 1;
|
||||||
|
if (mouse_button == 1)
|
||||||
|
{
|
||||||
|
mouse_button = 2;
|
||||||
|
}
|
||||||
|
else if (mouse_button == 2)
|
||||||
|
{
|
||||||
|
mouse_button = 1;
|
||||||
|
}
|
||||||
|
if (Sys_Milliseconds() - ui_mousecursor.buttontime[mouse_button] < multiclicktime)
|
||||||
|
{
|
||||||
|
ui_mousecursor.buttonclicks[mouse_button] += 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui_mousecursor.buttonclicks[mouse_button] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ui_mousecursor.buttonclicks[mouse_button] > 3)
|
||||||
|
{
|
||||||
|
ui_mousecursor.buttonclicks[mouse_button] = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
ui_mousecursor.buttontime[mouse_button] = Sys_Milliseconds();
|
||||||
|
|
||||||
|
ui_mousecursor.buttondown[mouse_button] = true;
|
||||||
|
ui_mousecursor.buttonused[mouse_button] = false;
|
||||||
|
ui_mousecursor.mouseaction = true;
|
||||||
|
|
||||||
|
Key_Event(K_MOUSE1 + mouse_button, 1, Sys_Milliseconds());
|
||||||
|
}
|
||||||
|
else if (evt.type == SDL_MOUSEBUTTONUP)
|
||||||
|
{
|
||||||
|
int mouse_button = evt.button.button - 1;
|
||||||
|
if (mouse_button == 1)
|
||||||
|
{
|
||||||
|
mouse_button = 2;
|
||||||
|
}
|
||||||
|
else if (mouse_button == 2)
|
||||||
|
{
|
||||||
|
mouse_button = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ui_mousecursor.buttondown[mouse_button] = false;
|
||||||
|
ui_mousecursor.buttonused[mouse_button] = false;
|
||||||
|
ui_mousecursor.mouseaction = true;
|
||||||
|
|
||||||
|
Key_Event(K_MOUSE1 + mouse_button, 0, Sys_Milliseconds());
|
||||||
|
}
|
||||||
|
else if (evt.type == SDL_MOUSEWHEEL)
|
||||||
|
{
|
||||||
|
int dir;
|
||||||
|
if (evt.wheel.y > 0)
|
||||||
|
{
|
||||||
|
dir = K_MWHEELUP;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dir = K_MWHEELDOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We only get one event per wheel change, so instantly press/release */
|
||||||
|
Key_Event(dir, 1, Sys_Milliseconds());
|
||||||
|
Key_Event(dir, 0, Sys_Milliseconds());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -31,7 +31,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
void *OpenGLLib; // instance of OpenGL library
|
SDL_Window *glWindow;
|
||||||
|
SDL_GLContext glContext;
|
||||||
|
|
||||||
FILE *log_fp;
|
FILE *log_fp;
|
||||||
} glwstate_t;
|
} glwstate_t;
|
||||||
|
|
|
@ -105,7 +105,6 @@ void IN_Commands (void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void M_Think_MouseCursor (void);
|
|
||||||
void IN_Move (usercmd_t *cmd)
|
void IN_Move (usercmd_t *cmd)
|
||||||
{
|
{
|
||||||
if (!mouse_avail)
|
if (!mouse_avail)
|
||||||
|
@ -139,7 +138,6 @@ void IN_Move (usercmd_t *cmd)
|
||||||
if (ui_mousecursor.x > viddef.width) ui_mousecursor.x = viddef.width;
|
if (ui_mousecursor.x > viddef.width) ui_mousecursor.x = viddef.width;
|
||||||
if (ui_mousecursor.y < 0) ui_mousecursor.y = 0;
|
if (ui_mousecursor.y < 0) ui_mousecursor.y = 0;
|
||||||
if (ui_mousecursor.y > viddef.height) ui_mousecursor.y = viddef.height;
|
if (ui_mousecursor.y > viddef.height) ui_mousecursor.y = viddef.height;
|
||||||
M_Think_MouseCursor();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// psychospaz - zooming in preserves sensitivity
|
// psychospaz - zooming in preserves sensitivity
|
||||||
|
|
|
@ -536,7 +536,7 @@ int NET_Socket (char *net_interface, int port)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!net_interface || !net_interface[0] || !stricmp(net_interface, "localhost"))
|
if (!net_interface || !net_interface[0] || !Q_stricmp(net_interface, "localhost"))
|
||||||
address.sin_addr.s_addr = INADDR_ANY;
|
address.sin_addr.s_addr = INADDR_ANY;
|
||||||
else
|
else
|
||||||
NET_StringToSockaddr (net_interface, (struct sockaddr *)&address);
|
NET_StringToSockaddr (net_interface, (struct sockaddr *)&address);
|
||||||
|
|
41
unix/old/glw_unix.h
Normal file
41
unix/old/glw_unix.h
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
===========================================================================
|
||||||
|
Copyright (C) 1997-2001 Id Software, Inc.
|
||||||
|
|
||||||
|
This file is part of Quake 2 source code.
|
||||||
|
|
||||||
|
Quake 2 source code is free software; you can redistribute it
|
||||||
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
|
or (at your option) any later version.
|
||||||
|
|
||||||
|
Quake 2 source code is distributed in the hope that it will be
|
||||||
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Quake 2 source code; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
===========================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __linux__
|
||||||
|
#ifndef __FreeBSD__
|
||||||
|
#error You shouldnt be including this file on non-Linux platforms
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __GLW_LINUX_H__
|
||||||
|
#define __GLW_LINUX_H__
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
void *OpenGLLib; // instance of OpenGL library
|
||||||
|
|
||||||
|
FILE *log_fp;
|
||||||
|
} glwstate_t;
|
||||||
|
|
||||||
|
extern glwstate_t glw_state;
|
||||||
|
|
||||||
|
#endif
|
182
unix/old/in_unix.c
Normal file
182
unix/old/in_unix.c
Normal file
|
@ -0,0 +1,182 @@
|
||||||
|
/*
|
||||||
|
===========================================================================
|
||||||
|
Copyright (C) 1997-2001 Id Software, Inc.
|
||||||
|
|
||||||
|
This file is part of Quake 2 source code.
|
||||||
|
|
||||||
|
Quake 2 source code is free software; you can redistribute it
|
||||||
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
|
or (at your option) any later version.
|
||||||
|
|
||||||
|
Quake 2 source code is distributed in the hope that it will be
|
||||||
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Quake 2 source code; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
===========================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
// in_unix.c -- unix mouse and joystick code
|
||||||
|
|
||||||
|
#include "../client/client.h"
|
||||||
|
#include "../ui/ui_local.h"
|
||||||
|
|
||||||
|
cvar_t *in_mouse;
|
||||||
|
cvar_t *in_joystick;
|
||||||
|
extern int mx, my;
|
||||||
|
static qboolean mouse_avail;
|
||||||
|
static int old_mouse_x, old_mouse_y;
|
||||||
|
|
||||||
|
static qboolean mlooking;
|
||||||
|
cvar_t *m_filter;
|
||||||
|
cvar_t *in_dgamouse;
|
||||||
|
cvar_t *autosensitivity;
|
||||||
|
cvar_t *in_menumouse; /// FIXME Menu Mouse on windowed mode
|
||||||
|
|
||||||
|
//extern cursor_t cursor;
|
||||||
|
|
||||||
|
void UI_RefreshCursorMenu (void);
|
||||||
|
void UI_RefreshCursorLink (void);
|
||||||
|
|
||||||
|
void IN_MLookDown (void) {
|
||||||
|
mlooking = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IN_MLookUp (void) {
|
||||||
|
mlooking = false;
|
||||||
|
if (!freelook->value && lookspring->value)
|
||||||
|
IN_CenterView ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Force_CenterView_f (void)
|
||||||
|
{
|
||||||
|
cl.viewangles[PITCH] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IN_Init (void)
|
||||||
|
{
|
||||||
|
in_mouse = Cvar_Get ("in_mouse", "1", CVAR_ARCHIVE);
|
||||||
|
Cvar_SetDescription ("in_mouse", "Enables mouse input.");
|
||||||
|
in_joystick = Cvar_Get ("in_joystick", "0", CVAR_ARCHIVE);
|
||||||
|
Cvar_SetDescription ("in_joystick", "Enables joystick input.");
|
||||||
|
m_filter = Cvar_Get ("m_filter", "0", 0);
|
||||||
|
Cvar_SetDescription ("m_filter", "Enables mouse input filtering.");
|
||||||
|
in_dgamouse = Cvar_Get ("in_dgamouse", "1", CVAR_ARCHIVE);
|
||||||
|
in_menumouse = Cvar_Get ("in_menumouse", "0", CVAR_ARCHIVE);
|
||||||
|
// Knightmare added
|
||||||
|
autosensitivity = Cvar_Get ("autosensitivity", "1", CVAR_ARCHIVE);
|
||||||
|
Cvar_SetDescription ("autosensitivity", "Enables scaling of mouse and joystick sensitivty when zoomed in.");
|
||||||
|
|
||||||
|
Cmd_AddCommand ("+mlook", IN_MLookDown);
|
||||||
|
Cmd_AddCommand ("-mlook", IN_MLookUp);
|
||||||
|
Cmd_AddCommand ("force_centerview", Force_CenterView_f);
|
||||||
|
|
||||||
|
mx = my = 0.0;
|
||||||
|
|
||||||
|
if (in_mouse->value)
|
||||||
|
mouse_avail = true;
|
||||||
|
else
|
||||||
|
mouse_avail = false;
|
||||||
|
|
||||||
|
// Knightmare- added Psychospaz's menu mouse support
|
||||||
|
UI_RefreshCursorMenu();
|
||||||
|
UI_RefreshCursorLink();
|
||||||
|
}
|
||||||
|
|
||||||
|
void IN_Shutdown (void)
|
||||||
|
{
|
||||||
|
if (!mouse_avail)
|
||||||
|
return;
|
||||||
|
|
||||||
|
IN_Activate(false);
|
||||||
|
|
||||||
|
mouse_avail = false;
|
||||||
|
|
||||||
|
Cmd_RemoveCommand ("+mlook");
|
||||||
|
Cmd_RemoveCommand ("-mlook");
|
||||||
|
Cmd_RemoveCommand ("force_centerview");
|
||||||
|
}
|
||||||
|
|
||||||
|
void IN_Commands (void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void M_Think_MouseCursor (void);
|
||||||
|
void IN_Move (usercmd_t *cmd)
|
||||||
|
{
|
||||||
|
if (!mouse_avail)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!autosensitivity)
|
||||||
|
autosensitivity = Cvar_Get ("autosensitivity", "1", CVAR_ARCHIVE);
|
||||||
|
|
||||||
|
if (m_filter->value)
|
||||||
|
{
|
||||||
|
mx = (mx + old_mouse_x) * 0.5;
|
||||||
|
my = (my + old_mouse_y) * 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
old_mouse_x = mx;
|
||||||
|
old_mouse_y = my;
|
||||||
|
|
||||||
|
//now to set the menu cursor
|
||||||
|
if (cls.key_dest == key_menu)
|
||||||
|
{
|
||||||
|
ui_mousecursor.oldx = ui_mousecursor.x;
|
||||||
|
ui_mousecursor.oldy = ui_mousecursor.y;
|
||||||
|
|
||||||
|
ui_mousecursor.x += mx * ui_sensitivity->value;
|
||||||
|
ui_mousecursor.y += my * ui_sensitivity->value;
|
||||||
|
|
||||||
|
if (ui_mousecursor.x!=ui_mousecursor.oldx || ui_mousecursor.y!=ui_mousecursor.oldy)
|
||||||
|
ui_mousecursor.mouseaction = true;
|
||||||
|
|
||||||
|
if (ui_mousecursor.x < 0) ui_mousecursor.x = 0;
|
||||||
|
if (ui_mousecursor.x > viddef.width) ui_mousecursor.x = viddef.width;
|
||||||
|
if (ui_mousecursor.y < 0) ui_mousecursor.y = 0;
|
||||||
|
if (ui_mousecursor.y > viddef.height) ui_mousecursor.y = viddef.height;
|
||||||
|
M_Think_MouseCursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
// psychospaz - zooming in preserves sensitivity
|
||||||
|
if (in_autosensitivity->integer && cl.base_fov < 90)
|
||||||
|
{
|
||||||
|
mx *= sensitivity->value * (cl.base_fov/90.0);
|
||||||
|
my *= sensitivity->value * (cl.base_fov/90.0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mx *= sensitivity->value;
|
||||||
|
my *= sensitivity->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// add mouse X/Y movement to cmd
|
||||||
|
if ((in_strafe.state & 1) || (lookstrafe->value && mlooking))
|
||||||
|
cmd->sidemove += m_side->value * mx;
|
||||||
|
else
|
||||||
|
cl.viewangles[YAW] -= m_yaw->value * mx;
|
||||||
|
|
||||||
|
if ( (mlooking || freelook->value) && !(in_strafe.state & 1))
|
||||||
|
cl.viewangles[PITCH] += m_pitch->value * my;
|
||||||
|
else
|
||||||
|
cmd->forwardmove -= m_forward->value * my;
|
||||||
|
|
||||||
|
mx = my = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IN_Frame (void)
|
||||||
|
{
|
||||||
|
if (!mouse_avail)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( !cl.refresh_prepped || cls.key_dest == key_console || cls.key_dest == key_menu)
|
||||||
|
IN_Activate(false);
|
||||||
|
else
|
||||||
|
IN_Activate(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
605
unix/old/net_udp.c
Normal file
605
unix/old/net_udp.c
Normal file
|
@ -0,0 +1,605 @@
|
||||||
|
/*
|
||||||
|
===========================================================================
|
||||||
|
Copyright (C) 1997-2001 Id Software, Inc.
|
||||||
|
|
||||||
|
This file is part of Quake 2 source code.
|
||||||
|
|
||||||
|
Quake 2 source code is free software; you can redistribute it
|
||||||
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
|
or (at your option) any later version.
|
||||||
|
|
||||||
|
Quake 2 source code is distributed in the hope that it will be
|
||||||
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Quake 2 source code; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
===========================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
// net_wins.c
|
||||||
|
|
||||||
|
#include "../qcommon/qcommon.h"
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/uio.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
|
#ifdef NeXT
|
||||||
|
#include <libc.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
netadr_t net_local_adr;
|
||||||
|
|
||||||
|
#define LOOPBACK 0x7f000001
|
||||||
|
|
||||||
|
#define MAX_LOOPBACK 4
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
byte data[MAX_MSGLEN];
|
||||||
|
int datalen;
|
||||||
|
} loopmsg_t;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
loopmsg_t msgs[MAX_LOOPBACK];
|
||||||
|
int get, send;
|
||||||
|
} loopback_t;
|
||||||
|
|
||||||
|
loopback_t loopbacks[2];
|
||||||
|
int ip_sockets[2];
|
||||||
|
int ipx_sockets[2];
|
||||||
|
int server_port; // added for r1ch fix
|
||||||
|
|
||||||
|
int NET_Socket (char *net_interface, int port);
|
||||||
|
char *NET_ErrorString (void);
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
|
||||||
|
void NetadrToSockadr (netadr_t *a, struct sockaddr_in *s)
|
||||||
|
{
|
||||||
|
memset (s, 0, sizeof(*s));
|
||||||
|
|
||||||
|
if (a->type == NA_BROADCAST)
|
||||||
|
{
|
||||||
|
s->sin_family = AF_INET;
|
||||||
|
|
||||||
|
s->sin_port = a->port;
|
||||||
|
*(int *)&s->sin_addr = -1;
|
||||||
|
}
|
||||||
|
else if (a->type == NA_IP)
|
||||||
|
{
|
||||||
|
s->sin_family = AF_INET;
|
||||||
|
|
||||||
|
*(int *)&s->sin_addr = *(int *)&a->ip;
|
||||||
|
s->sin_port = a->port;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SockadrToNetadr (struct sockaddr_in *s, netadr_t *a)
|
||||||
|
{
|
||||||
|
*(int *)&a->ip = *(int *)&s->sin_addr;
|
||||||
|
a->port = s->sin_port;
|
||||||
|
a->type = NA_IP;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
qboolean NET_CompareAdr (netadr_t a, netadr_t b)
|
||||||
|
{
|
||||||
|
if (a.ip[0] == b.ip[0] && a.ip[1] == b.ip[1] && a.ip[2] == b.ip[2] && a.ip[3] == b.ip[3] && a.port == b.port)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
===================
|
||||||
|
NET_CompareBaseAdr
|
||||||
|
|
||||||
|
Compares without the port
|
||||||
|
===================
|
||||||
|
*/
|
||||||
|
qboolean NET_CompareBaseAdr (netadr_t a, netadr_t b)
|
||||||
|
{
|
||||||
|
if (a.type != b.type)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (a.type == NA_LOOPBACK)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (a.type == NA_IP)
|
||||||
|
{
|
||||||
|
if (a.ip[0] == b.ip[0] && a.ip[1] == b.ip[1] && a.ip[2] == b.ip[2] && a.ip[3] == b.ip[3])
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (a.type == NA_IPX)
|
||||||
|
{
|
||||||
|
if ((memcmp(a.ipx, b.ipx, 10) == 0))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *NET_AdrToString (netadr_t a)
|
||||||
|
{
|
||||||
|
static char s[64];
|
||||||
|
|
||||||
|
Com_sprintf (s, sizeof(s), "%i.%i.%i.%i:%i", a.ip[0], a.ip[1], a.ip[2], a.ip[3], ntohs(a.port));
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *NET_BaseAdrToString (netadr_t a)
|
||||||
|
{
|
||||||
|
static char s[64];
|
||||||
|
|
||||||
|
Com_sprintf (s, sizeof(s), "%i.%i.%i.%i", a.ip[0], a.ip[1], a.ip[2], a.ip[3]);
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=============
|
||||||
|
NET_StringToAdr
|
||||||
|
|
||||||
|
localhost
|
||||||
|
idnewt
|
||||||
|
idnewt:28000
|
||||||
|
192.246.40.70
|
||||||
|
192.246.40.70:28000
|
||||||
|
=============
|
||||||
|
*/
|
||||||
|
qboolean NET_StringToSockaddr (char *s, struct sockaddr *sadr)
|
||||||
|
{
|
||||||
|
struct hostent *h;
|
||||||
|
char *colon;
|
||||||
|
char copy[128];
|
||||||
|
|
||||||
|
memset (sadr, 0, sizeof(*sadr));
|
||||||
|
((struct sockaddr_in *)sadr)->sin_family = AF_INET;
|
||||||
|
|
||||||
|
((struct sockaddr_in *)sadr)->sin_port = 0;
|
||||||
|
|
||||||
|
// strncpy (copy, s);
|
||||||
|
Q_strncpyz (copy, sizeof(copy), s);
|
||||||
|
// strip off a trailing :port if present
|
||||||
|
for (colon = copy ; *colon ; colon++)
|
||||||
|
if (*colon == ':')
|
||||||
|
{
|
||||||
|
*colon = 0;
|
||||||
|
((struct sockaddr_in *)sadr)->sin_port = htons((short)atoi(colon+1));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (copy[0] >= '0' && copy[0] <= '9')
|
||||||
|
{
|
||||||
|
*(int *)&((struct sockaddr_in *)sadr)->sin_addr = inet_addr(copy);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (! (h = gethostbyname(copy)) )
|
||||||
|
return 0;
|
||||||
|
*(int *)&((struct sockaddr_in *)sadr)->sin_addr = *(int *)h->h_addr_list[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=============
|
||||||
|
NET_StringToAdr
|
||||||
|
|
||||||
|
localhost
|
||||||
|
idnewt
|
||||||
|
idnewt:28000
|
||||||
|
192.246.40.70
|
||||||
|
192.246.40.70:28000
|
||||||
|
=============
|
||||||
|
*/
|
||||||
|
qboolean NET_StringToAdr (char *s, netadr_t *a)
|
||||||
|
{
|
||||||
|
struct sockaddr_in sadr;
|
||||||
|
|
||||||
|
if (!strcmp (s, "localhost"))
|
||||||
|
{
|
||||||
|
memset (a, 0, sizeof(*a));
|
||||||
|
a->type = NA_LOOPBACK;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!NET_StringToSockaddr (s, (struct sockaddr *)&sadr))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
SockadrToNetadr (&sadr, a);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
=============
|
||||||
|
NET_IsLocalAddress
|
||||||
|
=============
|
||||||
|
*/
|
||||||
|
qboolean NET_IsLocalAddress (netadr_t adr)
|
||||||
|
{
|
||||||
|
return NET_CompareAdr (adr, net_local_adr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
=============
|
||||||
|
NET_IsLocalHost
|
||||||
|
=============
|
||||||
|
*/
|
||||||
|
qboolean NET_IsLocalHost (netadr_t adr)
|
||||||
|
{
|
||||||
|
return (adr.type == NA_LOOPBACK);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=============================================================================
|
||||||
|
|
||||||
|
LOOPBACK BUFFERS FOR LOCAL PLAYER
|
||||||
|
|
||||||
|
=============================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
=============
|
||||||
|
NET_GetLoopPacket
|
||||||
|
=============
|
||||||
|
*/
|
||||||
|
qboolean NET_GetLoopPacket (netsrc_t sock, netadr_t *net_from, sizebuf_t *net_message)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
loopback_t *loop;
|
||||||
|
|
||||||
|
loop = &loopbacks[sock];
|
||||||
|
|
||||||
|
if (loop->send - loop->get > MAX_LOOPBACK)
|
||||||
|
loop->get = loop->send - MAX_LOOPBACK;
|
||||||
|
|
||||||
|
if (loop->get >= loop->send)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
i = loop->get & (MAX_LOOPBACK-1);
|
||||||
|
loop->get++;
|
||||||
|
|
||||||
|
memcpy (net_message->data, loop->msgs[i].data, loop->msgs[i].datalen);
|
||||||
|
net_message->cursize = loop->msgs[i].datalen;
|
||||||
|
*net_from = net_local_adr;
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
=============
|
||||||
|
NET_SendLoopPacket
|
||||||
|
=============
|
||||||
|
*/
|
||||||
|
void NET_SendLoopPacket (netsrc_t sock, int length, void *data, netadr_t to)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
loopback_t *loop;
|
||||||
|
|
||||||
|
loop = &loopbacks[sock^1];
|
||||||
|
|
||||||
|
i = loop->send & (MAX_LOOPBACK-1);
|
||||||
|
loop->send++;
|
||||||
|
|
||||||
|
memcpy (loop->msgs[i].data, data, length);
|
||||||
|
loop->msgs[i].datalen = length;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
|
||||||
|
/*
|
||||||
|
=============
|
||||||
|
NET_GetPacket
|
||||||
|
=============
|
||||||
|
*/
|
||||||
|
qboolean NET_GetPacket (netsrc_t sock, netadr_t *net_from, sizebuf_t *net_message)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
struct sockaddr_in from;
|
||||||
|
int fromlen;
|
||||||
|
int net_socket;
|
||||||
|
int protocol;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
if (NET_GetLoopPacket (sock, net_from, net_message))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
for (protocol = 0 ; protocol < 2 ; protocol++)
|
||||||
|
{
|
||||||
|
if (protocol == 0)
|
||||||
|
net_socket = ip_sockets[sock];
|
||||||
|
else
|
||||||
|
net_socket = ipx_sockets[sock];
|
||||||
|
|
||||||
|
if (!net_socket)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
fromlen = sizeof(from);
|
||||||
|
ret = recvfrom (net_socket, net_message->data, net_message->maxsize
|
||||||
|
, 0, (struct sockaddr *)&from, (socklen_t *)&fromlen);
|
||||||
|
|
||||||
|
SockadrToNetadr (&from, net_from);
|
||||||
|
|
||||||
|
if (ret == -1)
|
||||||
|
{
|
||||||
|
err = errno;
|
||||||
|
|
||||||
|
if (err == EWOULDBLOCK || err == ECONNREFUSED)
|
||||||
|
continue;
|
||||||
|
Com_Printf ("NET_GetPacket: %s from %s\n", NET_ErrorString(),
|
||||||
|
NET_AdrToString(*net_from));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret == net_message->maxsize)
|
||||||
|
{
|
||||||
|
Com_Printf ("Oversize packet from %s\n", NET_AdrToString (*net_from));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
net_message->cursize = ret;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
|
||||||
|
/*
|
||||||
|
=============
|
||||||
|
NET_SendPacket
|
||||||
|
=============
|
||||||
|
*/
|
||||||
|
void NET_SendPacket (netsrc_t sock, int length, void *data, netadr_t to)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
struct sockaddr_in addr;
|
||||||
|
int net_socket;
|
||||||
|
|
||||||
|
if ( to.type == NA_LOOPBACK )
|
||||||
|
{
|
||||||
|
NET_SendLoopPacket (sock, length, data, to);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (to.type == NA_BROADCAST)
|
||||||
|
{
|
||||||
|
net_socket = ip_sockets[sock];
|
||||||
|
if (!net_socket)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (to.type == NA_IP)
|
||||||
|
{
|
||||||
|
net_socket = ip_sockets[sock];
|
||||||
|
if (!net_socket)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (to.type == NA_IPX)
|
||||||
|
{
|
||||||
|
net_socket = ipx_sockets[sock];
|
||||||
|
if (!net_socket)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (to.type == NA_BROADCAST_IPX)
|
||||||
|
{
|
||||||
|
net_socket = ipx_sockets[sock];
|
||||||
|
if (!net_socket)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Com_Error (ERR_FATAL, "NET_SendPacket: bad address type");
|
||||||
|
|
||||||
|
NetadrToSockadr (&to, &addr);
|
||||||
|
|
||||||
|
ret = sendto (net_socket, data, length, 0, (struct sockaddr *)&addr, sizeof(addr) );
|
||||||
|
if (ret == -1)
|
||||||
|
{
|
||||||
|
Com_Printf ("NET_SendPacket ERROR: %s to %s\n", NET_ErrorString(),
|
||||||
|
NET_AdrToString (to));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
====================
|
||||||
|
NET_OpenIP
|
||||||
|
====================
|
||||||
|
*/
|
||||||
|
void NET_OpenIP (void)
|
||||||
|
{
|
||||||
|
cvar_t *port, *ip;
|
||||||
|
|
||||||
|
port = Cvar_Get ("port", va("%i", PORT_SERVER), CVAR_NOSET);
|
||||||
|
ip = Cvar_Get ("ip", "localhost", CVAR_NOSET);
|
||||||
|
|
||||||
|
if (!ip_sockets[NS_SERVER]) {
|
||||||
|
server_port = port; // added for r1ch fix
|
||||||
|
ip_sockets[NS_SERVER] = NET_Socket (ip->string, port->value);
|
||||||
|
}
|
||||||
|
if (!ip_sockets[NS_CLIENT])
|
||||||
|
ip_sockets[NS_CLIENT] = NET_Socket (ip->string, PORT_ANY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
====================
|
||||||
|
NET_OpenIPX
|
||||||
|
====================
|
||||||
|
*/
|
||||||
|
void NET_OpenIPX (void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
====================
|
||||||
|
NET_Config
|
||||||
|
|
||||||
|
A single player game will only use the loopback code
|
||||||
|
====================
|
||||||
|
*/
|
||||||
|
void NET_Config (qboolean multiplayer)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (!multiplayer)
|
||||||
|
{ // shut down any existing sockets
|
||||||
|
for (i=0 ; i<2 ; i++)
|
||||||
|
{
|
||||||
|
if (ip_sockets[i])
|
||||||
|
{
|
||||||
|
close (ip_sockets[i]);
|
||||||
|
ip_sockets[i] = 0;
|
||||||
|
}
|
||||||
|
if (ipx_sockets[i])
|
||||||
|
{
|
||||||
|
close (ipx_sockets[i]);
|
||||||
|
ipx_sockets[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // open sockets
|
||||||
|
NET_OpenIP ();
|
||||||
|
NET_OpenIPX ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//===================================================================
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
====================
|
||||||
|
NET_Init
|
||||||
|
====================
|
||||||
|
*/
|
||||||
|
void NET_Init (void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
====================
|
||||||
|
NET_Socket
|
||||||
|
====================
|
||||||
|
*/
|
||||||
|
int NET_Socket (char *net_interface, int port)
|
||||||
|
{
|
||||||
|
int newsocket;
|
||||||
|
struct sockaddr_in address;
|
||||||
|
qboolean _true = true;
|
||||||
|
int i = 1;
|
||||||
|
|
||||||
|
if ((newsocket = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
|
||||||
|
{
|
||||||
|
Com_Printf ("ERROR: UDP_OpenSocket: socket: %s", NET_ErrorString());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// make it non-blocking
|
||||||
|
if (ioctl (newsocket, FIONBIO, &_true) == -1)
|
||||||
|
{
|
||||||
|
Com_Printf ("ERROR: UDP_OpenSocket: ioctl FIONBIO:%s\n", NET_ErrorString());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// make it broadcast capable
|
||||||
|
if (setsockopt(newsocket, SOL_SOCKET, SO_BROADCAST, (char *)&i, sizeof(i)) == -1)
|
||||||
|
{
|
||||||
|
Com_Printf ("ERROR: UDP_OpenSocket: setsockopt SO_BROADCAST:%s\n", NET_ErrorString());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!net_interface || !net_interface[0] || !stricmp(net_interface, "localhost"))
|
||||||
|
address.sin_addr.s_addr = INADDR_ANY;
|
||||||
|
else
|
||||||
|
NET_StringToSockaddr (net_interface, (struct sockaddr *)&address);
|
||||||
|
|
||||||
|
if (port == PORT_ANY)
|
||||||
|
address.sin_port = 0;
|
||||||
|
else
|
||||||
|
address.sin_port = htons((short)port);
|
||||||
|
|
||||||
|
address.sin_family = AF_INET;
|
||||||
|
|
||||||
|
if( bind (newsocket, (void *)&address, sizeof(address)) == -1)
|
||||||
|
{
|
||||||
|
Com_Printf ("ERROR: UDP_OpenSocket: bind: %s\n", NET_ErrorString());
|
||||||
|
close (newsocket);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return newsocket;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
====================
|
||||||
|
NET_Shutdown
|
||||||
|
====================
|
||||||
|
*/
|
||||||
|
void NET_Shutdown (void)
|
||||||
|
{
|
||||||
|
NET_Config (false); // close sockets
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
====================
|
||||||
|
NET_ErrorString
|
||||||
|
====================
|
||||||
|
*/
|
||||||
|
char *NET_ErrorString (void)
|
||||||
|
{
|
||||||
|
int code;
|
||||||
|
|
||||||
|
code = errno;
|
||||||
|
return strerror (code);
|
||||||
|
}
|
||||||
|
|
||||||
|
// sleeps msec or until net socket is ready
|
||||||
|
void NET_Sleep(int msec)
|
||||||
|
{
|
||||||
|
struct timeval timeout;
|
||||||
|
fd_set fdset;
|
||||||
|
extern cvar_t *dedicated;
|
||||||
|
extern qboolean stdin_active;
|
||||||
|
|
||||||
|
if (!ip_sockets[NS_SERVER] || (dedicated && !dedicated->value))
|
||||||
|
return; // we're not a server, just run full speed
|
||||||
|
|
||||||
|
FD_ZERO(&fdset);
|
||||||
|
if (stdin_active)
|
||||||
|
FD_SET(0, &fdset); // stdin is processed too
|
||||||
|
FD_SET(ip_sockets[NS_SERVER], &fdset); // network socket
|
||||||
|
timeout.tv_sec = msec/1000;
|
||||||
|
timeout.tv_usec = (msec%1000)*1000;
|
||||||
|
select(ip_sockets[NS_SERVER]+1, &fdset, NULL, NULL, &timeout);
|
||||||
|
}
|
||||||
|
|
4201
unix/old/qgl_unix.c
Normal file
4201
unix/old/qgl_unix.c
Normal file
File diff suppressed because it is too large
Load diff
453
unix/old/sys_unix.c
Normal file
453
unix/old/sys_unix.c
Normal file
|
@ -0,0 +1,453 @@
|
||||||
|
/*
|
||||||
|
===========================================================================
|
||||||
|
Copyright (C) 1997-2001 Id Software, Inc.
|
||||||
|
|
||||||
|
This file is part of Quake 2 source code.
|
||||||
|
|
||||||
|
Quake 2 source code is free software; you can redistribute it
|
||||||
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
|
or (at your option) any later version.
|
||||||
|
|
||||||
|
Quake 2 source code is distributed in the hope that it will be
|
||||||
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Quake 2 source code; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
===========================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/ipc.h>
|
||||||
|
#include <sys/shm.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
#include <mntent.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <dlfcn.h>
|
||||||
|
|
||||||
|
#include "../qcommon/qcommon.h"
|
||||||
|
|
||||||
|
cvar_t *nostdout;
|
||||||
|
|
||||||
|
unsigned sys_frame_time;
|
||||||
|
|
||||||
|
uid_t saved_euid;
|
||||||
|
qboolean stdin_active = true;
|
||||||
|
int ActiveApp;
|
||||||
|
|
||||||
|
// Knightmare- added exe / pref dirs
|
||||||
|
static char exe_dir[MAX_OSPATH];
|
||||||
|
static char pref_dir[MAX_OSPATH];
|
||||||
|
static char download_dir[MAX_OSPATH];
|
||||||
|
|
||||||
|
// =======================================================================
|
||||||
|
// General routines
|
||||||
|
// =======================================================================
|
||||||
|
|
||||||
|
void Sys_ConsoleOutput (char *string)
|
||||||
|
{
|
||||||
|
if (nostdout && nostdout->value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fputs(string, stdout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sys_Sleep (int msec)
|
||||||
|
{
|
||||||
|
if (msec < 0) return;
|
||||||
|
usleep ((unsigned int)msec * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned Sys_TickCount (void)
|
||||||
|
{
|
||||||
|
return clock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sys_Printf (char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list argptr;
|
||||||
|
char text[1024];
|
||||||
|
unsigned char *p;
|
||||||
|
|
||||||
|
va_start (argptr, fmt);
|
||||||
|
Q_vsnprintf (text, sizeof(text), fmt, argptr);
|
||||||
|
va_end (argptr);
|
||||||
|
|
||||||
|
if (strlen(text) > sizeof(text))
|
||||||
|
Sys_Error("memory overwrite in Sys_Printf");
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
CL_Shutdown ();
|
||||||
|
Qcommon_Shutdown ();
|
||||||
|
fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sys_Init(void)
|
||||||
|
{
|
||||||
|
#if id386
|
||||||
|
// Sys_SetFPCW();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sys_Error (const char *error, ...)
|
||||||
|
{
|
||||||
|
va_list argptr;
|
||||||
|
char string[1024];
|
||||||
|
|
||||||
|
// change stdin to non blocking
|
||||||
|
fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
|
||||||
|
|
||||||
|
CL_Shutdown ();
|
||||||
|
Qcommon_Shutdown ();
|
||||||
|
|
||||||
|
va_start (argptr, error);
|
||||||
|
Q_vsnprintf (string, sizeof(string), error, argptr);
|
||||||
|
va_end (argptr);
|
||||||
|
fprintf(stderr, "Error: %s\n", string);
|
||||||
|
|
||||||
|
_exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sys_Warn (char *warning, ...)
|
||||||
|
{
|
||||||
|
va_list argptr;
|
||||||
|
char string[1024];
|
||||||
|
|
||||||
|
va_start (argptr, warning);
|
||||||
|
Q_vsnprintf (string, sizeof(string), warning, argptr);
|
||||||
|
va_end (argptr);
|
||||||
|
fprintf(stderr, "Warning: %s", string);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
============
|
||||||
|
Sys_FileTime
|
||||||
|
|
||||||
|
returns -1 if not present
|
||||||
|
============
|
||||||
|
*/
|
||||||
|
int Sys_FileTime (char *path)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *Sys_ConsoleInput(void)
|
||||||
|
{
|
||||||
|
static char text[256];
|
||||||
|
int len;
|
||||||
|
fd_set fdset;
|
||||||
|
struct timeval timeout;
|
||||||
|
|
||||||
|
if (!dedicated || !dedicated->value)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (!stdin_active)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
FD_ZERO(&fdset);
|
||||||
|
FD_SET(0, &fdset); // stdin
|
||||||
|
timeout.tv_sec = 0;
|
||||||
|
timeout.tv_usec = 0;
|
||||||
|
if (select (1, &fdset, NULL, NULL, &timeout) == -1 || !FD_ISSET(0, &fdset))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
len = read (0, text, sizeof(text));
|
||||||
|
if (len == 0) { // eof!
|
||||||
|
stdin_active = false;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (len < 1)
|
||||||
|
return NULL;
|
||||||
|
text[len-1] = 0; // rip off the /n and terminate
|
||||||
|
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Knightmare added
|
||||||
|
void Sys_ShowConsole (qboolean show)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static void *game_library;
|
||||||
|
|
||||||
|
/*
|
||||||
|
=================
|
||||||
|
Sys_UnloadGame
|
||||||
|
=================
|
||||||
|
*/
|
||||||
|
void Sys_UnloadGame (void)
|
||||||
|
{
|
||||||
|
if (game_library)
|
||||||
|
dlclose (game_library);
|
||||||
|
game_library = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=================
|
||||||
|
Sys_GetGameAPI
|
||||||
|
|
||||||
|
Loads the game dll
|
||||||
|
=================
|
||||||
|
*/
|
||||||
|
void *Sys_GetGameAPI (void *parms)
|
||||||
|
{
|
||||||
|
void *(*GetGameAPI) (void *);
|
||||||
|
|
||||||
|
char name[MAX_OSPATH];
|
||||||
|
char curpath[MAX_OSPATH];
|
||||||
|
char *path;
|
||||||
|
|
||||||
|
// Knightmare- changed game library name for better cohabitation
|
||||||
|
#ifdef __i386__
|
||||||
|
const char *gamename = "kmq2gamei386.so";
|
||||||
|
#elif defined __alpha__
|
||||||
|
const char *gamename = "kmq2gameaxp.so";
|
||||||
|
#elif defined __x86_64__
|
||||||
|
const char *gamename = "kmq2gamex86_64.so";
|
||||||
|
#elif defined __powerpc__
|
||||||
|
const char *gamename = "kmq2gameppc.so";
|
||||||
|
#elif defined __sparc__
|
||||||
|
const char *gamename = "kmq2gamesparc.so";
|
||||||
|
#else
|
||||||
|
#error Unknown arch
|
||||||
|
#endif
|
||||||
|
|
||||||
|
setreuid(getuid(), getuid());
|
||||||
|
setegid(getgid());
|
||||||
|
|
||||||
|
if (game_library)
|
||||||
|
Com_Error (ERR_FATAL, "Sys_GetGameAPI without Sys_UnloadingGame");
|
||||||
|
|
||||||
|
getcwd(curpath, sizeof(curpath));
|
||||||
|
|
||||||
|
Com_Printf("------- Loading %s -------\n", gamename);
|
||||||
|
|
||||||
|
// now run through the search paths
|
||||||
|
path = NULL;
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
// path = FS_NextPath (path);
|
||||||
|
path = FS_NextGamePath (path);
|
||||||
|
if (!path)
|
||||||
|
return NULL; // couldn't find one anywhere
|
||||||
|
Com_sprintf (name, sizeof(name), "%s/%s/%s", curpath, path, gamename);
|
||||||
|
game_library = dlopen (name, RTLD_LAZY );
|
||||||
|
if (game_library)
|
||||||
|
{
|
||||||
|
Com_Printf ("LoadLibrary (%s)\n",name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GetGameAPI = (void *)dlsym (game_library, "GetGameAPI");
|
||||||
|
if (!GetGameAPI)
|
||||||
|
{
|
||||||
|
Sys_UnloadGame ();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return GetGameAPI (parms);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void Sys_AppActivate (void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void HandleEvents(void);
|
||||||
|
void Sys_SendKeyEvents (void)
|
||||||
|
{
|
||||||
|
#ifndef DEDICATED_ONLY
|
||||||
|
HandleEvents();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// grab frame time
|
||||||
|
sys_frame_time = Sys_Milliseconds();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
// Knightmare- adapted from DK 1.3 Linux port
|
||||||
|
const char* Sys_ExeDir(void)
|
||||||
|
{
|
||||||
|
return exe_dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* Sys_PrefDir(void)
|
||||||
|
{
|
||||||
|
return pref_dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* Sys_DownloadDir(void)
|
||||||
|
{
|
||||||
|
return download_dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Init_ExeDir (const char* argv0)
|
||||||
|
{
|
||||||
|
#if 1
|
||||||
|
memset(exe_dir, 0, sizeof(exe_dir));
|
||||||
|
Q_snprintfz(exe_dir, sizeof(exe_dir), ".");
|
||||||
|
#else
|
||||||
|
char buf[MAX_OSPATH] = {0};
|
||||||
|
const char *lastSlash;
|
||||||
|
static int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
|
||||||
|
size_t buflen;
|
||||||
|
size_t len = lastSlash ? (lastSlash - buf) : 0;
|
||||||
|
|
||||||
|
memset(exe_dir, 0, sizeof(exe_dir));
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
readlink("/proc/self/exe", buf, MAX_OSPATH-1);
|
||||||
|
#elif __FreeBSD__
|
||||||
|
sysctl(mib, sizeof(mib)/sizeof(*mib), buf, &buflen, NULL, 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!*buf)
|
||||||
|
{
|
||||||
|
printf("WARNING: Couldn't get path to executable, reading from argv[0]!\n");
|
||||||
|
|
||||||
|
if (strlen(argv0) < sizeof(buf))
|
||||||
|
{
|
||||||
|
Q_strncpyz(buf, sizeof(buf), argv0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buf[0] = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// starting at the last slash the executable name begins - we only want the path up to there
|
||||||
|
lastSlash = strrchr(buf, '/');
|
||||||
|
len = lastSlash ? (lastSlash - buf) : 0;
|
||||||
|
if (lastSlash == NULL || len >= sizeof(exe_dir) || len == 0)
|
||||||
|
{
|
||||||
|
printf("WARNING: Couldn't get path to executable! Defaulting to \".\"!\n");
|
||||||
|
Q_snprintfz(exe_dir, sizeof(exe_dir), ".");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
memcpy(exe_dir, buf, len);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Sys_InitPrefDir (void)
|
||||||
|
{
|
||||||
|
char *pp = getenv("XDG_DATA_HOME");
|
||||||
|
|
||||||
|
memset(pref_dir, 0, sizeof(pref_dir));
|
||||||
|
|
||||||
|
if (pp == NULL)
|
||||||
|
{
|
||||||
|
Q_snprintfz(pref_dir, sizeof(pref_dir), "%s/.local/share/Daikatana", getenv("HOME"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen(pp) >= sizeof(pref_dir) - 1)
|
||||||
|
{
|
||||||
|
printf("WARNING: $XDG_DATA_HOME contains a too long path, defaulting to installation dir!\n");
|
||||||
|
Q_strncpyz(pref_dir, sizeof(pref_dir), exe_dir);
|
||||||
|
Q_strncpyz (download_dir, sizeof(download_dir), exe_dir);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_strncpyz (pref_dir, sizeof(pref_dir), pp);
|
||||||
|
Q_strncpyz (download_dir, sizeof(download_dir), pp);
|
||||||
|
}
|
||||||
|
// end Knightmare
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
int main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
int time, oldtime, newtime;
|
||||||
|
|
||||||
|
// go back to real user for config loads
|
||||||
|
saved_euid = geteuid();
|
||||||
|
seteuid(getuid());
|
||||||
|
|
||||||
|
printf ("\n");
|
||||||
|
printf ("========= Initialization =================\n");
|
||||||
|
printf ("KMQuake2 -- Version %4.2f\n", VERSION);
|
||||||
|
printf ("Linux Port by QuDos\n");
|
||||||
|
printf ("http://qudos.quakedev.com/\n");
|
||||||
|
printf ("Compiled: "__DATE__" -- "__TIME__"\n");
|
||||||
|
printf ("==========================================\n\n");
|
||||||
|
|
||||||
|
// Knightmare- init exe/pref dirs
|
||||||
|
Init_ExeDir(argv[0]);
|
||||||
|
Sys_InitPrefDir();
|
||||||
|
|
||||||
|
Qcommon_Init(argc, argv);
|
||||||
|
|
||||||
|
fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
|
||||||
|
|
||||||
|
nostdout = Cvar_Get("nostdout", "0", 0);
|
||||||
|
if (!nostdout->value) {
|
||||||
|
fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
|
||||||
|
// printf ("Linux Quake II -- Version %0.3f\n", KMQUAKE2_VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
oldtime = Sys_Milliseconds ();
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
// find time spent rendering last frame
|
||||||
|
do {
|
||||||
|
newtime = Sys_Milliseconds ();
|
||||||
|
time = newtime - oldtime;
|
||||||
|
} while (time < 1);
|
||||||
|
Qcommon_Frame (time);
|
||||||
|
oldtime = newtime;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
325
unix/old/vid_so.c
Normal file
325
unix/old/vid_so.c
Normal file
|
@ -0,0 +1,325 @@
|
||||||
|
/*
|
||||||
|
===========================================================================
|
||||||
|
Copyright (C) 1997-2001 Id Software, Inc.
|
||||||
|
|
||||||
|
This file is part of Quake 2 source code.
|
||||||
|
|
||||||
|
Quake 2 source code is free software; you can redistribute it
|
||||||
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
|
or (at your option) any later version.
|
||||||
|
|
||||||
|
Quake 2 source code is distributed in the hope that it will be
|
||||||
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Quake 2 source code; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
===========================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Main windowed and fullscreen graphics interface module. This module
|
||||||
|
// is used for both the software and OpenGL rendering versions of the
|
||||||
|
// Quake refresh engine.
|
||||||
|
|
||||||
|
#include <dlfcn.h> // ELF dl loader
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include "../client/client.h"
|
||||||
|
|
||||||
|
// Console variables that we need to access from this module
|
||||||
|
cvar_t *vid_gamma;
|
||||||
|
cvar_t *vid_ref; // Name of Refresh DLL loaded
|
||||||
|
cvar_t *vid_xpos; // X coordinate of window position
|
||||||
|
cvar_t *vid_ypos; // Y coordinate of window position
|
||||||
|
cvar_t *vid_fullscreen;
|
||||||
|
cvar_t *r_customwidth;
|
||||||
|
cvar_t *r_customheight;
|
||||||
|
|
||||||
|
// Global variables used internally by this module
|
||||||
|
viddef_t viddef; // global video state; used by other modules
|
||||||
|
qboolean kmgl_active = 0;
|
||||||
|
|
||||||
|
#define VID_NUM_MODES ( sizeof( vid_modes ) / sizeof( vid_modes[0] ) )
|
||||||
|
|
||||||
|
cvar_t *scanforcd; // Knightmare- just here to enable command line option
|
||||||
|
|
||||||
|
extern void VID_MenuShutdown (void);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
==========================================================================
|
||||||
|
|
||||||
|
DLL GLUE
|
||||||
|
|
||||||
|
==========================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define MAXPRINTMSG 16384 // was 4096
|
||||||
|
void VID_Printf (int print_level, char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list argptr;
|
||||||
|
char msg[MAXPRINTMSG];
|
||||||
|
// static qboolean inupdate;
|
||||||
|
|
||||||
|
va_start (argptr, fmt);
|
||||||
|
Q_vsnprintf (msg, sizeof(msg), fmt, argptr);
|
||||||
|
va_end (argptr);
|
||||||
|
|
||||||
|
if (print_level == PRINT_ALL)
|
||||||
|
Com_Printf ("%s", msg);
|
||||||
|
else
|
||||||
|
Com_DPrintf ("%s", msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VID_Error (int err_level, char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list argptr;
|
||||||
|
char msg[MAXPRINTMSG];
|
||||||
|
// static qboolean inupdate;
|
||||||
|
|
||||||
|
va_start (argptr, fmt);
|
||||||
|
Q_vsnprintf (msg, sizeof(msg), fmt, argptr);
|
||||||
|
va_end (argptr);
|
||||||
|
|
||||||
|
Com_Error (err_level,"%s", msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
/*
|
||||||
|
============
|
||||||
|
VID_Restart_f
|
||||||
|
|
||||||
|
Console command to re-start the video mode and refresh DLL. We do this
|
||||||
|
simply by setting the modified flag for the vid_ref variable, which will
|
||||||
|
cause the entire video mode and refresh DLL to be reset on the next frame.
|
||||||
|
============
|
||||||
|
*/
|
||||||
|
void VID_Restart_f (void)
|
||||||
|
{
|
||||||
|
vid_ref->modified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** VID_GetModeInfo
|
||||||
|
*/
|
||||||
|
typedef struct vidmode_s
|
||||||
|
{
|
||||||
|
const char *description;
|
||||||
|
int width, height;
|
||||||
|
int mode;
|
||||||
|
} vidmode_t;
|
||||||
|
|
||||||
|
vidmode_t vid_modes[] =
|
||||||
|
{
|
||||||
|
#include "../qcommon/vid_modes.h"
|
||||||
|
};
|
||||||
|
|
||||||
|
qboolean VID_GetModeInfo( int *width, int *height, int mode )
|
||||||
|
{
|
||||||
|
if (mode == -1) // custom mode
|
||||||
|
{
|
||||||
|
*width = r_customwidth->value;
|
||||||
|
*height = r_customheight->value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( mode < 0 || mode >= VID_NUM_MODES )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
*width = vid_modes[mode].width;
|
||||||
|
*height = vid_modes[mode].height;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** VID_NewWindow
|
||||||
|
*/
|
||||||
|
void VID_NewWindow ( int width, int height)
|
||||||
|
{
|
||||||
|
viddef.width = width;
|
||||||
|
viddef.height = height;
|
||||||
|
cl.force_refdef = true; // can't use a paused refdef
|
||||||
|
}
|
||||||
|
|
||||||
|
void VID_FreeReflib (void)
|
||||||
|
{
|
||||||
|
kmgl_active = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern decalpolys_t *active_decals;
|
||||||
|
static qboolean reclip_decals = false;
|
||||||
|
qboolean vid_reloading; // Knightmare- flag to not unnecessarily drop console
|
||||||
|
|
||||||
|
/*
|
||||||
|
==============
|
||||||
|
UpdateVideoRef
|
||||||
|
==============
|
||||||
|
*/
|
||||||
|
void UpdateVideoRef (void)
|
||||||
|
{
|
||||||
|
char reason[128];
|
||||||
|
|
||||||
|
if ( vid_ref->modified )
|
||||||
|
{
|
||||||
|
cl.force_refdef = true; // can't use a paused refdef
|
||||||
|
S_StopAllSounds();
|
||||||
|
|
||||||
|
// unclip decals
|
||||||
|
if (active_decals) {
|
||||||
|
CL_UnclipDecals();
|
||||||
|
reclip_decals = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vid_reloading = false;
|
||||||
|
|
||||||
|
while (vid_ref->modified)
|
||||||
|
{ // refresh has changed
|
||||||
|
vid_ref->modified = false;
|
||||||
|
vid_fullscreen->modified = true;
|
||||||
|
cl.refresh_prepped = false;
|
||||||
|
if (cl.cinematictime > 0) // Knightmare added
|
||||||
|
cls.disable_screen = false;
|
||||||
|
else
|
||||||
|
cls.disable_screen = true;
|
||||||
|
vid_reloading = true;
|
||||||
|
// end Knightmare
|
||||||
|
|
||||||
|
//==========================
|
||||||
|
// compacted code from VID_LoadRefresh
|
||||||
|
//==========================
|
||||||
|
if ( kmgl_active )
|
||||||
|
{
|
||||||
|
R_Shutdown();
|
||||||
|
VID_FreeReflib ();
|
||||||
|
}
|
||||||
|
|
||||||
|
Com_Printf( "\n--------- Renderer Initialization ---------\n");
|
||||||
|
|
||||||
|
if ( !R_Init( 0, 0, reason ) == -1 )
|
||||||
|
{
|
||||||
|
R_Shutdown();
|
||||||
|
VID_FreeReflib ();
|
||||||
|
Com_Error (ERR_FATAL, "Couldn't initialize OpenGL renderer!\n%s", reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
Com_Printf( "------------------------------------\n");
|
||||||
|
|
||||||
|
#ifdef CLIENT_SPLIT_NETFRAME
|
||||||
|
// auto-set r_maxfps based on r_displayrefresh
|
||||||
|
CL_SetFramerateCap ();
|
||||||
|
#endif // CLIENT_SPLIT_NETFRAME
|
||||||
|
|
||||||
|
kmgl_active = true;
|
||||||
|
//==========================
|
||||||
|
}
|
||||||
|
/* prefer to fall back on X if active */
|
||||||
|
//if (getenv("DISPLAY"))
|
||||||
|
Cvar_Set( "vid_ref", "glx" ); // was "kmglx"
|
||||||
|
/*else
|
||||||
|
Cvar_Set( "vid_ref", "kmsdlgl" );*/
|
||||||
|
|
||||||
|
// added to close loading screen
|
||||||
|
// if (cl.refresh_prepped && vid_reloading)
|
||||||
|
// cls.disable_screen = false;
|
||||||
|
|
||||||
|
// re-clip decals
|
||||||
|
if (cl.refresh_prepped && reclip_decals) {
|
||||||
|
CL_ReclipDecals();
|
||||||
|
reclip_decals = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
vid_reloading = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
============
|
||||||
|
VID_CheckChanges
|
||||||
|
|
||||||
|
This function gets called once just before drawing each frame, and it's sole purpose in life
|
||||||
|
is to check to see if any of the video mode parameters have changed, and if they have to
|
||||||
|
update the rendering DLL and/or video mode to match.
|
||||||
|
============
|
||||||
|
*/
|
||||||
|
void VID_CheckChanges (void)
|
||||||
|
{
|
||||||
|
|
||||||
|
//update changed vid_ref
|
||||||
|
UpdateVideoRef ();
|
||||||
|
|
||||||
|
// update our window position
|
||||||
|
if ( vid_xpos->modified || vid_ypos->modified )
|
||||||
|
{
|
||||||
|
if (!vid_fullscreen->value)
|
||||||
|
vid_fullscreen->modified = false;
|
||||||
|
|
||||||
|
vid_xpos->modified = false;
|
||||||
|
vid_ypos->modified = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
============
|
||||||
|
VID_Init
|
||||||
|
============
|
||||||
|
*/
|
||||||
|
void VID_Init (void)
|
||||||
|
{
|
||||||
|
/* Create the video variables so we know how to start the graphics drivers */
|
||||||
|
// if DISPLAY is defined, try X
|
||||||
|
//if (getenv("DISPLAY"))
|
||||||
|
vid_ref = Cvar_Get ("vid_ref", "glx", CVAR_ARCHIVE); // was "kmglx"
|
||||||
|
/*else
|
||||||
|
vid_ref = Cvar_Get ("vid_ref", "kmsdlgl", CVAR_ARCHIVE);*/
|
||||||
|
Cvar_SetDescription ("vid_ref", "Video renderer module in use. This is always set to \"gl\" in KMQuake2.");
|
||||||
|
|
||||||
|
vid_xpos = Cvar_Get ("vid_xpos", "3", CVAR_ARCHIVE);
|
||||||
|
Cvar_SetDescription ("vid_xpos", "Sets horizontal desktop position of window in windowed mode.");
|
||||||
|
vid_ypos = Cvar_Get ("vid_ypos", "22", CVAR_ARCHIVE);
|
||||||
|
Cvar_SetDescription ("vid_ypos", "Sets vertical desktop position of window in windowed mode.");
|
||||||
|
vid_fullscreen = Cvar_Get ("vid_fullscreen", "0", CVAR_ARCHIVE);
|
||||||
|
// Cvar_SetDescription ("vid_fullscreen", "Enables fullscreen video mode.");
|
||||||
|
Cvar_SetDescription ("vid_fullscreen", "Sets fullscreen or borderless video mode. 0 = windowed, 1 = fullscreen, 2 = borderless"); // borderless support
|
||||||
|
vid_gamma = Cvar_Get( "vid_gamma", "0.8", CVAR_ARCHIVE );
|
||||||
|
Cvar_SetDescription ("vid_gamma", "Screen brightness value. Uses inverse scale.");
|
||||||
|
r_customwidth = Cvar_Get( "r_customwidth", "1600", CVAR_ARCHIVE );
|
||||||
|
Cvar_SetDescription ("r_customwidth", "Sets resolution width when using custom video mode (-1).");
|
||||||
|
r_customheight = Cvar_Get( "r_customheight", "1024", CVAR_ARCHIVE );
|
||||||
|
Cvar_SetDescription ("r_customheight", "Sets resolution height when using custom video mode (-1).");
|
||||||
|
// Knightmare- just here to enable command line option without error
|
||||||
|
scanforcd = Cvar_Get( "scanforcd", "0", 0 );
|
||||||
|
|
||||||
|
// force vid_ref to gl
|
||||||
|
// older versions of Lazarus code check only vid_ref=gl for fadein effects
|
||||||
|
Cvar_Set( "vid_ref", "glx" ); // was "kmglx"
|
||||||
|
vidref_val = VIDREF_GL; // this is always in GL mode
|
||||||
|
|
||||||
|
/* Add some console commands that we want to handle */
|
||||||
|
Cmd_AddCommand ("vid_restart", VID_Restart_f);
|
||||||
|
|
||||||
|
/* Start the graphics mode and load refresh DLL */
|
||||||
|
VID_CheckChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
============
|
||||||
|
VID_Shutdown
|
||||||
|
============
|
||||||
|
*/
|
||||||
|
void VID_Shutdown (void)
|
||||||
|
{
|
||||||
|
if ( kmgl_active )
|
||||||
|
{
|
||||||
|
R_Shutdown ();
|
||||||
|
VID_FreeReflib ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -32,12 +32,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include "../renderer/r_local.h"
|
#include "../renderer/r_local.h"
|
||||||
|
|
||||||
|
#include <SDL.h>
|
||||||
#include "glw_unix.h"
|
#include "glw_unix.h"
|
||||||
|
|
||||||
#include <GL/glx.h>
|
|
||||||
|
|
||||||
#include <dlfcn.h>
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
//FX Mesa Functions
|
//FX Mesa Functions
|
||||||
|
@ -49,14 +47,6 @@ fxMesaContext (*qfxMesaGetCurrentContext)(void);
|
||||||
void (*qfxMesaSwapBuffers)(void);
|
void (*qfxMesaSwapBuffers)(void);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//GLX Functions
|
|
||||||
XVisualInfo * (*qglXChooseVisual)( Display *dpy, int screen, int *attribList );
|
|
||||||
GLXContext (*qglXCreateContext)( Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct );
|
|
||||||
void (*qglXDestroyContext)( Display *dpy, GLXContext ctx );
|
|
||||||
Bool (*qglXMakeCurrent)( Display *dpy, GLXDrawable drawable, GLXContext ctx);
|
|
||||||
void (*qglXCopyContext)( Display *dpy, GLXContext src, GLXContext dst, GLuint mask );
|
|
||||||
void (*qglXSwapBuffers)( Display *dpy, GLXDrawable drawable );
|
|
||||||
|
|
||||||
void ( APIENTRY * qglAccum )(GLenum op, GLfloat value);
|
void ( APIENTRY * qglAccum )(GLenum op, GLfloat value);
|
||||||
void ( APIENTRY * qglAlphaFunc )(GLenum func, GLclampf ref);
|
void ( APIENTRY * qglAlphaFunc )(GLenum func, GLclampf ref);
|
||||||
GLboolean ( APIENTRY * qglAreTexturesResident )(GLsizei n, const GLuint *textures, GLboolean *residences);
|
GLboolean ( APIENTRY * qglAreTexturesResident )(GLsizei n, const GLuint *textures, GLboolean *residences);
|
||||||
|
@ -407,6 +397,7 @@ void ( APIENTRY * qglColorTableEXT)( GLenum, GLenum, GLsizei, GLenum, GLenum, co
|
||||||
void ( APIENTRY * qgl3DfxSetPaletteEXT)( GLuint * );
|
void ( APIENTRY * qgl3DfxSetPaletteEXT)( GLuint * );
|
||||||
void ( APIENTRY * qglSelectTextureSGIS)( GLenum );
|
void ( APIENTRY * qglSelectTextureSGIS)( GLenum );
|
||||||
void ( APIENTRY * qglMTexCoord2fSGIS)( GLenum, GLfloat, GLfloat );
|
void ( APIENTRY * qglMTexCoord2fSGIS)( GLenum, GLfloat, GLfloat );
|
||||||
|
void ( APIENTRY * qglMultiTexCoord2fARB)(GLenum, GLfloat, GLfloat);
|
||||||
void ( APIENTRY * qglActiveTextureARB) ( GLenum );
|
void ( APIENTRY * qglActiveTextureARB) ( GLenum );
|
||||||
void ( APIENTRY * qglClientActiveTextureARB) ( GLenum );
|
void ( APIENTRY * qglClientActiveTextureARB) ( GLenum );
|
||||||
|
|
||||||
|
@ -2680,13 +2671,14 @@ static void APIENTRY logViewport(GLint x, GLint y, GLsizei width, GLsizei height
|
||||||
*/
|
*/
|
||||||
void QGL_Shutdown( void )
|
void QGL_Shutdown( void )
|
||||||
{
|
{
|
||||||
if ( glw_state.OpenGLLib )
|
if ( glw_state.glContext )
|
||||||
{
|
{
|
||||||
dlclose ( glw_state.OpenGLLib );
|
SDL_GL_DeleteContext(glw_state.glContext);
|
||||||
glw_state.OpenGLLib = NULL;
|
SDL_DestroyWindow(glw_state.glWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
glw_state.OpenGLLib = NULL;
|
glw_state.glContext = NULL;
|
||||||
|
glw_state.glWindow = NULL;
|
||||||
|
|
||||||
qglAccum = NULL;
|
qglAccum = NULL;
|
||||||
qglAlphaFunc = NULL;
|
qglAlphaFunc = NULL;
|
||||||
|
@ -3032,19 +3024,13 @@ void QGL_Shutdown( void )
|
||||||
qfxMesaGetCurrentContext = NULL;
|
qfxMesaGetCurrentContext = NULL;
|
||||||
qfxMesaSwapBuffers = NULL;
|
qfxMesaSwapBuffers = NULL;
|
||||||
*/
|
*/
|
||||||
qglXChooseVisual = NULL;
|
|
||||||
qglXCreateContext = NULL;
|
|
||||||
qglXDestroyContext = NULL;
|
|
||||||
qglXMakeCurrent = NULL;
|
|
||||||
qglXCopyContext = NULL;
|
|
||||||
qglXSwapBuffers = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define GPA( a ) dlsym( glw_state.OpenGLLib, a )
|
#define GPA( a ) SDL_GL_GetProcAddress( a )
|
||||||
|
|
||||||
void *qwglGetProcAddress(char *symbol)
|
void *qwglGetProcAddress(char *symbol)
|
||||||
{
|
{
|
||||||
if (glw_state.OpenGLLib)
|
if (glw_state.glContext)
|
||||||
return GPA ( symbol );
|
return GPA ( symbol );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -3074,21 +3060,18 @@ qboolean QGL_Init( const char *dllname )
|
||||||
putenv( envbuffer );
|
putenv( envbuffer );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ( glw_state.OpenGLLib = dlopen( dllname, RTLD_LAZY | RTLD_GLOBAL ) ) == 0 )
|
SDL_Init(SDL_INIT_VIDEO);
|
||||||
{
|
glw_state.glWindow = SDL_CreateWindow(
|
||||||
char fn[MAX_OSPATH];
|
WINDOWNAME,
|
||||||
char *path;
|
SDL_WINDOWPOS_CENTERED,
|
||||||
|
SDL_WINDOWPOS_CENTERED,
|
||||||
|
1280,
|
||||||
|
720,
|
||||||
|
SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN
|
||||||
|
);
|
||||||
|
glw_state.glContext = SDL_GL_CreateContext(glw_state.glWindow);
|
||||||
|
|
||||||
path = Cvar_Get ("basedir", ".", CVAR_NOSET)->string;
|
glConfig.allowCDS = true;
|
||||||
snprintf (fn, MAX_OSPATH, "%s/%s", path, dllname );
|
|
||||||
|
|
||||||
if ( ( glw_state.OpenGLLib = dlopen( fn, RTLD_LAZY ) ) == 0 ) {
|
|
||||||
Com_Printf( PRINT_ALL, "%s\n", dlerror() );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gl_config.allow_cds = true;
|
|
||||||
|
|
||||||
qglAccum = dllAccum = GPA( "glAccum" );
|
qglAccum = dllAccum = GPA( "glAccum" );
|
||||||
qglAlphaFunc = dllAlphaFunc = GPA( "glAlphaFunc" );
|
qglAlphaFunc = dllAlphaFunc = GPA( "glAlphaFunc" );
|
||||||
|
@ -3434,12 +3417,6 @@ qboolean QGL_Init( const char *dllname )
|
||||||
qfxMesaGetCurrentContext = GPA("fxMesaGetCurrentContext");
|
qfxMesaGetCurrentContext = GPA("fxMesaGetCurrentContext");
|
||||||
qfxMesaSwapBuffers = GPA("fxMesaSwapBuffers");
|
qfxMesaSwapBuffers = GPA("fxMesaSwapBuffers");
|
||||||
*/
|
*/
|
||||||
qglXChooseVisual = GPA("glXChooseVisual");
|
|
||||||
qglXCreateContext = GPA("glXCreateContext");
|
|
||||||
qglXDestroyContext = GPA("glXDestroyContext");
|
|
||||||
qglXMakeCurrent = GPA("glXMakeCurrent");
|
|
||||||
qglXCopyContext = GPA("glXCopyContext");
|
|
||||||
qglXSwapBuffers = GPA("glXSwapBuffers");
|
|
||||||
|
|
||||||
qglLockArraysEXT = 0;
|
qglLockArraysEXT = 0;
|
||||||
qglUnlockArraysEXT = 0;
|
qglUnlockArraysEXT = 0;
|
||||||
|
@ -3451,6 +3428,8 @@ qboolean QGL_Init( const char *dllname )
|
||||||
qglMTexCoord2fSGIS = 0;
|
qglMTexCoord2fSGIS = 0;
|
||||||
qglActiveTextureARB = 0;
|
qglActiveTextureARB = 0;
|
||||||
qglClientActiveTextureARB = 0;
|
qglClientActiveTextureARB = 0;
|
||||||
|
qglMultiTexCoord2fARB = 0;
|
||||||
|
|
||||||
|
|
||||||
qglActiveStencilFaceEXT = 0;
|
qglActiveStencilFaceEXT = 0;
|
||||||
|
|
||||||
|
|
124
unix/qsh_unix.c
124
unix/qsh_unix.c
|
@ -20,6 +20,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* For mremap() - must be before sys/mman.h include! */
|
||||||
|
#if defined(__linux__) && !defined(_GNU_SOURCE)
|
||||||
|
#define _GNU_SOURCE
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -40,86 +45,127 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
//===============================================================================
|
//===============================================================================
|
||||||
|
|
||||||
|
// Hunk implementation taken from yquake2
|
||||||
|
|
||||||
byte *membase;
|
byte *membase;
|
||||||
int maxhunksize;
|
size_t maxhunksize;
|
||||||
int curhunksize;
|
size_t curhunksize;
|
||||||
|
|
||||||
void *Hunk_Begin (int maxsize)
|
void *Hunk_Begin (size_t maxsize)
|
||||||
{
|
{
|
||||||
// reserve a huge chunk of memory, but don't commit any yet
|
/* reserve a huge chunk of memory, but don't commit any yet */
|
||||||
maxhunksize = maxsize + sizeof(int);
|
/* plus 32 bytes for cacheline */
|
||||||
|
maxhunksize = maxsize + sizeof(size_t) + 32;
|
||||||
curhunksize = 0;
|
curhunksize = 0;
|
||||||
|
int flags = MAP_PRIVATE | MAP_ANONYMOUS;
|
||||||
|
int prot = PROT_READ | PROT_WRITE;
|
||||||
|
|
||||||
#if (defined __FreeBSD__)
|
#if defined(MAP_ALIGNED_SUPER)
|
||||||
membase = mmap(0, maxhunksize, PROT_READ|PROT_WRITE,
|
const size_t hgpagesize = 1UL<<21;
|
||||||
MAP_PRIVATE|MAP_ANON, -1, 0);
|
size_t page_size = sysconf(_SC_PAGESIZE);
|
||||||
#else
|
|
||||||
membase = mmap(0, maxhunksize, PROT_READ|PROT_WRITE,
|
/* Archs supported has 2MB for super pages size */
|
||||||
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
|
if (maxhunksize >= hgpagesize)
|
||||||
|
{
|
||||||
|
maxhunksize = (maxhunksize & ~(page_size-1)) + page_size;
|
||||||
|
flags |= MAP_ALIGNED_SUPER;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (membase == NULL || membase == (byte *)-1)
|
#if defined(PROT_MAX)
|
||||||
|
/* For now it is FreeBSD exclusif but could possibly be extended
|
||||||
|
to other like DFBSD for example */
|
||||||
|
prot |= PROT_MAX(prot);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
membase = mmap(0, maxhunksize, prot,
|
||||||
|
flags, -1, 0);
|
||||||
|
|
||||||
|
if ((membase == NULL) || (membase == (byte *)-1))
|
||||||
|
{
|
||||||
Sys_Error("unable to virtual allocate %d bytes", maxsize);
|
Sys_Error("unable to virtual allocate %d bytes", maxsize);
|
||||||
|
|
||||||
*((int *)membase) = curhunksize;
|
|
||||||
|
|
||||||
return membase + sizeof(int);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void *Hunk_Alloc (int size)
|
*((size_t *)membase) = curhunksize;
|
||||||
|
|
||||||
|
return membase + sizeof(size_t);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *Hunk_Alloc (size_t size)
|
||||||
{
|
{
|
||||||
byte *buf;
|
byte *buf;
|
||||||
|
|
||||||
// round to cacheline
|
/* round to cacheline */
|
||||||
size = (size + 31) & ~31;
|
size = (size + 31) & ~31;
|
||||||
|
|
||||||
if (curhunksize + size > maxhunksize)
|
if (curhunksize + size > maxhunksize)
|
||||||
|
{
|
||||||
Sys_Error("Hunk_Alloc overflow");
|
Sys_Error("Hunk_Alloc overflow");
|
||||||
buf = membase + sizeof(int) + curhunksize;
|
}
|
||||||
|
|
||||||
|
buf = membase + sizeof(size_t) + curhunksize;
|
||||||
curhunksize += size;
|
curhunksize += size;
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Hunk_End (void)
|
size_t Hunk_End (void)
|
||||||
{
|
{
|
||||||
byte *n;
|
byte *n = NULL;
|
||||||
|
|
||||||
#if defined(__FreeBSD__)
|
#if defined(__linux__)
|
||||||
size_t old_size = maxhunksize;
|
n = (byte *)mremap(membase, maxhunksize, curhunksize + sizeof(size_t), 0);
|
||||||
size_t new_size = curhunksize + sizeof(int);
|
#elif defined(__NetBSD__)
|
||||||
void * unmap_base;
|
n = (byte *)mremap(membase, maxhunksize, NULL, curhunksize + sizeof(size_t), 0);
|
||||||
size_t unmap_len;
|
#else
|
||||||
|
#ifndef round_page
|
||||||
|
size_t page_size = sysconf(_SC_PAGESIZE);
|
||||||
|
#define round_page(x) ((((size_t)(x)) + page_size-1) & ~(page_size-1))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
size_t old_size = round_page(maxhunksize);
|
||||||
|
size_t new_size = round_page(curhunksize + sizeof(size_t));
|
||||||
|
|
||||||
new_size = round_page(new_size);
|
|
||||||
old_size = round_page(old_size);
|
|
||||||
if (new_size > old_size)
|
if (new_size > old_size)
|
||||||
n = 0; /* error */
|
{
|
||||||
|
/* Can never happen. If it happens something's very wrong. */
|
||||||
|
n = 0;
|
||||||
|
}
|
||||||
else if (new_size < old_size)
|
else if (new_size < old_size)
|
||||||
{
|
{
|
||||||
unmap_base = (caddr_t)(membase + new_size);
|
/* Hunk is to big, we need to shrink it. */
|
||||||
unmap_len = old_size - new_size;
|
n = munmap(membase + new_size, old_size - new_size) + membase;
|
||||||
n = munmap(unmap_base, unmap_len) + membase;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* No change necessary. */
|
||||||
|
n = membase;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(__linux__)
|
|
||||||
n = mremap(membase, maxhunksize, curhunksize + sizeof(int), 0);
|
|
||||||
#endif
|
|
||||||
if (n != membase)
|
if (n != membase)
|
||||||
|
{
|
||||||
Sys_Error("Hunk_End: Could not remap virtual block (%d)", errno);
|
Sys_Error("Hunk_End: Could not remap virtual block (%d)", errno);
|
||||||
*((int *)membase) = curhunksize + sizeof(int);
|
}
|
||||||
|
|
||||||
|
*((size_t *)membase) = curhunksize + sizeof(size_t);
|
||||||
|
|
||||||
return curhunksize;
|
return curhunksize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hunk_Free (void *base)
|
void Hunk_Free (void *base)
|
||||||
|
{
|
||||||
|
if (base)
|
||||||
{
|
{
|
||||||
byte *m;
|
byte *m;
|
||||||
|
|
||||||
if (base) {
|
m = ((byte *)base) - sizeof(size_t);
|
||||||
m = ((byte *)base) - sizeof(int);
|
|
||||||
if (munmap(m, *((int *)m)))
|
if (munmap(m, *((size_t *)m)))
|
||||||
|
{
|
||||||
Sys_Error("Hunk_Free: munmap failed (%d)", errno);
|
Sys_Error("Hunk_Free: munmap failed (%d)", errno);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//===============================================================================
|
//===============================================================================
|
||||||
|
|
||||||
|
|
|
@ -39,11 +39,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#ifdef __linux__
|
#include <SDL.h>
|
||||||
#include <mntent.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <dlfcn.h>
|
|
||||||
|
|
||||||
#include "../qcommon/qcommon.h"
|
#include "../qcommon/qcommon.h"
|
||||||
|
|
||||||
|
@ -124,7 +120,7 @@ void Sys_Init(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sys_Error (char *error, ...)
|
void Sys_Error (const char *error, ...)
|
||||||
{
|
{
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
char string[1024];
|
char string[1024];
|
||||||
|
@ -229,7 +225,7 @@ Sys_UnloadGame
|
||||||
void Sys_UnloadGame (void)
|
void Sys_UnloadGame (void)
|
||||||
{
|
{
|
||||||
if (game_library)
|
if (game_library)
|
||||||
dlclose (game_library);
|
SDL_UnloadObject (game_library);
|
||||||
game_library = NULL;
|
game_library = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,7 +277,7 @@ void *Sys_GetGameAPI (void *parms)
|
||||||
if (!path)
|
if (!path)
|
||||||
return NULL; // couldn't find one anywhere
|
return NULL; // couldn't find one anywhere
|
||||||
sprintf (name, "%s/%s/%s", curpath, path, gamename);
|
sprintf (name, "%s/%s/%s", curpath, path, gamename);
|
||||||
game_library = dlopen (name, RTLD_LAZY );
|
game_library = SDL_LoadObject (name);
|
||||||
if (game_library)
|
if (game_library)
|
||||||
{
|
{
|
||||||
Com_Printf ("LoadLibrary (%s)\n",name);
|
Com_Printf ("LoadLibrary (%s)\n",name);
|
||||||
|
@ -289,7 +285,7 @@ void *Sys_GetGameAPI (void *parms)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GetGameAPI = (void *)dlsym (game_library, "GetGameAPI");
|
GetGameAPI = (void *)SDL_LoadFunction (game_library, "GetGameAPI");
|
||||||
if (!GetGameAPI)
|
if (!GetGameAPI)
|
||||||
{
|
{
|
||||||
Sys_UnloadGame ();
|
Sys_UnloadGame ();
|
||||||
|
@ -336,75 +332,40 @@ const char* Sys_DownloadDir(void)
|
||||||
|
|
||||||
static void Init_ExeDir (const char* argv0)
|
static void Init_ExeDir (const char* argv0)
|
||||||
{
|
{
|
||||||
#if 1
|
char *basedir = SDL_GetBasePath();
|
||||||
|
if (basedir == NULL)
|
||||||
|
{
|
||||||
|
/* Oh well. */
|
||||||
memset(exe_dir, 0, sizeof(exe_dir));
|
memset(exe_dir, 0, sizeof(exe_dir));
|
||||||
Q_snprintfz(exe_dir, sizeof(exe_dir), ".");
|
Q_snprintfz(exe_dir, sizeof(exe_dir), ".");
|
||||||
#else
|
return;
|
||||||
char buf[MAX_OSPATH] = {0};
|
|
||||||
const char *lastSlash;
|
|
||||||
static int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
|
|
||||||
size_t buflen;
|
|
||||||
size_t len = lastSlash ? (lastSlash - buf) : 0;
|
|
||||||
|
|
||||||
memset(exe_dir, 0, sizeof(exe_dir));
|
|
||||||
|
|
||||||
#ifdef __linux__
|
|
||||||
readlink("/proc/self/exe", buf, MAX_OSPATH-1);
|
|
||||||
#elif __FreeBSD__
|
|
||||||
sysctl(mib, sizeof(mib)/sizeof(*mib), buf, &buflen, NULL, 0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!*buf)
|
|
||||||
{
|
|
||||||
printf("WARNING: Couldn't get path to executable, reading from argv[0]!\n");
|
|
||||||
|
|
||||||
if (strlen(argv0) < sizeof(buf))
|
|
||||||
{
|
|
||||||
Q_strncpyz(buf, sizeof(buf), argv0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
buf[0] = '\0';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Q_strncpyz(exe_dir, sizeof(exe_dir), basedir);
|
||||||
|
SDL_free(basedir);
|
||||||
|
|
||||||
// starting at the last slash the executable name begins - we only want the path up to there
|
/* Intentionally cut off the final separator */
|
||||||
lastSlash = strrchr(buf, '/');
|
exe_dir[strlen(exe_dir) - 1] = '\0';
|
||||||
len = lastSlash ? (lastSlash - buf) : 0;
|
|
||||||
if (lastSlash == NULL || len >= sizeof(exe_dir) || len == 0)
|
|
||||||
{
|
|
||||||
printf("WARNING: Couldn't get path to executable! Defaulting to \".\"!\n");
|
|
||||||
Q_snprintfz(exe_dir, sizeof(exe_dir), ".");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
memcpy(exe_dir, buf, len);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Sys_InitPrefDir (void)
|
static void Sys_InitPrefDir (void)
|
||||||
{
|
{
|
||||||
char *pp = getenv("XDG_DATA_HOME");
|
char *pp = SDL_GetPrefPath(NULL, SAVENAME);
|
||||||
|
|
||||||
memset(pref_dir, 0, sizeof(pref_dir));
|
if (pp != NULL)
|
||||||
|
|
||||||
if (pp == NULL)
|
|
||||||
{
|
{
|
||||||
Q_snprintfz(pref_dir, sizeof(pref_dir), "%s/.local/share/Daikatana", getenv("HOME"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strlen(pp) >= sizeof(pref_dir) - 1)
|
|
||||||
{
|
|
||||||
printf("WARNING: $XDG_DATA_HOME contains a too long path, defaulting to installation dir!\n");
|
|
||||||
Q_strncpyz(pref_dir, sizeof(pref_dir), exe_dir);
|
|
||||||
Q_strncpyz (download_dir, sizeof(download_dir), exe_dir);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_strncpyz(pref_dir, sizeof(pref_dir), pp);
|
Q_strncpyz(pref_dir, sizeof(pref_dir), pp);
|
||||||
Q_strncpyz(download_dir, sizeof(download_dir), pp);
|
Q_strncpyz(download_dir, sizeof(download_dir), pp);
|
||||||
|
SDL_free(pp);
|
||||||
|
|
||||||
|
/* Intentionally cut off the final separator */
|
||||||
|
pref_dir[strlen(pref_dir) - 1] = '\0';
|
||||||
|
download_dir[strlen(download_dir) - 1] = '\0';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("WARNING: SDL_GetPrefPath failed, defaulting to installation dir!\n");
|
||||||
|
Q_strncpyz(pref_dir, sizeof(pref_dir), exe_dir);
|
||||||
|
Q_strncpyz(download_dir, sizeof(download_dir), exe_dir);
|
||||||
}
|
}
|
||||||
// end Knightmare
|
// end Knightmare
|
||||||
|
|
||||||
|
|
|
@ -24,13 +24,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
// is used for both the software and OpenGL rendering versions of the
|
// is used for both the software and OpenGL rendering versions of the
|
||||||
// Quake refresh engine.
|
// Quake refresh engine.
|
||||||
|
|
||||||
#include <dlfcn.h> // ELF dl loader
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include "../client/client.h"
|
#include "../client/client.h"
|
||||||
|
|
||||||
|
int vidref_val;
|
||||||
|
|
||||||
// Console variables that we need to access from this module
|
// Console variables that we need to access from this module
|
||||||
cvar_t *vid_gamma;
|
cvar_t *vid_gamma;
|
||||||
cvar_t *vid_ref; // Name of Refresh DLL loaded
|
cvar_t *vid_ref; // Name of Refresh DLL loaded
|
||||||
|
|
Loading…
Reference in a new issue