mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 19:53:48 +00:00
As suggested, extract strlen calls from sizes into variables so it isn't called twice
This commit is contained in:
parent
ed10ce2511
commit
6b024b21bf
33 changed files with 171 additions and 114 deletions
|
|
@ -510,14 +510,16 @@ void queryMasterServer(U8 flags, const char* gameType, const char* missionType,
|
|||
// Update the active filter:
|
||||
if ( !sActiveFilter.gameType || dStrcmp( sActiveFilter.gameType, gameType ) != 0 )
|
||||
{
|
||||
sActiveFilter.gameType = (char*) dRealloc( sActiveFilter.gameType, dStrlen( gameType ) + 1 );
|
||||
dStrcpy( sActiveFilter.gameType, gameType, dStrlen(gameType) + 1 );
|
||||
dsize_t gameTypeLen = dStrlen(gameType) + 1;
|
||||
sActiveFilter.gameType = (char*) dRealloc( sActiveFilter.gameType, gameTypeLen );
|
||||
dStrcpy( sActiveFilter.gameType, gameType, gameTypeLen );
|
||||
}
|
||||
|
||||
if ( !sActiveFilter.missionType || dStrcmp( sActiveFilter.missionType, missionType ) != 0 )
|
||||
{
|
||||
sActiveFilter.missionType = (char*) dRealloc( sActiveFilter.missionType, dStrlen( missionType ) + 1 );
|
||||
dStrcpy( sActiveFilter.missionType, missionType, dStrlen(missionType) + 1 );
|
||||
dsize_t missionTypeLen = dStrlen(missionType) + 1;
|
||||
sActiveFilter.missionType = (char*) dRealloc( sActiveFilter.missionType, missionTypeLen );
|
||||
dStrcpy( sActiveFilter.missionType, missionType, missionTypeLen );
|
||||
}
|
||||
|
||||
sActiveFilter.queryFlags = flags | ServerFilter::NewStyleResponse;
|
||||
|
|
@ -969,8 +971,9 @@ static void pushServerFavorites()
|
|||
Net::stringToAddress( addrString, &addr );
|
||||
ServerInfo* si = findOrCreateServerInfo( &addr );
|
||||
AssertFatal(si, "pushServerFavorites - failed to create Server Info!" );
|
||||
si->name = (char*) dRealloc( (void*) si->name, dStrlen( serverName ) + 1 );
|
||||
dStrcpy( si->name, serverName, dStrlen(serverName) + 1 );
|
||||
dsize_t nameLen = dStrlen(serverName) + 1;
|
||||
si->name = (char*) dRealloc( (void*) si->name, nameLen );
|
||||
dStrcpy( si->name, serverName, nameLen );
|
||||
si->isFavorite = true;
|
||||
pushPingRequest( &addr );
|
||||
}
|
||||
|
|
@ -1053,8 +1056,9 @@ void addFakeServers( S32 howMany )
|
|||
newServer.maxPlayers = 64;
|
||||
char buf[256];
|
||||
dSprintf( buf, 255, "Fake server #%d", sNumFakeServers );
|
||||
newServer.name = (char*) dMalloc( dStrlen( buf ) + 1 );
|
||||
dStrcpy( newServer.name, buf, strlen(buf) + 1 );
|
||||
dsize_t nameLen = dStrlen(buf) + 1;
|
||||
newServer.name = (char*) dMalloc( nameLen );
|
||||
dStrcpy( newServer.name, buf, nameLen );
|
||||
newServer.gameType = (char*) dMalloc( 5 );
|
||||
dStrcpy( newServer.gameType, "Fake", 5 );
|
||||
newServer.missionType = (char*) dMalloc( 16 );
|
||||
|
|
@ -1753,8 +1757,9 @@ static void handleGameMasterInfoRequest( const NetAddress* address, U32 key, U8
|
|||
out->write( playerCount );
|
||||
|
||||
const char* guidList = Con::getVariable( "Server::GuidList" );
|
||||
char* buf = new char[dStrlen( guidList ) + 1];
|
||||
dStrcpy( buf, guidList, dStrlen(guidList) + 1 );
|
||||
dsize_t bufLen = dStrlen(guidList) + 1;
|
||||
char* buf = new char[bufLen];
|
||||
dStrcpy( buf, guidList, bufLen );
|
||||
char* temp = dStrtok( buf, "\t" );
|
||||
temp8 = 0;
|
||||
for ( ; temp && temp8 < playerCount; temp8++ )
|
||||
|
|
@ -1948,8 +1953,9 @@ static void handleGamePingResponse( const NetAddress* address, BitStream* stream
|
|||
stream->readString( buf );
|
||||
if ( !si->name )
|
||||
{
|
||||
si->name = (char*) dMalloc( dStrlen( buf ) + 1 );
|
||||
dStrcpy( si->name, buf, dStrlen(buf) + 1 );
|
||||
dsize_t bufLen = dStrlen(buf) + 1;
|
||||
si->name = (char*) dMalloc(bufLen);
|
||||
dStrcpy( si->name, buf, bufLen );
|
||||
}
|
||||
|
||||
// Set the server up to be queried:
|
||||
|
|
@ -2050,8 +2056,9 @@ static void handleGameInfoResponse( const NetAddress* address, BitStream* stream
|
|||
stream->readString( stringBuf );
|
||||
if ( !si->gameType || dStricmp( si->gameType, stringBuf ) != 0 )
|
||||
{
|
||||
si->gameType = (char*) dRealloc( (void*) si->gameType, dStrlen( stringBuf ) + 1 );
|
||||
dStrcpy( si->gameType, stringBuf, dStrlen(stringBuf) + 1 );
|
||||
dsize_t gameTypeLen = dStrlen(stringBuf) + 1;
|
||||
si->gameType = (char*) dRealloc( (void*) si->gameType, gameTypeLen );
|
||||
dStrcpy( si->gameType, stringBuf, gameTypeLen );
|
||||
|
||||
// Test against the active filter:
|
||||
if ( applyFilter && dStricmp( sActiveFilter.gameType, "any" ) != 0
|
||||
|
|
@ -2067,8 +2074,9 @@ static void handleGameInfoResponse( const NetAddress* address, BitStream* stream
|
|||
stream->readString( stringBuf );
|
||||
if ( !si->missionType || dStrcmp( si->missionType, stringBuf ) != 0 )
|
||||
{
|
||||
si->missionType = (char*) dRealloc( (void*) si->missionType, dStrlen( stringBuf ) + 1 );
|
||||
dStrcpy( si->missionType, stringBuf, dStrlen(stringBuf) + 1 );
|
||||
dsize_t missionTypeLen = dStrlen(stringBuf) + 1;
|
||||
si->missionType = (char*) dRealloc( (void*) si->missionType, missionTypeLen );
|
||||
dStrcpy( si->missionType, stringBuf, missionTypeLen );
|
||||
|
||||
// Test against the active filter:
|
||||
if ( applyFilter && dStricmp( sActiveFilter.missionType, "any" ) != 0
|
||||
|
|
@ -2088,8 +2096,9 @@ static void handleGameInfoResponse( const NetAddress* address, BitStream* stream
|
|||
*temp = '\0';
|
||||
if ( !si->missionName || dStrcmp( si->missionName, stringBuf ) != 0 )
|
||||
{
|
||||
si->missionName = (char*) dRealloc( (void*) si->missionName, dStrlen( stringBuf ) + 1 );
|
||||
dStrcpy( si->missionName, stringBuf, dStrlen(stringBuf) + 1 );
|
||||
dsize_t missionNameLen = dStrlen(stringBuf) + 1;
|
||||
si->missionName = (char*) dRealloc( (void*) si->missionName, missionNameLen );
|
||||
dStrcpy( si->missionName, stringBuf, missionNameLen );
|
||||
}
|
||||
|
||||
// Get the server status:
|
||||
|
|
@ -2157,16 +2166,18 @@ static void handleGameInfoResponse( const NetAddress* address, BitStream* stream
|
|||
stream->readString( stringBuf );
|
||||
if ( !si->statusString || ( isUpdate && dStrcmp( si->statusString, stringBuf ) != 0 ) )
|
||||
{
|
||||
si->infoString = (char*) dRealloc( (void*) si->infoString, dStrlen( stringBuf ) + 1 );
|
||||
dStrcpy( si->infoString, stringBuf, dStrlen(stringBuf) + 1 );
|
||||
dsize_t infoLen = dStrlen(stringBuf) + 1;
|
||||
si->infoString = (char*) dRealloc( (void*) si->infoString, infoLen );
|
||||
dStrcpy( si->infoString, stringBuf, infoLen );
|
||||
}
|
||||
|
||||
// Get the content string:
|
||||
readLongCString( stream, stringBuf );
|
||||
if ( !si->statusString || ( isUpdate && dStrcmp( si->statusString, stringBuf ) != 0 ) )
|
||||
{
|
||||
si->statusString = (char*) dRealloc( (void*) si->statusString, dStrlen( stringBuf ) + 1 );
|
||||
dStrcpy( si->statusString, stringBuf, dStrlen(stringBuf) + 1 );
|
||||
dsize_t statusLen = dStrlen(stringBuf) + 1;
|
||||
si->statusString = (char*) dRealloc( (void*) si->statusString, statusLen );
|
||||
dStrcpy( si->statusString, stringBuf, statusLen );
|
||||
}
|
||||
|
||||
// Update the server browser gui!
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue