]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
some whitespace changes
authorlordhavoc <lordhavoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 26 May 2001 19:44:32 +0000 (19:44 +0000)
committerlordhavoc <lordhavoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 26 May 2001 19:44:32 +0000 (19:44 +0000)
rearranged a few cvar definitions to be in more appropriate places
removed remnants of efrags system
added bitprofile command to report popularity of entity update components
fixed a number of baseline bugs and inconsistencies in the server and client (discovered using bitprofile)
general baseline generation code added (protocol.c)
added freelook cvar and menu option
exterior model capability added (so a model could be visible only when you are using chasecam, needed for visible weapon models)
fixed some inconsistencies in frame number sizes (should have been 16bit) in 16bit modelindex messages, and 8bit sound numbers that should have been 16bit
renamed Sys_FloatTime to Sys_DoubleTime
rewrote win32 Sys_DoubleTime code and minor work on UNIX Sys_DoubleTime
removed most of svc_entitiesbegin/svc_entitiesend code (big entity update protocol improvement planned)
hardware gamma/brightness/contrast support
hardware and software gamma/brightness/contrast adjustable in the menu
gl_lightmode (also known as lighthalf) switchable in the menu
can pick a crosshair in the menu
changed renderer references to r_refdef.vieworg to use r_origin instead
stripped out ancient transpoly code that was not being used
renamed qgamma array to texgamma
significant cleanup of mouse hide/show code in win32
improved eprint for better readability (better printing of floats/vectors)
added pr_fields and pr_globals commands to print a list of entity fields and global variables in loaded progs
moved some entity_state_t related stuff to protocol.c and protocol.h
made delta compression optional (sv_deltacompress cvar)
removed a lot of cruft
disabled stair step-up blending (never worked that well anyway)
removed sys_wind.c (I seriously doubt it worked)

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@205 d7cf8633-e32d-0410-b094-e92efae38249

53 files changed:
cl_input.c
cl_main.c
cl_parse.c
client.h
gl_draw.c
gl_models.c
gl_poly.c
gl_rmain.c
gl_rmisc.c
gl_rsurf.c
gl_screen.c
gl_warp.c
glquake.h
host.c
host_cmd.c
image.c
in_svgalib.c
in_win.c
makefile
menu.c
model_alias.c
model_brush.c
model_brush.h
model_zymotic.h
net_loop.c
net_main.c
net_wins.c
palette.c
palette.h
pr_cmds.c
pr_edict.c
progs.h
protocol.c [new file with mode: 0644]
protocol.h
quakedef.h
r_decals.c
r_part.c
render.h
screen.h
sv_main.c
sv_phys.c
sv_user.c
sys.h
sys_linux.c
sys_win.c
sys_wind.c [deleted file]
vid.h
vid_3dfxsvga.c
vid_glx.c
vid_shared.c
vid_wgl.c
view.c
winquake.h

index 890687344bc661d368fe5d60c2c7c0decf6c440f..18ba2fc11d158c52cb4eeae235a7eb5e68fea7c0 100644 (file)
@@ -227,17 +227,17 @@ float CL_KeyState (kbutton_t *key)
 
 //==========================================================================
 
-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"};
 
 
 /*
index 56a5a779681a7d48c0b7cd3222432a0860673952..89c2f6ca4ed0b189ea4c32e0617884b74c6ebb62 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -41,11 +41,13 @@ cvar_t      m_yaw = {"m_yaw","0.022", true};
 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];
@@ -73,7 +75,6 @@ void CL_ClearState (void)
        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));
@@ -82,20 +83,10 @@ void CL_ClearState (void)
        // 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;
 }
 
 /*
@@ -678,7 +669,7 @@ void CL_RelinkEntities (void)
                        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)
@@ -842,8 +833,6 @@ void CL_Fog_f (void)
        fog_blue = atof(Cmd_Argv(4));
 }
 
-cvar_t demo_nehahra = {"demo_nehahra", "0"};
-
 /*
 =================
 CL_Init
@@ -875,6 +864,7 @@ void CL_Init (void)
        Cvar_RegisterVariable (&lookspring);
        Cvar_RegisterVariable (&lookstrafe);
        Cvar_RegisterVariable (&sensitivity);
+       Cvar_RegisterVariable (&freelook);
 
        Cvar_RegisterVariable (&m_pitch);
        Cvar_RegisterVariable (&m_yaw);
@@ -884,6 +874,7 @@ void CL_Init (void)
 //     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);
index 4e449e00515ef5d63b6f591f606037ee2af90c73..c8ac267c66859e6fcb6d388473ab2b57b9aec1cc 100644 (file)
@@ -83,7 +83,7 @@ char *svc_strings[128] =
        "", // 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
 };
 
 //=============================================================================
@@ -216,7 +216,7 @@ void CL_KeepaliveMessage (void)
        memcpy (net_message.data, olddata, net_message.cursize);
 
 // check time
-       time = Sys_FloatTime ();
+       time = Sys_DoubleTime ();
        if (time - lastmsg < 5)
                return;
        lastmsg = time;
@@ -490,9 +490,10 @@ relinked.  Other attributes can change without relinking.
 ==================
 */
 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)
@@ -525,6 +526,11 @@ void CL_ParseUpdate (int bits)
 
        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)
@@ -561,6 +567,7 @@ void CL_ParseUpdate (int bits)
        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))
@@ -612,25 +619,65 @@ void CL_ParseUpdate (int bits)
        }
 }
 
-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;
 }
@@ -640,17 +687,22 @@ void CL_EntityUpdateEnd(int end)
 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++)
@@ -754,14 +806,14 @@ void CL_ParseClientdata (int bits)
 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];
@@ -782,7 +834,6 @@ void CL_ParseStatic (int largemodelindex)
 
        VectorCopy (ent->state_baseline.origin, ent->render.origin);
        VectorCopy (ent->state_baseline.angles, ent->render.angles);    
-//     R_AddEfrags (ent);
 }
 
 /*
@@ -790,13 +841,16 @@ void CL_ParseStatic (int largemodelindex)
 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 ();
        
@@ -824,7 +878,7 @@ void CL_ParseEffect2 (void)
 
        MSG_ReadVector(org);
        modelindex = MSG_ReadShort ();
-       startframe = MSG_ReadByte ();
+       startframe = MSG_ReadShort ();
        framecount = MSG_ReadByte ();
        framerate = MSG_ReadByte ();
 
@@ -847,7 +901,7 @@ CL_ParseServerMessage
 void CL_ParseServerMessage (void)
 {
        int                     cmd;
-       int                     i, updateend;
+       int                     i, entitiesupdated;
        byte            cmdlog[32];
        char            *cmdlogname[32], *temp;
        int                     cmdindex, cmdcount = 0;
@@ -872,7 +926,7 @@ void CL_ParseServerMessage (void)
 //
        MSG_BeginReading ();
 
-       updateend = false;
+       entitiesupdated = false;
        CL_EntityUpdateSetup();
        
        while (1)
@@ -945,8 +999,7 @@ void CL_ParseServerMessage (void)
                        
                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;
@@ -1064,7 +1117,7 @@ void CL_ParseServerMessage (void)
                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);
@@ -1108,7 +1161,11 @@ void CL_ParseServerMessage (void)
                        break;
                        
                case svc_spawnstaticsound:
-                       CL_ParseStaticSound ();
+                       CL_ParseStaticSound (false);
+                       break;
+
+               case svc_spawnstaticsound2:
+                       CL_ParseStaticSound (true);
                        break;
 
                case svc_cdtrack:
@@ -1149,19 +1206,9 @@ void CL_ParseServerMessage (void)
                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();
 }
-
index cc6551d382e64fb6bec4481e46d2e727e310810e..130f26f01a72130437a154a53b6e1fcf60d340ea 100644 (file)
--- a/client.h
+++ b/client.h
@@ -76,9 +76,6 @@ typedef struct
 }
 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
@@ -207,7 +204,6 @@ typedef struct
 
 // 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
@@ -223,46 +219,47 @@ client_state_t;
 //
 // 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];
@@ -347,6 +344,7 @@ void CL_TimeDemo_f (void);
 // cl_parse.c
 //
 void CL_ParseServerMessage (void);
+void CL_BitProfile_f(void);
 
 //
 // view
index 5a348d3e80544fb2696a761b2d91af6910ffb1eb..5840b946ffeda48883831492cb0a185fb60abf84 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -229,7 +229,10 @@ void Draw_Character (int x, int y, int num)
                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);
@@ -281,7 +284,10 @@ void Draw_String (int x, int y, char *str, int maxlen)
                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
        {
@@ -310,7 +316,10 @@ void Draw_GenericPic (rtexture_t *tex, float red, float green, float blue, float
 {
        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);
@@ -395,7 +404,13 @@ void Draw_Fill (int x, int y, int w, int h, int c)
        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);
 
index 10cfd7590e66585128d82114e8162ca68a5f536c..ebc22794cf96c6fe3df844013b3b25bfca1368bc 100644 (file)
@@ -421,7 +421,7 @@ void R_DrawAliasFrame (maliashdr_t *maliashdr, float alpha, vec3_t color, entity
                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));
@@ -521,7 +521,7 @@ void R_DrawQ2AliasFrame (md2mem_t *pheader, float alpha, vec3_t color, entity_t
                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)));
                }
 
@@ -734,6 +734,7 @@ void ZymoticTransformVerts(int vertcount, int *bonecounts, zymvertex_t *vert)
        while(vertcount--)
        {
                c = *bonecounts++;
+               // FIXME: validate bonecounts at load time (must be >= 1)
                if (c == 1)
                {
                        matrix = &zymbonepose[vert->bonenum];
@@ -869,7 +870,7 @@ void GL_DrawZymoticModelMeshFog(vec3_t org, zymtype1header_t *m)
        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);
index d2114ab609e0d1eaa3b99767b640916bf9f7da64..4a2e7a12210a43952618d7b2cff80b89119fb802 100644 (file)
--- a/gl_poly.c
+++ b/gl_poly.c
@@ -77,7 +77,7 @@ void transpolyclear()
        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
@@ -156,219 +156,6 @@ void transpolyend()
 
 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;
@@ -531,7 +318,7 @@ void transpolyrender()
                                                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);
@@ -544,7 +331,7 @@ void transpolyrender()
                                                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);
                                                }
@@ -766,7 +553,7 @@ lit:
                        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);
                        }
index 9a4d9333b47289422e30e2d9bcca1562e1d4cd72..d1acf3324bf1bf3f9c159ed71432139579153d0b 100644 (file)
@@ -75,8 +75,6 @@ cvar_t        r_dynamic = {"r_dynamic","1"};
 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"};
@@ -270,8 +268,6 @@ void GL_Main_Init()
        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);
@@ -351,8 +347,6 @@ void GL_Init (void)
        glAlphaFunc(GL_GREATER, 0.5);
 
 //     glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
-
-       Palette_Init();
 }
 
 
@@ -438,9 +432,9 @@ void R_PrepareEntities (void)
                        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);
                }
@@ -587,8 +581,6 @@ void R_SetupFrame (void)
                Cvar_Set ("r_ambient", "0");
        }
 
-       R_AnimateLight ();
-
        r_framecount++;
 
 // build the transformation matrix for the given view angles
@@ -616,6 +608,8 @@ void R_SetupFrame (void)
        c_sprites = 0;
        c_particles = 0;
 //     c_dlights = 0;
+
+       R_AnimateLight ();
 }
 
 
@@ -680,10 +674,7 @@ void R_SetupGL (void)
        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);
 
@@ -760,14 +751,14 @@ void GL_Brighten()
        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);
@@ -777,27 +768,16 @@ void GL_BlendView()
        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);
@@ -809,7 +789,7 @@ void GL_BlendView()
        if (r_speeds2.value)\
        {\
                temptime = currtime;\
-               currtime = Sys_FloatTime();\
+               currtime = Sys_DoubleTime();\
                VAR = (int) ((currtime - temptime) * 1000000.0);\
        }\
        else\
@@ -841,9 +821,7 @@ void R_RenderView (void)
        FOG_framebegin();
 
        if (r_speeds2.value)
-       {
-               starttime = currtime = Sys_FloatTime();
-       }
+               starttime = currtime = Sys_DoubleTime();
        else
                starttime = currtime = 0;
        R_Clear();
@@ -908,7 +886,7 @@ void R_RenderView (void)
        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);
index 6089fa1b94a96160612384b1e5ff6e7642f3c3f3..1981753362160750bdada6c730ba6a8dd85e2c9a 100644 (file)
@@ -138,11 +138,6 @@ void R_NewMap (void)
        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();
 
@@ -175,7 +170,7 @@ void R_TimeRefresh_f (void)
        float           start, stop, time;
 
        intimerefresh = 1;
-       start = Sys_FloatTime ();
+       start = Sys_DoubleTime ();
        for (i = 0;i < 128;i++)
        {
                r_refdef.viewangles[0] = 0;
@@ -184,7 +179,7 @@ void R_TimeRefresh_f (void)
                SCR_UpdateScreen();
        }
 
-       stop = Sys_FloatTime ();
+       stop = Sys_DoubleTime ();
        intimerefresh = 0;
        time = stop-start;
        Con_Printf ("%f seconds (%f fps)\n", time, 128/time);
index e3756c7fa0894f2ef2c8c0f4bba699a9410f9156..2b0f1c1738835e11d7513924d8b60cae8b671248 100644 (file)
@@ -891,7 +891,7 @@ void R_DrawBrushModel (entity_t *e)
 
        c_bmodels++;
 
-       VectorSubtract (r_refdef.vieworg, e->render.origin, modelorg);
+       VectorSubtract (r_origin, e->render.origin, modelorg);
        if (rotated)
        {
                vec3_t  temp;
@@ -904,7 +904,13 @@ void R_DrawBrushModel (entity_t *e)
                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
@@ -923,9 +929,9 @@ void R_DrawBrushModel (entity_t *e)
        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))
@@ -980,7 +986,7 @@ void R_SolidWorldNode ()
 
        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;
@@ -989,10 +995,6 @@ void R_SolidWorldNode ()
 
                        leaf->visframe = r_framecount;
 
-                       // deal with model fragments in this leaf
-//                     if (leaf->efrags)
-//                             R_StoreEfrags (&leaf->efrags);
-
                        if (leaf->nummarksurfaces)
                        {
                                mark = leaf->firstmarksurface;
@@ -1042,10 +1044,6 @@ void R_PortalWorldNode ()
 
                leaf->visframe = r_framecount;
 
-               // deal with model fragments in this leaf
-       //      if (leaf->efrags)
-       //              R_StoreEfrags (&leaf->efrags);
-
                if (leaf->nummarksurfaces)
                {
                        mark = leaf->firstmarksurface;
@@ -1115,10 +1113,6 @@ loc0:
 
        leaf->visframe = r_framecount;
 
-       // deal with model fragments in this leaf
-//     if (leaf->efrags)
-//             R_StoreEfrags (&leaf->efrags);
-
        if (leaf->nummarksurfaces)
        {
                mark = leaf->firstmarksurface;
@@ -1270,7 +1264,7 @@ void R_DrawWorld (void)
        modelalpha = ent.render.alpha = 1;
        ent.render.scale = 1;
 
-       VectorCopy (r_refdef.vieworg, modelorg);
+       VectorCopy (r_origin, modelorg);
 
        currententity = &ent;
 
index eb7a176ab360324117cda10fadd392ece8aab418..9b2a7b22c2da6c43b087fb3c4ff667f06e2bde24 100644 (file)
@@ -70,24 +70,24 @@ console is:
 */
 
 
-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
 
@@ -98,10 +98,6 @@ qpic_t               *scr_turtle;
 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;
@@ -392,6 +388,8 @@ void GL_Screen_Init (void)
        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
@@ -711,21 +709,34 @@ void DrawCrosshair(int num);
 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);
@@ -743,19 +754,20 @@ void GL_BrightenScreen()
                }
                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);
@@ -779,7 +791,9 @@ void SCR_UpdateScreen (void)
        double  time1 = 0, time2;
 
        if (r_speeds.value)
-               time1 = Sys_FloatTime ();
+               time1 = Sys_DoubleTime ();
+
+       VID_UpdateGamma(false);
 
        if (scr_disabled_for_loading)
        {
@@ -861,7 +875,7 @@ void SCR_UpdateScreen (void)
                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;
@@ -888,7 +902,7 @@ void SCR_UpdateScreen (void)
 
        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 ();
index c3ccd0d20a24931cb948df1a79c898ab924b673d..6c9b795c367052b8a640c3b5d5fb483e1bc34f3f 100644 (file)
--- a/gl_warp.c
+++ b/gl_warp.c
@@ -247,7 +247,7 @@ extern cvar_t r_farclip;
 
 #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()
 {
@@ -341,9 +341,9 @@ void skydome(float *source, float s, float texscale)
        {
                *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);
index 2b3e9cca175b6c20598a9b652d412a28914c5099..eea60c1a8a63a8cd30a2337ec8e852dd9c807fad 100644 (file)
--- a/glquake.h
+++ b/glquake.h
@@ -177,8 +177,8 @@ extern void (GLAPIENTRY *qglUnlockArraysEXT) (void);
 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"
diff --git a/host.c b/host.c
index c4aa4090f0d8e537e6f910d6ae9908c695a5b321..d169181f8d769e7370052bcee7ec011e524cc3f3 100644 (file)
--- a/host.c
+++ b/host.c
@@ -441,7 +441,7 @@ void Host_ShutdownServer(qboolean crash)
                CL_Disconnect ();
 
 // flush any pending messages - like the score!!!
-       start = Sys_FloatTime();
+       start = Sys_DoubleTime();
        do
        {
                count = 0;
@@ -461,7 +461,7 @@ void Host_ShutdownServer(qboolean crash)
                                }
                        }
                }
-               if ((Sys_FloatTime() - start) > 3.0)
+               if ((Sys_DoubleTime() - start) > 3.0)
                        break;
        }
        while (count);
@@ -555,8 +555,7 @@ qboolean Host_FilterTime (double time)
                        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;
 }
@@ -694,12 +693,12 @@ void _Host_Frame (float time)
 
 // 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)
@@ -715,7 +714,7 @@ void _Host_Frame (float time)
        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",
@@ -738,9 +737,9 @@ void Host_Frame (float time)
                return;
        }
        
-       time1 = Sys_FloatTime ();
+       time1 = Sys_DoubleTime ();
        _Host_Frame (time);
-       time2 = Sys_FloatTime ();       
+       time2 = Sys_DoubleTime ();      
        
        timetotal += time2 - time1;
        timecount++;
@@ -828,7 +827,11 @@ void Host_Init ()
        
        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 ();
index 7510ee753673dbbc5974a34e645ed826c1c6ecd5..5a23bfca1d5f68845ba766450a1d5d1a55b7ddf1 100644 (file)
@@ -1065,7 +1065,7 @@ void Host_Spawn_f (void)
                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");
diff --git a/image.c b/image.c
index a26b78fc600f309425b161c5542fe66e8d80e640..db7570f028d654ee783f19a26b59f23f065656ce 100644 (file)
--- a/image.c
+++ b/image.c
@@ -46,10 +46,10 @@ void Image_CopyRGBAGamma(byte *in, byte *out, int pixels)
 {
        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;
        }
index ea8460d752dcd34f0a5d42574a4550c9d283a89f..7c258a0c5a252b560cccaf9e40ba7e95d80f475f 100644 (file)
@@ -324,16 +324,20 @@ void IN_Commands(void)
 
 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;
        }
@@ -346,30 +350,28 @@ void IN_Move(usercmd_t *cmd)
        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;
-               }
        }
 }
 
index fb055bbb416e991c11aa2ff4d92029188d1cddb3..37397b6988735145216f44e162f0ca87301c315b 100644 (file)
--- a/in_win.c
+++ b/in_win.c
@@ -46,7 +46,7 @@ unsigned int uiWheelMessage;
 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;
@@ -188,12 +188,11 @@ IN_ShowMouse
 */
 void IN_ShowMouse (void)
 {
-
-       if (!mouseshowtoggle)
-       {
+//     if (!mouseshowtoggle)
+//     {
                ShowCursor (true);
-               mouseshowtoggle = 1;
-       }
+//             mouseshowtoggle = 1;
+//     }
 }
 
 
@@ -204,12 +203,11 @@ IN_HideMouse
 */
 void IN_HideMouse (void)
 {
-
-       if (mouseshowtoggle)
-       {
+//     if (mouseshowtoggle)
+//     {
                ShowCursor (false);
-               mouseshowtoggle = 0;
-       }
+//             mouseshowtoggle = 0;
+//     }
 }
 
 
@@ -248,6 +246,7 @@ void IN_ActivateMouse (void)
                        SetCursorPos (window_center_x, window_center_y);
                        SetCapture (mainwindow);
                        ClipCursor (&window_rect);
+                       
                }
 
                mouseactive = true;
@@ -255,18 +254,6 @@ void IN_ActivateMouse (void)
 }
 
 
-/*
-===========
-IN_SetQuakeMouseState
-===========
-*/
-void IN_SetQuakeMouseState (void)
-{
-       if (mouseactivatetoggle)
-               IN_ActivateMouse ();
-}
-
-
 /*
 ===========
 IN_DeactivateMouse
@@ -304,26 +291,6 @@ void IN_DeactivateMouse (void)
 }
 
 
-/*
-===========
-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
@@ -521,7 +488,7 @@ IN_Shutdown
 */
 void IN_Shutdown (void)
 {
-
+//     usingmouse = false;
        IN_DeactivateMouse ();
        IN_ShowMouse ();
 
@@ -578,8 +545,7 @@ IN_MouseMove
 */
 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;
@@ -695,16 +661,16 @@ void IN_MouseMove (usercmd_t *cmd)
        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)
@@ -1065,7 +1031,7 @@ void IN_JoyMove (usercmd_t *cmd)
 {
        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
@@ -1123,7 +1089,7 @@ void IN_JoyMove (usercmd_t *cmd)
                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)
@@ -1168,7 +1134,7 @@ void IN_JoyMove (usercmd_t *cmd)
                        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)
@@ -1195,7 +1161,7 @@ void IN_JoyMove (usercmd_t *cmd)
                        break;
 
                case AxisLook:
-                       if (in_mlook.state & 1)
+                       if (mouselook)
                        {
                                if (fabs(fAxisValue) > joy_pitchthreshold.value)
                                {
index 84cd188ce7d1cf710bea00d45bc4555bc234ee2f..69a0721932e766b68228d5a1331f849f57c8af11 100644 (file)
--- a/makefile
+++ b/makefile
@@ -16,6 +16,7 @@ CFLAGS= -Wall -Werror -I/usr/X11R6/include -I/usr/include/glide $(OPTIMIZATIONS)
 #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
 
diff --git a/menu.c b/menu.c
index e3795323340916f74d4159629fa359c806381c08..7092080e59dff09b72259b675a774f504317eae7 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -1234,11 +1234,7 @@ again:
 //=============================================================================
 /* OPTIONS MENU */
 
-#ifdef _WIN32
-#define        OPTIONS_ITEMS   14
-#else
-#define        OPTIONS_ITEMS   13
-#endif
+#define        OPTIONS_ITEMS   21
 
 #define        SLIDER_RANGE    10
 
@@ -1249,13 +1245,6 @@ void M_Menu_Options_f (void)
        key_dest = key_menu;
        m_state = m_options;
        m_entersound = true;
-
-#ifdef _WIN32
-       if ((options_cursor == 13) && (modestate != MS_WINDOWED))
-       {
-               options_cursor = 0;
-       }
-#endif
 }
 
 
@@ -1266,51 +1255,41 @@ void M_AdjustSliders (int dir)
        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);
@@ -1323,23 +1302,33 @@ void M_AdjustSliders (int dir)
                }
                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
        }
 }
 
@@ -1375,62 +1364,38 @@ void M_DrawCheckbox (int x, int y, int on)
 
 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));
 }
 
 
@@ -1456,7 +1421,7 @@ void M_Options_Key (int k)
                case 2:
                        Cbuf_AddText ("exec default.cfg\n");
                        break;
-               case 12:
+               case 20:
                        M_Menu_Video_f ();
                        break;
                default:
@@ -1487,24 +1452,6 @@ void M_Options_Key (int k)
                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
 }
 
 //=============================================================================
index 9e1c035145c4352d4cbe1b5a411b92c4f9b3aba3..ac10b6ebd34b5b4579def4d0016701e343580a7d 100644 (file)
@@ -1021,7 +1021,7 @@ void Mod_LoadZymoticModel (model_t *mod, void *buffer)
        }
        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];
@@ -1042,7 +1042,7 @@ void Mod_LoadZymoticModel (model_t *mod, void *buffer)
 //     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
index ccd95dc1a226864f95867019ed9f0748fca781d3..803fa9255fe29623596db1c92c122f41c6fbf2b2 100644 (file)
@@ -955,7 +955,6 @@ void Mod_LoadLeafs (lump_t *l)
                        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];
index 2355d2ecd63545fb4d9b08e55e90000678a7a2df..6470e1a9762ac8c703fd4ba9e529db7a2aad0b54 100644 (file)
@@ -175,7 +175,6 @@ typedef struct mleaf_s
        int                     dlightframe;
 
        byte            *compressed_vis;
-//     efrag_t         *efrags;
 
        msurface_t      **firstmarksurface;
        int                     nummarksurfaces;
index 70ab0ab467311a315a4b8e9c38a4ee64f13f4b89..d5d96e87271e64c6b48e51821fb26e4dbaba5ed0 100644 (file)
@@ -24,7 +24,7 @@ typedef struct zymtype1header_s
        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
 }
index ac2a5de9b2e050bb13a91af1a337814d8fba36b2..133766aa1ca5240ef752565af7cbdcf5d3549b00 100644 (file)
@@ -162,7 +162,7 @@ int Loop_SendMessage (qsocket_t *sock, sizebuf_t *data)
        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;
 
index 39b57cca238ffa7b24afd6ba494254796679222a..4df0adb606c963f458676aa0e554381cfc8d6734 100644 (file)
@@ -72,7 +72,7 @@ double                        net_time;
 
 double SetNetTime(void)
 {
-       net_time = Sys_FloatTime();
+       net_time = Sys_DoubleTime();
        return net_time;
 }
 
@@ -284,7 +284,7 @@ void NET_Slist_f (void)
        }
 
        slistInProgress = true;
-       slistStartTime = Sys_FloatTime();
+       slistStartTime = Sys_DoubleTime();
 
        SchedulePollProcedure(&slistSendProcedure, 0.0);
        SchedulePollProcedure(&slistPollProcedure, 0.1);
@@ -304,7 +304,7 @@ static void Slist_Send(void)
                dfunc.SearchForHosts (true);
        }
 
-       if ((Sys_FloatTime() - slistStartTime) < 0.5)
+       if ((Sys_DoubleTime() - slistStartTime) < 0.5)
                SchedulePollProcedure(&slistSendProcedure, 0.75);
 }
 
@@ -323,7 +323,7 @@ static void Slist_Poll(void)
        if (! slistSilent)
                PrintSlist();
 
-       if ((Sys_FloatTime() - slistStartTime) < 1.5)
+       if ((Sys_DoubleTime() - slistStartTime) < 1.5)
        {
                SchedulePollProcedure(&slistPollProcedure, 0.1);
                return;
@@ -641,7 +641,7 @@ int NET_SendToAll(sizebuf_t *data, int blocktime)
                }
        }
 
-       start = Sys_FloatTime();
+       start = Sys_DoubleTime();
        while (count)
        {
                count = 0;
@@ -676,7 +676,7 @@ int NET_SendToAll(sizebuf_t *data, int blocktime)
                                continue;
                        }
                }
-               if ((Sys_FloatTime() - start) > blocktime)
+               if ((Sys_DoubleTime() - start) > blocktime)
                        break;
        }
        return count;
@@ -811,7 +811,7 @@ void SchedulePollProcedure(PollProcedure *proc, double timeOffset)
 {
        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)
index e01a6191ed0abfd7ce8c7bdfb41bf597ac51536f..f16c51524676dfbc997e9744448e9e62ea1901b5 100644 (file)
@@ -68,7 +68,7 @@ BOOL PASCAL FAR BlockingHook(void)
     MSG                msg;
     BOOL       ret;
  
-       if ((Sys_FloatTime() - blocktime) > 2.0)
+       if ((Sys_DoubleTime() - blocktime) > 2.0)
        {
                WSACancelBlockingCall();
                return false;
@@ -100,7 +100,7 @@ void WINS_GetLocalAddress()
        if (pgethostname(buff, MAXHOSTNAMELEN) == SOCKET_ERROR)
                return;
 
-       blocktime = Sys_FloatTime();
+       blocktime = Sys_DoubleTime();
        WSASetBlockingHook(BlockingHook);
        local = pgethostbyname(buff);
        WSAUnhookBlockingHook();
index f43efcfc82a9b946bfe0f3bc2a83170c7da0283f..b574d8029a649a12083d45edc22555da48600a28 100644 (file)
--- a/palette.c
+++ b/palette.c
@@ -4,8 +4,13 @@
 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()
 {
@@ -57,32 +62,125 @@ void       Palette_Setup15to8()
 }
 */
 
-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;
@@ -94,5 +192,5 @@ void Palette_Init()
        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();
 }
index ff8dc7984ac64facea9bfd89b728efcb05c0314e..7e6dbc4bc9742fda5929a48cef103d1a79ffea92 100644 (file)
--- a/palette.h
+++ b/palette.h
@@ -1,8 +1,19 @@
 
+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();
index 90562b8511ff280d6d92793277cf09631431a810..e274a7deb722fcad68e03b62576bf5b393484016 100644 (file)
--- a/pr_cmds.c
+++ b/pr_cmds.c
@@ -62,6 +62,7 @@ DP_REGISTERCVAR \
 DP_SPRITE32 \
 DP_SV_DRAWONLYTOCLIENT \
 DP_SV_NODRAWTOCLIENT \
+DP_SV_EXTERIORMODELTOCLIENT \
 DP_SV_SETCOLOR \
 DP_SV_EFFECT \
 DP_TE_BLOOD \
@@ -632,7 +633,7 @@ void PF_ambientsound (void)
        char            *samp;
        float           *pos;
        float           vol, attenuation;
-       int                     i, soundnum;
+       int                     i, soundnum, large;
 
        pos = G_VECTOR (OFS_PARM0);                     
        samp = G_STRING(OFS_PARM1);
@@ -650,13 +651,24 @@ void PF_ambientsound (void)
                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);
@@ -1128,8 +1140,12 @@ void PF_Spawn (void)
 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);
 }
 
@@ -1798,23 +1814,27 @@ int SV_ModelIndex (char *name);
 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++)
index 1ef5b19a0cbcc93b8bdba1351373d26e681a8313..0a472da0a86ab4ff4aec0d997454530bcaf8065a 100644 (file)
@@ -107,6 +107,7 @@ int eval_idealpitch;
 int eval_pitch_speed;
 int eval_viewmodelforclient;
 int eval_nodrawtoclient;
+int eval_exteriormodeltoclient;
 int eval_drawonlytoclient;
 int eval_colormod;
 int eval_ping;
@@ -155,6 +156,7 @@ void FindEdictFieldOffsets()
        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");
@@ -305,7 +307,6 @@ ddef_t *ED_FindField (char *name)
        return NULL;
 }
 
-
 /*
 ============
 ED_FindGlobal
@@ -388,7 +389,7 @@ Returns a string describing *data in a type specific manner
 */
 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;
        
@@ -414,10 +415,12 @@ char *PR_ValueString (etype_t type, eval_t *val)
                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");
@@ -541,7 +544,7 @@ ED_Print
 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;
@@ -579,9 +582,9 @@ void ED_Print (edict_t *ed)
                        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");
@@ -743,9 +746,7 @@ void ED_WriteGlobals (FILE *f)
                        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;                
@@ -1280,6 +1281,32 @@ void PR_LoadProgs (void)
 }
 
 
+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
@@ -1291,6 +1318,8 @@ void PR_Init (void)
        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);
diff --git a/progs.h b/progs.h
index 4d4ce0ad18fa008edb27a86e28d1051d6a604b2b..bd8eada0445a1e8d78fb4894662fcfebeb0e4914 100644 (file)
--- a/progs.h
+++ b/progs.h
@@ -84,6 +84,7 @@ extern int eval_idealpitch;
 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;
diff --git a/protocol.c b/protocol.c
new file mode 100644 (file)
index 0000000..7d21297
--- /dev/null
@@ -0,0 +1,22 @@
+
+#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;
+}
+
index b7cf55c6fe12a63eea77dc4cd81ac0f814811073..96a03104b621e923d833cc80e738e47c0cf583b0 100644 (file)
@@ -49,46 +49,45 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #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)
@@ -201,15 +200,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #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
@@ -263,3 +263,30 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #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);
index f698972a2e4fa7b7db837cc5cf26748c914b4d96..4bd918598dd98f751008c6b8fc150cd5bd5746c5 100644 (file)
@@ -181,6 +181,7 @@ extern int buildnumber;
 #define        SOUND_CHANNELS          8
 
 #include "common.h"
+#include "cvar.h"
 #include "bspfile.h"
 #include "vid.h"
 #include "sys.h"
@@ -191,7 +192,6 @@ extern int buildnumber;
 
 #include "wad.h"
 #include "draw.h"
-#include "cvar.h"
 #include "screen.h"
 #include "net.h"
 #include "protocol.h"
index 9cfe99fdcd11490f2160fa865c2fed43f5e56aef..d35eb58709badd9bbf179d4098b007a1f0a627fc 100644 (file)
@@ -235,7 +235,7 @@ void GL_DrawDecals (void)
 
        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)
        {
@@ -261,7 +261,7 @@ void GL_DrawDecals (void)
                        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;
 
index fff8f378d92a76098bb53acc7ee8b4ef55239939..e41be9f93a03a597eb9355258f15ae9e3c86aafb 100644 (file)
--- a/r_part.c
+++ b/r_part.c
@@ -32,20 +32,19 @@ ptype_t;
 
 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
@@ -853,7 +852,7 @@ void R_RocketTrail (vec3_t start, vec3_t end, int type, entity_t *ent)
        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;
@@ -1366,7 +1365,7 @@ void R_DrawParticles (void)
        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++)
        {
@@ -1386,7 +1385,7 @@ void R_DrawParticles (void)
                /*
                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;
                }
index 2420f2ca3251837091870b3dbc0c51ae029faa81..2d22fd4c22c60b1853276ac2785f529446071f2a 100644 (file)
--- a/render.h
+++ b/render.h
@@ -20,45 +20,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 // 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
@@ -80,7 +46,6 @@ typedef struct entity_s
 
                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
@@ -88,21 +53,17 @@ typedef struct entity_s
                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;
@@ -156,11 +117,6 @@ void R_ViewChanged (vrect_t *pvrect, int lineadj, float aspect); // called whene
 // 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);
index 58281617b209ed732d73b5b1b96e643cfd716e86..e073834f7a231a91e6ae30d342f50904a6f49fce 100644 (file)
--- a/screen.h
+++ b/screen.h
@@ -31,15 +31,18 @@ void SCR_CenterPrint (char *str);
 //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;
index 0ef1184b3f25d8cd3e25ddb28e3f4c1251ae77cf..83f8ca52184fe74a95eb0870205aa2bad8dc861d 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -26,6 +26,8 @@ server_static_t       svs;
 
 char   localmodels[MAX_MODELS][5];                     // inline model names for precache
 
+extern cvar_t  sv_deltacompress;
+
 //============================================================================
 
 /*
@@ -59,6 +61,7 @@ void SV_Init (void)
        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);
@@ -113,14 +116,14 @@ void SV_StartEffect (vec3_t org, int modelindex, int startframe, int framecount,
 {
        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);
        }
@@ -463,7 +466,7 @@ SV_WriteEntitiesToClient
 */
 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;
@@ -483,8 +486,6 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
                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
@@ -529,6 +530,9 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
                        }
                }
 
+               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;
@@ -538,12 +542,17 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
                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;
@@ -569,12 +578,7 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
 
                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)
                {
@@ -602,7 +606,7 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
 // 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])
@@ -692,7 +696,7 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
                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;
@@ -718,6 +722,9 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
                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;
@@ -763,9 +770,6 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
                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);
 }
 
 /*
@@ -1156,21 +1160,25 @@ SV_CreateBaseline
 */
 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);
@@ -1184,23 +1192,31 @@ void SV_CreateBaseline (void)
                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++)
index 7d647953f0f391a36bf90b84014eb680c46270be..655af5f49e1c4bfff61e961c016ce8a24c3a9cc8 100644 (file)
--- a/sv_phys.c
+++ b/sv_phys.c
@@ -948,8 +948,8 @@ int SV_TryUnstick (edict_t *ent, vec3_t oldvel)
 
 // 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
index 496d0c02126ca6c65758f99423481002987e7bfe..10cd006b3c608863d8fcd5e379ef21a72ffeee3e 100644 (file)
--- a/sv_user.c
+++ b/sv_user.c
@@ -26,6 +26,7 @@ edict_t       *sv_player;
 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;
@@ -530,7 +531,7 @@ qboolean SV_ReadClientMessage (void)
        int             ret;
        int             cmd;
        char            *s;
-       
+
        do
        {
 nextmsg:
@@ -542,9 +543,9 @@ nextmsg:
                }
                if (!ret)
                        return true;
-                                       
+
                MSG_BeginReading ();
-               
+
                while (1)
                {
                        if (!host_client->active)
@@ -606,18 +607,18 @@ nextmsg:
                                        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;
 }
 
diff --git a/sys.h b/sys.h
index 0df1b9b66dbc4ef54e4d55b3867586a1357bae25..dd31ce09f19dcd252836606642908c0046ce3b16 100644 (file)
--- a/sys.h
+++ b/sys.h
@@ -36,13 +36,6 @@ int Sys_FileWrite (int handle, void *data, int count);
 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
 //
@@ -56,7 +49,7 @@ void Sys_Printf (char *fmt, ...);
 
 void Sys_Quit (void);
 
-double Sys_FloatTime (void);
+double Sys_DoubleTime (void);
 
 char *Sys_ConsoleInput (void);
 
index d01fcf70ba390c99f2f1a03242b3e5d7db0b2297..c1d14940f4e5e24a15150a8bf7e27b6166737932 100644 (file)
@@ -30,10 +30,6 @@ char *basedir = ".";
 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;
 
@@ -188,10 +184,6 @@ void Sys_Quit (void)
        exit(0);
 }
 
-void Sys_Init(void)
-{
-}
-
 void Sys_Error (char *error, ...)
 { 
     va_list     argptr;
@@ -311,45 +303,31 @@ void Sys_DebugLog(char *file, char *fmt, ...)
     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;
 }
 
 // =======================================================================
@@ -363,12 +341,6 @@ void alarm_handler(int x)
        oktogo=1;
 }
 
-#if NOTUSED
-void Sys_LineRefresh(void)
-{
-}
-#endif
-
 void floating_point_exception_handler(int whatever)
 {
 //     Sys_Warn("floating point exception\n");
@@ -408,7 +380,7 @@ void Sys_Sleep(void)
 int main (int c, char **v)
 {
 
-       double          time, oldtime, newtime;
+       double oldtime, newtime;
 
 //     static char cwd[1024];
 
@@ -429,8 +401,6 @@ int main (int c, char **v)
 
        Host_Init();
 
-       Sys_Init();
-
        if (COM_CheckParm("-nostdout"))
                nostdout = 1;
        else
@@ -439,63 +409,15 @@ int main (int c, char **v)
                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
-
index a7f21401318f46288313024988d98f267096b0b6..e4e6cfd6bd57f35d4502ae6e6ee32d3ff853210d 100644 (file)
--- a/sys_win.c
+++ b/sys_win.c
@@ -19,6 +19,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
 // sys_win.c -- Win32 system interface code
 
+#define WIN32_USETIMEGETTIME 0
+
 #include "quakedef.h"
 #include "winquake.h"
 #include "errno.h"
@@ -33,12 +35,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 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;
@@ -50,8 +47,6 @@ static HANDLE hFile;
 static HANDLE  heventParent;
 static HANDLE  heventChild;
 
-void Sys_InitFloatTime (void);
-
 volatile int                                   sys_checksum;
 
 
@@ -212,77 +207,6 @@ SYSTEM IO
 ===============================================================================
 */
 
-#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;
@@ -318,11 +242,11 @@ void Sys_Error (char *error, ...)
                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))
                {
                }
        }
@@ -396,95 +320,97 @@ void Sys_Quit (void)
 
 /*
 ================
-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
 }
 
 
@@ -738,32 +664,27 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
                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)
@@ -775,22 +696,8 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
                        {
                                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;
                }
 
diff --git a/sys_wind.c b/sys_wind.c
deleted file mode 100644 (file)
index beb27db..0000000
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
-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;
-}
-
diff --git a/vid.h b/vid.h
index f0f49ab8e7116a6dcf2abe4ac2c822c32d0e6e77..d8638c42df24bbbad2bb65a7db44f96f27ca5fb8 100644 (file)
--- a/vid.h
+++ b/vid.h
@@ -45,6 +45,12 @@ extern       viddef_t        vid;                            // global video state
 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();
@@ -59,3 +65,6 @@ void  VID_Shutdown (void);
 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);
index 601387c1625991613ae96b094b9453ed708afcbf..e1dff04ad8379657442861cc936d4b2646a98d4f 100644 (file)
@@ -46,8 +46,6 @@
 #include <glide/sst1vid.h>
 
 
-cvar_t         vid_mode = {"vid_mode","0",false};
-
 viddef_t       vid;    // global video state
 
 static void    *dlhand = NULL;
@@ -306,6 +304,11 @@ findres(int *width, int *height)
        return GR_RESOLUTION_640x480;
 }
 
+int VID_SetGamma(float prescale, float gamma, float scale, float base)
+{
+       return FALSE;
+}
+
 void VID_Init()
 {
        int i;
@@ -388,9 +391,6 @@ void VID_ExtraOptionCmd(int option_cursor)
        }
 */
 }
-void VID_InitCvars ()
-{
-}
 
 void VID_SetCaption (char *text)
 {
index 2acfc4c6eb6c0b92fbc9eee22d8411ce2334cddc..ea76ba6b0803e44c329f782834d29b8659ba7e50 100644 (file)
--- a/vid_glx.c
+++ b/vid_glx.c
@@ -49,9 +49,6 @@ static GLXContext ctx = NULL;
 #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;
@@ -65,7 +62,6 @@ static cvar_t in_mouse = {"in_mouse", "1", false};
 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;
 
@@ -87,8 +83,6 @@ const char *gl_renderer;
 const char *gl_version;
 const char *gl_extensions;
 
-//static float vid_gamma = 1.0;
-
 /*-----------------------------------------------------------------------*/
 static int
 XLateKey(XKeyEvent *ev/*, qboolean modified*/)
@@ -304,7 +298,7 @@ static void HandleEvents(void)
                                        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);
@@ -524,6 +518,11 @@ void GL_EndRendering (void)
        glXSwapBuffers(dpy, win);
 }
 
+int VID_SetGamma(float prescale, float gamma, float scale, float base)
+{
+       return FALSE;
+}
+
 void VID_Init()
 {
        int i;
@@ -546,8 +545,6 @@ void VID_Init()
        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);
index 47ac0546550a08c4d740456a3f86a7967d60cd20..86205a125a994cb276bfed3c30650c0b7c4582b8 100644 (file)
@@ -11,7 +11,18 @@ qboolean gl_supportslockarrays = false;
 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);
+}
index fe9ec2cbf0471adec62bad6aa2dd608c0e2651f9..fab43df8b14b8ac9dd048405436700f43be952c6 100644 (file)
--- a/vid_wgl.c
+++ b/vid_wgl.c
@@ -75,7 +75,7 @@ static qboolean       vid_initialized = false;
 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;
 
@@ -115,12 +115,10 @@ void VID_UpdateWindowStatus (void);
 
 //====================================
 
-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;
@@ -281,24 +279,28 @@ int VID_SetMode (int modenum)
        // 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");
@@ -440,34 +442,34 @@ void GL_BeginRendering (int *x, int *y, int *width, int *height)
 
 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();
                }
        }
 }
@@ -477,6 +479,7 @@ void VID_SetDefaultMode (void)
        IN_DeactivateMouse ();
 }
 
+void VID_RestoreSystemGamma();
 
 void   VID_Shutdown (void)
 {
@@ -494,7 +497,8 @@ 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)
@@ -510,6 +514,8 @@ void        VID_Shutdown (void)
                        ReleaseDC (mainwindow, maindc);
 
                AppActivate(false, false);
+
+               VID_RestoreSystemGamma();
        }
 }
 
@@ -632,6 +638,8 @@ void ClearAllStates (void)
        IN_ClearStates ();
 }
 
+void VID_RestoreGameGamma();
+
 void AppActivate(BOOL fActive, BOOL minimize)
 /****************************************************************************
 *
@@ -665,9 +673,11 @@ 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);
@@ -676,29 +686,38 @@ void AppActivate(BOOL fActive, BOOL minimize)
                        // 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();
        }
 }
 
@@ -1222,6 +1241,50 @@ void VID_InitFullDIB (HINSTANCE hInstance)
                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, &currentgammaramps[0][0]);
+       for (i = 0;i < 256;i++)
+               currentgammaramps[1][i] = currentgammaramps[2][i] = currentgammaramps[0][i];
+
+       i = SetDeviceGammaRamp(hdc, &currentgammaramps[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
@@ -1237,16 +1300,16 @@ void    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();
diff --git a/view.c b/view.c
index 355a8e6e1c61a9f6702d213b02154336d10c0e40..a8821d1b231994ff423722a4e3ca4140e4d150aa 100644 (file)
--- a/view.c
+++ b/view.c
@@ -737,7 +737,7 @@ void V_CalcRefdef (void)
        vec3_t          forward;
        vec3_t          angles;
        float           bob;
-       static float oldz = 0;
+//     static float oldz = 0;
 
        V_DriftPitch ();
 
@@ -794,25 +794,19 @@ void V_CalcRefdef (void)
        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)
 {
@@ -833,9 +827,14 @@ 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 ();
index 9b35f8028027f10233528ca62601b0783f6afbc4..7c97334c07ff125ddf079accef6600a3bc6c3dd0 100644 (file)
@@ -58,20 +58,14 @@ extern modestate_t  modestate;
 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;