mirror of
https://github.com/isledecomp/isle.git
synced 2026-02-02 21:21:16 +00:00
LegoEntity parse action string
This commit is contained in:
parent
e341afd411
commit
9375677f88
21
LEGO1/extra.h
Normal file
21
LEGO1/extra.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef EXTRA_H
|
||||
#define EXTRA_H
|
||||
|
||||
// Items related to the Extra string of key-value pairs found in MxOb
|
||||
|
||||
enum ExtraActionType
|
||||
{
|
||||
ExtraActionType_opendisk = 1,
|
||||
ExtraActionType_openram = 2,
|
||||
ExtraActionType_close = 3,
|
||||
ExtraActionType_start = 4,
|
||||
ExtraActionType_stop = 5,
|
||||
ExtraActionType_run = 6,
|
||||
ExtraActionType_exit = 7,
|
||||
ExtraActionType_enable = 8,
|
||||
ExtraActionType_disable = 9,
|
||||
ExtraActionType_notify = 10,
|
||||
ExtraActionType_unknown = 11,
|
||||
};
|
||||
|
||||
#endif // EXTRA_H
|
||||
@ -1,7 +1,13 @@
|
||||
#include "legoentity.h"
|
||||
|
||||
#include "legoomni.h"
|
||||
#include "legoutil.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(LegoEntity, 0x68)
|
||||
|
||||
// 0x10102040
|
||||
char *g_strACTION = "ACTION";
|
||||
|
||||
// OFFSET: LEGO1 0x1000c290
|
||||
LegoEntity::~LegoEntity()
|
||||
{
|
||||
@ -16,8 +22,37 @@ MxLong LegoEntity::Notify(MxParam &p)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// OFFSET: LEGO1 0x100107e0 STUB
|
||||
void LegoEntity::vtable18()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// OFFSET: LEGO1 0x10010810 STUB
|
||||
void LegoEntity::Destroy()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
// OFFSET: LEGO1 0x10010e10
|
||||
void LegoEntity::ParseAction(char *p_extra)
|
||||
{
|
||||
char copy[1024];
|
||||
char actionValue[1024];
|
||||
strcpy(copy, p_extra);
|
||||
|
||||
if (KeyValueStringParse(actionValue, g_strACTION, copy)) {
|
||||
m_actionType = MatchActionString(strtok(actionValue, g_parseExtraTokens));
|
||||
|
||||
if (m_actionType != ExtraActionType_exit) {
|
||||
char *token = strtok(NULL, g_parseExtraTokens);
|
||||
|
||||
m_actionArgString = new char[strlen(token) + 1];
|
||||
strcpy(m_actionArgString, token);
|
||||
|
||||
if (m_actionType != ExtraActionType_run) {
|
||||
m_actionArgNumber = atoi(strtok(NULL, g_parseExtraTokens));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#define LEGOENTITY_H
|
||||
|
||||
#include "mxentity.h"
|
||||
#include "extra.h"
|
||||
|
||||
// VTABLE 0x100d4858
|
||||
// SIZE 0x68 (probably)
|
||||
@ -31,7 +32,16 @@ class LegoEntity : public MxEntity
|
||||
return !strcmp(name, LegoEntity::ClassName()) || MxEntity::IsA(name);
|
||||
}
|
||||
|
||||
virtual void vtable18(); // vtable+0x18
|
||||
virtual void Destroy() override; // vtable+0x1c
|
||||
virtual void ParseAction(char *); // vtable+0x20
|
||||
|
||||
protected:
|
||||
// For tokens from the extra string that look like this:
|
||||
// "Action:openram;\lego\scripts\Race\CarRaceR;0"
|
||||
ExtraActionType m_actionType; // 0x5c
|
||||
char *m_actionArgString; // 0x60
|
||||
MxS32 m_actionArgNumber; // 0x64
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -2,6 +2,36 @@
|
||||
|
||||
#include "mxtypes.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
// OFFSET: LEGO1 0x1003e300
|
||||
ExtraActionType MatchActionString(const char *p_str) {
|
||||
ExtraActionType result = ExtraActionType_unknown;
|
||||
|
||||
if (!strcmpi("openram", p_str))
|
||||
result = ExtraActionType_openram;
|
||||
else if (!strcmpi("opendisk", p_str))
|
||||
result = ExtraActionType_opendisk;
|
||||
else if (!strcmpi("close", p_str))
|
||||
result = ExtraActionType_close;
|
||||
else if (!strcmpi("start", p_str))
|
||||
result = ExtraActionType_start;
|
||||
else if (!strcmpi("stop", p_str))
|
||||
result = ExtraActionType_stop;
|
||||
else if (!strcmpi("run", p_str))
|
||||
result = ExtraActionType_run;
|
||||
else if (!strcmpi("exit", p_str))
|
||||
result = ExtraActionType_exit;
|
||||
else if (!strcmpi("enable", p_str))
|
||||
result = ExtraActionType_enable;
|
||||
else if (!strcmpi("disable", p_str))
|
||||
result = ExtraActionType_disable;
|
||||
else if (!strcmpi("notify", p_str))
|
||||
result = ExtraActionType_notify;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// OFFSET: LEGO1 0x1003eae0
|
||||
void ConvertHSVToRGB(float h, float s, float v, float *r_out, float *b_out, float *g_out)
|
||||
{
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
#ifndef LEGOUTIL_H
|
||||
#define LEGOUTIL_H
|
||||
|
||||
#include "extra.h"
|
||||
|
||||
template <class T>
|
||||
inline T Abs(T p_t)
|
||||
{
|
||||
@ -19,6 +21,7 @@ inline T Max(T p_t1, T p_t2)
|
||||
return p_t1 > p_t2 ? p_t1 : p_t2;
|
||||
}
|
||||
|
||||
ExtraActionType MatchActionString(const char *);
|
||||
void ConvertHSVToRGB(float r, float g, float b, float* out_r, float* out_g, float* out_b);
|
||||
|
||||
#endif // LEGOUTIL_H
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#include "mxentity.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(MxEntity, 0x68)
|
||||
// DECOMP_SIZE_ASSERT(MxEntity, 0x68)
|
||||
|
||||
// OFFSET: LEGO1 0x1001d190
|
||||
MxEntity::MxEntity()
|
||||
|
||||
@ -31,7 +31,7 @@ class MxEntity : public MxCore
|
||||
private:
|
||||
MxS32 m_mxEntityId; // 0x8
|
||||
MxAtomId m_atom; // 0xc
|
||||
undefined m_unk10[0x58];
|
||||
undefined m_unk10[76];
|
||||
};
|
||||
|
||||
#endif // MXENTITY_H
|
||||
|
||||
@ -85,5 +85,6 @@ class MxPresenter : public MxCore
|
||||
};
|
||||
|
||||
char *PresenterNameDispatch(const MxDSAction &);
|
||||
extern char *g_parseExtraTokens;
|
||||
|
||||
#endif // MXPRESENTER_H
|
||||
|
||||
Loading…
Reference in New Issue
Block a user