MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / ExtractFlatList

Function ExtractFlatList

Source/XML/level_loader.cpp:269–283  ·  view source on GitHub ↗

Finds entity IDs that are used more than once, and replaces repeats with -1 so they will be automatically reassigned

Source from the content-addressed store, hash-verified

267
268// Finds entity IDs that are used more than once, and replaces repeats with -1 so they will be automatically reassigned
269static void ExtractFlatList(EntityDescriptionList* desc_list, std::vector<IDAndType>& id_used) {
270 uint32_t counter = 1; // Zero is assigned to the terrain
271 // bool print_results = false;
272 for (auto& it : *desc_list) {
273 id_used.resize(id_used.size() + 1);
274 IDAndType* id_and_type = &id_used.back();
275 id_and_type->desc = &it;
276 id_and_type->desc->GetEditableField(EDF_ENTITY_TYPE)->ReadInt((int*)&id_and_type->type);
277 id_and_type->desc->GetEditableField(EDF_ID)->ReadInt(&id_and_type->id);
278 id_and_type->counter = counter++;
279 if (!id_and_type->desc->children.empty()) {
280 ExtractFlatList(&id_and_type->desc->children, id_used);
281 }
282 }
283}
284
285static void SetDescID(EntityDescription* desc, int id) {
286 EntityDescriptionField* edf = desc->GetEditableField(EDF_ID);

Callers 1

FixDuplicateIDsFunction · 0.85

Calls 6

GetEditableFieldMethod · 0.80
resizeMethod · 0.45
sizeMethod · 0.45
backMethod · 0.45
ReadIntMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected