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:
parent
5170bb9bcf
commit
f40ca59700
11 changed files with 44 additions and 24 deletions
|
|
@ -34,7 +34,7 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
template <typename T> T *allocate (const size_t length = 1) {
|
template <typename T> T *allocate (const size_t length = 1) {
|
||||||
auto memory = reinterpret_cast <T *> (malloc (length * sizeof (T)));
|
auto memory = reinterpret_cast <T *> (malloc (cr::max (1u, length * sizeof (T))));
|
||||||
|
|
||||||
if (!memory) {
|
if (!memory) {
|
||||||
plat.abort ();
|
plat.abort ();
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Deque () : contents_ (nullptr), capacity_ (0)
|
explicit Deque () : capacity_ (0), contents_ (nullptr)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
Deque (Deque &&rhs) : contents_ (cr::move (rhs.contents_)), capacity_ (rhs.capacity_) {
|
Deque (Deque &&rhs) : contents_ (cr::move (rhs.contents_)), capacity_ (rhs.capacity_) {
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,11 @@ CR_NAMESPACE_BEGIN
|
||||||
# define __PLACEMENT_NEW_INLINE 1
|
# define __PLACEMENT_NEW_INLINE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// disabled gcc warnings
|
||||||
|
#if defined (CR_CXX_GCC)
|
||||||
|
# pragma GCC diagnostic ignored "-Wignored-attributes"
|
||||||
|
#endif
|
||||||
|
|
||||||
CR_NAMESPACE_END
|
CR_NAMESPACE_END
|
||||||
|
|
||||||
#if defined(CR_WINDOWS)
|
#if defined(CR_WINDOWS)
|
||||||
|
|
|
||||||
19
inc/engine.h
19
inc/engine.h
|
|
@ -120,8 +120,8 @@ public:
|
||||||
using EntitySearch = Lambda <EntitySearchResult (edict_t *)>;
|
using EntitySearch = Lambda <EntitySearchResult (edict_t *)>;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_drawModels[DrawLine::Count];
|
int m_drawModels[DrawLine::Count] { };
|
||||||
int m_spawnCount[Team::Unassigned];
|
int m_spawnCount[Team::Unassigned] { };
|
||||||
|
|
||||||
// bot client command
|
// bot client command
|
||||||
StringArray m_botArgs;
|
StringArray m_botArgs;
|
||||||
|
|
@ -608,6 +608,21 @@ public:
|
||||||
++m_cursor;
|
++m_cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String readString () {
|
||||||
|
if (m_buffer.length () < m_cursor) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
String out;
|
||||||
|
|
||||||
|
for (; m_cursor < m_buffer.length () && m_buffer[m_cursor] != kNullChar; ++m_cursor) {
|
||||||
|
out += m_buffer[m_cursor];
|
||||||
|
}
|
||||||
|
++m_cursor;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
void shiftToEnd () {
|
void shiftToEnd () {
|
||||||
m_cursor = m_buffer.length ();
|
m_cursor = m_buffer.length ();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ public:
|
||||||
int getHumansCount (bool ignoreSpectators = false);
|
int getHumansCount (bool ignoreSpectators = false);
|
||||||
int getAliveHumansCount ();
|
int getAliveHumansCount ();
|
||||||
|
|
||||||
float getConnectTime (int botId, float original);
|
float getConnectTime (StringRef name, float original);
|
||||||
float getAverageTeamKPD (bool calcForBots);
|
float getAverageTeamKPD (bool calcForBots);
|
||||||
|
|
||||||
void setBombPlanted (bool isPlanted);
|
void setBombPlanted (bool isPlanted);
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ buildVersion = meson.project_version ()
|
||||||
compilerId = buildCompiler.get_id ()
|
compilerId = buildCompiler.get_id ()
|
||||||
compilerVersion = buildCompiler.version ()
|
compilerVersion = buildCompiler.version ()
|
||||||
|
|
||||||
isOptimize = get_option ('buildtype') == 'release'
|
isOptimize = get_option ('buildtype') == 'release' or get_option ('buildtype') == 'debugoptimized'
|
||||||
isVC = compilerId == 'msvc' or compilerId == 'intel-cl' or compilerId == 'clang-cl'
|
isVC = compilerId == 'msvc' or compilerId == 'intel-cl' or compilerId == 'clang-cl'
|
||||||
isGCC = compilerId == 'gcc'
|
isGCC = compilerId == 'gcc'
|
||||||
isIntel = compilerId == 'intel' or compilerId == 'intel-cl'
|
isIntel = compilerId == 'intel' or compilerId == 'intel-cl'
|
||||||
|
|
@ -82,7 +82,11 @@ if isCLang or isGCC or (isIntel and not isWindows)
|
||||||
'-m32',
|
'-m32',
|
||||||
'-fno-threadsafe-statics',
|
'-fno-threadsafe-statics',
|
||||||
'-fno-exceptions',
|
'-fno-exceptions',
|
||||||
'-fno-rtti',
|
'-fno-rtti'
|
||||||
|
]
|
||||||
|
|
||||||
|
flagsCompiler += [
|
||||||
|
'-pedantic'
|
||||||
]
|
]
|
||||||
|
|
||||||
if isOptimize
|
if isOptimize
|
||||||
|
|
@ -132,7 +136,6 @@ if isLinux or isDarwin
|
||||||
flagsCompiler += [
|
flagsCompiler += [
|
||||||
'-g3',
|
'-g3',
|
||||||
'-ggdb',
|
'-ggdb',
|
||||||
'-O3',
|
|
||||||
'-DCR_DEBUG'
|
'-DCR_DEBUG'
|
||||||
]
|
]
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -27,9 +27,6 @@ Game::Game () {
|
||||||
|
|
||||||
m_precached = false;
|
m_precached = false;
|
||||||
|
|
||||||
plat.bzero (m_drawModels, sizeof (m_drawModels));
|
|
||||||
plat.bzero (m_spawnCount, sizeof (m_spawnCount));
|
|
||||||
|
|
||||||
m_gameFlags = 0;
|
m_gameFlags = 0;
|
||||||
m_mapFlags = 0;
|
m_mapFlags = 0;
|
||||||
m_slowFrame = 0.0;
|
m_slowFrame = 0.0;
|
||||||
|
|
|
||||||
|
|
@ -870,7 +870,7 @@ void BotGraph::toggleFlags (int toggleFlag) {
|
||||||
if (m_paths[index].flags & toggleFlag) {
|
if (m_paths[index].flags & toggleFlag) {
|
||||||
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)) {
|
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);
|
ctrl.msg ("Cannot assign sniper flag to node %d. This is not camp node.", index);
|
||||||
return;
|
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
|
// draw a paths, camplines and danger directions for nearest node
|
||||||
if (nearestDistance <= 56.0f && m_pathDisplayTime <= game.time ()) {
|
if (nearestDistance <= 56.0f && m_pathDisplayTime <= game.time ()) {
|
||||||
m_pathDisplayTime = game.time () + 1.0f;
|
m_pathDisplayTime = game.time () + 1.0f;
|
||||||
|
|
||||||
|
// create path pointer for faster access
|
||||||
|
auto &path = m_paths[nearestIndex];
|
||||||
|
|
||||||
// draw the camplines
|
// draw the camplines
|
||||||
if (path.flags & NodeFlag::Camp) {
|
if (path.flags & NodeFlag::Camp) {
|
||||||
float height = 36.0f;
|
float height = 36.0f;
|
||||||
|
|
@ -2940,10 +2940,9 @@ void BotGraph::updateGlobalPractice () {
|
||||||
// get the most dangerous node for this position for both teams
|
// get the most dangerous node for this position for both teams
|
||||||
for (int team = Team::Terrorist; team < kGameTeamNum; ++team) {
|
for (int team = Team::Terrorist; team < kGameTeamNum; ++team) {
|
||||||
int bestIndex = kInvalidNodeIndex; // best index to store
|
int bestIndex = kInvalidNodeIndex; // best index to store
|
||||||
int maxDamage = 0;
|
|
||||||
|
|
||||||
for (int i = 0; i < length (); ++i) {
|
for (int i = 0; i < length (); ++i) {
|
||||||
maxDamage = 0;
|
int maxDamage = 0;
|
||||||
bestIndex = kInvalidNodeIndex;
|
bestIndex = kInvalidNodeIndex;
|
||||||
|
|
||||||
for (int j = 0; j < length (); ++j) {
|
for (int j = 0; j < length (); ++j) {
|
||||||
|
|
|
||||||
|
|
@ -757,11 +757,11 @@ void BotManager::listBots () {
|
||||||
ctrl.msg ("%d bots", m_bots.length ());
|
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.
|
// this function get's fake bot player time.
|
||||||
|
|
||||||
for (const auto &bot : m_bots) {
|
for (const auto &bot : m_bots) {
|
||||||
if (bot->entindex () == botId) {
|
if (name == bot->pev->netname.chars ()) {
|
||||||
return bot->getConnectionTime ();
|
return bot->getConnectionTime ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -581,6 +581,7 @@ void Bot::checkTerrain (float movedDistance, const Vector &dirNormal) {
|
||||||
|
|
||||||
do {
|
do {
|
||||||
sorting = false;
|
sorting = false;
|
||||||
|
|
||||||
for (i = 0; i < 3; ++i) {
|
for (i = 0; i < 3; ++i) {
|
||||||
if (state[i + kMaxCollideMoves] < state[i + kMaxCollideMoves + 1]) {
|
if (state[i + kMaxCollideMoves] < state[i + kMaxCollideMoves + 1]) {
|
||||||
cr::swap (state[i], state[i + 1]);
|
cr::swap (state[i], state[i + 1]);
|
||||||
|
|
@ -591,8 +592,8 @@ void Bot::checkTerrain (float movedDistance, const Vector &dirNormal) {
|
||||||
}
|
}
|
||||||
} while (sorting);
|
} while (sorting);
|
||||||
|
|
||||||
for (i = 0; i < kMaxCollideMoves; ++i) {
|
for (int j = 0; j < kMaxCollideMoves; ++j) {
|
||||||
m_collideMoves[i] = state[i];
|
m_collideMoves[j] = state[j];
|
||||||
}
|
}
|
||||||
|
|
||||||
m_collideTime = game.time ();
|
m_collideTime = game.time ();
|
||||||
|
|
|
||||||
|
|
@ -691,11 +691,11 @@ int32 BotSupport::sendTo (int socket, const void *message, size_t length, int fl
|
||||||
|
|
||||||
for (uint8 i = 0; i < count; ++i) {
|
for (uint8 i = 0; i < count; ++i) {
|
||||||
buffer.skip <uint8> (); // number
|
buffer.skip <uint8> (); // number
|
||||||
buffer.skipString (); // name
|
auto name = buffer.readString (); // name
|
||||||
buffer.skip <int32> (); // score
|
buffer.skip <int32> (); // score
|
||||||
|
|
||||||
auto ctime = buffer.read <float> (); // override connection time
|
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 ());
|
return send (buffer.data ());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue