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

View file

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

View file

@ -12,7 +12,9 @@
#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:
@ -39,10 +41,13 @@ static unsigned long crctable[256];
combinations of CRC register values and incoming bytes.
*/
void make_crc_table( void )
static void id_make_crc_table()
{
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): */
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++ )
{
c = ( unsigned long )i;
// RB: 64 bit fix, changed long to int
c = ( unsigned int )i;
// RB end
for( j = 0; j < 8; j++ )
{
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)
*/
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,
0x076dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L,
0x0edb8832L, 0x79dcb8a4L, 0xe0d5e91eL, 0x97d2d988L,
@ -139,40 +148,42 @@ static unsigned long crctable[256] =
#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;
}
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;
crc = crcvalue;
while( length-- )
{
crc = crctable[( crc ^ ( *buf++ ) ) & 0xff ] ^ ( crc >> 8 );
crc = id_crctable[( crc ^ ( *buf++ ) ) & 0xff ] ^ ( crc >> 8 );
}
crcvalue = crc;
}
void CRC32_FinishChecksum( unsigned long& crcvalue )
void CRC32_FinishChecksum( unsigned int& crcvalue )
{
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_UpdateChecksum( crc, data, length );
CRC32_FinishChecksum( crc );
return crc;
}
// RB end

View file

@ -10,9 +10,11 @@
===============================================================================
*/
void CRC32_InitChecksum( unsigned long& crcvalue );
void CRC32_UpdateChecksum( unsigned long& crcvalue, const void* data, int length );
void CRC32_FinishChecksum( unsigned long& crcvalue );
unsigned long CRC32_BlockChecksum( const void* data, int length );
// RB: 64 bit fixes, changed long to int
void CRC32_InitChecksum( unsigned int& crcvalue );
void CRC32_UpdateChecksum( unsigned int& crcvalue, 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__ */

View file

@ -38,7 +38,10 @@ typedef unsigned char* POINTER;
typedef unsigned short int UINT2;
/* 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. */
typedef struct
@ -259,10 +262,11 @@ void MD4_Final( MD4_CTX* context, unsigned char digest[16] )
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 long val;
unsigned int digest[4];
unsigned int val;
MD4_CTX ctx;
MD4_Init( &ctx );
@ -273,3 +277,5 @@ unsigned long MD4_BlockChecksum( const void* data, int length )
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__ */

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 )
{
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 );
}

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, "" );
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
========================
*/
unsigned long NetGetVersionChecksum()
// RB: 64 bit fixes, changed long to int
unsigned int NetGetVersionChecksum()
{
#if 0
return idStr( com_version.GetString() ).Hash();
#else
unsigned long ret = 0;
unsigned int ret = 0;
CRC32_InitChecksum( ret );
CRC32_UpdateChecksum( ret, netVersion.string, idStr::Length( netVersion.string ) );
@ -113,6 +114,7 @@ unsigned long NetGetVersionChecksum()
return ret;
#endif
}
// RB end
/*
========================