From b203ec61258693fa76622ec7e6ff843c78de13b3 Mon Sep 17 00:00:00 2001 From: black Date: Fri, 17 Oct 2003 14:02:34 +0000 Subject: [PATCH] Updated some builtin parameter lists, added 2 functions to the menu builtins. 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 | 8 +-- fs.c | 95 ++++++++++++++++++++++++++++++++- input.h | 5 ++ keys.c | 13 ++--- prvm_cmds.c | 147 ++++++++++++++++++++++++++++++++++++++++----------- vid_shared.c | 14 +++++ 6 files changed, 236 insertions(+), 46 deletions(-) diff --git a/cl_main.c b/cl_main.c index d6718392..f0104039 100644 --- a/cl_main.c +++ b/cl_main.c @@ -1115,16 +1115,16 @@ void CL_SendCmd(void) { // get basic movement from keyboard CL_BaseMove(&cmd); - + // OS independent code IN_PreMove(); - + // allow mice or other external controllers to add to the move IN_Move(&cmd); - + // OS independent code IN_PostMove(); - + // send the unreliable message CL_SendMove(&cmd); } diff --git a/fs.c b/fs.c index bbdaf2f6..333bf551 100644 --- a/fs.c +++ b/fs.c @@ -982,6 +982,98 @@ qfile_t *FS_FOpenFile (const char *filename, qboolean quiet) 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 ; inumfiles ; 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; @@ -1071,7 +1163,8 @@ qfile_t *FS_FOpenFile (const char *filename, qboolean quiet) return FS_OpenRead (netpath, -1, -1); } } - +#endif + if (!quiet) Sys_Printf ("FindFile: can't find %s\n", filename); diff --git a/input.h b/input.h index 30f76ef5..31a23180 100644 --- 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 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 diff --git a/keys.c b/keys.c index 1e2801e2..ff6ed0e6 100644 --- 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 + // console only wants key down events if (key_consoleactive && consolekeys[key] && down) - { - // console only wants key down events - //if (!down) - // return; - Key_Console (key, ascii); - } 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 && key_dest != key_menu) { kb = keybindings[key]; if (kb) @@ -899,9 +895,6 @@ void Key_Event (int key, char ascii, qboolean down) return; } - if (!down) - return; // other systems only care about key down events - switch (key_dest) { case key_message: diff --git a/prvm_cmds.c b/prvm_cmds.c index 0295b19b..e3610cc7 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -32,11 +32,11 @@ string vtos(vector) string etos(entity) float stof(...[string]) entity spawn() -entity remove() + remove(entity e) 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) @@ -48,7 +48,7 @@ string precache_sound (string sample) coredump() traceon() traceoff() - eprint(entity float) + eprint(entity e) 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) - randomvec() +vector randomvec() 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 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) - 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 tokenize(string s) changelevel(string map) localsound(string sample) - +vector getmousepos() + 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) + +============================================================================== +menu cmd list: +=============== + + setkeydest(float dest) +float getkeydest + setmousetarget(float target) +float getmousetarget(void) */ #include "quakedef.h" @@ -855,8 +866,8 @@ void VM_find (void) ========= 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 @@ -1090,7 +1101,7 @@ void VM_traceoff (void) ========= VM_eprint -eprint(entity float) +eprint(entity e) ========= */ void VM_eprint (void) @@ -1347,7 +1358,7 @@ VM_randomvec Returns a vector of length < 1 and > 0 -randomvec() +vector randomvec() ================= */ void VM_randomvec (void) @@ -1774,7 +1785,7 @@ void VM_strlen(void) ========= VM_strcat -string strcat(string s1, string s2) +string strcat(string,string,...[string]) ========= */ //string(string s1, string s2) strcat = #115; @@ -1784,8 +1795,9 @@ void VM_strcat(void) { 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); @@ -1862,7 +1874,7 @@ void VM_strzone(void) ========= 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!!!) @@ -2013,7 +2025,7 @@ void PF_setattachment (void) /* ========= -VM_serverstate +VM_isserver float isserver() ========= @@ -2302,6 +2314,23 @@ void VM_drawfill(void) 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 @@ -2361,7 +2390,56 @@ void VM_CL_Cmd_Reset(void) 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); @@ -2381,13 +2459,17 @@ void VM_M_setkeydest(void) // 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); @@ -2470,15 +2552,15 @@ prvm_builtin_t vm_m_builtins[] = { VM_stov, VM_strzone, VM_strunzone, - VM_isserver, - VM_clientcount, - VM_clientstate, // 60 - VM_clcommand, VM_tokenize, + VM_argv, + VM_isserver, // 60 + VM_clientcount, + VM_clientstate, + VM_clcommand, VM_changelevel, - VM_localsound, // 64 - 0, - 0, + VM_localsound, + VM_getmousepos, // 66 0, 0, 0, @@ -2519,9 +2601,12 @@ prvm_builtin_t vm_m_builtins[] = { e10, // 480 e10, // 490 e10, // 500 + e100, // 600 // 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); diff --git a/vid_shared.c b/vid_shared.c index 6c844d92..1a8d0f17 100644 --- a/vid_shared.c +++ b/vid_shared.c @@ -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. +// 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 @@ -533,6 +539,14 @@ void IN_Mouse(usercmd_t *cmd, float mx, float 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; -- 2.39.2