fix: occupied point check radius calculated incorrectly
fix: occupied point calculation takes too much cpu power fix: buffer overrun in messaging processing fix: running bots on hlds 3111e (cs 1.5) on linux* build: added back correct ldscript for gcc and clang * for some reason only gcc-compiled binaries working on centos5.8 and hlds 3.1.1.1e. clang binaries crashing immediately, so if you want to run bot on ancient os and/or hlds you need to recompile with gcc, as default linux binaries built with clang.
This commit is contained in:
parent
6cd471ead2
commit
f55730ac6d
11 changed files with 162 additions and 146 deletions
|
|
@ -457,7 +457,7 @@ void BotConfig::loadLanguageConfig () {
|
|||
setupMemoryFiles ();
|
||||
|
||||
if (game.is (GameFlags::Legacy)) {
|
||||
logger.message ("Bots multilingual system disabled, due to your Counter-Strike version!");
|
||||
logger.message ("Bots multilingual system disabled.");
|
||||
return; // dedicated server will use only english translation
|
||||
}
|
||||
String line;
|
||||
|
|
|
|||
|
|
@ -1612,6 +1612,9 @@ template <typename U> bool BotGraph::loadStorage (StringRef ext, StringRef name,
|
|||
bool isGraph = !!(options & StorageOption::Graph);
|
||||
MemFile file (strings.format ("%s%s/%s", getDataDirectory (true), isGraph ? "graph" : "train", filename)); // open the file
|
||||
|
||||
data.clear ();
|
||||
data.shrink ();
|
||||
|
||||
// resize data to fit the stuff
|
||||
auto resizeData = [&] (const size_t length) {
|
||||
data.resize (length); // for non-graph data the graph should be already loaded
|
||||
|
|
@ -1760,8 +1763,6 @@ bool BotGraph::loadGraphData () {
|
|||
ExtenHeader exten {};
|
||||
int32 outOptions = 0;
|
||||
|
||||
m_paths.clear ();
|
||||
|
||||
// check if loaded
|
||||
bool dataLoaded = loadStorage <Path> ("graph", "Graph", StorageOption::Graph, StorageVersion::Graph, m_paths, &exten, &outOptions);
|
||||
|
||||
|
|
|
|||
|
|
@ -805,30 +805,31 @@ CR_EXPORT int GetNewDLLFunctions (newgamefuncs_t *table, int *interfaceVersion)
|
|||
plat.bzero (table, sizeof (newgamefuncs_t));
|
||||
|
||||
if (!(game.is (GameFlags::Metamod))) {
|
||||
auto api_GetEntityAPI = game.lib ().resolve <decltype (&GetNewDLLFunctions)> (__FUNCTION__);
|
||||
auto api_GetNewDLLFunctions = game.lib ().resolve <decltype (&GetNewDLLFunctions)> (__FUNCTION__);
|
||||
|
||||
// pass other DLLs engine callbacks to function table...
|
||||
if (!api_GetEntityAPI || api_GetEntityAPI (&newapi, interfaceVersion) == 0) {
|
||||
if (!api_GetNewDLLFunctions || api_GetNewDLLFunctions (&newapi, interfaceVersion) == 0) {
|
||||
logger.error ("Could not resolve symbol \"%s\" in the game dll.", __FUNCTION__);
|
||||
}
|
||||
dllfuncs.newapi_table = &newapi;
|
||||
|
||||
memcpy (table, &newapi, sizeof (newgamefuncs_t));
|
||||
}
|
||||
|
||||
table->pfnOnFreeEntPrivateData = [] (edict_t *ent) {
|
||||
for (auto &bot : bots) {
|
||||
if (bot->m_enemy == ent) {
|
||||
bot->m_enemy = nullptr;
|
||||
bot->m_lastEnemy = nullptr;
|
||||
if (!game.is (GameFlags::Legacy)) {
|
||||
table->pfnOnFreeEntPrivateData = [] (edict_t *ent) {
|
||||
for (auto &bot : bots) {
|
||||
if (bot->m_enemy == ent) {
|
||||
bot->m_enemy = nullptr;
|
||||
bot->m_lastEnemy = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (game.is (GameFlags::Metamod)) {
|
||||
RETURN_META (MRES_IGNORED);
|
||||
}
|
||||
newapi.pfnOnFreeEntPrivateData (ent);
|
||||
};
|
||||
if (game.is (GameFlags::Metamod)) {
|
||||
RETURN_META (MRES_IGNORED);
|
||||
}
|
||||
newapi.pfnOnFreeEntPrivateData (ent);
|
||||
};
|
||||
}
|
||||
return HLTrue;
|
||||
}
|
||||
|
||||
|
|
@ -946,7 +947,7 @@ CR_EXPORT void Meta_Init () {
|
|||
# define DLL_GIVEFNPTRSTODLL CR_EXPORT void
|
||||
#endif
|
||||
|
||||
DLL_GIVEFNPTRSTODLL GiveFnptrsToDll (enginefuncs_t *functionTable, globalvars_t *glob) {
|
||||
DLL_GIVEFNPTRSTODLL GiveFnptrsToDll (enginefuncs_t *table, globalvars_t *glob) {
|
||||
// this is the very first function that is called in the game DLL by the game. Its purpose
|
||||
// is to set the functions interfacing up, by exchanging the functionTable function list
|
||||
// along with a pointer to the engine's global variables structure pGlobals, with the game
|
||||
|
|
@ -959,7 +960,7 @@ DLL_GIVEFNPTRSTODLL GiveFnptrsToDll (enginefuncs_t *functionTable, globalvars_t
|
|||
// initialization stuff will be done later, when we'll be certain to have a multilayer game.
|
||||
|
||||
// get the engine functions from the game...
|
||||
memcpy (&engfuncs, functionTable, sizeof (enginefuncs_t));
|
||||
memcpy (&engfuncs, table, sizeof (enginefuncs_t));
|
||||
globals = glob;
|
||||
|
||||
if (game.postload ()) {
|
||||
|
|
@ -970,13 +971,13 @@ DLL_GIVEFNPTRSTODLL GiveFnptrsToDll (enginefuncs_t *functionTable, globalvars_t
|
|||
if (!api_GiveFnptrsToDll) {
|
||||
logger.fatal ("Could not resolve symbol \"%s\" in the game dll.", __FUNCTION__);
|
||||
}
|
||||
GetEngineFunctions (functionTable, nullptr);
|
||||
GetEngineFunctions (table, nullptr);
|
||||
|
||||
// initialize dynamic linkents
|
||||
ents.initialize ();
|
||||
|
||||
// give the engine functions to the other DLL...
|
||||
api_GiveFnptrsToDll (functionTable, glob);
|
||||
api_GiveFnptrsToDll (table, glob);
|
||||
}
|
||||
|
||||
DLSYM_RETURN EntityLinkage::lookup (SharedLibrary::Handle module, const char *function) {
|
||||
|
|
|
|||
|
|
@ -134,15 +134,15 @@ void MessageDispatcher::netMsgWeaponList () {
|
|||
}
|
||||
|
||||
// store away this weapon with it's ammo information...
|
||||
conf.getWeaponProp (m_args[id].long_) = {
|
||||
m_args[classname].chars_,
|
||||
m_args[ammo_index_1].long_,
|
||||
m_args[max_ammo_1].long_,
|
||||
m_args[slot].long_,
|
||||
m_args[slot_pos].long_,
|
||||
m_args[id].long_,
|
||||
m_args[flags].long_
|
||||
};
|
||||
auto &prop = conf.getWeaponProp (m_args[id].long_);
|
||||
|
||||
prop.classname = m_args[classname].chars_;
|
||||
prop.ammo1 = m_args[ammo_index_1].long_;
|
||||
prop.ammo1Max = m_args[max_ammo_1].long_;
|
||||
prop.slot = m_args[slot].long_;
|
||||
prop.pos = m_args[slot_pos].long_;
|
||||
prop.id = m_args[id].long_;
|
||||
prop.flags = m_args[flags].long_;
|
||||
}
|
||||
|
||||
void MessageDispatcher::netMsgCurWeapon () {
|
||||
|
|
|
|||
|
|
@ -2993,49 +2993,52 @@ bool Bot::isOccupiedNode (int index, bool needZeroVelocity) {
|
|||
continue;
|
||||
}
|
||||
|
||||
// just in case, if something happend, and we're not updated yet
|
||||
if (!util.isAlive (client.ent)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// do not check clients far away from us
|
||||
if ((pev->origin - client.origin).lengthSq () > cr::square (320.0f)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (needZeroVelocity && client.ent->v.velocity.length2d () > 0.0f) {
|
||||
continue;
|
||||
}
|
||||
auto bot = bots[client.ent];
|
||||
auto length = (graph[index].origin - client.origin).lengthSq ();
|
||||
|
||||
if (bot == this) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (bot != nullptr) {
|
||||
int occupyId = util.getShootingCone (bot->ent (), pev->origin) >= 0.7f ? bot->m_previousNodes[0] : bot->m_currentNodeIndex;
|
||||
|
||||
if (index == occupyId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
float length = (graph[index].origin - client.origin).lengthSq ();
|
||||
|
||||
if (length < cr::clamp (graph[index].radius, cr::square (90.0f), cr::square (120.0f))) {
|
||||
if (length < cr::clamp (cr::square (graph[index].radius), cr::square (60.0f), cr::square (90.0f))) {
|
||||
return true;
|
||||
}
|
||||
#if 0 // too cpu hungry, disabled temporary
|
||||
auto bot = bots[client.ent];
|
||||
|
||||
if (bot == nullptr || bot == this || !bot->m_notKilled) {
|
||||
continue;
|
||||
}
|
||||
auto occupyId = util.getShootingCone (bot->ent (), pev->origin) >= 0.7f ? bot->m_previousNodes[0] : bot->m_currentNodeIndex;
|
||||
|
||||
if (index == occupyId) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
edict_t *Bot::lookupButton (const char *targetName) {
|
||||
edict_t *Bot::lookupButton (const char *target) {
|
||||
// this function tries to find nearest to current bot button, and returns pointer to
|
||||
// it's entity, also here must be specified the target, that button must open.
|
||||
|
||||
if (strings.isEmpty (targetName)) {
|
||||
if (strings.isEmpty (target)) {
|
||||
return nullptr;
|
||||
}
|
||||
float nearest = kInfiniteDistance;
|
||||
edict_t *result = nullptr;
|
||||
|
||||
// find the nearest button which can open our target
|
||||
game.searchEntities ("target", targetName, [&] (edict_t *ent) {
|
||||
game.searchEntities ("target", target, [&] (edict_t *ent) {
|
||||
const Vector &pos = game.getEntityWorldOrigin (ent);
|
||||
|
||||
// check if this place safe
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue