diff options
| author | inspectredc <78732756+inspectredc@users.noreply.github.com> | 2024-06-14 14:12:39 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-14 07:12:39 -0600 |
| commit | 61a621576298eede67ce4be3a91f92bb37e853c1 (patch) | |
| tree | 0a931a29ed44785ebc54e1d54eb49c12350c92e3 /src | |
| parent | aa95f29be7b9c7b3190c738e17126ba360b3798c (diff) | |
Fix Script Indenting and GeoLayout BranchAndLink to NULL (#139)
Diffstat (limited to 'src')
| -rw-r--r-- | src/factories/sm64/BehaviorScriptFactory.cpp | 6 | ||||
| -rw-r--r-- | src/factories/sm64/GeoLayoutFactory.cpp | 9 | ||||
| -rw-r--r-- | src/factories/sm64/LevelScriptFactory.cpp | 6 |
3 files changed, 15 insertions, 6 deletions
diff --git a/src/factories/sm64/BehaviorScriptFactory.cpp b/src/factories/sm64/BehaviorScriptFactory.cpp index 953b1de..1033676 100644 --- a/src/factories/sm64/BehaviorScriptFactory.cpp +++ b/src/factories/sm64/BehaviorScriptFactory.cpp @@ -29,14 +29,16 @@ ExportResult SM64::BehaviorScriptCodeExporter::Export(std::ostream &write, std:: for(auto& [opcode, arguments] : commands) { bool commaFlag = false; + if (opcode == BehaviorOpcode::END_LOOP || opcode == BehaviorOpcode::END_REPEAT || opcode == BehaviorOpcode::END_REPEAT_CONTINUE) { + --indentCount; + } + for (uint32_t i = 0; i < indentCount; ++i) { write << fourSpaceTab; } if (opcode == BehaviorOpcode::BEGIN_LOOP || opcode == BehaviorOpcode::BEGIN_REPEAT) { ++indentCount; - } else if (opcode == BehaviorOpcode::END_LOOP || opcode == BehaviorOpcode::END_REPEAT || opcode == BehaviorOpcode::END_REPEAT_CONTINUE) { - --indentCount; } write << opcode << "("; diff --git a/src/factories/sm64/GeoLayoutFactory.cpp b/src/factories/sm64/GeoLayoutFactory.cpp index 4cb924e..ebe679c 100644 --- a/src/factories/sm64/GeoLayoutFactory.cpp +++ b/src/factories/sm64/GeoLayoutFactory.cpp @@ -68,14 +68,16 @@ ExportResult SM64::GeoCodeExporter::Export(std::ostream&write, std::shared_ptr<I for(auto& [opcode, arguments] : cmds) { bool commaFlag = false; + if (opcode == GeoOpcode::OpenNode) { + ++indentCount; + } + for (uint32_t i = 0; i < indentCount; ++i) { write << fourSpaceTab; } if (opcode == GeoOpcode::CloseNode) { --indentCount; - } else if (opcode == GeoOpcode::OpenNode) { - ++indentCount; } write << opcode << "("; @@ -324,6 +326,9 @@ std::optional<std::shared_ptr<IParsedData>> SM64::GeoLayoutFactory::parse(std::v switch(opcode){ case GeoOpcode::BranchAndLink: { auto ptr = cur_geo_cmd_u32(0x04); + if (ptr == 0) { + processing = false; + } arguments.emplace_back(RegisterAutoGen(ptr, "SM64:GEO_LAYOUT")); cmd += 0x08 << CMD_SIZE_SHIFT; diff --git a/src/factories/sm64/LevelScriptFactory.cpp b/src/factories/sm64/LevelScriptFactory.cpp index dc5e68e..c866a0a 100644 --- a/src/factories/sm64/LevelScriptFactory.cpp +++ b/src/factories/sm64/LevelScriptFactory.cpp @@ -43,14 +43,16 @@ ExportResult SM64::LevelScriptCodeExporter::Export(std::ostream &write, std::sha for(auto& [opcode, arguments] : commands) { bool commaFlag = false; + if (opcode == LevelOpcode::END_AREA) { + --indentCount; + } + for (uint32_t i = 0; i < indentCount; ++i) { write << fourSpaceTab; } if (opcode == LevelOpcode::AREA) { ++indentCount; - } else if (opcode == LevelOpcode::END_AREA) { - --indentCount; } write << opcode << "("; |
