Skip to content

Commit f6aaaa6

Browse files
committed
Add support for high resolution GeoMod textures
1 parent c039114 commit f6aaaa6

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

docs/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Version 1.9.0 (not released yet)
5050
- Add option to disguise as Alpine Faction to avoids AF advertisements and allow playing in servers that reject non-AF players
5151
- Enable loading RFL version 300
5252
- Log a warning when RFL uses unsupported event class
53+
- Add support for high resolution GeoMod textures
5354

5455
[@GooberRF](https://github.com/GooberRF)
5556
- Fix crash when `verify_level` command is run without a level being loaded

game_patch/misc/level.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "../os/console.h"
88
#include "../rf/multi.h"
99
#include "../rf/level.h"
10+
#include "../rf/geometry.h"
1011
#include "../rf/file/file.h"
1112
#include "level.h"
1213

@@ -92,6 +93,18 @@ CodeInjection level_load_chunk_inj{
9293
},
9394
};
9495

96+
CodeInjection level_blast_ppm_injection{
97+
0x00466C00,
98+
[](auto& regs) {
99+
rf::GSolid* solid = regs.ecx;
100+
int bmh = regs.edi;
101+
int w = 256, h = 256;
102+
rf::bm::get_dimensions(bmh, &w, &h);
103+
float ppm = std::min(w, h) / 256.0 * 32.0;
104+
solid->set_autotexture_pixels_per_meter(ppm);
105+
},
106+
};
107+
95108
void level_apply_patch()
96109
{
97110
// Enable loading RFLs with version 300 (produced by AF editor)
@@ -112,4 +125,7 @@ void level_apply_patch()
112125
// Load custom rfl chunks
113126
level_load_init_inj.install();
114127
level_load_chunk_inj.install();
128+
129+
// Increase PPM (Pixels per Meter) for GeoMod textures if they have higher dimensions than 256x256
130+
level_blast_ppm_injection.install();
115131
}

game_patch/rf/geometry.h

+5
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ namespace rf
115115
{
116116
AddrCaller{0x004DF1C0}.this_call(this, in, out, clear_fraction);
117117
}
118+
119+
void set_autotexture_pixels_per_meter(float ppm)
120+
{
121+
AddrCaller{0x004F8730}.this_call(this, ppm);
122+
}
118123
};
119124
static_assert(sizeof(GSolid) == 0x378);
120125

0 commit comments

Comments
 (0)