summaryrefslogtreecommitdiffstats
path: root/src/Scoreboard.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Scoreboard.cpp54
1 files changed, 51 insertions, 3 deletions
diff --git a/src/Scoreboard.cpp b/src/Scoreboard.cpp
index 7fa1eab99..e6812d3d7 100644
--- a/src/Scoreboard.cpp
+++ b/src/Scoreboard.cpp
@@ -7,6 +7,7 @@
#include "Scoreboard.h"
#include "World.h"
+#include "ClientHandle.h"
@@ -178,6 +179,20 @@ void cObjective::SetDisplayName(const AString & a_Name)
+void cObjective::SendTo(cClientHandle & a_Client)
+{
+ a_Client.SendScoreboardObjective(m_Name, m_DisplayName, 0);
+
+ for (cScoreMap::const_iterator it = m_Scores.begin(); it != m_Scores.end(); ++it)
+ {
+ a_Client.SendScoreUpdate(m_Name, it->first, it->second, 0);
+ }
+}
+
+
+
+
+
cTeam::cTeam(const AString & a_Name, const AString & a_DisplayName,
const AString & a_Prefix, const AString & a_Suffix)
: m_AllowsFriendlyFire(true)
@@ -397,11 +412,19 @@ void cScoreboard::SetDisplay(const AString & a_Objective, eDisplaySlot a_Slot)
cObjective * Objective = GetObjective(a_Objective);
- m_Display[a_Slot] = Objective;
+ SetDisplay(Objective, a_Slot);
+}
+
+
+
+
+
+void cScoreboard::SetDisplay(cObjective * a_Objective, eDisplaySlot a_Slot)
+{
+ m_Display[a_Slot] = a_Objective;
ASSERT(m_World != NULL);
- m_World->BroadcastDisplayObjective(Objective ? a_Objective : "", a_Slot);
-
+ m_World->BroadcastDisplayObjective(a_Objective ? a_Objective->GetName() : "", a_Slot);
}
@@ -440,6 +463,31 @@ void cScoreboard::ForEachObjectiveWith(cObjective::eType a_Type, cObjectiveCallb
+void cScoreboard::SendTo(cClientHandle & a_Client)
+{
+ cCSLock Lock(m_CSObjectives);
+
+ for (cObjectiveMap::iterator it = m_Objectives.begin(); it != m_Objectives.end(); ++it)
+ {
+ it->second.SendTo(a_Client);
+ }
+
+ for (int i = 0; i < (int) E_DISPLAY_SLOT_COUNT; ++i)
+ {
+ // Avoid race conditions
+ cObjective * Objective = m_Display[i];
+
+ if (Objective)
+ {
+ a_Client.SendDisplayObjective(Objective->GetName(), (eDisplaySlot) i);
+ }
+ }
+}
+
+
+
+
+
unsigned int cScoreboard::GetNumObjectives(void) const
{
return m_Objectives.size();