nanoMMO 0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
measure.h
Go to the documentation of this file.
1#ifndef NANOMMO_TOOLS_CHEAT_MEASURE_H_
2#define NANOMMO_TOOLS_CHEAT_MEASURE_H_
3
4#include <cstdint>
5#include <deque>
6
7namespace nanommo {
8
9/// How fast the server moves a player, from where its worlds put them: what a
10/// client that breaks the rules gets for it, if anything.
12 public:
13 /// Where a world had the player, sent at the time, in seconds on the
14 /// server's clock. A world older than the newest it has is left out.
15 void Add(double sent, float x, float z);
16
17 /// In metres a second, along the way it went over the last second of
18 /// worlds, so that turning back doesn't count against it, or 0 before two.
19 float MetresASecond() const;
20
21 private:
22 struct Place {
23 double sent = 0.0;
24 float x = 0.0f;
25 float z = 0.0f;
26 };
27 std::deque<Place> places_;
28};
29
30/// The hits a player lands, and their damage, from the events the server
31/// sends: what a client that breaks the rules gets for it in a fight.
32class Hits {
33 public:
34 /// A hit that did the amount, at the time, in seconds on our clock.
35 void Add(double at, uint32_t amount);
36
37 /// Over the last five seconds to now, as a swing takes about one.
38 float PerSecond(double now) const;
39 float DamagePerSecond(double now) const;
40
41 private:
42 struct Hit {
43 double at = 0.0;
44 uint32_t amount = 0;
45 };
46 std::deque<Hit> hits_;
47};
48
49} // namespace nanommo
50
51#endif // NANOMMO_TOOLS_CHEAT_MEASURE_H_
float DamagePerSecond(double now) const
Definition measure.cc:55
void Add(double at, uint32_t amount)
A hit that did the amount, at the time, in seconds on our clock.
Definition measure.cc:40
float PerSecond(double now) const
Over the last five seconds to now, as a swing takes about one.
Definition measure.cc:47
float MetresASecond() const
Definition measure.cc:27
void Add(double sent, float x, float z)
Definition measure.cc:17
Definition chat.cc:9