From 31a3fe54282d1fec8b5ceb96c2fa4a700ca547f2 Mon Sep 17 00:00:00 2001 From: Huoji's <1296564236@qq.com> Date: Sat, 21 Oct 2023 04:24:28 +0800 Subject: [PATCH] finished --- csgo2/global.cpp | 1 - csgo2/global.h | 1 - csgo2/hooks.cpp | 68 +++++++--- csgo2/hooks.h | 1 + csgo2/native_sdk.cpp | 2 +- csgo2/player_manager.cpp | 57 +++++---- csgo2/player_manager.h | 21 +++ csgo2/script_apis.cpp | 69 +++++++++- csgo2/sdk/public/igameeventsystem.h | 24 ++-- csgo2/sdk/sdk.h | 1 + csgo2/sdk/tier1/UtlString.cpp | 190 +--------------------------- csgo2/sdk/tier1/UtlString.hpp | 3 +- csgo2/sdk/tier1/bufferstring.h | 1 - 13 files changed, 192 insertions(+), 247 deletions(-) diff --git a/csgo2/global.cpp b/csgo2/global.cpp index bb961d4..3ce0e8a 100644 --- a/csgo2/global.cpp +++ b/csgo2/global.cpp @@ -8,5 +8,4 @@ namespace global { float m_flUniversalTime; float m_flLastTickedTime; bool IsMetaModInit; - bool IsDisableBlood; } \ No newline at end of file diff --git a/csgo2/global.h b/csgo2/global.h index 9f2c56f..c641844 100644 --- a/csgo2/global.h +++ b/csgo2/global.h @@ -11,5 +11,4 @@ namespace global { extern float m_flUniversalTime; extern float m_flLastTickedTime; extern bool IsMetaModInit; - extern bool IsDisableBlood; } \ No newline at end of file diff --git a/csgo2/hooks.cpp b/csgo2/hooks.cpp index c18ba9a..6d39b8c 100644 --- a/csgo2/hooks.cpp +++ b/csgo2/hooks.cpp @@ -17,6 +17,7 @@ GameFrame_t origin_GameFrame = NULL; CCSWeaponBase_Spawn_t origin_CCSWeaponBase_Spawn = NULL; UTIL_SayText2Filter_t origin_UTIL_SayText2Filter = NULL; PostEventAbstract_t origin_PostEventAbstract = NULL; + void __fastcall hook_PostEventAbstract( void* rcx, CSplitScreenSlot nSlot, @@ -28,26 +29,61 @@ void __fastcall hook_PostEventAbstract( unsigned long nSize, NetChannelBufType_t bufType) { - /* - if (global::IsDisableBlood == true) { + do + { + if (global::EntitySystem == nullptr) { + break; + } + if (pEvent == nullptr) { + break; + } NetMessageInfo_t* info = pEvent->GetNetMessageInfo(); - if (info) { - if (info->m_MessageId == TE_WorldDecalId) + if (info == nullptr) { + break; + } + const auto isBloodAboutMessage = (info->m_MessageId == TE_WorldDecalId || info->m_MessageId == TE_EffectDispatchId); + if (isBloodAboutMessage == false/* && isWeaponAboutMessage == false */) { + break; + } + for (uint64 i = 0; i < global::MaxPlayers; i++) + { + if (!(*(uint64*)clients & ((uint64)1 << i))) { + continue; + } + + const auto pEntity = global::EntitySystem->GetBaseEntity(i); + if (pEntity == nullptr) { + continue; + } + + if (pEntity->IsBasePlayerController() == false) { + continue; + } + const auto player = reinterpret_cast(pEntity); + + const auto [isSuccess, playerSetting] = ExtendPlayerManager::GetPlayerSettingBySteamId(player->m_steamID()); + if (isSuccess == false) { + continue; + } + bool skipTheEvent = false; + if (isBloodAboutMessage) { + skipTheEvent = (playerSetting.bloodSetting == _ExtendPlayerSetting_Blood::kDisableBloodEffectDispatch && info->m_MessageId == TE_EffectDispatchId) || + (playerSetting.bloodSetting == _ExtendPlayerSetting_Blood::kDisableBloodWorldDecal && info->m_MessageId == TE_WorldDecalId) || + (playerSetting.bloodSetting == _ExtendPlayerSetting_Blood::kDisableBloodWorldDecalAndEffectDispatch); + } + /* + else if (isWeaponAboutMessage) { - LOG("delete the blood in here \n"); - //*(uint64_t*)clients &= ~((uint64)1 << nSlot.Get()); + skipTheEvent = (playerSetting.weaponSetting == _ExtendPlayerSetting_Weapon::kDisablebulletHole); + } + */ + if (skipTheEvent) { + *(uint64*)clients &= ~((uint64)1 << i); + nClientCount--; } } - } - - */ - if (pEvent) { - NetMessageInfo_t* info = pEvent->GetNetMessageInfo(); - if (info && info->m_MessageId != 0) { - LOG("1111:%d \n", info->m_MessageId); - } - } - return origin_PostEventAbstract(rcx, nSlot, bLocalOnly, nClientCount, clients, pEvent, pData, nSize, bufType); + } while (false); + origin_PostEventAbstract(rcx, nSlot, bLocalOnly, nClientCount, clients, pEvent, pData, nSize, bufType); } void __fastcall hook_UTIL_SayText2Filter( IRecipientFilter& filter, CCSPlayerController* pEntity, diff --git a/csgo2/hooks.h b/csgo2/hooks.h index a5ef475..a20470a 100644 --- a/csgo2/hooks.h +++ b/csgo2/hooks.h @@ -19,6 +19,7 @@ typedef void(__fastcall* UTIL_SayText2Filter_t)(IRecipientFilter&, const char*, const char*, const char*, const char*, const char*); +//typedef void(__fastcall* PostEventAbstract_t)(void*, CSplitScreenSlot, bool, IRecipientFilter*, INetworkSerializable*, const void*, unsigned long); typedef void(__fastcall* PostEventAbstract_t)(void*, CSplitScreenSlot, bool, int, const uint64_t*, INetworkSerializable*, const void*, unsigned long, NetChannelBufType_t); namespace hooks { extern Host_Say_t original_Host_Say; diff --git a/csgo2/native_sdk.cpp b/csgo2/native_sdk.cpp index c605ef7..08bcb94 100644 --- a/csgo2/native_sdk.cpp +++ b/csgo2/native_sdk.cpp @@ -43,7 +43,7 @@ auto CCSPlayerPawn::GetPlayerController() -> CCSPlayerController* { if (!pEntitySystem) { return nullptr; } - for (int i = 1; i <= global::MaxPlayers; ++i) { + for (int i = 0; i <= global::MaxPlayers; ++i) { CBaseEntity* pEntity = pEntitySystem->GetBaseEntity(i); if (!pEntity) continue; if (pEntity->IsBasePlayerController()) { diff --git a/csgo2/player_manager.cpp b/csgo2/player_manager.cpp index b0f3a33..8442d45 100644 --- a/csgo2/player_manager.cpp +++ b/csgo2/player_manager.cpp @@ -1,32 +1,41 @@ #include "player_manager.h" namespace ExtendPlayerManager { std::shared_mutex mutex_Table_PlayerSteamIdPlayerSlot; - -std::unordered_map Table_PlayerSteamIdPlayerSlot; - +std::unordered_map Table_PlayerSteamIdPlayerSlot; +//GPT error fixed; auto SteamIDStringToUInt64(const std::string& steamID) -> uint64_t { - std::istringstream iss( - steamID.substr(3, steamID.size() - 4)); // 去掉"[U:"和"]" - std::string tmp; - uint32_t instance, account_id; - - // 读取 Account Instance - std::getline(iss, tmp, ':'); - instance = std::stoi(tmp); - - // 读取 Account ID - std::getline(iss, tmp); - account_id = std::stoi(tmp); - - // 计算并返回结果 - return (uint64_t(account_id) << 1 | instance) + 76561197960265728ULL; + std::size_t pos = steamID.find_last_of(":"); + if (pos != std::string::npos) { + uint64_t x = std::stoull(steamID.substr(pos + 1)); + return 76561197960265728 + x; + } + return -1; } - auto AddSteamIdToPlayerSteamIdWithNameTable(uint64_t SteamId, uint64_t PlayerSlot) -> void { std::unique_lock lock( mutex_Table_PlayerSteamIdPlayerSlot); - Table_PlayerSteamIdPlayerSlot.insert(std::make_pair(SteamId, PlayerSlot)); + Table_PlayerSteamIdPlayerSlot.insert(std::make_pair(SteamId, _ExtendPlayerSetting{.playerSlot = PlayerSlot })); +} +auto UpdatePlayerSettingBySteamId(uint64_t SteamId, _ExtendPlayerSetting setting) -> void { + std::shared_lock lock( + mutex_Table_PlayerSteamIdPlayerSlot); + + auto it = Table_PlayerSteamIdPlayerSlot.find(SteamId); + if (it != Table_PlayerSteamIdPlayerSlot.end()) { + it->second.bloodSetting = setting.bloodSetting; + it->second.weaponSetting = setting.weaponSetting; + } +} +auto GetPlayerSettingBySteamId(uint64_t SteamId) -> std::pair { + std::shared_lock lock( + mutex_Table_PlayerSteamIdPlayerSlot); + + auto it = Table_PlayerSteamIdPlayerSlot.find(SteamId); + if (it != Table_PlayerSteamIdPlayerSlot.end()) { + return { true, it->second }; + } + return { false, {} }; } auto GetPlayerSlotBySteamId(uint64_t SteamId) -> uint64_t { std::shared_lock lock( @@ -34,15 +43,15 @@ auto GetPlayerSlotBySteamId(uint64_t SteamId) -> uint64_t { auto it = Table_PlayerSteamIdPlayerSlot.find(SteamId); if (it != Table_PlayerSteamIdPlayerSlot.end()) { - return it->second; + return it->second.playerSlot; } return -1; } auto GetPlayerSteamIdByPlayerSlot(uint64_t playerSlot) -> uint64_t { std::shared_lock lock( mutex_Table_PlayerSteamIdPlayerSlot); - for (auto& [SteamId, PlayerSlot] : Table_PlayerSteamIdPlayerSlot) { - if (PlayerSlot == playerSlot) { + for (auto& [SteamId, PlayerSetting] : Table_PlayerSteamIdPlayerSlot) { + if (PlayerSetting.playerSlot == playerSlot) { return SteamId; } } @@ -65,7 +74,7 @@ auto GetPlayerByPlayerSlot(uint64_t playerSlot) -> CCSPlayerController* { if (!pEntitySystem) { return nullptr; } - for (int i = 1; i <= global::MaxPlayers; ++i) { + for (int i = 0; i <= global::MaxPlayers; ++i) { CBaseEntity* pEntity = pEntitySystem->GetBaseEntity(i); if (!pEntity) continue; if (pEntity->IsBasePlayerController()) { diff --git a/csgo2/player_manager.h b/csgo2/player_manager.h index 0d43ae3..8ecdd21 100644 --- a/csgo2/player_manager.h +++ b/csgo2/player_manager.h @@ -1,5 +1,24 @@ #pragma once #include "head.h" +enum class _ExtendPlayerSetting_Blood +{ + kNone, + kDisableBloodWorldDecal, + kDisableBloodEffectDispatch, + kDisableBloodWorldDecalAndEffectDispatch, + kMax +}; +enum class _ExtendPlayerSetting_Weapon +{ + kNone, + kDisablebulletHole, + kMax +}; +struct _ExtendPlayerSetting { + uint64_t playerSlot; + _ExtendPlayerSetting_Blood bloodSetting; + _ExtendPlayerSetting_Weapon weaponSetting; +}; namespace ExtendPlayerManager { auto AddSteamIdToPlayerSteamIdWithNameTable(uint64_t SteamId, uint64_t PlayerSlot) -> void; @@ -7,4 +26,6 @@ auto GetPlayerSlotBySteamId(uint64_t SteamId) -> uint64_t; auto SteamIDStringToUInt64(const std::string& steamID) -> uint64_t; auto RemovePlayerSlotBySteamId(uint64_t SteamId) -> void; auto GetPlayerByPlayerSlot(uint64_t playerSlot) -> CCSPlayerController*; +auto UpdatePlayerSettingBySteamId(uint64_t SteamId, _ExtendPlayerSetting setting) -> void; +auto GetPlayerSettingBySteamId(uint64_t SteamId)->std::pair; }; // namespace ExtendPlayerManager diff --git a/csgo2/script_apis.cpp b/csgo2/script_apis.cpp index db9d639..e0bea83 100644 --- a/csgo2/script_apis.cpp +++ b/csgo2/script_apis.cpp @@ -972,11 +972,68 @@ auto luaApi_GetConVarObject(lua_State* luaVm) -> int { return 1; } +auto luaApi_SetPlayerWeaponEffectStatus(lua_State* luaVm) -> int { + const auto playerIndex = lua_tointeger(luaVm, 1); + const auto status = lua_tointeger(luaVm, 2); + auto playerSlot = EntityIndex_to_PlayerSlot(playerIndex); + do + { + if (status >= static_cast(_ExtendPlayerSetting_Weapon::kMax) + || status < static_cast(_ExtendPlayerSetting_Weapon::kNone)) { + break; + } + if (playerSlot == -1) { + break; + } + auto player = ExtendPlayerManager::GetPlayerByPlayerSlot(playerSlot); + if (player == nullptr) { + break; + } + auto [isSuccess, playerSetting] = ExtendPlayerManager::GetPlayerSettingBySteamId(player->m_steamID()); + if (isSuccess == false) { + LOG("can't get player setting, wtf bug?? \n"); + break; + } + ExtendPlayerManager::UpdatePlayerSettingBySteamId(player->m_steamID(), _ExtendPlayerSetting{ + .bloodSetting = playerSetting.bloodSetting, + .weaponSetting = static_cast<_ExtendPlayerSetting_Weapon>(status) + }); -auto luaApi_SetServerBloodStatus(lua_State* luaVm) -> int { - // param: isEnableBoold:bool - global::IsDisableBlood = !lua_toboolean(luaVm, 1); - lua_pop(luaVm, 1); + } while (false); + + lua_pop(luaVm, 2); + return 0; +} +auto luaApi_SetPlayerBloodStatus(lua_State* luaVm) -> int { + const auto playerIndex = lua_tointeger(luaVm, 1); + const auto status = lua_tointeger(luaVm, 2); + auto playerSlot = EntityIndex_to_PlayerSlot(playerIndex); + do + { + if (status >= static_cast(_ExtendPlayerSetting_Blood::kMax) + || status < static_cast(_ExtendPlayerSetting_Blood::kNone)) { + break; + } + if (playerSlot == -1) { + break; + } + auto player = ExtendPlayerManager::GetPlayerByPlayerSlot(playerSlot); + if (player == nullptr) { + break; + } + auto [isSuccess, playerSetting] = ExtendPlayerManager::GetPlayerSettingBySteamId(player->m_steamID()); + if (isSuccess == false) { + LOG("can't get player setting, wtf bug?? \n"); + break; + } + ExtendPlayerManager::UpdatePlayerSettingBySteamId(player->m_steamID(), _ExtendPlayerSetting { + .bloodSetting = static_cast<_ExtendPlayerSetting_Blood>(status), + .weaponSetting = playerSetting.weaponSetting + }); + + } while (false); + + lua_pop(luaVm, 2); return 0; } auto initFunciton(lua_State* luaVm) -> void { @@ -1038,8 +1095,8 @@ auto initFunciton(lua_State* luaVm) -> void { lua_register(luaVm, "luaApi_GetPlayerName", luaApi_GetPlayerName); lua_register(luaVm, "luaApi_SetPlayerNameSlient", luaApi_SetPlayerNameSlient); - lua_register(luaVm, "luaApi_SetServerBloodStatus", luaApi_SetServerBloodStatus); - + //lua_register(luaVm, "luaApi_SetPlayerWeaponEffectStatus", luaApi_SetPlayerWeaponEffectStatus); + lua_register(luaVm, "luaApi_SetPlayerBloodStatus", luaApi_SetPlayerBloodStatus); // lua_register(luaVm, "luaApi_TeleportPlayer", luaApi_TeleportPlayer); luabridge::getGlobalNamespace(luaVm) diff --git a/csgo2/sdk/public/igameeventsystem.h b/csgo2/sdk/public/igameeventsystem.h index 644b089..859a31e 100644 --- a/csgo2/sdk/public/igameeventsystem.h +++ b/csgo2/sdk/public/igameeventsystem.h @@ -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 @@ class INetworkSerializable 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 diff --git a/csgo2/sdk/sdk.h b/csgo2/sdk/sdk.h index dc5ee15..44301b2 100644 --- a/csgo2/sdk/sdk.h +++ b/csgo2/sdk/sdk.h @@ -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, diff --git a/csgo2/sdk/tier1/UtlString.cpp b/csgo2/sdk/tier1/UtlString.cpp index 253dbaf..ef3b88c 100644 --- a/csgo2/sdk/tier1/UtlString.cpp +++ b/csgo2/sdk/tier1/UtlString.cpp @@ -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) -{ -} - -CUtlString::CUtlString(const void* pMemory, int nSizeInBytes) : m_Storage(pMemory, nSizeInBytes) +inline const char* CUtlString::Get() const { -} - -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(m_Storage.Get()); -} - -// Converts to c-strings -CUtlString::operator const char*() const -{ - 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(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; + return m_pString; } - -//----------------------------------------------------------------------------- -// Strips the trailing slash -//----------------------------------------------------------------------------- -void CUtlString::StripTrailingSlash() +inline void CUtlString::Set(const char* pValue) { - 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); - } } \ No newline at end of file diff --git a/csgo2/sdk/tier1/UtlString.hpp b/csgo2/sdk/tier1/UtlString.hpp index cc34b0e..a5863d6 100644 --- a/csgo2/sdk/tier1/UtlString.hpp +++ b/csgo2/sdk/tier1/UtlString.hpp @@ -181,7 +181,8 @@ class CUtlString static int __cdecl SortCaseSensitive(const CUtlString *pString1, const CUtlString *pString2); private: - CUtlBinaryBlock m_Storage; + //CUtlBinaryBlock m_Storage; + char* m_pString; }; diff --git a/csgo2/sdk/tier1/bufferstring.h b/csgo2/sdk/tier1/bufferstring.h index 9a30101..d314ef1 100644 --- a/csgo2/sdk/tier1/bufferstring.h +++ b/csgo2/sdk/tier1/bufferstring.h @@ -1,6 +1,5 @@ #pragma once #include "../sdk.h" -#define DLL_CLASS_IMPORT __declspec( dllimport ) class CFormatStringElement; class IFormatOutputStream;