Merged 64 bit fixes.

This commit is contained in:
Robert Beckebans 2012-12-12 12:11:55 +01:00
parent 2952f227ea
commit 86deed26b8
12 changed files with 131 additions and 76 deletions

View file

@ -367,7 +367,9 @@ pvsStack_t* idPVS::FloodPassagePVS_r( pvsPortal_t* source, const pvsPortal_t* po
pvsArea_t* area; pvsArea_t* area;
pvsStack_t* stack; pvsStack_t* stack;
pvsPassage_t* passage; pvsPassage_t* passage;
long* sourceVis, *passageVis, *portalVis, *mightSee, *prevMightSee, more; // RB: 64 bit fixes, changed long to int
int* sourceVis, *passageVis, *portalVis, *mightSee, *prevMightSee, more;
// RB end
area = &pvsAreas[portal->areaNum]; area = &pvsAreas[portal->areaNum];
@ -406,16 +408,22 @@ pvsStack_t* idPVS::FloodPassagePVS_r( pvsPortal_t* source, const pvsPortal_t* po
source->vis[n >> 3] |= ( 1 << ( n & 7 ) ); source->vis[n >> 3] |= ( 1 << ( n & 7 ) );
// get pointers to vis data // get pointers to vis data
prevMightSee = reinterpret_cast<long*>( prevStack->mightSee );
passageVis = reinterpret_cast<long*>( passage->canSee ); // RB: 64 bit fixes, changed long to int
sourceVis = reinterpret_cast<long*>( source->vis ); prevMightSee = reinterpret_cast<int*>( prevStack->mightSee );
mightSee = reinterpret_cast<long*>( stack->mightSee ); passageVis = reinterpret_cast<int*>( passage->canSee );
sourceVis = reinterpret_cast<int*>( source->vis );
mightSee = reinterpret_cast<int*>( stack->mightSee );
// RB end
more = 0; more = 0;
// use the portal PVS if it has been calculated // use the portal PVS if it has been calculated
if( p->done ) if( p->done )
{ {
portalVis = reinterpret_cast<long*>( p->vis ); // RB: 64 bit fixes, changed long to int
portalVis = reinterpret_cast<int*>( p->vis );
// RB end
for( j = 0; j < portalVisLongs; j++ ) for( j = 0; j < portalVisLongs; j++ )
{ {
// get new PVS which is decreased by going through this passage // get new PVS which is decreased by going through this passage
@ -828,7 +836,9 @@ idPVS::AreaPVSFromPortalPVS
int idPVS::AreaPVSFromPortalPVS() const int idPVS::AreaPVSFromPortalPVS() const
{ {
int i, j, k, areaNum, totalVisibleAreas; int i, j, k, areaNum, totalVisibleAreas;
long* p1, *p2; // RB: 64 bit fixes, changed long to int
int* p1, *p2;
// RB end
byte* pvs, *portalPVS; byte* pvs, *portalPVS;
pvsArea_t* area; pvsArea_t* area;
@ -857,8 +867,11 @@ int idPVS::AreaPVSFromPortalPVS() const
// store the PVS of all portals in this area at the first portal // store the PVS of all portals in this area at the first portal
for( j = 1; j < area->numPortals; j++ ) for( j = 1; j < area->numPortals; j++ )
{ {
p1 = reinterpret_cast<long*>( area->portals[0]->vis ); // RB: 64 bit fixes, changed long to int
p2 = reinterpret_cast<long*>( area->portals[j]->vis ); p1 = reinterpret_cast<int*>( area->portals[0]->vis );
p2 = reinterpret_cast<int*>( area->portals[j]->vis );
// RB end
for( k = 0; k < portalVisLongs; k++ ) for( k = 0; k < portalVisLongs; k++ )
{ {
*p1++ |= *p2++; *p1++ |= *p2++;
@ -917,7 +930,9 @@ void idPVS::Init()
areaQueue = new( TAG_PVS ) int[numAreas]; areaQueue = new( TAG_PVS ) int[numAreas];
areaVisBytes = ( ( ( numAreas + 31 )&~31 ) >> 3 ); areaVisBytes = ( ( ( numAreas + 31 )&~31 ) >> 3 );
areaVisLongs = areaVisBytes / sizeof( long ); // RB: 64 bit fixes, changed long to int
areaVisLongs = areaVisBytes / sizeof( int );
// RB end
areaPVS = new( TAG_PVS ) byte[numAreas * areaVisBytes]; areaPVS = new( TAG_PVS ) byte[numAreas * areaVisBytes];
memset( areaPVS, 0xFF, numAreas * areaVisBytes ); memset( areaPVS, 0xFF, numAreas * areaVisBytes );
@ -925,7 +940,9 @@ void idPVS::Init()
numPortals = GetPortalCount(); numPortals = GetPortalCount();
portalVisBytes = ( ( ( numPortals + 31 )&~31 ) >> 3 ); portalVisBytes = ( ( ( numPortals + 31 )&~31 ) >> 3 );
portalVisLongs = portalVisBytes / sizeof( long ); // RB: 64 bit fixes, changed long to int
portalVisLongs = portalVisBytes / sizeof( int );
// RB end
for( int i = 0; i < MAX_CURRENT_PVS; i++ ) for( int i = 0; i < MAX_CURRENT_PVS; i++ )
{ {
@ -1147,7 +1164,9 @@ pvsHandle_t idPVS::SetupCurrentPVS( const int* sourceAreas, const int numSourceA
{ {
int i, j; int i, j;
unsigned int h; unsigned int h;
long* vis, *pvs; // RB: 64 bit fixes, changed long to int
int* vis, *pvs;
// RB end
pvsHandle_t handle; pvsHandle_t handle;
h = 0; h = 0;
@ -1172,8 +1191,10 @@ pvsHandle_t idPVS::SetupCurrentPVS( const int* sourceAreas, const int numSourceA
assert( sourceAreas[i] >= 0 && sourceAreas[i] < numAreas ); assert( sourceAreas[i] >= 0 && sourceAreas[i] < numAreas );
vis = reinterpret_cast<long*>( areaPVS + sourceAreas[i] * areaVisBytes ); // RB: 64 bit fixes, changed long to int
pvs = reinterpret_cast<long*>( currentPVS[handle.i].pvs ); vis = reinterpret_cast<int*>( areaPVS + sourceAreas[i] * areaVisBytes );
pvs = reinterpret_cast<int*>( currentPVS[handle.i].pvs );
// RB end
for( j = 0; j < areaVisLongs; j++ ) for( j = 0; j < areaVisLongs; j++ )
{ {
*pvs++ |= *vis++; *pvs++ |= *vis++;
@ -1221,7 +1242,9 @@ idPVS::MergeCurrentPVS
pvsHandle_t idPVS::MergeCurrentPVS( pvsHandle_t pvs1, pvsHandle_t pvs2 ) const pvsHandle_t idPVS::MergeCurrentPVS( pvsHandle_t pvs1, pvsHandle_t pvs2 ) const
{ {
int i; int i;
long* pvs1Ptr, *pvs2Ptr, *ptr; // RB: 64 bit fixes, changed long to int
int* pvs1Ptr, *pvs2Ptr, *ptr;
// RB end
pvsHandle_t handle = { 0 }; pvsHandle_t handle = { 0 };
if( pvs1.i < 0 || pvs1.i >= MAX_CURRENT_PVS || pvs1.h != currentPVS[pvs1.i].handle.h || if( pvs1.i < 0 || pvs1.i >= MAX_CURRENT_PVS || pvs1.h != currentPVS[pvs1.i].handle.h ||
@ -1233,9 +1256,11 @@ pvsHandle_t idPVS::MergeCurrentPVS( pvsHandle_t pvs1, pvsHandle_t pvs2 ) const
handle = AllocCurrentPVS( pvs1.h ^ pvs2.h ); handle = AllocCurrentPVS( pvs1.h ^ pvs2.h );
ptr = reinterpret_cast<long*>( currentPVS[handle.i].pvs ); // RB: 64 bit fixes, changed long to int
pvs1Ptr = reinterpret_cast<long*>( currentPVS[pvs1.i].pvs ); ptr = reinterpret_cast<int*>( currentPVS[handle.i].pvs );
pvs2Ptr = reinterpret_cast<long*>( currentPVS[pvs2.i].pvs ); pvs1Ptr = reinterpret_cast<int*>( currentPVS[pvs1.i].pvs );
pvs2Ptr = reinterpret_cast<int*>( currentPVS[pvs2.i].pvs );
// RB end
for( i = 0; i < areaVisLongs; i++ ) for( i = 0; i < areaVisLongs; i++ )
{ {

View file

@ -267,7 +267,9 @@ idDict::Checksum
*/ */
int idDict::Checksum() const int idDict::Checksum() const
{ {
unsigned long ret; // RB: 64 bit fixes, changed long to int
unsigned int ret;
// RB end
int i, n; int i, n;
idList<idKeyValue> sorted = args; idList<idKeyValue> sorted = args;

View file

@ -12,7 +12,9 @@
#ifdef CREATE_CRC_TABLE #ifdef CREATE_CRC_TABLE
static unsigned long crctable[256]; // RB: 64 bit fix, changed long to int
static unsigned int id_crctable[256];
// RB end
/* /*
Generate a table for a byte-wise 32-bit CRC calculation on the polynomial: Generate a table for a byte-wise 32-bit CRC calculation on the polynomial:
@ -39,10 +41,13 @@ static unsigned long crctable[256];
combinations of CRC register values and incoming bytes. combinations of CRC register values and incoming bytes.
*/ */
void make_crc_table( void ) static void id_make_crc_table()
{ {
int i, j; int i, j;
unsigned long c, poly; // RB: 64 bit fix, changed long to int
unsigned int c, poly;
// RB end
/* terms of polynomial defining this crc (except x^32): */ /* terms of polynomial defining this crc (except x^32): */
static const byte p[] = {0, 1, 2, 4, 5, 7, 8, 10, 11, 12, 16, 22, 23, 26}; static const byte p[] = {0, 1, 2, 4, 5, 7, 8, 10, 11, 12, 16, 22, 23, 26};
@ -55,7 +60,9 @@ void make_crc_table( void )
for( i = 0; i < 256; i++ ) for( i = 0; i < 256; i++ )
{ {
c = ( unsigned long )i; // RB: 64 bit fix, changed long to int
c = ( unsigned int )i;
// RB end
for( j = 0; j < 8; j++ ) for( j = 0; j < 8; j++ )
{ {
c = ( c & 1 ) ? poly ^ ( c >> 1 ) : ( c >> 1 ); c = ( c & 1 ) ? poly ^ ( c >> 1 ) : ( c >> 1 );
@ -69,8 +76,10 @@ void make_crc_table( void )
/* /*
Table of CRC-32's of all single-byte values (made by make_crc_table) Table of CRC-32's of all single-byte values (made by make_crc_table)
*/ */
static unsigned long crctable[256] = // RB: 64 bit fix, changed long to int
static unsigned int id_crctable[256] =
{ {
// RB end
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL,
0x076dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x076dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L,
0x0edb8832L, 0x79dcb8a4L, 0xe0d5e91eL, 0x97d2d988L, 0x0edb8832L, 0x79dcb8a4L, 0xe0d5e91eL, 0x97d2d988L,
@ -139,40 +148,42 @@ static unsigned long crctable[256] =
#endif #endif
void CRC32_InitChecksum( unsigned long& crcvalue ) // RB: 64 bit fixes, changed long to int
void CRC32_InitChecksum( unsigned int& crcvalue )
{ {
crcvalue = CRC32_INIT_VALUE; crcvalue = CRC32_INIT_VALUE;
} }
void CRC32_Update( unsigned long& crcvalue, const byte data ) void CRC32_Update( unsigned int& crcvalue, const byte data )
{ {
crcvalue = crctable[( crcvalue ^ data ) & 0xff ] ^ ( crcvalue >> 8 ); crcvalue = id_crctable[( crcvalue ^ data ) & 0xff ] ^ ( crcvalue >> 8 );
} }
void CRC32_UpdateChecksum( unsigned long& crcvalue, const void* data, int length ) void CRC32_UpdateChecksum( unsigned int& crcvalue, const void* data, int length )
{ {
unsigned long crc; unsigned int crc;
const unsigned char* buf = ( const unsigned char* ) data; const unsigned char* buf = ( const unsigned char* ) data;
crc = crcvalue; crc = crcvalue;
while( length-- ) while( length-- )
{ {
crc = crctable[( crc ^ ( *buf++ ) ) & 0xff ] ^ ( crc >> 8 ); crc = id_crctable[( crc ^ ( *buf++ ) ) & 0xff ] ^ ( crc >> 8 );
} }
crcvalue = crc; crcvalue = crc;
} }
void CRC32_FinishChecksum( unsigned long& crcvalue ) void CRC32_FinishChecksum( unsigned int& crcvalue )
{ {
crcvalue ^= CRC32_XOR_VALUE; crcvalue ^= CRC32_XOR_VALUE;
} }
unsigned long CRC32_BlockChecksum( const void* data, int length ) unsigned int CRC32_BlockChecksum( const void* data, int length )
{ {
unsigned long crc; unsigned int crc;
CRC32_InitChecksum( crc ); CRC32_InitChecksum( crc );
CRC32_UpdateChecksum( crc, data, length ); CRC32_UpdateChecksum( crc, data, length );
CRC32_FinishChecksum( crc ); CRC32_FinishChecksum( crc );
return crc; return crc;
} }
// RB end

View file

@ -10,9 +10,11 @@
=============================================================================== ===============================================================================
*/ */
void CRC32_InitChecksum( unsigned long& crcvalue ); // RB: 64 bit fixes, changed long to int
void CRC32_UpdateChecksum( unsigned long& crcvalue, const void* data, int length ); void CRC32_InitChecksum( unsigned int& crcvalue );
void CRC32_FinishChecksum( unsigned long& crcvalue ); void CRC32_UpdateChecksum( unsigned int& crcvalue, const void* data, int length );
unsigned long CRC32_BlockChecksum( const void* data, int length ); void CRC32_FinishChecksum( unsigned int& crcvalue );
unsigned int CRC32_BlockChecksum( const void* data, int length );
// RB end
#endif /* !__CRC32_H__ */ #endif /* !__CRC32_H__ */

View file

@ -38,7 +38,10 @@ typedef unsigned char* POINTER;
typedef unsigned short int UINT2; typedef unsigned short int UINT2;
/* UINT4 defines a four byte word */ /* UINT4 defines a four byte word */
typedef unsigned long int UINT4; // RB: 64 bit fix, changed long int to int
typedef unsigned int UINT4;
// RB end
/* MD4 context. */ /* MD4 context. */
typedef struct typedef struct
@ -259,10 +262,11 @@ void MD4_Final( MD4_CTX* context, unsigned char digest[16] )
MD4_BlockChecksum MD4_BlockChecksum
=============== ===============
*/ */
unsigned long MD4_BlockChecksum( const void* data, int length ) // RB: 64 bit fixes, changed long to int
unsigned int MD4_BlockChecksum( const void* data, int length )
{ {
unsigned long digest[4]; unsigned int digest[4];
unsigned long val; unsigned int val;
MD4_CTX ctx; MD4_CTX ctx;
MD4_Init( &ctx ); MD4_Init( &ctx );
@ -273,3 +277,5 @@ unsigned long MD4_BlockChecksum( const void* data, int length )
return val; return val;
} }
// RB end

View file

@ -10,6 +10,8 @@
=============================================================================== ===============================================================================
*/ */
unsigned long MD4_BlockChecksum( const void* data, int length ); // RB: 64 bit fix, changed long to int
unsigned int MD4_BlockChecksum( const void* data, int length );
// RB end
#endif /* !__MD4_H__ */ #endif /* !__MD4_H__ */

View file

@ -32,7 +32,10 @@ If you have questions concerning this license or the applicable additional terms
uint32 SnapObjChecksum( const uint8* data, int length ) uint32 SnapObjChecksum( const uint8* data, int length )
{ {
extern unsigned long CRC32_BlockChecksum( const void * data, int length ); // RB: 64 bit fixes, changed long to int
extern unsigned int CRC32_BlockChecksum( const void * data, int length );
// RB end
return CRC32_BlockChecksum( data, length ); return CRC32_BlockChecksum( data, length );
} }

View file

@ -53,7 +53,9 @@ idCVar net_ignoreConnects( "net_ignoreConnects", "0", CVAR_INTEGER, "Test as if
idCVar net_skipGoodbye( "net_skipGoodbye", "0", CVAR_BOOL, "" ); idCVar net_skipGoodbye( "net_skipGoodbye", "0", CVAR_BOOL, "" );
extern unsigned long NetGetVersionChecksum(); // RB: 64 bit fixes, changed long to int
extern unsigned int NetGetVersionChecksum();
// RB end
/* /*
======================== ========================

View file

@ -97,12 +97,13 @@ struct netVersion_s
NetGetVersionChecksum NetGetVersionChecksum
======================== ========================
*/ */
unsigned long NetGetVersionChecksum() // RB: 64 bit fixes, changed long to int
unsigned int NetGetVersionChecksum()
{ {
#if 0 #if 0
return idStr( com_version.GetString() ).Hash(); return idStr( com_version.GetString() ).Hash();
#else #else
unsigned long ret = 0; unsigned int ret = 0;
CRC32_InitChecksum( ret ); CRC32_InitChecksum( ret );
CRC32_UpdateChecksum( ret, netVersion.string, idStr::Length( netVersion.string ) ); CRC32_UpdateChecksum( ret, netVersion.string, idStr::Length( netVersion.string ) );
@ -113,6 +114,7 @@ unsigned long NetGetVersionChecksum()
return ret; return ret;
#endif #endif
} }
// RB end
/* /*
======================== ========================