Match ParseExtra functions (#605)

* Match ParseExtra functions

* Match MxStillPresenter::ParseExtra

* Match remaining ParseExtra functions
This commit is contained in:
Christian Semmler 2024-02-29 13:15:20 -05:00 committed by GitHub
parent ff04b0ba5a
commit 49d6c88912
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 133 additions and 111 deletions

View file

@ -3,6 +3,8 @@
#include "legoentitypresenter.h" #include "legoentitypresenter.h"
class LegoWorld;
// VTABLE: LEGO1 0x100d8ee0 // VTABLE: LEGO1 0x100d8ee0
// SIZE 0x54 // SIZE 0x54
class LegoWorldPresenter : public LegoEntityPresenter { class LegoWorldPresenter : public LegoEntityPresenter {
@ -31,6 +33,8 @@ class LegoWorldPresenter : public LegoEntityPresenter {
MxResult StartAction(MxStreamController* p_controller, MxDSAction* p_action) override; // vtable+0x3c MxResult StartAction(MxStreamController* p_controller, MxDSAction* p_action) override; // vtable+0x3c
void VTable0x60(MxPresenter* p_presenter) override; // vtable+0x60 void VTable0x60(MxPresenter* p_presenter) override; // vtable+0x60
void LoadWorld(char* p_worldName, LegoWorld* p_world);
// SYNTHETIC: LEGO1 0x10066750 // SYNTHETIC: LEGO1 0x10066750
// LegoWorldPresenter::`scalar deleting destructor' // LegoWorldPresenter::`scalar deleting destructor'

View file

@ -78,24 +78,23 @@ void LegoActionControlPresenter::Destroy(MxBool p_fromDestructor)
// FUNCTION: LEGO1 0x10043e50 // FUNCTION: LEGO1 0x10043e50
void LegoActionControlPresenter::ParseExtra() void LegoActionControlPresenter::ParseExtra()
{ {
MxU32 len = m_action->GetExtraLength(); MxU16 extraLength;
char* extraData;
m_action->GetExtra(extraLength, extraData);
if (len == 0) { if (extraLength & MAXWORD) {
return; char extraCopy[1024];
} memcpy(extraCopy, extraData, extraLength & MAXWORD);
extraCopy[extraLength & MAXWORD] = '\0';
len &= MAXWORD;
char buf[1024];
memcpy(buf, m_action->GetExtraData(), len);
buf[len] = '\0';
char output[1024]; char output[1024];
if (KeyValueStringParse(output, g_strACTION, buf)) { if (KeyValueStringParse(output, g_strACTION, extraCopy)) {
m_unk0x50 = MatchActionString(strtok(output, g_parseExtraTokens)); m_unk0x50 = MatchActionString(strtok(output, g_parseExtraTokens));
if (m_unk0x50 != Extra::ActionType::e_exit) { if (m_unk0x50 != Extra::ActionType::e_exit) {
MakeSourceName(buf, strtok(NULL, g_parseExtraTokens)); MakeSourceName(extraCopy, strtok(NULL, g_parseExtraTokens));
m_unk0x54 = buf;
m_unk0x54 = extraCopy;
m_unk0x54.ToLowerCase(); m_unk0x54.ToLowerCase();
if (m_unk0x50 != Extra::ActionType::e_run) { if (m_unk0x50 != Extra::ActionType::e_run) {
m_unk0x64 = atoi(strtok(NULL, g_parseExtraTokens)); m_unk0x64 = atoi(strtok(NULL, g_parseExtraTokens));
@ -103,3 +102,4 @@ void LegoActionControlPresenter::ParseExtra()
} }
} }
} }
}

View file

@ -255,15 +255,19 @@ void MxControlPresenter::ReadyTickle()
// FUNCTION: LEGO1 0x10044640 // FUNCTION: LEGO1 0x10044640
void MxControlPresenter::ParseExtra() void MxControlPresenter::ParseExtra()
{ {
char result[256]; MxU16 extraLength;
MxU16 len = m_action->GetExtraLength(); char* extraData;
if (len) { m_action->GetExtra(extraLength, extraData);
char buffer[256];
memcpy(buffer, m_action->GetExtraData(), m_action->GetExtraLength()); if (extraLength & MAXWORD) {
buffer[len] = 0; char extraCopy[256];
memcpy(extraCopy, extraData, extraLength & MAXWORD);
extraCopy[extraLength & MAXWORD] = '\0';
char output[256];
if (KeyValueStringParse(output, g_style, extraCopy)) {
char* str = strtok(output, g_parseExtraTokens);
if (KeyValueStringParse(result, g_style, buffer)) {
char* str = strtok(result, g_parseExtraTokens);
if (!strcmpi(str, g_toggle)) { if (!strcmpi(str, g_toggle)) {
m_unk0x4c = 1; m_unk0x4c = 1;
} }
@ -275,10 +279,12 @@ void MxControlPresenter::ParseExtra()
else if (!strcmpi(str, g_map)) { else if (!strcmpi(str, g_map)) {
m_unk0x4c = 3; m_unk0x4c = 3;
str = strtok(NULL, g_parseExtraTokens); str = strtok(NULL, g_parseExtraTokens);
if (str) { if (str) {
MxS16 count = atoi(str); MxS16 count = atoi(str);
m_unk0x58 = new MxS16[count + 1]; m_unk0x58 = new MxS16[count + 1];
*m_unk0x58 = count; *m_unk0x58 = count;
for (MxS16 i = 1; i <= count; i++) { for (MxS16 i = 1; i <= count; i++) {
m_unk0x58[i] = atoi(strtok(NULL, g_parseExtraTokens)); m_unk0x58[i] = atoi(strtok(NULL, g_parseExtraTokens));
} }
@ -289,8 +295,8 @@ void MxControlPresenter::ParseExtra()
} }
} }
if (KeyValueStringParse(result, g_strVISIBILITY, buffer)) { if (KeyValueStringParse(output, g_strVISIBILITY, extraCopy)) {
if (!strcmpi(result, "FALSE")) { if (!strcmpi(output, "FALSE")) {
Enable(FALSE); Enable(FALSE);
} }
} }

View file

@ -28,12 +28,15 @@ void LegoActorPresenter::StartingTickle()
// FUNCTION: LEGO1 0x10076cc0 // FUNCTION: LEGO1 0x10076cc0
void LegoActorPresenter::ParseExtra() void LegoActorPresenter::ParseExtra()
{ {
char buffer[512]; MxU16 extraLength;
char* extraData = m_action->GetExtraData(); char* extraData;
if (m_action->GetExtraLength()) { m_action->GetExtra(extraLength, extraData);
memcpy(buffer, extraData, m_action->GetExtraLength());
buffer[m_action->GetExtraLength()] = 0;
m_entity->ParseAction(buffer); if (extraLength & MAXWORD) {
char extraCopy[512];
memcpy(extraCopy, extraData, extraLength & MAXWORD);
extraCopy[extraLength & MAXWORD] = '\0';
m_entity->ParseAction(extraCopy);
} }
} }

View file

@ -96,13 +96,15 @@ void LegoEntityPresenter::SetEntityLocation(
// FUNCTION: LEGO1 0x10053750 // FUNCTION: LEGO1 0x10053750
void LegoEntityPresenter::ParseExtra() void LegoEntityPresenter::ParseExtra()
{ {
char data[512]; MxU16 extraLength;
MxU16 len = m_action->GetExtraLength(); char* extraData;
if (len) { m_action->GetExtra(extraLength, extraData);
memcpy(data, m_action->GetExtraData(), len);
data[len] = 0;
len &= MAXWORD; if (extraLength & MAXWORD) {
m_entity->ParseAction(data); char extraCopy[512];
memcpy(extraCopy, extraData, extraLength & MAXWORD);
extraCopy[extraLength & MAXWORD] = '\0';
m_entity->ParseAction(extraCopy);
} }
} }

View file

@ -150,7 +150,7 @@ void LegoWorldPresenter::StartingTickle()
} }
// STUB: LEGO1 0x10066b40 // STUB: LEGO1 0x10066b40
void LoadWorld(char* p_worldName, LegoWorld* p_world) void LegoWorldPresenter::LoadWorld(char* p_worldName, LegoWorld* p_world)
{ {
} }
@ -180,15 +180,17 @@ void LegoWorldPresenter::VTable0x60(MxPresenter* p_presenter)
// FUNCTION: LEGO1 0x10067b00 // FUNCTION: LEGO1 0x10067b00
void LegoWorldPresenter::ParseExtra() void LegoWorldPresenter::ParseExtra()
{ {
char data[1024]; MxU16 extraLength;
char output[1024]; char* extraData;
MxU16 len = m_action->GetExtraLength(); m_action->GetExtra(extraLength, extraData);
*((MxU16*) &data[0]) = m_action->GetExtraLength();
if (len != 0) {
memcpy(data, m_action->GetExtraData(), len);
data[len] = 0;
if (KeyValueStringParse(output, g_strWORLD, data)) { if (extraLength & MAXWORD) {
char extraCopy[1024];
memcpy(extraCopy, extraData, extraLength & MAXWORD);
extraCopy[extraLength & MAXWORD] = '\0';
char output[1024];
if (KeyValueStringParse(output, g_strWORLD, extraCopy)) {
char* worldKey = strtok(output, g_parseExtraTokens); char* worldKey = strtok(output, g_parseExtraTokens);
LoadWorld(worldKey, (LegoWorld*) m_entity); LoadWorld(worldKey, (LegoWorld*) m_entity);
((LegoWorld*) m_entity)->SetScriptIndex(Lego()->GetScriptIndex(worldKey)); ((LegoWorld*) m_entity)->SetScriptIndex(Lego()->GetScriptIndex(worldKey));

View file

@ -53,39 +53,39 @@ LegoMeterPresenter::~LegoMeterPresenter()
// FUNCTION: LEGO1 0x10043800 // FUNCTION: LEGO1 0x10043800
void LegoMeterPresenter::ParseExtra() void LegoMeterPresenter::ParseExtra()
{ {
char buffer[256];
MxStillPresenter::ParseExtra(); MxStillPresenter::ParseExtra();
*((MxU16*) &buffer[0]) = m_action->GetExtraLength();
char* extraData = m_action->GetExtraData();
if (*((MxU16*) &buffer[0])) { MxU16 extraLength;
MxU16 len = *((MxU16*) &buffer[0]); char* extraData;
memcpy(buffer, extraData, len); m_action->GetExtra(extraLength, extraData);
buffer[len] = '\0';
char result[256]; if (extraLength & MAXWORD) {
if (KeyValueStringParse(buffer, g_type, result)) { char extraCopy[256];
if (!strcmpi(result, g_leftToRight)) { memcpy(extraCopy, extraData, extraLength & MAXWORD);
extraCopy[extraLength & MAXWORD] = '\0';
char output[256];
if (KeyValueStringParse(extraCopy, g_type, output)) {
if (!strcmpi(output, g_leftToRight)) {
m_layout = 0; m_layout = 0;
} }
else if (!strcmpi(result, g_rightToLeft)) { else if (!strcmpi(output, g_rightToLeft)) {
m_layout = 1; m_layout = 1;
} }
else if (!strcmpi(result, g_bottomToTop)) { else if (!strcmpi(output, g_bottomToTop)) {
m_layout = 2; m_layout = 2;
} }
else if (!strcmpi(result, g_topToBottom)) { else if (!strcmpi(output, g_topToBottom)) {
m_layout = 3; m_layout = 3;
} }
} }
if (KeyValueStringParse(buffer, g_filterIndex, result)) { if (KeyValueStringParse(extraCopy, g_filterIndex, output)) {
m_type = atoi(result); m_type = atoi(output);
} }
if (KeyValueStringParse(buffer, g_variable, result)) { if (KeyValueStringParse(extraCopy, g_variable, output)) {
m_variable = result; m_variable = output;
} }
else { else {
EndAction(); EndAction();

View file

@ -260,25 +260,25 @@ void LegoModelPresenter::ReadyTickle()
// FUNCTION: LEGO1 0x100801b0 // FUNCTION: LEGO1 0x100801b0
void LegoModelPresenter::ParseExtra() void LegoModelPresenter::ParseExtra()
{ {
char output[1024]; MxU16 extraLength;
char* extraData;
m_action->GetExtra(extraLength, extraData);
MxU16 len = m_action->GetExtraLength(); if (extraLength & MAXWORD) {
char* extraData = m_action->GetExtraData(); char extraCopy[1024], output[1024];
output[0] = '\0';
memcpy(extraCopy, extraData, extraLength & MAXWORD);
extraCopy[extraLength & MAXWORD] = '\0';
if (len != 0) { if (KeyValueStringParse(output, g_autoCreate, extraCopy) != 0) {
char buffer[1024];
output[0] = 0;
memcpy(buffer, extraData, len);
buffer[len] = 0;
if (KeyValueStringParse(output, g_autoCreate, buffer) != 0) {
char* token = strtok(output, g_parseExtraTokens); char* token = strtok(output, g_parseExtraTokens);
if (m_roi == NULL) { if (m_roi == NULL) {
m_roi = UnkSaveDataWriter()->FUN_10083500(token, FALSE); m_roi = UnkSaveDataWriter()->FUN_10083500(token, FALSE);
m_addedToView = FALSE; m_addedToView = FALSE;
} }
} }
else if (KeyValueStringParse(output, g_dbCreate, buffer) != 0 && m_roi == NULL) { else if (KeyValueStringParse(output, g_dbCreate, extraCopy) != 0 && m_roi == NULL) {
LegoWorld* currentWorld = CurrentWorld(); LegoWorld* currentWorld = CurrentWorld();
list<LegoROI*>& roiList = currentWorld->GetUnknownList0xe0(); list<LegoROI*>& roiList = currentWorld->GetUnknownList0xe0();

View file

@ -57,6 +57,12 @@ class MxDSAction : public MxDSObject {
void AppendData(MxU16 p_extraLength, const char* p_extraData); void AppendData(MxU16 p_extraLength, const char* p_extraData);
inline void GetExtra(MxU16& p_extraLength, char*& p_extraData)
{
p_extraLength = m_extraLength;
p_extraData = m_extraData;
}
inline MxU32 GetFlags() { return m_flags; } inline MxU32 GetFlags() { return m_flags; }
inline void SetFlags(MxU32 p_flags) { m_flags = p_flags; } inline void SetFlags(MxU32 p_flags) { m_flags = p_flags; }
inline char* GetExtraData() { return m_extraData; } inline char* GetExtraData() { return m_extraData; }

View file

@ -322,16 +322,16 @@ void MxWavePresenter::Enable(MxBool p_enable)
// FUNCTION: LEGO1 0x100b23a0 // FUNCTION: LEGO1 0x100b23a0
void MxWavePresenter::ParseExtra() void MxWavePresenter::ParseExtra()
{ {
char extraCopy[512];
MxSoundPresenter::ParseExtra(); MxSoundPresenter::ParseExtra();
*((MxU16*) &extraCopy[0]) = m_action->GetExtraLength();
char* extraData = m_action->GetExtraData();
if (*((MxU16*) &extraCopy[0])) { MxU16 extraLength;
MxU16 len = *((MxU16*) &extraCopy[0]); char* extraData;
memcpy(extraCopy, extraData, len); m_action->GetExtra(extraLength, extraData);
extraCopy[len] = '\0';
if (extraLength & MAXWORD) {
char extraCopy[512];
memcpy(extraCopy, extraData, extraLength & MAXWORD);
extraCopy[extraLength & MAXWORD] = '\0';
char soundValue[512]; char soundValue[512];
if (KeyValueStringParse(soundValue, g_strSOUND, extraCopy)) { if (KeyValueStringParse(soundValue, g_strSOUND, extraCopy)) {

View file

@ -78,14 +78,15 @@ void MxPresenter::EndAction()
void MxPresenter::ParseExtra() void MxPresenter::ParseExtra()
{ {
MxAutoLocker lock(&m_criticalSection); MxAutoLocker lock(&m_criticalSection);
MxU16 len = m_action->GetExtraLength();
char* extraData = m_action->GetExtraData();
if (len) { MxU16 extraLength;
// len &= MAXWORD; char* extraData;
m_action->GetExtra(extraLength, extraData);
if (extraLength & MAXWORD) {
char extraCopy[512]; char extraCopy[512];
memcpy(extraCopy, extraData, len); memcpy(extraCopy, extraData, extraLength & MAXWORD);
extraCopy[len] = '\0'; extraCopy[extraLength & MAXWORD] = '\0';
char worldValue[512]; char worldValue[512];
if (KeyValueStringParse(worldValue, g_strWORLD, extraCopy)) { if (KeyValueStringParse(worldValue, g_strWORLD, extraCopy)) {

View file

@ -198,31 +198,29 @@ void MxStillPresenter::ParseExtra()
SetBit3(TRUE); SetBit3(TRUE);
} }
MxU32 len = m_action->GetExtraLength(); MxU16 extraLength;
char* extraData;
m_action->GetExtra(extraLength, extraData);
if (len == 0) { if (extraLength & MAXWORD) {
return; char extraCopy[512];
} memcpy(extraCopy, extraData, extraLength & MAXWORD);
extraCopy[extraLength & MAXWORD] = '\0';
len &= MAXWORD;
char buf[512];
memcpy(buf, m_action->GetExtraData(), len);
buf[len] = '\0';
char output[512]; char output[512];
if (KeyValueStringParse(output, g_strVISIBILITY, buf)) { if (KeyValueStringParse(output, g_strVISIBILITY, extraCopy)) {
if (strcmpi(output, "FALSE") == 0) { if (strcmpi(output, "FALSE") == 0) {
Enable(FALSE); Enable(FALSE);
} }
} }
if (KeyValueStringParse(output, g_strBmpIsmap, buf)) { if (KeyValueStringParse(output, g_strBmpIsmap, extraCopy)) {
SetBit4(TRUE); SetBit4(TRUE);
SetBit1(FALSE); SetBit1(FALSE);
SetBit2(FALSE); SetBit2(FALSE);
} }
} }
}
// FUNCTION: LEGO1 0x100ba2c0 // FUNCTION: LEGO1 0x100ba2c0
MxStillPresenter* MxStillPresenter::Clone() MxStillPresenter* MxStillPresenter::Clone()