MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / save

Method save

src/Savegame/Craft.cpp:205–241  ·  view source on GitHub ↗

* Saves the craft to a YAML file. * @return YAML node. */

Source from the content-addressed store, hash-verified

203 * @return YAML node.
204 */
205YAML::Node Craft::save() const
206{
207 YAML::Node node = MovingTarget::save();
208 node["type"] = _rules->getType();
209 node["id"] = _id;
210 node["fuel"] = _fuel;
211 node["damage"] = _damage;
212 for (std::vector<CraftWeapon*>::const_iterator i = _weapons.begin(); i != _weapons.end(); ++i)
213 {
214 YAML::Node subnode;
215 if (*i != 0)
216 {
217 subnode = (*i)->save();
218 }
219 else
220 {
221 subnode["type"] = "0";
222 }
223 node["weapons"].push_back(subnode);
224 }
225 node["items"] = _items->save();
226 for (std::vector<Vehicle*>::const_iterator i = _vehicles.begin(); i != _vehicles.end(); ++i)
227 {
228 node["vehicles"].push_back((*i)->save());
229 }
230 node["status"] = _status;
231 if (_lowFuel)
232 node["lowFuel"] = _lowFuel;
233 if (_inBattlescape)
234 node["inBattlescape"] = _inBattlescape;
235 node["interceptionOrder"] = _interceptionOrder;
236 if (_takeoff != 0)
237 node["takeoff"] = _takeoff;
238 if (!_name.empty())
239 node["name"] = Language::wstrToUtf8(_name);
240 return node;
241}
242
243/**
244 * Saves the craft's unique identifiers to a YAML file.

Callers

nothing calls this directly

Calls 3

saveFunction · 0.85
getTypeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected