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:
parent
b946cbdcbf
commit
7f4d4748fa
22 changed files with 105 additions and 99 deletions
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#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> {
|
||||
public:
|
||||
GraphAnalyze () = default;
|
||||
|
|
@ -16,21 +16,21 @@ public:
|
|||
private:
|
||||
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_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_optimizedNodes[kMaxNodes] {}; // all nodes expanded ?
|
||||
|
||||
public:
|
||||
// start analyzation process
|
||||
// start analysis process
|
||||
void start ();
|
||||
|
||||
// update analyzation process
|
||||
// update analysis process
|
||||
void update ();
|
||||
|
||||
// suspend aanalyzing
|
||||
// suspend analysis
|
||||
void suspend ();
|
||||
|
||||
private:
|
||||
|
|
@ -40,10 +40,10 @@ private:
|
|||
// set update interval (keeps game from freezing)
|
||||
void setUpdateInterval ();
|
||||
|
||||
// mark waypoints as goals
|
||||
// mark nodes as goals
|
||||
void markGoals ();
|
||||
|
||||
// terminate analyzation and save data
|
||||
// terminate analysis and save data
|
||||
void finish ();
|
||||
|
||||
// optimize nodes a little
|
||||
|
|
@ -59,7 +59,7 @@ public:
|
|||
return m_isCrouch;
|
||||
}
|
||||
|
||||
// is currently anaylyzing ?
|
||||
// is currently analyzing ?
|
||||
bool isAnalyzing () const {
|
||||
return m_isAnalyzing;
|
||||
}
|
||||
|
|
@ -75,5 +75,5 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
// explose global
|
||||
// expose global
|
||||
CR_EXPOSE_GLOBAL_SINGLETON (GraphAnalyze, analyzer);
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ public:
|
|||
// fix weapon prices (ie for elite)
|
||||
void adjustWeaponPrices ();
|
||||
|
||||
// find weapon info by weaponi d
|
||||
// find weapon info by weapon id
|
||||
WeaponInfo &findWeaponById (int id);
|
||||
|
||||
// translates bot message into needed language
|
||||
|
|
@ -139,7 +139,7 @@ private:
|
|||
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);
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
// command handler status
|
||||
CR_DECLARE_SCOPED_ENUM (BotCommandResult,
|
||||
Handled = 0, // command successfully handled
|
||||
ListenServer, // command is only avaialble on listen server
|
||||
ListenServer, // command is only available on listen server
|
||||
BadFormat // wrong params
|
||||
)
|
||||
|
||||
|
|
@ -224,7 +224,7 @@ public:
|
|||
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);
|
||||
|
||||
public:
|
||||
|
|
@ -242,7 +242,7 @@ public:
|
|||
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) {
|
||||
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) {
|
||||
if (m_silenceMessages) {
|
||||
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);
|
||||
|
|
|
|||
12
inc/engine.h
12
inc/engine.h
|
|
@ -194,7 +194,7 @@ public:
|
|||
// sends local registration stack for engine registration
|
||||
void registerCvars (bool gameVars = false);
|
||||
|
||||
// checks whether softwared rendering is enabled
|
||||
// checks whether software rendering is enabled
|
||||
bool isSoftwareRenderer ();
|
||||
|
||||
// load the cs binary in non metamod mode
|
||||
|
|
@ -386,7 +386,7 @@ public:
|
|||
|
||||
// prints center message to specified player
|
||||
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)...);
|
||||
return;
|
||||
}
|
||||
|
|
@ -395,7 +395,7 @@ public:
|
|||
|
||||
// prints message to client console
|
||||
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)...);
|
||||
return;
|
||||
}
|
||||
|
|
@ -431,7 +431,7 @@ public:
|
|||
else if constexpr (cr::is_same <U, int>::value) {
|
||||
return static_cast <int> (ptr->value);
|
||||
}
|
||||
assert ("!Inavlid type requeted.");
|
||||
assert ("!Invalid type requested.");
|
||||
}
|
||||
|
||||
bool bool_ () const {
|
||||
|
|
@ -525,11 +525,11 @@ 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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
14
inc/graph.h
14
inc/graph.h
|
|
@ -88,7 +88,7 @@ CR_DECLARE_SCOPED_ENUM (NotifySound,
|
|||
|
||||
#include <vistable.h>
|
||||
|
||||
// general waypoint header information structure
|
||||
// general waypoint header information structure for podbot
|
||||
struct PODGraphHeader {
|
||||
char header[8];
|
||||
int32_t fileVersion;
|
||||
|
|
@ -97,7 +97,7 @@ struct PODGraphHeader {
|
|||
char author[32];
|
||||
};
|
||||
|
||||
// defines linked waypoints
|
||||
// defines linked nodes
|
||||
struct PathLink {
|
||||
Vector velocity;
|
||||
int32_t distance;
|
||||
|
|
@ -114,7 +114,7 @@ struct Path {
|
|||
PathVis vis;
|
||||
};
|
||||
|
||||
// define waypoint structure for podbot (will convert on load)
|
||||
// define waypoint structure for podbot (will convert on load)
|
||||
struct PODPath {
|
||||
int32_t number, flags;
|
||||
Vector origin;
|
||||
|
|
@ -126,7 +126,7 @@ struct PODPath {
|
|||
PathVis vis;
|
||||
};
|
||||
|
||||
// general stprage header information structure
|
||||
// general storage header information structure
|
||||
struct StorageHeader {
|
||||
int32_t magic;
|
||||
int32_t version;
|
||||
|
|
@ -328,7 +328,7 @@ public:
|
|||
return m_editor;
|
||||
}
|
||||
|
||||
// slicence all graph messages or not
|
||||
// silence all graph messages or not
|
||||
void setMessageSilence (bool enable) {
|
||||
m_silenceMessages = enable;
|
||||
}
|
||||
|
|
@ -344,7 +344,7 @@ 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);
|
||||
|
||||
public:
|
||||
|
|
@ -368,5 +368,5 @@ public:
|
|||
#include <manager.h>
|
||||
#include <practice.h>
|
||||
|
||||
// explose global
|
||||
// expose global
|
||||
CR_EXPOSE_GLOBAL_SINGLETON (BotGraph, graph);
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ private:
|
|||
int m_bombSayStatus {}; // some bot is issued whine about bomb
|
||||
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_bombPlanted {};
|
||||
bool m_botsCanPause {};
|
||||
|
|
@ -326,7 +326,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
// explose global
|
||||
// expose global
|
||||
CR_EXPOSE_GLOBAL_SINGLETON (BotManager, bots);
|
||||
|
||||
// expose async worker
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public:
|
|||
// gets the node nearest to origin
|
||||
virtual int getNearestNode (float *origin) = 0;
|
||||
|
||||
// checks wether node is valid
|
||||
// checks whether node is valid
|
||||
virtual bool isNodeValid (int node) = 0;
|
||||
|
||||
// gets the node origin
|
||||
|
|
|
|||
|
|
@ -126,5 +126,5 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
// explose global
|
||||
// expose global
|
||||
CR_EXPOSE_GLOBAL_SINGLETON (BotPractice, practice);
|
||||
|
|
|
|||
|
|
@ -36,5 +36,5 @@ public:
|
|||
void simulateNoise (int playerIndex);
|
||||
};
|
||||
|
||||
// explose global
|
||||
// expose global
|
||||
CR_EXPOSE_GLOBAL_SINGLETON (BotSounds, sounds);
|
||||
|
|
|
|||
|
|
@ -72,20 +72,20 @@ public:
|
|||
// saves the data and compress with ulz
|
||||
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);
|
||||
|
||||
// builds the filename to requested filename
|
||||
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);
|
||||
|
||||
// remove all bot related files frorm disk
|
||||
// remove all bot related files from disk
|
||||
void unlinkFromDisk ();
|
||||
|
||||
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 () {
|
||||
m_retries = 0;
|
||||
}
|
||||
|
|
@ -98,6 +98,6 @@ public:
|
|||
|
||||
#undef BOT_STORAGE_EXPLICIT_INSTANTIATIONS
|
||||
|
||||
// explose global
|
||||
// expose global
|
||||
CR_EXPOSE_GLOBAL_SINGLETON (BotStorage, bstor);
|
||||
|
||||
|
|
|
|||
|
|
@ -39,16 +39,16 @@ public:
|
|||
// check if entity is alive
|
||||
bool isAlive (edict_t *ent);
|
||||
|
||||
// checks if entitiy is fakeclient
|
||||
// checks if entity is fakeclient
|
||||
bool isFakeClient (edict_t *ent);
|
||||
|
||||
// check if entitiy is a player
|
||||
// check if entity is a player
|
||||
bool isPlayer (edict_t *ent);
|
||||
|
||||
// check if entitiy is a monster
|
||||
// check if entity is a monster
|
||||
bool isMonster (edict_t *ent);
|
||||
|
||||
// check if entitiy is a item
|
||||
// check if entity is a item
|
||||
bool isItem (edict_t *ent);
|
||||
|
||||
// check if entity is a vip
|
||||
|
|
@ -90,13 +90,13 @@ public:
|
|||
// send modified pings to all the clients
|
||||
void emitPings (edict_t *to);
|
||||
|
||||
// installs the sendto function intreception
|
||||
// installs the sendto function interception
|
||||
void installSendTo ();
|
||||
|
||||
// check if object inside frustum plane
|
||||
bool isObjectInsidePlane (FrustumPlane &plane, const Vector ¢er, 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);
|
||||
|
||||
// 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);
|
||||
};
|
||||
|
||||
// explose global
|
||||
// expose global
|
||||
CR_EXPOSE_GLOBAL_SINGLETON (BotSupport, util);
|
||||
|
|
|
|||
|
|
@ -56,6 +56,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
// explose global
|
||||
// expose global
|
||||
CR_EXPOSE_GLOBAL_SINGLETON (GraphVistable, vistab);
|
||||
|
||||
|
|
|
|||
20
inc/yapb.h
20
inc/yapb.h
|
|
@ -388,7 +388,7 @@ CR_DECLARE_SCOPED_ENUM_TYPE (AimFlags, uint32_t,
|
|||
Enemy = cr::bit (5), // aim at enemy
|
||||
Grenade = cr::bit (6), // aim for grenade throw
|
||||
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
|
||||
|
|
@ -416,7 +416,7 @@ CR_DECLARE_SCOPED_ENUM (FrustumSide,
|
|||
Num
|
||||
)
|
||||
|
||||
// some hardcoded desire defines used to override calculated ones
|
||||
// some hard-coded desire defines used to override calculated ones
|
||||
struct TaskPri {
|
||||
static constexpr auto Normal { 35.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 flags; // client flags
|
||||
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 iconFlags[kGameMaxPlayers]; // flag holding chatter icons
|
||||
float iconTimestamp[kGameMaxPlayers]; // timers for chatter icons
|
||||
|
|
@ -676,7 +676,7 @@ private:
|
|||
int m_plantedBombNodeIndex {}; // nearest to planted bomb node
|
||||
int m_currentNodeIndex {}; // current node index
|
||||
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_needAvoidGrenade {}; // which direction to strafe away
|
||||
int m_campDirection {}; // camp Facing direction
|
||||
|
|
@ -702,7 +702,7 @@ private:
|
|||
float m_lastCommandTime {}; // time bot last thinked
|
||||
float m_reloadCheckTime {}; // time to check reloading
|
||||
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_sniperStopTime {}; // bot switched to other weapon?
|
||||
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_playServerTime {}; // time bot spent in the game
|
||||
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
|
||||
|
||||
bool m_moveToGoal {}; // bot currently moving to goal??
|
||||
|
|
@ -782,7 +782,7 @@ private:
|
|||
edict_t *m_lastBreakable {}; // last acquired breakable
|
||||
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_hindrance {}; // the hidrance
|
||||
edict_t *m_hindrance {}; // the hindrance
|
||||
|
||||
Vector m_liftTravelPos {}; // lift travel position
|
||||
Vector m_moveAngles {}; // bot move angles
|
||||
|
|
@ -1070,7 +1070,7 @@ public:
|
|||
int m_basePing {}; // base ping for bot
|
||||
int m_numEnemiesLeft {}; // number of enemies 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_voteKickIndex {}; // index of player to vote against
|
||||
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_inBombZone {}; // bot in the bomb zone or not
|
||||
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_buyPending {}; // bot buy is pending
|
||||
bool m_hasDefuser {}; // does bot has defuser
|
||||
|
|
@ -1233,7 +1233,7 @@ public:
|
|||
return m_currentNodeIndex;
|
||||
}
|
||||
|
||||
// is low on admmo on index?
|
||||
// is low on ammo on index?
|
||||
bool isLowOnAmmo (const int index, const float factor) const;
|
||||
|
||||
// prints debug message
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue