Skip to content

Commit

Permalink
Merge pull request #211 from h1-mod/develop
Browse files Browse the repository at this point in the history
Release v1.0.5
  • Loading branch information
mjkzy authored Aug 8, 2022
2 parents a27aa7b + a9d207d commit 1d0b599
Show file tree
Hide file tree
Showing 19 changed files with 785 additions and 189 deletions.
2 changes: 1 addition & 1 deletion deps/GSL
2 changes: 1 addition & 1 deletion deps/asmjit
2 changes: 1 addition & 1 deletion deps/curl
Submodule curl updated 122 files
2 changes: 1 addition & 1 deletion deps/rapidjson
2 changes: 1 addition & 1 deletion deps/sol2
2 changes: 1 addition & 1 deletion deps/zlib
Submodule zlib updated 2 files
+9 −7 infback.c
+3 −2 inflate.c
7 changes: 7 additions & 0 deletions src/client/component/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,13 @@ namespace console
update();
break;
}
case VK_ESCAPE:
{
con.cursor = 0;
clear_output();
strncpy_s(con.buffer, "", sizeof(con.buffer));
break;
}
default:
{
const auto c = record.Event.KeyEvent.uChar.AsciiChar;
Expand Down
6 changes: 0 additions & 6 deletions src/client/component/demonware.hpp

This file was deleted.

4 changes: 2 additions & 2 deletions src/client/component/game_console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,13 @@ namespace game_console
if (matches.size() > 24)
{
draw_hint_box(1, dvars::con_inputHintBoxColor->current.vector);
draw_hint_text(0, utils::string::va("%i matches (too many to show here). Press SHIFT + TAB to show them", matches.size()),
draw_hint_text(0, utils::string::va("%i matches (too many to show here). Press SHIFT + TAB to show more", matches.size()),
dvars::con_inputDvarMatchColor->current.vector);

if (game::playerKeys[0].keys[game::keyNum_t::K_SHIFT].down && game::playerKeys[0].keys[game::keyNum_t::K_TAB].down)
{
console::info("]%s\n", con.buffer);
for (int i = 0; i < matches.size(); i++)
for (size_t i = 0; i < matches.size(); i++)
{
console::info("\t%s\n", matches[i].name.data());
}
Expand Down
75 changes: 63 additions & 12 deletions src/client/component/gameplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ namespace gameplay
a.jnz(allsolid);

a.bind(stand);
a.and_(dword_ptr(r15, 0x54), 0xFFFFFFFD);
a.jmp(0x2C9F9D_b);
a.and_(dword_ptr(SELECT_VALUE(r14, r15), 0x54), 0xFFFFFFFD);
a.jmp(SELECT_VALUE(0x499628_b, 0x2C9F9D_b));

a.bind(allsolid);
a.jmp(0x2C9F9F_b);
a.jmp(SELECT_VALUE(0x6878D4_b, 0x2C9F9F_b));
};

void client_end_frame_stub2(game::mp::gentity_s* entity)
Expand Down Expand Up @@ -266,21 +266,74 @@ namespace gameplay
vel_out[2] = new_z * length_scale;
}
}

void* pm_can_start_sprint_stub()
{
return utils::hook::assemble([=](utils::hook::assembler& a)
{
const auto skip_jz = a.newLabel();
const auto loc_2C98EF = a.newLabel();

// save rax's original value
a.push(rax);

// move dvar pointer to rax
a.mov(rax, qword_ptr(reinterpret_cast<uint64_t>(&dvars::pm_sprintInAir)));

// move *(rax + 16) into al
a.mov(al, byte_ptr(rax, 0x10));

// compare al with 1
a.cmp(al, 1);

// restore rax to its original value
a.pop(rax);

// jz == jump zero, jumps if the two operands in cmp are equal
a.jz(skip_jz); // skip the last cmp & jz

// execute original code at 0x2C98C0 & 0x2C98C6
// necessary because our jump overwrites 12 bytes after it
a.mov(eax, 0x7FF); // rax got overwritted by our long jump (it does mov rax, <jmpaddr>; jmp rax)
a.cmp(word_ptr(rbx, 0x22), ax);
a.jz(loc_2C98EF);

a.bind(skip_jz);

// execute original code from 0x2C98C6 to 0x2C98CC
a.mov(edx, dword_ptr(rdi, 0x8));
a.mov(rcx, rbx);

// the section of code that was overwritten by our jump is finished so we can jump back to the game code
a.jmp(0x2C98CC_b);

// original code
a.bind(loc_2C98EF);
a.jmp(0x2C98EF_b);
});
}
}

class component final : public component_interface
{
public:
void post_unpack() override
{
dvars::player_sustainAmmo = dvars::register_bool("player_sustainAmmo", false,
game::DVAR_FLAG_REPLICATED, "Firing weapon will not decrease clip ammo");
pm_weapon_use_ammo_hook.create(SELECT_VALUE(0x4AF600_b, 0x2DF830_b), &pm_weapon_use_ammo_stub);

// Influence PM_JitterPoint code flow so the trace->startsolid checks are 'ignored'
pm_player_trace_hook.create(SELECT_VALUE(0x4A0A90_b, 0x2D14C0_b), &pm_player_trace_stub);

// If g_enableElevators is 1 the 'ducked' flag will always be removed from the player state
utils::hook::jump(SELECT_VALUE(0x499617_b, 0x2C9F90_b), utils::hook::assemble(pm_trace_stub), true);
dvars::g_enableElevators = dvars::register_bool("g_enableElevators", false, game::DVAR_FLAG_REPLICATED, "Enables Elevators");

if (game::environment::is_sp())
{
return;
}

dvars::player_sustainAmmo = dvars::register_bool("player_sustainAmmo", false,
game::DVAR_FLAG_REPLICATED, "Firing weapon will not decrease clip ammo");
pm_weapon_use_ammo_hook.create(0x2DF830_b, &pm_weapon_use_ammo_stub);

utils::hook::nop(0x4006AD_b, 15);
utils::hook::jump(0x4006AD_b, g_speed_stub(), true);
Expand All @@ -300,11 +353,9 @@ namespace gameplay
utils::hook::jump(0x3FF812_b, client_end_frame_stub(), true);
utils::hook::nop(0x3FF808_b, 1);

// Influence PM_JitterPoint code flow so the trace->startsolid checks are 'ignored'
pm_player_trace_hook.create(0x2D14C0_b, &pm_player_trace_stub);
// If g_enableElevators is 1 the 'ducked' flag will always be removed from the player state
utils::hook::jump(0x2C9F90_b, utils::hook::assemble(pm_trace_stub), true);
dvars::g_enableElevators = dvars::register_bool("g_enableElevators", false, game::DVAR_FLAG_REPLICATED, "Enables Elevators");
dvars::pm_sprintInAir = dvars::register_bool("pm_sprintInAir", false,
game::DVAR_FLAG_REPLICATED, "Enable Mid-Air Sprinting");
utils::hook::jump(0x2C98C0_b, pm_can_start_sprint_stub(), true);

auto* timescale = dvars::register_float("timescale", 1.0f, 0.1f, 50.0f, game::DVAR_FLAG_REPLICATED, "Changes Timescale of the game");
utils::hook::inject(0x15B204_b, &timescale->current.value); // Com_GetTimeScale
Expand Down
6 changes: 6 additions & 0 deletions src/client/component/patches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,17 @@ namespace patches
}, scheduler::pipeline::main);
}

// Set compassSize dvar minimum to 0.1
dvars::override::register_float("compassSize", 1.0f, 0.1f, 50.0f, game::DVAR_FLAG_SAVED);

// Make cg_fov and cg_fovscale saved dvars
dvars::override::register_float("cg_fov", 65.f, 40.f, 200.f, game::DvarFlags::DVAR_FLAG_SAVED);
dvars::override::register_float("cg_fovScale", 1.f, 0.1f, 2.f, game::DvarFlags::DVAR_FLAG_SAVED);
dvars::override::register_float("cg_fovMin", 1.f, 1.0f, 90.f, game::DvarFlags::DVAR_FLAG_SAVED);

// Makes mis_cheat saved dvar
dvars::override::register_bool("mis_cheat", 0, game::DVAR_FLAG_SAVED);

// Allow kbam input when gamepad is enabled
utils::hook::nop(SELECT_VALUE(0x1AC0CE_b, 0x135EFB_b), 2);
utils::hook::nop(SELECT_VALUE(0x1A9DDC_b, 0x13388F_b), 6);
Expand Down
41 changes: 23 additions & 18 deletions src/client/component/steam_proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ namespace steam_proxy
{
return;
}

if (!FindWindowA(0, "Steam"))
{
return;
}

this->load_client();
this->clean_up_on_error();
Expand Down Expand Up @@ -152,29 +157,29 @@ namespace steam_proxy
void clean_up_on_error()
{
scheduler::schedule([this]()
{
if (this->steam_client_module_
&& this->steam_pipe_
&& this->global_user_
&& this->steam_client_module_.invoke<bool>("Steam_BConnected", this->global_user_,
this->steam_pipe_)
&& this->steam_client_module_.invoke<bool>("Steam_BLoggedOn", this->global_user_, this->steam_pipe_)
)
{
if (this->steam_client_module_
&& this->steam_pipe_
&& this->global_user_
&& this->steam_client_module_.invoke<bool>("Steam_BConnected", this->global_user_,
this->steam_pipe_)
&& this->steam_client_module_.invoke<bool>("Steam_BLoggedOn", this->global_user_, this->steam_pipe_)
)
{
return scheduler::cond_continue;
}
return scheduler::cond_continue;
}

this->client_engine_ = nullptr;
this->client_user_ = nullptr;
this->client_utils_ = nullptr;
this->client_engine_ = nullptr;
this->client_user_ = nullptr;
this->client_utils_ = nullptr;

this->steam_pipe_ = nullptr;
this->global_user_ = nullptr;
this->steam_pipe_ = nullptr;
this->global_user_ = nullptr;

this->steam_client_module_ = utils::nt::library{nullptr};
this->steam_client_module_ = utils::nt::library{nullptr};

return scheduler::cond_end;
});
return scheduler::cond_end;
});
}
};

Expand Down
18 changes: 17 additions & 1 deletion src/client/game/dvars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ namespace dvars

game::dvar_t* pm_bouncing = nullptr;
game::dvar_t* pm_bouncingAllAngles = nullptr;
game::dvar_t* pm_sprintInAir = nullptr;

game::dvar_t* jump_ladderPushVel = nullptr;

Expand Down Expand Up @@ -3757,7 +3758,7 @@ namespace dvars
},
{
"g_ai",
"Enable AI.",
"Enable AI",
generate_hash("g_ai")
},
{
Expand Down Expand Up @@ -4160,6 +4161,16 @@ namespace dvars
"Time after the last talk packet was received that the player is considered by the\nserver to still be talking in milliseconds",
generate_hash("g_voiceChatTalkingDuration")
},
{
"g_gravity",
"Game gravity in inches per second squared",
generate_hash("g_gravity")
},
{
"g_speed",
"changes the speed of the player",
generate_hash("g_speed")
},
{
"gamedate",
"The date compiled",
Expand Down Expand Up @@ -4605,6 +4616,11 @@ namespace dvars
"Slow player movement after jumping",
generate_hash("jump_slowdownEnable")
},
{
"jump_height",
"The maximum height of a player\'s jump",
generate_hash("jump_height")
},
{
"laserDebug",
"Enables the display of various debug info.",
Expand Down
1 change: 1 addition & 0 deletions src/client/game/dvars.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace dvars

extern game::dvar_t* pm_bouncing;
extern game::dvar_t* pm_bouncingAllAngles;
extern game::dvar_t* pm_sprintInAir;

extern game::dvar_t* jump_ladderPushVel;

Expand Down
Loading

0 comments on commit 1d0b599

Please sign in to comment.