Fix help computer and inventory updates when already opened

These changes ware originally committed by svdijk into baseq2
as reveison 6f6c9a1 to 20110fa.
This commit is contained in:
Yamagi Burmeister 2014-02-22 13:14:02 +01:00
parent f321c100d6
commit 926c38ac1b
6 changed files with 97 additions and 82 deletions

View file

@ -600,10 +600,66 @@ Cmd_Drop_f(edict_t *ent)
it->drop(ent, it);
}
void
Cmd_Score_f(edict_t *ent)
{
if (!ent)
{
return;
}
ent->client->showinventory = false;
ent->client->showhelp = false;
if (!deathmatch->value && !coop->value)
{
return;
}
if (ent->client->showscores)
{
ent->client->showscores = false;
return;
}
ent->client->showscores = true;
DeathmatchScoreboardMessage(ent, ent->enemy);
gi.unicast(ent, true);
}
void
Cmd_Help_f(edict_t *ent)
{
if (!ent)
{
return;
}
/* this is for backwards compatability */
if (deathmatch->value)
{
Cmd_Score_f(ent);
return;
}
ent->client->showinventory = false;
ent->client->showscores = false;
if (ent->client->showhelp)
{
ent->client->showhelp = false;
return;
}
ent->client->showhelp = true;
ent->client->pers.helpchanged = 0;
HelpComputerMessage(ent);
gi.unicast(ent, true);
}
void
Cmd_Inven_f(edict_t *ent)
{
int i;
gclient_t *cl;
if (!ent)
@ -623,14 +679,8 @@ Cmd_Inven_f(edict_t *ent)
}
cl->showinventory = true;
gi.WriteByte(svc_inventory);
for (i = 0; i < MAX_ITEMS; i++)
{
gi.WriteShort(cl->pers.inventory[i]);
}
InventoryMessage(ent);
gi.unicast(ent, true);
}

View file

@ -663,7 +663,6 @@ extern gitem_t itemlist[];
/* g_cmds.c */
void Cmd_Help_f(edict_t *ent);
void Cmd_Score_f(edict_t *ent);
/* g_items.c */
void PrecacheItem(gitem_t *it);
@ -862,6 +861,8 @@ void G_SetSpectatorStats(edict_t *ent);
void G_CheckChaseStats(edict_t *ent);
void ValidateSelectedItem(edict_t *ent);
void DeathmatchScoreboardMessage(edict_t *client, edict_t *killer);
void HelpComputerMessage(edict_t *client);
void InventoryMessage(edict_t *client);
/* g_pweapon.c */
void PlayerNoise(edict_t *who, vec3_t where, int type);

View file

@ -179,7 +179,7 @@ BeginIntermission(edict_t *targ)
}
void
DeathmatchScoreboardMessage(edict_t *ent, edict_t *killer)
DeathmatchScoreboardMessage(edict_t *ent, edict_t *killer /* can be NULL */)
{
char entry[1024];
char string[1400];
@ -193,7 +193,7 @@ DeathmatchScoreboardMessage(edict_t *ent, edict_t *killer)
edict_t *cl_ent;
char *tag;
if (!ent || !killer)
if (!ent)
{
return;
}
@ -306,55 +306,11 @@ DeathmatchScoreboardMessage(edict_t *ent, edict_t *killer)
gi.WriteString(string);
}
/*
* Draw instead of help message.
*/
void
DeathmatchScoreboard(edict_t *ent)
{
if (!ent)
{
return;
}
DeathmatchScoreboardMessage(ent, ent->enemy);
gi.unicast(ent, true);
}
/*
* Display the scoreboard
*/
void
Cmd_Score_f(edict_t *ent)
{
if (!ent)
{
return;
}
ent->client->showinventory = false;
ent->client->showhelp = false;
if (!deathmatch->value && !coop->value)
{
return;
}
if (ent->client->showscores)
{
ent->client->showscores = false;
return;
}
ent->client->showscores = true;
DeathmatchScoreboard(ent);
}
/*
* Draw help computer.
*/
void
HelpComputer(edict_t *ent)
HelpComputerMessage(edict_t *ent)
{
char string[1024];
char *sk;
@ -399,34 +355,27 @@ HelpComputer(edict_t *ent)
gi.WriteByte(svc_layout);
gi.WriteString(string);
gi.unicast(ent, true);
}
/*
* Display the current help message
*/
void
Cmd_Help_f(edict_t *ent)
InventoryMessage(edict_t *ent)
{
/* this is for backwards compatability */
if (deathmatch->value)
int i;
if (!ent)
{
Cmd_Score_f(ent);
return;
}
ent->client->showinventory = false;
ent->client->showscores = false;
gi.WriteByte(svc_inventory);
if (ent->client->showhelp && (ent->client->pers.game_helpchanged == game.helpchanged))
for (i = 0; i < MAX_ITEMS; i++)
{
ent->client->showhelp = false;
return;
gi.WriteShort(ent->client->pers.inventory[i]);
}
ent->client->showhelp = true;
ent->client->pers.helpchanged = 0;
HelpComputer(ent);
}
/* ======================================================================= */

View file

@ -1421,10 +1421,28 @@ ClientEndServerFrame(edict_t *ent)
VectorClear(ent->client->kick_origin);
VectorClear(ent->client->kick_angles);
/* if the scoreboard is up, update it */
if (ent->client->showscores && !(level.framenum & 31))
if (!(level.framenum & 31))
{
DeathmatchScoreboardMessage(ent, ent->enemy);
/* if the scoreboard is up, update it */
if (ent->client->showscores)
{
DeathmatchScoreboardMessage(ent, ent->enemy);
gi.unicast(ent, false);
}
/* if the help computer is up, update it */
if (ent->client->showhelp)
{
ent->client->pers.helpchanged = 0;
HelpComputerMessage(ent);
gi.unicast(ent, false);
}
}
/* if the inventory is up, update it */
if (ent->client->showinventory)
{
InventoryMessage(ent);
gi.unicast(ent, false);
}
}

View file

@ -148,10 +148,8 @@ extern void PlayerTrail_Init ( void ) ;
extern void G_SetSpectatorStats ( edict_t * ent ) ;
extern void G_CheckChaseStats ( edict_t * ent ) ;
extern void G_SetStats ( edict_t * ent ) ;
extern void Cmd_Help_f ( edict_t * ent ) ;
extern void HelpComputer ( edict_t * ent ) ;
extern void Cmd_Score_f ( edict_t * ent ) ;
extern void DeathmatchScoreboard ( edict_t * ent ) ;
extern void InventoryMessage ( edict_t * ent ) ;
extern void HelpComputerMessage ( edict_t * ent ) ;
extern void DeathmatchScoreboardMessage ( edict_t * ent , edict_t * killer ) ;
extern void BeginIntermission ( edict_t * targ ) ;
extern void MoveClientToIntermission ( edict_t * ent ) ;

View file

@ -148,10 +148,8 @@
{"G_SetSpectatorStats", (byte *)G_SetSpectatorStats},
{"G_CheckChaseStats", (byte *)G_CheckChaseStats},
{"G_SetStats", (byte *)G_SetStats},
{"Cmd_Help_f", (byte *)Cmd_Help_f},
{"HelpComputer", (byte *)HelpComputer},
{"Cmd_Score_f", (byte *)Cmd_Score_f},
{"DeathmatchScoreboard", (byte *)DeathmatchScoreboard},
{"InventoryMessage", (byte *)InventoryMessage},
{"HelpComputerMessage", (byte *)HelpComputerMessage},
{"DeathmatchScoreboardMessage", (byte *)DeathmatchScoreboardMessage},
{"BeginIntermission", (byte *)BeginIntermission},
{"MoveClientToIntermission", (byte *)MoveClientToIntermission},
@ -1419,6 +1417,7 @@
{"Cmd_WeapPrev_f", (byte *)Cmd_WeapPrev_f},
{"Cmd_InvUse_f", (byte *)Cmd_InvUse_f},
{"Cmd_Inven_f", (byte *)Cmd_Inven_f},
{"Cmd_Help_f", (byte *)Cmd_Help_f},
{"Cmd_Drop_f", (byte *)Cmd_Drop_f},
{"Cmd_Use_f", (byte *)Cmd_Use_f},
{"Cmd_Noclip_f", (byte *)Cmd_Noclip_f},