MTROPOLIS: Add another variable reference hack to fix Hispaniola not transitioning to night in MTI

This commit is contained in:
elasota 2023-06-13 00:10:23 -04:00
parent cc0cc74a87
commit 464834000f
3 changed files with 34 additions and 1 deletions

View File

@ -2770,6 +2770,16 @@ Modifier *CompoundVariableModifier::findChildByName(Runtime *runtime, const Comm
if (modifier)
return modifier;
}
if (myName.size() == 1 && myName == "g") {
if (caseInsensitiveEqual(name, "choresdone") || caseInsensitiveEqual(name, "donechore")) {
Project *project = runtime->getProject();
Modifier *modifier = project->findGlobalVarWithName(MTropolis::toCaseInsensitive(name)).get();
if (modifier)
return modifier;
}
}
}
for (Common::Array<Common::SharedPtr<Modifier> >::const_iterator it = _children.begin(), itEnd = _children.end(); it != itEnd; ++it) {
@ -2814,10 +2824,20 @@ CompoundVariableModifier::SaveLoad::SaveLoad(Runtime *runtime, CompoundVariableM
break;
}
}
}
for (const Common::SharedPtr<Modifier> &child : modifier->_children) {
if (isMTIHackGlobalContainer) {
bool loadFromGlobal = false;
if (isMTIHackGlobalContainer)
loadFromGlobal = true;
else if (isMTIHackG) {
// Hack to fix Hispaniola not transitioning to night
loadFromGlobal = caseInsensitiveEqual(child->getName(), "choresdone") || caseInsensitiveEqual(child->getName(), "donechore");
}
if (loadFromGlobal) {
Common::SharedPtr<Modifier> globalVarModifier = runtime->getProject()->findGlobalVarWithName(child->getName());
if (globalVarModifier) {

View File

@ -9324,6 +9324,15 @@ DynamicValueWriteProxy VariableModifier::createWriteProxy() {
return proxy;
}
#ifdef MTROPOLIS_DEBUG_ENABLE
void VariableModifier::debugInspect(IDebugInspectionReport *report) const {
Modifier::debugInspect(report);
if (report->declareStatic("storage"))
report->declareStaticContents(Common::String::format("%p", _storage.get()));
}
#endif
MiniscriptInstructionOutcome VariableModifier::WriteProxyInterface::write(MiniscriptThread *thread, const DynamicValue &dest, void *objectRef, uintptr ptrOrOffset) {
if (!static_cast<VariableModifier *>(objectRef)->varSetValue(thread, dest))
return kMiniscriptInstructionOutcomeFailed;

View File

@ -3010,6 +3010,10 @@ public:
virtual DynamicValueWriteProxy createWriteProxy();
#ifdef MTROPOLIS_DEBUG_ENABLE
void debugInspect(IDebugInspectionReport *report) const override;
#endif
private:
VariableModifier() = delete;