Fixes for best waypoint searching and waypoint advance code.

Fixed software renderer true for OSX & Linux.
Fixed software renderer is default for OSX & Linux.
Fixed GCCs -pedantic warnings.
This commit is contained in:
jeefo 2019-08-01 23:02:44 +03:00
commit 1d3910d629
12 changed files with 71 additions and 68 deletions

View file

@ -20,7 +20,7 @@
CR_DECLARE_SCOPED_ENUM (ReservePolicy,
Multiple,
Single,
);
)
CR_NAMESPACE_BEGIN

View file

@ -41,7 +41,7 @@ using uint8 = unsigned char;
using uint16 = unsigned short;
using uint32 = unsigned int;
using uint64 = unsigned long long;
};
}
// make types available for our own use
using namespace cr::types;
@ -114,13 +114,13 @@ public:
__VA_ARGS__ \
}; \
}; \
}; \
} \
CR_NAMESPACE_END \
using enumName = ::cr::enums::_##enumName::Type; \
// same as above, but with int32 type
#define CR_DECLARE_SCOPED_ENUM(enumName, ...) \
CR_DECLARE_SCOPED_ENUM_TYPE(enumName, int32, __VA_ARGS__); \
CR_DECLARE_SCOPED_ENUM_TYPE(enumName, int32, __VA_ARGS__) \
CR_NAMESPACE_END

View file

@ -34,7 +34,7 @@ CR_NAMESPACE_BEGIN
namespace types {
using StringArray = Array <String>;
using IntArray = Array <int>;
};
}
using namespace cr::types;

View file

@ -41,7 +41,7 @@ CR_DECLARE_SCOPED_ENUM (HttpClientResult,
Undefined,
NoLocalFile = -1,
LocalFileExists = -2
);
)
CR_NAMESPACE_BEGIN
@ -193,7 +193,7 @@ namespace detail {
return result;
}
};
};
}
// simple http client for downloading/uploading files only
class HttpClient final : public Singleton <HttpClient> {

View file

@ -83,7 +83,7 @@ inline float cosf (const float value) {
inline float atanf (const float x) {
const float sqr = cr::square (x);
return x * (48.70107004404898384f + sqr * (49.5326263772254345f + sqr * 9.40604244231624f)) / (48.70107004404996166f + sqr * (65.7663163908956299f + sqr * (21.587934067020262f + sqr)));
};
}
inline float atan2f (const float y, const float x) {
const float ax = cr::abs (x);

View file

@ -23,7 +23,7 @@ namespace detail {
template <typename T> struct ClearRef <T &&> {
using Type = T;
};
};
}
template <typename T> typename detail::ClearRef <T>::Type constexpr &&move (T &&type) noexcept {
return static_cast <typename detail::ClearRef <T>::Type &&> (type);

View file

@ -14,7 +14,7 @@ CR_DECLARE_SCOPED_ENUM (DrawLine,
Simple,
Arrow,
Count
);
)
// trace ignore
CR_DECLARE_SCOPED_ENUM (TraceIgnore,
@ -22,7 +22,7 @@ CR_DECLARE_SCOPED_ENUM (TraceIgnore,
Glass = cr::bit (0),
Monsters = cr::bit (1),
Everything = Glass | Monsters
);
)
// variable type
CR_DECLARE_SCOPED_ENUM (Var,
@ -31,7 +31,7 @@ CR_DECLARE_SCOPED_ENUM (Var,
Password,
NoServer,
NoRegister
);
)
// netmessage functions
CR_DECLARE_SCOPED_ENUM (NetMsg,
@ -59,7 +59,7 @@ CR_DECLARE_SCOPED_ENUM (NetMsg,
Fashlight = 22,
ItemStatus = 23,
Count = 25
);
)
// supported cs's
CR_DECLARE_SCOPED_ENUM (GameFlags,
@ -75,7 +75,7 @@ CR_DECLARE_SCOPED_ENUM (GameFlags,
ReGameDLL = cr::bit (9), // server dll is a regamedll
HasFakePings = cr::bit (10), // on that game version we can fake bots pings
HasBotVoice = cr::bit (11) // on that game version we can use chatter
);
)
// defines map type
CR_DECLARE_SCOPED_ENUM (MapFlags,
@ -86,7 +86,7 @@ CR_DECLARE_SCOPED_ENUM (MapFlags,
KnifeArena = cr::bit (4),
Fun = cr::bit (5),
HasDoors = cr::bit (10) // additional flags
);
)
// variable reg pair
struct VarPair {

View file

@ -41,7 +41,7 @@ CR_DECLARE_SCOPED_ENUM (Task,
Hide,
Blind,
Spraypaint,
);
)
// bot menu ids
CR_DECLARE_SCOPED_ENUM (Menu,
@ -67,13 +67,13 @@ CR_DECLARE_SCOPED_ENUM (Menu,
KickPage2,
KickPage3,
KickPage4,
);
)
// bomb say string
CR_DECLARE_SCOPED_ENUM (BombPlantedSay,
ChatSay = cr::bit (1),
Chatter = cr::bit (2)
);
)
// chat types id's
CR_DECLARE_SCOPED_ENUM (Chat,
@ -85,7 +85,7 @@ CR_DECLARE_SCOPED_ENUM (Chat,
Hello, // id to welcome chat array
NoKeyword, // id to no keyword chat array
Count // number for array
);
)
// personalities defines
CR_DECLARE_SCOPED_ENUM (Personality,
@ -93,7 +93,7 @@ CR_DECLARE_SCOPED_ENUM (Personality,
Rusher,
Careful,
Invalid = -1
);
)
// bot difficulties
CR_DECLARE_SCOPED_ENUM (Difficulty,
@ -103,7 +103,7 @@ CR_DECLARE_SCOPED_ENUM (Difficulty,
Hard,
Extreme,
Invalid = -1
);
)
// collision states
CR_DECLARE_SCOPED_ENUM (CollisionState,
@ -114,7 +114,7 @@ CR_DECLARE_SCOPED_ENUM (CollisionState,
Duck,
StrafeLeft,
StrafeRight
);
)
// counter-strike team id's
CR_DECLARE_SCOPED_ENUM (Team,
@ -123,13 +123,13 @@ CR_DECLARE_SCOPED_ENUM (Team,
Spectator,
Unassigned,
Invalid = -1
);
)
// item status for StatusIcon message
CR_DECLARE_SCOPED_ENUM (ItemStatus,
Nightvision = cr::bit (0),
DefusalKit = cr::bit (1)
);
)
// client flags
CR_DECLARE_SCOPED_ENUM (ClientFlags,
@ -137,7 +137,7 @@ CR_DECLARE_SCOPED_ENUM (ClientFlags,
Alive = cr::bit (1),
Admin = cr::bit (2),
Icon = cr::bit (3)
);
)
// bot create status
CR_DECLARE_SCOPED_ENUM (BotCreateResult,
@ -145,7 +145,7 @@ CR_DECLARE_SCOPED_ENUM (BotCreateResult,
MaxPlayersReached,
GraphError,
TeamStacked
);
)
// radio messages
CR_DECLARE_SCOPED_ENUM (Radio,
@ -170,7 +170,7 @@ CR_DECLARE_SCOPED_ENUM (Radio,
ShesGonnaBlow = 27,
Negative = 28,
EnemyDown = 29
);
)
// chatter system (extending enum above, messages 30-39 is reserved)
CR_DECLARE_SCOPED_ENUM (Chatter,
@ -226,7 +226,7 @@ CR_DECLARE_SCOPED_ENUM (Chatter,
BehindSmoke,
BombsiteSecured,
Count
);
)
// counter-strike weapon id's
CR_DECLARE_SCOPED_ENUM (Weapon,
@ -263,7 +263,7 @@ CR_DECLARE_SCOPED_ENUM (Weapon,
Armor = 31,
ArmorHelm = 32,
Defuser = 33
);
)
// buy counts
CR_DECLARE_SCOPED_ENUM (BuyState,
@ -275,7 +275,7 @@ CR_DECLARE_SCOPED_ENUM (BuyState,
Ammo,
NightVision,
Done
);
)
// economics limits
CR_DECLARE_SCOPED_ENUM (EcoLimit,
@ -290,7 +290,7 @@ CR_DECLARE_SCOPED_ENUM (EcoLimit,
ProstockRusher,
ProstockCareful,
ShieldGreater
);
)
// defines for pickup items
CR_DECLARE_SCOPED_ENUM (Pickup,
@ -302,42 +302,42 @@ CR_DECLARE_SCOPED_ENUM (Pickup,
Button,
Shield,
DefusalKit
);
)
// fight style type
CR_DECLARE_SCOPED_ENUM (Fight,
None = 0,
Strafe,
Stay
);
)
// dodge type
CR_DECLARE_SCOPED_ENUM (Dodge,
None = 0,
Left,
Right
);
)
// reload state
CR_DECLARE_SCOPED_ENUM (Reload,
None = 0, // no reload state currently
Primary, // primary weapon reload state
Secondary // secondary weapon reload state
);
)
// collision probes
CR_DECLARE_SCOPED_ENUM (CollisionProbe,
Jump = cr::bit (0), // probe jump when colliding
Duck = cr::bit (1), // probe duck when colliding
Strafe = cr::bit (2) // probe strafing when colliding
);
)
// vgui menus (since latest steam updates is obsolete, but left for old cs)
CR_DECLARE_SCOPED_ENUM (GuiMenu,
TeamSelect = 2, // menu select team
TerroristSelect = 26, // terrorist select menu
CTSelect = 27 // ct select menu
);
)
// lift usage states
CR_DECLARE_SCOPED_ENUM (LiftState,
@ -349,7 +349,7 @@ CR_DECLARE_SCOPED_ENUM (LiftState,
LookingButtonInside,
TravelingBy,
Leaving
);
)
// game start messages for counter-strike...
CR_DECLARE_SCOPED_ENUM (BotMsg,
@ -360,7 +360,7 @@ CR_DECLARE_SCOPED_ENUM (BotMsg,
Radio = 200,
Say = 10000,
SayTeam = 10001
);
)
// sensing states
CR_DECLARE_SCOPED_ENUM (Sense,
@ -371,7 +371,7 @@ CR_DECLARE_SCOPED_ENUM (Sense,
ThrowExplosive = cr::bit (4), // could throw he grenade
ThrowFlashbang = cr::bit (5), // could throw flashbang
ThrowSmoke = cr::bit (6) // could throw smokegrenade
);
)
// positions to aim at
CR_DECLARE_SCOPED_ENUM (AimFlags,
@ -383,27 +383,27 @@ CR_DECLARE_SCOPED_ENUM (AimFlags,
Enemy = cr::bit (5), // aim at enemy
Grenade = cr::bit (6), // aim for grenade throw
Override = cr::bit (7) // overrides all others (blinded)
);
)
// famas/glock burst mode status + m4a1/usp silencer
CR_DECLARE_SCOPED_ENUM (BurstMode,
On = cr::bit (0),
Off = cr::bit (1)
);
)
// visibility flags
CR_DECLARE_SCOPED_ENUM (Visibility,
Head = cr::bit (1),
Body = cr::bit (2),
Other = cr::bit (3)
);
)
// command handler status
CR_DECLARE_SCOPED_ENUM (BotCommandResult,
Handled = 0, // command successfully handled
ListenServer, // command is only avaialble on listen server
BadFormat // wrong params
);
)
// defines for nodes flags field (32 bits are available)
CR_DECLARE_SCOPED_ENUM (NodeFlag,
@ -419,45 +419,45 @@ CR_DECLARE_SCOPED_ENUM (NodeFlag,
Sniper = cr::bit (28), // it's a specific sniper point
TerroristOnly = cr::bit (29), // it's a specific terrorist point
CTOnly = cr::bit (30), // it's a specific ct point
);
)
// defines for node connection flags field (16 bits are available)
CR_DECLARE_SCOPED_ENUM_TYPE (PathFlag, uint16,
Jump = cr::bit (0) // must jump for this connection
);
)
// enum pathfind search type
CR_DECLARE_SCOPED_ENUM (FindPath,
Fast = 0,
Optimal,
Safe
);
)
// defines node connection types
CR_DECLARE_SCOPED_ENUM (PathConnection,
Outgoing = 0,
Incoming,
Bidirectional
);
)
// defines node add commands
CR_DECLARE_SCOPED_ENUM (GraphAdd,
Normal = 0,
);
)
// a* route state
CR_DECLARE_SCOPED_ENUM (RouteState,
Open = 0,
Closed,
New
);
)
// node edit states
CR_DECLARE_SCOPED_ENUM (GraphEdit,
On = cr::bit (1),
Noclip = cr::bit (2),
Auto = cr::bit (3)
);
)
CR_DECLARE_SCOPED_ENUM (StorageOption,
Practice = cr::bit (0), // this is practice (experience) file
@ -467,7 +467,7 @@ CR_DECLARE_SCOPED_ENUM (StorageOption,
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
);
)
CR_DECLARE_SCOPED_ENUM (StorageVersion,
Graph = 1,
@ -475,7 +475,7 @@ CR_DECLARE_SCOPED_ENUM (StorageVersion,
Vistable = 1,
Matrix = 1,
Podbot = 7
);
)
// some hardcoded desire defines used to override calculated ones
namespace TaskPri {

View file

@ -11,7 +11,7 @@ PROJECT = yapb
SOURCES = ../source
OBJECTS = $(wildcard $(SOURCES)/*.cpp)
COMPILER_FLAGS = -std=c++11 -m32 -Wall -Wextra -Werror -fno-exceptions -fno-rtti
COMPILER_FLAGS = -std=c++11 -m32 -Wall -Wextra -Werror -fno-exceptions -fno-rtti -pedantic
LINKER_FLAGS = -m32 -ldl
ifeq "$(DEBUG)" "true"

View file

@ -316,7 +316,7 @@ Vector Game::getAbsPos (edict_t *ent) {
}
if (ent->v.origin.empty ()) {
return (ent->v.absmin + ent->v.absmax) * 0.5f;
return ent->v.absmin + (ent->v.size * 0.5);
}
return ent->v.origin;
}
@ -423,13 +423,13 @@ bool Game::isSoftwareRenderer () {
if (plat.isWindows) {
return plat.hasModule ("sw");
}
return true;
return false;
}
void Game::addNewCvar (const char *variable, const char *value, Var varType, bool regMissing, const char *regVal, ConVar *self) {
// this function adds globally defined variable to registration stack
VarPair pair = {};
VarPair pair {};
pair.reg.name = const_cast <char *> (variable);
pair.reg.string = const_cast <char *> (value);

View file

@ -285,7 +285,7 @@ void Bot::ignoreCollision () {
void Bot::avoidIncomingPlayers (edict_t *touch) {
auto task = getCurrentTaskId ();
if (task == Task::PlantBomb || task == Task::DefuseBomb || task == Task::Camp || m_moveSpeed <= 100.0f) {
if (task == Task::PlantBomb || task == Task::DefuseBomb || task == Task::Camp || m_moveSpeed <= 100.0f || m_avoidTime > game.timebase ()) {
return;
}
@ -1540,13 +1540,13 @@ bool Bot::findBestNearestNode () {
int lessIndex[3] = { kInvalidNodeIndex, kInvalidNodeIndex , kInvalidNodeIndex };
auto &bucket = graph.getNodesInBucket (pev->origin);
int numToSkip = cr::clamp (rg.int_ (0, static_cast <int> (bucket.length () - 1)), 0, 5);
int numToSkip = cr::clamp (rg.int_ (0, 3), 0, static_cast <int> (bucket.length () / 2));
for (const int at : bucket) {
bool skip = !!(at == m_currentNodeIndex);
// skip the current node, if any
if (skip) {
if (skip && numToSkip > 0) {
continue;
}
@ -1568,13 +1568,18 @@ bool Bot::findBestNearestNode () {
continue;
}
// check we're have link to it
if (m_currentNodeIndex != kInvalidNodeIndex && !graph.isConnected (m_currentNodeIndex, at)) {
continue;
}
// ignore non-reacheable nodes...
if (!graph.isReachable (this, at)) {
continue;
}
// check if node is already used by another bot...
if (bots.getRoundStartTime () + 5.0f > game.timebase () && isOccupiedPoint (at)) {
if (bots.getRoundStartTime () + 5.0f < game.timebase () && isOccupiedPoint (at)) {
busy = at;
continue;
}
@ -2072,7 +2077,7 @@ bool Bot::selectBestNextNode () {
continue;
}
if (!isOccupiedPoint (link.index)) {
if (!isOccupiedPoint (link.index) && graph[link.index].origin.z <= graph[m_currentNodeIndex].origin.z + 10.0f) {
m_pathWalk.first () = link.index;
return true;
}
@ -3033,15 +3038,13 @@ bool Bot::isOccupiedPoint (int index) {
if (bot != nullptr) {
int occupyId = util.getShootingCone (bot->ent (), pev->origin) >= 0.7f ? bot->m_previousNodes[0] : bot->m_currentNodeIndex;
if (bot != nullptr) {
if (index == occupyId) {
return true;
}
}
}
float length = (graph[index].origin - client.origin).lengthSq ();
if (length < cr::clamp (graph[index].radius, cr::square (32.0f), cr::square (90.0f))) {
if (length < cr::clamp (graph[index].radius, cr::square (64.0f), cr::square (120.0f))) {
return true;
}
}

View file

@ -566,7 +566,7 @@ void BotUtils::sendPings (edict_t *to) {
constexpr int kGamePingSVC = 17;
for (auto &client : m_clients) {
if (!(client.flags & ClientFlags::Used)) {
if (!(client.flags & ClientFlags::Used) || client.ent == game.getLocalEntity ()) {
continue;
}
if (!client.pingUpdate) {