mirror of
https://github.com/worldforge/cyphesis
synced 2026-08-13 12:26:04 -04:00
All IG code should use the interface of LocatedEntity when dealing with any entity, rather than sometimes requiring Entity. Add virtual functions to the interface where required, and modify all other interfaces to stop them using Entity. This makes the code way cleaner, and much better de-coupled.
89 lines
2.4 KiB
C++
89 lines
2.4 KiB
C++
// Cyphesis Online RPG Server and AI Engine
|
|
// Copyright (C) 2008 Alistair Riddoch
|
|
//
|
|
// This program is free software; you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program; if not, write to the Free Software Foundation,
|
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
// $Id$
|
|
|
|
#ifndef SERVER_STORAGE_MANAGER_H
|
|
#define SERVER_STORAGE_MANAGER_H
|
|
|
|
#include <modules/EntityRef.h>
|
|
|
|
#include <deque>
|
|
#include <string>
|
|
|
|
class Entity;
|
|
class WorldRouter;
|
|
class PropertyBase;
|
|
|
|
/// \brief StorageManager represents the subsystem which stores world storage
|
|
///
|
|
/// This class has one instance which is the core of the world's persistent
|
|
/// storage in whatever data store is being used.
|
|
class StorageManager {
|
|
protected:
|
|
typedef std::deque<EntityRef> Entitystore;
|
|
typedef std::deque<long> Idstore;
|
|
|
|
/// \brief Queue of references to entities yet to be stored.
|
|
Entitystore m_unstoredEntities;
|
|
|
|
/// \brief Queue of references to entities with modifications.
|
|
Entitystore m_dirtyEntities;
|
|
|
|
/// \brief Queue of IDs of entities that are destroyed
|
|
Idstore m_destroyedEntities;
|
|
|
|
int m_insertEntityCount;
|
|
int m_updateEntityCount;
|
|
|
|
int m_insertPropertyCount;
|
|
int m_updatePropertyCount;
|
|
|
|
int m_insertQps;
|
|
int m_updateQps;
|
|
|
|
int m_insertQpsNow;
|
|
int m_updateQpsNow;
|
|
|
|
int m_insertQpsAvg;
|
|
int m_updateQpsAvg;
|
|
|
|
int m_insertQpsIndex;
|
|
int m_updateQpsIndex;
|
|
|
|
int m_insertQpsRing[32];
|
|
int m_updateQpsRing[32];
|
|
|
|
void entityInserted(LocatedEntity *);
|
|
void entityUpdated(LocatedEntity *);
|
|
|
|
void encodeProperty(PropertyBase *, std::string &);
|
|
void restoreProperties(LocatedEntity *);
|
|
|
|
void insertEntity(LocatedEntity *);
|
|
void updateEntity(LocatedEntity *);
|
|
void restoreChildren(LocatedEntity *);
|
|
|
|
public:
|
|
StorageManager(WorldRouter &);
|
|
|
|
void tick();
|
|
int initWorld();
|
|
int restoreWorld();
|
|
};
|
|
|
|
#endif // SERVER_STORAGE_MANAGER_H
|