Skip to content

Commit e64c4f5

Browse files
authored
INF parsing fixes for split seq blocks. (luciusDXL#588)
1. Add function mergeExistingInfItem() to scan for existing INF items with matching name and wallnum, then merge the newly added item's classData to the existing entry. This structures the data such that the INF editor UI can use these classes correctly. 2. Add s_levelInf.item.clear() to areas where it was needed. Item data was accumulating and ending up in strange places like exported TFL files.
1 parent fe2d97b commit e64c4f5

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

TheForceEngine/TFE_Editor/LevelEditor/levelEditorData.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@ namespace LevelEditor
508508
void levelClear()
509509
{
510510
// Clear the INF data.
511+
s_levelInf.item.clear();
511512
s_levelInf.elevator.clear();
512513
s_levelInf.teleport.clear();
513514
s_levelInf.trigger.clear();
@@ -529,6 +530,7 @@ namespace LevelEditor
529530
FileUtil::stripExtension(asset->name.c_str(), slotName);
530531

531532
// Clear the INF data.
533+
s_levelInf.item.clear();
532534
s_levelInf.elevator.clear();
533535
s_levelInf.teleport.clear();
534536
s_levelInf.trigger.clear();

TheForceEngine/TFE_Editor/LevelEditor/levelEditorInf.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,6 +1231,26 @@ namespace LevelEditor
12311231
return true;
12321232
}
12331233

1234+
void mergeExistingInfItem()
1235+
{
1236+
Editor_InfItem* last = &s_levelInf.item.back();
1237+
Editor_InfItem* item = s_levelInf.item.data();
1238+
for (s32 i = 0; i < (s32)s_levelInf.item.size() - 1; i++, item++) // -1: dont match self
1239+
{
1240+
if (item->name == last->name && item->wallNum == last->wallNum)
1241+
{
1242+
LE_WARNING("Merging INF item - Name: %s - Wall number: %d", last->name.c_str(), last->wallNum);
1243+
for (size_t j = 0; j < last->classData.size(); j++)
1244+
{
1245+
s_levelInf.item[i].classData.push_back(s_levelInf.item.back().classData[j]);
1246+
}
1247+
1248+
s_levelInf.item.pop_back();
1249+
return;
1250+
}
1251+
}
1252+
}
1253+
12341254
bool loadLevelInfFromAsset(const Asset* asset)
12351255
{
12361256
char infFile[TFE_MAX_PATH];
@@ -1454,6 +1474,9 @@ namespace LevelEditor
14541474
} // while (!seqEnd) - outer (Line Classes).
14551475
} break;
14561476
}
1477+
1478+
// Fix up sibling classes split over multiple seq blocks if we can
1479+
mergeExistingInfItem();
14571480
}
14581481

14591482
return true;

0 commit comments

Comments
 (0)