Merge pull request #985 from nullworks/crash_fix
Fix potential crashes and confusing naming Scheme
This commit is contained in:
commit
2c14b5b487
@ -80,9 +80,9 @@ struct offsets
|
|||||||
{
|
{
|
||||||
return PlatformOffset(7, undefined, undefined);
|
return PlatformOffset(7, undefined, undefined);
|
||||||
}
|
}
|
||||||
static constexpr uint32_t CreateMoveLate()
|
static constexpr uint32_t CreateMoveEarly()
|
||||||
{
|
{
|
||||||
return PlatformOffset(21, undefined, undefined);
|
return PlatformOffset(3, undefined, undefined);
|
||||||
}
|
}
|
||||||
static constexpr uint32_t CreateMove()
|
static constexpr uint32_t CreateMove()
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,7 @@ enum ec_types
|
|||||||
/* Note: engine prediction is run on this kind of CreateMove */
|
/* Note: engine prediction is run on this kind of CreateMove */
|
||||||
CreateMove = 0,
|
CreateMove = 0,
|
||||||
/* Note: this is the CreatMove one layer higher, and should only be used for things that mess with command number*/
|
/* Note: this is the CreatMove one layer higher, and should only be used for things that mess with command number*/
|
||||||
CreateMoveLate,
|
CreateMoveEarly,
|
||||||
/* This kind of CreateMove will run earlier than all CreateMove events
|
/* This kind of CreateMove will run earlier than all CreateMove events
|
||||||
* and guranteed to run before EnginePrediction
|
* and guranteed to run before EnginePrediction
|
||||||
*/
|
*/
|
||||||
|
@ -41,11 +41,11 @@ DECLARE_HOOKED_METHOD(LevelShutdown, void, void *);
|
|||||||
// ClientMode + 4
|
// ClientMode + 4
|
||||||
DECLARE_HOOKED_METHOD(FireGameEvent, void, void *, IGameEvent *);
|
DECLARE_HOOKED_METHOD(FireGameEvent, void, void *, IGameEvent *);
|
||||||
// IBaseClient
|
// IBaseClient
|
||||||
DECLARE_HOOKED_METHOD(CreateMoveLate, void, void *this_, int sequence_nr, float input_sample_time, bool arg3)
|
|
||||||
DECLARE_HOOKED_METHOD(DispatchUserMessage, bool, void *, int, bf_read &);
|
DECLARE_HOOKED_METHOD(DispatchUserMessage, bool, void *, int, bf_read &);
|
||||||
DECLARE_HOOKED_METHOD(IN_KeyEvent, int, void *, int, ButtonCode_t, const char *);
|
DECLARE_HOOKED_METHOD(IN_KeyEvent, int, void *, int, ButtonCode_t, const char *);
|
||||||
DECLARE_HOOKED_METHOD(FrameStageNotify, void, void *, ClientFrameStage_t);
|
DECLARE_HOOKED_METHOD(FrameStageNotify, void, void *, ClientFrameStage_t);
|
||||||
// IInput
|
// IInput
|
||||||
|
DECLARE_HOOKED_METHOD(CreateMoveEarly, void, IInput *, int, float, bool)
|
||||||
DECLARE_HOOKED_METHOD(GetUserCmd, CUserCmd *, IInput *, int);
|
DECLARE_HOOKED_METHOD(GetUserCmd, CUserCmd *, IInput *, int);
|
||||||
// INetChannel
|
// INetChannel
|
||||||
DECLARE_HOOKED_METHOD(SendNetMsg, bool, INetChannel *, INetMessage &, bool, bool);
|
DECLARE_HOOKED_METHOD(SendNetMsg, bool, INetChannel *, INetMessage &, bool, bool);
|
||||||
|
@ -1013,7 +1013,7 @@ static CatCommand debug_print_crit_info("debug_print_crit_info", "Print a bunch
|
|||||||
});
|
});
|
||||||
|
|
||||||
static InitRoutine init([]() {
|
static InitRoutine init([]() {
|
||||||
EC::Register(EC::CreateMoveLate, CreateMove, "crit_cm");
|
EC::Register(EC::CreateMoveEarly, CreateMove, "crit_cm");
|
||||||
#if ENABLE_VISUALS
|
#if ENABLE_VISUALS
|
||||||
EC::Register(EC::Draw, Draw, "crit_draw");
|
EC::Register(EC::Draw, Draw, "crit_draw");
|
||||||
#endif
|
#endif
|
||||||
|
@ -185,7 +185,6 @@ void hack::Hook()
|
|||||||
|
|
||||||
hooks::client.Set(g_IBaseClient);
|
hooks::client.Set(g_IBaseClient);
|
||||||
hooks::client.HookMethod(HOOK_ARGS(DispatchUserMessage));
|
hooks::client.HookMethod(HOOK_ARGS(DispatchUserMessage));
|
||||||
hooks::client.HookMethod(HOOK_ARGS(CreateMoveLate));
|
|
||||||
#if ENABLE_VISUALS
|
#if ENABLE_VISUALS
|
||||||
hooks::client.HookMethod(HOOK_ARGS(FrameStageNotify));
|
hooks::client.HookMethod(HOOK_ARGS(FrameStageNotify));
|
||||||
hooks::client.HookMethod(HOOK_ARGS(IN_KeyEvent));
|
hooks::client.HookMethod(HOOK_ARGS(IN_KeyEvent));
|
||||||
@ -215,6 +214,7 @@ void hack::Hook()
|
|||||||
|
|
||||||
hooks::input.Set(g_IInput);
|
hooks::input.Set(g_IInput);
|
||||||
hooks::input.HookMethod(HOOK_ARGS(GetUserCmd));
|
hooks::input.HookMethod(HOOK_ARGS(GetUserCmd));
|
||||||
|
hooks::input.HookMethod(HOOK_ARGS(CreateMoveEarly));
|
||||||
hooks::input.Apply();
|
hooks::input.Apply();
|
||||||
|
|
||||||
#if ENABLE_VISUALS || ENABLE_TEXTMODE
|
#if ENABLE_VISUALS || ENABLE_TEXTMODE
|
||||||
|
@ -189,7 +189,7 @@ struct bonelist_s
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// ent->m_bBonesSetup = false;
|
// ent->m_bBonesSetup = false;
|
||||||
const auto &bones = ent->hitboxes.GetBones();
|
const auto &bones = ent->hitboxes.GetBones();
|
||||||
DrawBoneList(bones, leg_r, 3, color);
|
DrawBoneList(bones, leg_r, 3, color);
|
||||||
DrawBoneList(bones, leg_l, 3, color);
|
DrawBoneList(bones, leg_l, 3, color);
|
||||||
DrawBoneList(bones, bottom, 3, color);
|
DrawBoneList(bones, bottom, 3, color);
|
||||||
@ -295,8 +295,7 @@ static void cm()
|
|||||||
|
|
||||||
static draw::Texture atlas{ paths::getDataPath("/textures/atlas.png") };
|
static draw::Texture atlas{ paths::getDataPath("/textures/atlas.png") };
|
||||||
static draw::Texture idspec{ paths::getDataPath("/textures/idspec.png") };
|
static draw::Texture idspec{ paths::getDataPath("/textures/idspec.png") };
|
||||||
|
|
||||||
|
|
||||||
Timer retry{};
|
Timer retry{};
|
||||||
void Init()
|
void Init()
|
||||||
{
|
{
|
||||||
@ -625,23 +624,23 @@ void _FASTCALL ProcessEntityPT(CachedEntity *ent)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (draw_bones)
|
if (draw_bones)
|
||||||
{
|
{
|
||||||
if (vischeck && !ent->IsVisible())
|
if (vischeck && !ent->IsVisible())
|
||||||
transparent = true;
|
transparent = true;
|
||||||
rgba_t bone_color = colors::EntityF(ent);
|
rgba_t bone_color = colors::EntityF(ent);
|
||||||
if (transparent)
|
if (transparent)
|
||||||
bone_color = colors::Transparent(bone_color);
|
bone_color = colors::Transparent(bone_color);
|
||||||
|
|
||||||
bonelist_s bl;
|
bonelist_s bl;
|
||||||
if (!CE_INVALID(ent) && ent->m_bAlivePlayer() && !RAW_ENT(ent)->IsDormant() && LOCAL_E->m_bAlivePlayer())
|
if (!CE_INVALID(ent) && ent->m_bAlivePlayer() && !RAW_ENT(ent)->IsDormant() && LOCAL_E->m_bAlivePlayer())
|
||||||
{
|
{
|
||||||
if (bones_color)
|
if (bones_color)
|
||||||
bl.Draw(ent, bone_color);
|
bl.Draw(ent, bone_color);
|
||||||
else
|
else
|
||||||
bl.Draw(ent, colors::white);
|
bl.Draw(ent, colors::white);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Top horizontal health bar
|
// Top horizontal health bar
|
||||||
if (*healthbar == 1)
|
if (*healthbar == 1)
|
||||||
@ -1372,7 +1371,7 @@ void _FASTCALL ProcessEntity(CachedEntity *ent)
|
|||||||
if (IDX_GOOD(widx))
|
if (IDX_GOOD(widx))
|
||||||
{
|
{
|
||||||
CachedEntity *weapon = ENTITY(widx);
|
CachedEntity *weapon = ENTITY(widx);
|
||||||
if (CE_VALID(weapon))
|
if (CE_VALID(weapon) && re::C_BaseCombatWeapon::IsBaseCombatWeapon(RAW_ENT(weapon)))
|
||||||
{
|
{
|
||||||
if (show_weapon)
|
if (show_weapon)
|
||||||
{
|
{
|
||||||
|
@ -420,14 +420,15 @@ void WriteCmd(IInput *input, CUserCmd *cmd, int sequence_nr)
|
|||||||
GetCmds(input)[sequence_nr % VERIFIED_CMD_SIZE] = *cmd;
|
GetCmds(input)[sequence_nr % VERIFIED_CMD_SIZE] = *cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_HOOKED_METHOD(CreateMoveLate, void, void *this_, int sequence_nr, float input_sample_time, bool arg3)
|
// This gets called before the other CreateMove, but since we run original first in here all the stuff gets called after normal CreateMove is done
|
||||||
|
DEFINE_HOOKED_METHOD(CreateMoveEarly, void, IInput *this_, int sequence_nr, float input_sample_time, bool arg3)
|
||||||
{
|
{
|
||||||
// Call original function, includes Early CreateMove
|
// Call original function, includes Normal CreateMove
|
||||||
original::CreateMoveLate(this_, sequence_nr, input_sample_time, arg3);
|
original::CreateMoveEarly(this_, sequence_nr, input_sample_time, arg3);
|
||||||
|
|
||||||
CUserCmd *cmd = nullptr;
|
CUserCmd *cmd = nullptr;
|
||||||
if (g_IInput && GetCmds(g_IInput) && sequence_nr > 0)
|
if (this_ && GetCmds(this_) && sequence_nr > 0)
|
||||||
cmd = g_IInput->GetUserCmd(sequence_nr);
|
cmd = this_->GetUserCmd(sequence_nr);
|
||||||
|
|
||||||
if (!cmd)
|
if (!cmd)
|
||||||
return;
|
return;
|
||||||
@ -436,22 +437,22 @@ DEFINE_HOOKED_METHOD(CreateMoveLate, void, void *this_, int sequence_nr, float i
|
|||||||
|
|
||||||
if (!isHackActive())
|
if (!isHackActive())
|
||||||
{
|
{
|
||||||
WriteCmd(g_IInput, current_late_user_cmd, sequence_nr);
|
WriteCmd(this_, current_late_user_cmd, sequence_nr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_IEngine->IsInGame())
|
if (!g_IEngine->IsInGame())
|
||||||
{
|
{
|
||||||
WriteCmd(g_IInput, current_late_user_cmd, sequence_nr);
|
WriteCmd(this_, current_late_user_cmd, sequence_nr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PROF_SECTION(CreateMoveLate);
|
PROF_SECTION(CreateMoveEarly);
|
||||||
|
|
||||||
// Run EC
|
// Run EC
|
||||||
EC::run(EC::CreateMoveLate);
|
EC::run(EC::CreateMoveEarly);
|
||||||
|
|
||||||
// Write the usercmd
|
// Write the usercmd
|
||||||
WriteCmd(g_IInput, current_late_user_cmd, sequence_nr);
|
WriteCmd(this_, current_late_user_cmd, sequence_nr);
|
||||||
}
|
}
|
||||||
} // namespace hooked_methods
|
} // namespace hooked_methods
|
||||||
|
Reference in New Issue
Block a user