mirror of
https://github.com/alliedmodders/hl2sdk.git
synced 2025-09-19 20:16:10 +08:00
Modified SDK for GCC 4.2
This commit is contained in:
@ -27,7 +27,7 @@
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
static char * s_LastFileLoadingFrom = "unknown"; // just needed for error messages
|
||||
static const char * s_LastFileLoadingFrom = "unknown"; // just needed for error messages
|
||||
|
||||
#define KEYVALUES_TOKEN_SIZE 1024
|
||||
static char s_pTokenBuf[KEYVALUES_TOKEN_SIZE];
|
||||
@ -369,7 +369,9 @@ int KeyValues::GetNameSymbol() const
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Read a single token from buffer (0 terminated)
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (disable:4706)
|
||||
#endif
|
||||
const char *KeyValues::ReadToken( CUtlBuffer &buf, bool &wasQuoted, bool &wasConditional )
|
||||
{
|
||||
wasQuoted = false;
|
||||
@ -416,7 +418,7 @@ const char *KeyValues::ReadToken( CUtlBuffer &buf, bool &wasQuoted, bool &wasCon
|
||||
bool bReportedError = false;
|
||||
bool bConditionalStart = false;
|
||||
int nCount = 0;
|
||||
while ( c = (const char*)buf.PeekGet( sizeof(char), 0 ) )
|
||||
while ( (c = (const char*)buf.PeekGet( sizeof(char), 0 )) )
|
||||
{
|
||||
// end of file
|
||||
if ( *c == 0 )
|
||||
@ -453,8 +455,9 @@ const char *KeyValues::ReadToken( CUtlBuffer &buf, bool &wasQuoted, bool &wasCon
|
||||
s_pTokenBuf[ nCount ] = 0;
|
||||
return s_pTokenBuf;
|
||||
}
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (default:4706)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -472,7 +475,9 @@ void KeyValues::UsesEscapeSequences(bool state)
|
||||
bool KeyValues::LoadFromFile( IBaseFileSystem *filesystem, const char *resourceName, const char *pathID )
|
||||
{
|
||||
Assert(filesystem);
|
||||
#ifndef _LINUX
|
||||
Assert( IsX360() || ( IsPC() && _heapchk() == _HEAPOK ) );
|
||||
#endif
|
||||
|
||||
FileHandle_t f = filesystem->Open(resourceName, "rb", pathID);
|
||||
if ( !f )
|
||||
@ -1166,8 +1171,8 @@ const char *KeyValues::GetString( const char *keyName, const char *defaultValue
|
||||
|
||||
const wchar_t *KeyValues::GetWString( const char *keyName, const wchar_t *defaultValue)
|
||||
{
|
||||
KeyValues *dat = FindKey( keyName, false );
|
||||
#ifdef _WIN32
|
||||
KeyValues *dat = FindKey( keyName, false );
|
||||
if ( dat )
|
||||
{
|
||||
wchar_t wbuf[64];
|
||||
@ -1235,7 +1240,7 @@ Color KeyValues::GetColor( const char *keyName )
|
||||
}
|
||||
else if ( dat->m_iDataType == TYPE_FLOAT )
|
||||
{
|
||||
color[0] = dat->m_flValue;
|
||||
color[0] = (unsigned char)dat->m_flValue;
|
||||
}
|
||||
else if ( dat->m_iDataType == TYPE_INT )
|
||||
{
|
||||
|
@ -321,7 +321,7 @@ void netadr_t::SetFromSocket( int hSocket )
|
||||
|
||||
struct sockaddr address;
|
||||
int namelen = sizeof(address);
|
||||
if ( getsockname( hSocket, (struct sockaddr *)&address, (int *)&namelen) == 0 )
|
||||
if ( getsockname( hSocket, (struct sockaddr *)&address, (socklen_t *)&namelen) == 0 )
|
||||
{
|
||||
SetFromSockadr( &address );
|
||||
}
|
||||
|
@ -438,7 +438,7 @@ void old_bf_write::WriteBitCoordMP( const float f, bool bIntegral, bool bLowPrec
|
||||
VPROF( "old_bf_write::WriteBitCoordMP" );
|
||||
#endif
|
||||
int signbit = (f <= -( bLowPrecision ? COORD_RESOLUTION_LOWPRECISION : COORD_RESOLUTION ));
|
||||
int intval = (int)abs(f);
|
||||
int intval = (int)fabs(f);
|
||||
int fractval = bLowPrecision ?
|
||||
( abs((int)(f*COORD_DENOMINATOR_LOWPRECISION)) & (COORD_DENOMINATOR_LOWPRECISION-1) ) :
|
||||
( abs((int)(f*COORD_DENOMINATOR)) & (COORD_DENOMINATOR-1) );
|
||||
@ -498,7 +498,7 @@ void old_bf_write::WriteBitCoord (const float f)
|
||||
VPROF( "old_bf_write::WriteBitCoord" );
|
||||
#endif
|
||||
int signbit = (f <= -COORD_RESOLUTION);
|
||||
int intval = (int)abs(f);
|
||||
int intval = (int)fabs(f);
|
||||
int fractval = abs((int)(f*COORD_DENOMINATOR)) & (COORD_DENOMINATOR-1);
|
||||
|
||||
|
||||
|
@ -34,7 +34,7 @@ void CharacterSetBuild( characterset_t *pSetBuffer, const char *pszSetString )
|
||||
|
||||
while ( pszSetString[i] )
|
||||
{
|
||||
pSetBuffer->set[ pszSetString[i] ] = 1;
|
||||
pSetBuffer->set[ static_cast<size_t>(pszSetString[i]) ] = 1;
|
||||
i++;
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ CVarDLLIdentifier_t ConCommandBase::GetDLLIdentifier() const
|
||||
//-----------------------------------------------------------------------------
|
||||
void ConCommandBase::Create( const char *pName, const char *pHelpString /*= 0*/, int flags /*= 0*/ )
|
||||
{
|
||||
static char *empty_string = "";
|
||||
static const char *empty_string = "";
|
||||
|
||||
m_bRegistered = false;
|
||||
|
||||
@ -592,7 +592,7 @@ void ConCommand::Dispatch( const CCommand &command )
|
||||
}
|
||||
|
||||
// Command without callback!!!
|
||||
AssertMsg( 0, ( "Encountered ConCommand '%s' without a callback!\n", GetName() ) );
|
||||
AssertMsg( 0, ( "Encountered ConCommand without a callback!\n" ) );
|
||||
}
|
||||
|
||||
|
||||
@ -907,7 +907,7 @@ void ConVar::Create( const char *pName, const char *pDefaultValue, int flags /*=
|
||||
const char *pHelpString /*= NULL*/, bool bMin /*= false*/, float fMin /*= 0.0*/,
|
||||
bool bMax /*= false*/, float fMax /*= false*/, FnChangeCallback_t callback /*= NULL*/ )
|
||||
{
|
||||
static char *empty_string = "";
|
||||
static const char *empty_string = "";
|
||||
|
||||
m_pParent = this;
|
||||
|
||||
|
@ -40,7 +40,7 @@ CMemoryPool::CMemoryPool( int blockSize, int numElements, int growMode, const ch
|
||||
|
||||
m_nAlignment = ( nAlignment != 0 ) ? nAlignment : 1;
|
||||
Assert( IsPowerOfTwo( m_nAlignment ) );
|
||||
m_BlockSize = blockSize < sizeof(void*) ? sizeof(void*) : blockSize;
|
||||
m_BlockSize = blockSize < (int)sizeof(void*) ? sizeof(void*) : blockSize;
|
||||
m_BlockSize = AlignValue( m_BlockSize, m_nAlignment );
|
||||
m_BlocksPerBlob = numElements;
|
||||
m_PeakAlloc = 0;
|
||||
|
@ -31,16 +31,19 @@ MEMALLOC_DEFINE_EXTERNAL_TRACKING(CMemoryStack);
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
CMemoryStack::CMemoryStack()
|
||||
: m_pBase( NULL ),
|
||||
m_pNextAlloc( NULL ),
|
||||
m_pAllocLimit( NULL ),
|
||||
: m_pNextAlloc( NULL ),
|
||||
m_pCommitLimit( NULL ),
|
||||
m_pAllocLimit( NULL ),
|
||||
m_pBase( NULL ),
|
||||
m_maxSize( 0 ),
|
||||
#if defined (_LINUX)
|
||||
m_alignment( 16 )
|
||||
#elif defined(_WIN32)
|
||||
m_alignment( 16 ),
|
||||
#if defined(_WIN32)
|
||||
m_commitSize( 0 ),
|
||||
m_minCommit( 0 ),
|
||||
m_minCommit( 0 )
|
||||
#endif
|
||||
m_maxSize( 0 )
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
@ -114,7 +117,7 @@ bool CMemoryStack::Init( unsigned maxSize, unsigned commitSize, unsigned initial
|
||||
}
|
||||
|
||||
#else
|
||||
m_pBase = MemAlloc_AllocAligned( m_maxSize, alignment ? alignment : 1 );
|
||||
m_pBase = (byte *)MemAlloc_AllocAligned( m_maxSize, alignment ? alignment : 1 );
|
||||
m_pNextAlloc = m_pBase;
|
||||
m_pCommitLimit = m_pBase + m_maxSize;
|
||||
#endif
|
||||
|
@ -150,7 +150,7 @@ void CBitWrite::WriteBytes( const void *pBuf, int nBytes )
|
||||
void CBitWrite::WriteBitCoord (const float f)
|
||||
{
|
||||
int signbit = (f <= -COORD_RESOLUTION);
|
||||
int intval = (int)abs(f);
|
||||
int intval = (int)fabs(f);
|
||||
int fractval = abs((int)(f*COORD_DENOMINATOR)) & (COORD_DENOMINATOR-1);
|
||||
|
||||
|
||||
@ -182,7 +182,7 @@ void CBitWrite::WriteBitCoord (const float f)
|
||||
void CBitWrite::WriteBitCoordMP (const float f, bool bIntegral, bool bLowPrecision )
|
||||
{
|
||||
int signbit = (f <= -( bLowPrecision ? COORD_RESOLUTION_LOWPRECISION : COORD_RESOLUTION ));
|
||||
int intval = (int)abs(f);
|
||||
int intval = (int)fabs(f);
|
||||
int fractval = bLowPrecision ?
|
||||
( abs((int)(f*COORD_DENOMINATOR_LOWPRECISION)) & (COORD_DENOMINATOR_LOWPRECISION-1) ) :
|
||||
( abs((int)(f*COORD_DENOMINATOR)) & (COORD_DENOMINATOR-1) );
|
||||
|
@ -885,17 +885,17 @@ char *V_pretifynum( int64 value )
|
||||
}
|
||||
|
||||
// Render quadrillions
|
||||
if ( value >= 1000000000000 )
|
||||
if ( value >= 1000000000000LL )
|
||||
{
|
||||
char *pchRender = out + V_strlen( out );
|
||||
V_snprintf( pchRender, 32, "%d,", value / 1000000000000 );
|
||||
V_snprintf( pchRender, 32, "%d,", value / 1000000000000LL );
|
||||
}
|
||||
|
||||
// Render trillions
|
||||
if ( value >= 1000000000000 )
|
||||
if ( value >= 1000000000000LL )
|
||||
{
|
||||
char *pchRender = out + V_strlen( out );
|
||||
V_snprintf( pchRender, 32, "%d,", value / 1000000000000 );
|
||||
V_snprintf( pchRender, 32, "%d,", value / 1000000000000LL );
|
||||
}
|
||||
|
||||
// Render billions
|
||||
@ -1413,7 +1413,7 @@ bool V_ExtractFilePath (const char *path, char *dest, int destSize )
|
||||
//-----------------------------------------------------------------------------
|
||||
void V_ExtractFileExtension( const char *path, char *dest, int destSize )
|
||||
{
|
||||
*dest = NULL;
|
||||
*dest = '\0';
|
||||
const char * extension = V_GetFileExtension( path );
|
||||
if ( NULL != extension )
|
||||
V_strncpy( dest, extension, destSize );
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,9 @@
|
||||
// Serialization buffer
|
||||
//===========================================================================//
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (disable : 4514)
|
||||
#endif
|
||||
|
||||
#include "utlbuffer.h"
|
||||
#include <stdio.h>
|
||||
@ -92,14 +94,14 @@ CUtlCStringConversion::CUtlCStringConversion( char nEscapeChar, const char *pDel
|
||||
memset( m_pConversion, 0x0, sizeof(m_pConversion) );
|
||||
for ( int i = 0; i < nCount; ++i )
|
||||
{
|
||||
m_pConversion[ pArray[i].m_pReplacementString[0] ] = pArray[i].m_nActualChar;
|
||||
m_pConversion[ static_cast<size_t>(pArray[i].m_pReplacementString[0]) ] = pArray[i].m_nActualChar;
|
||||
}
|
||||
}
|
||||
|
||||
// Finds a conversion for the passed-in string, returns length
|
||||
char CUtlCStringConversion::FindConversion( const char *pString, int *pLength )
|
||||
{
|
||||
char c = m_pConversion[ pString[0] ];
|
||||
char c = m_pConversion[ static_cast<size_t>(pString[0]) ];
|
||||
*pLength = (c != '\0') ? 1 : 0;
|
||||
return c;
|
||||
}
|
||||
@ -122,7 +124,7 @@ CUtlCharConversion::CUtlCharConversion( char nEscapeChar, const char *pDelimiter
|
||||
for ( int i = 0; i < nCount; ++i )
|
||||
{
|
||||
m_pList[i] = pArray[i].m_nActualChar;
|
||||
ConversionInfo_t &info = m_pReplacements[ m_pList[i] ];
|
||||
ConversionInfo_t &info = m_pReplacements[ static_cast<size_t>(m_pList[i]) ];
|
||||
Assert( info.m_pReplacementString == 0 );
|
||||
info.m_pReplacementString = pArray[i].m_pReplacementString;
|
||||
info.m_nLength = Q_strlen( info.m_pReplacementString );
|
||||
@ -158,12 +160,12 @@ int CUtlCharConversion::GetDelimiterLength() const
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *CUtlCharConversion::GetConversionString( char c ) const
|
||||
{
|
||||
return m_pReplacements[ c ].m_pReplacementString;
|
||||
return m_pReplacements[ static_cast<size_t>(c) ].m_pReplacementString;
|
||||
}
|
||||
|
||||
int CUtlCharConversion::GetConversionLength( char c ) const
|
||||
{
|
||||
return m_pReplacements[ c ].m_nLength;
|
||||
return m_pReplacements[ static_cast<size_t>(c) ].m_nLength;
|
||||
}
|
||||
|
||||
int CUtlCharConversion::MaxConversionLength() const
|
||||
@ -179,9 +181,9 @@ char CUtlCharConversion::FindConversion( const char *pString, int *pLength )
|
||||
{
|
||||
for ( int i = 0; i < m_nCount; ++i )
|
||||
{
|
||||
if ( !Q_strcmp( pString, m_pReplacements[ m_pList[i] ].m_pReplacementString ) )
|
||||
if ( !Q_strcmp( pString, m_pReplacements[ static_cast<size_t>(m_pList[i]) ].m_pReplacementString ) )
|
||||
{
|
||||
*pLength = m_pReplacements[ m_pList[i] ].m_nLength;
|
||||
*pLength = m_pReplacements[ static_cast<size_t>(m_pList[i]) ].m_nLength;
|
||||
return m_pList[i];
|
||||
}
|
||||
}
|
||||
@ -891,7 +893,9 @@ void CUtlBuffer::SeekGet( SeekType_t type, int offset )
|
||||
// Parse...
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning ( disable : 4706 )
|
||||
#endif
|
||||
|
||||
int CUtlBuffer::VaScanf( const char* pFmt, va_list list )
|
||||
{
|
||||
@ -903,7 +907,7 @@ int CUtlBuffer::VaScanf( const char* pFmt, va_list list )
|
||||
int nLength;
|
||||
char c;
|
||||
char* pEnd;
|
||||
while ( c = *pFmt++ )
|
||||
while ( (c = *pFmt++) )
|
||||
{
|
||||
// Stop if we hit the end of the buffer
|
||||
if ( m_Get >= TellMaxPut() )
|
||||
@ -1062,7 +1066,9 @@ int CUtlBuffer::VaScanf( const char* pFmt, va_list list )
|
||||
return numScanned;
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning ( default : 4706 )
|
||||
#endif
|
||||
|
||||
int CUtlBuffer::Scanf( const char* pFmt, ... )
|
||||
{
|
||||
@ -1681,7 +1687,7 @@ bool CUtlBuffer::ConvertCRLF( CUtlBuffer &outBuf )
|
||||
CUtlInplaceBuffer::CUtlInplaceBuffer( int growSize /* = 0 */, int initSize /* = 0 */, int nFlags /* = 0 */ ) :
|
||||
CUtlBuffer( growSize, initSize, nFlags )
|
||||
{
|
||||
NULL;
|
||||
|
||||
}
|
||||
|
||||
bool CUtlInplaceBuffer::InplaceGetLinePtr( char **ppszInBufferPtr, int *pnLineLength )
|
||||
|
@ -6,7 +6,9 @@
|
||||
// Serialization buffer
|
||||
//===========================================================================//
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (disable : 4514)
|
||||
#endif
|
||||
|
||||
#include "tier1/utlbufferutil.h"
|
||||
#include "tier1/utlbuffer.h"
|
||||
|
@ -6,7 +6,9 @@
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (disable:4514)
|
||||
#endif
|
||||
|
||||
#include "utlsymbol.h"
|
||||
#include "KeyValues.h"
|
||||
@ -344,7 +346,7 @@ FileNameHandle_t CUtlFilenameSymbolTable::FindFileName( const char *pFileName )
|
||||
handle.file = m_StringPool.FindStringHandle(filename);
|
||||
m_lock.UnlockRead();
|
||||
|
||||
if ( handle.path == NULL || handle.file == NULL )
|
||||
if ( handle.path == 0 || handle.file == 0 )
|
||||
return NULL;
|
||||
|
||||
return *( FileNameHandle_t * )( &handle );
|
||||
|
Reference in New Issue
Block a user