void Initialize() { Units::Initialize(); Memory::WriteRelativeCall(&ObjectsUpdate, GET_FUNC_VPTR(OBJECTS_UPDATE_CALL), true); Memory::WriteRelativeCall(&ObjectDepleteBodyKillChildUnit, GET_FUNC_VPTR(OBJECT_DEPLETE_BODY_UNIT_KILL_CALL), true); }
void Initialize() { // TODO: If using DX_WRAPPER, refer to the DxWrapper.cpp file // instead of hooking the game render loop #if !defined(DX_WRAPPER) Memory::WriteRelativeCall(&Rasterizer::Update, GET_FUNC_VPTR(RENDER_WINDOW_END_HOOK)); #endif Memory::WriteRelativeCall(&RenderWindowHook, GET_FUNC_VPTR(RENDER_WINDOW_REFLECTION_CALL), true); }
void Initialize() { c_settings_rasterizer::Register(Settings::Manager()); Render::Initialize(); // hook the calls to rasterizer_dispose Memory::WriteRelativeCall(&RasterizerDisposeHook, GET_FUNC_VPTR(RASTERIZER_DISPOSE_CALL_FROM_RASTERIZER)); Memory::WriteRelativeCall(&RasterizerDisposeHook, GET_FUNC_VPTR(RASTERIZER_DISPOSE_CALL_FROM_SHELL)); size_t address = CAST_PTR(size_t, Rasterizer::DebugOptions()); for(const auto& rdt : k_rasterizer_debug_table) { // this is the only time we should be modifying the hs definitions // outside of the ScriptLibrary code, so do some cast magic Scripting::hs_global_definition* global_def = CAST_QUAL(Scripting::hs_global_definition*, &(Scripting::HSExternalGlobals()[rdt.index]) ); // get the hs global definition we're about to fix up global_def->address = CAST_PTR(void*, address + rdt.field);// fix the global definition's address to point to the correct memory } #if PLATFORM_VERSION <= 0x1090 // update the resolution definition array length // definition count has been increased to 64 so that ridiculous amounts of resolutions in the future are accommodated GET_PTR(RESOLUTION_LIST_COUNT) = NUMBEROF(g_resolution_list); // redirect all resolution definition pointers to the new array for(auto ptr : K_RESOLUTION_LIST_X_REFERENCES) *ptr = &g_resolution_list[0].width; for(auto ptr : K_RESOLUTION_LIST_Y_REFERENCES) *ptr = &g_resolution_list[0].height; for(auto ptr : K_RESOLUTION_LIST_STRING_REFERENCES) *ptr = &g_resolution_list[0].resolution_string; *GET_PTR(RESOLUTION_LIST_STRING_NULL_REFERENCE) = &(g_resolution_list[0].resolution_string[15]); for(auto ptr : K_RESOLUTION_LIST_REFRESH_COUNT_REFERENCES) *ptr = &g_resolution_list[0].refresh_rate_count; for(auto ptr : K_RESOLUTION_LIST_REFRESH_RATE_REFERENCES) *ptr = &g_resolution_list[0].refresh_rates; // replace the original resolution populator with the new one Memory::WriteRelativeCall(&SetupResolutions, GET_FUNC_VPTR(RESOLUTION_LIST_SETUP_RESOLUTIONS_CALL), true); #endif // make the screenshot function use a unique subfolder tag_string screenshots_folder; GetTimeStampStringForFile(screenshots_folder); strcat_s(g_screenshot_folder, sizeof(g_screenshot_folder), screenshots_folder); for(auto ptr : K_SCREENSHOT_FOLDER_REFERENCES) *ptr = &g_screenshot_folder[0]; }
void c_gbuffer_system::Initialize() { char file_string[MAX_PATH]; file_string[0] = '\0'; g_default_system.Ctor(); c_gbuffer_system::g_output_object_tbn = false; // leave as false, not enough vertex shader registers available to do object velocity with bones c_gbuffer_system::g_output_object_velocity = false; c_gbuffer_system::g_output_velocity = true; D3DXMatrixIdentity(&c_gbuffer_system::g_identity_matrix); Memory::WriteRelativeJmp(&Hook_RenderObjectList_GetObjectIndex, GET_FUNC_VPTR(RENDER_OBJECT_LIST_HOOK), true); Memory::WriteRelativeJmp(&Hook_RenderObjectList_ClearObjectIndex, GET_FUNC_VPTR(RENDER_OBJECT_LIST_END_HOOK), true); Memory::WriteRelativeJmp(&Hook_FirstPersonWeaponDraw_GetObjectIndex, GET_FUNC_VPTR(FIRST_PERSON_WEAPON_DRAW_HOOK), true); Memory::WriteRelativeJmp(&Hook_RenderObject_GetCurrentLOD, GET_FUNC_VPTR(RENDER_OBJECT_OBJECT_LOD_HOOK), true); Memory::WriteRelativeJmp(&Hook_CommandCameraSet, GET_FUNC_VPTR(COMMAND_CAMERA_SET_HOOK), true); Memory::WriteRelativeJmp(&Hook_CommandSwitchBSP, GET_FUNC_VPTR(COMMAND_SWITCH_BSP_HOOK), true); Memory::WriteRelativeJmp(&Hook_CommandGameSave, GET_FUNC_VPTR(COMMAND_GAME_SAVE_HOOK), true); Memory::WriteRelativeJmp(&Hook_RenderObjectsTransparent, GET_FUNC_VPTR(RENDER_WINDOW_CALL_RENDER_OBJECTS_TRANSPARENT_HOOK), true); byte NOP = 0x90; byte* call_address; call_address = CAST_PTR(byte*, GET_FUNC_VPTR(RASTERIZER_DRAW_STATIC_TRIANGLES_STATIC_VERTICES__DRAW_INDEXED_PRIMITIVE_HOOK)); Memory::WriteRelativeCall(&DrawIndexedPrimitive_Object, call_address, true); Memory::WriteMemory(call_address + 5, &NOP, sizeof(NOP)); call_address = CAST_PTR(byte*, GET_FUNC_VPTR(RASTERIZER_DRAW_DYNAMIC_TRIANGLES_STATIC_VERTICES2__DRAW_INDEXED_PRIMITIVE_HOOK)); Memory::WriteRelativeCall(&DrawIndexedPrimitive_Structure, call_address, true); Memory::WriteMemory(call_address + 5, &NOP, sizeof(NOP)); }
void Initialize() { Animations::Initialize(); SeatBoarding::Initialize(); // Enables biped seats Memory::WriteMemory(GET_FUNC_VPTR(BIPED_UPDATE_CHECK_PARENT_UNIT_TYPE), Enums::_x86_opcode_nop, 2); *CAST_PTR(byte*, GET_FUNC_PTR(BIPED_UPDATE_PARENT_UNIT_TYPE_MASK)) = Enums::_object_type_mask_unit; *CAST_PTR(byte*, GET_FUNC_PTR(BIPED_VEHICLE_SPEECH_PARENT_UNIT_TYPE_MASK)) = Enums::_object_type_mask_unit; *CAST_PTR(tag*, GET_FUNC_PTR(BIPED_VEHICLE_SPEECH_PARENT_UNIT_TYPE_TAG)) = 'unit'; // Stop an assertion when a unit with a parent tries to enter another seat Memory::WriteMemory(GET_FUNC_VPTR(INTER_VEHICLE_SEAT_ASSERT_JZ), Enums::_x86_opcode_jmp_short, 1); Memory::WriteRelativeCall(&UnitDamageAftermathHook, GET_FUNC_VPTR(UNIT_DAMAGE_AFTERMATH_CALL), true); Memory::WriteRelativeJmp(&UnitCanEnterSeat, GET_FUNC_VPTR(UNIT_CAN_ENTER_SEAT_HOOK), true); Memory::WriteRelativeJmp(&BipedSeatedMeleeHook, GET_FUNC_VPTR(BIPED_SEATED_MELEE_HOOK), true); Memory::WriteRelativeCall(&UnitThrowGrenadeReleaseHook, GET_FUNC_VPTR(UNIT_THROW_GRENADE_RELEASE_HOOK), true); Memory::WriteRelativeJmp(&WeaponPreventsGrenadeThrowingHook, GET_FUNC_VPTR(WEAPON_PREVENTS_GRENADE_THROWING_HOOK), true); }