persister cleanup

This commit is contained in:
DarthArgus
2016-12-15 03:00:59 +00:00
parent 76d08c50da
commit 18cb7d0e95
452 changed files with 1344 additions and 1532 deletions
@@ -25,7 +25,7 @@ class NetworkId;
namespace DB
{
typedef stdset<Tag>::fwd TagSet;
typedef std::set<Tag> TagSet;
}
// ======================================================================
@@ -34,14 +34,14 @@ void ConfigServerDatabase::install(void)
ConfigServerUtility::install();
data = &staticData;
KEY_INT (objvarNameCleanupTime, 10);
KEY_INT (orphanedObjectCleanupTime, 10);
KEY_INT (marketAttributesCleanupTime, 10);
KEY_INT (messagesCleanupTime, 10);
KEY_INT (brokenObjectCleanupTime, 10);
KEY_INT (vendorObjectCleanupTime, 10);
KEY_INT (objvarNameCleanupTime, 0);
KEY_INT (orphanedObjectCleanupTime, 0);
KEY_INT (marketAttributesCleanupTime, 0);
KEY_INT (messagesCleanupTime, 0);
KEY_INT (brokenObjectCleanupTime, 0);
KEY_INT (vendorObjectCleanupTime, 0);
KEY_STRING (customSQLFilename,"");
KEY_BOOL (enableFixBadCells, true);
KEY_BOOL (enableFixBadCells, false);
KEY_STRING (objectTemplateListUpdateFilename,"");
KEY_STRING (DSN,"gameserver");
@@ -56,7 +56,7 @@ void ConfigServerDatabase::install(void)
KEY_INT (taskManagerPort, 60001);
KEY_INT (expectedDBVersion, 270);
KEY_BOOL (correctDBVersionRequired,true);
KEY_INT (saveFrequencyLimit,1);
KEY_INT (saveFrequencyLimit,0);
KEY_STRING (schemaOwner, "");
KEY_STRING (goldSchemaOwner, "");
KEY_FLOAT (uniqueMessageCacheTimeSec, 30.0f);
@@ -50,7 +50,7 @@ class DatabaseProcess : public MessageDispatch::Receiver
// getters:
GameServerConnection * getConnectionByProcess(const uint32 processId);
void getGameServerProcessIds(stdvector<uint32>::fwd &processIds) const;
void getGameServerProcessIds(std::vector<uint32> &processIds) const;
uint32 getProcessId(void);
DB::Server *getDBServer(void);
const std::string &getClusterName() const;
@@ -27,7 +27,7 @@ public:
void clearChunkCompleteQueue();
private:
typedef stdvector<std::pair<int, int> >::fwd ChunkCompleteQueueType;
typedef std::vector<std::pair<int, int> > ChunkCompleteQueueType;
ChunkCompleteQueueType * const m_chunkCompleteQueue;
private:
@@ -28,7 +28,7 @@ class ImmediateDeleteCustomPersistStep : public CustomPersistStep
void addObject (const NetworkId &deletedObject);
private:
stdset<NetworkId>::fwd *m_objects; // using set instead of vector to enforce uniqueness
std::set<NetworkId> *m_objects; // using set instead of vector to enforce uniqueness
private:
ImmediateDeleteCustomPersistStep &operator= (const ImmediateDeleteCustomPersistStep&); //disable
@@ -53,8 +53,8 @@ class LazyDeleter
private:
static LazyDeleter *ms_instance;
Thread *m_workerThread;
stdvector<NetworkId>::fwd *m_incomingObjects;
stddeque<NetworkId>::fwd *m_objectsToDelete;
std::vector<NetworkId> *m_incomingObjects;
std::deque<NetworkId> *m_objectsToDelete;
Mutex *m_objectListLock;
bool m_shutdown;
bool m_paused;
@@ -27,7 +27,7 @@ class GameServerConnection;
class MessageToManager
{
public:
typedef stdvector<MessageToPayload>::fwd MessageVector;
typedef std::vector<MessageToPayload> MessageVector;
public:
static void install();
@@ -5,6 +5,8 @@
//
// ======================================================================
#include <memory>
#include "serverDatabase/FirstServerDatabase.h"
#include "serverDatabase/Persister.h"
@@ -174,33 +176,15 @@ Persister::~Persister()
{
DEBUG_FATAL(taskQueue,("Call shutdown() before deleting Persister.\n"));
for (auto i=m_currentSnapshots.begin(); i!=m_currentSnapshots.end(); ++i) {
ServerSnapshotMap::iterator i;
for (i=m_currentSnapshots.begin(); i!=m_currentSnapshots.end(); ++i)
delete i->second;
i->second = nullptr;
}
for (auto i=m_newObjectSnapshots.begin(); i!=m_newObjectSnapshots.end(); ++i) {
for (i=m_newObjectSnapshots.begin(); i!=m_newObjectSnapshots.end(); ++i)
delete i->second;
i->second = nullptr;
}
for (auto i=m_savingCharacterSnapshots.begin(); i!=m_savingCharacterSnapshots.end(); ++i) {
delete *i;
*i = nullptr;
}
for (auto i=m_savingSnapshots.begin(); i!=m_savingSnapshots.end(); ++i) {
delete *i;
*i = nullptr;
}
m_currentSnapshots.clear();
m_newObjectSnapshots.clear();
m_objectSnapshotMap.clear();
m_savingCharacterSnapshots.clear();
m_savingSnapshots.clear();
m_messageSnapshot = nullptr;
m_commoditiesSnapshot = nullptr;
m_arbitraryGameDataSnapshot = nullptr;
@@ -235,18 +219,14 @@ void Persister::onFrameBarrierReached()
if (m_newCharacterTaskQueue->getNumPendingTasks() == 0)
{
ServerSnapshotMap delayedSaves;
for (ServerSnapshotMap::iterator i=m_newCharacterSnapshots.begin(); i!=m_newCharacterSnapshots.end(); ++i)
{
if (m_newCharacterLock.find(i->first)==m_newCharacterLock.end())
{
DEBUG_REPORT_LOG(ConfigServerDatabase::getReportSaveTimes(),("Starting new character save\n"));
if (i->second != nullptr) {
m_savingCharacterSnapshots.push_back(i->second);
m_newCharacterTaskQueue->asyncRequest(new TaskSaveSnapshot(i->second));
}
m_savingCharacterSnapshots.push_back(i->second);
m_newCharacterTaskQueue->asyncRequest(new TaskSaveSnapshot(i->second));
for (ObjectSnapshotMap::iterator obj=m_objectSnapshotMap.begin(); obj!=m_objectSnapshotMap.end();)
{
if (obj->second == i->second)
@@ -265,7 +245,8 @@ void Persister::onFrameBarrierReached()
}
// Check for whether it is time to save
FATAL(m_timeSinceLastSave > ConfigServerDatabase::getMaxTimewarp(),("Save was not completed within %i seconds. We may experience a \"time warp\"\n",ConfigServerDatabase::getMaxTimewarp()));
FATAL(m_timeSinceLastSave > ConfigServerDatabase::getMaxTimewarp(),("Save was not completed within %i seconds. Shutting down to avoid a longer timewarp.\n",ConfigServerDatabase::getMaxTimewarp()));
if (ConfigServerDatabase::getSaveAtModulus()!=-1)
{
@@ -329,7 +310,7 @@ void Persister::startSave(void)
for (CharactersToDeleteType::const_iterator iter = m_charactersToDeleteThisSaveCycle->begin(); iter != m_charactersToDeleteThisSaveCycle->end(); ++iter)
{
DeleteCharacterCustomPersistStep *cps = new DeleteCharacterCustomPersistStep(iter->first, iter->second);
getSnapshotForObject(iter->second, 0).addCustomPersistStep(cps);
getSnapshotForObject(iter->second, 0)->addCustomPersistStep(cps);
}
// if this is the final save before the cluster is brought down,
@@ -340,7 +321,7 @@ void Persister::startSave(void)
for (CharactersToDeleteType::const_iterator iter2 = m_charactersToDeleteNextSaveCycle->begin(); iter2 != m_charactersToDeleteNextSaveCycle->end(); ++iter2)
{
DeleteCharacterCustomPersistStep *cps = new DeleteCharacterCustomPersistStep(iter2->first, iter2->second);
getSnapshotForObject(iter2->second, 0).addCustomPersistStep(cps);
getSnapshotForObject(iter2->second, 0)->addCustomPersistStep(cps);
}
}
}
@@ -353,19 +334,14 @@ void Persister::startSave(void)
ServerSnapshotMap::iterator i;
for (i=m_currentSnapshots.begin(); i!=m_currentSnapshots.end(); ++i)
{
if (i->second != nullptr) {
m_savingSnapshots.push_back(i->second);
taskQueue->asyncRequest(new TaskSaveSnapshot(i->second));
}
m_savingSnapshots.push_back(i->second);
taskQueue->asyncRequest(new TaskSaveSnapshot(i->second));
}
for (i=m_newObjectSnapshots.begin(); i!=m_newObjectSnapshots.end(); ++i)
{
if (i->second != nullptr) {
m_savingSnapshots.push_back(i->second);
taskQueue->asyncRequest(new TaskSaveSnapshot(i->second));
}
}
{
m_savingSnapshots.push_back(i->second);
taskQueue->asyncRequest(new TaskSaveSnapshot(i->second));
}
// nothing changed so send a complete message for the shutdown process
if( m_savingSnapshots.empty() )
@@ -407,18 +383,18 @@ void Persister::startSave(void)
* the first time we've seen the object, remember which snapshot we
* decided to use for it.)
*/
Snapshot & Persister::getSnapshotForObject(const NetworkId &networkId, uint32 serverId)
Snapshot * Persister::getSnapshotForObject(const NetworkId &networkId, uint32 serverId)
{
ObjectSnapshotMap::const_iterator i=m_objectSnapshotMap.find(networkId);
if (i!=m_objectSnapshotMap.end())
{
NOT_NULL(i->second);
return *(i->second);
return i->second;
}
else
{
Snapshot &snap = getSnapshotForServer(serverId);
m_objectSnapshotMap[networkId]=&snap;
Snapshot *snap = getSnapshotForServer(serverId);
m_objectSnapshotMap[networkId]=snap;
return snap;
}
}
@@ -433,7 +409,7 @@ bool Persister::hasDataForObject(const NetworkId &objectId) const
// ----------------------------------------------------------------------
Snapshot & Persister::getSnapshotForServer(uint32 serverId)
Snapshot *Persister::getSnapshotForServer(uint32 serverId)
{
if (serverId==0)
{
@@ -442,7 +418,7 @@ Snapshot & Persister::getSnapshotForServer(uint32 serverId)
m_arbitraryGameDataSnapshot = makeSnapshot(DB::ModeQuery::mode_UPDATE);
m_currentSnapshots[0] = m_arbitraryGameDataSnapshot;
}
return *m_arbitraryGameDataSnapshot;
return m_arbitraryGameDataSnapshot;
}
else
{
@@ -454,23 +430,23 @@ Snapshot & Persister::getSnapshotForServer(uint32 serverId)
m_currentSnapshots[serverId]=snap;
if (!m_arbitraryGameDataSnapshot)
m_arbitraryGameDataSnapshot = snap;
return *snap;
return snap;
}
else
{
NOT_NULL (j->second);
return *(j->second);
return j->second;
}
}
}
// ----------------------------------------------------------------------
Snapshot & Persister::getCommoditiesSnapshot(uint32 serverId)
Snapshot *Persister::getCommoditiesSnapshot(uint32 serverId)
{
if (m_commoditiesSnapshot)
{
return *m_commoditiesSnapshot;
return m_commoditiesSnapshot;
}
else
{
@@ -483,13 +459,13 @@ Snapshot & Persister::getCommoditiesSnapshot(uint32 serverId)
Snapshot *snap = makeCommoditiesSnapshot(DB::ModeQuery::mode_INSERT);
m_currentSnapshots[serverId]=snap;
m_commoditiesSnapshot = snap;
return *snap;
return snap;
}
else
{
NOT_NULL (j->second);
m_commoditiesSnapshot = j->second;
return *(j->second);
return j->second;
}
}
}
@@ -500,7 +476,7 @@ void Persister::handleDeltasMessage(uint32 serverId, const DeltasMessage &msg)
{
NetworkId objectId=msg.getTarget();
// DEBUG_REPORT_LOG(true,("Got deltas message for object %s.\n",objectId.getValueString().c_str()));
getSnapshotForObject(objectId,serverId).handleDeltasMessage(objectId, msg);
getSnapshotForObject(objectId,serverId)->handleDeltasMessage(objectId, msg);
}
// ----------------------------------------------------------------------
@@ -510,7 +486,7 @@ void Persister::handleBaselinesMessage(uint32 serverId, const BaselinesMessage &
// DEBUG_REPORT_LOG(true,("Got baselines message.\n"));
NetworkId objectId=msg.getTarget();
getSnapshotForObject(objectId,serverId).handleBaselinesMessage(objectId, msg);
getSnapshotForObject(objectId,serverId)->handleBaselinesMessage(objectId, msg);
}
// ----------------------------------------------------------------------
@@ -521,7 +497,7 @@ void Persister::handleBaselinesMessage(uint32 serverId, const BaselinesMessage &
void Persister::handleDeleteMessage(uint32 serverId, const NetworkId &objectId, int reasonCode, bool immediate, bool demandLoadedContainer, bool cascadeReason)
{
getSnapshotForObject(objectId,serverId).handleDeleteMessage(objectId, reasonCode, immediate, demandLoadedContainer, cascadeReason);
getSnapshotForObject(objectId,serverId)->handleDeleteMessage(objectId, reasonCode, immediate, demandLoadedContainer, cascadeReason);
}
// ----------------------------------------------------------------------
@@ -619,48 +595,22 @@ void Persister::endBaselines(const NetworkId &objectId, uint32 serverId)
// ----------------------------------------------------------------------
void Persister::nukeOrphans() {
if (m_completedSnapshots.size() > 0) {
int completeCount = m_completedSnapshots.size();
int snapshotClassCount = (*m_completedSnapshots.begin())->getPendingCount();
WARNING(true, ("%i snapshots done, snapshot class reports %i currently allocated", completeCount, snapshotClassCount));
if (snapshotClassCount > 5) {
delmutex.lock();
for (auto i = m_completedSnapshots.begin(); i != m_completedSnapshots.end(); ++i) {
if (i != m_completedSnapshots.end() && *i != nullptr && !(*i)->getIsBeingSaved() && completeCount > 5) {
WARNING(true, ("Deleting orphaned snapshot"));
delete (*i);
*i = nullptr;
i = m_completedSnapshots.erase(i);
completeCount--;
} else {
break;
}
}
delmutex.unlock();
}
}
}
/**
* Called by TaskSaveSnapshot when it finishes.
*/
void Persister::saveCompleted(Snapshot *completedSnapshot)
{
nukeOrphans();
auto i=std::remove(m_savingSnapshots.begin(),m_savingSnapshots.end(),completedSnapshot);
SnapshotListType::iterator i=std::remove(m_savingSnapshots.begin(),m_savingSnapshots.end(),completedSnapshot);
if (i!=m_savingSnapshots.end())
{
m_savingSnapshots.erase(i, m_savingSnapshots.end());
if (completedSnapshot != nullptr) {
delete completedSnapshot;
completedSnapshot = nullptr;
}
if (m_savingSnapshots.empty() && ConfigServerDatabase::getReportSaveTimes())
{
int saveTime = Clock::timeMs() - m_saveStartTime;
@@ -671,9 +621,11 @@ void Persister::saveCompleted(Snapshot *completedSnapshot)
DEBUG_REPORT_LOG(true,("Save completed in %i. (Average %i, max %i)\n", saveTime, m_totalSaveTime/m_saveCount, m_maxSaveTime));
LOG("SaveTimes",("Save completed in %i. (Average %i, max %i)", saveTime, m_totalSaveTime/m_saveCount, m_maxSaveTime));
m_lastSaveTime = saveTime;
}
if (m_savingSnapshots.empty())
if (m_savingSnapshots.empty())
{
// message Central Server that the current save cycle is complete
GenericValueTypeMessage<int> const saveCompleteMessage("DatabaseSaveComplete", ++m_saveCounter);
@@ -689,26 +641,22 @@ void Persister::saveCompleted(Snapshot *completedSnapshot)
}
else
{
auto j=std::remove(m_savingCharacterSnapshots.begin(),m_savingCharacterSnapshots.end(),completedSnapshot);
if (j != m_savingCharacterSnapshots.end()) {
m_savingCharacterSnapshots.erase(j, m_savingCharacterSnapshots.end());
} else {
DEBUG_WARNING(true,("saveCompleted called w/o snap in m_savingSnapshots or m_savingCharacterSnapshots."));
SnapshotListType::iterator j=std::remove(m_savingCharacterSnapshots.begin(),m_savingCharacterSnapshots.end(),completedSnapshot);
DEBUG_FATAL(i==m_savingCharacterSnapshots.end(),("Programmer bug: SaveCompleted() called with a snapshot that wasn't in m_savingSnapshots or m_savingCharacterSnapshots."));
m_savingCharacterSnapshots.erase(j, m_savingCharacterSnapshots.end());
if (completedSnapshot != nullptr) {
delete completedSnapshot;
completedSnapshot = nullptr;
}
}
bool locked = false;
do {
locked = delmutex.try_lock();
} while (!locked);
if (completedSnapshot != nullptr){
m_completedSnapshots.push_back(completedSnapshot);
DEBUG_REPORT_LOG(ConfigServerDatabase::getReportSaveTimes(),("New character save completed\n"));
}
delmutex.unlock();
}
// ----------------------------------------------------------------------
void Persister::receiveMessage(const MessageDispatch::Emitter & source, const MessageDispatch::MessageBase & message)
@@ -764,7 +712,7 @@ void Persister::receiveMessage(const MessageDispatch::Emitter & source, const Me
Archive::ReadIterator ri = static_cast<const GameNetworkMessage &>(message).getByteStream().begin();
UpdateObjectPositionMessage msg(ri);
getSnapshotForObject(msg.getNetworkId(), sourceGameServer).handleUpdateObjectPosition(msg);
getSnapshotForObject(msg.getNetworkId(), sourceGameServer)->handleUpdateObjectPosition(msg);
break;
}
case constcrc("AddCharacterMessage") :
@@ -924,7 +872,7 @@ void Persister::receiveMessage(const MessageDispatch::Emitter & source, const Me
{
Archive::ReadIterator ri = static_cast<const GameNetworkMessage &>(message).getByteStream().begin();
BountyHunterTargetMessage msg(ri);
getSnapshotForServer(sourceGameServer).handleBountyHunterTargetMessage(msg);
getSnapshotForServer(sourceGameServer)->handleBountyHunterTargetMessage(msg);
break;
}
case constcrc("CMCreateAuctionMessage") :
@@ -940,7 +888,7 @@ void Persister::receiveMessage(const MessageDispatch::Emitter & source, const Me
if (commConnection)
commServerId = commConnection->getProcessId();
getCommoditiesSnapshot(commServerId).handleCommoditiesDataMessage(message);
getCommoditiesSnapshot(commServerId)->handleCommoditiesDataMessage(message);
break;
}
case constcrc("LoadCommodities") :
@@ -1072,9 +1020,8 @@ void Persister::handleMessageTo(uint32 sourceServer, const MessageToPayload &dat
}
else
{
if (!m_messageSnapshot)
m_messageSnapshot = &getSnapshotForServer(sourceServer);
if (!m_messageSnapshot)
m_messageSnapshot = getSnapshotForServer(sourceServer);
m_messageSnapshot->handleMessageTo(data);
}
MessageToManager::getInstance().handleMessageTo(data);
@@ -1089,7 +1036,7 @@ void Persister::handleMessageTo(uint32 sourceServer, const MessageToPayload &dat
void Persister::handleMessageToAck(uint32 sourceServer, const MessageToId &messageId)
{
if (!m_messageSnapshot)
m_messageSnapshot = &getSnapshotForServer(sourceServer);
m_messageSnapshot = getSnapshotForServer(sourceServer);
m_messageSnapshot->handleMessageToAck(messageId);
MessageToManager::getInstance().handleMessageToAck(messageId);
@@ -1114,7 +1061,7 @@ void Persister::deleteCharacter(StationId stationId, const NetworkId &characterI
else
{
DeleteCharacterCustomPersistStep *cps = new DeleteCharacterCustomPersistStep(stationId, characterId);
getSnapshotForObject(characterId, 0).addCustomPersistStep(cps);
getSnapshotForObject(characterId, 0)->addCustomPersistStep(cps);
}
// send delete character message to CommoditiesServer to delete auction items from this character
@@ -1169,7 +1116,7 @@ void Persister::renameCharacter(uint32 sourceServer, int8 renameCharacterMessage
}
RenameCharacterCustomPersistStep *cps = new RenameCharacterCustomPersistStep(renameCharacterMessageSource, stationId, characterId, newName, oldName, requestedBy, renameRequest);
getSnapshotForServer(sourceServer).addCustomPersistStep(cps);
getSnapshotForServer(sourceServer)->addCustomPersistStep(cps);
if (static_cast<RenameCharacterMessageEx::RenameCharacterMessageSource>(renameCharacterMessageSource) == RenameCharacterMessageEx::RCMS_player_request)
{
@@ -1214,7 +1161,7 @@ void Persister::changeStationId(const TransferAccountData * transferRequest)
void Persister::unloadCharacter(const NetworkId &characterId, uint32 sourceServer)
{
UnloadCharacterCustomPersistStep *cps = new UnloadCharacterCustomPersistStep(characterId, sourceServer);
getSnapshotForObject(characterId, sourceServer).addCustomPersistStep(cps);
getSnapshotForObject(characterId, sourceServer)->addCustomPersistStep(cps);
}
// ----------------------------------------------------------------------
@@ -1236,7 +1183,7 @@ bool Persister::isSaveInProgress()
void Persister::moveToPlayer(uint32 sourceServer, const NetworkId &objectId, const NetworkId &targetPlayer, int maxDepth, bool useBank, bool useDatapad)
{
MoveToPlayerCustomPersistStep *cps = new MoveToPlayerCustomPersistStep(objectId, targetPlayer, maxDepth, useBank, useDatapad);
getSnapshotForObject(objectId, sourceServer).addCustomPersistStep(cps);
getSnapshotForObject(objectId, sourceServer)->addCustomPersistStep(cps);
}
// ----------------------------------------------------------------------
@@ -1244,7 +1191,7 @@ void Persister::moveToPlayer(uint32 sourceServer, const NetworkId &objectId, con
void Persister::fixLoadWith(uint32 sourceServer, const NetworkId &topmostObject, const NetworkId &startingLoadWith, int maxDepth)
{
FixLoadWithCustomPersistStep *cps = new FixLoadWithCustomPersistStep(topmostObject, startingLoadWith, maxDepth);
getSnapshotForObject(topmostObject, sourceServer).addCustomPersistStep(cps);
getSnapshotForObject(topmostObject, sourceServer)->addCustomPersistStep(cps);
}
// ----------------------------------------------------------------------
@@ -1290,7 +1237,7 @@ void Persister::planetRequestedSave()
void Persister::handleAddResourceTypeMessage(uint32 const serverId, AddResourceTypeMessage const & message)
{
getSnapshotForServer(serverId).handleAddResourceTypeMessage(message);
getSnapshotForServer(serverId)->handleAddResourceTypeMessage(message);
}
// ----------------------------------------------------------------------
@@ -1298,7 +1245,7 @@ void Persister::handleAddResourceTypeMessage(uint32 const serverId, AddResourceT
void Persister::handlePurgeCompleteMessage(uint32 const serverId, StationId stationId)
{
PurgeCompleteCustomPersistStep * cps = new PurgeCompleteCustomPersistStep(stationId);
getSnapshotForServer(serverId).addCustomPersistStep(cps);
getSnapshotForServer(serverId)->addCustomPersistStep(cps);
}
// ======================================================================
@@ -16,8 +16,6 @@
#include <vector>
#include <set> //TODO: remove when we clean up newCharacterLock hack
#include <mutex>
#include "Unicode.h"
#include "serverNetworkMessages/MessageToPayload.h"
#include "sharedDatabaseInterface/DbModeQuery.h"
@@ -71,8 +69,6 @@ class Persister : public MessageDispatch::Receiver
void beginBaselines(const NetworkId &newObject) const;
void endBaselines(const NetworkId &newObject, uint32 serverId);
void nukeOrphans();
void saveCompleted (Snapshot *completedSnapshot);
void onNewCharacterSaved (uint32 stationId, const NetworkId &characterObject, const Unicode::String &characterName, const int templateId, bool special) const;
@@ -101,8 +97,6 @@ class Persister : public MessageDispatch::Receiver
DB::TaskQueue *m_newCharacterTaskQueue;
private:
std::mutex delmutex;
struct PendingCharacter
{
uint32 stationId;
@@ -122,11 +116,8 @@ class Persister : public MessageDispatch::Receiver
ServerSnapshotMap m_newCharacterSnapshots;
ObjectSnapshotMap m_objectSnapshotMap;
PendingCharactersType m_pendingCharacters;
SnapshotListType m_savingSnapshots;
SnapshotListType m_savingCharacterSnapshots;
SnapshotListType m_completedSnapshots;
NewCharacterLockType m_newCharacterLock;
CharactersToDeleteType * m_charactersToDeleteThisSaveCycle;
CharactersToDeleteType * m_charactersToDeleteNextSaveCycle;
@@ -154,8 +145,8 @@ class Persister : public MessageDispatch::Receiver
virtual void startSave() = 0;
Snapshot & getSnapshotForObject(const NetworkId &networkId, uint32 serverId);
Snapshot & getSnapshotForServer(uint32 serverId);
Snapshot *getSnapshotForObject(const NetworkId &networkId, uint32 serverId);
Snapshot *getSnapshotForServer(uint32 serverId);
private:
@@ -173,7 +164,7 @@ class Persister : public MessageDispatch::Receiver
void centralRequestedSave ();
void planetRequestedSave ();
Snapshot & getCommoditiesSnapshot(uint32 serverId);
Snapshot *getCommoditiesSnapshot(uint32 serverId);
/**
* Derived class should override this to make a game-specific derived Snapshot.
@@ -192,7 +183,7 @@ class Persister : public MessageDispatch::Receiver
/**
* Misc game-specific persistence steps
*/
virtual void getMoneyFromOfflineObject(uint32 replyServer, NetworkId const & sourceObject, int amount, NetworkId const & replyTo, std::string const & successCallback, std::string const & failCallback, stdvector<int8>::fwd const & packedDictionary)=0;
virtual void getMoneyFromOfflineObject(uint32 replyServer, NetworkId const & sourceObject, int amount, NetworkId const & replyTo, std::string const & successCallback, std::string const & failCallback, std::vector<int8> const & packedDictionary)=0;
protected:
Persister();
@@ -116,7 +116,7 @@ bool Snapshot::saveToDB(DB::Session *session)
* appropriate (virtual) function.
*/
void Snapshot::handleDeltasMessage(NetworkId objectId, const DeltasMessage &msg)
void Snapshot::handleDeltasMessage(NetworkId & objectId, const DeltasMessage &msg)
{
unsigned char packageId=msg.getPackageId();
Tag typeId=msg.getTypeId();
@@ -164,7 +164,7 @@ void Snapshot::handleDeltasMessage(NetworkId objectId, const DeltasMessage &msg)
* appropriate (virtual) function.
*/
void Snapshot::handleBaselinesMessage(NetworkId objectId, const BaselinesMessage &msg)
void Snapshot::handleBaselinesMessage(NetworkId &objectId, const BaselinesMessage &msg)
{
unsigned char packageId=msg.getPackageId();
Tag typeId=msg.getTypeId();
@@ -45,16 +45,16 @@ public:
virtual ~Snapshot();
virtual void handleUpdateObjectPosition(const UpdateObjectPositionMessage &msg) =0;
virtual void handleDeleteMessage (const NetworkId objectID, int reasonCode, bool immediate, bool demandLoadedContainer, bool cascadeReason) =0;
virtual void handleDeleteMessage (const NetworkId & objectID, int reasonCode, bool immediate, bool demandLoadedContainer, bool cascadeReason) =0;
virtual void handleMessageTo (const MessageToPayload &data) =0;
virtual void handleMessageToAck (const MessageToId &messageId) =0;
virtual void handleAddResourceTypeMessage (const AddResourceTypeMessage &message) =0;
virtual void handleBountyHunterTargetMessage (const BountyHunterTargetMessage &message) =0;
virtual void getWorldContainers (stdvector<NetworkId>::fwd &containers) const = 0;
virtual void getWorldContainers (std::vector<NetworkId> &containers) const = 0;
void handleDeltasMessage (NetworkId objectId, const DeltasMessage &msg);
void handleBaselinesMessage (NetworkId objectId, const BaselinesMessage &msg);
void handleDeltasMessage (NetworkId & objectId, const DeltasMessage &msg);
void handleBaselinesMessage (NetworkId & objectId, const BaselinesMessage &msg);
virtual bool saveToDB (DB::Session *session) =0;
virtual bool load (DB::Session *session) =0;
@@ -63,8 +63,8 @@ public:
void takeTimestamp();
virtual void newObject (NetworkId const objectId, int templateId, Tag typeId) =0;
// virtual void addObjectIdForLoad (NetworkId objectId)=0; //TODO: the load list could be moved into Snapshot, intead of being in the derived class
virtual void newObject (const NetworkId & objectId, int templateId, Tag typeId) =0;
// virtual void addObjectIdForLoad (NetworkId & objectId)=0; //TODO: the load list could be moved into Snapshot, intead of being in the derived class
void addLocator (ObjectLocator *newLocator);
void addCustomPersistStep (CustomPersistStep *newStep);
@@ -113,15 +113,15 @@ private:
static int ms_deletionCount;
protected:
virtual void decodeServerData(NetworkId const objectId, Tag typeId, uint16 index, Archive::ReadIterator &bs, bool isBaseline) = 0;
virtual void decodeSharedData(NetworkId const objectId, Tag typeId, uint16 index, Archive::ReadIterator &bs, bool isBaseline) = 0;
virtual void decodeClientData(NetworkId const objectId, Tag typeId, uint16 index, Archive::ReadIterator &bs, bool isBaseline) = 0;
virtual void decodeParentClientData(NetworkId const objectId, Tag typeId, uint16 index, Archive::ReadIterator &bs, bool isBaseline) = 0;
virtual void decodeServerData(const NetworkId & objectId, Tag typeId, uint16 index, Archive::ReadIterator &bs, bool isBaseline) = 0;
virtual void decodeSharedData(const NetworkId & objectId, Tag typeId, uint16 index, Archive::ReadIterator &bs, bool isBaseline) = 0;
virtual void decodeClientData(const NetworkId & objectId, Tag typeId, uint16 index, Archive::ReadIterator &bs, bool isBaseline) = 0;
virtual void decodeParentClientData(const NetworkId & objectId, Tag typeId, uint16 index, Archive::ReadIterator &bs, bool isBaseline) = 0;
virtual bool encodeParentClientData(NetworkId const objectId, Tag typeId, stdvector<BatchBaselinesMessageData>::fwd &baselines) const = 0;
virtual bool encodeClientData(NetworkId const objectId, Tag typeId, stdvector<BatchBaselinesMessageData>::fwd &baselines) const = 0;
virtual bool encodeServerData(NetworkId const objectId, Tag typeId, stdvector<BatchBaselinesMessageData>::fwd &baselines) const = 0;
virtual bool encodeSharedData(NetworkId const objectId, Tag typeId, stdvector<BatchBaselinesMessageData>::fwd &baselines) const = 0;
virtual bool encodeParentClientData(NetworkId const & objectId, Tag typeId, std::vector<BatchBaselinesMessageData> &baselines) const = 0;
virtual bool encodeClientData(NetworkId const & objectId, Tag typeId, std::vector<BatchBaselinesMessageData> &baselines) const = 0;
virtual bool encodeServerData(NetworkId const & objectId, Tag typeId, std::vector<BatchBaselinesMessageData> &baselines) const = 0;
virtual bool encodeSharedData(NetworkId const & objectId, Tag typeId, std::vector<BatchBaselinesMessageData> &baselines) const = 0;
private:
Snapshot(const Snapshot&); //disable
@@ -23,14 +23,14 @@
class WorldContainerLocator : public ObjectLocator
{
public:
WorldContainerLocator(const stdvector<NetworkId>::fwd &containers);
WorldContainerLocator(const std::vector<NetworkId> &containers);
virtual ~WorldContainerLocator();
public:
virtual bool locateObjects(DB::Session *session, const std::string &schema, int &objectsLocated);
private:
stdvector<NetworkId>::fwd * m_containers;
std::vector<NetworkId> * m_containers;
private:
WorldContainerLocator &operator=(const WorldContainerLocator&); //disable
@@ -29,7 +29,7 @@ struct BidRecord
// ======================================================================
typedef stdvector<BidRecord>::fwd BidList;
typedef std::vector<BidRecord> BidList;
// ======================================================================
@@ -36,7 +36,7 @@ struct LocationRecord
// ======================================================================
typedef stdvector<LocationRecord>::fwd LocationList;
typedef std::vector<LocationRecord> LocationList;
// ======================================================================