mirror of
https://github.com/SWG-Source/src.git
synced 2026-07-28 22:15:49 -04:00
Initial LoginServer project commit
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
project(LoginServer)
|
||||
|
||||
add_subdirectory(src)
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
|
||||
add_subdirectory(shared)
|
||||
|
||||
if(WIN32)
|
||||
add_subdirectory(win32)
|
||||
else()
|
||||
add_subdirectory(linux)
|
||||
endif()
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
add_executable(LoginServer
|
||||
main.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(LoginServer
|
||||
LoginServershared
|
||||
)
|
||||
@@ -0,0 +1,49 @@
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
|
||||
#include "ConfigLoginServer.h"
|
||||
#include "LoginServer.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 = "loginServer.cfg";
|
||||
SetupSharedFoundation::install (setupFoundationData);
|
||||
|
||||
if (ConfigFile::isEmpty())
|
||||
FATAL(true, ("No config file specified"));
|
||||
|
||||
SetupSharedCompression::install();
|
||||
|
||||
SetupSharedFile::install(false);
|
||||
SetupSharedNetworkMessages::install();
|
||||
|
||||
SetupSharedRandom::install(static_cast<uint32>(time(NULL))); //lint !e1924 !e64 // NULL is a C-Style cast?
|
||||
|
||||
Os::setProgramName("LoginServer");
|
||||
//setup the server
|
||||
ConfigLoginServer::install();
|
||||
|
||||
//-- run game
|
||||
SetupSharedFoundation::callbackWithExceptionHandling(LoginServer::run);
|
||||
SetupSharedFoundation::remove();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
|
||||
add_library(LoginServershared
|
||||
CentralServerConnection.cpp
|
||||
CentralServerConnection.h
|
||||
ClientConnection.cpp
|
||||
ClientConnection.h
|
||||
ConfigLoginServer.cpp
|
||||
ConfigLoginServer.h
|
||||
ConsoleCommandParser.cpp
|
||||
ConsoleCommandParser.h
|
||||
ConsoleCommandParserLoginServer.cpp
|
||||
ConsoleCommandParserLoginServer.h
|
||||
ConsoleManager.cpp
|
||||
ConsoleManager.h
|
||||
CSToolConnection.cpp
|
||||
CSToolConnection.h
|
||||
DatabaseConnection.cpp
|
||||
DatabaseConnection.h
|
||||
FirstLoginServer.h
|
||||
LoginServer.cpp
|
||||
LoginServer.h
|
||||
LoginServerRemoteDebugConnection.cpp
|
||||
LoginServerRemoteDebugConnection.h
|
||||
LoginServerRemoteDebugSetup.cpp
|
||||
LoginServerRemoteDebugSetup.h
|
||||
PingConnection.cpp
|
||||
PingConnection.h
|
||||
PurgeManager.cpp
|
||||
PurgeManager.h
|
||||
SessionApiClient.cpp
|
||||
SessionApiClient.h
|
||||
TaskChangeStationId.cpp
|
||||
TaskChangeStationId.h
|
||||
TaskClaimRewards.cpp
|
||||
TaskClaimRewards.h
|
||||
TaskCreateCharacter.cpp
|
||||
TaskCreateCharacter.h
|
||||
TaskDeleteCharacter.cpp
|
||||
TaskDeleteCharacter.h
|
||||
TaskEnableCharacter.cpp
|
||||
TaskEnableCharacter.h
|
||||
TaskGetAccountForPurge.cpp
|
||||
TaskGetAccountForPurge.h
|
||||
TaskGetAvatarList.cpp
|
||||
TaskGetAvatarList.h
|
||||
TaskGetCharactersForDelete.cpp
|
||||
TaskGetCharactersForDelete.h
|
||||
TaskGetClusterList.cpp
|
||||
TaskGetClusterList.h
|
||||
TaskGetValidationData.cpp
|
||||
TaskGetValidationData.h
|
||||
TaskRegisterNewCluster.cpp
|
||||
TaskRegisterNewCluster.h
|
||||
TaskRenameCharacter.cpp
|
||||
TaskRenameCharacter.h
|
||||
TaskRestoreCharacter.cpp
|
||||
TaskRestoreCharacter.h
|
||||
TaskSetPurgeStatus.cpp
|
||||
TaskSetPurgeStatus.h
|
||||
TaskToggleCharacterDisable.cpp
|
||||
TaskToggleCharacterDisable.h
|
||||
TaskToggleCompletedTutorial.cpp
|
||||
TaskToggleCompletedTutorial.h
|
||||
TaskUpdatePurgeAccountList.cpp
|
||||
TaskUpdatePurgeAccountList.h
|
||||
TaskUpgradeAccount.cpp
|
||||
TaskUpgradeAccount.h
|
||||
)
|
||||
@@ -0,0 +1,397 @@
|
||||
// CSToolConnection.cpp
|
||||
// copyright 2005 Sony Online Entertainment
|
||||
// Author: Robert Hanz
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
|
||||
#include "Archive/ByteStream.h"
|
||||
#include "ConfigLoginServer.h"
|
||||
#include "CSToolConnection.h"
|
||||
#include "serverNetworkMessages/CSToolRequest.h"
|
||||
#include "serverUtility/AdminAccountManager.h"
|
||||
#include "Session/LoginAPI/Client.h"
|
||||
#include "SessionApiClient.h"
|
||||
#include "sharedLog/Log.h"
|
||||
|
||||
#if defined(WIN32)
|
||||
#include <winsock.h>
|
||||
#else // for non-windows platforms (linux)
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
namespace CSToolConnectionNamespace
|
||||
{
|
||||
std::map< uint32, CSToolConnection * > toolsByID;
|
||||
}
|
||||
|
||||
uint32 CSToolConnection::m_curToolID = 0;
|
||||
|
||||
// statics
|
||||
|
||||
CSToolConnection * CSToolConnection::getCSToolConnectionByToolId( uint32 id )
|
||||
{
|
||||
std::map< uint32, CSToolConnection * >::iterator it = CSToolConnectionNamespace::toolsByID.find( id );
|
||||
return it == CSToolConnectionNamespace::toolsByID.end() ? 0 : it->second;
|
||||
}
|
||||
|
||||
void CSToolConnection::validateCSTool(uint32 toolId, apiResult result, const apiSession& session)
|
||||
{
|
||||
//find the tool
|
||||
CSToolConnection * p_connection = getCSToolConnectionByToolId(toolId);
|
||||
if (!p_connection)
|
||||
return; // no connection, they must have bailed.
|
||||
|
||||
// check the result
|
||||
if(result == RESULT_SUCCESS)
|
||||
{
|
||||
// if we're valid, set to logged in
|
||||
p_connection->m_bLoggedIn = true;
|
||||
if (session.GetIsSecure())
|
||||
{
|
||||
p_connection->m_bSecure = true;
|
||||
}
|
||||
|
||||
// if we have a null session type, then we aren't connected to the
|
||||
// Session Server and are in debug mode.
|
||||
//
|
||||
// if we *do* have a good session, then check the admin table for access level.
|
||||
int accessLevel = 100;
|
||||
|
||||
bool sessionNull = (session.GetType() == SESSION_TYPE_NULL);
|
||||
bool isAdmin = AdminAccountManager::isAdminAccount(p_connection->m_sUserName, accessLevel);
|
||||
bool needSecure = ConfigLoginServer::getRequireSecureLoginForCsTool();
|
||||
bool isInternal = AdminAccountManager::isInternalIp(p_connection->getRemoteAddress());
|
||||
DEBUG_REPORT_LOG( true, ("CS Tool login for %s, admin=%s, access=%d, internal=%s\n",
|
||||
p_connection->m_sUserName.c_str(),
|
||||
isAdmin ? "true" : "false",
|
||||
accessLevel,
|
||||
isInternal ? "true" : "false"));
|
||||
|
||||
|
||||
bool canLogin = isInternal; // we always have to be internal.
|
||||
if (sessionNull)
|
||||
{
|
||||
// null session means we can skip everything else.
|
||||
canLogin = canLogin && true;
|
||||
accessLevel = 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
// if we don't have a session, we need to be on the admin table
|
||||
if(isAdmin)
|
||||
{
|
||||
// allow login if we either don't need to be secure, or if we are.
|
||||
if((!needSecure) || p_connection->m_bSecure)
|
||||
{
|
||||
canLogin = canLogin && true;
|
||||
}
|
||||
else
|
||||
{
|
||||
canLogin = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
canLogin = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(canLogin)
|
||||
{
|
||||
// and inform
|
||||
std::string response = "Logged in successfully.";
|
||||
|
||||
response += "\r\n";
|
||||
p_connection->sendToTool(response);
|
||||
|
||||
p_connection->m_ui32PrivilegeLevel = (uint32)accessLevel;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_connection->sendToTool("Invalid name/password.\r\n");
|
||||
}
|
||||
|
||||
}
|
||||
// otherwise, give the appropriate response
|
||||
else if( result == RESULT_INVALID_NAME_OR_PASSWORD )
|
||||
{
|
||||
p_connection->sendToTool("Invalid name/password.\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_REPORT_LOG(true,("Could not log in CS Tool for user %s, reason %d\n", p_connection->m_sUserName.c_str(), result));
|
||||
p_connection->sendToTool("Invalid name/password.\r\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// members
|
||||
|
||||
CSToolConnection::CSToolConnection( UdpConnectionMT * pUdpConn, TcpClient * pTcpConn ) :
|
||||
Connection( pUdpConn, pTcpConn ),
|
||||
m_ui32StationID( 0 ),
|
||||
m_bSecure( false ),
|
||||
m_bLoggedIn( false ),
|
||||
m_ui32PrivilegeLevel( 0 )
|
||||
{
|
||||
if( pTcpConn ) // it'd better be!
|
||||
setRawTCP( true );
|
||||
}
|
||||
|
||||
CSToolConnection::~CSToolConnection()
|
||||
{
|
||||
}
|
||||
|
||||
void CSToolConnection::onReceive( const Archive::ByteStream & message )
|
||||
{
|
||||
// for testing purposes, just echo back to the user.
|
||||
|
||||
// add to buffer
|
||||
std::string input;
|
||||
const unsigned char * uc = message.getBuffer();
|
||||
while (uc < message.getBuffer() + message.getSize())
|
||||
{
|
||||
char s = *uc;
|
||||
input += s;
|
||||
++uc;
|
||||
}
|
||||
m_sInputBuffer += input;
|
||||
|
||||
|
||||
// while we've got an EOL signifier
|
||||
std::string::size_type pos;
|
||||
while( ( pos = m_sInputBuffer.find( '\r' ) ) != std::string::npos )
|
||||
{
|
||||
// rebuild message buffer properly.
|
||||
std::string command = m_sInputBuffer.substr( 0, pos );
|
||||
// should dispatch here, for now we're echoing back for debug.
|
||||
|
||||
//command = command + "\r\n";
|
||||
//sendToTool( command );
|
||||
this->parse( command );
|
||||
// then we have additional data. Otherwise, we don't.
|
||||
if( m_sInputBuffer.size() >= pos + 2 )
|
||||
{
|
||||
m_sInputBuffer = m_sInputBuffer.substr( pos + 2, m_sInputBuffer.length() - ( pos + 2 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_sInputBuffer = "";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void CSToolConnection::parse( const std::string command )
|
||||
{
|
||||
// grab the first word of the command.
|
||||
std::string first;
|
||||
std::string args;
|
||||
std::string::size_type pos;
|
||||
if( ( pos = command.find( ' ' ) ) == std::string::npos )
|
||||
{
|
||||
first = command;
|
||||
}
|
||||
else
|
||||
{
|
||||
first = command.substr( 0, pos );
|
||||
args = command.substr( pos + 1, command.size() - ( pos + 1 ) );
|
||||
}
|
||||
// test for empty commands.
|
||||
if( first.length() == 0 || first[ 0 ] == ' ' )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::string response = "ls:";
|
||||
|
||||
|
||||
if( first == "clusters" )
|
||||
{
|
||||
response += "Active clusters:\r\n";
|
||||
std::map< std::string, uint32 > data;
|
||||
LoginServer::getInstance().getAllClusterNamesAndIDs( data );
|
||||
for( std::map< std::string, uint32 >::iterator it = data.begin();
|
||||
it != data.end();
|
||||
++it )
|
||||
{
|
||||
response += it->first + "\r\n";
|
||||
}
|
||||
sendToTool( response );
|
||||
}
|
||||
else if ( first == "select" )
|
||||
{
|
||||
// see if we're adding, removing, or exclusive-adding.
|
||||
if( args[ 0 ] == '+' )
|
||||
{
|
||||
if( args.size() > 1 )
|
||||
{
|
||||
if( args[ 1 ] == '+' )
|
||||
{
|
||||
m_selectedClusters.clear();
|
||||
sendToTool( "ls:deselected all servers\r\n" );
|
||||
}
|
||||
pos = args.find_first_not_of( "+" );
|
||||
if( pos == std::string::npos )
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string cluster = args.substr( pos, args.size() - pos );
|
||||
response += selectCluster( cluster );
|
||||
sendToTool( response );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( args[ 0 ] == '-' )
|
||||
{
|
||||
if( args.size() > 1 )
|
||||
{
|
||||
std::string cluster = args.substr( 1, args.size() - 1 );
|
||||
if( m_selectedClusters.find( cluster ) != m_selectedClusters.end() )
|
||||
{
|
||||
response += deselectCluster( cluster );
|
||||
sendToTool( response );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sendToTool( "Error! Bad select format!\r\n" );
|
||||
}
|
||||
}
|
||||
else if ( first == "showselected" )
|
||||
{
|
||||
response += "Currently selected clusters:\r\n";
|
||||
for( std::set< std::string >::iterator it = m_selectedClusters.begin();
|
||||
it != m_selectedClusters.end();
|
||||
++it )
|
||||
{
|
||||
response += *it + "\r\n";
|
||||
}
|
||||
sendToTool( response );
|
||||
|
||||
}
|
||||
else if( first == "login" )
|
||||
{
|
||||
// assume name/pw do not have spaces.
|
||||
std::string name;
|
||||
std::string pw;
|
||||
|
||||
// split apart
|
||||
unsigned pos = args.find( " " );
|
||||
if( pos != std::string::npos )
|
||||
{
|
||||
name = args.substr( 0, pos );
|
||||
pw = args.substr( pos + 1, args.length() - pos - 1 );
|
||||
m_sUserName = name;
|
||||
if( !LoginServer::getInstance().getSessionApiClient() )
|
||||
{
|
||||
apiSession session;
|
||||
validateCSTool( m_toolID, RESULT_SUCCESS, session );
|
||||
return;
|
||||
}
|
||||
LoginServer::getInstance().getSessionApiClient()->
|
||||
SessionLogin(name.c_str(),
|
||||
pw.c_str(),
|
||||
SESSION_TYPE_STARWARS,
|
||||
inet_addr( getRemoteAddress().c_str() ),
|
||||
0,
|
||||
_defaultNamespace,
|
||||
( void * )m_toolID );
|
||||
}
|
||||
|
||||
// pass to session.
|
||||
}
|
||||
// default command handler.
|
||||
else
|
||||
{
|
||||
if( m_bLoggedIn )
|
||||
{
|
||||
sendToClusters( first, command );
|
||||
}
|
||||
else
|
||||
{
|
||||
sendToTool( "Not logged in.\r\n" );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CSToolConnection::sendToClusters( const std::string & sCommand, const std::string & sCommandLine )
|
||||
{
|
||||
// build the message
|
||||
CSToolRequest msg( m_ui32StationID, m_ui32PrivilegeLevel, sCommandLine, sCommand, m_toolID, m_sUserName );
|
||||
|
||||
// send to all currently selected clusters.
|
||||
for( std::set< std::string >::iterator it = m_selectedClusters.begin();
|
||||
it != m_selectedClusters.end();
|
||||
++it )
|
||||
{
|
||||
LoginServer::getInstance().sendToCluster( LoginServer::getInstance().getClusterIDByName( *it ), msg );
|
||||
}
|
||||
}
|
||||
|
||||
std::string CSToolConnection::selectCluster( const std::string & cluster )
|
||||
{
|
||||
std::string response;
|
||||
// see if we have a valid cluster.
|
||||
uint32 cluster_id = LoginServer::getInstance().getClusterIDByName( cluster );
|
||||
if( cluster_id == 0 )
|
||||
{
|
||||
response += "Cluster " + cluster + " does not exist.\r\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
m_selectedClusters.insert( cluster );
|
||||
response += "Cluster " + cluster + " added to active list\r\n";
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
std::string CSToolConnection::deselectCluster( const std::string & cluster )
|
||||
{
|
||||
std::string response;
|
||||
|
||||
// see if we are currently talking to that cluster.
|
||||
std::set< std::string >::iterator it = m_selectedClusters.find( cluster );
|
||||
if( it == m_selectedClusters.end() )
|
||||
{
|
||||
response += "Cluster " + cluster + " is not currently selected.\r\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
m_selectedClusters.erase( it );
|
||||
response += "Cluster " + cluster + " removed from active list.\r\n";
|
||||
}
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
void CSToolConnection::sendToTool( const std::string & message )
|
||||
{
|
||||
// convert to ByteStream
|
||||
std::string temp = message;
|
||||
temp += "\r\n*\r\n";
|
||||
Archive::ByteStream bs;
|
||||
bs.put( temp.c_str(), temp.size() );
|
||||
// send.
|
||||
this->send( bs, true );
|
||||
}
|
||||
|
||||
void CSToolConnection::onConnectionOpened()
|
||||
{
|
||||
LOG( "CSTool", ("Connection opened") );
|
||||
// assign an ID, and stick it in our map.
|
||||
m_curToolID++;
|
||||
m_toolID = m_curToolID;
|
||||
CSToolConnectionNamespace::toolsByID[ m_toolID ] = this;
|
||||
|
||||
}
|
||||
|
||||
void CSToolConnection::onConnectionClosed()
|
||||
{
|
||||
LOG( "CSTool", ("Connection closed") );
|
||||
CSToolConnectionNamespace::toolsByID.erase( m_toolID );
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
// CSToolConnection.h
|
||||
// copyright 2005 Sony Online Entertainment
|
||||
// Author: Robert Hanz
|
||||
|
||||
#ifndef _CSToolConnection_h
|
||||
#define _CSToolConnection_h
|
||||
|
||||
#include "SessionApiClient.h"
|
||||
#include "sharedFoundation/StationId.h"
|
||||
#include "sharedNetwork/Connection.h"
|
||||
|
||||
#include <set>
|
||||
|
||||
|
||||
class CSToolConnection : public Connection
|
||||
{
|
||||
public:
|
||||
CSToolConnection(UdpConnectionMT *, TcpClient *);
|
||||
|
||||
CSToolConnection(
|
||||
const std::string & address,
|
||||
const unsigned short port);
|
||||
|
||||
virtual ~CSToolConnection();
|
||||
|
||||
void onReceive(const Archive::ByteStream & message);
|
||||
void sendToTool(const std::string & message );
|
||||
virtual void onConnectionOpened();
|
||||
virtual void onConnectionClosed();
|
||||
void sendToClusters( const std::string & sCommand, const std::string &sCommandLine );
|
||||
|
||||
static CSToolConnection * getCSToolConnectionByToolId( uint32 id );
|
||||
static void validateCSTool( uint32 toolId, apiResult result, const apiSession & session );
|
||||
|
||||
// cluster selection interface
|
||||
std::string selectCluster( const std::string & cluster );
|
||||
std::string deselectCluster( const std::string & cluster );
|
||||
|
||||
protected:
|
||||
|
||||
void parse( const std::string command );
|
||||
|
||||
uint32 m_ui32StationID; // 0 = not authenticated
|
||||
std::string m_sAccountLogin;
|
||||
bool m_bSecure;
|
||||
bool m_bLoggedIn;
|
||||
uint32 m_ui32PrivilegeLevel;
|
||||
std::string m_sInputBuffer;
|
||||
std::string m_sUserName;
|
||||
uint32 m_toolID;
|
||||
static uint32 m_curToolID;
|
||||
std::set< std::string > m_selectedClusters;
|
||||
|
||||
private:
|
||||
CSToolConnection(const CSToolConnection& );
|
||||
CSToolConnection& operator=(const CSToolConnection& );
|
||||
};
|
||||
|
||||
#endif //_CSToolConnection_h
|
||||
@@ -0,0 +1,375 @@
|
||||
// CentralServerConnection.cpp
|
||||
// copyright 2000 Verant Interactive
|
||||
// Author: Justin Randall
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
#include "Archive/ByteStream.h"
|
||||
#include "sharedFoundation/NetworkIdArchive.h"
|
||||
#include "CentralServerConnection.h"
|
||||
#include "ConsoleManager.h"
|
||||
#include "CSToolConnection.h"
|
||||
#include "ClientConnection.h"
|
||||
#include "DatabaseConnection.h"
|
||||
#include "serverNetworkMessages/CSToolResponse.h"
|
||||
#include "serverNetworkMessages/LoginClusterName.h"
|
||||
#include "serverNetworkMessages/LoginClusterName2.h"
|
||||
#include "serverNetworkMessages/ToggleAvatarLoginStatus.h"
|
||||
#include "serverNetworkMessages/TransferAccountData.h"
|
||||
#include "serverNetworkMessages/TransferAccountDataArchive.h"
|
||||
#include "serverNetworkMessages/TransferCharacterData.h"
|
||||
#include "serverNetworkMessages/TransferCharacterDataArchive.h"
|
||||
#include "serverNetworkMessages/TransferReplyCharacterList.h"
|
||||
#include "sharedLog/Log.h"
|
||||
#include "sharedNetwork/NetworkSetupData.h"
|
||||
#include "sharedNetworkMessages/ConsoleChannelMessages.h"
|
||||
#include "sharedNetworkMessages/DeleteCharacterMessage.h"
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
#include "Unicode.h"
|
||||
#include "UnicodeUtils.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
namespace CentralServerConnectionNamespace
|
||||
{
|
||||
std::map<std::string, CentralServerConnection *> s_centralConnectionsByName;
|
||||
}
|
||||
|
||||
using namespace CentralServerConnectionNamespace;
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
CentralServerConnection::CentralServerConnection(UdpConnectionMT * u, TcpClient * t) :
|
||||
ServerConnection(u, t),
|
||||
m_clusterName(),
|
||||
m_networkVersion(),
|
||||
m_clusterId(0)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
CentralServerConnection::CentralServerConnection(
|
||||
const std::string & address,
|
||||
const unsigned short port,
|
||||
const std::string &clusterName,
|
||||
const uint32 clusterId) :
|
||||
ServerConnection(address,port, NetworkSetupData()),
|
||||
m_clusterName( clusterName ),
|
||||
m_networkVersion(),
|
||||
m_clusterId( clusterId )
|
||||
{
|
||||
s_centralConnectionsByName[m_clusterName] = this;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
CentralServerConnection::~CentralServerConnection()
|
||||
{
|
||||
if(! m_clusterName.empty())
|
||||
{
|
||||
std::map<std::string, CentralServerConnection *>::iterator f = s_centralConnectionsByName.find(m_clusterName);
|
||||
if(f != s_centralConnectionsByName.end())
|
||||
{
|
||||
s_centralConnectionsByName.erase(f);
|
||||
}
|
||||
|
||||
LOG("CentralServerConnection", ("Galaxy [%s] disconnected", m_clusterName.c_str()));
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("CentralServerConnection", ("Galaxy connection destroyed (never fully connected)"));
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CentralServerConnection::onConnectionOpened()
|
||||
{
|
||||
ServerConnection::onConnectionOpened();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CentralServerConnection::onReceive(const Archive::ByteStream & message)
|
||||
{
|
||||
// emit the message in case someone else wants to use it
|
||||
ServerConnection::onReceive(message);
|
||||
|
||||
Archive::ReadIterator ri = message.begin();
|
||||
GameNetworkMessage m(ri);
|
||||
ri = message.begin();
|
||||
// handle messages the connection object itself may be interested in
|
||||
if(m.isType("LoginClusterName"))
|
||||
{
|
||||
const LoginClusterName c(ri);
|
||||
ri = message.begin();
|
||||
setClusterName(c.getClusterName());
|
||||
LOG("CentralServerConnection", ("Galaxy [%s] connected", c.getClusterName().c_str()));
|
||||
}
|
||||
else if ( m.isType( "LoginClusterName2" ) )
|
||||
{
|
||||
const LoginClusterName2 c( ri );
|
||||
ri = message.begin();
|
||||
|
||||
const std::string &clusterName = c.getClusterName();
|
||||
const std::string &branch = c.getBranch();
|
||||
const int changelist = c.getChangelist();
|
||||
const std::string &networkVersion = c.getNetworkVersion();
|
||||
|
||||
DEBUG_REPORT_LOG( true, ( "!!!!!!!!!!!!!!!! name=%s branch=%s changelist=%d net=%s\n", clusterName.c_str(), branch.c_str(), changelist, networkVersion.c_str() ) );
|
||||
|
||||
setClusterName( clusterName );
|
||||
setNetworkVersion( c.getNetworkVersion() );
|
||||
LOG("CentralServerConnection", ("Galaxy [%s] connected", getClusterName().c_str()));
|
||||
|
||||
LoginServer::getInstance().setClusterInfoByName( clusterName, branch, changelist, networkVersion );
|
||||
|
||||
}
|
||||
else if(m.isType("ToggleAvatarLoginStatus"))
|
||||
{
|
||||
const ToggleAvatarLoginStatus t(ri);
|
||||
if(t.getEnabled())
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: ToggleAvatarLoginStatus(%s, %d, %s, true)", t.getClusterName().c_str(), t.getStationId(), t.getCharacterId().getValueString().c_str()));
|
||||
}
|
||||
else
|
||||
{
|
||||
// send message to the cluster to drop connected clients for the
|
||||
// station id in case the avatar being disabled is currently logged in
|
||||
GenericValueTypeMessage<unsigned int> const closeRequest("TransferCloseClientConnection", t.getStationId());
|
||||
LoginServer::getInstance().sendToCluster(LoginServer::getInstance().getClusterIDByName(t.getClusterName()), closeRequest);
|
||||
|
||||
LOG("CustomerService", ("CharacterTransfer: ToggleAvatarLoginStatus(%s, %d, %s, false)\n", t.getClusterName().c_str(), t.getStationId(), t.getCharacterId().getValueString().c_str()));
|
||||
}
|
||||
DatabaseConnection::getInstance().toggleDisableCharacter(LoginServer::getInstance().getClusterIDByName(t.getClusterName()), t.getCharacterId(), t.getStationId(), t.getEnabled());
|
||||
}
|
||||
else if(m.isType("CtsCompletedForcharacter"))
|
||||
{
|
||||
const GenericValueTypeMessage<std::pair<std::string, NetworkId> > msg(ri);
|
||||
LoginServer::getInstance().sendToCluster(LoginServer::getInstance().getClusterIDByName(msg.getValue().first), msg);
|
||||
}
|
||||
else if(m.isType("TransferRequestCharacterList"))
|
||||
{
|
||||
const GenericValueTypeMessage<TransferCharacterData> request(ri);
|
||||
const TransferCharacterData & d = request.getValue();
|
||||
DatabaseConnection::getInstance().requestAvatarListForAccount(d.getSourceStationId(), &d);
|
||||
}
|
||||
else if(m.isType("TransferReplyLoginLocationData"))
|
||||
{
|
||||
const GenericValueTypeMessage<TransferCharacterData> reply(ri);
|
||||
const TransferCharacterData & d = reply.getValue();
|
||||
LOG("CustomerService", ("CharacterTransfer: Received login location data. %s", d.toString().c_str()));
|
||||
}
|
||||
else if(m.isType("TransferGetCharacterDataFromLoginServer"))
|
||||
{
|
||||
// the TransferServer sent a request to the central server
|
||||
// to retrieve a character ID from the login database given
|
||||
// a source station ID and a source character name. Retrieve
|
||||
// this data from the login database.
|
||||
const GenericValueTypeMessage<TransferCharacterData> request(ri);
|
||||
TransferCharacterData d = request.getValue();
|
||||
DatabaseConnection::getInstance().requestAvatarListForAccount(d.getSourceStationId(), &d);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferGetCharactetrDataFromLoginServer from CentralServer. %s", d.toString().c_str()));
|
||||
}
|
||||
else if(m.isType("TransferRenameCharacterInLoginDatabase"))
|
||||
{
|
||||
const GenericValueTypeMessage<TransferCharacterData> request(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferRenameCharacterInLoginDatabase : %s", request.getValue().toString().c_str()));
|
||||
const TransferCharacterData & requestData = request.getValue();
|
||||
DatabaseConnection::getInstance().renameCharacter(getClusterId(), requestData.getCharacterId(), Unicode::narrowToWide(requestData.getDestinationCharacterName()), &requestData);
|
||||
}
|
||||
else if(m.isType("TransferKickConnectedClients"))
|
||||
{
|
||||
const GenericValueTypeMessage<unsigned int> kick(ri);
|
||||
ClientConnection * clientConnection = LoginServer::getInstance().getValidatedClient(kick.getValue());
|
||||
if(! clientConnection)
|
||||
{
|
||||
clientConnection = LoginServer::getInstance().getUnvalidatedClient(kick.getValue());
|
||||
}
|
||||
|
||||
if(clientConnection)
|
||||
{
|
||||
clientConnection->disconnect();
|
||||
}
|
||||
}
|
||||
else if(m.isType("TransferAccountRequestLoginServer"))
|
||||
{
|
||||
const GenericValueTypeMessage<TransferAccountData> request(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferAccountRequestLoginServer from station ID %d to from station ID %d", request.getValue().getSourceStationId(), request.getValue().getDestinationStationId()));
|
||||
const TransferAccountData requestData = request.getValue();
|
||||
DatabaseConnection::getInstance().requestAvatarListAccountTransfer(&requestData);
|
||||
}
|
||||
else if(m.isType("EnableCharacterMessage"))
|
||||
{
|
||||
const GenericValueTypeMessage<std::pair<std::pair<StationId, NetworkId>, std::string> > msg(ri);
|
||||
|
||||
LOG("LoginServer", ("EnableCharacter %d, %s request from %s\n", msg.getValue().first.first, msg.getValue().first.second.getValueString().c_str(), msg.getValue().second.c_str()));
|
||||
|
||||
DatabaseConnection::getInstance().enableCharacter(msg.getValue().first.first, msg.getValue().first.second, msg.getValue().second, true, m_clusterId);
|
||||
}
|
||||
else if(m.isType("DisableCharacterMessage"))
|
||||
{
|
||||
const GenericValueTypeMessage<std::pair<std::pair<StationId, NetworkId>, std::string> > msg(ri);
|
||||
|
||||
LOG("LoginServer", ("DisableCharacter %d, %s request from %s\n", msg.getValue().first.first, msg.getValue().first.second.getValueString().c_str(), msg.getValue().second.c_str()));
|
||||
|
||||
DatabaseConnection::getInstance().enableCharacter(msg.getValue().first.first, msg.getValue().first.second, msg.getValue().second, false, m_clusterId);
|
||||
}
|
||||
else if(m.isType("DeleteFailedTransfer"))
|
||||
{
|
||||
GenericValueTypeMessage<TransferCharacterData> deleteCharacter(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: LoginServer received request to delete a character for a failed transfer. %s", deleteCharacter.getValue().toString().c_str()));
|
||||
LoginServer::getInstance().deleteCharacter(m_clusterId, deleteCharacter.getValue().getDestinationCharacterId(), deleteCharacter.getValue().getDestinationStationId());
|
||||
}
|
||||
else if(m.isType("RequestTransferClosePseudoClientConnection"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::string, unsigned int> > const request(ri);
|
||||
GenericValueTypeMessage<unsigned int> const closeRequest("TransferClosePseudoClientConnection", request.getValue().second);
|
||||
LoginServer::getInstance().sendToCluster(LoginServer::getInstance().getClusterIDByName(request.getValue().first), closeRequest);
|
||||
}
|
||||
else if(m.isType("CSToolResponse" ) )
|
||||
{
|
||||
CSToolResponse response(ri);
|
||||
// find the connection, if it still exists
|
||||
CSToolConnection * con = CSToolConnection::getCSToolConnectionByToolId( response.getToolId() );
|
||||
|
||||
// send the response
|
||||
if( con )
|
||||
{
|
||||
std::string message;
|
||||
message = m_clusterName + ":" + response.getResult();
|
||||
|
||||
if( message[ message.length() -1 ] == '\n' && message[ message.length() - 2 ] != '\r' )
|
||||
{
|
||||
message[ message.length() - 1 ] = '\r';
|
||||
message += '\n';
|
||||
}
|
||||
|
||||
con->sendToTool( message );
|
||||
}
|
||||
}
|
||||
else if(m.isType("ConGenericMessage"))
|
||||
{
|
||||
ConGenericMessage con(ri);
|
||||
parseCommand(con.getMsg(), con.getMsgId());
|
||||
}
|
||||
else if(m.isType("LoginToggleCompletedTutorial"))
|
||||
{
|
||||
GenericValueTypeMessage< std::pair<unsigned int, bool> > const request(ri);
|
||||
std::pair<unsigned int, bool> values = request.getValue();
|
||||
DatabaseConnection::getInstance().toggleCompletedTutorial(values.first, values.second);
|
||||
}
|
||||
|
||||
else if(m.isType("AllCluserGlobalChannel"))
|
||||
{
|
||||
typedef std::pair<std::pair<std::string,std::string>, bool> PayloadType;
|
||||
GenericValueTypeMessage<PayloadType> msg(ri);
|
||||
|
||||
PayloadType const & payload = msg.getValue();
|
||||
std::string const & channelName = payload.first.first;
|
||||
std::string const & messageText = payload.first.second;
|
||||
bool const & isRemove = payload.second;
|
||||
|
||||
LOG("CustomerService", ("BroadcastVoiceChannel: LoginServer sending AllCluserGlobalChannel to all clusters chan(%s) text(%s) remove(%d)",
|
||||
channelName.c_str(), messageText.c_str(), (isRemove?1:0) ));
|
||||
|
||||
LoginServer::getInstance().sendToAllClusters(msg);
|
||||
}
|
||||
|
||||
else if(m.isType("GcwScoreStatRaw"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::string, std::pair<std::map<std::string, std::pair<int64, int64> >, std::map<std::string, std::pair<int64, int64> > > > > const msg(ri);
|
||||
LoginServer::getInstance().sendToAllClusters(msg, NULL, 0, msg.getValue().first.c_str());
|
||||
}
|
||||
|
||||
else if(m.isType("GcwScoreStatPct"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::string, std::pair<std::map<std::string, int>, std::map<std::string, int> > > > const msg(ri);
|
||||
LoginServer::getInstance().sendToAllClusters(msg, NULL, 0, msg.getValue().first.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
bool CentralServerConnection::sendCharacterListResponse(unsigned int stationId, const AvatarList & avatarList, const TransferCharacterData & characterData)
|
||||
{
|
||||
bool result = false;
|
||||
// find proper central connection
|
||||
std::map<std::string, CentralServerConnection *>::iterator f = s_centralConnectionsByName.find(characterData.getSourceGalaxy());
|
||||
if(f != s_centralConnectionsByName.end())
|
||||
{
|
||||
// cull characters not associated with this server
|
||||
CentralServerConnection * connection = f->second;
|
||||
AvatarList::const_iterator i;
|
||||
AvatarList replyCharacters;
|
||||
for(i = avatarList.begin(); i != avatarList.end(); ++i)
|
||||
{
|
||||
if(i->m_clusterId == connection->m_clusterId)
|
||||
replyCharacters.push_back(*i);
|
||||
}
|
||||
TransferReplyCharacterList reply(characterData.getTrack(), stationId, replyCharacters);
|
||||
connection->send(reply, true);
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("Connection", ("Could not find a connection server to send character list response to for character %d\n", stationId));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CentralServerConnection::sendToCentralServer(const std::string & galaxyName, const GameNetworkMessage & message)
|
||||
{
|
||||
std::map<std::string, CentralServerConnection *>::iterator f = s_centralConnectionsByName.find(galaxyName);
|
||||
if(f != s_centralConnectionsByName.end())
|
||||
{
|
||||
CentralServerConnection * connection = f->second;
|
||||
connection->send(message, true);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CentralServerConnection::setClusterName(const std::string & newClusterName)
|
||||
{
|
||||
DEBUG_REPORT_LOG( true, ( "setClusterName %s\n", newClusterName.c_str() ) );
|
||||
|
||||
m_clusterName = newClusterName;
|
||||
s_centralConnectionsByName[m_clusterName] = this;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CentralServerConnection::setClusterId(uint32 clusterId)
|
||||
{
|
||||
m_clusterId = clusterId;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CentralServerConnection::parseCommand(const std::string & cmd, int track)
|
||||
{
|
||||
// int i = s_track;
|
||||
// s_resultsMap[i] = this;
|
||||
// ++s_track;
|
||||
std::string result;
|
||||
/*CommandParser::ErrorType err =*/ ConsoleManager::processString(cmd, track, result);
|
||||
ConGenericMessage con(result, track);
|
||||
send(con, true);
|
||||
/* if(err == CommandParser::ERR_CMD_NOT_FOUND)
|
||||
{
|
||||
onCommandComplete(result, track);
|
||||
}
|
||||
else if(!result.empty() && err == CommandParser::ERR_SUCCESS)
|
||||
{
|
||||
onCommandComplete(result, track);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@@ -0,0 +1,83 @@
|
||||
// CentralServerConnection.h
|
||||
// copyright 2000 Verant Interactive
|
||||
// Author: Justin Randall
|
||||
|
||||
#ifndef _CentralServerConnection_H
|
||||
#define _CentralServerConnection_H
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "serverNetworkMessages/AvatarList.h"
|
||||
#include "serverUtility/ServerConnection.h"
|
||||
|
||||
class CentralServerCommandChannel;
|
||||
class TransferCharacterData;
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
class CentralServerConnection : public ServerConnection
|
||||
{
|
||||
public:
|
||||
CentralServerConnection(UdpConnectionMT *, TcpClient *);
|
||||
|
||||
CentralServerConnection(
|
||||
const std::string & address,
|
||||
const unsigned short port,
|
||||
const std::string &clusterName,
|
||||
const uint32 clusterId);
|
||||
|
||||
~CentralServerConnection();
|
||||
|
||||
const std::string & getClusterName(void) const;
|
||||
uint32 getClusterId() const;
|
||||
const std::string & getNetworkVersion() const;
|
||||
void onConnectionOpened();
|
||||
void onReceive(const Archive::ByteStream & message);
|
||||
void setClusterName(const std::string & newClusterName);
|
||||
void setClusterId(uint32 clusterId);
|
||||
void setNetworkVersion( const std::string &networkVersion );
|
||||
static bool sendCharacterListResponse(unsigned int, const AvatarList &, const TransferCharacterData &);
|
||||
static void sendToCentralServer(const std::string &, const GameNetworkMessage &);
|
||||
|
||||
private:
|
||||
std::string m_clusterName;
|
||||
std::string m_networkVersion;
|
||||
uint32 m_clusterId;
|
||||
|
||||
private:
|
||||
CentralServerConnection(const CentralServerConnection&);
|
||||
CentralServerConnection& operator=(const CentralServerConnection&);
|
||||
void parseCommand (const std::string & cmd, int trackId);
|
||||
}; //lint !e1712 // default constructor not defined
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline const std::string & CentralServerConnection::getClusterName(void) const
|
||||
{
|
||||
return m_clusterName;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline uint32 CentralServerConnection::getClusterId() const
|
||||
{
|
||||
return m_clusterId;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline void CentralServerConnection::setNetworkVersion( const std::string &version )
|
||||
{
|
||||
m_networkVersion = version;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline const std::string &CentralServerConnection::getNetworkVersion() const
|
||||
{
|
||||
return m_networkVersion;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif // _CentralServerConnection_H
|
||||
@@ -0,0 +1,258 @@
|
||||
// ClientConnection.cpp
|
||||
// copyright 2000 Verant Interactive
|
||||
// Author: Justin Randall
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
#include "ClientConnection.h"
|
||||
|
||||
#include "Archive/ByteStream.h"
|
||||
#include "ConfigLoginServer.h"
|
||||
#include "DatabaseConnection.h"
|
||||
#include "LoginServer.h"
|
||||
#include "SessionApiClient.h"
|
||||
#include "serverKeyShare/KeyShare.h"
|
||||
#include "sharedFoundation/ApplicationVersion.h"
|
||||
#include "sharedLog/Log.h"
|
||||
#include "sharedNetworkMessages/ClientLoginMessages.h"
|
||||
#include "sharedNetworkMessages/DeleteCharacterMessage.h"
|
||||
#include "sharedNetworkMessages/DeleteCharacterReplyMessage.h"
|
||||
#include "sharedNetworkMessages/ErrorMessage.h"
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
#include "sharedNetworkMessages/LoginEnumCluster.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
ClientConnection::ClientConnection(UdpConnectionMT * u, TcpClient * t) :
|
||||
ServerConnection(u, t),
|
||||
m_clientId(0),
|
||||
m_isValidated(false),
|
||||
m_isSecure(false),
|
||||
m_adminLevel(-1),
|
||||
m_stationId(0),
|
||||
m_requestedAdminSuid(0),
|
||||
m_gameBits(0),
|
||||
m_subscriptionBits(0),
|
||||
m_waitingForCharacterLoginDeletion(false),
|
||||
m_waitingForCharacterClusterDeletion(false)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
ClientConnection::~ClientConnection()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void ClientConnection::onConnectionClosed()
|
||||
{
|
||||
// client has disconnected
|
||||
DEBUG_REPORT_LOG(true, ("Client %lu disconnected\n", getStationId()));
|
||||
LOG("LoginClientConnection", ("onConnectionClosed() for stationId (%lu) at IP (%s)", m_stationId, getRemoteAddress().c_str()));
|
||||
LoginServer::getInstance().removeClient(m_clientId);
|
||||
|
||||
if (!m_isValidated)
|
||||
{
|
||||
SessionApiClient * session = LoginServer::getInstance().getSessionApiClient();
|
||||
if (session)
|
||||
session->dropClient(this);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void ClientConnection::onConnectionOpened()
|
||||
{
|
||||
m_clientId = LoginServer::getInstance().addClient(*this);
|
||||
setOverflowLimit(ConfigLoginServer::getClientOverflowLimit());
|
||||
|
||||
LOG("LoginClientConnection", ("onConnectionOpened() for stationId (%lu) at IP (%s)", m_stationId, getRemoteAddress().c_str()));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void ClientConnection::onReceive(const Archive::ByteStream & message)
|
||||
{
|
||||
try
|
||||
{
|
||||
//Handle all client messages here. Do not forward out.
|
||||
Archive::ReadIterator ri = message.begin();
|
||||
GameNetworkMessage m(ri);
|
||||
ri = message.begin();
|
||||
|
||||
//Validation check
|
||||
if (!getIsValidated() && !m.isType("LoginClientId"))
|
||||
{
|
||||
//Receiving message from unvalidated client. Pitch it.
|
||||
DEBUG_WARNING(true, ("Received %s message from unknown, unvalidated client", m.getCmdName().c_str()));
|
||||
return;
|
||||
}
|
||||
|
||||
if(m.isType("LoginClientId"))
|
||||
{
|
||||
// send the client the server "now" Epoch time so that the
|
||||
// client has an idea of how much difference there is between
|
||||
// the client's Epoch time and the server Epoch time
|
||||
GenericValueTypeMessage<int32> const serverNowEpochTime(
|
||||
"ServerNowEpochTime", static_cast<int32>(::time(NULL)));
|
||||
send(serverNowEpochTime, true);
|
||||
|
||||
LoginClientId id(ri);
|
||||
|
||||
// verify version
|
||||
#if PRODUCTION == 1
|
||||
|
||||
if(!ConfigLoginServer::getValidateClientVersion() || id.getVersion() == GameNetworkMessage::NetworkVersionId)
|
||||
{
|
||||
validateClient(id.getId(), id.getKey());
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("CustomerService", ("Login:LoginServer dropping client (stationId=[%lu], ip=[%s], id=[%s], key=[%s], version=[%s]) because of network version mismatch (required version=[%s])", m_stationId, getRemoteAddress().c_str(), id.getId().c_str(), id.getKey().c_str(), id.getVersion().c_str(), GameNetworkMessage::NetworkVersionId.c_str()));
|
||||
// disconnect is handled on the client side, as soon as it recieves this message
|
||||
#if _DEBUG
|
||||
LoginIncorrectClientId incorrectId(GameNetworkMessage::NetworkVersionId, ApplicationVersion::getInternalVersion());
|
||||
#else
|
||||
LoginIncorrectClientId incorrectId("", "");
|
||||
#endif // _DEBUG
|
||||
send(incorrectId, true);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
validateClient( id.getId(), id.getKey() );
|
||||
|
||||
#endif // PRODUCTION == 1
|
||||
|
||||
}
|
||||
else if ( m.isType( "RequestExtendedClusterInfo" ) )
|
||||
{
|
||||
LoginServer::getInstance().sendExtendedClusterInfo( *this );
|
||||
}
|
||||
else if (m.isType("DeleteCharacterMessage"))
|
||||
{
|
||||
DeleteCharacterMessage msg(ri);
|
||||
std::vector<NetworkId>::const_iterator f = std::find(m_charactersPendingDeletion.begin(), m_charactersPendingDeletion.end(), msg.getCharacterId());
|
||||
if ((m_waitingForCharacterLoginDeletion || m_waitingForCharacterClusterDeletion) && f != m_charactersPendingDeletion.end())
|
||||
{
|
||||
DeleteCharacterReplyMessage reply(DeleteCharacterReplyMessage::rc_ALREADY_IN_PROGRESS);
|
||||
send(reply,true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LoginServer::getInstance().deleteCharacter(msg.getClusterId(), msg.getCharacterId(), getStationId()))
|
||||
{
|
||||
m_waitingForCharacterLoginDeletion=true;
|
||||
m_waitingForCharacterClusterDeletion=true;
|
||||
m_charactersPendingDeletion.push_back(msg.getCharacterId());
|
||||
}
|
||||
else
|
||||
{
|
||||
DeleteCharacterReplyMessage reply(DeleteCharacterReplyMessage::rc_CLUSTER_DOWN);
|
||||
send(reply,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(const Archive::ReadException & readException)
|
||||
{
|
||||
WARNING(true, ("Archive read error (%s) on message from client. Disconnecting client.", readException.what()));
|
||||
disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// Stub routine for station API account validation.
|
||||
// Grab a challenge key from the list and send it back to the client.
|
||||
void ClientConnection::validateClient(const std::string & id, const std::string & key)
|
||||
{
|
||||
|
||||
if (ConfigLoginServer::getValidateStationKey())
|
||||
{
|
||||
m_requestedAdminSuid = atoi(id.c_str()); // for normal logins, this will be set to 0
|
||||
|
||||
SessionApiClient * sessionApiClient = LoginServer::getInstance().getSessionApiClient();
|
||||
DEBUG_FATAL(!sessionApiClient, ("Config file says to validate with session, but no session api is installed"));
|
||||
if(sessionApiClient) //lint !e774 //(Boolean within 'if' always evaluates to True) the previous DEBUG_FATAL probably causes this warning
|
||||
sessionApiClient->validateClient(this, key);
|
||||
}
|
||||
else if (ConfigLoginServer::getDoSessionLogin())
|
||||
{
|
||||
SessionApiClient * sessionApiClient = LoginServer::getInstance().getSessionApiClient();
|
||||
DEBUG_FATAL(!sessionApiClient, ("Config file says to do session login, but no session api is installed"));
|
||||
if(sessionApiClient) //lint !e774 //(Boolean within 'if' always evaluates to True) the previous DEBUG_FATAL probably causes this warning
|
||||
sessionApiClient->loginClient(this, id, key);
|
||||
}
|
||||
else
|
||||
{
|
||||
StationId suid = atoi(id.c_str());
|
||||
|
||||
if (suid==0)
|
||||
{
|
||||
std::hash<std::string> h;
|
||||
suid = h(id); //lint !e603 // Symbol 'h' not initialized (it's a functor)
|
||||
}
|
||||
|
||||
LOG("LoginClientConnection", ("validateClient() for stationId (%lu) at IP (%s), id (%s) key (%s), skipping validating session", m_stationId, getRemoteAddress().c_str(), id.c_str(), key.c_str()));
|
||||
|
||||
LoginServer::getInstance().onValidateClient(suid, id, this, true, NULL, 0xFFFFFFFF, 0xFFFFFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The character has been deleted from the login database. 1/2 of what is
|
||||
* required for character deletion. If the character has already been deleted
|
||||
* from the cluster, send the reply message to the client.
|
||||
*/
|
||||
void ClientConnection::onCharacterDeletedFromLoginDatabase(const NetworkId & characterId)
|
||||
{
|
||||
m_waitingForCharacterLoginDeletion = false;
|
||||
if (!m_waitingForCharacterClusterDeletion)
|
||||
{
|
||||
std::vector<NetworkId>::iterator f = std::find(m_charactersPendingDeletion.begin(), m_charactersPendingDeletion.end(), characterId);
|
||||
if(f != m_charactersPendingDeletion.end())
|
||||
{
|
||||
m_charactersPendingDeletion.erase(f);
|
||||
}
|
||||
|
||||
DeleteCharacterReplyMessage reply(DeleteCharacterReplyMessage::rc_OK);
|
||||
send(reply,true);
|
||||
LOG("CustomerService", ("Player:deleted character %s for stationId %u at IP: %s", characterId.getValueString().c_str(), m_stationId, getRemoteAddress().c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void ClientConnection::onCharacterDeletedFromCluster(const NetworkId & characterId)
|
||||
{
|
||||
m_waitingForCharacterClusterDeletion = false;
|
||||
if (!m_waitingForCharacterLoginDeletion)
|
||||
{
|
||||
std::vector<NetworkId>::iterator f = std::find(m_charactersPendingDeletion.begin(), m_charactersPendingDeletion.end(), characterId);
|
||||
if(f != m_charactersPendingDeletion.end())
|
||||
{
|
||||
m_charactersPendingDeletion.erase(f);
|
||||
}
|
||||
|
||||
DeleteCharacterReplyMessage reply(DeleteCharacterReplyMessage::rc_OK);
|
||||
send(reply,true);
|
||||
LOG("CustomerService", ("Player:deleted character %s for stationId %u at IP: %s", characterId.getValueString().c_str(), m_stationId, getRemoteAddress().c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
StationId ClientConnection::getRequestedAdminSuid() const
|
||||
{
|
||||
return m_requestedAdminSuid;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
// ClientConnection.h
|
||||
// copyright 2000 Verant Interactive
|
||||
// Author: Justin Randall
|
||||
|
||||
#ifndef _ClientConnection_H
|
||||
#define _ClientConnection_H
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "serverUtility/ServerConnection.h"
|
||||
#include "sharedFoundation/StationId.h"
|
||||
|
||||
class ClientCommandChannel;
|
||||
class NetworkId;
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
class ClientConnection : public ServerConnection
|
||||
{
|
||||
public:
|
||||
ClientConnection(UdpConnectionMT *, TcpClient *);
|
||||
~ClientConnection();
|
||||
|
||||
bool getIsValidated() const;
|
||||
void setIsValidated(bool);
|
||||
|
||||
bool getIsSecure() const;
|
||||
void setIsSecure(bool);
|
||||
|
||||
int getAdminLevel() const;
|
||||
void setAdminLevel(int);
|
||||
|
||||
const StationId getStationId() const;
|
||||
void setStationId(StationId newValue) const;
|
||||
StationId getRequestedAdminSuid() const;
|
||||
|
||||
const uint32 getGameBits() const;
|
||||
const uint32 getSubscriptionBits() const;
|
||||
void setGameBits(uint32 gameBits) const;
|
||||
void setSubscriptionBits(uint32 subscriptionBits) const;
|
||||
|
||||
virtual void onConnectionClosed ();
|
||||
virtual void onConnectionOpened ();
|
||||
virtual void onReceive (const Archive::ByteStream & message);
|
||||
|
||||
void onCharacterDeletedFromLoginDatabase (const NetworkId & characterId);
|
||||
void onCharacterDeletedFromCluster (const NetworkId & characterId);
|
||||
|
||||
private:
|
||||
ClientConnection(const ClientConnection&);
|
||||
ClientConnection& operator=( const ClientConnection&);
|
||||
|
||||
void validateClient(const std::string & id, const std::string & key);
|
||||
|
||||
private:
|
||||
int m_clientId;
|
||||
bool m_isValidated;
|
||||
bool m_isSecure; // player logged in using a SecureId
|
||||
int m_adminLevel; // admin level of the player in the admin file (-1 if not in the admin file)
|
||||
mutable StationId m_stationId;
|
||||
StationId m_requestedAdminSuid;
|
||||
mutable uint32 m_gameBits;
|
||||
mutable uint32 m_subscriptionBits;
|
||||
|
||||
bool m_waitingForCharacterLoginDeletion;
|
||||
bool m_waitingForCharacterClusterDeletion;
|
||||
std::vector<NetworkId> m_charactersPendingDeletion;
|
||||
|
||||
}; //lint !e1712 // default constructor not defined
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline const StationId ClientConnection::getStationId() const
|
||||
{
|
||||
return m_stationId;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline void ClientConnection::setStationId(StationId newValue) const
|
||||
{
|
||||
m_stationId = newValue;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline bool ClientConnection::getIsValidated() const
|
||||
{
|
||||
return m_isValidated;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline void ClientConnection::setIsValidated(bool newValue)
|
||||
{
|
||||
m_isValidated = newValue;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline bool ClientConnection::getIsSecure() const
|
||||
{
|
||||
return m_isSecure;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline void ClientConnection::setIsSecure(bool newValue)
|
||||
{
|
||||
m_isSecure = newValue;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline int ClientConnection::getAdminLevel()const
|
||||
{
|
||||
return m_adminLevel;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline void ClientConnection::setAdminLevel(int newValue)
|
||||
{
|
||||
m_adminLevel = newValue;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline const uint32 ClientConnection::getGameBits() const
|
||||
{
|
||||
return m_gameBits;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline void ClientConnection::setGameBits(uint32 gameBits) const
|
||||
{
|
||||
m_gameBits = gameBits;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline const uint32 ClientConnection::getSubscriptionBits() const
|
||||
{
|
||||
return m_subscriptionBits;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline void ClientConnection::setSubscriptionBits(uint32 subscriptionBits) const
|
||||
{
|
||||
m_subscriptionBits = subscriptionBits;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
#endif // _ClientConnection_H
|
||||
@@ -0,0 +1,204 @@
|
||||
// ConfigLoginServer.cpp
|
||||
// copyright 2000 Verant Interactive
|
||||
// Author: Justin Randall
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
#include "serverUtility/ConfigServerUtility.h"
|
||||
#include "Session/LoginAPI/Client.h"
|
||||
#include "sharedFoundation/ConfigFile.h"
|
||||
#include "sharedNetwork/SetupSharedNetwork.h"
|
||||
#include "ConfigLoginServer.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
ConfigLoginServer::Data * ConfigLoginServer::data = 0;
|
||||
|
||||
#define KEY_INT(a,b) (data->a = ConfigFile::getKeyInt("LoginServer", #a, b))
|
||||
#define KEY_BOOL(a,b) (data->a = ConfigFile::getKeyBool("LoginServer", #a, b))
|
||||
// #define KEY_REAL(a,b) (data->a = ConfigFile::getKeyReal("LoginServer", #a, b))
|
||||
#define KEY_FLOAT(a,b) (data->a = ConfigFile::getKeyFloat("LoginServer", #a, b))
|
||||
#define KEY_STRING(a,b) (data->a = ConfigFile::getKeyString("LoginServer", #a, b))
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
namespace ConfigLoginServerNamespace
|
||||
{
|
||||
typedef std::vector<char const *> StringPtrArray;
|
||||
StringPtrArray ms_privateIpMasks; // ConfigFile owns the pointer
|
||||
StringPtrArray ms_sessionServer; // ConfigFile owns the pointer
|
||||
|
||||
int const ms_numPurgePhases=5;
|
||||
int ms_purgePhaseAdvanceDays[ms_numPurgePhases]={0,30,60,90,120};
|
||||
|
||||
// disable character creation for these clusters through config option
|
||||
std::set<std::string> ms_clusterCharacterCreationDisable;
|
||||
}
|
||||
|
||||
using namespace ConfigLoginServerNamespace;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
int ConfigLoginServer::getNumberOfSessionServers()
|
||||
{
|
||||
return static_cast<int>(ms_sessionServer.size());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
char const * ConfigLoginServer::getSessionServer(int index)
|
||||
{
|
||||
VALIDATE_RANGE_INCLUSIVE_EXCLUSIVE(0, index, getNumberOfSessionServers());
|
||||
return ms_sessionServer[static_cast<size_t>(index)];
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void ConfigLoginServer::install(void)
|
||||
{
|
||||
ConfigServerUtility::install();
|
||||
|
||||
SetupSharedNetwork::SetupData networkSetupData;
|
||||
SetupSharedNetwork::getDefaultServerSetupData(networkSetupData);
|
||||
SetupSharedNetwork::install(networkSetupData);
|
||||
|
||||
data = new ConfigLoginServer::Data;
|
||||
|
||||
KEY_INT (centralServicePort, 44452);
|
||||
KEY_INT (clientServicePort, 44453);
|
||||
KEY_INT (clientOverflowLimit, 1024 * 8);
|
||||
KEY_INT (maxClients, 250);
|
||||
KEY_INT (taskServicePort, 44459);
|
||||
KEY_INT (pingServicePort, 44460);
|
||||
KEY_INT (httpServicePort, 44490);
|
||||
KEY_STRING (DSN, "loginserver");
|
||||
KEY_STRING (privateIpMask, "127.0.0.1");
|
||||
KEY_STRING (databaseUID, "loginserver");
|
||||
KEY_STRING (schemaOwner, "");
|
||||
KEY_STRING (databasePWD, "loginserver");
|
||||
KEY_STRING (databaseProtocol, "OCI");
|
||||
KEY_BOOL (enableQueryProfile,false);
|
||||
KEY_BOOL (verboseQueryMode,false);
|
||||
KEY_BOOL(logWorkerThreads, false);
|
||||
KEY_INT (maxPlayersPerCluster, 2500);
|
||||
KEY_INT (maxCharactersPerCluster, 10000);
|
||||
KEY_INT (maxCharactersPerAccount, 20);
|
||||
KEY_BOOL (validateClientVersion, true);
|
||||
KEY_BOOL (validateStationKey, false);
|
||||
KEY_BOOL (doSessionLogin, false);
|
||||
KEY_BOOL (doConsumption, false);
|
||||
KEY_STRING (sessionServers, "sdlogin-test:3004");
|
||||
KEY_INT (sessionType, SESSION_TYPE_STARWARS);
|
||||
KEY_BOOL (developmentMode, true);
|
||||
KEY_INT (databaseThreads, 1);
|
||||
KEY_BOOL (compressClientNetworkTraffic, true);
|
||||
KEY_INT (metricsListenerPort, 2201);
|
||||
KEY_FLOAT (defaultDBQueueUpdateTimeLimit, 0.25f);
|
||||
KEY_INT (disconnectSleepTime, 30000);
|
||||
KEY_INT (clusterGroup,1);
|
||||
KEY_INT(maxSimultaneousPurgeAccounts,1000);
|
||||
KEY_INT(purgeSleepTime,600);
|
||||
KEY_BOOL(enableStructurePurge,false);
|
||||
KEY_BOOL(enableCharacterPurge,false);
|
||||
KEY_INT (updatePurgeAccountListTime, 0);
|
||||
KEY_STRING (purgeAccountSourceTable,"account_extract");
|
||||
KEY_STRING (adminAccountDataTable, "datatables/admin/us_admin.iff");
|
||||
KEY_BOOL(allowSkipTutorialToAll,false);
|
||||
KEY_BOOL(internalBypassOnlineLimit,true);
|
||||
KEY_INT (populationExtremelyHeavyThresholdPercent, 50);
|
||||
KEY_INT (populationVeryHeavyThresholdPercent, 40);
|
||||
KEY_INT (populationHeavyThresholdPercent, 32);
|
||||
KEY_INT (populationMediumThresholdPercent, 16);
|
||||
KEY_INT (populationLightThresholdPercent, 8);
|
||||
KEY_INT (csToolPort, 10666);
|
||||
KEY_BOOL(requireSecureLoginForCsTool, true);
|
||||
|
||||
int index = 0;
|
||||
char const * result = 0;
|
||||
do
|
||||
{
|
||||
result = ConfigFile::getKeyString("LoginServer", "privateIpMask", index++, 0);
|
||||
if (result != 0)
|
||||
{
|
||||
ms_privateIpMasks.push_back(result);
|
||||
}
|
||||
}
|
||||
while (result);
|
||||
|
||||
index = 0;
|
||||
result = 0;
|
||||
do
|
||||
{
|
||||
result = ConfigFile::getKeyString("LoginServer", "sessionServer", index++, 0);
|
||||
if (result != 0)
|
||||
{
|
||||
ms_sessionServer.push_back(result);
|
||||
}
|
||||
}
|
||||
while (result);
|
||||
|
||||
index = 0;
|
||||
result = 0;
|
||||
do
|
||||
{
|
||||
result = ConfigFile::getKeyString("LoginServer", "disableCharacterCreation", index++, 0);
|
||||
if (result != 0)
|
||||
{
|
||||
ms_clusterCharacterCreationDisable.insert(result);
|
||||
}
|
||||
}
|
||||
while (result);
|
||||
|
||||
if (!ms_clusterCharacterCreationDisable.empty())
|
||||
{
|
||||
for (std::set<std::string>::const_iterator iter = ms_clusterCharacterCreationDisable.begin(); iter != ms_clusterCharacterCreationDisable.end(); ++iter)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, ("Character creation for cluster (%s) has been disabled through config option.\n", iter->c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
char keyName[500];
|
||||
for (int index=0; index < ms_numPurgePhases; index++)
|
||||
{
|
||||
snprintf(keyName,sizeof(keyName),"purgePhaseAdvanceDays%i",index);
|
||||
ms_purgePhaseAdvanceDays[index] = ConfigFile::getKeyInt("LoginServer", keyName, 0, ms_purgePhaseAdvanceDays[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void ConfigLoginServer::remove(void)
|
||||
{
|
||||
delete data;
|
||||
data = 0;
|
||||
ConfigServerUtility::remove();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
int ConfigLoginServer::getPurgePhaseAdvanceDays(int purgePhase)
|
||||
{
|
||||
VALIDATE_RANGE_INCLUSIVE_EXCLUSIVE(0, purgePhase, ms_numPurgePhases);
|
||||
return ms_purgePhaseAdvanceDays[purgePhase];
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool ConfigLoginServer::isCharacterCreationDisabled(std::string const & cluster)
|
||||
{
|
||||
return (ms_clusterCharacterCreationDisable.count(cluster) >= 1);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
std::set<std::string> const & ConfigLoginServer::getCharacterCreationDisabledClusterList()
|
||||
{
|
||||
return ms_clusterCharacterCreationDisable;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,472 @@
|
||||
// ConfigLoginServer.h
|
||||
// copyright 2000 Verant Interactive
|
||||
// Author: Justin Randall
|
||||
|
||||
#ifndef _ConfigLoginServer_H
|
||||
#define _ConfigLoginServer_H
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
class ConfigLoginServer
|
||||
{
|
||||
public:
|
||||
struct Data
|
||||
{
|
||||
int centralServicePort;
|
||||
int clientServicePort;
|
||||
int maxClients;
|
||||
int taskServicePort;
|
||||
int pingServicePort;
|
||||
int httpServicePort;
|
||||
bool validateClientVersion;
|
||||
bool validateStationKey;
|
||||
bool doSessionLogin;
|
||||
bool doConsumption;
|
||||
const char * sessionServers;
|
||||
int sessionType;
|
||||
|
||||
const char * DSN;
|
||||
const char * databaseUID;
|
||||
const char * schemaOwner;
|
||||
const char * databasePWD;
|
||||
const char * databaseProtocol;
|
||||
bool enableQueryProfile;
|
||||
bool verboseQueryMode;
|
||||
bool logWorkerThreads;
|
||||
|
||||
const char * privateIpMask;
|
||||
int maxPlayersPerCluster;
|
||||
int maxCharactersPerCluster;
|
||||
int maxCharactersPerAccount;
|
||||
int clientOverflowLimit;
|
||||
bool developmentMode;
|
||||
int databaseThreads;
|
||||
bool compressClientNetworkTraffic;
|
||||
int metricsListenerPort;
|
||||
float defaultDBQueueUpdateTimeLimit;
|
||||
int disconnectSleepTime;
|
||||
int clusterGroup;
|
||||
int maxSimultaneousPurgeAccounts;
|
||||
int purgeSleepTime;
|
||||
bool enableStructurePurge;
|
||||
bool enableCharacterPurge;
|
||||
int updatePurgeAccountListTime;
|
||||
const char * purgeAccountSourceTable;
|
||||
const char * adminAccountDataTable;
|
||||
bool allowSkipTutorialToAll;
|
||||
|
||||
bool internalBypassOnlineLimit;
|
||||
|
||||
int populationExtremelyHeavyThresholdPercent;
|
||||
int populationVeryHeavyThresholdPercent;
|
||||
int populationHeavyThresholdPercent;
|
||||
int populationMediumThresholdPercent;
|
||||
int populationLightThresholdPercent;
|
||||
int csToolPort;
|
||||
|
||||
bool requireSecureLoginForCsTool;
|
||||
};
|
||||
|
||||
static const uint16 getCentralServicePort();
|
||||
static const uint16 getClientServicePort();
|
||||
static const int getClientOverflowLimit();
|
||||
static const uint16 getTaskServicePort();
|
||||
static const uint16 getPingServicePort();
|
||||
static const uint16 getHttpServicePort();
|
||||
static const bool getValidateClientVersion();
|
||||
static const bool getValidateStationKey();
|
||||
static const bool getDoSessionLogin();
|
||||
static const bool getDoConsumption();
|
||||
static const char * getSessionServers();
|
||||
static const int getSessionType();
|
||||
|
||||
static const int getMaxClients ();
|
||||
static const char * getPrivateIpMask();
|
||||
static const char * getDSN();
|
||||
static const char * getDatabaseUID();
|
||||
static const char * getSchemaOwner();
|
||||
static const char * getDatabasePWD();
|
||||
static const char * getDatabaseProtocol();
|
||||
static const bool getEnableQueryProfile();
|
||||
static const bool getVerboseQueryMode();
|
||||
static const bool getLogWorkerThreads();
|
||||
static int getMaxPlayersPerCluster();
|
||||
static int getMaxCharactersPerCluster();
|
||||
static int getMaxCharactersPerAccount();
|
||||
//static int getMaxCharactersPerAccountPerCluster();
|
||||
static const bool getDevelopmentMode();
|
||||
static int getDatabaseThreads();
|
||||
static bool getCompressClientNetworkTraffic();
|
||||
static uint16 getMetricsListenerPort();
|
||||
static float getDefaultDBQueueUpdateTimeLimit();
|
||||
static void install ();
|
||||
static void remove ();
|
||||
|
||||
static int getNumberOfSessionServers();
|
||||
static char const * getSessionServer(int index);
|
||||
static const int getDisconnectSleepTime (void);
|
||||
static const int getClusterGroup();
|
||||
static int getMaxSimultaneousPurgeAccounts();
|
||||
static int getPurgeSleepTime();
|
||||
static bool getEnableStructurePurge();
|
||||
static bool getEnableCharacterPurge();
|
||||
static int getUpdatePurgeAccountListTime();
|
||||
static const char * getPurgeAccountSourceTable();
|
||||
static int getPurgePhaseAdvanceDays(int purgePhase);
|
||||
static const char * getAdminAccountDataTable();
|
||||
static bool getAllowSkipTutorialToAll();
|
||||
|
||||
static bool getInternalBypassOnlineLimit();
|
||||
static const int getCSToolPort();
|
||||
|
||||
static bool getRequireSecureLoginForCsTool();
|
||||
|
||||
static int getPopulationExtremelyHeavyThresholdPercent();
|
||||
static int getPopulationVeryHeavyThresholdPercent();
|
||||
static int getPopulationHeavyThresholdPercent();
|
||||
static int getPopulationMediumThresholdPercent();
|
||||
static int getPopulationLightThresholdPercent();
|
||||
|
||||
// has character creation for this cluster been disabled through config option
|
||||
static bool isCharacterCreationDisabled(std::string const & cluster);
|
||||
static stdset<std::string>::fwd const & getCharacterCreationDisabledClusterList();
|
||||
|
||||
private:
|
||||
static Data * data;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline const uint16 ConfigLoginServer::getCentralServicePort()
|
||||
{
|
||||
return static_cast<const uint16>(data->centralServicePort);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline const uint16 ConfigLoginServer::getHttpServicePort()
|
||||
{
|
||||
return static_cast<const uint16>(data->httpServicePort);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline const uint16 ConfigLoginServer::getClientServicePort()
|
||||
{
|
||||
return static_cast<const uint16>(data->clientServicePort);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline const int ConfigLoginServer::getClientOverflowLimit()
|
||||
{
|
||||
return data->clientOverflowLimit;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
inline const int ConfigLoginServer::getMaxClients()
|
||||
{
|
||||
return data->maxClients;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline const char * ConfigLoginServer::getPrivateIpMask()
|
||||
{
|
||||
return data->privateIpMask;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline const uint16 ConfigLoginServer::getTaskServicePort()
|
||||
{
|
||||
return static_cast<const uint16>(data->taskServicePort);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline const uint16 ConfigLoginServer::getPingServicePort()
|
||||
{
|
||||
return static_cast<const uint16>(data->pingServicePort);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline const bool ConfigLoginServer::getValidateClientVersion()
|
||||
{
|
||||
return (data->validateClientVersion);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline const bool ConfigLoginServer::getValidateStationKey()
|
||||
{
|
||||
return (data->validateStationKey);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline const bool ConfigLoginServer::getDoSessionLogin()
|
||||
{
|
||||
return (data->doSessionLogin);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline const bool ConfigLoginServer::getDoConsumption()
|
||||
{
|
||||
return (data->doConsumption);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline const char * ConfigLoginServer::getSessionServers()
|
||||
{
|
||||
return (data->sessionServers);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
inline const int ConfigLoginServer::getSessionType()
|
||||
{
|
||||
return data->sessionType;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline const char * ConfigLoginServer::getDSN()
|
||||
{
|
||||
return (data->DSN);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline const char * ConfigLoginServer::getDatabaseUID()
|
||||
{
|
||||
return (data->databaseUID);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline const char * ConfigLoginServer::getDatabasePWD()
|
||||
{
|
||||
return (data->databasePWD);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline const char * ConfigLoginServer::getDatabaseProtocol()
|
||||
{
|
||||
return (data->databaseProtocol);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline int ConfigLoginServer::getMaxPlayersPerCluster()
|
||||
{
|
||||
return (data->maxPlayersPerCluster);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline int ConfigLoginServer::getMaxCharactersPerCluster()
|
||||
{
|
||||
return (data->maxCharactersPerCluster);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline int ConfigLoginServer::getMaxCharactersPerAccount()
|
||||
{
|
||||
return (data->maxCharactersPerAccount);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline const bool ConfigLoginServer::getEnableQueryProfile()
|
||||
{
|
||||
return (data->enableQueryProfile);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline const bool ConfigLoginServer::getVerboseQueryMode()
|
||||
{
|
||||
return (data->verboseQueryMode);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline const bool ConfigLoginServer::getLogWorkerThreads()
|
||||
{
|
||||
return data->logWorkerThreads;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline const bool ConfigLoginServer::getDevelopmentMode()
|
||||
{
|
||||
return (data->developmentMode);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline int ConfigLoginServer::getDatabaseThreads()
|
||||
{
|
||||
return (data->databaseThreads);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline bool ConfigLoginServer::getCompressClientNetworkTraffic()
|
||||
{
|
||||
return data->compressClientNetworkTraffic;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline uint16 ConfigLoginServer::getMetricsListenerPort()
|
||||
{
|
||||
return static_cast<uint16>(data->metricsListenerPort);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline const char *ConfigLoginServer::getSchemaOwner()
|
||||
{
|
||||
return data->schemaOwner;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline float ConfigLoginServer::getDefaultDBQueueUpdateTimeLimit()
|
||||
{
|
||||
return data->defaultDBQueueUpdateTimeLimit;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline const int ConfigLoginServer::getDisconnectSleepTime(void)
|
||||
{
|
||||
return data->disconnectSleepTime;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline const int ConfigLoginServer::getClusterGroup()
|
||||
{
|
||||
return data->clusterGroup;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline int ConfigLoginServer::getMaxSimultaneousPurgeAccounts()
|
||||
{
|
||||
return data->maxSimultaneousPurgeAccounts;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline int ConfigLoginServer::getPurgeSleepTime()
|
||||
{
|
||||
return data->purgeSleepTime;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline bool ConfigLoginServer::getEnableStructurePurge()
|
||||
{
|
||||
return data->enableStructurePurge;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline bool ConfigLoginServer::getEnableCharacterPurge()
|
||||
{
|
||||
return data->enableCharacterPurge;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline int ConfigLoginServer::getUpdatePurgeAccountListTime()
|
||||
{
|
||||
return data->updatePurgeAccountListTime;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline char const * ConfigLoginServer::getPurgeAccountSourceTable()
|
||||
{
|
||||
return data->purgeAccountSourceTable;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline const char * ConfigLoginServer::getAdminAccountDataTable()
|
||||
{
|
||||
return data->adminAccountDataTable;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline bool ConfigLoginServer::getAllowSkipTutorialToAll()
|
||||
{
|
||||
return data->allowSkipTutorialToAll;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline bool ConfigLoginServer::getInternalBypassOnlineLimit()
|
||||
{
|
||||
return data->internalBypassOnlineLimit;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline int ConfigLoginServer::getPopulationExtremelyHeavyThresholdPercent()
|
||||
{
|
||||
return data->populationExtremelyHeavyThresholdPercent;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline int ConfigLoginServer::getPopulationVeryHeavyThresholdPercent()
|
||||
{
|
||||
return data->populationVeryHeavyThresholdPercent;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline int ConfigLoginServer::getPopulationHeavyThresholdPercent()
|
||||
{
|
||||
return data->populationHeavyThresholdPercent;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline int ConfigLoginServer::getPopulationMediumThresholdPercent()
|
||||
{
|
||||
return data->populationMediumThresholdPercent;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline int ConfigLoginServer::getPopulationLightThresholdPercent()
|
||||
{
|
||||
return data->populationLightThresholdPercent;
|
||||
}
|
||||
|
||||
inline bool ConfigLoginServer::getRequireSecureLoginForCsTool()
|
||||
{
|
||||
return data->requireSecureLoginForCsTool;
|
||||
}
|
||||
|
||||
inline const int ConfigLoginServer::getCSToolPort()
|
||||
{
|
||||
return data->csToolPort;
|
||||
}
|
||||
// ======================================================================
|
||||
|
||||
#endif // _ConfigLoginServer_H
|
||||
@@ -0,0 +1,56 @@
|
||||
// ConsoleCommandParser.cpp
|
||||
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Justin Randall
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
#include "ConsoleCommandParser.h"
|
||||
#include "UnicodeUtils.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
namespace CommandNames
|
||||
{
|
||||
#define MAKE_COMMAND(a) const char * const a = #a
|
||||
#undef MAKE_COMMAND
|
||||
}
|
||||
|
||||
const CommandParser::CmdInfo cmds[] =
|
||||
{
|
||||
{"runState", 0, "", "Return the running state of the CentralServer. It should always return 'running'"},
|
||||
{"", 0, "", ""} // this must be last
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
ConsoleCommandParser::ConsoleCommandParser() :
|
||||
CommandParser ("", 0, "...", "console commands", this)
|
||||
{
|
||||
createDelegateCommands(cmds);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
ConsoleCommandParser::~ConsoleCommandParser()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
bool ConsoleCommandParser::performParsing(const NetworkId &, const StringVector_t & argv, const String_t &, String_t & result, const CommandParser *)
|
||||
{
|
||||
bool successResult = false;
|
||||
|
||||
if(isCommand(argv[0], "runState"))
|
||||
{
|
||||
result += Unicode::narrowToWide("running");
|
||||
successResult = true;
|
||||
}
|
||||
|
||||
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,73 @@
|
||||
// ConsoleCommandParserLoginServer.cpp
|
||||
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Justin Randall
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
#include "ConsoleCommandParserLoginServer.h"
|
||||
#include "LoginServer.h"
|
||||
#include "sharedNetworkMessages/ConsoleChannelMessages.h"
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
#include "UnicodeUtils.h"
|
||||
#include "sharedLog/Log.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
namespace CommandNames
|
||||
{
|
||||
#define MAKE_COMMAND(a) const char * const a = #a
|
||||
MAKE_COMMAND(login);
|
||||
#undef MAKE_COMMAND
|
||||
}
|
||||
|
||||
const CommandParser::CmdInfo cmds[] =
|
||||
{
|
||||
{"runState", 0, "", "Return the running state of the CentralServer. It should always return 'running'"},
|
||||
{"", 0, "", ""} // this must be last
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
ConsoleCommandParserLoginServer::ConsoleCommandParserLoginServer() :
|
||||
CommandParser ("login", 0, "...", "console commands", 0)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
ConsoleCommandParserLoginServer::~ConsoleCommandParserLoginServer()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
bool ConsoleCommandParserLoginServer::performParsing(const NetworkId & track, const StringVector_t & argv,const String_t & originalCommand,String_t & result,const CommandParser *)
|
||||
{
|
||||
bool successResult = false;
|
||||
|
||||
if(isCommand(argv[0], CommandNames::login))
|
||||
{
|
||||
if(argv.size() > 1)
|
||||
{
|
||||
std::string cmd = Unicode::wideToNarrow(argv[1]);
|
||||
if(cmd == "runState")
|
||||
{
|
||||
result += Unicode::narrowToWide("running");
|
||||
successResult = true;
|
||||
}
|
||||
else if(cmd == "exit")
|
||||
{
|
||||
result += Unicode::narrowToWide("exiting");
|
||||
LoginServer::getInstance().setDone(true);
|
||||
successResult = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return successResult;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
// ConsoleCommandParserGame.h
|
||||
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Justin Randall
|
||||
|
||||
#ifndef _INCLUDED_ConsoleCommandParserLoginServer_H
|
||||
#define _INCLUDED_ConsoleCommandParserLoginServer_H
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "sharedCommandParser/CommandParser.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
class ConsoleCommandParserLoginServer : public CommandParser
|
||||
{
|
||||
public:
|
||||
ConsoleCommandParserLoginServer();
|
||||
~ConsoleCommandParserLoginServer();
|
||||
virtual bool performParsing(const NetworkId & userId, const StringVector_t & argv,const String_t & originalCommand,String_t & result,const CommandParser * node);
|
||||
|
||||
private:
|
||||
ConsoleCommandParserLoginServer & operator = (const ConsoleCommandParserLoginServer & rhs);
|
||||
ConsoleCommandParserLoginServer(const ConsoleCommandParserLoginServer & source);
|
||||
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#endif // _INCLUDED_ConsoleCommandParserLoginServer_H
|
||||
@@ -0,0 +1,61 @@
|
||||
// ConsoleManager.cpp
|
||||
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Justin Randall
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
#include "ConsoleCommandParser.h"
|
||||
#include "ConsoleCommandParserLoginServer.h"
|
||||
#include "ConsoleManager.h"
|
||||
#include "UnicodeUtils.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
namespace ConsoleManagerNamespace
|
||||
{
|
||||
ConsoleCommandParser * s_consoleCommandParserRoot = NULL;
|
||||
}
|
||||
|
||||
using namespace ConsoleManagerNamespace;
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
ConsoleManager::ConsoleManager()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
ConsoleManager::~ConsoleManager()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void ConsoleManager::install()
|
||||
{
|
||||
s_consoleCommandParserRoot = new ConsoleCommandParser;
|
||||
IGNORE_RETURN(s_consoleCommandParserRoot->addSubCommand(new ConsoleCommandParserLoginServer));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void ConsoleManager::remove()
|
||||
{
|
||||
delete s_consoleCommandParserRoot;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
CommandParser::ErrorType ConsoleManager::processString(const std::string & msg, const int track, std::string & result)
|
||||
{
|
||||
CommandParser::ErrorType parseResult;
|
||||
Unicode::String wideResult;
|
||||
parseResult = s_consoleCommandParserRoot->parse(NetworkId(static_cast<NetworkId::NetworkIdType>(track)), Unicode::narrowToWide(msg), wideResult);
|
||||
result = Unicode::wideToNarrow(wideResult);
|
||||
return parseResult;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
@@ -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 "sharedCommandParser/CommandParser.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
class ConsoleManager
|
||||
{
|
||||
public:
|
||||
static void install();
|
||||
static void remove();
|
||||
static CommandParser::ErrorType 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,351 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// DatabaseConnection.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
#include "DatabaseConnection.h"
|
||||
|
||||
#include "ConfigLoginServer.h"
|
||||
#include "LoginServer.h"
|
||||
#include "TaskClaimRewards.h"
|
||||
#include "TaskChangeStationId.h"
|
||||
#include "TaskCreateCharacter.h"
|
||||
#include "TaskDeleteCharacter.h"
|
||||
#include "TaskEnableCharacter.h"
|
||||
#include "TaskGetAccountForPurge.h"
|
||||
#include "TaskGetAvatarList.h"
|
||||
#include "TaskGetCharactersForDelete.h"
|
||||
#include "TaskGetClusterList.h"
|
||||
#include "TaskGetValidationData.h"
|
||||
#include "TaskRegisterNewCluster.h"
|
||||
#include "TaskRenameCharacter.h"
|
||||
#include "TaskRestoreCharacter.h"
|
||||
#include "TaskSetPurgeStatus.h"
|
||||
#include "TaskToggleCharacterDisable.h"
|
||||
#include "TaskToggleCompletedTutorial.h"
|
||||
#include "TaskUpdatePurgeAccountList.h"
|
||||
#include "TaskUpgradeAccount.h"
|
||||
#include "serverNetworkMessages/AvatarList.h"
|
||||
#include "serverNetworkMessages/ClaimRewardsReplyMessage.h"
|
||||
#include "sharedDatabaseInterface/DbServer.h"
|
||||
#include "sharedDatabaseInterface/DbTaskQueue.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
DatabaseConnection::DatabaseConnection() :
|
||||
Singleton<DatabaseConnection>(),
|
||||
m_databaseServer(0),
|
||||
m_taskQueue(0)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
DatabaseConnection::~DatabaseConnection()
|
||||
{
|
||||
delete m_databaseServer;
|
||||
delete m_taskQueue;
|
||||
|
||||
m_databaseServer=0;
|
||||
m_taskQueue=0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DatabaseConnection::connect()
|
||||
{
|
||||
DEBUG_FATAL(m_databaseServer,("Called DatabaseConnection::connect() when already connected.\n"));
|
||||
|
||||
m_databaseServer = DB::Server::create(ConfigLoginServer::getDSN(),
|
||||
ConfigLoginServer::getDatabaseUID(),
|
||||
ConfigLoginServer::getDatabasePWD(),
|
||||
DB::Server::getProtocolByName(ConfigLoginServer::getDatabaseProtocol()),
|
||||
true);
|
||||
DB::Server::setDisconnectSleepTime(ConfigLoginServer::getDisconnectSleepTime());
|
||||
m_taskQueue=new DB::TaskQueue(static_cast<unsigned int>(ConfigLoginServer::getDatabaseThreads()),m_databaseServer,0);
|
||||
|
||||
if (ConfigLoginServer::getEnableQueryProfile())
|
||||
DB::Server::enableProfiling();
|
||||
|
||||
if (ConfigLoginServer::getVerboseQueryMode())
|
||||
DB::Server::enableVerboseMode();
|
||||
|
||||
DB::TaskQueue::enableWorkerThreadsLogging(ConfigLoginServer::getLogWorkerThreads());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DatabaseConnection::disconnect()
|
||||
{
|
||||
DEBUG_FATAL(!m_databaseServer,("Called DatabaseConnection::disconnect() when not connected.\n"));
|
||||
|
||||
if (ConfigLoginServer::getEnableQueryProfile())
|
||||
{
|
||||
DB::Server::debugOutputProfile();
|
||||
DB::Server::endProfiling();
|
||||
}
|
||||
|
||||
delete m_taskQueue;
|
||||
delete m_databaseServer;
|
||||
|
||||
m_taskQueue=0;
|
||||
m_databaseServer=0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DatabaseConnection::requestAvatarListForAccount(StationId stationId, const TransferCharacterData * characterData)
|
||||
{
|
||||
NOT_NULL(m_taskQueue);
|
||||
m_taskQueue->asyncRequest(new TaskGetAvatarList(stationId, ConfigLoginServer::getClusterGroup(), characterData));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DatabaseConnection::onAvatarListRetrieved(StationId stationId, int stationIdNumberJediSlot, const AvatarList & avatars, TransferCharacterData * const transferData) const
|
||||
{
|
||||
LoginServer::getInstance().sendAvatarList(stationId, stationIdNumberJediSlot, avatars, transferData);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Retreive the list of all known clusters from the database.
|
||||
* This list is in the database so that we know about clusters
|
||||
* that aren't currently running, for character lists, etc.
|
||||
*/
|
||||
|
||||
void DatabaseConnection::requestClusterList()
|
||||
{
|
||||
NOT_NULL(m_taskQueue);
|
||||
m_taskQueue->asyncRequest(new TaskGetClusterList(ConfigLoginServer::getClusterGroup()));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Called when a previously unknown cluster connects. Adds the cluster
|
||||
* to the database and assigns it the next available cluster ID.
|
||||
*/
|
||||
|
||||
void DatabaseConnection::registerNewCluster(const std::string &clusterName, const std::string &remoteAddress)
|
||||
{
|
||||
NOT_NULL(m_taskQueue);
|
||||
m_taskQueue->asyncRequest(new TaskRegisterNewCluster(clusterName, remoteAddress));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DatabaseConnection::update()
|
||||
{
|
||||
NOT_NULL(m_taskQueue);
|
||||
m_taskQueue->update(ConfigLoginServer::getDefaultDBQueueUpdateTimeLimit());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DatabaseConnection::getAccountValidationData(StationId stationId, uint32 clusterId, unsigned int track, uint32 subscriptionBits)
|
||||
{
|
||||
NOT_NULL(m_taskQueue);
|
||||
m_taskQueue->asyncRequest(new TaskGetValidationData(stationId, ConfigLoginServer::getClusterGroup(), clusterId, track, subscriptionBits));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DatabaseConnection::getAccountValidationData(const TransferRequestMoveValidation & request, uint32 clusterId)
|
||||
{
|
||||
NOT_NULL(m_taskQueue);
|
||||
m_taskQueue->asyncRequest(new TaskGetValidationData(request, ConfigLoginServer::getClusterGroup(), clusterId));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DatabaseConnection::deleteCharacter(uint32 clusterId, const NetworkId &characterId, StationId stationId)
|
||||
{
|
||||
NOT_NULL(m_taskQueue);
|
||||
m_taskQueue->asyncRequest(new TaskDeleteCharacter(clusterId,characterId,stationId));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DatabaseConnection::deleteAllCharacters(StationId stationId)
|
||||
{
|
||||
NON_NULL(m_taskQueue)->asyncRequest(new TaskGetCharactersForDelete(stationId,ConfigLoginServer::getClusterGroup()));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DatabaseConnection::renameCharacter(uint32 clusterId, const NetworkId &characterId, const Unicode::String &newName, const TransferCharacterData * requestData)
|
||||
{
|
||||
NOT_NULL(m_taskQueue);
|
||||
m_taskQueue->asyncRequest(new TaskRenameCharacter(clusterId, characterId, newName, requestData));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DatabaseConnection::requestAvatarListAccountTransfer(const TransferAccountData * requestData)
|
||||
{
|
||||
NOT_NULL(m_taskQueue);
|
||||
m_taskQueue->asyncRequest(new TaskGetAvatarList(ConfigLoginServer::getClusterGroup(), requestData));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DatabaseConnection::onAvatarListRetrievedAccountTransfer(const AvatarList &avatars, TransferAccountData * transferAccountData)
|
||||
{
|
||||
NOT_NULL(m_taskQueue);
|
||||
LoginServer::getInstance().performAccountTransfer(avatars, transferAccountData);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DatabaseConnection::changeStationId(StationId sourceStationId, StationId destinationStationId, const TransferAccountData * const transferAccountData)
|
||||
{
|
||||
NOT_NULL(m_taskQueue);
|
||||
m_taskQueue->asyncRequest(new TaskChangeStationId(sourceStationId, destinationStationId, transferAccountData));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DatabaseConnection::createCharacter(uint32 clusterId, StationId stationId, const Unicode::String &characterName, const NetworkId &characterObjectId, int templateId, bool jedi)
|
||||
{
|
||||
NOT_NULL(m_taskQueue);
|
||||
m_taskQueue->asyncRequest(new TaskCreateCharacter(clusterId, stationId, characterName, characterObjectId, templateId, jedi));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DatabaseConnection::restoreCharacter(uint32 clusterId, const std::string &whoRequested, StationId stationId, const Unicode::String &characterName, const NetworkId &characterObjectId, int templateId, bool jedi)
|
||||
{
|
||||
NOT_NULL(m_taskQueue);
|
||||
m_taskQueue->asyncRequest(new TaskRestoreCharacter(clusterId, whoRequested, stationId, characterName, characterObjectId, templateId, jedi));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DatabaseConnection::enableCharacter(StationId stationId, const NetworkId &characterId, const std::string &whoRequested, bool enabled, uint32 clusterId)
|
||||
{
|
||||
NOT_NULL(m_taskQueue);
|
||||
m_taskQueue->asyncRequest(new TaskEnableCharacter(stationId, characterId, whoRequested, enabled, clusterId));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DatabaseConnection::upgradeAccount(LoginUpgradeAccountMessage *msg, uint32 clusterId)
|
||||
{
|
||||
NOT_NULL(m_taskQueue);
|
||||
m_taskQueue->asyncRequest(new TaskUpgradeAccount(msg,clusterId));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DatabaseConnection::toggleDisableCharacter(uint32 clusterId, const NetworkId &characterId, StationId stationId, bool enabled)
|
||||
{
|
||||
NOT_NULL(m_taskQueue);
|
||||
m_taskQueue->asyncRequest(new TaskToggleCharacterDisable(clusterId,characterId,stationId,enabled));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DatabaseConnection::toggleCompletedTutorial(StationId stationId, bool newValue)
|
||||
{
|
||||
NOT_NULL(m_taskQueue);
|
||||
m_taskQueue->asyncRequest(new TaskToggleCompletedTutorial(stationId, newValue));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const std::string DatabaseConnection::getSchemaQualifier() const
|
||||
{
|
||||
if (ConfigLoginServer::getSchemaOwner()[0]!='\0')
|
||||
return std::string(ConfigLoginServer::getSchemaOwner())+'.';
|
||||
else
|
||||
return std::string();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DatabaseConnection::claimRewards(uint32 clusterId, uint32 gameServerId, StationId stationId, NetworkId const & playerId, std::string const & rewardEvent, bool consumeEvent, std::string const & rewardItem, bool consumeItem, uint32 accountFeatureId, bool consumeAccountFeatureId, int previousAccountFeatureIdCount, int currentAccountFeatureIdCount)
|
||||
{
|
||||
NOT_NULL(m_taskQueue);
|
||||
|
||||
if (consumeEvent || consumeItem || ((accountFeatureId > 0) && consumeAccountFeatureId))
|
||||
{
|
||||
m_taskQueue->asyncRequest(new TaskClaimRewards(clusterId, gameServerId, stationId, playerId, rewardEvent, consumeEvent, rewardItem, consumeItem, accountFeatureId, consumeAccountFeatureId, previousAccountFeatureIdCount, currentAccountFeatureIdCount));
|
||||
}
|
||||
else
|
||||
{
|
||||
ClaimRewardsReplyMessage const msg(gameServerId, stationId, playerId, rewardEvent, rewardItem, accountFeatureId, consumeAccountFeatureId, previousAccountFeatureIdCount, currentAccountFeatureIdCount, true);
|
||||
LoginServer::getInstance().sendToCluster(clusterId, msg);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DatabaseConnection::getAccountForPurge(int purgePhase)
|
||||
{
|
||||
NOT_NULL(m_taskQueue);
|
||||
m_taskQueue->asyncRequest(new TaskGetAccountForPurge(purgePhase));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DatabaseConnection::setPurgeStatusAndRelease(StationId account, int newPurgePhase)
|
||||
{
|
||||
NOT_NULL(m_taskQueue);
|
||||
m_taskQueue->asyncRequest(new TaskSetPurgeStatus(account, newPurgePhase));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DatabaseConnection::updatePurgeAccountList()
|
||||
{
|
||||
FATAL(ConfigLoginServer::getDatabaseThreads() < 2,("Attempted to run updatePurgeAccountList with only 1 worker thread, which would mean logins would be blocked while the process is running. Either disable updating the purge account list, or add more worker threads."));
|
||||
NOT_NULL(m_taskQueue);
|
||||
m_taskQueue->asyncRequest(new TaskUpdatePurgeAccountList);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DatabaseConnection::occupyUnlockedSlot(uint32 clusterId, StationId stationId, NetworkId const & characterId, uint32 replyGameServerId)
|
||||
{
|
||||
NOT_NULL(m_taskQueue);
|
||||
m_taskQueue->asyncRequest(new TaskOccupyUnlockedSlot(ConfigLoginServer::getClusterGroup(), clusterId, stationId, characterId, replyGameServerId));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DatabaseConnection::vacateUnlockedSlot(uint32 clusterId, StationId stationId, NetworkId const & characterId, uint32 replyGameServerId)
|
||||
{
|
||||
NOT_NULL(m_taskQueue);
|
||||
m_taskQueue->asyncRequest(new TaskVacateUnlockedSlot(ConfigLoginServer::getClusterGroup(), clusterId, stationId, characterId, replyGameServerId));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DatabaseConnection::swapUnlockedSlot(uint32 clusterId, StationId stationId, NetworkId const & sourceCharacterId, NetworkId const & targetCharacterId, uint32 replyGameServerId)
|
||||
{
|
||||
NOT_NULL(m_taskQueue);
|
||||
m_taskQueue->asyncRequest(new TaskSwapUnlockedSlot(ConfigLoginServer::getClusterGroup(), clusterId, stationId, sourceCharacterId, targetCharacterId, replyGameServerId));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DatabaseConnection::featureIdTransactionRequest(uint32 clusterId, StationId stationId, NetworkId const & characterId, uint32 replyGameServerId)
|
||||
{
|
||||
NOT_NULL(m_taskQueue);
|
||||
m_taskQueue->asyncRequest(new TaskFeatureIdTransactionRequest(clusterId, stationId, characterId, replyGameServerId));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DatabaseConnection::featureIdTransactionSyncUpdate(uint32 clusterId, StationId stationId, NetworkId const & characterId, std::string const & itemId, int adjustment)
|
||||
{
|
||||
NOT_NULL(m_taskQueue);
|
||||
m_taskQueue->asyncRequest(new TaskFeatureIdTransactionSyncUpdate(clusterId, stationId, characterId, itemId, adjustment));
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,80 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// DatabaseConnection.h
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_DatabaseConnection_H
|
||||
#define INCLUDED_DatabaseConnection_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "Singleton/Singleton.h"
|
||||
#include "serverNetworkMessages/AvatarList.h"
|
||||
#include "sharedFoundation/NetworkId.h"
|
||||
#include "sharedFoundation/StationId.h"
|
||||
|
||||
namespace DB
|
||||
{
|
||||
class Server;
|
||||
class TaskQueue;
|
||||
}
|
||||
|
||||
class LoginUpgradeAccountMessage;
|
||||
class TransferAccountData;
|
||||
class TransferCharacterData;
|
||||
class TransferRequestMoveValidation;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
/**
|
||||
* A class to manage the LoginServer's connection to the database.
|
||||
*/
|
||||
|
||||
class DatabaseConnection : public Singleton<DatabaseConnection>
|
||||
{
|
||||
public:
|
||||
DatabaseConnection();
|
||||
~DatabaseConnection();
|
||||
|
||||
void connect ();
|
||||
void disconnect ();
|
||||
void requestAvatarListForAccount (StationId stationId, const TransferCharacterData *);
|
||||
void requestClusterList ();
|
||||
void registerNewCluster (const std::string &clusterName, const std::string &remoteAddress);
|
||||
void onAvatarListRetrieved (StationId stationId, int stationIdNumberJediSlot, const AvatarList &avatars, TransferCharacterData * const transferCharacterData) const;
|
||||
void update ();
|
||||
void getAccountValidationData (StationId stationId, uint32 clusterId, unsigned int track, uint32 subscriptionBits);
|
||||
void getAccountValidationData (const TransferRequestMoveValidation & request, uint32 clusterId);
|
||||
void deleteCharacter (uint32 clusterId, const NetworkId &characterId, StationId stationId);
|
||||
void deleteAllCharacters (StationId stationId);
|
||||
void renameCharacter (uint32 clusterId, const NetworkId &characterId, const Unicode::String &newName, const TransferCharacterData * requestData);
|
||||
void requestAvatarListAccountTransfer (const TransferAccountData * requestData);
|
||||
void onAvatarListRetrievedAccountTransfer (const AvatarList &avatars, TransferAccountData * transferAccountData);
|
||||
void changeStationId (StationId sourceStationId, StationId destinationStationId, const TransferAccountData * const transferAccountData);
|
||||
void createCharacter (uint32 clusterId, StationId stationId, const Unicode::String &characterName, const NetworkId &characterObjectId, int templateId, bool jedi);
|
||||
void restoreCharacter (uint32 clusterId, const std::string &whoRequested, StationId stationId, const Unicode::String &characterName, const NetworkId &characterObjectId, int templateId, bool jedi);
|
||||
void enableCharacter (StationId stationId, const NetworkId &characterId, const std::string &whoRequested, bool enabled, uint32 clusterId);
|
||||
void upgradeAccount (LoginUpgradeAccountMessage *msg, uint32 clusterId);
|
||||
void toggleDisableCharacter (uint32 clusterId, const NetworkId &characterId, StationId stationId, bool enabled);
|
||||
void toggleCompletedTutorial (StationId stationId, bool newValue);
|
||||
const std::string getSchemaQualifier() const;
|
||||
void claimRewards (uint32 clusterId, uint32 gameServerId, StationId stationId, NetworkId const & playerId, std::string const & rewardEvent, bool consumeEvent, std::string const & rewardItem, bool consumeItem, uint32 accountFeatureId, bool consumeAccountFeatureId, int previousAccountFeatureIdCount, int currentAccountFeatureIdCount);
|
||||
void getAccountForPurge (int purgePhase);
|
||||
void setPurgeStatusAndRelease (StationId account, int newPurgePhase);
|
||||
void updatePurgeAccountList ();
|
||||
void occupyUnlockedSlot (uint32 clusterId, StationId stationId, NetworkId const & characterId, uint32 replyGameServerId);
|
||||
void vacateUnlockedSlot (uint32 clusterId, StationId stationId, NetworkId const & characterId, uint32 replyGameServerId);
|
||||
void swapUnlockedSlot (uint32 clusterId, StationId stationId, NetworkId const & sourceCharacterId, NetworkId const & targetCharacterId, uint32 replyGameServerId);
|
||||
void featureIdTransactionRequest (uint32 clusterId, StationId stationId, NetworkId const & characterId, uint32 replyGameServerId);
|
||||
void featureIdTransactionSyncUpdate(uint32 clusterId, StationId stationId, NetworkId const & characterId, std::string const & itemId, int adjustment);
|
||||
|
||||
private:
|
||||
DB::Server *m_databaseServer;
|
||||
DB::TaskQueue *m_taskQueue;
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,24 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// FirstLoginServer.h
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_FirstLoginServer_H
|
||||
#define INCLUDED_FirstLoginServer_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#pragma warning ( disable : 4702 ) // unreachable code (STL vector)
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
#include "Archive/ByteStream.h"
|
||||
#include "serverUtility/ServerConnection.h"
|
||||
#include "sharedDebug/FirstSharedDebug.h"
|
||||
#include "sharedMemoryManager/FirstSharedMemoryManager.h"
|
||||
#include "LoginServer.h"
|
||||
#include "sharedNetworkMessages/GameNetworkMessage.h"
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,184 @@
|
||||
// LoginServer.h
|
||||
// copyright 2000 Verant Interactive
|
||||
// Author: Justin Randall
|
||||
|
||||
#ifndef _LoginServer_H
|
||||
#define _LoginServer_H
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "Singleton/Singleton.h"
|
||||
#include "serverNetworkMessages/AvatarList.h"
|
||||
#include "sharedFoundation/StationId.h"
|
||||
#include "sharedMessageDispatch/Receiver.h"
|
||||
#include "sharedNetwork/Service.h"
|
||||
#include <hash_map>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "serverKeyShare/KeyShare.h"
|
||||
|
||||
class CentralServerConnection;
|
||||
class ClientConnection;
|
||||
class CMonitorAPI;
|
||||
class DeleteCharacterMessage;
|
||||
class GameNetworkMessage;
|
||||
class KeyServer;
|
||||
class ServerConnection;
|
||||
class Service;
|
||||
class SessionApiClient;
|
||||
class TransferAccountData;
|
||||
class TransferCharacterData;
|
||||
class TransferRequestMoveValidation;
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
class LoginServer : public Singleton<LoginServer>, public MessageDispatch::Receiver
|
||||
{
|
||||
public:
|
||||
|
||||
~LoginServer ();
|
||||
int addClient (ClientConnection & client);
|
||||
ClientConnection* getValidatedClient (const StationId& suid);
|
||||
ClientConnection* getUnvalidatedClient (int clientId);
|
||||
void removeClient (int clientId);
|
||||
|
||||
const std::hash_map<std::string, const CentralServerConnection *> & getCentralServerMap_hide() const;
|
||||
|
||||
bool deleteCharacter (uint32 clusterId, NetworkId const & characterId, StationId suid);
|
||||
|
||||
const KeyShare::Key & getCurrentKey (void) const;
|
||||
SessionApiClient* getSessionApiClient ();
|
||||
KeyShare::Token makeToken (const unsigned char * data, const uint32 dataLen) const;
|
||||
void pushAllKeys (CentralServerConnection * targetCentralServer) const;
|
||||
void pushKeyToAllServers (void);
|
||||
void receiveMessage (const MessageDispatch::Emitter & source, const MessageDispatch::MessageBase & message);
|
||||
|
||||
static void run (void);
|
||||
void onValidateClient (StationId id, const std::string & username, ClientConnection*,bool, const char*, uint32 gameBits, uint32 subscriptionBits);
|
||||
|
||||
void sendAvatarList (const StationId& stationId, int stationIdNumberJediSlot, const AvatarList &avatars, TransferCharacterData * const);
|
||||
|
||||
void updateClusterData (uint32 clusterId, const std::string &clusterName, const std::string &address, const uint16 port, bool secret, bool locked, bool notRecommended, int maxCharactersPerAccount, int onlinePlayerLimit, int onlineFreeTrialLimit, bool freeTrialCanCreateChar, int onlineTutorialLimit);
|
||||
void onClusterRegistered (uint32 clusterId, const std::string &clusterName);
|
||||
void validateAccount (const StationId& stationId, uint32 clusterId, uint32 subscriptionBits, bool canCreateRegular, bool canCreateJedi, bool canSkipTutorial, unsigned int track, std::vector<std::pair<NetworkId, std::string> > const & consumedRewardEvents, std::vector<std::pair<NetworkId, std::string> > const & claimedRewardItems);
|
||||
void validateAccountForTransfer(const TransferRequestMoveValidation & request, uint32 clusterId, uint32 sourceCharacterTemplateId, bool canCreateRegular, bool canCreateJedi);
|
||||
void sendToCluster (uint32 clusterId, const GameNetworkMessage &message);
|
||||
void sendToAllClusters (GameNetworkMessage const & message, Connection const * excludeCentralConnection = NULL, uint32 excludeClusterId = 0, char const * excludeClusterName = NULL);
|
||||
bool areAllClustersUp () const;
|
||||
void getClusterIds (stdvector<uint32>::fwd result);
|
||||
void performAccountTransfer (const AvatarList &avatars, TransferAccountData * transferAccountData);
|
||||
void setDone (const bool isDone);
|
||||
|
||||
void setClusterInfoByName( const std::string &name, const std::string &branch, int changelist, const std::string &networkVersion );
|
||||
void sendExtendedClusterInfo( ClientConnection &client ) const;
|
||||
|
||||
void getAllClusterNamesAndIDs( std::map< std::string, uint32 > &results ) const;
|
||||
uint32 getClusterIDByName( const std::string &sName );
|
||||
const std::string & getClusterNameById( uint32 clusterId );
|
||||
|
||||
struct ConnectionServerEntry
|
||||
{
|
||||
std::string clientServiceAddress;
|
||||
uint16 clientServicePortPrivate;
|
||||
uint16 clientServicePortPublic;
|
||||
int id;
|
||||
uint16 pingPort;
|
||||
int numClients;
|
||||
|
||||
bool operator==(const ConnectionServerEntry &rhs) const;
|
||||
};
|
||||
|
||||
|
||||
protected:
|
||||
friend class Singleton<LoginServer>;
|
||||
LoginServer ();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Data structure to track a cluster.
|
||||
* This may be only partly filled in if the cluster exists
|
||||
* but isn't connected.
|
||||
*/
|
||||
struct ClusterListEntry
|
||||
{
|
||||
uint32 m_clusterId;
|
||||
std::string m_clusterName;
|
||||
CentralServerConnection * m_centralServerConnection;
|
||||
std::vector<ConnectionServerEntry> m_connectionServers;
|
||||
int m_numPlayers;
|
||||
int m_numFreeTrialPlayers;
|
||||
int m_numTutorialPlayers;
|
||||
int m_maxCharacters;
|
||||
int m_maxCharactersPerAccount;
|
||||
int m_onlinePlayerLimit;
|
||||
int m_onlineFreeTrialLimit;
|
||||
int m_onlineTutorialLimit;
|
||||
bool m_freeTrialCanCreateChar;
|
||||
int m_timeZone;
|
||||
bool m_connected;
|
||||
std::string m_address;
|
||||
uint16 m_port;
|
||||
bool m_allowReconnect;
|
||||
bool m_secret;
|
||||
bool m_readyForPlayers;
|
||||
bool m_locked;
|
||||
bool m_notRecommendedDatabase;
|
||||
bool m_notRecommendedCentral;
|
||||
std::string m_branch;
|
||||
int m_changelist;
|
||||
std::string m_networkVersion;
|
||||
|
||||
ClusterListEntry ();
|
||||
ClusterListEntry (const ClusterListEntry &rhs);
|
||||
ClusterListEntry & operator= (const ClusterListEntry &rhs);
|
||||
};
|
||||
|
||||
typedef std::vector<ClusterListEntry*> ClusterListType;
|
||||
typedef std::map<int, ClientConnection *> ActiveClientsType;
|
||||
|
||||
private:
|
||||
void installSessionValidation();
|
||||
ClusterListEntry * findClusterById (uint32 clusterId);
|
||||
ClusterListEntry * findClusterByName (const std::string & clusterName);
|
||||
ClusterListEntry * findClusterByConnection (const CentralServerConnection *connection);
|
||||
void sendClusterStatus (ClientConnection &conn) const;
|
||||
void sendClusterStatusToAll () const;
|
||||
void refreshConnections ();
|
||||
ClusterListEntry * addCluster (const std::string &clusterName);
|
||||
void disconnectCluster (ClusterListEntry &cle, bool forceDisconnect, bool reconnect);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
bool done;
|
||||
Service * m_centralService;
|
||||
Service * clientService;
|
||||
Service * pingService;
|
||||
Service * m_CSService;
|
||||
KeyServer * keyServer;
|
||||
ActiveClientsType m_clientMap;
|
||||
ClusterListType m_clusterList;
|
||||
SessionApiClient* m_sessionApiClient;
|
||||
std::map<StationId, ClientConnection*> m_validatedClientMap;
|
||||
bool m_clusterStatusChanged; // true if any cluster has changed status and the list should be resent to all clients
|
||||
CMonitorAPI * m_soeMonitor;
|
||||
|
||||
|
||||
private:
|
||||
LoginServer (const LoginServer & source);
|
||||
LoginServer & operator=(const LoginServer & rhs);
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
inline bool LoginServer::ConnectionServerEntry::operator==(const ConnectionServerEntry &rhs) const
|
||||
{
|
||||
return (id == rhs.id);
|
||||
}
|
||||
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif // _LoginServer_H
|
||||
@@ -0,0 +1,48 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// LoginServerRemoteDebugConnection.cpp
|
||||
// copyright 2001, Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
#include "LoginServerRemoteDebugConnection.h"
|
||||
#include "sharedDebug/RemoteDebug_inner.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
LoginServerRemoteDebugConnection::LoginServerRemoteDebugConnection(UdpConnectionMT * u, TcpClient * t) :
|
||||
ServerConnection(u, t)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
LoginServerRemoteDebugConnection::~LoginServerRemoteDebugConnection(void)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void LoginServerRemoteDebugConnection::onConnectionClosed()
|
||||
{
|
||||
RemoteDebugServer::close();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void LoginServerRemoteDebugConnection::onConnectionOpened()
|
||||
{
|
||||
RemoteDebugServer::isReady();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void LoginServerRemoteDebugConnection::onReceive(const Archive::ByteStream & message)
|
||||
{
|
||||
Archive::ReadIterator ri = message.begin();
|
||||
GameNetworkMessage m(ri);
|
||||
emitMessage(m);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@@ -0,0 +1,33 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// LoginServerRemoteDebugConnection.h
|
||||
// copyright 2001, Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef _LoginServerRemoteDebugConnection_H
|
||||
#define _LoginServerRemoteDebugConnection_H
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "serverUtility/ServerConnection.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
class LoginServerRemoteDebugConnection : public ServerConnection
|
||||
{
|
||||
public:
|
||||
LoginServerRemoteDebugConnection(UdpConnectionMT *, TcpClient *);
|
||||
virtual ~LoginServerRemoteDebugConnection();
|
||||
void onConnectionClosed ();
|
||||
void onConnectionOpened ();
|
||||
void onReceive (const Archive::ByteStream & message);
|
||||
|
||||
private:
|
||||
LoginServerRemoteDebugConnection(const LoginServerRemoteDebugConnection & source);
|
||||
LoginServerRemoteDebugConnection & operator = (const LoginServerRemoteDebugConnection & rhs);
|
||||
}; //lint !e1712 default constructor not defined
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#endif // _ServerConnectionHandler_H
|
||||
@@ -0,0 +1,96 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// LoginServerRemoteDebugSetup.cpp
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
#include "Archive/ByteStream.h"
|
||||
#include "sharedFoundation/ConfigSharedFoundation.h"
|
||||
#include "LoginServerRemoteDebugSetup.h"
|
||||
#include "LoginServerRemoteDebugConnection.h"
|
||||
#include "sharedDebug/RemoteDebug_inner.h"
|
||||
#include "sharedNetwork/Connection.h"
|
||||
#include "sharedNetwork/NetworkSetupData.h"
|
||||
#include "sharedNetwork/Service.h"
|
||||
|
||||
//static definitions
|
||||
//Network::Address *LoginServerRemoteDebugSetup::ms_remoteDebugService;
|
||||
bool LoginServerRemoteDebugSetup::ms_installed;
|
||||
unsigned int LoginServerRemoteDebugSetup::ms_remoteDebugToolChannelID;
|
||||
Connection *LoginServerRemoteDebugSetup::ms_connection;
|
||||
Service *LoginServerRemoteDebugSetup::ms_remoteDebugService;
|
||||
|
||||
void LoginServerRemoteDebugSetup::install(void)
|
||||
{
|
||||
if (ms_installed)
|
||||
{
|
||||
//TODO bad
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ConfigSharedFoundation::getUseRemoteDebug())
|
||||
return;
|
||||
|
||||
NetworkSetupData setup;
|
||||
setup.port = 4446;
|
||||
setup.maxConnections = 16;
|
||||
ms_remoteDebugService = new Service(ConnectionAllocator<LoginServerRemoteDebugConnection>(), setup);
|
||||
|
||||
RemoteDebugServer::install(remove, open, close, send, 0);//, receive);
|
||||
ms_installed = true;
|
||||
}
|
||||
|
||||
void LoginServerRemoteDebugSetup::remove(void)
|
||||
{
|
||||
if (!ms_installed)
|
||||
{
|
||||
//TODO bad
|
||||
return;
|
||||
}
|
||||
delete ms_remoteDebugService;
|
||||
|
||||
RemoteDebugServer::remove();
|
||||
ms_installed = false;
|
||||
}
|
||||
|
||||
void LoginServerRemoteDebugSetup::open(const char *, uint16)
|
||||
{
|
||||
DEBUG_WARNING(true, ("not implemented! Fix ME!"));
|
||||
/*
|
||||
//TODO config file this?
|
||||
//attempt to auto-connect to a localhost client app (if it's auto-listening)
|
||||
if (ms_remoteDebugService->getHostPort())
|
||||
Network::connect(ms_connection, "127.0.0.1", port);
|
||||
else
|
||||
{
|
||||
//TODO bad
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void LoginServerRemoteDebugSetup::close(void)
|
||||
{
|
||||
if (!ms_installed)
|
||||
{
|
||||
//TODO bad
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void LoginServerRemoteDebugSetup::send(void *, uint32)
|
||||
{
|
||||
DEBUG_WARNING(true, ("not implemented! Fix ME!"));
|
||||
/*
|
||||
if (!ms_installed)
|
||||
{
|
||||
//TODO bad
|
||||
return;
|
||||
}
|
||||
//always send on VNL channel 0, send the buffer, it's length, and reliable=1
|
||||
NOT_NULL(ms_connection);
|
||||
static Archive::ByteStream bs(reinterpret_cast<unsigned char *>(buffer), bufferLen);
|
||||
ms_connection->send(bs, true);
|
||||
*/
|
||||
}//lint !e818 // parameter bufffer could be declared as pointint to const (but the function prototype beyond this class cannot)
|
||||
@@ -0,0 +1,32 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// LoginServerRemoteDebugSetup.h
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
class Connection;
|
||||
class LoginServerRemoteDebugConnection;
|
||||
class Service;
|
||||
|
||||
class LoginServerRemoteDebugSetup
|
||||
{
|
||||
friend class LoginServerRemoteDebugConnection;
|
||||
|
||||
public:
|
||||
static void install(void);
|
||||
static void remove(void);
|
||||
|
||||
private:
|
||||
///The client-specific network service data instance
|
||||
///true if system has been installed, false otherwise
|
||||
static bool ms_installed;
|
||||
|
||||
static unsigned int ms_remoteDebugToolChannelID;
|
||||
static Connection * ms_connection;
|
||||
static Service * ms_remoteDebugService;
|
||||
static void open(const char *server, uint16 port);
|
||||
static void close(void);
|
||||
static void send(void *buffer, uint32 bufferLen);
|
||||
static void receive(void *buffer, uint32 bufferLen);
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
// PingConnection.cpp
|
||||
// Copyright 2000-01, Sony Online Entertainment Inc., all rights reserved.
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
#include "CentralServerConnection.h"
|
||||
#include "LoginServer.h"
|
||||
#include "PingConnection.h"
|
||||
#include "Archive/ByteStream.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
PingConnection::PingConnection(UdpConnectionMT * u, TcpClient * t) :
|
||||
ServerConnection(u, t)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
PingConnection::~PingConnection()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void PingConnection::onConnectionOpened()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void PingConnection::onReceive(const Archive::ByteStream &message )
|
||||
{
|
||||
Archive::ReadIterator r(message);
|
||||
GameNetworkMessage g(r);
|
||||
|
||||
if (g.isType("LoginPingMessage"))
|
||||
{
|
||||
send(g, true);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
// PingConnection.h
|
||||
// Copyright 2000-01, Sony Online Entertainment Inc., all rights reserved.
|
||||
|
||||
#ifndef _INCLUDED_PingConnection_H
|
||||
#define _INCLUDED_PingConnection_H
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "serverUtility/ServerConnection.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
class PingConnection : public ServerConnection
|
||||
{
|
||||
public:
|
||||
PingConnection(UdpConnectionMT *, TcpClient *);
|
||||
~PingConnection();
|
||||
void onConnectionOpened();
|
||||
void onReceive(const Archive::ByteStream & message);
|
||||
|
||||
private:
|
||||
PingConnection & operator = (const PingConnection & rhs);
|
||||
PingConnection(const PingConnection & source);
|
||||
|
||||
};//lint !e1712 default constructor not defined
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#endif // _INCLUDED_PingConnection_H
|
||||
@@ -0,0 +1,385 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// PurgeManager.cpp
|
||||
// copyright (c) 2005 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
#include "PurgeManager.h"
|
||||
|
||||
#include "ConfigLoginServer.h"
|
||||
#include "DatabaseConnection.h"
|
||||
#include "LoginServer.h"
|
||||
#include "SessionApiClient.h"
|
||||
#include "sharedFoundation/Timer.h"
|
||||
#include "sharedLog/Log.h"
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
namespace PurgeManagerNamespace
|
||||
{
|
||||
enum PurgePhase
|
||||
{
|
||||
ppNoPurge, ppNotWarned, ppStructureWarningSent, ppStructuresPurged, ppCharacterWarningSent, ppPurged
|
||||
};
|
||||
bool m_gettingAccount=false;
|
||||
|
||||
void removeFromPurgeList(StationId account);
|
||||
void releaseAccount(StationId account);
|
||||
PurgePhase getNextPurgePhase(PurgePhase previousPurgePhase);
|
||||
|
||||
class PurgeRecord
|
||||
{
|
||||
public:
|
||||
PurgeRecord(StationId stationId, PurgePhase purgePhase);
|
||||
StationId getStationId() const;
|
||||
PurgePhase getPurgePhase() const;
|
||||
void grabClusterList();
|
||||
bool hasCluster(uint32 clusterId) const;
|
||||
void removeCluster(uint32 clusterId);
|
||||
bool hasClusters() const;
|
||||
void advancePurgePhase();
|
||||
|
||||
private:
|
||||
StationId m_stationId;
|
||||
PurgePhase m_purgePhase;
|
||||
std::set<uint32> m_clusters;
|
||||
};
|
||||
|
||||
typedef std::map<StationId, PurgeRecord> PurgeRecordsType;
|
||||
|
||||
PurgeRecordsType m_purgeRecords;
|
||||
PurgePhase m_currentPurgePhase = ppNotWarned;
|
||||
}
|
||||
|
||||
using namespace PurgeManagerNamespace;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
/**
|
||||
* The PurgeManager picks a purge phase and finds accounts for that phase.
|
||||
* If no accounts can be found for that phase, it moves on to the next phase.
|
||||
* Once it has tried all purge phases without finding any accounts, it will
|
||||
* sleep for a while before starting again.
|
||||
*/
|
||||
void PurgeManager::update(float time)
|
||||
{
|
||||
if (!(ConfigLoginServer::getEnableStructurePurge())||(ConfigLoginServer::getEnableCharacterPurge()))
|
||||
return;
|
||||
|
||||
static Timer retryAccountsTimer(ConfigLoginServer::getPurgeSleepTime());
|
||||
|
||||
if ((m_currentPurgePhase==ppPurged) || // last purge phase, so wait a while then start over
|
||||
((m_currentPurgePhase>=ppStructuresPurged) && (!ConfigLoginServer::getEnableCharacterPurge())))
|
||||
{
|
||||
if (retryAccountsTimer.updateZero(time))
|
||||
m_currentPurgePhase=ppNotWarned;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LoginServer::getInstance().areAllClustersUp() && (!m_gettingAccount && m_purgeRecords.size() < static_cast<size_t>(ConfigLoginServer::getMaxSimultaneousPurgeAccounts())))
|
||||
{
|
||||
m_gettingAccount=true;
|
||||
DatabaseConnection::getInstance().getAccountForPurge(m_currentPurgePhase);
|
||||
}
|
||||
}
|
||||
|
||||
if (ConfigLoginServer::getUpdatePurgeAccountListTime() != 0)
|
||||
{
|
||||
static Timer updateAccountListTimer(ConfigLoginServer::getUpdatePurgeAccountListTime());
|
||||
if (updateAccountListTimer.updateZero(time))
|
||||
DatabaseConnection::getInstance().updatePurgeAccountList();
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void PurgeManager::onGetAccountForPurge(StationId account, int purgePhase)
|
||||
{
|
||||
m_gettingAccount=false;
|
||||
if (account==0)
|
||||
{
|
||||
// No remaining accounts in the DB
|
||||
m_currentPurgePhase=getNextPurgePhase(m_currentPurgePhase);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (purgePhase == ppNoPurge)
|
||||
{
|
||||
WARNING_DEBUG_FATAL(true,("Programmer bug: onGetAccountForPurge(%i) -- account was in the \"No Purge\" phase. The DB query shouldn't return accounts in this phase.", account));
|
||||
return;
|
||||
}
|
||||
if (purgePhase == ppPurged)
|
||||
{
|
||||
WARNING_DEBUG_FATAL(true,("Programmer bug: onGetAccountForPurge(%i) -- account was in the \"Purged\" phase. The DB query shouldn't return accounts in this phase.", account));
|
||||
return;
|
||||
}
|
||||
|
||||
PurgeRecord record(account, static_cast<PurgePhase>(purgePhase));
|
||||
m_purgeRecords.insert(std::make_pair(account,record));
|
||||
|
||||
if (ConfigLoginServer::getValidateStationKey())
|
||||
NON_NULL(LoginServer::getInstance().getSessionApiClient())->checkStatusForPurge(account);
|
||||
else
|
||||
onCheckStatusForPurge(account, false);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void PurgeManager::onCheckStatusForPurge(StationId account, bool isActive)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true,("onCheckStatusForPurge(%li, %s)\n",account, isActive ? "true" : "false"));
|
||||
PurgeRecordsType::iterator i=m_purgeRecords.find(account);
|
||||
if (i==m_purgeRecords.end())
|
||||
{
|
||||
WARNING_DEBUG_FATAL(true,("Programmer bug: onCheckStatusForPurge(%i) -- account was not in m_purgeRecords", account));
|
||||
return;
|
||||
}
|
||||
PurgeRecord & record = i->second;
|
||||
|
||||
|
||||
if (isActive)
|
||||
{
|
||||
removeFromPurgeList(account);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!LoginServer::getInstance().areAllClustersUp())
|
||||
{
|
||||
// Don't try to process any purges while clusters are down
|
||||
releaseAccount(account);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (record.getPurgePhase())
|
||||
{
|
||||
case ppNoPurge:
|
||||
WARNING_DEBUG_FATAL(true,("Programmer bug: onCheckStatusForPurge(%i) -- account was in the \"No Purge\" phase.", account));
|
||||
break;
|
||||
case ppNotWarned:
|
||||
{
|
||||
LOG("CustomerService",( "Purge: Sending structure purge warning emails for account %i", account));
|
||||
//TODO: send to platform somehow for warning emails
|
||||
record.grabClusterList();
|
||||
GenericValueTypeMessage<StationId> msg("WarnStructuresAboutPurgeMessage",account);
|
||||
LoginServer::getInstance().sendToAllClusters(msg);
|
||||
|
||||
break;
|
||||
}
|
||||
case ppStructureWarningSent:
|
||||
{
|
||||
LOG("CustomerService",( "Purge: Starting structure and vendor purge for account %i", account));
|
||||
record.grabClusterList();
|
||||
GenericValueTypeMessage<StationId> msg("PurgeStructuresForAccountMessage",account);
|
||||
LoginServer::getInstance().sendToAllClusters(msg);
|
||||
break;
|
||||
}
|
||||
case ppStructuresPurged:
|
||||
LOG("CustomerService",( "Purge: Sending character purge warning emails for account %i", account));
|
||||
//TODO: send to platform somehow for warning emails
|
||||
record.advancePurgePhase();
|
||||
releaseAccount(record.getStationId());
|
||||
break;
|
||||
case ppCharacterWarningSent:
|
||||
LOG("CustomerService",( "Purge: Deleting all characters for account %i", account));
|
||||
DatabaseConnection::getInstance().deleteAllCharacters(account);
|
||||
break;
|
||||
case ppPurged:
|
||||
WARNING_DEBUG_FATAL(true,("Programmer bug: onCheckStatusForPurge(%i) -- account was in the \"Purged\" phase. This should not be possible.", account));
|
||||
break;
|
||||
default:
|
||||
WARNING_DEBUG_FATAL(true,("Programmer bug: onCheckStatusForPurge(%i) -- account was in an unhandled purge phase", account));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void PurgeManagerNamespace::removeFromPurgeList(StationId account)
|
||||
{
|
||||
DatabaseConnection::getInstance().setPurgeStatusAndRelease(account, ppNoPurge);
|
||||
m_purgeRecords.erase(account);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void PurgeManagerNamespace::releaseAccount(StationId account)
|
||||
{
|
||||
PurgeRecordsType::iterator record=m_purgeRecords.find(account);
|
||||
if (record==m_purgeRecords.end())
|
||||
{
|
||||
WARNING_DEBUG_FATAL(true,("Programmer bug: releaseAccount(%i) -- account was not in m_purgeRecords", account));
|
||||
return;
|
||||
}
|
||||
|
||||
DatabaseConnection::getInstance().setPurgeStatusAndRelease(account, record->second.getPurgePhase());
|
||||
m_purgeRecords.erase(record);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The specified cluster is no longer ready for players. Indicates
|
||||
* a game server crashed or some other problem. Assume any pending purges
|
||||
* on this cluster did not go through, retry them later.
|
||||
*/
|
||||
void PurgeManager::onClusterNoLongerReady(uint32 clusterId)
|
||||
{
|
||||
for (PurgeRecordsType::iterator record=m_purgeRecords.begin(); record!=m_purgeRecords.end(); )
|
||||
{
|
||||
if (record->second.hasCluster(clusterId))
|
||||
{
|
||||
PurgeRecordsType::iterator nextRecord=record;
|
||||
++nextRecord;
|
||||
releaseAccount(record->second.getStationId());
|
||||
record=nextRecord;
|
||||
}
|
||||
else
|
||||
++record;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Called when a cluster indicates it has done the purge for a particular
|
||||
* account and saved the results.
|
||||
*/
|
||||
void PurgeManager::handlePurgeCompleteOnCluster(StationId account, uint32 clusterId)
|
||||
{
|
||||
PurgeRecordsType::iterator i=m_purgeRecords.find(account);
|
||||
if (i==m_purgeRecords.end())
|
||||
{
|
||||
DEBUG_REPORT_LOG(true,("Purge record could not be found in handlePurgeCompleteOnCluster(%li, %li). Probably indicates the cluster and/or the login server were restarted while a purge was in progress. The purge will be retried later.\n",account,clusterId));
|
||||
return;
|
||||
}
|
||||
|
||||
PurgeRecord & record = i->second;
|
||||
record.removeCluster(clusterId);
|
||||
if (!record.hasClusters())
|
||||
{
|
||||
// No more clusters remaining. Purge was a success
|
||||
record.advancePurgePhase();
|
||||
releaseAccount(record.getStationId());
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void PurgeManager::onAllCharactersDeleted(StationId account, bool success)
|
||||
{
|
||||
PurgeRecordsType::iterator i=m_purgeRecords.find(account);
|
||||
if (i==m_purgeRecords.end())
|
||||
{
|
||||
WARNING_DEBUG_FATAL(true,("Programmer bug: onAllCharactersDeleted(%li) called with an account that wasn't in m_purgeRecords",account));
|
||||
return;
|
||||
}
|
||||
|
||||
PurgeRecord & record = i->second;
|
||||
if (record.getPurgePhase()!=ppCharacterWarningSent)
|
||||
{
|
||||
WARNING_DEBUG_FATAL(true,("Programmer bug: onAllCharactersDeleted(%li) called with an account that wasn't in the ppCharacterWarningSent phase",account));
|
||||
releaseAccount(record.getStationId());
|
||||
return;
|
||||
}
|
||||
|
||||
if (success)
|
||||
record.advancePurgePhase();
|
||||
|
||||
releaseAccount(record.getStationId());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
PurgePhase PurgeManagerNamespace::getNextPurgePhase(PurgePhase previousPurgePhase)
|
||||
{
|
||||
switch (previousPurgePhase)
|
||||
{
|
||||
case ppNoPurge:
|
||||
return ppNoPurge;
|
||||
case ppNotWarned:
|
||||
return ppStructureWarningSent;
|
||||
break;
|
||||
case ppStructureWarningSent:
|
||||
return ppStructuresPurged;
|
||||
break;
|
||||
case ppStructuresPurged:
|
||||
return ppCharacterWarningSent;
|
||||
break;
|
||||
case ppCharacterWarningSent:
|
||||
return ppPurged;
|
||||
break;
|
||||
case ppPurged:
|
||||
return ppPurged;
|
||||
default:
|
||||
// This needs to FATAL, not WARN, because if the purge phase is fried it might mean we're going to purge accounts that aren't in the right phase
|
||||
FATAL(true,("Programmer bug: getNextPurgePhase called with invalid purge phase %i",static_cast<int>(previousPurgePhase)));
|
||||
return ppNoPurge;
|
||||
}
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
PurgeRecord::PurgeRecord(StationId stationId, PurgePhase purgePhase) :
|
||||
m_stationId(stationId),
|
||||
m_purgePhase(purgePhase)
|
||||
{
|
||||
}
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
StationId PurgeRecord::getStationId() const
|
||||
{
|
||||
return m_stationId;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
PurgePhase PurgeRecord::getPurgePhase() const
|
||||
{
|
||||
return m_purgePhase;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void PurgeRecord::grabClusterList()
|
||||
{
|
||||
std::vector<uint32> clusterList;
|
||||
LoginServer::getInstance().getClusterIds(clusterList);
|
||||
m_clusters.insert(clusterList.begin(), clusterList.end());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool PurgeRecord::hasCluster(uint32 clusterId) const
|
||||
{
|
||||
return (m_clusters.find(clusterId)!=m_clusters.end());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void PurgeRecord::removeCluster(uint32 clusterId)
|
||||
{
|
||||
m_clusters.erase(clusterId);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool PurgeRecord::hasClusters() const
|
||||
{
|
||||
return (!m_clusters.empty());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Move to the next phase in the purge sequence.
|
||||
*/
|
||||
void PurgeRecord::advancePurgePhase()
|
||||
{
|
||||
m_purgePhase=getNextPurgePhase(m_purgePhase);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,26 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// PurgeManager.h
|
||||
// copyright (c) 2005 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_PurgeManager_H
|
||||
#define INCLUDED_PurgeManager_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class PurgeManager
|
||||
{
|
||||
public:
|
||||
static void update(float time);
|
||||
static void onCheckStatusForPurge(StationId account, bool isActive);
|
||||
static void onGetAccountForPurge(StationId account, int purgePhase);
|
||||
static void onClusterNoLongerReady(uint32 clusterId);
|
||||
static void handlePurgeCompleteOnCluster(StationId account, uint32 clusterId);
|
||||
static void onAllCharactersDeleted(StationId account, bool success);
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,456 @@
|
||||
// SessionApiClient.cpp
|
||||
// copyright 2002 Sony Online Entertainment
|
||||
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
#include "SessionApiClient.h"
|
||||
|
||||
#include "ClientConnection.h"
|
||||
#include "ConfigLoginServer.h"
|
||||
#include "CSToolConnection.h"
|
||||
#include "DatabaseConnection.h"
|
||||
#include "LoginServer.h"
|
||||
#include "PurgeManager.h"
|
||||
#include "serverNetworkMessages/ClaimRewardsMessage.h"
|
||||
#include "serverNetworkMessages/ClaimRewardsReplyMessage.h"
|
||||
#include "Session/CommonAPI/CommonAPIStrings.h"
|
||||
#include "sharedGame/PlatformFeatureBits.h"
|
||||
#include "sharedLog/Log.h"
|
||||
#include "sharedNetworkMessages/ErrorMessage.h"
|
||||
#include "sharedSynchronization/Mutex.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
std::map<apiTrackingNumber, ClientConnection *> SessionApiClient::m_validationMap;
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
namespace SessionApiClientNamespace
|
||||
{
|
||||
std::map<apiTrackingNumber, std::pair<uint32, ClaimRewardsMessage const *> > ms_modifyFeatureTrackingNumberMap;
|
||||
};
|
||||
|
||||
using namespace SessionApiClientNamespace;
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
SessionApiClient::SessionApiClient(const char ** serverList, int serverCount) :
|
||||
Client(serverList, static_cast<unsigned int>(serverCount), "Starwars Login Server")
|
||||
{
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
SessionApiClient::~SessionApiClient()
|
||||
{
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
void SessionApiClient::OnSessionLogin(const apiTrackingNumber trackingNumber,
|
||||
const apiResult result,
|
||||
const apiAccount & account,
|
||||
const apiSubscription & subscription,
|
||||
const apiSession & session,
|
||||
const LoginAPI::UsageLimit & usageLimit,
|
||||
const LoginAPI::Entitlement & entitlement,
|
||||
void * userData)
|
||||
{
|
||||
OnSessionValidate(trackingNumber, result, account, subscription, session, usageLimit, entitlement, userData);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
void SessionApiClient::OnSessionLoginInternal(const apiTrackingNumber trackingNumber,
|
||||
const apiResult result,
|
||||
const apiAccount & account,
|
||||
const apiSubscription & subscription,
|
||||
const apiSession & session,
|
||||
const LoginAPI::UsageLimit & usageLimit,
|
||||
const LoginAPI::Entitlement & entitlement,
|
||||
void * userData)
|
||||
{
|
||||
UNREF(trackingNumber);
|
||||
UNREF(result);
|
||||
UNREF(account);
|
||||
UNREF(subscription);
|
||||
UNREF(session);
|
||||
UNREF(usageLimit);
|
||||
UNREF(entitlement);
|
||||
UNREF(userData);
|
||||
// DEBUG_REPORT_LOG(true, ("Session login internal.\n"));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
void SessionApiClient::OnSessionValidate(const apiTrackingNumber trackingNumber,
|
||||
const apiResult result,
|
||||
const apiAccount & account,
|
||||
const apiSubscription & subscription,
|
||||
const apiSession & session,
|
||||
const LoginAPI::UsageLimit & usageLimit,
|
||||
const LoginAPI::Entitlement & entitlement,
|
||||
void * userData)
|
||||
{
|
||||
UNREF(usageLimit);
|
||||
UNREF(userData);
|
||||
|
||||
std::map<apiTrackingNumber, ClientConnection*>::iterator i = m_validationMap.find(trackingNumber);
|
||||
DEBUG_REPORT_LOG(true, ("OnSessionValidate result: %d for suid: %d (entitlement total: %u/%u, since last login: %u/%u, reason unentitled: %d)\n", result, account.GetId(), entitlement.GetEntitledTime(), entitlement.GetTotalTime(), entitlement.GetEntitledTimeSinceLastLogin(), entitlement.GetTotalTimeSinceLastLogin(), static_cast<int>(entitlement.GetReasonUnentitled())));
|
||||
|
||||
if (i != m_validationMap.end())
|
||||
{
|
||||
if (result == RESULT_SUCCESS)
|
||||
{
|
||||
LOG("LoginClientConnection", ("OnSessionValidate() for stationId (%u) at IP (%s), id (%s), apiTrackingNumber (%u), SUCCESS", account.GetId(), i->second->getRemoteAddress().c_str(), account.GetName(), trackingNumber));
|
||||
LoginServer::getInstance().onValidateClient(account.GetId(), account.GetName(), i->second, session.GetIsSecure(), session.GetId(), subscription.GetGameFeatures(), subscription.GetSubscriptionFeatures());
|
||||
m_validationMap.erase(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("LoginClientConnection", ("OnSessionValidate() for stationId (%u) at IP (%s), id (%s), apiTrackingNumber (%u), VALIDATION FAILED (%u)", account.GetId(), i->second->getRemoteAddress().c_str(), account.GetName(), trackingNumber, result));
|
||||
ErrorMessage err("VALIDATION FAILED", "Your station Id was not valid. Wrong password? Account closed?");
|
||||
i->second->send(err, true);
|
||||
i->second->disconnect();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// attempt to validate a CS Tool associated with this request.
|
||||
CSToolConnection::validateCSTool( ( uint32 )userData, result, session );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
void SessionApiClient::OnSessionConsume(const apiTrackingNumber trackingNumber,
|
||||
const apiResult result,
|
||||
const apiAccount & account,
|
||||
const apiSubscription & subscription,
|
||||
const apiSession & session,
|
||||
const LoginAPI::UsageLimit & usageLimit,
|
||||
const LoginAPI::Entitlement & entitlement,
|
||||
void * userData)
|
||||
{
|
||||
UNREF(trackingNumber);
|
||||
UNREF(result);
|
||||
UNREF(account);
|
||||
UNREF(subscription);
|
||||
UNREF(session);
|
||||
UNREF(usageLimit);
|
||||
UNREF(entitlement);
|
||||
UNREF(userData);
|
||||
// DEBUG_REPORT_LOG(true, ("Session consume.\n"));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
void SessionApiClient::OnSessionStartPlay(const apiTrackingNumber trackingNumber,
|
||||
const apiResult result,
|
||||
void * userData)
|
||||
{
|
||||
UNREF(trackingNumber);
|
||||
UNREF(result);
|
||||
UNREF(userData);
|
||||
// DEBUG_REPORT_LOG(true, ("Session start play.\n"));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
void SessionApiClient::OnSessionStopPlay(const apiTrackingNumber trackingNumber,
|
||||
const apiResult result,
|
||||
void * userData)
|
||||
{
|
||||
UNREF(trackingNumber);
|
||||
UNREF(result);
|
||||
UNREF(userData);
|
||||
// DEBUG_REPORT_LOG(true, ("Session stop play.\n"));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
void SessionApiClient::OnSessionKick(const apiTrackingNumber trackingNumber,
|
||||
const apiResult result,
|
||||
void * userData)
|
||||
{
|
||||
UNREF(trackingNumber);
|
||||
UNREF(result);
|
||||
UNREF(userData);
|
||||
// DEBUG_REPORT_LOG(true, ("Session kick.\n"));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
void SessionApiClient::OnGetSessions(const apiTrackingNumber trackingNumber,
|
||||
const apiResult result,
|
||||
const unsigned count,
|
||||
const apiSession session[],
|
||||
const apiSubscription subscription[],
|
||||
const LoginAPI::UsageLimit usageLimit[],
|
||||
const unsigned timeCreated[],
|
||||
const unsigned timeTouched[],
|
||||
void * userData)
|
||||
{
|
||||
UNREF(trackingNumber);
|
||||
UNREF(result);
|
||||
UNREF(count);
|
||||
UNREF(session);
|
||||
UNREF(subscription);
|
||||
UNREF(usageLimit);
|
||||
UNREF(timeCreated);
|
||||
UNREF(timeTouched);
|
||||
UNREF(userData);
|
||||
// DEBUG_REPORT_LOG(true, ("Get sessions.\n"));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
void SessionApiClient::OnGetFeatures(const apiTrackingNumber trackingNumber,
|
||||
const apiResult result,
|
||||
const unsigned featureCount,
|
||||
const LoginAPI::Feature featureArray[],
|
||||
const void * userData)
|
||||
{
|
||||
UNREF(trackingNumber);
|
||||
UNREF(result);
|
||||
UNREF(featureCount);
|
||||
UNREF(featureArray);
|
||||
UNREF(userData);
|
||||
// DEBUG_REPORT_LOG(true, ("Get features.\n"));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
void SessionApiClient::OnGrantFeature(const apiTrackingNumber trackingNumber,
|
||||
const apiResult result,
|
||||
void * userData)
|
||||
{
|
||||
UNREF(trackingNumber);
|
||||
UNREF(result);
|
||||
UNREF(userData);
|
||||
// DEBUG_REPORT_LOG(true, ("Grant feature.\n"));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
void SessionApiClient::OnModifyFeature(const apiTrackingNumber trackingNumber,
|
||||
const apiResult result,
|
||||
void * userData)
|
||||
{
|
||||
UNREF(trackingNumber);
|
||||
UNREF(result);
|
||||
UNREF(userData);
|
||||
// DEBUG_REPORT_LOG(true, ("Modify feature.\n"));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
void SessionApiClient::OnModifyFeature_v2(const apiTrackingNumber trackingNumber,
|
||||
const apiResult result,
|
||||
const LoginAPI::Feature & currentFeature,
|
||||
void * userData)
|
||||
{
|
||||
UNREF(currentFeature);
|
||||
UNREF(userData);
|
||||
|
||||
std::map<apiTrackingNumber, std::pair<uint32, ClaimRewardsMessage const *> >::iterator i = ms_modifyFeatureTrackingNumberMap.find(trackingNumber);
|
||||
if (i != ms_modifyFeatureTrackingNumberMap.end())
|
||||
{
|
||||
if (result != RESULT_SUCCESS)
|
||||
{
|
||||
// if failed to update feature id, send failure message
|
||||
LOG("CustomerService",("VeteranRewards: received non-success result code (%u) from session to adjust feature id %lu (%s -> %s) for account (%lu), character (%s), reward event (%s), reward item (%s), session tracking number (%u)", result, i->second.second->getAccountFeatureId(), i->second.second->getAccountFeatureIdOldValue().c_str(), i->second.second->getAccountFeatureIdNewValue().c_str(), i->second.second->getStationId(), i->second.second->getPlayer().getValueString().c_str(), i->second.second->getRewardEvent().c_str(), i->second.second->getRewardItem().c_str(), trackingNumber));
|
||||
|
||||
ClaimRewardsReplyMessage const rsp(i->second.second->getGameServer(), i->second.second->getStationId(), i->second.second->getPlayer(), i->second.second->getRewardEvent(), i->second.second->getRewardItem(), i->second.second->getAccountFeatureId(), true, 0, 0, false);
|
||||
LoginServer::getInstance().sendToCluster(i->second.first, rsp);
|
||||
}
|
||||
else
|
||||
{
|
||||
// if feature id updated successfully, record transaction
|
||||
LoginAPI::Feature oldFeature;
|
||||
oldFeature.SetID(i->second.second->getAccountFeatureId());
|
||||
oldFeature.SetData(i->second.second->getAccountFeatureIdOldValue());
|
||||
|
||||
LoginAPI::Feature newFeature;
|
||||
newFeature.SetID(i->second.second->getAccountFeatureId());
|
||||
newFeature.SetData(i->second.second->getAccountFeatureIdNewValue());
|
||||
|
||||
DatabaseConnection::getInstance().claimRewards(i->second.first, i->second.second->getGameServer(), i->second.second->getStationId(), i->second.second->getPlayer(), i->second.second->getRewardEvent(), i->second.second->getConsumeEvent(), i->second.second->getRewardItem(), i->second.second->getConsumeItem(), i->second.second->getAccountFeatureId(), true, oldFeature.GetConsumeCount(), newFeature.GetConsumeCount());
|
||||
}
|
||||
|
||||
delete i->second.second;
|
||||
ms_modifyFeatureTrackingNumberMap.erase(i);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
void SessionApiClient::OnRevokeFeature(const apiTrackingNumber trackingNumber,
|
||||
const apiResult result,
|
||||
void * userData)
|
||||
{
|
||||
UNREF(trackingNumber);
|
||||
UNREF(result);
|
||||
UNREF(userData);
|
||||
// DEBUG_REPORT_LOG(true, ("Revoke feature.\n"));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
void SessionApiClient::OnEnumerateFeatures(const apiTrackingNumber trackingNumber,
|
||||
const apiResult result,
|
||||
const unsigned featureCount,
|
||||
const LoginAPI::FeatureDescription featureArray[],
|
||||
const void * userData)
|
||||
{
|
||||
UNREF(trackingNumber);
|
||||
UNREF(result);
|
||||
UNREF(featureCount);
|
||||
UNREF(featureArray);
|
||||
UNREF(userData);
|
||||
// DEBUG_REPORT_LOG(true, ("Enumerate features.\n"));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
void SessionApiClient::handleClaimRewardsMessage(uint32 clusterId, ClaimRewardsMessage const * msg)
|
||||
{
|
||||
UNREF(AccountStatusString);
|
||||
UNREF(SessionTypeString);
|
||||
UNREF(GamecodeString);
|
||||
UNREF(SubscriptionStatusString);
|
||||
|
||||
if (!msg)
|
||||
return;
|
||||
|
||||
LoginAPI::Feature oldFeature;
|
||||
oldFeature.SetID(msg->getAccountFeatureId());
|
||||
oldFeature.SetData(msg->getAccountFeatureIdOldValue());
|
||||
|
||||
LoginAPI::Feature newFeature;
|
||||
newFeature.SetID(msg->getAccountFeatureId());
|
||||
newFeature.SetData(msg->getAccountFeatureIdNewValue());
|
||||
|
||||
apiTrackingNumber const tn = ModifyFeature_v2(msg->getStationId(), PlatformGameCode::getGamecodeName(PlatformGameCode::SWG).c_str(), oldFeature, newFeature);
|
||||
LOG("CustomerService",("VeteranRewards: requesting session to adjust feature id %lu (%s -> %s) for account (%lu), character (%s), reward event (%s), reward item (%s), session tracking number (%u)", msg->getAccountFeatureId(), msg->getAccountFeatureIdOldValue().c_str(), msg->getAccountFeatureIdNewValue().c_str(), msg->getStationId(), msg->getPlayer().getValueString().c_str(), msg->getRewardEvent().c_str(), msg->getRewardItem().c_str(), tn));
|
||||
ms_modifyFeatureTrackingNumberMap[tn] = std::make_pair(clusterId, msg);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
void SessionApiClient::dropClient(const ClientConnection* client) const
|
||||
{
|
||||
std::map<apiTrackingNumber, ClientConnection*>::iterator i = m_validationMap.begin();
|
||||
for (;i != m_validationMap.end(); ++i)
|
||||
{
|
||||
if (i->second == client)
|
||||
{
|
||||
m_validationMap.erase(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
void SessionApiClient::validateClient (ClientConnection* client, const std::string & key)
|
||||
{
|
||||
|
||||
//Key will be the real session key
|
||||
//We will only use id if we aren't validating.
|
||||
//The key will provide a username and an id from the station.
|
||||
|
||||
//We call SessionValidate(key, type) on the Session client
|
||||
//It will callback with OnSessionValidate(trackingNumber, result, account, subscription, userdata);
|
||||
|
||||
//type will be ConfigLoginServer::getSessionType()
|
||||
//result is hopefully RESULT_SUCCESS
|
||||
//acount is struct (name, id, status) where status is ACCOUNT_STATUS_ACTIVE and id is unsigned
|
||||
//subscription is hopefully SUBSCRIPTION_STATUS_ACTIVE could be trial
|
||||
//user data is a void* and I think un-used.
|
||||
|
||||
//Then store the client in a map based on the key.
|
||||
|
||||
apiTrackingNumber track = SessionValidate(key.c_str(), static_cast<apiSessionType>(ConfigLoginServer::getSessionType()));
|
||||
//apiTrackingNumber track = SessionConsume(key.c_str(), static_cast<apiSessionType>(ConfigLoginServer::getSessionType()));
|
||||
|
||||
LOG("LoginClientConnection", ("validateClient() for stationId (%lu) at IP (%s), key (%s), apiTrackingNumber (%u), validating session", client->getStationId(), client->getRemoteAddress().c_str(), key.c_str(), track));
|
||||
|
||||
//Ok to overwrite old or add new here.
|
||||
m_validationMap[track] = client;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
void SessionApiClient::loginClient (ClientConnection* client, const std::string& username, const std::string & password)
|
||||
{
|
||||
apiTrackingNumber track = SessionLogin(username.c_str(), password.c_str(), static_cast<apiSessionType>(ConfigLoginServer::getSessionType()), 0, 0);
|
||||
|
||||
LOG("LoginClientConnection", ("loginClient() for stationId (%lu) at IP (%s), key (%s), apiTrackingNumber (%u), validating session", client->getStationId(), client->getRemoteAddress().c_str(), password.c_str(), track));
|
||||
|
||||
//Ok to overwrite old or add new here.
|
||||
m_validationMap[track] = client;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
void SessionApiClient::OnConnectionOpened(const char * address, unsigned port)
|
||||
{
|
||||
UNREF(address);
|
||||
UNREF(port);
|
||||
// DEBUG_REPORT_LOG(true, ("Connection success\n"));
|
||||
}
|
||||
void SessionApiClient::OnConnectionClosed(const char * address, unsigned port)
|
||||
{
|
||||
UNREF(address);
|
||||
UNREF(port);
|
||||
// DEBUG_REPORT_LOG(true, ("Connection closed.\n"));
|
||||
}
|
||||
void SessionApiClient::OnConnectionFailed(const char * address, unsigned port)
|
||||
{
|
||||
UNREF(address);
|
||||
UNREF(port);
|
||||
// DEBUG_FATAL(true, ("Connection failed"));
|
||||
}
|
||||
void SessionApiClient::OnException()
|
||||
{
|
||||
// DEBUG_REPORT_LOG(true, ("Connection exception.\n"));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
void SessionApiClient::NotifySessionKick(const char ** sessionList,
|
||||
const unsigned sessionCount)
|
||||
{
|
||||
UNREF(sessionList);
|
||||
UNREF(sessionCount);
|
||||
// DEBUG_REPORT_LOG(true, ("Session kick.\n"));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void SessionApiClient::checkStatusForPurge(StationId account)
|
||||
{
|
||||
GetAccountSubscription(account, PlatformGameCode::SWG, NULL);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
void SessionApiClient::OnGetAccountSubscription(const apiTrackingNumber trackingNumber,
|
||||
const apiResult result,
|
||||
const apiAccount & account,
|
||||
const apiSubscription & subscription,
|
||||
void * userData)
|
||||
{
|
||||
// This assumes that the only reason this would be called would be to check the status
|
||||
// for the purge process. If something else ever uses getAccountSubscription, this will
|
||||
// need to be changed.
|
||||
if (result==RESULT_SUCCESS)
|
||||
PurgeManager::onCheckStatusForPurge(account.GetId(), (account.GetStatus()==ACCOUNT_STATUS_ACTIVE));
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,136 @@
|
||||
// SessionApiClient.h
|
||||
// copyright 2002 Sony Online Entertainment
|
||||
|
||||
#ifndef _SessionApiClient_H
|
||||
#define _SessionApiClient_H
|
||||
|
||||
#include <map>
|
||||
#include "Session/LoginAPI/Client.h"
|
||||
|
||||
class ClaimRewardsMessage;
|
||||
class ClientConnection;
|
||||
|
||||
class SessionApiClient : public LoginAPI::Client
|
||||
{
|
||||
public:
|
||||
|
||||
SessionApiClient(const char ** serverList, int serverCount);
|
||||
~SessionApiClient();
|
||||
|
||||
virtual void OnSessionLogin(const apiTrackingNumber trackingNumber,
|
||||
const apiResult result,
|
||||
const apiAccount & account,
|
||||
const apiSubscription & subscription,
|
||||
const apiSession & session,
|
||||
const LoginAPI::UsageLimit & usageLimit,
|
||||
const LoginAPI::Entitlement & entitlement,
|
||||
void * userData);
|
||||
|
||||
virtual void OnSessionLoginInternal(const apiTrackingNumber trackingNumber,
|
||||
const apiResult result,
|
||||
const apiAccount & account,
|
||||
const apiSubscription & subscription,
|
||||
const apiSession & session,
|
||||
const LoginAPI::UsageLimit & usageLimit,
|
||||
const LoginAPI::Entitlement & entitlement,
|
||||
void * userData);
|
||||
|
||||
virtual void OnSessionValidate(const apiTrackingNumber trackingNumber,
|
||||
const apiResult result,
|
||||
const apiAccount & account,
|
||||
const apiSubscription & subscription,
|
||||
const apiSession & session,
|
||||
const LoginAPI::UsageLimit & usageLimit,
|
||||
const LoginAPI::Entitlement & entitlement,
|
||||
void * userData);
|
||||
|
||||
virtual void OnSessionConsume(const apiTrackingNumber trackingNumber,
|
||||
const apiResult result,
|
||||
const apiAccount & account,
|
||||
const apiSubscription & subscription,
|
||||
const apiSession & session,
|
||||
const LoginAPI::UsageLimit & usageLimit,
|
||||
const LoginAPI::Entitlement & entitlement,
|
||||
void * userData);
|
||||
|
||||
virtual void OnSessionStartPlay(const apiTrackingNumber trackingNumber,
|
||||
const apiResult result,
|
||||
void * userData);
|
||||
|
||||
virtual void OnSessionStopPlay(const apiTrackingNumber trackingNumber,
|
||||
const apiResult result,
|
||||
void * userData);
|
||||
|
||||
virtual void OnSessionKick(const unsigned trackingNumber,
|
||||
const apiResult result,
|
||||
void * userData);
|
||||
|
||||
virtual void OnGetSessions(const apiTrackingNumber trackingNumber,
|
||||
const apiResult result,
|
||||
const unsigned count,
|
||||
const apiSession session[],
|
||||
const apiSubscription subscription[],
|
||||
const LoginAPI::UsageLimit usageLimit[],
|
||||
const unsigned timeCreated[],
|
||||
const unsigned timeTouched[],
|
||||
void * userData);
|
||||
|
||||
virtual void OnGetFeatures(const apiTrackingNumber trackingNumber,
|
||||
const apiResult result,
|
||||
const unsigned featureCount,
|
||||
const LoginAPI::Feature featureArray[],
|
||||
const void * userData = 0);
|
||||
|
||||
virtual void OnGrantFeature(const apiTrackingNumber trackingNumber,
|
||||
const apiResult result,
|
||||
void * userData);
|
||||
|
||||
virtual void OnModifyFeature(const apiTrackingNumber trackingNumber,
|
||||
const apiResult result,
|
||||
void * userData);
|
||||
|
||||
virtual void OnModifyFeature_v2(const apiTrackingNumber trackingNumber,
|
||||
const apiResult result,
|
||||
const LoginAPI::Feature & currentFeature,
|
||||
void * userData);
|
||||
|
||||
virtual void OnRevokeFeature(const apiTrackingNumber trackingNumber,
|
||||
const apiResult result,
|
||||
void * userData);
|
||||
|
||||
virtual void OnEnumerateFeatures(const apiTrackingNumber trackingNumber,
|
||||
const apiResult result,
|
||||
const unsigned featureCount,
|
||||
const LoginAPI::FeatureDescription featureArray[],
|
||||
const void * userData = 0);
|
||||
|
||||
virtual void OnGetAccountSubscription(const apiTrackingNumber trackingNumber,
|
||||
const apiResult result,
|
||||
const apiAccount & account,
|
||||
const apiSubscription & subscription,
|
||||
void * userData);
|
||||
|
||||
virtual void OnConnectionOpened(const char * address, unsigned port);
|
||||
virtual void OnConnectionClosed(const char * address, unsigned port);
|
||||
virtual void OnConnectionFailed(const char * address, unsigned port);
|
||||
virtual void OnException();
|
||||
|
||||
virtual void NotifySessionKick(const char ** sessionList,
|
||||
const unsigned sessionCount);
|
||||
|
||||
void handleClaimRewardsMessage(uint32 clusterId, ClaimRewardsMessage const * msg);
|
||||
void dropClient(const ClientConnection* client) const;
|
||||
void validateClient (ClientConnection* client, const std::string & key);
|
||||
void loginClient(ClientConnection* client, const std::string & username, const std::string & password);
|
||||
void checkStatusForPurge (StationId account);
|
||||
|
||||
static void FlushSessionQueue();
|
||||
|
||||
private:
|
||||
|
||||
static std::map<apiTrackingNumber, ClientConnection *> m_validationMap;
|
||||
SessionApiClient();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,113 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskChangeStationId.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
#include "TaskChangeStationId.h"
|
||||
|
||||
#include "CentralServerConnection.h"
|
||||
#include "DatabaseConnection.h"
|
||||
#include "sharedLog/Log.h"
|
||||
#include "serverNetworkMessages/TransferAccountData.h"
|
||||
#include "serverNetworkMessages/TransferAccountDataArchive.h"
|
||||
#include "sharedDatabaseInterface/DbSession.h"
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskChangeStationId::TaskChangeStationId(StationId sourceStationId, StationId destinationStationId, const TransferAccountData *requestData) :
|
||||
TaskRequest(),
|
||||
m_sourceStationId(sourceStationId),
|
||||
m_destinationStationId(destinationStationId),
|
||||
m_requestData(0),
|
||||
m_success(false)
|
||||
{
|
||||
if(requestData)
|
||||
{
|
||||
m_requestData = new TransferAccountData(*requestData);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
TaskChangeStationId::~TaskChangeStationId()
|
||||
{
|
||||
delete m_requestData;
|
||||
m_requestData = 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskChangeStationId::process(DB::Session *session)
|
||||
{
|
||||
ChangeStationIdQuery qry;
|
||||
qry.source_station_id = m_sourceStationId;
|
||||
qry.destination_station_id = m_destinationStationId;
|
||||
|
||||
m_success = session->exec(&qry);
|
||||
|
||||
qry.done();
|
||||
return m_success;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskChangeStationId::onComplete()
|
||||
{
|
||||
// part of account to account move request for character transfer system
|
||||
LOG("CustomerService", ("CharacterTransfer: Completed database change for account transfer from %lu to %lu: sending reply back to transfer server on %s", m_sourceStationId, m_destinationStationId, m_requestData->getStartGalaxy().c_str()));
|
||||
const GenericValueTypeMessage<TransferAccountData> response("TransferAccountReplySuccessTransferServer", *m_requestData);
|
||||
CentralServerConnection::sendToCentralServer(m_requestData->getStartGalaxy(), response);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskChangeStationId::ChangeStationIdQuery::ChangeStationIdQuery() :
|
||||
Query(),
|
||||
destination_station_id(0),
|
||||
source_station_id(0)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskChangeStationId::ChangeStationIdQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql =
|
||||
std::string("begin ")+
|
||||
DatabaseConnection::getInstance().getSchemaQualifier()+"\n\
|
||||
Update swg_characters Set station_id = :destination_station_id Where station_id = :source_station_id;\n\
|
||||
Update account_reward_events Set station_id = :destination_station_id Where station_id = :source_station_id;\n\
|
||||
Update account_reward_items Set station_id = :destination_station_id Where station_id = :source_station_id;\n\
|
||||
end;";
|
||||
|
||||
// DEBUG_REPORT_LOG(true, ("TaskChangeStationId SQL: %s\n", sql.c_str()));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskChangeStationId::ChangeStationIdQuery::bindParameters()
|
||||
{
|
||||
if (!bindParameter(destination_station_id)) return false;
|
||||
if (!bindParameter(source_station_id)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskChangeStationId::ChangeStationIdQuery::bindColumns()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
DB::Query::QueryMode TaskChangeStationId::ChangeStationIdQuery::getExecutionMode() const
|
||||
{
|
||||
return MODE_PROCEXEC;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,61 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskChangeStationId.h
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_TaskChangeStationId_H
|
||||
#define INCLUDED_TaskChangeStationId_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedDatabaseInterface/Bindable.h"
|
||||
#include "sharedDatabaseInterface/BindableNetworkId.h"
|
||||
#include "sharedDatabaseInterface/DbQuery.h"
|
||||
#include "sharedDatabaseInterface/DbTaskRequest.h"
|
||||
#include "sharedFoundation/StationId.h"
|
||||
|
||||
class TransferAccountData;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class TaskChangeStationId : public DB::TaskRequest
|
||||
{
|
||||
public:
|
||||
TaskChangeStationId(StationId sourceStationId, StationId destinationStationId, const TransferAccountData * requestData);
|
||||
~TaskChangeStationId();
|
||||
public:
|
||||
virtual bool process (DB::Session *session);
|
||||
virtual void onComplete ();
|
||||
|
||||
private:
|
||||
TaskChangeStationId(); // disabled default constructor
|
||||
class ChangeStationIdQuery : public DB::Query
|
||||
{
|
||||
public:
|
||||
ChangeStationIdQuery();
|
||||
|
||||
DB::BindableLong destination_station_id; //lint !e1925 // public data member
|
||||
DB::BindableLong source_station_id; //lint !e1925 // public data member
|
||||
|
||||
virtual void getSQL (std::string &sql);
|
||||
virtual bool bindParameters ();
|
||||
virtual bool bindColumns ();
|
||||
virtual QueryMode getExecutionMode () const;
|
||||
|
||||
private: //disable
|
||||
ChangeStationIdQuery (const ChangeStationIdQuery&);
|
||||
ChangeStationIdQuery &operator= (const ChangeStationIdQuery&);
|
||||
};
|
||||
|
||||
private:
|
||||
StationId m_sourceStationId;
|
||||
StationId m_destinationStationId;
|
||||
TransferAccountData *m_requestData;
|
||||
bool m_success;
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,485 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskClaimRewards.cpp
|
||||
// copyright (c) 2004 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
#include "TaskClaimRewards.h"
|
||||
|
||||
#include "DatabaseConnection.h"
|
||||
#include "serverNetworkMessages/ClaimRewardsReplyMessage.h"
|
||||
#include "serverNetworkMessages/FeatureIdTransactionResponse.h"
|
||||
#include "sharedDatabaseInterface/Bindable.h"
|
||||
#include "sharedDatabaseInterface/BindableNetworkId.h"
|
||||
#include "sharedDatabaseInterface/DbQuery.h"
|
||||
#include "sharedDatabaseInterface/DbSession.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
namespace TaskClaimRewardsNamespace
|
||||
{
|
||||
class ConsumeEventQuery : public DB::Query
|
||||
{
|
||||
public:
|
||||
ConsumeEventQuery(StationId stationId, NetworkId const & characterId, uint32 clusterId, std::string const & eventId);
|
||||
|
||||
virtual void getSQL(std::string &sql);
|
||||
virtual bool bindParameters();
|
||||
virtual bool bindColumns();
|
||||
virtual QueryMode getExecutionMode() const;
|
||||
|
||||
bool getResult() const;
|
||||
|
||||
private:
|
||||
DB::BindableLong station_id;
|
||||
DB::BindableNetworkId character_id;
|
||||
DB::BindableLong cluster_id;
|
||||
DB::BindableString<255> event_id;
|
||||
DB::BindableLong result;
|
||||
|
||||
private: //disable
|
||||
ConsumeEventQuery();
|
||||
ConsumeEventQuery(const ConsumeEventQuery&);
|
||||
ConsumeEventQuery &operator=(const ConsumeEventQuery&);
|
||||
};
|
||||
|
||||
class ClaimItemQuery : public DB::Query
|
||||
{
|
||||
public:
|
||||
ClaimItemQuery(StationId stationId, NetworkId const & characterId, uint32 clusterId, std::string const & itemId);
|
||||
|
||||
virtual void getSQL(std::string &sql);
|
||||
virtual bool bindParameters();
|
||||
virtual bool bindColumns();
|
||||
virtual QueryMode getExecutionMode() const;
|
||||
|
||||
bool getResult() const;
|
||||
|
||||
private:
|
||||
DB::BindableLong station_id;
|
||||
DB::BindableNetworkId character_id;
|
||||
DB::BindableLong cluster_id;
|
||||
DB::BindableString<255> item_id;
|
||||
DB::BindableLong result;
|
||||
|
||||
private: //disable
|
||||
ClaimItemQuery();
|
||||
ClaimItemQuery(const ClaimItemQuery&);
|
||||
ClaimItemQuery &operator=(const ClaimItemQuery&);
|
||||
};
|
||||
|
||||
class UpdateFeatureIdTransactionQuery : public DB::Query
|
||||
{
|
||||
public:
|
||||
UpdateFeatureIdTransactionQuery(StationId stationId, NetworkId const & characterId, uint32 clusterId, std::string const & itemId, int countAdjustment);
|
||||
|
||||
virtual void getSQL(std::string &sql);
|
||||
virtual bool bindParameters();
|
||||
virtual bool bindColumns();
|
||||
virtual QueryMode getExecutionMode() const;
|
||||
|
||||
bool getResult() const;
|
||||
|
||||
private:
|
||||
DB::BindableLong station_id;
|
||||
DB::BindableNetworkId character_id;
|
||||
DB::BindableLong cluster_id;
|
||||
DB::BindableString<255> item_id;
|
||||
DB::BindableLong count_adjustment;
|
||||
DB::BindableLong result;
|
||||
|
||||
private: //disable
|
||||
UpdateFeatureIdTransactionQuery();
|
||||
UpdateFeatureIdTransactionQuery(const UpdateFeatureIdTransactionQuery&);
|
||||
UpdateFeatureIdTransactionQuery &operator=(const UpdateFeatureIdTransactionQuery&);
|
||||
};
|
||||
|
||||
class GetFeatureIdTransactionsQuery : public DB::Query
|
||||
{
|
||||
public:
|
||||
GetFeatureIdTransactionsQuery(StationId stationId, NetworkId const & characterId, uint32 clusterId);
|
||||
|
||||
DB::BindableString<255> item_id;
|
||||
DB::BindableLong count;
|
||||
|
||||
virtual void getSQL(std::string &sql);
|
||||
virtual bool bindParameters();
|
||||
virtual bool bindColumns();
|
||||
virtual QueryMode getExecutionMode() const;
|
||||
|
||||
private:
|
||||
DB::BindableLong station_id;
|
||||
DB::BindableNetworkId character_id;
|
||||
DB::BindableLong cluster_id;
|
||||
|
||||
private: //disable
|
||||
GetFeatureIdTransactionsQuery(const GetFeatureIdTransactionsQuery&);
|
||||
GetFeatureIdTransactionsQuery& operator=(const GetFeatureIdTransactionsQuery&);
|
||||
};
|
||||
}
|
||||
|
||||
using namespace TaskClaimRewardsNamespace;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskClaimRewards::TaskClaimRewards(uint32 clusterId, uint32 gameServerId, StationId stationId, NetworkId const & playerId, std::string const & rewardEvent, bool consumeEvent, std::string const & rewardItem, bool consumeItem, uint32 accountFeatureId, bool consumeAccountFeatureId, int previousAccountFeatureIdCount, int currentAccountFeatureIdCount) :
|
||||
DB::TaskRequest(),
|
||||
m_clusterId(clusterId),
|
||||
m_gameServerId(gameServerId),
|
||||
m_stationId(stationId),
|
||||
m_playerId(playerId),
|
||||
m_rewardEvent(rewardEvent),
|
||||
m_consumeEvent(consumeEvent),
|
||||
m_rewardItem(rewardItem),
|
||||
m_consumeItem(consumeItem),
|
||||
m_accountFeatureId(accountFeatureId),
|
||||
m_consumeAccountFeatureId(consumeAccountFeatureId),
|
||||
m_previousAccountFeatureIdCount(previousAccountFeatureIdCount),
|
||||
m_currentAccountFeatureIdCount(currentAccountFeatureIdCount),
|
||||
m_result(false)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskClaimRewards::process(DB::Session *session)
|
||||
{
|
||||
if (!session->setAutoCommitMode(false))
|
||||
return false;
|
||||
|
||||
// record the account feature id transaction
|
||||
if ((m_accountFeatureId > 0) && m_consumeAccountFeatureId)
|
||||
{
|
||||
UpdateFeatureIdTransactionQuery featureIdQry(m_stationId, m_playerId, m_clusterId, m_rewardItem, 1);
|
||||
if (!session->exec(&featureIdQry))
|
||||
return false;
|
||||
if (!featureIdQry.getResult())
|
||||
{
|
||||
if (!session->rollbackTransaction())
|
||||
return false;
|
||||
m_result = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// consume the event
|
||||
if (m_consumeEvent)
|
||||
{
|
||||
ConsumeEventQuery eventQry(m_stationId, m_playerId, m_clusterId, m_rewardEvent);
|
||||
if (!session->exec(&eventQry))
|
||||
return false;
|
||||
if (!eventQry.getResult())
|
||||
{
|
||||
if (!session->rollbackTransaction())
|
||||
return false;
|
||||
m_result = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// consume the item
|
||||
if (m_consumeItem)
|
||||
{
|
||||
ClaimItemQuery itemQuery(m_stationId, m_playerId, m_clusterId, m_rewardItem);
|
||||
if (!session->exec(&itemQuery))
|
||||
return false;
|
||||
if (!itemQuery.getResult())
|
||||
{
|
||||
if (!session->rollbackTransaction())
|
||||
return false;
|
||||
m_result = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!session->commitTransaction())
|
||||
return false;
|
||||
m_result = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskClaimRewards::onComplete()
|
||||
{
|
||||
// if the reward used an account feature id, we have already updated the account feature id
|
||||
// on session/Platform, so regardless if whether we were able to record the transaction
|
||||
// in the LoginServer DB or not, always send SUCCESS back to the game server for the item
|
||||
// to be granted
|
||||
ClaimRewardsReplyMessage msg(m_gameServerId, m_stationId, m_playerId, m_rewardEvent, m_rewardItem, m_accountFeatureId, m_consumeAccountFeatureId, m_previousAccountFeatureIdCount, m_currentAccountFeatureIdCount, (((m_accountFeatureId > 0) && m_consumeAccountFeatureId) ? true : m_result));
|
||||
LoginServer::getInstance().sendToCluster(m_clusterId, msg);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskFeatureIdTransactionRequest::TaskFeatureIdTransactionRequest(uint32 clusterId, StationId stationId, NetworkId const & playerId, uint32 gameServerId) :
|
||||
DB::TaskRequest(),
|
||||
m_clusterId(clusterId),
|
||||
m_stationId(stationId),
|
||||
m_playerId(playerId),
|
||||
m_gameServerId(gameServerId),
|
||||
m_transactions()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskFeatureIdTransactionRequest::process(DB::Session *session)
|
||||
{
|
||||
GetFeatureIdTransactionsQuery qry(m_stationId, m_playerId, m_clusterId);
|
||||
if (!(session->exec(&qry)))
|
||||
return false;
|
||||
|
||||
int rowsFetched;
|
||||
while ((rowsFetched = qry.fetch()) > 0)
|
||||
m_transactions[qry.item_id.getValueASCII()] = static_cast<int>(qry.count.getValue());
|
||||
|
||||
return (rowsFetched >= 0);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskFeatureIdTransactionRequest::onComplete()
|
||||
{
|
||||
FeatureIdTransactionResponse const fitr(m_gameServerId, m_playerId, m_transactions);
|
||||
LoginServer::getInstance().sendToCluster(m_clusterId, fitr);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskFeatureIdTransactionSyncUpdate::TaskFeatureIdTransactionSyncUpdate(uint32 clusterId, StationId stationId, NetworkId const & playerId, std::string const & itemId, int adjustment) :
|
||||
DB::TaskRequest(),
|
||||
m_clusterId(clusterId),
|
||||
m_stationId(stationId),
|
||||
m_playerId(playerId),
|
||||
m_itemId(itemId),
|
||||
m_adjustment(adjustment)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskFeatureIdTransactionSyncUpdate::process(DB::Session *session)
|
||||
{
|
||||
UpdateFeatureIdTransactionQuery featureIdQry(m_stationId, m_playerId, m_clusterId, m_itemId, m_adjustment);
|
||||
if (!session->exec(&featureIdQry))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskFeatureIdTransactionSyncUpdate::onComplete()
|
||||
{
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskClaimRewardsNamespace::ConsumeEventQuery::ConsumeEventQuery(StationId stationId, NetworkId const & characterId, uint32 clusterId, std::string const & eventId) :
|
||||
DB::Query(),
|
||||
station_id(static_cast<long>(stationId)),
|
||||
character_id(characterId),
|
||||
cluster_id(static_cast<long>(clusterId)),
|
||||
event_id(eventId),
|
||||
result(0)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskClaimRewardsNamespace::ConsumeEventQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql = std::string("begin :result := ")+DatabaseConnection::getInstance().getSchemaQualifier()+"login.consume_reward_event(:station_id, :character_id, :cluster_id, :event_id); end;";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskClaimRewardsNamespace::ConsumeEventQuery::bindParameters()
|
||||
{
|
||||
if (!bindParameter(result)) return false;
|
||||
if (!bindParameter(station_id)) return false;
|
||||
if (!bindParameter(character_id)) return false;
|
||||
if (!bindParameter(cluster_id)) return false;
|
||||
if (!bindParameter(event_id)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskClaimRewardsNamespace::ConsumeEventQuery::bindColumns()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
TaskClaimRewardsNamespace::ConsumeEventQuery::QueryMode TaskClaimRewardsNamespace::ConsumeEventQuery::getExecutionMode() const
|
||||
{
|
||||
return MODE_PROCEXEC;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskClaimRewardsNamespace::ConsumeEventQuery::getResult() const
|
||||
{
|
||||
return (result.getValue() != 0);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskClaimRewardsNamespace::ClaimItemQuery::ClaimItemQuery(StationId stationId, NetworkId const & characterId, uint32 clusterId, std::string const & itemId) :
|
||||
DB::Query(),
|
||||
station_id(static_cast<long>(stationId)),
|
||||
character_id(characterId),
|
||||
cluster_id(static_cast<long>(clusterId)),
|
||||
item_id(itemId),
|
||||
result(0)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskClaimRewardsNamespace::ClaimItemQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql = std::string("begin :result := ")+DatabaseConnection::getInstance().getSchemaQualifier()+"login.claim_reward_item(:station_id, :character_id, :cluster_id, :item_id); end;";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskClaimRewardsNamespace::ClaimItemQuery::bindParameters()
|
||||
{
|
||||
if (!bindParameter(result)) return false;
|
||||
if (!bindParameter(station_id)) return false;
|
||||
if (!bindParameter(character_id)) return false;
|
||||
if (!bindParameter(cluster_id)) return false;
|
||||
if (!bindParameter(item_id)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskClaimRewardsNamespace::ClaimItemQuery::bindColumns()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
TaskClaimRewardsNamespace::ClaimItemQuery::QueryMode TaskClaimRewardsNamespace::ClaimItemQuery::getExecutionMode() const
|
||||
{
|
||||
return MODE_PROCEXEC;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskClaimRewardsNamespace::ClaimItemQuery::getResult() const
|
||||
{
|
||||
return (result.getValue() != 0);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskClaimRewardsNamespace::UpdateFeatureIdTransactionQuery::UpdateFeatureIdTransactionQuery(StationId stationId, NetworkId const & characterId, uint32 clusterId, std::string const & itemId, int countAdjustment) :
|
||||
DB::Query(),
|
||||
station_id(static_cast<long>(stationId)),
|
||||
character_id(characterId),
|
||||
cluster_id(static_cast<long>(clusterId)),
|
||||
item_id(itemId),
|
||||
count_adjustment(static_cast<long>(countAdjustment)),
|
||||
result(0)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskClaimRewardsNamespace::UpdateFeatureIdTransactionQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql = std::string("begin :result := ")+DatabaseConnection::getInstance().getSchemaQualifier()+"login.update_feature_id_transaction(:station_id, :cluster_id, :character_id, :item_id, :count_adjustment); end;";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskClaimRewardsNamespace::UpdateFeatureIdTransactionQuery::bindParameters()
|
||||
{
|
||||
if (!bindParameter(result)) return false;
|
||||
if (!bindParameter(station_id)) return false;
|
||||
if (!bindParameter(cluster_id)) return false;
|
||||
if (!bindParameter(character_id)) return false;
|
||||
if (!bindParameter(item_id)) return false;
|
||||
if (!bindParameter(count_adjustment)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskClaimRewardsNamespace::UpdateFeatureIdTransactionQuery::bindColumns()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
TaskClaimRewardsNamespace::UpdateFeatureIdTransactionQuery::QueryMode TaskClaimRewardsNamespace::UpdateFeatureIdTransactionQuery::getExecutionMode() const
|
||||
{
|
||||
return MODE_PROCEXEC;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskClaimRewardsNamespace::UpdateFeatureIdTransactionQuery::getResult() const
|
||||
{
|
||||
return (result.getValue() != 0);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskClaimRewardsNamespace::GetFeatureIdTransactionsQuery::GetFeatureIdTransactionsQuery(StationId stationId, NetworkId const & characterId, uint32 clusterId) :
|
||||
DB::Query(),
|
||||
item_id(),
|
||||
count(0),
|
||||
station_id(static_cast<long>(stationId)),
|
||||
character_id(characterId),
|
||||
cluster_id(static_cast<long>(clusterId))
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskClaimRewardsNamespace::GetFeatureIdTransactionsQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql = std::string("begin :result := ")+DatabaseConnection::getInstance().getSchemaQualifier()+"login.get_feature_id_transactions(:station_id, :cluster_id, :character_id); end;";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskClaimRewardsNamespace::GetFeatureIdTransactionsQuery::bindParameters()
|
||||
{
|
||||
if (!bindParameter(station_id)) return false;
|
||||
if (!bindParameter(cluster_id)) return false;
|
||||
if (!bindParameter(character_id)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskClaimRewardsNamespace::GetFeatureIdTransactionsQuery::bindColumns()
|
||||
{
|
||||
if (!bindCol(item_id)) return false;
|
||||
if (!bindCol(count)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
TaskClaimRewardsNamespace::GetFeatureIdTransactionsQuery::QueryMode TaskClaimRewardsNamespace::GetFeatureIdTransactionsQuery::getExecutionMode() const
|
||||
{
|
||||
return MODE_PLSQL_REFCURSOR;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,92 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskClaimRewards.h
|
||||
// copyright (c) 2004 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_TaskClaimRewards_H
|
||||
#define INCLUDED_TaskClaimRewards_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedDatabaseInterface/DbTaskRequest.h"
|
||||
#include "sharedFoundation/StationId.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class TaskClaimRewards : public DB::TaskRequest
|
||||
{
|
||||
public:
|
||||
TaskClaimRewards(uint32 clusterId, uint32 gameServerId, StationId stationId, NetworkId const & playerId, std::string const & rewardEvent, bool consumeEvent, std::string const & rewardItem, bool consumeItem, uint32 accountFeatureId, bool consumeAccountFeatureId, int previousAccountFeatureIdCount, int currentAccountFeatureIdCount);
|
||||
|
||||
public:
|
||||
virtual bool process (DB::Session *session);
|
||||
virtual void onComplete ();
|
||||
|
||||
private:
|
||||
uint32 const m_clusterId;
|
||||
uint32 const m_gameServerId;
|
||||
StationId const m_stationId;
|
||||
NetworkId const m_playerId;
|
||||
std::string const m_rewardEvent;
|
||||
bool const m_consumeEvent;
|
||||
std::string const m_rewardItem;
|
||||
bool const m_consumeItem;
|
||||
uint32 const m_accountFeatureId;
|
||||
bool const m_consumeAccountFeatureId;
|
||||
int m_previousAccountFeatureIdCount;
|
||||
int m_currentAccountFeatureIdCount;
|
||||
bool m_result;
|
||||
|
||||
private:
|
||||
TaskClaimRewards(); // disabled default constructor
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class TaskFeatureIdTransactionRequest : public DB::TaskRequest
|
||||
{
|
||||
public:
|
||||
TaskFeatureIdTransactionRequest(uint32 clusterId, StationId stationId, NetworkId const & playerId, uint32 gameServerId);
|
||||
|
||||
public:
|
||||
virtual bool process (DB::Session *session);
|
||||
virtual void onComplete ();
|
||||
|
||||
private:
|
||||
uint32 const m_clusterId;
|
||||
StationId const m_stationId;
|
||||
NetworkId const m_playerId;
|
||||
uint32 const m_gameServerId;
|
||||
std::map<std::string, int> m_transactions;
|
||||
|
||||
private:
|
||||
TaskFeatureIdTransactionRequest(); // disabled default constructor
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class TaskFeatureIdTransactionSyncUpdate : public DB::TaskRequest
|
||||
{
|
||||
public:
|
||||
TaskFeatureIdTransactionSyncUpdate(uint32 clusterId, StationId stationId, NetworkId const & playerId, std::string const & itemId, int adjustment);
|
||||
|
||||
public:
|
||||
virtual bool process (DB::Session *session);
|
||||
virtual void onComplete ();
|
||||
|
||||
private:
|
||||
uint32 const m_clusterId;
|
||||
StationId const m_stationId;
|
||||
NetworkId const m_playerId;
|
||||
std::string const m_itemId;
|
||||
int const m_adjustment;
|
||||
|
||||
private:
|
||||
TaskFeatureIdTransactionSyncUpdate(); // disabled default constructor
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,112 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskCreateCharacter.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
#include "TaskCreateCharacter.h"
|
||||
|
||||
#include "LoginServer.h"
|
||||
#include "DatabaseConnection.h"
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
#include "serverNetworkMessages/LoginCreateCharacterAckMessage.h"
|
||||
#include "sharedDatabaseInterface/DbSession.h"
|
||||
#include "sharedFoundation/NetworkIdArchive.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskCreateCharacter::TaskCreateCharacter(uint32 clusterId, StationId stationId, const Unicode::String &characterName, const NetworkId &characterId, int templateId, bool jedi) :
|
||||
TaskRequest(),
|
||||
m_clusterId(clusterId),
|
||||
m_stationId(stationId),
|
||||
m_characterName(characterName),
|
||||
m_characterId(characterId),
|
||||
m_templateId(templateId),
|
||||
m_jedi(jedi)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskCreateCharacter::process(DB::Session *session)
|
||||
{
|
||||
CreateCharacterQuery qry;
|
||||
qry.cluster_id = static_cast<long>(m_clusterId);
|
||||
qry.station_id = static_cast<long>(m_stationId);
|
||||
qry.character_name = m_characterName;
|
||||
qry.character_id = m_characterId;
|
||||
qry.template_id = m_templateId;
|
||||
if (m_jedi)
|
||||
qry.character_type = 2; //TODO: Make an enum somewhere
|
||||
else
|
||||
qry.character_type = 1;
|
||||
|
||||
bool rval = session->exec(&qry);
|
||||
|
||||
qry.done();
|
||||
return rval;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskCreateCharacter::onComplete()
|
||||
{
|
||||
LoginCreateCharacterAckMessage ackMessage(m_stationId,m_characterId);
|
||||
LoginServer::getInstance().sendToCluster(m_clusterId,ackMessage);
|
||||
|
||||
// let all other galaxies know that a new character has been created for the station account
|
||||
GenericValueTypeMessage<StationId> const ncc("NewCharacterCreated", m_stationId);
|
||||
LoginServer::getInstance().sendToAllClusters(ncc, NULL, m_clusterId);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskCreateCharacter::CreateCharacterQuery::CreateCharacterQuery() :
|
||||
Query(),
|
||||
cluster_id(),
|
||||
station_id(),
|
||||
character_name(),
|
||||
character_id(),
|
||||
template_id(),
|
||||
character_type()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskCreateCharacter::CreateCharacterQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql = std::string("begin ")+DatabaseConnection::getInstance().getSchemaQualifier()+"login.create_character(:cluster_id, :station_id, :character_name, :character_id, :template_name, :character_type); end;";
|
||||
// DEBUG_REPORT_LOG(true, ("TaskCreateCharacter SQL: %s\n", sql.c_str()));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskCreateCharacter::CreateCharacterQuery::bindParameters()
|
||||
{
|
||||
if (!bindParameter(cluster_id)) return false;
|
||||
if (!bindParameter(station_id)) return false;
|
||||
if (!bindParameter(character_name)) return false;
|
||||
if (!bindParameter(character_id)) return false;
|
||||
if (!bindParameter(template_id)) return false;
|
||||
if (!bindParameter(character_type)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskCreateCharacter::CreateCharacterQuery::bindColumns()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
DB::Query::QueryMode TaskCreateCharacter::CreateCharacterQuery::getExecutionMode() const
|
||||
{
|
||||
return MODE_PROCEXEC;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,64 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskCreateCharacter.h
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_TaskCreateCharacter_H
|
||||
#define INCLUDED_TaskCreateCharacter_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedDatabaseInterface/Bindable.h"
|
||||
#include "sharedDatabaseInterface/BindableNetworkId.h"
|
||||
#include "sharedDatabaseInterface/DbQuery.h"
|
||||
#include "sharedDatabaseInterface/DbTaskRequest.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class TaskCreateCharacter : public DB::TaskRequest
|
||||
{
|
||||
public:
|
||||
TaskCreateCharacter(uint32 clusterId, StationId stationId, const Unicode::String &characterName, const NetworkId &characterId, int templateId, bool jedi);
|
||||
|
||||
public:
|
||||
virtual bool process (DB::Session *session);
|
||||
virtual void onComplete ();
|
||||
|
||||
private:
|
||||
TaskCreateCharacter(); // disabled default constructor
|
||||
class CreateCharacterQuery : public DB::Query
|
||||
{
|
||||
public:
|
||||
CreateCharacterQuery();
|
||||
|
||||
DB::BindableLong cluster_id; //lint !e1925 // public data member
|
||||
DB::BindableLong station_id; //lint !e1925 // public data member
|
||||
DB::BindableString<127> character_name; //lint !e1925 // public data member
|
||||
DB::BindableNetworkId character_id; //lint !e1925 // public data member
|
||||
DB::BindableLong template_id; //lint !e1925 // public data member
|
||||
DB::BindableLong character_type; //lint !e1925 // public data member
|
||||
|
||||
virtual void getSQL (std::string &sql);
|
||||
virtual bool bindParameters ();
|
||||
virtual bool bindColumns ();
|
||||
virtual QueryMode getExecutionMode () const;
|
||||
|
||||
private: //disable
|
||||
CreateCharacterQuery (const CreateCharacterQuery&);
|
||||
CreateCharacterQuery &operator= (const CreateCharacterQuery&);
|
||||
};
|
||||
|
||||
private:
|
||||
uint32 m_clusterId;
|
||||
StationId m_stationId;
|
||||
Unicode::String m_characterName;
|
||||
NetworkId m_characterId;
|
||||
int m_templateId;
|
||||
bool m_jedi;
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,93 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskDeleteCharacter.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
#include "TaskDeleteCharacter.h"
|
||||
|
||||
#include "ClientConnection.h"
|
||||
#include "LoginServer.h"
|
||||
#include "DatabaseConnection.h"
|
||||
#include "sharedDatabaseInterface/DbSession.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskDeleteCharacter::TaskDeleteCharacter(uint32 clusterId, const NetworkId &characterId, StationId stationId) :
|
||||
TaskRequest(),
|
||||
m_clusterId(clusterId),
|
||||
m_characterId(characterId),
|
||||
m_stationId(stationId)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskDeleteCharacter::process(DB::Session *session)
|
||||
{
|
||||
DeleteCharacterQuery qry;
|
||||
qry.cluster_id=m_clusterId; //lint !e713 // loss ofp recision unsigned long to long
|
||||
qry.character_id=m_characterId;
|
||||
qry.station_id=m_stationId; //lint !e713 // loss ofp recision unsigned long to long
|
||||
|
||||
bool rval = session->exec(&qry);
|
||||
|
||||
qry.done();
|
||||
return rval;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskDeleteCharacter::onComplete()
|
||||
{
|
||||
ClientConnection* target = LoginServer::getInstance().getValidatedClient(m_stationId);
|
||||
if (target)
|
||||
target->onCharacterDeletedFromLoginDatabase(m_characterId);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskDeleteCharacter::DeleteCharacterQuery::DeleteCharacterQuery() :
|
||||
Query(),
|
||||
cluster_id(),
|
||||
character_id(),
|
||||
station_id()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskDeleteCharacter::DeleteCharacterQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql = std::string("begin ")+DatabaseConnection::getInstance().getSchemaQualifier()+"login.delete_character(:cluster_id, :character_id, :station_id); end;";
|
||||
// DEBUG_REPORT_LOG(true, ("TaskDeleteCharacter SQL: %s\n", sql.c_str()));
|
||||
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskDeleteCharacter::DeleteCharacterQuery::bindParameters()
|
||||
{
|
||||
if (!bindParameter(cluster_id)) return false;
|
||||
if (!bindParameter(character_id)) return false;
|
||||
if (!bindParameter(station_id)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskDeleteCharacter::DeleteCharacterQuery::bindColumns()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
DB::Query::QueryMode TaskDeleteCharacter::DeleteCharacterQuery::getExecutionMode() const
|
||||
{
|
||||
return MODE_PROCEXEC;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,60 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskDeleteCharacter.h
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_TaskDeleteCharacter_H
|
||||
#define INCLUDED_TaskDeleteCharacter_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "serverNetworkMessages/AvatarList.h"
|
||||
#include "sharedDatabaseInterface/Bindable.h"
|
||||
#include "sharedDatabaseInterface/BindableNetworkId.h"
|
||||
#include "sharedDatabaseInterface/DbQuery.h"
|
||||
#include "sharedDatabaseInterface/DbTaskRequest.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class TaskDeleteCharacter : public DB::TaskRequest
|
||||
{
|
||||
public:
|
||||
TaskDeleteCharacter(uint32 clusterId, const NetworkId &characterId, StationId stationId);
|
||||
|
||||
public:
|
||||
virtual bool process (DB::Session *session);
|
||||
virtual void onComplete ();
|
||||
|
||||
private:
|
||||
TaskDeleteCharacter(); // disabled default constructor
|
||||
|
||||
class DeleteCharacterQuery : public DB::Query
|
||||
{
|
||||
public:
|
||||
DeleteCharacterQuery();
|
||||
|
||||
DB::BindableLong cluster_id; //lint !e1925 // public data member
|
||||
DB::BindableNetworkId character_id; //lint !e1925 // public data member
|
||||
DB::BindableLong station_id; //lint !e1925 // public data member
|
||||
|
||||
virtual void getSQL(std::string &sql);
|
||||
virtual bool bindParameters();
|
||||
virtual bool bindColumns();
|
||||
virtual QueryMode getExecutionMode() const;
|
||||
|
||||
private: //disable
|
||||
DeleteCharacterQuery(const DeleteCharacterQuery&);
|
||||
DeleteCharacterQuery &operator=(const DeleteCharacterQuery&);
|
||||
};
|
||||
|
||||
private:
|
||||
uint32 m_clusterId;
|
||||
NetworkId m_characterId;
|
||||
StationId m_stationId;
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,119 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskEnableCharacter.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
#include "TaskEnableCharacter.h"
|
||||
#include "CentralServerConnection.h"
|
||||
|
||||
#include "ClientConnection.h"
|
||||
#include "LoginServer.h"
|
||||
#include "DatabaseConnection.h"
|
||||
#include "sharedDatabaseInterface/DbSession.h"
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskEnableCharacter::TaskEnableCharacter(StationId &stationId, const NetworkId &characterId, const std::string &whoRequested, bool enabled, uint32 clusterId) :
|
||||
TaskRequest(),
|
||||
m_stationId(stationId),
|
||||
m_characterId(characterId),
|
||||
m_whoRequested(whoRequested),
|
||||
m_enabled(enabled),
|
||||
m_clusterId(clusterId)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskEnableCharacter::process(DB::Session *session)
|
||||
{
|
||||
EnableCharacterQuery qry;
|
||||
qry.station_id=static_cast<long>(m_stationId);
|
||||
qry.character_id=m_characterId;
|
||||
qry.enabled.setValue(m_enabled);
|
||||
|
||||
bool rval = session->exec(&qry);
|
||||
|
||||
qry.done();
|
||||
m_result = qry.result.getValue();
|
||||
return rval;
|
||||
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskEnableCharacter::onComplete()
|
||||
{
|
||||
std::string message;
|
||||
switch (m_result)
|
||||
{
|
||||
case 1:
|
||||
if (m_enabled)
|
||||
message = "Character enabled.";
|
||||
else
|
||||
message = "Character disabled.";
|
||||
break;
|
||||
|
||||
case 2:
|
||||
message = "Could not find Character";
|
||||
break;
|
||||
|
||||
default:
|
||||
message = "The database returned an unknown error code";
|
||||
break;
|
||||
}
|
||||
|
||||
GenericValueTypeMessage<std::pair<std::string, std::string> > reply("EnableCharacterReplyMessage",
|
||||
std::make_pair(m_whoRequested, message));
|
||||
LoginServer::getInstance().sendToCluster(m_clusterId, reply);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
TaskEnableCharacter::EnableCharacterQuery::EnableCharacterQuery() :
|
||||
Query(),
|
||||
station_id(),
|
||||
character_id(),
|
||||
enabled()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskEnableCharacter::EnableCharacterQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql = std::string("begin :result := ") + DatabaseConnection::getInstance().getSchemaQualifier() + "login.enable_disable_character(:station_id, :character_id, :enabled); end;";
|
||||
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskEnableCharacter::EnableCharacterQuery::bindParameters()
|
||||
{
|
||||
if (!bindParameter(result)) return false;
|
||||
if (!bindParameter(station_id)) return false;
|
||||
if (!bindParameter(character_id)) return false;
|
||||
if (!bindParameter(enabled)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskEnableCharacter::EnableCharacterQuery::bindColumns()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
DB::Query::QueryMode TaskEnableCharacter::EnableCharacterQuery::getExecutionMode() const
|
||||
{
|
||||
return MODE_PROCEXEC;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,65 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskEnableCharacter.h
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_TaskEnableCharacter_H
|
||||
#define INCLUDED_TaskEnableCharacter_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "serverNetworkMessages/AvatarList.h"
|
||||
#include "sharedDatabaseInterface/Bindable.h"
|
||||
#include "sharedDatabaseInterface/BindableNetworkId.h"
|
||||
#include "sharedDatabaseInterface/DbQuery.h"
|
||||
#include "sharedDatabaseInterface/DbTaskRequest.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class TaskEnableCharacter : public DB::TaskRequest
|
||||
{
|
||||
public:
|
||||
TaskEnableCharacter(StationId &stationId, const NetworkId &characterId, const std::string &whoRequested, bool enabled, uint32 clusterId);
|
||||
|
||||
public:
|
||||
virtual bool process (DB::Session *session);
|
||||
virtual void onComplete ();
|
||||
|
||||
private:
|
||||
TaskEnableCharacter(); // disabled default constructor
|
||||
|
||||
class EnableCharacterQuery : public DB::Query
|
||||
{
|
||||
public:
|
||||
EnableCharacterQuery();
|
||||
|
||||
DB::BindableLong station_id; //lint !e1925 // public data member : suppressed because this is a private inner class
|
||||
DB::BindableNetworkId character_id; //lint !e1925 // public data member : suppressed because this is a private inner class
|
||||
DB::BindableBool enabled; //lint !e1925 // public data member : suppressed because this is a private inner class
|
||||
DB::BindableLong result; //lint !e1925 // public data member : suppressed because this is a private inner class
|
||||
|
||||
|
||||
virtual void getSQL(std::string &sql);
|
||||
virtual bool bindParameters();
|
||||
virtual bool bindColumns();
|
||||
virtual QueryMode getExecutionMode() const;
|
||||
|
||||
private: //disable
|
||||
EnableCharacterQuery(const EnableCharacterQuery&);
|
||||
EnableCharacterQuery &operator=(const EnableCharacterQuery&);
|
||||
};
|
||||
|
||||
private:
|
||||
StationId m_stationId;
|
||||
NetworkId m_characterId;
|
||||
std::string m_whoRequested;
|
||||
bool m_enabled;
|
||||
uint32 m_clusterId;
|
||||
int m_result;
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,124 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskGetAccountForPurge.cpp
|
||||
// copyright (c) 2005 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
#include "TaskGetAccountForPurge.h"
|
||||
|
||||
#include "ConfigLoginServer.h"
|
||||
#include "DatabaseConnection.h"
|
||||
#include "PurgeManager.h"
|
||||
#include "sharedDatabaseInterface/Bindable.h"
|
||||
#include "sharedDatabaseInterface/DbQuery.h"
|
||||
#include "sharedDatabaseInterface/DbSession.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
namespace TaskGetAccountForPurgeNamespace
|
||||
{
|
||||
class GetAccountForPurgeQuery : public DB::Query
|
||||
{
|
||||
public:
|
||||
GetAccountForPurgeQuery(int purgePhase, int minAge);
|
||||
|
||||
virtual void getSQL(std::string &sql);
|
||||
virtual bool bindParameters();
|
||||
virtual bool bindColumns();
|
||||
virtual QueryMode getExecutionMode() const;
|
||||
|
||||
StationId getAccount() const;
|
||||
|
||||
private:
|
||||
DB::BindableLong m_account;
|
||||
DB::BindableLong m_min_age;
|
||||
DB::BindableLong m_purge_phase;
|
||||
|
||||
private: //disable
|
||||
GetAccountForPurgeQuery(const GetAccountForPurgeQuery&);
|
||||
GetAccountForPurgeQuery& operator=(const GetAccountForPurgeQuery&);
|
||||
};
|
||||
}
|
||||
using namespace TaskGetAccountForPurgeNamespace;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskGetAccountForPurge::TaskGetAccountForPurge(int purgePhase) :
|
||||
DB::TaskRequest(),
|
||||
m_purgePhase(purgePhase)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskGetAccountForPurge::process(DB::Session *session)
|
||||
{
|
||||
GetAccountForPurgeQuery qry(m_purgePhase, ConfigLoginServer::getPurgePhaseAdvanceDays(m_purgePhase));
|
||||
if (!session->exec(&qry))
|
||||
return false;
|
||||
m_account = qry.getAccount();
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskGetAccountForPurge::onComplete()
|
||||
{
|
||||
PurgeManager::onGetAccountForPurge(m_account, m_purgePhase);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
|
||||
GetAccountForPurgeQuery::GetAccountForPurgeQuery(int purgePhase, int minAge) :
|
||||
Query(),
|
||||
m_account(),
|
||||
m_min_age(minAge),
|
||||
m_purge_phase(purgePhase)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void GetAccountForPurgeQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql=std::string("begin :account := ")+DatabaseConnection::getInstance().getSchemaQualifier()+"purge_process.get_account_for_purge(:purge_phase, :min_age); end;";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool GetAccountForPurgeQuery::bindParameters()
|
||||
{
|
||||
if (!bindParameter(m_account)) return false;
|
||||
if (!bindParameter(m_purge_phase)) return false;
|
||||
if (!bindParameter(m_min_age)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool GetAccountForPurgeQuery::bindColumns()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
GetAccountForPurgeQuery::QueryMode GetAccountForPurgeQuery::getExecutionMode() const
|
||||
{
|
||||
return MODE_PROCEXEC;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
StationId GetAccountForPurgeQuery::getAccount() const
|
||||
{
|
||||
if (!m_account.isNull())
|
||||
return m_account.getValue();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,29 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskGetAccountForPurge.h
|
||||
// copyright (c) 2005 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_TaskGetAccountForPurge_H
|
||||
#define INCLUDED_TaskGetAccountForPurge_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedDatabaseInterface/DbTaskRequest.h"
|
||||
|
||||
class TaskGetAccountForPurge : public DB::TaskRequest
|
||||
{
|
||||
public:
|
||||
explicit TaskGetAccountForPurge(int purgePhase);
|
||||
virtual bool process (DB::Session *session);
|
||||
virtual void onComplete ();
|
||||
|
||||
private:
|
||||
int m_purgePhase;
|
||||
StationId m_account;
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,221 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskGetAvatarList.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
#include "TaskGetAvatarList.h"
|
||||
|
||||
#include "serverNetworkMessages/AvatarList.h"
|
||||
#include "CentralServerConnection.h"
|
||||
#include "DatabaseConnection.h"
|
||||
#include "sharedLog/Log.h"
|
||||
#include "serverNetworkMessages/TransferAccountData.h"
|
||||
#include "serverNetworkMessages/TransferAccountDataArchive.h"
|
||||
#include "serverNetworkMessages/TransferCharacterData.h"
|
||||
#include "sharedDatabaseInterface/DbSession.h"
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
#include "TaskUpgradeAccount.h"
|
||||
#include <vector>
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskGetAvatarList::TaskGetAvatarList (StationId stationId, int clusterGroupId, const TransferCharacterData * transferCharacterData) :
|
||||
TaskRequest(),
|
||||
m_stationId(stationId),
|
||||
m_stationIdNumberJediSlot(0),
|
||||
m_clusterGroupId(clusterGroupId),
|
||||
m_avatars(),
|
||||
m_transferCharacterData(0),
|
||||
m_transferAccountData(0)
|
||||
{
|
||||
if(transferCharacterData)
|
||||
{
|
||||
m_transferCharacterData = new TransferCharacterData(*transferCharacterData);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
TaskGetAvatarList::TaskGetAvatarList (int clusterGroupId, const TransferAccountData * transferAccountData) :
|
||||
TaskRequest(),
|
||||
m_stationId(),
|
||||
m_stationIdNumberJediSlot(0),
|
||||
m_clusterGroupId(clusterGroupId),
|
||||
m_avatars(),
|
||||
m_transferCharacterData(0),
|
||||
m_transferAccountData(0)
|
||||
{
|
||||
if(transferAccountData)
|
||||
{
|
||||
m_transferAccountData = new TransferAccountData(*transferAccountData);
|
||||
m_stationId = m_transferAccountData->getSourceStationId();
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
TaskGetAvatarList::~TaskGetAvatarList()
|
||||
{
|
||||
delete m_transferCharacterData;
|
||||
m_transferCharacterData = 0;
|
||||
delete m_transferAccountData;
|
||||
m_transferAccountData = 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskGetAvatarList::process(DB::Session *session)
|
||||
{
|
||||
if (m_transferAccountData)
|
||||
{
|
||||
// if we are doing an account transfer, we need to also check the number of avatars in the destination station id
|
||||
GetCharactersQuery qry;
|
||||
int rowsFetched;
|
||||
|
||||
qry.station_id = m_transferAccountData->getDestinationStationId();
|
||||
qry.cluster_group_id = m_clusterGroupId;
|
||||
|
||||
if (! (session->exec(&qry)))
|
||||
return false;
|
||||
|
||||
bool hasAvatars = false;
|
||||
while ((rowsFetched = qry.fetch()) > 0)
|
||||
{
|
||||
hasAvatars = true;
|
||||
}
|
||||
|
||||
m_transferAccountData->setDestinationHasAvatars(hasAvatars);
|
||||
}
|
||||
|
||||
m_stationIdNumberJediSlot = 0;
|
||||
if (!m_transferAccountData)
|
||||
{
|
||||
TaskUpgradeAccount::QueryJediQuery qryHasJediSlot;
|
||||
qryHasJediSlot.station_id = m_stationId; //lint !e713 // loss of precision unsigned long to long
|
||||
qryHasJediSlot.character_type = 2;
|
||||
|
||||
if (session->exec(&qryHasJediSlot))
|
||||
{
|
||||
m_stationIdNumberJediSlot = qryHasJediSlot.result.getValue();
|
||||
}
|
||||
|
||||
qryHasJediSlot.done();
|
||||
}
|
||||
|
||||
GetCharactersQuery qry;
|
||||
int rowsFetched;
|
||||
|
||||
qry.station_id = m_stationId; //lint !e713 // loss of precision unsigned long to long
|
||||
qry.cluster_group_id = m_clusterGroupId;
|
||||
|
||||
if (! (session->exec(&qry)))
|
||||
return false;
|
||||
|
||||
AvatarRecord temp;
|
||||
|
||||
while ((rowsFetched = qry.fetch()) > 0)
|
||||
{
|
||||
qry.character_name.getValue(temp.m_name);
|
||||
qry.object_template_id.getValue(temp.m_objectTemplateId);
|
||||
qry.object_id.getValue(temp.m_networkId);
|
||||
qry.cluster_id.getValue(temp.m_clusterId);
|
||||
qry.character_type.getValue(temp.m_characterType);
|
||||
|
||||
m_avatars.push_back(temp);
|
||||
}
|
||||
return (rowsFetched >= 0);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskGetAvatarList::onComplete()
|
||||
{
|
||||
if (m_transferAccountData)
|
||||
{
|
||||
if (m_transferAccountData->getDestinationHasAvatars())
|
||||
{
|
||||
// send a message back to the transfer server
|
||||
LOG("CustomerService", ("CharacterTransfer: Cannot complete account transfer from %lu to %lu: destination stationId contains avatars\n", m_transferAccountData->getSourceStationId(), m_transferAccountData->getDestinationStationId()));
|
||||
const GenericValueTypeMessage<TransferAccountData> response("TransferAccountFailedDestinationNotEmpty", *m_transferAccountData);
|
||||
CentralServerConnection::sendToCentralServer(m_transferAccountData->getStartGalaxy(), response);
|
||||
}
|
||||
else
|
||||
DatabaseConnection::getInstance().onAvatarListRetrievedAccountTransfer(m_avatars, m_transferAccountData);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
DatabaseConnection::getInstance().onAvatarListRetrieved(m_stationId, m_stationIdNumberJediSlot, m_avatars, m_transferCharacterData);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
AvatarList const & TaskGetAvatarList::getAvatars() const
|
||||
{
|
||||
return m_avatars;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
StationId TaskGetAvatarList::getStationId() const
|
||||
{
|
||||
return m_stationId;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
void TaskGetAvatarList::GetCharactersQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql=std::string("begin :result := ")+DatabaseConnection::getInstance().getSchemaQualifier()+"login.get_avatar_list(:station_id, :cluster_group_id); end;";
|
||||
// DEBUG_REPORT_LOG(true, ("TaskGetAvatarList SQL: %s\n", sql.c_str()));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskGetAvatarList::GetCharactersQuery::bindParameters()
|
||||
{
|
||||
if (!bindParameter(station_id)) return false;
|
||||
if (!bindParameter(cluster_group_id)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskGetAvatarList::GetCharactersQuery::bindColumns()
|
||||
{
|
||||
if (!bindCol(character_name)) return false;
|
||||
if (!bindCol(object_template_id)) return false;
|
||||
if (!bindCol(object_id)) return false;
|
||||
if (!bindCol(cluster_id)) return false;
|
||||
if (!bindCol(character_type)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
DB::Query::QueryMode TaskGetAvatarList::GetCharactersQuery::getExecutionMode() const
|
||||
{
|
||||
return MODE_PLSQL_REFCURSOR;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
TaskGetAvatarList::GetCharactersQuery::GetCharactersQuery() :
|
||||
Query(),
|
||||
station_id(),
|
||||
cluster_group_id(),
|
||||
character_name(),
|
||||
object_template_id(),
|
||||
object_id(),
|
||||
cluster_id(),
|
||||
character_type()
|
||||
{
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,74 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskGetAvatarList.h
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_TaskGetAvatarList_H
|
||||
#define INCLUDED_TaskGetAvatarList_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "serverNetworkMessages/AvatarList.h"
|
||||
#include "sharedDatabaseInterface/Bindable.h"
|
||||
#include "sharedDatabaseInterface/BindableNetworkId.h"
|
||||
#include "sharedDatabaseInterface/DbQuery.h"
|
||||
#include "sharedDatabaseInterface/DbTaskRequest.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class TransferAccountData;
|
||||
class TransferCharacterData;
|
||||
|
||||
class TaskGetAvatarList : public DB::TaskRequest
|
||||
{
|
||||
public:
|
||||
explicit TaskGetAvatarList (StationId stationId, int clusterGroupId, const TransferCharacterData * transferCharacterData);
|
||||
explicit TaskGetAvatarList (int clusterGroupId, const TransferAccountData * transferAccountData);
|
||||
virtual ~TaskGetAvatarList ();
|
||||
|
||||
public:
|
||||
virtual bool process (DB::Session *session);
|
||||
virtual void onComplete ();
|
||||
AvatarList const & getAvatars() const;
|
||||
StationId getStationId() const;
|
||||
|
||||
class GetCharactersQuery : public DB::Query
|
||||
{
|
||||
public:
|
||||
DB::BindableLong station_id; //lint !e1925 // public data member
|
||||
DB::BindableLong cluster_group_id; //lint !e1925 // public data member
|
||||
DB::BindableString<128> character_name; //lint !e1925 // public data member
|
||||
DB::BindableLong object_template_id; //lint !e1925 // public data member
|
||||
DB::BindableNetworkId object_id; //lint !e1925 // public data member
|
||||
DB::BindableLong cluster_id; //lint !e1925 // public data member
|
||||
DB::BindableLong character_type; //lint !e1925 // public data member
|
||||
|
||||
GetCharactersQuery();
|
||||
|
||||
virtual void getSQL(std::string &sql);
|
||||
virtual bool bindParameters();
|
||||
virtual bool bindColumns();
|
||||
virtual QueryMode getExecutionMode() const;
|
||||
|
||||
private: //disable
|
||||
GetCharactersQuery(const GetCharactersQuery&);
|
||||
GetCharactersQuery& operator=(const GetCharactersQuery&);
|
||||
};
|
||||
|
||||
private:
|
||||
TaskGetAvatarList(); // disabled default constructor
|
||||
TaskGetAvatarList(const TaskGetAvatarList &);
|
||||
TaskGetAvatarList & operator= (const TaskGetAvatarList &);
|
||||
StationId m_stationId;
|
||||
int m_stationIdNumberJediSlot;
|
||||
int m_clusterGroupId;
|
||||
AvatarList m_avatars;
|
||||
TransferCharacterData * m_transferCharacterData;
|
||||
TransferAccountData * m_transferAccountData;
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,42 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskGetCharactersForDelete.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
#include "TaskGetCharactersForDelete.h"
|
||||
|
||||
#include "PurgeManager.h"
|
||||
#include "serverNetworkMessages/AvatarList.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskGetCharactersForDelete::TaskGetCharactersForDelete (StationId stationId, int clusterGroupId) :
|
||||
TaskGetAvatarList(stationId, clusterGroupId, NULL)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
TaskGetCharactersForDelete::~TaskGetCharactersForDelete()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskGetCharactersForDelete::onComplete()
|
||||
{
|
||||
bool success=true;
|
||||
AvatarList const & theList = getAvatars();
|
||||
for (AvatarList::const_iterator i=theList.begin(); i!=theList.end(); ++i)
|
||||
{
|
||||
if (!LoginServer::getInstance().deleteCharacter(i->m_clusterId, i->m_networkId, getStationId()))
|
||||
success=false;
|
||||
}
|
||||
|
||||
PurgeManager::onAllCharactersDeleted(getStationId(), success);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,29 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskGetCharactersForDelete.h
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_TaskGetCharactersForDelete_H
|
||||
#define INCLUDED_TaskGetCharactersForDelete_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "TaskGetAvatarList.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class TaskGetCharactersForDelete : public TaskGetAvatarList
|
||||
{
|
||||
public:
|
||||
explicit TaskGetCharactersForDelete (StationId stationId, int clusterGroupId);
|
||||
virtual ~TaskGetCharactersForDelete ();
|
||||
|
||||
public:
|
||||
virtual void onComplete ();
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,137 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskGetClusterList.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
#include "TaskGetClusterList.h"
|
||||
|
||||
#include "serverNetworkMessages/AvatarList.h"
|
||||
#include "ConfigLoginServer.h"
|
||||
#include "DatabaseConnection.h"
|
||||
#include "sharedDatabaseInterface/DbSession.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskGetClusterList::TaskGetClusterList (int const groupId) :
|
||||
TaskRequest(),
|
||||
m_clusterData(),
|
||||
m_groupId(groupId)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskGetClusterList::process(DB::Session *session)
|
||||
{
|
||||
GetClustersQuery qry;
|
||||
int rowsFetched;
|
||||
|
||||
qry.group_id = m_groupId;
|
||||
|
||||
if (! (session->exec(&qry)))
|
||||
return false;
|
||||
|
||||
ClusterData temp;
|
||||
|
||||
while ((rowsFetched = qry.fetch()) > 0)
|
||||
{
|
||||
qry.cluster_id.getValue(temp.m_clusterId);
|
||||
qry.cluster_name.getValue(temp.m_clusterName);
|
||||
qry.address.getValue(temp.m_address);
|
||||
if (qry.port.isNull())
|
||||
temp.m_port = ConfigLoginServer::getCentralServicePort();
|
||||
else
|
||||
temp.m_port = static_cast<uint16>(qry.port.getValue());
|
||||
qry.secret.getValue(temp.m_secret);
|
||||
qry.locked.getValue(temp.m_locked);
|
||||
qry.not_recommended.getValue(temp.m_notRecommended);
|
||||
qry.maxCharacterPerAccount.getValue(temp.m_maxCharactersPerAccount);
|
||||
qry.online_player_limit.getValue(temp.m_onlinePlayerLimit);
|
||||
qry.online_free_trial_limit.getValue(temp.m_onlineFreeTrialLimit);
|
||||
qry.free_trial_can_create_char.getValue(temp.m_freeTrialCanCreateChar);
|
||||
qry.online_tutorial_limit.getValue(temp.m_onlineTutorialLimit);
|
||||
|
||||
m_clusterData.push_back(temp);
|
||||
}
|
||||
return (rowsFetched >= 0);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskGetClusterList::onComplete()
|
||||
{
|
||||
for (std::vector<ClusterData>::const_iterator i=m_clusterData.begin(); i!= m_clusterData.end(); ++i)
|
||||
{
|
||||
FATAL(i->m_clusterId<1,("Cluster id %i was specified in the database for cluster \"%s\". 1 is the minimum legal cluster id",i->m_clusterId, i->m_clusterName.c_str()));
|
||||
LoginServer::getInstance().updateClusterData((*i).m_clusterId, (*i).m_clusterName, (*i).m_address, (*i).m_port, (*i).m_secret, (*i).m_locked, (*i).m_notRecommended, (*i).m_maxCharactersPerAccount, (*i).m_onlinePlayerLimit, (*i).m_onlineFreeTrialLimit, (*i).m_freeTrialCanCreateChar, (*i).m_onlineTutorialLimit);
|
||||
}
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
void TaskGetClusterList::GetClustersQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql=std::string("begin :result := ")+DatabaseConnection::getInstance().getSchemaQualifier()+"login.get_cluster_list(:group_id); end;";
|
||||
// DEBUG_REPORT_LOG(true, ("TaskGetClusterList SQL: %s\n", sql.c_str()));
|
||||
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskGetClusterList::GetClustersQuery::bindParameters()
|
||||
{
|
||||
if (!bindParameter(group_id)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskGetClusterList::GetClustersQuery::bindColumns()
|
||||
{
|
||||
if (!bindCol(cluster_id)) return false;
|
||||
if (!bindCol(cluster_name)) return false;
|
||||
if (!bindCol(address)) return false;
|
||||
if (!bindCol(port)) return false;
|
||||
if (!bindCol(secret)) return false;
|
||||
if (!bindCol(locked)) return false;
|
||||
if (!bindCol(not_recommended)) return false;
|
||||
if (!bindCol(maxCharacterPerAccount)) return false;
|
||||
if (!bindCol(online_player_limit)) return false;
|
||||
if (!bindCol(online_free_trial_limit)) return false;
|
||||
if (!bindCol(free_trial_can_create_char)) return false;
|
||||
if (!bindCol(online_tutorial_limit)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
DB::Query::QueryMode TaskGetClusterList::GetClustersQuery::getExecutionMode() const
|
||||
{
|
||||
return MODE_PLSQL_REFCURSOR;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
TaskGetClusterList::GetClustersQuery::GetClustersQuery() :
|
||||
Query(),
|
||||
group_id(),
|
||||
cluster_id(),
|
||||
cluster_name(),
|
||||
address(),
|
||||
port(),
|
||||
secret(),
|
||||
locked(),
|
||||
not_recommended(),
|
||||
maxCharacterPerAccount(),
|
||||
online_player_limit(),
|
||||
online_free_trial_limit(),
|
||||
free_trial_can_create_char(),
|
||||
online_tutorial_limit()
|
||||
{
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,86 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskGetClusterList.h
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_TaskGetClusterList_H
|
||||
#define INCLUDED_TaskGetClusterList_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "serverNetworkMessages/AvatarList.h"
|
||||
#include "sharedDatabaseInterface/Bindable.h"
|
||||
#include "sharedDatabaseInterface/BindableNetworkId.h"
|
||||
#include "sharedDatabaseInterface/DbQuery.h"
|
||||
#include "sharedDatabaseInterface/DbTaskRequest.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class TaskGetClusterList : public DB::TaskRequest
|
||||
{
|
||||
public:
|
||||
explicit TaskGetClusterList (int groupId);
|
||||
|
||||
public:
|
||||
virtual bool process (DB::Session *session);
|
||||
virtual void onComplete ();
|
||||
|
||||
private:
|
||||
class GetClustersQuery : public DB::Query
|
||||
{
|
||||
public:
|
||||
DB::BindableLong group_id; //lint !e1925 // public data member
|
||||
|
||||
DB::BindableLong cluster_id; //lint !e1925 // public data member
|
||||
DB::BindableString<255> cluster_name; //lint !e1925 // public data member
|
||||
DB::BindableString<255> address; //lint !e1925 // public data member
|
||||
DB::BindableLong port; //lint !e1925 // public data member
|
||||
DB::BindableBool secret; //lint !e1925 // public data member
|
||||
DB::BindableBool locked; //lint !e1925 // public data member
|
||||
DB::BindableBool not_recommended; //lint !e1925 // public data member
|
||||
DB::BindableLong maxCharacterPerAccount; //lint !e1925 // public data member
|
||||
DB::BindableLong online_player_limit; //lint !e1925 // public data member
|
||||
DB::BindableLong online_free_trial_limit; //lint !e1925 // public data member
|
||||
DB::BindableBool free_trial_can_create_char; //lint !e1925 // public data member
|
||||
DB::BindableLong online_tutorial_limit; //lint !e1925 // public data member
|
||||
|
||||
GetClustersQuery();
|
||||
|
||||
virtual void getSQL(std::string &sql);
|
||||
virtual bool bindParameters();
|
||||
virtual bool bindColumns();
|
||||
virtual QueryMode getExecutionMode() const;
|
||||
|
||||
private: //disable
|
||||
GetClustersQuery(const GetClustersQuery&);
|
||||
GetClustersQuery& operator=(const GetClustersQuery&);
|
||||
};
|
||||
|
||||
struct ClusterData
|
||||
{
|
||||
uint32 m_clusterId;
|
||||
std::string m_clusterName;
|
||||
std::string m_address;
|
||||
uint16 m_port;
|
||||
bool m_secret;
|
||||
bool m_locked;
|
||||
bool m_notRecommended;
|
||||
int m_maxCharactersPerAccount;
|
||||
int m_onlinePlayerLimit;
|
||||
int m_onlineFreeTrialLimit;
|
||||
bool m_freeTrialCanCreateChar;
|
||||
int m_onlineTutorialLimit;
|
||||
};
|
||||
|
||||
std::vector<ClusterData> m_clusterData;
|
||||
int m_groupId;
|
||||
|
||||
private:
|
||||
TaskGetClusterList (); // disable
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,591 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskGetValidationData.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
#include "TaskGetValidationData.h"
|
||||
|
||||
#include "ConfigLoginServer.h"
|
||||
#include "DatabaseConnection.h"
|
||||
#include "TaskGetAvatarList.h"
|
||||
#include "TaskUpgradeAccount.h"
|
||||
#include "serverNetworkMessages/AvatarList.h"
|
||||
#include "serverNetworkMessages/TransferRequestMoveValidation.h"
|
||||
#include "sharedDatabaseInterface/BindableNetworkId.h"
|
||||
#include "sharedDatabaseInterface/DbSession.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
namespace TaskGetValidationDataNamespace
|
||||
{
|
||||
class GetValidationDataQuery : public DB::Query
|
||||
{
|
||||
public:
|
||||
GetValidationDataQuery();
|
||||
|
||||
DB::BindableLong station_id; //lint !e1925 // public data member
|
||||
DB::BindableLong cluster_id; //lint !e1925 // public data member
|
||||
DB::BindableLong character_type_id; //lint !e1925 // public data member
|
||||
DB::BindableLong num_open_slots; //lint !e1925 // public data member
|
||||
|
||||
virtual void getSQL(std::string &sql);
|
||||
virtual bool bindParameters();
|
||||
virtual bool bindColumns();
|
||||
virtual QueryMode getExecutionMode() const;
|
||||
|
||||
private: //disable
|
||||
GetValidationDataQuery(const GetValidationDataQuery&);
|
||||
GetValidationDataQuery &operator=(const GetValidationDataQuery&);
|
||||
};
|
||||
|
||||
class GetCompletedTutorialQuery : public DB::Query
|
||||
{
|
||||
public:
|
||||
GetCompletedTutorialQuery(StationId stationId);
|
||||
|
||||
DB::BindableLong station_id;
|
||||
DB::BindableBool completed_tutorial;
|
||||
|
||||
virtual void getSQL(std::string &sql);
|
||||
virtual bool bindParameters();
|
||||
virtual bool bindColumns();
|
||||
virtual QueryMode getExecutionMode() const;
|
||||
|
||||
private: //disable
|
||||
GetCompletedTutorialQuery(const GetCompletedTutorialQuery&);
|
||||
GetCompletedTutorialQuery &operator=(const GetCompletedTutorialQuery&);
|
||||
};
|
||||
|
||||
class GetConsumedRewardEventsQuery : public DB::Query
|
||||
{
|
||||
public:
|
||||
explicit GetConsumedRewardEventsQuery(StationId stationId);
|
||||
|
||||
virtual void getSQL(std::string &sql);
|
||||
virtual bool bindParameters();
|
||||
virtual bool bindColumns();
|
||||
virtual QueryMode getExecutionMode() const;
|
||||
|
||||
std::string getEventId() const;
|
||||
uint32 getClusterId() const;
|
||||
NetworkId const getCharacterId() const;
|
||||
|
||||
private:
|
||||
DB::BindableLong station_id;
|
||||
DB::BindableString<100> event_id;
|
||||
DB::BindableLong cluster_id;
|
||||
DB::BindableNetworkId character_id;
|
||||
|
||||
private: //disable
|
||||
GetConsumedRewardEventsQuery();
|
||||
GetConsumedRewardEventsQuery(const GetConsumedRewardEventsQuery&);
|
||||
GetConsumedRewardEventsQuery &operator=(const GetConsumedRewardEventsQuery&);
|
||||
};
|
||||
|
||||
class GetClaimedRewardItemsQuery : public DB::Query
|
||||
{
|
||||
public:
|
||||
explicit GetClaimedRewardItemsQuery(StationId stationId);
|
||||
|
||||
virtual void getSQL(std::string &sql);
|
||||
virtual bool bindParameters();
|
||||
virtual bool bindColumns();
|
||||
virtual QueryMode getExecutionMode() const;
|
||||
|
||||
std::string getItemId() const;
|
||||
uint32 getClusterId() const;
|
||||
NetworkId const getCharacterId() const;
|
||||
|
||||
private:
|
||||
DB::BindableLong station_id;
|
||||
DB::BindableString<100> item_id;
|
||||
DB::BindableLong cluster_id;
|
||||
DB::BindableNetworkId character_id;
|
||||
|
||||
private: //disable
|
||||
GetClaimedRewardItemsQuery();
|
||||
GetClaimedRewardItemsQuery(const GetClaimedRewardItemsQuery&);
|
||||
GetClaimedRewardItemsQuery &operator=(const GetClaimedRewardItemsQuery&);
|
||||
};
|
||||
|
||||
class IsClusterAtLimitQuery : public DB::Query
|
||||
{
|
||||
public:
|
||||
IsClusterAtLimitQuery();
|
||||
|
||||
DB::BindableLong cluster_id; //lint !e1925 // public data member
|
||||
DB::BindableLong result; //lint !e1925 // public data member
|
||||
|
||||
virtual void getSQL (std::string &sql);
|
||||
virtual bool bindParameters ();
|
||||
virtual bool bindColumns ();
|
||||
virtual QueryMode getExecutionMode () const;
|
||||
|
||||
private: //disable
|
||||
IsClusterAtLimitQuery (const IsClusterAtLimitQuery&);
|
||||
IsClusterAtLimitQuery &operator= (const IsClusterAtLimitQuery&);
|
||||
};
|
||||
}
|
||||
|
||||
using namespace TaskGetValidationDataNamespace;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskGetValidationData::TaskGetValidationData (StationId stationId, int clusterGroupId, uint32 clusterId, unsigned int track, uint32 subscriptionBits) :
|
||||
TaskRequest(),
|
||||
m_stationId(stationId),
|
||||
m_clusterGroupId(clusterGroupId),
|
||||
m_clusterId(clusterId),
|
||||
m_openCharacterSlots(4,0),
|
||||
m_canSkipTutorial(false),
|
||||
m_track(track),
|
||||
m_subscriptionBits(subscriptionBits),
|
||||
m_transferRequest(0),
|
||||
m_transferRequestSourceCharacterTemplateId(0),
|
||||
m_consumedRewardEvents(),
|
||||
m_claimedRewardItems()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
TaskGetValidationData::TaskGetValidationData(const TransferRequestMoveValidation & request, int clusterGroupId, uint32 clusterId) :
|
||||
TaskRequest(),
|
||||
m_stationId(request.getDestinationStationId()),
|
||||
m_clusterGroupId(clusterGroupId),
|
||||
m_clusterId(clusterId),
|
||||
m_openCharacterSlots(4,0),
|
||||
m_canSkipTutorial(true),
|
||||
m_track(request.getTrack()),
|
||||
m_transferRequest(0),
|
||||
m_transferRequestSourceCharacterTemplateId(request.getSourceCharacterTemplateId()),
|
||||
m_consumedRewardEvents(),
|
||||
m_claimedRewardItems()
|
||||
{
|
||||
Archive::ByteStream bs;
|
||||
request.pack(bs);
|
||||
Archive::ReadIterator ri(bs);
|
||||
m_transferRequest = new TransferRequestMoveValidation(ri);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
TaskGetValidationData::~TaskGetValidationData()
|
||||
{
|
||||
delete m_transferRequest;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskGetValidationData::process(DB::Session *session)
|
||||
{
|
||||
// if this is a same account transfer request, use a different check
|
||||
// for available character slots; specifically, don't enforce the max
|
||||
// characters per account rule because this is a same account transfer
|
||||
// and after everything is said and done, the number of characters on
|
||||
// the account will not change
|
||||
if (m_transferRequest && (m_transferRequest->getSourceStationId() == m_transferRequest->getDestinationStationId()))
|
||||
{
|
||||
IsClusterAtLimitQuery clusterLimitQry;
|
||||
clusterLimitQry.cluster_id = static_cast<long>(m_clusterId);
|
||||
|
||||
if (!(session->exec(&clusterLimitQry)))
|
||||
return false;
|
||||
|
||||
clusterLimitQry.done();
|
||||
|
||||
if (clusterLimitQry.result.getValue() == 0)
|
||||
{
|
||||
// cluster is not at limit, check per account per cluster limit
|
||||
TaskVacateUnlockedSlot::GetOnlyOpenCharacterSlotsQuery qry;
|
||||
qry.station_id = static_cast<long>(m_stationId);
|
||||
qry.cluster_id = static_cast<long>(m_clusterId);
|
||||
|
||||
int rowsFetched;
|
||||
if (! (session->exec(&qry)))
|
||||
return false;
|
||||
while ((rowsFetched = qry.fetch()) > 0)
|
||||
m_openCharacterSlots[static_cast<unsigned long>(qry.character_type_id.getValue())]=qry.num_open_slots.getValue();
|
||||
qry.done();
|
||||
if (rowsFetched < 0)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GetValidationDataQuery qry;
|
||||
qry.station_id = static_cast<long>(m_stationId);
|
||||
qry.cluster_id = static_cast<long>(m_clusterId);
|
||||
|
||||
int rowsFetched;
|
||||
if (! (session->exec(&qry)))
|
||||
return false;
|
||||
while ((rowsFetched = qry.fetch()) > 0)
|
||||
m_openCharacterSlots[static_cast<unsigned long>(qry.character_type_id.getValue())]=qry.num_open_slots.getValue();
|
||||
qry.done();
|
||||
if (rowsFetched < 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
// if transfer request and the source character
|
||||
// template id hasn't been specified, retrieve it
|
||||
if (m_transferRequest && (m_openCharacterSlots[1] > 0) && (m_transferRequestSourceCharacterTemplateId == 0))
|
||||
{
|
||||
uint32 const sourceClusterId = LoginServer::getInstance().getClusterIDByName(m_transferRequest->getSourceGalaxy());
|
||||
|
||||
TaskGetAvatarList::GetCharactersQuery qryGetCharacters;
|
||||
qryGetCharacters.station_id = m_transferRequest->getSourceStationId(); //lint !e713 // loss of precision unsigned long to long
|
||||
qryGetCharacters.cluster_group_id = m_clusterGroupId;
|
||||
|
||||
if (!session->exec(&qryGetCharacters))
|
||||
return false;
|
||||
|
||||
uint32 characterClusterId;
|
||||
std::string characterName;
|
||||
int rowsFetched;
|
||||
while ((rowsFetched = qryGetCharacters.fetch()) > 0)
|
||||
{
|
||||
qryGetCharacters.cluster_id.getValue(characterClusterId);
|
||||
if (characterClusterId == sourceClusterId)
|
||||
{
|
||||
qryGetCharacters.character_name.getValue(characterName);
|
||||
if (characterName == m_transferRequest->getSourceCharacter())
|
||||
{
|
||||
qryGetCharacters.object_template_id.getValue(m_transferRequestSourceCharacterTemplateId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
qryGetCharacters.done();
|
||||
}
|
||||
|
||||
if (!m_transferRequest)
|
||||
{
|
||||
GetConsumedRewardEventsQuery eventQuery(m_stationId);
|
||||
int rowsFetched;
|
||||
if (! (session->exec(&eventQuery)))
|
||||
return false;
|
||||
while ((rowsFetched = eventQuery.fetch()) > 0)
|
||||
{
|
||||
// If the event was claimed on this cluster, tell the cluster the network ID of the character that claimed it.
|
||||
// If claimed on another cluster, hide the network ID because it's not meaningful
|
||||
NetworkId const characterId = eventQuery.getClusterId()==m_clusterId ? eventQuery.getCharacterId() : NetworkId::cms_invalid;
|
||||
m_consumedRewardEvents.push_back(std::make_pair(characterId, eventQuery.getEventId()));
|
||||
}
|
||||
eventQuery.done();
|
||||
if (rowsFetched < 0)
|
||||
return false;
|
||||
|
||||
GetClaimedRewardItemsQuery itemQuery(m_stationId);
|
||||
if (! (session->exec(&itemQuery)))
|
||||
return false;
|
||||
while ((rowsFetched = itemQuery.fetch()) > 0)
|
||||
{
|
||||
NetworkId const characterId = itemQuery.getClusterId()==m_clusterId ? itemQuery.getCharacterId() : NetworkId::cms_invalid;
|
||||
m_claimedRewardItems.push_back(std::make_pair(characterId, itemQuery.getItemId()));
|
||||
}
|
||||
itemQuery.done();
|
||||
if (rowsFetched < 0)
|
||||
return false;
|
||||
|
||||
// check to see if the account can skip the tutorial or not
|
||||
GetCompletedTutorialQuery tutorialQuery(m_stationId);
|
||||
if (! (session->exec(&tutorialQuery)))
|
||||
return false;
|
||||
while ((rowsFetched = tutorialQuery.fetch()) > 0)
|
||||
{
|
||||
tutorialQuery.completed_tutorial.getValue(m_canSkipTutorial);
|
||||
}
|
||||
tutorialQuery.done();
|
||||
if (rowsFetched < 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskGetValidationData::onComplete()
|
||||
{
|
||||
bool canCreateNormal=false;
|
||||
bool canCreateJedi=false;
|
||||
if (m_openCharacterSlots[1] > 0)
|
||||
canCreateNormal=true;
|
||||
if (m_openCharacterSlots[2] > 0 && m_openCharacterSlots[3] > 0)
|
||||
canCreateJedi=true;
|
||||
|
||||
// check to see if character creation has been disabled for the cluster
|
||||
if (ConfigLoginServer::isCharacterCreationDisabled(LoginServer::getInstance().getClusterNameById(m_clusterId)))
|
||||
{
|
||||
canCreateNormal=false;
|
||||
canCreateJedi=false;
|
||||
}
|
||||
|
||||
if(m_transferRequest)
|
||||
{
|
||||
LoginServer::getInstance().validateAccountForTransfer(*m_transferRequest, m_clusterId, m_transferRequestSourceCharacterTemplateId, canCreateNormal, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
LoginServer::getInstance().validateAccount(m_stationId, m_clusterId, m_subscriptionBits, canCreateNormal, canCreateJedi, m_canSkipTutorial, m_track, m_consumedRewardEvents, m_claimedRewardItems);
|
||||
}
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
void GetValidationDataQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql = std::string("begin :rc := ")+DatabaseConnection::getInstance().getSchemaQualifier()+"login.get_open_character_slots(:station_id,:cluster_id); end;";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool GetValidationDataQuery::bindParameters()
|
||||
{
|
||||
if (!bindParameter(station_id)) return false;
|
||||
if (!bindParameter(cluster_id)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool GetValidationDataQuery::bindColumns()
|
||||
{
|
||||
if (!bindCol(character_type_id)) return false;
|
||||
if (!bindCol(num_open_slots)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
DB::Query::QueryMode GetValidationDataQuery::getExecutionMode() const
|
||||
{
|
||||
return MODE_PLSQL_REFCURSOR;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
GetValidationDataQuery::GetValidationDataQuery() :
|
||||
Query(),
|
||||
station_id(),
|
||||
cluster_id(),
|
||||
character_type_id(),
|
||||
num_open_slots()
|
||||
{
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
void GetCompletedTutorialQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql = std::string("begin :rc := ")+DatabaseConnection::getInstance().getSchemaQualifier()+"login.get_completed_tutorial(:station_id); end;";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool GetCompletedTutorialQuery::bindParameters()
|
||||
{
|
||||
if (!bindParameter(station_id)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool GetCompletedTutorialQuery::bindColumns()
|
||||
{
|
||||
if (!bindCol(completed_tutorial)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
DB::Query::QueryMode GetCompletedTutorialQuery::getExecutionMode() const
|
||||
{
|
||||
return MODE_PLSQL_REFCURSOR;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
GetCompletedTutorialQuery::GetCompletedTutorialQuery(StationId stationId) :
|
||||
DB::Query(),
|
||||
station_id(stationId),
|
||||
completed_tutorial(false)
|
||||
{
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
GetConsumedRewardEventsQuery::GetConsumedRewardEventsQuery(StationId stationId) :
|
||||
DB::Query(),
|
||||
station_id(static_cast<long>(stationId)),
|
||||
event_id(),
|
||||
cluster_id(),
|
||||
character_id()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void GetConsumedRewardEventsQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql = std::string("begin :result := ")+DatabaseConnection::getInstance().getSchemaQualifier()+"login.get_consumed_reward_events(:station_id); end;";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool GetConsumedRewardEventsQuery::bindParameters()
|
||||
{
|
||||
if (!bindParameter(station_id)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool GetConsumedRewardEventsQuery::bindColumns()
|
||||
{
|
||||
if (!bindCol(event_id)) return false;
|
||||
if (!bindCol(cluster_id)) return false;
|
||||
if (!bindCol(character_id)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
DB::Query::QueryMode GetConsumedRewardEventsQuery::getExecutionMode() const
|
||||
{
|
||||
return MODE_PLSQL_REFCURSOR;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
std::string GetConsumedRewardEventsQuery::getEventId() const
|
||||
{
|
||||
return (event_id.getValueASCII());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
uint32 GetConsumedRewardEventsQuery::getClusterId() const
|
||||
{
|
||||
return static_cast<uint32>(cluster_id.getValue());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
NetworkId const GetConsumedRewardEventsQuery::getCharacterId() const
|
||||
{
|
||||
return character_id.getValue();
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
GetClaimedRewardItemsQuery::GetClaimedRewardItemsQuery(StationId stationId) :
|
||||
DB::Query(),
|
||||
station_id(static_cast<long>(stationId)),
|
||||
item_id(),
|
||||
cluster_id(),
|
||||
character_id()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void GetClaimedRewardItemsQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql = std::string("begin :result := ")+DatabaseConnection::getInstance().getSchemaQualifier()+"login.get_claimed_reward_items(:station_id); end;";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool GetClaimedRewardItemsQuery::bindParameters()
|
||||
{
|
||||
if (!bindParameter(station_id)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool GetClaimedRewardItemsQuery::bindColumns()
|
||||
{
|
||||
if (!bindCol(item_id)) return false;
|
||||
if (!bindCol(cluster_id)) return false;
|
||||
if (!bindCol(character_id)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
DB::Query::QueryMode GetClaimedRewardItemsQuery::getExecutionMode() const
|
||||
{
|
||||
return MODE_PLSQL_REFCURSOR;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
std::string GetClaimedRewardItemsQuery::getItemId() const
|
||||
{
|
||||
return (item_id.getValueASCII());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
uint32 GetClaimedRewardItemsQuery::getClusterId() const
|
||||
{
|
||||
return static_cast<uint32>(cluster_id.getValue());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
NetworkId const GetClaimedRewardItemsQuery::getCharacterId() const
|
||||
{
|
||||
return character_id.getValue();
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
IsClusterAtLimitQuery::IsClusterAtLimitQuery() :
|
||||
Query(),
|
||||
cluster_id(),
|
||||
result()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void IsClusterAtLimitQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql = std::string("begin :result := ")+DatabaseConnection::getInstance().getSchemaQualifier()+"login.is_cluster_at_limit(:cluster_id); end;";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool IsClusterAtLimitQuery::bindParameters()
|
||||
{
|
||||
if (!bindParameter(result)) return false;
|
||||
if (!bindParameter(cluster_id)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool IsClusterAtLimitQuery::bindColumns()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
DB::Query::QueryMode IsClusterAtLimitQuery::getExecutionMode() const
|
||||
{
|
||||
return MODE_PROCEXEC;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,55 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskGetValidationData.h
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_TaskGetValidationData_H
|
||||
#define INCLUDED_TaskGetValidationData_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "serverNetworkMessages/AvatarList.h"
|
||||
#include "sharedDatabaseInterface/Bindable.h"
|
||||
#include "sharedDatabaseInterface/DbQuery.h"
|
||||
#include "sharedDatabaseInterface/DbTaskRequest.h"
|
||||
|
||||
class TransferRequestMoveValidation;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class TaskGetValidationData : public DB::TaskRequest
|
||||
{
|
||||
public:
|
||||
TaskGetValidationData (StationId stationId, int clusterGroupId, uint32 clusterId, unsigned int track, uint32 subscriptionBits);
|
||||
TaskGetValidationData (const TransferRequestMoveValidation & request, int clusterGroupId, uint32 clusterId);
|
||||
~TaskGetValidationData();
|
||||
public:
|
||||
virtual bool process (DB::Session *session);
|
||||
virtual void onComplete ();
|
||||
|
||||
private:
|
||||
TaskGetValidationData(); // disabled default constructor
|
||||
|
||||
private:
|
||||
StationId m_stationId;
|
||||
int m_clusterGroupId;
|
||||
uint32 m_clusterId;
|
||||
std::vector<int> m_openCharacterSlots;
|
||||
bool m_canSkipTutorial;
|
||||
unsigned int m_track;
|
||||
uint32 m_subscriptionBits;
|
||||
TransferRequestMoveValidation * m_transferRequest;
|
||||
uint32 m_transferRequestSourceCharacterTemplateId;
|
||||
std::vector<std::pair<NetworkId, std::string> > m_consumedRewardEvents;
|
||||
std::vector<std::pair<NetworkId, std::string> > m_claimedRewardItems;
|
||||
|
||||
private:
|
||||
TaskGetValidationData(const TaskGetValidationData&); //disable
|
||||
TaskGetValidationData &operator=(const TaskGetValidationData&); //disable
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,90 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskRegisterNewCluster.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
#include "TaskRegisterNewCluster.h"
|
||||
|
||||
#include "serverNetworkMessages/AvatarList.h"
|
||||
#include "DatabaseConnection.h"
|
||||
#include "sharedDatabaseInterface/DbSession.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskRegisterNewCluster::TaskRegisterNewCluster (const std::string &newClusterName, const std::string &address) :
|
||||
TaskRequest(),
|
||||
m_clusterId(0),
|
||||
m_clusterName(newClusterName),
|
||||
m_address(address)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskRegisterNewCluster::process(DB::Session *session)
|
||||
{
|
||||
RegisterClusterQuery qry;
|
||||
qry.cluster_name=m_clusterName;
|
||||
qry.address=m_address;
|
||||
|
||||
bool rval = session->exec(&qry);
|
||||
|
||||
qry.cluster_id.getValue(m_clusterId);
|
||||
return rval;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskRegisterNewCluster::onComplete()
|
||||
{
|
||||
DEBUG_FATAL(m_clusterId == 0 || m_clusterId > 10000,("TaskRegisterNewCluster got invalid number %u for cluster id when trying to register cluster %s\n",m_clusterId,m_clusterName.c_str()));
|
||||
LoginServer::getInstance().onClusterRegistered(m_clusterId, m_clusterName);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
void TaskRegisterNewCluster::RegisterClusterQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql = std::string("begin ")+DatabaseConnection::getInstance().getSchemaQualifier()+"login.register_new_cluster(:cluster_name, :address, :cluster_id); end;";
|
||||
// DEBUG_REPORT_LOG(true, ("TaskRegisterNewCluster SQL: %s\n", sql.c_str()));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskRegisterNewCluster::RegisterClusterQuery::bindParameters()
|
||||
{
|
||||
if (!bindParameter(cluster_name)) return false;
|
||||
if (!bindParameter(address)) return false;
|
||||
if (!bindParameter(cluster_id)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskRegisterNewCluster::RegisterClusterQuery::bindColumns()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
DB::Query::QueryMode TaskRegisterNewCluster::RegisterClusterQuery::getExecutionMode() const
|
||||
{
|
||||
return MODE_PROCEXEC;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
TaskRegisterNewCluster::RegisterClusterQuery::RegisterClusterQuery() :
|
||||
Query(),
|
||||
cluster_id(),
|
||||
cluster_name(),
|
||||
address()
|
||||
{
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,59 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskRegisterNewCluster.h
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_TaskRegisterNewCluster_H
|
||||
#define INCLUDED_TaskRegisterNewCluster_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "serverNetworkMessages/AvatarList.h"
|
||||
#include "sharedDatabaseInterface/Bindable.h"
|
||||
#include "sharedDatabaseInterface/BindableNetworkId.h"
|
||||
#include "sharedDatabaseInterface/DbQuery.h"
|
||||
#include "sharedDatabaseInterface/DbTaskRequest.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class TaskRegisterNewCluster : public DB::TaskRequest
|
||||
{
|
||||
public:
|
||||
explicit TaskRegisterNewCluster (const std::string &newClusterName, const std::string &address);
|
||||
|
||||
public:
|
||||
virtual bool process (DB::Session *session);
|
||||
virtual void onComplete ();
|
||||
|
||||
private:
|
||||
TaskRegisterNewCluster(); // disabled default constructor
|
||||
class RegisterClusterQuery : public DB::Query
|
||||
{
|
||||
public:
|
||||
RegisterClusterQuery();
|
||||
|
||||
DB::BindableLong cluster_id; //lint !e1925 // public data member
|
||||
DB::BindableString<255> cluster_name; //lint !e1925 // public data member
|
||||
DB::BindableString<255> address; //lint !e1925 // public data member
|
||||
|
||||
virtual void getSQL(std::string &sql);
|
||||
virtual bool bindParameters();
|
||||
virtual bool bindColumns();
|
||||
virtual QueryMode getExecutionMode() const;
|
||||
|
||||
private: //disable
|
||||
RegisterClusterQuery(const RegisterClusterQuery&);
|
||||
RegisterClusterQuery &operator=(const RegisterClusterQuery&);
|
||||
};
|
||||
|
||||
private:
|
||||
uint32 m_clusterId;
|
||||
std::string m_clusterName;
|
||||
std::string m_address;
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,110 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskRenameCharacter.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
#include "TaskRenameCharacter.h"
|
||||
|
||||
#include "LoginServer.h"
|
||||
#include "DatabaseConnection.h"
|
||||
#include "serverNetworkMessages/TransferCharacterData.h"
|
||||
#include "serverNetworkMessages/TransferCharacterDataArchive.h"
|
||||
#include "sharedDatabaseInterface/DbSession.h"
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskRenameCharacter::TaskRenameCharacter(uint32 clusterId, const NetworkId &characterId, const Unicode::String &newName, const TransferCharacterData * requestData) :
|
||||
TaskRequest(),
|
||||
m_clusterId(clusterId),
|
||||
m_characterId(characterId),
|
||||
m_newName(newName),
|
||||
m_success(false),
|
||||
m_requestData(0)
|
||||
{
|
||||
if(requestData)
|
||||
{
|
||||
m_requestData = new TransferCharacterData(*requestData);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
TaskRenameCharacter::~TaskRenameCharacter()
|
||||
{
|
||||
delete m_requestData;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskRenameCharacter::process(DB::Session *session)
|
||||
{
|
||||
RenameCharacterQuery qry;
|
||||
qry.cluster_id=m_clusterId; //lint !e713 loss of precision
|
||||
qry.character_id=m_characterId;
|
||||
qry.new_name=m_newName;
|
||||
|
||||
m_success = session->exec(&qry);
|
||||
|
||||
qry.done();
|
||||
return m_success;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskRenameCharacter::onComplete()
|
||||
{
|
||||
if(m_requestData)
|
||||
{
|
||||
m_requestData->setIsValidName(m_success);
|
||||
GenericValueTypeMessage<TransferCharacterData> reply("TransferRenameCharacterReplyFromLoginServer", *m_requestData);
|
||||
LoginServer::getInstance().sendToCluster(m_clusterId, reply);
|
||||
}
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskRenameCharacter::RenameCharacterQuery::RenameCharacterQuery() :
|
||||
Query(),
|
||||
cluster_id(),
|
||||
character_id(),
|
||||
new_name()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskRenameCharacter::RenameCharacterQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql = std::string("begin ")+DatabaseConnection::getInstance().getSchemaQualifier()+"login.rename_character(:cluster_id, :character_id, :new_name); end;";
|
||||
// DEBUG_REPORT_LOG(true, ("TaskRenameCharacter SQL: %s\n", sql.c_str()));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskRenameCharacter::RenameCharacterQuery::bindParameters()
|
||||
{
|
||||
if (!bindParameter(cluster_id)) return false;
|
||||
if (!bindParameter(character_id)) return false;
|
||||
if (!bindParameter(new_name)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskRenameCharacter::RenameCharacterQuery::bindColumns()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
DB::Query::QueryMode TaskRenameCharacter::RenameCharacterQuery::getExecutionMode() const
|
||||
{
|
||||
return MODE_PROCEXEC;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,62 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskRenameCharacter.h
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_TaskRenameCharacter_H
|
||||
#define INCLUDED_TaskRenameCharacter_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedDatabaseInterface/Bindable.h"
|
||||
#include "sharedDatabaseInterface/BindableNetworkId.h"
|
||||
#include "sharedDatabaseInterface/DbQuery.h"
|
||||
#include "sharedDatabaseInterface/DbTaskRequest.h"
|
||||
|
||||
class TransferCharacterData;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class TaskRenameCharacter : public DB::TaskRequest
|
||||
{
|
||||
public:
|
||||
TaskRenameCharacter(uint32 clusterId, const NetworkId &characterId, const Unicode::String &newName, const TransferCharacterData * requestData);
|
||||
~TaskRenameCharacter();
|
||||
public:
|
||||
virtual bool process (DB::Session *session);
|
||||
virtual void onComplete ();
|
||||
|
||||
private:
|
||||
TaskRenameCharacter(); // disabled default constructor
|
||||
class RenameCharacterQuery : public DB::Query
|
||||
{
|
||||
public:
|
||||
RenameCharacterQuery();
|
||||
|
||||
DB::BindableLong cluster_id; //lint !e1925 // public data member
|
||||
DB::BindableNetworkId character_id; //lint !e1925 // public data member
|
||||
DB::BindableString<127> new_name; //lint !e1925 // public data member
|
||||
|
||||
virtual void getSQL (std::string &sql);
|
||||
virtual bool bindParameters ();
|
||||
virtual bool bindColumns ();
|
||||
virtual QueryMode getExecutionMode () const;
|
||||
|
||||
private: //disable
|
||||
RenameCharacterQuery (const RenameCharacterQuery&);
|
||||
RenameCharacterQuery &operator= (const RenameCharacterQuery&);
|
||||
};
|
||||
|
||||
private:
|
||||
uint32 m_clusterId;
|
||||
NetworkId m_characterId;
|
||||
Unicode::String m_newName;
|
||||
bool m_success;
|
||||
TransferCharacterData * m_requestData;
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,133 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskRestoreCharacter.cpp
|
||||
// copyright (c) 2003 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
#include "TaskRestoreCharacter.h"
|
||||
|
||||
#include "DatabaseConnection.h"
|
||||
#include "LoginServer.h"
|
||||
#include "serverNetworkMessages/LoginCreateCharacterAckMessage.h"
|
||||
#include "sharedDatabaseInterface/DbSession.h"
|
||||
#include "sharedFoundation/NetworkIdArchive.h"
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskRestoreCharacter::TaskRestoreCharacter(uint32 clusterId, const std::string &whoRequested, StationId stationId, const Unicode::String &characterName, const NetworkId &characterId, int templateId, bool jedi) :
|
||||
TaskRequest(),
|
||||
m_clusterId(clusterId),
|
||||
m_whoRequested(whoRequested),
|
||||
m_stationId(stationId),
|
||||
m_characterName(characterName),
|
||||
m_characterId(characterId),
|
||||
m_templateId(templateId),
|
||||
m_jedi(jedi),
|
||||
m_result(0)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskRestoreCharacter::process(DB::Session *session)
|
||||
{
|
||||
RestoreCharacterQuery qry;
|
||||
qry.cluster_id = static_cast<long>(m_clusterId);
|
||||
qry.station_id = static_cast<long>(m_stationId);
|
||||
qry.character_name = m_characterName;
|
||||
qry.character_id = m_characterId;
|
||||
qry.template_id = m_templateId;
|
||||
if (m_jedi)
|
||||
qry.character_type = 2;
|
||||
else
|
||||
qry.character_type = 1;
|
||||
|
||||
bool rval = session->exec(&qry);
|
||||
qry.done();
|
||||
|
||||
qry.result.getValue(m_result);
|
||||
return rval;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskRestoreCharacter::onComplete()
|
||||
{
|
||||
std::string message;
|
||||
switch (m_result)
|
||||
{
|
||||
case 1:
|
||||
message = "Character restored.";
|
||||
break;
|
||||
|
||||
case 2:
|
||||
message = "Character restored. The player now has more characters on this cluster than the normal limit.";
|
||||
break;
|
||||
|
||||
case 3:
|
||||
message = "There was an error in the database while attempting to restore the character.";
|
||||
break;
|
||||
|
||||
default:
|
||||
message = "The database returned an unknown code in response to the request to restore the character.";
|
||||
break;
|
||||
}
|
||||
|
||||
GenericValueTypeMessage<std::pair<std::string, std::string> > reply("DatabaseConsoleReplyMessage",
|
||||
std::make_pair(m_whoRequested, message));
|
||||
LoginServer::getInstance().sendToCluster(m_clusterId, reply);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskRestoreCharacter::RestoreCharacterQuery::RestoreCharacterQuery() :
|
||||
Query(),
|
||||
cluster_id(),
|
||||
station_id(),
|
||||
character_name(),
|
||||
character_id(),
|
||||
template_id(),
|
||||
character_type(),
|
||||
result()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskRestoreCharacter::RestoreCharacterQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql = std::string("begin :result := ")+DatabaseConnection::getInstance().getSchemaQualifier()+"login.restore_character(:cluster_id, :station_id, :character_name, :character_id, :template_name, :character_type); end;";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskRestoreCharacter::RestoreCharacterQuery::bindParameters()
|
||||
{
|
||||
if (!bindParameter(result)) return false;
|
||||
if (!bindParameter(cluster_id)) return false;
|
||||
if (!bindParameter(station_id)) return false;
|
||||
if (!bindParameter(character_name)) return false;
|
||||
if (!bindParameter(character_id)) return false;
|
||||
if (!bindParameter(template_id)) return false;
|
||||
if (!bindParameter(character_type)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskRestoreCharacter::RestoreCharacterQuery::bindColumns()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
DB::Query::QueryMode TaskRestoreCharacter::RestoreCharacterQuery::getExecutionMode() const
|
||||
{
|
||||
return MODE_PROCEXEC;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,67 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskRestoreCharacter.h
|
||||
// copyright (c) 2003 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_TaskRestoreCharacter_H
|
||||
#define INCLUDED_TaskRestoreCharacter_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedDatabaseInterface/Bindable.h"
|
||||
#include "sharedDatabaseInterface/BindableNetworkId.h"
|
||||
#include "sharedDatabaseInterface/DbQuery.h"
|
||||
#include "sharedDatabaseInterface/DbTaskRequest.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class TaskRestoreCharacter : public DB::TaskRequest
|
||||
{
|
||||
public:
|
||||
TaskRestoreCharacter(uint32 clusterId, const std::string &whoRequested, StationId stationId, const Unicode::String &characterName, const NetworkId &characterId, int templateId, bool jedi);
|
||||
|
||||
public:
|
||||
virtual bool process (DB::Session *session);
|
||||
virtual void onComplete ();
|
||||
|
||||
private:
|
||||
TaskRestoreCharacter(); // disabled default constructor
|
||||
class RestoreCharacterQuery : public DB::Query
|
||||
{
|
||||
public:
|
||||
RestoreCharacterQuery();
|
||||
|
||||
DB::BindableLong cluster_id; //lint !e1925 // public data member
|
||||
DB::BindableLong station_id; //lint !e1925 // public data member
|
||||
DB::BindableString<127> character_name; //lint !e1925 // public data member
|
||||
DB::BindableNetworkId character_id; //lint !e1925 // public data member
|
||||
DB::BindableLong template_id; //lint !e1925 // public data member
|
||||
DB::BindableLong character_type; //lint !e1925 // public data member
|
||||
DB::BindableLong result; //lint !e1925 // public data member
|
||||
|
||||
virtual void getSQL (std::string &sql);
|
||||
virtual bool bindParameters ();
|
||||
virtual bool bindColumns ();
|
||||
virtual QueryMode getExecutionMode () const;
|
||||
|
||||
private: //disable
|
||||
RestoreCharacterQuery (const RestoreCharacterQuery&);
|
||||
RestoreCharacterQuery &operator= (const RestoreCharacterQuery&);
|
||||
};
|
||||
|
||||
private:
|
||||
uint32 m_clusterId;
|
||||
std::string m_whoRequested;
|
||||
StationId m_stationId;
|
||||
Unicode::String m_characterName;
|
||||
NetworkId m_characterId;
|
||||
int m_templateId;
|
||||
bool m_jedi;
|
||||
int m_result;
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,107 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskSetPurgeStatus.cpp
|
||||
// copyright (c) 2005 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
#include "TaskSetPurgeStatus.h"
|
||||
|
||||
#include "DatabaseConnection.h"
|
||||
#include "PurgeManager.h"
|
||||
#include "sharedDatabaseInterface/Bindable.h"
|
||||
#include "sharedDatabaseInterface/DbQuery.h"
|
||||
#include "sharedDatabaseInterface/DbSession.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
namespace TaskSetPurgeStatusNamespace
|
||||
{
|
||||
class SetPurgeStatusQuery : public DB::Query
|
||||
{
|
||||
public:
|
||||
SetPurgeStatusQuery(StationId account, int purgePhase);
|
||||
|
||||
virtual void getSQL(std::string &sql);
|
||||
virtual bool bindParameters();
|
||||
virtual bool bindColumns();
|
||||
virtual QueryMode getExecutionMode() const;
|
||||
|
||||
private:
|
||||
DB::BindableLong m_account;
|
||||
DB::BindableLong m_purge_phase;
|
||||
|
||||
private: //disable
|
||||
SetPurgeStatusQuery(const SetPurgeStatusQuery&);
|
||||
SetPurgeStatusQuery& operator=(const SetPurgeStatusQuery&);
|
||||
};
|
||||
}
|
||||
using namespace TaskSetPurgeStatusNamespace;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskSetPurgeStatus::TaskSetPurgeStatus(StationId account, int purgePhase) :
|
||||
DB::TaskRequest(),
|
||||
m_account(account),
|
||||
m_purgePhase(purgePhase)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskSetPurgeStatus::process(DB::Session *session)
|
||||
{
|
||||
SetPurgeStatusQuery qry(m_account, m_purgePhase);
|
||||
if (!session->exec(&qry))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskSetPurgeStatus::onComplete()
|
||||
{
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
|
||||
SetPurgeStatusQuery::SetPurgeStatusQuery(StationId account, int purgePhase) :
|
||||
Query(),
|
||||
m_account(account),
|
||||
m_purge_phase(purgePhase)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void SetPurgeStatusQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql=std::string("begin ")+DatabaseConnection::getInstance().getSchemaQualifier()+"purge_process.set_purge_status(:account, :purge_phase); end;";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool SetPurgeStatusQuery::bindParameters()
|
||||
{
|
||||
if (!bindParameter(m_account)) return false;
|
||||
if (!bindParameter(m_purge_phase)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool SetPurgeStatusQuery::bindColumns()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
SetPurgeStatusQuery::QueryMode SetPurgeStatusQuery::getExecutionMode() const
|
||||
{
|
||||
return MODE_PROCEXEC;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,29 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskSetPurgeStatus.h
|
||||
// copyright (c) 2005 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_TaskSetPurgeStatus_H
|
||||
#define INCLUDED_TaskSetPurgeStatus_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedDatabaseInterface/DbTaskRequest.h"
|
||||
|
||||
class TaskSetPurgeStatus : public DB::TaskRequest
|
||||
{
|
||||
public:
|
||||
explicit TaskSetPurgeStatus(StationId account, int purgePhase);
|
||||
virtual bool process (DB::Session *session);
|
||||
virtual void onComplete ();
|
||||
|
||||
private:
|
||||
StationId m_account;
|
||||
int m_purgePhase;
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,95 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskToggleCharacterDisable.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
#include "TaskToggleCharacterDisable.h"
|
||||
|
||||
#include "ClientConnection.h"
|
||||
#include "LoginServer.h"
|
||||
#include "DatabaseConnection.h"
|
||||
#include "sharedDatabaseInterface/DbSession.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskToggleCharacterDisable::TaskToggleCharacterDisable(uint32 clusterId, const NetworkId &characterId, StationId stationId, bool enabled) :
|
||||
TaskRequest(),
|
||||
m_clusterId(clusterId),
|
||||
m_characterId(characterId),
|
||||
m_stationId(stationId),
|
||||
m_enabled(enabled)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskToggleCharacterDisable::process(DB::Session *session)
|
||||
{
|
||||
ToggleCharacterDisableQuery qry;
|
||||
qry.cluster_id=static_cast<long>(m_clusterId);
|
||||
qry.character_id=m_characterId;
|
||||
qry.station_id=static_cast<long>(m_stationId);
|
||||
qry.enabled_flag=m_enabled;
|
||||
|
||||
bool rval = session->exec(&qry);
|
||||
|
||||
qry.done();
|
||||
return rval;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskToggleCharacterDisable::onComplete()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
TaskToggleCharacterDisable::ToggleCharacterDisableQuery::ToggleCharacterDisableQuery() :
|
||||
Query(),
|
||||
cluster_id(),
|
||||
character_id(),
|
||||
station_id(),
|
||||
enabled_flag()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskToggleCharacterDisable::ToggleCharacterDisableQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql = std::string("begin ")+DatabaseConnection::getInstance().getSchemaQualifier()+"login.toggle_disable_character(:cluster_id, :character_id, :station_id, :enabled); end;";
|
||||
// DEBUG_REPORT_LOG(true, ("TaskToggleCharacterDisable SQL: %s\n", sql.c_str()));
|
||||
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskToggleCharacterDisable::ToggleCharacterDisableQuery::bindParameters()
|
||||
{
|
||||
if (!bindParameter(cluster_id)) return false;
|
||||
if (!bindParameter(character_id)) return false;
|
||||
if (!bindParameter(station_id)) return false;
|
||||
if (!bindParameter(enabled_flag)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskToggleCharacterDisable::ToggleCharacterDisableQuery::bindColumns()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
DB::Query::QueryMode TaskToggleCharacterDisable::ToggleCharacterDisableQuery::getExecutionMode() const
|
||||
{
|
||||
return MODE_PROCEXEC;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,63 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskToggleCharacterDisable.h
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_TaskToggleCharacterDisable_H
|
||||
#define INCLUDED_TaskToggleCharacterDisable_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "serverNetworkMessages/AvatarList.h"
|
||||
#include "sharedDatabaseInterface/Bindable.h"
|
||||
#include "sharedDatabaseInterface/BindableNetworkId.h"
|
||||
#include "sharedDatabaseInterface/DbQuery.h"
|
||||
#include "sharedDatabaseInterface/DbTaskRequest.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class TaskToggleCharacterDisable : public DB::TaskRequest
|
||||
{
|
||||
public:
|
||||
TaskToggleCharacterDisable(uint32 clusterId, const NetworkId &characterId, StationId stationId, bool enabled);
|
||||
|
||||
public:
|
||||
virtual bool process (DB::Session *session);
|
||||
virtual void onComplete ();
|
||||
|
||||
private:
|
||||
TaskToggleCharacterDisable(); // disabled default constructor
|
||||
|
||||
class ToggleCharacterDisableQuery : public DB::Query
|
||||
{
|
||||
public:
|
||||
ToggleCharacterDisableQuery();
|
||||
|
||||
DB::BindableLong cluster_id; //lint !e1925 // public data member : suppressed because this is a private inner class
|
||||
DB::BindableNetworkId character_id; //lint !e1925 // public data member : suppressed because this is a private inner class
|
||||
DB::BindableLong station_id; //lint !e1925 // public data member : suppressed because this is a private inner class
|
||||
DB::BindableBool enabled_flag; //lint !e1925 // public data member : suppressed because this is a private inner class
|
||||
|
||||
|
||||
virtual void getSQL(std::string &sql);
|
||||
virtual bool bindParameters();
|
||||
virtual bool bindColumns();
|
||||
virtual QueryMode getExecutionMode() const;
|
||||
|
||||
private: //disable
|
||||
ToggleCharacterDisableQuery(const ToggleCharacterDisableQuery&);
|
||||
ToggleCharacterDisableQuery &operator=(const ToggleCharacterDisableQuery&);
|
||||
};
|
||||
|
||||
private:
|
||||
uint32 m_clusterId;
|
||||
NetworkId m_characterId;
|
||||
StationId m_stationId;
|
||||
bool m_enabled;
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,85 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskToggleCompletedTutorial.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
#include "TaskToggleCompletedTutorial.h"
|
||||
|
||||
#include "LoginServer.h"
|
||||
#include "DatabaseConnection.h"
|
||||
#include "sharedDatabaseInterface/DbSession.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskToggleCompletedTutorial::TaskToggleCompletedTutorial(StationId stationId, bool completed) :
|
||||
TaskRequest(),
|
||||
m_stationId(stationId),
|
||||
m_completed(completed)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskToggleCompletedTutorial::process(DB::Session *session)
|
||||
{
|
||||
ToggleCompletedTutorialQuery qry;
|
||||
qry.station_id=static_cast<long>(m_stationId);
|
||||
qry.completed_flag=m_completed;
|
||||
|
||||
bool rval = session->exec(&qry);
|
||||
|
||||
qry.done();
|
||||
return rval;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskToggleCompletedTutorial::onComplete()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
TaskToggleCompletedTutorial::ToggleCompletedTutorialQuery::ToggleCompletedTutorialQuery() :
|
||||
Query(),
|
||||
station_id(),
|
||||
completed_flag()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskToggleCompletedTutorial::ToggleCompletedTutorialQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql = std::string("begin ")+DatabaseConnection::getInstance().getSchemaQualifier()+"login.toggle_completed_tutorial(:station_id, :completed_flag); end;";
|
||||
//DEBUG_REPORT_LOG(true, ("TaskToggleCompletedTutorial SQL: %s\n", sql.c_str()));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskToggleCompletedTutorial::ToggleCompletedTutorialQuery::bindParameters()
|
||||
{
|
||||
if (!bindParameter(station_id)) return false;
|
||||
if (!bindParameter(completed_flag)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskToggleCompletedTutorial::ToggleCompletedTutorialQuery::bindColumns()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
DB::Query::QueryMode TaskToggleCompletedTutorial::ToggleCompletedTutorialQuery::getExecutionMode() const
|
||||
{
|
||||
return MODE_PROCEXEC;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,57 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskToggleCompletedTutorial.h
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_TaskToggleCompletedTutorial_H
|
||||
#define INCLUDED_TaskToggleCompletedTutorial_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedDatabaseInterface/Bindable.h"
|
||||
#include "sharedDatabaseInterface/BindableNetworkId.h"
|
||||
#include "sharedDatabaseInterface/DbQuery.h"
|
||||
#include "sharedDatabaseInterface/DbTaskRequest.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class TaskToggleCompletedTutorial : public DB::TaskRequest
|
||||
{
|
||||
public:
|
||||
TaskToggleCompletedTutorial(StationId stationId, bool completed);
|
||||
|
||||
public:
|
||||
virtual bool process (DB::Session *session);
|
||||
virtual void onComplete ();
|
||||
|
||||
private:
|
||||
TaskToggleCompletedTutorial(); // disabled default constructor
|
||||
|
||||
class ToggleCompletedTutorialQuery : public DB::Query
|
||||
{
|
||||
public:
|
||||
ToggleCompletedTutorialQuery();
|
||||
|
||||
DB::BindableLong station_id; //lint !e1925 // public data member : suppressed because this is a private inner class
|
||||
DB::BindableBool completed_flag; //lint !e1925 // public data member : suppressed because this is a private inner class
|
||||
|
||||
virtual void getSQL(std::string &sql);
|
||||
virtual bool bindParameters();
|
||||
virtual bool bindColumns();
|
||||
virtual QueryMode getExecutionMode() const;
|
||||
|
||||
private: //disable
|
||||
ToggleCompletedTutorialQuery(const ToggleCompletedTutorialQuery&);
|
||||
ToggleCompletedTutorialQuery &operator=(const ToggleCompletedTutorialQuery&);
|
||||
};
|
||||
|
||||
private:
|
||||
StationId m_stationId;
|
||||
bool m_completed;
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,102 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskUpdatePurgeAccountList.cpp
|
||||
// copyright (c) 2005 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
#include "TaskUpdatePurgeAccountList.h"
|
||||
|
||||
#include "ConfigLoginServer.h"
|
||||
#include "DatabaseConnection.h"
|
||||
#include "PurgeManager.h"
|
||||
#include "sharedDatabaseInterface/Bindable.h"
|
||||
#include "sharedDatabaseInterface/DbQuery.h"
|
||||
#include "sharedDatabaseInterface/DbSession.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
namespace TaskUpdatePurgeAccountListNamespace
|
||||
{
|
||||
class UpdateAccoutListQuery : public DB::Query
|
||||
{
|
||||
public:
|
||||
UpdateAccoutListQuery();
|
||||
|
||||
virtual void getSQL(std::string &sql);
|
||||
virtual bool bindParameters();
|
||||
virtual bool bindColumns();
|
||||
virtual QueryMode getExecutionMode() const;
|
||||
|
||||
DB::BindableString<100> m_source_table;
|
||||
|
||||
private: //disable
|
||||
UpdateAccoutListQuery(const UpdateAccoutListQuery&);
|
||||
UpdateAccoutListQuery& operator=(const UpdateAccoutListQuery&);
|
||||
};
|
||||
}
|
||||
using namespace TaskUpdatePurgeAccountListNamespace;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskUpdatePurgeAccountList::TaskUpdatePurgeAccountList() :
|
||||
DB::TaskRequest()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskUpdatePurgeAccountList::process(DB::Session *session)
|
||||
{
|
||||
UpdateAccoutListQuery qry;
|
||||
if (!session->exec(&qry))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskUpdatePurgeAccountList::onComplete()
|
||||
{
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
|
||||
UpdateAccoutListQuery::UpdateAccoutListQuery() :
|
||||
Query(),
|
||||
m_source_table(ConfigLoginServer::getPurgeAccountSourceTable())
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void UpdateAccoutListQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql=std::string("begin ")+DatabaseConnection::getInstance().getSchemaQualifier()+"purge_process.update_account_list(:source_table); end;";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool UpdateAccoutListQuery::bindParameters()
|
||||
{
|
||||
if (!bindParameter(m_source_table)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool UpdateAccoutListQuery::bindColumns()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
UpdateAccoutListQuery::QueryMode UpdateAccoutListQuery::getExecutionMode() const
|
||||
{
|
||||
return MODE_PROCEXEC;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,29 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskUpdatePurgeAccountList.h
|
||||
// copyright (c) 2005 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_TaskUpdatePurgeAccountList_H
|
||||
#define INCLUDED_TaskUpdatePurgeAccountList_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedDatabaseInterface/DbTaskRequest.h"
|
||||
|
||||
class TaskUpdatePurgeAccountList : public DB::TaskRequest
|
||||
{
|
||||
public:
|
||||
TaskUpdatePurgeAccountList();
|
||||
virtual bool process (DB::Session *session);
|
||||
virtual void onComplete ();
|
||||
|
||||
private:
|
||||
StationId m_account;
|
||||
int m_purgePhase;
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,687 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskUpgradeAccount.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstLoginServer.h"
|
||||
#include "TaskUpgradeAccount.h"
|
||||
|
||||
#include "LoginServer.h"
|
||||
#include "DatabaseConnection.h"
|
||||
#include "serverNetworkMessages/LoginUpgradeAccountMessage.h"
|
||||
#include "sharedDatabaseInterface/DbSession.h"
|
||||
#include "sharedFoundation/NetworkIdArchive.h"
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
#include "TaskGetAvatarList.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskUpgradeAccount::TaskUpgradeAccount(LoginUpgradeAccountMessage *message, uint32 clusterId) :
|
||||
TaskRequest(),
|
||||
m_message(message),
|
||||
m_clusterId(clusterId)
|
||||
{
|
||||
NOT_NULL(message);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
TaskUpgradeAccount::~TaskUpgradeAccount()
|
||||
{
|
||||
delete m_message;
|
||||
m_message=0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskUpgradeAccount::process(DB::Session *session)
|
||||
{
|
||||
bool rval = true;
|
||||
switch (m_message->getUpgradeType())
|
||||
{
|
||||
case LoginUpgradeAccountMessage::UT_addJedi:
|
||||
{
|
||||
QueryJediQuery qryHasJediSlot;
|
||||
qryHasJediSlot.station_id = static_cast<long>(m_message->getStationId());
|
||||
qryHasJediSlot.character_type = 2;
|
||||
|
||||
rval = session->exec(&qryHasJediSlot);
|
||||
|
||||
qryHasJediSlot.done();
|
||||
|
||||
// account doesn't have jedi slot yet, add it
|
||||
if (!rval || (qryHasJediSlot.result.getValue() == 0))
|
||||
{
|
||||
AddJediQuery qry;
|
||||
qry.cluster_id = static_cast<long>(m_clusterId);
|
||||
qry.station_id = static_cast<long>(m_message->getStationId());
|
||||
|
||||
rval = session->exec(&qry);
|
||||
|
||||
qry.done();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case LoginUpgradeAccountMessage::UT_setSpectral:
|
||||
{
|
||||
SetCharacterTypeQuery qry;
|
||||
qry.cluster_id = static_cast<long>(m_clusterId);
|
||||
qry.station_id = static_cast<long>(m_message->getStationId());
|
||||
qry.character = m_message->getCharacter();
|
||||
qry.character_type = 3;
|
||||
|
||||
rval = session->exec(&qry);
|
||||
|
||||
qry.done();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
WARNING_STRICT_FATAL(true,("LoginUpgradeAccountMessage contained unrecognized upgrade type.\n"));
|
||||
}
|
||||
return rval;
|
||||
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskUpgradeAccount::onComplete()
|
||||
{
|
||||
m_message->setAck();
|
||||
LoginServer::getInstance().sendToCluster(m_clusterId,*m_message);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskUpgradeAccount::SetCharacterTypeQuery::SetCharacterTypeQuery() :
|
||||
Query(),
|
||||
cluster_id(),
|
||||
station_id(),
|
||||
character(),
|
||||
character_type()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskUpgradeAccount::SetCharacterTypeQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql = std::string("begin ")+DatabaseConnection::getInstance().getSchemaQualifier()+"login.set_character_type(:cluster_id, :station_id, :character, :character_type); end;";
|
||||
// DEBUG_REPORT_LOG(true, ("TaskUpgradeAccount SQL: %s\n", sql.c_str()));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskUpgradeAccount::SetCharacterTypeQuery::bindParameters()
|
||||
{
|
||||
if (!bindParameter(cluster_id)) return false;
|
||||
if (!bindParameter(station_id)) return false;
|
||||
if (!bindParameter(character)) return false;
|
||||
if (!bindParameter(character_type)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskUpgradeAccount::SetCharacterTypeQuery::bindColumns()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
DB::Query::QueryMode TaskUpgradeAccount::SetCharacterTypeQuery::getExecutionMode() const
|
||||
{
|
||||
return MODE_PROCEXEC;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskUpgradeAccount::AddJediQuery::AddJediQuery() :
|
||||
Query(),
|
||||
cluster_id(),
|
||||
station_id()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskUpgradeAccount::AddJediQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql = std::string("begin ")+DatabaseConnection::getInstance().getSchemaQualifier()+"login.set_character_slots(:cluster_id, :station_id, 2, 1); end;";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskUpgradeAccount::AddJediQuery::bindParameters()
|
||||
{
|
||||
if (!bindParameter(cluster_id)) return false;
|
||||
if (!bindParameter(station_id)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskUpgradeAccount::AddJediQuery::bindColumns()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
DB::Query::QueryMode TaskUpgradeAccount::AddJediQuery::getExecutionMode() const
|
||||
{
|
||||
return MODE_PROCEXEC;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskUpgradeAccount::QueryJediQuery::QueryJediQuery() :
|
||||
Query(),
|
||||
station_id(),
|
||||
character_type(),
|
||||
result()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskUpgradeAccount::QueryJediQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql = std::string("begin :result := ")+DatabaseConnection::getInstance().getSchemaQualifier()+"login.has_extra_character_slot(:station_id, :character_type); end;";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskUpgradeAccount::QueryJediQuery::bindParameters()
|
||||
{
|
||||
if (!bindParameter(result)) return false;
|
||||
if (!bindParameter(station_id)) return false;
|
||||
if (!bindParameter(character_type)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskUpgradeAccount::QueryJediQuery::bindColumns()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
DB::Query::QueryMode TaskUpgradeAccount::QueryJediQuery::getExecutionMode() const
|
||||
{
|
||||
return MODE_PROCEXEC;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskOccupyUnlockedSlot::TaskOccupyUnlockedSlot(int clusterGroupId, uint32 clusterId, StationId stationId, NetworkId const & characterId, uint32 replyGameServerId) :
|
||||
TaskRequest(),
|
||||
m_clusterGroupId(clusterGroupId),
|
||||
m_clusterId(clusterId),
|
||||
m_stationId(stationId),
|
||||
m_characterId(characterId),
|
||||
m_replyGameServerId(replyGameServerId),
|
||||
m_result(static_cast<int>(LoginUpgradeAccountMessage::OUSR_db_error))
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
TaskOccupyUnlockedSlot::~TaskOccupyUnlockedSlot()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskOccupyUnlockedSlot::process(DB::Session *session)
|
||||
{
|
||||
bool rval = true;
|
||||
m_result = static_cast<int>(LoginUpgradeAccountMessage::OUSR_success);
|
||||
|
||||
// see if account has an unlocked slot
|
||||
TaskUpgradeAccount::QueryJediQuery qryHasJediSlot;
|
||||
qryHasJediSlot.station_id = static_cast<long>(m_stationId);
|
||||
qryHasJediSlot.character_type = 2;
|
||||
|
||||
rval = session->exec(&qryHasJediSlot);
|
||||
|
||||
qryHasJediSlot.done();
|
||||
|
||||
if (!rval)
|
||||
{
|
||||
m_result = static_cast<int>(LoginUpgradeAccountMessage::OUSR_db_error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// account doesn't have unlocked slot
|
||||
int const numberUnlockedSlot = static_cast<int>(qryHasJediSlot.result.getValue());
|
||||
if (numberUnlockedSlot == 0)
|
||||
{
|
||||
m_result = static_cast<int>(LoginUpgradeAccountMessage::OUSR_account_has_no_unlocked_slot);
|
||||
return true;
|
||||
}
|
||||
|
||||
// get the list of characters for the account to see if the account already has an unlocked slot character
|
||||
TaskGetAvatarList::GetCharactersQuery qryGetCharacters;
|
||||
|
||||
qryGetCharacters.station_id = m_stationId; //lint !e713 // loss of precision unsigned long to long
|
||||
qryGetCharacters.cluster_group_id = m_clusterGroupId;
|
||||
|
||||
rval = session->exec(&qryGetCharacters);
|
||||
if (!rval)
|
||||
{
|
||||
m_result = static_cast<int>(LoginUpgradeAccountMessage::OUSR_db_error);
|
||||
return false;
|
||||
}
|
||||
|
||||
int numberUnlockedSlotCharacter = 0;
|
||||
bool hasUnlockedSlotCharacterOnCluster = false;
|
||||
int rowsFetched;
|
||||
while ((rowsFetched = qryGetCharacters.fetch()) > 0)
|
||||
{
|
||||
if (qryGetCharacters.character_type.getValue() == 2)
|
||||
{
|
||||
++numberUnlockedSlotCharacter;
|
||||
|
||||
if (qryGetCharacters.cluster_id.getValue() == static_cast<long>(m_clusterId))
|
||||
hasUnlockedSlotCharacterOnCluster = true;
|
||||
}
|
||||
}
|
||||
|
||||
qryGetCharacters.done();
|
||||
|
||||
if (numberUnlockedSlotCharacter >= numberUnlockedSlot)
|
||||
{
|
||||
m_result = static_cast<int>(LoginUpgradeAccountMessage::OUSR_account_has_no_unoccupied_unlocked_slot);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (hasUnlockedSlotCharacterOnCluster)
|
||||
{
|
||||
m_result = static_cast<int>(LoginUpgradeAccountMessage::OUSR_cluster_already_has_unlocked_slot_character);
|
||||
return true;
|
||||
}
|
||||
|
||||
// make the character an unlocked slot character
|
||||
TaskUpgradeAccount::SetCharacterTypeQuery qrySetUnlocked;
|
||||
qrySetUnlocked.cluster_id = static_cast<long>(m_clusterId);
|
||||
qrySetUnlocked.station_id = static_cast<long>(m_stationId);
|
||||
qrySetUnlocked.character = m_characterId;
|
||||
qrySetUnlocked.character_type = 2;
|
||||
|
||||
rval = session->exec(&qrySetUnlocked);
|
||||
|
||||
qrySetUnlocked.done();
|
||||
|
||||
if (!rval)
|
||||
{
|
||||
m_result = static_cast<int>(LoginUpgradeAccountMessage::OUSR_db_error);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskOccupyUnlockedSlot::onComplete()
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::pair<int, NetworkId>, uint32> > const occupyUnlockedSlotRsp("OccupyUnlockedSlotRsp", std::make_pair(std::make_pair(m_result, m_characterId), m_replyGameServerId));
|
||||
LoginServer::getInstance().sendToCluster(m_clusterId, occupyUnlockedSlotRsp);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskVacateUnlockedSlot::TaskVacateUnlockedSlot(int clusterGroupId, uint32 clusterId, StationId stationId, NetworkId const & characterId, uint32 replyGameServerId) :
|
||||
TaskRequest(),
|
||||
m_clusterGroupId(clusterGroupId),
|
||||
m_clusterId(clusterId),
|
||||
m_stationId(stationId),
|
||||
m_characterId(characterId),
|
||||
m_replyGameServerId(replyGameServerId),
|
||||
m_result(static_cast<int>(LoginUpgradeAccountMessage::VUSR_db_error))
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
TaskVacateUnlockedSlot::~TaskVacateUnlockedSlot()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskVacateUnlockedSlot::process(DB::Session *session)
|
||||
{
|
||||
bool rval = true;
|
||||
m_result = static_cast<int>(LoginUpgradeAccountMessage::VUSR_success);
|
||||
|
||||
// see if account has an unlocked slot
|
||||
TaskUpgradeAccount::QueryJediQuery qryHasJediSlot;
|
||||
qryHasJediSlot.station_id = static_cast<long>(m_stationId);
|
||||
qryHasJediSlot.character_type = 2;
|
||||
|
||||
rval = session->exec(&qryHasJediSlot);
|
||||
|
||||
qryHasJediSlot.done();
|
||||
|
||||
if (!rval)
|
||||
{
|
||||
m_result = static_cast<int>(LoginUpgradeAccountMessage::VUSR_db_error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// account doesn't have unlocked slot
|
||||
if (qryHasJediSlot.result.getValue() == 0)
|
||||
{
|
||||
m_result = static_cast<int>(LoginUpgradeAccountMessage::VUSR_account_has_no_unlocked_slot);
|
||||
return true;
|
||||
}
|
||||
|
||||
// get the list of characters for the account to see if this character is an unlocked slot character
|
||||
TaskGetAvatarList::GetCharactersQuery qryGetCharacters;
|
||||
|
||||
qryGetCharacters.station_id = m_stationId; //lint !e713 // loss of precision unsigned long to long
|
||||
qryGetCharacters.cluster_group_id = m_clusterGroupId;
|
||||
|
||||
rval = session->exec(&qryGetCharacters);
|
||||
if (!rval)
|
||||
{
|
||||
m_result = static_cast<int>(LoginUpgradeAccountMessage::VUSR_db_error);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isUnlockedSlotCharacter = false;
|
||||
int rowsFetched;
|
||||
while ((rowsFetched = qryGetCharacters.fetch()) > 0)
|
||||
{
|
||||
if ((qryGetCharacters.cluster_id.getValue() == static_cast<long>(m_clusterId)) && (qryGetCharacters.object_id.getValue() == m_characterId))
|
||||
{
|
||||
if (qryGetCharacters.character_type.getValue() == 2)
|
||||
{
|
||||
isUnlockedSlotCharacter = true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
qryGetCharacters.done();
|
||||
|
||||
if (!isUnlockedSlotCharacter)
|
||||
{
|
||||
m_result = static_cast<int>(LoginUpgradeAccountMessage::VUSR_not_unlocked_slot_character);
|
||||
return true;
|
||||
}
|
||||
|
||||
// check to see if the account can create a normal character, because
|
||||
// we are going to be making the character into a normal character, and
|
||||
// we must be sure that doing will not violate the normal character limit
|
||||
GetOnlyOpenCharacterSlotsQuery qryGetOnlyOpenCharacterSlots;
|
||||
qryGetOnlyOpenCharacterSlots.station_id = static_cast<long>(m_stationId);
|
||||
qryGetOnlyOpenCharacterSlots.cluster_id = static_cast<long>(m_clusterId);
|
||||
|
||||
rval = session->exec(&qryGetOnlyOpenCharacterSlots);
|
||||
if (!rval)
|
||||
{
|
||||
m_result = static_cast<int>(LoginUpgradeAccountMessage::VUSR_db_error);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<int> openCharacterSlots(4,0);
|
||||
while ((rowsFetched = qryGetOnlyOpenCharacterSlots.fetch()) > 0)
|
||||
{
|
||||
openCharacterSlots[static_cast<unsigned long>(qryGetOnlyOpenCharacterSlots.character_type_id.getValue())]=qryGetOnlyOpenCharacterSlots.num_open_slots.getValue();
|
||||
}
|
||||
|
||||
qryGetOnlyOpenCharacterSlots.done();
|
||||
|
||||
if (openCharacterSlots[1] <= 0)
|
||||
{
|
||||
m_result = static_cast<int>(LoginUpgradeAccountMessage::VUSR_no_available_normal_character_slot);
|
||||
return true;
|
||||
}
|
||||
|
||||
// make the character a normal slot character
|
||||
TaskUpgradeAccount::SetCharacterTypeQuery qrySetNormal;
|
||||
qrySetNormal.cluster_id = static_cast<long>(m_clusterId);
|
||||
qrySetNormal.station_id = static_cast<long>(m_stationId);
|
||||
qrySetNormal.character = m_characterId;
|
||||
qrySetNormal.character_type = 1;
|
||||
|
||||
rval = session->exec(&qrySetNormal);
|
||||
|
||||
qrySetNormal.done();
|
||||
|
||||
if (!rval)
|
||||
{
|
||||
m_result = static_cast<int>(LoginUpgradeAccountMessage::VUSR_db_error);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskVacateUnlockedSlot::onComplete()
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::pair<int, NetworkId>, std::pair<uint32, uint32> > > const vacateUnlockedSlotRsp("VacateUnlockedSlotRsp", std::make_pair(std::make_pair(m_result, m_characterId), std::make_pair(static_cast<uint32>(m_stationId), m_replyGameServerId)));
|
||||
LoginServer::getInstance().sendToCluster(m_clusterId, vacateUnlockedSlotRsp);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskVacateUnlockedSlot::GetOnlyOpenCharacterSlotsQuery::GetOnlyOpenCharacterSlotsQuery() :
|
||||
Query(),
|
||||
station_id(),
|
||||
cluster_id(),
|
||||
character_type_id(),
|
||||
num_open_slots()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskVacateUnlockedSlot::GetOnlyOpenCharacterSlotsQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql = std::string("begin :rc := ")+DatabaseConnection::getInstance().getSchemaQualifier()+"login.get_only_open_character_slots(:station_id,:cluster_id); end;";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskVacateUnlockedSlot::GetOnlyOpenCharacterSlotsQuery::bindParameters()
|
||||
{
|
||||
if (!bindParameter(station_id)) return false;
|
||||
if (!bindParameter(cluster_id)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskVacateUnlockedSlot::GetOnlyOpenCharacterSlotsQuery::bindColumns()
|
||||
{
|
||||
if (!bindCol(character_type_id)) return false;
|
||||
if (!bindCol(num_open_slots)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
DB::Query::QueryMode TaskVacateUnlockedSlot::GetOnlyOpenCharacterSlotsQuery::getExecutionMode() const
|
||||
{
|
||||
return MODE_PLSQL_REFCURSOR;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskSwapUnlockedSlot::TaskSwapUnlockedSlot(int clusterGroupId, uint32 clusterId, StationId stationId, NetworkId const & sourceCharacterId, NetworkId const & targetCharacterId, uint32 replyGameServerId) :
|
||||
TaskRequest(),
|
||||
m_clusterGroupId(clusterGroupId),
|
||||
m_clusterId(clusterId),
|
||||
m_stationId(stationId),
|
||||
m_sourceCharacterId(sourceCharacterId),
|
||||
m_targetCharacterId(targetCharacterId),
|
||||
m_targetCharacterName(),
|
||||
m_replyGameServerId(replyGameServerId),
|
||||
m_result(static_cast<int>(LoginUpgradeAccountMessage::SUSR_db_error))
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
TaskSwapUnlockedSlot::~TaskSwapUnlockedSlot()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool TaskSwapUnlockedSlot::process(DB::Session *session)
|
||||
{
|
||||
bool rval = true;
|
||||
m_result = static_cast<int>(LoginUpgradeAccountMessage::SUSR_success);
|
||||
|
||||
// see if account has an unlocked slot
|
||||
TaskUpgradeAccount::QueryJediQuery qryHasJediSlot;
|
||||
qryHasJediSlot.station_id = static_cast<long>(m_stationId);
|
||||
qryHasJediSlot.character_type = 2;
|
||||
|
||||
rval = session->exec(&qryHasJediSlot);
|
||||
|
||||
qryHasJediSlot.done();
|
||||
|
||||
if (!rval)
|
||||
{
|
||||
m_result = static_cast<int>(LoginUpgradeAccountMessage::SUSR_db_error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// account doesn't have unlocked slot
|
||||
if (qryHasJediSlot.result.getValue() == 0)
|
||||
{
|
||||
m_result = static_cast<int>(LoginUpgradeAccountMessage::SUSR_account_has_no_unlocked_slot);
|
||||
return true;
|
||||
}
|
||||
|
||||
// get the list of characters for the account to see if this character is an unlocked slot character,
|
||||
// and the the target character is not an unlocked slot character, and the target character is on
|
||||
// the same cluster
|
||||
TaskGetAvatarList::GetCharactersQuery qryGetCharacters;
|
||||
|
||||
qryGetCharacters.station_id = m_stationId; //lint !e713 // loss of precision unsigned long to long
|
||||
qryGetCharacters.cluster_group_id = m_clusterGroupId;
|
||||
|
||||
rval = session->exec(&qryGetCharacters);
|
||||
if (!rval)
|
||||
{
|
||||
m_result = static_cast<int>(LoginUpgradeAccountMessage::SUSR_db_error);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool foundSourceCharacter = false;
|
||||
bool isSourceUnlockedSlotCharacter = false;
|
||||
bool isTargetUnlockedSlotCharacter = false;
|
||||
bool isTargetOnSameCluster = false;
|
||||
int rowsFetched;
|
||||
while ((rowsFetched = qryGetCharacters.fetch()) > 0)
|
||||
{
|
||||
if ((qryGetCharacters.cluster_id.getValue() == static_cast<long>(m_clusterId)) && (qryGetCharacters.object_id.getValue() == m_sourceCharacterId))
|
||||
{
|
||||
foundSourceCharacter = true;
|
||||
|
||||
if (qryGetCharacters.character_type.getValue() == 2)
|
||||
{
|
||||
isSourceUnlockedSlotCharacter = true;
|
||||
}
|
||||
}
|
||||
|
||||
// this is not a "else if" because we don't trust that m_sourceCharacterId is always different from m_targetCharacterId
|
||||
if ((qryGetCharacters.cluster_id.getValue() == static_cast<long>(m_clusterId)) && (qryGetCharacters.object_id.getValue() == m_targetCharacterId))
|
||||
{
|
||||
qryGetCharacters.character_name.getValue(m_targetCharacterName);
|
||||
isTargetOnSameCluster = true;
|
||||
|
||||
if (qryGetCharacters.character_type.getValue() == 2)
|
||||
{
|
||||
isTargetUnlockedSlotCharacter = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (foundSourceCharacter && isTargetOnSameCluster)
|
||||
break;
|
||||
}
|
||||
|
||||
qryGetCharacters.done();
|
||||
|
||||
if (!isSourceUnlockedSlotCharacter)
|
||||
{
|
||||
m_result = static_cast<int>(LoginUpgradeAccountMessage::SUSR_not_unlocked_slot_character);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!isTargetOnSameCluster)
|
||||
{
|
||||
m_result = static_cast<int>(LoginUpgradeAccountMessage::SUSR_invalid_target_character);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isTargetUnlockedSlotCharacter)
|
||||
{
|
||||
m_result = static_cast<int>(LoginUpgradeAccountMessage::SUSR_target_character_already_unlocked_slot_character);
|
||||
return true;
|
||||
}
|
||||
|
||||
// make the source character a normal slot character
|
||||
TaskUpgradeAccount::SetCharacterTypeQuery qrySetNormal;
|
||||
qrySetNormal.cluster_id = static_cast<long>(m_clusterId);
|
||||
qrySetNormal.station_id = static_cast<long>(m_stationId);
|
||||
qrySetNormal.character = m_sourceCharacterId;
|
||||
qrySetNormal.character_type = 1;
|
||||
|
||||
rval = session->exec(&qrySetNormal);
|
||||
|
||||
qrySetNormal.done();
|
||||
|
||||
if (!rval)
|
||||
{
|
||||
m_result = static_cast<int>(LoginUpgradeAccountMessage::SUSR_db_error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// make the target character an unlocked slot character
|
||||
TaskUpgradeAccount::SetCharacterTypeQuery qrySetUnlocked;
|
||||
qrySetUnlocked.cluster_id = static_cast<long>(m_clusterId);
|
||||
qrySetUnlocked.station_id = static_cast<long>(m_stationId);
|
||||
qrySetUnlocked.character = m_targetCharacterId;
|
||||
qrySetUnlocked.character_type = 2;
|
||||
|
||||
rval = session->exec(&qrySetUnlocked);
|
||||
|
||||
qrySetUnlocked.done();
|
||||
|
||||
if (!rval)
|
||||
{
|
||||
m_result = static_cast<int>(LoginUpgradeAccountMessage::SUSR_db_error);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TaskSwapUnlockedSlot::onComplete()
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::pair<int, NetworkId>, std::pair<uint32, std::pair<NetworkId, std::string> > > > const swapUnlockedSlotRsp("SwapUnlockedSlotRsp", std::make_pair(std::make_pair(m_result, m_sourceCharacterId), std::make_pair(m_replyGameServerId, std::make_pair(m_targetCharacterId, m_targetCharacterName))));
|
||||
LoginServer::getInstance().sendToCluster(m_clusterId, swapUnlockedSlotRsp);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,200 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TaskSetCharacterType.h
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_TaskUpgradeAccount_H
|
||||
#define INCLUDED_TaskUpgradeAccount_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedDatabaseInterface/Bindable.h"
|
||||
#include "sharedDatabaseInterface/BindableNetworkId.h"
|
||||
#include "sharedDatabaseInterface/DbQuery.h"
|
||||
#include "sharedDatabaseInterface/DbTaskRequest.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class LoginUpgradeAccountMessage;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class TaskUpgradeAccount : public DB::TaskRequest
|
||||
{
|
||||
public:
|
||||
TaskUpgradeAccount(LoginUpgradeAccountMessage *message, uint32 clusterId);
|
||||
~TaskUpgradeAccount();
|
||||
|
||||
public:
|
||||
virtual bool process (DB::Session *session);
|
||||
virtual void onComplete ();
|
||||
|
||||
class SetCharacterTypeQuery : public DB::Query
|
||||
{
|
||||
public:
|
||||
SetCharacterTypeQuery();
|
||||
|
||||
DB::BindableLong cluster_id; //lint !e1925 // public data member
|
||||
DB::BindableLong station_id; //lint !e1925 // public data member
|
||||
DB::BindableNetworkId character; //lint !e1925 // public data member
|
||||
DB::BindableLong character_type; //lint !e1925 // public data member
|
||||
|
||||
virtual void getSQL (std::string &sql);
|
||||
virtual bool bindParameters ();
|
||||
virtual bool bindColumns ();
|
||||
virtual QueryMode getExecutionMode () const;
|
||||
|
||||
private: //disable
|
||||
SetCharacterTypeQuery (const SetCharacterTypeQuery&);
|
||||
SetCharacterTypeQuery &operator= (const SetCharacterTypeQuery&);
|
||||
};
|
||||
|
||||
class QueryJediQuery : public DB::Query
|
||||
{
|
||||
public:
|
||||
QueryJediQuery();
|
||||
|
||||
DB::BindableLong station_id; //lint !e1925 // public data member
|
||||
DB::BindableLong character_type; //lint !e1925 // public data member
|
||||
DB::BindableLong result; //lint !e1925 // public data member
|
||||
|
||||
virtual void getSQL (std::string &sql);
|
||||
virtual bool bindParameters ();
|
||||
virtual bool bindColumns ();
|
||||
virtual QueryMode getExecutionMode () const;
|
||||
|
||||
private: //disable
|
||||
QueryJediQuery (const QueryJediQuery&);
|
||||
QueryJediQuery &operator= (const QueryJediQuery&);
|
||||
};
|
||||
|
||||
private:
|
||||
class AddJediQuery : public DB::Query
|
||||
{
|
||||
public:
|
||||
AddJediQuery();
|
||||
|
||||
DB::BindableLong cluster_id; //lint !e1925 // public data member
|
||||
DB::BindableLong station_id; //lint !e1925 // public data member
|
||||
|
||||
virtual void getSQL (std::string &sql);
|
||||
virtual bool bindParameters ();
|
||||
virtual bool bindColumns ();
|
||||
virtual QueryMode getExecutionMode () const;
|
||||
|
||||
private: //disable
|
||||
AddJediQuery (const AddJediQuery&);
|
||||
AddJediQuery &operator= (const AddJediQuery&);
|
||||
};
|
||||
|
||||
private:
|
||||
TaskUpgradeAccount(); // disable default constructor
|
||||
TaskUpgradeAccount(const TaskUpgradeAccount &); // disable copy constructor
|
||||
TaskUpgradeAccount & operator = (const TaskUpgradeAccount &); // disable assignment operator
|
||||
|
||||
LoginUpgradeAccountMessage *m_message;
|
||||
uint32 m_clusterId;
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class TaskOccupyUnlockedSlot : public DB::TaskRequest
|
||||
{
|
||||
public:
|
||||
TaskOccupyUnlockedSlot(int clusterGroupId, uint32 clusterId, StationId stationId, NetworkId const & characterId, uint32 replyGameServerId);
|
||||
~TaskOccupyUnlockedSlot();
|
||||
|
||||
public:
|
||||
virtual bool process (DB::Session *session);
|
||||
virtual void onComplete ();
|
||||
|
||||
private:
|
||||
TaskOccupyUnlockedSlot(); // disable default constructor
|
||||
TaskOccupyUnlockedSlot(const TaskOccupyUnlockedSlot &); // disable copy constructor
|
||||
TaskOccupyUnlockedSlot & operator = (const TaskOccupyUnlockedSlot &); // disable assignment operator
|
||||
|
||||
int m_clusterGroupId;
|
||||
uint32 m_clusterId;
|
||||
StationId m_stationId;
|
||||
NetworkId m_characterId;
|
||||
uint32 m_replyGameServerId;
|
||||
int m_result;
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class TaskVacateUnlockedSlot : public DB::TaskRequest
|
||||
{
|
||||
public:
|
||||
TaskVacateUnlockedSlot(int clusterGroupId, uint32 clusterId, StationId stationId, NetworkId const & characterId, uint32 replyGameServerId);
|
||||
~TaskVacateUnlockedSlot();
|
||||
|
||||
public:
|
||||
virtual bool process (DB::Session *session);
|
||||
virtual void onComplete ();
|
||||
|
||||
class GetOnlyOpenCharacterSlotsQuery : public DB::Query
|
||||
{
|
||||
public:
|
||||
GetOnlyOpenCharacterSlotsQuery();
|
||||
|
||||
DB::BindableLong station_id; //lint !e1925 // public data member
|
||||
DB::BindableLong cluster_id; //lint !e1925 // public data member
|
||||
DB::BindableLong character_type_id; //lint !e1925 // public data member
|
||||
DB::BindableLong num_open_slots; //lint !e1925 // public data member
|
||||
|
||||
virtual void getSQL(std::string &sql);
|
||||
virtual bool bindParameters();
|
||||
virtual bool bindColumns();
|
||||
virtual QueryMode getExecutionMode() const;
|
||||
|
||||
private: //disable
|
||||
GetOnlyOpenCharacterSlotsQuery(const GetOnlyOpenCharacterSlotsQuery&);
|
||||
GetOnlyOpenCharacterSlotsQuery &operator=(const GetOnlyOpenCharacterSlotsQuery&);
|
||||
};
|
||||
|
||||
private:
|
||||
TaskVacateUnlockedSlot(); // disable default constructor
|
||||
TaskVacateUnlockedSlot(const TaskVacateUnlockedSlot &); // disable copy constructor
|
||||
TaskVacateUnlockedSlot & operator = (const TaskVacateUnlockedSlot &); // disable assignment operator
|
||||
|
||||
int m_clusterGroupId;
|
||||
uint32 m_clusterId;
|
||||
StationId m_stationId;
|
||||
NetworkId m_characterId;
|
||||
uint32 m_replyGameServerId;
|
||||
int m_result;
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class TaskSwapUnlockedSlot : public DB::TaskRequest
|
||||
{
|
||||
public:
|
||||
TaskSwapUnlockedSlot(int clusterGroupId, uint32 clusterId, StationId stationId, NetworkId const & sourceCharacterId, NetworkId const & targetCharacterId, uint32 replyGameServerId);
|
||||
~TaskSwapUnlockedSlot();
|
||||
|
||||
public:
|
||||
virtual bool process (DB::Session *session);
|
||||
virtual void onComplete ();
|
||||
|
||||
private:
|
||||
TaskSwapUnlockedSlot(); // disable default constructor
|
||||
TaskSwapUnlockedSlot(const TaskSwapUnlockedSlot &); // disable copy constructor
|
||||
TaskSwapUnlockedSlot & operator = (const TaskSwapUnlockedSlot &); // disable assignment operator
|
||||
|
||||
int m_clusterGroupId;
|
||||
uint32 m_clusterId;
|
||||
StationId m_stationId;
|
||||
NetworkId m_sourceCharacterId;
|
||||
NetworkId m_targetCharacterId;
|
||||
std::string m_targetCharacterName;
|
||||
uint32 m_replyGameServerId;
|
||||
int m_result;
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
add_executable(LoginServer
|
||||
WinMain.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(LoginServer
|
||||
LoginServershared
|
||||
)
|
||||
@@ -0,0 +1 @@
|
||||
#include "FirstLoginServer.h"
|
||||
@@ -0,0 +1,46 @@
|
||||
#include "FirstLoginServer.h"
|
||||
#include "ConfigLoginServer.h"
|
||||
#include "LoginServer.h"
|
||||
|
||||
#include "sharedCompression/SetupSharedCompression.h"
|
||||
#include "sharedDebug/SetupSharedDebug.h"
|
||||
#include "sharedFile/SetupSharedFile.h"
|
||||
#include "sharedFoundation/SetupSharedFoundation.h"
|
||||
#include "sharedNetworkMessages/SetupSharedNetworkMessages.h"
|
||||
#include "sharedRandom/SetupSharedRandom.h"
|
||||
#include "sharedThread/SetupSharedThread.h"
|
||||
|
||||
#include <time.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
SetupSharedThread::install();
|
||||
SetupSharedDebug::install(1024);
|
||||
|
||||
//-- setup foundation
|
||||
SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game);
|
||||
|
||||
setupFoundationData.argc = argc;
|
||||
setupFoundationData.argv = argv;
|
||||
setupFoundationData.createWindow = false;
|
||||
|
||||
SetupSharedFoundation::install (setupFoundationData);
|
||||
SetupSharedNetworkMessages::install();
|
||||
|
||||
SetupSharedCompression::install();
|
||||
|
||||
SetupSharedFile::install(false);
|
||||
|
||||
SetupSharedRandom::install(time(NULL));
|
||||
|
||||
//-- setup game server
|
||||
ConfigLoginServer::install ();
|
||||
|
||||
//-- run game
|
||||
SetupSharedFoundation::callbackWithExceptionHandling(LoginServer::run);
|
||||
|
||||
SetupSharedFoundation::remove();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user