Merge branch 'master' into emscripten

This commit is contained in:
Christian Semmler 2025-06-12 12:38:05 -07:00
commit 453c7cb94a
No known key found for this signature in database
GPG Key ID: 086DAA1360BEEE5C
4 changed files with 31 additions and 19 deletions

View File

@ -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;
}

View File

@ -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<TextureDestroyContext*>(arg);
auto& cacheEntry = ctx->renderer->m_textures[ctx->textureId];
auto* ctx = static_cast<CacheDestroyContext*>(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<MeshDestroyContext*>(arg);
ctx->renderer->m_meshs[ctx->id].meshGroup = nullptr;
[](IDirect3DRMObject* obj, void* arg) {
auto* ctx = static_cast<CacheDestroyContext*>(arg);
auto& cacheEntry = ctx->renderer->m_meshs[ctx->id];
if (cacheEntry.meshGroup) {
cacheEntry.meshGroup = nullptr;
cacheEntry.vertices.clear();
cacheEntry.indices.clear();
}
delete ctx;
},
ctx

View File

@ -14,8 +14,8 @@
#include <functional>
#include <math.h>
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)
{
}

View File

@ -7,12 +7,20 @@
template <typename T>
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();