Debian Codegraph @

plugins/dm.gameconnection/DiffDoom3MapWriter.cpp

raw
1 #include "DiffDoom3MapWriter.h"
2 #include "DiffStatus.h"
3
4 #include "ientity.h"
5
6 namespace gameconn
7 {
8
9 DiffDoom3MapWriter::DiffDoom3MapWriter(const std::map<std::string, DiffStatus>& statuses) :
10 _entityStatuses(statuses)
11 {}
12
13 void DiffDoom3MapWriter::beginWriteMap(const scene::IMapRootNodePtr& root, std::ostream& stream)
14 {}
15
16 void DiffDoom3MapWriter::endWriteMap(const scene::IMapRootNodePtr& root, std::ostream& stream)
17 {}
18
19 void DiffDoom3MapWriter::writeEntityPreamble(const std::string& name, std::ostream& stream) {
20 DiffStatus status = _entityStatuses.at(name);
21 assert(status.isModified());
22 const char* statusWord = "modify";
23 if (status.needsRespawn())
24 statusWord = "modify_respawn";
25 if (status.isAdded())
26 statusWord = "add";
27 if (status.isRemoved())
28 statusWord = "remove";
29 stream << statusWord << " entity" << std::endl;
30 }
31
32 void DiffDoom3MapWriter::writeRemoveEntityStub(const std::string& name, std::ostream& stream) {
33 writeEntityPreamble(name, stream);
34 stream << "{" << std::endl;
35 stream << "\"name\" \"" << name << "\"" << std::endl;
36 stream << "}" << std::endl;
37 }
38
39 void DiffDoom3MapWriter::beginWriteEntity(const IEntityNodePtr& entity, std::ostream& stream) {
40 const std::string& name = entity->name();
41 writeEntityPreamble(name, stream);
42 stream << "{" << std::endl;
43
44 // Entity key values
45 entity->getEntity().forEachKeyValue([&](const std::string& key, const std::string& value)
46 {
47 stream << "\"" << key << "\" \"" << value << "\"" << std::endl;
48 });
49 }
50
51 void DiffDoom3MapWriter::endWriteEntity(const IEntityNodePtr& entity, std::ostream& stream) {
52 stream << "}" << std::endl;
53 }
54
55 void DiffDoom3MapWriter::beginWriteBrush(const IBrushNodePtr&, std::ostream&)
56 {}
57
58 void DiffDoom3MapWriter::endWriteBrush(const IBrushNodePtr&, std::ostream&)
59 {}
60
61 void DiffDoom3MapWriter::beginWritePatch(const IPatchNodePtr&, std::ostream&)
62 {}
63
64 void DiffDoom3MapWriter::endWritePatch(const IPatchNodePtr&, std::ostream&)
65 {}
66
67 }