]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Updated some builtin parameter lists, added 2 functions to the menu builtins.
authorblack <black@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 17 Oct 2003 14:02:34 +0000 (14:02 +0000)
committerblack <black@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 17 Oct 2003 14:02:34 +0000 (14:02 +0000)
Added the boolean in_client_mouse (used to indicate wheter mouse position data
should be send to the client.
(Only Win at the moment)

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

cl_main.c
fs.c
input.h
keys.c
prvm_cmds.c
vid_shared.c

index d67183929a497b4fee32b7e82aa5270f070d0bbf..f01040391e931c570a04eaff68daf4be00b331f0 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -1115,16 +1115,16 @@ void CL_SendCmd(void)
        {
                // get basic movement from keyboard
                CL_BaseMove(&cmd);
        {
                // get basic movement from keyboard
                CL_BaseMove(&cmd);
-
+               
                // OS independent code
                IN_PreMove();
                // OS independent code
                IN_PreMove();
-
+                       
                // 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);
-
+                       
                // OS independent code
                IN_PostMove();
                // OS independent code
                IN_PostMove();
-
+                       
                // send the unreliable message
                CL_SendMove(&cmd);
        }
                // send the unreliable message
                CL_SendMove(&cmd);
        }
diff --git a/fs.c b/fs.c
index bbdaf2f6ac3fcad47abb44e78e4d5b797bafb678..333bf551a5cef75603dd1ef73121e69f38c675fa 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -982,6 +982,98 @@ qfile_t *FS_FOpenFile (const char *filename, qboolean quiet)
 
        filenamelen = strlen (filename);
 
 
        filenamelen = strlen (filename);
 
+               // search through the path, one element at a time
+       search = fs_searchpaths;
+
+       for( ; search ; search = search->next)
+               if(!search->pack)
+               {
+                       snprintf (netpath, sizeof (netpath), "%s/%s",search->filename, filename);
+                       
+                       if (!FS_SysFileExists (netpath))
+                               continue;
+                       
+                       if (!quiet)
+                               Sys_Printf ("FindFile: %s\n",netpath);
+                       return FS_OpenRead (netpath, -1, -1);
+               }
+               
+#ifdef AKVERSION               
+       search = fs_searchpaths;
+       for ( ; search ; search = search->next)
+               // is the element a pak file?
+               if (search->pack)
+               {
+                       // look through all the pak file elements
+                       pak = search->pack;
+                       for (i=0 ; i<pak->numfiles ; i++)
+                       {
+                               if (pak->ignorecase)
+                                       matched = !strcasecmp (pak->files[i].name, filename);
+                               else
+                                       matched = !strcmp (pak->files[i].name, filename);
+                               if (matched)  // found it?
+                               {
+                                       qfile_t *file;
+
+                                       if (!quiet)
+                                               Sys_Printf ("PackFile: %s : %s\n",pak->filename, pak->files[i].name);
+
+                                       // If we don't have the true offset, get it now
+                                       if (! (pak->files[i].flags & FILE_FLAG_TRUEOFFS))
+                                               PK3_GetTrueFileOffset (&pak->files[i], pak);
+
+                                       // No Zlib DLL = no compressed files
+                                       if (!zlib_dll && (pak->files[i].flags & FILE_FLAG_DEFLATED))
+                                       {
+                                               Con_Printf ("WARNING: can't open the compressed file %s\n"
+                                                                       "You need the Zlib DLL to use compressed files\n", filename);
+                                               fs_filesize = -1;
+                                               return NULL;
+                                       }
+
+                                       // open a new file in the pakfile
+                                       file = FS_OpenRead (pak->filename, pak->files[i].offset, pak->files[i].packsize);
+                                       fs_filesize = pak->files[i].realsize;
+
+                                       if (pak->files[i].flags & FILE_FLAG_DEFLATED)
+                                       {
+                                               ztoolkit_t *ztk;
+
+                                               file->flags |= FS_FLAG_DEFLATED;
+
+                                               // We need some more variables
+                                               ztk = Mem_Alloc (fs_mempool, sizeof (*file->z));
+
+                                               ztk->real_length = pak->files[i].realsize;
+
+                                               // Initialize zlib stream
+                                               ztk->zstream.next_in = ztk->input;
+                                               ztk->zstream.avail_in = 0;
+
+                                               /* From Zlib's "unzip.c":
+                                                *
+                                                * windowBits is passed < 0 to tell that there is no zlib header.
+                                                * Note that in this case inflate *requires* an extra "dummy" byte
+                                                * after the compressed stream in order to complete decompression and
+                                                * return Z_STREAM_END.
+                                                * In unzip, i don't wait absolutely Z_STREAM_END because I known the
+                                                * size of both compressed and uncompressed data
+                                                */
+                                               if (qz_inflateInit2 (&ztk->zstream, -MAX_WBITS) != Z_OK)
+                                                       Sys_Error ("inflate init error (file: %s)", filename);
+
+                                               ztk->zstream.next_out = ztk->output;
+                                               ztk->zstream.avail_out = sizeof (ztk->output);
+
+                                               file->z = ztk;
+                                       }
+
+                                       return file;
+                               }
+                       }
+               }
+#else
        // search through the path, one element at a time
        search = fs_searchpaths;
 
        // search through the path, one element at a time
        search = fs_searchpaths;
 
@@ -1071,7 +1163,8 @@ qfile_t *FS_FOpenFile (const char *filename, qboolean quiet)
                        return FS_OpenRead (netpath, -1, -1);
                }
        }
                        return FS_OpenRead (netpath, -1, -1);
                }
        }
-
+#endif
+       
        if (!quiet)
                Sys_Printf ("FindFile: can't find %s\n", filename);
 
        if (!quiet)
                Sys_Printf ("FindFile: can't find %s\n", filename);
 
diff --git a/input.h b/input.h
index 30f76ef56fe80ae01fb03aa15bfc1137b7d38909..31a231805919af431cbeda69af848ed4ef80c1bc 100644 (file)
--- a/input.h
+++ b/input.h
@@ -25,6 +25,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 extern cvar_t in_pitch_min;
 extern cvar_t in_pitch_max;
 
 extern cvar_t in_pitch_min;
 extern cvar_t in_pitch_max;
 
+extern qboolean in_client_mouse;
+extern float in_mouse_x, in_mouse_y;
+
+//enum {input_game,input_message,input_menu} input_dest;
+
 void IN_Commands (void);
 // oportunity for devices to stick commands on the script buffer
 
 void IN_Commands (void);
 // oportunity for devices to stick commands on the script buffer
 
diff --git a/keys.c b/keys.c
index 1e2801e2edfd72e92a3894c6e2a2e711dc19f206..ff6ed0e6476ae32f175f1e71c712150a2ec2dcee 100644 (file)
--- a/keys.c
+++ b/keys.c
@@ -836,18 +836,13 @@ void Key_Event (int key, char ascii, qboolean down)
                }
        }
 
                }
        }
 
-       // AK What the fuck ?!?
+       // AK New WTF ?!?
        // AK Changed so the code does what the comments tell 
        // 
        // 1. if console is active or not, always send the up events
        // AK Changed so the code does what the comments tell 
        // 
        // 1. if console is active or not, always send the up events
+       // console only wants key down events
        if (key_consoleactive && consolekeys[key] && down)
        if (key_consoleactive && consolekeys[key] && down)
-       {
-               // console only wants key down events
-               //if (!down)
-               //      return;
-
                Key_Console (key, ascii);
                Key_Console (key, ascii);
-       }
        else
        {
                //
        else
        {
                //
@@ -880,6 +875,7 @@ void Key_Event (int key, char ascii, qboolean down)
                if ((key_consoleactive && !consolekeys[key])
                 || (key_dest == key_menu && menubound[key])
                 || key_dest == key_game)
                if ((key_consoleactive && !consolekeys[key])
                 || (key_dest == key_menu && menubound[key])
                 || key_dest == key_game)
+               if (!key_consoleactive && key_dest != key_menu)
                {
                        kb = keybindings[key];
                        if (kb)
                {
                        kb = keybindings[key];
                        if (kb)
@@ -899,9 +895,6 @@ void Key_Event (int key, char ascii, qboolean down)
                        return;
                }
 
                        return;
                }
 
-               if (!down)
-                       return;         // other systems only care about key down events
-
                switch (key_dest)
                {
                case key_message:
                switch (key_dest)
                {
                case key_message:
index 0295b19b6c82b01cb4fa1b225cc7f9a62ab9391c..e3610cc71852fad341d28323d06f8dd7a11ca03b 100644 (file)
@@ -32,11 +32,11 @@ string      vtos(vector)
 string etos(entity)
 float  stof(...[string])
 entity spawn()
 string etos(entity)
 float  stof(...[string])
 entity spawn()
-entity remove()
+               remove(entity e)
 entity find(entity start, .string field, string match)
 
 entity find(entity start, .string field, string match)
 
-entity findfloat(entity start, .float field, string match)
-entity findentity(entity start, .entity field, string match)
+entity findfloat(entity start, .float field, float match)
+entity findentity(entity start, .entity field, entity match)
 
 entity findchain(.string field, string match)
 
 
 entity findchain(.string field, string match)
 
@@ -48,7 +48,7 @@ string        precache_sound (string sample)
                coredump()
                traceon()
                traceoff()
                coredump()
                traceon()
                traceoff()
-               eprint(entity float)
+               eprint(entity e)
 float  rint(float)
 float  floor(float)
 float  ceil(float)
 float  rint(float)
 float  floor(float)
 float  ceil(float)
@@ -56,7 +56,7 @@ entity        nextent(entity)
 float  sin(float)
 float  cos(float)
 float  sqrt(float)
 float  sin(float)
 float  cos(float)
 float  sqrt(float)
-               randomvec()
+vector randomvec()
 float  registercvar (string name, string value)
 float  min(float a, float b, ...[float])
 float  max(float a, float b, ...[float])
 float  registercvar (string name, string value)
 float  min(float a, float b, ...[float])
 float  max(float a, float b, ...[float])
@@ -68,19 +68,21 @@ float       fopen(string filename, float mode)
 string fgets(float fhandle)
                fputs(float fhandle, string s)
 float  strlen(string s)
 string fgets(float fhandle)
                fputs(float fhandle, string s)
 float  strlen(string s)
-string strcat(string s1, string s2)
+string strcat(string,string,...[string])
 string substring(string s, float start, float length)
 vector stov(string s)
 string strzone(string s)
 string substring(string s, float start, float length)
 vector stov(string s)
 string strzone(string s)
-               strzone(string s)
+               strunzone(string s)
+float  tokenize(string s)
+string argv(float n)
 float  isserver()
 float  clientcount()
 float  clientstate()
                clientcommand(float client, string s) (for client and menu)
 float  isserver()
 float  clientcount()
 float  clientstate()
                clientcommand(float client, string s) (for client and menu)
-float  tokenize(string s)
                changelevel(string map)
                localsound(string sample)
                changelevel(string map)
                localsound(string sample)
-
+vector getmousepos()
+               
 perhaps only : Menu : WriteMsg 
 ===============================
 
 perhaps only : Menu : WriteMsg 
 ===============================
 
@@ -104,6 +106,15 @@ float      drawstring(vector position, string text, vector scale, vector rgb, float a
 float  drawpic(vector position, string pic, vector size, vector rgb, float alpha, float flag)
 float  drawfill(vector position, vector size, vector rgb, float alpha, float flag)
 
 float  drawpic(vector position, string pic, vector size, vector rgb, float alpha, float flag)
 float  drawfill(vector position, vector size, vector rgb, float alpha, float flag)
 
+
+==============================================================================
+menu cmd list:
+===============
+
+               setkeydest(float dest)
+float  getkeydest
+               setmousetarget(float target)
+float  getmousetarget(void)
 */
 
 #include "quakedef.h"
 */
 
 #include "quakedef.h"
@@ -855,8 +866,8 @@ void VM_find (void)
 =========
 VM_findfloat
 
 =========
 VM_findfloat
 
-  entity       findfloat(entity start, .float field, string match)
-  entity       findentity(entity start, .entity field, string match)
+  entity       findfloat(entity start, .float field, float match)
+  entity       findentity(entity start, .entity field, entity match)
 =========
 */
 // LordHavoc: added this for searching float, int, and entity reference fields
 =========
 */
 // LordHavoc: added this for searching float, int, and entity reference fields
@@ -1090,7 +1101,7 @@ void VM_traceoff (void)
 =========
 VM_eprint
 
 =========
 VM_eprint
 
-eprint(entity float)
+eprint(entity e)
 =========
 */
 void VM_eprint (void)
 =========
 */
 void VM_eprint (void)
@@ -1347,7 +1358,7 @@ VM_randomvec
 
 Returns a vector of length < 1 and > 0
 
 
 Returns a vector of length < 1 and > 0
 
-randomvec()
+vector randomvec()
 =================
 */
 void VM_randomvec (void)
 =================
 */
 void VM_randomvec (void)
@@ -1774,7 +1785,7 @@ void VM_strlen(void)
 =========
 VM_strcat
 
 =========
 VM_strcat
 
-string strcat(string s1, string s2)
+string strcat(string,string,...[string])
 =========
 */
 //string(string s1, string s2) strcat = #115;
 =========
 */
 //string(string s1, string s2) strcat = #115;
@@ -1784,8 +1795,9 @@ void VM_strcat(void)
 {
        char *s;
 
 {
        char *s;
 
-       VM_SAFEPARMCOUNT(2,VM_strcat);
-
+       if(prog->argc <= 2) 
+               PRVM_ERROR("VM_strcat wrong parameter count (min. 2 expected ) !\n");
+       
        s = VM_GetTempString();
        VM_VarString(0, s, STRINGTEMP_LENGTH);
        PRVM_G_INT(OFS_RETURN) = PRVM_SetString(s);
        s = VM_GetTempString();
        VM_VarString(0, s, STRINGTEMP_LENGTH);
        PRVM_G_INT(OFS_RETURN) = PRVM_SetString(s);
@@ -1862,7 +1874,7 @@ void VM_strzone(void)
 =========
 VM_strunzone
 
 =========
 VM_strunzone
 
-strzone(string s)
+strunzone(string s)
 =========
 */
 //void(string s) strunzone = #119; // removes a copy of a string from the string zone (you can not use that string again or it may crash!!!)
 =========
 */
 //void(string s) strunzone = #119; // removes a copy of a string from the string zone (you can not use that string again or it may crash!!!)
@@ -2013,7 +2025,7 @@ void PF_setattachment (void)
 
 /*
 =========
 
 /*
 =========
-VM_serverstate
+VM_isserver
 
 float  isserver()
 =========
 
 float  isserver()
 =========
@@ -2302,6 +2314,23 @@ void VM_drawfill(void)
        PRVM_G_FLOAT(OFS_RETURN) = 1;
 }
 
        PRVM_G_FLOAT(OFS_RETURN) = 1;
 }
 
+/*
+=========
+VM_getmousepos
+
+vector getmousepos()
+=========
+*/
+void VM_getmousepos(void)
+{
+
+       VM_SAFEPARMCOUNT(0,VM_getmousepos);
+       
+       PRVM_G_VECTOR(OFS_RETURN)[0] = in_mouse_x;
+       PRVM_G_VECTOR(OFS_RETURN)[1] = in_mouse_y;
+       PRVM_G_VECTOR(OFS_RETURN)[0] = 0;
+}
+
 void VM_Cmd_Init(void)
 {
        // only init the stuff for the current prog
 void VM_Cmd_Init(void)
 {
        // only init the stuff for the current prog
@@ -2361,7 +2390,56 @@ void VM_CL_Cmd_Reset(void)
 char *vm_m_extensions =
 "";
 
 char *vm_m_extensions =
 "";
 
-// void setkeydest(float dest)
+/*
+=========
+VM_M_setmousetarget
+
+setmousetarget(float target)
+=========
+*/
+void VM_M_setmousetarget(void)
+{
+       VM_SAFEPARMCOUNT(1, VM_M_setmousetarget);
+
+       switch((int)PRVM_G_FLOAT(OFS_PARM0))
+       {
+       case 1:
+               in_client_mouse = false;
+               break;
+       case 2:
+               in_client_mouse = true;
+               break;
+       default:
+               PRVM_ERROR("VM_M_setmousetarget: wrong destination %i !\n",PRVM_G_FLOAT(OFS_PARM0));
+       }
+}
+
+/*
+=========
+VM_M_getmousetarget
+
+float  getmousetarget
+=========
+*/
+void VM_M_getmousetarget(void)
+{
+       VM_SAFEPARMCOUNT(0,VM_M_getmousetarget);
+
+       if(in_client_mouse)
+               PRVM_G_FLOAT(OFS_RETURN) = 2;
+       else
+               PRVM_G_FLOAT(OFS_RETURN) = 1;
+}
+       
+
+
+/*
+=========
+VM_M_setkeydest
+
+setkeydest(float dest)
+=========
+*/
 void VM_M_setkeydest(void)
 {
        VM_SAFEPARMCOUNT(1,VM_M_SetKeyDest);
 void VM_M_setkeydest(void)
 {
        VM_SAFEPARMCOUNT(1,VM_M_SetKeyDest);
@@ -2381,13 +2459,17 @@ void VM_M_setkeydest(void)
                // key_dest = key_message
                // break;
        default:
                // key_dest = key_message
                // break;
        default:
-               PRVM_ERROR("VM_M_SetKeyDest: wrong destination %i !\n",prog->globals[OFS_PARM0]);
+               PRVM_ERROR("VM_M_setkeydest: wrong destination %i !\n",prog->globals[OFS_PARM0]);
        }
        }
-
-       return;
 }
 
 }
 
-// float getkeydest(void)
+/*
+=========
+VM_M_getkeydest
+
+float  getkeydest
+=========
+*/
 void VM_M_getkeydest(void)
 {
        VM_SAFEPARMCOUNT(0,VM_M_GetKeyDest);
 void VM_M_getkeydest(void)
 {
        VM_SAFEPARMCOUNT(0,VM_M_GetKeyDest);
@@ -2470,15 +2552,15 @@ prvm_builtin_t vm_m_builtins[] = {
        VM_stov,
        VM_strzone,
        VM_strunzone,
        VM_stov,
        VM_strzone,
        VM_strunzone,
-       VM_isserver,
-       VM_clientcount,
-       VM_clientstate, // 60
-       VM_clcommand,
        VM_tokenize,
        VM_tokenize,
+       VM_argv,
+       VM_isserver,    // 60
+       VM_clientcount, 
+       VM_clientstate, 
+       VM_clcommand,
        VM_changelevel,
        VM_changelevel,
-       VM_localsound,  // 64
-       0,
-       0,
+       VM_localsound,  
+       VM_getmousepos, // 66
        0,
        0,
        0,
        0,
        0,
        0,
@@ -2519,9 +2601,12 @@ prvm_builtin_t vm_m_builtins[] = {
        e10,                    // 480
        e10,                    // 490
        e10,                    // 500
        e10,                    // 480
        e10,                    // 490
        e10,                    // 500
+       e100,                   // 600
        // menu functions
        VM_M_setkeydest,
        // menu functions
        VM_M_setkeydest,
-       VM_M_getkeydest
+       VM_M_getkeydest,
+       VM_M_setmousetarget,
+       VM_M_getmousetarget
 };
 
 const int vm_m_numbuiltins = sizeof(vm_m_builtins) / sizeof(prvm_builtin_t);
 };
 
 const int vm_m_numbuiltins = sizeof(vm_m_builtins) / sizeof(prvm_builtin_t);
index 6c844d924aff1eb2f38a2ff954f60577066fb539..1a8d0f170cc714bf19f5402779d1b91da93b5177 100644 (file)
@@ -8,6 +8,12 @@ viddef_t vid;
 qboolean isG200 = false; // LordHavoc: the Matrox G200 can't do per pixel alpha, and it uses a D3D driver for GL... ugh...
 qboolean isRagePro = false; // LordHavoc: the ATI Rage Pro has limitations with per pixel alpha (the color scaler does not apply to per pixel alpha images...), although not as bad as a G200.
 
 qboolean isG200 = false; // LordHavoc: the Matrox G200 can't do per pixel alpha, and it uses a D3D driver for GL... ugh...
 qboolean isRagePro = false; // LordHavoc: the ATI Rage Pro has limitations with per pixel alpha (the color scaler does not apply to per pixel alpha images...), although not as bad as a G200.
 
+// AK FIXME -> input_dest
+qboolean in_client_mouse = true;
+
+// AK where should it be placed ?
+float in_mouse_x, in_mouse_y;
+
 // GL_ARB_multitexture
 int gl_textureunits = 0;
 // GL_ARB_texture_env_combine or GL_EXT_texture_env_combine
 // GL_ARB_multitexture
 int gl_textureunits = 0;
 // GL_ARB_texture_env_combine or GL_EXT_texture_env_combine
@@ -533,6 +539,14 @@ void IN_Mouse(usercmd_t *cmd, float mx, float my)
        old_mouse_x = mx;
        old_mouse_y = my;
 
        old_mouse_x = mx;
        old_mouse_y = my;
 
+       in_mouse_x = mouse_x;
+       in_mouse_y = mouse_y;
+
+       // AK: eveything else is client stuff 
+       // BTW, this should be seperated somewhen
+       if(!in_client_mouse) 
+               return;
+
        // LordHavoc: viewzoom affects mouse sensitivity for sniping
        mouse_x *= sensitivity.value * cl.viewzoom;
        mouse_y *= sensitivity.value * cl.viewzoom;
        // LordHavoc: viewzoom affects mouse sensitivity for sniping
        mouse_x *= sensitivity.value * cl.viewzoom;
        mouse_y *= sensitivity.value * cl.viewzoom;