Alternative approach to MinGW compatibility

This commit is contained in:
MattKC 2023-07-01 08:00:09 -07:00 committed by Anonymous Maarten
parent 5bf7f1e57a
commit fd848fa096
5 changed files with 20 additions and 22 deletions

14
LEGO1/compat.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef ISLECOMPAT_H
#define ISLECOMPAT_H
// Various macros to enable compiling with other/newer compilers.
// Use `COMPAT_CONST` where something ought to be 'const', and a newer compiler would complain if it
// wasn't, but we know it isn't 'const' in the original code.
#ifdef __MINGW32__
#define COMPAT_CONST const
#else
#define COMPAT_CONST
#endif
#endif // ISLECOMPAT_H

View File

@ -176,19 +176,12 @@ void LegoOmni::Init()
}
// OFFSET: LEGO1 0x10058e70
MxResult LegoOmni::Create(MxOmniCreateParam &p)
MxResult LegoOmni::Create(COMPAT_CONST MxOmniCreateParam &p)
{
// FIXME: Stub
return SUCCESS;
}
#if defined(__MINGW32__)
MxResult LegoOmni::Create(const MxOmniCreateParam &p)
{
return Create((MxOmniCreateParam &)p);
}
#endif
void LegoOmni::Destroy()
{
// FIXME: Stub

View File

@ -1,6 +1,7 @@
#ifndef LEGOOMNI_H
#define LEGOOMNI_H
#include "compat.h"
#include "legoentity.h"
#include "legoinputmanager.h"
#include "legogamestate.h"
@ -51,7 +52,7 @@ class LegoOmni : public MxOmni
}
virtual void Init(); // vtable+14
virtual MxResult Create(MxOmniCreateParam &p); // vtable+18
virtual MxResult Create(COMPAT_CONST MxOmniCreateParam &p); // vtable+18
virtual void Destroy(); // vtable+1c
virtual void vtable20();
virtual void vtable24(MxDSAction &ds);
@ -63,10 +64,6 @@ class LegoOmni : public MxOmni
virtual void vtable3c();
virtual unsigned char vtable40();
#if defined(__MINGW32__)
virtual MxResult Create(const MxOmniCreateParam &p); // vtable+18
#endif
LegoVideoManager *GetVideoManager() { return (LegoVideoManager *) m_videoManager; }
LegoSoundManager *GetSoundManager() { return (LegoSoundManager *)m_soundManager;}
MxBackgroundAudioManager *GetBackgroundAudioManager() { return m_bkgAudioManager; }

View File

@ -17,7 +17,7 @@ MxVideoParam::MxVideoParam()
}
// OFFSET: LEGO1 0x100beca0
MxVideoParam::MxVideoParam(MxRect32 &p_rect, MxPalette *p_pal, unsigned long p_backBuffers, MxVideoParamFlags &p_flags)
MxVideoParam::MxVideoParam(COMPAT_CONST MxRect32 &p_rect, MxPalette *p_pal, unsigned long p_backBuffers, COMPAT_CONST MxVideoParamFlags &p_flags)
{
this->m_rect.m_left = p_rect.m_left;
this->m_rect.m_top = p_rect.m_top;

View File

@ -3,6 +3,7 @@
#include <ddraw.h>
#include "compat.h"
#include "mxpalette.h"
#include "mxrect32.h"
#include "mxtypes.h"
@ -14,17 +15,10 @@ class MxVideoParam
public:
__declspec(dllexport) MxVideoParam();
__declspec(dllexport) MxVideoParam(MxVideoParam &);
__declspec(dllexport) MxVideoParam(MxRect32 &rect, MxPalette *pal, unsigned long p3, MxVideoParamFlags &flags);
__declspec(dllexport) MxVideoParam(COMPAT_CONST MxRect32 &rect, MxPalette *pal, unsigned long p3, COMPAT_CONST MxVideoParamFlags &flags);
__declspec(dllexport) MxVideoParam &operator=(const MxVideoParam &);
__declspec(dllexport) ~MxVideoParam();
#ifdef __MINGW32__
__declspec(dllexport) MxVideoParam(const MxRect32 &rect, MxPalette *pal, unsigned long p3, const MxVideoParamFlags &flags)
: MxVideoParam((MxRect32 &)rect, pal, p3, (MxVideoParamFlags &)flags)
{
}
#endif
__declspec(dllexport) void SetDeviceName(char *id);
inline MxVideoParamFlags &flags() { return m_flags; }