Move some classes to LegoOmni (#417)

This commit is contained in:
Christian Semmler 2024-01-08 06:45:07 -05:00 committed by GitHub
parent c47206617d
commit 091ecd5935
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 245 additions and 229 deletions

View file

@ -18,6 +18,7 @@ add_library(lego1 SHARED
LEGO1/lego/legoomni/src/audio/legocachesound.cpp
LEGO1/lego/legoomni/src/audio/legoloadcachesoundpresenter.cpp
LEGO1/lego/legoomni/src/audio/legosoundmanager.cpp
LEGO1/lego/legoomni/src/audio/mxbackgroundaudiomanager.cpp
LEGO1/lego/legoomni/src/build/buildingentity.cpp
LEGO1/lego/legoomni/src/build/dunebuggy.cpp
LEGO1/lego/legoomni/src/build/helicopter.cpp
@ -41,6 +42,7 @@ add_library(lego1 SHARED
LEGO1/lego/legoomni/src/common/legostream.cpp
LEGO1/lego/legoomni/src/common/legounksavedatawriter.cpp
LEGO1/lego/legoomni/src/common/legoutil.cpp
LEGO1/lego/legoomni/src/common/mxcompositemediapresenter.cpp
LEGO1/lego/legoomni/src/control/legocontrolmanager.cpp
LEGO1/lego/legoomni/src/entity/legoactor.cpp
LEGO1/lego/legoomni/src/entity/legoanimactor.cpp
@ -114,6 +116,7 @@ add_library(lego1 SHARED
LEGO1/lego/legoomni/src/video/legophonemepresenter.cpp
LEGO1/lego/legoomni/src/video/legotexturepresenter.cpp
LEGO1/lego/legoomni/src/video/legovideomanager.cpp
LEGO1/lego/legoomni/src/video/mxtransitionmanager.cpp
LEGO1/lego/sources/3dmanager/lego3dmanager.cpp
LEGO1/lego/sources/3dmanager/lego3dview.cpp
LEGO1/lego/sources/3dmanager/legoview1.cpp
@ -136,7 +139,6 @@ add_library(lego1 SHARED
LEGO1/omni/src/action/mxdsstreamingaction.cpp
LEGO1/omni/src/audio/mxaudiomanager.cpp
LEGO1/omni/src/audio/mxaudiopresenter.cpp
LEGO1/omni/src/audio/mxbackgroundaudiomanager.cpp
LEGO1/omni/src/audio/mxloopingmidipresenter.cpp
LEGO1/omni/src/audio/mxmidipresenter.cpp
LEGO1/omni/src/audio/mxmusicmanager.cpp
@ -146,7 +148,6 @@ add_library(lego1 SHARED
LEGO1/omni/src/audio/mxwavepresenter.cpp
LEGO1/omni/src/common/mxatomidcounter.cpp
LEGO1/omni/src/common/mxatomid.cpp
LEGO1/omni/src/common/mxcompositemediapresenter.cpp
LEGO1/omni/src/common/mxcompositepresenter.cpp
LEGO1/omni/src/common/mxcore.cpp
LEGO1/omni/src/common/mxmediamanager.cpp
@ -156,6 +157,7 @@ add_library(lego1 SHARED
LEGO1/omni/src/common/mxstring.cpp
LEGO1/omni/src/common/mxticklemanager.cpp
LEGO1/omni/src/common/mxtimer.cpp
LEGO1/omni/src/common/mxutil.cpp
LEGO1/omni/src/common/mxvariable.cpp
LEGO1/omni/src/common/mxvariabletable.cpp
LEGO1/omni/src/control/mxcontrolpresenter.cpp
@ -201,7 +203,6 @@ add_library(lego1 SHARED
LEGO1/omni/src/video/mxsmack.cpp
LEGO1/omni/src/video/mxsmkpresenter.cpp
LEGO1/omni/src/video/mxstillpresenter.cpp
LEGO1/omni/src/video/mxtransitionmanager.cpp
LEGO1/omni/src/video/mxvideomanager.cpp
LEGO1/omni/src/video/mxvideoparam.cpp
LEGO1/omni/src/video/mxvideoparamflags.cpp

View file

@ -140,15 +140,12 @@ class LegoOmni : public MxOmni {
};
__declspec(dllexport) MxBackgroundAudioManager* BackgroundAudioManager();
__declspec(dllexport) MxDSObject* CreateStreamObject(MxDSFile*, MxS16);
__declspec(dllexport) LegoGameState* GameState();
__declspec(dllexport) const char* GetNoCD_SourceName();
__declspec(dllexport) LegoInputManager* InputManager();
__declspec(dllexport) LegoOmni* Lego();
__declspec(dllexport) void MakeSourceName(char*, const char*);
__declspec(dllexport) LegoEntity* PickEntity(MxLong, MxLong);
__declspec(dllexport) LegoROI* PickROI(MxLong, MxLong);
__declspec(dllexport) void SetOmniUserMessage(void (*)(const char*, int));
__declspec(dllexport) LegoSoundManager* SoundManager();
__declspec(dllexport) MxResult Start(MxDSAction*);
__declspec(dllexport) MxTransitionManager* TransitionManager();
@ -159,26 +156,12 @@ LegoBuildingManager* BuildingManager();
LegoControlManager* ControlManager();
IslePathActor* GetCurrentVehicle();
LegoPlantManager* PlantManager();
MxBool KeyValueStringParse(char*, const char*, const char*);
LegoWorld* GetCurrentWorld();
GifManager* GetGifManager();
void FUN_10015820(MxU32, MxU32);
LegoEntity* FindEntityByAtomIdOrEntityId(const MxAtomId& p_atom, MxS32 p_entityid);
MxDSAction& GetCurrentAction();
MxBool FUN_100b6e10(
MxS32 p_bitmapWidth,
MxS32 p_bitmapHeight,
MxS32 p_videoParamWidth,
MxS32 p_videoParamHeight,
MxS32* p_left,
MxS32* p_top,
MxS32* p_right,
MxS32* p_bottom,
MxS32* p_width,
MxS32* p_height
);
void PlayMusic(MxU32 p_index);
void SetIsWorldActive(MxBool p_isWorldActive);
void RegisterScripts();

View file

@ -2,58 +2,13 @@
#define LEGOUTIL_H
#include "extra.h"
#include "legoentity.h"
#include "mxatomid.h"
#include "mxtypes.h"
#include "mxutil.h"
#include <windows.h>
template <class T>
inline T Abs(T p_t)
{
return p_t < 0 ? -p_t : p_t;
}
template <class T>
inline T Min(T p_t1, T p_t2)
{
return p_t1 < p_t2 ? p_t1 : p_t2;
}
template <class T>
inline T Max(T p_t1, T p_t2)
{
return p_t1 > p_t2 ? p_t1 : p_t2;
}
template <class T>
inline void GetScalar(MxU8** p_source, T& p_dest)
{
p_dest = *(T*) *p_source;
*p_source += sizeof(T);
}
template <class T>
inline T GetScalar(T** p_source)
{
T val = **p_source;
*p_source += 1;
return val;
}
template <class T>
inline void GetDouble(MxU8** p_source, T& p_dest)
{
p_dest = *(double*) *p_source;
*p_source += sizeof(double);
}
template <class T>
inline void GetString(MxU8** p_source, char** p_dest, T* p_obj, void (T::*p_setter)(const char*))
{
(p_obj->*p_setter)((char*) *p_source);
*p_source += strlen(*p_dest) + 1;
}
class MxAtomId;
class LegoEntity;
ExtraActionType MatchActionString(const char*);
void InvokeAction(ExtraActionType p_actionId, MxAtomId& p_pAtom, int p_targetEntityId, LegoEntity* p_sender);

View file

@ -111,9 +111,6 @@ MxAtomId* g_nocdSourceName = NULL;
// GLOBAL: LEGO1 0x100f6718
const char* g_current = "current";
// GLOBAL: LEGO1 0x101020e8
void (*g_omniUserMessage)(const char*, int);
// GLOBAL: LEGO1 0x100f4c58
MxBool g_isWorldActive = TRUE;
@ -694,144 +691,3 @@ MxResult Start(MxDSAction* p_dsAction)
{
return MxOmni::GetInstance()->Start(p_dsAction);
}
// Probably should be somewhere else
// FUNCTION: LEGO1 0x100b6e10
MxBool FUN_100b6e10(
MxS32 p_bitmapWidth,
MxS32 p_bitmapHeight,
MxS32 p_videoParamWidth,
MxS32 p_videoParamHeight,
MxS32* p_left,
MxS32* p_top,
MxS32* p_right,
MxS32* p_bottom,
MxS32* p_width,
MxS32* p_height
)
{
MxPoint32 topLeft(*p_left, *p_top);
MxRect32 bitmapRect(MxPoint32(0, 0), MxSize32(p_bitmapWidth, p_bitmapHeight));
MxPoint32 bottomRight(*p_right, *p_bottom);
MxRect32 videoParamRect(MxPoint32(0, 0), MxSize32(p_videoParamWidth, p_videoParamHeight));
MxRect32 rect(0, 0, *p_width, *p_height);
rect.AddPoint(topLeft);
if (!rect.IntersectsWith(bitmapRect))
return FALSE;
rect.Intersect(bitmapRect);
rect.SubtractPoint(topLeft);
rect.AddPoint(bottomRight);
if (!rect.IntersectsWith(videoParamRect))
return FALSE;
rect.Intersect(videoParamRect);
rect.SubtractPoint(bottomRight);
*p_left += rect.GetLeft();
*p_top += rect.GetTop();
*p_right += rect.GetLeft();
*p_bottom += rect.GetTop();
*p_width = rect.GetWidth();
*p_height = rect.GetHeight();
return TRUE;
}
// FUNCTION: LEGO1 0x100b6ff0
void MakeSourceName(char* p_output, const char* p_input)
{
const char* cln = strchr(p_input, ':');
if (cln) {
p_input = cln + 1;
}
strcpy(p_output, p_input);
strlwr(p_output);
char* extLoc = strstr(p_output, ".si");
if (extLoc) {
*extLoc = 0;
}
}
// FUNCTION: LEGO1 0x100b7050
MxBool KeyValueStringParse(char* p_outputValue, const char* p_key, const char* p_source)
{
MxBool didMatch = FALSE;
MxS16 len = strlen(p_source);
char* temp = new char[len + 1];
strcpy(temp, p_source);
char* token = strtok(temp, ", \t\r\n:");
while (token) {
len -= (strlen(token) + 1);
if (strcmpi(token, p_key) == 0) {
if (p_outputValue && len > 0) {
char* cur = &token[strlen(p_key)];
cur++;
while (*cur != ',') {
if (*cur == ' ' || *cur == '\0' || *cur == '\t' || *cur == '\n' || *cur == '\r')
break;
*p_outputValue++ = *cur++;
}
*p_outputValue = '\0';
}
didMatch = TRUE;
break;
}
token = strtok(NULL, ", \t\r\n:");
}
delete[] temp;
return didMatch;
}
// FUNCTION: LEGO1 0x100b7210
void SetOmniUserMessage(void (*p_userMsg)(const char*, int))
{
g_omniUserMessage = p_userMsg;
}
// FUNCTION: LEGO1 0x100c0280
MxDSObject* CreateStreamObject(MxDSFile* p_file, MxS16 p_ofs)
{
MxU8* buf;
_MMCKINFO tmpChunk;
if (p_file->Seek(((MxLong*) p_file->GetBuffer())[p_ofs], 0)) {
return NULL;
}
if (p_file->Read((MxU8*) &tmpChunk.ckid, 8) == 0 && tmpChunk.ckid == FOURCC('M', 'x', 'S', 't')) {
if (p_file->Read((MxU8*) &tmpChunk.ckid, 8) == 0 && tmpChunk.ckid == FOURCC('M', 'x', 'O', 'b')) {
buf = new MxU8[tmpChunk.cksize];
if (!buf) {
return NULL;
}
if (p_file->Read(buf, tmpChunk.cksize) != 0) {
return NULL;
}
// Save a copy so we can clean up properly, because
// this function will alter the pointer value.
MxU8* copy = buf;
MxDSObject* obj = DeserializeDSObjectDispatch(&buf, -1);
delete[] copy;
return obj;
}
return NULL;
}
return NULL;
}

View file

@ -0,0 +1,75 @@
#ifndef MXUTIL_H
#define MXUTIL_H
#include "mxtypes.h"
class MxDSFile;
class MxDSObject;
template <class T>
inline T Abs(T p_t)
{
return p_t < 0 ? -p_t : p_t;
}
template <class T>
inline T Min(T p_t1, T p_t2)
{
return p_t1 < p_t2 ? p_t1 : p_t2;
}
template <class T>
inline T Max(T p_t1, T p_t2)
{
return p_t1 > p_t2 ? p_t1 : p_t2;
}
template <class T>
inline void GetScalar(MxU8** p_source, T& p_dest)
{
p_dest = *(T*) *p_source;
*p_source += sizeof(T);
}
template <class T>
inline T GetScalar(T** p_source)
{
T val = **p_source;
*p_source += 1;
return val;
}
template <class T>
inline void GetDouble(MxU8** p_source, T& p_dest)
{
p_dest = *(double*) *p_source;
*p_source += sizeof(double);
}
template <class T>
inline void GetString(MxU8** p_source, char** p_dest, T* p_obj, void (T::*p_setter)(const char*))
{
(p_obj->*p_setter)((char*) *p_source);
*p_source += strlen(*p_dest) + 1;
}
MxBool FUN_100b6e10(
MxS32 p_bitmapWidth,
MxS32 p_bitmapHeight,
MxS32 p_videoParamWidth,
MxS32 p_videoParamHeight,
MxS32* p_left,
MxS32* p_top,
MxS32* p_right,
MxS32* p_bottom,
MxS32* p_width,
MxS32* p_height
);
__declspec(dllexport) void MakeSourceName(char*, const char*);
__declspec(dllexport) void SetOmniUserMessage(void (*)(const char*, int));
__declspec(dllexport) MxDSObject* CreateStreamObject(MxDSFile*, MxS16);
MxBool KeyValueStringParse(char*, const char*, const char*);
#endif // MXUTIL_H

View file

@ -1,8 +1,8 @@
#include "mxdsaction.h"
#include "legoutil.h"
#include "mxomni.h"
#include "mxtimer.h"
#include "mxutil.h"
#include <float.h>
#include <limits.h>

View file

@ -1,6 +1,6 @@
#include "mxdsmediaaction.h"
#include "legoutil.h"
#include "mxutil.h"
DECOMP_SIZE_ASSERT(MxDSMediaAction, 0xb8)

View file

@ -1,6 +1,5 @@
#include "mxdsobject.h"
#include "legoutil.h"
#include "mxdsaction.h"
#include "mxdsanim.h"
#include "mxdsevent.h"
@ -13,6 +12,7 @@
#include "mxdssound.h"
#include "mxdsstill.h"
#include "mxdstypes.h"
#include "mxutil.h"
#include <stdlib.h>
#include <string.h>

View file

@ -1,6 +1,6 @@
#include "mxdssound.h"
#include "legoutil.h"
#include "mxutil.h"
DECOMP_SIZE_ASSERT(MxDSSound, 0xc0)

View file

@ -1,7 +1,6 @@
#include "mxmidipresenter.h"
#include "decomp.h"
#include "legoomni.h"
#include "mxautolocker.h"
#include "mxdssound.h"
#include "mxmusicmanager.h"

View file

@ -2,11 +2,11 @@
#include "decomp.h"
#include "define.h"
#include "legoomni.h"
#include "mxautolocker.h"
#include "mxdssound.h"
#include "mxomni.h"
#include "mxsoundmanager.h"
#include "mxutil.h"
DECOMP_SIZE_ASSERT(MxWavePresenter, 0x6c);
DECOMP_SIZE_ASSERT(MxWavePresenter::WaveFormat, 0x1c);

View file

@ -2,8 +2,6 @@
#include "decomp.h"
#include "define.h"
#include "legoobjectfactory.h"
#include "legoomni.h"
#include "mxactionnotificationparam.h"
#include "mxautolocker.h"
#include "mxcompositepresenter.h"
@ -11,8 +9,10 @@
#include "mxdssound.h"
#include "mxentity.h"
#include "mxnotificationmanager.h"
#include "mxobjectfactory.h"
#include "mxparam.h"
#include "mxstreamer.h"
#include "mxutil.h"
#include <string.h>

View file

@ -0,0 +1,149 @@
#include "mxutil.h"
#include "mxdsfile.h"
#include "mxdsobject.h"
#include "mxrect32.h"
// GLOBAL: LEGO1 0x101020e8
void (*g_omniUserMessage)(const char*, int);
// FUNCTION: LEGO1 0x100b6e10
MxBool FUN_100b6e10(
MxS32 p_bitmapWidth,
MxS32 p_bitmapHeight,
MxS32 p_videoParamWidth,
MxS32 p_videoParamHeight,
MxS32* p_left,
MxS32* p_top,
MxS32* p_right,
MxS32* p_bottom,
MxS32* p_width,
MxS32* p_height
)
{
MxPoint32 topLeft(*p_left, *p_top);
MxRect32 bitmapRect(MxPoint32(0, 0), MxSize32(p_bitmapWidth, p_bitmapHeight));
MxPoint32 bottomRight(*p_right, *p_bottom);
MxRect32 videoParamRect(MxPoint32(0, 0), MxSize32(p_videoParamWidth, p_videoParamHeight));
MxRect32 rect(0, 0, *p_width, *p_height);
rect.AddPoint(topLeft);
if (!rect.IntersectsWith(bitmapRect))
return FALSE;
rect.Intersect(bitmapRect);
rect.SubtractPoint(topLeft);
rect.AddPoint(bottomRight);
if (!rect.IntersectsWith(videoParamRect))
return FALSE;
rect.Intersect(videoParamRect);
rect.SubtractPoint(bottomRight);
*p_left += rect.GetLeft();
*p_top += rect.GetTop();
*p_right += rect.GetLeft();
*p_bottom += rect.GetTop();
*p_width = rect.GetWidth();
*p_height = rect.GetHeight();
return TRUE;
}
// FUNCTION: LEGO1 0x100b6ff0
void MakeSourceName(char* p_output, const char* p_input)
{
const char* cln = strchr(p_input, ':');
if (cln) {
p_input = cln + 1;
}
strcpy(p_output, p_input);
strlwr(p_output);
char* extLoc = strstr(p_output, ".si");
if (extLoc) {
*extLoc = 0;
}
}
// FUNCTION: LEGO1 0x100b7050
MxBool KeyValueStringParse(char* p_outputValue, const char* p_key, const char* p_source)
{
MxBool didMatch = FALSE;
MxS16 len = strlen(p_source);
char* temp = new char[len + 1];
strcpy(temp, p_source);
char* token = strtok(temp, ", \t\r\n:");
while (token) {
len -= (strlen(token) + 1);
if (strcmpi(token, p_key) == 0) {
if (p_outputValue && len > 0) {
char* cur = &token[strlen(p_key)];
cur++;
while (*cur != ',') {
if (*cur == ' ' || *cur == '\0' || *cur == '\t' || *cur == '\n' || *cur == '\r')
break;
*p_outputValue++ = *cur++;
}
*p_outputValue = '\0';
}
didMatch = TRUE;
break;
}
token = strtok(NULL, ", \t\r\n:");
}
delete[] temp;
return didMatch;
}
// FUNCTION: LEGO1 0x100b7210
void SetOmniUserMessage(void (*p_userMsg)(const char*, int))
{
g_omniUserMessage = p_userMsg;
}
// Should probably be somewhere else
// FUNCTION: LEGO1 0x100c0280
MxDSObject* CreateStreamObject(MxDSFile* p_file, MxS16 p_ofs)
{
MxU8* buf;
_MMCKINFO tmpChunk;
if (p_file->Seek(((MxLong*) p_file->GetBuffer())[p_ofs], 0)) {
return NULL;
}
if (p_file->Read((MxU8*) &tmpChunk.ckid, 8) == 0 && tmpChunk.ckid == FOURCC('M', 'x', 'S', 't')) {
if (p_file->Read((MxU8*) &tmpChunk.ckid, 8) == 0 && tmpChunk.ckid == FOURCC('M', 'x', 'O', 'b')) {
buf = new MxU8[tmpChunk.cksize];
if (!buf) {
return NULL;
}
if (p_file->Read(buf, tmpChunk.cksize) != 0) {
return NULL;
}
// Save a copy so we can clean up properly, because
// this function will alter the pointer value.
MxU8* copy = buf;
MxDSObject* obj = DeserializeDSObjectDispatch(&buf, -1);
delete[] copy;
return obj;
}
return NULL;
}
return NULL;
}

View file

@ -1,6 +1,5 @@
#include "mxcontrolpresenter.h"
#include "legoomni.h"
#include "mxticklemanager.h"
DECOMP_SIZE_ASSERT(MxControlPresenter, 0x5c)

View file

@ -2,8 +2,8 @@
#include "compat.h"
#include "decomp.h"
#include "legoomni.h"
#include "mxautolocker.h"
#include "mxomni.h"
#include "mxparam.h"
#include "mxticklemanager.h"
#include "mxtypes.h"

View file

@ -1,8 +1,8 @@
#include "mxstreamchunk.h"
#include "legoutil.h"
#include "mxdsbuffer.h"
#include "mxstreamlist.h"
#include "mxutil.h"
// FUNCTION: LEGO1 0x100c2fe0
MxStreamChunk::~MxStreamChunk()

View file

@ -1,14 +1,14 @@
#include "mxstreamcontroller.h"
#include "legoomni.h"
#include "legoutil.h"
#include "mxautolocker.h"
#include "mxdsmultiaction.h"
#include "mxdsstreamingaction.h"
#include "mxnextactiondatastart.h"
#include "mxomni.h"
#include "mxstl/stlcompat.h"
#include "mxstreamchunk.h"
#include "mxtimer.h"
#include "mxutil.h"
DECOMP_SIZE_ASSERT(MxStreamController, 0x64)
DECOMP_SIZE_ASSERT(MxNextActionDataStart, 0x14)

View file

@ -1,8 +1,8 @@
#include "mxstreamer.h"
#include "legoomni.h"
#include "mxdiskstreamcontroller.h"
#include "mxnotificationmanager.h"
#include "mxomni.h"
#include "mxramstreamcontroller.h"
#include <algorithm>

View file

@ -1,6 +1,6 @@
#include "mxdisplaysurface.h"
#include "legoomni.h"
#include "mxutil.h"
#include "mxvideomanager.h"
#include <windows.h>

View file

@ -2,10 +2,10 @@
#include "decomp.h"
#include "define.h"
#include "legoomni.h"
#include "mxcompositepresenter.h"
#include "mxdsmediaaction.h"
#include "mxomni.h"
#include "mxutil.h"
#include "mxvideomanager.h"
DECOMP_SIZE_ASSERT(MxStillPresenter, 0x6c);

View file

@ -1,6 +1,5 @@
#include "mxvideomanager.h"
#include "legoomni.h"
#include "mxautolocker.h"
#include "mxpresenter.h"
#include "mxticklemanager.h"