rework GetClient to use new ForEachClient, return shared_ptr

this simplifies a lot of functions, and removes a lot of potential
errors when using the function. You now only check whether the return
value is null, and if it's not, you have a valid, reference-counted,
client pointer.
This commit is contained in:
Lion Kortlepel
2022-11-13 13:36:04 +01:00
parent 844b64f5d9
commit 2f85c708c5
5 changed files with 51 additions and 63 deletions

View File

@@ -129,4 +129,5 @@ private:
std::chrono::time_point<TimeType> mLastPingTime;
};
std::optional<std::weak_ptr<TClient>> GetClient(class TServer& Server, int ID);
// Returns a valid client, or nullptr if no such client exists
std::shared_ptr<TClient> GetClient(class TServer& Server, int ID);