mirror of
https://github.com/rehlds/rechecker.git
synced 2024-12-27 12:55:28 +03:00
Minor refactoring
This commit is contained in:
parent
bb2bb4453f
commit
d1d4c4766c
3
Makefile
3
Makefile
@ -7,8 +7,7 @@ OBJECTS = src/main.cpp src/meta_api.cpp src/dllapi.cpp src/cmdexec.cpp \
|
|||||||
src/sdk_util.cpp src/hookchains_impl.cpp src/rechecker_api_impl.cpp public/interface.cpp
|
src/sdk_util.cpp src/hookchains_impl.cpp src/rechecker_api_impl.cpp public/interface.cpp
|
||||||
|
|
||||||
LINK = -lm -ldl -static-intel -static-libgcc -no-intel-extensions -fno-exceptions
|
LINK = -lm -ldl -static-intel -static-libgcc -no-intel-extensions -fno-exceptions
|
||||||
|
OPT_FLAGS = -m32 -O3 -msse3 -fPIC -ipo -no-prec-div -fp-model fast=2 -funroll-loops -fomit-frame-pointer -fno-stack-protector
|
||||||
OPT_FLAGS = -O3 -msse3 -ipo -no-prec-div -fp-model fast=2 -funroll-loops -fomit-frame-pointer -fno-stack-protector
|
|
||||||
|
|
||||||
INCLUDE = -I. -Isrc -Icommon -Idlls -Iengine -Ipm_shared -Ipublic -Imetamod
|
INCLUDE = -I. -Isrc -Icommon -Idlls -Iengine -Ipm_shared -Ipublic -Imetamod
|
||||||
|
|
||||||
|
130
common/mathlib.h
130
common/mathlib.h
@ -26,19 +26,23 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MATHLIB_H
|
|
||||||
#define MATHLIB_H
|
|
||||||
#ifdef _WIN32
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#endif
|
|
||||||
|
#ifdef PLAY_GAMEDLL
|
||||||
|
|
||||||
|
// probably gamedll compiled with flag /fpmath:fasted,
|
||||||
|
// so we need to use type double, otherwise will be the test failed
|
||||||
|
|
||||||
|
typedef double float_precision;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
typedef float float_precision;
|
||||||
|
|
||||||
|
#endif // PLAY_GAMEDLL
|
||||||
|
|
||||||
typedef float vec_t;
|
typedef float vec_t;
|
||||||
|
|
||||||
#if !defined DID_VEC3_T_DEFINE && !defined vec3_t
|
|
||||||
#define DID_VEC3_T_DEFINE
|
|
||||||
typedef vec_t vec3_t[3];
|
typedef vec_t vec3_t[3];
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef vec_t vec4_t[4];
|
typedef vec_t vec4_t[4];
|
||||||
typedef int fixed16_t;
|
typedef int fixed16_t;
|
||||||
|
|
||||||
@ -65,35 +69,16 @@ typedef union DLONG_u
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline T min(T a, T b)
|
const T& min(const T& a, const T& b) { return (a < b) ? a : b; }
|
||||||
{
|
|
||||||
return (a < b) ? a : b;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline T max(T a, T b)
|
const T& max(const T& a, const T& b) { return (a > b) ? a : b; }
|
||||||
{
|
|
||||||
return (a < b) ? b : a;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline T clamp(T a, T min, T max)
|
const T& clamp(const T& a, const T& min, const T& max) { return (a > max) ? max : (a < min) ? min : a; }
|
||||||
{
|
|
||||||
return (a > max) ? max : (a < min) ? min : a;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
inline T bswap(T s)
|
|
||||||
{
|
|
||||||
switch (sizeof(T))
|
|
||||||
{
|
|
||||||
case 2: {auto res = __builtin_bswap16(*(uint16 *)&s); return *(T *)&res; }
|
|
||||||
case 4: {auto res = __builtin_bswap32(*(uint32 *)&s); return *(T *)&res; }
|
|
||||||
case 8: {auto res = __builtin_bswap64(*(uint64 *)&s); return *(T *)&res; }
|
|
||||||
default: return s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else // __cplusplus
|
#else // __cplusplus
|
||||||
|
|
||||||
#ifndef max
|
#ifndef max
|
||||||
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
||||||
#endif
|
#endif
|
||||||
@ -105,4 +90,83 @@ inline T bswap(T s)
|
|||||||
#define clamp(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val)))
|
#define clamp(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val)))
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
#endif // MATHLIB_H
|
// bitwise operators templates
|
||||||
|
//template<class T, class type=typename std::underlying_type<T>::type>
|
||||||
|
//inline T operator~ (T a) { return (T)~(type)a; }
|
||||||
|
//template<class T, class type=typename std::underlying_type<T>::type>
|
||||||
|
//inline T operator| (T a, T b) { return (T)((type)a | (type)b); }
|
||||||
|
//template<class T, class type=typename std::underlying_type<T>::type>
|
||||||
|
//inline T operator& (T a, T b) { return (T)((type)a & (type)b); }
|
||||||
|
//template<class T, class type=typename std::underlying_type<T>::type>
|
||||||
|
//inline T operator^ (T a, T b) { return (T)((type)a ^ (type)b); }
|
||||||
|
//template<class T, class type=typename std::underlying_type<T>::type>
|
||||||
|
//inline T& operator|= (T& a, T b) { return (T&)((type&)a |= (type)b); }
|
||||||
|
//template<class T, class type=typename std::underlying_type<T>::type>
|
||||||
|
//inline T& operator&= (T& a, T b) { return (T&)((type&)a &= (type)b); }
|
||||||
|
//template<class T, class type=typename std::underlying_type<T>::type>
|
||||||
|
//inline T& operator^= (T& a, T b) { return (T&)((type&)a ^= (type)b); }
|
||||||
|
|
||||||
|
inline float M_sqrt(float value) {
|
||||||
|
return _mm_cvtss_f32(_mm_sqrt_ss(_mm_load_ss(&value)));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline double M_sqrt(double value) {
|
||||||
|
auto v = _mm_load_sd(&value);
|
||||||
|
return _mm_cvtsd_f64(_mm_sqrt_sd(v, v));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline double M_sqrt(T value) {
|
||||||
|
return sqrt(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float M_min(float a, float b) {
|
||||||
|
return _mm_cvtss_f32(_mm_min_ss(_mm_load_ss(&a), _mm_load_ss(&b)));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline double M_min(double a, double b) {
|
||||||
|
return _mm_cvtsd_f64(_mm_min_sd(_mm_load_sd(&a), _mm_load_sd(&b)));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline T M_min(T a, T b) {
|
||||||
|
return min(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float M_max(float a, float b) {
|
||||||
|
return _mm_cvtss_f32(_mm_max_ss(_mm_load_ss(&a), _mm_load_ss(&b)));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline double M_max(double a, double b) {
|
||||||
|
return _mm_cvtsd_f64(_mm_max_sd(_mm_load_sd(&a), _mm_load_sd(&b)));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline T M_max(T a, T b) {
|
||||||
|
return max(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float M_clamp(float a, float min, float max) {
|
||||||
|
return _mm_cvtss_f32(_mm_min_ss(_mm_max_ss(_mm_load_ss(&a), _mm_load_ss(&min)), _mm_load_ss(&max)));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline double M_clamp(double a, double min, double max) {
|
||||||
|
return _mm_cvtsd_f64(_mm_min_sd(_mm_max_sd(_mm_load_sd(&a), _mm_load_sd(&min)), _mm_load_sd(&max)));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline T M_clamp(T a, T min, T max) {
|
||||||
|
return clamp(a, min, max);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline void SWAP(T &first, T &second) {
|
||||||
|
T temp = first;
|
||||||
|
first = second;
|
||||||
|
second = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define VectorSubtract(a,b,c) {(c)[0]=(a)[0]-(b)[0];(c)[1]=(a)[1]-(b)[1];(c)[2]=(a)[2]-(b)[2];}
|
||||||
|
#define VectorAdd(a,b,c) {(c)[0]=(a)[0]+(b)[0];(c)[1]=(a)[1]+(b)[1];(c)[2]=(a)[2]+(b)[2];}
|
||||||
|
#define VectorCopy(a,b) {(b)[0]=(a)[0];(b)[1]=(a)[1];(b)[2]=(a)[2];}
|
||||||
|
#define VectorClear(a) {(a)[0]=0.0;(a)[1]=0.0;(a)[2]=0.0;}
|
||||||
|
@ -25,21 +25,36 @@
|
|||||||
* version.
|
* version.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// 2DVector - used for many pathfinding and many other
|
// 2DVector - used for many pathfinding and many other
|
||||||
// operations that are treated as planar rather than 3d.
|
// operations that are treated as planar rather than 3d.
|
||||||
class Vector2D {
|
class Vector2D {
|
||||||
public:
|
public:
|
||||||
|
// Construction/destruction
|
||||||
inline Vector2D() : x(), y() {}
|
inline Vector2D() : x(), y() {}
|
||||||
inline Vector2D(float X, float Y) : x(X), y(Y) {}
|
inline Vector2D(float X, float Y) : x(X), y(Y) {}
|
||||||
inline Vector2D(const Vector2D &v) { *(int *)&x = *(int *)&v.x; *(int *)&y = *(int *)&v.y; }
|
inline Vector2D(const Vector2D &v) { *(int *)&x = *(int *)&v.x; *(int *)&y = *(int *)&v.y; }
|
||||||
inline Vector2D operator+(const Vector2D &v) const { return Vector2D(x + v.x, y + v.y); }
|
|
||||||
inline Vector2D operator-(const Vector2D &v) const { return Vector2D(x - v.x, y - v.y); }
|
// Operators
|
||||||
|
inline bool operator==(const Vector2D &v) const { return x == v.x && y == v.y; }
|
||||||
|
inline bool operator!=(const Vector2D &v) const { return !(*this == v); }
|
||||||
|
|
||||||
inline Vector2D operator*(float fl) const { return Vector2D(x * fl, y * fl); }
|
inline Vector2D operator*(float fl) const { return Vector2D(x * fl, y * fl); }
|
||||||
inline Vector2D operator/(float fl) const { return Vector2D(x / fl, y / fl); }
|
inline Vector2D operator/(float fl) const { return Vector2D(x / fl, y / fl); }
|
||||||
inline Vector2D operator/=(float fl) const { return Vector2D(x / fl, y / fl); }
|
inline Vector2D operator/=(float fl) const { return Vector2D(x / fl, y / fl); }
|
||||||
|
|
||||||
|
inline Vector2D operator+(const Vector2D &v) const { return Vector2D(x + v.x, y + v.y); }
|
||||||
|
inline Vector2D operator-(const Vector2D &v) const { return Vector2D(x - v.x, y - v.y); }
|
||||||
|
inline Vector2D operator*(const Vector2D &v) const { return Vector2D(x * v.x, y * v.y); }
|
||||||
|
inline Vector2D operator/(const Vector2D &v) const { return Vector2D(x / v.x, y / v.y); }
|
||||||
|
|
||||||
|
inline Vector2D operator+=(const Vector2D &v) const { return Vector2D(x + v.x, y + v.y); }
|
||||||
|
inline Vector2D operator-=(const Vector2D &v) const { return Vector2D(x - v.x, y - v.y); }
|
||||||
|
inline Vector2D operator*=(const Vector2D &v) const { return Vector2D(x * v.x, y * v.y); }
|
||||||
|
inline Vector2D operator/=(const Vector2D &v) const { return Vector2D(x / v.x, y / v.y); }
|
||||||
|
|
||||||
inline float Length() const { return sqrt(x * x + y * y); }
|
inline float Length() const { return sqrt(x * x + y * y); }
|
||||||
inline float LengthSquared() const { return (x * x + y * y); }
|
inline float LengthSquared() const { return (x * x + y * y); }
|
||||||
|
|
||||||
@ -98,14 +113,23 @@ public:
|
|||||||
|
|
||||||
// Operators
|
// Operators
|
||||||
inline Vector operator-() const { return Vector(-x, -y, -z); }
|
inline Vector operator-() const { return Vector(-x, -y, -z); }
|
||||||
inline int operator==(const Vector &v) const { return x == v.x && y == v.y && z == v.z; }
|
|
||||||
inline int operator!=(const Vector &v) const { return !(*this == v); }
|
|
||||||
inline Vector operator+(const Vector &v) const { return Vector(x + v.x, y + v.y, z + v.z); }
|
|
||||||
inline Vector operator-(const Vector &v) const { return Vector(x - v.x, y - v.y, z - v.z); }
|
|
||||||
inline Vector operator*(float fl) const { return Vector(x * fl, y * fl, z * fl); }
|
inline Vector operator*(float fl) const { return Vector(x * fl, y * fl, z * fl); }
|
||||||
inline Vector operator/(float fl) const { return Vector(x / fl, y / fl, z / fl); }
|
inline Vector operator/(float fl) const { return Vector(x / fl, y / fl, z / fl); }
|
||||||
inline Vector operator/=(float fl) const { return Vector(x / fl, y / fl, z / fl); }
|
inline Vector operator/=(float fl) const { return Vector(x / fl, y / fl, z / fl); }
|
||||||
|
|
||||||
|
inline 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); }
|
||||||
|
|
||||||
|
inline Vector operator+(const Vector &v) const { return Vector(x + v.x, y + v.y, z + v.z); }
|
||||||
|
inline Vector operator-(const Vector &v) const { return Vector(x - v.x, y - v.y, z - v.z); }
|
||||||
|
inline Vector operator*(const Vector &v) const { return Vector(x * v.x, y * v.y, z * v.z); }
|
||||||
|
inline Vector operator/(const Vector &v) const { return Vector(x / v.x, y / v.y, z / v.z); }
|
||||||
|
|
||||||
|
inline Vector operator+=(const Vector &v) const { return Vector(x + v.x, y + v.y, z + v.z); }
|
||||||
|
inline Vector operator-=(const Vector &v) const { return Vector(x - v.x, y - v.y, z - v.z); }
|
||||||
|
inline Vector operator*=(const Vector &v) const { return Vector(x * v.x, y * v.y, z * v.z); }
|
||||||
|
inline Vector operator/=(const Vector &v) const { return Vector(x / v.x, y / v.y, z / v.z); }
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
inline void CopyToArray(float *rgfl) const { *(int *)&rgfl[0] = *(int *)&x; *(int *)&rgfl[1] = *(int *)&y; *(int *)&rgfl[2] = *(int *)&z; }
|
inline void CopyToArray(float *rgfl) const { *(int *)&rgfl[0] = *(int *)&x; *(int *)&rgfl[1] = *(int *)&y; *(int *)&rgfl[2] = *(int *)&z; }
|
||||||
inline float Length() const { return sqrt(x * x + y * y + z * z); }
|
inline float Length() const { return sqrt(x * x + y * y + z * z); }
|
||||||
@ -166,11 +190,3 @@ inline Vector operator*(float fl, const Vector &v) { return v * fl; }
|
|||||||
inline float DotProduct(const Vector &a, const Vector &b) { return (a.x * b.x + a.y * b.y + a.z * b.z); }
|
inline float DotProduct(const Vector &a, const Vector &b) { return (a.x * b.x + a.y * b.y + a.z * b.z); }
|
||||||
inline float DotProduct2D(const Vector &a, const Vector &b) { return (a.x * b.x + a.y * b.y); }
|
inline float DotProduct2D(const Vector &a, const Vector &b) { return (a.x * b.x + a.y * b.y); }
|
||||||
inline Vector CrossProduct(const Vector &a, const Vector &b) { return Vector(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x); }
|
inline Vector CrossProduct(const Vector &a, const Vector &b) { return Vector(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x); }
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline void SWAP(T &first, T &second)
|
|
||||||
{
|
|
||||||
T temp = first;
|
|
||||||
first = second;
|
|
||||||
second = temp;
|
|
||||||
}
|
|
||||||
|
@ -1,9 +1,30 @@
|
|||||||
//========= Copyright 1996-2001, Valve LLC, All rights reserved. ============
|
/*
|
||||||
//
|
*
|
||||||
// Purpose:
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
//
|
* under the terms of the GNU General Public License as published by the
|
||||||
// $NoKeywords: $
|
* Free Software Foundation; either version 2 of the License, or (at
|
||||||
//=============================================================================
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
* In addition, as a special exception, the author gives permission to
|
||||||
|
* link the code of this program with the Half-Life Game Engine ("HL
|
||||||
|
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
|
||||||
|
* L.L.C ("Valve"). You must obey the GNU General Public License in all
|
||||||
|
* respects for all of the code used other than the HL Engine and MODs
|
||||||
|
* from Valve. If you modify this file, you may extend this exception
|
||||||
|
* to your version of the file, but you are not obligated to do so. If
|
||||||
|
* you do not wish to do so, delete this exception statement from your
|
||||||
|
* version.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef BASETYPES_H
|
#ifndef BASETYPES_H
|
||||||
#define BASETYPES_H
|
#define BASETYPES_H
|
||||||
@ -12,9 +33,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "osconfig.h"
|
#include "osconfig.h"
|
||||||
#include "protected_things.h"
|
|
||||||
#include "commonmacros.h"
|
#include "commonmacros.h"
|
||||||
|
|
||||||
|
#include "mathlib.h"
|
||||||
|
|
||||||
// For backward compatibilty only...
|
// For backward compatibilty only...
|
||||||
#include "tier0/platform.h"
|
#include "tier0/platform.h"
|
||||||
@ -24,45 +45,16 @@
|
|||||||
#define NULL 0
|
#define NULL 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define ExecuteNTimes( nTimes, x ) \
|
|
||||||
{ \
|
|
||||||
static int __executeCount=0;\
|
|
||||||
if ( __executeCount < nTimes )\
|
|
||||||
{ \
|
|
||||||
x; \
|
|
||||||
++__executeCount; \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#define ExecuteOnce( x ) ExecuteNTimes( 1, x )
|
|
||||||
|
|
||||||
|
|
||||||
// Pad a number so it lies on an N byte boundary.
|
// Pad a number so it lies on an N byte boundary.
|
||||||
// So PAD_NUMBER(0,4) is 0 and PAD_NUMBER(1,4) is 4
|
// So PAD_NUMBER(0,4) is 0 and PAD_NUMBER(1,4) is 4
|
||||||
#define PAD_NUMBER(number, boundary) \
|
#define PAD_NUMBER(number, boundary) \
|
||||||
(((number) + ((boundary) - 1)) / (boundary)) * (boundary)
|
(((number) + ((boundary) - 1)) / (boundary)) * (boundary)
|
||||||
|
|
||||||
#ifndef MATHLIB_H
|
|
||||||
// In case this ever changes
|
|
||||||
#define M_PI 3.14159265358979323846
|
|
||||||
|
|
||||||
#ifndef min
|
|
||||||
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef max
|
|
||||||
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
|
||||||
#endif
|
|
||||||
#endif // MATHLIB_H
|
|
||||||
|
|
||||||
#ifndef FALSE
|
#ifndef FALSE
|
||||||
#define FALSE 0
|
#define FALSE 0
|
||||||
#define TRUE (!FALSE)
|
#define TRUE (!FALSE)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
typedef int BOOL;
|
typedef int BOOL;
|
||||||
typedef int qboolean;
|
typedef int qboolean;
|
||||||
typedef unsigned long ULONG;
|
typedef unsigned long ULONG;
|
||||||
@ -72,216 +64,14 @@ typedef unsigned short word;
|
|||||||
|
|
||||||
typedef float vec_t;
|
typedef float vec_t;
|
||||||
|
|
||||||
|
|
||||||
// FIXME: this should move
|
|
||||||
#ifndef __cplusplus
|
|
||||||
#define true TRUE
|
|
||||||
#define false FALSE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// look for NANs, infinities, and underflows.
|
|
||||||
// This assumes the ANSI/IEEE 754-1985 standard
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
|
|
||||||
inline unsigned long& FloatBits(vec_t& f)
|
|
||||||
{
|
|
||||||
return *reinterpret_cast<unsigned long*>(&f);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline unsigned long const& FloatBits(vec_t const& f)
|
|
||||||
{
|
|
||||||
return *reinterpret_cast<unsigned long const*>(&f);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline vec_t BitsToFloat(unsigned long i)
|
|
||||||
{
|
|
||||||
return *reinterpret_cast<vec_t*>(&i);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool IsFinite(vec_t f)
|
|
||||||
{
|
|
||||||
return ((FloatBits(f) & 0x7F800000) != 0x7F800000);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline unsigned long FloatAbsBits(vec_t f)
|
|
||||||
{
|
|
||||||
return FloatBits(f) & 0x7FFFFFFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline float FloatMakeNegative(vec_t f)
|
|
||||||
{
|
|
||||||
return BitsToFloat(FloatBits(f) | 0x80000000);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined( WIN32 )
|
|
||||||
|
|
||||||
//#include <math.h>
|
|
||||||
// Just use prototype from math.h
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
double __cdecl fabs(double);
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// In win32 try to use the intrinsic fabs so the optimizer can do it's thing inline in the code
|
|
||||||
#pragma intrinsic( fabs )
|
|
||||||
// Also, alias float make positive to use fabs, too
|
|
||||||
// NOTE: Is there a perf issue with double<->float conversion?
|
|
||||||
inline float FloatMakePositive(vec_t f)
|
|
||||||
{
|
|
||||||
return fabs(f);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
inline float FloatMakePositive(vec_t f)
|
|
||||||
{
|
|
||||||
return BitsToFloat(FloatBits(f) & 0x7FFFFFFF);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
inline float FloatNegate(vec_t f)
|
|
||||||
{
|
|
||||||
return BitsToFloat(FloatBits(f) ^ 0x80000000);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#define FLOAT32_NAN_BITS (unsigned long)0x7FC00000 // not a number!
|
|
||||||
#define FLOAT32_NAN BitsToFloat( FLOAT32_NAN_BITS )
|
|
||||||
|
|
||||||
#define VEC_T_NAN FLOAT32_NAN
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// FIXME: why are these here? Hardly anyone actually needs them.
|
|
||||||
struct valve_color24
|
|
||||||
{
|
|
||||||
byte r, g, b;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct valve_color32_s
|
|
||||||
{
|
|
||||||
bool operator!=(const struct valve_color32_s &other) const;
|
|
||||||
|
|
||||||
byte r, g, b, a;
|
|
||||||
} valve_color32;
|
|
||||||
|
|
||||||
inline bool valve_color32::operator!=(const valve_color32 &other) const
|
|
||||||
{
|
|
||||||
return r != other.r || g != other.g || b != other.b || a != other.a;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct valve_colorRGBExp32
|
|
||||||
{
|
|
||||||
byte r, g, b;
|
|
||||||
signed char exponent;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct valve_colorVec
|
|
||||||
{
|
|
||||||
unsigned r, g, b, a;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef UNUSED
|
#ifndef UNUSED
|
||||||
#define UNUSED(x) (x = x) // for pesky compiler / lint warnings
|
#define UNUSED(x) (x = x) // for pesky compiler / lint warnings
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
|
|
||||||
struct vrect_t
|
struct vrect_t
|
||||||
{
|
{
|
||||||
int x, y, width, height;
|
int x, y, width, height;
|
||||||
vrect_t *pnext;
|
vrect_t *pnext;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// MaterialRect_t struct - used for DrawDebugText
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
struct Rect_t
|
|
||||||
{
|
|
||||||
int x, y;
|
|
||||||
int width, height;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Declares a type-safe handle type; you can't assign one handle to the next
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// 32-bit pointer handles.
|
|
||||||
|
|
||||||
// Typesafe 8-bit and 16-bit handles.
|
|
||||||
template< class HandleType >
|
|
||||||
class CBaseIntHandle
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
inline bool operator==(const CBaseIntHandle &other) { return m_Handle == other.m_Handle; }
|
|
||||||
inline bool operator!=(const CBaseIntHandle &other) { return m_Handle != other.m_Handle; }
|
|
||||||
|
|
||||||
// Only the code that doles out these handles should use these functions.
|
|
||||||
// Everyone else should treat them as a transparent type.
|
|
||||||
inline HandleType GetHandleValue() { return m_Handle; }
|
|
||||||
inline void SetHandleValue(HandleType val) { m_Handle = val; }
|
|
||||||
|
|
||||||
typedef HandleType HANDLE_TYPE;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
HandleType m_Handle;
|
|
||||||
};
|
|
||||||
|
|
||||||
template< class DummyType >
|
|
||||||
class CIntHandle16 : public CBaseIntHandle < unsigned short >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
inline CIntHandle16() {}
|
|
||||||
|
|
||||||
static inline CIntHandle16<DummyType> MakeHandle(HANDLE_TYPE val)
|
|
||||||
{
|
|
||||||
return CIntHandle16<DummyType>(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
inline CIntHandle16(HANDLE_TYPE val)
|
|
||||||
{
|
|
||||||
m_Handle = val;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
template< class DummyType >
|
|
||||||
class CIntHandle32 : public CBaseIntHandle < unsigned long >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
inline CIntHandle32() {}
|
|
||||||
|
|
||||||
static inline CIntHandle32<DummyType> MakeHandle(HANDLE_TYPE val)
|
|
||||||
{
|
|
||||||
return CIntHandle32<DummyType>(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
inline CIntHandle32(HANDLE_TYPE val)
|
|
||||||
{
|
|
||||||
m_Handle = val;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// NOTE: This macro is the same as windows uses; so don't change the guts of it
|
|
||||||
#define DECLARE_HANDLE_16BIT(name) typedef CIntHandle16< struct name##__handle * > name;
|
|
||||||
#define DECLARE_HANDLE_32BIT(name) typedef CIntHandle32< struct name##__handle * > name;
|
|
||||||
|
|
||||||
#define DECLARE_POINTER_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
|
|
||||||
#define FORWARD_DECLARE_HANDLE(name) typedef struct name##__ *name
|
|
||||||
|
|
||||||
#endif // BASETYPES_H
|
#endif // BASETYPES_H
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "interface.h"
|
#include "precompiled.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
@ -87,9 +87,9 @@ public:
|
|||||||
EXPOSE_SINGLE_INTERFACE_GLOBALVAR(className, interfaceName, versionName, __g_##className##_singleton)
|
EXPOSE_SINGLE_INTERFACE_GLOBALVAR(className, interfaceName, versionName, __g_##className##_singleton)
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define EXPORT_FUNCTION __declspec(dllexport)
|
#define EXPORT_FUNCTION __declspec(dllexport) EXT_FUNC
|
||||||
#else
|
#else
|
||||||
#define EXPORT_FUNCTION __attribute__((visibility("default")))
|
#define EXPORT_FUNCTION __attribute__((visibility("default"))) EXT_FUNC
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
|
|
||||||
// This function is automatically exported and allows you to access any interfaces exposed with the above macros.
|
// This function is automatically exported and allows you to access any interfaces exposed with the above macros.
|
||||||
|
211
public/strtools.h
Normal file
211
public/strtools.h
Normal file
@ -0,0 +1,211 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
* In addition, as a special exception, the author gives permission to
|
||||||
|
* link the code of this program with the Half-Life Game Engine ("HL
|
||||||
|
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
|
||||||
|
* L.L.C ("Valve"). You must obey the GNU General Public License in all
|
||||||
|
* respects for all of the code used other than the HL Engine and MODs
|
||||||
|
* from Valve. If you modify this file, you may extend this exception
|
||||||
|
* to your version of the file, but you are not obligated to do so. If
|
||||||
|
* you do not wish to do so, delete this exception statement from your
|
||||||
|
* version.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
const char CORRECT_PATH_SEPARATOR = '\\';
|
||||||
|
const char INCORRECT_PATH_SEPARATOR = '/';
|
||||||
|
#else
|
||||||
|
const char CORRECT_PATH_SEPARATOR = '/';
|
||||||
|
const char INCORRECT_PATH_SEPARATOR = '\\';
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(_WIN32)
|
||||||
|
inline char *_strupr(char *start)
|
||||||
|
{
|
||||||
|
char *str = start;
|
||||||
|
while (str && *str)
|
||||||
|
{
|
||||||
|
*str = (char)toupper(*str);
|
||||||
|
str++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return start;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline char *_strlwr(char *start)
|
||||||
|
{
|
||||||
|
char *str = start;
|
||||||
|
while (str && *str)
|
||||||
|
{
|
||||||
|
*str = (char)tolower(*str);
|
||||||
|
str++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return start;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ASMLIB_H) && defined(HAVE_OPT_STRTOOLS)
|
||||||
|
#define Q_memset A_memset
|
||||||
|
#define Q_memcpy A_memcpy
|
||||||
|
#define Q_memcmp A_memcmp
|
||||||
|
#define Q_memmove A_memmove
|
||||||
|
#define Q_strlen A_strlen
|
||||||
|
#define Q_strcpy A_strcpy
|
||||||
|
#define Q_strncpy strncpy
|
||||||
|
#define Q_strcat A_strcat
|
||||||
|
#define Q_strncat strncat
|
||||||
|
#define Q_strcmp A_strcmp
|
||||||
|
#define Q_strncmp strncmp
|
||||||
|
#define Q_strdup _strdup
|
||||||
|
#define Q_stricmp A_stricmp
|
||||||
|
#define Q_strnicmp _strnicmp
|
||||||
|
#define Q_strstr A_strstr
|
||||||
|
#define Q_strchr strchr
|
||||||
|
#define Q_strrchr strrchr
|
||||||
|
#define Q_strlwr A_strtolower
|
||||||
|
#define Q_strupr A_strtoupper
|
||||||
|
#define Q_sprintf sprintf
|
||||||
|
#define Q_snprintf _snprintf
|
||||||
|
#define Q_vsnprintf _vsnprintf
|
||||||
|
#define Q_vsnwprintf _vsnwprintf
|
||||||
|
#define Q_atoi atoi
|
||||||
|
#define Q_atof atof
|
||||||
|
#define Q_sqrt M_sqrt
|
||||||
|
#define Q_min M_min
|
||||||
|
#define Q_max M_max
|
||||||
|
#define Q_clamp M_clamp
|
||||||
|
#define Q_abs abs
|
||||||
|
#define Q_fabs fabs
|
||||||
|
#define Q_tan tan
|
||||||
|
#define Q_atan atan
|
||||||
|
#define Q_atan2 atan2
|
||||||
|
#define Q_acos acos
|
||||||
|
#define Q_cos cos
|
||||||
|
#define Q_sin sin
|
||||||
|
#define Q_pow pow
|
||||||
|
#define Q_fmod fmod
|
||||||
|
#else
|
||||||
|
#define Q_memset memset
|
||||||
|
#define Q_memcpy memcpy
|
||||||
|
#define Q_memcmp memcmp
|
||||||
|
#define Q_memmove memmove
|
||||||
|
#define Q_strlen strlen
|
||||||
|
#define Q_strcpy strcpy
|
||||||
|
#define Q_strncpy strncpy
|
||||||
|
#define Q_strcat strcat
|
||||||
|
#define Q_strncat strncat
|
||||||
|
#define Q_strcmp strcmp
|
||||||
|
#define Q_strncmp strncmp
|
||||||
|
#define Q_strdup _strdup
|
||||||
|
#define Q_stricmp _stricmp
|
||||||
|
#define Q_strnicmp _strnicmp
|
||||||
|
#define Q_strstr strstr
|
||||||
|
#define Q_strchr strchr
|
||||||
|
#define Q_strrchr strrchr
|
||||||
|
#define Q_strlwr _strlwr
|
||||||
|
#define Q_strupr _strupr
|
||||||
|
#define Q_sprintf sprintf
|
||||||
|
#define Q_snprintf _snprintf
|
||||||
|
#define Q_vsnprintf _vsnprintf
|
||||||
|
#define Q_vsnwprintf _vsnwprintf
|
||||||
|
#define Q_atoi atoi
|
||||||
|
#define Q_atof atof
|
||||||
|
#define Q_sqrt sqrt
|
||||||
|
#define Q_min min
|
||||||
|
#define Q_max max
|
||||||
|
#define Q_clamp clamp
|
||||||
|
#define Q_abs abs
|
||||||
|
#define Q_fabs fabs
|
||||||
|
#define Q_tan tan
|
||||||
|
#define Q_atan atan
|
||||||
|
#define Q_atan2 atan2
|
||||||
|
#define Q_acos acos
|
||||||
|
#define Q_cos cos
|
||||||
|
#define Q_sin sin
|
||||||
|
#define Q_pow pow
|
||||||
|
#define Q_fmod fmod
|
||||||
|
#endif // #if defined(ASMLIB_H) && defined(HAVE_OPT_STRTOOLS)
|
||||||
|
|
||||||
|
// a safe variant of strcpy that truncates the result to fit in the destination buffer
|
||||||
|
template <size_t size>
|
||||||
|
char *Q_strlcpy(char (&dest)[size], const char *src) {
|
||||||
|
Q_strncpy(dest, src, size - 1);
|
||||||
|
dest[size - 1] = '\0';
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline char *Q_strnlcpy(char *dest, const char *src, size_t n) {
|
||||||
|
Q_strncpy(dest, src, n - 1);
|
||||||
|
dest[n - 1] = '\0';
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
// safely concatenate two strings.
|
||||||
|
// a variant of strcat that truncates the result to fit in the destination buffer
|
||||||
|
template <size_t size>
|
||||||
|
size_t Q_strlcat(char (&dest)[size], const char *src)
|
||||||
|
{
|
||||||
|
size_t srclen; // Length of source string
|
||||||
|
size_t dstlen; // Length of destination string
|
||||||
|
|
||||||
|
// Figure out how much room is left
|
||||||
|
dstlen = Q_strlen(dest);
|
||||||
|
size_t length = size - dstlen + 1;
|
||||||
|
|
||||||
|
if (!length) {
|
||||||
|
// No room, return immediately
|
||||||
|
return dstlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Figure out how much room is needed
|
||||||
|
srclen = Q_strlen(src);
|
||||||
|
|
||||||
|
// Copy the appropriate amount
|
||||||
|
if (srclen > length) {
|
||||||
|
srclen = length;
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_memcpy(dest + dstlen, src, srclen);
|
||||||
|
dest[dstlen + srclen] = '\0';
|
||||||
|
|
||||||
|
return dstlen + srclen;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Force slashes of either type to be = separator character
|
||||||
|
inline void Q_FixSlashes(char *pname, char separator = CORRECT_PATH_SEPARATOR)
|
||||||
|
{
|
||||||
|
while (*pname)
|
||||||
|
{
|
||||||
|
if (*pname == INCORRECT_PATH_SEPARATOR || *pname == CORRECT_PATH_SEPARATOR)
|
||||||
|
{
|
||||||
|
*pname = separator;
|
||||||
|
}
|
||||||
|
|
||||||
|
pname++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// strcpy that works correctly with overlapping src and dst buffers
|
||||||
|
inline char *Q_strcpy_s(char *dst, char *src) {
|
||||||
|
int len = Q_strlen(src);
|
||||||
|
Q_memmove(dst, src, len + 1);
|
||||||
|
return dst;
|
||||||
|
}
|
@ -19,9 +19,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "osconfig.h"
|
|
||||||
#include "basetypes.h"
|
#include "basetypes.h"
|
||||||
#include "tier0/platform.h"
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
//========= Copyright © 1996-2001, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose: Memory allocation!
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#ifndef TIER0_MEM_H
|
|
||||||
#define TIER0_MEM_H
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#pragma once
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "osconfig.h"
|
|
||||||
#include <stddef.h>
|
|
||||||
#include "tier0/platform.h"
|
|
||||||
|
|
||||||
#ifdef TIER0_DLL_EXPORT
|
|
||||||
# define MEM_INTERFACE DLL_EXPORT
|
|
||||||
#else
|
|
||||||
# define MEM_INTERFACE DLL_IMPORT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// DLL-exported methods for particular kinds of memory
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
MEM_INTERFACE void *MemAllocScratch(int nMemSize);
|
|
||||||
MEM_INTERFACE void MemFreeScratch();
|
|
||||||
|
|
||||||
#ifdef __linux__
|
|
||||||
MEM_INTERFACE void ZeroMemory(void *mem, size_t length);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* TIER0_MEM_H */
|
|
@ -1,77 +0,0 @@
|
|||||||
//========= Copyright © 1996-2001, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose: This header should never be used directly from leaf code!!!
|
|
||||||
// Instead, just add the file memoverride.cpp into your project and all this
|
|
||||||
// will automagically be used
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#ifndef TIER0_MEMALLOC_H
|
|
||||||
#define TIER0_MEMALLOC_H
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#pragma once
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "osconfig.h"
|
|
||||||
#include <stddef.h>
|
|
||||||
#include "tier0/mem.h"
|
|
||||||
|
|
||||||
struct _CrtMemState;
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// NOTE! This should never be called directly from leaf code
|
|
||||||
// Just use new,delete,malloc,free etc. They will call into this eventually
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
class IMemAlloc
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// Release versions
|
|
||||||
virtual void *Alloc(size_t nSize) = 0;
|
|
||||||
virtual void *Realloc(void *pMem, size_t nSize) = 0;
|
|
||||||
virtual void Free(void *pMem) = 0;
|
|
||||||
virtual void *Expand(void *pMem, size_t nSize) = 0;
|
|
||||||
|
|
||||||
// Debug versions
|
|
||||||
virtual void *Alloc(size_t nSize, const char *pFileName, int nLine) = 0;
|
|
||||||
virtual void *Realloc(void *pMem, size_t nSize, const char *pFileName, int nLine) = 0;
|
|
||||||
virtual void Free(void *pMem, const char *pFileName, int nLine) = 0;
|
|
||||||
virtual void *Expand(void *pMem, size_t nSize, const char *pFileName, int nLine) = 0;
|
|
||||||
|
|
||||||
// Returns size of a particular allocation
|
|
||||||
virtual size_t GetSize(void *pMem) = 0;
|
|
||||||
|
|
||||||
// Force file + line information for an allocation
|
|
||||||
virtual void PushAllocDbgInfo(const char *pFileName, int nLine) = 0;
|
|
||||||
virtual void PopAllocDbgInfo() = 0;
|
|
||||||
|
|
||||||
// FIXME: Remove when we have our own allocator
|
|
||||||
// these methods of the Crt debug code is used in our codebase currently
|
|
||||||
virtual long CrtSetBreakAlloc(long lNewBreakAlloc) = 0;
|
|
||||||
virtual int CrtSetReportMode(int nReportType, int nReportMode) = 0;
|
|
||||||
virtual int CrtIsValidHeapPointer(const void *pMem) = 0;
|
|
||||||
virtual int CrtCheckMemory(void) = 0;
|
|
||||||
virtual int CrtSetDbgFlag(int nNewFlag) = 0;
|
|
||||||
virtual void CrtMemCheckpoint(_CrtMemState *pState) = 0;
|
|
||||||
|
|
||||||
// FIXME: Make a better stats interface
|
|
||||||
virtual void DumpStats() = 0;
|
|
||||||
|
|
||||||
// FIXME: Remove when we have our own allocator
|
|
||||||
virtual void* CrtSetReportFile(int nRptType, void* hFile) = 0;
|
|
||||||
virtual void* CrtSetReportHook(void* pfnNewHook) = 0;
|
|
||||||
virtual int CrtDbgReport(int nRptType, const char * szFile,
|
|
||||||
int nLine, const char * szModule, const char * pMsg) = 0;
|
|
||||||
|
|
||||||
virtual int heapchk() = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Singleton interface
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
IMemAlloc *g_pMemAlloc;
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* TIER0_MEMALLOC_H */
|
|
@ -1,21 +0,0 @@
|
|||||||
//========= Copyright © 1996-2003, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose: This header, which must be the final line of a .h file,
|
|
||||||
// causes all crt methods to stop using debugging versions of the memory allocators.
|
|
||||||
// NOTE: Use memdbgon.h to re-enable memory debugging.
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#ifdef MEM_DEBUG_ON
|
|
||||||
|
|
||||||
#undef malloc
|
|
||||||
#undef realloc
|
|
||||||
#undef calloc
|
|
||||||
#undef free
|
|
||||||
#undef _expand
|
|
||||||
#undef _msize
|
|
||||||
#undef new
|
|
||||||
#undef MEM_DEBUG_ON
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,93 +0,0 @@
|
|||||||
//========= Copyright © 1996-2003, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose: This header, which must be the final include in a .cpp (or .h) file,
|
|
||||||
// causes all crt methods to use debugging versions of the memory allocators.
|
|
||||||
// NOTE: Use memdbgoff.h to disable memory debugging.
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
// SPECIAL NOTE! This file must *not* use include guards; we need to be able
|
|
||||||
// to include this potentially multiple times (since we can deactivate debugging
|
|
||||||
// by including memdbgoff.h)
|
|
||||||
|
|
||||||
// SPECIAL NOTE #2: This must be the final include in a .cpp or .h file!!!
|
|
||||||
#include "osconfig.h"
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
|
||||||
|
|
||||||
#include <tchar.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <crtdbg.h>
|
|
||||||
|
|
||||||
#include "tier0/memdbgoff.h"
|
|
||||||
|
|
||||||
#define MEM_DEBUG_ON 1
|
|
||||||
|
|
||||||
#undef malloc
|
|
||||||
#undef realloc
|
|
||||||
#undef calloc
|
|
||||||
#undef _expand
|
|
||||||
#undef free
|
|
||||||
#undef _msize
|
|
||||||
|
|
||||||
#define malloc(s) _malloc_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)
|
|
||||||
#define calloc(c, s) _calloc_dbg(c, s, _NORMAL_BLOCK, __FILE__, __LINE__)
|
|
||||||
#define realloc(p, s) _realloc_dbg(p, s, _NORMAL_BLOCK, __FILE__, __LINE__)
|
|
||||||
#define free(p) _free_dbg(p, _NORMAL_BLOCK)
|
|
||||||
#define _msize(p) _msize_dbg(p, _NORMAL_BLOCK)
|
|
||||||
#define _expand(p, s) _expand_dbg(p, s, _NORMAL_BLOCK, __FILE__, __LINE__)
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(__AFX_H__) && defined(DEBUG_NEW)
|
|
||||||
#define new DEBUG_NEW
|
|
||||||
#else
|
|
||||||
#undef new
|
|
||||||
#define MEMALL_DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
|
|
||||||
#define new MEMALL_DEBUG_NEW
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#undef _strdup
|
|
||||||
#undef strdup
|
|
||||||
#undef _wcsdup
|
|
||||||
#undef wcsup
|
|
||||||
|
|
||||||
#define _strdup(s) strdup_dbg(s, __FILE__, __LINE__)
|
|
||||||
#define strdup(s) strdup_dbg(s, __FILE__, __LINE__)
|
|
||||||
#define _wcsdup(s) wcsdup_dbg(s, __FILE__, __LINE__)
|
|
||||||
#define wcsdup(s) wcsdup_dbg(s, __FILE__, __LINE__)
|
|
||||||
|
|
||||||
// Make sure we don't define strdup twice
|
|
||||||
#ifndef MEM_DBG_DEFINED_STRDUP
|
|
||||||
#define MEM_DBG_DEFINED_STRDUP 1
|
|
||||||
|
|
||||||
inline char *strdup_dbg(const char *pString, const char *pFileName, unsigned nLine)
|
|
||||||
{
|
|
||||||
char *pMemory;
|
|
||||||
|
|
||||||
if (!pString)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if ((pMemory = (char *)_malloc_dbg(strlen(pString) + 1, _NORMAL_BLOCK, pFileName, nLine)) != NULL)
|
|
||||||
return strcpy(pMemory, pString);
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline wchar_t *wcsdup_dbg(const wchar_t *pString, const char *pFileName, unsigned nLine)
|
|
||||||
{
|
|
||||||
wchar_t *pMemory;
|
|
||||||
|
|
||||||
if (!pString)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if ((pMemory = (wchar_t *)_malloc_dbg((wcslen(pString) + 1) * sizeof(wchar_t), _NORMAL_BLOCK, pFileName, nLine)) != NULL)
|
|
||||||
return wcscpy(pMemory, pString);
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // DBMEM_DEFINED_STRDUP
|
|
||||||
|
|
||||||
#endif // _DEBUG
|
|
@ -1,102 +1,40 @@
|
|||||||
//=========== (C) Copyright 1999 Valve, L.L.C. All rights reserved. ===========
|
/*
|
||||||
//
|
*
|
||||||
// The copyright to the contents herein is the property of Valve, L.L.C.
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
// The contents may be used and/or copied only with the written permission of
|
* under the terms of the GNU General Public License as published by the
|
||||||
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
|
* Free Software Foundation; either version 2 of the License, or (at
|
||||||
// the agreement/contract under which the contents have been supplied.
|
* your option) any later version.
|
||||||
//
|
*
|
||||||
// $Header: $
|
* This program is distributed in the hope that it will be useful, but
|
||||||
// $NoKeywords: $
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
//
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// Extremely low-level platform-specific stuff
|
* General Public License for more details.
|
||||||
//=============================================================================
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
* In addition, as a special exception, the author gives permission to
|
||||||
|
* link the code of this program with the Half-Life Game Engine ("HL
|
||||||
|
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
|
||||||
|
* L.L.C ("Valve"). You must obey the GNU General Public License in all
|
||||||
|
* respects for all of the code used other than the HL Engine and MODs
|
||||||
|
* from Valve. If you modify this file, you may extend this exception
|
||||||
|
* to your version of the file, but you are not obligated to do so. If
|
||||||
|
* you do not wish to do so, delete this exception statement from your
|
||||||
|
* version.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef PLATFORM_H
|
|
||||||
#define PLATFORM_H
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "osconfig.h"
|
#include "osconfig.h"
|
||||||
|
|
||||||
// need this for _alloca
|
#include <malloc.h> // need this for _alloca
|
||||||
#include <malloc.h>
|
#include <string.h> // need this for memset
|
||||||
|
|
||||||
// need this for memset
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "archtypes.h"
|
#include "archtypes.h"
|
||||||
|
|
||||||
typedef float float32;
|
|
||||||
typedef double float64;
|
|
||||||
|
|
||||||
// for when we don't care about how many bits we use
|
|
||||||
typedef unsigned int uint;
|
|
||||||
|
|
||||||
// This can be used to ensure the size of pointers to members when declaring
|
|
||||||
// a pointer type for a class that has only been forward declared
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#define SINGLE_INHERITANCE __single_inheritance
|
|
||||||
#define MULTIPLE_INHERITANCE __multiple_inheritance
|
|
||||||
#else
|
|
||||||
#define SINGLE_INHERITANCE
|
|
||||||
#define MULTIPLE_INHERITANCE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
FIXME: Enable this when we no longer fear change =)
|
|
||||||
|
|
||||||
// need these for the limits
|
|
||||||
#include <limits.h>
|
|
||||||
#include <float.h>
|
|
||||||
|
|
||||||
// Maximum and minimum representable values
|
|
||||||
#define INT8_MAX SCHAR_MAX
|
|
||||||
#define INT16_MAX SHRT_MAX
|
|
||||||
#define INT32_MAX LONG_MAX
|
|
||||||
#define INT64_MAX (((int64)~0) >> 1)
|
|
||||||
|
|
||||||
#define INT8_MIN SCHAR_MIN
|
|
||||||
#define INT16_MIN SHRT_MIN
|
|
||||||
#define INT32_MIN LONG_MIN
|
|
||||||
#define INT64_MIN (((int64)1) << 63)
|
|
||||||
|
|
||||||
#define UINT8_MAX ((uint8)~0)
|
|
||||||
#define UINT16_MAX ((uint16)~0)
|
|
||||||
#define UINT32_MAX ((uint32)~0)
|
|
||||||
#define UINT64_MAX ((uint64)~0)
|
|
||||||
|
|
||||||
#define UINT8_MIN 0
|
|
||||||
#define UINT16_MIN 0
|
|
||||||
#define UINT32_MIN 0
|
|
||||||
#define UINT64_MIN 0
|
|
||||||
|
|
||||||
#ifndef UINT_MIN
|
|
||||||
#define UINT_MIN UINT32_MIN
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define FLOAT32_MAX FLT_MAX
|
|
||||||
#define FLOAT64_MAX DBL_MAX
|
|
||||||
|
|
||||||
#define FLOAT32_MIN FLT_MIN
|
|
||||||
#define FLOAT64_MIN DBL_MIN
|
|
||||||
*/
|
|
||||||
|
|
||||||
// portability / compiler settings
|
|
||||||
#if defined(_WIN32) && !defined(WINDED)
|
|
||||||
|
|
||||||
#if defined(_M_IX86)
|
|
||||||
#define __i386__ 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#elif __linux__
|
|
||||||
typedef void * HINSTANCE;
|
|
||||||
#define _MAX_PATH PATH_MAX
|
|
||||||
#endif // defined(_WIN32) && !defined(WINDED)
|
|
||||||
|
|
||||||
|
|
||||||
// Defines MAX_PATH
|
// Defines MAX_PATH
|
||||||
#ifndef MAX_PATH
|
#ifndef MAX_PATH
|
||||||
#define MAX_PATH 260
|
#define MAX_PATH 260
|
||||||
@ -108,18 +46,12 @@ typedef void * HINSTANCE;
|
|||||||
// C functions for external declarations that call the appropriate C++ methods
|
// C functions for external declarations that call the appropriate C++ methods
|
||||||
#ifndef EXPORT
|
#ifndef EXPORT
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define EXPORT _declspec( dllexport )
|
#define EXPORT __declspec(dllexport)
|
||||||
#else
|
#else
|
||||||
#define EXPORT /* */
|
#define EXPORT /* */
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined __i386__ && !defined __linux__
|
|
||||||
#define id386 1
|
|
||||||
#else
|
|
||||||
#define id386 0
|
|
||||||
#endif // __i386__
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// Used for dll exporting and importing
|
// Used for dll exporting and importing
|
||||||
#define DLL_EXPORT extern "C" __declspec(dllexport)
|
#define DLL_EXPORT extern "C" __declspec(dllexport)
|
||||||
@ -150,50 +82,6 @@ typedef void * HINSTANCE;
|
|||||||
#error "Unsupported Platform."
|
#error "Unsupported Platform."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Used for standard calling conventions
|
|
||||||
#ifdef _WIN32
|
|
||||||
#define FASTCALL __fastcall
|
|
||||||
#define FORCEINLINE __forceinline
|
|
||||||
#else
|
|
||||||
#define FASTCALL
|
|
||||||
#define FORCEINLINE inline
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Force a function call site -not- to inlined. (useful for profiling)
|
|
||||||
#define DONT_INLINE(a) (((int)(a)+1)?(a):(a))
|
|
||||||
|
|
||||||
// Pass hints to the compiler to prevent it from generating unnessecary / stupid code
|
|
||||||
// in certain situations. Several compilers other than MSVC also have an equivilent
|
|
||||||
// construct.
|
|
||||||
//
|
|
||||||
// Essentially the 'Hint' is that the condition specified is assumed to be true at
|
|
||||||
// that point in the compilation. If '0' is passed, then the compiler assumes that
|
|
||||||
// any subsequent code in the same 'basic block' is unreachable, and thus usually
|
|
||||||
// removed.
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#define HINT(THE_HINT) __assume((THE_HINT))
|
|
||||||
#else
|
|
||||||
#define HINT(THE_HINT) 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Marks the codepath from here until the next branch entry point as unreachable,
|
|
||||||
// and asserts if any attempt is made to execute it.
|
|
||||||
#define UNREACHABLE() { Assert(0); HINT(0); }
|
|
||||||
|
|
||||||
// In cases where no default is present or appropriate, this causes MSVC to generate
|
|
||||||
// as little code as possible, and throw an assertion in debug.
|
|
||||||
#define NO_DEFAULT default: UNREACHABLE();
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
// Alloca defined for this platform
|
|
||||||
#define stackalloc( _size ) _alloca( _size )
|
|
||||||
#define stackfree( _p ) 0
|
|
||||||
#elif __linux__
|
|
||||||
// Alloca defined for this platform
|
|
||||||
#define stackalloc( _size ) alloca( _size )
|
|
||||||
#define stackfree( _p ) 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// Remove warnings from warning level 4.
|
// Remove warnings from warning level 4.
|
||||||
#pragma warning(disable : 4514) // warning C4514: 'acosl' : unreferenced inline function has been removed
|
#pragma warning(disable : 4514) // warning C4514: 'acosl' : unreferenced inline function has been removed
|
||||||
@ -216,260 +104,8 @@ typedef void * HINSTANCE;
|
|||||||
#pragma warning(disable : 4511) // Disable warnings about private copy constructors
|
#pragma warning(disable : 4511) // Disable warnings about private copy constructors
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Standard functions for handling endian-ness
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
//-------------------------------------
|
|
||||||
// Basic swaps
|
|
||||||
//-------------------------------------
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
inline T WordSwapC(T w)
|
|
||||||
{
|
|
||||||
uint16 temp;
|
|
||||||
|
|
||||||
temp = ((*((uint16 *)&w) & 0xff00) >> 8);
|
|
||||||
temp |= ((*((uint16 *)&w) & 0x00ff) << 8);
|
|
||||||
|
|
||||||
return *((T*)&temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
inline T DWordSwapC(T dw)
|
|
||||||
{
|
|
||||||
uint32 temp;
|
|
||||||
|
|
||||||
temp = *((uint32 *)&dw) >> 24;
|
|
||||||
temp |= ((*((uint32 *)&dw) & 0x00FF0000) >> 8);
|
|
||||||
temp |= ((*((uint32 *)&dw) & 0x0000FF00) << 8);
|
|
||||||
temp |= ((*((uint32 *)&dw) & 0x000000FF) << 24);
|
|
||||||
|
|
||||||
return *((T*)&temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
//-------------------------------------
|
|
||||||
// Fast swaps
|
|
||||||
//-------------------------------------
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
|
|
||||||
#define WordSwap WordSwapAsm
|
|
||||||
#define DWordSwap DWordSwapAsm
|
|
||||||
|
|
||||||
#pragma warning(push)
|
|
||||||
#pragma warning (disable:4035) // no return value
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
inline T WordSwapAsm(T w)
|
|
||||||
{
|
|
||||||
__asm
|
|
||||||
{
|
|
||||||
mov ax, w
|
|
||||||
xchg al, ah
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
inline T DWordSwapAsm(T dw)
|
|
||||||
{
|
|
||||||
__asm
|
|
||||||
{
|
|
||||||
mov eax, dw
|
|
||||||
bswap eax
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma warning(pop)
|
|
||||||
|
|
||||||
// The assembly implementation is not compatible with floats
|
|
||||||
template <>
|
|
||||||
inline float DWordSwapAsm<float>(float f)
|
|
||||||
{
|
|
||||||
return DWordSwapC(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define WordSwap WordSwapC
|
|
||||||
#define DWordSwap DWordSwapC
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//-------------------------------------
|
|
||||||
// The typically used methods.
|
|
||||||
//-------------------------------------
|
|
||||||
|
|
||||||
#if defined(__i386__)
|
|
||||||
#define VALVE_LITTLE_ENDIAN 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _SGI_SOURCE
|
|
||||||
#define VALVE_BIG_ENDIAN 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(VALVE_LITTLE_ENDIAN)
|
|
||||||
|
|
||||||
#define Valve_BigShort( val ) WordSwap( val )
|
|
||||||
#define Valve_BigWord( val ) WordSwap( val )
|
|
||||||
#define Valve_BigLong( val ) DWordSwap( val )
|
|
||||||
#define Valve_BigDWord( val ) DWordSwap( val )
|
|
||||||
#define Valve_BigFloat( val ) DWordSwap( val )
|
|
||||||
#define Valve_LittleShort( val ) ( val )
|
|
||||||
#define Valve_LittleWord( val ) ( val )
|
|
||||||
#define Valve_LittleLong( val ) ( val )
|
|
||||||
#define Valve_LittleDWord( val ) ( val )
|
|
||||||
#define Valve_LittleFloat( val ) ( val )
|
|
||||||
|
|
||||||
#elif defined(BIG_ENDIAN)
|
|
||||||
|
|
||||||
#define Valve_BigShort( val ) ( val )
|
|
||||||
#define Valve_BigWord( val ) ( val )
|
|
||||||
#define Valve_BigLong( val ) ( val )
|
|
||||||
#define Valve_BigDWord( val ) ( val )
|
|
||||||
#define Valve_BigFloat( val ) ( val )
|
|
||||||
#define Valve_LittleShort( val ) WordSwap( val )
|
|
||||||
#define Valve_LittleWord( val ) WordSwap( val )
|
|
||||||
#define Valve_LittleLong( val ) DWordSwap( val )
|
|
||||||
#define Valve_LittleDWord( val ) DWordSwap( val )
|
|
||||||
#define Valve_LittleFloat( val ) DWordSwap( val )
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
// @Note (toml 05-02-02): this technique expects the compiler to
|
|
||||||
// optimize the expression and eliminate the other path. On any new
|
|
||||||
// platform/compiler this should be tested.
|
|
||||||
inline short BigShort(short val) { int test = 1; return (*(char *)&test == 1) ? WordSwap(val) : val; }
|
|
||||||
inline uint16 BigWord(uint16 val) { int test = 1; return (*(char *)&test == 1) ? WordSwap(val) : val; }
|
|
||||||
inline long BigLong(long val) { int test = 1; return (*(char *)&test == 1) ? DWordSwap(val) : val; }
|
|
||||||
inline uint32 BigDWord(uint32 val) { int test = 1; return (*(char *)&test == 1) ? DWordSwap(val) : val; }
|
|
||||||
inline float BigFloat(float val) { int test = 1; return (*(char *)&test == 1) ? DWordSwap(val) : val; }
|
|
||||||
inline short LittleShort(short val) { int test = 1; return (*(char *)&test == 1) ? val : WordSwap(val); }
|
|
||||||
inline uint16 LittleWord(uint16 val) { int test = 1; return (*(char *)&test == 1) ? val : WordSwap(val); }
|
|
||||||
inline long LittleLong(long val) { int test = 1; return (*(char *)&test == 1) ? val : DWordSwap(val); }
|
|
||||||
inline uint32 LittleDWord(uint32 val) { int test = 1; return (*(char *)&test == 1) ? val : DWordSwap(val); }
|
|
||||||
inline float LittleFloat(float val) { int test = 1; return (*(char *)&test == 1) ? val : DWordSwap(val); }
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef TIER0_DLL_EXPORT
|
|
||||||
#define PLATFORM_INTERFACE DLL_EXPORT
|
|
||||||
#define PLATFORM_OVERLOAD DLL_GLOBAL_EXPORT
|
|
||||||
#else
|
|
||||||
#define PLATFORM_INTERFACE DLL_IMPORT
|
|
||||||
#define PLATFORM_OVERLOAD DLL_GLOBAL_IMPORT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
PLATFORM_INTERFACE double Plat_FloatTime(); // Returns time in seconds since the module was loaded.
|
|
||||||
PLATFORM_INTERFACE unsigned long Plat_MSTime(); // Time in milliseconds.
|
|
||||||
|
|
||||||
// b/w compatibility
|
|
||||||
#define Sys_FloatTime Plat_FloatTime
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Processor Information:
|
|
||||||
struct CPUInformation
|
|
||||||
{
|
|
||||||
int m_Size; // Size of this structure, for forward compatability.
|
|
||||||
|
|
||||||
bool m_bRDTSC : 1, // Is RDTSC supported?
|
|
||||||
m_bCMOV : 1, // Is CMOV supported?
|
|
||||||
m_bFCMOV : 1, // Is FCMOV supported?
|
|
||||||
m_bSSE : 1, // Is SSE supported?
|
|
||||||
m_bSSE2 : 1, // Is SSE2 Supported?
|
|
||||||
m_b3DNow : 1, // Is 3DNow! Supported?
|
|
||||||
m_bMMX : 1, // Is MMX supported?
|
|
||||||
m_bHT : 1; // Is HyperThreading supported?
|
|
||||||
|
|
||||||
unsigned char m_nLogicalProcessors, // Number op logical processors.
|
|
||||||
m_nPhysicalProcessors; // Number of physical processors
|
|
||||||
|
|
||||||
int64 m_Speed; // In cycles per second.
|
|
||||||
|
|
||||||
char* m_szProcessorID; // Processor vendor Identification.
|
|
||||||
};
|
|
||||||
|
|
||||||
PLATFORM_INTERFACE const CPUInformation& GetCPUInformation();
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Thread related functions
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Registers the current thread with Tier0's thread management system.
|
|
||||||
// This should be called on every thread created in the game.
|
|
||||||
PLATFORM_INTERFACE unsigned long Plat_RegisterThread(const char *pName = "Source Thread");
|
|
||||||
|
|
||||||
// Registers the current thread as the primary thread.
|
|
||||||
PLATFORM_INTERFACE unsigned long Plat_RegisterPrimaryThread();
|
|
||||||
|
|
||||||
// VC-specific. Sets the thread's name so it has a friendly name in the debugger.
|
|
||||||
// This should generally only be handled by Plat_RegisterThread and Plat_RegisterPrimaryThread
|
|
||||||
PLATFORM_INTERFACE void Plat_SetThreadName(unsigned long dwThreadID, const char *pName);
|
|
||||||
|
|
||||||
// These would be private if it were possible to export private variables from a .DLL.
|
|
||||||
// They need to be variables because they are checked by inline functions at performance
|
|
||||||
// critical places.
|
|
||||||
PLATFORM_INTERFACE unsigned long Plat_PrimaryThreadID;
|
|
||||||
|
|
||||||
// Returns the ID of the currently executing thread.
|
|
||||||
PLATFORM_INTERFACE unsigned long Plat_GetCurrentThreadID();
|
|
||||||
|
|
||||||
// Returns the ID of the primary thread.
|
|
||||||
inline unsigned long Plat_GetPrimaryThreadID()
|
|
||||||
{
|
|
||||||
return Plat_PrimaryThreadID;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns true if the current thread is the primary thread.
|
|
||||||
inline bool Plat_IsPrimaryThread()
|
|
||||||
{
|
|
||||||
//return true;
|
|
||||||
return (Plat_GetPrimaryThreadID() == Plat_GetCurrentThreadID());
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Security related functions
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Ensure that the hardware key's drivers have been installed.
|
|
||||||
PLATFORM_INTERFACE bool Plat_VerifyHardwareKeyDriver();
|
|
||||||
|
|
||||||
// Ok, so this isn't a very secure way to verify the hardware key for now. It
|
|
||||||
// is primarially depending on the fact that all the binaries have been wrapped
|
|
||||||
// with the secure wrapper provided by the hardware keys vendor.
|
|
||||||
PLATFORM_INTERFACE bool Plat_VerifyHardwareKey();
|
|
||||||
|
|
||||||
// The same as above, but notifies user with a message box when the key isn't in
|
|
||||||
// and gives him an opportunity to correct the situation.
|
|
||||||
PLATFORM_INTERFACE bool Plat_VerifyHardwareKeyPrompt();
|
|
||||||
|
|
||||||
// Can be called in real time, doesn't perform the verify every frame. Mainly just
|
|
||||||
// here to allow the game to drop out quickly when the key is removed, rather than
|
|
||||||
// allowing the wrapper to pop up it's own blocking dialog, which the engine doesn't
|
|
||||||
// like much.
|
|
||||||
PLATFORM_INTERFACE bool Plat_FastVerifyHardwareKey();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Include additional dependant header components.
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//#include "tier0/fasttimer.h"
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Just logs file and line to simple.log
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void* Plat_SimpleLog(const char* file, int line);
|
|
||||||
|
|
||||||
//#define Plat_dynamic_cast Plat_SimpleLog(__FILE__,__LINE__),dynamic_cast
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Methods to invoke the constructor, copy constructor, and destructor
|
// Methods to invoke the constructor, copy constructor, and destructor
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline void Construct(T *pMemory)
|
inline void Construct(T *pMemory)
|
||||||
{
|
{
|
||||||
@ -491,140 +127,3 @@ inline void Destruct(T* pMemory)
|
|||||||
memset(pMemory, 0xDD, sizeof(T));
|
memset(pMemory, 0xDD, sizeof(T));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// GET_OUTER()
|
|
||||||
//
|
|
||||||
// A platform-independent way for a contained class to get a pointer to its
|
|
||||||
// owner. If you know a class is exclusively used in the context of some
|
|
||||||
// "outer" class, this is a much more space efficient way to get at the outer
|
|
||||||
// class than having the inner class store a pointer to it.
|
|
||||||
//
|
|
||||||
// class COuter
|
|
||||||
// {
|
|
||||||
// class CInner // Note: this does not need to be a nested class to work
|
|
||||||
// {
|
|
||||||
// void PrintAddressOfOuter()
|
|
||||||
// {
|
|
||||||
// printf( "Outer is at 0x%x\n", GET_OUTER( COuter, m_Inner ) );
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// CInner m_Inner;
|
|
||||||
// friend class CInner;
|
|
||||||
// };
|
|
||||||
|
|
||||||
#define GET_OUTER( OuterType, OuterMember ) \
|
|
||||||
( ( OuterType * ) ( (char *)this - offsetof( OuterType, OuterMember ) ) )
|
|
||||||
|
|
||||||
|
|
||||||
/* TEMPLATE_FUNCTION_TABLE()
|
|
||||||
|
|
||||||
(Note added to platform.h so platforms that correctly support templated
|
|
||||||
functions can handle portions as templated functions rather than wrapped
|
|
||||||
functions)
|
|
||||||
|
|
||||||
Helps automate the process of creating an array of function
|
|
||||||
templates that are all specialized by a single integer.
|
|
||||||
This sort of thing is often useful in optimization work.
|
|
||||||
|
|
||||||
For example, using TEMPLATE_FUNCTION_TABLE, this:
|
|
||||||
|
|
||||||
TEMPLATE_FUNCTION_TABLE(int, Function, ( int blah, int blah ), 10)
|
|
||||||
{
|
|
||||||
return argument * argument;
|
|
||||||
}
|
|
||||||
|
|
||||||
is equivilent to the following:
|
|
||||||
|
|
||||||
(NOTE: the function has to be wrapped in a class due to code
|
|
||||||
generation bugs involved with directly specializing a function
|
|
||||||
based on a constant.)
|
|
||||||
|
|
||||||
template<int argument>
|
|
||||||
class FunctionWrapper
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int Function( int blah, int blah )
|
|
||||||
{
|
|
||||||
return argument*argument;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef int (*FunctionType)( int blah, int blah );
|
|
||||||
|
|
||||||
class FunctionName
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum { count = 10 };
|
|
||||||
FunctionType functions[10];
|
|
||||||
};
|
|
||||||
|
|
||||||
FunctionType FunctionName::functions[] =
|
|
||||||
{
|
|
||||||
FunctionWrapper<0>::Function,
|
|
||||||
FunctionWrapper<1>::Function,
|
|
||||||
FunctionWrapper<2>::Function,
|
|
||||||
FunctionWrapper<3>::Function,
|
|
||||||
FunctionWrapper<4>::Function,
|
|
||||||
FunctionWrapper<5>::Function,
|
|
||||||
FunctionWrapper<6>::Function,
|
|
||||||
FunctionWrapper<7>::Function,
|
|
||||||
FunctionWrapper<8>::Function,
|
|
||||||
FunctionWrapper<9>::Function
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool vtune(bool resume);
|
|
||||||
|
|
||||||
|
|
||||||
#define TEMPLATE_FUNCTION_TABLE(RETURN_TYPE, NAME, ARGS, COUNT) \
|
|
||||||
\
|
|
||||||
typedef RETURN_TYPE (FASTCALL *__Type_##NAME) ARGS; \
|
|
||||||
\
|
|
||||||
template<const int nArgument> \
|
|
||||||
struct __Function_##NAME \
|
|
||||||
{ \
|
|
||||||
static RETURN_TYPE FASTCALL Run ARGS; \
|
|
||||||
}; \
|
|
||||||
\
|
|
||||||
template <int i> \
|
|
||||||
struct __MetaLooper_##NAME : __MetaLooper_##NAME<i-1> \
|
|
||||||
{ \
|
|
||||||
__Type_##NAME func; \
|
|
||||||
inline __MetaLooper_##NAME() { func = __Function_##NAME<i>::Run; } \
|
|
||||||
}; \
|
|
||||||
\
|
|
||||||
template<> \
|
|
||||||
struct __MetaLooper_##NAME<0> \
|
|
||||||
{ \
|
|
||||||
__Type_##NAME func; \
|
|
||||||
inline __MetaLooper_##NAME() { func = __Function_##NAME<0>::Run; } \
|
|
||||||
}; \
|
|
||||||
\
|
|
||||||
class NAME \
|
|
||||||
{ \
|
|
||||||
private: \
|
|
||||||
static const __MetaLooper_##NAME<COUNT> m; \
|
|
||||||
public: \
|
|
||||||
enum { count = COUNT }; \
|
|
||||||
static const __Type_##NAME* functions; \
|
|
||||||
}; \
|
|
||||||
const __MetaLooper_##NAME<COUNT> NAME::m; \
|
|
||||||
const __Type_##NAME* NAME::functions = (__Type_##NAME*)&m; \
|
|
||||||
template<int nArgument> \
|
|
||||||
RETURN_TYPE FASTCALL __Function_##NAME<nArgument>::Run ARGS
|
|
||||||
|
|
||||||
|
|
||||||
#define LOOP_INTERCHANGE(BOOLEAN, CODE)\
|
|
||||||
if( (BOOLEAN) )\
|
|
||||||
{\
|
|
||||||
CODE;\
|
|
||||||
} else\
|
|
||||||
{\
|
|
||||||
CODE;\
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* PLATFORM_H */
|
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#include "precompiled.h"
|
|
||||||
|
|
||||||
double Plat_FloatTime()
|
|
||||||
{
|
|
||||||
struct timeval tp;
|
|
||||||
static int secbase = 0;
|
|
||||||
|
|
||||||
gettimeofday(&tp, NULL);
|
|
||||||
|
|
||||||
if (!secbase)
|
|
||||||
{
|
|
||||||
secbase = tp.tv_sec;
|
|
||||||
return (tp.tv_usec / 1000000.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ((tp.tv_sec - secbase) + tp.tv_usec / 1000000.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long Plat_MSTime()
|
|
||||||
{
|
|
||||||
struct timeval tp;
|
|
||||||
static int secbase = 0;
|
|
||||||
|
|
||||||
gettimeofday(&tp, NULL);
|
|
||||||
|
|
||||||
if (!secbase)
|
|
||||||
{
|
|
||||||
secbase = tp.tv_sec;
|
|
||||||
return (tp.tv_usec / 1000000.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (unsigned long)((tp.tv_sec - secbase) + tp.tv_usec / 1000000.0);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool vtune(bool resume)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------- //
|
|
||||||
// Memory stuff.
|
|
||||||
// -------------------------------------------------------------------------------------------------- //
|
|
||||||
|
|
||||||
|
|
||||||
void Plat_SetThreadName(unsigned long dwThreadID, const char *pName)
|
|
||||||
{
|
|
||||||
Assert("Plat_SetThreadName not implemented");
|
|
||||||
}
|
|
@ -1,95 +0,0 @@
|
|||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#include "precompiled.h"
|
|
||||||
|
|
||||||
static LARGE_INTEGER g_PerformanceFrequency;
|
|
||||||
static LARGE_INTEGER g_MSPerformanceFrequency;
|
|
||||||
static LARGE_INTEGER g_ClockStart;
|
|
||||||
static HINSTANCE g_pVTuneDLL;
|
|
||||||
|
|
||||||
static void InitTime()
|
|
||||||
{
|
|
||||||
if (!g_PerformanceFrequency.QuadPart)
|
|
||||||
{
|
|
||||||
QueryPerformanceFrequency(&g_PerformanceFrequency);
|
|
||||||
g_MSPerformanceFrequency.QuadPart = g_PerformanceFrequency.QuadPart / 1000;
|
|
||||||
QueryPerformanceCounter(&g_ClockStart);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
double Plat_FloatTime()
|
|
||||||
{
|
|
||||||
InitTime();
|
|
||||||
|
|
||||||
LARGE_INTEGER CurrentTime;
|
|
||||||
|
|
||||||
QueryPerformanceCounter(&CurrentTime);
|
|
||||||
|
|
||||||
double fRawSeconds = (double)(CurrentTime.QuadPart - g_ClockStart.QuadPart) / (double)(g_PerformanceFrequency.QuadPart);
|
|
||||||
|
|
||||||
return fRawSeconds;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long Plat_MSTime()
|
|
||||||
{
|
|
||||||
InitTime();
|
|
||||||
|
|
||||||
LARGE_INTEGER CurrentTime;
|
|
||||||
|
|
||||||
QueryPerformanceCounter(&CurrentTime);
|
|
||||||
|
|
||||||
return (unsigned long)((CurrentTime.QuadPart - g_ClockStart.QuadPart) / g_MSPerformanceFrequency.QuadPart);
|
|
||||||
}
|
|
||||||
|
|
||||||
void free_vtune()
|
|
||||||
{
|
|
||||||
FreeLibrary(g_pVTuneDLL);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool vtune(bool resume)
|
|
||||||
{
|
|
||||||
static bool bInitialized = false;
|
|
||||||
static void(__cdecl *VTResume)(void) = NULL;
|
|
||||||
static void(__cdecl *VTPause) (void) = NULL;
|
|
||||||
|
|
||||||
// Grab the Pause and Resume function pointers from the VTune DLL the first time through:
|
|
||||||
if (!bInitialized)
|
|
||||||
{
|
|
||||||
bInitialized = true;
|
|
||||||
|
|
||||||
g_pVTuneDLL = LoadLibrary("vtuneapi.dll");
|
|
||||||
|
|
||||||
if (g_pVTuneDLL)
|
|
||||||
{
|
|
||||||
VTResume = (void(__cdecl *)())GetProcAddress(g_pVTuneDLL, "VTResume");
|
|
||||||
VTPause = (void(__cdecl *)())GetProcAddress(g_pVTuneDLL, "VTPause");
|
|
||||||
atexit(free_vtune);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Call the appropriate function, as indicated by the argument:
|
|
||||||
if (resume && VTResume)
|
|
||||||
{
|
|
||||||
VTResume();
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (!resume && VTPause)
|
|
||||||
{
|
|
||||||
VTPause();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------- //
|
|
||||||
// Memory stuff.
|
|
||||||
// -------------------------------------------------------------------------------------------------- //
|
|
@ -1,4 +1,4 @@
|
|||||||
//========= Copyright © 1996-2001, Valve LLC, All rights reserved. ============
|
//========= Copyright 1996-2001, Valve LLC, All rights reserved. ============
|
||||||
//
|
//
|
||||||
// The copyright to the contents herein is the property of Valve, L.L.C.
|
// The copyright to the contents herein is the property of Valve, L.L.C.
|
||||||
// The contents may be used and/or copied only with the written permission of
|
// The contents may be used and/or copied only with the written permission of
|
||||||
@ -13,6 +13,12 @@
|
|||||||
|
|
||||||
#include "precompiled.h"
|
#include "precompiled.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// constructors
|
// constructors
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include "osconfig.h"
|
#include "osconfig.h"
|
||||||
#include "basetypes.h"
|
#include "basetypes.h"
|
||||||
#include "utlmemory.h"
|
#include "utlmemory.h"
|
||||||
#include "tier0/dbg.h"
|
//#include "tier0/dbg.h"
|
||||||
|
|
||||||
|
|
||||||
// This is a useful macro to iterate from head to tail in a linked list.
|
// This is a useful macro to iterate from head to tail in a linked list.
|
||||||
|
@ -1,36 +1,43 @@
|
|||||||
//=========== (C) Copyright 1999 Valve, L.L.C. All rights reserved. ===========
|
/*
|
||||||
//
|
*
|
||||||
// The copyright to the contents herein is the property of Valve, L.L.C.
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
// The contents may be used and/or copied only with the written permission of
|
* under the terms of the GNU General Public License as published by the
|
||||||
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
|
* Free Software Foundation; either version 2 of the License, or (at
|
||||||
// the agreement/contract under which the contents have been supplied.
|
* your option) any later version.
|
||||||
//
|
*
|
||||||
// $Header: $
|
* This program is distributed in the hope that it will be useful, but
|
||||||
// $NoKeywords: $
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
//
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// A growable memory class.
|
* General Public License for more details.
|
||||||
//=============================================================================
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
* In addition, as a special exception, the author gives permission to
|
||||||
|
* link the code of this program with the Half-Life Game Engine ("HL
|
||||||
|
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
|
||||||
|
* L.L.C ("Valve"). You must obey the GNU General Public License in all
|
||||||
|
* respects for all of the code used other than the HL Engine and MODs
|
||||||
|
* from Valve. If you modify this file, you may extend this exception
|
||||||
|
* to your version of the file, but you are not obligated to do so. If
|
||||||
|
* you do not wish to do so, delete this exception statement from your
|
||||||
|
* version.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef UTLMEMORY_H
|
|
||||||
#define UTLMEMORY_H
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "osconfig.h"
|
#include "osconfig.h"
|
||||||
#include "tier0/dbg.h"
|
#include "tier0/dbg.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "tier0/platform.h"
|
|
||||||
|
|
||||||
#pragma warning (disable:4100)
|
#pragma warning (disable:4100)
|
||||||
#pragma warning (disable:4514)
|
#pragma warning (disable:4514)
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// The CUtlMemory class:
|
// The CUtlMemory class:
|
||||||
// A growable memory class which doubles in size by default.
|
// A growable memory class which doubles in size by default.
|
||||||
//-----------------------------------------------------------------------------
|
template <class T, class I = int>
|
||||||
template< class T >
|
|
||||||
class CUtlMemory
|
class CUtlMemory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -39,14 +46,38 @@ public:
|
|||||||
CUtlMemory(T *pMemory, int numElements);
|
CUtlMemory(T *pMemory, int numElements);
|
||||||
~CUtlMemory();
|
~CUtlMemory();
|
||||||
|
|
||||||
|
// Set the size by which the memory grows
|
||||||
|
void Init(int nGrowSize = 0, int nInitSize = 0);
|
||||||
|
|
||||||
|
class Iterator_t
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Iterator_t(I i) : m_index(i) {}
|
||||||
|
I m_index;
|
||||||
|
|
||||||
|
bool operator==(const Iterator_t it) const { return m_index == it.m_index; }
|
||||||
|
bool operator!=(const Iterator_t it) const { return m_index != it.m_index; }
|
||||||
|
};
|
||||||
|
|
||||||
|
Iterator_t First() const { return Iterator_t(IsIdxValid(0) ? 0 : InvalidIndex()); }
|
||||||
|
Iterator_t Next(const Iterator_t &it) const { return Iterator_t(IsIdxValid(it.index + 1) ? it.index + 1 : InvalidIndex()); }
|
||||||
|
I GetIndex(const Iterator_t &it) const { return it.index; }
|
||||||
|
bool IsIdxAfter(I i, const Iterator_t &it) const { return i > it.index; }
|
||||||
|
bool IsValidIterator(const Iterator_t &it) const { return IsIdxValid(it.index); }
|
||||||
|
Iterator_t InvalidIterator() const { return Iterator_t(InvalidIndex()); }
|
||||||
|
|
||||||
// element access
|
// element access
|
||||||
T& operator[](int i);
|
T& Element(I i);
|
||||||
T const& operator[](int i) const;
|
T const& Element(I i) const;
|
||||||
T& Element(int i);
|
T& operator[](I i);
|
||||||
T const& Element(int i) const;
|
T const& operator[](I i) const;
|
||||||
|
|
||||||
// Can we use this index?
|
// Can we use this index?
|
||||||
bool IsIdxValid(int i) const;
|
bool IsIdxValid(I i) const;
|
||||||
|
|
||||||
|
// Specify the invalid ('null') index that we'll only return on failure
|
||||||
|
static const I INVALID_INDEX = (I)-1; // For use with COMPILE_TIME_ASSERT
|
||||||
|
static I InvalidIndex() { return INVALID_INDEX; }
|
||||||
|
|
||||||
// Gets the base address (can change when adding elements!)
|
// Gets the base address (can change when adding elements!)
|
||||||
T *Base();
|
T *Base();
|
||||||
@ -85,13 +116,10 @@ private:
|
|||||||
int m_nGrowSize;
|
int m_nGrowSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// constructor, destructor
|
// constructor, destructor
|
||||||
//-----------------------------------------------------------------------------
|
template <class T, class I>
|
||||||
template< class T >
|
CUtlMemory<T, I>::CUtlMemory(int nGrowSize, int nInitSize) : m_pMemory(0),
|
||||||
CUtlMemory<T>::CUtlMemory(int nGrowSize, int nInitAllocationCount) : m_pMemory(0),
|
m_nAllocationCount(nInitSize), m_nGrowSize(nGrowSize)
|
||||||
m_nAllocationCount(nInitAllocationCount), m_nGrowSize(nGrowSize)
|
|
||||||
{
|
{
|
||||||
Assert((nGrowSize >= 0) && (nGrowSize != EXTERNAL_BUFFER_MARKER));
|
Assert((nGrowSize >= 0) && (nGrowSize != EXTERNAL_BUFFER_MARKER));
|
||||||
if (m_nAllocationCount)
|
if (m_nAllocationCount)
|
||||||
@ -100,26 +128,37 @@ m_nAllocationCount(nInitAllocationCount), m_nGrowSize(nGrowSize)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class T >
|
template <class T, class I>
|
||||||
CUtlMemory<T>::CUtlMemory(T* pMemory, int numElements) : m_pMemory(pMemory),
|
CUtlMemory<T, I>::CUtlMemory(T *pMemory, int numElements) : m_pMemory(pMemory),
|
||||||
m_nAllocationCount(numElements)
|
m_nAllocationCount(numElements)
|
||||||
{
|
{
|
||||||
// Special marker indicating externally supplied memory
|
// Special marker indicating externally supplied memory
|
||||||
m_nGrowSize = EXTERNAL_BUFFER_MARKER;
|
m_nGrowSize = EXTERNAL_BUFFER_MARKER;
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class T >
|
template <class T, class I>
|
||||||
CUtlMemory<T>::~CUtlMemory()
|
CUtlMemory<T, I>::~CUtlMemory()
|
||||||
{
|
{
|
||||||
Purge();
|
Purge();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class T, class I>
|
||||||
|
void CUtlMemory<T,I>::Init(int nGrowSize, int nInitSize)
|
||||||
|
{
|
||||||
|
Purge();
|
||||||
|
|
||||||
|
m_nGrowSize = nGrowSize;
|
||||||
|
m_nAllocationCount = nInitSize;
|
||||||
|
Assert(nGrowSize >= 0);
|
||||||
|
if (m_nAllocationCount)
|
||||||
|
{
|
||||||
|
m_pMemory = (T *)malloc(m_nAllocationCount * sizeof(T));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Attaches the buffer to external memory....
|
// Attaches the buffer to external memory....
|
||||||
//-----------------------------------------------------------------------------
|
template <class T, class I>
|
||||||
template< class T >
|
void CUtlMemory<T, I>::SetExternalBuffer(T *pMemory, int numElements)
|
||||||
void CUtlMemory<T>::SetExternalBuffer(T* pMemory, int numElements)
|
|
||||||
{
|
{
|
||||||
// Blow away any existing allocated memory
|
// Blow away any existing allocated memory
|
||||||
Purge();
|
Purge();
|
||||||
@ -131,104 +170,85 @@ void CUtlMemory<T>::SetExternalBuffer(T* pMemory, int numElements)
|
|||||||
m_nGrowSize = EXTERNAL_BUFFER_MARKER;
|
m_nGrowSize = EXTERNAL_BUFFER_MARKER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// element access
|
// element access
|
||||||
//-----------------------------------------------------------------------------
|
template <class T, class I>
|
||||||
template< class T >
|
inline T& CUtlMemory<T, I>::operator[](I i)
|
||||||
inline T& CUtlMemory<T>::operator[](int i)
|
|
||||||
{
|
{
|
||||||
Assert(IsIdxValid(i));
|
Assert(IsIdxValid(i));
|
||||||
return m_pMemory[i];
|
return m_pMemory[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class T >
|
template <class T, class I>
|
||||||
inline T const& CUtlMemory<T>::operator[](int i) const
|
inline T const& CUtlMemory<T, I>::operator[](I i) const
|
||||||
{
|
{
|
||||||
Assert(IsIdxValid(i));
|
Assert(IsIdxValid(i));
|
||||||
return m_pMemory[i];
|
return m_pMemory[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class T >
|
template <class T, class I>
|
||||||
inline T& CUtlMemory<T>::Element(int i)
|
inline T& CUtlMemory<T, I>::Element(I i)
|
||||||
{
|
{
|
||||||
Assert(IsIdxValid(i));
|
Assert(IsIdxValid(i));
|
||||||
return m_pMemory[i];
|
return m_pMemory[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class T >
|
template <class T, class I>
|
||||||
inline T const& CUtlMemory<T>::Element(int i) const
|
inline T const& CUtlMemory<T, I>::Element(I i) const
|
||||||
{
|
{
|
||||||
Assert(IsIdxValid(i));
|
Assert(IsIdxValid(i));
|
||||||
return m_pMemory[i];
|
return m_pMemory[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// is the memory externally allocated?
|
// is the memory externally allocated?
|
||||||
//-----------------------------------------------------------------------------
|
template <class T, class I>
|
||||||
template< class T >
|
bool CUtlMemory<T, I>::IsExternallyAllocated() const
|
||||||
bool CUtlMemory<T>::IsExternallyAllocated() const
|
|
||||||
{
|
{
|
||||||
return m_nGrowSize == EXTERNAL_BUFFER_MARKER;
|
return m_nGrowSize == EXTERNAL_BUFFER_MARKER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class T, class I>
|
||||||
template< class T >
|
void CUtlMemory<T, I>::SetGrowSize(int nSize)
|
||||||
void CUtlMemory<T>::SetGrowSize(int nSize)
|
|
||||||
{
|
{
|
||||||
Assert((nSize >= 0) && (nSize != EXTERNAL_BUFFER_MARKER));
|
Assert((nSize >= 0) && (nSize != EXTERNAL_BUFFER_MARKER));
|
||||||
m_nGrowSize = nSize;
|
m_nGrowSize = nSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Gets the base address (can change when adding elements!)
|
// Gets the base address (can change when adding elements!)
|
||||||
//-----------------------------------------------------------------------------
|
template <class T, class I>
|
||||||
template< class T >
|
inline T *CUtlMemory<T, I>::Base()
|
||||||
inline T* CUtlMemory<T>::Base()
|
|
||||||
{
|
{
|
||||||
return m_pMemory;
|
return m_pMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class T >
|
template <class T, class I>
|
||||||
inline T const* CUtlMemory<T>::Base() const
|
inline T const *CUtlMemory<T, I>::Base() const
|
||||||
{
|
{
|
||||||
return m_pMemory;
|
return m_pMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Size
|
// Size
|
||||||
//-----------------------------------------------------------------------------
|
template <class T, class I>
|
||||||
template< class T >
|
inline int CUtlMemory<T, I>::NumAllocated() const
|
||||||
inline int CUtlMemory<T>::NumAllocated() const
|
|
||||||
{
|
{
|
||||||
return m_nAllocationCount;
|
return m_nAllocationCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class T >
|
template <class T, class I>
|
||||||
inline int CUtlMemory<T>::Count() const
|
inline int CUtlMemory<T, I>::Count() const
|
||||||
{
|
{
|
||||||
return m_nAllocationCount;
|
return m_nAllocationCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Is element index valid?
|
// Is element index valid?
|
||||||
//-----------------------------------------------------------------------------
|
template <class T, class I>
|
||||||
template< class T >
|
inline bool CUtlMemory<T, I>::IsIdxValid(I i) const
|
||||||
inline bool CUtlMemory<T>::IsIdxValid(int i) const
|
|
||||||
{
|
{
|
||||||
return (i >= 0) && (i < m_nAllocationCount);
|
return (((int)i) >= 0) && (((int) i) < m_nAllocationCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Grows the memory
|
// Grows the memory
|
||||||
//-----------------------------------------------------------------------------
|
template <class T, class I>
|
||||||
template< class T >
|
void CUtlMemory<T, I>::Grow(int num)
|
||||||
void CUtlMemory<T>::Grow(int num)
|
|
||||||
{
|
{
|
||||||
Assert(num > 0);
|
Assert(num > 0);
|
||||||
|
|
||||||
@ -273,12 +293,9 @@ void CUtlMemory<T>::Grow(int num)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Makes sure we've got at least this much memory
|
// Makes sure we've got at least this much memory
|
||||||
//-----------------------------------------------------------------------------
|
template <class T, class I>
|
||||||
template< class T >
|
inline void CUtlMemory<T, I>::EnsureCapacity(int num)
|
||||||
inline void CUtlMemory<T>::EnsureCapacity(int num)
|
|
||||||
{
|
{
|
||||||
if (m_nAllocationCount >= num)
|
if (m_nAllocationCount >= num)
|
||||||
return;
|
return;
|
||||||
@ -301,12 +318,9 @@ inline void CUtlMemory<T>::EnsureCapacity(int num)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Memory deallocation
|
// Memory deallocation
|
||||||
//-----------------------------------------------------------------------------
|
template <class T, class I>
|
||||||
template< class T >
|
void CUtlMemory<T, I>::Purge()
|
||||||
void CUtlMemory<T>::Purge()
|
|
||||||
{
|
{
|
||||||
if (!IsExternallyAllocated())
|
if (!IsExternallyAllocated())
|
||||||
{
|
{
|
||||||
@ -318,6 +332,3 @@ void CUtlMemory<T>::Purge()
|
|||||||
m_nAllocationCount = 0;
|
m_nAllocationCount = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // UTLSTORAGE_H
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,16 +1,3 @@
|
|||||||
//=========== (C) Copyright 1999 Valve, L.L.C. All rights reserved. ===========
|
|
||||||
//
|
|
||||||
// The copyright to the contents herein is the property of Valve, L.L.C.
|
|
||||||
// The contents may be used and/or copied only with the written permission of
|
|
||||||
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
|
|
||||||
// the agreement/contract under which the contents have been supplied.
|
|
||||||
//
|
|
||||||
// $Header: $
|
|
||||||
// $NoKeywords: $
|
|
||||||
//
|
|
||||||
// A growable memory class.
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#ifndef UTLVECTOR_H
|
#ifndef UTLVECTOR_H
|
||||||
#define UTLVECTOR_H
|
#define UTLVECTOR_H
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -18,7 +5,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "utlmemory.h"
|
#include "utlmemory.h"
|
||||||
#include "tier0/platform.h"
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
class CUtlVector
|
class CUtlVector
|
||||||
@ -110,8 +96,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Can't copy this unless we explicitly do it!
|
// Can't copy this unless we explicitly do it!
|
||||||
CUtlVector( CUtlVector const& vec ) { assert(0);
|
CUtlVector(CUtlVector const& vec) { assert(0); }
|
||||||
}
|
|
||||||
|
|
||||||
// Grows the vector
|
// Grows the vector
|
||||||
void GrowVector(int num = 1);
|
void GrowVector(int num = 1);
|
||||||
@ -134,6 +119,7 @@ protected:
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// For easier access to the elements through the debugger
|
// For easier access to the elements through the debugger
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
template< class T >
|
template< class T >
|
||||||
inline void CUtlVector<T>::ResetDbgInfo()
|
inline void CUtlVector<T>::ResetDbgInfo()
|
||||||
{
|
{
|
||||||
@ -143,6 +129,7 @@ inline void CUtlVector<T>::ResetDbgInfo()
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// constructor, destructor
|
// constructor, destructor
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
template< class T >
|
template< class T >
|
||||||
inline CUtlVector<T>::CUtlVector(int growSize, int initSize) :
|
inline CUtlVector<T>::CUtlVector(int growSize, int initSize) :
|
||||||
m_Memory(growSize, initSize), m_Size(0)
|
m_Memory(growSize, initSize), m_Size(0)
|
||||||
@ -173,6 +160,7 @@ inline CUtlVector<T>& CUtlVector<T>::operator=( const CUtlVector<T> &other )
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// element access
|
// element access
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
template< class T >
|
template< class T >
|
||||||
inline T& CUtlVector<T>::operator[](int i)
|
inline T& CUtlVector<T>::operator[](int i)
|
||||||
{
|
{
|
||||||
@ -204,6 +192,7 @@ inline T const& CUtlVector<T>::Element( int i ) const
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Gets the base address (can change when adding elements!)
|
// Gets the base address (can change when adding elements!)
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
template< class T >
|
template< class T >
|
||||||
inline T* CUtlVector<T>::Base()
|
inline T* CUtlVector<T>::Base()
|
||||||
{
|
{
|
||||||
@ -219,6 +208,7 @@ inline T const* CUtlVector<T>::Base() const
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Count
|
// Count
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
template< class T >
|
template< class T >
|
||||||
inline int CUtlVector<T>::Size() const
|
inline int CUtlVector<T>::Size() const
|
||||||
{
|
{
|
||||||
@ -234,6 +224,7 @@ inline int CUtlVector<T>::Count() const
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Is element index valid?
|
// Is element index valid?
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
template< class T >
|
template< class T >
|
||||||
inline bool CUtlVector<T>::IsValidIndex(int i) const
|
inline bool CUtlVector<T>::IsValidIndex(int i) const
|
||||||
{
|
{
|
||||||
@ -499,7 +490,7 @@ void CUtlVector<T>::FastRemove( int elem )
|
|||||||
Destruct(&Element(elem));
|
Destruct(&Element(elem));
|
||||||
if (m_Size > 0)
|
if (m_Size > 0)
|
||||||
{
|
{
|
||||||
memcpy( &Element(elem), &Element(m_Size-1), sizeof(T) );
|
Q_memcpy(&Element(elem), &Element(m_Size-1), sizeof(T));
|
||||||
--m_Size;
|
--m_Size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,6 @@ char *GetExecCmdPrepare(IGameClient *pClient, CResourceBuffer *pResource, uint32
|
|||||||
if (string[0] != '\0')
|
if (string[0] != '\0')
|
||||||
{
|
{
|
||||||
g_pResource->Log(LOG_NORMAL, " -> ExecuteCMD: (%s), for (#%u)(%s)", string, nUserID, pClient->GetName());
|
g_pResource->Log(LOG_NORMAL, " -> ExecuteCMD: (%s), for (#%u)(%s)", string, nUserID, pClient->GetName());
|
||||||
}
|
|
||||||
|
|
||||||
len = strlen(string);
|
len = strlen(string);
|
||||||
|
|
||||||
@ -77,13 +76,16 @@ char *GetExecCmdPrepare(IGameClient *pClient, CResourceBuffer *pResource, uint32
|
|||||||
strcat(string, "\n");
|
strcat(string, "\n");
|
||||||
else
|
else
|
||||||
string[len - 1] = '\n';
|
string[len - 1] = '\n';
|
||||||
|
}
|
||||||
|
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool haveAtLeastOneExecuted = false;
|
||||||
void EXT_FUNC CmdExec_hook(IGameClient *pClient, IResourceBuffer *pRes, char *cmdExec, uint32 responseHash) {
|
void EXT_FUNC CmdExec_hook(IGameClient *pClient, IResourceBuffer *pRes, char *cmdExec, uint32 responseHash) {
|
||||||
// execute cmdexec
|
// execute cmdexec
|
||||||
SERVER_COMMAND(cmdExec);
|
SERVER_COMMAND(cmdExec);
|
||||||
|
haveAtLeastOneExecuted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CExecMngr::ExecuteCommand(IGameClient *pClient)
|
void CExecMngr::ExecuteCommand(IGameClient *pClient)
|
||||||
@ -127,6 +129,11 @@ void CExecMngr::ExecuteCommand(IGameClient *pClient)
|
|||||||
delete pExec;
|
delete pExec;
|
||||||
iter = m_execList.erase(iter);
|
iter = m_execList.erase(iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (haveAtLeastOneExecuted) {
|
||||||
|
SERVER_EXECUTE();
|
||||||
|
haveAtLeastOneExecuted = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CExecMngr::Clear(IGameClient *pClient)
|
void CExecMngr::Clear(IGameClient *pClient)
|
||||||
@ -148,12 +155,13 @@ void CExecMngr::Clear(IGameClient *pClient)
|
|||||||
CBufExec *pExec = (*iter);
|
CBufExec *pExec = (*iter);
|
||||||
|
|
||||||
// erase cmdexec
|
// erase cmdexec
|
||||||
if (pExec->GetUserID() == nUserID)
|
if (pExec->GetUserID() != nUserID)
|
||||||
{
|
{
|
||||||
|
iter++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
delete pExec;
|
delete pExec;
|
||||||
iter = m_execList.erase(iter);
|
iter = m_execList.erase(iter);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
iter++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ private:
|
|||||||
uint32 m_ClientHash;
|
uint32 m_ClientHash;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::list<CBufExec *> CBufExecList;
|
typedef std::vector<CBufExec *> CBufExecList;
|
||||||
CBufExecList m_execList;
|
CBufExecList m_execList;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ plugin_info_t Plugin_info =
|
|||||||
{
|
{
|
||||||
META_INTERFACE_VERSION,
|
META_INTERFACE_VERSION,
|
||||||
"Rechecker",
|
"Rechecker",
|
||||||
"2.3",
|
"2.4",
|
||||||
__DATE__,
|
__DATE__,
|
||||||
"s1lent",
|
"s1lent",
|
||||||
"http://www.dedicated-server.ru/",
|
"http://www.dedicated-server.ru/",
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#include "basetypes.h"
|
#include "basetypes.h"
|
||||||
#include "archtypes.h"
|
#include "archtypes.h"
|
||||||
|
|
||||||
#include <list>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cstring> // strrchr
|
#include <cstring> // strrchr
|
||||||
#include <algorithm> // std::sort
|
#include <algorithm> // std::sort
|
||||||
|
@ -119,15 +119,15 @@ IResourceFile *EXT_FUNC GetResource_api() {
|
|||||||
return g_pResource;
|
return g_pResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
IRecheckerHookRegistry_FileConsistencyProcess *CRecheckerHookchains::FileConsistencyProcess() {
|
IRecheckerHookRegistry_FileConsistencyProcess *EXT_FUNC CRecheckerHookchains::FileConsistencyProcess() {
|
||||||
return &m_FileConsistencyProcess;
|
return &m_FileConsistencyProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
IRecheckerHookRegistry_CmdExec *CRecheckerHookchains::CmdExec() {
|
IRecheckerHookRegistry_CmdExec *EXT_FUNC CRecheckerHookchains::CmdExec() {
|
||||||
return &m_CmdExec;
|
return &m_CmdExec;
|
||||||
}
|
}
|
||||||
|
|
||||||
IRecheckerHookRegistry_FileConsistencyFinal *CRecheckerHookchains::FileConsistencyFinal() {
|
IRecheckerHookRegistry_FileConsistencyFinal *EXT_FUNC CRecheckerHookchains::FileConsistencyFinal() {
|
||||||
return &m_FileConsistencyFinal;
|
return &m_FileConsistencyFinal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user