Skip to content

Commit 10a49b2

Browse files
committed
Merge branch 'main' into carbon
2 parents 6bafb3b + f5cca45 commit 10a49b2

6 files changed

Lines changed: 90 additions & 6 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ nunit-*.xml
5757
[Rr]eleasePS/
5858
dlldata.c
5959

60+
# Version Files
61+
version.hpp
62+
6063
# Benchmark Results
6164
BenchmarkDotNet.Artifacts/
6265

src/hyperlib/streamer/sections.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,9 @@ namespace hyper
502502
{
503503
const group_info& info = visible_section::manager::group_info_table[i];
504504

505-
if (string::length(info.selection_set_name) == length && !::_strnicmp(info.selection_set_name, group_name, length))
505+
size_t namesz = string::length(info.selection_set_name);
506+
507+
if (namesz <= length && !::_strnicmp(info.selection_set_name, group_name, namesz))
506508
{
507509
return &info;
508510
}

src/hyperlib/version.hpp

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/hyperlib/world/world.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@ namespace hyper
5050
}
5151
}
5252

53+
void world::init_topology_and_scenery_groups()
54+
{
55+
for (const char* group : world::permanent_scenery_groups)
56+
{
57+
if (scenery::group::find(hashing::bin(group)) != nullptr)
58+
{
59+
world::enable_barrier_scenery_group(group, false);
60+
}
61+
}
62+
}
63+
5364
void world::redo_topology_and_scenery_groups()
5465
{
5566
track_path::manager::instance.disable_all_barriers();
@@ -58,9 +69,6 @@ namespace hyper
5869

5970
world::disable_all_scenery_groups();
6071

61-
if (scenery::group::find(hashing::bin_const("SCENERY_GROUP_DOOR")) != nullptr)
62-
{
63-
world::enable_barrier_scenery_group("SCENERY_GROUP_DOOR", false);
64-
}
72+
world::init_topology_and_scenery_groups();
6573
}
6674
}

src/hyperlib/world/world.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ namespace hyper
1818

1919
static void disable_all_scenery_groups();
2020

21+
static void init_topology_and_scenery_groups();
22+
2123
static void redo_topology_and_scenery_groups();
24+
25+
private:
26+
static inline const char* permanent_scenery_groups[] =
27+
{
28+
"SCENERY_GROUP_DOOR",
29+
};
2230
};
2331
}

src/hyperlinked/patches/world/world.cpp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,64 @@
33

44
namespace hyper
55
{
6+
__declspec(naked) void detour_setup_topology_and_scenery()
7+
{
8+
__asm
9+
{
10+
// [esp + 0x00] is 'return address'
11+
12+
// esp is auto-managed, non-incremental
13+
// ebp is auto-managed, restored on function return
14+
15+
push eax; // 'return address' is now at [esp + 0x04]
16+
push ebx; // 'return address' is now at [esp + 0x08]
17+
push ecx; // 'return address' is now at [esp + 0x0C]
18+
push edx; // 'return address' is now at [esp + 0x10]
19+
push esi; // 'return address' is now at [esp + 0x14]
20+
push edi; // 'return address' is now at [esp + 0x18]
21+
22+
call world::init_topology_and_scenery_groups; // call custom init_topology_and_scenery_groups
23+
24+
pop edi; // restore saved register
25+
pop esi; // restore saved register
26+
pop edx; // restore saved register
27+
pop ecx; // restore saved register
28+
pop ebx; // restore saved register
29+
pop eax; // restore saved register
30+
31+
retn; // return immediately to caller function, not back to SetupTopologyAndScenery
32+
}
33+
}
34+
35+
__declspec(naked) void detour_init_topology_and_scenery_groups()
36+
{
37+
__asm
38+
{
39+
// [esp + 0x00] is 'return address'
40+
41+
// esp is auto-managed, non-incremental
42+
// ebp is auto-managed, restored on function return
43+
44+
push eax; // 'return address' is now at [esp + 0x04]
45+
push ebx; // 'return address' is now at [esp + 0x08]
46+
push ecx; // 'return address' is now at [esp + 0x0C]
47+
push edx; // 'return address' is now at [esp + 0x10]
48+
push esi; // 'return address' is now at [esp + 0x14]
49+
push edi; // 'return address' is now at [esp + 0x18]
50+
51+
call world::init_topology_and_scenery_groups; // call custom init_topology_and_scenery_groups
52+
53+
pop edi; // restore saved register
54+
pop esi; // restore saved register
55+
pop edx; // restore saved register
56+
pop ecx; // restore saved register
57+
pop ebx; // restore saved register
58+
pop eax; // restore saved register
59+
60+
retn; // return immediately to caller function, not back to InitTopologyAndSceneryGroups
61+
}
62+
}
63+
664
__declspec(naked) void detour_redo_topology_and_scenery_groups()
765
{
866
__asm
@@ -34,6 +92,12 @@ namespace hyper
3492

3593
void world_patches::init()
3694
{
95+
// SetupTopologyAndScenery
96+
hook::jump(0x007990A0, &detour_setup_topology_and_scenery);
97+
98+
// InitTopologyAndSceneryGroups
99+
hook::jump(0x006A8A80, &detour_init_topology_and_scenery_groups);
100+
37101
// RedoTopologyAndSceneryGroups
38102
hook::jump(0x006A8AD0, &detour_redo_topology_and_scenery_groups);
39103
}

0 commit comments

Comments
 (0)