mirror of
https://github.com/SWG-Source/src.git
synced 2026-09-29 16:13:07 -04:00
Added TransferServer project and CTServiceGameAPI library
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
project(TransferServer)
|
||||
|
||||
add_subdirectory(src)
|
||||
@@ -0,0 +1,89 @@
|
||||
|
||||
set(SHARED_SOURCES
|
||||
shared/CentralServerConnection.cpp
|
||||
shared/CentralServerConnection.h
|
||||
shared/ConfigTransferServer.cpp
|
||||
shared/ConfigTransferServer.h
|
||||
shared/ConsoleCommandParser.cpp
|
||||
shared/ConsoleCommandParser.h
|
||||
shared/ConsoleManager.cpp
|
||||
shared/ConsoleManager.h
|
||||
shared/CTSAPIClient.cpp
|
||||
shared/CTSAPIClient.h
|
||||
shared/FirstTransferServer.h
|
||||
shared/TransferServer.cpp
|
||||
shared/TransferServer.h
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
set(PLATFORM_SOURCES
|
||||
win32/WinMain.cpp
|
||||
)
|
||||
else()
|
||||
set(PLATFORM_SOURCES
|
||||
linux/main.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shared
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedCommandParser/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedCompression/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedDebug/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFile/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedThread/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedUtility/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/server/library/serverNetworkMessages/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/server/library/serverUtility/include/public
|
||||
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/archive/include
|
||||
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/unicode/include
|
||||
${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/soePlatform/CTServiceGameAPI
|
||||
)
|
||||
|
||||
link_directories(${STLPORT_LIBDIR})
|
||||
|
||||
add_executable(TransferServer
|
||||
${SHARED_SOURCES}
|
||||
${PLATFORM_SOURCES}
|
||||
)
|
||||
|
||||
target_link_libraries(TransferServer
|
||||
sharedCommandParser
|
||||
sharedCompression
|
||||
sharedDebug
|
||||
sharedFile
|
||||
sharedFoundation
|
||||
sharedLog
|
||||
sharedMath
|
||||
sharedMemoryManager
|
||||
sharedMessageDispatch
|
||||
sharedNetwork
|
||||
sharedNetworkMessages
|
||||
sharedRandom
|
||||
sharedSynchronization
|
||||
sharedThread
|
||||
sharedUtility
|
||||
serverNetworkMessages
|
||||
serverUtility
|
||||
archive
|
||||
fileInterface
|
||||
localization
|
||||
localizationArchive
|
||||
unicode
|
||||
unicodeArchive
|
||||
udplibrary
|
||||
CTServiceGameAPI
|
||||
${ZLIB_LIBRARY}
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(TransferServer mswsock ws2_32)
|
||||
endif()
|
||||
@@ -0,0 +1,60 @@
|
||||
// main.cpp
|
||||
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Justin Randall
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "FirstTransferServer.h"
|
||||
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
#include "sharedCompression/SetupSharedCompression.h"
|
||||
#include "sharedDebug/SetupSharedDebug.h"
|
||||
#include "sharedFile/SetupSharedFile.h"
|
||||
#include "sharedFoundation/Os.h"
|
||||
#include "sharedFoundation/SetupSharedFoundation.h"
|
||||
#include "sharedNetwork/SetupSharedNetwork.h"
|
||||
#include "sharedNetwork/NetworkHandler.h"
|
||||
#include "sharedNetworkMessages/SetupSharedNetworkMessages.h"
|
||||
#include "sharedThread/SetupSharedThread.h"
|
||||
#include "TransferServer.h"
|
||||
#include "ConfigTransferServer.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.runInBackground = true;
|
||||
SetupSharedFoundation::install (setupFoundationData);
|
||||
|
||||
SetupSharedCompression::install();
|
||||
SetupSharedFile::install(false);
|
||||
SetupSharedNetworkMessages::install();
|
||||
|
||||
SetupSharedNetwork::SetupData networkSetupData;
|
||||
SetupSharedNetwork::getDefaultServerSetupData(networkSetupData);
|
||||
SetupSharedNetwork::install(networkSetupData);
|
||||
NetworkHandler::install();
|
||||
|
||||
Os::setProgramName("TransferServer");
|
||||
ConfigTransferServer::install();
|
||||
|
||||
//-- run server
|
||||
SetupSharedFoundation::callbackWithExceptionHandling(TransferServer::run);
|
||||
|
||||
NetworkHandler::remove();
|
||||
SetupSharedFoundation::remove();
|
||||
SetupSharedThread::remove();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,336 @@
|
||||
// CTSAPIClient.h
|
||||
// Copyright 2000-01, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Justin Randall
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "FirstTransferServer.h"
|
||||
#include "CentralServerConnection.h"
|
||||
#include "ConfigTransferServer.h"
|
||||
#include "CTSAPIClient.h"
|
||||
#include "CTCommon/CTServiceServer.h"
|
||||
#include <map>
|
||||
#include "sharedLog/Log.h"
|
||||
#include "TransferServer.h"
|
||||
#include "UnicodeUtils.h"
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
class CentralServerConnection;
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
namespace CTSAPIClientNamespace
|
||||
{
|
||||
struct TransactionTrackData
|
||||
{
|
||||
const CentralServerConnection * m_sourceCentralServerConnection;
|
||||
const CentralServerConnection * m_destinationCentralServerConnection;
|
||||
unsigned int m_track;
|
||||
};
|
||||
|
||||
std::map<unsigned int, TransactionTrackData> s_activeTransfers;
|
||||
std::map<unsigned int, int> s_completedTransfers;
|
||||
}
|
||||
using namespace CTSAPIClientNamespace;
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
CTSAPIClient::CTSAPIClient(const std::string & hostName, const std::string & game) :
|
||||
CTServiceAPI(hostName.c_str(), game.c_str())
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
CTSAPIClient::~CTSAPIClient()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CTSAPIClient::onTest(const unsigned track, const int resultCode, const unsigned value, void *user)
|
||||
{
|
||||
LOG("CTSAPI", ("CTSAPIClient::onTest(%d, %d, %d, %p)", track, resultCode, value, user));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CTSAPIClient::onReplyTest(const unsigned track, const int resultCode, void *user)
|
||||
{
|
||||
LOG("CTSAPI", ("CTSAPIClient::onReplyTest(%d, %d, %p)", track, resultCode, user));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CTSAPIClient::onReplyMoveStatus(const unsigned track, const int resultCode, void *user)
|
||||
{
|
||||
LOG("CTSAPI", ("CTSAPIClient::onReplyMoveStatus(%d, %d, %p)", track, resultCode, user));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CTSAPIClient::onReplyValidateMove(const unsigned track, const int resultCode, void *user)
|
||||
{
|
||||
LOG("CTSAPI", ("CTSAPIClient::onReplyValidateMove(%d, %d, %p)", track, resultCode, user));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CTSAPIClient::onReplyMove(const unsigned track, const int resultCode, void *user)
|
||||
{
|
||||
LOG("CTSAPI", ("CTSAPIClient::onReplyMove(%d, %d, %p)", track, resultCode, user));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CTSAPIClient::onReplyTransferAccount(const unsigned track, const int resultCode, void *user)
|
||||
{
|
||||
LOG("CTSAPI", ("CTSAPIClient::onReplyTransferAccount(%d, %d, %p)", track, resultCode, user));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CTSAPIClient::onReplyCharacterList(const unsigned track, const int resultCode, void *user)
|
||||
{
|
||||
LOG("CTSAPI", ("CTSAPIClient::onReplyCharacterList(%d, %d, %p)", track, resultCode, user));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CTSAPIClient::onReplyServerList(const unsigned track, const int resultCode, void *user)
|
||||
{
|
||||
LOG("CTSAPI", ("CTSAPIClient::onReplyServerList(%d, %d, %p)",track, resultCode, user));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CTSAPIClient::onReplyDestinationServerList(const unsigned track, const int resultCode, void *user)
|
||||
{
|
||||
LOG("CTSAPI", ("CTSAPIClient::onReplyDestinationServerList(%d, %d, %p)", track, resultCode, user));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
void CTSAPIClient::onServerTest(const unsigned server_track, const char *game, const char *param)
|
||||
{
|
||||
LOG("CTSAPI", ("CTSAPIClient::onServerTest(%d, %s, %s)", server_track, game, param));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CTSAPIClient::onRequestMoveStatus(const unsigned server_track, const char *language, const unsigned transactionID)
|
||||
{
|
||||
LOG("CTSAPI", ("CTSAPIClient::onRequestMoveStatus(%d, %s, %d)", server_track, language, transactionID));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CTSAPIClient::onRequestValidateMove(const unsigned server_track, const char *language, const CTService::CTUnicodeChar *sourceServer, const CTService::CTUnicodeChar *destServer, const CTService::CTUnicodeChar *sourceCharacter, const CTService::CTUnicodeChar *destCharacter, const unsigned uid, const unsigned destuid, bool /*withItems*/, bool /*allowOverride*/)
|
||||
{
|
||||
LOG("CTSAPI", ("CTSAPIClient::onRequestValidateMove(%d, %s, %s, %s, %s, %s, %d, %d", server_track, language, Unicode::wideToNarrow(sourceServer).c_str(), Unicode::wideToNarrow(destServer).c_str(), Unicode::wideToNarrow(sourceCharacter).c_str(), Unicode::wideToNarrow(destCharacter).c_str(), uid, destuid));
|
||||
TransferServer::requestMoveValidation(server_track, uid, destuid, Unicode::wideToNarrow(Unicode::String(sourceServer)), Unicode::wideToNarrow(Unicode::String(destServer)), Unicode::wideToNarrow(Unicode::String(sourceCharacter)), Unicode::wideToNarrow(Unicode::String(destCharacter)), std::string(language));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CTSAPIClient::onRequestMove(const unsigned server_track, const char *language, const CTService::CTUnicodeChar *sourceServer, const CTService::CTUnicodeChar *destServer, const CTService::CTUnicodeChar *sourceCharacter, const CTService::CTUnicodeChar *destCharacter, const unsigned uid, const unsigned destuid, const unsigned transactionID, bool withItems, bool allowOverride)
|
||||
{
|
||||
std::map<unsigned int, TransactionTrackData>::const_iterator f = s_activeTransfers.find(uid);
|
||||
if(f == s_activeTransfers.end())
|
||||
{
|
||||
std::string isWithItems = "false";
|
||||
if(withItems)
|
||||
isWithItems = "true";
|
||||
LOG("CTSAPI", ("CTSAPIClient::onRequestMove(%d, %s, %s, %s, %s, %s, %d, %d, %d, %s)", server_track, language, Unicode::wideToNarrow(sourceServer).c_str(), Unicode::wideToNarrow(destServer).c_str(), Unicode::wideToNarrow(sourceCharacter).c_str(), Unicode::wideToNarrow(destCharacter).c_str(), uid, destuid, transactionID, isWithItems.c_str()));
|
||||
TransferServer::requestMove(server_track, std::string(language), Unicode::wideToNarrow(Unicode::String(sourceServer)), Unicode::wideToNarrow(Unicode::String(destServer)), Unicode::wideToNarrow(Unicode::String(sourceCharacter)), Unicode::wideToNarrow(Unicode::String(destCharacter)), uid, destuid, transactionID, withItems, allowOverride);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("CTSAPI", ("Received a transfer request for station ID %d, but a transfer for that id is already in progress", uid));
|
||||
const unsigned int result = static_cast<unsigned int>(CTService::CT_GAMERESULT_SOFTERROR);
|
||||
IGNORE_RETURN(replyMove(server_track, result, NULL, NULL));
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CTSAPIClient::onRequestTransferAccount(const unsigned server_track, const unsigned uid, const unsigned destuid, const unsigned transactionID)
|
||||
{
|
||||
std::map<unsigned int, TransactionTrackData>::const_iterator f = s_activeTransfers.find(uid);
|
||||
if(f == s_activeTransfers.end())
|
||||
{
|
||||
LOG("CTSAPI", ("CTSAPIClient::onRequestTransferAccount(%d, d, %d, %d)", server_track, uid, destuid, transactionID));
|
||||
TransferServer::requestTransferAccount(server_track, uid, destuid, transactionID);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("CTSAPI", ("Received a transfer request for station ID %d, but a transfer for that id is already in progress", uid));
|
||||
const unsigned int result = static_cast<unsigned int>(CTService::CT_GAMERESULT_SOFTERROR);
|
||||
IGNORE_RETURN(replyTransferAccount(server_track, result, NULL, NULL));
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CTSAPIClient::onRequestCharacterList(const unsigned server_track, const char *language, const CTService::CTUnicodeChar *server, const unsigned uid)
|
||||
{
|
||||
LOG("CTSAPI", ("CTSAPIClient::onRequestCharacterList(%d, %s, %s, %d)", server_track, language, Unicode::wideToNarrow(server).c_str(), uid));
|
||||
TransferServer::requestCharacterList(server_track, uid, Unicode::wideToNarrow(Unicode::String(server)), std::string(language));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CTSAPIClient::onRequestServerList(const unsigned server_track, const char *language)
|
||||
{
|
||||
LOG("CTSAPI", ("CTSAPIClient::onRequestServerList(%d, %s)", server_track, language));
|
||||
std::map<std::string, CentralServerConnection *> galaxies = CentralServerConnection::getGalaxies();
|
||||
std::vector<CTService::CTServiceServer> servers;
|
||||
std::vector<std::string>::const_iterator i;
|
||||
|
||||
for (i = ConfigTransferServer::getServersAllowedToUploadCharacterData().begin(); i != ConfigTransferServer::getServersAllowedToUploadCharacterData().end(); ++i)
|
||||
{
|
||||
std::map<std::string, CentralServerConnection *>::iterator f = galaxies.find(*i);
|
||||
if(f != galaxies.end())
|
||||
{
|
||||
servers.push_back(CTService::CTServiceServer(Unicode::narrowToWide(i->c_str()).c_str()));
|
||||
}
|
||||
}
|
||||
if(! servers.empty())
|
||||
{
|
||||
const unsigned int result = static_cast<unsigned int>(CTService::CT_RESULT_SUCCESS);
|
||||
IGNORE_RETURN(replyServerList(server_track, result, servers.size(), &servers[0], NULL));
|
||||
}
|
||||
else
|
||||
{
|
||||
const unsigned int result = static_cast<unsigned int>(CTService::CT_RESULT_FAILURE);
|
||||
IGNORE_RETURN(replyServerList(server_track, result, servers.size(), NULL, NULL));
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CTSAPIClient::onRequestDestinationServerList(const unsigned server_track, const char *language, const CTService::CTUnicodeChar *character, const CTService::CTUnicodeChar *server)
|
||||
{
|
||||
LOG("CTSAPI", ("CTSAPIClient::onRequestDestinationServerList(%d, %s, %s, %s)", server_track, language, Unicode::wideToNarrow(character).c_str(), Unicode::wideToNarrow(server).c_str()));
|
||||
std::map<std::string, CentralServerConnection *> galaxies = CentralServerConnection::getGalaxies();
|
||||
std::vector<CTService::CTServiceServer> servers;
|
||||
std::vector<std::string>::const_iterator i;
|
||||
|
||||
for (i = ConfigTransferServer::getServersAllowedToDownloadCharacterData().begin(); i != ConfigTransferServer::getServersAllowedToDownloadCharacterData().end(); ++i)
|
||||
{
|
||||
std::map<std::string, CentralServerConnection *>::iterator f = galaxies.find(*i);
|
||||
if(f != galaxies.end())
|
||||
{
|
||||
servers.push_back(CTService::CTServiceServer(Unicode::narrowToWide(i->c_str()).c_str()));
|
||||
}
|
||||
}
|
||||
if(! servers.empty())
|
||||
{
|
||||
const unsigned int result = static_cast<unsigned int>(CTService::CT_RESULT_SUCCESS);
|
||||
IGNORE_RETURN(replyDestinationServerList(server_track, result, servers.size(), &servers[0], NULL));
|
||||
}
|
||||
else
|
||||
{
|
||||
const unsigned int result = static_cast<unsigned int>(CTService::CT_RESULT_FAILURE);
|
||||
IGNORE_RETURN(replyDestinationServerList(server_track, result, servers.size(), NULL, NULL));
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CTSAPIClient::onConnect(const char *host, const short port, const short current, const short max)
|
||||
{
|
||||
LOG("CTSAPI", ("CTSAPIClient::onConnect(%s, %d, %d, %d)", host, port, current, max));
|
||||
REPORT_LOG(true, ("CTSAPIClient::onConnect(%s, %d, %d, %d)\n", host, port, current, max));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
void CTSAPIClient::onDisconnect(const char *host, const short port, const short current, const short max)
|
||||
{
|
||||
LOG("CTSAPI", ("CTSAPIClient::onDisconnect(%s, %d, %d, %d)", host, port, current, max));
|
||||
REPORT_LOG(true, ("CTSAPIClient::onDisconnect(%s, %d, %d, %d)\n", host, port, current, max));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CTSAPIClient::moveStart(unsigned int stationId, unsigned int track, const CentralServerConnection * sourceCentralServerConnection, const CentralServerConnection * destinationCentralServerConnection)
|
||||
{
|
||||
// first check to see if this track has been completed
|
||||
std::map<unsigned int, int>::iterator f = s_completedTransfers.find(track);
|
||||
if(f != s_completedTransfers.end())
|
||||
{
|
||||
IGNORE_RETURN(replyMove(track, f->second, NULL, NULL));
|
||||
}
|
||||
else
|
||||
{
|
||||
TransactionTrackData trackData;
|
||||
trackData.m_destinationCentralServerConnection = destinationCentralServerConnection;
|
||||
trackData.m_sourceCentralServerConnection = sourceCentralServerConnection;
|
||||
trackData.m_track = track;
|
||||
IGNORE_RETURN(s_activeTransfers.insert(std::make_pair(stationId, trackData)));
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CTSAPIClient::lostCentralServerConnection(const CentralServerConnection * centralServerConnection)
|
||||
{
|
||||
// send a failure response to the CTS backend for all id's with
|
||||
// a transaction in progress on the dead server
|
||||
std::map<unsigned int, TransactionTrackData>::iterator i;
|
||||
const unsigned int result = static_cast<unsigned int>(CTService::CT_GAMERESULT_SERVER_IS_DOWN);
|
||||
for(i = s_activeTransfers.begin(); i != s_activeTransfers.end();)
|
||||
{
|
||||
if(i->second.m_sourceCentralServerConnection == centralServerConnection || i->second.m_destinationCentralServerConnection == centralServerConnection)
|
||||
{
|
||||
IGNORE_RETURN(replyMove(i->second.m_track, result, NULL, NULL));
|
||||
s_activeTransfers.erase(i++);
|
||||
}
|
||||
else
|
||||
{
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// NOT IMPLEMENTED IN SWG TRANSFER SERVICE
|
||||
void CTSAPIClient::moveComplete(unsigned int id, unsigned int track, int result) const
|
||||
{
|
||||
std::map<unsigned int, TransactionTrackData>::iterator f = s_activeTransfers.find(id);
|
||||
if(f != s_activeTransfers.end())
|
||||
{
|
||||
s_activeTransfers.erase(f);
|
||||
}
|
||||
if(track != 0)
|
||||
{
|
||||
s_completedTransfers.insert(std::make_pair(track, result));
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// NOT IMPLEMENTED IN SWG TRANSFER SERVICE
|
||||
void CTSAPIClient::onReplyDelete(const unsigned int, const int, void *)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// NOT IMPLEMENTED IN SWG TRANSFER SERVICE
|
||||
void CTSAPIClient::onReplyRestore(const unsigned int, const int, void *)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// NOT IMPLEMENTED IN SWG TRANSFER SERVICE
|
||||
void CTSAPIClient::onRequestDelete(const unsigned int, const char *, const CTService::CTUnicodeChar *, const CTService::CTUnicodeChar *, const CTService::CTUnicodeChar *, const CTService::CTUnicodeChar *, const unsigned int, const unsigned int, const unsigned int, bool, bool)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// NOT IMPLEMENTED IN SWG TRANSFER SERVICE
|
||||
void CTSAPIClient::onRequestRestore(const unsigned int, const char *, const CTService::CTUnicodeChar *, const CTService::CTUnicodeChar *, const CTService::CTUnicodeChar *, const CTService::CTUnicodeChar *, const unsigned int, const unsigned int, const unsigned int, bool, bool)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@@ -0,0 +1,65 @@
|
||||
// CTSAPIClient.h
|
||||
// Copyright 2000-01, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Justin Randall
|
||||
|
||||
#ifndef _INCLUDED_CTSAPIClient_H
|
||||
#define _INCLUDED_CTSAPIClient_H
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "CTServiceAPI.h"
|
||||
#include <string>
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
class CTSAPIClient : public CTService::CTServiceAPI
|
||||
{
|
||||
public:
|
||||
CTSAPIClient(const std::string & hostName, const std::string & game);
|
||||
virtual ~CTSAPIClient();
|
||||
|
||||
virtual void onConnect(const char *host, const short port, const short current, const short max);
|
||||
virtual void onDisconnect(const char *host, const short port, const short current, const short max);
|
||||
|
||||
// ----- Normal Callbacks as a response to requests sent -----
|
||||
|
||||
virtual void onTest(const unsigned track, const int resultCode, const unsigned value, void *user);
|
||||
virtual void onReplyTest(const unsigned track, const int resultCode, void *user);
|
||||
virtual void onReplyMoveStatus(const unsigned track, const int resultCode, void *user);
|
||||
virtual void onReplyValidateMove(const unsigned track, const int resultCode, void *user);
|
||||
virtual void onReplyMove(const unsigned track, const int resultCode, void *user);
|
||||
virtual void onReplyTransferAccount(const unsigned track, const int resultCode, void *user);
|
||||
virtual void onReplyCharacterList(const unsigned track, const int resultCode, void *user);
|
||||
virtual void onReplyServerList(const unsigned track, const int resultCode, void *user);
|
||||
virtual void onReplyDestinationServerList(const unsigned track, const int resultCode, void *user);
|
||||
|
||||
// ----- Callbacks generated by the server directly -----
|
||||
|
||||
virtual void onServerTest(const unsigned server_track, const char *game, const char *param);
|
||||
virtual void onRequestMoveStatus(const unsigned server_track, const char *language, const unsigned transactionID);
|
||||
virtual void onRequestValidateMove(const unsigned server_track, const char *language, const CTService::CTUnicodeChar *sourceServer, const CTService::CTUnicodeChar *destServer, const CTService::CTUnicodeChar *sourceCharacter,const CTService::CTUnicodeChar *destCharacter, const unsigned uid, const unsigned destuid, bool withItems, bool);
|
||||
virtual void onRequestMove(const unsigned server_track, const char *language, const CTService::CTUnicodeChar *sourceServer, const CTService::CTUnicodeChar *destServer, const CTService::CTUnicodeChar *sourceCharacter, const CTService::CTUnicodeChar *destCharacter, const unsigned uid, const unsigned destuid, const unsigned transactionID, bool withItems, bool allowOverride);
|
||||
virtual void onRequestTransferAccount(const unsigned server_track, const unsigned uid, const unsigned destuid, const unsigned transactionID);
|
||||
virtual void onRequestCharacterList(const unsigned server_track, const char *language, const CTService::CTUnicodeChar *server, const unsigned uid);
|
||||
virtual void onRequestServerList(const unsigned server_track, const char *language);
|
||||
virtual void onRequestDestinationServerList(const unsigned server_track, const char *language, const CTService::CTUnicodeChar *character, const CTService::CTUnicodeChar *server);
|
||||
void moveComplete(unsigned int id, unsigned int track, int result) const;
|
||||
void moveStart(unsigned int id, unsigned int track, const CentralServerConnection * sourceCentralServerConnection, const CentralServerConnection * destinationCentralServerConnection);
|
||||
void lostCentralServerConnection(const CentralServerConnection * centralServerConnection);
|
||||
|
||||
private:
|
||||
/* NOT IMPLEMENTED IN SWG TRANSFER SERVICE */
|
||||
void onReplyDelete(const unsigned int, const int, void *);
|
||||
void onReplyRestore(const unsigned int, const int, void *);
|
||||
void onRequestDelete(const unsigned int, const char *, const CTService::CTUnicodeChar *, const CTService::CTUnicodeChar *, const CTService::CTUnicodeChar *, const CTService::CTUnicodeChar *, const unsigned int, const unsigned int, const unsigned int, bool, bool);
|
||||
void onRequestRestore(const unsigned int, const char *, const CTService::CTUnicodeChar *, const CTService::CTUnicodeChar *, const CTService::CTUnicodeChar *, const CTService::CTUnicodeChar *, const unsigned int, const unsigned int, const unsigned int, bool, bool);
|
||||
|
||||
private:
|
||||
CTSAPIClient();
|
||||
CTSAPIClient(const CTSAPIClient &);
|
||||
CTSAPIClient & operator= (const CTSAPIClient &);
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#endif//_INCLUDED_CTSAPIClient_H
|
||||
@@ -0,0 +1,410 @@
|
||||
// CentralServerConnection.cpp
|
||||
// Copyright 2000-01, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Justin Randall
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "FirstTransferServer.h"
|
||||
#include "CentralServerConnection.h"
|
||||
#include "ConsoleManager.h"
|
||||
#include "TransferServer.h"
|
||||
#include "serverNetworkMessages/CharacterTransferStatusMessage.h"
|
||||
#include "serverNetworkMessages/DownloadCharacterMessage.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 "serverNetworkMessages/TransferReplyMoveValidation.h"
|
||||
#include "serverNetworkMessages/UploadCharacterMessage.h"
|
||||
#include "sharedLog/Log.h"
|
||||
#include "sharedCommandParser/CommandParser.h"
|
||||
#include "sharedNetworkMessages/ConsoleChannelMessages.h"
|
||||
#include "sharedNetworkMessages/GameNetworkMessage.h"
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
#include "UnicodeUtils.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
namespace CentralServerConnectionNamespace
|
||||
{
|
||||
std::map<std::string, CentralServerConnection *> s_centralServerConnections;
|
||||
}
|
||||
|
||||
using namespace CentralServerConnectionNamespace;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
CentralServerConnection::CentralServerConnection(UdpConnectionMT * u, TcpClient * t) :
|
||||
ServerConnection(u, t),
|
||||
m_galaxyName("")
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
CentralServerConnection::~CentralServerConnection()
|
||||
{
|
||||
std::map<std::string, CentralServerConnection *>::iterator f = s_centralServerConnections.find(m_galaxyName);
|
||||
if(f != s_centralServerConnections.end())
|
||||
{
|
||||
s_centralServerConnections.erase(f);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
CentralServerConnection * CentralServerConnection::getCentralServerConnectionForGalaxy(const std::string & galaxyName)
|
||||
{
|
||||
CentralServerConnection * result = 0;
|
||||
std::map<std::string, CentralServerConnection *>::iterator f = s_centralServerConnections.find(galaxyName);
|
||||
if(f != s_centralServerConnections.end())
|
||||
{
|
||||
result = f->second;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
const std::map<std::string, CentralServerConnection *> & CentralServerConnection::getGalaxies()
|
||||
{
|
||||
return s_centralServerConnections;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CentralServerConnection::onConnectionClosed()
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Connection with CentralServer running Galaxy %s has closed\n", m_galaxyName.c_str()));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CentralServerConnection::onConnectionOpened()
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: A connection with a CentralServer has opened\n"));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CentralServerConnection::onReceive(const Archive::ByteStream & message)
|
||||
{
|
||||
Archive::ReadIterator ri = message.begin();
|
||||
const GameNetworkMessage msg(ri);
|
||||
ri = message.begin();
|
||||
if(msg.isType("CentralGalaxyName"))
|
||||
{
|
||||
|
||||
const GenericValueTypeMessage<std::string> cgn(ri);
|
||||
setGalaxyName(cgn.getValue());
|
||||
LOG("CustomerService", ("CharacterTransfer: Received CentralGalaxyName for %s", cgn.getValue().c_str()));
|
||||
}
|
||||
else if(msg.isType("UploadCharacterMessage"))
|
||||
{
|
||||
// receiving character data
|
||||
const UploadCharacterMessage ucm(ri);
|
||||
CharacterTransferData data;
|
||||
data.stationId = ucm.getStationId();
|
||||
data.fromGalaxy = m_galaxyName;
|
||||
data.packedData = ucm.getPackedCharacterData();
|
||||
bool result = TransferServer::uploadCharacterTransferData(data, ucm.getIsAdmin());
|
||||
if(result)
|
||||
{
|
||||
CharacterTransferStatusMessage uploadResult(ucm.getFromGameServerId(), ucm.getFromCharacterId(), "@base_player:upload_success");
|
||||
send(uploadResult, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
CharacterTransferStatusMessage uploadResult(ucm.getFromGameServerId(), ucm.getFromCharacterId(), "@base_player:upload_fail");
|
||||
send(uploadResult, true);
|
||||
}
|
||||
}
|
||||
else if(msg.isType("DownloadCharacterMessage"))
|
||||
{
|
||||
// retreive packed data from transfer server and
|
||||
// send it to the requesting central server
|
||||
const DownloadCharacterMessage dcm(ri);
|
||||
const CharacterTransferData * data = TransferServer::getCharacterTransferData(dcm.getStationId(), m_galaxyName, dcm.getIsAdmin());
|
||||
if(data)
|
||||
{
|
||||
const UploadCharacterMessage ucm(data->stationId, data->packedData, dcm.getGameServerId(), dcm.getToCharacterId(), true);
|
||||
send(ucm, true);
|
||||
LOG("CustomerService", ("CharacterTransfer: Character data for SUID %d downloaded\n", data->stationId));
|
||||
}
|
||||
else
|
||||
{
|
||||
CharacterTransferStatusMessage downloadResult(dcm.getGameServerId(), dcm.getToCharacterId(), "@base_player:download_fail");
|
||||
send(downloadResult, true);
|
||||
}
|
||||
|
||||
}
|
||||
else if(msg.isType("AuthorizeDownload"))
|
||||
{
|
||||
const GenericValueTypeMessage<unsigned int> auth(ri);
|
||||
TransferServer::authorizeDownload(auth.getValue());
|
||||
}
|
||||
else if(msg.isType("UnauthorizeDownload"))
|
||||
{
|
||||
const GenericValueTypeMessage<unsigned int> auth(ri);
|
||||
TransferServer::unauthorizeDownload(auth.getValue());
|
||||
}
|
||||
else if(msg.isType("TransferReplyCharacterList"))
|
||||
{
|
||||
const TransferReplyCharacterList reply(ri);
|
||||
|
||||
// TESTING!
|
||||
LOG("CustomerService", ("CharacterTransfer: Received character list for station id %d\n", reply.getStationId()));
|
||||
const std::vector<AvatarRecord> & avatarList = reply.getAvatarList();
|
||||
std::vector<AvatarRecord>::const_iterator i;
|
||||
LOG("CustomerService", ("CharacterTransfer: Enumerating %d characters", avatarList.size()));
|
||||
for(i = avatarList.begin() ; i != avatarList.end(); ++i)
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: m_name = \"%s\" m_networkId = %s\n", Unicode::wideToNarrow(i->m_name).c_str(), i->m_networkId.getValueString().c_str()));
|
||||
}
|
||||
|
||||
// TESTING END
|
||||
TransferServer::replyCharacterList(reply);
|
||||
}
|
||||
else if(msg.isType("TransferReplyMoveValidation"))
|
||||
{
|
||||
const TransferReplyMoveValidation reply(ri);
|
||||
if(reply.getResult() == TransferReplyMoveValidation::TRMVR_can_create_regular_character)
|
||||
{
|
||||
// save off the source character's template crc so it can be used in
|
||||
// subsequent TransferRequestMoveValidation queries, so the LoginServer
|
||||
// doesn't have to continually query the DB to fetch the same information
|
||||
// over and over again, because the character's template crc
|
||||
// (i.e. the character's species) should never, ever change
|
||||
TransferServer::cacheSourceCharacterTemplateCrc(reply.getSourceStationId(), reply.getSourceGalaxy(), reply.getSourceCharacter(), reply.getSourceCharacterTemplateId());
|
||||
|
||||
TransferCharacterData requestData(reply.getTransferRequestSource());
|
||||
requestData.setTrack(reply.getTrack());
|
||||
requestData.setCustomerLocalizedLanguage(reply.getCustomerLocalizedLanguage());
|
||||
requestData.setSourceGalaxy(reply.getSourceGalaxy());
|
||||
requestData.setDestinationGalaxy(reply.getDestinationGalaxy());
|
||||
requestData.setSourceCharacterName(reply.getSourceCharacter());
|
||||
requestData.setObjectTemplateCrc(reply.getSourceCharacterTemplateId());
|
||||
requestData.setDestinationCharacterName(reply.getDestinationCharacter());
|
||||
requestData.setSourceStationId(reply.getSourceStationId());
|
||||
requestData.setDestinationStationId(reply.getDestinationStationId());
|
||||
const GenericValueTypeMessage<TransferCharacterData> requestNameValidation("TransferRequestNameValidation", requestData);
|
||||
CentralServerConnection * destinationConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(reply.getDestinationGalaxy());
|
||||
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferReplyMoveValidation for %s on %s to %s on %s from CentralServer. Sending TransferRequestNameValidation to destination CentralServer.", reply.getSourceCharacter().c_str(), reply.getSourceGalaxy().c_str(), reply.getDestinationCharacter().c_str(), reply.getDestinationGalaxy().c_str()));
|
||||
|
||||
const GenericValueTypeMessage<std::pair<unsigned int, unsigned int> > kick("TransferRequestKickConnectedClients", std::make_pair(requestData.getSourceStationId(), requestData.getDestinationStationId()));
|
||||
if(destinationConnection)
|
||||
{
|
||||
destinationConnection->send(requestNameValidation, true);
|
||||
destinationConnection->send(kick, true);
|
||||
}
|
||||
|
||||
CentralServerConnection * sourceConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(reply.getSourceGalaxy());
|
||||
if(sourceConnection)
|
||||
{
|
||||
sourceConnection->send(kick, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: TransferReplyMoveValidation failed for %s on %s to %s on %s from CentralServer because the account cannot create a new character on the destination server", reply.getSourceCharacter().c_str(), reply.getSourceGalaxy().c_str(), reply.getDestinationCharacter().c_str(), reply.getDestinationGalaxy().c_str()));
|
||||
TransferServer::failedToValidateTransfer(reply);
|
||||
}
|
||||
}
|
||||
else if(msg.isType("TransferReplyNameValidation"))
|
||||
{
|
||||
const GenericValueTypeMessage<std::pair<std::string, TransferCharacterData> > replyNameValidation(ri);
|
||||
if(!replyNameValidation.getValue().second.getIsMoveRequest())
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Received replyNameValidation for move validation request. (%s) %s", replyNameValidation.getValue().first.c_str(), replyNameValidation.getValue().second.toString().c_str()));
|
||||
TransferServer::replyValidateMove(replyNameValidation.getValue().second);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(TransferServer::isRename(replyNameValidation.getValue().second))
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Received replyNameValidation for rename request, starting character rename protocol. (%s) %s", replyNameValidation.getValue().first.c_str(), replyNameValidation.getValue().second.toString().c_str()));
|
||||
const GenericValueTypeMessage<TransferCharacterData> renameCharacter("TransferRenameCharacter", replyNameValidation.getValue().second);
|
||||
CentralServerConnection * centralServerConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(replyNameValidation.getValue().second.getSourceGalaxy());
|
||||
if(centralServerConnection)
|
||||
{
|
||||
centralServerConnection->send(renameCharacter, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
TransferServer::transferCreateCharacterFailed(replyNameValidation.getValue().second);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(true, ("Received TransferReplyNameValidation for a move request that is not a rename!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(msg.isType("TransferReplyCharacterDataFromLoginServer"))
|
||||
{
|
||||
const GenericValueTypeMessage<TransferCharacterData> reply(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Got TransferReplyCharacterDataFromLoginServer, characterId=%s\n", reply.getValue().getCharacterId().getValueString().c_str()));
|
||||
|
||||
// is this a transfer or a rename?
|
||||
if(TransferServer::isRename(reply.getValue()))
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Sending TransferRequestNameValidation for character rename request: %s", reply.getValue().toString().c_str()));
|
||||
// send a name validation request
|
||||
const GenericValueTypeMessage<TransferCharacterData> requestNameValidation("TransferRequestNameValidation", reply.getValue());
|
||||
CentralServerConnection * centralServerConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(reply.getValue().getSourceGalaxy());
|
||||
if(centralServerConnection)
|
||||
{
|
||||
centralServerConnection->send(requestNameValidation, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// this is a transfer
|
||||
TransferServer::getLoginLocationData(reply.getValue());
|
||||
}
|
||||
}
|
||||
else if(msg.isType("TransferReplyLoginLocationData"))
|
||||
{
|
||||
const GenericValueTypeMessage<TransferCharacterData> reply(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Got TransferReplyLoginLocationData from CentralServer. TransferCharacterData=%s\n", reply.getValue().toString().c_str()));
|
||||
|
||||
// send character to ConnectionServer for login to a game server
|
||||
const GenericValueTypeMessage<TransferCharacterData> login("TransferLoginCharacterToSourceServer", reply.getValue());
|
||||
LOG("CustomerService", ("CharacterTransfer: Sending TransferLoginCharacterToSourceServer to CentralServer : %s", login.getValue().toString().c_str()));
|
||||
send(login, true);
|
||||
}
|
||||
else if(msg.isType("TransferReceiveDataFromGameServer"))
|
||||
{
|
||||
const GenericValueTypeMessage<TransferCharacterData> transferReply(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Got TransferReceiveDataFromGameServer: %s", transferReply.getValue().toString().c_str()));
|
||||
REPORT_LOG(true, ("Got TransferReceiveDataFromGameServer: %s\n", transferReply.getValue().toString().c_str()));
|
||||
|
||||
// find a central server connection for the target cluster
|
||||
CentralServerConnection * destinationCentralConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(transferReply.getValue().getDestinationGalaxy());
|
||||
if(destinationCentralConnection)
|
||||
{
|
||||
// send character to ConnectionServer for creation on the destination server
|
||||
GenericValueTypeMessage<TransferCharacterData> login("TransferLoginCharacterToDestinationServer", transferReply.getValue());
|
||||
destinationCentralConnection->send(login, true);
|
||||
LOG("CustomerService", ("CharacterTransfer: Sending TransferLoginCharacterToDestinationServer to CentralServer (%s) for (%s)", transferReply.getValue().getDestinationGalaxy().c_str(), login.getValue().toString().c_str()));
|
||||
}
|
||||
else
|
||||
{
|
||||
//@todo: report error to CTS API
|
||||
LOG("CustomerService", ("CharacterTransfer: Failed to get a CentralServer connection for %s", transferReply.getValue().getDestinationGalaxy().c_str()));
|
||||
TransferServer::transferCreateCharacterFailed(transferReply.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
else if(msg.isType("ApplyTransferDataSuccess"))
|
||||
{
|
||||
const GenericValueTypeMessage<TransferCharacterData> success(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received ApplyTransferDataSuccess from target galaxy. %s", success.getValue().toString().c_str()));
|
||||
|
||||
CentralServerConnection * centralServerConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(success.getValue().getSourceGalaxy());
|
||||
if(centralServerConnection)
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Sending ToggleAvatarLoginStatus request to source central server"));
|
||||
const ToggleAvatarLoginStatus toggleLoginStatus(success.getValue().getSourceGalaxy(), success.getValue().getSourceStationId(), success.getValue().getCharacterId(), false);
|
||||
centralServerConnection->send(toggleLoginStatus, true);
|
||||
TransferServer::replyMoveSuccess(success.getValue());
|
||||
LOG("CustomerService", ("CharacterTransfer: TRANSFER SUCCESSFUL for transactionId=%u", success.getValue().getTransactionId()));
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Transfer failed on target galaxy : %s", success.getValue().toString().c_str()));
|
||||
TransferServer::transferCreateCharacterFailed(success.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
else if(msg.isType("ApplyTransferDataFail"))
|
||||
{
|
||||
const GenericValueTypeMessage<TransferCharacterData> fail(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received ApplyTransferDataFail from target galaxy. %s", fail.getValue().toString().c_str()));
|
||||
|
||||
CentralServerConnection * centralServerConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(fail.getValue().getDestinationGalaxy());
|
||||
if(centralServerConnection)
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: failed to apply transfer data. Deleting character on destination server. %s", fail.getValue().toString().c_str()));
|
||||
const GenericValueTypeMessage<TransferCharacterData> deleteCharacter("DeleteFailedTransfer", fail.getValue());
|
||||
centralServerConnection->send(deleteCharacter, true);
|
||||
TransferServer::failedToApplyTransferData(fail.getValue());
|
||||
}
|
||||
}
|
||||
else if(msg.isType("TransferCreateCharacterFailed"))
|
||||
{
|
||||
const GenericValueTypeMessage<TransferCharacterData> fail(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferCreateCharacterFailed, sending response to CTS API. %s", fail.getValue().toString().c_str()));
|
||||
TransferServer::transferCreateCharacterFailed(fail.getValue());
|
||||
}
|
||||
else if(msg.isType("TransferRenameCharacterReply"))
|
||||
{
|
||||
const GenericValueTypeMessage<TransferCharacterData> reply(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferRenameCharacterReply from Central Server : %s", reply.getValue().toString().c_str()));
|
||||
if(reply.getValue().getIsValidName())
|
||||
{
|
||||
TransferServer::replyMoveSuccess(reply.getValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
TransferServer::transferCreateCharacterFailed(reply.getValue());
|
||||
}
|
||||
}
|
||||
else if(msg.isType("TransferAccountReplySuccessTransferServer"))
|
||||
{
|
||||
const GenericValueTypeMessage<TransferAccountData> reply(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferAccountReplySuccessTransferServer from station Id %d to station Id %d", reply.getValue().getSourceStationId(), reply.getValue().getDestinationStationId()));
|
||||
TransferServer::replyTransferAccountSuccess(reply.getValue());
|
||||
}
|
||||
else if(msg.isType("TransferAccountFailedToUpdateGameDatabase"))
|
||||
{
|
||||
const GenericValueTypeMessage<TransferAccountData> reply(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferAccountFailedToUpdateGameDatabase for transfer from station Id %d to station Id %d", reply.getValue().getSourceStationId(), reply.getValue().getDestinationStationId()));
|
||||
TransferServer::failedToTransferAccountNoCentralConnection(reply.getValue());
|
||||
}
|
||||
else if(msg.isType("TransferAccountFailedDestinationNotEmpty"))
|
||||
{
|
||||
const GenericValueTypeMessage<TransferAccountData> reply(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferAccountFailedDestinationNotEmpty for transfer from station Id %d to station Id %d", reply.getValue().getSourceStationId(), reply.getValue().getDestinationStationId()));
|
||||
TransferServer::failedToTransferAccountDestinationNotEmpty(reply.getValue());
|
||||
}
|
||||
else if(msg.isType("ReplyTransferDataFail"))
|
||||
{
|
||||
const GenericValueTypeMessage<TransferCharacterData> reply(ri);
|
||||
TransferServer::failedToRetrieveTransferData(reply.getValue());
|
||||
}
|
||||
else if(msg.isType("TransferFailGameServerClosedConnectionWithConnectionServer"))
|
||||
{
|
||||
const GenericValueTypeMessage<TransferCharacterData> fail(ri);
|
||||
TransferServer::failedToTransferCharacterGameConnectionClosed(fail.getValue());
|
||||
}
|
||||
else if(msg.isType("TransferFailConnectionServerClosedConnectionWithCentralServer"))
|
||||
{
|
||||
const GenericValueTypeMessage<unsigned int> fail(ri);
|
||||
TransferServer::failedToTransferCharacterConnectionServerConnectionClosed(fail.getValue());
|
||||
}
|
||||
else if(msg.isType("ConGenericMessage"))
|
||||
{
|
||||
const ConGenericMessage cm(ri);
|
||||
std::string result;
|
||||
ConsoleManager::processString(cm.getMsg(), static_cast<const NetworkId::NetworkIdType>(cm.getMsgId()), result);
|
||||
const ConGenericMessage response(result, cm.getMsgId());
|
||||
send(response, true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CentralServerConnection::setGalaxyName(const std::string & galaxyName)
|
||||
{
|
||||
s_centralServerConnections[galaxyName] = this;
|
||||
m_galaxyName = galaxyName;
|
||||
REPORT_LOG("CentralServerConnection", ("Galaxy %s is handled by CentralServerConnection with %s:%d\n", m_galaxyName.c_str(), getRemoteAddress().c_str(), getRemotePort()));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@@ -0,0 +1,42 @@
|
||||
// CentralServerConnection.h
|
||||
// Copyright 2000-01, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Justin Randall
|
||||
|
||||
#ifndef _INCLUDED_CentralServerConnection_H
|
||||
#define _INCLUDED_CentralServerConnection_H
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "serverUtility/ServerConnection.h"
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
class CentralServerConnection;
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
class CentralServerConnection : public ServerConnection
|
||||
{
|
||||
public:
|
||||
CentralServerConnection(UdpConnectionMT *, TcpClient * t);
|
||||
~CentralServerConnection();
|
||||
|
||||
virtual void onConnectionClosed ();
|
||||
virtual void onConnectionOpened ();
|
||||
virtual void onReceive (const Archive::ByteStream & message);
|
||||
|
||||
static CentralServerConnection * getCentralServerConnectionForGalaxy(const std::string & galaxyName);
|
||||
void setGalaxyName (const std::string & galaxyName);
|
||||
|
||||
static const std::map<std::string, CentralServerConnection *> & getGalaxies();
|
||||
|
||||
private:
|
||||
CentralServerConnection & operator = (const CentralServerConnection & rhs);
|
||||
CentralServerConnection(const CentralServerConnection & source);
|
||||
|
||||
std::string m_galaxyName;
|
||||
}; //lint !e1712 default constructor not defined for class 'CentralServerConnection'
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#endif // _INCLUDED_CentralServerConnection_H
|
||||
@@ -0,0 +1,137 @@
|
||||
// ConfigTransferServer.cpp
|
||||
// Copyright 2000-01, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Justin Randall
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "FirstTransferServer.h"
|
||||
#include "sharedFoundation/ConfigFile.h"
|
||||
#include "sharedNetwork/SetupSharedNetwork.h"
|
||||
#include "ConfigTransferServer.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
ConfigTransferServer::Data * ConfigTransferServer::data = 0;
|
||||
|
||||
#define KEY_INT(a,b) (data->a = ConfigFile::getKeyInt("TransferServer", #a, b))
|
||||
#define KEY_BOOL(a,b) (data->a = ConfigFile::getKeyBool("TransferServer", #a, b))
|
||||
#define KEY_STRING(a,b) (data->a = ConfigFile::getKeyString("TransferServer", #a, b))
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
namespace ConfigTransferServerNamespace
|
||||
{
|
||||
std::vector<std::string> s_serversAllowedToUploadCharacterData;
|
||||
std::vector<std::string> s_serversAllowedToDownloadCharacterData;
|
||||
}
|
||||
|
||||
using namespace ConfigTransferServerNamespace;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const std::vector<std::string> & ConfigTransferServer::getServersAllowedToUploadCharacterData()
|
||||
{
|
||||
return s_serversAllowedToUploadCharacterData;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const std::vector<std::string> & ConfigTransferServer::getServersAllowedToDownloadCharacterData()
|
||||
{
|
||||
return s_serversAllowedToDownloadCharacterData;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void ConfigTransferServer::install(void)
|
||||
{
|
||||
SetupSharedNetwork::SetupData networkSetupData;
|
||||
SetupSharedNetwork::getDefaultServerSetupData(networkSetupData);
|
||||
|
||||
data = new ConfigTransferServer::Data;
|
||||
|
||||
KEY_INT (centralServerServiceBindPort, 50005);
|
||||
KEY_STRING (centralServerServiceBindInterface, "");
|
||||
KEY_BOOL (allowSameServerTransfers, false);
|
||||
KEY_BOOL (allowAccountTransfers, true);
|
||||
KEY_STRING (apiServerHostAddress, "");
|
||||
KEY_BOOL (transferChatAvatar, false);
|
||||
|
||||
int index = 0;
|
||||
char const * result = 0;
|
||||
do
|
||||
{
|
||||
result = ConfigFile::getKeyString("TransferServer", "serverAllowedToUploadCharacterData", index++, 0);
|
||||
if (result != 0)
|
||||
{
|
||||
s_serversAllowedToUploadCharacterData.push_back(result);
|
||||
}
|
||||
}
|
||||
while (result);
|
||||
|
||||
index = 0;
|
||||
result = 0;
|
||||
do
|
||||
{
|
||||
result = ConfigFile::getKeyString("TransferServer", "serverAllowedToDownloadCharacterData", index++, 0);
|
||||
if (result != 0)
|
||||
{
|
||||
s_serversAllowedToDownloadCharacterData.push_back(result);
|
||||
}
|
||||
}
|
||||
while (result);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void ConfigTransferServer::remove(void)
|
||||
{
|
||||
delete data;
|
||||
data = 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
unsigned short ConfigTransferServer::getCentralServerServiceBindPort()
|
||||
{
|
||||
return static_cast<unsigned short>(data->centralServerServiceBindPort);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
const char * ConfigTransferServer::getCentralServerServiceBindInterface()
|
||||
{
|
||||
return data->centralServerServiceBindInterface;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
bool ConfigTransferServer::getAllowSameServerTransfers()
|
||||
{
|
||||
return data->allowSameServerTransfers;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
bool ConfigTransferServer::getAllowAccountTransfers()
|
||||
{
|
||||
return data->allowAccountTransfers;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
const char * ConfigTransferServer::getApiServerHostAddress()
|
||||
{
|
||||
return data->apiServerHostAddress;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
const bool ConfigTransferServer::getTransferChatAvatar()
|
||||
{
|
||||
return data->transferChatAvatar;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@@ -0,0 +1,48 @@
|
||||
// ConfigTransferServer.h
|
||||
// Copyright 2000-04, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Justin Randall
|
||||
|
||||
#ifndef _ConfigTransferServer_H
|
||||
#define _ConfigTransferServer_H
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
class ConfigTransferServer
|
||||
{
|
||||
public:
|
||||
struct Data
|
||||
{
|
||||
int centralServerServiceBindPort;
|
||||
const char * consoleServiceBindInterface;
|
||||
const char * gameServiceBindInterface;
|
||||
const char * centralServerServiceBindInterface;
|
||||
bool allowSameServerTransfers;
|
||||
bool allowAccountTransfers;
|
||||
const char * apiServerHostAddress;
|
||||
bool transferChatAvatar;
|
||||
};
|
||||
|
||||
static uint16 getCentralServerServiceBindPort ();
|
||||
static const char * getCentralServerServiceBindInterface ();
|
||||
static bool getAllowSameServerTransfers ();
|
||||
static bool getAllowAccountTransfers ();
|
||||
|
||||
static void install ();
|
||||
static void remove ();
|
||||
|
||||
static const std::vector<std::string> & getServersAllowedToUploadCharacterData();
|
||||
static const std::vector<std::string> & getServersAllowedToDownloadCharacterData();
|
||||
static const char * getApiServerHostAddress();
|
||||
static const bool getTransferChatAvatar();
|
||||
private:
|
||||
static Data * data;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#endif // _ConfigTransferServer_H
|
||||
@@ -0,0 +1,139 @@
|
||||
// ConsoleCommandParser.cpp
|
||||
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Justin Randall
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
#include "sharedFoundation/NetworkId.h"
|
||||
#include "sharedLog/Log.h"
|
||||
#include "ConsoleCommandParser.h"
|
||||
#include "TransferServer.h"
|
||||
#include "UnicodeUtils.h"
|
||||
#include <vector>
|
||||
#include "Unicode.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
namespace CommandNames
|
||||
{
|
||||
#define MAKE_COMMAND(a) const char * const a = #a
|
||||
#undef MAKE_COMMAND
|
||||
}
|
||||
|
||||
const CommandParser::CmdInfo cmds[] =
|
||||
{
|
||||
{"transfer", 4, "<requestMove> <station id> <character name> <source server> <destination server>", "Request a character transfer for <character name> from <source server> to <destination server>"},
|
||||
{"transfer", 2, "<requestAccountMove> <source station id> <destination station id>", "Request an account transfer from <source station id> to <destination station id>"},
|
||||
{"", 0, "", ""} // this must be last
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
ConsoleCommandParser::ConsoleCommandParser() :
|
||||
CommandParser ("", 0, "...", "console commands", this)
|
||||
{
|
||||
createDelegateCommands(cmds);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
ConsoleCommandParser::~ConsoleCommandParser()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
bool ConsoleCommandParser::performParsing(const NetworkId & track, const StringVector_t & argv, const String_t &, String_t & result, const CommandParser *)
|
||||
{
|
||||
bool successResult = false;
|
||||
|
||||
if(isCommand(argv[0], "transfer"))
|
||||
{
|
||||
if(isCommand(argv[1], "requestMove"))
|
||||
{
|
||||
if(argv.size() > 5)
|
||||
{
|
||||
std::string stationIdString = Unicode::wideToNarrow(argv[2]);
|
||||
std::string characterName = Unicode::wideToNarrow(argv[3]);
|
||||
std::string sourceServer = Unicode::wideToNarrow(argv[4]);
|
||||
std::string destinationServer = Unicode::wideToNarrow(argv[5]);
|
||||
|
||||
LOG("CustomerService", ("CharacterTransfer: received console request to transfer %s, belonging to %s from %s to %s", characterName.c_str(), stationIdString.c_str(), sourceServer.c_str(), destinationServer.c_str()));
|
||||
|
||||
result += Unicode::narrowToWide("Received request to move ");
|
||||
result += Unicode::narrowToWide(characterName);
|
||||
result += Unicode::narrowToWide(" owned by station ID ");
|
||||
result += Unicode::narrowToWide(stationIdString);
|
||||
result += Unicode::narrowToWide(" on cluster ");
|
||||
result += Unicode::narrowToWide(sourceServer);
|
||||
result += Unicode::narrowToWide(" to cluster ");
|
||||
result += Unicode::narrowToWide(destinationServer);
|
||||
|
||||
const unsigned int stationId = static_cast<const unsigned int>(atoi (stationIdString.c_str()));
|
||||
const unsigned int trackId = static_cast<const unsigned int>(track.getValue());
|
||||
|
||||
//todo : drive these through the command handler, just testing
|
||||
// basic functionality for now.
|
||||
const bool withItems = true;
|
||||
const bool allowOverride = true;
|
||||
|
||||
TransferServer::requestMove(trackId, "en", sourceServer, destinationServer, characterName, characterName, stationId, stationId, trackId, withItems, allowOverride);
|
||||
successResult = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string messageString = "not enough arguments to 'requestMove <station id> <character name> <source server> <destination server>'";
|
||||
StringVector_t::const_iterator i;
|
||||
|
||||
for(i = argv.begin(); i != argv.end(); ++i)
|
||||
{
|
||||
messageString = messageString + Unicode::wideToNarrow(*i) + " | ";
|
||||
}
|
||||
LOG("CustomerService", ("CharacterTransfer: %s", messageString.c_str()));
|
||||
result += Unicode::narrowToWide(messageString);
|
||||
}
|
||||
}
|
||||
else if (isCommand(argv[1], "requestAccountMove"))
|
||||
{
|
||||
if (argv.size() > 3)
|
||||
{
|
||||
std::string sourceStationIdString = Unicode::wideToNarrow(argv[2]);
|
||||
std::string destinationStationIdString = Unicode::wideToNarrow(argv[3]);
|
||||
|
||||
LOG("CustomerService", ("CharacterTransfer: received console request to transfer account from station ID %s to station ID %s", sourceStationIdString.c_str(), destinationStationIdString.c_str()));
|
||||
|
||||
result += Unicode::narrowToWide("Received request to move from station ID ");
|
||||
result += Unicode::narrowToWide(sourceStationIdString);
|
||||
result += Unicode::narrowToWide(" to station ID ");
|
||||
result += Unicode::narrowToWide(destinationStationIdString);
|
||||
result += Unicode::narrowToWide("\n");
|
||||
|
||||
const unsigned int sourceStationId = static_cast<const unsigned int>(atoi (sourceStationIdString.c_str()));
|
||||
const unsigned int destinationStationId = static_cast<const unsigned int>(atoi (destinationStationIdString.c_str()));
|
||||
const unsigned int trackId = static_cast<const unsigned int>(track.getValue());
|
||||
|
||||
TransferServer::requestTransferAccount(trackId, sourceStationId, destinationStationId, trackId);
|
||||
successResult = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string messageString = "not enough arguments to 'requestAccountMove <source station id> <destination station id>'";
|
||||
StringVector_t::const_iterator i;
|
||||
|
||||
for(i = argv.begin(); i != argv.end(); ++i)
|
||||
{
|
||||
messageString = messageString + Unicode::wideToNarrow(*i) + " | ";
|
||||
}
|
||||
LOG("CustomerService", ("CharacterTransfer: %s\n", messageString.c_str()));
|
||||
result += Unicode::narrowToWide(messageString);
|
||||
result += Unicode::narrowToWide("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return successResult;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@@ -0,0 +1,29 @@
|
||||
// ConsoleCommandParser.h
|
||||
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Justin Randall
|
||||
|
||||
#ifndef _INCLUDED_ConsoleCommandParser_H
|
||||
#define _INCLUDED_ConsoleCommandParser_H
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "sharedCommandParser/CommandParser.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
class ConsoleCommandParser : public CommandParser
|
||||
{
|
||||
public:
|
||||
ConsoleCommandParser();
|
||||
~ConsoleCommandParser();
|
||||
virtual bool performParsing(const NetworkId & userId, const StringVector_t & argv,const String_t & originalCommand,String_t & result,const CommandParser * node);
|
||||
|
||||
private:
|
||||
ConsoleCommandParser & operator = (const ConsoleCommandParser & rhs);
|
||||
ConsoleCommandParser(const ConsoleCommandParser & source);
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#endif // _INCLUDED_ConsoleCommandParser_H
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
// ConsoleManager.cpp
|
||||
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Justin Randall
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
#include "sharedFoundation/NetworkId.h"
|
||||
#include "ConsoleManager.h"
|
||||
#include "ConsoleCommandParser.h"
|
||||
#include "UnicodeUtils.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
namespace ConsoleManagerNamespace
|
||||
{
|
||||
ConsoleCommandParser * s_consoleCommandParserRoot = NULL;
|
||||
}
|
||||
|
||||
using namespace ConsoleManagerNamespace;
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
ConsoleManager::ConsoleManager()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
ConsoleManager::~ConsoleManager()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void ConsoleManager::install()
|
||||
{
|
||||
s_consoleCommandParserRoot = new ConsoleCommandParser;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void ConsoleManager::remove()
|
||||
{
|
||||
delete s_consoleCommandParserRoot;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void ConsoleManager::processString(const std::string & msg, const int track, std::string & result)
|
||||
{
|
||||
Unicode::String wideResult;
|
||||
IGNORE_RETURN(s_consoleCommandParserRoot->parse(NetworkId(static_cast<NetworkId::NetworkIdType>(track)), Unicode::narrowToWide(msg), wideResult));
|
||||
result = Unicode::wideToNarrow(wideResult);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// ConsoleManager.h
|
||||
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Justin Randall
|
||||
|
||||
#ifndef _INCLUDED_ConsoleManager_H
|
||||
#define _INCLUDED_ConsoleManager_H
|
||||
|
||||
#include <string>
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
class ConsoleManager
|
||||
{
|
||||
public:
|
||||
static void install();
|
||||
static void remove();
|
||||
static void processString(const std::string & msg, const int track, std::string & result);
|
||||
private:
|
||||
ConsoleManager & operator = (const ConsoleManager & rhs);
|
||||
ConsoleManager(const ConsoleManager & source);
|
||||
ConsoleManager();
|
||||
~ConsoleManager();
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#endif // _INCLUDED_ConsoleManager_H
|
||||
@@ -0,0 +1,14 @@
|
||||
// FirstServerConsole.h
|
||||
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Justin Randall
|
||||
|
||||
#ifndef _INCLUDED_FirstServerConsole_H
|
||||
#define _INCLUDED_FirstServerConsole_H
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#endif // _INCLUDED_FirstServerConsole_H
|
||||
@@ -0,0 +1,872 @@
|
||||
// TransferServer.cpp
|
||||
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Justin Randall
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "FirstTransferServer.h"
|
||||
#include "CentralServerConnection.h"
|
||||
#include "ConfigTransferServer.h"
|
||||
#include "ConsoleManager.h"
|
||||
#include "CTSAPIClient.h"
|
||||
#include "CTCommon/CTServiceCharacter.h"
|
||||
#include "serverNetworkMessages/TransferAccountData.h"
|
||||
#include "serverNetworkMessages/TransferAccountDataArchive.h"
|
||||
#include "serverNetworkMessages/TransferCharacterData.h"
|
||||
#include "serverNetworkMessages/TransferCharacterDataArchive.h"
|
||||
#include "serverNetworkMessages/TransferReplyCharacterList.h"
|
||||
#include "serverNetworkMessages/TransferReplyMoveValidation.h"
|
||||
#include "serverNetworkMessages/TransferRequestMoveValidation.h"
|
||||
#include "sharedFoundation/Os.h"
|
||||
#include "sharedLog/Log.h"
|
||||
#include "sharedLog/SetupSharedLog.h"
|
||||
#include "sharedMath/Vector.h"
|
||||
#include "sharedNetwork/Connection.h"
|
||||
#include "sharedNetwork/Service.h"
|
||||
#include "sharedNetwork/NetworkSetupData.h"
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
#include "sharedUtility/DataTableManager.h"
|
||||
#include "TransferServer.h"
|
||||
#include "CentralServerConnection.h"
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <ostream>
|
||||
#include "Unicode.h"
|
||||
#include "UnicodeUtils.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
namespace TransferServerNamespace
|
||||
{
|
||||
Service * s_transferServerService;
|
||||
std::map<unsigned int, CharacterTransferData> s_transferData;
|
||||
std::set<std::string> s_serversAllowedToUpload;
|
||||
std::set<std::string> s_serversAllowedToDownload;
|
||||
std::set<unsigned int> s_authorizedDownloads;
|
||||
bool s_done = false;
|
||||
CTSAPIClient * s_apiClient = 0;
|
||||
|
||||
// as we receive the source character's template crc that comes back from the LoginServer
|
||||
// in the TransferReplyMoveValidation message, save it here, and send it back in subseqnent
|
||||
// TransferRequestMoveValidation messages as an optimization so the LoginServer doesn't have
|
||||
// to continually query the DB to fetch the same information over and over again, because
|
||||
// the character's template crc (i.e. the character's species) should never, ever change
|
||||
std::map<std::pair<unsigned int, std::pair<std::string, std::string> >, uint32> s_cacheSourceCharacterTemplateCrc;
|
||||
|
||||
void closePseudoClientConnection(const std::string & galaxyName, const unsigned int stationId)
|
||||
{
|
||||
CentralServerConnection * centralServerConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(galaxyName);
|
||||
if(centralServerConnection)
|
||||
{
|
||||
GenericValueTypeMessage<unsigned int> closeRequest("TransferClosePseudoClientConnection", stationId);
|
||||
centralServerConnection->send(closeRequest, true);
|
||||
}
|
||||
}
|
||||
|
||||
void closePseudoClientConnections(const std::string & sourceGalaxyName, const unsigned int sourceStationId, const std::string & destinationGalaxyName, const unsigned int destinationStationId)
|
||||
{
|
||||
// close pseudoclientconnections
|
||||
closePseudoClientConnection(sourceGalaxyName, sourceStationId);
|
||||
|
||||
unsigned int destId = destinationStationId;
|
||||
if(destId == 0)
|
||||
destId = sourceStationId;
|
||||
closePseudoClientConnection(destinationGalaxyName, destId);
|
||||
|
||||
}
|
||||
|
||||
std::string resultToString(CTService::CTMoveResult resultCode)
|
||||
{
|
||||
std::string resultString;
|
||||
|
||||
switch (resultCode)
|
||||
{
|
||||
case CTService::CT_GAMERESULT_SUCCESS:
|
||||
resultString = "CTService::CT_GAMERESULT_SUCCESS";
|
||||
break;
|
||||
case CTService::CT_GAMERESULT_SOFTERROR:
|
||||
resultString = "CTService::CT_GAMERESULT_SOFTERROR";
|
||||
break;
|
||||
case CTService::CT_GAMERESULT_HARDERROR:
|
||||
resultString = "CTService::CT_GAMERESULT_HARDERROR";
|
||||
break;
|
||||
case CTService::CT_GAMERESULT_INVALID_NAME:
|
||||
resultString = "CTService::CT_GAMERESULT_INVALID_NAME";
|
||||
break;
|
||||
case CTService::CT_GAMERESULT_NAME_ALREADY_TAKE:
|
||||
resultString = "CTService::CT_GAMERESULT_NAME_ALREADY_TAKE";
|
||||
break;
|
||||
case CTService::CT_GAMERESULT_HAS_CORPSE:
|
||||
resultString = "CTService::CT_GAMERESULT_NAME_HAS_CORPSE";
|
||||
break;
|
||||
case CTService::CT_GAMERESULT_SERVER_IS_DOWN:
|
||||
resultString = "CTService::CT_GAMERESULT_SERVER_IS_DOWN";
|
||||
break;
|
||||
case CTService::CT_GAMERESULT_MAX_CHAR_ON_DEST_SERVER:
|
||||
resultString = "CTService::CT_GAMERESULT_MAX_CHAR_ON_DEST_SERVER";
|
||||
break;
|
||||
case CTService::CT_GAMERESULT_CHAR_HAS_ITEM_NOT_ALLOWED_TO_LEAVE_SRC_SERVER:
|
||||
resultString = "CTService::CT_GAMERESULT_CHAR_HAS_ITEM_NOT_ALLOWED_TO_LEAVE_SRC_SERVER";
|
||||
break;
|
||||
case CTService::CT_GAMERESULT_CHAR_HAS_ITEM_NOT_ALLOWED_ON_DEST_SERVER:
|
||||
resultString = "CTService::CT_GAMERESULT_CHAR_HAS_ITEM_NOT_ALLOWED_ON_DEST_SERVER";
|
||||
break;
|
||||
case CTService::CT_GAMERESULT_CHAR_NOT_ALLOWED_TO_MOVE_FROM_SRC_SERVER:
|
||||
resultString = "CTService::CT_GAMERESULT_CHAR_NOT_ALLOWED_TO_MOVE_FROM_SRC_SERVER";
|
||||
break;
|
||||
case CTService::CT_GAMERESULT_CHAR_NOT_ALLOWED_TO_MOVE_TO_DEST_SERVER:
|
||||
resultString = "CTService::CT_GAMERESULT_CHAR_NOT_ALLOWED_TO_MOVE_TO_DEST_SERVER";
|
||||
break;
|
||||
case CTService::CT_GAMERESULT_CHAR_NOT_ALLOWED_TO_MOVE_FROM_THIS_SRC_SERVER_TO_THIS_DEST_SERVER:
|
||||
resultString = "CTService::CT_GAMERESULT_CHAR_NOT_ALLOWED_TO_MOVE_FROM_THIS_SRC_SERVER_TO_THIS_DEST_SERVER";
|
||||
break;
|
||||
case CTService::CT_GAMERESULT_CHAR_TYPE_NOT_ALLOWED_TO_LEAVE_SRC_SERVER:
|
||||
resultString = "CTService::CT_GAMERESULT_CHAR_TYPE_NOT_ALLOWED_TO_LEAVE_SRC_SERVER";
|
||||
break;
|
||||
case CTService::CT_GAMERESULT_CHAR_TYPE_NOT_ALLOWED_ON_DEST_SERVER:
|
||||
resultString = "CTService::CT_GAMERESULT_CHAR_TYPE_NOT_ALLOWED_ON_DEST_SERVER";
|
||||
break;
|
||||
case CTService::CT_GAMERESULT_SOFTERROR_FOR_LOCALIZED_TEXT:
|
||||
resultString = "CTService::CT_GAMERESULT_SOFTERROR_FOR_LOCALIZED_TEXT";
|
||||
break;
|
||||
case CTService::CT_GAMERESULT_HARDERROR_FOR_LOCALIZED_TEXT:
|
||||
resultString = "CTService::CT_GAMERESULT_HARDERROR_FOR_LOCALIZED_TEXT";
|
||||
break;
|
||||
default:
|
||||
{
|
||||
std::ostringstream buffer;
|
||||
buffer << "unknown code (" << resultCode << ")" << std::ends;
|
||||
resultString = buffer.str();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return resultString;
|
||||
}
|
||||
|
||||
void replyMove(const TransferCharacterData & reply, CTService::CTMoveResult resultCode)
|
||||
{
|
||||
if(s_apiClient)
|
||||
{
|
||||
const std::string resultString = resultToString(resultCode);
|
||||
LOG("CustomerService", ("CharacterTransfer: transactionId=%u replyMove(%u, %s, NULL, NULL)", reply.getTransactionId(), reply.getTrack(), resultString.c_str()));
|
||||
const unsigned int result = static_cast<unsigned int>(resultCode);
|
||||
s_apiClient->moveComplete(reply.getSourceStationId(), reply.getTrack(), result);
|
||||
IGNORE_RETURN(s_apiClient->replyMove(reply.getTrack(), result, Unicode::narrowToWide(resultString).c_str(), NULL));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
using namespace TransferServerNamespace;
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
TransferServer::TransferServer()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
TransferServer::~TransferServer()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void TransferServer::authorizeDownload(unsigned int stationId)
|
||||
{
|
||||
IGNORE_RETURN(s_authorizedDownloads.insert(stationId));
|
||||
REPORT_LOG(true, ("Received download authorization for station id %d\n", stationId));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void TransferServer::unauthorizeDownload(unsigned int stationId)
|
||||
{
|
||||
std::set<unsigned int>::iterator f = s_authorizedDownloads.find(stationId);
|
||||
if(f != s_authorizedDownloads.end())
|
||||
{
|
||||
s_authorizedDownloads.erase(f);
|
||||
REPORT_LOG(true, ("Received request to remove download authorization for station id %d\n", stationId));
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
const CharacterTransferData * TransferServer::getCharacterTransferData(unsigned int stationId, const std::string & fromGalaxy, bool administrativeRequest)
|
||||
{
|
||||
const CharacterTransferData * result = 0;
|
||||
|
||||
std::map<unsigned int, CharacterTransferData>::const_iterator f = s_transferData.find(stationId);
|
||||
if(f != s_transferData.end())
|
||||
result = &(*f).second;
|
||||
|
||||
if(result)
|
||||
{
|
||||
bool authorized = false;
|
||||
// was the request administratively initiated?
|
||||
if(administrativeRequest)
|
||||
{
|
||||
// admins always get what they want
|
||||
authorized = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// users, however, must live up to a higher standard
|
||||
// is the request coming from a server that is allowed
|
||||
// to download character data?
|
||||
std::set<std::string>::const_iterator g = s_serversAllowedToDownload.find(fromGalaxy);
|
||||
if(g != s_serversAllowedToDownload.end())
|
||||
{
|
||||
// the request is coming from a server that a user is allowed to download to
|
||||
if(ConfigTransferServer::getAllowSameServerTransfers())
|
||||
{
|
||||
authorized = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(fromGalaxy != result->fromGalaxy)
|
||||
{
|
||||
authorized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// was this transfer pre-authorized administratively?
|
||||
std::set<unsigned int>::const_iterator a = s_authorizedDownloads.find(stationId);
|
||||
if(a != s_authorizedDownloads.end())
|
||||
{
|
||||
authorized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// were all requirements met?
|
||||
if(! authorized)
|
||||
result = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
REPORT_LOG(true, ("Download failed: Transfer data for SUID %d was not found.\n", stationId));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void TransferServer::requestCharacterList(unsigned int track, unsigned int stationId, const std::string & serverName, const std::string & customerLocalizedLanguage)
|
||||
{
|
||||
CentralServerConnection * centralConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(serverName);
|
||||
if(centralConnection)
|
||||
{
|
||||
// this request is routed to the central server for the target
|
||||
// galaxy, which in turn queries a LoginServer for the character
|
||||
// list. The LoginServer returns the list, with the tracking
|
||||
// ID, to the CentralServer, and ultimately responds to this
|
||||
// transfer server with the listing.
|
||||
static const std::string emptyString("");
|
||||
TransferCharacterData characterData(TransferRequestMoveValidation::TRS_transfer_server);
|
||||
characterData.setCustomerLocalizedLanguage(customerLocalizedLanguage);
|
||||
characterData.setSourceGalaxy(serverName);
|
||||
characterData.setSourceStationId(stationId);
|
||||
characterData.setTrack(track);
|
||||
const GenericValueTypeMessage<TransferCharacterData> request("TransferRequestCharacterList", characterData);
|
||||
centralConnection->send(request, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// send failure to CTS API backend
|
||||
if(s_apiClient)
|
||||
{
|
||||
const unsigned int result = static_cast<int>(CTService::CT_RESULT_FAILURE);
|
||||
|
||||
IGNORE_RETURN(s_apiClient->replyCharacterList(track, result, 0, NULL, NULL));
|
||||
s_apiClient->moveComplete(stationId, track, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void TransferServer::getLoginLocationData(const TransferCharacterData & characterData)
|
||||
{
|
||||
CentralServerConnection * sourceCentralConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(characterData.getSourceGalaxy());
|
||||
if(sourceCentralConnection)
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Sending getLoginLocationData for %s", characterData.getSourceCharacterName().c_str()));
|
||||
const GenericValueTypeMessage<TransferCharacterData> getLoginLocation("TransferGetLoginLocationData", characterData);
|
||||
sourceCentralConnection->send(getLoginLocation, true);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void TransferServer::requestMove(unsigned int track, const std::string & customerLocalizedLanguage, const std::string & sourceGalaxy, const std::string & destinationGalaxy, const std::string & sourceCharacter, const std::string & destinationCharacter, unsigned int sourceStationId, unsigned int destinationStationId, unsigned int transactionId, const bool withItems, const bool allowOverride)
|
||||
{
|
||||
std::string withItemsString = "UNINITIALIZED";
|
||||
if(withItems)
|
||||
withItemsString = "true";
|
||||
else
|
||||
withItemsString = "false";
|
||||
|
||||
std::string allowOverrideString = "UNINITIALIZED";
|
||||
if(allowOverride)
|
||||
allowOverrideString = "true";
|
||||
else
|
||||
allowOverrideString = "false";
|
||||
|
||||
LOG("CustomerService", ("CharacterTransfer: TransferServer::requestMove(%d, %s, %s, %s, %s, %s, %d, %d, %d, %s, %s)", track, customerLocalizedLanguage.c_str(), sourceGalaxy.c_str(), destinationGalaxy.c_str(), sourceCharacter.c_str(), destinationCharacter.c_str(), sourceStationId, destinationStationId, transactionId, withItemsString.c_str(), allowOverrideString.c_str()));
|
||||
// this request is routed to the central server for the target
|
||||
// galaxy, which in turn queries a LoginServer for the character
|
||||
// list. The LoginServer populates the TransferCharacterData
|
||||
// with the source characterID. After the response is received
|
||||
// in CentralServerConnection.cpp, TransferServer::getLoginLocationData
|
||||
// is called.
|
||||
|
||||
// prequalification: if both Galaxies are available, send request, otherwise send failure
|
||||
CentralServerConnection * sourceCentralConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(sourceGalaxy);
|
||||
CentralServerConnection * destinationCentralConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(destinationGalaxy);
|
||||
|
||||
if(destinationStationId == 0)
|
||||
destinationStationId = sourceStationId;
|
||||
|
||||
std::string destinationCharacterName = destinationCharacter;
|
||||
if(destinationCharacter.empty())
|
||||
destinationCharacterName = sourceCharacter;
|
||||
|
||||
TransferCharacterData characterData(TransferRequestMoveValidation::TRS_transfer_server);
|
||||
characterData.setCustomerLocalizedLanguage(customerLocalizedLanguage);
|
||||
characterData.setSourceGalaxy(sourceGalaxy);
|
||||
characterData.setDestinationGalaxy(destinationGalaxy);
|
||||
characterData.setSourceCharacterName(sourceCharacter);
|
||||
characterData.setDestinationCharacterName(destinationCharacterName);
|
||||
characterData.setSourceStationId(sourceStationId);
|
||||
characterData.setDestinationStationId(destinationStationId);
|
||||
characterData.setTransactionId(transactionId);
|
||||
characterData.setIsMoveRequest(true);
|
||||
characterData.setWithItems(withItems);
|
||||
characterData.setAllowOverride(allowOverride);
|
||||
characterData.setTrack(track);
|
||||
|
||||
/*
|
||||
TransferCharacterData characterData(track, // track
|
||||
customerLocalizedLanguage, // customerLocalizedLanguage
|
||||
sourceGalaxy, // sourceGalaxy
|
||||
destinationGalaxy, // destinationGalaxy
|
||||
sourceCharacter, // sourceCharacterName
|
||||
destinationCharacterName, // destinationCharacterName
|
||||
sourceStationId, // sourceStationId
|
||||
destinationStationId, // destinationStationId
|
||||
transactionId, // transactionId
|
||||
NetworkId::cms_invalid, // characterId
|
||||
NetworkId::cms_invalid, // containerId
|
||||
std::string(""), // scene
|
||||
0, // clusterId
|
||||
Vector(), // starting coordinates
|
||||
std::string(""), // customization data
|
||||
std::vector<unsigned char>(), // script dictionary buffer
|
||||
std::string(""), // object template name
|
||||
1.0f, // scale factor
|
||||
std::string(""), // hair template name
|
||||
std::string(""), // hair appearance data
|
||||
std::string(""), // profession
|
||||
false, // is a jedi
|
||||
Unicode::String(), // Biography
|
||||
NetworkId::cms_invalid, // destination character id
|
||||
false, // is name validated?
|
||||
true, // is this a move request?
|
||||
withItems); // does the move include items?
|
||||
*/
|
||||
|
||||
if(sourceCentralConnection && destinationCentralConnection)
|
||||
{
|
||||
// transfer the character
|
||||
const GenericValueTypeMessage<TransferCharacterData> getCharacterData("TransferGetCharacterDataFromLoginServer", characterData);
|
||||
sourceCentralConnection->send(getCharacterData, true);
|
||||
s_apiClient->moveStart(sourceStationId, track, sourceCentralConnection, destinationCentralConnection);
|
||||
LOG("CustomerService", ("CharacterTransfer: sent TransferGetCharacterDataFromLoginServer message : %s\n", characterData.toString().c_str()));
|
||||
|
||||
const GenericValueTypeMessage<std::pair<unsigned int, unsigned int> > kick("TransferRequestKickConnectedClients", std::make_pair(sourceStationId, destinationStationId));
|
||||
sourceCentralConnection->send(kick, true);
|
||||
destinationCentralConnection->send(kick, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
replyMove(characterData, CTService::CT_GAMERESULT_SERVER_IS_DOWN);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void TransferServer::requestTransferAccount(unsigned int track, unsigned int sourceStationId, unsigned int destinationStationId, unsigned int transactionId)
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: TransferServer::requestAccount(%d, %d, %d, %d)", track, sourceStationId, destinationStationId, transactionId));
|
||||
|
||||
if(!ConfigTransferServer::getAllowAccountTransfers())
|
||||
{
|
||||
LOG("CustomerService", ("Cannot transfer account, account transfers are not enabled\n"));
|
||||
if(s_apiClient)
|
||||
{
|
||||
const unsigned int result = static_cast<unsigned int>(CTService::CT_GAMERESULT_HARDERROR);
|
||||
IGNORE_RETURN(s_apiClient->replyValidateMove(track, result, NULL, NULL, NULL));
|
||||
s_apiClient->moveComplete(sourceStationId, track, result);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// this request is routed to a login server
|
||||
// which in turn updates the DatabaseProcess in the CentralServer, and finally updates the ChatServer
|
||||
// prequalification: if a galaxy is available, send request, otherwise send failure
|
||||
std::map<std::string, CentralServerConnection *> galaxies = CentralServerConnection::getGalaxies();
|
||||
std::map<std::string, CentralServerConnection *>::iterator firstGalaxy = galaxies.begin();
|
||||
|
||||
if (firstGalaxy == galaxies.end())
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Account to account move request made, but no central server connections are available in transfer server source station id: %lu destination station id: %lu\n", sourceStationId, destinationStationId));
|
||||
|
||||
if(s_apiClient)
|
||||
{
|
||||
const unsigned int result = static_cast<unsigned int>(CTService::CT_GAMERESULT_SERVER_IS_DOWN);
|
||||
IGNORE_RETURN(s_apiClient->replyTransferAccount(track, result, NULL, NULL));
|
||||
s_apiClient->moveComplete(sourceStationId, track, result);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string galaxyName = firstGalaxy->first;
|
||||
CentralServerConnection * sourceCentralConnection = firstGalaxy->second;
|
||||
|
||||
if(destinationStationId == 0 || sourceStationId == 0)
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Account move request made with a null destination station id: or source station id: %lu\n", sourceStationId));
|
||||
|
||||
if(s_apiClient)
|
||||
{
|
||||
const unsigned int result = static_cast<unsigned int>(CTService::CT_GAMERESULT_HARDERROR);
|
||||
IGNORE_RETURN(s_apiClient->replyTransferAccount(track, result, NULL, NULL));
|
||||
s_apiClient->moveComplete(sourceStationId, track, result);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
TransferAccountData transferData;
|
||||
transferData.setSourceStationId(sourceStationId);
|
||||
transferData.setDestinationStationId(destinationStationId);
|
||||
transferData.setTransactionId(transactionId);
|
||||
transferData.setStartGalaxy(galaxyName);
|
||||
transferData.setTrack(track);
|
||||
|
||||
// verify neither of the station ids are connected
|
||||
const GenericValueTypeMessage<std::pair<unsigned int, unsigned int> > kick("TransferRequestKickConnectedClients", std::make_pair(sourceStationId, destinationStationId));
|
||||
sourceCentralConnection->send(kick, true);
|
||||
|
||||
// start the transfer process
|
||||
const GenericValueTypeMessage<TransferAccountData> getAccountData("TransferAccountRequestLoginServer", transferData);
|
||||
sourceCentralConnection->send(getAccountData, true);
|
||||
|
||||
if (s_apiClient)
|
||||
s_apiClient->moveStart(sourceStationId, track, sourceCentralConnection, 0);
|
||||
|
||||
LOG("CustomerService", ("CharacterTransfer: sent TransferAccountRequestLoginServer message : %s\n", transferData.toString().c_str()));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void TransferServer::requestMoveValidation(unsigned int track, unsigned int sourceStationId, unsigned int destinationStationId, const std::string & sourceGalaxy, const std::string & destinationGalaxy, const std::string & sourceCharacter, const std::string & destinationCharacter, const std::string & customerLocalizedLanguage)
|
||||
{
|
||||
// prequalification: if both Galaxies are available, send request, otherwise send failure
|
||||
const CentralServerConnection * sourceCentralConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(sourceGalaxy);
|
||||
CentralServerConnection * destinationCentralConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(destinationGalaxy);
|
||||
|
||||
if(sourceStationId != destinationStationId && (!ConfigTransferServer::getAllowAccountTransfers()))
|
||||
{
|
||||
if(s_apiClient)
|
||||
{
|
||||
const unsigned int result = static_cast<unsigned int>(CTService::CT_GAMERESULT_HARDERROR);
|
||||
IGNORE_RETURN(s_apiClient->replyValidateMove(track, result, NULL, NULL, NULL));
|
||||
s_apiClient->moveComplete(sourceStationId, track, result);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(sourceCentralConnection && destinationCentralConnection)
|
||||
{
|
||||
// This is sent to the CentralServer on the destination galaxy
|
||||
// which then forwards it to an arbitrary LoginServer
|
||||
// the validation response is routed back to the TransferServer
|
||||
// and is handled in CentralServerConnection as a TransferReplyMoveValidation
|
||||
|
||||
// see if we already have the source character's template crc from a previous query
|
||||
// and if so, pass that along as an optimization so the LoginServer doesn't have
|
||||
// to continually query the DB to fetch the same information over and over again, because
|
||||
// the character's template crc (i.e. the character's species) should never, ever change
|
||||
std::map<std::pair<unsigned int, std::pair<std::string, std::string> >, uint32>::const_iterator const iterFind = s_cacheSourceCharacterTemplateCrc.find(std::make_pair(sourceStationId, std::make_pair(sourceGalaxy, sourceCharacter)));
|
||||
|
||||
const TransferRequestMoveValidation request(TransferRequestMoveValidation::TRS_transfer_server, track, sourceStationId, destinationStationId, sourceGalaxy, destinationGalaxy, sourceCharacter, NetworkId::cms_invalid, ((iterFind == s_cacheSourceCharacterTemplateCrc.end()) ? 0 : iterFind->second), destinationCharacter, customerLocalizedLanguage);
|
||||
|
||||
destinationCentralConnection->send(request, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(s_apiClient)
|
||||
{
|
||||
const unsigned int result = static_cast<unsigned int>(CTService::CT_GAMERESULT_SERVER_IS_DOWN);
|
||||
IGNORE_RETURN(s_apiClient->replyValidateMove(track, result, NULL, NULL, NULL));
|
||||
s_apiClient->moveComplete(sourceStationId, track, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void TransferServer::cacheSourceCharacterTemplateCrc(unsigned int stationId, const std::string & galaxy, const std::string & characterName, uint32 characterTemplateCrc)
|
||||
{
|
||||
s_cacheSourceCharacterTemplateCrc[std::make_pair(stationId, std::make_pair(galaxy, characterName))] = characterTemplateCrc;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void TransferServer::run()
|
||||
{
|
||||
SetupSharedLog::install("TransferServer");
|
||||
ConsoleManager::install();
|
||||
DataTableManager::install();
|
||||
|
||||
std::vector<std::string>::const_iterator i;
|
||||
|
||||
for (i = ConfigTransferServer::getServersAllowedToUploadCharacterData().begin(); i != ConfigTransferServer::getServersAllowedToUploadCharacterData().end(); ++i)
|
||||
{
|
||||
IGNORE_RETURN(s_serversAllowedToUpload.insert(*i));
|
||||
REPORT_LOG(true, ("%s allows players to upload character data\n", i->c_str()));
|
||||
}
|
||||
|
||||
for (i = ConfigTransferServer::getServersAllowedToDownloadCharacterData().begin(); i != ConfigTransferServer::getServersAllowedToDownloadCharacterData().end(); ++i)
|
||||
{
|
||||
IGNORE_RETURN(s_serversAllowedToDownload.insert(*i));
|
||||
REPORT_LOG(true, ("%s allows players to download character data without administrative intervention\n", i->c_str()));
|
||||
}
|
||||
|
||||
NetworkSetupData setup;
|
||||
setup.port = ConfigTransferServer::getCentralServerServiceBindPort();
|
||||
setup.bindInterface = ConfigTransferServer::getCentralServerServiceBindInterface();
|
||||
setup.maxConnections=500;
|
||||
|
||||
if(strlen(ConfigTransferServer::getApiServerHostAddress()))
|
||||
{
|
||||
s_apiClient = new CTSAPIClient(ConfigTransferServer::getApiServerHostAddress(), "SWG");
|
||||
REPORT_LOG(true, ("Attempting to connect to CTS Backend %s\n", ConfigTransferServer::getApiServerHostAddress()));
|
||||
LOG("CTSAPI", ("Attempting to connect to CTS Backend %s", ConfigTransferServer::getApiServerHostAddress()));
|
||||
}
|
||||
else
|
||||
{
|
||||
REPORT_LOG(true, ("Running without CTS backend connection because none is configured.\n"));
|
||||
LOG("CTSAPI", ("Running without CTS backend connection because none is configured."));
|
||||
}
|
||||
|
||||
s_transferServerService = new Service(ConnectionAllocator<CentralServerConnection>(), setup);
|
||||
while(! s_done)
|
||||
{
|
||||
if(s_apiClient)
|
||||
{
|
||||
s_apiClient->process();
|
||||
}
|
||||
|
||||
NetworkHandler::update();
|
||||
NetworkHandler::dispatch();
|
||||
NetworkHandler::clearBytesThisFrame();
|
||||
Os::sleep(1);
|
||||
}
|
||||
delete s_apiClient;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void TransferServer::setDone(bool isDone)
|
||||
{
|
||||
s_done = isDone;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
bool TransferServer::uploadCharacterTransferData(const CharacterTransferData & data, bool administrative)
|
||||
{
|
||||
bool result = false;
|
||||
std::set<std::string>::const_iterator f = s_serversAllowedToUpload.find(data.fromGalaxy);
|
||||
|
||||
bool authorized = administrative;
|
||||
if(! authorized)
|
||||
{
|
||||
std::set<unsigned int>::const_iterator a = s_authorizedDownloads.find(data.stationId);
|
||||
if(a != s_authorizedDownloads.end())
|
||||
{
|
||||
authorized = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(f != s_serversAllowedToUpload.end() || authorized)
|
||||
{
|
||||
s_transferData[data.stationId] = data;
|
||||
REPORT_LOG(true, ("%d bytes of data for SUID %d uploaded\n", data.packedData.length(), data.stationId));
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
REPORT_LOG(true, ("An attempt to upload character data from %s was denied by the TransferServer configuration\n", data.fromGalaxy.c_str()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void TransferServer::replyCharacterList(const TransferReplyCharacterList & reply)
|
||||
{
|
||||
if(s_apiClient)
|
||||
{
|
||||
std::vector<AvatarRecord>::const_iterator i;
|
||||
std::vector<CTService::CTServiceCharacter> chars;
|
||||
for(i = reply.getAvatarList().begin(); i != reply.getAvatarList().end(); ++i)
|
||||
{
|
||||
CTService::CTServiceCharacter character;
|
||||
character.SetCharacter(i->m_name.c_str());
|
||||
chars.push_back(character);
|
||||
LOG("CTSAPI", ("adding CTService::CTServiceCharacter(%s) to replyCharacterList", Unicode::wideToNarrow(i->m_name).c_str()));
|
||||
}
|
||||
|
||||
CTService::CTServiceCharacter * characters = 0;
|
||||
unsigned int result = static_cast<unsigned int>(CTService::CT_RESULT_SUCCESS);
|
||||
|
||||
if(! reply.getAvatarList().empty())
|
||||
{
|
||||
characters = &chars[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
result = static_cast<unsigned int>(CTService::CT_RESULT_FAILURE);
|
||||
s_apiClient->moveComplete(reply.getStationId(), reply.getTrack(), result);
|
||||
}
|
||||
LOG("CTSAPI", ("invoking CTServiceAPI::replyCharacterList(%d, %d, %d, characters, NULL)", reply.getTrack(), result, chars.size()));
|
||||
IGNORE_RETURN(s_apiClient->replyCharacterList(reply.getTrack(), result, reply.getAvatarList().size(), characters, NULL));
|
||||
}
|
||||
// else use another interface if available
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void TransferServer::replyValidateMove(const TransferCharacterData & reply)
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Received replyValidateMove for %s", reply.toString().c_str()));
|
||||
|
||||
if(s_apiClient)
|
||||
{
|
||||
unsigned int result = static_cast<unsigned int>(CTService::CT_GAMERESULT_SUCCESS);
|
||||
if(! reply.getIsValidName())
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: replyValidateMove failed name validation for %s", reply.toString().c_str()));
|
||||
result = static_cast<unsigned int>(CTService::CT_GAMERESULT_NAME_ALREADY_TAKE);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: replyValidateMove passed name validation for %s", reply.toString().c_str()));
|
||||
}
|
||||
IGNORE_RETURN(s_apiClient->replyValidateMove(reply.getTrack(), result, NULL, NULL, NULL));
|
||||
s_apiClient->moveComplete(reply.getSourceStationId(), reply.getTrack(), result);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void TransferServer::replyMoveSuccess(const TransferCharacterData & reply)
|
||||
{
|
||||
// send RequestTransferAvatar to ChatServer via CentralServer
|
||||
CentralServerConnection * centralServerConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(reply.getSourceGalaxy());
|
||||
if(centralServerConnection)
|
||||
{
|
||||
if(ConfigTransferServer::getTransferChatAvatar())
|
||||
{
|
||||
const GenericValueTypeMessage<TransferCharacterData> chatTransfer("RequestChatTransferAvatar", reply);
|
||||
LOG("CustomerService", ("CharacterTransfer: Sending RequestChatTransferAvatar to Central Server %s. %s", chatTransfer.getValue().getSourceGalaxy().c_str(), chatTransfer.getValue().toString().c_str()));
|
||||
centralServerConnection->send(chatTransfer, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("CustomerService", ("Not transfering chat avatar. Chat transfers are currently disabled"));
|
||||
}
|
||||
}
|
||||
|
||||
replyMove(reply, CTService::CT_GAMERESULT_SUCCESS);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void TransferServer::replyTransferAccountSuccess(const TransferAccountData & reply)
|
||||
{
|
||||
// send RequestTransferAvatar to ChatServer via CentralServer for each of the cluster ids
|
||||
if(ConfigTransferServer::getTransferChatAvatar())
|
||||
{
|
||||
const std::vector<AvatarData> avatarData(reply.getSourceAvatarData());
|
||||
for (std::vector<AvatarData>::const_iterator i = avatarData.begin(); i != avatarData.end(); ++i)
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Sending request to update chat server (cluster: %s) for account transfer from %lu to %lu\n", (i->first).c_str(), reply.getSourceStationId(), reply.getDestinationStationId()));
|
||||
|
||||
// need to make a small transferCharacterData object to send with the message
|
||||
TransferCharacterData chatRequest(TransferRequestMoveValidation::TRS_transfer_server);
|
||||
chatRequest.setSourceStationId(reply.getSourceStationId());
|
||||
chatRequest.setSourceGalaxy(i->first);
|
||||
chatRequest.setSourceCharacterName(i->second);
|
||||
chatRequest.setDestinationStationId(reply.getDestinationStationId());
|
||||
chatRequest.setDestinationGalaxy(i->first);
|
||||
chatRequest.setDestinationCharacterName(i->second);
|
||||
|
||||
CentralServerConnection * centralServerConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(i->first);
|
||||
|
||||
if (centralServerConnection)
|
||||
{
|
||||
const GenericValueTypeMessage<TransferCharacterData> message("RequestChatTransferAvatar", chatRequest);
|
||||
centralServerConnection->send(message, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Could not transfer chat avatars for character %s on cluster %s from %lu to %lu: central connection does not exist in transferserver", i->second.c_str(), i->first.c_str(), reply.getSourceStationId(), reply.getDestinationStationId()));
|
||||
const unsigned int result = static_cast<unsigned int>(CTService::CT_GAMERESULT_HARDERROR);
|
||||
s_apiClient->moveComplete(reply.getSourceStationId(), reply.getTrack(), result);
|
||||
IGNORE_RETURN(s_apiClient->replyTransferAccount(reply.getTrack(), result, NULL, NULL));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Not transfering any chat avatars. Chat transfers are currently disabled"));
|
||||
}
|
||||
|
||||
if(s_apiClient)
|
||||
{
|
||||
const unsigned int result = static_cast<unsigned int>(CTService::CT_GAMERESULT_SUCCESS);
|
||||
IGNORE_RETURN(s_apiClient->replyTransferAccount(reply.getTrack(), result, NULL, NULL));
|
||||
s_apiClient->moveComplete(reply.getSourceStationId(), reply.getTrack(), result);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void TransferServer::transferCreateCharacterFailed(const TransferCharacterData & failed)
|
||||
{
|
||||
replyMove(failed, CTService::CT_GAMERESULT_INVALID_NAME);
|
||||
|
||||
// close pseudoclientconnections
|
||||
closePseudoClientConnections(failed.getSourceGalaxy(), failed.getSourceStationId(), failed.getDestinationGalaxy(), failed.getDestinationStationId());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
bool TransferServer::isRename(const TransferCharacterData & request)
|
||||
{
|
||||
// IF:
|
||||
// the source and destination station ID are identcal (not a transfer to another account)
|
||||
// the source and destination galaxy are identicay (not a transfer to another server)
|
||||
// the destination name is not empty
|
||||
// the source and destination name are different
|
||||
// This is a character rename request
|
||||
return (request.getSourceStationId() == request.getDestinationStationId() && request.getSourceGalaxy() == request.getDestinationGalaxy() && !request.getDestinationCharacterName().empty() && request.getSourceCharacterName() != request.getDestinationCharacterName());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void TransferServer::failedToRetrieveTransferData(const TransferCharacterData & failed)
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Transfer failed: Failed to retrieve character data. Sending HARD ERROR to CTS API. %s", failed.toString().c_str()));
|
||||
replyMove(failed, CTService::CT_GAMERESULT_HARDERROR);
|
||||
|
||||
// close pseudoclientconnections
|
||||
closePseudoClientConnections(failed.getSourceGalaxy(), failed.getSourceStationId(), failed.getDestinationGalaxy(), failed.getDestinationStationId());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void TransferServer::failedToApplyTransferData(const TransferCharacterData & failed)
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Transfer failed: Failed to apply character data. Sending HARD ERROR to CTS API. %s", failed.toString().c_str()));
|
||||
|
||||
replyMove(failed, CTService::CT_GAMERESULT_HARDERROR);
|
||||
|
||||
// close pseudoclientconnections
|
||||
closePseudoClientConnections(failed.getSourceGalaxy(), failed.getSourceStationId(), failed.getDestinationGalaxy(), failed.getDestinationStationId());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void TransferServer::failedToTransferAccountNoCentralConnection(const TransferAccountData & failed)
|
||||
{
|
||||
if(s_apiClient)
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Transfer failed: Could not connect to central server to update game database. Sending HARD ERROR to CTS API. %s", failed.toString().c_str()));
|
||||
const unsigned int result = static_cast<unsigned int>(CTService::CT_GAMERESULT_HARDERROR);
|
||||
s_apiClient->moveComplete(failed.getSourceStationId(), failed.getTrack(), result);
|
||||
IGNORE_RETURN(s_apiClient->replyTransferAccount(failed.getTrack(), result, NULL, NULL));
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void TransferServer::failedToTransferAccountDestinationNotEmpty (const TransferAccountData & failed)
|
||||
{
|
||||
if(s_apiClient)
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Transfer failed: Destination stationId has avatars. Sending HARD ERROR to CTS API. %s", failed.toString().c_str()));
|
||||
const unsigned int result = static_cast<unsigned int>(CTService::CT_GAMERESULT_HARDERROR);
|
||||
s_apiClient->moveComplete(failed.getSourceStationId(), failed.getTrack(), result);
|
||||
IGNORE_RETURN(s_apiClient->replyTransferAccount(failed.getTrack(), result, NULL, NULL));
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void TransferServer::failedToTransferCharacterGameConnectionClosed(const TransferCharacterData & failed)
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Transfer failed: GameServer connection closed while transfer was in progress. Sending SOFT ERROR to CTS API. %s", failed.toString().c_str()));
|
||||
|
||||
replyMove(failed, CTService::CT_GAMERESULT_SOFTERROR);
|
||||
|
||||
// close pseudoclientconnections
|
||||
closePseudoClientConnections(failed.getSourceGalaxy(), failed.getSourceStationId(), failed.getDestinationGalaxy(), failed.getDestinationStationId());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void TransferServer::failedToTransferCharacterConnectionServerConnectionClosed(unsigned int stationId)
|
||||
{
|
||||
if(s_apiClient)
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Transfer failed: ConnectionServer connection closed with CentralServer while transfer was in progress for station id %d", stationId));
|
||||
const unsigned int result = static_cast<unsigned int>(CTService::CT_GAMERESULT_SOFTERROR);
|
||||
s_apiClient->moveComplete(stationId, 0, result);
|
||||
// tracking information is not availalable in this case, so an
|
||||
// API call can not be made. This is a SOFT error, however, and
|
||||
// the API will retry the transfer if there is a timeout.
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void TransferServer::failedToValidateTransfer(const TransferReplyMoveValidation & reply)
|
||||
{
|
||||
if(s_apiClient)
|
||||
{
|
||||
const unsigned int result = ((reply.getResult() == TransferReplyMoveValidation::TRMVR_cannot_create_regular_character) ? static_cast<unsigned int>(CTService::CT_GAMERESULT_MAX_CHAR_ON_DEST_SERVER) : static_cast<unsigned int>(CTService::CT_GAMERESULT_SERVER_IS_DOWN));
|
||||
|
||||
IGNORE_RETURN(s_apiClient->replyValidateMove(reply.getTrack(), result, NULL, NULL, NULL));
|
||||
s_apiClient->moveComplete(reply.getSourceStationId(), reply.getTrack(), result);
|
||||
|
||||
// close pseudoclientconnections
|
||||
closePseudoClientConnections(reply.getSourceGalaxy(), reply.getSourceStationId(), reply.getDestinationGalaxy(), reply.getDestinationStationId());
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@@ -0,0 +1,71 @@
|
||||
// TransferServer.h
|
||||
// Copyright 2000-03, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Justin Randall
|
||||
|
||||
#ifndef _INCLUDED_TransferServer_H
|
||||
#define _INCLUDED_TransferServer_H
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "Archive/ByteStream.h"
|
||||
#include <string>
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
struct CharacterTransferData
|
||||
{
|
||||
unsigned int stationId;
|
||||
std::string packedData;
|
||||
std::string fromGalaxy;
|
||||
};
|
||||
|
||||
class TransferAccountData;
|
||||
class TransferCharacterData;
|
||||
class TransferReplyCharacterList;
|
||||
class TransferReplyMoveValidation;
|
||||
class TransferReplyNameValidation;
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
class TransferServer
|
||||
{
|
||||
public:
|
||||
TransferServer();
|
||||
~TransferServer();
|
||||
|
||||
static void unauthorizeDownload (unsigned int stationId);
|
||||
static void authorizeDownload (unsigned int stationId);
|
||||
static const CharacterTransferData * getCharacterTransferData (unsigned int stationId, const std::string & fromGalaxy, bool administrativeRequest);
|
||||
static void run ();
|
||||
static void setDone (bool isDone);
|
||||
static bool uploadCharacterTransferData (const CharacterTransferData &, bool administrative);
|
||||
|
||||
static void requestCharacterList (unsigned int track, unsigned int stationId, const std::string & serverName, const std::string & customerLocalizedLanguage);
|
||||
static void requestMoveValidation (unsigned int track, unsigned int sourceStationId, unsigned int destinationStationId, const std::string & sourceGalaxy, const std::string & destinationGalaxy, const std::string & sourceCharacter, const std::string & destinationCharacter, const std::string & customerLocalizedLanguage);
|
||||
static void cacheSourceCharacterTemplateCrc(unsigned int stationId, const std::string & galaxy, const std::string & characterName, uint32 characterTemplateCrc);
|
||||
|
||||
static void requestMove (unsigned int track, const std::string & customerLocalizedLanguage, const std::string & sourceGalaxy, const std::string & destinationGalaxy, const std::string & sourceCharacter, const std::string & destinationCharacter, unsigned int sourceStationId, unsigned int destinationStationId, unsigned int transactionId, const bool withItems, const bool allowOverride);
|
||||
static void requestTransferAccount (unsigned int track, unsigned int sourceStationId, unsigned int destinationStationId, unsigned int transactionId);
|
||||
static void getLoginLocationData (const TransferCharacterData & characterData);
|
||||
static void replyCharacterList (const TransferReplyCharacterList & characterList);
|
||||
static void replyValidateMove (const TransferCharacterData &);
|
||||
static void replyMoveSuccess (const TransferCharacterData & reply);
|
||||
static void replyTransferAccountSuccess (const TransferAccountData & reply);
|
||||
static void transferCreateCharacterFailed(const TransferCharacterData & failed);
|
||||
static bool isRename (const TransferCharacterData & request);
|
||||
static void failedToRetrieveTransferData (const TransferCharacterData & failed);
|
||||
static void failedToApplyTransferData (const TransferCharacterData & failed);
|
||||
static void failedToTransferAccountNoCentralConnection (const TransferAccountData & failed);
|
||||
static void failedToTransferAccountDestinationNotEmpty (const TransferAccountData & failed);
|
||||
static void failedToTransferCharacterGameConnectionClosed (const TransferCharacterData & failed);
|
||||
static void failedToTransferCharacterConnectionServerConnectionClosed (const unsigned int stationId);
|
||||
static void failedToValidateTransfer (const TransferReplyMoveValidation & reply);
|
||||
|
||||
private:
|
||||
TransferServer & operator = (const TransferServer & rhs);
|
||||
TransferServer(const TransferServer & source);
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#endif // _INCLUDED_TransferServer_H
|
||||
@@ -0,0 +1,60 @@
|
||||
// main.cpp
|
||||
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Justin Randall
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "FirstTransferServer.h"
|
||||
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
#include "sharedCompression/SetupSharedCompression.h"
|
||||
#include "sharedDebug/SetupSharedDebug.h"
|
||||
#include "sharedFile/SetupSharedFile.h"
|
||||
#include "sharedFoundation/Os.h"
|
||||
#include "sharedFoundation/SetupSharedFoundation.h"
|
||||
#include "sharedNetwork/SetupSharedNetwork.h"
|
||||
#include "sharedNetwork/NetworkHandler.h"
|
||||
#include "sharedNetworkMessages/SetupSharedNetworkMessages.h"
|
||||
#include "sharedThread/SetupSharedThread.h"
|
||||
#include "TransferServer.h"
|
||||
#include "ConfigTransferServer.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 = true;
|
||||
SetupSharedFoundation::install (setupFoundationData);
|
||||
|
||||
SetupSharedCompression::install();
|
||||
SetupSharedFile::install(false);
|
||||
SetupSharedNetworkMessages::install();
|
||||
|
||||
SetupSharedNetwork::SetupData networkSetupData;
|
||||
SetupSharedNetwork::getDefaultServerSetupData(networkSetupData);
|
||||
SetupSharedNetwork::install(networkSetupData);
|
||||
NetworkHandler::install();
|
||||
|
||||
//Os::setProgramName("TransferServer");
|
||||
ConfigTransferServer::install();
|
||||
|
||||
//-- run server
|
||||
SetupSharedFoundation::callbackWithExceptionHandling(TransferServer::run);
|
||||
|
||||
NetworkHandler::remove();
|
||||
SetupSharedFoundation::remove();
|
||||
SetupSharedThread::remove();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user