Correctly update points and kills

This commit is contained in:
Ryan Baldwin 2022-07-02 17:08:36 -07:00
parent d97e3fcea2
commit 68481edc45
8 changed files with 62 additions and 24 deletions

Binary file not shown.

Binary file not shown.

View File

@ -952,11 +952,7 @@ void CL_ParseLimbUpdate (void)
#define SHOWNET(x) if(cl_shownet.value==2)Con_Printf ("%3i:%s\n", msg_readcount-1, x);
/*
=====================
CL_ParseServerMessage
=====================
*/
void CL_ParseServerMessage (void)
{
int cmd;
@ -1087,14 +1083,6 @@ void CL_ParseServerMessage (void)
Host_Error ("CL_ParseServerMessage: svc_updatename > MAX_SCOREBOARD");
strcpy (cl.scores[i].name, MSG_ReadString ());
break;
case svc_updatefrags:
Sbar_Changed ();
i = MSG_ReadByte ();
if (i >= cl.maxclients)
Host_Error ("CL_ParseServerMessage: svc_updatefrags > MAX_SCOREBOARD");
MSG_ReadShort ();
break;
case svc_updatecolors:
Sbar_Changed ();
@ -1204,6 +1192,21 @@ void CL_ParseServerMessage (void)
case svc_limbupdate:
CL_ParseLimbUpdate();
break;
case svc_updatepoints:
i = MSG_ReadByte ();
if (i >= cl.maxclients)
Host_Error ("CL_ParseServerMessage: svc_updatepoints > MAX_SCOREBOARD");
cl.scores[i].points = MSG_ReadLong ();
break;
case svc_updatekills:
i = MSG_ReadByte ();
if (i >= cl.maxclients)
Host_Error ("CL_ParseServerMessage: svc_updatekills > MAX_SCOREBOARD");
cl.scores[i].kills = MSG_ReadShort ();
break;
}
}
}

View File

@ -375,7 +375,8 @@ void SV_DropClient (qboolean crash)
// free the client (the body stays around)
host_client->active = false;
host_client->name[0] = 0;
host_client->old_frags = -999999;
host_client->old_points = -999999;
host_client->old_kills = -999999;
net_activeconnections--;
// send notification to all clients
@ -386,12 +387,12 @@ void SV_DropClient (qboolean crash)
MSG_WriteByte (&client->message, svc_updatename);
MSG_WriteByte (&client->message, host_client - svs.clients);
MSG_WriteString (&client->message, "");
MSG_WriteByte (&client->message, svc_updatefrags);
MSG_WriteByte (&client->message, svc_updatepoints);
MSG_WriteByte (&client->message, host_client - svs.clients);
MSG_WriteLong (&client->message, 0);
MSG_WriteByte (&client->message, svc_updatekills);
MSG_WriteByte (&client->message, host_client - svs.clients);
MSG_WriteShort (&client->message, 0);
MSG_WriteByte (&client->message, svc_updatecolors);
MSG_WriteByte (&client->message, host_client - svs.clients);
MSG_WriteByte (&client->message, 0);
}
}

View File

@ -1328,12 +1328,12 @@ void Host_Spawn_f (void)
MSG_WriteByte (&host_client->message, svc_updatename);
MSG_WriteByte (&host_client->message, i);
MSG_WriteString (&host_client->message, client->name);
MSG_WriteByte (&host_client->message, svc_updatefrags);
MSG_WriteByte (&host_client->message, svc_updatepoints);
MSG_WriteByte (&host_client->message, i);
MSG_WriteShort (&host_client->message, client->old_frags);
MSG_WriteByte (&host_client->message, svc_updatecolors);
MSG_WriteLong (&host_client->message, client->old_points);
MSG_WriteByte (&host_client->message, svc_updatekills);
MSG_WriteByte (&host_client->message, i);
MSG_WriteByte (&host_client->message, client->colors);
MSG_WriteShort (&host_client->message, client->old_kills);
}
// send all current light styles

View File

@ -101,7 +101,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// [string]...[0]sounds cache
#define svc_lightstyle 12 // [byte] [string]
#define svc_updatename 13 // [byte] [string]
#define svc_updatefrags 14 // [byte] [short]
#define svc_updatepoints 14 // [byte] [short]
#define svc_clientdata 15 // <shortbits + data>
#define svc_stopsound 16 // <see code>
#define svc_updatecolors 17 // [byte] [byte]

View File

@ -105,7 +105,11 @@ typedef struct client_s
float spawn_parms[NUM_SPAWN_PARMS];
// client known data for deltas
int old_frags;
//int old_frags;
int old_points;
int old_kills;
} client_t;

View File

@ -746,7 +746,36 @@ void SV_UpdateToReliableMessages (void)
// check for changes to be sent over the reliable streams
for (i=0, host_client = svs.clients ; i<svs.maxclients ; i++, host_client++)
{
if (host_client->old_points != host_client->edict->v.points)
{
for (j=0, client = svs.clients ; j<svs.maxclients ; j++, client++)
{
if (!client->active)
continue;
MSG_WriteByte (&client->message, svc_updatepoints);
MSG_WriteByte (&client->message, i);
MSG_WriteLong (&client->message, host_client->edict->v.points);
}
host_client->old_points = host_client->edict->v.points;
}
}
for (i=0, host_client = svs.clients ; i<svs.maxclients ; i++, host_client++)
{
if (host_client->old_kills != host_client->edict->v.kills)
{
for (j=0, client = svs.clients ; j<svs.maxclients ; j++, client++)
{
if (!client->active)
continue;
MSG_WriteByte (&client->message, svc_updatekills);
MSG_WriteByte (&client->message, i);
MSG_WriteShort (&client->message, host_client->edict->v.kills);
}
host_client->old_points = host_client->edict->v.points;
}
}
for (j=0, client = svs.clients ; j<svs.maxclients ; j++, client++)