From 496c337cdfa593654018c171f6a74c28272265b5 Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Fri, 1 Sep 2017 12:04:50 +0100 Subject: Replace ItemCallbacks with lambdas (#3948) --- src/Root.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/Root.h') diff --git a/src/Root.h b/src/Root.h index 44567018d..09e2c7880 100644 --- a/src/Root.h +++ b/src/Root.h @@ -1,10 +1,11 @@ - + #pragma once #include "Protocol/Authenticator.h" #include "Protocol/MojangAPI.h" #include "HTTP/HTTPServer.h" #include "Defines.h" +#include #include "RankManager.h" @@ -27,8 +28,8 @@ class cSettingsRepositoryInterface; class cDeadlockDetect; class cUUID; -typedef cItemCallback cPlayerListCallback; -typedef cItemCallback cWorldListCallback; +using cPlayerListCallback = std::function; +using cWorldListCallback = std::function; namespace Json { @@ -76,7 +77,7 @@ public: // tolua_end /** Calls the callback for each world; returns true if the callback didn't abort (return true) */ - bool ForEachWorld(cWorldListCallback & a_Callback); // >> Exported in ManualBindings << + bool ForEachWorld(const cWorldListCallback & a_Callback); // >> Exported in ManualBindings << /** Writes chunkstats, for each world and totals, to the output callback */ void LogChunkStats(cCommandOutputCallback & a_Output); @@ -136,16 +137,16 @@ public: void SaveAllChunks(void); // tolua_export /** Calls the callback for each player in all worlds */ - bool ForEachPlayer(cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS << + bool ForEachPlayer(const cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS << /** Finds a player from a partial or complete player name and calls the callback - case-insensitive */ - bool FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS << + bool FindAndDoWithPlayer(const AString & a_PlayerName, const cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS << /** Finds the player over his uuid and calls the callback */ - bool DoWithPlayerByUUID(const cUUID & a_PlayerUUID, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS << + bool DoWithPlayerByUUID(const cUUID & a_PlayerUUID, const cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS << /** Finds the player using it's complete username and calls the callback */ - bool DoWithPlayer(const AString & a_PlayerName, cPlayerListCallback & a_Callback); + bool DoWithPlayer(const AString & a_PlayerName, const cPlayerListCallback & a_Callback); /** Send playerlist of all worlds to player */ void SendPlayerLists(cPlayer * a_DestPlayer); -- cgit v1.2.3