[yquake2] 01/04: New upstream version 6.00~dfsg1

Simon McVittie smcv at debian.org
Tue Dec 13 13:54:06 UTC 2016


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian/master
in repository yquake2.

commit 0a5508d34c5d8fec2b2a0886e65634c41ca0883d
Author: Simon McVittie <smcv at debian.org>
Date:   Tue Dec 13 13:22:00 2016 +0000

    New upstream version 6.00~dfsg1
---
 CHANGELOG                         |  14 +
 CMakeLists.txt                    |   8 +-
 Makefile                          |  39 ++-
 README.md                         |  13 +-
 src/backends/generic/header/qgl.h |  17 +-
 src/backends/generic/qal.c        | 206 ++++++++-------
 src/backends/generic/qgl.c        |  14 +-
 src/backends/generic/vid.c        |   4 -
 src/backends/sdl/input.c          |   8 +-
 src/backends/sdl/refresh.c        |  36 +++
 src/backends/unix/main.c          |  13 +-
 src/backends/unix/signalhandler.c |  10 +-
 src/backends/unix/system.c        |  22 +-
 src/backends/windows/system.c     |  10 +-
 src/client/cl_cin.c               |   6 +
 src/client/cl_download.c          |   3 +
 src/client/cl_effects.c           |   3 +-
 src/client/cl_input.c             | 166 +++++++++---
 src/client/cl_lights.c            |   2 +-
 src/client/cl_main.c              | 300 +++++++++++++--------
 src/client/cl_prediction.c        |  26 +-
 src/client/cl_screen.c            |  10 +-
 src/client/header/client.h        |   8 +-
 src/client/menu/menu.c            |  47 +---
 src/client/refresh/header/local.h |  43 ++-
 src/client/refresh/r_draw.c       | 337 ++++++++++++++++--------
 src/client/refresh/r_image.c      |  50 ++--
 src/client/refresh/r_light.c      |  48 ++--
 src/client/refresh/r_lightmap.c   |   3 +-
 src/client/refresh/r_main.c       | 531 ++++++++++++++++++++++----------------
 src/client/refresh/r_mesh.c       | 176 +++++--------
 src/client/refresh/r_misc.c       |  12 +-
 src/client/refresh/r_surf.c       | 356 ++++++++++++++-----------
 src/client/refresh/r_warp.c       |  74 ++++--
 src/client/sound/openal.c         |   2 +-
 src/common/cvar.c                 |   1 +
 src/common/filesystem.c           |  62 -----
 src/common/header/common.h        |  15 +-
 src/common/misc.c                 |   2 +-
 src/game/g_ai.c                   |   3 +-
 src/game/g_misc.c                 |   2 +-
 src/game/g_monster.c              |   5 -
 src/game/g_spawn.c                |  16 ++
 src/game/monster/flyer/flyer.c    |   2 +-
 src/game/monster/gunner/gunner.c  |   5 +-
 src/game/savegame/savegame.c      |  38 +--
 stuff/README.old                  |   2 +-
 47 files changed, 1634 insertions(+), 1136 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 280e7ff..200ced3 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,17 @@
+Quake II 5.34 to 6.00:
+- Make the client asynchronous. The old behaviour can be forced by
+  setting cl_async to 0. Please note that asynchronicity can lead to
+  problems if the old SDL 1.2 backend is used and vsync is enabled.
+- Implement gl_overbrightbits in the non multitexturing case.  A
+  value of 1 just fixes lighting on water surfaces, higher values
+  increase the brightness of everything.
+- General renderer overhaul for better compatibility with modern GPUs.
+  OpenGL 1.4 is now required, older versions are no longer supported.
+  Multitexturing was deprecated and will be removed in a future 
+  release.
+- Fix some longstanding AI problems.
+- Several general gameplay fixes.
+
 Quake II 5.33 to 5.34:
 - Add support for stereo 3D (by Valery Guskov)
 - Make gibt solid so they move with conveyor belts.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cf0e2f0..9215741 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -56,13 +56,15 @@ set(SERVER_SRC_DIR ${SOURCE_DIR}/server)
 set(CLIENT_SRC_DIR ${SOURCE_DIR}/client)
 
 # Operating system
-add_definitions(-DOSTYPE="${CMAKE_SYSTEM_NAME}")
+set(YQ2OSTYPE "${CMAKE_SYSTEM_NAME}" CACHE STRING "Override operation system type")
+add_definitions(-DYQ2OSTYPE="${YQ2OSTYPE}")
 
 # Architecture string
-string(REGEX REPLACE "amd64" "x86_64" ARCH ${CMAKE_SYSTEM_PROCESSOR})
+set(YQ2ARCH "${CMAKE_SYSTEM_PROCESSOR}" CACHE STRING "Override CPU architecture")
+string(REGEX REPLACE "amd64" "x86_64" ARCH ${YQ2ARCH})
 string(REGEX REPLACE "i.86" "i386" ARCH ${ARCH})
 string(REGEX REPLACE "^arm.*" "arm" ARCH ${ARCH})
-add_definitions(-DARCH="${ARCH}")
+add_definitions(-DYQ2ARCH="${ARCH}")
 
 # Systemwide installation of game assets
 if(${SYSTEMWIDE_SUPPORT})
diff --git a/Makefile b/Makefile
index 05c06ad..d085c83 100755
--- a/Makefile
+++ b/Makefile
@@ -44,6 +44,12 @@ WITH_OGG:=yes
 # installed
 WITH_OPENAL:=yes
 
+# Enables optional runtime loading of OpenAL (dlopen or
+# similar). If set to "no", the library is linked in at
+# compile time in the normal way. On Windows this option
+# is ignored, OpenAL is always loaded at runtime.
+DLOPEN_OPENAL:=yes
+
 # Use SDL2 instead of SDL1.2. Disables CD audio support,
 # because SDL2 has none. Use OGG/Vorbis music instead :-)
 # On Windows sdl-config isn't used, so make sure that
@@ -94,9 +100,9 @@ endif
 
 # Detect the OS
 ifdef SystemRoot
-OSTYPE := Windows
+OSTYPE ?= Windows
 else
-OSTYPE := $(shell uname -s)
+OSTYPE ?= $(shell uname -s)
 endif
 
 # Special case for MinGW
@@ -108,14 +114,14 @@ endif
 ifeq ($(OSTYPE), Windows)
 ifdef PROCESSOR_ARCHITEW6432
 # 64 bit Windows
-ARCH := $(PROCESSOR_ARCHITEW6432)
+ARCH ?= $(PROCESSOR_ARCHITEW6432)
 else
 # 32 bit Windows
-ARCH := $(PROCESSOR_ARCHITECTURE)
+ARCH ?= $(PROCESSOR_ARCHITECTURE)
 endif
 else
 # Normalize some abiguous ARCH strings
-ARCH := $(shell uname -m | sed -e 's/i.86/i386/' -e 's/amd64/x86_64/' -e 's/^arm.*/arm/')
+ARCH ?= $(shell uname -m | sed -e 's/i.86/i386/' -e 's/amd64/x86_64/' -e 's/^arm.*/arm/')
 endif
 
 # Disable CDA for SDL2
@@ -130,6 +136,7 @@ CDA_DISABLED:=yes
 endif
 endif
 
+
 # ----------
 
 # Base CFLAGS.
@@ -161,7 +168,14 @@ endif
 # ----------
 
 # Defines the operating system and architecture
-CFLAGS += -DOSTYPE=\"$(OSTYPE)\" -DARCH=\"$(ARCH)\"
+CFLAGS += -DYQ2OSTYPE=\"$(OSTYPE)\" -DYQ2ARCH=\"$(ARCH)\"
+
+# ----------
+
+# https://reproducible-builds.org/specs/source-date-epoch/
+ifdef SOURCE_DATE_EPOCH
+CFLAGS += -DBUILD_DATE=\"$(shell date --utc --date="@${SOURCE_DATE_EPOCH}" +"%b %_d %Y" | sed -e 's/ /\\ /g')\"
+endif
 
 # ----------
 
@@ -357,7 +371,7 @@ release/quake2.exe : LDFLAGS += -lvorbisfile -lvorbis -logg
 endif
 
 ifeq ($(WITH_OPENAL),yes)
-release/quake2.exe : CFLAGS += -DUSE_OPENAL -DDEFAULT_OPENAL_DRIVER='"openal32.dll"'
+release/quake2.exe : CFLAGS += -DUSE_OPENAL -DDEFAULT_OPENAL_DRIVER='"openal32.dll"' -DDLOPEN_OPENAL
 endif
 
 ifeq ($(WITH_ZIP),yes)
@@ -398,15 +412,20 @@ release/quake2 : LDFLAGS += -lvorbis -lvorbisfile -logg
 endif
 
 ifeq ($(WITH_OPENAL),yes)
+ifeq ($(DLOPEN_OPENAL),yes)
 ifeq ($(OSTYPE), OpenBSD)
-release/quake2 : CFLAGS += -DUSE_OPENAL -DDEFAULT_OPENAL_DRIVER='"libopenal.so"'
+release/quake2 : CFLAGS += -DUSE_OPENAL -DDEFAULT_OPENAL_DRIVER='"libopenal.so"' -DDLOPEN_OPENAL
 else ifeq ($(OSTYPE), Darwin)
 release/quake2 : CFLAGS += -DUSE_OPENAL -DDEFAULT_OPENAL_DRIVER='"libopenal.dylib"' -I/usr/local/opt/openal-soft/include
 release/quake2 : LDFLAGS += -L/usr/local/opt/openal-soft/lib
 else
-release/quake2 : CFLAGS += -DUSE_OPENAL -DDEFAULT_OPENAL_DRIVER='"libopenal.so.1"'
-endif
+release/quake2 : CFLAGS += -DUSE_OPENAL -DDEFAULT_OPENAL_DRIVER='"libopenal.so.1"' -DDLOPEN_OPENAL
 endif
+else # !DLOPEN_OPENAL
+release/quake2 : CFLAGS += -DUSE_OPENAL
+release/quake2 : LDFLAGS += -lopenal
+endif # !DLOPEN_OPENAL
+endif # WITH_OPENAL
 
 ifeq ($(WITH_ZIP),yes)
 release/quake2 : CFLAGS += -DZIP -DNOUNCRYPT
diff --git a/README.md b/README.md
index 0685eac..d8bfb2c 100644
--- a/README.md
+++ b/README.md
@@ -5,12 +5,12 @@ This is the Yamagi Quake II Client, an enhanced version of id Software's Quake
 II with focus on offline and coop gameplay. Both the gameplay and the graphics
 are unchanged, but many bugs if the last official release were fixed and some
 nice to have features like widescreen support were added. Unlike most other
-Quake II source ports Yamagi Quake II is full 64 bit clean. It works perfectly
+Quake II source ports Yamagi Quake II is fully 64 bit clean. It works perfectly
 on modern processors and operating systems. Yamagi Quake II runs on nearly all
-common platforms, including FreeBSD, Linux, OpenBSD, Windows and OS X.
+common platforms; including FreeBSD, Linux, OpenBSD, Windows and OS X.
 
 This code is build upon Icculus Quake II, which itself is based on Quake II
-3.21. Yamagi Quake II released under the terms of the GPL version 2. See the
+3.21. Yamagi Quake II is released under the terms of the GPL version 2. See the
 LICENSE file for further information.
 
 
@@ -217,11 +217,12 @@ Visual Studio.
 #### Compiling
 
 Download the latest release from http://www.yamagi.org/quake2 or clone the
-source from https://github.com/yquake/yquake.git, change into the yquake2/
+source from https://github.com/yquake2/yquake2.git, change into the yquake2/
 source directory and type *make*. After that copy everything from the release/
 directory to your Yamagi Quake II installation directory.
 
 For the addons download or clone their source, change into the source directory
-and type *make*. After the compilation finishes the release/game.so is copied
-to the corresponding directory in your Quake II installation.
+and type *make* (*make CC=gcc* on Windows). After the compilation finishes the
+release/game.so is copied to the corresponding directory in your Quake II
+installation.
  
diff --git a/src/backends/generic/header/qgl.h b/src/backends/generic/header/qgl.h
index 59c46c8..bd33da1 100644
--- a/src/backends/generic/header/qgl.h
+++ b/src/backends/generic/header/qgl.h
@@ -45,9 +45,6 @@
 
 #define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB
 
-#define GL_TEXTURE0_SGIS 0x835E
-#define GL_TEXTURE1_SGIS 0x835F
-
 #define GL_POINT_SIZE_MIN_EXT 0x8126
 #define GL_POINT_SIZE_MAX_EXT 0x8127
 #define GL_DISTANCE_ATTENUATION_EXT 0x8129
@@ -96,7 +93,14 @@
 #define GL_OPERAND7_ALPHA_EXT 0x859F
 #endif
 
-/* QGL main functions */
+#ifdef _WIN32
+GLAPI void APIENTRY glActiveTextureARB( GLenum texture );
+GLAPI void APIENTRY glClientActiveTextureARB( GLenum texture );
+GLAPI void APIENTRY glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t);
+GLAPI void APIENTRY glMultiTexCoord2fvARB(GLenum target, const GLfloat *v);
+#endif
+
+// =======================================================================
 
 /*
  * This is responsible for setting up our QGL extension pointers
@@ -109,14 +113,15 @@ qboolean QGL_Init ( void );
 void QGL_Shutdown ( void );
 
 /* GL extensions */
-extern void ( APIENTRY *qglPointParameterfEXT ) ( GLenum param, GLfloat value );
-extern void ( APIENTRY *qglPointParameterfvEXT ) ( GLenum param,
+extern void ( APIENTRY *qglPointParameterfARB ) ( GLenum param, GLfloat value );
+extern void ( APIENTRY *qglPointParameterfvARB ) ( GLenum param,
 		const GLfloat *value );
 extern void ( APIENTRY *qglColorTableEXT ) ( GLenum, GLenum, GLsizei, GLenum,
 		GLenum, const GLvoid * );
 extern void ( APIENTRY *qglLockArraysEXT ) ( int, int );
 extern void ( APIENTRY *qglUnlockArraysEXT ) ( void );
 extern void ( APIENTRY *qglMultiTexCoord2fARB) ( GLenum, GLfloat, GLfloat );
+extern void ( APIENTRY *qglMultiTexCoord2fvARB) ( GLenum, GLfloat* );
 extern void ( APIENTRY *qglActiveTextureARB ) ( GLenum );
 extern void ( APIENTRY *qglClientActiveTextureARB ) ( GLenum );
 
diff --git a/src/backends/generic/qal.c b/src/backends/generic/qal.c
index ae04ac2..b5cdef4 100644
--- a/src/backends/generic/qal.c
+++ b/src/backends/generic/qal.c
@@ -43,7 +43,9 @@
 static ALCcontext *context;
 static ALCdevice *device;
 static cvar_t *al_device;
+#ifdef DLOPEN_OPENAL
 static cvar_t *al_driver;
+#endif
 static void *handle;
 
 /* Function pointers for OpenAL management */
@@ -322,9 +324,12 @@ QAL_Shutdown()
 	qalFilterf = NULL;
 	qalDeleteFilters = NULL;
 
-	/* Unload the shared lib */
-	Sys_FreeLibrary(handle);
-    handle = NULL;
+	if (handle)
+	{
+		/* Unload the shared lib */
+		Sys_FreeLibrary(handle);
+		handle = NULL;
+	}
 }
 
 /*
@@ -334,9 +339,11 @@ QAL_Shutdown()
 qboolean
 QAL_Init()
 {
+	al_device = Cvar_Get("al_device", "", CVAR_ARCHIVE);
+
+#ifdef DLOPEN_OPENAL
 	/* DEFAULT_OPENAL_DRIVER is defined at compile time via the compiler */
 	al_driver = Cvar_Get("al_driver", DEFAULT_OPENAL_DRIVER, CVAR_ARCHIVE);
-	al_device = Cvar_Get("al_device", "", CVAR_ARCHIVE);
 
 	Com_Printf("LoadLibrary(%s)\n", al_driver->string);
 
@@ -348,104 +355,109 @@ QAL_Init()
 		Com_Printf("Loading %s failed! Disabling OpenAL.\n", al_driver->string);
 		return false;
 	}
+#	define ALSYMBOL(handle, sym) Sys_GetProcAddress(handle, #sym)
+#else
+	handle = NULL;
+#	define ALSYMBOL(handle, sym) sym
+#endif
 
 	/* Connect function pointers to management functions */
-	qalcCreateContext = Sys_GetProcAddress(handle, "alcCreateContext");
-	qalcMakeContextCurrent = Sys_GetProcAddress(handle, "alcMakeContextCurrent");
-	qalcProcessContext = Sys_GetProcAddress(handle, "alcProcessContext");
-	qalcSuspendContext = Sys_GetProcAddress(handle, "alcSuspendContext");
-	qalcDestroyContext = Sys_GetProcAddress(handle, "alcDestroyContext");
-	qalcGetCurrentContext = Sys_GetProcAddress(handle, "alcGetCurrentContext");
-	qalcGetContextsDevice = Sys_GetProcAddress(handle, "alcGetContextsDevice");
-	qalcOpenDevice = Sys_GetProcAddress(handle, "alcOpenDevice");
-	qalcCloseDevice = Sys_GetProcAddress(handle, "alcCloseDevice");
-	qalcGetError = Sys_GetProcAddress(handle, "alcGetError");
-	qalcIsExtensionPresent = Sys_GetProcAddress(handle, "alcIsExtensionPresent");
-	qalcGetProcAddress = Sys_GetProcAddress(handle, "alcGetProcAddress");
-	qalcGetEnumValue = Sys_GetProcAddress(handle, "alcGetEnumValue");
-	qalcGetString = Sys_GetProcAddress(handle, "alcGetString");
-	qalcGetIntegerv = Sys_GetProcAddress(handle, "alcGetIntegerv");
-	qalcCaptureOpenDevice = Sys_GetProcAddress(handle, "alcCaptureOpenDevice");
-	qalcCaptureCloseDevice = Sys_GetProcAddress(handle, "alcCaptureCloseDevice");
-	qalcCaptureStart = Sys_GetProcAddress(handle, "alcCaptureStart");
-	qalcCaptureStop = Sys_GetProcAddress(handle, "alcCaptureStop");
-	qalcCaptureSamples = Sys_GetProcAddress(handle, "alcCaptureSamples");
+	qalcCreateContext = ALSYMBOL(handle, alcCreateContext);
+	qalcMakeContextCurrent = ALSYMBOL(handle, alcMakeContextCurrent);
+	qalcProcessContext = ALSYMBOL(handle, alcProcessContext);
+	qalcSuspendContext = ALSYMBOL(handle, alcSuspendContext);
+	qalcDestroyContext = ALSYMBOL(handle, alcDestroyContext);
+	qalcGetCurrentContext = ALSYMBOL(handle, alcGetCurrentContext);
+	qalcGetContextsDevice = ALSYMBOL(handle, alcGetContextsDevice);
+	qalcOpenDevice = ALSYMBOL(handle, alcOpenDevice);
+	qalcCloseDevice = ALSYMBOL(handle, alcCloseDevice);
+	qalcGetError = ALSYMBOL(handle, alcGetError);
+	qalcIsExtensionPresent = ALSYMBOL(handle, alcIsExtensionPresent);
+	qalcGetProcAddress = ALSYMBOL(handle, alcGetProcAddress);
+	qalcGetEnumValue = ALSYMBOL(handle, alcGetEnumValue);
+	qalcGetString = ALSYMBOL(handle, alcGetString);
+	qalcGetIntegerv = ALSYMBOL(handle, alcGetIntegerv);
+	qalcCaptureOpenDevice = ALSYMBOL(handle, alcCaptureOpenDevice);
+	qalcCaptureCloseDevice = ALSYMBOL(handle, alcCaptureCloseDevice);
+	qalcCaptureStart = ALSYMBOL(handle, alcCaptureStart);
+	qalcCaptureStop = ALSYMBOL(handle, alcCaptureStop);
+	qalcCaptureSamples = ALSYMBOL(handle, alcCaptureSamples);
 
 	/* Connect function pointers to
 	   to OpenAL API functions */
-	qalEnable = Sys_GetProcAddress(handle, "alEnable");
-	qalDisable = Sys_GetProcAddress(handle, "alDisable");
-	qalIsEnabled = Sys_GetProcAddress(handle, "alIsEnabled");
-	qalGetString = Sys_GetProcAddress(handle, "alGetString");
-	qalGetBooleanv = Sys_GetProcAddress(handle, "alGetBooleanv");
-	qalGetIntegerv = Sys_GetProcAddress(handle, "alGetIntegerv");
-	qalGetFloatv = Sys_GetProcAddress(handle, "alGetFloatv");
-	qalGetDoublev = Sys_GetProcAddress(handle, "alGetDoublev");
-	qalGetBoolean = Sys_GetProcAddress(handle, "alGetBoolean");
-	qalGetInteger = Sys_GetProcAddress(handle, "alGetInteger");
-	qalGetFloat = Sys_GetProcAddress(handle, "alGetFloat");
-	qalGetDouble = Sys_GetProcAddress(handle, "alGetDouble");
-	qalGetError = Sys_GetProcAddress(handle, "alGetError");
-	qalIsExtensionPresent = Sys_GetProcAddress(handle, "alIsExtensionPresent");
-	qalGetProcAddress = Sys_GetProcAddress(handle, "alGetProcAddress");
-	qalGetEnumValue = Sys_GetProcAddress(handle, "alGetEnumValue");
-	qalListenerf = Sys_GetProcAddress(handle, "alListenerf");
-	qalListener3f = Sys_GetProcAddress(handle, "alListener3f");
-	qalListenerfv = Sys_GetProcAddress(handle, "alListenerfv");
-	qalListeneri = Sys_GetProcAddress(handle, "alListeneri");
-	qalListener3i = Sys_GetProcAddress(handle, "alListener3i");
-	qalListeneriv = Sys_GetProcAddress(handle, "alListeneriv");
-	qalGetListenerf = Sys_GetProcAddress(handle, "alGetListenerf");
-	qalGetListener3f = Sys_GetProcAddress(handle, "alGetListener3f");
-	qalGetListenerfv = Sys_GetProcAddress(handle, "alGetListenerfv");
-	qalGetListeneri = Sys_GetProcAddress(handle, "alGetListeneri");
-	qalGetListener3i = Sys_GetProcAddress(handle, "alGetListener3i");
-	qalGetListeneriv = Sys_GetProcAddress(handle, "alGetListeneriv");
-	qalGenSources = Sys_GetProcAddress(handle, "alGenSources");
-	qalDeleteSources = Sys_GetProcAddress(handle, "alDeleteSources");
-	qalIsSource = Sys_GetProcAddress(handle, "alIsSource");
-	qalSourcef = Sys_GetProcAddress(handle, "alSourcef");
-	qalSource3f = Sys_GetProcAddress(handle, "alSource3f");
-	qalSourcefv = Sys_GetProcAddress(handle, "alSourcefv");
-	qalSourcei = Sys_GetProcAddress(handle, "alSourcei");
-	qalSource3i = Sys_GetProcAddress(handle, "alSource3i");
-	qalSourceiv = Sys_GetProcAddress(handle, "alSourceiv");
-	qalGetSourcef = Sys_GetProcAddress(handle, "alGetSourcef");
-	qalGetSource3f = Sys_GetProcAddress(handle, "alGetSource3f");
-	qalGetSourcefv = Sys_GetProcAddress(handle, "alGetSourcefv");
-	qalGetSourcei = Sys_GetProcAddress(handle, "alGetSourcei");
-	qalGetSource3i = Sys_GetProcAddress(handle, "alGetSource3i");
-	qalGetSourceiv = Sys_GetProcAddress(handle, "alGetSourceiv");
-	qalSourcePlayv = Sys_GetProcAddress(handle, "alSourcePlayv");
-	qalSourceStopv = Sys_GetProcAddress(handle, "alSourceStopv");
-	qalSourceRewindv = Sys_GetProcAddress(handle, "alSourceRewindv");
-	qalSourcePausev = Sys_GetProcAddress(handle, "alSourcePausev");
-	qalSourcePlay = Sys_GetProcAddress(handle, "alSourcePlay");
-	qalSourceStop = Sys_GetProcAddress(handle, "alSourceStop");
-	qalSourceRewind = Sys_GetProcAddress(handle, "alSourceRewind");
-	qalSourcePause = Sys_GetProcAddress(handle, "alSourcePause");
-	qalSourceQueueBuffers = Sys_GetProcAddress(handle, "alSourceQueueBuffers");
-	qalSourceUnqueueBuffers = Sys_GetProcAddress(handle, "alSourceUnqueueBuffers");
-	qalGenBuffers = Sys_GetProcAddress(handle, "alGenBuffers");
-	qalDeleteBuffers = Sys_GetProcAddress(handle, "alDeleteBuffers");
-	qalIsBuffer = Sys_GetProcAddress(handle, "alIsBuffer");
-	qalBufferData = Sys_GetProcAddress(handle, "alBufferData");
-	qalBufferf = Sys_GetProcAddress(handle, "alBufferf");
-	qalBuffer3f = Sys_GetProcAddress(handle, "alBuffer3f");
-	qalBufferfv = Sys_GetProcAddress(handle, "alBufferfv");
-	qalBufferi = Sys_GetProcAddress(handle, "alBufferi");
-	qalBuffer3i = Sys_GetProcAddress(handle, "alBuffer3i");
-	qalBufferiv = Sys_GetProcAddress(handle, "alBufferiv");
-	qalGetBufferf = Sys_GetProcAddress(handle, "alGetBufferf");
-	qalGetBuffer3f = Sys_GetProcAddress(handle, "alGetBuffer3f");
-	qalGetBufferfv = Sys_GetProcAddress(handle, "alGetBufferfv");
-	qalGetBufferi = Sys_GetProcAddress(handle, "alGetBufferi");
-	qalGetBuffer3i = Sys_GetProcAddress(handle, "alGetBuffer3i");
-	qalGetBufferiv = Sys_GetProcAddress(handle, "alGetBufferiv");
-	qalDopplerFactor = Sys_GetProcAddress(handle, "alDopplerFactor");
-	qalDopplerVelocity = Sys_GetProcAddress(handle, "alDopplerVelocity");
-	qalSpeedOfSound = Sys_GetProcAddress(handle, "alSpeedOfSound");
-	qalDistanceModel = Sys_GetProcAddress(handle, "alDistanceModel");
+	qalEnable = ALSYMBOL(handle, alEnable);
+	qalDisable = ALSYMBOL(handle, alDisable);
+	qalIsEnabled = ALSYMBOL(handle, alIsEnabled);
+	qalGetString = ALSYMBOL(handle, alGetString);
+	qalGetBooleanv = ALSYMBOL(handle, alGetBooleanv);
+	qalGetIntegerv = ALSYMBOL(handle, alGetIntegerv);
+	qalGetFloatv = ALSYMBOL(handle, alGetFloatv);
+	qalGetDoublev = ALSYMBOL(handle, alGetDoublev);
+	qalGetBoolean = ALSYMBOL(handle, alGetBoolean);
+	qalGetInteger = ALSYMBOL(handle, alGetInteger);
+	qalGetFloat = ALSYMBOL(handle, alGetFloat);
+	qalGetDouble = ALSYMBOL(handle, alGetDouble);
+	qalGetError = ALSYMBOL(handle, alGetError);
+	qalIsExtensionPresent = ALSYMBOL(handle, alIsExtensionPresent);
+	qalGetProcAddress = ALSYMBOL(handle, alGetProcAddress);
+	qalGetEnumValue = ALSYMBOL(handle, alGetEnumValue);
+	qalListenerf = ALSYMBOL(handle, alListenerf);
+	qalListener3f = ALSYMBOL(handle, alListener3f);
+	qalListenerfv = ALSYMBOL(handle, alListenerfv);
+	qalListeneri = ALSYMBOL(handle, alListeneri);
+	qalListener3i = ALSYMBOL(handle, alListener3i);
+	qalListeneriv = ALSYMBOL(handle, alListeneriv);
+	qalGetListenerf = ALSYMBOL(handle, alGetListenerf);
+	qalGetListener3f = ALSYMBOL(handle, alGetListener3f);
+	qalGetListenerfv = ALSYMBOL(handle, alGetListenerfv);
+	qalGetListeneri = ALSYMBOL(handle, alGetListeneri);
+	qalGetListener3i = ALSYMBOL(handle, alGetListener3i);
+	qalGetListeneriv = ALSYMBOL(handle, alGetListeneriv);
+	qalGenSources = ALSYMBOL(handle, alGenSources);
+	qalDeleteSources = ALSYMBOL(handle, alDeleteSources);
+	qalIsSource = ALSYMBOL(handle, alIsSource);
+	qalSourcef = ALSYMBOL(handle, alSourcef);
+	qalSource3f = ALSYMBOL(handle, alSource3f);
+	qalSourcefv = ALSYMBOL(handle, alSourcefv);
+	qalSourcei = ALSYMBOL(handle, alSourcei);
+	qalSource3i = ALSYMBOL(handle, alSource3i);
+	qalSourceiv = ALSYMBOL(handle, alSourceiv);
+	qalGetSourcef = ALSYMBOL(handle, alGetSourcef);
+	qalGetSource3f = ALSYMBOL(handle, alGetSource3f);
+	qalGetSourcefv = ALSYMBOL(handle, alGetSourcefv);
+	qalGetSourcei = ALSYMBOL(handle, alGetSourcei);
+	qalGetSource3i = ALSYMBOL(handle, alGetSource3i);
+	qalGetSourceiv = ALSYMBOL(handle, alGetSourceiv);
+	qalSourcePlayv = ALSYMBOL(handle, alSourcePlayv);
+	qalSourceStopv = ALSYMBOL(handle, alSourceStopv);
+	qalSourceRewindv = ALSYMBOL(handle, alSourceRewindv);
+	qalSourcePausev = ALSYMBOL(handle, alSourcePausev);
+	qalSourcePlay = ALSYMBOL(handle, alSourcePlay);
+	qalSourceStop = ALSYMBOL(handle, alSourceStop);
+	qalSourceRewind = ALSYMBOL(handle, alSourceRewind);
+	qalSourcePause = ALSYMBOL(handle, alSourcePause);
+	qalSourceQueueBuffers = ALSYMBOL(handle, alSourceQueueBuffers);
+	qalSourceUnqueueBuffers = ALSYMBOL(handle, alSourceUnqueueBuffers);
+	qalGenBuffers = ALSYMBOL(handle, alGenBuffers);
+	qalDeleteBuffers = ALSYMBOL(handle, alDeleteBuffers);
+	qalIsBuffer = ALSYMBOL(handle, alIsBuffer);
+	qalBufferData = ALSYMBOL(handle, alBufferData);
+	qalBufferf = ALSYMBOL(handle, alBufferf);
+	qalBuffer3f = ALSYMBOL(handle, alBuffer3f);
+	qalBufferfv = ALSYMBOL(handle, alBufferfv);
+	qalBufferi = ALSYMBOL(handle, alBufferi);
+	qalBuffer3i = ALSYMBOL(handle, alBuffer3i);
+	qalBufferiv = ALSYMBOL(handle, alBufferiv);
+	qalGetBufferf = ALSYMBOL(handle, alGetBufferf);
+	qalGetBuffer3f = ALSYMBOL(handle, alGetBuffer3f);
+	qalGetBufferfv = ALSYMBOL(handle, alGetBufferfv);
+	qalGetBufferi = ALSYMBOL(handle, alGetBufferi);
+	qalGetBuffer3i = ALSYMBOL(handle, alGetBuffer3i);
+	qalGetBufferiv = ALSYMBOL(handle, alGetBufferiv);
+	qalDopplerFactor = ALSYMBOL(handle, alDopplerFactor);
+	qalDopplerVelocity = ALSYMBOL(handle, alDopplerVelocity);
+	qalSpeedOfSound = ALSYMBOL(handle, alSpeedOfSound);
+	qalDistanceModel = ALSYMBOL(handle, alDistanceModel);
 
 	/* Open the OpenAL device */
     Com_Printf("...opening OpenAL device:");
diff --git a/src/backends/generic/qgl.c b/src/backends/generic/qgl.c
index 06c593f..3b078f0 100644
--- a/src/backends/generic/qgl.c
+++ b/src/backends/generic/qgl.c
@@ -38,15 +38,14 @@
 /*
  * GL extensions
  */
-void (APIENTRY *qglLockArraysEXT)(int, int);
-void (APIENTRY *qglUnlockArraysEXT)(void);
-void (APIENTRY *qglPointParameterfEXT)(GLenum param, GLfloat value);
-void (APIENTRY *qglPointParameterfvEXT)(GLenum param, const GLfloat *value);
+void (APIENTRY *qglPointParameterfARB)(GLenum param, GLfloat value);
+void (APIENTRY *qglPointParameterfvARB)(GLenum param, const GLfloat *value);
 void (APIENTRY *qglColorTableEXT)(GLenum, GLenum, GLsizei, GLenum, GLenum,
 		const GLvoid *);
 
 void ( APIENTRY *qgl3DfxSetPaletteEXT ) ( GLuint * );
 void ( APIENTRY *qglMultiTexCoord2fARB ) ( GLenum, GLfloat, GLfloat );
+void ( APIENTRY *qglMultiTexCoord2fvARB) ( GLenum, GLfloat* );
 void ( APIENTRY *qglActiveTextureARB ) ( GLenum );
 void ( APIENTRY *qglClientActiveTextureARB ) ( GLenum );
 
@@ -54,13 +53,12 @@ void ( APIENTRY *qglClientActiveTextureARB ) ( GLenum );
 
 void QGL_EXT_Reset ( void )
 {
-	qglLockArraysEXT          = NULL;
-	qglUnlockArraysEXT 	      = NULL;
-	qglPointParameterfEXT     = NULL;
-	qglPointParameterfvEXT    = NULL;
+	qglPointParameterfARB     = NULL;
+	qglPointParameterfvARB    = NULL;
 	qglColorTableEXT          = NULL;
 	qgl3DfxSetPaletteEXT      = NULL;
 	qglMultiTexCoord2fARB     = NULL;
+	qglMultiTexCoord2fvARB    = NULL;
 	qglActiveTextureARB       = NULL;
 	qglClientActiveTextureARB = NULL;
 }
diff --git a/src/backends/generic/vid.c b/src/backends/generic/vid.c
index be5a869..27d8dc5 100644
--- a/src/backends/generic/vid.c
+++ b/src/backends/generic/vid.c
@@ -78,8 +78,6 @@ vidmode_t vid_modes[] = {
 
 /* Console variables that we need to access from this module */
 cvar_t *vid_gamma;
-cvar_t *vid_xpos;               /* X coordinate of window position */
-cvar_t *vid_ypos;               /* Y coordinate of window position */
 cvar_t *vid_fullscreen;
 
 /* Global variables used internally by this module */
@@ -209,8 +207,6 @@ void
 VID_Init(void)
 {
 	/* Create the video variables so we know how to start the graphics drivers */
-	vid_xpos = Cvar_Get("vid_xpos", "3", CVAR_ARCHIVE);
-	vid_ypos = Cvar_Get("vid_ypos", "22", CVAR_ARCHIVE);
 	vid_fullscreen = Cvar_Get("vid_fullscreen", "0", CVAR_ARCHIVE);
 	vid_gamma = Cvar_Get("vid_gamma", "1", CVAR_ARCHIVE);
 
diff --git a/src/backends/sdl/input.c b/src/backends/sdl/input.c
index b5b7701..5de226f 100644
--- a/src/backends/sdl/input.c
+++ b/src/backends/sdl/input.c
@@ -423,7 +423,8 @@ IN_Update(void)
 
 #if SDL_VERSION_ATLEAST(2, 0, 0)
 			case SDL_WINDOWEVENT:
-				if(event.window.event == SDL_WINDOWEVENT_FOCUS_LOST)
+				if(event.window.event == SDL_WINDOWEVENT_FOCUS_LOST ||
+						event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED)
 				{
 					Key_MarkAllUp();
 				}
@@ -436,6 +437,11 @@ IN_Update(void)
 				}
 #endif
 				break;
+
+			case SDL_QUIT:
+				Com_Quit();
+				
+				break;
 		}
 	}
 
diff --git a/src/backends/sdl/refresh.c b/src/backends/sdl/refresh.c
index bfd5e39..169e111 100644
--- a/src/backends/sdl/refresh.c
+++ b/src/backends/sdl/refresh.c
@@ -43,6 +43,8 @@
 
 #ifdef SDL2
 #include <SDL2/SDL.h>
+#include <SDL2/SDL_video.h>
+
 #else // SDL1.2
 #include <SDL/SDL.h>
 #endif //SDL2
@@ -66,6 +68,7 @@ SDL_Surface* window = NULL;
 #endif
 
 qboolean have_stencil = false;
+qboolean vsync_active;
 
 #ifdef X11GAMMA
 XRRCrtcGamma** gammaRamps = NULL;
@@ -602,6 +605,7 @@ GLimp_InitGraphics(qboolean fullscreen)
 
 	/* Set vsync */
 	SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, gl_swapinterval->value ? 1 : 0);
+	vsync_active = gl_swapinterval->value ? true : false;
 #endif
 
 	while (1)
@@ -661,6 +665,7 @@ GLimp_InitGraphics(qboolean fullscreen)
 
 	/* Set vsync - TODO: -1 could be set for "late swap tearing" */
 	SDL_GL_SetSwapInterval(gl_swapinterval->value ? 1 : 0);
+	vsync_active = gl_swapinterval->value ? true : false;
 #endif
 
 	/* Initialize the stencil buffer */
@@ -751,6 +756,37 @@ void GLimp_GrabInput(qboolean grab)
 }
 
 /*
+ * Returns the VSync state.
+ */
+qboolean GLimp_VsyncEnabled(void)
+{
+	return vsync_active;
+}
+
+/*
+ * Returns the current display refresh rate.
+ */
+int GLimp_GetRefreshRate(void)
+{
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+	int i;
+	int refresh = 0;
+	SDL_DisplayMode mode;
+
+	for (i = 0; i < SDL_GetNumVideoDisplays(); ++i)
+	{
+		SDL_GetCurrentDisplayMode(i, &mode);
+		refresh = refresh < mode.refresh_rate ? mode.refresh_rate : refresh;
+	}
+
+	return refresh;
+#else
+	// Asume 60hz.
+	return 60
+#endif
+}
+
+/*
  * Shuts the SDL render backend down
  */
 void
diff --git a/src/backends/unix/main.c b/src/backends/unix/main.c
index 3388cea..a4976bd 100644
--- a/src/backends/unix/main.c
+++ b/src/backends/unix/main.c
@@ -26,9 +26,8 @@
  */
 
 #include <fcntl.h>
-#include <locale.h>
 #include <sys/types.h>
-#include <sys/stat.h>
+#include <time.h>
 #include <unistd.h>
 
 #include "../../common/header/common.h"
@@ -40,6 +39,7 @@ main(int argc, char **argv)
 	int time, oldtime, newtime;
 	int verLen, i;
 	const char* versionString;
+	struct timespec t;
 
 	/* register signal handler */
 	registerHandler();
@@ -110,8 +110,8 @@ main(int argc, char **argv)
 #endif
 #endif
 
-	printf("Platform: %s\n", OSTYPE);
-	printf("Architecture: %s\n", ARCH);
+	printf("Platform: %s\n", YQ2OSTYPE);
+	printf("Architecture: %s\n", YQ2ARCH);
 
 	/* Seed PRNG */
 	randk_seed();
@@ -123,6 +123,7 @@ main(int argc, char **argv)
 	fcntl(fileno(stdin), F_SETFL, fcntl(fileno(stdin), F_GETFL, NULL) | FNDELAY);
 
 	oldtime = Sys_Milliseconds();
+	t.tv_sec = 0;
 
 	/* The legendary Quake II mainloop */
 	while (1)
@@ -130,6 +131,10 @@ main(int argc, char **argv)
 		/* find time spent rendering last frame */
 		do
 		{
+			/* Sleep 10 microseconds */
+			t.tv_nsec = 10000;
+			nanosleep(&t, NULL);
+
 			newtime = Sys_Milliseconds();
 			time = newtime - oldtime;
 		}
diff --git a/src/backends/unix/signalhandler.c b/src/backends/unix/signalhandler.c
index 2f802df..b204f5a 100644
--- a/src/backends/unix/signalhandler.c
+++ b/src/backends/unix/signalhandler.c
@@ -49,8 +49,8 @@ printBacktrace(int sig)
 
 	printf("Product:      Yamagi Quake II\n");
 	printf("Version:      %s\n", YQ2VERSION);
-	printf("Plattform:    %s\n", OSTYPE);
-	printf("Architecture: %s\n", ARCH);
+	printf("Platform:     %s\n", YQ2OSTYPE);
+	printf("Architecture: %s\n", YQ2ARCH);
 	printf("Compiler:     %s\n", __VERSION__);
 	printf("Signal:       %i\n", sig);
 	printf("\nBacktrace:\n");
@@ -70,8 +70,8 @@ printBacktrace(int sig)
 {
 	printf("Product:      Yamagi Quake II\n");
 	printf("Version:      %s\n", YQ2VERSION);
-	printf("Plattform:    %s\n", OSTYPE);
-	printf("Architecture: %s\n", ARCH);
+	printf("Platform:     %s\n", YQ2OSTYPE);
+	printf("Architecture: %s\n", YQ2ARCH);
 	printf("Compiler:     %s\n", __VERSION__);
 	printf("Signal:       %i\n", sig);
 	printf("\nBacktrace:\n");
@@ -97,7 +97,7 @@ signalhandler(int sig)
 	printf("    - game.so (the game.so of the mod you were playing\n");
 	printf("      when the game crashed. baseq2/game.so for the\n");
 	printf("      main game)\n\n");
-	printf(" - Any other data which you think might be usefull\n");
+	printf(" - Any other data which you think might be useful\n");
 	printf("\nThank you very much for your help, making Yamagi Quake\n");
 	printf("II an even better source port. It's much appreciated.\n");
 	printf("\n=======================================================\n\n");
diff --git a/src/backends/unix/system.c b/src/backends/unix/system.c
index 13e6a32..d3b31e2 100644
--- a/src/backends/unix/system.c
+++ b/src/backends/unix/system.c
@@ -100,6 +100,12 @@ Sys_Milliseconds(void)
 }
 
 void
+Sys_Sleep(int msec)
+{
+	usleep((unsigned int)1000 * msec);
+}
+
+void
 Sys_Mkdir(char *path)
 {
 	mkdir(path, 0755);
@@ -480,7 +486,21 @@ Sys_GetHomeDir(void)
 void *
 Sys_GetProcAddress(void *handle, const char *sym)
 {
-	return dlsym(handle, sym);
+    if (handle == NULL)
+    {
+#ifdef RTLD_DEFAULT
+        return dlsym(RTLD_DEFAULT, sym);
+#else
+        /* POSIX suggests that this is a portable equivalent */
+        static void *global_namespace = NULL;
+
+        if (global_namespace == NULL)
+            global_namespace = dlopen(NULL, RTLD_GLOBAL|RTLD_LAZY);
+
+        return dlsym(global_namespace, sym);
+#endif
+    }
+    return dlsym(handle, sym);
 }
 
 void *
diff --git a/src/backends/windows/system.c b/src/backends/windows/system.c
index 3d73a06..3d71004 100644
--- a/src/backends/windows/system.c
+++ b/src/backends/windows/system.c
@@ -429,6 +429,12 @@ Sys_Milliseconds(void)
 	return curtime;
 }
 
+void
+Sys_Sleep(int msec)
+{
+	Sleep(msec);
+}
+
 /* ======================================================================= */
 
 static qboolean
@@ -739,8 +745,8 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
 #endif
 #endif
 
-	printf("Platform: %s\n", OSTYPE);
-	printf("Architecture: %s\n", ARCH);
+	printf("Platform: %s\n", YQ2OSTYPE);
+	printf("Architecture: %s\n", YQ2ARCH);
 
 	/* Seed PRNG */
 	randk_seed();
diff --git a/src/client/cl_cin.c b/src/client/cl_cin.c
index 1ef6acf..85b49a2 100644
--- a/src/client/cl_cin.c
+++ b/src/client/cl_cin.c
@@ -576,6 +576,12 @@ SCR_PlayCinematic(char *arg)
 	byte *palette;
 	char name[MAX_OSPATH], *dot;
 
+	/* Make sure that all keys are marked up. Under
+	   some circumstances cinematics are started with
+	   at least one key marked down, causing them to
+	   abort right after the first frame... */
+	Key_MarkAllUp();
+
 	/* make sure background music is not playing */
 #ifdef CDA
 	CDAudio_Stop();
diff --git a/src/client/cl_download.c b/src/client/cl_download.c
index cfc5736..e4891c7 100644
--- a/src/client/cl_download.c
+++ b/src/client/cl_download.c
@@ -418,6 +418,7 @@ CL_RequestNextDownload(void)
 
 	MSG_WriteByte(&cls.netchan.message, clc_stringcmd);
 	MSG_WriteString(&cls.netchan.message, va("begin %i\n", precache_spawncount));
+	cls.forcePacket = true;
 }
 
 void
@@ -500,6 +501,7 @@ CL_CheckOrDownloadFile(char *filename)
 	}
 
 	cls.downloadnumber++;
+	cls.forcePacket = true;
 
 	return false;
 }
@@ -606,6 +608,7 @@ CL_ParseDownload(void)
 
 		MSG_WriteByte(&cls.netchan.message, clc_stringcmd);
 		SZ_Print(&cls.netchan.message, "nextdl");
+		cls.forcePacket = true;
 	}
 	else
 	{
diff --git a/src/client/cl_effects.c b/src/client/cl_effects.c
index e8befdb..dc3c7d9 100644
--- a/src/client/cl_effects.c
+++ b/src/client/cl_effects.c
@@ -341,7 +341,8 @@ CL_AddMuzzleFlash2(void)
 
 	if (flash_number > 210)
 	{
-		Com_Error(ERR_DROP, "CL_AddMuzzleFlash2: bad offset");
+		Com_DPrintf("CL_AddMuzzleFlash2: bad offset");
+		return;
 	}
 
 	/* locate the origin */
diff --git a/src/client/cl_input.c b/src/client/cl_input.c
index 828edcf..71ad088 100644
--- a/src/client/cl_input.c
+++ b/src/client/cl_input.c
@@ -427,12 +427,12 @@ CL_AdjustAngles(void)
 
 	if (in_speed.state & 1)
 	{
-		speed = cls.frametime * cl_anglespeedkey->value;
+		speed = cls.nframetime * cl_anglespeedkey->value;
 	}
 
 	else
 	{
-		speed = cls.frametime;
+		speed = cls.nframetime;
 	}
 
 	if (!(in_strafe.state & 1))
@@ -553,7 +553,7 @@ CL_FinishMove(usercmd_t *cmd)
 	}
 
 	/* send milliseconds of time to apply the move */
-	ms = cls.frametime * 1000;
+	ms = cls.nframetime * 1000;
 
 	if (ms > 250)
 	{
@@ -576,36 +576,6 @@ CL_FinishMove(usercmd_t *cmd)
 	cmd->lightlevel = (byte)cl_lightlevel->value;
 }
 
-usercmd_t
-CL_CreateCmd(void)
-{
-	usercmd_t cmd;
-
-	frame_msec = sys_frame_time - old_sys_frame_time;
-
-	if (frame_msec < 1)
-	{
-		frame_msec = 1;
-	}
-
-	if (frame_msec > 200)
-	{
-		frame_msec = 200;
-	}
-
-	/* get basic movement from keyboard */
-	CL_BaseMove(&cmd);
-
-	/* allow mice or other external controllers to add to the move */
-	IN_Move(&cmd);
-
-	CL_FinishMove(&cmd);
-
-	old_sys_frame_time = sys_frame_time;
-
-	return cmd;
-}
-
 void
 IN_CenterView(void)
 {
@@ -663,6 +633,123 @@ CL_InitInput(void)
 }
 
 void
+CL_RefreshCmd(void)
+{
+	int ms;
+	usercmd_t *cmd;
+
+	// CMD to fill
+	cmd = &cl.cmds[cls.netchan.outgoing_sequence & (CMD_BACKUP - 1)];
+
+	// Calculate delta
+	frame_msec = sys_frame_time - old_sys_frame_time;
+
+	// Check bounds
+	if (frame_msec < 1)
+	{
+		return;
+	}
+	else if (frame_msec > 200)
+	{
+		frame_msec = 200;
+	}
+
+	// Add movement
+	CL_BaseMove(cmd);
+	IN_Move(cmd);
+
+	// Clamp angels for prediction
+	CL_ClampPitch();
+
+	cmd->angles[0] = ANGLE2SHORT(cl.viewangles[0]);
+	cmd->angles[1] = ANGLE2SHORT(cl.viewangles[1]);
+	cmd->angles[2] = ANGLE2SHORT(cl.viewangles[2]);
+
+	// Update time for prediction
+	ms = (int)(cls.nframetime * 1000.0f);
+
+	if (ms > 250)
+	{
+		ms = 100;
+	}
+
+	cmd->msec = ms;
+
+	// Update frame time for the next call
+	old_sys_frame_time = sys_frame_time;
+
+	// Important events are send immediately
+	if (((in_attack.state & 2)) || (in_use.state & 2))
+	{
+		cls.forcePacket = true;
+	}
+}
+
+void
+CL_RefreshMove(void)
+{
+	usercmd_t *cmd;
+
+	// CMD to fill
+	cmd = &cl.cmds[cls.netchan.outgoing_sequence & (CMD_BACKUP - 1)];
+
+	// Calculate delta
+	frame_msec = sys_frame_time - old_sys_frame_time;
+
+	// Check bounds
+	if (frame_msec < 1)
+	{
+		return;
+	}
+	else if (frame_msec > 200)
+	{
+		frame_msec = 200;
+	}
+
+	// Add movement
+	CL_BaseMove(cmd);
+	IN_Move(cmd);
+
+	old_sys_frame_time = sys_frame_time;
+}
+
+void
+CL_FinalizeCmd(void)
+{
+	usercmd_t *cmd;
+
+	// CMD to fill
+	cmd = &cl.cmds[cls.netchan.outgoing_sequence & (CMD_BACKUP - 1)];
+
+	// Mouse button events
+	if (in_attack.state & 3)
+	{
+		cmd->buttons |= BUTTON_ATTACK;
+	}
+
+	in_attack.state &= ~2;
+
+	if (in_use.state & 3)
+	{
+		cmd->buttons |= BUTTON_USE;
+	}
+
+	in_use.state &= ~2;
+
+	// Keyboard events
+	if (anykeydown && cls.key_dest == key_game)
+	{
+		cmd->buttons |= BUTTON_ANY;
+	}
+
+	cmd->impulse = in_impulse;
+	in_impulse = 0;
+
+	// Set light level for muzzle flash
+	cmd->lightlevel = (byte)cl_lightlevel->value;
+}
+
+void
 CL_SendCmd(void)
 {
 	sizebuf_t buf;
@@ -672,14 +759,14 @@ CL_SendCmd(void)
 	usercmd_t nullcmd;
 	int checksumIndex;
 
-	/* build a command even if not connected */
+	memset(&buf, 0, sizeof(buf));
 
 	/* save this command off for prediction */
 	i = cls.netchan.outgoing_sequence & (CMD_BACKUP - 1);
 	cmd = &cl.cmds[i];
 	cl.cmd_time[i] = cls.realtime; /* for netgraph ping calculation */
 
-	*cmd = CL_CreateCmd();
+	CL_FinalizeCmd();
 
 	cl.cmd = *cmd;
 
@@ -691,10 +778,9 @@ CL_SendCmd(void)
 	if (cls.state == ca_connected)
 	{
 		if (cls.netchan.message.cursize ||
-			(curtime - cls.netchan.last_sent > 100))
+			(curtime - cls.netchan.last_sent > 1000))
 		{
-            byte zero_data = 0;
-			Netchan_Transmit(&cls.netchan, 0, &zero_data);
+			Netchan_Transmit(&cls.netchan, 0, buf.data);
 		}
 
 		return;
@@ -761,5 +847,9 @@ CL_SendCmd(void)
 
 	/* deliver the message */
 	Netchan_Transmit(&cls.netchan, buf.cursize, buf.data);
+
+	/* Reinit the current cmd buffer */
+	cmd = &cl.cmds[cls.netchan.outgoing_sequence & (CMD_BACKUP - 1)];
+	memset(cmd, 0, sizeof(*cmd));
 }
 
diff --git a/src/client/cl_lights.c b/src/client/cl_lights.c
index 0b2a54a..04ec044 100644
--- a/src/client/cl_lights.c
+++ b/src/client/cl_lights.c
@@ -188,7 +188,7 @@ CL_RunDLights(void)
 			return;
 		}
 
-		dl->radius -= cls.frametime * dl->decay;
+		dl->radius -= cls.rframetime * dl->decay;
 
 		if (dl->radius < 0)
 		{
diff --git a/src/client/cl_main.c b/src/client/cl_main.c
index f2035ec..3c3566b 100644
--- a/src/client/cl_main.c
+++ b/src/client/cl_main.c
@@ -37,21 +37,10 @@ void CL_CheckForResend(void);
 
 cvar_t *freelook;
 
-cvar_t *adr0;
-cvar_t *adr1;
-cvar_t *adr2;
-cvar_t *adr3;
-cvar_t *adr4;
-cvar_t *adr5;
-cvar_t *adr6;
-cvar_t *adr7;
-cvar_t *adr8;
-
 cvar_t *rcon_client_password;
 cvar_t *rcon_address;
 
 cvar_t *cl_noskins;
-cvar_t *cl_autoskins;
 cvar_t *cl_footsteps;
 cvar_t *cl_timeout;
 cvar_t *cl_predict;
@@ -62,6 +51,7 @@ cvar_t *cl_add_particles;
 cvar_t *cl_add_lights;
 cvar_t *cl_add_entities;
 cvar_t *cl_add_blend;
+cvar_t *cl_async;
 
 cvar_t *cl_shownet;
 cvar_t *cl_showmiss;
@@ -82,8 +72,6 @@ cvar_t *m_side;
 cvar_t *cl_lightlevel;
 
 /* userinfo */
-cvar_t *info_password;
-cvar_t *info_spectator;
 cvar_t *name;
 cvar_t *skin;
 cvar_t *rate;
@@ -95,6 +83,7 @@ cvar_t *hand;
 cvar_t *gender;
 cvar_t *gender_auto;
 
+cvar_t *gl_maxfps;
 
 cvar_t	*gl_stereo;
 cvar_t	*gl_stereo_separation;
@@ -484,19 +473,9 @@ CL_InitLocal(void)
 
 	CL_InitInput();
 
-	adr0 = Cvar_Get("adr0", "", CVAR_ARCHIVE);
-	adr1 = Cvar_Get("adr1", "", CVAR_ARCHIVE);
-	adr2 = Cvar_Get("adr2", "", CVAR_ARCHIVE);
-	adr3 = Cvar_Get("adr3", "", CVAR_ARCHIVE);
-	adr4 = Cvar_Get("adr4", "", CVAR_ARCHIVE);
-	adr5 = Cvar_Get("adr5", "", CVAR_ARCHIVE);
-	adr6 = Cvar_Get("adr6", "", CVAR_ARCHIVE);
-	adr7 = Cvar_Get("adr7", "", CVAR_ARCHIVE);
-	adr8 = Cvar_Get("adr8", "", CVAR_ARCHIVE);
-
+	/* register our variables */
 	cin_force43 = Cvar_Get("cin_force43", "1", 0);
 
-	/* register our variables */
 	cl_add_blend = Cvar_Get("cl_blend", "1", 0);
 	cl_add_lights = Cvar_Get("cl_lights", "1", 0);
 	cl_add_particles = Cvar_Get("cl_particles", "1", 0);
@@ -504,10 +483,10 @@ CL_InitLocal(void)
 	cl_gun = Cvar_Get("cl_gun", "2", CVAR_ARCHIVE);
 	cl_footsteps = Cvar_Get("cl_footsteps", "1", 0);
 	cl_noskins = Cvar_Get("cl_noskins", "0", 0);
-	cl_autoskins = Cvar_Get("cl_autoskins", "0", 0);
 	cl_predict = Cvar_Get("cl_predict", "1", 0);
-	cl_maxfps = Cvar_Get("cl_maxfps", "95", CVAR_ARCHIVE);
+	cl_maxfps = Cvar_Get("cl_maxfps", "60", CVAR_ARCHIVE);
 	cl_drawfps = Cvar_Get("cl_drawfps", "0", CVAR_ARCHIVE);
+	cl_async = Cvar_Get("cl_async", "1", CVAR_ARCHIVE);
 
 	cl_upspeed = Cvar_Get("cl_upspeed", "200", 0);
 	cl_forwardspeed = Cvar_Get("cl_forwardspeed", "200", 0);
@@ -534,6 +513,8 @@ CL_InitLocal(void)
 	cl_paused = Cvar_Get("paused", "0", 0);
 	cl_timedemo = Cvar_Get("timedemo", "0", 0);
 
+	gl_maxfps = Cvar_Get("gl_maxfps", "95", CVAR_ARCHIVE);
+
 	gl_stereo = Cvar_Get( "gl_stereo", "0", CVAR_ARCHIVE );
 	gl_stereo_separation = Cvar_Get( "gl_stereo_separation", "1", CVAR_ARCHIVE );
 	gl_stereo_convergence = Cvar_Get( "gl_stereo_convergence", "1.4", CVAR_ARCHIVE );
@@ -544,8 +525,6 @@ CL_InitLocal(void)
 	cl_lightlevel = Cvar_Get("gl_lightlevel", "0", 0);
 
 	/* userinfo */
-	info_password = Cvar_Get("password", "", CVAR_USERINFO);
-	info_spectator = Cvar_Get("spectator", "0", CVAR_USERINFO);
 	name = Cvar_Get("name", "unnamed", CVAR_USERINFO | CVAR_ARCHIVE);
 	skin = Cvar_Get("skin", "male/grunt", CVAR_USERINFO | CVAR_ARCHIVE);
 	rate = Cvar_Get("rate", "8000", CVAR_USERINFO | CVAR_ARCHIVE);
@@ -639,6 +618,8 @@ CL_WriteConfiguration(void)
 	fprintf(f, "// generated by quake, do not modify\n");
 
 	Key_WriteBindings(f);
+
+	fflush(f);
 	fclose(f);
 
 	Cvar_WriteVariables(path);
@@ -726,66 +707,68 @@ CL_UpdateWindowedMouse(void)
 	}
 }
 
-void
-CL_SendCommand(void)
-{
-	/* update windowed_mouse cvar */
-	CL_UpdateWindowedMouse();
-
-	/* get new key events */
-	Sys_SendKeyEvents();
-
-	/* process console commands */
-	Cbuf_Execute();
-
-	/* fix any cheating cvars */
-	CL_FixCvarCheats();
-
-	/* send intentions now */
-	CL_SendCmd();
-
-	/* resend a connection request if necessary */
-	CL_CheckForResend();
-}
+qboolean GLimp_VsyncEnabled(void);
+int GLimp_GetRefreshRate(void);
 
 void
 CL_Frame(int msec)
 {
-	static int extratime;
+	int nfps;
+	int rfps;
+
 	static int lasttimecalled;
 
+	static int packetdelta = 1000;
+	static int renderdelta = 1000;
+	static int miscdelta = 1000;
+
+	qboolean packetframe = true;
+	qboolean renderframe = true;
+	qboolean miscframe = true;
+
 	if (dedicated->value)
 	{
 		return;
 	}
 
-	extratime += msec;
-
-	if (!cl_timedemo->value)
+	// Target render frame rate
+	if (GLimp_VsyncEnabled())
 	{
-		if ((cls.state == ca_connected) && (extratime < 100))
-		{
-			return; /* don't flood packets out while connecting */
-		}
+		rfps = GLimp_GetRefreshRate();
 
-		if (extratime < 1000 / cl_maxfps->value)
+		if (rfps > gl_maxfps->value)
 		{
-			return; /* framerate is too high */
+			rfps = (int)gl_maxfps->value;
 		}
 	}
+	else
+	{
+		rfps = (int)gl_maxfps->value;
+	}
 
-	/* decide the simulation time */
-	cls.frametime = extratime / 1000.0;
+	// The network framerate must not be higher then the render framerate
+	nfps = (cl_maxfps->value > rfps) ? rfps : cl_maxfps->value;
 
-	cl.time += extratime;
+	// Adjust deltas
+	packetdelta += msec;
+	renderdelta += msec;
+	miscdelta += msec;
 
+	// Calculate simulation time
+	cls.nframetime = packetdelta * 0.001f;
+	cls.rframetime = renderdelta * 0.001f;
 	cls.realtime = curtime;
+	cl.time += msec;
 
-	extratime = 0;
+	// Don't extrapolate too far ahead
+	if (cls.nframetime > 0.5f)
+	{
+		cls.nframetime = 0.5f;
+	}
 
-	if (cls.frametime > (1.0 / 5))
+	if (cls.rframetime > 0.5f)
 	{
-		cls.frametime = (1.0 / 5);
+		cls.rframetime = 0.5f;
 	}
 
 	/* if in the debugger last frame, don't timeout */
@@ -794,77 +777,176 @@ CL_Frame(int msec)
 		cls.netchan.last_received = Sys_Milliseconds();
 	}
 
-	/* fetch results from server */
-	CL_ReadPackets();
+	if (!cl_timedemo->value)
+	{
+		// Don't flood while connecting
+		if ((cls.state == ca_connected) && (packetdelta < 100))
+		{
+			packetframe = false;
+		}
+
+		if (cl_async->value)
+		{
+			// Network frames
+			if (packetdelta < (1000.0f / nfps))
+			{
+				packetframe = false;
+			}
+			else if (cls.nframetime == cls.rframetime)
+			{
+				packetframe = false;
+			}
+
+			// Render frames
+			if (renderdelta < (1000.0f / rfps))
+			{
+				renderframe = false;
+			}
 
-	/* send a new command message to the server */
-	CL_SendCommand();
+			// Misc. stuff at 10 FPS
+			if (miscdelta < 100.0f)
+			{
+				miscframe = false;
+			}
+		}
+		else
+		{
+			// Cap frames at gl_maxfps
+			if (renderdelta < (1000.0f / rfps))
+			{
+				renderframe = false;
+				packetframe = false;
+				miscframe = false;
+			}
+		}
 
-	/* predict all unacknowledged movements */
-	CL_PredictMovement();
+		// Throttle the game a little bit. 1000 FPS are enough.
+		if (!packetframe && !renderframe && !cls.forcePacket && !userinfo_modified)
+		{
+			double frametime = (1000.0 / cl_maxfps->value - packetdelta) <= (1000.0 / gl_maxfps->value - renderdelta) ?
+							   (1000.0 / cl_maxfps->value - packetdelta) : (1000.0 / gl_maxfps->value - renderdelta);
 
-	/* allow renderer DLL change */
-	VID_CheckChanges();
+			if (frametime > 1)
+			{
+				Sys_Sleep(1);
+			}
 
-	if (!cl.refresh_prepped && (cls.state == ca_active))
+			return;
+		}
+	}
+	else if (msec < 1)
 	{
-		CL_PrepRefresh();
+		return;
 	}
 
-	/* update the screen */
-	if (host_speeds->value)
+	// Update input stuff
+	if (packetframe || renderframe)
 	{
-		time_before_ref = Sys_Milliseconds();
+		CL_ReadPackets();
+		CL_UpdateWindowedMouse();
+		Sys_SendKeyEvents();
+		Cbuf_Execute();
+		CL_FixCvarCheats();
+
+		if (cls.state > ca_connecting)
+		{
+			CL_RefreshCmd();
+		}
+		else
+		{
+			CL_RefreshMove();
+		}
 	}
 
-	SCR_UpdateScreen();
+	if (cls.forcePacket || userinfo_modified)
+	{
+		packetframe = true;
+		cls.forcePacket = false;
+	}
 
-	if (host_speeds->value)
+	if (packetframe)
 	{
-		time_after_ref = Sys_Milliseconds();
+		packetdelta = 0;
+
+		CL_SendCmd();
+		CL_CheckForResend();
 	}
 
-	/* update audio */
-	S_Update(cl.refdef.vieworg, cl.v_forward, cl.v_right, cl.v_up);
-#ifdef CDA
-	CDAudio_Update();
-#endif
+	if (renderframe)
+	{
+		renderdelta = 0;
+
+		if (miscframe)
+		{
+			miscdelta = 0;
+
+			VID_CheckChanges();
+		}
 
-	/* advance local effects for next frame */
-	CL_RunDLights();
+		CL_PredictMovement();
 
-	CL_RunLightStyles();
+		if (!cl.refresh_prepped && (cls.state == ca_active))
+		{
+			CL_PrepRefresh();
+		}
+
+		/* update the screen */
+		if (host_speeds->value)
+		{
+			time_before_ref = Sys_Milliseconds();
+		}
 
-	SCR_RunCinematic();
+		SCR_UpdateScreen();
 
-	SCR_RunConsole();
+		if (host_speeds->value)
+		{
+			time_after_ref = Sys_Milliseconds();
+		}
 
-	cls.framecount++;
+		/* update audio */
+		S_Update(cl.refdef.vieworg, cl.v_forward, cl.v_right, cl.v_up);
 
-	if (log_stats->value)
-	{
-		if (cls.state == ca_active)
+#ifdef CDA
+		if (miscframe)
 		{
-			if (!lasttimecalled)
-			{
-				lasttimecalled = Sys_Milliseconds();
+			CDAudio_Update();
+		}
+#endif
 
-				if (log_stats_file)
-				{
-					fprintf(log_stats_file, "0\n");
-				}
-			}
+		/* advance local effects for next frame */
+		CL_RunDLights();
+		CL_RunLightStyles();
+		SCR_RunCinematic();
+		SCR_RunConsole();
 
-			else
-			{
-				int now = Sys_Milliseconds();
+		/* Update framecounter */
+		cls.framecount++;
 
-				if (log_stats_file)
+		if (log_stats->value)
+		{
+			if (cls.state == ca_active)
+			{
+				if (!lasttimecalled)
 				{
-					fprintf(log_stats_file, "%d\n", now - lasttimecalled);
+					lasttimecalled = Sys_Milliseconds();
+
+					if (log_stats_file)
+					{
+						fprintf(log_stats_file, "0\n");
+					}
 				}
 
-				lasttimecalled = now;
+				else
+				{
+					int now = Sys_Milliseconds();
+
+					if (log_stats_file)
+					{
+						fprintf(log_stats_file, "%d\n", now - lasttimecalled);
+					}
+
+					lasttimecalled = now;
+				}
 			}
 		}
 	}
diff --git a/src/client/cl_prediction.c b/src/client/cl_prediction.c
index 8fe1aff..a451e23 100644
--- a/src/client/cl_prediction.c
+++ b/src/client/cl_prediction.c
@@ -227,12 +227,10 @@ CL_PredictMovement(void)
 {
 	int ack, current;
 	int frame;
-	int oldframe;
 	usercmd_t *cmd;
 	pmove_t pm;
 	int i;
 	int step;
-	int oldz;
 
 	if (cls.state != ca_active)
 	{
@@ -272,20 +270,24 @@ CL_PredictMovement(void)
 	}
 
 	/* copy current state to pmove */
+	memset (&pm, 0, sizeof(pm));
 	pm.trace = CL_PMTrace;
 	pm.pointcontents = CL_PMpointcontents;
-	pm_airaccelerate = strtod(cl.configstrings[CS_AIRACCEL], (char **)NULL);
+	pm_airaccelerate = atof(cl.configstrings[CS_AIRACCEL]);
 	pm.s = cl.frame.playerstate.pmove;
 
-	VectorSet(pm.mins, -16, -16, -24);
-	VectorSet(pm.maxs, 16, 16, 32);
-
 	/* run frames */
-	while (++ack < current)
+	while (++ack <= current)
 	{
 		frame = ack & (CMD_BACKUP - 1);
 		cmd = &cl.cmds[frame];
 
+		// Ignore null entries
+		if (!cmd->msec)
+		{
+			continue;
+		}
+
 		pm.cmd = *cmd;
 		Pmove(&pm);
 
@@ -293,14 +295,14 @@ CL_PredictMovement(void)
 		VectorCopy(pm.s.origin, cl.predicted_origins[frame]);
 	}
 
-	oldframe = (ack - 2) & (CMD_BACKUP - 1);
-	oldz = cl.predicted_origins[oldframe][2];
-	step = pm.s.origin[2] - oldz;
+	step = pm.s.origin[2] - (int)(cl.predicted_origin[2] * 8);
 
-	if ((step > 63) && (step < 160) && (pm.s.pm_flags & PMF_ON_GROUND))
+	if (((step > 126 && step < 130))
+		&& !VectorCompare((float *)pm.s.velocity, vec3_origin)
+		&& (pm.s.pm_flags & PMF_ON_GROUND))
 	{
 		cl.predicted_step = step * 0.125f;
-		cl.predicted_step_time = cls.realtime - cls.frametime * 500;
+		cl.predicted_step_time = cls.realtime - (int)(cls.nframetime * 500);
 	}
 
 	/* copy results out for rendering */
diff --git a/src/client/cl_screen.c b/src/client/cl_screen.c
index 5459db2..5b8eb7b 100644
--- a/src/client/cl_screen.c
+++ b/src/client/cl_screen.c
@@ -319,7 +319,7 @@ SCR_DrawCenterString(void)
 void
 SCR_CheckDrawCenterString(void)
 {
-	scr_centertime_off -= cls.frametime;
+	scr_centertime_off -= cls.rframetime;
 
 	if (scr_centertime_off <= 0)
 	{
@@ -514,7 +514,7 @@ SCR_RunConsole(void)
 
 	if (scr_conlines < scr_con_current)
 	{
-		scr_con_current -= scr_conspeed->value * cls.frametime;
+		scr_con_current -= scr_conspeed->value * cls.rframetime;
 
 		if (scr_conlines > scr_con_current)
 		{
@@ -523,7 +523,7 @@ SCR_RunConsole(void)
 	}
 	else if (scr_conlines > scr_con_current)
 	{
-		scr_con_current += scr_conspeed->value * cls.frametime;
+		scr_con_current += scr_conspeed->value * cls.rframetime;
 
 		if (scr_conlines < scr_con_current)
 		{
@@ -1541,13 +1541,13 @@ SCR_UpdateScreen(void)
 			if (cl_drawfps->value)
 			{
 				char s[8];
-				sprintf(s, "%3.0ffps", 1 / cls.frametime);
+				sprintf(s, "%3.0ffps", 1 / cls.rframetime);
 				DrawString(viddef.width - 64, 0, s);
 			}
 
 			if (scr_timegraph->value)
 			{
-				SCR_DebugGraph(cls.frametime * 300, 0);
+				SCR_DebugGraph(cls.rframetime * 300, 0);
 			}
 
 			if (scr_debuggraph->value || scr_timegraph->value ||
diff --git a/src/client/header/client.h b/src/client/header/client.h
index e1586e4..eacad82 100644
--- a/src/client/header/client.h
+++ b/src/client/header/client.h
@@ -210,7 +210,8 @@ typedef struct
 
 	int			framecount;
 	int			realtime; /* always increasing, no clamping, etc */
-	float		frametime; /* seconds since last frame */
+	float		rframetime; /* seconds since last render frame */
+	float		nframetime; /* network frame time */
 
 	/* screen rendering information */
 	float		disable_screen; /* showing loading plaque between levels */
@@ -231,6 +232,8 @@ typedef struct
 
 	int			challenge; /* from the server to use for connecting */
 
+	qboolean	forcePacket; /* Forces a package to be send at the next frame. */
+
 	FILE		*download; /* file transfer from server */
 	char		downloadtempname[MAX_OSPATH];
 	char		downloadname[MAX_OSPATH];
@@ -258,7 +261,6 @@ extern	cvar_t	*cl_add_entities;
 extern	cvar_t	*cl_predict;
 extern	cvar_t	*cl_footsteps;
 extern	cvar_t	*cl_noskins;
-extern	cvar_t	*cl_autoskins;
 extern	cvar_t	*cl_upspeed;
 extern	cvar_t	*cl_forwardspeed;
 extern	cvar_t	*cl_sidespeed;
@@ -438,7 +440,9 @@ extern 	kbutton_t 	in_strafe;
 extern 	kbutton_t 	in_speed;
 
 void CL_InitInput (void);
+void CL_RefreshCmd(void);
 void CL_SendCmd (void);
+void CL_RefreshMove(void);
 void CL_SendMove (usercmd_t *cmd);
 
 void CL_ClearState (void);
diff --git a/src/client/menu/menu.c b/src/client/menu/menu.c
index 57ded35..a114e5b 100644
--- a/src/client/menu/menu.c
+++ b/src/client/menu/menu.c
@@ -1696,7 +1696,7 @@ static const char *xatcredits[] =
     "Chris Toft",
     "Juan Valdes",
     "",
-    "+THANKS TO INTERGRAPH COMPUTER SYTEMS",
+    "+THANKS TO INTERGRAPH COMPUTER SYSTEMS",
     "+IN PARTICULAR:",
     "",
     "Michael T. Nicolaou",
@@ -3783,38 +3783,15 @@ extern char **FS_ListFiles(char *, int *, unsigned, unsigned);
 static qboolean
 PlayerConfig_ScanDirectories(void)
 {
-	char findname[1024];
 	char scratch[1024];
 	int ndirs = 0, npms = 0;
 	char **dirnames = NULL;
-	char *path = NULL;
 	int i;
 
 	s_numplayermodels = 0;
 
 	/* get a list of directories */
-	do
-	{
-		path = FS_NextPath(path);
-
-		/* If FS_NextPath returns NULL we get a SEGV on the next line.
-		   On other platforms this propably works (path becomes
-		   the null string or something like that). */
-		if (path == NULL)
-		{
-			break;
-		}
-
-		Com_sprintf(findname, sizeof(findname), "%s/players/*.*", path);
-
-		if ((dirnames = FS_ListFiles(findname, &ndirs, SFF_SUBDIR, 0)) != 0)
-		{
-			break;
-		}
-	}
-	while (path);
-
-	if (!dirnames)
+	if ((dirnames = FS_ListFiles2("players/*", &ndirs, SFF_SUBDIR, 0)) == NULL)
 	{
 		return false;
 	}
@@ -3833,6 +3810,7 @@ PlayerConfig_ScanDirectories(void)
 		char *a, *b, *c;
 		char **pcxnames;
 		char **skinnames;
+		fileHandle_t f;
 		int npcxfiles;
 		int nskins = 0;
 
@@ -3845,23 +3823,22 @@ PlayerConfig_ScanDirectories(void)
 		strcpy(scratch, dirnames[i]);
 		strcat(scratch, "/tris.md2");
 
-		if (!Sys_FindFirst(scratch, 0, SFF_SUBDIR | SFF_HIDDEN | SFF_SYSTEM))
+		if (FS_FOpenFile(scratch, &f, false) == 0)
 		{
 			free(dirnames[i]);
 			dirnames[i] = 0;
-			Sys_FindClose();
 			continue;
 		}
-
-		Sys_FindClose();
+		else
+		{
+			FS_FCloseFile(f);
+		}
 
 		/* verify the existence of at least one pcx skin */
 		strcpy(scratch, dirnames[i]);
 		strcat(scratch, "/*.pcx");
-		pcxnames = FS_ListFiles(scratch, &npcxfiles,
-				0, SFF_SUBDIR | SFF_HIDDEN | SFF_SYSTEM);
 
-		if (!pcxnames)
+		if ((pcxnames = FS_ListFiles2(scratch, &npcxfiles, 0, SFF_SUBDIR | SFF_HIDDEN | SFF_SYSTEM)) == NULL)
 		{
 			free(dirnames[i]);
 			dirnames[i] = 0;
@@ -3941,10 +3918,8 @@ PlayerConfig_ScanDirectories(void)
 			c = b;
 		}
 
-		Q_strlcpy(s_pmi[s_numplayermodels].displayname, c + 1,
-				sizeof(s_pmi[s_numplayermodels].displayname));
-		Q_strlcpy(s_pmi[s_numplayermodels].directory, c + 1,
-				sizeof(s_pmi[s_numplayermodels].directory));
+		Q_strlcpy(s_pmi[s_numplayermodels].displayname, c + 1, sizeof(s_pmi[s_numplayermodels].displayname));
+		Q_strlcpy(s_pmi[s_numplayermodels].directory, c + 1, sizeof(s_pmi[s_numplayermodels].directory));
 
 		FreeFileList(pcxnames, npcxfiles);
 
diff --git a/src/client/refresh/header/local.h b/src/client/refresh/header/local.h
index a5befd1..1fa7aae 100644
--- a/src/client/refresh/header/local.h
+++ b/src/client/refresh/header/local.h
@@ -59,6 +59,7 @@
 #endif
 
 #ifndef GL_VERSION_1_3
+ #define GL_TEXTURE0 0x84C0
  #define GL_TEXTURE1 0x84C1
 #endif
 
@@ -80,8 +81,6 @@
 #define REF_VERSION "Yamagi Quake II OpenGL Refresher"
 #define MAX_LBM_HEIGHT 480
 #define BACKFACE_EPSILON 0.01
-#define DYNAMIC_LIGHT_WIDTH 128
-#define DYNAMIC_LIGHT_HEIGHT 128
 #define LIGHTMAP_BYTES 4
 #define MAX_LIGHTMAPS 128
 #define GL_LIGHTMAP_FORMAT GL_RGBA
@@ -95,7 +94,6 @@
 /* fall over */
 #define ROLL 2
 
-char *strlwr(char *s);
 extern viddef_t vid;
 
 /*
@@ -207,7 +205,6 @@ extern cvar_t *gl_drawworld;
 extern cvar_t *gl_speeds;
 extern cvar_t *gl_fullbright;
 extern cvar_t *gl_novis;
-extern cvar_t *gl_nocull;
 extern cvar_t *gl_lerpmodels;
 
 extern cvar_t *gl_lightlevel;
@@ -215,12 +212,10 @@ extern cvar_t *gl_overbrightbits;
 
 extern cvar_t *gl_vertex_arrays;
 
-extern cvar_t *gl_ext_swapinterval;
-extern cvar_t *gl_ext_palettedtexture;
-extern cvar_t *gl_ext_multitexture;
-extern cvar_t *gl_ext_pointparameters;
-extern cvar_t *gl_ext_compiled_vertex_array;
-extern cvar_t *gl_ext_mtexcombine;
+extern cvar_t *gl_palettedtexture;
+extern cvar_t *gl_multitexture;
+extern cvar_t *gl_pointparameters;
+extern cvar_t *gl_mtexcombine;
 
 extern cvar_t *gl_particle_min_size;
 extern cvar_t *gl_particle_max_size;
@@ -229,10 +224,7 @@ extern cvar_t *gl_particle_att_a;
 extern cvar_t *gl_particle_att_b;
 extern cvar_t *gl_particle_att_c;
 
-extern cvar_t *gl_nosubimage;
-extern cvar_t *gl_bitdepth;
 extern cvar_t *gl_mode;
-
 extern cvar_t *gl_customwidth;
 extern cvar_t *gl_customheight;
 
@@ -245,25 +237,18 @@ extern cvar_t *gl_dynamic;
 extern cvar_t *gl_nobind;
 extern cvar_t *gl_round_down;
 extern cvar_t *gl_picmip;
-extern cvar_t *gl_skymip;
 extern cvar_t *gl_showtris;
 extern cvar_t *gl_finish;
 extern cvar_t *gl_ztrick;
 extern cvar_t *gl_zfix;
 extern cvar_t *gl_clear;
 extern cvar_t *gl_cull;
-extern cvar_t *gl_poly;
-extern cvar_t *gl_texsort;
 extern cvar_t *gl_polyblend;
 extern cvar_t *gl_flashblend;
-extern cvar_t *gl_lightmaptype;
 extern cvar_t *gl_modulate;
-extern cvar_t *gl_playermip;
 extern cvar_t *gl_drawbuffer;
-extern cvar_t *gl_3dlabs_broken;
 extern cvar_t *gl_swapinterval;
 extern cvar_t *gl_anisotropic;
-extern cvar_t *gl_anisotropic_avail;
 extern cvar_t *gl_texturemode;
 extern cvar_t *gl_texturealphamode;
 extern cvar_t *gl_texturesolidmode;
@@ -276,7 +261,6 @@ extern cvar_t *vid_gamma;
 
 extern cvar_t *intensity;
 
-extern int gl_lightmap_format;
 extern int gl_solid_format;
 extern int gl_alpha_format;
 extern int gl_tex_solid_format;
@@ -370,17 +354,25 @@ void R_DrawParticles2(int n,
 
 typedef struct
 {
-	int renderer;
 	const char *renderer_string;
 	const char *vendor_string;
 	const char *version_string;
 	const char *extensions_string;
 
-	qboolean allow_cds;
-	qboolean mtexcombine;
+	int major_version;
+	int minor_version;
+
+	// ----
 
 	qboolean anisotropic;
-	qboolean tex_npot;
+	qboolean mtexcombine;
+	qboolean multitexture;
+	qboolean npottextures;
+	qboolean palettedtexture;
+	qboolean pointparameters;
+
+	// ----
+
 	float max_anisotropy;
 } glconfig_t;
 
@@ -397,6 +389,7 @@ typedef struct
 
 	int currenttextures[2];
 	int currenttmu;
+	GLenum currenttarget;
 
 	float camera_separation;
 	enum stereo_modes stereo_mode;
diff --git a/src/client/refresh/r_draw.c b/src/client/refresh/r_draw.c
index 0f3ed0b..7e4598a 100644
--- a/src/client/refresh/r_draw.c
+++ b/src/client/refresh/r_draw.c
@@ -90,16 +90,29 @@ Draw_CharScaled(int x, int y, int num, float scale)
 
 	R_Bind(draw_chars->texnum);
 
-	glBegin(GL_QUADS);
-	glTexCoord2f(fcol, frow);
-	glVertex2f(x, y);
-	glTexCoord2f(fcol + size, frow);
-	glVertex2f(x + scaledSize, y);
-	glTexCoord2f(fcol + size, frow + size);
-	glVertex2f(x + scaledSize, y + scaledSize);
-	glTexCoord2f(fcol, frow + size);
-	glVertex2f(x, y + scaledSize);
-	glEnd();
+	GLfloat vtx[] = {
+		x, y,
+		x + scaledSize, y,
+		x + scaledSize, y + scaledSize,
+		x, y + scaledSize
+	};
+
+	GLfloat tex[] = {
+		fcol, frow,
+		fcol + size, frow,
+		fcol + size, frow + size,
+		fcol, frow + size
+	};
+
+	glEnableClientState( GL_VERTEX_ARRAY );
+	glEnableClientState( GL_TEXTURE_COORD_ARRAY );
+
+	glVertexPointer( 2, GL_FLOAT, 0, vtx );
+	glTexCoordPointer( 2, GL_FLOAT, 0, tex );
+	glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
+
+	glDisableClientState( GL_VERTEX_ARRAY );
+	glDisableClientState( GL_TEXTURE_COORD_ARRAY );
 }
 
 image_t *
@@ -157,16 +170,30 @@ Draw_StretchPic(int x, int y, int w, int h, char *pic)
 	}
 
 	R_Bind(gl->texnum);
-	glBegin(GL_QUADS);
-	glTexCoord2f(gl->sl, gl->tl);
-	glVertex2f(x, y);
-	glTexCoord2f(gl->sh, gl->tl);
-	glVertex2f(x + w, y);
-	glTexCoord2f(gl->sh, gl->th);
-	glVertex2f(x + w, y + h);
-	glTexCoord2f(gl->sl, gl->th);
-	glVertex2f(x, y + h);
-	glEnd();
+
+	GLfloat vtx[] = {
+		x, y,
+		x + w, y,
+		x + w, y + h,
+		x, y + h
+	};
+
+	GLfloat tex[] = {
+		gl->sl, gl->tl,
+		gl->sh, gl->tl,
+		gl->sh, gl->th,
+		gl->sl, gl->th
+	};
+
+	glEnableClientState( GL_VERTEX_ARRAY );
+	glEnableClientState( GL_TEXTURE_COORD_ARRAY );
+
+	glVertexPointer( 2, GL_FLOAT, 0, vtx );
+	glTexCoordPointer( 2, GL_FLOAT, 0, tex );
+	glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
+
+	glDisableClientState( GL_VERTEX_ARRAY );
+	glDisableClientState( GL_TEXTURE_COORD_ARRAY );
 }
 
 void
@@ -193,20 +220,31 @@ Draw_PicScaled(int x, int y, char *pic, float factor)
 		Scrap_Upload();
 	}
 
-	GLfloat w = gl->width*factor;
-	GLfloat h = gl->height*factor;
-
 	R_Bind(gl->texnum);
-	glBegin(GL_QUADS);
-	glTexCoord2f(gl->sl, gl->tl);
-	glVertex2f(x, y);
-	glTexCoord2f(gl->sh, gl->tl);
-	glVertex2f(x + w, y);
-	glTexCoord2f(gl->sh, gl->th);
-	glVertex2f(x + w, y + h);
-	glTexCoord2f(gl->sl, gl->th);
-	glVertex2f(x, y + h);
-	glEnd();
+
+	GLfloat vtx[] = {
+		x, y,
+		x + gl->width * factor, y,
+		x + gl->width * factor, y + gl->height * factor,
+		x, y + gl->height * factor
+	};
+
+	GLfloat tex[] = {
+		gl->sl, gl->tl,
+		gl->sh, gl->tl,
+		gl->sh, gl->th,
+		gl->sl, gl->th
+	};
+
+	glEnableClientState( GL_VERTEX_ARRAY );
+	glEnableClientState( GL_TEXTURE_COORD_ARRAY );
+
+	glVertexPointer( 2, GL_FLOAT, 0, vtx );
+	glTexCoordPointer( 2, GL_FLOAT, 0, tex );
+	glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
+
+	glDisableClientState( GL_VERTEX_ARRAY );
+	glDisableClientState( GL_TEXTURE_COORD_ARRAY );
 }
 
 /*
@@ -228,16 +266,30 @@ Draw_TileClear(int x, int y, int w, int h, char *pic)
 	}
 
 	R_Bind(image->texnum);
-	glBegin(GL_QUADS);
-	glTexCoord2f(x / 64.0, y / 64.0);
-	glVertex2f(x, y);
-	glTexCoord2f((x + w) / 64.0, y / 64.0);
-	glVertex2f(x + w, y);
-	glTexCoord2f((x + w) / 64.0, (y + h) / 64.0);
-	glVertex2f(x + w, y + h);
-	glTexCoord2f(x / 64.0, (y + h) / 64.0);
-	glVertex2f(x, y + h);
-	glEnd();
+
+	GLfloat vtx[] = {
+		x, y,
+		x + w, y,
+		x + w, y + h,
+		x, y + h
+	};
+
+	GLfloat tex[] = {
+		x / 64.0, y / 64.0,
+		( x + w ) / 64.0, y / 64.0,
+		( x + w ) / 64.0, ( y + h ) / 64.0,
+		x / 64.0, ( y + h ) / 64.0
+	};
+
+	glEnableClientState( GL_VERTEX_ARRAY );
+	glEnableClientState( GL_TEXTURE_COORD_ARRAY );
+
+	glVertexPointer( 2, GL_FLOAT, 0, vtx );
+	glTexCoordPointer( 2, GL_FLOAT, 0, tex );
+	glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
+
+	glDisableClientState( GL_VERTEX_ARRAY );
+	glDisableClientState( GL_TEXTURE_COORD_ARRAY );
 }
 
 /*
@@ -260,18 +312,24 @@ Draw_Fill(int x, int y, int w, int h, int c)
 	glDisable(GL_TEXTURE_2D);
 
 	color.c = d_8to24table[c];
-	glColor3f(color.v[0] / 255.0, color.v[1] / 255.0,
-			color.v[2] / 255.0);
+	glColor4f(color.v [ 0 ] / 255.0, color.v [ 1 ] / 255.0,
+			   color.v [ 2 ] / 255.0, 1);
+
+	GLfloat vtx[] = {
+		x, y,
+		x + w, y,
+		x + w, y + h,
+		x, y + h
+	};
 
-	glBegin(GL_QUADS);
+	glEnableClientState( GL_VERTEX_ARRAY );
 
-	glVertex2f(x, y);
-	glVertex2f(x + w, y);
-	glVertex2f(x + w, y + h);
-	glVertex2f(x, y + h);
+	glVertexPointer( 2, GL_FLOAT, 0, vtx );
+	glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
 
-	glEnd();
-	glColor3f(1, 1, 1);
+	glDisableClientState( GL_VERTEX_ARRAY );
+
+	glColor4f( 1, 1, 1, 1 );
 	glEnable(GL_TEXTURE_2D);
 }
 
@@ -281,14 +339,21 @@ Draw_FadeScreen(void)
 	glEnable(GL_BLEND);
 	glDisable(GL_TEXTURE_2D);
 	glColor4f(0, 0, 0, 0.8);
-	glBegin(GL_QUADS);
 
-	glVertex2f(0, 0);
-	glVertex2f(vid.width, 0);
-	glVertex2f(vid.width, vid.height);
-	glVertex2f(0, vid.height);
+	GLfloat vtx[] = {
+		0, 0,
+		vid.width, 0,
+		vid.width, vid.height,
+		0, vid.height
+	};
+
+	glEnableClientState( GL_VERTEX_ARRAY );
+
+	glVertexPointer( 2, GL_FLOAT, 0, vtx );
+	glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
+
+	glDisableClientState( GL_VERTEX_ARRAY );
 
-	glEnd();
 	glColor4f(1, 1, 1, 1);
 	glEnable(GL_TEXTURE_2D);
 	glDisable(GL_BLEND);
@@ -297,61 +362,136 @@ Draw_FadeScreen(void)
 void
 Draw_StretchRaw(int x, int y, int w, int h, int cols, int rows, byte *data)
 {
-	unsigned image32[256 * 256];
-	unsigned char image8[256 * 256];
-	int i, j, trows;
+	GLfloat tex[8];
 	byte *source;
-	int frac, fracstep;
 	float hscale;
+	int frac, fracstep;
+	int i, j, trows;
 	int row;
-	float t;
 
 	R_Bind(0);
 
-	if (rows <= 256)
+	if(gl_config.npottextures || rows <= 256)
 	{
-		hscale = 1;
-		trows = rows;
+		// X, X
+		tex[0] = 0;
+		tex[1] = 0;
+
+		// X, Y
+		tex[2] = 1;
+		tex[3] = 0;
+
+		// Y, X
+		tex[4] = 1;
+		tex[5] = 1;
+
+		// Y, Y
+		tex[6] = 0;
+		tex[7] = 1;
 	}
 	else
 	{
+		// Scale params
 		hscale = rows / 256.0;
 		trows = 256;
+
+		// X, X
+		tex[0] = 1.0 / 512.0;
+		tex[1] = 1.0 / 512.0;
+
+		// X, Y
+		tex[2] = 511.0 / 512.0;
+		tex[3] = 1.0 / 512.0;
+
+		// Y, X
+		tex[4] = 511.0 / 512.0;
+		tex[5] = rows * hscale / 256 - 1.0 / 512.0;
+
+		// Y, Y
+		tex[6] = 1.0 / 512.0;
+		tex[7] = rows * hscale / 256 - 1.0 / 512.0;
 	}
 
-	t = rows * hscale / 256 - 1.0 / 512.0;
+	GLfloat vtx[] = {
+			x, y,
+			x + w, y,
+			x + w, y + h,
+			x, y + h
+	};
 
-	if (!qglColorTableEXT)
+	if (!gl_config.palettedtexture)
 	{
-		unsigned *dest;
-
-		for (i = 0; i < trows; i++)
+		unsigned image32[320*240]; /* was 256 * 256, but we want a bit more space */
+
+		/* .. because now if non-power-of-2 textures are supported, we just load
+		 * the data into a texture in the original format, without skipping any
+		 * pixels to fit into a 256x256 texture.
+		 * This causes text in videos (which are 320x240) to not look broken anymore.
+		 */
+		if(gl_config.npottextures || rows <= 256)
 		{
-			row = (int)(i * hscale);
+			unsigned* img = image32;
 
-			if (row > rows)
+			if(cols*rows > 320*240)
 			{
-				break;
+				/* in case there is a bigger video after all,
+				 * malloc enough space to hold the frame */
+				img = (unsigned*)malloc(cols*rows*4);
 			}
 
-			source = data + cols * row;
-			dest = &image32[i * 256];
-			fracstep = cols * 0x10000 / 256;
-			frac = fracstep >> 1;
+			for(i=0; i<rows; ++i)
+			{
+				int rowOffset = i*cols;
+				for(j=0; j<cols; ++j)
+				{
+					byte palIdx = data[rowOffset+j];
+					img[rowOffset+j] = r_rawpalette[palIdx];
+				}
+			}
 
-			for (j = 0; j < 256; j++)
+			glTexImage2D(GL_TEXTURE_2D, 0, gl_tex_solid_format,
+								cols, rows, 0, GL_RGBA, GL_UNSIGNED_BYTE,
+								img);
+
+			if(img != image32)
 			{
-				dest[j] = r_rawpalette[source[frac >> 16]];
-				frac += fracstep;
+				free(img);
 			}
 		}
+		else
+		{
+			unsigned int image32[320*240];
+			unsigned *dest;
+
+			for (i = 0; i < trows; i++)
+			{
+				row = (int)(i * hscale);
+
+				if (row > rows)
+				{
+					break;
+				}
+
+				source = data + cols * row;
+				dest = &image32[i * 256];
+				fracstep = cols * 0x10000 / 256;
+				frac = fracstep >> 1;
+
+				for (j = 0; j < 256; j++)
+				{
+					dest[j] = r_rawpalette[source[frac >> 16]];
+					frac += fracstep;
+				}
+			}
 
-		glTexImage2D(GL_TEXTURE_2D, 0, gl_tex_solid_format,
-				256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE,
-				image32);
+			glTexImage2D(GL_TEXTURE_2D, 0, gl_tex_solid_format,
+					256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE,
+					image32);
+		}
 	}
 	else
 	{
+		unsigned char image8[256 * 256];
 		unsigned char *dest;
 
 		for (i = 0; i < trows; i++)
@@ -375,29 +515,22 @@ Draw_StretchRaw(int x, int y, int w, int h, int cols, int rows, byte *data)
 			}
 		}
 
-		glTexImage2D(GL_TEXTURE_2D,
-				0,
-				GL_COLOR_INDEX8_EXT,
-				256, 256,
-				0,
-				GL_COLOR_INDEX,
-				GL_UNSIGNED_BYTE,
-				image8);
+		glTexImage2D(GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, 256, 256,
+				0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, image8);
 	}
 
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 
-	glBegin(GL_QUADS);
-	glTexCoord2f(1.0 / 512.0, 1.0 / 512.0);
-	glVertex2f(x, y);
-	glTexCoord2f(511.0 / 512.0, 1.0 / 512.0);
-	glVertex2f(x + w, y);
-	glTexCoord2f(511.0 / 512.0, t);
-	glVertex2f(x + w, y + h);
-	glTexCoord2f(1.0 / 512.0, t);
-	glVertex2f(x, y + h);
-	glEnd();
+	glEnableClientState( GL_VERTEX_ARRAY );
+	glEnableClientState( GL_TEXTURE_COORD_ARRAY );
+
+	glVertexPointer( 2, GL_FLOAT, 0, vtx );
+	glTexCoordPointer( 2, GL_FLOAT, 0, tex );
+	glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
+
+	glDisableClientState( GL_VERTEX_ARRAY );
+	glDisableClientState( GL_TEXTURE_COORD_ARRAY );
 }
 
 int
diff --git a/src/client/refresh/r_image.c b/src/client/refresh/r_image.c
index c4a1c5c..e93e687 100644
--- a/src/client/refresh/r_image.c
+++ b/src/client/refresh/r_image.c
@@ -43,11 +43,11 @@ qboolean R_Upload8(byte *data, int width, int height,
 		qboolean mipmap, qboolean is_sky);
 qboolean R_Upload32(unsigned *data, int width, int height, qboolean mipmap);
 
-int gl_solid_format = 3;
-int gl_alpha_format = 4;
+int gl_solid_format = GL_RGB;
+int gl_alpha_format = GL_RGBA;
 
-int gl_tex_solid_format = 3;
-int gl_tex_alpha_format = 4;
+int gl_tex_solid_format = GL_RGB;
+int gl_tex_alpha_format = GL_RGBA;
 
 int gl_filter_min = GL_LINEAR_MIPMAP_NEAREST;
 int gl_filter_max = GL_LINEAR;
@@ -78,7 +78,7 @@ typedef struct
 } gltmode_t;
 
 gltmode_t gl_alpha_modes[] = {
-	{"default", 4},
+	{"default", GL_RGBA},
 	{"GL_RGBA", GL_RGBA},
 	{"GL_RGBA8", GL_RGBA8},
 	{"GL_RGB5_A1", GL_RGB5_A1},
@@ -89,15 +89,12 @@ gltmode_t gl_alpha_modes[] = {
 #define NUM_GL_ALPHA_MODES (sizeof(gl_alpha_modes) / sizeof(gltmode_t))
 
 gltmode_t gl_solid_modes[] = {
-	{"default", 3},
+	{"default", GL_RGB},
 	{"GL_RGB", GL_RGB},
 	{"GL_RGB8", GL_RGB8},
 	{"GL_RGB5", GL_RGB5},
 	{"GL_RGB4", GL_RGB4},
 	{"GL_R3_G3_B2", GL_R3_G3_B2},
-#ifdef GL_RGB2_EXT
-	{"GL_RGB2", GL_RGB2_EXT},
-#endif
 };
 
 #define NUM_GL_SOLID_MODES (sizeof(gl_solid_modes) / sizeof(gltmode_t))
@@ -134,7 +131,7 @@ R_SetTexturePalette(unsigned palette[256])
 	int i;
 	unsigned char temptable[768];
 
-	if (qglColorTableEXT && gl_ext_palettedtexture->value)
+	if (gl_config.palettedtexture)
 	{
 		for (i = 0; i < 256; i++)
 		{
@@ -151,7 +148,7 @@ R_SetTexturePalette(unsigned palette[256])
 void
 R_EnableMultitexture(qboolean enable)
 {
-	if (!qglActiveTextureARB)
+	if (!gl_config.multitexture)
 	{
 		return;
 	}
@@ -178,7 +175,7 @@ R_SelectTexture(GLenum texture)
 {
 	int tmu;
 
-	if (!qglActiveTextureARB)
+	if (!gl_config.multitexture)
 	{
 		return;
 	}
@@ -198,12 +195,10 @@ R_SelectTexture(GLenum texture)
 	}
 
 	gl_state.currenttmu = tmu;
+	gl_state.currenttarget = texture;
 
-	if (qglActiveTextureARB)
-	{
-		qglActiveTextureARB(texture);
-		qglClientActiveTextureARB(texture);
-	}
+	qglActiveTextureARB(texture);
+	qglClientActiveTextureARB(texture);
 }
 
 void
@@ -240,7 +235,10 @@ R_Bind(int texnum)
 void
 R_MBind(GLenum target, int texnum)
 {
-	R_SelectTexture(target);
+	if (target != gl_state.currenttarget)
+	{
+		R_SelectTexture(target);
+	}
 
 	if (target == GL_TEXTURE0_ARB)
 	{
@@ -667,7 +665,7 @@ R_Upload32Native(unsigned *data, int width, int height, qboolean mipmap)
 
 
 qboolean
-R_Upload32Old(unsigned *data, int width, int height, qboolean mipmap)
+R_Upload32Soft(unsigned *data, int width, int height, qboolean mipmap)
 {
 	int samples;
 	unsigned scaled[256 * 256];
@@ -753,7 +751,7 @@ R_Upload32Old(unsigned *data, int width, int height, qboolean mipmap)
 	{
 		if (!mipmap)
 		{
-			if (qglColorTableEXT && gl_ext_palettedtexture->value &&
+			if (qglColorTableEXT && gl_palettedtexture->value &&
 				(samples == gl_solid_format))
 			{
 				uploaded_paletted = true;
@@ -783,7 +781,7 @@ R_Upload32Old(unsigned *data, int width, int height, qboolean mipmap)
 
 	R_LightScaleTexture(scaled, scaled_width, scaled_height, !mipmap);
 
-	if (qglColorTableEXT && gl_ext_palettedtexture->value &&
+	if (qglColorTableEXT && gl_palettedtexture->value &&
 		(samples == gl_solid_format))
 	{
 		uploaded_paletted = true;
@@ -824,7 +822,7 @@ R_Upload32Old(unsigned *data, int width, int height, qboolean mipmap)
 
 			miplevel++;
 
-			if (qglColorTableEXT && gl_ext_palettedtexture->value &&
+			if (qglColorTableEXT && gl_palettedtexture->value &&
 				(samples == gl_solid_format))
 			{
 				uploaded_paletted = true;
@@ -852,13 +850,13 @@ R_Upload32(unsigned *data, int width, int height, qboolean mipmap)
 {
 	qboolean res;
 
-	if (gl_config.tex_npot)
+	if (gl_config.npottextures)
 	{
 		res = R_Upload32Native(data, width, height, mipmap);
 	}
 	else
 	{
-		res = R_Upload32Old(data, width, height, mipmap);
+		res = R_Upload32Soft(data, width, height, mipmap);
 	}
 
 	if (mipmap)
@@ -898,7 +896,7 @@ R_Upload8(byte *data, int width, int height, qboolean mipmap, qboolean is_sky)
 		VID_Error(ERR_DROP, "R_Upload8: too large");
 	}
 
-	if (qglColorTableEXT && gl_ext_palettedtexture->value && is_sky)
+	if (gl_config.palettedtexture && is_sky)
 	{
 		glTexImage2D(GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT,
 				width, height, 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE,
@@ -1349,7 +1347,7 @@ R_InitImages(void)
 
 	Draw_GetPalette();
 
-	if (qglColorTableEXT)
+	if (gl_config.palettedtexture)
 	{
 		FS_LoadFile("pics/16to8.dat", (void **)&gl_state.d_16to8table);
 
diff --git a/src/client/refresh/r_light.c b/src/client/refresh/r_light.c
index 1847717..e4da73e 100644
--- a/src/client/refresh/r_light.c
+++ b/src/client/refresh/r_light.c
@@ -39,39 +39,51 @@ R_RenderDlight(dlight_t *light)
 {
 	int i, j;
 	float a;
-	vec3_t v;
 	float rad;
 
 	rad = light->intensity * 0.35;
 
-	VectorSubtract(light->origin, r_origin, v);
+	GLfloat vtx[3*18];
+	GLfloat clr[4*18];
 
-	glBegin(GL_TRIANGLE_FAN);
-	glColor3f(light->color[0] * 0.2, light->color[1] * 0.2,
-			light->color[2] * 0.2);
+	unsigned int index_vtx = 4;
+	unsigned int index_clr = 0;
 
-	for (i = 0; i < 3; i++)
+	glEnableClientState( GL_VERTEX_ARRAY );
+	glEnableClientState( GL_COLOR_ARRAY );
+
+	clr[index_clr++] = light->color [ 0 ] * 0.2;
+	clr[index_clr++] = light->color [ 1 ] * 0.2;
+	clr[index_clr++] = light->color [ 2 ] * 0.2;
+	clr[index_clr++] = 1;
+
+	for ( i = 0; i < 3; i++ )
 	{
-		v[i] = light->origin[i] - vpn[i] * rad;
+		vtx [ i ] = light->origin [ i ] - vpn [ i ] * rad;
 	}
 
-	glVertex3fv(v);
-	glColor3f(0, 0, 0);
-
-	for (i = 16; i >= 0; i--)
+	for ( i = 16; i >= 0; i-- )
 	{
+		clr[index_clr++] = 0;
+		clr[index_clr++] = 0;
+		clr[index_clr++] = 0;
+		clr[index_clr++] = 1;
+
 		a = i / 16.0 * M_PI * 2;
 
-		for (j = 0; j < 3; j++)
+		for ( j = 0; j < 3; j++ )
 		{
-			v[j] = light->origin[j] + vright[j] * cos(a) * rad
-				   + vup[j] * sin(a) * rad;
+			vtx[index_vtx++] = light->origin [ j ] + vright [ j ] * cos( a ) * rad
+				+ vup [ j ] * sin( a ) * rad;
 		}
-
-		glVertex3fv(v);
 	}
 
-	glEnd();
+	glVertexPointer( 3, GL_FLOAT, 0, vtx );
+	glColorPointer( 4, GL_FLOAT, 0, clr );
+	glDrawArrays( GL_TRIANGLE_FAN, 0, 18 );
+
+	glDisableClientState( GL_VERTEX_ARRAY );
+	glDisableClientState( GL_COLOR_ARRAY );
 }
 
 void
@@ -101,7 +113,7 @@ R_RenderDlights(void)
 		R_RenderDlight(l);
 	}
 
-	glColor3f(1, 1, 1);
+	glColor4f(1, 1, 1, 1);
 	glDisable(GL_BLEND);
 	glEnable(GL_TEXTURE_2D);
 	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
diff --git a/src/client/refresh/r_lightmap.c b/src/client/refresh/r_lightmap.c
index a95e48d..57e8599 100644
--- a/src/client/refresh/r_lightmap.c
+++ b/src/client/refresh/r_lightmap.c
@@ -74,6 +74,7 @@ LM_UploadBlock(qboolean dynamic)
 	}
 	else
 	{
+		gl_lms.internal_format = GL_LIGHTMAP_FORMAT;
 		glTexImage2D(GL_TEXTURE_2D, 0, gl_lms.internal_format,
 				BLOCK_WIDTH, BLOCK_HEIGHT, 0, GL_LIGHTMAP_FORMAT,
 				GL_UNSIGNED_BYTE, gl_lms.lightmap_buffer);
@@ -273,7 +274,7 @@ LM_BeginBuildingLightmaps(model_t *m)
 	}
 
 	gl_lms.current_lightmap_texture = 1;
-	gl_lms.internal_format = gl_tex_solid_format;
+	gl_lms.internal_format = GL_LIGHTMAP_FORMAT;
 
 	/* initialize the dynamic lightmap texture */
 	R_Bind(gl_state.lightmap_textures + 0);
diff --git a/src/client/refresh/r_main.c b/src/client/refresh/r_main.c
index cedd0fc..20cb7d0 100644
--- a/src/client/refresh/r_main.c
+++ b/src/client/refresh/r_main.c
@@ -75,7 +75,6 @@ cvar_t *gl_drawworld;
 cvar_t *gl_speeds;
 cvar_t *gl_fullbright;
 cvar_t *gl_novis;
-cvar_t *gl_nocull;
 cvar_t *gl_lerpmodels;
 cvar_t *gl_lefthand;
 cvar_t *gl_farsee;
@@ -83,11 +82,6 @@ cvar_t *gl_farsee;
 cvar_t *gl_lightlevel;
 cvar_t *gl_overbrightbits;
 
-cvar_t *gl_nosubimage;
-cvar_t *gl_allow_software;
-
-cvar_t *gl_vertex_arrays;
-
 cvar_t *gl_particle_min_size;
 cvar_t *gl_particle_max_size;
 cvar_t *gl_particle_size;
@@ -95,14 +89,11 @@ cvar_t *gl_particle_att_a;
 cvar_t *gl_particle_att_b;
 cvar_t *gl_particle_att_c;
 
-cvar_t *gl_ext_swapinterval;
-cvar_t *gl_ext_palettedtexture;
-cvar_t *gl_ext_multitexture;
-cvar_t *gl_ext_pointparameters;
-cvar_t *gl_ext_compiled_vertex_array;
-cvar_t *gl_ext_mtexcombine;
+cvar_t *gl_palettedtexture;
+cvar_t *gl_multitexture;
+cvar_t *gl_pointparameters;
+cvar_t *gl_mtexcombine;
 
-cvar_t *gl_bitdepth;
 cvar_t *gl_drawbuffer;
 cvar_t *gl_lightmap;
 cvar_t *gl_shadows;
@@ -119,7 +110,6 @@ cvar_t *gl_modulate;
 cvar_t *gl_nobind;
 cvar_t *gl_round_down;
 cvar_t *gl_picmip;
-cvar_t *gl_skymip;
 cvar_t *gl_showtris;
 cvar_t *gl_ztrick;
 cvar_t *gl_zfix;
@@ -128,14 +118,12 @@ cvar_t *gl_clear;
 cvar_t *gl_cull;
 cvar_t *gl_polyblend;
 cvar_t *gl_flashblend;
-cvar_t *gl_playermip;
 cvar_t *gl_saturatelighting;
 cvar_t *gl_swapinterval;
 cvar_t *gl_texturemode;
 cvar_t *gl_texturealphamode;
 cvar_t *gl_texturesolidmode;
 cvar_t *gl_anisotropic;
-cvar_t *gl_anisotropic_avail;
 cvar_t *gl_lockpvs;
 cvar_t *gl_msaa_samples;
 
@@ -155,7 +143,7 @@ R_CullBox(vec3_t mins, vec3_t maxs)
 {
 	int i;
 
-	if (gl_nocull->value)
+	if (!gl_cull->value)
 	{
 		return false;
 	}
@@ -185,7 +173,7 @@ void
 R_DrawSpriteModel(entity_t *e)
 {
 	float alpha = 1.0F;
-	vec3_t point;
+    vec3_t point[4];
 	dsprframe_t *frame;
 	float *up, *right;
 	dsprite_t *psprite;
@@ -226,29 +214,34 @@ R_DrawSpriteModel(entity_t *e)
 		glDisable(GL_ALPHA_TEST);
 	}
 
-	glBegin(GL_QUADS);
+	GLfloat tex[] = {
+		0, 1,
+		0, 0,
+		1, 0,
+		1, 1
+	};
+
+	VectorMA( e->origin, -frame->origin_y, up, point[0] );
+	VectorMA( point[0], -frame->origin_x, right, point[0] );
+
+	VectorMA( e->origin, frame->height - frame->origin_y, up, point[1] );
+	VectorMA( point[1], -frame->origin_x, right, point[1] );
 
-	glTexCoord2f(0, 1);
-	VectorMA(e->origin, -frame->origin_y, up, point);
-	VectorMA(point, -frame->origin_x, right, point);
-	glVertex3fv(point);
+	VectorMA( e->origin, frame->height - frame->origin_y, up, point[2] );
+	VectorMA( point[2], frame->width - frame->origin_x, right, point[2] );
 
-	glTexCoord2f(0, 0);
-	VectorMA(e->origin, frame->height - frame->origin_y, up, point);
-	VectorMA(point, -frame->origin_x, right, point);
-	glVertex3fv(point);
+	VectorMA( e->origin, -frame->origin_y, up, point[3] );
+	VectorMA( point[3], frame->width - frame->origin_x, right, point[3] );
 
-	glTexCoord2f(1, 0);
-	VectorMA(e->origin, frame->height - frame->origin_y, up, point);
-	VectorMA(point, frame->width - frame->origin_x, right, point);
-	glVertex3fv(point);
+	glEnableClientState( GL_VERTEX_ARRAY );
+	glEnableClientState( GL_TEXTURE_COORD_ARRAY );
 
-	glTexCoord2f(1, 1);
-	VectorMA(e->origin, -frame->origin_y, up, point);
-	VectorMA(point, frame->width - frame->origin_x, right, point);
-	glVertex3fv(point);
+	glVertexPointer( 3, GL_FLOAT, 0, point );
+	glTexCoordPointer( 2, GL_FLOAT, 0, tex );
+	glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
 
-	glEnd();
+	glDisableClientState( GL_VERTEX_ARRAY );
+	glDisableClientState( GL_TEXTURE_COORD_ARRAY );
 
 	glDisable(GL_ALPHA_TEST);
 	R_TexEnv(GL_REPLACE);
@@ -265,7 +258,6 @@ void
 R_DrawNullModel(void)
 {
 	vec3_t shadelight;
-	int i;
 
 	if (currententity->flags & RF_FULLBRIGHT)
 	{
@@ -280,29 +272,41 @@ R_DrawNullModel(void)
 	R_RotateForEntity(currententity);
 
 	glDisable(GL_TEXTURE_2D);
-	glColor3fv(shadelight);
+	glColor4f( shadelight[0], shadelight[1], shadelight[2], 1 );
 
-	glBegin(GL_TRIANGLE_FAN);
-	glVertex3f(0, 0, -16);
+    GLfloat vtxA[] = {
+        0, 0, -16,
+        16 * cos( 0 * M_PI / 2 ), 16 * sin( 0 * M_PI / 2 ), 0,
+        16 * cos( 1 * M_PI / 2 ), 16 * sin( 1 * M_PI / 2 ), 0,
+        16 * cos( 2 * M_PI / 2 ), 16 * sin( 2 * M_PI / 2 ), 0,
+        16 * cos( 3 * M_PI / 2 ), 16 * sin( 3 * M_PI / 2 ), 0,
+        16 * cos( 4 * M_PI / 2 ), 16 * sin( 4 * M_PI / 2 ), 0
+    };
 
-	for (i = 0; i <= 4; i++)
-	{
-		glVertex3f(16 * cos(i * M_PI / 2), 16 * sin(i * M_PI / 2), 0);
-	}
+    glEnableClientState( GL_VERTEX_ARRAY );
 
-	glEnd();
+    glVertexPointer( 3, GL_FLOAT, 0, vtxA );
+    glDrawArrays( GL_TRIANGLE_FAN, 0, 6 );
 
-	glBegin(GL_TRIANGLE_FAN);
-	glVertex3f(0, 0, 16);
+    glDisableClientState( GL_VERTEX_ARRAY );
 
-	for (i = 4; i >= 0; i--)
-	{
-		glVertex3f(16 * cos(i * M_PI / 2), 16 * sin(i * M_PI / 2), 0);
-	}
+	GLfloat vtxB[] = {
+		0, 0, 16,
+		16 * cos( 4 * M_PI / 2 ), 16 * sin( 4 * M_PI / 2 ), 0,
+		16 * cos( 3 * M_PI / 2 ), 16 * sin( 3 * M_PI / 2 ), 0,
+		16 * cos( 2 * M_PI / 2 ), 16 * sin( 2 * M_PI / 2 ), 0,
+		16 * cos( 1 * M_PI / 2 ), 16 * sin( 1 * M_PI / 2 ), 0,
+		16 * cos( 0 * M_PI / 2 ), 16 * sin( 0 * M_PI / 2 ), 0
+	};
+
+	glEnableClientState( GL_VERTEX_ARRAY );
 
-	glEnd();
+	glVertexPointer( 3, GL_FLOAT, 0, vtxB );
+	glDrawArrays( GL_TRIANGLE_FAN, 0, 6 );
 
-	glColor3f(1, 1, 1);
+	glDisableClientState( GL_VERTEX_ARRAY );
+
+	glColor4f(1, 1, 1, 1);
 	glPopMatrix();
 	glEnable(GL_TEXTURE_2D);
 }
@@ -417,24 +421,31 @@ R_DrawParticles2(int num_particles, const particle_t particles[],
 	vec3_t up, right;
 	float scale;
 	byte color[4];
-
+ 
+	GLfloat vtx[3*num_particles*3];
+	GLfloat tex[2*num_particles*3];
+	GLfloat clr[4*num_particles*3];
+	unsigned int index_vtx = 0;
+	unsigned int index_tex = 0;
+	unsigned int index_clr = 0;
+	unsigned int j;
+ 
 	R_Bind(r_particletexture->texnum);
 	glDepthMask(GL_FALSE); /* no z buffering */
 	glEnable(GL_BLEND);
 	R_TexEnv(GL_MODULATE);
-	glBegin(GL_TRIANGLES);
 
-	VectorScale(vup, 1.5, up);
-	VectorScale(vright, 1.5, right);
+	VectorScale( vup, 1.5, up );
+	VectorScale( vright, 1.5, right );
 
-	for (p = particles, i = 0; i < num_particles; i++, p++)
+	for ( p = particles, i = 0; i < num_particles; i++, p++ )
 	{
 		/* hack a scale up to keep particles from disapearing */
-		scale = (p->origin[0] - r_origin[0]) * vpn[0] +
-				(p->origin[1] - r_origin[1]) * vpn[1] +
-				(p->origin[2] - r_origin[2]) * vpn[2];
+		scale = ( p->origin [ 0 ] - r_origin [ 0 ] ) * vpn [ 0 ] +
+			( p->origin [ 1 ] - r_origin [ 1 ] ) * vpn [ 1 ] +
+			( p->origin [ 2 ] - r_origin [ 2 ] ) * vpn [ 2 ];
 
-		if (scale < 20)
+		if ( scale < 20 )
 		{
 			scale = 1;
 		}
@@ -443,26 +454,54 @@ R_DrawParticles2(int num_particles, const particle_t particles[],
 			scale = 1 + scale * 0.004;
 		}
 
-		*(int *)color = colortable[p->color];
-		color[3] = p->alpha * 255;
+		*(int *) color = colortable [ p->color ];
 
-		glColor4ubv(color);
+		for (j=0; j<3; j++) // Copy the color for each point
+		{
+			clr[index_clr++] = color[0]/255.0f;
+			clr[index_clr++] = color[1]/255.0f;
+			clr[index_clr++] = color[2]/255.0f;
+			clr[index_clr++] = p->alpha;
+		}
 
-		glTexCoord2f(0.0625, 0.0625);
-		glVertex3fv(p->origin);
+		// point 0
+		tex[index_tex++] = 0.0625f;
+		tex[index_tex++] = 0.0625f;
 
-		glTexCoord2f(1.0625, 0.0625);
-		glVertex3f(p->origin[0] + up[0] * scale,
-				p->origin[1] + up[1] * scale,
-				p->origin[2] + up[2] * scale);
+		vtx[index_vtx++] = p->origin[0];
+		vtx[index_vtx++] = p->origin[1];
+		vtx[index_vtx++] = p->origin[2];
 
-		glTexCoord2f(0.0625, 1.0625);
-		glVertex3f(p->origin[0] + right[0] * scale,
-				p->origin[1] + right[1] * scale,
-				p->origin[2] + right[2] * scale);
+		// point 1
+		tex[index_tex++] = 1.0625f;
+		tex[index_tex++] = 0.0625f;
+
+		vtx[index_vtx++] = p->origin [ 0 ] + up [ 0 ] * scale;
+		vtx[index_vtx++] = p->origin [ 1 ] + up [ 1 ] * scale;
+		vtx[index_vtx++] = p->origin [ 2 ] + up [ 2 ] * scale;
+
+		// point 2
+		tex[index_tex++] = 0.0625f;
+		tex[index_tex++] = 1.0625f;
+
+		vtx[index_vtx++] = p->origin [ 0 ] + right [ 0 ] * scale;
+		vtx[index_vtx++] = p->origin [ 1 ] + right [ 1 ] * scale;
+		vtx[index_vtx++] = p->origin [ 2 ] + right [ 2 ] * scale;
 	}
 
-	glEnd();
+	glEnableClientState( GL_VERTEX_ARRAY );
+	glEnableClientState( GL_TEXTURE_COORD_ARRAY );
+	glEnableClientState( GL_COLOR_ARRAY );
+
+	glVertexPointer( 3, GL_FLOAT, 0, vtx );
+	glTexCoordPointer( 2, GL_FLOAT, 0, tex );
+	glColorPointer( 4, GL_FLOAT, 0, clr );
+	glDrawArrays( GL_TRIANGLES, 0, num_particles*3 );
+
+	glDisableClientState( GL_VERTEX_ARRAY );
+	glDisableClientState( GL_TEXTURE_COORD_ARRAY );
+	glDisableClientState( GL_COLOR_ARRAY );
+ 
 	glDisable(GL_BLEND);
 	glColor4f(1, 1, 1, 1);
 	glDepthMask(1); /* back to normal Z buffering */
@@ -475,34 +514,48 @@ R_DrawParticles(void)
 	qboolean stereo_split_tb = ((gl_state.stereo_mode == STEREO_SPLIT_VERTICAL) && gl_state.camera_separation);
 	qboolean stereo_split_lr = ((gl_state.stereo_mode == STEREO_SPLIT_HORIZONTAL) && gl_state.camera_separation);
 
-	if (gl_ext_pointparameters->value && qglPointParameterfEXT && !(stereo_split_tb || stereo_split_lr))
+	if (gl_config.pointparameters && !(stereo_split_tb || stereo_split_lr))
 	{
 		int i;
 		unsigned char color[4];
 		const particle_t *p;
-
+ 
+		GLfloat vtx[3*r_newrefdef.num_particles];
+		GLfloat clr[4*r_newrefdef.num_particles];
+		unsigned int index_vtx = 0;
+		unsigned int index_clr = 0;
+  
 		glDepthMask(GL_FALSE);
 		glEnable(GL_BLEND);
 		glDisable(GL_TEXTURE_2D);
 
 		glPointSize(LittleFloat(gl_particle_size->value));
 
-		glBegin(GL_POINTS);
-
-		for (i = 0, p = r_newrefdef.particles;
-			 i < r_newrefdef.num_particles;
-			 i++, p++)
+		for ( i = 0, p = r_newrefdef.particles; i < r_newrefdef.num_particles; i++, p++ )
 		{
-			*(int *)color = d_8to24table[p->color & 0xFF];
-			color[3] = p->alpha * 255;
-			glColor4ubv(color);
-			glVertex3fv(p->origin);
+			*(int *) color = d_8to24table [ p->color & 0xFF ];
+			clr[index_clr++] = color[0]/255.0f;
+			clr[index_clr++] = color[1]/255.0f;
+			clr[index_clr++] = color[2]/255.0f;
+			clr[index_clr++] = p->alpha;
+
+			vtx[index_vtx++] = p->origin[0];
+			vtx[index_vtx++] = p->origin[1];
+			vtx[index_vtx++] = p->origin[2];
 		}
 
-		glEnd();
+		glEnableClientState( GL_VERTEX_ARRAY );
+		glEnableClientState( GL_COLOR_ARRAY );
+
+		glVertexPointer( 3, GL_FLOAT, 0, vtx );
+		glColorPointer( 4, GL_FLOAT, 0, clr );
+		glDrawArrays( GL_POINTS, 0, r_newrefdef.num_particles );
+
+		glDisableClientState( GL_VERTEX_ARRAY );
+		glDisableClientState( GL_COLOR_ARRAY );
 
 		glDisable(GL_BLEND);
-		glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+		glColor4f( 1, 1, 1, 1 );
 		glDepthMask(GL_TRUE);
 		glEnable(GL_TEXTURE_2D);
 	}
@@ -536,15 +589,21 @@ R_PolyBlend(void)
 	glRotatef(-90, 1, 0, 0); /* put Z going up */
 	glRotatef(90, 0, 0, 1); /* put Z going up */
 
-	glColor4fv(v_blend);
+	glColor4f( v_blend[0], v_blend[1], v_blend[2], v_blend[3] );
+
+	GLfloat vtx[] = {
+		10, 100, 100,
+		10, -100, 100,
+		10, -100, -100,
+		10, 100, -100
+	};
+
+	glEnableClientState( GL_VERTEX_ARRAY );
 
-	glBegin(GL_QUADS);
+	glVertexPointer( 3, GL_FLOAT, 0, vtx );
+	glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
 
-	glVertex3f(10, 100, 100);
-	glVertex3f(10, -100, 100);
-	glVertex3f(10, -100, -100);
-	glVertex3f(10, 100, -100);
-	glEnd();
+	glDisableClientState( GL_VERTEX_ARRAY );
 
 	glDisable(GL_BLEND);
 	glEnable(GL_TEXTURE_2D);
@@ -1138,15 +1197,11 @@ R_Register(void)
 	gl_drawentities = Cvar_Get("gl_drawentities", "1", 0);
 	gl_drawworld = Cvar_Get("gl_drawworld", "1", 0);
 	gl_novis = Cvar_Get("gl_novis", "0", 0);
-	gl_nocull = Cvar_Get("gl_nocull", "0", 0);
 	gl_lerpmodels = Cvar_Get("gl_lerpmodels", "1", 0);
 	gl_speeds = Cvar_Get("gl_speeds", "0", 0);
 
 	gl_lightlevel = Cvar_Get("gl_lightlevel", "0", 0);
-	gl_overbrightbits = Cvar_Get("gl_overbrightbits", "2", CVAR_ARCHIVE);
-
-	gl_nosubimage = Cvar_Get("gl_nosubimage", "0", 0);
-	gl_allow_software = Cvar_Get("gl_allow_software", "0", 0);
+	gl_overbrightbits = Cvar_Get("gl_overbrightbits", "0", CVAR_ARCHIVE);
 
 	gl_particle_min_size = Cvar_Get("gl_particle_min_size", "2", CVAR_ARCHIVE);
 	gl_particle_max_size = Cvar_Get("gl_particle_max_size", "40", CVAR_ARCHIVE);
@@ -1156,7 +1211,6 @@ R_Register(void)
 	gl_particle_att_c = Cvar_Get("gl_particle_att_c", "0.01", CVAR_ARCHIVE);
 
 	gl_modulate = Cvar_Get("gl_modulate", "1", CVAR_ARCHIVE);
-	gl_bitdepth = Cvar_Get("gl_bitdepth", "0", 0);
 	gl_mode = Cvar_Get("gl_mode", "4", CVAR_ARCHIVE);
 	gl_lightmap = Cvar_Get("gl_lightmap", "0", 0);
 	gl_shadows = Cvar_Get("gl_shadows", "0", CVAR_ARCHIVE);
@@ -1165,7 +1219,6 @@ R_Register(void)
 	gl_nobind = Cvar_Get("gl_nobind", "0", 0);
 	gl_round_down = Cvar_Get("gl_round_down", "1", 0);
 	gl_picmip = Cvar_Get("gl_picmip", "0", 0);
-	gl_skymip = Cvar_Get("gl_skymip", "0", 0);
 	gl_showtris = Cvar_Get("gl_showtris", "0", 0);
 	gl_ztrick = Cvar_Get("gl_ztrick", "0", 0);
 	gl_zfix = Cvar_Get("gl_zfix", "0", 0);
@@ -1174,23 +1227,17 @@ R_Register(void)
 	gl_cull = Cvar_Get("gl_cull", "1", 0);
 	gl_polyblend = Cvar_Get("gl_polyblend", "1", 0);
 	gl_flashblend = Cvar_Get("gl_flashblend", "0", 0);
-	gl_playermip = Cvar_Get("gl_playermip", "0", 0);
 
 	gl_texturemode = Cvar_Get("gl_texturemode", "GL_LINEAR_MIPMAP_NEAREST", CVAR_ARCHIVE);
 	gl_texturealphamode = Cvar_Get("gl_texturealphamode", "default", CVAR_ARCHIVE);
 	gl_texturesolidmode = Cvar_Get("gl_texturesolidmode", "default", CVAR_ARCHIVE);
 	gl_anisotropic = Cvar_Get("gl_anisotropic", "0", CVAR_ARCHIVE);
-	gl_anisotropic_avail = Cvar_Get("gl_anisotropic_avail", "0", 0);
 	gl_lockpvs = Cvar_Get("gl_lockpvs", "0", 0);
 
-	gl_vertex_arrays = Cvar_Get("gl_vertex_arrays", "0", CVAR_ARCHIVE);
-
-	gl_ext_swapinterval = Cvar_Get("gl_ext_swapinterval", "1", CVAR_ARCHIVE);
-	gl_ext_palettedtexture = Cvar_Get("gl_ext_palettedtexture", "0", CVAR_ARCHIVE);
-	gl_ext_multitexture = Cvar_Get("gl_ext_multitexture", "0", CVAR_ARCHIVE);
-	gl_ext_pointparameters = Cvar_Get("gl_ext_pointparameters", "1", CVAR_ARCHIVE);
-	gl_ext_compiled_vertex_array = Cvar_Get("gl_ext_compiled_vertex_array", "1", CVAR_ARCHIVE);
-	gl_ext_mtexcombine = Cvar_Get("gl_ext_mtexcombine", "1", CVAR_ARCHIVE);
+	gl_palettedtexture = Cvar_Get("gl_palettedtexture", "0", CVAR_ARCHIVE);
+	gl_multitexture = Cvar_Get("gl_multitexture", "0", CVAR_ARCHIVE);
+	gl_pointparameters = Cvar_Get("gl_pointparameters", "1", CVAR_ARCHIVE);
+	gl_mtexcombine = Cvar_Get("gl_mtexcombine", "1", CVAR_ARCHIVE);
 
 	gl_drawbuffer = Cvar_Get("gl_drawbuffer", "GL_BACK", 0);
 	gl_swapinterval = Cvar_Get("gl_swapinterval", "1", CVAR_ARCHIVE);
@@ -1280,9 +1327,6 @@ R_SetMode(void)
 int
 R_Init(void *hinstance, void *hWnd)
 {
-	char renderer_buffer[1000];
-	char vendor_buffer[1000];
-	int err;
 	int j;
 	extern float r_turbsin[256];
 
@@ -1334,161 +1378,190 @@ R_Init(void *hinstance, void *hWnd)
 
 	VID_MenuInit();
 
+	// --------
+
 	/* get our various GL strings */
 	VID_Printf(PRINT_ALL, "\nOpenGL setting:\n", gl_config.vendor_string);
+
 	gl_config.vendor_string = (char *)glGetString(GL_VENDOR);
 	VID_Printf(PRINT_ALL, "GL_VENDOR: %s\n", gl_config.vendor_string);
+
 	gl_config.renderer_string = (char *)glGetString(GL_RENDERER);
 	VID_Printf(PRINT_ALL, "GL_RENDERER: %s\n", gl_config.renderer_string);
+
 	gl_config.version_string = (char *)glGetString(GL_VERSION);
 	VID_Printf(PRINT_ALL, "GL_VERSION: %s\n", gl_config.version_string);
+
 	gl_config.extensions_string = (char *)glGetString(GL_EXTENSIONS);
 	VID_Printf(PRINT_ALL, "GL_EXTENSIONS: %s\n", gl_config.extensions_string);
 
-	Q_strlcpy(renderer_buffer, gl_config.renderer_string, sizeof(renderer_buffer));
-	Q_strlwr(renderer_buffer);
+	sscanf(gl_config.version_string, "%d.%d", &gl_config.major_version, &gl_config.minor_version);
 
-	Q_strlcpy(vendor_buffer, gl_config.vendor_string, sizeof(vendor_buffer));
-	Q_strlwr(vendor_buffer);
+	if (gl_config.major_version == 1)
+	{
+		if (gl_config.minor_version < 4)
+		{
+			QGL_Shutdown();
+			VID_Printf(PRINT_ALL, "Support for OpenGL 1.4 is not available\n");
 
-	Cvar_Set("scr_drawall", "0");
-	gl_config.allow_cds = true;
+			return -1;
+		}
+	}
 
 	VID_Printf(PRINT_ALL, "\n\nProbing for OpenGL extensions:\n");
 
-	/* grab extensions */
-	if (strstr(gl_config.extensions_string, "GL_EXT_compiled_vertex_array"))
+	// ----
+
+	/* Point parameters */
+	VID_Printf(PRINT_ALL, " - Point parameters: ");
+
+	if (strstr(gl_config.extensions_string, "GL_ARB_point_parameters"))
 	{
-		VID_Printf(PRINT_ALL, "...using GL_EXT_compiled_vertex_array\n");
-		qglLockArraysEXT = ( void * ) GLimp_GetProcAddress ( "glLockArraysEXT" );
-		qglUnlockArraysEXT = ( void * ) GLimp_GetProcAddress ( "glUnlockArraysEXT" );
+			qglPointParameterfARB = (void (APIENTRY *)(GLenum, GLfloat))GLimp_GetProcAddress ( "glPointParameterfARB" );
+			qglPointParameterfvARB = (void (APIENTRY *)(GLenum, const GLfloat *))GLimp_GetProcAddress ( "glPointParameterfvARB" );
+	}
+
+	gl_config.pointparameters = false;
+
+	if (gl_pointparameters->value)
+	{
+		if (qglPointParameterfARB && qglPointParameterfvARB)
+		{
+			gl_config.pointparameters = true;
+			VID_Printf(PRINT_ALL, "Okay\n");
+		}
+		else
+		{
+			VID_Printf(PRINT_ALL, "Failed\n");
+		}
 	}
 	else
 	{
-		VID_Printf(PRINT_ALL, "...GL_EXT_compiled_vertex_array not found\n");
+		VID_Printf(PRINT_ALL, "Disabled\n");
+	}
+
+	// ----
+
+	/* Paletted texture */
+	VID_Printf(PRINT_ALL, " - Paletted texture: ");
+
+	if (strstr(gl_config.extensions_string, "GL_EXT_paletted_texture") &&
+		strstr(gl_config.extensions_string, "GL_EXT_shared_texture_palette"))
+	{
+			qglColorTableEXT = (void (APIENTRY *)(GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid * ))
+					GLimp_GetProcAddress ("glColorTableEXT");
 	}
 
-	if (strstr(gl_config.extensions_string, "GL_EXT_point_parameters"))
+	gl_config.palettedtexture = false;
+
+	if (gl_palettedtexture->value)
 	{
-		if (gl_ext_pointparameters->value)
+		if (qglColorTableEXT)
 		{
-			VID_Printf(PRINT_ALL, "...using GL_EXT_point_parameters\n");
-			qglPointParameterfEXT = (void (APIENTRY *)(GLenum, GLfloat))
-				GLimp_GetProcAddress ( "glPointParameterfEXT" );
-			qglPointParameterfvEXT = (void (APIENTRY *)(GLenum, const GLfloat *))
-				GLimp_GetProcAddress ( "glPointParameterfvEXT" );
+			gl_config.palettedtexture = true;
+			VID_Printf(PRINT_ALL, "Okay\n");
 		}
 		else
 		{
-			VID_Printf(PRINT_ALL, "...ignoring GL_EXT_point_parameters\n");
+			VID_Printf(PRINT_ALL, "Failed\n");
 		}
 	}
 	else
 	{
-		VID_Printf(PRINT_ALL, "...GL_EXT_point_parameters not found\n");
+		VID_Printf(PRINT_ALL, "Disabled\n");
 	}
 
-	if (!qglColorTableEXT &&
-		strstr(gl_config.extensions_string, "GL_EXT_paletted_texture") &&
-		strstr(gl_config.extensions_string, "GL_EXT_shared_texture_palette"))
+	// ----
+
+	/* Multitexturing */
+	VID_Printf(PRINT_ALL, " - Multitexturing: ");
+
+	if (strstr(gl_config.extensions_string, "GL_ARB_multitexture"))
+	{
+		qglMultiTexCoord2fARB = (void *)GLimp_GetProcAddress("glMultiTexCoord2fARB");
+		qglMultiTexCoord2fvARB = (void *)GLimp_GetProcAddress("glMultiTexCoord2fvARB");
+		qglActiveTextureARB = (void *)GLimp_GetProcAddress("glActiveTextureARB");
+		qglClientActiveTextureARB = (void *)GLimp_GetProcAddress("glClientActiveTextureARB");
+	}
+
+	gl_config.multitexture = false;
+
+	if (gl_multitexture->value)
 	{
-		if (gl_ext_palettedtexture->value)
+		if (qglMultiTexCoord2fARB && qglMultiTexCoord2fvARB && qglActiveTextureARB && qglClientActiveTextureARB)
 		{
-			VID_Printf(PRINT_ALL, "...using GL_EXT_shared_texture_palette\n");
-			qglColorTableEXT =
-				(void (APIENTRY *)(GLenum, GLenum, GLsizei, GLenum, GLenum,
-						const GLvoid * ) ) GLimp_GetProcAddress ("glColorTableEXT");
+			gl_config.multitexture = true;
+			VID_Printf(PRINT_ALL, "Okay\n");
 		}
 		else
 		{
-			VID_Printf(PRINT_ALL, "...ignoring GL_EXT_shared_texture_palette\n");
+			VID_Printf(PRINT_ALL, "Failed\n");
 		}
 	}
 	else
 	{
-		VID_Printf(PRINT_ALL, "...GL_EXT_shared_texture_palette not found\n");
+		VID_Printf(PRINT_ALL, "Disabled\n");
 	}
 
-	if (strstr(gl_config.extensions_string, "GL_ARB_multitexture"))
+	// ----
+
+	/* Multi texturing combine */
+	VID_Printf(PRINT_ALL, " - Multi texturing combine: ");
+
+	if (strstr(gl_config.extensions_string, "GL_ARB_texture_env_combine") && gl_config.multitexture)
 	{
-		if (gl_ext_multitexture->value)
+		if (gl_mtexcombine->value)
 		{
-			VID_Printf(PRINT_ALL, "...using GL_ARB_multitexture\n");
-			qglMultiTexCoord2fARB = ( void * ) GLimp_GetProcAddress ( "glMultiTexCoord2fARB" );
-			qglActiveTextureARB = ( void * ) GLimp_GetProcAddress ( "glActiveTextureARB" );
-			qglClientActiveTextureARB = ( void * ) GLimp_GetProcAddress ( "glClientActiveTextureARB" );
+			gl_config.mtexcombine = true;
+			VID_Printf(PRINT_ALL, "Okay\n");
 		}
 		else
 		{
-			VID_Printf(PRINT_ALL, "...ignoring GL_ARB_multitexture\n");
+			VID_Printf(PRINT_ALL, "Disabled\n");
 		}
 	}
 	else
 	{
-		VID_Printf(PRINT_ALL, "...GL_ARB_multitexture not found\n");
+		VID_Printf(PRINT_ALL, "Failed\n");
 	}
 
-	gl_config.anisotropic = false;
+	// --------
+
+	/* Anisotropic */
+	VID_Printf(PRINT_ALL, " - Anisotropic: ");
 
 	if (strstr(gl_config.extensions_string, "GL_EXT_texture_filter_anisotropic"))
 	{
-		VID_Printf(PRINT_ALL, "...using GL_EXT_texture_filter_anisotropic\n");
 		gl_config.anisotropic = true;
 		glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gl_config.max_anisotropy);
-		Cvar_SetValue("gl_anisotropic_avail", gl_config.max_anisotropy);
+
+		VID_Printf(PRINT_ALL, "%ux\n", (int)gl_config.max_anisotropy);
 	}
 	else
 	{
-		VID_Printf(PRINT_ALL, "...GL_EXT_texture_filter_anisotropic not found\n");
 		gl_config.anisotropic = false;
 		gl_config.max_anisotropy = 0.0;
-		Cvar_SetValue("gl_anisotropic_avail", 0.0);
-	}
 
-	if (strstr(gl_config.extensions_string, "GL_ARB_texture_non_power_of_two"))
-	{
-		VID_Printf(PRINT_ALL, "...using GL_ARB_texture_non_power_of_two\n");
-		gl_config.tex_npot = true;
+		VID_Printf(PRINT_ALL, "Failed\n");
 	}
 
-	gl_config.mtexcombine = false;
+	// ----
+
+	/* Non power of two textures */
+	VID_Printf(PRINT_ALL, " - Non power of two textures: ");
 
-	if (strstr(gl_config.extensions_string, "GL_ARB_texture_env_combine"))
+	if (strstr(gl_config.extensions_string, "GL_ARB_texture_non_power_of_two"))
 	{
-		if (gl_ext_mtexcombine->value)
-		{
-			VID_Printf(PRINT_ALL, "...using GL_ARB_texture_env_combine\n");
-			gl_config.mtexcombine = true;
-		}
-		else
-		{
-			VID_Printf(PRINT_ALL, "...ignoring GL_ARB_texture_env_combine\n");
-		}
+		gl_config.npottextures = true;
+		VID_Printf(PRINT_ALL, "Okay\n");
 	}
 	else
 	{
-		VID_Printf(PRINT_ALL, "...GL_ARB_texture_env_combine not found\n");
+		gl_config.npottextures = false;
+		VID_Printf(PRINT_ALL, "Failed\n");
 	}
 
-	if (!gl_config.mtexcombine)
-	{
-		if (strstr(gl_config.extensions_string, "GL_EXT_texture_env_combine"))
-		{
-			if (gl_ext_mtexcombine->value)
-			{
-				VID_Printf(PRINT_ALL, "...using GL_EXT_texture_env_combine\n");
-				gl_config.mtexcombine = true;
-			}
-			else
-			{
-				VID_Printf(PRINT_ALL, "...ignoring GL_EXT_texture_env_combine\n");
-			}
-		}
-		else
-		{
-			VID_Printf(PRINT_ALL, "...GL_EXT_texture_env_combine not found\n");
-		}
-	}
+	// ----
 
 	R_SetDefaultState();
 
@@ -1497,13 +1570,6 @@ R_Init(void *hinstance, void *hWnd)
 	R_InitParticleTexture();
 	Draw_InitLocal();
 
-	err = glGetError();
-
-	if (err != GL_NO_ERROR)
-	{
-		VID_Printf(PRINT_ALL, "glGetError() = 0x%x\n", err);
-	}
-
 	return true;
 }
 
@@ -1564,6 +1630,21 @@ R_BeginFrame(float camera_separation)
 		}
 	}
 
+	// Clamp overbrightbits
+	if (gl_overbrightbits->modified)
+	{
+		if (gl_overbrightbits->value > 2 && gl_overbrightbits->value < 4)
+		{
+			Cvar_Set("gl_overbrightbits", "2");
+		}
+		else if (gl_overbrightbits->value > 4)
+		{
+			Cvar_Set("gl_overbrightbits", "4");
+		}
+
+		gl_overbrightbits->modified = false;
+	}
+
 	/* go into 2D mode */
 
 	int x, w, y, h;
@@ -1686,7 +1767,11 @@ R_DrawBeam(entity_t *e)
 	vec3_t direction, normalized_direction;
 	vec3_t start_points[NUM_BEAM_SEGS], end_points[NUM_BEAM_SEGS];
 	vec3_t oldorigin, origin;
-
+ 
+	GLfloat vtx[3*NUM_BEAM_SEGS*4];
+	unsigned int index_vtx = 0;
+	unsigned int pointb;
+ 
 	oldorigin[0] = e->oldorigin[0];
 	oldorigin[1] = e->oldorigin[1];
 	oldorigin[2] = e->oldorigin[2];
@@ -1729,27 +1814,35 @@ R_DrawBeam(entity_t *e)
 
 	glColor4f(r, g, b, e->alpha);
 
-	glBegin(GL_TRIANGLE_STRIP);
-
-	for (i = 0; i < NUM_BEAM_SEGS; i++)
+	for ( i = 0; i < NUM_BEAM_SEGS; i++ )
 	{
-		glVertex3fv(start_points[i]);
-		glVertex3fv(end_points[i]);
-		glVertex3fv(start_points[(i + 1) % NUM_BEAM_SEGS]);
-		glVertex3fv(end_points[(i + 1) % NUM_BEAM_SEGS]);
+		vtx[index_vtx++] = start_points [ i ][ 0 ];
+		vtx[index_vtx++] = start_points [ i ][ 1 ];
+		vtx[index_vtx++] = start_points [ i ][ 2 ];
+
+		vtx[index_vtx++] = end_points [ i ][ 0 ];
+		vtx[index_vtx++] = end_points [ i ][ 1 ];
+		vtx[index_vtx++] = end_points [ i ][ 2 ];
+
+		pointb = ( i + 1 ) % NUM_BEAM_SEGS;
+		vtx[index_vtx++] = start_points [ pointb ][ 0 ];
+		vtx[index_vtx++] = start_points [ pointb ][ 1 ];
+		vtx[index_vtx++] = start_points [ pointb ][ 2 ];
+
+		vtx[index_vtx++] = end_points [ pointb ][ 0 ];
+		vtx[index_vtx++] = end_points [ pointb ][ 1 ];
+		vtx[index_vtx++] = end_points [ pointb ][ 2 ];
 	}
 
-	glEnd();
+	glEnableClientState( GL_VERTEX_ARRAY );
+
+	glVertexPointer( 3, GL_FLOAT, 0, vtx );
+	glDrawArrays( GL_TRIANGLE_STRIP, 0, NUM_BEAM_SEGS*4 );
+
+	glDisableClientState( GL_VERTEX_ARRAY );
 
 	glEnable(GL_TEXTURE_2D);
 	glDisable(GL_BLEND);
 	glDepthMask(GL_TRUE);
 }
 
-/*void
-R_GetRefAPI(void)
-{
-	Swap_Init();
-}*/
-
-
diff --git a/src/client/refresh/r_mesh.c b/src/client/refresh/r_mesh.c
index 326d96f..d00c9ff 100644
--- a/src/client/refresh/r_mesh.c
+++ b/src/client/refresh/r_mesh.c
@@ -87,6 +87,8 @@ R_LerpVerts(int nverts, dtrivertx_t *v, dtrivertx_t *ov,
 void
 R_DrawAliasFrameLerp(dmdl_t *paliashdr, float backlerp)
 {
+    unsigned short total;
+    GLenum type;
 	float l;
 	daliasframe_t *frame, *oldframe;
 	dtrivertx_t *v, *ov, *verts;
@@ -153,40 +155,6 @@ R_DrawAliasFrameLerp(dmdl_t *paliashdr, float backlerp)
 
 	R_LerpVerts(paliashdr->num_xyz, v, ov, verts, lerp, move, frontv, backv);
 
-	if (gl_vertex_arrays->value)
-	{
-		float colorArray[MAX_VERTS * 4];
-
-		glEnableClientState(GL_VERTEX_ARRAY);
-		glVertexPointer(3, GL_FLOAT, 16, s_lerped);
-
-		if (currententity->flags &
-			(RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE |
-			 RF_SHELL_DOUBLE | RF_SHELL_HALF_DAM))
-		{
-			glColor4f(shadelight[0], shadelight[1], shadelight[2], alpha);
-		}
-		else
-		{
-			glEnableClientState(GL_COLOR_ARRAY);
-			glColorPointer(3, GL_FLOAT, 0, colorArray);
-
-			/* pre light everything */
-			for (i = 0; i < paliashdr->num_xyz; i++)
-			{
-				float l = shadedots[verts[i].lightnormalindex];
-
-				colorArray[i * 3 + 0] = l * shadelight[0];
-				colorArray[i * 3 + 1] = l * shadelight[1];
-				colorArray[i * 3 + 2] = l * shadelight[2];
-			}
-		}
-
-		if (qglLockArraysEXT != 0)
-		{
-			qglLockArraysEXT(0, paliashdr->num_xyz);
-		}
-
 		while (1)
 		{
 			/* get the vertex count and primitive type */
@@ -200,71 +168,21 @@ R_DrawAliasFrameLerp(dmdl_t *paliashdr, float backlerp)
 			if (count < 0)
 			{
 				count = -count;
-				glBegin(GL_TRIANGLE_FAN);
-			}
-			else
-			{
-				glBegin(GL_TRIANGLE_STRIP);
-			}
-
-			if (currententity->flags &
-				(RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE |
-				 RF_SHELL_DOUBLE |
-				 RF_SHELL_HALF_DAM))
-			{
-				do
-				{
-					index_xyz = order[2];
-					order += 3;
 
-					glVertex3fv(s_lerped[index_xyz]);
-				}
-				while (--count);
+                type = GL_TRIANGLE_FAN;
 			}
 			else
 			{
-				do
-				{
-					/* texture coordinates come from the draw list */
-					glTexCoord2f(((float *)order)[0], ((float *)order)[1]);
-					index_xyz = order[2];
-
-					order += 3;
-
-					glArrayElement(index_xyz);
-				}
-				while (--count);
-			}
-
-			glEnd();
-		}
-
-		if (qglUnlockArraysEXT != 0)
-		{
-			qglUnlockArraysEXT();
-		}
-	}
-	else
-	{
-		while (1)
-		{
-			/* get the vertex count and primitive type */
-			count = *order++;
-
-			if (!count)
-			{
-				break; /* done */
+                type = GL_TRIANGLE_STRIP;
 			}
 
-			if (count < 0)
-			{
-				count = -count;
-				glBegin(GL_TRIANGLE_FAN);
-			}
-			else
-			{
-				glBegin(GL_TRIANGLE_STRIP);
-			}
+			total = count;
+			GLfloat vtx[3*total];
+			GLfloat tex[2*total];
+			GLfloat clr[4 * total];
+			unsigned int index_vtx = 0;
+			unsigned int index_tex = 0;
+			unsigned int index_clr = 0;
 
 			if (currententity->flags &
 				(RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE))
@@ -274,9 +192,14 @@ R_DrawAliasFrameLerp(dmdl_t *paliashdr, float backlerp)
 					index_xyz = order[2];
 					order += 3;
 
-					glColor4f(shadelight[0], shadelight[1],
-							shadelight[2], alpha);
-					glVertex3fv(s_lerped[index_xyz]);
+					clr[index_clr++] = shadelight[0];
+					clr[index_clr++] = shadelight[1];
+					clr[index_clr++] = shadelight[2];
+					clr[index_clr++] = alpha;
+
+					vtx[index_vtx++] = s_lerped[index_xyz][0];
+					vtx[index_vtx++] = s_lerped[index_xyz][1];
+					vtx[index_vtx++] = s_lerped[index_xyz][2];
 				}
 				while (--count);
 			}
@@ -285,23 +208,40 @@ R_DrawAliasFrameLerp(dmdl_t *paliashdr, float backlerp)
 				do
 				{
 					/* texture coordinates come from the draw list */
-					glTexCoord2f(((float *)order)[0], ((float *)order)[1]);
+					tex[index_tex++] = ((float *) order)[0];
+					tex[index_tex++] = ((float *) order)[1];
+
 					index_xyz = order[2];
 					order += 3;
 
 					/* normals and vertexes come from the frame list */
 					l = shadedots[verts[index_xyz].lightnormalindex];
 
-					glColor4f(l * shadelight[0], l * shadelight[1],
-							l * shadelight[2], alpha);
-					glVertex3fv(s_lerped[index_xyz]);
+					clr[index_clr++] = l * shadelight[0];
+					clr[index_clr++] = l * shadelight[1];
+					clr[index_clr++] = l * shadelight[2];
+					clr[index_clr++] = alpha;
+
+					vtx[index_vtx++] = s_lerped[index_xyz][0];
+					vtx[index_vtx++] = s_lerped[index_xyz][1];
+					vtx[index_vtx++] = s_lerped[index_xyz][2];
 				}
 				while (--count);
 			}
 
-			glEnd();
+			glEnableClientState(GL_VERTEX_ARRAY);
+			glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+			glEnableClientState(GL_COLOR_ARRAY);
+
+			glVertexPointer(3, GL_FLOAT, 0, vtx);
+			glTexCoordPointer(2, GL_FLOAT, 0, tex);
+			glColorPointer(4, GL_FLOAT, 0, clr);
+			glDrawArrays(type, 0, total);
+
+			glDisableClientState(GL_VERTEX_ARRAY);
+			glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+			glDisableClientState(GL_COLOR_ARRAY);
 		}
-	}
 
 	if (currententity->flags &
 		(RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE |
@@ -314,6 +254,8 @@ R_DrawAliasFrameLerp(dmdl_t *paliashdr, float backlerp)
 void
 R_DrawAliasShadow(dmdl_t *paliashdr, int posenum)
 {
+    unsigned short total;
+    GLenum type;
 	int *order;
 	vec3_t point;
 	float height = 0, lheight;
@@ -344,13 +286,18 @@ R_DrawAliasShadow(dmdl_t *paliashdr, int posenum)
 		if (count < 0)
 		{
 			count = -count;
-			glBegin(GL_TRIANGLE_FAN);
+			
+            type = GL_TRIANGLE_FAN;
 		}
 		else
 		{
-			glBegin(GL_TRIANGLE_STRIP);
+            type = GL_TRIANGLE_STRIP;
 		}
 
+        total = count;
+        GLfloat vtx[3*total];
+        unsigned int index_vtx = 0;
+
 		do
 		{
 			/* normals and vertexes come from the frame list */
@@ -359,13 +306,21 @@ R_DrawAliasShadow(dmdl_t *paliashdr, int posenum)
 			point[0] -= shadevector[0] * (point[2] + lheight);
 			point[1] -= shadevector[1] * (point[2] + lheight);
 			point[2] = height;
-			glVertex3fv(point);
+
+            vtx[index_vtx++] = point [ 0 ];
+            vtx[index_vtx++] = point [ 1 ];
+            vtx[index_vtx++] = point [ 2 ];
 
 			order += 3;
 		}
 		while (--count);
 
-		glEnd();
+        glEnableClientState( GL_VERTEX_ARRAY );
+
+        glVertexPointer( 3, GL_FLOAT, 0, vtx );
+        glDrawArrays( type, 0, total );
+
+        glDisableClientState( GL_VERTEX_ARRAY );
 	}
 
 	/* stencilbuffer shadows */
@@ -669,11 +624,8 @@ R_DrawAliasModel(entity_t *e)
 	}
 
 
-    /* Apply gl_overbrightbits to the mesh. If we don't do this they will appear slightly dimmer relative to
-       walls. Also note that gl_overbrightbits is only applied to walls when gl_ext_mtexcombine is set to 1,
-       so we'll also want to check that; otherwise we'll end up in the reverse situation and the meshes will
-       appear too bright. */
-    if (gl_config.mtexcombine && gl_overbrightbits->value)
+    // Apply gl_overbrightbits to the mesh. If we don't do this they will appear slightly dimmer relative to walls.
+    if (gl_overbrightbits->value)
     {
         for (i = 0; i < 3; ++i)
         {
@@ -831,7 +783,7 @@ R_DrawAliasModel(entity_t *e)
 
 		glDisable(GL_TEXTURE_2D);
 		glEnable(GL_BLEND);
-		glColor4f(0, 0, 0, 0.5);
+		glColor4f(0, 0, 0, 0.5f);
 		R_DrawAliasShadow(paliashdr, currententity->frame);
 		glEnable(GL_TEXTURE_2D);
 		glDisable(GL_BLEND);
diff --git a/src/client/refresh/r_misc.c b/src/client/refresh/r_misc.c
index 90ebcc4..a07d0c5 100644
--- a/src/client/refresh/r_misc.c
+++ b/src/client/refresh/r_misc.c
@@ -216,7 +216,7 @@ R_SetDefaultState(void)
 
 	R_TexEnv(GL_REPLACE);
 
-	if (qglPointParameterfEXT)
+	if (gl_config.pointparameters)
 	{
 		float attenuations[3];
 
@@ -229,14 +229,12 @@ R_SetDefaultState(void)
 		   i915.so. That the points are squares and not circles
 		   is not a problem by Quake II! */
 		glEnable(GL_POINT_SMOOTH);
-		qglPointParameterfEXT(GL_POINT_SIZE_MIN_EXT,
-				gl_particle_min_size->value);
-		qglPointParameterfEXT(GL_POINT_SIZE_MAX_EXT,
-				gl_particle_max_size->value);
-		qglPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, attenuations);
+		qglPointParameterfARB(GL_POINT_SIZE_MIN_EXT, gl_particle_min_size->value);
+		qglPointParameterfARB(GL_POINT_SIZE_MAX_EXT, gl_particle_max_size->value);
+		qglPointParameterfvARB(GL_DISTANCE_ATTENUATION_EXT, attenuations);
 	}
 
-	if (qglColorTableEXT && gl_ext_palettedtexture->value)
+	if (gl_config.palettedtexture)
 	{
 		glEnable(GL_SHARED_TEXTURE_PALETTE_EXT);
 		R_SetTexturePalette(d_8to24table);
diff --git a/src/client/refresh/r_surf.c b/src/client/refresh/r_surf.c
index 93c51f5..6af16ff 100644
--- a/src/client/refresh/r_surf.c
+++ b/src/client/refresh/r_surf.c
@@ -68,19 +68,19 @@ R_TextureAnimation(mtexinfo_t *tex)
 void
 R_DrawGLPoly(glpoly_t *p)
 {
-	int i;
 	float *v;
 
-	glBegin(GL_POLYGON);
 	v = p->verts[0];
 
-	for (i = 0; i < p->numverts; i++, v += VERTEXSIZE)
-	{
-		glTexCoord2f(v[3], v[4]);
-		glVertex3fv(v);
-	}
+    glEnableClientState( GL_VERTEX_ARRAY );
+    glEnableClientState( GL_TEXTURE_COORD_ARRAY );
+
+    glVertexPointer( 3, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v );
+    glTexCoordPointer( 2, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v+3 );
+    glDrawArrays( GL_TRIANGLE_FAN, 0, p->numverts );
 
-	glEnd();
+    glDisableClientState( GL_VERTEX_ARRAY );
+    glDisableClientState( GL_TEXTURE_COORD_ARRAY );
 }
 
 void
@@ -100,16 +100,27 @@ R_DrawGLFlowingPoly(msurface_t *fa)
 		scroll = -64.0;
 	}
 
-	glBegin(GL_POLYGON);
-	v = p->verts[0];
+    GLfloat tex[2*p->numverts];
+    unsigned int index_tex = 0;
 
-	for (i = 0; i < p->numverts; i++, v += VERTEXSIZE)
-	{
-		glTexCoord2f((v[3] + scroll), v[4]);
-		glVertex3fv(v);
-	}
+    v = p->verts [ 0 ];
+
+	for ( i = 0; i < p->numverts; i++, v += VERTEXSIZE )
+    {
+        tex[index_tex++] = v [ 3 ] + scroll;
+        tex[index_tex++] = v [ 4 ];
+    }
+    v = p->verts [ 0 ];
 
-	glEnd();
+    glEnableClientState( GL_VERTEX_ARRAY );
+    glEnableClientState( GL_TEXTURE_COORD_ARRAY );
+
+    glVertexPointer( 3, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v );
+    glTexCoordPointer( 2, GL_FLOAT, 0, tex );
+    glDrawArrays( GL_TRIANGLE_FAN, 0, p->numverts );
+
+    glDisableClientState( GL_VERTEX_ARRAY );
+    glDisableClientState( GL_TEXTURE_COORD_ARRAY );
 }
 
 void
@@ -141,12 +152,23 @@ R_DrawTriangleOutlines(void)
 			{
 				for (j = 2; j < p->numverts; j++)
 				{
-					glBegin(GL_LINE_STRIP);
-					glVertex3fv(p->verts[0]);
-					glVertex3fv(p->verts[j - 1]);
-					glVertex3fv(p->verts[j]);
-					glVertex3fv(p->verts[0]);
-					glEnd();
+                    GLfloat vtx[12];
+                    unsigned int k;
+
+                    for (k=0; k<3; k++)
+                    {
+                       vtx[0+k] = p->verts [ 0 ][ k ];
+                        vtx[3+k] = p->verts [ j - 1 ][ k ];
+                        vtx[6+k] = p->verts [ j ][ k ];
+                        vtx[9+k] = p->verts [ 0 ][ k ];
+                    }
+
+                    glEnableClientState( GL_VERTEX_ARRAY );
+
+                    glVertexPointer( 3, GL_FLOAT, 0, vtx );
+                    glDrawArrays( GL_LINE_STRIP, 0, 4 );
+
+                    glDisableClientState( GL_VERTEX_ARRAY );
 				}
 			}
 		}
@@ -164,7 +186,6 @@ R_DrawGLPolyChain(glpoly_t *p, float soffset, float toffset)
 		for ( ; p != 0; p = p->chain)
 		{
 			float *v;
-			int j;
 
 			v = p->verts[0];
 
@@ -174,15 +195,15 @@ R_DrawGLPolyChain(glpoly_t *p, float soffset, float toffset)
 				return;
 			}
 
-			glBegin(GL_POLYGON);
+            glEnableClientState( GL_VERTEX_ARRAY );
+            glEnableClientState( GL_TEXTURE_COORD_ARRAY );
 
-			for (j = 0; j < p->numverts; j++, v += VERTEXSIZE)
-			{
-				glTexCoord2f(v[5], v[6]);
-				glVertex3fv(v);
-			}
+            glVertexPointer( 3, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v );
+            glTexCoordPointer( 2, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v+5 );
+            glDrawArrays( GL_TRIANGLE_FAN, 0, p->numverts );
 
-			glEnd();
+            glDisableClientState( GL_VERTEX_ARRAY );
+            glDisableClientState( GL_TEXTURE_COORD_ARRAY );
 		}
 	}
 	else
@@ -192,16 +213,28 @@ R_DrawGLPolyChain(glpoly_t *p, float soffset, float toffset)
 			float *v;
 			int j;
 
-			glBegin(GL_POLYGON);
 			v = p->verts[0];
 
-			for (j = 0; j < p->numverts; j++, v += VERTEXSIZE)
+            GLfloat tex[2*p->numverts];
+            unsigned int index_tex = 0;
+
+			for ( j = 0; j < p->numverts; j++, v += VERTEXSIZE )
 			{
-				glTexCoord2f(v[5] - soffset, v[6] - toffset);
-				glVertex3fv(v);
+			    tex[index_tex++] = v [ 5 ] - soffset;
+			    tex[index_tex++] = v [ 6 ] - toffset;
 			}
 
-			glEnd();
+			v = p->verts [ 0 ];
+
+            glEnableClientState( GL_VERTEX_ARRAY );
+            glEnableClientState( GL_TEXTURE_COORD_ARRAY );
+
+            glVertexPointer( 3, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v );
+            glTexCoordPointer( 2, GL_FLOAT, 0, tex );
+            glDrawArrays( GL_TRIANGLE_FAN, 0, p->numverts );
+
+            glDisableClientState( GL_VERTEX_ARRAY );
+            glDisableClientState( GL_TEXTURE_COORD_ARRAY );
 		}
 	}
 }
@@ -269,6 +302,14 @@ R_BlendLightmaps(void)
 			{
 				if (surf->polys)
 				{
+					// Apply overbright bits to the static lightmaps
+					if (gl_overbrightbits->value)
+					{
+						R_TexEnv(GL_COMBINE_EXT);
+						R_SelectTexture(GL_TEXTURE1);
+						glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, gl_overbrightbits->value);
+					}
+
 					R_DrawGLPolyChain(surf->polys, 0, 0);
 				}
 			}
@@ -321,6 +362,14 @@ R_BlendLightmaps(void)
 				{
 					if (drawsurf->polys)
 					{
+						// Apply overbright bits to the dynamic lightmaps
+						if (gl_overbrightbits->value)
+						{
+							R_TexEnv(GL_COMBINE_EXT);
+							R_SelectTexture(GL_TEXTURE1);
+							glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, gl_overbrightbits->value);
+						}
+
 						R_DrawGLPolyChain(drawsurf->polys,
 								(drawsurf->light_s - drawsurf->dlight_s) * (1.0 / 128.0),
 								(drawsurf->light_t - drawsurf->dlight_t) * (1.0 / 128.0));
@@ -358,6 +407,14 @@ R_BlendLightmaps(void)
 		{
 			if (surf->polys)
 			{
+				// Apply overbright bits to the remainder lightmaps
+				if (gl_overbrightbits->value)
+				{
+					R_TexEnv(GL_COMBINE_EXT);
+					R_SelectTexture(GL_TEXTURE1);
+					glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, gl_overbrightbits->value);
+				}
+
 				R_DrawGLPolyChain(surf->polys,
 						(surf->light_s - surf->dlight_s) * (1.0 / 128.0),
 						(surf->light_t - surf->dlight_t) * (1.0 / 128.0));
@@ -386,10 +443,32 @@ R_RenderBrushPoly(msurface_t *fa)
 	{
 		R_Bind(image->texnum);
 
-		/* warp texture, no lightmaps */
-		R_TexEnv(GL_MODULATE);
-		glColor4f(gl_state.inverse_intensity, gl_state.inverse_intensity,
-				gl_state.inverse_intensity, 1.0F);
+		/* This is a hack ontop of a hack. Warping surfaces like those generated
+		   by R_EmitWaterPolys() don't have a lightmap. Original Quake II therefor
+		   negated the global intensity on those surfaces, because otherwise they
+		   would show up much too bright. When we implemented overbright bits this
+		   hack modified the global GL state in an incompatible way. So implement
+		   a new hack, based on overbright bits... Depending on the value set to
+		   gl_overbrightbits the result is different:
+
+		    0: Old behaviour.
+		    1: No overbright bits on the global scene but correct lightning on
+		       warping surfaces.
+		    2: Overbright bits on the global scene but not on warping surfaces.
+		        They oversaturate otherwise. */
+		if (gl_overbrightbits->value)
+		{
+			R_TexEnv(GL_COMBINE_EXT);
+			R_SelectTexture(GL_TEXTURE1);
+			glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 1);
+		}
+		else
+		{
+			R_TexEnv(GL_MODULATE);
+			glColor4f(gl_state.inverse_intensity, gl_state.inverse_intensity,
+					  gl_state.inverse_intensity, 1.0f);
+		}
+
 		R_EmitWaterPolys(fa);
 		R_TexEnv(GL_REPLACE);
 
@@ -542,7 +621,7 @@ R_DrawTextureChains(void)
 
 	c_visible_textures = 0;
 
-	if (!qglActiveTextureARB)
+	if (!gl_config.multitexture)
 	{
 		for (i = 0, image = gltextures; i < numgltextures; i++, image++)
 		{
@@ -624,34 +703,45 @@ R_DrawTextureChains(void)
 	R_TexEnv(GL_REPLACE);
 }
 
-static void
+void
 R_RenderLightmappedPoly(msurface_t *surf)
 {
-	int i, nv = surf->polys->numverts;
+	int i;
 	int map;
+	int nv;
+	int smax;
+	int tmax;
+	float scroll;
 	float *v;
-	image_t *image = R_TextureAnimation(surf->texinfo);
-	qboolean is_dynamic = false;
-	unsigned lmtex = surf->lightmaptexturenum;
 	glpoly_t *p;
+	image_t *image;
+	qboolean is_dynamic;
+	unsigned lmtex;
+	unsigned temp[128 * 128];
+
+	image = R_TextureAnimation(surf->texinfo);
+	is_dynamic = false;
+	lmtex = surf->lightmaptexturenum;
+	nv = surf->polys->numverts;
 
+	// Any dynamic lights on this surface?
 	for (map = 0; map < MAXLIGHTMAPS && surf->styles[map] != 255; map++)
 	{
-		if (r_newrefdef.lightstyles[surf->styles[map]].white !=
-			surf->cached_light[map])
+		if (r_newrefdef.lightstyles[surf->styles[map]].white != surf->cached_light[map])
 		{
-			goto dynamic;
+			if (!(surf->texinfo->flags & (SURF_SKY | SURF_TRANS33 | SURF_TRANS66 | SURF_WARP)))
+			{
+				is_dynamic = true;
+			}
 		}
 	}
 
+	// Normal dynamic lights
 	if (surf->dlightframe == r_framecount)
 	{
-	dynamic:
-
 		if (gl_dynamic->value)
 		{
-			if (!(surf->texinfo->flags &
-				  (SURF_SKY | SURF_TRANS33 | SURF_TRANS66 | SURF_WARP)))
+			if (!(surf->texinfo->flags & (SURF_SKY | SURF_TRANS33 | SURF_TRANS66 | SURF_WARP)))
 			{
 				is_dynamic = true;
 			}
@@ -660,140 +750,97 @@ R_RenderLightmappedPoly(msurface_t *surf)
 
 	if (is_dynamic)
 	{
-		unsigned temp[128 * 128];
-		int smax, tmax;
-
-		if (((surf->styles[map] >= 32) ||
-			 (surf->styles[map] == 0)) &&
-				(surf->dlightframe != r_framecount))
+		// Dynamic lights on a surface
+		if (((surf->styles[map] >= 32) || (surf->styles[map] == 0)) && (surf->dlightframe != r_framecount))
 		{
 			smax = (surf->extents[0] >> 4) + 1;
 			tmax = (surf->extents[1] >> 4) + 1;
 
-			R_BuildLightMap(surf, (void *)temp, smax * 4);
+			R_BuildLightMap(surf, (void *) temp, smax * 4);
 			R_SetCacheState(surf);
-
 			R_MBind(GL_TEXTURE1_ARB, gl_state.lightmap_textures + surf->lightmaptexturenum);
 
 			lmtex = surf->lightmaptexturenum;
 
-			glTexSubImage2D(GL_TEXTURE_2D, 0, surf->light_s, surf->light_t,
-					smax, tmax, GL_LIGHTMAP_FORMAT, GL_UNSIGNED_BYTE, temp);
+			glTexSubImage2D(GL_TEXTURE_2D, 0, surf->light_s, surf->light_t, smax,
+							tmax, GL_LIGHTMAP_FORMAT, GL_UNSIGNED_BYTE, temp);
 		}
-		else
+		else // Normal dynamic lights
 		{
 			smax = (surf->extents[0] >> 4) + 1;
 			tmax = (surf->extents[1] >> 4) + 1;
 
-			R_BuildLightMap(surf, (void *)temp, smax * 4);
-
+			R_BuildLightMap(surf, (void *) temp, smax * 4);
 			R_MBind(GL_TEXTURE1_ARB, gl_state.lightmap_textures + 0);
 
 			lmtex = 0;
 
-			glTexSubImage2D(GL_TEXTURE_2D, 0, surf->light_s, surf->light_t,
-					smax, tmax, GL_LIGHTMAP_FORMAT, GL_UNSIGNED_BYTE, temp);
+			glTexSubImage2D(GL_TEXTURE_2D, 0, surf->light_s, surf->light_t, smax,
+							tmax, GL_LIGHTMAP_FORMAT, GL_UNSIGNED_BYTE, temp);
 		}
 
 		c_brush_polys++;
 
 		R_MBind(GL_TEXTURE0_ARB, image->texnum);
 		R_MBind(GL_TEXTURE1_ARB, gl_state.lightmap_textures + lmtex);
-
-		if (surf->texinfo->flags & SURF_FLOWING)
-		{
-			float scroll;
-
-			scroll = -64 *
-					 ((r_newrefdef.time / 40.0) - (int)(r_newrefdef.time / 40.0));
-
-			if (scroll == 0.0)
-			{
-				scroll = -64.0;
-			}
-
-			for (p = surf->polys; p; p = p->chain)
-			{
-				v = p->verts[0];
-				glBegin(GL_POLYGON);
-
-				for (i = 0; i < nv; i++, v += VERTEXSIZE)
-				{
-					qglMultiTexCoord2fARB(GL_TEXTURE0_ARB, (v[3] + scroll), v[4]);
-					qglMultiTexCoord2fARB(GL_TEXTURE1_ARB, v[5], v[6]);
-					glVertex3fv(v);
-				}
-
-				glEnd();
-			}
-		}
-		else
-		{
-			for (p = surf->polys; p; p = p->chain)
-			{
-				v = p->verts[0];
-				glBegin(GL_POLYGON);
-
-				for (i = 0; i < nv; i++, v += VERTEXSIZE)
-				{
-					qglMultiTexCoord2fARB(GL_TEXTURE0_ARB, v[3], v[4]);
-					qglMultiTexCoord2fARB(GL_TEXTURE1_ARB, v[5], v[6]);
-					glVertex3fv(v);
-				}
-
-				glEnd();
-			}
-		}
 	}
-	else
+	else // No dynamic lights
 	{
 		c_brush_polys++;
 
 		R_MBind(GL_TEXTURE0_ARB, image->texnum);
 		R_MBind(GL_TEXTURE1_ARB, gl_state.lightmap_textures + lmtex);
+	}
 
-		if (surf->texinfo->flags & SURF_FLOWING)
+	if (surf->texinfo->flags & SURF_FLOWING)
+	{
+		scroll = -64 * ((r_newrefdef.time / 40.0) - (int) (r_newrefdef.time / 40.0));
+
+		if (scroll == 0.0)
 		{
-			float scroll;
+			scroll = -64.0;
+		}
 
-			scroll = -64 * ((r_newrefdef.time / 40.0) - (int)(r_newrefdef.time / 40.0));
+		for (p = surf->polys; p; p = p->chain)
+		{
+			v = p->verts[0];
+			glBegin(GL_POLYGON);
 
-			if (scroll == 0.0)
+			for (i = 0; i < nv; i++, v += VERTEXSIZE)
 			{
-				scroll = -64.0;
+				qglMultiTexCoord2fARB(GL_TEXTURE0, (v[3] + scroll), v[4]);
+				qglMultiTexCoord2fvARB(GL_TEXTURE1, &v[5]);
+				glVertex3fv(v);
 			}
 
-			for (p = surf->polys; p; p = p->chain)
-			{
-				v = p->verts[0];
-				glBegin(GL_POLYGON);
-
-				for (i = 0; i < nv; i++, v += VERTEXSIZE)
-				{
-					qglMultiTexCoord2fARB(GL_TEXTURE0_ARB, (v[3] + scroll), v[4]);
-					qglMultiTexCoord2fARB(GL_TEXTURE1_ARB, v[5], v[6]);
-					glVertex3fv(v);
-				}
-
-				glEnd();
-			}
+			glEnd();
 		}
-		else
+	}
+	else
+	{
+		for (p = surf->polys; p; p = p->chain)
 		{
-			for (p = surf->polys; p; p = p->chain)
-			{
-				v = p->verts[0];
-				glBegin(GL_POLYGON);
+			v = p->verts[0];
 
-				for (i = 0; i < nv; i++, v += VERTEXSIZE)
-				{
-					qglMultiTexCoord2fARB(GL_TEXTURE0_ARB, v[3], v[4]);
-					qglMultiTexCoord2fARB(GL_TEXTURE1_ARB, v[5], v[6]);
-					glVertex3fv(v);
-				}
+			// Polygon
+			glEnableClientState(GL_VERTEX_ARRAY);
+			glVertexPointer(3, GL_FLOAT, VERTEXSIZE * sizeof(GLfloat), v);
 
-				glEnd();
-			}
+			// Texture
+			glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+			qglClientActiveTextureARB(GL_TEXTURE0_ARB);
+			glTexCoordPointer(2, GL_FLOAT, VERTEXSIZE * sizeof(GLfloat), v + 3);
+
+			// Lightmap
+			glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+			qglClientActiveTextureARB(GL_TEXTURE1_ARB);
+			glTexCoordPointer(2, GL_FLOAT, VERTEXSIZE * sizeof(GLfloat), v + 5);
+
+			// Draw the crap
+			glDrawArrays(GL_TRIANGLE_FAN, 0, p->numverts);
+
+			glDisableClientState(GL_VERTEX_ARRAY);
+			glDisableClientState(GL_TEXTURE_COORD_ARRAY);
 		}
 	}
 }
@@ -814,8 +861,7 @@ R_DrawInlineBModel(void)
 
 		for (k = 0; k < r_newrefdef.num_dlights; k++, lt++)
 		{
-			R_MarkLights(lt, 1 << k,
-					currentmodel->nodes + currentmodel->firstnode);
+			R_MarkLights(lt, 1 << k, currentmodel->nodes + currentmodel->firstnode);
 		}
 	}
 
@@ -846,7 +892,7 @@ R_DrawInlineBModel(void)
 				psurf->texturechain = r_alpha_surfaces;
 				r_alpha_surfaces = psurf;
 			}
-			else if (qglMultiTexCoord2fARB && !(psurf->flags & SURF_DRAWTURB))
+			else if (gl_config.multitexture && !(psurf->flags & SURF_DRAWTURB))
 			{
 				R_RenderLightmappedPoly(psurf);
 			}
@@ -861,7 +907,7 @@ R_DrawInlineBModel(void)
 
 	if (!(currententity->flags & RF_TRANSLUCENT))
 	{
-		if (!qglMultiTexCoord2fARB)
+		if (!gl_config.multitexture)
 		{
 			R_BlendLightmaps();
 		}
@@ -916,7 +962,7 @@ R_DrawBrushModel(entity_t *e)
 		glEnable(GL_POLYGON_OFFSET_FILL);
 	}
 
-	glColor3f(1, 1, 1);
+	glColor4f(1, 1, 1, 1);
 	memset(gl_lms.lightmap_surfaces, 0, sizeof(gl_lms.lightmap_surfaces));
 
 	VectorSubtract(r_newrefdef.vieworg, e->origin, modelorg);
@@ -1121,7 +1167,7 @@ R_RecursiveWorldNode(mnode_t *node)
 		}
 		else
 		{
-			if (qglMultiTexCoord2fARB && !(surf->flags & SURF_DRAWTURB))
+			if (gl_config.multitexture && !(surf->flags & SURF_DRAWTURB))
 			{
 				R_RenderLightmappedPoly(surf);
 			}
@@ -1165,11 +1211,11 @@ R_DrawWorld(void)
 
 	gl_state.currenttextures[0] = gl_state.currenttextures[1] = -1;
 
-	glColor3f(1, 1, 1);
+	glColor4f(1, 1, 1, 1);
 	memset(gl_lms.lightmap_surfaces, 0, sizeof(gl_lms.lightmap_surfaces));
 	R_ClearSkyBox();
 
-	if (qglMultiTexCoord2fARB)
+	if (gl_config.multitexture)
 	{
 		R_EnableMultitexture(true);
 
@@ -1178,7 +1224,7 @@ R_DrawWorld(void)
 		if (!gl_config.mtexcombine)
 		{
 			R_TexEnv(GL_REPLACE);
-			R_SelectTexture(GL_TEXTURE1);
+			R_SelectTexture(GL_TEXTURE1_ARB);
 
 			if (gl_lightmap->value)
 			{
@@ -1196,7 +1242,7 @@ R_DrawWorld(void)
 			glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
 			glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE);
 			glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE);
-			R_SelectTexture(GL_TEXTURE1);
+			R_SelectTexture(GL_TEXTURE1_ARB);
 			R_TexEnv(GL_COMBINE_EXT);
 
 			if (gl_lightmap->value)
diff --git a/src/client/refresh/r_warp.c b/src/client/refresh/r_warp.c
index f0bc952..95a1b90 100644
--- a/src/client/refresh/r_warp.c
+++ b/src/client/refresh/r_warp.c
@@ -38,7 +38,12 @@ vec3_t skyaxis;
 image_t *sky_images[6];
 msurface_t *warpface;
 int skytexorder[6] = {0, 2, 1, 3, 4, 5};
-
+ 
+GLfloat vtx_sky[12];
+GLfloat tex_sky[8];
+unsigned int index_vtx = 0;
+unsigned int index_tex = 0;
+ 
 /* 3dstudio environment map names */
 char *suf[6] = {"rt", "bk", "lf", "ft", "up", "dn"};
 
@@ -297,25 +302,33 @@ R_EmitWaterPolys(msurface_t *fa)
 	{
 		p = bp;
 
-		glBegin(GL_TRIANGLE_FAN);
+        GLfloat tex[2*p->numverts];
+        unsigned int index_tex = 0;
 
-		for (i = 0, v = p->verts[0]; i < p->numverts; i++, v += VERTEXSIZE)
+		for ( i = 0, v = p->verts [ 0 ]; i < p->numverts; i++, v += VERTEXSIZE )
 		{
-			os = v[3];
-			ot = v[4];
+			os = v [ 3 ];
+			ot = v [ 4 ];
 
-			s = os + r_turbsin[(int)((ot * 0.125 + r_newrefdef.time) * TURBSCALE) & 255];
+			s = os + r_turbsin [ (int) ( ( ot * 0.125 + r_newrefdef.time ) * TURBSCALE ) & 255 ];
 			s += scroll;
-			s *= (1.0 / 64);
-
-			t = ot + r_turbsin[(int)((os * 0.125 + rdt) * TURBSCALE) & 255];
-			t *= (1.0 / 64);
+			tex[index_tex++] = s * ( 1.0 / 64 );
 
-			glTexCoord2f(s, t);
-			glVertex3fv(v);
+			t = ot + r_turbsin [ (int) ( ( os * 0.125 + rdt ) * TURBSCALE ) & 255 ];
+			tex[index_tex++] = t * ( 1.0 / 64 );
 		}
 
-		glEnd();
+		v = p->verts [ 0 ];
+
+        glEnableClientState( GL_VERTEX_ARRAY );
+        glEnableClientState( GL_TEXTURE_COORD_ARRAY );
+
+        glVertexPointer( 3, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v );
+        glTexCoordPointer( 2, GL_FLOAT, 0, tex );
+        glDrawArrays( GL_TRIANGLE_FAN, 0, p->numverts );
+
+        glDisableClientState( GL_VERTEX_ARRAY );
+        glDisableClientState( GL_TEXTURE_COORD_ARRAY );
 	}
 }
 
@@ -634,8 +647,13 @@ R_MakeSkyVec(float s, float t, int axis)
 	}
 
 	t = 1.0 - t;
-	glTexCoord2f(s, t);
-	glVertex3fv(v);
+
+    tex_sky[index_tex++] = s;
+    tex_sky[index_tex++] = t;
+
+    vtx_sky[index_vtx++] = v[ 0 ];
+    vtx_sky[index_vtx++] = v[ 1 ];
+    vtx_sky[index_vtx++] = v[ 2 ];
 }
 
 void
@@ -682,12 +700,24 @@ R_DrawSkyBox(void)
 
 		R_Bind(sky_images[skytexorder[i]]->texnum);
 
-		glBegin(GL_QUADS);
-		R_MakeSkyVec(skymins[0][i], skymins[1][i], i);
-		R_MakeSkyVec(skymins[0][i], skymaxs[1][i], i);
-		R_MakeSkyVec(skymaxs[0][i], skymaxs[1][i], i);
-		R_MakeSkyVec(skymaxs[0][i], skymins[1][i], i);
-		glEnd();
+        glEnableClientState( GL_VERTEX_ARRAY );
+        glEnableClientState( GL_TEXTURE_COORD_ARRAY );
+
+
+        index_vtx = 0;
+        index_tex = 0;
+
+		R_MakeSkyVec( skymins [ 0 ] [ i ], skymins [ 1 ] [ i ], i );
+		R_MakeSkyVec( skymins [ 0 ] [ i ], skymaxs [ 1 ] [ i ], i );
+		R_MakeSkyVec( skymaxs [ 0 ] [ i ], skymaxs [ 1 ] [ i ], i );
+		R_MakeSkyVec( skymaxs [ 0 ] [ i ], skymins [ 1 ] [ i ], i );
+
+        glVertexPointer( 3, GL_FLOAT, 0, vtx_sky );
+        glTexCoordPointer( 2, GL_FLOAT, 0, tex_sky );
+        glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
+
+        glDisableClientState( GL_VERTEX_ARRAY );
+        glDisableClientState( GL_TEXTURE_COORD_ARRAY );
 	}
 
 	glPopMatrix();
@@ -705,7 +735,7 @@ R_SetSky(char *name, float rotate, vec3_t axis)
 
 	for (i = 0; i < 6; i++)
 	{
-		if (qglColorTableEXT && gl_ext_palettedtexture->value)
+		if (gl_config.palettedtexture)
 		{
 			Com_sprintf(pathname, sizeof(pathname), "env/%s%s.pcx",
 					skyname, suf[i]);
diff --git a/src/client/sound/openal.c b/src/client/sound/openal.c
index 48a3f12..4261214 100644
--- a/src/client/sound/openal.c
+++ b/src/client/sound/openal.c
@@ -842,7 +842,7 @@ AL_Shutdown(void)
 {
 	Com_Printf("Shutting down OpenAL.\n");
 
-	AL_StreamDie();
+	AL_StopAllChannels();
 
 	qalDeleteSources(1, &streamSource);
 	qalDeleteFilters(1, &underwaterFilter);
diff --git a/src/common/cvar.c b/src/common/cvar.c
index 008d09c..ceaec0e 100644
--- a/src/common/cvar.c
+++ b/src/common/cvar.c
@@ -471,6 +471,7 @@ Cvar_WriteVariables(char *path)
 		}
 	}
 
+	fflush(f);
 	fclose(f);
 }
 
diff --git a/src/common/filesystem.c b/src/common/filesystem.c
index 3768741..0293ff2 100644
--- a/src/common/filesystem.c
+++ b/src/common/filesystem.c
@@ -306,68 +306,6 @@ FS_GetFileByHandle(fileHandle_t f)
 }
 
 /*
- * Returns file size or -1 on error.
- */
-int
-FS_FOpenFileAppend(fsHandle_t *handle)
-{
-	char path[MAX_OSPATH];
-
-	FS_CreatePath(handle->name);
-
-	Com_sprintf(path, sizeof(path), "%s/%s", fs_gamedir, handle->name);
-
-	handle->file = fopen(path, "ab");
-
-	if (handle->file)
-	{
-		if (fs_debug->value)
-		{
-			Com_Printf("FS_FOpenFileAppend: '%s'.\n", path);
-		}
-
-		return FS_FileLength(handle->file);
-	}
-
-	if (fs_debug->value)
-	{
-		Com_Printf("FS_FOpenFileAppend: couldn't open '%s'.\n", path);
-	}
-
-	return -1;
-}
-
-/*
- * Always returns 0 or -1 on error.
- */
-int
-FS_FOpenFileWrite(fsHandle_t *handle)
-{
-	char path[MAX_OSPATH];
-
-	FS_CreatePath(handle->name);
-
-	Com_sprintf(path, sizeof(path), "%s/%s", fs_gamedir, handle->name);
-
-	if ((handle->file = fopen(path, "wb")) != NULL)
-	{
-		if (fs_debug->value)
-		{
-			Com_Printf("FS_FOpenFileWrite: '%s'.\n", path);
-		}
-
-		return 0;
-	}
-
-	if (fs_debug->value)
-	{
-		Com_Printf("FS_FOpenFileWrite: couldn't open '%s'.\n", path);
-	}
-
-	return -1;
-}
-
-/*
  * Other dll's can't just call fclose() on files returned by FS_FOpenFile.
  */
 void
diff --git a/src/common/header/common.h b/src/common/header/common.h
index 9199fe0..18d705c 100644
--- a/src/common/header/common.h
+++ b/src/common/header/common.h
@@ -33,15 +33,19 @@
 #include "crc.h"
 
 /* Should have 4 characters. */
-#define YQ2VERSION "5.34"
+#define YQ2VERSION "6.00"
 #define BASEDIRNAME "baseq2"
 
-#ifndef OSTYPE
-#error OSTYPE should be defined by the build system
+#ifndef YQ2OSTYPE
+#error YQ2OSTYPE should be defined by the build system
 #endif
 
-#ifndef ARCH
-#error ARCH should be defined by the build system
+#ifndef YQ2ARCH
+#error YQ2ARCH should be defined by the build system
+#endif
+
+#ifndef BUILD_DATE
+#define BUILD_DATE __DATE__
 #endif
 
 #ifdef _WIN32
@@ -760,6 +764,7 @@ void Sys_Error(char *error, ...);
 void Sys_Quit(void);
 char *Sys_GetHomeDir(void);
 const char *Sys_GetBinaryDir(void);
+void Sys_Sleep(int msec);
 
 void Sys_FreeLibrary(void *handle);
 void *Sys_LoadLibrary(const char *path, const char *sym, void **handle);
diff --git a/src/common/misc.c b/src/common/misc.c
index 98a90e5..b474c72 100644
--- a/src/common/misc.c
+++ b/src/common/misc.c
@@ -241,7 +241,7 @@ Qcommon_Init(int argc, char **argv)
 	dedicated = Cvar_Get("dedicated", "0", CVAR_NOSET);
 #endif
 
-	s = va("%s %s %s %s", YQ2VERSION, ARCH, __DATE__, OSTYPE);
+	s = va("%s %s %s %s", YQ2VERSION, YQ2ARCH, BUILD_DATE, YQ2OSTYPE);
 	Cvar_Get("version", s, CVAR_SERVERINFO | CVAR_NOSET);
 
 	if (dedicated->value)
diff --git a/src/game/g_ai.c b/src/game/g_ai.c
index f92c71d..41b01b0 100644
--- a/src/game/g_ai.c
+++ b/src/game/g_ai.c
@@ -1060,7 +1060,8 @@ ai_checkattack(edict_t *self)
 		VectorCopy(self->enemy->s.origin, self->monsterinfo.last_sighting);
 	}
 
-	if (coop && (self->monsterinfo.search_time < level.time))
+	/* look for other coop players here */
+	if (coop->value && (self->monsterinfo.search_time < level.time))
 	{
 		if (FindTarget(self))
 		{
diff --git a/src/game/g_misc.c b/src/game/g_misc.c
index 1523e5a..91f1185 100644
--- a/src/game/g_misc.c
+++ b/src/game/g_misc.c
@@ -399,7 +399,7 @@ ThrowDebris(edict_t *self, char *modelname, float speed, vec3_t origin)
 	v[2] = 100 + 100 * crandom();
 	VectorMA(self->velocity, speed, v, chunk->velocity);
 	chunk->movetype = MOVETYPE_BOUNCE;
-	chunk->solid = SOLID_BBOX;
+	chunk->solid = SOLID_NOT;
 	chunk->avelocity[0] = random() * 600;
 	chunk->avelocity[1] = random() * 600;
 	chunk->avelocity[2] = random() * 600;
diff --git a/src/game/g_monster.c b/src/game/g_monster.c
index 5661f4a..2bd42bc 100644
--- a/src/game/g_monster.c
+++ b/src/game/g_monster.c
@@ -257,11 +257,6 @@ M_CheckGround(edict_t *ent)
 		return;
 	}
 
-    /* This two lines were commented out
-	   by id. But why? */
-    ent->groundentity = trace.ent;
-	ent->groundentity_linkcount = trace.ent->linkcount;
-
 	if (!trace.startsolid && !trace.allsolid)
 	{
 		VectorCopy(trace.endpos, ent->s.origin);
diff --git a/src/game/g_spawn.c b/src/game/g_spawn.c
index 9011487..d4295b2 100644
--- a/src/game/g_spawn.c
+++ b/src/game/g_spawn.c
@@ -572,6 +572,7 @@ SpawnEntities(const char *mapname, char *entities, const char *spawnpoint)
 	const char *com_token;
 	int i;
 	float skill_level;
+	static qboolean monster_count_city3 = false;
 
 	if (!mapname || !entities || !spawnpoint)
 	{
@@ -649,6 +650,21 @@ SpawnEntities(const char *mapname, char *entities, const char *spawnpoint)
 			ent->spawnflags &= ~SPAWNFLAG_NOT_HARD;
 		}
 
+		/*
+		 * The 'monsters' count in city3.bsp is wrong.
+		 * There're two monsters triggered in a hidden
+		 * and unreachable room next to the security
+		 * pass.
+		 *
+		 * We need to make sure that this hack is only
+		 * applied once!
+		 */
+		if(!Q_stricmp(level.mapname, "city3") && !monster_count_city3)
+		{
+			level.total_monsters = level.total_monsters - 2;
+			monster_count_city3 = true;
+		}
+
 		/* remove things (except the world) from
 		   different skill levels or deathmatch */
 		if (ent != g_edicts)
diff --git a/src/game/monster/flyer/flyer.c b/src/game/monster/flyer/flyer.c
index d263732..4d64f4d 100644
--- a/src/game/monster/flyer/flyer.c
+++ b/src/game/monster/flyer/flyer.c
@@ -496,7 +496,7 @@ flyer_fire(edict_t *self, int flash_number)
 	vec3_t dir;
 	int effect;
 
-	if (!self)
+	if (!self || !self->enemy)
 	{
 		return;
 	}
diff --git a/src/game/monster/gunner/gunner.c b/src/game/monster/gunner/gunner.c
index 3c63e50..56317e7 100644
--- a/src/game/monster/gunner/gunner.c
+++ b/src/game/monster/gunner/gunner.c
@@ -388,7 +388,7 @@ gunner_pain(edict_t *self, edict_t *other /* unused */,
 
 	if (self->health < (self->max_health / 2))
 	{
-		self->s.skinnum |= 1;
+		self->s.skinnum = 1;
 	}
 
 	if (level.time < self->pain_debounce_time)
@@ -476,8 +476,7 @@ gunner_die(edict_t *self, edict_t *inflictor /* unused */,
 		return;
 	}
 
-	self->s.skinnum |= 1;
-	self->monsterinfo.power_armor_type = POWER_ARMOR_NONE;
+	self->s.skinnum = 1;
 
 	/* check for gib */
 	if (self->health <= self->gib_health)
diff --git a/src/game/savegame/savegame.c b/src/game/savegame/savegame.c
index 9dc0878..701382f 100644
--- a/src/game/savegame/savegame.c
+++ b/src/game/savegame/savegame.c
@@ -73,17 +73,21 @@
  */
 #define SAVEGAMEVER "YQ2-2"
 
+#ifndef BUILD_DATE
+#define BUILD_DATE __DATE__
+#endif
+
 /*
  * This macros are used to prohibit loading of savegames
  * created on other systems or architectures. This will
  * crash q2 in spectacular ways
  */
-#ifndef OSTYPE
-#error OSTYPE should be defined by the build system
+#ifndef YQ2OSTYPE
+#error YQ2OSTYPE should be defined by the build system
 #endif
 
-#ifndef ARCH
-#error ARCH should be defined by the build system
+#ifndef YQ2ARCH
+#error YQ2ARCH should be defined by the build system
 #endif
 
 /*
@@ -207,7 +211,7 @@ void
 InitGame(void)
 {
 	gi.dprintf("Game is starting up.\n");
-	gi.dprintf("Game is %s built on %s.\n", GAMEVERSION, __DATE__);
+	gi.dprintf("Game is %s built on %s.\n", GAMEVERSION, BUILD_DATE);
 
 	gun_x = gi.cvar("gun_x", "0", 0);
 	gun_y = gi.cvar("gun_y", "0", 0);
@@ -223,7 +227,7 @@ InitGame(void)
 	/* latched vars */
 	sv_cheats = gi.cvar("cheats", "0", CVAR_SERVERINFO | CVAR_LATCH);
 	gi.cvar("gamename", GAMEVERSION, CVAR_SERVERINFO | CVAR_LATCH);
-	gi.cvar("gamedate", __DATE__, CVAR_SERVERINFO | CVAR_LATCH);
+	gi.cvar("gamedate", BUILD_DATE, CVAR_SERVERINFO | CVAR_LATCH);
 	maxclients = gi.cvar("maxclients", "4", CVAR_SERVERINFO | CVAR_LATCH);
 	maxspectators = gi.cvar("maxspectators", "4", CVAR_SERVERINFO);
 	deathmatch = gi.cvar("deathmatch", "0", CVAR_LATCH);
@@ -783,8 +787,8 @@ WriteGame(const char *filename, qboolean autosave)
 
 	Q_strlcpy(str_ver, SAVEGAMEVER, sizeof(str_ver));
 	Q_strlcpy(str_game, GAMEVERSION, sizeof(str_game));
-	Q_strlcpy(str_os, OSTYPE, sizeof(str_os));
-	Q_strlcpy(str_arch, ARCH, sizeof(str_arch));
+	Q_strlcpy(str_os, YQ2OSTYPE, sizeof(str_os));
+	Q_strlcpy(str_arch, YQ2ARCH, sizeof(str_arch));
 
 	fwrite(str_ver, sizeof(str_ver), 1, f);
 	fwrite(str_game, sizeof(str_game), 1, f);
@@ -838,17 +842,17 @@ ReadGame(const char *filename)
 		if (strcmp(str_game, GAMEVERSION))
 		{
 			fclose(f);
-			gi.error("Savegame from an other game.so.\n");
+			gi.error("Savegame from another game.so.\n");
 		}
-		else if (strcmp(str_os, OSTYPE))
+		else if (strcmp(str_os, YQ2OSTYPE))
 		{
 			fclose(f);
-			gi.error("Savegame from an other os.\n");
+			gi.error("Savegame from another os.\n");
 		}
-		else if (strcmp(str_arch, ARCH))
+		else if (strcmp(str_arch, YQ2ARCH))
 		{
 			fclose(f);
-			gi.error("Savegame from an other architecure.\n");
+			gi.error("Savegame from another architecture.\n");
 		}
 	}
 	else if (!strcmp(str_ver, "YQ2-1"))
@@ -856,12 +860,12 @@ ReadGame(const char *filename)
 		if (strcmp(str_game, GAMEVERSION))
 		{
 			fclose(f);
-			gi.error("Savegame from an other game.so.\n");
+			gi.error("Savegame from another game.so.\n");
 		}
 		else if (strcmp(str_os, OSTYPE_1))
 		{
 			fclose(f);
-			gi.error("Savegame from an other os.\n");
+			gi.error("Savegame from another os.\n");
 		}
 
 		if (!strcmp(str_os, "Windows"))
@@ -870,7 +874,7 @@ ReadGame(const char *filename)
 			if (strcmp(str_arch, "i386"))
 			{
 				fclose(f);
-				gi.error("Savegame from an other architecure.\n");
+				gi.error("Savegame from another architecture.\n");
 			}
 		}
 		else
@@ -878,7 +882,7 @@ ReadGame(const char *filename)
 			if (strcmp(str_arch, ARCH_1))
 			{
 				fclose(f);
-				gi.error("Savegame from an other architecure.\n");
+				gi.error("Savegame from another architecture.\n");
 			}
 		}
 	}
diff --git a/stuff/README.old b/stuff/README.old
index bcc3661..89dabf4 100644
--- a/stuff/README.old
+++ b/stuff/README.old
@@ -484,7 +484,7 @@ the most common questions are answered.
 
 - Particle effects are broken. They're just squares and not perfectly
   round: This is a problem by your graphics driver, not implementing
-  a special filter mode for "points". Set "gl_ext_pointparameters" to 0
+  a special filter mode for "points". Set "gl_pointparameters" to 0
   to get better (but not perfect) particles.
 
 - The game is bright enough but it's also washed out and dull: You need

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/yquake2.git



More information about the Pkg-games-commits mailing list