mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2025-02-05 18:20:33 +03:00
Minor refactoring qstring.h
This commit is contained in:
parent
536fc2da57
commit
3635adc587
@ -36,7 +36,7 @@ void CItemAirBox::Spawn()
|
|||||||
|
|
||||||
pev->movetype = MOVETYPE_NOCLIP;
|
pev->movetype = MOVETYPE_NOCLIP;
|
||||||
|
|
||||||
if (!m_iszSpriteName.IsEmpty())
|
if (!m_iszSpriteName.IsNull())
|
||||||
{
|
{
|
||||||
m_pSprite = CSprite::SpriteCreate(m_iszSpriteName, pev->origin, FALSE);
|
m_pSprite = CSprite::SpriteCreate(m_iszSpriteName, pev->origin, FALSE);
|
||||||
m_pSprite->SetTransparency(m_rendermode, m_rendercolor.x, m_rendercolor.y, m_rendercolor.z, m_renderamt, m_renderfx);
|
m_pSprite->SetTransparency(m_rendermode, m_rendercolor.x, m_rendercolor.y, m_rendercolor.z, m_renderamt, m_renderfx);
|
||||||
@ -75,7 +75,7 @@ void CItemAirBox::Precache()
|
|||||||
{
|
{
|
||||||
CArmoury::Precache();
|
CArmoury::Precache();
|
||||||
|
|
||||||
if (!m_iszSpriteName.IsEmpty()) {
|
if (!m_iszSpriteName.IsNull()) {
|
||||||
PRECACHE_MODEL(m_iszSpriteName);
|
PRECACHE_MODEL(m_iszSpriteName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
class CItemAirBox: public CArmoury {
|
class CItemAirBox: public CArmoury {
|
||||||
public:
|
public:
|
||||||
void Spawn();
|
void Spawn();
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#include "precompiled.h"
|
#include "precompiled.h"
|
||||||
|
|
||||||
#define SF_SETORIGIN_CONST_UPDATE BIT(0) // The entity will constantly update position if set
|
#define SF_SETORIGIN_CONST_UPDATE BIT(0) // The entity will constantly update position if set
|
||||||
|
@ -1447,7 +1447,7 @@ void CBaseEntity::SUB_FadeOut()
|
|||||||
|
|
||||||
void OnFreeEntPrivateData(edict_t *pEnt)
|
void OnFreeEntPrivateData(edict_t *pEnt)
|
||||||
{
|
{
|
||||||
CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pEnt);
|
CBaseEntity *pEntity = GET_PRIVATE<CBaseEntity>(pEnt);
|
||||||
if (!pEntity)
|
if (!pEntity)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -950,7 +950,6 @@ void packPlayerItem(CBasePlayer *pPlayer, CBasePlayerItem *pItem, bool packAmmo)
|
|||||||
bool CanSeeUseable(CBasePlayer *me, CBaseEntity *entity);
|
bool CanSeeUseable(CBasePlayer *me, CBaseEntity *entity);
|
||||||
void FixPlayerCrouchStuck(edict_t *pPlayer);
|
void FixPlayerCrouchStuck(edict_t *pPlayer);
|
||||||
BOOL IsSpawnPointValid(CBaseEntity *pPlayer, CBaseEntity *pSpot);
|
BOOL IsSpawnPointValid(CBaseEntity *pPlayer, CBaseEntity *pSpot);
|
||||||
CBaseEntity *FindZombieSpawn(CBaseEntity *player, bool forceSpawn);
|
|
||||||
CBaseEntity *FindEntityForward(CBaseEntity *pMe);
|
CBaseEntity *FindEntityForward(CBaseEntity *pMe);
|
||||||
float_precision GetPlayerPitch(const edict_t *pEdict);
|
float_precision GetPlayerPitch(const edict_t *pEdict);
|
||||||
float_precision GetPlayerYaw(const edict_t *pEdict);
|
float_precision GetPlayerYaw(const edict_t *pEdict);
|
||||||
|
@ -30,19 +30,25 @@
|
|||||||
|
|
||||||
#define QSTRING_DEFINE
|
#define QSTRING_DEFINE
|
||||||
|
|
||||||
constexpr auto iStringNull = 0u;
|
constexpr unsigned int iStringNull = {0};
|
||||||
|
|
||||||
// Quake string (helper class)
|
// Quake string (helper class)
|
||||||
template <typename T = unsigned int>
|
|
||||||
class QString final
|
class QString final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString(): m_string(iStringNull) {};
|
using qstring_t = unsigned int;
|
||||||
QString(T string): m_string(string) {};
|
|
||||||
|
|
||||||
bool IsEmpty() const;
|
QString(): m_string(iStringNull) {};
|
||||||
bool operator==(T string) const;
|
QString(qstring_t string): m_string(string) {};
|
||||||
bool operator==(const QString<T> &s) const;
|
|
||||||
|
bool IsNull() const;
|
||||||
|
bool IsNullOrEmpty() const;
|
||||||
|
|
||||||
|
// Copy the array
|
||||||
|
QString &operator=(const QString &other);
|
||||||
|
|
||||||
|
bool operator==(qstring_t string) const;
|
||||||
|
bool operator==(const QString &s) const;
|
||||||
bool operator==(const char *pszString) const;
|
bool operator==(const char *pszString) const;
|
||||||
|
|
||||||
operator const char *() const;
|
operator const char *() const;
|
||||||
@ -50,11 +56,11 @@ public:
|
|||||||
const char *str() const;
|
const char *str() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T m_string;
|
qstring_t m_string;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef USE_QSTRING
|
#ifdef USE_QSTRING
|
||||||
#define string_t QString<>
|
#define string_t QString
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
@ -68,44 +74,48 @@ extern globalvars_t *gpGlobals;
|
|||||||
#define MAKE_STRING(str) ((unsigned int)(str) - (unsigned int)(STRING(0)))
|
#define MAKE_STRING(str) ((unsigned int)(str) - (unsigned int)(STRING(0)))
|
||||||
|
|
||||||
// Inlines
|
// Inlines
|
||||||
template <typename T>
|
inline bool QString::IsNull() const
|
||||||
inline bool QString<T>::IsEmpty() const
|
|
||||||
{
|
{
|
||||||
return m_string == iStringNull;
|
return m_string == iStringNull;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
inline bool QString::IsNullOrEmpty() const
|
||||||
inline bool QString<T>::operator==(T string) const
|
{
|
||||||
|
return IsNull() || (&gpGlobals->pStringBase[m_string])[0] == '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QString &QString::operator=(const QString &other)
|
||||||
|
{
|
||||||
|
m_string = other.m_string;
|
||||||
|
return (*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool QString::operator==(qstring_t string) const
|
||||||
{
|
{
|
||||||
return m_string == string;
|
return m_string == string;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
inline bool QString::operator==(const QString &s) const
|
||||||
inline bool QString<T>::operator==(const QString<T> &s) const
|
|
||||||
{
|
{
|
||||||
return m_string == s.m_string;
|
return m_string == s.m_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
inline bool QString::operator==(const char *pszString) const
|
||||||
inline bool QString<T>::operator==(const char *pszString) const
|
|
||||||
{
|
{
|
||||||
return FStrEq(&gpGlobals->pStringBase[m_string], pszString);
|
return Q_strcmp(&gpGlobals->pStringBase[m_string], pszString) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
inline const char *QString::str() const
|
||||||
inline const char *QString<T>::str() const
|
|
||||||
{
|
{
|
||||||
return &gpGlobals->pStringBase[m_string];
|
return &gpGlobals->pStringBase[m_string];
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
inline QString::operator const char *() const
|
||||||
inline QString<T>::operator const char *() const
|
|
||||||
{
|
{
|
||||||
return str();
|
return str();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
inline QString::operator unsigned int() const
|
||||||
inline QString<T>::operator unsigned int() const
|
|
||||||
{
|
{
|
||||||
return m_string;
|
return m_string;
|
||||||
}
|
}
|
||||||
|
@ -1547,20 +1547,14 @@ void UTIL_Remove(CBaseEntity *pEntity)
|
|||||||
if (!pEntity)
|
if (!pEntity)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if 0
|
#ifdef REGAMEDLL_FIXES
|
||||||
// TODO: Some safe checks.
|
if (pEntity->pev == VARS(eoNullEntity) || pEntity->IsPlayer() || (pEntity->pev->flags & FL_KILLME) == FL_KILLME)
|
||||||
if (pEntity == VARS(eoNullEntity))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (pEntity->IsPlayer())
|
|
||||||
{
|
|
||||||
pEntity->pev->health = 1.0f;
|
|
||||||
pEntity->TakeDamage(VARS(eoNullEntity), VARS(eoNullEntity), 9999, DMG_ALWAYSGIB);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pEntity->UpdateOnRemove();
|
pEntity->UpdateOnRemove();
|
||||||
|
|
||||||
|
pEntity->pev->solid = SOLID_NOT;
|
||||||
pEntity->pev->flags |= FL_KILLME;
|
pEntity->pev->flags |= FL_KILLME;
|
||||||
pEntity->pev->targetname = 0;
|
pEntity->pev->targetname = 0;
|
||||||
}
|
}
|
||||||
|
@ -38,36 +38,36 @@ public:
|
|||||||
Vector2D(const Vector2D &v) { *(int *)&x = *(int *)&v.x; *(int *)&y = *(int *)&v.y; }
|
Vector2D(const Vector2D &v) { *(int *)&x = *(int *)&v.x; *(int *)&y = *(int *)&v.y; }
|
||||||
|
|
||||||
// Operators
|
// Operators
|
||||||
inline decltype(auto) operator-() const { return Vector2D(-x, -y); }
|
decltype(auto) operator-() const { return Vector2D(-x, -y); }
|
||||||
inline bool operator==(const Vector2D &v) const { return x == v.x && y == v.y; }
|
bool operator==(const Vector2D &v) const { return x == v.x && y == v.y; }
|
||||||
inline bool operator!=(const Vector2D &v) const { return !(*this == v); }
|
bool operator!=(const Vector2D &v) const { return !(*this == v); }
|
||||||
|
|
||||||
inline decltype(auto) operator+(const Vector2D &v) const { return Vector2D(x + v.x, y + v.y); }
|
decltype(auto) operator+(const Vector2D &v) const { return Vector2D(x + v.x, y + v.y); }
|
||||||
inline decltype(auto) operator-(const Vector2D &v) const { return Vector2D(x - v.x, y - v.y); }
|
decltype(auto) operator-(const Vector2D &v) const { return Vector2D(x - v.x, y - v.y); }
|
||||||
inline decltype(auto) operator*(const Vector2D &v) const { return Vector2D(x * v.x, y * v.y); }
|
decltype(auto) operator*(const Vector2D &v) const { return Vector2D(x * v.x, y * v.y); }
|
||||||
inline decltype(auto) operator/(const Vector2D &v) const { return Vector2D(x / v.x, y / v.y); }
|
decltype(auto) operator/(const Vector2D &v) const { return Vector2D(x / v.x, y / v.y); }
|
||||||
|
|
||||||
inline decltype(auto) operator+=(const Vector2D &v) { return (*this = *this + v); }
|
decltype(auto) operator+=(const Vector2D &v) { return (*this = *this + v); }
|
||||||
inline decltype(auto) operator-=(const Vector2D &v) { return (*this = *this - v); }
|
decltype(auto) operator-=(const Vector2D &v) { return (*this = *this - v); }
|
||||||
inline decltype(auto) operator*=(const Vector2D &v) { return (*this = *this * v); }
|
decltype(auto) operator*=(const Vector2D &v) { return (*this = *this * v); }
|
||||||
inline decltype(auto) operator/=(const Vector2D &v) { return (*this = *this / v); }
|
decltype(auto) operator/=(const Vector2D &v) { return (*this = *this / v); }
|
||||||
|
|
||||||
inline decltype(auto) operator+(float fl) const { return Vector2D(x + fl, y + fl); }
|
decltype(auto) operator+(float fl) const { return Vector2D(x + fl, y + fl); }
|
||||||
inline decltype(auto) operator-(float fl) const { return Vector2D(x - fl, y - fl); }
|
decltype(auto) operator-(float fl) const { return Vector2D(x - fl, y - fl); }
|
||||||
|
|
||||||
// TODO: FIX ME!!
|
// TODO: FIX ME!!
|
||||||
#ifdef PLAY_GAMEDLL
|
#ifdef PLAY_GAMEDLL
|
||||||
inline decltype(auto) operator*(float fl) const { return Vector2D(vec_t(x * fl), vec_t(y * fl)); }
|
decltype(auto) operator*(float fl) const { return Vector2D(vec_t(x * fl), vec_t(y * fl)); }
|
||||||
inline decltype(auto) operator/(float fl) const { return Vector2D(vec_t(x / fl), vec_t(y / fl)); }
|
decltype(auto) operator/(float fl) const { return Vector2D(vec_t(x / fl), vec_t(y / fl)); }
|
||||||
#else
|
#else
|
||||||
inline decltype(auto) operator*(float fl) const { return Vector2D(x * fl, y * fl); }
|
decltype(auto) operator*(float fl) const { return Vector2D(x * fl, y * fl); }
|
||||||
inline decltype(auto) operator/(float fl) const { return Vector2D(x / fl, y / fl); }
|
decltype(auto) operator/(float fl) const { return Vector2D(x / fl, y / fl); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline decltype(auto) operator+=(float fl) { return (*this = *this + fl); }
|
decltype(auto) operator+=(float fl) { return (*this = *this + fl); }
|
||||||
inline decltype(auto) operator-=(float fl) { return (*this = *this - fl); }
|
decltype(auto) operator-=(float fl) { return (*this = *this - fl); }
|
||||||
inline decltype(auto) operator*=(float fl) { return (*this = *this * fl); }
|
decltype(auto) operator*=(float fl) { return (*this = *this * fl); }
|
||||||
inline decltype(auto) operator/=(float fl) { return (*this = *this / fl); }
|
decltype(auto) operator/=(float fl) { return (*this = *this / fl); }
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
inline void CopyToArray(float *rgfl) const { *(int *)&rgfl[0] = *(int *)&x; *(int *)&rgfl[1] = *(int *)&y; }
|
inline void CopyToArray(float *rgfl) const { *(int *)&rgfl[0] = *(int *)&x; *(int *)&rgfl[1] = *(int *)&y; }
|
||||||
@ -140,36 +140,36 @@ public:
|
|||||||
Vector(const float rgfl[3]) { *(int *)&x = *(int *)&rgfl[0]; *(int *)&y = *(int *)&rgfl[1]; *(int *)&z = *(int *)&rgfl[2]; }
|
Vector(const float rgfl[3]) { *(int *)&x = *(int *)&rgfl[0]; *(int *)&y = *(int *)&rgfl[1]; *(int *)&z = *(int *)&rgfl[2]; }
|
||||||
|
|
||||||
// Operators
|
// Operators
|
||||||
inline decltype(auto) operator-() const { return Vector(-x, -y, -z); }
|
decltype(auto) operator-() const { return Vector(-x, -y, -z); }
|
||||||
inline bool operator==(const Vector &v) const { return x == v.x && y == v.y && z == v.z; }
|
bool operator==(const Vector &v) const { return x == v.x && y == v.y && z == v.z; }
|
||||||
inline bool operator!=(const Vector &v) const { return !(*this == v); }
|
bool operator!=(const Vector &v) const { return !(*this == v); }
|
||||||
|
|
||||||
inline decltype(auto) operator+(const Vector &v) const { return Vector(x + v.x, y + v.y, z + v.z); }
|
decltype(auto) operator+(const Vector &v) const { return Vector(x + v.x, y + v.y, z + v.z); }
|
||||||
inline decltype(auto) operator-(const Vector &v) const { return Vector(x - v.x, y - v.y, z - v.z); }
|
decltype(auto) operator-(const Vector &v) const { return Vector(x - v.x, y - v.y, z - v.z); }
|
||||||
inline decltype(auto) operator*(const Vector &v) const { return Vector(x * v.x, y * v.y, z * v.z); }
|
decltype(auto) operator*(const Vector &v) const { return Vector(x * v.x, y * v.y, z * v.z); }
|
||||||
inline decltype(auto) operator/(const Vector &v) const { return Vector(x / v.x, y / v.y, z / v.z); }
|
decltype(auto) operator/(const Vector &v) const { return Vector(x / v.x, y / v.y, z / v.z); }
|
||||||
|
|
||||||
inline decltype(auto) operator+=(const Vector &v) { return (*this = *this + v); }
|
decltype(auto) operator+=(const Vector &v) { return (*this = *this + v); }
|
||||||
inline decltype(auto) operator-=(const Vector &v) { return (*this = *this - v); }
|
decltype(auto) operator-=(const Vector &v) { return (*this = *this - v); }
|
||||||
inline decltype(auto) operator*=(const Vector &v) { return (*this = *this * v); }
|
decltype(auto) operator*=(const Vector &v) { return (*this = *this * v); }
|
||||||
inline decltype(auto) operator/=(const Vector &v) { return (*this = *this / v); }
|
decltype(auto) operator/=(const Vector &v) { return (*this = *this / v); }
|
||||||
|
|
||||||
inline decltype(auto) operator+(float fl) const { return Vector(x + fl, y + fl, z + fl); }
|
decltype(auto) operator+(float fl) const { return Vector(x + fl, y + fl, z + fl); }
|
||||||
inline decltype(auto) operator-(float fl) const { return Vector(x - fl, y - fl, z - fl); }
|
decltype(auto) operator-(float fl) const { return Vector(x - fl, y - fl, z - fl); }
|
||||||
|
|
||||||
// TODO: FIX ME!!
|
// TODO: FIX ME!!
|
||||||
#ifdef PLAY_GAMEDLL
|
#ifdef PLAY_GAMEDLL
|
||||||
inline decltype(auto) operator*(float fl) const { return Vector(vec_t(x * fl), vec_t(y * fl), vec_t(z * fl)); }
|
decltype(auto) operator*(float fl) const { return Vector(vec_t(x * fl), vec_t(y * fl), vec_t(z * fl)); }
|
||||||
inline decltype(auto) operator/(float fl) const { return Vector(vec_t(x / fl), vec_t(y / fl), vec_t(z / fl)); }
|
decltype(auto) operator/(float fl) const { return Vector(vec_t(x / fl), vec_t(y / fl), vec_t(z / fl)); }
|
||||||
#else
|
#else
|
||||||
inline decltype(auto) operator*(float fl) const { return Vector(x * fl, y * fl, z * fl); }
|
decltype(auto) operator*(float fl) const { return Vector(x * fl, y * fl, z * fl); }
|
||||||
inline decltype(auto) operator/(float fl) const { return Vector(x / fl, y / fl, z / fl); }
|
decltype(auto) operator/(float fl) const { return Vector(x / fl, y / fl, z / fl); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline decltype(auto) operator+=(float fl) { return (*this = *this + fl); }
|
decltype(auto) operator+=(float fl) { return (*this = *this + fl); }
|
||||||
inline decltype(auto) operator-=(float fl) { return (*this = *this - fl); }
|
decltype(auto) operator-=(float fl) { return (*this = *this - fl); }
|
||||||
inline decltype(auto) operator*=(float fl) { return (*this = *this * fl); }
|
decltype(auto) operator*=(float fl) { return (*this = *this * fl); }
|
||||||
inline decltype(auto) operator/=(float fl) { return (*this = *this / fl); }
|
decltype(auto) operator/=(float fl) { return (*this = *this / fl); }
|
||||||
|
|
||||||
void CopyToArray(float *rgfl) const
|
void CopyToArray(float *rgfl) const
|
||||||
{
|
{
|
||||||
|
@ -118,7 +118,7 @@ enum NavRelativeDirType
|
|||||||
NUM_RELATIVE_DIRECTIONS
|
NUM_RELATIVE_DIRECTIONS
|
||||||
};
|
};
|
||||||
|
|
||||||
const double GenerationStepSize = 25.0; // (30) was 20, but bots can't fit always fit
|
const double GenerationStepSize = 25.0; // (30) was 20, but bots can't always fit
|
||||||
const float StepHeight = 18.0f; // if delta Z is greater than this, we have to jump to get up
|
const float StepHeight = 18.0f; // if delta Z is greater than this, we have to jump to get up
|
||||||
const float JumpHeight = 41.8f; // if delta Z is less than this, we can jump up on it
|
const float JumpHeight = 41.8f; // if delta Z is less than this, we can jump up on it
|
||||||
const float JumpCrouchHeight = 58.0f; // (48) if delta Z is less than or equal to this, we can jumpcrouch up on it
|
const float JumpCrouchHeight = 58.0f; // (48) if delta Z is less than or equal to this, we can jumpcrouch up on it
|
||||||
|
Loading…
x
Reference in New Issue
Block a user