MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / Serialize

Method Serialize

engine/Poseidon/World/Terrain/LandSave.cpp:1682–1752  ·  view source on GitHub ↗

load/save current status (no terrain/object data save here)

Source from the content-addressed store, hash-verified

1680 f.close();
1681}
1682
1683// load/save current status (no terrain/object data save here)
1684LSError Landscape::Serialize(ParamArchive& ar)
1685{
1686 PARAM_CHECK(ar.Serialize("lastObjectID", _objectId, 1))
1687 if (ar.IsSaving())
1688 {
1689 RefArray<Object> objects;
1690 for (int x = 0; x < _landRange; x++)
1691 {
1692 for (int z = 0; z < _landRange; z++)
1693 {
1694 const ObjectList& list = _objects(x, z);
1695 for (int o = 0; o < list.Size(); o++)
1696 {
1697 Object* obj = list[o];
1698 // do not save temporaries
1699 if (obj->GetType() != Primary && obj->GetType() != Network)
1700 {
1701 continue;
1702 }
1703 PoseidonAssert(obj->GetShape());
1704 PoseidonAssert(obj->GetShape()->Name());
1705 if (obj->ID() == 0)
1706 {
1707 Log("Object id %d %s", obj->ID(), (const char*)obj->GetShape()->Name());
1708 }
1709 if (!obj->MustBeSaved())
1710 {
1711 continue; // save only non-default states
1712 }
1713 objects.Add(obj);
1714 }
1715 }
1716 }
1717 PARAM_CHECK(ar.Serialize("Objects", objects, 1))
1718 }
1719 else if (ar.GetPass() == ParamArchive::PassSecond)
1720 {
1721 ParamArchive arCls;
1722 if (!ar.OpenSubclass("Objects", arCls))
1723 {
1724 return LSOK; // no objects saved
1725 }
1726 arCls.FirstPass();
1727 int n;
1728 PARAM_CHECK(arCls.Serialize("items", n, 1))
1729 for (int i = 0; i < n; i++)
1730 {
1731 char buffer[256];
1732 snprintf(buffer, sizeof(buffer), "Item%d", i);
1733 ParamArchive arRef;
1734 if (!arCls.OpenSubclass(buffer, arRef))
1735 {
1736 continue;
1737 }
1738 Object* obj = Object::CreateObject(arRef); // Find object in landscape
1739 if (!obj)

Callers

nothing calls this directly

Calls 13

GetPassMethod · 0.80
OpenSubclassMethod · 0.80
FirstPassMethod · 0.80
SecondPassMethod · 0.80
CloseSubclassMethod · 0.80
IsSavingMethod · 0.45
SizeMethod · 0.45
GetTypeMethod · 0.45
GetShapeMethod · 0.45
NameMethod · 0.45
IDMethod · 0.45
MustBeSavedMethod · 0.45

Tested by

no test coverage detected