Skip to content

Commit a6c3024

Browse files
committed
Don't crash when level doesn't have fast geometry
1 parent 5ad9a8b commit a6c3024

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

src/Layers/xrRender/FVisual.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ void Fvisual::Load(const char* N, IReader* data, u32 dwFlags)
5454
#endif
5555
// check for fast-vertices
5656
#if RENDER == R_R1
57-
if (data->find_chunk(OGF_FASTPATH) && ps_r1_force_geomx)
57+
if (RImplementation.IsFastGeomSupported() && data->find_chunk(OGF_FASTPATH) && ps_r1_force_geomx)
5858
#else
59-
if (data->find_chunk(OGF_FASTPATH))
59+
if (RImplementation.IsFastGeomSupported() && data->find_chunk(OGF_FASTPATH))
6060
#endif
6161
{
6262
destructor<IReader> geomdef(data->open_chunk(OGF_FASTPATH));

src/Layers/xrRender_R2/r2.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,8 @@ class CRender final : public D3DXRenderBase
335335

336336
bool m_bFirstFrameAfterReset{}; // Determines weather the frame is the first after resetting device.
337337

338+
bool m_fast_geom_loaded{};
339+
338340
private:
339341
// Loading / Unloading
340342
void LoadBuffers(CStreamReader* fs, bool alternative);
@@ -404,6 +406,12 @@ class CRender final : public D3DXRenderBase
404406
# error No graphics API selected or enabled!
405407
#endif
406408

409+
[[nodiscard]]
410+
bool IsFastGeomSupported() const
411+
{
412+
return m_fast_geom_loaded;
413+
}
414+
407415
// Loading / Unloading
408416
void create() override;
409417
void destroy() override;

src/Layers/xrRender_R2/r2_loader.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ void CRender::level_Load(IReader* fs)
6767
}
6868

6969
//...and alternate/fast geometry
70+
if (CStreamReader* geom = FS.rs_open("$level$", "level.geomX"))
7071
{
71-
CStreamReader* geom = FS.rs_open("$level$", "level.geomx");
72-
R_ASSERT2(geom, "level.geomX");
7372
LoadBuffers(geom, true);
7473
FS.r_close(geom);
74+
m_fast_geom_loaded = true;
7575
}
7676

7777
// Visuals
@@ -177,6 +177,8 @@ void CRender::level_Unload()
177177
nDC.clear();
178178
xDC.clear();
179179

180+
m_fast_geom_loaded = false;
181+
180182
//*** Components
181183
xr_delete(Details);
182184
xr_delete(Wallmarks);

0 commit comments

Comments
 (0)