From 5dfb486acbafa1c3702e03e9e24aedabdca69067 Mon Sep 17 00:00:00 2001 From: Chris Parsons Date: Tue, 19 Nov 2024 21:04:44 -0330 Subject: [PATCH] Allow server operators to set dropped CTF flag return time (#304) * Add $DF CTF Flag Return Time * Update game_patch/multi/multi.cpp Co-authored-by: is-this-c <87069698+is-this-c@users.noreply.github.com> * Update server.cpp --------- Co-authored-by: is-this-c <87069698+is-this-c@users.noreply.github.com> --- README.md | 2 ++ docs/CHANGELOG.md | 1 + game_patch/multi/multi.cpp | 6 ++++++ game_patch/multi/server.cpp | 4 ++++ game_patch/multi/server_internal.h | 1 + 5 files changed, 14 insertions(+) diff --git a/README.md b/README.md index d6efb542..617be6d4 100644 --- a/README.md +++ b/README.md @@ -156,6 +156,8 @@ Configuration example: $DF Spawn Health: 100 // Initial player armor after spawn $DF Spawn Armor: 0 + // Time before a dropped CTF flag will return to base in ms (default is same as stock RF - 25000) + $DF CTF Flag Return Time: 25000 // Enable hit-sounds $DF Hitsounds: true // Sound used for hit notification diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 09fc862d..20828c6c 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -46,6 +46,7 @@ Version 1.9.0 (not released yet) - Fix crash when `verify_level` command is run without a level being loaded - Fix cockpit not rendering for any jeeps after the first one entered each level load - Add `server_password` command +- Add `$DF CTF Flag Return Time` option in dedicated server config Contributions: diff --git a/game_patch/multi/multi.cpp b/game_patch/multi/multi.cpp index 9742e0f0..1d6bd444 100644 --- a/game_patch/multi/multi.cpp +++ b/game_patch/multi/multi.cpp @@ -3,8 +3,10 @@ #include #include #include +#include #include "multi.h" #include "multi_private.h" +#include "server_internal.h" #include "../misc/misc.h" #include "../rf/os/os.h" #include "../rf/os/timer.h" @@ -335,6 +337,10 @@ void multi_do_patch() multi_limbo_init.install(); multi_start_injection.install(); + // Allow server to customize dropped flag return timer in ms + AsmWriter{0x00473B88}.push(g_additional_server_config.ctf_flag_return_time_ms); // blue flag + AsmWriter{0x00473B28}.push(g_additional_server_config.ctf_flag_return_time_ms); // red flag + // Fix CTF flag not returning to the base if the other flag was returned when the first one was waiting ctf_flag_return_fix.install(); diff --git a/game_patch/multi/server.cpp b/game_patch/multi/server.cpp index d63dd608..56ce6ca5 100644 --- a/game_patch/multi/server.cpp +++ b/game_patch/multi/server.cpp @@ -87,6 +87,10 @@ void load_additional_server_config(rf::Parser& parser) g_additional_server_config.spawn_armor = {parser.parse_float()}; } + if (parser.parse_optional("$DF CTF Flag Return Time:")) { + g_additional_server_config.ctf_flag_return_time_ms = parser.parse_int(); + } + if (parser.parse_optional("$DF Hitsounds:")) { g_additional_server_config.hit_sounds.enabled = parser.parse_bool(); if (parser.parse_optional("+Sound ID:")) { diff --git a/game_patch/multi/server_internal.h b/game_patch/multi/server_internal.h index 71317375..161eb770 100644 --- a/game_patch/multi/server_internal.h +++ b/game_patch/multi/server_internal.h @@ -37,6 +37,7 @@ struct ServerAdditionalConfig int spawn_protection_duration_ms = 1500; std::optional spawn_life; std::optional spawn_armor; + int ctf_flag_return_time_ms = 25000; HitSoundsConfig hit_sounds; std::map item_replacements; std::string default_player_weapon;