From a0c29e7dd67abb15c74c85f07741784877edfdcd Mon Sep 17 00:00:00 2001 From: Joe Ludwig Date: Mon, 2 Sep 2013 11:39:10 -0700 Subject: General: * Fixed a variety of server browser issues with mods based on this SDK * Fixed many warnings on various platforms * Added source code for fgdlib and raytrace * Updated many source files with the latest shared source from TF2. OSX: * Added support for Xcode 4.6 * Switched OSX builds to use Xcode instead of makefiles * Moved libs from src/lib/osx32 to src/lib/public/osx32 or src/lib/common/osx32 to match windows better. Linux: * Moved libs from src/lib/linux32 to src/lib/public/linux32 or src/lib/common/linux32 to match windows better. --- mp/src/tier1/bitbuf.cpp | 10 +++++----- mp/src/tier1/strtools.cpp | 24 ++++++++++++++++++++++-- mp/src/tier1/tier1.vpc | 3 --- 3 files changed, 27 insertions(+), 10 deletions(-) (limited to 'mp/src/tier1') diff --git a/mp/src/tier1/bitbuf.cpp b/mp/src/tier1/bitbuf.cpp index 8294c93c..4c457aa4 100644 --- a/mp/src/tier1/bitbuf.cpp +++ b/mp/src/tier1/bitbuf.cpp @@ -877,7 +877,7 @@ unsigned int bf_read::CheckReadUBitLong(int numbits) void bf_read::ReadBits(void *pOutData, int nBits) { #if defined( BB_PROFILING ) - VPROF( "bf_write::ReadBits" ); + VPROF( "bf_read::ReadBits" ); #endif unsigned char *pOut = (unsigned char*)pOutData; @@ -1083,7 +1083,7 @@ unsigned int bf_read::ReadBitLong(int numbits, bool bSigned) float bf_read::ReadBitCoord (void) { #if defined( BB_PROFILING ) - VPROF( "bf_write::ReadBitCoord" ); + VPROF( "bf_read::ReadBitCoord" ); #endif int intval=0,fractval=0,signbit=0; float value = 0.0; @@ -1126,7 +1126,7 @@ float bf_read::ReadBitCoord (void) float bf_read::ReadBitCoordMP( bool bIntegral, bool bLowPrecision ) { #if defined( BB_PROFILING ) - VPROF( "bf_write::ReadBitCoordMP" ); + VPROF( "bf_read::ReadBitCoordMP" ); #endif // BitCoordMP float encoding: inbounds bit, integer bit, sign bit, optional int bits, float bits // BitCoordMP integer encoding: inbounds bit, integer bit, optional sign bit, optional int bits. @@ -1212,7 +1212,7 @@ float bf_read::ReadBitCoordMP( bool bIntegral, bool bLowPrecision ) unsigned int bf_read::ReadBitCoordBits (void) { #if defined( BB_PROFILING ) - VPROF( "bf_write::ReadBitCoordBits" ); + VPROF( "bf_read::ReadBitCoordBits" ); #endif unsigned int flags = ReadUBitLong(2); @@ -1231,7 +1231,7 @@ unsigned int bf_read::ReadBitCoordBits (void) unsigned int bf_read::ReadBitCoordMPBits( bool bIntegral, bool bLowPrecision ) { #if defined( BB_PROFILING ) - VPROF( "bf_write::ReadBitCoordMPBits" ); + VPROF( "bf_read::ReadBitCoordMPBits" ); #endif unsigned int flags = ReadUBitLong(2); diff --git a/mp/src/tier1/strtools.cpp b/mp/src/tier1/strtools.cpp index 6e0ba9f5..5e7fd002 100644 --- a/mp/src/tier1/strtools.cpp +++ b/mp/src/tier1/strtools.cpp @@ -1491,14 +1491,34 @@ int V_UCS2ToUTF8( const ucs2 *pUCS2, char *pUTF8, int cubDestSizeInBytes ) #elif defined(POSIX) iconv_t conv_t = iconv_open( "UTF-8", "UCS-2LE" ); size_t cchResult = -1; - size_t nLenUnicde = cubDestSizeInBytes; - size_t nMaxUTF8 = cubDestSizeInBytes; + + // pUCS2 will be null-terminated so use that to work out the input + // buffer size. Note that we shouldn't assume iconv will stop when it + // finds a zero, and nLenUnicde should be given in bytes, so we multiply + // it by sizeof( ucs2 ) at the end. + size_t nLenUnicde = 0; + while ( pUCS2[nLenUnicde] ) + { + ++nLenUnicde; + } + nLenUnicde *= sizeof( ucs2 ); + + // Calculate number of bytes we want iconv to write, leaving space + // for the null-terminator + size_t nMaxUTF8 = cubDestSizeInBytes - 1; char *pIn = (char *)pUCS2; char *pOut = (char *)pUTF8; if ( conv_t > 0 ) { cchResult = 0; + const size_t nBytesToWrite = nMaxUTF8; cchResult = iconv( conv_t, &pIn, &nLenUnicde, &pOut, &nMaxUTF8 ); + + // Calculate how many bytes were actually written and use that to + // null-terminate our output string. + const size_t nBytesWritten = nBytesToWrite - nMaxUTF8; + pUTF8[nBytesWritten] = 0; + iconv_close( conv_t ); if ( (int)cchResult < 0 ) cchResult = 0; diff --git a/mp/src/tier1/tier1.vpc b/mp/src/tier1/tier1.vpc index eac035ce..9ff36c83 100644 --- a/mp/src/tier1/tier1.vpc +++ b/mp/src/tier1/tier1.vpc @@ -5,11 +5,8 @@ //----------------------------------------------------------------------------- $macro SRCDIR ".." - -$macro OUTLIBDIR "$SRCDIR\lib\public" [!$LINUX && !$OSXALL] $include "$SRCDIR\vpc_scripts\source_lib_base.vpc" -$include "$SRCDIR\vstdlib\vstdlib_exclude.vpc" [$OSXALL] $Configuration { -- cgit v1.2.3