X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fshared%2Fcli.cpp;h=bb4aa6de706e3259f25f374a9fdfe15d57808870;hb=b00e4b77859d13bdf29bd50e91315a46a15bd01d;hp=cb46cfc264c289fcb73abb9b89caceaefd60af1e;hpb=b07f3c123fff221edeffb4864bab7db88d0d1f4d;p=blank.git diff --git a/src/shared/cli.cpp b/src/shared/cli.cpp index cb46cfc..bb4aa6d 100644 --- a/src/shared/cli.cpp +++ b/src/shared/cli.cpp @@ -63,19 +63,30 @@ CLI::Command::~Command() { } +CLIContext::CLIContext(Player *p, Entity *e) +: original_player(p) +, effective_player(p) +, original_entity(e) +, effective_entity(e) { + if (!e && p) { + original_entity = effective_entity = &p->GetEntity(); + } +} + + void TeleportCommand::Execute(CLI &, CLIContext &ctx, TokenStreamReader &args) { - if (!ctx.HasPlayer()) { - ctx.Error("teleport needs player to operate on"); + if (!ctx.HasEntity()) { + ctx.Error("teleport needs entity to operate on"); return; } glm::vec3 pos(args.GetFloat(), args.GetFloat(), args.GetFloat()); - EntityState state = ctx.GetPlayer().GetEntity().GetState(); + EntityState state = ctx.GetEntity().GetState(); state.pos = ExactLocation(pos).Sanitize(); - ctx.GetPlayer().GetEntity().SetState(state); + ctx.GetEntity().SetState(state); stringstream msg; - msg << ctx.GetPlayer().Name() << " teleported to " << pos; + msg << ctx.GetEntity().Name() << " teleported to " << pos; ctx.Broadcast(msg.str()); }