mirror of
https://github.com/nillerusr/source-engine.git
synced 2025-01-29 00:04:27 +00:00
commit
4243cede59
@ -539,64 +539,62 @@ struct leafnums_t
|
|||||||
CCollisionBSPData *pBSPData;
|
CCollisionBSPData *pBSPData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int CM_BoxLeafnums( leafnums_t &context, const Vector ¢er, const Vector &extents, int nodenum )
|
int CM_BoxLeafnums( leafnums_t &context, const Vector ¢er, const Vector &extents, int nodenum )
|
||||||
{
|
{
|
||||||
int leafCount = 0;
|
int leafCount = 0;
|
||||||
const int NODELIST_MAX = 1024;
|
const int NODELIST_MAX = 1024;
|
||||||
int nodeList[NODELIST_MAX];
|
int nodeList[NODELIST_MAX];
|
||||||
int nodeReadIndex = 0;
|
int nodeReadIndex = 0;
|
||||||
int nodeWriteIndex = 0;
|
int nodeWriteIndex = 0;
|
||||||
cplane_t *plane;
|
cplane_t *plane;
|
||||||
cnode_t *node;
|
cnode_t *node;
|
||||||
int prev_topnode = -1;
|
int prev_topnode = -1;
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
if (nodenum < 0)
|
if (nodenum < 0)
|
||||||
{
|
{
|
||||||
// This handles the case when the box lies completely
|
// This handles the case when the box lies completely
|
||||||
// within a single node. In that case, the top node should be
|
// within a single node. In that case, the top node should be
|
||||||
// the parent of the leaf
|
// the parent of the leaf
|
||||||
if (context.leafTopNode == -1)
|
if (context.leafTopNode == -1)
|
||||||
context.leafTopNode = prev_topnode;
|
context.leafTopNode = prev_topnode;
|
||||||
|
|
||||||
if (leafCount < context.leafMaxCount)
|
if (leafCount < context.leafMaxCount)
|
||||||
{
|
{
|
||||||
context.pLeafList[leafCount] = -1 - nodenum;
|
context.pLeafList[leafCount] = -1 - nodenum;
|
||||||
leafCount++;
|
leafCount++;
|
||||||
}
|
}
|
||||||
if ( nodeReadIndex == nodeWriteIndex )
|
if ( nodeReadIndex == nodeWriteIndex )
|
||||||
return leafCount;
|
return leafCount;
|
||||||
nodenum = nodeList[nodeReadIndex];
|
nodenum = nodeList[nodeReadIndex];
|
||||||
nodeReadIndex = (nodeReadIndex+1) & (NODELIST_MAX-1);
|
nodeReadIndex = (nodeReadIndex+1) & (NODELIST_MAX-1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
node = &context.pBSPData->map_rootnode[nodenum];
|
node = &context.pBSPData->map_rootnode[nodenum];
|
||||||
plane = node->plane;
|
plane = node->plane;
|
||||||
// s = BoxOnPlaneSide (leaf_mins, leaf_maxs, plane);
|
// s = BoxOnPlaneSide (leaf_mins, leaf_maxs, plane);
|
||||||
// s = BOX_ON_PLANE_SIDE(*leaf_mins, *leaf_maxs, plane);
|
// s = BOX_ON_PLANE_SIDE(*leaf_mins, *leaf_maxs, plane);
|
||||||
float d0 = DotProduct( plane->normal, center ) - plane->dist;
|
float d0 = DotProduct( plane->normal, center ) - plane->dist;
|
||||||
float d1 = DotProductAbs( plane->normal, extents );
|
float d1 = DotProductAbs( plane->normal, extents );
|
||||||
prev_topnode = nodenum;
|
prev_topnode = nodenum;
|
||||||
if (d0 >= d1)
|
if (d0 >= d1)
|
||||||
nodenum = node->children[0];
|
nodenum = node->children[0];
|
||||||
else if (d0 < -d1)
|
else if (d0 < -d1)
|
||||||
nodenum = node->children[1];
|
nodenum = node->children[1];
|
||||||
else
|
else
|
||||||
{ // go down both
|
{ // go down both
|
||||||
if (context.leafTopNode == -1)
|
if (context.leafTopNode == -1)
|
||||||
context.leafTopNode = nodenum;
|
context.leafTopNode = nodenum;
|
||||||
nodeList[nodeWriteIndex] = node->children[0];
|
nodeList[nodeWriteIndex] = node->children[0];
|
||||||
nodeWriteIndex = (nodeWriteIndex+1) & (NODELIST_MAX-1);
|
nodeWriteIndex = (nodeWriteIndex+1) & (NODELIST_MAX-1);
|
||||||
// check for overflow of the ring buffer
|
// check for overflow of the ring buffer
|
||||||
Assert(nodeWriteIndex != nodeReadIndex);
|
Assert(nodeWriteIndex != nodeReadIndex);
|
||||||
nodenum = node->children[1];
|
nodenum = node->children[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int CM_BoxLeafnums ( const Vector& mins, const Vector& maxs, int *list, int listsize, int *topnode)
|
int CM_BoxLeafnums ( const Vector& mins, const Vector& maxs, int *list, int listsize, int *topnode)
|
||||||
@ -2666,38 +2664,32 @@ bool CM_HeadnodeVisible (int nodenum, const byte *visbits, int vissize )
|
|||||||
// *visbits - pvs or pas of some cluster
|
// *visbits - pvs or pas of some cluster
|
||||||
// Output : true if visible, false if not
|
// Output : true if visible, false if not
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
#define MAX_BOX_LEAVES 256
|
#define MAX_BOX_LEAVES 256
|
||||||
int CM_BoxVisible( const Vector& mins, const Vector& maxs, const byte *visbits, int vissize )
|
int CM_BoxVisible( const Vector& mins, const Vector& maxs, const byte *visbits, int vissize )
|
||||||
{
|
{
|
||||||
int leafList[MAX_BOX_LEAVES];
|
int leafList[MAX_BOX_LEAVES];
|
||||||
int topnode;
|
int topnode;
|
||||||
|
|
||||||
// FIXME: Could save a loop here by traversing the tree in this routine like the code above
|
// FIXME: Could save a loop here by traversing the tree in this routine like the code above
|
||||||
int count = CM_BoxLeafnums( mins, maxs, leafList, MAX_BOX_LEAVES, &topnode );
|
int count = CM_BoxLeafnums( mins, maxs, leafList, MAX_BOX_LEAVES, &topnode );
|
||||||
for ( int i = 0; i < count; i++ )
|
for ( int i = 0; i < count; i++ )
|
||||||
{
|
{
|
||||||
int cluster = CM_LeafCluster( leafList[i] );
|
int cluster = CM_LeafCluster( leafList[i] );
|
||||||
int offset = cluster>>3;
|
int offset = cluster>>3;
|
||||||
|
|
||||||
if ( offset == -1 )
|
if ( offset > vissize )
|
||||||
{
|
{
|
||||||
return false;
|
Sys_Error( "CM_BoxVisible: cluster %i, offset %i out of bounds %i\n", cluster, offset, vissize );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( offset > vissize || offset < 0 )
|
if (visbits[cluster>>3] & (1<<(cluster&7)))
|
||||||
{
|
{
|
||||||
Sys_Error( "CM_BoxVisible: cluster %i, offset %i out of bounds %i\n", cluster, offset, vissize );
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (visbits[cluster>>3] & (1<<(cluster&7)))
|
return false;
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Returns the world-space center of an entity
|
// Returns the world-space center of an entity
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -3380,12 +3380,14 @@ void CBasePlayer::PhysicsSimulate( void )
|
|||||||
pi->m_nNumCmds = commandsToRun;
|
pi->m_nNumCmds = commandsToRun;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
else if ( GetTimeSinceLastUserCommand() > sv_player_usercommand_timeout.GetFloat() )
|
else if ( GetTimeSinceLastUserCommand() > sv_player_usercommand_timeout.GetFloat() )
|
||||||
{
|
{
|
||||||
// no usercommand from player after some threshold
|
// no usercommand from player after some threshold
|
||||||
// server should start RunNullCommand as if client sends an empty command so that Think and gamestate related things run properly
|
// server should start RunNullCommand as if client sends an empty command so that Think and gamestate related things run properly
|
||||||
RunNullCommand();
|
RunNullCommand();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Restore the true server clock
|
// Restore the true server clock
|
||||||
// FIXME: Should this occur after simulation of children so
|
// FIXME: Should this occur after simulation of children so
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "tier1/strtools.h"
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: Basic handler for an rgb set of colors
|
// Purpose: Basic handler for an rgb set of colors
|
||||||
// This class is fully inline
|
// This class is fully inline
|
||||||
@ -22,7 +24,7 @@ public:
|
|||||||
// constructors
|
// constructors
|
||||||
Color()
|
Color()
|
||||||
{
|
{
|
||||||
*((int *)this) = 0;
|
Q_memset( _color, 0, sizeof _color );
|
||||||
}
|
}
|
||||||
Color(int _r,int _g,int _b)
|
Color(int _r,int _g,int _b)
|
||||||
{
|
{
|
||||||
@ -32,7 +34,7 @@ public:
|
|||||||
{
|
{
|
||||||
SetColor(_r, _g, _b, _a);
|
SetColor(_r, _g, _b, _a);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the color
|
// set the color
|
||||||
// r - red component (0-255)
|
// r - red component (0-255)
|
||||||
// g - green component (0-255)
|
// g - green component (0-255)
|
||||||
@ -56,19 +58,21 @@ public:
|
|||||||
|
|
||||||
void SetRawColor( int color32 )
|
void SetRawColor( int color32 )
|
||||||
{
|
{
|
||||||
*((int *)this) = color32;
|
Q_memcpy( _color, &color32, sizeof _color );
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetRawColor() const
|
int GetRawColor() const
|
||||||
{
|
{
|
||||||
return *((int *)this);
|
int color;
|
||||||
|
Q_memcpy( &color, _color, sizeof _color );
|
||||||
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int r() const { return _color[0]; }
|
inline int r() const { return _color[0]; }
|
||||||
inline int g() const { return _color[1]; }
|
inline int g() const { return _color[1]; }
|
||||||
inline int b() const { return _color[2]; }
|
inline int b() const { return _color[2]; }
|
||||||
inline int a() const { return _color[3]; }
|
inline int a() const { return _color[3]; }
|
||||||
|
|
||||||
unsigned char &operator[](int index)
|
unsigned char &operator[](int index)
|
||||||
{
|
{
|
||||||
return _color[index];
|
return _color[index];
|
||||||
@ -79,12 +83,12 @@ public:
|
|||||||
return _color[index];
|
return _color[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator == (const Color &rhs) const
|
bool operator == (const Color &rhs)
|
||||||
{
|
{
|
||||||
return ( *((int *)this) == *((int *)&rhs) );
|
return Q_memcmp( this, &rhs, sizeof(Color) ) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator != (const Color &rhs) const
|
bool operator != (const Color &rhs)
|
||||||
{
|
{
|
||||||
return !(operator==(rhs));
|
return !(operator==(rhs));
|
||||||
}
|
}
|
||||||
|
@ -128,11 +128,9 @@ DECLARE_FIELD_SIZE( FIELD_MATERIALINDEX, sizeof(int) )
|
|||||||
#define ARRAYSIZE2D(p) (sizeof(p)/sizeof(p[0][0]))
|
#define ARRAYSIZE2D(p) (sizeof(p)/sizeof(p[0][0]))
|
||||||
#define SIZE_OF_ARRAY(p) _ARRAYSIZE(p)
|
#define SIZE_OF_ARRAY(p) _ARRAYSIZE(p)
|
||||||
|
|
||||||
// Normal offset of is invalid on non-array-types, this is dubious as hell. The rest of the codebase converted to the
|
#define _offsetof(s,m) ((size_t)&(((s *)0)->m))
|
||||||
// legit offsetof from the C headers, so we'll use the old impl here to avoid exposing temptation to others
|
|
||||||
#define _hacky_datamap_offsetof(s,m) ((size_t)&(((s *)0)->m))
|
|
||||||
|
|
||||||
#define _FIELD(name,fieldtype,count,flags,mapname,tolerance) { fieldtype, #name, { (int)_hacky_datamap_offsetof(classNameTypedef, name), 0 }, count, flags, mapname, NULL, NULL, NULL, sizeof( ((classNameTypedef *)0)->name ), NULL, 0, tolerance }
|
#define _FIELD(name,fieldtype,count,flags,mapname,tolerance) { fieldtype, #name, { _offsetof(classNameTypedef, name), 0 }, count, flags, mapname, NULL, NULL, NULL, sizeof( ((classNameTypedef *)0)->name ), NULL, 0, tolerance }
|
||||||
#define DEFINE_FIELD_NULL { FIELD_VOID,0, {0,0},0,0,0,0,0,0}
|
#define DEFINE_FIELD_NULL { FIELD_VOID,0, {0,0},0,0,0,0,0,0}
|
||||||
#define DEFINE_FIELD(name,fieldtype) _FIELD(name, fieldtype, 1, FTYPEDESC_SAVE, NULL, 0 )
|
#define DEFINE_FIELD(name,fieldtype) _FIELD(name, fieldtype, 1, FTYPEDESC_SAVE, NULL, 0 )
|
||||||
#define DEFINE_KEYFIELD(name,fieldtype, mapname) _FIELD(name, fieldtype, 1, FTYPEDESC_KEY | FTYPEDESC_SAVE, mapname, 0 )
|
#define DEFINE_KEYFIELD(name,fieldtype, mapname) _FIELD(name, fieldtype, 1, FTYPEDESC_KEY | FTYPEDESC_SAVE, mapname, 0 )
|
||||||
@ -144,35 +142,35 @@ DECLARE_FIELD_SIZE( FIELD_MATERIALINDEX, sizeof(int) )
|
|||||||
#define DEFINE_ENTITY_GLOBAL_FIELD(name,fieldtype) _FIELD(edict_t, name, fieldtype, 1, FTYPEDESC_KEY | FTYPEDESC_SAVE | FTYPEDESC_GLOBAL, #name, 0 )
|
#define DEFINE_ENTITY_GLOBAL_FIELD(name,fieldtype) _FIELD(edict_t, name, fieldtype, 1, FTYPEDESC_KEY | FTYPEDESC_SAVE | FTYPEDESC_GLOBAL, #name, 0 )
|
||||||
#define DEFINE_GLOBAL_FIELD(name,fieldtype) _FIELD(name, fieldtype, 1, FTYPEDESC_GLOBAL | FTYPEDESC_SAVE, NULL, 0 )
|
#define DEFINE_GLOBAL_FIELD(name,fieldtype) _FIELD(name, fieldtype, 1, FTYPEDESC_GLOBAL | FTYPEDESC_SAVE, NULL, 0 )
|
||||||
#define DEFINE_GLOBAL_KEYFIELD(name,fieldtype, mapname) _FIELD(name, fieldtype, 1, FTYPEDESC_GLOBAL | FTYPEDESC_KEY | FTYPEDESC_SAVE, mapname, 0 )
|
#define DEFINE_GLOBAL_KEYFIELD(name,fieldtype, mapname) _FIELD(name, fieldtype, 1, FTYPEDESC_GLOBAL | FTYPEDESC_KEY | FTYPEDESC_SAVE, mapname, 0 )
|
||||||
#define DEFINE_CUSTOM_FIELD(name,datafuncs) { FIELD_CUSTOM, #name, { (int)_hacky_datamap_offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE, NULL, datafuncs, NULL }
|
#define DEFINE_CUSTOM_FIELD(name,datafuncs) { FIELD_CUSTOM, #name, { _offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE, NULL, datafuncs, NULL }
|
||||||
#define DEFINE_CUSTOM_KEYFIELD(name,datafuncs,mapname) { FIELD_CUSTOM, #name, { (int)_hacky_datamap_offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE | FTYPEDESC_KEY, mapname, datafuncs, NULL }
|
#define DEFINE_CUSTOM_KEYFIELD(name,datafuncs,mapname) { FIELD_CUSTOM, #name, { _offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE | FTYPEDESC_KEY, mapname, datafuncs, NULL }
|
||||||
#define DEFINE_AUTO_ARRAY2D(name,fieldtype) _FIELD(name, fieldtype, ARRAYSIZE2D(((classNameTypedef *)0)->name), FTYPEDESC_SAVE, NULL, 0 )
|
#define DEFINE_AUTO_ARRAY2D(name,fieldtype) _FIELD(name, fieldtype, ARRAYSIZE2D(((classNameTypedef *)0)->name), FTYPEDESC_SAVE, NULL, 0 )
|
||||||
// Used by byteswap datadescs
|
// Used by byteswap datadescs
|
||||||
#define DEFINE_BITFIELD(name,fieldtype,bitcount) DEFINE_ARRAY(name,fieldtype,((bitcount+FIELD_BITS(fieldtype)-1)&~(FIELD_BITS(fieldtype)-1)) / FIELD_BITS(fieldtype) )
|
#define DEFINE_BITFIELD(name,fieldtype,bitcount) DEFINE_ARRAY(name,fieldtype,((bitcount+FIELD_BITS(fieldtype)-1)&~(FIELD_BITS(fieldtype)-1)) / FIELD_BITS(fieldtype) )
|
||||||
#define DEFINE_INDEX(name,fieldtype) _FIELD(name, fieldtype, 1, FTYPEDESC_INDEX, NULL, 0 )
|
#define DEFINE_INDEX(name,fieldtype) _FIELD(name, fieldtype, 1, FTYPEDESC_INDEX, NULL, 0 )
|
||||||
|
|
||||||
#define DEFINE_EMBEDDED( name ) \
|
#define DEFINE_EMBEDDED( name ) \
|
||||||
{ FIELD_EMBEDDED, #name, { (int)_hacky_datamap_offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE, NULL, NULL, NULL, &(((classNameTypedef *)0)->name.m_DataMap), sizeof( ((classNameTypedef *)0)->name ), NULL, 0, 0.0f }
|
{ FIELD_EMBEDDED, #name, { _offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE, NULL, NULL, NULL, &(((classNameTypedef *)0)->name.m_DataMap), sizeof( ((classNameTypedef *)0)->name ), NULL, 0, 0.0f }
|
||||||
|
|
||||||
#define DEFINE_EMBEDDED_OVERRIDE( name, overridetype ) \
|
#define DEFINE_EMBEDDED_OVERRIDE( name, overridetype ) \
|
||||||
{ FIELD_EMBEDDED, #name, { (int)_hacky_datamap_offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE, NULL, NULL, NULL, &((overridetype *)0)->m_DataMap, sizeof( ((classNameTypedef *)0)->name ), NULL, 0, 0.0f }
|
{ FIELD_EMBEDDED, #name, { _offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE, NULL, NULL, NULL, &((overridetype *)0)->m_DataMap, sizeof( ((classNameTypedef *)0)->name ), NULL, 0, 0.0f }
|
||||||
|
|
||||||
#define DEFINE_EMBEDDEDBYREF( name ) \
|
#define DEFINE_EMBEDDEDBYREF( name ) \
|
||||||
{ FIELD_EMBEDDED, #name, { (int)_hacky_datamap_offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE | FTYPEDESC_PTR, NULL, NULL, NULL, &(((classNameTypedef *)0)->name->m_DataMap), sizeof( *(((classNameTypedef *)0)->name) ), NULL, 0, 0.0f }
|
{ FIELD_EMBEDDED, #name, { _offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE | FTYPEDESC_PTR, NULL, NULL, NULL, &(((classNameTypedef *)0)->name->m_DataMap), sizeof( *(((classNameTypedef *)0)->name) ), NULL, 0, 0.0f }
|
||||||
|
|
||||||
#define DEFINE_EMBEDDED_ARRAY( name, count ) \
|
#define DEFINE_EMBEDDED_ARRAY( name, count ) \
|
||||||
{ FIELD_EMBEDDED, #name, { (int)_hacky_datamap_offsetof(classNameTypedef, name), 0 }, count, FTYPEDESC_SAVE, NULL, NULL, NULL, &(((classNameTypedef *)0)->name->m_DataMap), sizeof( ((classNameTypedef *)0)->name[0] ), NULL, 0, 0.0f }
|
{ FIELD_EMBEDDED, #name, { _offsetof(classNameTypedef, name), 0 }, count, FTYPEDESC_SAVE, NULL, NULL, NULL, &(((classNameTypedef *)0)->name->m_DataMap), sizeof( ((classNameTypedef *)0)->name[0] ), NULL, 0, 0.0f }
|
||||||
|
|
||||||
#define DEFINE_EMBEDDED_AUTO_ARRAY( name ) \
|
#define DEFINE_EMBEDDED_AUTO_ARRAY( name ) \
|
||||||
{ FIELD_EMBEDDED, #name, { (int)_hacky_datamap_offsetof(classNameTypedef, name), 0 }, SIZE_OF_ARRAY( ((classNameTypedef *)0)->name ), FTYPEDESC_SAVE, NULL, NULL, NULL, &(((classNameTypedef *)0)->name->m_DataMap), sizeof( ((classNameTypedef *)0)->name[0] ), NULL, 0, 0.0f }
|
{ FIELD_EMBEDDED, #name, { _offsetof(classNameTypedef, name), 0 }, SIZE_OF_ARRAY( ((classNameTypedef *)0)->name ), FTYPEDESC_SAVE, NULL, NULL, NULL, &(((classNameTypedef *)0)->name->m_DataMap), sizeof( ((classNameTypedef *)0)->name[0] ), NULL, 0, 0.0f }
|
||||||
|
|
||||||
#ifndef NO_ENTITY_PREDICTION
|
#ifndef NO_ENTITY_PREDICTION
|
||||||
|
|
||||||
#define DEFINE_PRED_TYPEDESCRIPTION( name, fieldtype ) \
|
#define DEFINE_PRED_TYPEDESCRIPTION( name, fieldtype ) \
|
||||||
{ FIELD_EMBEDDED, #name, { (int)_hacky_datamap_offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE, NULL, NULL, NULL, &fieldtype::m_PredMap }
|
{ FIELD_EMBEDDED, #name, { _offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE, NULL, NULL, NULL, &fieldtype::m_PredMap }
|
||||||
|
|
||||||
#define DEFINE_PRED_TYPEDESCRIPTION_PTR( name, fieldtype ) \
|
#define DEFINE_PRED_TYPEDESCRIPTION_PTR( name, fieldtype ) \
|
||||||
{ FIELD_EMBEDDED, #name, { (int)_hacky_datamap_offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE | FTYPEDESC_PTR, NULL, NULL, NULL, &fieldtype::m_PredMap }
|
{ FIELD_EMBEDDED, #name, { _offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE | FTYPEDESC_PTR, NULL, NULL, NULL, &fieldtype::m_PredMap }
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@ -193,7 +191,7 @@ DECLARE_FIELD_SIZE( FIELD_MATERIALINDEX, sizeof(int) )
|
|||||||
//#define DEFINE_DATA( name, fieldextname, flags ) _FIELD(name, fieldtype, 1, flags, extname )
|
//#define DEFINE_DATA( name, fieldextname, flags ) _FIELD(name, fieldtype, 1, flags, extname )
|
||||||
|
|
||||||
// INPUTS
|
// INPUTS
|
||||||
#define DEFINE_INPUT( name, fieldtype, inputname ) { fieldtype, #name, { (int)_hacky_datamap_offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_INPUT | FTYPEDESC_SAVE | FTYPEDESC_KEY, inputname, NULL, NULL, NULL, sizeof( ((classNameTypedef *)0)->name ) }
|
#define DEFINE_INPUT( name, fieldtype, inputname ) { fieldtype, #name, { _offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_INPUT | FTYPEDESC_SAVE | FTYPEDESC_KEY, inputname, NULL, NULL, NULL, sizeof( ((classNameTypedef *)0)->name ) }
|
||||||
#define DEFINE_INPUTFUNC( fieldtype, inputname, inputfunc ) { fieldtype, #inputfunc, { NULL, NULL }, 1, FTYPEDESC_INPUT, inputname, NULL, static_cast <inputfunc_t> (&classNameTypedef::inputfunc) }
|
#define DEFINE_INPUTFUNC( fieldtype, inputname, inputfunc ) { fieldtype, #inputfunc, { NULL, NULL }, 1, FTYPEDESC_INPUT, inputname, NULL, static_cast <inputfunc_t> (&classNameTypedef::inputfunc) }
|
||||||
|
|
||||||
// OUTPUTS
|
// OUTPUTS
|
||||||
@ -201,7 +199,7 @@ DECLARE_FIELD_SIZE( FIELD_MATERIALINDEX, sizeof(int) )
|
|||||||
// we know the output type from the variable itself, so it doesn't need to be specified here
|
// we know the output type from the variable itself, so it doesn't need to be specified here
|
||||||
class ISaveRestoreOps;
|
class ISaveRestoreOps;
|
||||||
extern ISaveRestoreOps *eventFuncs;
|
extern ISaveRestoreOps *eventFuncs;
|
||||||
#define DEFINE_OUTPUT( name, outputname ) { FIELD_CUSTOM, #name, { (int)_hacky_datamap_offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_OUTPUT | FTYPEDESC_SAVE | FTYPEDESC_KEY, outputname, eventFuncs }
|
#define DEFINE_OUTPUT( name, outputname ) { FIELD_CUSTOM, #name, { _offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_OUTPUT | FTYPEDESC_SAVE | FTYPEDESC_KEY, outputname, eventFuncs }
|
||||||
|
|
||||||
// replaces EXPORT table for portability and non-DLL based systems (xbox)
|
// replaces EXPORT table for portability and non-DLL based systems (xbox)
|
||||||
#define DEFINE_FUNCTION_RAW( function, func_type ) { FIELD_VOID, nameHolder.GenerateName(#function), { NULL, NULL }, 1, FTYPEDESC_FUNCTIONTABLE, NULL, NULL, (inputfunc_t)((func_type)(&classNameTypedef::function)) }
|
#define DEFINE_FUNCTION_RAW( function, func_type ) { FIELD_VOID, nameHolder.GenerateName(#function), { NULL, NULL }, 1, FTYPEDESC_FUNCTIONTABLE, NULL, NULL, (inputfunc_t)((func_type)(&classNameTypedef::function)) }
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include "mathlib/vector.h"
|
#include "mathlib/vector.h"
|
||||||
#include "basetypes.h"
|
#include "basetypes.h"
|
||||||
#include "tier0/dbg.h"
|
#include "tier0/dbg.h"
|
||||||
|
#include "strtools.h"
|
||||||
|
|
||||||
#if _DEBUG
|
#if _DEBUG
|
||||||
#define BITBUF_INLINE inline
|
#define BITBUF_INLINE inline
|
||||||
@ -465,12 +465,12 @@ BITBUF_INLINE void bf_write::WriteUBitVar( unsigned int data )
|
|||||||
// write raw IEEE float bits in little endian form
|
// write raw IEEE float bits in little endian form
|
||||||
BITBUF_INLINE void bf_write::WriteBitFloat(float val)
|
BITBUF_INLINE void bf_write::WriteBitFloat(float val)
|
||||||
{
|
{
|
||||||
long intVal;
|
int32 intVal;
|
||||||
|
|
||||||
Assert(sizeof(long) == sizeof(float));
|
Assert(sizeof(long) == sizeof(float));
|
||||||
Assert(sizeof(float) == 4);
|
Assert(sizeof(float) == 4);
|
||||||
|
|
||||||
intVal = *((long*)&val);
|
Q_memcpy( &intVal, &val, sizeof(intVal));
|
||||||
WriteUBitLong( intVal, 32 );
|
WriteUBitLong( intVal, 32 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -598,7 +598,7 @@ inline void CUtlBuffer::GetObject( T *dest )
|
|||||||
{
|
{
|
||||||
if ( !m_Byteswap.IsSwappingBytes() || ( sizeof( T ) == 1 ) )
|
if ( !m_Byteswap.IsSwappingBytes() || ( sizeof( T ) == 1 ) )
|
||||||
{
|
{
|
||||||
*dest = *(T *)PeekGet();
|
Q_memcpy( dest, PeekGet(), sizeof( T ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -630,18 +630,18 @@ inline void CUtlBuffer::GetTypeBin( T &dest )
|
|||||||
{
|
{
|
||||||
if ( !m_Byteswap.IsSwappingBytes() || ( sizeof( T ) == 1 ) )
|
if ( !m_Byteswap.IsSwappingBytes() || ( sizeof( T ) == 1 ) )
|
||||||
{
|
{
|
||||||
dest = *(T *)PeekGet();
|
Q_memcpy(&dest, PeekGet(), sizeof(T) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_Byteswap.SwapBufferToTargetEndian<T>( &dest, (T*)PeekGet() );
|
m_Byteswap.SwapBufferToTargetEndian<T>( &dest, (T*)PeekGet() );
|
||||||
}
|
}
|
||||||
m_Get += sizeof(T);
|
m_Get += sizeof(T);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dest = 0;
|
dest = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
@ -661,18 +661,18 @@ inline void CUtlBuffer::GetTypeBin< float >( float &dest )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// aligned read
|
// aligned read
|
||||||
dest = *(float *)pData;
|
Q_memcpy( &dest, (void*)pData, sizeof(float) );
|
||||||
}
|
}
|
||||||
if ( m_Byteswap.IsSwappingBytes() )
|
if ( m_Byteswap.IsSwappingBytes() )
|
||||||
{
|
{
|
||||||
m_Byteswap.SwapBufferToTargetEndian< float >( &dest, &dest );
|
m_Byteswap.SwapBufferToTargetEndian< float >( &dest, &dest );
|
||||||
}
|
}
|
||||||
m_Get += sizeof( float );
|
m_Get += sizeof( float );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dest = 0;
|
dest = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -816,7 +816,7 @@ inline void CUtlBuffer::PutObject( T *src )
|
|||||||
{
|
{
|
||||||
if ( !m_Byteswap.IsSwappingBytes() || ( sizeof( T ) == 1 ) )
|
if ( !m_Byteswap.IsSwappingBytes() || ( sizeof( T ) == 1 ) )
|
||||||
{
|
{
|
||||||
*(T *)PeekPut() = *src;
|
Q_memcpy( PeekPut(), src, sizeof( T ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -845,7 +845,7 @@ inline void CUtlBuffer::PutTypeBin( T src )
|
|||||||
{
|
{
|
||||||
if ( !m_Byteswap.IsSwappingBytes() || ( sizeof( T ) == 1 ) )
|
if ( !m_Byteswap.IsSwappingBytes() || ( sizeof( T ) == 1 ) )
|
||||||
{
|
{
|
||||||
*(T *)PeekPut() = src;
|
Q_memcpy( PeekPut(), &src, sizeof( T ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
typedef uint16 PackFileIndex_t;
|
typedef uint16 PackFileIndex_t;
|
||||||
#define PACKFILEINDEX_END 0xffff
|
#define PACKFILEINDEX_END 0xffff
|
||||||
|
const uint16 packedfileindex_end = 0xffff;
|
||||||
|
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
struct CFilePartDescr
|
struct CFilePartDescr
|
||||||
@ -120,9 +120,12 @@ static int SkipFile( char const * &pData ) // returns highest file index
|
|||||||
int nHighestChunkIndex = -1;
|
int nHighestChunkIndex = -1;
|
||||||
pData += 1 + V_strlen( pData );
|
pData += 1 + V_strlen( pData );
|
||||||
pData += sizeof( uint32 );
|
pData += sizeof( uint32 );
|
||||||
int nMetaDataSize = *(reinterpret_cast<uint16 const *>( pData ) );
|
|
||||||
|
uint16 nMetaDataSize;
|
||||||
|
Q_memcpy( &nMetaDataSize, pData, sizeof( uint16 ) );
|
||||||
|
|
||||||
pData += sizeof( uint16 );
|
pData += sizeof( uint16 );
|
||||||
while ( *( ( PackFileIndex_t const *) pData ) != PACKFILEINDEX_END )
|
while ( Q_memcmp( pData, &packedfileindex_end, sizeof( packedfileindex_end ) ) != 0 )
|
||||||
{
|
{
|
||||||
int nIdx = reinterpret_cast<CFilePartDescr const *>(pData)->m_nFileNumber;
|
int nIdx = reinterpret_cast<CFilePartDescr const *>(pData)->m_nFileNumber;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user