diff --git a/engine/Makefile b/engine/Makefile index a0b82d22..cbd86249 100644 --- a/engine/Makefile +++ b/engine/Makefile @@ -21,6 +21,9 @@ ifeq ($(COMPILE_PLATFORM),mingw32) ifeq ($(COMPILE_ARCH),i386) COMPILE_ARCH=x86 endif + ifeq ($(COMPILE_ARCH),x86_64) + COMPILE_ARCH=x64 + endif endif ifndef BUILD_STANDALONE @@ -54,7 +57,7 @@ ifndef BUILD_DEFINES endif # ioquake3 svn version that this is based on -IOQ3_REVISION = 2116 +IOQ3_REVISION = 2143 ############################################################################# # @@ -283,30 +286,7 @@ ifneq (,$(findstring "$(PLATFORM)", "linux" "gnu_kfreebsd" "kfreebsd-gnu")) BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \ -pipe -DUSE_ICON - CLIENT_CFLAGS = $(SDL_CFLAGS) - SERVER_CFLAGS = - - ifeq ($(USE_OPENAL),1) - CLIENT_CFLAGS += -DUSE_OPENAL - ifeq ($(USE_OPENAL_DLOPEN),1) - CLIENT_CFLAGS += -DUSE_OPENAL_DLOPEN - endif - endif - - ifeq ($(USE_CURL),1) - CLIENT_CFLAGS += -DUSE_CURL - ifeq ($(USE_CURL_DLOPEN),1) - CLIENT_CFLAGS += -DUSE_CURL_DLOPEN - endif - endif - - ifeq ($(USE_CODEC_VORBIS),1) - CLIENT_CFLAGS += -DUSE_CODEC_VORBIS - endif - - ifeq ($(USE_RENDERER_DLOPEN),1) - CLIENT_CFLAGS += -DUSE_RENDERER_DLOPEN - endif + CLIENT_CFLAGS += $(SDL_CFLAGS) OPTIMIZEVM = -O3 -funroll-loops -fomit-frame-pointer OPTIMIZE = $(OPTIMIZEVM) -ffast-math @@ -346,10 +326,6 @@ ifneq (,$(findstring "$(PLATFORM)", "linux" "gnu_kfreebsd" "kfreebsd-gnu")) endif endif - ifneq ($(HAVE_VM_COMPILED),true) - BASE_CFLAGS += -DNO_VM_COMPILED - endif - SHLIBEXT=so SHLIBCFLAGS=-fPIC -fvisibility=hidden SHLIBLDFLAGS=-shared $(LDFLAGS) @@ -357,7 +333,8 @@ ifneq (,$(findstring "$(PLATFORM)", "linux" "gnu_kfreebsd" "kfreebsd-gnu")) THREAD_LIBS=-lpthread LIBS=-ldl -lm - CLIENT_LIBS=$(SDL_LIBS) -lGL + CLIENT_LIBS=$(SDL_LIBS) + RENDERER_LIBS = $(SDL_LIBS) -lGL ifeq ($(USE_OPENAL),1) ifneq ($(USE_OPENAL_DLOPEN),1) @@ -401,11 +378,10 @@ ifeq ($(PLATFORM),darwin) HAVE_VM_COMPILED=true LIBS = -framework Cocoa CLIENT_LIBS= + RENDERER_LIBS= OPTIMIZEVM= BASE_CFLAGS = -Wall -Wimplicit -Wstrict-prototypes - CLIENT_CFLAGS = - SERVER_CFLAGS = ifeq ($(ARCH),ppc) BASE_CFLAGS += -faltivec @@ -418,31 +394,27 @@ ifeq ($(PLATFORM),darwin) OPTIMIZEVM += -march=prescott -mfpmath=sse # x86 vm will crash without -mstackrealign since MMX instructions will be # used no matter what and they corrupt the frame pointer in VM calls - BASE_CFLAGS += -mstackrealign + BASE_CFLAGS += -m32 -mstackrealign + endif + ifeq ($(ARCH),x86_64) + OPTIMIZEVM += -mfpmath=sse endif BASE_CFLAGS += -fno-strict-aliasing -DMACOS_X -fno-common -pipe ifeq ($(USE_OPENAL),1) - BASE_CFLAGS += -DUSE_OPENAL ifneq ($(USE_OPENAL_DLOPEN),1) CLIENT_LIBS += -framework OpenAL - else - CLIENT_CFLAGS += -DUSE_OPENAL_DLOPEN endif endif ifeq ($(USE_CURL),1) - CLIENT_CFLAGS += -DUSE_CURL ifneq ($(USE_CURL_DLOPEN),1) CLIENT_LIBS += -lcurl - else - CLIENT_CFLAGS += -DUSE_CURL_DLOPEN endif endif ifeq ($(USE_CODEC_VORBIS),1) - CLIENT_CFLAGS += -DUSE_CODEC_VORBIS CLIENT_LIBS += -lvorbisfile -lvorbis -logg endif @@ -456,16 +428,13 @@ ifeq ($(PLATFORM),darwin) # the file has been modified by each build. LIBSDLMAIN=$(B)/libSDLmain.a LIBSDLMAINSRC=$(LIBSDIR)/macosx/libSDLmain.a - CLIENT_LIBS += -framework IOKit -framework OpenGL \ + CLIENT_LIBS += -framework IOKit \ $(LIBSDIR)/macosx/libSDL-1.2.0.dylib + RENDERER_LIBS += -framework OpenGL $(LIBSDIR)/macosx/libSDL-1.2.0.dylib OPTIMIZEVM += -falign-loops=16 OPTIMIZE = $(OPTIMIZEVM) -ffast-math - ifneq ($(HAVE_VM_COMPILED),true) - BASE_CFLAGS += -DNO_VM_COMPILED - endif - SHLIBEXT=dylib SHLIBCFLAGS=-fPIC -fno-common SHLIBLDFLAGS=-dynamiclib $(LDFLAGS) @@ -495,8 +464,6 @@ ifeq ($(PLATFORM),mingw32) BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \ -DUSE_ICON - CLIENT_CFLAGS = - SERVER_CFLAGS = # In the absence of wspiapi.h, require Windows XP or later ifeq ($(shell test -e $(CMDIR)/wspiapi.h; echo $$?),1) @@ -504,23 +471,12 @@ ifeq ($(PLATFORM),mingw32) endif ifeq ($(USE_OPENAL),1) - CLIENT_CFLAGS += -DUSE_OPENAL CLIENT_CFLAGS += $(OPENAL_CFLAGS) - ifeq ($(USE_OPENAL_DLOPEN),1) - CLIENT_CFLAGS += -DUSE_OPENAL_DLOPEN - else + ifneq ($(USE_OPENAL_DLOPEN),1) CLIENT_LDFLAGS += $(OPENAL_LDFLAGS) endif endif - - ifeq ($(USE_CODEC_VORBIS),1) - CLIENT_CFLAGS += -DUSE_CODEC_VORBIS - endif - ifeq ($(USE_RENDERER_DLOPEN),1) - CLIENT_CFLAGS += -DUSE_RENDERER_DLOPEN - endif - ifeq ($(ARCH),x64) OPTIMIZEVM = -O3 -fno-omit-frame-pointer \ -falign-loops=2 -funroll-loops -falign-jumps=2 -falign-functions=2 \ @@ -543,18 +499,18 @@ ifeq ($(PLATFORM),mingw32) BINEXT=.exe LIBS= -lws2_32 -lwinmm -lpsapi - CLIENT_LDFLAGS = -mwindows - CLIENT_LIBS = -lgdi32 -lole32 -lopengl32 - + CLIENT_LDFLAGS += -mwindows + CLIENT_LIBS = -lgdi32 -lole32 + RENDERER_LIBS = -lgdi32 -lole32 -lopengl32 + ifeq ($(USE_CURL),1) - CLIENT_CFLAGS += -DUSE_CURL CLIENT_CFLAGS += $(CURL_CFLAGS) ifneq ($(USE_CURL_DLOPEN),1) ifeq ($(USE_LOCAL_HEADERS),1) CLIENT_CFLAGS += -DCURL_STATICLIB ifeq ($(ARCH),x64) - CLIENT_LIBS += $(LIBSDIR)/win64/libcurl.a - else + CLIENT_LIBS += $(LIBSDIR)/win64/libcurl.a + else CLIENT_LIBS += $(LIBSDIR)/win32/libcurl.a endif else @@ -576,18 +532,25 @@ ifeq ($(PLATFORM),mingw32) # libmingw32 must be linked before libSDLmain CLIENT_LIBS += -lmingw32 + RENDERER_LIBS += -lmingw32 + ifeq ($(USE_LOCAL_HEADERS),1) CLIENT_CFLAGS += -I$(SDLHDIR)/include ifeq ($(ARCH), x86) CLIENT_LIBS += $(LIBSDIR)/win32/libSDLmain.a \ $(LIBSDIR)/win32/libSDL.dll.a + RENDERER_LIBS += $(LIBSDIR)/win32/libSDLmain.a \ + $(LIBSDIR)/win32/libSDL.dll.a else CLIENT_LIBS += $(LIBSDIR)/win64/libSDLmain.a \ $(LIBSDIR)/win64/libSDL64.dll.a + RENDERER_LIBS += $(LIBSDIR)/win64/libSDLmain.a \ + $(LIBSDIR)/win64/libSDL64.dll.a endif else CLIENT_CFLAGS += $(SDL_CFLAGS) CLIENT_LIBS += $(SDL_LIBS) + RENDERER_LIBS += $(SDL_LIBS) endif BUILD_CLIENT_SMP = 0 @@ -604,8 +567,7 @@ ifeq ($(PLATFORM),freebsd) BASE_CFLAGS = $(shell env MACHINE_ARCH=$(ARCH) make -f /dev/null -VCFLAGS) \ -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \ -DUSE_ICON -DMAP_ANONYMOUS=MAP_ANON - CLIENT_CFLAGS = $(SDL_CFLAGS) - SERVER_CFLAGS = + CLIENT_CFLAGS += $(SDL_CFLAGS) HAVE_VM_COMPILED = true OPTIMIZEVM = -O3 -funroll-loops -fomit-frame-pointer @@ -621,27 +583,23 @@ ifeq ($(PLATFORM),freebsd) CLIENT_LIBS = - CLIENT_LIBS += $(SDL_LIBS) -lGL + CLIENT_LIBS += $(SDL_LIBS) + RENDERER_LIBS = $(SDL_LIBS) -lGL # optional features/libraries ifeq ($(USE_OPENAL),1) - CLIENT_CFLAGS += -DUSE_OPENAL ifeq ($(USE_OPENAL_DLOPEN),1) - CLIENT_CFLAGS += -DUSE_OPENAL_DLOPEN CLIENT_LIBS += $(THREAD_LIBS) -lopenal endif endif ifeq ($(USE_CURL),1) - CLIENT_CFLAGS += -DUSE_CURL ifeq ($(USE_CURL_DLOPEN),1) - CLIENT_CFLAGS += -DUSE_CURL_DLOPEN CLIENT_LIBS += -lcurl endif endif ifeq ($(USE_CODEC_VORBIS),1) - CLIENT_CFLAGS += -DUSE_CODEC_VORBIS CLIENT_LIBS += -lvorbisfile -lvorbis -logg endif @@ -669,28 +627,13 @@ ifeq ($(PLATFORM),openbsd) BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \ -DUSE_ICON -DMAP_ANONYMOUS=MAP_ANON - CLIENT_CFLAGS = $(SDL_CFLAGS) - SERVER_CFLAGS = - - ifeq ($(USE_OPENAL),1) - CLIENT_CFLAGS += -DUSE_OPENAL - ifeq ($(USE_OPENAL_DLOPEN),1) - CLIENT_CFLAGS += -DUSE_OPENAL_DLOPEN - endif - endif - - ifeq ($(USE_CODEC_VORBIS),1) - CLIENT_CFLAGS += -DUSE_CODEC_VORBIS - endif + CLIENT_CFLAGS += $(SDL_CFLAGS) ifeq ($(USE_CURL),1) - CLIENT_CFLAGS += -DUSE_CURL $(CURL_CFLAGS) + CLIENT_CFLAGS += $(CURL_CFLAGS) USE_CURL_DLOPEN=0 endif - BASE_CFLAGS += -DNO_VM_COMPILED - HAVE_VM_COMPILED=false - SHLIBEXT=so SHLIBNAME=.$(SHLIBEXT) SHLIBCFLAGS=-fPIC @@ -701,7 +644,8 @@ ifeq ($(PLATFORM),openbsd) CLIENT_LIBS = - CLIENT_LIBS += $(SDL_LIBS) -lGL + CLIENT_LIBS += $(SDL_LIBS) + RENDERER_LIBS = $(SDL_LIBS) -lGL ifeq ($(USE_OPENAL),1) ifneq ($(USE_OPENAL_DLOPEN),1) @@ -738,15 +682,12 @@ ifeq ($(PLATFORM),netbsd) THREAD_LIBS=-lpthread BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes - CLIENT_CFLAGS = - SERVER_CFLAGS = - ifneq ($(ARCH),i386) - BASE_CFLAGS += -DNO_VM_COMPILED + ifeq ($(ARCH),i386) + HAVE_VM_COMPILED=true endif BUILD_CLIENT = 0 - BUILD_GAME_QVM = 0 else # ifeq netbsd @@ -762,8 +703,8 @@ ifeq ($(PLATFORM),irix64) MKDIR = mkdir -p BASE_CFLAGS=-Dstricmp=strcasecmp -Xcpluscomm -woff 1185 \ - -I. -I$(ROOT)/usr/include -DNO_VM_COMPILED - CLIENT_CFLAGS = $(SDL_CFLAGS) + -I. -I$(ROOT)/usr/include + CLIENT_CFLAGS += $(SDL_CFLAGS) OPTIMIZE = -O3 SHLIBEXT=so @@ -772,8 +713,9 @@ ifeq ($(PLATFORM),irix64) LIBS=-ldl -lm -lgen # FIXME: The X libraries probably aren't necessary? - CLIENT_LIBS=-L/usr/X11/$(LIB) $(SDL_LIBS) -lGL \ + CLIENT_LIBS=-L/usr/X11/$(LIB) $(SDL_LIBS) \ -lX11 -lXext -lm + RENDERER_LIBS = $(SDL_LIBS) -lGL else # ifeq IRIX @@ -802,8 +744,7 @@ ifeq ($(PLATFORM),sunos) BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \ -pipe -DUSE_ICON - CLIENT_CFLAGS = $(SDL_CFLAGS) - SERVER_CFLAGS = + CLIENT_CFLAGS += $(SDL_CFLAGS) OPTIMIZEVM = -O3 -funroll-loops @@ -826,10 +767,6 @@ ifeq ($(PLATFORM),sunos) OPTIMIZE = $(OPTIMIZEVM) -ffast-math - ifneq ($(HAVE_VM_COMPILED),true) - BASE_CFLAGS += -DNO_VM_COMPILED - endif - SHLIBEXT=so SHLIBCFLAGS=-fPIC SHLIBLDFLAGS=-shared $(LDFLAGS) @@ -839,14 +776,15 @@ ifeq ($(PLATFORM),sunos) BOTCFLAGS=-O0 - CLIENT_LIBS +=$(SDL_LIBS) -lGL -lX11 -lXext -liconv -lm + CLIENT_LIBS +=$(SDL_LIBS) -lX11 -lXext -liconv -lm + RENDERER_LIBS = $(SDL_LIBS) -lGL else # ifeq sunos ############################################################################# # SETUP AND BUILD -- GENERIC ############################################################################# - BASE_CFLAGS=-DNO_VM_COMPILED + BASE_CFLAGS= OPTIMIZE = -O3 SHLIBEXT=so @@ -862,6 +800,11 @@ endif #NetBSD endif #IRIX endif #SunOS +ifneq ($(HAVE_VM_COMPILED),true) + BASE_CFLAGS += -DNO_VM_COMPILED + BUILD_GAME_QVM=0 +endif + TARGETS = ifndef FULLBINEXT @@ -923,6 +866,28 @@ ifneq ($(BUILD_GAME_QVM),0) endif endif +ifeq ($(USE_OPENAL),1) + CLIENT_CFLAGS += -DUSE_OPENAL + ifeq ($(USE_OPENAL_DLOPEN),1) + CLIENT_CFLAGS += -DUSE_OPENAL_DLOPEN + endif +endif + +ifeq ($(USE_CURL),1) + CLIENT_CFLAGS += -DUSE_CURL + ifeq ($(USE_CURL_DLOPEN),1) + CLIENT_CFLAGS += -DUSE_CURL_DLOPEN + endif +endif + +ifeq ($(USE_CODEC_VORBIS),1) + CLIENT_CFLAGS += -DUSE_CODEC_VORBIS +endif + +ifeq ($(USE_RENDERER_DLOPEN),1) + CLIENT_CFLAGS += -DUSE_RENDERER_DLOPEN +endif + ifeq ($(USE_MUMBLE),1) CLIENT_CFLAGS += -DUSE_MUMBLE endif @@ -948,7 +913,7 @@ ifeq ($(USE_INTERNAL_JPEG),1) BASE_CFLAGS += -DUSE_INTERNAL_JPEG BASE_CFLAGS += -I$(JPDIR) else - CLIENT_LIBS += -ljpeg + RENDERER_LIBS += -ljpeg endif ifdef DEFAULT_BASEDIR @@ -1165,7 +1130,6 @@ makedirs: @if [ ! -d $(BUILD_DIR) ];then $(MKDIR) $(BUILD_DIR);fi @if [ ! -d $(B) ];then $(MKDIR) $(B);fi @if [ ! -d $(B)/client ];then $(MKDIR) $(B)/client;fi - @if [ ! -d $(B)/clientsmp ];then $(MKDIR) $(B)/clientsmp;fi @if [ ! -d $(B)/renderer ];then $(MKDIR) $(B)/renderer;fi @if [ ! -d $(B)/renderersmp ];then $(MKDIR) $(B)/renderersmp;fi @if [ ! -d $(B)/ded ];then $(MKDIR) $(B)/ded;fi diff --git a/engine/README b/engine/README index 4ef1ff78..ded561f7 100644 --- a/engine/README +++ b/engine/README @@ -401,7 +401,7 @@ SDL Keyboard Differences On many international layouts the default console toggle keys are also dead keys, meaning that dropping the console potentially results in - unintentionally initiating the keying of a dead key. Futhermore SDL 1.2's + unintentionally initiating the keying of a dead key. Furthermore SDL 1.2's dead key support is broken by design and Q3 doesn't support non-ASCII text entry, so the chances are you won't get the correct character anyway. @@ -547,7 +547,7 @@ Creating standalone games information appropriate for your project. While a lot of work has been put into ioquake3 that you can benefit from free - of charge, it does not mean that you have no obligations to fulfil. Please be + of charge, it does not mean that you have no obligations to fulfill. Please be aware that as soon as you start distributing your game with an engine based on our sources we expect you to fully comply with the requirements as stated in the GPL. That includes making sources and modifications you made to the @@ -663,7 +663,7 @@ are off by default. --------------------------------------------- Building Official Installers ----- We need help getting automated installers on all the platforms that ioquake3 -supports. We don't neccesarily care about all the installers being identical, +supports. We don't necessarily care about all the installers being identical, but we have some general guidelines: * Please include the id patch pk3s in your installer, which are available @@ -678,7 +678,7 @@ but we have some general guidelines: user in copying the file or tell them how. * It is fine to just install the binaries without requiring id EULA agreement, - providing pak0.pk3 and the patch pk3s are not refered to or included in the + providing pak0.pk3 and the patch pk3s are not referred to or included in the installer. * Please include at least an SDL so/dylib/dll on every platform. diff --git a/engine/code/client/cl_main.c b/engine/code/client/cl_main.c index 7c8c2102..deaa4120 100644 --- a/engine/code/client/cl_main.c +++ b/engine/code/client/cl_main.c @@ -47,7 +47,9 @@ cvar_t *cl_voipShowMeter; cvar_t *cl_voip; #endif +#ifdef USE_RENDERER_DLOPEN cvar_t *cl_renderer; +#endif cvar_t *cl_nodelta; cvar_t *cl_debugMove; @@ -144,7 +146,7 @@ int serverStatusCount; void hA3Dg_ExportRenderGeom (refexport_t *incoming_re); #endif -static int isQuitting = qfalse; +static int noGameRestart = qfalse; extern void SV_BotFrame( int time ); void CL_CheckForResend( void ); @@ -1360,8 +1362,8 @@ static void CL_OldGame(void) { // change back to previous fs_game cls.oldGameSet = qfalse; - Cvar_Set("fs_game", cls.oldGame); - Com_GameRestart(0, qtrue); + Cvar_Set2("fs_game", cls.oldGame, qtrue); + FS_ConditionalRestart(clc.checksumFeed, qfalse); } } @@ -1475,8 +1477,10 @@ void CL_Disconnect( qboolean showMainMenu ) { CL_UpdateGUID( NULL, 0 ); - if(!isQuitting) + if(!noGameRestart) CL_OldGame(); + else + noGameRestart = qfalse; } @@ -1730,6 +1734,7 @@ void CL_Connect_f( void ) { Cvar_Set( "sv_killserver", "1" ); SV_Frame( 0 ); + noGameRestart = qtrue; CL_Disconnect( qtrue ); Con_Close(); @@ -3650,7 +3655,7 @@ void CL_Shutdown(char *finalmsg, qboolean disconnect, qboolean quit) } recursive = qtrue; - isQuitting = quit; + noGameRestart = quit; if(disconnect) CL_Disconnect(qtrue); diff --git a/engine/code/client/cl_parse.c b/engine/code/client/cl_parse.c index da982034..e269be35 100644 --- a/engine/code/client/cl_parse.c +++ b/engine/code/client/cl_parse.c @@ -417,8 +417,14 @@ void CL_SystemInfoChanged( void ) { // If this cvar may not be modified by a server discard the value. if(!(cvar_flags & (CVAR_SYSTEMINFO | CVAR_SERVER_CREATED | CVAR_USER_CREATED))) { - Com_Printf(S_COLOR_YELLOW "WARNING: server is not allowed to set %s=%s\n", key, value); - continue; +#ifndef STANDALONE + if(Q_stricmp(key, "g_synchronousClients") && Q_stricmp(key, "pmove_fixed") && + Q_stricmp(key, "pmove_msec")) +#endif + { + Com_Printf(S_COLOR_YELLOW "WARNING: server is not allowed to set %s=%s\n", key, value); + continue; + } } Cvar_SetSafe(key, value); diff --git a/engine/code/game/bg_pmove.c b/engine/code/game/bg_pmove.c index 3c0a9100..cfbbee01 100644 --- a/engine/code/game/bg_pmove.c +++ b/engine/code/game/bg_pmove.c @@ -2466,7 +2466,7 @@ void PmoveSingle (pmove_t *pmove) { } // set the firing flag for continuous beam weapons - if ( !(pm->ps->pm_flags & PMF_RESPAWNED) && pm->ps->pm_type != PM_INTERMISSION && (!pm->ps->pm_type == PM_NOCLIP) + if ( !(pm->ps->pm_flags & PMF_RESPAWNED) && pm->ps->pm_type != PM_INTERMISSION && pm->ps->pm_type != PM_NOCLIP && ( pm->cmd.buttons & BUTTON_ATTACK ) && pm->ps->ammo[ pm->ps->weapon ] ) { pm->ps->eFlags |= EF_FIRING; } else { diff --git a/engine/code/game/g_weapon.c b/engine/code/game/g_weapon.c index 385ca934..0015f4ab 100644 --- a/engine/code/game/g_weapon.c +++ b/engine/code/game/g_weapon.c @@ -99,9 +99,6 @@ qboolean CheckGauntletAttack( gentity_t *ent ) { else traceEnt = &g_entities[ tr.entityNum ]; - if ( traceEnt->client->noclip ) { - return qfalse; - } // send blood impact if ( traceEnt->takedamage && traceEnt->client ) { tent = G_TempEntity( tr.endpos, EV_MISSILE_HIT ); diff --git a/engine/code/q3_ui/ui_rally_servers.c b/engine/code/q3_ui/ui_rally_servers.c index 6b51d445..cb446891 100644 --- a/engine/code/q3_ui/ui_rally_servers.c +++ b/engine/code/q3_ui/ui_rally_servers.c @@ -433,6 +433,29 @@ static int QDECL ArenaServers_Compare( const void *arg1, const void *arg2 ) { return 0; } +/* +================= +ArenaServers_SourceForLAN + +Convert ui's g_servertype to AS_* used by trap calls. +================= +*/ +int ArenaServers_SourceForLAN(void) { + switch( g_servertype ) { + default: + case UIAS_LOCAL: + return AS_LOCAL; + case UIAS_GLOBAL1: + case UIAS_GLOBAL2: + case UIAS_GLOBAL3: + case UIAS_GLOBAL4: + case UIAS_GLOBAL5: + return AS_GLOBAL; + case UIAS_FAVORITES: + return AS_FAVORITES; + } +} + /* ================= ArenaServers_GametypeForGames @@ -793,7 +816,7 @@ static void ArenaServers_Insert( char* adrstr, char* info, int pingtime ) int i; - if ((pingtime >= ArenaServers_MaxPing()) && (g_servertype != AS_FAVORITES)) + if ((pingtime >= ArenaServers_MaxPing()) && (g_servertype != UIAS_FAVORITES)) { // slow global or local servers do not get entered return; @@ -998,7 +1021,7 @@ static void ArenaServers_StopRefresh( void ) g_arenaservers.refreshservers = qfalse; - if (g_servertype == AS_FAVORITES) + if (g_servertype == UIAS_FAVORITES) { // nonresponsive favorites must be shown ArenaServers_InsertFavorites(); @@ -1036,11 +1059,11 @@ static void ArenaServers_DoRefresh( void ) { if (g_servertype != UIAS_FAVORITES) { if (g_servertype == UIAS_LOCAL) { - if (!trap_LAN_GetServerCount(g_servertype)) { + if (!trap_LAN_GetServerCount(AS_LOCAL)) { return; } } - if (trap_LAN_GetServerCount(g_servertype) < 0) { + if (trap_LAN_GetServerCount(ArenaServers_SourceForLAN()) < 0) { // still waiting for response return; } @@ -1110,10 +1133,10 @@ static void ArenaServers_DoRefresh( void ) // get results of servers query // counts can increase as servers respond - if (g_servertype == AS_FAVORITES) { + if (g_servertype == UIAS_FAVORITES) { g_arenaservers.numqueriedservers = g_arenaservers.numfavoriteaddresses; } else { - g_arenaservers.numqueriedservers = trap_LAN_GetServerCount(g_servertype); + g_arenaservers.numqueriedservers = trap_LAN_GetServerCount(ArenaServers_SourceForLAN()); } // if (g_arenaservers.numqueriedservers > g_arenaservers.maxservers) @@ -1140,10 +1163,10 @@ static void ArenaServers_DoRefresh( void ) // get an address to ping - if (g_servertype == AS_FAVORITES) { + if (g_servertype == UIAS_FAVORITES) { strcpy( adrstr, g_arenaservers.favoriteaddresses[g_arenaservers.currentping] ); } else { - trap_LAN_GetServerAddressString(g_servertype, g_arenaservers.currentping, adrstr, MAX_ADDRESSLENGTH ); + trap_LAN_GetServerAddressString(ArenaServers_SourceForLAN(), g_arenaservers.currentping, adrstr, MAX_ADDRESSLENGTH ); } strcpy( g_arenaservers.pinglist[j].adrstr, adrstr ); @@ -1465,7 +1488,7 @@ static sfxHandle_t ArenaServers_MenuKey( int key ) { } - if( ( key == K_DEL || key == K_KP_DEL ) && ( g_servertype == AS_FAVORITES ) && + if( ( key == K_DEL || key == K_KP_DEL ) && ( g_servertype == UIAS_FAVORITES ) && ( Menu_ItemAtCursor( &g_arenaservers.menu) == &g_arenaservers.list ) ) { ArenaServers_Remove(); ArenaServers_UpdateMenu(); @@ -1490,7 +1513,6 @@ ArenaServers_MenuInit static void ArenaServers_MenuInit( void ) { int i; int y; - int value; static char statusbuffer[MAX_STATUSLENGTH]; static char leaguebuffer[MAX_LEAGUELENGTH]; @@ -1501,7 +1523,7 @@ static void ArenaServers_MenuInit( void ) { g_arenaservers.menu.fullscreen = qtrue; g_arenaservers.menu.wrapAround = qtrue; - g_arenaservers.menu.draw = ArenaServers_MenuDraw; + g_arenaservers.menu.draw = ArenaServers_MenuDraw; g_arenaservers.menu.key = ArenaServers_MenuKey; g_arenaservers.banner.generic.type = MTYPE_BTEXT; @@ -1873,12 +1895,7 @@ static void ArenaServers_MenuInit( void ) { ArenaServers_LoadFavorites(); - g_servertype = Com_Clamp( 0, 3, ui_browserMaster.integer ); - // hack to get rid of MPlayer stuff - value = g_servertype; - if (value >= 1) - value--; - g_arenaservers.master.curvalue = g_servertype; + g_arenaservers.master.curvalue = g_servertype = Com_Clamp( 0, 6, ui_browserMaster.integer ); // STONELANCE // g_gametype = Com_Clamp( 0, 4, ui_browserGameType.integer ); diff --git a/engine/code/qcommon/common.c b/engine/code/qcommon/common.c index 5eebfad7..c2fddcbd 100644 --- a/engine/code/qcommon/common.c +++ b/engine/code/qcommon/common.c @@ -2886,15 +2886,45 @@ Read whatever is in com_pipefile, if anything, and execute it */ void Com_ReadFromPipe( void ) { - char buffer[MAX_STRING_CHARS] = {""}; - qboolean read; + static char buf[MAX_STRING_CHARS]; + static int accu = 0; + int read; if( !pipefile ) return; - read = FS_Read( buffer, sizeof( buffer ), pipefile ); - if( read ) - Cbuf_ExecuteText( EXEC_APPEND, buffer ); + while( ( read = FS_Read( buf + accu, sizeof( buf ) - accu - 1, pipefile ) ) > 0 ) + { + char *brk = NULL; + int i; + + for( i = accu; i < accu + read; ++i ) + { + if( buf[ i ] == '\0' ) + buf[ i ] = '\n'; + if( buf[ i ] == '\n' || buf[ i ] == '\r' ) + brk = &buf[ i + 1 ]; + } + buf[ accu + read ] = '\0'; + + accu += read; + + if( brk ) + { + char tmp = *brk; + *brk = '\0'; + Cbuf_ExecuteText( EXEC_APPEND, buf ); + *brk = tmp; + + accu -= brk - buf; + memmove( buf, brk, accu + 1 ); + } + else if( accu >= sizeof( buf ) - 1 ) // full + { + Cbuf_ExecuteText( EXEC_APPEND, buf ); + accu = 0; + } + } } diff --git a/engine/code/qcommon/cvar.c b/engine/code/qcommon/cvar.c index 68f25070..6a090d68 100644 --- a/engine/code/qcommon/cvar.c +++ b/engine/code/qcommon/cvar.c @@ -629,7 +629,7 @@ void Cvar_SetSafe( const char *var_name, const char *value ) { int flags = Cvar_Flags( var_name ); - if( flags != CVAR_NONEXISTENT && flags & CVAR_PROTECTED ) + if((flags != CVAR_NONEXISTENT) && (flags & CVAR_PROTECTED)) { if( value ) Com_Error( ERR_DROP, "Restricted source tried to set " diff --git a/engine/code/qcommon/files.c b/engine/code/qcommon/files.c index 65000943..bf5236a2 100644 --- a/engine/code/qcommon/files.c +++ b/engine/code/qcommon/files.c @@ -4054,12 +4054,27 @@ restart if necessary */ qboolean FS_ConditionalRestart(int checksumFeed, qboolean disconnect) { + int retval; + if(fs_gamedirvar->modified) { - Com_GameRestart(checksumFeed, disconnect); - return qtrue; + if(FS_FilenameCompare(lastValidGame, fs_gamedirvar->string) && + (*lastValidGame || FS_FilenameCompare(fs_gamedirvar->string, com_basegame->string)) && + (*fs_gamedirvar->string || FS_FilenameCompare(lastValidGame, com_basegame->string))) + { + Com_GameRestart(checksumFeed, disconnect); + return qtrue; + } + else + { + fs_gamedirvar->modified = qfalse; + retval = qtrue; + } } - else if(checksumFeed != fs_checksumFeed) + else + retval = qfalse; + + if(checksumFeed != fs_checksumFeed) FS_Restart(checksumFeed); else if(fs_numServerPaks && !fs_reordered) FS_ReorderPurePaks(); diff --git a/engine/code/qcommon/q_platform.h b/engine/code/qcommon/q_platform.h index c9965035..8bc2984c 100644 --- a/engine/code/qcommon/q_platform.h +++ b/engine/code/qcommon/q_platform.h @@ -98,7 +98,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define PATH_SEP '\\' #if defined( __WIN64__ ) -#define ARCH_STRING "x86_64" +#define ARCH_STRING "x64" #elif defined _M_ALPHA #define ARCH_STRING "AXP" #endif @@ -348,6 +348,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA //endianness +void CopyShortSwap (void *dest, void *src); +void CopyLongSwap (void *dest, void *src); short ShortSwap (short l); int LongSwap (int l); float FloatSwap (const float *f); diff --git a/engine/code/qcommon/q_shared.c b/engine/code/qcommon/q_shared.c index bad6a9a7..594f3d94 100644 --- a/engine/code/qcommon/q_shared.c +++ b/engine/code/qcommon/q_shared.c @@ -896,12 +896,11 @@ int Q_isalpha( int c ) qboolean Q_isanumber( const char *s ) { char *p; - double d; if( *s == '\0' ) return qfalse; - d = strtod( s, &p ); + strtod( s, &p ); return *p == '\0'; } diff --git a/engine/code/qcommon/q_shared.h b/engine/code/qcommon/q_shared.h index 5065ce92..53364919 100644 --- a/engine/code/qcommon/q_shared.h +++ b/engine/code/qcommon/q_shared.h @@ -493,7 +493,9 @@ int Q_isnan(float x); extern int (QDECL *Q_VMftol)(void); extern void (QDECL *Q_SnapVector)(vec3_t vec); #else - #define Q_ftol(f) lrintf((f)) + // Q_ftol must expand to a function name so the pluggable renderer can take + // its address + #define Q_ftol lrintf #define Q_SnapVector(vec)\ do\ {\ diff --git a/engine/code/qcommon/qcommon.h b/engine/code/qcommon/qcommon.h index 7d913612..6203f1d0 100644 --- a/engine/code/qcommon/qcommon.h +++ b/engine/code/qcommon/qcommon.h @@ -1073,7 +1073,7 @@ typedef enum { void Sys_Init (void); // general development dll loading for virtual machine testing -void * QDECL Sys_LoadQVMDll( const char *name, intptr_t (QDECL **entryPoint)(int, ...), +void * QDECL Sys_LoadGameDll( const char *name, intptr_t (QDECL **entryPoint)(int, ...), intptr_t (QDECL *systemcalls)(intptr_t, ...) ); void Sys_UnloadDll( void *dllHandle ); diff --git a/engine/code/qcommon/vm.c b/engine/code/qcommon/vm.c index 6f0548d9..c500aea6 100644 --- a/engine/code/qcommon/vm.c +++ b/engine/code/qcommon/vm.c @@ -579,7 +579,7 @@ vm_t *VM_Create( const char *module, intptr_t (*systemCalls)(intptr_t *), { Com_Printf("Try loading dll file %s\n", filename); - vm->dllHandle = Sys_LoadQVMDll(filename, &vm->entryPoint, VM_DllSyscall); + vm->dllHandle = Sys_LoadGameDll(filename, &vm->entryPoint, VM_DllSyscall); if(vm->dllHandle) { diff --git a/engine/code/qcommon/vm_x86.c b/engine/code/qcommon/vm_x86.c index da472082..a303a335 100644 --- a/engine/code/qcommon/vm_x86.c +++ b/engine/code/qcommon/vm_x86.c @@ -455,7 +455,7 @@ static void DoSyscall(void) opStackBase[opStackOfs + 1] = savedVM->systemCall(args); #else data[0] = ~syscallNum; - opStackBase[opStackOfs + 1] = savedVM->systemCall(data); + opStackBase[opStackOfs + 1] = savedVM->systemCall((intptr_t *) data); #endif } else @@ -1776,25 +1776,25 @@ int VM_CallCompiled(vm_t *vm, int *args) #endif #elif idx64 __asm__ volatile( - "movq %5, %%rax\r\n" - "movq %3, %%r8\r\n" - "movq %4, %%r9\r\n" - "push %%r15\r\n" - "push %%r14\r\n" - "push %%r13\r\n" - "push %%r12\r\n" - "callq *%%rax\r\n" - "pop %%r12\r\n" - "pop %%r13\r\n" - "pop %%r14\r\n" - "pop %%r15\r\n" + "movq %5, %%rax\n" + "movq %3, %%r8\n" + "movq %4, %%r9\n" + "push %%r15\n" + "push %%r14\n" + "push %%r13\n" + "push %%r12\n" + "callq *%%rax\n" + "pop %%r12\n" + "pop %%r13\n" + "pop %%r14\n" + "pop %%r15\n" : "+S" (programStack), "+D" (opStack), "+b" (opStackOfs) : "g" (vm->instructionPointers), "g" (vm->dataBase), "g" (entryPoint) : "cc", "memory", "%rax", "%rcx", "%rdx", "%r8", "%r9", "%r10", "%r11" ); #else __asm__ volatile( - "calll *%3\r\n" + "calll *%3\n" : "+S" (programStack), "+D" (opStack), "+b" (opStackOfs) : "g" (entryPoint) : "cc", "memory", "%eax", "%ecx", "%edx" diff --git a/engine/code/sdl/sdl_input.c b/engine/code/sdl/sdl_input.c index 6d85945a..dad9169a 100644 --- a/engine/code/sdl/sdl_input.c +++ b/engine/code/sdl/sdl_input.c @@ -1050,16 +1050,8 @@ void IN_Init( void ) SDL_EnableKeyRepeat( SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL ); keyRepeatEnabled = qtrue; - if( in_mouse->value ) - { - mouseAvailable = qtrue; - IN_ActivateMouse( ); - } - else - { - IN_DeactivateMouse( ); - mouseAvailable = qfalse; - } + mouseAvailable = ( in_mouse->value != 0 ); + IN_DeactivateMouse( ); appState = SDL_GetAppState( ); Cvar_SetValue( "com_unfocused", !( appState & SDL_APPINPUTFOCUS ) ); diff --git a/engine/code/sys/con_tty.c b/engine/code/sys/con_tty.c index 7f5f6317..6e5e966c 100644 --- a/engine/code/sys/con_tty.c +++ b/engine/code/sys/con_tty.c @@ -88,14 +88,13 @@ send "\b \b" static void CON_Back( void ) { char key; - size_t size; key = '\b'; - size = write(STDOUT_FILENO, &key, 1); + write(STDOUT_FILENO, &key, 1); key = ' '; - size = write(STDOUT_FILENO, &key, 1); + write(STDOUT_FILENO, &key, 1); key = '\b'; - size = write(STDOUT_FILENO, &key, 1); + write(STDOUT_FILENO, &key, 1); } /* @@ -146,13 +145,12 @@ static void CON_Show( void ) ttycon_hide--; if (ttycon_hide == 0) { - size_t size; - size = write(STDOUT_FILENO, "]", 1); + write(STDOUT_FILENO, "]", 1); if (TTY_con.cursor) { for (i=0; itp += 1; if (trp->tp>=trp->lp) @@ -92,9 +92,9 @@ doinclude(Tokenrow *trp) break; } if ( Mflag>1 || (!angled&&Mflag==1) ) { - wlen = write(1,objname,strlen(objname)); - wlen = write(1,iname,strlen(iname)); - wlen = write(1,"\n",1); + write(1,objname,strlen(objname)); + write(1,iname,strlen(iname)); + write(1,"\n",1); } if (fd >= 0) { if (++incdepth > 10) diff --git a/engine/code/tools/lcc/cpp/tokens.c b/engine/code/tools/lcc/cpp/tokens.c index ad9f2f7c..3570896c 100644 --- a/engine/code/tools/lcc/cpp/tokens.c +++ b/engine/code/tools/lcc/cpp/tokens.c @@ -290,7 +290,7 @@ void puttokens(Tokenrow *trp) { Token *tp; - int len, wlen; + int len; uchar *p; if (verbose) @@ -305,15 +305,15 @@ puttokens(Tokenrow *trp) } if (len>OBS/2) { /* handle giant token */ if (wbp > wbuf) - wlen = write(1, wbuf, wbp-wbuf); - wlen = write(1, (char *)p, len); + write(1, wbuf, wbp-wbuf); + write(1, (char *)p, len); wbp = wbuf; } else { memcpy(wbp, p, len); wbp += len; } if (wbp >= &wbuf[OBS]) { - wlen = write(1, wbuf, OBS); + write(1, wbuf, OBS); if (wbp > &wbuf[OBS]) memcpy(wbuf, wbuf+OBS, wbp - &wbuf[OBS]); wbp -= OBS; @@ -327,9 +327,8 @@ puttokens(Tokenrow *trp) void flushout(void) { - int wlen; if (wbp>wbuf) { - wlen = write(1, wbuf, wbp-wbuf); + write(1, wbuf, wbp-wbuf); wbp = wbuf; } } diff --git a/engine/code/tools/lcc/etc/lcc.c b/engine/code/tools/lcc/etc/lcc.c index a1688525..8595f2b0 100644 --- a/engine/code/tools/lcc/etc/lcc.c +++ b/engine/code/tools/lcc/etc/lcc.c @@ -813,10 +813,9 @@ char *strsave(const char *str) { char *stringf(const char *fmt, ...) { char buf[1024]; va_list ap; - int n; va_start(ap, fmt); - n = vsprintf(buf, fmt, ap); + vsprintf(buf, fmt, ap); va_end(ap); return strsave(buf); } diff --git a/engine/code/tools/lcc/src/bytecode.c b/engine/code/tools/lcc/src/bytecode.c index e83429fc..871056a0 100644 --- a/engine/code/tools/lcc/src/bytecode.c +++ b/engine/code/tools/lcc/src/bytecode.c @@ -261,8 +261,7 @@ static void LoadSourceFile( const char *filename ) { length = filelength( f ); sourceFile = malloc( length + 1 ); if ( sourceFile ) { - size_t size; - size = fread( sourceFile, length, 1, f ); + fread( sourceFile, length, 1, f ); sourceFile[length] = 0; } diff --git a/engine/code/ui/ui_main.c b/engine/code/ui/ui_main.c index 26adcc75..a8a4d869 100644 --- a/engine/code/ui/ui_main.c +++ b/engine/code/ui/ui_main.c @@ -54,10 +54,21 @@ static const char *skillLevels[] = { static const int numSkillLevels = ARRAY_LEN( skillLevels ); +#define UIAS_LOCAL 0 +#define UIAS_GLOBAL1 1 +#define UIAS_GLOBAL2 2 +#define UIAS_GLOBAL3 3 +#define UIAS_GLOBAL4 4 +#define UIAS_GLOBAL5 5 +#define UIAS_FAVORITES 6 + static const char *netSources[] = { "Local", - "Mplayer", - "Internet", + "Internet1", + "Internet2", + "Internet3", + "Internet4", + "Internet5", "Favorites" }; static const int numNetSources = ARRAY_LEN( netSources ); @@ -981,6 +992,24 @@ void UI_Load(void) { } +// Convert ui's net source to AS_* used by trap calls. +int UI_SourceForLAN(void) { + switch (ui_netSource.integer) { + default: + case UIAS_LOCAL: + return AS_LOCAL; + case UIAS_GLOBAL1: + case UIAS_GLOBAL2: + case UIAS_GLOBAL3: + case UIAS_GLOBAL4: + case UIAS_GLOBAL5: + return AS_GLOBAL; + case UIAS_FAVORITES: + return AS_FAVORITES; + } +} + + static const char *handicapValues[] = {"None","95","90","85","80","75","70","65","60","55","50","45","40","35","30","25","20","15","10","5",NULL}; #ifndef MISSIONPACK static int numHandicaps = ARRAY_LEN(handicapValues); @@ -1678,7 +1707,7 @@ static int UI_OwnerDrawWidth(int ownerDraw, float scale) { s = va("%i. %s", ownerDraw-UI_REDTEAM1 + 1, text); break; case UI_NETSOURCE: - if (ui_netSource.integer < 0 || ui_netSource.integer > uiInfo.numJoinGameTypes) { + if (ui_netSource.integer < 0 || ui_netSource.integer > numNetSources) { ui_netSource.integer = 0; } s = va("Source: %s", netSources[ui_netSource.integer]); @@ -1826,7 +1855,7 @@ static void UI_DrawServerRefreshDate(rectDef_t *rect, float scale, vec4_t color, lowLight[2] = 0.8 * color[2]; lowLight[3] = 0.8 * color[3]; LerpColor(color,lowLight,newColor,0.5+0.5*sin(uiInfo.uiDC.realTime / PULSE_DIVISOR)); - Text_Paint(rect->x, rect->y, scale, newColor, va("Getting info for %d servers (ESC to cancel)", trap_LAN_GetServerCount(ui_netSource.integer)), 0, 0, textStyle); + Text_Paint(rect->x, rect->y, scale, newColor, va("Getting info for %d servers (ESC to cancel)", trap_LAN_GetServerCount(UI_SourceForLAN())), 0, 0, textStyle); } else { char buff[64]; Q_strncpyz(buff, UI_Cvar_VariableString(va("ui_lastServerRefresh_%i", ui_netSource.integer)), 64); @@ -2162,14 +2191,14 @@ static qboolean UI_OwnerDrawVisible(int flags) { } if (flags & UI_SHOW_FAVORITESERVERS) { // this assumes you only put this type of display flag on something showing in the proper context - if (ui_netSource.integer != AS_FAVORITES) { + if (ui_netSource.integer != UIAS_FAVORITES) { vis = qfalse; } flags &= ~UI_SHOW_FAVORITESERVERS; } if (flags & UI_SHOW_NOTFAVORITESERVERS) { // this assumes you only put this type of display flag on something showing in the proper context - if (ui_netSource.integer == AS_FAVORITES) { + if (ui_netSource.integer == UIAS_FAVORITES) { vis = qfalse; } flags &= ~UI_SHOW_NOTFAVORITESERVERS; @@ -2467,28 +2496,47 @@ static qboolean UI_TeamMember_HandleKey(int flags, float *special, int key, qboo } static qboolean UI_NetSource_HandleKey(int flags, float *special, int key) { - if (key == K_MOUSE1 || key == K_MOUSE2 || key == K_ENTER || key == K_KP_ENTER) { + if (key == K_MOUSE1 || key == K_MOUSE2 || key == K_ENTER || key == K_KP_ENTER) { if (key == K_MOUSE2) { ui_netSource.integer--; } else { ui_netSource.integer++; } - + + if(ui_netSource.integer >= UIAS_GLOBAL1 && ui_netSource.integer <= UIAS_GLOBAL5) + { + char masterstr[2], cvarname[sizeof("sv_master1")]; + + while(ui_netSource.integer >= UIAS_GLOBAL1 && ui_netSource.integer <= UIAS_GLOBAL5) + { + Com_sprintf(cvarname, sizeof(cvarname), "sv_master%d", ui_netSource.integer); + trap_Cvar_VariableStringBuffer(cvarname, masterstr, sizeof(masterstr)); + if(*masterstr) + break; + + if (key == K_MOUSE2) { + ui_netSource.integer--; + } else { + ui_netSource.integer++; + } + } + } + if (ui_netSource.integer >= numNetSources) { - ui_netSource.integer = 0; - } else if (ui_netSource.integer < 0) { - ui_netSource.integer = numNetSources - 1; + ui_netSource.integer = 0; + } else if (ui_netSource.integer < 0) { + ui_netSource.integer = numNetSources - 1; } UI_BuildServerDisplayList(qtrue); - if (ui_netSource.integer != AS_GLOBAL) { + if (!(ui_netSource.integer >= UIAS_GLOBAL1 && ui_netSource.integer <= UIAS_GLOBAL5)) { UI_StartServerRefresh(qtrue); } - trap_Cvar_Set( "ui_netSource", va("%d", ui_netSource.integer)); - return qtrue; - } - return qfalse; + trap_Cvar_Set( "ui_netSource", va("%d", ui_netSource.integer)); + return qtrue; + } + return qfalse; } static qboolean UI_NetFilter_HandleKey(int flags, float *special, int key) { @@ -2717,7 +2765,7 @@ UI_ServersQsortCompare ================= */ static int QDECL UI_ServersQsortCompare( const void *arg1, const void *arg2 ) { - return trap_LAN_CompareServers( ui_netSource.integer, uiInfo.serverStatus.sortKey, uiInfo.serverStatus.sortDir, *(int*)arg1, *(int*)arg2); + return trap_LAN_CompareServers( UI_SourceForLAN(), uiInfo.serverStatus.sortKey, uiInfo.serverStatus.sortDir, *(int*)arg1, *(int*)arg2); } @@ -3312,13 +3360,13 @@ static void UI_RunMenuScript(char **args) { uiInfo.nextServerStatusRefresh = 0; uiInfo.nextFindPlayerRefresh = 0; } else if (Q_stricmp(name, "UpdateFilter") == 0) { - if (ui_netSource.integer == AS_LOCAL) { + if (ui_netSource.integer == UIAS_LOCAL) { UI_StartServerRefresh(qtrue); } UI_BuildServerDisplayList(qtrue); UI_FeederSelection(FEEDER_SERVERS, 0); } else if (Q_stricmp(name, "ServerStatus") == 0) { - trap_LAN_GetServerAddressString(ui_netSource.integer, uiInfo.serverStatus.displayServers[uiInfo.serverStatus.currentServer], uiInfo.serverStatusAddress, sizeof(uiInfo.serverStatusAddress)); + trap_LAN_GetServerAddressString(UI_SourceForLAN(), uiInfo.serverStatus.displayServers[uiInfo.serverStatus.currentServer], uiInfo.serverStatusAddress, sizeof(uiInfo.serverStatusAddress)); UI_BuildServerStatus(qtrue); } else if (Q_stricmp(name, "FoundPlayerServerStatus") == 0) { Q_strncpyz(uiInfo.serverStatusAddress, uiInfo.foundPlayerServerAddresses[uiInfo.currentFoundPlayerServer], sizeof(uiInfo.serverStatusAddress)); @@ -3334,7 +3382,7 @@ static void UI_RunMenuScript(char **args) { trap_Cvar_Set("cg_cameraOrbit", "0"); trap_Cvar_Set("ui_singlePlayerActive", "0"); if (uiInfo.serverStatus.currentServer >= 0 && uiInfo.serverStatus.currentServer < uiInfo.serverStatus.numDisplayServers) { - trap_LAN_GetServerAddressString(ui_netSource.integer, uiInfo.serverStatus.displayServers[uiInfo.serverStatus.currentServer], buff, 1024); + trap_LAN_GetServerAddressString(UI_SourceForLAN(), uiInfo.serverStatus.displayServers[uiInfo.serverStatus.currentServer], buff, 1024); trap_Cmd_ExecuteText( EXEC_APPEND, va( "connect %s\n", buff ) ); } } else if (Q_stricmp(name, "FoundPlayerJoinServer") == 0) { @@ -3397,12 +3445,12 @@ static void UI_RunMenuScript(char **args) { trap_Cmd_ExecuteText( EXEC_APPEND, va("addbot %s %i %s\n", UI_GetBotNameByNumber(uiInfo.botIndex), uiInfo.skillIndex+1, (uiInfo.redBlue == 0) ? "Red" : "Blue") ); } } else if (Q_stricmp(name, "addFavorite") == 0) { - if (ui_netSource.integer != AS_FAVORITES) { + if (ui_netSource.integer != UIAS_FAVORITES) { char name[MAX_NAME_LENGTH]; char addr[MAX_NAME_LENGTH]; int res; - trap_LAN_GetServerInfo(ui_netSource.integer, uiInfo.serverStatus.displayServers[uiInfo.serverStatus.currentServer], buff, MAX_STRING_CHARS); + trap_LAN_GetServerInfo(UI_SourceForLAN(), uiInfo.serverStatus.displayServers[uiInfo.serverStatus.currentServer], buff, MAX_STRING_CHARS); name[0] = addr[0] = '\0'; Q_strncpyz(name, Info_ValueForKey(buff, "hostname"), MAX_NAME_LENGTH); Q_strncpyz(addr, Info_ValueForKey(buff, "addr"), MAX_NAME_LENGTH); @@ -3423,9 +3471,9 @@ static void UI_RunMenuScript(char **args) { } } } else if (Q_stricmp(name, "deleteFavorite") == 0) { - if (ui_netSource.integer == AS_FAVORITES) { + if (ui_netSource.integer == UIAS_FAVORITES) { char addr[MAX_NAME_LENGTH]; - trap_LAN_GetServerInfo(ui_netSource.integer, uiInfo.serverStatus.displayServers[uiInfo.serverStatus.currentServer], buff, MAX_STRING_CHARS); + trap_LAN_GetServerInfo(AS_FAVORITES, uiInfo.serverStatus.displayServers[uiInfo.serverStatus.currentServer], buff, MAX_STRING_CHARS); addr[0] = '\0'; Q_strncpyz(addr, Info_ValueForKey(buff, "addr"), MAX_NAME_LENGTH); if (strlen(addr) > 0) { @@ -3433,7 +3481,7 @@ static void UI_RunMenuScript(char **args) { } } } else if (Q_stricmp(name, "createFavorite") == 0) { - if (ui_netSource.integer == AS_FAVORITES) { + if (ui_netSource.integer == UIAS_FAVORITES) { char name[MAX_NAME_LENGTH]; char addr[MAX_NAME_LENGTH]; int res; @@ -3688,7 +3736,7 @@ static void UI_BinaryServerInsertion(int num) { while(mid > 0) { mid = len >> 1; // - res = trap_LAN_CompareServers( ui_netSource.integer, uiInfo.serverStatus.sortKey, + res = trap_LAN_CompareServers( UI_SourceForLAN(), uiInfo.serverStatus.sortKey, uiInfo.serverStatus.sortDir, num, uiInfo.serverStatus.displayServers[offset+mid]); // if equal if (res == 0) { @@ -3721,6 +3769,7 @@ static void UI_BuildServerDisplayList(qboolean force) { char info[MAX_STRING_CHARS]; // qboolean startRefresh = qtrue; TTimo: unused static int numinvisible; + int lanSource; if (!(force || uiInfo.uiDC.realTime > uiInfo.serverStatus.nextDisplayRefresh)) { return; @@ -3742,6 +3791,8 @@ static void UI_BuildServerDisplayList(qboolean force) { uiInfo.serverStatus.motdWidth = -1; } + lanSource = UI_SourceForLAN(); + if (force) { numinvisible = 0; // clear number of displayed servers @@ -3750,12 +3801,12 @@ static void UI_BuildServerDisplayList(qboolean force) { // set list box index to zero Menu_SetFeederSelection(NULL, FEEDER_SERVERS, 0, NULL); // mark all servers as visible so we store ping updates for them - trap_LAN_MarkServerVisible(ui_netSource.integer, -1, qtrue); + trap_LAN_MarkServerVisible(lanSource, -1, qtrue); } // get the server count (comes from the master) - count = trap_LAN_GetServerCount(ui_netSource.integer); - if (count == -1 || (ui_netSource.integer == AS_LOCAL && count == 0) ) { + count = trap_LAN_GetServerCount(lanSource); + if (count == -1 || (ui_netSource.integer == UIAS_LOCAL && count == 0) ) { // still waiting on a response from the master uiInfo.serverStatus.numDisplayServers = 0; uiInfo.serverStatus.numPlayersOnServers = 0; @@ -3766,22 +3817,22 @@ static void UI_BuildServerDisplayList(qboolean force) { visible = qfalse; for (i = 0; i < count; i++) { // if we already got info for this server - if (!trap_LAN_ServerIsVisible(ui_netSource.integer, i)) { + if (!trap_LAN_ServerIsVisible(lanSource, i)) { continue; } visible = qtrue; // get the ping for this server - ping = trap_LAN_GetServerPing(ui_netSource.integer, i); - if (ping > 0 || ui_netSource.integer == AS_FAVORITES) { + ping = trap_LAN_GetServerPing(lanSource, i); + if (ping > 0 || ui_netSource.integer == UIAS_FAVORITES) { - trap_LAN_GetServerInfo(ui_netSource.integer, i, info, MAX_STRING_CHARS); + trap_LAN_GetServerInfo(lanSource, i, info, MAX_STRING_CHARS); clients = atoi(Info_ValueForKey(info, "clients")); uiInfo.serverStatus.numPlayersOnServers += clients; if (ui_browserShowEmpty.integer == 0) { if (clients == 0) { - trap_LAN_MarkServerVisible(ui_netSource.integer, i, qfalse); + trap_LAN_MarkServerVisible(lanSource, i, qfalse); continue; } } @@ -3789,7 +3840,7 @@ static void UI_BuildServerDisplayList(qboolean force) { if (ui_browserShowFull.integer == 0) { maxClients = atoi(Info_ValueForKey(info, "sv_maxclients")); if (clients == maxClients) { - trap_LAN_MarkServerVisible(ui_netSource.integer, i, qfalse); + trap_LAN_MarkServerVisible(lanSource, i, qfalse); continue; } } @@ -3797,26 +3848,26 @@ static void UI_BuildServerDisplayList(qboolean force) { if (uiInfo.joinGameTypes[ui_joinGameType.integer].gtEnum != -1) { game = atoi(Info_ValueForKey(info, "gametype")); if (game != uiInfo.joinGameTypes[ui_joinGameType.integer].gtEnum) { - trap_LAN_MarkServerVisible(ui_netSource.integer, i, qfalse); + trap_LAN_MarkServerVisible(lanSource, i, qfalse); continue; } } if (ui_serverFilterType.integer > 0) { if (Q_stricmp(Info_ValueForKey(info, "game"), serverFilters[ui_serverFilterType.integer].basedir) != 0) { - trap_LAN_MarkServerVisible(ui_netSource.integer, i, qfalse); + trap_LAN_MarkServerVisible(lanSource, i, qfalse); continue; } } // make sure we never add a favorite server twice - if (ui_netSource.integer == AS_FAVORITES) { + if (ui_netSource.integer == UIAS_FAVORITES) { UI_RemoveServerFromDisplayList(i); } // insert the server into the list UI_BinaryServerInsertion(i); // done with this server if (ping > 0) { - trap_LAN_MarkServerVisible(ui_netSource.integer, i, qfalse); + trap_LAN_MarkServerVisible(lanSource, i, qfalse); numinvisible++; } } @@ -4012,6 +4063,7 @@ static void UI_BuildFindPlayerList(qboolean force) { serverStatusInfo_t info; char name[MAX_NAME_LENGTH+2]; char infoString[MAX_STRING_CHARS]; + int lanSource; if (!force) { if (!uiInfo.nextFindPlayerRefresh || uiInfo.nextFindPlayerRefresh > uiInfo.uiDC.realTime) { @@ -4100,9 +4152,10 @@ static void UI_BuildFindPlayerList(qboolean force) { // if we didn't try to get the status of all servers in the main browser yet if (uiInfo.pendingServerStatus.num < uiInfo.serverStatus.numDisplayServers) { uiInfo.pendingServerStatus.server[i].startTime = uiInfo.uiDC.realTime; - trap_LAN_GetServerAddressString(ui_netSource.integer, uiInfo.serverStatus.displayServers[uiInfo.pendingServerStatus.num], + lanSource = UI_SourceForLAN(); + trap_LAN_GetServerAddressString(lanSource, uiInfo.serverStatus.displayServers[uiInfo.pendingServerStatus.num], uiInfo.pendingServerStatus.server[i].adrstr, sizeof(uiInfo.pendingServerStatus.server[i].adrstr)); - trap_LAN_GetServerInfo(ui_netSource.integer, uiInfo.serverStatus.displayServers[uiInfo.pendingServerStatus.num], infoString, sizeof(infoString)); + trap_LAN_GetServerInfo(lanSource, uiInfo.serverStatus.displayServers[uiInfo.pendingServerStatus.num], infoString, sizeof(infoString)); Q_strncpyz(uiInfo.pendingServerStatus.server[i].name, Info_ValueForKey(infoString, "hostname"), sizeof(uiInfo.pendingServerStatus.server[0].name)); uiInfo.pendingServerStatus.server[i].valid = qtrue; uiInfo.pendingServerStatus.num++; @@ -4259,7 +4312,7 @@ static int UI_GetIndexFromSelection(int actual) { } static void UI_UpdatePendingPings( void ) { - trap_LAN_ResetPings(ui_netSource.integer); + trap_LAN_ResetPings(UI_SourceForLAN()); uiInfo.serverStatus.refreshActive = qtrue; uiInfo.serverStatus.refreshtime = uiInfo.uiDC.realTime + 1000; @@ -4286,7 +4339,7 @@ static const char *UI_FeederItemText(float feederID, int index, int column, qhan if (index >= 0 && index < uiInfo.serverStatus.numDisplayServers) { int ping, game, punkbuster; if (lastColumn != column || lastTime > uiInfo.uiDC.realTime + 5000) { - trap_LAN_GetServerInfo(ui_netSource.integer, uiInfo.serverStatus.displayServers[index], info, MAX_STRING_CHARS); + trap_LAN_GetServerInfo(UI_SourceForLAN(), uiInfo.serverStatus.displayServers[index], info, MAX_STRING_CHARS); lastColumn = column; lastTime = uiInfo.uiDC.realTime; } @@ -4300,7 +4353,7 @@ static const char *UI_FeederItemText(float feederID, int index, int column, qhan if (ping <= 0) { return Info_ValueForKey(info, "addr"); } else { - if ( ui_netSource.integer == AS_LOCAL ) { + if ( ui_netSource.integer == UIAS_LOCAL ) { int nettype = atoi(Info_ValueForKey(info, "nettype")); if (nettype < 0 || nettype >= ARRAY_LEN(netnames)) { @@ -4456,7 +4509,7 @@ static void UI_FeederSelection(float feederID, int index) { } else if (feederID == FEEDER_SERVERS) { const char *mapName = NULL; uiInfo.serverStatus.currentServer = index; - trap_LAN_GetServerInfo(ui_netSource.integer, uiInfo.serverStatus.displayServers[index], info, MAX_STRING_CHARS); + trap_LAN_GetServerInfo(UI_SourceForLAN(), uiInfo.serverStatus.displayServers[index], info, MAX_STRING_CHARS); uiInfo.serverStatus.currentServerPreview = trap_R_RegisterShaderNoMip(va("levelshots/%s", Info_ValueForKey(info, "mapname"))); if (uiInfo.serverStatus.currentServerCinematic >= 0) { trap_CIN_StopCinematic(uiInfo.serverStatus.currentServerCinematic); @@ -5657,6 +5710,9 @@ vmCvar_t ui_lastServerRefresh_0; vmCvar_t ui_lastServerRefresh_1; vmCvar_t ui_lastServerRefresh_2; vmCvar_t ui_lastServerRefresh_3; +vmCvar_t ui_lastServerRefresh_4; +vmCvar_t ui_lastServerRefresh_5; +vmCvar_t ui_lastServerRefresh_6; vmCvar_t ui_singlePlayerActive; vmCvar_t ui_scoreAccuracy; vmCvar_t ui_scoreImpressives; @@ -5775,6 +5831,9 @@ static cvarTable_t cvarTable[] = { { &ui_lastServerRefresh_1, "ui_lastServerRefresh_1", "", CVAR_ARCHIVE}, { &ui_lastServerRefresh_2, "ui_lastServerRefresh_2", "", CVAR_ARCHIVE}, { &ui_lastServerRefresh_3, "ui_lastServerRefresh_3", "", CVAR_ARCHIVE}, + { &ui_lastServerRefresh_4, "ui_lastServerRefresh_4", "", CVAR_ARCHIVE}, + { &ui_lastServerRefresh_5, "ui_lastServerRefresh_5", "", CVAR_ARCHIVE}, + { &ui_lastServerRefresh_6, "ui_lastServerRefresh_6", "", CVAR_ARCHIVE}, { &ui_singlePlayerActive, "ui_singlePlayerActive", "0", 0}, { &ui_scoreAccuracy, "ui_scoreAccuracy", "0", CVAR_ARCHIVE}, { &ui_scoreImpressives, "ui_scoreImpressives", "0", CVAR_ARCHIVE}, @@ -5855,7 +5914,7 @@ static void UI_StopServerRefresh( void ) Com_Printf("%d servers listed in browser with %d players.\n", uiInfo.serverStatus.numDisplayServers, uiInfo.serverStatus.numPlayersOnServers); - count = trap_LAN_GetServerCount(ui_netSource.integer); + count = trap_LAN_GetServerCount(UI_SourceForLAN()); if (count - uiInfo.serverStatus.numDisplayServers > 0) { Com_Printf("%d servers not listed due to packet loss or pings higher than %d\n", count - uiInfo.serverStatus.numDisplayServers, @@ -5893,13 +5952,13 @@ static void UI_DoServerRefresh( void ) if (!uiInfo.serverStatus.refreshActive) { return; } - if (ui_netSource.integer != AS_FAVORITES) { - if (ui_netSource.integer == AS_LOCAL) { - if (!trap_LAN_GetServerCount(ui_netSource.integer)) { + if (ui_netSource.integer != UIAS_FAVORITES) { + if (ui_netSource.integer == UIAS_LOCAL) { + if (!trap_LAN_GetServerCount(AS_LOCAL)) { wait = qtrue; } } else { - if (trap_LAN_GetServerCount(ui_netSource.integer) < 0) { + if (trap_LAN_GetServerCount(AS_GLOBAL) < 0) { wait = qtrue; } } @@ -5912,7 +5971,7 @@ static void UI_DoServerRefresh( void ) } // if still trying to retrieve pings - if (trap_LAN_UpdateVisiblePings(ui_netSource.integer)) { + if (trap_LAN_UpdateVisiblePings(UI_SourceForLAN())) { uiInfo.serverStatus.refreshtime = uiInfo.uiDC.realTime + 1000; } else if (!wait) { // get the last servers in the list @@ -5932,6 +5991,7 @@ UI_StartServerRefresh static void UI_StartServerRefresh(qboolean full) { char *ptr; + int lanSource; qtime_t q; trap_RealTime(&q); @@ -5947,26 +6007,28 @@ static void UI_StartServerRefresh(qboolean full) // clear number of displayed servers uiInfo.serverStatus.numDisplayServers = 0; uiInfo.serverStatus.numPlayersOnServers = 0; + + lanSource = UI_SourceForLAN(); // mark all servers as visible so we store ping updates for them - trap_LAN_MarkServerVisible(ui_netSource.integer, -1, qtrue); + trap_LAN_MarkServerVisible(lanSource, -1, qtrue); // reset all the pings - trap_LAN_ResetPings(ui_netSource.integer); + trap_LAN_ResetPings(lanSource); // - if( ui_netSource.integer == AS_LOCAL ) { + if( ui_netSource.integer == UIAS_LOCAL ) { trap_Cmd_ExecuteText( EXEC_NOW, "localservers\n" ); uiInfo.serverStatus.refreshtime = uiInfo.uiDC.realTime + 1000; return; } uiInfo.serverStatus.refreshtime = uiInfo.uiDC.realTime + 5000; - if( ui_netSource.integer == AS_GLOBAL ) { + if( ui_netSource.integer >= UIAS_GLOBAL1 && ui_netSource.integer <= UIAS_GLOBAL5 ) { ptr = UI_Cvar_VariableString("debug_protocol"); if (strlen(ptr)) { - trap_Cmd_ExecuteText( EXEC_NOW, va( "globalservers 0 %s full empty\n", ptr)); + trap_Cmd_ExecuteText( EXEC_NOW, va( "globalservers %d %s full empty\n", ui_netSource.integer-1, ptr)); } else { - trap_Cmd_ExecuteText( EXEC_NOW, va( "globalservers 0 %d full empty\n", (int)trap_Cvar_VariableValue( "protocol" ) ) ); + trap_Cmd_ExecuteText( EXEC_NOW, va( "globalservers %d %d full empty\n", ui_netSource.integer-1, (int)trap_Cvar_VariableValue( "protocol" ) ) ); } } }