Exported cScoreboard::ForEachTeam
This commit is contained in:
parent
692a84af31
commit
39c8e68ef0
@ -1866,6 +1866,7 @@ end
|
||||
{
|
||||
AddPlayerScore = { Params = "Name, Type, Value", Return = "", Notes = "Adds a value to all player scores of the specified objective type." },
|
||||
ForEachObjective = { Params = "CallBackFunction, [CallbackData]", Return = "bool", Notes = "Calls the specified callback for each objective in the scoreboard. Returns true if all objectives have been processed (including when there are zero objectives), or false if the callback function has aborted the enumeration by returning true. The callback function has the following signature: <pre class=\"prettyprint lang-lua\">function Callback({{cObjective|Objective}}, [CallbackData])</pre> The callback should return false or no value to continue with the next objective, or true to abort the enumeration." },
|
||||
ForEachTeam = { Params = "CallBackFunction, [CallbackData]", Return = "bool", Notes = "Calls the specified callback for each team in the scoreboard. Returns true if all teams have been processed (including when there are zero teams), or false if the callback function has aborted the enumeration by returning true. The callback function has the following signature: <pre class=\"prettyprint lang-lua\">function Callback({{cObjective|Objective}}, [CallbackData])</pre> The callback should return false or no value to continue with the next team, or true to abort the enumeration." },
|
||||
GetNumObjectives = { Params = "", Return = "number", Notes = "Returns the nuber of registered objectives." },
|
||||
GetNumTeams = { Params = "", Return = "number", Notes = "Returns the number of registered teams." },
|
||||
GetObjective = { Params = "string", Return = "{{cObjective}}", Notes = "Returns the objective with the specified name." },
|
||||
|
@ -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");
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user