diff --git a/engine/server/application/CMakeLists.txt b/engine/server/application/CMakeLists.txt index b96af8e1..bd0461c8 100644 --- a/engine/server/application/CMakeLists.txt +++ b/engine/server/application/CMakeLists.txt @@ -9,5 +9,6 @@ add_subdirectory(LoginServer) add_subdirectory(MetricsServer) add_subdirectory(PlanetServer) add_subdirectory(ServerConsole) +add_subdirectory(StationPlayersCollector) add_subdirectory(TaskManager) add_subdirectory(TransferServer) diff --git a/engine/server/application/LoginServer/src/CMakeLists.txt b/engine/server/application/LoginServer/src/CMakeLists.txt index 17a945a0..3239fe14 100644 --- a/engine/server/application/LoginServer/src/CMakeLists.txt +++ b/engine/server/application/LoginServer/src/CMakeLists.txt @@ -75,7 +75,7 @@ if(WIN32) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/win32) else() - set(PLATFORM_SOURCES + set(PLATFORM_SOURCES linux/main.cpp ) @@ -158,10 +158,8 @@ target_link_libraries(LoginServer MonAPI2 udplibrary ${STLPORT_LIBRARIES} - ${ZLIB_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS} - ${ORACLE_LIBRARY} ) if(WIN32) diff --git a/engine/server/application/StationPlayersCollector/CMakeLists.txt b/engine/server/application/StationPlayersCollector/CMakeLists.txt new file mode 100644 index 00000000..60fab7e4 --- /dev/null +++ b/engine/server/application/StationPlayersCollector/CMakeLists.txt @@ -0,0 +1,6 @@ + +cmake_minimum_required(VERSION 2.8) + +project(StationPlayersCollector) + +add_subdirectory(src) diff --git a/engine/server/application/StationPlayersCollector/src/CMakeLists.txt b/engine/server/application/StationPlayersCollector/src/CMakeLists.txt new file mode 100644 index 00000000..edd946b7 --- /dev/null +++ b/engine/server/application/StationPlayersCollector/src/CMakeLists.txt @@ -0,0 +1,77 @@ + +set(SHARED_SOURCES + shared/CentralServerConnection.cpp + shared/CentralServerConnection.h + shared/StationPlayersCollector.cpp + shared/StationPlayersCollector.h + shared/StationPlayersCollectorImpl.cpp + shared/StationPlayersCollectorImpl.h + shared/ConfigStationPlayersCollector.cpp + shared/ConfigStationPlayersCollector.h + shared/DatabaseConnection.cpp + shared/DatabaseConnection.h + shared/TaskUpdateSPCharacterProfileData.cpp + shared/TaskUpdateSPCharacterProfileData.h +) + +if(WIN32) + set(PLATFORM_SOURCES "") +else() + set(PLATFORM_SOURCES + linux/main.cpp + ) +endif() + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR}/shared + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedCompression/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedDatabaseInterface/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedDebug/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFile/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/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/sharedRandom/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/serverBase/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/unicode/include +) + +link_directories(${STLPORT_LIBDIR}) + +add_executable(StationPlayersCollector + ${SHARED_SOURCES} + ${PLATFORM_SOURCES} +) + +target_link_libraries(StationPlayersCollector + sharedCompression + sharedDatabaseInterface + sharedDatabaseInterface_oci + sharedDebug + sharedFile + sharedFoundation + sharedLog + sharedMemoryManager + sharedMessageDispatch + sharedNetwork + sharedNetworkMessages + sharedRandom + sharedThread + serverBase + serverNetworkMessages + serverUtility + archive + unicode + ${STLPORT_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} + ${CMAKE_DL_LIBS} +) diff --git a/engine/server/application/StationPlayersCollector/src/linux/main.cpp b/engine/server/application/StationPlayersCollector/src/linux/main.cpp new file mode 100644 index 00000000..7112ccde --- /dev/null +++ b/engine/server/application/StationPlayersCollector/src/linux/main.cpp @@ -0,0 +1,48 @@ +#include "sharedFoundation/FirstSharedFoundation.h" + +#include "ConfigStationPlayersCollector.h" +#include "StationPlayersCollector.h" + +#include "sharedCompression/SetupSharedCompression.h" +#include "sharedDebug/SetupSharedDebug.h" +#include "sharedFile/SetupSharedFile.h" +#include "sharedFoundation/ConfigFile.h" +#include "sharedFoundation/Os.h" +#include "sharedFoundation/SetupSharedFoundation.h" +#include "sharedNetworkMessages/SetupSharedNetworkMessages.h" +#include "sharedRandom/SetupSharedRandom.h" +#include "sharedThread/SetupSharedThread.h" + +// ====================================================================== + +int main(int argc, char ** argv) +{ + + SetupSharedThread::install(); + SetupSharedDebug::install(1024); + + //-- setup foundation + SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game); + setupFoundationData.lpCmdLine = ConvertCommandLine(argc,argv); + setupFoundationData.configFile = "stationPlayersCollector.cfg"; + SetupSharedFoundation::install (setupFoundationData); + + if (ConfigFile::isEmpty()) + FATAL(true, ("No config file specified")); + + SetupSharedCompression::install(); + + SetupSharedFile::install(false); + SetupSharedNetworkMessages::install(); + + SetupSharedRandom::install(static_cast(time(NULL))); //lint !e1924 !e64 // NULL is a C-Style cast? + + Os::setProgramName("StationPlayersCollector"); + + //-- run game + StationPlayersCollector::install(); + SetupSharedFoundation::callbackWithExceptionHandling(StationPlayersCollector::run); + SetupSharedFoundation::remove(); + + return 0; +} diff --git a/engine/server/application/StationPlayersCollector/src/shared/CentralServerConnection.cpp b/engine/server/application/StationPlayersCollector/src/shared/CentralServerConnection.cpp new file mode 100644 index 00000000..ca07f218 --- /dev/null +++ b/engine/server/application/StationPlayersCollector/src/shared/CentralServerConnection.cpp @@ -0,0 +1,126 @@ +// ====================================================================== +// +// CentralServerConnection.cpp +// copyright (c) 2005 Sony Online Entertainment +// Author: Doug Mellencamp +// +// ====================================================================== + +#include "FirstStationPlayersCollector.h" +#include "StationPlayersCollector.h" +#include "CentralServerConnection.h" + +#include "Archive/ByteStream.h" +#include "sharedFoundation/NetworkId.h" +#include "sharedLog/Log.h" +#include "sharedNetworkMessages/GenericValueTypeMessage.h" +#include "sharedNetwork/NetworkSetupData.h" +#include "UnicodeUtils.h" + +// ====================================================================== + +namespace CentralServerConnectionNamespace +{ + static std::map s_centralServerConnections; +} + +using namespace CentralServerConnectionNamespace; + +// ====================================================================== + + +CentralServerConnection::CentralServerConnection(UdpConnectionMT * u, TcpClient * t) : + ServerConnection(u, t) +{ +} + +//----------------------------------------------------------------------- + +CentralServerConnection::CentralServerConnection(const std::string & a, const unsigned short p) : + ServerConnection(a, p, NetworkSetupData()) +{ +} + +//----------------------------------------------------------------------- + +CentralServerConnection::~CentralServerConnection() +{ +} + +//----------------------------------------------------------------------- + +void CentralServerConnection::onConnectionClosed() +{ + + DEBUG_REPORT_LOG(true, ("[StationPlayersCollector] : CentralServerConnection::onConnectionClosed()\n")); + + ServerConnection::onConnectionClosed(); + + s_centralServerConnections.erase(getProcessId()); + + //static MessageConnectionCallback m("centralConnectionClosed"); + //emitMessage(m); +} + +//----------------------------------------------------------------------- + +void CentralServerConnection::onConnectionOpened() +{ + + DEBUG_REPORT_LOG(true, ("[StationPlayersCollector] : CentralServerConnection::onConnectionOpened()\n")); + + ServerConnection::onConnectionOpened(); + + s_centralServerConnections[getProcessId()]=this; + +} + +// ---------------------------------------------------------------------- + +void CentralServerConnection::onReceive(const Archive::ByteStream & message) +{ + DEBUG_REPORT_LOG(true, ("[StationPlayersCollector] : CentralServerConnection::onReceive() ... ")); + Archive::ReadIterator ri = message.begin(); + GameNetworkMessage msg(ri); + ri = message.begin(); + + if (msg.isType("SPCharacterProfileMessage")) + { + DEBUG_REPORT_LOG(true,(" Got SPCharacterProfileMessage:")); + StationPlayersCollector::handleSPCharacterProfileData(msg); + } + else if ( msg.isType("SomeOtherMessage") ) + { + + } + else + { + DEBUG_REPORT_LOG(true, ("Got (%s) handing off to ServerConnection::onReceive\n", msg.getCmdName().c_str())); + ServerConnection::onReceive(message); + } +} + +//----------------------------------------------------------------------- + +CentralServerConnection * CentralServerConnection::getConnectionById(const uint32 serverId) +{ + CentralServerConnection * result = 0; + std::map::const_iterator j = s_centralServerConnections.find(serverId); + if(j != s_centralServerConnections.end()) + { + result = (*j).second; + } + return result; +} + +// ---------------------------------------------------------------------- + +//These ids might not be unique across multiple clusters +void CentralServerConnection::getServerIds(std::vector &serverIds) +{ + for (std::map::const_iterator i = s_centralServerConnections.begin(); i != s_centralServerConnections.end(); ++i) + serverIds.push_back((*i).first); +} + +// ---------------------------------------------------------------------- + diff --git a/engine/server/application/StationPlayersCollector/src/shared/CentralServerConnection.h b/engine/server/application/StationPlayersCollector/src/shared/CentralServerConnection.h new file mode 100644 index 00000000..81dc28e0 --- /dev/null +++ b/engine/server/application/StationPlayersCollector/src/shared/CentralServerConnection.h @@ -0,0 +1,40 @@ +// ====================================================================== +// +// CentralServerConnection.h +// copyright (c) 2005 Sony Online Entertainment +// Author: Doug Mellencamp +// +// ====================================================================== + +#ifndef _CentralServerConnection_H +#define _CentralServerConnection_H + +//----------------------------------------------------------------------- + +#include "serverUtility/ServerConnection.h" + +//----------------------------------------------------------------------- + +class CentralServerConnection : public ServerConnection +{ +public: + CentralServerConnection(UdpConnectionMT *, TcpClient * t); + CentralServerConnection(const std::string & remoteAddress, const unsigned short remotePort); + ~CentralServerConnection(); + virtual void onConnectionClosed (); + virtual void onConnectionOpened (); + virtual void onReceive (const Archive::ByteStream & message); + + // Internal Connection tracking by processid + static CentralServerConnection * getConnectionById (const uint32 serverId); + static void getServerIds (std::vector &serverIds); + +private: + + CentralServerConnection (const CentralServerConnection&); + CentralServerConnection& operator= (const CentralServerConnection&); +}; + +//----------------------------------------------------------------------- + +#endif // _CentralServerConnection_H diff --git a/engine/server/application/StationPlayersCollector/src/shared/ConfigStationPlayersCollector.cpp b/engine/server/application/StationPlayersCollector/src/shared/ConfigStationPlayersCollector.cpp new file mode 100644 index 00000000..19c20417 --- /dev/null +++ b/engine/server/application/StationPlayersCollector/src/shared/ConfigStationPlayersCollector.cpp @@ -0,0 +1,167 @@ +// ====================================================================== +// +// ConfigStationPlayersCollector.cpp +// Copyright 2005, Sony Online Entertainment Inc., all rights reserved. +// Author: Doug Mellencamp +// +// ====================================================================== + +//----------------------------------------------------------------------- + +#include "FirstStationPlayersCollector.h" +#include "sharedFoundation/ConfigFile.h" +#include "sharedNetwork/SetupSharedNetwork.h" +#include "ConfigStationPlayersCollector.h" + +//----------------------------------------------------------------------- + +ConfigStationPlayersCollector::Data * ConfigStationPlayersCollector::data = 0; + +#define KEY_INT(a,b) (data->a = ConfigFile::getKeyInt("StationPlayersCollector", #a, b)) +#define KEY_BOOL(a,b) (data->a = ConfigFile::getKeyBool("StationPlayersCollector", #a, b)) +#define KEY_FLOAT(a,b) (data->a = ConfigFile::getKeyFloat("StationPlayersCollector", #a, b)) +#define KEY_STRING(a,b) (data->a = ConfigFile::getKeyString("StationPlayersCollector", #a, b)) + +//----------------------------------------------------------------------- + +void ConfigStationPlayersCollector::install(void) +{ + SetupSharedNetwork::SetupData networkSetupData; + SetupSharedNetwork::getDefaultServerSetupData(networkSetupData); + + data = new ConfigStationPlayersCollector::Data; + + KEY_INT (centralServerServiceBindPort, 50010); + KEY_STRING (centralServerServiceBindInterface, "localhost"); + KEY_STRING (dsn,"swodb"); + KEY_STRING (databaseUID,"character_data"); + KEY_STRING (databasePWD, "changeme"); + KEY_STRING (databaseSchema, "character_data"); + KEY_INT (secondsBetweenDBReconnect, 45); + KEY_STRING (databaseProtocol, "OCI"); + KEY_BOOL (enableQueryProfile,false); + KEY_BOOL (verboseQueryMode,false); + KEY_INT (databaseThreads, 3); + KEY_BOOL (logWorkerThreads, false); + KEY_FLOAT (defaultDBQueueUpdateTimeLimit, 0.25f); + KEY_INT (disconnectSleepTime, 30000); + KEY_BOOL (showAllDebugInfo, false); +} + +//----------------------------------------------------------------------- + +void ConfigStationPlayersCollector::remove(void) +{ + delete data; + data = 0; +} + +//----------------------------------------------------------------------- + +unsigned short ConfigStationPlayersCollector::getCentralServerServiceBindPort() +{ + return data->centralServerServiceBindPort; +} + +//----------------------------------------------------------------------- + +const char * ConfigStationPlayersCollector::getCentralServerServiceBindInterface() +{ + return data->centralServerServiceBindInterface; +} + +//----------------------------------------------------------------------- + +const char * ConfigStationPlayersCollector::getDSN() +{ + return data->dsn; +} + +//----------------------------------------------------------------------- + +const char * ConfigStationPlayersCollector::getDatabaseUID() +{ + return data->databaseUID; +} + +//----------------------------------------------------------------------- + + +const char * ConfigStationPlayersCollector::getDatabasePWD() +{ + return data->databasePWD; +} + +//----------------------------------------------------------------------- + +const char * ConfigStationPlayersCollector::getDatabaseSchema() +{ + return data->databaseSchema; +} + +//----------------------------------------------------------------------- + +unsigned short ConfigStationPlayersCollector::getSecondsBetweenDBReconnect() +{ + return data->secondsBetweenDBReconnect; +} + +//----------------------------------------------------------------------- + + +const char * ConfigStationPlayersCollector::getDatabaseProtocol() +{ + return (data->databaseProtocol); +} + +//----------------------------------------------------------------------- + + +const bool ConfigStationPlayersCollector::getEnableQueryProfile() +{ + return (data->enableQueryProfile); +} + +// ---------------------------------------------------------------------- + +const bool ConfigStationPlayersCollector::getVerboseQueryMode() +{ + return (data->verboseQueryMode); +} + +// ---------------------------------------------------------------------- + +int ConfigStationPlayersCollector::getDatabaseThreads() +{ + return (data->databaseThreads); +} + +// ---------------------------------------------------------------------- + +const bool ConfigStationPlayersCollector::getLogWorkerThreads() +{ + return data->logWorkerThreads; +} + +// ---------------------------------------------------------------------- + +float ConfigStationPlayersCollector::getDefaultDBQueueUpdateTimeLimit() +{ + return data->defaultDBQueueUpdateTimeLimit; +} + +// ---------------------------------------------------------------------- + +const int ConfigStationPlayersCollector::getDisconnectSleepTime() +{ + return data->disconnectSleepTime; +} + +// ---------------------------------------------------------------------- + +const bool ConfigStationPlayersCollector::getShowAllDebugInfo() +{ + return data->showAllDebugInfo; +} + +// ---------------------------------------------------------------------- diff --git a/engine/server/application/StationPlayersCollector/src/shared/ConfigStationPlayersCollector.h b/engine/server/application/StationPlayersCollector/src/shared/ConfigStationPlayersCollector.h new file mode 100644 index 00000000..71fa5986 --- /dev/null +++ b/engine/server/application/StationPlayersCollector/src/shared/ConfigStationPlayersCollector.h @@ -0,0 +1,63 @@ +// ====================================================================== +// +// ConfigStationPlayersCollector.h +// Copyright 2005, Sony Online Entertainment Inc., all rights reserved. +// Author: Doug Mellencamp +// +// ====================================================================== + +#ifndef _ConfigStationPlayersCollector_H +#define _ConfigStationPlayersCollector_H + +//----------------------------------------------------------------------- + +class ConfigStationPlayersCollector +{ + public: + struct Data + { + int centralServerServiceBindPort; + const char * centralServerServiceBindInterface; + const char * dsn; + const char * databaseUID; + const char * databasePWD; + const char * databaseSchema; + int secondsBetweenDBReconnect; + const char * databaseProtocol; + bool enableQueryProfile; + bool verboseQueryMode; + int databaseThreads; // db task q threads + bool logWorkerThreads; + float defaultDBQueueUpdateTimeLimit; + int disconnectSleepTime; + bool showAllDebugInfo; + + + }; + + static uint16 getCentralServerServiceBindPort (); + static const char * getCentralServerServiceBindInterface (); + static const char * getDSN (); + static const char * getDatabaseUID (); + static const char * getDatabasePWD (); + static const char * getDatabaseSchema (); + static uint16 getSecondsBetweenDBReconnect (); + static const char * getDatabaseProtocol (); + static const bool getEnableQueryProfile (); + static const bool getVerboseQueryMode (); + static int getDatabaseThreads (); + static const bool getLogWorkerThreads (); + static float getDefaultDBQueueUpdateTimeLimit (); + static const int getDisconnectSleepTime (); + static const bool getShowAllDebugInfo (); + + static void install (); + static void remove (); + + private: + static Data * data; +}; + +// ---------------------------------------------------------------------- + +#endif // _ConfigStationPlayersCollector_H diff --git a/engine/server/application/StationPlayersCollector/src/shared/DatabaseConnection.cpp b/engine/server/application/StationPlayersCollector/src/shared/DatabaseConnection.cpp new file mode 100644 index 00000000..60ae73c0 --- /dev/null +++ b/engine/server/application/StationPlayersCollector/src/shared/DatabaseConnection.cpp @@ -0,0 +1,175 @@ +// ====================================================================== +// +// DatabaseConnection.cpp +// copyright (c) 2005 Sony Online Entertainment +// Author: Doug Mellencamp +// +// ====================================================================== + +#include "FirstStationPlayersCollector.h" +#include "DatabaseConnection.h" + +#include "ConfigStationPlayersCollector.h" +#include "StationPlayersCollector.h" +#include "sharedDatabaseInterface/DbServer.h" +#include "sharedDatabaseInterface/DbTaskQueue.h" +#include "TaskUpdateSPCharacterProfileData.h" + +// ====================================================================== + +namespace DatabaseConnectionNamespace +{ + DB::Server *s_databaseServer; + DB::TaskQueue *s_taskQueue; +} + +using namespace DatabaseConnectionNamespace; + +// ====================================================================== + +void DatabaseConnection::connect() +{ + DEBUG_FATAL(s_databaseServer,("Called DatabaseConnection::connect() when already connected.\n")); + + s_databaseServer = DB::Server::create(ConfigStationPlayersCollector::getDSN(), + ConfigStationPlayersCollector::getDatabaseUID(), + ConfigStationPlayersCollector::getDatabasePWD(), + DB::Server::getProtocolByName(ConfigStationPlayersCollector::getDatabaseProtocol()),true); + + DB::Server::setDisconnectSleepTime(ConfigStationPlayersCollector::getDisconnectSleepTime()); + s_taskQueue=new DB::TaskQueue(static_cast(ConfigStationPlayersCollector::getDatabaseThreads()),s_databaseServer,0); + + if (ConfigStationPlayersCollector::getEnableQueryProfile()) + DB::Server::enableProfiling(); + + if (ConfigStationPlayersCollector::getVerboseQueryMode()) + DB::Server::enableVerboseMode(); + + DB::TaskQueue::enableWorkerThreadsLogging(ConfigStationPlayersCollector::getLogWorkerThreads()); +} + +// ---------------------------------------------------------------------- + +void DatabaseConnection::disconnect() +{ + DEBUG_FATAL(!s_databaseServer,("Called DatabaseConnection::disconnect() when not connected.\n")); + + if (ConfigStationPlayersCollector::getEnableQueryProfile()) + { + DB::Server::debugOutputProfile(); + DB::Server::endProfiling(); + } + + delete s_taskQueue; + delete s_databaseServer; + + s_taskQueue=0; + s_databaseServer=0; +} + +// ---------------------------------------------------------------------- + +void DatabaseConnection::update() +{ + NOT_NULL(s_taskQueue); + s_taskQueue->update(ConfigStationPlayersCollector::getDefaultDBQueueUpdateTimeLimit()); +} + +// ---------------------------------------------------------------------- + +const std::string DatabaseConnection::getSchemaQualifier() +{ + if (ConfigStationPlayersCollector::getDatabaseSchema()[0]!='\0') + return std::string(ConfigStationPlayersCollector::getDatabaseSchema())+'.'; + else + return std::string(); +} + +// ---------------------------------------------------------------------- + +void DatabaseConnection::updateSPCharacterProfileData(const std::string & clusterName,const NetworkId & characterId,const std::string & characterName,const std::string & objectName,float x,float y,float z,const std::string & sceneId,float cash_balance,float bank_balance,const std::string & objectTemplateName,int stationId,const NetworkId & containedBy,int createTime,int playedTime,int numLots) +{ + NOT_NULL(s_taskQueue); + s_taskQueue->asyncRequest(new TaskUpdateSPCharacterProfileData(clusterName,characterId,characterName,objectName,x,y,z,sceneId,cash_balance,bank_balance,objectTemplateName,stationId,containedBy,createTime,playedTime,numLots)); +} + +// ---------------------------------------------------------------------- + +void DatabaseConnection::updateSPCharacterItemData() +{ + +} + +// ---------------------------------------------------------------------- + +void DatabaseConnection::updateSPCharacterVendorData() +{ + +} + +// ---------------------------------------------------------------------- + +void DatabaseConnection::updateSPCharacterVendorItemData() +{ + +} + +// ---------------------------------------------------------------------- + +void DatabaseConnection::updateSPCharacterStructureData() +{ + +} + +// ---------------------------------------------------------------------- + +void DatabaseConnection::updateSPCharacterShipData() +{ + +} + +// ---------------------------------------------------------------------- + +void DatabaseConnection::updateSPCharacterSkillData() +{ + +} + +// ---------------------------------------------------------------------- + +void DatabaseConnection::updateSPCharacterMount_VehicleData() +{ + +} + +// ---------------------------------------------------------------------- + +void DatabaseConnection::updateSPCharacterWayPointData() +{ + +} + +// ---------------------------------------------------------------------- + +void DatabaseConnection::updateSPCharacterQuestData() +{ + +} + +// ---------------------------------------------------------------------- + +void DatabaseConnection::updateSPCharacterSchematicData() +{ + +} + +// ---------------------------------------------------------------------- + +void DatabaseConnection::updateSPCharacterRankingData() +{ + +} + +// ---------------------------------------------------------------------- + +// ====================================================================== diff --git a/engine/server/application/StationPlayersCollector/src/shared/DatabaseConnection.h b/engine/server/application/StationPlayersCollector/src/shared/DatabaseConnection.h new file mode 100644 index 00000000..a8d6c6e3 --- /dev/null +++ b/engine/server/application/StationPlayersCollector/src/shared/DatabaseConnection.h @@ -0,0 +1,47 @@ +// ====================================================================== +// +// DatabaseConnection.h +// copyright (c) 2005 Sony Online Entertainment +// Author: Doug Mellencamp +// +// ====================================================================== + +#ifndef INCLUDED_DatabaseConnection_H +#define INCLUDED_DatabaseConnection_H + +// ====================================================================== + +#include "sharedFoundation/NetworkId.h" +#include "sharedFoundation/StationId.h" + +// ====================================================================== + +class DatabaseConnection +{ + public: + + static void connect (); + static void disconnect (); + static void update (); + static const std::string getSchemaQualifier (); + + static void updateSPCharacterProfileData (const std::string & clusterName,const NetworkId & characterId,const std::string & characterName,const std::string & objectName,float x,float y,float z,const std::string & sceneId,float cash_balance,float bank_balance,const std::string & objectTemplateName,int stationId,const NetworkId & containedBy,int createTime,int playedTime,int numLots); + static void updateSPCharacterItemData (); + static void updateSPCharacterVendorData (); + static void updateSPCharacterVendorItemData (); + static void updateSPCharacterStructureData (); + static void updateSPCharacterShipData (); + static void updateSPCharacterSkillData (); + static void updateSPCharacterMount_VehicleData (); + static void updateSPCharacterWayPointData (); + static void updateSPCharacterQuestData (); + static void updateSPCharacterSchematicData (); + static void updateSPCharacterRankingData (); + + private: + +}; + +// ====================================================================== + +#endif diff --git a/engine/server/application/StationPlayersCollector/src/shared/FirstStationPlayersCollector.h b/engine/server/application/StationPlayersCollector/src/shared/FirstStationPlayersCollector.h new file mode 100644 index 00000000..563d9b6b --- /dev/null +++ b/engine/server/application/StationPlayersCollector/src/shared/FirstStationPlayersCollector.h @@ -0,0 +1,33 @@ +// ====================================================================== +// +// FirstStationPlayersCollector.h +// copyright (c) 2005 Sony Online Entertainment +// Author: Doug Mellencamp +// +// ====================================================================== + +#ifndef INCLUDED_FirstStationPlayersCollector_H +#define INCLUDED_FirstStationPlayersCollector_H + +// ====================================================================== + +#include "sharedFoundation/FirstSharedFoundation.h" +#include "sharedNetworkMessages/GameNetworkMessage.h" + +#include +#include +#include + +#ifdef WIN32 +// need to boost type_info into the std namespace, as the boost libraries expect it. +#include +namespace std +{ + typedef ::type_info type_info; +}; +#endif + +// ====================================================================== + +#endif + diff --git a/engine/server/application/StationPlayersCollector/src/shared/StationPlayersCollector.cpp b/engine/server/application/StationPlayersCollector/src/shared/StationPlayersCollector.cpp new file mode 100644 index 00000000..89b7a620 --- /dev/null +++ b/engine/server/application/StationPlayersCollector/src/shared/StationPlayersCollector.cpp @@ -0,0 +1,259 @@ +// ====================================================================== +// +// StationPlayersCollector.cpp +// Copyright 2005, Sony Online Entertainment Inc., all rights reserved. +// Author: Doug Mellencamp +// +// ====================================================================== + +#include "StationPlayersCollector.h" +#include "StationPlayersCollectorImpl.h" +#include "ConfigStationPlayersCollector.h" +#include "sharedFoundation/ExitChain.h" +#include "sharedLog/Log.h" + +// ====================================================================== + +void StationPlayersCollector::install() +{ + DEBUG_REPORT_LOG(true, ("[StationPlayersCollector] : StationPlayersCollector::install().\n")); + + ConfigStationPlayersCollector::install(); + + ServerBase::install(new StationPlayersCollectorImpl); + + ServerBase::setSleepTimePerFrameMs(250); + + ExitChain::add(remove, "StationPlayersCollector::remove"); +} + +//----------------------------------------------------------------------- + +void StationPlayersCollector::remove() +{ + DEBUG_REPORT_LOG(true, ("[StationPlayersCollector] : StationPlayersCollector::remove().\n")); + + ServerBase::remove(); + + ConfigStationPlayersCollector::remove(); +} + +//----------------------------------------------------------------------- + +StationPlayersCollectorImpl * StationPlayersCollector::getImpl() +{ + DEBUG_REPORT_LOG(true, ("[StationPlayersCollector] : StationPlayersCollector::getImpl().\n")); + + return static_cast(s_implementation); +} + +//======================================================================= +// game server message handlers +//======================================================================= +void StationPlayersCollector::handleSPCharacterProfileData(const GameNetworkMessage & message) +{ + DEBUG_FATAL( !getImpl(), ("StationPlayersCollector implementation not set")); + getImpl()->handleSPCharacterProfileData(message); +} + +//----------------------------------------------------------------------- + +void StationPlayersCollector::handleSPCharacterItemData(const GameNetworkMessage & message) +{ + DEBUG_FATAL( !getImpl(), ("StationPlayersCollector implementation not set")); + getImpl()->handleSPCharacterItemData(message); +} + +//----------------------------------------------------------------------- + +void StationPlayersCollector::handleSPCharacterVendorData(const GameNetworkMessage & message) +{ + DEBUG_FATAL( !getImpl(), ("StationPlayersCollector implementation not set")); + getImpl()->handleSPCharacterVendorData(message); +} + +//----------------------------------------------------------------------- + +void StationPlayersCollector::handleSPCharacterVendorItemData(const GameNetworkMessage & message) +{ + DEBUG_FATAL( !getImpl(), ("StationPlayersCollector implementation not set")); + getImpl()->handleSPCharacterVendorItemData(message); +} + +//----------------------------------------------------------------------- + +void StationPlayersCollector::handleSPCharacterStructureData(const GameNetworkMessage & message) +{ + DEBUG_FATAL( !getImpl(), ("StationPlayersCollector implementation not set")); + getImpl()->handleSPCharacterStructureData(message); +} + +//----------------------------------------------------------------------- + +void StationPlayersCollector::handleSPCharacterShipData(const GameNetworkMessage & message) +{ + DEBUG_FATAL( !getImpl(), ("StationPlayersCollector implementation not set")); + getImpl()->handleSPCharacterShipData(message); +} + +//----------------------------------------------------------------------- + +void StationPlayersCollector::handleSPCharacterSkillData(const GameNetworkMessage & message) +{ + DEBUG_FATAL( !getImpl(), ("StationPlayersCollector implementation not set")); + getImpl()->handleSPCharacterSkillData(message); +} + +//----------------------------------------------------------------------- + +void StationPlayersCollector::handleSPCharacterMount_VehicleData(const GameNetworkMessage & message) +{ + DEBUG_FATAL( !getImpl(), ("StationPlayersCollector implementation not set")); + getImpl()->handleSPCharacterMount_VehicleData(message); +} + +//----------------------------------------------------------------------- + +void StationPlayersCollector::handleSPCharacterWayPointData(const GameNetworkMessage & message) +{ + DEBUG_FATAL( !getImpl(), ("StationPlayersCollector implementation not set")); + getImpl()->handleSPCharacterWayPointData(message); +} + +//----------------------------------------------------------------------- + +void StationPlayersCollector::handleSPCharacterQuestData(const GameNetworkMessage & message) +{ + DEBUG_FATAL( !getImpl(), ("StationPlayersCollector implementation not set")); + getImpl()->handleSPCharacterQuestData(message); +} + +//----------------------------------------------------------------------- + +void StationPlayersCollector::handleSPCharacterSchematicData(const GameNetworkMessage & message) +{ + DEBUG_FATAL( !getImpl(), ("StationPlayersCollector implementation not set")); + getImpl()->handleSPCharacterSchematicData(message); +} + +//----------------------------------------------------------------------- + +void StationPlayersCollector::handleSPCharacterRankingData(const GameNetworkMessage & message) +{ + DEBUG_FATAL( !getImpl(), ("StationPlayersCollector implementation not set")); + getImpl()->handleSPCharacterRankingData(message); +} + +//----------------------------------------------------------------------- + +//====================================================================== +// game server message & connection event callbacks & sends +//====================================================================== +void StationPlayersCollector::ackSPCharacterProfileData() +{ + DEBUG_FATAL( !getImpl(), ("StationPlayersCollector implementation not set")); + getImpl()->ackSPCharacterProfileData(); +} + +//----------------------------------------------------------------------- + +void StationPlayersCollector::ackSPCharacterItemData() +{ + DEBUG_FATAL( !getImpl(), ("StationPlayersCollector implementation not set")); + getImpl()->ackSPCharacterItemData(); +} + +//----------------------------------------------------------------------- + +void StationPlayersCollector::ackSPCharacterVendorData() +{ + DEBUG_FATAL( !getImpl(), ("StationPlayersCollector implementation not set")); + getImpl()->ackSPCharacterVendorData(); +} + +//----------------------------------------------------------------------- + +void StationPlayersCollector::ackSPCharacterVendorItemData() +{ + DEBUG_FATAL( !getImpl(), ("StationPlayersCollector implementation not set")); + getImpl()->ackSPCharacterVendorItemData(); +} + +//----------------------------------------------------------------------- + +void StationPlayersCollector::ackSPCharacterStructureData() +{ + DEBUG_FATAL( !getImpl(), ("StationPlayersCollector implementation not set")); + getImpl()->ackSPCharacterStructureData(); +} + +//----------------------------------------------------------------------- + +void StationPlayersCollector::ackSPCharacterShipData() +{ + DEBUG_FATAL( !getImpl(), ("StationPlayersCollector implementation not set")); + getImpl()->ackSPCharacterShipData(); +} + +//----------------------------------------------------------------------- + +void StationPlayersCollector::ackSPCharacterSkillData() +{ + DEBUG_FATAL( !getImpl(), ("StationPlayersCollector implementation not set")); + getImpl()->ackSPCharacterSkillData(); +} + +//----------------------------------------------------------------------- + +void StationPlayersCollector::ackSPCharacterMount_VehicleData() +{ + DEBUG_FATAL( !getImpl(), ("StationPlayersCollector implementation not set")); + getImpl()->ackSPCharacterMount_VehicleData(); +} + +//----------------------------------------------------------------------- + +void StationPlayersCollector::ackSPCharacterWayPointData() +{ + DEBUG_FATAL( !getImpl(), ("StationPlayersCollector implementation not set")); + getImpl()->ackSPCharacterWayPointData(); +} + +//----------------------------------------------------------------------- + +void StationPlayersCollector::ackSPCharacterQuestData() +{ + DEBUG_FATAL( !getImpl(), ("StationPlayersCollector implementation not set")); + getImpl()->ackSPCharacterQuestData(); +} + +//----------------------------------------------------------------------- + +void StationPlayersCollector::ackSPCharacterSchematicData() +{ + DEBUG_FATAL( !getImpl(), ("StationPlayersCollector implementation not set")); + getImpl()->ackSPCharacterSchematicData(); +} + +//----------------------------------------------------------------------- + +void StationPlayersCollector::ackSPCharacterRankingData() +{ + DEBUG_FATAL( !getImpl(), ("StationPlayersCollector implementation not set")); + getImpl()->ackSPCharacterRankingData(); +} + +//----------------------------------------------------------------------- + +//====================================================================== +// game server generic/global commincation methods +//====================================================================== +void StationPlayersCollector::sendToCentralServer(const uint32 serverId, const GameNetworkMessage & message, const bool reliable) +{ + DEBUG_FATAL( !getImpl(), ("StationPlayersCollector implementation not set")); + getImpl()->sendToCentralServer(serverId, message, reliable); +} + +//----------------------------------------------------------------------- + +// ====================================================================== diff --git a/engine/server/application/StationPlayersCollector/src/shared/StationPlayersCollector.h b/engine/server/application/StationPlayersCollector/src/shared/StationPlayersCollector.h new file mode 100644 index 00000000..67386b96 --- /dev/null +++ b/engine/server/application/StationPlayersCollector/src/shared/StationPlayersCollector.h @@ -0,0 +1,75 @@ +// ====================================================================== +// +// StationPlayersCollector.h +// Copyright 2005, Sony Online Entertainment Inc., all rights reserved. +// Author: Doug Mellencamp +// +// ====================================================================== +#ifndef _INCLUDED_StationPlayersCollector_H +#define _INCLUDED_StationPlayersCollector_H + +#include "FirstStationPlayersCollector.h" +#include "serverBase/ServerBase.h" + +//----------------------------------------------------------------------- + +class NetworkId; +class GameServerConnection; +class GameNetworkMessage; +class StationPlayersCollectorImpl; + +//----------------------------------------------------------------------- + +class StationPlayersCollector : public ServerBase +{ + public: + + //=================================================================== + // game server message handlers + //=================================================================== + static void handleSPCharacterProfileData (const GameNetworkMessage & message); + static void handleSPCharacterItemData (const GameNetworkMessage & message); + static void handleSPCharacterVendorData (const GameNetworkMessage & message); + static void handleSPCharacterVendorItemData (const GameNetworkMessage & message); + static void handleSPCharacterStructureData (const GameNetworkMessage & message); + static void handleSPCharacterShipData (const GameNetworkMessage & message); + static void handleSPCharacterSkillData (const GameNetworkMessage & message); + static void handleSPCharacterMount_VehicleData (const GameNetworkMessage & message); + static void handleSPCharacterWayPointData (const GameNetworkMessage & message); + static void handleSPCharacterQuestData (const GameNetworkMessage & message); + static void handleSPCharacterSchematicData (const GameNetworkMessage & message); + static void handleSPCharacterRankingData (const GameNetworkMessage & message); + + //=================================================================== + // game server message & connection event callbacks & sends + //=================================================================== + static void ackSPCharacterProfileData (); + static void ackSPCharacterItemData (); + static void ackSPCharacterVendorData (); + static void ackSPCharacterVendorItemData (); + static void ackSPCharacterStructureData (); + static void ackSPCharacterShipData (); + static void ackSPCharacterSkillData (); + static void ackSPCharacterMount_VehicleData (); + static void ackSPCharacterWayPointData (); + static void ackSPCharacterQuestData (); + static void ackSPCharacterSchematicData (); + static void ackSPCharacterRankingData (); + + //=================================================================== + // game server generic/global commincation methods + //=================================================================== + static void sendToCentralServer(const uint32 serverId, const GameNetworkMessage & message, const bool reliable); + + static void install(); + static void remove(); + + protected: + + static StationPlayersCollectorImpl * getImpl(); + +}; + +//----------------------------------------------------------------------- + +#endif // _INCLUDED_StationPlayersCollector_H diff --git a/engine/server/application/StationPlayersCollector/src/shared/StationPlayersCollectorImpl.cpp b/engine/server/application/StationPlayersCollector/src/shared/StationPlayersCollectorImpl.cpp new file mode 100644 index 00000000..3f95df90 --- /dev/null +++ b/engine/server/application/StationPlayersCollector/src/shared/StationPlayersCollectorImpl.cpp @@ -0,0 +1,334 @@ +// ====================================================================== +// +// StationPlayersCollectorImpl.cpp +// Copyright 2005, Sony Online Entertainment Inc., all rights reserved. +// Author: Doug Mellencamp +// +// ====================================================================== + +#include "StationPlayersCollectorImpl.h" +#include "CentralServerConnection.h" +#include "DatabaseConnection.h" +#include "ConfigStationPlayersCollector.h" +#include "sharedNetwork/Connection.h" +#include "sharedNetwork/Service.h" +#include "sharedNetwork/NetworkSetupData.h" +#include "serverNetworkMessages/SPCharacterProfileMessage.h" + +//----------------------------------------------------------------------- + +StationPlayersCollectorImpl::StationPlayersCollectorImpl() : + ServerBaseImpl(), + m_centralServerService(0) +{ + +} + +//----------------------------------------------------------------------- + +StationPlayersCollectorImpl::~StationPlayersCollectorImpl() +{ + +} + +//======================================================================= +// virtual overrides from ServerBaseImpl +//======================================================================= + +void StationPlayersCollectorImpl::preMainLoopInit() +{ + DEBUG_REPORT_LOG(true, ("[StationPlayersCollector] : StationPlayersCollectorImpl::preMainLoopInit().\n")); + + ServerBaseImpl::preMainLoopInit(); + + // add additional pre main loop initilizations here +} + +//----------------------------------------------------------------------- + +void StationPlayersCollectorImpl::postMainLoopCleanup() +{ + DEBUG_REPORT_LOG(true, ("[StationPlayersCollector] : StationPlayersCollectorImpl::postMainLoopCleanup().\n")); + + // add additional post main loop clean here + + ServerBaseImpl::postMainLoopCleanup(); +} + +//----------------------------------------------------------------------- + +void StationPlayersCollectorImpl::setupConnections() +{ + NetworkSetupData setup; + setup.port = ConfigStationPlayersCollector::getCentralServerServiceBindPort(); + setup.bindInterface = ConfigStationPlayersCollector::getCentralServerServiceBindInterface(); + setup.maxConnections=500; + + DEBUG_REPORT_LOG(true, ("[StationPlayersCollector] : StationPlayersCollectorImpl::setupConnections() - Starting database connection pool.\n")); + DatabaseConnection::connect(); + + DEBUG_REPORT_LOG(true, ("[StationPlayersCollector] : StationPlayersCollectorImpl::setupConnections() - Starting Central Server Listening Service on %s:%d.\n",ConfigStationPlayersCollector::getCentralServerServiceBindInterface(), static_cast(ConfigStationPlayersCollector::getCentralServerServiceBindPort()))); + m_centralServerService = new Service(ConnectionAllocator(), setup); + +} + +//----------------------------------------------------------------------- + +void StationPlayersCollectorImpl::unsetupConnections() +{ + DEBUG_REPORT_LOG(true, ("[StationPlayersCollector] : StationPlayersCollectorImpl::unsetupConnections() - shutting down the Central Server Listening Service.\n")); + + m_centralServerService = 0; + delete m_centralServerService; + + DEBUG_REPORT_LOG(true, ("[StationPlayersCollector] : StationPlayersCollectorImpl::unsetupConnections() - Disconnecting from the Database.\n")); + DatabaseConnection::disconnect(); +} + +//----------------------------------------------------------------------- + +void StationPlayersCollectorImpl::update (real time) +{ + // add StationPlayersCollectorImpl logic here + + DatabaseConnection::update(); + + + // end StationPlayersCollectorImpl + + ServerBaseImpl::update(time); +} + +//======================================================================= +// game server message handlers +//======================================================================= +void StationPlayersCollectorImpl::handleSPCharacterProfileData(const GameNetworkMessage & message) +{ + //TODO: do any additional data conversion/normalization here + + Archive::ReadIterator ri = static_cast(message).getByteStream().begin(); + SPCharacterProfileMessage msg(ri); + + + DEBUG_REPORT_LOG(ConfigStationPlayersCollector::getShowAllDebugInfo(), ("[StationPlayersCollector] : StationPlayersCollectorImpl::handleSPCharacterProfileData().\n")); + DEBUG_REPORT_LOG(ConfigStationPlayersCollector::getShowAllDebugInfo(), ("[StationPlayersCollector] : \t Clustername: %s\n",msg.GetClusterName().c_str())); + DEBUG_REPORT_LOG(ConfigStationPlayersCollector::getShowAllDebugInfo(), ("[StationPlayersCollector] : \t CharacterID: %s\n",msg.GetCharacterId().getValueString().c_str())); + DEBUG_REPORT_LOG(ConfigStationPlayersCollector::getShowAllDebugInfo(), ("[StationPlayersCollector] : \t CharacterName: %s\n",msg.GetCharacterName().c_str())); + DEBUG_REPORT_LOG(ConfigStationPlayersCollector::getShowAllDebugInfo(), ("[StationPlayersCollector] : \t XCoord: %f\n",msg.GetX())); + DEBUG_REPORT_LOG(ConfigStationPlayersCollector::getShowAllDebugInfo(), ("[StationPlayersCollector] : \t YCoord: %f\n",msg.GetY())); + DEBUG_REPORT_LOG(ConfigStationPlayersCollector::getShowAllDebugInfo(), ("[StationPlayersCollector] : \t ZCoord: %f\n",msg.GetZ())); + DEBUG_REPORT_LOG(ConfigStationPlayersCollector::getShowAllDebugInfo(), ("[StationPlayersCollector] : \t SceneId: %s\n",msg.GetSceneId().c_str())); + DEBUG_REPORT_LOG(ConfigStationPlayersCollector::getShowAllDebugInfo(), ("[StationPlayersCollector] : \t Cash: %f\n",msg.GetCash_Balance())); + DEBUG_REPORT_LOG(ConfigStationPlayersCollector::getShowAllDebugInfo(), ("[StationPlayersCollector] : \t Bank: %f\n",msg.GetBank_Balance())); + DEBUG_REPORT_LOG(ConfigStationPlayersCollector::getShowAllDebugInfo(), ("[StationPlayersCollector] : \t Template: %s\n",msg.GetObjectTemplateName().c_str())); + DEBUG_REPORT_LOG(ConfigStationPlayersCollector::getShowAllDebugInfo(), ("[StationPlayersCollector] : \t StationId: %d\n",msg.GetStationId())); + DEBUG_REPORT_LOG(ConfigStationPlayersCollector::getShowAllDebugInfo(), ("[StationPlayersCollector] : \t ContainedBy: %s\n",msg.GetContainedBy().getValueString().c_str())); + DEBUG_REPORT_LOG(ConfigStationPlayersCollector::getShowAllDebugInfo(), ("[StationPlayersCollector] : \t CreateTime: %d\n",msg.GetCreateTime())); + DEBUG_REPORT_LOG(ConfigStationPlayersCollector::getShowAllDebugInfo(), ("[StationPlayersCollector] : \t PlayedTime: %d\n",msg.GetPlayedTime())); + DEBUG_REPORT_LOG(ConfigStationPlayersCollector::getShowAllDebugInfo(), ("[StationPlayersCollector] : \t Lots: %d\n",msg.GetNumLots())); + + DatabaseConnection::updateSPCharacterProfileData( + msg.GetClusterName(), + msg.GetCharacterId(), + msg.GetCharacterName(), + msg.GetObjectName(), + msg.GetX(), + msg.GetY(), + msg.GetZ(), + msg.GetSceneId(), + msg.GetCash_Balance(), + msg.GetBank_Balance(), + msg.GetObjectTemplateName(), + msg.GetStationId(), + msg.GetContainedBy(), + msg.GetCreateTime(), + msg.GetPlayedTime(), + msg.GetNumLots()); +} + +//----------------------------------------------------------------------- + +void StationPlayersCollectorImpl::handleSPCharacterItemData(const GameNetworkMessage & message) +{ + //TODO: add message handler code here +} + +//----------------------------------------------------------------------- + +void StationPlayersCollectorImpl::handleSPCharacterVendorData(const GameNetworkMessage & message) +{ + //TODO: add message handler code here +} + +//----------------------------------------------------------------------- + +void StationPlayersCollectorImpl::handleSPCharacterVendorItemData(const GameNetworkMessage & message) +{ + //TODO: add message handler code here +} + +//----------------------------------------------------------------------- + +void StationPlayersCollectorImpl::handleSPCharacterStructureData(const GameNetworkMessage & message) +{ + //TODO: add message handler code here +} + +//----------------------------------------------------------------------- + +void StationPlayersCollectorImpl::handleSPCharacterShipData(const GameNetworkMessage & message) +{ + //TODO: add message handler code here +} + +//----------------------------------------------------------------------- + +void StationPlayersCollectorImpl::handleSPCharacterSkillData(const GameNetworkMessage & message) +{ + //TODO: add message handler code here +} + +//----------------------------------------------------------------------- + +void StationPlayersCollectorImpl::handleSPCharacterMount_VehicleData(const GameNetworkMessage & message) +{ + //TODO: add message handler code here +} + +//----------------------------------------------------------------------- + +void StationPlayersCollectorImpl::handleSPCharacterWayPointData(const GameNetworkMessage & message) +{ + //TODO: add message handler code here +} + +//----------------------------------------------------------------------- + +void StationPlayersCollectorImpl::handleSPCharacterQuestData(const GameNetworkMessage & message) +{ + //TODO: add message handler code here +} + +//----------------------------------------------------------------------- + +void StationPlayersCollectorImpl::handleSPCharacterSchematicData(const GameNetworkMessage & message) +{ + //TODO: add message handler code here +} + +//----------------------------------------------------------------------- + +void StationPlayersCollectorImpl::handleSPCharacterRankingData(const GameNetworkMessage & message) +{ + //TODO: add message handler code here +} + +//----------------------------------------------------------------------- + +//======================================================================= +// game server message & connection event callbacks & sends +//======================================================================= +void StationPlayersCollectorImpl::ackSPCharacterProfileData() +{ + //TODO: add message callback code here +} + +//----------------------------------------------------------------------- + +void StationPlayersCollectorImpl::ackSPCharacterItemData() +{ + //TODO: add message callback code here +} + +//----------------------------------------------------------------------- + +void StationPlayersCollectorImpl::ackSPCharacterVendorData() +{ + //TODO: add message callback code here +} + +//----------------------------------------------------------------------- + +void StationPlayersCollectorImpl::ackSPCharacterVendorItemData() +{ + //TODO: add message callback code here +} + +//----------------------------------------------------------------------- + +void StationPlayersCollectorImpl::ackSPCharacterStructureData() +{ + //TODO: add message callback code here +} + +//----------------------------------------------------------------------- + +void StationPlayersCollectorImpl::ackSPCharacterShipData() +{ + //TODO: add message callback code here +} + +//----------------------------------------------------------------------- + +void StationPlayersCollectorImpl::ackSPCharacterSkillData() +{ + //TODO: add message callback code here +} + +//----------------------------------------------------------------------- + +void StationPlayersCollectorImpl::ackSPCharacterMount_VehicleData() +{ + //TODO: add message callback code here +} + +//----------------------------------------------------------------------- + +void StationPlayersCollectorImpl::ackSPCharacterWayPointData() +{ + //TODO: add message callback code here +} + +//----------------------------------------------------------------------- + +void StationPlayersCollectorImpl::ackSPCharacterQuestData() +{ + //TODO: add message callback code here +} + +//----------------------------------------------------------------------- + +void StationPlayersCollectorImpl::ackSPCharacterSchematicData() +{ + //TODO: add message callback code here +} + +//----------------------------------------------------------------------- + +void StationPlayersCollectorImpl::ackSPCharacterRankingData() +{ + //TODO: add message callback code here +} + +//----------------------------------------------------------------------- + +//======================================================================= +// game server generic/global commincation methods +//======================================================================= + +void StationPlayersCollectorImpl::sendToCentralServer(const uint32 serverId, const GameNetworkMessage & message, const bool reliable) +{ + DEBUG_WARNING(!reliable, ("[StationPlayersCollector] : Sending message unreliably from server to server")); + + CentralServerConnection * centralServerConnection = CentralServerConnection::getConnectionById(serverId); + if( centralServerConnection ) + { + centralServerConnection->send( message, reliable ); + } + else + { + DEBUG_REPORT_LOG(true,("[StationPlayersCollector] : Tried to send a message to a Central Server(%d), but it was not connected.\n", static_cast(serverId))); + } +} + +// ====================================================================== diff --git a/engine/server/application/StationPlayersCollector/src/shared/StationPlayersCollectorImpl.h b/engine/server/application/StationPlayersCollector/src/shared/StationPlayersCollectorImpl.h new file mode 100644 index 00000000..9cb61069 --- /dev/null +++ b/engine/server/application/StationPlayersCollector/src/shared/StationPlayersCollectorImpl.h @@ -0,0 +1,87 @@ +// ====================================================================== +// +// StationPlayersCollectorImpl.h +// Copyright 2005, Sony Online Entertainment Inc., all rights reserved. +// Author: Doug Mellencamp +// +// ====================================================================== +#ifndef _INCLUDED_StationPlayersCollectorImpl_H +#define _INCLUDED_StationPlayersCollectorImpl_H + +#include "FirstStationPlayersCollector.h" +#include "sharedFoundation/StationId.h" +#include "sharedFoundation/Tag.h" +#include "serverBase/ServerBaseImpl.h" + +//----------------------------------------------------------------------- + +class NetworkId; +class CentralServerConnection; +class Service; +class GameNetworkMessage; + +//----------------------------------------------------------------------- + +class StationPlayersCollectorImpl : public ServerBaseImpl +{ + public: + + virtual ~StationPlayersCollectorImpl(); + StationPlayersCollectorImpl(); + + //=================================================================== + // game server loader message handlers + //=================================================================== + virtual void handleSPCharacterProfileData (const GameNetworkMessage & message); + virtual void handleSPCharacterItemData (const GameNetworkMessage & message); + virtual void handleSPCharacterVendorData (const GameNetworkMessage & message); + virtual void handleSPCharacterVendorItemData (const GameNetworkMessage & message); + virtual void handleSPCharacterStructureData (const GameNetworkMessage & message); + virtual void handleSPCharacterShipData (const GameNetworkMessage & message); + virtual void handleSPCharacterSkillData (const GameNetworkMessage & message); + virtual void handleSPCharacterMount_VehicleData (const GameNetworkMessage & message); + virtual void handleSPCharacterWayPointData (const GameNetworkMessage & message); + virtual void handleSPCharacterQuestData (const GameNetworkMessage & message); + virtual void handleSPCharacterSchematicData (const GameNetworkMessage & message); + virtual void handleSPCharacterRankingData (const GameNetworkMessage & message); + + //=================================================================== + // game server message & connection event callbacks & sends + //=================================================================== + virtual void ackSPCharacterProfileData (); + virtual void ackSPCharacterItemData (); + virtual void ackSPCharacterVendorData (); + virtual void ackSPCharacterVendorItemData (); + virtual void ackSPCharacterStructureData (); + virtual void ackSPCharacterShipData (); + virtual void ackSPCharacterSkillData (); + virtual void ackSPCharacterMount_VehicleData (); + virtual void ackSPCharacterWayPointData (); + virtual void ackSPCharacterQuestData (); + virtual void ackSPCharacterSchematicData (); + virtual void ackSPCharacterRankingData (); + + //=================================================================== + // game server generic/global commincation methods + //=================================================================== + virtual void sendToCentralServer(const uint32 serverId, const GameNetworkMessage & message, const bool reliable); + + //=================================================================== + // The following are virtual overrides from BaseServerImpl + //=================================================================== + virtual void update (real time); + virtual void setupConnections (); + virtual void unsetupConnections (); + virtual void preMainLoopInit (); + virtual void postMainLoopCleanup (); + + protected: + + Service * m_centralServerService; + +}; + + +//----------------------------------------------------------------------- + +#endif // _INCLUDED_StationPlayersCollector_H diff --git a/engine/server/application/StationPlayersCollector/src/shared/TaskUpdateSPCharacterProfileData.cpp b/engine/server/application/StationPlayersCollector/src/shared/TaskUpdateSPCharacterProfileData.cpp new file mode 100644 index 00000000..2f1c1d04 --- /dev/null +++ b/engine/server/application/StationPlayersCollector/src/shared/TaskUpdateSPCharacterProfileData.cpp @@ -0,0 +1,146 @@ +// ====================================================================== +// +// TaskUpdateSPCharacterProfileData.cpp +// copyright (c) 2005 Sony Online Entertainment +// +// ====================================================================== + +#include "FirstStationPlayersCollector.h" +#include "TaskUpdateSPCharacterProfileData.h" + +#include "StationPlayersCollector.h" +#include "DatabaseConnection.h" +#include "sharedDatabaseInterface/DbSession.h" +#include "sharedFoundation/NetworkIdArchive.h" +#include "ConfigStationPlayersCollector.h" + +// ====================================================================== + +TaskUpdateSPCharacterProfileData::TaskUpdateSPCharacterProfileData(const std::string & clusterName,const NetworkId & characterId,const std::string & characterName,const std::string & objectName,float x,float y,float z,const std::string & sceneId,float cash_balance,float bank_balance,const std::string & objectTemplateName,int stationId,const NetworkId & containedBy,int createTime,int playedTime,int numLots) : + TaskRequest(), + m_clusterName(clusterName), + m_characterId(characterId), + m_characterName(characterName), + m_objectName(objectName), + m_x(x), + m_y(y), + m_z(z), + m_sceneId(sceneId), + m_cash_balance(cash_balance), + m_bank_balance(bank_balance), + m_objectTemplateName(objectTemplateName), + m_stationId(stationId), + m_containedby(containedBy), + m_createTime(createTime), + m_playedTime(playedTime), + m_numLots(numLots) +{ +} + +// ---------------------------------------------------------------------- + +bool TaskUpdateSPCharacterProfileData::process(DB::Session *session) +{ + UpdateSPCharacterProfileDataQuery qry; + + qry.clusterName = m_clusterName; + qry.characterId = m_characterId; + qry.characterName = m_characterName; + qry.objectName = m_objectName; + qry.x = m_x; + qry.y = m_y; + qry.z = m_z; + qry.sceneId = m_sceneId; + qry.cash_balance = m_cash_balance; + qry.bank_balance = m_bank_balance; + qry.objectTemplateName = m_objectTemplateName; + qry.stationId = static_cast(m_stationId); + qry.containedBy = m_containedby; + qry.createTime = m_createTime; + qry.playedTime = m_playedTime; + qry.numLots = m_numLots; + + bool rval = session->exec(&qry); + + qry.done(); + return rval; +} + +// ---------------------------------------------------------------------- + +void TaskUpdateSPCharacterProfileData::onComplete() +{ + // StationPlayersCollector::ackSPCharacterProfileData(); + DEBUG_REPORT_LOG(ConfigStationPlayersCollector::getShowAllDebugInfo(), ("[StationPlayersCollector] : TaskUpdateSPCharacterProfileData::onComplete().\n")); +} + +// ====================================================================== + +TaskUpdateSPCharacterProfileData::UpdateSPCharacterProfileDataQuery::UpdateSPCharacterProfileDataQuery() : + Query(), + clusterName(), + characterId(), + characterName(), + objectName(), + x(), + y(), + z(), + sceneId(), + cash_balance(), + bank_balance(), + objectTemplateName(), + stationId(), + containedBy(), + createTime(), + playedTime(), + numLots() +{ +} + +// ---------------------------------------------------------------------- + +void TaskUpdateSPCharacterProfileData::UpdateSPCharacterProfileDataQuery::getSQL(std::string &sql) +{ + sql = std::string("begin ")+DatabaseConnection::getSchemaQualifier()+"station_players.update_character(:clusterName,:characterId,:characterName,:objectName,:x,:y,:z,:sceneId,:cash_balance,:bank_balance,:objectTemplateName,:stationId,:containedBy,:createTime,:playedTime,:numLots); end;"; + DEBUG_REPORT_LOG(true, ("TaskUpdateSPCharacterProfileData SQL: %s\n", sql.c_str())); +} + +// ---------------------------------------------------------------------- + +bool TaskUpdateSPCharacterProfileData::UpdateSPCharacterProfileDataQuery::bindParameters() +{ + if (!bindParameter(clusterName)) return false; + if (!bindParameter(characterId)) return false; + if (!bindParameter(characterName)) return false; + if (!bindParameter(objectName)) return false; + if (!bindParameter(x)) return false; + if (!bindParameter(y)) return false; + if (!bindParameter(z)) return false; + if (!bindParameter(sceneId)) return false; + if (!bindParameter(cash_balance)) return false; + if (!bindParameter(bank_balance)) return false; + if (!bindParameter(objectTemplateName)) return false; + if (!bindParameter(stationId)) return false; + if (!bindParameter(containedBy)) return false; + if (!bindParameter(createTime)) return false; + if (!bindParameter(playedTime)) return false; + if (!bindParameter(numLots)) return false; + + return true; +} + +// ---------------------------------------------------------------------- + +bool TaskUpdateSPCharacterProfileData::UpdateSPCharacterProfileDataQuery::bindColumns() +{ + return true; +} + +// ---------------------------------------------------------------------- + +DB::Query::QueryMode TaskUpdateSPCharacterProfileData::UpdateSPCharacterProfileDataQuery::getExecutionMode() const +{ + return MODE_PROCEXEC; +} + +// ====================================================================== diff --git a/engine/server/application/StationPlayersCollector/src/shared/TaskUpdateSPCharacterProfileData.h b/engine/server/application/StationPlayersCollector/src/shared/TaskUpdateSPCharacterProfileData.h new file mode 100644 index 00000000..712b95bd --- /dev/null +++ b/engine/server/application/StationPlayersCollector/src/shared/TaskUpdateSPCharacterProfileData.h @@ -0,0 +1,84 @@ +// ====================================================================== +// +// TaskUpdateSPCharacterProfileData.h +// copyright (c) 2005 Sony Online Entertainment +// +// ====================================================================== + +#ifndef INCLUDED_TaskUpdateSPCharacterProfileData_H +#define INCLUDED_TaskUpdateSPCharacterProfileData_H + +// ====================================================================== + +#include "sharedDatabaseInterface/Bindable.h" +#include "sharedDatabaseInterface/BindableNetworkId.h" +#include "sharedDatabaseInterface/DbQuery.h" +#include "sharedDatabaseInterface/DbTaskRequest.h" + +// ====================================================================== + +class TaskUpdateSPCharacterProfileData : public DB::TaskRequest +{ + public: + TaskUpdateSPCharacterProfileData(const std::string & clusterName,const NetworkId & characterId,const std::string & characterName,const std::string & objectName,float x,float y,float z,const std::string & sceneId,float cash_balance,float bank_balance,const std::string & objectTemplateName,int stationId,const NetworkId & containedBy,int createTime,int playedTime,int numLots); + + public: + virtual bool process (DB::Session *session); + virtual void onComplete (); + + private: + TaskUpdateSPCharacterProfileData(); // disabled default constructor + class UpdateSPCharacterProfileDataQuery : public DB::Query + { + public: + UpdateSPCharacterProfileDataQuery(); + + DB::BindableString<50> clusterName; + DB::BindableNetworkId characterId; + DB::BindableString<127> characterName; + DB::BindableString<127> objectName; + DB::BindableDouble x; + DB::BindableDouble y; + DB::BindableDouble z; + DB::BindableString<50> sceneId; + DB::BindableDouble cash_balance; + DB::BindableDouble bank_balance; + DB::BindableString<500> objectTemplateName; + DB::BindableLong stationId; + DB::BindableNetworkId containedBy; + DB::BindableLong createTime; + DB::BindableLong playedTime; + DB::BindableLong numLots; + + virtual void getSQL (std::string &sql); + virtual bool bindParameters (); + virtual bool bindColumns (); + virtual QueryMode getExecutionMode () const; + + private: //disable + UpdateSPCharacterProfileDataQuery (const UpdateSPCharacterProfileDataQuery&); + UpdateSPCharacterProfileDataQuery &operator= (const UpdateSPCharacterProfileDataQuery&); + }; + + private: + std::string m_clusterName; + NetworkId m_characterId; + std::string m_characterName; + std::string m_objectName; + float m_x; + float m_y; + float m_z; + std::string m_sceneId; + float m_cash_balance; + float m_bank_balance; + std::string m_objectTemplateName; + int m_stationId; + NetworkId m_containedby; + int m_createTime; + int m_playedTime; + int m_numLots; +}; + +// ====================================================================== + +#endif diff --git a/engine/shared/library/sharedDatabaseInterface/src_oci/CMakeLists.txt b/engine/shared/library/sharedDatabaseInterface/src_oci/CMakeLists.txt index 3f6d1659..e656be4c 100644 --- a/engine/shared/library/sharedDatabaseInterface/src_oci/CMakeLists.txt +++ b/engine/shared/library/sharedDatabaseInterface/src_oci/CMakeLists.txt @@ -28,4 +28,5 @@ add_library(sharedDatabaseInterface_oci STATIC target_link_libraries(sharedDatabaseInterface_oci sharedDatabaseInterface + ${ORACLE_LIBRARY} )