mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
allow server clients to be initialized properly (SV_Spawn) and send server
client info to connecting clients
This commit is contained in:
parent
7d09105740
commit
fd433442fb
4 changed files with 39 additions and 17 deletions
|
@ -547,6 +547,7 @@ void *SV_AddUserCommand (const char *name, void (*func) (void *userdata),
|
|||
void *userdata,
|
||||
void (*on_free) (void *userdata));
|
||||
int SV_RemoveUserCommand (void *cmd);
|
||||
void SV_Spawn (client_t *client);
|
||||
|
||||
//
|
||||
// svonly.c
|
||||
|
|
|
@ -466,7 +466,7 @@ SV_FullClientUpdate (client_t *client, sizebuf_t *buf)
|
|||
void
|
||||
SV_FullClientUpdateToClient (client_t *client, client_t *cl)
|
||||
{
|
||||
if (client->state < cs_connected)
|
||||
if (client->state < cs_connected && client->state != cs_server)
|
||||
return;
|
||||
ClientReliableCheckBlock (cl, 24 + client->userinfo->cursize);
|
||||
if (cl->num_backbuf) {
|
||||
|
|
|
@ -1855,7 +1855,19 @@ PR_SV_UserCmd (progs_t *pr)
|
|||
SV_PreRunCmd ();
|
||||
SV_RunCmd (&ucmd, 0);
|
||||
SV_PostRunCmd ();
|
||||
};
|
||||
}
|
||||
|
||||
static void
|
||||
PR_SV_Spawn (progs_t *pr)
|
||||
{
|
||||
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");
|
||||
|
||||
SV_Spawn (cl);
|
||||
}
|
||||
|
||||
void
|
||||
SV_PR_Cmds_Init ()
|
||||
|
@ -2023,4 +2035,6 @@ SV_PR_Cmds_Init ()
|
|||
PR_AddBuiltin (&sv_pr_state, "SV_SetPing", PR_SV_SetPing, -1);
|
||||
// void (entity cl, float secs, vector angles, vector move, integer buttons, integer impulse) SV_UserCmd
|
||||
PR_AddBuiltin (&sv_pr_state, "SV_UserCmd", PR_SV_UserCmd, -1);
|
||||
// void (entity cl) SV_Spawn
|
||||
PR_AddBuiltin (&sv_pr_state, "SV_Spawn", PR_SV_Spawn, -1);
|
||||
};
|
||||
|
|
|
@ -334,12 +334,32 @@ SV_PreSpawn_f (void *unused)
|
|||
MSG_WriteString (msg, command);
|
||||
}
|
||||
|
||||
void
|
||||
SV_Spawn (client_t *client)
|
||||
{
|
||||
edict_t *ent;
|
||||
|
||||
// set up the edict
|
||||
ent = client->edict;
|
||||
|
||||
memset (&ent->v, 0, sv_pr_state.progs->entityfields * 4);
|
||||
SVfloat (ent, colormap) = NUM_FOR_EDICT (&sv_pr_state, ent);
|
||||
SVfloat (ent, team) = 0; // FIXME
|
||||
SVstring (ent, netname) = PR_SetString (&sv_pr_state, host_client->name);
|
||||
|
||||
host_client->entgravity = 1.0;
|
||||
if (sv_fields.gravity != -1)
|
||||
SVfloat (ent, gravity) = 1.0;
|
||||
host_client->maxspeed = sv_maxspeed->value;
|
||||
if (sv_fields.maxspeed != -1)
|
||||
SVfloat (ent, maxspeed) = sv_maxspeed->value;
|
||||
}
|
||||
|
||||
static void
|
||||
SV_Spawn_f (void *unused)
|
||||
{
|
||||
int i, n;
|
||||
client_t *client;
|
||||
edict_t *ent;
|
||||
|
||||
if (host_client->state != cs_connected) {
|
||||
SV_Printf ("Spawn not valid -- already spawned\n");
|
||||
|
@ -389,20 +409,7 @@ SV_Spawn_f (void *unused)
|
|||
ClientReliableWrite_String (host_client, sv.lightstyles[i]);
|
||||
}
|
||||
|
||||
// set up the edict
|
||||
ent = host_client->edict;
|
||||
|
||||
memset (&ent->v, 0, sv_pr_state.progs->entityfields * 4);
|
||||
SVfloat (ent, colormap) = NUM_FOR_EDICT (&sv_pr_state, ent);
|
||||
SVfloat (ent, team) = 0; // FIXME
|
||||
SVstring (ent, netname) = PR_SetString (&sv_pr_state, host_client->name);
|
||||
|
||||
host_client->entgravity = 1.0;
|
||||
if (sv_fields.gravity != -1)
|
||||
SVfloat (ent, gravity) = 1.0;
|
||||
host_client->maxspeed = sv_maxspeed->value;
|
||||
if (sv_fields.maxspeed != -1)
|
||||
SVfloat (ent, maxspeed) = sv_maxspeed->value;
|
||||
SV_Spawn (host_client);
|
||||
|
||||
//
|
||||
// force stats to be updated
|
||||
|
|
Loading…
Reference in a new issue