1#ifndef EXTRAS_H
2#define EXTRAS_H
3
4#include <string>
5#include <map>
6#include <framework/core/logger.h>
7#include <deque>
8
9constexpr bool default_value = true;
10
11#define DEFINE_OPTION(option, description) { m_options[ #option ] = std::make_pair(description, &(this -> option )); }
12
13class Extras {
14public:
15 Extras() {
16 DEFINE_OPTION(limitedPolling, "Limited polling");
17
18 DEFINE_OPTION(debugWalking, "Debug walking");
19 DEFINE_OPTION(debugPredictiveWalking, "Debug predictive walking");
20 DEFINE_OPTION(debugPathfinding, "Debug path finding");
21 DEFINE_OPTION(debugRender, "Debug render");
22 DEFINE_OPTION(debugProxy, "Debug proxy");
23 DEFINE_OPTION(showPredictions, "Show predictions");
24 DEFINE_OPTION(debugWidgets, "Debug widgets");
25
26 DEFINE_OPTION(disablePredictiveWalking, "Disable predictive walking");
27 }
28
29 bool botDetection = default_value;
30
31 bool newMapViewRendering = default_value;
32 bool limitedPolling = default_value;
33
34 bool debugWalking = false;
35 bool debugPredictiveWalking = false;
36 bool debugPathfinding = false;
37 bool debugRender = false;
38 bool debugProxy = false;
39 bool disablePredictiveWalking = false;
40 bool showPredictions = false;
41 bool debugWidgets = false;
42
43 int testMode = 0;
44
45 void set(const std::string& key, bool value) {
46 auto it = m_options.find(key);
47 if (it == m_options.end()) {
48 g_logger.fatal(std::string("Invalid extraOptions key:") + key);
49 return;
50 }
51 *(it->second.second) = value;
52 }
53
54 bool get(const std::string& key) {
55 auto it = m_options.find(key);
56 if (it == m_options.end()) {
57 g_logger.fatal(std::string("Invalid extraOptions key:") + key);
58 return false;
59 }
60 return *(it->second.second);
61 }
62
63 std::string getDescription(const std::string& key) {
64 auto it = m_options.find(key);
65 if (it == m_options.end()) {
66 g_logger.fatal(std::string("Invalid extraOptions key:") + key);
67 return "";
68 }
69 return it->second.first;
70 }
71
72 std::vector<std::string> getAll() {
73 std::vector<std::string> ret;
74 for (auto& it : m_options)
75 ret.push_back(it.first);
76 return ret;
77 }
78
79private:
80 std::map<std::string, std::pair<std::string, bool*>> m_options;
81 std::deque<ticks_t> framerRenderTimes;
82};
83
84extern Extras g_extras;
85
86#endif