load/save current status (no terrain/object data save here)
| 1680 | f.close(); |
| 1681 | } |
| 1682 | |
| 1683 | // load/save current status (no terrain/object data save here) |
| 1684 | LSError 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) |
nothing calls this directly
no test coverage detected