Workarounds for naggy help icons

This commit is contained in:
BjossiAlfreds 2024-07-15 22:46:01 +00:00
parent 36e9e03144
commit df596a7b44
3 changed files with 57 additions and 6 deletions

View file

@ -7,6 +7,9 @@
#include "header/local.h"
#define TARGET_HELP_PRIMARY 1
#define TARGET_HELP_THINK_DELAY 0.3f
/* QUAKED target_temp_entity (1 0 0) (-8 -8 -8) (8 8 8)
* Fire an origin based temp entity event to the clients.
*
@ -151,26 +154,72 @@ SP_target_speaker(edict_t *ent)
/* ========================================================== */
void
Use_Target_Help(edict_t *ent, edict_t *other, edict_t *activator)
static void
Target_Help_Apply(const char *msg, int is_primary)
{
if (!ent)
char *curr;
size_t sz;
if (!msg)
{
return;
}
if (ent->spawnflags & 1)
if (is_primary)
{
strncpy(game.helpmessage1, ent->message, sizeof(game.helpmessage2) - 1);
curr = game.helpmessage1;
sz = sizeof(game.helpmessage1);
}
else
{
strncpy(game.helpmessage2, ent->message, sizeof(game.helpmessage1) - 1);
curr = game.helpmessage2;
sz = sizeof(game.helpmessage2);
}
if (strcmp(curr, msg) == 0)
{
return;
}
Q_strlcpy(curr, msg, sz - 1);
game.helpchanged++;
}
void
Target_Help_Think(edict_t *ent)
{
if (!ent)
{
return;
}
Target_Help_Apply(ent->message, ent->spawnflags & TARGET_HELP_PRIMARY);
ent->think = NULL;
}
void
Use_Target_Help(edict_t *ent, edict_t *other /* unused */, edict_t *activator /* unused */)
{
if (!ent)
{
return;
}
if (level.time > TARGET_HELP_THINK_DELAY)
{
Target_Help_Apply(ent->message, ent->spawnflags & TARGET_HELP_PRIMARY);
}
else
{
/* The game is still pre-loading so delay the help message a bit,
otherwise its changes to game structure will leak past save loads
*/
ent->think = Target_Help_Think;
ent->nextthink = TARGET_HELP_THINK_DELAY;
}
}
/*
* QUAKED target_help (1 0 1) (-16 -16 -24) (16 16 24) help1
* When fired, the "message" key becomes the current personal computer string,

View file

@ -869,6 +869,7 @@ extern void SP_target_secret ( edict_t * ent ) ;
extern void use_target_secret ( edict_t * ent , edict_t * other , edict_t * activator ) ;
extern void SP_target_help ( edict_t * ent ) ;
extern void Use_Target_Help ( edict_t * ent , edict_t * other , edict_t * activator ) ;
extern void Target_Help_Think ( edict_t * ent ) ;
extern void SP_target_speaker ( edict_t * ent ) ;
extern void Use_Target_Speaker ( edict_t * ent , edict_t * other , edict_t * activator ) ;
extern void SP_target_temp_entity ( edict_t * ent ) ;

View file

@ -869,6 +869,7 @@
{"use_target_secret", (byte *)use_target_secret},
{"SP_target_help", (byte *)SP_target_help},
{"Use_Target_Help", (byte *)Use_Target_Help},
{"Target_Help_Think", (byte *)Target_Help_Think},
{"SP_target_speaker", (byte *)SP_target_speaker},
{"Use_Target_Speaker", (byte *)Use_Target_Speaker},
{"SP_target_temp_entity", (byte *)SP_target_temp_entity},