3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "irrlichttypes_bloated.h"
29 class ServerActiveObject;
37 StaticObject() = default;
38 StaticObject(const ServerActiveObject *s_obj, const v3f &pos_);
40 void serialize(std::ostream &os) const;
41 void deSerialize(std::istream &is, u8 version);
44 class StaticObjectList
48 Inserts an object to the container.
49 Id must be unique (active) or 0 (stored).
51 void insert(u16 id, const StaticObject &obj)
54 m_stored.push_back(obj);
56 if (m_active.find(id) != m_active.end()) {
57 dstream << "ERROR: StaticObjectList::insert(): "
58 << "id already exists" << std::endl;
59 FATAL_ERROR("StaticObjectList::insert()");
67 assert(id != 0); // Pre-condition
68 if (m_active.find(id) == m_active.end()) {
69 warningstream << "StaticObjectList::remove(): id=" << id << " not found"
76 void serialize(std::ostream &os);
77 void deSerialize(std::istream &is);
79 // Never permit to modify outside of here. Only this object is responsible of m_stored and m_active modifications
80 const std::vector<StaticObject>& getAllStored() const { return m_stored; }
81 const std::map<u16, StaticObject> &getAllActives() const { return m_active; }
83 inline void setActive(u16 id, const StaticObject &obj) { m_active[id] = obj; }
84 inline size_t getActiveSize() const { return m_active.size(); }
85 inline size_t getStoredSize() const { return m_stored.size(); }
86 inline void clearStored() { m_stored.clear(); }
87 void pushStored(const StaticObject &obj) { m_stored.push_back(obj); }
89 bool storeActiveObject(u16 id);
99 return m_active.size() + m_stored.size();
104 NOTE: When an object is transformed to active, it is removed
105 from m_stored and inserted to m_active.
107 std::vector<StaticObject> m_stored;
108 std::map<u16, StaticObject> m_active;