summary refs log tree commit diff stats
path: root/tools/mapedit/src/world.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/mapedit/src/world.cpp')
-rw-r--r--tools/mapedit/src/world.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/tools/mapedit/src/world.cpp b/tools/mapedit/src/world.cpp index 79f5a58..9983731 100644 --- a/tools/mapedit/src/world.cpp +++ b/tools/mapedit/src/world.cpp
@@ -94,6 +94,11 @@ World::World(std::string filename)
94 map->setTitle((char*) titleKey, false); 94 map->setTitle((char*) titleKey, false);
95 xmlFree(titleKey); 95 xmlFree(titleKey);
96 96
97 xmlChar* noiKey = xmlGetProp(node, (xmlChar*) "nextObject");
98 if (noiKey == 0) throw MapLoadException("map missing nextObject attribute");
99 map->setNextObjectIndex(atoi((char*) noiKey));
100 xmlFree(noiKey);
101
97 for (xmlNodePtr mapNode = node->xmlChildrenNode; mapNode != NULL; mapNode = mapNode->next) 102 for (xmlNodePtr mapNode = node->xmlChildrenNode; mapNode != NULL; mapNode = mapNode->next)
98 { 103 {
99 if (!xmlStrcmp(mapNode->name, (const xmlChar*) "environment")) 104 if (!xmlStrcmp(mapNode->name, (const xmlChar*) "environment"))
@@ -125,7 +130,12 @@ World::World(std::string filename)
125 int ypos = atoi((char*) yKey); 130 int ypos = atoi((char*) yKey);
126 xmlFree(yKey); 131 xmlFree(yKey);
127 132
128 auto data = std::make_shared<MapObjectEntry>(obj, xpos, ypos); 133 xmlChar* indexKey = xmlGetProp(mapNode, (const xmlChar*) "index");
134 if (indexKey == 0) throw MapLoadException("entity missing index attribute");
135 int objIndex = atoi((char*) indexKey);
136 xmlFree(indexKey);
137
138 auto data = std::make_shared<MapObjectEntry>(obj, xpos, ypos, objIndex);
129 139
130 map->addObject(data, false); 140 map->addObject(data, false);
131 141
@@ -312,6 +322,10 @@ void World::save(std::string name, wxTreeCtrl* mapTree)
312 // title= 322 // title=
313 rc = xmlTextWriterWriteAttribute(writer, (xmlChar*) "title", (xmlChar*) map.getTitle().c_str()); 323 rc = xmlTextWriterWriteAttribute(writer, (xmlChar*) "title", (xmlChar*) map.getTitle().c_str());
314 if (rc < 0) throw MapWriteException(name); 324 if (rc < 0) throw MapWriteException(name);
325
326 // nextObject=
327 rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "nextObject", "%zu", map.getNextObjectIndex());
328 if (rc < 0) throw MapWriteException(name);
315 329
316 // <environment 330 // <environment
317 rc = xmlTextWriterStartElement(writer, (xmlChar*) "environment"); 331 rc = xmlTextWriterStartElement(writer, (xmlChar*) "environment");
@@ -358,6 +372,10 @@ void World::save(std::string name, wxTreeCtrl* mapTree)
358 rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "y", "%d", object->getPosition().second); 372 rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "y", "%d", object->getPosition().second);
359 if (rc < 0) throw MapWriteException(name); 373 if (rc < 0) throw MapWriteException(name);
360 374
375 // index=
376 rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "index", "%zu", object->getIndex());
377 if (rc < 0) throw MapWriteException(name);
378
361 for (auto item : object->getItems()) 379 for (auto item : object->getItems())
362 { 380 {
363 // <item 381 // <item