--- /dev/null
+/*
+Copyright (C) 1996-1997 Id Software, Inc.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+// Quake is a trademark of Id Software, Inc., (c) 1996 Id Software, Inc. All
+// rights reserved.
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <sys/file.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <string.h>
+#include <time.h>
+#include <errno.h>
+
+#include <linux/cdrom.h>
+
+#include "quakedef.h"
+
+static qboolean cdValid = false;
+static qboolean playing = false;
+static qboolean wasPlaying = false;
+static qboolean initialized = false;
+static qboolean enabled = true;
+static qboolean playLooping = false;
+static float cdvolume;
+static byte remap[100];
+static byte playTrack;
+static byte maxTrack;
+
+static int cdfile = -1;
+static char cd_dev[64] = "/dev/cdrom";
+
+static void CDAudio_Eject(void)
+{
+ if (cdfile == -1 || !enabled)
+ return; // no cd init'd
+
+ if ( ioctl(cdfile, CDROMEJECT) == -1 )
+ Con_DPrintf("ioctl cdromeject failed\n");
+}
+
+
+static void CDAudio_CloseDoor(void)
+{
+ if (cdfile == -1 || !enabled)
+ return; // no cd init'd
+
+ if ( ioctl(cdfile, CDROMCLOSETRAY) == -1 )
+ Con_DPrintf("ioctl cdromclosetray failed\n");
+}
+
+static int CDAudio_GetAudioDiskInfo(void)
+{
+ struct cdrom_tochdr tochdr;
+
+ cdValid = false;
+
+ if ( ioctl(cdfile, CDROMREADTOCHDR, &tochdr) == -1 )
+ {
+ Con_DPrintf("ioctl cdromreadtochdr failed\n");
+ return -1;
+ }
+
+ if (tochdr.cdth_trk0 < 1)
+ {
+ Con_DPrintf("CDAudio: no music tracks\n");
+ return -1;
+ }
+
+ cdValid = true;
+ maxTrack = tochdr.cdth_trk1;
+
+ return 0;
+}
+
+
+void CDAudio_Play(byte track, qboolean looping)
+{
+ struct cdrom_tocentry entry;
+ struct cdrom_ti ti;
+
+ if (cdfile == -1 || !enabled)
+ return;
+
+ if (!cdValid)
+ {
+ CDAudio_GetAudioDiskInfo();
+ if (!cdValid)
+ return;
+ }
+
+ track = remap[track];
+
+ if (track < 1 || track > maxTrack)
+ {
+ Con_DPrintf("CDAudio: Bad track number %u.\n", track);
+ return;
+ }
+
+ // don't try to play a non-audio track
+ entry.cdte_track = track;
+ entry.cdte_format = CDROM_MSF;
+ if ( ioctl(cdfile, CDROMREADTOCENTRY, &entry) == -1 )
+ {
+ Con_DPrintf("ioctl cdromreadtocentry failed\n");
+ return;
+ }
+ if (entry.cdte_ctrl == CDROM_DATA_TRACK)
+ {
+ Con_Printf("CDAudio: track %i is not audio\n", track);
+ return;
+ }
+
+ if (playing)
+ {
+ if (playTrack == track)
+ return;
+ CDAudio_Stop();
+ }
+
+ ti.cdti_trk0 = track;
+ ti.cdti_trk1 = track;
+ ti.cdti_ind0 = 1;
+ ti.cdti_ind1 = 99;
+
+ if ( ioctl(cdfile, CDROMPLAYTRKIND, &ti) == -1 )
+ {
+ Con_DPrintf("ioctl cdromplaytrkind failed\n");
+ return;
+ }
+
+ if ( ioctl(cdfile, CDROMRESUME) == -1 )
+ Con_DPrintf("ioctl cdromresume failed\n");
+
+ playLooping = looping;
+ playTrack = track;
+ playing = true;
+
+ if (cdvolume == 0.0)
+ CDAudio_Pause ();
+}
+
+
+void CDAudio_Stop(void)
+{
+ if (cdfile == -1 || !enabled)
+ return;
+
+ if (!playing)
+ return;
+
+ if ( ioctl(cdfile, CDROMSTOP) == -1 )
+ Con_DPrintf("ioctl cdromstop failed (%d)\n", errno);
+
+ wasPlaying = false;
+ playing = false;
+}
+
+void CDAudio_Pause(void)
+{
+ if (cdfile == -1 || !enabled)
+ return;
+
+ if (!playing)
+ return;
+
+ if ( ioctl(cdfile, CDROMPAUSE) == -1 )
+ Con_DPrintf("ioctl cdrompause failed\n");
+
+ wasPlaying = playing;
+ playing = false;
+}
+
+
+void CDAudio_Resume(void)
+{
+ if (cdfile == -1 || !enabled)
+ return;
+
+ if (!cdValid)
+ return;
+
+ if (!wasPlaying)
+ return;
+
+ if ( ioctl(cdfile, CDROMRESUME) == -1 )
+ Con_DPrintf("ioctl cdromresume failed\n");
+ playing = true;
+}
+
+static void CD_f (void)
+{
+ char *command;
+ int ret;
+ int n;
+
+ if (Cmd_Argc() < 2)
+ return;
+
+ command = Cmd_Argv (1);
+
+ if (Q_strcasecmp(command, "on") == 0)
+ {
+ enabled = true;
+ return;
+ }
+
+ if (Q_strcasecmp(command, "off") == 0)
+ {
+ if (playing)
+ CDAudio_Stop();
+ enabled = false;
+ return;
+ }
+
+ if (Q_strcasecmp(command, "reset") == 0)
+ {
+ enabled = true;
+ if (playing)
+ CDAudio_Stop();
+ for (n = 0; n < 100; n++)
+ remap[n] = n;
+ CDAudio_GetAudioDiskInfo();
+ return;
+ }
+
+ if (Q_strcasecmp(command, "remap") == 0)
+ {
+ ret = Cmd_Argc() - 2;
+ if (ret <= 0)
+ {
+ for (n = 1; n < 100; n++)
+ if (remap[n] != n)
+ Con_Printf(" %u -> %u\n", n, remap[n]);
+ return;
+ }
+ for (n = 1; n <= ret; n++)
+ remap[n] = atoi(Cmd_Argv (n+1));
+ return;
+ }
+
+ if (Q_strcasecmp(command, "close") == 0)
+ {
+ CDAudio_CloseDoor();
+ return;
+ }
+
+ if (!cdValid)
+ {
+ CDAudio_GetAudioDiskInfo();
+ if (!cdValid)
+ {
+ Con_Printf("No CD in player.\n");
+ return;
+ }
+ }
+
+ if (Q_strcasecmp(command, "play") == 0)
+ {
+ CDAudio_Play((byte)atoi(Cmd_Argv (2)), false);
+ return;
+ }
+
+ if (Q_strcasecmp(command, "loop") == 0)
+ {
+ CDAudio_Play((byte)atoi(Cmd_Argv (2)), true);
+ return;
+ }
+
+ if (Q_strcasecmp(command, "stop") == 0)
+ {
+ CDAudio_Stop();
+ return;
+ }
+
+ if (Q_strcasecmp(command, "pause") == 0)
+ {
+ CDAudio_Pause();
+ return;
+ }
+
+ if (Q_strcasecmp(command, "resume") == 0)
+ {
+ CDAudio_Resume();
+ return;
+ }
+
+ if (Q_strcasecmp(command, "eject") == 0)
+ {
+ if (playing)
+ CDAudio_Stop();
+ CDAudio_Eject();
+ cdValid = false;
+ return;
+ }
+
+ if (Q_strcasecmp(command, "info") == 0)
+ {
+ Con_Printf("%u tracks\n", maxTrack);
+ if (playing)
+ Con_Printf("Currently %s track %u\n", playLooping ? "looping" : "playing", playTrack);
+ else if (wasPlaying)
+ Con_Printf("Paused %s track %u\n", playLooping ? "looping" : "playing", playTrack);
+ Con_Printf("Volume is %f\n", cdvolume);
+ return;
+ }
+}
+
+void CDAudio_Update(void)
+{
+ struct cdrom_subchnl subchnl;
+ static time_t lastchk;
+
+ if (!enabled)
+ return;
+
+ if (bgmvolume.value != cdvolume)
+ {
+ if (cdvolume)
+ {
+ Cvar_SetValue ("bgmvolume", 0.0);
+ cdvolume = bgmvolume.value;
+ CDAudio_Pause ();
+ }
+ else
+ {
+ Cvar_SetValue ("bgmvolume", 1.0);
+ cdvolume = bgmvolume.value;
+ CDAudio_Resume ();
+ }
+ }
+
+ if (playing && lastchk < time(NULL)) {
+ lastchk = time(NULL) + 2; //two seconds between chks
+ subchnl.cdsc_format = CDROM_MSF;
+ if (ioctl(cdfile, CDROMSUBCHNL, &subchnl) == -1 ) {
+ Con_DPrintf("ioctl cdromsubchnl failed\n");
+ playing = false;
+ return;
+ }
+ if (subchnl.cdsc_audiostatus != CDROM_AUDIO_PLAY &&
+ subchnl.cdsc_audiostatus != CDROM_AUDIO_PAUSED) {
+ playing = false;
+ if (playLooping)
+ CDAudio_Play(playTrack, true);
+ }
+ }
+}
+
+int CDAudio_Init(void)
+{
+ int i;
+
+ if (cls.state == ca_dedicated)
+ return -1;
+
+ if (COM_CheckParm("-nocdaudio"))
+ return -1;
+
+ if ((i = COM_CheckParm("-cddev")) != 0 && i < com_argc - 1) {
+ strncpy(cd_dev, com_argv[i + 1], sizeof(cd_dev));
+ cd_dev[sizeof(cd_dev) - 1] = 0;
+ }
+
+ if ((cdfile = open(cd_dev, O_RDONLY)) == -1) {
+ Con_Printf("CDAudio_Init: open of \"%s\" failed (%i)\n", cd_dev, errno);
+ cdfile = -1;
+ return -1;
+ }
+
+ for (i = 0; i < 100; i++)
+ remap[i] = i;
+ initialized = true;
+ enabled = true;
+
+ if (CDAudio_GetAudioDiskInfo())
+ {
+ Con_Printf("CDAudio_Init: No CD in player.\n");
+ cdValid = false;
+ }
+
+ Cmd_AddCommand ("cd", CD_f);
+
+ Con_Printf("CD Audio Initialized\n");
+
+ return 0;
+}
+
+
+void CDAudio_Shutdown(void)
+{
+ if (!initialized)
+ return;
+ CDAudio_Stop();
+ close(cdfile);
+ cdfile = -1;
+}
val = 0;
if (impulsedown && !impulseup)
+ {
if (down)
val = 0.5; // pressed and held this frame
else
val = 0; // I_Error ();
+ }
if (impulseup && !impulsedown)
+ {
if (down)
val = 0; // I_Error ();
else
val = 0; // released this frame
+ }
if (!impulsedown && !impulseup)
+ {
if (down)
val = 1.0; // held the entire frame
else
val = 0; // up the entire frame
+ }
if (impulsedown && impulseup)
+ {
if (down)
val = 0.75; // released and re-pressed this frame
else
val = 0.25; // pressed and released this frame
+ }
key->state &= 1; // clear impulses
}
host_client->pmodel = i;
- if (val = GETEDICTFIELDVALUE(host_client->edict, eval_pmodel))
+ if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_pmodel)))
val->_float = i;
}
cl.paused = MSG_ReadByte ();
if (cl.paused)
- {
CDAudio_Pause ();
-#ifdef _WIN32
- VID_HandlePause (true);
-#endif
- }
else
- {
CDAudio_Resume ();
-#ifdef _WIN32
- VID_HandlePause (false);
-#endif
- }
}
break;
R_SetSkyBox(MSG_ReadString());
break;
case svc_skyboxsize:
- /*r_skyboxsize.value = */MSG_ReadCoord();
+ i = MSG_ReadCoord();
+ // r_skyboxsize.value = MSG_ReadCoord();
break;
case svc_fog:
if (MSG_ReadByte())
pos[0] = MSG_ReadCoord ();
pos[1] = MSG_ReadCoord ();
pos[2] = MSG_ReadCoord ();
- R_ParticleExplosion (pos, false);
+// R_ParticleExplosion (pos, false);
dl = CL_AllocDlight (0);
VectorCopy (pos, dl->origin);
dl->radius = 350;
pos[0] = MSG_ReadCoord ();
pos[1] = MSG_ReadCoord ();
pos[2] = MSG_ReadCoord ();
- R_ParticleExplosion (pos, false);
+// R_ParticleExplosion (pos, false);
dl = CL_AllocDlight (0);
VectorCopy (pos, dl->origin);
dl->radius = 600;
pos[0] = MSG_ReadCoord ();
pos[1] = MSG_ReadCoord ();
pos[2] = MSG_ReadCoord ();
- R_ParticleExplosion (pos, false);
+// R_ParticleExplosion (pos, false);
dl = CL_AllocDlight (0);
VectorCopy (pos, dl->origin);
dl->radius = 350;
pos[0] = MSG_ReadCoord ();
pos[1] = MSG_ReadCoord ();
pos[2] = MSG_ReadCoord ();
- R_ParticleExplosion (pos, false);
+// R_ParticleExplosion (pos, false);
dl = CL_AllocDlight (0);
VectorCopy (pos, dl->origin);
dl->radius = 350;
pos[0] = MSG_ReadCoord ();
pos[1] = MSG_ReadCoord ();
pos[2] = MSG_ReadCoord ();
- R_BlobExplosion (pos);
+// R_BlobExplosion (pos);
+ S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1);
+ dl = CL_AllocDlight (0);
+ VectorCopy (pos, dl->origin);
+ dl->radius = 600;
+ dl->die = cl.time + 0.5;
+ dl->decay = 1200;
+ dl->color[0] = 0.8;dl->color[1] = 0.4;dl->color[2] = 1.0;
S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1);
break;
pos[2] = MSG_ReadCoord ();
colorStart = MSG_ReadByte ();
colorLength = MSG_ReadByte ();
- R_ParticleExplosion2 (pos, colorStart, colorLength);
+// R_ParticleExplosion2 (pos, colorStart, colorLength);
dl = CL_AllocDlight (0);
VectorCopy (pos, dl->origin);
dl->radius = 350;
dl->die = cl.time + 0.5;
dl->decay = 700;
- tempcolor = (byte *)&d_8to24table[colorStart+(colorLength >> 1)];
+ tempcolor = (byte *)&d_8to24table[(rand()%colorLength) + colorStart];
dl->color[0] = tempcolor[0];dl->color[1] = tempcolor[1];dl->color[2] = tempcolor[2];
S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1);
break;
else
buf = loadbuf;
}
+ else if (usehunk == 5)
+ buf = malloc (len+1);
else
Sys_Error ("COM_LoadFile: bad usehunk");
return COM_LoadFile (path, 2, quiet);
}
+// LordHavoc: returns malloc'd memory
+byte *COM_LoadMallocFile (char *path, qboolean quiet)
+{
+ return COM_LoadFile (path, 5, quiet);
+}
+
void COM_LoadCacheFile (char *path, struct cache_user_s *cu, qboolean quiet)
{
loadcache = cu;
byte *COM_LoadStackFile (char *path, void *buffer, int bufsize, qboolean quiet);
byte *COM_LoadTempFile (char *path, qboolean quiet);
byte *COM_LoadHunkFile (char *path, qboolean quiet);
+byte *COM_LoadMallocFile (char *path, qboolean quiet);
void COM_LoadCacheFile (char *path, struct cache_user_s *cu, qboolean quiet);
byte *COM_LoadFile (char *path, int usehunk, qboolean quiet);
--- /dev/null
+
+#include "quakedef.h"
+
+/*
+===============
+Mod_PointInLeaf
+===============
+*/
+mleaf_t *Mod_PointInLeaf (vec3_t p, model_t *model)
+{
+ mnode_t *node;
+
+// if (!model || !model->nodes)
+// Sys_Error ("Mod_PointInLeaf: bad model");
+
+ node = model->nodes;
+ if (node->contents < 0)
+ return (mleaf_t *)node;
+ while (1)
+ {
+ node = node->children[(node->plane->type < 3 ? p[node->plane->type] : DotProduct (p,node->plane->normal)) < node->plane->dist];
+ if (node->contents < 0)
+ return (mleaf_t *)node;
+ }
+
+ return NULL; // never reached
+}
+/*
+mleaf_t *Mod_PointInLeaf (vec3_t p, model_t *model)
+{
+ mnode_t *node;
+ float d;
+ mplane_t *plane;
+
+ if (!model || !model->nodes)
+ Sys_Error ("Mod_PointInLeaf: bad model");
+
+ node = model->nodes;
+ while (1)
+ {
+ if (node->contents < 0)
+ return (mleaf_t *)node;
+ plane = node->plane;
+ d = DotProduct (p,plane->normal) - plane->dist;
+ if (d > 0)
+ node = node->children[0];
+ else
+ node = node->children[1];
+ }
+
+ return NULL; // never reached
+}
+*/
+
+/*
+==================
+SV_HullPointContents
+
+==================
+*/
+int SV_HullPointContents (hull_t *hull, int num, vec3_t p)
+{
+ while (num >= 0)
+ num = hull->clipnodes[num].children[(hull->planes[hull->clipnodes[num].planenum].type < 3 ? p[hull->planes[hull->clipnodes[num].planenum].type] : DotProduct (hull->planes[hull->clipnodes[num].planenum].normal, p)) < hull->planes[hull->clipnodes[num].planenum].dist];
+
+ return num;
+}
--- /dev/null
+nasmw -fwin32 cpu_x86.nasm
--- /dev/null
+ BITS 32
+ GLOBAL _Mod_PointInLeaf
+ GLOBAL _SV_HullPointContents
+ SECTION .text
+_Mod_PointInLeaf
+
+;{
+
+ mov eax, dword [esp+12-4] ; model
+ sub esp, 4
+ push ebx
+ push esi
+
+; mnode_t *node;
+; node = model->nodes;
+
+ mov esi, dword [eax+200]
+
+; if (node->contents < 0)
+
+ cmp dword [esi], 0
+ jge .firstvalid
+
+; return (mleaf_t *)node;
+
+ mov eax, esi
+ pop esi
+ pop ebx
+ add esp, 4
+ ret 0
+.firstvalid
+ mov edx, dword [esp+8+8] ; p
+.loop
+
+; while (1)
+
+ mov eax, dword [esi+36]
+ mov cl, byte [eax+16]
+
+; {
+; node = node->children[(node->plane->type < 3 ? p[node->plane->type] : DotProduct (p,node->plane->normal)) < node->plane->dist];
+
+ cmp cl, 3
+ jb .axisplane
+ fld dword [eax+4]
+ fmul dword [edx+4]
+ fld dword [eax+8]
+ fmul dword [edx+8]
+ fld dword [eax]
+ fmul dword [edx]
+ faddp st1, st0
+ faddp st1, st0
+ fld dword [eax+12]
+ fcompp
+ xor ecx, ecx
+ fnstsw ax
+ test ah, 65 ; 00000041H
+ sete cl
+ mov esi, dword [esi+ecx*4+40]
+
+; if (node->contents < 0)
+
+ cmp dword [esi], 0
+ jge .loop
+
+; return (mleaf_t *)node;
+
+ mov eax, esi
+
+; }
+; return NULL; // never reached
+;}
+
+ pop esi
+ pop ebx
+ add esp, 4
+ ret 0
+.axisplane:
+ xor ebx, ebx
+ mov bl, cl
+ fld dword [edx+ebx*4]
+ fld dword [eax+12]
+ fcompp
+ xor ecx, ecx
+ fnstsw ax
+ test ah, 65 ; 00000041H
+ sete cl
+ mov esi, dword [esi+ecx*4+40]
+
+; if (node->contents < 0)
+
+ cmp dword [esi], 0
+ jge .loop
+
+; return (mleaf_t *)node;
+
+ mov eax, esi
+
+; }
+; return NULL; // never reached
+;}
+
+ pop esi
+ pop ebx
+ add esp, 4
+ ret 0
+
+
+_SV_HullPointContents
+
+;{
+ mov ecx, [esp+12-4] ; num
+ sub esp, 4
+ test ecx, ecx
+ nop ; padding
+ push ebx
+ push esi
+ push edi
+ push ebp
+
+; while (num >= 0)
+
+ jge .firstvalid
+; return num;
+ mov eax, ecx
+ pop ebp
+;}
+ pop edi
+ pop esi
+ pop ebx
+ add esp, 4
+ ret 0
+.firstvalid
+ mov eax, [esp+8+16] ; hull
+ mov edx, [esp+16+16] ; p
+ mov esi, [eax]
+ mov edi, [eax+4]
+.loop
+ mov eax, [esi+ecx*8]
+ lea ebx, [eax+eax*2]
+ xor eax, eax
+ mov al, [edi+ebx*8+16]
+ lea ebp, [edi+ebx*8]
+
+; num = hull->clipnodes[num].children[(hull->planes[hull->clipnodes[num].planenum].type < 3 ? p[hull->planes[hull->clipnodes[num].planenum].type] : DotProduct (hull->planes[hull->clipnodes[num].planenum].normal, p)) < hull->planes[hull->clipnodes[num].planenum].dist];
+
+ cmp al, 3
+ jb .axisplane
+ fld dword [edx+8]
+ fmul dword [ebp+8]
+ fld dword [edx+4]
+ fmul dword [ebp+4]
+ fld dword [edx]
+ fmul dword [ebp]
+ faddp st1, st0
+ faddp st1, st0
+ fstp dword [esp-4+20]
+
+ fld dword [ebp+12]
+ fcomp dword [esp-4+20]
+ xor ebx, ebx
+ fnstsw ax
+ test ah, 65 ; 00000041H
+ sete bl
+ lea eax, [ebx+ecx*4]
+ movsx ecx, word [esi+eax*2+4]
+ test ecx, ecx
+ jge .loop
+; return num;
+ mov eax, ecx
+ pop ebp
+;}
+ pop edi
+ pop esi
+ pop ebx
+ add esp, 4
+ ret 0
+
+.axisplane
+ mov eax, [edx+eax*4]
+ mov [esp-4+20], eax
+
+ fld dword [ebp+12]
+ fcomp dword [esp-4+20]
+ xor ebx, ebx
+ fnstsw ax
+ test ah, 65 ; 00000041H
+ sete bl
+ lea eax, [ebx+ecx*4]
+ movsx ecx, word [esi+eax*2+4]
+ test ecx, ecx
+ jge .loop
+; return num;
+ mov eax, ecx
+ pop ebp
+;}
+ pop edi
+ pop esi
+ pop ebx
+ add esp, 4
+ ret 0
}
Sys_Error ("Scrap_AllocBlock: full");
+ return 0;
}
int scrap_uploads;
start = Hunk_LowMark();
- cb = (qpic_t *)COM_LoadTempFile ("gfx/conback.lmp", false);
+ cb = (qpic_t *)COM_LoadMallocFile ("gfx/conback.lmp", false);
if (!cb)
Sys_Error ("Couldn't load gfx/conback.lmp");
SwapPic (cb);
// hack the version number directly into the pic
#ifdef NEHAHRA
#if defined(__linux__)
- sprintf (ver, "(DPNehahra %.2f, Linux %2.2f, gl %.2f) %.2f", (float) DP_VERSION, (float)LINUX_VERSION, (float)GLQUAKE_VERSION, (float)VERSION);
+ sprintf (ver, "DPNehahra Linux GL %.2f", (float) VERSION);
#else
- sprintf (ver, "(DPNehahra %.2f, gl %.2f) %.2f", (float) DP_VERSION, (float)GLQUAKE_VERSION, (float)VERSION);
+ sprintf (ver, "DPNehahra Windows GL %.2f", (float) VERSION);
#endif
#else
#if defined(__linux__)
- sprintf (ver, "(DarkPlaces %.2f, Linux %2.2f, gl %.2f) %.2f", (float) DP_VERSION, (float)LINUX_VERSION, (float)GLQUAKE_VERSION, (float)VERSION);
+ sprintf (ver, "DarkPlaces Linux GL %.2f", (float)VERSION);
#else
- sprintf (ver, "(DarkPlaces %.2f, gl %.2f) %.2f", (float) DP_VERSION, (float)GLQUAKE_VERSION, (float)VERSION);
+ sprintf (ver, "DarkPlaces Windows GL %.2f", (float)VERSION);
#endif
#endif
dest = cb->data + 320*186 + 320 - 11 - 8*strlen(ver);
conback->height = vid.height;
// free loaded console
- Hunk_FreeToLowMark(start);
+ free(cb);
// save a texture slot for translated picture
translate_texture = texture_extension_number++;
return -1;
}
-extern byte gamma[];
+extern byte qgamma[];
// LordHavoc: gamma correction and improved resampling
void GL_ResampleTextureLerpLine (byte *in, byte *out, int inwidth, int outwidth)
{
l2 = f - xi;
l1 = 1 - l2;
- *out++ = gamma[(byte) (in[0] * l1 + in[4] * l2)];
- *out++ = gamma[(byte) (in[1] * l1 + in[5] * l2)];
- *out++ = gamma[(byte) (in[2] * l1 + in[6] * l2)];
- *out++ = (byte) (in[3] * l1 + in[7] * l2) ;
+ *out++ = qgamma[(byte) (in[0] * l1 + in[4] * l2)];
+ *out++ = qgamma[(byte) (in[1] * l1 + in[5] * l2)];
+ *out++ = qgamma[(byte) (in[2] * l1 + in[6] * l2)];
+ *out++ = (byte) (in[3] * l1 + in[7] * l2) ;
}
else // last pixel of the line has no pixel to lerp to
{
- *out++ = gamma[in[0]];
- *out++ = gamma[in[1]];
- *out++ = gamma[in[2]];
- *out++ = in[3] ;
+ *out++ = qgamma[in[0]];
+ *out++ = qgamma[in[1]];
+ *out++ = qgamma[in[2]];
+ *out++ = in[3] ;
}
}
}
frac = fracstep >> 1;
for (j=0 ; j<outwidth ; j+=4)
{
- inpix = inrow + ((frac >> 14) & ~3);*out++ = gamma[*inpix++];*out++ = gamma[*inpix++];*out++ = gamma[*inpix++];*out++ = *inpix++ ;frac += fracstep;
- inpix = inrow + ((frac >> 14) & ~3);*out++ = gamma[*inpix++];*out++ = gamma[*inpix++];*out++ = gamma[*inpix++];*out++ = *inpix++ ;frac += fracstep;
- inpix = inrow + ((frac >> 14) & ~3);*out++ = gamma[*inpix++];*out++ = gamma[*inpix++];*out++ = gamma[*inpix++];*out++ = *inpix++ ;frac += fracstep;
- inpix = inrow + ((frac >> 14) & ~3);*out++ = gamma[*inpix++];*out++ = gamma[*inpix++];*out++ = gamma[*inpix++];*out++ = *inpix++ ;frac += fracstep;
+ inpix = inrow + ((frac >> 14) & ~3);*out++ = qgamma[*inpix++];*out++ = qgamma[*inpix++];*out++ = qgamma[*inpix++];*out++ = *inpix++ ;frac += fracstep;
+ inpix = inrow + ((frac >> 14) & ~3);*out++ = qgamma[*inpix++];*out++ = qgamma[*inpix++];*out++ = qgamma[*inpix++];*out++ = *inpix++ ;frac += fracstep;
+ inpix = inrow + ((frac >> 14) & ~3);*out++ = qgamma[*inpix++];*out++ = qgamma[*inpix++];*out++ = qgamma[*inpix++];*out++ = *inpix++ ;frac += fracstep;
+ inpix = inrow + ((frac >> 14) & ~3);*out++ = qgamma[*inpix++];*out++ = qgamma[*inpix++];*out++ = qgamma[*inpix++];*out++ = *inpix++ ;frac += fracstep;
}
}
}
out = (byte *)scaled;
for (i = 0;i < width*height;i++)
{
- *out++ = gamma[*in++];
- *out++ = gamma[*in++];
- *out++ = gamma[*in++];
+ *out++ = qgamma[*in++];
+ *out++ = qgamma[*in++];
+ *out++ = qgamma[*in++];
*out++ = *in++;
}
}
void GL_Upload8_EXT (byte *data, int width, int height, qboolean mipmap)
{
int scaled_width, scaled_height;
- byte *scaled;
+ byte *scaled = NULL;
for (scaled_width = 1 ; scaled_width < width ; scaled_width<<=1)
;
else
{
scaled = malloc(scaled_width*scaled_height*4);
- GL_Resample8BitTexture (data, width, height, (void*) &scaled, scaled_width, scaled_height);
+ GL_Resample8BitTexture (data, width, height, (void*) scaled, scaled_width, scaled_height);
}
glTexImage2D (GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, scaled_width, scaled_height, 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, scaled);
int i;
model_t *clmodel;
vec3_t mins, maxs;
- aliashdr_t *paliashdr;
- md2mem_t *pheader;
+ aliashdr_t *paliashdr = NULL;
+ md2mem_t *pheader = NULL;
int anim;
if (modelalpha < (1.0 / 64.0))
*/
void R_Init (void)
{
- extern byte *hunk_base;
// extern cvar_t gl_finish;
Cmd_AddCommand ("timerefresh", R_TimeRefresh_f);
int inwidth, inheight;
byte *inrow;
unsigned frac, fracstep;
- extern byte **player_8bit_texels_tbl;
top = cl.scores[playernum].colors & 0xf0;
bottom = (cl.scores[playernum].colors &15)<<4;
Cvar_RegisterVariable(&gl_nosubimagefragments);
Cvar_RegisterVariable(&gl_nosubimage);
// check if it's the glquake minigl driver
- if (strnicmp(gl_vendor,"3Dfx",4)==0)
+ if (strncasecmp(gl_vendor,"3Dfx",4)==0)
if (!gl_arrays)
{
Cvar_SetValue("gl_nosubimagefragments", 1);
// subdivided water surface warp
if (s->flags & SURF_DRAWTURB)
{
- int light, alpha, r, g, b;
+ int light, alpha, r = 0, g = 0, b = 0;
vec3_t nv, shadecolor;
alpha = s->flags & SURF_DRAWNOALPHA ? 255 : r_wateralpha.value*255.0f;
light = false;
if (s->flags & SURF_DRAWTURB)
{
glpoly_t *p;
- int light, alpha, r, g, b;
+ int light, alpha, r = 0, g = 0, b = 0;
vec3_t shadecolor;
if (s->flags & SURF_DRAWNOALPHA)
{
for (;c;c--, surf++)
{
- if (surf->visframe == r_framecount && !(surf->flags & SURF_PLANEBACK))
+ if (surf->visframe == r_framecount && (!(surf->flags & SURF_PLANEBACK)))
{
surf->texturechain = surf->texinfo->texture->texturechain;
surf->texinfo->texture->texturechain = surf;
mleaf_t *pleaf;
pleaf = (mleaf_t *)node;
- if (c = pleaf->nummarksurfaces)
+ if ((c = pleaf->nummarksurfaces))
{
msurface_t **mark;
mark = pleaf->firstmarksurface;
// backside
side = dot >= 0;
// draw stuff
- if (c = node->numsurfaces)
+ if ((c = node->numsurfaces))
{
msurface_t *surf;
surf = cl.worldmodel->surfaces + node->firstsurface;
}
Sys_Error ("AllocBlock: full");
+ return 0;
}
int c_nodes;
void SCR_UpdateScreen (void)
{
- static float oldscr_viewsize;
- double time1, time2;
+ double time1 = 0, time2;
if (r_speeds.value)
{
unsigned transpix;
int r, g, b;
unsigned *rgba;
- extern int skytexturenum;
// src = (byte *)mt + mt->offsets[0];
*/
// disable data conversion warnings
-#pragma warning(disable : 4244) // MIPS
-#pragma warning(disable : 4136) // X86
-#pragma warning(disable : 4051) // ALPHA
+#ifdef _MSC_VER
+//#pragma warning(disable : 4244) // MIPS
+//#pragma warning(disable : 4136) // X86
+//#pragma warning(disable : 4051) // ALPHA
+#pragma warning(disable : 4244) // LordHavoc: MSVC++ 4 x86, double/float
#pragma warning(disable : 4305) // LordHavoc: MSVC++ 6 x86, double/float
-#pragma warning(disable : 4018) // LordHavoc: MSVC++ 4, signed/unsigned mismatch
+#pragma warning(disable : 4018) // LordHavoc: MSVC++ 4 x86, signed/unsigned mismatch
+#endif
#ifdef _WIN32
#include <windows.h>
+#define strcasecmp stricmp
+#define strncasecmp strnicmp
#endif
#include <GL/gl.h>
-#include <GL/glu.h>
+//#include <GL/glu.h>
void GL_BeginRendering (int *x, int *y, int *width, int *height);
void GL_EndRendering (void);
-
-#ifdef _WIN32
-// Function prototypes for the Texture Object Extension routines
-typedef GLboolean (APIENTRY *ARETEXRESFUNCPTR)(GLsizei, const GLuint *,
- const GLboolean *);
-typedef void (APIENTRY *BINDTEXFUNCPTR)(GLenum, GLuint);
-typedef void (APIENTRY *DELTEXFUNCPTR)(GLsizei, const GLuint *);
-typedef void (APIENTRY *GENTEXFUNCPTR)(GLsizei, GLuint *);
-typedef GLboolean (APIENTRY *ISTEXFUNCPTR)(GLuint);
-typedef void (APIENTRY *PRIORTEXFUNCPTR)(GLsizei, const GLuint *,
- const GLclampf *);
-typedef void (APIENTRY *TEXSUBIMAGEPTR)(int, int, int, int, int, int, int, int, void *);
-
-extern BINDTEXFUNCPTR bindTexFunc;
-extern DELTEXFUNCPTR delTexFunc;
-extern TEXSUBIMAGEPTR TexSubImage2DFunc;
-#endif
-
extern int texture_extension_number;
extern float gldepthmin, gldepthmax;
extern int glx, gly, glwidth, glheight;
-#ifdef _WIN32
-extern PROC glArrayElementEXT;
-extern PROC glColorPointerEXT;
-extern PROC glTexturePointerEXT;
-extern PROC glVertexPointerEXT;
-#endif
-
// r_local.h -- private refresh defs
#define ALIAS_BASE_SIZE_RATIO (1.0 / 11.0)
extern void (APIENTRY *qglDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
//extern void (APIENTRY *qglInterleavedArrays)(GLenum format, GLsizei stride, const GLvoid *pointer);
+extern void (APIENTRY *qglMTexCoord2f) (GLenum, GLfloat, GLfloat);
+extern void (APIENTRY *qglSelectTexture) (GLenum);
+extern void (APIENTRY *glColorTableEXT)(int, int, int, int, int, const void*);
+
#else
//#define qglPolygonOffset glPolygonOffset
#define qglDrawElements glDrawElements
//#define qglInterleavedArrays glInterleavedArrays
-#endif
+extern void (*qglMTexCoord2f) (GLenum, GLfloat, GLfloat);
+extern void (*qglSelectTexture) (GLenum);
+extern void (*glColorTableEXT)(int, int, int, int, int, const void*);
-extern void (APIENTRY *qglMTexCoord2f) (GLenum, GLfloat, GLfloat);
-extern void (APIENTRY *qglSelectTexture) (GLenum);
-extern void (APIENTRY *glColorTableEXT)(int, int, int, int, int, const void*);
+#endif
// LordHavoc: vertex transform
#include "transform.h"
Draw_Init ();
SCR_Init ();
R_Init ();
-#ifndef _WIN32
- // on Win32, sound initialization has to come before video initialization, so we
- // can put up a popup if the sound hardware is in use
S_Init ();
-#else
-
- // FIXME: doesn't use the new one-window approach yet
- S_Init ();
-
-#endif // _WIN32
CDAudio_Init ();
Sbar_Init ();
CL_Init ();
host_initialized = true;
- Sys_Printf ("========Quake Initialized=========\n");
+// Sys_Printf ("========Quake Initialized=========\n");
+// printf("========Quake Initialized=========\n");
}
return;
}
- if (pr_global_struct->deathmatch && !host_client->privileged)
+ if (pr_global_struct->deathmatch)
return;
sv_player->v.flags = (int)sv_player->v.flags ^ FL_GODMODE;
return;
}
- if (pr_global_struct->deathmatch && !host_client->privileged)
+ if (pr_global_struct->deathmatch)
return;
sv_player->v.flags = (int)sv_player->v.flags ^ FL_NOTARGET;
return;
}
- if (pr_global_struct->deathmatch && !host_client->privileged)
+ if (pr_global_struct->deathmatch)
return;
if (sv_player->v.movetype != MOVETYPE_NOCLIP)
return;
}
- if (pr_global_struct->deathmatch && !host_client->privileged)
+ if (pr_global_struct->deathmatch)
return;
if (sv_player->v.movetype != MOVETYPE_FLY)
Con_Printf ("Exe: "__TIME__" "__DATE__"\n");
}
-#ifdef IDGODS
-void Host_Please_f (void)
-{
- client_t *cl;
- int j;
-
- if (cmd_source != src_command)
- return;
-
- if ((Cmd_Argc () == 3) && strcmp(Cmd_Argv(1), "#") == 0)
- {
- j = atof(Cmd_Argv(2)) - 1;
- if (j < 0 || j >= svs.maxclients)
- return;
- if (!svs.clients[j].active)
- return;
- cl = &svs.clients[j];
- if (cl->privileged)
- {
- cl->privileged = false;
- cl->edict->v.flags = (int)cl->edict->v.flags & ~(FL_GODMODE|FL_NOTARGET);
- cl->edict->v.movetype = MOVETYPE_WALK;
- noclip_anglehack = false;
- }
- else
- cl->privileged = true;
- }
-
- if (Cmd_Argc () != 2)
- return;
-
- for (j=0, cl = svs.clients ; j<svs.maxclients ; j++, cl++)
- {
- if (!cl->active)
- continue;
- if (strcasecmp(cl->name, Cmd_Argv(1)) == 0)
- {
- if (cl->privileged)
- {
- cl->privileged = false;
- cl->edict->v.flags = (int)cl->edict->v.flags & ~(FL_GODMODE|FL_NOTARGET);
- cl->edict->v.movetype = MOVETYPE_WALK;
- noclip_anglehack = false;
- }
- else
- cl->privileged = true;
- break;
- }
- }
-}
-#endif
-
-
void Host_Say(qboolean teamonly)
{
client_t *client;
// if this is the last client to be connected, unpause
sv.paused = false;
- if (f = ED_FindFunction ("RestoreGame"))
- if (RestoreGame = (func_t)(f - pr_functions))
+ if ((f = ED_FindFunction ("RestoreGame")))
+ if ((RestoreGame = (func_t)(f - pr_functions)))
{
Con_DPrintf("Calling RestoreGame\n");
pr_global_struct->time = sv.time;
ent->v.colormap = NUM_FOR_EDICT(ent);
ent->v.team = (host_client->colors & 15) + 1;
ent->v.netname = host_client->name - pr_strings;
- if (val = GETEDICTFIELDVALUE(host_client->edict, eval_pmodel))
+ if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_pmodel)))
val->_float = host_client->pmodel;
// copy spawn parms out of the client_t
return;
}
}
- else if (pr_global_struct->deathmatch && !host_client->privileged)
+ else if (pr_global_struct->deathmatch)
return;
save = host_client;
return;
}
- if (pr_global_struct->deathmatch && !host_client->privileged)
+ if (pr_global_struct->deathmatch)
return;
t = Cmd_Argv(1);
case 's':
if (rogue)
{
- if (val = GETEDICTFIELDVALUE(sv_player, eval_ammo_shells1))
+ if ((val = GETEDICTFIELDVALUE(sv_player, eval_ammo_shells1)))
val->_float = v;
}
case 'n':
if (rogue)
{
- if (val = GETEDICTFIELDVALUE(sv_player, eval_ammo_nails1))
+ if ((val = GETEDICTFIELDVALUE(sv_player, eval_ammo_nails1)))
{
val->_float = v;
if (sv_player->v.weapon <= IT_LIGHTNING)
Cmd_AddCommand ("reconnect", Host_Reconnect_f);
Cmd_AddCommand ("name", Host_Name_f);
Cmd_AddCommand ("version", Host_Version_f);
-#ifdef IDGODS
- Cmd_AddCommand ("please", Host_Please_f);
-#endif
Cmd_AddCommand ("say", Host_Say_f);
Cmd_AddCommand ("say_team", Host_Say_Team_f);
Cmd_AddCommand ("tell", Host_Tell_f);
for(row=rows-1; row>=0; row--) {
pixbuf = image_rgba + row*columns*4;
for(column=0; column<columns; column++) {
- unsigned char red,green,blue,alphabyte;
+ unsigned char red = 0,green = 0,blue = 0,alphabyte = 0;
switch (targa_header.pixel_size) {
case 24:
}
}
else if (targa_header.image_type==10) { // Runlength encoded RGB images
- unsigned char red,green,blue,alphabyte,packetHeader,packetSize,j;
+ unsigned char red = 0,green = 0,blue = 0,alphabyte = 0,packetHeader,packetSize,j;
for(row=rows-1; row>=0; row--) {
pixbuf = image_rgba + row*columns*4;
for(column=0; column<columns; ) {
COM_FOpenFile (name, &f, true);
if (f)
return LoadPCX (f, matchwidth, matchheight);
- if (image_rgba = W_GetTexture(basename, matchwidth, matchheight))
+ if ((image_rgba = W_GetTexture(basename, matchwidth, matchheight)))
return image_rgba;
if (complain)
Con_Printf ("Couldn't load %s.tga or .pcx\n", filename);
--- /dev/null
+TARGET = darkplacesglx
+
+OBJECTS = cd_linux.o chase.o cl_demo.o cl_input.o cl_main.o cl_parse.o cl_tent.o cmd.o common.o console.o cpu_noasm.o crc.o cvar.o fractalnoise.o gl_draw.o gl_poly.o gl_refrag.o gl_rmain.o gl_rmisc.o gl_rsurf.o gl_screen.o gl_warp.o host.o host_cmd.o image.o keys.o mathlib.o menu.o model_alias.o model_brush.o model_shared.o model_sprite.o net_bsd.o net_udp.o net_dgrm.o net_loop.o net_main.o net_vcr.o pr_cmds.o pr_edict.o pr_exec.o r_light.o r_part.o sbar.o snd_dma.o snd_mem.o snd_mix.o snd_linux.o sv_main.o sv_move.o sv_phys.o sv_user.o sys_linux.o transform.o vid_shared.o vid_glx.o view.o wad.o world.o zone.o
+
+OPTIMIZATIONS = -O6 -ffast-math -funroll-loops -fomit-frame-pointer -fexpensive-optimizations
+CFLAGS = -Wall -Werror -I/usr/X11/include $(OPTIMIZATIONS)
+#CFLAGS = -Wall -Werror -I/usr/X11/include -ggdb $(OPTIMIZATIONS)
+LIBS = -L/usr/X11/lib -lc -lm -lXext -lXxf86dga -lXxf86vm -lGL
+
+#quick:
+# gcc -o $(TARGET) $(CFLAGS) cd_linux.c chase.c cl_demo.c cl_input.c cl_main.c cl_parse.c cl_tent.c cmd.c common.c console.c cpu_noasm.c crc.c cvar.c fractalnoise.c gl_draw.c gl_poly.c gl_refrag.c gl_rmain.c gl_rmisc.c gl_rsurf.c gl_screen.c gl_warp.c host.c host_cmd.c image.c keys.c mathlib.c menu.c model_alias.c model_brush.c model_shared.c model_sprite.c net_bsd.c net_udp.c net_dgrm.c net_loop.c net_main.c net_vcr.c pr_cmds.c pr_edict.c pr_exec.c r_light.c r_part.c sbar.c snd_dma.c snd_mem.c snd_mix.c snd_linux.c sv_main.c sv_move.c sv_phys.c sv_user.c sys_linux.c transform.c vid_shared.c vid_glx.c view.c wad.c world.c zone.c $(LIBS)
+.c.o:
+ gcc $(CFLAGS) -c $*.c
+
+$(TARGET) : $(OBJECTS)
+ gcc $(LIBS) -o $(TARGET) $(OBJECTS) $(LIBS)
+
#define VectorAdd(a,b,c) {c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];}
#define VectorCopy(a,b) {b[0]=a[0];b[1]=a[1];b[2]=a[2];}
#define CrossProduct(v1,v2,cross) {cross[0] = v1[1]*v2[2] - v1[2]*v2[1];cross[1] = v1[2]*v2[0] - v1[0]*v2[2];cross[2] = v1[0]*v2[1] - v1[1]*v2[0];}
-#define VectorNormalize(v) {float ilength;if (ilength = sqrt (v[0]*v[0] + v[1]*v[1] + v[2]*v[2])) {ilength = 1/ilength;v[0] *= ilength;v[1] *= ilength;v[2] *= ilength;}}
-#define VectorNormalize2(v,dest) {float ilength;if (ilength = sqrt (v[0]*v[0] + v[1]*v[1] + v[2]*v[2])) {ilength = 1/ilength;dest[0] = v[0] * ilength;dest[1] = v[1] * ilength;dest[2] = v[2] * ilength;}}
+#define VectorNormalize(v) {float ilength;if ((ilength = sqrt (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]))) {ilength = 1/ilength;v[0] *= ilength;v[1] *= ilength;v[2] *= ilength;}}
+#define VectorNormalize2(v,dest) {float ilength;if ((ilength = sqrt (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]))) {ilength = 1/ilength;dest[0] = v[0] * ilength;dest[1] = v[1] * ilength;dest[2] = v[2] * ilength;}}
void VectorMA (vec3_t veca, float scale, vec3_t vecb, vec3_t vecc);
#define PlaneDiff(point,plane) ((plane)->type < 3 ? (point)[(plane)->type] - (plane)->dist : DotProduct((point), (plane)->normal) - (plane)->dist)
#define lhrandom(MIN,MAX) ((rand() & 32767) * (((MAX)-(MIN)) * (1.0f / 32767.0f)) + (MIN))
+
+#ifndef min
+#define min(A,B) (A < B ? A : B)
+#define max(A,B) (A > B ? A : B)
+#endif
}
if (DirectConfig && (serialConfig_cursor == 3 || serialConfig_cursor == 4))
+ {
if (key == K_UPARROW)
serialConfig_cursor = 2;
else
serialConfig_cursor = 5;
+ }
if (SerialConfig && StartingGame && serialConfig_cursor == 4)
+ {
if (key == K_UPARROW)
serialConfig_cursor = 3;
else
serialConfig_cursor = 5;
+ }
}
//=============================================================================
}
if (StartingGame && lanConfig_cursor == 2)
+ {
if (key == K_UPARROW)
lanConfig_cursor = 1;
else
lanConfig_cursor = 0;
+ }
l = atoi(lanConfig_portname);
if (l > 65535)
if (scr_con_current)
{
Draw_ConsoleBackground (vid.height);
- VID_UnlockBuffer ();
S_ExtraUpdate ();
- VID_LockBuffer ();
}
// else
// Draw_FadeScreen ();
m_entersound = false;
}
- VID_UnlockBuffer ();
S_ExtraUpdate ();
- VID_LockBuffer ();
}
=================
*/
-/*
typedef struct
{
short x, y;
skin[x + skinwidth * y] = fdc;
}
}
-*/
/*
===============
{
if (pskintype->type == ALIAS_SKIN_SINGLE)
{
-// if (bytesperpixel == 1)
-// Mod_FloodFillSkin( skin, pheader->skinwidth, pheader->skinheight );
+ if (bytesperpixel == 1)
+ Mod_FloodFillSkin( skin, pheader->skinwidth, pheader->skinheight );
// save 8 bit texels for the player model to remap
// if (!strcmp(loadmodel->name,"progs/player.mdl")) {
for (j = 0;j < groupskins;j++)
{
-// if (bytesperpixel == 1)
-// Mod_FloodFillSkin( skin, pheader->skinwidth, pheader->skinheight );
+ if (bytesperpixel == 1)
+ Mod_FloodFillSkin( skin, pheader->skinwidth, pheader->skinheight );
if (j == 0)
{
texels = Hunk_AllocName(s, loadname);
float scale[3]; // multiply byte verts by this
float translate[3]; // then add this
char name[16]; // frame name from grabbing
- trivertx_t verts[]; // variable sized
+ trivertx_t verts[0]; // variable sized
} md2frame_t;
// LordHavoc: memory representation is different than disk
{
float scale[3]; // multiply byte verts by this
float translate[3]; // then add this
- trivert2 verts[]; // variable sized
+ trivert2 verts[0]; // variable sized
} md2memframe_t;
memset (mod_novis, 0xff, sizeof(mod_novis));
}
-/*
-===============
-Mod_PointInLeaf
-===============
-*/
-mleaf_t *Mod_PointInLeaf (vec3_t p, model_t *model)
-{
- mnode_t *node;
- float d;
- mplane_t *plane;
-
- if (!model || !model->nodes)
- Sys_Error ("Mod_PointInLeaf: bad model");
-
- node = model->nodes;
- while (1)
- {
- if (node->contents < 0)
- return (mleaf_t *)node;
- plane = node->plane;
- d = DotProduct (p,plane->normal) - plane->dist;
- if (d > 0)
- node = node->children[0];
- else
- node = node->children[1];
- }
-
- return NULL; // never reached
-}
-
+// Mod_PointInLeaf moved to cpu_noasm.c
/*
===================
out->planenum = LittleLong(in->planenum);
out->children[0] = LittleShort(in->children[0]);
out->children[1] = LittleShort(in->children[1]);
+ if (out->children[0] >= count || out->children[1] >= count)
+ Host_Error("Corrupt clipping hull (out of range child)\n");
}
}
header = (dheader_t *)buffer;
i = LittleLong (header->version);
- if (i != BSPVERSION & i != 30)
+ if (i != BSPVERSION && i != 30)
Host_Error ("Mod_LoadBrushModel: %s has wrong version number (%i should be %i or 30 (HalfLife))", mod->name, i, BSPVERSION);
hlbsp = i == 30;
halflifebsp.value = hlbsp;
#endif
#endif
-#ifdef IDGODS
-qboolean IsID(struct qsockaddr *addr);
-#endif
-
//============================================================================
//
// public network functions
--- /dev/null
+/*
+Copyright (C) 1996-1997 Id Software, Inc.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+#include "quakedef.h"
+
+#include "net_loop.h"
+#include "net_dgrm.h"
+
+net_driver_t net_drivers[MAX_NET_DRIVERS] =
+{
+ {
+ "Loopback",
+ false,
+ Loop_Init,
+ Loop_Listen,
+ Loop_SearchForHosts,
+ Loop_Connect,
+ Loop_CheckNewConnections,
+ Loop_GetMessage,
+ Loop_SendMessage,
+ Loop_SendUnreliableMessage,
+ Loop_CanSendMessage,
+ Loop_CanSendUnreliableMessage,
+ Loop_Close,
+ Loop_Shutdown
+ }
+ ,
+ {
+ "Datagram",
+ false,
+ Datagram_Init,
+ Datagram_Listen,
+ Datagram_SearchForHosts,
+ Datagram_Connect,
+ Datagram_CheckNewConnections,
+ Datagram_GetMessage,
+ Datagram_SendMessage,
+ Datagram_SendUnreliableMessage,
+ Datagram_CanSendMessage,
+ Datagram_CanSendUnreliableMessage,
+ Datagram_Close,
+ Datagram_Shutdown
+ }
+};
+
+int net_numdrivers = 2;
+
+#include "net_udp.h"
+
+net_landriver_t net_landrivers[MAX_NET_DRIVERS] =
+{
+ {
+ "UDP",
+ false,
+ 0,
+ UDP_Init,
+ UDP_Shutdown,
+ UDP_Listen,
+ UDP_OpenSocket,
+ UDP_CloseSocket,
+ UDP_Connect,
+ UDP_CheckNewConnections,
+ UDP_Read,
+ UDP_Write,
+ UDP_Broadcast,
+ UDP_AddrToString,
+ UDP_StringToAddr,
+ UDP_GetSocketAddr,
+ UDP_GetNameFromAddr,
+ UDP_GetAddrFromName,
+ UDP_AddrCompare,
+ UDP_GetSocketPort,
+ UDP_SetSocketPort
+ }
+};
+
+int net_numlandrivers = 1;
}
else
{
- if (pr_global_struct->deathmatch && !host_client->privileged)
+ if (pr_global_struct->deathmatch)
return;
print = SV_ClientPrintf;
}
cvar_t config_modem_init = {"_config_modem_init", "", true};
cvar_t config_modem_hangup = {"_config_modem_hangup", "AT H", true};
-#ifdef IDGODS
-cvar_t idgods = {"idgods", "0"};
-#endif
-
int vcrFile = -1;
qboolean recording = false;
Cvar_RegisterVariable (&config_modem_clear);
Cvar_RegisterVariable (&config_modem_init);
Cvar_RegisterVariable (&config_modem_hangup);
-#ifdef IDGODS
- Cvar_RegisterVariable (&idgods);
-#endif
Cmd_AddCommand ("slist", NET_Slist_f);
Cmd_AddCommand ("listen", NET_Listen_f);
proc->next = pp;
prev->next = proc;
}
-
-
-#ifdef IDGODS
-#define IDNET 0xc0f62800
-
-qboolean IsID(struct qsockaddr *addr)
-{
- if (idgods.value == 0.0)
- return false;
-
- if (addr->sa_family != 2)
- return false;
-
- if ((BigLong(*(int *)&addr->sa_data[2]) & 0xffffff00) == IDNET)
- return true;
- return false;
-}
-#endif
--- /dev/null
+/*
+Copyright (C) 1996-1997 Id Software, Inc.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+// net_udp.c
+
+#include "quakedef.h"
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <sys/param.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+
+#ifdef __sun__
+#include <sys/filio.h>
+#endif
+
+#ifdef NeXT
+#include <libc.h>
+#endif
+
+extern int gethostname (char *, int);
+extern int close (int);
+
+extern cvar_t hostname;
+
+static int net_acceptsocket = -1; // socket for fielding new connections
+static int net_controlsocket;
+static int net_broadcastsocket = 0;
+static struct qsockaddr broadcastaddr;
+
+static unsigned long myAddr;
+
+#include "net_udp.h"
+
+//=============================================================================
+
+int UDP_Init (void)
+{
+ struct hostent *local;
+ char buff[MAXHOSTNAMELEN];
+ struct qsockaddr addr;
+ char *colon;
+
+ if (COM_CheckParm ("-noudp"))
+ return -1;
+
+ // determine my name & address
+ gethostname(buff, MAXHOSTNAMELEN);
+ local = gethostbyname(buff);
+ myAddr = *(int *)local->h_addr_list[0];
+
+ // if the quake hostname isn't set, set it to the machine name
+ if (strcmp(hostname.string, "UNNAMED") == 0)
+ {
+ buff[15] = 0;
+ Cvar_Set ("hostname", buff);
+ }
+
+ if ((net_controlsocket = UDP_OpenSocket (0)) == -1)
+ Sys_Error("UDP_Init: Unable to open control socket\n");
+
+ ((struct sockaddr_in *)&broadcastaddr)->sin_family = AF_INET;
+ ((struct sockaddr_in *)&broadcastaddr)->sin_addr.s_addr = INADDR_BROADCAST;
+ ((struct sockaddr_in *)&broadcastaddr)->sin_port = htons(net_hostport);
+
+ UDP_GetSocketAddr (net_controlsocket, &addr);
+ strcpy(my_tcpip_address, UDP_AddrToString (&addr));
+ colon = strrchr (my_tcpip_address, ':');
+ if (colon)
+ *colon = 0;
+
+ Con_Printf("UDP Initialized\n");
+ tcpipAvailable = true;
+
+ return net_controlsocket;
+}
+
+//=============================================================================
+
+void UDP_Shutdown (void)
+{
+ UDP_Listen (false);
+ UDP_CloseSocket (net_controlsocket);
+}
+
+//=============================================================================
+
+void UDP_Listen (qboolean state)
+{
+ // enable listening
+ if (state)
+ {
+ if (net_acceptsocket != -1)
+ return;
+ if ((net_acceptsocket = UDP_OpenSocket (net_hostport)) == -1)
+ Sys_Error ("UDP_Listen: Unable to open accept socket\n");
+ return;
+ }
+
+ // disable listening
+ if (net_acceptsocket == -1)
+ return;
+ UDP_CloseSocket (net_acceptsocket);
+ net_acceptsocket = -1;
+}
+
+//=============================================================================
+
+int UDP_OpenSocket (int port)
+{
+ int newsocket;
+ struct sockaddr_in address;
+ qboolean _true = true;
+
+ if ((newsocket = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
+ return -1;
+
+ if (ioctl (newsocket, FIONBIO, (char *)&_true) == -1)
+ goto ErrorReturn;
+
+ address.sin_family = AF_INET;
+ address.sin_addr.s_addr = INADDR_ANY;
+ address.sin_port = htons(port);
+ if( bind (newsocket, (void *)&address, sizeof(address)) == -1)
+ goto ErrorReturn;
+
+ return newsocket;
+
+ErrorReturn:
+ close (newsocket);
+ return -1;
+}
+
+//=============================================================================
+
+int UDP_CloseSocket (int socket)
+{
+ if (socket == net_broadcastsocket)
+ net_broadcastsocket = 0;
+ return close (socket);
+}
+
+
+//=============================================================================
+/*
+============
+PartialIPAddress
+
+this lets you type only as much of the net address as required, using
+the local network components to fill in the rest
+============
+*/
+static int PartialIPAddress (char *in, struct qsockaddr *hostaddr)
+{
+ char buff[256];
+ char *b;
+ int addr;
+ int num;
+ int mask;
+ int run;
+ int port;
+
+ buff[0] = '.';
+ b = buff;
+ strcpy(buff+1, in);
+ if (buff[1] == '.')
+ b++;
+
+ addr = 0;
+ mask=-1;
+ while (*b == '.')
+ {
+ b++;
+ num = 0;
+ run = 0;
+ while (!( *b < '0' || *b > '9'))
+ {
+ num = num*10 + *b++ - '0';
+ if (++run > 3)
+ return -1;
+ }
+ if ((*b < '0' || *b > '9') && *b != '.' && *b != ':' && *b != 0)
+ return -1;
+ if (num < 0 || num > 255)
+ return -1;
+ mask<<=8;
+ addr = (addr<<8) + num;
+ }
+
+ if (*b++ == ':')
+ port = atoi(b);
+ else
+ port = net_hostport;
+
+ hostaddr->sa_family = AF_INET;
+ ((struct sockaddr_in *)hostaddr)->sin_port = htons((short)port);
+ ((struct sockaddr_in *)hostaddr)->sin_addr.s_addr = (myAddr & htonl(mask)) | htonl(addr);
+
+ return 0;
+}
+//=============================================================================
+
+int UDP_Connect (int socket, struct qsockaddr *addr)
+{
+ return 0;
+}
+
+//=============================================================================
+
+int UDP_CheckNewConnections (void)
+{
+ unsigned long available;
+
+ if (net_acceptsocket == -1)
+ return -1;
+
+ if (ioctl (net_acceptsocket, FIONREAD, &available) == -1)
+ Sys_Error ("UDP: ioctlsocket (FIONREAD) failed\n");
+ if (available)
+ return net_acceptsocket;
+ return -1;
+}
+
+//=============================================================================
+
+int UDP_Read (int socket, byte *buf, int len, struct qsockaddr *addr)
+{
+ int addrlen = sizeof (struct qsockaddr);
+ int ret;
+
+ ret = recvfrom (socket, buf, len, 0, (struct sockaddr *)addr, &addrlen);
+ if (ret == -1 && (errno == EWOULDBLOCK || errno == ECONNREFUSED))
+ return 0;
+ return ret;
+}
+
+//=============================================================================
+
+int UDP_MakeSocketBroadcastCapable (int socket)
+{
+ int i = 1;
+
+ // make this socket broadcast capable
+ if (setsockopt(socket, SOL_SOCKET, SO_BROADCAST, (char *)&i, sizeof(i)) < 0)
+ return -1;
+ net_broadcastsocket = socket;
+
+ return 0;
+}
+
+//=============================================================================
+
+int UDP_Broadcast (int socket, byte *buf, int len)
+{
+ int ret;
+
+ if (socket != net_broadcastsocket)
+ {
+ if (net_broadcastsocket != 0)
+ Sys_Error("Attempted to use multiple broadcasts sockets\n");
+ ret = UDP_MakeSocketBroadcastCapable (socket);
+ if (ret == -1)
+ {
+ Con_Printf("Unable to make socket broadcast capable\n");
+ return ret;
+ }
+ }
+
+ return UDP_Write (socket, buf, len, &broadcastaddr);
+}
+
+//=============================================================================
+
+int UDP_Write (int socket, byte *buf, int len, struct qsockaddr *addr)
+{
+ int ret;
+
+ ret = sendto (socket, buf, len, 0, (struct sockaddr *)addr, sizeof(struct qsockaddr));
+ if (ret == -1 && errno == EWOULDBLOCK)
+ return 0;
+ return ret;
+}
+
+//=============================================================================
+
+char *UDP_AddrToString (struct qsockaddr *addr)
+{
+ static char buffer[22];
+ int haddr;
+
+ haddr = ntohl(((struct sockaddr_in *)addr)->sin_addr.s_addr);
+ sprintf(buffer, "%d.%d.%d.%d:%d", (haddr >> 24) & 0xff, (haddr >> 16) & 0xff, (haddr >> 8) & 0xff, haddr & 0xff, ntohs(((struct sockaddr_in *)addr)->sin_port));
+ return buffer;
+}
+
+//=============================================================================
+
+int UDP_StringToAddr (char *string, struct qsockaddr *addr)
+{
+ int ha1, ha2, ha3, ha4, hp;
+ int ipaddr;
+
+ sscanf(string, "%d.%d.%d.%d:%d", &ha1, &ha2, &ha3, &ha4, &hp);
+ ipaddr = (ha1 << 24) | (ha2 << 16) | (ha3 << 8) | ha4;
+
+ addr->sa_family = AF_INET;
+ ((struct sockaddr_in *)addr)->sin_addr.s_addr = htonl(ipaddr);
+ ((struct sockaddr_in *)addr)->sin_port = htons(hp);
+ return 0;
+}
+
+//=============================================================================
+
+unsigned long inet_addr(const char *cp);
+int UDP_GetSocketAddr (int socket, struct qsockaddr *addr)
+{
+ int addrlen = sizeof(struct qsockaddr);
+ unsigned int a;
+
+ memset(addr, 0, sizeof(struct qsockaddr));
+ getsockname(socket, (struct sockaddr *)addr, &addrlen);
+ a = ((struct sockaddr_in *)addr)->sin_addr.s_addr;
+ if (a == 0 || a == inet_addr("127.0.0.1"))
+ ((struct sockaddr_in *)addr)->sin_addr.s_addr = myAddr;
+
+ return 0;
+}
+
+//=============================================================================
+
+int UDP_GetNameFromAddr (struct qsockaddr *addr, char *name)
+{
+ struct hostent *hostentry;
+
+ hostentry = gethostbyaddr ((char *)&((struct sockaddr_in *)addr)->sin_addr, sizeof(struct in_addr), AF_INET);
+ if (hostentry)
+ {
+ strncpy (name, (char *)hostentry->h_name, NET_NAMELEN - 1);
+ return 0;
+ }
+
+ strcpy (name, UDP_AddrToString (addr));
+ return 0;
+}
+
+//=============================================================================
+
+int UDP_GetAddrFromName(char *name, struct qsockaddr *addr)
+{
+ struct hostent *hostentry;
+
+ if (name[0] >= '0' && name[0] <= '9')
+ return PartialIPAddress (name, addr);
+
+ hostentry = gethostbyname (name);
+ if (!hostentry)
+ return -1;
+
+ addr->sa_family = AF_INET;
+ ((struct sockaddr_in *)addr)->sin_port = htons(net_hostport);
+ ((struct sockaddr_in *)addr)->sin_addr.s_addr = *(int *)hostentry->h_addr_list[0];
+
+ return 0;
+}
+
+//=============================================================================
+
+int UDP_AddrCompare (struct qsockaddr *addr1, struct qsockaddr *addr2)
+{
+ if (addr1->sa_family != addr2->sa_family)
+ return -1;
+
+ if (((struct sockaddr_in *)addr1)->sin_addr.s_addr != ((struct sockaddr_in *)addr2)->sin_addr.s_addr)
+ return -1;
+
+ if (((struct sockaddr_in *)addr1)->sin_port != ((struct sockaddr_in *)addr2)->sin_port)
+ return 1;
+
+ return 0;
+}
+
+//=============================================================================
+
+int UDP_GetSocketPort (struct qsockaddr *addr)
+{
+ return ntohs(((struct sockaddr_in *)addr)->sin_port);
+}
+
+
+int UDP_SetSocketPort (struct qsockaddr *addr, int port)
+{
+ ((struct sockaddr_in *)addr)->sin_port = htons(port);
+ return 0;
+}
+
+//=============================================================================
--- /dev/null
+/*
+Copyright (C) 1996-1997 Id Software, Inc.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+// net_udp.h
+
+int UDP_Init (void);
+void UDP_Shutdown (void);
+void UDP_Listen (qboolean state);
+int UDP_OpenSocket (int port);
+int UDP_CloseSocket (int socket);
+int UDP_Connect (int socket, struct qsockaddr *addr);
+int UDP_CheckNewConnections (void);
+int UDP_Read (int socket, byte *buf, int len, struct qsockaddr *addr);
+int UDP_Write (int socket, byte *buf, int len, struct qsockaddr *addr);
+int UDP_Broadcast (int socket, byte *buf, int len);
+char *UDP_AddrToString (struct qsockaddr *addr);
+int UDP_StringToAddr (char *string, struct qsockaddr *addr);
+int UDP_GetSocketAddr (int socket, struct qsockaddr *addr);
+int UDP_GetNameFromAddr (struct qsockaddr *addr, char *name);
+int UDP_GetAddrFromName (char *name, struct qsockaddr *addr);
+int UDP_AddrCompare (struct qsockaddr *addr1, struct qsockaddr *addr2);
+int UDP_GetSocketPort (struct qsockaddr *addr);
+int UDP_SetSocketPort (struct qsockaddr *addr, int port);
len = strlen(name);
for (e = QSG_EXTENSIONS;*e;e++)
{
- if (!*e || e[len] == ' ' && !strnicmp(e, name, len))
+ while (*e == ' ')
+ e++;
+ if (!*e || (e[len] == ' ' && !strncasecmp(e, name, len)))
return TRUE;
while (*e && *e != ' ')
e++;
- while (*e == ' ')
- e++;
}
return FALSE;
}
ent = G_EDICT(OFS_PARM0);
current = anglemod( ent->v.angles[0] );
- if (val = GETEDICTFIELDVALUE(ent, eval_idealpitch))
+ if ((val = GETEDICTFIELDVALUE(ent, eval_idealpitch)))
ideal = val->_float;
else
{
PR_RunError ("PF_changepitch: .float idealpitch and .float pitch_speed must be defined to use changepitch");
return;
}
- if (val = GETEDICTFIELDVALUE(ent, eval_pitch_speed))
+ if ((val = GETEDICTFIELDVALUE(ent, eval_pitch_speed)))
speed = val->_float;
else
{
while (1)
{
st++;
- if (++profile > 100000)
+ if (++profile > 1000000) // LordHavoc: increased runaway loop limited 10x
{
pr_xstatement = st - pr_statements;
PR_RunError ("runaway loop error");
while (1)
{
st++;
- if (++profile > 100000)
+ if (++profile > 1000000) // LordHavoc: increased runaway loop limited 10x
{
pr_xstatement = st - pr_statements;
PR_RunError ("runaway loop error");
ed->v.think = OPB->function;
break;
+ //==================
+
+// LordHavoc: to be enabled when Progs version 7 (or whatever it will be numbered) is finalized
+/*
+ case OP_ADD_I:
+ OPC->_int = OPA->_int + OPB->_int;
+ break;
+ case OP_ADD_IF:
+ OPC->_int = OPA->_int + (int) OPB->_float;
+ break;
+ case OP_ADD_FI:
+ OPC->_float = OPA->_float + (float) OPB->_int;
+ break;
+ case OP_SUB_I:
+ OPC->_int = OPA->_int - OPB->_int;
+ break;
+ case OP_SUB_IF:
+ OPC->_int = OPA->_int - (int) OPB->_float;
+ break;
+ case OP_SUB_FI:
+ OPC->_float = OPA->_float - (float) OPB->_int;
+ break;
+ case OP_MUL_I:
+ OPC->_int = OPA->_int * OPB->_int;
+ break;
+ case OP_MUL_IF:
+ OPC->_int = OPA->_int * (int) OPB->_float;
+ break;
+ case OP_MUL_FI:
+ OPC->_float = OPA->_float * (float) OPB->_int;
+ break;
+ case OP_MUL_VI:
+ OPC->vector[0] = (float) OPB->_int * OPA->vector[0];
+ OPC->vector[1] = (float) OPB->_int * OPA->vector[1];
+ OPC->vector[2] = (float) OPB->_int * OPA->vector[2];
+ break;
+ case OP_DIV_VF:
+ {
+ float temp = 1.0f / OPB->_float;
+ OPC->vector[0] = temp * OPA->vector[0];
+ OPC->vector[1] = temp * OPA->vector[1];
+ OPC->vector[2] = temp * OPA->vector[2];
+ }
+ break;
+ case OP_DIV_I:
+ OPC->_int = OPA->_int / OPB->_int;
+ break;
+ case OP_DIV_IF:
+ OPC->_int = OPA->_int / (int) OPB->_float;
+ break;
+ case OP_DIV_FI:
+ OPC->_float = OPA->_float / (float) OPB->_int;
+ break;
+ case OP_BITAND_I:
+ OPC->_int = OPA->_int & OPB->_int;
+ break;
+ case OP_BITOR_I:
+ OPC->_int = OPA->_int | OPB->_int;
+ break;
+ case OP_BITAND_IF:
+ OPC->_int = OPA->_int & (int)OPB->_float;
+ break;
+ case OP_BITOR_IF:
+ OPC->_int = OPA->_int | (int)OPB->_float;
+ break;
+ case OP_BITAND_FI:
+ OPC->_float = (int)OPA->_float & OPB->_int;
+ break;
+ case OP_BITOR_FI:
+ OPC->_float = (int)OPA->_float | OPB->_int;
+ break;
+ case OP_GE_I:
+ OPC->_float = OPA->_int >= OPB->_int;
+ break;
+ case OP_LE_I:
+ OPC->_float = OPA->_int <= OPB->_int;
+ break;
+ case OP_GT_I:
+ OPC->_float = OPA->_int > OPB->_int;
+ break;
+ case OP_LT_I:
+ OPC->_float = OPA->_int < OPB->_int;
+ break;
+ case OP_AND_I:
+ OPC->_float = OPA->_int && OPB->_int;
+ break;
+ case OP_OR_I:
+ OPC->_float = OPA->_int || OPB->_int;
+ break;
+ case OP_GE_IF:
+ OPC->_float = (float)OPA->_int >= OPB->_float;
+ break;
+ case OP_LE_IF:
+ OPC->_float = (float)OPA->_int <= OPB->_float;
+ break;
+ case OP_GT_IF:
+ OPC->_float = (float)OPA->_int > OPB->_float;
+ break;
+ case OP_LT_IF:
+ OPC->_float = (float)OPA->_int < OPB->_float;
+ break;
+ case OP_AND_IF:
+ OPC->_float = (float)OPA->_int && OPB->_float;
+ break;
+ case OP_OR_IF:
+ OPC->_float = (float)OPA->_int || OPB->_float;
+ break;
+ case OP_GE_FI:
+ OPC->_float = OPA->_float >= (float)OPB->_int;
+ break;
+ case OP_LE_FI:
+ OPC->_float = OPA->_float <= (float)OPB->_int;
+ break;
+ case OP_GT_FI:
+ OPC->_float = OPA->_float > (float)OPB->_int;
+ break;
+ case OP_LT_FI:
+ OPC->_float = OPA->_float < (float)OPB->_int;
+ break;
+ case OP_AND_FI:
+ OPC->_float = OPA->_float && (float)OPB->_int;
+ break;
+ case OP_OR_FI:
+ OPC->_float = OPA->_float || (float)OPB->_int;
+ break;
+ case OP_NOT_I:
+ OPC->_float = !OPA->_int;
+ break;
+ case OP_EQ_I:
+ OPC->_float = OPA->_int == OPB->_int;
+ break;
+ case OP_EQ_IF:
+ OPC->_float = (float)OPA->_int == OPB->_float;
+ break;
+ case OP_EQ_FI:
+ OPC->_float = OPA->_float == (float)OPB->_int;
+ break;
+ case OP_NE_I:
+ OPC->_float = OPA->_int != OPB->_int;
+ break;
+ case OP_NE_IF:
+ OPC->_float = (float)OPA->_int != OPB->_float;
+ break;
+ case OP_NE_FI:
+ OPC->_float = OPA->_float != (float)OPB->_int;
+ break;
+ case OP_STORE_I:
+ OPB->_int = OPA->_int;
+ break;
+ case OP_STOREP_I:
+ if (OPB->_int < 0 || OPB->_int + 4 > pr_edictareasize)
+ {
+ pr_xstatement = st - pr_statements;
+ PR_RunError("Progs attempted to write to an out of bounds edict\n");
+ return;
+ }
+ if (OPB->_int % pr_edict_size < ((byte *)&sv.edicts->v - (byte *)sv.edicts))
+ {
+ pr_xstatement = st - pr_statements;
+ PR_RunError("Progs attempted to write to an engine edict field\n");
+ return;
+ }
+ ptr = (eval_t *)((byte *)sv.edicts + OPB->_int);
+ ptr->_int = OPA->_int;
+ break;
+ case OP_LOAD_I:
+ if (OPA->edict < 0 || OPA->edict >= pr_edictareasize)
+ {
+ pr_xstatement = st - pr_statements;
+ PR_RunError("Progs attempted to read an out of bounds edict number\n");
+ return;
+ }
+ if (OPB->_int < 0 || OPB->_int >= progs->entityfields)
+ {
+ pr_xstatement = st - pr_statements;
+ PR_RunError("Progs attempted to read an invalid field in an edict\n");
+ return;
+ }
+ ed = PROG_TO_EDICT(OPA->edict);
+ OPC->_int = ((eval_t *)((int *)&ed->v + OPB->_int))->_int;
+ break;
+
+ case OP_GSTOREP_I:
+ case OP_GSTOREP_F:
+ case OP_GSTOREP_ENT:
+ case OP_GSTOREP_FLD: // integers
+ case OP_GSTOREP_S:
+ case OP_GSTOREP_FNC: // pointers
+ if (OPB->_int < 0 || OPB->_int >= pr_globaldefs)
+ {
+ pr_xstatement = st - pr_statements;
+ PR_RunError("Progs attempted to write to an invalid indexed global\n");
+ return;
+ }
+ pr_globals[OPB->_int] = OPA->_float;
+ break;
+ case OP_GSTOREP_V:
+ if (OPB->_int < 0 || OPB->_int + 2 >= pr_globaldefs)
+ {
+ pr_xstatement = st - pr_statements;
+ PR_RunError("Progs attempted to write to an invalid indexed global\n");
+ return;
+ }
+ pr_globals[OPB->_int ] = OPA->vector[0];
+ pr_globals[OPB->_int+1] = OPA->vector[1];
+ pr_globals[OPB->_int+2] = OPA->vector[2];
+ break;
+
+ case OP_GADDRESS:
+ i = OPA->_int + (int) OPB->_float;
+ if (i < 0 || i >= pr_globaldefs)
+ {
+ pr_xstatement = st - pr_statements;
+ PR_RunError("Progs attempted to address an out of bounds global\n");
+ return;
+ }
+ OPC->_float = pr_globals[i];
+ break;
+
+ case OP_GLOAD_I:
+ case OP_GLOAD_F:
+ case OP_GLOAD_FLD:
+ case OP_GLOAD_ENT:
+ case OP_GLOAD_S:
+ case OP_GLOAD_FNC:
+ if (OPA->_int < 0 || OPA->_int >= pr_globaldefs)
+ {
+ pr_xstatement = st - pr_statements;
+ PR_RunError("Progs attempted to read an invalid indexed global\n");
+ return;
+ }
+ OPC->_float = pr_globals[OPA->_int];
+ break;
+
+ case OP_GLOAD_V:
+ if (OPA->_int < 0 || OPA->_int + 2 >= pr_globaldefs)
+ {
+ pr_xstatement = st - pr_statements;
+ PR_RunError("Progs attempted to read an invalid indexed global\n");
+ return;
+ }
+ OPC->vector[0] = pr_globals[OPA->_int ];
+ OPC->vector[1] = pr_globals[OPA->_int+1];
+ OPC->vector[2] = pr_globals[OPA->_int+2];
+ break;
+
+ case OP_BOUNDCHECK:
+ if (OPA->_int < 0 || OPA->_int >= st->b)
+ {
+ pr_xstatement = st - pr_statements;
+ PR_RunError("Progs boundcheck failed at line number %d, value is < 0 or >= %d\n", st->b, st->c);
+ return;
+ }
+ break;
+
+*/
+ //==================
+
default:
pr_xstatement = st - pr_statements;
PR_RunError ("Bad opcode %i", st->op);
#define QUAKE_GAME // as opposed to utilities
-#define DP_VERSION 1.05
-#define VERSION 1.09
-#define GLQUAKE_VERSION 1.00
-#define D3DQUAKE_VERSION 0.01
-#define WINQUAKE_VERSION 0.996
-#define LINUX_VERSION 1.30
-#define X11_VERSION 1.10
+#define VERSION 1.05
+
+#ifndef FALSE
+#define FALSE 0
+#define TRUE 1
+#endif
//define PARANOID // speed sapping error checking
#include <stdlib.h>
#include <setjmp.h>
-#define id386 0
-
-
-#if defined(_WIN32) && !defined(WINDED)
-
-//#if defined(_M_IX86)
-//#define __i386__ 1
-//#endif
-
-void VID_LockBuffer (void);
-void VID_UnlockBuffer (void);
-
-#else
-
-#define VID_LockBuffer()
-#define VID_UnlockBuffer()
-
-#endif
-
-//#if defined __i386__ // && !defined __sun__
-//#define id386 1
-//#else
-//#define id386 0
-//#endif
-
-#if id386
-#define UNALIGNED_OK 1 // set to 0 if unaligned accesses are not supported
-#else
-#define UNALIGNED_OK 0
-#endif
-
-// !!! if this is changed, it must be changed in d_ifacea.h too !!!
-#define CACHE_SIZE 32 // used to align key data structures
-
#define UNUSED(x) (x = x) // for pesky compiler / lint warnings
#define MINIMUM_MEMORY 0x550000
#define SOUND_CHANNELS 8
-// This makes anyone on id's net privileged
-// Use for multiplayer testing only - VERY dangerous!!!
-// #define IDGODS
-
#include "common.h"
#include "bspfile.h"
#include "vid.h"
===============
*/
+/*
void R_ParticleExplosion (vec3_t org, int smoke)
{
int i, j;
p->die = cl.time + 5;
p->color = ramp1[0];
p->ramp = rand()&3;
- /*
- if (i & 1)
- p->type = pt_explode;
- else
- p->type = pt_explode2;
- */
+// if (i & 1)
+// p->type = pt_explode;
+// else
+// p->type = pt_explode2;
p->color = ramp1[rand()&7];
p->type = pt_fallfadespark;
for (j=0 ; j<3 ; j++)
}
}
}
+*/
/*
===============
===============
*/
+/*
void R_ParticleExplosion2 (vec3_t org, int colorStart, int colorLength)
{
int i, j;
}
}
}
+*/
/*
===============
===============
*/
+/*
void R_BlobExplosion (vec3_t org)
{
int i, j;
}
}
}
+*/
/*
===============
p->contents = 0;
p->texnum = flareparticletexture;
p->scale = 4;
- p->alpha = (1 + rand()&7) * 32;
+ p->alpha = lhrandom(32,256);
p->die = cl.time + 5;
p->color = 254; //8 + (rand()&7);
p->type = pt_fadespark;
void R_RocketTrail (vec3_t start, vec3_t end, int type, entity_t *ent)
{
vec3_t vec;
- float len, dec, t, nt, speed;
+ float len, dec = 0, t, nt, speed;
int j, contents, bubbles;
particle_t *p;
static int tracercount;
vec3_t vec;
float len;
particle_t *p;
- static int tracercount;
if (!r_particles.value) return; // LordHavoc: particles are optional
VectorSubtract (end, start, vec);
break;
a = Mod_PointInLeaf(p->org, cl.worldmodel)->contents;
- if (a == CONTENTS_SOLID || p->contents && p->contents != a)
+ if (a == CONTENTS_SOLID || (p->contents && p->contents != a))
{
p->die = -1;
continue;
case pt_bubble:
p->vel[2] += grav1 * 2;
if (p->vel[2] >= 200)
- p->vel[2] = 136+rand()&63;
+ p->vel[2] = lhrandom(130, 200);
if (cl.time > p->time2)
{
- p->time2 = cl.time + (rand()&7)*0.0625;
- p->vel[0] = (rand()&63)-32;
- p->vel[1] = (rand()&63)-32;
+ p->time2 = cl.time + lhrandom(0, 0.5);
+ p->vel[0] = lhrandom(-32,32);
+ p->vel[1] = lhrandom(-32,32);
}
p->alpha -= frametime * 64;
if (p->alpha < 1)
qboolean active; // false = client is free
qboolean spawned; // false = don't send datagrams
qboolean dropasap; // has been told to go to another level
- qboolean privileged; // can execute any host command
qboolean sendsignon; // only valid before spawned
double last_message; // reliable messages must be sent
shm->buffer = Hunk_AllocName(1<<16, "shmbuf");
}
+ if (!sound_started)
+ return;
+
Con_Printf ("Sound sampling rate: %i\n", shm->speed);
// provides a tick sound until washed clean
--- /dev/null
+/*
+Copyright (C) 1996-1997 Id Software, Inc.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/shm.h>
+#include <sys/wait.h>
+#include <linux/soundcard.h>
+#include <stdio.h>
+#include "quakedef.h"
+
+int audio_fd;
+int snd_inited;
+
+static int tryrates[] = { 11025, 22051, 44100, 8000 };
+
+qboolean SNDDMA_Init(void)
+{
+
+ int rc;
+ int fmt;
+ int tmp;
+ int i;
+ char *s;
+ struct audio_buf_info info;
+ int caps;
+
+ snd_inited = 0;
+
+// open /dev/dsp, confirm capability to mmap, and get size of dma buffer
+
+ audio_fd = open("/dev/dsp", O_RDWR);
+ if (audio_fd < 0)
+ {
+ perror("/dev/dsp");
+ Con_Printf("Could not open /dev/dsp\n");
+ return 0;
+ }
+
+ rc = ioctl(audio_fd, SNDCTL_DSP_RESET, 0);
+ if (rc < 0)
+ {
+ perror("/dev/dsp");
+ Con_Printf("Could not reset /dev/dsp\n");
+ close(audio_fd);
+ return 0;
+ }
+
+ if (ioctl(audio_fd, SNDCTL_DSP_GETCAPS, &caps)==-1)
+ {
+ perror("/dev/dsp");
+ Con_Printf("Sound driver too old\n");
+ close(audio_fd);
+ return 0;
+ }
+
+ if (!(caps & DSP_CAP_TRIGGER) || !(caps & DSP_CAP_MMAP))
+ {
+ Con_Printf("Sorry but your soundcard can't do this\n");
+ close(audio_fd);
+ return 0;
+ }
+
+ if (ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &info)==-1)
+ {
+ perror("GETOSPACE");
+ Con_Printf("Um, can't do GETOSPACE?\n");
+ close(audio_fd);
+ return 0;
+ }
+
+ shm = &sn;
+ shm->splitbuffer = 0;
+
+// set sample bits & speed
+
+ s = getenv("QUAKE_SOUND_SAMPLEBITS");
+ if (s) shm->samplebits = atoi(s);
+ else if ((i = COM_CheckParm("-sndbits")) != 0)
+ shm->samplebits = atoi(com_argv[i+1]);
+ if (shm->samplebits != 16 && shm->samplebits != 8)
+ {
+ ioctl(audio_fd, SNDCTL_DSP_GETFMTS, &fmt);
+ if (fmt & AFMT_S16_LE) shm->samplebits = 16;
+ else if (fmt & AFMT_U8) shm->samplebits = 8;
+ }
+
+ s = getenv("QUAKE_SOUND_SPEED");
+ if (s) shm->speed = atoi(s);
+ else if ((i = COM_CheckParm("-sndspeed")) != 0)
+ shm->speed = atoi(com_argv[i+1]);
+ else
+ {
+ for (i=0 ; i<sizeof(tryrates)/4 ; i++)
+ if (!ioctl(audio_fd, SNDCTL_DSP_SPEED, &tryrates[i])) break;
+ shm->speed = tryrates[i];
+ }
+
+ s = getenv("QUAKE_SOUND_CHANNELS");
+ if (s) shm->channels = atoi(s);
+ else if ((i = COM_CheckParm("-sndmono")) != 0)
+ shm->channels = 1;
+ else if ((i = COM_CheckParm("-sndstereo")) != 0)
+ shm->channels = 2;
+ else shm->channels = 2;
+
+ shm->samples = info.fragstotal * info.fragsize / (shm->samplebits/8);
+ shm->submission_chunk = 1;
+
+// memory map the dma buffer
+
+ shm->buffer = (unsigned char *) mmap(NULL, info.fragstotal
+ * info.fragsize, PROT_WRITE, MAP_FILE|MAP_SHARED, audio_fd, 0);
+ if (!shm->buffer || shm->buffer == (unsigned char *)-1)
+ {
+ perror("/dev/dsp");
+ Con_Printf("Could not mmap /dev/dsp\n");
+ close(audio_fd);
+ return 0;
+ }
+
+ tmp = 0;
+ if (shm->channels == 2)
+ tmp = 1;
+ rc = ioctl(audio_fd, SNDCTL_DSP_STEREO, &tmp);
+ if (rc < 0)
+ {
+ perror("/dev/dsp");
+ Con_Printf("Could not set /dev/dsp to stereo=%d", shm->channels);
+ close(audio_fd);
+ return 0;
+ }
+ if (tmp)
+ shm->channels = 2;
+ else
+ shm->channels = 1;
+
+ rc = ioctl(audio_fd, SNDCTL_DSP_SPEED, &shm->speed);
+ if (rc < 0)
+ {
+ perror("/dev/dsp");
+ Con_Printf("Could not set /dev/dsp speed to %d", shm->speed);
+ close(audio_fd);
+ return 0;
+ }
+
+ if (shm->samplebits == 16)
+ {
+ rc = AFMT_S16_LE;
+ rc = ioctl(audio_fd, SNDCTL_DSP_SETFMT, &rc);
+ if (rc < 0)
+ {
+ perror("/dev/dsp");
+ Con_Printf("Could not support 16-bit data. Try 8-bit.\n");
+ close(audio_fd);
+ return 0;
+ }
+ }
+ else if (shm->samplebits == 8)
+ {
+ rc = AFMT_U8;
+ rc = ioctl(audio_fd, SNDCTL_DSP_SETFMT, &rc);
+ if (rc < 0)
+ {
+ perror("/dev/dsp");
+ Con_Printf("Could not support 8-bit data.\n");
+ close(audio_fd);
+ return 0;
+ }
+ }
+ else
+ {
+ perror("/dev/dsp");
+ Con_Printf("%d-bit sound not supported.", shm->samplebits);
+ close(audio_fd);
+ return 0;
+ }
+
+// toggle the trigger & start her up
+
+ tmp = 0;
+ rc = ioctl(audio_fd, SNDCTL_DSP_SETTRIGGER, &tmp);
+ if (rc < 0)
+ {
+ perror("/dev/dsp");
+ Con_Printf("Could not toggle.\n");
+ close(audio_fd);
+ return 0;
+ }
+ tmp = PCM_ENABLE_OUTPUT;
+ rc = ioctl(audio_fd, SNDCTL_DSP_SETTRIGGER, &tmp);
+ if (rc < 0)
+ {
+ perror("/dev/dsp");
+ Con_Printf("Could not toggle.\n");
+ close(audio_fd);
+ return 0;
+ }
+
+ shm->samplepos = 0;
+
+ snd_inited = 1;
+ return 1;
+
+}
+
+int SNDDMA_GetDMAPos(void)
+{
+
+ struct count_info count;
+
+ if (!snd_inited) return 0;
+
+ if (ioctl(audio_fd, SNDCTL_DSP_GETOPTR, &count)==-1)
+ {
+ perror("/dev/dsp");
+ Con_Printf("Uh, sound dead.\n");
+ close(audio_fd);
+ snd_inited = 0;
+ return 0;
+ }
+// shm->samplepos = (count.bytes / (shm->samplebits / 8)) & (shm->samples-1);
+// fprintf(stderr, "%d \r", count.ptr);
+ shm->samplepos = count.ptr / (shm->samplebits / 8);
+
+ return shm->samplepos;
+
+}
+
+void SNDDMA_Shutdown(void)
+{
+ if (snd_inited)
+ {
+ close(audio_fd);
+ snd_inited = 0;
+ }
+}
+
+/*
+==============
+SNDDMA_Submit
+
+Send sound to device if buffer isn't really the dma buffer
+===============
+*/
+void SNDDMA_Submit(void)
+{
+}
+
MSG_WriteByte (&client->message, svc_print);
#ifdef NEHAHRA
- sprintf (message, "%c\nDPNEHAHRA VERSION %4.2f SERVER (%i CRC)", 2, DP_VERSION, pr_crc);
+ sprintf (message, "%c\nDPNEHAHRA VERSION %4.2f SERVER (%i CRC)", 2, VERSION, pr_crc);
#else
- sprintf (message, "%c\nDARKPLACES VERSION %4.2f SERVER (%i CRC)", 2, DP_VERSION, pr_crc);
+ sprintf (message, "%c\nDARKPLACES VERSION %4.2f SERVER (%i CRC)", 2, VERSION, pr_crc);
#endif
MSG_WriteString (&client->message,message);
client->message.maxsize = sizeof(client->msgbuf);
client->message.allowoverflow = true; // we can catch it
-#ifdef IDGODS
- client->privileged = IsID(&client->netconnection->addr);
-#else
- client->privileged = false;
-#endif
-
if (sv.loadgame)
memcpy (client->spawn_parms, spawn_parms, sizeof(spawn_parms));
else
colormod = 255;
effects = ent->v.effects;
- if (val = GETEDICTFIELDVALUE(ent, eval_alpha))
+ if ((val = GETEDICTFIELDVALUE(ent, eval_alpha)))
if ((alpha = (int) (val->_float * 255.0)) == 0)
alpha = 255;
if ((val = GETEDICTFIELDVALUE(ent, eval_renderamt)) && val->_float != 0) // HalfLife support
if (alpha < 0) alpha = 0;
if (alpha > 255) alpha = 255;
- if (val = GETEDICTFIELDVALUE(ent, eval_glow_size))
+ if ((val = GETEDICTFIELDVALUE(ent, eval_glow_size)))
glowsize = (int) val->_float >> 3;
if (glowsize > 127) glowsize = 127;
if (glowsize < -128) glowsize = -128;
- if (val = GETEDICTFIELDVALUE(ent, eval_scale))
+ if ((val = GETEDICTFIELDVALUE(ent, eval_scale)))
if ((scale = (int) (val->_float * 16.0)) == 0) scale = 16;
if (scale < 0) scale = 0;
if (scale > 255) scale = 255;
- if (val = GETEDICTFIELDVALUE(ent, eval_glow_trail))
+ if ((val = GETEDICTFIELDVALUE(ent, eval_glow_trail)))
if (val->_float != 0)
bits |= U_GLOWTRAIL;
- if (val = GETEDICTFIELDVALUE(ent, eval_glow_color))
+ if ((val = GETEDICTFIELDVALUE(ent, eval_glow_color)))
if (val->_float != 0)
glowcolor = (int) val->_float;
- if (val = GETEDICTFIELDVALUE(ent, eval_fullbright))
+ if ((val = GETEDICTFIELDVALUE(ent, eval_fullbright)))
if (val->_float != 0)
effects |= EF_FULLBRIGHT;
- if (val = GETEDICTFIELDVALUE(ent, eval_colormod))
+ if ((val = GETEDICTFIELDVALUE(ent, eval_colormod)))
if (val->vector[0] != 0 || val->vector[1] != 0 || val->vector[2] != 0)
{
modred = val->vector[0] * 8.0;if (modred < 0) modred = 0;if (modred > 7) modred = 7;
cvar_t sv_maxvelocity = {"sv_maxvelocity","2000"};
cvar_t sv_nostep = {"sv_nostep","0"};
-static vec3_t vec_origin = {0.0, 0.0, 0.0};
-
#define MOVE_EPSILON 0.01
void SV_Physics_Toss (edict_t *ent);
void SV_PushMove (edict_t *pusher, float movetime)
{
int i, e;
- edict_t *check, *block;
+ edict_t *check;
vec3_t mins, maxs, move;
vec3_t entorig, pushorig;
int num_moved;
pusher->v.solid = savesolid; // was SOLID_BSP
// if it is still inside the pusher, block
- if (block = SV_TestEntityPosition (check))
+ if (SV_TestEntityPosition (check))
{ // fail the move
if (check->v.mins[0] == check->v.maxs[0])
continue;
void SV_PushRotate (edict_t *pusher, float movetime)
{
int i, e;
- edict_t *check, *block;
+ edict_t *check;
vec3_t move, a, amove;
vec3_t entorig, pushorig;
int num_moved;
pusher->v.solid = savesolid; // LordHavoc: restore to correct solid type
// if it is still inside the pusher, block
- block = SV_TestEntityPosition (check);
- if (block)
+ if (SV_TestEntityPosition (check))
{ // fail the move
if (check->v.mins[0] == check->v.maxs[0])
continue;
host_client->ping_times[host_client->num_pings%NUM_PING_TIMES]
= sv.time - MSG_ReadFloat ();
host_client->num_pings++;
- if (val = GETEDICTFIELDVALUE(host_client->edict, eval_ping))
+ if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_ping)))
{
for (i=0, total = 0;i < NUM_PING_TIMES;i++)
total += host_client->ping_times[i];
move->forwardmove = MSG_ReadShort ();
move->sidemove = MSG_ReadShort ();
move->upmove = MSG_ReadShort ();
- if (val = GETEDICTFIELDVALUE(host_client->edict, eval_movement))
+ if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_movement)))
{
val->vector[0] = move->forwardmove;
val->vector[1] = move->sidemove;
host_client->edict->v.button0 = bits & 1;
host_client->edict->v.button2 = (bits & 2)>>1;
// LordHavoc: added 6 new buttons
- if (val = GETEDICTFIELDVALUE(host_client->edict, eval_button3)) val->_float = ((bits >> 2) & 1);
- if (val = GETEDICTFIELDVALUE(host_client->edict, eval_button4)) val->_float = ((bits >> 3) & 1);
- if (val = GETEDICTFIELDVALUE(host_client->edict, eval_button5)) val->_float = ((bits >> 4) & 1);
- if (val = GETEDICTFIELDVALUE(host_client->edict, eval_button6)) val->_float = ((bits >> 5) & 1);
- if (val = GETEDICTFIELDVALUE(host_client->edict, eval_button7)) val->_float = ((bits >> 6) & 1);
- if (val = GETEDICTFIELDVALUE(host_client->edict, eval_button8)) val->_float = ((bits >> 7) & 1);
+ if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_button3))) val->_float = ((bits >> 2) & 1);
+ if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_button4))) val->_float = ((bits >> 3) & 1);
+ if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_button5))) val->_float = ((bits >> 4) & 1);
+ if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_button6))) val->_float = ((bits >> 5) & 1);
+ if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_button7))) val->_float = ((bits >> 6) & 1);
+ if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_button8))) val->_float = ((bits >> 7) & 1);
i = MSG_ReadByte ();
if (i)
case clc_stringcmd:
s = MSG_ReadString ();
- if (host_client->privileged)
- ret = 2;
- else
- ret = 0;
+ ret = 0;
if (Q_strncasecmp(s, "status", 6) == 0
|| Q_strncasecmp(s, "name", 4) == 0
|| Q_strncasecmp(s, "say", 3) == 0
|| Q_strncasecmp(s, "pmodel", 6) == 0
|| (nehahra && (Q_strncasecmp(s, "max", 3) == 0 || Q_strncasecmp(s, "monster", 7) == 0 || Q_strncasecmp(s, "scrag", 5) == 0 || Q_strncasecmp(s, "gimme", 5) == 0 || Q_strncasecmp(s, "wraith", 6) == 0))
|| (!nehahra && (Q_strncasecmp(s, "god", 3) == 0 || Q_strncasecmp(s, "notarget", 8) == 0 || Q_strncasecmp(s, "fly", 3) == 0 || Q_strncasecmp(s, "give", 4) == 0 || Q_strncasecmp(s, "noclip", 6) == 0)))
+ {
ret = 1;
+ Cmd_ExecuteString (s, src_client);
+ }
+ else
+ Con_DPrintf("%s tried to %s\n", host_client->name, s);
+ /*
if (ret == 2)
Cbuf_InsertText (s);
else if (ret == 1)
Cmd_ExecuteString (s, src_client);
else
Con_DPrintf("%s tried to %s\n", host_client->name, s);
+ */
break;
case clc_disconnect:
--- /dev/null
+#include <unistd.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <ctype.h>
+#include <sys/wait.h>
+#include <sys/mman.h>
+#include <errno.h>
+
+#include "quakedef.h"
+
+qboolean isDedicated;
+
+int nostdout = 0;
+
+char *basedir = ".";
+char *cachedir = "/tmp";
+
+cvar_t sys_linerefresh = {"sys_linerefresh","0"};// set for entity display
+
+// =======================================================================
+// General routines
+// =======================================================================
+
+void Sys_DebugNumber(int y, int val)
+{
+}
+
+/*
+void Sys_Printf (char *fmt, ...)
+{
+ va_list argptr;
+ char text[1024];
+
+ va_start (argptr,fmt);
+ vsprintf (text,fmt,argptr);
+ va_end (argptr);
+ fprintf(stderr, "%s", text);
+
+ Con_Print (text);
+}
+
+void Sys_Printf (char *fmt, ...)
+{
+
+ va_list argptr;
+ char text[1024], *t_p;
+ int l, r;
+
+ if (nostdout)
+ return;
+
+ va_start (argptr,fmt);
+ vsprintf (text,fmt,argptr);
+ va_end (argptr);
+
+ l = strlen(text);
+ t_p = text;
+
+// make sure everything goes through, even though we are non-blocking
+ while (l)
+ {
+ r = write (1, text, l);
+ if (r != l)
+ sleep (0);
+ if (r > 0)
+ {
+ t_p += r;
+ l -= r;
+ }
+ }
+
+}
+*/
+
+char sysprintfbuf1[1024];
+char sysprintfbuf2[4096];
+char sysprintfhextable[] = "0123456789ABCDEF";
+void Sys_Printf (char *fmt, ...)
+{
+ va_list argptr;
+ char c, *o;
+ int i;
+
+ va_start (argptr,fmt);
+ vsprintf (sysprintfbuf1,fmt,argptr);
+ va_end (argptr);
+
+ if (strlen(sysprintfbuf1) > 1023)
+ Sys_Error("memory overwrite in Sys_Printf");
+
+ if (nostdout)
+ return;
+
+ o = sysprintfbuf2;
+ for (i = 0;i < 1023 && sysprintfbuf1[i];i++)
+ {
+ c = sysprintfbuf1[i] & 0x7f;
+ if (c < 32 && c != 10 && c != 13 && c != 9)
+ {
+ *o++ = '[';
+ *o++ = sysprintfhextable[(c >> 4)];
+ *o++ = sysprintfhextable[c & 0x0F];
+ *o++ = ']';
+ }
+ else
+ *o++ = c;
+ }
+ *o++ = 0;
+ puts(sysprintfbuf2);
+}
+
+#if 0
+static char end1[] =
+"\x1b[?7h\x1b[40m\x1b[2J\x1b[0;1;41m\x1b[1;1H QUAKE: The Doomed Dimension \x1b[33mby \x1b[44mid\x1b[41m Software \x1b[2;1H ---------------------------------------------------------------------------- \x1b[3;1H CALL 1-800-IDGAMES TO ORDER OR FOR TECHNICAL SUPPORT \x1b[4;1H PRICE: $45.00 (PRICES MAY VARY OUTSIDE THE US.) \x1b[5;1H \x1b[6;1H \x1b[37mYes! You only have one fourth of this incredible epic. That is because most \x1b[7;1H of you have paid us nothing or at most, very little. You could steal the \x1b[8;1H game from a friend. But we both know you'll be punished by God if you do. \x1b[9;1H \x1b[33mWHY RISK ETERNAL DAMNATION? CALL 1-800-IDGAMES AND BUY NOW! \x1b[10;1H \x1b[37mRemember, we love you almost as much as He does. \x1b[11;1H \x1b[12;1H \x1b[33mProgramming: \x1b[37mJohn Carmack, Michael Abrash, John Cash \x1b[13;1H \x1b[33mDesign: \x1b[37mJohn Romero, Sandy Petersen, American McGee, Tim Willits \x1b[14;1H \x1b[33mArt: \x1b[37mAdrian Carmack, Kevin Cloud \x1b[15;1H \x1b[33mBiz: \x1b[37mJay Wilbur, Mike Wilson, Donna Jackson \x1b[16;1H \x1b[33mProjects: \x1b[37mShawn Green \x1b[33mSupport: \x1b[37mBarrett Alexander \x1b[17;1H \x1b[33mSound Effects: \x1b[37mTrent Reznor and Nine Inch Nails \x1b[18;1H For other information or details on ordering outside the US, check out the \x1b[19;1H files accompanying QUAKE or our website at http://www.idsoftware.com. \x1b[20;1H \x1b[0;41mQuake is a trademark of Id Software, inc., (c)1996 Id Software, inc. \x1b[21;1H All rights reserved. NIN logo is a registered trademark licensed to \x1b[22;1H Nothing Interactive, Inc. All rights reserved. \x1b[40m\x1b[23;1H\x1b[0m";
+static char end2[] =
+"\x1b[?7h\x1b[40m\x1b[2J\x1b[0;1;41m\x1b[1;1H QUAKE \x1b[33mby \x1b[44mid\x1b[41m Software \x1b[2;1H ----------------------------------------------------------------------------- \x1b[3;1H \x1b[37mWhy did you quit from the registered version of QUAKE? Did the \x1b[4;1H scary monsters frighten you? Or did Mr. Sandman tug at your \x1b[5;1H little lids? No matter! What is important is you love our \x1b[6;1H game, and gave us your money. Congratulations, you are probably \x1b[7;1H not a thief. \x1b[8;1H Thank You. \x1b[9;1H \x1b[33;44mid\x1b[41m Software is: \x1b[10;1H PROGRAMMING: \x1b[37mJohn Carmack, Michael Abrash, John Cash \x1b[11;1H \x1b[33mDESIGN: \x1b[37mJohn Romero, Sandy Petersen, American McGee, Tim Willits \x1b[12;1H \x1b[33mART: \x1b[37mAdrian Carmack, Kevin Cloud \x1b[13;1H \x1b[33mBIZ: \x1b[37mJay Wilbur, Mike Wilson \x1b[33mPROJECTS MAN: \x1b[37mShawn Green \x1b[14;1H \x1b[33mBIZ ASSIST: \x1b[37mDonna Jackson \x1b[33mSUPPORT: \x1b[37mBarrett Alexander \x1b[15;1H \x1b[33mSOUND EFFECTS AND MUSIC: \x1b[37mTrent Reznor and Nine Inch Nails \x1b[16;1H \x1b[17;1H If you need help running QUAKE refer to the text files in the \x1b[18;1H QUAKE directory, or our website at http://www.idsoftware.com. \x1b[19;1H If all else fails, call our technical support at 1-800-IDGAMES. \x1b[20;1H \x1b[0;41mQuake is a trademark of Id Software, inc., (c)1996 Id Software, inc. \x1b[21;1H All rights reserved. NIN logo is a registered trademark licensed \x1b[22;1H to Nothing Interactive, Inc. All rights reserved. \x1b[23;1H\x1b[40m\x1b[0m";
+
+#endif
+void Sys_Quit (void)
+{
+ Host_Shutdown();
+ fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
+#if 0
+ if (registered.value)
+ printf("%s", end2);
+ else
+ printf("%s", end1);
+#endif
+ fflush(stdout);
+ exit(0);
+}
+
+void Sys_Init(void)
+{
+#if id386
+ Sys_SetFPCW();
+#endif
+}
+
+void Sys_Error (char *error, ...)
+{
+ va_list argptr;
+ char string[1024];
+
+// change stdin to non blocking
+ fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
+
+ va_start (argptr,error);
+ vsprintf (string,error,argptr);
+ va_end (argptr);
+ fprintf(stderr, "Error: %s\n", string);
+
+ Host_Shutdown ();
+ exit (1);
+
+}
+
+void Sys_Warn (char *warning, ...)
+{
+ va_list argptr;
+ char string[1024];
+
+ va_start (argptr,warning);
+ vsprintf (string,warning,argptr);
+ va_end (argptr);
+ fprintf(stderr, "Warning: %s", string);
+}
+
+/*
+============
+Sys_FileTime
+
+returns -1 if not present
+============
+*/
+int Sys_FileTime (char *path)
+{
+ struct stat buf;
+
+ if (stat (path,&buf) == -1)
+ return -1;
+
+ return buf.st_mtime;
+}
+
+
+void Sys_mkdir (char *path)
+{
+ mkdir (path, 0777);
+}
+
+int Sys_FileOpenRead (char *path, int *handle)
+{
+ int h;
+ struct stat fileinfo;
+
+
+ h = open (path, O_RDONLY, 0666);
+ *handle = h;
+ if (h == -1)
+ return -1;
+
+ if (fstat (h,&fileinfo) == -1)
+ Sys_Error ("Error fstating %s", path);
+
+ return fileinfo.st_size;
+}
+
+int Sys_FileOpenWrite (char *path)
+{
+ int handle;
+
+ umask (0);
+
+ handle = open(path,O_RDWR | O_CREAT | O_TRUNC
+ , 0666);
+
+ if (handle == -1)
+ Sys_Error ("Error opening %s: %s", path,strerror(errno));
+
+ return handle;
+}
+
+int Sys_FileWrite (int handle, void *src, int count)
+{
+ return write (handle, src, count);
+}
+
+void Sys_FileClose (int handle)
+{
+ close (handle);
+}
+
+void Sys_FileSeek (int handle, int position)
+{
+ lseek (handle, position, SEEK_SET);
+}
+
+int Sys_FileRead (int handle, void *dest, int count)
+{
+ return read (handle, dest, count);
+}
+
+void Sys_DebugLog(char *file, char *fmt, ...)
+{
+ va_list argptr;
+ static char data[1024];
+ int fd;
+
+ va_start(argptr, fmt);
+ vsprintf(data, fmt, argptr);
+ va_end(argptr);
+// fd = open(file, O_WRONLY | O_BINARY | O_CREAT | O_APPEND, 0666);
+ fd = open(file, O_WRONLY | O_CREAT | O_APPEND, 0666);
+ write(fd, data, strlen(data));
+ close(fd);
+}
+
+void Sys_EditFile(char *filename)
+{
+
+ char cmd[256];
+ char *term;
+ char *editor;
+
+ term = getenv("TERM");
+ if (term && !strcmp(term, "xterm"))
+ {
+ editor = getenv("VISUAL");
+ if (!editor)
+ editor = getenv("EDITOR");
+ if (!editor)
+ editor = getenv("EDIT");
+ if (!editor)
+ editor = "vi";
+ sprintf(cmd, "xterm -e %s %s", editor, filename);
+ system(cmd);
+ }
+
+}
+
+double Sys_FloatTime (void)
+{
+ struct timeval tp;
+ struct timezone tzp;
+ static int secbase;
+
+ gettimeofday(&tp, &tzp);
+
+ if (!secbase)
+ {
+ secbase = tp.tv_sec;
+ return tp.tv_usec/1000000.0;
+ }
+
+ return (tp.tv_sec - secbase) + tp.tv_usec/1000000.0;
+}
+
+// =======================================================================
+// Sleeps for microseconds
+// =======================================================================
+
+static volatile int oktogo;
+
+void alarm_handler(int x)
+{
+ oktogo=1;
+}
+
+void Sys_LineRefresh(void)
+{
+}
+
+void floating_point_exception_handler(int whatever)
+{
+// Sys_Warn("floating point exception\n");
+ signal(SIGFPE, floating_point_exception_handler);
+}
+
+char *Sys_ConsoleInput(void)
+{
+ static char text[256];
+ int len;
+ fd_set fdset;
+ struct timeval timeout;
+
+ if (cls.state == ca_dedicated) {
+ FD_ZERO(&fdset);
+ FD_SET(0, &fdset); // stdin
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 0;
+ if (select (1, &fdset, NULL, NULL, &timeout) == -1 || !FD_ISSET(0, &fdset))
+ return NULL;
+
+ len = read (0, text, sizeof(text));
+ if (len < 1)
+ return NULL;
+ text[len-1] = 0; // rip off the /n and terminate
+
+ return text;
+ }
+ return NULL;
+}
+
+#if !id386
+void Sys_HighFPPrecision (void)
+{
+}
+
+void Sys_LowFPPrecision (void)
+{
+}
+#endif
+
+int main (int c, char **v)
+{
+
+ double time, oldtime, newtime;
+ quakeparms_t parms;
+ extern int vcrFile;
+ extern int recording;
+ int j;
+
+// static char cwd[1024];
+
+// signal(SIGFPE, floating_point_exception_handler);
+ signal(SIGFPE, SIG_IGN);
+
+ memset(&parms, 0, sizeof(parms));
+
+ COM_InitArgv(c, v);
+ parms.argc = com_argc;
+ parms.argv = com_argv;
+
+ parms.memsize = 24*1024*1024;
+
+ j = COM_CheckParm("-mem");
+ if (j)
+ parms.memsize = (int) (atof(com_argv[j+1]) * 1024 * 1024);
+ parms.membase = malloc (parms.memsize);
+ if (!parms.membase)
+ {
+ printf("Unable to allocate heap memory\n");
+ return 1;
+ }
+
+ parms.basedir = basedir;
+// caching is disabled by default, use -cachedir to enable
+// parms.cachedir = cachedir;
+
+ fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
+
+ Host_Init(&parms);
+
+ Sys_Init();
+
+ if (COM_CheckParm("-nostdout"))
+ nostdout = 1;
+ else
+ {
+ fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
+ printf ("Linux DarkPlaces -- Version %0.3f\n", VERSION);
+ }
+
+ oldtime = Sys_FloatTime () - 0.1;
+ while (1)
+ {
+ // find time spent rendering last frame
+ newtime = Sys_FloatTime ();
+ time = newtime - oldtime;
+
+ if (cls.state == ca_dedicated)
+ { // play vcrfiles at max speed
+ if (time < sys_ticrate.value && (vcrFile == -1 || recording) )
+ {
+ usleep(1);
+ continue; // not time to run a server only tic yet
+ }
+ time = sys_ticrate.value;
+ }
+
+ if (time > sys_ticrate.value*2)
+ oldtime = newtime;
+ else
+ oldtime += time;
+
+ Host_Frame (time);
+
+ // graphic debugging aids
+ if (sys_linerefresh.value)
+ Sys_LineRefresh ();
+ }
+ return 0;
+}
+
+
+/*
+================
+Sys_MakeCodeWriteable
+================
+*/
+void Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length)
+{
+
+ int r;
+ unsigned long addr;
+ int psize = getpagesize();
+
+ addr = (startaddr & ~(psize-1)) - psize;
+
+// fprintf(stderr, "writable code %lx(%lx)-%lx, length=%lx\n", startaddr,
+// addr, startaddr+length, length);
+
+ r = mprotect((char*)addr, length + startaddr - addr + psize, 7);
+
+ if (r < 0)
+ Sys_Error("Protection change failed\n");
+
+}
+
{
int pos;
int end;
- int t;
-
- t = VID_ForceUnlockedAndReturnState ();
pos = ftell (f);
fseek (f, 0, SEEK_END);
end = ftell (f);
fseek (f, pos, SEEK_SET);
- VID_ForceLockState (t);
-
return end;
}
{
FILE *f;
int i, retval;
- int t;
-
- t = VID_ForceUnlockedAndReturnState ();
i = findhandle ();
retval = filelength(f);
}
- VID_ForceLockState (t);
-
return retval;
}
{
FILE *f;
int i;
- int t;
- t = VID_ForceUnlockedAndReturnState ();
-
i = findhandle ();
f = fopen(path, "wb");
Host_Error ("Error opening %s: %s", path,strerror(errno));
sys_handles[i] = f;
- VID_ForceLockState (t);
-
return i;
}
void Sys_FileClose (int handle)
{
- int t;
-
- t = VID_ForceUnlockedAndReturnState ();
fclose (sys_handles[handle]);
sys_handles[handle] = NULL;
- VID_ForceLockState (t);
}
void Sys_FileSeek (int handle, int position)
{
- int t;
-
- t = VID_ForceUnlockedAndReturnState ();
fseek (sys_handles[handle], position, SEEK_SET);
- VID_ForceLockState (t);
}
int Sys_FileRead (int handle, void *dest, int count)
{
- int t, x;
-
- t = VID_ForceUnlockedAndReturnState ();
- x = fread (dest, 1, count, sys_handles[handle]);
- VID_ForceLockState (t);
- return x;
+ return fread (dest, 1, count, sys_handles[handle]);
}
int Sys_FileWrite (int handle, void *data, int count)
{
- int t, x;
-
- t = VID_ForceUnlockedAndReturnState ();
- x = fwrite (data, 1, count, sys_handles[handle]);
- VID_ForceLockState (t);
- return x;
+ return fwrite (data, 1, count, sys_handles[handle]);
}
int Sys_FileTime (char *path)
{
FILE *f;
- int t, retval;
+ int retval;
- t = VID_ForceUnlockedAndReturnState ();
-
f = fopen(path, "rb");
if (f)
retval = -1;
}
- VID_ForceLockState (t);
return retval;
}
static int in_sys_error3 = 0;
if (!in_sys_error3)
- {
in_sys_error3 = 1;
- VID_ForceUnlockedAndReturnState ();
- }
va_start (argptr, error);
vsprintf (text, error, argptr);
void Sys_Quit (void)
{
- VID_ForceUnlockedAndReturnState ();
-
Host_Shutdown();
if (tevent)
void VID_Shutdown (void);
// Called at shutdown
-void VID_Update (vrect_t *rects);
-// flushes the given rectangles from the view buffer to the screen
-
int VID_SetMode (int modenum, unsigned char *palette);
// sets the mode; only used by the Quake engine for resetting to mode 0 (the
// base mode) on memory allocation failures
-
-void VID_HandlePause (qboolean pause);
-// called only on Win32, when pause happens, so the mouse can be released
-
--- /dev/null
+/*
+Copyright (C) 1996-1997 Id Software, Inc.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+#include <termios.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <sys/vt.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <signal.h>
+
+#include <dlfcn.h>
+
+#include "quakedef.h"
+
+#include <GL/glx.h>
+
+#include <X11/keysym.h>
+#include <X11/cursorfont.h>
+
+#include <X11/extensions/xf86dga.h>
+#include <X11/extensions/xf86vmode.h>
+
+#define WARP_WIDTH 320
+#define WARP_HEIGHT 200
+
+static Display *dpy = NULL;
+static int scrnum;
+static Window win;
+static GLXContext ctx = NULL;
+
+#define KEY_MASK (KeyPressMask | KeyReleaseMask)
+#define MOUSE_MASK (ButtonPressMask | ButtonReleaseMask | \
+ PointerMotionMask | ButtonMotionMask )
+#define X_MASK (KEY_MASK | MOUSE_MASK | VisibilityChangeMask | StructureNotifyMask )
+
+
+unsigned short d_8to16table[256];
+unsigned d_8to24table[256];
+unsigned char d_15to8table[65536];
+
+cvar_t vid_mode = {"vid_mode","0",false};
+
+viddef_t vid; // global video state
+
+static qboolean mouse_avail;
+static qboolean mouse_active;
+static int mx, my;
+static int old_mouse_x, old_mouse_y;
+
+static cvar_t in_mouse = {"in_mouse", "1", false};
+static cvar_t in_dgamouse = {"in_dgamouse", "1", false};
+static cvar_t m_filter = {"m_filter", "0"};
+
+qboolean dgamouse = false;
+qboolean vidmode_ext = false;
+
+static int win_x, win_y;
+
+static int scr_width, scr_height;
+
+static XF86VidModeModeInfo **vidmodes;
+//static int default_dotclock_vidmode;
+static int num_vidmodes;
+static qboolean vidmode_active = false;
+
+/*-----------------------------------------------------------------------*/
+
+//int texture_mode = GL_NEAREST;
+//int texture_mode = GL_NEAREST_MIPMAP_NEAREST;
+//int texture_mode = GL_NEAREST_MIPMAP_LINEAR;
+int texture_mode = GL_LINEAR;
+//int texture_mode = GL_LINEAR_MIPMAP_NEAREST;
+//int texture_mode = GL_LINEAR_MIPMAP_LINEAR;
+
+int texture_extension_number = 1;
+
+float gldepthmin, gldepthmax;
+
+const char *gl_vendor;
+const char *gl_renderer;
+const char *gl_version;
+const char *gl_extensions;
+
+void (*qglColorTableEXT) (int, int, int, int, int, const void*);
+void (*qgl3DfxSetPaletteEXT) (GLuint *);
+void (*qglMTexCoord2f) (GLenum, GLfloat, GLfloat);
+void (*qglSelectTexture) (GLenum);
+
+//static float vid_gamma = 1.0;
+
+// LordHavoc: ARB multitexture support
+int gl_mtex_enum = 0;
+
+// LordHavoc: in GLX these are never set, simply provided to make the rest of the code work
+qboolean is8bit = false;
+qboolean isPermedia = false;
+qboolean isATI = false;
+qboolean isG200 = false;
+qboolean isRagePro = false;
+qboolean gl_mtexable = false;
+qboolean gl_arrays = false;
+
+/*-----------------------------------------------------------------------*/
+void D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height)
+{
+}
+
+void D_EndDirectRect (int x, int y, int width, int height)
+{
+}
+
+static int XLateKey(XKeyEvent *ev)
+{
+
+ int key;
+ char buf[64];
+ KeySym keysym;
+
+ key = 0;
+
+ XLookupString(ev, buf, sizeof buf, &keysym, 0);
+
+ switch(keysym)
+ {
+ case XK_KP_Page_Up:
+ case XK_Page_Up: key = K_PGUP; break;
+
+ case XK_KP_Page_Down:
+ case XK_Page_Down: key = K_PGDN; break;
+
+ case XK_KP_Home:
+ case XK_Home: key = K_HOME; break;
+
+ case XK_KP_End:
+ case XK_End: key = K_END; break;
+
+ case XK_KP_Left:
+ case XK_Left: key = K_LEFTARROW; break;
+
+ case XK_KP_Right:
+ case XK_Right: key = K_RIGHTARROW; break;
+
+ case XK_KP_Down:
+ case XK_Down: key = K_DOWNARROW; break;
+
+ case XK_KP_Up:
+ case XK_Up: key = K_UPARROW; break;
+
+ case XK_Escape: key = K_ESCAPE; break;
+
+ case XK_KP_Enter:
+ case XK_Return: key = K_ENTER; break;
+
+ case XK_Tab: key = K_TAB; break;
+
+ case XK_F1: key = K_F1; break;
+
+ case XK_F2: key = K_F2; break;
+
+ case XK_F3: key = K_F3; break;
+
+ case XK_F4: key = K_F4; break;
+
+ case XK_F5: key = K_F5; break;
+
+ case XK_F6: key = K_F6; break;
+
+ case XK_F7: key = K_F7; break;
+
+ case XK_F8: key = K_F8; break;
+
+ case XK_F9: key = K_F9; break;
+
+ case XK_F10: key = K_F10; break;
+
+ case XK_F11: key = K_F11; break;
+
+ case XK_F12: key = K_F12; break;
+
+ case XK_BackSpace: key = K_BACKSPACE; break;
+
+ case XK_KP_Delete:
+ case XK_Delete: key = K_DEL; break;
+
+ case XK_Pause: key = K_PAUSE; break;
+
+ case XK_Shift_L:
+ case XK_Shift_R: key = K_SHIFT; break;
+
+ case XK_Execute:
+ case XK_Control_L:
+ case XK_Control_R: key = K_CTRL; break;
+
+ case XK_Alt_L:
+ case XK_Meta_L:
+ case XK_Alt_R:
+ case XK_Meta_R: key = K_ALT; break;
+
+ case XK_KP_Begin: key = '5'; break;
+
+ case XK_KP_Insert:
+ case XK_Insert:key = K_INS; break;
+
+ case XK_KP_Multiply: key = '*'; break;
+ case XK_KP_Add: key = '+'; break;
+ case XK_KP_Subtract: key = '-'; break;
+ case XK_KP_Divide: key = '/'; break;
+
+#if 0
+ case 0x021: key = '1';break;/* [!] */
+ case 0x040: key = '2';break;/* [@] */
+ case 0x023: key = '3';break;/* [#] */
+ case 0x024: key = '4';break;/* [$] */
+ case 0x025: key = '5';break;/* [%] */
+ case 0x05e: key = '6';break;/* [^] */
+ case 0x026: key = '7';break;/* [&] */
+ case 0x02a: key = '8';break;/* [*] */
+ case 0x028: key = '9';;break;/* [(] */
+ case 0x029: key = '0';break;/* [)] */
+ case 0x05f: key = '-';break;/* [_] */
+ case 0x02b: key = '=';break;/* [+] */
+ case 0x07c: key = '\'';break;/* [|] */
+ case 0x07d: key = '[';break;/* [}] */
+ case 0x07b: key = ']';break;/* [{] */
+ case 0x022: key = '\'';break;/* ["] */
+ case 0x03a: key = ';';break;/* [:] */
+ case 0x03f: key = '/';break;/* [?] */
+ case 0x03e: key = '.';break;/* [>] */
+ case 0x03c: key = ',';break;/* [<] */
+#endif
+
+ default:
+ key = *(unsigned char*)buf;
+ if (key >= 'A' && key <= 'Z')
+ key = key - 'A' + 'a';
+ break;
+ }
+
+ return key;
+}
+
+static Cursor CreateNullCursor(Display *display, Window root)
+{
+ Pixmap cursormask;
+ XGCValues xgc;
+ GC gc;
+ XColor dummycolour;
+ Cursor cursor;
+
+ cursormask = XCreatePixmap(display, root, 1, 1, 1/*depth*/);
+ xgc.function = GXclear;
+ gc = XCreateGC(display, cursormask, GCFunction, &xgc);
+ XFillRectangle(display, cursormask, gc, 0, 0, 1, 1);
+ dummycolour.pixel = 0;
+ dummycolour.red = 0;
+ dummycolour.flags = 04;
+ cursor = XCreatePixmapCursor(display, cursormask, cursormask,
+ &dummycolour,&dummycolour, 0,0);
+ XFreePixmap(display,cursormask);
+ XFreeGC(display,gc);
+ return cursor;
+}
+
+static void install_grabs(void)
+{
+
+// inviso cursor
+ XDefineCursor(dpy, win, CreateNullCursor(dpy, win));
+
+ XGrabPointer(dpy, win,
+ True,
+ 0,
+ GrabModeAsync, GrabModeAsync,
+ win,
+ None,
+ CurrentTime);
+
+ if (in_dgamouse.value) {
+ int MajorVersion, MinorVersion;
+
+ if (!XF86DGAQueryVersion(dpy, &MajorVersion, &MinorVersion)) {
+ // unable to query, probalby not supported
+ Con_Printf( "Failed to detect XF86DGA Mouse\n" );
+ in_dgamouse.value = 0;
+ } else {
+ dgamouse = true;
+ XF86DGADirectVideo(dpy, DefaultScreen(dpy), XF86DGADirectMouse);
+ XWarpPointer(dpy, None, win, 0, 0, 0, 0, 0, 0);
+ }
+ } else {
+ XWarpPointer(dpy, None, win,
+ 0, 0, 0, 0,
+ vid.width / 2, vid.height / 2);
+ }
+
+ XGrabKeyboard(dpy, win,
+ False,
+ GrabModeAsync, GrabModeAsync,
+ CurrentTime);
+
+ mouse_active = true;
+
+// XSync(dpy, True);
+}
+
+static void uninstall_grabs(void)
+{
+ if (!dpy || !win)
+ return;
+
+ if (dgamouse) {
+ dgamouse = false;
+ XF86DGADirectVideo(dpy, DefaultScreen(dpy), 0);
+ }
+
+ XUngrabPointer(dpy, CurrentTime);
+ XUngrabKeyboard(dpy, CurrentTime);
+
+// inviso cursor
+ XUndefineCursor(dpy, win);
+
+ mouse_active = false;
+}
+
+static void HandleEvents(void)
+{
+ XEvent event;
+// KeySym ks;
+ int b;
+ qboolean dowarp = false;
+ int mwx = vid.width/2;
+ int mwy = vid.height/2;
+
+ if (!dpy)
+ return;
+
+ while (XPending(dpy)) {
+ XNextEvent(dpy, &event);
+
+ switch (event.type) {
+ case KeyPress:
+ case KeyRelease:
+ Key_Event(XLateKey(&event.xkey), event.type == KeyPress);
+ break;
+
+ case MotionNotify:
+ if (mouse_active) {
+ if (dgamouse) {
+ mx += (event.xmotion.x + win_x) * 2;
+ my += (event.xmotion.y + win_y) * 2;
+ }
+ else
+ {
+ mx += ((int)event.xmotion.x - mwx) * 2;
+ my += ((int)event.xmotion.y - mwy) * 2;
+ mwx = event.xmotion.x;
+ mwy = event.xmotion.y;
+
+ if (mx || my)
+ dowarp = true;
+ }
+ }
+ break;
+
+ break;
+
+ case ButtonPress:
+ b=-1;
+ if (event.xbutton.button == 1)
+ b = 0;
+ else if (event.xbutton.button == 2)
+ b = 2;
+ else if (event.xbutton.button == 3)
+ b = 1;
+ if (b>=0)
+ Key_Event(K_MOUSE1 + b, true);
+ break;
+
+ case ButtonRelease:
+ b=-1;
+ if (event.xbutton.button == 1)
+ b = 0;
+ else if (event.xbutton.button == 2)
+ b = 2;
+ else if (event.xbutton.button == 3)
+ b = 1;
+ if (b>=0)
+ Key_Event(K_MOUSE1 + b, false);
+ break;
+
+ case CreateNotify :
+ win_x = event.xcreatewindow.x;
+ win_y = event.xcreatewindow.y;
+ break;
+
+ case ConfigureNotify :
+ win_x = event.xconfigure.x;
+ win_y = event.xconfigure.y;
+ break;
+ }
+ }
+
+ if (dowarp) {
+ /* move the mouse to the window center again */
+ XWarpPointer(dpy, None, win, 0, 0, 0, 0, vid.width / 2, vid.height / 2);
+ }
+
+}
+
+static void IN_DeactivateMouse( void )
+{
+ if (!mouse_avail || !dpy || !win)
+ return;
+
+ if (mouse_active) {
+ uninstall_grabs();
+ mouse_active = false;
+ }
+}
+
+static void IN_ActivateMouse( void )
+{
+ if (!mouse_avail || !dpy || !win)
+ return;
+
+ if (!mouse_active) {
+ mx = my = 0; // don't spazz
+ install_grabs();
+ mouse_active = true;
+ }
+}
+
+
+void VID_Shutdown(void)
+{
+ if (!ctx || !dpy)
+ return;
+ IN_DeactivateMouse();
+ if (dpy) {
+ if (ctx)
+ glXDestroyContext(dpy, ctx);
+ if (win)
+ XDestroyWindow(dpy, win);
+ if (vidmode_active)
+ XF86VidModeSwitchToMode(dpy, scrnum, vidmodes[0]);
+ XCloseDisplay(dpy);
+ }
+ vidmode_active = false;
+ dpy = NULL;
+ win = 0;
+ ctx = NULL;
+}
+
+void signal_handler(int sig)
+{
+ printf("Received signal %d, exiting...\n", sig);
+ Sys_Quit();
+ exit(0);
+}
+
+void InitSig(void)
+{
+ signal(SIGHUP, signal_handler);
+ signal(SIGINT, signal_handler);
+ signal(SIGQUIT, signal_handler);
+ signal(SIGILL, signal_handler);
+ signal(SIGTRAP, signal_handler);
+ signal(SIGIOT, signal_handler);
+ signal(SIGBUS, signal_handler);
+ signal(SIGFPE, signal_handler);
+ signal(SIGSEGV, signal_handler);
+ signal(SIGTERM, signal_handler);
+}
+
+/*
+void (*qglVertexPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
+void (*qglColorPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
+void (*qglTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
+void (*qglArrayElement)(GLint i);
+void (*qglDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
+void (*qglMTexCoord2f)(GLenum, GLfloat, GLfloat);
+void (*qglSelectTexture)(GLenum);
+void (*glColorTableEXT)(int, int, int, int, int, const void*);
+
+void CheckVertexArrays (void)
+{
+ void *prjobj;
+ if (COM_CheckParm("-novertex"))
+ {
+ Con_Printf("...vertex array support disabled\n");
+ return;
+ }
+ if ((prjobj = dlopen(NULL, RTLD_LAZY)) == NULL)
+ {
+ Con_Printf("Unable to open symbol list for main program.\n");
+ return;
+ }
+ qglMTexCoord2fSGIS = (void *) dlsym(prjobj, "glMTexCoord2fSGIS");
+ if ((qglArrayElement = (void *) dlsym(prjobj, "glArrayElement"))
+ && (qglColorPointer = (void *) dlsym(prjobj, "glColorPointer"))
+// && (qglDrawArrays = (void *) dlsym(prjobj, "glDrawArrays"))
+ && (qglDrawElements = (void *) dlsym(prjobj, "glDrawElements"))
+// && (qglInterleavedArrays = (void *) dlsym(prjobj, "glInterleavedArrays"))
+ && (qglTexCoordPointer = (void *) dlsym(prjobj, "glTexCoordPointer"))
+ && (qglVertexPointer = (void *) dlsym(prjobj, "glVertexPointer"))
+ )
+ {
+ Con_Printf("...vertex array support detected\n");
+ gl_arrays = true;
+ dlclose(prjobj);
+ return;
+ }
+
+ Con_Printf("...vertex array support disabled (not detected - get a better driver)\n");
+ dlclose(prjobj);
+}
+*/
+
+void CheckMultiTexture(void)
+{
+ void *prjobj;
+ qglMTexCoord2f = NULL;
+ qglSelectTexture = NULL;
+ // Check to see if multitexture is disabled
+ if (COM_CheckParm("-nomtex"))
+ {
+ Con_Printf("...multitexture disabled\n");
+ return;
+ }
+ if ((prjobj = dlopen(NULL, RTLD_LAZY)) == NULL)
+ {
+ Con_Printf("Unable to open symbol list for main program.\n");
+ return;
+ }
+ // Test for ARB_multitexture
+ if (!COM_CheckParm("-SGISmtex") && strstr(gl_extensions, "GL_ARB_multitexture "))
+ {
+ Con_Printf("...using GL_ARB_multitexture\n");
+ qglMTexCoord2f = (void *) dlsym(prjobj, "glMultiTexCoord2fARB");
+ qglSelectTexture = (void *) dlsym(prjobj, "glActiveTextureARB");
+ gl_mtexable = true;
+ gl_mtex_enum = GL_TEXTURE0_ARB;
+ }
+ else if (strstr(gl_extensions, "GL_SGIS_multitexture ")) // Test for SGIS_multitexture (if ARB_multitexture not found)
+ {
+ Con_Printf("...using GL_SGIS_multitexture\n");
+ qglMTexCoord2f = (void *) dlsym(prjobj, "glMTexCoord2fSGIS");
+ qglSelectTexture = (void *) dlsym(prjobj, "glSelectTextureSGIS");
+ gl_mtexable = true;
+ gl_mtex_enum = TEXTURE0_SGIS;
+ }
+ if (!gl_mtexable)
+ Con_Printf("...multitexture disabled (not detected)\n");
+ dlclose(prjobj);
+}
+
+/*
+===============
+GL_Init
+===============
+*/
+extern char *QSG_EXTENSIONS;
+void GL_Init (void)
+{
+ gl_vendor = glGetString (GL_VENDOR);
+ Con_Printf ("GL_VENDOR: %s\n", gl_vendor);
+ gl_renderer = glGetString (GL_RENDERER);
+ Con_Printf ("GL_RENDERER: %s\n", gl_renderer);
+
+ gl_version = glGetString (GL_VERSION);
+ Con_Printf ("GL_VERSION: %s\n", gl_version);
+ gl_extensions = glGetString (GL_EXTENSIONS);
+ Con_Printf ("GL_EXTENSIONS: %s\n", gl_extensions);
+
+// Con_Printf ("%s %s\n", gl_renderer, gl_version);
+
+ CheckMultiTexture();
+// CheckVertexArrays();
+
+ // LordHavoc: report supported extensions
+ Con_Printf ("\nQSG extensions: %s\n", QSG_EXTENSIONS);
+
+// glClearColor (1,0,0,0);
+ glCullFace(GL_FRONT);
+// glEnable(GL_TEXTURE_2D);
+//
+// glEnable(GL_ALPHA_TEST);
+ glAlphaFunc(GL_GREATER, 0.5);
+//
+// glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
+// glShadeModel (GL_FLAT);
+//
+// glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+// glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+// glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+// glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+//
+// glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+//
+// glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+// glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+}
+
+/*
+=================
+GL_BeginRendering
+
+=================
+*/
+void GL_BeginRendering (int *x, int *y, int *width, int *height)
+{
+ *x = *y = 0;
+ *width = scr_width;
+ *height = scr_height;
+
+// if (!wglMakeCurrent( maindc, baseRC ))
+// Sys_Error ("wglMakeCurrent failed");
+
+// glViewport (*x, *y, *width, *height);
+}
+
+
+void GL_EndRendering (void)
+{
+ glFlush();
+ glXSwapBuffers(dpy, win);
+}
+
+qboolean VID_Is8bit(void)
+{
+ return is8bit;
+}
+
+void VID_Init8bitPalette(void)
+{
+ // Check for 8bit Extensions and initialize them.
+ int i;
+ void *prjobj;
+
+ if (!COM_CheckParm("-8bit"))
+ return;
+ if ((prjobj = dlopen(NULL, RTLD_LAZY)) == NULL)
+ {
+ Con_Printf("Unable to open symbol list for main program.\n");
+ return;
+ }
+
+ if (strstr(gl_extensions, "3DFX_set_global_palette") && (qgl3DfxSetPaletteEXT = dlsym(prjobj, "gl3DfxSetPaletteEXT")) != NULL)
+ {
+ GLubyte table[256][4];
+ char *oldpal;
+
+ Con_SafePrintf("8-bit GL extensions enabled.\n");
+ glEnable( GL_SHARED_TEXTURE_PALETTE_EXT );
+ oldpal = (char *) d_8to24table; //d_8to24table3dfx;
+ for (i=0;i<256;i++)
+ {
+ table[i][2] = *oldpal++;
+ table[i][1] = *oldpal++;
+ table[i][0] = *oldpal++;
+ table[i][3] = 255;
+ oldpal++;
+ }
+ qgl3DfxSetPaletteEXT((GLuint *)table);
+ is8bit = true;
+
+ }
+ else if (strstr(gl_extensions, "GL_EXT_shared_texture_palette") && (qglColorTableEXT = dlsym(prjobj, "glColorTableEXT")) != NULL)
+ {
+ char thePalette[256*3];
+ char *oldPalette, *newPalette;
+
+ Con_SafePrintf("8-bit GL extensions enabled.\n");
+ glEnable( GL_SHARED_TEXTURE_PALETTE_EXT );
+ oldPalette = (char *) d_8to24table; //d_8to24table3dfx;
+ newPalette = thePalette;
+ for (i=0;i<256;i++)
+ {
+ *newPalette++ = *oldPalette++;
+ *newPalette++ = *oldPalette++;
+ *newPalette++ = *oldPalette++;
+ oldPalette++;
+ }
+ qglColorTableEXT(GL_SHARED_TEXTURE_PALETTE_EXT, GL_RGB, 256, GL_RGB, GL_UNSIGNED_BYTE, (void *) thePalette);
+ is8bit = true;
+ }
+
+ dlclose(prjobj);
+}
+
+extern void Check_Gamma (unsigned char *pal);
+void VID_Setup15to8Palette ();
+
+void VID_Init(unsigned char *palette)
+{
+ int i;
+ int attrib[] = {
+ GLX_RGBA,
+ GLX_RED_SIZE, 1,
+ GLX_GREEN_SIZE, 1,
+ GLX_BLUE_SIZE, 1,
+ GLX_DOUBLEBUFFER,
+ GLX_DEPTH_SIZE, 1,
+ None
+ };
+// char gldir[MAX_OSPATH];
+ int width = 640, height = 480;
+ XSetWindowAttributes attr;
+ unsigned long mask;
+ Window root;
+ XVisualInfo *visinfo;
+ qboolean fullscreen = true;
+ int MajorVersion, MinorVersion;
+ int actualWidth, actualHeight;
+
+ Cvar_RegisterVariable (&vid_mode);
+ Cvar_RegisterVariable (&in_mouse);
+ Cvar_RegisterVariable (&in_dgamouse);
+ Cvar_RegisterVariable (&m_filter);
+
+ vid.maxwarpwidth = WARP_WIDTH;
+ vid.maxwarpheight = WARP_HEIGHT;
+ vid.colormap = host_colormap;
+ vid.fullbright = 256 - LittleLong (*((int *)vid.colormap + 2048));
+
+// interpret command-line params
+
+// set vid parameters
+ if ((i = COM_CheckParm("-window")) != 0)
+ fullscreen = false;
+
+ if ((i = COM_CheckParm("-width")) != 0)
+ width = atoi(com_argv[i+1]);
+
+ if ((i = COM_CheckParm("-height")) != 0)
+ height = atoi(com_argv[i+1]);
+
+ if ((i = COM_CheckParm("-conwidth")) != 0)
+ vid.conwidth = atoi(com_argv[i+1]);
+ else
+ vid.conwidth = 640;
+
+ vid.conwidth &= 0xfff8; // make it a multiple of eight
+
+ if (vid.conwidth < 320)
+ vid.conwidth = 320;
+
+ // pick a conheight that matches with correct aspect
+ vid.conheight = vid.conwidth*3 / 4;
+
+ if ((i = COM_CheckParm("-conheight")) != 0)
+ vid.conheight = atoi(com_argv[i+1]);
+ if (vid.conheight < 200)
+ vid.conheight = 200;
+
+ if (!(dpy = XOpenDisplay(NULL))) {
+ fprintf(stderr, "Error couldn't open the X display\n");
+ exit(1);
+ }
+
+ scrnum = DefaultScreen(dpy);
+ root = RootWindow(dpy, scrnum);
+
+ // Get video mode list
+ MajorVersion = MinorVersion = 0;
+ if (!XF86VidModeQueryVersion(dpy, &MajorVersion, &MinorVersion)) {
+ vidmode_ext = false;
+ } else {
+ Con_Printf("Using XFree86-VidModeExtension Version %d.%d\n", MajorVersion, MinorVersion);
+ vidmode_ext = true;
+ }
+
+ visinfo = glXChooseVisual(dpy, scrnum, attrib);
+ if (!visinfo) {
+ fprintf(stderr, "qkHack: Error couldn't get an RGB, Double-buffered, Depth visual\n");
+ exit(1);
+ }
+
+ if (vidmode_ext) {
+ int best_fit, best_dist, dist, x, y;
+
+ XF86VidModeGetAllModeLines(dpy, scrnum, &num_vidmodes, &vidmodes);
+
+ // Are we going fullscreen? If so, let's change video mode
+ if (fullscreen) {
+ best_dist = 9999999;
+ best_fit = -1;
+
+ for (i = 0; i < num_vidmodes; i++) {
+ if (width > vidmodes[i]->hdisplay ||
+ height > vidmodes[i]->vdisplay)
+ continue;
+
+ x = width - vidmodes[i]->hdisplay;
+ y = height - vidmodes[i]->vdisplay;
+ dist = (x * x) + (y * y);
+ if (dist < best_dist) {
+ best_dist = dist;
+ best_fit = i;
+ }
+ }
+
+ if (best_fit != -1) {
+ actualWidth = vidmodes[best_fit]->hdisplay;
+ actualHeight = vidmodes[best_fit]->vdisplay;
+
+ // change to the mode
+ XF86VidModeSwitchToMode(dpy, scrnum, vidmodes[best_fit]);
+ vidmode_active = true;
+
+ // Move the viewport to top left
+ XF86VidModeSetViewPort(dpy, scrnum, 0, 0);
+ } else
+ fullscreen = 0;
+ }
+ }
+
+ /* window attributes */
+ attr.background_pixel = 0;
+ attr.border_pixel = 0;
+ attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
+ attr.event_mask = X_MASK;
+ if (vidmode_active) {
+ mask = CWBackPixel | CWColormap | CWSaveUnder | CWBackingStore |
+ CWEventMask | CWOverrideRedirect;
+ attr.override_redirect = True;
+ attr.backing_store = NotUseful;
+ attr.save_under = False;
+ } else
+ mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
+
+ win = XCreateWindow(dpy, root, 0, 0, width, height,
+ 0, visinfo->depth, InputOutput,
+ visinfo->visual, mask, &attr);
+ XMapWindow(dpy, win);
+
+ if (vidmode_active) {
+ XMoveWindow(dpy, win, 0, 0);
+ XRaiseWindow(dpy, win);
+ XWarpPointer(dpy, None, win, 0, 0, 0, 0, 0, 0);
+ XFlush(dpy);
+ // Move the viewport to top left
+ XF86VidModeSetViewPort(dpy, scrnum, 0, 0);
+ }
+
+ XFlush(dpy);
+
+ ctx = glXCreateContext(dpy, visinfo, NULL, True);
+
+ glXMakeCurrent(dpy, win, ctx);
+
+ scr_width = width;
+ scr_height = height;
+
+ if (vid.conheight > height)
+ vid.conheight = height;
+ if (vid.conwidth > width)
+ vid.conwidth = width;
+ vid.width = vid.conwidth;
+ vid.height = vid.conheight;
+
+ vid.aspect = ((float)vid.height / (float)vid.width) * (320.0 / 240.0);
+ vid.numpages = 2;
+
+ InitSig(); // trap evil signals
+
+ GL_Init();
+
+// sprintf (gldir, "%s/glquake", com_gamedir);
+// Sys_mkdir (gldir);
+
+ VID_SetPalette(palette);
+
+ Check_Gamma(palette);
+
+ VID_Init8bitPalette();
+
+ if (is8bit) // LordHavoc: avoid calculating 15to8 table if it won't be used
+ VID_Setup15to8Palette ();
+
+ Con_SafePrintf ("Video mode %dx%d initialized.\n", width, height);
+
+ vid.recalc_refdef = 1; // force a surface cache flush
+}
+
+void Sys_SendKeyEvents(void)
+{
+ HandleEvents();
+}
+
+void Force_CenterView_f (void)
+{
+ cl.viewangles[PITCH] = 0;
+}
+
+void IN_Init(void)
+{
+}
+
+void IN_Shutdown(void)
+{
+}
+
+/*
+===========
+IN_Commands
+===========
+*/
+void IN_Commands (void)
+{
+ if (!dpy || !win)
+ return;
+
+ if (vidmode_active || key_dest == key_game)
+ IN_ActivateMouse();
+ else
+ IN_DeactivateMouse ();
+}
+
+/*
+===========
+IN_Move
+===========
+*/
+void IN_MouseMove (usercmd_t *cmd)
+{
+ if (!mouse_avail)
+ return;
+
+ if (m_filter.value)
+ {
+ mx = (mx + old_mouse_x) * 0.5;
+ my = (my + old_mouse_y) * 0.5;
+ }
+ old_mouse_x = mx;
+ old_mouse_y = my;
+
+ mx *= sensitivity.value;
+ my *= sensitivity.value;
+
+// add mouse X/Y movement to cmd
+ if ( (in_strafe.state & 1) || (lookstrafe.value && (in_mlook.state & 1) ))
+ cmd->sidemove += m_side.value * mx;
+ else
+ cl.viewangles[YAW] -= m_yaw.value * mx;
+
+ if (in_mlook.state & 1)
+ V_StopPitchDrift ();
+
+ if ( (in_mlook.state & 1) && !(in_strafe.state & 1))
+ {
+ cl.viewangles[PITCH] += m_pitch.value * my;
+ if (cl.viewangles[PITCH] > 80)
+ cl.viewangles[PITCH] = 80;
+ if (cl.viewangles[PITCH] < -70)
+ cl.viewangles[PITCH] = -70;
+ }
+ else
+ {
+ if ((in_strafe.state & 1) && noclip_anglehack)
+ cmd->upmove -= m_forward.value * my;
+ else
+ cmd->forwardmove -= m_forward.value * my;
+ }
+ mx = my = 0;
+}
+
+void IN_Move (usercmd_t *cmd)
+{
+ IN_MouseMove(cmd);
+}
+
+
#include "quakedef.h"
-unsigned d_8to24table[256];
+unsigned d_8to24table[256];
unsigned char d_15to8table[32768]; // LordHavoc: was 64k elements, now 32k like it should be
void VID_SetPalette (unsigned char *palette)
}
// LordHavoc: gamma correction does not belong in gl_vidnt.c
-byte gamma[256];
+byte qgamma[256];
static float vid_gamma = 1.0;
void Check_Gamma (unsigned char *pal)
float inf;
int i;
- if (i = COM_CheckParm("-gamma"))
+ if ((i = COM_CheckParm("-gamma")))
vid_gamma = atof(com_argv[i+1]);
else
{
if (vid_gamma == 1) // LordHavoc: dodge the math
{
for (i = 0;i < 256;i++)
- gamma[i] = i;
+ qgamma[i] = i;
}
else
{
inf = pow((i+1)/256.0, vid_gamma)*255 + 0.5;
if (inf < 0) inf = 0;
if (inf > 255) inf = 255;
- gamma[i] = inf;
+ qgamma[i] = inf;
}
}
// gamma correct the palette
for (i=0 ; i<768 ; i++)
- pal[i] = gamma[pal[i]];
+ pal[i] = qgamma[pal[i]];
// note: 32bit uploads are corrected by the upload functions
}
// direct draw software compatability stuff
-void VID_HandlePause (qboolean pause)
-{
-}
-
-void VID_ForceLockState (int lk)
-{
-}
-
-void VID_LockBuffer (void)
-{
-}
-
-void VID_UnlockBuffer (void)
-{
-}
-
-int VID_ForceUnlockedAndReturnState (void)
-{
- return 0;
-}
-
void CenterWindow(HWND hWndCenter, int width, int height, BOOL lefttopjustify)
{
int CenterX, CenterY;
// Con_Printf ("%s %s\n", gl_renderer, gl_version);
- if (strnicmp(gl_renderer,"Permedia",8)==0)
- isPermedia = true;
+ if (strncasecmp(gl_renderer,"Permedia",8)==0)
+ isPermedia = true;
// LordHavoc: special differences for ATI (broken 8bit color when also using 32bit? weird!)
- if (strnicmp(gl_vendor,"ATI",3)==0)
+ if (strncasecmp(gl_vendor,"ATI",3)==0)
{
isATI = true;
- if (strnicmp(gl_renderer,"Rage Pro",8)==0)
+ if (strncasecmp(gl_renderer,"Rage Pro",8)==0)
isRagePro = true;
}
- if (strnicmp(gl_renderer,"Matrox G200 Direct3D",20)==0) // a D3D driver for GL? sigh...
+ if (strncasecmp(gl_renderer,"Matrox G200 Direct3D",20)==0) // a D3D driver for GL? sigh...
isG200 = true;
CheckMultiTexture ();
char thePalette[256*3];
char *oldPalette, *newPalette;
// LordHavoc: 8bit texture support broke many things... it now must be specifically stated on the commandline (-no8bit became -8bit)
- if (!COM_CheckParm("-8bit"))
+ if (!COM_CheckParm("-8bit"))
return;
- if (strstr(gl_extensions, "GL_EXT_shared_texture_palette"))
+ if (strstr(gl_extensions, "GL_EXT_shared_texture_palette"))
return;
- if (!(glColorTableEXT = (void *)wglGetProcAddress("glColorTableEXT")))
+ if (!(glColorTableEXT = (void *)wglGetProcAddress("glColorTableEXT")))
return;
Con_SafePrintf("8-bit GL extensions enabled.\n");
- glEnable( GL_SHARED_TEXTURE_PALETTE_EXT );
+ glEnable( GL_SHARED_TEXTURE_PALETTE_EXT );
oldPalette = (char *) d_8to24table;
newPalette = thePalette;
for (i=0;i<256;i++)
VID_SetMode (vid_default, palette);
- maindc = GetDC(mainwindow);
+ maindc = GetDC(mainwindow);
bSetupPixelFormat(maindc);
- baseRC = wglCreateContext( maindc );
+ baseRC = wglCreateContext( maindc );
if (!baseRC)
Sys_Error ("Could not initialize GL (wglCreateContext failed).\n\nMake sure you are in 65536 color mode, and try running -window.");
- if (!wglMakeCurrent( maindc, baseRC ))
+ if (!wglMakeCurrent( maindc, baseRC ))
Sys_Error ("wglMakeCurrent failed");
GL_Init ();
void SwapPic (qpic_t *pic);
// LordHavoc: added alternate texture WAD2/WAD3 system for easier loading of HalfLife texture wads
-extern image_width, image_height;
+extern int image_width, image_height;
void W_LoadTextureWadFile (char *filename, int complain);
byte *W_GetTexture (char *name, int matchwidth, int matchheight); // returns malloc'd image data, width and height are in image_width and image_height (yeah yeah so I'm lazy...)
extern qboolean WinNT;
-int VID_ForceUnlockedAndReturnState (void);
-void VID_ForceLockState (int lk);
-
void IN_ShowMouse (void);
void IN_DeactivateMouse (void);
void IN_HideMouse (void);
===============================================================================
*/
-#if !id386
-
-/*
-==================
-SV_HullPointContents
-
-==================
-*/
-int SV_HullPointContents (hull_t *hull, int num, vec3_t p)
-{
- dclipnode_t *node;
- mplane_t *plane;
-
- while (num >= 0)
- {
- if (num < hull->firstclipnode || num > hull->lastclipnode)
- Sys_Error ("SV_HullPointContents: bad node number");
-
- node = hull->clipnodes + num;
- plane = hull->planes + node->planenum;
-
-// LordHavoc: optimized this slightly (probably no actual impact due to compiler optimization)
- if (plane->type < 3)
- num = node->children[p[plane->type] < plane->dist];
- else
- num = node->children[DotProduct (plane->normal, p) < plane->dist];
- }
-
- return num;
-}
-
-#endif // !id386
-
+// SV_HullPointContents moved to cpu_noasm.c
/*
============