mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
first step in creating an interface for the snagging of client slots by
the progs
This commit is contained in:
parent
8db10ff577
commit
389542fda7
6 changed files with 33 additions and 26 deletions
|
@ -120,6 +120,7 @@ typedef struct
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
cs_free, // can be reused for a new connection
|
cs_free, // can be reused for a new connection
|
||||||
|
cs_server, // client is grabbed by the server for its own purposes
|
||||||
cs_zombie, // client has been disconnected, but don't reuse
|
cs_zombie, // client has been disconnected, but don't reuse
|
||||||
// connection for a couple seconds
|
// connection for a couple seconds
|
||||||
cs_connected, // has been assigned to a client_t, but not in game yet
|
cs_connected, // has been assigned to a client_t, but not in game yet
|
||||||
|
|
|
@ -103,7 +103,7 @@ SV_Match_User (const char *substr)
|
||||||
|
|
||||||
if (!*str) {
|
if (!*str) {
|
||||||
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
||||||
if (!cl->state)
|
if (cl->state < cs_zombie)
|
||||||
continue;
|
continue;
|
||||||
if (cl->userid == uid) {
|
if (cl->userid == uid) {
|
||||||
SV_Printf ("User %04d matches with name: %s\n",
|
SV_Printf ("User %04d matches with name: %s\n",
|
||||||
|
@ -116,7 +116,7 @@ SV_Match_User (const char *substr)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
||||||
if (!cl->state)
|
if (cl->state < cs_zombie)
|
||||||
continue;
|
continue;
|
||||||
for (str = cl->name; *str && !match_char (*str, substr[0]); str++)
|
for (str = cl->name; *str && !match_char (*str, substr[0]); str++)
|
||||||
;
|
;
|
||||||
|
@ -230,7 +230,7 @@ SV_SetPlayer (void)
|
||||||
idnum = atoi (Cmd_Argv (1));
|
idnum = atoi (Cmd_Argv (1));
|
||||||
|
|
||||||
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
||||||
if (!cl->state)
|
if (cl->state < cs_zombie)
|
||||||
continue;
|
continue;
|
||||||
if (cl->userid == idnum) {
|
if (cl->userid == idnum) {
|
||||||
host_client = cl;
|
host_client = cl;
|
||||||
|
@ -496,6 +496,10 @@ SV_Status_f (void)
|
||||||
SV_Printf ("ZOMBIE\n");
|
SV_Printf ("ZOMBIE\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (cl->state == cs_server) {
|
||||||
|
SV_Printf ("SERVER\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
SV_Printf ("%4i %4i %5.2f\n",
|
SV_Printf ("%4i %4i %5.2f\n",
|
||||||
(int) (1000 * cl->netchan.frame_rate),
|
(int) (1000 * cl->netchan.frame_rate),
|
||||||
(int) SV_CalcPing (cl),
|
(int) SV_CalcPing (cl),
|
||||||
|
@ -527,6 +531,10 @@ SV_Status_f (void)
|
||||||
SV_Printf ("ZOMBIE\n");
|
SV_Printf ("ZOMBIE\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (cl->state == cs_server) {
|
||||||
|
SV_Printf ("SERVER\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
SV_Printf ("%4i %4i %3.1f %4i",
|
SV_Printf ("%4i %4i %3.1f %4i",
|
||||||
(int) (1000 * cl->netchan.frame_rate),
|
(int) (1000 * cl->netchan.frame_rate),
|
||||||
(int) SV_CalcPing (cl),
|
(int) SV_CalcPing (cl),
|
||||||
|
@ -582,7 +590,7 @@ SV_Cuff_f (void)
|
||||||
}
|
}
|
||||||
if (all) {
|
if (all) {
|
||||||
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
||||||
if (!cl->state)
|
if (cl->state < cs_zombie)
|
||||||
continue;
|
continue;
|
||||||
cl->cuff_time = realtime + mins*60.0;
|
cl->cuff_time = realtime + mins*60.0;
|
||||||
done = true;
|
done = true;
|
||||||
|
@ -644,7 +652,7 @@ SV_Mute_f (void)
|
||||||
}
|
}
|
||||||
if (all) {
|
if (all) {
|
||||||
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
||||||
if (!cl->state)
|
if (cl->state < cs_zombie)
|
||||||
continue;
|
continue;
|
||||||
cl->lockedtill = realtime + mins*60.0;
|
cl->lockedtill = realtime + mins*60.0;
|
||||||
done = true;
|
done = true;
|
||||||
|
@ -766,7 +774,7 @@ SV_ConSay (const char *prefix)
|
||||||
text[j++] |= 0x80; // non-bold text
|
text[j++] |= 0x80; // non-bold text
|
||||||
|
|
||||||
for (j = 0, client = svs.clients; j < MAX_CLIENTS; j++, client++) {
|
for (j = 0, client = svs.clients; j < MAX_CLIENTS; j++, client++) {
|
||||||
if (client->state != cs_spawned) // kk just has !client->state
|
if (client->state < cs_zombie)
|
||||||
continue;
|
continue;
|
||||||
SV_ClientPrintf (1, client, PRINT_HIGH, "%s\n", text);
|
SV_ClientPrintf (1, client, PRINT_HIGH, "%s\n", text);
|
||||||
if (*prefix != 'I') // beep, except for Info says
|
if (*prefix != 'I') // beep, except for Info says
|
||||||
|
@ -1045,7 +1053,7 @@ SV_Snap (int uid)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
||||||
if (!cl->state)
|
if (cl->state < cs_zombie)
|
||||||
continue;
|
continue;
|
||||||
if (cl->userid == uid)
|
if (cl->userid == uid)
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -59,7 +59,7 @@ SV_GIB_GetClient (int uid)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++)
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++)
|
||||||
if (cl->state && cl->userid == uid)
|
if (cl->state >= cs_connected && cl->userid == uid)
|
||||||
return cl;
|
return cl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ SV_GIB_Client_GetList_f (void)
|
||||||
GIB_USAGE("");
|
GIB_USAGE("");
|
||||||
else if (GIB_CanReturn())
|
else if (GIB_CanReturn())
|
||||||
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++)
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++)
|
||||||
if (cl->state)
|
if (cl->state >= cs_connected)
|
||||||
dsprintf (GIB_Return(0), "%i", cl->userid);
|
dsprintf (GIB_Return(0), "%i", cl->userid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ SV_GIB_Client_Print_All_f (void)
|
||||||
if (GIB_Argc() != 2)
|
if (GIB_Argc() != 2)
|
||||||
GIB_USAGE("message");
|
GIB_USAGE("message");
|
||||||
else for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++)
|
else for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++)
|
||||||
if (cl->state)
|
if (cl->state >= cs_connected)
|
||||||
SV_ClientPrintf (0, cl, level, "%s", GIB_Argv(1));
|
SV_ClientPrintf (0, cl, level, "%s", GIB_Argv(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -321,7 +321,7 @@ SV_FinalMessage (const char *message)
|
||||||
MSG_WriteByte (net_message->message, svc_disconnect);
|
MSG_WriteByte (net_message->message, svc_disconnect);
|
||||||
|
|
||||||
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++)
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++)
|
||||||
if (cl->state >= cs_spawned)
|
if (cl->state >= cs_connected)
|
||||||
Netchan_Transmit (&cl->netchan, net_message->message->cursize,
|
Netchan_Transmit (&cl->netchan, net_message->message->cursize,
|
||||||
net_message->message->data);
|
net_message->message->data);
|
||||||
}
|
}
|
||||||
|
@ -571,8 +571,7 @@ SVC_Status (void)
|
||||||
SV_Printf ("%s\n", Info_MakeString (svs.info, 0));
|
SV_Printf ("%s\n", Info_MakeString (svs.info, 0));
|
||||||
for (i = 0; i < MAX_CLIENTS; i++) {
|
for (i = 0; i < MAX_CLIENTS; i++) {
|
||||||
cl = &svs.clients[i];
|
cl = &svs.clients[i];
|
||||||
if ((cl->state == cs_connected || cl->state == cs_spawned)
|
if ((cl->state >= cs_connected) && !cl->spectator) {
|
||||||
&& !cl->spectator) {
|
|
||||||
top = atoi (Info_ValueForKey (cl->userinfo, "topcolor"));
|
top = atoi (Info_ValueForKey (cl->userinfo, "topcolor"));
|
||||||
bottom = atoi (Info_ValueForKey (cl->userinfo, "bottomcolor"));
|
bottom = atoi (Info_ValueForKey (cl->userinfo, "bottomcolor"));
|
||||||
top = (top < 0) ? 0 : ((top > 13) ? 13 : top);
|
top = (top < 0) ? 0 : ((top > 13) ? 13 : top);
|
||||||
|
@ -840,7 +839,7 @@ SVC_DirectConnect (void)
|
||||||
|
|
||||||
// if there is already a slot for this ip, drop it
|
// if there is already a slot for this ip, drop it
|
||||||
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
||||||
if (cl->state == cs_free)
|
if (cl->state < cs_zombie)
|
||||||
continue;
|
continue;
|
||||||
if (NET_CompareBaseAdr (adr, cl->netchan.remote_address)
|
if (NET_CompareBaseAdr (adr, cl->netchan.remote_address)
|
||||||
&& (cl->netchan.qport == qport
|
&& (cl->netchan.qport == qport
|
||||||
|
@ -974,7 +973,7 @@ Name_of_sender (void)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i=0, cl=svs.clients ; i<MAX_CLIENTS ; i++,cl++) {
|
for (i=0, cl=svs.clients ; i<MAX_CLIENTS ; i++,cl++) {
|
||||||
if (cl->state == cs_free)
|
if (cl->state < cs_zombie)
|
||||||
continue;
|
continue;
|
||||||
if (!NET_CompareBaseAdr(net_from, cl->netchan.remote_address))
|
if (!NET_CompareBaseAdr(net_from, cl->netchan.remote_address))
|
||||||
continue;
|
continue;
|
||||||
|
@ -1435,7 +1434,7 @@ SV_AddIP_f (void)
|
||||||
const char *typestr;
|
const char *typestr;
|
||||||
char timestr[1024];
|
char timestr[1024];
|
||||||
|
|
||||||
if (cl->state == cs_free)
|
if (cl->state < cs_zombie)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (SV_MaskIPCompare (cl->netchan.remote_address.ip,
|
if (SV_MaskIPCompare (cl->netchan.remote_address.ip,
|
||||||
|
@ -1781,7 +1780,7 @@ SV_ReadPackets (void)
|
||||||
|
|
||||||
// check for packets from connected clients
|
// check for packets from connected clients
|
||||||
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
||||||
if (cl->state == cs_free)
|
if (cl->state < cs_zombie)
|
||||||
continue;
|
continue;
|
||||||
if (!NET_CompareBaseAdr (net_from, cl->netchan.remote_address))
|
if (!NET_CompareBaseAdr (net_from, cl->netchan.remote_address))
|
||||||
continue;
|
continue;
|
||||||
|
@ -1833,7 +1832,7 @@ SV_CheckTimeouts (void)
|
||||||
nclients = 0;
|
nclients = 0;
|
||||||
|
|
||||||
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
||||||
if (cl->state == cs_connected || cl->state == cs_spawned) {
|
if (cl->state >= cs_connected) {
|
||||||
if (!cl->spectator)
|
if (!cl->spectator)
|
||||||
nclients++;
|
nclients++;
|
||||||
if (cl->netchan.last_received < droptime) {
|
if (cl->netchan.last_received < droptime) {
|
||||||
|
@ -2244,8 +2243,8 @@ Master_Heartbeat (void)
|
||||||
// count active users
|
// count active users
|
||||||
active = 0;
|
active = 0;
|
||||||
for (i = 0; i < MAX_CLIENTS; i++)
|
for (i = 0; i < MAX_CLIENTS; i++)
|
||||||
if (svs.clients[i].state == cs_connected ||
|
if (svs.clients[i].state >= cs_connected)
|
||||||
svs.clients[i].state == cs_spawned) active++;
|
active++;
|
||||||
|
|
||||||
svs.heartbeat_sequence++;
|
svs.heartbeat_sequence++;
|
||||||
snprintf (string, sizeof (string), "%c\n%i\n%i\n", S2M_HEARTBEAT,
|
snprintf (string, sizeof (string), "%c\n%i\n%i\n", S2M_HEARTBEAT,
|
||||||
|
@ -2362,7 +2361,6 @@ SV_ExtractFromUserinfo (client_t *cl)
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally, report it to all our friends
|
// finally, report it to all our friends
|
||||||
// if (cl->state >= cs_spawned && !cl->spectator)
|
|
||||||
if (*cl->name)
|
if (*cl->name)
|
||||||
SV_BroadcastPrintf (PRINT_HIGH, "%s changed name to %s\n",
|
SV_BroadcastPrintf (PRINT_HIGH, "%s changed name to %s\n",
|
||||||
cl->name, newname);
|
cl->name, newname);
|
||||||
|
|
|
@ -294,7 +294,7 @@ SV_BroadcastPrintf (int level, const char *fmt, ...)
|
||||||
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
||||||
if (level < cl->messagelevel)
|
if (level < cl->messagelevel)
|
||||||
continue;
|
continue;
|
||||||
if (!cl->state)
|
if (cl->state < cs_zombie)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
SV_PrintToClient (cl, level, string);
|
SV_PrintToClient (cl, level, string);
|
||||||
|
@ -807,7 +807,7 @@ SV_SendClientMessages (void)
|
||||||
|
|
||||||
// build individual updates
|
// build individual updates
|
||||||
for (i = 0, c = svs.clients; i < MAX_CLIENTS; i++, c++) {
|
for (i = 0, c = svs.clients; i < MAX_CLIENTS; i++, c++) {
|
||||||
if (!c->state)
|
if (c->state < cs_zombie)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (c->drop) {
|
if (c->drop) {
|
||||||
|
@ -1012,7 +1012,7 @@ SV_SendMessagesToAll (void)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0, c = svs.clients; i < MAX_CLIENTS; i++, c++)
|
for (i = 0, c = svs.clients; i < MAX_CLIENTS; i++, c++)
|
||||||
if (c->state) // FIXME: should this only send to active?
|
if (c->state < cs_zombie) // FIXME: should this only send to active?
|
||||||
c->send_message = true;
|
c->send_message = true;
|
||||||
|
|
||||||
SV_SendClientMessages ();
|
SV_SendClientMessages ();
|
||||||
|
|
|
@ -456,7 +456,7 @@ SV_Begin_f (ucmd_t *cmd)
|
||||||
unsigned int pmodel = 0, emodel = 0;
|
unsigned int pmodel = 0, emodel = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (host_client->state == cs_spawned)
|
if (host_client->state != cs_connected)
|
||||||
return; // don't begin again
|
return; // don't begin again
|
||||||
|
|
||||||
host_client->state = cs_spawned;
|
host_client->state = cs_spawned;
|
||||||
|
@ -946,7 +946,7 @@ SV_TogglePause (const char *msg)
|
||||||
|
|
||||||
// send notification to all clients
|
// send notification to all clients
|
||||||
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
||||||
if (!cl->state)
|
if (cl->state < cs_zombie)
|
||||||
continue;
|
continue;
|
||||||
ClientReliableWrite_Begin (cl, svc_setpause, 2);
|
ClientReliableWrite_Begin (cl, svc_setpause, 2);
|
||||||
ClientReliableWrite_Byte (cl, sv.paused);
|
ClientReliableWrite_Byte (cl, sv.paused);
|
||||||
|
|
Loading…
Reference in a new issue