tweaked a little weapon firing code
fixed chatter icon not disappearing set bots correct walk speeds implemented some sse2 stuff update linux & android makefiles
This commit is contained in:
parent
2eec5839bd
commit
c07065ca9d
15 changed files with 268 additions and 221 deletions
|
|
@ -17,16 +17,12 @@
|
|||
|
||||
using namespace Math;
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <float.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <corelib.h>
|
||||
|
||||
// defines bots tasks
|
||||
enum TaskID
|
||||
{
|
||||
|
|
@ -71,7 +67,7 @@ enum GameFlags
|
|||
// bot menu ids
|
||||
enum MenuId
|
||||
{
|
||||
BOT_MENU_IVALID = -1,
|
||||
BOT_MENU_INVALID = 0,
|
||||
BOT_MENU_MAIN,
|
||||
BOT_MENU_FEATURES,
|
||||
BOT_MENU_CONTROL,
|
||||
|
|
@ -655,8 +651,6 @@ struct Client
|
|||
|
||||
int iconFlags[MAX_ENGINE_PLAYERS]; // flag holding chatter icons
|
||||
float iconTimestamp[MAX_ENGINE_PLAYERS]; // timers for chatter icons
|
||||
|
||||
Client (void) : menu (BOT_MENU_IVALID) { }
|
||||
};
|
||||
|
||||
// experience data hold in memory while playing
|
||||
|
|
@ -1076,7 +1070,7 @@ private:
|
|||
float GetBombTimeleft (void);
|
||||
float GetEstimatedReachTime (void);
|
||||
|
||||
int GetAimingWaypoint (void);
|
||||
int GetCampAimingWaypoint (void);
|
||||
int GetAimingWaypoint (const Vector &to);
|
||||
|
||||
void FindShortestPath (int srcIndex, int destIndex);
|
||||
|
|
@ -1214,6 +1208,9 @@ public:
|
|||
/// the things that can be executed while skipping frames
|
||||
void ThinkFrame (void);
|
||||
|
||||
void GotBlind (int alpha);
|
||||
void GetDamage (edict_t *inflictor, int damage, int armor, int bits);
|
||||
|
||||
void DisplayDebugOverlay (void);
|
||||
void NewRound (void);
|
||||
void EquipInBuyzone (int buyState);
|
||||
|
|
@ -1226,19 +1223,16 @@ public:
|
|||
void DeleteSearchNodes (void);
|
||||
void VerifyBreakable (edict_t *touch);
|
||||
|
||||
void RemoveCertainTask (TaskID id);
|
||||
void PushTask (TaskID id, float desire, int data, float time, bool canContinue);
|
||||
|
||||
void RemoveCertainTask (TaskID id);
|
||||
void ApplyTaskFilters (void);
|
||||
void ResetTasks (void);
|
||||
|
||||
TaskItem *GetTask (void);
|
||||
inline TaskID GetTaskId (void) { return GetTask ()->id; };
|
||||
|
||||
void TakeDamage (edict_t *inflictor, int damage, int armor, int bits);
|
||||
void TakeBlinded (int r, int g, int b, int alpha);
|
||||
|
||||
void DiscardWeaponForUser (edict_t *user, bool discardC4);
|
||||
void ReleaseUsedName (void);
|
||||
|
||||
void SayText (const char *text);
|
||||
void TeamSayText (const char *text);
|
||||
|
|
@ -1266,8 +1260,6 @@ public:
|
|||
bool HasSecondaryWeapon(void);
|
||||
bool HasShield (void);
|
||||
bool IsShieldDrawn (void);
|
||||
|
||||
void ReleaseUsedName (void);
|
||||
};
|
||||
|
||||
// manager class
|
||||
|
|
|
|||
|
|
@ -21,12 +21,19 @@
|
|||
#include <math.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <platform.h>
|
||||
|
||||
#ifdef PLATFORM_WIN32
|
||||
#include <direct.h>
|
||||
#else
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_SSE_INTRINSICS
|
||||
#include <xmmintrin.h>
|
||||
#include <emmintrin.h>
|
||||
#endif
|
||||
|
||||
//
|
||||
// Basic Types
|
||||
//
|
||||
|
|
@ -69,7 +76,7 @@ static inline char *A_strdup (const char *str)
|
|||
// From metamod-p
|
||||
static inline bool A_IsValidCodePointer (const void *ptr)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#ifdef PLATFORM_WIN32
|
||||
if (IsBadCodePtr (reinterpret_cast <FARPROC> (ptr)))
|
||||
return false;
|
||||
#endif
|
||||
|
|
@ -80,6 +87,11 @@ static inline bool A_IsValidCodePointer (const void *ptr)
|
|||
return true;
|
||||
}
|
||||
|
||||
#ifndef PLATFORM_WIN32
|
||||
#define _unlink(p) unlink (p)
|
||||
#define _mkdir(p) mkdir (p, 0777)
|
||||
#endif
|
||||
|
||||
//
|
||||
// Title: Utility Classes Header
|
||||
//
|
||||
|
|
@ -135,6 +147,106 @@ namespace Math
|
|||
const float MATH_D2R = MATH_PI / 180.0f;
|
||||
const float MATH_R2D = 180.0f / MATH_PI;
|
||||
|
||||
#ifdef ENABLE_SSE_INTRINSICS
|
||||
//
|
||||
// Function: mm_abs
|
||||
//
|
||||
// mm version if abs
|
||||
//
|
||||
static inline __m128 mm_abs (__m128 val)
|
||||
{
|
||||
return _mm_andnot_ps (_mm_castsi128_ps (_mm_set1_epi32 (0x80000000)), val);
|
||||
};
|
||||
|
||||
//
|
||||
// Function: mm_sine
|
||||
//
|
||||
// mm version if sine
|
||||
//
|
||||
static inline __m128 mm_sine (__m128 inp)
|
||||
{
|
||||
__m128 pi2 = _mm_set1_ps (MATH_PI * 2);
|
||||
__m128 val = _mm_cmpnlt_ps (inp, _mm_set1_ps (MATH_PI));
|
||||
|
||||
val = _mm_and_ps (val, pi2);
|
||||
inp = _mm_sub_ps (inp, val);
|
||||
val = _mm_cmpngt_ps (inp, _mm_set1_ps (-MATH_PI));
|
||||
val = _mm_and_ps (val, pi2);
|
||||
inp = _mm_add_ps (inp, val);
|
||||
val = _mm_mul_ps (mm_abs (inp), _mm_set1_ps (-4.0f / (MATH_PI * MATH_PI)));
|
||||
val = _mm_add_ps (val, _mm_set1_ps (4.0f / MATH_PI));
|
||||
|
||||
__m128 res = _mm_mul_ps (val, inp);
|
||||
|
||||
val = _mm_mul_ps (mm_abs (res), res);
|
||||
val = _mm_sub_ps (val, res);
|
||||
val = _mm_mul_ps (val, _mm_set1_ps (0.225f));
|
||||
res = _mm_add_ps (val, res);
|
||||
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
//
|
||||
// Function: A_sqrtf
|
||||
//
|
||||
// SIMD version of sqrtf.
|
||||
//
|
||||
static inline float A_sqrtf (float value)
|
||||
{
|
||||
#ifdef ENABLE_SSE_INTRINSICS
|
||||
return _mm_cvtss_f32 (_mm_sqrt_ss (_mm_load_ss (&value)));
|
||||
#else
|
||||
return sqrtf (value);
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// Function: A_sinf
|
||||
//
|
||||
// SIMD version of sinf.
|
||||
//
|
||||
static inline float A_sinf (float value)
|
||||
{
|
||||
#ifdef ENABLE_SSE_INTRINSICS
|
||||
return _mm_cvtss_f32 (mm_sine (_mm_set1_ps (value)));
|
||||
#else
|
||||
return sinf (value);
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// Function: A_cosf
|
||||
//
|
||||
// SIMD version of cosf.
|
||||
//
|
||||
static inline float A_cosf (float value)
|
||||
{
|
||||
#ifdef ENABLE_SSE_INTRINSICS
|
||||
return _mm_cvtss_f32 (mm_sine (_mm_set1_ps (value + MATH_PI / 2.0f)));
|
||||
#else
|
||||
return cosf (value);
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// Function: A_sincosf
|
||||
//
|
||||
// SIMD version of sincosf.
|
||||
//
|
||||
static inline void A_sincosf (float rad, float *sine, float *cosine)
|
||||
{
|
||||
#ifdef ENABLE_SSE_INTRINSICS
|
||||
__m128 m_sincos = mm_sine (_mm_set_ps (0.0f, 0.0f, rad + MATH_PI / 2.f, rad));
|
||||
__m128 m_cos = _mm_shuffle_ps (m_sincos, m_sincos, _MM_SHUFFLE (0, 0, 0, 1));
|
||||
|
||||
*sine = _mm_cvtss_f32 (m_sincos);
|
||||
*cosine = _mm_cvtss_f32 (m_cos);
|
||||
#else
|
||||
*sine = sinf (rad);
|
||||
*cosine = cosf (rad);
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// Function: FltZero
|
||||
//
|
||||
|
|
@ -262,28 +374,11 @@ namespace Math
|
|||
//
|
||||
static inline void SineCosine (float rad, float *sine, float *cosine)
|
||||
{
|
||||
#if defined (_WIN32) && defined (_MSC_VER) && !defined (__clang__)
|
||||
__asm
|
||||
{
|
||||
fld dword ptr[rad]
|
||||
fsincos
|
||||
mov ebx, [cosine]
|
||||
fstp dword ptr[ebx]
|
||||
mov ebx, [sine]
|
||||
fstp dword ptr[ebx]
|
||||
}
|
||||
#elif defined (__ANDROID__)
|
||||
#if defined (__ANDROID__)
|
||||
*sine = sinf (rad);
|
||||
*cosine = cosf (rad);
|
||||
#elif defined (__linux__) || defined (GCC) || defined (__APPLE__)
|
||||
double _cos, _sin;
|
||||
__asm __volatile__ ("fsincos" : "=t" (_cos), "=u" (_sin) : "0" (rad));
|
||||
|
||||
*cosine = _cos;
|
||||
*sine = _sin;
|
||||
#else
|
||||
*sine = sinf (rad);
|
||||
*cosine = cosf (rad);
|
||||
A_sincosf (rad, sine, cosine);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -294,7 +389,7 @@ namespace Math
|
|||
|
||||
template <typename Type> Type Clamp (Type x, Type a, Type b)
|
||||
{
|
||||
return x < a ? a : (x > b ? b : x);
|
||||
return (x < a) ? a : ((x > b) ? b : x);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -549,7 +644,7 @@ public:
|
|||
//
|
||||
inline float GetLength (void) const
|
||||
{
|
||||
return sqrtf (x * x + y * y + z * z);
|
||||
return Math::A_sqrtf (x * x + y * y + z * z);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
@ -565,7 +660,7 @@ public:
|
|||
//
|
||||
inline float GetLength2D (void) const
|
||||
{
|
||||
return sqrtf (x * x + y * y);
|
||||
return Math::A_sqrtf (x * x + y * y);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
@ -3693,19 +3788,11 @@ public:
|
|||
{
|
||||
// create the directory
|
||||
*ofs = 0;
|
||||
#ifdef _WIN32
|
||||
_mkdir (path);
|
||||
#else
|
||||
mkdir (path, 0777);
|
||||
#endif
|
||||
*ofs = '/';
|
||||
}
|
||||
}
|
||||
#ifdef _WIN32
|
||||
_mkdir (path);
|
||||
#else
|
||||
mkdir (path, 0777);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -8,21 +8,13 @@
|
|||
#ifndef META_API_H
|
||||
#define META_API_H
|
||||
|
||||
|
||||
typedef int (*GameAPI_t) (gamefuncs_t *, int);
|
||||
typedef int (*GameAPI2_t) (gamefuncs_t *, int *);
|
||||
typedef int (*NewAPI2_t) (gamefuncs_t *, int *);
|
||||
typedef int (*EngineAPI_t) (enginefuncs_t *, int *);
|
||||
|
||||
typedef int (*GETENTITYAPI_FN) (gamefuncs_t *pFunctionTable, int interfaceVersion);
|
||||
typedef int (*GETENTITYAPI2_FN) (gamefuncs_t *pFunctionTable, int *interfaceVersion);
|
||||
typedef int (*GETNEWDLLFUNCTIONS_FN) (newgamefuncs_t *pFunctionTable, int *interfaceVersion);
|
||||
typedef int (*GET_ENGINE_FUNCTIONS_FN) (enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion);
|
||||
|
||||
|
||||
#define META_INTERFACE_VERSION "5:13"
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PT_NEVER = 0,
|
||||
|
|
@ -107,7 +99,6 @@ typedef struct
|
|||
|
||||
#include "util.h"
|
||||
|
||||
|
||||
// max buffer size for printed messages
|
||||
#define MAX_LOGMSG_LEN 1024
|
||||
|
||||
|
|
@ -157,7 +148,6 @@ extern mutil_funcs_t *gpMetaUtilFuncs;
|
|||
extern meta_globals_t *gpMetaGlobals;
|
||||
extern metamod_funcs_t gMetaFunctionTable;
|
||||
|
||||
|
||||
#define MDLL_FUNC gpGamedllFuncs->dllapi_table
|
||||
|
||||
#define MDLL_GameDLLInit MDLL_FUNC->pfnGameInit
|
||||
|
|
@ -238,6 +228,5 @@ extern metamod_funcs_t gMetaFunctionTable;
|
|||
#define IS_QUERYING_CLIENT_CVAR (*gpMetaUtilFuncs->pfnIsQueryingClienCVar_t)
|
||||
#define MAKE_REQUESTID (*gpMetaUtilFuncs->pfnMakeRequestID)
|
||||
#define GET_HOOK_TABLES (*gpMetaUtilFuncs->pfnGetHookTables)
|
||||
uint16 FixedUnsigned16 (float fValue, float fScale);
|
||||
short FixedSigned16 (float fValue, float fScale);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -34,20 +34,25 @@
|
|||
#error "Can't configure export macros. Compiler unrecognized."
|
||||
#endif
|
||||
|
||||
// enable sse intrinsics
|
||||
#define ENABLE_SSE_INTRINSICS 1
|
||||
|
||||
// operating system specific macros, functions and typedefs
|
||||
#ifdef PLATFORM_WIN32
|
||||
|
||||
#include <direct.h>
|
||||
#include <string.h>
|
||||
|
||||
#define DLL_ENTRYPOINT int __stdcall DllMain (HINSTANCE, DWORD dwReason, LPVOID)
|
||||
#define STD_CALL __stdcall
|
||||
|
||||
#define DLL_ENTRYPOINT int STD_CALL DllMain (HINSTANCE, DWORD dwReason, LPVOID)
|
||||
#define DLL_DETACHING (dwReason == DLL_PROCESS_DETACH)
|
||||
#define DLL_RETENTRY return TRUE
|
||||
|
||||
#if defined (COMPILER_VISUALC)
|
||||
#define DLL_GIVEFNPTRSTODLL extern "C" void __stdcall
|
||||
#define DLL_GIVEFNPTRSTODLL extern "C" void STD_CALL
|
||||
#elif defined (COMPILER_MINGW32)
|
||||
#define DLL_GIVEFNPTRSTODLL SHARED_LIBRARAY_EXPORT void __stdcall
|
||||
#define DLL_GIVEFNPTRSTODLL SHARED_LIBRARAY_EXPORT void STD_CALL
|
||||
#endif
|
||||
|
||||
// specify export parameter
|
||||
|
|
@ -56,12 +61,6 @@
|
|||
#pragma comment (linker, "/SECTION:.data,RW")
|
||||
#endif
|
||||
|
||||
typedef int (*GetEntityApi2_FN) (gamefuncs_t *, int);
|
||||
typedef int (*GetNewEntityApi_FN) (newgamefuncs_t *, int *);
|
||||
typedef int (*GetBlendingInterface_FN) (int, void **, void *, float (*)[3][4], float (*)[128][3][4]);
|
||||
typedef void (*Entity_FN) (entvars_t *);
|
||||
typedef void (__stdcall *GiveFnptrsToDll_FN) (enginefuncs_t *, globalvars_t *);
|
||||
|
||||
#elif defined (PLATFORM_LINUX) || defined (PLATFORM_OSX)
|
||||
|
||||
#include <unistd.h>
|
||||
|
|
@ -81,18 +80,12 @@
|
|||
#define DLL_RETENTRY return
|
||||
#define DLL_GIVEFNPTRSTODLL extern "C" void __attribute__((visibility("default")))
|
||||
|
||||
#define STD_CALL /* */
|
||||
|
||||
#if defined (__ANDROID__)
|
||||
#define PLATFORM_ANDROID 1
|
||||
#undef ENABLE_SSE_INTRINSICS
|
||||
#endif
|
||||
|
||||
typedef int (*GetEntityApi2_FN) (gamefuncs_t *, int);
|
||||
typedef int (*GetNewEntityApi_FN) (newgamefuncs_t *, int *);
|
||||
typedef int (*GetBlendingInterface_FN) (int, void **, void *, float (*)[3][4], float (*)[128][3][4]);
|
||||
typedef void (*Entity_FN) (entvars_t *);
|
||||
typedef void (*GiveFnptrsToDll_FN) (enginefuncs_t *, globalvars_t *);
|
||||
|
||||
// posix compatibility
|
||||
#define _unlink unlink
|
||||
#else
|
||||
#error "Platform unrecognized."
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue