Skip to content

Commit

Permalink
Remove Private IP from automap
Browse files Browse the repository at this point in the history
  • Loading branch information
kphoenix137 committed Feb 13, 2025
1 parent 3970aae commit 0397436
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions Source/automap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <algorithm>
#include <cstdint>
#include <regex>

#include <fmt/format.h>

Expand Down Expand Up @@ -1410,10 +1411,16 @@ void DrawAutomapText(const Surface &out)

if (gbIsMultiplayer) {
if (GameName != "0.0.0.0" && !IsLoopback) {
std::string description = std::string(_("Game: "));
description.append(GameName);
DrawString(out, description, linePosition);
linePosition.y += 15;
// Check if GameName is an IP address
std::regex ipRegex(
R"((\d{1,3}\.){3}\d{1,3})"); // Basic IPv4 regex (not fully strict)

if (!std::regex_match(GameName, ipRegex)) { // Only show if not an IP
std::string description = std::string(_("Game: "));
description.append(GameName);
DrawString(out, description, linePosition);
linePosition.y += 15;
}
}

std::string description;
Expand Down

0 comments on commit 0397436

Please sign in to comment.