Browse Source

Fix nodes

foolsday
mittorn 9 years ago
parent
commit
1ca34fcb43
  1. 18
      dlls/nodes.cpp
  2. 2
      dlls/nodes.h

18
dlls/nodes.cpp

@ -42,7 +42,7 @@ LINK_ENTITY_TO_CLASS( info_node, CNodeEnt ); @@ -42,7 +42,7 @@ LINK_ENTITY_TO_CLASS( info_node, CNodeEnt );
LINK_ENTITY_TO_CLASS( info_node_air, CNodeEnt );
#ifdef __linux__
#include <unistd.h>
#include <sys/stat.h>
#include <sys/stat.h>
#define CreateDirectory(p, n) mkdir(p, 0777)
#endif
//=========================================================
@ -515,13 +515,13 @@ int CGraph::NextNodeInRoute( int iCurrentNode, int iDest, int iHull, int iCap ) @@ -515,13 +515,13 @@ int CGraph::NextNodeInRoute( int iCurrentNode, int iDest, int iHull, int iCap )
{
int iNext = iCurrentNode;
int nCount = iDest+1;
char *pRoute = m_pRouteInfo + m_pNodes[ iCurrentNode ].m_pNextBestNode[iHull][iCap];
signed char *pRoute = m_pRouteInfo + m_pNodes[ iCurrentNode ].m_pNextBestNode[iHull][iCap];
// Until we decode the next best node
//
while (nCount > 0)
{
char ch = *pRoute++;
signed char ch = *pRoute++;
//ALERT(at_aiconsole, "C(%d)", ch);
if (ch < 0)
{
@ -2420,7 +2420,7 @@ int CGraph :: FLoadGraph ( char *szMapName ) @@ -2420,7 +2420,7 @@ int CGraph :: FLoadGraph ( char *szMapName )
// Malloc for the routing info.
//
m_fRoutingComplete = FALSE;
m_pRouteInfo = (char *)calloc( sizeof(char), m_nRouteInfo );
m_pRouteInfo = (signed char *)calloc( sizeof(signed char), m_nRouteInfo );
if ( !m_pRouteInfo )
{
ALERT ( at_aiconsole, "***ERROR**\nCounldn't malloc %d route bytes!\n", m_nRouteInfo );
@ -2534,7 +2534,7 @@ int CGraph :: FSaveGraph ( char *szMapName ) @@ -2534,7 +2534,7 @@ int CGraph :: FSaveGraph ( char *szMapName )
//
if ( m_pRouteInfo && m_nRouteInfo )
{
fwrite ( m_pRouteInfo, sizeof( char ), m_nRouteInfo, file );
fwrite ( m_pRouteInfo, sizeof( signed char ), m_nRouteInfo, file );
}
if (m_pHashLinks && m_nHashLinks)
@ -3035,7 +3035,7 @@ void CGraph :: ComputeStaticRoutingTables( void ) @@ -3035,7 +3035,7 @@ void CGraph :: ComputeStaticRoutingTables( void )
int *pMyPath = new int[m_cNodes];
unsigned short *BestNextNodes = new unsigned short[m_cNodes];
char *pRoute = new char[m_cNodes*2];
signed char *pRoute = new signed char[m_cNodes*2];
if (Routes && pMyPath && BestNextNodes && pRoute)
@ -3129,7 +3129,7 @@ void CGraph :: ComputeStaticRoutingTables( void ) @@ -3129,7 +3129,7 @@ void CGraph :: ComputeStaticRoutingTables( void )
int cSequence = 0;
int cRepeats = 0;
int CompressedSize = 0;
char *p = pRoute;
signed char *p = pRoute;
for (int i = 0; i < m_cNodes; i++)
{
BOOL CanRepeat = ((BestNextNodes[i] == iLastNode) && cRepeats < 127);
@ -3289,7 +3289,7 @@ void CGraph :: ComputeStaticRoutingTables( void ) @@ -3289,7 +3289,7 @@ void CGraph :: ComputeStaticRoutingTables( void )
}
else
{
char *Tmp = (char *)calloc(sizeof(char), (m_nRouteInfo + nRoute));
signed char *Tmp = (signed char *)calloc(sizeof(signed char), (m_nRouteInfo + nRoute));
memcpy(Tmp, m_pRouteInfo, m_nRouteInfo);
free(m_pRouteInfo);
m_pRouteInfo = Tmp;
@ -3302,7 +3302,7 @@ void CGraph :: ComputeStaticRoutingTables( void ) @@ -3302,7 +3302,7 @@ void CGraph :: ComputeStaticRoutingTables( void )
else
{
m_nRouteInfo = nRoute;
m_pRouteInfo = (char *)calloc(sizeof(char), nRoute);
m_pRouteInfo = (signed char *)calloc(sizeof(signed char), nRoute);
memcpy(m_pRouteInfo, pRoute, nRoute);
m_pNodes[ iFrom ].m_pNextBestNode[iHull][iCap] = 0;
nTotalCompressedSize += CompressedSize;

2
dlls/nodes.h

@ -116,7 +116,7 @@ public: @@ -116,7 +116,7 @@ public:
CNode *m_pNodes;// pointer to the memory block that contains all node info
CLink *m_pLinkPool;// big list of all node connections
char *m_pRouteInfo; // compressed routing information the nodes use.
signed char *m_pRouteInfo; // compressed routing information the nodes use.
int m_cNodes;// total number of nodes
int m_cLinks;// total number of links

Loading…
Cancel
Save