mirror of
https://github.com/nzp-team/quakec.git
synced 2024-11-22 03:41:15 +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 rounds;
|
||||||
float perks;
|
float perks;
|
||||||
float rounds_change;
|
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 player_count;
|
||||||
float score_show;
|
float score_show;
|
||||||
|
|
||||||
|
@ -173,6 +169,8 @@ float fade_time;
|
||||||
float fade_type;
|
float fade_type;
|
||||||
|
|
||||||
.float stance;
|
.float stance;
|
||||||
|
.float points;
|
||||||
|
.float kills;
|
||||||
|
|
||||||
float menu_initialized;
|
float menu_initialized;
|
||||||
|
|
||||||
|
|
|
@ -310,15 +310,18 @@ void(float pwidth, float width, float height, float playernum) PointUpdate =
|
||||||
|
|
||||||
void(float width, float height) HUD_Points =
|
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;
|
float backwidth = 0.8*width;
|
||||||
vector TEXTCOLOR = '0 0 0';
|
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;
|
continue;
|
||||||
|
|
||||||
switch(i) {
|
switch(i) {
|
||||||
case 1: TEXTCOLOR = TEXT_LIGHTBLUE; break;
|
case 1: TEXTCOLOR = TEXT_LIGHTBLUE; break;
|
||||||
case 2: TEXTCOLOR = TEXT_ORANGE; break;
|
case 2: TEXTCOLOR = TEXT_ORANGE; break;
|
||||||
|
@ -326,15 +329,15 @@ void(float width, float height) HUD_Points =
|
||||||
default: TEXTCOLOR = [1, 1, 1]; break;
|
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();
|
x = (99 - pointwidth)/2 + GetUltraWideOffset();
|
||||||
|
|
||||||
if ((i + 1) == getstatf(STAT_PLAYERNUM)) {
|
if ((i + 1) == getstatf(STAT_PLAYERNUM)) {
|
||||||
drawpic([3 + GetUltraWideOffset(), g_height - 97 - (i * 25)], "gfx/hud/moneyback.tga", [96, 24], [1,1,1], 1);
|
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 {
|
} else {
|
||||||
drawpic([-7 + GetUltraWideOffset(), g_height - 97 - (i * 25)], "gfx/hud/moneyback_condensed.tga", [96, 24], [1,1,1], 1);
|
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);
|
PointUpdate(x + 70, width, height, i + 1);
|
||||||
|
@ -1392,7 +1395,10 @@ void() HUD_Scores =
|
||||||
|
|
||||||
for (int i = 0; i < 4; i = i + 1)
|
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;
|
break;
|
||||||
|
|
||||||
switch(i) {
|
switch(i) {
|
||||||
|
@ -1419,17 +1425,18 @@ void() HUD_Scores =
|
||||||
}
|
}
|
||||||
|
|
||||||
// Name
|
// 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
|
// 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;
|
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
|
// 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;
|
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,"");
|
setmodel(v2model,"");
|
||||||
mzlflash.renderflags = vmodel.renderflags;
|
mzlflash.renderflags = vmodel.renderflags;
|
||||||
mzlflash.origin = vmodel.origin + vmodel_muzzleoffset;
|
mzlflash.origin = vmodel.origin + vmodel_muzzleoffset;
|
||||||
|
|
||||||
playerpoints[1] = -1;
|
|
||||||
playerpoints[2] = -1;
|
|
||||||
playerpoints[3] = -1;
|
|
||||||
|
|
||||||
Achievement_Init();
|
Achievement_Init();
|
||||||
Init_Particles();
|
Init_Particles();
|
||||||
|
@ -544,6 +540,8 @@ noref void(float isnew) CSQC_Ent_Update =
|
||||||
self.drawmask = MASK_ENGINE;
|
self.drawmask = MASK_ENGINE;
|
||||||
setmodel(self, "models/player.mdl");
|
setmodel(self, "models/player.mdl");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float old_points = self.points;
|
||||||
|
|
||||||
self.origin_x = readcoord();
|
self.origin_x = readcoord();
|
||||||
self.origin_y = readcoord();
|
self.origin_y = readcoord();
|
||||||
|
@ -558,8 +556,12 @@ noref void(float isnew) CSQC_Ent_Update =
|
||||||
self.modelindex = readshort();
|
self.modelindex = readshort();
|
||||||
self.frame = readbyte();
|
self.frame = readbyte();
|
||||||
self.movetype = readshort();
|
self.movetype = readshort();
|
||||||
self.flags = readfloat();
|
self.flags = readshort();
|
||||||
self.stance = readbyte();
|
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)
|
if (self.movetype == MOVETYPE_TOSS)
|
||||||
self.solid = SOLID_NOT;
|
self.solid = SOLID_NOT;
|
||||||
|
@ -1457,20 +1459,20 @@ noref void() CSQC_Parse_Event =
|
||||||
revive_icons[reviveoff_id].draw = false;
|
revive_icons[reviveoff_id].draw = false;
|
||||||
active_revive_icons--;
|
active_revive_icons--;
|
||||||
break;
|
break;
|
||||||
case EVENT_POINTUPDATE:
|
// case EVENT_POINTUPDATE:
|
||||||
float playernum = readbyte();
|
// float playernum = readbyte();
|
||||||
float temppoints = readlong();
|
// float temppoints = readlong();
|
||||||
RegisterPointChange(readlong(), playernum);
|
// RegisterPointChange(readlong(), playernum);
|
||||||
float tempkills = readlong();
|
// float tempkills = readlong();
|
||||||
string tempname = readstring();
|
// string tempname = readstring();
|
||||||
|
|
||||||
switch(playernum) {
|
// switch(playernum) {
|
||||||
case 1: playerpoints[0] = temppoints; playerkills[0] = tempkills; playernames[0] = tempname; break;
|
// 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 2: playerpoints[1] = temppoints; playerkills[1] = tempkills; playernames[1] = tempname; break;
|
||||||
case 3: playerpoints[2] = temppoints; playerkills[2] = tempkills; playernames[2] = 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;
|
// case 4: playerpoints[3] = temppoints; playerkills[3] = tempkills; playernames[3] = tempname; break;
|
||||||
}
|
// }
|
||||||
break;
|
// break;
|
||||||
case EVENT_BLACKOUT:
|
case EVENT_BLACKOUT:
|
||||||
fade_time = readbyte();
|
fade_time = readbyte();
|
||||||
fade_type = readbyte();
|
fade_type = readbyte();
|
||||||
|
|
|
@ -264,35 +264,6 @@ void(float broadcast_time, float type, string str) BroadcastMessage =
|
||||||
#endif // FTE
|
#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 = {
|
void(float count) UpdatePlayerCount = {
|
||||||
#ifdef FTE
|
#ifdef FTE
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
|
@ -567,14 +538,10 @@ float Player_SendEntity( entity ePVEnt, float flChanged ) {
|
||||||
WriteShort( MSG_ENTITY, self.modelindex ); // Player Model
|
WriteShort( MSG_ENTITY, self.modelindex ); // Player Model
|
||||||
WriteByte( MSG_ENTITY, self.frame ); // Player's Frame
|
WriteByte( MSG_ENTITY, self.frame ); // Player's Frame
|
||||||
WriteShort( MSG_ENTITY, self.movetype ); // Player Movetype
|
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
|
WriteByte( MSG_ENTITY, self.stance ); // Player Stance
|
||||||
// WriteCoord( MSG_ENTITY, self.mins_x ); // Min Size X
|
WriteFloat( MSG_ENTITY, self.points ); // Player Score
|
||||||
// WriteCoord( MSG_ENTITY, self.mins_y ); // Min Size Y
|
WriteShort( MSG_ENTITY, self.kills ); // Player Kills
|
||||||
// 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
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -715,8 +682,6 @@ void(entity person, float expamt, float doublepoint) addmoney =
|
||||||
total_powerup_points += expamt;
|
total_powerup_points += expamt;
|
||||||
|
|
||||||
person.points += expamt;
|
person.points += expamt;
|
||||||
|
|
||||||
UpdatePlayerPoints(person.playernum, person.points, expamt, person.kills, person.netname, person);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
float(entity them, entity me) PlayerIsLooking =
|
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()
|
// Player_PickSpawnPoint()
|
||||||
// Picks a valid spawn point for the
|
// Picks a valid spawn point for the
|
||||||
|
@ -839,7 +821,6 @@ void() PlayerSpawn =
|
||||||
|
|
||||||
#ifdef FTE
|
#ifdef FTE
|
||||||
|
|
||||||
PollPlayerPoints();
|
|
||||||
UpdateV2model("", 0);
|
UpdateV2model("", 0);
|
||||||
stuffcmd(self, "cl_gunx 8;cl_guny 16;cl_gunz 25\n");
|
stuffcmd(self, "cl_gunx 8;cl_guny 16;cl_gunz 25\n");
|
||||||
SetRound(self, G_STARTROUND);
|
SetRound(self, G_STARTROUND);
|
||||||
|
|
Loading…
Reference in a new issue