Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow server operators to set dropped CTF flag return time #304

Merged
merged 4 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Version 1.9.0 (not released yet)
- Add level filename to "Level Initializing" console message
- Properly handle WM_PAINT in dedicated server, may improve performance (DF bug)
- Fix crash when `verify_level` command is run without a level being loaded
- Add `$DF CTF Flag Return Time` option in dedicated server config

Version 1.8.0 (released 2022-09-17)
-----------------------------------
Expand Down
6 changes: 6 additions & 0 deletions game_patch/multi/multi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
#include <winsock2.h>
#include <patch_common/FunHook.h>
#include <patch_common/CodeInjection.h>
#include <patch_common/AsmWriter.h>
#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"
Expand Down Expand Up @@ -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
GooberRF marked this conversation as resolved.
Show resolved Hide resolved

// 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();

Expand Down
4 changes: 4 additions & 0 deletions game_patch/multi/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,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()};
GooberRF marked this conversation as resolved.
Show resolved Hide resolved
}

if (parser.parse_optional("$DF Hitsounds:")) {
g_additional_server_config.hit_sounds.enabled = parser.parse_bool();
if (parser.parse_optional("+Sound ID:")) {
Expand Down
1 change: 1 addition & 0 deletions game_patch/multi/server_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ struct ServerAdditionalConfig
int spawn_protection_duration_ms = 1500;
std::optional<float> spawn_life;
std::optional<float> spawn_armor;
int ctf_flag_return_time_ms = 25000;
HitSoundsConfig hit_sounds;
std::map<std::string, std::string> item_replacements;
std::string default_player_weapon;
Expand Down