diff --git a/inc/config.h b/inc/config.h index 0ee08e3..d67304e 100644 --- a/inc/config.h +++ b/inc/config.h @@ -57,7 +57,7 @@ private: StringArray m_logos; StringArray m_avatars; - HashMap > m_language; + HashMap > m_language { 256 }; HashMap m_difficulty; // default tables for personality weapon preferences, overridden by weapon.cfg diff --git a/inc/control.h b/inc/control.h index 74e64d8..1f698dd 100644 --- a/inc/control.h +++ b/inc/control.h @@ -104,6 +104,7 @@ private: int cmdNodeReleaseEditor (); int cmdNodeUpload (); int cmdNodeIterateCamp (); + int cmdNodeShowStats (); private: int menuMain (int item); diff --git a/inc/graph.h b/inc/graph.h index 08d7ce6..929da1d 100644 --- a/inc/graph.h +++ b/inc/graph.h @@ -371,6 +371,7 @@ public: void convertToPOD (const Path &path, PODPath &pod); void convertCampDirection (Path &path); void setAutoPathDistance (const float distance); + void showStats (); const char *getDataDirectory (bool isMemoryFile = false); const char *getOldFormatGraphName (bool isMemoryFile = false); diff --git a/src/config.cpp b/src/config.cpp index aa3330f..7545c92 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -766,13 +766,21 @@ const char *BotConfig::translate (StringRef input) { uint32 BotConfig::hashLangString (const char *input) { auto str = reinterpret_cast (const_cast (input)); - uint32 hash = 0; + uint32_t hash = 0; - while (*str++) { + for (; *str; ++str) { if (!isalnum (*str)) { continue; } - hash = ((*str << 5) + hash) + *str; + + hash += *str; + hash += (hash << 10); + hash ^= (hash >> 6); } + + hash += (hash << 3); + hash ^= (hash >> 11); + hash += (hash << 15); + return hash; } diff --git a/src/control.cpp b/src/control.cpp index e63771e..470051b 100644 --- a/src/control.cpp +++ b/src/control.cpp @@ -325,6 +325,7 @@ int BotControl::cmdNode () { addGraphCmd ("flags", "flags [noarguments]", "Open and displays menu for modifying flags for nearest point.", &BotControl::cmdNodeSetFlags); addGraphCmd ("teleport", "teleport [index]", "Teleports player to specified node index.", &BotControl::cmdNodeTeleport); addGraphCmd ("upload", "upload [id]", "Uploads created graph to graph database.", &BotControl::cmdNodeUpload); + addGraphCmd ("stats", "[noarguments]", "Shows the stats about node types on the map.", &BotControl::cmdNodeShowStats); // add path commands addGraphCmd ("path_create", "path_create [noarguments]", "Opens and displays path creation menu.", &BotControl::cmdNodePathCreate); @@ -842,6 +843,14 @@ int BotControl::cmdNodeIterateCamp () { return BotCommandResult::Handled; } +int BotControl::cmdNodeShowStats () { + enum args { graph_cmd = 1 }; + + graph.showStats (); + + return BotCommandResult::Handled; +} + int BotControl::menuMain (int item) { showMenu (Menu::None); // reset menu display @@ -1222,54 +1231,11 @@ int BotControl::menuGraphPage2 (int item) { showMenu (Menu::None); // reset menu display switch (item) { - case 1: { - int terrPoints = 0; - int ctPoints = 0; - int goalPoints = 0; - int rescuePoints = 0; - int campPoints = 0; - int sniperPoints = 0; - int noHostagePoints = 0; - - for (int i = 0; i < graph.length (); ++i) { - const Path &path = graph[i]; - - if (path.flags & NodeFlag::TerroristOnly) { - ++terrPoints; - } - - if (path.flags & NodeFlag::CTOnly) { - ++ctPoints; - } - - if (path.flags & NodeFlag::Goal) { - ++goalPoints; - } - - if (path.flags & NodeFlag::Rescue) { - ++rescuePoints; - } - - if (path.flags & NodeFlag::Camp) { - ++campPoints; - } - - if (path.flags & NodeFlag::Sniper) { - ++sniperPoints; - } - - if (path.flags & NodeFlag::NoHostage) { - ++noHostagePoints; - } - } - msg ("Nodes: %d - T Points: %d\n" - "CT Points: %d - Goal Points: %d\n" - "Rescue Points: %d - Camp Points: %d\n" - "Block Hostage Points: %d - Sniper Points: %d\n", - graph.length (), terrPoints, ctPoints, goalPoints, rescuePoints, campPoints, noHostagePoints, sniperPoints); - + case 1: + graph.showStats (); showMenu (Menu::NodeMainPage2); - } break; + + break; case 2: graph.setEditFlag (GraphEdit::On); diff --git a/src/graph.cpp b/src/graph.cpp index 7db2d5b..547c41a 100644 --- a/src/graph.cpp +++ b/src/graph.cpp @@ -1076,6 +1076,51 @@ void BotGraph::setAutoPathDistance (const float distance) { } } +void BotGraph::showStats () { + int terrPoints = 0; + int ctPoints = 0; + int goalPoints = 0; + int rescuePoints = 0; + int campPoints = 0; + int sniperPoints = 0; + int noHostagePoints = 0; + + for (const auto &path : m_paths) { + if (path.flags & NodeFlag::TerroristOnly) { + ++terrPoints; + } + + if (path.flags & NodeFlag::CTOnly) { + ++ctPoints; + } + + if (path.flags & NodeFlag::Goal) { + ++goalPoints; + } + + if (path.flags & NodeFlag::Rescue) { + ++rescuePoints; + } + + if (path.flags & NodeFlag::Camp) { + ++campPoints; + } + + if (path.flags & NodeFlag::Sniper) { + ++sniperPoints; + } + + if (path.flags & NodeFlag::NoHostage) { + ++noHostagePoints; + } + } + + ctrl.msg ("Nodes: %d - T Points: %d", m_paths.length (), terrPoints); + ctrl.msg ("CT Points: %d - Goal Points: %d", ctPoints, goalPoints); + ctrl.msg ("Rescue Points: %d - Camp Points: %d", rescuePoints, campPoints); + ctrl.msg ("Block Hostage Points: %d - Sniper Points: %d", noHostagePoints, sniperPoints); +} + void BotGraph::calculatePathRadius (int index) { // calculate "wayzones" for the nearest node (meaning a dynamic distance area to vary node origin)