-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathRegionUtils.cpp
63 lines (57 loc) · 1.4 KB
/
RegionUtils.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "RegionUtils.hpp"
std::map<region*, MenuRegionInfo> s_MenuRegions;
region* GetRegionByName(const char* s)
{
region* const regions = game::get_regions();
if (regions != nullptr)
{
for (size_t i = 0; i < SM3_REGIONS_COUNT; i++)
{
region* const currentRegion = regions + i;
if (strcmp(currentRegion->name, s) == 0)
{
return currentRegion;
}
}
}
return nullptr;
}
void UnlockAllUndergroundInteriors()
{
region* const regions = game::get_regions();
if (regions != nullptr)
{
for (size_t i = 0; i < SM3_REGIONS_COUNT; i++)
{
region* const currentRegion = regions + i;
if (currentRegion->pos_1.y < 0.0f)
{
currentRegion->flags &= E_REGION_FLAGS::E_LOADED;
}
}
}
}
void LoadInterior(region* target)
{
const float MAX_Y = 1024.0f;
vector3d pos = { max(target->pos_1.x, target->pos_2.x), target->pos_1.y, max(target->pos_1.z, target->pos_2.z) };
if (pos.y < 0.0f)
{
pos.y = max(target->pos_1.y, target->pos_2.y);
UnlockAllUndergroundInteriors();
}
else
{
if (pos.y > MAX_Y)
{
pos.y = target->pos_2.y;
}
const std::shared_ptr<debug_menu_entry_list> list = s_MenuRegions.at(target).region_entry_parent->sublist;
for (size_t i = 0; i < list->size(); i++)
{
region* const currentRegion = reinterpret_cast<region*>(list->entry_at(i)->callback_arg);
currentRegion->flags &= E_REGION_FLAGS::E_LOADED;
}
}
world::inst()->set_hero_rel_position(pos);
}