mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 22:31:05 +00:00
provide SV_UserCmd builtin so progs can emulate a client but use the
engine's physics code
This commit is contained in:
parent
57a470a88a
commit
4c7daebe89
3 changed files with 30 additions and 4 deletions
|
@ -480,6 +480,9 @@ void SV_SaveSpawnparms (void);
|
|||
|
||||
void SV_Physics_Client (struct edict_s *ent);
|
||||
|
||||
void SV_PreRunCmd (void);
|
||||
void SV_RunCmd (usercmd_t *ucmd, qboolean inside);
|
||||
void SV_PostRunCmd (void);
|
||||
void SV_SetupUserCommands (void);
|
||||
void SV_ExecuteUserCommand (const char *s);
|
||||
void SV_InitOperatorCommands (void);
|
||||
|
|
|
@ -1818,6 +1818,28 @@ PR_SV_SetPing (progs_t *pr)
|
|||
cl->ping = P_INT (pr, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
PR_SV_UserCmd (progs_t *pr)
|
||||
{
|
||||
usercmd_t ucmd;
|
||||
int entnum = P_EDICTNUM (pr, 0);
|
||||
client_t *cl = svs.clients + entnum - 1;
|
||||
|
||||
if (entnum < 1 || entnum > MAX_CLIENTS || cl->state != cs_server)
|
||||
PR_RunError (pr, "not a server client");
|
||||
|
||||
host_client = cl;
|
||||
sv_player = host_client->edict;
|
||||
ucmd.msec = 1000 * P_FLOAT (pr, 1);
|
||||
VectorCopy (P_VECTOR (pr, 2), ucmd.angles);
|
||||
VectorCopy (P_VECTOR (pr, 3), &ucmd.forwardmove); //FIXME right order?
|
||||
ucmd.buttons = P_INT (pr, 4);
|
||||
ucmd.impulse = P_INT (pr, 5);
|
||||
SV_PreRunCmd ();
|
||||
SV_RunCmd (&ucmd, 0);
|
||||
SV_PostRunCmd ();
|
||||
};
|
||||
|
||||
void
|
||||
SV_PR_Cmds_Init ()
|
||||
{
|
||||
|
@ -1897,4 +1919,5 @@ SV_PR_Cmds_Init ()
|
|||
PR_AddBuiltin (&sv_pr_state, "SV_FreeClient", PF_SV_FreeClient, -1);
|
||||
PR_AddBuiltin (&sv_pr_state, "SV_SetUserinfo", PF_SV_SetUserinfo, -1);
|
||||
PR_AddBuiltin (&sv_pr_state, "SV_SetPing", PR_SV_SetPing, -1);
|
||||
PR_AddBuiltin (&sv_pr_state, "SV_UserCmd", PR_SV_UserCmd, -1);
|
||||
};
|
||||
|
|
|
@ -1394,7 +1394,7 @@ byte playertouch[(MAX_EDICTS + 7) / 8];
|
|||
|
||||
Done before running a player command. Clears the touch array
|
||||
*/
|
||||
static void
|
||||
void
|
||||
SV_PreRunCmd (void)
|
||||
{
|
||||
memset (playertouch, 0, sizeof (playertouch));
|
||||
|
@ -1459,7 +1459,7 @@ check_usecs (usercmd_t *ucmd)
|
|||
host_client->msecs = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
SV_RunCmd (usercmd_t *ucmd, qboolean inside)
|
||||
{
|
||||
int oldmsec, i, n;
|
||||
|
@ -1505,7 +1505,7 @@ SV_RunCmd (usercmd_t *ucmd, qboolean inside)
|
|||
|
||||
// angles
|
||||
// show 1/3 the pitch angle and all the roll angle
|
||||
if (SVfloat (sv_player, health) > 0) {
|
||||
if (SVfloat (sv_player, health) > 0) { //FIXME hardcoded mod info
|
||||
if (!SVfloat (sv_player, fixangle)) {
|
||||
SVvector (sv_player, angles)[PITCH] =
|
||||
-SVvector (sv_player, v_angle)[PITCH] / 3;
|
||||
|
@ -1625,7 +1625,7 @@ SV_RunCmd (usercmd_t *ucmd, qboolean inside)
|
|||
|
||||
Done after running a player command.
|
||||
*/
|
||||
static void
|
||||
void
|
||||
SV_PostRunCmd (void)
|
||||
{
|
||||
// run post-think
|
||||
|
|
Loading…
Reference in a new issue