diff --git a/Source/Client/ModeFade.cpp b/Source/Client/ModeFade.cpp index 31005f06..273a09e7 100644 --- a/Source/Client/ModeFade.cpp +++ b/Source/Client/ModeFade.cpp @@ -19,7 +19,7 @@ void ModeFade::Draw() { const std::uint32_t elapsed = timeGetTime() - g_modeFadeTick; if (elapsed < 255) { DrawAlphaRectangle( - this->primitives, this->textures, this->queues, 0, 0, this->screenWidth, this->screenHeight, (255 - elapsed) << 24, this->depthAlpha, this->depthStart, + this->primitives, this->queues, 0, 0, this->screenWidth, this->screenHeight, (255 - elapsed) << 24, this->depthAlpha, this->depthStart, this->depthEnd ); } diff --git a/Source/Client/ModeFade.h b/Source/Client/ModeFade.h index 52090771..60d9f589 100644 --- a/Source/Client/ModeFade.h +++ b/Source/Client/ModeFade.h @@ -12,7 +12,6 @@ extern std::uint32_t g_modeFadeTick; struct ModeFade { int& requested; RenderPrimitivePool& primitives; - TextureCache& textures; RenderQueues& queues; const int& screenWidth; const int& screenHeight; diff --git a/Source/Client/ModeFadeOut.cpp b/Source/Client/ModeFadeOut.cpp index 86cb4e1e..aa4559d2 100644 --- a/Source/Client/ModeFadeOut.cpp +++ b/Source/Client/ModeFadeOut.cpp @@ -12,14 +12,14 @@ // OFFSET: 0x00AD6960 // FUNCTION: fn_17847 -std::uint32_t FadeOutMode(CRenderer& renderer, CRenderSystemBase& system, TextureCache& textures, ResourceMgr& resources, +std::uint32_t FadeOutMode(CRenderer& renderer, CRenderSystemBase& system, ResourceMgr& resources, int showLogo, bool depthAlpha, float depthStart, float depthEnd) { g_soundMgr->FadeOut(); g_modeFadeTick = timeGetTime(); renderer.CaptureBackBuffer(); std::uint32_t elapsed = timeGetTime() - g_modeFadeTick; while (elapsed < 255) { - DrawAlphaRectangle(renderer.primitives, textures, renderer.queues, 0, 0, renderer.viewport.width, renderer.viewport.height, elapsed << 24, + DrawAlphaRectangle(renderer.primitives, renderer.queues, 0, 0, renderer.viewport.width, renderer.viewport.height, elapsed << 24, depthAlpha, depthStart, depthEnd); if (showLogo != 0) { auto* logo = static_cast(resources.Load(Resolve("rag_logo.bmp"))); diff --git a/Source/Client/ModeFadeOut.h b/Source/Client/ModeFadeOut.h index 0854e169..8be082e3 100644 --- a/Source/Client/ModeFadeOut.h +++ b/Source/Client/ModeFadeOut.h @@ -8,7 +8,7 @@ class CRenderSystemBase; class TextureCache; class ResourceMgr; -std::uint32_t FadeOutMode(CRenderer& renderer, CRenderSystemBase& system, TextureCache& textures, ResourceMgr& resources, +std::uint32_t FadeOutMode(CRenderer& renderer, CRenderSystemBase& system, ResourceMgr& resources, int showLogo, bool depthAlpha, float depthStart, float depthEnd); #endif diff --git a/Source/Contents/Effects/PartyEffect.cpp b/Source/Contents/Effects/PartyEffect.cpp index 860af229..68a6a45f 100644 --- a/Source/Contents/Effects/PartyEffect.cpp +++ b/Source/Contents/Effects/PartyEffect.cpp @@ -10,7 +10,7 @@ // OFFSET: 0x00C2CF20 // FUNCTION: fn_20088 bool UpdatePartyEffect( - CRagEffect& self, ResourceMgr& resources, std::list& worldObjects, TextureCache& textures, const TerrainHeight& ground, + CRagEffect& self, ResourceMgr& resources, std::list& worldObjects, const TerrainHeight& ground, int updateTick ) { RagEffectState& effect = self.state; @@ -53,7 +53,7 @@ bool UpdatePartyEffect( const auto bytes = state.totalTexture >> 30 != 0 ? std::numeric_limits::max() : static_cast(4u * state.totalTexture); state.textures = static_cast(::operator new(bytes)); - state.textures[0] = textures.Load("effect\\party.tga", 0, false, true, false); + state.textures[0] = g_texMgr.Load("effect\\party.tga", 0, false, true, false); } render.position.y = ground.Height(render.position.x, render.position.z) - 2.0f; diff --git a/Source/Contents/Effects/PartyEffect.h b/Source/Contents/Effects/PartyEffect.h index be0a92d4..2a591ca1 100644 --- a/Source/Contents/Effects/PartyEffect.h +++ b/Source/Contents/Effects/PartyEffect.h @@ -11,7 +11,7 @@ class TextureCache; class CRenderObject; bool UpdatePartyEffect( - CRagEffect& self, ResourceMgr& resources, std::list& worldObjects, TextureCache& textures, const TerrainHeight& ground, + CRagEffect& self, ResourceMgr& resources, std::list& worldObjects, const TerrainHeight& ground, int updateTick ); diff --git a/Source/Contents/Effects/RagEffect.cpp b/Source/Contents/Effects/RagEffect.cpp index f80ec31e..280171ba 100644 --- a/Source/Contents/Effects/RagEffect.cpp +++ b/Source/Contents/Effects/RagEffect.cpp @@ -187,7 +187,7 @@ void CRagEffect::FireBall() { // OFFSET: 0x00C15E40 // FUNCTION: fn_20054 -void CRagEffect::FrostDiver(TextureCache& textures, char type) { +void CRagEffect::FrostDiver(char type) { if (g_serviceOptions.Get(229) != 0) { return; } @@ -252,7 +252,7 @@ void CRagEffect::FrostDiver(TextureCache& textures, char type) { this->state.unknown_11C84->chCnt = 20; this->state.unknown_11C84->fadeOutCnt = this->state.unknown_11C84->duration - 10; AllocateTextures(*this->state.unknown_11C84); - CTexture* texture = textures.Load("effect\\ice.tga", 0, false, true, false); + CTexture* texture = g_texMgr.Load("effect\\ice.tga", 0, false, true, false); this->state.unknown_11C84->textures[0] = texture; this->state.deltaPos3[0] = this->state.deltaPos3[0] - this->state.deltaPos2[0]; this->state.deltaPos3[1] = this->state.deltaPos3[1] - this->state.deltaPos2[1]; @@ -261,7 +261,7 @@ void CRagEffect::FrostDiver(TextureCache& textures, char type) { // OFFSET: 0x00C16C70 // FUNCTION: fn_20058 -void CRagEffect::GrimTooth(TextureCache& textures) { +void CRagEffect::GrimTooth() { if (this->state.stateCnt == 0) { PlayEffectWave(*this, "effect\\EF_FrostDiver.wav"); this->Face(this->state.deltaPos[0], this->state.deltaPos[2]); @@ -323,7 +323,7 @@ void CRagEffect::GrimTooth(TextureCache& textures) { this->state.unknown_11C84->chCnt = 6; this->state.unknown_11C84->fadeOutCnt = this->state.unknown_11C84->duration - 10; AllocateTextures(*this->state.unknown_11C84); - CTexture* texture = textures.Load("effect\\stone.bmp", 0, false, true, false); + CTexture* texture = g_texMgr.Load("effect\\stone.bmp", 0, false, true, false); this->state.deltaPos3[0] = this->state.deltaPos3[0] - this->state.deltaPos2[0]; this->state.deltaPos3[1] = this->state.deltaPos3[1] - this->state.deltaPos2[1]; this->state.unknown_11C84->textures[0] = texture; @@ -332,7 +332,7 @@ void CRagEffect::GrimTooth(TextureCache& textures) { // OFFSET: 0x00C19980 // FUNCTION: fn_20066 -void CRagEffect::Hit4(const RenderProjection& projection, TextureCache& textures) { +void CRagEffect::Hit4(const RenderProjection& projection) { RenderVertex vertex{0.0f, 0.0f, 0.0f, 0.0f, 0u, 0xFF000000u, 0.0f, 0.0f}; projection.Project(&this->state.parent->render.position.x, static_cast(g_modeMgr.GetGameMode())->camera->frame.view.values, vertex); this->state.tlvertX = vertex.x; @@ -364,7 +364,7 @@ void CRagEffect::Hit4(const RenderProjection& projection, TextureCache& textures const int lifetime = this->state.unknown_11C84->duration; this->state.unknown_11C84->fadeOutCnt = lifetime - lifetime / 3; AllocateTextures(*this->state.unknown_11C84); - CTexture* texture = textures.Load("effect\\lens2.tga", 0, false, true, false); + CTexture* texture = g_texMgr.Load("effect\\lens2.tga", 0, false, true, false); this->state.unknown_11C84->textures[0] = texture; for (int count = 5; count != 0; --count) { @@ -526,7 +526,7 @@ void CRagEffect::SpearBmr() { // OFFSET: 0x00C3BD40 // FUNCTION: fn_20109 -void CRagEffect::SprayPond(TextureCache& textures) { +void CRagEffect::SprayPond() { if (this->state.stateCnt == 0) { for (int angle = 0; angle < 360; angle += 45) { this->state.unknown_11C84 = &CreateEffectParticle(*this, this->render, 15, 0.0f, 0.0f, 0.0f, WorldObjects())->state; @@ -545,7 +545,7 @@ void CRagEffect::SprayPond(TextureCache& textures) { this->state.unknown_11C84->widthSize = 5.0f; this->state.unknown_11C84->heightSize = 2.7f; AllocateTextures(*this->state.unknown_11C84); - this->state.unknown_11C84->textures[0] = textures.Load("effect\\pond_water.bmp", 0, false, true, false); + this->state.unknown_11C84->textures[0] = g_texMgr.Load("effect\\pond_water.bmp", 0, false, true, false); } } @@ -569,7 +569,7 @@ void CRagEffect::SprayPond(TextureCache& textures) { this->state.unknown_11C84->widthSize = 5.5f; this->state.unknown_11C84->heightSize = 1.0f; AllocateTextures(*this->state.unknown_11C84); - this->state.unknown_11C84->textures[0] = textures.Load("effect\\alpha_down.tga", 0, false, true, false); + this->state.unknown_11C84->textures[0] = g_texMgr.Load("effect\\alpha_down.tga", 0, false, true, false); } } @@ -589,7 +589,7 @@ void CRagEffect::SprayPond(TextureCache& textures) { this->state.unknown_11C84->fadeOutCnt = 0; Owner(this->state.unknown_11C84).InitSegment(); AllocateTextures(*this->state.unknown_11C84); - this->state.unknown_11C84->textures[0] = textures.Load("effect\\alpha_center.tga", 0, false, true, false); + this->state.unknown_11C84->textures[0] = g_texMgr.Load("effect\\alpha_center.tga", 0, false, true, false); } } @@ -630,7 +630,7 @@ void CRagEffect::WaterBall2() { // OFFSET: 0x00C3FE30 // FUNCTION: fn_20124 -void CRagEffect::Yufitel(TextureCache& textures, char F1) { +void CRagEffect::Yufitel(char F1) { if (this->state.stateCnt != 0) { return; } @@ -663,7 +663,7 @@ void CRagEffect::Yufitel(TextureCache& textures, char F1) { this->state.unknown_11C84->alpha = 170.0f; AllocateTextures(*this->state.unknown_11C84); this->state.unknown_11C84->textures[0] = - F1 != 0 ? textures.Load("effect\\twirl_soft.bmp", 0, false, true, false) : textures.Load("effect\\thunder_center.bmp", 0, false, true, false); + F1 != 0 ? g_texMgr.Load("effect\\twirl_soft.bmp", 0, false, true, false) : g_texMgr.Load("effect\\thunder_center.bmp", 0, false, true, false); this->state.unknown_11C84 = &CreateEffectParticle(*this, this->render, 15, 0.0f, 0.0f, 0.0f, WorldObjects())->state; this->state.unknown_11C84->duration = 20; this->state.unknown_11C84->pattern = 0x40u; @@ -689,25 +689,25 @@ void CRagEffect::Yufitel(TextureCache& textures, char F1) { AllocateTextures(*this->state.unknown_11C84); if (F1 != 0) { - this->state.unknown_11C84->textures[0] = textures.Load("effect\\twirl_soft.bmp", 0, false, true, false); - this->state.unknown_11C84->textures[1] = textures.Load("effect\\thunder_ball_b.bmp", 0, false, true, false); - this->state.unknown_11C84->textures[2] = textures.Load("effect\\twirl_soft.bmp", 0, false, true, false); - this->state.unknown_11C84->textures[3] = textures.Load("effect\\thunder_ball_d.bmp", 0, false, true, false); - this->state.unknown_11C84->textures[4] = textures.Load("effect\\twirl_soft.bmp", 0, false, true, false); + this->state.unknown_11C84->textures[0] = g_texMgr.Load("effect\\twirl_soft.bmp", 0, false, true, false); + this->state.unknown_11C84->textures[1] = g_texMgr.Load("effect\\thunder_ball_b.bmp", 0, false, true, false); + this->state.unknown_11C84->textures[2] = g_texMgr.Load("effect\\twirl_soft.bmp", 0, false, true, false); + this->state.unknown_11C84->textures[3] = g_texMgr.Load("effect\\thunder_ball_d.bmp", 0, false, true, false); + this->state.unknown_11C84->textures[4] = g_texMgr.Load("effect\\twirl_soft.bmp", 0, false, true, false); } else { - this->state.unknown_11C84->textures[0] = textures.Load("effect\\thunder_ball_a.bmp", 0, false, true, false); - this->state.unknown_11C84->textures[1] = textures.Load("effect\\thunder_ball_b.bmp", 0, false, true, false); - this->state.unknown_11C84->textures[2] = textures.Load("effect\\thunder_ball_c.bmp", 0, false, true, false); - this->state.unknown_11C84->textures[3] = textures.Load("effect\\thunder_ball_d.bmp", 0, false, true, false); - this->state.unknown_11C84->textures[4] = textures.Load("effect\\thunder_ball_e.bmp", 0, false, true, false); + this->state.unknown_11C84->textures[0] = g_texMgr.Load("effect\\thunder_ball_a.bmp", 0, false, true, false); + this->state.unknown_11C84->textures[1] = g_texMgr.Load("effect\\thunder_ball_b.bmp", 0, false, true, false); + this->state.unknown_11C84->textures[2] = g_texMgr.Load("effect\\thunder_ball_c.bmp", 0, false, true, false); + this->state.unknown_11C84->textures[3] = g_texMgr.Load("effect\\thunder_ball_d.bmp", 0, false, true, false); + this->state.unknown_11C84->textures[4] = g_texMgr.Load("effect\\thunder_ball_e.bmp", 0, false, true, false); } - this->state.unknown_11C84->textures[5] = textures.Load("effect\\thunder_ball_f.bmp", 0, false, true, false); + this->state.unknown_11C84->textures[5] = g_texMgr.Load("effect\\thunder_ball_f.bmp", 0, false, true, false); } // OFFSET: 0x00C40E70 // FUNCTION: fn_20132 -void CRagEffect::AirTexture(TextureCache& textures, const char* name) { +void CRagEffect::AirTexture(const char* name) { const int frame = this->state.stateCnt; const RenderObjectState& parent = this->state.parent->render; this->render.position.x = parent.position.x; @@ -722,7 +722,7 @@ void CRagEffect::AirTexture(TextureCache& textures, const char* name) { this->state.unknown_11C84->renderFlag = 5; this->state.unknown_11C84->duration = this->state.duration; AllocateTextures(*this->state.unknown_11C84); - this->state.unknown_11C84->textures[0] = textures.Load(name, 0, false, true, false); + this->state.unknown_11C84->textures[0] = g_texMgr.Load(name, 0, false, true, false); this->state.unknown_11C84->size = 0.0f; this->state.unknown_11C84->slots[0].life = 1; this->state.unknown_11C84->slots[0].process = 0; @@ -1019,7 +1019,7 @@ bool CRagEffect::Aspersio() { // OFFSET: 0x00C0C550 // FUNCTION: fn_20019 -void CRagEffect::Blessing(TextureCache& textures) { +void CRagEffect::Blessing() { const EffectActor& parent = *this->state.parent; this->render.position.x = parent.render.position.x; this->render.position.y = parent.render.position.y; @@ -1043,7 +1043,7 @@ void CRagEffect::Blessing(TextureCache& textures) { ring.fadeOutCnt = ring.duration - 30; Owner(&ring).InitSegment(); AllocateTextures(ring); - ring.textures[0] = textures.Load("effect\\alpha_down.tga", 0, false, true, false); + ring.textures[0] = g_texMgr.Load("effect\\alpha_down.tga", 0, false, true, false); } if (this->state.stateCnt % 3 == 0 && this->state.stateCnt < 10) { @@ -1085,7 +1085,7 @@ void CRagEffect::Blessing(TextureCache& textures) { } // INLINED -static __forceinline void SpawnBottomQuad(CRagEffect& effect, TextureCache& textures, const vector3d& velocity, int angle) { +static __forceinline void SpawnBottomQuad(CRagEffect& effect, const vector3d& velocity, int angle) { effect.state.unknown_11C84 = &CreateEffectParticle(effect, effect.render, 15, 0.0f, 0.0f, 0.0f, WorldObjects())->state; EffectPrimitiveState& quad = *effect.state.unknown_11C84; quad.duration = 9999; @@ -1102,12 +1102,12 @@ static __forceinline void SpawnBottomQuad(CRagEffect& effect, TextureCache& text quad.alphaSpeed = quad.maxAlpha / 6.0f; quad.fadeOutCnt = quad.duration - 35; AllocateTextures(quad); - quad.textures[0] = textures.Load("effect\\magic_violet.tga", 0, false, true, false); + quad.textures[0] = g_texMgr.Load("effect\\magic_violet.tga", 0, false, true, false); } // OFFSET: 0x00C0DA60 // FUNCTION: fn_20023 -void CRagEffect::Bottom(TextureCache& textures) { +void CRagEffect::Bottom() { if (this->state.stateCnt != 0) { return; } @@ -1126,11 +1126,11 @@ void CRagEffect::Bottom(TextureCache& textures) { for (int side = 1; side > -2; side -= 2) { const float distance = static_cast(side) * 5.0f; SpawnBottomQuad( - *this, textures, {m[3] * 0.0f + m[0] * 0.0f + distance * m[6] + m[9], m[4] * 0.0f + m[1] * 0.0f + distance * m[7] + m[10], m[5] * 0.0f + m[2] * 0.0f + distance * m[8] + m[11]}, + *this, {m[3] * 0.0f + m[0] * 0.0f + distance * m[6] + m[9], m[4] * 0.0f + m[1] * 0.0f + distance * m[7] + m[10], m[5] * 0.0f + m[2] * 0.0f + distance * m[8] + m[11]}, angle + 90 ); SpawnBottomQuad( - *this, textures, {distance * m[0] + m[3] * 0.0f + m[6] * 0.0f + m[9], distance * m[1] + m[4] * 0.0f + m[7] * 0.0f + m[10], distance * m[2] + m[5] * 0.0f + m[8] * 0.0f + m[11]}, + *this, {distance * m[0] + m[3] * 0.0f + m[6] * 0.0f + m[9], distance * m[1] + m[4] * 0.0f + m[7] * 0.0f + m[10], distance * m[2] + m[5] * 0.0f + m[8] * 0.0f + m[11]}, angle ); } @@ -1202,7 +1202,7 @@ void CRagEffect::Fireworks() { // OFFSET: 0x00C410A0 // FUNCTION: fn_20133 -void CRagEffect::AttackEnergy2(TextureCache& textures, const char* name) { +void CRagEffect::AttackEnergy2(const char* name) { const EffectActor& parent = *this->state.parent; this->render.position.x = parent.render.position.x; this->render.position.y = parent.render.position.y; @@ -1218,7 +1218,7 @@ void CRagEffect::AttackEnergy2(TextureCache& textures, const char* name) { prim.duration = this->state.duration; prim.totalTexture = 1; AllocateTextures(prim); - prim.textures[0] = textures.Load(name, 0, false, true, false); + prim.textures[0] = g_texMgr.Load(name, 0, false, true, false); prim.size = 4.0f; for (EffectPrimitiveSlot& slot : prim.slots) { @@ -1344,7 +1344,7 @@ void CRagEffect::Sphere() { // OFFSET: 0x00C17220 // FUNCTION: fn_20059 -void CRagEffect::GrimToothAtk(TextureCache& textures) { +void CRagEffect::GrimToothAtk() { if (this->state.stateCnt != 0) { return; } @@ -1381,7 +1381,7 @@ void CRagEffect::GrimToothAtk(TextureCache& textures) { this->state.unknown_11C84->chCnt = 10; this->state.unknown_11C84->fadeOutCnt = this->state.unknown_11C84->duration - 10; AllocateTextures(*this->state.unknown_11C84); - CTexture* texture = textures.Load("effect\\stone.bmp", 0, false, true, false); + CTexture* texture = g_texMgr.Load("effect\\stone.bmp", 0, false, true, false); this->state.deltaPos3[0] = this->state.deltaPos3[0] - this->state.deltaPos2[0]; this->state.unknown_11C84->textures[0] = texture; this->state.deltaPos3[1] = this->state.deltaPos3[1] - this->state.deltaPos2[1]; @@ -1441,7 +1441,7 @@ void CRagEffect::Snow() { // OFFSET: 0x00C12B90 // FUNCTION: fn_20042 -void CRagEffect::Entry(TextureCache& textures) { +void CRagEffect::Entry() { if (this->state.stateCnt != 0) { return; } @@ -1465,7 +1465,7 @@ void CRagEffect::Entry(TextureCache& textures) { int duration = this->state.unknown_11C84->duration; this->state.unknown_11C84->fadeOutCnt = duration - duration / 5; AllocateTextures(*this->state.unknown_11C84); - this->state.unknown_11C84->textures[0] = textures.Load("effect\\ring_blue.tga", 0, false, true, false); + this->state.unknown_11C84->textures[0] = g_texMgr.Load("effect\\ring_blue.tga", 0, false, true, false); if (this->state.stateCnt == 0) { this->state.unknown_11C84 = &CreateEffectParticle(*this, this->render, 13, 0.0f, 0.0f, 0.0f, WorldObjects())->state; @@ -1482,13 +1482,13 @@ void CRagEffect::Entry(TextureCache& textures) { duration = this->state.unknown_11C84->duration; this->state.unknown_11C84->fadeOutCnt = duration - duration / 3; AllocateTextures(*this->state.unknown_11C84); - this->state.unknown_11C84->textures[0] = textures.Load("effect\\ring_blue.tga", 0, false, true, false); + this->state.unknown_11C84->textures[0] = g_texMgr.Load("effect\\ring_blue.tga", 0, false, true, false); } } // OFFSET: 0x00C0E280 // FUNCTION: fn_20025 -bool CRagEffect::CartRevolution(TextureCache& textures) { +bool CRagEffect::CartRevolution() { if (this->state.stateCnt == 7 || this->state.stateCnt == 20) { PlayEffectWave(*this, "effect\\EF_MagnumBreak.wav"); this->state.unknown_11C84 = &CreateEffectParticle(*this, this->render, 12, 0.0f, 0.0f, 0.0f, WorldObjects())->state; @@ -1505,7 +1505,7 @@ bool CRagEffect::CartRevolution(TextureCache& textures) { this->state.unknown_11C84->fadeOutCnt = this->state.unknown_11C84->duration - 15; Owner(this->state.unknown_11C84).InitSegment(); AllocateTextures(*this->state.unknown_11C84); - this->state.unknown_11C84->textures[0] = textures.Load("effect\\ring_yellow.tga", 0, false, true, false); + this->state.unknown_11C84->textures[0] = g_texMgr.Load("effect\\ring_yellow.tga", 0, false, true, false); this->state.unknown_11C84 = &CreateEffectParticle(*this, this->render, 14, 0.0f, 0.0f, 0.0f, WorldObjects())->state; this->state.unknown_11C84->duration = 20; @@ -1518,7 +1518,7 @@ bool CRagEffect::CartRevolution(TextureCache& textures) { this->state.unknown_11C84->alphaSpeed = this->state.unknown_11C84->maxAlpha / 7.0f; this->state.unknown_11C84->fadeOutCnt = this->state.unknown_11C84->duration - 15; AllocateTextures(*this->state.unknown_11C84); - this->state.unknown_11C84->textures[0] = textures.Load("effect\\대폭발.tga", 0, false, true, false); + this->state.unknown_11C84->textures[0] = g_texMgr.Load("effect\\대폭발.tga", 0, false, true, false); } if (this->state.stateCnt < 300) { @@ -1531,7 +1531,7 @@ bool CRagEffect::CartRevolution(TextureCache& textures) { // OFFSET: 0x00C0DEF0 // FUNCTION: fn_20024 -void CRagEffect::BowlingBash(TextureCache& textures) { +void CRagEffect::BowlingBash() { if (this->state.stateCnt != 0 && this->state.stateCnt != 5) { return; } @@ -1556,7 +1556,7 @@ void CRagEffect::BowlingBash(TextureCache& textures) { const int duration = this->state.unknown_11C84->duration; this->state.unknown_11C84->fadeOutCnt = duration - duration / 2; AllocateTextures(*this->state.unknown_11C84); - this->state.unknown_11C84->textures[0] = textures.Load("effect\\ring_blue.tga", 0, false, true, false); + this->state.unknown_11C84->textures[0] = g_texMgr.Load("effect\\ring_blue.tga", 0, false, true, false); if (this->state.stateCnt == 0) { this->state.unknown_11C84 = &CreateEffectParticle(*this, this->render, 12, 0.0f, 0.0f, 0.0f, WorldObjects())->state; @@ -1574,13 +1574,13 @@ void CRagEffect::BowlingBash(TextureCache& textures) { this->state.unknown_11C84->fadeOutCnt = 35; Owner(this->state.unknown_11C84).InitSegment(); AllocateTextures(*this->state.unknown_11C84); - this->state.unknown_11C84->textures[0] = textures.Load("effect\\ring_yellow.tga", 0, false, true, false); + this->state.unknown_11C84->textures[0] = g_texMgr.Load("effect\\ring_yellow.tga", 0, false, true, false); } } // OFFSET: 0x00C3AF00 // FUNCTION: fn_20105 -void CRagEffect::SonicBlowHit(TextureCache& textures) { +void CRagEffect::SonicBlowHit() { if (this->state.stateCnt != 0) { return; } @@ -1625,5 +1625,5 @@ void CRagEffect::SonicBlowHit(TextureCache& textures) { const int duration = this->state.unknown_11C84->duration; this->state.unknown_11C84->fadeOutCnt = duration - duration / 2; AllocateTextures(*this->state.unknown_11C84); - this->state.unknown_11C84->textures[0] = textures.Load("effect\\magic_red.tga", 0, false, true, false); + this->state.unknown_11C84->textures[0] = g_texMgr.Load("effect\\magic_red.tga", 0, false, true, false); } diff --git a/Source/Contents/Effects/RagEffect.h b/Source/Contents/Effects/RagEffect.h index 8ccc6cad..30d8a132 100644 --- a/Source/Contents/Effects/RagEffect.h +++ b/Source/Contents/Effects/RagEffect.h @@ -27,30 +27,30 @@ struct CRagEffect : CRenderObject { bool ProcessEZ2STRC15990(); bool ProcessEZ2STRC159D0(); bool ShieldCharge(); - void GrimToothAtk(TextureCache& textures); + void GrimToothAtk(); void Snow(); - void Entry(TextureCache& textures); - bool CartRevolution(TextureCache& textures); - void BowlingBash(TextureCache& textures); - void SonicBlowHit(TextureCache& textures); - void AttackEnergy2(TextureCache& textures, const char* name); + void Entry(); + bool CartRevolution(); + void BowlingBash(); + void SonicBlowHit(); + void AttackEnergy2(const char* name); bool LexDivina(); void RemoveTrap(); void Sphere(); bool Aspersio(); - void Blessing(TextureCache& textures); - void Bottom(TextureCache& textures); + void Blessing(); + void Bottom(); void BloodDrain(); void FireBall(); - void FrostDiver(TextureCache& textures, char type); - void GrimTooth(TextureCache& textures); - void Hit4(const RenderProjection& projection, TextureCache& textures); + void FrostDiver(char type); + void GrimTooth(); + void Hit4(const RenderProjection& projection); void SoulStrike(char F1); void SpearBmr(); - void SprayPond(TextureCache& textures); + void SprayPond(); void WaterBall2(); - void Yufitel(TextureCache& textures, char F1); - void AirTexture(TextureCache& textures, const char* name); + void Yufitel(char F1); + void AirTexture(const char* name); void EnergyDrain2(); virtual void Slot08(); diff --git a/Source/Contents/Ground/GroundDecals.cpp b/Source/Contents/Ground/GroundDecals.cpp index d9c4f11b..9173e2f6 100644 --- a/Source/Contents/Ground/GroundDecals.cpp +++ b/Source/Contents/Ground/GroundDecals.cpp @@ -105,9 +105,9 @@ void GroundGeometry::DrawGridDecal( // OFFSET: 0x00AC16D0 // FUNCTION: fn_17587 void GroundGeometry::DrawGrid( - const C3dAttr& terrain, const float* matrix, int column, int row, std::uint32_t color, TextureCache& textures, GroundRenderContext& context + const C3dAttr& terrain, const float* matrix, int column, int row, std::uint32_t color, GroundRenderContext& context ) const { - CTexture* texture = textures.Load("grid.tga", 0, false, true, false); + CTexture* texture = g_texMgr.Load("grid.tga", 0, false, true, false); // STATIC: 0x01347EB0 constexpr float uv[8] = {0, 0, 1, 0, 0, 1, 1, 1}; this->DrawGridDecal(terrain, matrix, column, row, color, *texture, uv, context); diff --git a/Source/Contents/Ground/GroundGeometry.cpp b/Source/Contents/Ground/GroundGeometry.cpp index 9078f15c..8fdb11b3 100644 --- a/Source/Contents/Ground/GroundGeometry.cpp +++ b/Source/Contents/Ground/GroundGeometry.cpp @@ -100,12 +100,12 @@ GroundSpatial GroundGeometry::Spatial() const { // OFFSET: 0x00ABDEF0 // FUNCTION: fn_17556 -void GroundGeometry::Build(CGndRes& resource, TextureCache& textures, const float* lightDirection, const float* diffuse, const float* ambient) { +void GroundGeometry::Build(CGndRes& resource, const float* lightDirection, const float* diffuse, const float* ambient) { this->loaded = resource.loaded; this->Reset(resource.width, resource.height); std::vector normals(this->cells.size()); this->cellSize = resource.cellSize; - this->BuildLightmaps(resource, textures); + this->BuildLightmaps(resource); this->tiles.resize(static_cast(resource.tileCount)); for (int row = 0; row < this->height; ++row) { @@ -141,7 +141,7 @@ void GroundGeometry::Build(CGndRes& resource, TextureCache& textures, const floa std::uint16_t lightmapIndex; std::memcpy(&textureIndex, tileBytes + 32, sizeof(textureIndex)); std::memcpy(&lightmapIndex, tileBytes + 34, sizeof(lightmapIndex)); - tile.texture = textures.Load(resource.textureNames[textureIndex], 0, false, true, false); + tile.texture = g_texMgr.Load(resource.textureNames[textureIndex], 0, false, true, false); float positions[4][3]; if (face == 0) { diff --git a/Source/Contents/Ground/GroundGeometry.h b/Source/Contents/Ground/GroundGeometry.h index a3985587..4a651a13 100644 --- a/Source/Contents/Ground/GroundGeometry.h +++ b/Source/Contents/Ground/GroundGeometry.h @@ -24,7 +24,7 @@ public: ~GroundGeometry(); GroundGeometry(const GroundGeometry&) = delete; GroundGeometry& operator=(const GroundGeometry&) = delete; - void Build(CGndRes& resource, TextureCache& textures, const float* lightDirection, const float* diffuse, const float* ambient); + void Build(CGndRes& resource, const float* lightDirection, const float* diffuse, const float* ambient); void ClearGeometry(); void Reset(int columns, int rows); GroundSpatial Spatial() const; @@ -43,7 +43,7 @@ public: GroundRenderContext& context ) const; void DrawGrid( - const class C3dAttr& terrain, const float* matrix, int column, int row, std::uint32_t color, TextureCache& textures, GroundRenderContext& context + const class C3dAttr& terrain, const float* matrix, int column, int row, std::uint32_t color, GroundRenderContext& context ) const; void DrawTerrainOverlay( const class C3dAttr& terrain, const float* matrix, int column, int row, std::uint32_t color, CTexture* texture, GroundRenderContext& context @@ -73,7 +73,7 @@ public: GroundWaterState water; private: - void BuildLightmaps(CGndRes& resource, TextureCache& textures); + void BuildLightmaps(CGndRes& resource); void ClearLightmaps(); }; diff --git a/Source/Contents/Ground/GroundLightmaps.cpp b/Source/Contents/Ground/GroundLightmaps.cpp index 63f4b793..fddf806a 100644 --- a/Source/Contents/Ground/GroundLightmaps.cpp +++ b/Source/Contents/Ground/GroundLightmaps.cpp @@ -19,7 +19,7 @@ void GroundGeometry::ClearLightmaps() { // OFFSET: 0x00AC0360 // FUNCTION: fn_17565 -void GroundGeometry::BuildLightmaps(CGndRes& resource, TextureCache& textures) { +void GroundGeometry::BuildLightmaps(CGndRes& resource) { this->ClearLightmaps(); this->lightmaps.resize(static_cast(resource.lightmapCount)); const unsigned atlasCount = (static_cast(resource.lightmapCount) + 1023u) / 1024u; @@ -68,7 +68,7 @@ void GroundGeometry::BuildLightmaps(CGndRes& resource, TextureCache& textures) { } } - this->lightmapTextures.push_back(textures.Upload(256, 256, pixels.data(), 4, 0, false, false, false)); + this->lightmapTextures.push_back(g_texMgr.Upload(256, 256, pixels.data(), 4, 0, false, false, false)); } for (unsigned index = 0; index < this->lightmaps.size(); ++index) { diff --git a/Source/Contents/Ground/GroundWaterState.cpp b/Source/Contents/Ground/GroundWaterState.cpp index bc0a58ce..96147f3c 100644 --- a/Source/Contents/Ground/GroundWaterState.cpp +++ b/Source/Contents/Ground/GroundWaterState.cpp @@ -23,7 +23,7 @@ void GroundWaterState::Set(float newLevel, int newType, int newAnimation, int ne // OFFSET: 0x00AC30D0 // FUNCTION: fn_17599 -bool GroundWaterState::Import(const CGndRes& resource, TextureCache& textures) { +bool GroundWaterState::Import(const CGndRes& resource) { if (resource.major == 1 && resource.minor >= 8) { this->columns = resource.waterWidth; this->rows = resource.waterHeight; @@ -48,7 +48,7 @@ bool GroundWaterState::Import(const CGndRes& resource, TextureCache& textures) { this->levels.push_back(this->level); } - this->Update(textures); + this->Update(); this->partitioned = this->levels.size() > 1; return this->partitioned; } @@ -67,7 +67,7 @@ float GroundWaterState::Level(int width, int height, int column, int row) const // OFFSET: 0x00AC1430 // FUNCTION: fn_17581 -void GroundWaterState::Update(TextureCache& textures) { +void GroundWaterState::Update() { // STATIC: 0x01159248 constexpr char format[] = "워터\\water%d%02d.jpg"; char name[32]{}; @@ -82,7 +82,7 @@ void GroundWaterState::Update(TextureCache& textures) { const int image = (surface.frame / surface.animation) % 32; _snprintf_s(name, sizeof(name), _TRUNCATE, format, surface.type, image); - surface.texture = textures.Load(name, 0, false, true, false); + surface.texture = g_texMgr.Load(name, 0, false, true, false); const float phase = surface.speed + surface.phase; surface.phase = phase; diff --git a/Source/Contents/Ground/GroundWaterState.h b/Source/Contents/Ground/GroundWaterState.h index a14f98c9..34b1a97c 100644 --- a/Source/Contents/Ground/GroundWaterState.h +++ b/Source/Contents/Ground/GroundWaterState.h @@ -23,8 +23,8 @@ struct GroundWaterSurface { struct GroundWaterState { GroundWaterState(); void Set(float level, int type, int animation, int pitch, int phase, float height); - bool Import(const CGndRes& resource, TextureCache& textures); - void Update(TextureCache& textures); + bool Import(const CGndRes& resource); + void Update(); float Level(int width, int height, int column, int row) const; float level; diff --git a/Source/Contents/Movies/BinkMovies.cpp b/Source/Contents/Movies/BinkMovies.cpp index 906ae51e..66a13041 100644 --- a/Source/Contents/Movies/BinkMovies.cpp +++ b/Source/Contents/Movies/BinkMovies.cpp @@ -57,14 +57,14 @@ void BinkMovies::AddPosition(NamedBinkMovie& movie, float x, float y, float z) { // OFFSET: 0x007B04F0 // FUNCTION: fn_09166 -void BinkMovies::Update(TextureCache& textures, const float* playerPosition, int volume) { +void BinkMovies::Update(const float* playerPosition, int volume) { for (const auto& movie : this->m_movies) { if (!movie || !movie->decoder || movie->name.empty()) { continue; } if (movie->decoder->Update()) { - CTexture* texture = textures.Load(movie->name.c_str(), 0, false, true, false); + CTexture* texture = g_texMgr.Load(movie->name.c_str(), 0, false, true, false); if (texture) { movie->decoder->CopyTo(texture); diff --git a/Source/Contents/Movies/BinkMovies.h b/Source/Contents/Movies/BinkMovies.h index fe83ebe6..2dd47f74 100644 --- a/Source/Contents/Movies/BinkMovies.h +++ b/Source/Contents/Movies/BinkMovies.h @@ -31,7 +31,7 @@ public: ~BinkMovies(); NamedBinkMovie* Get(std::string name, int loop); void AddPosition(NamedBinkMovie& movie, float x, float y, float z); - void Update(TextureCache& textures, const float* playerPosition, int volume); + void Update(const float* playerPosition, int volume); private: /* 0000 */ std::list> m_movies; diff --git a/Source/Contents/World/WorldGroundImport.h b/Source/Contents/World/WorldGroundImport.h index 1bb82b06..fbfa9c83 100644 --- a/Source/Contents/World/WorldGroundImport.h +++ b/Source/Contents/World/WorldGroundImport.h @@ -11,7 +11,7 @@ // INLINED inline bool ImportWorldGround( - const C3dWorldRes& world, ResourceMgr& resources, TextureCache& textures, CRenderSystemBase* renderSystem, C3dAttr*& terrain, GroundGeometry*& ground, + const C3dWorldRes& world, ResourceMgr& resources, CRenderSystemBase* renderSystem, C3dAttr*& terrain, GroundGeometry*& ground, int& nearbyRange, const float* lightDirection, const float* diffuse, const float* ambient ) { if (world.terrainName.empty()) { @@ -47,11 +47,11 @@ inline bool ImportWorldGround( } ground = new GroundGeometry; - ground->Build(*resource, textures, lightDirection, diffuse, ambient); + ground->Build(*resource, lightDirection, diffuse, ambient); const int pitch = TruncateToInt(world.waveSpeed); const int phase = TruncateToInt(world.wavePitch); ground->water.Set(world.waterLevel, world.waterType, world.waterAnimation, pitch, phase, world.waveHeight); - ground->water.Import(*resource, textures); + ground->water.Import(*resource); resources.Remove(resource); return true; diff --git a/Source/Render/AlphaRectangle.cpp b/Source/Render/AlphaRectangle.cpp index fb4563fd..58e1b118 100644 --- a/Source/Render/AlphaRectangle.cpp +++ b/Source/Render/AlphaRectangle.cpp @@ -6,7 +6,7 @@ // OFFSET: 0x0054E460 // FUNCTION: fn_01952 void DrawAlphaRectangle( - RenderPrimitivePool& primitives, TextureCache& textures, RenderQueues& queues, int x, int y, int width, int height, std::uint32_t color, bool depthAlpha, + RenderPrimitivePool& primitives, RenderQueues& queues, int x, int y, int width, int height, std::uint32_t color, bool depthAlpha, float depthStart, float depthEnd ) { if ((color & 0xFF000000u) == 0) { @@ -14,7 +14,7 @@ void DrawAlphaRectangle( } RenderPrimitive* primitive = primitives.Acquire(); - primitive->texture = textures.Default(); + primitive->texture = g_texMgr.Default(); const float left = static_cast(x); const float top = static_cast(y); const float right = static_cast(x + width); diff --git a/Source/Render/DX9/RenderSystemDX9.cpp b/Source/Render/DX9/RenderSystemDX9.cpp index f02bf9f8..f9ff80ed 100644 --- a/Source/Render/DX9/RenderSystemDX9.cpp +++ b/Source/Render/DX9/RenderSystemDX9.cpp @@ -7,7 +7,7 @@ // FUNCTION: fn_02353 CRenderSystemDX9::CRenderSystemDX9(RenderSystemDX9Context& context) : m_device(new DeviceOwnerDX9), m_defaultTexture(nullptr), m_context(&context), - m_rendererContext{*this, context.d3dx, context.textures, context.sources, context.retirement, context.options, context.multitexture, + m_rendererContext{*this, context.d3dx, context.retirement, context.options, context.multitexture, context.fog, context.worldFlag, context.overlayColor, context.diagnostic}, m_textureContext{}, m_surfaceContext{} { this->RefreshContexts(); diff --git a/Source/Render/DX9/RenderSystemDX9.h b/Source/Render/DX9/RenderSystemDX9.h index d4800f6e..81a72f2d 100644 --- a/Source/Render/DX9/RenderSystemDX9.h +++ b/Source/Render/DX9/RenderSystemDX9.h @@ -11,8 +11,6 @@ struct RenderSystemDX9Context { const AdapterConfiguration& adapter; const bool& serviceUsesDX7; D3DX9Runtime& d3dx; - TextureCache& textures; - TextureSources& sources; EffectRetirement& retirement; const ServiceOptions& options; const unsigned char& multitexture; diff --git a/Source/Render/DX9/RendererDX9.cpp b/Source/Render/DX9/RendererDX9.cpp index 782154c7..bdd7fd24 100644 --- a/Source/Render/DX9/RendererDX9.cpp +++ b/Source/Render/DX9/RendererDX9.cpp @@ -3,6 +3,7 @@ #include "Render/DX9/RendererFrameDX9.h" #include "Render/Textures/TextureCache.h" #include "Resource/Bitmap/BitmapResource.h" +#include "Resource/TextureNames.h" #include @@ -119,7 +120,7 @@ bool CRendererDX9::SaveBitmapResource(const char* filename, int format, CBitmapR if (bitmap) { const auto& image = bitmap->image; - overlay.reset(this->m_context->textures.Upload(image.width, image.height, image.pixels, image.alpha != 0, 0, false, false, false)); + overlay.reset(g_texMgr.Upload(image.width, image.height, image.pixels, image.alpha != 0, 0, false, false, false)); } auto& context = this->TextureContext(); @@ -146,8 +147,8 @@ void CRendererDX9::CleanupTextures() { // OFFSET: 0x005682D0 // FUNCTION: fn_02237 bool CRendererDX9::SaveLogo(std::string filename) { - const char* name = this->m_context->sources.Resolve("scr_logo.bmp"); - CTexture* overlay = this->m_context->textures.Load(name, 0, false, true, false); + const char* name = Resolve("scr_logo.bmp"); + CTexture* overlay = g_texMgr.Load(name, 0, false, true, false); auto& context = this->TextureContext(); return this->Operations(context).SaveScreenshot(*this->device, &this->m_context->system, filename.c_str(), 1, overlay, nullptr); diff --git a/Source/Render/DX9/RendererDX9.h b/Source/Render/DX9/RendererDX9.h index c4ea54b0..f9e9dc67 100644 --- a/Source/Render/DX9/RendererDX9.h +++ b/Source/Render/DX9/RendererDX9.h @@ -8,16 +8,12 @@ class DeviceOwnerDX9; class D3DX9Runtime; -class TextureCache; -class TextureSources; struct EffectRetirement; struct ServiceOptions; struct RendererDX9Context { CRenderSystemBase& system; D3DX9Runtime& d3dx; - TextureCache& textures; - TextureSources& sources; EffectRetirement& retirement; const ServiceOptions& options; const unsigned char& multitexture; diff --git a/Source/Render/Primitives/AlphaRectangle.h b/Source/Render/Primitives/AlphaRectangle.h index c1308100..9e6e8671 100644 --- a/Source/Render/Primitives/AlphaRectangle.h +++ b/Source/Render/Primitives/AlphaRectangle.h @@ -8,7 +8,7 @@ class TextureCache; struct RenderQueues; void DrawAlphaRectangle( - RenderPrimitivePool& primitives, TextureCache& textures, RenderQueues& queues, int x, int y, int width, int height, std::uint32_t color, bool depthAlpha, + RenderPrimitivePool& primitives, RenderQueues& queues, int x, int y, int width, int height, std::uint32_t color, bool depthAlpha, float depthStart, float depthEnd ); diff --git a/Source/Render/Primitives/UIRPData.h b/Source/Render/Primitives/UIRPData.h index e4c60d60..a4a6a0c3 100644 --- a/Source/Render/Primitives/UIRPData.h +++ b/Source/Render/Primitives/UIRPData.h @@ -16,7 +16,7 @@ public: virtual ~UIRPData(); void Draw(RenderPrimitivePool& pool, int x, int y, CTexture* texture, std::uint32_t color, int width, int height, bool stretched); void DrawStretched(RenderPrimitivePool& pool, int x, int y, CTexture* texture, std::uint32_t color, int width, int height); - void DrawNamed(RenderPrimitivePool& pool, TextureCache& textures, int x, int y, std::string name, std::uint32_t color, int width, int height); + void DrawNamed(RenderPrimitivePool& pool, int x, int y, std::string name, std::uint32_t color, int width, int height); void SetSolid(RenderPrimitivePool& pool, int width, int height, std::uint32_t color); protected: diff --git a/Source/Render/ScreenRectangle.cpp b/Source/Render/ScreenRectangle.cpp index 47ed072b..2ba0a296 100644 --- a/Source/Render/ScreenRectangle.cpp +++ b/Source/Render/ScreenRectangle.cpp @@ -7,7 +7,7 @@ // OFFSET: 0x0054E590 // FUNCTION: fn_01953 void DrawBlendedRectangle( - RenderPrimitivePool& primitives, TextureCache& textures, RenderQueues& queues, int x, int y, int width, int height, std::uint32_t color, bool depthAlpha, + RenderPrimitivePool& primitives, RenderQueues& queues, int x, int y, int width, int height, std::uint32_t color, bool depthAlpha, float depthStart, float depthEnd ) { if ((color & 0xFF000000u) == 0) { @@ -15,7 +15,7 @@ void DrawBlendedRectangle( } RenderPrimitive* primitive = primitives.Acquire(); - primitive->texture = textures.Default(); + primitive->texture = g_texMgr.Default(); const float left = static_cast(x); const float top = static_cast(y); const float right = static_cast(x + width); @@ -43,7 +43,7 @@ void DrawBlendedRectangle( // OFFSET: 0x0054ED40 // FUNCTION: fn_01954 void DrawTexturedRectangle( - RenderPrimitivePool& primitives, TextureCache& textures, RenderQueues& queues, int x, int y, int width, int height, std::uint32_t color, CTexture* texture, + RenderPrimitivePool& primitives, RenderQueues& queues, int x, int y, int width, int height, std::uint32_t color, CTexture* texture, bool depthAlpha, float depthStart, float depthEnd ) { if ((color & 0xFF000000u) == 0) { @@ -51,7 +51,7 @@ void DrawTexturedRectangle( } RenderPrimitive* primitive = primitives.Acquire(); - primitive->texture = texture ? texture : textures.Default(); + primitive->texture = texture ? texture : g_texMgr.Default(); const float left = static_cast(x); const float top = static_cast(y); const float right = static_cast(x + width); @@ -83,7 +83,7 @@ void DrawTexturedRectangle( // OFFSET: 0x0054EFD0 // FUNCTION: fn_01955 void DrawTextureRegion( - RenderPrimitivePool& primitives, TextureCache& textures, RenderQueues& queues, float x, float y, float width, float height, std::uint32_t color, + RenderPrimitivePool& primitives, RenderQueues& queues, float x, float y, float width, float height, std::uint32_t color, CTexture* texture, bool depthAlpha, float depthStart, float depthEnd ) { if ((color & 0xFF000000u) == 0) { @@ -91,7 +91,7 @@ void DrawTextureRegion( } RenderPrimitive* primitive = primitives.Acquire(); - primitive->texture = texture ? texture : textures.Default(); + primitive->texture = texture ? texture : g_texMgr.Default(); primitive->quad[0].x = x; primitive->quad[0].y = y; primitive->quad[0].u = g_textureOffsetX / static_cast(texture->TextureWidth()); diff --git a/Source/Render/ScreenRectangle.h b/Source/Render/ScreenRectangle.h index 22ce45d9..ff656593 100644 --- a/Source/Render/ScreenRectangle.h +++ b/Source/Render/ScreenRectangle.h @@ -9,15 +9,15 @@ class TextureCache; struct RenderQueues; void DrawBlendedRectangle( - RenderPrimitivePool& primitives, TextureCache& textures, RenderQueues& queues, int x, int y, int width, int height, std::uint32_t color, bool depthAlpha, + RenderPrimitivePool& primitives, RenderQueues& queues, int x, int y, int width, int height, std::uint32_t color, bool depthAlpha, float depthStart, float depthEnd ); void DrawTexturedRectangle( - RenderPrimitivePool& primitives, TextureCache& textures, RenderQueues& queues, int x, int y, int width, int height, std::uint32_t color, CTexture* texture, + RenderPrimitivePool& primitives, RenderQueues& queues, int x, int y, int width, int height, std::uint32_t color, CTexture* texture, bool depthAlpha, float depthStart, float depthEnd ); void DrawTextureRegion( - RenderPrimitivePool& primitives, TextureCache& textures, RenderQueues& queues, float x, float y, float width, float height, std::uint32_t color, + RenderPrimitivePool& primitives, RenderQueues& queues, float x, float y, float width, float height, std::uint32_t color, CTexture* texture, bool depthAlpha, float depthStart, float depthEnd ); diff --git a/Source/Render/Textures/ClientTextureSources.h b/Source/Render/Textures/ClientTextureSources.h index b3c3c3db..3032f830 100644 --- a/Source/Render/Textures/ClientTextureSources.h +++ b/Source/Render/Textures/ClientTextureSources.h @@ -10,12 +10,12 @@ class BinkMovies; -class ClientTextureSources : public TextureSources { +class ClientTextureSources { public: ClientTextureSources(const int& modeType, BinkMovies* const& movies, CRenderSystemBase*& system, IDirectDraw7* const& directDraw); - const char* Resolve(const char* name) override; - bool MovieSize(const char* name, int& width, int& height) override; - void CleanupTextures() override; + const char* Resolve(const char* name); + bool MovieSize(const char* name, int& width, int& height); + void CleanupTextures(); private: const int& m_modeType; diff --git a/Source/Render/Textures/TextureCache.cpp b/Source/Render/Textures/TextureCache.cpp index 50807909..02291681 100644 --- a/Source/Render/Textures/TextureCache.cpp +++ b/Source/Render/Textures/TextureCache.cpp @@ -1,14 +1,26 @@ +#include "Client/Mode/CGameMode.h" +#include "Client/Mode/ModeMgr.h" +#include "Contents/Movies/BinkMovies.h" +#include "Contents/World/World.h" #include "Render/DeviceContext/DCSurface.h" #include "Render/RenderSystemBase.h" #include "Render/Textures/Texture.h" #include "Render/Textures/TextureCache.h" #include "Resource/Bitmap/BitmapResource.h" #include "Resource/ResourceMgr.h" +#include "Resource/TextureNames.h" #include +#include #include #include +// GLOBAL: gl_24639 +int g_textureReduction = 1; + +// GLOBAL: gl_24638 +TextureCache g_texMgr; + // INLINED bool TextureNameLess::operator()(const char* left, const char* right) const { return std::strcmp(left, right) < 0; @@ -16,8 +28,7 @@ bool TextureNameLess::operator()(const char* left, const char* right) const { // OFFSET: 0x004074F5 // FUNCTION: fn_00152 -TextureCache::TextureCache(ResourceMgr& resources, CRenderSystemBase*& system, TextureSources& sources, const int& reduction, const unsigned& reuseDelay) - : m_resources(resources), m_system(system), m_sources(sources), m_reduction(reduction), m_reuseDelay(reuseDelay) { +TextureCache::TextureCache() { } // OFFSET: 0x005713C0 @@ -29,15 +40,15 @@ TextureCache::~TextureCache() { // OFFSET: 0x00571790 // FUNCTION: fn_02453 CTexture* TextureCache::Default() { - return this->m_system ? this->m_system->BackBufferTexture() : nullptr; + return GetRenderSystemHolder()->BackBufferTexture(); } // OFFSET: 0x005715E0 // FUNCTION: fn_02449 CTexture* TextureCache::Upload(int width, int height, const std::uint32_t* pixels, int format, int option, bool fullSize, bool dynamic, bool renderTarget) { - const int outputWidth = fullSize ? width : width / this->m_reduction; - const int outputHeight = fullSize ? height : height / this->m_reduction; - CTexture* texture = this->m_system ? this->m_system->CreateTexture(outputWidth, outputHeight, format, dynamic, renderTarget) : nullptr; + const int outputWidth = fullSize ? width : width / g_textureReduction; + const int outputHeight = fullSize ? height : height / g_textureReduction; + CTexture* texture = GetRenderSystemHolder()->CreateTexture(outputWidth, outputHeight, format, dynamic, renderTarget); if (texture) { texture->Upload(0, 0, width, height, pixels, option, 0); @@ -57,32 +68,38 @@ CTexture* CreateTexture(std::uint32_t width, std::uint32_t height, std::int32_t // FUNCTION: fn_02455 CTexture* TextureCache::Create(const char* name, int option, bool fullSize, bool dynamic, bool renderTarget) { if (std::strstr(name, ".bik")) { - int width; - int height; + if (g_modeMgr.GetGameMode() && static_cast(g_modeMgr.GetGameMode())->scene) { + BinkMovies* movies = static_cast(g_modeMgr.GetGameMode())->scene->movies; - if (this->m_sources.MovieSize(name, width, height)) { - CTexture* texture = this->m_system ? this->m_system->CreateTexture(width, height, TextureFormat::A8R8G8B8, false, false) : nullptr; + if (movies) { + NamedBinkMovie* movie = movies->Get(std::string(name), 1); - if (texture) { - return texture; + if (movie) { + const auto* handle = movie->decoder->Handle(); + CTexture* texture = GetRenderSystemHolder()->CreateTexture(handle->width, handle->height, TextureFormat::A8R8G8B8, false, false); + + if (texture) { + return texture; + } + } } } } else { - auto* bitmap = static_cast(this->m_resources.Load(this->m_sources.Resolve(name))); + auto* bitmap = static_cast(ResourceMgr::Instance().Load(Resolve(name))); if (bitmap) { const auto& image = bitmap->image; CTexture* texture = this->Upload( image.width, image.height, image.pixels, image.alpha != 0 ? TextureFormat::A4R4G4B4 : TextureFormat::A1R5G5B5, option, fullSize, dynamic, renderTarget ); - this->m_resources.Remove(bitmap); + ResourceMgr::Instance().Remove(bitmap); return texture; } } - const int extent = 1 / this->m_reduction; - CTexture* texture = this->m_system ? this->m_system->CreateTexture(extent, extent, TextureFormat::A1R5G5B5, false, false) : nullptr; + const int extent = 1 / g_textureReduction; + CTexture* texture = GetRenderSystemHolder()->CreateTexture(extent, extent, TextureFormat::A1R5G5B5, false, false); if (texture) { const std::uint32_t transparent = 0; @@ -143,7 +160,7 @@ void TextureCache::Clear() { // FUNCTION: fn_02456 void TextureCache::Reload() { for (auto& [name, texture] : this->m_textures) { - auto* bitmap = static_cast(this->m_resources.Load(this->m_sources.Resolve(name))); + auto* bitmap = static_cast(ResourceMgr::Instance().Load(Resolve(name))); if (!bitmap) { continue; @@ -155,20 +172,20 @@ void TextureCache::Reload() { if ((texture->unknown_0008 & 0xFF) == 1) { texture->Create(image.width, image.height, texture->m_format); } else { - texture->Create(image.width / this->m_reduction, image.height / this->m_reduction, texture->m_format); + texture->Create(image.width / g_textureReduction, image.height / g_textureReduction, texture->m_format); } texture->Upload(0, 0, image.width, image.height, image.pixels, 0, 0); } - this->m_resources.Remove(bitmap); + ResourceMgr::Instance().Remove(bitmap); } } // OFFSET: 0x00571C50 // FUNCTION: fn_02457 void TextureCache::ClearUnused() { - const unsigned threshold = timeGetTime() - this->m_reuseDelay; + const unsigned threshold = timeGetTime() - g_resourceReuseDelay; for (auto entry = this->m_textures.begin(); entry != this->m_textures.end();) { CTexture* texture = entry->second; @@ -183,5 +200,5 @@ void TextureCache::ClearUnused() { HeapCompact(GetProcessHeap(), 0); - this->m_sources.CleanupTextures(); + GetRenderSystemHolder()->RestoreDisplayMode(); } diff --git a/Source/Render/Textures/TextureCache.h b/Source/Render/Textures/TextureCache.h index 01fd3c24..4f24ac22 100644 --- a/Source/Render/Textures/TextureCache.h +++ b/Source/Render/Textures/TextureCache.h @@ -1,34 +1,21 @@ #ifndef RAGNAROK_SOURCE_RENDER_TEXTURES_TEXTURECACHE_H #define RAGNAROK_SOURCE_RENDER_TEXTURES_TEXTURECACHE_H -#include "Resource/EZeffectResource.h" - +#include #include -class ResourceMgr; -class CRenderSystemBase; - -class TextureSources { -public: - virtual const char* Resolve(const char* name) = 0; - virtual bool MovieSize(const char* name, int& width, int& height) = 0; - - virtual void CleanupTextures() = 0; - -protected: - ~TextureSources() = default; -}; +class CTexture; struct TextureNameLess { bool operator()(const char* left, const char* right) const; }; -class TextureCache : public EffectTextures { +class TextureCache { public: - TextureCache(ResourceMgr& resources, CRenderSystemBase*& system, TextureSources& sources, const int& reduction, const unsigned& reuseDelay); + TextureCache(); ~TextureCache(); - CTexture* Load(const char* name, int option, bool fullSize, bool dynamic, bool renderTarget) override; - CTexture* Default() override; + CTexture* Load(const char* name, int option, bool fullSize, bool dynamic, bool renderTarget); + CTexture* Default(); CTexture* Create(const char* name, int option, bool fullSize, bool dynamic, bool renderTarget); CTexture* Upload(int width, int height, const std::uint32_t* pixels, int format, int option, bool fullSize, bool dynamic, bool renderTarget); void Remove(CTexture* texture); @@ -37,14 +24,16 @@ public: void Reload(); private: - ResourceMgr& m_resources; - CRenderSystemBase*& m_system; - TextureSources& m_sources; - const int& m_reduction; - const unsigned& m_reuseDelay; - std::map m_textures; + /* 0000 */ std::map m_textures; }; +#if defined(_WIN32) && !defined(_WIN64) +static_assert(sizeof(TextureCache) == 8); +#endif + +extern TextureCache g_texMgr; +extern int g_textureReduction; + CTexture* CreateTexture(std::uint32_t width, std::uint32_t height, std::int32_t format, bool dynamic, bool renderTarget); #endif diff --git a/Source/Render/UIRPDataDrawing.cpp b/Source/Render/UIRPDataDrawing.cpp index a5f03213..2f92bc04 100644 --- a/Source/Render/UIRPDataDrawing.cpp +++ b/Source/Render/UIRPDataDrawing.cpp @@ -44,8 +44,8 @@ void UIRPData::DrawStretched(RenderPrimitivePool& pool, int x, int y, CTexture* // OFFSET: 0x008134B0 // FUNCTION: fn_10122 -void UIRPData::DrawNamed(RenderPrimitivePool& pool, TextureCache& textures, int x, int y, std::string name, std::uint32_t color, int width, int height) { - CTexture* texture = textures.Load(name.c_str(), 0, true, true, false); +void UIRPData::DrawNamed(RenderPrimitivePool& pool, int x, int y, std::string name, std::uint32_t color, int width, int height) { + CTexture* texture = g_texMgr.Load(name.c_str(), 0, true, true, false); if (!texture) { return; } diff --git a/Source/Resource/EZeffectResource.cpp b/Source/Resource/EZeffectResource.cpp index 1818bf42..ed3fce78 100644 --- a/Source/Resource/EZeffectResource.cpp +++ b/Source/Resource/EZeffectResource.cpp @@ -2,6 +2,7 @@ #include "Render/Textures/Texture.h" #include "Render/DeviceContext/DCSurface.h" #include "Resource/EZeffectResource.h" +#include "Render/Textures/TextureCache.h" #include @@ -94,9 +95,9 @@ void CEZeffectRes::Unload() { // OFFSET: 0x0074D850 // FUNCTION: fn_07897 -CTexture* EZeffectClip::Texture(int index, EffectTextures& owner) { +CTexture* EZeffectClip::Texture(int index) { if (index >= this->textureCount) { - return owner.Default(); + return g_texMgr.Default(); } if (!this->textures[index]) { @@ -106,7 +107,7 @@ CTexture* EZeffectClip::Texture(int index, EffectTextures& owner) { path.append(".bmp", 4); } - this->textures[index] = owner.Load(path.c_str(), 1, false, true, false); + this->textures[index] = g_texMgr.Load(path.c_str(), 1, false, true, false); if (this->textures[index]) { this->textures[index]->Retain(); @@ -118,9 +119,9 @@ CTexture* EZeffectClip::Texture(int index, EffectTextures& owner) { // OFFSET: 0x0074D9A0 // FUNCTION: fn_07898 -CTexture* EZeffectClip::Texture(int index, const char* prefix, EffectTextures& owner) { +CTexture* EZeffectClip::Texture(int index, const char* prefix) { if (index >= this->textureCount) { - return owner.Default(); + return g_texMgr.Default(); } if (!this->textures[index]) { @@ -130,7 +131,7 @@ CTexture* EZeffectClip::Texture(int index, const char* prefix, EffectTextures& o path.append(".bmp", 4); } - this->textures[index] = owner.Load(path.c_str(), 1, false, true, false); + this->textures[index] = g_texMgr.Load(path.c_str(), 1, false, true, false); if (this->textures[index]) { this->textures[index]->Retain(); diff --git a/Source/Resource/EZeffectResource.h b/Source/Resource/EZeffectResource.h index 13c5cbec..e522e88c 100644 --- a/Source/Resource/EZeffectResource.h +++ b/Source/Resource/EZeffectResource.h @@ -9,15 +9,6 @@ class CTexture; -class EffectTextures { -public: - virtual CTexture* Load(const char* name, int format, bool option1, bool option2, bool option3) = 0; - virtual CTexture* Default() = 0; - -protected: - ~EffectTextures() = default; -}; - struct EZeffectTransform { /* 0000 */ float x; /* 0004 */ float y; @@ -53,8 +44,8 @@ struct EZeffectKeyFrame { struct EZeffectClip { EZeffectClip(); ~EZeffectClip(); - CTexture* Texture(int index, EffectTextures& textures); - CTexture* Texture(int index, const char* prefix, EffectTextures& textures); + CTexture* Texture(int index); + CTexture* Texture(int index, const char* prefix); /* 0000 */ int textureCount; /* 0004 */ int unknown_0004; diff --git a/Source/Resource/Models/AnimatedModelResource.cpp b/Source/Resource/Models/AnimatedModelResource.cpp index 19484b30..c1f1ebb3 100644 --- a/Source/Resource/Models/AnimatedModelResource.cpp +++ b/Source/Resource/Models/AnimatedModelResource.cpp @@ -32,9 +32,8 @@ AnimatedModelFrame::~AnimatedModelFrame() { } // INLINED -AnimatedModelNode::AnimatedModelNode(TextureCache& textures) - : model(nullptr), parent(nullptr), vertexCount(0), faceCount(0), faceNormals(nullptr), frames(nullptr), faces(nullptr), textures(nullptr), - m_textures(textures) { +AnimatedModelNode::AnimatedModelNode() + : model(nullptr), parent(nullptr), vertexCount(0), faceCount(0), faceNormals(nullptr), frames(nullptr), faces(nullptr), textures(nullptr) { } // INLINED @@ -46,7 +45,7 @@ AnimatedModelNode::~AnimatedModelNode() { if (this->textures) { for (int index = 0; index < this->textureCount; ++index) { this->textures[index]->Release(); - this->m_textures.Remove(this->textures[index]); + g_texMgr.Remove(this->textures[index]); } delete[] this->textures; @@ -138,7 +137,7 @@ bool C3dAnimModelRes::Load(const char* name) { input.Read(&nodeCount, 4); for (int index = 0; index < nodeCount; ++index) { - auto node = std::make_unique(this->m_context->textures); + auto node = std::make_unique(); node->model = this; node->frames = new AnimatedModelFrame[this->frameCount]; std::uint32_t marker; @@ -160,7 +159,7 @@ bool C3dAnimModelRes::Load(const char* name) { for (int texture = 0; texture < node->textureCount; ++texture) { int id; input.Read(&id, 4); - CTexture* value = this->m_context->textures.Load(names[id].c_str(), 0, false, true, false); + CTexture* value = g_texMgr.Load(names[id].c_str(), 0, false, true, false); value->Retain(); node->textures[texture] = value; } diff --git a/Source/Resource/Models/AnimatedModelResource.h b/Source/Resource/Models/AnimatedModelResource.h index 2a1ac4c4..2e50c682 100644 --- a/Source/Resource/Models/AnimatedModelResource.h +++ b/Source/Resource/Models/AnimatedModelResource.h @@ -31,7 +31,7 @@ struct AnimatedModelRecord { class C3dAnimModelRes; struct AnimatedModelNode { - explicit AnimatedModelNode(TextureCache& textures); + AnimatedModelNode(); ~AnimatedModelNode(); AnimatedModelNode(const AnimatedModelNode&) = delete; AnimatedModelNode& operator=(const AnimatedModelNode&) = delete; @@ -53,7 +53,6 @@ struct AnimatedModelNode { /* 0060 */ int sharedTextureVertices; private: - TextureCache& m_textures; }; class C3dAnimModelRes : public CRes { diff --git a/Source/Resource/Models/ModelResource.cpp b/Source/Resource/Models/ModelResource.cpp index 38d9a38d..6facf67e 100644 --- a/Source/Resource/Models/ModelResource.cpp +++ b/Source/Resource/Models/ModelResource.cpp @@ -57,7 +57,7 @@ ModelNode::~ModelNode() { for (CTexture* texture : this->textures) { if (texture) { texture->Release(); - this->model->m_context->textures.Remove(texture); + g_texMgr.Remove(texture); } } @@ -148,7 +148,7 @@ inline void C3dModelResV1::ReadNode(ResourceByteReader& input, unsigned minor, c for (int index = 0; index < textureCount; ++index) { int textureIndex = 0; input.Read(&textureIndex, 4); - CTexture* texture = this->m_context->textures.Load(textureNames[textureIndex].c_str(), 0, false, true, false); + CTexture* texture = g_texMgr.Load(textureNames[textureIndex].c_str(), 0, false, true, false); node->textures.push_back(texture); if (texture) { @@ -448,7 +448,7 @@ CTexture* C3dGrannyModelRes::CreateTexture(const granny_texture* texture, int) { format = 1; } - CTexture* result = this->m_context->textures.Upload(width, height, reinterpret_cast(pixels), format, 0, false, false, false); + CTexture* result = g_texMgr.Upload(width, height, reinterpret_cast(pixels), format, 0, false, false, false); delete[] pixels; delete[] source; return result; diff --git a/Source/Resource/Models/ModelResource.h b/Source/Resource/Models/ModelResource.h index 5c1ded1c..f6b351f2 100644 --- a/Source/Resource/Models/ModelResource.h +++ b/Source/Resource/Models/ModelResource.h @@ -93,7 +93,6 @@ public: struct ModelResourceContext { ResourceBytes& file; - TextureCache& textures; CRenderSystemBase*& renderSystem; }; diff --git a/Source/Resource/Models/ModelResourceV2.cpp b/Source/Resource/Models/ModelResourceV2.cpp index 26b00a08..11762067 100644 --- a/Source/Resource/Models/ModelResourceV2.cpp +++ b/Source/Resource/Models/ModelResourceV2.cpp @@ -148,7 +148,7 @@ void C3dModelResV2::ReadVersion1(ResourceByteReader& input) { for (int texture = 0; texture < nodeTextureCount; ++texture) { int textureIndex = 0; input.Read(&textureIndex, 4); - CTexture* loaded = this->m_context->textures.Load(textureNames[textureIndex].c_str(), 0, false, true, false); + CTexture* loaded = g_texMgr.Load(textureNames[textureIndex].c_str(), 0, false, true, false); node->textures.push_back(loaded); if (loaded) { @@ -277,7 +277,7 @@ void C3dModelResV2::ReadVersion2(ResourceByteReader& input) { for (int texture = 0; texture < nodeTextureCount; ++texture) { int textureIndex = 0; input.Read(&textureIndex, 4); - CTexture* loaded = this->m_context->textures.Load(textureNames[textureIndex].c_str(), 0, false, true, false); + CTexture* loaded = g_texMgr.Load(textureNames[textureIndex].c_str(), 0, false, true, false); node->textures.push_back(loaded); if (loaded) { @@ -386,7 +386,7 @@ void C3dModelResV2::ReadVersion3(ResourceByteReader& input) { input.Read(&textureBytes, 4); char textureName[40]{}; input.Read(textureName, textureBytes); - CTexture* loaded = this->m_context->textures.Load(textureName, 0, false, true, false); + CTexture* loaded = g_texMgr.Load(textureName, 0, false, true, false); node->textures.push_back(loaded); if (loaded) { diff --git a/Source/UI/Window/UIWindow.h b/Source/UI/Window/UIWindow.h index d71a7ad4..344aaa8a 100644 --- a/Source/UI/Window/UIWindow.h +++ b/Source/UI/Window/UIWindow.h @@ -42,7 +42,6 @@ struct UIWindowContext { WindowRegistration& registration; UIWindowMgr& windowMgr; std::unordered_set& deferredDeletion; - TextureCache& textures; void DestroyDeferredChildren(); }; diff --git a/Source/UI/WindowOverlay.cpp b/Source/UI/WindowOverlay.cpp index 6dfe7a78..da100d58 100644 --- a/Source/UI/WindowOverlay.cpp +++ b/Source/UI/WindowOverlay.cpp @@ -10,11 +10,11 @@ void UIWhisperWnd::Slot43() { int y = 0; this->ToScreen(x, y); DrawAlphaRectangle( - g_renderer->primitives, this->m_context->textures, g_renderer->queues, x + 1, y + 1, this->geometry.width - 2, this->geometry.height, 0x66000000, + g_renderer->primitives, g_renderer->queues, x + 1, y + 1, this->geometry.width - 2, this->geometry.height, 0x66000000, g_renderer->fog.supported != 0, g_depthStart, g_depthEnd ); DrawAlphaRectangle( - g_renderer->primitives, this->m_context->textures, g_renderer->queues, x + 1, y + 1, this->geometry.width - 2, 17, 0x449EB6E4, + g_renderer->primitives, g_renderer->queues, x + 1, y + 1, this->geometry.width - 2, 17, 0x449EB6E4, g_renderer->fog.supported != 0, g_depthStart, g_depthEnd ); }