small optimizations and code style fixes

This commit is contained in:
jeefo 2015-06-24 15:38:48 +03:00
commit c28110cce2
12 changed files with 220 additions and 200 deletions

View file

@ -90,8 +90,6 @@ using namespace Math;
#define DLL_RETENTRY return
#define DLL_GIVEFNPTRSTODLL extern "C" void __attribute__((visibility("default")))
static inline uint32 _lrotl (uint32 x, int r) { return (x << r) | (x >> (sizeof (x) * 8 - r));}
typedef int (*EntityAPI_t) (gamefuncs_t *, int);
typedef int (*NewEntityAPI_t) (newgamefuncs_t *, int *);
typedef int (*BlendAPI_t) (int, void **, void *, float (*)[3][4], float (*)[128][3][4]);
@ -242,7 +240,8 @@ enum CollisionState
COLLISION_JUMP,
COLLISION_DUCK,
COLLISION_STRAFELEFT,
COLLISION_STRAFERIGHT
COLLISION_STRAFERIGHT,
COLLISION_BACKOFF
};
// counter-strike team id's
@ -409,7 +408,8 @@ enum CollisionProbe
{
PROBE_JUMP = (1 << 0), // probe jump when colliding
PROBE_DUCK = (1 << 1), // probe duck when colliding
PROBE_STRAFE = (1 << 2) // probe strafing when colliding
PROBE_STRAFE = (1 << 2), // probe strafing when colliding
PROBE_BACKOFF = (1 << 3) // probe going back when colliding
};
// vgui menus (since latest steam updates is obsolete, but left for old cs)
@ -857,7 +857,7 @@ private:
float m_lastCollTime; // time until next collision check
unsigned int m_collisionProbeBits; // bits of possible collision moves
unsigned int m_collideMoves[4]; // sorted array of movements
unsigned int m_collideMoves[5]; // sorted array of movements
unsigned int m_collStateIndex; // index into collide moves
CollisionState m_collisionState; // collision State
@ -1051,8 +1051,8 @@ private:
bool OutOfBombTimer (void);
void SelectLeaderEachTeam (int team);
Vector CheckToss (const Vector &start, Vector end);
Vector CheckThrow (const Vector &start, Vector end);
const Vector &CheckThrow (const Vector &start, const Vector &stop);
const Vector &CheckToss (const Vector &start, const Vector &stop);
Vector CheckBombAudible (void);
const Vector &GetAimPosition (void);
@ -1279,10 +1279,9 @@ private:
Array <CreateQueue> m_creationTab; // bot creation tab
Bot *m_bots[32]; // all available bots
float m_maintainTime; // time to maintain bot creation quota
float m_maintainTime; // time to maintain bot creation quota
int m_lastWinner; // the team who won previous round
int m_roundCount; // rounds passed
bool m_economicsGood[2]; // is team able to buy anything
bool m_deathMsgSent; // for fakeping
@ -1291,7 +1290,7 @@ private:
Array <entity_t> m_activeGrenades;
protected:
int CreateBot (String name, int difficulty, int personality, int team, int member);
int CreateBot (const String &name, int difficulty, int personality, int team, int member);
public:
BotManager (void);
@ -1320,7 +1319,7 @@ public:
void AddRandom (void) { AddBot ("", -1, -1, -1, -1); }
void AddBot (const String &name, int difficulty, int personality, int team, int member);
void AddBot (String name, String difficulty, String personality, String team, String member);
void AddBot (const String &name, const String &difficulty, const String &personality, const String &team, const String &member);
void FillServer (int selection, int personality = PERSONALITY_NORMAL, int difficulty = -1, int numToAdd = -1);
void RemoveAll (bool zeroQuota = true);
@ -1635,7 +1634,7 @@ extern bool TryFileOpen (const char *fileName);
extern bool IsDedicatedServer (void);
extern bool IsVisible (const Vector &origin, edict_t *ent);
extern bool IsAlive (edict_t *ent);
extern bool IsInViewCone (Vector origin, edict_t *ent);
extern bool IsInViewCone (const Vector &origin, edict_t *ent);
extern int GetWeaponPenetrationPower (int id);
extern bool IsValidBot (edict_t *ent);
extern bool IsValidPlayer (edict_t *ent);
@ -1665,7 +1664,6 @@ extern void ServerPrint (const char *format, ...);
extern void ChartPrint (const char *format, ...);
extern void CenterPrint (const char *format, ...);
extern void ClientPrint (edict_t *ent, int dest, const char *format, ...);
extern void HudMessage (edict_t *ent, bool toCenter, Vector rgb, char *format, ...);
extern void AddLogEntry (bool outputToConsole, int logLevel, const char *format, ...);
extern void TraceLine (const Vector &start, const Vector &end, bool ignoreMonsters, bool ignoreGlass, edict_t *ignoreEntity, TraceResult *ptr);

View file

@ -212,10 +212,10 @@ namespace Math
{
fld dword ptr[rad]
fsincos
mov edx, dword ptr[cos]
mov eax, dword ptr[sin]
fstp dword ptr[edx]
fstp dword ptr[eax]
mov ebx, [cos]
fstp dword ptr[ebx]
mov ebx, [sin]
fstp dword ptr[ebx]
}
#elif defined (__linux__) || defined (GCC) || defined (__APPLE__)
register double _cos, _sin;
@ -369,15 +369,6 @@ public:
return &x;
}
inline float &operator [] (int index)
{
return (&x)[index];
}
inline const float &operator [] (int index) const
{
return (&x)[index];
}
inline const Vector operator + (const Vector &right) const
{
@ -410,11 +401,13 @@ public:
return Vector (inv * x, inv * y, inv * z);
}
// cross product
inline const Vector operator ^ (const Vector &right) const
{
return Vector (y * right.z - z * right.y, z * right.x - x * right.z, x * right.y - y * right.x);
}
// dot product
inline float operator | (const Vector &right) const
{
return x * right.x + y * right.y + z * right.z;
@ -545,14 +538,14 @@ public:
}
//
// Function: SkipZ
// Function: Get2D
//
// Gets vector without Z axis.
//
// Returns:
// 2D vector from 3D vector.
//
inline Vector SkipZ (void) const
inline Vector Get2D (void) const
{
return Vector (x, y, 0.0f);
}
@ -708,7 +701,7 @@ public:
{
float sinePitch = 0.0f, cosinePitch = 0.0f, sineYaw = 0.0f, cosineYaw = 0.0f, sineRoll = 0.0f, cosineRoll = 0.0f;
Math::SineCosine (Math::DegreeToRadian (x), &sinePitch, &cosinePitch); // compute the sine and cosine of the pitch component
Math::SineCosine (Math::DegreeToRadian (x), &sinePitch, &cosinePitch); // compute the sine and cosine of the pitch component
Math::SineCosine (Math::DegreeToRadian (y), &sineYaw, &cosineYaw); // compute the sine and cosine of the yaw component
Math::SineCosine (Math::DegreeToRadian (z), &sineRoll, &cosineRoll); // compute the sine and cosine of the roll component
@ -2473,7 +2466,7 @@ public:
// Returns:
// Integer value of string.
//
int ToInt (void)
int ToInt (void) const
{
return atoi (m_bufferPtr);
}

View file

@ -348,7 +348,7 @@ typedef struct
void (*pfnSetupVisibility) (struct edict_s *pViewEntity, struct edict_s *client, unsigned char **pvs, unsigned char **pas);
void (*pfnUpdateClientData) (const struct edict_s *ent, int sendweapons, struct clientdata_s *cd);
int (*pfnAddToFullPack) (struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet);
void (*pfnCreateBaseline) (int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs);
void (*pfnCreateBaseline) (int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, float* player_mins, float* player_maxs);
void (*pfnRegisterEncoders) (void);
int (*pfnGetWeaponData) (struct edict_s *player, struct weapon_data_s *info);

View file

@ -13,15 +13,15 @@
#define PRODUCT_NAME "Yet Another POD-Bot"
#define PRODUCT_VERSION "2.7"
#define PRODUCT_AUTHOR "YaPB Dev Team"
#define PRODUCT_URL "http://yapb.ru/"
#define PRODUCT_URL "http://yapb.jeefo.net"
#define PRODUCT_EMAIL "dmitry@jeefo.net"
#define PRODUCT_LOGTAG "YAPB"
#define PRODUCT_DESCRIPTION PRODUCT_NAME " v" PRODUCT_VERSION " - The Counter-Strike Bot"
#define PRODUCT_COPYRIGHT "Copyright © 2015, by " PRODUCT_AUTHOR
#define PRODUCT_COPYRIGHT "Copyright © 2003-2015, by " PRODUCT_AUTHOR
#define PRODUCT_LEGAL "Half-Life, Counter-Strike, Counter-Strike: Condition Zero, Steam, Valve is a trademark of Valve Corporation"
#define PRODUCT_ORIGINAL_NAME "yapb.dll"
#define PRODUCT_INTERNAL_NAME "podbot"
#define PRODUCT_VERSION_DWORD 2,7,0,0 // major version, minor version, WIP (or Update) version
#define PRODUCT_VERSION_DWORD 2,7,0,0
#define PRODUCT_SUPPORT_VERSION "1.0 - CZ"
#define PRODUCT_COMMENTS "http://github.com/jeefo/yapb/"
#define PRODUCT_DATE __DATE__