Skip to content

Commit fbe7f8b

Browse files
madebrfoxtacles
andauthored
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 <[email protected]>
1 parent bb7e4df commit fbe7f8b

16 files changed

+144
-40
lines changed

3rdparty/dx5/inc/d3drmdef.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ typedef struct _D3DRMIMAGE
136136
int bytes_per_line; /* number of bytes of memory for a
137137
scanline. This must be a multiple
138138
of 4. */
139-
void* buffer1; /* memory to render into (first buffer). */
140-
void* buffer2; /* second rendering buffer for double
139+
char* buffer1; /* memory to render into (first buffer). */
140+
char* buffer2; /* second rendering buffer for double
141141
buffering, set to NULL for single
142142
buffering. */
143143
unsigned long red_mask;

ISLE/isleapp.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,18 @@ BOOL IsleApp::SetupLegoOmni()
132132
char mediaPath[256];
133133
GetProfileStringA("LEGO Island", "MediaPath", "", mediaPath, sizeof(mediaPath));
134134

135+
#ifdef COMPAT_MODE
136+
BOOL failure;
137+
{
138+
MxOmniCreateParam param(mediaPath, (struct HWND__*) m_windowHandle, m_videoParam, MxOmniCreateFlags());
139+
failure = Lego()->Create(param) == FAILURE;
140+
}
141+
#else
135142
BOOL failure =
136143
Lego()->Create(MxOmniCreateParam(mediaPath, (struct HWND__*) m_windowHandle, m_videoParam, MxOmniCreateFlags())
137144
) == FAILURE;
145+
#endif
146+
138147
if (!failure) {
139148
VariableTable()->SetVariable("ACTOR_01", "");
140149
TickleManager()->SetClientTickleInterval(VideoManager(), 10);

LEGO1/mxatomid.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,15 @@ void MxAtomId::Destroy()
3434
if (!AtomIdCounterSet())
3535
return;
3636

37-
// The dtor is called on the counter object immediately,
38-
// so this syntax should be correct.
37+
#ifdef COMPAT_MODE
38+
MxAtomIdCounterSet::iterator it;
39+
{
40+
MxAtomIdCounter id_counter(m_internal);
41+
it = AtomIdCounterSet()->find(&id_counter);
42+
}
43+
#else
3944
MxAtomIdCounterSet::iterator it = AtomIdCounterSet()->find(&MxAtomIdCounter(m_internal));
45+
#endif
4046

4147
MxAtomIdCounter* counter = (MxAtomIdCounter*) (*it);
4248
counter->Dec();

LEGO1/mxbackgroundaudiomanager.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ void MxBackgroundAudioManager::FUN_1007ee70()
104104
m_unk0x138 = NULL;
105105
m_action2.SetObjectId(-1);
106106
m_action2.SetAtomId(MxAtomId());
107-
m_unk0x13c = NULL;
107+
m_unk0x13c = 0;
108108
}
109109
}
110110

@@ -133,7 +133,7 @@ void MxBackgroundAudioManager::FUN_1007ef40()
133133
m_unk0x138 = NULL;
134134
m_action2.SetObjectId(-1);
135135
m_action2.SetAtomId(MxAtomId());
136-
m_unk0x13c = NULL;
136+
m_unk0x13c = 0;
137137
}
138138
}
139139
}

LEGO1/mxcompositepresenter.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,17 @@ void MxCompositePresenter::EndAction()
9797
MxPresenter::EndAction();
9898

9999
if (action && action->GetOrigin()) {
100+
#ifdef COMPAT_MODE
101+
{
102+
MxEndActionNotificationParam param(c_notificationEndAction, this, action, FALSE);
103+
NotificationManager()->Send(action->GetOrigin(), &param);
104+
}
105+
#else
100106
NotificationManager()->Send(
101107
action->GetOrigin(),
102108
&MxEndActionNotificationParam(c_notificationEndAction, this, action, FALSE)
103109
);
110+
#endif
104111
}
105112
}
106113

LEGO1/mxdirectx/mxdirect3d.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ MxDirect3D::MxDirect3D()
1414
{
1515
this->m_pDirect3d = NULL;
1616
this->m_pDirect3dDevice = NULL;
17-
this->m_unk0x88c = NULL;
17+
this->m_unk0x88c = 0;
1818
this->m_assignedDevice = NULL;
1919
}
2020

LEGO1/mxdiskstreamcontroller.cpp

+16-1
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,16 @@ MxDiskStreamController::~MxDiskStreamController()
2323
m_unk0xc4 = FALSE;
2424
m_unk0x70 = FALSE;
2525

26-
if (m_provider)
26+
if (m_provider) {
27+
#ifdef COMPAT_MODE
28+
{
29+
MxDSAction action;
30+
m_provider->VTable0x20(&action);
31+
}
32+
#else
2733
m_provider->VTable0x20(&MxDSAction());
34+
#endif
35+
}
2836

2937
MxDSAction* action;
3038
while (m_unk0x3c.PopFront(action))
@@ -299,9 +307,16 @@ MxResult MxDiskStreamController::VTable0x24(MxDSAction* p_action)
299307
MxAutoLocker lock(&this->m_criticalSection);
300308
if (m_unk0x54.Find(p_action, FALSE) == NULL) {
301309
if (VTable0x30(p_action) == SUCCESS) {
310+
#ifdef COMPAT_MODE
311+
{
312+
MxEndActionNotificationParam param(c_notificationEndAction, NULL, p_action, TRUE);
313+
MxOmni::GetInstance()->NotifyCurrentEntity(&param);
314+
}
315+
#else
302316
MxOmni::GetInstance()->NotifyCurrentEntity(
303317
&MxEndActionNotificationParam(c_notificationEndAction, NULL, p_action, TRUE)
304318
);
319+
#endif
305320
}
306321
}
307322

LEGO1/mxmediapresenter.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,17 @@ void MxMediaPresenter::EndAction()
160160
}
161161

162162
if (action && action->GetOrigin()) {
163+
#ifdef COMPAT_MODE
164+
{
165+
MxEndActionNotificationParam param(c_notificationEndAction, this, action, FALSE);
166+
NotificationManager()->Send(action->GetOrigin(), &param);
167+
}
168+
#else
163169
NotificationManager()->Send(
164170
action->GetOrigin(),
165171
&MxEndActionNotificationParam(c_notificationEndAction, this, action, FALSE)
166172
);
173+
#endif
167174
}
168175
}
169176
}

LEGO1/mxomni.cpp

+15-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ void MxOmni::Init()
157157
m_timer = NULL;
158158
m_streamer = NULL;
159159
m_atomIdCounterSet = NULL;
160-
m_timerRunning = NULL;
160+
m_timerRunning = FALSE;
161161
}
162162

163163
// FUNCTION: LEGO1 0x100af0b0
@@ -345,14 +345,28 @@ MxResult MxOmni::CreatePresenter(MxStreamController* p_controller, MxDSAction& p
345345

346346
if (object->StartAction(p_controller, &p_action) == SUCCESS) {
347347
if (sender) {
348+
#ifdef COMPAT_MODE
349+
{
350+
MxType4NotificationParam param(this, &p_action, object);
351+
NotificationManager()->Send(sender, &param);
352+
}
353+
#else
348354
NotificationManager()->Send(sender, &MxType4NotificationParam(this, &p_action, object));
355+
#endif
349356
}
350357

351358
if (p_action.GetUnknown84()) {
359+
#ifdef COMPAT_MODE
360+
{
361+
MxStartActionNotificationParam param(c_notificationStartAction, object, &p_action, FALSE);
362+
NotificationManager()->Send(p_action.GetUnknown84(), &param);
363+
}
364+
#else
352365
NotificationManager()->Send(
353366
p_action.GetUnknown84(),
354367
&MxStartActionNotificationParam(c_notificationStartAction, object, &p_action, FALSE)
355368
);
369+
#endif
356370
}
357371
result = SUCCESS;
358372
}

LEGO1/mxpresenter.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,16 @@ void MxPresenter::EndAction()
147147
MxAutoLocker lock(&this->m_criticalSection);
148148

149149
if (!this->m_compositePresenter) {
150+
#ifdef COMPAT_MODE
151+
{
152+
MxEndActionNotificationParam param(c_notificationEndAction, NULL, this->m_action, TRUE);
153+
MxOmni::GetInstance()->NotifyCurrentEntity(&param);
154+
}
155+
#else
150156
MxOmni::GetInstance()->NotifyCurrentEntity(
151157
&MxEndActionNotificationParam(c_notificationEndAction, NULL, this->m_action, TRUE)
152158
);
159+
#endif
153160
}
154161

155162
this->m_action = NULL;
@@ -195,7 +202,14 @@ void MxPresenter::SendToCompositePresenter(MxOmni* p_omni)
195202
if (m_compositePresenter) {
196203
MxAutoLocker lock(&m_criticalSection);
197204

205+
#ifdef COMPAT_MODE
206+
{
207+
MxNotificationParam param(MXPRESENTER_NOTIFICATION, this);
208+
NotificationManager()->Send(m_compositePresenter, &param);
209+
}
210+
#else
198211
NotificationManager()->Send(m_compositePresenter, &MxNotificationParam(MXPRESENTER_NOTIFICATION, this));
212+
#endif
199213

200214
m_action->SetOrigin(p_omni ? p_omni : MxOmni::GetInstance());
201215
m_compositePresenter = NULL;

LEGO1/mxstreamcontroller.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,14 @@ MxStreamController::~MxStreamController()
5555
if (m_provider) {
5656
MxStreamProvider* provider = m_provider;
5757
m_provider = NULL;
58+
#ifdef COMPAT_MODE
59+
{
60+
MxDSAction action;
61+
provider->VTable0x20(&action);
62+
}
63+
#else
5864
provider->VTable0x20(&MxDSAction());
65+
#endif
5966
delete provider;
6067
}
6168

LEGO1/mxstreamer.cpp

+18-13
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,16 @@ MxLong MxStreamer::Close(const char* p_name)
8181

8282
if (c->FUN_100c20d0(ds))
8383
delete c;
84-
else
84+
else {
85+
#ifdef COMPAT_MODE
86+
{
87+
MxStreamerNotification notification(MXSTREAMER_DELETE_NOTIFY, NULL, c);
88+
NotificationManager()->Send(this, &notification);
89+
}
90+
#else
8591
NotificationManager()->Send(this, &MxStreamerNotification(MXSTREAMER_DELETE_NOTIFY, NULL, c));
92+
#endif
93+
}
8694

8795
return SUCCESS;
8896
}
@@ -185,20 +193,17 @@ MxLong MxStreamer::Notify(MxParam& p_param)
185193

186194
if (c->FUN_100c20d0(ds))
187195
delete c;
188-
else
196+
else {
197+
#ifdef COMPAT_MODE
198+
{
199+
MxStreamerNotification notification(MXSTREAMER_DELETE_NOTIFY, NULL, c);
200+
NotificationManager()->Send(this, &notification);
201+
}
202+
#else
189203
NotificationManager()->Send(this, &MxStreamerNotification(MXSTREAMER_DELETE_NOTIFY, NULL, c));
204+
#endif
205+
}
190206
}
191207

192208
return 0;
193209
}
194-
195-
// No offset, function is always inlined
196-
MxStreamerSubClass1::MxStreamerSubClass1(undefined4 p_size)
197-
{
198-
m_buffer = NULL;
199-
m_size = p_size;
200-
undefined4* ptr = &m_unk0x08;
201-
for (int i = 0; i >= 0; i--) {
202-
ptr[i] = 0;
203-
}
204-
}

LEGO1/mxstreamer.h

+9-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@
1414
// STL. But I haven't figured out what yet (it's definitely not a vector).
1515
class MxStreamerSubClass1 {
1616
public:
17-
inline MxStreamerSubClass1(undefined4 p_size);
17+
inline MxStreamerSubClass1(undefined4 p_size)
18+
{
19+
m_buffer = NULL;
20+
m_size = p_size;
21+
undefined4* ptr = &m_unk0x08;
22+
for (int i = 0; i >= 0; i--) {
23+
ptr[i] = 0;
24+
}
25+
}
1826

1927
~MxStreamerSubClass1() { delete[] m_buffer; }
2028

LEGO1/mxtransitionmanager.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,14 @@ void MxTransitionManager::EndTransition(MxBool p_notifyWorld)
140140
LegoWorld* world = GetCurrentWorld();
141141

142142
if (world) {
143+
#ifdef COMPAT_MODE
144+
{
145+
MxNotificationParam param(MXTRANSITIONMANAGER_TRANSITIONENDED, this);
146+
world->Notify(param);
147+
}
148+
#else
143149
world->Notify(MxNotificationParam(MXTRANSITIONMANAGER_TRANSITIONENDED, this));
150+
#endif
144151
}
145152
}
146153
}

LEGO1/tgl/d3drm/impl.h

+19
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,25 @@ class RendererImpl : public Renderer {
8686
IDirect3DRM2* m_data;
8787
};
8888

89+
extern IDirect3DRM2* g_pD3DRM;
90+
91+
inline void RendererDestroy(IDirect3DRM2* pRenderer)
92+
{
93+
int refCount = pRenderer->Release();
94+
if (refCount <= 0) {
95+
g_pD3DRM = NULL;
96+
}
97+
}
98+
99+
// Inlined only
100+
void RendererImpl::Destroy()
101+
{
102+
if (m_data) {
103+
RendererDestroy(m_data);
104+
m_data = NULL;
105+
}
106+
}
107+
89108
// VTABLE 0x100db988
90109
class DeviceImpl : public Device {
91110
public:

LEGO1/tgl/d3drm/renderer.cpp

+3-17
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ Renderer* Tgl::CreateRenderer()
1313
return renderer;
1414
}
1515

16+
namespace TglImpl
17+
{
1618
// GLOBAL: LEGO1 0x1010103c
1719
IDirect3DRM2* g_pD3DRM = NULL;
20+
} // namespace TglImpl
1821

1922
// Inlined only
2023
Result RendererImpl::Create()
@@ -31,23 +34,6 @@ Result RendererImpl::Create()
3134
return (m_data != NULL) ? Success : Error;
3235
}
3336

34-
inline void RendererDestroy(IDirect3DRM2* pRenderer)
35-
{
36-
int refCount = pRenderer->Release();
37-
if (refCount <= 0) {
38-
g_pD3DRM = NULL;
39-
}
40-
}
41-
42-
// Inlined only
43-
void RendererImpl::Destroy()
44-
{
45-
if (m_data) {
46-
RendererDestroy(m_data);
47-
m_data = NULL;
48-
}
49-
}
50-
5137
// FUNCTION: LEGO1 0x100a1894
5238
Device* RendererImpl::CreateDevice(const DeviceDirect3DCreateData& data)
5339
{

0 commit comments

Comments
 (0)