Changeset View
Changeset View
Standalone View
Standalone View
source/graphics/MapWriter.cpp
/* Copyright (C) 2019 Wildfire Games. | /* Copyright (C) 2020 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
Show All 24 Lines | |||||
#include "ps/Loader.h" | #include "ps/Loader.h" | ||||
#include "ps/Filesystem.h" | #include "ps/Filesystem.h" | ||||
#include "ps/XML/XMLWriter.h" | #include "ps/XML/XMLWriter.h" | ||||
#include "renderer/PostprocManager.h" | #include "renderer/PostprocManager.h" | ||||
#include "renderer/SkyManager.h" | #include "renderer/SkyManager.h" | ||||
#include "renderer/WaterManager.h" | #include "renderer/WaterManager.h" | ||||
#include "simulation2/Simulation2.h" | #include "simulation2/Simulation2.h" | ||||
#include "simulation2/components/ICmpCinemaManager.h" | #include "simulation2/components/ICmpCinemaManager.h" | ||||
#include "simulation2/components/ICmpGarrisonHolder.h" | |||||
#include "simulation2/components/ICmpObstruction.h" | #include "simulation2/components/ICmpObstruction.h" | ||||
#include "simulation2/components/ICmpOwnership.h" | #include "simulation2/components/ICmpOwnership.h" | ||||
#include "simulation2/components/ICmpPosition.h" | #include "simulation2/components/ICmpPosition.h" | ||||
#include "simulation2/components/ICmpTemplateManager.h" | #include "simulation2/components/ICmpTemplateManager.h" | ||||
#include "simulation2/components/ICmpVisual.h" | #include "simulation2/components/ICmpVisual.h" | ||||
#include "simulation2/components/ICmpWaterManager.h" | #include "simulation2/components/ICmpWaterManager.h" | ||||
/////////////////////////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
▲ Show 20 Lines • Show All 286 Lines • ▼ Show 20 Lines | if (!sim.GetStartupScript().empty()) | ||||
entityTag.Attribute("uid", ent); | entityTag.Attribute("uid", ent); | ||||
entityTag.Setting("Template", cmpTemplateManager->GetCurrentTemplateName(ent)); | entityTag.Setting("Template", cmpTemplateManager->GetCurrentTemplateName(ent)); | ||||
CmpPtr<ICmpOwnership> cmpOwnership(sim, ent); | CmpPtr<ICmpOwnership> cmpOwnership(sim, ent); | ||||
if (cmpOwnership) | if (cmpOwnership) | ||||
entityTag.Setting("Player", static_cast<int>(cmpOwnership->GetOwner())); | entityTag.Setting("Player", static_cast<int>(cmpOwnership->GetOwner())); | ||||
CmpPtr<ICmpGarrisonHolder> cmpGarrisonHolder(sim, ent); | |||||
if (cmpGarrisonHolder) | |||||
{ | |||||
XMLWriter_Element garrisonTag(xmlMapFile, "Garrison"); | |||||
std::vector<entity_id_t> garrison = cmpGarrisonHolder->GetEntities(); | |||||
for (const entity_id_t& garr_ent_id : garrison) | |||||
Stan: Range loop here too. | |||||
Done Inline Actions(entity_id_t& -> entity_id_t, supposedly copying an integer is faster than passing a reference to an integer, I guess because the former avoids a dereference operation and it means the value is copied into the current memory page) elexis: (entity_id_t& -> entity_id_t, supposedly copying an integer is faster than passing a reference… | |||||
{ | |||||
Done Inline ActionsHow to convert the set to an array which can be saved in the tag? Freagarach: How to convert the set to an array which can be saved in the tag? | |||||
XMLWriter_Element garrisonedEntityTag(xmlMapFile, "GarrisonedEntity"); | |||||
garrisonedEntityTag.Attribute("uid", static_cast<int>(garr_ent_id)); | |||||
// ToDo: We can store turret position as well. | |||||
} | |||||
} | |||||
CmpPtr<ICmpPosition> cmpPosition(sim, ent); | CmpPtr<ICmpPosition> cmpPosition(sim, ent); | ||||
if (cmpPosition) | if (cmpPosition) | ||||
{ | { | ||||
CFixedVector3D pos; | CFixedVector3D pos; | ||||
if (cmpPosition->IsInWorld()) | if (cmpPosition->IsInWorld()) | ||||
pos = cmpPosition->GetPosition(); | pos = cmpPosition->GetPosition(); | ||||
CFixedVector3D rot = cmpPosition->GetRotation(); | CFixedVector3D rot = cmpPosition->GetRotation(); | ||||
▲ Show 20 Lines • Show All 127 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Range loop here too.