武器崩溃问题
This commit is contained in:
@@ -12,6 +12,39 @@ OnClientDisconnect_t original_OnClientDisconnect = NULL;
|
|||||||
Host_Say_t original_Host_Say = NULL;
|
Host_Say_t original_Host_Say = NULL;
|
||||||
StartupServer_t origin_StartServer = NULL;
|
StartupServer_t origin_StartServer = NULL;
|
||||||
GameFrame_t origin_GameFrame = NULL;
|
GameFrame_t origin_GameFrame = NULL;
|
||||||
|
CCSWeaponBase_Spawn_t origin_CCSWeaponBase_Spawn = NULL;
|
||||||
|
|
||||||
|
void __fastcall hook_CCSWeaponBase_Spawn(CBaseEntity* pThis, void* a2) {
|
||||||
|
const char* pszClassName = pThis->m_pEntity()->m_designerName;
|
||||||
|
LOG("Weapon spawn: %s\n", pszClassName);
|
||||||
|
|
||||||
|
origin_CCSWeaponBase_Spawn(pThis, a2);
|
||||||
|
|
||||||
|
do {
|
||||||
|
auto pWeapon = reinterpret_cast<CCSWeaponBase*>(pThis);
|
||||||
|
// Weapon could be already initialized with the correct data from
|
||||||
|
// GiveNamedItem, in that case we don't need to do anything
|
||||||
|
if (!pWeapon ||
|
||||||
|
pWeapon->m_AttributeManager()->m_Item()->m_bInitialized()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (GameWeapons::WeaponMap.find(pszClassName) ==
|
||||||
|
GameWeapons::WeaponMap.end()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const auto [fullWeaponName, weaponiItemDefIndex] =
|
||||||
|
GameWeapons::WeaponMap.at(pszClassName);
|
||||||
|
|
||||||
|
LOG("Fixing a %s with index = %d and initialized = %d\n", pszClassName,
|
||||||
|
pWeapon->m_AttributeManager()->m_Item()->m_iItemDefinitionIndex(),
|
||||||
|
pWeapon->m_AttributeManager()->m_Item()->m_bInitialized());
|
||||||
|
|
||||||
|
pWeapon->m_AttributeManager()->m_Item()->m_bInitialized(true);
|
||||||
|
pWeapon->m_AttributeManager()->m_Item()->m_iItemDefinitionIndex(
|
||||||
|
weaponiItemDefIndex);
|
||||||
|
} while (false);
|
||||||
|
}
|
||||||
|
|
||||||
void __fastcall hook_GameFrame(void* rcx, bool simulating, bool bFirstTick,
|
void __fastcall hook_GameFrame(void* rcx, bool simulating, bool bFirstTick,
|
||||||
bool bLastTick) {
|
bool bLastTick) {
|
||||||
/**
|
/**
|
||||||
@@ -180,6 +213,13 @@ auto initMinHook() -> bool {
|
|||||||
LOG("MH_CreateHook original_Host_Say\n");
|
LOG("MH_CreateHook original_Host_Say\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (MH_CreateHook((LPVOID)Offset::FnCCSWeaponBase_Spawn,
|
||||||
|
&hook_CCSWeaponBase_Spawn,
|
||||||
|
reinterpret_cast<LPVOID*>(
|
||||||
|
&origin_CCSWeaponBase_Spawn)) != MH_OK) {
|
||||||
|
LOG("MH_CreateHook origin_CCSWeaponBase_Spawn\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
// <20><><EFBFBD>ù<EFBFBD><C3B9><EFBFBD>
|
// <20><><EFBFBD>ù<EFBFBD><C3B9><EFBFBD>
|
||||||
if (MH_EnableHook(MH_ALL_HOOKS) != MH_OK) {
|
if (MH_EnableHook(MH_ALL_HOOKS) != MH_OK) {
|
||||||
LOG("MH_EnableHook \n");
|
LOG("MH_EnableHook \n");
|
||||||
|
|||||||
@@ -205,14 +205,16 @@ class CUtlVector_NativeSdk {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class CBaseEntity;
|
class CBaseEntity;
|
||||||
|
|
||||||
|
|
||||||
class CEntityIdentity {
|
class CEntityIdentity {
|
||||||
public:
|
public:
|
||||||
CBaseEntity* entity; // 0
|
CBaseEntity* entity; // 0
|
||||||
void* dunno; // 8
|
void* dunno; // 8
|
||||||
int64_t unk0; // 12
|
int64_t unk0; // 12
|
||||||
int64_t unk1; // 16
|
int64_t unk1; // 16
|
||||||
const char* internalName;
|
const char* m_name;
|
||||||
const char* entityName;
|
const char* m_designerName;
|
||||||
void* unk2;
|
void* unk2;
|
||||||
void* unk3;
|
void* unk3;
|
||||||
void* unk4;
|
void* unk4;
|
||||||
@@ -407,6 +409,8 @@ class CEconItemView {
|
|||||||
auto GetStaticData() {
|
auto GetStaticData() {
|
||||||
return CALL_VIRTUAL(CEconItemDefinition*, 13, this);
|
return CALL_VIRTUAL(CEconItemDefinition*, 13, this);
|
||||||
}
|
}
|
||||||
|
SCHEMA_FIELD(uint16_t, m_iItemDefinitionIndex)
|
||||||
|
SCHEMA_FIELD(bool, m_bInitialized)
|
||||||
};
|
};
|
||||||
class CAttributeContainer {
|
class CAttributeContainer {
|
||||||
public:
|
public:
|
||||||
@@ -421,6 +425,11 @@ class CEconEntity {
|
|||||||
PSCHEMA_FIELD(CAttributeContainer, m_AttributeManager);
|
PSCHEMA_FIELD(CAttributeContainer, m_AttributeManager);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CCSWeaponBase : public CEconEntity
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DECLARE_CLASS(CCSWeaponBase)
|
||||||
|
};
|
||||||
class CBasePlayerWeapon : public CEconEntity {
|
class CBasePlayerWeapon : public CEconEntity {
|
||||||
public:
|
public:
|
||||||
DECLARE_CLASS(CBasePlayerWeapon);
|
DECLARE_CLASS(CBasePlayerWeapon);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ EntityRemove_t FnEntityRemove;
|
|||||||
UTIL_SayTextFilter_t FnUTIL_SayTextFilter;
|
UTIL_SayTextFilter_t FnUTIL_SayTextFilter;
|
||||||
UTIL_ClientPrintAll_t FnUTIL_ClientPrintAll;
|
UTIL_ClientPrintAll_t FnUTIL_ClientPrintAll;
|
||||||
ClientPrint_t FnClientPrint;
|
ClientPrint_t FnClientPrint;
|
||||||
|
CCSWeaponBase_Spawn_t FnCCSWeaponBase_Spawn;
|
||||||
// CreateGameRuleInterFace_t FnCreateCCSGameRulesInterFace;
|
// CreateGameRuleInterFace_t FnCreateCCSGameRulesInterFace;
|
||||||
bool InitOffsetSuccess = false;
|
bool InitOffsetSuccess = false;
|
||||||
namespace InterFaces {
|
namespace InterFaces {
|
||||||
@@ -79,6 +80,8 @@ auto Init() -> bool {
|
|||||||
server.FindPattern(pattern_FnClientPrint).Get(FnClientPrint);
|
server.FindPattern(pattern_FnClientPrint).Get(FnClientPrint);
|
||||||
|
|
||||||
server.FindPattern(pattern_FnUTIL_SayTextFilter).Get(FnUTIL_SayTextFilter);
|
server.FindPattern(pattern_FnUTIL_SayTextFilter).Get(FnUTIL_SayTextFilter);
|
||||||
|
server.FindPattern(pattern_CCSWeaponBase_Spawn).Get(FnCCSWeaponBase_Spawn);
|
||||||
|
|
||||||
InterFaces::SchemaSystem = reinterpret_cast<CSchemaSystem*>(
|
InterFaces::SchemaSystem = reinterpret_cast<CSchemaSystem*>(
|
||||||
schemasystem.FindInterface("SchemaSystem_001").Get());
|
schemasystem.FindInterface("SchemaSystem_001").Get());
|
||||||
// InterFaces::GameEventManager = reinterpret_cast<IGameEventManager2*>(
|
// InterFaces::GameEventManager = reinterpret_cast<IGameEventManager2*>(
|
||||||
@@ -124,6 +127,7 @@ auto Init() -> bool {
|
|||||||
LOG("[huoji]FnGiveNamedItem : %llx \n", FnGiveNamedItem);
|
LOG("[huoji]FnGiveNamedItem : %llx \n", FnGiveNamedItem);
|
||||||
LOG("[huoji]FnClientPrint : %llx \n", FnClientPrint);
|
LOG("[huoji]FnClientPrint : %llx \n", FnClientPrint);
|
||||||
LOG("[huoji]FnUTIL_ClientPrintAll : %llx \n", FnUTIL_ClientPrintAll);
|
LOG("[huoji]FnUTIL_ClientPrintAll : %llx \n", FnUTIL_ClientPrintAll);
|
||||||
|
LOG("[huoji]FnCCSWeaponBase_Spawn : %llx \n", FnCCSWeaponBase_Spawn);
|
||||||
|
|
||||||
LOG("[huoji]MaxGlobals : %d \n", global::MaxPlayers);
|
LOG("[huoji]MaxGlobals : %d \n", global::MaxPlayers);
|
||||||
|
|
||||||
@@ -150,7 +154,7 @@ auto Init() -> bool {
|
|||||||
0, NULL);
|
0, NULL);
|
||||||
// LOG("FnServerHashFunction: %llx \n", FnServerHashFunction("here",
|
// LOG("FnServerHashFunction: %llx \n", FnServerHashFunction("here",
|
||||||
// sizeof("here") - 1, 0x31415926));
|
// sizeof("here") - 1, 0x31415926));
|
||||||
return FnEntityRemove && FnRespawnPlayer && FnGiveNamedItem &&
|
return FnCCSWeaponBase_Spawn && FnEntityRemove && FnRespawnPlayer && FnGiveNamedItem &&
|
||||||
FnServerHashFunction && Host_SayPtr && InterFaces::IVEngineServer &&
|
FnServerHashFunction && Host_SayPtr && InterFaces::IVEngineServer &&
|
||||||
InterFaces::GameResourceServiceServer &&
|
InterFaces::GameResourceServiceServer &&
|
||||||
InterFaces::IServerGameClient && InterFaces::GameEventManager &&
|
InterFaces::IServerGameClient && InterFaces::GameEventManager &&
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ class CEntityInstance;
|
|||||||
class CCSPlayerPawn;
|
class CCSPlayerPawn;
|
||||||
class CGameEntitySystem;
|
class CGameEntitySystem;
|
||||||
class CCSPlayerController;
|
class CCSPlayerController;
|
||||||
|
class CBaseEntity;
|
||||||
typedef uint64_t(__fastcall* HashFunction_t)(const char*, unsigned int,
|
typedef uint64_t(__fastcall* HashFunction_t)(const char*, unsigned int,
|
||||||
unsigned int);
|
unsigned int);
|
||||||
typedef void(__fastcall* StateChanged_t)(void* networkTransmitComponent,
|
typedef void(__fastcall* StateChanged_t)(void* networkTransmitComponent,
|
||||||
@@ -24,6 +25,7 @@ typedef void*(__fastcall* UTIL_SayTextFilter_t)(IRecipientFilter&, const char*,
|
|||||||
CCSPlayerController*, uint64_t);
|
CCSPlayerController*, uint64_t);
|
||||||
typedef void(__fastcall* UTIL_ClientPrintAll_t)(int msg_dest, const char* msg_name, const char* param1, const char* param2, const char* param3, const char* param4);
|
typedef void(__fastcall* UTIL_ClientPrintAll_t)(int msg_dest, const char* msg_name, const char* param1, const char* param2, const char* param3, const char* param4);
|
||||||
typedef void(__fastcall* ClientPrint_t)(CCSPlayerController* player, int msg_dest, const char* msg_name, const char* param1, const char* param2, const char* param3, const char* param4);
|
typedef void(__fastcall* ClientPrint_t)(CCSPlayerController* player, int msg_dest, const char* msg_name, const char* param1, const char* param2, const char* param3, const char* param4);
|
||||||
|
typedef void(__fastcall* CCSWeaponBase_Spawn_t)(CBaseEntity*, void*);
|
||||||
|
|
||||||
class CSchemaSystem;
|
class CSchemaSystem;
|
||||||
class CGameResourceService;
|
class CGameResourceService;
|
||||||
@@ -91,6 +93,7 @@ static const auto pattern_UTIL_ClientPrintAll = THE_GAME_SIG(
|
|||||||
"48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 48 81 EC 70 01 ?? ?? 8B E9");
|
"48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 48 81 EC 70 01 ?? ?? 8B E9");
|
||||||
static const auto pattern_FnClientPrint = THE_GAME_SIG(
|
static const auto pattern_FnClientPrint = THE_GAME_SIG(
|
||||||
"48 85 C9 0F 84 ?? ?? ?? ?? 48 8B C4 48 89 58 18");
|
"48 85 C9 0F 84 ?? ?? ?? ?? 48 8B C4 48 89 58 18");
|
||||||
|
static const auto pattern_CCSWeaponBase_Spawn = THE_GAME_SIG("48 89 5C 24 08 48 89 6C 24 18 48 89 74 24 20 57 48 83 EC 30 48 8B DA 48 8B E9 E8 ?? ?? ?? ??");
|
||||||
extern uint64_t GameResourceServicePtr;
|
extern uint64_t GameResourceServicePtr;
|
||||||
extern uint64_t FireEventServerSidePtr;
|
extern uint64_t FireEventServerSidePtr;
|
||||||
extern uint64_t Module_tier0;
|
extern uint64_t Module_tier0;
|
||||||
@@ -105,6 +108,7 @@ extern EntityRemove_t FnEntityRemove;
|
|||||||
extern UTIL_SayTextFilter_t FnUTIL_SayTextFilter;
|
extern UTIL_SayTextFilter_t FnUTIL_SayTextFilter;
|
||||||
extern UTIL_ClientPrintAll_t FnUTIL_ClientPrintAll;
|
extern UTIL_ClientPrintAll_t FnUTIL_ClientPrintAll;
|
||||||
extern ClientPrint_t FnClientPrint;
|
extern ClientPrint_t FnClientPrint;
|
||||||
|
extern CCSWeaponBase_Spawn_t FnCCSWeaponBase_Spawn;
|
||||||
extern bool InitOffsetSuccess;
|
extern bool InitOffsetSuccess;
|
||||||
auto Init() -> bool;
|
auto Init() -> bool;
|
||||||
}; // namespace Offset
|
}; // namespace Offset
|
||||||
|
|||||||
@@ -5,44 +5,43 @@ namespace GameWeapons {
|
|||||||
|
|
||||||
static const std::unordered_map<std::string, std::pair<std::string, int>>
|
static const std::unordered_map<std::string, std::pair<std::string, int>>
|
||||||
WeaponMap = {
|
WeaponMap = {
|
||||||
{"bizon", {"weapon_bizon", 1400}},
|
{"bizon", {"weapon_bizon", 26}},
|
||||||
{"mac10", {"weapon_mac10", 1400}},
|
{"mac10", {"weapon_mac10", 27}},
|
||||||
{"mp7", {"weapon_mp7", 1700}},
|
{"mp7", {"weapon_mp7", 23}},
|
||||||
{"mp9", {"weapon_mp9", 1250}},
|
{"mp9", {"weapon_mp9", 34}},
|
||||||
{"p90", {"weapon_p90", 2350}},
|
{"p90", {"weapon_p90", 19}},
|
||||||
{"ump45", {"weapon_ump45", 1700}},
|
{"ump45", {"weapon_ump45", 24}},
|
||||||
{"ak47", {"weapon_ak47", 2500}},
|
{"ak47", {"weapon_ak47", 7}},
|
||||||
{"aug", {"weapon_aug", 3500}},
|
{"aug", {"weapon_aug", 8}},
|
||||||
{"famas", {"weapon_famas", 2250}},
|
{"famas", {"weapon_famas", 10}},
|
||||||
{"galilar", {"weapon_galilar", 2000}},
|
{"galilar", {"weapon_galilar", 13}},
|
||||||
{"m4a4", {"weapon_m4a4", 3100}},
|
{"m4a4", {"weapon_m4a1", 16}},
|
||||||
{"m4a1_silencer", {"weapon_m4a1_silencer", 3100}},
|
{"m4a1", {"weapon_m4a1_silencer", 60}},
|
||||||
{"m4a1", {"weapon_m4a1_silencer", 3100}},
|
{"sg556", {"weapon_sg556", 39}},
|
||||||
{"a1", {"weapon_m4a1_silencer", 3100}},
|
{"awp", {"weapon_awp", 9}},
|
||||||
{"sg556", {"weapon_sg556", 3500}},
|
{"g3sg1", {"weapon_g3sg1", 11}},
|
||||||
{"awp", {"weapon_awp", 4750}},
|
{"scar20", {"weapon_scar20", 38}},
|
||||||
{"g3sg1", {"weapon_g3sg1", 5000}},
|
{"ssg08", {"weapon_ssg08", 40}},
|
||||||
{"scar20", {"weapon_scar20", 5000}},
|
{"mag7", {"weapon_mag7", 29}},
|
||||||
{"ssg08", {"weapon_ssg08", 2500}},
|
{"nova", {"weapon_nova", 35}},
|
||||||
{"mag7", {"weapon_mag7", 2000}},
|
{"sawedoff", {"weapon_sawedoff", 29}},
|
||||||
{"nova", {"weapon_nova", 1500}},
|
{"xm1014", {"weapon_xm1014", 25}},
|
||||||
{"sawedoff", {"weapon_sawedoff", 1500}},
|
{"m249", {"weapon_m249", 14}},
|
||||||
{"xm1014", {"weapon_xm1014", 3000}},
|
{"negev", {"weapon_negev", 28}},
|
||||||
{"m249", {"weapon_m249", 5750}},
|
{"deagle", {"weapon_deagle", 1}},
|
||||||
{"negev", {"weapon_negev", 5750}},
|
{"elite", {"weapon_elite", 2}},
|
||||||
{"deagle", {"weapon_deagle", 700}},
|
{"fiveseven", {"weapon_fiveseven", 3}},
|
||||||
{"elite", {"weapon_elite", 800}},
|
{"glock", {"weapon_glock", 4}},
|
||||||
{"fiveseven", {"weapon_fiveseven", 500}},
|
{"hkp2000", {"weapon_hkp2000", 32}},
|
||||||
{"glock", {"weapon_glock", 200}},
|
{"p250", {"weapon_p250", 36}},
|
||||||
{"hkp2000", {"weapon_hkp2000", 200}},
|
{"tec9", {"weapon_tec9", 30}},
|
||||||
{"p250", {"weapon_p250", 300}},
|
{"usp_silencer", {"weapon_usp_silencer", 61}},
|
||||||
{"tec9", {"weapon_tec9", 500}},
|
{"cz75a", {"weapon_cz75a", 63}},
|
||||||
{"usp_silencer", {"weapon_usp_silencer", 200}},
|
{"revolver", {"weapon_revolver", 64}},
|
||||||
{"cz75a", {"weapon_cz75a", 500}},
|
{"he", {"weapon_hegrenade", 44}},
|
||||||
{"revolver", {"weapon_revolver", 600}},
|
{"molotov", {"weapon_molotov", 46}},
|
||||||
{"kevlar", {"item_kevlar", 600}},
|
{"knife", {"weapon_knife", 42}}, // default CT knife
|
||||||
{"he", {"weapon_hegrenade", 300}},
|
{"kevlar", {"item_kevlar", 50}},
|
||||||
{"molotov", {"weapon_hegrenade", 850}},
|
|
||||||
};
|
};
|
||||||
auto ParseWeaponCommand(CCSPlayerController* pController,
|
auto ParseWeaponCommand(CCSPlayerController* pController,
|
||||||
std::string pszWeaponName) -> bool;
|
std::string pszWeaponName) -> bool;
|
||||||
|
|||||||
Reference in New Issue
Block a user