Added consistency check for graph files. Totally optional, but wiill notify user if graph file built not for loaded map.

Some minor cosmetic changes and refactoring.
Fixed #70. Better now, than never.
Implemented #121. Bots auto-kill delays.
Bumb the year.
This commit is contained in:
jeefo 2020-02-08 00:03:52 +03:00
commit d6150a8aba
22 changed files with 171 additions and 82 deletions

View file

@ -219,4 +219,4 @@ public:
};
// explose global
static auto &conf = BotConfig::get ();
CR_EXPOSE_GLOBAL_SINGLETON (BotConfig, conf);

View file

@ -216,4 +216,4 @@ template <typename ...Args> inline void BotControl::msg (const char *fmt, Args .
}
// explose global
static auto &ctrl = BotControl::get ();
CR_EXPOSE_GLOBAL_SINGLETON (BotControl, ctrl);

View file

@ -68,6 +68,6 @@ public:
}
};
static auto &alloc = Allocator::get ();
CR_EXPOSE_GLOBAL_SINGLETON (Allocator, alloc);
CR_NAMESPACE_END

View file

@ -111,6 +111,10 @@ public:
#define CR_DECLARE_SCOPED_ENUM(enumName, ...) \
CR_DECLARE_SCOPED_ENUM_TYPE(enumName, int32, __VA_ARGS__) \
// exposes global variable from class singleton
#define CR_EXPOSE_GLOBAL_SINGLETON(className, variable) \
static auto &variable = className::get () \
CR_NAMESPACE_END
// platform-dependant-stuff

View file

@ -453,6 +453,6 @@ public:
};
// expose global http client
static auto &http = HttpClient::get ();
CR_EXPOSE_GLOBAL_SINGLETON (HttpClient, http);
CR_NAMESPACE_END

View file

@ -96,6 +96,6 @@ public:
};
// expose global instance
static auto &logger = SimpleLogger::get ();
CR_EXPOSE_GLOBAL_SINGLETON (SimpleLogger, logger);
CR_NAMESPACE_END

View file

@ -246,6 +246,6 @@ struct Platform : public Singleton <Platform> {
};
// expose platform singleton
static auto &plat = Platform::get ();
CR_EXPOSE_GLOBAL_SINGLETON (Platform, plat);
CR_NAMESPACE_END

View file

@ -60,6 +60,6 @@ public:
};
// expose global random generator
static auto &rg = Random::get ();
CR_EXPOSE_GLOBAL_SINGLETON (Random, rg);
CR_NAMESPACE_END

View file

@ -905,7 +905,7 @@ public:
};
// expose global string pool
static auto &strings = StringBuffer::get ();
CR_EXPOSE_GLOBAL_SINGLETON (StringBuffer, strings);
// some limited utf8 stuff
class Utf8Tools : public Singleton <Utf8Tools> {
@ -1141,6 +1141,6 @@ public:
};
// expose global utf8 tools
static auto &utf8tools = Utf8Tools::get ();
CR_EXPOSE_GLOBAL_SINGLETON (Utf8Tools, utf8tools);
CR_NAMESPACE_END

View file

@ -671,6 +671,6 @@ public:
};
// expose globals
static auto &game = Game::get ();
static auto &illum = LightMeasure::get ();
static auto &ents = DynamicEntityLink::get ();
CR_EXPOSE_GLOBAL_SINGLETON (Game, game);
CR_EXPOSE_GLOBAL_SINGLETON (LightMeasure, illum);
CR_EXPOSE_GLOBAL_SINGLETON (DynamicEntityLink, ents);

View file

@ -71,7 +71,7 @@ CR_DECLARE_SCOPED_ENUM (StorageOption,
Graph = cr::bit (3), // this is a node graph data
Official = cr::bit (4), // this is additional flag for graph indicates graph are official
Recovered = cr::bit (5), // this is additional flag indicates graph converted from podbot and was bad
Author = cr::bit (6) // this is additional flag indicates that there's author info
Exten = cr::bit (6) // this is additional flag indicates that there's extension info
)
// storage header versions
@ -112,6 +112,12 @@ struct StorageHeader {
int32 uncompressed;
};
// extension header for graph information
struct ExtenHeader {
char author[32];
int32 mapSize;
};
// general waypoint header information structure
struct PODGraphHeader {
char header[8];
@ -313,8 +319,8 @@ public:
bool saveGraphData ();
bool loadGraphData ();
template <typename U> bool saveStorage (const String &ext, const String &name, StorageOption options, StorageVersion version, const SmallArray <U> &data, uint8 *blob);
template <typename U> bool loadStorage (const String &ext, const String &name, StorageOption options, StorageVersion version, SmallArray <U> &data, uint8 *blob, int32 *outOptions);
template <typename U> bool saveStorage (const String &ext, const String &name, StorageOption options, StorageVersion version, const SmallArray <U> &data, ExtenHeader *exten);
template <typename U> bool loadStorage (const String &ext, const String &name, StorageOption options, StorageVersion version, SmallArray <U> &data, ExtenHeader *exten, int32 *outOptions);
void saveOldFormat ();
void initGraph ();
@ -431,4 +437,4 @@ public:
};
// explose global
static auto &graph = BotGraph::get ();
CR_EXPOSE_GLOBAL_SINGLETON (BotGraph, graph);

View file

@ -29,6 +29,7 @@ private:
float m_timeRoundEnd;
float m_timeRoundMid;
float m_autoKillCheckTime; // time to kill all the bots ?
float m_maintainTime; // time to maintain bot creation
float m_quotaMaintainTime; // time to maintain bot quota
float m_grenadeUpdateTime; // time to update active grenades
@ -47,7 +48,7 @@ private:
bool m_economicsGood[kGameTeamNum]; // is team able to buy anything
bool m_bombPlanted;
bool m_botsCanPause;
bool m_roundEnded;
bool m_roundOver;
Array <edict_t *> m_activeGrenades; // holds currently active grenades on the map
Array <edict_t *> m_intrestingEntities; // holds currently intresting entities on the map
@ -93,6 +94,7 @@ public:
void kickFromTeam (Team team, bool removeAll = false);
void killAllBots (int team = -1);
void maintainQuota ();
void maintainAutoKill ();
void initQuota ();
void initRound ();
void decrementQuota (int by = 1);
@ -172,11 +174,7 @@ public:
}
bool isRoundOver () const {
return m_roundEnded;
}
void setRoundOver (const bool over) {
m_roundEnded = over;
return m_roundOver;
}
bool canPause () const {
@ -265,4 +263,4 @@ public:
};
// explose global
static auto &bots = BotManager::get ();
CR_EXPOSE_GLOBAL_SINGLETON (BotManager, bots);

View file

@ -146,4 +146,4 @@ private:
}
};
static auto &msgs = MessageDispatcher::get ();
CR_EXPOSE_GLOBAL_SINGLETON (MessageDispatcher, msgs);

View file

@ -16,7 +16,7 @@
#define PRODUCT_URL "https://yapb.ru/"
#define PRODUCT_EMAIL "yapb@entix.io"
#define PRODUCT_LOGTAG "YAPB"
#define PRODUCT_END_YEAR "2019"
#define PRODUCT_END_YEAR "2020"
#define PRODUCT_DESCRIPTION PRODUCT_NAME " v" PRODUCT_VERSION " - The Counter-Strike Bot (" PRODUCT_COMMENTS ")"
#define PRODUCT_COPYRIGHT "Copyright © 2004-" PRODUCT_END_YEAR ", by " PRODUCT_AUTHOR
#define PRODUCT_LEGAL "Half-Life, Counter-Strike, Counter-Strike: Condition Zero, Steam, Valve is a trademark of Valve Corporation"
@ -25,7 +25,7 @@
#define PRODUCT_GIT_HASH "unspecified_hash"
#define PRODUCT_GIT_COMMIT_AUTHOR "unspecified_author"
#define PRODUCT_GIT_COMMIT_ID 0000
#define PRODUCT_VERSION_DWORD_INTERNAL 2, 92
#define PRODUCT_VERSION_DWORD_INTERNAL 2,92
#define PRODUCT_VERSION_DWORD PRODUCT_VERSION_DWORD_INTERNAL, PRODUCT_GIT_COMMIT_ID
#define PRODUCT_SUPPORT_VERSION "Beta 6.6 - Condition Zero"
#define PRODUCT_COMMENTS "http://github.com/jeefo/yapb/"

View file

@ -151,4 +151,4 @@ public:
};
// explose global
static auto &util = BotUtils::get ();
CR_EXPOSE_GLOBAL_SINGLETON (BotUtils, util);