fix: center-screen messages not appearing (fix: #446)

fix: crash when creating too much threads
refactor: fix typos in comments in headers
This commit is contained in:
jeefo 2023-05-12 22:12:22 +03:00
commit 7f4d4748fa
No known key found for this signature in database
GPG key ID: 927BCA0779BEA8ED
22 changed files with 105 additions and 99 deletions

View file

@ -522,13 +522,13 @@
0. Выход 0. Выход
[ORIGINAL] [ORIGINAL]
Starting map analyzation. Starting map analysis.
[TRANSLATED] [TRANSLATED]
Начинается анализ карты. Начинается анализ карты.
[ORIGINAL] [ORIGINAL]
Completed map analyzation. Completed map analysis.
[TRANSLATED] [TRANSLATED]
Анализ карты завершён. Анализ карты завершён.
@ -1844,7 +1844,7 @@ Autostart analyzer if all other cases are failed.
Автозапуск анализатора, если все остальные случаи оказались неудачными. Автозапуск анализатора, если все остальные случаи оказались неудачными.
[ORIGINAL] [ORIGINAL]
Auto save results of analyzation to graph file. And re-add bots. Auto save results of analysis to graph file. And re-add bots.
[TRANSLATED] [TRANSLATED]
Автоматически сохранять результаты анализа в graph файл. И повторно добавлять ботов. Автоматически сохранять результаты анализа в graph файл. И повторно добавлять ботов.

@ -1 +1 @@
Subproject commit 9c2d3a60e330e2db3516a657289cfdae51c3053a Subproject commit 8053580ddde4ad6c8de7b33d1e29131fb87facd1

View file

@ -7,7 +7,7 @@
#pragma once #pragma once
// next code is based on cs-ebot implemntation, devised by EfeDursun125 // next code is based on cs-ebot implementation, devised by EfeDursun125
class GraphAnalyze : public Singleton <GraphAnalyze> { class GraphAnalyze : public Singleton <GraphAnalyze> {
public: public:
GraphAnalyze () = default; GraphAnalyze () = default;
@ -16,21 +16,21 @@ public:
private: private:
float m_updateInterval {}; // time to update analyzer float m_updateInterval {}; // time to update analyzer
bool m_basicsCreated {}; // basics waypoints were created? bool m_basicsCreated {}; // basics nodes were created?
bool m_isCrouch {}; // is node to be created as crouch ? bool m_isCrouch {}; // is node to be created as crouch ?
bool m_isAnalyzing {}; // we're in analyzing ? bool m_isAnalyzing {}; // we're in analyzing ?
bool m_isAnalyzed {}; // current waypoint is analyzed bool m_isAnalyzed {}; // current node is analyzed
bool m_expandedNodes[kMaxNodes] {}; // all nodes expanded ? bool m_expandedNodes[kMaxNodes] {}; // all nodes expanded ?
bool m_optimizedNodes[kMaxNodes] {}; // all nodes expanded ? bool m_optimizedNodes[kMaxNodes] {}; // all nodes expanded ?
public: public:
// start analyzation process // start analysis process
void start (); void start ();
// update analyzation process // update analysis process
void update (); void update ();
// suspend aanalyzing // suspend analysis
void suspend (); void suspend ();
private: private:
@ -40,10 +40,10 @@ private:
// set update interval (keeps game from freezing) // set update interval (keeps game from freezing)
void setUpdateInterval (); void setUpdateInterval ();
// mark waypoints as goals // mark nodes as goals
void markGoals (); void markGoals ();
// terminate analyzation and save data // terminate analysis and save data
void finish (); void finish ();
// optimize nodes a little // optimize nodes a little
@ -59,7 +59,7 @@ public:
return m_isCrouch; return m_isCrouch;
} }
// is currently anaylyzing ? // is currently analyzing ?
bool isAnalyzing () const { bool isAnalyzing () const {
return m_isAnalyzing; return m_isAnalyzing;
} }
@ -75,5 +75,5 @@ public:
} }
}; };
// explose global // expose global
CR_EXPOSE_GLOBAL_SINGLETON (GraphAnalyze, analyzer); CR_EXPOSE_GLOBAL_SINGLETON (GraphAnalyze, analyzer);

View file

@ -139,7 +139,7 @@ private:
return line.substr (0, 1).findFirstOf ("#/;") != String::InvalidIndex; return line.substr (0, 1).findFirstOf ("#/;") != String::InvalidIndex;
}; };
// hash the lang string, only the letters // hash the language string, only the letters
uint32_t hashLangString (StringRef str); uint32_t hashLangString (StringRef str);
public: public:

View file

@ -10,7 +10,7 @@
// command handler status // command handler status
CR_DECLARE_SCOPED_ENUM (BotCommandResult, CR_DECLARE_SCOPED_ENUM (BotCommandResult,
Handled = 0, // command successfully handled Handled = 0, // command successfully handled
ListenServer, // command is only avaialble on listen server ListenServer, // command is only available on listen server
BadFormat // wrong params BadFormat // wrong params
) )
@ -224,7 +224,7 @@ public:
return m_ent; return m_ent;
} }
// global heloer for sending message to correct channel // global helper for sending message to correct channel
template <typename ...Args> void msg (const char *fmt, Args &&...args); template <typename ...Args> void msg (const char *fmt, Args &&...args);
public: public:
@ -242,7 +242,7 @@ public:
bool handleMenuCommands (edict_t *ent); bool handleMenuCommands (edict_t *ent);
}; };
// global heloer for sending message to correct channel // global helper for sending message to correct channel
template <typename ...Args> inline void BotControl::msg (const char *fmt, Args &&...args) { template <typename ...Args> inline void BotControl::msg (const char *fmt, Args &&...args) {
m_ignoreTranslate = game.isDedicated () && game.isNullEntity (m_ent); m_ignoreTranslate = game.isDedicated () && game.isNullEntity (m_ent);
@ -274,7 +274,7 @@ template <typename ...Args> inline void BotControl::msg (const char *fmt, Args &
} }
} }
// graph heloer for sending message to correct channel // graph helper for sending message to correct channel
template <typename ...Args> inline void BotGraph::msg (const char *fmt, Args &&...args) { template <typename ...Args> inline void BotGraph::msg (const char *fmt, Args &&...args) {
if (m_silenceMessages) { if (m_silenceMessages) {
return; // no messages while analyzing (too much spam) return; // no messages while analyzing (too much spam)
@ -283,5 +283,5 @@ template <typename ...Args> inline void BotGraph::msg (const char *fmt, Args &&.
} }
// explose global // expose global
CR_EXPOSE_GLOBAL_SINGLETON (BotControl, ctrl); CR_EXPOSE_GLOBAL_SINGLETON (BotControl, ctrl);

View file

@ -194,7 +194,7 @@ public:
// sends local registration stack for engine registration // sends local registration stack for engine registration
void registerCvars (bool gameVars = false); void registerCvars (bool gameVars = false);
// checks whether softwared rendering is enabled // checks whether software rendering is enabled
bool isSoftwareRenderer (); bool isSoftwareRenderer ();
// load the cs binary in non metamod mode // load the cs binary in non metamod mode
@ -386,7 +386,7 @@ public:
// prints center message to specified player // prints center message to specified player
template <typename ...Args> void clientPrint (edict_t *ent, const char *fmt, Args &&...args) { template <typename ...Args> void clientPrint (edict_t *ent, const char *fmt, Args &&...args) {
if (isNullEntity (ent) || ent == getLocalEntity ()) { if (isNullEntity (ent)) {
print (fmt, cr::forward <Args> (args)...); print (fmt, cr::forward <Args> (args)...);
return; return;
} }
@ -395,7 +395,7 @@ public:
// prints message to client console // prints message to client console
template <typename ...Args> void centerPrint (edict_t *ent, const char *fmt, Args &&...args) { template <typename ...Args> void centerPrint (edict_t *ent, const char *fmt, Args &&...args) {
if (isNullEntity (ent) || ent == getLocalEntity ()) { if (isNullEntity (ent)) {
print (fmt, cr::forward <Args> (args)...); print (fmt, cr::forward <Args> (args)...);
return; return;
} }
@ -431,7 +431,7 @@ public:
else if constexpr (cr::is_same <U, int>::value) { else if constexpr (cr::is_same <U, int>::value) {
return static_cast <int> (ptr->value); return static_cast <int> (ptr->value);
} }
assert ("!Inavlid type requeted."); assert ("!Invalid type requested.");
} }
bool bool_ () const { bool bool_ () const {
@ -525,11 +525,11 @@ public:
} }
public: public:
static inline uint16_t fu16 (float value, float scale) { static constexpr uint16_t fu16 (float value, float scale) {
return cr::clamp <uint16_t> (static_cast <uint16_t> (value * cr::bit (static_cast <short> (scale))), 0, USHRT_MAX); return cr::clamp <uint16_t> (static_cast <uint16_t> (value * cr::bit (static_cast <short> (scale))), 0, USHRT_MAX);
} }
static inline short fs16 (float value, float scale) { static constexpr short fs16 (float value, float scale) {
return cr::clamp <short> (static_cast <short> (value * cr::bit (static_cast <short> (scale))), -SHRT_MAX, SHRT_MAX); return cr::clamp <short> (static_cast <short> (value * cr::bit (static_cast <short> (scale))), -SHRT_MAX, SHRT_MAX);
} }
}; };

View file

@ -88,7 +88,7 @@ CR_DECLARE_SCOPED_ENUM (NotifySound,
#include <vistable.h> #include <vistable.h>
// general waypoint header information structure // general waypoint header information structure for podbot
struct PODGraphHeader { struct PODGraphHeader {
char header[8]; char header[8];
int32_t fileVersion; int32_t fileVersion;
@ -97,7 +97,7 @@ struct PODGraphHeader {
char author[32]; char author[32];
}; };
// defines linked waypoints // defines linked nodes
struct PathLink { struct PathLink {
Vector velocity; Vector velocity;
int32_t distance; int32_t distance;
@ -126,7 +126,7 @@ struct PODPath {
PathVis vis; PathVis vis;
}; };
// general stprage header information structure // general storage header information structure
struct StorageHeader { struct StorageHeader {
int32_t magic; int32_t magic;
int32_t version; int32_t version;
@ -328,7 +328,7 @@ public:
return m_editor; return m_editor;
} }
// slicence all graph messages or not // silence all graph messages or not
void setMessageSilence (bool enable) { void setMessageSilence (bool enable) {
m_silenceMessages = enable; m_silenceMessages = enable;
} }
@ -344,7 +344,7 @@ public:
} }
public: public:
// graph heloer for sending message to correct channel // graph helper for sending message to correct channel
template <typename ...Args> void msg (const char *fmt, Args &&...args); template <typename ...Args> void msg (const char *fmt, Args &&...args);
public: public:
@ -368,5 +368,5 @@ public:
#include <manager.h> #include <manager.h>
#include <practice.h> #include <practice.h>
// explose global // expose global
CR_EXPOSE_GLOBAL_SINGLETON (BotGraph, graph); CR_EXPOSE_GLOBAL_SINGLETON (BotGraph, graph);

View file

@ -74,7 +74,7 @@ private:
int m_bombSayStatus {}; // some bot is issued whine about bomb int m_bombSayStatus {}; // some bot is issued whine about bomb
int m_lastRadio[kGameTeamNum] {}; // last radio message for team int m_lastRadio[kGameTeamNum] {}; // last radio message for team
bool m_leaderChoosen[kGameTeamNum] {}; // is team leader choose theese round bool m_leaderChoosen[kGameTeamNum] {}; // is team leader choose thees round
bool m_economicsGood[kGameTeamNum] {}; // is team able to buy anything bool m_economicsGood[kGameTeamNum] {}; // is team able to buy anything
bool m_bombPlanted {}; bool m_bombPlanted {};
bool m_botsCanPause {}; bool m_botsCanPause {};
@ -326,7 +326,7 @@ public:
} }
}; };
// explose global // expose global
CR_EXPOSE_GLOBAL_SINGLETON (BotManager, bots); CR_EXPOSE_GLOBAL_SINGLETON (BotManager, bots);
// expose async worker // expose async worker

View file

@ -28,7 +28,7 @@ public:
// gets the node nearest to origin // gets the node nearest to origin
virtual int getNearestNode (float *origin) = 0; virtual int getNearestNode (float *origin) = 0;
// checks wether node is valid // checks whether node is valid
virtual bool isNodeValid (int node) = 0; virtual bool isNodeValid (int node) = 0;
// gets the node origin // gets the node origin

View file

@ -126,5 +126,5 @@ public:
} }
}; };
// explose global // expose global
CR_EXPOSE_GLOBAL_SINGLETON (BotPractice, practice); CR_EXPOSE_GLOBAL_SINGLETON (BotPractice, practice);

View file

@ -36,5 +36,5 @@ public:
void simulateNoise (int playerIndex); void simulateNoise (int playerIndex);
}; };
// explose global // expose global
CR_EXPOSE_GLOBAL_SINGLETON (BotSounds, sounds); CR_EXPOSE_GLOBAL_SINGLETON (BotSounds, sounds);

View file

@ -72,20 +72,20 @@ public:
// saves the data and compress with ulz // saves the data and compress with ulz
template <typename U> bool save (const SmallArray <U> &data, ExtenHeader *exten = nullptr, int32_t passOptions = 0); template <typename U> bool save (const SmallArray <U> &data, ExtenHeader *exten = nullptr, int32_t passOptions = 0);
// report fatail error loading stuff // report fatal error loading stuff
template <typename ...Args> bool error (bool isGraph, bool isDebug, MemFile &file, const char *fmt, Args &&...args); template <typename ...Args> bool error (bool isGraph, bool isDebug, MemFile &file, const char *fmt, Args &&...args);
// builds the filename to requested filename // builds the filename to requested filename
String buildPath (int32_t type, bool isMemoryLoad = false); String buildPath (int32_t type, bool isMemoryLoad = false);
// converts storage option to stroage filename // converts storage option to storage filename
int32_t storageToBotFile (int32_t options); int32_t storageToBotFile (int32_t options);
// remove all bot related files frorm disk // remove all bot related files from disk
void unlinkFromDisk (); void unlinkFromDisk ();
public: public:
// loading the graph may attemp to recurse loading, with converting or download, reset retry counter // loading the graph may attempt to recurse loading, with converting or download, reset retry counter
void resetRetries () { void resetRetries () {
m_retries = 0; m_retries = 0;
} }
@ -98,6 +98,6 @@ public:
#undef BOT_STORAGE_EXPLICIT_INSTANTIATIONS #undef BOT_STORAGE_EXPLICIT_INSTANTIATIONS
// explose global // expose global
CR_EXPOSE_GLOBAL_SINGLETON (BotStorage, bstor); CR_EXPOSE_GLOBAL_SINGLETON (BotStorage, bstor);

View file

@ -39,16 +39,16 @@ public:
// check if entity is alive // check if entity is alive
bool isAlive (edict_t *ent); bool isAlive (edict_t *ent);
// checks if entitiy is fakeclient // checks if entity is fakeclient
bool isFakeClient (edict_t *ent); bool isFakeClient (edict_t *ent);
// check if entitiy is a player // check if entity is a player
bool isPlayer (edict_t *ent); bool isPlayer (edict_t *ent);
// check if entitiy is a monster // check if entity is a monster
bool isMonster (edict_t *ent); bool isMonster (edict_t *ent);
// check if entitiy is a item // check if entity is a item
bool isItem (edict_t *ent); bool isItem (edict_t *ent);
// check if entity is a vip // check if entity is a vip
@ -90,13 +90,13 @@ public:
// send modified pings to all the clients // send modified pings to all the clients
void emitPings (edict_t *to); void emitPings (edict_t *to);
// installs the sendto function intreception // installs the sendto function interception
void installSendTo (); void installSendTo ();
// check if object inside frustum plane // check if object inside frustum plane
bool isObjectInsidePlane (FrustumPlane &plane, const Vector &center, float height, float radius); bool isObjectInsidePlane (FrustumPlane &plane, const Vector &center, float height, float radius);
// checks if same model ommiting the models directory // checks if same model omitting the models directory
bool isModel (const edict_t *ent, StringRef model); bool isModel (const edict_t *ent, StringRef model);
// get the current date and time as string // get the current date and time as string
@ -143,5 +143,5 @@ public:
static int32_t CR_STDCALL sendTo (int socket, const void *message, size_t length, int flags, const struct sockaddr *dest, int destLength); static int32_t CR_STDCALL sendTo (int socket, const void *message, size_t length, int flags, const struct sockaddr *dest, int destLength);
}; };
// explose global // expose global
CR_EXPOSE_GLOBAL_SINGLETON (BotSupport, util); CR_EXPOSE_GLOBAL_SINGLETON (BotSupport, util);

View file

@ -56,6 +56,6 @@ public:
} }
}; };
// explose global // expose global
CR_EXPOSE_GLOBAL_SINGLETON (GraphVistable, vistab); CR_EXPOSE_GLOBAL_SINGLETON (GraphVistable, vistab);

View file

@ -388,7 +388,7 @@ CR_DECLARE_SCOPED_ENUM_TYPE (AimFlags, uint32_t,
Enemy = cr::bit (5), // aim at enemy Enemy = cr::bit (5), // aim at enemy
Grenade = cr::bit (6), // aim for grenade throw Grenade = cr::bit (6), // aim for grenade throw
Override = cr::bit (7), // overrides all others (blinded) Override = cr::bit (7), // overrides all others (blinded)
Danger = cr::bit (8) // additional danger falg Danger = cr::bit (8) // additional danger flag
) )
// famas/glock burst mode status + m4a1/usp silencer // famas/glock burst mode status + m4a1/usp silencer
@ -416,7 +416,7 @@ CR_DECLARE_SCOPED_ENUM (FrustumSide,
Num Num
) )
// some hardcoded desire defines used to override calculated ones // some hard-coded desire defines used to override calculated ones
struct TaskPri { struct TaskPri {
static constexpr auto Normal { 35.0f }; static constexpr auto Normal { 35.0f };
static constexpr auto Pause { 36.0f }; static constexpr auto Pause { 36.0f };
@ -562,7 +562,7 @@ struct Client {
int team2; // real bot team in free for all mode (csdm) int team2; // real bot team in free for all mode (csdm)
int flags; // client flags int flags; // client flags
int radio; // radio orders int radio; // radio orders
int menu; // identifier to openen menu int menu; // identifier to opened menu
int ping; // when bot latency is enabled, client ping stored here int ping; // when bot latency is enabled, client ping stored here
int iconFlags[kGameMaxPlayers]; // flag holding chatter icons int iconFlags[kGameMaxPlayers]; // flag holding chatter icons
float iconTimestamp[kGameMaxPlayers]; // timers for chatter icons float iconTimestamp[kGameMaxPlayers]; // timers for chatter icons
@ -676,7 +676,7 @@ private:
int m_plantedBombNodeIndex {}; // nearest to planted bomb node int m_plantedBombNodeIndex {}; // nearest to planted bomb node
int m_currentNodeIndex {}; // current node index int m_currentNodeIndex {}; // current node index
int m_travelStartIndex {}; // travel start index to double jump action int m_travelStartIndex {}; // travel start index to double jump action
int m_previousNodes[5] {}; // previous node indices from node find int m_previousNodes[5] {}; // previous node indexes from node find
int m_pathFlags {}; // current node flags int m_pathFlags {}; // current node flags
int m_needAvoidGrenade {}; // which direction to strafe away int m_needAvoidGrenade {}; // which direction to strafe away
int m_campDirection {}; // camp Facing direction int m_campDirection {}; // camp Facing direction
@ -702,7 +702,7 @@ private:
float m_lastCommandTime {}; // time bot last thinked float m_lastCommandTime {}; // time bot last thinked
float m_reloadCheckTime {}; // time to check reloading float m_reloadCheckTime {}; // time to check reloading
float m_zoomCheckTime {}; // time to check zoom again float m_zoomCheckTime {}; // time to check zoom again
float m_shieldCheckTime {}; // time to check shiled drawing again float m_shieldCheckTime {}; // time to check shield drawing again
float m_grenadeCheckTime {}; // time to check grenade usage float m_grenadeCheckTime {}; // time to check grenade usage
float m_sniperStopTime {}; // bot switched to other weapon? float m_sniperStopTime {}; // bot switched to other weapon?
float m_lastEquipTime {}; // last time we equipped in buyzone float m_lastEquipTime {}; // last time we equipped in buyzone
@ -740,7 +740,7 @@ private:
float m_joinServerTime {}; // time when bot joined the game float m_joinServerTime {}; // time when bot joined the game
float m_playServerTime {}; // time bot spent in the game float m_playServerTime {}; // time bot spent in the game
float m_changeViewTime {}; // timestamp to change look at while at freezetime float m_changeViewTime {}; // timestamp to change look at while at freezetime
float m_breakableTime {}; // breakeble acquired time float m_breakableTime {}; // breakable acquired time
float m_stuckTimestamp {}; // last time was stuck float m_stuckTimestamp {}; // last time was stuck
bool m_moveToGoal {}; // bot currently moving to goal?? bool m_moveToGoal {}; // bot currently moving to goal??
@ -782,7 +782,7 @@ private:
edict_t *m_lastBreakable {}; // last acquired breakable edict_t *m_lastBreakable {}; // last acquired breakable
edict_t *m_targetEntity {}; // the entity that the bot is trying to reach edict_t *m_targetEntity {}; // the entity that the bot is trying to reach
edict_t *m_avoidGrenade {}; // pointer to grenade entity to avoid edict_t *m_avoidGrenade {}; // pointer to grenade entity to avoid
edict_t *m_hindrance {}; // the hidrance edict_t *m_hindrance {}; // the hindrance
Vector m_liftTravelPos {}; // lift travel position Vector m_liftTravelPos {}; // lift travel position
Vector m_moveAngles {}; // bot move angles Vector m_moveAngles {}; // bot move angles
@ -1070,7 +1070,7 @@ public:
int m_basePing {}; // base ping for bot int m_basePing {}; // base ping for bot
int m_numEnemiesLeft {}; // number of enemies alive left on map int m_numEnemiesLeft {}; // number of enemies alive left on map
int m_numFriendsLeft {}; // number of friend alive left on map int m_numFriendsLeft {}; // number of friend alive left on map
int m_retryJoin {}; // retry count for chosing team/class int m_retryJoin {}; // retry count for choosing team/class
int m_startAction {}; // team/class selection state int m_startAction {}; // team/class selection state
int m_voteKickIndex {}; // index of player to vote against int m_voteKickIndex {}; // index of player to vote against
int m_lastVoteKick {}; // last index int m_lastVoteKick {}; // last index
@ -1094,7 +1094,7 @@ public:
bool m_ignoreBuyDelay {}; // when reaching buyzone in the middle of the round don't do pauses bool m_ignoreBuyDelay {}; // when reaching buyzone in the middle of the round don't do pauses
bool m_inBombZone {}; // bot in the bomb zone or not bool m_inBombZone {}; // bot in the bomb zone or not
bool m_inBuyZone {}; // bot currently in buy zone bool m_inBuyZone {}; // bot currently in buy zone
bool m_inVIPZone {}; // bot in the vip satefy zone bool m_inVIPZone {}; // bot in the vip safety zone
bool m_buyingFinished {}; // done with buying bool m_buyingFinished {}; // done with buying
bool m_buyPending {}; // bot buy is pending bool m_buyPending {}; // bot buy is pending
bool m_hasDefuser {}; // does bot has defuser bool m_hasDefuser {}; // does bot has defuser
@ -1233,7 +1233,7 @@ public:
return m_currentNodeIndex; return m_currentNodeIndex;
} }
// is low on admmo on index? // is low on ammo on index?
bool isLowOnAmmo (const int index, const float factor) const; bool isLowOnAmmo (const int index, const float factor) const;
// prints debug message // prints debug message

View file

@ -8,7 +8,7 @@
#include <yapb.h> #include <yapb.h>
ConVar cv_graph_analyze_auto_start ("yb_graph_analyze_auto_start", "1", "Autostart analyzer if all other cases are failed."); ConVar cv_graph_analyze_auto_start ("yb_graph_analyze_auto_start", "1", "Autostart analyzer if all other cases are failed.");
ConVar cv_graph_analyze_auto_save ("yb_graph_analyze_auto_save", "1", "Auto save results of analyzation to graph file. And re-add bots."); ConVar cv_graph_analyze_auto_save ("yb_graph_analyze_auto_save", "1", "Auto save results of analysis to graph file. And re-add bots.");
ConVar cv_graph_analyze_distance ("yb_graph_analyze_distance", "64", "The minimum distance to keep nodes from each other.", true, 42.0f, 128.0f); ConVar cv_graph_analyze_distance ("yb_graph_analyze_distance", "64", "The minimum distance to keep nodes from each other.", true, 42.0f, 128.0f);
ConVar cv_graph_analyze_max_jump_height ("yb_graph_analyze_max_jump_height", "44", "Max jump height to test if next node will be unreachable.", true, 44.0f, 64.0f); ConVar cv_graph_analyze_max_jump_height ("yb_graph_analyze_max_jump_height", "44", "Max jump height to test if next node will be unreachable.", true, 44.0f, 64.0f);
ConVar cv_graph_analyze_fps ("yb_graph_analyze_fps", "30.0", "The FPS at which analyzer process is running. This keeps game from freezing during analyzing.", false, 25.0f, 99.0f); ConVar cv_graph_analyze_fps ("yb_graph_analyze_fps", "30.0", "The FPS at which analyzer process is running. This keeps game from freezing during analyzing.", false, 25.0f, 99.0f);
@ -37,7 +37,7 @@ void GraphAnalyze::start () {
for (auto &optimized : m_optimizedNodes) { for (auto &optimized : m_optimizedNodes) {
optimized = false; optimized = false;
} }
ctrl.msg ("Starting map analyzation."); ctrl.msg ("Starting map analysis.");
} }
else { else {
m_updateInterval = 0.0f; m_updateInterval = 0.0f;
@ -143,7 +143,7 @@ void GraphAnalyze::finish () {
// un-silence all graph messages // un-silence all graph messages
graph.setMessageSilence (false); graph.setMessageSilence (false);
ctrl.msg ("Completed map analyzation."); ctrl.msg ("Completed map analysis.");
// auto save bots graph // auto save bots graph
if (cv_graph_analyze_auto_save.bool_ ()) { if (cv_graph_analyze_auto_save.bool_ ()) {

View file

@ -689,7 +689,7 @@ Vector Bot::getCampDirection (const Vector &dest) {
} }
float minDistance = kInfiniteDistance; float minDistance = kInfiniteDistance;
int lookAtWaypoint = kInvalidNodeIndex; int lookAtNode = kInvalidNodeIndex;
const Path &path = graph[tempIndex]; const Path &path = graph[tempIndex];
for (auto &link : path.links) { for (auto &link : path.links) {
@ -700,12 +700,12 @@ Vector Bot::getCampDirection (const Vector &dest) {
if (distance < minDistance) { if (distance < minDistance) {
minDistance = distance; minDistance = distance;
lookAtWaypoint = link.index; lookAtNode = link.index;
} }
} }
if (graph.exists (lookAtWaypoint)) { if (graph.exists (lookAtNode)) {
return graph[lookAtWaypoint].origin; return graph[lookAtNode].origin;
} }
} }
auto dangerIndex = practice.getIndex (m_team, m_currentNodeIndex, m_currentNodeIndex); auto dangerIndex = practice.getIndex (m_team, m_currentNodeIndex, m_currentNodeIndex);
@ -1498,7 +1498,7 @@ void Bot::overrideConditions () {
if (isKnifeMode () && (util.isPlayer (m_enemy) || (cv_attack_monsters.bool_ () && util.isMonster (m_enemy)))) { if (isKnifeMode () && (util.isPlayer (m_enemy) || (cv_attack_monsters.bool_ () && util.isMonster (m_enemy)))) {
float length = pev->origin.distance2d (m_enemy->v.origin); float length = pev->origin.distance2d (m_enemy->v.origin);
// do waypoint movement if enemy is not reachable with a knife // do nodes movement if enemy is not reachable with a knife
if (length > 250.0f && (m_states & Sense::SeeingEnemy)) { if (length > 250.0f && (m_states & Sense::SeeingEnemy)) {
int nearestToEnemyPoint = graph.getNearest (m_enemy->v.origin); int nearestToEnemyPoint = graph.getNearest (m_enemy->v.origin);
@ -2490,7 +2490,7 @@ void Bot::checkRadioQueue () {
float minDistance = kInfiniteDistance; float minDistance = kInfiniteDistance;
int bombPoint = kInvalidNodeIndex; int bombPoint = kInvalidNodeIndex;
// find nearest bomb waypoint to player // find nearest bomb node to player
for (auto &point : graph.m_goalPoints) { for (auto &point : graph.m_goalPoints) {
distance = graph[point].origin.distanceSq (m_radioEntity->v.origin); distance = graph[point].origin.distanceSq (m_radioEntity->v.origin);
@ -2500,7 +2500,7 @@ void Bot::checkRadioQueue () {
} }
} }
// mark this waypoint as restricted point // mark this node as restricted point
if (bombPoint != kInvalidNodeIndex && !graph.isVisited (bombPoint)) { if (bombPoint != kInvalidNodeIndex && !graph.isVisited (bombPoint)) {
// does this bot want to defuse? // does this bot want to defuse?
if (getCurrentTaskId () == Task::Normal) { if (getCurrentTaskId () == Task::Normal) {

View file

@ -2335,7 +2335,7 @@ void BotControl::createMenus () {
"0. Exit", "0. Exit",
&BotControl::menuGraphPage2); &BotControl::menuGraphPage2);
// select waypoint radius menu // select nodes radius menu
m_menus.emplace ( m_menus.emplace (
Menu::NodeRadius, keys (9), Menu::NodeRadius, keys (9),
"\\yWaypoint Radius\\w\n\n" "\\yWaypoint Radius\\w\n\n"
@ -2351,7 +2351,7 @@ void BotControl::createMenus () {
"0. Exit", "0. Exit",
&BotControl::menuGraphRadius); &BotControl::menuGraphRadius);
// waypoint add menu // nodes add menu
m_menus.emplace ( m_menus.emplace (
Menu::NodeType, keys (9), Menu::NodeType, keys (9),
"\\yWaypoint Type\\w\n\n" "\\yWaypoint Type\\w\n\n"

View file

@ -38,8 +38,8 @@ void Game::precache () {
m_drawModels[DrawLine::Simple] = m_engineWrap.precacheModel ("sprites/laserbeam.spr"); m_drawModels[DrawLine::Simple] = m_engineWrap.precacheModel ("sprites/laserbeam.spr");
m_drawModels[DrawLine::Arrow] = m_engineWrap.precacheModel ("sprites/arrow1.spr"); m_drawModels[DrawLine::Arrow] = m_engineWrap.precacheModel ("sprites/arrow1.spr");
m_engineWrap.precacheSound ("weapons/xbow_hit1.wav"); // waypoint add m_engineWrap.precacheSound ("weapons/xbow_hit1.wav"); // node add
m_engineWrap.precacheSound ("weapons/mine_activate.wav"); // waypoint delete m_engineWrap.precacheSound ("weapons/mine_activate.wav"); // node delete
m_engineWrap.precacheSound ("common/wpn_hudon.wav"); // path add/delete done m_engineWrap.precacheSound ("common/wpn_hudon.wav"); // path add/delete done
m_mapFlags = 0; // reset map type as worldspawn is the first entity spawned m_mapFlags = 0; // reset map type as worldspawn is the first entity spawned
@ -478,6 +478,12 @@ void Game::sendClientMessage (bool console, edict_t *ent, StringRef message) {
if (!util.isPlayer (ent) || util.isFakeClient (ent)) { if (!util.isPlayer (ent) || util.isFakeClient (ent)) {
return; return;
} }
// if console message and destination is listenserver entity, just print via server message instead of through unreliable channel
if (console && ent == game.getLocalEntity ()) {
sendServerMessage (message);
return;
}
const String &buffer = message; const String &buffer = message;
// used to split messages // used to split messages

View file

@ -675,7 +675,7 @@ void BotGraph::add (int type, const Vector &pos) {
else { else {
auto nearest = getEditorNearest (); auto nearest = getEditorNearest ();
// do not allow to place waypoints "inside" waypoints, make at leat 10 units range // do not allow to place node "inside" node, make at leat 10 units range
if (exists (nearest) && newOrigin.distanceSq (m_paths[nearest].origin) < cr::sqrf (10.0f)) { if (exists (nearest) && newOrigin.distanceSq (m_paths[nearest].origin) < cr::sqrf (10.0f)) {
msg ("Can't add node. It's way to near to %d node. Please move some units anywhere.", nearest); msg ("Can't add node. It's way to near to %d node. Please move some units anywhere.", nearest);
return; return;
@ -981,7 +981,7 @@ bool BotGraph::isConnected (int a, int b) {
} }
int BotGraph::getFacingIndex () { int BotGraph::getFacingIndex () {
// find the waypoint the user is pointing at // find the node the user is pointing at
Twin <int32_t, float> result { kInvalidNodeIndex, 5.32f }; Twin <int32_t, float> result { kInvalidNodeIndex, 5.32f };
auto nearestNode = getEditorNearest (); auto nearestNode = getEditorNearest ();
@ -991,7 +991,7 @@ int BotGraph::getFacingIndex () {
for (const auto &path : m_paths) { for (const auto &path : m_paths) {
// skip nearest waypoint to editor, since this used mostly for adding / removing paths // skip nearest node to editor, since this used mostly for adding / removing paths
if (path.number == nearestNode) { if (path.number == nearestNode) {
continue; continue;
} }
@ -999,12 +999,12 @@ int BotGraph::getFacingIndex () {
const auto &to = path.origin - m_editor->v.origin; const auto &to = path.origin - m_editor->v.origin;
auto angles = (to.angles () - m_editor->v.v_angle).clampAngles (); auto angles = (to.angles () - m_editor->v.v_angle).clampAngles ();
// skip the waypoints that are too far away from us, and we're not looking at them directly // skip the nodes that are too far away from us, and we're not looking at them directly
if (to.lengthSq () > cr::sqrf (500.0f) || cr::abs (angles.y) > result.second) { if (to.lengthSq () > cr::sqrf (500.0f) || cr::abs (angles.y) > result.second) {
continue; continue;
} }
// check if visible, (we're not using visiblity tables here, as they not valid at time of waypoint editing) // check if visible, (we're not using visibility tables here, as they not valid at time of node editing)
TraceResult tr {}; TraceResult tr {};
game.testLine (editorEyes, path.origin, TraceIgnore::Everything, m_editor, &tr); game.testLine (editorEyes, path.origin, TraceIgnore::Everything, m_editor, &tr);

View file

@ -1973,11 +1973,11 @@ void BotThreadWorker::startup (int workers) {
requestedThreadCount = 1; requestedThreadCount = 1;
} }
} }
requestedThreadCount = cr::clamp (requestedThreadCount, 1, hardwareConcurrency); requestedThreadCount = cr::clamp (requestedThreadCount, 1, hardwareConcurrency - 1);
// notify user // notify user
game.print ("Starting up bot thread worker with %d threads.", requestedThreadCount); game.print ("Starting up bot thread worker with %d threads.", requestedThreadCount);
// start up the worker // start up the worker
m_botWorker.startup (static_cast <int> (requestedThreadCount)); m_botWorker.startup (static_cast <size_t> (requestedThreadCount));
} }

View file

@ -18,7 +18,7 @@ void Bot::normal_ () {
int debugGoal = cv_debug_goal.int_ (); int debugGoal = cv_debug_goal.int_ ();
// user forced a waypoint as a goal? // user forced a node as a goal?
if (debugGoal != kInvalidNodeIndex && getTask ()->data != debugGoal) { if (debugGoal != kInvalidNodeIndex && getTask ()->data != debugGoal) {
clearSearchNodes (); clearSearchNodes ();
@ -127,7 +127,7 @@ void Bot::normal_ () {
} }
} }
else { else {
// some goal waypoints are map dependant so check it out... // some goal nodes are map dependent so check it out...
if (game.mapIs (MapFlags::HostageRescue)) { if (game.mapIs (MapFlags::HostageRescue)) {
// CT Bot has some hostages following? // CT Bot has some hostages following?
if (m_team == Team::CT && m_hasHostage) { if (m_team == Team::CT && m_hasHostage) {
@ -190,7 +190,7 @@ void Bot::normal_ () {
auto currIndex = getTask ()->data; auto currIndex = getTask ()->data;
auto destIndex = graph.exists (currIndex) ? currIndex : findBestGoal (); auto destIndex = graph.exists (currIndex) ? currIndex : findBestGoal ();
// check for existence (this is fail over, for i.e. csdm, this should be not true with normal game play, only when spawned outside of covered area) // check for existence (this is fail over, for i.e. CSDM, this should be not true with normal game play, only when spawned outside of covered area)
if (!graph.exists (destIndex)) { if (!graph.exists (destIndex)) {
destIndex = graph.getFarest (pev->origin, 1024.0f); destIndex = graph.getFarest (pev->origin, 1024.0f);
} }
@ -207,7 +207,8 @@ void Bot::normal_ () {
} }
ensureCurrentNodeIndex (); ensureCurrentNodeIndex ();
// do pathfinding if it's not the current waypoint // do pathfinding if it's not the current
if (destIndex != m_currentNodeIndex) { if (destIndex != m_currentNodeIndex) {
findPath (m_currentNodeIndex, destIndex, pathSearchType); findPath (m_currentNodeIndex, destIndex, pathSearchType);
} }
@ -350,9 +351,9 @@ void Bot::seekCover_ () {
m_prevGoalIndex = kInvalidNodeIndex; m_prevGoalIndex = kInvalidNodeIndex;
} }
// reached final waypoint? // reached final node?
else if (updateNavigation ()) { else if (updateNavigation ()) {
// yep. activate hide behaviour // yep. activate hide behavior
completeTask (); completeTask ();
m_prevGoalIndex = kInvalidNodeIndex; m_prevGoalIndex = kInvalidNodeIndex;
@ -366,7 +367,7 @@ void Bot::seekCover_ () {
m_lookAtSafe = dest; m_lookAtSafe = dest;
m_campDirection = 0; m_campDirection = 0;
// chosen waypoint is a camp waypoint? // chosen node is a camp node?
if (m_pathFlags & NodeFlag::Camp) { if (m_pathFlags & NodeFlag::Camp) {
// use the existing camp node prefs // use the existing camp node prefs
if (m_pathFlags & NodeFlag::Crouch) { if (m_pathFlags & NodeFlag::Crouch) {
@ -709,7 +710,7 @@ void Bot::moveToPos_ () {
m_position = nullptr; m_position = nullptr;
} }
// didn't choose goal waypoint yet? // didn't choose goal node yet?
else if (!hasActiveGoal ()) { else if (!hasActiveGoal ()) {
int destIndex = kInvalidNodeIndex; int destIndex = kInvalidNodeIndex;
int goal = getTask ()->data; int goal = getTask ()->data;
@ -804,7 +805,7 @@ void Bot::defuseBomb_ () {
// exception: bomb has been defused // exception: bomb has been defused
if (bombPos.empty ()) { if (bombPos.empty ()) {
// fix for stupid behaviour of CT's when bot is defused // fix for stupid behavior of CT's when bot is defused
for (const auto &bot : bots) { for (const auto &bot : bots) {
if (bot->m_team == m_team && bot->m_notKilled) { if (bot->m_team == m_team && bot->m_notKilled) {
auto defendPoint = graph.getFarest (bot->pev->origin); auto defendPoint = graph.getFarest (bot->pev->origin);
@ -1034,13 +1035,13 @@ void Bot::followUser_ () {
getTask ()->data = kInvalidNodeIndex; getTask ()->data = kInvalidNodeIndex;
} }
// didn't choose goal waypoint yet? // didn't choose goal node yet?
if (!hasActiveGoal ()) { if (!hasActiveGoal ()) {
int destIndex = graph.getNearest (m_targetEntity->v.origin); int destIndex = graph.getNearest (m_targetEntity->v.origin);
auto points = graph.getNarestInRadius (200.0f, m_targetEntity->v.origin); auto points = graph.getNarestInRadius (200.0f, m_targetEntity->v.origin);
for (auto &newIndex : points) { for (auto &newIndex : points) {
// if waypoint not yet used, assign it as dest // if node not yet used, assign it as dest
if (newIndex != m_currentNodeIndex && !isOccupiedNode (newIndex)) { if (newIndex != m_currentNodeIndex && !isOccupiedNode (newIndex)) {
destIndex = newIndex; destIndex = newIndex;
} }
@ -1288,7 +1289,7 @@ void Bot::doublejump_ () {
getTask ()->data = kInvalidNodeIndex; getTask ()->data = kInvalidNodeIndex;
} }
// didn't choose goal waypoint yet? // didn't choose goal node yet?
if (!hasActiveGoal ()) { if (!hasActiveGoal ()) {
int destIndex = graph.getNearest (m_doubleJumpOrigin); int destIndex = graph.getNearest (m_doubleJumpOrigin);
@ -1339,7 +1340,7 @@ void Bot::escapeFromBomb_ () {
startTask (Task::Camp, TaskPri::Camp, kInvalidNodeIndex, game.time () + 10.0f, true); startTask (Task::Camp, TaskPri::Camp, kInvalidNodeIndex, game.time () + 10.0f, true);
} }
// didn't choose goal waypoint yet? // didn't choose goal node yet?
else if (!hasActiveGoal ()) { else if (!hasActiveGoal ()) {
int bestIndex = kInvalidNodeIndex; int bestIndex = kInvalidNodeIndex;
@ -1591,7 +1592,6 @@ void Bot::pickupItem_ () {
return EntitySearchResult::Continue; return EntitySearchResult::Continue;
} }
} }
int hostageNodeIndex = graph.getNearest (ent->v.origin); int hostageNodeIndex = graph.getNearest (ent->v.origin);
if (graph.exists (hostageNodeIndex)) { if (graph.exists (hostageNodeIndex)) {