diff --git a/neo/cm/CollisionModel_local.h b/neo/cm/CollisionModel_local.h index 42d12379..d7dce801 100644 --- a/neo/cm/CollisionModel_local.h +++ b/neo/cm/CollisionModel_local.h @@ -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; diff --git a/neo/d3xp/Pvs.h b/neo/d3xp/Pvs.h index 2ed1b94e..2bc1b83f 100644 --- a/neo/d3xp/Pvs.h +++ b/neo/d3xp/Pvs.h @@ -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; diff --git a/neo/d3xp/gamesys/Class.cpp b/neo/d3xp/gamesys/Class.cpp index ac542088..e2ea595d 100644 --- a/neo/d3xp/gamesys/Class.cpp +++ b/neo/d3xp/gamesys/Class.cpp @@ -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; diff --git a/neo/framework/Compressor.cpp b/neo/framework/Compressor.cpp index 4916efa5..e386eb36 100644 --- a/neo/framework/Compressor.cpp +++ b/neo/framework/Compressor.cpp @@ -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 ); diff --git a/neo/framework/DeclManager.cpp b/neo/framework/DeclManager.cpp index bcd3af38..83072a50 100644 --- a/neo/framework/DeclManager.cpp +++ b/neo/framework/DeclManager.cpp @@ -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; -} \ No newline at end of file +} diff --git a/neo/framework/File.cpp b/neo/framework/File.cpp index 183c2b08..426999d2 100644 --- a/neo/framework/File.cpp +++ b/neo/framework/File.cpp @@ -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 } /* diff --git a/neo/framework/FileSystem.cpp b/neo/framework/FileSystem.cpp index 7c3c2d1d..d4353ac6 100644 --- a/neo/framework/FileSystem.cpp +++ b/neo/framework/FileSystem.cpp @@ -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 ); diff --git a/neo/idlib/Base64.cpp b/neo/idlib/Base64.cpp index 570228c3..8c58508c 100644 --- a/neo/idlib/Base64.cpp +++ b/neo/idlib/Base64.cpp @@ -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]; diff --git a/neo/idlib/Parser.cpp b/neo/idlib/Parser.cpp index d3b8c54f..bb5c1c32 100644 --- a/neo/idlib/Parser.cpp +++ b/neo/idlib/Parser.cpp @@ -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 ) diff --git a/neo/idlib/Parser.h b/neo/idlib/Parser.h index cdf44160..70aef498 100644 --- a/neo/idlib/Parser.h +++ b/neo/idlib/Parser.h @@ -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(); diff --git a/neo/idlib/Str.cpp b/neo/idlib/Str.cpp index c3e77b9e..cbddf776 100644 --- a/neo/idlib/Str.cpp +++ b/neo/idlib/Str.cpp @@ -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 ); diff --git a/neo/idlib/Token.h b/neo/idlib/Token.h index fd000548..50254320 100644 --- a/neo/idlib/Token.h +++ b/neo/idlib/Token.h @@ -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 diff --git a/neo/idlib/math/Random.h b/neo/idlib/math/Random.h index e920a9dd..b44ad378 100644 --- a/neo/idlib/math/Random.h +++ b/neo/idlib/math/Random.h @@ -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__ */ diff --git a/neo/idlib/math/Simd.cpp b/neo/idlib/math/Simd.cpp index a88215cf..e29c6651 100644 --- a/neo/idlib/math/Simd.cpp +++ b/neo/idlib/math/Simd.cpp @@ -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 diff --git a/neo/idlib/math/Simd_SSE.cpp b/neo/idlib/math/Simd_SSE.cpp index 8970c4fa..93c4a742 100644 --- a/neo/idlib/math/Simd_SSE.cpp +++ b/neo/idlib/math/Simd_SSE.cpp @@ -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; diff --git a/neo/idlib/sys/sys_types.h b/neo/idlib/sys/sys_types.h index 5fa55071..e49551a6 100644 --- a/neo/idlib/sys/sys_types.h +++ b/neo/idlib/sys/sys_types.h @@ -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; diff --git a/neo/sys/sys_lobby.cpp b/neo/sys/sys_lobby.cpp index f025480b..a2a03f3a 100644 --- a/neo/sys/sys_lobby.cpp +++ b/neo/sys/sys_lobby.cpp @@ -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; diff --git a/neo/sys/sys_lobby.h b/neo/sys/sys_lobby.h index ba58ed0c..c1efb62a 100644 --- a/neo/sys/sys_lobby.h +++ b/neo/sys/sys_lobby.h @@ -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; diff --git a/neo/sys/sys_public.h b/neo/sys/sys_public.h index cc1f2435..5e77a4d3 100644 --- a/neo/sys/sys_public.h +++ b/neo/sys/sys_public.h @@ -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(); diff --git a/neo/sys/sys_session_local.cpp b/neo/sys/sys_session_local.cpp index af0fed51..3cca6fa5 100644 --- a/neo/sys/sys_session_local.cpp +++ b/neo/sys/sys_session_local.cpp @@ -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 ) {