Fix all mingw errors & warnings (#411)

* Use COMPAT_MODE macro to fix errors with mingw gcc 12.2

* MxOmni::m_timerRunning is a MxBool

* MxDirect3D::m_unk0x88c is a MxBool

* MxBackgroundAudioManager::m_unk0x13c is a MxS32

* Fix warning: deleting 'void*' is undefined [-Wdelete-incomplete]

* Fix inline function 'void TglImpl::RendererImpl::Destroy()' used but never defined

* Fix warning: inline function 'MxStreamerSubClass1::MxStreamerSubClass1(undefined4)' used but never defined

* Use `FALSE` for m_timerRunning

* Format

* Format

* Remove comment

* Limit scope for variables in compat mode

* clang-format

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
Anonymous Maarten 2024-01-07 18:30:45 +01:00 committed by GitHub
parent bb7e4df11b
commit fbe7f8bbb0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 144 additions and 40 deletions

View file

@ -136,8 +136,8 @@ typedef struct _D3DRMIMAGE
int bytes_per_line; /* number of bytes of memory for a
scanline. This must be a multiple
of 4. */
void* buffer1; /* memory to render into (first buffer). */
void* buffer2; /* second rendering buffer for double
char* buffer1; /* memory to render into (first buffer). */
char* buffer2; /* second rendering buffer for double
buffering, set to NULL for single
buffering. */
unsigned long red_mask;

View file

@ -132,9 +132,18 @@ BOOL IsleApp::SetupLegoOmni()
char mediaPath[256];
GetProfileStringA("LEGO Island", "MediaPath", "", mediaPath, sizeof(mediaPath));
#ifdef COMPAT_MODE
BOOL failure;
{
MxOmniCreateParam param(mediaPath, (struct HWND__*) m_windowHandle, m_videoParam, MxOmniCreateFlags());
failure = Lego()->Create(param) == FAILURE;
}
#else
BOOL failure =
Lego()->Create(MxOmniCreateParam(mediaPath, (struct HWND__*) m_windowHandle, m_videoParam, MxOmniCreateFlags())
) == FAILURE;
#endif
if (!failure) {
VariableTable()->SetVariable("ACTOR_01", "");
TickleManager()->SetClientTickleInterval(VideoManager(), 10);

View file

@ -34,9 +34,15 @@ void MxAtomId::Destroy()
if (!AtomIdCounterSet())
return;
// The dtor is called on the counter object immediately,
// so this syntax should be correct.
#ifdef COMPAT_MODE
MxAtomIdCounterSet::iterator it;
{
MxAtomIdCounter id_counter(m_internal);
it = AtomIdCounterSet()->find(&id_counter);
}
#else
MxAtomIdCounterSet::iterator it = AtomIdCounterSet()->find(&MxAtomIdCounter(m_internal));
#endif
MxAtomIdCounter* counter = (MxAtomIdCounter*) (*it);
counter->Dec();

View file

@ -104,7 +104,7 @@ void MxBackgroundAudioManager::FUN_1007ee70()
m_unk0x138 = NULL;
m_action2.SetObjectId(-1);
m_action2.SetAtomId(MxAtomId());
m_unk0x13c = NULL;
m_unk0x13c = 0;
}
}
@ -133,7 +133,7 @@ void MxBackgroundAudioManager::FUN_1007ef40()
m_unk0x138 = NULL;
m_action2.SetObjectId(-1);
m_action2.SetAtomId(MxAtomId());
m_unk0x13c = NULL;
m_unk0x13c = 0;
}
}
}

View file

@ -97,10 +97,17 @@ void MxCompositePresenter::EndAction()
MxPresenter::EndAction();
if (action && action->GetOrigin()) {
#ifdef COMPAT_MODE
{
MxEndActionNotificationParam param(c_notificationEndAction, this, action, FALSE);
NotificationManager()->Send(action->GetOrigin(), &param);
}
#else
NotificationManager()->Send(
action->GetOrigin(),
&MxEndActionNotificationParam(c_notificationEndAction, this, action, FALSE)
);
#endif
}
}

View file

@ -14,7 +14,7 @@ MxDirect3D::MxDirect3D()
{
this->m_pDirect3d = NULL;
this->m_pDirect3dDevice = NULL;
this->m_unk0x88c = NULL;
this->m_unk0x88c = 0;
this->m_assignedDevice = NULL;
}

View file

@ -23,8 +23,16 @@ MxDiskStreamController::~MxDiskStreamController()
m_unk0xc4 = FALSE;
m_unk0x70 = FALSE;
if (m_provider)
if (m_provider) {
#ifdef COMPAT_MODE
{
MxDSAction action;
m_provider->VTable0x20(&action);
}
#else
m_provider->VTable0x20(&MxDSAction());
#endif
}
MxDSAction* action;
while (m_unk0x3c.PopFront(action))
@ -299,9 +307,16 @@ MxResult MxDiskStreamController::VTable0x24(MxDSAction* p_action)
MxAutoLocker lock(&this->m_criticalSection);
if (m_unk0x54.Find(p_action, FALSE) == NULL) {
if (VTable0x30(p_action) == SUCCESS) {
#ifdef COMPAT_MODE
{
MxEndActionNotificationParam param(c_notificationEndAction, NULL, p_action, TRUE);
MxOmni::GetInstance()->NotifyCurrentEntity(&param);
}
#else
MxOmni::GetInstance()->NotifyCurrentEntity(
&MxEndActionNotificationParam(c_notificationEndAction, NULL, p_action, TRUE)
);
#endif
}
}

View file

@ -160,10 +160,17 @@ void MxMediaPresenter::EndAction()
}
if (action && action->GetOrigin()) {
#ifdef COMPAT_MODE
{
MxEndActionNotificationParam param(c_notificationEndAction, this, action, FALSE);
NotificationManager()->Send(action->GetOrigin(), &param);
}
#else
NotificationManager()->Send(
action->GetOrigin(),
&MxEndActionNotificationParam(c_notificationEndAction, this, action, FALSE)
);
#endif
}
}
}

View file

@ -157,7 +157,7 @@ void MxOmni::Init()
m_timer = NULL;
m_streamer = NULL;
m_atomIdCounterSet = NULL;
m_timerRunning = NULL;
m_timerRunning = FALSE;
}
// FUNCTION: LEGO1 0x100af0b0
@ -345,14 +345,28 @@ MxResult MxOmni::CreatePresenter(MxStreamController* p_controller, MxDSAction& p
if (object->StartAction(p_controller, &p_action) == SUCCESS) {
if (sender) {
#ifdef COMPAT_MODE
{
MxType4NotificationParam param(this, &p_action, object);
NotificationManager()->Send(sender, &param);
}
#else
NotificationManager()->Send(sender, &MxType4NotificationParam(this, &p_action, object));
#endif
}
if (p_action.GetUnknown84()) {
#ifdef COMPAT_MODE
{
MxStartActionNotificationParam param(c_notificationStartAction, object, &p_action, FALSE);
NotificationManager()->Send(p_action.GetUnknown84(), &param);
}
#else
NotificationManager()->Send(
p_action.GetUnknown84(),
&MxStartActionNotificationParam(c_notificationStartAction, object, &p_action, FALSE)
);
#endif
}
result = SUCCESS;
}

View file

@ -147,9 +147,16 @@ void MxPresenter::EndAction()
MxAutoLocker lock(&this->m_criticalSection);
if (!this->m_compositePresenter) {
#ifdef COMPAT_MODE
{
MxEndActionNotificationParam param(c_notificationEndAction, NULL, this->m_action, TRUE);
MxOmni::GetInstance()->NotifyCurrentEntity(&param);
}
#else
MxOmni::GetInstance()->NotifyCurrentEntity(
&MxEndActionNotificationParam(c_notificationEndAction, NULL, this->m_action, TRUE)
);
#endif
}
this->m_action = NULL;
@ -195,7 +202,14 @@ void MxPresenter::SendToCompositePresenter(MxOmni* p_omni)
if (m_compositePresenter) {
MxAutoLocker lock(&m_criticalSection);
#ifdef COMPAT_MODE
{
MxNotificationParam param(MXPRESENTER_NOTIFICATION, this);
NotificationManager()->Send(m_compositePresenter, &param);
}
#else
NotificationManager()->Send(m_compositePresenter, &MxNotificationParam(MXPRESENTER_NOTIFICATION, this));
#endif
m_action->SetOrigin(p_omni ? p_omni : MxOmni::GetInstance());
m_compositePresenter = NULL;

View file

@ -55,7 +55,14 @@ MxStreamController::~MxStreamController()
if (m_provider) {
MxStreamProvider* provider = m_provider;
m_provider = NULL;
#ifdef COMPAT_MODE
{
MxDSAction action;
provider->VTable0x20(&action);
}
#else
provider->VTable0x20(&MxDSAction());
#endif
delete provider;
}

View file

@ -81,8 +81,16 @@ MxLong MxStreamer::Close(const char* p_name)
if (c->FUN_100c20d0(ds))
delete c;
else
else {
#ifdef COMPAT_MODE
{
MxStreamerNotification notification(MXSTREAMER_DELETE_NOTIFY, NULL, c);
NotificationManager()->Send(this, &notification);
}
#else
NotificationManager()->Send(this, &MxStreamerNotification(MXSTREAMER_DELETE_NOTIFY, NULL, c));
#endif
}
return SUCCESS;
}
@ -185,20 +193,17 @@ MxLong MxStreamer::Notify(MxParam& p_param)
if (c->FUN_100c20d0(ds))
delete c;
else
else {
#ifdef COMPAT_MODE
{
MxStreamerNotification notification(MXSTREAMER_DELETE_NOTIFY, NULL, c);
NotificationManager()->Send(this, &notification);
}
#else
NotificationManager()->Send(this, &MxStreamerNotification(MXSTREAMER_DELETE_NOTIFY, NULL, c));
#endif
}
}
return 0;
}
// No offset, function is always inlined
MxStreamerSubClass1::MxStreamerSubClass1(undefined4 p_size)
{
m_buffer = NULL;
m_size = p_size;
undefined4* ptr = &m_unk0x08;
for (int i = 0; i >= 0; i--) {
ptr[i] = 0;
}
}

View file

@ -14,7 +14,15 @@
// STL. But I haven't figured out what yet (it's definitely not a vector).
class MxStreamerSubClass1 {
public:
inline MxStreamerSubClass1(undefined4 p_size);
inline MxStreamerSubClass1(undefined4 p_size)
{
m_buffer = NULL;
m_size = p_size;
undefined4* ptr = &m_unk0x08;
for (int i = 0; i >= 0; i--) {
ptr[i] = 0;
}
}
~MxStreamerSubClass1() { delete[] m_buffer; }

View file

@ -140,7 +140,14 @@ void MxTransitionManager::EndTransition(MxBool p_notifyWorld)
LegoWorld* world = GetCurrentWorld();
if (world) {
#ifdef COMPAT_MODE
{
MxNotificationParam param(MXTRANSITIONMANAGER_TRANSITIONENDED, this);
world->Notify(param);
}
#else
world->Notify(MxNotificationParam(MXTRANSITIONMANAGER_TRANSITIONENDED, this));
#endif
}
}
}

View file

@ -86,6 +86,25 @@ class RendererImpl : public Renderer {
IDirect3DRM2* m_data;
};
extern IDirect3DRM2* g_pD3DRM;
inline void RendererDestroy(IDirect3DRM2* pRenderer)
{
int refCount = pRenderer->Release();
if (refCount <= 0) {
g_pD3DRM = NULL;
}
}
// Inlined only
void RendererImpl::Destroy()
{
if (m_data) {
RendererDestroy(m_data);
m_data = NULL;
}
}
// VTABLE 0x100db988
class DeviceImpl : public Device {
public:

View file

@ -13,8 +13,11 @@ Renderer* Tgl::CreateRenderer()
return renderer;
}
namespace TglImpl
{
// GLOBAL: LEGO1 0x1010103c
IDirect3DRM2* g_pD3DRM = NULL;
} // namespace TglImpl
// Inlined only
Result RendererImpl::Create()
@ -31,23 +34,6 @@ Result RendererImpl::Create()
return (m_data != NULL) ? Success : Error;
}
inline void RendererDestroy(IDirect3DRM2* pRenderer)
{
int refCount = pRenderer->Release();
if (refCount <= 0) {
g_pD3DRM = NULL;
}
}
// Inlined only
void RendererImpl::Destroy()
{
if (m_data) {
RendererDestroy(m_data);
m_data = NULL;
}
}
// FUNCTION: LEGO1 0x100a1894
Device* RendererImpl::CreateDevice(const DeviceDirect3DCreateData& data)
{