Added per-player userinfos (for splitscreen).

Enabled cheats in single player by default.
Added a 'sky' alias to wrap r_skybox.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3583 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2010-08-14 03:17:33 +00:00
parent 2cad75bc69
commit f535baa59f
22 changed files with 291 additions and 121 deletions

View File

@ -2660,7 +2660,6 @@ void CL_LinkPlayers (void)
frame_t *fromf;
int oldphysent;
vec3_t angles;
float *org;
qboolean predictplayers;
model_t *model;
@ -2748,7 +2747,6 @@ void CL_LinkPlayers (void)
if (radius)
{
vec3_t org;
int i;
VectorCopy(state->origin, org);
for (pnum = 0; pnum < cl.splitclients; pnum++)
VectorCopy(cl.simorg[pnum], org);

View File

@ -48,12 +48,18 @@ vec3_t mousemovements[MAX_SPLITS];
/*kinda a hack...*/
int con_splitmodifier;
cvar_t cl_defaultsplitclient = CVAR("cl_defaultsplitclient", "0");
int CL_TargettedSplit(void)
cvar_t cl_forcesplitclient = CVAR("cl_forcesplitclient", "0");
extern cvar_t cl_splitscreen;
int CL_TargettedSplit(qboolean nowrap)
{
char *c;
int pnum;
if (!cl.splitclients)
int mod;
if (nowrap)
mod = MAX_SPLITS;
else
mod = cl.splitclients;
if (mod < 1)
return 0;
c = Cmd_Argv(0);
pnum = atoi(c+strlen(c)-1);
@ -64,9 +70,9 @@ int CL_TargettedSplit(void)
}
if (con_splitmodifier > 0)
return (con_splitmodifier - 1)% cl.splitclients;
else if (cl_defaultsplitclient.ival > 0)
return cl_defaultsplitclient.ival % cl.splitclients;
return (con_splitmodifier - 1) % mod;
else if (cl_forcesplitclient.ival > 0)
return (cl_forcesplitclient.ival-1) % mod;
else
return 0;
}
@ -137,7 +143,7 @@ void KeyDown (kbutton_t *b)
int k;
char *c;
int pnum = CL_TargettedSplit();
int pnum = CL_TargettedSplit(false);
c = Cmd_Argv(1);
if (c[0])
@ -168,7 +174,7 @@ void KeyUp (kbutton_t *b)
int k;
char *c;
int pnum = CL_TargettedSplit();
int pnum = CL_TargettedSplit(false);
c = Cmd_Argv(1);
if (c[0])
@ -200,7 +206,7 @@ void IN_KLookUp (void) {KeyUp(&in_klook);}
void IN_MLookDown (void) {KeyDown(&in_mlook);}
void IN_MLookUp (void)
{
int pnum = CL_TargettedSplit();
int pnum = CL_TargettedSplit(false);
KeyUp(&in_mlook);
if ( !(in_mlook.state[pnum]&1) && lookspring.ival)
V_StartPitchDrift(pnum);
@ -241,7 +247,7 @@ void IN_JumpDown (void)
qboolean condition;
int pnum = CL_TargettedSplit();
int pnum = CL_TargettedSplit(false);
@ -293,14 +299,7 @@ void IN_Impulse (void)
{
int newimp;
int best, i, imp, items;
char *c;
int pnum;
c = Cmd_Argv(0);
pnum = atoi(c+strlen(c)-1);
if (pnum)pnum--;
int pnum = CL_TargettedSplit(false);
newimp = Q_atoi(Cmd_Argv(1));
@ -1278,7 +1277,7 @@ qboolean CL_SendCmdQ2 (sizebuf_t *buf)
if (cls.resendinfo)
{
MSG_WriteByte (&cls.netchan.message, clcq2_userinfo);
MSG_WriteString (&cls.netchan.message, cls.userinfo);
MSG_WriteString (&cls.netchan.message, cls.userinfo[0]);
cls.resendinfo = false;
}
@ -1841,7 +1840,7 @@ void CL_InitInput (void)
Cvar_Register (&cl_prydoncursor, inputnetworkcvargroup);
Cvar_Register (&cl_instantrotate, inputnetworkcvargroup);
Cvar_Register (&cl_defaultsplitclient, inputnetworkcvargroup);
Cvar_Register (&cl_forcesplitclient, inputnetworkcvargroup);
for (sp = 0; sp < MAX_SPLITS; sp++)
{

View File

@ -425,7 +425,6 @@ void CL_SendConnectPacket (
extern cvar_t qport;
netadr_t adr;
char data[2048];
char playerinfo2[MAX_INFO_STRING];
double t1, t2;
#ifdef PROTOCOL_VERSION_FTE
int fteprotextsupported=0;
@ -493,9 +492,6 @@ void CL_SendConnectPacket (
// Info_SetValueForStarKey (cls.userinfo, "*ip", NET_AdrToString(adr), MAX_INFO_STRING);
Q_strncpyz(playerinfo2, cls.userinfo, sizeof(playerinfo2)-1);
Info_SetValueForStarKey (playerinfo2, "name", "Second player", MAX_INFO_STRING);
clients = 1;
if (cl_splitscreen.value && (fteprotextsupported & PEXT_SPLITSCREEN))
{
@ -542,11 +538,10 @@ void CL_SendConnectPacket (
if (cls.protocol == CP_QUAKEWORLD)
Q_strncatz(data, va(" \"%s\\*z_ext\\%i\"", cls.userinfo, SUPPORTED_Z_EXTENSIONS), sizeof(data));
else
Q_strncatz(data, va(" \"%s\"", cls.userinfo), sizeof(data));
Q_strncatz(data, va(" \"%s\"", cls.userinfo[0]), sizeof(data));
for (c = 1; c < clients; c++)
{
Info_SetValueForStarKey (playerinfo2, "name", va("%s%i", name.string, c+1), MAX_INFO_STRING);
Q_strncatz(data, va(" \"%s\"", playerinfo2), sizeof(data));
Q_strncatz(data, va(" \"%s\"", cls.userinfo[c]), sizeof(data));
}
Q_strncatz(data, "\n", sizeof(data));
@ -1331,14 +1326,15 @@ void CL_Color_f (void)
// just for quake compatability...
int top, bottom;
char num[16];
int pnum = CL_TargettedSplit(true);
qboolean server_owns_colour;
if (Cmd_Argc() == 1)
{
Con_TPrintf (TLC_COLOURCURRENT,
Info_ValueForKey (cls.userinfo, "topcolor"),
Info_ValueForKey (cls.userinfo, "bottomcolor") );
Info_ValueForKey (cls.userinfo[pnum], "topcolor"),
Info_ValueForKey (cls.userinfo[pnum], "bottomcolor") );
Con_TPrintf (TLC_SYNTAX_COLOUR);
return;
}
@ -1603,6 +1599,7 @@ void CL_FullInfo_f (void)
char value[512];
char *o;
char *s;
int pnum = CL_TargettedSplit(true);
if (Cmd_Argc() != 2)
{
@ -1638,29 +1635,37 @@ void CL_FullInfo_f (void)
if (!stricmp(key, pmodel_name) || !stricmp(key, emodel_name))
continue;
Info_SetValueForKey (cls.userinfo, key, value, sizeof(cls.userinfo));
Info_SetValueForKey (cls.userinfo[pnum], key, value, sizeof(cls.userinfo[pnum]));
}
}
void CL_SetInfo (char *key, char *value)
void CL_SetInfo (int pnum, char *key, char *value)
{
cvar_t *var;
var = Cvar_FindVar(key);
if (var && (var->flags & CVAR_USERINFO))
{ //get the cvar code to set it. the server might have locked it.
Cvar_Set(var, value);
return;
if (!pnum)
{
var = Cvar_FindVar(key);
if (var && (var->flags & CVAR_USERINFO))
{ //get the cvar code to set it. the server might have locked it.
Cvar_Set(var, value);
return;
}
}
Info_SetValueForStarKey (cls.userinfo, key, value, sizeof(cls.userinfo));
if (cls.state >= ca_connected)
Info_SetValueForStarKey (cls.userinfo[pnum], key, value, sizeof(cls.userinfo[pnum]));
if (cls.state >= ca_connected && !cls.demoplayback)
{
#ifdef Q2CLIENT
if (cls.protocol == CP_QUAKE2 || cls.protocol == CP_QUAKE3)
cls.resendinfo = true;
else
#endif
Cmd_ForwardToServer ();
{
if (pnum)
CL_SendClientCommand(true, "%i setinfo %s %s", pnum+1, key, value);
else
CL_SendClientCommand(true, "setinfo %s %s", key, value);
}
}
}
/*
@ -1673,9 +1678,10 @@ Allow clients to change userinfo
void CL_SetInfo_f (void)
{
cvar_t *var;
int pnum = CL_TargettedSplit(true);
if (Cmd_Argc() == 1)
{
Info_Print (cls.userinfo);
Info_Print (cls.userinfo[pnum]);
return;
}
if (Cmd_Argc() != 3)
@ -1695,7 +1701,7 @@ void CL_SetInfo_f (void)
char *k;
for(i=0;;)
{
k = Info_KeyForNumber(cls.userinfo, i);
k = Info_KeyForNumber(cls.userinfo[pnum], i);
if (!*k)
break; //no more.
else if (*k == '*')
@ -1703,7 +1709,7 @@ void CL_SetInfo_f (void)
else if ((var = Cvar_FindVar(k)) && var->flags&CVAR_USERINFO)
i++; //this one is a cvar.
else
Info_RemoveKey(cls.userinfo, k); //we can remove this one though, so yay.
Info_RemoveKey(cls.userinfo[pnum], k); //we can remove this one though, so yay.
}
return;
@ -1713,14 +1719,21 @@ void CL_SetInfo_f (void)
}
CL_SetInfo(Cmd_Argv(1), Cmd_Argv(2));
CL_SetInfo(pnum, Cmd_Argv(1), Cmd_Argv(2));
}
void CL_SaveInfo(vfsfile_t *f)
{
int i;
VFS_WRITE(f, "\n", 1);
VFS_WRITE(f, "setinfo * \"\"\n", 13);
Info_WriteToFile(f, cls.userinfo, "setinfo", CVAR_USERINFO);
for (i = 0; i < MAX_SPLITS; i++)
{
if (i)
VFS_WRITE(f, va("p%i setinfo * \"\"\n", i+1), 16);
else
VFS_WRITE(f, "setinfo * \"\"\n", 13);
Info_WriteToFile(f, cls.userinfo[i], "setinfo", CVAR_USERINFO);
}
}
/*
@ -2888,7 +2901,10 @@ void CL_Init (void)
cls.state = ca_disconnected;
sprintf (st, "%s %i", DISTRIBUTION, build_number());
Info_SetValueForStarKey (cls.userinfo, "*ver", st, sizeof(cls.userinfo));
Info_SetValueForStarKey (cls.userinfo[0], "*ver", st, sizeof(cls.userinfo[0]));
Info_SetValueForStarKey (cls.userinfo[1], "*ss", "1", sizeof(cls.userinfo[1]));
Info_SetValueForStarKey (cls.userinfo[2], "*ss", "1", sizeof(cls.userinfo[2]));
Info_SetValueForStarKey (cls.userinfo[3], "*ss", "1", sizeof(cls.userinfo[3]));
InitValidation();

View File

@ -415,7 +415,7 @@ qintptr_t VARGS Plug_SetUserInfo(void *offset, quintptr_t mask, const qintptr_t
char *key = VM_POINTER(arg[0]);
char *value = VM_POINTER(arg[1]);
CL_SetInfo(key, value);
CL_SetInfo(0, key, value);
return true;
}

View File

@ -358,7 +358,7 @@ typedef struct
float lastarbiatarypackettime; //used to mark when packets were sent to prevent mvdsv servers from causing us to disconnect.
// private userinfo for sending to masterless servers
char userinfo[EXTENDED_INFO_STRING];
char userinfo[MAX_SPLITS][EXTENDED_INFO_STRING];
char servername[MAX_OSPATH]; // name of server from original connect
@ -768,7 +768,7 @@ void CL_Reconnect_f (void);
void CL_ConnectionlessPacket (void);
qboolean CL_DemoBehind(void);
void CL_SaveInfo(vfsfile_t *f);
void CL_SetInfo (char *key, char *value);
void CL_SetInfo (int pnum, char *key, char *value);
void CL_BeginServerConnect(void);
void CLNQ_BeginServerConnect(void);

View File

@ -62,6 +62,7 @@ cvar_t m_accel_noforce = SCVAR("m_accel_noforce", "0");
cvar_t m_threshold_noforce = SCVAR("m_threshold_noforce", "0");
cvar_t cl_keypad = SCVAR("cl_keypad", "0");
extern cvar_t cl_forcesplitclient;
qboolean Key_MouseShouldBeFree(void);
@ -1424,7 +1425,10 @@ static void ProcessMouse(mouse_t *mouse, float *movements, int pnum)
wpnum = cl.splitclients;
if (wpnum < 1)
wpnum = 1;
wpnum = mouse->playerid % wpnum;
if (cl_forcesplitclient.ival)
wpnum = (cl_forcesplitclient.ival-1) % wpnum;
else
wpnum = mouse->playerid % wpnum;
if (wpnum != pnum)
return;
@ -1857,7 +1861,10 @@ void IN_RawInput_MouseRead(HANDLE in_device_handle)
pnum = cl.splitclients;
if (pnum < 1)
pnum = 1;
pnum = rawmice[i].playerid % pnum;
if (cl_forcesplitclient.ival)
pnum = (cl_forcesplitclient.ival-1) % pnum;
else
pnum = rawmice[i].playerid % pnum;
// movement
if (raw->data.mouse.usFlags & MOUSE_MOVE_ABSOLUTE)

View File

@ -44,3 +44,5 @@ extern cvar_t in_xflip;
void IN_ActivateMouse(void);
void IN_DeactivateMouse(void);
#endif
int CL_TargettedSplit(qboolean nowrap);

View File

@ -549,6 +549,7 @@ void Renderer_Init(void)
Cvar_Register (&vid_desktopsettings, VIDCOMMANDGROUP);
Cvar_Register (&r_skyboxname, GRAPHICALNICETIES);
Cbuf_AddText("alias sky r_skybox\n", RESTRICT_LOCAL); /*alternative name for users*/
Cvar_Register(&r_dodgytgafiles, "Bug fixes");
Cvar_Register(&r_dodgypcxfiles, "Bug fixes");

View File

@ -22,9 +22,9 @@ void Mod_DoCRC(model_t *mod, char *buffer, int buffersize)
QCRC_ProcessByte(&crc, *p);
sprintf(st, "%d", (int) crc);
Info_SetValueForKey (cls.userinfo,
Info_SetValueForKey (cls.userinfo[0],
(loadmodel->engineflags & MDLF_PLAYER) ? pmodel_name : emodel_name,
st, sizeof(cls.userinfo));
st, sizeof(cls.userinfo[0]));
if (cls.state >= ca_connected)
{

View File

@ -670,10 +670,10 @@ cvar_t *Cvar_SetCore (cvar_t *var, const char *value, qboolean force)
}
if (var->flags & CVAR_USERINFO)
{
char *old = Info_ValueForKey(cls.userinfo, var->name);
char *old = Info_ValueForKey(cls.userinfo[0], var->name);
if (strcmp(old, value)) //only spam the server if it actually changed
{ //this helps with config execs
Info_SetValueForKey (cls.userinfo, var->name, value, sizeof(cls.userinfo));
Info_SetValueForKey (cls.userinfo[0], var->name, value, sizeof(cls.userinfo[0]));
if (cls.state >= ca_connected)
{
#ifdef Q2CLIENT

View File

@ -359,7 +359,7 @@ void PF_precache_sound_Internal (progfuncs_t *prinst, char *s);
int PF_precache_model_Internal (progfuncs_t *prinst, char *s);
void PF_setmodel_Internal (progfuncs_t *prinst, edict_t *e, char *m);
char *PF_infokey_Internal (int entnum, char *value);
void PF_centerprint_Internal (int entnum, char *s);
void PF_centerprint_Internal (int entnum, qboolean plaque, char *s);
void PF_WriteString_Internal (int target, char *str);
pbool ED_CanFree (edict_t *ed);
#endif

View File

@ -463,7 +463,7 @@ BSC32=bscmake.exe
LINK32=link.exe
# ADD BASE LINK32 comctl32.lib wsock32.lib winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /map /debug /machine:I386 /nodefaultlib:"msvcrt.lib" /out:"../../fteglqwvc6.exe" /libpath:"../libs/dxsdk7/lib"
# SUBTRACT BASE LINK32 /pdb:none
# ADD LINK32 comctl32.lib wsock32.lib winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib sdl.lib sdlmain.lib /nologo /subsystem:windows /map /debug /machine:I386 /nodefaultlib:"libcmt" /out:"../../fteglqw_sdl.exe" /libpath:"../libs/dxsdk7/lib"
# ADD LINK32 comctl32.lib wsock32.lib winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib sdl.lib sdlmain.lib /nologo /subsystem:windows /map /debug /machine:I386 /nodefaultlib:"libcmt" /out:"../../fteglqw_sdl.exe" /libpath:"../libs/dxsdk7/lib"
# SUBTRACT LINK32 /pdb:none
!ENDIF
@ -1593,6 +1593,67 @@ SOURCE=..\client\image.c
# Begin Source File
SOURCE=..\client\in_sdl.c
!IF "$(CFG)" == "ftequake - Win32 Release"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 Debug"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 GLDebug"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 GLRelease"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 MDebug"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 MRelease"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 MinGLDebug"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 MinGLRelease"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 Debug Dedicated Server"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 Release Dedicated Server"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 MinSW"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 GLDebugQ3"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 Debug Dedicated ServerQ3"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 D3DDebug"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 GLSDLDebug"
!ENDIF
# End Source File
# Begin Source File
@ -4541,6 +4602,67 @@ SOURCE=..\gl\gl_vidnt.c
# Begin Source File
SOURCE=..\gl\gl_vidsdl.c
!IF "$(CFG)" == "ftequake - Win32 Release"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 Debug"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 GLDebug"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 GLRelease"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 MDebug"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 MRelease"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 MinGLDebug"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 MinGLRelease"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 Debug Dedicated Server"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 Release Dedicated Server"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 MinSW"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 GLDebugQ3"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 Debug Dedicated ServerQ3"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 D3DDebug"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 GLSDLDebug"
!ENDIF
# End Source File
# Begin Source File

View File

@ -107,9 +107,9 @@ qboolean Mod_LoadHLModel (model_t *mod, void *buffer)
QCRC_ProcessByte(&crc, *p);
sprintf(st, "%d", (int) crc);
Info_SetValueForKey (cls.userinfo,
Info_SetValueForKey (cls.userinfo[0],
(mod->engineflags & MDLF_PLAYER) ? pmodel_name : emodel_name,
st, sizeof(cls.userinfo));
st, sizeof(cls.userinfo[0]));
if (cls.state >= ca_connected)
{

View File

@ -419,7 +419,7 @@ int checkDepth(int d)
if ([event type] == NSKeyDown)
{
int code = keyconv[[event keyCode]];
Key_Event(code, code>=128?0:code, TRUE);
Key_Event(0, code, code>=128?0:code, TRUE);
//printf("%d\n",[event keyCode]);
return;
}
@ -427,7 +427,7 @@ int checkDepth(int d)
if ([event type] == NSKeyUp)
{
int code = keyconv[[event keyCode]];
Key_Event(code, 0, FALSE);
Key_Event(0, code, 0, FALSE);
return;
}
@ -437,27 +437,27 @@ int checkDepth(int d)
if ((mflags & NSAlternateKeyMask) ^ (oldmflags & NSAlternateKeyMask))
{
Key_Event(K_ALT, 0, (mflags & NSAlternateKeyMask) ? TRUE : FALSE);
Key_Event(0, K_ALT, 0, (mflags & NSAlternateKeyMask) ? TRUE : FALSE);
}
if ((mflags & NSControlKeyMask) ^ (oldmflags & NSControlKeyMask))
{
Key_Event(K_LCTRL, 0, (mflags & NSControlKeyMask) ? TRUE : FALSE);
Key_Event(0, K_LCTRL, 0, (mflags & NSControlKeyMask) ? TRUE : FALSE);
}
if ((mflags & NSShiftKeyMask) ^ (oldmflags & NSShiftKeyMask))
{
Key_Event(K_LSHIFT, 0, (mflags & NSShiftKeyMask) ? TRUE : FALSE);
Key_Event(0, K_LSHIFT, 0, (mflags & NSShiftKeyMask) ? TRUE : FALSE);
}
if ((mflags & NSCommandKeyMask) ^ (oldmflags & NSCommandKeyMask))
{
Key_Event(K_LWIN, 0, (mflags & NSCommandKeyMask) ? TRUE : FALSE);
Key_Event(0, K_LWIN, 0, (mflags & NSCommandKeyMask) ? TRUE : FALSE);
}
if ((mflags & NSAlphaShiftKeyMask) ^ (oldmflags & NSAlphaShiftKeyMask))
{
Key_Event(K_CAPSLOCK, 0, (mflags & NSAlphaShiftKeyMask) ? TRUE : FALSE);
Key_Event(0, K_CAPSLOCK, 0, (mflags & NSAlphaShiftKeyMask) ? TRUE : FALSE);
}
oldmflags = mflags;
@ -507,43 +507,43 @@ int checkDepth(int d)
if ([event type] == NSLeftMouseDown)
{
Key_Event(K_MOUSE1, 0, TRUE);
Key_Event(0, K_MOUSE1, 0, TRUE);
return;
}
if ([event type] == NSLeftMouseUp)
{
Key_Event(K_MOUSE1, 0, FALSE);
Key_Event(0, K_MOUSE1, 0, FALSE);
return;
}
if ([event type] == NSRightMouseDown)
{
Key_Event(K_MOUSE2, 0, TRUE);
Key_Event(0, K_MOUSE2, 0, TRUE);
return;
}
if ([event type] == NSRightMouseUp)
{
Key_Event(K_MOUSE2, 0, FALSE);
Key_Event(0, K_MOUSE2, 0, FALSE);
return;
}
if ([event type] == NSOtherMouseDown)
{
Key_Event(K_MOUSE3, 0, TRUE);
Key_Event(0, K_MOUSE3, 0, TRUE);
return;
}
if ([event type] == NSOtherMouseUp)
{
Key_Event(K_MOUSE3, 0, FALSE);
Key_Event(0, K_MOUSE3, 0, FALSE);
return;
}
if ([event type] == NSScrollWheel)
{
Key_Event(([event deltaY] > 0.0) ? K_MWHEELUP : K_MWHEELDOWN, 0, TRUE);
Key_Event(0, ([event deltaY] > 0.0) ? K_MWHEELUP : K_MWHEELDOWN, 0, TRUE);
return;
}
}

View File

@ -364,7 +364,7 @@ void ClearAllStates (void)
// send an up event for each key, to make sure the server clears them all
for (i=0 ; i<256 ; i++)
{
Key_Event (i, 0, false);
Key_Event (0, i, 0, false);
}
Key_ClearStates ();
@ -395,11 +395,11 @@ static void GetEvent(void)
break;
case KeyPress:
b = XLateKey(&event.xkey, &uc);
Key_Event(b, uc, true);
Key_Event(0, b, uc, true);
break;
case KeyRelease:
b = XLateKey(&event.xkey, NULL);
Key_Event(b, 0, false);
Key_Event(0, b, 0, false);
break;
case MotionNotify:
@ -458,7 +458,7 @@ static void GetEvent(void)
b = x11violations?K_MOUSE10:-1;
if (b>=0)
Key_Event(b, 0, true);
Key_Event(0, b, 0, true);
#ifdef WITH_VMODE
if (vidmode_ext && vidmode_usemode>=0)
if (!ActiveApp)
@ -501,7 +501,7 @@ static void GetEvent(void)
b = x11violations?K_MOUSE10:-1;
if (b>=0)
Key_Event(b, 0, false);
Key_Event(0, b, 0, false);
break;
case FocusIn:

View File

@ -2252,7 +2252,7 @@ single print to a specific client
centerprint(clientent, value)
=================
*/
void PF_centerprint_Internal (int entnum, char *s)
void PF_centerprint_Internal (int entnum, qboolean plaque, char *s)
{
client_t *cl, *sp;
int slen;
@ -2268,8 +2268,13 @@ void PF_centerprint_Internal (int entnum, char *s)
return;
}
if (!*s)
plaque = false;
cl = &svs.clients[entnum-1];
slen = strlen(s);
if (plaque)
slen += 2;
if (cl->controller)
{ //this is a slave client.
@ -2281,18 +2286,22 @@ void PF_centerprint_Internal (int entnum, char *s)
break;
pnum++;
}
sp = cl->controller;
cl = cl->controller;
ClientReliableWrite_Begin (sp, svcfte_choosesplitclient, 4 + slen);
ClientReliableWrite_Byte (sp, pnum);
ClientReliableWrite_Byte (sp, svc_centerprint);
ClientReliableWrite_String (sp, s);
ClientReliableWrite_Begin (cl, svcfte_choosesplitclient, 4 + slen);
ClientReliableWrite_Byte (cl, pnum);
ClientReliableWrite_Byte (cl, svc_centerprint);
}
else
{
ClientReliableWrite_Begin (cl, svc_centerprint, 2 + slen);
ClientReliableWrite_String (cl, s);
}
if (plaque)
{
ClientReliableWrite_Char (cl, '/');
ClientReliableWrite_Char (cl, 'P');
}
ClientReliableWrite_String (cl, s);
if (sv.mvdrecording)
{
@ -2309,7 +2318,7 @@ void PF_centerprint (progfuncs_t *prinst, struct globalvars_s *pr_globals)
entnum = G_EDICTNUM(prinst, OFS_PARM0);
s = PF_VarString(prinst, 1, pr_globals);
PF_centerprint_Internal(entnum, s);
PF_centerprint_Internal(entnum, false, s);
}
/*
@ -7034,16 +7043,9 @@ void PF_h2plaque_draw(progfuncs_t *prinst, struct globalvars_s *pr_globals)
if (G_FLOAT(OFS_PARM0) == MSG_ONE)
{
client_t *cl = Write_GetClient();
if (!cl)
return;
ClientReliableWrite_Begin (cl, svc_centerprint, 4 + strlen(s));
if (*s)
{
ClientReliableWrite_Byte (cl, '/');
ClientReliableWrite_Byte (cl, 'P');
}
ClientReliableWrite_String (cl, s);
edict_t *ent;
ent = PROG_TO_EDICT(svprogfuncs, pr_global_struct->msg_entity);
PF_centerprint_Internal(NUM_FOR_EDICT(svprogfuncs, ent), true, s);
}
else
{

View File

@ -625,7 +625,7 @@ static qintptr_t syscallhandle (void *offset, quintptr_t mask, qintptr_t fn, con
break;
case G_CENTERPRINT:
PF_centerprint_Internal(VM_LONG(arg[0]), VM_POINTER(arg[1]));
PF_centerprint_Internal(VM_LONG(arg[0]), false, VM_POINTER(arg[1]));
break;
case G_AMBIENTSOUND:

View File

@ -1163,6 +1163,7 @@ extern cvar_t rank_needlogin;
client_t *SV_GetClientForString(char *name, int *id);
qboolean SV_MayCheat(void);
qboolean ReloadRanking(client_t *cl, char *newname);

View File

@ -27,7 +27,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
qboolean sv_allow_cheats;
int sv_allow_cheats;
qboolean SV_MayCheat(void)
{
if (sv_allow_cheats == 2)
return sv.allocated_client_slots == 1;
return sv_allow_cheats!=0;
}
extern cvar_t cl_warncmd;
cvar_t sv_cheats = SCVARF("sv_cheats", "0", CVAR_LATCH);
@ -273,7 +279,7 @@ Sets client to godmode
*/
void SV_God_f (void)
{
if (!sv_allow_cheats)
if (!SV_MayCheat())
{
Con_TPrintf (STL_NEEDCHEATPARM);
return;
@ -293,7 +299,7 @@ void SV_God_f (void)
void SV_Noclip_f (void)
{
if (!sv_allow_cheats)
if (!SV_MayCheat())
{
Con_TPrintf (STL_NEEDCHEATPARM);
return;
@ -326,7 +332,7 @@ void SV_Give_f (void)
char *t;
int v;
if (!sv_allow_cheats)
if (!SV_MayCheat())
{
Con_TPrintf (STL_NEEDCHEATPARM);
return;

View File

@ -41,7 +41,6 @@ extern cvar_t sv_bigcoords;
extern cvar_t sv_gamespeed;
extern cvar_t sv_csqcdebug;
extern cvar_t sv_csqc_progname;
extern qboolean sv_allow_cheats;
extern cvar_t sv_calcphs;
/*
@ -624,6 +623,7 @@ void SV_SpawnServer (char *server, char *startspot, qboolean noents, qboolean us
#endif
int i, j;
int spawnflagmask;
extern int sv_allow_cheats;
#ifndef SERVERONLY
if (!isDedicated && qrenderer == QR_NONE)
@ -817,20 +817,19 @@ void SV_SpawnServer (char *server, char *startspot, qboolean noents, qboolean us
COM_FlushTempoaryPacks();
//This fixes a bug where the server advertises cheats, the internal client connects, and doesn't think cheats are allowed.
//this applies to a few other things too, but cheats is the only special one (because of the *)
if (sv_cheats.value)
if (sv_cheats.ival)
{
sv_allow_cheats = true;
Info_SetValueForStarKey(svs.info, "*cheats", "ON", MAX_SERVERINFO_STRING);
}
else
{
sv_allow_cheats = false;
sv_allow_cheats = 2;
Info_SetValueForStarKey(svs.info, "*cheats", "", MAX_SERVERINFO_STRING);
}
#ifndef SERVERONLY
//This fixes a bug where the server advertises cheats, the internal client connects, and doesn't think cheats are allowed.
//this applies to a few other things too, but cheats is the only special one (because of the *)
Q_strncpyz(cl.serverinfo, svs.info, sizeof(cl.serverinfo));
CL_CheckServerInfo();
#endif
@ -1078,9 +1077,20 @@ void SV_SpawnServer (char *server, char *startspot, qboolean noents, qboolean us
ent = EDICT_NUM(svprogfuncs, 0);
ent->isfree = false;
/*force coop 1 if splitscreen and not deathmatch*/
{
extern cvar_t cl_splitscreen;
if (cl_splitscreen.value && !deathmatch.value && !coop.value)
Cvar_Set(&coop, "1");
}
/*only make one slot for single-player*/
if (!isDedicated && !deathmatch.value && !coop.value)
sv.allocated_client_slots = 1;
else
sv.allocated_client_slots = MAX_CLIENTS;
// leave slots at start for clients only
// sv.num_edicts = MAX_CLIENTS+1;
for (i=0 ; i<MAX_CLIENTS ; i++)
for (i=0 ; i<sv.allocated_client_slots ; i++)
{
svs.clients[i].viewent = 0;
@ -1111,8 +1121,12 @@ void SV_SpawnServer (char *server, char *startspot, qboolean noents, qboolean us
memset(svs.clients[i].csqcentversions, 0, sizeof(svs.clients[i].csqcentversions));
#endif
}
sv.allocated_client_slots = i;
for (; i < MAX_CLIENTS; i++)
{
if (svs.clients[i].state)
SV_DropClient(&svs.clients[i]);
svs.clients[i].namebuf[0] = '\0'; //kill all bots
}
#ifdef PEXT_CSQC
for (i=0 ; i<MAX_EDICTS ; i++)
sv.csqcentversion[i] = 1; //force all csqc edicts to start off as version 1

View File

@ -2028,6 +2028,10 @@ client_t *SVC_DirectConnect(void)
if (!newcl) //client has no slot. It's possible to bipass this if server is loading a game. (or a duplicated qsocket)
{
if (sv.allocated_client_slots == 1 && net_from.type == NA_LOOPBACK)
if (svs.clients[0].state)
SV_DropClient(svs.clients);
// if at server limits, refuse connection
if ( maxclients.ival > MAX_CLIENTS )
Cvar_SetValue (&maxclients, MAX_CLIENTS);

View File

@ -3397,11 +3397,9 @@ void SV_Vote_f (void)
}
}
extern qboolean sv_allow_cheats;
void Cmd_Notarget_f (void)
{
if (!sv_allow_cheats)
if (!SV_MayCheat())
{
SV_PrintToClient(host_client, PRINT_HIGH, "Cheats are not allowed on this server\n");
return;
@ -3417,7 +3415,7 @@ void Cmd_Notarget_f (void)
//Sets client to godmode
void Cmd_God_f (void)
{
if (!sv_allow_cheats)
if (!SV_MayCheat())
{
SV_PrintToClient(host_client, PRINT_HIGH, "Cheats are not allowed on this server\n");
return;
@ -3444,7 +3442,7 @@ void Cmd_Give_f (void)
}
#endif
if (!sv_allow_cheats)
if (!SV_MayCheat())
{
SV_PrintToClient(host_client, PRINT_HIGH, "Cheats are not allowed on this server\n");
return;
@ -3499,7 +3497,7 @@ void Cmd_Give_f (void)
void Cmd_Noclip_f (void)
{
if (!sv_allow_cheats)
if (!SV_MayCheat())
{
SV_PrintToClient(host_client, PRINT_HIGH, "Cheats are not allowed on this server\n");
return;
@ -3525,7 +3523,7 @@ void Cmd_Noclip_f (void)
void Cmd_Fly_f (void)
{
if (!sv_allow_cheats)
if (!SV_MayCheat())
{
SV_PrintToClient(host_client, PRINT_HIGH, "Cheats are not allowed on this server\n");
return;
@ -3556,7 +3554,7 @@ By Alex Shadowalker (and added to fte because he kept winging)
*/
void Cmd_SetPos_f(void)
{
if (!sv_allow_cheats)
if (!SV_MayCheat())
{
SV_PrintToClient(host_client, PRINT_HIGH, "Cheats are not allowed on this server\n");
return;