Mouse input filtering and some player name length fixes

git-svn-id: https://svn.eduke32.com/eduke32@157 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2006-05-09 04:24:44 +00:00
parent b8820227ed
commit e1fcaa3d40
7 changed files with 191 additions and 146 deletions

View file

@ -40,7 +40,7 @@ Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com)
#include "types.h"
#include "keyboard.h"
#define VERSION " 1.0.4"
#define VERSION " 1.0.5"
short floor_over_floor;

View file

@ -63,6 +63,7 @@ int32 ControllerType;
int32 RunMode;
int32 AutoAim; // JBF 20031125
int32 ShowOpponentWeapons;
int32 MouseFilter;
// JBF 20031211: Store the input settings because
// (currently) jmact can't regurgitate them
@ -231,7 +232,7 @@ void CONFIG_SetDefaults( void )
ud.drawweapon = 1;
ud.democams = 1;
ud.color = 0;
ud.msgdisptime = 640;
ud.msgdisptime = 120;
ud.brightness = 16;
ud.statusbarmode = 0;
ud.autovote = 0;
@ -652,6 +653,7 @@ void CONFIG_ReadSetup( void )
SCRIPT_GetNumber( scripthandle, "Controls","ControllerType",&ControllerType);
SCRIPT_GetNumber( scripthandle, "Controls","MouseAimingFlipped",&ud.mouseflip); // mouse aiming inverted
SCRIPT_GetNumber( scripthandle, "Controls","MouseAiming",&ud.mouseaiming); // 1=momentary/0=toggle
SCRIPT_GetNumber( scripthandle, "Controls","MouseFilter",&MouseFilter); // 1=momentary/0=toggle
//SCRIPT_GetNumber( scripthandle, "Controls","GameMouseAiming",(int32 *)&ps[0].aim_mode); // dupe of below (?)
ps[0].aim_mode = ud.mouseaiming;
SCRIPT_GetNumber( scripthandle, "Controls","AimingFlag",(int32 *)&myaimmode); // (if toggle mode) gives state
@ -710,6 +712,7 @@ void CONFIG_WriteSetup( void )
// SCRIPT_PutNumber( scripthandle, "Controls","GameMouseAiming",(int32) ps[myconnectindex].aim_mode,false,false);
SCRIPT_PutNumber( scripthandle, "Controls", "MouseAimingFlipped",ud.mouseflip,false,false);
SCRIPT_PutNumber( scripthandle, "Controls","MouseAiming",ud.mouseaiming,false,false);
SCRIPT_PutNumber( scripthandle, "Controls","MouseFilter",MouseFilter,false,false);
SCRIPT_PutNumber( scripthandle, "Controls","RunKeyBehaviour",ud.runkey_mode,false,false);
SCRIPT_PutNumber( scripthandle, "Controls","WeaponSwitchMode",ud.weaponswitch,false,false);

View file

@ -45,6 +45,7 @@ extern int32 ReverseStereo;
extern int32 ControllerType;
extern int32 RunMode;
extern int32 AutoAim;
extern int32 MouseFilter;
extern int32 ShowOpponentWeapons;
extern int32 ScreenMode;
extern int32 ScreenWidth;

View file

@ -866,6 +866,8 @@ void faketimerhandler()
//clearbufbyte(&inputfifo[movefifoend[i]&(MOVEFIFOSIZ-1)][i],sizeof(input),0L);
if(ud.playerai)
computergetinput(i,&inputfifo[movefifoend[i]&(MOVEFIFOSIZ-1)][i]);
inputfifo[movefifoend[i]&(MOVEFIFOSIZ-1)][i].svel++;
inputfifo[movefifoend[i]&(MOVEFIFOSIZ-1)][i].fvel++;
movefifoend[i]++;
}
return;
@ -2103,12 +2105,6 @@ void operatefta(void)
j -= 8;
}
for(i=0;i<MAXUSERQUOTES;i++)
if (user_quote_time[i])
{
user_quote_time[i]--;
if (!user_quote_time[i]) pub = NUMPAGES;
}
if ((klabs(quotebotgoal-quotebot) <= 16) && (ud.screen_size <= 8))
quotebot += ksgn(quotebotgoal-quotebot);
else
@ -2996,40 +2992,6 @@ void displayrest(long smoothratio)
rotatesprite((160L-(ps[myconnectindex].look_ang>>1))<<16,100L<<16,ud.crosshair>1?65536L>>(ud.crosshair-1):65536L,0,CROSSHAIR,0,0,2+1,windowx1,windowy1,windowx2,windowy2);
}
if(ud.idplayers && ud.multimode > 1)
{
long sx,sy,sz;
short sect,hw,hs;
for(i=0;i<MAXPLAYERS;i++)
if(ps[i].holoduke_on != -1)
sprite[ps[i].holoduke_on].cstat ^= 256;
hitscan(ps[screenpeek].posx,ps[screenpeek].posy,ps[screenpeek].posz,ps[screenpeek].cursectnum,
sintable[(ps[screenpeek].ang+512)&2047],
sintable[ps[screenpeek].ang&2047],
(100-ps[screenpeek].horiz-ps[screenpeek].horizoff)<<11,&sect,&hw,&hs,&sx,&sy,&sz,0xffff0030);
for(i=0;i<MAXPLAYERS;i++)
if(ps[i].holoduke_on != -1)
sprite[ps[i].holoduke_on].cstat ^= 256;
initprintf("%d\n",sprite[hs].picnum);
if(sprite[hs].picnum == APLAYER && sprite[hs].yvel != screenpeek)
{
if(ps[screenpeek].fta == 0 || ps[screenpeek].ftq == 117)
{
if(ldist(&sprite[ps[screenpeek].i],&sprite[hs]) < 9216)
{
Bsprintf(fta_quotes[117],"%s",&ud.user_name[sprite[hs].yvel][0]);
ps[screenpeek].fta = 12;
ps[screenpeek].ftq = 117;
}
} else ps[screenpeek].fta--;
}
}
if(ps[myconnectindex].gm&MODE_TYPE)
typemode();
else
@ -6047,6 +6009,28 @@ void animatesprites(long x,long y,short a,long smoothratio)
spritesortcnt++;
}
if( ( display_mirror == 1 || screenpeek != p || s->owner == -1 ) && ud.multimode > 1 && sync[p].svel == 0 && sync[p].fvel == 0 && !ud.pause_on)
{
memcpy((spritetype *)&tsprite[spritesortcnt],(spritetype *)t,sizeof(spritetype));
tsprite[spritesortcnt].statnum = 99;
tsprite[spritesortcnt].yrepeat = ( t->yrepeat>>3 );
if(t->yrepeat < 4) t->yrepeat = 4;
tsprite[spritesortcnt].cstat = 0;
tsprite[spritesortcnt].picnum = RESPAWNMARKERGREEN;
if(s->owner >= 0)
tsprite[spritesortcnt].z = ps[p].posz-(20<<8);
else tsprite[spritesortcnt].z = s->z-(96<<8);
tsprite[spritesortcnt].xrepeat = 16;
tsprite[spritesortcnt].yrepeat = 16;
tsprite[spritesortcnt].pal = 20;
spritesortcnt++;
}
if(s->owner == -1)
{
if (bpp > 8 && usemodels && md_tilehasmodel(s->picnum) >= 0) {
@ -8484,8 +8468,15 @@ void Startup(void)
if (CommandName)
{
Bstrncpy(myname, CommandName, 9);
myname[10] = '\0';
// Bstrncpy(myname, CommandName, 9);
// myname[10] = '\0';
Bstrcpy(tempbuf,CommandName);
while(Bstrlen(strip_color_codes(tempbuf)) > 10)
tempbuf[Bstrlen(tempbuf)-1] = '\0';
Bstrncpy(myname,tempbuf,sizeof(myname)-1);
myname[sizeof(myname)] = '\0';
}
if (CommandMap) {
@ -10072,6 +10063,45 @@ char domovethings(void)
if(earthquaketime > 0) earthquaketime--;
if(rtsplaying > 0) rtsplaying--;
for(i=0;i<MAXUSERQUOTES;i++)
if (user_quote_time[i])
{
user_quote_time[i]--;
if (!user_quote_time[i]) pub = NUMPAGES;
}
if(ud.idplayers && ud.multimode > 1)
{
long sx,sy,sz;
short sect,hw,hs;
for(i=0;i<MAXPLAYERS;i++)
if(ps[i].holoduke_on != -1)
sprite[ps[i].holoduke_on].cstat ^= 256;
hitscan(ps[screenpeek].posx,ps[screenpeek].posy,ps[screenpeek].posz,ps[screenpeek].cursectnum,
sintable[(ps[screenpeek].ang+512)&2047],
sintable[ps[screenpeek].ang&2047],
(100-ps[screenpeek].horiz-ps[screenpeek].horizoff)<<11,&sect,&hw,&hs,&sx,&sy,&sz,0xffff0030);
for(i=0;i<MAXPLAYERS;i++)
if(ps[i].holoduke_on != -1)
sprite[ps[i].holoduke_on].cstat ^= 256;
if(sprite[hs].picnum == APLAYER && sprite[hs].yvel != screenpeek && ps[sprite[hs].yvel].dead_flag == 0)
{
if(ps[screenpeek].fta == 0 || ps[screenpeek].ftq == 117)
{
if(ldist(&sprite[ps[screenpeek].i],&sprite[hs]) < 9216)
{
Bsprintf(fta_quotes[117],"%s",&ud.user_name[sprite[hs].yvel][0]);
ps[screenpeek].fta = 12;
ps[screenpeek].ftq = 117;
}
} else if(ps[screenpeek].fta > 2) ps[screenpeek].fta -= 3;
}
}
if( show_shareware > 0 )
{
show_shareware--;

View file

@ -710,7 +710,7 @@ void menus(void)
} else {
x = strget(200,50-9,buf,30,0);
while(Bstrlen(strip_color_codes(buf)) > 9)
while(Bstrlen(strip_color_codes(buf)) > 10)
{
buf[Bstrlen(buf)-1] = '\0';
inputloc--;
@ -719,11 +719,6 @@ void menus(void)
if (x) {
if (x == 1) {
if(buf[0]) {
if(Bstrlen(strip_color_codes(buf)) > 9)
{
Bstrncpy(buf,strip_color_codes(buf),9);
buf[10] = '\0';
}
Bstrcpy(myname,buf);
}
// send name update
@ -2932,7 +2927,7 @@ cheat_for_port_credits:
probey = whichkey;
} else if (function == 1) { // mouse digital axis
cmenu(212);
probey = 2+(whichkey^2);
probey = 3+(whichkey^2);
} else if (function == 2) { // joystick button/hat
cmenu(207);
probey = whichkey;
@ -3032,14 +3027,14 @@ cheat_for_port_credits:
c = (320>>1)-120;
onbar = (probey == 0 || probey == 1);
if (probey < 2)
x = probe(c,46,16,6);
else if (probey < 6) {
onbar = (probey == 0 || probey == 1 || probey == 2);
if (probey < 3)
x = probe(c,46,16,7);
else if (probey < 7) {
m=50;
x = probesm(c+10,96-(10+10),10,6);
x = probesm(c+10,96+16-(10+10+10),10,7);
} else {
x = probe(c,146-(16+16+16+16+16+16),16,6);
x = probe(c,146+16-(16+16+16+16+16+16),16,7);
}
switch (x) {
@ -3052,37 +3047,24 @@ cheat_for_port_credits:
// x-axis scale
case 1:
// y-axis scale
case 2:
// mouse filter
break;
case 2:
// digital up
case 3:
// digital down
// digital up
case 4:
// digital left
// digital down
case 5:
// digital left
case 6:
// digital right
function = 1;
whichkey = (x-2)^2; // flip the actual axis number
whichkey = (x-3)^2; // flip the actual axis number
cmenu(211);
probey = MouseDigitalFunctions[whichkey>>1][whichkey&1];
if (probey < 0) probey = NUMGAMEFUNCTIONS-1;
break;
case 6:
// analogue x
case 7:
// analogue y
l = MouseAnalogueAxes[x-6];
if (l == analog_turning) l = analog_strafing;
else if (l == analog_strafing) l = analog_lookingupanddown;
else if (l == analog_lookingupanddown) l = analog_moving;
else if (l == analog_moving) l = -1;
else l = analog_turning;
MouseAnalogueAxes[x-6] = l;
CONTROL_MapAnalogAxis(x-6,l,controldevice_mouse);
break;
}
menutext(c,46,MENUHIGHLIGHT(0),0,"X-AXIS SCALE");
@ -3107,64 +3089,47 @@ cheat_for_port_credits:
Bsprintf(tempbuf,"%s%.2f",l>=0?" ":"",(float)l/65536.0);
gametext(c+160-16,46+16-8,tempbuf,MENUHIGHLIGHT(1),2+8+16);
menutext(c,46+16+16+8,0,0,"DIGITAL AXES ACTIONS");
menutext(c,46+16+16,MENUHIGHLIGHT(2),0,"INPUT FILTER");
bar(c+160+40,46+16+16,(short *)&MouseFilter,4,x==2,MENUHIGHLIGHT(2),0);
gametext(c+10,90,"UP:",MENUHIGHLIGHT(2),2+8+16);
menutext(c,46+16+16+16+8,(MENUHIGHLIGHT(3))+(MENUHIGHLIGHT(4))+(MENUHIGHLIGHT(5))+(MENUHIGHLIGHT(6))-24,0,"DIGITAL AXES ACTIONS");
gametext(c+10,90+16,"UP:",MENUHIGHLIGHT(3),2+8+16);
if (MouseDigitalFunctions[1][0] < 0)
strcpy(tempbuf, " -NONE-");
else
strcpy(tempbuf, CONFIG_FunctionNumToName(MouseDigitalFunctions[1][0]));
for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' ';
minitext(c+10+60,91,tempbuf,0,10+16);
minitext(c+10+60,91+16,tempbuf,0,10+16);
gametext(c+10,90+10,"DOWN:",MENUHIGHLIGHT(3),2+8+16);
gametext(c+10,90+16+10,"DOWN:",MENUHIGHLIGHT(4),2+8+16);
if (MouseDigitalFunctions[1][1] < 0)
strcpy(tempbuf, " -NONE-");
else
strcpy(tempbuf, CONFIG_FunctionNumToName(MouseDigitalFunctions[1][1]));
for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' ';
minitext(c+10+60,91+10,tempbuf,0,10+16);
minitext(c+10+60,91+16+10,tempbuf,0,10+16);
gametext(c+10,90+10+10,"LEFT:",MENUHIGHLIGHT(4),2+8+16);
gametext(c+10,90+16+10+10,"LEFT:",MENUHIGHLIGHT(5),2+8+16);
if (MouseDigitalFunctions[0][0] < 0)
strcpy(tempbuf, " -NONE-");
else
strcpy(tempbuf, CONFIG_FunctionNumToName(MouseDigitalFunctions[0][0]));
for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' ';
minitext(c+10+60,91+10+10,tempbuf,0,10+16);
minitext(c+10+60,91+16+10+10,tempbuf,0,10+16);
gametext(c+10,90+10+10+10,"RIGHT:",MENUHIGHLIGHT(5),2+8+16);
gametext(c+10,90+16+10+10+10,"RIGHT:",MENUHIGHLIGHT(6),2+8+16);
if (MouseDigitalFunctions[0][1] < 0)
strcpy(tempbuf, " -NONE-");
else
strcpy(tempbuf, CONFIG_FunctionNumToName(MouseDigitalFunctions[0][1]));
for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' ';
minitext(c+10+60,91+10+10+10,tempbuf,0,10+16);
minitext(c+10+60,91+16+10+10+10,tempbuf,0,10+16);
/* JBF 20040107: It would appear giving these options confuses some tinkerers, so they've
* been moved to the bottom, and hidden in case I dare to reenable them again.
menutext(c,116+16+8,0,0,"ANALOG X");
if (CONFIG_AnalogNumToName( MouseAnalogueAxes[0] )) {
p = CONFIG_AnalogNumToName( MouseAnalogueAxes[0] );
if (p) {
gametext(c+148+4,118+16, strchr(p,'_')+1, 0, 2+8+16 );
}
}
if (probey == 6) gametext(160,158,"Default is \"turning\"",8,2+8+16);
menutext(c,116+16+16+8,0,0,"ANALOG Y");
if (CONFIG_AnalogNumToName( MouseAnalogueAxes[1] )) {
p = CONFIG_AnalogNumToName( MouseAnalogueAxes[1] );
if (p) {
gametext(c+148+4,118+16+16, strchr(p,'_')+1, 0, 2+8+16 );
}
}
if (probey == 7) gametext(160,158,"Default is \"moving\"",8,2+8+16);
*/
break;
case 206:

View file

@ -435,7 +435,6 @@ struct cvarmappings {
} cvar[] =
{
{ "crosshair", "crosshair: enable/disable crosshair", (void*)&ud.crosshair, CVAR_INT, 0, 0, 3 },
{ "name", "name: change your multiplayer nickname", (void*)&myname[0], CVAR_STRING|256, 11, 0, 0 },
{ "cl_autoaim", "cl_autoaim: enable/disable weapon autoaim", (void*)&AutoAim, CVAR_INT|256, 0, 0, 2 },
{ "cl_automsg", "cl_automsg: enable/disable automatically sending messages to all players", (void*)&ud.automsg, CVAR_BOOL, 0, 0, 1 },
@ -448,6 +447,8 @@ struct cvarmappings {
{ "cl_messagetime", "cl_messagetime: length of time to display multiplayer chat messages\n", (void*)&ud.msgdisptime, CVAR_INT, 0, 0, 3600 },
{ "cl_mousefilter", "cl_mousefilter: amount of mouse movement to filter out\n", (void*)&MouseFilter, CVAR_INT, 0, 0, 512 },
{ "cl_showcoords", "cl_showcoords: show your position in the game world", (void*)&ud.coords, CVAR_BOOL, 0, 0, 1 },
{ "cl_showfps", "cl_showfps: show the frame rate counter", (void*)&ud.tickrate, CVAR_BOOL, 0, 0, 1 },
@ -621,6 +622,29 @@ int osdcmd_mpmap(const osdfuncparm_t *parm)
return OSDCMD_OK;
}
int osdcmd_name(const osdfuncparm_t *parm)
{
if (parm->numparms != 1)
{
OSD_Printf("\"name\" is \"%s\"\n",myname);
return OSDCMD_SHOWHELP;
}
Bstrcpy(tempbuf,parm->parms[0]);
while(Bstrlen(strip_color_codes(tempbuf)) > 10)
tempbuf[Bstrlen(tempbuf)-1] = '\0';
Bstrncpy(myname,tempbuf,sizeof(myname)-1);
myname[sizeof(myname)] = '\0';
OSD_Printf("name %s\n",myname);
updatenames();
return OSDCMD_OK;
}
int registerosdcommands(void)
{
unsigned int i;
@ -645,6 +669,7 @@ int registerosdcommands(void)
OSD_RegisterFunction("god","god: toggles god mode", osdcmd_god);
OSD_RegisterFunction("gamma","gamma <value>: changes brightness", osdcmd_gamma);
OSD_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", osdcmd_give);
OSD_RegisterFunction("name","name: change your multiplayer nickname", osdcmd_name);
OSD_RegisterFunction("noclip","noclip: toggles clipping mode", osdcmd_noclip);
OSD_RegisterFunction("cl_statusbarscale","cl_statusbarscale: changes the status bar scale", osdcmd_setstatusbarscale);
@ -657,12 +682,6 @@ int registerosdcommands(void)
OSD_RegisterFunction("fileinfo","fileinfo <file>: gets a file's information", osdcmd_fileinfo);
OSD_RegisterFunction("quit","quit: exits the game immediately", osdcmd_quit);
/* OSD_RegisterFunction("myname","myname: change your multiplayer nickname", osdcmd_vars);
OSD_RegisterFunction("showfps","showfps: show the frame rate counter", osdcmd_vars);
OSD_RegisterFunction("showcoords","showcoords: show your position in the game world", osdcmd_vars);
OSD_RegisterFunction("useprecache","useprecache: enable/disable the pre-level caching routine", osdcmd_vars);
OSD_RegisterFunction("drawweapon","drawweapon: enable/disable weapon drawing", osdcmd_vars); */
OSD_RegisterFunction("restartvid","restartvid: reinitialised the video mode",osdcmd_restartvid);
OSD_RegisterFunction("vidmode","vidmode [xdim ydim] [bpp] [fullscreen]: immediately change the video mode",osdcmd_vidmode);

View file

@ -2705,6 +2705,30 @@ void getinput(short snum)
CONTROL_GetInput( &info );
if(MouseFilter)
{
if(info.dz > 0)
{
info.dz -= MouseFilter;
if(info.dz < 0) info.dz = 0;
}
else if(info.dz < 0)
{
info.dz += MouseFilter;
if(info.dz > 0) info.dz = 0;
}
if(info.dyaw > 0)
{
info.dyaw -= MouseFilter;
if(info.dyaw < 0) info.dyaw = 0;
}
else if(info.dyaw < 0)
{
info.dyaw += MouseFilter;
if(info.dyaw > 0) info.dyaw = 0;
}
}
if( (p->gm&MODE_MENU) || (p->gm&MODE_TYPE) || (ud.pause_on && !KB_KeyPressed(sc_Pause)) )
{
loc.fvel = vel = 0;
@ -3462,41 +3486,42 @@ void processinput(short snum)
FTA(116,&ps[p->frag_ps]);
}
if(gametype_flags[ud.coop] & GAMETYPE_FLAG_PLAYERSFRIENDLY)
i = 9;
else
{
switch(dynamictostatic[hittype[p->i].picnum]) {
case KNEE__STATIC:
if(hittype[p->i].temp_data[1] == 1)
i = 7;
else i = 0;
break;
case SHOTSPARK1__STATIC:
switch(ps[p->frag_ps].curr_weapon)
{
default:
case PISTOL_WEAPON:
i = 1;
break;
case SHOTGUN_WEAPON:
i = 2;
break;
case CHAINGUN_WEAPON:
i = 3;
break;
}
break;
case RPG__STATIC: i = 4; break;
case RADIUSEXPLOSION__STATIC: i = 5; break;
case SHRINKSPARK__STATIC: i = 6; break;
case GROWSPARK__STATIC: i = 8; break;
default: i = 0; break;
}
}
{
char name1[32],name2[32];
if(gametype_flags[ud.coop] & GAMETYPE_FLAG_PLAYERSFRIENDLY)
i = 9;
else
{
switch(dynamictostatic[hittype[p->i].picnum])
{
case KNEE__STATIC:
if(hittype[p->i].temp_data[1] == 1)
i = 7;
else i = 0;
break;
case SHOTSPARK1__STATIC:
switch(ps[p->frag_ps].curr_weapon)
{
default:
case PISTOL_WEAPON:
i = 1;
break;
case SHOTGUN_WEAPON:
i = 2;
break;
case CHAINGUN_WEAPON:
i = 3;
break;
}
break;
case RPG__STATIC: i = 4; break;
case RADIUSEXPLOSION__STATIC: i = 5; break;
case SHRINKSPARK__STATIC: i = 6; break;
case GROWSPARK__STATIC: i = 8; break;
default: i = 0; break;
}
}
Bstrcpy(name1,strip_color_codes(&ud.user_name[snum][0]));
Bstrcpy(name2,strip_color_codes(&ud.user_name[p->frag_ps][0]));
@ -3517,7 +3542,9 @@ void processinput(short snum)
else i = 0;
Bsprintf(tempbuf,fta_quotes[16350+i],strip_color_codes(&ud.user_name[snum][0]));
adduserquote(tempbuf);
if(ScreenWidth >= 640)
adduserquote(tempbuf);
else OSD_Printf("%s\n",strip_color_codes(tempbuf));
}
if(myconnectindex == connecthead)