finished
This commit is contained in:
@@ -8,5 +8,4 @@ namespace global {
|
|||||||
float m_flUniversalTime;
|
float m_flUniversalTime;
|
||||||
float m_flLastTickedTime;
|
float m_flLastTickedTime;
|
||||||
bool IsMetaModInit;
|
bool IsMetaModInit;
|
||||||
bool IsDisableBlood;
|
|
||||||
}
|
}
|
||||||
@@ -11,5 +11,4 @@ namespace global {
|
|||||||
extern float m_flUniversalTime;
|
extern float m_flUniversalTime;
|
||||||
extern float m_flLastTickedTime;
|
extern float m_flLastTickedTime;
|
||||||
extern bool IsMetaModInit;
|
extern bool IsMetaModInit;
|
||||||
extern bool IsDisableBlood;
|
|
||||||
}
|
}
|
||||||
@@ -17,6 +17,7 @@ GameFrame_t origin_GameFrame = NULL;
|
|||||||
CCSWeaponBase_Spawn_t origin_CCSWeaponBase_Spawn = NULL;
|
CCSWeaponBase_Spawn_t origin_CCSWeaponBase_Spawn = NULL;
|
||||||
UTIL_SayText2Filter_t origin_UTIL_SayText2Filter = NULL;
|
UTIL_SayText2Filter_t origin_UTIL_SayText2Filter = NULL;
|
||||||
PostEventAbstract_t origin_PostEventAbstract = NULL;
|
PostEventAbstract_t origin_PostEventAbstract = NULL;
|
||||||
|
|
||||||
void __fastcall hook_PostEventAbstract(
|
void __fastcall hook_PostEventAbstract(
|
||||||
void* rcx,
|
void* rcx,
|
||||||
CSplitScreenSlot nSlot,
|
CSplitScreenSlot nSlot,
|
||||||
@@ -28,26 +29,61 @@ void __fastcall hook_PostEventAbstract(
|
|||||||
unsigned long nSize,
|
unsigned long nSize,
|
||||||
NetChannelBufType_t bufType)
|
NetChannelBufType_t bufType)
|
||||||
{
|
{
|
||||||
/*
|
do
|
||||||
if (global::IsDisableBlood == true) {
|
{
|
||||||
|
if (global::EntitySystem == nullptr) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (pEvent == nullptr) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
NetMessageInfo_t* info = pEvent->GetNetMessageInfo();
|
NetMessageInfo_t* info = pEvent->GetNetMessageInfo();
|
||||||
if (info) {
|
if (info == nullptr) {
|
||||||
if (info->m_MessageId == TE_WorldDecalId)
|
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<CCSPlayerController*>(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");
|
skipTheEvent = (playerSetting.weaponSetting == _ExtendPlayerSetting_Weapon::kDisablebulletHole);
|
||||||
//*(uint64_t*)clients &= ~((uint64)1 << nSlot.Get());
|
}
|
||||||
|
*/
|
||||||
|
if (skipTheEvent) {
|
||||||
|
*(uint64*)clients &= ~((uint64)1 << i);
|
||||||
|
nClientCount--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} while (false);
|
||||||
|
origin_PostEventAbstract(rcx, nSlot, bLocalOnly, nClientCount, clients, pEvent, pData, nSize, bufType);
|
||||||
*/
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
void __fastcall hook_UTIL_SayText2Filter(
|
void __fastcall hook_UTIL_SayText2Filter(
|
||||||
IRecipientFilter& filter, CCSPlayerController* pEntity,
|
IRecipientFilter& filter, CCSPlayerController* pEntity,
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ typedef void(__fastcall* UTIL_SayText2Filter_t)(IRecipientFilter&,
|
|||||||
const char*, const char*,
|
const char*, const char*,
|
||||||
const char*, 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);
|
typedef void(__fastcall* PostEventAbstract_t)(void*, CSplitScreenSlot, bool, int, const uint64_t*, INetworkSerializable*, const void*, unsigned long, NetChannelBufType_t);
|
||||||
namespace hooks {
|
namespace hooks {
|
||||||
extern Host_Say_t original_Host_Say;
|
extern Host_Say_t original_Host_Say;
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ auto CCSPlayerPawn::GetPlayerController() -> CCSPlayerController* {
|
|||||||
if (!pEntitySystem) {
|
if (!pEntitySystem) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
for (int i = 1; i <= global::MaxPlayers; ++i) {
|
for (int i = 0; i <= global::MaxPlayers; ++i) {
|
||||||
CBaseEntity* pEntity = pEntitySystem->GetBaseEntity(i);
|
CBaseEntity* pEntity = pEntitySystem->GetBaseEntity(i);
|
||||||
if (!pEntity) continue;
|
if (!pEntity) continue;
|
||||||
if (pEntity->IsBasePlayerController()) {
|
if (pEntity->IsBasePlayerController()) {
|
||||||
|
|||||||
@@ -1,32 +1,41 @@
|
|||||||
#include "player_manager.h"
|
#include "player_manager.h"
|
||||||
namespace ExtendPlayerManager {
|
namespace ExtendPlayerManager {
|
||||||
std::shared_mutex mutex_Table_PlayerSteamIdPlayerSlot;
|
std::shared_mutex mutex_Table_PlayerSteamIdPlayerSlot;
|
||||||
|
std::unordered_map<uint64_t, _ExtendPlayerSetting> Table_PlayerSteamIdPlayerSlot;
|
||||||
std::unordered_map<uint64_t, uint64_t> Table_PlayerSteamIdPlayerSlot;
|
//GPT error fixed;
|
||||||
|
|
||||||
auto SteamIDStringToUInt64(const std::string& steamID) -> uint64_t {
|
auto SteamIDStringToUInt64(const std::string& steamID) -> uint64_t {
|
||||||
std::istringstream iss(
|
std::size_t pos = steamID.find_last_of(":");
|
||||||
steamID.substr(3, steamID.size() - 4)); // 去掉"[U:"和"]"
|
if (pos != std::string::npos) {
|
||||||
std::string tmp;
|
uint64_t x = std::stoull(steamID.substr(pos + 1));
|
||||||
uint32_t instance, account_id;
|
return 76561197960265728 + x;
|
||||||
|
}
|
||||||
// 读取 Account Instance
|
return -1;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto AddSteamIdToPlayerSteamIdWithNameTable(uint64_t SteamId,
|
auto AddSteamIdToPlayerSteamIdWithNameTable(uint64_t SteamId,
|
||||||
uint64_t PlayerSlot) -> void {
|
uint64_t PlayerSlot) -> void {
|
||||||
std::unique_lock<std::shared_mutex> lock(
|
std::unique_lock<std::shared_mutex> lock(
|
||||||
mutex_Table_PlayerSteamIdPlayerSlot);
|
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<std::shared_mutex> 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<bool, _ExtendPlayerSetting> {
|
||||||
|
std::shared_lock<std::shared_mutex> 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 {
|
auto GetPlayerSlotBySteamId(uint64_t SteamId) -> uint64_t {
|
||||||
std::shared_lock<std::shared_mutex> lock(
|
std::shared_lock<std::shared_mutex> lock(
|
||||||
@@ -34,15 +43,15 @@ auto GetPlayerSlotBySteamId(uint64_t SteamId) -> uint64_t {
|
|||||||
|
|
||||||
auto it = Table_PlayerSteamIdPlayerSlot.find(SteamId);
|
auto it = Table_PlayerSteamIdPlayerSlot.find(SteamId);
|
||||||
if (it != Table_PlayerSteamIdPlayerSlot.end()) {
|
if (it != Table_PlayerSteamIdPlayerSlot.end()) {
|
||||||
return it->second;
|
return it->second.playerSlot;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
auto GetPlayerSteamIdByPlayerSlot(uint64_t playerSlot) -> uint64_t {
|
auto GetPlayerSteamIdByPlayerSlot(uint64_t playerSlot) -> uint64_t {
|
||||||
std::shared_lock<std::shared_mutex> lock(
|
std::shared_lock<std::shared_mutex> lock(
|
||||||
mutex_Table_PlayerSteamIdPlayerSlot);
|
mutex_Table_PlayerSteamIdPlayerSlot);
|
||||||
for (auto& [SteamId, PlayerSlot] : Table_PlayerSteamIdPlayerSlot) {
|
for (auto& [SteamId, PlayerSetting] : Table_PlayerSteamIdPlayerSlot) {
|
||||||
if (PlayerSlot == playerSlot) {
|
if (PlayerSetting.playerSlot == playerSlot) {
|
||||||
return SteamId;
|
return SteamId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -65,7 +74,7 @@ auto GetPlayerByPlayerSlot(uint64_t playerSlot) -> CCSPlayerController* {
|
|||||||
if (!pEntitySystem) {
|
if (!pEntitySystem) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
for (int i = 1; i <= global::MaxPlayers; ++i) {
|
for (int i = 0; i <= global::MaxPlayers; ++i) {
|
||||||
CBaseEntity* pEntity = pEntitySystem->GetBaseEntity(i);
|
CBaseEntity* pEntity = pEntitySystem->GetBaseEntity(i);
|
||||||
if (!pEntity) continue;
|
if (!pEntity) continue;
|
||||||
if (pEntity->IsBasePlayerController()) {
|
if (pEntity->IsBasePlayerController()) {
|
||||||
|
|||||||
@@ -1,5 +1,24 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "head.h"
|
#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 {
|
namespace ExtendPlayerManager {
|
||||||
auto AddSteamIdToPlayerSteamIdWithNameTable(uint64_t SteamId,
|
auto AddSteamIdToPlayerSteamIdWithNameTable(uint64_t SteamId,
|
||||||
uint64_t PlayerSlot) -> void;
|
uint64_t PlayerSlot) -> void;
|
||||||
@@ -7,4 +26,6 @@ auto GetPlayerSlotBySteamId(uint64_t SteamId) -> uint64_t;
|
|||||||
auto SteamIDStringToUInt64(const std::string& steamID) -> uint64_t;
|
auto SteamIDStringToUInt64(const std::string& steamID) -> uint64_t;
|
||||||
auto RemovePlayerSlotBySteamId(uint64_t SteamId) -> void;
|
auto RemovePlayerSlotBySteamId(uint64_t SteamId) -> void;
|
||||||
auto GetPlayerByPlayerSlot(uint64_t playerSlot) -> CCSPlayerController*;
|
auto GetPlayerByPlayerSlot(uint64_t playerSlot) -> CCSPlayerController*;
|
||||||
|
auto UpdatePlayerSettingBySteamId(uint64_t SteamId, _ExtendPlayerSetting setting) -> void;
|
||||||
|
auto GetPlayerSettingBySteamId(uint64_t SteamId)->std::pair<bool, _ExtendPlayerSetting>;
|
||||||
}; // namespace ExtendPlayerManager
|
}; // namespace ExtendPlayerManager
|
||||||
|
|||||||
@@ -972,11 +972,68 @@ auto luaApi_GetConVarObject(lua_State* luaVm) -> int {
|
|||||||
|
|
||||||
return 1;
|
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<int>(_ExtendPlayerSetting_Weapon::kMax)
|
||||||
|
|| status < static_cast<int>(_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 {
|
} while (false);
|
||||||
// param: isEnableBoold:bool
|
|
||||||
global::IsDisableBlood = !lua_toboolean(luaVm, 1);
|
lua_pop(luaVm, 2);
|
||||||
lua_pop(luaVm, 1);
|
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<int>(_ExtendPlayerSetting_Blood::kMax)
|
||||||
|
|| status < static_cast<int>(_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;
|
return 0;
|
||||||
}
|
}
|
||||||
auto initFunciton(lua_State* luaVm) -> void {
|
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_GetPlayerName", luaApi_GetPlayerName);
|
||||||
lua_register(luaVm, "luaApi_SetPlayerNameSlient",
|
lua_register(luaVm, "luaApi_SetPlayerNameSlient",
|
||||||
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);
|
// lua_register(luaVm, "luaApi_TeleportPlayer", luaApi_TeleportPlayer);
|
||||||
|
|
||||||
luabridge::getGlobalNamespace(luaVm)
|
luabridge::getGlobalNamespace(luaVm)
|
||||||
|
|||||||
@@ -9,9 +9,10 @@ typedef uint NetworkCategoryId;
|
|||||||
|
|
||||||
enum NetChannelBufType_t
|
enum NetChannelBufType_t
|
||||||
{
|
{
|
||||||
kFuckOffAss
|
BUF_RELIABLE = 0,
|
||||||
|
BUF_UNRELIABLE,
|
||||||
|
BUF_VOICE,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum NetworkValidationMode_t
|
enum NetworkValidationMode_t
|
||||||
{
|
{
|
||||||
kFuckOffAss_NetworkValidationMode
|
kFuckOffAss_NetworkValidationMode
|
||||||
@@ -66,7 +67,7 @@ enum NetworkSerializationMode_t
|
|||||||
NET_SERIALIZATION_MODE_SERVER = 0x0,
|
NET_SERIALIZATION_MODE_SERVER = 0x0,
|
||||||
NET_SERIALIZATION_MODE_CLIENT = 0x1,
|
NET_SERIALIZATION_MODE_CLIENT = 0x1,
|
||||||
};
|
};
|
||||||
enum ETEProtobufIds_t {
|
enum ETEProtobufIds : int {
|
||||||
TE_EffectDispatchId = 400,
|
TE_EffectDispatchId = 400,
|
||||||
TE_ArmorRicochetId = 401,
|
TE_ArmorRicochetId = 401,
|
||||||
TE_BeamEntPointId = 402,
|
TE_BeamEntPointId = 402,
|
||||||
@@ -92,15 +93,16 @@ enum ETEProtobufIds_t {
|
|||||||
TE_PhysicsPropId = 423,
|
TE_PhysicsPropId = 423,
|
||||||
TE_PlayerDecalId = 424,
|
TE_PlayerDecalId = 424,
|
||||||
TE_ProjectedDecalId = 425,
|
TE_ProjectedDecalId = 425,
|
||||||
TE_SmokeId = 426
|
TE_SmokeId = 426,
|
||||||
|
TE_BulletHold = 452
|
||||||
};
|
};
|
||||||
class INetworkSerializable
|
class INetworkSerializable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~INetworkSerializable() = 0;
|
virtual ~INetworkSerializable() = 0;
|
||||||
|
|
||||||
virtual const char* GetUnscopedName() = 0;
|
virtual const char *GetUnscopedName() = 0;
|
||||||
virtual NetMessageInfo_t* GetNetMessageInfo() = 0;
|
virtual NetMessageInfo_t *GetNetMessageInfo() = 0;
|
||||||
|
|
||||||
virtual void SetMessageId(unsigned short nMessageId) = 0;
|
virtual void SetMessageId(unsigned short nMessageId) = 0;
|
||||||
|
|
||||||
@@ -108,12 +110,12 @@ public:
|
|||||||
|
|
||||||
virtual void SwitchMode(NetworkValidationMode_t nMode) = 0;
|
virtual void SwitchMode(NetworkValidationMode_t nMode) = 0;
|
||||||
|
|
||||||
virtual void* AllocateMessage() = 0;
|
virtual void *AllocateMessage() = 0;
|
||||||
virtual void DeallocateMessage(void* pMsg) = 0;
|
virtual void DeallocateMessage(void *pMsg) = 0;
|
||||||
virtual void* AllocateAndCopyConstructNetMessage(void const* pOther) = 0;
|
virtual void *AllocateAndCopyConstructNetMessage(void const *pOther) = 0;
|
||||||
|
|
||||||
virtual bool Serialize(bf_write& pBuf, void const* 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;
|
virtual bool Unserialize(bf_read &pBuf, void *pData, NetworkSerializationMode_t unused) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IGameEventSystem : public IAppSystem
|
class IGameEventSystem : public IAppSystem
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#define INCORRECT_PATH_SEPARATOR '/'
|
#define INCORRECT_PATH_SEPARATOR '/'
|
||||||
#define INCORRECT_PATH_SEPARATOR_S "/"
|
#define INCORRECT_PATH_SEPARATOR_S "/"
|
||||||
#define FMTFUNCTION(a, b)
|
#define FMTFUNCTION(a, b)
|
||||||
|
#define DLL_CLASS_IMPORT __declspec( dllimport )
|
||||||
|
|
||||||
enum EStringConvertErrorPolicy {
|
enum EStringConvertErrorPolicy {
|
||||||
_STRINGCONVERTFLAG_SKIP = 1,
|
_STRINGCONVERTFLAG_SKIP = 1,
|
||||||
|
|||||||
@@ -116,195 +116,15 @@ CUtlString::CUtlString(const CUtlString& string)
|
|||||||
{
|
{
|
||||||
Set(string.Get());
|
Set(string.Get());
|
||||||
}
|
}
|
||||||
|
inline const char* CUtlString::Get() const
|
||||||
// Attaches the string to external memory. Useful for avoiding a copy
|
|
||||||
CUtlString::CUtlString(void* pMemory, int nSizeInBytes, int nInitialLength) : m_Storage(pMemory, nSizeInBytes, nInitialLength)
|
|
||||||
{
|
{
|
||||||
}
|
if (!m_pString)
|
||||||
|
{
|
||||||
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) {
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
return m_pString;
|
||||||
return reinterpret_cast<const char*>(m_Storage.Get());
|
|
||||||
}
|
}
|
||||||
|
inline void CUtlString::Set(const char* pValue)
|
||||||
// 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<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);
|
static int __cdecl SortCaseSensitive(const CUtlString *pString1, const CUtlString *pString2);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CUtlBinaryBlock m_Storage;
|
//CUtlBinaryBlock m_Storage;
|
||||||
|
char* m_pString;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "../sdk.h"
|
#include "../sdk.h"
|
||||||
#define DLL_CLASS_IMPORT __declspec( dllimport )
|
|
||||||
|
|
||||||
class CFormatStringElement;
|
class CFormatStringElement;
|
||||||
class IFormatOutputStream;
|
class IFormatOutputStream;
|
||||||
|
|||||||
Reference in New Issue
Block a user