//==========================================================================
-cvar_t cl_upspeed = {"cl_upspeed","200"};
-cvar_t cl_forwardspeed = {"cl_forwardspeed","200", true};
-cvar_t cl_backspeed = {"cl_backspeed","200", true};
-cvar_t cl_sidespeed = {"cl_sidespeed","350"};
+cvar_t cl_upspeed = {"cl_upspeed","200"};
+cvar_t cl_forwardspeed = {"cl_forwardspeed","200", true};
+cvar_t cl_backspeed = {"cl_backspeed","200", true};
+cvar_t cl_sidespeed = {"cl_sidespeed","350"};
-cvar_t cl_movespeedkey = {"cl_movespeedkey","2.0"};
+cvar_t cl_movespeedkey = {"cl_movespeedkey","2.0"};
-cvar_t cl_yawspeed = {"cl_yawspeed","140"};
-cvar_t cl_pitchspeed = {"cl_pitchspeed","150"};
+cvar_t cl_yawspeed = {"cl_yawspeed","140"};
+cvar_t cl_pitchspeed = {"cl_pitchspeed","150"};
-cvar_t cl_anglespeedkey = {"cl_anglespeedkey","1.5"};
+cvar_t cl_anglespeedkey = {"cl_anglespeedkey","1.5"};
/*
cvar_t m_forward = {"m_forward","1", true};
cvar_t m_side = {"m_side","0.8", true};
+cvar_t freelook = {"freelook", "1", true};
+
+cvar_t demo_nehahra = {"demo_nehahra", "0"};
client_static_t cls;
client_state_t cl;
// FIXME: put these on hunk?
-//efrag_t cl_efrags[MAX_EFRAGS];
entity_t cl_entities[MAX_EDICTS];
entity_t cl_static_entities[MAX_STATIC_ENTITIES];
lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
SZ_Clear (&cls.message);
// clear other arrays
-// memset (cl_efrags, 0, sizeof(cl_efrags));
memset (cl_entities, 0, sizeof(cl_entities));
memset (cl_dlights, 0, sizeof(cl_dlights));
memset (cl_lightstyle, 0, sizeof(cl_lightstyle));
// LordHavoc: have to set up the baseline info for alpha and other stuff
for (i = 0;i < MAX_EDICTS;i++)
{
- cl_entities[i].state_baseline.alpha = 255;
- cl_entities[i].state_baseline.scale = 16;
- cl_entities[i].state_baseline.glowsize = 0;
- cl_entities[i].state_baseline.glowcolor = 254;
- cl_entities[i].state_baseline.colormod = 255;
+ ClearStateToDefault(&cl_entities[i].state_baseline);
+ ClearStateToDefault(&cl_entities[i].state_previous);
+ ClearStateToDefault(&cl_entities[i].state_current);
}
-
-////
-//// allocate the efrags and chain together into a free list
-////
-// cl.free_efrags = cl_efrags;
-// for (i=0 ; i<MAX_EFRAGS-1 ; i++)
-// cl.free_efrags[i].entnext = &cl.free_efrags[i+1];
-// cl.free_efrags[i].entnext = NULL;
}
/*
CL_AllocDlight (ent, ent->render.origin, dlightradius, dlightcolor[0] * d, dlightcolor[1] * d, dlightcolor[2] * d, 0, 0);
}
- if (i == cl.viewentity && !chase_active.value)
+ if (!chase_active.value && ((i == cl.viewentity) || (ent->render.flags & RENDER_EXTERIORMODEL)))
continue;
if (ent->render.model == NULL)
fog_blue = atof(Cmd_Argv(4));
}
-cvar_t demo_nehahra = {"demo_nehahra", "0"};
-
/*
=================
CL_Init
Cvar_RegisterVariable (&lookspring);
Cvar_RegisterVariable (&lookstrafe);
Cvar_RegisterVariable (&sensitivity);
+ Cvar_RegisterVariable (&freelook);
Cvar_RegisterVariable (&m_pitch);
Cvar_RegisterVariable (&m_yaw);
// Cvar_RegisterVariable (&cl_autofire);
Cmd_AddCommand ("entities", CL_PrintEntities_f);
+ Cmd_AddCommand ("bitprofile", CL_BitProfile_f);
Cmd_AddCommand ("disconnect", CL_Disconnect_f);
Cmd_AddCommand ("record", CL_Record_f);
Cmd_AddCommand ("stop", CL_Stop_f);
"", // 50
"svc_fog", // 51
"svc_effect", // [vector] org [byte] modelindex [byte] startframe [byte] framecount [byte] framerate
- "svc_effect2", // [vector] org [short] modelindex [byte] startframe [byte] framecount [byte] framerate
+ "svc_effect2", // [vector] org [short] modelindex [short] startframe [byte] framecount [byte] framerate
};
//=============================================================================
memcpy (net_message.data, olddata, net_message.cursize);
// check time
- time = Sys_FloatTime ();
+ time = Sys_DoubleTime ();
if (time - lastmsg < 5)
return;
lastmsg = time;
==================
*/
byte entkill[MAX_EDICTS];
+int bitprofile[32], bitprofilecount = 0;
void CL_ParseUpdate (int bits)
{
- int num, deltadie;
+ int i, num, deltadie;
entity_t *ent;
if (cls.signon == SIGNONS - 1)
ent = CL_EntityNum (num);
+ for (i = 0;i < 32;i++)
+ if (bits & (1 << i))
+ bitprofile[i]++;
+ bitprofilecount++;
+
ent->state_previous = ent->state_current;
deltadie = false;
if (bits & U_DELTA)
if (bits & U_FRAME2) ent->state_current.frame = (ent->state_current.frame & 0x00FF) | (MSG_ReadByte() << 8);
if (bits & U_MODEL2) ent->state_current.modelindex = (ent->state_current.modelindex & 0x00FF) | (MSG_ReadByte() << 8);
if (bits & U_VIEWMODEL) ent->state_current.flags |= RENDER_VIEWMODEL;
+ if (bits & U_EXTERIORMODEL) ent->state_current.flags |= RENDER_EXTERIORMODEL;
// LordHavoc: to allow playback of the Nehahra movie
if (Nehahrademcompatibility && (bits & U_EXTEND1))
}
}
-void CL_EntityUpdateSetup()
+char *bitprofilenames[32] =
{
- memset(entkill, 1, MAX_EDICTS);
+ "U_MOREBITS",
+ "U_ORIGIN1",
+ "U_ORIGIN2",
+ "U_ORIGIN3",
+ "U_ANGLE2",
+ "U_STEP",
+ "U_FRAME",
+ "U_SIGNAL",
+ "U_ANGLE1",
+ "U_ANGLE3",
+ "U_MODEL",
+ "U_COLORMAP",
+ "U_SKIN",
+ "U_EFFECTS",
+ "U_LONGENTITY",
+ "U_EXTEND1",
+ "U_DELTA",
+ "U_ALPHA",
+ "U_SCALE",
+ "U_EFFECTS2",
+ "U_GLOWSIZE",
+ "U_GLOWCOLOR",
+ "U_COLORMOD",
+ "U_EXTEND2",
+ "U_GLOWTRAIL",
+ "U_VIEWMODEL",
+ "U_FRAME2",
+ "U_MODEL2",
+ "U_EXTERIORMODEL",
+ "U_UNUSED29",
+ "U_UNUSED30",
+ "U_EXTEND3",
+};
+
+void CL_BitProfile_f(void)
+{
+ int i;
+ Con_Printf("bitprofile: %i updates\n");
+ if (bitprofilecount)
+ for (i = 0;i < 32;i++)
+// if (bitprofile[i])
+ Con_Printf("%s: %i %3.2f%%\n", bitprofilenames[i], bitprofile[i], bitprofile[i] * 100.0 / bitprofilecount);
+ Con_Printf("\n");
+ for (i = 0;i < 32;i++)
+ bitprofile[i] = 0;
+ bitprofilecount = 0;
}
-int entityupdatestart;
-void CL_EntityUpdateBegin(int start)
+void CL_EntityUpdateSetup()
{
- if (start < 0 || start >= MAX_EDICTS)
- Host_Error("CL_EntityUpdateBegin: start (%i) < 0 or >= MAX_EDICTS (%i)\n", start, MAX_EDICTS);
- entityupdatestart = start;
+ memset(entkill, 1, MAX_EDICTS);
}
-void CL_EntityUpdateEnd(int end)
+void CL_EntityUpdateEnd()
{
int i;
- if (end < 0 || end > MAX_EDICTS)
- Host_Error("CL_EntityUpdateEnd: end (%i) < 0 or > MAX_EDICTS (%i)\n", end, MAX_EDICTS);
- for (i = entityupdatestart;i < end;i++)
+ for (i = 1;i < MAX_EDICTS;i++)
if (entkill[i])
cl_entities[i].state_previous.active = cl_entities[i].state_current.active = 0;
}
CL_ParseBaseline
==================
*/
-void CL_ParseBaseline (entity_t *ent, int largemodelindex)
+void CL_ParseBaseline (entity_t *ent, int large)
{
int i;
memset(&ent->state_baseline, 0, sizeof(entity_state_t));
ent->state_baseline.active = true;
- if (largemodelindex)
+ if (large)
+ {
ent->state_baseline.modelindex = (unsigned short) MSG_ReadShort ();
+ ent->state_baseline.frame = (unsigned short) MSG_ReadShort ();
+ }
else
+ {
ent->state_baseline.modelindex = MSG_ReadByte ();
- ent->state_baseline.frame = MSG_ReadByte ();
+ ent->state_baseline.frame = MSG_ReadByte ();
+ }
ent->state_baseline.colormap = MSG_ReadByte();
ent->state_baseline.skin = MSG_ReadByte();
for (i = 0;i < 3;i++)
CL_ParseStatic
=====================
*/
-void CL_ParseStatic (int largemodelindex)
+void CL_ParseStatic (int large)
{
entity_t *ent;
if (cl.num_statics >= MAX_STATIC_ENTITIES)
Host_Error ("Too many static entities");
ent = &cl_static_entities[cl.num_statics++];
- CL_ParseBaseline (ent, largemodelindex);
+ CL_ParseBaseline (ent, large);
// copy it to the current state
ent->render.model = cl.model_precache[ent->state_baseline.modelindex];
VectorCopy (ent->state_baseline.origin, ent->render.origin);
VectorCopy (ent->state_baseline.angles, ent->render.angles);
-// R_AddEfrags (ent);
}
/*
CL_ParseStaticSound
===================
*/
-void CL_ParseStaticSound (void)
+void CL_ParseStaticSound (int large)
{
vec3_t org;
int sound_num, vol, atten;
MSG_ReadVector(org);
- sound_num = MSG_ReadByte ();
+ if (large)
+ sound_num = (unsigned short) MSG_ReadShort ();
+ else
+ sound_num = MSG_ReadByte ();
vol = MSG_ReadByte ();
atten = MSG_ReadByte ();
MSG_ReadVector(org);
modelindex = MSG_ReadShort ();
- startframe = MSG_ReadByte ();
+ startframe = MSG_ReadShort ();
framecount = MSG_ReadByte ();
framerate = MSG_ReadByte ();
void CL_ParseServerMessage (void)
{
int cmd;
- int i, updateend;
+ int i, entitiesupdated;
byte cmdlog[32];
char *cmdlogname[32], *temp;
int cmdindex, cmdcount = 0;
//
MSG_BeginReading ();
- updateend = false;
+ entitiesupdated = false;
CL_EntityUpdateSetup();
while (1)
case svc_time:
// handle old protocols which do not have entity update ranges
- CL_EntityUpdateBegin(1);
- updateend = true;
+ entitiesupdated = true;
cl.mtime[1] = cl.mtime[0];
cl.mtime[0] = MSG_ReadFloat ();
break;
case svc_spawnbaseline2:
i = MSG_ReadShort ();
// must use CL_EntityNum() to force cl.num_entities up
- CL_ParseBaseline (CL_EntityNum(i), false);
+ CL_ParseBaseline (CL_EntityNum(i), true);
break;
case svc_spawnstatic:
CL_ParseStatic (false);
break;
case svc_spawnstaticsound:
- CL_ParseStaticSound ();
+ CL_ParseStaticSound (false);
+ break;
+
+ case svc_spawnstaticsound2:
+ CL_ParseStaticSound (true);
break;
case svc_cdtrack:
case svc_showlmp:
SHOWLMP_decodeshow();
break;
- case svc_entitiesbegin:
- // the beginning of an entity update range
- CL_EntityUpdateBegin((unsigned) MSG_ReadShort());
- break;
- case svc_entitiesend:
- // the end of an entity update range
- CL_EntityUpdateEnd((unsigned) MSG_ReadShort());
- updateend = false;
- break;
}
}
- if (updateend)
- CL_EntityUpdateEnd(MAX_EDICTS);
+ if (entitiesupdated)
+ CL_EntityUpdateEnd();
}
-
}
beam_t;
-// LordHavoc: increased MAX_EFRAGS from 640 to 2048
-//#define MAX_EFRAGS 2048
-
#define MAX_MAPSTRING 2048
#define MAX_DEMOS 8
#define MAX_DEMONAME 16
// refresh related state
struct model_s *worldmodel; // cl_entitites[0].model
-// struct efrag_s *free_efrags;
// int num_entities; // held in cl_entities array
int num_statics; // held in cl_staticentities array
entity_t viewent; // the gun model
//
// cvars
//
-extern cvar_t cl_name;
-extern cvar_t cl_color;
-extern cvar_t cl_pmodel;
+extern cvar_t cl_name;
+extern cvar_t cl_color;
+extern cvar_t cl_pmodel;
+
+extern cvar_t cl_upspeed;
+extern cvar_t cl_forwardspeed;
+extern cvar_t cl_backspeed;
+extern cvar_t cl_sidespeed;
-extern cvar_t cl_upspeed;
-extern cvar_t cl_forwardspeed;
-extern cvar_t cl_backspeed;
-extern cvar_t cl_sidespeed;
+extern cvar_t cl_movespeedkey;
-extern cvar_t cl_movespeedkey;
+extern cvar_t cl_yawspeed;
+extern cvar_t cl_pitchspeed;
-extern cvar_t cl_yawspeed;
-extern cvar_t cl_pitchspeed;
+extern cvar_t cl_anglespeedkey;
-extern cvar_t cl_anglespeedkey;
+extern cvar_t cl_autofire;
-extern cvar_t cl_autofire;
+extern cvar_t cl_shownet;
+extern cvar_t cl_nolerp;
-extern cvar_t cl_shownet;
-extern cvar_t cl_nolerp;
+extern cvar_t cl_pitchdriftspeed;
+extern cvar_t lookspring;
+extern cvar_t lookstrafe;
+extern cvar_t sensitivity;
-extern cvar_t cl_pitchdriftspeed;
-extern cvar_t lookspring;
-extern cvar_t lookstrafe;
-extern cvar_t sensitivity;
+extern cvar_t freelook;
-extern cvar_t m_pitch;
-extern cvar_t m_yaw;
-extern cvar_t m_forward;
-extern cvar_t m_side;
+extern cvar_t m_pitch;
+extern cvar_t m_yaw;
+extern cvar_t m_forward;
+extern cvar_t m_side;
// LordHavoc: raised these from 64 and 128 to 512 and 256
#define MAX_TEMP_ENTITIES 512 // lightning bolts, effects, etc
#define MAX_STATIC_ENTITIES 256 // torches, etc
-extern client_state_t cl;
+extern client_state_t cl;
// FIXME, allocate dynamically
-//extern efrag_t cl_efrags[MAX_EFRAGS];
extern entity_t cl_entities[MAX_EDICTS];
extern entity_t cl_static_entities[MAX_STATIC_ENTITIES];
extern lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
// cl_parse.c
//
void CL_ParseServerMessage (void);
+void CL_BitProfile_f(void);
//
// view
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
- glColor3f(1,1,1);
+ if (lighthalf)
+ glColor3f(0.5f,0.5f,0.5f);
+ else
+ glColor3f(1.0f,1.0f,1.0f);
glBegin (GL_QUADS);
glTexCoord2f (fcol, frow);
glVertex2f (x, y);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
- glColor3f(1,1,1);
+ if (lighthalf)
+ glColor3f(0.5f,0.5f,0.5f);
+ else
+ glColor3f(1.0f,1.0f,1.0f);
glBegin (GL_QUADS);
while (maxlen-- && x < (int) vid.width) // stop rendering when out of characters or room
{
{
if (!r_render.value)
return;
- glColor4f(red,green,blue,alpha);
+ if (lighthalf)
+ glColor4f(red * 0.5f, green * 0.5f, blue * 0.5f, alpha);
+ else
+ glColor4f(red, green, blue, alpha);
glBindTexture(GL_TEXTURE_2D, R_GetTexture(tex));
glBegin (GL_QUADS);
glTexCoord2f (0, 0);glVertex2f (x, y);
if (!r_render.value)
return;
glDisable (GL_TEXTURE_2D);
- glColor3f (host_basepal[c*3]/255.0, host_basepal[c*3+1]/255.0, host_basepal[c*3+2]/255.0);
+ if (lighthalf)
+ {
+ byte *tempcolor = (byte *)&d_8to24table[c];
+ glColor4ub ((byte) (tempcolor[0] >> 1), (byte) (tempcolor[1] >> 1), (byte) (tempcolor[2] >> 1), tempcolor[3]);
+ }
+ else
+ glColor4ubv ((byte *)&d_8to24table[c]);
glBegin (GL_QUADS);
glEnable (GL_BLEND);
glDepthMask(0); // disable zbuffer updates
- VectorSubtract(org, r_refdef.vieworg, diff);
+ VectorSubtract(org, r_origin, diff);
glColor4f(fogcolor[0], fogcolor[1], fogcolor[2], exp(fogdensity/DotProduct(diff,diff)));
glDrawElements(GL_TRIANGLES, maliashdr->numtris * 3, GL_UNSIGNED_SHORT, (void *)((int) maliashdr + maliashdr->tridata));
glDepthMask(0); // disable zbuffer updates
{
vec3_t diff;
- VectorSubtract(org, r_refdef.vieworg, diff);
+ VectorSubtract(org, r_origin, diff);
glColor4f(fogcolor[0], fogcolor[1], fogcolor[2], exp(fogdensity/DotProduct(diff,diff)));
}
while(vertcount--)
{
c = *bonecounts++;
+ // FIXME: validate bonecounts at load time (must be >= 1)
if (c == 1)
{
matrix = &zymbonepose[vert->bonenum];
glEnable (GL_BLEND);
glDepthMask(0); // disable zbuffer updates
- VectorSubtract(org, r_refdef.vieworg, diff);
+ VectorSubtract(org, r_origin, diff);
glColor4f(fogcolor[0], fogcolor[1], fogcolor[2], exp(fogdensity/DotProduct(diff,diff)));
glVertexPointer(3, GL_FLOAT, 0, aliasvert);
currenttranspoly = currenttransvert = 0;
currenttranslist = translist;
memset(translisthash, 0, sizeof(translisthash));
- transviewdist = DotProduct(r_refdef.vieworg, vpn);
+ transviewdist = DotProduct(r_origin, vpn);
}
// turned into a #define
int transpolyindices;
-/*
-void transpolyrenderminmax()
-{
- int i, j, k, lastvert;
- vec_t d, min, max, viewdist, s, average;
- //vec_t ndist;
- //vec3_t v1, v2, n;
- transpolyindices = 0;
- viewdist = DotProduct(r_refdef.vieworg, vpn);
- for (i = 0;i < currenttranspoly;i++)
- {
- if (transpoly[i].verts < 3) // only process valid polygons
- continue;
- min = 1000000;max = -1000000;
- s = 1.0f / transpoly[i].verts;
- lastvert = transpoly[i].firstvert + transpoly[i].verts;
- average = 0;
- for (j = transpoly[i].firstvert;j < lastvert;j++)
- {
- d = DotProduct(transvert[j].v, vpn)-viewdist;
- if (d < min) min = d;
- if (d > max) max = d;
- average += d * s;
- }
- if (max < 4) // free to check here, so skip polys behind the view
- continue;
- transpoly[i].distance = average;
-*/
- /*
- transpoly[i].mindistance = min;
- transpoly[i].maxdistance = max;
- // calculate normal (eek)
- VectorSubtract(transvert[transpoly[i].firstvert ].v, transvert[transpoly[i].firstvert+1].v, v1);
- VectorSubtract(transvert[transpoly[i].firstvert+2].v, transvert[transpoly[i].firstvert+1].v, v2);
- VectorNormalize(v1);
- VectorNormalize(v2);
- if (transpoly[i].verts > 3 && fabs(DotProduct(v1, v2)) >= (1.0f - (1.0f / 256.0f))) // colinear edges, find a better triple
- {
- VectorSubtract(transvert[transpoly[i].firstvert + transpoly[i].verts - 1].v, transvert[transpoly[i].firstvert].v, v1);
- VectorSubtract(transvert[transpoly[i].firstvert + 1].v, transvert[transpoly[i].firstvert].v, v2);
- VectorNormalize(v1);
- VectorNormalize(v2);
- if (fabs(DotProduct(v1, v2)) < (1.0f - (1.0f / 256.0f))) // found a good triple
- goto foundtriple;
- for (k = transpoly[i].firstvert + 2;k < (transpoly[i].firstvert + transpoly[i].verts - 1);k++)
- {
- VectorSubtract(transvert[k-1].v, transvert[k].v, v1);
- VectorSubtract(transvert[k+1].v, transvert[k].v, v2);
- VectorNormalize(v1);
- VectorNormalize(v2);
- if (fabs(DotProduct(v1, v2)) < (1.0f - (1.0f / 256.0f))) // found a good triple
- goto foundtriple;
- }
- VectorSubtract(transvert[k-1].v, transvert[k].v, v1);
- VectorSubtract(transvert[transpoly[i].firstvert].v, transvert[k].v, v2);
- VectorNormalize(v1);
- VectorNormalize(v2);
- if (fabs(DotProduct(v1, v2)) >= (1.0f - (1.0f / 256.0f))) // no good triples; the polygon is a line, skip it
- continue;
- }
-foundtriple:
- CrossProduct(v1, v2, n);
- VectorNormalize(n);
- ndist = DotProduct(transvert[transpoly[i].firstvert+1].v, n);
- // sorted insert
- for (j = 0;j < transpolyindices;j++)
- {
- // easy cases
- if (transpoly[transpolyindex[j]].mindistance > max)
- continue;
- if (transpoly[transpolyindex[j]].maxdistance < min)
- break;
- // hard case, check side
- for (k = transpoly[transpolyindex[j]].firstvert;k < (transpoly[transpolyindex[j]].firstvert + transpoly[transpolyindex[j]].verts);k++)
- if (DotProduct(transvert[k].v, n) < ndist)
- goto skip;
- break;
-skip:
- ;
- }
- */
-/*
- // sorted insert
- for (j = 0;j < transpolyindices;j++)
- if (transpoly[transpolyindex[j]].distance < average)
- break;
- for (k = transpolyindices;k > j;k--)
- transpolyindex[k] = transpolyindex[k-1];
- transpolyindices++;
- transpolyindex[j] = i;
- }
-}
-*/
-/*
-// LordHavoc: qsort compare function
-int transpolyqsort(const void *ia, const void *ib)
-{
- transpoly_t *a, *b;
- int i, j;
- a = &transpoly[*((unsigned short *)ia)];
- b = &transpoly[*((unsigned short *)ib)];
- // easy cases
- if (a->mindistance > b->mindistance && a->maxdistance > b->maxdistance)
- return -1; // behind
- if (a->mindistance < b->mindistance && a->maxdistance < b->maxdistance)
- return 1; // infront
- // hard case
- if (!a->ndist)
- {
- // calculate normal (eek)
- vec3_t v1, v2;
- VectorSubtract(transvert[a->firstvert ].v, transvert[a->firstvert+1].v, v1);
- VectorSubtract(transvert[a->firstvert+2].v, transvert[a->firstvert+1].v, v2);
- CrossProduct(v1, v2, a->n);
- VectorNormalize(a->n);
- a->ndist = DotProduct(transvert[a->firstvert ].v, a->n);
- }
- // check side
- for (i = b->firstvert, j = 0;i < (b->firstvert + b->verts);i++)
- j += DotProduct(transvert[i].v, a->n) < a->ndist; // (1) b is infront of a
- if (j == 0)
- return -1; // (-1) a is behind b
- return j == b->verts; // (1) a is infront of b (0) a and b intersect
-// return (transpoly[*((unsigned short *)ib)].mindistance + transpoly[*((unsigned short *)ib)].maxdistance) - (transpoly[*((unsigned short *)ia)].mindistance + transpoly[*((unsigned short *)ia)].maxdistance);
- */
-/*
- return ((transpoly_t*)ia)->distance - ((transpoly_t*)ib)->distance;
-}
-*/
-
-/*
-int transpolyqsort(const void *ia, const void *ib)
-{
- return (transpoly[*((unsigned short *)ib)].distance - transpoly[*((unsigned short *)ia)].distance);
-}
-*/
-
-/*
-void transpolyrenderminmax()
-{
- int i, j, lastvert;
- vec_t d, max, viewdist, average;
- transpolyindices = 0;
- viewdist = DotProduct(r_refdef.vieworg, vpn);
- for (i = 0;i < currenttranspoly;i++)
- {
- if (transpoly[i].verts < 3) // only process valid polygons
- continue;
- max = -1000000;
- lastvert = transpoly[i].firstvert + transpoly[i].verts;
- average = 0;
- for (j = transpoly[i].firstvert;j < lastvert;j++)
- {
- d = DotProduct(transvert[j].v, vpn)-viewdist;
- average += d;
- if (d > max)
- max = d;
- }
- if (max < 4) // free to check here, so skip polys behind the view
- continue;
- transpoly[i].distance = average / transpoly[i].verts;
- transpolyindex[transpolyindices++] = i;
- }
- qsort(&transpolyindex[0], transpolyindices, sizeof(unsigned short), transpolyqsort);
-}
-*/
-/*
- int i, j, a;
- a = true;
- while(a)
- {
- a = false;
- for (i = 1;i < transpolyindices;i++)
- {
- // easy cases
- if (transpoly[transpolyindex[i - 1]].mindistance > transpoly[transpolyindex[i]].mindistance && transpoly[transpolyindex[i - 1]].maxdistance > transpoly[transpolyindex[i]].maxdistance)
- continue; // previous is behind (no swap)
- if (transpoly[transpolyindex[i - 1]].mindistance < transpoly[transpolyindex[i]].mindistance && transpoly[transpolyindex[i - 1]].maxdistance < transpoly[transpolyindex[i]].maxdistance)
- goto swap; // previous is infront (swap)
- // hard case
-*/
- /*
- if (!transpoly[transpolyindex[i - 1]].ndist)
- {
- // calculate normal (eek)
- vec3_t v1, v2;
- VectorSubtract(transvert[transpoly[transpolyindex[i - 1]].firstvert ].v, transvert[transpoly[transpolyindex[i - 1]].firstvert+1].v, v1);
- VectorSubtract(transvert[transpoly[transpolyindex[i - 1]].firstvert+2].v, transvert[transpoly[transpolyindex[i - 1]].firstvert+1].v, v2);
- CrossProduct(v1, v2, transpoly[transpolyindex[i - 1]].n);
- VectorNormalize(transpoly[transpolyindex[i - 1]].n);
- transpoly[transpolyindex[i - 1]].ndist = DotProduct(transvert[transpoly[transpolyindex[i - 1]].firstvert ].v, transpoly[transpolyindex[i - 1]].n);
- }
- if (DotProduct(transpoly[transpolyindex[i - 1]].n, vpn) >= 0.0f) // backface
- continue;
- */
-/*
- // check side
- for (i = transpoly[transpolyindex[i]].firstvert;i < (transpoly[transpolyindex[i]].firstvert + transpoly[transpolyindex[i]].verts);i++)
- if (DotProduct(transvert[i].v, transpoly[transpolyindex[i - 1]].n) >= transpoly[transpolyindex[i - 1]].ndist)
- goto noswap; // previous is behind or they intersect
-swap:
- // previous is infront (swap)
- j = transpolyindex[i];
- transpolyindex[i] = transpolyindex[i - 1];
- transpolyindex[i - 1] = j;
- a = true;
-noswap:
- ;
- }
- }
-}
-*/
-
void transpolyrender()
{
int i, j, tpolytype, texnum;
glBegin(GL_POLYGON);
for (j = 0,vert = &transvert[p->firstvert];j < p->verts;j++, vert++)
{
- VectorSubtract(vert->v, r_refdef.vieworg,diff);
+ VectorSubtract(vert->v, r_origin, diff);
glTexCoord2f(vert->s, vert->t);
glColor4f(fogcolor[0], fogcolor[1], fogcolor[2], vert->a*(1.0f/255.0f)*exp(fogdensity/DotProduct(diff,diff)));
glVertex3fv(vert->v);
glBegin(GL_POLYGON);
for (j = 0,vert = &transvert[p->firstvert];j < p->verts;j++, vert++)
{
- VectorSubtract(vert->v, r_refdef.vieworg,diff);
+ VectorSubtract(vert->v, r_origin, diff);
glColor4f(fogcolor[0], fogcolor[1], fogcolor[2], vert->a*(1.0f/255.0f)*exp(fogdensity/DotProduct(diff,diff)));
glVertex3fv(vert->v);
}
glBegin(GL_POLYGON);
for (j=0 ; j<p->numverts ; j++, vert++)
{
- VectorSubtract(vert->vert, r_refdef.vieworg,diff);
+ VectorSubtract(vert->vert, r_origin, diff);
glColor4f(fogcolor[0], fogcolor[1], fogcolor[2], exp(fogdensity/DotProduct(diff,diff)));
glVertex3fv (vert->vert);
}
cvar_t r_waterripple = {"r_waterripple","0"};
cvar_t r_fullbrights = {"r_fullbrights", "1"};
-cvar_t contrast = {"contrast", "1.0", true}; // LordHavoc: a method of operating system independent color correction
-cvar_t brightness = {"brightness", "1.0", true}; // LordHavoc: a method of operating system independent color correction
cvar_t gl_lightmode = {"gl_lightmode", "1", true}; // LordHavoc: overbright lighting
//cvar_t r_dynamicbothsides = {"r_dynamicbothsides", "1"}; // LordHavoc: can disable dynamic lighting of backfaces, but quake maps are weird so it doesn't always work right...
cvar_t r_farclip = {"r_farclip", "6144"};
Cvar_RegisterVariable (&r_drawviewmodel);
Cvar_RegisterVariable (&r_speeds);
Cvar_RegisterVariable (&r_speeds2);
- Cvar_RegisterVariable (&contrast);
- Cvar_RegisterVariable (&brightness);
Cvar_RegisterVariable (&gl_lightmode);
// Cvar_RegisterVariable (&r_dynamicwater);
// Cvar_RegisterVariable (&r_dynamicbothsides);
glAlphaFunc(GL_GREATER, 0.5);
// glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
-
- Palette_Init();
}
ent->render.flags -= RENDER_VIEWMODEL;
// transform origin
VectorCopy(ent->render.origin, v);
- ent->render.origin[0] = v[0] * vpn[0] + v[1] * vright[0] + v[2] * vup[0] + r_refdef.vieworg[0];
- ent->render.origin[1] = v[0] * vpn[1] + v[1] * vright[1] + v[2] * vup[1] + r_refdef.vieworg[1];
- ent->render.origin[2] = v[0] * vpn[2] + v[1] * vright[2] + v[2] * vup[2] + r_refdef.vieworg[2];
+ ent->render.origin[0] = v[0] * vpn[0] + v[1] * vright[0] + v[2] * vup[0] + r_origin[0];
+ ent->render.origin[1] = v[0] * vpn[1] + v[1] * vright[1] + v[2] * vup[1] + r_origin[1];
+ ent->render.origin[2] = v[0] * vpn[2] + v[1] * vright[2] + v[2] * vup[2] + r_origin[2];
// adjust angles
VectorAdd(ent->render.angles, r_refdef.viewangles, ent->render.angles);
}
Cvar_Set ("r_ambient", "0");
}
- R_AnimateLight ();
-
r_framecount++;
// build the transformation matrix for the given view angles
c_sprites = 0;
c_particles = 0;
// c_dlights = 0;
+
+ R_AnimateLight ();
}
glViewport (glx + x, gly + y2, w, h);
screenaspect = (float)r_refdef.vrect.width/r_refdef.vrect.height;
// yfov = 2*atan((float)r_refdef.vrect.height/r_refdef.vrect.width)*180/M_PI;
-// if (skyname[0]) // skybox enabled?
-// MYgluPerspective (r_refdef.fov_y, screenaspect, 4, r_skyboxsize.value*1.732050807569 + 256); // this is size*sqrt(3) + 256
-// else
- MYgluPerspective (r_refdef.fov_y, screenaspect, 4, r_farclip.value);
+ MYgluPerspective (r_refdef.fov_y, screenaspect, 4, r_farclip.value);
glCullFace(GL_FRONT);
glEnable (GL_CULL_FACE);
}
-extern cvar_t contrast;
-extern cvar_t brightness;
-extern cvar_t gl_lightmode;
-
void GL_BlendView()
{
if (!r_render.value)
return;
+
+ if (v_blend[3] < 0.01f)
+ return;
+
glMatrixMode(GL_PROJECTION);
glLoadIdentity ();
glOrtho (0, vid.width, vid.height, 0, -99999, 99999);
glDisable (GL_CULL_FACE);
glDisable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
- if (lighthalf)
- {
- glBlendFunc (GL_DST_COLOR, GL_ONE);
- glBegin (GL_TRIANGLES);
- glColor3f (1, 1, 1);
- glVertex2f (-5000, -5000);
- glVertex2f (10000, -5000);
- glVertex2f (-5000, 10000);
- glEnd ();
- }
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- contrast.value = bound(0.2, contrast.value, 1.0);
- if (/*gl_polyblend.value && */v_blend[3])
- {
- glBegin (GL_TRIANGLES);
+ glBegin (GL_TRIANGLES);
+ if (lighthalf)
+ glColor4f (v_blend[0] * 0.5f, v_blend[1] * 0.5f, v_blend[2] * 0.5f, v_blend[3]);
+ else
glColor4fv (v_blend);
- glVertex2f (-5000, -5000);
- glVertex2f (10000, -5000);
- glVertex2f (-5000, 10000);
- glEnd ();
- }
+ glVertex2f (-5000, -5000);
+ glVertex2f (10000, -5000);
+ glVertex2f (-5000, 10000);
+ glEnd ();
glEnable (GL_CULL_FACE);
glEnable (GL_DEPTH_TEST);
if (r_speeds2.value)\
{\
temptime = currtime;\
- currtime = Sys_FloatTime();\
+ currtime = Sys_DoubleTime();\
VAR = (int) ((currtime - temptime) * 1000000.0);\
}\
else\
FOG_framebegin();
if (r_speeds2.value)
- {
- starttime = currtime = Sys_FloatTime();
- }
+ starttime = currtime = Sys_DoubleTime();
else
starttime = currtime = 0;
R_Clear();
TIMEREPORT(time_blend)
if (r_speeds2.value)
{
- time_total = (int) ((Sys_FloatTime() - starttime) * 1000000.0);
+ time_total = (int) ((Sys_DoubleTime() - starttime) * 1000000.0);
sprintf(r_speeds2_string1, "%6i walls %6i dlitwalls %7i modeltris %7i transpoly\n", c_brush_polys, c_light_polys, c_alias_polys, currenttranspoly);
sprintf(r_speeds2_string2, "BSP: %6i faces %6i nodes %6i leafs\n", c_faces, c_nodes, c_leafs);
sprintf(r_speeds2_string3, "%4i models %4i bmodels %4i sprites %5i particles %3i dlights\n", c_models, c_bmodels, c_sprites, c_particles, c_dlights);
r_worldentity.render.model = cl.worldmodel;
currententity = &r_worldentity;
-// clear out efrags in case the level hasn't been reloaded
-// FIXME: is this one short?
-// for (i=0 ; i<cl.worldmodel->numleafs ; i++)
-// cl.worldmodel->leafs[i].efrags = NULL;
-
r_viewleaf = NULL;
R_Modules_NewMap();
float start, stop, time;
intimerefresh = 1;
- start = Sys_FloatTime ();
+ start = Sys_DoubleTime ();
for (i = 0;i < 128;i++)
{
r_refdef.viewangles[0] = 0;
SCR_UpdateScreen();
}
- stop = Sys_FloatTime ();
+ stop = Sys_DoubleTime ();
intimerefresh = 0;
time = stop-start;
Con_Printf ("%f seconds (%f fps)\n", time, 128/time);
c_bmodels++;
- VectorSubtract (r_refdef.vieworg, e->render.origin, modelorg);
+ VectorSubtract (r_origin, e->render.origin, modelorg);
if (rotated)
{
vec3_t temp;
modelorg[2] = DotProduct (temp, up);
}
- s = &clmodel->surfaces[clmodel->firstmodelsurface];
+ for (i = 0, s = &clmodel->surfaces[clmodel->firstmodelsurface];i < clmodel->nummodelsurfaces;i++, s++)
+ {
+ if (((s->flags & SURF_PLANEBACK) == 0) == (PlaneDiff(modelorg, s->plane) >= 0))
+ s->visframe = r_framecount;
+ else
+ s->visframe = -1;
+ }
// calculate dynamic lighting for bmodel if it's not an
// instanced model
e->render.angles[0] = -e->render.angles[0]; // stupid quake bug
// draw texture
- for (i = 0;i < clmodel->nummodelsurfaces;i++, s++)
+ for (i = 0, s = &clmodel->surfaces[clmodel->firstmodelsurface];i < clmodel->nummodelsurfaces;i++, s++)
{
- if (((s->flags & SURF_PLANEBACK) == 0) == (PlaneDiff(modelorg, s->plane) >= 0))
+ if (s->visframe == r_framecount)
{
// R_DrawSurf(s, true, vertexlit || s->texinfo->texture->transparent);
if (s->flags & (SURF_DRAWSKY | SURF_DRAWTURB))
for (l = 0, leaf = cl.worldmodel->leafs;l < cl.worldmodel->numleafs;l++, leaf++)
{
- if (/*leaf->efrags || */leaf->nummarksurfaces)
+ if (leaf->nummarksurfaces)
{
if (R_CullBox(leaf->mins, leaf->maxs))
continue;
leaf->visframe = r_framecount;
- // deal with model fragments in this leaf
-// if (leaf->efrags)
-// R_StoreEfrags (&leaf->efrags);
-
if (leaf->nummarksurfaces)
{
mark = leaf->firstmarksurface;
leaf->visframe = r_framecount;
- // deal with model fragments in this leaf
- // if (leaf->efrags)
- // R_StoreEfrags (&leaf->efrags);
-
if (leaf->nummarksurfaces)
{
mark = leaf->firstmarksurface;
leaf->visframe = r_framecount;
- // deal with model fragments in this leaf
-// if (leaf->efrags)
-// R_StoreEfrags (&leaf->efrags);
-
if (leaf->nummarksurfaces)
{
mark = leaf->firstmarksurface;
modelalpha = ent.render.alpha = 1;
ent.render.scale = 1;
- VectorCopy (r_refdef.vieworg, modelorg);
+ VectorCopy (r_origin, modelorg);
currententity = &ent;
*/
-int glx, gly, glwidth, glheight;
-
-float scr_con_current;
-float scr_conlines; // lines of console to display
-
-float oldscreensize, oldfov;
-cvar_t scr_viewsize = {"viewsize","100", true};
-cvar_t scr_fov = {"fov","90"}; // 10 - 170
-cvar_t scr_conspeed = {"scr_conspeed","300"};
-cvar_t scr_centertime = {"scr_centertime","2"};
-cvar_t scr_showram = {"showram","1"};
-cvar_t scr_showturtle = {"showturtle","0"};
-cvar_t scr_showpause = {"showpause","1"};
-cvar_t scr_printspeed = {"scr_printspeed","8"};
-cvar_t showfps = {"showfps", "0", true};
-cvar_t r_render = {"r_render", "1"};
-
-extern cvar_t crosshair;
+int glx, gly, glwidth, glheight;
+
+float scr_con_current;
+float scr_conlines; // lines of console to display
+
+float oldscreensize, oldfov;
+cvar_t scr_viewsize = {"viewsize","100", true};
+cvar_t scr_fov = {"fov","90"}; // 10 - 170
+cvar_t scr_conspeed = {"scr_conspeed","300"};
+cvar_t scr_centertime = {"scr_centertime","2"};
+cvar_t scr_showram = {"showram","1"};
+cvar_t scr_showturtle = {"showturtle","0"};
+cvar_t scr_showpause = {"showpause","1"};
+cvar_t scr_printspeed = {"scr_printspeed","8"};
+cvar_t showfps = {"showfps", "0", true};
+cvar_t r_render = {"r_render", "1"};
+cvar_t r_brightness = {"r_brightness", "1", true}; // LordHavoc: a method of operating system independent color correction
+cvar_t r_contrast = {"r_contrast", "1", true}; // LordHavoc: a method of operating system independent color correction
qboolean scr_initialized; // ready to draw
int clearconsole;
int clearnotify;
-extern int sb_lines;
-
-extern viddef_t vid; // global video state
-
qboolean scr_disabled_for_loading;
//qboolean scr_drawloading;
//float scr_disabled_time;
Cvar_RegisterVariable (&scr_printspeed);
Cvar_RegisterVariable (&showfps);
Cvar_RegisterVariable (&r_render);
+ Cvar_RegisterVariable (&r_brightness);
+ Cvar_RegisterVariable (&r_contrast);
#ifdef NORENDER
r_render.value = 0;
#endif
void GL_Set2D (void);
extern void SHOWLMP_drawall();
-extern cvar_t contrast;
-extern cvar_t brightness;
-extern cvar_t gl_lightmode;
extern cvar_t r_speeds2;
void GL_BrightenScreen()
{
float f;
+
+ if (r_brightness.value < 0.1f)
+ Cvar_SetValue("r_brightness", 0.1f);
+ if (r_brightness.value > 5.0f)
+ Cvar_SetValue("r_brightness", 5.0f);
+
+ if (r_contrast.value < 0.2f)
+ Cvar_SetValue("r_contrast", 0.2f);
+ if (r_contrast.value > 1.0f)
+ Cvar_SetValue("r_contrast", 1.0f);
+
+ if (!(lighthalf && !hardwaregammasupported) && r_brightness.value < 1.01f && r_contrast.value > 0.99f)
+ return;
+
if (!r_render.value)
return;
+
glDisable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
- f = bound(1.0f, brightness.value, 5.0f);
- if (f != brightness.value)
- Cvar_SetValue("brightness", f);
+ f = r_brightness.value;
+ // only apply lighthalf using software color correction if hardware is not available (speed reasons)
+ if (lighthalf && !hardwaregammasupported)
+ f *= 2;
if (f >= 1.01f)
{
glBlendFunc (GL_DST_COLOR, GL_ONE);
}
glEnd ();
}
- glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- f = bound(0.2f, contrast.value, 1.0f);
- if (f != contrast.value)
- Cvar_SetValue("contrast", f);
- if (contrast.value < 0.99f)
+ if (r_contrast.value <= 0.99f)
{
+ glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ if (lighthalf && hardwaregammasupported)
+ glColor4f (0.5, 0.5, 0.5, 1 - r_contrast.value);
+ else
+ glColor4f (1, 1, 1, 1 - r_contrast.value);
glBegin (GL_TRIANGLES);
- glColor4f (1, 1, 1, 1-contrast.value);
glVertex2f (-5000, -5000);
glVertex2f (10000, -5000);
glVertex2f (-5000, 10000);
glEnd ();
}
+ glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable (GL_CULL_FACE);
glEnable (GL_DEPTH_TEST);
double time1 = 0, time2;
if (r_speeds.value)
- time1 = Sys_FloatTime ();
+ time1 = Sys_DoubleTime ();
+
+ VID_UpdateGamma(false);
if (scr_disabled_for_loading)
{
double newtime;
char temp[32];
int calc;
- newtime = Sys_FloatTime();
+ newtime = Sys_DoubleTime();
calc = (int) ((1.0 / (newtime - currtime)) + 0.5);
sprintf(temp, "%4i fps", calc);
currtime = newtime;
if (r_speeds.value)
{
- time2 = Sys_FloatTime ();
+ time2 = Sys_DoubleTime ();
Con_Printf ("%3i ms %4i wpoly %4i epoly %4i transpoly %4i lightpoly %4i BSPnodes %4i BSPleafs %4i BSPfaces %4i models %4i bmodels %4i sprites %4i particles %3i dlights\n", (int)((time2-time1)*1000), c_brush_polys, c_alias_polys, currenttranspoly, c_light_polys, c_nodes, c_leafs, c_faces, c_models, c_bmodels, c_sprites, c_particles, c_dlights);
}
GL_EndRendering ();
#define R_SkyBoxPolyVec(s,t,x,y,z) \
glTexCoord2f((s) * (254.0f/256.0f) + (1.0f/256.0f), (t) * (254.0f/256.0f) + (1.0f/256.0f));\
- glVertex3f((x) * 1024.0 + r_refdef.vieworg[0], (y) * 1024.0 + r_refdef.vieworg[1], (z) * 1024.0 + r_refdef.vieworg[2]);
+ glVertex3f((x) * 1024.0 + r_origin[0], (y) * 1024.0 + r_origin[1], (z) * 1024.0 + r_origin[2]);
void R_SkyBox()
{
{
*t++ = source[0] * texscale + s;
*t++ = source[1] * texscale + s;
- *v++ = *source++ + r_refdef.vieworg[0];
- *v++ = *source++ + r_refdef.vieworg[1];
- *v++ = *source++ + r_refdef.vieworg[2];
+ *v++ = *source++ + r_origin[0];
+ *v++ = *source++ + r_origin[1];
+ *v++ = *source++ + r_origin[2];
}
glTexCoordPointer(2, GL_FLOAT, 0, tex);
glVertexPointer(3, GL_FLOAT, 0, vert);
extern qboolean fogenabled;
extern vec3_t fogcolor;
extern vec_t fogdensity;
-//#define calcfog(v) (exp(-(fogdensity*fogdensity*(((v)[0] - r_refdef.vieworg[0]) * vpn[0] + ((v)[1] - r_refdef.vieworg[1]) * vpn[1] + ((v)[2] - r_refdef.vieworg[2]) * vpn[2])*(((v)[0] - r_refdef.vieworg[0]) * vpn[0] + ((v)[1] - r_refdef.vieworg[1]) * vpn[1] + ((v)[2] - r_refdef.vieworg[2]) * vpn[2]))))
-#define calcfog(v) (exp(-(fogdensity*fogdensity*(((v)[0] - r_refdef.vieworg[0])*((v)[0] - r_refdef.vieworg[0])+((v)[1] - r_refdef.vieworg[1])*((v)[1] - r_refdef.vieworg[1])+((v)[2] - r_refdef.vieworg[2])*((v)[2] - r_refdef.vieworg[2])))))
+//#define calcfog(v) (exp(-(fogdensity*fogdensity*(((v)[0] - r_origin[0]) * vpn[0] + ((v)[1] - r_origin[1]) * vpn[1] + ((v)[2] - r_origin[2]) * vpn[2])*(((v)[0] - r_origin[0]) * vpn[0] + ((v)[1] - r_origin[1]) * vpn[1] + ((v)[2] - r_origin[2]) * vpn[2]))))
+#define calcfog(v) (exp(-(fogdensity*fogdensity*(((v)[0] - r_origin[0])*((v)[0] - r_origin[0])+((v)[1] - r_origin[1])*((v)[1] - r_origin[1])+((v)[2] - r_origin[2])*((v)[2] - r_origin[2])))))
#define calcfogbyte(v) ((byte) (bound(0, ((int) ((float) (calcfog((v)) * 255.0f))), 255)))
#include "r_modules.h"
CL_Disconnect ();
// flush any pending messages - like the score!!!
- start = Sys_FloatTime();
+ start = Sys_DoubleTime();
do
{
count = 0;
}
}
}
- if ((Sys_FloatTime() - start) > 3.0)
+ if ((Sys_DoubleTime() - start) > 3.0)
break;
}
while (count);
host_frametime = (1.0 / host_minfps.value);
}
- host_frametime *= slowmo.value;
- cl.frametime = host_frametime;
+ cl.frametime = host_frametime = bound(0, host_frametime * slowmo.value, 0.1f); // LordHavoc: the QC code relies on no less than 10fps
return true;
}
// update video
if (host_speeds.value)
- time1 = Sys_FloatTime ();
+ time1 = Sys_DoubleTime ();
SCR_UpdateScreen ();
if (host_speeds.value)
- time2 = Sys_FloatTime ();
+ time2 = Sys_DoubleTime ();
// update audio
if (cls.signon == SIGNONS)
if (host_speeds.value)
{
pass1 = (time1 - time3)*1000000;
- time3 = Sys_FloatTime ();
+ time3 = Sys_DoubleTime ();
pass2 = (time2 - time1)*1000000;
pass3 = (time3 - time2)*1000000;
Con_Printf ("%6ius total %6ius server %6ius gfx %6ius snd\n",
return;
}
- time1 = Sys_FloatTime ();
+ time1 = Sys_DoubleTime ();
_Host_Frame (time);
- time2 = Sys_FloatTime ();
+ time2 = Sys_DoubleTime ();
timetotal += time2 - time1;
timecount++;
if (cls.state != ca_dedicated)
{
- Palette_Init("gfx/palette.lmp");
+ VID_InitCvars();
+
+ Gamma_Init();
+
+ Palette_Init();
#ifndef _WIN32 // on non win32, mouse comes before video for security reasons
IN_Init ();
pr_global_struct->self = EDICT_TO_PROG(sv_player);
PR_ExecuteProgram (pr_global_struct->ClientConnect, "QC function ClientConnect is missing");
- if ((Sys_FloatTime() - host_client->netconnection->connecttime) <= sv.time)
+ if ((Sys_DoubleTime() - host_client->netconnection->connecttime) <= sv.time)
Sys_Printf ("%s entered the game\n", host_client->name);
PR_ExecuteProgram (pr_global_struct->PutClientInServer, "QC function PutClientInServer is missing");
{
while (pixels--)
{
- out[0] = qgamma[in[0]];
- out[1] = qgamma[in[1]];
- out[2] = qgamma[in[2]];
- out[3] = in[3] ;
+ out[0] = texgamma[in[0]];
+ out[1] = texgamma[in[1]];
+ out[2] = texgamma[in[2]];
+ out[3] = in[3] ;
in += 4;
out += 4;
}
void IN_Move(usercmd_t *cmd)
{
+ int mouselook = (in_mlook.state & 1) || freelook.value;
if (!UseMouse) return;
/* Poll mouse values */
while (mouse_update())
;
- if (m_filter.value) {
+ if (m_filter.value)
+ {
mouse_x = (mx + old_mouse_x) * 0.5;
mouse_y = (my + old_mouse_y) * 0.5;
- } else {
+ }
+ else
+ {
mouse_x = mx;
mouse_y = my;
}
mouse_y *= sensitivity.value;
/* Add mouse X/Y movement to cmd */
- if ( (in_strafe.state & 1) ||
- (lookstrafe.value && (in_mlook.state & 1) )) {
+ if ( (in_strafe.state & 1) || (lookstrafe.value && mouselook))
cmd->sidemove += m_side.value * mouse_x;
- } else {
+ else
cl.viewangles[YAW] -= m_yaw.value * mouse_x;
- }
- if ((in_mlook.state & 1)) V_StopPitchDrift();
+ if (mouselook) V_StopPitchDrift();
// LordHavoc: changed limits on pitch from -70 to 80, to -90 to 90
- if ((in_mlook.state & 1) && !(in_strafe.state & 1)) {
+ if (mouselook && !(in_strafe.state & 1))
+ {
cl.viewangles[PITCH] += m_pitch.value * mouse_y;
- if (cl.viewangles[PITCH] > 90) {
+ if (cl.viewangles[PITCH] > 90)
cl.viewangles[PITCH] = 90;
- }
- if (cl.viewangles[PITCH] < -90) {
+ if (cl.viewangles[PITCH] < -90)
cl.viewangles[PITCH] = -90;
- }
- } else {
- if ((in_strafe.state & 1) && noclip_anglehack) {
+ }
+ else
+ {
+ if ((in_strafe.state & 1) && noclip_anglehack)
cmd->upmove -= m_forward.value * mouse_y;
- } else {
+ else
cmd->forwardmove -= m_forward.value * mouse_y;
- }
}
}
qboolean mouseactive;
qboolean mouseinitialized;
static qboolean mouseparmsvalid, mouseactivatetoggle;
-static qboolean mouseshowtoggle = 1;
+//static qboolean mouseshowtoggle = 1;
static qboolean dinput_acquired;
static unsigned int mstate_di;
*/
void IN_ShowMouse (void)
{
-
- if (!mouseshowtoggle)
- {
+// if (!mouseshowtoggle)
+// {
ShowCursor (true);
- mouseshowtoggle = 1;
- }
+// mouseshowtoggle = 1;
+// }
}
*/
void IN_HideMouse (void)
{
-
- if (mouseshowtoggle)
- {
+// if (mouseshowtoggle)
+// {
ShowCursor (false);
- mouseshowtoggle = 0;
- }
+// mouseshowtoggle = 0;
+// }
}
SetCursorPos (window_center_x, window_center_y);
SetCapture (mainwindow);
ClipCursor (&window_rect);
+
}
mouseactive = true;
}
-/*
-===========
-IN_SetQuakeMouseState
-===========
-*/
-void IN_SetQuakeMouseState (void)
-{
- if (mouseactivatetoggle)
- IN_ActivateMouse ();
-}
-
-
/*
===========
IN_DeactivateMouse
}
-/*
-===========
-IN_RestoreOriginalMouseState
-===========
-*/
-void IN_RestoreOriginalMouseState (void)
-{
- if (mouseactivatetoggle)
- {
- IN_DeactivateMouse ();
- mouseactivatetoggle = true;
- }
-
-// try to redraw the cursor so it gets reinitialized, because sometimes it
-// has garbage after the mode switch
- ShowCursor (true);
- ShowCursor (false);
-}
-
-
/*
===========
IN_InitDInput
*/
void IN_Shutdown (void)
{
-
+// usingmouse = false;
IN_DeactivateMouse ();
IN_ShowMouse ();
*/
void IN_MouseMove (usercmd_t *cmd)
{
- int mx, my;
- int i;
+ int i, mx, my, mouselook = (in_mlook.state & 1) || freelook.value;
DIDEVICEOBJECTDATA od;
DWORD dwElements;
HRESULT hr;
mouse_y *= sensitivity.value;
// add mouse X/Y movement to cmd
- if ( (in_strafe.state & 1) || (lookstrafe.value && (in_mlook.state & 1) ))
+ if ( (in_strafe.state & 1) || (lookstrafe.value && mouselook))
cmd->sidemove += m_side.value * mouse_x;
else
cl.viewangles[YAW] -= m_yaw.value * mouse_x;
- if (in_mlook.state & 1)
+ if (mouselook)
V_StopPitchDrift ();
// LordHavoc: changed limits on pitch from -70 to 80, to -90 to 90
- if ( (in_mlook.state & 1) && !(in_strafe.state & 1))
+ if (mouselook && !(in_strafe.state & 1))
{
cl.viewangles[PITCH] += m_pitch.value * mouse_y;
if (cl.viewangles[PITCH] > 90)
{
float speed, aspeed;
float fAxisValue, fTemp;
- int i;
+ int i, mouselook = (in_mlook.state & 1) || freelook.value;
// complete initialization if first time in
// this is needed as cvars are not available at initialization time
switch (dwAxisMap[i])
{
case AxisForward:
- if ((joy_advanced.value == 0.0) && (in_mlook.state & 1))
+ if ((joy_advanced.value == 0.0) && mouselook)
{
// user wants forward control to become look control
if (fabs(fAxisValue) > joy_pitchthreshold.value)
break;
case AxisTurn:
- if ((in_strafe.state & 1) || (lookstrafe.value && (in_mlook.state & 1)))
+ if ((in_strafe.state & 1) || (lookstrafe.value && mouselook))
{
// user wants turn control to become side control
if (fabs(fAxisValue) > joy_sidethreshold.value)
break;
case AxisLook:
- if (in_mlook.state & 1)
+ if (mouselook)
{
if (fabs(fAxisValue) > joy_pitchthreshold.value)
{
#LDFLAGS= -L/usr/X11R6/lib -lm -lX11 -lXext -lXIE -lXxf86dga -lXxf86vm -lGL -ldl
LDFLAGS= -L/usr/X11R6/lib -lm -lX11 -lXext -lXIE -lXxf86dga -lXxf86vm -lGL -ldl -lasound
+#most people can't build the -3dfx version (-3dfx version needs some updates for new mesa)
all: darkplaces-glx
#all: darkplaces-glx darkplaces-3dfx
//=============================================================================
/* OPTIONS MENU */
-#ifdef _WIN32
-#define OPTIONS_ITEMS 14
-#else
-#define OPTIONS_ITEMS 13
-#endif
+#define OPTIONS_ITEMS 21
#define SLIDER_RANGE 10
key_dest = key_menu;
m_state = m_options;
m_entersound = true;
-
-#ifdef _WIN32
- if ((options_cursor == 13) && (modestate != MS_WINDOWED))
- {
- options_cursor = 0;
- }
-#endif
}
switch (options_cursor)
{
case 3: // screen size
- scr_viewsize.value += dir * 10;
- if (scr_viewsize.value < 30)
- scr_viewsize.value = 30;
- if (scr_viewsize.value > 120)
- scr_viewsize.value = 120;
- Cvar_SetValue ("viewsize", scr_viewsize.value);
- break;
- case 4: // brightness
- brightness.value += dir * 0.25;
- if (brightness.value < 1)
- brightness.value = 1;
- if (brightness.value > 5)
- brightness.value = 5;
- Cvar_SetValue ("brightness", brightness.value);
- break;
- case 5: // mouse speed
- sensitivity.value += dir * 0.5;
- if (sensitivity.value < 1)
- sensitivity.value = 1;
- if (sensitivity.value > 50)
- sensitivity.value = 50;
- Cvar_SetValue ("sensitivity", sensitivity.value);
- break;
- case 6: // music volume
+ Cvar_SetValue ("viewsize", bound(30, scr_viewsize.value + dir * 10, 120));
+ break;
+
+ case 4: // overbright rendering
+ Cvar_SetValue ("gl_lightmode", !gl_lightmode.value);
+ break;
+
+ case 5: // hardware gamma
+ Cvar_SetValue ("vid_gamma", bound(1, vid_gamma.value + dir * 0.25, 5));
+ break;
+ case 6: // hardware brightness
+ Cvar_SetValue ("vid_brightness", bound(1, vid_brightness.value + dir * 0.25, 5));
+ break;
+ case 7: // hardware contrast
+ Cvar_SetValue ("vid_contrast", bound(0.2, vid_contrast.value + dir * 0.08, 1));
+ break;
+ case 8: // software brightness
+ Cvar_SetValue ("r_brightness", bound(1, r_brightness.value + dir * 0.25, 5));
+ break;
+ case 9: // software base brightness
+ Cvar_SetValue ("r_contrast", bound(0.2, r_contrast.value + dir * 0.08, 1));
+ break;
+ case 10: // music volume
#ifdef _WIN32
bgmvolume.value += dir * 1.0;
#else
bgmvolume.value += dir * 0.1;
#endif
- if (bgmvolume.value < 0)
- bgmvolume.value = 0;
- if (bgmvolume.value > 1)
- bgmvolume.value = 1;
- Cvar_SetValue ("bgmvolume", bgmvolume.value);
- break;
- case 7: // sfx volume
- volume.value += dir * 0.1;
- if (volume.value < 0)
- volume.value = 0;
- if (volume.value > 1)
- volume.value = 1;
- Cvar_SetValue ("volume", volume.value);
- break;
-
- case 8: // always run
+ Cvar_SetValue ("bgmvolume", bound(1, bgmvolume.value, 5));
+ break;
+ case 11: // sfx volume
+ Cvar_SetValue ("volume", bound(1, volume.value + dir * 0.1, 5));
+ break;
+
+ case 12: // always run
if (cl_forwardspeed.value > 200)
{
Cvar_SetValue ("cl_forwardspeed", 200);
}
break;
- case 9: // invert mouse
- Cvar_SetValue ("m_pitch", -m_pitch.value);
- break;
-
- case 10: // lookspring
+ case 13: // lookspring
Cvar_SetValue ("lookspring", !lookspring.value);
break;
- case 11: // lookstrafe
+ case 14: // lookstrafe
Cvar_SetValue ("lookstrafe", !lookstrafe.value);
break;
-#ifdef _WIN32
- case 13: // _windowed_mouse
- Cvar_SetValue ("_windowed_mouse", !_windowed_mouse.value);
+ case 15: // mouse speed
+ Cvar_SetValue ("sensitivity", bound(1, sensitivity.value + dir * 0.5, 50));
+ break;
+
+ case 16: // mouse look
+ Cvar_SetValue ("freelook", !freelook.value);
+ break;
+
+ case 17: // invert mouse
+ Cvar_SetValue ("m_pitch", -m_pitch.value);
+ break;
+
+ case 18: // windowed mouse
+ Cvar_SetValue ("vid_mouse", !vid_mouse.value);
+ break;
+
+ case 19:
+ Cvar_SetValue ("crosshair", bound(0, crosshair.value + dir, 5));
break;
-#endif
}
}
void M_Options_Draw (void)
{
- float r;
+ float y;
qpic_t *p;
- M_DrawPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
- p = Draw_CachePic ("gfx/p_option.lmp");
- M_DrawPic ( (320-p->width)/2, 4, p);
-
- M_Print (16, 32, " Customize controls");
- M_Print (16, 40, " Go to console");
- M_Print (16, 48, " Reset to defaults");
-
- M_Print (16, 56, " Screen size");
- r = (scr_viewsize.value - 30) / (120 - 30);
- M_DrawSlider (220, 56, r);
-
- M_Print (16, 64, " Brightness");
- r = (brightness.value - 1) / 4;
- M_DrawSlider (220, 64, r);
-
- M_Print (16, 72, " Mouse Speed");
- r = (sensitivity.value - 1)/50;
- M_DrawSlider (220, 72, r);
-
- M_Print (16, 80, " CD Music Volume");
- r = bgmvolume.value;
- M_DrawSlider (220, 80, r);
-
- M_Print (16, 88, " Sound Volume");
- r = volume.value;
- M_DrawSlider (220, 88, r);
-
- M_Print (16, 96, " Always Run");
- M_DrawCheckbox (220, 96, cl_forwardspeed.value > 200);
-
- M_Print (16, 104, " Invert Mouse");
- M_DrawCheckbox (220, 104, m_pitch.value < 0);
-
- M_Print (16, 112, " Lookspring");
- M_DrawCheckbox (220, 112, lookspring.value);
-
- M_Print (16, 120, " Lookstrafe");
- M_DrawCheckbox (220, 120, lookstrafe.value);
-
- if (vid_menudrawfn)
- M_Print (16, 128, " Video Options");
-
-#ifdef _WIN32
- if (modestate == MS_WINDOWED)
- {
- M_Print (16, 136, " Use Mouse");
- M_DrawCheckbox (220, 136, _windowed_mouse.value);
- }
-#endif
-
-// cursor
- M_DrawCharacter (200, 32 + options_cursor*8, 12+((int)(realtime*4)&1));
+ M_DrawPic(16, 4, Draw_CachePic("gfx/qplaque.lmp") );
+ p = Draw_CachePic("gfx/p_option.lmp");
+ M_DrawPic((320-p->width)/2, 4, p);
+
+ y = 32;
+ M_Print(16, y, " Customize controls");y += 8;
+ M_Print(16, y, " Go to console");y += 8;
+ M_Print(16, y, " Reset to defaults");y += 8;
+ M_Print(16, y, " Screen size");M_DrawSlider(220, y, (scr_viewsize.value - 30) /(120 - 30));y += 8;
+ M_Print(16, y, " Overbright Rendering");M_DrawCheckbox(220, y, gl_lightmode.value);y += 8;
+ M_Print(16, y, " Hardware Gamma");M_DrawSlider(220, y, (vid_gamma.value - 1) / 4);y += 8;
+ M_Print(16, y, " Hardware Brightness");M_DrawSlider(220, y, (vid_brightness.value - 1) / 4);y += 8;
+ M_Print(16, y, " Hardware Contrast");M_DrawSlider(220, y, (vid_contrast.value - 0.2) / 0.8);y += 8;
+ M_Print(16, y, " Software Brightness");M_DrawSlider(220, y, (r_brightness.value - 1) / 4);y += 8;
+ M_Print(16, y, " Software Contrast");M_DrawSlider(220, y, (r_contrast.value - 0.2) / 0.8);y += 8;
+ M_Print(16, y, " CD Music Volume");M_DrawSlider(220, y, bgmvolume.value);y += 8;
+ M_Print(16, y, " Sound Volume");M_DrawSlider(220, y, volume.value);y += 8;
+ M_Print(16, y, " Always Run");M_DrawCheckbox(220, y, cl_forwardspeed.value > 200);y += 8;
+ M_Print(16, y, " Lookspring");M_DrawCheckbox(220, y, lookspring.value);y += 8;
+ M_Print(16, y, " Lookstrafe");M_DrawCheckbox(220, y, lookstrafe.value);y += 8;
+ M_Print(16, y, " Mouse Speed");M_DrawSlider(220, y, (sensitivity.value - 1)/50);y += 8;
+ M_Print(16, y, " Mouse Look");M_DrawCheckbox(220, y, freelook.value);y += 8;
+ M_Print(16, y, " Invert Mouse");M_DrawCheckbox(220, y, m_pitch.value < 0);y += 8;
+ M_Print(16, y, " Use Mouse");M_DrawCheckbox(220, y, vid_mouse.value);y += 8;
+ M_Print(16, y, " Crosshair");M_DrawSlider(220, y, crosshair.value / 5);y += 8;
+ M_Print(16, y, " Video Options");y += 8;
+
+ // cursor
+ M_DrawCharacter(200, 32 + options_cursor*8, 12+((int)(realtime*4)&1));
}
case 2:
Cbuf_AddText ("exec default.cfg\n");
break;
- case 12:
+ case 20:
M_Menu_Video_f ();
break;
default:
M_AdjustSliders (1);
break;
}
-
- if (options_cursor == 12 && vid_menudrawfn == NULL)
- {
- if (k == K_UPARROW)
- options_cursor = 11;
- else
- options_cursor = 0;
- }
-
-#ifdef _WIN32
- if ((options_cursor == 13) && (modestate != MS_WINDOWED))
- {
- if (k == K_UPARROW)
- options_cursor = 12;
- else
- options_cursor = 0;
- }
-#endif
}
//=============================================================================
}
mod->ofs_scenes = (int) animscenes - pbase;
-// zymlump_t lump_poses; // float pose[numposes][numbones][6]; // animation data
+// zymlump_t lump_poses; // float pose[numposes][numbones][3][4]; // animation data
swapintblock((void *) (pheader->lump_poses.start + pbase), pheader->lump_poses.length);
// zymlump_t lump_bones; // zymbone_t bone[numbones];
// zymlump_t lump_texcoords; // float texcoords[numvertices][2];
swapintblock((void *) (pheader->lump_texcoords.start + pbase), pheader->lump_texcoords.length);
-// zymlump_t lump_render; // int renderlist[rendersize]; // sorted by shader with run lengths (int shader, count), each run can be used with glDrawElements (each triangle is 3 int indices)
+// zymlump_t lump_render; // int renderlist[rendersize]; // sorted by shader with run lengths (int count), shaders are sequentially used, each run can be used with glDrawElements (each triangle is 3 int indices)
swapintblock((void *) (pheader->lump_render.start + pbase), pheader->lump_render.length);
// zymlump_t lump_shaders; // char shadername[numshaders][32]; // shaders used on this model
out->compressed_vis = NULL;
else
out->compressed_vis = loadmodel->visdata + p;
-// out->efrags = NULL;
for (j=0 ; j<4 ; j++)
out->ambient_sound_level[j] = in->ambient_level[j];
int dlightframe;
byte *compressed_vis;
-// efrag_t *efrags;
msurface_t **firstmarksurface;
int nummarksurfaces;
zymlump_t lump_vertbonecounts; // int vertbonecounts[numvertices]; // how many bones influence each vertex (separate mainly to make this compress better)
zymlump_t lump_verts; // zymvertex_t vert[numvertices]; // see vertex struct
zymlump_t lump_texcoords; // float texcoords[numvertices][2];
- zymlump_t lump_render; // int renderlist[rendersize]; // sorted by shader with run lengths (int shader, count), each run can be used with glDrawElements (each triangle is 3 int indices)
+ zymlump_t lump_render; // int renderlist[rendersize]; // sorted by shader with run lengths (int count), shaders are sequentially used, each run can be used with glDrawElements (each triangle is 3 int indices)
zymlump_t lump_shaders; // char shadername[numshaders][32]; // shaders used on this model
zymlump_t lump_trizone; // byte trizone[numtris]; // see trizone explanation
}
bufferLength = &((qsocket_t *)sock->driverdata)->receiveMessageLength;
if ((*bufferLength + data->cursize + 4) > NET_MAXMESSAGE)
- Sys_Error("Loop_SendMessage: overflow\n");
+ Host_Error("Loop_SendMessage: overflow\n");
buffer = ((qsocket_t *)sock->driverdata)->receiveMessage + *bufferLength;
double SetNetTime(void)
{
- net_time = Sys_FloatTime();
+ net_time = Sys_DoubleTime();
return net_time;
}
}
slistInProgress = true;
- slistStartTime = Sys_FloatTime();
+ slistStartTime = Sys_DoubleTime();
SchedulePollProcedure(&slistSendProcedure, 0.0);
SchedulePollProcedure(&slistPollProcedure, 0.1);
dfunc.SearchForHosts (true);
}
- if ((Sys_FloatTime() - slistStartTime) < 0.5)
+ if ((Sys_DoubleTime() - slistStartTime) < 0.5)
SchedulePollProcedure(&slistSendProcedure, 0.75);
}
if (! slistSilent)
PrintSlist();
- if ((Sys_FloatTime() - slistStartTime) < 1.5)
+ if ((Sys_DoubleTime() - slistStartTime) < 1.5)
{
SchedulePollProcedure(&slistPollProcedure, 0.1);
return;
}
}
- start = Sys_FloatTime();
+ start = Sys_DoubleTime();
while (count)
{
count = 0;
continue;
}
}
- if ((Sys_FloatTime() - start) > blocktime)
+ if ((Sys_DoubleTime() - start) > blocktime)
break;
}
return count;
{
PollProcedure *pp, *prev;
- proc->nextTime = Sys_FloatTime() + timeOffset;
+ proc->nextTime = Sys_DoubleTime() + timeOffset;
for (pp = pollProcedureList, prev = NULL; pp; pp = pp->next)
{
if (pp->nextTime >= proc->nextTime)
MSG msg;
BOOL ret;
- if ((Sys_FloatTime() - blocktime) > 2.0)
+ if ((Sys_DoubleTime() - blocktime) > 2.0)
{
WSACancelBlockingCall();
return false;
if (pgethostname(buff, MAXHOSTNAMELEN) == SOCKET_ERROR)
return;
- blocktime = Sys_FloatTime();
+ blocktime = Sys_DoubleTime();
WSASetBlockingHook(BlockingHook);
local = pgethostbyname(buff);
WSAUnhookBlockingHook();
unsigned int d_8to24table[256];
//byte d_15to8table[32768];
byte host_basepal[768];
-byte qgamma[256];
-static float vid_gamma = 1.0;
+byte texgamma[256];
+
+static float texture_gamma = 1.0;
+
+cvar_t vid_gamma = {"vid_gamma", "1", true};
+cvar_t vid_brightness = {"vid_brightness", "1", true};
+cvar_t vid_contrast = {"vid_contrast", "1", true};
void Palette_Setup8to24()
{
}
*/
-void Palette_Gamma ()
+void BuildGammaTable8(float prescale, float gamma, float scale, float base, byte *out)
+{
+ int i, adjusted;
+ double invgamma, d;
+
+ gamma = bound(0.1, gamma, 5.0);
+ if (gamma == 1) // LordHavoc: dodge the math
+ {
+ for (i = 0;i < 256;i++)
+ {
+ adjusted = (int) (i * prescale * scale + base * 255.0);
+ out[i] = bound(0, adjusted, 255);
+ }
+ }
+ else
+ {
+ invgamma = 1.0 / gamma;
+ prescale /= 255.0f;
+ for (i = 0;i < 256;i++)
+ {
+ d = pow((double) i * prescale, invgamma) * scale + base;
+ adjusted = (int) (255.0 * d);
+ out[i] = bound(0, adjusted, 255);
+ }
+ }
+}
+
+void BuildGammaTable16(float prescale, float gamma, float scale, float base, unsigned short *out)
{
- float inf;
- int i;
+ int i, adjusted;
+ double invgamma, d;
- vid_gamma = 1;
+ gamma = bound(0.1, gamma, 5.0);
+ if (gamma == 1) // LordHavoc: dodge the math
+ {
+ for (i = 0;i < 256;i++)
+ {
+ adjusted = (int) (i * 256.0 * prescale * scale + base * 65535.0);
+ out[i] = bound(0, adjusted, 65535);
+ }
+ }
+ else
+ {
+ invgamma = 1.0 / gamma;
+ prescale /= 255.0f;
+ for (i = 0;i < 256;i++)
+ {
+ d = pow((double) i * prescale, invgamma) * scale + base;
+ adjusted = (int) (65535.0 * d);
+ out[i] = bound(0, adjusted, 65535);
+ }
+ }
+}
+
+void Texture_Gamma ()
+{
+ int i, adjusted;
+ double invgamma;
+
+ texture_gamma = 1;
if ((i = COM_CheckParm("-gamma")))
- vid_gamma = atof(com_argv[i+1]);
+ texture_gamma = atof(com_argv[i+1]);
+ texture_gamma = bound(0.1, texture_gamma, 5.0);
- if (vid_gamma == 1) // LordHavoc: dodge the math
+ if (texture_gamma == 1) // LordHavoc: dodge the math
{
for (i = 0;i < 256;i++)
- qgamma[i] = i;
+ texgamma[i] = i;
}
else
{
+ invgamma = 1.0 / texture_gamma;
for (i = 0;i < 256;i++)
{
- inf = pow((i+1)/256.0, vid_gamma)*255 + 0.5;
- if (inf < 0) inf = 0;
- if (inf > 255) inf = 255;
- qgamma[i] = inf;
+ adjusted = (int) ((255.0 * pow((double) i / 255.0, invgamma)) + 0.5);
+ texgamma[i] = bound(0, adjusted, 255);
}
}
}
+qboolean hardwaregammasupported = false;
+void VID_UpdateGamma(qboolean force)
+{
+ static float cachegamma = -1, cachebrightness = -1, cachecontrast = -1, cachelighthalf = -1;
+ if (!force && vid_gamma.value == cachegamma && vid_brightness.value == cachebrightness && vid_contrast.value == cachecontrast && lighthalf == cachelighthalf)
+ return;
+
+ if (vid_gamma.value < 0.1)
+ Cvar_SetValue("vid_gamma", 0.1);
+ if (vid_gamma.value > 5.0)
+ Cvar_SetValue("vid_gamma", 5.0);
+
+ if (vid_brightness.value < 1.0)
+ Cvar_SetValue("vid_brightness", 1.0);
+ if (vid_brightness.value > 5.0)
+ Cvar_SetValue("vid_brightness", 5.0);
+
+ if (vid_contrast.value < 0.2)
+ Cvar_SetValue("vid_contrast", 0.2);
+ if (vid_contrast.value > 1)
+ Cvar_SetValue("vid_contrast", 1);
+
+ cachegamma = vid_gamma.value;
+ cachebrightness = vid_brightness.value;
+ cachecontrast = vid_contrast.value;
+ cachelighthalf = lighthalf;
+
+ hardwaregammasupported = VID_SetGamma((cachelighthalf ? 2.0f : 1.0f), cachegamma, cachebrightness * cachecontrast, 1 - cachecontrast);
+ if (!hardwaregammasupported)
+ Con_Printf("Hardware gamma not supported.\n");
+}
+
+void Gamma_Init()
+{
+ Cvar_RegisterVariable(&vid_gamma);
+ Cvar_RegisterVariable(&vid_brightness);
+ Cvar_RegisterVariable(&vid_contrast);
+}
+
void Palette_Init()
{
byte *pal;
host_basepal[765] = host_basepal[766] = host_basepal[767] = 0; // LordHavoc: force the transparent color to black
Palette_Setup8to24();
// Palette_Setup15to8();
- Palette_Gamma();
+ Texture_Gamma();
}
+extern cvar_t vid_gamma;
+extern cvar_t vid_brightness;
+extern cvar_t vid_contrast;
+
extern unsigned int d_8to24table[256];
//extern byte d_15to8table[32768];
-extern byte host_basepal[768];
-extern byte qgamma[256];
-extern float vid_gamma;
+extern byte texgamma[256];
+
+extern qboolean hardwaregammasupported;
+
+void VID_UpdateGamma(qboolean force);
+
+// used by hardware gamma functions in vid_* files
+void BuildGammaTable8(float prescale, float gamma, float scale, float base, byte *out);
+void BuildGammaTable16(float prescale, float gamma, float scale, float base, unsigned short *out);
+void Gamma_Init();
void Palette_Init();
DP_SPRITE32 \
DP_SV_DRAWONLYTOCLIENT \
DP_SV_NODRAWTOCLIENT \
+DP_SV_EXTERIORMODELTOCLIENT \
DP_SV_SETCOLOR \
DP_SV_EFFECT \
DP_TE_BLOOD \
char *samp;
float *pos;
float vol, attenuation;
- int i, soundnum;
+ int i, soundnum, large;
pos = G_VECTOR (OFS_PARM0);
samp = G_STRING(OFS_PARM1);
return;
}
-// add an svc_spawnambient command to the level signon packet
+ large = false;
+ if (soundnum >= 256)
+ large = true;
+
+ // add an svc_spawnambient command to the level signon packet
+
+ if (large)
+ MSG_WriteByte (&sv.signon, svc_spawnstaticsound2);
+ else
+ MSG_WriteByte (&sv.signon, svc_spawnstaticsound);
- MSG_WriteByte (&sv.signon,svc_spawnstaticsound);
for (i=0 ; i<3 ; i++)
MSG_WriteFloatCoord(&sv.signon, pos[i]);
- MSG_WriteByte (&sv.signon, soundnum);
+ if (large)
+ MSG_WriteShort (&sv.signon, soundnum);
+ else
+ MSG_WriteByte (&sv.signon, soundnum);
MSG_WriteByte (&sv.signon, vol*255);
MSG_WriteByte (&sv.signon, attenuation*64);
void PF_Remove (void)
{
edict_t *ed;
-
+
ed = G_EDICT(OFS_PARM0);
+ if (ed == sv.edicts)
+ PR_RunError("remove: tried to remove world\n");
+ if (NUM_FOR_EDICT(ed) <= svs.maxclients)
+ PR_RunError("remove: tried to remove a client\n");
ED_Free (ed);
}
void PF_makestatic (void)
{
edict_t *ent;
- int i;
+ int i, large;
ent = G_EDICT(OFS_PARM0);
- i = SV_ModelIndex(pr_strings + ent->v.model);
- if (i >= 256)
+ large = false;
+ if (ent->v.modelindex >= 256 || ent->v.frame >= 256)
+ large = true;
+
+ if (large)
{
MSG_WriteByte (&sv.signon,svc_spawnstatic2);
- MSG_WriteShort (&sv.signon, i);
+ MSG_WriteShort (&sv.signon, ent->v.modelindex);
+ MSG_WriteShort (&sv.signon, ent->v.frame);
}
else
{
MSG_WriteByte (&sv.signon,svc_spawnstatic);
- MSG_WriteByte (&sv.signon, i);
+ MSG_WriteByte (&sv.signon, ent->v.modelindex);
+ MSG_WriteByte (&sv.signon, ent->v.frame);
}
- MSG_WriteByte (&sv.signon, ent->v.frame);
MSG_WriteByte (&sv.signon, ent->v.colormap);
MSG_WriteByte (&sv.signon, ent->v.skin);
for (i=0 ; i<3 ; i++)
int eval_pitch_speed;
int eval_viewmodelforclient;
int eval_nodrawtoclient;
+int eval_exteriormodeltoclient;
int eval_drawonlytoclient;
int eval_colormod;
int eval_ping;
eval_pitch_speed = FindFieldOffset("pitch_speed");
eval_viewmodelforclient = FindFieldOffset("viewmodelforclient");
eval_nodrawtoclient = FindFieldOffset("nodrawtoclient");
+ eval_exteriormodeltoclient = FindFieldOffset("exteriormodeltoclient");
eval_drawonlytoclient = FindFieldOffset("drawonlytoclient");
eval_colormod = FindFieldOffset("colormod");
eval_ping = FindFieldOffset("ping");
return NULL;
}
-
/*
============
ED_FindGlobal
*/
char *PR_ValueString (etype_t type, eval_t *val)
{
- static char line[256];
+ static char line[1024]; // LordHavoc: enlarged a bit (was 256)
ddef_t *def;
dfunction_t *f;
sprintf (line, "void");
break;
case ev_float:
- sprintf (line, "%5.1f", val->_float);
+ // LordHavoc: changed from %5.1f to %10.4f
+ sprintf (line, "%10.4f", val->_float);
break;
case ev_vector:
- sprintf (line, "'%5.1f %5.1f %5.1f'", val->vector[0], val->vector[1], val->vector[2]);
+ // LordHavoc: changed from %5.1f to %10.4f
+ sprintf (line, "'%10.4f %10.4f %10.4f'", val->vector[0], val->vector[1], val->vector[2]);
break;
case ev_pointer:
sprintf (line, "pointer");
For debugging
=============
*/
-// LordHavoc: optimized this to print out much more quickly
+// LordHavoc: optimized this to print out much more quickly (tempstring)
void ED_Print (edict_t *ed)
{
int l;
continue;
strcat(tempstring, name);
- l = strlen (name);
- while (l++ < 15)
+ for (l = strlen(name);l < 14;l++)
strcat(tempstring, " ");
+ strcat(tempstring, " ");
strcat(tempstring, PR_ValueString(d->type, (eval_t *)v));
strcat(tempstring, "\n");
continue;
type &= ~DEF_SAVEGLOBAL;
- if (type != ev_string
- && type != ev_float
- && type != ev_entity)
+ if (type != ev_string && type != ev_float && type != ev_entity)
continue;
name = pr_strings + def->s_name;
}
+void PR_Fields_f (void)
+{
+ int i;
+ if (!sv.active)
+ {
+ Con_Printf("no progs loaded\n");
+ return;
+ }
+ for (i = 0;i < progs->numfielddefs;i++)
+ Con_Printf("%s\n", (pr_strings + pr_fielddefs[i].s_name));
+ Con_Printf("%i entity fields, totalling %i bytes per edict, %i edicts, %i bytes total spent on edict fields\n", progs->entityfields, progs->entityfields * 4, MAX_EDICTS, progs->entityfields * 4 * MAX_EDICTS);
+}
+
+void PR_Globals_f (void)
+{
+ int i;
+ if (!sv.active)
+ {
+ Con_Printf("no progs loaded\n");
+ return;
+ }
+ for (i = 0;i < progs->numglobaldefs;i++)
+ Con_Printf("%s\n", (pr_strings + pr_globaldefs[i].s_name));
+ Con_Printf("%i global variables, totalling %i bytes\n", progs->numglobals, progs->numglobals * 4);
+}
+
/*
===============
PR_Init
Cmd_AddCommand ("edicts", ED_PrintEdicts);
Cmd_AddCommand ("edictcount", ED_Count);
Cmd_AddCommand ("profile", PR_Profile_f);
+ Cmd_AddCommand ("pr_fields", PR_Fields_f);
+ Cmd_AddCommand ("pr_globals", PR_Globals_f);
Cvar_RegisterVariable (&pr_checkextension);
Cvar_RegisterVariable (&nomonsters);
Cvar_RegisterVariable (&gamecfg);
extern int eval_pitch_speed;
extern int eval_viewmodelforclient;
extern int eval_nodrawtoclient;
+extern int eval_exteriormodeltoclient;
extern int eval_drawonlytoclient;
extern int eval_colormod;
extern int eval_ping;
--- /dev/null
+
+#include "quakedef.h"
+
+void ClearStateToDefault(entity_state_t *s)
+{
+ s->time = 0;
+ VectorClear(s->origin);
+ VectorClear(s->angles);
+ s->effects = 0;
+ s->modelindex = 0;
+ s->frame = 0;
+ s->colormap = 0;
+ s->skin = 0;
+ s->alpha = 255;
+ s->scale = 16;
+ s->glowsize = 0;
+ s->glowcolor = 254;
+ s->colormod = 255;
+ s->flags = 0;
+ s->active = 0;
+}
+
#define EF_STEP 0x80000000 // internal client use only - present on MOVETYPE_STEP entities, not QC accessible (too many bits)
// if the high bit of the servercmd is set, the low bits are fast update flags:
-#define U_MOREBITS (1<<0)
-#define U_ORIGIN1 (1<<1)
-#define U_ORIGIN2 (1<<2)
-#define U_ORIGIN3 (1<<3)
-#define U_ANGLE2 (1<<4)
+#define U_MOREBITS (1<<0)
+#define U_ORIGIN1 (1<<1)
+#define U_ORIGIN2 (1<<2)
+#define U_ORIGIN3 (1<<3)
+#define U_ANGLE2 (1<<4)
// LordHavoc: U_NOLERP was only ever used for monsters, so I renamed it U_STEP
-#define U_STEP (1<<5)
-#define U_FRAME (1<<6)
+#define U_STEP (1<<5)
+#define U_FRAME (1<<6)
// just differentiates from other updates
-#define U_SIGNAL (1<<7)
+#define U_SIGNAL (1<<7)
-// svc_update can pass all of the fast update bits, plus more
-#define U_ANGLE1 (1<<8)
-#define U_ANGLE3 (1<<9)
-#define U_MODEL (1<<10)
-#define U_COLORMAP (1<<11)
-#define U_SKIN (1<<12)
-#define U_EFFECTS (1<<13)
-#define U_LONGENTITY (1<<14)
+#define U_ANGLE1 (1<<8)
+#define U_ANGLE3 (1<<9)
+#define U_MODEL (1<<10)
+#define U_COLORMAP (1<<11)
+#define U_SKIN (1<<12)
+#define U_EFFECTS (1<<13)
+#define U_LONGENTITY (1<<14)
// LordHavoc: protocol extension
-#define U_EXTEND1 (1<<15)
+#define U_EXTEND1 (1<<15)
// LordHavoc: first extend byte
-#define U_DELTA (1<<16) // no data, while this is set the entity is delta compressed (uses previous frame as a baseline, meaning only things that have changed from the previous frame are sent, except for the forced full update every half second)
-#define U_ALPHA (1<<17) // 1 byte, 0.0-1.0 maps to 0-255, not sent if exactly 1, and the entity is not sent if <=0 unless it has effects (model effects are checked as well)
-#define U_SCALE (1<<18) // 1 byte, scale / 16 positive, not sent if 1.0
-#define U_EFFECTS2 (1<<19) // 1 byte, this is .effects & 0xFF00 (second byte)
-#define U_GLOWSIZE (1<<20) // 1 byte, encoding is float/8.0, signed (negative is darklight), not sent if 0
-#define U_GLOWCOLOR (1<<21) // 1 byte, palette index, default is 254 (white), this IS used for darklight (allowing colored darklight), however the particles from a darklight are always black, not sent if default value (even if glowsize or glowtrail is set)
-#define U_COLORMOD (1<<22) // 1 byte, 3 bit red, 3 bit green, 2 bit blue, this lets you tint an object artifically, so you could make a red rocket, or a blue fiend...
-#define U_EXTEND2 (1<<23) // another byte to follow
+#define U_DELTA (1<<16) // no data, while this is set the entity is delta compressed (uses previous frame as a baseline, meaning only things that have changed from the previous frame are sent, except for the forced full update every half second)
+#define U_ALPHA (1<<17) // 1 byte, 0.0-1.0 maps to 0-255, not sent if exactly 1, and the entity is not sent if <=0 unless it has effects (model effects are checked as well)
+#define U_SCALE (1<<18) // 1 byte, scale / 16 positive, not sent if 1.0
+#define U_EFFECTS2 (1<<19) // 1 byte, this is .effects & 0xFF00 (second byte)
+#define U_GLOWSIZE (1<<20) // 1 byte, encoding is float/8.0, signed (negative is darklight), not sent if 0
+#define U_GLOWCOLOR (1<<21) // 1 byte, palette index, default is 254 (white), this IS used for darklight (allowing colored darklight), however the particles from a darklight are always black, not sent if default value (even if glowsize or glowtrail is set)
+#define U_COLORMOD (1<<22) // 1 byte, 3 bit red, 3 bit green, 2 bit blue, this lets you tint an object artifically, so you could make a red rocket, or a blue fiend...
+#define U_EXTEND2 (1<<23) // another byte to follow
// LordHavoc: second extend byte
-#define U_GLOWTRAIL (1<<24) // leaves a trail of particles (of color .glowcolor, or black if it is a negative glowsize)
-#define U_VIEWMODEL (1<<25) // attachs the model to the view (origin and angles become relative to it), only shown to owner, a more powerful alternative to .weaponmodel and such
-#define U_FRAME2 (1<<26) // 1 byte, this is .frame & 0xFF00 (second byte)
-#define U_MODEL2 (1<<27) // 1 byte, this is .modelindex & 0xFF00 (second byte)
-#define U_UNUSED28 (1<<28) // future expansion
-#define U_UNUSED29 (1<<29) // future expansion
-#define U_UNUSED30 (1<<30) // future expansion
-#define U_EXTEND3 (1<<31) // another byte to follow, future expansion
+#define U_GLOWTRAIL (1<<24) // leaves a trail of particles (of color .glowcolor, or black if it is a negative glowsize)
+#define U_VIEWMODEL (1<<25) // attachs the model to the view (origin and angles become relative to it), only shown to owner, a more powerful alternative to .weaponmodel and such
+#define U_FRAME2 (1<<26) // 1 byte, this is .frame & 0xFF00 (second byte)
+#define U_MODEL2 (1<<27) // 1 byte, this is .modelindex & 0xFF00 (second byte)
+#define U_EXTERIORMODEL (1<<28) // causes this model to not be drawn when using a first person view (third person will draw it, first person will not)
+#define U_UNUSED29 (1<<29) // future expansion
+#define U_UNUSED30 (1<<30) // future expansion
+#define U_EXTEND3 (1<<31) // another byte to follow, future expansion
#define SU_VIEWHEIGHT (1<<0)
#define SU_IDEALPITCH (1<<1)
#define svc_showlmp 35 // [string] slotname [string] lmpfilename [short] x [short] y
#define svc_hidelmp 36 // [string] slotname
-#define svc_unused1
+#define svc_unusedlh1
#define svc_fog 51 // unfinished
#define svc_effect 52 // [vector] org [byte] modelindex [byte] startframe [byte] framecount [byte] framerate
-#define svc_effect2 53 // [vector] org [short] modelindex [byte] startframe [byte] framecount [byte] framerate
+#define svc_effect2 53 // [vector] org [short] modelindex [short] startframe [byte] framecount [byte] framerate
#define svc_sound2 54 // short soundindex instead of byte
#define svc_spawnbaseline2 55 // short modelindex instead of byte
#define svc_spawnstatic2 56 // short modelindex instead of byte
-#define svc_entitiesbegin 57 // [short] entitynum
-#define svc_entitiesend 58 // [short] entitynum
+#define svc_unusedlh2 57
+#define svc_unusedlh3 58
+#define svc_spawnstaticsound2 59 // [coord3] [short] samp [byte] vol [byte] aten
//
// client to server
#define TE_SMALLFLASH 72 // [vector] origin
#define TE_CUSTOMFLASH 73 // [vector] origin [byte] radius / 8 - 1 [byte] lifetime / 256 - 1 [byte] red [byte] green [byte] blue
#define TE_FLAMEJET 74 // [vector] origin [vector] velocity [byte] count
+
+#define RENDER_STEP 1
+#define RENDER_GLOWTRAIL 2
+#define RENDER_VIEWMODEL 4
+#define RENDER_EXTERIORMODEL 8
+
+// LordHavoc: made this more compact, and added some more fields
+typedef struct
+{
+ double time; // time this state was updated
+ vec3_t origin;
+ vec3_t angles;
+ int effects;
+ unsigned short modelindex;
+ unsigned short frame;
+ byte colormap;
+ byte skin;
+ byte alpha;
+ byte scale;
+ byte glowsize;
+ byte glowcolor;
+ byte colormod;
+ byte flags;
+ byte active;
+} entity_state_t;
+
+void ClearStateToDefault(entity_state_t *s);
#define SOUND_CHANNELS 8
#include "common.h"
+#include "cvar.h"
#include "bspfile.h"
#include "vid.h"
#include "sys.h"
#include "wad.h"
#include "draw.h"
-#include "cvar.h"
#include "screen.h"
#include "net.h"
#include "protocol.h"
dynamiclight = (int) r_dynamic.value != 0 && (int) r_decals_lighting.value != 0;
- mindist = DotProduct(r_refdef.vieworg, vpn) + 4.0f;
+ mindist = DotProduct(r_origin, vpn) + 4.0f;
if (r_render.value)
{
continue;
// do not render if the view origin is behind the decal
- VectorSubtract(p->org, r_refdef.vieworg, v);
+ VectorSubtract(p->org, r_origin, v);
if (DotProduct(p->direction, v) < 0)
continue;
typedef struct particle_s
{
+ ptype_t type;
vec3_t org;
- float color;
vec3_t vel;
- float die;
- ptype_t type;
- float scale;
rtexture_t *tex;
byte dynlight; // if set the particle will be dynamically lit (if r_dynamicparticles is on), used for smoke and blood
byte rendermode; // a TPOLYTYPE_ value
- byte pad1;
+ byte color;
byte pad2;
+ float die;
+ float scale;
float alpha; // 0-255
float time2; // used for various things (snow fluttering, for example)
- float bounce; // how much bounce-back from a surface the particle hits (0 = no physics, 1 = stop and slide, 2 = keep bouncing forever, 1.5 is typical of bouncing particles)
+ float bounce; // how much bounce-back from a surface the particle hits (0 = no physics, 1 = stop and slide, 2 = keep bouncing forever, 1.5 is typical)
vec3_t oldorg;
vec3_t vel2; // used for snow fluttering (base velocity, wind for instance)
// vec3_t direction; // used by decals
VectorSubtract(end, start, dir);
VectorNormalize(dir);
- if (type == 0) // rocket glow
+ if (type == 0 && host_frametime != 0) // rocket glow
particle(pt_oneframe, 254, rocketglowparticletexture, TPOLYTYPE_ADD, false, 24, 255, 9999, 0, end[0] - 12 * dir[0], end[1] - 12 * dir[1], end[2] - 12 * dir[2], 0, 0, 0);
t = ent->render.trail_time;
uprightangles[2] = 0;
AngleVectors (uprightangles, NULL, right2, up2);
- minparticledist = DotProduct(r_refdef.vieworg, vpn) + 16.0f;
+ minparticledist = DotProduct(r_origin, vpn) + 16.0f;
for (i = 0, p = particles;i < numparticles;i++, p++)
{
/*
if (p->type == pt_decal)
{
- VectorSubtract(p->org, r_refdef.vieworg, v);
+ VectorSubtract(p->org, r_origin, v);
if (DotProduct(p->direction, v) < 0)
continue;
}
// refresh.h -- public interface to refresh functions
-#define MAXCLIPPLANES 11
-
#define TOP_RANGE 16 // soldier uniform colors
#define BOTTOM_RANGE 96
//=============================================================================
-typedef struct efrag_s
-{
- struct mleaf_s *leaf;
- struct efrag_s *leafnext;
- struct entity_s *entity;
- struct efrag_s *entnext;
-} efrag_t;
-
-#define RENDER_STEP 1
-#define RENDER_GLOWTRAIL 2
-#define RENDER_VIEWMODEL 4
-
-// LordHavoc: made this more compact, and added some more fields
-typedef struct
-{
- double time; // time this state was updated
- vec3_t origin;
- vec3_t angles;
- int effects;
- unsigned short modelindex;
- unsigned short frame;
- byte colormap;
- byte skin;
- byte alpha;
- byte scale;
- byte glowsize;
- byte glowcolor;
- byte colormod;
- byte flags;
- byte active;
-} entity_state_t;
-
typedef struct entity_s
{
entity_state_t state_baseline; // baseline for entity
struct model_s *model; // NULL = no model
int frame; // current desired frame (usually identical to frame2, but frame2 is not always used)
-// struct efrag_s *efrag; // linked list of efrags
int colormap;
int effects; // light, particles, etc
int skinnum; // for Alias models
int visframe; // last frame this entity was found in an active leaf
struct model_s *lerp_model; // lerp resets when model changes
- float lerp_starttime; // start of this transition
+ double lerp_starttime; // start of this transition
int frame1; // frame that the model is interpolating from
int frame2; // frame that the model is interpolating to
double framelerp; // interpolation factor, usually computed from lerp_starttime
double frame1start; // time frame1 began playing (for framegroup animations)
double frame2start; // time frame2 began playing (for framegroup animations)
-// float syncbase; // for client-side animations
int dlightframe; // dynamic lighting
int dlightbits[8];
float trail_time;
- // FIXME: could turn these into a union
-// int trivial_accept;
-// struct mnode_s *topnode; // for bmodels, first world node that splits bmodel, or NULL if not split
}
render;
} entity_t;
// LordHavoc: changed this for sake of GLQuake
void R_InitSky (byte *src, int bytesperpixel); // called at level load
-//void R_InitEfrags (void);
-//void R_AddEfrags (entity_t *ent);
-//void R_RemoveEfrags (entity_t *ent);
-//void R_StoreEfrags (efrag_t **ppefrag);
-
int R_VisibleCullBox (vec3_t mins, vec3_t maxs);
void R_NewMap (void);
//void SCR_BeginLoadingPlaque (void);
//void SCR_EndLoadingPlaque (void);
-extern float scr_con_current;
-extern float scr_conlines; // lines of console to display
+extern float scr_con_current;
+extern float scr_conlines; // lines of console to display
-extern int sb_lines;
+extern int sb_lines;
-extern int clearnotify; // set to 0 whenever notify text is drawn
-extern qboolean scr_disabled_for_loading;
-extern qboolean scr_skipupdate;
-
-extern cvar_t scr_viewsize;
+extern int clearnotify; // set to 0 whenever notify text is drawn
+extern qboolean scr_disabled_for_loading;
+extern qboolean scr_skipupdate;
extern cvar_t scr_viewsize;
+extern cvar_t r_brightness;
+extern cvar_t r_contrast;
+extern cvar_t gl_lightmode;
+extern cvar_t scr_viewsize;
+extern cvar_t crosshair;
char localmodels[MAX_MODELS][5]; // inline model names for precache
+extern cvar_t sv_deltacompress;
+
//============================================================================
/*
Cvar_RegisterVariable (&sv_aim);
Cvar_RegisterVariable (&sv_nostep);
Cvar_RegisterVariable (&sv_predict);
+ Cvar_RegisterVariable (&sv_deltacompress);
for (i=0 ; i<MAX_MODELS ; i++)
sprintf (localmodels[i], "*%i", i);
{
if (sv.datagram.cursize > MAX_DATAGRAM-18)
return;
- if (modelindex >= 256)
+ if (modelindex >= 256 || startframe >= 256)
{
MSG_WriteByte (&sv.datagram, svc_effect2);
MSG_WriteFloatCoord (&sv.datagram, org[0]);
MSG_WriteFloatCoord (&sv.datagram, org[1]);
MSG_WriteFloatCoord (&sv.datagram, org[2]);
MSG_WriteShort (&sv.datagram, modelindex);
- MSG_WriteByte (&sv.datagram, startframe);
+ MSG_WriteShort (&sv.datagram, startframe);
MSG_WriteByte (&sv.datagram, framecount);
MSG_WriteByte (&sv.datagram, framerate);
}
*/
void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
{
- int e, i, clentnum, bits, alpha, glowcolor, glowsize, scale, colormod, modred, modgreen, modblue, effects;
+ int e, i, clentnum, bits, alpha, glowcolor, glowsize, scale, colormod, effects;
byte *pvs;
vec3_t org, origin, angles;
float movelerp, moveilerp, nextfullupdate;
MSG_WriteFloat(msg, org[2]);
}
*/
- MSG_WriteByte(msg, svc_entitiesbegin);
- MSG_WriteShort(msg, 1);
clentnum = EDICT_TO_PROG(clent); // LordHavoc: for comparison purposes
// send over all entities (except the client) that touch the pvs
}
}
+ if ((val = GETEDICTFIELDVALUE(ent, eval_exteriormodeltoclient)) && val->edict == clentnum)
+ bits = bits | U_EXTERIORMODEL;
+
// don't send if flagged for NODRAW and there are no effects
alpha = 255;
scale = 16;
effects = ent->v.effects;
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 (val->_float != 0)
+ alpha = (int) (val->_float * 255.0);
+
+ // HalfLife support
+ if ((val = GETEDICTFIELDVALUE(ent, eval_renderamt)))
+ if (val->_float != 0)
alpha = (int) val->_float;
- if (alpha < 0) alpha = 0;
- if (alpha > 255) alpha = 255;
+
+ if (alpha == 0)
+ alpha = 255;
+ alpha = bound(0, alpha, 255);
if ((val = GETEDICTFIELDVALUE(ent, eval_glow_size)))
glowsize = (int) val->_float >> 2;
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;
- modgreen = val->vector[1] * 8.0;if (modgreen < 0) modgreen = 0;if (modgreen > 7) modgreen = 7;
- modblue = val->vector[2] * 4.0;if (modblue < 0) modblue = 0;if (modblue > 3) modblue = 3;
- colormod = (modred << 5) | (modgreen << 2) | modblue;
- }
+ colormod = (bound(0, (int) (val->vector[0] * 8.0), 7) << 5) | (bound(0, (int) (val->vector[1] * 8.0), 7) << 2) | bound(0, (int) (val->vector[2] * 4.0), 3);
if (ent != clent)
{
// send an update
baseline = &ent->baseline;
- if ((int)ent->v.effects & EF_DELTA)
+ if (((int)ent->v.effects & EF_DELTA) && sv_deltacompress.value)
{
// every half second a full update is forced
if (realtime < client->nextfullupdate[e])
if (baseline->skin != (byte) ent->v.skin) bits |= U_SKIN;
if ((baseline->frame & 0x00FF) != ((int) ent->v.frame & 0x00FF)) bits |= U_FRAME;
if ((baseline->effects & 0x00FF) != ((int) ent->v.effects & 0x00FF)) bits |= U_EFFECTS;
- if (baseline->modelindex != (byte) ent->v.modelindex) bits |= U_MODEL;
+ if ((baseline->modelindex & 0x00FF) != ((int) ent->v.modelindex & 0x00FF)) bits |= U_MODEL;
// LordHavoc: new stuff
if (baseline->alpha != alpha) bits |= U_ALPHA;
ent->deltabaseline.glowcolor = glowcolor;
ent->deltabaseline.colormod = colormod;
+ if (bits & (U_ALPHA | U_SCALE | U_EFFECTS2 | U_GLOWSIZE | U_GLOWCOLOR | U_COLORMOD | U_FRAME2 | U_MODEL2))
+ i = -1;
+
// write the message
if (bits >= 16777216)
bits |= U_EXTEND2;
if (bits & U_FRAME2) MSG_WriteByte(msg, (int)ent->v.frame >> 8);
if (bits & U_MODEL2) MSG_WriteByte(msg, (int)ent->v.modelindex >> 8);
}
-
- MSG_WriteByte(msg, svc_entitiesend);
- MSG_WriteShort(msg, MAX_EDICTS);
}
/*
*/
void SV_CreateBaseline (void)
{
- int i;
- edict_t *svent;
- int entnum;
-
- for (entnum = 0; entnum < sv.num_edicts ; entnum++)
+ int i, entnum, large;
+ edict_t *svent;
+
+ // LordHavoc: clear *all* states (note just active ones)
+ for (entnum = 0; entnum < MAX_EDICTS ; entnum++)
{
- // get the current server version
+ // get the current server version
svent = EDICT_NUM(entnum);
+
+ // LordHavoc: always clear state values, whether the entity is in use or not
+ ClearStateToDefault(&svent->baseline);
+
if (svent->free)
continue;
if (entnum > svs.maxclients && !svent->v.modelindex)
continue;
//
- // create entity baseline
+ // create entity baseline
//
VectorCopy (svent->v.origin, svent->baseline.origin);
VectorCopy (svent->v.angles, svent->baseline.angles);
else
{
svent->baseline.colormap = 0;
- svent->baseline.modelindex =
- SV_ModelIndex(pr_strings + svent->v.model);
+ svent->baseline.modelindex = svent->v.modelindex; //SV_ModelIndex(pr_strings + svent->v.model);
}
- svent->baseline.alpha = 255;
- svent->baseline.scale = 16;
- svent->baseline.glowsize = 0;
- svent->baseline.glowcolor = 254;
- svent->baseline.colormod = 255;
-
+
+ large = false;
+ if (svent->baseline.modelindex & 0xFF00 || svent->baseline.frame & 0xFF00)
+ large = true;
//
- // add to the message
+ // add to the message
//
- MSG_WriteByte (&sv.signon,svc_spawnbaseline);
- MSG_WriteShort (&sv.signon,entnum);
+ if (large)
+ MSG_WriteByte (&sv.signon, svc_spawnbaseline2);
+ else
+ MSG_WriteByte (&sv.signon, svc_spawnbaseline);
+ MSG_WriteShort (&sv.signon, entnum);
- MSG_WriteByte (&sv.signon, svent->baseline.modelindex);
- MSG_WriteByte (&sv.signon, svent->baseline.frame);
+ if (large)
+ {
+ MSG_WriteShort (&sv.signon, svent->baseline.modelindex);
+ MSG_WriteShort (&sv.signon, svent->baseline.frame);
+ }
+ else
+ {
+ MSG_WriteByte (&sv.signon, svent->baseline.modelindex);
+ MSG_WriteByte (&sv.signon, svent->baseline.frame);
+ }
MSG_WriteByte (&sv.signon, svent->baseline.colormap);
MSG_WriteByte (&sv.signon, svent->baseline.skin);
for (i=0 ; i<3 ; i++)
// retry the original move
ent->v.velocity[0] = oldvel[0];
- ent->v. velocity[1] = oldvel[1];
- ent->v. velocity[2] = 0;
+ ent->v.velocity[1] = oldvel[1];
+ ent->v.velocity[2] = 0;
clip = SV_FlyMove (ent, 0.1, &steptrace);
if ( fabs(oldorg[1] - ent->v.origin[1]) > 4
extern cvar_t sv_friction;
cvar_t sv_edgefriction = {"edgefriction", "2"};
cvar_t sv_predict = {"sv_predict", "1"};
+cvar_t sv_deltacompress = {"sv_deltacompress", "1"};
extern cvar_t sv_stopspeed;
static vec3_t forward, right, up;
int ret;
int cmd;
char *s;
-
+
do
{
nextmsg:
}
if (!ret)
return true;
-
+
MSG_BeginReading ();
-
+
while (1)
{
if (!host_client->active)
Con_DPrintf("%s tried to %s\n", host_client->name, s);
*/
break;
-
+
case clc_disconnect:
// Sys_Printf ("SV_ReadClientMessage: client disconnected\n");
return false;
-
+
case clc_move:
SV_ReadClientMove (&host_client->cmd);
break;
}
}
} while (ret == 1);
-
+
return true;
}
int Sys_FileTime (char *path);
void Sys_mkdir (char *path);
-//
-// memory protection
-//
-#if NOTUSED
-void Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length);
-#endif
-
//
// system IO
//
void Sys_Quit (void);
-double Sys_FloatTime (void);
+double Sys_DoubleTime (void);
char *Sys_ConsoleInput (void);
char *cachedir = "/tmp";
#endif
-#if NOTUSED
-cvar_t sys_linerefresh = {"sys_linerefresh","0"};// set for entity display
-#endif
-
extern cvar_t timestamps;
extern cvar_t timeformat;
exit(0);
}
-void Sys_Init(void)
-{
-}
-
void Sys_Error (char *error, ...)
{
va_list argptr;
close(fd);
}
-#if NOTUSED
-void Sys_EditFile(char *filename)
+double Sys_DoubleTime (void)
{
+ static int first = true;
+ static double oldtime = 0.0, basetime = 0.0;
+ double newtime;
+ struct timeval tp;
+ struct timezone tzp;
- char cmd[256];
- char *term;
- char *editor;
+ gettimeofday(&tp, &tzp);
- term = getenv("TERM");
- if (term && !strcmp(term, "xterm"))
+ newtime = (double) ((unsigned long) tp.tv_sec) + tp.tv_usec/1000000.0 - basetime;
+
+ if (first)
{
- 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);
+ first = false;
+ basetime = newtime;
+ newtime = 0.0;
}
-}
-#endif
-double Sys_FloatTime (void)
-{
- struct timeval tp;
- struct timezone tzp;
- static int secbase;
-
- gettimeofday(&tp, &tzp);
+ if (newtime < oldtime)
+ Sys_Error("Sys_DoubleTime: time running backwards??\n");
- if (!secbase)
- {
- secbase = tp.tv_sec;
- return tp.tv_usec/1000000.0;
- }
+ oldtime = newtime;
- return (tp.tv_sec - secbase) + tp.tv_usec/1000000.0;
+ return newtime;
}
// =======================================================================
oktogo=1;
}
-#if NOTUSED
-void Sys_LineRefresh(void)
-{
-}
-#endif
-
void floating_point_exception_handler(int whatever)
{
// Sys_Warn("floating point exception\n");
int main (int c, char **v)
{
- double time, oldtime, newtime;
+ double oldtime, newtime;
// static char cwd[1024];
Host_Init();
- Sys_Init();
-
if (COM_CheckParm("-nostdout"))
nostdout = 1;
else
printf ("Linux DarkPlaces -- Version %0.3f (build %i)\n", VERSION, buildnumber);
}
- oldtime = Sys_FloatTime () - 0.1;
+ oldtime = Sys_DoubleTime () - 0.1;
while (1)
{
// find time spent rendering last frame
- newtime = Sys_FloatTime ();
- time = newtime - oldtime;
-
- if (cls.state == ca_dedicated)
- {
- if (time < sys_ticrate.value)
- {
- 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);
-
-#if NOTUSED
- // graphic debugging aids
- if (sys_linerefresh.value)
- Sys_LineRefresh ();
-#endif
- }
- return 0;
-}
-
-
-#if NOTUSED
-/*
-================
-Sys_MakeCodeWriteable
-================
-*/
-void Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length)
-{
+ newtime = Sys_DoubleTime ();
- 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");
+ Host_Frame (newtime - oldtime);
+ oldtime = newtime;
+ }
+ return 0;
}
-#endif
-
*/
// sys_win.c -- Win32 system interface code
+#define WIN32_USETIMEGETTIME 0
+
#include "quakedef.h"
#include "winquake.h"
#include "errno.h"
int starttime;
qboolean ActiveApp, Minimized;
-qboolean WinNT;
-static double pfreq;
-static double curtime = 0.0;
-static double lastcurtime = 0.0;
-static int lowshift;
qboolean isDedicated;
static qboolean sc_return_on_enter = false;
HANDLE hinput, houtput;
static HANDLE heventParent;
static HANDLE heventChild;
-void Sys_InitFloatTime (void);
-
volatile int sys_checksum;
===============================================================================
*/
-#if NOTUSED
-/*
-================
-Sys_MakeCodeWriteable
-================
-*/
-void Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length)
-{
- DWORD flOldProtect;
-
- if (!VirtualProtect((LPVOID)startaddr, length, PAGE_READWRITE, &flOldProtect))
- Sys_Error("Protection change failed\n");
-}
-#endif
-
-
-/*
-================
-Sys_Init
-================
-*/
-void Sys_Init (void)
-{
- LARGE_INTEGER PerformanceFreq;
- unsigned int lowpart, highpart;
- OSVERSIONINFO vinfo;
-
- if (!QueryPerformanceFrequency (&PerformanceFreq))
- Sys_Error ("No hardware timer available");
-
-// get 32 out of the 64 time bits such that we have around
-// 1 microsecond resolution
-#ifdef __BORLANDC__
- lowpart = (unsigned int)PerformanceFreq.u.LowPart;
- highpart = (unsigned int)PerformanceFreq.u.HighPart;
-#else
- lowpart = (unsigned int)PerformanceFreq.LowPart;
- highpart = (unsigned int)PerformanceFreq.HighPart;
-#endif
- lowshift = 0;
-
- while (highpart || (lowpart > 2000000.0))
- {
- lowshift++;
- lowpart >>= 1;
- lowpart |= (highpart & 1) << 31;
- highpart >>= 1;
- }
-
- pfreq = 1.0 / (double)lowpart;
-
- Sys_InitFloatTime ();
-
- vinfo.dwOSVersionInfoSize = sizeof(vinfo);
-
- if (!GetVersionEx (&vinfo))
- Sys_Error ("Couldn't get OS info");
-
- if ((vinfo.dwMajorVersion < 4) ||
- (vinfo.dwPlatformId == VER_PLATFORM_WIN32s))
- {
- Sys_Error ("WinQuake requires at least Win95 or NT 4.0");
- }
-
- if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
- WinNT = true;
- else
- WinNT = false;
-}
-
-
void Sys_Error (char *error, ...)
{
va_list argptr;
WriteFile (houtput, text4, strlen (text4), &dummy, NULL);
- starttime = Sys_FloatTime ();
+ starttime = Sys_DoubleTime ();
sc_return_on_enter = true; // so Enter will get us out of here
while (!Sys_ConsoleInput () &&
- ((Sys_FloatTime () - starttime) < CONSOLE_ERROR_TIMEOUT))
+ ((Sys_DoubleTime () - starttime) < CONSOLE_ERROR_TIMEOUT))
{
}
}
/*
================
-Sys_FloatTime
+Sys_DoubleTime
================
*/
-double Sys_FloatTime (void)
+double Sys_DoubleTime (void)
{
- static int sametimecount;
- static unsigned int oldtime;
- static int first = 1;
- LARGE_INTEGER PerformanceCount;
- unsigned int temp, t2;
- double time;
+ // LordHavoc: note to people modifying this code, DWORD is specifically defined as an unsigned 32bit number, therefore the 65536.0 * 65536.0 is fine.
+#if WIN32_USETIMEGETTIME
+ // timeGetTime
+ // platform:
+ // Windows 95/98/ME/NT/2000
+ // features:
+ // reasonable accuracy (millisecond)
+ // issues:
+ // none known
+ static int first = true;
+ static double oldtime = 0.0, basetime = 0.0, old = 0.0;
+ double newtime, now;
+
+ now = (double) timeGetTime () - basetime;
- QueryPerformanceCounter (&PerformanceCount);
-
-#ifdef __BORLANDC__
- temp = ((unsigned int)PerformanceCount.u.LowPart >> lowshift) |
- ((unsigned int)PerformanceCount.u.HighPart << (32 - lowshift));
-#else
-
- temp = ((unsigned int)PerformanceCount.LowPart >> lowshift) |
- ((unsigned int)PerformanceCount.HighPart << (32 - lowshift));
-#endif
if (first)
{
- oldtime = temp;
- first = 0;
+ first = false;
+ basetime = now;
+ now = 0;
}
- else
- {
- // check for turnover or backward time
- if ((temp <= oldtime) && ((oldtime - temp) < 0x10000000))
- {
- oldtime = temp; // so we can't get stuck
- }
- else
- {
- t2 = temp - oldtime;
-
- time = (double)t2 * pfreq;
- oldtime = temp;
- curtime += time;
+ if (now < old)
+ {
+ // wrapped
+ basetime -= (65536.0 * 65536.0);
+ now += (65536.0 * 65536.0);
+ }
+ old = now;
- if (curtime == lastcurtime)
- {
- sametimecount++;
+ newtime = now / 1000.0;
- if (sametimecount > 100000)
- {
- curtime += 1.0;
- sametimecount = 0;
- }
- }
- else
- {
- sametimecount = 0;
- }
+ if (newtime < oldtime)
+ Sys_Error("Sys_DoubleTime: time running backwards??\n");
- lastcurtime = curtime;
- }
- }
+ oldtime = newtime;
- return curtime;
-}
+ return newtime;
+#else
+ // QueryPerformanceCounter
+ // platform:
+ // Windows 95/98/ME/NT/2000
+ // features:
+ // very accurate (CPU cycles)
+ // known issues:
+ // does not necessarily match realtime too well (tends to get faster and faster in win98)
+ static int first = true;
+ static double oldtime = 0.0, basetime = 0.0, timescale = 0.0;
+ double newtime;
+ LARGE_INTEGER PerformanceFreq;
+ LARGE_INTEGER PerformanceCount;
+ if (first)
+ {
+ if (!QueryPerformanceFrequency (&PerformanceFreq))
+ Sys_Error ("No hardware timer available");
-/*
-================
-Sys_InitFloatTime
-================
-*/
-void Sys_InitFloatTime (void)
-{
- int j;
+#ifdef __BORLANDC__
+ timescale = 1.0 / ((double) PerformanceFreq.u.LowPart + (double) PerformanceFreq.u.HighPart * 65536.0 * 65536.0);
+#else
+ timescale = 1.0 / ((double) PerformanceFreq.LowPart + (double) PerformanceFreq.HighPart * 65536.0 * 65536.0);
+#endif
+ }
- Sys_FloatTime ();
+ QueryPerformanceCounter (&PerformanceCount);
- j = COM_CheckParm("-starttime");
+#ifdef __BORLANDC__
+ newtime = ((double) PerformanceCount.u.LowPart + (double) PerformanceCount.u.HighPart * 65536.0 * 65536.0) * timescale - basetime;
+#else
+ newtime = ((double) PerformanceCount.LowPart + (double) PerformanceCount.HighPart * 65536.0 * 65536.0) * timescale - basetime;
+#endif
- if (j)
- {
- curtime = (double) (atof(com_argv[j+1]));
- }
- else
+ if (first)
{
- curtime = 0.0;
+ first = false;
+ basetime = newtime;
+ newtime = 0;
}
- lastcurtime = curtime;
+ if (newtime < oldtime)
+ Sys_Error("Sys_DoubleTime: time running backwards??\n");
+
+ oldtime = newtime;
+
+ return newtime;
+#endif
}
InitConProc (hFile, heventParent, heventChild);
}
- Sys_Init ();
-
// because sound is off until we become active
S_BlockSound ();
+#if WIN32_USETIMEGETTIME
+ // make sure the timer is high precision, otherwise NT gets 18ms resolution
+ // LordHavoc:
+ // Windows 2000 Advanced Server (and possibly other versions)
+ // apparently have a broken timer, because it runs at more like 10x speed
+ // if this isn't used, heh
+ timeBeginPeriod (1);
+#endif
+
Sys_Printf ("Host_Init\n");
Host_Init ();
- oldtime = Sys_FloatTime ();
+ oldtime = Sys_DoubleTime ();
/* main window message loop */
while (1)
{
- if (isDedicated)
- {
- newtime = Sys_FloatTime ();
- time = newtime - oldtime;
-
- while (time < sys_ticrate.value )
- {
- Sys_Sleep();
- newtime = Sys_FloatTime ();
- time = newtime - oldtime;
- }
- }
- else
+ if (!isDedicated)
{
// yield the CPU for a little while when paused, minimized, or not the focus
if ((cl.paused && (!ActiveApp && !DDActive)) || Minimized)
{
SleepUntilInput (NOT_FOCUS_SLEEP);
}
- /*
- else if (!cls.timedemo && time < (timediff = 1.0 / maxfps.value))
- {
- newtime = Sys_FloatTime ();
- time = newtime - oldtime;
-
- while (time < timediff)
- {
- Sys_Sleep();
- newtime = Sys_FloatTime ();
- time = newtime - oldtime;
- }
- }
- */
- newtime = Sys_FloatTime ();
+ newtime = Sys_DoubleTime ();
time = newtime - oldtime;
}
+++ /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.
-
-*/
-// sys_null.h -- null system driver to aid porting efforts
-
-#include "quakedef.h"
-#include "winquake.h"
-#include "errno.h"
-#include <sys\types.h>
-#include <sys\timeb.h>
-
-
-/*
-===============================================================================
-
-FILE IO
-
-===============================================================================
-*/
-
-// LordHavoc: 256 pak files (was 10)
-#define MAX_HANDLES 256
-FILE *sys_handles[MAX_HANDLES];
-
-int findhandle (void)
-{
- int i;
-
- for (i=1 ; i<MAX_HANDLES ; i++)
- if (!sys_handles[i])
- return i;
- Sys_Error ("out of handles");
- return -1;
-}
-
-/*
-================
-filelength
-================
-*/
-int filelength (FILE *f)
-{
- int pos;
- int end;
-
- pos = ftell (f);
- fseek (f, 0, SEEK_END);
- end = ftell (f);
- fseek (f, pos, SEEK_SET);
-
- return end;
-}
-
-int Sys_FileOpenRead (char *path, int *hndl)
-{
- FILE *f;
- int i;
-
- i = findhandle ();
-
- f = fopen(path, "rb");
- if (!f)
- {
- *hndl = -1;
- return -1;
- }
- sys_handles[i] = f;
- *hndl = i;
-
- return filelength(f);
-}
-
-int Sys_FileOpenWrite (char *path)
-{
- FILE *f;
- int i;
-
- i = findhandle ();
-
- f = fopen(path, "wb");
- if (!f)
- Sys_Error ("Error opening %s: %s", path,strerror(errno));
- sys_handles[i] = f;
-
- return i;
-}
-
-void Sys_FileClose (int handle)
-{
- fclose (sys_handles[handle]);
- sys_handles[handle] = NULL;
-}
-
-void Sys_FileSeek (int handle, int position)
-{
- fseek (sys_handles[handle], position, SEEK_SET);
-}
-
-int Sys_FileRead (int handle, void *dest, int count)
-{
- return fread (dest, 1, count, sys_handles[handle]);
-}
-
-int Sys_FileWrite (int handle, void *data, int count)
-{
- return fwrite (data, 1, count, sys_handles[handle]);
-}
-
-int Sys_FileTime (char *path)
-{
- FILE *f;
-
- f = fopen(path, "rb");
- if (f)
- {
- fclose(f);
- return 1;
- }
-
- return -1;
-}
-
-void Sys_mkdir (char *path)
-{
-}
-
-
-/*
-===============================================================================
-
-SYSTEM IO
-
-===============================================================================
-*/
-
-#if NOTUSED
-void Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length)
-{
-}
-#endif
-
-
-void Sys_DebugLog(char *file, char *fmt, ...)
-{
-}
-
-void Sys_Error (char *error, ...)
-{
- va_list argptr;
- char text[1024];
-
- va_start (argptr,error);
- vsprintf (text, error,argptr);
- va_end (argptr);
-
-// MessageBox(NULL, text, "Error", 0 /* MB_OK */ );
- printf ("ERROR: %s\n", text);
-
- exit (1);
-}
-
-void Sys_Printf (char *fmt, ...)
-{
- va_list argptr;
-
- va_start (argptr,fmt);
- vprintf (fmt,argptr);
- va_end (argptr);
-}
-
-void Sys_Quit (void)
-{
- exit (0);
-}
-
-double Sys_FloatTime (void)
-{
- double t;
- struct _timeb tstruct;
- static int starttime;
-
- _ftime( &tstruct );
-
- if (!starttime)
- starttime = tstruct.time;
- t = (tstruct.time-starttime) + tstruct.millitm*0.001;
-
- return t;
-}
-
-void Sys_Sleep (void)
-{
-}
-
-
-void Sys_SendKeyEvents (void)
-{
-}
-
-char *Sys_ConsoleInput (void)
-{
- static char text[256];
- static int len;
- INPUT_RECORD recs[1024];
- int count;
- int i;
- int c;
-
- // read a line out
- while (_kbhit())
- {
- c = _getch();
- putch (c);
- if (c == '\r')
- {
- text[len] = 0;
- putch ('\n');
- len = 0;
- return text;
- }
- if (c == 8)
- {
- putch (' ');
- putch (c);
- len--;
- text[len] = 0;
- continue;
- }
- text[len] = c;
- len++;
- text[len] = 0;
- if (len == sizeof(text))
- len = 0;
- }
-
- return NULL;
-}
-
-
-
-/*
-==================
-main
-
-==================
-*/
-char *newargv[256];
-
-int main (int argc, char **argv)
-{
- MSG msg;
- double time, oldtime;
- static char cwd[1024];
-
- memset (&host_parms, 0, sizeof(host_parms));
-
- host_parms.memsize = DEFAULTMEM * 1024*1024;
- host_parms.membase = qmalloc(parms.memsize);
-
- _getcwd (cwd, sizeof(cwd));
- if (cwd[strlen(cwd)-1] == '\\')
- cwd[strlen(cwd)-1] = 0;
- host_parms.basedir = cwd;
-
- COM_InitArgv (argc, argv);
-
- // dedicated server ONLY!
- if (!COM_CheckParm ("-dedicated"))
- {
- memcpy (newargv, argv, argc*4);
- newargv[argc] = "-dedicated";
- argc++;
- argv = newargv;
- COM_InitArgv (argc, argv);
- }
-
- host_parms.argc = argc;
- host_parms.argv = argv;
-
- printf ("Host_Init\n");
- Host_Init ();
-
- oldtime = Sys_FloatTime ();
-
- /* main window message loop */
- while (1)
- {
- time = Sys_FloatTime();
- if (time - oldtime < sys_ticrate.value )
- {
- Sleep(1);
- continue;
- }
-
- Host_Frame ( time - oldtime );
- oldtime = time;
- }
-
- /* return success of application */
- return true;
-}
-
extern void (*vid_menudrawfn)(void);
extern void (*vid_menukeyfn)(int key);
+extern cvar_t vid_mode;
+extern cvar_t vid_mouse;
+extern cvar_t vid_fullscreen;
+
+void VID_InitCvars();
+
void GL_Init (void);
void VID_CheckMultitexture();
int VID_SetMode (int modenum);
// sets the mode; only used by the Quake engine for resetting to mode 0 (the
// base mode) on memory allocation failures
+
+// sets hardware gamma correction, returns false if the device does not support gamma control
+int VID_SetGamma (float prescale, float gamma, float scale, float base);
#include <glide/sst1vid.h>
-cvar_t vid_mode = {"vid_mode","0",false};
-
viddef_t vid; // global video state
static void *dlhand = NULL;
return GR_RESOLUTION_640x480;
}
+int VID_SetGamma(float prescale, float gamma, float scale, float base)
+{
+ return FALSE;
+}
+
void VID_Init()
{
int i;
}
*/
}
-void VID_InitCvars ()
-{
-}
void VID_SetCaption (char *text)
{
#define X_MASK (KEY_MASK | MOUSE_MASK | VisibilityChangeMask | StructureNotifyMask )
-cvar_t vid_mode = {"vid_mode", "0", false};
-cvar_t vid_fullscreen = {"vid_fullscreen", "1"};
-
viddef_t vid; // global video state
static qboolean mouse_avail = true;
static cvar_t in_dga = {"in_dga", "1", false};
static cvar_t in_dga_mouseaccel = {"in_dga_mouseaccel", "1", false};
static cvar_t m_filter = {"m_filter", "0"};
-static cvar_t _windowed_mouse = {"_windowed_mouse", "1"};
qboolean vidmode_ext = false;
const char *gl_version;
const char *gl_extensions;
-//static float vid_gamma = 1.0;
-
/*-----------------------------------------------------------------------*/
static int
XLateKey(XKeyEvent *ev/*, qboolean modified*/)
Con_Printf("event->xmotion.x: %d\n", event.xmotion.x);
Con_Printf("event->xmotion.y: %d\n", event.xmotion.y);
}
- if (vid_fullscreen.value || _windowed_mouse.value) {
+ if (vid_fullscreen.value || vid_mouse.value) {
if (!event.xmotion.send_event) {
mouse_x += (event.xmotion.x - p_mouse_x);
mouse_y += (event.xmotion.y - p_mouse_y);
glXSwapBuffers(dpy, win);
}
+int VID_SetGamma(float prescale, float gamma, float scale, float base)
+{
+ return FALSE;
+}
+
void VID_Init()
{
int i;
int MajorVersion, MinorVersion;
int actualWidth, actualHeight;
- Cvar_RegisterVariable (&vid_mode);
- Cvar_RegisterVariable (&vid_fullscreen);
Cvar_RegisterVariable (&in_mouse);
Cvar_RegisterVariable (&in_dga);
Cvar_RegisterVariable (&in_dga_mouseaccel);
qboolean gl_mtexable = false;
int gl_mtex_enum = 0;
+cvar_t vid_mode = {"vid_mode", "0", false};
+cvar_t vid_mouse = {"vid_mouse", "1", true};
+cvar_t vid_fullscreen = {"vid_fullscreen", "1"};
+
void (GLAPIENTRY *qglMTexCoord2f) (GLenum, GLfloat, GLfloat);
void (GLAPIENTRY *qglSelectTexture) (GLenum);
void (GLAPIENTRY *qglLockArraysEXT) (GLint first, GLint count);
void (GLAPIENTRY *qglUnlockArraysEXT) (void);
+
+void VID_InitCvars()
+{
+ Cvar_RegisterVariable(&vid_mode);
+ Cvar_RegisterVariable(&vid_mouse);
+ Cvar_RegisterVariable(&vid_fullscreen);
+}
static qboolean windowed, leavecurrentmode;
static qboolean vid_canalttab = false;
static qboolean vid_wassuspended = false;
-static int windowed_mouse;
+static int usingmouse;
extern qboolean mouseactive; // from in_win.c
static HICON hIcon;
//====================================
-cvar_t vid_mode = {"vid_mode","0", false};
// Note that 0 is MODE_WINDOWED
//cvar_t _vid_default_mode = {"_vid_default_mode","0", true};
// Note that 3 is MODE_FULLSCREEN_DEFAULT
//cvar_t _vid_default_mode_win = {"_vid_default_mode_win","3", true};
-cvar_t _windowed_mouse = {"_windowed_mouse","1", true};
int window_center_x, window_center_y, window_x, window_y, window_width, window_height;
RECT window_rect;
// Set either the fullscreen or windowed mode
if (modelist[modenum].type == MS_WINDOWED)
{
- if (_windowed_mouse.value && key_dest == key_game)
- {
- stat = VID_SetWindowedMode(modenum);
- IN_ActivateMouse ();
- IN_HideMouse ();
- }
- else
- {
- IN_DeactivateMouse ();
- IN_ShowMouse ();
- stat = VID_SetWindowedMode(modenum);
- }
+// if (vid_mouse.value && key_dest == key_game)
+// {
+// stat = VID_SetWindowedMode(modenum);
+// usingmouse = true;
+// IN_ActivateMouse ();
+// IN_HideMouse ();
+// }
+// else
+// {
+// usingmouse = false;
+// IN_DeactivateMouse ();
+// IN_ShowMouse ();
+// stat = VID_SetWindowedMode(modenum);
+// }
+ stat = VID_SetWindowedMode(modenum);
}
else if (modelist[modenum].type == MS_FULLDIB)
{
stat = VID_SetFullDIBMode(modenum);
- IN_ActivateMouse ();
- IN_HideMouse ();
+// usingmouse = true;
+// IN_ActivateMouse ();
+// IN_HideMouse ();
}
else
Sys_Error ("VID_SetMode: Bad mode type in modelist");
void GL_EndRendering (void)
{
+ int usemouse;
if (r_render.value && !scr_skipupdate)
SwapBuffers(maindc);
// handle the mouse state when windowed if that's changed
- if (modestate == MS_WINDOWED)
+ usemouse = false;
+ if (vid_mouse.value && key_dest == key_game)
+ usemouse = true;
+ if (modestate == MS_FULLDIB)
+ usemouse = true;
+ if (!ActiveApp)
+ usemouse = false;
+ if (usemouse)
{
- if (!_windowed_mouse.value)
+ if (!usingmouse)
{
- if (windowed_mouse)
- {
- IN_DeactivateMouse ();
- IN_ShowMouse ();
- windowed_mouse = false;
- }
+ usingmouse = true;
+ IN_ActivateMouse ();
+ IN_HideMouse();
}
- else
+ }
+ else
+ {
+ if (usingmouse)
{
- windowed_mouse = true;
- if (key_dest == key_game && !mouseactive && ActiveApp)
- {
- IN_ActivateMouse ();
- IN_HideMouse ();
- }
- else if (mouseactive && key_dest != key_game)
- {
- IN_DeactivateMouse ();
- IN_ShowMouse ();
- }
+ usingmouse = false;
+ IN_DeactivateMouse ();
+ IN_ShowMouse();
}
}
}
IN_DeactivateMouse ();
}
+void VID_RestoreSystemGamma();
void VID_Shutdown (void)
{
wglMakeCurrent(NULL, NULL);
// LordHavoc: free textures before closing (may help NVIDIA)
- for (i = 0;i < 8192;i++) temp[i] = i+1;
+ for (i = 0;i < 8192;i++)
+ temp[i] = i+1;
glDeleteTextures(8192, temp);
if (hRC)
ReleaseDC (mainwindow, maindc);
AppActivate(false, false);
+
+ VID_RestoreSystemGamma();
}
}
IN_ClearStates ();
}
+void VID_RestoreGameGamma();
+
void AppActivate(BOOL fActive, BOOL minimize)
/****************************************************************************
*
{
if (modestate == MS_FULLDIB)
{
- IN_ActivateMouse ();
- IN_HideMouse ();
- if (vid_canalttab && vid_wassuspended) {
+// usingmouse = true;
+// IN_ActivateMouse ();
+// IN_HideMouse ();
+ if (vid_canalttab && vid_wassuspended)
+ {
vid_wassuspended = false;
ChangeDisplaySettings (&gdevmode, CDS_FULLSCREEN);
ShowWindow(mainwindow, SW_SHOWNORMAL);
// LordHavoc: from dabb, fix for alt-tab bug in NVidia drivers
MoveWindow(mainwindow,0,0,gdevmode.dmPelsWidth,gdevmode.dmPelsHeight,false);
}
- else if ((modestate == MS_WINDOWED) && _windowed_mouse.value && key_dest == key_game)
- {
- IN_ActivateMouse ();
- IN_HideMouse ();
- }
+// else if ((modestate == MS_WINDOWED) && vid_mouse.value && key_dest == key_game)
+// {
+// usingmouse = true;
+// IN_ActivateMouse ();
+// IN_HideMouse ();
+// }
+ VID_RestoreGameGamma();
}
if (!fActive)
{
+ usingmouse = false;
+ IN_DeactivateMouse ();
+ IN_ShowMouse ();
if (modestate == MS_FULLDIB)
{
- IN_DeactivateMouse ();
- IN_ShowMouse ();
- if (vid_canalttab) {
+// usingmouse = false;
+// IN_DeactivateMouse ();
+// IN_ShowMouse ();
+ if (vid_canalttab)
+ {
ChangeDisplaySettings (NULL, 0);
vid_wassuspended = true;
}
}
- else if ((modestate == MS_WINDOWED) && _windowed_mouse.value)
- {
- IN_DeactivateMouse ();
- IN_ShowMouse ();
- }
+// else if ((modestate == MS_WINDOWED) && vid_mouse.value)
+// {
+// usingmouse = false;
+// IN_DeactivateMouse ();
+// IN_ShowMouse ();
+// }
+ VID_RestoreSystemGamma();
}
}
Con_SafePrintf ("No fullscreen DIB modes found\n");
}
+static int grabsysgamma = true;
+WORD systemgammaramps[3][256], currentgammaramps[3][256];
+
+int VID_SetGamma(float prescale, float gamma, float scale, float base)
+{
+ int i;
+ HDC hdc;
+ hdc = GetDC (NULL);
+
+ BuildGammaTable16(prescale, gamma, scale, base, ¤tgammaramps[0][0]);
+ for (i = 0;i < 256;i++)
+ currentgammaramps[1][i] = currentgammaramps[2][i] = currentgammaramps[0][i];
+
+ i = SetDeviceGammaRamp(hdc, ¤tgammaramps[0][0]);
+
+ ReleaseDC (NULL, hdc);
+ return i; // return success or failure
+}
+
+void VID_RestoreGameGamma()
+{
+ VID_UpdateGamma(true);
+}
+
+void VID_GetSystemGamma()
+{
+ HDC hdc;
+ hdc = GetDC (NULL);
+
+ GetDeviceGammaRamp(hdc, &systemgammaramps[0][0]);
+
+ ReleaseDC (NULL, hdc);
+}
+
+void VID_RestoreSystemGamma()
+{
+ HDC hdc;
+ hdc = GetDC (NULL);
+
+ SetDeviceGammaRamp(hdc, &systemgammaramps[0][0]);
+
+ ReleaseDC (NULL, hdc);
+}
+
/*
===================
VID_Init
memset(&devmode, 0, sizeof(devmode));
- Cvar_RegisterVariable (&vid_mode);
// Cvar_RegisterVariable (&_vid_default_mode);
// Cvar_RegisterVariable (&_vid_default_mode_win);
- Cvar_RegisterVariable (&_windowed_mouse);
Cmd_AddCommand ("vid_nummodes", VID_NumModes_f);
Cmd_AddCommand ("vid_describecurrentmode", VID_DescribeCurrentMode_f);
Cmd_AddCommand ("vid_describemode", VID_DescribeMode_f);
Cmd_AddCommand ("vid_describemodes", VID_DescribeModes_f);
+ VID_GetSystemGamma();
+
hIcon = LoadIcon (global_hInstance, MAKEINTRESOURCE (IDI_ICON2));
InitCommonControls();
vec3_t forward;
vec3_t angles;
float bob;
- static float oldz = 0;
+// static float oldz = 0;
V_DriftPitch ();
for (i=0 ; i<3 ; i++)
{
view->render.origin[i] += forward[i]*bob*0.4;
-// view->origin[i] += right[i]*bob*0.4;
-// view->origin[i] += up[i]*bob*0.8;
+// view->render.origin[i] += right[i]*bob*0.4;
+// view->render.origin[i] += up[i]*bob*0.8;
}
view->render.origin[2] += bob;
-// fudge position around to keep amount of weapon visible
-// roughly equal with different FOV
-
view->render.model = cl.model_precache[cl.stats[STAT_WEAPON]];
view->render.frame = cl.stats[STAT_WEAPONFRAME];
view->render.colormap = -1; // no special coloring
// set up the refresh position
- if (!intimerefresh)
- if (v_punch.value)
- {
- VectorAdd (r_refdef.viewangles, cl.punchangle, r_refdef.viewangles);
- }
+ // LordHavoc: this never looked all that good to begin with...
+ /*
// smooth out stair step ups
if (cl.onground && ent->render.origin[2] - oldz > 0)
{
}
else
oldz = ent->render.origin[2];
+ */
-// LordHavoc: origin view kick
- VectorAdd(r_refdef.vieworg, cl.punchvector, r_refdef.vieworg);
+// LordHavoc: origin view kick added
+ if (!intimerefresh && v_punch.value)
+ {
+ VectorAdd(r_refdef.viewangles, cl.punchangle, r_refdef.viewangles);
+ VectorAdd(r_refdef.vieworg, cl.punchvector, r_refdef.vieworg);
+ }
if (chase_active.value)
Chase_Update ();
extern HWND mainwindow;
extern qboolean ActiveApp, Minimized;
-extern qboolean WinNT;
-
void IN_ShowMouse (void);
void IN_DeactivateMouse (void);
void IN_HideMouse (void);
void IN_ActivateMouse (void);
-void IN_RestoreOriginalMouseState (void);
-void IN_SetQuakeMouseState (void);
void IN_MouseEvent (int mstate);
extern qboolean winsock_lib_initialized;
-extern cvar_t _windowed_mouse;
-
extern int window_center_x, window_center_y;
extern RECT window_rect;