summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Bindings/ManualBindings.cpp1
-rw-r--r--src/Scoreboard.cpp19
-rw-r--r--src/Scoreboard.h15
3 files changed, 34 insertions, 1 deletions
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index 3c3e78d25..fcdd728be 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -2586,6 +2586,7 @@ void ManualBindings::Bind(lua_State * tolua_S)
tolua_beginmodule(tolua_S, "cScoreboard");
tolua_function(tolua_S, "ForEachObjective", tolua_ForEach<cScoreboard, cObjective, &cScoreboard::ForEachObjective>);
+ tolua_function(tolua_S, "ForEachTeam", tolua_ForEach<cScoreboard, cTeam, &cScoreboard::ForEachTeam>);
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cPlugin");
diff --git a/src/Scoreboard.cpp b/src/Scoreboard.cpp
index ee56a1145..05fd0314d 100644
--- a/src/Scoreboard.cpp
+++ b/src/Scoreboard.cpp
@@ -498,6 +498,25 @@ bool cScoreboard::ForEachObjective(cObjectiveCallback& a_Callback)
+bool cScoreboard::ForEachTeam(cTeamCallback& a_Callback)
+{
+ cCSLock Lock(m_CSObjectives);
+
+ for (cTeamMap::iterator it = m_Teams.begin(); it != m_Teams.end(); ++it)
+ {
+ // Call callback
+ if (a_Callback.Item(&it->second))
+ {
+ return false;
+ }
+ }
+ return true;
+}
+
+
+
+
+
void cScoreboard::AddPlayerScore(const AString & a_Name, cObjective::eType a_Type, cObjective::Score a_Value)
{
cCSLock Lock(m_CSObjectives);
diff --git a/src/Scoreboard.h b/src/Scoreboard.h
index 2abd1564b..e22ecaeb1 100644
--- a/src/Scoreboard.h
+++ b/src/Scoreboard.h
@@ -14,9 +14,11 @@
class cObjective;
+class cTeam;
class cWorld;
typedef cItemCallback<cObjective> cObjectiveCallback;
+typedef cItemCallback<cTeam> cTeamCallback;
@@ -170,6 +172,11 @@ public:
// tolua_end
+ static const char * GetClassStatic(void) // Needed for ManualBindings's ForEach templates
+ {
+ return "cTeam";
+ }
+
private:
typedef std::set<AString> cPlayerNameSet;
@@ -260,10 +267,16 @@ public:
/** Execute callback for each objective.
*
- * Returns true if all objectives processed, false if the callback aborted by returning true.
+ * Returns true if all objectives have been processed, false if the callback aborted by returning true.
*/
bool ForEachObjective(cObjectiveCallback& a_Callback); // Exported in ManualBindings.cpp
+ /** Execute callback for each team.
+ *
+ * Returns true if all teams have been processed, false if the callback aborted by returning true.
+ */
+ bool ForEachTeam(cTeamCallback& a_Callback); // Exported in ManualBindings.cpp
+
void SetDisplay(cObjective * a_Objective, eDisplaySlot a_Slot);