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

View File

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

View File

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

View File

@ -2,6 +2,8 @@
#include "decomp.h"
#include <SDL3/SDL_log.h>
DECOMP_SIZE_ASSERT(MxDirectDraw, 0x880)
#define RELEASE(x) \
@ -879,6 +881,7 @@ void MxDirectDraw::Error(const char* p_message, int p_error)
if (!g_isInsideError) {
g_isInsideError = TRUE;
Destroy();
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "MxDirectDraw error: [0x%08x] %s", p_error, p_message);
if (m_pErrorHandler) {
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);
if (!hWnd) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "MxDisplaySurface::Create: HWND is NULL");
goto done;
}
@ -176,6 +177,7 @@ MxResult MxDisplaySurface::Create(MxVideoParam& p_videoParam)
MxS32 height = m_videoParam.GetRect().GetHeight();
if (lpDirectDraw->SetCooperativeLevel(hWnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "DirectDraw::SetCooperativeLevel failed");
goto done;
}
@ -183,6 +185,7 @@ MxResult MxDisplaySurface::Create(MxVideoParam& p_videoParam)
ddsd.dwSize = sizeof(ddsd);
if (lpDirectDraw->GetDisplayMode(&ddsd)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "DirectDraw::GetDisplayMode failed");
goto done;
}
@ -190,6 +193,7 @@ MxResult MxDisplaySurface::Create(MxVideoParam& p_videoParam)
if (ddsd.dwWidth != width || ddsd.dwHeight != height || ddsd.ddpfPixelFormat.dwRGBBitCount != bitdepth) {
if (lpDirectDraw->SetDisplayMode(width, height, bitdepth)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "DirectDraw::SetDisplayMode failed");
goto done;
}
}
@ -203,12 +207,14 @@ MxResult MxDisplaySurface::Create(MxVideoParam& p_videoParam)
ddsd.ddsCaps.dwCaps = DDSCAPS_3DDEVICE | DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
if (lpDirectDraw->CreateSurface(&ddsd, &m_ddSurface1, NULL)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "DirectDraw::CreateSurface failed");
goto done;
}
ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
if (m_ddSurface1->GetAttachedSurface(&ddsd.ddsCaps, &m_ddSurface2)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "DirectDrawSurface::GetAttachedSurface failed");
goto done;
}
}
@ -219,6 +225,7 @@ MxResult MxDisplaySurface::Create(MxVideoParam& p_videoParam)
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
if (lpDirectDraw->CreateSurface(&ddsd, &m_ddSurface1, NULL)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "DirectDraw::CreateSurface failed");
goto done;
}
@ -234,6 +241,7 @@ MxResult MxDisplaySurface::Create(MxVideoParam& p_videoParam)
}
if (lpDirectDraw->CreateSurface(&ddsd, &m_ddSurface2, NULL)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "DirectDraw::CreateSurface failed");
goto done;
}
}
@ -246,6 +254,12 @@ MxResult MxDisplaySurface::Create(MxVideoParam& p_videoParam)
!m_ddSurface1->SetClipper(m_ddClipper)) {
result = SUCCESS;
}
else {
SDL_LogError(
SDL_LOG_CATEGORY_APPLICATION,
"DirectDraw::CreateClipper or DirectDrawSurface::SetClipper failed"
);
}
}
done:

View File

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