finished
This commit is contained in:
@@ -9,9 +9,10 @@ typedef uint NetworkCategoryId;
|
||||
|
||||
enum NetChannelBufType_t
|
||||
{
|
||||
kFuckOffAss
|
||||
BUF_RELIABLE = 0,
|
||||
BUF_UNRELIABLE,
|
||||
BUF_VOICE,
|
||||
};
|
||||
|
||||
enum NetworkValidationMode_t
|
||||
{
|
||||
kFuckOffAss_NetworkValidationMode
|
||||
@@ -66,7 +67,7 @@ enum NetworkSerializationMode_t
|
||||
NET_SERIALIZATION_MODE_SERVER = 0x0,
|
||||
NET_SERIALIZATION_MODE_CLIENT = 0x1,
|
||||
};
|
||||
enum ETEProtobufIds_t {
|
||||
enum ETEProtobufIds : int {
|
||||
TE_EffectDispatchId = 400,
|
||||
TE_ArmorRicochetId = 401,
|
||||
TE_BeamEntPointId = 402,
|
||||
@@ -92,15 +93,16 @@ enum ETEProtobufIds_t {
|
||||
TE_PhysicsPropId = 423,
|
||||
TE_PlayerDecalId = 424,
|
||||
TE_ProjectedDecalId = 425,
|
||||
TE_SmokeId = 426
|
||||
TE_SmokeId = 426,
|
||||
TE_BulletHold = 452
|
||||
};
|
||||
class INetworkSerializable
|
||||
{
|
||||
public:
|
||||
virtual ~INetworkSerializable() = 0;
|
||||
|
||||
virtual const char* GetUnscopedName() = 0;
|
||||
virtual NetMessageInfo_t* GetNetMessageInfo() = 0;
|
||||
virtual const char *GetUnscopedName() = 0;
|
||||
virtual NetMessageInfo_t *GetNetMessageInfo() = 0;
|
||||
|
||||
virtual void SetMessageId(unsigned short nMessageId) = 0;
|
||||
|
||||
@@ -108,12 +110,12 @@ public:
|
||||
|
||||
virtual void SwitchMode(NetworkValidationMode_t nMode) = 0;
|
||||
|
||||
virtual void* AllocateMessage() = 0;
|
||||
virtual void DeallocateMessage(void* pMsg) = 0;
|
||||
virtual void* AllocateAndCopyConstructNetMessage(void const* pOther) = 0;
|
||||
virtual void *AllocateMessage() = 0;
|
||||
virtual void DeallocateMessage(void *pMsg) = 0;
|
||||
virtual void *AllocateAndCopyConstructNetMessage(void const *pOther) = 0;
|
||||
|
||||
virtual bool Serialize(bf_write& pBuf, void const* pData, NetworkSerializationMode_t unused) = 0;
|
||||
virtual bool Unserialize(bf_read& pBuf, void* pData, NetworkSerializationMode_t unused) = 0;
|
||||
virtual bool Serialize(bf_write &pBuf, void const *pData, NetworkSerializationMode_t unused) = 0;
|
||||
virtual bool Unserialize(bf_read &pBuf, void *pData, NetworkSerializationMode_t unused) = 0;
|
||||
};
|
||||
|
||||
class IGameEventSystem : public IAppSystem
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#define INCORRECT_PATH_SEPARATOR '/'
|
||||
#define INCORRECT_PATH_SEPARATOR_S "/"
|
||||
#define FMTFUNCTION(a, b)
|
||||
#define DLL_CLASS_IMPORT __declspec( dllimport )
|
||||
|
||||
enum EStringConvertErrorPolicy {
|
||||
_STRINGCONVERTFLAG_SKIP = 1,
|
||||
|
||||
@@ -116,195 +116,15 @@ CUtlString::CUtlString(const CUtlString& string)
|
||||
{
|
||||
Set(string.Get());
|
||||
}
|
||||
|
||||
// Attaches the string to external memory. Useful for avoiding a copy
|
||||
CUtlString::CUtlString(void* pMemory, int nSizeInBytes, int nInitialLength) : m_Storage(pMemory, nSizeInBytes, nInitialLength)
|
||||
inline const char* CUtlString::Get() const
|
||||
{
|
||||
}
|
||||
|
||||
CUtlString::CUtlString(const void* pMemory, int nSizeInBytes) : m_Storage(pMemory, nSizeInBytes)
|
||||
{
|
||||
}
|
||||
|
||||
void CUtlString::Set(const char *pValue)
|
||||
{
|
||||
_UtlString_assert(!m_Storage.IsReadOnly());
|
||||
int nLen = pValue ? strlen(pValue) + 1 : 0;
|
||||
m_Storage.Set(pValue, nLen);
|
||||
}
|
||||
|
||||
// Returns strlen
|
||||
int CUtlString::Length() const
|
||||
{
|
||||
return m_Storage.Length() ? m_Storage.Length() - 1 : 0;
|
||||
}
|
||||
|
||||
// Sets the length (used to serialize into the buffer )
|
||||
void CUtlString::SetLength(int nLen)
|
||||
{
|
||||
_UtlString_assert(!m_Storage.IsReadOnly());
|
||||
|
||||
// Add 1 to account for the NULL
|
||||
m_Storage.SetLength(nLen > 0 ? nLen + 1 : 0);
|
||||
}
|
||||
|
||||
const char *CUtlString::Get() const
|
||||
{
|
||||
if(m_Storage.Length() == 0) {
|
||||
if (!m_pString)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
return reinterpret_cast<const char*>(m_Storage.Get());
|
||||
return m_pString;
|
||||
}
|
||||
|
||||
// Converts to c-strings
|
||||
CUtlString::operator const char*() const
|
||||
inline void CUtlString::Set(const char* pValue)
|
||||
{
|
||||
return Get();
|
||||
}
|
||||
|
||||
char *CUtlString::Get()
|
||||
{
|
||||
_UtlString_assert(!m_Storage.IsReadOnly());
|
||||
|
||||
if(m_Storage.Length() == 0) {
|
||||
// In general, we optimise away small mallocs for empty strings
|
||||
// but if you ask for the non-const bytes, they must be writable
|
||||
// so we can't return "" here, like we do for the const version - jd
|
||||
m_Storage.SetLength(1);
|
||||
m_Storage[0] = '\0';
|
||||
}
|
||||
|
||||
return reinterpret_cast<char*>(m_Storage.Get());
|
||||
}
|
||||
|
||||
CUtlString &CUtlString::operator=(const CUtlString &src)
|
||||
{
|
||||
_UtlString_assert(!m_Storage.IsReadOnly());
|
||||
m_Storage = src.m_Storage;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CUtlString &CUtlString::operator=(const char *src)
|
||||
{
|
||||
_UtlString_assert(!m_Storage.IsReadOnly());
|
||||
Set(src);
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool CUtlString::operator==(const CUtlString &src) const
|
||||
{
|
||||
return m_Storage == src.m_Storage;
|
||||
}
|
||||
|
||||
bool CUtlString::operator==(const char *src) const
|
||||
{
|
||||
return (strcmp(Get(), src) == 0);
|
||||
}
|
||||
|
||||
CUtlString &CUtlString::operator+=(const CUtlString &rhs)
|
||||
{
|
||||
_UtlString_assert(!m_Storage.IsReadOnly());
|
||||
|
||||
const int lhsLength(Length());
|
||||
const int rhsLength(rhs.Length());
|
||||
const int requestedLength(lhsLength + rhsLength);
|
||||
|
||||
SetLength(requestedLength);
|
||||
const int allocatedLength(Length());
|
||||
const int copyLength(allocatedLength - lhsLength < rhsLength ? allocatedLength - lhsLength : rhsLength);
|
||||
memcpy(Get() + lhsLength, rhs.Get(), copyLength);
|
||||
m_Storage[allocatedLength] = '\0';
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CUtlString &CUtlString::operator+=(const char *rhs)
|
||||
{
|
||||
_UtlString_assert(!m_Storage.IsReadOnly());
|
||||
|
||||
const int lhsLength(Length());
|
||||
const int rhsLength(strlen(rhs));
|
||||
const int requestedLength(lhsLength + rhsLength);
|
||||
|
||||
SetLength(requestedLength);
|
||||
const int allocatedLength(Length());
|
||||
const int copyLength(allocatedLength - lhsLength < rhsLength ? allocatedLength - lhsLength : rhsLength);
|
||||
memcpy(Get() + lhsLength, rhs, copyLength);
|
||||
m_Storage[allocatedLength] = '\0';
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CUtlString &CUtlString::operator+=(char c)
|
||||
{
|
||||
_UtlString_assert(!m_Storage.IsReadOnly());
|
||||
|
||||
int nLength = Length();
|
||||
SetLength(nLength + 1);
|
||||
m_Storage[nLength] = c;
|
||||
m_Storage[nLength + 1] = '\0';
|
||||
return *this;
|
||||
}
|
||||
|
||||
CUtlString &CUtlString::operator+=(int rhs)
|
||||
{
|
||||
_UtlString_assert(!m_Storage.IsReadOnly());
|
||||
_UtlString_assert(sizeof(rhs) == 4);
|
||||
|
||||
char tmpBuf[12]; // Sufficient for a signed 32 bit integer [ -2147483648 to +2147483647 ]
|
||||
snprintf(tmpBuf, sizeof(tmpBuf), "%d", rhs);
|
||||
tmpBuf[sizeof(tmpBuf) - 1] = '\0';
|
||||
|
||||
return operator+=(tmpBuf);
|
||||
}
|
||||
|
||||
CUtlString &CUtlString::operator+=(double rhs)
|
||||
{
|
||||
_UtlString_assert(!m_Storage.IsReadOnly());
|
||||
|
||||
char tmpBuf[256]; // How big can doubles be??? Dunno.
|
||||
snprintf(tmpBuf, sizeof(tmpBuf), "%lg", rhs);
|
||||
tmpBuf[sizeof(tmpBuf) - 1] = '\0';
|
||||
|
||||
return operator+=(tmpBuf);
|
||||
}
|
||||
|
||||
int CUtlString::Format(const char *pFormat, ...)
|
||||
{
|
||||
_UtlString_assert(!m_Storage.IsReadOnly());
|
||||
|
||||
char tmpBuf[4096]; //< Nice big 4k buffer, as much memory as my first computer had, a Radio Shack Color Computer
|
||||
|
||||
va_list marker;
|
||||
|
||||
va_start(marker, pFormat);
|
||||
int len = _vsnprintf_s(tmpBuf, 4096, sizeof(tmpBuf) - 1, pFormat, marker);
|
||||
va_end(marker);
|
||||
|
||||
// Len < 0 represents an overflow
|
||||
if(len < 0) {
|
||||
len = sizeof(tmpBuf) - 1;
|
||||
tmpBuf[sizeof(tmpBuf) - 1] = 0;
|
||||
}
|
||||
|
||||
Set(tmpBuf);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Strips the trailing slash
|
||||
//-----------------------------------------------------------------------------
|
||||
void CUtlString::StripTrailingSlash()
|
||||
{
|
||||
if(IsEmpty())
|
||||
return;
|
||||
|
||||
int nLastChar = Length() - 1;
|
||||
char c = m_Storage[nLastChar];
|
||||
if(c == '\\' || c == '/') {
|
||||
m_Storage[nLastChar] = 0;
|
||||
m_Storage.SetLength(m_Storage.Length() - 1);
|
||||
}
|
||||
}
|
||||
@@ -181,7 +181,8 @@ public:
|
||||
static int __cdecl SortCaseSensitive(const CUtlString *pString1, const CUtlString *pString2);
|
||||
|
||||
private:
|
||||
CUtlBinaryBlock m_Storage;
|
||||
//CUtlBinaryBlock m_Storage;
|
||||
char* m_pString;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
#include "../sdk.h"
|
||||
#define DLL_CLASS_IMPORT __declspec( dllimport )
|
||||
|
||||
class CFormatStringElement;
|
||||
class IFormatOutputStream;
|
||||
|
||||
Reference in New Issue
Block a user