X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fshared%2FCLIContext.hpp;h=5308bb2434146aa5d91e14263c3f5830491a0d03;hb=b07f3c123fff221edeffb4864bab7db88d0d1f4d;hp=8de432b7788adb966e0a890e45111e868290b0ca;hpb=20d0a76d2519c71009c3b3babec0df27529f8142;p=blank.git diff --git a/src/shared/CLIContext.hpp b/src/shared/CLIContext.hpp index 8de432b..5308bb2 100644 --- a/src/shared/CLIContext.hpp +++ b/src/shared/CLIContext.hpp @@ -11,11 +11,14 @@ class Player; class CLIContext { public: - explicit CLIContext(Player &p) + explicit CLIContext(Player *p = nullptr) : player(p) { } + /// check if this context associates a player + bool HasPlayer() { return player; } /// get the player responsible for all this - Player &GetPlayer() { return player; } + /// only valid if HasPlayer() returns true + Player &GetPlayer() { return *player; } /// an error has happened and the player should be notified virtual void Error(const std::string &) = 0; @@ -29,7 +32,7 @@ public: virtual void Broadcast(const std::string &) = 0; private: - Player &player; + Player *player; };