mirror of
https://github.com/nzp-team/quakec.git
synced 2024-11-25 05:11:05 +00:00
SERVER/CLIENT: Properly network player fields such as points and kills
This commit is contained in:
parent
981cd3a5ad
commit
49dbd80fa4
5 changed files with 46 additions and 93 deletions
|
@ -132,10 +132,6 @@ float interpolating2;
|
|||
float rounds;
|
||||
float perks;
|
||||
float rounds_change;
|
||||
|
||||
float playerpoints[4]; // player point holders, player 1 points are index 0, player 2 at 1...
|
||||
float playerkills[4]; // player kill holders, player 1 points are index 0, player 2 at 1...
|
||||
string playernames[4]; // player name holders, player 1 name at index 0, player 2 at 1...
|
||||
float player_count;
|
||||
float score_show;
|
||||
|
||||
|
@ -173,6 +169,8 @@ float fade_time;
|
|||
float fade_type;
|
||||
|
||||
.float stance;
|
||||
.float points;
|
||||
.float kills;
|
||||
|
||||
float menu_initialized;
|
||||
|
||||
|
|
|
@ -310,15 +310,18 @@ void(float pwidth, float width, float height, float playernum) PointUpdate =
|
|||
|
||||
void(float width, float height) HUD_Points =
|
||||
{
|
||||
float pointlength = 0, increm = 10, i = 0, pointwidth = 0, x = 0;
|
||||
float pointlength = 0, increm = 10, pointwidth = 0, x = 0;
|
||||
float backwidth = 0.8*width;
|
||||
vector TEXTCOLOR = '0 0 0';
|
||||
|
||||
for (i = 3; i >= 0; i = i - 1)
|
||||
|
||||
for (int i = 3; i >= 0; i = i - 1)
|
||||
{
|
||||
if (playerpoints[i] == -1)
|
||||
float player_number = getplayerkeyfloat(i, "viewentity");
|
||||
entity client = findfloat(world, playernum, player_number);
|
||||
|
||||
if (client == world || client.movetype == MOVETYPE_TOSS)
|
||||
continue;
|
||||
|
||||
|
||||
switch(i) {
|
||||
case 1: TEXTCOLOR = TEXT_LIGHTBLUE; break;
|
||||
case 2: TEXTCOLOR = TEXT_ORANGE; break;
|
||||
|
@ -326,15 +329,15 @@ void(float width, float height) HUD_Points =
|
|||
default: TEXTCOLOR = [1, 1, 1]; break;
|
||||
}
|
||||
|
||||
pointwidth = stringwidth(ftos(playerpoints[i]), 0, [12, 12]);
|
||||
pointwidth = stringwidth(ftos(client.points), 0, [12, 12]);
|
||||
x = (99 - pointwidth)/2 + GetUltraWideOffset();
|
||||
|
||||
if ((i + 1) == getstatf(STAT_PLAYERNUM)) {
|
||||
drawpic([3 + GetUltraWideOffset(), g_height - 97 - (i * 25)], "gfx/hud/moneyback.tga", [96, 24], [1,1,1], 1);
|
||||
drawstring([x, g_height - 92 - (i * 25)], ftos(playerpoints[i]), [12, 12], TEXTCOLOR, 1, 0);
|
||||
drawstring([x, g_height - 92 - (i * 25)], ftos(client.points), [12, 12], TEXTCOLOR, 1, 0);
|
||||
} else {
|
||||
drawpic([-7 + GetUltraWideOffset(), g_height - 97 - (i * 25)], "gfx/hud/moneyback_condensed.tga", [96, 24], [1,1,1], 1);
|
||||
drawstring([x - 9, g_height - 92 - (i * 25)], ftos(playerpoints[i]), [12, 12], TEXTCOLOR, 1, 0);
|
||||
drawstring([x - 9, g_height - 92 - (i * 25)], ftos(client.points), [12, 12], TEXTCOLOR, 1, 0);
|
||||
}
|
||||
|
||||
PointUpdate(x + 70, width, height, i + 1);
|
||||
|
@ -1392,7 +1395,10 @@ void() HUD_Scores =
|
|||
|
||||
for (int i = 0; i < 4; i = i + 1)
|
||||
{
|
||||
if (playerpoints[i] == -1)
|
||||
float player_number = getplayerkeyfloat(i, "viewentity");
|
||||
entity client = findfloat(world, playernum, player_number);
|
||||
|
||||
if (client == world || client.movetype == MOVETYPE_TOSS)
|
||||
break;
|
||||
|
||||
switch(i) {
|
||||
|
@ -1419,17 +1425,18 @@ void() HUD_Scores =
|
|||
}
|
||||
|
||||
// Name
|
||||
drawstring([g_width/2 - 245, 200 + (30 * i)], playernames[i], [12, 12], TEXTCOLOR, 1, 0);
|
||||
string player_name = getplayerkeyvalue(i, "name");
|
||||
drawstring([g_width/2 - 245, 200 + (30 * i)], player_name, [12, 12], TEXTCOLOR, 1, 0);
|
||||
|
||||
// Points
|
||||
float point_width = stringwidth(ftos(playerpoints[i]), 0, [12, 12]);
|
||||
float point_width = stringwidth(ftos(client.points), 0, [12, 12]);
|
||||
float point_x = ((g_width/2) - (point_width)/2) + 52;
|
||||
drawstring([point_x, 200 + (30 * i)], ftos(playerpoints[i]), [12, 12], TEXTCOLOR, 1, 0);
|
||||
drawstring([point_x, 200 + (30 * i)], ftos(client.points), [12, 12], TEXTCOLOR, 1, 0);
|
||||
|
||||
// Kills
|
||||
float kill_width = stringwidth(ftos(playerpoints[i]), 0, [12, 12]);
|
||||
float kill_width = stringwidth(ftos(client.points), 0, [12, 12]);
|
||||
float kill_x = ((g_width/2) - (kill_width)/2) + 210;
|
||||
drawstring([kill_x, 200 + (30 * i)], ftos(playerkills[i]), [12, 12], TEXTCOLOR, 1, 0);
|
||||
drawstring([kill_x, 200 + (30 * i)], ftos(client.kills), [12, 12], TEXTCOLOR, 1, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -195,10 +195,6 @@ noref void() CSQC_WorldLoaded =
|
|||
setmodel(v2model,"");
|
||||
mzlflash.renderflags = vmodel.renderflags;
|
||||
mzlflash.origin = vmodel.origin + vmodel_muzzleoffset;
|
||||
|
||||
playerpoints[1] = -1;
|
||||
playerpoints[2] = -1;
|
||||
playerpoints[3] = -1;
|
||||
|
||||
Achievement_Init();
|
||||
Init_Particles();
|
||||
|
@ -544,6 +540,8 @@ noref void(float isnew) CSQC_Ent_Update =
|
|||
self.drawmask = MASK_ENGINE;
|
||||
setmodel(self, "models/player.mdl");
|
||||
}
|
||||
|
||||
float old_points = self.points;
|
||||
|
||||
self.origin_x = readcoord();
|
||||
self.origin_y = readcoord();
|
||||
|
@ -558,8 +556,12 @@ noref void(float isnew) CSQC_Ent_Update =
|
|||
self.modelindex = readshort();
|
||||
self.frame = readbyte();
|
||||
self.movetype = readshort();
|
||||
self.flags = readfloat();
|
||||
self.flags = readshort();
|
||||
self.stance = readbyte();
|
||||
self.points = readfloat(); // FIXME: this should be made a short, but I know we use price of 1 for some test maps, so I can't do /10 *10 shenanigans.
|
||||
self.kills = readshort();
|
||||
|
||||
RegisterPointChange(self.points - old_points, self.playernum);
|
||||
|
||||
if (self.movetype == MOVETYPE_TOSS)
|
||||
self.solid = SOLID_NOT;
|
||||
|
@ -1457,20 +1459,20 @@ noref void() CSQC_Parse_Event =
|
|||
revive_icons[reviveoff_id].draw = false;
|
||||
active_revive_icons--;
|
||||
break;
|
||||
case EVENT_POINTUPDATE:
|
||||
float playernum = readbyte();
|
||||
float temppoints = readlong();
|
||||
RegisterPointChange(readlong(), playernum);
|
||||
float tempkills = readlong();
|
||||
string tempname = readstring();
|
||||
// case EVENT_POINTUPDATE:
|
||||
// float playernum = readbyte();
|
||||
// float temppoints = readlong();
|
||||
// RegisterPointChange(readlong(), playernum);
|
||||
// float tempkills = readlong();
|
||||
// string tempname = readstring();
|
||||
|
||||
switch(playernum) {
|
||||
case 1: playerpoints[0] = temppoints; playerkills[0] = tempkills; playernames[0] = tempname; break;
|
||||
case 2: playerpoints[1] = temppoints; playerkills[1] = tempkills; playernames[1] = tempname; break;
|
||||
case 3: playerpoints[2] = temppoints; playerkills[2] = tempkills; playernames[2] = tempname; break;
|
||||
case 4: playerpoints[3] = temppoints; playerkills[3] = tempkills; playernames[3] = tempname; break;
|
||||
}
|
||||
break;
|
||||
// switch(playernum) {
|
||||
// case 1: playerpoints[0] = temppoints; playerkills[0] = tempkills; playernames[0] = tempname; break;
|
||||
// case 2: playerpoints[1] = temppoints; playerkills[1] = tempkills; playernames[1] = tempname; break;
|
||||
// case 3: playerpoints[2] = temppoints; playerkills[2] = tempkills; playernames[2] = tempname; break;
|
||||
// case 4: playerpoints[3] = temppoints; playerkills[3] = tempkills; playernames[3] = tempname; break;
|
||||
// }
|
||||
// break;
|
||||
case EVENT_BLACKOUT:
|
||||
fade_time = readbyte();
|
||||
fade_type = readbyte();
|
||||
|
|
|
@ -264,35 +264,6 @@ void(float broadcast_time, float type, string str) BroadcastMessage =
|
|||
#endif // FTE
|
||||
}
|
||||
|
||||
void(float playernum, float points, float am, float kills, string name, entity person) UpdatePlayerPoints =
|
||||
{
|
||||
#ifdef FTE
|
||||
|
||||
if (player_count == 0) {
|
||||
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
|
||||
WriteByte(MSG_MULTICAST, EVENT_POINTUPDATE);
|
||||
WriteByte(MSG_MULTICAST, playernum);
|
||||
WriteLong(MSG_MULTICAST, points);
|
||||
WriteLong(MSG_MULTICAST, am);
|
||||
WriteLong(MSG_MULTICAST, kills);
|
||||
WriteString(MSG_MULTICAST, name);
|
||||
msg_entity = person;
|
||||
multicast('0 0 0', MULTICAST_ONE);
|
||||
}
|
||||
else {
|
||||
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
|
||||
WriteByte(MSG_MULTICAST, EVENT_POINTUPDATE);
|
||||
WriteByte(MSG_MULTICAST, playernum);
|
||||
WriteLong(MSG_MULTICAST, points);
|
||||
WriteLong(MSG_MULTICAST, am);
|
||||
WriteLong(MSG_MULTICAST, kills);
|
||||
WriteString(MSG_MULTICAST, name);
|
||||
multicast('0 0 0', MULTICAST_ALL);
|
||||
}
|
||||
|
||||
#endif // FTE
|
||||
}
|
||||
|
||||
void(float count) UpdatePlayerCount = {
|
||||
#ifdef FTE
|
||||
if (count == 0)
|
||||
|
@ -567,14 +538,10 @@ float Player_SendEntity( entity ePVEnt, float flChanged ) {
|
|||
WriteShort( MSG_ENTITY, self.modelindex ); // Player Model
|
||||
WriteByte( MSG_ENTITY, self.frame ); // Player's Frame
|
||||
WriteShort( MSG_ENTITY, self.movetype ); // Player Movetype
|
||||
WriteFloat( MSG_ENTITY, self.flags ); // Flags, important for physics
|
||||
WriteShort( MSG_ENTITY, self.flags ); // Flags, important for physics
|
||||
WriteByte( MSG_ENTITY, self.stance ); // Player Stance
|
||||
// WriteCoord( MSG_ENTITY, self.mins_x ); // Min Size X
|
||||
// WriteCoord( MSG_ENTITY, self.mins_y ); // Min Size Y
|
||||
// WriteCoord( MSG_ENTITY, self.maxs_z ); // Max Size Z
|
||||
// WriteCoord( MSG_ENTITY, self.maxs_x ); // Max Size X
|
||||
// WriteCoord( MSG_ENTITY, self.maxs_y ); // Max Size Y
|
||||
// WriteCoord( MSG_ENTITY, self.maxs_z ); // Max Size Z
|
||||
WriteFloat( MSG_ENTITY, self.points ); // Player Score
|
||||
WriteShort( MSG_ENTITY, self.kills ); // Player Kills
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -715,8 +682,6 @@ void(entity person, float expamt, float doublepoint) addmoney =
|
|||
total_powerup_points += expamt;
|
||||
|
||||
person.points += expamt;
|
||||
|
||||
UpdatePlayerPoints(person.playernum, person.points, expamt, person.kills, person.netname, person);
|
||||
};
|
||||
|
||||
float(entity them, entity me) PlayerIsLooking =
|
||||
|
|
|
@ -679,24 +679,6 @@ void() ClientConnect =
|
|||
}
|
||||
};
|
||||
|
||||
void() PollPlayerPoints =
|
||||
{
|
||||
float i, breakpoint;
|
||||
entity pollent;
|
||||
breakpoint = 0;
|
||||
|
||||
for (i = 1; i <= 4 && !breakpoint; i++)
|
||||
{
|
||||
pollent = findfloat(world, playernum, i);
|
||||
|
||||
if (pollent == world) {
|
||||
breakpoint = 1;
|
||||
break;
|
||||
}
|
||||
UpdatePlayerPoints(i, pollent.points, pollent.kills, 0, pollent.netname, pollent);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Player_PickSpawnPoint()
|
||||
// Picks a valid spawn point for the
|
||||
|
@ -839,7 +821,6 @@ void() PlayerSpawn =
|
|||
|
||||
#ifdef FTE
|
||||
|
||||
PollPlayerPoints();
|
||||
UpdateV2model("", 0);
|
||||
stuffcmd(self, "cl_gunx 8;cl_guny 16;cl_gunz 25\n");
|
||||
SetRound(self, G_STARTROUND);
|
||||
|
|
Loading…
Reference in a new issue