Skip to content

Commit

Permalink
Fix Script Indenting and GeoLayout BranchAndLink to NULL (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
inspectredc authored Jun 14, 2024
1 parent aa95f29 commit 61a6215
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/factories/sm64/BehaviorScriptFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 << "(";
Expand Down
9 changes: 7 additions & 2 deletions src/factories/sm64/GeoLayoutFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 << "(";
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions src/factories/sm64/LevelScriptFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 << "(";
Expand Down

0 comments on commit 61a6215

Please sign in to comment.