fix: players play time got replaced with bots play time.

fix: crlib: fixed clang-analyzer warnings.
build: removed predefined optimization flags in debug builds.
This commit is contained in:
ds 2020-10-03 16:39:09 +03:00
commit f40ca59700
11 changed files with 44 additions and 24 deletions

View file

@ -27,9 +27,6 @@ Game::Game () {
m_precached = false;
plat.bzero (m_drawModels, sizeof (m_drawModels));
plat.bzero (m_spawnCount, sizeof (m_spawnCount));
m_gameFlags = 0;
m_mapFlags = 0;
m_slowFrame = 0.0;

View file

@ -870,7 +870,7 @@ void BotGraph::toggleFlags (int toggleFlag) {
if (m_paths[index].flags & toggleFlag) {
m_paths[index].flags &= ~toggleFlag;
}
else if (!(m_paths[index].flags & toggleFlag)) {
else {
if (toggleFlag == NodeFlag::Sniper && !(m_paths[index].flags & NodeFlag::Camp)) {
ctrl.msg ("Cannot assign sniper flag to node %d. This is not camp node.", index);
return;
@ -2277,13 +2277,13 @@ void BotGraph::frame () {
}
}
// create path pointer for faster access
auto &path = m_paths[nearestIndex];
// draw a paths, camplines and danger directions for nearest node
if (nearestDistance <= 56.0f && m_pathDisplayTime <= game.time ()) {
m_pathDisplayTime = game.time () + 1.0f;
// create path pointer for faster access
auto &path = m_paths[nearestIndex];
// draw the camplines
if (path.flags & NodeFlag::Camp) {
float height = 36.0f;
@ -2940,10 +2940,9 @@ void BotGraph::updateGlobalPractice () {
// get the most dangerous node for this position for both teams
for (int team = Team::Terrorist; team < kGameTeamNum; ++team) {
int bestIndex = kInvalidNodeIndex; // best index to store
int maxDamage = 0;
for (int i = 0; i < length (); ++i) {
maxDamage = 0;
int maxDamage = 0;
bestIndex = kInvalidNodeIndex;
for (int j = 0; j < length (); ++j) {

View file

@ -757,11 +757,11 @@ void BotManager::listBots () {
ctrl.msg ("%d bots", m_bots.length ());
}
float BotManager::getConnectTime (int botId, float original) {
float BotManager::getConnectTime (StringRef name, float original) {
// this function get's fake bot player time.
for (const auto &bot : m_bots) {
if (bot->entindex () == botId) {
if (name == bot->pev->netname.chars ()) {
return bot->getConnectionTime ();
}
}

View file

@ -581,6 +581,7 @@ void Bot::checkTerrain (float movedDistance, const Vector &dirNormal) {
do {
sorting = false;
for (i = 0; i < 3; ++i) {
if (state[i + kMaxCollideMoves] < state[i + kMaxCollideMoves + 1]) {
cr::swap (state[i], state[i + 1]);
@ -591,8 +592,8 @@ void Bot::checkTerrain (float movedDistance, const Vector &dirNormal) {
}
} while (sorting);
for (i = 0; i < kMaxCollideMoves; ++i) {
m_collideMoves[i] = state[i];
for (int j = 0; j < kMaxCollideMoves; ++j) {
m_collideMoves[j] = state[j];
}
m_collideTime = game.time ();

View file

@ -691,11 +691,11 @@ int32 BotSupport::sendTo (int socket, const void *message, size_t length, int fl
for (uint8 i = 0; i < count; ++i) {
buffer.skip <uint8> (); // number
buffer.skipString (); // name
auto name = buffer.readString (); // name
buffer.skip <int32> (); // score
auto ctime = buffer.read <float> (); // override connection time
buffer.write <float> (bots.getConnectTime (i, ctime));
buffer.write <float> (bots.getConnectTime (name, ctime));
}
return send (buffer.data ());
}