Added serverDatabase library

This commit is contained in:
Anonymous
2014-01-17 08:02:53 -07:00
parent 5783bdd0e2
commit ebad6e01af
206 changed files with 14638 additions and 0 deletions
+1
View File
@@ -1,4 +1,5 @@
add_subdirectory(serverDatabase)
add_subdirectory(serverGame)
add_subdirectory(serverKeyShare)
add_subdirectory(serverMetrics)
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 2.8)
project(serverDatabase)
if(WIN32)
add_definitions(/D_CRT_SECURE_NO_WARNINGS)
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/public)
add_subdirectory(src)
@@ -0,0 +1 @@
#include "../../src/shared/AbstractTableBuffer.h"
@@ -0,0 +1 @@
#include "../../../../../../game/server/application/SwgDatabaseServer/src/shared/core/CMLoader.h"
@@ -0,0 +1 @@
#include "../../src/shared/CentralServerConnection.h"
@@ -0,0 +1 @@
#include "../../src/shared/CharacterLocator.h"
@@ -0,0 +1 @@
#include "../../src/shared/CharacterNameLocator.h"
@@ -0,0 +1 @@
#include "../../src/shared/CharacterQueries.h"
@@ -0,0 +1 @@
#include "../../src/shared/ChatServerConnection.h"
@@ -0,0 +1 @@
#include "../../src/shared/ChunkLocator.h"
@@ -0,0 +1 @@
#include "../../src/shared/CommoditiesServerConnection.h"
@@ -0,0 +1 @@
#include "../../src/shared/ConfigServerDatabase.h"
@@ -0,0 +1 @@
#include "../../src/shared/ContainedObjectLocator.h"
@@ -0,0 +1 @@
#include "../../src/shared/ContentsLocator.h"
@@ -0,0 +1 @@
#include "../../src/shared/CreateCharacterCustomPersistStep.h"
@@ -0,0 +1 @@
#include "../../src/shared/CustomPersistStep.h"
@@ -0,0 +1 @@
#include "../../src/shared/DataLookup.h"
@@ -0,0 +1 @@
#include "../../src/shared/DatabaseMetricsData.h"
@@ -0,0 +1 @@
#include "../../src/shared/DatabaseProcess.h"
@@ -0,0 +1 @@
#include "../../src/shared/DatabaseProcessQuery.h"
@@ -0,0 +1 @@
#include "../../src/shared/DeleteCharacterCustomPersistStep.h"
@@ -0,0 +1 @@
#include "../../src/shared/FirstServerDatabase.h"
@@ -0,0 +1 @@
#include "../../src/shared/FixLoadWithCustomPersistStep.h"
@@ -0,0 +1 @@
#include "../../src/shared/GameServerConnection.h"
@@ -0,0 +1 @@
#include "../../src/shared/GetBiographyQuery.h"
@@ -0,0 +1 @@
#include "../../src/shared/GetChunkQuery.h"
@@ -0,0 +1 @@
#include "../../src/shared/GetContentsList.h"
@@ -0,0 +1 @@
#include "../../src/shared/GetGoldVersionNumberQuery.h"
@@ -0,0 +1 @@
#include "../../src/shared/GetObjectIdsQuery.h"
@@ -0,0 +1 @@
#include "../../src/shared/GetTimestampQuery.h"
@@ -0,0 +1 @@
#include "../../src/shared/GetUniverseQuery.h"
@@ -0,0 +1 @@
#include "../../src/shared/GetVersionNumberQuery.h"
@@ -0,0 +1 @@
#include "../../src/shared/ImmediateDeleteCustomPersistStep.h"
@@ -0,0 +1 @@
#include "../../src/shared/LazyDeleteQuery.h"
@@ -0,0 +1 @@
#include "../../src/shared/LazyDeleter.h"
@@ -0,0 +1 @@
#include "../../src/shared/Loader.h"
@@ -0,0 +1 @@
#include "../../src/shared/LoaderSnapshotGroup.h"
@@ -0,0 +1 @@
#include "../../src/shared/MessageToManager.h"
@@ -0,0 +1 @@
#include "../../src/shared/MoveToPlayerCustomPersistStep.h"
@@ -0,0 +1 @@
#include "../../src/shared/ObjectLocator.h"
@@ -0,0 +1 @@
#include "../../src/shared/Persister.h"
@@ -0,0 +1 @@
#include "../../src/shared/PreloadListQuery.h"
@@ -0,0 +1 @@
#include "../../src/shared/PurgeCompleteCustomPersistStep.h"
@@ -0,0 +1 @@
#include "../../src/shared/RenameCharacterCustomPersistStep.h"
@@ -0,0 +1 @@
#include "../../src/shared/SaveTimestampQuery.h"
@@ -0,0 +1 @@
#include "../../src/shared/ScriptQueries.h"
@@ -0,0 +1 @@
#include "../../src/shared/SetBiographyQuery.h"
@@ -0,0 +1 @@
#include "../../src/shared/Snapshot.h"
@@ -0,0 +1 @@
#include "../../src/shared/StructureQueries.h"
@@ -0,0 +1 @@
#include "../../src/shared/TableBuffer.h"
@@ -0,0 +1 @@
#include "../../src/shared/TaskCSTasks.h"
@@ -0,0 +1 @@
#include "../../src/shared/TaskChangeStationId.h"
@@ -0,0 +1 @@
#include "../../src/shared/TaskCheckCharacterName.h"
@@ -0,0 +1 @@
#include "../../src/shared/TaskCheckGoldVersionNumber.h"
@@ -0,0 +1 @@
#include "../../src/shared/TaskCheckVersionNumber.h"
@@ -0,0 +1 @@
#include "../../src/shared/TaskGetBiography.h"
@@ -0,0 +1 @@
#include "../../src/shared/TaskGetObjectIds.h"
@@ -0,0 +1 @@
#include "../../src/shared/TaskGetStructures.h"
@@ -0,0 +1 @@
#include "../../src/shared/TaskGetStructuresForPurge.h"
@@ -0,0 +1 @@
#include "../../src/shared/TaskLoadClock.h"
@@ -0,0 +1 @@
#include "../../src/shared/TaskLoadSnapshots.h"
@@ -0,0 +1 @@
#include "../../src/shared/TaskManagerConnection.h"
@@ -0,0 +1 @@
#include "../../src/shared/TaskSaveSnapshot.h"
@@ -0,0 +1 @@
#include "../../src/shared/TaskSetBiography.h"
@@ -0,0 +1 @@
#include "../../src/shared/UniverseLocator.h"
@@ -0,0 +1 @@
#include "../../src/shared/UnloadCharacterCustomPersistStep.h"
@@ -0,0 +1 @@
#include "../../src/shared/WorldContainerLocator.h"
@@ -0,0 +1 @@
#include "../../src/shared/dBAuctionRecord.h"
@@ -0,0 +1 @@
#include "../../src/shared/dBBidRecord.h"
@@ -0,0 +1 @@
#include "../../src/shared/dBLocationRecord.h"
@@ -0,0 +1,174 @@
set(SHARED_SOURCES
shared/AbstractTableBuffer.cpp
shared/AbstractTableBuffer.h
shared/CentralServerConnection.cpp
shared/CentralServerConnection.h
shared/CharacterLocator.cpp
shared/CharacterLocator.h
shared/CharacterNameLocator.cpp
shared/CharacterNameLocator.h
shared/CharacterQueries.cpp
shared/CharacterQueries.h
shared/ChatServerConnection.cpp
shared/ChatServerConnection.h
shared/ChunkLocator.cpp
shared/ChunkLocator.h
shared/CommoditiesServerConnection.cpp
shared/CommoditiesServerConnection.h
shared/ConfigServerDatabase.cpp
shared/ConfigServerDatabase.h
shared/ConsoleManager.cpp
shared/ConsoleManager.h
shared/ConsoleCommandParser.cpp
shared/ConsoleCommandParser.h
shared/ContainedObjectLocator.cpp
shared/ContainedObjectLocator.h
shared/ContentsLocator.cpp
shared/ContentsLocator.h
shared/CreateCharacterCustomPersistStep.cpp
shared/CreateCharacterCustomPersistStep.h
shared/CustomPersistStep.cpp
shared/CustomPersistStep.h
shared/DatabaseMetricsData.cpp
shared/DatabaseMetricsData.h
shared/DatabaseProcess.cpp
shared/DatabaseProcess.h
shared/DatabaseProcessQuery.cpp
shared/DatabaseProcessQuery.h
shared/DataLookup.cpp
shared/DataLookup.h
shared/DeleteCharacterCustomPersistStep.cpp
shared/DeleteCharacterCustomPersistStep.h
shared/FirstServerDatabase.h
shared/FixLoadWithCustomPersistStep.cpp
shared/FixLoadWithCustomPersistStep.h
shared/GameServerConnection.cpp
shared/GameServerConnection.h
shared/GetBiographyQuery.cpp
shared/GetBiographyQuery.h
shared/GetChunkQuery.cpp
shared/GetChunkQuery.h
shared/GetContentsList.cpp
shared/GetContentsList.h
shared/GetGoldVersionNumberQuery.cpp
shared/GetGoldVersionNumberQuery.h
shared/GetObjectIdsQuery.cpp
shared/GetObjectIdsQuery.h
shared/GetTimestampQuery.cpp
shared/GetTimestampQuery.h
shared/GetUniverseQuery.cpp
shared/GetUniverseQuery.h
shared/GetVersionNumberQuery.cpp
shared/GetVersionNumberQuery.h
shared/ImmediateDeleteCustomPersistStep.cpp
shared/ImmediateDeleteCustomPersistStep.h
shared/LazyDeleteQuery.cpp
shared/LazyDeleteQuery.h
shared/LazyDeleter.cpp
shared/LazyDeleter.h
shared/Loader.cpp
shared/Loader.h
shared/LoaderSnapshotGroup.cpp
shared/LoaderSnapshotGroup.h
shared/MessageToManager.cpp
shared/MessageToManager.h
shared/MoveToPlayerCustomPersistStep.cpp
shared/MoveToPlayerCustomPersistStep.h
shared/ObjectLocator.cpp
shared/ObjectLocator.h
shared/PurgeCompleteCustomPersistStep.cpp
shared/PurgeCompleteCustomPersistStep.h
shared/Persister.cpp
shared/Persister.h
shared/PreloadListQuery.cpp
shared/PreloadListQuery.h
shared/RenameCharacterCustomPersistStep.cpp
shared/RenameCharacterCustomPersistStep.h
shared/SaveTimestampQuery.cpp
shared/SaveTimestampQuery.h
shared/ScriptQueries.cpp
shared/ScriptQueries.h
shared/SetBiographyQuery.cpp
shared/SetBiographyQuery.h
shared/Snapshot.cpp
shared/Snapshot.h
shared/StructureQueries.cpp
shared/StructureQueries.h
shared/TableBuffer.cpp
shared/TableBuffer.h
shared/TaskChangeStationId.cpp
shared/TaskChangeStationId.h
shared/TaskCheckCharacterName.cpp
shared/TaskCheckCharacterName.h
shared/TaskCheckGoldVersionNumber.cpp
shared/TaskCheckGoldVersionNumber.h
shared/TaskCheckVersionNumber.cpp
shared/TaskCheckVersionNumber.h
shared/TaskCSTasks.cpp
shared/TaskCSTasks.h
shared/TaskGetBiography.cpp
shared/TaskGetBiography.h
shared/TaskGetObjectIds.cpp
shared/TaskGetObjectIds.h
shared/TaskGetStructures.cpp
shared/TaskGetStructures.h
shared/TaskGetStructuresForPurge.cpp
shared/TaskGetStructuresForPurge.h
shared/TaskLoadClock.cpp
shared/TaskLoadClock.h
shared/TaskLoadSnapshots.cpp
shared/TaskLoadSnapshots.h
shared/TaskManagerConnection.cpp
shared/TaskManagerConnection.h
shared/TaskSaveSnapshot.cpp
shared/TaskSaveSnapshot.h
shared/TaskSetBiography.cpp
shared/TaskSetBiography.h
shared/UniverseLocator.cpp
shared/UniverseLocator.h
shared/UnloadCharacterCustomPersistStep.cpp
shared/UnloadCharacterCustomPersistStep.h
shared/WorldContainerLocator.cpp
shared/WorldContainerLocator.h
)
if(WIN32)
set(PLATFORM_SOURCES
win32/FirstServerDatabase.cpp
)
else()
set(PLATFORM_SOURCES "")
endif()
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/shared
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedCommandParser/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedDebug/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedDatabaseInterface/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMathArchive/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedSynchronization/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedThread/include/public
${SWG_ENGINE_SOURCE_DIR}/server/library/serverMetrics/include/public
${SWG_ENGINE_SOURCE_DIR}/server/library/serverNetworkMessages/include/public
${SWG_ENGINE_SOURCE_DIR}/server/library/serverUtility/include/public
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/archive/include
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/localization/include
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/localizationArchive/include/public
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/singleton/include
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/unicode/include
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/unicodeArchive/include/public
)
add_library(serverDatabase STATIC
${SHARED_SOURCES}
${PLATFORM_SOURCES}
)
@@ -0,0 +1,41 @@
// ======================================================================
//
// AbstractTableBuffer.cpp
// copyright (c) 2002 Sony Online Entertainment
//
// ======================================================================
#include "serverDatabase/FirstServerDatabase.h"
#include "serverDatabase/AbstractTableBuffer.h"
#include <algorithm>
#include <set>
#include <vector>
// ======================================================================
AbstractTableBuffer::AbstractTableBuffer()
{
}
// ----------------------------------------------------------------------
AbstractTableBuffer::~AbstractTableBuffer()
{
}
// ----------------------------------------------------------------------
/**
* Return TRUE if the two tagsets have at least one tag in common.
* TODO: If this starts showing up on profiles, write a more efficient version
*/
bool AbstractTableBuffer::hasCommonTags(const DB::TagSet &left, const DB::TagSet &right)
{
std::vector<Tag> result;
IGNORE_RETURN(std::set_intersection(left.begin(), left.end(), right.begin(), right.end(), std::back_inserter(result)));
return (!result.empty());
}
// ======================================================================
@@ -0,0 +1,60 @@
// ======================================================================
//
// AbstractTableBuffer.h
// copyright (c) 2001 Sony Online Entertainment
//
// ======================================================================
#ifndef INCLUDED_AbstractTableBuffer_H
#define INCLUDED_AbstractTableBuffer_H
// ======================================================================
#include "sharedFoundation/Tag.h"
// ======================================================================
namespace DB
{
class Session;
}
class NetworkId;
// ======================================================================
namespace DB
{
typedef stdset<Tag>::fwd TagSet;
}
// ======================================================================
/**
* Abstract base class for TableBuffer's. Allows TableBuffers to be
* put in lists, have virtual functions, etc.
*/
class AbstractTableBuffer
{
public:
/**
* Load the buffer from the database.
* The TagSet identifies which types of objects are being loaded
* Some buffers may change how they work or skip loading altogether
* based on the contents of this set.
*/
virtual bool load(DB::Session *session, const DB::TagSet &tags, const std::string &schema, bool usingGoldDatabase) =0;
virtual bool save(DB::Session *session) =0;
virtual void removeObject(const NetworkId &object) =0;
static bool hasCommonTags(const DB::TagSet &left, const DB::TagSet &right);
public:
AbstractTableBuffer();
virtual ~AbstractTableBuffer();
};
// ======================================================================
#endif
@@ -0,0 +1,104 @@
// ======================================================================
//
// CentralServerConnection.cpp
// copyright (c) 2001 Sony Online Entertainment
//
// ======================================================================
#include "serverDatabase/FirstServerDatabase.h"
#include "Archive/Archive.h"
#include "ConsoleManager.h"
#include "serverDatabase/CentralServerConnection.h"
#include "serverDatabase/GameServerConnection.h"
#include "serverDatabase/Persister.h"
#include "serverNetworkMessages/RenameCharacterMessage.h"
#include "serverNetworkMessages/TransferAccountData.h"
#include "serverNetworkMessages/TransferAccountDataArchive.h"
#include "serverNetworkMessages/TransferCharacterData.h"
#include "serverNetworkMessages/TransferCharacterDataArchive.h"
#include "sharedFoundation/NetworkIdArchive.h"
#include "sharedLog/Log.h"
#include "sharedNetwork/NetworkSetupData.h"
#include "sharedNetworkMessages/ConsoleChannelMessages.h"
#include "sharedNetworkMessages/GameNetworkMessage.h"
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
#include "Unicode.h"
#include "UnicodeUtils.h"
// ======================================================================
CentralServerConnection::CentralServerConnection(const std::string & a, const unsigned short p) :
ServerConnection(a, p, NetworkSetupData()),
MessageDispatch::Receiver()
{
}
// ----------------------------------------------------------------------
CentralServerConnection::~CentralServerConnection()
{
DEBUG_REPORT_LOG(true, ("Deleting central server connection\n"));
}
//-----------------------------------------------------------------------
void CentralServerConnection::onConnectionClosed()
{
ServerConnection::onConnectionClosed();
static MessageConnectionCallback m("CentralConnectionClosed");
emitMessage(m);
}
//-----------------------------------------------------------------------
void CentralServerConnection::onConnectionOpened()
{
static MessageConnectionCallback m("CentralConnectionOpened");
emitMessage(m);
}
//-----------------------------------------------------------------------
void CentralServerConnection::onReceive(const Archive::ByteStream & message)
{
Archive::ReadIterator ri = message.begin();
const GameNetworkMessage msg(ri);
ri = message.begin();
if(msg.isType("TransferRenameCharacter"))
{
const GenericValueTypeMessage<TransferCharacterData> request(ri);
const TransferCharacterData & requestData = request.getValue();
LOG("CustomerService", ("CharacterTransfer: Received TransferRenameCharacter, starting game database name change. %s", requestData.toString().c_str()));
Persister::getInstance().renameCharacter(0, static_cast<int8>(RenameCharacterMessageEx::RCMS_cts_rename), request.getValue().getSourceStationId(), request.getValue().getCharacterId(), Unicode::narrowToWide(request.getValue().getDestinationCharacterName()), Unicode::narrowToWide(request.getValue().getSourceCharacterName()), false, NetworkId::cms_invalid, &requestData);
}
else if(msg.isType("ConGenericMessage"))
{
const ConGenericMessage cm(ri);
std::string result;
ConsoleManager::processString(cm.getMsg(), cm.getMsgId(), result);
const ConGenericMessage response(result, cm.getMsgId());
send(response, true);
}
else if(msg.isType("TransferAccountRequestCentralDatabase"))
{
const GenericValueTypeMessage<TransferAccountData> request(ri);
const TransferAccountData & requestData = request.getValue();
LOG("CustomerService", ("CharacterTransfer: Received TransferAccountRequestCentralDatabase, starting game database change from station ID %d to station ID %d", request.getValue().getSourceStationId(), request.getValue().getDestinationStationId()));
Persister::getInstance().changeStationId(&requestData);
}
else
{
ServerConnection::onReceive(message);
}
}
//-----------------------------------------------------------------------
void CentralServerConnection::receiveMessage(const MessageDispatch::Emitter & source, const MessageDispatch::MessageBase & message)
{
UNREF(source);
UNREF(message);
}
// ======================================================================
@@ -0,0 +1,35 @@
// ======================================================================
//
// CentralServerConnection.h
// copyright (c) 2001 Sony Online Entertainment
//
// ======================================================================
#ifndef INCLUDED_CentralServerConnection_H
#define INCLUDED_CentralServerConnection_H
// ======================================================================
#include "sharedMessageDispatch/Receiver.h"
#include "serverUtility/ServerConnection.h"
// ======================================================================
class CentralServerConnection : public ServerConnection, public MessageDispatch::Receiver
{
public:
CentralServerConnection(const std::string & remoteAddress, const unsigned short port);
~CentralServerConnection();
void onConnectionClosed ();
void onConnectionOpened ();
void onReceive (const Archive::ByteStream & message);
void receiveMessage (const MessageDispatch::Emitter & source, const MessageDispatch::MessageBase & message);
private:
CentralServerConnection(CentralServerConnection&);
CentralServerConnection& operator=(CentralServerConnection&);
};
// ======================================================================
#endif
@@ -0,0 +1,91 @@
// ======================================================================
//
// CharacterLocator.cpp
// copyright (c) 2001 Sony Online Entertainment
//
// ======================================================================
#include "serverDatabase/FirstServerDatabase.h"
#include "serverDatabase/CharacterLocator.h"
#include <vector>
#include "serverDatabase/DatabaseProcess.h"
#include "serverDatabase/Loader.h"
#include "sharedDatabaseInterface/DbSession.h"
#include "sharedFoundation/Clock.h"
#include "sharedFoundation/NetworkIdArchive.h"
#include "sharedLog/Log.h"
// ======================================================================
CharacterLocator::CharacterLocator(const NetworkId &characterId) :
ObjectLocator(),
m_characterId(characterId)
{
}
// ----------------------------------------------------------------------
CharacterLocator::~CharacterLocator()
{
Loader::getInstance().onCharacterLocatorDeleted(m_characterId);
}
// ----------------------------------------------------------------------
bool CharacterLocator::locateObjects(DB::Session *session, const std::string &schema, int &objectsLocated)
{
NOT_NULL(session);
int startTime = Clock::timeMs();
LocateCharacterQuery qry(m_characterId, schema);
bool rval = session->exec(&qry);
qry.done();
LOG("TRACE_LOGIN",("Character locator %s -- %i objects %i ms",m_characterId.getValueString().c_str(), qry.object_count.getValue(), Clock::timeMs()-startTime));
objectsLocated = qry.object_count.getValue();
return rval;
}
// ======================================================================
CharacterLocator::LocateCharacterQuery::LocateCharacterQuery(const NetworkId &networkId, const std::string &schema) :
DB::Query(),
object_id(networkId),
m_schema(schema)
{
}
// ----------------------------------------------------------------------
void CharacterLocator::LocateCharacterQuery::getSQL(std::string &sql)
{
sql = std::string("begin :object_count := ") + m_schema + "loader.locate_player (:object_id); end;";
}
// ----------------------------------------------------------------------
bool CharacterLocator::LocateCharacterQuery::bindParameters()
{
if (!bindParameter(object_count)) return false;
if (!bindParameter(object_id)) return false;
return true;
}
// ----------------------------------------------------------------------
bool CharacterLocator::LocateCharacterQuery::bindColumns()
{
return true;
}
// ----------------------------------------------------------------------
DB::Query::QueryMode CharacterLocator::LocateCharacterQuery::getExecutionMode() const
{
return MODE_PROCEXEC;
}
// ======================================================================
@@ -0,0 +1,63 @@
// ======================================================================
//
// CharacterLocator.h
// copyright (c) 2001 Sony Online Entertainment
//
// ======================================================================
#ifndef INCLUDED_CharacterLocator_H
#define INCLUDED_CharacterLocator_H
#include "serverDatabase/ObjectLocator.h"
#include "sharedDatabaseInterface/Bindable.h"
#include "sharedDatabaseInterface/BindableNetworkId.h"
#include "sharedDatabaseInterface/DbQuery.h"
#include "sharedFoundation/NetworkId.h"
// ======================================================================
/**
* Locate a specified character and add it to the list of objects to be
* loaded by the Snapshot.
*/
class CharacterLocator : public ObjectLocator
{
public:
CharacterLocator(const NetworkId &characterId);
virtual ~CharacterLocator();
public:
bool locateObjects(DB::Session *session, const std::string &schema, int &objectsLocated);
private:
NetworkId m_characterId;
private:
class LocateCharacterQuery : public DB::Query
{
public:
LocateCharacterQuery(const NetworkId &networkId, const std::string &schema);
virtual void getSQL(std::string &sql);
virtual bool bindParameters();
virtual bool bindColumns();
private:
virtual DB::Query::QueryMode getExecutionMode() const;
private:
LocateCharacterQuery(const LocateCharacterQuery&); // disable
LocateCharacterQuery& operator=(const LocateCharacterQuery&); //disable
public:
DB::BindableLong object_count;
DB::BindableNetworkId object_id;
private:
std::string m_schema;
};
};
// ======================================================================
#endif
@@ -0,0 +1,108 @@
// ======================================================================
//
// CharacterNameLocator.cpp
// copyright (c) 2003 Sony Online Entertainment
//
// ======================================================================
#include "serverDatabase/FirstServerDatabase.h"
#include "serverDatabase/CharacterNameLocator.h"
#include "serverDatabase/ConfigServerDatabase.h"
#include "serverDatabase/DatabaseProcess.h"
#include "serverDatabase/GameServerConnection.h"
#include "serverNetworkMessages/CharacterNamesMessage.h"
#include "sharedDatabaseInterface/DbSession.h"
// ======================================================================
bool CharacterNameLocator::locateObjects(DB::Session *session, const std::string &schema, int &objectsLocated)
{
int rowsFetched;
DEBUG_REPORT_LOG(ConfigServerDatabase::getLogObjectLoading(),("Loading character names.\n"));
CharacterNameQuery qry(schema);
if (! (session->exec(&qry)))
{
objectsLocated = 0;
return false;
}
while ((rowsFetched = qry.fetch()) > 0)
{
size_t numRows = qry.getNumRowsFetched();
size_t count = 0;
const std::vector<CharacterNameRow> &data = qry.getData();
for (std::vector<CharacterNameRow>::const_iterator i=data.begin(); i!=data.end(); ++i)
{
if (++count > numRows)
break;
m_characterIds.push_back(i->character_id.getValue());
m_stationIds.push_back(i->character_station_id.getValue());
m_characterNames.push_back(i->character_name.getValueASCII());
m_characterFullNames.push_back(i->character_full_name.getValueASCII());
m_characterCreateTime.push_back(i->character_create_time.getValue() + (7 * 60 * 60));
m_characterLastLoginTime.push_back(i->character_last_login_time.getValue() + (7 * 60 * 60));
DEBUG_REPORT_LOG(ConfigServerDatabase::getLogObjectLoading(),("\t%s:%s\n", i->character_id.getValue().getValueString().c_str(), i->character_name.getValueASCII().c_str()));
}
}
objectsLocated = 0;
return (rowsFetched >= 0);
}
// ----------------------------------------------------------------------
void CharacterNameLocator::sendPostBaselinesCustomData(GameServerConnection &conn) const
{
CharacterNamesMessage msg(m_characterIds, m_stationIds, m_characterNames, m_characterFullNames, m_characterCreateTime, m_characterLastLoginTime);
conn.send(msg,true);
}
// ======================================================================
CharacterNameLocator::CharacterNameQuery::CharacterNameQuery(const std::string &schema) :
m_data(ConfigServerDatabase::getDefaultFetchBatchSize()),
m_schema(schema)
{
}
// ----------------------------------------------------------------------
void CharacterNameLocator::CharacterNameQuery::getSQL(std::string &sql)
{
sql="begin :result := "+m_schema+"loader.get_character_name_list(); end;";
}
// ----------------------------------------------------------------------
bool CharacterNameLocator::CharacterNameQuery::bindParameters()
{
return true;
}
// ----------------------------------------------------------------------
bool CharacterNameLocator::CharacterNameQuery::bindColumns()
{
size_t skipSize = reinterpret_cast<char*>(&(m_data[1])) - reinterpret_cast<char*>(&(m_data[0]));
setColArrayMode(skipSize, m_data.size());
if (!bindCol(m_data[0].character_id)) return false;
if (!bindCol(m_data[0].character_station_id)) return false;
if (!bindCol(m_data[0].character_name)) return false;
if (!bindCol(m_data[0].character_full_name)) return false;
if (!bindCol(m_data[0].character_create_time)) return false;
if (!bindCol(m_data[0].character_last_login_time)) return false;
return true;
}
// ----------------------------------------------------------------------
DB::Query::QueryMode CharacterNameLocator::CharacterNameQuery::getExecutionMode() const
{
return MODE_PLSQL_REFCURSOR;
}
// ======================================================================
@@ -0,0 +1,82 @@
// ======================================================================
//
// CharacterNameLocator.h
// copyright (c) 2003 Sony Online Entertainment
//
// ======================================================================
#ifndef INCLUDED_CharacterNameLocator_H
#define INCLUDED_CharacterNameLocator_H
// ======================================================================
#include "sharedDatabaseInterface/Bindable.h"
#include "sharedDatabaseInterface/BindableNetworkId.h"
#include "sharedDatabaseInterface/DbQuery.h"
#include "serverDatabase/ObjectLocator.h"
#include <vector>
// ======================================================================
/**
* Load character names and send them to the game server.
* (Doesn't add any objects to the load, handles the names as custom data.)
*/
class CharacterNameLocator : public ObjectLocator
{
public:
virtual bool locateObjects(DB::Session *session, const std::string &schema, int &objectsLocated);
virtual void sendPostBaselinesCustomData(GameServerConnection &conn) const;
private:
struct CharacterNameRow
{
DB::BindableNetworkId character_id;
DB::BindableLong character_station_id;
DB::BindableString<127> character_name;
DB::BindableString<127> character_full_name;
DB::BindableLong character_create_time;
DB::BindableLong character_last_login_time;
};
class CharacterNameQuery : public DB::Query
{
public:
CharacterNameQuery(const std::string &schema);
virtual void getSQL(std::string &sql);
virtual bool bindParameters();
virtual bool bindColumns();
virtual QueryMode getExecutionMode() const;
const std::vector<CharacterNameRow> & getData() const;
private:
std::vector<CharacterNameRow> m_data;
std::string m_schema;
private:
CharacterNameQuery(const CharacterNameQuery&);
CharacterNameQuery& operator=(const CharacterNameQuery&);
};
private:
std::vector<NetworkId> m_characterIds;
std::vector<int> m_stationIds;
std::vector<std::string> m_characterNames;
std::vector<std::string> m_characterFullNames;
std::vector<int> m_characterCreateTime;
std::vector<int> m_characterLastLoginTime;
};
// ======================================================================
inline const std::vector<CharacterNameLocator::CharacterNameRow> & CharacterNameLocator::CharacterNameQuery::getData() const
{
return m_data;
}
// ======================================================================
#endif
@@ -0,0 +1,164 @@
// ======================================================================
//
// CharacterQueries.cpp
// copyright (c) 2001 Sony Online Entertainment
//
// ======================================================================
#include "serverDatabase/FirstServerDatabase.h"
#include "serverDatabase/CharacterQueries.h"
#include "serverDatabase/DatabaseProcess.h"
using namespace DBQuery;
// ======================================================================
void GetCharacters::getSQL(std::string &sql)
{
sql="begin :result := "+DatabaseProcess::getInstance().getSchemaQualifier()+"loader.get_characters(:station_id); end;";
}
// ----------------------------------------------------------------------
bool GetCharacters::bindParameters()
{
if (!bindParameter(data.station_id)) return false;
return true;
}
// ----------------------------------------------------------------------
bool GetCharacters::bindColumns()
{
if (!bindCol(data.object_id)) return false;
if (!bindCol(data.object_template)) return false;
if (!bindCol(data.scene_id)) return false;
if (!bindCol(data.character_name)) return false;
if (!bindCol(data.container_id)) return false;
if (!bindCol(data.x)) return false;
if (!bindCol(data.y)) return false;
if (!bindCol(data.z)) return false;
return true;
}
// ----------------------------------------------------------------------
const GetCharacters::GetCharactersRow &GetCharacters::getData() const
{
return data;
}
// ----------------------------------------------------------------------
void GetCharacters::setStationId(StationId station_id)
{
data.station_id.setValue(static_cast<int32>(station_id));
}
// ----------------------------------------------------------------------
DB::Query::QueryMode GetCharacters::getExecutionMode() const
{
return MODE_PLSQL_REFCURSOR;
}
// ======================================================================
AddCharacter::AddCharacter(StationId stationId, const NetworkId &objectId, const Unicode::String &characterName, const std::string &normalizedName) :
DB::Query(),
station_id(static_cast<int32>(stationId)),
object_id(objectId),
character_name(characterName),
normalized_name(normalizedName)
{
}
// ----------------------------------------------------------------------
void AddCharacter::getSQL(std::string &sql)
{
sql="begin "+DatabaseProcess::getInstance().getSchemaQualifier()+"persister.add_player (:station_id, :character_object, :character_name, :normalized_name); end;";
// insert into players (station_id, character_object) values (?,?)");
}
// ----------------------------------------------------------------------
bool AddCharacter::bindParameters()
{
if (!bindParameter(station_id)) return false;
if (!bindParameter(object_id)) return false;
if (!bindParameter(character_name)) return false;
if (!bindParameter(normalized_name)) return false;
return true;
}
// ----------------------------------------------------------------------
bool AddCharacter::bindColumns()
{
return true;
}
// ----------------------------------------------------------------------
DB::Query::QueryMode AddCharacter::getExecutionMode() const
{
return MODE_PROCEXEC;
}
// ======================================================================
RenameCharacter::RenameCharacter(const NetworkId &characterId, const Unicode::String &characterName, const Unicode::String &normalizedName) :
DB::Query(),
object_id(characterId),
character_name(characterName),
normalized_name(normalizedName),
result()
{
}
// ----------------------------------------------------------------------
void RenameCharacter::getSQL(std::string &sql)
{
sql=std::string("begin :result := ")+DatabaseProcess::getInstance().getSchemaQualifier()+"persister.rename_character (:character_object, :character_name, :normalized_name); end;";
}
// ----------------------------------------------------------------------
bool RenameCharacter::bindParameters()
{
if (!bindParameter(result)) return false;
if (!bindParameter(object_id)) return false;
if (!bindParameter(character_name)) return false;
if (!bindParameter(normalized_name)) return false;
return true;
}
// ----------------------------------------------------------------------
bool RenameCharacter::bindColumns()
{
return true;
}
// ----------------------------------------------------------------------
DB::Query::QueryMode RenameCharacter::getExecutionMode() const
{
return MODE_PROCEXEC;
}
// ----------------------------------------------------------------------
bool RenameCharacter::getResult() const
{
return (result.getValue()==1);
}
// ======================================================================
@@ -0,0 +1,118 @@
// ======================================================================
//
// CharacterQueries.h
// copyright (c) 2001 Sony Online Entertainment
//
// ======================================================================
#ifndef INCLUDED_CharacterQueries_H
#define INCLUDED_CharacterQueries_H
// ======================================================================
#include "sharedDatabaseInterface/Bindable.h"
#include "sharedDatabaseInterface/BindableNetworkId.h"
#include "sharedDatabaseInterface/DbQuery.h"
#include "sharedDatabaseInterface/DbRow.h"
#include "sharedFoundation/StationId.h"
// ======================================================================
namespace DBQuery {
/** A query to get the list of characters for an account.
*/
class GetCharacters : public DB::Query
{
public:
struct GetCharactersRow : public DB::Row
{
DB::BindableString<128> character_name;
DB::BindableString<128> scene_id;
DB::BindableNetworkId object_id;
DB::BindableString<1000> object_template;
DB::BindableNetworkId container_id;
DB::BindableDouble x;
DB::BindableDouble y;
DB::BindableDouble z;
DB::BindableLong station_id;
};
GetCharacters() {}
virtual void getSQL(std::string &sql);
virtual bool bindParameters();
virtual bool bindColumns();
const GetCharactersRow &getData() const;
void setStationId(StationId station_id);
protected:
virtual QueryMode getExecutionMode() const;
private:
GetCharactersRow data;
private:
GetCharacters(const GetCharacters&); // disable
GetCharacters& operator=(const GetCharacters&); //disable
};
// ======================================================================
/** A query to associate a character with a particular account
*/
class AddCharacter : public DB::Query
{
public:
AddCharacter(StationId stationId, const NetworkId &objectId, const Unicode::String &characterName, const std::string &normalizedName);
virtual void getSQL(std::string &sql);
virtual bool bindParameters();
virtual bool bindColumns();
protected:
virtual QueryMode getExecutionMode() const;
private:
DB::BindableLong station_id;
DB::BindableNetworkId object_id;
DB::BindableString<127> character_name;
DB::BindableString<127> normalized_name;
private:
AddCharacter(const AddCharacter&); // disable
AddCharacter& operator=(const AddCharacter&); //disable
};
// ======================================================================
class RenameCharacter : public DB::Query
{
public:
RenameCharacter (const NetworkId &characterId, const Unicode::String &characterName, const Unicode::String &normalizedName);
bool getResult () const;
virtual void getSQL (std::string &sql);
virtual bool bindParameters ();
virtual bool bindColumns ();
protected:
virtual QueryMode getExecutionMode () const;
private:
DB::BindableNetworkId object_id;
DB::BindableString<127> character_name;
DB::BindableString<127> normalized_name;
DB::BindableLong result;
private:
RenameCharacter (const RenameCharacter&); // disable
RenameCharacter& operator= (const RenameCharacter&); //disable
};
}
// ======================================================================
#endif
@@ -0,0 +1,32 @@
// ChatServerConnection.cpp
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
// Author: Justin Randall
//-----------------------------------------------------------------------
#include "serverDatabase/FirstServerDatabase.h"
#include "ChatServerConnection.h"
#include "sharedNetwork/NetworkSetupData.h"
//-----------------------------------------------------------------------
ChatServerConnection::ChatServerConnection(const std::string & a, const unsigned short p) :
ServerConnection(a, p, NetworkSetupData())
{
}
//-----------------------------------------------------------------------
ChatServerConnection::~ChatServerConnection()
{
}
//-----------------------------------------------------------------------
void ChatServerConnection::onConnectionClosed()
{
static MessageConnectionCallback m("ChatServerConnectionClosed");
emitMessage(m);
}
//-----------------------------------------------------------------------
@@ -0,0 +1,30 @@
// ChatServerConnection.h
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
// Author: Justin Randall
#ifndef _INCLUDED_ChatServerConnection_H
#define _INCLUDED_ChatServerConnection_H
//-----------------------------------------------------------------------
#include "serverUtility/ServerConnection.h"
//-----------------------------------------------------------------------
class ChatServerConnection : public ServerConnection
{
public:
ChatServerConnection(const std::string & address, const unsigned short port);
~ChatServerConnection();
void onConnectionClosed();
private:
ChatServerConnection & operator = (const ChatServerConnection & rhs);
ChatServerConnection(const ChatServerConnection & source);
};
//-----------------------------------------------------------------------
#endif // _INCLUDED_ChatServerConnection_H
@@ -0,0 +1,75 @@
// ======================================================================
//
// ChunkLocator.cpp
// copyright (c) 2001 Sony Online Entertainment
//
// ======================================================================
#include "serverDatabase/FirstServerDatabase.h"
#include "serverDatabase/ChunkLocator.h"
#include <string>
#include <vector>
#include "serverDatabase/ConfigServerDatabase.h"
#include "serverDatabase/GameServerConnection.h"
#include "serverDatabase/GetChunkQuery.h"
#include "serverNetworkMessages/ChunkCompleteMessage.h"
#include "sharedDatabaseInterface/DbSession.h"
#include "sharedFoundation/Clock.h"
#include "sharedLog/Log.h"
// ======================================================================
ChunkLocator::ChunkLocator(int nodeX, int nodeZ, const std::string &sceneId, uint32 serverId, bool wantChunkCompleteMessage) :
ObjectLocator(),
m_nodeX(nodeX),
m_nodeZ(nodeZ),
m_sceneId(new std::string(sceneId)),
m_objectCount(0),
m_queryTime(0),
m_serverId(serverId),
m_wantChunkCompleteMessage(wantChunkCompleteMessage)
{
}
// ----------------------------------------------------------------------
ChunkLocator::~ChunkLocator()
{
if (ConfigServerDatabase::getLogChunkLoading())
LOG("ChunkLocator",("Chunk %s (%i,%i) (server %lu) -- %i objects %i ms",m_sceneId->c_str(), m_nodeX, m_nodeZ, m_serverId, m_objectCount,m_queryTime));
delete m_sceneId;
m_sceneId=0;
}
// ======================================================================
bool ChunkLocator::locateObjects(DB::Session *session, const std::string &schema, int &objectsLocated)
{
NOT_NULL(session);
DBQuery::GetChunkQuery qry(schema);
qry.setChunk(*m_sceneId, m_nodeX, m_nodeZ);
int startTime = Clock::timeMs();
bool rval = session->exec(&qry);
qry.done();
m_objectCount = qry.getObjectCount();
m_queryTime = Clock::timeMs()-startTime;
objectsLocated = m_objectCount;
return rval;
}
// ----------------------------------------------------------------------
void ChunkLocator::sendPostBaselinesCustomData(GameServerConnection &conn) const
{
if (m_wantChunkCompleteMessage)
conn.queueCompletedChunk(m_nodeX, m_nodeZ);
}
// ======================================================================
@@ -0,0 +1,49 @@
// ======================================================================
//
// ChunkLocator.h
// copyright (c) 2001 Sony Online Entertainment
//
// ======================================================================
#ifndef INCLUDED_ChunkLocator_H
#define INCLUDED_ChunkLocator_H
#include "serverDatabase/ObjectLocator.h"
// ======================================================================
/**
* Given a sceneID and map coordinates, locates all the objects in that
* chunk. Adds them to the list of objects to be loaded by the Snapshot.
*
* @todo It will be common to have a bunch of these attached to the same
* snapshot. Maybe it would be more efficient to find a way to combine
* them.
*/
class ChunkLocator : public ObjectLocator
{
public:
ChunkLocator(int nodeX, int nodeZ, const std::string &sceneId, uint32 serverId, bool wantChunkCompleteMessage);
virtual ~ChunkLocator();
public:
virtual bool locateObjects(DB::Session *session, const std::string &schema, int &objectsLocated);
virtual void sendPostBaselinesCustomData(GameServerConnection &conn) const;
private:
int m_nodeX;
int m_nodeZ;
std::string *m_sceneId;
int m_objectCount;
int m_queryTime;
uint32 m_serverId;
bool m_wantChunkCompleteMessage;
private:
ChunkLocator &operator=(const ChunkLocator&); //disable
ChunkLocator(const ChunkLocator&); //disable
};
// ======================================================================
#endif
@@ -0,0 +1,91 @@
// ======================================================================
//
// CommoditiesServerConnection.cpp
// Copyright 2004, Sony Online Entertainment Inc., all rights reserved.
// Author: Mike Howard
// Server Infrastructure by: Justin Randall
//
// This is message handler for incoming commodities messages.
//
// ======================================================================
#include "serverDatabase/FirstServerDatabase.h"
#include "Archive/ByteStream.h"
#include "serverDatabase/CommoditiesServerConnection.h"
#include "serverDatabase/DatabaseProcess.h"
#include "serverNetworkMessages/GameGameServerMessages.h"
#include "serverUtility/ConfigServerUtility.h"
#include "sharedNetwork/NetworkSetupData.h"
//-----------------------------------------------------------------------
namespace CommoditiesServerConnectionNamespace
{
}
using namespace CommoditiesServerConnectionNamespace;
//-----------------------------------------------------------------------
CommoditiesServerConnection::CommoditiesServerConnection(const std::string & a, const unsigned short p) :
ServerConnection(a, p, NetworkSetupData()),
MessageDispatch::Receiver()
{
}
//-----------------------------------------------------------------------
CommoditiesServerConnection::CommoditiesServerConnection(UdpConnectionMT * u, TcpClient * t) :
ServerConnection(u, t),
MessageDispatch::Receiver()
{
}
//-----------------------------------------------------------------------
CommoditiesServerConnection::~CommoditiesServerConnection()
{
DEBUG_REPORT_LOG(true, ("Deleting commodities server connection\n"));
}
//-----------------------------------------------------------------------
void CommoditiesServerConnection::onConnectionClosed()
{
ServerConnection::onConnectionClosed();
static MessageConnectionCallback m("CommoditiesConnectionClosed");
emitMessage(m);
}
//-----------------------------------------------------------------------
void CommoditiesServerConnection::onConnectionOpened()
{
ServerConnection::onConnectionOpened();
static MessageConnectionCallback m("CommoditiesConnectionOpened");
emitMessage(m);
}
//-----------------------------------------------------------------------
void CommoditiesServerConnection::onReceive(const Archive::ByteStream & message)
{
DEBUG_REPORT_LOG(true, ("CommoditiesServerConnection::onReceive.\n"));
ServerConnection::onReceive(message);
Archive::ReadIterator ri = message.begin();
const GameNetworkMessage msg(ri);
ri = message.begin();
DEBUG_REPORT_LOG(true, ("CommoditiesServerConnection::onReceive %s\n", msg.getCmdName().c_str()));
}
//-----------------------------------------------------------------------
void CommoditiesServerConnection::receiveMessage(const MessageDispatch::Emitter & source, const MessageDispatch::MessageBase & message)
{
DEBUG_REPORT_LOG(true, ("CommoditiesServerConnection::receiveMessage\n"));
UNREF(source);
UNREF(message);
}
// ======================================================================
@@ -0,0 +1,43 @@
// ======================================================================
//
// CommoditiesServerConnection.h
// Copyright 2004, Sony Online Entertainment Inc., all rights reserved.
// Author: Mike Howard
//
// This is message handler for incoming commodities messages.
//
// ======================================================================
#ifndef _INCLUDED_CommoditiesServerConnection_H
#define _INCLUDED_CommoditiesServerConnection_H
#include "sharedMessageDispatch/Receiver.h"
#include "serverUtility/ServerConnection.h"
// ======================================================================
class CommoditiesServerConnection : public ServerConnection, public MessageDispatch::Receiver
{
public:
CommoditiesServerConnection(const std::string & remoteAddress, const unsigned short remotePort);
explicit CommoditiesServerConnection(UdpConnectionMT *, TcpClient * t);
~CommoditiesServerConnection();
virtual void onConnectionClosed ();
virtual void onConnectionOpened ();
virtual void onReceive (const Archive::ByteStream & message);
virtual void receiveMessage (const MessageDispatch::Emitter & source, const MessageDispatch::MessageBase & message);
private:
int m_gameServerId;
bool m_showAllDebugInfo;
CommoditiesServerConnection();
CommoditiesServerConnection & operator = (const CommoditiesServerConnection & rhs);
CommoditiesServerConnection(const CommoditiesServerConnection & source);
};
//-----------------------------------------------------------------------
#endif // _INCLUDED_CommoditiesServerConnection_H
@@ -0,0 +1,136 @@
// ======================================================================
//
// ConfigServerDatabase.cpp
// copyright (c) 2001 Sony Online Entertainment
//
// ======================================================================
#include "serverDatabase/FirstServerDatabase.h"
#include "serverDatabase/ConfigServerDatabase.h"
#include "serverUtility/ConfigServerUtility.h"
#include "sharedFoundation/ConfigFile.h"
#include "sharedFoundation/ExitChain.h"
#include "sharedFoundation/NetworkId.h"
#include <string>
//-------------------------------------------------------------------
ConfigServerDatabase::Data* ConfigServerDatabase::data;
static ConfigServerDatabase::Data staticData;
//-------------------------------------------------------------------
#define KEY_INT(a,b) (data->a = ConfigFile::getKeyInt("dbProcess", #a, b))
#define KEY_BOOL(a,b) (data->a = ConfigFile::getKeyBool("dbProcess", #a, b))
#define KEY_FLOAT(a,b) (data->a = ConfigFile::getKeyFloat("dbProcess", #a, b))
#define KEY_STRING(a,b) (data->a = ConfigFile::getKeyString("dbProcess", #a, b))
//-------------------------------------------------------------------
void ConfigServerDatabase::install(void)
{
ExitChain::add(ConfigServerDatabase::remove,"ConfigServerDatabase::remove");
ConfigServerUtility::install();
data = &staticData;
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, false);
KEY_STRING (objectTemplateListUpdateFilename,"");
KEY_STRING (DSN,"gameserver");
KEY_STRING (alternateDSN,"");
KEY_STRING (databaseUID,"gameserver");
KEY_STRING (databasePWD,"gameserver");
KEY_STRING (databaseProtocol,"DEFAULT");
KEY_STRING (centralServerAddress, "swo-dev1.station.sony.com");
KEY_INT (centralServerPort, 44451);
KEY_STRING (commoditiesServerAddress, "swo-dev1.station.sony.com");
KEY_INT (commoditiesServerPort, 44457); //todo: confirm that this is a good port MSH
KEY_INT (taskManagerPort, 60001);
KEY_INT (expectedDBVersion, 270);
KEY_BOOL (correctDBVersionRequired,true);
KEY_INT (saveFrequencyLimit,10);
KEY_STRING (schemaOwner, "");
KEY_STRING (goldSchemaOwner, "");
KEY_FLOAT (uniqueMessageCacheTimeSec, 30.0f);
KEY_INT (loaderThreads,2);
KEY_INT (persisterThreads,1);
KEY_INT (newCharacterThreads,1);
KEY_INT (characterImmediateDeleteMinutes,120);
KEY_BOOL (logObjectLoading, false);
KEY_BOOL (enableQueryProfile, false);
KEY_BOOL (verboseQueryMode, false);
KEY_BOOL (logWorkerThreads, false);
KEY_STRING (gameServiceBindInterface, "");
KEY_BOOL (reportSaveTimes, false);
KEY_BOOL (shouldSleep, true);
KEY_BOOL (enableLoadLocks, true);
KEY_INT (databaseReconnectTime, 0);
KEY_BOOL (logChunkLoading,false);
KEY_BOOL (useMemoryManagerForOCI,true);
KEY_INT (maxCharactersPerLoadRequest,10);
KEY_INT (maxChunksPerLoadRequest,200);
KEY_FLOAT (maxLoadStartDelay,300.0f);
KEY_INT (maxErrorCountBeforeDisconnect,5);
KEY_INT (maxErrorCountBeforeBailout,15);
KEY_INT (errorSleepTime,5000);
KEY_INT (disconnectSleepTime,30000);
KEY_INT (saveAtModulus,-1);
KEY_INT (saveAtDivisor,10);
KEY_INT (backloggedQueueSize,50);
KEY_INT (backloggedRecoveryQueueSize,25);
KEY_INT (maxTimewarp,data->saveFrequencyLimit * 2 < 600 ? 600 : data->saveFrequencyLimit * 2);
KEY_BOOL (enableObjvarPacking, true);
KEY_INT (prefetchNumRows,0);
KEY_INT (prefetchMemory,0);
KEY_INT (defaultFetchBatchSize,1000);
KEY_INT (queryReportingRate,60);
KEY_INT (enableDatabaseErrorLogging, 0);
KEY_INT (defaultMessageBulkBindSize, 1000);
KEY_BOOL (enableGoldDatabase, false);
KEY_STRING (maxGoldNetworkId, "10000000");
KEY_FLOAT (defaultQueueUpdateTimeLimit, 0.25f);
KEY_BOOL (enableDataCleanup, false);
KEY_INT (defaultLazyDeleteBulkBindSize, 100);
KEY_INT (defaultLazyDeleteSleepTime, 1000);
KEY_INT (writeDelay, 0);
KEY_BOOL (delayUnloadIfObjectStillHasData, true);
KEY_FLOAT (experienceConsolidationTime, 0.0f);
KEY_INT (maxLoaderFinishedTasks, 100);
KEY_FLOAT (reportLongFrameTime, 1.0f);
KEY_BOOL (enableVerboseMessageLogging, false);
KEY_BOOL (profilerExpandAll, true);
KEY_INT (profilerDisplayPercentageMinimum, 0);
KEY_BOOL (fatalOnDataError, false);
KEY_INT (maxUnackedLoadCount, 1000000000); // by default, set to an "unlimited" number, and use maxUnackedLoadCountPerServer as the cap
KEY_INT (maxUnackedLoadCountPerServer, 2);
KEY_INT (auctionLocationLoadBatchSize, 100);
KEY_INT (auctionLoadBatchSize, 100);
KEY_INT (auctionAttributeLoadBatchSize, 100);
KEY_INT (auctionBidLoadBatchSize, 100);
KEY_INT (oldestUnackedLoadAlertThresholdSeconds, 10*60); // seconds
}
//-------------------------------------------------------------------
void ConfigServerDatabase::remove(void)
{
ConfigServerUtility::remove();
}
// ----------------------------------------------------------------------
const NetworkId & ConfigServerDatabase::getMaxGoldNetworkId(void)
{
static const NetworkId theValue(std::string(data->maxGoldNetworkId));
return theValue;
}
// ======================================================================
@@ -0,0 +1,772 @@
// ======================================================================
//
// ConfigServerDatabase.h
// copyright (c) 2001 Sony Online Entertainment
//
// ======================================================================
#ifndef INCLUDED_ConfigServerDatabase_H
#define INCLUDED_ConfigServerDatabase_H
// ======================================================================
class NetworkId;
// ======================================================================
class ConfigServerDatabase
{
public:
struct Data
{
const char * centralServerAddress;
int centralServerPort;
const char * commoditiesServerAddress;
int commoditiesServerPort;
// database configuration:
const char * DSN;
const char * alternateDSN;
const char * databaseUID;
const char * databasePWD;
const char * databaseProtocol;
const char * schemaOwner;
const char * goldSchemaOwner;
int objvarNameCleanupTime;
int orphanedObjectCleanupTime;
int marketAttributesCleanupTime;
int messagesCleanupTime;
int brokenObjectCleanupTime;
int vendorObjectCleanupTime;
const char * customSQLFilename;
bool enableFixBadCells;
const char * objectTemplateListUpdateFilename;
int taskManagerPort;
int expectedDBVersion;
bool correctDBVersionRequired;
int saveFrequencyLimit;
float uniqueMessageCacheTimeSec;
int loaderThreads;
int persisterThreads;
int newCharacterThreads;
int characterImmediateDeleteMinutes;
bool logObjectLoading;
bool enableQueryProfile;
bool verboseQueryMode;
bool logWorkerThreads;
const char * gameServiceBindInterface;
bool reportSaveTimes;
bool shouldSleep;
bool enableLoadLocks;
int databaseReconnectTime;
bool logChunkLoading;
bool useMemoryManagerForOCI;
int maxCharactersPerLoadRequest;
int maxChunksPerLoadRequest;
float maxLoadStartDelay;
int maxErrorCountBeforeDisconnect;
int maxErrorCountBeforeBailout;
int errorSleepTime;
int disconnectSleepTime;
int saveAtModulus;
int saveAtDivisor;
int backloggedQueueSize;
int backloggedRecoveryQueueSize;
int maxTimewarp;
bool enableObjvarPacking;
int prefetchNumRows;
int prefetchMemory;
int defaultFetchBatchSize;
int queryReportingRate;
int enableDatabaseErrorLogging;
int defaultMessageBulkBindSize;
bool enableGoldDatabase;
const char* maxGoldNetworkId;
float defaultQueueUpdateTimeLimit;
bool enableDataCleanup;
int defaultLazyDeleteBulkBindSize;
int defaultLazyDeleteSleepTime;
int writeDelay;
bool delayUnloadIfObjectStillHasData;
float experienceConsolidationTime;
int maxLoaderFinishedTasks;
float reportLongFrameTime;
bool enableVerboseMessageLogging;
bool profilerExpandAll;
int profilerDisplayPercentageMinimum;
bool fatalOnDataError;
int maxUnackedLoadCount;
int maxUnackedLoadCountPerServer;
int auctionLocationLoadBatchSize;
int auctionLoadBatchSize;
int auctionAttributeLoadBatchSize;
int auctionBidLoadBatchSize;
int oldestUnackedLoadAlertThresholdSeconds;
};
private:
static Data *data;
public:
static void install (void);
static void remove (void);
static const int getObjvarNameCleanupTime (void);
static const int getOrphanedObjectCleanupTime(void);
static const int getMarketAttributesCleanupTime(void);
static const int getMessagesCleanupTime (void);
static const int getBrokenObjectCleanupTime (void);
static const int getVendorObjectCleanupTime(void);
static const char * getCustomSQLFilename (void);
static bool getEnableFixBadCells (void);
static const char * getObjectTemplateListUpdateFilename (void);
static const char * getCentralServerAddress (void);
static const uint16 getCentralServerPort (void);
static const char * getCommoditiesServerAddress (void);
static const uint16 getCommoditiesServerPort (void);
static const char * getDSN (void);
static const char * getAlternateDSN (void);
static const char * getDatabaseUID (void);
static const char * getDatabasePWD (void);
static const char * getDatabaseProtocol (void);
static const uint16 getTaskManagerPort (void);
static const int getExpectedDBVersion (void);
static const bool isCorrectDBVersionRequired (void);
static const int getSaveFrequencyLimit (void);
static const char * getSchemaOwner (void);
static const char * getGoldSchemaOwner (void);
static const float getUniqueMessageCacheTimeSec(void);
static const int getLoaderThreads (void);
static const int getPersisterThreads (void);
static const int getNewCharacterThreads (void);
static const int getCharacterImmediateDeleteMinutes(void);
static const bool getLogObjectLoading (void);
static const bool getEnableQueryProfile (void);
static const bool getVerboseQueryMode (void);
static const bool getLogWorkerThreads (void);
static const char * getGameServiceBindInterface (void);
static const bool getReportSaveTimes (void);
static const bool getShouldSleep (void);
static const bool getEnableLoadLocks (void);
static const int getDatabaseReconnectTime (void);
static const bool getLogChunkLoading (void);
static const bool getUseMemoryManagerForOCI (void);
static const int getMaxCharactersPerLoadRequest(void);
static const int getMaxChunksPerLoadRequest (void);
static const float getMaxLoadStartDelay (void);
static const int getMaxErrorCountBeforeDisconnect (void);
static const int getMaxErrorCountBeforeBailout (void);
static const int getErrorSleepTime (void);
static const int getDisconnectSleepTime (void);
static const int getSaveAtModulus (void);
static const int getSaveAtDivisor (void);
static const int getBackloggedQueueSize (void);
static const int getBackloggedRecoveryQueueSize(void);
static const int getMaxTimewarp (void);
static const bool getEnableObjvarPacking (void);
static const int getPrefetchNumRows (void);
static const int getPrefetchMemory (void);
static const int getDefaultFetchBatchSize (void);
static const int getQueryReportingRate (void);
static const int getEnableDatabaseErrorLogging (void);
static const int getDefaultMessageBulkBindSize (void);
static const bool getEnableGoldDatabase (void);
static const NetworkId &getMaxGoldNetworkId (void);
static const float getDefaultQueueUpdateTimeLimit(void);
static const bool ConfigServerDatabase::getEnableDataCleanup(void);
static const int getDefaultLazyDeleteBulkBindSize (void);
static const int getDefaultLazyDeleteSleepTime (void);
static const int getWriteDelay (void);
static const bool getDelayUnloadIfObjectStillHasData(void);
static const float getExperienceConsolidationTime (void);
static const int getMaxLoaderFinishedTasks (void);
static const float getReportLongFrameTime (void);
static const bool getEnableVerboseMessageLogging(void);
static const bool getProfilerExpandAll (void);
static const int getProfilerDisplayPercentageMinimum(void);
static const bool getFatalOnDataError (void);
static const int getMaxUnackedLoadCount (void);
static const int getMaxUnackedLoadCountPerServer(void);
static const int getAuctionLocationLoadBatchSize(void);
static const int getAuctionLoadBatchSize(void);
static const int getAuctionAttributeLoadBatchSize(void);
static const int getAuctionBidLoadBatchSize(void);
static const int getOldestUnackedLoadAlertThresholdSeconds(void);
};
//-----------------------------------------------------------------------
inline const bool ConfigServerDatabase::getShouldSleep(void)
{
return data->shouldSleep;
}
//-----------------------------------------------------------------------
inline const int ConfigServerDatabase::getObjvarNameCleanupTime(void)
{
return data->objvarNameCleanupTime;
}
//-----------------------------------------------------------------------
inline const int ConfigServerDatabase::getOrphanedObjectCleanupTime(void)
{
return data->orphanedObjectCleanupTime;
}
//-----------------------------------------------------------------------
inline const int ConfigServerDatabase::getMarketAttributesCleanupTime(void)
{
return data->marketAttributesCleanupTime;
}
//-----------------------------------------------------------------------
inline const int ConfigServerDatabase::getMessagesCleanupTime(void)
{
return data->messagesCleanupTime;
}
//-----------------------------------------------------------------------
inline const int ConfigServerDatabase::getBrokenObjectCleanupTime(void)
{
return data->brokenObjectCleanupTime;
}
//-----------------------------------------------------------------------
inline const int ConfigServerDatabase::getVendorObjectCleanupTime(void)
{
return data->vendorObjectCleanupTime;
}
//-----------------------------------------------------------------------
inline const char * ConfigServerDatabase::getCustomSQLFilename(void)
{
return data->customSQLFilename;
}
//-----------------------------------------------------------------------
inline bool ConfigServerDatabase::getEnableFixBadCells(void)
{
return data->enableFixBadCells;
}
//-----------------------------------------------------------------------
inline const char * ConfigServerDatabase::getObjectTemplateListUpdateFilename(void)
{
return data->objectTemplateListUpdateFilename;
}
//-----------------------------------------------------------------------
inline const char * ConfigServerDatabase::getCentralServerAddress(void)
{
return data->centralServerAddress;
}
//-----------------------------------------------------------------------
inline const uint16 ConfigServerDatabase::getCentralServerPort(void)
{
return static_cast<const uint16>(data->centralServerPort);
}
//-----------------------------------------------------------------------
inline const char * ConfigServerDatabase::getCommoditiesServerAddress(void)
{
return data->commoditiesServerAddress;
}
//-----------------------------------------------------------------------
inline const uint16 ConfigServerDatabase::getCommoditiesServerPort(void)
{
return static_cast<const uint16>(data->commoditiesServerPort);
}
//-----------------------------------------------------------------------
inline const char * ConfigServerDatabase::getDSN(void)
{
return data->DSN;
}
//-----------------------------------------------------------------------
inline const char * ConfigServerDatabase::getAlternateDSN(void)
{
return data->alternateDSN;
}
//-----------------------------------------------------------------------
inline const char * ConfigServerDatabase::getDatabaseUID(void)
{
return data->databaseUID;
}
//-----------------------------------------------------------------------
inline const char * ConfigServerDatabase::getDatabasePWD(void)
{
return data->databasePWD;
}
//-----------------------------------------------------------------------
inline const char * ConfigServerDatabase::getDatabaseProtocol(void)
{
return data->databaseProtocol;
}
//-----------------------------------------------------------------------
inline const uint16 ConfigServerDatabase::getTaskManagerPort(void)
{
return static_cast<const uint16>(data->taskManagerPort);
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getExpectedDBVersion(void)
{
return data->expectedDBVersion;
}
// ----------------------------------------------------------------------
inline const bool ConfigServerDatabase::isCorrectDBVersionRequired(void)
{
return data->correctDBVersionRequired;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getSaveFrequencyLimit(void)
{
return data->saveFrequencyLimit;
}
// ----------------------------------------------------------------------
inline const char *ConfigServerDatabase::getSchemaOwner(void)
{
return data->schemaOwner;
}
// ----------------------------------------------------------------------
inline const char *ConfigServerDatabase::getGoldSchemaOwner(void)
{
return data->goldSchemaOwner;
}
// ----------------------------------------------------------------------
inline const float ConfigServerDatabase::getUniqueMessageCacheTimeSec(void)
{
return data->uniqueMessageCacheTimeSec;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getLoaderThreads(void)
{
return data->loaderThreads;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getPersisterThreads(void)
{
return data->persisterThreads;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getCharacterImmediateDeleteMinutes(void)
{
return data->characterImmediateDeleteMinutes;
}
// ----------------------------------------------------------------------
inline const bool ConfigServerDatabase::getLogObjectLoading(void)
{
return data->logObjectLoading;
}
// ----------------------------------------------------------------------
inline const bool ConfigServerDatabase::getEnableQueryProfile(void)
{
return data->enableQueryProfile;
}
// ----------------------------------------------------------------------
inline const bool ConfigServerDatabase::getVerboseQueryMode(void)
{
return data->verboseQueryMode;
}
// ----------------------------------------------------------------------
inline const bool ConfigServerDatabase::getLogWorkerThreads(void)
{
return data->logWorkerThreads;
}
// ----------------------------------------------------------------------
inline const char * ConfigServerDatabase::getGameServiceBindInterface(void)
{
return data->gameServiceBindInterface;
}
// ----------------------------------------------------------------------
inline const bool ConfigServerDatabase::getReportSaveTimes(void)
{
return data->reportSaveTimes;
}
// ----------------------------------------------------------------------
inline const bool ConfigServerDatabase::getEnableLoadLocks(void)
{
return data->enableLoadLocks;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getNewCharacterThreads(void)
{
return data->newCharacterThreads;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getDatabaseReconnectTime(void)
{
return data->databaseReconnectTime;
}
// ----------------------------------------------------------------------
inline const bool ConfigServerDatabase::getLogChunkLoading(void)
{
return data->logChunkLoading;
}
// ----------------------------------------------------------------------
inline const bool ConfigServerDatabase::getUseMemoryManagerForOCI(void)
{
return data->useMemoryManagerForOCI;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getMaxCharactersPerLoadRequest(void)
{
return data->maxCharactersPerLoadRequest;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getMaxChunksPerLoadRequest(void)
{
return data->maxChunksPerLoadRequest;
}
// ----------------------------------------------------------------------
inline const float ConfigServerDatabase::getMaxLoadStartDelay(void)
{
return data->maxLoadStartDelay;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getMaxErrorCountBeforeDisconnect(void)
{
return data->maxErrorCountBeforeDisconnect;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getMaxErrorCountBeforeBailout(void)
{
return data->maxErrorCountBeforeBailout;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getErrorSleepTime(void)
{
return data->errorSleepTime;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getDisconnectSleepTime(void)
{
return data->disconnectSleepTime;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getSaveAtModulus(void)
{
return data->saveAtModulus;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getSaveAtDivisor(void)
{
return data->saveAtDivisor;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getBackloggedQueueSize(void)
{
return data->backloggedQueueSize;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getBackloggedRecoveryQueueSize(void)
{
return data->backloggedRecoveryQueueSize;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getMaxTimewarp(void)
{
return data->maxTimewarp;
}
// ----------------------------------------------------------------------
inline const bool ConfigServerDatabase::getEnableObjvarPacking(void)
{
return data->enableObjvarPacking;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getPrefetchNumRows(void)
{
return data->prefetchNumRows;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getPrefetchMemory(void)
{
return data->prefetchMemory;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getDefaultFetchBatchSize(void)
{
return data->defaultFetchBatchSize;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getQueryReportingRate(void)
{
return data->queryReportingRate;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getEnableDatabaseErrorLogging(void)
{
return data->enableDatabaseErrorLogging;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getDefaultMessageBulkBindSize(void)
{
return data->defaultMessageBulkBindSize;
}
// ----------------------------------------------------------------------
inline const bool ConfigServerDatabase::getEnableGoldDatabase(void)
{
return data->enableGoldDatabase;
}
// ----------------------------------------------------------------------
inline const float ConfigServerDatabase::getDefaultQueueUpdateTimeLimit(void)
{
return data->defaultQueueUpdateTimeLimit;
}
// ----------------------------------------------------------------------
inline const bool ConfigServerDatabase::getEnableDataCleanup(void)
{
return data->enableDataCleanup;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getDefaultLazyDeleteBulkBindSize(void)
{
return data->defaultLazyDeleteBulkBindSize;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getDefaultLazyDeleteSleepTime(void)
{
return data->defaultLazyDeleteSleepTime;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getWriteDelay(void)
{
return data->writeDelay;
}
// ----------------------------------------------------------------------
inline const bool ConfigServerDatabase::getDelayUnloadIfObjectStillHasData(void)
{
return data->delayUnloadIfObjectStillHasData;
}
// ----------------------------------------------------------------------
inline const float ConfigServerDatabase::getExperienceConsolidationTime(void)
{
return data->experienceConsolidationTime;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getMaxLoaderFinishedTasks(void)
{
return data->maxLoaderFinishedTasks;
}
// ----------------------------------------------------------------------
inline const float ConfigServerDatabase::getReportLongFrameTime(void)
{
return data->reportLongFrameTime;
}
// ----------------------------------------------------------------------
inline const bool ConfigServerDatabase::getEnableVerboseMessageLogging(void)
{
return data->enableVerboseMessageLogging;
}
// ----------------------------------------------------------------------
inline const bool ConfigServerDatabase::getProfilerExpandAll(void)
{
return data->profilerExpandAll;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getProfilerDisplayPercentageMinimum(void)
{
return data->profilerDisplayPercentageMinimum;
}
// ----------------------------------------------------------------------
inline const bool ConfigServerDatabase::getFatalOnDataError(void)
{
return data->fatalOnDataError;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getMaxUnackedLoadCount(void)
{
return data->maxUnackedLoadCount;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getMaxUnackedLoadCountPerServer(void)
{
return data->maxUnackedLoadCountPerServer;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getAuctionLocationLoadBatchSize(void)
{
return data->auctionLocationLoadBatchSize;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getAuctionLoadBatchSize(void)
{
return data->auctionLoadBatchSize;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getAuctionAttributeLoadBatchSize(void)
{
return data->auctionAttributeLoadBatchSize;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getAuctionBidLoadBatchSize(void)
{
return data->auctionBidLoadBatchSize;
}
// ----------------------------------------------------------------------
inline const int ConfigServerDatabase::getOldestUnackedLoadAlertThresholdSeconds(void)
{
return data->oldestUnackedLoadAlertThresholdSeconds;
}
// ======================================================================
#endif
@@ -0,0 +1,67 @@
// ConsoleCommandParser.cpp
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
// Author: Justin Randall
//-----------------------------------------------------------------------
#include "serverDatabase/FirstServerDatabase.h"
#include "sharedFoundation/NetworkId.h"
#include "sharedLog/Log.h"
#include "ConsoleCommandParser.h"
#include "UnicodeUtils.h"
#include <vector>
#include "Unicode.h"
#pragma warning(disable: 4355) // Passing "this" to a base-class constructor
//-----------------------------------------------------------------------
namespace CommandNames
{
#define MAKE_COMMAND(a) const char * const a = #a
#undef MAKE_COMMAND
}
const CommandParser::CmdInfo cmds[] =
{
{"database", 0, "", ""},
{"", 0, "", ""} // this must be last
};
//-----------------------------------------------------------------------
ConsoleCommandParser::ConsoleCommandParser() :
CommandParser ("", 0, "...", "console commands", this)
{
createDelegateCommands(cmds);
}
//-----------------------------------------------------------------------
ConsoleCommandParser::~ConsoleCommandParser()
{
}
//-----------------------------------------------------------------------
bool ConsoleCommandParser::performParsing(const NetworkId & /* track*/, const StringVector_t & argv, const String_t &, String_t & result, const CommandParser *)
{
bool successResult = false;
if(isCommand(argv[0], "database"))
{
if(argv.size() > 1)
{
if(isCommand(argv[1], "runState"))
{
successResult = true;
result += Unicode::narrowToWide("running");
}
}
}
return successResult;
}
//-----------------------------------------------------------------------
@@ -0,0 +1,29 @@
// ConsoleCommandParser.h
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
// Author: Justin Randall
#ifndef _INCLUDED_ConsoleCommandParser_H
#define _INCLUDED_ConsoleCommandParser_H
//-----------------------------------------------------------------------
#include "sharedCommandParser/CommandParser.h"
//-----------------------------------------------------------------------
class ConsoleCommandParser : public CommandParser
{
public:
ConsoleCommandParser();
~ConsoleCommandParser();
virtual bool performParsing(const NetworkId & userId, const StringVector_t & argv,const String_t & originalCommand,String_t & result,const CommandParser * node);
private:
ConsoleCommandParser & operator = (const ConsoleCommandParser & rhs);
ConsoleCommandParser(const ConsoleCommandParser & source);
};
//-----------------------------------------------------------------------
#endif // _INCLUDED_ConsoleCommandParser_H
@@ -0,0 +1,58 @@
// ConsoleManager.cpp
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
// Author: Justin Randall
//-----------------------------------------------------------------------
#include "serverDatabase/FirstServerDatabase.h"
#include "sharedFoundation/NetworkId.h"
#include "ConsoleManager.h"
#include "ConsoleCommandParser.h"
#include "UnicodeUtils.h"
//-----------------------------------------------------------------------
namespace ConsoleManagerNamespace
{
ConsoleCommandParser * s_consoleCommandParserRoot = NULL;
}
using namespace ConsoleManagerNamespace;
//-----------------------------------------------------------------------
ConsoleManager::ConsoleManager()
{
}
//-----------------------------------------------------------------------
ConsoleManager::~ConsoleManager()
{
}
//-----------------------------------------------------------------------
void ConsoleManager::install()
{
s_consoleCommandParserRoot = new ConsoleCommandParser;
}
//-----------------------------------------------------------------------
void ConsoleManager::remove()
{
delete s_consoleCommandParserRoot;
}
//-----------------------------------------------------------------------
void ConsoleManager::processString(const std::string & msg, const int track, std::string & result)
{
Unicode::String wideResult;
IGNORE_RETURN(s_consoleCommandParserRoot->parse(NetworkId(static_cast<NetworkId::NetworkIdType>(track)), Unicode::narrowToWide(msg), wideResult));
result = Unicode::wideToNarrow(wideResult);
}
//-----------------------------------------------------------------------
@@ -0,0 +1,27 @@
// ConsoleManager.h
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
// Author: Justin Randall
#ifndef _INCLUDED_ConsoleManager_H
#define _INCLUDED_ConsoleManager_H
#include <string>
//-----------------------------------------------------------------------
class ConsoleManager
{
public:
static void install();
static void remove();
static void processString(const std::string & msg, const int track, std::string & result);
private:
ConsoleManager & operator = (const ConsoleManager & rhs);
ConsoleManager(const ConsoleManager & source);
ConsoleManager();
~ConsoleManager();
};
//-----------------------------------------------------------------------
#endif // _INCLUDED_ConsoleManager_H
@@ -0,0 +1,95 @@
// ======================================================================
//
// ContainedObjectLocator.cpp
// copyright (c) 2001 Sony Online Entertainment
//
// ======================================================================
#include "serverDatabase/FirstServerDatabase.h"
#include "serverDatabase/ContainedObjectLocator.h"
#include "serverDatabase/DatabaseProcess.h"
#include "serverDatabase/GameServerConnection.h"
#include "serverNetworkMessages/LoadContainedObjectMessage.h"
#include "sharedDatabaseInterface/DbSession.h"
#include "sharedLog/Log.h"
// ======================================================================
ContainedObjectLocator::ContainedObjectLocator(const NetworkId &containerId, const NetworkId &objectId) :
ObjectLocator(),
m_containerId(containerId),
m_objectId(objectId)
{
}
// ----------------------------------------------------------------------
ContainedObjectLocator::~ContainedObjectLocator()
{
}
// ----------------------------------------------------------------------
bool ContainedObjectLocator::locateObjects(DB::Session *session, const std::string &schema, int &objectsLocated)
{
NOT_NULL(session);
LocateObjectQuery qry(m_containerId, m_objectId, schema);
bool rval = session->exec(&qry);
qry.done();
objectsLocated = 1; //TODO: counts
return rval;
}
// ======================================================================
ContainedObjectLocator::LocateObjectQuery::LocateObjectQuery(const NetworkId &containerId, const NetworkId &objectId, const std::string &schema) :
container_id(containerId),
object_id(objectId),
m_schema(schema)
{
}
// ----------------------------------------------------------------------
void ContainedObjectLocator::LocateObjectQuery::getSQL(std::string &sql)
{
LOG("AuctionRetrieval", ("Loader:: calling LocateObjectQuery::getSQL() for loading object %s for retrieval", object_id.getValue().getValueString().c_str()));
sql = std::string("begin ") + m_schema + "loader.locate_contained_object (:container_id, :object_id); end;";
}
// ----------------------------------------------------------------------
bool ContainedObjectLocator::LocateObjectQuery::bindParameters()
{
if (!bindParameter(container_id)) return false;
if (!bindParameter(object_id)) return false;
return true;
}
// ----------------------------------------------------------------------
bool ContainedObjectLocator::LocateObjectQuery::bindColumns()
{
return true;
}
// ----------------------------------------------------------------------
DB::Query::QueryMode ContainedObjectLocator::LocateObjectQuery::getExecutionMode() const
{
return MODE_PROCEXEC;
}
// ----------------------------------------------------------------------
void ContainedObjectLocator::sendPostBaselinesCustomData (GameServerConnection &conn) const
{
LOG("AuctionRetrieval", ("Loader:: sending post baselines data for loading object %s for retrieval", m_objectId.getValueString().c_str()));
LoadContainedObjectMessage msg(m_containerId, m_objectId);
conn.send(msg,true);
}
// ======================================================================
@@ -0,0 +1,64 @@
// ======================================================================
//
// ContainedObjectLocator.h
// copyright (c) 2001 Sony Online Entertainment
//
// ======================================================================
#ifndef INCLUDED_ContainedObjectLocator_H
#define INCLUDED_ContainedObjectLocator_H
#include "serverDatabase/ObjectLocator.h"
#include "sharedDatabaseInterface/BindableNetworkId.h"
#include "sharedDatabaseInterface/DbQuery.h"
#include "sharedFoundation/NetworkId.h"
// ======================================================================
/**
* Locate a specified character and add it to the list of objects to be
* loaded by the Snapshot.
*/
class ContainedObjectLocator : public ObjectLocator
{
public:
ContainedObjectLocator (const NetworkId &containerId, const NetworkId &objectId);
virtual ~ContainedObjectLocator ();
public:
virtual bool locateObjects (DB::Session *session, const std::string &schema, int &objectsLocated);
virtual void sendPostBaselinesCustomData (GameServerConnection &conn) const;
private:
NetworkId m_containerId;
NetworkId m_objectId;
private:
class LocateObjectQuery : public DB::Query
{
public:
LocateObjectQuery (const NetworkId &containerId, const NetworkId &objectId, const std::string &schema);
virtual void getSQL (std::string &sql);
virtual bool bindParameters ();
virtual bool bindColumns ();
private:
virtual DB::Query::QueryMode getExecutionMode() const;
private:
LocateObjectQuery (const LocateObjectQuery&); // disable
LocateObjectQuery& operator= (const LocateObjectQuery&); //disable
public:
DB::BindableNetworkId container_id;
DB::BindableNetworkId object_id;
private:
std::string m_schema;
};
};
// ======================================================================
#endif
@@ -0,0 +1,89 @@
// ======================================================================
//
// ContentsLocator.cpp
// copyright (c) 2002 Sony Online Entertainment
//
// ======================================================================
#include "serverDatabase/FirstServerDatabase.h"
#include "serverDatabase/ContentsLocator.h"
#include "serverDatabase/DatabaseProcess.h"
#include "serverDatabase/GameServerConnection.h"
#include "serverNetworkMessages/LoadContentsMessage.h"
#include "sharedDatabaseInterface/DbSession.h"
// ======================================================================
ContentsLocator::ContentsLocator(const NetworkId &containerId) :
ObjectLocator(),
m_containerId(containerId)
{
}
// ----------------------------------------------------------------------
ContentsLocator::~ContentsLocator()
{
}
// ----------------------------------------------------------------------
bool ContentsLocator::locateObjects(DB::Session *session, const std::string &schema, int &objectsLocated)
{
NOT_NULL(session);
LocateObjectQuery qry(m_containerId, schema);
bool rval = session->exec(&qry);
qry.done();
objectsLocated = 1; //TODO: counts
return rval;
}
// ======================================================================
ContentsLocator::LocateObjectQuery::LocateObjectQuery(const NetworkId &containerId, const std::string &schema) :
container_id(containerId),
m_schema(schema)
{
}
// ----------------------------------------------------------------------
void ContentsLocator::LocateObjectQuery::getSQL(std::string &sql)
{
sql = std::string("begin ") + m_schema + "loader.locate_contents (:container_id); end;";
}
// ----------------------------------------------------------------------
bool ContentsLocator::LocateObjectQuery::bindParameters()
{
if (!bindParameter(container_id)) return false;
return true;
}
// ----------------------------------------------------------------------
bool ContentsLocator::LocateObjectQuery::bindColumns()
{
return true;
}
// ----------------------------------------------------------------------
DB::Query::QueryMode ContentsLocator::LocateObjectQuery::getExecutionMode() const
{
return MODE_PROCEXEC;
}
// ----------------------------------------------------------------------
void ContentsLocator::sendPostBaselinesCustomData (GameServerConnection &conn) const
{
LoadContentsMessage msg(m_containerId);
conn.send(msg,true);
}
// ======================================================================
@@ -0,0 +1,62 @@
// ======================================================================
//
// ContentsLocator.h
// copyright (c) 2002 Sony Online Entertainment
//
// ======================================================================
#ifndef INCLUDED_ContentsLocator_H
#define INCLUDED_ContentsLocator_H
#include "serverDatabase/ObjectLocator.h"
#include "sharedDatabaseInterface/BindableNetworkId.h"
#include "sharedDatabaseInterface/DbQuery.h"
#include "sharedFoundation/NetworkId.h"
// ======================================================================
/**
* Locate a specified character and add it to the list of objects to be
* loaded by the Snapshot.
*/
class ContentsLocator : public ObjectLocator
{
public:
ContentsLocator (const NetworkId &containerId);
virtual ~ContentsLocator ();
public:
virtual bool locateObjects (DB::Session *session, const std::string &schema, int &objectsLocated);
virtual void sendPostBaselinesCustomData (GameServerConnection &conn) const;
private:
NetworkId m_containerId;
private:
class LocateObjectQuery : public DB::Query
{
public:
LocateObjectQuery (const NetworkId &containerId, const std::string &schema);
virtual void getSQL (std::string &sql);
virtual bool bindParameters ();
virtual bool bindColumns ();
private:
virtual DB::Query::QueryMode getExecutionMode() const;
private:
LocateObjectQuery (const LocateObjectQuery&); // disable
LocateObjectQuery& operator= (const LocateObjectQuery&); // disable
public:
DB::BindableNetworkId container_id;
private:
std::string m_schema;
};
};
// ======================================================================
#endif
@@ -0,0 +1,66 @@
// ======================================================================
//
// CreateCharacterCustomPersistStep.cpp
// copyright (c) 2001 Sony Online Entertainment
//
// ======================================================================
#include "serverDatabase/FirstServerDatabase.h"
#include "serverDatabase/CreateCharacterCustomPersistStep.h"
#include "serverDatabase/CharacterQueries.h"
#include "serverDatabase/DatabaseProcess.h"
#include "serverDatabase/DataLookup.h"
#include "serverDatabase/Persister.h"
#include "sharedDatabaseInterface/DbSession.h"
#include "sharedLog/Log.h"
// ======================================================================
CreateCharacterCustomPersistStep::CreateCharacterCustomPersistStep(uint32 stationId, const NetworkId &characterObject, const Unicode::String &characterName, const std::string &normalizedName, int templateId, bool special) :
m_stationId(stationId),
m_characterObject(characterObject),
m_characterName(characterName),
m_normalizedName(normalizedName),
m_templateId(templateId),
m_clusterName(DatabaseProcess::getInstance().getClusterName()),
m_special(special)
{
}
// ----------------------------------------------------------------------
CreateCharacterCustomPersistStep::~CreateCharacterCustomPersistStep()
{
}
// ----------------------------------------------------------------------
bool CreateCharacterCustomPersistStep::beforePersist(DB::Session *session)
{
UNREF(session);
return true;
}
// ----------------------------------------------------------------------
bool CreateCharacterCustomPersistStep::afterPersist(DB::Session *session)
{
// std::string characterName = Unicode::wideToNarrow(DatabaseProcess::getInstance().getNameByStationId(m_stationId));
DBQuery::AddCharacter qry(m_stationId,m_characterObject, m_characterName, m_normalizedName);
if (! (session->exec(&qry)))
return false;
qry.done();
return true;
}
// ----------------------------------------------------------------------
void CreateCharacterCustomPersistStep::onComplete()
{
Persister::getInstance().onNewCharacterSaved(m_stationId,m_characterObject,m_characterName,m_templateId,m_special);
DataLookup::getInstance().releaseName(m_stationId, NetworkId::cms_invalid);
LOG("TraceCharacterCreation", ("%d CreateCharacterCustomPersistStep(%s) complete", m_stationId, Unicode::wideToNarrow(m_characterName).c_str()));
}
// ======================================================================
@@ -0,0 +1,48 @@
// ======================================================================
//
// CreateCharacterCustomPersistStep.h
// copyright (c) 2001 Sony Online Entertainment
//
// ======================================================================
#ifndef INCLUDED_CreateCharacterCustomPersistStep_H
#define INCLUDED_CreateCharacterCustomPersistStep_H
// ======================================================================
#include "serverDatabase/CustomPersistStep.h"
#include "sharedFoundation/NetworkId.h"
#include "Unicode.h"
#include <string>
class NetworkId;
// ======================================================================
class CreateCharacterCustomPersistStep : public CustomPersistStep
{
public:
CreateCharacterCustomPersistStep(uint32 stationId, const NetworkId &characterObject, const Unicode::String &characterName, const std::string &normalizedName, const int templateId, bool special);
~CreateCharacterCustomPersistStep();
virtual bool beforePersist (DB::Session *session);
virtual bool afterPersist (DB::Session *session);
virtual void onComplete ();
private:
uint32 m_stationId;
NetworkId m_characterObject;
Unicode::String m_characterName;
std::string m_normalizedName;
int m_templateId;
std::string m_clusterName;
bool m_special;
private:
CreateCharacterCustomPersistStep &operator= (const CreateCharacterCustomPersistStep&); //disable
CreateCharacterCustomPersistStep(const CreateCharacterCustomPersistStep&); //disable
};
// ======================================================================
#endif
@@ -0,0 +1,17 @@
// ======================================================================
//
// CustomPersistStep.cpp
// copyright (c) 2001 Sony Online Entertainment
//
// ======================================================================
#include "serverDatabase/FirstServerDatabase.h"
#include "serverDatabase/CustomPersistStep.h"
// ======================================================================
CustomPersistStep::~CustomPersistStep()
{
}
// ======================================================================

Some files were not shown because too many files have changed in this diff Show More