Skip to content

Commit 634bb2c

Browse files
committed
add legacy fog patch dvar + fixes
1 parent 6cc35e5 commit 634bb2c

5 files changed

Lines changed: 51 additions & 5 deletions

File tree

src/client/component/command.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ namespace command
7070
desc = info.value().description;
7171
}
7272

73-
console::info("\"%s\" is: \"%s\" default: \"%s\" hash: 0x%08lX\n",
74-
name.data(), current, reset, dvar->name);
73+
console::info("\"%s\" is: \"%s\" default: \"%s\" hash: 0x%08lX flags: 0x%08lX\n",
74+
name.data(), current, reset, dvar->name, dvar->flags);
7575

7676
console::info("%s\n", desc.data());
7777
console::info(" %s\n", dvars::dvar_get_domain(dvar->type, dvar->domain).data());

src/client/component/gui/assets/fxeffectdef.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ namespace gui::asset_list::fxeffectdef
120120
add_view_button(index, game::ASSET_TYPE_XMODEL, visual->model->name);
121121
break;
122122
case game::FX_ELEM_TYPE_RUNNER:
123-
ImGui::Text(visual->effectDef.name);
123+
ImGui::Text(visual->effectDef.handle->name);
124124
ImGui::SameLine();
125-
add_view_button(index, game::ASSET_TYPE_FX, visual->effectDef.name);
125+
add_view_button(index, game::ASSET_TYPE_FX, visual->effectDef.handle->name);
126126
break;
127127
case game::FX_ELEM_TYPE_SOUND:
128128
ImGui::Text(visual->soundName);

src/client/component/gui/debug.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ namespace gui::debug
7575
struct : draw_settings
7676
{
7777
bool draw_node_links;
78+
bool negotation_links_only;
7879
float size = 10.f;
7980
float link_thickness = 1.f;
8081
float color[4] = {1.f, 0.f, 0.f, 1.f};
@@ -436,6 +437,7 @@ namespace gui::debug
436437
ImGui::Checkbox("Lock camera", &path_node_settings.camera_locked);
437438

438439
ImGui::Checkbox("Draw node links", &path_node_settings.draw_node_links);
440+
ImGui::Checkbox("Negotation links only", &path_node_settings.negotation_links_only);
439441

440442
if (ImGui::TreeNode("Object type"))
441443
{
@@ -539,6 +541,12 @@ namespace gui::debug
539541
const auto num = node->constant.Links[i].nodeNum;
540542
const auto linked = &game::pathData->nodes[num];
541543

544+
if (path_node_settings.negotation_links_only &&
545+
linked->constant.type != game::NODE_NEGOTIATION_BEGIN && linked->constant.type != game::NODE_NEGOTIATION_END)
546+
{
547+
continue;
548+
}
549+
542550
get_pathnode_origin(linked, linked_origin);
543551
if (distance_2d(path_node_settings.camera, linked_origin) < path_node_settings.range)
544552
{
@@ -583,6 +591,12 @@ namespace gui::debug
583591
float origin[3] = {};
584592
const auto node = &game::pathData->nodes[i];
585593

594+
if (path_node_settings.negotation_links_only &&
595+
node->constant.type != game::NODE_NEGOTIATION_BEGIN && node->constant.type != game::NODE_NEGOTIATION_END)
596+
{
597+
continue;
598+
}
599+
586600
get_pathnode_origin(node, origin);
587601
if (distance_2d(path_node_settings.camera, origin) >= path_node_settings.range)
588602
{

src/client/component/gui/gui.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <utils/string.hpp>
1212
#include <utils/hook.hpp>
1313
#include <utils/concurrency.hpp>
14+
#include <utils/properties.hpp>
1415

1516
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
1617

@@ -54,6 +55,15 @@ namespace gui
5455
bool toggled = false;
5556
} globals;
5657

58+
void set_cfg_path()
59+
{
60+
const auto path = utils::properties::get_appdata_path() / "imgui.ini";
61+
const auto path_str = utils::memory::duplicate_string(path.generic_string());
62+
63+
auto& io = ImGui::GetIO();
64+
io.IniFilename = path_str;
65+
}
66+
5767
void initialize_gui_context()
5868
{
5969
ImGui::CreateContext();
@@ -63,6 +73,8 @@ namespace gui
6373
ImGui_ImplDX11_Init(globals.device, globals.device_context);
6474

6575
globals.initialized = true;
76+
77+
set_cfg_path();
6678
}
6779

6880
void run_event_queue()
@@ -465,7 +477,6 @@ namespace gui
465477
show_notifications();
466478
draw_main_menu_bar();
467479
});
468-
469480
}
470481

471482
void pre_destroy() override

src/client/component/renderer.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ namespace renderer
1616
utils::hook::detour r_init_draw_method_hook;
1717
utils::hook::detour r_update_front_end_dvar_options_hook;
1818

19+
game::dvar_t* r_legacy_fog_patch = nullptr;
20+
1921
int get_fullbright_technique()
2022
{
2123
switch (dvars::r_fullbright->current.integer)
@@ -56,6 +58,22 @@ namespace renderer
5658

5759
return r_update_front_end_dvar_options_hook.invoke<bool>();
5860
}
61+
62+
struct GfxCmdBufInput
63+
{
64+
float consts[363][4];
65+
};
66+
67+
utils::hook::detour set_frame_fog_hook;
68+
void set_frame_fog_stub(void* a1, GfxCmdBufInput* input, __m128* a3)
69+
{
70+
set_frame_fog_hook.invoke<void>(a1, input, a3);
71+
72+
if (r_legacy_fog_patch->current.enabled)
73+
{
74+
input->consts[game::CONST_SRC_CODE_ATMOS_FOG_PARMS_5][2] = 1.f;
75+
}
76+
}
5977
}
6078

6179
class component final : public component_interface
@@ -67,6 +85,9 @@ namespace renderer
6785

6886
r_init_draw_method_hook.create(0x14072F950, &r_init_draw_method_stub);
6987
r_update_front_end_dvar_options_hook.create(0x14076EE70, &r_update_front_end_dvar_options_stub);
88+
89+
set_frame_fog_hook.create(0x1407A97B0, set_frame_fog_stub);
90+
r_legacy_fog_patch = dvars::register_bool("r_legacyFogPatch", false, 0x40, "enable legacy fog patch (fixes black fx with legacy fog)");
7091
}
7192
};
7293
}

0 commit comments

Comments
 (0)