eliminate more longs

for 64bit compatibility.
This commit is contained in:
Daniel Gibson 2012-12-11 23:04:53 +01:00
parent 86deed26b8
commit ee88148bd1
20 changed files with 94 additions and 66 deletions

View file

@ -83,8 +83,10 @@ typedef struct cm_vertex_s
{
idVec3 p; // vertex point
int checkcount; // for multi-check avoidance
unsigned long side; // each bit tells at which side this vertex passes one of the trace model edges
unsigned long sideSet; // each bit tells if sidedness for the trace model edge has been calculated yet
// DG: use int instead of long for 64bit compatibility
unsigned int side; // each bit tells at which side this vertex passes one of the trace model edges
unsigned int sideSet; // each bit tells if sidedness for the trace model edge has been calculated yet
// DG end
} cm_vertex_t;
typedef struct cm_edge_s
@ -92,8 +94,10 @@ typedef struct cm_edge_s
int checkcount; // for multi-check avoidance
unsigned short internal; // a trace model can never collide with internal edges
unsigned short numUsers; // number of polygons using this edge
unsigned long side; // each bit tells at which side of this edge one of the trace model vertices passes
unsigned long sideSet; // each bit tells if sidedness for the trace model vertex has been calculated yet
// DG: use int instead of long for 64bit compatibility
unsigned int side; // each bit tells at which side of this edge one of the trace model vertices passes
unsigned int sideSet; // each bit tells if sidedness for the trace model vertex has been calculated yet
// DG end
int vertexNum[2]; // start and end point of edge
idVec3 normal; // edge normal
} cm_edge_t;

View file

@ -104,9 +104,9 @@ private:
mutable pvsCurrent_t currentPVS[MAX_CURRENT_PVS];
// used to create PVS
int portalVisBytes;
int portalVisLongs;
int portalVisLongs; // DG: Note: these are really ints now..
int areaVisBytes;
int areaVisLongs;
int areaVisLongs; // DG: Note: these are really ints now..
struct pvsPortal_s* pvsPortals;
struct pvsArea_s* pvsAreas;

View file

@ -312,7 +312,9 @@ idClass::FindUninitializedMemory
void idClass::FindUninitializedMemory()
{
#ifdef ID_DEBUG_UNINITIALIZED_MEMORY
unsigned long* ptr = ( ( unsigned long* )this ) - 1;
// DG: use int instead of long for 64bit compatibility
unsigned int* ptr = ( ( unsigned int* )this ) - 1;
// DG end
int size = *ptr;
assert( ( size & 3 ) == 0 );
size >>= 2;

View file

@ -1726,7 +1726,9 @@ idCompressor_Arithmetic::GetCurrentCount
*/
int idCompressor_Arithmetic::GetCurrentCount()
{
return ( unsigned int )( ( ( ( ( long ) code - low ) + 1 ) * scale - 1 ) / ( ( ( long ) high - low ) + 1 ) );
// DG: use int instead of long for 64bit compatibility
return ( unsigned int )( ( ( ( ( int ) code - low ) + 1 ) * scale - 1 ) / ( ( ( int ) high - low ) + 1 ) );
// DG end
}
/*
@ -1805,9 +1807,11 @@ idCompressor_Arithmetic::RemoveSymbolFromStream
*/
void idCompressor_Arithmetic::RemoveSymbolFromStream( acSymbol_t* symbol )
{
long range;
// DG: use int instead of long for 64bit compatibility
int range;
range = ( long )( high - low ) + 1;
range = ( int )( high - low ) + 1;
// DG end
high = low + ( unsigned short )( ( range * symbol->high ) / scale - 1 );
low = low + ( unsigned short )( ( range * symbol->low ) / scale );

View file

@ -286,7 +286,7 @@ typedef struct huffmanNode_s
typedef struct huffmanCode_s
{
unsigned long bits[8];
unsigned int bits[8]; // DG: use int instead of long for 64bit compatibility
int numBits;
} huffmanCode_t;
@ -2721,4 +2721,4 @@ idDeclLocal::EverReferenced
bool idDeclLocal::EverReferenced() const
{
return everReferenced;
}
}

View file

@ -39,8 +39,9 @@ FS_WriteFloatString
*/
int FS_WriteFloatString( char* buf, const char* fmt, va_list argPtr )
{
long i;
unsigned long u;
// DG: replaced long with int for 64bit compatibility in the whole function
int i;
unsigned int u;
double f;
char* str;
int index;
@ -84,27 +85,27 @@ int FS_WriteFloatString( char* buf, const char* fmt, va_list argPtr )
break;
case 'd':
case 'i':
i = va_arg( argPtr, long );
i = va_arg( argPtr, int );
index += sprintf( buf + index, format.c_str(), i );
break;
case 'u':
u = va_arg( argPtr, unsigned long );
u = va_arg( argPtr, unsigned int );
index += sprintf( buf + index, format.c_str(), u );
break;
case 'o':
u = va_arg( argPtr, unsigned long );
u = va_arg( argPtr, unsigned int );
index += sprintf( buf + index, format.c_str(), u );
break;
case 'x':
u = va_arg( argPtr, unsigned long );
u = va_arg( argPtr, unsigned int );
index += sprintf( buf + index, format.c_str(), u );
break;
case 'X':
u = va_arg( argPtr, unsigned long );
u = va_arg( argPtr, unsigned int );
index += sprintf( buf + index, format.c_str(), u );
break;
case 'c':
i = va_arg( argPtr, long );
i = va_arg( argPtr, int );
index += sprintf( buf + index, format.c_str(), ( char ) i );
break;
case 's':
@ -150,6 +151,7 @@ int FS_WriteFloatString( char* buf, const char* fmt, va_list argPtr )
}
return index;
// DG end
}
/*

View file

@ -2797,7 +2797,7 @@ void idFileSystemLocal::CreateCRCsForResourceFileList( const idFileList& list )
}
// All tables read, now seek to each one and calculate the CRC.
idTempArray< unsigned long > innerFileCRCs( numFileResources );
idTempArray< unsigned int > innerFileCRCs( numFileResources ); // DG: use int instead of long for 64bit compatibility
for( int innerFileIndex = 0; innerFileIndex < numFileResources; ++innerFileIndex )
{
const char* innerFileDataBegin = currentFile->GetDataPtr() + cacheEntries[innerFileIndex].offset;
@ -2806,7 +2806,7 @@ void idFileSystemLocal::CreateCRCsForResourceFileList( const idFileList& list )
}
// Get the CRC for all the CRCs.
const unsigned long totalCRC = CRC32_BlockChecksum( innerFileCRCs.Ptr(), innerFileCRCs.Size() );
const unsigned int totalCRC = CRC32_BlockChecksum( innerFileCRCs.Ptr(), innerFileCRCs.Size() ); // DG: use int instead of long for 64bit compatibility
// Write the .crc file corresponding to the .resources file.
idStr crcFilename = list.GetFile( fileIndex );

View file

@ -44,7 +44,7 @@ static const char sixtet_to_base64[] =
void idBase64::Encode( const byte* from, int size )
{
int i, j;
unsigned long w;
unsigned int w; // DG: use int instead of long for 64bit compatibility
byte* to;
EnsureAlloced( 4 * ( size + 3 ) / 3 + 2 ); // ratio and padding + trailing \0
@ -101,7 +101,7 @@ idBase64::Decode
*/
int idBase64::Decode( byte* to ) const
{
unsigned long w;
unsigned int w; // DG: use int instead of long for 64bit compatibility
int i, j;
size_t n;
static char base64_to_sixtet[256];

View file

@ -1511,7 +1511,7 @@ typedef struct operator_s
typedef struct value_s
{
signed long int intvalue;
signed int intvalue; // DG: use int instead of long for 64bit compatibility
double floatvalue;
int parentheses;
struct value_s* prev, *next;
@ -1606,7 +1606,7 @@ int PC_OperatorPriority( int op )
#define FreeOperator(op)
int idParser::EvaluateTokens( idToken* tokens, signed long int* intvalue, double* floatvalue, int integer )
int idParser::EvaluateTokens( idToken* tokens, signed int* intvalue, double* floatvalue, int integer )
{
operator_t* o, *firstoperator, *lastoperator;
value_t* v, *firstvalue, *lastvalue, *v1, *v2;
@ -2117,7 +2117,7 @@ int idParser::EvaluateTokens( idToken* tokens, signed long int* intvalue, double
idParser::Evaluate
================
*/
int idParser::Evaluate( signed long int* intvalue, double* floatvalue, int integer )
int idParser::Evaluate( signed int* intvalue, double* floatvalue, int integer )
{
idToken token, *firsttoken, *lasttoken;
idToken* t, *nexttoken;
@ -2224,7 +2224,7 @@ int idParser::Evaluate( signed long int* intvalue, double* floatvalue, int integ
idParser::DollarEvaluate
================
*/
int idParser::DollarEvaluate( signed long int* intvalue, double* floatvalue, int integer )
int idParser::DollarEvaluate( signed int* intvalue, double* floatvalue, int integer )
{
int indent, defined = false;
idToken token, *firsttoken, *lasttoken;
@ -2345,7 +2345,7 @@ idParser::Directive_elif
*/
int idParser::Directive_elif()
{
signed long int value;
signed int value; // DG: use int instead of long for 64bit compatibility
int type, skip;
idParser::PopIndent( &type, &skip );
@ -2370,7 +2370,7 @@ idParser::Directive_if
*/
int idParser::Directive_if()
{
signed long int value;
signed int value; // DG: use int instead of long for 64bit compatibility
int skip;
if( !idParser::Evaluate( &value, NULL, true ) )
@ -2477,7 +2477,7 @@ idParser::Directive_eval
*/
int idParser::Directive_eval()
{
signed long int value;
signed int value; // DG: use int instead of long for 64bit compatibility
idToken token;
char buf[128];
@ -2644,7 +2644,7 @@ idParser::DollarDirective_evalint
*/
int idParser::DollarDirective_evalint()
{
signed long int value;
signed int value; // DG: use int instead of long for 64bit compatibility
idToken token;
char buf[128];
@ -2697,7 +2697,7 @@ int idParser::DollarDirective_evalfloat()
token = buf;
token.type = TT_NUMBER;
token.subtype = TT_FLOAT | TT_LONG | TT_DECIMAL | TT_VALUESVALID;
token.intvalue = ( unsigned long ) fabs( value );
token.intvalue = ( unsigned int ) fabs( value ); // DG: use int instead of long for 64bit compatibility
token.floatvalue = fabs( value );
idParser::UnreadSourceToken( &token );
if( value < 0 )

View file

@ -232,9 +232,11 @@ private:
int Directive_ifndef();
int Directive_else();
int Directive_endif();
int EvaluateTokens( idToken* tokens, signed long int* intvalue, double* floatvalue, int integer );
int Evaluate( signed long int* intvalue, double* floatvalue, int integer );
int DollarEvaluate( signed long int* intvalue, double* floatvalue, int integer );
// DG: use int instead of long for 64bit compatibility
int EvaluateTokens( idToken* tokens, signed int* intvalue, double* floatvalue, int integer );
int Evaluate( signed int* intvalue, double* floatvalue, int integer );
int DollarEvaluate( signed int* intvalue, double* floatvalue, int integer );
// DG end
int Directive_define();
int Directive_elif();
int Directive_if();

View file

@ -1043,7 +1043,7 @@ idStr::FileNameHash
int idStr::FileNameHash() const
{
int i;
long hash;
int hash; // DG: use int instead of long for 64bit compatibility
char letter;
hash = 0;
@ -1059,7 +1059,7 @@ int idStr::FileNameHash() const
{
letter = '/';
}
hash += ( long )( letter ) * ( i + 119 );
hash += ( long )( letter ) * ( i + 119 ); // DG: use int instead of long for 64bit compatibility
i++;
}
hash &= ( FILE_HASH_SIZE - 1 );

View file

@ -99,7 +99,9 @@ public:
void NumberValue(); // calculate values for a TT_NUMBER
private:
unsigned long intvalue; // integer value
// DG: use int instead of long for 64bit compatibility
unsigned int intvalue; // integer value
// DG end
double floatvalue; // floating point value
const char* whiteSpaceStart_p; // start of white space before token, only used by idLexer
const char* whiteSpaceEnd_p; // end of white space before token, only used by idLexer

View file

@ -108,10 +108,11 @@ ID_INLINE float idRandom::CRandomFloat()
class idRandom2
{
public:
idRandom2( unsigned long seed = 0 );
// DG: use int instead of long for 64bit compatibility in this whole class
idRandom2( unsigned int seed = 0 );
void SetSeed( unsigned long seed );
unsigned long GetSeed() const;
void SetSeed( unsigned int seed );
unsigned int GetSeed() const;
int RandomInt(); // random integer in the range [0, MAX_RAND]
int RandomInt( int max ); // random integer in the range [0, max]
@ -121,23 +122,23 @@ public:
static const int MAX_RAND = 0x7fff;
private:
unsigned long seed;
unsigned int seed;
static const unsigned long IEEE_ONE = 0x3f800000;
static const unsigned long IEEE_MASK = 0x007fffff;
static const unsigned int IEEE_ONE = 0x3f800000;
static const unsigned int IEEE_MASK = 0x007fffff;
};
ID_INLINE idRandom2::idRandom2( unsigned long seed )
ID_INLINE idRandom2::idRandom2( unsigned int seed )
{
this->seed = seed;
}
ID_INLINE void idRandom2::SetSeed( unsigned long seed )
ID_INLINE void idRandom2::SetSeed( unsigned int seed )
{
this->seed = seed;
}
ID_INLINE unsigned long idRandom2::GetSeed() const
ID_INLINE unsigned int idRandom2::GetSeed() const
{
return seed;
}
@ -159,7 +160,7 @@ ID_INLINE int idRandom2::RandomInt( int max )
ID_INLINE float idRandom2::RandomFloat()
{
unsigned long i;
unsigned int i;
seed = 1664525L * seed + 1013904223L;
i = idRandom2::IEEE_ONE | ( seed & idRandom2::IEEE_MASK );
return ( ( *( float* )&i ) - 1.0f );
@ -167,10 +168,11 @@ ID_INLINE float idRandom2::RandomFloat()
ID_INLINE float idRandom2::CRandomFloat()
{
unsigned long i;
unsigned int i;
seed = 1664525L * seed + 1013904223L;
i = idRandom2::IEEE_ONE | ( seed & idRandom2::IEEE_MASK );
return ( 2.0f * ( *( float* )&i ) - 3.0f );
}
// DG end
#endif /* !__MATH_RANDOM_H__ */

View file

@ -124,7 +124,7 @@ void idSIMD::Shutdown() {
idSIMDProcessor *p_simd;
idSIMDProcessor *p_generic;
long baseClocks = 0;
int baseClocks = 0; // DG: use int instead of long for 64bit compatibility
#if defined(_MSC_VER) && defined(_M_IX86)
#define TIME_TYPE int

View file

@ -280,13 +280,17 @@ void VPCALL idSIMD_SSE::BlendJoints( idJointQuat* joints, const idJointQuat* ble
float omega;
float scale0;
float scale1;
unsigned long signBit;
// DG: use int instead of long for 64bit compatibility
unsigned int signBit;
// DG end
cosom = jointQuat.x * blendQuat.x + jointQuat.y * blendQuat.y + jointQuat.z * blendQuat.z + jointQuat.w * blendQuat.w;
signBit = ( *( unsigned long* )&cosom ) & ( 1 << 31 );
// DG: use int instead of long for 64bit compatibility
signBit = ( *( unsigned int* )&cosom ) & ( 1 << 31 );
( *( unsigned long* )&cosom ) ^= signBit;
( *( unsigned int* )&cosom ) ^= signBit;
// DG end
scale0 = 1.0f - cosom * cosom;
scale0 = ( scale0 <= 0.0f ) ? 1e-10f : scale0;
@ -295,7 +299,7 @@ void VPCALL idSIMD_SSE::BlendJoints( idJointQuat* joints, const idJointQuat* ble
scale0 = idMath::Sin16( ( 1.0f - lerp ) * omega ) * sinom;
scale1 = idMath::Sin16( lerp * omega ) * sinom;
( *( unsigned long* )&scale1 ) ^= signBit;
( *( unsigned int* )&scale1 ) ^= signBit; // DG: use int instead of long for 64bit compatibility
jointQuat.x = scale0 * jointQuat.x + scale1 * blendQuat.x;
jointQuat.y = scale0 * jointQuat.y + scale1 * blendQuat.y;

View file

@ -40,7 +40,7 @@ typedef unsigned char byte; // 8 bits
typedef unsigned short word; // 16 bits
typedef unsigned int dword; // 32 bits
typedef unsigned int uint;
typedef unsigned long ulong;
// typedef unsigned long ulong; // DG: long should be avoided.
typedef signed char int8;
typedef unsigned char uint8;

View file

@ -1573,7 +1573,7 @@ void idLobby::SendConnectionRequest()
idBitMsg msg( buffer, sizeof( buffer ) );
// Add the current version info to the handshake
const unsigned long localChecksum = NetGetVersionChecksum();
const unsigned int localChecksum = NetGetVersionChecksum(); // DG: use int instead of long for 64bit compatibility
NET_VERBOSE_PRINT( "NET: version = %i\n", localChecksum );
@ -1754,11 +1754,11 @@ idLobby::CheckVersion
*/
bool idLobby::CheckVersion( idBitMsg& msg, lobbyAddress_t peerAddress )
{
const unsigned long remoteChecksum = msg.ReadLong();
const unsigned int remoteChecksum = msg.ReadLong(); // DG: use int instead of long for 64bit compatibility
if( net_checkVersion.GetInteger() == 1 )
{
const unsigned long localChecksum = NetGetVersionChecksum();
const unsigned int localChecksum = NetGetVersionChecksum(); // DG: use int instead of long for 64bit compatibility
NET_VERBOSE_PRINT( "NET: Comparing handshake version - localChecksum = %i, remoteChecksum = %i\n", localChecksum, remoteChecksum );
return ( remoteChecksum == localChecksum );
@ -2312,7 +2312,9 @@ uint32 idLobby::GetPartyTokenAsHost()
{
// I don't know if this is mathematically sound, but it seems reasonable.
// Don't do this at app startup (i.e. in the constructor) or it will be a lot less random.
unsigned long seed = Sys_Milliseconds(); // time app has been running
// DG: use int instead of long for 64bit compatibility
unsigned int seed = Sys_Milliseconds(); // time app has been running
// DG end
idLocalUser* masterUser = session->GetSignInManager().GetMasterLocalUser();
if( masterUser != NULL )
{
@ -2865,7 +2867,7 @@ void idLobby::HandleReliableMsg( int p, idBitMsg& msg )
// This message is sent from the peers to state they are done loading the map
VERIFY_CONNECTED_PEER( p, actingGameStateLobbyType, RELIABLE_LOADING_DONE );
unsigned long networkChecksum = 0;
unsigned int networkChecksum = 0; // DG: use int instead of long for 64bit compatibility
networkChecksum = msg.ReadLong();
peer.networkChecksum = networkChecksum;

View file

@ -334,7 +334,9 @@ public:
int lastProcTime; // Used to determine when a packet was processed for sending to this peer
int lastInBandProcTime; // Last time a in-band packet was processed for sending
int lastFragmentSendTime; // Last time a fragment was sent out (fragments are processed msg's, waiting to be fully sent)
unsigned long networkChecksum; // Checksum used to determine if a peer loaded the network resources the EXACT same as the server did
// DG: use int instead of long for 64bit compatibility
unsigned int networkChecksum; // Checksum used to determine if a peer loaded the network resources the EXACT same as the server did
// DG end
int pauseSnapshots;
lobbyAddress_t address;

View file

@ -426,7 +426,7 @@ struct sysMemoryStats_t
int availExtendedVirtual;
};
typedef unsigned long address_t;
// typedef unsigned long address_t; // DG: this isn't even used
void Sys_Init();
void Sys_Shutdown();

View file

@ -4592,7 +4592,7 @@ void idSessionLocal::ListServersCommon()
idBitMsg msg( buffer, sizeof( buffer ) );
// Add the current version info to the query
const unsigned long localChecksum = NetGetVersionChecksum();
const unsigned int localChecksum = NetGetVersionChecksum(); // DG: use int instead of long for 64bit compatibility
NET_VERBOSE_PRINT( "ListServers: Hash checksum: %i, broadcasting to: %s\n", localChecksum, address.ToString() );
@ -4614,8 +4614,10 @@ void idSessionLocal::HandleDedicatedServerQueryRequest( lobbyAddress_t& remoteAd
bool canJoin = true;
const unsigned long localChecksum = NetGetVersionChecksum();
const unsigned long remoteChecksum = msg.ReadLong();
// DG: use int instead of long for 64bit compatibility
const unsigned int localChecksum = NetGetVersionChecksum();
const unsigned int remoteChecksum = msg.ReadLong();
// DG end
if( remoteChecksum != localChecksum )
{