mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-01-18 23:41:42 +00:00
Merged 64 bit fixes.
This commit is contained in:
parent
2952f227ea
commit
86deed26b8
12 changed files with 131 additions and 76 deletions
|
@ -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++ )
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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__ */
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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__ */
|
||||
|
|
|
@ -156,15 +156,15 @@ void Sys_Yield()
|
|||
idSysSignal::idSysSignal( bool manualReset )
|
||||
{
|
||||
pthread_mutexattr_t attr;
|
||||
|
||||
|
||||
//pthread_mutexattr_init( &attr );
|
||||
pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_ERRORCHECK );
|
||||
pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_DEFAULT );
|
||||
pthread_mutex_init( &mutex, &attr );
|
||||
pthread_mutexattr_destroy( &attr );
|
||||
|
||||
|
||||
pthread_cond_init( &cond, NULL );
|
||||
|
||||
|
||||
signaled = false;
|
||||
waiting = false;
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ idSysSignal::~idSysSignal()
|
|||
void idSysSignal::Raise()
|
||||
{
|
||||
pthread_mutex_lock( &mutex );
|
||||
|
||||
|
||||
if( waiting )
|
||||
{
|
||||
pthread_cond_signal( &cond );
|
||||
|
@ -187,16 +187,16 @@ void idSysSignal::Raise()
|
|||
// emulate Windows behaviour: if no thread is waiting, leave the signal on so next wait keeps going
|
||||
signaled = true;
|
||||
}
|
||||
|
||||
|
||||
pthread_mutex_unlock( &mutex );
|
||||
}
|
||||
|
||||
void idSysSignal::Clear()
|
||||
{
|
||||
pthread_mutex_lock( &mutex );
|
||||
|
||||
|
||||
signaled = false;
|
||||
|
||||
|
||||
pthread_mutex_unlock( &mutex );
|
||||
}
|
||||
|
||||
|
@ -206,29 +206,29 @@ void idSysSignal::Clear()
|
|||
bool idSysSignal::Wait( int timeout )
|
||||
{
|
||||
pthread_mutex_lock( &mutex );
|
||||
|
||||
|
||||
//DWORD result = WaitForSingleObject( handle, timeout == idSysSignal::WAIT_INFINITE ? INFINITE : timeout );
|
||||
//assert( result == WAIT_OBJECT_0 || ( timeout != idSysSignal::WAIT_INFINITE && result == WAIT_TIMEOUT ) );
|
||||
//return ( result == WAIT_OBJECT_0 );
|
||||
|
||||
|
||||
int result = 0;
|
||||
|
||||
|
||||
/*
|
||||
Return Value
|
||||
|
||||
|
||||
Except in the case of [ETIMEDOUT], all these error checks shall act as if they were performed immediately at the beginning of processing for the function and shall cause an error return, in effect, prior to modifying the state of the mutex specified by mutex or the condition variable specified by cond.
|
||||
|
||||
|
||||
Upon successful completion, a value of zero shall be returned; otherwise, an error number shall be returned to indicate the error.
|
||||
|
||||
|
||||
Errors
|
||||
|
||||
|
||||
The pthread_cond_timedwait() function shall fail if:
|
||||
|
||||
|
||||
ETIMEDOUT
|
||||
The time specified by abstime to pthread_cond_timedwait() has passed.
|
||||
|
||||
|
||||
The pthread_cond_timedwait() and pthread_cond_wait() functions may fail if:
|
||||
|
||||
|
||||
EINVAL
|
||||
The value specified by cond, mutex, or abstime is invalid.
|
||||
EINVAL
|
||||
|
@ -236,7 +236,7 @@ bool idSysSignal::Wait( int timeout )
|
|||
EPERM
|
||||
The mutex was not owned by the current thread at the time of the call.
|
||||
*/
|
||||
|
||||
|
||||
assert( !waiting ); // WaitForEvent from multiple threads? that wouldn't be good
|
||||
if( signaled )
|
||||
{
|
||||
|
@ -253,26 +253,26 @@ bool idSysSignal::Wait( int timeout )
|
|||
if( timeout == WAIT_INFINITE )
|
||||
{
|
||||
result = pthread_cond_wait( &cond, &mutex );
|
||||
|
||||
|
||||
assert( result == 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
timespec ts;
|
||||
clock_gettime( CLOCK_REALTIME, &ts );
|
||||
|
||||
|
||||
ts.tv_nsec += ( timeout * 1000000 );
|
||||
|
||||
|
||||
result = pthread_cond_timedwait( &cond, &mutex, &ts );
|
||||
|
||||
|
||||
assert( result == 0 || ( timeout != idSysSignal::WAIT_INFINITE && result == ETIMEDOUT ) );
|
||||
}
|
||||
#endif
|
||||
waiting = false;
|
||||
}
|
||||
|
||||
|
||||
pthread_mutex_unlock( &mutex );
|
||||
|
||||
|
||||
return ( result == 0 );
|
||||
}
|
||||
/*
|
||||
|
|
|
@ -727,11 +727,11 @@ bool R_LoadCubeImages( const char* imgName, cubeFiles_t extensions, byte* pics[6
|
|||
{
|
||||
int i, j;
|
||||
const char* cameraSides[6] = { "_forward.tga", "_back.tga", "_left.tga", "_right.tga",
|
||||
"_up.tga", "_down.tga"
|
||||
};
|
||||
"_up.tga", "_down.tga"
|
||||
};
|
||||
const char* axisSides[6] = { "_px.tga", "_nx.tga", "_py.tga", "_ny.tga",
|
||||
"_pz.tga", "_nz.tga"
|
||||
};
|
||||
"_pz.tga", "_nz.tga"
|
||||
};
|
||||
const char** sides;
|
||||
char fullName[MAX_IMAGE_NAME];
|
||||
int width, height, size = 0;
|
||||
|
|
|
@ -1659,8 +1659,8 @@ void R_MakeAmbientMap_f( const idCmdArgs& args )
|
|||
viewDef_t primary;
|
||||
int downSample;
|
||||
const char* extensions[6] = { "_px.tga", "_nx.tga", "_py.tga", "_ny.tga",
|
||||
"_pz.tga", "_nz.tga"
|
||||
};
|
||||
"_pz.tga", "_nz.tga"
|
||||
};
|
||||
int outSize;
|
||||
byte* buffers[6];
|
||||
int width = 0, height = 0;
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
/*
|
||||
========================
|
||||
|
|
|
@ -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
|
||||
|
||||
/*
|
||||
========================
|
||||
|
|
Loading…
Reference in a new issue