]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
added CVAR_SAVE and CVAR_NOTIFY flags to cvar_t structure (at the beginning), updated...
authorlordhavoc <lordhavoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 26 Oct 2001 20:17:33 +0000 (20:17 +0000)
committerlordhavoc <lordhavoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 26 Oct 2001 20:17:33 +0000 (20:17 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@953 d7cf8633-e32d-0410-b094-e92efae38249

51 files changed:
chase.c
cl_effects.c
cl_input.c
cl_main.c
cl_parse.c
cl_tent.c
common.c
console.c
cvar.c
cvar.h
draw.h
gl_draw.c
gl_models.c
gl_poly.c
gl_rmain.c
gl_rsurf.c
gl_screen.c
gl_textures.c
host.c
in_svgalib.c
in_win.c
makefile
model_alias.c
model_brush.c
model_brush.h
model_sprite.c
net_dgrm.c
net_main.c
palette.c
portals.c [new file with mode: 0644]
portals.h [new file with mode: 0644]
pr_cmds.c
pr_edict.c
quakedef.h
r_clip.c
r_crosshairs.c
r_decals.c
r_explosion.c
r_light.c
r_part.c
r_sprites.c
snd_dma.c
spritegn.h
sv_main.c
sv_phys.c
sv_user.c
ui.c [new file with mode: 0644]
ui.h [new file with mode: 0644]
vid_glx.c
vid_shared.c
view.c

diff --git a/chase.c b/chase.c
index 7633ff6cc9be4a3a815aeff8d06dc130a96c250b..22c82aac654718816b3bbde95f5b64c4c12de379 100644 (file)
--- a/chase.c
+++ b/chase.c
@@ -21,9 +21,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include "quakedef.h"
 
 
 #include "quakedef.h"
 
-cvar_t chase_back = {"chase_back", "48", true};
-cvar_t chase_up = {"chase_up", "48", true};
-cvar_t chase_active = {"chase_active", "0", true};
+cvar_t chase_back = {CVAR_SAVE, "chase_back", "48"};
+cvar_t chase_up = {CVAR_SAVE, "chase_up", "48"};
+cvar_t chase_active = {CVAR_SAVE, "chase_active", "0"};
 
 void Chase_Init (void)
 {
 
 void Chase_Init (void)
 {
index 5a7cad195c954ecc29ff309dfa9a8e366e8f66d7..42341f0ec83dffd3e809556201982e9bbc097212 100644 (file)
@@ -40,7 +40,7 @@ effect_t;
 
 effect_t effect[MAX_EFFECTS];
 
 
 effect_t effect[MAX_EFFECTS];
 
-cvar_t r_draweffects = {"r_draweffects", "1"};
+cvar_t r_draweffects = {0, "r_draweffects", "1"};
 
 void r_effects_start(void)
 {
 
 void r_effects_start(void)
 {
index d49dd439f6f4078c877df391d3c80e58bf4bb15b..481f843d88bac3f452174e69f33be4927cafd70f 100644 (file)
@@ -70,7 +70,7 @@ void KeyDown (kbutton_t *b)
 
        if (k == b->down[0] || k == b->down[1])
                return;         // repeating key
 
        if (k == b->down[0] || k == b->down[1])
                return;         // repeating key
-       
+
        if (!b->down[0])
                b->down[0] = k;
        else if (!b->down[1])
        if (!b->down[0])
                b->down[0] = k;
        else if (!b->down[1])
@@ -227,17 +227,17 @@ float CL_KeyState (kbutton_t *key)
 
 //==========================================================================
 
 
 //==========================================================================
 
-cvar_t cl_upspeed = {"cl_upspeed","400"};
-cvar_t cl_forwardspeed = {"cl_forwardspeed","400", true};
-cvar_t cl_backspeed = {"cl_backspeed","400", true};
-cvar_t cl_sidespeed = {"cl_sidespeed","350", true};
+cvar_t cl_upspeed = {CVAR_SAVE, "cl_upspeed","400"};
+cvar_t cl_forwardspeed = {CVAR_SAVE, "cl_forwardspeed","400"};
+cvar_t cl_backspeed = {CVAR_SAVE, "cl_backspeed","400"};
+cvar_t cl_sidespeed = {CVAR_SAVE, "cl_sidespeed","350"};
 
 
-cvar_t cl_movespeedkey = {"cl_movespeedkey","2.0"};
+cvar_t cl_movespeedkey = {CVAR_SAVE, "cl_movespeedkey","2.0"};
 
 
-cvar_t cl_yawspeed = {"cl_yawspeed","140"};
-cvar_t cl_pitchspeed = {"cl_pitchspeed","150"};
+cvar_t cl_yawspeed = {CVAR_SAVE, "cl_yawspeed","140"};
+cvar_t cl_pitchspeed = {CVAR_SAVE, "cl_pitchspeed","150"};
 
 
-cvar_t cl_anglespeedkey = {"cl_anglespeedkey","1.5"};
+cvar_t cl_anglespeedkey = {CVAR_SAVE, "cl_anglespeedkey","1.5"};
 
 
 /*
 
 
 /*
@@ -251,7 +251,7 @@ void CL_AdjustAngles (void)
 {
        float   speed;
        float   up, down;
 {
        float   speed;
        float   up, down;
-       
+
        if (in_speed.state & 1)
                speed = cl.frametime * cl_anglespeedkey.value;
        else
        if (in_speed.state & 1)
                speed = cl.frametime * cl_anglespeedkey.value;
        else
@@ -269,10 +269,10 @@ void CL_AdjustAngles (void)
                cl.viewangles[PITCH] -= speed*cl_pitchspeed.value * CL_KeyState (&in_forward);
                cl.viewangles[PITCH] += speed*cl_pitchspeed.value * CL_KeyState (&in_back);
        }
                cl.viewangles[PITCH] -= speed*cl_pitchspeed.value * CL_KeyState (&in_forward);
                cl.viewangles[PITCH] += speed*cl_pitchspeed.value * CL_KeyState (&in_back);
        }
-       
+
        up = CL_KeyState (&in_lookup);
        down = CL_KeyState(&in_lookdown);
        up = CL_KeyState (&in_lookup);
        down = CL_KeyState(&in_lookdown);
-       
+
        cl.viewangles[PITCH] -= speed*cl_pitchspeed.value * up;
        cl.viewangles[PITCH] += speed*cl_pitchspeed.value * down;
 
        cl.viewangles[PITCH] -= speed*cl_pitchspeed.value * up;
        cl.viewangles[PITCH] += speed*cl_pitchspeed.value * down;
 
index 2339a64445f65e594da6a2b7155fd327a7cebd3a..0341b9db388756c42feb337d61e1ecfebaaebf96 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -8,7 +8,7 @@ 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
 
 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.  
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 See the GNU General Public License for more details.
 
 
 See the GNU General Public License for more details.
 
@@ -25,23 +25,23 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 // references them even when on a unix system.
 
 // these two are not intended to be set directly
 // references them even when on a unix system.
 
 // these two are not intended to be set directly
-cvar_t cl_name = {"_cl_name", "player", true};
-cvar_t cl_color = {"_cl_color", "0", true};
-cvar_t cl_pmodel = {"_cl_pmodel", "0", true};
+cvar_t cl_name = {CVAR_SAVE, "_cl_name", "player"};
+cvar_t cl_color = {CVAR_SAVE, "_cl_color", "0"};
+cvar_t cl_pmodel = {CVAR_SAVE, "_cl_pmodel", "0"};
 
 
-cvar_t cl_shownet = {"cl_shownet","0"};        // can be 0, 1, or 2
-cvar_t cl_nolerp = {"cl_nolerp","0"};
+cvar_t cl_shownet = {0, "cl_shownet","0"};
+cvar_t cl_nolerp = {0, "cl_nolerp", "0"};
 
 
-cvar_t lookspring = {"lookspring","0", true};
-cvar_t lookstrafe = {"lookstrafe","0", true};
-cvar_t sensitivity = {"sensitivity","3", true};
+cvar_t lookspring = {CVAR_SAVE, "lookspring","0"};
+cvar_t lookstrafe = {CVAR_SAVE, "lookstrafe","0"};
+cvar_t sensitivity = {CVAR_SAVE, "sensitivity","3", 1, 30};
 
 
-cvar_t m_pitch = {"m_pitch","0.022", true};
-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 m_pitch = {CVAR_SAVE, "m_pitch","0.022"};
+cvar_t m_yaw = {CVAR_SAVE, "m_yaw","0.022"};
+cvar_t m_forward = {CVAR_SAVE, "m_forward","1"};
+cvar_t m_side = {CVAR_SAVE, "m_side","0.8"};
 
 
-cvar_t freelook = {"freelook", "1", true};
+cvar_t freelook = {CVAR_SAVE, "freelook", "1"};
 
 client_static_t        cls;
 client_state_t cl;
 
 client_static_t        cls;
 client_state_t cl;
@@ -460,7 +460,7 @@ void CL_RelinkEntities (void)
 
        if (cls.demoplayback)
        {
 
        if (cls.demoplayback)
        {
-       // interpolate the angles       
+       // interpolate the angles
                for (j = 0;j < 3;j++)
                {
                        d = cl.mviewangles[0][j] - cl.mviewangles[1][j];
                for (j = 0;j < 3;j++)
                {
                        d = cl.mviewangles[0][j] - cl.mviewangles[1][j];
@@ -754,7 +754,7 @@ void CL_SendCmd (void)
        {
        // get basic movement from keyboard
                CL_BaseMove (&cmd);
        {
        // get basic movement from keyboard
                CL_BaseMove (&cmd);
-       
+
        // allow mice or other external controllers to add to the move
                IN_Move (&cmd);
        
        // allow mice or other external controllers to add to the move
                IN_Move (&cmd);
        
@@ -902,4 +902,3 @@ void CL_Init (void)
 
        CL_Parse_Init();
 }
 
        CL_Parse_Init();
 }
-
index 7b68ddefcc37c1300a14f7dc2426636bd22a0783..860144143fccfaeeb36f4d44b920cd679c0c36f3 100644 (file)
@@ -88,7 +88,7 @@ char *svc_strings[128] =
 
 //=============================================================================
 
 
 //=============================================================================
 
-cvar_t demo_nehahra = {"demo_nehahra", "0"};
+cvar_t demo_nehahra = {0, "demo_nehahra", "0"};
 
 void CL_Parse_Init(void)
 {
 
 void CL_Parse_Init(void)
 {
index 22b258bcdc0dce5c148029d765d3cc5d22138330..9be371d831deb4ddd65acc707a3bc1f42985ccbd 100644 (file)
--- a/cl_tent.c
+++ b/cl_tent.c
@@ -8,7 +8,7 @@ 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
 
 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.  
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 See the GNU General Public License for more details.
 
 
 See the GNU General Public License for more details.
 
@@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include "quakedef.h"
 
 
 #include "quakedef.h"
 
-cvar_t r_glowinglightning = {"r_glowinglightning", "1", true};
+cvar_t r_glowinglightning = {CVAR_SAVE, "r_glowinglightning", "1"};
 
 int                    num_temp_entities;
 entity_t       cl_temp_entities[MAX_TEMP_ENTITIES];
 
 int                    num_temp_entities;
 entity_t       cl_temp_entities[MAX_TEMP_ENTITIES];
index 8f8464a403fc1e19b55a38f7e80593de47cd281d..22f2885bd1d7d8facc943f45af6cb9e1973615b8 100644 (file)
--- a/common.c
+++ b/common.c
@@ -8,7 +8,7 @@ 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
 
 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.  
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 See the GNU General Public License for more details.
 
 
 See the GNU General Public License for more details.
 
@@ -19,13 +19,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
 // common.c -- misc functions used in client and server
 
 */
 // common.c -- misc functions used in client and server
 
+#include <stdlib.h>
 #include <fcntl.h>
 #ifdef WIN32
 #include <io.h>
 #else
 #include <unistd.h>
 #endif
 #include <fcntl.h>
 #ifdef WIN32
 #include <io.h>
 #else
 #include <unistd.h>
 #endif
-#include <stdlib.h>
 
 #include "quakedef.h"
 
 
 #include "quakedef.h"
 
@@ -37,14 +37,14 @@ static char     *argvdummy = " ";
 static char     *safeargvs[NUM_SAFE_ARGVS] =
        {"-stdvid", "-nolan", "-nosound", "-nocdaudio", "-nojoy", "-nomouse", "-dibonly"};
 
 static char     *safeargvs[NUM_SAFE_ARGVS] =
        {"-stdvid", "-nolan", "-nosound", "-nocdaudio", "-nojoy", "-nomouse", "-dibonly"};
 
-cvar_t  registered = {"registered","0"};
-cvar_t  cmdline = {"cmdline","0", false, true};
+cvar_t registered = {0, "registered","0"};
+cvar_t cmdline = {0, "cmdline","0"};
 
 qboolean        com_modified;   // set true if using non-id files
 
 
 qboolean        com_modified;   // set true if using non-id files
 
-qboolean               proghack;
+//qboolean             proghack;
 
 
-int             static_registered = 1;  // only for startup check, then set
+//int             static_registered = 1;  // only for startup check, then set
 
 qboolean               msg_suppress_1 = 0;
 
 
 qboolean               msg_suppress_1 = 0;
 
@@ -54,7 +54,8 @@ char  com_token[1024];
 int            com_argc;
 char   **com_argv;
 
 int            com_argc;
 char   **com_argv;
 
-#define CMDLINE_LENGTH 256
+// LordHavoc: made commandline 1024 characters instead of 256
+#define CMDLINE_LENGTH 1024
 char   com_cmdline[CMDLINE_LENGTH];
 
 qboolean               standard_quake = true, rogue = false, hipnotic = false, nehahra = false;
 char   com_cmdline[CMDLINE_LENGTH];
 
 qboolean               standard_quake = true, rogue = false, hipnotic = false, nehahra = false;
@@ -251,7 +252,7 @@ int Q_atoi (char *str)
        int             val;
        int             sign;
        int             c;
        int             val;
        int             sign;
        int             c;
-       
+
        if (*str == '-')
        {
                sign = -1;
        if (*str == '-')
        {
                sign = -1;
@@ -1038,7 +1039,7 @@ void COM_CheckRegistered (void)
 {
        Cvar_Set ("cmdline", com_cmdline);
 
 {
        Cvar_Set ("cmdline", com_cmdline);
 
-       static_registered = 0;
+//     static_registered = 0;
 
        if (!Sys_FileTime("gfx/pop.lmp"))
        {
 
        if (!Sys_FileTime("gfx/pop.lmp"))
        {
@@ -1057,7 +1058,7 @@ void COM_CheckRegistered (void)
        
 //     Cvar_Set ("cmdline", com_cmdline);
        Cvar_Set ("registered", "1");
        
 //     Cvar_Set ("cmdline", com_cmdline);
        Cvar_Set ("registered", "1");
-       static_registered = 1;
+//     static_registered = 1;
        Con_Printf ("Playing registered version.\n");
 }
 
        Con_Printf ("Playing registered version.\n");
 }
 
@@ -1506,11 +1507,11 @@ int COM_FindFile (char *filename, QFile **file, qboolean quiet, qboolean zip)
 // search through the path, one element at a time
 //
        search = com_searchpaths;
 // search through the path, one element at a time
 //
        search = com_searchpaths;
-       if (proghack)
-       {       // gross hack to use quake 1 progs with quake 2 maps
-               if (!strcmp(filename, "progs.dat"))
-                       search = search->next;
-       }
+//     if (proghack)
+//     {       // gross hack to use quake 1 progs with quake 2 maps
+//             if (!strcmp(filename, "progs.dat"))
+//                     search = search->next;
+//     }
 
        for ( ; search ; search = search->next)
        {
 
        for ( ; search ; search = search->next)
        {
@@ -1896,8 +1897,8 @@ void COM_InitFilesystem (void)
                }
        }
 
                }
        }
 
-       if (COM_CheckParm ("-proghack"))
-               proghack = true;
+//     if (COM_CheckParm ("-proghack"))
+//             proghack = true;
 }
 
 int COM_FileExists(char *filename)
 }
 
 int COM_FileExists(char *filename)
index 1065d847febc4cddc0b1237b06a8813ad60f8383..d7cb88fc219f1d97c065df3f98a399d650ecd93d 100644 (file)
--- a/console.c
+++ b/console.c
@@ -47,8 +47,8 @@ int                   con_current;            // where next message will be printed
 int                    con_x;                          // offset in current line for next print
 char           *con_text = 0;
 
 int                    con_x;                          // offset in current line for next print
 char           *con_text = 0;
 
-cvar_t         con_notifytime = {"con_notifytime","3"};        //seconds
-cvar_t         logfile = {"logfile","0"};
+cvar_t         con_notifytime = {CVAR_SAVE, "con_notifytime","3"};     //seconds
+cvar_t         logfile = {0, "logfile","0"};
 
 #define        NUM_CON_TIMES 4
 float          con_times[NUM_CON_TIMES];       // realtime time the line was generated
 
 #define        NUM_CON_TIMES 4
 float          con_times[NUM_CON_TIMES];       // realtime time the line was generated
diff --git a/cvar.c b/cvar.c
index f8b874c129320555684fedf4381fbc81a4b46fc8..d38c5ba9eeda565bf22dc6b3c351e0521855c5d5 100644 (file)
--- a/cvar.c
+++ b/cvar.c
@@ -32,7 +32,7 @@ Cvar_FindVar
 cvar_t *Cvar_FindVar (char *var_name)
 {
        cvar_t  *var;
 cvar_t *Cvar_FindVar (char *var_name)
 {
        cvar_t  *var;
-       
+
        for (var=cvar_vars ; var ; var=var->next)
                if (!strcmp (var_name, var->name))
                        return var;
        for (var=cvar_vars ; var ; var=var->next)
                if (!strcmp (var_name, var->name))
                        return var;
@@ -48,7 +48,7 @@ Cvar_VariableValue
 float  Cvar_VariableValue (char *var_name)
 {
        cvar_t  *var;
 float  Cvar_VariableValue (char *var_name)
 {
        cvar_t  *var;
-       
+
        var = Cvar_FindVar (var_name);
        if (!var)
                return 0;
        var = Cvar_FindVar (var_name);
        if (!var)
                return 0;
@@ -64,7 +64,7 @@ Cvar_VariableString
 char *Cvar_VariableString (char *var_name)
 {
        cvar_t *var;
 char *Cvar_VariableString (char *var_name)
 {
        cvar_t *var;
-       
+
        var = Cvar_FindVar (var_name);
        if (!var)
                return cvar_null_string;
        var = Cvar_FindVar (var_name);
        if (!var)
                return cvar_null_string;
@@ -81,12 +81,12 @@ char *Cvar_CompleteVariable (char *partial)
 {
        cvar_t          *cvar;
        int                     len;
 {
        cvar_t          *cvar;
        int                     len;
-       
+
        len = strlen(partial);
        len = strlen(partial);
-       
+
        if (!len)
                return NULL;
        if (!len)
                return NULL;
-               
+
 // check functions
        for (cvar=cvar_vars ; cvar ; cvar=cvar->next)
                if (!strncmp (partial,cvar->name, len))
 // check functions
        for (cvar=cvar_vars ; cvar ; cvar=cvar->next)
                if (!strncmp (partial,cvar->name, len))
@@ -110,18 +110,18 @@ Cvar_CompleteCountPossible (char *partial)
        cvar_t  *cvar;
        int             len;
        int             h;
        cvar_t  *cvar;
        int             len;
        int             h;
-       
+
        h = 0;
        len = strlen(partial);
        h = 0;
        len = strlen(partial);
-       
+
        if (!len)
                return  0;
        if (!len)
                return  0;
-       
+
        // Loop through the cvars and count all possible matches
        for (cvar = cvar_vars; cvar; cvar = cvar->next)
                if (!strncasecmp(partial, cvar->name, len))
                        h++;
        // Loop through the cvars and count all possible matches
        for (cvar = cvar_vars; cvar; cvar = cvar->next)
                if (!strncasecmp(partial, cvar->name, len))
                        h++;
-       
+
        return h;
 }
 
        return h;
 }
 
@@ -152,7 +152,7 @@ Cvar_CompleteBuildList (char *partial)
 
        buf[bpos] = NULL;
        return buf;
 
        buf[bpos] = NULL;
        return buf;
-}      
+}
 
 /*
 ============
 
 /*
 ============
@@ -163,7 +163,7 @@ void Cvar_Set (char *var_name, char *value)
 {
        cvar_t  *var;
        qboolean changed;
 {
        cvar_t  *var;
        qboolean changed;
-       
+
        var = Cvar_FindVar (var_name);
        if (!var)
        {       // there is an error in C code if this happens
        var = Cvar_FindVar (var_name);
        if (!var)
        {       // there is an error in C code if this happens
@@ -172,13 +172,13 @@ void Cvar_Set (char *var_name, char *value)
        }
 
        changed = strcmp(var->string, value);
        }
 
        changed = strcmp(var->string, value);
-       
+
        Z_Free (var->string);   // free the old value string
        Z_Free (var->string);   // free the old value string
-       
+
        var->string = Z_Malloc (strlen(value)+1);
        strcpy (var->string, value);
        var->value = atof (var->string);
        var->string = Z_Malloc (strlen(value)+1);
        strcpy (var->string, value);
        var->value = atof (var->string);
-       if (var->server && changed)
+       if ((var->flags & CVAR_NOTIFY) && changed)
        {
                if (sv.active)
                        SV_BroadcastPrintf ("\"%s\" changed to \"%s\"\n", var->name, var->string);
        {
                if (sv.active)
                        SV_BroadcastPrintf ("\"%s\" changed to \"%s\"\n", var->name, var->string);
@@ -193,13 +193,12 @@ Cvar_SetValue
 void Cvar_SetValue (char *var_name, float value)
 {
        char    val[32];
 void Cvar_SetValue (char *var_name, float value)
 {
        char    val[32];
-       
+
        // LordHavoc: changed from %f to %g to use shortest representation
        sprintf (val, "%g",value);
        Cvar_Set (var_name, val);
 }
 
        // LordHavoc: changed from %f to %g to use shortest representation
        sprintf (val, "%g",value);
        Cvar_Set (var_name, val);
 }
 
-
 /*
 ============
 Cvar_RegisterVariable
 /*
 ============
 Cvar_RegisterVariable
@@ -210,27 +209,27 @@ Adds a freestanding variable to the variable list.
 void Cvar_RegisterVariable (cvar_t *variable)
 {
        char    *oldstr;
 void Cvar_RegisterVariable (cvar_t *variable)
 {
        char    *oldstr;
-       
+
 // first check to see if it has already been defined
        if (Cvar_FindVar (variable->name))
        {
                Con_Printf ("Can't register variable %s, already defined\n", variable->name);
                return;
        }
 // first check to see if it has already been defined
        if (Cvar_FindVar (variable->name))
        {
                Con_Printf ("Can't register variable %s, already defined\n", variable->name);
                return;
        }
-       
+
 // check for overlap with a command
        if (Cmd_Exists (variable->name))
        {
                Con_Printf ("Cvar_RegisterVariable: %s is a command\n", variable->name);
                return;
        }
 // check for overlap with a command
        if (Cmd_Exists (variable->name))
        {
                Con_Printf ("Cvar_RegisterVariable: %s is a command\n", variable->name);
                return;
        }
-               
+
 // copy the value off, because future sets will Z_Free it
        oldstr = variable->string;
 // copy the value off, because future sets will Z_Free it
        oldstr = variable->string;
-       variable->string = Z_Malloc (strlen(variable->string)+1);       
+       variable->string = Z_Malloc (strlen(variable->string)+1);
        strcpy (variable->string, oldstr);
        variable->value = atof (variable->string);
        strcpy (variable->string, oldstr);
        variable->value = atof (variable->string);
-       
+
 // link the variable in
        variable->next = cvar_vars;
        cvar_vars = variable;
 // link the variable in
        variable->next = cvar_vars;
        cvar_vars = variable;
@@ -251,7 +250,7 @@ qboolean    Cvar_Command (void)
        v = Cvar_FindVar (Cmd_Argv(0));
        if (!v)
                return false;
        v = Cvar_FindVar (Cmd_Argv(0));
        if (!v)
                return false;
-               
+
 // perform a variable print or set
        if (Cmd_Argc() == 1)
        {
 // perform a variable print or set
        if (Cmd_Argc() == 1)
        {
@@ -275,9 +274,9 @@ with the archive flag set to true.
 void Cvar_WriteVariables (QFile *f)
 {
        cvar_t  *var;
 void Cvar_WriteVariables (QFile *f)
 {
        cvar_t  *var;
-       
+
        for (var = cvar_vars ; var ; var = var->next)
        for (var = cvar_vars ; var ; var = var->next)
-               if (var->archive)
+               if (var->flags & CVAR_SAVE)
                        Qprintf (f, "%s \"%s\"\n", var->name, var->string);
 }
 
                        Qprintf (f, "%s \"%s\"\n", var->name, var->string);
 }
 
diff --git a/cvar.h b/cvar.h
index 1c73c39cd7ead433900a05afd3845508f7286257..61871b68afda2303f853cef1ea65cbe090ef011b 100644 (file)
--- a/cvar.h
+++ b/cvar.h
@@ -53,21 +53,69 @@ Cvars are restricted from having the same names as commands to keep this
 interface from being ambiguous.
 */
 
 interface from being ambiguous.
 */
 
+// cvar flags
+#define CVAR_SAVE 1
+#define CVAR_NOTIFY 2
+
+// type of a cvar for menu purposes
+#define CVARMENUTYPE_FLOAT 1
+#define CVARMENUTYPE_INTEGER 2
+#define CVARMENUTYPE_SLIDER 3
+#define CVARMENUTYPE_BOOL 4
+#define CVARMENUTYPE_STRING 5
+#define CVARMENUTYPE_OPTION 6
+
+// which menu to put a cvar in
+#define CVARMENU_GRAPHICS 1
+#define CVARMENU_SOUND 2
+#define CVARMENU_INPUT 3
+#define CVARMENU_NETWORK 4
+#define CVARMENU_SERVER 5
+
+#define MAX_CVAROPTIONS 16
+
+typedef struct
+{
+       int value;
+       char *name;
+}
+cvaroption_t;
+
+typedef struct
+{
+       int                             type;
+       float                   valuemin, valuemax, valuestep;
+       int                             numoptions;
+       cvaroption_t    optionlist[MAX_CVAROPTIONS];
+}
+menucvar_t;
+
 typedef struct cvar_s
 {
 typedef struct cvar_s
 {
-       char    *name;
-       char    *string;
-       qboolean archive;               // set to true to cause it to be saved to vars.rc
-       qboolean server;                // notifies players when changed
-       float   value;
-       struct cvar_s *next;
+       int                             flags;
+       char                    *name;
+       char                    *string;
+//     qboolean                archive;                // set to true to cause it to be saved to vars.rc
+//     qboolean                server;         // notifies players when changed
+       int                             intvalue;
+       float                   value;
+       float                   vector[3];
+       menucvar_t              menuinfo;
+       struct cvar_s   *next;
 } cvar_t;
 
 } cvar_t;
 
-void   Cvar_RegisterVariable (cvar_t *variable);
+void   Cvar_MenuSlider(cvar_t *variable, int menu, float slider_min, float slider_max, float slider_step);
+void   Cvar_MenuBool(cvar_t *variable, int menu, char *name_false, char *name_true);
+void   Cvar_MenuFloat(cvar_t *variable, int menu, float range_min, float range_max);
+void   Cvar_MenuInteger(cvar_t *variable, int menu, int range_min, int range_max);
+void   Cvar_MenuString(cvar_t *variable, int menu);
+void   Cvar_MenuOption(cvar_t *variable, int menu, int value[16], char *name[16]);
+
+void   Cvar_RegisterVariable (cvar_t *variable);
 // registers a cvar that already has the name, string, and optionally the
 // archive elements set.
 
 // registers a cvar that already has the name, string, and optionally the
 // archive elements set.
 
-void   Cvar_Set (char *var_name, char *value);
+void   Cvar_Set (char *var_name, char *value);
 // equivelant to "<name> <variable>" typed at the console
 
 void   Cvar_SetValue (char *var_name, float value);
 // equivelant to "<name> <variable>" typed at the console
 
 void   Cvar_SetValue (char *var_name, float value);
diff --git a/draw.h b/draw.h
index 267b9e921f91b690018133286b3db62b6d1c84db..58efe1b2978f5d93b6059c8d9507ed827ff3eda4 100644 (file)
--- a/draw.h
+++ b/draw.h
@@ -8,7 +8,7 @@ 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
 
 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.  
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 See the GNU General Public License for more details.
 
 
 See the GNU General Public License for more details.
 
@@ -27,6 +27,7 @@ void Draw_Init (void);
 void Draw_Character (int x, int y, int num);
 void Draw_GenericPic (rtexture_t *tex, float red, float green, float blue, float alpha, int x, int y, int width, int height);
 void Draw_Pic (int x, int y, qpic_t *pic);
 void Draw_Character (int x, int y, int num);
 void Draw_GenericPic (rtexture_t *tex, float red, float green, float blue, float alpha, int x, int y, int width, int height);
 void Draw_Pic (int x, int y, qpic_t *pic);
+void Draw_AdditivePic (int x, int y, qpic_t *pic);
 void Draw_PicTranslate (int x, int y, qpic_t *pic, byte *translation);
 void Draw_ConsoleBackground (int lines);
 void Draw_Fill (int x, int y, int w, int h, int c);
 void Draw_PicTranslate (int x, int y, qpic_t *pic, byte *translation);
 void Draw_ConsoleBackground (int lines);
 void Draw_Fill (int x, int y, int w, int h, int c);
index 330aff43dca48da4bcb0a217f7e9d012360f856b..8e0b3dc6025278c4c271c7a034e99b12589f1587 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 //#define GL_COLOR_INDEX8_EXT     0x80E5
 
 
 //#define GL_COLOR_INDEX8_EXT     0x80E5
 
-cvar_t         scr_conalpha = {"scr_conalpha", "1"};
+cvar_t         scr_conalpha = {CVAR_SAVE, "scr_conalpha", "1"};
 
 byte           *draw_chars;                            // 8*8 graphic characters
 qpic_t         *draw_disc;
 
 byte           *draw_chars;                            // 8*8 graphic characters
 qpic_t         *draw_disc;
@@ -330,7 +330,8 @@ Draw_AlphaPic
 */
 void Draw_AlphaPic (int x, int y, qpic_t *pic, float alpha)
 {
 */
 void Draw_AlphaPic (int x, int y, qpic_t *pic, float alpha)
 {
-       Draw_GenericPic(((glpic_t *)pic->data)->tex, 1,1,1,alpha, x,y,pic->width, pic->height);
+       if (pic)
+               Draw_GenericPic(((glpic_t *)pic->data)->tex, 1,1,1,alpha, x,y,pic->width, pic->height);
 }
 
 
 }
 
 
@@ -341,7 +342,19 @@ Draw_Pic
 */
 void Draw_Pic (int x, int y, qpic_t *pic)
 {
 */
 void Draw_Pic (int x, int y, qpic_t *pic)
 {
-       Draw_GenericPic(((glpic_t *)pic->data)->tex, 1,1,1,1, x,y,pic->width, pic->height);
+       if (pic)
+               Draw_GenericPic(((glpic_t *)pic->data)->tex, 1,1,1,1, x,y,pic->width, pic->height);
+}
+
+
+void Draw_AdditivePic (int x, int y, qpic_t *pic)
+{
+       if (pic)
+       {
+               glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+               Draw_GenericPic(((glpic_t *)pic->data)->tex, 1,1,1,1, x,y,pic->width, pic->height);
+               glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+       }
 }
 
 
 }
 
 
@@ -358,6 +371,9 @@ void Draw_PicTranslate (int x, int y, qpic_t *pic, byte *translation)
        byte                    *trans, *src, *dest;
        rtexture_t              *rt;
 
        byte                    *trans, *src, *dest;
        rtexture_t              *rt;
 
+       if (pic == NULL)
+               return;
+
        c = pic->width * pic->height;
        src = menuplyr_pixels;
        dest = trans = qmalloc(c);
        c = pic->width * pic->height;
        src = menuplyr_pixels;
        dest = trans = qmalloc(c);
index 65eac04ef068efc022f09dcfab993e292d2ff605..14ad45668448bfcdf9471a8b5e6b430b552379b0 100644 (file)
@@ -1,8 +1,8 @@
 
 #include "quakedef.h"
 
 
 #include "quakedef.h"
 
-cvar_t gl_transform = {"gl_transform", "1"};
-cvar_t gl_lockarrays = {"gl_lockarrays", "1"};
+cvar_t gl_transform = {0, "gl_transform", "1"};
+cvar_t gl_lockarrays = {0, "gl_lockarrays", "1"};
 
 typedef struct
 {
 
 typedef struct
 {
index 1bc09e667dad2721548c366f28666c64f72715c7..67def33c0547fbe68207b230c9ee590b50385cf3 100644 (file)
--- a/gl_poly.c
+++ b/gl_poly.c
@@ -18,9 +18,9 @@ int currentskyvert;
 
 void LoadSky_f(void);
 
 
 void LoadSky_f(void);
 
-cvar_t r_multitexture = {"r_multitexture", "1"};
-cvar_t r_skyquality = {"r_skyquality", "2", true};
-cvar_t r_mergesky = {"r_mergesky", "0", true};
+cvar_t r_multitexture = {0, "r_multitexture", "1"};
+cvar_t r_skyquality = {CVAR_SAVE, "r_skyquality", "2"};
+cvar_t r_mergesky = {CVAR_SAVE, "r_mergesky", "0"};
 
 char skyworldname[1024];
 rtexture_t *mergeskytexture;
 
 char skyworldname[1024];
 rtexture_t *mergeskytexture;
index 37052fd939e2e81255159cc6fc8b8370479d5d91..b3479c0930b8a0db957cfa3b3cf84477e5bad312 100644 (file)
@@ -62,30 +62,30 @@ float ixtable[4096];
 
 void R_MarkLeaves (void);
 
 
 void R_MarkLeaves (void);
 
-//cvar_t       r_norefresh = {"r_norefresh","0"};
-cvar_t r_drawentities = {"r_drawentities","1"};
-cvar_t r_drawviewmodel = {"r_drawviewmodel","1"};
-cvar_t r_speeds = {"r_speeds","0"};
-cvar_t r_speeds2 = {"r_speeds2","0"};
-cvar_t r_fullbright = {"r_fullbright","0"};
-//cvar_t       r_lightmap = {"r_lightmap","0"};
-cvar_t r_wateralpha = {"r_wateralpha","1"};
-cvar_t r_dynamic = {"r_dynamic","1"};
-cvar_t r_waterripple = {"r_waterripple","0"};
-cvar_t r_fullbrights = {"r_fullbrights", "1"};
-
-cvar_t gl_lightmode = {"gl_lightmode", "1", true}; // LordHavoc: overbright lighting
-//cvar_t       r_dynamicbothsides = {"r_dynamicbothsides", "1"}; // LordHavoc: can disable dynamic lighting of backfaces, but quake maps are weird so it doesn't always work right...
-cvar_t r_farclip = {"r_farclip", "6144"};
-
-cvar_t gl_fogenable = {"gl_fogenable", "0"};
-cvar_t gl_fogdensity = {"gl_fogdensity", "0.25"};
-cvar_t gl_fogred = {"gl_fogred","0.3"};
-cvar_t gl_foggreen = {"gl_foggreen","0.3"};
-cvar_t gl_fogblue = {"gl_fogblue","0.3"};
-cvar_t gl_fogstart = {"gl_fogstart", "0"};
-cvar_t gl_fogend = {"gl_fogend","0"};
-cvar_t glfog = {"glfog", "0"};
+//cvar_t       r_norefresh = {0, "r_norefresh","0"};
+cvar_t r_drawentities = {0, "r_drawentities","1"};
+cvar_t r_drawviewmodel = {0, "r_drawviewmodel","1"};
+cvar_t r_speeds = {0, "r_speeds","0"};
+cvar_t r_speeds2 = {0, "r_speeds2","0"};
+cvar_t r_fullbright = {0, "r_fullbright","0"};
+//cvar_t       r_lightmap = {0, "r_lightmap","0"};
+cvar_t r_wateralpha = {CVAR_SAVE, "r_wateralpha","1"};
+cvar_t r_dynamic = {CVAR_SAVE, "r_dynamic","1"};
+cvar_t r_waterripple = {CVAR_SAVE, "r_waterripple","0"};
+cvar_t r_fullbrights = {CVAR_SAVE, "r_fullbrights", "1"};
+
+cvar_t gl_lightmode = {CVAR_SAVE, "gl_lightmode", "1"}; // LordHavoc: overbright lighting
+//cvar_t       r_dynamicbothsides = {CVAR_SAVE, "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 = {0, "r_farclip", "6144"}; // FIXME: make this go away (calculate based on farthest visible object/polygon)
+
+cvar_t gl_fogenable = {0, "gl_fogenable", "0"};
+cvar_t gl_fogdensity = {0, "gl_fogdensity", "0.25"};
+cvar_t gl_fogred = {0, "gl_fogred","0.3"};
+cvar_t gl_foggreen = {0, "gl_foggreen","0.3"};
+cvar_t gl_fogblue = {0, "gl_fogblue","0.3"};
+cvar_t gl_fogstart = {0, "gl_fogstart", "0"};
+cvar_t gl_fogend = {0, "gl_fogend","0"};
+cvar_t glfog = {0, "glfog", "0"};
 
 /*
 int R_VisibleCullBox (vec3_t mins, vec3_t maxs)
 
 /*
 int R_VisibleCullBox (vec3_t mins, vec3_t maxs)
@@ -109,9 +109,9 @@ loc0:
                node = nodestack[--stack];
                goto loc0;
        }
                node = nodestack[--stack];
                goto loc0;
        }
-       
+
        sides = BOX_ON_PLANE_SIDE(mins, maxs, node->plane);
        sides = BOX_ON_PLANE_SIDE(mins, maxs, node->plane);
-       
+
 // recurse down the contacted sides
        if (sides & 1)
        {
 // recurse down the contacted sides
        if (sides & 1)
        {
@@ -244,7 +244,7 @@ void FOG_registercvars(void)
                Cvar_RegisterVariable (&gl_fogenable);
                Cvar_RegisterVariable (&gl_fogdensity);
                Cvar_RegisterVariable (&gl_fogred);
                Cvar_RegisterVariable (&gl_fogenable);
                Cvar_RegisterVariable (&gl_fogdensity);
                Cvar_RegisterVariable (&gl_fogred);
-               Cvar_RegisterVariable (&gl_foggreen); 
+               Cvar_RegisterVariable (&gl_foggreen);
                Cvar_RegisterVariable (&gl_fogblue);
                Cvar_RegisterVariable (&gl_fogstart);
                Cvar_RegisterVariable (&gl_fogend);
                Cvar_RegisterVariable (&gl_fogblue);
                Cvar_RegisterVariable (&gl_fogstart);
                Cvar_RegisterVariable (&gl_fogend);
@@ -304,6 +304,7 @@ extern void R_Particles_Init(void);
 extern void R_Explosion_Init(void);
 extern void CL_Effects_Init(void);
 extern void R_Clip_Init(void);
 extern void R_Explosion_Init(void);
 extern void CL_Effects_Init(void);
 extern void R_Clip_Init(void);
+extern void ui_init(void);
 
 void Render_Init(void)
 {
 
 void Render_Init(void)
 {
@@ -322,6 +323,7 @@ void Render_Init(void)
        R_Explosion_Init();
        CL_Effects_Init();
        R_Decals_Init();
        R_Explosion_Init();
        CL_Effects_Init();
        R_Decals_Init();
+       ui_init();
        R_Modules_Start();
 }
 
        R_Modules_Start();
 }
 
index 78ebba523ddbcaf209bca9056d0a0e97447ea77e..6f258d0e22126b15791a79215e786d63c6a336f1 100644 (file)
@@ -39,16 +39,16 @@ short lightmapupdate[MAX_LIGHTMAPS][2];
 signed int blocklights[BLOCK_WIDTH*BLOCK_HEIGHT*3]; // LordHavoc: *3 for colored lighting
 
 int lightmapalign, lightmapalignmask; // LordHavoc: NVIDIA's broken subimage fix, see BuildLightmaps for notes
 signed int blocklights[BLOCK_WIDTH*BLOCK_HEIGHT*3]; // LordHavoc: *3 for colored lighting
 
 int lightmapalign, lightmapalignmask; // LordHavoc: NVIDIA's broken subimage fix, see BuildLightmaps for notes
-cvar_t gl_lightmapalign = {"gl_lightmapalign", "4"};
-cvar_t gl_lightmaprgba = {"gl_lightmaprgba", "1"};
-cvar_t gl_nosubimagefragments = {"gl_nosubimagefragments", "0"};
-cvar_t gl_nosubimage = {"gl_nosubimage", "0"};
-cvar_t r_ambient = {"r_ambient", "0"};
-cvar_t gl_vertex = {"gl_vertex", "0"};
-cvar_t r_dlightmap = {"r_dlightmap", "1"};
-cvar_t r_drawportals = {"r_drawportals", "0"};
-cvar_t r_testvis = {"r_testvis", "0"};
-cvar_t r_solidworldnode = {"r_solidworldnode", "1"};
+cvar_t gl_lightmapalign = {0, "gl_lightmapalign", "4"};
+cvar_t gl_lightmaprgba = {0, "gl_lightmaprgba", "1"};
+cvar_t gl_nosubimagefragments = {0, "gl_nosubimagefragments", "0"};
+cvar_t gl_nosubimage = {0, "gl_nosubimage", "0"};
+cvar_t r_ambient = {0, "r_ambient", "0"};
+cvar_t gl_vertex = {0, "gl_vertex", "0"};
+cvar_t r_dlightmap = {CVAR_SAVE, "r_dlightmap", "1"};
+cvar_t r_drawportals = {0, "r_drawportals", "0"};
+cvar_t r_testvis = {0, "r_testvis", "0"};
+cvar_t r_solidworldnode = {0, "r_solidworldnode", "1"};
 
 qboolean lightmaprgba, nosubimagefragments, nosubimage;
 int lightmapbytes;
 
 qboolean lightmaprgba, nosubimagefragments, nosubimage;
 int lightmapbytes;
@@ -1469,248 +1469,6 @@ void R_PortalWorldNode (void)
 }
 */
 
 }
 */
 
-/*
-#define MAXRECURSIVEPORTALPLANES 1024
-#define MAXRECURSIVEPORTALS 256
-
-tinyplane_t portalplanes[MAXRECURSIVEPORTALPLANES];
-int portalplanestack[MAXRECURSIVEPORTALS];
-int portalplanecount;
-int ranoutofportalplanes;
-int ranoutofportals;
-int ranoutofleafs;
-int portalcantseeself;
-int portalrecursion;
-
-int R_ClipPolygonToPlane(float *in, float *out, int inpoints, int maxoutpoints, tinyplane_t *p)
-{
-       int i, outpoints, prevside, side;
-       float *prevpoint, prevdist, dist, dot;
-
-       if (inpoints < 3)
-               return inpoints;
-       // begin with the last point, then enter the loop with the first point as current
-       prevpoint = in + 3 * (inpoints - 1);
-       prevdist = DotProduct(prevpoint, p->normal) - p->dist;
-       prevside = prevdist >= 0 ? SIDE_FRONT : SIDE_BACK;
-       i = 0;
-       outpoints = 0;
-       goto begin;
-       for (;i < inpoints;i++)
-       {
-               prevpoint = in;
-               prevdist = dist;
-               prevside = side;
-               in += 3;
-
-begin:
-               dist = DotProduct(in, p->normal) - p->dist;
-               side = dist >= 0 ? SIDE_FRONT : SIDE_BACK;
-
-               if (prevside == SIDE_FRONT)
-               {
-                       if (outpoints >= maxoutpoints)
-                               return -1;
-                       VectorCopy(prevpoint, out);
-                       out += 3;
-                       outpoints++;
-                       if (side == SIDE_FRONT)
-                               continue;
-               }
-               else if (side == SIDE_BACK)
-                       continue;
-
-               // generate a split point
-               if (outpoints >= maxoutpoints)
-                       return -1;
-               dot = prevdist / (prevdist - dist);
-               out[0] = prevpoint[0] + dot * (in[0] - prevpoint[0]);
-               out[1] = prevpoint[1] + dot * (in[1] - prevpoint[1]);
-               out[2] = prevpoint[2] + dot * (in[2] - prevpoint[2]);
-               out += 3;
-               outpoints++;
-       }
-
-       return outpoints;
-}
-
-float portaltemppoints[2][256][3];
-float portaltemppoints2[256][3];
-
-int R_FrustumTestPolygon(float *points, int numpoints, int stride)
-{
-       int i;
-       float *out;
-       if (numpoints < 3)
-               return numpoints;
-       out = &portaltemppoints[0][0][0];
-       for (i = 0;i < numpoints;i++)
-       {
-               VectorCopy(points, portaltemppoints[0][i]);
-               (byte *)points += stride;
-       }
-       numpoints = R_ClipPolygonToPlane(&portaltemppoints[0][0][0], &portaltemppoints[1][0][0], numpoints, 256, (tinyplane_t *)&frustum[0]);
-       if (numpoints < 3)
-               return numpoints;
-       numpoints = R_ClipPolygonToPlane(&portaltemppoints[1][0][0], &portaltemppoints[0][0][0], numpoints, 256, (tinyplane_t *)&frustum[1]);
-       if (numpoints < 3)
-               return numpoints;
-       numpoints = R_ClipPolygonToPlane(&portaltemppoints[0][0][0], &portaltemppoints[1][0][0], numpoints, 256, (tinyplane_t *)&frustum[2]);
-       if (numpoints < 3)
-               return numpoints;
-       return      R_ClipPolygonToPlane(&portaltemppoints[1][0][0], &portaltemppoints[0][0][0], numpoints, 256, (tinyplane_t *)&frustum[3]);
-}
-
-void R_TriangleToPlane(vec3_t point1, vec3_t point2, vec3_t point3, tinyplane_t *p)
-{
-       vec3_t v1, v2;
-       VectorSubtract(point1, point2, v1);
-       VectorSubtract(point3, point2, v2);
-       CrossProduct(v1, v2, p->normal);
-//     VectorNormalize(p->normal);
-       VectorNormalizeFast(p->normal);
-       p->dist = DotProduct(point1, p->normal);
-}
-
-int R_PortalThroughPortalPlanes(tinyplane_t *clipplanes, int clipnumplanes, float *targpoints, int targnumpoints, float *out, int maxpoints)
-{
-       int numpoints, i;
-       if (targnumpoints < 3)
-               return targnumpoints;
-       if (maxpoints < 3)
-               return -1;
-       numpoints = targnumpoints;
-       memcpy(&portaltemppoints[0][0][0], targpoints, numpoints * 3 * sizeof(float));
-       for (i = 0;i < clipnumplanes;i++)
-       {
-               numpoints = R_ClipPolygonToPlane(&portaltemppoints[0][0][0], &portaltemppoints[1][0][0], numpoints, 256, clipplanes + i);
-               if (numpoints < 3)
-                       return numpoints;
-               memcpy(&portaltemppoints[0][0][0], &portaltemppoints[1][0][0], numpoints * 3 * sizeof(float));
-       }
-       if (numpoints > maxpoints)
-               return -1;
-       memcpy(out, &portaltemppoints[1][0][0], numpoints * 3 * sizeof(float));
-       return numpoints;
-}
-
-#define MAXRECURSIVEPORTALLEAFS 256
-
-//mleaf_t *leafstack[MAXRECURSIVEPORTALLEAFS];
-//int leafstackpos;
-int r_portalframecount;
-
-void R_RecursivePortalWorldNode (mleaf_t *leaf, int firstclipplane, int numclipplanes)
-{
-       mportal_t *p;
-
-//     if (leafstackpos >= MAXRECURSIVEPORTALLEAFS)
-//     {
-//             ranoutofleafs = true;
-//             return;
-//     }
-
-//     leafstack[leafstackpos++] = leaf;
-
-       if (leaf->visframe != r_framecount)
-       {
-               c_leafs++;
-               leaf->visframe = r_framecount;
-               if (leaf->nummarksurfaces)
-               {
-                       msurface_t *surf, **mark, **endmark;
-                       mark = leaf->firstmarksurface;
-                       endmark = mark + leaf->nummarksurfaces;
-                       do
-                       {
-                               surf = *mark++;
-                               // make sure surfaces are only processed once
-                               if (surf->worldnodeframe == r_framecount)
-                                       continue;
-                               surf->worldnodeframe = r_framecount;
-                               if (PlaneDist(modelorg, surf->plane) < surf->plane->dist)
-                               {
-                                       if (surf->flags & SURF_PLANEBACK)
-                                               RSurf_DoVisible(surf);
-                               }
-                               else
-                               {
-                                       if (!(surf->flags & SURF_PLANEBACK))
-                                               RSurf_DoVisible(surf);
-                               }
-                       }
-                       while (mark < endmark);
-               }
-       }
-
-       // follow portals into other leafs
-       for (p = leaf->portals;p;p = p->next)
-       {
-               int newpoints, i, prev;
-               vec3_t center;
-               vec3_t v1, v2;
-               tinyplane_t *newplanes;
-               // only flow through portals facing away from the viewer
-               if (PlaneDiff(r_origin, (&p->plane)) < 0)
-               {
-*/
-                       /*
-                       for (i = 0;i < leafstackpos;i++)
-                               if (leafstack[i] == p->past)
-                                       break;
-                       if (i < leafstackpos)
-                       {
-                               portalrecursion = true;
-                               continue;
-                       }
-                       */
-/*
-                       newpoints = R_PortalThroughPortalPlanes(&portalplanes[firstclipplane], numclipplanes, (float *) p->points, p->numpoints, &portaltemppoints2[0][0], 256);
-                       if (newpoints < 3)
-                               continue;
-                       else if (firstclipplane + numclipplanes + newpoints > MAXRECURSIVEPORTALPLANES)
-                               ranoutofportalplanes = true;
-                       else
-                       {
-                               // go ahead and mark the leaf early, nothing can abort here
-                               if (!r_testvis.value)
-                                       p->visframe = r_portalframecount;
-
-                               // find the center by averaging
-                               VectorClear(center);
-                               for (i = 0;i < newpoints;i++)
-                                       VectorAdd(center, portaltemppoints2[i], center);
-                               // ixtable is a 1.0f / N table
-                               VectorScale(center, ixtable[newpoints], center);
-                               // calculate the planes, and make sure the polygon can see it's own center
-                               newplanes = &portalplanes[firstclipplane + numclipplanes];
-                               for (prev = newpoints - 1, i = 0;i < newpoints;prev = i, i++)
-                               {
-//                                     R_TriangleToPlane(r_origin, portaltemppoints2[i], portaltemppoints2[prev], newplanes + i);
-                                       VectorSubtract(r_origin, portaltemppoints2[i], v1);
-                                       VectorSubtract(portaltemppoints2[prev], portaltemppoints2[i], v2);
-                                       CrossProduct(v1, v2, newplanes[i].normal);
-                                       VectorNormalizeFast(newplanes[i].normal);
-                                       newplanes[i].dist = DotProduct(r_origin, newplanes[i].normal);
-                                       if (DotProduct(newplanes[i].normal, center) <= newplanes[i].dist)
-                                       {
-                                               // polygon can't see it's own center, discard and use parent portal
-                                               break;
-                                       }
-                               }
-                               if (i == newpoints)
-                                       R_RecursivePortalWorldNode(p->past, firstclipplane + numclipplanes, newpoints);
-                               else
-                                       R_RecursivePortalWorldNode(p->past, firstclipplane, numclipplanes);
-                       }
-               }
-       }
-//     leafstackpos--;
-}
-
-//float viewportalpoints[16*3];
-
-*/
 
 int r_portalframecount = 0;
 
 
 int r_portalframecount = 0;
 
@@ -1810,33 +1568,6 @@ void R_PVSWorldNode()
        }
 }
 
        }
 }
 
-       /*
-       if (!r_testvis.value)
-               r_portalframecount = r_framecount;
-       portalplanecount = 0;
-//     leafstackpos = 0;
-       ranoutofportalplanes = false;
-       ranoutofportals = false;
-       ranoutofleafs = false;
-       portalcantseeself = 0;
-       portalrecursion = false;
-       memcpy(&portalplanes[0], &frustum[0], sizeof(tinyplane_t));
-       memcpy(&portalplanes[1], &frustum[1], sizeof(tinyplane_t));
-       memcpy(&portalplanes[2], &frustum[2], sizeof(tinyplane_t));
-       memcpy(&portalplanes[3], &frustum[3], sizeof(tinyplane_t));
-       R_RecursivePortalWorldNode(r_viewleaf, 0, 4);
-       if (ranoutofportalplanes)
-               Con_Printf("R_RecursivePortalWorldNode: ran out of %d plane stack when recursing through portals\n", MAXRECURSIVEPORTALPLANES);
-       if (ranoutofportals)
-               Con_Printf("R_RecursivePortalWorldNode: ran out of %d portal stack when recursing through portals\n", MAXRECURSIVEPORTALS);
-       if (ranoutofleafs)
-               Con_Printf("R_RecursivePortalWorldNode: ran out of %d leaf stack when recursing through portals\n", MAXRECURSIVEPORTALLEAFS);
-//     if (portalcantseeself)
-//             Con_Printf("R_RecursivePortalWorldNode: %d portals could not see themself during clipping\n", portalcantseeself);
-       if (portalrecursion)
-               Con_Printf("R_RecursivePortalWorldNode: portal saw into previously encountered leaf??\n");
-       */
-
 /*
 void R_OldPortalWorldNode (void)
 {
 /*
 void R_OldPortalWorldNode (void)
 {
index 56ba7f3abd390ca37c37c495867215b219c40166..977c4a04520841e6a638c6d7e12eb9543731d2cc 100644 (file)
@@ -76,18 +76,18 @@ float       scr_con_current;
 float  scr_conlines;           // lines of console to display
 
 float  oldscreensize, oldfov;
 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
+cvar_t scr_viewsize = {CVAR_SAVE, "viewsize","100"};
+cvar_t scr_fov = {CVAR_SAVE, "fov","90"};      // 10 - 170
+cvar_t scr_conspeed = {CVAR_SAVE, "scr_conspeed","900"}; // LordHavoc: quake used 300
+cvar_t scr_centertime = {0, "scr_centertime","2"};
+cvar_t scr_showram = {CVAR_SAVE, "showram","1"};
+cvar_t scr_showturtle = {CVAR_SAVE, "showturtle","0"};
+cvar_t scr_showpause = {CVAR_SAVE, "showpause","1"};
+cvar_t scr_printspeed = {0, "scr_printspeed","8"};
+cvar_t showfps = {CVAR_SAVE, "showfps", "0"};
+cvar_t r_render = {0, "r_render", "1"};
+cvar_t r_brightness = {CVAR_SAVE, "r_brightness", "1"}; // LordHavoc: a method of operating system independent color correction
+cvar_t r_contrast = {CVAR_SAVE, "r_contrast", "1"}; // LordHavoc: a method of operating system independent color correction
 
 qboolean       scr_initialized;                // ready to draw
 
 
 qboolean       scr_initialized;                // ready to draw
 
@@ -208,7 +208,7 @@ void SCR_CheckDrawCenterString (void)
                scr_erase_lines = scr_center_lines;
 
        scr_centertime_off -= host_frametime;
                scr_erase_lines = scr_center_lines;
 
        scr_centertime_off -= host_frametime;
-       
+
        if (scr_centertime_off <= 0 && !cl.intermission)
                return;
        if (key_dest != key_game)
        if (scr_centertime_off <= 0 && !cl.intermission)
                return;
        if (key_dest != key_game)
@@ -586,7 +586,7 @@ void SCR_ScreenShot_f (void)
        char            filename[80]; 
        char            checkname[MAX_OSPATH];
        int                     i;
        char            filename[80]; 
        char            checkname[MAX_OSPATH];
        int                     i;
-// 
+//
 // find a file name to save it to 
 // 
        strcpy(filename,"dp0000.tga");
 // find a file name to save it to 
 // 
        strcpy(filename,"dp0000.tga");
@@ -808,7 +808,7 @@ void SCR_UpdateScreen (void)
 
 
        GL_BeginRendering (&glx, &gly, &glwidth, &glheight);
 
 
        GL_BeginRendering (&glx, &gly, &glwidth, &glheight);
-       
+
        //
        // determine size of refresh window
        //
        //
        // determine size of refresh window
        //
@@ -860,9 +860,11 @@ void SCR_UpdateScreen (void)
        else if (cl.intermission == 2)
                Sbar_FinaleOverlay();
 
        else if (cl.intermission == 2)
                Sbar_FinaleOverlay();
 
-       SCR_DrawConsole();      
+       SCR_DrawConsole();
        M_Draw();
 
        M_Draw();
 
+       ui_draw();
+
 //     if (scr_drawloading)
 //             SCR_DrawLoading();
 
 //     if (scr_drawloading)
 //             SCR_DrawLoading();
 
@@ -880,7 +882,7 @@ void SCR_UpdateScreen (void)
        }
 
        // LordHavoc: only print info if renderer is being used
        }
 
        // LordHavoc: only print info if renderer is being used
-       if (r_speeds2.value && cl.worldmodel != NULL)
+       if (r_speeds2.value && !con_forcedup)
        {
                int i, j, lines, y;
                lines = 1;
        {
                int i, j, lines, y;
                lines = 1;
index c7b6221b5e599ba764085e8aa2a0642a6c248723..341be6c02769d498c258f3139309fe09499f3d68 100644 (file)
@@ -1,10 +1,10 @@
 #include "quakedef.h"
 
 #include "quakedef.h"
 
-cvar_t         r_max_size = {"r_max_size", "2048"};
-cvar_t         r_picmip = {"r_picmip", "0"};
-cvar_t         r_lerpimages = {"r_lerpimages", "1"};
-cvar_t         r_upload = {"r_upload", "1"};
-cvar_t         r_precachetextures = {"r_precachetextures", "1", true};
+cvar_t         r_max_size = {0, "r_max_size", "2048"};
+cvar_t         r_picmip = {0, "r_picmip", "0"};
+cvar_t         r_lerpimages = {CVAR_SAVE, "r_lerpimages", "1"};
+cvar_t         r_upload = {0, "r_upload", "1"};
+cvar_t         r_precachetextures = {CVAR_SAVE, "r_precachetextures", "1"};
 
 int            gl_filter_min = GL_LINEAR_MIPMAP_LINEAR; //NEAREST;
 int            gl_filter_max = GL_LINEAR;
 
 int            gl_filter_min = GL_LINEAR_MIPMAP_LINEAR; //NEAREST;
 int            gl_filter_max = GL_LINEAR;
diff --git a/host.c b/host.c
index 2ba18dca9a9c278170398282a23ddf78a12fa17a..39730caa98c71ab0fa565a9c3a3e7540f1796b8e 100644 (file)
--- a/host.c
+++ b/host.c
@@ -53,34 +53,34 @@ client_t    *host_client;                   // current client
 
 jmp_buf        host_abortserver;
 
 
 jmp_buf        host_abortserver;
 
-cvar_t host_framerate = {"host_framerate","0"};        // set for slow motion
-cvar_t host_speeds = {"host_speeds","0"};                      // set for running times
-cvar_t slowmo = {"slowmo", "1.0"};                                     // LordHavoc: framerate independent slowmo
-cvar_t host_minfps = {"host_minfps", "10"};            // LordHavoc: game logic lower cap on framerate (if framerate is below this is, it pretends it is this, so game logic will run normally)
-cvar_t host_maxfps = {"host_maxfps", "1000"};          // LordHavoc: framerate upper cap
+cvar_t host_framerate = {0, "host_framerate","0"};     // set for slow motion
+cvar_t host_speeds = {0, "host_speeds","0"};                   // set for running times
+cvar_t slowmo = {0, "slowmo", "1.0"};                                  // LordHavoc: framerate independent slowmo
+cvar_t host_minfps = {CVAR_SAVE, "host_minfps", "10"};         // LordHavoc: game logic lower cap on framerate (if framerate is below this is, it pretends it is this, so game logic will run normally)
+cvar_t host_maxfps = {CVAR_SAVE, "host_maxfps", "1000"};               // LordHavoc: framerate upper cap
 
 
-cvar_t sys_ticrate = {"sys_ticrate","0.05"};
-cvar_t serverprofile = {"serverprofile","0"};
+cvar_t sys_ticrate = {CVAR_SAVE, "sys_ticrate","0.05"};
+cvar_t serverprofile = {0, "serverprofile","0"};
 
 
-cvar_t fraglimit = {"fraglimit","0",false,true};
-cvar_t timelimit = {"timelimit","0",false,true};
-cvar_t teamplay = {"teamplay","0",false,true};
+cvar_t fraglimit = {CVAR_NOTIFY, "fraglimit","0"};
+cvar_t timelimit = {CVAR_NOTIFY, "timelimit","0"};
+cvar_t teamplay = {CVAR_NOTIFY, "teamplay","0"};
 
 
-cvar_t samelevel = {"samelevel","0"};
-cvar_t noexit = {"noexit","0",false,true};
+cvar_t samelevel = {0, "samelevel","0"};
+cvar_t noexit = {CVAR_NOTIFY, "noexit","0"};
 
 
-cvar_t developer = {"developer","0"};
+cvar_t developer = {0, "developer","0"};
 
 
-cvar_t skill = {"skill","1"};                                          // 0 - 3
-cvar_t deathmatch = {"deathmatch","0"};                        // 0, 1, or 2
-cvar_t coop = {"coop","0"};                    // 0 or 1
+cvar_t skill = {0, "skill","1"};                                               // 0 - 3
+cvar_t deathmatch = {0, "deathmatch","0"};                     // 0, 1, or 2
+cvar_t coop = {0, "coop","0"};                 // 0 or 1
 
 
-cvar_t pausable = {"pausable","1"};
+cvar_t pausable = {0, "pausable","1"};
 
 
-cvar_t temp1 = {"temp1","0"};
+cvar_t temp1 = {0, "temp1","0"};
 
 
-cvar_t timestamps = {"timestamps", "0", true};
-cvar_t timeformat = {"timeformat", "[%b %e %X] ", true};
+cvar_t timestamps = {CVAR_SAVE, "timestamps", "0"};
+cvar_t timeformat = {CVAR_SAVE, "timeformat", "[%b %e %X] "};
 
 /*
 ================
 
 /*
 ================
@@ -91,18 +91,18 @@ void Host_EndGame (char *message, ...)
 {
        va_list         argptr;
        char            string[1024];
 {
        va_list         argptr;
        char            string[1024];
-       
+
        va_start (argptr,message);
        vsprintf (string,message,argptr);
        va_end (argptr);
        Con_DPrintf ("Host_EndGame: %s\n",string);
        va_start (argptr,message);
        vsprintf (string,message,argptr);
        va_end (argptr);
        Con_DPrintf ("Host_EndGame: %s\n",string);
-       
+
        if (sv.active)
                Host_ShutdownServer (false);
 
        if (cls.state == ca_dedicated)
                Sys_Error ("Host_EndGame: %s\n",string);        // dedicated servers exit
        if (sv.active)
                Host_ShutdownServer (false);
 
        if (cls.state == ca_dedicated)
                Sys_Error ("Host_EndGame: %s\n",string);        // dedicated servers exit
-       
+
        if (cls.demonum != -1)
                CL_NextDemo ();
        else
        if (cls.demonum != -1)
                CL_NextDemo ();
        else
@@ -644,7 +644,7 @@ void _Host_Frame (float time)
 
 // keep the random time dependent
        rand ();
 
 // keep the random time dependent
        rand ();
-       
+
 // decide the simulation time
        if (!Host_FilterTime (time))
        {
 // decide the simulation time
        if (!Host_FilterTime (time))
        {
@@ -652,7 +652,7 @@ void _Host_Frame (float time)
                Sys_Sleep();
                return;
        }
                Sys_Sleep();
                return;
        }
-               
+
 // get new key events
        Sys_SendKeyEvents ();
 
 // get new key events
        Sys_SendKeyEvents ();
 
@@ -667,7 +667,7 @@ void _Host_Frame (float time)
 // if running the server locally, make intentions now
        if (sv.active)
                CL_SendCmd ();
 // if running the server locally, make intentions now
        if (sv.active)
                CL_SendCmd ();
-       
+
 //-------------------
 //
 // server operations
 //-------------------
 //
 // server operations
@@ -676,7 +676,7 @@ void _Host_Frame (float time)
 
 // check for commands typed to the host
        Host_GetConsoleCommands ();
 
 // check for commands typed to the host
        Host_GetConsoleCommands ();
-       
+
        if (sv.active)
                Host_ServerFrame ();
 
        if (sv.active)
                Host_ServerFrame ();
 
@@ -695,15 +695,17 @@ void _Host_Frame (float time)
        if (cls.state == ca_connected)
                CL_ReadFromServer ();
 
        if (cls.state == ca_connected)
                CL_ReadFromServer ();
 
+       ui_update();
+
 // update video
        if (host_speeds.value)
                time1 = Sys_DoubleTime ();
 // update video
        if (host_speeds.value)
                time1 = Sys_DoubleTime ();
-               
+
        SCR_UpdateScreen ();
 
        if (host_speeds.value)
                time2 = Sys_DoubleTime ();
        SCR_UpdateScreen ();
 
        if (host_speeds.value)
                time2 = Sys_DoubleTime ();
-               
+
 // update audio
        if (cls.signon == SIGNONS)
        {
 // update audio
        if (cls.signon == SIGNONS)
        {
@@ -712,7 +714,7 @@ void _Host_Frame (float time)
        }
        else
                S_Update (vec3_origin, vec3_origin, vec3_origin, vec3_origin);
        }
        else
                S_Update (vec3_origin, vec3_origin, vec3_origin, vec3_origin);
-       
+
        CDAudio_Update();
 
        if (host_speeds.value)
        CDAudio_Update();
 
        if (host_speeds.value)
@@ -724,7 +726,7 @@ void _Host_Frame (float time)
                Con_Printf ("%6ius total %6ius server %6ius gfx %6ius snd\n",
                                        pass1+pass2+pass3, pass1, pass2, pass3);
        }
                Con_Printf ("%6ius total %6ius server %6ius gfx %6ius snd\n",
                                        pass1+pass2+pass3, pass1, pass2, pass3);
        }
-       
+
        host_framecount++;
 }
 
        host_framecount++;
 }
 
index 2527be89cb5a133f820b079668d9a9f9838926d0..f585bf7a82cda7acc5d0c3ca8498f0f779276099 100644 (file)
@@ -58,12 +58,12 @@ static int  mouse_buttonstate;
 static int     mouse_oldbuttonstate;
 static float   mouse_x, mouse_y;
 static float   old_mouse_x, old_mouse_y;
 static int     mouse_oldbuttonstate;
 static float   mouse_x, mouse_y;
 static float   old_mouse_x, old_mouse_y;
-static int     mx, my;
+static int     mx, my, uimx, uimy;
 
 static void IN_init_kb(void);
 static void IN_init_mouse(void);
 
 
 static void IN_init_kb(void);
 static void IN_init_mouse(void);
 
-cvar_t m_filter = {"m_filter","0"};
+cvar_t m_filter = {CVAR_SAVE, "m_filter","0"};
 
 static void keyhandler(int scancode, int state)
 {
 
 static void keyhandler(int scancode, int state)
 {
@@ -80,6 +80,8 @@ static void keyhandler(int scancode, int state)
 static void mousehandler(int buttonstate, int dx, int dy, int dz, int drx, int dry, int drz)
 {
        mouse_buttonstate = buttonstate;
 static void mousehandler(int buttonstate, int dx, int dy, int dz, int drx, int dry, int drz)
 {
        mouse_buttonstate = buttonstate;
+       uimx += dx;
+       uimy += dy;
        mx += dx;
        my += dy;
        if (drx > 0) {
        mx += dx;
        my += dy;
        if (drx > 0) {
@@ -97,6 +99,7 @@ void IN_Init(void)
        if (COM_CheckParm("-nokbd")) UseKeyboard = 0;
        if (COM_CheckParm("-nomouse")) UseMouse = 0;
 
        if (COM_CheckParm("-nokbd")) UseKeyboard = 0;
        if (COM_CheckParm("-nomouse")) UseMouse = 0;
 
+       uimx = uimy = 0;
        if (UseKeyboard)
                IN_init_kb();
        if (UseMouse)
        if (UseKeyboard)
                IN_init_kb();
        if (UseMouse)
@@ -264,8 +267,10 @@ void IN_Shutdown(void)
 {
        Con_Printf("IN_Shutdown\n");
 
 {
        Con_Printf("IN_Shutdown\n");
 
-       if (UseMouse) mouse_close();
-       if (UseKeyboard) keyboard_close();
+       if (UseMouse)
+               mouse_close();
+       if (UseKeyboard)
+               keyboard_close();
        in_svgalib_inited = 0;
 }
 
        in_svgalib_inited = 0;
 }
 
@@ -318,12 +323,21 @@ void IN_Commands(void)
 void IN_Move(usercmd_t *cmd)
 {
        int mouselook = (in_mlook.state & 1) || freelook.value;
 void IN_Move(usercmd_t *cmd)
 {
        int mouselook = (in_mlook.state & 1) || freelook.value;
-       if (!UseMouse) return;
+       if (!UseMouse)
+               return;
 
        /* Poll mouse values */
        while (mouse_update())
                ;
 
 
        /* Poll mouse values */
        while (mouse_update())
                ;
 
+       if (key_dest != key_game)
+       {
+               ui_mouseupdaterelative(uimx, uimy);
+               uimx = uimy = 0;
+               return;
+       }
+       uimx = uimy = 0;
+
        if (m_filter.value)
        {
                mouse_x = (mx + old_mouse_x) * 0.5;
        if (m_filter.value)
        {
                mouse_x = (mx + old_mouse_x) * 0.5;
@@ -348,7 +362,8 @@ void IN_Move(usercmd_t *cmd)
        else
                cl.viewangles[YAW] -= m_yaw.value * mouse_x;
 
        else
                cl.viewangles[YAW] -= m_yaw.value * mouse_x;
 
-       if (mouselook) V_StopPitchDrift();
+       if (mouselook)
+               V_StopPitchDrift();
 
        // LordHavoc: changed limits on pitch from -70 to 80, to -90 to 90
        if (mouselook && !(in_strafe.state & 1))
 
        // LordHavoc: changed limits on pitch from -70 to 80, to -90 to 90
        if (mouselook && !(in_strafe.state & 1))
index d27f5976987734582a8e3498540ce679ea45f0eb..5f29a9e91b7076de3a7f57b372dce2fa30f72a68 100644 (file)
--- a/in_win.c
+++ b/in_win.c
@@ -33,7 +33,7 @@ HRESULT (WINAPI *pDirectInputCreate)(HINSTANCE hinst, DWORD dwVersion,
        LPDIRECTINPUT * lplpDirectInput, LPUNKNOWN punkOuter);
 
 // mouse variables
        LPDIRECTINPUT * lplpDirectInput, LPUNKNOWN punkOuter);
 
 // mouse variables
-cvar_t m_filter = {"m_filter","0"};
+cvar_t m_filter = {CVAR_SAVE, "m_filter","0"};
 
 int                    mouse_buttons;
 int                    mouse_oldbuttonstate;
 
 int                    mouse_buttons;
 int                    mouse_oldbuttonstate;
@@ -540,7 +540,11 @@ void IN_MouseMove (usercmd_t *cmd)
        HRESULT                         hr;
 
        if (!mouseactive)
        HRESULT                         hr;
 
        if (!mouseactive)
+       {
+               GetCursorPos (&current_pos);
+               ui_updatemouse(current_pos.x - window_x, current_pos.y - window_y);
                return;
                return;
+       }
 
        if (dinput)
        {
 
        if (dinput)
        {
@@ -592,7 +596,7 @@ void IN_MouseMove (usercmd_t *cmd)
                                        else
                                                mstate_di &= ~(1<<1);
                                        break;
                                        else
                                                mstate_di &= ~(1<<1);
                                        break;
-                                       
+
                                case DIMOFS_BUTTON2:
                                        if (od.dwData & 0x80)
                                                mstate_di |= (1<<2);
                                case DIMOFS_BUTTON2:
                                        if (od.dwData & 0x80)
                                                mstate_di |= (1<<2);
@@ -616,8 +620,8 @@ void IN_MouseMove (usercmd_t *cmd)
                        {
                                Key_Event (K_MOUSE1 + i, false);
                        }
                        {
                                Key_Event (K_MOUSE1 + i, false);
                        }
-               }       
-                       
+               }
+
                mouse_oldbuttonstate = mstate_di;
        }
        else
                mouse_oldbuttonstate = mstate_di;
        }
        else
index 2357b83beffe62d38b0781531028cd35651f7286..043cea8ef32176f98976b527ccecd9ce0fb4e262 100644 (file)
--- a/makefile
+++ b/makefile
@@ -9,7 +9,7 @@ SOUNDLIB=-lasound
 #SND=snd_oss.o
 #SOUNDLIB=
 
 #SND=snd_oss.o
 #SOUNDLIB=
 
-OBJECTS= buildnumber.o cd_linux.o chase.o cl_demo.o cl_input.o cl_main.o cl_parse.o cl_tent.o cmd.o common.o console.o crc.o cvar.o fractalnoise.o gl_draw.o gl_poly.o gl_rmain.o gl_rmisc.o gl_rsurf.o gl_screen.o gl_warp.o host.o host_cmd.o image.o keys.o mathlib.o menu.o model_alias.o model_brush.o model_shared.o model_sprite.o net_bsd.o net_udp.o net_dgrm.o net_loop.o net_main.o pr_cmds.o pr_edict.o pr_exec.o r_light.o r_part.o r_explosion.o sbar.o snd_dma.o snd_mem.o snd_mix.o $(SND) sv_main.o sv_move.o sv_phys.o sv_user.o sv_light.o sys_linux.o transform.o view.o wad.o world.o zone.o vid_shared.o palette.o r_crosshairs.o gl_textures.o gl_models.o r_sprites.o r_modules.o r_explosion.o r_lerpanim.o cl_effects.o r_decals.o protocol.o quakeio.o r_clip.o
+OBJECTS= buildnumber.o cd_linux.o chase.o cl_demo.o cl_input.o cl_main.o cl_parse.o cl_tent.o cmd.o common.o console.o crc.o cvar.o fractalnoise.o gl_draw.o gl_poly.o gl_rmain.o gl_rmisc.o gl_rsurf.o gl_screen.o gl_warp.o host.o host_cmd.o image.o keys.o mathlib.o menu.o model_alias.o model_brush.o model_shared.o model_sprite.o net_bsd.o net_udp.o net_dgrm.o net_loop.o net_main.o pr_cmds.o pr_edict.o pr_exec.o r_light.o r_part.o r_explosion.o sbar.o snd_dma.o snd_mem.o snd_mix.o $(SND) sv_main.o sv_move.o sv_phys.o sv_user.o sv_light.o sys_linux.o transform.o view.o wad.o world.o zone.o vid_shared.o palette.o r_crosshairs.o gl_textures.o gl_models.o r_sprites.o r_modules.o r_explosion.o r_lerpanim.o cl_effects.o r_decals.o protocol.o quakeio.o r_clip.o ui.o portals.o
 
 #K6/athlon optimizations
 CPUOPTIMIZATIONS=-march=k6
 
 #K6/athlon optimizations
 CPUOPTIMIZATIONS=-march=k6
@@ -28,11 +28,11 @@ NOPROFILEOPTIMIZATIONS=
 #this is used to ensure that all released versions are free of warnings.
 
 #normal compile
 #this is used to ensure that all released versions are free of warnings.
 
 #normal compile
-#OPTIMIZATIONS= -O6 -ffast-math -funroll-loops $(NOPROFILEOPTIMIZATIONS) -fexpensive-optimizations $(CPUOPTIMIZATIONS)
-#CFLAGS= -MD -Wall -Werror -I/usr/X11R6/include -I/usr/include/glide $(OPTIMIZATIONS) $(PROFILEOPTION)
+OPTIMIZATIONS= -O6 -ffast-math -funroll-loops $(NOPROFILEOPTIMIZATIONS) -fexpensive-optimizations $(CPUOPTIMIZATIONS)
+CFLAGS= -MD -Wall -Werror -I/usr/X11R6/include -I/usr/include/glide $(OPTIMIZATIONS) $(PROFILEOPTION)
 #debug compile
 #debug compile
-OPTIMIZATIONS= -O -g
-CFLAGS= -MD -Wall -Werror -I/usr/X11R6/include -ggdb $(OPTIMIZATIONS) $(PROFILEOPTION)
+#OPTIMIZATIONS= -O -g
+#CFLAGS= -MD -Wall -Werror -I/usr/X11R6/include -ggdb $(OPTIMIZATIONS) $(PROFILEOPTION)
 
 LDFLAGS= -L/usr/X11R6/lib -lm -lX11 -lXext -lXIE -lXxf86dga -lXxf86vm -lGL -ldl $(SOUNDLIB) -lz $(PROFILEOPTION)
 
 
 LDFLAGS= -L/usr/X11R6/lib -lm -lX11 -lXext -lXIE -lXxf86dga -lXxf86vm -lGL -ldl $(SOUNDLIB) -lz $(PROFILEOPTION)
 
index ac10b6ebd34b5b4579def4d0016701e343580a7d..1a3b8684fb51623e74ba50562a578ea654eee2ce 100644 (file)
@@ -8,7 +8,7 @@ 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
 
 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.  
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 See the GNU General Public License for more details.
 
 
 See the GNU General Public License for more details.
 
@@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include "quakedef.h"
 
 
 #include "quakedef.h"
 
-cvar_t r_mipskins = {"r_mipskins", "1", true};
+cvar_t r_mipskins = {CVAR_SAVE, "r_mipskins", "1"};
 
 /*
 ===============
 
 /*
 ===============
index 81a06f6655dc1c763ee22847e017a2dd73096229..d417326f79e8813d09a4c972183cd452a3cb2024 100644 (file)
@@ -8,7 +8,7 @@ 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
 
 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.  
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 See the GNU General Public License for more details.
 
 
 See the GNU General Public License for more details.
 
@@ -24,9 +24,9 @@ byte  mod_novis[MAX_MAP_LEAFS/8];
 
 qboolean       hlbsp; // LordHavoc: true if it is a HalfLife BSP file (version 30)
 
 
 qboolean       hlbsp; // LordHavoc: true if it is a HalfLife BSP file (version 30)
 
-cvar_t gl_subdivide_size = {"gl_subdivide_size", "128", true};
-cvar_t halflifebsp = {"halflifebsp", "0"};
-cvar_t r_novis = {"r_novis", "0"};
+cvar_t gl_subdivide_size = {CVAR_SAVE, "gl_subdivide_size", "128"};
+cvar_t halflifebsp = {0, "halflifebsp", "0"};
+cvar_t r_novis = {0, "r_novis", "0"};
 
 /*
 ===============
 
 /*
 ===============
index 24710e2ef98aee9fcc34069491b881dec6940b13..41d42c956eb0a970ccc36a85982138e73d2ae8ff 100644 (file)
@@ -170,6 +170,7 @@ typedef struct mleaf_s
 // leaf specific
 //     int                     visframe;               // visible if current (r_framecount)
 //     int                     worldnodeframe; // used by certain worldnode variants to avoid processing the same leaf twice in a frame
 // leaf specific
 //     int                     visframe;               // visible if current (r_framecount)
 //     int                     worldnodeframe; // used by certain worldnode variants to avoid processing the same leaf twice in a frame
+       int                     portalmarkid;   // used by polygon-through-portals visibility checker
 
        // for bounding box culling
        vec3_t          mins;
 
        // for bounding box culling
        vec3_t          mins;
index fda321eec23754dc85853fa60b6c13f03a9f85f0..d2509037263453cea54c4f494f39a154c1e60554 100644 (file)
@@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include "quakedef.h"
 
 
 #include "quakedef.h"
 
-cvar_t r_mipsprites = {"r_mipsprites", "1", true};
+cvar_t r_mipsprites = {CVAR_SAVE, "r_mipsprites", "1"};
 
 /*
 ===============
 
 /*
 ===============
@@ -56,7 +56,7 @@ void Mod_Sprite_StripExtension(char *in, char *out)
 Mod_LoadSpriteFrame
 =================
 */
 Mod_LoadSpriteFrame
 =================
 */
-void * Mod_LoadSpriteFrame (void * pin, mspriteframe_t *frame, int framenum, int bytesperpixel)
+void * Mod_LoadSpriteFrame (void * pin, mspriteframe_t *frame, int framenum, int bytesperpixel, byte *palette)
 {
        dspriteframe_t          *pinframe;
        mspriteframe_t          *pspriteframe;
 {
        dspriteframe_t          *pinframe;
        mspriteframe_t          *pspriteframe;
@@ -88,42 +88,42 @@ void * Mod_LoadSpriteFrame (void * pin, mspriteframe_t *frame, int framenum, int
        sprintf (name, "%s_%i", tempname, framenum);
        pspriteframe->texture = loadtextureimagewithmask(name, 0, 0, false, r_mipsprites.value, true);
        pspriteframe->fogtexture = image_masktex;
        sprintf (name, "%s_%i", tempname, framenum);
        pspriteframe->texture = loadtextureimagewithmask(name, 0, 0, false, r_mipsprites.value, true);
        pspriteframe->fogtexture = image_masktex;
-       if (!pspriteframe->texture)
+
+       pixbuf = qmalloc(width*height*4);
+
+       inpixel = (byte *)(pinframe + 1);
+       pixel = pixbuf;
+       if (bytesperpixel == 1)
        {
        {
-               pspriteframe->texture = R_LoadTexture (name, width, height, (byte *)(pinframe + 1), TEXF_ALPHA | (bytesperpixel > 1 ? TEXF_RGBA : 0) | (r_mipsprites.value ? TEXF_MIPMAP : 0) | TEXF_PRECACHE);
-               // make fog version (just alpha)
-               pixbuf = pixel = qmalloc(width*height*4);
-               inpixel = (byte *)(pinframe + 1);
-               if (bytesperpixel == 1)
+               for (i = 0;i < width * height;i++)
                {
                {
-                       for (i = 0;i < width*height;i++)
-                       {
-                               *pixel++ = 255;
-                               *pixel++ = 255;
-                               *pixel++ = 255;
-                               if (*inpixel++ != 255)
-                                       *pixel++ = 255;
-                               else
-                                       *pixel++ = 0;
-                       }
+                       *pixel++ = palette[inpixel[i]*4+0];
+                       *pixel++ = palette[inpixel[i]*4+1];
+                       *pixel++ = palette[inpixel[i]*4+2];
+                       *pixel++ = palette[inpixel[i]*4+3];
                }
                }
-               else
+       }
+       else
+               memcpy(pixel, inpixel, width*height*4);
+
+       if (!pspriteframe->texture)
+       {
+               pspriteframe->texture = R_LoadTexture (name, width, height, pixbuf, TEXF_ALPHA | TEXF_RGBA | (r_mipsprites.value ? TEXF_MIPMAP : 0) | TEXF_PRECACHE);
+               // make fog version (just alpha)
+               pixel = pixbuf;
+               for (i = 0;i < width*height;i++)
                {
                {
-                       inpixel+=3;
-                       for (i = 0;i < width*height;i++)
-                       {
-                               *pixel++ = 255;
-                               *pixel++ = 255;
-                               *pixel++ = 255;
-                               *pixel++ = *inpixel;
-                               inpixel+=4;
-                       }
+                       *pixel++ = 255;
+                       *pixel++ = 255;
+                       *pixel++ = 255;
+                       pixel++;
                }
                sprintf (name, "%s_%ifog", loadmodel->name, framenum);
                pspriteframe->fogtexture = R_LoadTexture (name, width, height, pixbuf, TEXF_ALPHA | TEXF_RGBA | (r_mipsprites.value ? TEXF_MIPMAP : 0) | TEXF_PRECACHE);
                }
                sprintf (name, "%s_%ifog", loadmodel->name, framenum);
                pspriteframe->fogtexture = R_LoadTexture (name, width, height, pixbuf, TEXF_ALPHA | TEXF_RGBA | (r_mipsprites.value ? TEXF_MIPMAP : 0) | TEXF_PRECACHE);
-               qfree(pixbuf);
        }
 
        }
 
+       qfree(pixbuf);
+
        return (void *)((byte *)pinframe + sizeof (dspriteframe_t) + size);
 }
 
        return (void *)((byte *)pinframe + sizeof (dspriteframe_t) + size);
 }
 
@@ -133,6 +133,7 @@ void * Mod_LoadSpriteFrame (void * pin, mspriteframe_t *frame, int framenum, int
 Mod_LoadSpriteGroup
 =================
 */
 Mod_LoadSpriteGroup
 =================
 */
+/*
 void *Mod_LoadSpriteGroup (void * pin, mspriteframe_t *frame, int numframes, int framenum, int bytesperpixel)
 {
        int i;
 void *Mod_LoadSpriteGroup (void * pin, mspriteframe_t *frame, int numframes, int framenum, int bytesperpixel)
 {
        int i;
@@ -145,14 +146,10 @@ void *Mod_LoadSpriteGroup (void * pin, mspriteframe_t *frame, int numframes, int
 
        return ptemp;
 }
 
        return ptemp;
 }
-
-
-/*
-=================
-Mod_LoadSpriteModel
-=================
 */
 */
-void Mod_LoadSpriteModel (model_t *mod, void *buffer)
+
+// this actually handles both quake sprite and darkplaces sprite32
+void Mod_LoadQuakeSprite (model_t *mod, void *buffer)
 {
        int                                     i, j, version, numframes, realframes, size, bytesperpixel, start, end, total, maxwidth, maxheight;
        dsprite_t                       *pin;
 {
        int                                     i, j, version, numframes, realframes, size, bytesperpixel, start, end, total, maxwidth, maxheight;
        dsprite_t                       *pin;
@@ -182,14 +179,7 @@ void Mod_LoadSpriteModel (model_t *mod, void *buffer)
        pin = (dsprite_t *)buffer;
 
        version = LittleLong (pin->version);
        pin = (dsprite_t *)buffer;
 
        version = LittleLong (pin->version);
-       if (version == 2)
-       {
-               version = 32;
-               Con_Printf("warning: %s is a version 2 sprite (RGBA), supported for now, please hex edit to version 32 incase HalfLife sprites might be supported at some point.\n", mod->name);
-       }
        // LordHavoc: 32bit textures
        // LordHavoc: 32bit textures
-       if (version != SPRITE_VERSION && version != SPRITE32_VERSION)
-               Host_Error ("%s has wrong version number (%i should be %i or %i)", mod->name, version, SPRITE_VERSION, SPRITE32_VERSION);
        bytesperpixel = 1;
        if (version == SPRITE32_VERSION)
                bytesperpixel = 4;
        bytesperpixel = 1;
        if (version == SPRITE32_VERSION)
                bytesperpixel = 4;
@@ -211,12 +201,12 @@ void Mod_LoadSpriteModel (model_t *mod, void *buffer)
        mod->maxs[0] = mod->maxs[1] = maxwidth/2;
        mod->mins[2] = -maxheight/2;
        mod->maxs[2] = maxheight/2;
        mod->maxs[0] = mod->maxs[1] = maxwidth/2;
        mod->mins[2] = -maxheight/2;
        mod->maxs[2] = maxheight/2;
-       
+
 //
 // load the frames
 //
        if (numframes < 1)
 //
 // load the frames
 //
        if (numframes < 1)
-               Host_Error ("Mod_LoadSpriteModel: Invalid # of frames: %d\n", numframes);
+               Host_Error ("Mod_LoadQuakeSprite: Invalid # of frames: %d\n", numframes);
 
        mod->numframes = numframes;
 
 
        mod->numframes = numframes;
 
@@ -272,7 +262,179 @@ void Mod_LoadSpriteModel (model_t *mod, void *buffer)
        {
                for (j = 0;j < animscenes[i].framecount;j++)
                {
        {
                for (j = 0;j < animscenes[i].framecount;j++)
                {
-                       Mod_LoadSpriteFrame (framedata[realframes], frames + realframes, i, bytesperpixel);
+                       Mod_LoadSpriteFrame (framedata[realframes], frames + realframes, i, bytesperpixel, (byte *)&d_8to24table);
+                       realframes++;
+               }
+       }
+
+       psprite->ofs_frames = (int) frames - (int) psprite;
+
+       qfree(framedata);
+
+       mod->type = mod_sprite;
+
+// move the complete, relocatable sprite model to the cache
+       end = Hunk_LowMark ();
+       mod->cachesize = total = end - start;
+
+       Cache_Alloc (&mod->cache, total, loadname);
+       if (!mod->cache.data)
+               return;
+       memcpy (mod->cache.data, psprite, total);
+
+       Hunk_FreeToLowMark (start);
+}
+
+void Mod_LoadHLSprite (model_t *mod, void *buffer)
+{
+       int                                     i, j, numframes, realframes, size, start, end, total, maxwidth, maxheight, rendermode;
+       byte                            palette[256][4], *in;
+       dspritehl_t                     *pin;
+       msprite_t                       *psprite;
+       dspriteframetype_t      *pframetype;
+       dspriteframe_t          *pframe;
+       animscene_t                     *animscenes;
+       mspriteframe_t          *frames;
+       dspriteframe_t          **framedata;
+
+       start = Hunk_LowMark ();
+
+       mod->flags = EF_FULLBRIGHT;
+
+       // build a list of frames while parsing
+       framedata = qmalloc(65536*sizeof(dspriteframe_t));
+
+       pin = (dspritehl_t *)buffer;
+
+       numframes = LittleLong (pin->numframes);
+
+       psprite = Hunk_AllocName (sizeof(msprite_t), va("%s info", loadname));
+
+       psprite->type = LittleLong (pin->type);
+       maxwidth = LittleLong (pin->width);
+       maxheight = LittleLong (pin->height);
+       mod->synctype = LittleLong (pin->synctype);
+       rendermode = pin->rendermode;
+
+       mod->mins[0] = mod->mins[1] = -maxwidth/2;
+       mod->maxs[0] = mod->maxs[1] = maxwidth/2;
+       mod->mins[2] = -maxheight/2;
+       mod->maxs[2] = maxheight/2;
+
+//
+// load the frames
+//
+       if (numframes < 1)
+               Host_Error ("Mod_LoadHLSprite: Invalid # of frames: %d\n", numframes);
+
+       mod->numframes = numframes;
+
+       in = (byte *)(pin + 1);
+       i = in[0] + in[1] * 256;
+       if (i != 256)
+               Host_Error ("Mod_LoadHLSprite: unexpected number of palette colors %i (should be 256)", i);
+       in += 2;
+       switch(rendermode)
+       {
+       case SPRHL_NORMAL:
+               for (i = 0;i < 256;i++)
+               {
+                       palette[i][0] = *in++;
+                       palette[i][1] = *in++;
+                       palette[i][2] = *in++;
+                       palette[i][3] = 255;
+               }
+               palette[255][0] = palette[255][1] = palette[255][2] = palette[255][3] = 0;
+               break;
+       case SPRHL_ADDITIVE:
+               for (i = 0;i < 256;i++)
+               {
+                       palette[i][0] = *in++;
+                       palette[i][1] = *in++;
+                       palette[i][2] = *in++;
+                       palette[i][3] = 255;
+               }
+//             palette[255][0] = palette[255][1] = palette[255][2] = palette[255][3] = 0;
+               mod->flags |= EF_ADDITIVE;
+               break;
+       case SPRHL_INDEXALPHA:
+               for (i = 0;i < 256;i++)
+               {
+                       palette[i][0] = 255;
+                       palette[i][1] = 255;
+                       palette[i][2] = 255;
+                       palette[i][3] = i;
+                       in += 3;
+               }
+               break;
+       case SPRHL_ALPHATEST:
+               for (i = 0;i < 256;i++)
+               {
+                       palette[i][0] = *in++;
+                       palette[i][1] = *in++;
+                       palette[i][2] = *in++;
+                       palette[i][3] = 255;
+               }
+               palette[0][0] = palette[0][1] = palette[0][2] = palette[0][3] = 0;
+               break;
+       default:
+               Host_Error("Mod_LoadHLSprite: unknown texFormat (%i, should be 0, 1, 2, or 3)\n", i);
+               return;
+       }
+
+       pframetype = (dspriteframetype_t *)in;
+
+       animscenes = Hunk_AllocName(sizeof(animscene_t) * mod->numframes, va("%s sceneinfo", loadname));
+
+       realframes = 0;
+
+       for (i = 0;i < numframes;i++)
+       {
+               spriteframetype_t       frametype;
+
+               frametype = LittleLong (pframetype->type);
+
+               sprintf(animscenes[i].name, "frame%i", i);
+               animscenes[i].firstframe = realframes;
+               animscenes[i].loop = true;
+               if (frametype == SPR_SINGLE)
+               {
+                       animscenes[i].framecount = 1;
+                       animscenes[i].framerate = 10;
+                       pframe = (dspriteframe_t *) (pframetype + 1);
+                       framedata[realframes] = pframe;
+                       size = LittleLong(pframe->width) * LittleLong(pframe->height);
+                       pframetype = (dspriteframetype_t *) (size + sizeof(dspriteframe_t) + (int) pframe);
+                       realframes++;
+               }
+               else
+               {
+                       j = LittleLong(((dspritegroup_t *) (sizeof(dspriteframetype_t) + (int) pframetype))->numframes);
+                       animscenes[i].framecount = j;
+                       // FIXME: support variable framerate?
+                       animscenes[i].framerate = 1.0f / LittleFloat(((dspriteinterval_t *) (sizeof(dspritegroup_t) + sizeof(dspriteframetype_t) + (int) pframetype))->interval);
+                       pframe = (dspriteframe_t *) (sizeof(dspriteinterval_t) * j + sizeof(dspritegroup_t) + sizeof(dspriteframetype_t) + (int) pframetype);
+                       while (j--)
+                       {
+                               framedata[realframes] = pframe;
+                               size = LittleLong(pframe->width) * LittleLong(pframe->height);
+                               pframe = (dspriteframe_t *) (size + sizeof(dspriteframe_t) + (int) pframe);
+                               realframes++;
+                       }
+                       pframetype = (dspriteframetype_t *) pframe;
+               }
+       }
+
+       mod->ofs_scenes = (int) animscenes - (int) psprite;
+
+       frames = Hunk_AllocName(sizeof(mspriteframe_t) * realframes, va("%s frames", loadname));
+
+       realframes = 0;
+       for (i = 0;i < numframes;i++)
+       {
+               for (j = 0;j < animscenes[i].framecount;j++)
+               {
+                       Mod_LoadSpriteFrame (framedata[realframes], frames + realframes, i, 1, &palette[0][0]);
                        realframes++;
                }
        }
                        realframes++;
                }
        }
@@ -286,7 +448,7 @@ void Mod_LoadSpriteModel (model_t *mod, void *buffer)
 // move the complete, relocatable sprite model to the cache
        end = Hunk_LowMark ();
        mod->cachesize = total = end - start;
 // move the complete, relocatable sprite model to the cache
        end = Hunk_LowMark ();
        mod->cachesize = total = end - start;
-       
+
        Cache_Alloc (&mod->cache, total, loadname);
        if (!mod->cache.data)
                return;
        Cache_Alloc (&mod->cache, total, loadname);
        if (!mod->cache.data)
                return;
@@ -294,3 +456,28 @@ void Mod_LoadSpriteModel (model_t *mod, void *buffer)
 
        Hunk_FreeToLowMark (start);
 }
 
        Hunk_FreeToLowMark (start);
 }
+
+
+/*
+=================
+Mod_LoadSpriteModel
+=================
+*/
+void Mod_LoadSpriteModel (model_t *mod, void *buffer)
+{
+       int version;
+       version = ((dsprite_t *)buffer)->version;
+       switch(version)
+       {
+       case SPRITEHL_VERSION:
+               Mod_LoadHLSprite (mod, buffer);
+               break;
+       case SPRITE_VERSION:
+       case SPRITE32_VERSION:
+               Mod_LoadQuakeSprite(mod, buffer);
+               break;
+       default:
+               Host_Error ("Mod_LoadSpriteModel: %s has wrong version number (%i should be 1 (quake) or 32 (sprite32) or 2 (halflife)", mod->name, version);
+               break;
+       }
+}
index fb7c7e7ce01cb52388b2b3735fdd84ac79e4a73f..15ac113fc0be662e22b76b65c4bb875591850d5e 100644 (file)
@@ -937,7 +937,7 @@ static qsocket_t *_Datagram_CheckNewConnections (void)
                // search for the next server cvar
                while (var)
                {
                // search for the next server cvar
                while (var)
                {
-                       if (var->server)
+                       if (var->flags & CVAR_NOTIFY)
                                break;
                        var = var->next;
                }
                                break;
                        var = var->next;
                }
index 4df0adb606c963f458676aa0e554381cfc8d6734..b457a672da4c659c0f7e792981083f3c9e16468f 100644 (file)
@@ -8,7 +8,7 @@ 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
 
 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.  
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 See the GNU General Public License for more details.
 
 
 See the GNU General Public License for more details.
 
@@ -56,8 +56,8 @@ int messagesReceived = 0;
 int unreliableMessagesSent = 0;
 int unreliableMessagesReceived = 0;
 
 int unreliableMessagesSent = 0;
 int unreliableMessagesReceived = 0;
 
-cvar_t net_messagetimeout = {"net_messagetimeout","300"};
-cvar_t hostname = {"hostname", "UNNAMED"};
+cvar_t net_messagetimeout = {0, "net_messagetimeout","300"};
+cvar_t hostname = {CVAR_SAVE, "hostname", "UNNAMED"};
 
 qboolean       configRestored = false;
 
 
 qboolean       configRestored = false;
 
index 47428dfc742b5a643576a3cd7898ec1a3f2ead72..5eb176f13cef59a0442155b584d47c16711852a0 100644 (file)
--- a/palette.c
+++ b/palette.c
@@ -8,9 +8,9 @@ byte texgamma[256];
 
 static float texture_gamma = 1.0;
 
 
 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};
+cvar_t vid_gamma = {CVAR_SAVE, "vid_gamma", "1"};
+cvar_t vid_brightness = {CVAR_SAVE, "vid_brightness", "1"};
+cvar_t vid_contrast = {CVAR_SAVE, "vid_contrast", "1"};
 
 void Palette_Setup8to24(void)
 {
 
 void Palette_Setup8to24(void)
 {
diff --git a/portals.c b/portals.c
new file mode 100644 (file)
index 0000000..85a8c7d
--- /dev/null
+++ b/portals.c
@@ -0,0 +1,338 @@
+
+#include "quakedef.h"
+
+#define MAXRECURSIVEPORTALPLANES 1024
+#define MAXRECURSIVEPORTALS 256
+
+tinyplane_t portalplanes[MAXRECURSIVEPORTALPLANES];
+int portalplanestack[MAXRECURSIVEPORTALS];
+int portalplanecount;
+int ranoutofportalplanes;
+int ranoutofportals;
+
+int R_ClipPolygonToPlane(float *in, float *out, int inpoints, int maxoutpoints, tinyplane_t *p)
+{
+       int i, outpoints, prevside, side;
+       float *prevpoint, prevdist, dist, dot;
+
+       if (inpoints < 3)
+               return inpoints;
+       // begin with the last point, then enter the loop with the first point as current
+       prevpoint = in + 3 * (inpoints - 1);
+       prevdist = DotProduct(prevpoint, p->normal) - p->dist;
+       prevside = prevdist >= 0 ? SIDE_FRONT : SIDE_BACK;
+       i = 0;
+       outpoints = 0;
+       goto begin;
+       for (;i < inpoints;i++)
+       {
+               prevpoint = in;
+               prevdist = dist;
+               prevside = side;
+               in += 3;
+
+begin:
+               dist = DotProduct(in, p->normal) - p->dist;
+               side = dist >= 0 ? SIDE_FRONT : SIDE_BACK;
+
+               if (prevside == SIDE_FRONT)
+               {
+                       if (outpoints >= maxoutpoints)
+                               return -1;
+                       VectorCopy(prevpoint, out);
+                       out += 3;
+                       outpoints++;
+                       if (side == SIDE_FRONT)
+                               continue;
+               }
+               else if (side == SIDE_BACK)
+                       continue;
+
+               // generate a split point
+               if (outpoints >= maxoutpoints)
+                       return -1;
+               dot = prevdist / (prevdist - dist);
+               out[0] = prevpoint[0] + dot * (in[0] - prevpoint[0]);
+               out[1] = prevpoint[1] + dot * (in[1] - prevpoint[1]);
+               out[2] = prevpoint[2] + dot * (in[2] - prevpoint[2]);
+               out += 3;
+               outpoints++;
+       }
+
+       return outpoints;
+}
+
+float portaltemppoints[2][256][3];
+float portaltemppoints2[256][3];
+
+/*
+void R_TriangleToPlane(vec3_t point1, vec3_t point2, vec3_t point3, tinyplane_t *p)
+{
+       vec3_t v1, v2;
+       VectorSubtract(point1, point2, v1);
+       VectorSubtract(point3, point2, v2);
+       CrossProduct(v1, v2, p->normal);
+//     VectorNormalize(p->normal);
+       VectorNormalizeFast(p->normal);
+       p->dist = DotProduct(point1, p->normal);
+}
+*/
+
+int R_PortalThroughPortalPlanes(tinyplane_t *clipplanes, int clipnumplanes, float *targpoints, int targnumpoints, float *out, int maxpoints)
+{
+       int numpoints, i;
+       if (targnumpoints < 3)
+               return targnumpoints;
+       if (maxpoints < 3)
+               return -1;
+       numpoints = targnumpoints;
+       memcpy(&portaltemppoints[0][0][0], targpoints, numpoints * 3 * sizeof(float));
+       for (i = 0;i < clipnumplanes;i++)
+       {
+               numpoints = R_ClipPolygonToPlane(&portaltemppoints[0][0][0], &portaltemppoints[1][0][0], numpoints, 256, clipplanes + i);
+               if (numpoints < 3)
+                       return numpoints;
+               memcpy(&portaltemppoints[0][0][0], &portaltemppoints[1][0][0], numpoints * 3 * sizeof(float));
+       }
+       if (numpoints > maxpoints)
+               return -1;
+       memcpy(out, &portaltemppoints[1][0][0], numpoints * 3 * sizeof(float));
+       return numpoints;
+}
+
+static int portal_markid = 0;
+
+int Portal_RecursiveFlowSearch (mleaf_t *leaf, vec3_t eye, int firstclipplane, int numclipplanes)
+{
+       mportal_t *p;
+
+       if (leaf->portalmarkid == portal_markid)
+               return true;
+
+       // follow portals into other leafs
+       for (p = leaf->portals;p;p = p->next)
+       {
+               int newpoints, i, prev;
+               vec3_t center;
+               vec3_t v1, v2;
+               tinyplane_t *newplanes;
+               // only flow through portals facing away from the viewer
+               if (PlaneDiff(eye, (&p->plane)) < 0)
+               {
+                       newpoints = R_PortalThroughPortalPlanes(&portalplanes[firstclipplane], numclipplanes, (float *) p->points, p->numpoints, &portaltemppoints2[0][0], 256);
+                       if (newpoints < 3)
+                               continue;
+                       else if (firstclipplane + numclipplanes + newpoints > MAXRECURSIVEPORTALPLANES)
+                               ranoutofportalplanes = true;
+                       else
+                       {
+                               // find the center by averaging
+                               VectorClear(center);
+                               for (i = 0;i < newpoints;i++)
+                                       VectorAdd(center, portaltemppoints2[i], center);
+                               // ixtable is a 1.0f / N table
+                               VectorScale(center, ixtable[newpoints], center);
+                               // calculate the planes, and make sure the polygon can see it's own center
+                               newplanes = &portalplanes[firstclipplane + numclipplanes];
+                               for (prev = newpoints - 1, i = 0;i < newpoints;prev = i, i++)
+                               {
+//                                     R_TriangleToPlane(eye, portaltemppoints2[i], portaltemppoints2[prev], newplanes + i);
+                                       VectorSubtract(eye, portaltemppoints2[i], v1);
+                                       VectorSubtract(portaltemppoints2[prev], portaltemppoints2[i], v2);
+                                       CrossProduct(v1, v2, newplanes[i].normal);
+                                       VectorNormalizeFast(newplanes[i].normal);
+                                       newplanes[i].dist = DotProduct(eye, newplanes[i].normal);
+                                       if (DotProduct(newplanes[i].normal, center) <= newplanes[i].dist)
+                                       {
+                                               // polygon can't see it's own center, discard and use parent portal
+                                               break;
+                                       }
+                               }
+                               if (i == newpoints)
+                               {
+                                       if (Portal_RecursiveFlowSearch(p->past, eye, firstclipplane + numclipplanes, newpoints))
+                                               return true;
+                       }
+                               else
+                               {
+                                       if (Portal_RecursiveFlowSearch(p->past, eye, firstclipplane, numclipplanes))
+                                               return true;
+                       }
+                       }
+               }
+       }
+
+       return false;
+}
+
+//float viewportalpoints[16*3];
+
+void Portal_PolygonRecursiveMarkLeafs(mnode_t *node, float *polypoints, int numpoints)
+{
+       int i, front;
+       float *p;
+
+loc0:
+       if (node->contents < 0)
+       {
+               ((mleaf_t *)node)->portalmarkid = portal_markid;
+               return;
+       }
+
+       front = 0;
+       for (i = 0, p = polypoints;i < numpoints;i++, p += 3)
+       {
+               if (DotProduct(p, node->plane->normal) > node->plane->dist)
+                       front++;
+       }
+       if (front > 0)
+       {
+               if (front == numpoints)
+               {
+                       node = node->children[0];
+                       goto loc0;
+               }
+               else
+                       Portal_PolygonRecursiveMarkLeafs(node->children[0], polypoints, numpoints);
+       }
+       node = node->children[1];
+       goto loc0;
+}
+
+int Portal_CheckPolygon(model_t *model, vec3_t eye, float *polypoints, int numpoints)
+{
+       int i, prev, returnvalue;
+       mleaf_t *eyeleaf;
+       vec3_t center, v1, v2;
+
+       portal_markid++;
+
+       Portal_PolygonRecursiveMarkLeafs(model->nodes, polypoints, numpoints);
+
+       eyeleaf = Mod_PointInLeaf(eye, model);
+
+       // find the center by averaging
+       VectorClear(center);
+       for (i = 0;i < numpoints;i++)
+               VectorAdd(center, (&polypoints[i * 3]), center);
+       // ixtable is a 1.0f / N table
+       VectorScale(center, ixtable[numpoints], center);
+
+       // calculate the planes, and make sure the polygon can see it's own center
+       for (prev = numpoints - 1, i = 0;i < numpoints;prev = i, i++)
+       {
+//             R_TriangleToPlane(eye, portaltemppoints2[i], portaltemppoints2[prev], newplanes + i);
+               VectorSubtract(eye, (&polypoints[i * 3]), v1);
+               VectorSubtract((&polypoints[prev * 3]), (&polypoints[i * 3]), v2);
+               CrossProduct(v1, v2, portalplanes[i].normal);
+               VectorNormalizeFast(portalplanes[i].normal);
+               portalplanes[i].dist = DotProduct(eye, portalplanes[i].normal);
+               if (DotProduct(portalplanes[i].normal, center) <= portalplanes[i].dist)
+               {
+                       // polygon can't see it's own center, discard
+                       return false;
+               }
+       }
+
+       portalplanecount = 0;
+       ranoutofportalplanes = false;
+       ranoutofportals = false;
+
+       returnvalue = Portal_RecursiveFlowSearch(eyeleaf, eye, 0, numpoints);
+
+       if (ranoutofportalplanes)
+               Con_Printf("Portal_RecursiveFlowSearch: ran out of %d plane stack when recursing through portals\n", MAXRECURSIVEPORTALPLANES);
+       if (ranoutofportals)
+               Con_Printf("Portal_RecursiveFlowSearch: ran out of %d portal stack when recursing through portals\n", MAXRECURSIVEPORTALS);
+
+       return returnvalue;
+}
+
+float boxpoints[4*3];
+
+#define Portal_MinsBoxPolygon(axis, axisvalue, x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4) \
+{\
+       if (eye[(axis)] < ((axisvalue) - 0.5f))\
+       {\
+               boxpoints[ 0] = x1;boxpoints[ 1] = y1;boxpoints[ 2] = z1;\
+               boxpoints[ 3] = x2;boxpoints[ 4] = y2;boxpoints[ 5] = z2;\
+               boxpoints[ 6] = x3;boxpoints[ 7] = y3;boxpoints[ 8] = z3;\
+               boxpoints[ 9] = x4;boxpoints[10] = y4;boxpoints[11] = z4;\
+               if (Portal_CheckPolygon(model, eye, boxpoints, 4))\
+                       return true;\
+       }\
+}
+
+#define Portal_MaxsBoxPolygon(axis, axisvalue, x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4) \
+{\
+       if (eye[(axis)] > ((axisvalue) + 0.5f))\
+       {\
+               boxpoints[ 0] = x1;boxpoints[ 1] = y1;boxpoints[ 2] = z1;\
+               boxpoints[ 3] = x2;boxpoints[ 4] = y2;boxpoints[ 5] = z2;\
+               boxpoints[ 6] = x3;boxpoints[ 7] = y3;boxpoints[ 8] = z3;\
+               boxpoints[ 9] = x4;boxpoints[10] = y4;boxpoints[11] = z4;\
+               if (Portal_CheckPolygon(model, eye, boxpoints, 4))\
+                       return true;\
+       }\
+}
+
+int Portal_CheckBox(model_t *model, vec3_t eye, vec3_t a, vec3_t b)
+{
+       if (eye[0] >= (a[0] - 1.0f) && eye[0] < (b[0] + 1.0f)
+        && eye[1] >= (a[1] - 1.0f) && eye[1] < (b[1] + 1.0f)
+        && eye[2] >= (a[2] - 1.0f) && eye[2] < (b[2] + 1.0f))
+       {
+               return true;
+       }
+
+       Portal_MinsBoxPolygon
+       (
+               0, a[0],
+               a[0], a[1], a[2],
+               a[0], b[1], a[2],
+               a[0], b[1], b[2],
+               a[0], a[1], b[2]
+       );
+       Portal_MaxsBoxPolygon
+       (
+               0, b[0],
+               b[0], b[1], a[2],
+               b[0], a[1], a[2],
+               b[0], a[1], b[2],
+               b[0], b[1], b[2]
+       );
+       Portal_MinsBoxPolygon
+       (
+               1, a[1],
+               b[0], a[1], a[2],
+               a[0], a[1], a[2],
+               a[0], a[1], b[2],
+               b[0], a[1], b[2]
+       );
+       Portal_MaxsBoxPolygon
+       (
+               1, b[1],
+               a[0], b[1], a[2],
+               b[0], b[1], a[2],
+               b[0], b[1], b[2],
+               a[0], b[1], b[2]
+       );
+       Portal_MinsBoxPolygon
+       (
+               2, a[2],
+               a[0], a[1], a[2],
+               b[0], a[1], a[2],
+               b[0], b[1], a[2],
+               a[0], b[1], a[2]
+       );
+       Portal_MaxsBoxPolygon
+       (
+               2, b[2],
+               b[0], a[1], b[2],
+               a[0], a[1], b[2],
+               a[0], b[1], b[2],
+               b[0], b[1], b[2]
+       );
+
+       return false;
+}
diff --git a/portals.h b/portals.h
new file mode 100644 (file)
index 0000000..80f88a1
--- /dev/null
+++ b/portals.h
@@ -0,0 +1,3 @@
+
+int Portal_CheckPolygon(model_t *model, vec3_t eye, float *polypoints, int numpoints);
+int Portal_CheckBox(model_t *model, vec3_t eye, vec3_t a, vec3_t b);
index e274a7deb722fcad68e03b62576bf5b393484016..f1dde6d4a7171aeb0044136b8574ea0fda6dcf5b 100644 (file)
--- a/pr_cmds.c
+++ b/pr_cmds.c
@@ -8,7 +8,7 @@ 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
 
 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.  
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 See the GNU General Public License for more details.
 
 
 See the GNU General Public License for more details.
 
@@ -20,6 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include "quakedef.h"
 
 
 #include "quakedef.h"
 
+cvar_t sv_aim = {CVAR_SAVE, "sv_aim", "2"}; //"0.93"}; // LordHavoc: disabled autoaim by default
+
 #define        RETURN_EDICT(e) (((int *)pr_globals)[OFS_RETURN] = EDICT_TO_PROG(e))
 
 
 #define        RETURN_EDICT(e) (((int *)pr_globals)[OFS_RETURN] = EDICT_TO_PROG(e))
 
 
@@ -36,7 +38,7 @@ char *PF_VarString (int       first)
 {
        int             i;
        static char out[256];
 {
        int             i;
        static char out[256];
-       
+
        out[0] = 0;
        for (i=first ; i<pr_argc ; i++)
        {
        out[0] = 0;
        for (i=first ; i<pr_argc ; i++)
        {
@@ -498,7 +500,7 @@ void PF_vlen (void)
 {
        float   *value1;
        float   new;
 {
        float   *value1;
        float   new;
-       
+
        value1 = G_VECTOR(OFS_PARM0);
 
        new = value1[0] * value1[0] + value1[1] * value1[1] + value1[2]*value1[2];
        value1 = G_VECTOR(OFS_PARM0);
 
        new = value1[0] * value1[0] + value1[1] * value1[1] + value1[2]*value1[2];
@@ -1296,7 +1298,7 @@ void PF_precache_sound (void)
        
        if (sv.state != ss_loading)
                PR_RunError ("PF_Precache_*: Precache can only be done in spawn functions");
        
        if (sv.state != ss_loading)
                PR_RunError ("PF_Precache_*: Precache can only be done in spawn functions");
-               
+
        s = G_STRING(OFS_PARM0);
        G_INT(OFS_RETURN) = G_INT(OFS_PARM0);
        PR_CheckEmptyString (s);
        s = G_STRING(OFS_PARM0);
        G_INT(OFS_RETURN) = G_INT(OFS_PARM0);
        PR_CheckEmptyString (s);
@@ -1548,7 +1550,6 @@ Pick a vector for the player to shoot along
 vector aim(entity, missilespeed)
 =============
 */
 vector aim(entity, missilespeed)
 =============
 */
-cvar_t sv_aim = {"sv_aim", "0.93"};
 void PF_aim (void)
 {
        edict_t *ent, *check, *bestent;
 void PF_aim (void)
 {
        edict_t *ent, *check, *bestent;
index 49253e181b967eac72bc81474c71db12bbb57b78..23872816059a4257ac9d5cb2e8a60ff3b1d0a291 100644 (file)
@@ -39,32 +39,32 @@ int         type_size[8] = {1,sizeof(string_t)/4,1,3,1,1,sizeof(func_t)/4,sizeof(void *
 ddef_t *ED_FieldAtOfs (int ofs);
 qboolean       ED_ParseEpair (void *base, ddef_t *key, char *s);
 
 ddef_t *ED_FieldAtOfs (int ofs);
 qboolean       ED_ParseEpair (void *base, ddef_t *key, char *s);
 
-cvar_t pr_checkextension = {"pr_checkextension", "1"};
-cvar_t nomonsters = {"nomonsters", "0"};
-cvar_t gamecfg = {"gamecfg", "0"};
-cvar_t scratch1 = {"scratch1", "0"};
-cvar_t scratch2 = {"scratch2", "0"};
-cvar_t scratch3 = {"scratch3", "0"};
-cvar_t scratch4 = {"scratch4", "0"};
-cvar_t savedgamecfg = {"savedgamecfg", "0", true};
-cvar_t saved1 = {"saved1", "0", true};
-cvar_t saved2 = {"saved2", "0", true};
-cvar_t saved3 = {"saved3", "0", true};
-cvar_t saved4 = {"saved4", "0", true};
-cvar_t decors = {"decors", "0"};
-cvar_t nehx00 = {"nehx00", "0"};cvar_t nehx01 = {"nehx01", "0"};
-cvar_t nehx02 = {"nehx02", "0"};cvar_t nehx03 = {"nehx03", "0"};
-cvar_t nehx04 = {"nehx04", "0"};cvar_t nehx05 = {"nehx05", "0"};
-cvar_t nehx06 = {"nehx06", "0"};cvar_t nehx07 = {"nehx07", "0"};
-cvar_t nehx08 = {"nehx08", "0"};cvar_t nehx09 = {"nehx09", "0"};
-cvar_t nehx10 = {"nehx10", "0"};cvar_t nehx11 = {"nehx11", "0"};
-cvar_t nehx12 = {"nehx12", "0"};cvar_t nehx13 = {"nehx13", "0"};
-cvar_t nehx14 = {"nehx14", "0"};cvar_t nehx15 = {"nehx15", "0"};
-cvar_t nehx16 = {"nehx16", "0"};cvar_t nehx17 = {"nehx17", "0"};
-cvar_t nehx18 = {"nehx18", "0"};cvar_t nehx19 = {"nehx19", "0"};
-cvar_t cutscene = {"cutscene", "1"};
+cvar_t pr_checkextension = {0, "pr_checkextension", "1"};
+cvar_t nomonsters = {0, "nomonsters", "0"};
+cvar_t gamecfg = {0, "gamecfg", "0"};
+cvar_t scratch1 = {0, "scratch1", "0"};
+cvar_t scratch2 = {0,"scratch2", "0"};
+cvar_t scratch3 = {0, "scratch3", "0"};
+cvar_t scratch4 = {0, "scratch4", "0"};
+cvar_t savedgamecfg = {CVAR_SAVE, "savedgamecfg", "0"};
+cvar_t saved1 = {CVAR_SAVE, "saved1", "0"};
+cvar_t saved2 = {CVAR_SAVE, "saved2", "0"};
+cvar_t saved3 = {CVAR_SAVE, "saved3", "0"};
+cvar_t saved4 = {CVAR_SAVE, "saved4", "0"};
+cvar_t decors = {0, "decors", "0"};
+cvar_t nehx00 = {0, "nehx00", "0"};cvar_t      nehx01 = {0, "nehx01", "0"};
+cvar_t nehx02 = {0, "nehx02", "0"};cvar_t      nehx03 = {0, "nehx03", "0"};
+cvar_t nehx04 = {0, "nehx04", "0"};cvar_t      nehx05 = {0, "nehx05", "0"};
+cvar_t nehx06 = {0, "nehx06", "0"};cvar_t      nehx07 = {0, "nehx07", "0"};
+cvar_t nehx08 = {0, "nehx08", "0"};cvar_t      nehx09 = {0, "nehx09", "0"};
+cvar_t nehx10 = {0, "nehx10", "0"};cvar_t      nehx11 = {0, "nehx11", "0"};
+cvar_t nehx12 = {0, "nehx12", "0"};cvar_t      nehx13 = {0, "nehx13", "0"};
+cvar_t nehx14 = {0, "nehx14", "0"};cvar_t      nehx15 = {0, "nehx15", "0"};
+cvar_t nehx16 = {0, "nehx16", "0"};cvar_t      nehx17 = {0, "nehx17", "0"};
+cvar_t nehx18 = {0, "nehx18", "0"};cvar_t      nehx19 = {0, "nehx19", "0"};
+cvar_t cutscene = {0, "cutscene", "1"};
 // LordHavoc: optional runtime bounds checking (speed drain, but worth it for security, on by default - breaks most QCCX features (used by CRMod and others))
 // LordHavoc: optional runtime bounds checking (speed drain, but worth it for security, on by default - breaks most QCCX features (used by CRMod and others))
-cvar_t pr_boundscheck = {"pr_boundscheck", "1"};
+cvar_t pr_boundscheck = {0, "pr_boundscheck", "1"};
 
 #define        MAX_FIELD_LEN   64
 #define GEFV_CACHESIZE 2
 
 #define        MAX_FIELD_LEN   64
 #define GEFV_CACHESIZE 2
index 73ad3018c04bddf7d323ec2dd338300565ef73db..8c806df7d63b6bc0e7bf0472fa7d14e12b2c9121 100644 (file)
@@ -8,7 +8,7 @@ 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
 
 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.  
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 See the GNU General Public License for more details.
 
 
 See the GNU General Public License for more details.
 
@@ -19,9 +19,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
 // quakedef.h -- primary header for client
 
 */
 // quakedef.h -- primary header for client
 
-#define        QUAKE_GAME                      // as opposed to utilities
+#define QUAKE_GAME // as opposed to utilities
+
+#define VERSION 1.50
 
 
-#define        VERSION                         1.50
 extern int buildnumber;
 
 #ifndef FALSE
 extern int buildnumber;
 
 #ifndef FALSE
@@ -215,6 +216,10 @@ extern int buildnumber;
 
 #include "glquake.h"
 
 
 #include "glquake.h"
 
+#include "ui.h"
+
+#include "portals.h"
+
 //=============================================================================
 
 // the host system specifies the base of the directory tree, the
 //=============================================================================
 
 // the host system specifies the base of the directory tree, the
index 373e1fa3dc624e5c65c50bc9a95068d756089354..1f59dc320185e3cd06832d8f70ba13f700e626e8 100644 (file)
--- a/r_clip.c
+++ b/r_clip.c
@@ -40,10 +40,10 @@ clipsurf_t surfstack;
 clipedge_t edgehead, edgetail;
 clipedge_t maxedge = {2000000000.0f};
 
 clipedge_t edgehead, edgetail;
 clipedge_t maxedge = {2000000000.0f};
 
-cvar_t r_clipwidth = {"r_clipwidth", "800"};
-cvar_t r_clipheight = {"r_clipheight", "600"};
-cvar_t r_clipedges = {"r_clipedges", "32768", true};
-cvar_t r_clipsurfaces = {"r_clipsurfaces", "8192", true};
+cvar_t r_clipwidth = {0, "r_clipwidth", "800"};
+cvar_t r_clipheight = {0, "r_clipheight", "600"};
+cvar_t r_clipedges = {CVAR_SAVE, "r_clipedges", "32768"};
+cvar_t r_clipsurfaces = {CVAR_SAVE, "r_clipsurfaces", "8192"};
 
 int clipwidth = 0, clipheight = 0;
 int maxclipsurfs = 0, maxclipedges = 0;
 
 int clipwidth = 0, clipheight = 0;
 int maxclipsurfs = 0, maxclipedges = 0;
index 2884c24cf2b9faf75b0dbae32ab7d01a4b1983f3..de0c1a08b56a70acd9e6ad55499741fec721ca24 100644 (file)
@@ -1,9 +1,9 @@
 #include "quakedef.h"
 
 #include "quakedef.h"
 
-cvar_t crosshair_brightness = {"crosshair_brightness", "1.0", true};
-cvar_t crosshair_alpha = {"crosshair_alpha", "1.0", true};
-cvar_t crosshair_flashspeed = {"crosshair_flashspeed", "2", true};
-cvar_t crosshair_flashrange = {"crosshair_flashrange", "0.1", true};
+cvar_t crosshair_brightness = {CVAR_SAVE, "crosshair_brightness", "1.0"};
+cvar_t crosshair_alpha = {CVAR_SAVE, "crosshair_alpha", "1.0"};
+cvar_t crosshair_flashspeed = {CVAR_SAVE, "crosshair_flashspeed", "2"};
+cvar_t crosshair_flashrange = {CVAR_SAVE, "crosshair_flashrange", "0.1"};
 
 #define NUMCROSSHAIRS 5
 
 
 #define NUMCROSSHAIRS 5
 
index f920b2ab68a824e37dacf5419dbf2dd41af9a7b0..8f8176aac2a10c4f04127c8e1afa8b0d06ad5de1 100644 (file)
@@ -8,7 +8,7 @@ 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
 
 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.  
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 See the GNU General Public License for more details.
 
 
 See the GNU General Public License for more details.
 
@@ -38,8 +38,8 @@ decal_t;
 decal_t *decals;
 int currentdecal; // wraps around in decal array, replacing old ones when a new one is needed
 
 decal_t *decals;
 int currentdecal; // wraps around in decal array, replacing old ones when a new one is needed
 
-cvar_t r_drawdecals = {"r_drawdecals", "1"};
-cvar_t r_decals_lighting = {"r_decals_lighting", "1"};
+cvar_t r_drawdecals = {0, "r_drawdecals", "1"};
+cvar_t r_decals_lighting = {0, "r_decals_lighting", "1"};
 
 void r_decals_start(void)
 {
 
 void r_decals_start(void)
 {
index ae40cb45b6e9ec27830d3c5110c8399fbbae53c3..db67b390a9ae634dae1b98242ce3c987759a0496 100644 (file)
@@ -52,8 +52,8 @@ explosion_t explosion[128];
 rtexture_t     *explosiontexture;
 rtexture_t     *explosiontexturefog;
 
 rtexture_t     *explosiontexture;
 rtexture_t     *explosiontexturefog;
 
-cvar_t r_explosionclip = {"r_explosionclip", "0", true};
-cvar_t r_drawexplosions = {"r_drawexplosions", "1"};
+cvar_t r_explosionclip = {CVAR_SAVE, "r_explosionclip", "1"};
+cvar_t r_drawexplosions = {0, "r_drawexplosions", "1"};
 
 int R_ExplosionVert(int column, int row)
 {
 
 int R_ExplosionVert(int column, int row)
 {
index b5757cadf5b3871f2d0bc4692b9ab262057e49b7..f8f797c4b4c71ef95e9639ce92869f6c498d6e35 100644 (file)
--- a/r_light.c
+++ b/r_light.c
@@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include "quakedef.h"
 
 
 #include "quakedef.h"
 
-cvar_t r_lightmodels = {"r_lightmodels", "1"};
+cvar_t r_lightmodels = {0, "r_lightmodels", "1"};
 
 void r_light_start(void)
 {
 
 void r_light_start(void)
 {
index 3256c3b5a5c4e1c2d400a9395bbd29bc6db5e095..790a421859de5cd5c10306d391565b08626a50c8 100644 (file)
--- a/r_part.c
+++ b/r_part.c
@@ -74,14 +74,14 @@ vec3_t                      r_pright, r_pup, r_ppn;
 int                    numparticles;
 particle_t     **freeparticles; // list used only in compacting particles array
 
 int                    numparticles;
 particle_t     **freeparticles; // list used only in compacting particles array
 
-cvar_t r_particles = {"r_particles", "1", true};
-cvar_t r_drawparticles = {"r_drawparticles", "1"};
-cvar_t r_particles_lighting = {"r_particles_lighting", "1", true};
-cvar_t r_particles_bloodshowers = {"r_particles_bloodshowers", "1", true};
-cvar_t r_particles_blood = {"r_particles_blood", "1", true};
-cvar_t r_particles_smoke = {"r_particles_smoke", "1", true};
-cvar_t r_particles_sparks = {"r_particles_sparks", "1", true};
-cvar_t r_particles_bubbles = {"r_particles_bubbles", "1", true};
+cvar_t r_particles = {CVAR_SAVE, "r_particles", "1"};
+cvar_t r_drawparticles = {0, "r_drawparticles", "1"};
+cvar_t r_particles_lighting = {CVAR_SAVE, "r_particles_lighting", "1"};
+cvar_t r_particles_bloodshowers = {CVAR_SAVE, "r_particles_bloodshowers", "1"};
+cvar_t r_particles_blood = {CVAR_SAVE, "r_particles_blood", "1"};
+cvar_t r_particles_smoke = {CVAR_SAVE, "r_particles_smoke", "1"};
+cvar_t r_particles_sparks = {CVAR_SAVE, "r_particles_sparks", "1"};
+cvar_t r_particles_bubbles = {CVAR_SAVE, "r_particles_bubbles", "1"};
 
 byte shadebubble(float dx, float dy, vec3_t light)
 {
 
 byte shadebubble(float dx, float dy, vec3_t light)
 {
index 0a44499e9b4633d4984c8d10819f30d702be6970..e7f561179493f4903c9ab1d5bd13e1808995af2d 100644 (file)
@@ -72,7 +72,7 @@ void GL_DrawSpriteImage (mspriteframe_t *frame, vec3_t origin, vec3_t up, vec3_t
 {
        byte alphaub;
        alphaub = bound(0, alpha, 255);
 {
        byte alphaub;
        alphaub = bound(0, alpha, 255);
-       transpolybegin(R_GetTexture(frame->texture), 0, R_GetTexture(frame->fogtexture), currententity->render.effects & EF_ADDITIVE ? TPOLYTYPE_ADD : TPOLYTYPE_ALPHA);
+       transpolybegin(R_GetTexture(frame->texture), 0, R_GetTexture(frame->fogtexture), ((currententity->render.effects & EF_ADDITIVE) || (currententity->render.model->flags & EF_ADDITIVE)) ? TPOLYTYPE_ADD : TPOLYTYPE_ALPHA);
        transpolyvertub(origin[0] + frame->down * up[0] + frame->left  * right[0], origin[1] + frame->down * up[1] + frame->left  * right[1], origin[2] + frame->down * up[2] + frame->left  * right[2], 0, 1, red, green, blue, alphaub);
        transpolyvertub(origin[0] + frame->up   * up[0] + frame->left  * right[0], origin[1] + frame->up   * up[1] + frame->left  * right[1], origin[2] + frame->up   * up[2] + frame->left  * right[2], 0, 0, red, green, blue, alphaub);
        transpolyvertub(origin[0] + frame->up   * up[0] + frame->right * right[0], origin[1] + frame->up   * up[1] + frame->right * right[1], origin[2] + frame->up   * up[2] + frame->right * right[2], 1, 0, red, green, blue, alphaub);
        transpolyvertub(origin[0] + frame->down * up[0] + frame->left  * right[0], origin[1] + frame->down * up[1] + frame->left  * right[1], origin[2] + frame->down * up[2] + frame->left  * right[2], 0, 1, red, green, blue, alphaub);
        transpolyvertub(origin[0] + frame->up   * up[0] + frame->left  * right[0], origin[1] + frame->up   * up[1] + frame->left  * right[1], origin[2] + frame->up   * up[2] + frame->left  * right[2], 0, 0, red, green, blue, alphaub);
        transpolyvertub(origin[0] + frame->up   * up[0] + frame->right * right[0], origin[1] + frame->up   * up[1] + frame->right * right[1], origin[2] + frame->up   * up[2] + frame->right * right[2], 1, 0, red, green, blue, alphaub);
index d8001f4f39e6cddfc44f3760a9f1f54f82a7c874..862287355bcf30a71292bb2ee99164277b333f53 100644 (file)
--- a/snd_dma.c
+++ b/snd_dma.c
@@ -66,19 +66,20 @@ sfx_t               *ambient_sfx[NUM_AMBIENTS];
 
 int sound_started=0;
 
 
 int sound_started=0;
 
-cvar_t bgmvolume = {"bgmvolume", "1", true};
-cvar_t volume = {"volume", "0.7", true};
-
-cvar_t nosound = {"nosound", "0"};
-cvar_t precache = {"precache", "1"};
-//cvar_t loadas8bit = {"loadas8bit", "0"};
-cvar_t bgmbuffer = {"bgmbuffer", "4096"};
-cvar_t ambient_level = {"ambient_level", "0.3"};
-cvar_t ambient_fade = {"ambient_fade", "100"};
-cvar_t snd_noextraupdate = {"snd_noextraupdate", "0"};
-cvar_t snd_show = {"snd_show", "0"};
-cvar_t _snd_mixahead = {"_snd_mixahead", "0.1", true};
-cvar_t snd_swapstereo = {"snd_swapstereo", "0", true};
+// FIXME: make bgmvolume/volume always be registered for sake of config saving, and add check for whether sound is enabled to menu
+cvar_t bgmvolume = {CVAR_SAVE, "bgmvolume", "1"};
+cvar_t volume = {CVAR_SAVE, "volume", "0.7"};
+
+cvar_t nosound = {0, "nosound", "0"};
+cvar_t precache = {0, "precache", "1"};
+//cvar_t loadas8bit = {0, "loadas8bit", "0"};
+cvar_t bgmbuffer = {0, "bgmbuffer", "4096"};
+cvar_t ambient_level = {0, "ambient_level", "0.3"};
+cvar_t ambient_fade = {0, "ambient_fade", "100"};
+cvar_t snd_noextraupdate = {0, "snd_noextraupdate", "0"};
+cvar_t snd_show = {0, "snd_show", "0"};
+cvar_t _snd_mixahead = {CVAR_SAVE, "_snd_mixahead", "0.1"};
+cvar_t snd_swapstereo = {CVAR_SAVE, "snd_swapstereo", "0"};
 
 
 // ====================================================================
 
 
 // ====================================================================
index 007a8bb238e8df93a5c536e80c200f5cbc8e9fb2..1bde4d72764812699578e0101693c53ff5f37851 100644 (file)
@@ -43,11 +43,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 //-------------------------------------------------------
 
 #define SPRITE_VERSION 1
 //-------------------------------------------------------
 
 #define SPRITE_VERSION 1
-#define HALFLIFESPRITE_VERSION 2
+#define SPRITEHL_VERSION       2
 #define SPRITE32_VERSION       32
 
 #define SPRITE32_VERSION       32
 
-// TODO: shorten these?
-typedef struct {
+typedef struct
+{
        int                     ident;
        int                     version;
        int                     type;
        int                     ident;
        int                     version;
        int                     type;
@@ -59,12 +59,32 @@ typedef struct {
        synctype_t      synctype;
 } dsprite_t;
 
        synctype_t      synctype;
 } dsprite_t;
 
+typedef struct
+{
+       int                     ident;
+       int                     version;
+       int                     type;
+       int                     rendermode;
+       float           boundingradius;
+       int                     width;
+       int                     height;
+       int                     numframes;
+       float           beamlength;
+       synctype_t      synctype;
+} dspritehl_t;
+
 #define SPR_VP_PARALLEL_UPRIGHT                0
 #define SPR_FACING_UPRIGHT                     1
 #define SPR_VP_PARALLEL                                2
 #define SPR_ORIENTED                           3
 #define SPR_VP_PARALLEL_ORIENTED       4
 
 #define SPR_VP_PARALLEL_UPRIGHT                0
 #define SPR_FACING_UPRIGHT                     1
 #define SPR_VP_PARALLEL                                2
 #define SPR_ORIENTED                           3
 #define SPR_VP_PARALLEL_ORIENTED       4
 
+#define SPRHL_NORMAL   0
+#define SPRHL_ADDITIVE 1
+// no idea how to handle these two rendering modes
+#define SPRHL_INDEXALPHA       2
+#define SPRHL_ALPHATEST        3
+
 typedef struct {
        int                     origin[2];
        int                     width;
 typedef struct {
        int                     origin[2];
        int                     width;
index 783e65363d7eb436fd06b2f1a6518c4531b3fb86..2c82c63cedb27727bc439e1e590eeb59fdee7764 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -8,7 +8,7 @@ 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
 
 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.  
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 See the GNU General Public License for more details.
 
 
 See the GNU General Public License for more details.
 
@@ -21,6 +21,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include "quakedef.h"
 
 
 #include "quakedef.h"
 
+cvar_t sv_vischeckentities = {0, "sv_vischeckentities", "1"};
+cvar_t sv_reportvischeckentities = {0, "sv_reportvischeckentities", "0"};
+int sv_vischeckentitycullcount = 0;
+
 server_t               sv;
 server_static_t        svs;
 
 server_t               sv;
 server_static_t        svs;
 
@@ -49,6 +53,8 @@ void SV_Init (void)
        Cvar_RegisterVariable (&sv_nostep);
        Cvar_RegisterVariable (&sv_predict);
        Cvar_RegisterVariable (&sv_deltacompress);
        Cvar_RegisterVariable (&sv_nostep);
        Cvar_RegisterVariable (&sv_predict);
        Cvar_RegisterVariable (&sv_deltacompress);
+       Cvar_RegisterVariable (&sv_vischeckentities);
+       Cvar_RegisterVariable (&sv_reportvischeckentities);
 
        for (i = 0;i < MAX_MODELS;i++)
                sprintf (localmodels[i], "*%i", i);
 
        for (i = 0;i < MAX_MODELS;i++)
                sprintf (localmodels[i], "*%i", i);
@@ -62,7 +68,7 @@ EVENT MESSAGES
 =============================================================================
 */
 
 =============================================================================
 */
 
-/*  
+/*
 ==================
 SV_StartParticle
 
 ==================
 SV_StartParticle
 
@@ -74,7 +80,7 @@ void SV_StartParticle (vec3_t org, vec3_t dir, int color, int count)
        int             i, v;
 
        if (sv.datagram.cursize > MAX_DATAGRAM-16)
        int             i, v;
 
        if (sv.datagram.cursize > MAX_DATAGRAM-16)
-               return; 
+               return;
        MSG_WriteByte (&sv.datagram, svc_particle);
        MSG_WriteFloatCoord (&sv.datagram, org[0]);
        MSG_WriteFloatCoord (&sv.datagram, org[1]);
        MSG_WriteByte (&sv.datagram, svc_particle);
        MSG_WriteFloatCoord (&sv.datagram, org[0]);
        MSG_WriteFloatCoord (&sv.datagram, org[1]);
@@ -90,9 +96,9 @@ void SV_StartParticle (vec3_t org, vec3_t dir, int color, int count)
        }
        MSG_WriteByte (&sv.datagram, count);
        MSG_WriteByte (&sv.datagram, color);
        }
        MSG_WriteByte (&sv.datagram, count);
        MSG_WriteByte (&sv.datagram, color);
-}           
+}
 
 
-/*  
+/*
 ==================
 SV_StartEffect
 
 ==================
 SV_StartEffect
 
@@ -102,7 +108,7 @@ Make sure the event gets sent to all clients
 void SV_StartEffect (vec3_t org, int modelindex, int startframe, int framecount, int framerate)
 {
        if (sv.datagram.cursize > MAX_DATAGRAM-18)
 void SV_StartEffect (vec3_t org, int modelindex, int startframe, int framecount, int framerate)
 {
        if (sv.datagram.cursize > MAX_DATAGRAM-18)
-               return; 
+               return;
        if (modelindex >= 256 || startframe >= 256)
        {
                MSG_WriteByte (&sv.datagram, svc_effect2);
        if (modelindex >= 256 || startframe >= 256)
        {
                MSG_WriteByte (&sv.datagram, svc_effect2);
@@ -125,9 +131,9 @@ void SV_StartEffect (vec3_t org, int modelindex, int startframe, int framecount,
                MSG_WriteByte (&sv.datagram, framecount);
                MSG_WriteByte (&sv.datagram, framerate);
        }
                MSG_WriteByte (&sv.datagram, framecount);
                MSG_WriteByte (&sv.datagram, framerate);
        }
-}           
+}
 
 
-/*  
+/*
 ==================
 SV_StartSound
 
 ==================
 SV_StartSound
 
@@ -141,15 +147,15 @@ An attenuation of 0 will play full volume everywhere in the level.
 Larger attenuations will drop off.  (max 4 attenuation)
 
 ==================
 Larger attenuations will drop off.  (max 4 attenuation)
 
 ==================
-*/  
+*/
 void SV_StartSound (edict_t *entity, int channel, char *sample, int volume,
     float attenuation)
 void SV_StartSound (edict_t *entity, int channel, char *sample, int volume,
     float attenuation)
-{       
+{
     int         sound_num;
     int field_mask;
     int                        i;
        int                     ent;
     int         sound_num;
     int field_mask;
     int                        i;
        int                     ent;
-       
+
        if (volume < 0 || volume > 255)
                Host_Error ("SV_StartSound: volume = %i", volume);
 
        if (volume < 0 || volume > 255)
                Host_Error ("SV_StartSound: volume = %i", volume);
 
@@ -160,7 +166,7 @@ void SV_StartSound (edict_t *entity, int channel, char *sample, int volume,
                Host_Error ("SV_StartSound: channel = %i", channel);
 
        if (sv.datagram.cursize > MAX_DATAGRAM-16)
                Host_Error ("SV_StartSound: channel = %i", channel);
 
        if (sv.datagram.cursize > MAX_DATAGRAM-16)
-               return; 
+               return;
 
 // find precache number for sound
     for (sound_num=1 ; sound_num<MAX_SOUNDS
 
 // find precache number for sound
     for (sound_num=1 ; sound_num<MAX_SOUNDS
@@ -292,7 +298,7 @@ void SV_ConnectClient (int clientnum)
        
 // set up the client_t
        netconnection = client->netconnection;
        
 // set up the client_t
        netconnection = client->netconnection;
-       
+
        if (sv.loadgame)
                memcpy (spawn_parms, client->spawn_parms, sizeof(spawn_parms));
        memset (client, 0, sizeof(*client));
        if (sv.loadgame)
                memcpy (spawn_parms, client->spawn_parms, sizeof(spawn_parms));
        memset (client, 0, sizeof(*client));
@@ -342,7 +348,7 @@ void SV_CheckForNewClients (void)
 
        // 
        // init a new client structure
 
        // 
        // init a new client structure
-       //      
+       //
                for (i=0 ; i<svs.maxclients ; i++)
                        if (!svs.clients[i].active)
                                break;
                for (i=0 ; i<svs.maxclients ; i++)
                        if (!svs.clients[i].active)
                                break;
@@ -455,7 +461,7 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
 {
        int             e, i, clentnum, bits, alpha, glowcolor, glowsize, scale, colormod, effects;
        byte    *pvs;
 {
        int             e, i, clentnum, bits, alpha, glowcolor, glowsize, scale, colormod, effects;
        byte    *pvs;
-       vec3_t  org, origin, angles;
+       vec3_t  org, origin, angles, entmins, entmaxs;
        float   movelerp, moveilerp, nextfullupdate;
        edict_t *ent;
        eval_t  *val;
        float   movelerp, moveilerp, nextfullupdate;
        edict_t *ent;
        eval_t  *val;
@@ -508,12 +514,22 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
                                for (i = 0;i < ent->num_leafs;i++)
                                        if (pvs[ent->leafnums[i] >> 3] & (1 << (ent->leafnums[i]&7) ))
                                                break;
                                for (i = 0;i < ent->num_leafs;i++)
                                        if (pvs[ent->leafnums[i] >> 3] & (1 << (ent->leafnums[i]&7) ))
                                                break;
-                                       
+
                                if (i == ent->num_leafs)
                                {
                                        // not visible
                                        continue;
                                }
                                if (i == ent->num_leafs)
                                {
                                        // not visible
                                        continue;
                                }
+
+                               VectorAdd(ent->v.mins, ent->v.origin, entmins);
+                               VectorAdd(ent->v.maxs, ent->v.origin, entmaxs);
+                               entmins[0] -= 1.0f;entmins[1] -= 1.0f;entmins[2] -= 1.0f;
+                               entmaxs[0] += 1.0f;entmaxs[1] += 1.0f;entmaxs[2] += 1.0f;
+                               if (!Portal_CheckBox(sv.worldmodel, org, entmins, entmaxs))
+                               {
+                                       sv_vischeckentitycullcount++;
+                                       continue;
+                               }
                        }
                }
 
                        }
                }
 
@@ -615,7 +631,7 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
 
                if (ent->v.movetype == MOVETYPE_STEP)
                        bits |= U_STEP;
 
                if (ent->v.movetype == MOVETYPE_STEP)
                        bits |= U_STEP;
-               
+
                if (ent->v.movetype == MOVETYPE_STEP && ((int) ent->v.flags & (FL_ONGROUND | FL_FLY | FL_SWIM))) // monsters have smoothed walking/flying/swimming movement
                {
                        if (!ent->steplerptime || ent->steplerptime > sv.time) // when the level just started...
                if (ent->v.movetype == MOVETYPE_STEP && ((int) ent->v.flags & (FL_ONGROUND | FL_FLY | FL_SWIM))) // monsters have smoothed walking/flying/swimming movement
                {
                        if (!ent->steplerptime || ent->steplerptime > sv.time) // when the level just started...
@@ -757,6 +773,10 @@ 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);
        }
                if (bits & U_FRAME2)    MSG_WriteByte(msg, (int)ent->v.frame >> 8);
                if (bits & U_MODEL2)    MSG_WriteByte(msg, (int)ent->v.modelindex >> 8);
        }
+
+       if (sv_reportvischeckentities.value)
+               Con_Printf("sv_vischeck culled entities: %d\n", sv_vischeckentitycullcount);
+       sv_vischeckentitycullcount = 0;
 }
 
 /*
 }
 
 /*
@@ -769,7 +789,7 @@ void SV_CleanupEnts (void)
 {
        int             e;
        edict_t *ent;
 {
        int             e;
        edict_t *ent;
-       
+
        ent = NEXT_EDICT(sv.edicts);
        for (e=1 ; e<sv.num_edicts ; e++, ent = NEXT_EDICT(ent))
        {
        ent = NEXT_EDICT(sv.edicts);
        for (e=1 ; e<sv.num_edicts ; e++, ent = NEXT_EDICT(ent))
        {
@@ -804,7 +824,7 @@ void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg)
                MSG_WriteByte (msg, ent->v.dmg_take);
                for (i=0 ; i<3 ; i++)
                        MSG_WriteFloatCoord (msg, other->v.origin[i] + 0.5*(other->v.mins[i] + other->v.maxs[i]));
                MSG_WriteByte (msg, ent->v.dmg_take);
                for (i=0 ; i<3 ; i++)
                        MSG_WriteFloatCoord (msg, other->v.origin[i] + 0.5*(other->v.mins[i] + other->v.maxs[i]));
-       
+
                ent->v.dmg_take = 0;
                ent->v.dmg_save = 0;
        }
                ent->v.dmg_take = 0;
                ent->v.dmg_save = 0;
        }
@@ -824,10 +844,10 @@ void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg)
        }
 
        bits = 0;
        }
 
        bits = 0;
-       
+
        if (ent->v.view_ofs[2] != DEFAULT_VIEWHEIGHT)
                bits |= SU_VIEWHEIGHT;
        if (ent->v.view_ofs[2] != DEFAULT_VIEWHEIGHT)
                bits |= SU_VIEWHEIGHT;
-               
+
        if (ent->v.idealpitch)
                bits |= SU_IDEALPITCH;
 
        if (ent->v.idealpitch)
                bits |= SU_IDEALPITCH;
 
@@ -862,7 +882,7 @@ void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg)
                if (ent->v.velocity[i])
                        bits |= (SU_VELOCITY1<<i);
        }
                if (ent->v.velocity[i])
                        bits |= (SU_VELOCITY1<<i);
        }
-       
+
        if (ent->v.weaponframe)
                bits |= SU_WEAPONFRAME;
 
        if (ent->v.weaponframe)
                bits |= SU_WEAPONFRAME;
 
@@ -968,7 +988,7 @@ qboolean SV_SendClientDatagram (client_t *client)
                SV_DropClient (true);// if the message couldn't send, kick off
                return false;
        }
                SV_DropClient (true);// if the message couldn't send, kick off
                return false;
        }
-       
+
        return true;
 }
 
        return true;
 }
 
@@ -1340,7 +1360,7 @@ void SV_SpawnServer (char *server)
        sv.signon.maxsize = sizeof(sv.signon_buf);
        sv.signon.cursize = 0;
        sv.signon.data = sv.signon_buf;
        sv.signon.maxsize = sizeof(sv.signon_buf);
        sv.signon.cursize = 0;
        sv.signon.data = sv.signon_buf;
-       
+
 // leave slots at start for clients only
        sv.num_edicts = svs.maxclients+1;
        for (i=0 ; i<svs.maxclients ; i++)
 // leave slots at start for clients only
        sv.num_edicts = svs.maxclients+1;
        for (i=0 ; i<svs.maxclients ; i++)
@@ -1366,7 +1386,7 @@ void SV_SpawnServer (char *server)
                return;
        }
        sv.models[1] = sv.worldmodel;
                return;
        }
        sv.models[1] = sv.worldmodel;
-       
+
 //
 // clear world interaction links
 //
 //
 // clear world interaction links
 //
@@ -1411,7 +1431,7 @@ void SV_SpawnServer (char *server)
 
 // all setup is completed, any further precache statements are errors
        sv.state = ss_active;
 
 // all setup is completed, any further precache statements are errors
        sv.state = ss_active;
-       
+
 // run two frames to allow everything to settle
        sv.frametime = pr_global_struct->frametime = host_frametime = 0.1;
        SV_Physics ();
 // run two frames to allow everything to settle
        sv.frametime = pr_global_struct->frametime = host_frametime = 0.1;
        SV_Physics ();
@@ -1424,6 +1444,6 @@ void SV_SpawnServer (char *server)
        for (i=0,host_client = svs.clients ; i<svs.maxclients ; i++, host_client++)
                if (host_client->active)
                        SV_SendServerinfo (host_client);
        for (i=0,host_client = svs.clients ; i<svs.maxclients ; i++, host_client++)
                if (host_client->active)
                        SV_SendServerinfo (host_client);
-       
+
        Con_DPrintf ("Server spawned.\n");
 }
        Con_DPrintf ("Server spawned.\n");
 }
index 8effeb422124241656d1c553cbcfb00930258d04..33f6434485aac1b182cf6899e116baaf36a66db2 100644 (file)
--- a/sv_phys.c
+++ b/sv_phys.c
@@ -8,7 +8,7 @@ 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
 
 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.  
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 See the GNU General Public License for more details.
 
 
 See the GNU General Public License for more details.
 
@@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 pushmove objects do not obey gravity, and do not interact with each other or trigger fields, but block normal movement and push normal objects when they move.
 
 
 pushmove objects do not obey gravity, and do not interact with each other or trigger fields, but block normal movement and push normal objects when they move.
 
-onground is set for toss objects when they come to a complete rest.  it is set for steping or walking objects 
+onground is set for toss objects when they come to a complete rest.  it is set for steping or walking objects
 
 doors, plats, etc are SOLID_BSP, and MOVETYPE_PUSH
 bonus items are SOLID_TRIGGER touch, and MOVETYPE_TOSS
 
 doors, plats, etc are SOLID_BSP, and MOVETYPE_PUSH
 bonus items are SOLID_TRIGGER touch, and MOVETYPE_TOSS
@@ -39,11 +39,11 @@ solid_edge items only clip against bsp models.
 
 */
 
 
 */
 
-cvar_t sv_friction = {"sv_friction","4",false,true};
-cvar_t sv_stopspeed = {"sv_stopspeed","100"};
-cvar_t sv_gravity = {"sv_gravity","800",false,true};
-cvar_t sv_maxvelocity = {"sv_maxvelocity","2000"};
-cvar_t sv_nostep = {"sv_nostep","0"};
+cvar_t sv_friction = {CVAR_NOTIFY, "sv_friction","4"};
+cvar_t sv_stopspeed = {0, "sv_stopspeed","100"};
+cvar_t sv_gravity = {CVAR_NOTIFY, "sv_gravity","800"};
+cvar_t sv_maxvelocity = {0, "sv_maxvelocity","2000"};
+cvar_t sv_nostep = {0, "sv_nostep","0"};
 
 #define        MOVE_EPSILON    0.01
 
 
 #define        MOVE_EPSILON    0.01
 
index 9bf6c2189efca730953da76f9b5726296965e395..b00cbcf5ceea65d0ecd5ba6a17091736871d4984 100644 (file)
--- a/sv_user.c
+++ b/sv_user.c
@@ -8,7 +8,7 @@ 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
 
 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.  
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 See the GNU General Public License for more details.
 
 
 See the GNU General Public License for more details.
 
@@ -23,9 +23,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 edict_t        *sv_player;
 
 
 edict_t        *sv_player;
 
-cvar_t sv_edgefriction = {"edgefriction", "2"};
-cvar_t sv_predict = {"sv_predict", "1"};
-cvar_t sv_deltacompress = {"sv_deltacompress", "1"};
+cvar_t sv_edgefriction = {0, "edgefriction", "2"};
+cvar_t sv_predict = {0, "sv_predict", "1"};
+cvar_t sv_deltacompress = {0, "sv_deltacompress", "1"};
+cvar_t sv_idealpitchscale = {0, "sv_idealpitchscale","0.8"};
+cvar_t sv_maxspeed = {CVAR_NOTIFY, "sv_maxspeed", "320"};
+cvar_t sv_accelerate = {0, "sv_accelerate", "10"};
 
 static vec3_t          forward, right, up;
 
 
 static vec3_t          forward, right, up;
 
@@ -41,8 +44,6 @@ qboolean      onground;
 
 usercmd_t      cmd;
 
 
 usercmd_t      cmd;
 
-cvar_t sv_idealpitchscale = {"sv_idealpitchscale","0.8"};
-
 
 /*
 ===============
 
 /*
 ===============
@@ -165,8 +166,6 @@ void SV_UserFriction (void)
 SV_Accelerate
 ==============
 */
 SV_Accelerate
 ==============
 */
-cvar_t sv_maxspeed = {"sv_maxspeed", "320", false, true};
-cvar_t sv_accelerate = {"sv_accelerate", "10"};
 #if 0
 void SV_Accelerate (vec3_t wishvel)
 {
 #if 0
 void SV_Accelerate (vec3_t wishvel)
 {
diff --git a/ui.c b/ui.c
new file mode 100644 (file)
index 0000000..042b3a5
--- /dev/null
+++ b/ui.c
@@ -0,0 +1,391 @@
+
+#include "quakedef.h"
+
+cvar_t ui_showname = {0, "ui_showname", "0"};
+
+#define ITEM_CLICKABLE 1
+#define ITEM_DRAWABLE 2
+
+#define UIKEY_LEFT 1
+#define UIKEY_RIGHT 2
+#define UIKEY_UP 3
+#define UIKEY_DOWN 4
+#define UIKEY_ENTER 5
+
+#define UI_MOUSEBUTTONS 3
+
+static int                     ui_alive, ui_active;
+static float           ui_mouse_x, ui_mouse_y;
+static int                     ui_mousebutton[UI_MOUSEBUTTONS], ui_mouseclick;
+static int                     ui_keyui, ui_keyitem;
+static ui_item_t       *ui_keyrealitem;
+
+static ui_t *ui_list[MAX_UI_COUNT];
+
+static qpic_t *ui_mousepointer;
+
+void ui_start(void)
+{
+       ui_mousepointer = Draw_CachePic("ui/mousepointer.lmp");
+       ui_mouse_x = vid.width * 0.5;
+       ui_mouse_y = vid.height * 0.5;
+       ui_alive = true;
+}
+
+void ui_shutdown(void)
+{
+       ui_mousepointer = NULL;
+       ui_alive = false;
+}
+
+void ui_newmap(void)
+{
+}
+
+void ui_init(void)
+{
+       Cvar_RegisterVariable(&ui_showname);
+       R_RegisterModule("UI", ui_start, ui_shutdown, ui_newmap);
+}
+
+void ui_mouseupdate(float x, float y)
+{
+       if (ui_alive)
+       {
+               ui_mouse_x = bound(0, x, vid.width);
+               ui_mouse_y = bound(0, y, vid.height);
+       }
+}
+
+void ui_mouseupdaterelative(float x, float y)
+{
+       if (ui_alive)
+       {
+               ui_mouse_x += x;
+               ui_mouse_y += y;
+               ui_mouse_x = bound(0, ui_mouse_x, vid.width);
+               ui_mouse_y = bound(0, ui_mouse_y, vid.height);
+       }
+}
+
+ui_t *ui_create(void)
+{
+       ui_t *ui;
+       ui = qmalloc(sizeof(*ui));
+       if (ui == NULL)
+               Sys_Error("ui_create: unable to allocate memory for new ui\n");
+       memset(ui, 0, sizeof(*ui));
+       return ui;
+}
+
+void ui_free(ui_t *ui)
+{
+       if (ui)
+               qfree(ui);
+}
+
+void ui_clear(ui_t *ui)
+{
+       ui->item_count = 0;
+}
+
+void ui_item
+(
+       ui_t *ui, char *basename, int number,
+       float x, float y, qpic_t *pic,
+       float left, float top, float width, float height,
+       void(*leftkey)(void *nativedata1, void *nativedata2, float data1, float data2),
+       void(*rightkey)(void *nativedata1, void *nativedata2, float data1, float data2),
+       void(*enterkey)(void *nativedata1, void *nativedata2, float data1, float data2),
+       void(*mouseclick)(void *nativedata1, void *nativedata2, float data1, float data2, float xfrac, float yfrac),
+       void *nativedata1, void *nativedata2, float data1, float data2
+)
+{
+       int i;
+       ui_item_t *it;
+       char itemname[32];
+       snprintf(itemname, sizeof(itemname), "%s%04d", basename, number);
+       for (it = ui->items, i = 0;i < ui->item_count;it++, i++)
+               if (it->name == NULL || !strncmp(itemname, it->name, 32))
+                       break;
+       if (i == ui->item_count)
+       {
+               if (i == MAX_UI_ITEMS)
+               {
+                       Con_Printf("ui_item: ran out of UI item slots\n");
+                       return;
+               }
+               ui->item_count++;
+       }
+       strncpy(it->name, itemname, 32);
+       it->flags = 0;
+       if (leftkey || rightkey || enterkey || mouseclick)
+               it->flags |= ITEM_CLICKABLE;
+       if (pic)
+               it->flags |= ITEM_DRAWABLE;
+       it->draw_x = x;
+       it->draw_y = y;
+       it->click_x = x + left;
+       it->click_y = y + top;
+       it->click_x2 = it->click_x + width;
+       it->click_y2 = it->click_y + height;
+       it->leftkey = leftkey;
+       it->rightkey = rightkey;
+       it->enterkey = enterkey;
+       it->mouseclick = mouseclick;
+       if (it->mouseclick == NULL)
+               it->mouseclick = (void *)it->enterkey;
+       if (it->leftkey == NULL)
+               it->leftkey = it->enterkey;
+       if (it->rightkey == NULL)
+               it->rightkey = it->enterkey;
+       it->nativedata1 = nativedata1;
+       it->nativedata2 = nativedata2;
+}
+
+void ui_item_remove(ui_t *ui, char *basename, int number)
+{
+       int i;
+       ui_item_t *it;
+       char itemname[32];
+       snprintf(itemname, sizeof(itemname), "%s%04d", basename, number);
+       for (it = ui->items, i = 0;i < ui->item_count;it++, i++)
+               if (it->name && !strncmp(itemname, it->name, 32))
+                       break;
+       if (i < ui->item_count)
+               it->name[0] = 0;
+}
+
+ui_item_t *ui_hititem(float x, float y)
+{
+       int i, j;
+       ui_item_t *it;
+       ui_t *ui;
+       for (j = 0;j < MAX_UI_COUNT;j++)
+               if ((ui = ui_list[j]))
+                       for (it = ui->items, i = 0;i < ui->item_count;it++, i++)
+                               if (it->name[0] && (it->flags & ITEM_CLICKABLE))
+                                       if (x >= it->click_x && y >= it->click_y && x < it->click_x2 && y < it->click_y2)
+                                               return it;
+       return NULL;
+}
+
+int ui_uiactive(ui_t *ui)
+{
+       int i;
+       for (i = 0;i < MAX_UI_COUNT;i++)
+               if (ui_list[i] == ui)
+                       return true;
+       return false;
+}
+
+void ui_activate(ui_t *ui, int yes)
+{
+       int i;
+       if (yes)
+       {
+               if (ui_uiactive(ui))
+                       return;
+
+               for (i = 0;i < MAX_UI_COUNT;i++)
+               {
+                       if (ui_list[i] == NULL)
+                       {
+                               ui_list[i] = ui;
+                               return;
+                       }
+               }
+
+               Con_Printf("ui_activate: ran out of active ui list items\n");
+       }
+       else
+       {
+               for (i = 0;i < MAX_UI_COUNT;i++)
+               {
+                       if (ui_list[i] == ui)
+                       {
+                               ui_list[i] = NULL;
+                               return;
+                       }
+               }
+       }
+}
+
+int ui_isactive(void)
+{
+       int j;
+       ui_t *ui;
+       if (ui_alive)
+       {
+               for (j = 0;j < MAX_UI_COUNT;j++)
+                       if ((ui = ui_list[j]))
+                               if (ui->item_count)
+                                       return true;
+       }
+       return false;
+}
+
+#define UI_QUEUE_SIZE 256
+static byte ui_keyqueue[UI_QUEUE_SIZE];
+static int ui_keyqueuepos = 0;
+
+void ui_leftkeyupdate(int pressed)
+{
+       static int key = false;
+       if (pressed && !key && ui_keyqueuepos < UI_QUEUE_SIZE)
+               ui_keyqueue[ui_keyqueuepos++] = UIKEY_LEFT;
+       key = pressed;
+}
+
+void ui_rightkeyupdate(int pressed)
+{
+       static int key = false;
+       if (pressed && !key && ui_keyqueuepos < UI_QUEUE_SIZE)
+               ui_keyqueue[ui_keyqueuepos++] = UIKEY_RIGHT;
+       key = pressed;
+}
+
+void ui_upkeyupdate(int pressed)
+{
+       static int key = false;
+       if (pressed && !key && ui_keyqueuepos < UI_QUEUE_SIZE)
+               ui_keyqueue[ui_keyqueuepos++] = UIKEY_UP;
+       key = pressed;
+}
+
+void ui_downkeyupdate(int pressed)
+{
+       static int key = false;
+       if (pressed && !key && ui_keyqueuepos < UI_QUEUE_SIZE)
+               ui_keyqueue[ui_keyqueuepos++] = UIKEY_DOWN;
+       key = pressed;
+}
+
+void ui_mousebuttonupdate(int button, int pressed)
+{
+       if (button < 0 || button >= UI_MOUSEBUTTONS)
+               return;
+       if (button == 0 && ui_mousebutton[button] && !pressed)
+               ui_mouseclick = true;
+       ui_mousebutton[button] = pressed;
+}
+
+void ui_update(void)
+{
+       ui_item_t *startitem, *it;
+       if (ui_alive)
+       {
+               ui_mouse_x = bound(0, ui_mouse_x, vid.width);
+               ui_mouse_y = bound(0, ui_mouse_y, vid.height);
+
+               if ((ui_active = ui_isactive()))
+               {
+                       // validate currently selected item
+                       if(ui_list[ui_keyui] == NULL)
+                       {
+                               while (ui_list[ui_keyui] == NULL)
+                                       ui_keyui = (ui_keyui + 1) % MAX_UI_COUNT;
+                               ui_keyitem = 0;
+                       }
+                       ui_keyitem = bound(0, ui_keyitem, ui_list[ui_keyui]->item_count - 1);
+                       startitem = ui_keyrealitem = &ui_list[ui_keyui]->items[ui_keyitem];
+                       if ((ui_keyrealitem->flags & ITEM_CLICKABLE) == 0)
+                       {
+                               do
+                               {
+                                       // FIXME: cycle through UIs as well as items in a UI
+                                       ui_keyitem = (ui_keyitem - 1) % ui_list[ui_keyui]->item_count - 1;
+                                       ui_keyrealitem = &ui_list[ui_keyui]->items[ui_keyitem];
+                               }
+                               while (ui_keyrealitem != startitem && (ui_keyrealitem->flags & ITEM_CLICKABLE) == 0);
+                       }
+
+                       if (ui_keyqueuepos)
+                       {
+                               int i;
+                               for (i = 0;i < ui_keyqueuepos;i++)
+                               {
+                                       startitem = ui_keyrealitem;
+                                       switch(ui_keyqueue[i])
+                                       {
+                                       case UIKEY_UP:
+                                               do
+                                               {
+                                                       ui_keyitem--;
+                                                       if (ui_keyitem < 0)
+                                                       {
+                                                               do
+                                                                       ui_keyui = (ui_keyui - 1) % MAX_UI_COUNT;
+                                                               while(ui_list[ui_keyui] == NULL);
+                                                               ui_keyitem = ui_list[ui_keyui]->item_count - 1;
+                                                       }
+                                                       ui_keyrealitem = &ui_list[ui_keyui]->items[ui_keyitem];
+                                               }
+                                               while (ui_keyrealitem != startitem && (ui_keyrealitem->flags & ITEM_CLICKABLE) == 0);
+                                               break;
+                                       case UIKEY_DOWN:
+                                               do
+                                               {
+                                                       ui_keyitem++;
+                                                       if (ui_keyitem >= ui_list[ui_keyui]->item_count)
+                                                       {
+                                                               do
+                                                                       ui_keyui = (ui_keyui + 1) % MAX_UI_COUNT;
+                                                               while(ui_list[ui_keyui] == NULL);
+                                                               ui_keyitem = 0;
+                                                       }
+                                                       ui_keyrealitem = &ui_list[ui_keyui]->items[ui_keyitem];
+                                               }
+                                               while (ui_keyrealitem != startitem && (ui_keyrealitem->flags & ITEM_CLICKABLE) == 0);
+                                               break;
+                                       case UIKEY_LEFT:
+                                               if (ui_keyrealitem->leftkey)
+                                                       ui_keyrealitem->leftkey(ui_keyrealitem->nativedata1, ui_keyrealitem->nativedata2, ui_keyrealitem->data1, ui_keyrealitem->data2);
+                                               break;
+                                       case UIKEY_RIGHT:
+                                               if (ui_keyrealitem->rightkey)
+                                                       ui_keyrealitem->rightkey(ui_keyrealitem->nativedata1, ui_keyrealitem->nativedata2, ui_keyrealitem->data1, ui_keyrealitem->data2);
+                                               break;
+                                       case UIKEY_ENTER:
+                                               if (ui_keyrealitem->enterkey)
+                                                       ui_keyrealitem->enterkey(ui_keyrealitem->nativedata1, ui_keyrealitem->nativedata2, ui_keyrealitem->data1, ui_keyrealitem->data2);
+                                               break;
+                                       }
+                               }
+                       }
+                       ui_keyqueuepos = 0;
+
+                       if (ui_mouseclick && (it = ui_hititem(ui_mouse_x, ui_mouse_y)) && it->mouseclick)
+                               it->mouseclick(it->nativedata1, it->nativedata2, it->data1, it->data2, ui_mouse_x - it->click_x, ui_mouse_y - it->click_y);
+       }
+       }
+       ui_mouseclick = false;
+}
+
+void ui_draw(void)
+{
+       int i, j;
+       ui_item_t *it;
+       ui_t *ui;
+       if (ui_alive && ui_active)
+       {
+               for (j = 0;j < MAX_UI_COUNT;j++)
+                       if ((ui = ui_list[j]))
+                               if (ui->item_count)
+                                       for (i = 0, it = ui->items;i < ui->item_count;i++, it++)
+                                               if (it->flags & ITEM_DRAWABLE)
+                                                       Draw_Pic(it->draw_x, it->draw_y, it->draw_pic);
+
+               if ((it = ui_hititem(ui_mouse_x, ui_mouse_y)))
+               {
+                       Draw_AdditivePic(it->draw_x, it->draw_y, it->draw_pic);
+                       if (ui_showname.value)
+                               Draw_String(ui_mouse_x, ui_mouse_y + 16, it->name, 9999);
+       }
+
+               it = ui_keyrealitem;
+               Draw_AdditivePic(it->draw_x, it->draw_y, it->draw_pic);
+
+               Draw_Pic(ui_mouse_x, ui_mouse_y, ui_mousepointer);
+       }
+}
diff --git a/ui.h b/ui.h
new file mode 100644 (file)
index 0000000..5d58c6d
--- /dev/null
+++ b/ui.h
@@ -0,0 +1,55 @@
+
+#define MAX_UI_COUNT 16
+#define MAX_UI_ITEMS 256
+
+typedef struct
+{
+       char name[32];
+       int flags;
+       qpic_t *draw_pic;
+       int draw_x, draw_y;
+       int click_x, click_y, click_x2, click_y2;
+       void(*leftkey)(void *nativedata1, void *nativedata2, float data1, float data2);
+       void(*rightkey)(void *nativedata1, void *nativedata2, float data1, float data2);
+       void(*enterkey)(void *nativedata1, void *nativedata2, float data1, float data2);
+       void(*mouseclick)(void *nativedata1, void *nativedata2, float data1, float data2, float xfrac, float yfrac);
+       void *nativedata1, *nativedata2;
+       float data1, data2;
+}
+ui_item_t;
+
+typedef struct
+{
+       int item_count;
+       int pad;
+       ui_item_t items[MAX_UI_ITEMS];
+}
+ui_t;
+
+void ui_init(void);
+void ui_mouseupdate(float x, float y);
+void ui_mouseupdaterelative(float x, float y);
+ui_t *ui_create(void);
+void ui_free(ui_t *ui);
+void ui_clear(ui_t *ui);
+void ui_item
+(
+       ui_t *ui, char *basename, int number,
+       float x, float y, qpic_t *pic,
+       float left, float top, float width, float height,
+       void(*leftkey)(void *nativedata1, void *nativedata2, float data1, float data2),
+       void(*rightkey)(void *nativedata1, void *nativedata2, float data1, float data2),
+       void(*enterkey)(void *nativedata1, void *nativedata2, float data1, float data2),
+       void(*mouseclick)(void *nativedata1, void *nativedata2, float data1, float data2, float xfrac, float yfrac),
+       void *nativedata1, void *nativedata2, float data1, float data2
+);
+void ui_item_remove(ui_t *ui, char *basename, int number);
+int ui_uiactive(ui_t *ui);
+void ui_activate(ui_t *ui, int yes);
+void ui_leftkeyupdate(int pressed);
+void ui_rightkeyupdate(int pressed);
+void ui_upkeyupdate(int pressed);
+void ui_downkeyupdate(int pressed);
+void ui_mousebuttonupdate(int button, int pressed);
+void ui_update(void);
+void ui_draw(void);
index a1a898fde3c3975759361c4f56bfc7783a16c1ee..995cd6416a4c334227d80b13df90a9280abe7d09 100644 (file)
--- a/vid_glx.c
+++ b/vid_glx.c
@@ -58,9 +58,9 @@ static float  mouse_x, mouse_y;
 static float   old_mouse_x, old_mouse_y;
 static int p_mouse_x, p_mouse_y;
 
 static float   old_mouse_x, old_mouse_y;
 static int p_mouse_x, p_mouse_y;
 
-cvar_t vid_dga = {"vid_dga", "1", true};
-cvar_t vid_dga_mouseaccel = {"vid_dga_mouseaccel", "1", false};
-cvar_t m_filter = {"m_filter", "0"};
+cvar_t vid_dga = {CVAR_SAVE, "vid_dga", "1"};
+cvar_t vid_dga_mouseaccel = {0, "vid_dga_mouseaccel", "1"};
+cvar_t m_filter = {0, "m_filter", "0"};
 
 qboolean vidmode_ext = false;
 
 
 qboolean vidmode_ext = false;
 
@@ -310,8 +310,8 @@ static void HandleEvents(void)
                                        {
                                                if (!event.xmotion.send_event)
                                                {
                                        {
                                                if (!event.xmotion.send_event)
                                                {
-                                                       mouse_x += (event.xmotion.x - p_mouse_x);
-                                                       mouse_y += (event.xmotion.y - p_mouse_y);
+                                                       mouse_x += event.xmotion.x - p_mouse_x;
+                                                       mouse_y += event.xmotion.y - p_mouse_y;
                                                        if (abs(vid.width/2 - event.xmotion.x) > vid.width / 4 || abs(vid.height/2 - event.xmotion.y) > vid.height / 4)
                                                                dowarp = true;
                                                }
                                                        if (abs(vid.width/2 - event.xmotion.x) > vid.width / 4 || abs(vid.height/2 - event.xmotion.y) > vid.height / 4)
                                                                dowarp = true;
                                                }
@@ -327,6 +327,8 @@ static void HandleEvents(void)
                                        p_mouse_y = event.xmotion.y;
                                }
                        }
                                        p_mouse_y = event.xmotion.y;
                                }
                        }
+                       else
+                               ui_mouseupdate(event.xmotion.x, event.xmotion.y);
                        break;
 
                case ButtonPress:
                        break;
 
                case ButtonPress:
@@ -493,18 +495,38 @@ void VID_CheckMultitexture(void)
                Con_Printf("...using GL_ARB_multitexture\n");
                qglMTexCoord2f = (void *) dlsym(prjobj, "glMultiTexCoord2fARB");
                qglSelectTexture = (void *) dlsym(prjobj, "glActiveTextureARB");
                Con_Printf("...using GL_ARB_multitexture\n");
                qglMTexCoord2f = (void *) dlsym(prjobj, "glMultiTexCoord2fARB");
                qglSelectTexture = (void *) dlsym(prjobj, "glActiveTextureARB");
-               gl_mtexable = true;
-               gl_mtex_enum = GL_TEXTURE0_ARB;
+               if (qglMTexCoord2f != NULL && qglSelectTexture != NULL)
+               {
+                       gl_mtexable = true;
+                       gl_mtex_enum = GL_TEXTURE0_ARB;
+               }
+               else
+               {
+                       if (qglMTexCoord2f == NULL)
+                               Con_Printf("dlsym(prjobj, \"glMultiTexCoord2fARB\") == NULL!\n");
+                       if (qglSelectTexture == NULL)
+                               Con_Printf("dlsym(prjobj, \"glActiveTextureARB\") == NULL!\n");
+       }
        }
        }
-       else if (strstr(gl_extensions, "GL_SGIS_multitexture ")) // Test for SGIS_multitexture (if ARB_multitexture not found)
+       if (!gl_mtexable && strstr(gl_extensions, "GL_SGIS_multitexture ")) // Test for SGIS_multitexture (if ARB_multitexture not found)
        {
                Con_Printf("...using GL_SGIS_multitexture\n");
                qglMTexCoord2f = (void *) dlsym(prjobj, "glMTexCoord2fSGIS");
                qglSelectTexture = (void *) dlsym(prjobj, "glSelectTextureSGIS");
        {
                Con_Printf("...using GL_SGIS_multitexture\n");
                qglMTexCoord2f = (void *) dlsym(prjobj, "glMTexCoord2fSGIS");
                qglSelectTexture = (void *) dlsym(prjobj, "glSelectTextureSGIS");
-               gl_mtexable = true;
-               gl_mtex_enum = TEXTURE0_SGIS;
+               if (qglMTexCoord2f != NULL && qglSelectTexture != NULL)
+               {
+                       gl_mtexable = true;
+                       gl_mtex_enum = TEXTURE0_SGIS;
+               }
+               else
+               {
+                       if (qglMTexCoord2f == NULL)
+                               Con_Printf("dlsym(prjobj, \"glMTexCoord2fSGIS\") == NULL!\n");
+                       if (qglSelectTexture == NULL)
+                               Con_Printf("dlsym(prjobj, \"glSelectTextureSGIS\") == NULL!\n");
+       }
        }
        }
-       else
+       if (!gl_mtexable)
                Con_Printf("...multitexture disabled (not detected)\n");
        dlclose(prjobj);
 }
                Con_Printf("...multitexture disabled (not detected)\n");
        dlclose(prjobj);
 }
@@ -530,7 +552,16 @@ void VID_CheckCVA(void)
                Con_Printf("...using compiled vertex arrays\n");
                qglLockArraysEXT = (void *) dlsym(prjobj, "glLockArraysEXT");
                qglUnlockArraysEXT = (void *) dlsym(prjobj, "glUnlockArraysEXT");
                Con_Printf("...using compiled vertex arrays\n");
                qglLockArraysEXT = (void *) dlsym(prjobj, "glLockArraysEXT");
                qglUnlockArraysEXT = (void *) dlsym(prjobj, "glUnlockArraysEXT");
-               gl_supportslockarrays = true;
+               if (qglLockArraysEXT != NULL && qglUnlockArraysEXT != NULL)
+                       gl_supportslockarrays = true;
+               else
+               {
+                       if (qglLockArraysEXT == NULL)
+                               Con_Printf("dlsym(prjobj, \"glLockArraysEXT\") == NULL!\n");
+                       if (qglUnlockArraysEXT == NULL)
+                               Con_Printf("dlsym(prjobj, \"glUnlockArraysEXT\") == NULL!\n");
+                       Con_Printf("...compiled vertex arrays disabled\n");
+       }
        }
        dlclose(prjobj);
 }
        }
        dlclose(prjobj);
 }
index b28692ad57b8a74b3bafd5bbd08b1b232ae03101..8852c35942bcd4c3e9948ee0154d76b8c9256d66 100644 (file)
@@ -11,9 +11,9 @@ qboolean gl_supportslockarrays = false;
 qboolean gl_mtexable = false;
 int gl_mtex_enum = 0;
 
 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"};
+cvar_t vid_mode = {0, "vid_mode", "0"};
+cvar_t vid_mouse = {CVAR_SAVE, "vid_mouse", "1"};
+cvar_t vid_fullscreen = {0, "vid_fullscreen", "1"};
 
 void (GLAPIENTRY *qglMTexCoord2f) (GLenum, GLfloat, GLfloat);
 void (GLAPIENTRY *qglSelectTexture) (GLenum);
 
 void (GLAPIENTRY *qglMTexCoord2f) (GLenum, GLfloat, GLfloat);
 void (GLAPIENTRY *qglSelectTexture) (GLenum);
diff --git a/view.c b/view.c
index c14f9603ff39bebfc9093b34aee54ecdfdcca608..ae3c45f2aba532d3b2db2566fde9b6587ce1a6e6 100644 (file)
--- a/view.c
+++ b/view.c
@@ -30,34 +30,35 @@ when crossing a water boudnary.
 
 */
 
 
 */
 
-cvar_t cl_rollspeed = {"cl_rollspeed", "200"};
-cvar_t cl_rollangle = {"cl_rollangle", "2.0"};
+cvar_t cl_rollspeed = {0, "cl_rollspeed", "200"};
+cvar_t cl_rollangle = {0, "cl_rollangle", "2.0"};
 
 
-cvar_t cl_bob = {"cl_bob","0.02", false};
-cvar_t cl_bobcycle = {"cl_bobcycle","0.6", false};
-cvar_t cl_bobup = {"cl_bobup","0.5", false};
+cvar_t cl_bob = {0, "cl_bob","0.02"};
+cvar_t cl_bobcycle = {0, "cl_bobcycle","0.6"};
+cvar_t cl_bobup = {0, "cl_bobup","0.5"};
 
 
-cvar_t v_kicktime = {"v_kicktime", "0.5", false};
-cvar_t v_kickroll = {"v_kickroll", "0.6", false};
-cvar_t v_kickpitch = {"v_kickpitch", "0.6", false};
+cvar_t v_kicktime = {0, "v_kicktime", "0.5"};
+cvar_t v_kickroll = {0, "v_kickroll", "0.6"};
+cvar_t v_kickpitch = {0, "v_kickpitch", "0.6"};
 
 
-cvar_t v_punch = {"v_punch", "1", false};
+cvar_t v_punch = {0, "v_punch", "1"};
 
 
-cvar_t v_iyaw_cycle = {"v_iyaw_cycle", "2", false};
-cvar_t v_iroll_cycle = {"v_iroll_cycle", "0.5", false};
-cvar_t v_ipitch_cycle = {"v_ipitch_cycle", "1", false};
-cvar_t v_iyaw_level = {"v_iyaw_level", "0.3", false};
-cvar_t v_iroll_level = {"v_iroll_level", "0.1", false};
-cvar_t v_ipitch_level = {"v_ipitch_level", "0.3", false};
+cvar_t v_iyaw_cycle = {0, "v_iyaw_cycle", "2"};
+cvar_t v_iroll_cycle = {0, "v_iroll_cycle", "0.5"};
+cvar_t v_ipitch_cycle = {0, "v_ipitch_cycle", "1"};
+cvar_t v_iyaw_level = {0, "v_iyaw_level", "0.3"};
+cvar_t v_iroll_level = {0, "v_iroll_level", "0.1"};
+cvar_t v_ipitch_level = {0, "v_ipitch_level", "0.3"};
 
 
-cvar_t v_idlescale = {"v_idlescale", "0", false};
+cvar_t v_idlescale = {0, "v_idlescale", "0"};
 
 
-cvar_t crosshair = {"crosshair", "0", true};
-cvar_t cl_crossx = {"cl_crossx", "0", false};
-cvar_t cl_crossy = {"cl_crossy", "0", false};
+cvar_t crosshair = {CVAR_SAVE, "crosshair", "0"};
 
 
-//cvar_t       gl_cshiftpercent = {"gl_cshiftpercent", "100", false};
-cvar_t gl_polyblend = {"gl_polyblend", "1", true};
+//cvar_t       gl_cshiftpercent = {0, "gl_cshiftpercent", "100"};
+cvar_t gl_polyblend = {CVAR_SAVE, "gl_polyblend", "1"};
+
+cvar_t v_centermove = {0, "v_centermove", "0.15"};
+cvar_t v_centerspeed = {0, "v_centerspeed","500"};
 
 float  v_dmg_time, v_dmg_roll, v_dmg_pitch;
 
 
 float  v_dmg_time, v_dmg_roll, v_dmg_pitch;
 
@@ -89,9 +90,9 @@ float V_CalcRoll (vec3_t angles, vec3_t velocity)
                side = side * value / cl_rollspeed.value;
        else
                side = value;
                side = side * value / cl_rollspeed.value;
        else
                side = value;
-       
+
        return side*sign;
        return side*sign;
-       
+
 }
 
 
 }
 
 
@@ -131,10 +132,6 @@ float V_CalcBob (void)
 //=============================================================================
 
 
 //=============================================================================
 
 
-cvar_t v_centermove = {"v_centermove", "0.15", false};
-cvar_t v_centerspeed = {"v_centerspeed","500"};
-
-
 void V_StartPitchDrift (void)
 {
 #if 1
 void V_StartPitchDrift (void)
 {
 #if 1
@@ -168,7 +165,7 @@ If the user is adjusting pitch manually, either with lookup/lookdown,
 mlook and mouse, or klook and keyboard, pitch drifting is constantly stopped.
 
 Drifting is enabled when the center view key is hit, mlook is released and
 mlook and mouse, or klook and keyboard, pitch drifting is constantly stopped.
 
 Drifting is enabled when the center view key is hit, mlook is released and
-lookspring is non 0, or when 
+lookspring is non 0, or when
 ===============
 */
 void V_DriftPitch (void)
 ===============
 */
 void V_DriftPitch (void)
@@ -511,7 +508,7 @@ void V_UpdateBlends (void)
        V_CalcPowerupCshift ();
        
        new = false;
        V_CalcPowerupCshift ();
        
        new = false;
-       
+
        for (i=0 ; i<NUM_CSHIFTS ; i++)
        {
                if (cl.cshifts[i].percent != cl.prev_cshifts[i].percent)
        for (i=0 ; i<NUM_CSHIFTS ; i++)
        {
                if (cl.cshifts[i].percent != cl.prev_cshifts[i].percent)
@@ -595,7 +592,7 @@ void CalcGunAngle (void)
                if (oldyaw - move > yaw)
                        yaw = oldyaw - move;
        }
                if (oldyaw - move > yaw)
                        yaw = oldyaw - move;
        }
-       
+
        if (pitch > oldpitch)
        {
                if (oldpitch + move < pitch)
        if (pitch > oldpitch)
        {
                if (oldpitch + move < pitch)
@@ -889,8 +886,6 @@ void V_Init (void)
 
        Cvar_RegisterVariable (&v_idlescale);
        Cvar_RegisterVariable (&crosshair);
 
        Cvar_RegisterVariable (&v_idlescale);
        Cvar_RegisterVariable (&crosshair);
-       Cvar_RegisterVariable (&cl_crossx);
-       Cvar_RegisterVariable (&cl_crossy);
 //     Cvar_RegisterVariable (&gl_cshiftpercent);
        Cvar_RegisterVariable (&gl_polyblend);
 
 //     Cvar_RegisterVariable (&gl_cshiftpercent);
        Cvar_RegisterVariable (&gl_polyblend);