summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorx12xx12x <44411062+12xx12@users.noreply.github.com>2023-03-27 00:25:54 +0200
committerGitHub <noreply@github.com>2023-03-27 00:25:54 +0200
commitceaebd00d88fe70516c7b4ef1fa84d2f5f10d736 (patch)
tree4139ae31ab9f76df997c74eb8d8e4caa967ecc06 /src
parentHandle newlines in cIniFile (#5447) (diff)
downloadcuberite-ceaebd00d88fe70516c7b4ef1fa84d2f5f10d736.tar
cuberite-ceaebd00d88fe70516c7b4ef1fa84d2f5f10d736.tar.gz
cuberite-ceaebd00d88fe70516c7b4ef1fa84d2f5f10d736.tar.bz2
cuberite-ceaebd00d88fe70516c7b4ef1fa84d2f5f10d736.tar.lz
cuberite-ceaebd00d88fe70516c7b4ef1fa84d2f5f10d736.tar.xz
cuberite-ceaebd00d88fe70516c7b4ef1fa84d2f5f10d736.tar.zst
cuberite-ceaebd00d88fe70516c7b4ef1fa84d2f5f10d736.zip
Diffstat (limited to 'src')
-rw-r--r--src/Scoreboard.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/Scoreboard.cpp b/src/Scoreboard.cpp
index 7a6ed8867..fad78210e 100644
--- a/src/Scoreboard.cpp
+++ b/src/Scoreboard.cpp
@@ -361,11 +361,15 @@ cTeam * cScoreboard::RegisterTeam(
const AString & a_Prefix, const AString & a_Suffix
)
{
- cTeam Team(a_Name, a_DisplayName, a_Prefix, a_Suffix);
+ auto [TeamIterator, TeamExists] = m_Teams.try_emplace(a_Name, a_Name, a_DisplayName, a_Prefix, a_Suffix);
- std::pair<cTeamMap::iterator, bool> Status = m_Teams.insert(cNamedTeam(a_Name, Team));
+ if (!TeamExists && GetTeam(a_Name))
+ {
+ LOGWARNING("Tried to register a team that already exists: %s", a_Name.c_str());
+ return nullptr;
+ }
- return Status.second ? &Status.first->second : nullptr;
+ return &TeamIterator->second;
}