diff --git a/LEGO1/lego/legoomni/src/worlds/infocenter.cpp b/LEGO1/lego/legoomni/src/worlds/infocenter.cpp index 15630db9..50515f9f 100644 --- a/LEGO1/lego/legoomni/src/worlds/infocenter.cpp +++ b/LEGO1/lego/legoomni/src/worlds/infocenter.cpp @@ -273,7 +273,11 @@ MxLong Infocenter::Notify(MxParam& p_param) else if (m_destLocation != 0) { BackgroundAudioManager()->RaiseVolume(); GameState()->SwitchArea(m_destLocation); - m_destLocation = LegoGameState::e_undefined; + + if (GameState()->m_currentArea != LegoGameState::e_act2main && + GameState()->m_currentArea != LegoGameState::e_act3script) { + m_destLocation = LegoGameState::e_undefined; + } } break; } diff --git a/miniwin/src/d3drm/backends/software/renderer.cpp b/miniwin/src/d3drm/backends/software/renderer.cpp index 24fd1e92..305a5fe9 100644 --- a/miniwin/src/d3drm/backends/software/renderer.cpp +++ b/miniwin/src/d3drm/backends/software/renderer.cpp @@ -268,7 +268,7 @@ void Direct3DRMSoftwareRenderer::DrawTriangleProjected( Uint8 r, g, b; SDL_Color c0 = ApplyLighting(v0.position, v0.normal, appearance); - SDL_Color c1, c2; + SDL_Color c1 = {}, c2 = {}; if (!appearance.flat) { c1 = ApplyLighting(v1.position, v1.normal, appearance); c2 = ApplyLighting(v2.position, v2.normal, appearance); @@ -436,18 +436,18 @@ void Direct3DRMSoftwareRenderer::DrawTriangleProjected( } } -struct TextureDestroyContext { +struct CacheDestroyContext { Direct3DRMSoftwareRenderer* renderer; - Uint32 textureId; + Uint32 id; }; void Direct3DRMSoftwareRenderer::AddTextureDestroyCallback(Uint32 id, IDirect3DRMTexture* texture) { - auto* ctx = new TextureDestroyContext{this, id}; + auto* ctx = new CacheDestroyContext{this, id}; texture->AddDestroyCallback( [](IDirect3DRMObject* obj, void* arg) { - auto* ctx = static_cast(arg); - auto& cacheEntry = ctx->renderer->m_textures[ctx->textureId]; + auto* ctx = static_cast(arg); + auto& cacheEntry = ctx->renderer->m_textures[ctx->id]; if (cacheEntry.cached) { SDL_UnlockSurface(cacheEntry.cached); SDL_DestroySurface(cacheEntry.cached); @@ -525,18 +525,18 @@ MeshCache UploadMesh(const MeshGroup& meshGroup) return cache; } -struct MeshDestroyContext { - Direct3DRMSoftwareRenderer* renderer; - Uint32 id; -}; - void Direct3DRMSoftwareRenderer::AddMeshDestroyCallback(Uint32 id, IDirect3DRMMesh* mesh) { - auto* ctx = new MeshDestroyContext{this, id}; + auto* ctx = new CacheDestroyContext{this, id}; mesh->AddDestroyCallback( - [](IDirect3DRMObject*, void* arg) { - auto* ctx = static_cast(arg); - ctx->renderer->m_meshs[ctx->id].meshGroup = nullptr; + [](IDirect3DRMObject* obj, void* arg) { + auto* ctx = static_cast(arg); + auto& cacheEntry = ctx->renderer->m_meshs[ctx->id]; + if (cacheEntry.meshGroup) { + cacheEntry.meshGroup = nullptr; + cacheEntry.vertices.clear(); + cacheEntry.indices.clear(); + } delete ctx; }, ctx diff --git a/miniwin/src/d3drm/d3drmviewport.cpp b/miniwin/src/d3drm/d3drmviewport.cpp index 065ea0ff..3f60c368 100644 --- a/miniwin/src/d3drm/d3drmviewport.cpp +++ b/miniwin/src/d3drm/d3drmviewport.cpp @@ -14,8 +14,8 @@ #include #include -Direct3DRMViewportImpl::Direct3DRMViewportImpl(DWORD width, DWORD height, Direct3DRMRenderer* rendere) - : m_width(width), m_height(height), m_renderer(rendere) +Direct3DRMViewportImpl::Direct3DRMViewportImpl(DWORD width, DWORD height, Direct3DRMRenderer* renderer) + : m_width(width), m_height(height), m_renderer(renderer) { } diff --git a/miniwin/src/internal/d3drmobject_impl.h b/miniwin/src/internal/d3drmobject_impl.h index a4a7cd1e..6cd449fe 100644 --- a/miniwin/src/internal/d3drmobject_impl.h +++ b/miniwin/src/internal/d3drmobject_impl.h @@ -7,12 +7,20 @@ template struct Direct3DRMObjectBaseImpl : public T { + Direct3DRMObjectBaseImpl() : T() {} + Direct3DRMObjectBaseImpl(const Direct3DRMObjectBaseImpl& other) : m_appData(other.m_appData), T(other) + { + if (other.m_name) { + m_name = SDL_strdup(other.m_name); + } + } ULONG Release() override { - if (IUnknown::m_refCount == 1) { + if (T::m_refCount == 1) { for (auto it = m_callbacks.cbegin(); it != m_callbacks.cend(); it++) { it->first(this, it->second); } + m_callbacks.clear(); } SDL_free(m_name); return this->T::Release();