mirror of
https://github.com/YGGverse/hlsdk-portable.git
synced 2025-01-11 15:38:12 +00:00
Replaced magic numbers with defines in dlls/nodes*
- Changed some symbols to be platform-independent - Now the CGraph_Retail::copyOverTo method doesn't automatically fall back to manual copy (instead of memcpy) on GRAPH_VERSION increments
This commit is contained in:
parent
2b61380146
commit
8ef6cb2427
@ -2397,7 +2397,7 @@ int CGraph::FLoadGraph( const char *szMapName )
|
||||
iVersion = *(int *) pMemFile;
|
||||
pMemFile += sizeof(int);
|
||||
|
||||
if( iVersion == GRAPH_VERSION || iVersion == 16 )
|
||||
if( iVersion == GRAPH_VERSION || iVersion == GRAPH_VERSION_RETAIL )
|
||||
{
|
||||
// Read the graph class
|
||||
//
|
||||
@ -2417,15 +2417,15 @@ int CGraph::FLoadGraph( const char *szMapName )
|
||||
m_pRouteInfo = NULL;
|
||||
m_pHashLinks = NULL;
|
||||
}
|
||||
#if _GRAPH_VERSION != 16
|
||||
#if _GRAPH_VERSION != _GRAPH_VERSION_RETAIL
|
||||
else
|
||||
{
|
||||
ALERT( at_aiconsole, "Loading CGraph in GRAPH_VERSION 16 compatibility mode\n" );
|
||||
length -= sizeof(CGraph_32);
|
||||
length -= sizeof(CGraph_Retail);
|
||||
if( length < 0 )
|
||||
goto ShortFile;
|
||||
reinterpret_cast<CGraph_32*>(pMemFile) -> copyOverTo(this);
|
||||
pMemFile += sizeof(CGraph_32);
|
||||
reinterpret_cast<CGraph_Retail*>(pMemFile) -> copyOverTo(this);
|
||||
pMemFile += sizeof(CGraph_Retail);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -2467,15 +2467,15 @@ int CGraph::FLoadGraph( const char *szMapName )
|
||||
memcpy( m_pLinkPool, pMemFile, sizeof(CLink) * m_cLinks );
|
||||
pMemFile += sizeof(CLink) * m_cLinks;
|
||||
}
|
||||
#if _GRAPH_VERSION != 16
|
||||
#if _GRAPH_VERSION != _GRAPH_VERSION_RETAIL
|
||||
else
|
||||
{
|
||||
ALERT( at_aiconsole, "Loading CLink array in GRAPH_VERSION 16 compatibility mode\n" );
|
||||
length -= sizeof(CLink_32) * m_cLinks;
|
||||
length -= sizeof(CLink_Retail) * m_cLinks;
|
||||
if( length < 0 )
|
||||
goto ShortFile;
|
||||
reinterpret_cast<CLink_32*>(pMemFile) -> copyOverTo(m_pLinkPool);
|
||||
pMemFile += sizeof(CLink_32) * m_cLinks;
|
||||
reinterpret_cast<CLink_Retail*>(pMemFile) -> copyOverTo(m_pLinkPool);
|
||||
pMemFile += sizeof(CLink_Retail) * m_cLinks;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -105,12 +105,14 @@ typedef struct
|
||||
//=========================================================
|
||||
// CGraph
|
||||
//=========================================================
|
||||
#define _GRAPH_VERSION_RETAIL 16 // Retail Half-Life graph version. Don't increment this
|
||||
#ifdef XASH_64BIT
|
||||
#define _GRAPH_VERSION (16 * 10)
|
||||
#else
|
||||
#define _GRAPH_VERSION (16)// !!!increment this whever graph/node/link classes change, to obsolesce older disk files.
|
||||
#define _GRAPH_VERSION (16) // !!!increment this whenever graph/node/link classes change, to obsolesce older disk files.
|
||||
#endif
|
||||
#define GRAPH_VERSION (int)_GRAPH_VERSION
|
||||
#define GRAPH_VERSION_RETAIL (int)_GRAPH_VERSION_RETAIL
|
||||
|
||||
class CGraph
|
||||
{
|
||||
|
@ -5,13 +5,13 @@
|
||||
|
||||
//#include "nodes.h"
|
||||
|
||||
#if _GRAPH_VERSION != 16
|
||||
#if _GRAPH_VERSION != _GRAPH_VERSION_RETAIL
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
typedef int32_t PTR32;
|
||||
|
||||
class CGraph_32
|
||||
class CGraph_Retail
|
||||
{
|
||||
public:
|
||||
|
||||
@ -62,10 +62,11 @@ public:
|
||||
other->m_nRouteInfo = m_nRouteInfo;
|
||||
|
||||
other->m_di = NULL;
|
||||
#if _GRAPH_VERSION == 160
|
||||
|
||||
memcpy( (void *) &other->m_RangeStart, (void *) m_RangeStart,
|
||||
offsetof(class CGraph, m_pHashLinks) - offsetof(class CGraph, m_RangeStart) );
|
||||
#else // fallback routine if the graph version changes
|
||||
|
||||
#if 0 // replacement routine in case a change in CGraph breaks the above memcpy
|
||||
for (int i = 0; i < 3; ++i)
|
||||
for (int j = 0; j < NUM_RANGES; ++j)
|
||||
other->m_RangeStart[i][j] = m_RangeStart[i][j];
|
||||
@ -102,6 +103,7 @@ public:
|
||||
other->m_HashPrimes[i] = m_HashPrimes[i];
|
||||
// m_HashPrimes[16]
|
||||
#endif
|
||||
|
||||
other->m_pHashLinks = NULL;
|
||||
other->m_nHashLinks = m_nHashLinks;
|
||||
|
||||
@ -114,7 +116,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class CLink_32
|
||||
class CLink_Retail
|
||||
{
|
||||
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user