Skip to content

Commit 1d0b599

Browse files
authored
Merge pull request #211 from h1-mod/develop
Release v1.0.5
2 parents a27aa7b + a9d207d commit 1d0b599

19 files changed

+785
-189
lines changed

deps/GSL

deps/curl

Submodule curl updated 122 files

deps/rapidjson

deps/sol2

deps/zlib

src/client/component/console.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,13 @@ namespace console
292292
update();
293293
break;
294294
}
295+
case VK_ESCAPE:
296+
{
297+
con.cursor = 0;
298+
clear_output();
299+
strncpy_s(con.buffer, "", sizeof(con.buffer));
300+
break;
301+
}
295302
default:
296303
{
297304
const auto c = record.Event.KeyEvent.uChar.AsciiChar;

src/client/component/demonware.hpp

-6
This file was deleted.

src/client/component/game_console.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -269,13 +269,13 @@ namespace game_console
269269
if (matches.size() > 24)
270270
{
271271
draw_hint_box(1, dvars::con_inputHintBoxColor->current.vector);
272-
draw_hint_text(0, utils::string::va("%i matches (too many to show here). Press SHIFT + TAB to show them", matches.size()),
272+
draw_hint_text(0, utils::string::va("%i matches (too many to show here). Press SHIFT + TAB to show more", matches.size()),
273273
dvars::con_inputDvarMatchColor->current.vector);
274274

275275
if (game::playerKeys[0].keys[game::keyNum_t::K_SHIFT].down && game::playerKeys[0].keys[game::keyNum_t::K_TAB].down)
276276
{
277277
console::info("]%s\n", con.buffer);
278-
for (int i = 0; i < matches.size(); i++)
278+
for (size_t i = 0; i < matches.size(); i++)
279279
{
280280
console::info("\t%s\n", matches[i].name.data());
281281
}

src/client/component/gameplay.cpp

+63-12
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,11 @@ namespace gameplay
166166
a.jnz(allsolid);
167167

168168
a.bind(stand);
169-
a.and_(dword_ptr(r15, 0x54), 0xFFFFFFFD);
170-
a.jmp(0x2C9F9D_b);
169+
a.and_(dword_ptr(SELECT_VALUE(r14, r15), 0x54), 0xFFFFFFFD);
170+
a.jmp(SELECT_VALUE(0x499628_b, 0x2C9F9D_b));
171171

172172
a.bind(allsolid);
173-
a.jmp(0x2C9F9F_b);
173+
a.jmp(SELECT_VALUE(0x6878D4_b, 0x2C9F9F_b));
174174
};
175175

176176
void client_end_frame_stub2(game::mp::gentity_s* entity)
@@ -266,21 +266,74 @@ namespace gameplay
266266
vel_out[2] = new_z * length_scale;
267267
}
268268
}
269+
270+
void* pm_can_start_sprint_stub()
271+
{
272+
return utils::hook::assemble([=](utils::hook::assembler& a)
273+
{
274+
const auto skip_jz = a.newLabel();
275+
const auto loc_2C98EF = a.newLabel();
276+
277+
// save rax's original value
278+
a.push(rax);
279+
280+
// move dvar pointer to rax
281+
a.mov(rax, qword_ptr(reinterpret_cast<uint64_t>(&dvars::pm_sprintInAir)));
282+
283+
// move *(rax + 16) into al
284+
a.mov(al, byte_ptr(rax, 0x10));
285+
286+
// compare al with 1
287+
a.cmp(al, 1);
288+
289+
// restore rax to its original value
290+
a.pop(rax);
291+
292+
// jz == jump zero, jumps if the two operands in cmp are equal
293+
a.jz(skip_jz); // skip the last cmp & jz
294+
295+
// execute original code at 0x2C98C0 & 0x2C98C6
296+
// necessary because our jump overwrites 12 bytes after it
297+
a.mov(eax, 0x7FF); // rax got overwritted by our long jump (it does mov rax, <jmpaddr>; jmp rax)
298+
a.cmp(word_ptr(rbx, 0x22), ax);
299+
a.jz(loc_2C98EF);
300+
301+
a.bind(skip_jz);
302+
303+
// execute original code from 0x2C98C6 to 0x2C98CC
304+
a.mov(edx, dword_ptr(rdi, 0x8));
305+
a.mov(rcx, rbx);
306+
307+
// the section of code that was overwritten by our jump is finished so we can jump back to the game code
308+
a.jmp(0x2C98CC_b);
309+
310+
// original code
311+
a.bind(loc_2C98EF);
312+
a.jmp(0x2C98EF_b);
313+
});
314+
}
269315
}
270316

271317
class component final : public component_interface
272318
{
273319
public:
274320
void post_unpack() override
275321
{
322+
dvars::player_sustainAmmo = dvars::register_bool("player_sustainAmmo", false,
323+
game::DVAR_FLAG_REPLICATED, "Firing weapon will not decrease clip ammo");
324+
pm_weapon_use_ammo_hook.create(SELECT_VALUE(0x4AF600_b, 0x2DF830_b), &pm_weapon_use_ammo_stub);
325+
326+
// Influence PM_JitterPoint code flow so the trace->startsolid checks are 'ignored'
327+
pm_player_trace_hook.create(SELECT_VALUE(0x4A0A90_b, 0x2D14C0_b), &pm_player_trace_stub);
328+
329+
// If g_enableElevators is 1 the 'ducked' flag will always be removed from the player state
330+
utils::hook::jump(SELECT_VALUE(0x499617_b, 0x2C9F90_b), utils::hook::assemble(pm_trace_stub), true);
331+
dvars::g_enableElevators = dvars::register_bool("g_enableElevators", false, game::DVAR_FLAG_REPLICATED, "Enables Elevators");
332+
276333
if (game::environment::is_sp())
277334
{
278335
return;
279336
}
280-
281-
dvars::player_sustainAmmo = dvars::register_bool("player_sustainAmmo", false,
282-
game::DVAR_FLAG_REPLICATED, "Firing weapon will not decrease clip ammo");
283-
pm_weapon_use_ammo_hook.create(0x2DF830_b, &pm_weapon_use_ammo_stub);
284337

285338
utils::hook::nop(0x4006AD_b, 15);
286339
utils::hook::jump(0x4006AD_b, g_speed_stub(), true);
@@ -300,11 +353,9 @@ namespace gameplay
300353
utils::hook::jump(0x3FF812_b, client_end_frame_stub(), true);
301354
utils::hook::nop(0x3FF808_b, 1);
302355

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

309360
auto* timescale = dvars::register_float("timescale", 1.0f, 0.1f, 50.0f, game::DVAR_FLAG_REPLICATED, "Changes Timescale of the game");
310361
utils::hook::inject(0x15B204_b, &timescale->current.value); // Com_GetTimeScale

src/client/component/patches.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,17 @@ namespace patches
293293
}, scheduler::pipeline::main);
294294
}
295295

296+
// Set compassSize dvar minimum to 0.1
297+
dvars::override::register_float("compassSize", 1.0f, 0.1f, 50.0f, game::DVAR_FLAG_SAVED);
298+
296299
// Make cg_fov and cg_fovscale saved dvars
297300
dvars::override::register_float("cg_fov", 65.f, 40.f, 200.f, game::DvarFlags::DVAR_FLAG_SAVED);
298301
dvars::override::register_float("cg_fovScale", 1.f, 0.1f, 2.f, game::DvarFlags::DVAR_FLAG_SAVED);
299302
dvars::override::register_float("cg_fovMin", 1.f, 1.0f, 90.f, game::DvarFlags::DVAR_FLAG_SAVED);
300303

304+
// Makes mis_cheat saved dvar
305+
dvars::override::register_bool("mis_cheat", 0, game::DVAR_FLAG_SAVED);
306+
301307
// Allow kbam input when gamepad is enabled
302308
utils::hook::nop(SELECT_VALUE(0x1AC0CE_b, 0x135EFB_b), 2);
303309
utils::hook::nop(SELECT_VALUE(0x1A9DDC_b, 0x13388F_b), 6);

src/client/component/steam_proxy.cpp

+23-18
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ namespace steam_proxy
3535
{
3636
return;
3737
}
38+
39+
if (!FindWindowA(0, "Steam"))
40+
{
41+
return;
42+
}
3843

3944
this->load_client();
4045
this->clean_up_on_error();
@@ -152,29 +157,29 @@ namespace steam_proxy
152157
void clean_up_on_error()
153158
{
154159
scheduler::schedule([this]()
160+
{
161+
if (this->steam_client_module_
162+
&& this->steam_pipe_
163+
&& this->global_user_
164+
&& this->steam_client_module_.invoke<bool>("Steam_BConnected", this->global_user_,
165+
this->steam_pipe_)
166+
&& this->steam_client_module_.invoke<bool>("Steam_BLoggedOn", this->global_user_, this->steam_pipe_)
167+
)
155168
{
156-
if (this->steam_client_module_
157-
&& this->steam_pipe_
158-
&& this->global_user_
159-
&& this->steam_client_module_.invoke<bool>("Steam_BConnected", this->global_user_,
160-
this->steam_pipe_)
161-
&& this->steam_client_module_.invoke<bool>("Steam_BLoggedOn", this->global_user_, this->steam_pipe_)
162-
)
163-
{
164-
return scheduler::cond_continue;
165-
}
169+
return scheduler::cond_continue;
170+
}
166171

167-
this->client_engine_ = nullptr;
168-
this->client_user_ = nullptr;
169-
this->client_utils_ = nullptr;
172+
this->client_engine_ = nullptr;
173+
this->client_user_ = nullptr;
174+
this->client_utils_ = nullptr;
170175

171-
this->steam_pipe_ = nullptr;
172-
this->global_user_ = nullptr;
176+
this->steam_pipe_ = nullptr;
177+
this->global_user_ = nullptr;
173178

174-
this->steam_client_module_ = utils::nt::library{nullptr};
179+
this->steam_client_module_ = utils::nt::library{nullptr};
175180

176-
return scheduler::cond_end;
177-
});
181+
return scheduler::cond_end;
182+
});
178183
}
179184
};
180185

src/client/game/dvars.cpp

+17-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ namespace dvars
3232

3333
game::dvar_t* pm_bouncing = nullptr;
3434
game::dvar_t* pm_bouncingAllAngles = nullptr;
35+
game::dvar_t* pm_sprintInAir = nullptr;
3536

3637
game::dvar_t* jump_ladderPushVel = nullptr;
3738

@@ -3757,7 +3758,7 @@ namespace dvars
37573758
},
37583759
{
37593760
"g_ai",
3760-
"Enable AI.",
3761+
"Enable AI",
37613762
generate_hash("g_ai")
37623763
},
37633764
{
@@ -4160,6 +4161,16 @@ namespace dvars
41604161
"Time after the last talk packet was received that the player is considered by the\nserver to still be talking in milliseconds",
41614162
generate_hash("g_voiceChatTalkingDuration")
41624163
},
4164+
{
4165+
"g_gravity",
4166+
"Game gravity in inches per second squared",
4167+
generate_hash("g_gravity")
4168+
},
4169+
{
4170+
"g_speed",
4171+
"changes the speed of the player",
4172+
generate_hash("g_speed")
4173+
},
41634174
{
41644175
"gamedate",
41654176
"The date compiled",
@@ -4605,6 +4616,11 @@ namespace dvars
46054616
"Slow player movement after jumping",
46064617
generate_hash("jump_slowdownEnable")
46074618
},
4619+
{
4620+
"jump_height",
4621+
"The maximum height of a player\'s jump",
4622+
generate_hash("jump_height")
4623+
},
46084624
{
46094625
"laserDebug",
46104626
"Enables the display of various debug info.",

src/client/game/dvars.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ namespace dvars
3535

3636
extern game::dvar_t* pm_bouncing;
3737
extern game::dvar_t* pm_bouncingAllAngles;
38+
extern game::dvar_t* pm_sprintInAir;
3839

3940
extern game::dvar_t* jump_ladderPushVel;
4041

0 commit comments

Comments
 (0)