refactor: clang-tidy source a little
build: remove -fPIC option
This commit is contained in:
parent
570cfe0538
commit
f051fe2b99
13 changed files with 88 additions and 94 deletions
|
|
@ -1 +1 @@
|
|||
Subproject commit 544851dd2f24a2fd4d11633167c773d98383ba29
|
||||
Subproject commit 26c617d0a0cd18238a62f6e829da9161b7d56bd0
|
||||
|
|
@ -152,7 +152,7 @@ public:
|
|||
void testLine (const Vector &start, const Vector &end, int ignoreFlags, edict_t *ignoreEntity, TraceResult *ptr);
|
||||
|
||||
// trace line with channel, but allows us to store last traceline bot has fired, saving us some cpu cycles
|
||||
bool testLineChannel (TraceChannel channel, const Vector &start, const Vector &end, int ignoreFlags, edict_t *ignoreEntity, TraceResult *ptr);
|
||||
bool testLineChannel (TraceChannel channel, const Vector &start, const Vector &end, int ignoreFlags, edict_t *ignoreEntity, TraceResult &result);
|
||||
|
||||
// test line
|
||||
void testHull (const Vector &start, const Vector &end, int ignoreFlags, int hullNumber, edict_t *ignoreEntity, TraceResult *ptr);
|
||||
|
|
@ -170,7 +170,7 @@ public:
|
|||
const char *getMapName ();
|
||||
|
||||
// get the "any" entity origin
|
||||
Vector getEntityWorldOrigin (edict_t *ent);
|
||||
Vector getEntityOrigin (edict_t *ent);
|
||||
|
||||
// registers a server command
|
||||
void registerEngineCommand (const char *command, void func ());
|
||||
|
|
@ -574,7 +574,7 @@ public:
|
|||
|
||||
public:
|
||||
template <typename T> T read () {
|
||||
T result;
|
||||
T result {};
|
||||
auto size = sizeof (T);
|
||||
|
||||
if (m_cursor + size > m_buffer.length ()) {
|
||||
|
|
|
|||
16
inc/yapb.h
16
inc/yapb.h
|
|
@ -1137,8 +1137,8 @@ public:
|
|||
}
|
||||
|
||||
// get the bot last trace result
|
||||
TraceResult *getLastTraceResult (TraceChannel channel) {
|
||||
return &m_lastTrace[channel];
|
||||
TraceResult &getLastTraceResult (TraceChannel channel) {
|
||||
return m_lastTrace[channel];
|
||||
}
|
||||
|
||||
// prints debug message
|
||||
|
|
@ -1171,6 +1171,18 @@ extern ConVar cv_quota;
|
|||
extern ConVar cv_difficulty;
|
||||
extern ConVar cv_attack_monsters;
|
||||
extern ConVar cv_pickup_custom_items;
|
||||
extern ConVar cv_economics_rounds;
|
||||
extern ConVar cv_shoots_thru_walls;
|
||||
extern ConVar cv_debug;
|
||||
extern ConVar cv_debug_goal;
|
||||
|
||||
extern ConVar mp_freezetime;
|
||||
extern ConVar mp_roundtime;
|
||||
extern ConVar mp_timelimit;
|
||||
extern ConVar mp_limitteams;
|
||||
extern ConVar mp_autoteambalance;
|
||||
extern ConVar mp_footsteps;
|
||||
extern ConVar mp_startmoney;
|
||||
|
||||
// execute client command helper
|
||||
template <typename ...Args> void Bot::issueCommand (const char *fmt, Args &&...args) {
|
||||
|
|
|
|||
|
|
@ -329,7 +329,7 @@ void Bot::avoidGrenades () {
|
|||
if (m_preventFlashing < game.time () && m_personality == Personality::Rusher && m_difficulty == Difficulty::Expert && strcmp (model, "flashbang.mdl") == 0) {
|
||||
// don't look at flash bang
|
||||
if (!(m_states & Sense::SeeingEnemy)) {
|
||||
pev->v_angle.y = cr::normalizeAngles ((game.getEntityWorldOrigin (pent) - getEyesPos ()).angles ().y + 180.0f);
|
||||
pev->v_angle.y = cr::normalizeAngles ((game.getEntityOrigin (pent) - getEyesPos ()).angles ().y + 180.0f);
|
||||
|
||||
m_canChooseAimDirection = false;
|
||||
m_preventFlashing = game.time () + rg.get (1.0f, 2.0f);
|
||||
|
|
@ -402,7 +402,7 @@ void Bot::checkBreakablesAround () {
|
|||
if (!game.isShootableBreakable (breakable)) {
|
||||
continue;
|
||||
}
|
||||
const auto &origin = game.getEntityWorldOrigin (breakable);
|
||||
const auto &origin = game.getEntityOrigin (breakable);
|
||||
const auto lengthToObstacle = (origin - pev->origin).lengthSq ();
|
||||
|
||||
// too far, skip it
|
||||
|
|
@ -437,7 +437,7 @@ edict_t *Bot::lookupBreakable () {
|
|||
|
||||
// check if this isn't a triggered (bomb) breakable and if it takes damage. if true, shoot the crap!
|
||||
if (game.isShootableBreakable (ent)) {
|
||||
m_breakableOrigin = game.getEntityWorldOrigin (ent);
|
||||
m_breakableOrigin = game.getEntityOrigin (ent);
|
||||
return ent;
|
||||
}
|
||||
}
|
||||
|
|
@ -447,7 +447,7 @@ edict_t *Bot::lookupBreakable () {
|
|||
auto ent = tr.pHit;
|
||||
|
||||
if (game.isShootableBreakable (ent)) {
|
||||
m_breakableOrigin = game.getEntityWorldOrigin (ent);
|
||||
m_breakableOrigin = game.getEntityOrigin (ent);
|
||||
return ent;
|
||||
}
|
||||
}
|
||||
|
|
@ -501,7 +501,7 @@ void Bot::updatePickups () {
|
|||
if (ent->v.effects & EF_NODRAW) {
|
||||
continue;
|
||||
}
|
||||
const Vector &origin = game.getEntityWorldOrigin (ent);
|
||||
const Vector &origin = game.getEntityOrigin (ent);
|
||||
|
||||
// too far from us ?
|
||||
if ((pev->origin - origin).lengthSq () > radius) {
|
||||
|
|
@ -536,7 +536,7 @@ void Bot::updatePickups () {
|
|||
bool allowPickup = false; // assume can't use it until known otherwise
|
||||
|
||||
// get the entity origin
|
||||
const auto &origin = game.getEntityWorldOrigin (ent);
|
||||
const auto &origin = game.getEntityOrigin (ent);
|
||||
|
||||
if ((ent->v.effects & EF_NODRAW) || ent == m_itemIgnore || cr::abs (origin.z - pev->origin.z) > 96.0f) {
|
||||
continue; // someone owns this weapon or it hasn't respawned yet
|
||||
|
|
@ -734,7 +734,6 @@ void Bot::updatePickups () {
|
|||
}
|
||||
else if (pickupType == Pickup::PlantedC4) {
|
||||
if (util.isAlive (m_enemy)) {
|
||||
allowPickup = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -743,9 +742,6 @@ void Bot::updatePickups () {
|
|||
|
||||
// then start escape from bomb immediate
|
||||
startTask (Task::EscapeFromBomb, TaskPri::EscapeFromBomb, kInvalidNodeIndex, 0.0f, true);
|
||||
|
||||
// and no pickup
|
||||
allowPickup = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -931,8 +927,8 @@ void Bot::instantChatter (int type) {
|
|||
return;
|
||||
}
|
||||
|
||||
auto playbackSound = conf.pickRandomFromChatterBank (type);
|
||||
auto painSound = conf.pickRandomFromChatterBank (Chatter::DiePain);
|
||||
const auto &playbackSound = conf.pickRandomFromChatterBank (type);
|
||||
const auto &painSound = conf.pickRandomFromChatterBank (Chatter::DiePain);
|
||||
|
||||
if (m_notKilled) {
|
||||
showChaterIcon (true);
|
||||
|
|
@ -1001,8 +997,6 @@ void Bot::pushChatterMessage (int message) {
|
|||
void Bot::checkMsgQueue () {
|
||||
// this function checks and executes pending messages
|
||||
|
||||
extern ConVar mp_freezetime;
|
||||
|
||||
// no new message?
|
||||
if (m_msgQueue.empty ()) {
|
||||
return;
|
||||
|
|
@ -1294,7 +1288,7 @@ void Bot::buyStuff () {
|
|||
}
|
||||
|
||||
int count = 0, weaponCount = 0;
|
||||
int choices[kNumWeapons];
|
||||
int choices[kNumWeapons] {};
|
||||
|
||||
// select the priority tab for this personality
|
||||
const int *pref = conf.getWeaponPrefs (m_personality) + kNumWeapons;
|
||||
|
|
@ -1896,7 +1890,7 @@ void Bot::filterTasks () {
|
|||
filter[Task::PickupItem].desire = 50.0f; // always pickup button
|
||||
}
|
||||
else {
|
||||
float distance = (500.0f - (game.getEntityWorldOrigin (m_pickupItem) - pev->origin).length ()) * 0.2f;
|
||||
float distance = (500.0f - (game.getEntityOrigin (m_pickupItem) - pev->origin).length ()) * 0.2f;
|
||||
|
||||
if (distance > 50.0f) {
|
||||
distance = 50.0f;
|
||||
|
|
@ -4448,7 +4442,7 @@ void Bot::pickupItem_ () {
|
|||
|
||||
return;
|
||||
}
|
||||
const Vector &dest = game.getEntityWorldOrigin (m_pickupItem);
|
||||
const Vector &dest = game.getEntityOrigin (m_pickupItem);
|
||||
|
||||
m_destOrigin = dest;
|
||||
m_entity = dest;
|
||||
|
|
@ -4948,7 +4942,7 @@ void Bot::showDebugOverlay () {
|
|||
return;
|
||||
}
|
||||
static float timeDebugUpdate = 0.0f;
|
||||
static int index, goal, taskID;
|
||||
static int index = kInvalidNodeIndex, goal = kInvalidNodeIndex, taskID = 0;
|
||||
|
||||
static HashMap <int32, String> tasks;
|
||||
static HashMap <int32, String> personalities;
|
||||
|
|
@ -5526,7 +5520,7 @@ bool Bot::canSkipNextTrace (TraceChannel channel) {
|
|||
// for optmization purposes skip every second traceline fired, this doesn't affect ai
|
||||
// behaviour too much, but saves alot of cpu cycles.
|
||||
|
||||
constexpr auto kSkipTrace = 3;
|
||||
constexpr auto kSkipTrace = 4;
|
||||
|
||||
// check if we're have to skip
|
||||
if ((++m_traceSkip[channel] % kSkipTrace) == 0) {
|
||||
|
|
@ -5743,7 +5737,6 @@ void Bot::updateHearing () {
|
|||
}
|
||||
}
|
||||
}
|
||||
extern ConVar cv_shoots_thru_walls;
|
||||
|
||||
// check if heard enemy can be seen
|
||||
if (checkBodyParts (player)) {
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ bool Bot::checkBodyParts (edict_t *target) {
|
|||
else {
|
||||
spot.z = target->v.origin.z - standFeet;
|
||||
}
|
||||
game.testLineChannel (TraceChannel::Enemy, eyes, spot, TraceIgnore::Everything, self, &result);
|
||||
game.testLineChannel (TraceChannel::Enemy, eyes, spot, TraceIgnore::Everything, self, result);
|
||||
|
||||
if (result.flFraction >= 1.0f) {
|
||||
m_enemyParts |= Visibility::Other;
|
||||
|
|
@ -171,7 +171,7 @@ bool Bot::checkBodyParts (edict_t *target) {
|
|||
Vector perp (-dir.y, dir.x, 0.0f);
|
||||
spot = target->v.origin + Vector (perp.x * edgeOffset, perp.y * edgeOffset, 0);
|
||||
|
||||
game.testLineChannel (TraceChannel::Enemy, eyes, spot, TraceIgnore::Everything, self, &result);
|
||||
game.testLineChannel (TraceChannel::Enemy, eyes, spot, TraceIgnore::Everything, self, result);
|
||||
|
||||
if (result.flFraction >= 1.0f) {
|
||||
m_enemyParts |= Visibility::Other;
|
||||
|
|
@ -181,7 +181,7 @@ bool Bot::checkBodyParts (edict_t *target) {
|
|||
}
|
||||
spot = target->v.origin - Vector (perp.x * edgeOffset, perp.y * edgeOffset, 0);
|
||||
|
||||
game.testLineChannel (TraceChannel::Enemy, eyes, spot, TraceIgnore::Everything, self, &result);
|
||||
game.testLineChannel (TraceChannel::Enemy, eyes, spot, TraceIgnore::Everything, self, result);
|
||||
|
||||
if (result.flFraction >= 1.0f) {
|
||||
m_enemyParts |= Visibility::Other;
|
||||
|
|
@ -327,7 +327,7 @@ bool Bot::lookupEnemies () {
|
|||
}
|
||||
}
|
||||
|
||||
if (util.isPlayer (newEnemy) || (cv_attack_monsters.bool_ () && util.isMonster (newEnemy))) {
|
||||
if (newEnemy != nullptr && (util.isPlayer (newEnemy) || (cv_attack_monsters.bool_ () && util.isMonster (newEnemy)))) {
|
||||
bots.setCanPause (true);
|
||||
|
||||
m_aimFlags |= AimFlags::Enemy;
|
||||
|
|
@ -924,7 +924,7 @@ void Bot::fireWeapons () {
|
|||
}
|
||||
|
||||
// use knife if near and good difficulty (l33t dude!)
|
||||
if (cv_stab_close_enemies.bool_ () && m_difficulty >= Difficulty::Hard && m_healthValue > 80.0f && !game.isNullEntity (enemy) && m_healthValue >= enemy->v.health && distance < 100.0f && !isOnLadder () && !isGroupOfEnemies (pev->origin)) {
|
||||
if (cv_stab_close_enemies.bool_ () && m_difficulty >= Difficulty::Normal && m_healthValue > 80.0f && !game.isNullEntity (enemy) && m_healthValue >= enemy->v.health && distance < 100.0f && !isOnLadder () && !isGroupOfEnemies (pev->origin)) {
|
||||
selectWeapons (distance, selectIndex, selectId, choosenWeapon);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -335,7 +335,7 @@ void BotConfig::loadChatterConfig () {
|
|||
|
||||
for (auto &sound : sounds) {
|
||||
sound.trim ().trim ("\"");
|
||||
float duration = game.getWaveLen (sound.chars ());
|
||||
auto duration = game.getWaveLen (sound.chars ());
|
||||
|
||||
if (duration > 0.0f) {
|
||||
m_chatter[event.code].emplace (cr::move (sound), event.repeat, duration);
|
||||
|
|
@ -582,7 +582,7 @@ void BotConfig::loadDifficultyConfig () {
|
|||
logger.error ("Error in difficulty config file syntax... Please correct all errors.");
|
||||
continue;
|
||||
}
|
||||
auto key = items[0].trim ();
|
||||
const auto &key = items[0].trim ();
|
||||
|
||||
// get our keys
|
||||
if (key == "Noob") {
|
||||
|
|
|
|||
|
|
@ -349,7 +349,7 @@ int BotControl::cmdNode () {
|
|||
}
|
||||
}
|
||||
if (commands.has (strValue (cmd))) {
|
||||
auto item = commands[strValue (cmd)];
|
||||
const auto &item = commands[strValue (cmd)];
|
||||
|
||||
// graph have only bad format return status
|
||||
int status = (this->*item.handler) ();
|
||||
|
|
@ -405,8 +405,6 @@ int BotControl::cmdNodeOn () {
|
|||
}
|
||||
|
||||
if (graph.hasEditFlag (GraphEdit::On)) {
|
||||
extern ConVar mp_roundtime, mp_freezetime, mp_timelimit;
|
||||
|
||||
mp_roundtime.set (9);
|
||||
mp_freezetime.set (0);
|
||||
mp_timelimit.set (0);
|
||||
|
|
@ -914,7 +912,6 @@ int BotControl::menuFeatures (int item) {
|
|||
break;
|
||||
|
||||
case 4:
|
||||
extern ConVar cv_debug;
|
||||
cv_debug.set (cv_debug.int_ () ^ 1);
|
||||
|
||||
showMenu (Menu::Features);
|
||||
|
|
@ -1067,8 +1064,6 @@ int BotControl::menuTeamSelect (int item) {
|
|||
closeMenu (); // reset menu display
|
||||
|
||||
if (item < 3) {
|
||||
extern ConVar mp_limitteams, mp_autoteambalance;
|
||||
|
||||
// turn off cvars if specified team
|
||||
mp_limitteams.set (0);
|
||||
mp_autoteambalance.set (0);
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ void Game::testLine (const Vector &start, const Vector &end, int ignoreFlags, ed
|
|||
engfuncs.pfnTraceLine (start, end, engineFlags, ignoreEntity, ptr);
|
||||
}
|
||||
|
||||
bool Game::testLineChannel (TraceChannel channel, const Vector &start, const Vector &end, int ignoreFlags, edict_t *ignoreEntity, TraceResult *ptr) {
|
||||
bool Game::testLineChannel (TraceChannel channel, const Vector &start, const Vector &end, int ignoreFlags, edict_t *ignoreEntity, TraceResult &result) {
|
||||
// this function traces a line dot by dot, starting from vecStart in the direction of vecEnd,
|
||||
// ignoring or not monsters (depending on the value of IGNORE_MONSTERS, true or false), and stops
|
||||
// at the first obstacle encountered, returning the results of the trace in the TraceResult structure
|
||||
|
|
@ -225,17 +225,17 @@ bool Game::testLineChannel (TraceChannel channel, const Vector &start, const Vec
|
|||
|
||||
// check if bot is firing trace line
|
||||
if (bot && bot->canSkipNextTrace (channel)) {
|
||||
ptr = bot->getLastTraceResult (channel); // set the result from bot stored one
|
||||
result = bot->getLastTraceResult (channel); // set the result from bot stored one
|
||||
|
||||
// current call is skipped
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
testLine (start, end, ignoreFlags, ignoreEntity, ptr);
|
||||
testLine (start, end, ignoreFlags, ignoreEntity, &result);
|
||||
|
||||
// if we're still reaching here, save the last trace result
|
||||
if (bot) {
|
||||
bot->setLastTraceResult (channel, ptr);
|
||||
bot->setLastTraceResult (channel, &result);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
@ -326,7 +326,13 @@ float Game::getWaveLen (const char *fileName) {
|
|||
logger.error ("Wave File %s - has zero length!", filePath);
|
||||
return 0.0f;
|
||||
}
|
||||
return 1.0f * weh.read32 (header.dataChunkLength) / (weh.read16 (header.bitsPerSample) / 8) / weh.read16 (header.numChannels) / weh.read32 (header.sampleRate);
|
||||
|
||||
auto length = static_cast <float> (weh.read32 (header.dataChunkLength));
|
||||
auto bps = static_cast <float> (weh.read16 (header.bitsPerSample)) / 8;
|
||||
auto channels = static_cast <float> (weh.read16 (header.numChannels));
|
||||
auto rate = static_cast <float> (weh.read32 (header.sampleRate));
|
||||
|
||||
return length / bps / channels / rate;
|
||||
}
|
||||
|
||||
bool Game::isDedicated () {
|
||||
|
|
@ -364,7 +370,7 @@ const char *Game::getMapName () {
|
|||
return strings.format ("%s", globals->mapname.chars ());
|
||||
}
|
||||
|
||||
Vector Game::getEntityWorldOrigin (edict_t *ent) {
|
||||
Vector Game::getEntityOrigin (edict_t *ent) {
|
||||
// this expanded function returns the vector origin of a bounded entity, assuming that any
|
||||
// entity that has a bounding box has its center at the center of the bounding box itself.
|
||||
|
||||
|
|
|
|||
|
|
@ -1133,15 +1133,15 @@ void BotGraph::calculatePathRadius (int index) {
|
|||
TraceResult tr {};
|
||||
bool wayBlocked = false;
|
||||
|
||||
for (float scanDistance = 32.0f; scanDistance < 128.0f; scanDistance += 16.0f) {
|
||||
for (int32 scanDistance = 32; scanDistance < 128; scanDistance += 16) {
|
||||
start = path.origin;
|
||||
|
||||
direction = Vector (0.0f, 0.0f, 0.0f).forward () * scanDistance;
|
||||
direction = direction.angles ();
|
||||
|
||||
path.radius = scanDistance;
|
||||
path.radius = static_cast <float> (scanDistance);
|
||||
|
||||
for (float circleRadius = 0.0f; circleRadius < 360.0f; circleRadius += 20.0f) {
|
||||
for (int32 circleRadius = 0; circleRadius < 360; circleRadius += 20) {
|
||||
const auto &forward = direction.forward ();
|
||||
|
||||
auto radiusStart = start + forward * scanDistance;
|
||||
|
|
@ -1195,7 +1195,7 @@ void BotGraph::calculatePathRadius (int index) {
|
|||
|
||||
break;
|
||||
}
|
||||
direction.y = cr::normalizeAngles (direction.y + circleRadius);
|
||||
direction.y = cr::normalizeAngles (direction.y + static_cast <float> (circleRadius));
|
||||
}
|
||||
|
||||
if (wayBlocked) {
|
||||
|
|
@ -1445,7 +1445,6 @@ void BotGraph::initNarrowPlaces () {
|
|||
if (accumWeight > 1) {
|
||||
path.flags |= NodeFlag::Narrow;
|
||||
}
|
||||
accumWeight = 0;
|
||||
}
|
||||
m_narrowChecked = true;
|
||||
}
|
||||
|
|
@ -1793,7 +1792,6 @@ bool BotGraph::loadGraphData () {
|
|||
ctrl.msg ("Warning: Graph data is probably not for this map. Please check bots behaviour.");
|
||||
}
|
||||
}
|
||||
extern ConVar cv_debug_goal;
|
||||
cv_debug_goal.set (kInvalidNodeIndex);
|
||||
|
||||
return true;
|
||||
|
|
@ -2683,7 +2681,7 @@ void BotGraph::addBasic () {
|
|||
Vector up, down, front, back;
|
||||
|
||||
const Vector &diff = ((ladderLeft - ladderRight) ^ Vector (0.0f, 0.0f, 0.0f)).normalize () * 15.0f;
|
||||
front = back = game.getEntityWorldOrigin (ent);
|
||||
front = back = game.getEntityOrigin (ent);
|
||||
|
||||
front = front + diff; // front
|
||||
back = back - diff; // back
|
||||
|
|
@ -2723,7 +2721,7 @@ void BotGraph::addBasic () {
|
|||
|
||||
auto autoCreateForEntity = [] (int type, const char *entity) {
|
||||
game.searchEntities ("classname", entity, [&] (edict_t *ent) {
|
||||
const Vector &pos = game.getEntityWorldOrigin (ent);
|
||||
const Vector &pos = game.getEntityOrigin (ent);
|
||||
|
||||
if (graph.getNearestNoBuckets (pos, 50.0f) == kInvalidNodeIndex) {
|
||||
graph.add (type, pos);
|
||||
|
|
@ -2813,7 +2811,7 @@ void BotGraph::setBombOrigin (bool reset, const Vector &pos) {
|
|||
|
||||
game.searchEntities ("classname", "grenade", [&] (edict_t *ent) {
|
||||
if (util.isModel (ent, bombModel)) {
|
||||
m_bombOrigin = game.getEntityWorldOrigin (ent);
|
||||
m_bombOrigin = game.getEntityOrigin (ent);
|
||||
wasFound = true;
|
||||
|
||||
return EntitySearchResult::Break;
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ void BotManager::touchKillerEntity (Bot *bot) {
|
|||
m_killerEntity->v.dmg_inflictor = bot->ent ();
|
||||
m_killerEntity->v.dmg = (bot->pev->health + bot->pev->armorvalue) * 4.0f;
|
||||
|
||||
KeyValueData kv;
|
||||
KeyValueData kv {};
|
||||
kv.szClassName = const_cast <char *> (prop.classname.chars ());
|
||||
kv.szKeyName = "damagetype";
|
||||
kv.szValue = const_cast <char *> (strings.format ("%d", cr::bit (4)));
|
||||
|
|
@ -297,7 +297,7 @@ void BotManager::addbot (StringRef name, StringRef difficulty, StringRef persona
|
|||
// this function is same as the function above, but accept as parameters string instead of integers
|
||||
|
||||
BotRequest request {};
|
||||
StringRef any = "*";
|
||||
static StringRef any = "*";
|
||||
|
||||
request.name = (name.empty () || name == any) ? StringRef ("\0") : name;
|
||||
request.difficulty = (difficulty.empty () || difficulty == any) ? -1 : difficulty.int_ ();
|
||||
|
|
@ -306,7 +306,7 @@ void BotManager::addbot (StringRef name, StringRef difficulty, StringRef persona
|
|||
request.personality = (personality.empty () || personality == any) ? -1 : personality.int_ ();
|
||||
request.manual = manual;
|
||||
|
||||
m_addRequests.emplaceLast (cr::move (request));
|
||||
addbot (request.name, request.difficulty, request.personality, request.team, request.skin, request.manual);
|
||||
}
|
||||
|
||||
void BotManager::maintainQuota () {
|
||||
|
|
@ -394,8 +394,7 @@ void BotManager::maintainQuota () {
|
|||
createRandom ();
|
||||
}
|
||||
else if (desiredBotCount < botsInGame) {
|
||||
auto tp = countTeamPlayers ();
|
||||
|
||||
const auto &tp = countTeamPlayers ();
|
||||
bool isKicked = false;
|
||||
|
||||
if (tp.first > tp.second) {
|
||||
|
|
@ -754,7 +753,7 @@ float BotManager::getConnectTime (StringRef name, float original) {
|
|||
// this function get's fake bot player time.
|
||||
|
||||
for (const auto &bot : m_bots) {
|
||||
if (name == bot->pev->netname.chars ()) {
|
||||
if (name.startsWith (bot->pev->netname.chars ())) {
|
||||
return bot->getConnectionTime ();
|
||||
}
|
||||
}
|
||||
|
|
@ -823,8 +822,6 @@ void BotManager::updateTeamEconomics (int team, bool setTrue) {
|
|||
// that have not enough money to buy primary (with economics), and if this result higher 80%, player is can't
|
||||
// buy primary weapons.
|
||||
|
||||
extern ConVar cv_economics_rounds;
|
||||
|
||||
if (setTrue || !cv_economics_rounds.bool_ ()) {
|
||||
m_economicsGood[team] = true;
|
||||
return; // don't check economics while economics disable
|
||||
|
|
@ -877,8 +874,6 @@ void BotManager::updateBotDifficulties () {
|
|||
}
|
||||
|
||||
void BotManager::balanceBotDifficulties () {
|
||||
extern ConVar cv_whose_your_daddy;
|
||||
|
||||
// with nightmare difficulty, there is no balance
|
||||
if (cv_whose_your_daddy.bool_ ()) {
|
||||
return;
|
||||
|
|
@ -918,7 +913,6 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int skin) {
|
|||
// we're not initializing all the variables in bot class, so do an ugly thing... memset this
|
||||
plat.bzero (this, sizeof (*this));
|
||||
|
||||
|
||||
int clientIndex = game.indexOfEntity (bot);
|
||||
pev = &bot->v;
|
||||
|
||||
|
|
@ -1496,7 +1490,7 @@ void Bot::updateTeamJoin () {
|
|||
}
|
||||
|
||||
if (m_wantedTeam != 1 && m_wantedTeam != 2) {
|
||||
auto players = bots.countTeamPlayers ();
|
||||
const auto &players = bots.countTeamPlayers ();
|
||||
|
||||
// balance the team upon creation, we can't use game auto select (5) from now, as we use enforced skins belows
|
||||
// due to we don't know the team bot selected, and TeamInfo messages still shows us we're spectators..
|
||||
|
|
|
|||
|
|
@ -41,8 +41,6 @@ void MessageDispatcher::netMsgTextMsg () {
|
|||
bots.updateTeamEconomics (Team::CT, true);
|
||||
bots.updateTeamEconomics (Team::Terrorist, true);
|
||||
|
||||
extern ConVar mp_startmoney;
|
||||
|
||||
// set balance for all players
|
||||
bots.forEach ([] (Bot *bot) {
|
||||
bot->m_moneyAmount = mp_startmoney.int_ ();
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ int Bot::findBestGoal () {
|
|||
|
||||
game.searchEntities ("classname", "weaponbox", [&] (edict_t *ent) {
|
||||
if (util.isModel (ent, "backpack.mdl")) {
|
||||
result = graph.getNearest (game.getEntityWorldOrigin (ent));
|
||||
result = graph.getNearest (game.getEntityOrigin (ent));
|
||||
|
||||
if (graph.exists (result)) {
|
||||
return EntitySearchResult::Break;
|
||||
|
|
@ -429,7 +429,7 @@ void Bot::checkTerrain (float movedDistance, const Vector &dirNormal) {
|
|||
|
||||
// collision check allowed if not flying through the air
|
||||
if (isOnFloor () || isOnLadder () || isInWater ()) {
|
||||
int state[kMaxCollideMoves * 2 + 1];
|
||||
int state[kMaxCollideMoves * 2 + 1] {};
|
||||
int i = 0;
|
||||
|
||||
Vector src {}, dst {};
|
||||
|
|
@ -714,7 +714,7 @@ bool Bot::updateNavigation () {
|
|||
|
||||
if (!game.isNullEntity (tr.pHit) && game.isNullEntity (m_liftEntity) && strncmp (tr.pHit->v.classname.chars (), "func_door", 9) == 0) {
|
||||
// if the door is near enough...
|
||||
if ((game.getEntityWorldOrigin (tr.pHit) - pev->origin).lengthSq () < 2500.0f) {
|
||||
if ((game.getEntityOrigin (tr.pHit) - pev->origin).lengthSq () < 2500.0f) {
|
||||
ignoreCollision (); // don't consider being stuck
|
||||
|
||||
if (rg.chance (50)) {
|
||||
|
|
@ -1814,8 +1814,8 @@ int Bot::findDefendNode (const Vector &origin) {
|
|||
}
|
||||
TraceResult tr {};
|
||||
|
||||
int nodeIndex[kMaxNodeLinks];
|
||||
int minDistance[kMaxNodeLinks];
|
||||
int nodeIndex[kMaxNodeLinks] {};
|
||||
int minDistance[kMaxNodeLinks] {};
|
||||
|
||||
for (int i = 0; i < kMaxNodeLinks; ++i) {
|
||||
nodeIndex[i] = kInvalidNodeIndex;
|
||||
|
|
@ -1927,8 +1927,8 @@ int Bot::findCoverNode (float maxDistance) {
|
|||
|
||||
IntArray enemies;
|
||||
|
||||
int nodeIndex[kMaxNodeLinks];
|
||||
int minDistance[kMaxNodeLinks];
|
||||
int nodeIndex[kMaxNodeLinks] {};
|
||||
int minDistance[kMaxNodeLinks] {};
|
||||
|
||||
for (int i = 0; i < kMaxNodeLinks; ++i) {
|
||||
nodeIndex[i] = kInvalidNodeIndex;
|
||||
|
|
@ -1997,7 +1997,7 @@ int Bot::findCoverNode (float maxDistance) {
|
|||
minDistance[i] += practice;
|
||||
}
|
||||
}
|
||||
bool sorting;
|
||||
bool sorting = false;
|
||||
|
||||
// sort resulting nodes for nearest distance
|
||||
do {
|
||||
|
|
@ -2240,7 +2240,7 @@ bool Bot::cantMoveForward (const Vector &normal, TraceResult *tr) {
|
|||
};
|
||||
|
||||
// trace from the bot's eyes straight forward...
|
||||
traceResult = game.testLineChannel (TraceChannel::Body, src, forward, TraceIgnore::Monsters, ent (), tr);
|
||||
traceResult = game.testLineChannel (TraceChannel::Body, src, forward, TraceIgnore::Monsters, ent (), *tr);
|
||||
|
||||
// check if the trace hit something...
|
||||
if (tr->flFraction < 1.0f) {
|
||||
|
|
@ -2255,7 +2255,7 @@ bool Bot::cantMoveForward (const Vector &normal, TraceResult *tr) {
|
|||
src = getEyesPos () + Vector (0.0f, 0.0f, -16.0f) - right * -16.0f;
|
||||
forward = getEyesPos () + Vector (0.0f, 0.0f, -16.0f) + right * 16.0f + normal * 24.0f;
|
||||
|
||||
traceResult = game.testLineChannel (TraceChannel::Body, src, forward, TraceIgnore::Monsters, ent (), tr);
|
||||
traceResult = game.testLineChannel (TraceChannel::Body, src, forward, TraceIgnore::Monsters, ent (), *tr);
|
||||
|
||||
// check if the trace hit something...
|
||||
if (checkDoor (tr)) {
|
||||
|
|
@ -2267,7 +2267,7 @@ bool Bot::cantMoveForward (const Vector &normal, TraceResult *tr) {
|
|||
src = getEyesPos () + Vector (0.0f, 0.0f, -16.0f) + right * 16.0f;
|
||||
forward = getEyesPos () + Vector (0.0f, 0.0f, -16.0f) - right * -16.0f + normal * 24.0f;
|
||||
|
||||
traceResult = game.testLineChannel (TraceChannel::Body, src, forward, TraceIgnore::Monsters, ent (), tr);
|
||||
traceResult = game.testLineChannel (TraceChannel::Body, src, forward, TraceIgnore::Monsters, ent (), *tr);
|
||||
|
||||
// check if the trace hit something...
|
||||
if (checkDoor (tr)) {
|
||||
|
|
@ -2279,7 +2279,7 @@ bool Bot::cantMoveForward (const Vector &normal, TraceResult *tr) {
|
|||
src = pev->origin + Vector (0.0f, 0.0f, -19.0f + 19.0f);
|
||||
forward = src + Vector (0.0f, 0.0f, 10.0f) + normal * 24.0f;
|
||||
|
||||
traceResult = game.testLineChannel (TraceChannel::Body, src, forward, TraceIgnore::Monsters, ent (), tr);
|
||||
traceResult = game.testLineChannel (TraceChannel::Body, src, forward, TraceIgnore::Monsters, ent (), *tr);
|
||||
|
||||
// check if the trace hit something...
|
||||
if (checkDoor (tr)) {
|
||||
|
|
@ -2288,7 +2288,7 @@ bool Bot::cantMoveForward (const Vector &normal, TraceResult *tr) {
|
|||
src = pev->origin;
|
||||
forward = src + normal * 24.0f;
|
||||
|
||||
traceResult = game.testLineChannel (TraceChannel::Body, src, forward, TraceIgnore::Monsters, ent (), tr);
|
||||
traceResult = game.testLineChannel (TraceChannel::Body, src, forward, TraceIgnore::Monsters, ent (), *tr);
|
||||
|
||||
// check if the trace hit something...
|
||||
if (checkDoor (tr)) {
|
||||
|
|
@ -2301,7 +2301,7 @@ bool Bot::cantMoveForward (const Vector &normal, TraceResult *tr) {
|
|||
forward = pev->origin + Vector (0.0f, 0.0f, -17.0f) + right * 16.0f + normal * 24.0f;
|
||||
|
||||
// trace from the bot's waist straight forward...
|
||||
traceResult = game.testLineChannel (TraceChannel::Body, src, forward, TraceIgnore::Monsters, ent (), tr);
|
||||
traceResult = game.testLineChannel (TraceChannel::Body, src, forward, TraceIgnore::Monsters, ent (), *tr);
|
||||
|
||||
// check if the trace hit something...
|
||||
if (checkDoor (tr)) {
|
||||
|
|
@ -2312,7 +2312,7 @@ bool Bot::cantMoveForward (const Vector &normal, TraceResult *tr) {
|
|||
src = pev->origin + Vector (0.0f, 0.0f, -24.0f) + right * 16.0f;
|
||||
forward = pev->origin + Vector (0.0f, 0.0f, -24.0f) - right * -16.0f + normal * 24.0f;
|
||||
|
||||
traceResult = game.testLineChannel (TraceChannel::Body, src, forward, TraceIgnore::Monsters, ent (), tr);
|
||||
traceResult = game.testLineChannel (TraceChannel::Body, src, forward, TraceIgnore::Monsters, ent (), *tr);
|
||||
|
||||
// check if the trace hit something...
|
||||
if (checkDoor (tr)) {
|
||||
|
|
@ -2759,9 +2759,9 @@ int Bot::findCampingDirection () {
|
|||
m_currentNodeIndex = changePointIndex (findNearestNode ());
|
||||
}
|
||||
|
||||
int count = 0, indices[3];
|
||||
float distTab[3];
|
||||
uint16 visibility[3];
|
||||
int count = 0, indices[3] {};
|
||||
float distTab[3] {};
|
||||
uint16 visibility[3] {};
|
||||
|
||||
int currentNode = m_currentNodeIndex;
|
||||
|
||||
|
|
@ -2978,7 +2978,7 @@ int Bot::getNearestToPlantedBomb () {
|
|||
// search the bomb on the map
|
||||
game.searchEntities ("classname", "grenade", [&result, &bombModel] (edict_t *ent) {
|
||||
if (util.isModel (ent, bombModel)) {
|
||||
result = graph.getNearest (game.getEntityWorldOrigin (ent));
|
||||
result = graph.getNearest (game.getEntityOrigin (ent));
|
||||
|
||||
if (graph.exists (result)) {
|
||||
return EntitySearchResult::Break;
|
||||
|
|
@ -3045,7 +3045,7 @@ edict_t *Bot::lookupButton (const char *target) {
|
|||
|
||||
// find the nearest button which can open our target
|
||||
game.searchEntities ("target", target, [&] (edict_t *ent) {
|
||||
const Vector &pos = game.getEntityWorldOrigin (ent);
|
||||
const Vector &pos = game.getEntityOrigin (ent);
|
||||
|
||||
// check if this place safe
|
||||
if (!isDeadlyMove (pos)) {
|
||||
|
|
|
|||
|
|
@ -375,7 +375,7 @@ void BotSupport::listenNoise (edict_t *ent, StringRef sample, float volume) {
|
|||
if (game.isNullEntity (ent) || sample.empty ()) {
|
||||
return;
|
||||
}
|
||||
const Vector &origin = game.getEntityWorldOrigin (ent);
|
||||
const auto &origin = game.getEntityOrigin (ent);
|
||||
|
||||
// something wrong with sound...
|
||||
if (origin.empty ()) {
|
||||
|
|
@ -496,8 +496,6 @@ void BotSupport::simulateNoise (int playerIndex) {
|
|||
}
|
||||
}
|
||||
else {
|
||||
extern ConVar mp_footsteps;
|
||||
|
||||
if (mp_footsteps.bool_ ()) {
|
||||
// moves fast enough?
|
||||
noise.dist = 1280.0f * (client.ent->v.velocity.length2d () / 260.0f);
|
||||
|
|
@ -688,7 +686,7 @@ bool BotSupport::isObjectInsidePlane (FrustumPlane &plane, const Vector ¢er,
|
|||
}
|
||||
|
||||
bool BotSupport::isModel (const edict_t *ent, StringRef model) {
|
||||
return model == ent->v.model.chars (9);
|
||||
return model.startsWith (ent->v.model.chars (9));
|
||||
}
|
||||
|
||||
int32 BotSupport::sendTo (int socket, const void *message, size_t length, int flags, const sockaddr *dest, int destLength) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue