From a254cdb8bee6adacf69494d03e9812aa402a4a0c Mon Sep 17 00:00:00 2001 From: Oscar Linderholm Date: Sat, 4 Oct 2025 12:26:25 +0200 Subject: [PATCH 1/2] Add on_countdown_start event Similar to the on_match_start event, but this one fires as soon as the countdown starts instead of when the match starts. --- include/g_consts.h | 1 + include/g_local.h | 1 + src/g_utils.c | 18 ++++++++++++++++++ src/match.c | 12 ++++++++++++ 4 files changed, 32 insertions(+) diff --git a/include/g_consts.h b/include/g_consts.h index c49c52f0..4727cb9f 100644 --- a/include/g_consts.h +++ b/include/g_consts.h @@ -270,6 +270,7 @@ // ( 64) deathmatch mode change #define EV_ON_ADMIN ( 128) // admin #define EV_ON_UNADMIN ( 256) // unadmin +#define EV_ON_COUNTDOWN_START ( 512) // countdown start // CTF #define CTF_RUNE_RES 1 // IT_SIGIL1 diff --git a/include/g_local.h b/include/g_local.h index 711828f3..89d297a7 100644 --- a/include/g_local.h +++ b/include/g_local.h @@ -424,6 +424,7 @@ void on_match_end(gedict_t *p); void on_match_break(gedict_t *p); void on_admin(gedict_t *p); void on_unadmin(gedict_t *p); +void on_countdown_start(gedict_t *p); void info_ev_update(gedict_t *p, char *from, char *to); void info_kf_update(gedict_t *p, char *from, char *to); diff --git a/src/g_utils.c b/src/g_utils.c index 774a1e56..10050e7f 100644 --- a/src/g_utils.c +++ b/src/g_utils.c @@ -2576,6 +2576,23 @@ void on_unadmin(gedict_t *p) stuffcmd_flags(p, STUFFCMD_IGNOREINDEMO, "on_unadmin\n"); } +void on_countdown_start(gedict_t *p) +{ + if (!(iKey(p, "ev") & EV_ON_COUNTDOWN_START)) + { + return; + } + + if (p->ct == ctPlayer) + { + stuffcmd_flags(p, STUFFCMD_IGNOREINDEMO, "on_countdown_start\n"); + } + else + { + stuffcmd_flags(p, STUFFCMD_IGNOREINDEMO, "on_spec_countdown_start\n"); + } +} + void ev_print(gedict_t *p, int new_ev, int old_ev, int bit, char *msg) { int on; @@ -2597,6 +2614,7 @@ void info_ev_update(gedict_t *p, char *from, char *to) ev_print(p, new_ev, old_ev, EV_ON_MATCH_BREAK, "[on_matchbreak] event: "); ev_print(p, new_ev, old_ev, EV_ON_ADMIN, "[on_admin] event: "); ev_print(p, new_ev, old_ev, EV_ON_UNADMIN, "[on_unadmin] event: "); + ev_print(p, new_ev, old_ev, EV_ON_COUNTDOWN_START, "[on_countdown_start] event: "); } void info_kf_update(gedict_t *p, char *from, char *to) diff --git a/src/match.c b/src/match.c index c18d5756..f53ec78e 100644 --- a/src/match.c +++ b/src/match.c @@ -1234,6 +1234,16 @@ void SM_on_MatchStart(void) } } +void SM_on_CountdownStart(void) +{ + gedict_t *p; + + for (p = world; (p = find_client(p));) + { + on_countdown_start(p); + } +} + // Reset player frags and start the timer. void HideSpawnPoints(void); @@ -2536,6 +2546,8 @@ void StartTimer(void) localcmd("serverinfo status Countdown\n"); StartDemoRecord(); // if allowed + + SM_on_CountdownStart(); } static qbool match_can_cancel_demo(void) From ce5c15facfaf1e99f2c4f02a926fde8365e5e07f Mon Sep 17 00:00:00 2001 From: Oscar Linderholm Date: Sat, 4 Oct 2025 13:18:50 +0200 Subject: [PATCH 2/2] Add on_countdown_break event Similar to the on_countdown_start event, but this one fires when the countdown is interrupted. --- include/g_consts.h | 1 + include/g_local.h | 1 + src/g_utils.c | 18 ++++++++++++++++++ src/match.c | 11 +++++++++++ 4 files changed, 31 insertions(+) diff --git a/include/g_consts.h b/include/g_consts.h index 4727cb9f..185bf92c 100644 --- a/include/g_consts.h +++ b/include/g_consts.h @@ -271,6 +271,7 @@ #define EV_ON_ADMIN ( 128) // admin #define EV_ON_UNADMIN ( 256) // unadmin #define EV_ON_COUNTDOWN_START ( 512) // countdown start +#define EV_ON_COUNTDOWN_BREAK (1024) // countdown break // CTF #define CTF_RUNE_RES 1 // IT_SIGIL1 diff --git a/include/g_local.h b/include/g_local.h index 89d297a7..fa744359 100644 --- a/include/g_local.h +++ b/include/g_local.h @@ -425,6 +425,7 @@ void on_match_break(gedict_t *p); void on_admin(gedict_t *p); void on_unadmin(gedict_t *p); void on_countdown_start(gedict_t *p); +void on_countdown_break(gedict_t *p); void info_ev_update(gedict_t *p, char *from, char *to); void info_kf_update(gedict_t *p, char *from, char *to); diff --git a/src/g_utils.c b/src/g_utils.c index 10050e7f..de94b373 100644 --- a/src/g_utils.c +++ b/src/g_utils.c @@ -2593,6 +2593,23 @@ void on_countdown_start(gedict_t *p) } } +void on_countdown_break(gedict_t *p) +{ + if (!(iKey(p, "ev") & EV_ON_COUNTDOWN_BREAK)) + { + return; + } + + if (p->ct == ctPlayer) + { + stuffcmd_flags(p, STUFFCMD_IGNOREINDEMO, "on_countdown_break\n"); + } + else + { + stuffcmd_flags(p, STUFFCMD_IGNOREINDEMO, "on_spec_countdown_break\n"); + } +} + void ev_print(gedict_t *p, int new_ev, int old_ev, int bit, char *msg) { int on; @@ -2615,6 +2632,7 @@ void info_ev_update(gedict_t *p, char *from, char *to) ev_print(p, new_ev, old_ev, EV_ON_ADMIN, "[on_admin] event: "); ev_print(p, new_ev, old_ev, EV_ON_UNADMIN, "[on_unadmin] event: "); ev_print(p, new_ev, old_ev, EV_ON_COUNTDOWN_START, "[on_countdown_start] event: "); + ev_print(p, new_ev, old_ev, EV_ON_COUNTDOWN_BREAK, "[on_countdown_break] event: "); } void info_kf_update(gedict_t *p, char *from, char *to) diff --git a/src/match.c b/src/match.c index f53ec78e..2e408458 100644 --- a/src/match.c +++ b/src/match.c @@ -1244,6 +1244,16 @@ void SM_on_CountdownStart(void) } } +void SM_on_CountdownBreak(void) +{ + gedict_t *p; + + for (p = world; (p = find_client(p));) + { + on_countdown_break(p); + } +} + // Reset player frags and start the timer. void HideSpawnPoints(void); @@ -3128,6 +3138,7 @@ void PlayerBreak(void) { G_bprint(2, "%s %s\n", self->netname, redtext("stops the countdown")); StopTimer(1); + SM_on_CountdownBreak(); } else {