71#include "absl/status/statusor.h"
72#include "absl/strings/str_cat.h"
73#include "asio/ssl/context.hpp"
76#include "protocol/nanommo.pb.h"
79#include "protocol/version.h"
85constexpr uint16_t kLoginPort = 7778;
86constexpr uint16_t kWorldPort = 7777;
88constexpr uint16_t kNextPort = 7877;
90constexpr auto kKnocking = std::chrono::seconds(20);
91constexpr char kWorld[] =
"Ember";
93constexpr auto kTick = std::chrono::milliseconds(50);
94constexpr auto kEachWay = std::chrono::seconds(3);
97constexpr auto kDrawn = std::chrono::milliseconds(100);
98constexpr auto kStale = std::chrono::milliseconds(1000);
100constexpr char kFarmers[] =
"Farmers";
101constexpr char kFeeders[] =
"Feeders";
103absl::StatusOr<nanommo::protocol::LoginReply> Ask(
104 asio::ssl::context& tls,
const nanommo::protocol::LoginRequest& request) {
105 absl::StatusOr<nanommo::protocol::LoginReply> reply =
107 if (reply.ok() && !reply->ok()) {
108 return absl::PermissionDeniedError(reply->error());
115absl::StatusOr<std::string> Enter(asio::ssl::context& tls,
116 const std::string& name,
117 const std::string& password) {
118 nanommo::protocol::LoginRequest request;
119 request.set_username(name);
120 request.set_password(password);
121 request.set_version(nanommo::kVersion);
122 absl::StatusOr<nanommo::protocol::LoginReply> reply = Ask(tls, request);
123 if (absl::IsPermissionDenied(reply.status())) {
124 request.set_new_account(
true);
125 reply = Ask(tls, request);
128 return reply.status();
130 const auto mine = [](
const nanommo::protocol::LoginReply& listed) {
131 for (
const nanommo::protocol::CharacterListing& character :
132 listed.characters()) {
133 if (character.world() == kWorld) {
134 return character.id();
139 nanommo::protocol::LoginRequest next;
140 next.set_session(reply->session());
141 uint32_t character = mine(*reply);
142 if (character == 0) {
143 nanommo::protocol::LoginRequest create = next;
144 create.set_create_character(
true);
145 create.set_world(kWorld);
146 create.set_name(name);
147 reply = Ask(tls, create);
149 return reply.status();
151 character = mine(*reply);
153 next.set_enter(
true);
154 next.set_character(character);
155 reply = Ask(tls, next);
157 return reply.status();
159 return reply->token();
163const nanommo::protocol::Player* Player(
const nanommo::protocol::World& world,
165 for (
const nanommo::protocol::Player& player : world.players()) {
166 if (player.id() ==
id) {
174const nanommo::protocol::Player* Us(
const nanommo::protocol::World& world) {
175 return Player(world, world.you());
179const nanommo::protocol::Player* Named(
const nanommo::protocol::World& world,
180 const std::string& name) {
181 for (
const nanommo::protocol::Player& player : world.players()) {
182 if (player.name() == name) {
190const nanommo::protocol::Monster* Monster(
const nanommo::protocol::World& world,
192 for (
const nanommo::protocol::Monster& monster : world.monsters()) {
193 if (monster.id() ==
id) {
201uint32_t Pick(
const nanommo::protocol::World& world,
202 const nanommo::protocol::Player& us,
float away) {
204 float best = std::numeric_limits<float>::max();
205 for (
const nanommo::protocol::Monster& monster : world.monsters()) {
207 std::abs(std::hypot(monster.x() - us.x(), monster.z() - us.z()) - away);
208 if (monster.health() > 0 && off < best) {
210 picked = monster.id();
236nanommo::protocol::Input Move(
const nanommo::protocol::Place& from,
237 const nanommo::protocol::Place& to) {
238 nanommo::protocol::Input input;
239 nanommo::protocol::ItemMove* move = input.mutable_item()->mutable_move();
240 *move->mutable_from() = from;
241 *move->mutable_to() = to;
246uint32_t FreeSlot(
const nanommo::protocol::Inventory& inventory) {
248 while (inventory.bag().contains(slot)) {
255nanommo::protocol::Input Trading(
const nanommo::protocol::TradeAction& action) {
256 nanommo::protocol::Input input;
257 *input.mutable_trade() = action;
262std::string Count(
const nanommo::protocol::Inventory& inventory,
265 for (
const auto& [slot, stack] : inventory.bag()) {
266 count += stack.item() == item ? 1 : 0;
268 for (
const auto& [slot, stack] : inventory.worn()) {
269 count += stack.item() == item ? 1 : 0;
271 return absl::StrCat(count, count == 1 ?
" sword" :
" swords");
275std::optional<uint32_t> SlotOf(
const nanommo::protocol::Inventory& inventory,
277 for (
const auto& [slot, stack] : inventory.bag()) {
278 if (stack.item() == item) {
287int Back(asio::ssl::context& tls,
const std::string& name,
288 const std::string& password, uint32_t sword) {
289 std::this_thread::sleep_for(std::chrono::seconds(1));
290 absl::StatusOr<std::string> token = Enter(tls, name, password);
292 std::cerr <<
"cheat: " << name <<
" couldn't come back: " << token.status()
296 absl::StatusOr<std::unique_ptr<nanommo::Connection>> back =
299 std::cerr <<
"cheat: " << back.status() <<
"\n";
302 while ((*back)->connected() && (*back)->inventory().bag().empty()) {
304 std::this_thread::sleep_for(std::chrono::milliseconds(5));
306 std::cout <<
"cheat: " << name <<
" is back, and has "
307 << Count((*back)->inventory(), sword) << std::endl;
313std::unique_ptr<nanommo::Connection> Second(asio::ssl::context& tls,
314 const std::string& name,
315 const std::string& password) {
316 absl::StatusOr<std::string> token = Enter(tls, name, password);
320 absl::StatusOr<std::unique_ptr<nanommo::Connection>> second =
325 const auto start = std::chrono::steady_clock::now();
326 while ((*second)->connected() && (*second)->inventory().worn().empty() &&
327 std::chrono::steady_clock::now() - start < std::chrono::seconds(3)) {
329 std::this_thread::sleep_for(std::chrono::milliseconds(5));
331 if (!(*second)->connected() || (*second)->inventory().worn().empty()) {
334 return *std::move(second);
340int Trade(asio::ssl::context& tls,
const std::string& name,
341 const std::string& password, Cheat cheat,
const std::string& partner,
342 std::unique_ptr<nanommo::Connection> connection) {
343 nanommo::protocol::Place hand;
344 hand.set_worn(nanommo::items::SLOT_MAIN_HAND);
347 std::chrono::steady_clock::time_point asked;
350 std::optional<uint32_t> offered;
352 std::optional<std::chrono::steady_clock::time_point> moved;
358 std::unique_ptr<nanommo::Connection> next;
359 bool knocking = cheat == Cheat::kTwice;
360 const auto started = std::chrono::steady_clock::now();
361 std::chrono::steady_clock::time_point knocked;
362 while (connection->connected()) {
365 std::chrono::steady_clock::now() - knocked >= std::chrono::seconds(1)) {
366 knocked = std::chrono::steady_clock::now();
367 next = Second(tls, name, password);
368 if (next !=
nullptr) {
370 std::cout <<
"cheat: " << name <<
" is in Ember a second time, on "
371 << kNextPort << std::endl;
372 }
else if (knocked - started >= kKnocking) {
374 std::cout <<
"cheat: the second instance turned " << name
375 <<
" away, as it's playing on the first" << std::endl;
378 if (next !=
nullptr) {
381 std::this_thread::sleep_for(std::chrono::milliseconds(5));
382 const nanommo::protocol::Inventory& bag = connection->inventory();
383 const auto in_hand =
static_cast<uint32_t
>(hand.worn());
385 if (bag.worn().contains(in_hand)) {
386 sword = bag.worn().at(in_hand).item();
387 std::cout <<
"cheat: " << name <<
" has " << Count(bag, sword)
392 const nanommo::protocol::Trade& trade = connection->trade();
393 if (trade.partner() != partner) {
396 const auto end = std::chrono::steady_clock::now();
397 while (std::chrono::steady_clock::now() - end <
398 std::chrono::milliseconds(500)) {
400 std::this_thread::sleep_for(std::chrono::milliseconds(5));
402 std::cout <<
"cheat: the trade's over, and " << name <<
" has "
403 << Count(connection->inventory(), sword) << std::endl;
404 if (next ==
nullptr) {
411 nanommo::protocol::Place free;
412 free.set_bag(FreeSlot(next->inventory()));
413 next->Send(Move(hand, free));
414 const auto put = std::chrono::steady_clock::now();
415 while (std::chrono::steady_clock::now() - put <
416 std::chrono::milliseconds(500)) {
418 std::this_thread::sleep_for(std::chrono::milliseconds(5));
420 std::cout <<
"cheat: on " << kNextPort <<
", " << name
421 <<
" still has its sword, and puts it in the bag"
424 return Back(tls, name, password, sword);
427 const auto now = std::chrono::steady_clock::now();
428 if (now - asked >= std::chrono::seconds(1)) {
429 nanommo::protocol::TradeAction ask;
430 ask.set_ask(partner);
431 connection->Send(Trading(ask));
437 if (cheat == Cheat::kTake) {
438 if (!ready && trade.theirs().bag_size() > 0) {
439 nanommo::protocol::TradeAction yes;
441 yes.set_revision(trade.revision());
442 connection->Send(Trading(yes));
444 std::cout <<
"cheat: " << partner <<
" offers a sword, so " << name
445 <<
" is ready" << std::endl;
453 nanommo::protocol::Place free;
454 free.set_bag(FreeSlot(bag));
455 connection->Send(Move(hand, free));
457 }
else if (
const std::optional<uint32_t> slot = SlotOf(bag, sword)) {
458 nanommo::protocol::TradeAction offer;
459 offer.mutable_offer()->add_bag(*slot);
460 connection->Send(Trading(offer));
462 std::cout <<
"cheat: " << name <<
" offers its sword, from slot "
463 << *slot << std::endl;
468 if (ready || !trade.theirs().ready() || knocking) {
471 nanommo::protocol::TradeAction yes;
473 yes.set_revision(trade.revision());
474 if (cheat == Cheat::kSwap) {
477 nanommo::protocol::Place from;
478 from.set_bag(*offered);
479 nanommo::protocol::Place to;
480 to.set_bag(FreeSlot(bag));
481 connection->Send(Move(from, to));
482 moved = std::chrono::steady_clock::now();
483 std::cout <<
"cheat: " << partner <<
" is ready, so " << name
484 <<
" moves the sword to slot " << to.bag() << std::endl;
485 }
else if (!bag.bag().contains(*offered)) {
486 connection->Send(Trading(yes));
488 std::cout <<
"cheat: " << name <<
" is ready too" << std::endl;
489 }
else if (std::chrono::steady_clock::now() - *moved >
490 std::chrono::seconds(1)) {
492 connection->Send(Trading(yes));
494 std::cout <<
"cheat: the sword's still in slot " << *offered <<
", so "
495 << name <<
" is ready with it there" << std::endl;
499 connection->Send(Trading(yes));
500 if (cheat == Cheat::kTwice) {
502 std::cout <<
"cheat: " << partner <<
" is ready, so " << name
503 <<
" is ready too" << std::endl;
508 std::cout <<
"cheat: " << partner <<
" is ready, so " << name
509 <<
" is ready too, and leaves at once" << std::endl;
510 return Back(tls, name, password, sword);
512 std::cout <<
"cheat: the server closed the connection" << std::endl;
522int Duel(Cheat cheat,
const std::string& partner,
523 std::unique_ptr<nanommo::Connection> connection) {
524 const std::string named = cheat == Cheat::kStale ?
"stale" :
"duel";
525 const auto says = cheat == Cheat::kStale ? kStale : kDrawn;
527 uint32_t sequence = 0;
530 std::chrono::steady_clock::time_point asked;
531 std::chrono::steady_clock::time_point tick;
532 std::chrono::steady_clock::time_point second;
533 std::cout << std::fixed << std::setprecision(1);
534 while (connection->connected()) {
536 std::this_thread::sleep_for(std::chrono::milliseconds(5));
537 const auto now = std::chrono::steady_clock::now();
538 const nanommo::protocol::World& world = connection->world();
539 const nanommo::protocol::Duel& duel = connection->duel();
540 const std::vector<nanommo::protocol::Event> events =
541 connection->TakeEvents();
542 if (duel.state() != nanommo::protocol::DUEL_FIGHTING) {
544 std::cout <<
"cheat: the duel's over, and " << landed
545 << (landed == 1 ?
" blow" :
" blows") <<
" landed"
551 const bool waiting = duel.state() == nanommo::protocol::DUEL_ASKING ||
552 duel.state() == nanommo::protocol::DUEL_COUNTDOWN;
553 if (!waiting && now - asked >= std::chrono::seconds(1)) {
554 nanommo::protocol::Input ask;
555 ask.mutable_duel()->set_ask(partner);
556 connection->Send(ask);
563 const uint32_t them = duel.opponent_id();
564 const nanommo::protocol::Player* us = Us(world);
565 const nanommo::protocol::Player* other = Player(world, them);
566 if (us ==
nullptr || other ==
nullptr) {
569 const auto sent = std::chrono::microseconds(world.sent());
570 history.
Record(them, sent, {.x = other->x(), .z = other->z()});
572 const auto away = [&](std::chrono::milliseconds ago) {
574 return std::hypot(then.
x - us->x(), then.
z - us->z());
576 for (
const nanommo::protocol::Event& event : events) {
577 if (event.kind() == nanommo::protocol::EVENT_HURT &&
578 event.player() == them) {
580 std::cout <<
"cheat: a blow landed on " << partner <<
", for "
581 <<
event.amount() <<
", " << away({}) <<
" m away"
587 nanommo::protocol::Input input;
588 input.set_target_player(them);
589 input.set_attack(
true);
590 input.set_sequence(++sequence);
591 input.set_seen(connection->whole());
592 input.set_drawn((sent - says).count());
593 connection->Send(input);
595 if (now - second >= std::chrono::seconds(1)) {
597 std::cout <<
"cheat: " << named <<
" says it drew " << partner <<
" "
598 << says.count() <<
" ms ago, " << away(says)
599 <<
" m away then, and " << away({}) <<
" m away now"
603 std::cout <<
"cheat: the server closed the connection" << std::endl;
613int War(Cheat cheat,
const std::string& partner,
614 std::unique_ptr<nanommo::Connection> connection) {
615 const bool farming = cheat == Cheat::kFarm;
616 const std::string ours = farming ? kFarmers : kFeeders;
617 const std::string theirs = farming ? kFeeders : kFarmers;
618 uint32_t sequence = 0;
622 std::chrono::steady_clock::time_point asked;
623 std::chrono::steady_clock::time_point tick;
624 std::chrono::steady_clock::time_point started;
625 std::cout << std::fixed << std::setprecision(1);
626 while (connection->connected()) {
628 std::this_thread::sleep_for(std::chrono::milliseconds(5));
629 const auto now = std::chrono::steady_clock::now();
630 const nanommo::protocol::Guild& guild = connection->guild();
631 if (guild.war().enemy() != theirs) {
632 if (now - asked >= std::chrono::seconds(1)) {
633 nanommo::protocol::Input ask;
634 if (guild.name().empty()) {
635 ask.mutable_guild()->set_create(ours);
637 ask.mutable_guild()->set_war(theirs);
639 connection->Send(ask);
645 const nanommo::protocol::World& world = connection->world();
646 const nanommo::protocol::Player* us = Us(world);
647 const nanommo::protocol::Player* them = Named(world, partner);
648 if (us ==
nullptr || them ==
nullptr) {
651 const double minutes =
652 std::chrono::duration<double>(now - started).count() / 60;
654 const bool died = us->motion() == nanommo::protocol::MOTION_DEAD;
655 if (died && world.respawn() == 0 && now >= tick) {
656 nanommo::protocol::Input respawn;
657 respawn.set_respawn(
true);
658 connection->Send(respawn);
659 tick = now + std::chrono::seconds(1);
660 }
else if (!died && dead) {
661 nanommo::protocol::Input back;
662 back.mutable_walk_to()->set_x(them->x());
663 back.mutable_walk_to()->set_z(them->z());
664 connection->Send(back);
665 std::cout <<
"cheat: " << partner <<
" killed " << us->name()
666 <<
", who walks back" << std::endl;
673 nanommo::protocol::Input input;
674 input.set_target_player(them->id());
675 input.set_attack(
true);
676 input.set_sequence(++sequence);
677 input.set_seen(connection->whole());
678 connection->Send(input);
680 const bool killed = them->motion() == nanommo::protocol::MOTION_DEAD;
681 if (killed && !dead) {
683 std::cout <<
"cheat: farm killed " << partner <<
", " << kills
684 << (kills == 1 ?
" time" :
" times") <<
" in " << minutes
685 <<
" minutes" << std::endl;
688 if (guild.war().kills() != score) {
689 score = guild.war().kills();
690 std::cout <<
"cheat: after " << minutes <<
" minutes, the war's score is "
691 << score <<
" to " << guild.war().enemy_kills() <<
", "
692 << score / minutes <<
" a minute" << std::endl;
695 std::cout <<
"cheat: the server closed the connection" << std::endl;
701int main(
int argc,
char** argv) {
702 const std::string usage =
703 "usage: nanommo_cheat <name> <password> "
704 "<walk|speed|teleport|reach|fight|rapid|swing|cancel>\n"
705 " nanommo_cheat <name> <password> "
706 "<take|swap|run|twice|duel|stale|feed|farm> <partner>\n";
707 if (argc != 4 && argc != 5) {
711 const std::string name = argv[1];
712 const std::string password = argv[2];
713 const std::string named = argv[3];
714 Cheat cheat = Cheat::kWalk;
715 if (named ==
"walk") {
716 cheat = Cheat::kWalk;
717 }
else if (named ==
"speed") {
718 cheat = Cheat::kSpeed;
719 }
else if (named ==
"teleport") {
720 cheat = Cheat::kTeleport;
721 }
else if (named ==
"reach") {
722 cheat = Cheat::kReach;
723 }
else if (named ==
"fight") {
724 cheat = Cheat::kFight;
725 }
else if (named ==
"rapid") {
726 cheat = Cheat::kRapid;
727 }
else if (named ==
"swing") {
728 cheat = Cheat::kSwing;
729 }
else if (named ==
"cancel") {
730 cheat = Cheat::kCancel;
731 }
else if (named ==
"take") {
732 cheat = Cheat::kTake;
733 }
else if (named ==
"swap") {
734 cheat = Cheat::kSwap;
735 }
else if (named ==
"run") {
737 }
else if (named ==
"twice") {
738 cheat = Cheat::kTwice;
739 }
else if (named ==
"duel") {
740 cheat = Cheat::kDuel;
741 }
else if (named ==
"stale") {
742 cheat = Cheat::kStale;
743 }
else if (named ==
"feed") {
744 cheat = Cheat::kFeed;
745 }
else if (named ==
"farm") {
746 cheat = Cheat::kFarm;
751 const bool trades = cheat == Cheat::kTake || cheat == Cheat::kSwap ||
752 cheat == Cheat::kRun || cheat == Cheat::kTwice;
753 const bool duels = cheat == Cheat::kDuel || cheat == Cheat::kStale;
754 const bool wars = cheat == Cheat::kFeed || cheat == Cheat::kFarm;
756 if ((trades || duels || wars) != (argc == 5)) {
760 const bool fights = cheat == Cheat::kReach || cheat == Cheat::kFight ||
761 cheat == Cheat::kRapid || cheat == Cheat::kSwing ||
762 cheat == Cheat::kCancel;
764 absl::StatusOr<asio::ssl::context> tls =
767 std::cerr <<
"cheat: " << tls.status() <<
"\n";
771 absl::StatusOr<std::string> token;
772 for (
int tries = 0; tries < 60; ++tries) {
773 token = Enter(*tls, name, password);
777 std::this_thread::sleep_for(std::chrono::milliseconds(500));
780 std::cerr <<
"cheat: " << name <<
" couldn't enter: " << token.status()
784 absl::StatusOr<std::unique_ptr<nanommo::Connection>> connection =
786 if (!connection.ok()) {
787 std::cerr <<
"cheat: " << connection.status() <<
"\n";
790 std::cout <<
"cheat: " << name <<
" is in " << kWorld <<
", trying " << named
793 return Trade(*tls, name, password, cheat, argv[4], *std::move(connection));
796 return Duel(cheat, argv[4], *std::move(connection));
799 return War(cheat, argv[4], *std::move(connection));
804 uint32_t sequence = 0;
807 std::optional<nanommo::protocol::Place> away;
808 std::chrono::steady_clock::time_point back;
811 const auto start = std::chrono::steady_clock::now();
814 while ((*connection)->connected()) {
815 (*connection)->Poll();
816 const auto now = std::chrono::steady_clock::now();
817 const double seconds = std::chrono::duration<double>(now - start).count();
818 const nanommo::protocol::World& world = (*connection)->world();
819 const nanommo::protocol::Player* us = Us(world);
820 if (world.sent() != last && us !=
nullptr) {
822 speed.
Add(
static_cast<double>(world.sent()) / 1e6, us->x(), us->z());
824 for (
const nanommo::protocol::Event& event : (*connection)->TakeEvents()) {
825 if (event.kind() == nanommo::protocol::EVENT_HIT &&
826 event.player() == world.you()) {
827 hits.
Add(seconds, event.amount());
830 const nanommo::protocol::Inventory& bag = (*connection)->inventory();
831 const auto hand =
static_cast<uint32_t
>(nanommo::items::SLOT_MAIN_HAND);
832 if (cheat == Cheat::kCancel && !away && bag.worn().contains(hand)) {
833 nanommo::protocol::Place worn;
834 worn.set_worn(nanommo::items::SLOT_MAIN_HAND);
836 away->set_bag(FreeSlot(bag));
837 (*connection)->Send(Move(worn, *away));
838 back = std::chrono::steady_clock::now() + 2 * kTick;
843 if (away && std::chrono::steady_clock::now() >= back) {
844 nanommo::protocol::Place worn;
845 worn.set_worn(nanommo::items::SLOT_MAIN_HAND);
846 (*connection)->Send(Move(*away, worn));
851 if (fights && us !=
nullptr) {
852 const nanommo::protocol::Monster* picked = Monster(world, target);
853 if (picked ==
nullptr || picked->health() == 0) {
854 target = Pick(world, *us, cheat == Cheat::kReach ? 20.0f : 0.0f);
857 const auto ways = (now - start) / kEachWay;
858 const bool east = ways % 2 == 0;
861 const bool number = ways % 2 == 0;
862 const float far_x = (ways / 2) % 2 == 0 ? 1000.0f : -1000.0f;
866 const int keys = cheat == Cheat::kSpeed ? 3 : 1;
867 for (
int i = 0; i < keys; ++i) {
868 nanommo::protocol::Input input;
869 if (cheat == Cheat::kTeleport) {
870 input.set_x(number ? far_x : std::numeric_limits<float>::quiet_NaN());
873 input.set_target(target);
874 input.set_attack(target != 0);
876 input.set_x(east ? 1.0f : -1.0f);
879 input.set_sequence(++sequence);
880 input.set_seen((*connection)->whole());
881 (*connection)->Send(input);
886 const bool skills = cheat == Cheat::kFight || cheat == Cheat::kRapid;
887 if (skills && target != 0 && world.skills_size() > 0) {
888 const uint32_t skill = world.skills(0);
889 const bool ready = !world.cooldowns().contains(skill);
890 const int uses = cheat == Cheat::kRapid ? 10
891 : cheat == Cheat::kFight && ready ? 1
893 for (
int i = 0; i < uses; ++i) {
894 nanommo::protocol::Input use;
895 use.set_skill(skill);
896 (*connection)->Send(use);
901 if (now - second >= std::chrono::seconds(1)) {
903 std::cout <<
"cheat: " << named <<
" sent " << sent
904 <<
" inputs a second, and ";
905 if (cheat == Cheat::kTeleport) {
906 std::cout <<
"with x "
907 << (number ? (far_x > 0 ?
"1000" :
"-1000") :
"not a number")
910 std::cout << std::fixed << std::setprecision(1);
912 std::cout << (cheat == Cheat::kTeleport ?
"" :
"ran ")
915 const nanommo::protocol::Monster* picked = Monster(world, target);
916 if (picked !=
nullptr && us !=
nullptr) {
918 << std::hypot(picked->x() - us->x(), picked->z() - us->z())
919 <<
" m from its monster, ";
921 std::cout <<
"hits " << hits.
PerSecond(seconds) <<
" times a second, "
924 std::cout << std::endl;
927 std::this_thread::sleep_for(std::chrono::milliseconds(5));
929 std::cout <<
"cheat: the server closed the connection" << std::endl;
static absl::StatusOr< std::unique_ptr< Connection > > Create(const std::string &host, uint16_t port, asio::ssl::context &tls, const std::string &token, bool udp)
Connects to the server over TLS, or returns why it couldn't.
std::optional< Place > At(uint32_t id, std::chrono::nanoseconds time) const
void Record(uint32_t id, std::chrono::nanoseconds time, Place place)
float DamagePerSecond(double now) const
void Add(double at, uint32_t amount)
A hit that did the amount, at the time, in seconds on our clock.
float PerSecond(double now) const
Over the last five seconds to now, as a swing takes about one.
float MetresASecond() const
void Add(double sent, float x, float z)
absl::StatusOr< protocol::LoginReply > LogIn(const std::string &host, uint16_t port, asio::ssl::context &tls, const protocol::LoginRequest &request, std::chrono::milliseconds deadline)
std::string FileSetting(const char *name, const std::string &path)
absl::StatusOr< asio::ssl::context > ClientTls(const std::string &authority)
In metres from the middle of a land.