From 1cb77001349fbebf25310a3b88268e325d5f17a8 Mon Sep 17 00:00:00 2001 From: Walter Julius Hennecke Date: Mon, 31 Dec 2012 13:37:16 +0100 Subject: [PATCH] Windows: Fixed all signed/unsigned mismatches --- Shared/qcommon/output.cpp | 4 ++-- dlls/game/archive.cpp | 8 +++---- dlls/game/g_main.cpp | 5 ++--- dlls/game/gamecmds.cpp | 5 ++--- dlls/game/listener.cpp | 7 +++---- dlls/game/mp_modeBase.cpp | 39 ++++++++++++----------------------- dlls/game/mp_modeBase.hpp | 2 +- dlls/game/mp_modeCtf.cpp | 6 ++---- dlls/game/mp_modeDm.cpp | 6 ++---- dlls/game/mp_modeTeamBase.cpp | 2 +- dlls/game/mp_modeTeamDm.cpp | 3 +-- dlls/game/navigate.h | 8 +++---- dlls/game/q_shared.h | 2 +- dlls/game/script.cpp | 3 +-- dlls/game/sentient.cpp | 2 +- 15 files changed, 40 insertions(+), 62 deletions(-) diff --git a/Shared/qcommon/output.cpp b/Shared/qcommon/output.cpp index ef8b9c3..cefdbcb 100644 --- a/Shared/qcommon/output.cpp +++ b/Shared/qcommon/output.cpp @@ -443,7 +443,7 @@ void HTMLDocFileOutput::OutputEvent(Event *ev) if ( text ) { char new_doc[1024]; - int old_index; + unsigned old_index; int new_index = 0; for ( old_index = 0 ; old_index < strlen ( text ) ; old_index++ ) @@ -701,7 +701,7 @@ void ToolDocFileOutput::OutputEvent(Event *ev) { int numargs; const char *text; - int i; + unsigned i; fprintf(fileptr, "\n"); fprintf(fileptr, "\t%s\n", ev->getName() ); diff --git a/dlls/game/archive.cpp b/dlls/game/archive.cpp index 6a8c586..06abf70 100644 --- a/dlls/game/archive.cpp +++ b/dlls/game/archive.cpp @@ -863,11 +863,11 @@ Class * Archiver::ReadObject( void ) if ( !fileerror ) { endpos = readfile.Pos(); - if ( ( endpos - objstart ) > size ) + if ( ( endpos - objstart ) > (long)size ) { FileError( "Object read past end of object's data" ); } - else if ( ( endpos - objstart ) < size ) + else if ( ( endpos - objstart ) < (long)size ) { FileError( "Object didn't read entire data from file" ); } @@ -945,11 +945,11 @@ void Archiver::ArchiveObject( Class *obj ) if ( !fileerror ) { endpos = readfile.Pos(); - if ( ( endpos - objstart ) > size ) + if ( ( endpos - objstart ) > (long)size ) { FileError( "Object read past end of object's data" ); } - else if ( ( endpos - objstart ) < size ) + else if ( ( endpos - objstart ) < (long)size ) { FileError( "Object didn't read entire data from file" ); } diff --git a/dlls/game/g_main.cpp b/dlls/game/g_main.cpp index e034934..820f2f1 100644 --- a/dlls/game/g_main.cpp +++ b/dlls/game/g_main.cpp @@ -1867,7 +1867,6 @@ extern "C" void G_ClientUserinfoChanged( gentity_t *ent, const char *userinfo ) //Event *ev; bool autoSwitchWeapons; char tempName[ MAX_NETNAME ]; - int i; bool validName; try @@ -1904,7 +1903,7 @@ extern "C" void G_ClientUserinfoChanged( gentity_t *ent, const char *userinfo ) validName = false; - for ( i = 0 ; i < strlen( tempName ) ; i++ ) + for ( unsigned i = 0 ; i < strlen( tempName ) ; i++ ) { if ( ( tempName[ i ] == '^' ) && ( tempName[ i + 1 ] >= '0' ) && ( tempName[ i + 1 ] <= '9' ) ) { @@ -1930,7 +1929,7 @@ extern "C" void G_ClientUserinfoChanged( gentity_t *ent, const char *userinfo ) // Strip out bad characters - for ( i = 0 ; i < strlen( ent->client->pers.netname ) ; i++ ) + for ( unsigned i = 0 ; i < strlen( ent->client->pers.netname ) ; i++ ) { if ( ent->client->pers.netname[ i ] == ':' ) { diff --git a/dlls/game/gamecmds.cpp b/dlls/game/gamecmds.cpp index 8da17d3..3380ffd 100644 --- a/dlls/game/gamecmds.cpp +++ b/dlls/game/gamecmds.cpp @@ -917,7 +917,7 @@ qboolean G_SendCommandToAllPlayers( const char *command ) { bool retVal = true ; - for( unsigned int clientIdx = 0; clientIdx < maxclients->integer; ++clientIdx ) + for( int clientIdx = 0; clientIdx < maxclients->integer; ++clientIdx ) { gentity_t *ent = g_entities + clientIdx ; if ( !ent->inuse || !ent->client || !ent->entity ) continue; @@ -1007,8 +1007,7 @@ qboolean G_SetWidgetTextOfPlayer( const gentity_t *ent, const char *widgetName, strcpy(tmpstr, widgetText); - int i; - for ( i=0; i ( tokptr - scratch + 1) ) + if ( (int)strlen( scratch ) > ( tokptr - scratch + 1) ) second = true; else second = false; @@ -1429,10 +1429,9 @@ void Event::PrintDocumentation( FILE *event_file, qboolean html ) if ( documentation ) { char new_doc[1024]; - int old_index; int new_index = 0; - for ( old_index = 0 ; old_index < strlen ( documentation ) ; old_index++ ) + for ( unsigned old_index = 0 ; old_index < strlen ( documentation ) ; old_index++ ) { if ( documentation[old_index] == '\n' ) { @@ -2860,7 +2859,7 @@ void Event::SetConsoleEdict( const gentity_t *consoleedict ) gentity_t *Event::GetConsoleEdict( void ) { // linenumber does double duty in the case of the console commands - if ( ( info.source != EV_FROM_CONSOLE ) || ( info.linenumber >= game.maxclients ) ) + if ( ( info.source != EV_FROM_CONSOLE ) || ( game.maxclients && (info.linenumber >= (unsigned)game.maxclients )) ) { // default to player 1 for release return &g_entities[ 0 ]; diff --git a/dlls/game/mp_modeBase.cpp b/dlls/game/mp_modeBase.cpp index bfaeca3..3b3ec5a 100644 --- a/dlls/game/mp_modeBase.cpp +++ b/dlls/game/mp_modeBase.cpp @@ -178,9 +178,7 @@ void MultiplayerModeBase::initItems( void ) int MultiplayerModeBase::findPlayer( const Player *player ) { - int i; - - for ( i = 0 ; i < _maxPlayers ; i++ ) + for ( unsigned i = 0 ; i < _maxPlayers ; i++ ) { if ( _playerGameData[ i ]._playing && _playerGameData[ i ]._entnum == player->entnum ) return i; @@ -341,13 +339,11 @@ void MultiplayerModeBase::update( float frameTime ) //================================================================ bool MultiplayerModeBase::isEndOfMatch( void ) { - int i; - // See if we have a gone over the point limit if ( getPointLimit() > 0 ) { - for ( i = 0 ; i < _maxPlayers ; i++ ) + for ( unsigned i = 0 ; i < _maxPlayers ; i++ ) { if ( _playerGameData[ i ]._playing ) { @@ -445,7 +441,6 @@ void MultiplayerModeBase::obituary( Player *killedPlayer, Player *attackingPlaye str printString; bool suicide; bool printSomething; - int i; char color; bool sameTeam; @@ -660,7 +655,7 @@ void MultiplayerModeBase::obituary( Player *killedPlayer, Player *attackingPlaye // Print to all of the players - for ( i = 0 ; i < _maxPlayers ; i++ ) + for ( unsigned i = 0 ; i < _maxPlayers ; i++ ) { currentPlayer = multiplayerManager.getPlayer( i ); @@ -909,7 +904,6 @@ bool MultiplayerModeBase::shouldStartMatch( void ) { int timeRemaining; int numPlayers; - int i; if ( _gameStarted ) return false; @@ -961,7 +955,7 @@ bool MultiplayerModeBase::shouldStartMatch( void ) numPlayers = 0; - for ( i = 0 ; i < _maxPlayers ; i++ ) + for ( unsigned i = 0 ; i < _maxPlayers ; i++ ) { if ( _playerGameData[ i ]._playing ) { @@ -980,7 +974,6 @@ int MultiplayerModeBase::getStat( Player *player, int statNum, int value ) if ( statNum == STAT_MP_STATE ) { int numPlayers; - int i; Player *player; if ( _gameStarted ) @@ -998,7 +991,7 @@ int MultiplayerModeBase::getStat( Player *player, int statNum, int value ) numPlayers = 0; - for ( i = 0 ; i < _maxPlayers ; i++ ) + for ( unsigned i = 0 ; i < _maxPlayers ; i++ ) { player = multiplayerManager.getPlayer( i ); @@ -1018,7 +1011,6 @@ int MultiplayerModeBase::getStat( Player *player, int statNum, int value ) void MultiplayerModeBase::startMatch( void ) { - int i; Player *player; _gameStarted = true; @@ -1026,7 +1018,7 @@ void MultiplayerModeBase::startMatch( void ) // Make everyone not a spectator and spawn them into the world - for ( i = 0 ; i < _maxPlayers ; i++ ) + for ( unsigned i = 0 ; i < _maxPlayers ; i++ ) { player = getPlayer( i ); @@ -1056,14 +1048,13 @@ void MultiplayerModeBase::restartMatch( void ) void MultiplayerModeBase::endMatch( void ) { - int i; Player *player; _gameStarted = false; // Make everyone a spectator - for ( i = 0 ; i < _maxPlayers ; i++ ) + for ( unsigned i = 0 ; i < _maxPlayers ; i++ ) { if ( _playerGameData[ i ]._playing ) { @@ -1082,7 +1073,7 @@ bool MultiplayerModeBase::inMatch( void ) return _gameStarted; } -Player *MultiplayerModeBase::getPlayer( int entnum ) +Player *MultiplayerModeBase::getPlayer( unsigned entnum ) { // Make sure everything is ok @@ -1149,7 +1140,6 @@ void MultiplayerModeBase::score( const Player *player ) { char string[1400]; char entry[1024]; - int i; int tempStringlength; int count = 0; int stringlength = 0; @@ -1168,7 +1158,7 @@ void MultiplayerModeBase::score( const Player *player ) // This for loop builds a string containing all the players scores. - for ( i = 0 ; i < _maxPlayers ; i++ ) + for ( unsigned i = 0 ; i < _maxPlayers ; i++ ) { currentPlayer = multiplayerManager.getPlayer( i ); @@ -1465,12 +1455,11 @@ void MultiplayerModeBase::_endMatch() void MultiplayerModeBase::declareWinner( void ) { - int i; Player *player; int place; bool tied; - for ( i = 0 ; i < _maxPlayers ; i++ ) + for ( unsigned i = 0 ; i < _maxPlayers ; i++ ) { player = getPlayer( i ); @@ -1591,7 +1580,7 @@ Entity* MultiplayerModeBase::getRandomSpawnpoint( bool useCounter ) if ( useCounter ) { - if ( _spawncounter > numPoints ) + if ( (int)_spawncounter > numPoints ) { _spawncounter = 1; // reuse spawn points } @@ -1888,11 +1877,10 @@ int MultiplayerModeBase::getPlace( Player *player, bool *tied ) { int place = 1; bool isTied = false; - int i; Player *currentPlayer; int scoreDiff; - for ( i = 0 ; i < _maxPlayers ; i++ ) + for ( unsigned i = 0 ; i < _maxPlayers ; i++ ) { // Get this player and make sure everything is ok @@ -1929,10 +1917,9 @@ int MultiplayerModeBase::getPlace( Player *player, bool *tied ) int MultiplayerModeBase::getHighestPoints( void ) { - int i; int highestPoints = -999999999; - for ( i = 0 ; i < _maxPlayers ; i++ ) + for ( unsigned i = 0 ; i < _maxPlayers ; i++ ) { if ( _playerGameData[ i ]._points > highestPoints ) { diff --git a/dlls/game/mp_modeBase.hpp b/dlls/game/mp_modeBase.hpp index b7219de..8db1956 100644 --- a/dlls/game/mp_modeBase.hpp +++ b/dlls/game/mp_modeBase.hpp @@ -125,7 +125,7 @@ class MultiplayerModeBase : public Class void handleKill( Player *killedPlayer, Player *attackingPlayer, Entity *inflictor, int meansOfDeath, bool goodKill ); - Player * getPlayer( int entnum ); + Player * getPlayer( unsigned entnum ); public: CLASS_PROTOTYPE( MultiplayerModeBase ); diff --git a/dlls/game/mp_modeCtf.cpp b/dlls/game/mp_modeCtf.cpp index af84781..8a1893a 100644 --- a/dlls/game/mp_modeCtf.cpp +++ b/dlls/game/mp_modeCtf.cpp @@ -422,7 +422,6 @@ float ModeCaptureTheFlag::findNearestTeamFlagDist( const str &teamName, const Ve float ModeCaptureTheFlag::findNearestTeamFlagCarrierDist( const str &teamName, const Vector &position ) { - int i; Player *currentPlayer; Player *nearestFlagCarrier = NULL; float nearestDistance = -1.0f; @@ -432,7 +431,7 @@ float ModeCaptureTheFlag::findNearestTeamFlagCarrierDist( const str &teamName, c // Go through all of the flags - for ( i = 0 ; i < _maxPlayers ; i++ ) + for ( unsigned i = 0 ; i < _maxPlayers ; i++ ) { if ( !_playerGameData[ i ]._playing ) continue; @@ -935,7 +934,6 @@ void ModeCaptureTheFlag::score( const Player *player ) { char string[1400]; char entry[1024]; - int i; int tempStringlength; int count = 0; int stringlength = 0; @@ -958,7 +956,7 @@ void ModeCaptureTheFlag::score( const Player *player ) // This for loop builds a string containing all the players scores. - for ( i = 0 ; i < _maxPlayers ; i++ ) + for ( unsigned i = 0 ; i < _maxPlayers ; i++ ) { currentPlayer = multiplayerManager.getPlayer( i ); diff --git a/dlls/game/mp_modeDm.cpp b/dlls/game/mp_modeDm.cpp index 4775a66..634aebb 100644 --- a/dlls/game/mp_modeDm.cpp +++ b/dlls/game/mp_modeDm.cpp @@ -180,10 +180,9 @@ bool ModeDeathmatch::checkGameType( const char *gameType ) int ModeDeathmatch::getHighestPoints( int entnum ) { - int i; int highestPoints = -999999999; - for ( i = 0 ; i < _maxPlayers ; i++ ) + for ( unsigned i = 0 ; i < _maxPlayers ; i++ ) { if ( _playerGameData[ i ]._playing && ( _playerGameData[ i ]._entnum != entnum ) ) { @@ -207,7 +206,6 @@ bool ModeDeathmatch::checkRule( const char *rule, bool defaultValue, Player *pla void ModeDeathmatch::update( float frameTime ) { - int i; Player *player; int place; bool tied; @@ -218,7 +216,7 @@ void ModeDeathmatch::update( float frameTime ) if ( _gameStarted ) { - for ( i = 0 ; i < _maxPlayers ; i++ ) + for ( unsigned i = 0 ; i < _maxPlayers ; i++ ) { player = multiplayerManager.getPlayer( i ); diff --git a/dlls/game/mp_modeTeamBase.cpp b/dlls/game/mp_modeTeamBase.cpp index 3ae51fd..d9585ee 100644 --- a/dlls/game/mp_modeTeamBase.cpp +++ b/dlls/game/mp_modeTeamBase.cpp @@ -110,7 +110,7 @@ bool ModeTeamBase::isEndOfMatch( void ) for (int idx=1; idx <= _teamList.NumObjects(); idx++) { Team* team = _teamList.ObjectAt(idx); - if (team->getDeaths() > getPointLimit()) + if ((int)(team->getDeaths()) > getPointLimit()) { multiplayerManager.centerPrintAllClients(va("$$%s$$ $$TeamLoses$$\n", team->getName().c_str() ), CENTERPRINT_IMPORTANCE_NORMAL ); diff --git a/dlls/game/mp_modeTeamDm.cpp b/dlls/game/mp_modeTeamDm.cpp index abe49b5..b01a4e2 100644 --- a/dlls/game/mp_modeTeamDm.cpp +++ b/dlls/game/mp_modeTeamDm.cpp @@ -144,7 +144,6 @@ void ModeTeamDeathmatch::score( const Player *player ) { char string[1400]; char entry[1024]; - int i; int tempStringlength; int count = 0; int stringlength = 0; @@ -167,7 +166,7 @@ void ModeTeamDeathmatch::score( const Player *player ) // This for loop builds a string containing all the players scores. - for ( i = 0 ; i < _maxPlayers ; i++ ) + for ( unsigned i = 0 ; i < _maxPlayers ; i++ ) { currentPlayer = multiplayerManager.getPlayer( i ); diff --git a/dlls/game/navigate.h b/dlls/game/navigate.h index 4602dd1..2513115 100644 --- a/dlls/game/navigate.h +++ b/dlls/game/navigate.h @@ -714,9 +714,9 @@ void PathFinder::PropagateDown child = thePathManager.GetNode( path->targetNodeIndex ); movecost = g + heuristic.cost( node, c ); - if ( movecost < child->g ) + if ( (long)movecost < child->g ) { - child->g = movecost; + child->g = (long)movecost; child->f = child->g + child->h; child->Parent = node; @@ -739,9 +739,9 @@ void PathFinder::PropagateDown // we stop the propagation when the g value of the child is equal or better than // the cost we're propagating movecost = parent->g + path->moveCost; - if ( movecost < child->g ) + if ( (long)movecost < child->g ) { - child->g = movecost; + child->g = (long)movecost; child->f = child->g + child->h; child->Parent = parent; stack.Push( child ); diff --git a/dlls/game/q_shared.h b/dlls/game/q_shared.h index 15a19db..1d70015 100644 --- a/dlls/game/q_shared.h +++ b/dlls/game/q_shared.h @@ -32,7 +32,7 @@ #ifdef _WIN32 -#pragma warning(disable : 4018) // signed/unsigned mismatch +//#pragma warning(disable : 4018) // signed/unsigned mismatch //#pragma warning(disable : 4032) // formal parameter 'number' has different type when promoted #pragma warning(disable : 4051) // type conversion, possible loss of data #pragma warning(disable : 4057) // slightly different base types diff --git a/dlls/game/script.cpp b/dlls/game/script.cpp index 2735ac6..99b2e6b 100644 --- a/dlls/game/script.cpp +++ b/dlls/game/script.cpp @@ -664,11 +664,10 @@ char *Script::EvaluateMacroString( const char *theMacroString ) static char evalText[255]; char buffer[255], *bufferptr = buffer, oper = '+', newoper = '+'; bool haveoper = false; - int i; float value = 0.0f, val = 0.0f; memset(buffer, 0, 255); - for ( i=0;i<=strlen(theMacroString);i++ ) + for ( unsigned i=0;i<=strlen(theMacroString);i++ ) { if ( theMacroString[i] == '+' ) { haveoper = true; newoper = '+'; } if ( theMacroString[i] == '-' ) { haveoper = true; newoper = '-'; } diff --git a/dlls/game/sentient.cpp b/dlls/game/sentient.cpp index 1ce02d3..462e86a 100644 --- a/dlls/game/sentient.cpp +++ b/dlls/game/sentient.cpp @@ -4280,7 +4280,7 @@ void Sentient::CheckAnimations( Event *ev ) int state_len = strlen( cs ); // Animation in tik file is longer than the state machine's anim - if ( strlen( c ) > state_len ) + if ( (int)strlen( c ) > state_len ) { if ( c[state_len] != '_' ) // If next character is an '_' then no match {