Skip to content

Commit d3b5702

Browse files
committed
Merge branch 'carbon' into w2c
2 parents 14629d4 + 2ad4669 commit d3b5702

16 files changed

Lines changed: 321 additions & 24 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/assets/textures.cpp

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,43 +26,43 @@ namespace hyper
2626
switch (texture->blend_type)
2727
{
2828
case texture::alpha_blend_type::blend:
29-
this->alpha_blend_src = D3DBLEND_SRCALPHA;
30-
this->alpha_blend_dest = D3DBLEND_INVSRCALPHA;
29+
this->alpha_blend_src = ::D3DBLEND_SRCALPHA;
30+
this->alpha_blend_dest = ::D3DBLEND_INVSRCALPHA;
3131
break;
3232

3333
case texture::alpha_blend_type::additive:
34-
this->alpha_blend_src = D3DBLEND_SRCALPHA;
35-
this->alpha_blend_dest = D3DBLEND_ONE;
34+
this->alpha_blend_src = ::D3DBLEND_SRCALPHA;
35+
this->alpha_blend_dest = ::D3DBLEND_ONE;
3636
this->is_additive_blend = true;
3737
this->colour_write_alpha = true;
3838
break;
3939

4040
case texture::alpha_blend_type::subtractive:
41-
this->alpha_blend_src = D3DBLEND_ZERO;
42-
this->alpha_blend_dest = D3DBLEND_INVSRCCOLOR;
41+
this->alpha_blend_src = ::D3DBLEND_ZERO;
42+
this->alpha_blend_dest = ::D3DBLEND_INVSRCCOLOR;
4343
break;
4444

4545
case texture::alpha_blend_type::overbright:
46-
this->alpha_blend_src = D3DBLEND_SRCALPHA;
47-
this->alpha_blend_dest = D3DBLEND_INVSRCALPHA;
46+
this->alpha_blend_src = ::D3DBLEND_SRCALPHA;
47+
this->alpha_blend_dest = ::D3DBLEND_INVSRCALPHA;
4848
break;
4949

5050
case texture::alpha_blend_type::dest_blend:
51-
this->alpha_blend_src = D3DBLEND_DESTALPHA;
52-
this->alpha_blend_dest = D3DBLEND_INVDESTALPHA;
51+
this->alpha_blend_src = ::D3DBLEND_DESTALPHA;
52+
this->alpha_blend_dest = ::D3DBLEND_INVDESTALPHA;
5353
break;
5454

5555
case texture::alpha_blend_type::dest_additive:
56-
this->alpha_blend_src = D3DBLEND_DESTALPHA;
57-
this->alpha_blend_dest = D3DBLEND_ONE;
56+
this->alpha_blend_src = ::D3DBLEND_DESTALPHA;
57+
this->alpha_blend_dest = ::D3DBLEND_ONE;
5858
break;
5959
}
6060
}
6161
else
6262
{
6363
this->z_write_enabled = true;
64-
this->alpha_blend_src = D3DBLEND_ONE;
65-
this->alpha_blend_dest = D3DBLEND_ZERO;
64+
this->alpha_blend_src = ::D3DBLEND_ONE;
65+
this->alpha_blend_dest = ::D3DBLEND_ZERO;
6666

6767
if (!this->alpha_test_enabled && (texture->flags & texture::bit_flags::disable_culling) != texture::bit_flags::disable_culling)
6868
{
@@ -72,24 +72,28 @@ namespace hyper
7272

7373
if ((texture->tilable_uv & texture::tileable_type::u_mirror) == texture::tileable_type::u_mirror)
7474
{
75-
this->texture_address_u = D3DTADDRESS_MIRROR;
75+
this->texture_address_u = ::D3DTADDRESS_MIRROR;
7676
}
7777
else
7878
{
79-
this->texture_address_u = (texture->tilable_uv & texture::tileable_type::u_repeat) == texture::tileable_type::u_repeat ? D3DTADDRESS_WRAP : D3DTADDRESS_CLAMP;
79+
this->texture_address_u = (texture->tilable_uv & texture::tileable_type::u_repeat) == texture::tileable_type::u_repeat
80+
? ::D3DTADDRESS_WRAP
81+
: ::D3DTADDRESS_CLAMP;
8082
}
8183

8284
if ((texture->tilable_uv & texture::tileable_type::v_mirror) == texture::tileable_type::v_mirror)
8385
{
84-
this->texture_address_v = D3DTADDRESS_MIRROR;
86+
this->texture_address_v = ::D3DTADDRESS_MIRROR;
8587
}
8688
else
8789
{
88-
this->texture_address_v = (texture->tilable_uv & texture::tileable_type::v_repeat) == texture::tileable_type::v_repeat ? D3DTADDRESS_WRAP : D3DTADDRESS_CLAMP;
90+
this->texture_address_v = (texture->tilable_uv & texture::tileable_type::v_repeat) == texture::tileable_type::v_repeat
91+
? ::D3DTADDRESS_WRAP
92+
: ::D3DTADDRESS_CLAMP;
8993
}
9094

9195
this->bias_level = texture->bias_level & 3;
92-
this->alpha_test_ref = 11u; // #TODO
96+
this->alpha_test_ref = 11u; // #TODO ?
9397

9498
if (class_key == hashing::bin_const("Tree Leaves") || class_key == hashing::bin_const("Tree Cards") || class_key == hashing::bin_const("MultiPass Blend"))
9599
{
@@ -99,7 +103,7 @@ namespace hyper
99103

100104
bool is_barrier = class_key == hashing::bin_const("Barrier Mask")
101105
#if defined(CHECK_BARRIER_STRINGS)
102-
|| ::strncmp(reinterpret_cast<const char*>(texture->name), "SFX_TRACKBARRIER", 16u)
106+
|| !::strncmp(reinterpret_cast<const char*>(texture->name), "SFX_TRACKBARRIER", 16u)
103107
#endif
104108
;
105109

src/hyperlib/renderer/flare_pool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ namespace hyper
117117

118118
void flare_pool::ctor(flare_pool* pool)
119119
{
120-
new (pool) flare_pool(0x80u); // by default, flare pool is initialized to 0x80 flares
120+
new (pool) flare_pool(0x200u);
121121
}
122122

123123
void flare_pool::dtor(flare_pool* pool)

src/hyperlib/streamer/sections.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,11 @@ namespace hyper
306306
}
307307
}
308308

309+
void visible_section::manager::disable_all_groups()
310+
{
311+
::memset(this->enabled_groups, 0, sizeof(this->enabled_groups));
312+
}
313+
309314
bool visible_section::manager::loader(chunk* block)
310315
{
311316
if (block->id() == block_id::visible_section_manager)
@@ -488,4 +493,23 @@ namespace hyper
488493

489494
return extra_width;
490495
}
496+
497+
auto visible_section::manager::get_group_info(const char* group_name) -> const group_info*
498+
{
499+
size_t length = string::length(group_name);
500+
501+
for (size_t i = 0u; i < visible_section::manager::group_info_table.length(); ++i)
502+
{
503+
const group_info& info = visible_section::manager::group_info_table[i];
504+
505+
size_t namesz = string::length(info.selection_set_name);
506+
507+
if (namesz <= length && !::_strnicmp(info.selection_set_name, group_name, namesz))
508+
{
509+
return &info;
510+
}
511+
}
512+
513+
return nullptr;
514+
}
491515
}

src/hyperlib/streamer/sections.hpp

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

326326
void disable_group(std::uint32_t key);
327327

328+
void disable_all_groups();
329+
328330
bool loader(chunk* block);
329331

330332
bool unloader(chunk* block);
@@ -337,6 +339,8 @@ namespace hyper
337339
public:
338340
static auto get_distance_outside(const boundary* bound, const vector2& position, float extra_width) -> float;
339341

342+
static auto get_group_info(const char* group_name) -> const group_info*;
343+
340344
public:
341345
linked_list<boundary> drivable_boundary_list;
342346
linked_list<boundary> non_drivable_boundary_list;
@@ -370,6 +374,8 @@ namespace hyper
370374
static inline std::uint32_t& current_zone_number = *reinterpret_cast<std::uint32_t*>(0x00A71C1C);
371375

372376
static inline geometry::model*& zone_boundary_model = *reinterpret_cast<geometry::model**>(0x00B69BE8);
377+
378+
static inline array<group_info, 5u> group_info_table = array<group_info, 5u>(0x00A72C30);
373379
};
374380
};
375381

src/hyperlib/streamer/track_path.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

33
namespace hyper
44
{
5+
void track_path::manager::disable_all_barriers()
6+
{
7+
for (std::uint32_t i = 0u; i < this->barrier_count; ++i)
8+
{
9+
this->barriers[i].enabled = false;
10+
}
11+
}
12+
13+
void track_path::manager::enable_barriers(const char* barrier_name)
14+
{
15+
call_function<void(__thiscall*)(track_path::manager*, const char*)>(0x007A2390)(this, barrier_name);
16+
}
17+
518
auto track_path::manager::find_zone(const vector2* position, zone::type type, const zone* prev) -> zone*
619
{
720
if (position == nullptr)

src/hyperlib/streamer/track_path.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ namespace hyper
7676
struct manager
7777
{
7878
public:
79+
void disable_all_barriers();
80+
81+
void enable_barriers(const char* barrier_name);
82+
7983
auto find_zone(const vector2* position, zone::type type, const zone* prev) -> zone*;
8084

8185
public:

src/hyperlib/version.hpp

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

src/hyperlib/world/world.cpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#include <hyperlib/assets/scenery.hpp>
2+
#include <hyperlib/streamer/sections.hpp>
3+
#include <hyperlib/streamer/track_path.hpp>
14
#include <hyperlib/world/world.hpp>
25

36
namespace hyper
@@ -19,4 +22,53 @@ namespace hyper
1922
{
2023
call_function<void(__cdecl*)()>(0x007AF8F0)();
2124
}
25+
26+
void world::enable_barrier_scenery_group(const char* name, bool flip_artwork)
27+
{
28+
if (visible_section::manager::get_group_info(name) != nullptr)
29+
{
30+
std::uint32_t key = hashing::bin(name);
31+
32+
visible_section::manager::instance.enable_group(key);
33+
34+
scenery::group::enable(key, flip_artwork);
35+
36+
track_path::manager::instance.enable_barriers(name);
37+
}
38+
}
39+
40+
void world::disable_all_scenery_groups()
41+
{
42+
for (const scenery::group* i = scenery::group::list.begin(); i != scenery::group::list.end(); i = i->next())
43+
{
44+
if (scenery::group::enabled_table[i->group_number])
45+
{
46+
i->disable_rendering();
47+
48+
scenery::group::enabled_table[i->group_number] = 0;
49+
}
50+
}
51+
}
52+
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+
64+
void world::redo_topology_and_scenery_groups()
65+
{
66+
track_path::manager::instance.disable_all_barriers();
67+
68+
visible_section::manager::instance.disable_all_groups();
69+
70+
world::disable_all_scenery_groups();
71+
72+
world::init_topology_and_scenery_groups();
73+
}
2274
}

src/hyperlib/world/world.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,21 @@ namespace hyper
1313
static void init_visible_zones(geometry::model*& boundary_model);
1414

1515
static void notify_sky_loader();
16+
17+
static void enable_barrier_scenery_group(const char* name, bool flip_artwork);
18+
19+
static void disable_all_scenery_groups();
20+
21+
static void init_topology_and_scenery_groups();
22+
23+
static void redo_topology_and_scenery_groups();
24+
25+
private:
26+
static inline const char* permanent_scenery_groups[] =
27+
{
28+
"SCENERY_GROUP_DOOR",
29+
"SCENERY_GROUP_CHRISTMAS",
30+
"SCENERY_GROUP_HALLOWEEN_DISABLE",
31+
};
1632
};
1733
}

0 commit comments

Comments
 (0)