add: new graph cmd: "stats", now accessible through cmd, not only via menu.
fix: changed language string hashes to reduce collisions.
This commit is contained in:
parent
5bef8f7540
commit
eadd7cd3a2
6 changed files with 72 additions and 51 deletions
|
|
@ -57,7 +57,7 @@ private:
|
||||||
StringArray m_logos;
|
StringArray m_logos;
|
||||||
StringArray m_avatars;
|
StringArray m_avatars;
|
||||||
|
|
||||||
HashMap <uint32, String, Hash <int32>> m_language;
|
HashMap <uint32, String, Hash <int32>> m_language { 256 };
|
||||||
HashMap <int32, DifficultyData> m_difficulty;
|
HashMap <int32, DifficultyData> m_difficulty;
|
||||||
|
|
||||||
// default tables for personality weapon preferences, overridden by weapon.cfg
|
// default tables for personality weapon preferences, overridden by weapon.cfg
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,7 @@ private:
|
||||||
int cmdNodeReleaseEditor ();
|
int cmdNodeReleaseEditor ();
|
||||||
int cmdNodeUpload ();
|
int cmdNodeUpload ();
|
||||||
int cmdNodeIterateCamp ();
|
int cmdNodeIterateCamp ();
|
||||||
|
int cmdNodeShowStats ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int menuMain (int item);
|
int menuMain (int item);
|
||||||
|
|
|
||||||
|
|
@ -371,6 +371,7 @@ public:
|
||||||
void convertToPOD (const Path &path, PODPath &pod);
|
void convertToPOD (const Path &path, PODPath &pod);
|
||||||
void convertCampDirection (Path &path);
|
void convertCampDirection (Path &path);
|
||||||
void setAutoPathDistance (const float distance);
|
void setAutoPathDistance (const float distance);
|
||||||
|
void showStats ();
|
||||||
|
|
||||||
const char *getDataDirectory (bool isMemoryFile = false);
|
const char *getDataDirectory (bool isMemoryFile = false);
|
||||||
const char *getOldFormatGraphName (bool isMemoryFile = false);
|
const char *getOldFormatGraphName (bool isMemoryFile = false);
|
||||||
|
|
|
||||||
|
|
@ -766,13 +766,21 @@ const char *BotConfig::translate (StringRef input) {
|
||||||
|
|
||||||
uint32 BotConfig::hashLangString (const char *input) {
|
uint32 BotConfig::hashLangString (const char *input) {
|
||||||
auto str = reinterpret_cast <uint8 *> (const_cast <char *> (input));
|
auto str = reinterpret_cast <uint8 *> (const_cast <char *> (input));
|
||||||
uint32 hash = 0;
|
uint32_t hash = 0;
|
||||||
|
|
||||||
while (*str++) {
|
for (; *str; ++str) {
|
||||||
if (!isalnum (*str)) {
|
if (!isalnum (*str)) {
|
||||||
continue;
|
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;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -325,6 +325,7 @@ int BotControl::cmdNode () {
|
||||||
addGraphCmd ("flags", "flags [noarguments]", "Open and displays menu for modifying flags for nearest point.", &BotControl::cmdNodeSetFlags);
|
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 ("teleport", "teleport [index]", "Teleports player to specified node index.", &BotControl::cmdNodeTeleport);
|
||||||
addGraphCmd ("upload", "upload [id]", "Uploads created graph to graph database.", &BotControl::cmdNodeUpload);
|
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
|
// add path commands
|
||||||
addGraphCmd ("path_create", "path_create [noarguments]", "Opens and displays path creation menu.", &BotControl::cmdNodePathCreate);
|
addGraphCmd ("path_create", "path_create [noarguments]", "Opens and displays path creation menu.", &BotControl::cmdNodePathCreate);
|
||||||
|
|
@ -842,6 +843,14 @@ int BotControl::cmdNodeIterateCamp () {
|
||||||
return BotCommandResult::Handled;
|
return BotCommandResult::Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int BotControl::cmdNodeShowStats () {
|
||||||
|
enum args { graph_cmd = 1 };
|
||||||
|
|
||||||
|
graph.showStats ();
|
||||||
|
|
||||||
|
return BotCommandResult::Handled;
|
||||||
|
}
|
||||||
|
|
||||||
int BotControl::menuMain (int item) {
|
int BotControl::menuMain (int item) {
|
||||||
showMenu (Menu::None); // reset menu display
|
showMenu (Menu::None); // reset menu display
|
||||||
|
|
||||||
|
|
@ -1222,54 +1231,11 @@ int BotControl::menuGraphPage2 (int item) {
|
||||||
showMenu (Menu::None); // reset menu display
|
showMenu (Menu::None); // reset menu display
|
||||||
|
|
||||||
switch (item) {
|
switch (item) {
|
||||||
case 1: {
|
case 1:
|
||||||
int terrPoints = 0;
|
graph.showStats ();
|
||||||
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);
|
|
||||||
|
|
||||||
showMenu (Menu::NodeMainPage2);
|
showMenu (Menu::NodeMainPage2);
|
||||||
} break;
|
|
||||||
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
graph.setEditFlag (GraphEdit::On);
|
graph.setEditFlag (GraphEdit::On);
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
void BotGraph::calculatePathRadius (int index) {
|
||||||
// calculate "wayzones" for the nearest node (meaning a dynamic distance area to vary node origin)
|
// calculate "wayzones" for the nearest node (meaning a dynamic distance area to vary node origin)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue