SP fixes
This commit is contained in:
parent
d9e6b0f30b
commit
47f0455b0f
@ -399,6 +399,18 @@ namespace fastfiles
|
||||
game::DB_LevelLoadAddZone(load, name, alloc_flags | game::DB_ZONE_CUSTOM, size_est);
|
||||
}
|
||||
}
|
||||
|
||||
void db_find_aipaths_stub(game::XAssetType type, const char* name, int allow_create_default)
|
||||
{
|
||||
if (game::DB_XAssetExists(type, name))
|
||||
{
|
||||
game::DB_FindXAssetHeader(type, name, allow_create_default);
|
||||
}
|
||||
else
|
||||
{
|
||||
console::warn("No aipaths found for this map\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool exists(const std::string& zone, bool ignore_usermap)
|
||||
@ -498,6 +510,14 @@ namespace fastfiles
|
||||
{
|
||||
utils::hook::nop(0x368153_b, 2); // DB_InflateInit
|
||||
}
|
||||
|
||||
if (game::environment::is_sp())
|
||||
{
|
||||
// Allow loading mp maps
|
||||
utils::hook::set(0x40AF90_b, 0xC300B0);
|
||||
// Don't sys_error if aipaths are missing
|
||||
utils::hook::call(0x2F8EE9_b, db_find_aipaths_stub);
|
||||
}
|
||||
|
||||
// Allow loading of mixed compressor types
|
||||
utils::hook::nop(SELECT_VALUE(0x1C4BE7_b, 0x3687A7_b), 2);
|
||||
@ -507,7 +527,10 @@ namespace fastfiles
|
||||
|
||||
// Add custom zone paths
|
||||
sys_createfile_hook.create(game::Sys_CreateFile, sys_create_file_stub);
|
||||
db_file_exists_hook.create(0x394DC0_b, db_file_exists_stub);
|
||||
if (!game::environment::is_sp())
|
||||
{
|
||||
db_file_exists_hook.create(0x394DC0_b, db_file_exists_stub);
|
||||
}
|
||||
|
||||
// load our custom pre_gfx zones
|
||||
utils::hook::call(SELECT_VALUE(0x3862ED_b, 0x15C3FD_b), load_pre_gfx_zones);
|
||||
|
@ -82,19 +82,19 @@ namespace gameplay
|
||||
|
||||
a.mov(rax, qword_ptr(reinterpret_cast<int64_t>(&dvars::pm_bouncing)));
|
||||
a.mov(al, byte_ptr(rax, 0x10));
|
||||
a.cmp(byte_ptr(rbp, -0x7D), al);
|
||||
a.cmp(byte_ptr(rbp, SELECT_VALUE(-0x5D, -0x7D)), al);
|
||||
|
||||
a.pop(rax);
|
||||
a.jz(no_bounce);
|
||||
a.jmp(0x2D39C0_b);
|
||||
a.jmp(SELECT_VALUE(0x4A2E81_b, 0x2D39C0_b));
|
||||
|
||||
a.bind(no_bounce);
|
||||
a.cmp(dword_ptr(rsp, 0x44), 0);
|
||||
a.jnz(loc_2D395D);
|
||||
a.jmp(0x2D39B1_b);
|
||||
a.jmp(SELECT_VALUE(0x4A2E6F_b, 0x2D39B1_b));
|
||||
|
||||
a.bind(loc_2D395D);
|
||||
a.jmp(0x2D395D_b);
|
||||
a.jmp(SELECT_VALUE(0x4A2F18_b, 0x2D395D_b));
|
||||
});
|
||||
}
|
||||
|
||||
@ -330,6 +330,10 @@ namespace gameplay
|
||||
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");
|
||||
|
||||
dvars::pm_bouncing = dvars::register_bool("pm_bouncing", false,
|
||||
game::DVAR_FLAG_REPLICATED, "Enable bouncing");
|
||||
utils::hook::jump(SELECT_VALUE(0x4A2E5E_b, 0x2D39A4_b), pm_bouncing_stub_mp(), true);
|
||||
|
||||
if (game::environment::is_sp())
|
||||
{
|
||||
return;
|
||||
@ -340,10 +344,6 @@ namespace gameplay
|
||||
dvars::g_speed = dvars::register_int("g_speed", 190, 0, 1000,
|
||||
game::DVAR_FLAG_REPLICATED, "changes the speed of the player");
|
||||
|
||||
dvars::pm_bouncing = dvars::register_bool("pm_bouncing", false,
|
||||
game::DVAR_FLAG_REPLICATED, "Enable bouncing");
|
||||
utils::hook::jump(0x2D39A4_b, pm_bouncing_stub_mp(), true);
|
||||
|
||||
dvars::pm_bouncingAllAngles = dvars::register_bool("pm_bouncingAllAngles", false,
|
||||
game::DvarFlags::DVAR_FLAG_REPLICATED, "Enable bouncing from all angles");
|
||||
utils::hook::call(0x2D3A74_b, pm_project_velocity_stub);
|
||||
|
@ -144,7 +144,7 @@ namespace mapents
|
||||
std::string entity_string;
|
||||
const char* cm_entity_string_stub()
|
||||
{
|
||||
const auto original = utils::hook::invoke<const char*>(0x4CD140_b);
|
||||
const auto original = utils::hook::invoke<const char*>(SELECT_VALUE(0x3685C0_b, 0x4CD140_b));
|
||||
const auto parsed = parse_mapents(original);
|
||||
if (parsed.has_value())
|
||||
{
|
||||
@ -160,7 +160,7 @@ namespace mapents
|
||||
void cm_unload_stub(void* clip_map)
|
||||
{
|
||||
entity_string.clear();
|
||||
utils::hook::invoke<void>(0x4CD0E0_b, clip_map);
|
||||
utils::hook::invoke<void>(SELECT_VALUE(0x368560_b, 0x4CD0E0_b), clip_map);
|
||||
}
|
||||
}
|
||||
|
||||
@ -169,8 +169,8 @@ namespace mapents
|
||||
public:
|
||||
void post_unpack() override
|
||||
{
|
||||
utils::hook::call(0x41F594_b, cm_entity_string_stub);
|
||||
utils::hook::call(0x399814_b, cm_unload_stub);
|
||||
utils::hook::call(SELECT_VALUE(0x2A1154_b, 0x41F594_b), cm_entity_string_stub);
|
||||
utils::hook::call(SELECT_VALUE(0x1F4E74_b, 0x399814_b), cm_unload_stub);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -218,6 +218,17 @@ namespace scripting
|
||||
canonical_string_table[result] = str;
|
||||
return result;
|
||||
}
|
||||
|
||||
void* get_spawn_point_stub()
|
||||
{
|
||||
const auto spawn_point = utils::hook::invoke<void*>(0x28BD50_b);
|
||||
if (spawn_point == nullptr)
|
||||
{
|
||||
console::warn("No spawnpoint found for this map, using (0, 0, 0)\n");
|
||||
return &game::sp::g_entities[0];
|
||||
}
|
||||
return spawn_point;
|
||||
}
|
||||
}
|
||||
|
||||
std::string get_token(unsigned int id)
|
||||
@ -267,6 +278,11 @@ namespace scripting
|
||||
|
||||
g_shutdown_game_hook.create(SELECT_VALUE(0x2A5130_b, 0x422F30_b), g_shutdown_game_stub);
|
||||
|
||||
if (game::environment::is_sp())
|
||||
{
|
||||
utils::hook::call(0x28AE82_b, get_spawn_point_stub);
|
||||
}
|
||||
|
||||
scheduler::loop([]
|
||||
{
|
||||
lua::engine::run_frame();
|
||||
|
Loading…
Reference in New Issue
Block a user