mirror of
https://github.com/yquake2/rogue.git
synced 2024-11-26 06:00:50 +00:00
Cleanup hud.c and add sanity checks
This commit is contained in:
parent
d8c6aae783
commit
174a7b42bc
1 changed files with 368 additions and 276 deletions
644
src/player/hud.c
644
src/player/hud.c
|
@ -1,30 +1,29 @@
|
||||||
#include "../header/local.h"
|
#include "../header/local.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
MoveClientToIntermission(edict_t *ent)
|
||||||
/*
|
{
|
||||||
======================================================================
|
if (!ent)
|
||||||
|
{
|
||||||
INTERMISSION
|
return;
|
||||||
|
}
|
||||||
======================================================================
|
|
||||||
*/
|
|
||||||
|
|
||||||
void MoveClientToIntermission (edict_t *ent)
|
|
||||||
{
|
|
||||||
if (deathmatch->value || coop->value)
|
if (deathmatch->value || coop->value)
|
||||||
|
{
|
||||||
ent->client->showscores = true;
|
ent->client->showscores = true;
|
||||||
VectorCopy (level.intermission_origin, ent->s.origin);
|
}
|
||||||
ent->client->ps.pmove.origin[0] = level.intermission_origin[0]*8;
|
|
||||||
ent->client->ps.pmove.origin[1] = level.intermission_origin[1]*8;
|
VectorCopy(level.intermission_origin, ent->s.origin);
|
||||||
ent->client->ps.pmove.origin[2] = level.intermission_origin[2]*8;
|
ent->client->ps.pmove.origin[0] = level.intermission_origin[0] * 8;
|
||||||
VectorCopy (level.intermission_angle, ent->client->ps.viewangles);
|
ent->client->ps.pmove.origin[1] = level.intermission_origin[1] * 8;
|
||||||
|
ent->client->ps.pmove.origin[2] = level.intermission_origin[2] * 8;
|
||||||
|
VectorCopy(level.intermission_angle, ent->client->ps.viewangles);
|
||||||
ent->client->ps.pmove.pm_type = PM_FREEZE;
|
ent->client->ps.pmove.pm_type = PM_FREEZE;
|
||||||
ent->client->ps.gunindex = 0;
|
ent->client->ps.gunindex = 0;
|
||||||
ent->client->ps.blend[3] = 0;
|
ent->client->ps.blend[3] = 0;
|
||||||
ent->client->ps.rdflags &= ~RDF_UNDERWATER;
|
ent->client->ps.rdflags &= ~RDF_UNDERWATER;
|
||||||
|
|
||||||
// clean up powerup info
|
/* clean up powerup info */
|
||||||
ent->client->quad_framenum = 0;
|
ent->client->quad_framenum = 0;
|
||||||
ent->client->invincible_framenum = 0;
|
ent->client->invincible_framenum = 0;
|
||||||
ent->client->breather_framenum = 0;
|
ent->client->breather_framenum = 0;
|
||||||
|
@ -32,10 +31,10 @@ void MoveClientToIntermission (edict_t *ent)
|
||||||
ent->client->grenade_blew_up = false;
|
ent->client->grenade_blew_up = false;
|
||||||
ent->client->grenade_time = 0;
|
ent->client->grenade_time = 0;
|
||||||
|
|
||||||
ent->client->ps.rdflags &= ~RDF_IRGOGGLES; // PGM
|
ent->client->ps.rdflags &= ~RDF_IRGOGGLES;
|
||||||
ent->client->ir_framenum = 0; // PGM
|
ent->client->ir_framenum = 0;
|
||||||
ent->client->nuke_framenum = 0; // PMM
|
ent->client->nuke_framenum = 0;
|
||||||
ent->client->double_framenum = 0; // PMM
|
ent->client->double_framenum = 0;
|
||||||
|
|
||||||
ent->viewheight = 0;
|
ent->viewheight = 0;
|
||||||
ent->s.modelindex = 0;
|
ent->s.modelindex = 0;
|
||||||
|
@ -46,34 +45,46 @@ void MoveClientToIntermission (edict_t *ent)
|
||||||
ent->s.sound = 0;
|
ent->s.sound = 0;
|
||||||
ent->solid = SOLID_NOT;
|
ent->solid = SOLID_NOT;
|
||||||
|
|
||||||
// add the layout
|
/* add the layout */
|
||||||
|
|
||||||
if (deathmatch->value || coop->value)
|
if (deathmatch->value || coop->value)
|
||||||
{
|
{
|
||||||
DeathmatchScoreboardMessage (ent, NULL);
|
DeathmatchScoreboardMessage(ent, NULL);
|
||||||
gi.unicast (ent, true);
|
gi.unicast(ent, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BeginIntermission (edict_t *targ)
|
void
|
||||||
|
BeginIntermission(edict_t *targ)
|
||||||
{
|
{
|
||||||
int i, n;
|
int i, n;
|
||||||
edict_t *ent, *client;
|
edict_t *ent, *client;
|
||||||
|
|
||||||
|
if (!targ)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (level.intermissiontime)
|
if (level.intermissiontime)
|
||||||
return; // already activated
|
{
|
||||||
|
return; /* already activated */
|
||||||
|
}
|
||||||
|
|
||||||
game.autosaved = false;
|
game.autosaved = false;
|
||||||
|
|
||||||
// respawn any dead clients
|
/* respawn any dead clients */
|
||||||
for (i=0 ; i<maxclients->value ; i++)
|
for (i = 0; i < maxclients->value; i++)
|
||||||
{
|
{
|
||||||
client = g_edicts + 1 + i;
|
client = g_edicts + 1 + i;
|
||||||
|
|
||||||
if (!client->inuse)
|
if (!client->inuse)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (client->health <= 0)
|
if (client->health <= 0)
|
||||||
|
{
|
||||||
respawn(client);
|
respawn(client);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
level.intermissiontime = level.time;
|
level.intermissiontime = level.time;
|
||||||
|
@ -83,16 +94,22 @@ void BeginIntermission (edict_t *targ)
|
||||||
{
|
{
|
||||||
if (coop->value)
|
if (coop->value)
|
||||||
{
|
{
|
||||||
for (i=0 ; i<maxclients->value ; i++)
|
for (i = 0; i < maxclients->value; i++)
|
||||||
{
|
{
|
||||||
client = g_edicts + 1 + i;
|
client = g_edicts + 1 + i;
|
||||||
|
|
||||||
if (!client->inuse)
|
if (!client->inuse)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
// strip players of all keys between units
|
}
|
||||||
|
|
||||||
|
/* strip players of all keys between units */
|
||||||
for (n = 0; n < MAX_ITEMS; n++)
|
for (n = 0; n < MAX_ITEMS; n++)
|
||||||
{
|
{
|
||||||
if (itemlist[n].flags & IT_KEY)
|
if (itemlist[n].flags & IT_KEY)
|
||||||
|
{
|
||||||
client->client->pers.inventory[n] = 0;
|
client->client->pers.inventory[n] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,181 +118,220 @@ void BeginIntermission (edict_t *targ)
|
||||||
{
|
{
|
||||||
if (!deathmatch->value)
|
if (!deathmatch->value)
|
||||||
{
|
{
|
||||||
level.exitintermission = 1; // go immediately to the next level
|
level.exitintermission = 1; /* go immediately to the next level */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
level.exitintermission = 0;
|
level.exitintermission = 0;
|
||||||
|
|
||||||
// find an intermission spot
|
/* find an intermission spot */
|
||||||
ent = G_Find (NULL, FOFS(classname), "info_player_intermission");
|
ent = G_Find(NULL, FOFS(classname), "info_player_intermission");
|
||||||
|
|
||||||
if (!ent)
|
if (!ent)
|
||||||
{ // the map creator forgot to put in an intermission point...
|
{
|
||||||
ent = G_Find (NULL, FOFS(classname), "info_player_start");
|
/* the map creator forgot to put in an intermission point... */
|
||||||
|
ent = G_Find(NULL, FOFS(classname), "info_player_start");
|
||||||
|
|
||||||
if (!ent)
|
if (!ent)
|
||||||
ent = G_Find (NULL, FOFS(classname), "info_player_deathmatch");
|
{
|
||||||
|
ent = G_Find(NULL, FOFS(classname), "info_player_deathmatch");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // chose one of four spots
|
{
|
||||||
|
/* chose one of four spots */
|
||||||
i = rand() & 3;
|
i = rand() & 3;
|
||||||
|
|
||||||
while (i--)
|
while (i--)
|
||||||
{
|
{
|
||||||
ent = G_Find (ent, FOFS(classname), "info_player_intermission");
|
ent = G_Find(ent, FOFS(classname), "info_player_intermission");
|
||||||
if (!ent) // wrap around the list
|
|
||||||
ent = G_Find (ent, FOFS(classname), "info_player_intermission");
|
if (!ent) /* wrap around the list */
|
||||||
|
{
|
||||||
|
ent = G_Find(ent, FOFS(classname), "info_player_intermission");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VectorCopy (ent->s.origin, level.intermission_origin);
|
VectorCopy(ent->s.origin, level.intermission_origin);
|
||||||
VectorCopy (ent->s.angles, level.intermission_angle);
|
VectorCopy(ent->s.angles, level.intermission_angle);
|
||||||
|
|
||||||
// move all clients to the intermission point
|
/* move all clients to the intermission point */
|
||||||
for (i=0 ; i<maxclients->value ; i++)
|
for (i = 0; i < maxclients->value; i++)
|
||||||
{
|
{
|
||||||
client = g_edicts + 1 + i;
|
client = g_edicts + 1 + i;
|
||||||
|
|
||||||
if (!client->inuse)
|
if (!client->inuse)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
MoveClientToIntermission (client);
|
}
|
||||||
|
|
||||||
|
MoveClientToIntermission(client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
/*
|
DeathmatchScoreboardMessage(edict_t *ent, edict_t *killer)
|
||||||
==================
|
|
||||||
DeathmatchScoreboardMessage
|
|
||||||
|
|
||||||
==================
|
|
||||||
*/
|
|
||||||
void DeathmatchScoreboardMessage (edict_t *ent, edict_t *killer)
|
|
||||||
{
|
{
|
||||||
char entry[1024];
|
char entry[1024];
|
||||||
char string[1400];
|
char string[1400];
|
||||||
int stringlength;
|
int stringlength;
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
int sorted[MAX_CLIENTS];
|
int sorted[MAX_CLIENTS];
|
||||||
int sortedscores[MAX_CLIENTS];
|
int sortedscores[MAX_CLIENTS];
|
||||||
int score, total;
|
int score, total;
|
||||||
int x, y;
|
int x, y;
|
||||||
gclient_t *cl;
|
gclient_t *cl;
|
||||||
edict_t *cl_ent;
|
edict_t *cl_ent;
|
||||||
char *tag;
|
char *tag;
|
||||||
|
|
||||||
// sort the clients by score
|
if (!ent || !killer)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* sort the clients by score */
|
||||||
total = 0;
|
total = 0;
|
||||||
for (i=0 ; i<game.maxclients ; i++)
|
|
||||||
|
for (i = 0; i < game.maxclients; i++)
|
||||||
{
|
{
|
||||||
cl_ent = g_edicts + 1 + i;
|
cl_ent = g_edicts + 1 + i;
|
||||||
|
|
||||||
if (!cl_ent->inuse || game.clients[i].resp.spectator)
|
if (!cl_ent->inuse || game.clients[i].resp.spectator)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
score = game.clients[i].resp.score;
|
score = game.clients[i].resp.score;
|
||||||
for (j=0 ; j<total ; j++)
|
|
||||||
|
for (j = 0; j < total; j++)
|
||||||
{
|
{
|
||||||
if (score > sortedscores[j])
|
if (score > sortedscores[j])
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (k=total ; k>j ; k--)
|
|
||||||
|
for (k = total; k > j; k--)
|
||||||
{
|
{
|
||||||
sorted[k] = sorted[k-1];
|
sorted[k] = sorted[k - 1];
|
||||||
sortedscores[k] = sortedscores[k-1];
|
sortedscores[k] = sortedscores[k - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
sorted[j] = i;
|
sorted[j] = i;
|
||||||
sortedscores[j] = score;
|
sortedscores[j] = score;
|
||||||
total++;
|
total++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// print level name and exit rules
|
/* print level name and exit rules */
|
||||||
string[0] = 0;
|
string[0] = 0;
|
||||||
|
|
||||||
stringlength = strlen(string);
|
stringlength = strlen(string);
|
||||||
|
|
||||||
// add the clients in sorted order
|
/* add the clients in sorted order */
|
||||||
if (total > 12)
|
if (total > 12)
|
||||||
|
{
|
||||||
total = 12;
|
total = 12;
|
||||||
|
}
|
||||||
|
|
||||||
for (i=0 ; i<total ; i++)
|
for (i = 0; i < total; i++)
|
||||||
{
|
{
|
||||||
cl = &game.clients[sorted[i]];
|
cl = &game.clients[sorted[i]];
|
||||||
cl_ent = g_edicts + 1 + sorted[i];
|
cl_ent = g_edicts + 1 + sorted[i];
|
||||||
|
|
||||||
x = (i>=6) ? 160 : 0;
|
x = (i >= 6) ? 160 : 0;
|
||||||
y = 32 + 32 * (i%6);
|
y = 32 + 32 * (i % 6);
|
||||||
|
|
||||||
// add a dogtag
|
/* add a dogtag */
|
||||||
if (cl_ent == ent)
|
if (cl_ent == ent)
|
||||||
|
{
|
||||||
tag = "tag1";
|
tag = "tag1";
|
||||||
|
}
|
||||||
else if (cl_ent == killer)
|
else if (cl_ent == killer)
|
||||||
|
{
|
||||||
tag = "tag2";
|
tag = "tag2";
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
tag = NULL;
|
tag = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
//===============
|
/* allow new DM games to override the tag picture */
|
||||||
//ROGUE
|
|
||||||
// allow new DM games to override the tag picture
|
|
||||||
if (gamerules && gamerules->value)
|
if (gamerules && gamerules->value)
|
||||||
{
|
{
|
||||||
if(DMGame.DogTag)
|
if (DMGame.DogTag)
|
||||||
|
{
|
||||||
DMGame.DogTag(cl_ent, killer, &tag);
|
DMGame.DogTag(cl_ent, killer, &tag);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//ROGUE
|
|
||||||
//===============
|
|
||||||
|
|
||||||
if (tag)
|
if (tag)
|
||||||
{
|
{
|
||||||
Com_sprintf (entry, sizeof(entry),
|
Com_sprintf(entry, sizeof(entry), "xv %i yv %i picn %s ", x + 32, y, tag);
|
||||||
"xv %i yv %i picn %s ",x+32, y, tag);
|
|
||||||
j = strlen(entry);
|
j = strlen(entry);
|
||||||
|
|
||||||
if (stringlength + j > 1024)
|
if (stringlength + j > 1024)
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
strcpy (string + stringlength, entry);
|
}
|
||||||
|
|
||||||
|
strcpy(string + stringlength, entry);
|
||||||
stringlength += j;
|
stringlength += j;
|
||||||
}
|
}
|
||||||
|
|
||||||
// send the layout
|
/* send the layout */
|
||||||
Com_sprintf (entry, sizeof(entry),
|
Com_sprintf(entry, sizeof(entry), "client %i %i %i %i %i %i ",
|
||||||
"client %i %i %i %i %i %i ",
|
x, y, sorted[i], cl->resp.score, cl->ping,
|
||||||
x, y, sorted[i], cl->resp.score, cl->ping, (level.framenum - cl->resp.enterframe)/600);
|
(level.framenum - cl->resp.enterframe) / 600);
|
||||||
j = strlen(entry);
|
j = strlen(entry);
|
||||||
|
|
||||||
if (stringlength + j > 1024)
|
if (stringlength + j > 1024)
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
strcpy (string + stringlength, entry);
|
}
|
||||||
|
|
||||||
|
strcpy(string + stringlength, entry);
|
||||||
stringlength += j;
|
stringlength += j;
|
||||||
}
|
}
|
||||||
|
|
||||||
gi.WriteByte (svc_layout);
|
gi.WriteByte(svc_layout);
|
||||||
gi.WriteString (string);
|
gi.WriteString(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==================
|
* Draw instead of help message.
|
||||||
DeathmatchScoreboard
|
*/
|
||||||
|
void
|
||||||
Draw instead of help message.
|
DeathmatchScoreboard(edict_t *ent)
|
||||||
Note that it isn't that hard to overflow the 1400 byte message limit!
|
{
|
||||||
==================
|
if (!ent)
|
||||||
*/
|
{
|
||||||
void DeathmatchScoreboard (edict_t *ent)
|
return;
|
||||||
{
|
}
|
||||||
DeathmatchScoreboardMessage (ent, ent->enemy);
|
|
||||||
gi.unicast (ent, true);
|
DeathmatchScoreboardMessage(ent, ent->enemy);
|
||||||
|
gi.unicast(ent, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==================
|
* Display the scoreboard
|
||||||
Cmd_Score_f
|
*/
|
||||||
|
void
|
||||||
Display the scoreboard
|
Cmd_Score_f(edict_t *ent)
|
||||||
==================
|
{
|
||||||
*/
|
if (!ent)
|
||||||
void Cmd_Score_f (edict_t *ent)
|
{
|
||||||
{
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ent->client->showinventory = false;
|
ent->client->showinventory = false;
|
||||||
ent->client->showhelp = false;
|
ent->client->showhelp = false;
|
||||||
|
|
||||||
if (!deathmatch->value && !coop->value)
|
if (!deathmatch->value && !coop->value)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (ent->client->showscores)
|
if (ent->client->showscores)
|
||||||
{
|
{
|
||||||
|
@ -284,67 +340,71 @@ void Cmd_Score_f (edict_t *ent)
|
||||||
}
|
}
|
||||||
|
|
||||||
ent->client->showscores = true;
|
ent->client->showscores = true;
|
||||||
DeathmatchScoreboard (ent);
|
DeathmatchScoreboard(ent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==================
|
* Draw help computer.
|
||||||
HelpComputer
|
*/
|
||||||
|
void
|
||||||
Draw help computer.
|
HelpComputer(edict_t *ent)
|
||||||
==================
|
|
||||||
*/
|
|
||||||
void HelpComputer (edict_t *ent)
|
|
||||||
{
|
{
|
||||||
char string[1024];
|
char string[1024];
|
||||||
char *sk;
|
char *sk;
|
||||||
|
|
||||||
|
if (!ent)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (skill->value == 0)
|
if (skill->value == 0)
|
||||||
|
{
|
||||||
sk = "easy";
|
sk = "easy";
|
||||||
|
}
|
||||||
else if (skill->value == 1)
|
else if (skill->value == 1)
|
||||||
|
{
|
||||||
sk = "medium";
|
sk = "medium";
|
||||||
|
}
|
||||||
else if (skill->value == 2)
|
else if (skill->value == 2)
|
||||||
|
{
|
||||||
sk = "hard";
|
sk = "hard";
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
sk = "hard+";
|
sk = "hard+";
|
||||||
|
}
|
||||||
|
|
||||||
// send the layout
|
/* send the layout */
|
||||||
Com_sprintf (string, sizeof(string),
|
Com_sprintf(string, sizeof(string),
|
||||||
"xv 32 yv 8 picn help " // background
|
"xv 32 yv 8 picn help " /* background */
|
||||||
"xv 202 yv 12 string2 \"%s\" " // skill
|
"xv 202 yv 12 string2 \"%s\" " /* skill */
|
||||||
"xv 0 yv 24 cstring2 \"%s\" " // level name
|
"xv 0 yv 24 cstring2 \"%s\" " /* level name */
|
||||||
"xv 0 yv 54 cstring2 \"%s\" " // help 1
|
"xv 0 yv 54 cstring2 \"%s\" " /* help 1 */
|
||||||
"xv 0 yv 110 cstring2 \"%s\" " // help 2
|
"xv 0 yv 110 cstring2 \"%s\" " /* help 2 */
|
||||||
"xv 50 yv 164 string2 \" kills goals secrets\" "
|
"xv 50 yv 164 string2 \" kills goals secrets\" "
|
||||||
"xv 50 yv 172 string2 \"%3i/%3i %i/%i %i/%i\" ",
|
"xv 50 yv 172 string2 \"%3i/%3i %i/%i %i/%i\" ",
|
||||||
sk,
|
sk, level.level_name,
|
||||||
level.level_name,
|
game.helpmessage1,
|
||||||
game.helpmessage1,
|
game.helpmessage2,
|
||||||
game.helpmessage2,
|
level.killed_monsters, level.total_monsters,
|
||||||
level.killed_monsters, level.total_monsters,
|
level.found_goals, level.total_goals,
|
||||||
level.found_goals, level.total_goals,
|
level.found_secrets, level.total_secrets);
|
||||||
level.found_secrets, level.total_secrets);
|
|
||||||
|
|
||||||
gi.WriteByte (svc_layout);
|
gi.WriteByte(svc_layout);
|
||||||
gi.WriteString (string);
|
gi.WriteString(string);
|
||||||
gi.unicast (ent, true);
|
gi.unicast(ent, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==================
|
* Display the current help message
|
||||||
Cmd_Help_f
|
*/
|
||||||
|
void
|
||||||
Display the current help message
|
Cmd_Help_f(edict_t *ent)
|
||||||
==================
|
|
||||||
*/
|
|
||||||
void Cmd_Help_f (edict_t *ent)
|
|
||||||
{
|
{
|
||||||
// this is for backwards compatability
|
/* this is for backwards compatability */
|
||||||
if (deathmatch->value)
|
if (deathmatch->value)
|
||||||
{
|
{
|
||||||
Cmd_Score_f (ent);
|
Cmd_Score_f(ent);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,33 +419,29 @@ void Cmd_Help_f (edict_t *ent)
|
||||||
|
|
||||||
ent->client->showhelp = true;
|
ent->client->showhelp = true;
|
||||||
ent->client->pers.helpchanged = 0;
|
ent->client->pers.helpchanged = 0;
|
||||||
HelpComputer (ent);
|
HelpComputer(ent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ======================================================================= */
|
||||||
|
|
||||||
//=======================================================================
|
void
|
||||||
|
G_SetStats(edict_t *ent)
|
||||||
/*
|
|
||||||
===============
|
|
||||||
G_SetStats
|
|
||||||
===============
|
|
||||||
*/
|
|
||||||
void G_SetStats (edict_t *ent)
|
|
||||||
{
|
{
|
||||||
gitem_t *item;
|
gitem_t *item;
|
||||||
int index, cells;
|
int index, cells;
|
||||||
int power_armor_type;
|
int power_armor_type;
|
||||||
|
|
||||||
//
|
if (!ent)
|
||||||
// health
|
{
|
||||||
//
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* health */
|
||||||
ent->client->ps.stats[STAT_HEALTH_ICON] = level.pic_health;
|
ent->client->ps.stats[STAT_HEALTH_ICON] = level.pic_health;
|
||||||
ent->client->ps.stats[STAT_HEALTH] = ent->health;
|
ent->client->ps.stats[STAT_HEALTH] = ent->health;
|
||||||
|
|
||||||
//
|
/* ammo */
|
||||||
// ammo
|
if (!ent->client->ammo_index)
|
||||||
//
|
|
||||||
if (!ent->client->ammo_index /* || !ent->client->pers.inventory[ent->client->ammo_index] */)
|
|
||||||
{
|
{
|
||||||
ent->client->ps.stats[STAT_AMMO_ICON] = 0;
|
ent->client->ps.stats[STAT_AMMO_ICON] = 0;
|
||||||
ent->client->ps.stats[STAT_AMMO] = 0;
|
ent->client->ps.stats[STAT_AMMO] = 0;
|
||||||
|
@ -393,35 +449,39 @@ void G_SetStats (edict_t *ent)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
item = &itemlist[ent->client->ammo_index];
|
item = &itemlist[ent->client->ammo_index];
|
||||||
ent->client->ps.stats[STAT_AMMO_ICON] = gi.imageindex (item->icon);
|
ent->client->ps.stats[STAT_AMMO_ICON] = gi.imageindex(item->icon);
|
||||||
ent->client->ps.stats[STAT_AMMO] = ent->client->pers.inventory[ent->client->ammo_index];
|
ent->client->ps.stats[STAT_AMMO] =
|
||||||
|
ent->client->pers.inventory[ent->client->ammo_index];
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
/* armor */
|
||||||
// armor
|
power_armor_type = PowerArmorType(ent);
|
||||||
//
|
|
||||||
power_armor_type = PowerArmorType (ent);
|
|
||||||
if (power_armor_type)
|
if (power_armor_type)
|
||||||
{
|
{
|
||||||
cells = ent->client->pers.inventory[ITEM_INDEX(FindItem ("cells"))];
|
cells = ent->client->pers.inventory[ITEM_INDEX(FindItem("cells"))];
|
||||||
|
|
||||||
if (cells == 0)
|
if (cells == 0)
|
||||||
{ // ran out of cells for power armor
|
{
|
||||||
|
/* ran out of cells for power armor */
|
||||||
ent->flags &= ~FL_POWER_ARMOR;
|
ent->flags &= ~FL_POWER_ARMOR;
|
||||||
gi.sound(ent, CHAN_ITEM, gi.soundindex("misc/power2.wav"), 1, ATTN_NORM, 0);
|
gi.sound(ent, CHAN_ITEM, gi.soundindex( "misc/power2.wav"), 1, ATTN_NORM, 0);
|
||||||
power_armor_type = 0;;
|
power_armor_type = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
index = ArmorIndex (ent);
|
index = ArmorIndex(ent);
|
||||||
if (power_armor_type && (!index || (level.framenum & 8) ) )
|
|
||||||
{ // flash between power armor and other armor icon
|
if (power_armor_type && (!index || (level.framenum & 8)))
|
||||||
ent->client->ps.stats[STAT_ARMOR_ICON] = gi.imageindex ("i_powershield");
|
{
|
||||||
|
/* flash between power armor and other armor icon */
|
||||||
|
ent->client->ps.stats[STAT_ARMOR_ICON] = gi.imageindex("i_powershield");
|
||||||
ent->client->ps.stats[STAT_ARMOR] = cells;
|
ent->client->ps.stats[STAT_ARMOR] = cells;
|
||||||
}
|
}
|
||||||
else if (index)
|
else if (index)
|
||||||
{
|
{
|
||||||
item = GetItemByIndex (index);
|
item = GetItemByIndex(index);
|
||||||
ent->client->ps.stats[STAT_ARMOR_ICON] = gi.imageindex (item->icon);
|
ent->client->ps.stats[STAT_ARMOR_ICON] = gi.imageindex(item->icon);
|
||||||
ent->client->ps.stats[STAT_ARMOR] = ent->client->pers.inventory[index];
|
ent->client->ps.stats[STAT_ARMOR] = ent->client->pers.inventory[index];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -430,176 +490,208 @@ void G_SetStats (edict_t *ent)
|
||||||
ent->client->ps.stats[STAT_ARMOR] = 0;
|
ent->client->ps.stats[STAT_ARMOR] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
/* pickup message */
|
||||||
// pickup message
|
|
||||||
//
|
|
||||||
if (level.time > ent->client->pickup_msg_time)
|
if (level.time > ent->client->pickup_msg_time)
|
||||||
{
|
{
|
||||||
ent->client->ps.stats[STAT_PICKUP_ICON] = 0;
|
ent->client->ps.stats[STAT_PICKUP_ICON] = 0;
|
||||||
ent->client->ps.stats[STAT_PICKUP_STRING] = 0;
|
ent->client->ps.stats[STAT_PICKUP_STRING] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
/* timers */
|
||||||
// timers
|
|
||||||
//
|
|
||||||
if (ent->client->quad_framenum > level.framenum)
|
if (ent->client->quad_framenum > level.framenum)
|
||||||
{
|
{
|
||||||
ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex ("p_quad");
|
ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex("p_quad");
|
||||||
ent->client->ps.stats[STAT_TIMER] = (ent->client->quad_framenum - level.framenum)/10;
|
ent->client->ps.stats[STAT_TIMER] = (ent->client->quad_framenum - level.framenum) / 10;
|
||||||
}
|
}
|
||||||
// PMM
|
|
||||||
else if (ent->client->double_framenum > level.framenum)
|
else if (ent->client->double_framenum > level.framenum)
|
||||||
{
|
{
|
||||||
ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex ("p_double");
|
ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex("p_double");
|
||||||
ent->client->ps.stats[STAT_TIMER] = (ent->client->double_framenum - level.framenum)/10;
|
ent->client->ps.stats[STAT_TIMER] =
|
||||||
|
(ent->client->double_framenum - level.framenum) / 10;
|
||||||
}
|
}
|
||||||
// PMM
|
|
||||||
else if (ent->client->invincible_framenum > level.framenum)
|
else if (ent->client->invincible_framenum > level.framenum)
|
||||||
{
|
{
|
||||||
ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex ("p_invulnerability");
|
ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex( "p_invulnerability");
|
||||||
ent->client->ps.stats[STAT_TIMER] = (ent->client->invincible_framenum - level.framenum)/10;
|
ent->client->ps.stats[STAT_TIMER] = (ent->client->invincible_framenum - level.framenum) / 10;
|
||||||
}
|
}
|
||||||
else if (ent->client->enviro_framenum > level.framenum)
|
else if (ent->client->enviro_framenum > level.framenum)
|
||||||
{
|
{
|
||||||
ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex ("p_envirosuit");
|
ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex("p_envirosuit");
|
||||||
ent->client->ps.stats[STAT_TIMER] = (ent->client->enviro_framenum - level.framenum)/10;
|
ent->client->ps.stats[STAT_TIMER] = (ent->client->enviro_framenum - level.framenum) / 10;
|
||||||
}
|
}
|
||||||
else if (ent->client->breather_framenum > level.framenum)
|
else if (ent->client->breather_framenum > level.framenum)
|
||||||
{
|
{
|
||||||
ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex ("p_rebreather");
|
ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex("p_rebreather");
|
||||||
ent->client->ps.stats[STAT_TIMER] = (ent->client->breather_framenum - level.framenum)/10;
|
ent->client->ps.stats[STAT_TIMER] = (ent->client->breather_framenum - level.framenum) / 10;
|
||||||
}
|
}
|
||||||
// PGM
|
|
||||||
else if (ent->client->owned_sphere)
|
else if (ent->client->owned_sphere)
|
||||||
{
|
{
|
||||||
if(ent->client->owned_sphere->spawnflags == 1) // defender
|
if (ent->client->owned_sphere->spawnflags == 1) /* defender */
|
||||||
ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex ("p_defender");
|
{
|
||||||
else if(ent->client->owned_sphere->spawnflags == 2) // hunter
|
ent->client->ps.stats[STAT_TIMER_ICON] =
|
||||||
ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex ("p_hunter");
|
gi.imageindex("p_defender");
|
||||||
else if(ent->client->owned_sphere->spawnflags == 4) // vengeance
|
}
|
||||||
ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex ("p_vengeance");
|
else if (ent->client->owned_sphere->spawnflags == 2) /* hunter */
|
||||||
else // error case
|
{
|
||||||
ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex ("i_fixme");
|
ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex("p_hunter");
|
||||||
|
}
|
||||||
|
else if (ent->client->owned_sphere->spawnflags == 4) /* vengeance */
|
||||||
|
{
|
||||||
|
ent->client->ps.stats[STAT_TIMER_ICON] =
|
||||||
|
gi.imageindex("p_vengeance");
|
||||||
|
}
|
||||||
|
else /* error case */
|
||||||
|
{
|
||||||
|
ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex("i_fixme");
|
||||||
|
}
|
||||||
|
|
||||||
ent->client->ps.stats[STAT_TIMER] = (int)(ent->client->owned_sphere->wait - level.time);
|
ent->client->ps.stats[STAT_TIMER] =
|
||||||
|
(int)(ent->client->owned_sphere->wait - level.time);
|
||||||
}
|
}
|
||||||
else if (ent->client->ir_framenum > level.framenum)
|
else if (ent->client->ir_framenum > level.framenum)
|
||||||
{
|
{
|
||||||
ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex ("p_ir");
|
ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex("p_ir");
|
||||||
ent->client->ps.stats[STAT_TIMER] = (ent->client->ir_framenum - level.framenum)/10;
|
ent->client->ps.stats[STAT_TIMER] =
|
||||||
}
|
(ent->client->ir_framenum - level.framenum) / 10; }
|
||||||
// PGM
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ent->client->ps.stats[STAT_TIMER_ICON] = 0;
|
ent->client->ps.stats[STAT_TIMER_ICON] = 0;
|
||||||
ent->client->ps.stats[STAT_TIMER] = 0;
|
ent->client->ps.stats[STAT_TIMER] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
/* selected item */
|
||||||
// selected item
|
|
||||||
//
|
|
||||||
if (ent->client->pers.selected_item == -1)
|
if (ent->client->pers.selected_item == -1)
|
||||||
|
{
|
||||||
ent->client->ps.stats[STAT_SELECTED_ICON] = 0;
|
ent->client->ps.stats[STAT_SELECTED_ICON] = 0;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
ent->client->ps.stats[STAT_SELECTED_ICON] = gi.imageindex (itemlist[ent->client->pers.selected_item].icon);
|
{
|
||||||
|
ent->client->ps.stats[STAT_SELECTED_ICON] = gi.imageindex(itemlist[ent->client->pers.selected_item].icon);
|
||||||
|
}
|
||||||
|
|
||||||
ent->client->ps.stats[STAT_SELECTED_ITEM] = ent->client->pers.selected_item;
|
ent->client->ps.stats[STAT_SELECTED_ITEM] = ent->client->pers.selected_item;
|
||||||
|
|
||||||
//
|
/* layouts */
|
||||||
// layouts
|
|
||||||
//
|
|
||||||
ent->client->ps.stats[STAT_LAYOUTS] = 0;
|
ent->client->ps.stats[STAT_LAYOUTS] = 0;
|
||||||
|
|
||||||
if (deathmatch->value)
|
if (deathmatch->value)
|
||||||
{
|
{
|
||||||
if (ent->client->pers.health <= 0 || level.intermissiontime
|
if ((ent->client->pers.health <= 0) || level.intermissiontime || ent->client->showscores)
|
||||||
|| ent->client->showscores)
|
{
|
||||||
ent->client->ps.stats[STAT_LAYOUTS] |= 1;
|
ent->client->ps.stats[STAT_LAYOUTS] |= 1;
|
||||||
if (ent->client->showinventory && ent->client->pers.health > 0)
|
}
|
||||||
|
|
||||||
|
if (ent->client->showinventory && (ent->client->pers.health > 0))
|
||||||
|
{
|
||||||
ent->client->ps.stats[STAT_LAYOUTS] |= 2;
|
ent->client->ps.stats[STAT_LAYOUTS] |= 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (ent->client->showscores || ent->client->showhelp)
|
if (ent->client->showscores || ent->client->showhelp)
|
||||||
|
{
|
||||||
ent->client->ps.stats[STAT_LAYOUTS] |= 1;
|
ent->client->ps.stats[STAT_LAYOUTS] |= 1;
|
||||||
if (ent->client->showinventory && ent->client->pers.health > 0)
|
}
|
||||||
|
|
||||||
|
if (ent->client->showinventory && (ent->client->pers.health > 0))
|
||||||
|
{
|
||||||
ent->client->ps.stats[STAT_LAYOUTS] |= 2;
|
ent->client->ps.stats[STAT_LAYOUTS] |= 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
/* frags */
|
||||||
// frags
|
|
||||||
//
|
|
||||||
ent->client->ps.stats[STAT_FRAGS] = ent->client->resp.score;
|
ent->client->ps.stats[STAT_FRAGS] = ent->client->resp.score;
|
||||||
|
|
||||||
//
|
/* help icon / current weapon if not shown */
|
||||||
// help icon / current weapon if not shown
|
if (ent->client->pers.helpchanged && (level.framenum & 8))
|
||||||
//
|
{
|
||||||
if (ent->client->pers.helpchanged && (level.framenum&8) )
|
ent->client->ps.stats[STAT_HELPICON] = gi.imageindex("i_help");
|
||||||
ent->client->ps.stats[STAT_HELPICON] = gi.imageindex ("i_help");
|
}
|
||||||
else if ( (ent->client->pers.hand == CENTER_HANDED || ent->client->ps.fov > 91)
|
else if (((ent->client->pers.hand == CENTER_HANDED) ||
|
||||||
&& ent->client->pers.weapon)
|
(ent->client->ps.fov > 91)) && ent->client->pers.weapon)
|
||||||
{
|
{
|
||||||
cvar_t *gun;
|
cvar_t *gun;
|
||||||
gun = gi.cvar("cl_gun", "2", 0);
|
gun = gi.cvar("cl_gun", "2", 0);
|
||||||
|
|
||||||
if(gun->value != 2)
|
if (gun->value != 2)
|
||||||
ent->client->ps.stats[STAT_HELPICON] = gi.imageindex (ent->client->pers.weapon->icon);
|
{
|
||||||
|
ent->client->ps.stats[STAT_HELPICON] = gi.imageindex(ent->client->pers.weapon->icon);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
ent->client->ps.stats[STAT_HELPICON] = 0;
|
ent->client->ps.stats[STAT_HELPICON] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
ent->client->ps.stats[STAT_HELPICON] = 0;
|
ent->client->ps.stats[STAT_HELPICON] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
ent->client->ps.stats[STAT_SPECTATOR] = 0;
|
ent->client->ps.stats[STAT_SPECTATOR] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void
|
||||||
===============
|
G_CheckChaseStats(edict_t *ent)
|
||||||
G_CheckChaseStats
|
|
||||||
===============
|
|
||||||
*/
|
|
||||||
void G_CheckChaseStats (edict_t *ent)
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
gclient_t *cl;
|
gclient_t *cl;
|
||||||
|
|
||||||
|
if (!ent)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 1; i <= maxclients->value; i++)
|
for (i = 1; i <= maxclients->value; i++)
|
||||||
{
|
{
|
||||||
cl = g_edicts[i].client;
|
cl = g_edicts[i].client;
|
||||||
if (!g_edicts[i].inuse || cl->chase_target != ent)
|
|
||||||
|
if (!g_edicts[i].inuse || (cl->chase_target != ent))
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(cl->ps.stats, ent->client->ps.stats, sizeof(cl->ps.stats));
|
memcpy(cl->ps.stats, ent->client->ps.stats, sizeof(cl->ps.stats));
|
||||||
G_SetSpectatorStats(g_edicts + i);
|
G_SetSpectatorStats(g_edicts + i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void
|
||||||
===============
|
G_SetSpectatorStats(edict_t *ent)
|
||||||
G_SetSpectatorStats
|
{
|
||||||
===============
|
if (!ent)
|
||||||
*/
|
{
|
||||||
void G_SetSpectatorStats (edict_t *ent)
|
return;
|
||||||
{
|
}
|
||||||
|
|
||||||
gclient_t *cl = ent->client;
|
gclient_t *cl = ent->client;
|
||||||
|
|
||||||
if (!cl->chase_target)
|
if (!cl->chase_target)
|
||||||
G_SetStats (ent);
|
{
|
||||||
|
G_SetStats(ent);
|
||||||
|
}
|
||||||
|
|
||||||
cl->ps.stats[STAT_SPECTATOR] = 1;
|
cl->ps.stats[STAT_SPECTATOR] = 1;
|
||||||
|
|
||||||
// layouts are independant in spectator
|
/* layouts are independant in spectator */
|
||||||
cl->ps.stats[STAT_LAYOUTS] = 0;
|
cl->ps.stats[STAT_LAYOUTS] = 0;
|
||||||
if (cl->pers.health <= 0 || level.intermissiontime || cl->showscores)
|
|
||||||
|
if ((cl->pers.health <= 0) || level.intermissiontime || cl->showscores)
|
||||||
|
{
|
||||||
cl->ps.stats[STAT_LAYOUTS] |= 1;
|
cl->ps.stats[STAT_LAYOUTS] |= 1;
|
||||||
if (cl->showinventory && cl->pers.health > 0)
|
}
|
||||||
|
|
||||||
|
if (cl->showinventory && (cl->pers.health > 0))
|
||||||
|
{
|
||||||
cl->ps.stats[STAT_LAYOUTS] |= 2;
|
cl->ps.stats[STAT_LAYOUTS] |= 2;
|
||||||
|
}
|
||||||
|
|
||||||
if (cl->chase_target && cl->chase_target->inuse)
|
if (cl->chase_target && cl->chase_target->inuse)
|
||||||
{
|
{
|
||||||
cl->ps.stats[STAT_CHASE] = CS_PLAYERSKINS +
|
cl->ps.stats[STAT_CHASE] = CS_PLAYERSKINS +
|
||||||
(cl->chase_target - g_edicts) - 1;
|
(cl->chase_target - g_edicts) - 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
cl->ps.stats[STAT_CHASE] = 0;
|
cl->ps.stats[STAT_CHASE] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue