Merge commit 'ceaebd00d88fe70516c7b4ef1fa84d2f5f10d736' into pullstream

This commit is contained in:
Rebekah 2024-02-13 19:56:11 -05:00
commit 651b4ab127
Signed by: oneechanhax
GPG Key ID: 183EB7902964DAE5
2 changed files with 8 additions and 4 deletions

View File

@ -12292,7 +12292,7 @@ end
Type = "cTeam",
},
},
Notes = "Registers a new team. Returns the {{cTeam}} instance, nil on error.",
Notes = "Registers a new team. Returns the {{cTeam}} instance, nil on error. For example if the team already exists.",
},
RemoveObjective =
{

View File

@ -377,11 +377,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;
}