Log errors during initialization

This commit is contained in:
Anonymous Maarten 2024-12-28 00:00:34 +01:00
parent 6b19c6dc26
commit 643397299a
6 changed files with 70 additions and 0 deletions

View File

@ -33,6 +33,7 @@
#include "scripts.h" #include "scripts.h"
#include "viewmanager/viewmanager.h" #include "viewmanager/viewmanager.h"
#include <SDL3/SDL_log.h>
#include <SDL3/SDL_stdinc.h> #include <SDL3/SDL_stdinc.h>
DECOMP_SIZE_ASSERT(LegoOmni, 0x140) DECOMP_SIZE_ASSERT(LegoOmni, 0x140)
@ -168,18 +169,22 @@ MxResult LegoOmni::Create(MxOmniCreateParam& p_param)
p_param.CreateFlags().CreateTickleManager(FALSE); p_param.CreateFlags().CreateTickleManager(FALSE);
if (!(m_tickleManager = new MxTickleManager())) { if (!(m_tickleManager = new MxTickleManager())) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to create MxTickleManager");
goto done; goto done;
} }
if (MxOmni::Create(p_param) != SUCCESS) { if (MxOmni::Create(p_param) != SUCCESS) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to create MxOmni");
goto done; goto done;
} }
if (!(m_objectFactory = new LegoObjectFactory())) { if (!(m_objectFactory = new LegoObjectFactory())) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to create LegoObjectFactory");
goto done; goto done;
} }
if (!(m_soundManager = new LegoSoundManager()) || m_soundManager->Create(10, 0) != SUCCESS) { if (!(m_soundManager = new LegoSoundManager()) || m_soundManager->Create(10, 0) != SUCCESS) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to create LegoSoundManager");
delete m_soundManager; delete m_soundManager;
m_soundManager = NULL; m_soundManager = NULL;
goto done; goto done;
@ -187,6 +192,7 @@ MxResult LegoOmni::Create(MxOmniCreateParam& p_param)
if (!(m_videoManager = new LegoVideoManager()) || if (!(m_videoManager = new LegoVideoManager()) ||
m_videoManager->Create(p_param.GetVideoParam(), 100, 0) != SUCCESS) { m_videoManager->Create(p_param.GetVideoParam(), 100, 0) != SUCCESS) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to create LegoVideoManager");
delete m_videoManager; delete m_videoManager;
m_videoManager = NULL; m_videoManager = NULL;
goto done; goto done;
@ -199,6 +205,7 @@ MxResult LegoOmni::Create(MxOmniCreateParam& p_param)
NULL NULL
); );
if (!(m_inputManager = new LegoInputManager()) || m_inputManager->Create(hWnd) != SUCCESS) { if (!(m_inputManager = new LegoInputManager()) || m_inputManager->Create(hWnd) != SUCCESS) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to create LegoInputManager");
delete m_inputManager; delete m_inputManager;
m_inputManager = NULL; m_inputManager = NULL;
goto done; goto done;
@ -218,27 +225,37 @@ MxResult LegoOmni::Create(MxOmniCreateParam& p_param)
if (!m_viewLODListManager || !m_textureContainer || !m_worldList || !m_characterManager || !m_plantManager || if (!m_viewLODListManager || !m_textureContainer || !m_worldList || !m_characterManager || !m_plantManager ||
!m_animationManager || !m_buildingManager) { !m_animationManager || !m_buildingManager) {
SDL_LogError(
SDL_LOG_CATEGORY_APPLICATION,
"Failed to create "
"ViewLODListManager/LegoTextureContainer/LegoCharacterManager/LegoPlantManager/LegoAnimationManager/"
"LegoBuildingManager"
);
goto done; goto done;
} }
MxVariable* variable; MxVariable* variable;
if (!(variable = new VisibilityVariable())) { if (!(variable = new VisibilityVariable())) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to create VisibilityVariable");
goto done; goto done;
} }
m_variableTable->SetVariable(variable); m_variableTable->SetVariable(variable);
if (!(variable = new CameraLocationVariable())) { if (!(variable = new CameraLocationVariable())) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to create CameraLocationVariable");
goto done; goto done;
} }
m_variableTable->SetVariable(variable); m_variableTable->SetVariable(variable);
if (!(variable = new CursorVariable())) { if (!(variable = new CursorVariable())) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to create CursorVariable");
goto done; goto done;
} }
m_variableTable->SetVariable(variable); m_variableTable->SetVariable(variable);
if (!(variable = new WhoAmIVariable())) { if (!(variable = new WhoAmIVariable())) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to create WhoAmIVariable");
goto done; goto done;
} }
m_variableTable->SetVariable(variable); m_variableTable->SetVariable(variable);
@ -248,18 +265,22 @@ MxResult LegoOmni::Create(MxOmniCreateParam& p_param)
result = RegisterWorlds(); result = RegisterWorlds();
if (result != SUCCESS) { if (result != SUCCESS) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to create RegisterWorlds");
goto done; goto done;
} }
if (!(m_bkgAudioManager = new MxBackgroundAudioManager())) { if (!(m_bkgAudioManager = new MxBackgroundAudioManager())) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to create MxBackgroundAudioManager");
goto done; goto done;
} }
if (!(m_transitionManager = new MxTransitionManager())) { if (!(m_transitionManager = new MxTransitionManager())) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to create MxTransitionManager");
goto done; goto done;
} }
if (m_transitionManager->GetDDrawSurfaceFromVideoManager() != SUCCESS) { if (m_transitionManager->GetDDrawSurfaceFromVideoManager() != SUCCESS) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "MxTransitionManager::GetDDrawSurfaceFromVideoManager failed");
goto done; goto done;
} }

View File

@ -19,6 +19,7 @@
#include "tgl/d3drm/impl.h" #include "tgl/d3drm/impl.h"
#include "viewmanager/viewroi.h" #include "viewmanager/viewroi.h"
#include <SDL3/SDL_log.h>
#include <SDL3/SDL_stdinc.h> #include <SDL3/SDL_stdinc.h>
#include <stdio.h> #include <stdio.h>
@ -98,6 +99,7 @@ MxResult LegoVideoManager::Create(MxVideoParam& p_videoParam, MxU32 p_frequencyM
p_videoParam.SetPalette(palette); p_videoParam.SetPalette(palette);
if (!p_videoParam.GetPalette()) { if (!p_videoParam.GetPalette()) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "MxPalette::GetPalette returned NULL palette");
goto done; goto done;
} }
paletteCreated = TRUE; paletteCreated = TRUE;
@ -107,10 +109,12 @@ MxResult LegoVideoManager::Create(MxVideoParam& p_videoParam, MxU32 p_frequencyM
p_videoParam.GetPalette()->GetEntries(paletteEntries); p_videoParam.GetPalette()->GetEntries(paletteEntries);
if (CreateDirect3D() != SUCCESS) { if (CreateDirect3D() != SUCCESS) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "::CreateDirect3D failed");
goto done; goto done;
} }
if (deviceEnumerate.DoEnumerate() != SUCCESS) { if (deviceEnumerate.DoEnumerate() != SUCCESS) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "LegoDeviceEnumerate::DoEnumerate failed");
goto done; goto done;
} }
@ -151,6 +155,7 @@ MxResult LegoVideoManager::Create(MxVideoParam& p_videoParam, MxU32 p_frequencyM
paletteEntries, paletteEntries,
sizeof(paletteEntries) / sizeof(paletteEntries[0]) sizeof(paletteEntries) / sizeof(paletteEntries[0])
)) { )) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "MxDirect3D::Create failed");
goto done; goto done;
} }
@ -164,18 +169,21 @@ MxResult LegoVideoManager::Create(MxVideoParam& p_videoParam, MxU32 p_frequencyM
p_frequencyMS, p_frequencyMS,
p_createThread p_createThread
) != SUCCESS) { ) != SUCCESS) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "MxVideoManager::VTable0x28 failed");
goto done; goto done;
} }
m_renderer = Tgl::CreateRenderer(); m_renderer = Tgl::CreateRenderer();
if (!m_renderer) { if (!m_renderer) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Tgl::CreateRenderer failed");
goto done; goto done;
} }
m_3dManager = new Lego3DManager; m_3dManager = new Lego3DManager;
if (!m_3dManager) { if (!m_3dManager) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Lego3DManager::Lego3DManager failed");
goto done; goto done;
} }
@ -196,12 +204,14 @@ MxResult LegoVideoManager::Create(MxVideoParam& p_videoParam, MxU32 p_frequencyM
createStruct.m_d3dDevice = m_direct3d->Direct3DDevice(); createStruct.m_d3dDevice = m_direct3d->Direct3DDevice();
if (!m_3dManager->Create(createStruct)) { if (!m_3dManager->Create(createStruct)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Lego3DManager::Create failed");
goto done; goto done;
} }
ViewLODList* pLODList; ViewLODList* pLODList;
if (ConfigureD3DRM() != SUCCESS) { if (ConfigureD3DRM() != SUCCESS) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "LegoVideoManager::ConfigureD3DRM failed");
goto done; goto done;
} }

View File

@ -52,9 +52,16 @@ BOOL MxDirect3D::Create(
paletteEntryCount paletteEntryCount
); );
if (!ret) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "MxDirectDraw::Create failed");
}
if (ret && D3DCreate() && D3DSetMode()) { if (ret && D3DCreate() && D3DSetMode()) {
success = TRUE; success = TRUE;
} }
else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "D3DCreate()/D3DSetMode failed");
}
if (!success) { if (!success) {
FUN_1009d920(); FUN_1009d920();

View File

@ -2,6 +2,8 @@
#include "decomp.h" #include "decomp.h"
#include <SDL3/SDL_log.h>
DECOMP_SIZE_ASSERT(MxDirectDraw, 0x880) DECOMP_SIZE_ASSERT(MxDirectDraw, 0x880)
#define RELEASE(x) \ #define RELEASE(x) \
@ -879,6 +881,7 @@ void MxDirectDraw::Error(const char* p_message, int p_error)
if (!g_isInsideError) { if (!g_isInsideError) {
g_isInsideError = TRUE; g_isInsideError = TRUE;
Destroy(); Destroy();
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "MxDirectDraw error: [0x%08x] %s", p_error, p_message);
if (m_pErrorHandler) { if (m_pErrorHandler) {
m_pErrorHandler(p_message, p_error, m_pErrorHandlerArg); m_pErrorHandler(p_message, p_error, m_pErrorHandlerArg);
} }

View File

@ -145,6 +145,7 @@ MxResult MxDisplaySurface::Create(MxVideoParam& p_videoParam)
(HWND) SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL); (HWND) SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL);
if (!hWnd) { if (!hWnd) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "MxDisplaySurface::Create: HWND is NULL");
goto done; goto done;
} }
@ -176,6 +177,7 @@ MxResult MxDisplaySurface::Create(MxVideoParam& p_videoParam)
MxS32 height = m_videoParam.GetRect().GetHeight(); MxS32 height = m_videoParam.GetRect().GetHeight();
if (lpDirectDraw->SetCooperativeLevel(hWnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN)) { if (lpDirectDraw->SetCooperativeLevel(hWnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "DirectDraw::SetCooperativeLevel failed");
goto done; goto done;
} }
@ -183,6 +185,7 @@ MxResult MxDisplaySurface::Create(MxVideoParam& p_videoParam)
ddsd.dwSize = sizeof(ddsd); ddsd.dwSize = sizeof(ddsd);
if (lpDirectDraw->GetDisplayMode(&ddsd)) { if (lpDirectDraw->GetDisplayMode(&ddsd)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "DirectDraw::GetDisplayMode failed");
goto done; goto done;
} }
@ -190,6 +193,7 @@ MxResult MxDisplaySurface::Create(MxVideoParam& p_videoParam)
if (ddsd.dwWidth != width || ddsd.dwHeight != height || ddsd.ddpfPixelFormat.dwRGBBitCount != bitdepth) { if (ddsd.dwWidth != width || ddsd.dwHeight != height || ddsd.ddpfPixelFormat.dwRGBBitCount != bitdepth) {
if (lpDirectDraw->SetDisplayMode(width, height, bitdepth)) { if (lpDirectDraw->SetDisplayMode(width, height, bitdepth)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "DirectDraw::SetDisplayMode failed");
goto done; goto done;
} }
} }
@ -203,12 +207,14 @@ MxResult MxDisplaySurface::Create(MxVideoParam& p_videoParam)
ddsd.ddsCaps.dwCaps = DDSCAPS_3DDEVICE | DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; ddsd.ddsCaps.dwCaps = DDSCAPS_3DDEVICE | DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
if (lpDirectDraw->CreateSurface(&ddsd, &m_ddSurface1, NULL)) { if (lpDirectDraw->CreateSurface(&ddsd, &m_ddSurface1, NULL)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "DirectDraw::CreateSurface failed");
goto done; goto done;
} }
ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER; ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
if (m_ddSurface1->GetAttachedSurface(&ddsd.ddsCaps, &m_ddSurface2)) { if (m_ddSurface1->GetAttachedSurface(&ddsd.ddsCaps, &m_ddSurface2)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "DirectDrawSurface::GetAttachedSurface failed");
goto done; goto done;
} }
} }
@ -219,6 +225,7 @@ MxResult MxDisplaySurface::Create(MxVideoParam& p_videoParam)
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
if (lpDirectDraw->CreateSurface(&ddsd, &m_ddSurface1, NULL)) { if (lpDirectDraw->CreateSurface(&ddsd, &m_ddSurface1, NULL)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "DirectDraw::CreateSurface failed");
goto done; goto done;
} }
@ -234,6 +241,7 @@ MxResult MxDisplaySurface::Create(MxVideoParam& p_videoParam)
} }
if (lpDirectDraw->CreateSurface(&ddsd, &m_ddSurface2, NULL)) { if (lpDirectDraw->CreateSurface(&ddsd, &m_ddSurface2, NULL)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "DirectDraw::CreateSurface failed");
goto done; goto done;
} }
} }
@ -246,6 +254,12 @@ MxResult MxDisplaySurface::Create(MxVideoParam& p_videoParam)
!m_ddSurface1->SetClipper(m_ddClipper)) { !m_ddSurface1->SetClipper(m_ddClipper)) {
result = SUCCESS; result = SUCCESS;
} }
else {
SDL_LogError(
SDL_LOG_CATEGORY_APPLICATION,
"DirectDraw::CreateClipper or DirectDrawSurface::SetClipper failed"
);
}
} }
done: done:

View File

@ -10,6 +10,8 @@
#include "mxticklemanager.h" #include "mxticklemanager.h"
#include "mxticklethread.h" #include "mxticklethread.h"
#include <SDL3/SDL_log.h>
DECOMP_SIZE_ASSERT(MxVideoManager, 0x64) DECOMP_SIZE_ASSERT(MxVideoManager, 0x64)
// FUNCTION: LEGO1 0x100be1f0 // FUNCTION: LEGO1 0x100be1f0
@ -221,6 +223,7 @@ MxResult MxVideoManager::Create(MxVideoParam& p_videoParam, MxU32 p_frequencyMS,
m_unk0x60 = TRUE; m_unk0x60 = TRUE;
if (MxMediaManager::Create() != SUCCESS) { if (MxMediaManager::Create() != SUCCESS) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "MxMediaManager::Create failed");
goto done; goto done;
} }
@ -231,10 +234,12 @@ MxResult MxVideoManager::Create(MxVideoParam& p_videoParam, MxU32 p_frequencyMS,
m_region = new MxRegion(); m_region = new MxRegion();
if (!m_region) { if (!m_region) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "MxRegion::MxRegion failed");
goto done; goto done;
} }
if (DirectDrawCreate(NULL, &m_pDirectDraw, NULL) != DD_OK) { if (DirectDrawCreate(NULL, &m_pDirectDraw, NULL) != DD_OK) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "::DirectDrawCreate failed");
goto done; goto done;
} }
@ -245,6 +250,7 @@ MxResult MxVideoManager::Create(MxVideoParam& p_videoParam, MxU32 p_frequencyMS,
NULL NULL
); );
if (m_pDirectDraw->SetCooperativeLevel(hWnd, DDSCL_NORMAL) != DD_OK) { if (m_pDirectDraw->SetCooperativeLevel(hWnd, DDSCL_NORMAL) != DD_OK) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "IDirectDraw::SetCooperativeLevel failed");
goto done; goto done;
} }
@ -254,6 +260,7 @@ MxResult MxVideoManager::Create(MxVideoParam& p_videoParam, MxU32 p_frequencyMS,
m_videoParam.SetPalette(palette); m_videoParam.SetPalette(palette);
if (!palette) { if (!palette) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "MxPalette::MxPalette failed");
goto done; goto done;
} }
} }
@ -262,6 +269,7 @@ MxResult MxVideoManager::Create(MxVideoParam& p_videoParam, MxU32 p_frequencyMS,
m_videoParam.SetPalette(palette); m_videoParam.SetPalette(palette);
if (!palette) { if (!palette) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "MxPalette::Clone failed");
goto done; goto done;
} }
} }
@ -274,6 +282,7 @@ MxResult MxVideoManager::Create(MxVideoParam& p_videoParam, MxU32 p_frequencyMS,
m_thread = new MxTickleThread(this, p_frequencyMS); m_thread = new MxTickleThread(this, p_frequencyMS);
if (!m_thread || m_thread->Start(0, 0) != SUCCESS) { if (!m_thread || m_thread->Start(0, 0) != SUCCESS) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "MxTickleThread::MxTickleThread failed");
goto done; goto done;
} }
} }
@ -283,6 +292,12 @@ MxResult MxVideoManager::Create(MxVideoParam& p_videoParam, MxU32 p_frequencyMS,
status = SUCCESS; status = SUCCESS;
} }
else {
SDL_LogError(
SDL_LOG_CATEGORY_APPLICATION,
"MxDisplaySurface::MxDisplaySurface/MxDisplaySurface::Create failed"
);
}
done: done:
if (status != SUCCESS) { if (status != SUCCESS) {