Skip to content

Commit

Permalink
Server var: show_on_server_list
Browse files Browse the repository at this point in the history
  • Loading branch information
geneotech committed Jul 29, 2024
1 parent b969f8c commit be393f8
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 13 deletions.
22 changes: 13 additions & 9 deletions src/application/gui/settings_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1775,6 +1775,18 @@ void settings_gui_state::perform(
revertable_checkbox("Map CAPS LOCK to ESC", config.window.map_caps_lock_to_esc);
#endif

ImGui::Separator();

text_color("Masterserver", yellow);

ImGui::Separator();

input_text("Server list provider", config.server_list_provider, ImGuiInputTextFlags_EnterReturnsTrue); revert(config.server_list_provider);
input_text("WebRTC signalling server", config.webrtc_signalling_server_url, ImGuiInputTextFlags_EnterReturnsTrue); revert(config.webrtc_signalling_server_url);

#if 0
input_text("Port probing host", config.nat_detection.port_probing.host.address, ImGuiInputTextFlags_EnterReturnsTrue); revert(config.nat_detection.port_probing.host.address);
#endif

#if !PLATFORM_WEB
ImGui::Separator();
Expand All @@ -1792,15 +1804,6 @@ void settings_gui_state::perform(
input_text<100>(SCOPE_CFG_NVP(update_host), ImGuiInputTextFlags_EnterReturnsTrue); revert(config.self_update.update_host);
input_text<100>(SCOPE_CFG_NVP(update_path), ImGuiInputTextFlags_EnterReturnsTrue); revert(config.self_update.update_path);

ImGui::Separator();

text_color("Masterserver", yellow);

ImGui::Separator();

input_text("Server list provider", config.server_list_provider, ImGuiInputTextFlags_EnterReturnsTrue); revert(config.server_list_provider);
input_text("WebRTC signalling server", config.webrtc_signalling_server_url, ImGuiInputTextFlags_EnterReturnsTrue); revert(config.webrtc_signalling_server_url);
input_text("Port probing host", config.nat_detection.port_probing.host.address, ImGuiInputTextFlags_EnterReturnsTrue); revert(config.nat_detection.port_probing.host.address);
}

#endif
Expand Down Expand Up @@ -2239,6 +2242,7 @@ void do_server_vars(

revertable_checkbox("Friendly fire", vars.friendly_fire);

revertable_checkbox("Show on server list", vars.show_on_server_list);
revertable_input_text(SCOPE_CFG_NVP(notified_server_list));

#if !IS_PRODUCTION_BUILD
Expand Down
29 changes: 25 additions & 4 deletions src/application/masterserver/masterserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ work_result perform_masterserver(const config_json_table& cfg) try {
for (auto& server : server_list) {
const auto address = server.first;

if (!server.second.last_heartbeat.show_on_server_list) {
continue;
}

augs::write_bytes(ss, address);
augs::write_bytes(ss, server.second.meta);
augs::write_bytes(ss, server.second.last_heartbeat);
Expand All @@ -306,6 +310,10 @@ work_result perform_masterserver(const config_json_table& cfg) try {
continue;
}

if (!server.second.last_heartbeat.show_on_server_list) {
continue;
}

const auto ip_address = server.second.ip_informational;

masterserver_entry_meta meta;
Expand Down Expand Up @@ -390,6 +398,10 @@ work_result perform_masterserver(const config_json_table& cfg) try {
};

for (const auto& server : server_list) {
if (!server.second.last_heartbeat.show_on_server_list) {
continue;
}

write_json_entry(
server.second.last_heartbeat,
server.second.meta,
Expand All @@ -403,6 +415,10 @@ work_result perform_masterserver(const config_json_table& cfg) try {
continue;
}

if (!server.second.last_heartbeat.show_on_server_list) {
continue;
}

masterserver_entry_meta meta;
meta.time_hosted = server.second.time_hosted;
meta.type = server_type::WEB;
Expand Down Expand Up @@ -805,12 +821,17 @@ work_result perform_masterserver(const config_json_table& cfg) try {
if (is_new_server) {
server_entry.meta.time_hosted = current_time;

if (!typed_request.suppress_new_community_server_webhook) {
MSR_LOG("New server sent a heartbeat from %x. Sending a notification.", ip_str);
push_new_server_webhook(from, typed_request);
if (typed_request.show_on_server_list) {
if (!typed_request.suppress_new_community_server_webhook) {
MSR_LOG("New server sent a heartbeat from %x. Sending a notification.", ip_str);
push_new_server_webhook(from, typed_request);
}
else {
MSR_LOG("New server sent a heartbeat from %x. Skipping notification due to a flag.", ip_str);
}
}
else {
MSR_LOG("New server sent a heartbeat from %x. Skipping notification due to a flag.", ip_str);
MSR_LOG("New server sent a heartbeat from %x. Skipping notification due show_on_server_list = false.", ip_str);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/application/masterserver/server_heartbeat.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct server_heartbeat {
std::optional<netcode_address_t> internal_network_address;
nat_detection_result nat;
bool suppress_new_community_server_webhook = false;
bool show_on_server_list = true;
game_version_identifier server_version = "Unknown";
bool is_editor_playtesting_server = false;

Expand Down
2 changes: 2 additions & 0 deletions src/application/setups/server/server_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1991,6 +1991,8 @@ void server_setup::send_heartbeat_to_server_list() {
vars.suppress_new_community_server_webhook
;

heartbeat.show_on_server_list = vars.show_on_server_list;

#if BUILD_NATIVE_SOCKETS
heartbeat.internal_network_address = internal_address;
#endif
Expand Down
1 change: 1 addition & 0 deletions src/application/setups/server/server_vars.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ struct server_vars {
server_name_type server_name;
address_string_type notified_server_list;
bool suppress_new_community_server_webhook = false;
bool show_on_server_list = true;

bool allow_nat_traversal = true;
bool allow_direct_arena_file_downloads = true;
Expand Down

0 comments on commit be393f8

Please sign in to comment.