From 0d27bfe7b9337cb1a311ce4a67c43736f9495c6c Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Sat, 23 Jun 2012 01:42:47 +0200 Subject: [PATCH] Remove usage of long type from idlib/ Apart from some minor stuff, this changes the signature of some methods of Parser and Token classes and of the (unused) Random2 class. That no problem though, because the calling code uses normal ints anyway. --- neo/cm/CollisionModel_files.cpp | 2 +- neo/idlib/Base64.cpp | 4 ++-- neo/idlib/Parser.cpp | 18 +++++++++--------- neo/idlib/Parser.h | 6 +++--- neo/idlib/Str.cpp | 4 ++-- neo/idlib/Token.h | 8 ++++---- neo/idlib/math/Random.h | 28 ++++++++++++++-------------- neo/idlib/math/Simd.cpp | 4 ++-- neo/sound/snd_efxfile.cpp | 2 +- neo/tools/compilers/aas/AASFile.cpp | 2 +- 10 files changed, 39 insertions(+), 39 deletions(-) diff --git a/neo/cm/CollisionModel_files.cpp b/neo/cm/CollisionModel_files.cpp index 367cca83..9240b06b 100644 --- a/neo/cm/CollisionModel_files.cpp +++ b/neo/cm/CollisionModel_files.cpp @@ -587,7 +587,7 @@ bool idCollisionModelManagerLocal::LoadCollisionModelFile( const char *name, uns return false; } - crc = token.GetUnsignedLongValue(); + crc = token.GetUnsignedIntValue(); if ( mapFileCRC && crc != mapFileCRC ) { common->Printf( "%s is out of date\n", fileName.c_str() ); delete src; diff --git a/neo/idlib/Base64.cpp b/neo/idlib/Base64.cpp index 85d4639e..046b4a04 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; byte *to; EnsureAlloced( 4*(size+3)/3 + 2 ); // ratio and padding + trailing \0 @@ -94,7 +94,7 @@ idBase64::Decode ============ */ int idBase64::Decode( byte *to ) const { - unsigned long w; + unsigned int w; 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 199ac7fa..a461a0e9 100644 --- a/neo/idlib/Parser.cpp +++ b/neo/idlib/Parser.cpp @@ -1297,7 +1297,7 @@ typedef struct operator_s typedef struct value_s { - signed long int intvalue; + int intvalue; double floatvalue; int parentheses; struct value_s *prev, *next; @@ -1368,7 +1368,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, int *intvalue, double *floatvalue, int integer ) { operator_t *o, *firstoperator, *lastoperator; value_t *v, *firstvalue, *lastvalue, *v1, *v2; idToken *t; @@ -1791,7 +1791,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( int *intvalue, double *floatvalue, int integer ) { idToken token, *firsttoken, *lasttoken; idToken *t, *nexttoken; define_t *define; @@ -1882,7 +1882,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( int *intvalue, double *floatvalue, int integer) { int indent, defined = false; idToken token, *firsttoken, *lasttoken; idToken *t, *nexttoken; @@ -1984,7 +1984,7 @@ idParser::Directive_elif ================ */ int idParser::Directive_elif( void ) { - signed long int value; + int value; int type, skip; idParser::PopIndent( &type, &skip ); @@ -2006,7 +2006,7 @@ idParser::Directive_if ================ */ int idParser::Directive_if( void ) { - signed long int value; + int value; int skip; if ( !idParser::Evaluate( &value, NULL, true ) ) { @@ -2102,7 +2102,7 @@ idParser::Directive_eval ================ */ int idParser::Directive_eval( void ) { - signed long int value; + int value; idToken token; char buf[128]; @@ -2241,7 +2241,7 @@ idParser::DollarDirective_evalint ================ */ int idParser::DollarDirective_evalint( void ) { - signed long int value; + int value; idToken token; char buf[128]; @@ -2290,7 +2290,7 @@ int idParser::DollarDirective_evalfloat( void ) { 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 ); token.floatvalue = fabs( value ); idParser::UnreadSourceToken( &token ); if ( value < 0 ) { diff --git a/neo/idlib/Parser.h b/neo/idlib/Parser.h index a8c821ab..88f98964 100644 --- a/neo/idlib/Parser.h +++ b/neo/idlib/Parser.h @@ -228,9 +228,9 @@ private: int Directive_ifndef( void ); int Directive_else( void ); int Directive_endif( void ); - 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); + int EvaluateTokens( idToken *tokens, int *intvalue, double *floatvalue, int integer ); + int Evaluate( int *intvalue, double *floatvalue, int integer ); + int DollarEvaluate( int *intvalue, double *floatvalue, int integer); int Directive_define( void ); int Directive_elif( void ); int Directive_if( void ); diff --git a/neo/idlib/Str.cpp b/neo/idlib/Str.cpp index 034fbe90..2271c733 100644 --- a/neo/idlib/Str.cpp +++ b/neo/idlib/Str.cpp @@ -703,7 +703,7 @@ idStr::FileNameHash */ int idStr::FileNameHash( void ) const { int i; - long hash; + int hash; char letter; hash = 0; @@ -716,7 +716,7 @@ int idStr::FileNameHash( void ) const { if ( letter =='\\' ) { letter = '/'; } - hash += (long)(letter)*(i+119); + hash += (int)(letter)*(i+119); i++; } hash &= (FILE_HASH_SIZE-1); diff --git a/neo/idlib/Token.h b/neo/idlib/Token.h index b80d471a..1df728fc 100644 --- a/neo/idlib/Token.h +++ b/neo/idlib/Token.h @@ -92,7 +92,7 @@ public: double GetDoubleValue( void ); // double value of TT_NUMBER float GetFloatValue( void ); // float value of TT_NUMBER - unsigned long GetUnsignedLongValue( void ); // unsigned long value of TT_NUMBER + unsigned int GetUnsignedIntValue( void ); // unsigned int value of TT_NUMBER int GetIntValue( void ); // int value of TT_NUMBER int WhiteSpaceBeforeToken( void ) const;// returns length of whitespace before token void ClearTokenWhiteSpace( void ); // forget whitespace before token @@ -100,7 +100,7 @@ public: void NumberValue( void ); // calculate values for a TT_NUMBER private: - unsigned long intvalue; // integer value + unsigned int intvalue; // integer value 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 @@ -141,7 +141,7 @@ ID_INLINE float idToken::GetFloatValue( void ) { return (float) GetDoubleValue(); } -ID_INLINE unsigned long idToken::GetUnsignedLongValue( void ) { +ID_INLINE unsigned int idToken::GetUnsignedIntValue( void ) { if ( type != TT_NUMBER ) { return 0; } @@ -152,7 +152,7 @@ ID_INLINE unsigned long idToken::GetUnsignedLongValue( void ) { } ID_INLINE int idToken::GetIntValue( void ) { - return (int) GetUnsignedLongValue(); + return (int) GetUnsignedIntValue(); } ID_INLINE int idToken::WhiteSpaceBeforeToken( void ) const { diff --git a/neo/idlib/math/Random.h b/neo/idlib/math/Random.h index 1640901d..f8ed085c 100644 --- a/neo/idlib/math/Random.h +++ b/neo/idlib/math/Random.h @@ -100,10 +100,10 @@ ID_INLINE float idRandom::CRandomFloat( void ) { class idRandom2 { public: - idRandom2( unsigned long seed = 0 ); + idRandom2( unsigned int seed = 0 ); - void SetSeed( unsigned long seed ); - unsigned long GetSeed( void ) const; + void SetSeed( unsigned int seed ); + unsigned int GetSeed( void ) const; int RandomInt( void ); // random integer in the range [0, MAX_RAND] int RandomInt( int max ); // random integer in the range [0, max] @@ -113,26 +113,26 @@ 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( void ) const { +ID_INLINE unsigned int idRandom2::GetSeed( void ) const { return seed; } ID_INLINE int idRandom2::RandomInt( void ) { - seed = 1664525L * seed + 1013904223L; + seed = 1664525 * seed + 1013904223; return ( (int) seed & idRandom2::MAX_RAND ); } @@ -144,15 +144,15 @@ ID_INLINE int idRandom2::RandomInt( int max ) { } ID_INLINE float idRandom2::RandomFloat( void ) { - unsigned long i; - seed = 1664525L * seed + 1013904223L; + unsigned int i; + seed = 1664525 * seed + 1013904223; i = idRandom2::IEEE_ONE | ( seed & idRandom2::IEEE_MASK ); return ( ( *(float *)&i ) - 1.0f ); } ID_INLINE float idRandom2::CRandomFloat( void ) { - unsigned long i; - seed = 1664525L * seed + 1013904223L; + unsigned int i; + seed = 1664525 * seed + 1013904223; i = idRandom2::IEEE_ONE | ( seed & idRandom2::IEEE_MASK ); return ( 2.0f * ( *(float *)&i ) - 3.0f ); } diff --git a/neo/idlib/math/Simd.cpp b/neo/idlib/math/Simd.cpp index c1b0fb1b..e5156347 100644 --- a/neo/idlib/math/Simd.cpp +++ b/neo/idlib/math/Simd.cpp @@ -147,7 +147,7 @@ void idSIMD::Shutdown( void ) { idSIMDProcessor *p_simd; idSIMDProcessor *p_generic; -long baseClocks = 0; +int baseClocks = 0; #ifdef _MSC_VER @@ -155,7 +155,7 @@ long baseClocks = 0; #pragma warning(disable : 4731) // frame pointer register 'ebx' modified by inline assembly code -long saved_ebx = 0; +int saved_ebx = 0; #define StartRecordTime( start ) \ __asm mov saved_ebx, ebx \ diff --git a/neo/sound/snd_efxfile.cpp b/neo/sound/snd_efxfile.cpp index 6845d070..cbf7fe15 100644 --- a/neo/sound/snd_efxfile.cpp +++ b/neo/sound/snd_efxfile.cpp @@ -245,7 +245,7 @@ bool idEFXFile::ReadEffect( idLexer &src, idSoundEffect *effect ) { efxf(AL_EAXREVERB_ROOM_ROLLOFF_FACTOR, src.ParseFloat()); } else if ( token == "flags" ) { src.ReadTokenOnLine( &token ); - unsigned int flags = token.GetUnsignedLongValue(); + unsigned int flags = token.GetUnsignedIntValue(); efxi(AL_EAXREVERB_DECAY_HFLIMIT, (flags & 0x20) ? AL_TRUE : AL_FALSE); // the other SCALE flags have no equivalent in efx diff --git a/neo/tools/compilers/aas/AASFile.cpp b/neo/tools/compilers/aas/AASFile.cpp index e6f2ba13..bcbb8a0c 100644 --- a/neo/tools/compilers/aas/AASFile.cpp +++ b/neo/tools/compilers/aas/AASFile.cpp @@ -1131,7 +1131,7 @@ bool idAASFileLocal::Load( const idStr &fileName, unsigned int mapFileCRC ) { return false; } - c = token.GetUnsignedLongValue(); + c = token.GetUnsignedIntValue(); if ( mapFileCRC && c != mapFileCRC ) { common->Warning( "AAS file '%s' is out of date", name.c_str() ); return false;