Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions CMakeCache.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# This is the CMakeCache file.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should not have been sent

# For build in directory: c:/Users/Paul/source/repos/dashfaction
# It was generated by CMake: C:/Program Files/CMake/bin/cmake.exe
# You can edit this file to change values found and used by cmake.
# If you do not want to change any of the values, simply exit the editor.
# If you do want to change a value, simply edit, save, and exit the editor.
# The syntax for the file is as follows:
# KEY:TYPE=VALUE
# KEY is the name of a variable in the cache.
# TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT TYPE!.
# VALUE is the current value for the KEY.

########################
# EXTERNAL cache entries
########################

//Semicolon separated list of supported configuration types, only
// supports Debug, Release, MinSizeRel, and RelWithDebInfo, anything
// else will be ignored.
CMAKE_CONFIGURATION_TYPES:STRING=Debug;Release;MinSizeRel;RelWithDebInfo

//Value Computed by CMake.
CMAKE_FIND_PACKAGE_REDIRECTS_DIR:STATIC=C:/Users/Paul/source/repos/dashfaction/CMakeFiles/pkgRedirects

//Value Computed by CMake
CMAKE_PROJECT_DESCRIPTION:STATIC=

//Value Computed by CMake
CMAKE_PROJECT_HOMEPAGE_URL:STATIC=

//Value Computed by CMake
CMAKE_PROJECT_NAME:STATIC=DashFaction

//Value Computed by CMake
DashFaction_BINARY_DIR:STATIC=C:/Users/Paul/source/repos/dashfaction

//Value Computed by CMake
DashFaction_IS_TOP_LEVEL:STATIC=ON

//Value Computed by CMake
DashFaction_SOURCE_DIR:STATIC=C:/Users/Paul/source/repos/dashfaction


########################
# INTERNAL cache entries
########################

//This is the directory where this CMakeCache.txt was created
CMAKE_CACHEFILE_DIR:INTERNAL=c:/Users/Paul/source/repos/dashfaction
//Major version of cmake used to create the current loaded cache
CMAKE_CACHE_MAJOR_VERSION:INTERNAL=3
//Minor version of cmake used to create the current loaded cache
CMAKE_CACHE_MINOR_VERSION:INTERNAL=26
//Patch version of cmake used to create the current loaded cache
CMAKE_CACHE_PATCH_VERSION:INTERNAL=4
//Path to CMake executable.
CMAKE_COMMAND:INTERNAL=C:/Program Files/CMake/bin/cmake.exe
//Path to cpack program executable.
CMAKE_CPACK_COMMAND:INTERNAL=C:/Program Files/CMake/bin/cpack.exe
//Path to ctest program executable.
CMAKE_CTEST_COMMAND:INTERNAL=C:/Program Files/CMake/bin/ctest.exe
//Name of external makefile project generator.
CMAKE_EXTRA_GENERATOR:INTERNAL=
//Name of generator.
CMAKE_GENERATOR:INTERNAL=Visual Studio 17 2022
//Generator instance identifier.
CMAKE_GENERATOR_INSTANCE:INTERNAL=
//Name of generator platform.
CMAKE_GENERATOR_PLATFORM:INTERNAL=Win32
//Name of generator toolset.
CMAKE_GENERATOR_TOOLSET:INTERNAL=
//Source directory with the top level CMakeLists.txt file for this
// project
CMAKE_HOME_DIRECTORY:INTERNAL=C:/Users/Paul/source/repos/dashfaction
//number of local generators
CMAKE_NUMBER_OF_MAKEFILES:INTERNAL=1
//Platform information initialized
CMAKE_PLATFORM_INFO_INITIALIZED:INTERNAL=1
//Path to CMake installation.
CMAKE_ROOT:INTERNAL=C:/Program Files/CMake/share/cmake-3.26

15 changes: 15 additions & 0 deletions CMakeFiles/3.26.4/CMakeSystem.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
set(CMAKE_HOST_SYSTEM "Windows-10.0.22621")
set(CMAKE_HOST_SYSTEM_NAME "Windows")
set(CMAKE_HOST_SYSTEM_VERSION "10.0.22621")
set(CMAKE_HOST_SYSTEM_PROCESSOR "AMD64")



set(CMAKE_SYSTEM "Windows-10.0.22621")
set(CMAKE_SYSTEM_NAME "Windows")
set(CMAKE_SYSTEM_VERSION "10.0.22621")
set(CMAKE_SYSTEM_PROCESSOR "AMD64")

set(CMAKE_CROSSCOMPILING "FALSE")

set(CMAKE_SYSTEM_LOADED 1)
11 changes: 11 additions & 0 deletions CMakeFiles/CMakeConfigureLog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

---
events:
-
kind: "message-v1"
backtrace:
- "C:/Program Files/CMake/share/cmake-3.26/Modules/CMakeDetermineSystem.cmake:204 (message)"
- "CMakeLists.txt:3 (project)"
message: |
The system is: Windows - 10.0.22621 - AMD64
...
1 change: 1 addition & 0 deletions CMakeFiles/cmake.check_cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This file is generated by cmake for dependency checking of the CMakeCache.txt file
1 change: 1 addition & 0 deletions common/include/common/config/GameConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ struct GameConfig
CfgVar<bool> reduced_speed_in_background = false;
CfgVar<bool> player_join_beep = false;
CfgVar<bool> autosave = true;
CfgVar<bool> derandomize_bomb = false;

// Internal
CfgVar<std::string> dash_faction_version{""};
Expand Down
1 change: 1 addition & 0 deletions common/src/config/GameConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ bool GameConfig::visit_vars(T&& visitor, bool is_save)
result &= visitor(dash_faction_key, "Mesh Static Lighting", mesh_static_lighting);
result &= visitor(dash_faction_key, "Player Join Beep", player_join_beep);
result &= visitor(dash_faction_key, "Autosave", autosave);
result &= visitor(dash_faction_key, "Derandomize Bomb", derandomize_bomb);

return result;
}
Expand Down
123 changes: 73 additions & 50 deletions game_patch/misc/misc.cpp
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
#include <windows.h>
#include <common/version/version.h>
#include <common/config/BuildConfig.h>
#include <xlog/xlog.h>
#include <patch_common/AsmOpcodes.h>
#include <patch_common/AsmWriter.h>
#include <patch_common/CallHook.h>
#include <patch_common/CodeInjection.h>
#include <patch_common/FunHook.h>
#include <cstring>
#include "misc.h"
#include "../sound/sound.h"
#include "../os/console.h"
#include "../main/main.h"
#include "../object/object.h"
#include "../os/console.h"
#include "../rf/gameseq.h"
#include "../rf/gr/gr.h"
#include "../rf/player/player.h"
#include "../rf/misc.h"
#include "../rf/multi.h"
#include "../rf/gameseq.h"
#include "../rf/os/os.h"
#include "../rf/misc.h"
#include "../rf/player/player.h"
#include "../rf/vmesh.h"
#include "../object/object.h"
#include "../sound/sound.h"
#include <common/config/BuildConfig.h>
#include <common/version/version.h>
#include <cstring>
#include <patch_common/AsmOpcodes.h>
#include <patch_common/AsmWriter.h>
#include <patch_common/CallHook.h>
#include <patch_common/CodeInjection.h>
#include <patch_common/FunHook.h>
#include <windows.h>
#include <xlog/xlog.h>

void apply_main_menu_patches();
void apply_save_restore_patches();
Expand Down Expand Up @@ -79,6 +79,26 @@ CodeInjection level_read_data_check_restore_status_patch{
},
};

CodeInjection derandomize_bomb{
0x0043b4c7,
[](auto& regs) {
write_mem<i32>(0x0063914C, 1);
write_mem<i32>(0x0063914C + 4, 1);
write_mem<i32>(0x0063914C + 8, 3);
write_mem<i32>(0x0063914C + 12, 2);

write_mem<i32>(0x006390D8, 3);
write_mem<i32>(0x006390D8 + 4, 2);
write_mem<i32>(0x006390D8 + 8, 1);
write_mem<i32>(0x006390D8 + 12, 0);
write_mem<i32>(0x006390D8 + 16, 0);
write_mem<i32>(0x006390D8 + 20, 2);
write_mem<i32>(0x006390D8 + 24, 1);

regs.eip = 0x0043b632;
},
};

void set_jump_to_multi_server_list(bool jump)
{
g_jump_to_multi_server_list = jump;
Expand All @@ -93,7 +113,9 @@ void start_join_multi_game_sequence(const rf::NetAddr& addr, const std::string&
bool multi_join_game(const rf::NetAddr& addr, const std::string& password)
{
auto multi_set_current_server_addr = addr_as_ref<void(const rf::NetAddr& addr)>(0x0044B380);
auto send_join_req_packet = addr_as_ref<void(const rf::NetAddr& addr, rf::String::Pod name, rf::String::Pod password, int max_rate)>(0x0047AA40);
auto send_join_req_packet =
addr_as_ref<void(const rf::NetAddr& addr, rf::String::Pod name, rf::String::Pod password, int max_rate)>(
0x0047AA40);

if (rf::gameseq_get_state() != rf::GS_MULTI_SERVER_LIST) {
return false;
Expand All @@ -110,10 +132,11 @@ FunHook<void(int, int)> rf_init_state_hook{
0x004B1AC0,
[](int state, int old_state) {
rf_init_state_hook.call_target(state, old_state);
xlog::trace("state %d old_state %d g_jump_to_multi_server_list %d", state, old_state, g_jump_to_multi_server_list);
xlog::trace("state %d old_state %d g_jump_to_multi_server_list %d", state, old_state,
g_jump_to_multi_server_list);

bool exiting_game = state == rf::GS_MAIN_MENU &&
(old_state == rf::GS_END_GAME || old_state == rf::GS_NEW_LEVEL);
bool exiting_game =
state == rf::GS_MAIN_MENU && (old_state == rf::GS_END_GAME || old_state == rf::GS_NEW_LEVEL);
if (exiting_game && g_in_mp_game) {
g_in_mp_game = false;
g_jump_to_multi_server_list = true;
Expand Down Expand Up @@ -164,24 +187,18 @@ FunHook<void()> multi_after_players_packet_hook{
},
};

CodeInjection mover_rotating_keyframe_oob_crashfix{
0x0046A559,
[](auto& regs) {
float& unk_time = *reinterpret_cast<float*>(regs.esi + 0x308);
unk_time = 0;
regs.eip = 0x0046A89D;
}
};
CodeInjection mover_rotating_keyframe_oob_crashfix{0x0046A559, [](auto& regs) {
float& unk_time = *reinterpret_cast<float*>(regs.esi + 0x308);
unk_time = 0;
regs.eip = 0x0046A89D;
}};

CodeInjection parser_xstr_oob_fix{
0x0051212E,
[](auto& regs) {
if (regs.edi >= 1000) {
xlog::warn("XSTR index is out of bounds: %d!", static_cast<int>(regs.edi));
regs.edi = -1;
}
}
};
CodeInjection parser_xstr_oob_fix{0x0051212E, [](auto& regs) {
if (regs.edi >= 1000) {
xlog::warn("XSTR index is out of bounds: %d!", static_cast<int>(regs.edi));
regs.edi = -1;
}
}};

CodeInjection ammo_tbl_buffer_overflow_fix{
0x004C218E,
Expand Down Expand Up @@ -311,7 +328,8 @@ CodeInjection glass_shard_level_init_fix{
},
};

int debug_print_hook(char* buf, const char *fmt, ...) {
int debug_print_hook(char* buf, const char* fmt, ...)
{
va_list vl;
va_start(vl, fmt);
int ret = vsprintf(buf, fmt, vl);
Expand All @@ -322,7 +340,7 @@ int debug_print_hook(char* buf, const char *fmt, ...) {

CallHook<int(char*, const char*)> skeleton_pagein_debug_print_patch{
0x0053AA73,
reinterpret_cast<int(*)(char*, const char*)>(debug_print_hook),
reinterpret_cast<int (*)(char*, const char*)>(debug_print_hook),
};

CodeInjection level_load_items_crash_fix{
Expand Down Expand Up @@ -360,20 +378,21 @@ CodeInjection explosion_crash_fix{
},
};

CallHook<void(rf::Vector3*, float, float, float, float, bool, int, int)> level_read_geometry_header_light_add_directional_hook{
0x004619E1,
[](rf::Vector3 *dir, float intensity, float r, float g, float b, bool is_dynamic, int casts_shadow, int dropoff_type) {
if (rf::gr::lighting_enabled()) {
level_read_geometry_header_light_add_directional_hook.call_target(dir, intensity, r, g, b, is_dynamic, casts_shadow, dropoff_type);
}
},
};
CallHook<void(rf::Vector3*, float, float, float, float, bool, int, int)>
level_read_geometry_header_light_add_directional_hook{
0x004619E1,
[](rf::Vector3* dir, float intensity, float r, float g, float b, bool is_dynamic, int casts_shadow,
int dropoff_type) {
if (rf::gr::lighting_enabled()) {
level_read_geometry_header_light_add_directional_hook.call_target(dir, intensity, r, g, b, is_dynamic,
casts_shadow, dropoff_type);
}
},
};

CodeInjection vfile_read_stack_corruption_fix{
0x0052D0E0,
[](auto& regs) {
regs.esi = regs.eax;
},
[](auto& regs) { regs.esi = regs.eax; },
};

void misc_init()
Expand Down Expand Up @@ -466,6 +485,10 @@ void misc_init()
// Fix stack corruption when packfile has lower size than expected
vfile_read_stack_corruption_fix.install();

if (g_game_config.derandomize_bomb) {
derandomize_bomb.install();
}

// Improve parse error message
// For some reason RF replaces all characters with code lower than 0x20 (space) by character with code 0x16 (SYN)
// in "Found this text" and "Prior text" sections. This makes all new line characters (CRLF) and tabs to be
Expand Down
Loading