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

View file

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

View file

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

View file

@ -28,12 +28,15 @@ void LegoActorPresenter::StartingTickle()
// FUNCTION: LEGO1 0x10076cc0
void LegoActorPresenter::ParseExtra()
{
char buffer[512];
char* extraData = m_action->GetExtraData();
if (m_action->GetExtraLength()) {
memcpy(buffer, extraData, m_action->GetExtraLength());
buffer[m_action->GetExtraLength()] = 0;
MxU16 extraLength;
char* extraData;
m_action->GetExtra(extraLength, extraData);
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
void LegoEntityPresenter::ParseExtra()
{
char data[512];
MxU16 len = m_action->GetExtraLength();
if (len) {
memcpy(data, m_action->GetExtraData(), len);
data[len] = 0;
MxU16 extraLength;
char* extraData;
m_action->GetExtra(extraLength, extraData);
len &= MAXWORD;
m_entity->ParseAction(data);
if (extraLength & MAXWORD) {
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
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
void LegoWorldPresenter::ParseExtra()
{
char data[1024];
char output[1024];
MxU16 len = m_action->GetExtraLength();
*((MxU16*) &data[0]) = m_action->GetExtraLength();
if (len != 0) {
memcpy(data, m_action->GetExtraData(), len);
data[len] = 0;
MxU16 extraLength;
char* extraData;
m_action->GetExtra(extraLength, extraData);
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);
LoadWorld(worldKey, (LegoWorld*) m_entity);
((LegoWorld*) m_entity)->SetScriptIndex(Lego()->GetScriptIndex(worldKey));

View file

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

View file

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

View file

@ -57,6 +57,12 @@ class MxDSAction : public MxDSObject {
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 void SetFlags(MxU32 p_flags) { m_flags = p_flags; }
inline char* GetExtraData() { return m_extraData; }

View file

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

View file

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

View file

@ -198,29 +198,27 @@ void MxStillPresenter::ParseExtra()
SetBit3(TRUE);
}
MxU32 len = m_action->GetExtraLength();
MxU16 extraLength;
char* extraData;
m_action->GetExtra(extraLength, extraData);
if (len == 0) {
return;
}
if (extraLength & MAXWORD) {
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];
if (KeyValueStringParse(output, g_strVISIBILITY, buf)) {
if (strcmpi(output, "FALSE") == 0) {
Enable(FALSE);
char output[512];
if (KeyValueStringParse(output, g_strVISIBILITY, extraCopy)) {
if (strcmpi(output, "FALSE") == 0) {
Enable(FALSE);
}
}
}
if (KeyValueStringParse(output, g_strBmpIsmap, buf)) {
SetBit4(TRUE);
SetBit1(FALSE);
SetBit2(FALSE);
if (KeyValueStringParse(output, g_strBmpIsmap, extraCopy)) {
SetBit4(TRUE);
SetBit1(FALSE);
SetBit2(FALSE);
}
}
}