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