Rework where connection_started is set to make sure its always set. Fixes https://github.com/fte-team/fteqw/issues/164

This commit is contained in:
Shpoike 2023-01-26 07:07:53 +00:00
parent 990066dea1
commit f8962b6c47
5 changed files with 16 additions and 16 deletions

View file

@ -4180,6 +4180,7 @@ static void QCBUILTIN PF_spawnclient (pubprogfuncs_t *prinst, struct globalvars_
svs.clients[i].userid = ++nextuserid; svs.clients[i].userid = ++nextuserid;
svs.clients[i].protocol = SCP_BAD; //marker for bots svs.clients[i].protocol = SCP_BAD; //marker for bots
svs.clients[i].state = cs_spawned; svs.clients[i].state = cs_spawned;
svs.clients[i].connection_started = realtime;
svs.clients[i].spawned = true; svs.clients[i].spawned = true;
sv.spawned_client_slots++; sv.spawned_client_slots++;
svs.clients[i].netchan.message.allowoverflow = true; svs.clients[i].netchan.message.allowoverflow = true;

View file

@ -1668,6 +1668,7 @@ static qintptr_t QVM_Add_Bot (void *offset, quintptr_t mask, const qintptr_t *ar
cl->userid = ++nextuserid; cl->userid = ++nextuserid;
cl->protocol = SCP_BAD; //marker for bots cl->protocol = SCP_BAD; //marker for bots
cl->state = cs_spawned; cl->state = cs_spawned;
cl->connection_started = realtime;
cl->spawned = true; cl->spawned = true;
sv.spawned_client_slots++; sv.spawned_client_slots++;
cl->netchan.message.allowoverflow = true; cl->netchan.message.allowoverflow = true;

View file

@ -1018,6 +1018,7 @@ void SV_FullClientUpdate (client_t *client, client_t *to)
if (ISQWCLIENT(to)) if (ISQWCLIENT(to))
{ {
float onservertime;
unsigned int pext = to->fteprotocolextensions; unsigned int pext = to->fteprotocolextensions;
int ping = SV_CalcPing (client, false); int ping = SV_CalcPing (client, false);
if (ping > 0xffff) if (ping > 0xffff)
@ -1041,10 +1042,13 @@ void SV_FullClientUpdate (client_t *client, client_t *to)
MSG_WriteByte(buf, client->lossage); MSG_WriteByte(buf, client->lossage);
ClientReliable_FinishWrite(to); ClientReliable_FinishWrite(to);
onservertime = realtime - client->connection_started;
if (onservertime > sv.time)
onservertime = sv.time;
buf = ClientReliable_StartWrite(to, 6); buf = ClientReliable_StartWrite(to, 6);
MSG_WriteByte(buf, svc_updateentertime); MSG_WriteByte(buf, svc_updateentertime);
MSG_WriteByte(buf, i); MSG_WriteByte(buf, i);
MSG_WriteFloat(buf, realtime - client->connection_started); MSG_WriteFloat(buf, onservertime);
ClientReliable_FinishWrite(to); ClientReliable_FinishWrite(to);
InfoBuf_ToString(&client->userinfo, info, (pext&PEXT_BIGUSERINFOS)?BASIC_INFO_STRING:sizeof(info), basicuserinfos, privateuserinfos, (pext&PEXT_BIGUSERINFOS)?NULL:basicuserinfos, &to->infosync, &client->userinfo); InfoBuf_ToString(&client->userinfo, info, (pext&PEXT_BIGUSERINFOS)?BASIC_INFO_STRING:sizeof(info), basicuserinfos, privateuserinfos, (pext&PEXT_BIGUSERINFOS)?NULL:basicuserinfos, &to->infosync, &client->userinfo);
@ -2546,6 +2550,7 @@ client_t *SV_AddSplit(client_t *controller, char *info, int id)
if (cl->spectator) if (cl->spectator)
InfoBuf_SetValueForStarKey (&cl->userinfo, "*spectator", va("%i", cl->spectator)); InfoBuf_SetValueForStarKey (&cl->userinfo, "*spectator", va("%i", cl->spectator));
cl->state = controller->state; cl->state = controller->state;
cl->connection_started = realtime;
// host_client = NULL; // host_client = NULL;
// sv_player = NULL; // sv_player = NULL;
@ -3076,6 +3081,7 @@ void SV_DoDirectConnect(svconnectinfo_t *fte_restrict info)
#endif #endif
newcl->state = cs_connected; newcl->state = cs_connected;
newcl->connection_started = realtime;
#ifdef Q3SERVER #ifdef Q3SERVER
newcl->gamestatesequence = -1; newcl->gamestatesequence = -1;
@ -5273,6 +5279,7 @@ void SV_Impulse_f (void)
pr_global_struct->time = sv.world.physicstime; pr_global_struct->time = sv.world.physicstime;
svs.clients[i].state = cs_connected; svs.clients[i].state = cs_connected;
svs.clients[i].connection_started = realtime;
SV_SetUpClientEdict(&svs.clients[i], svs.clients[i].edict); SV_SetUpClientEdict(&svs.clients[i], svs.clients[i].edict);

View file

@ -375,7 +375,6 @@ void SV_New_f (void)
ClientReliableWrite_Byte (host_client, playernum); ClientReliableWrite_Byte (host_client, playernum);
split->state = cs_connected; split->state = cs_connected;
split->connection_started = realtime;
#ifdef SVRANKING #ifdef SVRANKING
split->stats_started = realtime; split->stats_started = realtime;
#endif #endif
@ -412,7 +411,6 @@ void SV_New_f (void)
playernum |= 128; playernum |= 128;
split->state = cs_connected; split->state = cs_connected;
split->connection_started = realtime;
#ifdef SVRANKING #ifdef SVRANKING
split->stats_started = realtime; split->stats_started = realtime;
#endif #endif
@ -5459,7 +5457,6 @@ void SV_SetUpClientEdict (client_t *cl, edict_t *ent)
ent->v->movetype = MOVETYPE_NOCLIP; ent->v->movetype = MOVETYPE_NOCLIP;
ent->v->frags = 0; ent->v->frags = 0;
cl->connection_started = realtime;
} }
//dynamically add/remove a splitscreen client //dynamically add/remove a splitscreen client
@ -5949,18 +5946,7 @@ static void SVNQ_Spawn_f (void)
host_client->maxspeed = ent->xv->maxspeed; host_client->maxspeed = ent->xv->maxspeed;
} }
else else
{ SV_SetUpClientEdict(host_client, ent);
ED_Clear(svprogfuncs, ent);
ED_Spawned(ent, false);
ent->v->colormap = NUM_FOR_EDICT(svprogfuncs, ent);
ent->v->team = 0; // FIXME
svprogfuncs->SetStringField(svprogfuncs, ent, &ent->v->netname, host_client->name, true);
host_client->entgravity = ent->xv->gravity = 1.0;
host_client->entgravity*=sv_gravity.value;
host_client->maxspeed = ent->xv->maxspeed = sv_maxspeed.value;
}
// //
// force stats to be updated // force stats to be updated
@ -6221,6 +6207,8 @@ static void SVNQ_Status_f(void)
int hours, mins, secs; int hours, mins, secs;
if (!cl->state) if (!cl->state)
continue; continue;
if (i >= host_client->max_net_clients)
break; //don't send more than it expects. the ping parsers will give up and get spammy (sucks).
secs = realtime - cl->connection_started; secs = realtime - cl->connection_started;
mins = secs/60; mins = secs/60;
secs -= mins*60; secs -= mins*60;
@ -6418,6 +6406,7 @@ ucmd_t ucmds[] =
{"sayone", SV_SayOne_f}, {"sayone", SV_SayOne_f},
{"say", SV_Say_f}, {"say", SV_Say_f},
{"say_team", SV_Say_Team_f}, {"say_team", SV_Say_Team_f},
{"status", SVNQ_Status_f},
#ifdef SVRANKING #ifdef SVRANKING
{"topten", Rank_ListTop10_f}, {"topten", Rank_ListTop10_f},
#endif #endif

View file

@ -3409,6 +3409,7 @@ void SVQ3_DirectConnect(netadr_t *from, sizebuf_t *msg) //Actually connect the c
cl->protocol = SCP_QUAKE3; cl->protocol = SCP_QUAKE3;
cl->state = cs_connected; cl->state = cs_connected;
cl->connection_started = realtime;
cl->name = cl->namebuf; cl->name = cl->namebuf;
cl->team = cl->teambuf; cl->team = cl->teambuf;
worldfuncs->ExtractFromUserinfo(cl, true); worldfuncs->ExtractFromUserinfo(cl, true);
@ -3434,6 +3435,7 @@ static int SVQ3_AddBot(void)
return -1; //failure, no slots return -1; //failure, no slots
cl->protocol = SCP_BAD; cl->protocol = SCP_BAD;
cl->connection_started = realtime;
cl->state = cs_connected; cl->state = cs_connected;
cl->name = cl->namebuf; cl->name = cl->namebuf;
cl->team = cl->teambuf; cl->team = cl->teambuf;