mirror of
https://github.com/SWG-Source/src.git
synced 2026-07-31 00:15:55 -04:00
Merge branch 'testing' - this is newjava up to the current tip
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
*.geany
|
||||
*.cfg
|
||||
*.cmd
|
||||
.project
|
||||
*.kdev4
|
||||
latex
|
||||
@@ -5,3 +8,9 @@ html
|
||||
build*/
|
||||
!game/server/database/build/
|
||||
game/server/database/data/templates.sql
|
||||
.codelite/
|
||||
.idea/
|
||||
build.log
|
||||
*.phprj
|
||||
*.project
|
||||
*.workspace
|
||||
|
||||
+40
-14
@@ -2,12 +2,12 @@ cmake_policy(SET CMP0003 OLD) # or cmake_policy(VERSION 2.4)
|
||||
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
project(swgnge C CXX)
|
||||
project(stellabellum C CXX)
|
||||
|
||||
if(WIN32)
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/win32")
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/win32")
|
||||
elseif(UNIX)
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/linux")
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/linux")
|
||||
endif()
|
||||
|
||||
set(SWG_ROOT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
@@ -16,13 +16,11 @@ set(SWG_EXTERNALS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external)
|
||||
set(SWG_EXTERNALS_FIND ${CMAKE_CURRENT_SOURCE_DIR}/external/3rd/library)
|
||||
set(SWG_GAME_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/game)
|
||||
|
||||
|
||||
include_directories(/usr/include/i386-linux-gnu)
|
||||
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
|
||||
|
||||
find_package(BISON REQUIRED)
|
||||
find_package(Boost REQUIRED)
|
||||
find_package(FLEX REQUIRED)
|
||||
find_package(JNI REQUIRED)
|
||||
find_package(LibXml2 REQUIRED)
|
||||
@@ -31,29 +29,57 @@ find_package(PCRE REQUIRED)
|
||||
find_package(Perl REQUIRED)
|
||||
find_package(Threads)
|
||||
find_package(ZLIB REQUIRED)
|
||||
find_package(CURL REQUIRED)
|
||||
|
||||
if(WIN32)
|
||||
find_package(Iconv REQUIRED)
|
||||
#Dont-Build-PDB RELEASE build use the following (by either commenting---uncommenting the line as needed)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NODEFAULTLIB:libc.lib /SAFESEH:NO")
|
||||
|
||||
#Dont-Build-PDB RELEASE build use the following (by either commenting---uncommenting the line as needed)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NODEFAULTLIB:libc.lib /SAFESEH:NO")
|
||||
|
||||
####################################
|
||||
#Do-Build-PDB RELEASE build use the following (by either commenting---uncommenting the line as needed)
|
||||
#Do-Build-PDB RELEASE build use the following (by either commenting---uncommenting the line as needed)
|
||||
#set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DWIN32 -Dwin32 -DUDP_LIBRARY -DDEBUG_LEVEL=0 -DPRODUCTION=1 /Oi /Ot /Oy /O2 /GF /Gy /Zi /MT -D_USE_32BIT_TIME_T=1 -D_MBCS -DPLATFORM_BASE_SINGLE_THREAD -D_CRT_SECURE_NO_WARNINGS /MP /wd4244 /wd4996 /wd4018 /wd4351 /Zc:wchar_t- /Ob1 /FC")
|
||||
#Dont-Build-PDB RELEASE build use the following (by either commenting---uncommenting the line as needed)
|
||||
#Dont-Build-PDB RELEASE build use the following (by either commenting---uncommenting the line as needed)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DWIN32 -Dwin32 -DUDP_LIBRARY -DDEBUG_LEVEL=0 -DPRODUCTION=1 /Oi /Ot /Oy /O2 /GF /Gy /MT -D_USE_32BIT_TIME_T=1 -D_MBCS -DPLATFORM_BASE_SINGLE_THREAD -D_CRT_SECURE_NO_WARNINGS /MP /wd4244 /wd4996 /wd4018 /wd4351 /Zc:wchar_t- /Ob1 /FC")
|
||||
|
||||
|
||||
####################################
|
||||
#Standard DEBUG build use the following (by either commenting---uncommenting the line as needed)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DWIN32 -Dwin32 -D_DEBUG -DUDP_LIBRARY -DDEBUG_LEVEL=2 -DPRODUCTION=0 /MTd -D_USE_32BIT_TIME_T=1 -D_MBCS -DPLATFORM_BASE_SINGLE_THREAD -D_CRT_SECURE_NO_WARNINGS /MP /wd4244 /wd4996 /wd4018 /wd4351 /Zc:wchar_t- /Ob1 /FC")
|
||||
|
||||
elseif(UNIX)
|
||||
find_package(Curses REQUIRED)
|
||||
#find_package(MULODI REQUIRED)
|
||||
set(BUILD_MULODI_LIB FALSE)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG -DDEBUG_LEVEL=2 -DPRODUCTION=0 -g3 -pipe -O0 -Wall -Wno-overloaded-virtual -Wno-missing-braces -Wno-format -Wno-write-strings -Wno-unknown-pragmas -Wno-uninitialized -Wno-reorder")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDEBUG_LEVEL=0 -DPRODUCTION=1 -pipe -march=native -mtune=native -O2 -Wno-overloaded-virtual -Wno-missing-braces -Wno-format -Wno-write-strings -Wno-unknown-pragmas -Wno-uninitialized -Wno-reorder")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -D_GLIBCXX_USE_CXX11_ABI=0")
|
||||
# linker flags
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-O1,--sort-common,--as-needed,-z,relro")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
|
||||
|
||||
# don't put anything too crazy in debug...and any common flags go into CMAKE_CXX_FLAGS
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG -DDEBUG_LEVEL=2 -DPRODUCTION=0 -O0")
|
||||
|
||||
# funroll loops and everything else potentially crazy for performance here
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDEBUG_LEVEL=0 -DPRODUCTION=1 -Ofast -funroll-loops")
|
||||
|
||||
# TODO: The below flags will enhance security but at the cost of performance, arguably...
|
||||
# currently with them SWG cluster idles at ~17-18% of 24 cpus, and ata round ~14-17% without
|
||||
# there is likely also a latency/speed impact as well
|
||||
# not sure if needed or not - https://wiki.debian.org/Hardening
|
||||
# ============================================================================================
|
||||
# -fstack-protector-all -Wstack-protector --param ssp-buffer-size=4 -fPIE -ftrapv
|
||||
# -D_FORTIFY_SOURCE=2 is generally considered safe but crashes datatabletool when built with gcc
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -D_GLIBCXX_USE_CXX11_ABI=0 \
|
||||
-m32 -pipe -march=native -mtune=native \
|
||||
-Wformat -Wno-overloaded-virtual -Wno-missing-braces -Wno-format \
|
||||
-Wno-write-strings -Wno-unknown-pragmas \
|
||||
-Wno-uninitialized -Wno-reorder")
|
||||
|
||||
# we could use libc++ with gcc too but let's roll with default there
|
||||
#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
#endif()
|
||||
|
||||
add_definitions(-DLINUX -D_REENTRANT -Dlinux -D_USING_STL -D__STL_NO_BAD_ALLOC -D_GNU_SOURCE -D_XOPEN_SOURCE=500)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -181,6 +181,7 @@ set(JAVA_AWT_INCLUDE_DIRECTORIES
|
||||
/usr/lib/jvm/java-8-oracle/include
|
||||
/usr/lib/jvm/java-7-oracle/include
|
||||
/usr/lib/jvm/java-6-oracle/include
|
||||
/opt/java/include
|
||||
)
|
||||
|
||||
foreach(JAVA_PROG "${JAVA_RUNTIME}" "${JAVA_COMPILE}" "${JAVA_ARCHIVE}")
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
# when using clang with m32, mulodi4 is missing...this checks for it/not
|
||||
# if we're using linux/not
|
||||
|
||||
include(CheckCXXSourceCompiles)
|
||||
set(BUILD_MULODI_LIB FALSE)
|
||||
|
||||
set(find_mulodi_test_program
|
||||
"#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int64_t x = ((int64_t)atoi(argv[1])) * (int64_t)atoi(argv[2])
|
||||
* (int64_t)atoi(argv[3]);
|
||||
return x == 9;
|
||||
}")
|
||||
|
||||
set(CMAKE_REQUIRED_FLAGS "-Wl,-O1,--sort-common,--as-needed,-z,relro,-flto -ftrapv -m32")
|
||||
set(CMAKE_REQUIRED_LIBRARIES "")
|
||||
CHECK_CXX_SOURCE_COMPILES(
|
||||
"${find_mulodi_test_program}"
|
||||
mulodi_found
|
||||
)
|
||||
|
||||
if(NOT mulodi_found)
|
||||
set(BUILD_MULODI_LIB TRUE)
|
||||
endif()
|
||||
@@ -271,7 +271,7 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
|
||||
*/
|
||||
#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
|
||||
? (yy_buffer_stack)[(yy_buffer_stack_top)] \
|
||||
: NULL)
|
||||
: nullptr)
|
||||
|
||||
/* Same as previous macro, but useful when we know that the buffer stack is not
|
||||
* NULL or when we need an lvalue. For internal use only.
|
||||
@@ -5779,7 +5779,7 @@ extern int isatty (int );
|
||||
*/
|
||||
void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
|
||||
{
|
||||
if (new_buffer == NULL)
|
||||
if (new_buffer == nullptr)
|
||||
return;
|
||||
|
||||
yyensure_buffer_stack();
|
||||
@@ -5813,7 +5813,7 @@ void yypop_buffer_state (void)
|
||||
return;
|
||||
|
||||
yy_delete_buffer(YY_CURRENT_BUFFER );
|
||||
YY_CURRENT_BUFFER_LVALUE = NULL;
|
||||
YY_CURRENT_BUFFER_LVALUE = nullptr;
|
||||
if ((yy_buffer_stack_top) > 0)
|
||||
--(yy_buffer_stack_top);
|
||||
|
||||
@@ -6097,13 +6097,13 @@ int yylex_destroy (void)
|
||||
/* Pop the buffer stack, destroying each element. */
|
||||
while(YY_CURRENT_BUFFER){
|
||||
yy_delete_buffer(YY_CURRENT_BUFFER );
|
||||
YY_CURRENT_BUFFER_LVALUE = NULL;
|
||||
YY_CURRENT_BUFFER_LVALUE = nullptr;
|
||||
yypop_buffer_state();
|
||||
}
|
||||
|
||||
/* Destroy the stack itself. */
|
||||
yyfree((yy_buffer_stack) );
|
||||
(yy_buffer_stack) = NULL;
|
||||
(yy_buffer_stack) = nullptr;
|
||||
|
||||
/* Reset the globals. This is important in a non-reentrant scanner so the next time
|
||||
* yylex() is called, initialization will occur. */
|
||||
|
||||
@@ -124,7 +124,7 @@ int InputFileHandler::deleteFile(
|
||||
if (deleteHandleFlag && file)
|
||||
{
|
||||
delete file;
|
||||
file = NULL;
|
||||
file = nullptr;
|
||||
}
|
||||
return(unlink(filename));
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
OutputFileHandler::OutputFileHandler(const char *filename)
|
||||
{
|
||||
outputIFF = new Iff(MAXIFFDATASIZE);
|
||||
outFilename = NULL;
|
||||
outFilename = nullptr;
|
||||
|
||||
setCurrentFilename(filename);
|
||||
}
|
||||
@@ -45,7 +45,7 @@ OutputFileHandler::~OutputFileHandler(void)
|
||||
delete [] outFilename;
|
||||
}
|
||||
|
||||
outputIFF = NULL;
|
||||
outputIFF = nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -632,13 +632,6 @@ yyerrlab1: /* here on error raised explicitly by an action */
|
||||
|
||||
yyerrdefault: /* current state does not do anything special for the error token. */
|
||||
|
||||
#if 0
|
||||
/* This is wrong; only states that explicitly want error tokens
|
||||
should shift them. */
|
||||
yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
|
||||
if (yyn) goto yydefault;
|
||||
#endif
|
||||
|
||||
yyerrpop: /* pop the current state because it cannot handle the error token */
|
||||
|
||||
if (yyssp == yyss) YYABORT;
|
||||
|
||||
@@ -53,9 +53,7 @@
|
||||
#include <stdlib.h> // for tolower()
|
||||
|
||||
//================================================= static vars assignment ==
|
||||
const int entryPointVersion = 1; // constantly check DataEntryPoint.h to see if this value has changed
|
||||
|
||||
OutputFileHandler *outfileHandler = NULL;
|
||||
OutputFileHandler *outfileHandler = nullptr;
|
||||
const int bufferSize = 16 * 1024 * 1024;
|
||||
const int maxStringSize = 256;
|
||||
const char version[] = "1.3 September 18, 2000";
|
||||
@@ -242,7 +240,7 @@ int main( int argc, // number of args in commandline
|
||||
//
|
||||
static void callbackFunction(void)
|
||||
{
|
||||
outfileHandler = NULL;
|
||||
outfileHandler = nullptr;
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
@@ -382,201 +380,6 @@ static errorType evaluateArgs(void)
|
||||
return retVal;
|
||||
|
||||
return retVal;
|
||||
|
||||
#if 0
|
||||
|
||||
errorType retVal = ERR_NONE; // assume no error has been found
|
||||
bool outPathUsed = false; // flag to monitor if -o flag was used, if so, we can ignore -d, -p, -e, -f
|
||||
bool inFileEntered = false;
|
||||
int argc = CommandLine::getPlainCount();
|
||||
|
||||
// get default values from DOS
|
||||
char currentDir[maxStringSize];
|
||||
if (NULL == getcwd(currentDir, maxStringSize)) // get current working directory
|
||||
{
|
||||
retVal = ERR_UNKNOWNDIR;
|
||||
return(retVal);
|
||||
}
|
||||
drive[0] = currentDir[0]; // drive letter
|
||||
drive[1] = 0; // and null terminate it
|
||||
strcpy(extension, "IFF"); // default to uppercase .IFF
|
||||
strcpy(directory, ¤tDir[2]); // get everything after the Drive: including the first backslash
|
||||
filename[0] = 0;
|
||||
|
||||
// see specs.txt for requests
|
||||
// scan for any argv's that has '-' in the argv[n][0]'s character
|
||||
for (int index = 0; index < argc; index++) // note: if using argv[] rather then CommandLine::getPlainString() then start with 1 rather then 0
|
||||
{
|
||||
if ('-' == CommandLine::getPlainString(index)[0])
|
||||
{
|
||||
// we've found a parameter switch
|
||||
switch (tolower(CommandLine::getPlainString(index)[1])) // assume non case sensitive switches
|
||||
{
|
||||
case 'i': // install via #pragma
|
||||
{
|
||||
usePragma = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'c': // use CCCP instead of CPP
|
||||
useCCCP = true;
|
||||
break;
|
||||
|
||||
case 'v': // don't show any debug message
|
||||
verboseMode = true;
|
||||
break;
|
||||
|
||||
case '$':
|
||||
debugMode = true;
|
||||
break;
|
||||
|
||||
case 'o': // target output file name and path (complete path)
|
||||
{
|
||||
index++; // next param
|
||||
outPathUsed = true;
|
||||
strcpy(outFileName, CommandLine::getPlainString(index));
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 'd': // target drive letter (-p must be present)
|
||||
{
|
||||
if (!outPathUsed)
|
||||
{
|
||||
index++; // next param
|
||||
strcpy(drive, CommandLine::getPlainString(index));
|
||||
}
|
||||
else
|
||||
index++; // skip the drive letter arg that SHOULD follow the -d option
|
||||
break;
|
||||
}
|
||||
|
||||
case 'p': // target pathname
|
||||
{
|
||||
if (!outPathUsed)
|
||||
{
|
||||
index++; // next param
|
||||
strcpy(directory, CommandLine::getPlainString(index));
|
||||
}
|
||||
else
|
||||
index++; // skip the pathname arg that follows the -p option
|
||||
break;
|
||||
}
|
||||
|
||||
case 'f': // target filename
|
||||
{
|
||||
if (!outPathUsed)
|
||||
{
|
||||
index++; // next param
|
||||
strcpy(filename, CommandLine::getPlainString(index));
|
||||
}
|
||||
else
|
||||
index++; // skip the filename arg that follows the -f
|
||||
break;
|
||||
}
|
||||
|
||||
case 'e': // target extension
|
||||
{
|
||||
if (!outPathUsed)
|
||||
{
|
||||
index++; // next param
|
||||
strcpy(extension, CommandLine::getPlainString(index));
|
||||
}
|
||||
else
|
||||
index++; // skip the extension arg that follows the -e
|
||||
break;
|
||||
}
|
||||
|
||||
case 'h': // help!
|
||||
case '?':
|
||||
{
|
||||
help();
|
||||
index = argc; // force to exit
|
||||
retVal = ERR_HELPREQUEST;
|
||||
return(retVal); // special case, ONLY time I call return() in the middle of the function (because I check for argc < 2 at the end of the code)
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
sprintf(err_msg, "\nUnknown parameter %s, use -h to seek help...\n", CommandLine::getPlainString(index));
|
||||
MIFFMessage(err_msg, 1);
|
||||
index = argc; // force to exit
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// we found an arg that doesn't start with '-' so let's assume it's a filename
|
||||
if (!inFileEntered)
|
||||
{
|
||||
strcpy(inFileName, CommandLine::getPlainString(index));
|
||||
inFileEntered = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal = ERR_MULTIPLEINFILE;
|
||||
index = argc;
|
||||
}
|
||||
|
||||
// now construct the DEFAULT filename for this file by scanning backwards to front and only extracting the filename (no extension, no path)
|
||||
if (ERR_NONE == retVal)
|
||||
{
|
||||
char sourceName[maxStringSize];
|
||||
strcpy(sourceName, inFileName); // make a duplicate for us to play with
|
||||
for (int strIndex = strlen(sourceName); strIndex > 0; strIndex--)
|
||||
{
|
||||
if ('.' == sourceName[strIndex])
|
||||
sourceName[strIndex] = 0; // put a stopper here... we are assuming that '.' indicates extension! I'm going to assume that the person is just testing me if s/he decides to use filename like "foo.bar.psych" which will truncate to "foo"
|
||||
if ('\\' == sourceName[strIndex])
|
||||
break; // get out, for we've reached the path name...
|
||||
}
|
||||
|
||||
// ok, by here, strIndex should point to either beginning of the string, or where the first '\' was found scanning backwards
|
||||
strcpy(filename, &sourceName[strIndex]); // ta-da-!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (inFileEntered)
|
||||
{
|
||||
if (0 == preprocessSource(inFileName))
|
||||
{
|
||||
if (verboseMode)
|
||||
{
|
||||
// using err_msg as my temp buffer...
|
||||
sprintf(err_msg,"Now compiling %s\n", inFileName);
|
||||
MIFFMessage(err_msg, 0);
|
||||
}
|
||||
|
||||
if (ERR_NONE == retVal)
|
||||
retVal = loadInputToBuffer(sourceBuffer, bufferSize);
|
||||
}
|
||||
else // preprocessSource returned an error...
|
||||
{
|
||||
retVal = ERR_PREPROCESS;
|
||||
}
|
||||
}
|
||||
else // inFileEntered == false
|
||||
{
|
||||
MIFFMessage("Missing input filename in command line!", 1);
|
||||
}
|
||||
|
||||
// construct a outFileName[] based on drive[], directory[], filename[], and extension[]
|
||||
if (!outPathUsed && (ERR_NONE == retVal))
|
||||
{
|
||||
if (inFileName[0]) // make sure the user has entered a input filename
|
||||
sprintf(outFileName,"%s:%s\\%s.%s", drive, directory, filename, extension);
|
||||
}
|
||||
|
||||
if (argc < 1)
|
||||
retVal = ERR_ARGSTOOFEW; // we can do this because we know -h was not entered...
|
||||
|
||||
return(retVal);
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -619,7 +422,7 @@ static errorType loadInputToBuffer(
|
||||
// we've successfully read the file, now close it...
|
||||
delete inFileHandler;
|
||||
}
|
||||
else // inFileName is NULL
|
||||
else // inFileName is nullptr
|
||||
{
|
||||
retVal = ERR_FILENOTFOUND;
|
||||
}
|
||||
@@ -746,7 +549,7 @@ static void handleError(errorType error)
|
||||
// Revisions and History:
|
||||
// 1/07/99 [] - created
|
||||
//
|
||||
extern "C" void MIFFMessage(char *message, // null terminated string to be displayed
|
||||
extern "C" void MIFFMessage(char *message, // nullptr terminated string to be displayed
|
||||
int forceOutput) // if non-zero, it will print out even in quiet mode (for ERRORs)
|
||||
{
|
||||
if (forceOutput)
|
||||
|
||||
@@ -0,0 +1,334 @@
|
||||
|
||||
extern int timeclock;
|
||||
|
||||
|
||||
int yyerror; /* Yyerror and yycost are set by guards. */
|
||||
int yycost; /* If yyerror is set to a nonzero value by a */
|
||||
/* guard, the reduction with which the guard */
|
||||
/* is associated is not performed, and the */
|
||||
/* error recovery mechanism is invoked. */
|
||||
/* Yycost indicates the cost of performing */
|
||||
/* the reduction given the attributes of the */
|
||||
/* symbols. */
|
||||
|
||||
|
||||
/* YYMAXDEPTH indicates the size of the parser's state and value */
|
||||
/* stacks. */
|
||||
|
||||
#ifndef YYMAXDEPTH
|
||||
#define YYMAXDEPTH 500
|
||||
#endif
|
||||
|
||||
/* YYMAXRULES must be at least as large as the number of rules that */
|
||||
/* could be placed in the rule queue. That number could be determined */
|
||||
/* from the grammar and the size of the stack, but, as yet, it is not. */
|
||||
|
||||
#ifndef YYMAXRULES
|
||||
#define YYMAXRULES 100
|
||||
#endif
|
||||
|
||||
#ifndef YYMAXBACKUP
|
||||
#define YYMAXBACKUP 100
|
||||
#endif
|
||||
|
||||
|
||||
short yyss[YYMAXDEPTH]; /* the state stack */
|
||||
YYSTYPE yyvs[YYMAXDEPTH]; /* the semantic value stack */
|
||||
YYLTYPE yyls[YYMAXDEPTH]; /* the location stack */
|
||||
short yyrq[YYMAXRULES]; /* the rule queue */
|
||||
int yychar; /* the lookahead symbol */
|
||||
|
||||
YYSTYPE yylval; /* the semantic value of the */
|
||||
/* lookahead symbol */
|
||||
|
||||
YYSTYPE yytval; /* the semantic value for the state */
|
||||
/* at the top of the state stack. */
|
||||
|
||||
YYSTYPE yyval; /* the variable used to return */
|
||||
/* semantic values from the action */
|
||||
/* routines */
|
||||
|
||||
YYLTYPE yylloc; /* location data for the lookahead */
|
||||
/* symbol */
|
||||
|
||||
YYLTYPE yytloc; /* location data for the state at the */
|
||||
/* top of the state stack */
|
||||
|
||||
|
||||
int yynunlexed;
|
||||
short yyunchar[YYMAXBACKUP];
|
||||
YYSTYPE yyunval[YYMAXBACKUP];
|
||||
YYLTYPE yyunloc[YYMAXBACKUP];
|
||||
|
||||
short *yygssp; /* a pointer to the top of the state */
|
||||
/* stack; only set during error */
|
||||
/* recovery. */
|
||||
|
||||
YYSTYPE *yygvsp; /* a pointer to the top of the value */
|
||||
/* stack; only set during error */
|
||||
/* recovery. */
|
||||
|
||||
YYLTYPE *yyglsp; /* a pointer to the top of the */
|
||||
/* location stack; only set during */
|
||||
/* error recovery. */
|
||||
|
||||
|
||||
/* Yyget is an interface between the parser and the lexical analyzer. */
|
||||
/* It is costly to provide such an interface, but it avoids requiring */
|
||||
/* the lexical analyzer to be able to back up the scan. */
|
||||
|
||||
yyget()
|
||||
{
|
||||
if (yynunlexed > 0)
|
||||
{
|
||||
yynunlexed--;
|
||||
yychar = yyunchar[yynunlexed];
|
||||
yylval = yyunval[yynunlexed];
|
||||
yylloc = yyunloc[yynunlexed];
|
||||
}
|
||||
else if (yychar <= 0)
|
||||
yychar = 0;
|
||||
else
|
||||
{
|
||||
yychar = yylex();
|
||||
if (yychar < 0)
|
||||
yychar = 0;
|
||||
else yychar = YYTRANSLATE(yychar);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
yyunlex(chr, val, loc)
|
||||
int chr;
|
||||
YYSTYPE val;
|
||||
YYLTYPE loc;
|
||||
{
|
||||
yyunchar[yynunlexed] = chr;
|
||||
yyunval[yynunlexed] = val;
|
||||
yyunloc[yynunlexed] = loc;
|
||||
yynunlexed++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
yyrestore(first, last)
|
||||
register short *first;
|
||||
register short *last;
|
||||
{
|
||||
register short *ssp;
|
||||
register short *rp;
|
||||
register int symbol;
|
||||
register int state;
|
||||
register int tvalsaved;
|
||||
|
||||
ssp = yygssp;
|
||||
yyunlex(yychar, yylval, yylloc);
|
||||
|
||||
tvalsaved = 0;
|
||||
while (first != last)
|
||||
{
|
||||
symbol = yystos[*ssp];
|
||||
if (symbol < YYNTBASE)
|
||||
{
|
||||
yyunlex(symbol, yytval, yytloc);
|
||||
tvalsaved = 1;
|
||||
ssp--;
|
||||
}
|
||||
|
||||
ssp--;
|
||||
|
||||
if (first == yyrq)
|
||||
first = yyrq + YYMAXRULES;
|
||||
|
||||
first--;
|
||||
|
||||
for (rp = yyrhs + yyprhs[*first]; symbol = *rp; rp++)
|
||||
{
|
||||
if (symbol < YYNTBASE)
|
||||
state = yytable[yypact[*ssp] + symbol];
|
||||
else
|
||||
{
|
||||
state = yypgoto[symbol - YYNTBASE] + *ssp;
|
||||
|
||||
if (state >= 0 && state <= YYLAST && yycheck[state] == *ssp)
|
||||
state = yytable[state];
|
||||
else
|
||||
state = yydefgoto[symbol - YYNTBASE];
|
||||
}
|
||||
|
||||
*++ssp = state;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! tvalsaved && ssp > yyss)
|
||||
{
|
||||
yyunlex(yystos[*ssp], yytval, yytloc);
|
||||
ssp--;
|
||||
}
|
||||
|
||||
yygssp = ssp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
yyparse()
|
||||
{
|
||||
register int yystate;
|
||||
register int yyn;
|
||||
register short *yyssp;
|
||||
register short *yyrq0;
|
||||
register short *yyptr;
|
||||
register YYSTYPE *yyvsp;
|
||||
|
||||
int yylen;
|
||||
YYLTYPE *yylsp;
|
||||
short *yyrq1;
|
||||
short *yyrq2;
|
||||
|
||||
yystate = 0;
|
||||
yyssp = yyss - 1;
|
||||
yyvsp = yyvs - 1;
|
||||
yylsp = yyls - 1;
|
||||
yyrq0 = yyrq;
|
||||
yyrq1 = yyrq0;
|
||||
yyrq2 = yyrq0;
|
||||
|
||||
yychar = yylex();
|
||||
if (yychar < 0)
|
||||
yychar = 0;
|
||||
else yychar = YYTRANSLATE(yychar);
|
||||
|
||||
yynewstate:
|
||||
|
||||
if (yyssp >= yyss + YYMAXDEPTH - 1)
|
||||
{
|
||||
yyabort("Parser Stack Overflow");
|
||||
YYABORT;
|
||||
}
|
||||
|
||||
*++yyssp = yystate;
|
||||
|
||||
yyresume:
|
||||
|
||||
yyn = yypact[yystate];
|
||||
if (yyn == YYFLAG)
|
||||
goto yydefault;
|
||||
|
||||
yyn += yychar;
|
||||
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar)
|
||||
goto yydefault;
|
||||
|
||||
yyn = yytable[yyn];
|
||||
if (yyn < 0)
|
||||
{
|
||||
yyn = -yyn;
|
||||
goto yyreduce;
|
||||
}
|
||||
else if (yyn == 0)
|
||||
goto yyerrlab;
|
||||
|
||||
yystate = yyn;
|
||||
|
||||
yyptr = yyrq2;
|
||||
while (yyptr != yyrq1)
|
||||
{
|
||||
yyn = *yyptr++;
|
||||
yylen = yyr2[yyn];
|
||||
yyvsp -= yylen;
|
||||
yylsp -= yylen;
|
||||
|
||||
yyguard(yyn, yyvsp, yylsp);
|
||||
if (yyerror)
|
||||
goto yysemerr;
|
||||
|
||||
yyaction(yyn, yyvsp, yylsp);
|
||||
*++yyvsp = yyval;
|
||||
|
||||
yylsp++;
|
||||
if (yylen == 0)
|
||||
{
|
||||
yylsp->timestamp = timeclock;
|
||||
yylsp->first_line = yytloc.first_line;
|
||||
yylsp->first_column = yytloc.first_column;
|
||||
yylsp->last_line = (yylsp-1)->last_line;
|
||||
yylsp->last_column = (yylsp-1)->last_column;
|
||||
yylsp->text = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
yylsp->last_line = (yylsp+yylen-1)->last_line;
|
||||
yylsp->last_column = (yylsp+yylen-1)->last_column;
|
||||
}
|
||||
|
||||
if (yyptr == yyrq + YYMAXRULES)
|
||||
yyptr = yyrq;
|
||||
}
|
||||
|
||||
if (yystate == YYFINAL)
|
||||
YYACCEPT;
|
||||
|
||||
yyrq2 = yyptr;
|
||||
yyrq1 = yyrq0;
|
||||
|
||||
*++yyvsp = yytval;
|
||||
*++yylsp = yytloc;
|
||||
yytval = yylval;
|
||||
yytloc = yylloc;
|
||||
yyget();
|
||||
|
||||
goto yynewstate;
|
||||
|
||||
yydefault:
|
||||
|
||||
yyn = yydefact[yystate];
|
||||
if (yyn == 0)
|
||||
goto yyerrlab;
|
||||
|
||||
yyreduce:
|
||||
|
||||
*yyrq0++ = yyn;
|
||||
|
||||
if (yyrq0 == yyrq + YYMAXRULES)
|
||||
yyrq0 = yyrq;
|
||||
|
||||
if (yyrq0 == yyrq2)
|
||||
{
|
||||
yyabort("Parser Rule Queue Overflow");
|
||||
YYABORT;
|
||||
}
|
||||
|
||||
yyssp -= yyr2[yyn];
|
||||
yyn = yyr1[yyn];
|
||||
|
||||
yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
|
||||
if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
|
||||
yystate = yytable[yystate];
|
||||
else
|
||||
yystate = yydefgoto[yyn - YYNTBASE];
|
||||
|
||||
goto yynewstate;
|
||||
|
||||
yysemerr:
|
||||
*--yyptr = yyn;
|
||||
yyrq2 = yyptr;
|
||||
yyvsp += yyr2[yyn];
|
||||
|
||||
yyerrlab:
|
||||
|
||||
yygssp = yyssp;
|
||||
yygvsp = yyvsp;
|
||||
yyglsp = yylsp;
|
||||
yyrestore(yyrq0, yyrq2);
|
||||
yyrecover();
|
||||
yystate = *yygssp;
|
||||
yyssp = yygssp;
|
||||
yyvsp = yygvsp;
|
||||
yyrq0 = yyrq;
|
||||
yyrq1 = yyrq0;
|
||||
yyrq2 = yyrq0;
|
||||
goto yyresume;
|
||||
}
|
||||
|
||||
$
|
||||
@@ -0,0 +1,136 @@
|
||||
//===========================================================================
|
||||
//
|
||||
// FILENAME: InputFileHandler.cpp [C:\Projects\new\tools\src\miff\src\]
|
||||
// COPYRIGHT: (C) 1999 BY Bootprint Entertainment
|
||||
//
|
||||
// DESCRIPTION: file handler for input files (standard flat text files)
|
||||
// AUTHOR: Hideki Ikeda
|
||||
// DATE: 1/13/99 4:53:31 PM
|
||||
//
|
||||
// HISTORY: 1/13/99 [HAI] - File created
|
||||
// :
|
||||
//
|
||||
// FUNCTION: InputFileHandler() constructor
|
||||
// : ~InputFileHandler() destructor
|
||||
// :
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
//========================================================== include files ==
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
#include "InputFileHandler.h"
|
||||
|
||||
#include "sharedFile/TreeFile.h"
|
||||
//#include "sharedFile/Iff.h"
|
||||
|
||||
//================================================= static vars assignment ==
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Constructor
|
||||
//
|
||||
// Remarks:
|
||||
//
|
||||
//
|
||||
// See Also:
|
||||
//
|
||||
//
|
||||
// Revisions and History:
|
||||
// 1/13/99 [HAI] - created
|
||||
//
|
||||
InputFileHandler::InputFileHandler(const char *infilename)
|
||||
{
|
||||
TreeFile::addSearchAbsolute(0); // search current working directory
|
||||
|
||||
file = TreeFile::open(infilename, AbstractFile::PriorityData, true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Destructor
|
||||
//
|
||||
// Remarks:
|
||||
//
|
||||
//
|
||||
// See Also:
|
||||
//
|
||||
//
|
||||
// Revisions and History:
|
||||
// 1/13/99 [HAI] - created
|
||||
//
|
||||
InputFileHandler::~InputFileHandler(void)
|
||||
{
|
||||
if(file)
|
||||
delete file;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// reads a file stream into specified buffer of the size passed
|
||||
//
|
||||
// Return Value:
|
||||
// actual size read (signed int)
|
||||
//
|
||||
// Remarks:
|
||||
//
|
||||
//
|
||||
// See Also:
|
||||
// Treefile::read()
|
||||
//
|
||||
// Revisions and History:
|
||||
// 1/13/99 [HAI] - created
|
||||
//
|
||||
const int InputFileHandler::read(
|
||||
void *sourceBuffer, // pointer to the buffer
|
||||
int bufferSize // number of BYTES to be read
|
||||
)
|
||||
{
|
||||
int retVal = -1; // assume fileHandle is NOT valid
|
||||
|
||||
if (file)
|
||||
retVal = file->read(sourceBuffer, bufferSize);
|
||||
|
||||
return(retVal);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Deletes a file
|
||||
//
|
||||
// Return Value:
|
||||
// whatever DeleteFile() returns
|
||||
// if fileHandle != -1, it assumes that the fileHandle passed belonged to
|
||||
// this filename, and therefore, it will attempt to close the file and
|
||||
// set it to 0.
|
||||
//
|
||||
// Remarks:
|
||||
// calls DeleteFile() found in windows.h
|
||||
// InputFileHandler does NOT have any way to validate that the handle
|
||||
// passed belongs to the filename that it wants to be deleted. So use
|
||||
// it with caution
|
||||
//
|
||||
// See Also:
|
||||
// windows.h
|
||||
//
|
||||
// Revisions and History:
|
||||
// 1/13/99 [HAI] - created
|
||||
//
|
||||
int InputFileHandler::deleteFile(
|
||||
const char *filename,
|
||||
bool deleteHandleFlag
|
||||
)
|
||||
{
|
||||
if (deleteHandleFlag && file)
|
||||
{
|
||||
delete file;
|
||||
file = NULL;
|
||||
}
|
||||
return(DeleteFile(filename));
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//============================================================ End-of-file ==
|
||||
//===========================================================================
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
#ifndef __INPUTFILEHANDLER_H__
|
||||
#define __INPUTFILEHANDLER_H__
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// FILENAME: InputFileHandler.h [C:\Projects\new\tools\src\miff\src\]
|
||||
// COPYRIGHT: (C) 1999 BY Bootprint Entertainment
|
||||
//
|
||||
// DESCRIPTION: file handler for input files (flat text files)
|
||||
// AUTHOR: Hideki Ikeda
|
||||
// DATE: 1/13/99 4:55:15 PM
|
||||
//
|
||||
// HISTORY: 1/13/99 [HAI] - File created
|
||||
// :
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
//============================================================== #includes ==
|
||||
|
||||
//========================================================= class typedefs ==
|
||||
|
||||
//====================================================== class definitions ==
|
||||
|
||||
class AbstractFile;
|
||||
|
||||
class InputFileHandler
|
||||
{
|
||||
//------------------------------
|
||||
//--- public var & functions ---
|
||||
//------------------------------
|
||||
public: // functions
|
||||
InputFileHandler(const char *infilename);
|
||||
~InputFileHandler(void);
|
||||
|
||||
const int read(void *sourceBuffer, int bufferSize);
|
||||
int deleteFile(const char * filename, bool deleteHandleFlag = false);
|
||||
|
||||
public: // vars
|
||||
|
||||
|
||||
//-------------------------------
|
||||
//--- member vars declaration ---
|
||||
//-------------------------------
|
||||
protected: // vars
|
||||
AbstractFile *file;
|
||||
|
||||
private: // vars
|
||||
|
||||
//-----------------------------------
|
||||
//--- member function declaration ---
|
||||
//-----------------------------------
|
||||
protected: // functions
|
||||
|
||||
private: // functions
|
||||
void close(void); // close the input file called by destructor
|
||||
|
||||
};
|
||||
|
||||
//===========================================================================
|
||||
//========================================================= inline methods ==
|
||||
//===========================================================================
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//============================================================ End-of-file ==
|
||||
//===========================================================================
|
||||
#else
|
||||
#ifdef DEBUG
|
||||
#pragma message("InputFileHandler.h included more then once!")
|
||||
#endif
|
||||
#endif // ifndef __H__
|
||||
@@ -0,0 +1,164 @@
|
||||
//===========================================================================
|
||||
//
|
||||
// FILENAME: OutputFileHandler.cpp
|
||||
// COPYRIGHT: (C) 1999 BY Bootprint Entertainment
|
||||
//
|
||||
// DESCRIPTION: file handler for Output file (IFF file)
|
||||
// AUTHOR: Hideki Ikeda
|
||||
// DATE: 1/13/99 4:52:42 PM
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
#include "OutputFileHandler.h"
|
||||
|
||||
#include "sharedFile/Iff.h"
|
||||
|
||||
//===========================================================================
|
||||
// Constructor
|
||||
|
||||
OutputFileHandler::OutputFileHandler(const char *filename)
|
||||
{
|
||||
outputIFF = new Iff(MAXIFFDATASIZE);
|
||||
outFilename = NULL;
|
||||
|
||||
setCurrentFilename(filename);
|
||||
}
|
||||
|
||||
void OutputFileHandler::setCurrentFilename(const char *filename)
|
||||
{
|
||||
if (outFilename)
|
||||
delete [] outFilename;
|
||||
|
||||
outFilename = new char[strlen(filename)+1];
|
||||
strcpy(outFilename, filename);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Destructor
|
||||
|
||||
OutputFileHandler::~OutputFileHandler(void)
|
||||
{
|
||||
if (outputIFF && outFilename)
|
||||
{
|
||||
delete outputIFF;
|
||||
delete [] outFilename;
|
||||
}
|
||||
|
||||
outputIFF = NULL;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// begins a new FORM in the IFF
|
||||
//
|
||||
// Return Value:
|
||||
// bool - true == success
|
||||
//
|
||||
// See Also:
|
||||
// Iff::insertForm()
|
||||
|
||||
void OutputFileHandler::insertForm(
|
||||
const char *tag
|
||||
)
|
||||
{
|
||||
Tag formTag = convertStrToTag(tag);
|
||||
outputIFF->insertForm(formTag);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// begins a new CHUNK in the IFF
|
||||
//
|
||||
// See Also:
|
||||
// Iff::insertChunk()
|
||||
|
||||
void OutputFileHandler::insertChunk(
|
||||
const char *tag
|
||||
)
|
||||
{
|
||||
Tag chunkTag = convertStrToTag(tag);
|
||||
outputIFF->insertChunk(chunkTag);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// converts string (4 bytes) form into Tag format
|
||||
//
|
||||
// Return Value:
|
||||
// Tag
|
||||
//
|
||||
// Remarks:
|
||||
// currently, this code is machine dependant code (non portable) and it assumes little endian
|
||||
//
|
||||
// See Also:
|
||||
// Tag
|
||||
|
||||
Tag OutputFileHandler::convertStrToTag(
|
||||
const char *str
|
||||
)
|
||||
{
|
||||
// prepare for hack-o-rama. It is byte order dependant, thus not portable ^_^
|
||||
Tag retVal = str[3] + (str[2] * 0x100) + (str[1] * 0x10000) + (str[0] * 0x1000000);
|
||||
|
||||
return(retVal);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// adds new chunk data into the current chunk it is in
|
||||
//
|
||||
// See Also:
|
||||
// Iff::insertChunkData()
|
||||
//
|
||||
|
||||
void OutputFileHandler::insertChunkData(
|
||||
void *data,
|
||||
int length
|
||||
)
|
||||
{
|
||||
outputIFF->insertChunkData(data, length);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// exits current FORM section we are in
|
||||
//
|
||||
// See Also:
|
||||
// Iff::exitForm()
|
||||
|
||||
void OutputFileHandler::exitForm(void)
|
||||
{
|
||||
outputIFF->exitForm();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// exits current CHUNK we are in
|
||||
//
|
||||
// See Also:
|
||||
// Iff::exitChunk()
|
||||
|
||||
void OutputFileHandler::exitChunk(void)
|
||||
{
|
||||
outputIFF->exitChunk();
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Calls Iff:write()
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// True if the Iff was successfully written, otherwise false
|
||||
//
|
||||
// See Also:
|
||||
// Iff::write()
|
||||
|
||||
bool OutputFileHandler::writeBuffer(void)
|
||||
{
|
||||
if (outputIFF && outFilename)
|
||||
return outputIFF->write(outFilename, true);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
#ifndef __OUTPUTFILEHANDLER_H__
|
||||
#define __OUTPUTFILEHANDLER_H__
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// FILENAME: OutputFileHandler.h [C:\Projects\new\tools\src\miff\src\]
|
||||
// COPYRIGHT: (C) 1999 BY Bootprint Entertainment
|
||||
//
|
||||
// DESCRIPTION: file handler for output files (IFF file format)
|
||||
// AUTHOR: Hideki Ikeda
|
||||
// DATE: 1/13/99 4:55:56 PM
|
||||
//
|
||||
// HISTORY: 1/13/99 [HAI] - File created
|
||||
// :
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
//============================================================== #includes ==
|
||||
|
||||
//========================================================= class typedefs ==
|
||||
#include "sharedFile/Iff.h"
|
||||
|
||||
//====================================================== class definitions ==
|
||||
class OutputFileHandler
|
||||
{
|
||||
//------------------------------
|
||||
//--- public var & functions ---
|
||||
//------------------------------
|
||||
public: // functions
|
||||
OutputFileHandler(const char *filename);
|
||||
~OutputFileHandler(void);
|
||||
bool writeBuffer(void);
|
||||
|
||||
void insertForm(const char *tagName);
|
||||
void insertChunk(const char *tagName);
|
||||
void insertChunkData(void *data, int length);
|
||||
void exitForm(void);
|
||||
void exitChunk(void);
|
||||
|
||||
void setCurrentFilename(const char *fname);
|
||||
|
||||
public: // vars
|
||||
|
||||
|
||||
//-------------------------------
|
||||
//--- member vars declaration ---
|
||||
//-------------------------------
|
||||
protected: // vars
|
||||
Iff * outputIFF;
|
||||
char *outFilename;
|
||||
|
||||
enum{
|
||||
MAXIFFDATASIZE = 8192 // allocate 8K of memory for a starter
|
||||
};
|
||||
|
||||
private: // vars
|
||||
|
||||
//-----------------------------------
|
||||
//--- member function declaration ---
|
||||
//-----------------------------------
|
||||
protected: // functions
|
||||
|
||||
private: // functions
|
||||
Tag convertStrToTag(const char *str);
|
||||
|
||||
};
|
||||
|
||||
//===========================================================================
|
||||
//========================================================= inline methods ==
|
||||
//===========================================================================
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//============================================================ End-of-file ==
|
||||
//===========================================================================
|
||||
#else
|
||||
#ifdef DEBUG
|
||||
#pragma message("OutputFileHandler.h included more then once!")
|
||||
#endif
|
||||
#endif // ifndef __H__
|
||||
@@ -0,0 +1,698 @@
|
||||
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
|
||||
#line 3 "bison.simple"
|
||||
|
||||
/* Skeleton output parser for bison,
|
||||
Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* As a special exception, when this file is copied by Bison into a
|
||||
Bison output file, you may use that output file without restriction.
|
||||
This special exception was added by the Free Software Foundation
|
||||
in version 1.24 of Bison. */
|
||||
|
||||
#define MSDOS 1
|
||||
|
||||
#ifndef alloca
|
||||
#ifdef __GNUC__
|
||||
#define alloca __builtin_alloca
|
||||
#else /* not GNU C. */
|
||||
#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
|
||||
#include <alloca.h>
|
||||
#else /* not sparc */
|
||||
#if defined (MSDOS) && !defined (__TURBOC__)
|
||||
#include <malloc.h>
|
||||
#else /* not MSDOS, or __TURBOC__ */
|
||||
#if defined(_AIX)
|
||||
#include <malloc.h>
|
||||
#pragma alloca
|
||||
#else /* not MSDOS, __TURBOC__, or _AIX */
|
||||
#ifdef __hpux
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
void *alloca (unsigned int);
|
||||
};
|
||||
#else /* not __cplusplus */
|
||||
void *alloca ();
|
||||
#endif /* not __cplusplus */
|
||||
#endif /* __hpux */
|
||||
#endif /* not _AIX */
|
||||
#endif /* not MSDOS, or __TURBOC__ */
|
||||
#endif /* not sparc. */
|
||||
#endif /* not GNU C. */
|
||||
#endif /* alloca not defined. */
|
||||
|
||||
#ifdef MSDOS
|
||||
#define alloca(n) malloc(n)
|
||||
#endif
|
||||
|
||||
/* This is the parser code that is written into each bison parser
|
||||
when the %semantic_parser declaration is not specified in the grammar.
|
||||
It was written by Richard Stallman by simplifying the hairy parser
|
||||
used when %semantic_parser is specified. */
|
||||
|
||||
/* Note: there must be only one dollar sign in this file.
|
||||
It is replaced by the list of actions, each action
|
||||
as one case of the switch. */
|
||||
|
||||
#define yyerrok (yyerrstatus = 0)
|
||||
#define yyclearin (yychar = YYEMPTY)
|
||||
#define YYEMPTY -2
|
||||
#define YYEOF 0
|
||||
#define YYACCEPT return(0)
|
||||
#define YYABORT return(1)
|
||||
#define YYERROR goto yyerrlab1
|
||||
/* Like YYERROR except do call yyerror.
|
||||
This remains here temporarily to ease the
|
||||
transition to the new meaning of YYERROR, for GCC.
|
||||
Once GCC version 2 has supplanted version 1, this can go. */
|
||||
#define YYFAIL goto yyerrlab
|
||||
#define YYRECOVERING() (!!yyerrstatus)
|
||||
#define YYBACKUP(token, value) \
|
||||
do \
|
||||
if (yychar == YYEMPTY && yylen == 1) \
|
||||
{ yychar = (token), yylval = (value); \
|
||||
yychar1 = YYTRANSLATE (yychar); \
|
||||
YYPOPSTACK; \
|
||||
goto yybackup; \
|
||||
} \
|
||||
else \
|
||||
{ yyerror ("syntax error: cannot back up"); YYERROR; } \
|
||||
while (0)
|
||||
|
||||
#define YYTERROR 1
|
||||
#define YYERRCODE 256
|
||||
|
||||
#ifndef YYPURE
|
||||
#define YYLEX yylex()
|
||||
#endif
|
||||
|
||||
#ifdef YYPURE
|
||||
#ifdef YYLSP_NEEDED
|
||||
#ifdef YYLEX_PARAM
|
||||
#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
|
||||
#else
|
||||
#define YYLEX yylex(&yylval, &yylloc)
|
||||
#endif
|
||||
#else /* not YYLSP_NEEDED */
|
||||
#ifdef YYLEX_PARAM
|
||||
#define YYLEX yylex(&yylval, YYLEX_PARAM)
|
||||
#else
|
||||
#define YYLEX yylex(&yylval)
|
||||
#endif
|
||||
#endif /* not YYLSP_NEEDED */
|
||||
#endif
|
||||
|
||||
/* If nonreentrant, generate the variables here */
|
||||
|
||||
#ifndef YYPURE
|
||||
|
||||
int yychar; /* the lookahead symbol */
|
||||
YYSTYPE yylval; /* the semantic value of the */
|
||||
/* lookahead symbol */
|
||||
|
||||
#ifdef YYLSP_NEEDED
|
||||
YYLTYPE yylloc; /* location data for the lookahead */
|
||||
/* symbol */
|
||||
#endif
|
||||
|
||||
int yynerrs; /* number of parse errors so far */
|
||||
#endif /* not YYPURE */
|
||||
|
||||
#if YYDEBUG != 0
|
||||
int yydebug = 1; /* nonzero means print parse trace */
|
||||
/* Since this is uninitialized, it does not stop multiple parsers
|
||||
from coexisting. */
|
||||
#endif
|
||||
|
||||
/* YYINITDEPTH indicates the initial size of the parser's stacks */
|
||||
|
||||
#ifndef YYINITDEPTH
|
||||
#define YYINITDEPTH 200
|
||||
#endif
|
||||
|
||||
/* YYMAXDEPTH is the maximum size the stacks can grow to
|
||||
(effective only if the built-in stack extension method is used). */
|
||||
|
||||
#if YYMAXDEPTH == 0
|
||||
#undef YYMAXDEPTH
|
||||
#endif
|
||||
|
||||
#ifndef YYMAXDEPTH
|
||||
#define YYMAXDEPTH 10000
|
||||
#endif
|
||||
|
||||
/* Prevent warning if -Wstrict-prototypes. */
|
||||
#ifdef __GNUC__
|
||||
int yyparse (void);
|
||||
#endif
|
||||
|
||||
#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
|
||||
#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
|
||||
#else /* not GNU C or C++ */
|
||||
#ifndef __cplusplus
|
||||
|
||||
/* This is the most reliable way to avoid incompatibilities
|
||||
in available built-in functions on various systems. */
|
||||
static void
|
||||
__yy_memcpy (to, from, count)
|
||||
char *to;
|
||||
char *from;
|
||||
int count;
|
||||
{
|
||||
register char *f = from;
|
||||
register char *t = to;
|
||||
register int i = count;
|
||||
|
||||
while (i-- > 0)
|
||||
*t++ = *f++;
|
||||
}
|
||||
|
||||
#else /* __cplusplus */
|
||||
|
||||
/* This is the most reliable way to avoid incompatibilities
|
||||
in available built-in functions on various systems. */
|
||||
static void
|
||||
__yy_memcpy (char *to, char *from, int count)
|
||||
{
|
||||
register char *f = from;
|
||||
register char *t = to;
|
||||
register int i = count;
|
||||
|
||||
while (i-- > 0)
|
||||
*t++ = *f++;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#line 196 "bison.simple"
|
||||
|
||||
/* The user can define YYPARSE_PARAM as the name of an argument to be passed
|
||||
into yyparse. The argument should have type void *.
|
||||
It should actually point to an object.
|
||||
Grammar actions can access the variable by casting it
|
||||
to the proper pointer type. */
|
||||
|
||||
#ifdef YYPARSE_PARAM
|
||||
#ifdef __cplusplus
|
||||
#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
|
||||
#define YYPARSE_PARAM_DECL
|
||||
#else /* not __cplusplus */
|
||||
#define YYPARSE_PARAM_ARG YYPARSE_PARAM
|
||||
#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
|
||||
#endif /* not __cplusplus */
|
||||
#else /* not YYPARSE_PARAM */
|
||||
#define YYPARSE_PARAM_ARG
|
||||
#define YYPARSE_PARAM_DECL
|
||||
#endif /* not YYPARSE_PARAM */
|
||||
|
||||
int
|
||||
yyparse(YYPARSE_PARAM_ARG)
|
||||
YYPARSE_PARAM_DECL
|
||||
{
|
||||
register int yystate;
|
||||
register int yyn;
|
||||
register short *yyssp;
|
||||
register YYSTYPE *yyvsp;
|
||||
int yyerrstatus; /* number of tokens to shift before error messages enabled */
|
||||
int yychar1 = 0; /* lookahead token as an internal (translated) token number */
|
||||
|
||||
short yyssa[YYINITDEPTH]; /* the state stack */
|
||||
YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
|
||||
|
||||
short *yyss = yyssa; /* refer to the stacks thru separate pointers */
|
||||
YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
|
||||
|
||||
#ifdef YYLSP_NEEDED
|
||||
YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
|
||||
YYLTYPE *yyls = yylsa;
|
||||
YYLTYPE *yylsp;
|
||||
|
||||
#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
|
||||
#else
|
||||
#define YYPOPSTACK (yyvsp--, yyssp--)
|
||||
#endif
|
||||
|
||||
int yystacksize = YYINITDEPTH;
|
||||
|
||||
#ifdef YYPURE
|
||||
int yychar;
|
||||
YYSTYPE yylval;
|
||||
int yynerrs;
|
||||
#ifdef YYLSP_NEEDED
|
||||
YYLTYPE yylloc;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
YYSTYPE yyval; /* the variable used to return */
|
||||
/* semantic values from the action */
|
||||
/* routines */
|
||||
|
||||
int yylen;
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
fprintf(stderr, "Starting parse\n");
|
||||
#endif
|
||||
|
||||
yystate = 0;
|
||||
yyerrstatus = 0;
|
||||
yynerrs = 0;
|
||||
yychar = YYEMPTY; /* Cause a token to be read. */
|
||||
|
||||
/* Initialize stack pointers.
|
||||
Waste one element of value and location stack
|
||||
so that they stay on the same level as the state stack.
|
||||
The wasted elements are never initialized. */
|
||||
|
||||
yyssp = yyss - 1;
|
||||
yyvsp = yyvs;
|
||||
#ifdef YYLSP_NEEDED
|
||||
yylsp = yyls;
|
||||
#endif
|
||||
|
||||
/* Push a new state, which is found in yystate . */
|
||||
/* In all cases, when you get here, the value and location stacks
|
||||
have just been pushed. so pushing a state here evens the stacks. */
|
||||
yynewstate:
|
||||
|
||||
*++yyssp = yystate;
|
||||
|
||||
if (yyssp >= yyss + yystacksize - 1)
|
||||
{
|
||||
/* Give user a chance to reallocate the stack */
|
||||
/* Use copies of these so that the &'s don't force the real ones into memory. */
|
||||
YYSTYPE *yyvs1 = yyvs;
|
||||
short *yyss1 = yyss;
|
||||
#ifdef YYLSP_NEEDED
|
||||
YYLTYPE *yyls1 = yyls;
|
||||
#endif
|
||||
|
||||
/* Get the current used size of the three stacks, in elements. */
|
||||
int size = yyssp - yyss + 1;
|
||||
|
||||
#ifdef yyoverflow
|
||||
/* Each stack pointer address is followed by the size of
|
||||
the data in use in that stack, in bytes. */
|
||||
#ifdef YYLSP_NEEDED
|
||||
/* This used to be a conditional around just the two extra args,
|
||||
but that might be undefined if yyoverflow is a macro. */
|
||||
yyoverflow("parser stack overflow",
|
||||
&yyss1, size * sizeof (*yyssp),
|
||||
&yyvs1, size * sizeof (*yyvsp),
|
||||
&yyls1, size * sizeof (*yylsp),
|
||||
&yystacksize);
|
||||
#else
|
||||
yyoverflow("parser stack overflow",
|
||||
&yyss1, size * sizeof (*yyssp),
|
||||
&yyvs1, size * sizeof (*yyvsp),
|
||||
&yystacksize);
|
||||
#endif
|
||||
|
||||
yyss = yyss1; yyvs = yyvs1;
|
||||
#ifdef YYLSP_NEEDED
|
||||
yyls = yyls1;
|
||||
#endif
|
||||
#else /* no yyoverflow */
|
||||
/* Extend the stack our own way. */
|
||||
if (yystacksize >= YYMAXDEPTH)
|
||||
{
|
||||
yyerror("parser stack overflow");
|
||||
return 2;
|
||||
}
|
||||
yystacksize *= 2;
|
||||
if (yystacksize > YYMAXDEPTH)
|
||||
yystacksize = YYMAXDEPTH;
|
||||
yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
|
||||
__yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
|
||||
yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
|
||||
__yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
|
||||
#ifdef YYLSP_NEEDED
|
||||
yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
|
||||
__yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
|
||||
#endif
|
||||
#endif /* no yyoverflow */
|
||||
|
||||
yyssp = yyss + size - 1;
|
||||
yyvsp = yyvs + size - 1;
|
||||
#ifdef YYLSP_NEEDED
|
||||
yylsp = yyls + size - 1;
|
||||
#endif
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
fprintf(stderr, "Stack size increased to %d\n", yystacksize);
|
||||
#endif
|
||||
|
||||
if (yyssp >= yyss + yystacksize - 1)
|
||||
YYABORT;
|
||||
}
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
fprintf(stderr, "Entering state %d\n", yystate);
|
||||
#endif
|
||||
|
||||
goto yybackup;
|
||||
yybackup:
|
||||
|
||||
/* Do appropriate processing given the current state. */
|
||||
/* Read a lookahead token if we need one and don't already have one. */
|
||||
/* yyresume: */
|
||||
|
||||
/* First try to decide what to do without reference to lookahead token. */
|
||||
|
||||
yyn = yypact[yystate];
|
||||
if (yyn == YYFLAG)
|
||||
goto yydefault;
|
||||
|
||||
/* Not known => get a lookahead token if don't already have one. */
|
||||
|
||||
/* yychar is either YYEMPTY or YYEOF
|
||||
or a valid token in external form. */
|
||||
|
||||
if (yychar == YYEMPTY)
|
||||
{
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
fprintf(stderr, "Reading a token: ");
|
||||
#endif
|
||||
yychar = YYLEX;
|
||||
}
|
||||
|
||||
/* Convert token to internal form (in yychar1) for indexing tables with */
|
||||
|
||||
if (yychar <= 0) /* This means end of input. */
|
||||
{
|
||||
yychar1 = 0;
|
||||
yychar = YYEOF; /* Don't call YYLEX any more */
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
fprintf(stderr, "Now at end of input.\n");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
yychar1 = YYTRANSLATE(yychar);
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
{
|
||||
fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
|
||||
/* Give the individual parser a way to print the precise meaning
|
||||
of a token, for further debugging info. */
|
||||
#ifdef YYPRINT
|
||||
YYPRINT (stderr, yychar, yylval);
|
||||
#endif
|
||||
fprintf (stderr, ")\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
yyn += yychar1;
|
||||
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
|
||||
goto yydefault;
|
||||
|
||||
yyn = yytable[yyn];
|
||||
|
||||
/* yyn is what to do for this token type in this state.
|
||||
Negative => reduce, -yyn is rule number.
|
||||
Positive => shift, yyn is new state.
|
||||
New state is final state => don't bother to shift,
|
||||
just return success.
|
||||
0, or most negative number => error. */
|
||||
|
||||
if (yyn < 0)
|
||||
{
|
||||
if (yyn == YYFLAG)
|
||||
goto yyerrlab;
|
||||
yyn = -yyn;
|
||||
goto yyreduce;
|
||||
}
|
||||
else if (yyn == 0)
|
||||
goto yyerrlab;
|
||||
|
||||
if (yyn == YYFINAL)
|
||||
YYACCEPT;
|
||||
|
||||
/* Shift the lookahead token. */
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
|
||||
#endif
|
||||
|
||||
/* Discard the token being shifted unless it is eof. */
|
||||
if (yychar != YYEOF)
|
||||
yychar = YYEMPTY;
|
||||
|
||||
*++yyvsp = yylval;
|
||||
#ifdef YYLSP_NEEDED
|
||||
*++yylsp = yylloc;
|
||||
#endif
|
||||
|
||||
/* count tokens shifted since error; after three, turn off error status. */
|
||||
if (yyerrstatus) yyerrstatus--;
|
||||
|
||||
yystate = yyn;
|
||||
goto yynewstate;
|
||||
|
||||
/* Do the default action for the current state. */
|
||||
yydefault:
|
||||
|
||||
yyn = yydefact[yystate];
|
||||
if (yyn == 0)
|
||||
goto yyerrlab;
|
||||
|
||||
/* Do a reduction. yyn is the number of a rule to reduce with. */
|
||||
yyreduce:
|
||||
yylen = yyr2[yyn];
|
||||
if (yylen > 0)
|
||||
yyval = yyvsp[1-yylen]; /* implement default value of the action */
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
{
|
||||
int i;
|
||||
|
||||
fprintf (stderr, "Reducing via rule %d (line %d), ",
|
||||
yyn, yyrline[yyn]);
|
||||
|
||||
/* Print the symbols being reduced, and their result. */
|
||||
for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
|
||||
fprintf (stderr, "%s ", yytname[yyrhs[i]]);
|
||||
fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
|
||||
}
|
||||
#endif
|
||||
|
||||
$ /* the action file gets copied in in place of this dollarsign */
|
||||
#line 498 "bison.simple"
|
||||
|
||||
yyvsp -= yylen;
|
||||
yyssp -= yylen;
|
||||
#ifdef YYLSP_NEEDED
|
||||
yylsp -= yylen;
|
||||
#endif
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
{
|
||||
short *ssp1 = yyss - 1;
|
||||
fprintf (stderr, "state stack now");
|
||||
while (ssp1 != yyssp)
|
||||
fprintf (stderr, " %d", *++ssp1);
|
||||
fprintf (stderr, "\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
*++yyvsp = yyval;
|
||||
|
||||
#ifdef YYLSP_NEEDED
|
||||
yylsp++;
|
||||
if (yylen == 0)
|
||||
{
|
||||
yylsp->first_line = yylloc.first_line;
|
||||
yylsp->first_column = yylloc.first_column;
|
||||
yylsp->last_line = (yylsp-1)->last_line;
|
||||
yylsp->last_column = (yylsp-1)->last_column;
|
||||
yylsp->text = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
yylsp->last_line = (yylsp+yylen-1)->last_line;
|
||||
yylsp->last_column = (yylsp+yylen-1)->last_column;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Now "shift" the result of the reduction.
|
||||
Determine what state that goes to,
|
||||
based on the state we popped back to
|
||||
and the rule number reduced by. */
|
||||
|
||||
yyn = yyr1[yyn];
|
||||
|
||||
yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
|
||||
if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
|
||||
yystate = yytable[yystate];
|
||||
else
|
||||
yystate = yydefgoto[yyn - YYNTBASE];
|
||||
|
||||
goto yynewstate;
|
||||
|
||||
yyerrlab: /* here on detecting error */
|
||||
|
||||
if (! yyerrstatus)
|
||||
/* If not already recovering from an error, report this error. */
|
||||
{
|
||||
++yynerrs;
|
||||
|
||||
#ifdef YYERROR_VERBOSE
|
||||
yyn = yypact[yystate];
|
||||
|
||||
if (yyn > YYFLAG && yyn < YYLAST)
|
||||
{
|
||||
int size = 0;
|
||||
char *msg;
|
||||
int x, count;
|
||||
|
||||
count = 0;
|
||||
/* Start X at -yyn if nec to avoid negative indexes in yycheck. */
|
||||
for (x = (yyn < 0 ? -yyn : 0);
|
||||
x < (sizeof(yytname) / sizeof(char *)); x++)
|
||||
if (yycheck[x + yyn] == x)
|
||||
size += strlen(yytname[x]) + 15, count++;
|
||||
msg = (char *) malloc(size + 15);
|
||||
if (msg != 0)
|
||||
{
|
||||
strcpy(msg, "parse error");
|
||||
|
||||
if (count < 5)
|
||||
{
|
||||
count = 0;
|
||||
for (x = (yyn < 0 ? -yyn : 0);
|
||||
x < (sizeof(yytname) / sizeof(char *)); x++)
|
||||
if (yycheck[x + yyn] == x)
|
||||
{
|
||||
strcat(msg, count == 0 ? ", expecting `" : " or `");
|
||||
strcat(msg, yytname[x]);
|
||||
strcat(msg, "'");
|
||||
count++;
|
||||
}
|
||||
}
|
||||
yyerror(msg);
|
||||
free(msg);
|
||||
}
|
||||
else
|
||||
yyerror ("parse error; also virtual memory exceeded");
|
||||
}
|
||||
else
|
||||
#endif /* YYERROR_VERBOSE */
|
||||
yyerror("parse error");
|
||||
}
|
||||
|
||||
goto yyerrlab1;
|
||||
yyerrlab1: /* here on error raised explicitly by an action */
|
||||
|
||||
if (yyerrstatus == 3)
|
||||
{
|
||||
/* if just tried and failed to reuse lookahead token after an error, discard it. */
|
||||
|
||||
/* return failure if at end of input */
|
||||
if (yychar == YYEOF)
|
||||
YYABORT;
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
|
||||
#endif
|
||||
|
||||
yychar = YYEMPTY;
|
||||
}
|
||||
|
||||
/* Else will try to reuse lookahead token
|
||||
after shifting the error token. */
|
||||
|
||||
yyerrstatus = 3; /* Each real token shifted decrements this */
|
||||
|
||||
goto yyerrhandle;
|
||||
|
||||
yyerrdefault: /* current state does not do anything special for the error token. */
|
||||
|
||||
#if 0
|
||||
/* This is wrong; only states that explicitly want error tokens
|
||||
should shift them. */
|
||||
yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
|
||||
if (yyn) goto yydefault;
|
||||
#endif
|
||||
|
||||
yyerrpop: /* pop the current state because it cannot handle the error token */
|
||||
|
||||
if (yyssp == yyss) YYABORT;
|
||||
yyvsp--;
|
||||
yystate = *--yyssp;
|
||||
#ifdef YYLSP_NEEDED
|
||||
yylsp--;
|
||||
#endif
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
{
|
||||
short *ssp1 = yyss - 1;
|
||||
fprintf (stderr, "Error: state stack now");
|
||||
while (ssp1 != yyssp)
|
||||
fprintf (stderr, " %d", *++ssp1);
|
||||
fprintf (stderr, "\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
yyerrhandle:
|
||||
|
||||
yyn = yypact[yystate];
|
||||
if (yyn == YYFLAG)
|
||||
goto yyerrdefault;
|
||||
|
||||
yyn += YYTERROR;
|
||||
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
|
||||
goto yyerrdefault;
|
||||
|
||||
yyn = yytable[yyn];
|
||||
if (yyn < 0)
|
||||
{
|
||||
if (yyn == YYFLAG)
|
||||
goto yyerrpop;
|
||||
yyn = -yyn;
|
||||
goto yyreduce;
|
||||
}
|
||||
else if (yyn == 0)
|
||||
goto yyerrpop;
|
||||
|
||||
if (yyn == YYFINAL)
|
||||
YYACCEPT;
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
fprintf(stderr, "Shifting error token, ");
|
||||
#endif
|
||||
|
||||
*++yyvsp = yylval;
|
||||
#ifdef YYLSP_NEEDED
|
||||
*++yylsp = yylloc;
|
||||
#endif
|
||||
|
||||
yystate = yyn;
|
||||
goto yynewstate;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
// NOTE: this makes it more convinient for me to make the help screen fancier...
|
||||
// blah... not that anybody cares...
|
||||
|
||||
printf("\
|
||||
Usage:\n\
|
||||
mIFF {-%c <filename>|--%s=<filename>}\n\
|
||||
[{-%c <filename>|--%s=<filename>} | {-%c|--%s}]\n\
|
||||
[{-%c|--%s}] [{-%c|--%s}] [{-%c|--%s}]\n\n",
|
||||
SNAME_INPUT_FILE, LNAME_INPUT_FILE,
|
||||
SNAME_OUTPUT_FILE, LNAME_OUTPUT_FILE,
|
||||
SNAME_PRAGMA_TARGET, LNAME_PRAGMA_TARGET,
|
||||
SNAME_CCCP, LNAME_CCCP,
|
||||
SNAME_VERBOSE, LNAME_VERBOSE,
|
||||
SNAME_DEBUG, LNAME_DEBUG);
|
||||
printf("\
|
||||
mIFF {-%c|--%s}\n\n", SNAME_HELP, LNAME_HELP);
|
||||
|
||||
printf("\
|
||||
Parameters:\n\
|
||||
-%c <filename>,--%s=<filename>\n\
|
||||
[required] specifies the input path for IFF source file.\n", SNAME_INPUT_FILE, LNAME_INPUT_FILE);
|
||||
printf("\
|
||||
-%c <filename>,--%s=<filename>\n\
|
||||
[optional] specifies the pathname for the generated \n\
|
||||
IFF data file. Note that if neither this nor the following \n\
|
||||
option are specified, a default output filename of the source\n\
|
||||
file's base name with extension \".iff\" will be used.\n", SNAME_OUTPUT_FILE, LNAME_OUTPUT_FILE);
|
||||
printf("\
|
||||
-%c,--%s\n\
|
||||
[optional] specifies the generated output filename should be \n\
|
||||
taken from the #pragma options within the source file. \n\
|
||||
Allowable #pragma options are: \n\
|
||||
#pragma drive \"<drive letter>:\"\n\
|
||||
#pragma directory \"<directory name>\"\n\
|
||||
#pragma filename \"<filename>\"\n\
|
||||
#pragma extension \"<extension>\"\n", SNAME_PRAGMA_TARGET, LNAME_PRAGMA_TARGET);
|
||||
printf("\
|
||||
-%c,--%s\n\
|
||||
[optional] use CCCP rather than CPP.\n", SNAME_CCCP, LNAME_CCCP);
|
||||
printf("\
|
||||
-%c,--%s\n\
|
||||
[optional] display more information during execution.\n", SNAME_VERBOSE, LNAME_VERBOSE);
|
||||
printf("\
|
||||
-%c,--%s\n\
|
||||
[optional] enable debug mode (save intermediate files).\n", SNAME_DEBUG, LNAME_DEBUG);
|
||||
printf("\
|
||||
-%c,--%s\n\
|
||||
[very optional] this help screen.\n", SNAME_HELP, LNAME_HELP);
|
||||
printf("\
|
||||
Examples:\n\
|
||||
mIFF -%c foo.bar\n\
|
||||
this will generate an iff file foo.iff (default if no parm specified)\n\
|
||||
in the current working directory. Even if foo.bar contains #pragma, \n\
|
||||
it will create foo.iff because -%c was not specified.\n", SNAME_INPUT_FILE, SNAME_PRAGMA_TARGET);
|
||||
printf("\
|
||||
mIFF -%c \"C:\\my project\\myData\\foo.iff\" --%s=foo.bar\n\
|
||||
notice that if you have space in your dirname, use \" to encapsulate \n\
|
||||
it.\n", SNAME_OUTPUT_FILE, LNAME_INPUT_FILE);
|
||||
printf("\
|
||||
mIFF -%c foo.bar --%s\n\
|
||||
will generate output file specified by #pragma statements \n\
|
||||
within file foo.bar.\n", SNAME_INPUT_FILE, LNAME_PRAGMA_TARGET);
|
||||
@@ -0,0 +1,961 @@
|
||||
//===========================================================================
|
||||
//
|
||||
// FILENAME: mIFF.cpp [C:\Projects\new\tools\src\miff\src\]
|
||||
// COPYRIGHT: (C) 1999 BY Bootprint Entertainment
|
||||
//
|
||||
// DESCRIPTION: make IFF (Console version)
|
||||
// AUTHOR: Hideki Ikeda
|
||||
// DATE: 1/07/99 12:57:20 PM
|
||||
//
|
||||
// HISTORY: 1/07/99 [HAI] - File created
|
||||
// : 1/07/99 [HAI] - v1.0 introductory version
|
||||
// : 1/12/99 [HAI] - v1.1 switched from DOS to Engine library
|
||||
// : - first attempt was to setup the main entry
|
||||
// : point via ConsoleEntryPoint() via callback
|
||||
// : 1/29/99 [HAI] - changed the parameter in MIFFMessage to allow
|
||||
// : output even in non-verbose mode (for error
|
||||
// : message purpose.
|
||||
// : 05/07/99 [HAI]- added MIFFallocString() and MIFFfreeString()
|
||||
// : to work with memory manager. they are allocated
|
||||
// : in the lexical analyzer for IDENTIFIERS and STR_LIT
|
||||
// : deleted after parser parses the rule.
|
||||
//
|
||||
// FUNCTION: main()
|
||||
// : evaluateArgs()
|
||||
// : help()
|
||||
// : handleError()
|
||||
// : preprocessSource()
|
||||
// : MIFFMessage()
|
||||
// : callbackFunction()
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
//========================================================== include files ==
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
|
||||
#include "sharedCompression/SetupSharedCompression.h"
|
||||
#include "sharedDebug/SetupSharedDebug.h"
|
||||
#include "sharedFile/SetupSharedFile.h"
|
||||
#include "sharedFile/TreeFile.h"
|
||||
#include "sharedFoundation/CommandLine.h"
|
||||
#include "sharedFoundation/Crc.h"
|
||||
#include "sharedFoundation/Os.h"
|
||||
#include "sharedFoundation/SetupSharedFoundation.h"
|
||||
#include "sharedMemoryManager/MemoryManager.h"
|
||||
#include "sharedThread/SetupSharedThread.h"
|
||||
|
||||
#include "InputFileHandler.h"
|
||||
#include "OutputFileHandler.h"
|
||||
|
||||
#include <string.h> // for memset()
|
||||
#include <stdio.h> // FILE stuff
|
||||
#include <direct.h> // for getcwd()
|
||||
#include <stdlib.h> // for tolower()
|
||||
#include <process.h> // for system()
|
||||
|
||||
//================================================= static vars assignment ==
|
||||
const int entryPointVersion = 1; // constantly check DataEntryPoint.h to see if this value has changed
|
||||
|
||||
OutputFileHandler *outfileHandler = NULL;
|
||||
const int bufferSize = 16 * 1024 * 1024;
|
||||
const int maxStringSize = 256;
|
||||
const char version[] = "1.3 September 18, 2000";
|
||||
|
||||
// vars set by pragmas or via command line
|
||||
char drive[4]; // should be no more then 2 char "C:"
|
||||
char directory[maxStringSize];
|
||||
char filename[maxStringSize];
|
||||
char extension[8]; // we'll truncate if the extension is more then 8 chars...
|
||||
char inFileName[maxStringSize];
|
||||
|
||||
// switches to be sent to mIFF Compiler
|
||||
char sourceBuffer[bufferSize];
|
||||
char outFileName[(maxStringSize * 2) + 8]; // x2 to combine filename, dir, and ext
|
||||
bool usePragma = false;
|
||||
bool useCCCP = false;
|
||||
bool verboseMode = false; // default to non-verbose mode
|
||||
bool debugMode = false; // set this on and the preprocessed source file (mIFF.$$$) won't be deleted
|
||||
|
||||
static bool runningUnderNT;
|
||||
|
||||
enum errorType {
|
||||
ERR_FILENOTFOUND = -1,
|
||||
ERR_ARGSTOOFEW = -2,
|
||||
ERR_BUFFERTOOSMALL = -3,
|
||||
ERR_UNKNOWNDIR = -4,
|
||||
ERR_PREPROCESS = -5,
|
||||
ERR_MULTIPLEINFILE = -6,
|
||||
ERR_PARSER = -7,
|
||||
ERR_ENGINE = -8,
|
||||
|
||||
ERR_HELPREQUEST = -9,
|
||||
ERR_OPTIONS = -10,
|
||||
|
||||
ERR_WRITEERROR = -11,
|
||||
|
||||
ERR_NONE = 0
|
||||
};
|
||||
char err_msg[512];
|
||||
errorType errorFlag = ERR_NONE; // assume no error (default)
|
||||
|
||||
|
||||
// long and short name definitions for command line options
|
||||
|
||||
static const char * const LNAME_HELP = "help";
|
||||
static const char * const LNAME_INPUT_FILE = "inputfile";
|
||||
static const char * const LNAME_OUTPUT_FILE = "outputfile";
|
||||
static const char * const LNAME_PRAGMA_TARGET = "pragmatarget";
|
||||
static const char * const LNAME_CCCP = "cccp";
|
||||
static const char * const LNAME_VERBOSE = "verbose";
|
||||
static const char * const LNAME_DEBUG = "debug";
|
||||
|
||||
static const char SNAME_HELP = 'h';
|
||||
static const char SNAME_INPUT_FILE = 'i';
|
||||
static const char SNAME_OUTPUT_FILE = 'o';
|
||||
static const char SNAME_PRAGMA_TARGET = 'p';
|
||||
static const char SNAME_CCCP = 'c';
|
||||
static const char SNAME_VERBOSE = 'v';
|
||||
static const char SNAME_DEBUG = 'd';
|
||||
|
||||
// following is the command line option spec tree needed for command line processing
|
||||
static CommandLine::OptionSpec optionSpecArray[] =
|
||||
{
|
||||
OP_BEGIN_SWITCH(OP_NODE_REQUIRED),
|
||||
|
||||
// help
|
||||
OP_SINGLE_SWITCH_NODE(SNAME_HELP, LNAME_HELP, OP_ARG_NONE, OP_MULTIPLE_DENIED),
|
||||
|
||||
// real options
|
||||
OP_BEGIN_SWITCH_NODE(OP_MULTIPLE_DENIED),
|
||||
OP_BEGIN_LIST(),
|
||||
// input filename required
|
||||
OP_SINGLE_LIST_NODE(SNAME_INPUT_FILE, LNAME_INPUT_FILE, OP_ARG_REQUIRED, OP_MULTIPLE_DENIED, OP_NODE_REQUIRED),
|
||||
|
||||
// optional, mutually exclusive output file specification options
|
||||
// if none specified, generate derive output filename from input filename
|
||||
OP_BEGIN_LIST_NODE(OP_MULTIPLE_DENIED, OP_NODE_OPTIONAL),
|
||||
OP_BEGIN_SWITCH(OP_NODE_OPTIONAL),
|
||||
// specify output filename on command line
|
||||
OP_SINGLE_SWITCH_NODE(SNAME_OUTPUT_FILE, LNAME_OUTPUT_FILE, OP_ARG_REQUIRED, OP_MULTIPLE_DENIED),
|
||||
|
||||
// use pragma target for output filename
|
||||
OP_SINGLE_SWITCH_NODE(SNAME_PRAGMA_TARGET, LNAME_PRAGMA_TARGET, OP_ARG_NONE, OP_MULTIPLE_DENIED),
|
||||
OP_END_SWITCH(),
|
||||
OP_END_LIST_NODE(),
|
||||
|
||||
// if specified, use cccp instead of cpp
|
||||
OP_SINGLE_LIST_NODE(SNAME_CCCP, LNAME_CCCP, OP_ARG_NONE, OP_MULTIPLE_DENIED, OP_NODE_OPTIONAL),
|
||||
|
||||
// if specified, be verbose
|
||||
OP_SINGLE_LIST_NODE(SNAME_VERBOSE, LNAME_VERBOSE, OP_ARG_NONE, OP_MULTIPLE_DENIED, OP_NODE_OPTIONAL),
|
||||
|
||||
// if specified, enter debug info
|
||||
OP_SINGLE_LIST_NODE(SNAME_DEBUG, LNAME_DEBUG, OP_ARG_NONE, OP_MULTIPLE_DENIED, OP_NODE_OPTIONAL),
|
||||
OP_END_LIST(),
|
||||
OP_END_SWITCH_NODE(),
|
||||
|
||||
OP_END_SWITCH()
|
||||
};
|
||||
static const int optionSpecCount = sizeof(optionSpecArray) / sizeof(optionSpecArray[0]);
|
||||
|
||||
//================================================= function prototypes ==
|
||||
int main(int argc, char *argv[]);
|
||||
static errorType evaluateArgs(void);
|
||||
static void help(void);
|
||||
static void handleError(errorType error);
|
||||
static int preprocessSource(char *sourceName);
|
||||
static void callbackFunction(void);
|
||||
static errorType loadInputToBuffer(void *destAddr, int maxBufferSize);
|
||||
|
||||
// functions called by parser.yac and parser.lex
|
||||
extern "C" void MIFFMessage(char *msg, int forceOut);
|
||||
extern "C" void MIFFSetError(void);
|
||||
extern "C" void MIFFSetIFFName(const char *newFileName);
|
||||
extern "C" void MIFFinsertForm(const char *formName);
|
||||
extern "C" void MIFFinsertChunk(const char *chunkName);
|
||||
extern "C" void MIFFinsertChunkData(void * buffer, unsigned bufferSize);
|
||||
extern "C" int MIFFloadRawData(char *fname, void * buffer, unsigned maxBufferSize);
|
||||
extern "C" void MIFFexitChunk(void);
|
||||
extern "C" void MIFFexitForm(void);
|
||||
extern "C" unsigned long MIFFgetLabelHash(char *inputStream);
|
||||
|
||||
// external functions found in parser.lex file
|
||||
extern "C" void MIFFCompile(char *inputStream, char *inputFname);
|
||||
extern "C" void MIFFCompileInit(char *inputStream, char *inputFname);
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// main entry point from console call
|
||||
//
|
||||
// Return Value:
|
||||
// errorType - see enumeration; 0 if no errors
|
||||
//
|
||||
// Remarks:
|
||||
//
|
||||
//
|
||||
// See Also:
|
||||
//
|
||||
//
|
||||
// Revisions and History:
|
||||
// 1/07/99 [HAI] - created
|
||||
//
|
||||
int main( int argc, // number of args in commandline
|
||||
char * argv[] // list of pointers to strings
|
||||
)
|
||||
{
|
||||
memset(sourceBuffer, 0, bufferSize);
|
||||
|
||||
SetupSharedThread::install();
|
||||
SetupSharedDebug::install(4096);
|
||||
|
||||
SetupSharedFoundation::Data SetupSharedFoundationData (SetupSharedFoundation::Data::D_console);
|
||||
SetupSharedFoundationData.useWindowHandle = false;
|
||||
SetupSharedFoundationData.argc = argc;
|
||||
SetupSharedFoundationData.argv = argv;
|
||||
SetupSharedFoundationData.demoMode = true;
|
||||
SetupSharedFoundation::install (SetupSharedFoundationData);
|
||||
|
||||
SetupSharedCompression::install();
|
||||
|
||||
SetupSharedFile::install(false);
|
||||
|
||||
TreeFile::addSearchAbsolute(0);
|
||||
TreeFile::addSearchPath (".", 0);
|
||||
|
||||
SetupSharedFoundation::callbackWithExceptionHandling(callbackFunction);
|
||||
SetupSharedFoundation::remove();
|
||||
|
||||
SetupSharedThread::remove();
|
||||
return static_cast<int> (errorFlag);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// callback function for Engine's console entry point
|
||||
//
|
||||
// Return Value:
|
||||
// none
|
||||
//
|
||||
// Remarks:
|
||||
// this is like a substitute of main()
|
||||
//
|
||||
// See Also:
|
||||
//
|
||||
//
|
||||
// Revisions and History:
|
||||
// 1/12/99 [HAI] - created
|
||||
//
|
||||
static void callbackFunction(void)
|
||||
{
|
||||
outfileHandler = NULL;
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
// check if we're running under NT
|
||||
OSVERSIONINFO osInfo;
|
||||
Zero(osInfo);
|
||||
|
||||
osInfo.dwOSVersionInfoSize = sizeof(osInfo);
|
||||
const BOOL getVersionResult = GetVersionEx(&osInfo);
|
||||
if (getVersionResult)
|
||||
runningUnderNT = (osInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
if (runningUnderNT)
|
||||
DEBUG_REPORT_LOG(true, ("MIFF: running under Windows NT platform\n"));
|
||||
else
|
||||
DEBUG_REPORT_LOG(true, ("MIFF: running under non-NT Windows platform\n"));
|
||||
|
||||
#endif
|
||||
|
||||
errorFlag = evaluateArgs();
|
||||
if (ERR_NONE == errorFlag)
|
||||
{
|
||||
outfileHandler = new OutputFileHandler(outFileName);
|
||||
MIFFCompile(sourceBuffer, inFileName);
|
||||
}
|
||||
else
|
||||
handleError(errorFlag);
|
||||
|
||||
if (outfileHandler)
|
||||
{
|
||||
// only write output IF there was no error
|
||||
if (ERR_NONE == errorFlag)
|
||||
{
|
||||
if (!outfileHandler->writeBuffer())
|
||||
{
|
||||
fprintf(stderr, "MIFF: failed to write output file \"%s\"\n", outFileName);
|
||||
errorFlag = ERR_WRITEERROR;
|
||||
}
|
||||
}
|
||||
delete outfileHandler;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Evaluates the command line and sets up the environment variables required for mIFF to function
|
||||
//
|
||||
// Return Value:
|
||||
// errorType
|
||||
//
|
||||
// Remarks:
|
||||
// argc's and argv's are substituted with CommandLine::functions()
|
||||
//
|
||||
// See Also:
|
||||
//
|
||||
//
|
||||
// Revisions and History:
|
||||
// 1/07/99 [HAI] - created
|
||||
//
|
||||
static errorType evaluateArgs(void)
|
||||
{
|
||||
errorType retVal = ERR_NONE;
|
||||
|
||||
// parse the commandline
|
||||
const CommandLine::MatchCode mc = CommandLine::parseOptions(optionSpecArray, optionSpecCount);
|
||||
if (mc != CommandLine::MC_MATCH)
|
||||
{
|
||||
// -TF- add call to retrieve command line error buffer for display (as soon as it is written!)
|
||||
printf("WARNING: usage error detected, printing help.\n");
|
||||
help();
|
||||
return ERR_OPTIONS;
|
||||
}
|
||||
else if (CommandLine::getOccurrenceCount(SNAME_HELP))
|
||||
{
|
||||
// user specified help
|
||||
help();
|
||||
retVal = ERR_HELPREQUEST;
|
||||
return(retVal);
|
||||
}
|
||||
|
||||
// at this point, we can assume a valid combination of options has been specified on the commandline
|
||||
|
||||
|
||||
// setup input filename
|
||||
strcpy(inFileName, CommandLine::getOptionString(SNAME_INPUT_FILE));
|
||||
|
||||
|
||||
// handle output filename spec
|
||||
if (CommandLine::getOccurrenceCount(SNAME_OUTPUT_FILE))
|
||||
{
|
||||
strcpy(outFileName, CommandLine::getOptionString(SNAME_OUTPUT_FILE));
|
||||
}
|
||||
else if (CommandLine::getOccurrenceCount(SNAME_PRAGMA_TARGET))
|
||||
{
|
||||
// use pragma target within iff source for output filename
|
||||
usePragma = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// no output option specified on commandline, derive from input filename
|
||||
char *terminator;
|
||||
|
||||
// start with input file pathname
|
||||
strcpy(outFileName, inFileName);
|
||||
|
||||
// try to terminate at rightmost '.'
|
||||
terminator = strrchr(outFileName, '.');
|
||||
if (terminator)
|
||||
*terminator = 0;
|
||||
|
||||
// append the default iff extension
|
||||
strcat(outFileName, ".iff");
|
||||
}
|
||||
|
||||
|
||||
// handle options (get them out of the way, as we use them later)
|
||||
useCCCP = (CommandLine::getOccurrenceCount(SNAME_CCCP) != 0);
|
||||
verboseMode = (CommandLine::getOccurrenceCount(SNAME_VERBOSE) != 0);
|
||||
debugMode = (CommandLine::getOccurrenceCount(SNAME_DEBUG) != 0);
|
||||
|
||||
|
||||
// preprocess the input file
|
||||
if (0 == preprocessSource(inFileName))
|
||||
{
|
||||
if (verboseMode)
|
||||
{
|
||||
sprintf(err_msg,"Now compiling %s...\n", inFileName);
|
||||
MIFFMessage(err_msg, 0);
|
||||
}
|
||||
if (ERR_NONE == retVal)
|
||||
retVal = loadInputToBuffer(sourceBuffer, bufferSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
// preprocessSource returned an error...
|
||||
retVal = ERR_PREPROCESS;
|
||||
}
|
||||
if (retVal != ERR_NONE)
|
||||
return retVal;
|
||||
|
||||
return retVal;
|
||||
|
||||
#if 0
|
||||
|
||||
errorType retVal = ERR_NONE; // assume no error has been found
|
||||
bool outPathUsed = false; // flag to monitor if -o flag was used, if so, we can ignore -d, -p, -e, -f
|
||||
bool inFileEntered = false;
|
||||
int argc = CommandLine::getPlainCount();
|
||||
|
||||
// get default values from DOS
|
||||
char currentDir[maxStringSize];
|
||||
if (NULL == getcwd(currentDir, maxStringSize)) // get current working directory
|
||||
{
|
||||
retVal = ERR_UNKNOWNDIR;
|
||||
return(retVal);
|
||||
}
|
||||
drive[0] = currentDir[0]; // drive letter
|
||||
drive[1] = 0; // and null terminate it
|
||||
strcpy(extension, "IFF"); // default to uppercase .IFF
|
||||
strcpy(directory, ¤tDir[2]); // get everything after the Drive: including the first backslash
|
||||
filename[0] = 0;
|
||||
|
||||
// see specs.txt for requests
|
||||
// scan for any argv's that has '-' in the argv[n][0]'s character
|
||||
for (int index = 0; index < argc; index++) // note: if using argv[] rather then CommandLine::getPlainString() then start with 1 rather then 0
|
||||
{
|
||||
if ('-' == CommandLine::getPlainString(index)[0])
|
||||
{
|
||||
// we've found a parameter switch
|
||||
switch (tolower(CommandLine::getPlainString(index)[1])) // assume non case sensitive switches
|
||||
{
|
||||
case 'i': // install via #pragma
|
||||
{
|
||||
usePragma = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'c': // use CCCP instead of CPP
|
||||
useCCCP = true;
|
||||
break;
|
||||
|
||||
case 'v': // don't show any debug message
|
||||
verboseMode = true;
|
||||
break;
|
||||
|
||||
case '$':
|
||||
debugMode = true;
|
||||
break;
|
||||
|
||||
case 'o': // target output file name and path (complete path)
|
||||
{
|
||||
index++; // next param
|
||||
outPathUsed = true;
|
||||
strcpy(outFileName, CommandLine::getPlainString(index));
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 'd': // target drive letter (-p must be present)
|
||||
{
|
||||
if (!outPathUsed)
|
||||
{
|
||||
index++; // next param
|
||||
strcpy(drive, CommandLine::getPlainString(index));
|
||||
}
|
||||
else
|
||||
index++; // skip the drive letter arg that SHOULD follow the -d option
|
||||
break;
|
||||
}
|
||||
|
||||
case 'p': // target pathname
|
||||
{
|
||||
if (!outPathUsed)
|
||||
{
|
||||
index++; // next param
|
||||
strcpy(directory, CommandLine::getPlainString(index));
|
||||
}
|
||||
else
|
||||
index++; // skip the pathname arg that follows the -p option
|
||||
break;
|
||||
}
|
||||
|
||||
case 'f': // target filename
|
||||
{
|
||||
if (!outPathUsed)
|
||||
{
|
||||
index++; // next param
|
||||
strcpy(filename, CommandLine::getPlainString(index));
|
||||
}
|
||||
else
|
||||
index++; // skip the filename arg that follows the -f
|
||||
break;
|
||||
}
|
||||
|
||||
case 'e': // target extension
|
||||
{
|
||||
if (!outPathUsed)
|
||||
{
|
||||
index++; // next param
|
||||
strcpy(extension, CommandLine::getPlainString(index));
|
||||
}
|
||||
else
|
||||
index++; // skip the extension arg that follows the -e
|
||||
break;
|
||||
}
|
||||
|
||||
case 'h': // help!
|
||||
case '?':
|
||||
{
|
||||
help();
|
||||
index = argc; // force to exit
|
||||
retVal = ERR_HELPREQUEST;
|
||||
return(retVal); // special case, ONLY time I call return() in the middle of the function (because I check for argc < 2 at the end of the code)
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
sprintf(err_msg, "\nUnknown parameter %s, use -h to seek help...\n", CommandLine::getPlainString(index));
|
||||
MIFFMessage(err_msg, 1);
|
||||
index = argc; // force to exit
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// we found an arg that doesn't start with '-' so let's assume it's a filename
|
||||
if (!inFileEntered)
|
||||
{
|
||||
strcpy(inFileName, CommandLine::getPlainString(index));
|
||||
inFileEntered = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal = ERR_MULTIPLEINFILE;
|
||||
index = argc;
|
||||
}
|
||||
|
||||
// now construct the DEFAULT filename for this file by scanning backwards to front and only extracting the filename (no extension, no path)
|
||||
if (ERR_NONE == retVal)
|
||||
{
|
||||
char sourceName[maxStringSize];
|
||||
strcpy(sourceName, inFileName); // make a duplicate for us to play with
|
||||
for (int strIndex = strlen(sourceName); strIndex > 0; strIndex--)
|
||||
{
|
||||
if ('.' == sourceName[strIndex])
|
||||
sourceName[strIndex] = 0; // put a stopper here... we are assuming that '.' indicates extension! I'm going to assume that the person is just testing me if s/he decides to use filename like "foo.bar.psych" which will truncate to "foo"
|
||||
if ('\\' == sourceName[strIndex])
|
||||
break; // get out, for we've reached the path name...
|
||||
}
|
||||
|
||||
// ok, by here, strIndex should point to either beginning of the string, or where the first '\' was found scanning backwards
|
||||
strcpy(filename, &sourceName[strIndex]); // ta-da-!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (inFileEntered)
|
||||
{
|
||||
if (0 == preprocessSource(inFileName))
|
||||
{
|
||||
if (verboseMode)
|
||||
{
|
||||
// using err_msg as my temp buffer...
|
||||
sprintf(err_msg,"Now compiling %s\n", inFileName);
|
||||
MIFFMessage(err_msg, 0);
|
||||
}
|
||||
|
||||
if (ERR_NONE == retVal)
|
||||
retVal = loadInputToBuffer(sourceBuffer, bufferSize);
|
||||
}
|
||||
else // preprocessSource returned an error...
|
||||
{
|
||||
retVal = ERR_PREPROCESS;
|
||||
}
|
||||
}
|
||||
else // inFileEntered == false
|
||||
{
|
||||
MIFFMessage("Missing input filename in command line!", 1);
|
||||
}
|
||||
|
||||
// construct a outFileName[] based on drive[], directory[], filename[], and extension[]
|
||||
if (!outPathUsed && (ERR_NONE == retVal))
|
||||
{
|
||||
if (inFileName[0]) // make sure the user has entered a input filename
|
||||
sprintf(outFileName,"%s:%s\\%s.%s", drive, directory, filename, extension);
|
||||
}
|
||||
|
||||
if (argc < 1)
|
||||
retVal = ERR_ARGSTOOFEW; // we can do this because we know -h was not entered...
|
||||
|
||||
return(retVal);
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// reads the tmeporary files spit out by CCCP and stuffs the plain text into source buffer
|
||||
//
|
||||
// Return Value:
|
||||
// errorType
|
||||
//
|
||||
// Remarks:
|
||||
//
|
||||
//
|
||||
// See Also:
|
||||
//
|
||||
//
|
||||
// Revisions and History:
|
||||
// 1/14/99 [HAI] - created
|
||||
//
|
||||
static errorType loadInputToBuffer(
|
||||
void * dest, // destination address of where you want the date to be read
|
||||
int maxBufferSize // maximum destination data pool size
|
||||
)
|
||||
{
|
||||
errorType retVal = ERR_NONE;
|
||||
InputFileHandler *inFileHandler = new InputFileHandler("mIFF.$$$");
|
||||
if (inFileHandler)
|
||||
{
|
||||
int sizeRead = inFileHandler->read(dest, maxBufferSize);
|
||||
if (sizeRead >= maxBufferSize)
|
||||
{
|
||||
retVal = ERR_BUFFERTOOSMALL;
|
||||
}
|
||||
else
|
||||
{
|
||||
reinterpret_cast<char *>(dest)[sizeRead] = 0; // so stupid... but if you don't zero-terminate at exact spot, YYInput may chokes because of extra grammer that may exist...
|
||||
}
|
||||
if (!debugMode)
|
||||
inFileHandler->deleteFile("mIFF.$$$", true); // no need for temp file now...
|
||||
|
||||
// we've successfully read the file, now close it...
|
||||
delete inFileHandler;
|
||||
}
|
||||
else // inFileName is NULL
|
||||
{
|
||||
retVal = ERR_FILENOTFOUND;
|
||||
}
|
||||
|
||||
return(retVal);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// help function called by main upon -h switch
|
||||
//
|
||||
// Return Value:
|
||||
// none
|
||||
//
|
||||
// Remarks:
|
||||
// #include's mIFF.dox
|
||||
// make sure to update the version when modified.
|
||||
// Notice that help() does NOT go thru MIFFMessage() because we want it to
|
||||
// print out whether it's verbose mode or not...
|
||||
//
|
||||
// See Also:
|
||||
// mIFF.dox
|
||||
//
|
||||
// Revisions and History:
|
||||
// 1/07/99 [HAI] - created
|
||||
//
|
||||
static void help(void)
|
||||
{
|
||||
printf("\nmIFF v%s (DOS version) - Bootprint Ent. (c) 1999\n", version);
|
||||
printf("Hideki Ikeda\n");
|
||||
#include "mIFF.dox"
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// upon exit from main(), if error has been found, it calls here to inform the user of the type of errors it has encounted.
|
||||
//
|
||||
// Return Value:
|
||||
// none
|
||||
//
|
||||
// Remarks:
|
||||
// use -q switch to suppress error messages - but in shell, return value can be used to determine the handling
|
||||
//
|
||||
// See Also:
|
||||
//
|
||||
//
|
||||
// Revisions and History:
|
||||
// 1/07/99 [HAI] - created
|
||||
//
|
||||
static void handleError(errorType error)
|
||||
{
|
||||
if (ERR_NONE == error)
|
||||
return;
|
||||
|
||||
switch (error)
|
||||
{
|
||||
case ERR_NONE:
|
||||
break;
|
||||
|
||||
case ERR_FILENOTFOUND:
|
||||
MIFFMessage("ERROR: INPUT File not found!\n", 1);
|
||||
break;
|
||||
|
||||
case ERR_ARGSTOOFEW:
|
||||
MIFFMessage("ERROR: Not enough arguments. Use -h for help.\n", 1);
|
||||
break;
|
||||
|
||||
case ERR_BUFFERTOOSMALL:
|
||||
MIFFMessage("ERROR: Internally allocated buffer for reading\nsource code is too small, increase buffer and re-compile\n", 1);
|
||||
break;
|
||||
|
||||
case ERR_UNKNOWNDIR:
|
||||
MIFFMessage("ERROR: Directory unknown...\n", 1);
|
||||
break;
|
||||
|
||||
case ERR_PREPROCESS:
|
||||
MIFFMessage("ERROR: Possible problems running the GNU C Preprocessor.\n", 1);
|
||||
break;
|
||||
|
||||
case ERR_MULTIPLEINFILE:
|
||||
MIFFMessage("ERROR: There can only be ONE inputfile name.\nPerhaps you've forgotten the -o option flag\n", 1);
|
||||
break;
|
||||
|
||||
case ERR_ENGINE:
|
||||
MIFFMessage("ERROR: Engine returned a non-zero value...\n", 1);
|
||||
break;
|
||||
|
||||
case ERR_PARSER:
|
||||
MIFFMessage("ERROR: Parser error\n", 1);
|
||||
break;
|
||||
|
||||
case ERR_HELPREQUEST:
|
||||
break;
|
||||
|
||||
case ERR_OPTIONS:
|
||||
MIFFMessage("ERROR: Failed to handle command line options\n", 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
MIFFMessage("ERROR: Unknown error, you suck!\n", 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// gotta write all these externs because you can't call C++ class based non-static
|
||||
// functions from C... So we will use here as the bridge between the two
|
||||
// languages
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Message output handler called by ALL external "C" functions
|
||||
//
|
||||
// Return Value:
|
||||
// none
|
||||
//
|
||||
// Remarks:
|
||||
// all the messages that are displayed are channeled thru this function. Note the -q quiet mode suppresses all messages.
|
||||
// this is an extern "C" function
|
||||
//
|
||||
// See Also:
|
||||
// yyerror()
|
||||
//
|
||||
// Revisions and History:
|
||||
// 1/07/99 [] - created
|
||||
//
|
||||
extern "C" void MIFFMessage(char *message, // null terminated string to be displayed
|
||||
int forceOutput) // if non-zero, it will print out even in quiet mode (for ERRORs)
|
||||
{
|
||||
if (forceOutput)
|
||||
fprintf(stdout, "%s\n", message);
|
||||
else if (verboseMode)
|
||||
fprintf(stdout, "%s\n", message);
|
||||
OutputDebugString(message);
|
||||
OutputDebugString("\n");
|
||||
}
|
||||
|
||||
// Only call this via parser!!!
|
||||
extern "C" void MIFFSetError(void)
|
||||
{
|
||||
errorFlag = ERR_PARSER;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// validation of the filename passed are legal.
|
||||
//
|
||||
// Return Value:
|
||||
// bool usePragma - whether #pragma is ignored or not
|
||||
//
|
||||
// Remarks:
|
||||
// if -i switch is used then #pragma's are expected
|
||||
// this is an extern "C" function
|
||||
//
|
||||
// See Also:
|
||||
//
|
||||
//
|
||||
// Revisions and History:
|
||||
// 1/07/99 [ ] - created
|
||||
//
|
||||
extern "C" int validateTargetFilename( char *targetFileName, // pointer to where we can store the string filename
|
||||
unsigned maxTargetBufSize // size of the filename string buffer
|
||||
)
|
||||
{
|
||||
if (strlen(outFileName) > maxTargetBufSize)
|
||||
MIFFMessage("Internal error, increase string buffer size in parser.yac and recompile!", 1);
|
||||
|
||||
strcpy(targetFileName, outFileName);
|
||||
|
||||
return(usePragma);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// function calls CCCP or CPP via shell to preprocess the source code for #include's and #define's via C-Compatible Compiler Preprocessor
|
||||
//
|
||||
// Return Value:
|
||||
// shell return value (4DOS is very generous on returning different values, while DOS just returns 0 all the time)
|
||||
//
|
||||
// Remarks:
|
||||
// use -c switch to use CCCP rather then CPP in your search path
|
||||
//
|
||||
// See Also:
|
||||
//
|
||||
//
|
||||
// Revisions and History:
|
||||
// 1/07/99 [ ] - created
|
||||
//
|
||||
static int preprocessSource(char *sourceName)
|
||||
{
|
||||
char shellCommand[512];
|
||||
int retVal = 0;
|
||||
|
||||
memset(shellCommand, 0, sizeof(shellCommand));
|
||||
|
||||
// if (!runningUnderNT)
|
||||
{
|
||||
|
||||
if (verboseMode)
|
||||
MIFFMessage("Preprocessing... via CCCP", 0);
|
||||
|
||||
// CCCP parameters:
|
||||
// -nostdinc -nostdinc++ - do NOT search for standard include directory; without this, your
|
||||
// puter would be just twiddling its thumb because CCCP can't find it...
|
||||
// -pedantic - issue warnings (use pedantic-errors if you want it as errors)
|
||||
// required by the ANSI C standard in certain cases such as comments that
|
||||
// follow the #else/#endif
|
||||
// -dD - output #defines (for the purpose of error msg I parse)
|
||||
// -H - display the name of the header/included files (verbose mode)
|
||||
// -P - originally, I had this... so it won't show the # line_num "filename" ???
|
||||
if (!useCCCP && verboseMode)
|
||||
{
|
||||
sprintf(shellCommand, "cpp.exe -nostdinc -nostdinc++ -pedantic -Wall -dD -H %s mIFF.$$$", sourceName);
|
||||
}
|
||||
else if (!useCCCP && !verboseMode)
|
||||
{
|
||||
sprintf(shellCommand, "cpp.exe -nostdinc -nostdinc++ -pedantic -Wall -dD %s mIFF.$$$", sourceName);
|
||||
}
|
||||
else if (useCCCP && verboseMode)
|
||||
{
|
||||
sprintf(shellCommand, "cccp.exe -nostdinc -nostdinc++ -pedantic -Wall -dD -H %s mIFF.$$$", sourceName);
|
||||
}
|
||||
else
|
||||
sprintf(shellCommand, "cccp.exe -nostdinc -nostdinc++ -pedantic -Wall -dD %s mIFF.$$$", sourceName);
|
||||
}
|
||||
// else
|
||||
{
|
||||
// running under NT. Use the MSVC cl since it deals with long filenames on fat16/fat32 partitions correctly
|
||||
// and ccp and cccp don't
|
||||
// sprintf(shellCommand, "cl /nologo /W4 /EP %s > mIFF.$$$", sourceName);
|
||||
}
|
||||
|
||||
retVal = system(shellCommand);
|
||||
if (2 == retVal) // actually, I think 4DOS reports 2 for cannot find file, but DOS returns a 0...
|
||||
{
|
||||
REPORT_LOG(true, ("failed to execute following shell command (%d):\n", retVal));
|
||||
REPORT_LOG(true, (" %s\n", shellCommand));
|
||||
MIFFMessage("\n\nERROR: Cannot find preprocessor (either CCCP.EXE, CPP.EXE or CL.EXE (under NT) in the search path...\n", 1);
|
||||
MIFFMessage("Please make sure the preprocessor is in your search path!\n", 1);
|
||||
}
|
||||
return(retVal);
|
||||
}
|
||||
|
||||
extern "C" void MIFFSetIFFName(const char *newFileName)
|
||||
{
|
||||
if (ERR_NONE != errorFlag)
|
||||
return;
|
||||
|
||||
if (outfileHandler)
|
||||
outfileHandler->setCurrentFilename(newFileName);
|
||||
}
|
||||
|
||||
extern "C" void MIFFinsertForm(const char *formName)
|
||||
{
|
||||
if (ERR_NONE != errorFlag)
|
||||
return;
|
||||
|
||||
if (outfileHandler)
|
||||
outfileHandler->insertForm(formName);
|
||||
}
|
||||
|
||||
extern "C" void MIFFinsertChunk(const char *chunkName)
|
||||
{
|
||||
if (ERR_NONE != errorFlag)
|
||||
return;
|
||||
|
||||
if (outfileHandler)
|
||||
outfileHandler->insertChunk(chunkName);
|
||||
}
|
||||
|
||||
extern "C" void MIFFinsertChunkData(void * buffer, unsigned bufferSize)
|
||||
{
|
||||
if (ERR_NONE != errorFlag)
|
||||
return;
|
||||
|
||||
if (outfileHandler)
|
||||
outfileHandler->insertChunkData(buffer, bufferSize);
|
||||
}
|
||||
|
||||
extern "C" int MIFFloadRawData(char *fname, void * buffer, unsigned maxBufferSize)
|
||||
{
|
||||
int sizeRead = -1;
|
||||
|
||||
if (ERR_NONE != errorFlag)
|
||||
return(sizeRead); // should be -1
|
||||
|
||||
InputFileHandler * inFileName = new InputFileHandler(fname);
|
||||
if (inFileName)
|
||||
{
|
||||
sizeRead = inFileName->read(buffer, maxBufferSize);
|
||||
if (static_cast<unsigned>(sizeRead) >= maxBufferSize)
|
||||
{
|
||||
handleError(ERR_BUFFERTOOSMALL);
|
||||
sizeRead = -1;
|
||||
}
|
||||
delete inFileName;
|
||||
}
|
||||
|
||||
return(sizeRead);
|
||||
}
|
||||
|
||||
extern "C" void MIFFexitChunk(void)
|
||||
{
|
||||
if (ERR_NONE != errorFlag)
|
||||
return;
|
||||
|
||||
if (outfileHandler)
|
||||
outfileHandler->exitChunk();
|
||||
}
|
||||
extern "C" void MIFFexitForm(void)
|
||||
{
|
||||
if (ERR_NONE != errorFlag)
|
||||
return;
|
||||
|
||||
if (outfileHandler)
|
||||
outfileHandler->exitForm();
|
||||
}
|
||||
|
||||
extern "C" char * MIFFallocString(int sizeOfString)
|
||||
{
|
||||
return(new char[sizeOfString]);
|
||||
}
|
||||
|
||||
extern "C" void MIFFfreeString(char * pointer)
|
||||
{
|
||||
delete [] pointer;
|
||||
}
|
||||
|
||||
extern "C" unsigned long MIFFgetLabelHash(char * inputStream)
|
||||
{
|
||||
return (unsigned long)Crc::calculate(inputStream);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//============================================================ End-of-file ==
|
||||
//===========================================================================
|
||||
|
||||
@@ -0,0 +1,517 @@
|
||||
%option full
|
||||
|
||||
%{
|
||||
/*-----------------------------------------------------------------------------**
|
||||
** FILE: parser.lex **
|
||||
** (c) 1998 - Bootprint GTInteractive **
|
||||
** **
|
||||
** DESCRIPTION: lexical analyzer for mIFF **
|
||||
** **
|
||||
** AUTHOR: Hideki Ikeda **
|
||||
** **
|
||||
** HISTORY: **
|
||||
** **
|
||||
** Notes: companion to parser.yac **
|
||||
**-----------------------------------------------------------------------------*/
|
||||
/* Disable compiler warnings (we want warning level 4) for anything that flex spits out */
|
||||
#pragma warning (disable: 4127) /* conditional expression is constant - ie. while(1) */
|
||||
#pragma warning (disable: 4131) /* usage of old-style declarator */
|
||||
#pragma warning (disable: 4098) /* void function returning a vlue - this is because yyterminate() is defined as return() */
|
||||
#pragma warning (disable: 4505) /* unreferenced local function has been removed (to be direct: yyunput()) */
|
||||
|
||||
/* include files */
|
||||
#include "parser.h" /* NOTE: make sure this matches what Bison/yacc spits out */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/*--------------------------------**
|
||||
** exteranl prototype declaration **
|
||||
**--------------------------------*/
|
||||
void MIFFMessage(char *message, int forceOutput);
|
||||
void MIFFSetError(void);
|
||||
char * MIFFallocString(int sizeOfString);
|
||||
void MIFFfreeString(char * pointer);
|
||||
|
||||
int yyparse();
|
||||
|
||||
/* prototype declaration */
|
||||
int MIFFYYInput(char *buf,int max_size);
|
||||
void initParser(void);
|
||||
void count(void);
|
||||
void yyerror(char *err);
|
||||
void open_brace(void);
|
||||
void close_brace(void);
|
||||
int count_brace(void);
|
||||
|
||||
void printString(char *str);
|
||||
|
||||
/* global vars that has to be pre-declared because it's referenced by the lexical analyzer */
|
||||
int initialCompile = 0;
|
||||
int globalErrorFlag = 0;
|
||||
char inFileName[512]; /* keep track of source file name for error message */
|
||||
|
||||
#undef YY_INPUT
|
||||
#define YY_INPUT(buf,result,max_size) (result = MIFFYYInput(buf,max_size))
|
||||
|
||||
#define SPACE_COUNT_FOR_TAB (8)
|
||||
|
||||
%}
|
||||
|
||||
DIGIT [0-9]
|
||||
HEXDIGIT [0-9a-fA-F]
|
||||
LETTER [A-z_]
|
||||
FLOATSYM (f|F|l|L)
|
||||
INTSYM (u|U|l|L)*
|
||||
EXP (e|E)(\+|-)?
|
||||
|
||||
%%
|
||||
"//"[^\n]*\n {
|
||||
/* don't do count(); */
|
||||
}
|
||||
|
||||
"#define"[^\n]*\n {
|
||||
/* don't you love regular expression? [^\n]* everything but \n, and then end with \n */
|
||||
/* don't do count(); just like comments */
|
||||
/* return(DEFINE); <-- note: #define's are ignored in parser for they are handled via preprocessors CCCP */
|
||||
}
|
||||
|
||||
\"([^\"]|(\\\"))*\" {
|
||||
/* start with " then ( [^\"] | (\\\") )* which means either anything but " OR \" of multiple encounter, and then close with " */
|
||||
/* case for "string" literals */
|
||||
char *s; // allocate space for string and pass the string pointer rather then yytext
|
||||
|
||||
count();
|
||||
s = MIFFallocString(strlen(yytext) + 1);
|
||||
strcpy(s, yytext+1); /* strip off the double quotes */
|
||||
s[strlen(yytext+1)-1] = 0; /* strip off the ending double quotes */
|
||||
yylval.stype = s;
|
||||
return(STR_LIT);
|
||||
}
|
||||
|
||||
"form" |
|
||||
"FORM" {
|
||||
count();
|
||||
return(FORM);
|
||||
}
|
||||
|
||||
"chunk" |
|
||||
"CHUNK" {
|
||||
count();
|
||||
return(CHUNK);
|
||||
}
|
||||
|
||||
"int32" {
|
||||
count();
|
||||
return(INT32);
|
||||
}
|
||||
"int16" {
|
||||
count();
|
||||
return(INT16);
|
||||
}
|
||||
"int8" {
|
||||
count();
|
||||
return(INT8);
|
||||
}
|
||||
"uint32" {
|
||||
count();
|
||||
return(UINT32);
|
||||
}
|
||||
"uint16" {
|
||||
count();
|
||||
return(UINT16);
|
||||
}
|
||||
"uint8" {
|
||||
count();
|
||||
return(UINT8);
|
||||
}
|
||||
"float" {
|
||||
count();
|
||||
return(FLOAT);
|
||||
}
|
||||
"double" {
|
||||
count();
|
||||
return(DOUBLE);
|
||||
}
|
||||
"string" |
|
||||
"cstring" |
|
||||
"CString" {
|
||||
count();
|
||||
return(STRING);
|
||||
}
|
||||
"wstring" |
|
||||
"WString" {
|
||||
count();
|
||||
return(WSTRING);
|
||||
}
|
||||
"labelhash" {
|
||||
count();
|
||||
return(LABELHASH);
|
||||
}
|
||||
|
||||
"sin" {
|
||||
count();
|
||||
return(SIN);
|
||||
}
|
||||
"cos" {
|
||||
count();
|
||||
return(COS);
|
||||
}
|
||||
"tan" {
|
||||
count();
|
||||
return(TAN);
|
||||
}
|
||||
"asin" {
|
||||
count();
|
||||
return(ASIN);
|
||||
}
|
||||
"acos" {
|
||||
count();
|
||||
return(ACOS);
|
||||
}
|
||||
"atan" {
|
||||
count();
|
||||
return(ATAN);
|
||||
}
|
||||
|
||||
"enum" {
|
||||
count();
|
||||
return(ENUMSTRUCT);
|
||||
}
|
||||
|
||||
"includeIFF" |
|
||||
"includeiff" {
|
||||
count();
|
||||
return(INCLUDEIFF);
|
||||
}
|
||||
"include" {
|
||||
count();
|
||||
return(INCLUDEBIN);
|
||||
}
|
||||
"#include" {
|
||||
count();
|
||||
return(INCLUDESOURCE);
|
||||
}
|
||||
"#pragma" {
|
||||
count();
|
||||
return(PRAGMA);
|
||||
}
|
||||
"drive" {
|
||||
count();
|
||||
return(PRAGMA_DRIVE);
|
||||
}
|
||||
"directory" {
|
||||
count();
|
||||
return(PRAGMA_DIR);
|
||||
}
|
||||
"filename" {
|
||||
count();
|
||||
return(PRAGMA_FNAME);
|
||||
}
|
||||
"extension" {
|
||||
count();
|
||||
return(PRAGMA_EXT);
|
||||
}
|
||||
|
||||
{LETTER}({LETTER}|{DIGIT})* {
|
||||
/* label identifiers */
|
||||
char *s; // allocate space for string and pass the string pointer rather then yytext
|
||||
|
||||
count();
|
||||
s = MIFFallocString(strlen(yytext) + 1);
|
||||
strcpy(s, yytext);
|
||||
yylval.stype = s;
|
||||
return(IDENTIFIER);
|
||||
}
|
||||
|
||||
{DIGIT}*"."{DIGIT}+{FLOATSYM}? {
|
||||
/* handle numericals (floats) */
|
||||
/*
|
||||
* {DIGIT}*"."{DIGIT}+{FLOATSYM}? means zero or more digits . one or more digit and with/without f at the end
|
||||
*/
|
||||
count();
|
||||
/* make sure to store it to dtype, and use strtod to convert to double */
|
||||
yylval.dtype = strtod((char *) yytext, (char **) 0);
|
||||
return(FLOAT_LIT);
|
||||
}
|
||||
|
||||
0[xX]{HEXDIGIT}+{INTSYM}? |
|
||||
0{DIGIT}+{INTSYM}? |
|
||||
{DIGIT}+{INTSYM}? {
|
||||
/* handle numericals ( hex, ints) */
|
||||
/*
|
||||
* 0[xX]{HEXDIGIT}+{INTSYM}? means start with 0, then X one or more digit and you can put int symbol if you want
|
||||
* 0{DIGIT}+{INTSYM}? means start with 0, one ore more digit and w/or w/o int symbol
|
||||
* {DIGIT}+{INTSYM}? means one or more digit and w/or w/o int symbol
|
||||
*/
|
||||
count();
|
||||
/* make sure to store it to ltype (long), and use strtod to convert to unsigned long */
|
||||
yylval.ltype = strtoul((char *) yytext, (char **) 0, 0);
|
||||
return(LIT);
|
||||
}
|
||||
|
||||
'(\\.|[^\\'])+' {
|
||||
/* handle 'x' - single character */
|
||||
count();
|
||||
yylval.chtype = yytext[1];
|
||||
return(CHAR_LIT);
|
||||
}
|
||||
|
||||
"#" {
|
||||
/* #'s are used for informing the parser which file and line number it is processing (debug purpose) */
|
||||
count();
|
||||
return(POUND);
|
||||
}
|
||||
|
||||
">>" {
|
||||
count();
|
||||
return(SHIFTRIGHT);
|
||||
}
|
||||
"<<" {
|
||||
count();
|
||||
return(SHIFTLEFT);
|
||||
}
|
||||
"^^" {
|
||||
count();
|
||||
return(RAISEDPOWER);
|
||||
}
|
||||
|
||||
"[" |
|
||||
"]" |
|
||||
"^" |
|
||||
";" |
|
||||
"," |
|
||||
":" |
|
||||
"=" |
|
||||
"(" |
|
||||
")" |
|
||||
"." |
|
||||
"&" |
|
||||
"!" |
|
||||
"~" |
|
||||
"-" |
|
||||
"+" |
|
||||
"*" |
|
||||
"/" |
|
||||
"%" |
|
||||
"<" |
|
||||
">" |
|
||||
"|" |
|
||||
"?" {
|
||||
/* valid operators */
|
||||
count();
|
||||
yylval.stype = yytext;
|
||||
return(* yylval.stype);
|
||||
}
|
||||
|
||||
"{" {
|
||||
count();
|
||||
open_brace();
|
||||
yylval.stype = yytext;
|
||||
return(* yylval.stype);
|
||||
}
|
||||
"}" {
|
||||
count();
|
||||
close_brace();
|
||||
yylval.stype = yytext;
|
||||
return(* yylval.stype);
|
||||
}
|
||||
|
||||
[ \t\n\r]+ {
|
||||
/* white spaces and newlines are ignored */
|
||||
count();
|
||||
}
|
||||
|
||||
<<EOF>> {
|
||||
/* do a count on bracket matching... */
|
||||
if (0 == count_brace())
|
||||
{
|
||||
if (!initialCompile && !globalErrorFlag)
|
||||
MIFFMessage("mIFF successfully compiled!\n", 0);
|
||||
}
|
||||
|
||||
yyterminate(); /* tell yyparse() it's time to quit! DO NOT comment or delete this line! */
|
||||
}
|
||||
|
||||
. {
|
||||
/* anything that's not a rule from above goes here */
|
||||
count();
|
||||
yyerror((char *) yytext);
|
||||
}
|
||||
%%
|
||||
|
||||
/*--------------------**
|
||||
** C supporting codes **
|
||||
**--------------------*/
|
||||
|
||||
/*------------------**
|
||||
** static variables **
|
||||
**------------------*/
|
||||
static char *MIFFInputStream;
|
||||
int column = 0;
|
||||
int line_num = 1;
|
||||
int line_num2 = 1;
|
||||
char error_line_buffer[4096];
|
||||
long brace_counter = 0;
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------**
|
||||
** Initialize all the static variables before all calls to MIFFCompile **
|
||||
**---------------------------------------------------------------------*/
|
||||
void initParser(void)
|
||||
{
|
||||
line_num = 1;
|
||||
column = 0;
|
||||
|
||||
brace_counter = 0;
|
||||
error_line_buffer[0] = 0;
|
||||
|
||||
globalErrorFlag = 0;
|
||||
|
||||
memset(inFileName, 0, 512); /* make sure to change this size if the char array gets bigger... */
|
||||
}
|
||||
|
||||
/*-------------------------------------------------**
|
||||
** generate a dialog box to MFC to report an error **
|
||||
**-------------------------------------------------*/
|
||||
void yyerror(char *err) /* called by yyparse() */
|
||||
{
|
||||
char myString[256];
|
||||
|
||||
if (!initialCompile)
|
||||
{
|
||||
/* spit it out in MSDev error format */
|
||||
sprintf(myString, "\n%s(%d) : yyERROR : %s\n>>%s<<", inFileName, line_num, err, error_line_buffer);
|
||||
MIFFMessage(myString, 1);
|
||||
globalErrorFlag = 1;
|
||||
MIFFSetError(); /* set global error flag for shell as well */
|
||||
yyterminate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*-------------------------**
|
||||
** our version of YY_INPUT **
|
||||
**-------------------------*/
|
||||
int MIFFYYInput(char *buf,int max_size)
|
||||
{
|
||||
int len = strlen(MIFFInputStream);
|
||||
int n = max_size < len ? max_size : len;
|
||||
if (n > 0)
|
||||
{
|
||||
memcpy(buf,MIFFInputStream,n);
|
||||
MIFFInputStream += n;
|
||||
}
|
||||
return(n);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------**
|
||||
** line and column counter for error searching during compile **
|
||||
**------------------------------------------------------------*/
|
||||
void count()
|
||||
{
|
||||
int i;
|
||||
static char *elb = error_line_buffer;
|
||||
for (i = 0; yytext[i] != '\0'; i++)
|
||||
{
|
||||
if (yytext[i] == '\n')
|
||||
{
|
||||
column = 0;
|
||||
line_num++;
|
||||
elb = error_line_buffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
*elb++ = yytext[i];
|
||||
if (yytext[i] == '\t')
|
||||
column += SPACE_COUNT_FOR_TAB - (column & (SPACE_COUNT_FOR_TAB - 1));
|
||||
else
|
||||
column++;
|
||||
}
|
||||
*elb = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------**
|
||||
** sets up current line number and filename the error came from **
|
||||
**--------------------------------------------------------------*/
|
||||
void setCurrentLineNumber(int lineNum, char * fileName, int mysteryNum)
|
||||
{
|
||||
line_num = lineNum;
|
||||
strcpy(inFileName, fileName);
|
||||
line_num2 = mysteryNum;
|
||||
}
|
||||
|
||||
/*----------------------------------------------**
|
||||
** MIFFCompile called by CMIFFView::OnCompile() **
|
||||
**----------------------------------------------*/
|
||||
void MIFFCompile(char *inputStream, char *inputFileName)
|
||||
{
|
||||
MIFFInputStream = inputStream;
|
||||
yyrestart(0);
|
||||
initParser();
|
||||
initialCompile = 0;
|
||||
strcpy(inFileName, inputFileName);
|
||||
yyparse();
|
||||
}
|
||||
|
||||
void MIFFCompileInit(char *inputStream, char *inputFileName)
|
||||
{
|
||||
MIFFInputStream = inputStream;
|
||||
yyrestart(0);
|
||||
initParser();
|
||||
initialCompile = 1;
|
||||
strcpy(inFileName, inputFileName);
|
||||
yyparse();
|
||||
}
|
||||
|
||||
/*---------------------------------------**
|
||||
** matching of open/close brace checking **
|
||||
**---------------------------------------*/
|
||||
void open_brace(void)
|
||||
{
|
||||
brace_counter++;
|
||||
}
|
||||
|
||||
void close_brace(void)
|
||||
{
|
||||
brace_counter--;
|
||||
}
|
||||
|
||||
/*
|
||||
* what: count_brace():
|
||||
* return: 0 == all braces matched
|
||||
*/
|
||||
int count_brace(void)
|
||||
{
|
||||
if (0 == brace_counter) /* things are fine... */
|
||||
return(0);
|
||||
|
||||
/* if this is called, we should have 0 brace counter if not, we have a mis-match*/
|
||||
if (brace_counter > 0)
|
||||
{
|
||||
/* a mismatch */
|
||||
yyerror("There are more OPEN brackets then closed");
|
||||
}
|
||||
else if (brace_counter < 0)
|
||||
{
|
||||
yyerror("There are more CLOSED brackets then open");
|
||||
}
|
||||
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------**
|
||||
** FLEX.SLK requires this prototype function so I'm forced to do this... **
|
||||
**-----------------------------------------------------------------------*/
|
||||
int yywrap()
|
||||
{
|
||||
return(1);
|
||||
}
|
||||
|
||||
void printString(char *str)
|
||||
{
|
||||
char ts[256];
|
||||
sprintf(ts, "%s - %s", str, yytext);
|
||||
MIFFMessage(ts, 0);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Regular → Executable
+3
@@ -154,6 +154,7 @@ include_directories(
|
||||
${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/platform/projects
|
||||
${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/platform/utils
|
||||
${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/udplibrary
|
||||
${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/webAPI
|
||||
)
|
||||
|
||||
add_executable(CentralServer
|
||||
@@ -190,5 +191,7 @@ target_link_libraries(CentralServer
|
||||
localizationArchive
|
||||
unicode
|
||||
unicodeArchive
|
||||
webAPI
|
||||
${CURL_LIBRARIES}
|
||||
${CMAKE_DL_LIBS}
|
||||
)
|
||||
|
||||
@@ -35,7 +35,7 @@ void AuctionTransferClient::addCoinToAuction( const ExchangeListCreditsMessage&
|
||||
// 2bi. if user connected: send VeAuctionCoinReply (with result code) to user's ES
|
||||
// 2bii. if user not connected: send immediate abort back to auction service
|
||||
|
||||
const unsigned uTrack = getNewTransactionID( NULL );
|
||||
const unsigned uTrack = getNewTransactionID( nullptr );
|
||||
|
||||
AuctionAssetDetails &details = m_mPendingRequestDetails[ uTrack ];
|
||||
details.u8Type = AuctionAssetDetails::TYPE_COIN;
|
||||
|
||||
+217
-222
@@ -13,260 +13,255 @@
|
||||
using namespace std;
|
||||
|
||||
#ifdef EXTERNAL_DISTRO
|
||||
namespace NAMESPACE
|
||||
namespace NAMESPACE
|
||||
{
|
||||
|
||||
#endif
|
||||
|
||||
//----------------------------------------
|
||||
ServerTrackObject::ServerTrackObject(unsigned mapped_track, unsigned real_track, GenericConnection *con)
|
||||
: m_mappedTrack(mapped_track), m_realTrack(real_track), m_connection(con)
|
||||
//----------------------------------------
|
||||
{
|
||||
}
|
||||
//----------------------------------------
|
||||
ServerTrackObject::ServerTrackObject(unsigned mapped_track, unsigned real_track, GenericConnection *con)
|
||||
: m_mappedTrack(mapped_track), m_realTrack(real_track), m_connection(con)
|
||||
//----------------------------------------
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
GenericAPICore::GenericAPICore(const char *host,
|
||||
short port,
|
||||
unsigned reqTimeout,
|
||||
unsigned reconnectTimeout,
|
||||
unsigned noDataTimeoutSecs,
|
||||
unsigned noAckTimeoutSecs,
|
||||
unsigned incomingBufSizeInKB,
|
||||
unsigned outgoingBufSizeInKB,
|
||||
unsigned keepAlive,
|
||||
unsigned maxRecvMessageSizeInKB)
|
||||
: m_currTrack(0),
|
||||
m_reconnectTimeout(0),
|
||||
m_outCount(0),
|
||||
m_pendingCount(0),
|
||||
m_requestTimeout(reqTimeout),
|
||||
m_currentConnections(0), m_maxConnections(0),
|
||||
m_suspended(false),
|
||||
m_nextConnectionIndex(0)
|
||||
//----------------------------------------
|
||||
{
|
||||
GenericConnection *con = new GenericConnection(host, port, this, reconnectTimeout, noDataTimeoutSecs, noAckTimeoutSecs, incomingBufSizeInKB, outgoingBufSizeInKB, keepAlive, maxRecvMessageSizeInKB);
|
||||
m_serverConnections.push_back(con);
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
GenericAPICore::GenericAPICore(const char *game, const char *hosts[],
|
||||
const short port[],
|
||||
unsigned arraySize,
|
||||
unsigned reqTimeout,
|
||||
unsigned reconnectTimeout,
|
||||
unsigned noDataTimeoutSecs,
|
||||
unsigned noAckTimeoutSecs,
|
||||
unsigned incomingBufSizeInKB,
|
||||
unsigned outgoingBufSizeInKB,
|
||||
unsigned keepAlive,
|
||||
unsigned maxRecvMessageSizeInKB)
|
||||
: m_currTrack(0),
|
||||
m_reconnectTimeout(0),
|
||||
m_outCount(0),
|
||||
m_pendingCount(0),
|
||||
m_requestTimeout(reqTimeout),
|
||||
m_currentConnections(0), m_maxConnections(0),
|
||||
m_suspended(false),
|
||||
m_nextConnectionIndex(0),
|
||||
m_game(game)
|
||||
//----------------------------------------
|
||||
{
|
||||
for (unsigned i=0; i<arraySize; i++)
|
||||
{
|
||||
GenericConnection *con = new GenericConnection(hosts[i], port[i], this, reconnectTimeout, noDataTimeoutSecs, noAckTimeoutSecs, incomingBufSizeInKB, outgoingBufSizeInKB, keepAlive, maxRecvMessageSizeInKB);
|
||||
//----------------------------------------
|
||||
GenericAPICore::GenericAPICore(const char *host,
|
||||
short port,
|
||||
unsigned reqTimeout,
|
||||
unsigned reconnectTimeout,
|
||||
unsigned noDataTimeoutSecs,
|
||||
unsigned noAckTimeoutSecs,
|
||||
unsigned incomingBufSizeInKB,
|
||||
unsigned outgoingBufSizeInKB,
|
||||
unsigned keepAlive,
|
||||
unsigned maxRecvMessageSizeInKB)
|
||||
: m_currTrack(0),
|
||||
m_reconnectTimeout(0),
|
||||
m_outCount(0),
|
||||
m_pendingCount(0),
|
||||
m_requestTimeout(reqTimeout),
|
||||
m_currentConnections(0), m_maxConnections(0),
|
||||
m_suspended(false),
|
||||
m_nextConnectionIndex(0)
|
||||
//----------------------------------------
|
||||
{
|
||||
GenericConnection *con = new GenericConnection(host, port, this, reconnectTimeout, noDataTimeoutSecs, noAckTimeoutSecs, incomingBufSizeInKB, outgoingBufSizeInKB, keepAlive, maxRecvMessageSizeInKB);
|
||||
m_serverConnections.push_back(con);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------
|
||||
GenericAPICore::~GenericAPICore()
|
||||
//----------------------------------------
|
||||
{
|
||||
for (std::vector<GenericConnection *>::iterator conIter = m_serverConnections.begin(); conIter != m_serverConnections.end(); conIter++)
|
||||
{
|
||||
GenericConnection *con = *conIter;
|
||||
delete con;
|
||||
}
|
||||
m_serverConnections.clear();
|
||||
|
||||
for(map<unsigned, GenericResponse *>::iterator iter = m_pending.begin(); iter != m_pending.end(); ++iter)
|
||||
{
|
||||
delete (*iter).second;
|
||||
}
|
||||
|
||||
m_pending.empty();
|
||||
|
||||
while(m_outCount > 0)
|
||||
//----------------------------------------
|
||||
GenericAPICore::GenericAPICore(const char *game, const char *hosts[],
|
||||
const short port[],
|
||||
unsigned arraySize,
|
||||
unsigned reqTimeout,
|
||||
unsigned reconnectTimeout,
|
||||
unsigned noDataTimeoutSecs,
|
||||
unsigned noAckTimeoutSecs,
|
||||
unsigned incomingBufSizeInKB,
|
||||
unsigned outgoingBufSizeInKB,
|
||||
unsigned keepAlive,
|
||||
unsigned maxRecvMessageSizeInKB)
|
||||
: m_currTrack(0),
|
||||
m_reconnectTimeout(0),
|
||||
m_outCount(0),
|
||||
m_pendingCount(0),
|
||||
m_requestTimeout(reqTimeout),
|
||||
m_currentConnections(0), m_maxConnections(0),
|
||||
m_suspended(false),
|
||||
m_nextConnectionIndex(0),
|
||||
m_game(game)
|
||||
//----------------------------------------
|
||||
{
|
||||
delete m_outboundQueue.front().second;
|
||||
delete m_outboundQueue.front().first;
|
||||
m_outboundQueue.pop();
|
||||
--m_outCount;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
unsigned GenericAPICore::submitRequest(GenericRequest *req, GenericResponse *res)
|
||||
//----------------------------------------
|
||||
{
|
||||
++m_outCount;
|
||||
if(m_currTrack == 0)
|
||||
{
|
||||
m_currTrack++;
|
||||
}
|
||||
req->setTrack(m_currTrack);
|
||||
res->setTrack(m_currTrack);
|
||||
time_t timeout = time(NULL) + m_requestTimeout;
|
||||
|
||||
req->setTimeout(timeout);
|
||||
res->setTimeout(timeout);
|
||||
|
||||
m_outboundQueue.push(pair<GenericRequest *, GenericResponse *>(req, res));
|
||||
return(m_currTrack++);
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
void GenericAPICore::process()
|
||||
//----------------------------------------
|
||||
{
|
||||
GenericRequest *req;
|
||||
GenericResponse *res;
|
||||
|
||||
if (!m_suspended)
|
||||
{
|
||||
// Process timeout on pending requests
|
||||
while((m_outCount > 0) && ((req = m_outboundQueue.front().first)->getTimeout() <= time(NULL)))
|
||||
for (unsigned i = 0; i < arraySize; i++)
|
||||
{
|
||||
--m_outCount;
|
||||
res = m_outboundQueue.front().second;
|
||||
GenericConnection *con = new GenericConnection(hosts[i], port[i], this, reconnectTimeout, noDataTimeoutSecs, noAckTimeoutSecs, incomingBufSizeInKB, outgoingBufSizeInKB, keepAlive, maxRecvMessageSizeInKB);
|
||||
m_serverConnections.push_back(con);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
GenericAPICore::~GenericAPICore()
|
||||
//----------------------------------------
|
||||
{
|
||||
for (std::vector<GenericConnection *>::iterator conIter = m_serverConnections.begin(); conIter != m_serverConnections.end(); conIter++)
|
||||
{
|
||||
GenericConnection *con = *conIter;
|
||||
delete con;
|
||||
}
|
||||
m_serverConnections.clear();
|
||||
|
||||
for (map<unsigned, GenericResponse *>::iterator iter = m_pending.begin(); iter != m_pending.end(); ++iter)
|
||||
{
|
||||
delete (*iter).second;
|
||||
}
|
||||
|
||||
m_pending.clear();
|
||||
|
||||
while (m_outCount > 0)
|
||||
{
|
||||
delete m_outboundQueue.front().second;
|
||||
delete m_outboundQueue.front().first;
|
||||
m_outboundQueue.pop();
|
||||
|
||||
responseCallback(res);
|
||||
delete res;
|
||||
delete req;
|
||||
--m_outCount;
|
||||
}
|
||||
}
|
||||
|
||||
// Process timeout on pending responses
|
||||
while((m_pendingCount > 0) && ((res = (*m_pending.begin()).second)->getTimeout() <= time(NULL)))
|
||||
//----------------------------------------
|
||||
unsigned GenericAPICore::submitRequest(GenericRequest *req, GenericResponse *res)
|
||||
//----------------------------------------
|
||||
{
|
||||
++m_outCount;
|
||||
if (m_currTrack == 0)
|
||||
{
|
||||
--m_pendingCount;
|
||||
m_pending.erase(m_pending.begin());
|
||||
responseCallback(res);
|
||||
delete res;
|
||||
m_currTrack++;
|
||||
}
|
||||
req->setTrack(m_currTrack);
|
||||
res->setTrack(m_currTrack);
|
||||
time_t timeout = time(nullptr) + m_requestTimeout;
|
||||
|
||||
while(m_outCount > 0)
|
||||
req->setTimeout(timeout);
|
||||
res->setTimeout(timeout);
|
||||
|
||||
m_outboundQueue.push(pair<GenericRequest *, GenericResponse *>(req, res));
|
||||
return(m_currTrack++);
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
void GenericAPICore::process()
|
||||
//----------------------------------------
|
||||
{
|
||||
GenericRequest *req;
|
||||
GenericResponse *res;
|
||||
|
||||
if (!m_suspended)
|
||||
{
|
||||
pair<GenericRequest *, GenericResponse *> out_pair = m_outboundQueue.front();
|
||||
req = out_pair.first;
|
||||
res = out_pair.second;
|
||||
GenericConnection *con = NULL;
|
||||
if (req->getMappedServerTrack() == 0) // request has no originating "owner" server
|
||||
// Process timeout on pending requests
|
||||
while ((m_outCount > 0) && ((req = m_outboundQueue.front().first)->getTimeout() <= time(nullptr)))
|
||||
{
|
||||
con = getNextActiveConnection(); // it does not matter which server we send this to
|
||||
--m_outCount;
|
||||
res = m_outboundQueue.front().second;
|
||||
m_outboundQueue.pop();
|
||||
|
||||
responseCallback(res);
|
||||
delete res;
|
||||
delete req;
|
||||
}
|
||||
else
|
||||
|
||||
// Process timeout on pending responses
|
||||
while ((m_pendingCount > 0) && ((res = (*m_pending.begin()).second)->getTimeout() <= time(nullptr)))
|
||||
{
|
||||
ServerTrackObject *stobj = findServer(req->getMappedServerTrack());
|
||||
if (stobj)
|
||||
--m_pendingCount;
|
||||
m_pending.erase(m_pending.begin());
|
||||
responseCallback(res);
|
||||
delete res;
|
||||
}
|
||||
|
||||
while (m_outCount > 0)
|
||||
{
|
||||
pair<GenericRequest *, GenericResponse *> out_pair = m_outboundQueue.front();
|
||||
req = out_pair.first;
|
||||
res = out_pair.second;
|
||||
GenericConnection *con = nullptr;
|
||||
if (req->getMappedServerTrack() == 0) // request has no originating "owner" server
|
||||
{
|
||||
con = stobj->getConnection(); // the server connection to respond to
|
||||
req->setServerTrack(stobj->getRealServerTrack()); // map server track back to REAL server track
|
||||
//printf("\nUnmapping %d to %d", stobj->getMappedServerTrack(), req->getMappedServerTrack()); //debug
|
||||
delete stobj;
|
||||
con = getNextActiveConnection(); // it does not matter which server we send this to
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerTrackObject *stobj = findServer(req->getMappedServerTrack());
|
||||
if (stobj)
|
||||
{
|
||||
con = stobj->getConnection(); // the server connection to respond to
|
||||
req->setServerTrack(stobj->getRealServerTrack()); // map server track back to REAL server track
|
||||
//printf("\nUnmapping %d to %d", stobj->getMappedServerTrack(), req->getMappedServerTrack()); //debug
|
||||
delete stobj;
|
||||
}
|
||||
}
|
||||
|
||||
if (con != nullptr)
|
||||
{
|
||||
Base::ByteStream msg;
|
||||
req->pack(msg);
|
||||
con->Send(msg);
|
||||
m_pending.insert(pair<unsigned, GenericResponse *>(res->getTrack(), res));
|
||||
--m_outCount;
|
||||
++m_pendingCount;
|
||||
m_outboundQueue.pop();
|
||||
delete req;
|
||||
}
|
||||
else
|
||||
{
|
||||
//no active connections
|
||||
break; //from while loop
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (con != NULL)
|
||||
{
|
||||
Base::ByteStream msg;
|
||||
req->pack(msg);
|
||||
con->Send(msg);
|
||||
m_pending.insert(pair<unsigned, GenericResponse *>(res->getTrack(), res));
|
||||
--m_outCount;
|
||||
++m_pendingCount;
|
||||
m_outboundQueue.pop();
|
||||
delete req;
|
||||
}
|
||||
else
|
||||
{
|
||||
//no active connections
|
||||
break; //from while loop
|
||||
}
|
||||
|
||||
for (std::vector<GenericConnection *>::iterator conIter = m_serverConnections.begin(); conIter != m_serverConnections.end(); conIter++)
|
||||
{
|
||||
GenericConnection *con = *conIter;
|
||||
con->process();
|
||||
}
|
||||
}
|
||||
|
||||
for (std::vector<GenericConnection *>::iterator conIter = m_serverConnections.begin(); conIter != m_serverConnections.end(); conIter++)
|
||||
{
|
||||
GenericConnection *con = *conIter;
|
||||
con->process();
|
||||
}
|
||||
}
|
||||
//----------------------------------------
|
||||
GenericConnection *GenericAPICore::getNextActiveConnection()
|
||||
//----------------------------------------
|
||||
{
|
||||
unsigned startIndex = m_nextConnectionIndex;
|
||||
unsigned maxIndex = m_serverConnections.size() - 1;
|
||||
|
||||
GenericConnection *con = nullptr;
|
||||
|
||||
//----------------------------------------
|
||||
GenericConnection *GenericAPICore::getNextActiveConnection()
|
||||
//----------------------------------------
|
||||
{
|
||||
unsigned startIndex = m_nextConnectionIndex;
|
||||
unsigned maxIndex = m_serverConnections.size() - 1;
|
||||
//loop until we find an active connection, or until we get back
|
||||
// to where we started
|
||||
do
|
||||
{
|
||||
if (m_serverConnections[m_nextConnectionIndex]->isConnected())
|
||||
{
|
||||
con = m_serverConnections[m_nextConnectionIndex];
|
||||
if (m_nextConnectionIndex == maxIndex)
|
||||
m_nextConnectionIndex = 0;
|
||||
else
|
||||
m_nextConnectionIndex++;
|
||||
}
|
||||
else if (++m_nextConnectionIndex > maxIndex)
|
||||
{
|
||||
//went past end of vector, start back at 0
|
||||
m_nextConnectionIndex = 0;
|
||||
}
|
||||
} while (con == nullptr && m_nextConnectionIndex != startIndex);
|
||||
|
||||
GenericConnection *con = NULL;
|
||||
return con;
|
||||
}
|
||||
|
||||
//loop until we find an active connection, or until we get back
|
||||
// to where we started
|
||||
do
|
||||
{
|
||||
if (m_serverConnections[m_nextConnectionIndex]->isConnected())
|
||||
{
|
||||
con = m_serverConnections[m_nextConnectionIndex];
|
||||
if (m_nextConnectionIndex == maxIndex)
|
||||
m_nextConnectionIndex = 0;
|
||||
else
|
||||
m_nextConnectionIndex++;
|
||||
|
||||
}
|
||||
else if (++m_nextConnectionIndex > maxIndex)
|
||||
{
|
||||
//went past end of vector, start back at 0
|
||||
m_nextConnectionIndex = 0;
|
||||
}
|
||||
}while (con == NULL && m_nextConnectionIndex != startIndex);
|
||||
//----------------------------------------
|
||||
void GenericAPICore::countOpenConnections()
|
||||
//----------------------------------------
|
||||
{
|
||||
m_currentConnections = 0;
|
||||
m_maxConnections = m_serverConnections.size();
|
||||
|
||||
return con;
|
||||
}
|
||||
for (std::vector<GenericConnection *>::iterator conIter = m_serverConnections.begin(); conIter != m_serverConnections.end(); conIter++)
|
||||
{
|
||||
GenericConnection *con = *conIter;
|
||||
if (con->isConnected())
|
||||
++m_currentConnections;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
void GenericAPICore::countOpenConnections()
|
||||
//----------------------------------------
|
||||
{
|
||||
m_currentConnections = 0;
|
||||
m_maxConnections = m_serverConnections.size();
|
||||
|
||||
for (std::vector<GenericConnection *>::iterator conIter = m_serverConnections.begin(); conIter != m_serverConnections.end(); conIter++)
|
||||
{
|
||||
GenericConnection *con = *conIter;
|
||||
if (con->isConnected())
|
||||
++m_currentConnections;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
ServerTrackObject *GenericAPICore::findServer(unsigned server_track)
|
||||
//----------------------------------------
|
||||
{
|
||||
std::map<unsigned, ServerTrackObject *>::iterator iter = m_serverTracks.find(server_track);
|
||||
if (iter == m_serverTracks.end())
|
||||
return NULL;
|
||||
ServerTrackObject *stobj = (*iter).second;
|
||||
m_serverTracks.erase(server_track);
|
||||
return stobj;
|
||||
}
|
||||
//----------------------------------------
|
||||
ServerTrackObject *GenericAPICore::findServer(unsigned server_track)
|
||||
//----------------------------------------
|
||||
{
|
||||
std::map<unsigned, ServerTrackObject *>::iterator iter = m_serverTracks.find(server_track);
|
||||
if (iter == m_serverTracks.end())
|
||||
return nullptr;
|
||||
ServerTrackObject *stobj = (*iter).second;
|
||||
m_serverTracks.erase(server_track);
|
||||
return stobj;
|
||||
}
|
||||
|
||||
#ifdef EXTERNAL_DISTRO
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
+150
-166
@@ -15,204 +15,188 @@
|
||||
#define GAME_RESOURCE 1
|
||||
|
||||
#ifdef EXTERNAL_DISTRO
|
||||
namespace NAMESPACE
|
||||
namespace NAMESPACE
|
||||
{
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
using namespace Base;
|
||||
using namespace std;
|
||||
using namespace Base;
|
||||
|
||||
GenericConnection::GenericConnection(const char *host, short port, GenericAPICore *apiCore, unsigned reconnectTimeout, unsigned noDataTimeoutSecs, unsigned, unsigned incomingBufSizeInKB, unsigned outgoingBufSizeInKB, unsigned keepAlive, unsigned maxRecvMessageSizeInKB)
|
||||
: m_bConnected(CON_NONE),
|
||||
m_apiCore(apiCore),
|
||||
m_con(NULL),
|
||||
m_host(host),
|
||||
m_port(port),
|
||||
m_lastTrack(123455), //random choice != 1
|
||||
m_conState(CON_DISCONNECT),
|
||||
m_reconnectTimeout(reconnectTimeout)
|
||||
{
|
||||
TcpManager::TcpParams params;
|
||||
|
||||
params.incomingBufferSize = incomingBufSizeInKB * 1024;
|
||||
params.outgoingBufferSize = outgoingBufSizeInKB * 1024;
|
||||
params.maxConnections = 1;
|
||||
params.port = 0;
|
||||
params.maxRecvMessageSize = maxRecvMessageSizeInKB*1024;
|
||||
params.keepAliveDelay = keepAlive * 1000;
|
||||
params.noDataTimeout = noDataTimeoutSecs * 1000;
|
||||
//params.oldestUnacknowledgedTimeout = noAckTimeoutSecs * 1000;
|
||||
|
||||
m_manager = new TcpManager(params);
|
||||
}
|
||||
|
||||
GenericConnection::~GenericConnection()
|
||||
{
|
||||
if(m_con)
|
||||
GenericConnection::GenericConnection(const char *host, short port, GenericAPICore *apiCore, unsigned reconnectTimeout, unsigned noDataTimeoutSecs, unsigned, unsigned incomingBufSizeInKB, unsigned outgoingBufSizeInKB, unsigned keepAlive, unsigned maxRecvMessageSizeInKB)
|
||||
: m_bConnected(CON_NONE),
|
||||
m_apiCore(apiCore),
|
||||
m_con(nullptr),
|
||||
m_host(host),
|
||||
m_port(port),
|
||||
m_conState(CON_DISCONNECT),
|
||||
m_reconnectTimeout(reconnectTimeout),
|
||||
m_conTimeout(0)
|
||||
{
|
||||
m_con->SetHandler(NULL);
|
||||
m_con->Disconnect();//don't worry about onterminated being called, we've set it's handler to null, so it wont
|
||||
m_con->Release();
|
||||
TcpManager::TcpParams params;
|
||||
|
||||
params.incomingBufferSize = incomingBufSizeInKB * 1024;
|
||||
params.outgoingBufferSize = outgoingBufSizeInKB * 1024;
|
||||
params.maxConnections = 1;
|
||||
params.port = 0;
|
||||
params.maxRecvMessageSize = maxRecvMessageSizeInKB * 1024;
|
||||
params.keepAliveDelay = keepAlive * 1000;
|
||||
params.noDataTimeout = noDataTimeoutSecs * 1000;
|
||||
//params.oldestUnacknowledgedTimeout = noAckTimeoutSecs * 1000;
|
||||
|
||||
m_manager = new TcpManager(params);
|
||||
}
|
||||
|
||||
m_manager->Release();
|
||||
}
|
||||
|
||||
void GenericConnection::disconnect()
|
||||
{
|
||||
if (m_con)
|
||||
GenericConnection::~GenericConnection()
|
||||
{
|
||||
m_con->Disconnect();
|
||||
//no need to release, since callback to onTerminated releases it, and callback is allways made m_con->Release();
|
||||
m_con = NULL;
|
||||
if (m_con)
|
||||
{
|
||||
m_con->SetHandler(nullptr);
|
||||
m_con->Disconnect();//don't worry about onterminated being called, we've set it's handler to nullptr, so it wont
|
||||
m_con->Release();
|
||||
}
|
||||
|
||||
m_manager->Release();
|
||||
}
|
||||
m_conState = CON_DISCONNECT;
|
||||
m_bConnected = CON_NONE;
|
||||
}
|
||||
|
||||
void GenericConnection::OnTerminated(TcpConnection *)
|
||||
{
|
||||
// m_apiCore->OnDisconnect(m_host.c_str(), m_port);
|
||||
m_apiCore->OnDisconnect(this);
|
||||
if(m_con)
|
||||
void GenericConnection::disconnect()
|
||||
{
|
||||
m_con->Release();
|
||||
m_con = NULL;
|
||||
if (m_con)
|
||||
{
|
||||
m_con->Disconnect();
|
||||
//no need to release, since callback to onTerminated releases it, and callback is allways made m_con->Release();
|
||||
m_con = nullptr;
|
||||
}
|
||||
m_conState = CON_DISCONNECT;
|
||||
m_bConnected = CON_NONE;
|
||||
}
|
||||
m_conState = CON_DISCONNECT;
|
||||
m_bConnected = CON_NONE;
|
||||
}
|
||||
|
||||
void GenericConnection::OnRoutePacket(TcpConnection *, const unsigned char *data, int dataLen)
|
||||
{
|
||||
short type;
|
||||
unsigned track;
|
||||
|
||||
ByteStream msg(data, dataLen);
|
||||
ByteStream::ReadIterator iter = msg.begin();
|
||||
|
||||
get(iter, type);
|
||||
get(iter, track);
|
||||
GenericResponse *res = NULL;
|
||||
|
||||
// the following if block is a temporary fix that prevents
|
||||
// a crash with a game team in which they occasionally find
|
||||
// themselves receiving a dupe track in consecutive calls to
|
||||
// OnRoutePacket (which then leads to a callback being called
|
||||
// twice and data being invalid on the second call -> crash!).
|
||||
// TODO: resolve this BK
|
||||
/* if (track != 0 &&
|
||||
track == m_lastTrack)
|
||||
void GenericConnection::OnTerminated(TcpConnection *)
|
||||
{
|
||||
printf("!!! ERROR !!! Got a duplicate track ID %u\n", track);
|
||||
return;
|
||||
// m_apiCore->OnDisconnect(m_host.c_str(), m_port);
|
||||
m_apiCore->OnDisconnect(this);
|
||||
if (m_con)
|
||||
{
|
||||
m_con->Release();
|
||||
m_con = nullptr;
|
||||
}
|
||||
m_conState = CON_DISCONNECT;
|
||||
m_bConnected = CON_NONE;
|
||||
}
|
||||
m_lastTrack = track;
|
||||
*/
|
||||
// end temporary fix.
|
||||
|
||||
if(track == 0) // notification message from the server, not as a response to a request from this API
|
||||
void GenericConnection::OnRoutePacket(TcpConnection *, const unsigned char *data, int dataLen)
|
||||
{
|
||||
if (type == ATGAME_REQUEST_CONNECT)
|
||||
{ // this is a special case, for when we have identified our game code to server
|
||||
m_bConnected = CON_IDENTIFIED;
|
||||
m_apiCore->OnConnect(this);
|
||||
short type;
|
||||
unsigned track;
|
||||
|
||||
ByteStream msg(data, dataLen);
|
||||
ByteStream::ReadIterator iter = msg.begin();
|
||||
|
||||
get(iter, type);
|
||||
get(iter, track);
|
||||
GenericResponse *res = nullptr;
|
||||
|
||||
if (track == 0) // notification message from the server, not as a response to a request from this API
|
||||
{
|
||||
if (type == ATGAME_REQUEST_CONNECT)
|
||||
{ // this is a special case, for when we have identified our game code to server
|
||||
m_bConnected = CON_IDENTIFIED;
|
||||
m_apiCore->OnConnect(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_apiCore->responseCallback(type, iter, this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_apiCore->responseCallback(type, iter, this);
|
||||
map<unsigned, GenericResponse *>::iterator mapIter = m_apiCore->m_pending.find(track);
|
||||
|
||||
if (mapIter != m_apiCore->m_pending.end())
|
||||
{
|
||||
res = (*mapIter).second;
|
||||
iter = msg.begin();
|
||||
res->unpack(iter);
|
||||
m_apiCore->responseCallback(res);
|
||||
m_apiCore->m_pendingCount--;
|
||||
m_apiCore->m_pending.erase(mapIter);
|
||||
delete res;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
void GenericConnection::process()
|
||||
{
|
||||
map<unsigned, GenericResponse *>::iterator mapIter = m_apiCore->m_pending.find(track);
|
||||
|
||||
if(mapIter != m_apiCore->m_pending.end())
|
||||
switch (m_conState)
|
||||
{
|
||||
res = (*mapIter).second;
|
||||
iter = msg.begin();
|
||||
res->unpack(iter);
|
||||
m_apiCore->responseCallback(res);
|
||||
m_apiCore->m_pendingCount--;
|
||||
m_apiCore->m_pending.erase(mapIter);
|
||||
delete res;
|
||||
}
|
||||
}
|
||||
}
|
||||
case CON_DISCONNECT:
|
||||
// create connection object, attempting to connect and
|
||||
// checking for connection in next state, CON_NEGOTIATE
|
||||
m_con = m_manager->EstablishConnection(m_host.c_str(), m_port);
|
||||
if (m_con)
|
||||
{
|
||||
m_con->SetHandler(this);
|
||||
m_conState = CON_NEGOTIATE;
|
||||
m_conTimeout = time(nullptr) + m_reconnectTimeout;
|
||||
}
|
||||
break;
|
||||
case CON_NEGOTIATE:
|
||||
// check for connection
|
||||
|
||||
void GenericConnection::process()
|
||||
{
|
||||
switch(m_conState)
|
||||
{
|
||||
case CON_DISCONNECT:
|
||||
// create connection object, attempting to connect and
|
||||
// checking for connection in next state, CON_NEGOTIATE
|
||||
m_con = m_manager->EstablishConnection(m_host.c_str(), m_port);
|
||||
if(m_con)
|
||||
{
|
||||
m_con->SetHandler(this);
|
||||
m_conState = CON_NEGOTIATE;
|
||||
m_conTimeout = time(NULL) + m_reconnectTimeout;
|
||||
}
|
||||
break;
|
||||
case CON_NEGOTIATE:
|
||||
// check for connection
|
||||
if (m_con->GetStatus() == TcpConnection::StatusConnected)
|
||||
{
|
||||
// we're connected
|
||||
m_conState = CON_CONNECT;
|
||||
m_bConnected = CON_CONNECTED;
|
||||
// instead of calling OnConnect() right now, we are going to submit a connection packet
|
||||
// identifying us
|
||||
// m_apiCore->OnConnect(this);
|
||||
Base::ByteStream msg;
|
||||
put(msg, (short)REQUEST_SET_API);
|
||||
put(msg, (unsigned)0); // track
|
||||
put(msg, (unsigned)API_VERSION_CODE);
|
||||
put(msg, GAME_RESOURCE); // identify us as a game connection resource
|
||||
|
||||
if(m_con->GetStatus() == TcpConnection::StatusConnected)
|
||||
{
|
||||
// we're connected
|
||||
m_conState = CON_CONNECT;
|
||||
m_bConnected = CON_CONNECTED;
|
||||
// instead of calling OnConnect() right now, we are going to submit a connection packet
|
||||
// identifying us
|
||||
// m_apiCore->OnConnect(this);
|
||||
Base::ByteStream msg;
|
||||
put(msg, (short)REQUEST_SET_API);
|
||||
put(msg, (unsigned)0); // track
|
||||
put(msg, (unsigned)API_VERSION_CODE);
|
||||
put(msg, GAME_RESOURCE); // identify us as a game connection resource
|
||||
|
||||
// now add in the game identifiers
|
||||
put(msg, (unsigned)m_apiCore->m_gameIdentifiers.size()); // number of strings to read
|
||||
for(unsigned index = 0; index < m_apiCore->m_gameIdentifiers.size(); index++)
|
||||
put(msg, std::string(m_apiCore->m_gameIdentifiers[index]));
|
||||
Send(msg);
|
||||
}
|
||||
else if(time(NULL) > m_conTimeout)
|
||||
{
|
||||
// we did not connect
|
||||
m_con->Disconnect();
|
||||
//no need to release, since callback to onTerminated releases it, and callback is allways made m_con->Release();
|
||||
m_con = NULL;
|
||||
// now add in the game identifiers
|
||||
put(msg, (unsigned)m_apiCore->m_gameIdentifiers.size()); // number of strings to read
|
||||
for (unsigned index = 0; index < m_apiCore->m_gameIdentifiers.size(); index++)
|
||||
put(msg, std::string(m_apiCore->m_gameIdentifiers[index]));
|
||||
Send(msg);
|
||||
}
|
||||
else if (time(nullptr) > m_conTimeout)
|
||||
{
|
||||
// we did not connect
|
||||
m_con->Disconnect();
|
||||
//no need to release, since callback to onTerminated releases it, and callback is allways made m_con->Release();
|
||||
m_con = nullptr;
|
||||
m_conState = CON_DISCONNECT;
|
||||
m_bConnected = CON_NONE;
|
||||
}
|
||||
break;
|
||||
case CON_CONNECT:
|
||||
// do nothing
|
||||
break;
|
||||
default:
|
||||
// this should not occur, but we revert to CON_DISCONNECT if it does
|
||||
m_conState = CON_DISCONNECT;
|
||||
m_bConnected = CON_NONE;
|
||||
}
|
||||
break;
|
||||
case CON_CONNECT:
|
||||
// do nothing
|
||||
break;
|
||||
default:
|
||||
// this should not occur, but we revert to CON_DISCONNECT if it does
|
||||
m_conState = CON_DISCONNECT;
|
||||
m_bConnected = CON_NONE;
|
||||
if (m_con)
|
||||
{
|
||||
m_con->Disconnect();
|
||||
//no need to release, since callback to onTerminated releases it, and callback is allways made m_con->Release();
|
||||
m_con = NULL;
|
||||
m_bConnected = CON_NONE;
|
||||
if (m_con)
|
||||
{
|
||||
m_con->Disconnect();
|
||||
//no need to release, since callback to onTerminated releases it, and callback is allways made m_con->Release();
|
||||
m_con = nullptr;
|
||||
}
|
||||
}
|
||||
m_manager->GiveTime();
|
||||
}
|
||||
m_manager->GiveTime();
|
||||
}
|
||||
|
||||
void GenericConnection::Send(Base::ByteStream &msg)
|
||||
{
|
||||
if(m_con && m_con->GetStatus() == TcpConnection::StatusConnected)
|
||||
void GenericConnection::Send(Base::ByteStream &msg)
|
||||
{
|
||||
m_con->Send((const char *)msg.getBuffer(), msg.getSize());
|
||||
if (m_con && m_con->GetStatus() == TcpConnection::StatusConnected)
|
||||
{
|
||||
m_con->Send((const char *)msg.getBuffer(), msg.getSize());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef EXTERNAL_DISTRO
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
-1
@@ -75,7 +75,6 @@ private:
|
||||
TcpConnection *m_con;
|
||||
std::string m_host;
|
||||
short m_port;
|
||||
unsigned m_lastTrack;
|
||||
eConState m_conState;
|
||||
time_t m_conTimeout;
|
||||
unsigned m_reconnectTimeout;
|
||||
|
||||
+23
-24
@@ -9,36 +9,35 @@
|
||||
//----------------------------------------
|
||||
|
||||
#ifdef EXTERNAL_DISTRO
|
||||
namespace NAMESPACE
|
||||
namespace NAMESPACE
|
||||
{
|
||||
|
||||
#endif
|
||||
|
||||
using namespace Base;
|
||||
using namespace Base;
|
||||
|
||||
//-------------------------------------------
|
||||
GenericRequest::GenericRequest(short type, unsigned server_track)
|
||||
: m_type(type), m_server_track(server_track)
|
||||
//-------------------------------------------
|
||||
{
|
||||
}
|
||||
//-------------------------------------------
|
||||
GenericRequest::GenericRequest(short type, unsigned server_track)
|
||||
: m_type(type), m_server_track(server_track), m_track(0), m_timeout(0)
|
||||
//-------------------------------------------
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------
|
||||
GenericResponse::GenericResponse(short type, unsigned result, void *user)
|
||||
: m_type(type), m_result(result), m_user(user)
|
||||
//-------------------------------------------
|
||||
{
|
||||
}
|
||||
//-------------------------------------------
|
||||
GenericResponse::GenericResponse(short type, unsigned result, void *user)
|
||||
: m_type(type), m_result(result), m_user(user), m_track(0), m_timeout(0)
|
||||
//-------------------------------------------
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
void GenericResponse::unpack(ByteStream::ReadIterator &iter)
|
||||
//-----------------------------------------
|
||||
{
|
||||
get(iter, m_type);
|
||||
get(iter, m_track);
|
||||
get(iter, m_result);
|
||||
}
|
||||
//-----------------------------------------
|
||||
void GenericResponse::unpack(ByteStream::ReadIterator &iter)
|
||||
//-----------------------------------------
|
||||
{
|
||||
get(iter, m_type);
|
||||
get(iter, m_track);
|
||||
get(iter, m_result);
|
||||
}
|
||||
|
||||
#ifdef EXTERNAL_DISTRO
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
+5
-5
@@ -25,9 +25,9 @@ AuctionTransferAPI::AuctionTransferAPI(const char *hostNames, const char *identi
|
||||
std::vector<short> portArray;
|
||||
char hostConfig[4096];
|
||||
char identifierConfig[4096];
|
||||
if (hostNames == NULL)
|
||||
if (hostNames == nullptr)
|
||||
hostNames = DEFAULT_HOST;
|
||||
if(identifiers == NULL)
|
||||
if(identifiers == nullptr)
|
||||
identifiers = DEFAULT_IDENTIFIER;
|
||||
|
||||
// parse the hosts and ports out :
|
||||
@@ -52,7 +52,7 @@ AuctionTransferAPI::AuctionTransferAPI(const char *hostNames, const char *identi
|
||||
portArray.push_back(port);
|
||||
}
|
||||
}
|
||||
while ((ptr = strtok(NULL, " ")) != NULL);
|
||||
while ((ptr = strtok(nullptr, " ")) != nullptr);
|
||||
}
|
||||
|
||||
strncpy(identifierConfig, identifiers, 4096); identifierConfig[4095] = 0;
|
||||
@@ -67,7 +67,7 @@ AuctionTransferAPI::AuctionTransferAPI(const char *hostNames, const char *identi
|
||||
identifierArray.push_back(identifier);
|
||||
}
|
||||
}
|
||||
while ((ptr = strtok(NULL, ";")) != NULL);
|
||||
while ((ptr = strtok(nullptr, ";")) != nullptr);
|
||||
}
|
||||
|
||||
if (hostArray.empty())
|
||||
@@ -134,7 +134,7 @@ unsigned AuctionTransferAPI::sendCommitTransaction(long long transactionID, void
|
||||
unsigned AuctionTransferAPI::sendPrepareTransaction(const char *serverIdentifier, long long transactionID, unsigned stationID, unsigned characterID, long long assetID, const char *xmlAsset, void *user, bool compress)
|
||||
{
|
||||
RequestTypes requestEnum = GAME_REQUEST_SEND_PREPARE_TRANSACTION;
|
||||
GenericRequest *req = NULL;
|
||||
GenericRequest *req = nullptr;
|
||||
if( compress )
|
||||
{
|
||||
requestEnum = GAME_REQUEST_SEND_PREPARE_TRANSACTION_COMPRESSED;
|
||||
|
||||
+2
-2
@@ -91,7 +91,7 @@ namespace Base
|
||||
ByteStream::ByteStream() :
|
||||
allocatedSize(0),
|
||||
beginReadIterator(),
|
||||
data(NULL),
|
||||
data(nullptr),
|
||||
size(0),
|
||||
lastPutSize(0)
|
||||
{
|
||||
@@ -208,7 +208,7 @@ namespace Base
|
||||
if(data->size < allocatedSize)
|
||||
{
|
||||
unsigned char * tmp = new unsigned char[newSize];
|
||||
if(data->buffer != NULL)
|
||||
if(data->buffer != nullptr)
|
||||
memcpy(tmp, data->buffer, size);
|
||||
delete[] data->buffer;
|
||||
data->buffer = tmp;
|
||||
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#ifndef BASE_WIN32_ARCHIVE_H
|
||||
#define BASE_WIN32_ARCHIVE_H
|
||||
|
||||
#ifdef EXTERNAL_DISTRO
|
||||
namespace NAMESPACE
|
||||
{
|
||||
|
||||
#endif
|
||||
namespace Base
|
||||
{
|
||||
|
||||
|
||||
#ifdef PACK_BIG_ENDIAN
|
||||
|
||||
inline double byteSwap(double value) { byteReverse64(&value); return value; }
|
||||
inline float byteSwap(float value) { byteReverse32(&value); return value; }
|
||||
inline uint64 byteSwap(uint64 value) { byteReverse64(&value); return value; }
|
||||
inline int64 byteSwap(int64 value) { byteReverse64(&value); return value; }
|
||||
inline uint32 byteSwap(uint32 value) { byteReverse32(&value); return value; }
|
||||
inline int32 byteSwap(int32 value) { byteReverse32(&value); return value; }
|
||||
inline uint16 byteSwap(uint16 value) { byteReverse16(&value); return value; }
|
||||
inline int16 byteSwap(int16 value) { byteReverse16(&value); return value; }
|
||||
|
||||
#else
|
||||
|
||||
inline double byteSwap(double value) { return value; }
|
||||
inline float byteSwap(float value) { return value; }
|
||||
inline uint64 byteSwap(uint64 value) { return value; }
|
||||
inline int64 byteSwap(int64 value) { return value; }
|
||||
inline uint32 byteSwap(uint32 value) { return value; }
|
||||
inline int32 byteSwap(int32 value) { return value; }
|
||||
inline uint16 byteSwap(uint16 value) { return value; }
|
||||
inline int16 byteSwap(int16 value) { return value; }
|
||||
|
||||
#endif
|
||||
|
||||
};
|
||||
#ifdef EXTERNAL_DISTRO
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
////////////////////////////////////////
|
||||
// Platform.cpp
|
||||
//
|
||||
// Purpose:
|
||||
// 1. Implementation of the global functionality declaired in Platform.h.
|
||||
//
|
||||
// Revisions:
|
||||
// 07/10/2001 Created
|
||||
//
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#ifdef EXTERNAL_DISTRO
|
||||
namespace NAMESPACE
|
||||
{
|
||||
|
||||
#endif
|
||||
namespace Base
|
||||
{
|
||||
|
||||
|
||||
CTimer::CTimer() :
|
||||
mTimer(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
#ifdef EXTERNAL_DISTRO
|
||||
};
|
||||
#endif
|
||||
Executable
+98
@@ -0,0 +1,98 @@
|
||||
////////////////////////////////////////
|
||||
// Platform.h
|
||||
//
|
||||
// Purpose:
|
||||
// 1. Include relevent system headers that are platform specific.
|
||||
// 2. Declair global platform specific functionality.
|
||||
// 3. Include primative type definitions
|
||||
//
|
||||
// Global Functions:
|
||||
// getTimer() : Return the current high resolution clock count.
|
||||
// getTimerFrequency() : Return the frequency of the high resolution clock.
|
||||
// sleep() : Voluntarily relinquish timeslice of the calling thread for a
|
||||
// specified number of milliseconds.
|
||||
//
|
||||
// Revisions:
|
||||
// 07/10/2001 Created
|
||||
//
|
||||
|
||||
#ifndef BASE_WIN32_PLATFORM_H
|
||||
#define BASE_WIN32_PLATFORM_H
|
||||
|
||||
#include <memory.h>
|
||||
#include <winsock2.h>
|
||||
#include <time.h>
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include <direct.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include "Types.h"
|
||||
|
||||
#ifdef EXTERNAL_DISTRO
|
||||
namespace NAMESPACE
|
||||
{
|
||||
|
||||
#endif
|
||||
namespace Base
|
||||
{
|
||||
|
||||
uint64 getTimer(void);
|
||||
uint64 getTimerFrequency(void);
|
||||
|
||||
inline uint64 getTimer(void)
|
||||
{
|
||||
uint64 result;
|
||||
if (!QueryPerformanceCounter(reinterpret_cast<LARGE_INTEGER *>(&result)))
|
||||
result = 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
inline uint64 getTimerFrequency(void)
|
||||
{
|
||||
uint64 result;
|
||||
if (!QueryPerformanceFrequency(reinterpret_cast<LARGE_INTEGER *>(&result)))
|
||||
result = 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
inline void sleep(uint32 ms)
|
||||
{
|
||||
Sleep(ms);
|
||||
}
|
||||
|
||||
|
||||
class CTimer
|
||||
{
|
||||
public:
|
||||
CTimer();
|
||||
|
||||
void Set(uint32 seconds);
|
||||
void Signal();
|
||||
bool Expired();
|
||||
|
||||
private:
|
||||
uint32 mTimer;
|
||||
};
|
||||
|
||||
inline void CTimer::Set(uint32 interval)
|
||||
{
|
||||
mTimer = (uint32)time(0) + interval;
|
||||
}
|
||||
|
||||
inline void CTimer::Signal()
|
||||
{
|
||||
mTimer = 0;
|
||||
}
|
||||
|
||||
inline bool CTimer::Expired()
|
||||
{
|
||||
return (mTimer <= (uint32)time(0));
|
||||
}
|
||||
};
|
||||
#ifdef EXTERNAL_DISTRO
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#endif BASE_WIN32_PLATFORM_H
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
////////////////////////////////////////
|
||||
// Types.h
|
||||
//
|
||||
// Purpose:
|
||||
// 1. Define integer types that are unambiguous with respect to size
|
||||
//
|
||||
// Revisions:
|
||||
// 07/10/2001 Created
|
||||
//
|
||||
|
||||
#ifndef BASE_WIN32_TYPES_H
|
||||
#define BASE_WIN32_TYPES_H
|
||||
|
||||
#ifdef EXTERNAL_DISTRO
|
||||
namespace NAMESPACE
|
||||
{
|
||||
|
||||
#endif
|
||||
namespace Base
|
||||
{
|
||||
|
||||
#define INT32_MAX 0x7FFFFFFF
|
||||
#define INT32_MIN 0x80000000
|
||||
#define UINT32_MAX 0xFFFFFFFF
|
||||
|
||||
typedef signed char int8;
|
||||
typedef unsigned char uint8;
|
||||
typedef short int16;
|
||||
typedef unsigned short uint16;
|
||||
|
||||
typedef int int32;
|
||||
typedef unsigned uint32;
|
||||
typedef __int64 int64;
|
||||
typedef unsigned __int64 uint64;
|
||||
|
||||
};
|
||||
#ifdef EXTERNAL_DISTRO
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // BASE_WIN32_TYPES_H
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@ void put(Base::ByteStream &msg, const Blob &source);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
Blob::Blob(const unsigned char *data, unsigned len)
|
||||
: m_data(NULL),
|
||||
: m_data(nullptr),
|
||||
m_len(len)
|
||||
{
|
||||
if (m_len > 0)
|
||||
@@ -20,7 +20,7 @@ void put(Base::ByteStream &msg, const Blob &source);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
Blob::Blob(const Blob &cpy)
|
||||
: m_data(NULL),
|
||||
: m_data(nullptr),
|
||||
m_len(cpy.m_len)
|
||||
{
|
||||
if (m_len > 0)
|
||||
@@ -45,7 +45,7 @@ void put(Base::ByteStream &msg, const Blob &source);
|
||||
if (m_data)
|
||||
{
|
||||
delete [] m_data;
|
||||
m_data = NULL;
|
||||
m_data = nullptr;
|
||||
}
|
||||
|
||||
m_len = cpy.m_len;
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ public:
|
||||
* @brief Used to retreive the the dot-notation represenatatiion of this address.
|
||||
*
|
||||
* @param buffer A pointer to the buffer to place the ip address into.
|
||||
* Must be at least 17 characters long, will be null terminated.
|
||||
* Must be at least 17 characters long, will be nullptr terminated.
|
||||
*
|
||||
* @return A pointer to the buffer the address was placed into.
|
||||
*/
|
||||
|
||||
+3
-3
@@ -6,7 +6,7 @@ namespace NAMESPACE
|
||||
#endif
|
||||
|
||||
TcpBlockAllocator::TcpBlockAllocator(const unsigned initSize, const unsigned initCount)
|
||||
: m_freeHead(NULL), m_blockCount(initCount), m_blockSize(initSize), m_numAvailBlocks(0)
|
||||
: m_freeHead(nullptr), m_blockCount(initCount), m_blockSize(initSize), m_numAvailBlocks(0)
|
||||
{
|
||||
realloc();
|
||||
}
|
||||
@@ -33,7 +33,7 @@ data_block *TcpBlockAllocator::getBlock()
|
||||
|
||||
tmp = m_freeHead;
|
||||
m_freeHead = m_freeHead->m_next;
|
||||
tmp->m_next = NULL;
|
||||
tmp->m_next = nullptr;
|
||||
m_numAvailBlocks--;
|
||||
return(tmp);
|
||||
}
|
||||
@@ -56,7 +56,7 @@ void TcpBlockAllocator::returnBlock(data_block *b)
|
||||
|
||||
void TcpBlockAllocator::realloc()
|
||||
{
|
||||
data_block *tmp = NULL, *cursor = NULL;
|
||||
data_block *tmp = nullptr, *cursor = nullptr;
|
||||
|
||||
tmp = new data_block; m_numAvailBlocks++;
|
||||
cursor = tmp;
|
||||
|
||||
+32
-32
@@ -11,28 +11,28 @@ namespace NAMESPACE
|
||||
|
||||
//used when want to open new connection with this socket
|
||||
TcpConnection::TcpConnection(TcpManager *tcpManager, TcpBlockAllocator *sendAlloc, TcpManager::TcpParams ¶ms, const IPAddress &destIP, short destPort, unsigned timeout)
|
||||
: m_nextConnection(NULL),
|
||||
m_prevConnection(NULL),
|
||||
: m_nextConnection(nullptr),
|
||||
m_prevConnection(nullptr),
|
||||
m_socket(INVALID_SOCKET),
|
||||
m_nextKeepAliveConnection(NULL),
|
||||
m_prevKeepAliveConnection(NULL),
|
||||
m_nextKeepAliveConnection(nullptr),
|
||||
m_prevKeepAliveConnection(nullptr),
|
||||
m_aliveListId(tcpManager->m_aliveList.m_listID),
|
||||
m_nextRecvDataConnection(NULL),
|
||||
m_prevRecvDataConnection(NULL),
|
||||
m_nextRecvDataConnection(nullptr),
|
||||
m_prevRecvDataConnection(nullptr),
|
||||
m_recvDataListId(tcpManager->m_dataList.m_listID),
|
||||
m_manager(tcpManager),
|
||||
m_status(StatusNegotiating),
|
||||
m_handler(NULL),
|
||||
m_handler(nullptr),
|
||||
m_destIP(destIP),
|
||||
m_destPort(destPort),
|
||||
m_refCount(0),
|
||||
m_sendAllocator(sendAlloc),
|
||||
m_head(NULL),
|
||||
m_tail(NULL),
|
||||
m_head(nullptr),
|
||||
m_tail(nullptr),
|
||||
m_bytesRead(0),
|
||||
m_bytesNeeded(0),
|
||||
m_params(params),
|
||||
m_recvBuff(NULL),
|
||||
m_recvBuff(nullptr),
|
||||
m_connectTimeout(timeout),
|
||||
m_connectTimer(),
|
||||
m_wasConRemovedFromMgr(false)
|
||||
@@ -94,28 +94,28 @@ TcpConnection::TcpConnection(TcpManager *tcpManager, TcpBlockAllocator *sendAllo
|
||||
|
||||
//used when server mode creates new connection object representing a connect request
|
||||
TcpConnection::TcpConnection(TcpManager *tcpManager, TcpBlockAllocator *sendAlloc, TcpManager::TcpParams ¶ms, SOCKET socket, const IPAddress &destIP, short destPort)
|
||||
: m_nextConnection(NULL),
|
||||
m_prevConnection(NULL),
|
||||
: m_nextConnection(nullptr),
|
||||
m_prevConnection(nullptr),
|
||||
m_socket(socket),
|
||||
m_nextKeepAliveConnection(NULL),
|
||||
m_prevKeepAliveConnection(NULL),
|
||||
m_nextKeepAliveConnection(nullptr),
|
||||
m_prevKeepAliveConnection(nullptr),
|
||||
m_aliveListId(tcpManager->m_aliveList.m_listID),
|
||||
m_nextRecvDataConnection(NULL),
|
||||
m_prevRecvDataConnection(NULL),
|
||||
m_nextRecvDataConnection(nullptr),
|
||||
m_prevRecvDataConnection(nullptr),
|
||||
m_recvDataListId(tcpManager->m_dataList.m_listID),
|
||||
m_manager(tcpManager),
|
||||
m_status(StatusConnected),
|
||||
m_handler(NULL),
|
||||
m_handler(nullptr),
|
||||
m_destIP(destIP),
|
||||
m_destPort(destPort),
|
||||
m_refCount(0),
|
||||
m_sendAllocator(sendAlloc),
|
||||
m_head(NULL),
|
||||
m_tail(NULL),
|
||||
m_head(nullptr),
|
||||
m_tail(nullptr),
|
||||
m_bytesRead(0),
|
||||
m_bytesNeeded(0),
|
||||
m_params(params),
|
||||
m_recvBuff(NULL),
|
||||
m_recvBuff(nullptr),
|
||||
m_connectTimeout(0),
|
||||
m_connectTimer(),
|
||||
m_wasConRemovedFromMgr(false)
|
||||
@@ -208,7 +208,7 @@ int TcpConnection::finishConnect()
|
||||
t.tv_sec = 0;
|
||||
t.tv_usec = 0;
|
||||
|
||||
int err = select(m_socket + 1, NULL, &wrSet, NULL, &t);
|
||||
int err = select(m_socket + 1, nullptr, &wrSet, nullptr, &t);
|
||||
|
||||
if (err == 0)
|
||||
{
|
||||
@@ -303,7 +303,7 @@ TcpConnection::~TcpConnection()
|
||||
{
|
||||
delete [] m_recvBuff;
|
||||
|
||||
while(m_head != NULL)
|
||||
while(m_head != nullptr)
|
||||
{
|
||||
data_block *tmp = m_head;
|
||||
m_head = m_head->m_next;
|
||||
@@ -327,22 +327,22 @@ void TcpConnection::Send(const char *data, unsigned int dataLen)
|
||||
{
|
||||
m_aliveListId = m_manager->m_keepAliveList.m_listID;
|
||||
|
||||
if (m_prevKeepAliveConnection != NULL)
|
||||
if (m_prevKeepAliveConnection != nullptr)
|
||||
m_prevKeepAliveConnection->m_nextKeepAliveConnection = m_nextKeepAliveConnection;
|
||||
if (m_nextKeepAliveConnection != NULL)
|
||||
if (m_nextKeepAliveConnection != nullptr)
|
||||
m_nextKeepAliveConnection->m_prevKeepAliveConnection = m_prevKeepAliveConnection;
|
||||
if (m_manager->m_keepAliveList.m_beginList == this)
|
||||
m_manager->m_keepAliveList.m_beginList = m_nextKeepAliveConnection;
|
||||
|
||||
m_nextKeepAliveConnection = m_manager->m_aliveList.m_beginList;
|
||||
m_prevKeepAliveConnection = NULL;
|
||||
if (m_manager->m_aliveList.m_beginList != NULL)
|
||||
m_prevKeepAliveConnection = nullptr;
|
||||
if (m_manager->m_aliveList.m_beginList != nullptr)
|
||||
m_manager->m_aliveList.m_beginList->m_prevKeepAliveConnection = this;
|
||||
m_manager->m_aliveList.m_beginList = this;
|
||||
}
|
||||
|
||||
|
||||
data_block *work = NULL;
|
||||
data_block *work = nullptr;
|
||||
|
||||
// this connection has no send buffer. Get a block
|
||||
if(!m_tail)
|
||||
@@ -467,16 +467,16 @@ int TcpConnection::processIncoming()
|
||||
{
|
||||
m_recvDataListId = m_manager->m_noDataList.m_listID;
|
||||
|
||||
if (m_prevRecvDataConnection != NULL)
|
||||
if (m_prevRecvDataConnection != nullptr)
|
||||
m_prevRecvDataConnection->m_nextRecvDataConnection = m_nextRecvDataConnection;
|
||||
if (m_nextRecvDataConnection != NULL)
|
||||
if (m_nextRecvDataConnection != nullptr)
|
||||
m_nextRecvDataConnection->m_prevRecvDataConnection = m_prevRecvDataConnection;
|
||||
if (m_manager->m_noDataList.m_beginList == this)
|
||||
m_manager->m_noDataList.m_beginList = m_nextRecvDataConnection;
|
||||
|
||||
m_nextRecvDataConnection = m_manager->m_dataList.m_beginList;
|
||||
m_prevRecvDataConnection = NULL;
|
||||
if (m_manager->m_dataList.m_beginList != NULL)
|
||||
m_prevRecvDataConnection = nullptr;
|
||||
if (m_manager->m_dataList.m_beginList != nullptr)
|
||||
m_manager->m_dataList.m_beginList->m_prevRecvDataConnection = this;
|
||||
m_manager->m_dataList.m_beginList = this;
|
||||
}
|
||||
@@ -622,7 +622,7 @@ int TcpConnection::processOutgoing()
|
||||
|
||||
int sendError = 1;
|
||||
|
||||
// If m_head is not null, then this connection has something to send
|
||||
// If m_head is not nullptr, then this connection has something to send
|
||||
|
||||
|
||||
if(m_head)
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ public:
|
||||
* connection is disconnected, you simply need to derive your class
|
||||
* (multiply if necessary) from TcpConnectionHandler, then you can use
|
||||
* this method to set the object the TcpConnection will call as appropriate.
|
||||
* default = NULL (no callbacks made)
|
||||
* default = nullptr (no callbacks made)
|
||||
*
|
||||
* @param handler The object which will be called for notifications.
|
||||
*/
|
||||
|
||||
+611
-635
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -156,7 +156,7 @@ public:
|
||||
* simply need to derive your class (multiply if necessary) from TcpManagerHandler, then you can use
|
||||
* this method to set the object the TcpManager will call as appropriate. The TcpConnection object
|
||||
* also has a handler mechanism that replaces the other callback functions below, see TcpConnection::SetHandler
|
||||
* default = NULL (no callbacks made)
|
||||
* default = nullptr (no callbacks made)
|
||||
*
|
||||
* @param handler The object which will be called for manager related notifications.
|
||||
*/
|
||||
@@ -211,7 +211,7 @@ public:
|
||||
* the connect-complete callback to be called if the connection is succesfull.
|
||||
*
|
||||
* @return A pointer to a TcpConnection object.
|
||||
* NULL if the manager object has exceeded its maximum number of connections
|
||||
* nullptr if the manager object has exceeded its maximum number of connections
|
||||
* or if the serverAddress cannot be resolved to an IP address.
|
||||
*/
|
||||
TcpConnection *EstablishConnection(const char *serverAddress, unsigned short serverPort, unsigned timeout = 0);
|
||||
|
||||
+2
-2
@@ -187,7 +187,7 @@ class CA2GZIPT
|
||||
int destroy()
|
||||
{
|
||||
int err = Z_OK;
|
||||
if (m_zstream.state != NULL) {
|
||||
if (m_zstream.state != nullptr) {
|
||||
err = deflateEnd(&(m_zstream));
|
||||
}
|
||||
if (m_z_err < 0) err = m_z_err;
|
||||
@@ -459,7 +459,7 @@ class CGZIP2AT
|
||||
int destroy()
|
||||
{
|
||||
int err = Z_OK;
|
||||
if (m_zstream.state != NULL) {
|
||||
if (m_zstream.state != nullptr) {
|
||||
err = inflateEnd(&(m_zstream));
|
||||
}
|
||||
if (m_z_err < 0) err = m_z_err;
|
||||
|
||||
+19
-19
@@ -74,7 +74,7 @@ typedef struct z_stream_s {
|
||||
uInt avail_out; /* remaining free space at next_out */
|
||||
uLong total_out; /* total nb of bytes output so far */
|
||||
|
||||
char *msg; /* last error message, NULL if no error */
|
||||
char *msg; /* last error message, nullptr if no error */
|
||||
struct internal_state FAR *state; /* not visible by applications */
|
||||
|
||||
alloc_func zalloc; /* used to allocate the internal state */
|
||||
@@ -193,7 +193,7 @@ ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
|
||||
enough memory, Z_STREAM_ERROR if level is not a valid compression level,
|
||||
Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
|
||||
with the version assumed by the caller (ZLIB_VERSION).
|
||||
msg is set to null if there is no error message. deflateInit does not
|
||||
msg is set to nullptr if there is no error message. deflateInit does not
|
||||
perform any compression: this will be done by deflate().
|
||||
*/
|
||||
|
||||
@@ -271,7 +271,7 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
|
||||
processed or more output produced), Z_STREAM_END if all input has been
|
||||
consumed and all output has been produced (only when flush is set to
|
||||
Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
|
||||
if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible
|
||||
if next_in or next_out was nullptr), Z_BUF_ERROR if no progress is possible
|
||||
(for example avail_in or avail_out was zero).
|
||||
*/
|
||||
|
||||
@@ -304,7 +304,7 @@ ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
|
||||
|
||||
inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
||||
memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
|
||||
version assumed by the caller. msg is set to null if there is no error
|
||||
version assumed by the caller. msg is set to nullptr if there is no error
|
||||
message. inflateInit does not perform any decompression apart from reading
|
||||
the zlib header if present: this will be done by inflate(). (So next_in and
|
||||
avail_in may be modified, but next_out and avail_out are unchanged.)
|
||||
@@ -372,7 +372,7 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
|
||||
preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
|
||||
corrupted (input stream not conforming to the zlib format or incorrect
|
||||
adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent
|
||||
(for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not
|
||||
(for example if next_in or next_out was nullptr), Z_MEM_ERROR if there was not
|
||||
enough memory, Z_BUF_ERROR if no progress is possible or if there was not
|
||||
enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR
|
||||
case, the application may then call inflateSync to look for a good
|
||||
@@ -437,7 +437,7 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
|
||||
|
||||
deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
||||
memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid
|
||||
method). msg is set to null if there is no error message. deflateInit2 does
|
||||
method). msg is set to nullptr if there is no error message. deflateInit2 does
|
||||
not perform any compression: this will be done by deflate().
|
||||
*/
|
||||
|
||||
@@ -471,7 +471,7 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
|
||||
actually used by the compressor.)
|
||||
|
||||
deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
|
||||
parameter is invalid (such as NULL dictionary) or the stream state is
|
||||
parameter is invalid (such as nullptr dictionary) or the stream state is
|
||||
inconsistent (for example if deflate has already been called for this stream
|
||||
or if the compression method is bsort). deflateSetDictionary does not
|
||||
perform any compression: this will be done by deflate().
|
||||
@@ -491,7 +491,7 @@ ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
|
||||
|
||||
deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
|
||||
enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
|
||||
(such as zalloc being NULL). msg is left unchanged in both source and
|
||||
(such as zalloc being nullptr). msg is left unchanged in both source and
|
||||
destination.
|
||||
*/
|
||||
|
||||
@@ -503,7 +503,7 @@ ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
|
||||
that may have been set by deflateInit2.
|
||||
|
||||
deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
|
||||
stream state was inconsistent (such as zalloc or state being NULL).
|
||||
stream state was inconsistent (such as zalloc or state being nullptr).
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
|
||||
@@ -544,7 +544,7 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
|
||||
|
||||
inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
||||
memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative
|
||||
memLevel). msg is set to null if there is no error message. inflateInit2
|
||||
memLevel). msg is set to nullptr if there is no error message. inflateInit2
|
||||
does not perform any decompression apart from reading the zlib header if
|
||||
present: this will be done by inflate(). (So next_in and avail_in may be
|
||||
modified, but next_out and avail_out are unchanged.)
|
||||
@@ -562,7 +562,7 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
|
||||
dictionary (see deflateSetDictionary).
|
||||
|
||||
inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
|
||||
parameter is invalid (such as NULL dictionary) or the stream state is
|
||||
parameter is invalid (such as nullptr dictionary) or the stream state is
|
||||
inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
|
||||
expected one (incorrect Adler32 value). inflateSetDictionary does not
|
||||
perform any decompression: this will be done by subsequent calls of
|
||||
@@ -591,7 +591,7 @@ ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
|
||||
The stream will keep attributes that may have been set by inflateInit2.
|
||||
|
||||
inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
|
||||
stream state was inconsistent (such as zalloc or state being NULL).
|
||||
stream state was inconsistent (such as zalloc or state being nullptr).
|
||||
*/
|
||||
|
||||
|
||||
@@ -667,7 +667,7 @@ ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
|
||||
gzopen can be used to read a file which is not in gzip format; in this
|
||||
case gzread will directly read from the file without decompression.
|
||||
|
||||
gzopen returns NULL if the file could not be opened or if there was
|
||||
gzopen returns nullptr if the file could not be opened or if there was
|
||||
insufficient memory to allocate the (de)compression state; errno
|
||||
can be checked to distinguish the two cases (if errno is zero, the
|
||||
zlib error is Z_MEM_ERROR). */
|
||||
@@ -681,7 +681,7 @@ ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
|
||||
The next call of gzclose on the returned gzFile will also close the
|
||||
file descriptor fd, just like fclose(fdopen(fd), mode) closes the file
|
||||
descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).
|
||||
gzdopen returns NULL if there was insufficient memory to allocate
|
||||
gzdopen returns nullptr if there was insufficient memory to allocate
|
||||
the (de)compression state.
|
||||
*/
|
||||
|
||||
@@ -718,8 +718,8 @@ ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));
|
||||
|
||||
ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
|
||||
/*
|
||||
Writes the given null-terminated string to the compressed file, excluding
|
||||
the terminating null character.
|
||||
Writes the given nullptr-terminated string to the compressed file, excluding
|
||||
the terminating nullptr character.
|
||||
gzputs returns the number of characters written, or -1 in case of error.
|
||||
*/
|
||||
|
||||
@@ -727,7 +727,7 @@ ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
|
||||
/*
|
||||
Reads bytes from the compressed file until len-1 characters are read, or
|
||||
a newline character is read and transferred to buf, or an end-of-file
|
||||
condition is encountered. The string is then terminated with a null
|
||||
condition is encountered. The string is then terminated with a nullptr
|
||||
character.
|
||||
gzgets returns buf, or Z_NULL in case of error.
|
||||
*/
|
||||
@@ -822,7 +822,7 @@ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
|
||||
|
||||
/*
|
||||
Update a running Adler-32 checksum with the bytes buf[0..len-1] and
|
||||
return the updated checksum. If buf is NULL, this function returns
|
||||
return the updated checksum. If buf is nullptr, this function returns
|
||||
the required initial value for the checksum.
|
||||
An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
|
||||
much faster. Usage example:
|
||||
@@ -838,7 +838,7 @@ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
|
||||
ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
|
||||
/*
|
||||
Update a running crc with the bytes buf[0..len-1] and return the updated
|
||||
crc. If buf is NULL, this function returns the required initial value
|
||||
crc. If buf is nullptr, this function returns the required initial value
|
||||
for the crc. Pre- and post-conditioning (one's complement) is performed
|
||||
within this function so it shouldn't be done by the application.
|
||||
Usage example:
|
||||
|
||||
+2
-2
@@ -116,7 +116,7 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||
# include <unix.h> /* for fdopen */
|
||||
# else
|
||||
# ifndef fdopen
|
||||
# define fdopen(fd,mode) NULL /* No fdopen() */
|
||||
# define fdopen(fd,mode) nullptr /* No fdopen() */
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
@@ -130,7 +130,7 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||
#endif
|
||||
|
||||
#if defined(_BEOS_) || defined(RISCOS)
|
||||
# define fdopen(fd,mode) NULL /* No fdopen() */
|
||||
# define fdopen(fd,mode) nullptr /* No fdopen() */
|
||||
#endif
|
||||
|
||||
#if (defined(_MSC_VER) && (_MSC_VER > 600))
|
||||
|
||||
@@ -16,28 +16,27 @@ class StructureListMessage;
|
||||
|
||||
#define DECLARE_CS_CMD( _name ) void handle_##_name( GameServerCSRequestMessage & message );
|
||||
|
||||
|
||||
class CentralCSHandler
|
||||
{
|
||||
public:
|
||||
static void install();
|
||||
static void remove();
|
||||
static CentralCSHandler & getInstance();
|
||||
void handle( const CSToolRequest& msg, uint32 loginServerId );
|
||||
void handle(const CSToolRequest& msg, uint32 loginServerId);
|
||||
~CentralCSHandler();
|
||||
|
||||
void handleFindObjectResponse( int iIndex, bool bFound );
|
||||
void handleStructureListResponse( StructureListMessage& msg );
|
||||
|
||||
|
||||
void handleFindObjectResponse(int iIndex, bool bFound);
|
||||
void handleStructureListResponse(StructureListMessage& msg);
|
||||
|
||||
// only need to DECLARE_CS_CMD for commands handled at the CentralServer.
|
||||
|
||||
DECLARE_CS_CMD( list_structures );
|
||||
DECLARE_CS_CMD( login_character );
|
||||
DECLARE_CS_CMD( warp_player );
|
||||
|
||||
|
||||
DECLARE_CS_CMD(list_structures);
|
||||
DECLARE_CS_CMD(login_character);
|
||||
DECLARE_CS_CMD(warp_player);
|
||||
|
||||
protected:
|
||||
static CentralCSHandler * smp_instance;
|
||||
typedef void( CentralCSHandler::*CentralCSHandlerFunc )( GameServerCSRequestMessage & );
|
||||
typedef void(CentralCSHandler::*CentralCSHandlerFunc)(GameServerCSRequestMessage &);
|
||||
|
||||
class HandlerEntry
|
||||
{
|
||||
@@ -52,75 +51,70 @@ protected:
|
||||
TYPE_ARBITRARY_GAME_SERVER // send to a game server, we don't care which one. This is used
|
||||
// if all game servers have what we're looking for, so we don't care who gets it.
|
||||
};
|
||||
|
||||
|
||||
HandlerEntry( const std::string & in_name, CentralCSHandlerFunc in_func, EntryType in_type ) :
|
||||
name( in_name ),
|
||||
type( in_type ),
|
||||
func( in_func )
|
||||
|
||||
HandlerEntry(const std::string & in_name, CentralCSHandlerFunc in_func, EntryType in_type) :
|
||||
name(in_name),
|
||||
type(in_type),
|
||||
func(in_func)
|
||||
{
|
||||
}
|
||||
|
||||
HandlerEntry( const std::string & in_name, EntryType in_type ) :
|
||||
name(in_name),
|
||||
type( in_type )
|
||||
|
||||
HandlerEntry(const std::string & in_name, EntryType in_type) :
|
||||
name(in_name),
|
||||
type(in_type),
|
||||
func(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
std::string name;
|
||||
EntryType type;
|
||||
CentralCSHandlerFunc func; // will be null unless it's of TYPE_CENTRAL.
|
||||
|
||||
|
||||
CentralCSHandlerFunc func; // will be nullptr unless it's of TYPE_CENTRAL.
|
||||
};
|
||||
|
||||
|
||||
class CSCharacterFindInfo
|
||||
{
|
||||
public:
|
||||
CSCharacterFindInfo( NetworkId & id, int numServers, GameServerCSRequestMessage &req, bool bHandleAtCentral ) :
|
||||
commandLine( req.getCommandString() ),
|
||||
command( req.getCommandName() ),
|
||||
iAccessLevel( req.getAccessLevel() ),
|
||||
user(req.getUserName() ),
|
||||
iToolId( req.getToolId() ),
|
||||
iAccount( req.getAccountId() ),
|
||||
responsesWaiting( numServers ),
|
||||
iLoginServerId( req.getLoginServerID() ),
|
||||
bCentral( bHandleAtCentral )
|
||||
|
||||
CSCharacterFindInfo(NetworkId & id, int numServers, GameServerCSRequestMessage &req, bool bHandleAtCentral) :
|
||||
commandLine(req.getCommandString()),
|
||||
command(req.getCommandName()),
|
||||
iAccessLevel(req.getAccessLevel()),
|
||||
user(req.getUserName()),
|
||||
iToolId(req.getToolId()),
|
||||
iAccount(req.getAccountId()),
|
||||
responsesWaiting(numServers),
|
||||
iLoginServerId(req.getLoginServerID()),
|
||||
bCentral(bHandleAtCentral)
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
std::string commandLine;
|
||||
std::string command;
|
||||
|
||||
|
||||
uint32 iAccessLevel;
|
||||
std::string user;
|
||||
|
||||
|
||||
uint32 iToolId;
|
||||
int iAccount;
|
||||
|
||||
|
||||
int responsesWaiting;
|
||||
|
||||
int responsesWaiting;
|
||||
int iLoginServerId;
|
||||
bool bCentral; // if offline, should we handle this at the Central Server or the DB?
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
|
||||
typedef std::map< int, CSCharacterFindInfo * > CentralCharFindMap;
|
||||
|
||||
|
||||
CentralCharFindMap m_findMap;
|
||||
|
||||
|
||||
typedef std::map< std::string, HandlerEntry * > CentralCSHandlerMap;
|
||||
|
||||
|
||||
CentralCSHandlerMap m_entries;
|
||||
|
||||
|
||||
private:
|
||||
CentralCSHandler() :
|
||||
m_findMap(),
|
||||
m_entries()
|
||||
m_findMap(),
|
||||
m_entries()
|
||||
{
|
||||
};
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -121,7 +121,7 @@ public:
|
||||
void sendToAllGameServersExceptDBProcess(const GameNetworkMessage & message, const bool reliable);
|
||||
void sendToAllPlanetServers(const GameNetworkMessage & message, const bool reliable);
|
||||
void sendToPlanetServer(const std::string &sceneId, const GameNetworkMessage & message, const bool reliable);
|
||||
void sendToAllConnectionServers(const GameNetworkMessage & message, const bool reliable, Connection const * exclude = NULL);
|
||||
void sendToAllConnectionServers(const GameNetworkMessage & message, const bool reliable, Connection const * exclude = nullptr);
|
||||
void sendToConnectionServerForAccount(StationId account, const GameNetworkMessage & message, const bool reliable);
|
||||
void sendToDBProcess(const GameNetworkMessage & message, const bool reliable) const;
|
||||
void sendToLoginServer(uint32 loginServerId, const GameNetworkMessage &message);
|
||||
@@ -182,6 +182,7 @@ private:
|
||||
size_t getGameServerCount (void) const;
|
||||
void update();
|
||||
void sendPopulationUpdateToLoginServer();
|
||||
void sendMetricsToWebAPI();
|
||||
ConnectionServerConnection * getConnectionServerForAccount(StationId suid);
|
||||
void addToAccountConnectionMap(StationId suid, ConnectionServerConnection * cconn, uint32 subscriptionBits);
|
||||
void removeFromAccountConnectionMap(int connectionServerConnectionId);
|
||||
|
||||
@@ -148,7 +148,7 @@ void CentralServerMetricsData::updateData()
|
||||
// appear yellow to draw attention) for some amount of time
|
||||
// after detecting a system time mismatch issue
|
||||
#ifndef WIN32
|
||||
if ((lastTimeSystemTimeMismatchNotification + ConfigCentralServer::getSystemTimeMismatchAlertIntervalSeconds()) > ::time(NULL))
|
||||
if ((lastTimeSystemTimeMismatchNotification + ConfigCentralServer::getSystemTimeMismatchAlertIntervalSeconds()) > ::time(nullptr))
|
||||
m_data[m_systemTimeMismatch].m_value = STATUS_LOADING;
|
||||
else
|
||||
m_data[m_systemTimeMismatch].m_value = 1;
|
||||
@@ -202,7 +202,7 @@ void CentralServerMetricsData::updateData()
|
||||
std::string label("population.");
|
||||
label += iter->first;
|
||||
|
||||
m_mapPopulationStatisticsIndex[iter->first] = addMetric(label.c_str(), 0, NULL, false, false);
|
||||
m_mapPopulationStatisticsIndex[iter->first] = addMetric(label.c_str(), 0, nullptr, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -235,7 +235,7 @@ void CentralServerMetricsData::updateData()
|
||||
}
|
||||
else
|
||||
{
|
||||
gcwScoreStatisticsIndex = addMetric(iter->first.c_str(), 0, NULL, false, false);
|
||||
gcwScoreStatisticsIndex = addMetric(iter->first.c_str(), 0, nullptr, false, false);
|
||||
IGNORE_RETURN(m_mapGcwScoreStatisticsIndex.insert(std::make_pair(iter->first, gcwScoreStatisticsIndex)));
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ void CentralServerMetricsData::updateData()
|
||||
std::string label("population.");
|
||||
label += secondIter.first;
|
||||
|
||||
m_mapLastLoginTimeStatisticsIndex[secondIter.first] = addMetric(label.c_str(), 0, NULL, false, false);
|
||||
m_mapLastLoginTimeStatisticsIndex[secondIter.first] = addMetric(label.c_str(), 0, nullptr, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -288,7 +288,7 @@ void CentralServerMetricsData::updateData()
|
||||
std::string label("population.");
|
||||
label += iter->second.first;
|
||||
|
||||
m_mapCreateTimeStatisticsIndex[iter->second.first] = addMetric(label.c_str(), 0, NULL, false, false);
|
||||
m_mapCreateTimeStatisticsIndex[iter->second.first] = addMetric(label.c_str(), 0, nullptr, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,13 +26,13 @@
|
||||
|
||||
// ======================================================================
|
||||
|
||||
CharacterCreationTracker * CharacterCreationTracker::ms_instance = NULL;
|
||||
CharacterCreationTracker * CharacterCreationTracker::ms_instance = nullptr;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
void CharacterCreationTracker::install()
|
||||
{
|
||||
DEBUG_FATAL(ms_instance != NULL,("Called install() twice.\n"));
|
||||
DEBUG_FATAL(ms_instance != nullptr,("Called install() twice.\n"));
|
||||
ms_instance = new CharacterCreationTracker;
|
||||
ExitChain::add(CharacterCreationTracker::remove,"CharacterCreationTracker::remove");
|
||||
}
|
||||
@@ -354,8 +354,8 @@ void CharacterCreationTracker::setFastCreationLock(StationId account)
|
||||
|
||||
CharacterCreationTracker::CreationRecord::CreationRecord() :
|
||||
m_stage(S_queuedForGameServer),
|
||||
m_gameCreationRequest(NULL),
|
||||
m_loginCreationRequest(NULL),
|
||||
m_gameCreationRequest(nullptr),
|
||||
m_loginCreationRequest(nullptr),
|
||||
m_creationTime(ServerClock::getInstance().getGameTimeSeconds()),
|
||||
m_gameServerId(0),
|
||||
m_loginServerId(0),
|
||||
|
||||
@@ -74,7 +74,7 @@ void ConfigCentralServer::install(void)
|
||||
|
||||
KEY_INT (chatServicePort, 61232);
|
||||
KEY_INT (connectionServicePort, 0);
|
||||
KEY_INT (customerServicePort, 61242);
|
||||
KEY_INT (customerServicePort, 0);
|
||||
KEY_INT (gameServicePort, 44451);
|
||||
KEY_STRING (loginServerAddress, "127.0.0.1");
|
||||
KEY_INT (loginServerPort, 44452);
|
||||
@@ -127,6 +127,8 @@ void ConfigCentralServer::install(void)
|
||||
KEY_BOOL (disconnectDuplicateConnectionsOnOtherGalaxies, false);
|
||||
KEY_BOOL (requestDbSaveOnPlanetServerCrash, true);
|
||||
KEY_INT (maxTimeToWaitForPlanetServerStartSeconds, 5*60); // seconds
|
||||
KEY_STRING (metricsDataURL, "");
|
||||
KEY_INT (webUpdateIntervalSeconds, 0);
|
||||
|
||||
int index = 0;
|
||||
char const * result = 0;
|
||||
|
||||
@@ -71,6 +71,9 @@ public:
|
||||
bool requestDbSaveOnPlanetServerCrash;
|
||||
|
||||
int maxTimeToWaitForPlanetServerStartSeconds;
|
||||
|
||||
const char * metricsDataURL;
|
||||
int webUpdateIntervalSeconds;
|
||||
};
|
||||
|
||||
static const unsigned short getChatServicePort ();
|
||||
@@ -141,6 +144,8 @@ public:
|
||||
|
||||
static int getMaxTimeToWaitForPlanetServerStartSeconds();
|
||||
|
||||
static const char * getMetricsDataURL();
|
||||
static int getWebUpdateIntervalSeconds();
|
||||
private:
|
||||
static Data * data;
|
||||
};
|
||||
@@ -510,6 +515,20 @@ inline int ConfigCentralServer::getMaxTimeToWaitForPlanetServerStartSeconds()
|
||||
return data->maxTimeToWaitForPlanetServerStartSeconds;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline const char * ConfigCentralServer::getMetricsDataURL()
|
||||
{
|
||||
return data->metricsDataURL;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline int ConfigCentralServer::getWebUpdateIntervalSeconds()
|
||||
{
|
||||
return data->webUpdateIntervalSeconds;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif // _ConfigCentralServer_H
|
||||
|
||||
+264
-245
@@ -1,8 +1,6 @@
|
||||
// ConnectionServerConnection.cpp
|
||||
// copyright 2001 Verant Interactive
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "FirstCentralServer.h"
|
||||
@@ -25,6 +23,8 @@
|
||||
#include "sharedNetwork/NetworkSetupData.h"
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
|
||||
#include "sharedFoundation/CrcConstexpr.hpp"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
namespace ConnectionServerConnectionNamespace
|
||||
@@ -40,48 +40,50 @@ struct OnConnectionServerConnectionClosed {};
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
ConnectionServerConnection::ConnectionServerConnection(const std::string & a, const uint16 p) :
|
||||
ServerConnection (a, p, NetworkSetupData()),
|
||||
m_chatServicePort (0),
|
||||
m_csServicePort (0),
|
||||
m_clientServicePortPrivate (0),
|
||||
m_clientServicePortPublic (0),
|
||||
m_gameServicePort (0),
|
||||
m_id (0),
|
||||
m_pingPort (0),
|
||||
m_connectionServerNumber (0),
|
||||
m_gameServiceAddress (),
|
||||
m_playerCount (0),
|
||||
m_freeTrialCount (0),
|
||||
m_emptySceneCount (0),
|
||||
m_tutorialSceneCount (0),
|
||||
m_falconSceneCount (0),
|
||||
m_clientServiceAddress (),
|
||||
m_chatServiceAddress (),
|
||||
m_customerServiceAddress ()
|
||||
ServerConnection(a, p, NetworkSetupData()),
|
||||
m_chatServicePort(0),
|
||||
m_csServicePort(0),
|
||||
m_clientServicePortPrivate(0),
|
||||
m_clientServicePortPublic(0),
|
||||
m_gameServicePort(0),
|
||||
m_id(0),
|
||||
m_pingPort(0),
|
||||
m_connectionServerNumber(0),
|
||||
m_gameServiceAddress(),
|
||||
m_playerCount(0),
|
||||
m_freeTrialCount(0),
|
||||
m_emptySceneCount(0),
|
||||
m_tutorialSceneCount(0),
|
||||
m_falconSceneCount(0),
|
||||
m_clientServiceAddress(),
|
||||
m_chatServiceAddress(),
|
||||
m_customerServiceAddress(),
|
||||
m_voiceChatServicePort(0)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
ConnectionServerConnection::ConnectionServerConnection(UdpConnectionMT * u, TcpClient * t) :
|
||||
ServerConnection (u, t),
|
||||
m_chatServicePort (0),
|
||||
m_csServicePort (0),
|
||||
m_clientServicePortPrivate (0),
|
||||
m_clientServicePortPublic (0),
|
||||
m_gameServicePort (0),
|
||||
m_id (0),
|
||||
m_pingPort (0),
|
||||
m_connectionServerNumber (0),
|
||||
m_gameServiceAddress (),
|
||||
m_playerCount (0),
|
||||
m_freeTrialCount (0),
|
||||
m_emptySceneCount (0),
|
||||
m_tutorialSceneCount (0),
|
||||
m_falconSceneCount (0),
|
||||
m_clientServiceAddress (),
|
||||
m_chatServiceAddress (),
|
||||
m_customerServiceAddress ()
|
||||
ServerConnection(u, t),
|
||||
m_chatServicePort(0),
|
||||
m_csServicePort(0),
|
||||
m_clientServicePortPrivate(0),
|
||||
m_clientServicePortPublic(0),
|
||||
m_gameServicePort(0),
|
||||
m_id(0),
|
||||
m_pingPort(0),
|
||||
m_connectionServerNumber(0),
|
||||
m_gameServiceAddress(),
|
||||
m_playerCount(0),
|
||||
m_freeTrialCount(0),
|
||||
m_emptySceneCount(0),
|
||||
m_tutorialSceneCount(0),
|
||||
m_falconSceneCount(0),
|
||||
m_clientServiceAddress(),
|
||||
m_chatServiceAddress(),
|
||||
m_customerServiceAddress(),
|
||||
m_voiceChatServicePort(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -89,12 +91,12 @@ m_customerServiceAddress ()
|
||||
|
||||
ConnectionServerConnection::~ConnectionServerConnection()
|
||||
{
|
||||
// remove ConnectionServerConnection *'s from the
|
||||
// remove ConnectionServerConnection *'s from the
|
||||
// s_pseudoClientConnectionMap
|
||||
std::map<unsigned int, std::pair<TransferRequestMoveValidation::TransferRequestSource, ConnectionServerConnection *> >::iterator i;
|
||||
for(i = s_pseudoClientConnectionMap.begin(); i != s_pseudoClientConnectionMap.end();)
|
||||
for (i = s_pseudoClientConnectionMap.begin(); i != s_pseudoClientConnectionMap.end();)
|
||||
{
|
||||
if(i->second.second == this)
|
||||
if (i->second.second == this)
|
||||
{
|
||||
if (i->second.first == TransferRequestMoveValidation::TRS_transfer_server)
|
||||
{
|
||||
@@ -121,7 +123,7 @@ bool ConnectionServerConnection::sendToPseudoClientConnection(unsigned int stati
|
||||
{
|
||||
bool result = false;
|
||||
std::map<unsigned int, std::pair<TransferRequestMoveValidation::TransferRequestSource, ConnectionServerConnection *> >::iterator f = s_pseudoClientConnectionMap.find(stationId);
|
||||
if(f != s_pseudoClientConnectionMap.end())
|
||||
if (f != s_pseudoClientConnectionMap.end())
|
||||
{
|
||||
result = true;
|
||||
f->second.second->send(message, true);
|
||||
@@ -166,239 +168,256 @@ void ConnectionServerConnection::onReceive(const Archive::ByteStream & message)
|
||||
{
|
||||
Archive::ReadIterator ri = message.begin();
|
||||
GameNetworkMessage m(ri);
|
||||
ri = message.begin();
|
||||
ri = message.begin();
|
||||
|
||||
const uint32 messageType = m.getType();
|
||||
|
||||
if(m.isType("NewCentralConnectionServer"))
|
||||
{
|
||||
const NewCentralConnectionServer ncs(ri);
|
||||
|
||||
m_chatServicePort = ncs.getChatServicePort();
|
||||
m_csServicePort = ncs.getCustomerServicePort();
|
||||
|
||||
m_clientServicePortPrivate = ncs.getClientServicePortPrivate();
|
||||
m_clientServicePortPublic = ncs.getClientServicePortPublic();
|
||||
m_gameServicePort = ncs.getGameServicePort();
|
||||
m_pingPort = ncs.getPingPort ();
|
||||
m_connectionServerNumber = ncs.getConnectionServerNumber();
|
||||
m_gameServiceAddress = ncs.getGameServiceAddress();
|
||||
m_clientServiceAddress = ncs.getClientServiceAddress();
|
||||
m_chatServiceAddress = ncs.getChatServiceAddress();
|
||||
m_customerServiceAddress = ncs.getCustomerServiceAddress();
|
||||
|
||||
CentralServer::getInstance().addConnectionServerConnection(this);
|
||||
|
||||
//Now broadcast to gameservers
|
||||
ConnectionServerAddress const addressMessage(m_gameServiceAddress, m_gameServicePort);
|
||||
CentralServer::getInstance().broadcastToGameServers(addressMessage);
|
||||
|
||||
//Send to chat server
|
||||
const int ct = static_cast<int>(EnumerateServers::CONNECTION_SERVER);
|
||||
EnumerateServers e(true, getChatServiceAddress(), getChatServicePort(), ct);
|
||||
|
||||
if (!getChatServiceAddress().empty() && (getChatServicePort() != 0))
|
||||
switch(messageType) {
|
||||
case constcrc("NewCentralConnectionServer") :
|
||||
{
|
||||
CentralServer::getInstance().broadcastToChatServers(e);
|
||||
const NewCentralConnectionServer ncs(ri);
|
||||
|
||||
m_chatServicePort = ncs.getChatServicePort();
|
||||
m_csServicePort = ncs.getCustomerServicePort();
|
||||
|
||||
m_clientServicePortPrivate = ncs.getClientServicePortPrivate();
|
||||
m_clientServicePortPublic = ncs.getClientServicePortPublic();
|
||||
m_gameServicePort = ncs.getGameServicePort();
|
||||
m_pingPort = ncs.getPingPort();
|
||||
m_connectionServerNumber = ncs.getConnectionServerNumber();
|
||||
m_gameServiceAddress = ncs.getGameServiceAddress();
|
||||
m_clientServiceAddress = ncs.getClientServiceAddress();
|
||||
m_chatServiceAddress = ncs.getChatServiceAddress();
|
||||
m_customerServiceAddress = ncs.getCustomerServiceAddress();
|
||||
|
||||
CentralServer::getInstance().addConnectionServerConnection(this);
|
||||
|
||||
//Now broadcast to gameservers
|
||||
ConnectionServerAddress const addressMessage(m_gameServiceAddress, m_gameServicePort);
|
||||
CentralServer::getInstance().broadcastToGameServers(addressMessage);
|
||||
|
||||
//Send to chat server
|
||||
const int ct = static_cast<int>(EnumerateServers::CONNECTION_SERVER);
|
||||
EnumerateServers e(true, getChatServiceAddress(), getChatServicePort(), ct);
|
||||
|
||||
if (!getChatServiceAddress().empty() && (getChatServicePort() != 0))
|
||||
{
|
||||
CentralServer::getInstance().broadcastToChatServers(e);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("ChatServ", ("ConnectionServerConnection::onReceive() Chat service address and port are invalid, unable to CentralServer::getInstance().broadcastToChatServers()"));
|
||||
}
|
||||
|
||||
//Send to CS servers
|
||||
const EnumerateServers e2(true, getCustomerServiceAddress(), getCustomerServicePort(), ct);
|
||||
|
||||
if (!getCustomerServiceAddress().empty()
|
||||
&& (getCustomerServicePort() != 0))
|
||||
{
|
||||
CentralServer::getInstance().broadcastToCustomerServiceServers(e2);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("ChatServ", ("ConnectionServerConnection::onReceive() Customer service address and port are invalid, unable to CentralServer::getInstance().broadcastToCustomerServiceServers()"));
|
||||
}
|
||||
|
||||
//Send to login Servers
|
||||
if ((getClientServicePortPrivate() != 0) || (getClientServicePortPublic() != 0))
|
||||
{
|
||||
const LoginConnectionServerAddress csa(m_id, getClientServiceAddress(), getClientServicePortPrivate(),
|
||||
getClientServicePortPublic(), getPlayerCount(), getPingPort());
|
||||
CentralServer::getInstance().sendToAllLoginServers(csa);
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
case constcrc("UpdateConnectionServerStatus") :
|
||||
{
|
||||
LOG("ChatServ", ("ConnectionServerConnection::onReceive() Chat service address and port are invalid, unable to CentralServer::getInstance().broadcastToChatServers()"));
|
||||
DEBUG_REPORT_LOG(true, ("Got update status for connection server\n"));
|
||||
const UpdateConnectionServerStatus ucs(ri);
|
||||
m_clientServicePortPublic = ucs.getPublicPort();
|
||||
m_clientServicePortPrivate = ucs.getPrivatePort();
|
||||
UpdateLoginConnectionServerStatus ulc(getId(), m_clientServicePortPublic, m_clientServicePortPrivate, getPlayerCount());
|
||||
CentralServer::getInstance().sendToAllLoginServers(ulc);
|
||||
break;
|
||||
}
|
||||
|
||||
//Send to CS servers
|
||||
const EnumerateServers e2(true, getCustomerServiceAddress(), getCustomerServicePort(), ct);
|
||||
|
||||
if ( !getCustomerServiceAddress().empty()
|
||||
&& (getCustomerServicePort() != 0))
|
||||
case constcrc("TaskSpawnProcess") :
|
||||
{
|
||||
CentralServer::getInstance().broadcastToCustomerServiceServers(e2);
|
||||
const TaskSpawnProcess spawn(ri);
|
||||
CentralServer::getInstance().sendTaskMessage(spawn);
|
||||
break;
|
||||
}
|
||||
else
|
||||
case constcrc("NewPseudoClientConnection") :
|
||||
{
|
||||
LOG("ChatServ", ("ConnectionServerConnection::onReceive() Customer service address and port are invalid, unable to CentralServer::getInstance().broadcastToCustomerServiceServers()"));
|
||||
}
|
||||
const GenericValueTypeMessage<std::pair<unsigned int, int8> > info(ri);
|
||||
s_pseudoClientConnectionMap[info.getValue().first] = std::make_pair(static_cast<TransferRequestMoveValidation::TransferRequestSource>(info.getValue().second), this);
|
||||
|
||||
//Send to login Servers
|
||||
if ( (getClientServicePortPrivate() != 0) || (getClientServicePortPublic() != 0) )
|
||||
// remove corresponding "non pseudo client connection"
|
||||
CentralServer::getInstance().removeFromAccountConnectionMap(static_cast<StationId>(info.getValue().first));
|
||||
break;
|
||||
}
|
||||
case constcrc("DestroyPseudoClientConnection") :
|
||||
{
|
||||
const LoginConnectionServerAddress csa(m_id, getClientServiceAddress(), getClientServicePortPrivate(),
|
||||
getClientServicePortPublic(), getPlayerCount(), getPingPort ());
|
||||
CentralServer::getInstance().sendToAllLoginServers(csa);
|
||||
const GenericValueTypeMessage<unsigned int> info(ri);
|
||||
std::map<unsigned int, std::pair<TransferRequestMoveValidation::TransferRequestSource, ConnectionServerConnection *> >::iterator f = s_pseudoClientConnectionMap.find(info.getValue());
|
||||
if (f != s_pseudoClientConnectionMap.end())
|
||||
{
|
||||
s_pseudoClientConnectionMap.erase(f);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (m.isType("UpdateConnectionServerStatus"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, ("Got update status for connection server\n"));
|
||||
const UpdateConnectionServerStatus ucs(ri);
|
||||
m_clientServicePortPublic = ucs.getPublicPort();
|
||||
m_clientServicePortPrivate = ucs.getPrivatePort();
|
||||
UpdateLoginConnectionServerStatus ulc(getId(), m_clientServicePortPublic, m_clientServicePortPrivate, getPlayerCount());
|
||||
CentralServer::getInstance().sendToAllLoginServers(ulc);
|
||||
}
|
||||
|
||||
else if(m.isType("TaskSpawnProcess"))
|
||||
{
|
||||
const TaskSpawnProcess spawn(ri);
|
||||
CentralServer::getInstance().sendTaskMessage(spawn);
|
||||
}
|
||||
else if(m.isType("NewPseudoClientConnection"))
|
||||
{
|
||||
const GenericValueTypeMessage<std::pair<unsigned int, int8> > info(ri);
|
||||
s_pseudoClientConnectionMap[info.getValue().first] = std::make_pair(static_cast<TransferRequestMoveValidation::TransferRequestSource>(info.getValue().second), this);
|
||||
|
||||
// remove corresponding "non pseudo client connection"
|
||||
CentralServer::getInstance().removeFromAccountConnectionMap(static_cast<StationId>(info.getValue().first));
|
||||
}
|
||||
else if(m.isType("DestroyPseudoClientConnection"))
|
||||
{
|
||||
const GenericValueTypeMessage<unsigned int> info(ri);
|
||||
std::map<unsigned int, std::pair<TransferRequestMoveValidation::TransferRequestSource, ConnectionServerConnection *> >::iterator f = s_pseudoClientConnectionMap.find(info.getValue());
|
||||
if(f != s_pseudoClientConnectionMap.end())
|
||||
case constcrc("TransferReceiveDataFromGameServer") :
|
||||
{
|
||||
s_pseudoClientConnectionMap.erase(f);
|
||||
}
|
||||
}
|
||||
else if(m.isType("TransferReceiveDataFromGameServer"))
|
||||
{
|
||||
const GenericValueTypeMessage<TransferCharacterData> transferReply(ri);
|
||||
const GenericValueTypeMessage<TransferCharacterData> transferReply(ri);
|
||||
|
||||
if(transferReply.getValue().getTransferRequestSource() == TransferRequestMoveValidation::TRS_transfer_server)
|
||||
if (transferReply.getValue().getTransferRequestSource() == TransferRequestMoveValidation::TRS_transfer_server)
|
||||
{
|
||||
CentralServer::getInstance().sendToTransferServer(transferReply);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Got TransferReceiveDataFromGameServer: %s", transferReply.getValue().toString().c_str()));
|
||||
|
||||
// send character to ConnectionServer for creation on the destination server
|
||||
GenericValueTypeMessage<TransferCharacterData> login("TransferLoginCharacterToDestinationServer", transferReply.getValue());
|
||||
CentralServer::getInstance().sendToArbitraryLoginServer(login);
|
||||
LOG("CustomerService", ("CharacterTransfer: Sending TransferLoginCharacterToDestinationServer to CentralServer (via LoginServer) (%s) for (%s)", transferReply.getValue().getDestinationGalaxy().c_str(), login.getValue().toString().c_str()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case constcrc("ApplyTransferDataSuccess") :
|
||||
{
|
||||
CentralServer::getInstance().sendToTransferServer(transferReply);
|
||||
const GenericValueTypeMessage<TransferCharacterData> success(ri);
|
||||
|
||||
// send message to source galaxy (via LoginServer) to mark
|
||||
// the source character as having been transferred to prevent
|
||||
// all future login of the character
|
||||
{
|
||||
const GenericValueTypeMessage<std::pair<std::string, NetworkId> > msg("CtsCompletedForcharacter", std::make_pair(success.getValue().getSourceGalaxy(), success.getValue().getCharacterId()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(msg));
|
||||
}
|
||||
|
||||
// send the message back to the transfer server, which then
|
||||
// sends a disable login request to the source central server,
|
||||
// "removing" the account on the source galaxy.
|
||||
if (success.getValue().getTransferRequestSource() == TransferRequestMoveValidation::TRS_transfer_server)
|
||||
{
|
||||
CentralServer::getInstance().sendToTransferServer(success);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Received ApplyTransferDataSuccess from ConnectionServer. %s", success.getValue().toString().c_str()));
|
||||
LOG("CustomerService", ("CharacterTransfer: Sending ToggleAvatarLoginStatus request to LoginServer"));
|
||||
|
||||
const ToggleAvatarLoginStatus toggleLoginStatus(success.getValue().getSourceGalaxy(), success.getValue().getSourceStationId(), success.getValue().getCharacterId(), false);
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(toggleLoginStatus));
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
case constcrc("ApplyTransferDataFail") :
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Got TransferReceiveDataFromGameServer: %s", transferReply.getValue().toString().c_str()));
|
||||
const GenericValueTypeMessage<TransferCharacterData> fail(ri);
|
||||
|
||||
// send character to ConnectionServer for creation on the destination server
|
||||
GenericValueTypeMessage<TransferCharacterData> login("TransferLoginCharacterToDestinationServer", transferReply.getValue());
|
||||
CentralServer::getInstance().sendToArbitraryLoginServer(login);
|
||||
LOG("CustomerService", ("CharacterTransfer: Sending TransferLoginCharacterToDestinationServer to CentralServer (via LoginServer) (%s) for (%s)", transferReply.getValue().getDestinationGalaxy().c_str(), login.getValue().toString().c_str()));
|
||||
// send the message back to the transfer server, which then
|
||||
// sends a delete request to the destination central server,
|
||||
// "removing" the account on the destination galaxy.
|
||||
if (fail.getValue().getTransferRequestSource() == TransferRequestMoveValidation::TRS_transfer_server)
|
||||
{
|
||||
CentralServer::getInstance().sendToTransferServer(fail);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Received ApplyTransferDataFail from ConnectionServer. %s", fail.getValue().toString().c_str()));
|
||||
LOG("CustomerService", ("CharacterTransfer: failed to apply transfer data. Deleting character on destination server. %s", fail.getValue().toString().c_str()));
|
||||
|
||||
GenericValueTypeMessage<TransferCharacterData> const deleteCharacter("DeleteFailedTransfer", fail.getValue());
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(deleteCharacter));
|
||||
|
||||
GenericValueTypeMessage<std::pair<std::string, unsigned int> > const closeRequestSource("RequestTransferClosePseudoClientConnection", std::make_pair(fail.getValue().getSourceGalaxy(), fail.getValue().getSourceStationId()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(closeRequestSource));
|
||||
|
||||
GenericValueTypeMessage<std::pair<std::string, unsigned int> > const closeRequestTarget("RequestTransferClosePseudoClientConnection", std::make_pair(fail.getValue().getDestinationGalaxy(), fail.getValue().getDestinationStationId()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(closeRequestTarget));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(m.isType("ApplyTransferDataSuccess"))
|
||||
{
|
||||
const GenericValueTypeMessage<TransferCharacterData> success(ri);
|
||||
|
||||
// send message to source galaxy (via LoginServer) to mark
|
||||
// the source character as having been transferred to prevent
|
||||
// all future login of the character
|
||||
case constcrc("TransferCreateCharacterFailed") :
|
||||
{
|
||||
const GenericValueTypeMessage<std::pair<std::string, NetworkId> > msg("CtsCompletedForcharacter", std::make_pair(success.getValue().getSourceGalaxy(), success.getValue().getCharacterId()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(msg));
|
||||
}
|
||||
const GenericValueTypeMessage<TransferCharacterData> fail(ri);
|
||||
|
||||
// send the message back to the transfer server, which then
|
||||
// sends a disable login request to the source central server,
|
||||
// "removing" the account on the source galaxy.
|
||||
if(success.getValue().getTransferRequestSource() == TransferRequestMoveValidation::TRS_transfer_server)
|
||||
if (fail.getValue().getTransferRequestSource() == TransferRequestMoveValidation::TRS_transfer_server)
|
||||
{
|
||||
CentralServer::getInstance().sendToTransferServer(fail);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferCreateCharacterFailed. %s", fail.getValue().toString().c_str()));
|
||||
|
||||
GenericValueTypeMessage<std::pair<std::string, unsigned int> > const closeRequestSource("RequestTransferClosePseudoClientConnection", std::make_pair(fail.getValue().getSourceGalaxy(), fail.getValue().getSourceStationId()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(closeRequestSource));
|
||||
|
||||
GenericValueTypeMessage<std::pair<std::string, unsigned int> > const closeRequestTarget("RequestTransferClosePseudoClientConnection", std::make_pair(fail.getValue().getDestinationGalaxy(), fail.getValue().getDestinationStationId()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(closeRequestTarget));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case constcrc("ReplyTransferDataFail") :
|
||||
{
|
||||
CentralServer::getInstance().sendToTransferServer(success);
|
||||
const GenericValueTypeMessage<TransferCharacterData> reply(ri);
|
||||
|
||||
if (reply.getValue().getTransferRequestSource() == TransferRequestMoveValidation::TRS_transfer_server)
|
||||
{
|
||||
CentralServer::getInstance().sendToTransferServer(reply);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Transfer failed: Failed to retrieve character data. %s", reply.getValue().toString().c_str()));
|
||||
|
||||
GenericValueTypeMessage<std::pair<std::string, unsigned int> > const closeRequestSource("RequestTransferClosePseudoClientConnection", std::make_pair(reply.getValue().getSourceGalaxy(), reply.getValue().getSourceStationId()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(closeRequestSource));
|
||||
|
||||
GenericValueTypeMessage<std::pair<std::string, unsigned int> > const closeRequestTarget("RequestTransferClosePseudoClientConnection", std::make_pair(reply.getValue().getDestinationGalaxy(), reply.getValue().getDestinationStationId()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(closeRequestTarget));
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
case constcrc("TransferFailGameServerClosedConnectionWithConnectionServer") :
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Received ApplyTransferDataSuccess from ConnectionServer. %s", success.getValue().toString().c_str()));
|
||||
LOG("CustomerService", ("CharacterTransfer: Sending ToggleAvatarLoginStatus request to LoginServer"));
|
||||
const GenericValueTypeMessage<TransferCharacterData> fail(ri);
|
||||
|
||||
const ToggleAvatarLoginStatus toggleLoginStatus(success.getValue().getSourceGalaxy(), success.getValue().getSourceStationId(), success.getValue().getCharacterId(), false);
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(toggleLoginStatus));
|
||||
if (fail.getValue().getTransferRequestSource() == TransferRequestMoveValidation::TRS_transfer_server)
|
||||
{
|
||||
CentralServer::getInstance().sendToTransferServer(fail);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Transfer failed: GameServer connection closed while transfer was in progress. %s", fail.getValue().toString().c_str()));
|
||||
|
||||
GenericValueTypeMessage<std::pair<std::string, unsigned int> > const closeRequestSource("RequestTransferClosePseudoClientConnection", std::make_pair(fail.getValue().getSourceGalaxy(), fail.getValue().getSourceStationId()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(closeRequestSource));
|
||||
|
||||
GenericValueTypeMessage<std::pair<std::string, unsigned int> > const closeRequestTarget("RequestTransferClosePseudoClientConnection", std::make_pair(fail.getValue().getDestinationGalaxy(), fail.getValue().getDestinationStationId()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(closeRequestTarget));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(m.isType("ApplyTransferDataFail"))
|
||||
{
|
||||
const GenericValueTypeMessage<TransferCharacterData> fail(ri);
|
||||
|
||||
// send the message back to the transfer server, which then
|
||||
// sends a delete request to the destination central server,
|
||||
// "removing" the account on the destination galaxy.
|
||||
if(fail.getValue().getTransferRequestSource() == TransferRequestMoveValidation::TRS_transfer_server)
|
||||
case constcrc("AccountFeatureIdRequest") :
|
||||
{
|
||||
CentralServer::getInstance().sendToTransferServer(fail);
|
||||
const AccountFeatureIdRequest msg(ri);
|
||||
CentralServer::getInstance().sendToArbitraryLoginServer(msg);
|
||||
break;
|
||||
}
|
||||
else
|
||||
case constcrc("AdjustAccountFeatureIdRequest") :
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Received ApplyTransferDataFail from ConnectionServer. %s", fail.getValue().toString().c_str()));
|
||||
LOG("CustomerService", ("CharacterTransfer: failed to apply transfer data. Deleting character on destination server. %s", fail.getValue().toString().c_str()));
|
||||
|
||||
GenericValueTypeMessage<TransferCharacterData> const deleteCharacter("DeleteFailedTransfer", fail.getValue());
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(deleteCharacter));
|
||||
|
||||
GenericValueTypeMessage<std::pair<std::string, unsigned int> > const closeRequestSource("RequestTransferClosePseudoClientConnection", std::make_pair(fail.getValue().getSourceGalaxy(), fail.getValue().getSourceStationId()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(closeRequestSource));
|
||||
|
||||
GenericValueTypeMessage<std::pair<std::string, unsigned int> > const closeRequestTarget("RequestTransferClosePseudoClientConnection", std::make_pair(fail.getValue().getDestinationGalaxy(), fail.getValue().getDestinationStationId()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(closeRequestTarget));
|
||||
const AdjustAccountFeatureIdRequest msg(ri);
|
||||
CentralServer::getInstance().sendToArbitraryLoginServer(msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(m.isType("TransferCreateCharacterFailed"))
|
||||
{
|
||||
const GenericValueTypeMessage<TransferCharacterData> fail(ri);
|
||||
|
||||
if(fail.getValue().getTransferRequestSource() == TransferRequestMoveValidation::TRS_transfer_server)
|
||||
default :
|
||||
{
|
||||
CentralServer::getInstance().sendToTransferServer(fail);
|
||||
ServerConnection::onReceive(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferCreateCharacterFailed. %s", fail.getValue().toString().c_str()));
|
||||
|
||||
GenericValueTypeMessage<std::pair<std::string, unsigned int> > const closeRequestSource("RequestTransferClosePseudoClientConnection", std::make_pair(fail.getValue().getSourceGalaxy(), fail.getValue().getSourceStationId()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(closeRequestSource));
|
||||
|
||||
GenericValueTypeMessage<std::pair<std::string, unsigned int> > const closeRequestTarget("RequestTransferClosePseudoClientConnection", std::make_pair(fail.getValue().getDestinationGalaxy(), fail.getValue().getDestinationStationId()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(closeRequestTarget));
|
||||
}
|
||||
}
|
||||
else if(m.isType("ReplyTransferDataFail"))
|
||||
{
|
||||
const GenericValueTypeMessage<TransferCharacterData> reply(ri);
|
||||
|
||||
if(reply.getValue().getTransferRequestSource() == TransferRequestMoveValidation::TRS_transfer_server)
|
||||
{
|
||||
CentralServer::getInstance().sendToTransferServer(reply);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Transfer failed: Failed to retrieve character data. %s", reply.getValue().toString().c_str()));
|
||||
|
||||
GenericValueTypeMessage<std::pair<std::string, unsigned int> > const closeRequestSource("RequestTransferClosePseudoClientConnection", std::make_pair(reply.getValue().getSourceGalaxy(), reply.getValue().getSourceStationId()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(closeRequestSource));
|
||||
|
||||
GenericValueTypeMessage<std::pair<std::string, unsigned int> > const closeRequestTarget("RequestTransferClosePseudoClientConnection", std::make_pair(reply.getValue().getDestinationGalaxy(), reply.getValue().getDestinationStationId()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(closeRequestTarget));
|
||||
}
|
||||
}
|
||||
else if(m.isType("TransferFailGameServerClosedConnectionWithConnectionServer"))
|
||||
{
|
||||
const GenericValueTypeMessage<TransferCharacterData> fail(ri);
|
||||
|
||||
if(fail.getValue().getTransferRequestSource() == TransferRequestMoveValidation::TRS_transfer_server)
|
||||
{
|
||||
CentralServer::getInstance().sendToTransferServer(fail);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Transfer failed: GameServer connection closed while transfer was in progress. %s", fail.getValue().toString().c_str()));
|
||||
|
||||
GenericValueTypeMessage<std::pair<std::string, unsigned int> > const closeRequestSource("RequestTransferClosePseudoClientConnection", std::make_pair(fail.getValue().getSourceGalaxy(), fail.getValue().getSourceStationId()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(closeRequestSource));
|
||||
|
||||
GenericValueTypeMessage<std::pair<std::string, unsigned int> > const closeRequestTarget("RequestTransferClosePseudoClientConnection", std::make_pair(fail.getValue().getDestinationGalaxy(), fail.getValue().getDestinationStationId()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(closeRequestTarget));
|
||||
}
|
||||
}
|
||||
else if(m.isType("AccountFeatureIdRequest"))
|
||||
{
|
||||
const AccountFeatureIdRequest msg(ri);
|
||||
CentralServer::getInstance().sendToArbitraryLoginServer(msg);
|
||||
}
|
||||
else if(m.isType("AdjustAccountFeatureIdRequest"))
|
||||
{
|
||||
const AdjustAccountFeatureIdRequest msg(ri);
|
||||
CentralServer::getInstance().sendToArbitraryLoginServer(msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerConnection::onReceive(message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -408,7 +427,7 @@ ConnectionServerConnection * ConnectionServerConnection::getConnectionForAccount
|
||||
{
|
||||
ConnectionServerConnection * result = 0;
|
||||
std::map<unsigned int, std::pair<TransferRequestMoveValidation::TransferRequestSource, ConnectionServerConnection *> >::iterator f = s_pseudoClientConnectionMap.find(stationId);
|
||||
if(f != s_pseudoClientConnectionMap.end())
|
||||
if (f != s_pseudoClientConnectionMap.end())
|
||||
{
|
||||
result = f->second.second;
|
||||
}
|
||||
@@ -424,4 +443,4 @@ void ConnectionServerConnection::removeFromAccountConnectionMap(unsigned int sta
|
||||
{
|
||||
s_pseudoClientConnectionMap.erase(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -117,8 +117,8 @@ bool ConsoleCommandParserGame::performParsing(const NetworkId & track, const Str
|
||||
if( argv.size() > 4 )
|
||||
{
|
||||
LOG("ServerConsole", ("Received command to shutdown the cluster."));
|
||||
uint32 timeToShutdown = strtoul(Unicode::wideToNarrow(argv[2]).c_str(), NULL, 10);
|
||||
uint32 maxTime = strtoul(Unicode::wideToNarrow(argv[3]).c_str(), NULL, 10);
|
||||
uint32 timeToShutdown = strtoul(Unicode::wideToNarrow(argv[2]).c_str(), nullptr, 10);
|
||||
uint32 maxTime = strtoul(Unicode::wideToNarrow(argv[3]).c_str(), nullptr, 10);
|
||||
Unicode::String systemMessage = Unicode::narrowToWide("");
|
||||
for(unsigned int i = 4; i < argv.size(); ++i)
|
||||
{
|
||||
@@ -141,7 +141,7 @@ bool ConsoleCommandParserGame::performParsing(const NetworkId & track, const Str
|
||||
{
|
||||
if(argv.size() > 1)
|
||||
{
|
||||
unsigned int stationId = strtoul(Unicode::wideToNarrow(argv[2]).c_str(), NULL, 10);
|
||||
unsigned int stationId = strtoul(Unicode::wideToNarrow(argv[2]).c_str(), nullptr, 10);
|
||||
if(stationId > 0)
|
||||
{
|
||||
GenericValueTypeMessage<unsigned int> auth("AuthorizeDownload", stationId);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
namespace ConsoleManagerNamespace
|
||||
{
|
||||
ConsoleCommandParser * s_consoleCommandParserRoot = NULL;
|
||||
ConsoleCommandParser * s_consoleCommandParserRoot = nullptr;
|
||||
}
|
||||
|
||||
using namespace ConsoleManagerNamespace;
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
#include "unicodeArchive/UnicodeArchive.h"
|
||||
|
||||
#include "sharedFoundation/CrcConstexpr.hpp"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
GameServerConnection::GameServerConnection(UdpConnectionMT *u, TcpClient *t) :
|
||||
@@ -88,289 +90,331 @@ void GameServerConnection::onReceive(Archive::ByteStream const &message)
|
||||
Archive::ReadIterator ri = message.begin();
|
||||
GameNetworkMessage const m(ri);
|
||||
ri = message.begin();
|
||||
|
||||
const uint32 messageType = m.getType();
|
||||
|
||||
if (m.isType("CentralGameServerConnect"))
|
||||
{
|
||||
CentralGameServerConnect const c(ri);
|
||||
setClientServiceAddress(c.getClientServiceAddress());
|
||||
setClientServicePort(c.getClientServicePort());
|
||||
setGameServiceAddress(c.getGameServiceAddress());
|
||||
setGameServicePort(c.getGameServicePort());
|
||||
setSceneId(c.getVolumeName());
|
||||
}
|
||||
else if (m.isType("GameServerUniverseLoadedMessage"))
|
||||
{
|
||||
m_ready = true;
|
||||
|
||||
if (ConfigCentralServer::getGameServerConnectionPendingAllocatedSizeLimit() != 0)
|
||||
setTcpClientPendingSendAllocatedSizeLimit(0);
|
||||
}
|
||||
else if (m.isType("TaskSpawnProcess"))
|
||||
{
|
||||
TaskSpawnProcess const spawn(ri);
|
||||
CentralServer::getInstance().sendTaskMessage(spawn);
|
||||
}
|
||||
else if (m.isType("ConGenericMessage"))
|
||||
{
|
||||
ConGenericMessage const con(ri);
|
||||
ConsoleConnection::onCommandComplete(con.getMsg(), static_cast<int>(con.getMsgId()));
|
||||
}
|
||||
else if (m.isType("TransferReplyNameValidation"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::string, TransferCharacterData> > const replyNameValidation(ri);
|
||||
|
||||
if (replyNameValidation.getValue().second.getTransferRequestSource() == TransferRequestMoveValidation::TRS_transfer_server)
|
||||
switch(messageType) {
|
||||
case constcrc("CentralGameServerConnect") :
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferReplyNameValidation from GameServer, forwarding to TransferServer : %s", replyNameValidation.getValue().second.toString().c_str()));
|
||||
CentralServer::getInstance().sendToTransferServer(replyNameValidation);
|
||||
CentralGameServerConnect const c(ri);
|
||||
setClientServiceAddress(c.getClientServiceAddress());
|
||||
setClientServicePort(c.getClientServicePort());
|
||||
setGameServiceAddress(c.getGameServiceAddress());
|
||||
setGameServicePort(c.getGameServicePort());
|
||||
setSceneId(c.getVolumeName());
|
||||
break;
|
||||
}
|
||||
else
|
||||
case constcrc("GameServerUniverseLoadedMessage") :
|
||||
{
|
||||
// pass reply back to the source galaxy for handling, which is to
|
||||
// either display an error message to the user if the request failed,
|
||||
// or to start the transfer process if the request succeeds
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferReplyNameValidation from GameServer, forwarding to source galaxy CentralServer : %s", replyNameValidation.getValue().second.toString().c_str()));
|
||||
CentralServer::getInstance().sendToArbitraryLoginServer(replyNameValidation);
|
||||
m_ready = true;
|
||||
|
||||
// if the request succeeded, also disconnect any clients with a connection to SWG services on this (the target) galaxy
|
||||
if (replyNameValidation.getValue().second.getIsValidName() && (replyNameValidation.getValue().second.getTransferRequestSource() != TransferRequestMoveValidation::TRS_ingame_freects_command_validate) && (replyNameValidation.getValue().second.getTransferRequestSource() != TransferRequestMoveValidation::TRS_ingame_cts_command_validate))
|
||||
if (ConfigCentralServer::getGameServerConnectionPendingAllocatedSizeLimit() != 0)
|
||||
setTcpClientPendingSendAllocatedSizeLimit(0);
|
||||
break;
|
||||
}
|
||||
case constcrc("TaskSpawnProcess") :
|
||||
{
|
||||
TaskSpawnProcess const spawn(ri);
|
||||
CentralServer::getInstance().sendTaskMessage(spawn);
|
||||
break;
|
||||
}
|
||||
case constcrc("ConGenericMessage") :
|
||||
{
|
||||
ConGenericMessage const con(ri);
|
||||
ConsoleConnection::onCommandComplete(con.getMsg(), static_cast<int>(con.getMsgId()));
|
||||
break;
|
||||
}
|
||||
case constcrc("TransferReplyNameValidation") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::string, TransferCharacterData> > const replyNameValidation(ri);
|
||||
|
||||
if (replyNameValidation.getValue().second.getTransferRequestSource() == TransferRequestMoveValidation::TRS_transfer_server)
|
||||
{
|
||||
GenericValueTypeMessage<unsigned int> kickSource("TransferKickConnectedClients", replyNameValidation.getValue().second.getSourceStationId());
|
||||
GenericValueTypeMessage<unsigned int> kickDestination("TransferKickConnectedClients", replyNameValidation.getValue().second.getDestinationStationId());
|
||||
CentralServer::getInstance().sendToAllLoginServers(kickSource);
|
||||
CentralServer::getInstance().sendToAllLoginServers(kickDestination);
|
||||
CentralServer::getInstance().sendToAllConnectionServers(kickSource, true);
|
||||
CentralServer::getInstance().sendToAllConnectionServers(kickDestination, true);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferReplyNameValidation from GameServer, forwarding to TransferServer : %s", replyNameValidation.getValue().second.toString().c_str()));
|
||||
CentralServer::getInstance().sendToTransferServer(replyNameValidation);
|
||||
}
|
||||
else
|
||||
{
|
||||
// pass reply back to the source galaxy for handling, which is to
|
||||
// either display an error message to the user if the request failed,
|
||||
// or to start the transfer process if the request succeeds
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferReplyNameValidation from GameServer, forwarding to source galaxy CentralServer : %s", replyNameValidation.getValue().second.toString().c_str()));
|
||||
CentralServer::getInstance().sendToArbitraryLoginServer(replyNameValidation);
|
||||
|
||||
// if the request succeeded, also disconnect any clients with a connection to SWG services on this (the target) galaxy
|
||||
if (replyNameValidation.getValue().second.getIsValidName() && (replyNameValidation.getValue().second.getTransferRequestSource() != TransferRequestMoveValidation::TRS_ingame_freects_command_validate) && (replyNameValidation.getValue().second.getTransferRequestSource() != TransferRequestMoveValidation::TRS_ingame_cts_command_validate))
|
||||
{
|
||||
GenericValueTypeMessage<unsigned int> kickSource("TransferKickConnectedClients", replyNameValidation.getValue().second.getSourceStationId());
|
||||
GenericValueTypeMessage<unsigned int> kickDestination("TransferKickConnectedClients", replyNameValidation.getValue().second.getDestinationStationId());
|
||||
CentralServer::getInstance().sendToAllLoginServers(kickSource);
|
||||
CentralServer::getInstance().sendToAllLoginServers(kickDestination);
|
||||
CentralServer::getInstance().sendToAllConnectionServers(kickSource, true);
|
||||
CentralServer::getInstance().sendToAllConnectionServers(kickDestination, true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (m.isType("TransferReplyCharacterList"))
|
||||
{
|
||||
// forward the message to the TransferServer
|
||||
TransferReplyCharacterList const reply(ri);
|
||||
CentralServer::getInstance().sendToTransferServer(reply);
|
||||
}
|
||||
else if (m.isType("TransferRenameCharacterReplyFromDatabase"))
|
||||
{
|
||||
GenericValueTypeMessage<TransferCharacterData> const renameReplyFromDatabase(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferRenameCharacterReplyFromDatabase %s", renameReplyFromDatabase.getValue().toString().c_str()));
|
||||
if (renameReplyFromDatabase.getValue().getIsValidName())
|
||||
case constcrc("TransferReplyCharacterList") :
|
||||
{
|
||||
// forward to LoginServer
|
||||
LOG("CustomerService", ("CharacterTransfer: Sending TransferRenameCharacterInLoginDatabase request to Login Database"));
|
||||
GenericValueTypeMessage<TransferCharacterData> const request("TransferRenameCharacterInLoginDatabase", renameReplyFromDatabase.getValue());
|
||||
CentralServer::getInstance().sendToArbitraryLoginServer(request);
|
||||
// forward the message to the TransferServer
|
||||
TransferReplyCharacterList const reply(ri);
|
||||
CentralServer::getInstance().sendToTransferServer(reply);
|
||||
break;
|
||||
}
|
||||
else
|
||||
case constcrc("TransferRenameCharacterReplyFromDatabase") :
|
||||
{
|
||||
// send failure back to TransferServer
|
||||
LOG("CustomerService", ("CharacterTransfer: Character rename request failed in the game database. %s", renameReplyFromDatabase.getValue().toString().c_str()));
|
||||
GenericValueTypeMessage<TransferCharacterData> const transferRenameCharacterReply("TransferRenameCharacterReply", renameReplyFromDatabase.getValue());
|
||||
GenericValueTypeMessage<TransferCharacterData> const renameReplyFromDatabase(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferRenameCharacterReplyFromDatabase %s", renameReplyFromDatabase.getValue().toString().c_str()));
|
||||
if (renameReplyFromDatabase.getValue().getIsValidName())
|
||||
{
|
||||
// forward to LoginServer
|
||||
LOG("CustomerService", ("CharacterTransfer: Sending TransferRenameCharacterInLoginDatabase request to Login Database"));
|
||||
GenericValueTypeMessage<TransferCharacterData> const request("TransferRenameCharacterInLoginDatabase", renameReplyFromDatabase.getValue());
|
||||
CentralServer::getInstance().sendToArbitraryLoginServer(request);
|
||||
}
|
||||
else
|
||||
{
|
||||
// send failure back to TransferServer
|
||||
LOG("CustomerService", ("CharacterTransfer: Character rename request failed in the game database. %s", renameReplyFromDatabase.getValue().toString().c_str()));
|
||||
GenericValueTypeMessage<TransferCharacterData> const transferRenameCharacterReply("TransferRenameCharacterReply", renameReplyFromDatabase.getValue());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (m.isType("LocateObject"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<uint32, std::pair<NetworkId, NetworkId> > > const msg(ri);
|
||||
CentralServer::getInstance().sendToAllGameServersExceptDBProcess(msg, true);
|
||||
}
|
||||
else if (m.isType("LocateObjectByTemplateName"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<uint32, std::pair<uint32, NetworkId> > > const msg(ri);
|
||||
CentralServer::getInstance().sendToAllGameServersExceptDBProcess(msg, true);
|
||||
}
|
||||
else if (m.isType("LocateObjectResponseMessage"))
|
||||
{
|
||||
LocateObjectResponseMessage const msg(ri);
|
||||
CentralServer::getInstance().sendToGameServer(msg.getResponsePid(), msg, true);
|
||||
}
|
||||
else if (m.isType("LocatePlayerByPartialName"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<uint32, std::pair<std::string, NetworkId> > > const msg(ri);
|
||||
CentralServer::getInstance().sendToAllGameServersExceptDBProcess(msg, true);
|
||||
}
|
||||
else if (m.isType("LocateWarden"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<uint32, NetworkId> > const msg(ri);
|
||||
CentralServer::getInstance().sendToAllGameServersExceptDBProcess(msg, true);
|
||||
}
|
||||
else if (m.isType("LocateCreatureByCreatureName"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<uint32, std::pair<std::string, NetworkId> > > const msg(ri);
|
||||
CentralServer::getInstance().sendToAllGameServersExceptDBProcess(msg, true);
|
||||
}
|
||||
else if (m.isType("LocatePlayerResponseMessage"))
|
||||
{
|
||||
LocatePlayerResponseMessage const msg(ri);
|
||||
CentralServer::getInstance().sendToGameServer(msg.getResponsePid(), msg, true);
|
||||
}
|
||||
else if (m.isType("LSBOIReq"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::pair<uint32, bool>, std::pair<std::pair<NetworkId, NetworkId>, NetworkId> > > const locateStructureByOwnerIdReq(ri);
|
||||
CentralServer::getInstance().sendToAllGameServersExceptDBProcess(locateStructureByOwnerIdReq, true);
|
||||
}
|
||||
else if (m.isType("LSBOIRsp"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::pair<uint32, NetworkId>, std::vector<std::string> > > const locateStructureByOwnerIdRsp(ri);
|
||||
CentralServer::getInstance().sendToGameServer(locateStructureByOwnerIdRsp.getValue().first.first, locateStructureByOwnerIdRsp, true);
|
||||
}
|
||||
else if (m.isType("ReportSystemClockTime"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<uint32, NetworkId> > const msg(ri);
|
||||
CentralServer::getInstance().sendToAllGameServersExceptDBProcess(msg, true);
|
||||
}
|
||||
else if (m.isType("ReportSystemClockTimeResponse"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<uint32, std::pair<std::string, NetworkId> > > const msg(ri);
|
||||
CentralServer::getInstance().sendToGameServer(msg.getValue().first, msg, true);
|
||||
}
|
||||
else if (m.isType("ReportPlanetaryTime"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<uint32, NetworkId> > const msg(ri);
|
||||
CentralServer::getInstance().sendToAllGameServersExceptDBProcess(msg, true);
|
||||
}
|
||||
else if (m.isType("ReportPlanetaryTimeResponse"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<uint32, std::pair<std::string, NetworkId> > > const msg(ri);
|
||||
CentralServer::getInstance().sendToGameServer(msg.getValue().first, msg, true);
|
||||
}
|
||||
else if (m.isType("TeleportToMessage"))
|
||||
{
|
||||
TeleportToMessage const msg(ri);
|
||||
CentralServer::getInstance().sendToAllGameServersExceptDBProcess(msg, true);
|
||||
}
|
||||
else if (m.isType("LoginToggleCompletedTutorial"))
|
||||
{
|
||||
GenericValueTypeMessage< std::pair<unsigned int, bool> > const msg(ri);
|
||||
CentralServer::getInstance().sendToArbitraryLoginServer(msg);
|
||||
}
|
||||
else if( m.isType( "GameServerCSResponse" ) )
|
||||
{
|
||||
GameServerCSResponseMessage const msg( ri );
|
||||
CSToolResponse rmsg( msg.getAccountId(),
|
||||
msg.getResponse(),
|
||||
msg.getToolId() );
|
||||
CentralServer::getInstance().sendToLoginServer( msg.getLoginServerID(), rmsg );
|
||||
}
|
||||
else if( m.isType( "GetCharactersForAccountCSReplyMsg" ) )
|
||||
{
|
||||
GetCharactersForAccountCSReplyMsg const msg( ri );
|
||||
// send repsonse to tool.
|
||||
char buf[ 256 ];
|
||||
snprintf( buf, 255, "Character search for %lu\r\n", msg.getTargetAccountId() );
|
||||
std::string response = buf;
|
||||
response = response + msg.getResponse();
|
||||
|
||||
CSToolResponse rmsg( msg.getAccountId(),
|
||||
response,
|
||||
msg.getToolId() );
|
||||
CentralServer::getInstance().sendToLoginServer( msg.getLoginServerId(), rmsg );
|
||||
}
|
||||
else if( m.isType( "GetDeletedItemsReplyMessage" ) )
|
||||
{
|
||||
GetDeletedItemsReplyMessage const msg( ri );
|
||||
char buf[ 256 ];
|
||||
snprintf( buf, 255, "Deleted items for %s\r\n", msg.getCharacterId().getValueString().c_str() );
|
||||
std::string response = buf;
|
||||
response = response + msg.getResponse();
|
||||
CSToolResponse rmsg( msg.getAccountId(),
|
||||
response,
|
||||
msg.getToolId() );
|
||||
CentralServer::getInstance().sendToLoginServer( msg.getLoginServerId(), rmsg );
|
||||
|
||||
}
|
||||
else if( m.isType( "GetCharacterIdReplyMessage" ) )
|
||||
{
|
||||
GetCharacterIdReplyMessage const msg( ri );
|
||||
std::string response = "Character id for ";
|
||||
response = response + msg.getCharacterName() + "\r\n";
|
||||
response = response + "character id:" + msg.getCharacterId().getValueString() + "\r\n";
|
||||
char buf[ 64 ];
|
||||
|
||||
snprintf( buf, 64, "%lu", msg.getAccountId() );
|
||||
|
||||
response = response + "account id:" + buf + "\r\n";
|
||||
|
||||
CSToolResponse rmsg( msg.getAccountId(), response, msg.getToolId() );
|
||||
CentralServer::getInstance().sendToLoginServer( msg.getLoginServerId(), rmsg );
|
||||
|
||||
}
|
||||
else if( m.isType( "CSFindAuthObjectReply" ) )
|
||||
{
|
||||
GenericValueTypeMessage< std::pair< unsigned int, bool > > const msg( ri );
|
||||
CentralCSHandler::getInstance().handleFindObjectResponse( msg.getValue().first, msg.getValue().second );
|
||||
}
|
||||
else if(m.isType("StructureListMessage"))
|
||||
{
|
||||
StructureListMessage msg(ri);
|
||||
CentralCSHandler::getInstance().handleStructureListResponse(msg);
|
||||
}
|
||||
else if (m.isType("SPCharacterProfileMessage"))
|
||||
{
|
||||
SPCharacterProfileMessage const msg(ri);
|
||||
CentralServer::getInstance().sendToStationPlayersCollector(msg);
|
||||
}
|
||||
else if (m.isType("OccupyUnlockedSlotReq"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::pair<uint32, NetworkId>, uint32> > const occupyUnlockedSlotReq(ri);
|
||||
CentralServer::getInstance().sendToArbitraryLoginServer(occupyUnlockedSlotReq);
|
||||
}
|
||||
else if (m.isType("VacateUnlockedSlotReq"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::pair<uint32, NetworkId>, uint32> > const vacateUnlockedSlotReq(ri);
|
||||
CentralServer::getInstance().sendToArbitraryLoginServer(vacateUnlockedSlotReq);
|
||||
case constcrc("LocateObject") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<uint32, std::pair<NetworkId, NetworkId> > > const msg(ri);
|
||||
CentralServer::getInstance().sendToAllGameServersExceptDBProcess(msg, true);
|
||||
break;
|
||||
}
|
||||
case constcrc("LocateObjectByTemplateName") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<uint32, std::pair<uint32, NetworkId> > > const msg(ri);
|
||||
CentralServer::getInstance().sendToAllGameServersExceptDBProcess(msg, true);
|
||||
break;
|
||||
}
|
||||
case constcrc("LocateObjectResponseMessage") :
|
||||
{
|
||||
LocateObjectResponseMessage const msg(ri);
|
||||
CentralServer::getInstance().sendToGameServer(msg.getResponsePid(), msg, true);
|
||||
break;
|
||||
}
|
||||
case constcrc("LocatePlayerByPartialName") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<uint32, std::pair<std::string, NetworkId> > > const msg(ri);
|
||||
CentralServer::getInstance().sendToAllGameServersExceptDBProcess(msg, true);
|
||||
break;
|
||||
}
|
||||
case constcrc("LocateWarden") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<uint32, NetworkId> > const msg(ri);
|
||||
CentralServer::getInstance().sendToAllGameServersExceptDBProcess(msg, true);
|
||||
break;
|
||||
}
|
||||
case constcrc("LocateCreatureByCreatureName") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<uint32, std::pair<std::string, NetworkId> > > const msg(ri);
|
||||
CentralServer::getInstance().sendToAllGameServersExceptDBProcess(msg, true);
|
||||
break;
|
||||
}
|
||||
case constcrc("LocatePlayerResponseMessage") :
|
||||
{
|
||||
LocatePlayerResponseMessage const msg(ri);
|
||||
CentralServer::getInstance().sendToGameServer(msg.getResponsePid(), msg, true);
|
||||
break;
|
||||
}
|
||||
case constcrc("LSBOIReq") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::pair<uint32, bool>, std::pair<std::pair<NetworkId, NetworkId>, NetworkId> > > const locateStructureByOwnerIdReq(ri);
|
||||
CentralServer::getInstance().sendToAllGameServersExceptDBProcess(locateStructureByOwnerIdReq, true);
|
||||
break;
|
||||
}
|
||||
case constcrc("LSBOIRsp") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::pair<uint32, NetworkId>, std::vector<std::string> > > const locateStructureByOwnerIdRsp(ri);
|
||||
CentralServer::getInstance().sendToGameServer(locateStructureByOwnerIdRsp.getValue().first.first, locateStructureByOwnerIdRsp, true);
|
||||
break;
|
||||
}
|
||||
case constcrc("ReportSystemClockTime") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<uint32, NetworkId> > const msg(ri);
|
||||
CentralServer::getInstance().sendToAllGameServersExceptDBProcess(msg, true);
|
||||
break;
|
||||
}
|
||||
case constcrc("ReportSystemClockTimeResponse") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<uint32, std::pair<std::string, NetworkId> > > const msg(ri);
|
||||
CentralServer::getInstance().sendToGameServer(msg.getValue().first, msg, true);
|
||||
break;
|
||||
}
|
||||
case constcrc("ReportPlanetaryTime") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<uint32, NetworkId> > const msg(ri);
|
||||
CentralServer::getInstance().sendToAllGameServersExceptDBProcess(msg, true);
|
||||
break;
|
||||
}
|
||||
case constcrc("ReportPlanetaryTimeResponse") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<uint32, std::pair<std::string, NetworkId> > > const msg(ri);
|
||||
CentralServer::getInstance().sendToGameServer(msg.getValue().first, msg, true);
|
||||
break;
|
||||
}
|
||||
case constcrc("TeleportToMessage") :
|
||||
{
|
||||
TeleportToMessage const msg(ri);
|
||||
CentralServer::getInstance().sendToAllGameServersExceptDBProcess(msg, true);
|
||||
break;
|
||||
}
|
||||
case constcrc("LoginToggleCompletedTutorial") :
|
||||
{
|
||||
GenericValueTypeMessage< std::pair<unsigned int, bool> > const msg(ri);
|
||||
CentralServer::getInstance().sendToArbitraryLoginServer(msg);
|
||||
break;
|
||||
}
|
||||
case constcrc("GameServerCSResponse" ) :
|
||||
{
|
||||
GameServerCSResponseMessage const msg( ri );
|
||||
CSToolResponse rmsg( msg.getAccountId(),
|
||||
msg.getResponse(),
|
||||
msg.getToolId() );
|
||||
CentralServer::getInstance().sendToLoginServer( msg.getLoginServerID(), rmsg );
|
||||
break;
|
||||
}
|
||||
case constcrc("GetCharactersForAccountCSReplyMsg" ) :
|
||||
{
|
||||
GetCharactersForAccountCSReplyMsg const msg( ri );
|
||||
// send repsonse to tool.
|
||||
char buf[ 256 ];
|
||||
snprintf( buf, 255, "Character search for %lu\r\n", msg.getTargetAccountId() );
|
||||
std::string response = buf;
|
||||
response = response + msg.getResponse();
|
||||
|
||||
CSToolResponse rmsg( msg.getAccountId(),
|
||||
response,
|
||||
msg.getToolId() );
|
||||
CentralServer::getInstance().sendToLoginServer( msg.getLoginServerId(), rmsg );
|
||||
break;
|
||||
}
|
||||
case constcrc("GetDeletedItemsReplyMessage" ) :
|
||||
{
|
||||
GetDeletedItemsReplyMessage const msg( ri );
|
||||
char buf[ 256 ];
|
||||
snprintf( buf, 255, "Deleted items for %s\r\n", msg.getCharacterId().getValueString().c_str() );
|
||||
std::string response = buf;
|
||||
response = response + msg.getResponse();
|
||||
CSToolResponse rmsg( msg.getAccountId(),
|
||||
response,
|
||||
msg.getToolId() );
|
||||
CentralServer::getInstance().sendToLoginServer( msg.getLoginServerId(), rmsg );
|
||||
break;
|
||||
|
||||
}
|
||||
case constcrc("GetCharacterIdReplyMessage" ) :
|
||||
{
|
||||
GetCharacterIdReplyMessage const msg( ri );
|
||||
std::string response = "Character id for ";
|
||||
response = response + msg.getCharacterName() + "\r\n";
|
||||
response = response + "character id:" + msg.getCharacterId().getValueString() + "\r\n";
|
||||
char buf[ 64 ];
|
||||
|
||||
snprintf( buf, 64, "%lu", msg.getAccountId() );
|
||||
|
||||
response = response + "account id:" + buf + "\r\n";
|
||||
|
||||
CSToolResponse rmsg( msg.getAccountId(), response, msg.getToolId() );
|
||||
CentralServer::getInstance().sendToLoginServer( msg.getLoginServerId(), rmsg );
|
||||
break;
|
||||
|
||||
}
|
||||
case constcrc("CSFindAuthObjectReply" ) :
|
||||
{
|
||||
GenericValueTypeMessage< std::pair< unsigned int, bool > > const msg( ri );
|
||||
CentralCSHandler::getInstance().handleFindObjectResponse( msg.getValue().first, msg.getValue().second );
|
||||
break;
|
||||
}
|
||||
case constcrc("StructureListMessage") :
|
||||
{
|
||||
StructureListMessage msg(ri);
|
||||
CentralCSHandler::getInstance().handleStructureListResponse(msg);
|
||||
break;
|
||||
}
|
||||
case constcrc("SPCharacterProfileMessage") :
|
||||
{
|
||||
SPCharacterProfileMessage const msg(ri);
|
||||
CentralServer::getInstance().sendToStationPlayersCollector(msg);
|
||||
break;
|
||||
}
|
||||
case constcrc("OccupyUnlockedSlotReq") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::pair<uint32, NetworkId>, uint32> > const occupyUnlockedSlotReq(ri);
|
||||
CentralServer::getInstance().sendToArbitraryLoginServer(occupyUnlockedSlotReq);
|
||||
break;
|
||||
}
|
||||
case constcrc("VacateUnlockedSlotReq") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::pair<uint32, NetworkId>, uint32> > const vacateUnlockedSlotReq(ri);
|
||||
CentralServer::getInstance().sendToArbitraryLoginServer(vacateUnlockedSlotReq);
|
||||
|
||||
// to safeguard against any sort of timing exploit to create another normal
|
||||
// slot character while this one is being converted to normal, thus allowing
|
||||
// the account to have more normal slot characters on this cluster than is
|
||||
// allowed, set the "creating characters too rapidly" flag to prevent any
|
||||
// character creation on the account on this cluster for a while
|
||||
CharacterCreationTracker::getInstance().setFastCreationLock(vacateUnlockedSlotReq.getValue().first.first);
|
||||
}
|
||||
else if (m.isType("SwapUnlockedSlotReq"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::pair<uint32, NetworkId>, std::pair<uint32, NetworkId> > > const swapUnlockedSlotReq(ri);
|
||||
CentralServer::getInstance().sendToArbitraryLoginServer(swapUnlockedSlotReq);
|
||||
}
|
||||
else if (m.isType("FeatureIdTransactionRequest"))
|
||||
{
|
||||
FeatureIdTransactionRequest const fitr(ri);
|
||||
CentralServer::getInstance().sendToArbitraryLoginServer(fitr);
|
||||
}
|
||||
else if (m.isType("FeatureIdTransactionSyncUpdate"))
|
||||
{
|
||||
FeatureIdTransactionSyncUpdate const fitsu(ri);
|
||||
CentralServer::getInstance().sendToArbitraryLoginServer(fitsu);
|
||||
}
|
||||
else if (m.isType("AllCluserGlobalChannel"))
|
||||
{
|
||||
typedef std::pair<std::pair<std::string,std::string>, bool> PayloadType;
|
||||
GenericValueTypeMessage<PayloadType> msg(ri);
|
||||
// to safeguard against any sort of timing exploit to create another normal
|
||||
// slot character while this one is being converted to normal, thus allowing
|
||||
// the account to have more normal slot characters on this cluster than is
|
||||
// allowed, set the "creating characters too rapidly" flag to prevent any
|
||||
// character creation on the account on this cluster for a while
|
||||
CharacterCreationTracker::getInstance().setFastCreationLock(vacateUnlockedSlotReq.getValue().first.first);
|
||||
break;
|
||||
}
|
||||
case constcrc("SwapUnlockedSlotReq") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::pair<uint32, NetworkId>, std::pair<uint32, NetworkId> > > const swapUnlockedSlotReq(ri);
|
||||
CentralServer::getInstance().sendToArbitraryLoginServer(swapUnlockedSlotReq);
|
||||
break;
|
||||
}
|
||||
case constcrc("FeatureIdTransactionRequest") :
|
||||
{
|
||||
FeatureIdTransactionRequest const fitr(ri);
|
||||
CentralServer::getInstance().sendToArbitraryLoginServer(fitr);
|
||||
break;
|
||||
}
|
||||
case constcrc("FeatureIdTransactionSyncUpdate") :
|
||||
{
|
||||
FeatureIdTransactionSyncUpdate const fitsu(ri);
|
||||
CentralServer::getInstance().sendToArbitraryLoginServer(fitsu);
|
||||
break;
|
||||
}
|
||||
case constcrc("AllCluserGlobalChannel") :
|
||||
{
|
||||
typedef std::pair<std::pair<std::string,std::string>, bool> PayloadType;
|
||||
GenericValueTypeMessage<PayloadType> msg(ri);
|
||||
|
||||
PayloadType const & payload = msg.getValue();
|
||||
std::string const & channelName = payload.first.first;
|
||||
std::string const & messageText = payload.first.second;
|
||||
bool const & isRemove = payload.second;
|
||||
PayloadType const & payload = msg.getValue();
|
||||
std::string const & channelName = payload.first.first;
|
||||
std::string const & messageText = payload.first.second;
|
||||
bool const & isRemove = payload.second;
|
||||
|
||||
LOG("CustomerService", ("BroadcastVoiceChannel: CentralServer got AllCluserGlobalChannel from GameServer, sending to LoginServer chan(%s) text(%s) remove(%d)",
|
||||
channelName.c_str(), messageText.c_str(), (isRemove?1:0) ));
|
||||
LOG("CustomerService", ("BroadcastVoiceChannel: CentralServer got AllCluserGlobalChannel from GameServer, sending to LoginServer chan(%s) text(%s) remove(%d)",
|
||||
channelName.c_str(), messageText.c_str(), (isRemove?1:0) ));
|
||||
|
||||
CentralServer::getInstance().sendToArbitraryLoginServer(msg);
|
||||
}
|
||||
else if (m.isType("TransferRequestMoveValidation"))
|
||||
{
|
||||
TransferRequestMoveValidation const request(ri);
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(request));
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferRequestMoveValidation from GameServer (%u) : [%u, %s, %s (%s)] to [%u, %s, %s]. Forwarding request to LoginServer.", request.getTrack(), request.getSourceStationId(), request.getSourceGalaxy().c_str(), request.getSourceCharacter().c_str(), request.getSourceCharacterId().getValueString().c_str(), request.getDestinationStationId(), request.getDestinationGalaxy().c_str(), request.getDestinationCharacter().c_str()));
|
||||
}
|
||||
else if (m.isType("GcwScoreStatRaw"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::string, std::pair<std::map<std::string, std::pair<int64, int64> >, std::map<std::string, std::pair<int64, int64> > > > > const msg(ri);
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(msg));
|
||||
}
|
||||
else if (m.isType("GcwScoreStatPct"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::string, std::pair<std::map<std::string, int>, std::map<std::string, int> > > > const msg(ri);
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(msg));
|
||||
CentralServer::getInstance().sendToArbitraryLoginServer(msg);
|
||||
break;
|
||||
}
|
||||
case constcrc("TransferRequestMoveValidation") :
|
||||
{
|
||||
TransferRequestMoveValidation const request(ri);
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(request));
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferRequestMoveValidation from GameServer (%u) : [%u, %s, %s (%s)] to [%u, %s, %s]. Forwarding request to LoginServer.", request.getTrack(), request.getSourceStationId(), request.getSourceGalaxy().c_str(), request.getSourceCharacter().c_str(), request.getSourceCharacterId().getValueString().c_str(), request.getDestinationStationId(), request.getDestinationGalaxy().c_str(), request.getDestinationCharacter().c_str()));
|
||||
break;
|
||||
}
|
||||
case constcrc("GcwScoreStatRaw") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::string, std::pair<std::map<std::string, std::pair<int64, int64> >, std::map<std::string, std::pair<int64, int64> > > > > const msg(ri);
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(msg));
|
||||
break;
|
||||
}
|
||||
case constcrc("GcwScoreStatPct") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::string, std::pair<std::map<std::string, int>, std::map<std::string, int> > > > const msg(ri);
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(msg));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ServerConnection::onReceive(message);
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
#include "sharedNetworkMessages/ConsoleChannelMessages.h"
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
|
||||
#include "sharedFoundation/CrcConstexpr.hpp"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
LoginServerConnection::LoginServerConnection(const std::string & a, const unsigned short p) :
|
||||
@@ -87,238 +89,265 @@ void LoginServerConnection::onReceive(const Archive::ByteStream & message)
|
||||
GameNetworkMessage m(ri);
|
||||
ri = message.begin();
|
||||
|
||||
if(m.isType("TransferReplyCharacterList"))
|
||||
{
|
||||
// if this is not a free CTS galaxy, immediately forward the message to the TransferServer,
|
||||
// else if this is a free CTS galaxy, forward the message to a game server so that characters
|
||||
// in the list that qualifies for free CTS are removed from the list; characters that qualify
|
||||
// for free CTS should/must use the in-game free CTS to transfer the character;
|
||||
TransferReplyCharacterList reply(ri);
|
||||
if (!FreeCtsDataTable::isFreeCtsSourceCluster(ConfigCentralServer::getClusterName()))
|
||||
CentralServer::getInstance().sendToTransferServer(reply);
|
||||
else
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToRandomGameServer(reply));
|
||||
}
|
||||
else if(m.isType("TransferReplyCharacterDataFromLoginServer"))
|
||||
{
|
||||
GenericValueTypeMessage<TransferCharacterData> reply(ri);
|
||||
// see if we need to send to transfer or connection server.
|
||||
if(reply.getValue().getCSToolId() > 0)
|
||||
const uint32 messageType = m.getType();
|
||||
|
||||
switch (messageType) {
|
||||
case constcrc("TransferReplyCharacterList") :
|
||||
{
|
||||
// for CS admin login. send to DB. This just shortcuts what would normally
|
||||
// happen at the transfer server.
|
||||
GenericValueTypeMessage<TransferCharacterData> login("TransferGetLoginLocationData", reply.getValue());
|
||||
CentralServer::getInstance().sendToDBProcess(login, true);
|
||||
}
|
||||
else if (reply.getValue().getTransferRequestSource() == TransferRequestMoveValidation::TRS_transfer_server)
|
||||
{
|
||||
// for CTS. Send to transfer.
|
||||
CentralServer::getInstance().sendToTransferServer(reply);
|
||||
}
|
||||
}
|
||||
else if(m.isType("TransferReplyMoveValidation"))
|
||||
{
|
||||
TransferReplyMoveValidation const reply(ri);
|
||||
|
||||
if (reply.getTransferRequestSource() == TransferRequestMoveValidation::TRS_transfer_server)
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferReplyMoveValidation for %s on %s to %s on %s from LoginServer. Forwarding reply to TransferServer.", reply.getSourceCharacter().c_str(), reply.getSourceGalaxy().c_str(), reply.getDestinationCharacter().c_str(), reply.getDestinationGalaxy().c_str()));
|
||||
CentralServer::getInstance().sendToTransferServer(reply);
|
||||
}
|
||||
else if (reply.getResult() != TransferReplyMoveValidation::TRMVR_can_create_regular_character)
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Received ***FAILED*** TransferReplyMoveValidation for [%u, %s, %s (%s)] to [%u, %s, %s] from LoginServer. Forwarding ***FAILED*** reply to GameServer (%u).", reply.getSourceStationId(), reply.getSourceGalaxy().c_str(), reply.getSourceCharacter().c_str(), reply.getSourceCharacterId().getValueString().c_str(), reply.getDestinationStationId(), reply.getDestinationGalaxy().c_str(), reply.getDestinationCharacter().c_str(), reply.getTrack()));
|
||||
GameServerConnection * gs = CentralServer::getInstance().getGameServer(reply.getTrack());
|
||||
if (!gs)
|
||||
gs = CentralServer::getInstance().getRandomGameServer();
|
||||
|
||||
if (gs)
|
||||
gs->send(reply, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Received ***SUCCESS*** TransferReplyMoveValidation for [%u, %s, %s (%s)] to [%u, %s, %s] from LoginServer. Sending TransferRequestNameValidation to a random game server.", reply.getSourceStationId(), reply.getSourceGalaxy().c_str(), reply.getSourceCharacter().c_str(), reply.getSourceCharacterId().getValueString().c_str(), reply.getDestinationStationId(), reply.getDestinationGalaxy().c_str(), reply.getDestinationCharacter().c_str()));
|
||||
|
||||
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.setCharacterId(reply.getSourceCharacterId());
|
||||
requestData.setObjectTemplateCrc(reply.getSourceCharacterTemplateId());
|
||||
requestData.setDestinationCharacterName(reply.getDestinationCharacter());
|
||||
requestData.setSourceStationId(reply.getSourceStationId());
|
||||
requestData.setDestinationStationId(reply.getDestinationStationId());
|
||||
const GenericValueTypeMessage<TransferCharacterData> requestNameValidation("TransferRequestNameValidation", requestData);
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToRandomGameServer(requestNameValidation));
|
||||
}
|
||||
}
|
||||
else if(m.isType("TransferReplyNameValidation"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::string, TransferCharacterData> > const replyNameValidation(ri);
|
||||
if (!replyNameValidation.getValue().second.getIsValidName() || (replyNameValidation.getValue().second.getTransferRequestSource() == TransferRequestMoveValidation::TRS_ingame_freects_command_validate) || (replyNameValidation.getValue().second.getTransferRequestSource() == TransferRequestMoveValidation::TRS_ingame_cts_command_validate))
|
||||
{
|
||||
if (!replyNameValidation.getValue().second.getIsValidName())
|
||||
LOG("CustomerService", ("CharacterTransfer: Received ***FAILED*** TransferReplyNameValidation from target galaxy CentralServer : (%s) %s", replyNameValidation.getValue().first.c_str(), replyNameValidation.getValue().second.toString().c_str()));
|
||||
// if this is not a free CTS galaxy, immediately forward the message to the TransferServer,
|
||||
// else if this is a free CTS galaxy, forward the message to a game server so that characters
|
||||
// in the list that qualifies for free CTS are removed from the list; characters that qualify
|
||||
// for free CTS should/must use the in-game free CTS to transfer the character;
|
||||
TransferReplyCharacterList reply(ri);
|
||||
if (!FreeCtsDataTable::isFreeCtsSourceCluster(ConfigCentralServer::getClusterName()))
|
||||
CentralServer::getInstance().sendToTransferServer(reply);
|
||||
else
|
||||
LOG("CustomerService", ("CharacterTransfer: Received ***SUCCESS*** TransferReplyNameValidation from target galaxy CentralServer. Forwarding reply to GameServer (%u). %s", replyNameValidation.getValue().second.getTrack(), replyNameValidation.getValue().second.toString().c_str()));
|
||||
|
||||
GameServerConnection * gs = CentralServer::getInstance().getGameServer(replyNameValidation.getValue().second.getTrack());
|
||||
if (!gs)
|
||||
gs = CentralServer::getInstance().getRandomGameServer();
|
||||
|
||||
if (gs)
|
||||
gs->send(replyNameValidation, true);
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToRandomGameServer(reply));
|
||||
|
||||
break;
|
||||
}
|
||||
else
|
||||
case constcrc("TransferReplyCharacterDataFromLoginServer") :
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Received ***SUCCESS*** TransferReplyNameValidation from target galaxy CentralServer. Starting transfer process : %s", replyNameValidation.getValue().second.toString().c_str()));
|
||||
|
||||
// disconnect any clients with a connection to SWG services on this (the source) galaxy
|
||||
GenericValueTypeMessage<unsigned int> kickSource("TransferKickConnectedClients", replyNameValidation.getValue().second.getSourceStationId());
|
||||
GenericValueTypeMessage<unsigned int> kickDestination("TransferKickConnectedClients", replyNameValidation.getValue().second.getDestinationStationId());
|
||||
CentralServer::getInstance().sendToAllLoginServers(kickSource);
|
||||
CentralServer::getInstance().sendToAllLoginServers(kickDestination);
|
||||
CentralServer::getInstance().sendToAllConnectionServers(kickSource, true);
|
||||
CentralServer::getInstance().sendToAllConnectionServers(kickDestination, true);
|
||||
|
||||
TransferCharacterData characterData(replyNameValidation.getValue().second);
|
||||
characterData.setIsMoveRequest(true);
|
||||
characterData.setWithItems(true);
|
||||
characterData.setAllowOverride(true);
|
||||
|
||||
LOG("CustomerService", ("CharacterTransfer: Sending TransferGetLoginLocationData for %s\n", characterData.getSourceCharacterName().c_str()));
|
||||
|
||||
const GenericValueTypeMessage<TransferCharacterData> getLoginLocation("TransferGetLoginLocationData", characterData);
|
||||
CentralServer::getInstance().sendToDBProcess(getLoginLocation, true);
|
||||
}
|
||||
}
|
||||
else if(m.isType("TransferLoginCharacterToDestinationServer"))
|
||||
{
|
||||
GenericValueTypeMessage<TransferCharacterData> const loginCharacter(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: ***CentralServer: Received TransferLoginCharacterToDestinationServer request from Login Server for %s\n", loginCharacter.getValue().toString().c_str()));
|
||||
ConnectionServerConnection * connectionServer = CentralServer::getInstance().getAnyConnectionServer();
|
||||
if(connectionServer)
|
||||
{
|
||||
connectionServer->send(loginCharacter, true);
|
||||
}
|
||||
}
|
||||
else if(m.isType("TransferClosePseudoClientConnection"))
|
||||
{
|
||||
GenericValueTypeMessage<unsigned int> const closeRequest(ri);
|
||||
CentralServer::getInstance().sendToAllConnectionServers(closeRequest, true);
|
||||
}
|
||||
else if(m.isType("TransferCloseClientConnection"))
|
||||
{
|
||||
GenericValueTypeMessage<unsigned int> const closeRequest(ri);
|
||||
|
||||
GenericValueTypeMessage<unsigned int> const kick("TransferKickConnectedClients", closeRequest.getValue());
|
||||
CentralServer::getInstance().sendToAllLoginServers(kick);
|
||||
CentralServer::getInstance().sendToAllConnectionServers(kick, true);
|
||||
}
|
||||
else if(m.isType("CtsCompletedForcharacter"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::string, NetworkId> > const msg(ri);
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToRandomGameServer(msg));
|
||||
}
|
||||
else if(m.isType("TransferRenameCharacterReplyFromLoginServer"))
|
||||
{
|
||||
GenericValueTypeMessage<TransferCharacterData> replyFromLoginServer(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferRenameCharacterReplyFromLoginServer : %s", replyFromLoginServer.getValue().toString().c_str()));
|
||||
|
||||
GenericValueTypeMessage<TransferCharacterData> reply("TransferRenameCharacterReply", replyFromLoginServer.getValue());
|
||||
CentralServer::getInstance().sendToTransferServer(reply);
|
||||
}
|
||||
else if(m.isType("TransferAccountRequestCentralDatabase"))
|
||||
{
|
||||
// got message back from loginServer - have to transfer to DBProcess to update the game database
|
||||
GenericValueTypeMessage<TransferAccountData> accountTransferRequest(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferAccountRequestCentralDatabase from station ID %d to station ID %d", accountTransferRequest.getValue().getSourceStationId(), accountTransferRequest.getValue().getDestinationStationId()));
|
||||
CentralServer::getInstance().sendToDBProcess(accountTransferRequest, true);
|
||||
}
|
||||
else if(m.isType("TransferAccountReplySuccessTransferServer"))
|
||||
{
|
||||
// got reply back from login server - fwd to transfer server
|
||||
GenericValueTypeMessage<TransferAccountData> replyToTransferServer(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferAccountReplySuccessTransferServer from station ID %d to station ID %d", replyToTransferServer.getValue().getSourceStationId(), replyToTransferServer.getValue().getDestinationStationId()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToTransferServer(replyToTransferServer));
|
||||
}
|
||||
else if(m.isType("TransferAccountFailedToUpdateGameDatabase"))
|
||||
{
|
||||
// got failure message back from login server - fwd to transfer server
|
||||
GenericValueTypeMessage<TransferAccountData> replyToTransferServer(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferAccountFailedToUpdateGameDatabase for transfer from station ID %d to station ID %d", replyToTransferServer.getValue().getSourceStationId(), replyToTransferServer.getValue().getDestinationStationId()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToTransferServer(replyToTransferServer));
|
||||
}
|
||||
else if(m.isType("TransferAccountFailedDestinationNotEmpty"))
|
||||
{
|
||||
// got failure message back from login server - fwd to transfer server
|
||||
GenericValueTypeMessage<TransferAccountData> replyToTransferServer(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferAccountFailedDestinationNotEmpty for transfer from station ID %d to station ID %d", replyToTransferServer.getValue().getSourceStationId(), replyToTransferServer.getValue().getDestinationStationId()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToTransferServer(replyToTransferServer));
|
||||
}
|
||||
else if(m.isType("CSToolRequest"))
|
||||
{
|
||||
// for now, just parse the command through the command queue.
|
||||
// TODO: implement command processor for this, specifically. Or, at least, make sure we're
|
||||
// specifying access levels.
|
||||
CSToolRequest const req(ri);
|
||||
|
||||
// Doesn't appear to be too much that we can really do with the Central Server.
|
||||
// So, for now, we'll just implement a 'central' command here and spam the GameServers with
|
||||
// the original message otherwise.
|
||||
|
||||
unsigned pos = req.getCommandString().find( " " );
|
||||
pos = pos == std::string::npos ? req.getCommandString().length() : pos;
|
||||
|
||||
CentralCSHandler::getInstance().handle( req, getProcessId() );
|
||||
|
||||
|
||||
}
|
||||
else if(m.isType("ConGenericMessage"))
|
||||
{
|
||||
ConGenericMessage con(ri);
|
||||
ConsoleConnection::onCommandComplete(con.getMsg(), static_cast<int>(con.getMsgId()));
|
||||
}
|
||||
else if(m.isType("AllCluserGlobalChannel"))
|
||||
{
|
||||
//TODO: Route to connection server directly if there is no channel?
|
||||
typedef std::pair<std::pair<std::string,std::string>, bool> PayloadType;
|
||||
GenericValueTypeMessage<PayloadType> msg(ri);
|
||||
|
||||
PayloadType const & payload = msg.getValue();
|
||||
std::string const & channelName = payload.first.first;
|
||||
std::string const & messageText = payload.first.second;
|
||||
bool const & isRemove = payload.second;
|
||||
|
||||
LOG("CustomerService", ("BroadcastVoiceChannel: CentralServer got AllCluserGlobalChannel from LoginServer, sending to all ChatServers chan(%s) text(%s) remove(%d)",
|
||||
channelName.c_str(), messageText.c_str(), (isRemove?1:0) ));
|
||||
|
||||
CentralServer::getInstance().broadcastToChatServers(msg);
|
||||
}
|
||||
else if(m.isType("GcwScoreStatRaw"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::string, std::pair<std::map<std::string, std::pair<int64, int64> >, std::map<std::string, std::pair<int64, int64> > > > > const msg(ri);
|
||||
if (_stricmp(msg.getValue().first.c_str(), ConfigCentralServer::getClusterName()))
|
||||
{
|
||||
GameServerConnection * universeGameServerConnection = CentralServer::getInstance().getGameServer(UniverseManager::getInstance().getUniverseProcess());
|
||||
if (universeGameServerConnection)
|
||||
GenericValueTypeMessage<TransferCharacterData> reply(ri);
|
||||
// see if we need to send to transfer or connection server.
|
||||
if(reply.getValue().getCSToolId() > 0)
|
||||
{
|
||||
universeGameServerConnection->send(msg, true);
|
||||
// for CS admin login. send to DB. This just shortcuts what would normally
|
||||
// happen at the transfer server.
|
||||
GenericValueTypeMessage<TransferCharacterData> login("TransferGetLoginLocationData", reply.getValue());
|
||||
CentralServer::getInstance().sendToDBProcess(login, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(m.isType("GcwScoreStatPct"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::string, std::pair<std::map<std::string, int>, std::map<std::string, int> > > > const msg(ri);
|
||||
if (_stricmp(msg.getValue().first.c_str(), ConfigCentralServer::getClusterName()))
|
||||
{
|
||||
GameServerConnection * universeGameServerConnection = CentralServer::getInstance().getGameServer(UniverseManager::getInstance().getUniverseProcess());
|
||||
if (universeGameServerConnection)
|
||||
else if (reply.getValue().getTransferRequestSource() == TransferRequestMoveValidation::TRS_transfer_server)
|
||||
{
|
||||
universeGameServerConnection->send(msg, true);
|
||||
// for CTS. Send to transfer.
|
||||
CentralServer::getInstance().sendToTransferServer(reply);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case constcrc("TransferReplyMoveValidation") :
|
||||
{
|
||||
TransferReplyMoveValidation const reply(ri);
|
||||
|
||||
if (reply.getTransferRequestSource() == TransferRequestMoveValidation::TRS_transfer_server)
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferReplyMoveValidation for %s on %s to %s on %s from LoginServer. Forwarding reply to TransferServer.", reply.getSourceCharacter().c_str(), reply.getSourceGalaxy().c_str(), reply.getDestinationCharacter().c_str(), reply.getDestinationGalaxy().c_str()));
|
||||
CentralServer::getInstance().sendToTransferServer(reply);
|
||||
}
|
||||
else if (reply.getResult() != TransferReplyMoveValidation::TRMVR_can_create_regular_character)
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Received ***FAILED*** TransferReplyMoveValidation for [%u, %s, %s (%s)] to [%u, %s, %s] from LoginServer. Forwarding ***FAILED*** reply to GameServer (%u).", reply.getSourceStationId(), reply.getSourceGalaxy().c_str(), reply.getSourceCharacter().c_str(), reply.getSourceCharacterId().getValueString().c_str(), reply.getDestinationStationId(), reply.getDestinationGalaxy().c_str(), reply.getDestinationCharacter().c_str(), reply.getTrack()));
|
||||
GameServerConnection * gs = CentralServer::getInstance().getGameServer(reply.getTrack());
|
||||
if (!gs)
|
||||
gs = CentralServer::getInstance().getRandomGameServer();
|
||||
|
||||
if (gs)
|
||||
gs->send(reply, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Received ***SUCCESS*** TransferReplyMoveValidation for [%u, %s, %s (%s)] to [%u, %s, %s] from LoginServer. Sending TransferRequestNameValidation to a random game server.", reply.getSourceStationId(), reply.getSourceGalaxy().c_str(), reply.getSourceCharacter().c_str(), reply.getSourceCharacterId().getValueString().c_str(), reply.getDestinationStationId(), reply.getDestinationGalaxy().c_str(), reply.getDestinationCharacter().c_str()));
|
||||
|
||||
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.setCharacterId(reply.getSourceCharacterId());
|
||||
requestData.setObjectTemplateCrc(reply.getSourceCharacterTemplateId());
|
||||
requestData.setDestinationCharacterName(reply.getDestinationCharacter());
|
||||
requestData.setSourceStationId(reply.getSourceStationId());
|
||||
requestData.setDestinationStationId(reply.getDestinationStationId());
|
||||
const GenericValueTypeMessage<TransferCharacterData> requestNameValidation("TransferRequestNameValidation", requestData);
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToRandomGameServer(requestNameValidation));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case constcrc("TransferReplyNameValidation") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::string, TransferCharacterData> > const replyNameValidation(ri);
|
||||
if (!replyNameValidation.getValue().second.getIsValidName() || (replyNameValidation.getValue().second.getTransferRequestSource() == TransferRequestMoveValidation::TRS_ingame_freects_command_validate) || (replyNameValidation.getValue().second.getTransferRequestSource() == TransferRequestMoveValidation::TRS_ingame_cts_command_validate))
|
||||
{
|
||||
if (!replyNameValidation.getValue().second.getIsValidName())
|
||||
LOG("CustomerService", ("CharacterTransfer: Received ***FAILED*** TransferReplyNameValidation from target galaxy CentralServer : (%s) %s", replyNameValidation.getValue().first.c_str(), replyNameValidation.getValue().second.toString().c_str()));
|
||||
else
|
||||
LOG("CustomerService", ("CharacterTransfer: Received ***SUCCESS*** TransferReplyNameValidation from target galaxy CentralServer. Forwarding reply to GameServer (%u). %s", replyNameValidation.getValue().second.getTrack(), replyNameValidation.getValue().second.toString().c_str()));
|
||||
|
||||
GameServerConnection * gs = CentralServer::getInstance().getGameServer(replyNameValidation.getValue().second.getTrack());
|
||||
if (!gs)
|
||||
gs = CentralServer::getInstance().getRandomGameServer();
|
||||
|
||||
if (gs)
|
||||
gs->send(replyNameValidation, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Received ***SUCCESS*** TransferReplyNameValidation from target galaxy CentralServer. Starting transfer process : %s", replyNameValidation.getValue().second.toString().c_str()));
|
||||
|
||||
// disconnect any clients with a connection to SWG services on this (the source) galaxy
|
||||
GenericValueTypeMessage<unsigned int> kickSource("TransferKickConnectedClients", replyNameValidation.getValue().second.getSourceStationId());
|
||||
GenericValueTypeMessage<unsigned int> kickDestination("TransferKickConnectedClients", replyNameValidation.getValue().second.getDestinationStationId());
|
||||
CentralServer::getInstance().sendToAllLoginServers(kickSource);
|
||||
CentralServer::getInstance().sendToAllLoginServers(kickDestination);
|
||||
CentralServer::getInstance().sendToAllConnectionServers(kickSource, true);
|
||||
CentralServer::getInstance().sendToAllConnectionServers(kickDestination, true);
|
||||
|
||||
TransferCharacterData characterData(replyNameValidation.getValue().second);
|
||||
characterData.setIsMoveRequest(true);
|
||||
characterData.setWithItems(true);
|
||||
characterData.setAllowOverride(true);
|
||||
|
||||
LOG("CustomerService", ("CharacterTransfer: Sending TransferGetLoginLocationData for %s\n", characterData.getSourceCharacterName().c_str()));
|
||||
|
||||
const GenericValueTypeMessage<TransferCharacterData> getLoginLocation("TransferGetLoginLocationData", characterData);
|
||||
CentralServer::getInstance().sendToDBProcess(getLoginLocation, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case constcrc("TransferLoginCharacterToDestinationServer") :
|
||||
{
|
||||
GenericValueTypeMessage<TransferCharacterData> const loginCharacter(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: ***CentralServer: Received TransferLoginCharacterToDestinationServer request from Login Server for %s\n", loginCharacter.getValue().toString().c_str()));
|
||||
ConnectionServerConnection * connectionServer = CentralServer::getInstance().getAnyConnectionServer();
|
||||
if(connectionServer)
|
||||
{
|
||||
connectionServer->send(loginCharacter, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case constcrc("TransferClosePseudoClientConnection") :
|
||||
{
|
||||
GenericValueTypeMessage<unsigned int> const closeRequest(ri);
|
||||
CentralServer::getInstance().sendToAllConnectionServers(closeRequest, true);
|
||||
break;
|
||||
}
|
||||
case constcrc("TransferCloseClientConnection") :
|
||||
{
|
||||
GenericValueTypeMessage<unsigned int> const closeRequest(ri);
|
||||
|
||||
GenericValueTypeMessage<unsigned int> const kick("TransferKickConnectedClients", closeRequest.getValue());
|
||||
CentralServer::getInstance().sendToAllLoginServers(kick);
|
||||
CentralServer::getInstance().sendToAllConnectionServers(kick, true);
|
||||
break;
|
||||
}
|
||||
case constcrc("CtsCompletedForcharacter") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::string, NetworkId> > const msg(ri);
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToRandomGameServer(msg));
|
||||
break;
|
||||
}
|
||||
case constcrc("TransferRenameCharacterReplyFromLoginServer") :
|
||||
{
|
||||
GenericValueTypeMessage<TransferCharacterData> replyFromLoginServer(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferRenameCharacterReplyFromLoginServer : %s", replyFromLoginServer.getValue().toString().c_str()));
|
||||
|
||||
GenericValueTypeMessage<TransferCharacterData> reply("TransferRenameCharacterReply", replyFromLoginServer.getValue());
|
||||
CentralServer::getInstance().sendToTransferServer(reply);
|
||||
|
||||
break;
|
||||
}
|
||||
case constcrc("TransferAccountRequestCentralDatabase") :
|
||||
{
|
||||
// got message back from loginServer - have to transfer to DBProcess to update the game database
|
||||
GenericValueTypeMessage<TransferAccountData> accountTransferRequest(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferAccountRequestCentralDatabase from station ID %d to station ID %d", accountTransferRequest.getValue().getSourceStationId(), accountTransferRequest.getValue().getDestinationStationId()));
|
||||
CentralServer::getInstance().sendToDBProcess(accountTransferRequest, true);
|
||||
break;
|
||||
}
|
||||
case constcrc("TransferAccountReplySuccessTransferServer") :
|
||||
{
|
||||
// got reply back from login server - fwd to transfer server
|
||||
GenericValueTypeMessage<TransferAccountData> replyToTransferServer(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferAccountReplySuccessTransferServer from station ID %d to station ID %d", replyToTransferServer.getValue().getSourceStationId(), replyToTransferServer.getValue().getDestinationStationId()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToTransferServer(replyToTransferServer));
|
||||
|
||||
break;
|
||||
}
|
||||
case constcrc("TransferAccountFailedToUpdateGameDatabase") :
|
||||
{
|
||||
// got failure message back from login server - fwd to transfer server
|
||||
GenericValueTypeMessage<TransferAccountData> replyToTransferServer(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferAccountFailedToUpdateGameDatabase for transfer from station ID %d to station ID %d", replyToTransferServer.getValue().getSourceStationId(), replyToTransferServer.getValue().getDestinationStationId()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToTransferServer(replyToTransferServer));
|
||||
break;
|
||||
}
|
||||
case constcrc("TransferAccountFailedDestinationNotEmpty") :
|
||||
{
|
||||
// got failure message back from login server - fwd to transfer server
|
||||
GenericValueTypeMessage<TransferAccountData> replyToTransferServer(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferAccountFailedDestinationNotEmpty for transfer from station ID %d to station ID %d", replyToTransferServer.getValue().getSourceStationId(), replyToTransferServer.getValue().getDestinationStationId()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToTransferServer(replyToTransferServer));
|
||||
break;
|
||||
}
|
||||
case constcrc("CSToolRequest") :
|
||||
{
|
||||
// for now, just parse the command through the command queue.
|
||||
// TODO: implement command processor for this, specifically. Or, at least, make sure we're
|
||||
// specifying access levels.
|
||||
CSToolRequest const req(ri);
|
||||
|
||||
// Doesn't appear to be too much that we can really do with the Central Server.
|
||||
// So, for now, we'll just implement a 'central' command here and spam the GameServers with
|
||||
// the original message otherwise.
|
||||
|
||||
unsigned pos = req.getCommandString().find( " " );
|
||||
pos = pos == std::string::npos ? req.getCommandString().length() : pos;
|
||||
|
||||
CentralCSHandler::getInstance().handle( req, getProcessId() );
|
||||
|
||||
break;
|
||||
}
|
||||
case constcrc("ConGenericMessage") :
|
||||
{
|
||||
ConGenericMessage con(ri);
|
||||
ConsoleConnection::onCommandComplete(con.getMsg(), static_cast<int>(con.getMsgId()));
|
||||
|
||||
break;
|
||||
}
|
||||
case constcrc("AllCluserGlobalChannel") :
|
||||
{
|
||||
//TODO: Route to connection server directly if there is no channel?
|
||||
typedef std::pair<std::pair<std::string,std::string>, bool> PayloadType;
|
||||
GenericValueTypeMessage<PayloadType> msg(ri);
|
||||
|
||||
PayloadType const & payload = msg.getValue();
|
||||
std::string const & channelName = payload.first.first;
|
||||
std::string const & messageText = payload.first.second;
|
||||
bool const & isRemove = payload.second;
|
||||
|
||||
LOG("CustomerService", ("BroadcastVoiceChannel: CentralServer got AllCluserGlobalChannel from LoginServer, sending to all ChatServers chan(%s) text(%s) remove(%d)",
|
||||
channelName.c_str(), messageText.c_str(), (isRemove?1:0) ));
|
||||
|
||||
CentralServer::getInstance().broadcastToChatServers(msg);
|
||||
|
||||
break;
|
||||
}
|
||||
case constcrc("GcwScoreStatRaw") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::string, std::pair<std::map<std::string, std::pair<int64, int64> >, std::map<std::string, std::pair<int64, int64> > > > > const msg(ri);
|
||||
if (_stricmp(msg.getValue().first.c_str(), ConfigCentralServer::getClusterName()))
|
||||
{
|
||||
GameServerConnection * universeGameServerConnection = CentralServer::getInstance().getGameServer(UniverseManager::getInstance().getUniverseProcess());
|
||||
if (universeGameServerConnection)
|
||||
{
|
||||
universeGameServerConnection->send(msg, true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case constcrc("GcwScoreStatPct") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::string, std::pair<std::map<std::string, int>, std::map<std::string, int> > > > const msg(ri);
|
||||
if (_stricmp(msg.getValue().first.c_str(), ConfigCentralServer::getClusterName()))
|
||||
{
|
||||
GameServerConnection * universeGameServerConnection = CentralServer::getInstance().getGameServer(UniverseManager::getInstance().getUniverseProcess());
|
||||
if (universeGameServerConnection)
|
||||
{
|
||||
universeGameServerConnection->send(msg, true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#include "serverNetworkMessages/TaskSpawnProcess.h"
|
||||
#include "sharedNetwork/NetworkHandler.h"
|
||||
|
||||
#include "sharedFoundation/CrcConstexpr.hpp"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
PlanetManager::PlanetRec::PlanetRec() :
|
||||
@@ -85,48 +87,55 @@ void PlanetManager::addGameServerForScene(const std::string &sceneId, GameServer
|
||||
|
||||
void PlanetManager::receiveMessage(const MessageDispatch::Emitter &source , const MessageDispatch::MessageBase & message)
|
||||
{
|
||||
if(message.isType("PlanetObjectIdMessage")) //@todo: Is this message actually used anymore?
|
||||
{
|
||||
Archive::ReadIterator ri = static_cast<const GameNetworkMessage &>(message).getByteStream().begin();
|
||||
PlanetObjectIdMessage msg(ri);
|
||||
|
||||
// Message identifies the PlanetObject that belongs to a particular planet
|
||||
ServerListType::iterator i=m_servers.find(msg.getSceneId());
|
||||
if (i==m_servers.end())
|
||||
const uint32 messageType = message.getType();
|
||||
|
||||
switch (messageType) {
|
||||
case constcrc("PlanetObjectIdMessage") : //@todo: Is this message actually used anymore?
|
||||
{
|
||||
WARNING_STRICT_FATAL(true,("Got unexpected PlanetObjectIdMessage for %s.\n",msg.getSceneId().c_str()));
|
||||
return;
|
||||
}
|
||||
Archive::ReadIterator ri = static_cast<const GameNetworkMessage &>(message).getByteStream().begin();
|
||||
PlanetObjectIdMessage msg(ri);
|
||||
|
||||
(*i).second.m_planetObjectId=msg.getPlanetObject();
|
||||
|
||||
// Not needed because all UniverseObjects are proxied.
|
||||
// CentralServer::getInstance().proxyOnAllServersForScene(msg.getPlanetObject(),msg.getSceneId());
|
||||
}
|
||||
else if(message.isType("PlanetServerConnectionClosed"))
|
||||
{
|
||||
const PlanetServerConnection * c = static_cast<const PlanetServerConnection *>(&source); //lint !e826 Suspiscious pointer-to-pointer conversion (area too small)
|
||||
ServerListType::iterator i = m_servers.begin();
|
||||
for (; i != m_servers.end(); ++i)
|
||||
{
|
||||
if (i->second.m_connection == c)
|
||||
// Message identifies the PlanetObject that belongs to a particular planet
|
||||
ServerListType::iterator i=m_servers.find(msg.getSceneId());
|
||||
if (i==m_servers.end())
|
||||
{
|
||||
m_servers.erase(i);
|
||||
break;
|
||||
WARNING_STRICT_FATAL(true,("Got unexpected PlanetObjectIdMessage for %s.\n",msg.getSceneId().c_str()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (ConfigCentralServer::getRequestDbSaveOnPlanetServerCrash())
|
||||
(*i).second.m_planetObjectId=msg.getPlanetObject();
|
||||
|
||||
// Not needed because all UniverseObjects are proxied.
|
||||
// CentralServer::getInstance().proxyOnAllServersForScene(msg.getPlanetObject(),msg.getSceneId());
|
||||
break;
|
||||
}
|
||||
case constcrc("PlanetServerConnectionClosed") :
|
||||
{
|
||||
GameNetworkMessage const msg("CentralRequestSave");
|
||||
CentralServer::getInstance().sendToDBProcess(msg, true);
|
||||
}
|
||||
const PlanetServerConnection * c = static_cast<const PlanetServerConnection *>(&source); //lint !e826 Suspiscious pointer-to-pointer conversion (area too small)
|
||||
ServerListType::iterator i = m_servers.begin();
|
||||
for (; i != m_servers.end(); ++i)
|
||||
{
|
||||
if (i->second.m_connection == c)
|
||||
{
|
||||
m_servers.erase(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CentralServer::getInstance().startPlanetServer(CentralServer::getInstance().getHostForScene(c->getSceneId()), c->getSceneId(), ConfigCentralServer::getPlanetServerRestartDelayTimeSeconds());
|
||||
}
|
||||
else
|
||||
{
|
||||
WARNING_STRICT_FATAL(true,("Planet Manager got unexpected message.\n"));
|
||||
if (ConfigCentralServer::getRequestDbSaveOnPlanetServerCrash())
|
||||
{
|
||||
GameNetworkMessage const msg("CentralRequestSave");
|
||||
CentralServer::getInstance().sendToDBProcess(msg, true);
|
||||
}
|
||||
|
||||
CentralServer::getInstance().startPlanetServer(CentralServer::getInstance().getHostForScene(c->getSceneId()), c->getSceneId(), ConfigCentralServer::getPlanetServerRestartDelayTimeSeconds());
|
||||
break;
|
||||
}
|
||||
default :
|
||||
{
|
||||
WARNING_STRICT_FATAL(true,("Planet Manager got unexpected message.\n"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +147,7 @@ PlanetServerConnection *PlanetManager::getPlanetServerForScene(const std::string
|
||||
if (i!=instance().m_servers.end())
|
||||
return (*i).second.m_connection;
|
||||
else
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#include "sharedNetworkMessages/ConsoleChannelMessages.h"
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
|
||||
#include "sharedFoundation/CrcConstexpr.hpp"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
PlanetServerConnection::PlanetServerConnection(UdpConnectionMT *u, TcpClient *t) :
|
||||
@@ -69,39 +71,42 @@ void PlanetServerConnection::onReceive(Archive::ByteStream const &message)
|
||||
GameNetworkMessage const msg(ri);
|
||||
ri = message.begin();
|
||||
|
||||
const uint32 msgType = msg.getType();
|
||||
|
||||
if (!m_forwardDestinationServers.empty())
|
||||
{
|
||||
if (isMessageForwardable(msg.getType()))
|
||||
if (isMessageForwardable(msgType))
|
||||
{
|
||||
m_forwardMessages.push_back(std::make_pair(message, m_forwardDestinationServers.back()));
|
||||
return;
|
||||
}
|
||||
else if (msg.isType("EndForward"))
|
||||
{
|
||||
if (--m_forwardCounts.back() == 0)
|
||||
{
|
||||
m_forwardCounts.pop_back();
|
||||
m_forwardDestinationServers.pop_back();
|
||||
if (m_forwardDestinationServers.empty())
|
||||
pushAndClearObjectForwarding();
|
||||
} else {
|
||||
switch (msgType) {
|
||||
case constcrc("EndForward"): {
|
||||
if (--m_forwardCounts.back() == 0) {
|
||||
m_forwardCounts.pop_back();
|
||||
m_forwardDestinationServers.pop_back();
|
||||
|
||||
if (m_forwardDestinationServers.empty()) {
|
||||
pushAndClearObjectForwarding();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
case constcrc("BeginForward") : {
|
||||
GenericValueTypeMessage <std::vector<uint32>> const beginForwardMessage(ri);
|
||||
if (beginForwardMessage.getValue() == m_forwardDestinationServers.back())
|
||||
++m_forwardCounts.back();
|
||||
else {
|
||||
m_forwardCounts.push_back(1);
|
||||
m_forwardDestinationServers.push_back(beginForwardMessage.getValue());
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (msg.isType("BeginForward"))
|
||||
{
|
||||
GenericValueTypeMessage<std::vector<uint32> > const beginForwardMessage(ri);
|
||||
if (beginForwardMessage.getValue() == m_forwardDestinationServers.back())
|
||||
++m_forwardCounts.back();
|
||||
else
|
||||
{
|
||||
m_forwardCounts.push_back(1);
|
||||
m_forwardDestinationServers.push_back(beginForwardMessage.getValue());
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (msg.isType("BeginForward"))
|
||||
if (msgType == constcrc("BeginForward"))
|
||||
{
|
||||
GenericValueTypeMessage<std::vector<uint32> > const beginForwardMessage(ri);
|
||||
|
||||
@@ -112,20 +117,22 @@ void PlanetServerConnection::onReceive(Archive::ByteStream const &message)
|
||||
|
||||
ServerConnection::onReceive(message);
|
||||
|
||||
if (msg.isType("CentralPlanetServerConnect"))
|
||||
{
|
||||
CentralPlanetServerConnect const id(ri);
|
||||
sceneId = id.getSceneId();
|
||||
}
|
||||
else if (msg.isType("TaskSpawnProcess"))
|
||||
{
|
||||
TaskSpawnProcess const spawn(ri);
|
||||
CentralServer::getInstance().sendTaskMessage(spawn);
|
||||
}
|
||||
else if (msg.isType("ConGenericMessage"))
|
||||
{
|
||||
ConGenericMessage const con(ri);
|
||||
ConsoleConnection::onCommandComplete(con.getMsg(), static_cast<int>(con.getMsgId()));
|
||||
switch (msgType) {
|
||||
case constcrc("CentralPlanetServerConnect") : {
|
||||
CentralPlanetServerConnect const id(ri);
|
||||
sceneId = id.getSceneId();
|
||||
break;
|
||||
}
|
||||
case constcrc("TaskSpawnProcess") : {
|
||||
TaskSpawnProcess const spawn(ri);
|
||||
CentralServer::getInstance().sendTaskMessage(spawn);
|
||||
break;
|
||||
}
|
||||
case constcrc("ConGenericMessage") : {
|
||||
ConGenericMessage const con(ri);
|
||||
ConsoleConnection::onCommandComplete(con.getMsg(), static_cast<int>(con.getMsgId()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-4
@@ -15,6 +15,8 @@
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
#include "StationPlayersCollectorConnection.h"
|
||||
|
||||
#include "sharedFoundation/CrcConstexpr.hpp"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
StationPlayersCollectorConnection::StationPlayersCollectorConnection(const std::string & a, const unsigned short p) :
|
||||
@@ -55,13 +57,19 @@ void StationPlayersCollectorConnection::onReceive(const Archive::ByteStream & me
|
||||
const GameNetworkMessage msg(ri);
|
||||
ri = message.begin();
|
||||
|
||||
if(msg.isType("OnSPCharacterProfileMessage"))
|
||||
{
|
||||
}
|
||||
else if(msg.isType("ConGenericMessage"))
|
||||
const uint32 messageType = msg.getType();
|
||||
|
||||
if(messageType == constcrc("ConGenericMessage"))
|
||||
{
|
||||
ConGenericMessage con(ri);
|
||||
ConsoleConnection::onCommandComplete(con.getMsg(), static_cast<int>(con.getMsgId()));
|
||||
} else {
|
||||
if(messageType == constcrc("OnSPCharacterProfileMessage"))
|
||||
{
|
||||
DEBUG_WARNING(true, ("StationPlayersCollectorConnection called with unimplemented message type OnSPCharacterProfileMessage."));
|
||||
} else {
|
||||
DEBUG_WARNING(true, ("StationPlayersCollectorConnection called with unknown/unused message type."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
#include "TransferServerConnection.h"
|
||||
|
||||
#include "sharedFoundation/CrcConstexpr.hpp"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
TransferServerConnection::TransferServerConnection(const std::string & a, const unsigned short p) :
|
||||
@@ -65,132 +67,153 @@ void TransferServerConnection::onReceive(const Archive::ByteStream & message)
|
||||
Archive::ReadIterator ri = message.begin();
|
||||
const GameNetworkMessage msg(ri);
|
||||
ri = message.begin();
|
||||
|
||||
const uint32 messageType = msg.getType();
|
||||
|
||||
if(msg.isType("UploadCharacterMessage"))
|
||||
{
|
||||
const UploadCharacterMessage ucm(ri);
|
||||
CentralServer::getInstance().sendToGameServer(ucm.getFromGameServerId(), ucm, true);
|
||||
LOG("TransferServerConnection", ("Received character data for SUID %lu for character object %s on game server %d", ucm.getStationId(), ucm.getFromCharacterId().getValueString().c_str(), ucm.getFromGameServerId()));
|
||||
}
|
||||
else if(msg.isType("CharacterTransferStatusMessage"))
|
||||
{
|
||||
const CharacterTransferStatusMessage ctsm(ri);
|
||||
CentralServer::getInstance().sendToGameServer(ctsm.getGameServerId(), ctsm, true);
|
||||
}
|
||||
else if(msg.isType("TransferRequestCharacterList"))
|
||||
{
|
||||
// simply forward the request to any available login server
|
||||
const GenericValueTypeMessage<TransferCharacterData> request(ri);
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(request));
|
||||
}
|
||||
else if(msg.isType("TransferRequestMoveValidation"))
|
||||
{
|
||||
const TransferRequestMoveValidation request(ri);
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(request));
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferRequestMoveValidation : %s on %s to %s on %s. Forwarding request to LoginServer.", request.getSourceCharacter().c_str(), request.getSourceGalaxy().c_str(), request.getDestinationCharacter().c_str(), request.getDestinationGalaxy().c_str()));
|
||||
}
|
||||
else if(msg.isType("TransferRequestKickConnectedClients"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<unsigned int, unsigned int> > const request(ri);
|
||||
// disconnect any clients with a connection to SWG services
|
||||
GenericValueTypeMessage<unsigned int> kickSource("TransferKickConnectedClients", request.getValue().first);
|
||||
GenericValueTypeMessage<unsigned int> kickDestination("TransferKickConnectedClients", request.getValue().second);
|
||||
CentralServer::getInstance().sendToAllLoginServers(kickSource);
|
||||
CentralServer::getInstance().sendToAllLoginServers(kickDestination);
|
||||
CentralServer::getInstance().sendToAllConnectionServers(kickSource, true);
|
||||
CentralServer::getInstance().sendToAllConnectionServers(kickDestination, true);
|
||||
}
|
||||
else if(msg.isType("TransferGetCharacterDataFromLoginServer"))
|
||||
{
|
||||
const GenericValueTypeMessage<TransferCharacterData> getCharacterData(ri);
|
||||
|
||||
// The transfer server has received a move request. The request doesn't
|
||||
// contain the source id of the character, character's container or scene
|
||||
// information. The LoginServer can retrieve the character ID for the
|
||||
// source station id + character name contained in character data.
|
||||
// Forward the request to the login server. It will respond and the
|
||||
// message can be routed back to the transfer server for further
|
||||
// processing
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(getCharacterData));
|
||||
LOG("CustomerService", ("CharacterTransfer: ***CentralServer: received TransferGetCharacterDataFromLoginServer : %s)", getCharacterData.getValue().toString().c_str()));
|
||||
}
|
||||
else if(msg.isType("TransferGetLoginLocationData"))
|
||||
{
|
||||
GenericValueTypeMessage<TransferCharacterData> getLoginData(ri);
|
||||
CentralServer::getInstance().sendToDBProcess(getLoginData, true);
|
||||
LOG("CustomerService", ("CharacterTransfer: ***CentralServer: Received TransferGetLoginLocationData for %s\n", getLoginData.getValue().getSourceCharacterName().c_str()));
|
||||
}
|
||||
else if(msg.isType("TransferLoginCharacterToSourceServer"))
|
||||
{
|
||||
const GenericValueTypeMessage<TransferCharacterData> loginCharacter(ri);
|
||||
ConnectionServerConnection * connectionServer = CentralServer::getInstance().getAnyConnectionServer();
|
||||
if(connectionServer)
|
||||
switch(messageType) {
|
||||
case constcrc("UploadCharacterMessage") :
|
||||
{
|
||||
connectionServer->send(loginCharacter, true);
|
||||
LOG("CustomerService", ("CharacterTransfer: ***CentralServer: Received TransferLoginCharacterToSourceServer request from Transfer Server. Sendint request to ConnectionServer : %s\n", loginCharacter.getValue().toString().c_str()));
|
||||
const UploadCharacterMessage ucm(ri);
|
||||
CentralServer::getInstance().sendToGameServer(ucm.getFromGameServerId(), ucm, true);
|
||||
LOG("TransferServerConnection", ("Received character data for SUID %lu for character object %s on game server %d", ucm.getStationId(), ucm.getFromCharacterId().getValueString().c_str(), ucm.getFromGameServerId()));
|
||||
break;
|
||||
}
|
||||
else
|
||||
case constcrc("CharacterTransferStatusMessage") :
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: ***CentralServer: Couldn't find a connection server to satisfy the transfer request for %s\n", loginCharacter.getValue().toString().c_str()));
|
||||
const CharacterTransferStatusMessage ctsm(ri);
|
||||
CentralServer::getInstance().sendToGameServer(ctsm.getGameServerId(), ctsm, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(msg.isType("TransferLoginCharacterToDestinationServer"))
|
||||
{
|
||||
const GenericValueTypeMessage<TransferCharacterData> loginCharacter(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: ***CentralServer: Received TransferLoginCharacterToDestinationServer request from Transfer Server for %s\n", loginCharacter.getValue().toString().c_str()));
|
||||
ConnectionServerConnection * connectionServer = CentralServer::getInstance().getAnyConnectionServer();
|
||||
if(connectionServer)
|
||||
case constcrc("TransferRequestCharacterList") :
|
||||
{
|
||||
connectionServer->send(loginCharacter, true);
|
||||
// simply forward the request to any available login server
|
||||
const GenericValueTypeMessage<TransferCharacterData> request(ri);
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(request));
|
||||
break;
|
||||
}
|
||||
case constcrc("TransferRequestMoveValidation") :
|
||||
{
|
||||
const TransferRequestMoveValidation request(ri);
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(request));
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferRequestMoveValidation : %s on %s to %s on %s. Forwarding request to LoginServer.", request.getSourceCharacter().c_str(), request.getSourceGalaxy().c_str(), request.getDestinationCharacter().c_str(), request.getDestinationGalaxy().c_str()));
|
||||
break;
|
||||
}
|
||||
case constcrc("TransferRequestKickConnectedClients") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<unsigned int, unsigned int> > const request(ri);
|
||||
// disconnect any clients with a connection to SWG services
|
||||
GenericValueTypeMessage<unsigned int> kickSource("TransferKickConnectedClients", request.getValue().first);
|
||||
GenericValueTypeMessage<unsigned int> kickDestination("TransferKickConnectedClients", request.getValue().second);
|
||||
CentralServer::getInstance().sendToAllLoginServers(kickSource);
|
||||
CentralServer::getInstance().sendToAllLoginServers(kickDestination);
|
||||
CentralServer::getInstance().sendToAllConnectionServers(kickSource, true);
|
||||
CentralServer::getInstance().sendToAllConnectionServers(kickDestination, true);
|
||||
break;
|
||||
}
|
||||
case constcrc("TransferGetCharacterDataFromLoginServer") :
|
||||
{
|
||||
const GenericValueTypeMessage<TransferCharacterData> getCharacterData(ri);
|
||||
|
||||
// The transfer server has received a move request. The request doesn't
|
||||
// contain the source id of the character, character's container or scene
|
||||
// information. The LoginServer can retrieve the character ID for the
|
||||
// source station id + character name contained in character data.
|
||||
// Forward the request to the login server. It will respond and the
|
||||
// message can be routed back to the transfer server for further
|
||||
// processing
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(getCharacterData));
|
||||
LOG("CustomerService", ("CharacterTransfer: ***CentralServer: received TransferGetCharacterDataFromLoginServer : %s)", getCharacterData.getValue().toString().c_str()));
|
||||
break;
|
||||
}
|
||||
case constcrc("TransferGetLoginLocationData") :
|
||||
{
|
||||
GenericValueTypeMessage<TransferCharacterData> getLoginData(ri);
|
||||
CentralServer::getInstance().sendToDBProcess(getLoginData, true);
|
||||
LOG("CustomerService", ("CharacterTransfer: ***CentralServer: Received TransferGetLoginLocationData for %s\n", getLoginData.getValue().getSourceCharacterName().c_str()));
|
||||
break;
|
||||
}
|
||||
case constcrc("TransferLoginCharacterToSourceServer") :
|
||||
{
|
||||
const GenericValueTypeMessage<TransferCharacterData> loginCharacter(ri);
|
||||
ConnectionServerConnection * connectionServer = CentralServer::getInstance().getAnyConnectionServer();
|
||||
if(connectionServer)
|
||||
{
|
||||
connectionServer->send(loginCharacter, true);
|
||||
LOG("CustomerService", ("CharacterTransfer: ***CentralServer: Received TransferLoginCharacterToSourceServer request from Transfer Server. Sendint request to ConnectionServer : %s\n", loginCharacter.getValue().toString().c_str()));
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: ***CentralServer: Couldn't find a connection server to satisfy the transfer request for %s\n", loginCharacter.getValue().toString().c_str()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case constcrc("TransferLoginCharacterToDestinationServer") :
|
||||
{
|
||||
const GenericValueTypeMessage<TransferCharacterData> loginCharacter(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: ***CentralServer: Received TransferLoginCharacterToDestinationServer request from Transfer Server for %s\n", loginCharacter.getValue().toString().c_str()));
|
||||
ConnectionServerConnection * connectionServer = CentralServer::getInstance().getAnyConnectionServer();
|
||||
if(connectionServer)
|
||||
{
|
||||
connectionServer->send(loginCharacter, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case constcrc("ToggleAvatarLoginStatus") :
|
||||
{
|
||||
ToggleAvatarLoginStatus toggle(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received ToggleAvatarLoginStatus for station ID %d, Character Object %s", toggle.getStationId(), toggle.getCharacterId().getValueString().c_str()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(toggle));
|
||||
break;
|
||||
}
|
||||
case constcrc("TransferRequestNameValidation") :
|
||||
{
|
||||
GenericValueTypeMessage<TransferCharacterData> request(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferRequestNameValidation from TransferServer. Forwarding request to a random GameServer. %s", request.getValue().toString().c_str()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToRandomGameServer(request));
|
||||
break;
|
||||
}
|
||||
case constcrc("TransferRenameCharacter") :
|
||||
{
|
||||
GenericValueTypeMessage<TransferCharacterData> renameRequest(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferRenameCharacter. Sending rename request to game database. %s", renameRequest.getValue().toString().c_str()));
|
||||
// send first portion of request to DBProcess , wait for response
|
||||
CentralServer::getInstance().sendToDBProcess(renameRequest, true);
|
||||
break;
|
||||
}
|
||||
case constcrc("TransferAccountRequestLoginServer") :
|
||||
{
|
||||
// got message to transfer a character from one account to another - have to update in loginServer
|
||||
GenericValueTypeMessage<TransferAccountData> accountTransferRequest(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferAccountRequestLoginServer from station ID %d to station ID %d", accountTransferRequest.getValue().getSourceStationId(), accountTransferRequest.getValue().getDestinationStationId()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(accountTransferRequest));
|
||||
break;
|
||||
}
|
||||
case constcrc("RequestChatTransferAvatar") :
|
||||
{
|
||||
GenericValueTypeMessage<TransferCharacterData> chatTransferAvatar(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received RequestChatTransferAvatar from TransferServer. Forward request to ChatServer. %s", chatTransferAvatar.getValue().toString().c_str()));
|
||||
CentralServer::getInstance().broadcastToChatServers(chatTransferAvatar);
|
||||
break;
|
||||
}
|
||||
case constcrc("DeleteFailedTransfer") :
|
||||
{
|
||||
GenericValueTypeMessage<TransferCharacterData> deleteCharacter(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: received request to delete a character for a failed transfer. %s", deleteCharacter.getValue().toString().c_str()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(deleteCharacter));
|
||||
break;
|
||||
}
|
||||
case constcrc("TransferClosePseudoClientConnection") :
|
||||
{
|
||||
GenericValueTypeMessage<unsigned int> closeRequest(ri);
|
||||
CentralServer::getInstance().sendToAllConnectionServers(closeRequest, true);
|
||||
break;
|
||||
}
|
||||
case constcrc("ConGenericMessage") :
|
||||
{
|
||||
ConGenericMessage con(ri);
|
||||
ConsoleConnection::onCommandComplete(con.getMsg(), static_cast<int>(con.getMsgId()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(msg.isType("ToggleAvatarLoginStatus"))
|
||||
{
|
||||
ToggleAvatarLoginStatus toggle(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received ToggleAvatarLoginStatus for station ID %d, Character Object %s", toggle.getStationId(), toggle.getCharacterId().getValueString().c_str()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(toggle));
|
||||
}
|
||||
else if(msg.isType("TransferRequestNameValidation"))
|
||||
{
|
||||
GenericValueTypeMessage<TransferCharacterData> request(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferRequestNameValidation from TransferServer. Forwarding request to a random GameServer. %s", request.getValue().toString().c_str()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToRandomGameServer(request));
|
||||
}
|
||||
else if(msg.isType("TransferRenameCharacter"))
|
||||
{
|
||||
GenericValueTypeMessage<TransferCharacterData> renameRequest(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferRenameCharacter. Sending rename request to game database. %s", renameRequest.getValue().toString().c_str()));
|
||||
// send first portion of request to DBProcess , wait for response
|
||||
CentralServer::getInstance().sendToDBProcess(renameRequest, true);
|
||||
}
|
||||
else if(msg.isType("TransferAccountRequestLoginServer"))
|
||||
{
|
||||
// got message to transfer a character from one account to another - have to update in loginServer
|
||||
GenericValueTypeMessage<TransferAccountData> accountTransferRequest(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received TransferAccountRequestLoginServer from station ID %d to station ID %d", accountTransferRequest.getValue().getSourceStationId(), accountTransferRequest.getValue().getDestinationStationId()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(accountTransferRequest));
|
||||
}
|
||||
else if(msg.isType("RequestChatTransferAvatar"))
|
||||
{
|
||||
GenericValueTypeMessage<TransferCharacterData> chatTransferAvatar(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received RequestChatTransferAvatar from TransferServer. Forward request to ChatServer. %s", chatTransferAvatar.getValue().toString().c_str()));
|
||||
CentralServer::getInstance().broadcastToChatServers(chatTransferAvatar);
|
||||
}
|
||||
else if(msg.isType("DeleteFailedTransfer"))
|
||||
{
|
||||
GenericValueTypeMessage<TransferCharacterData> deleteCharacter(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: received request to delete a character for a failed transfer. %s", deleteCharacter.getValue().toString().c_str()));
|
||||
IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(deleteCharacter));
|
||||
}
|
||||
else if(msg.isType("TransferClosePseudoClientConnection"))
|
||||
{
|
||||
GenericValueTypeMessage<unsigned int> closeRequest(ri);
|
||||
CentralServer::getInstance().sendToAllConnectionServers(closeRequest, true);
|
||||
}
|
||||
else if(msg.isType("ConGenericMessage"))
|
||||
{
|
||||
ConGenericMessage con(ri);
|
||||
ConsoleConnection::onCommandComplete(con.getMsg(), static_cast<int>(con.getMsgId()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
#include "serverNetworkMessages/SetUniverseAuthoritativeMessage.h"
|
||||
#include "sharedLog/Log.h"
|
||||
|
||||
#include "sharedFoundation/CrcConstexpr.hpp"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
UniverseManager::UniverseManager() :
|
||||
@@ -47,62 +49,72 @@ UniverseManager::~UniverseManager()
|
||||
|
||||
void UniverseManager::receiveMessage(const MessageDispatch::Emitter & source, const MessageDispatch::MessageBase & message)
|
||||
{
|
||||
if(message.isType("CentralGameServerDbProcessServerProcessId"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, ("dbProcess connected\n"));
|
||||
Archive::ReadIterator ri = static_cast<const GameNetworkMessage &>(message).getByteStream().begin();
|
||||
CentralGameServerDbProcessServerProcessId d(ri);
|
||||
|
||||
const GameServerConnection * g = static_cast<const GameServerConnection *>(&source); //lint !e826 Suspicious pointer-to-pointer conversion
|
||||
NOT_NULL(g);
|
||||
onDatabaseProcessConnect(*g);
|
||||
}
|
||||
else if (message.isType("CreateDynamicRegionCircleMessage"))
|
||||
{
|
||||
Archive::ReadIterator ri = static_cast<const GameNetworkMessage &>(message).getByteStream().begin();
|
||||
CreateDynamicRegionCircleMessage msg(ri);
|
||||
if (!m_databaseAuthoritative)
|
||||
CentralServer::getInstance().sendToGameServer(m_universeProcess, msg, true);
|
||||
}
|
||||
else if (message.isType("CreateDynamicRegionRectangleMessage"))
|
||||
{
|
||||
Archive::ReadIterator ri = static_cast<const GameNetworkMessage &>(message).getByteStream().begin();
|
||||
CreateDynamicRegionRectangleMessage msg(ri);
|
||||
if (!m_databaseAuthoritative)
|
||||
CentralServer::getInstance().sendToGameServer(m_universeProcess, msg, true);
|
||||
}
|
||||
else if (message.isType("CreateGroupMessage"))
|
||||
{
|
||||
Archive::ReadIterator ri = static_cast<const GameNetworkMessage &>(message).getByteStream().begin();
|
||||
CreateGroupMessage msg(ri);
|
||||
if (!m_databaseAuthoritative)
|
||||
CentralServer::getInstance().sendToGameServer(m_universeProcess, msg, true);
|
||||
}
|
||||
else if (message.isType("ChangeUniverseProcessMessage"))
|
||||
{
|
||||
Archive::ReadIterator ri = static_cast<const GameNetworkMessage &>(message).getByteStream().begin();
|
||||
ChangeUniverseProcessMessage msg(ri);
|
||||
uint32 processId = static_cast<uint32>(msg.getId());
|
||||
if (!m_databaseAuthoritative && CentralServer::getInstance().getGameServer(processId))
|
||||
const uint32 messageType = message.getType();
|
||||
|
||||
switch(messageType) {
|
||||
case constcrc("CentralGameServerDbProcessServerProcessId") :
|
||||
{
|
||||
m_universeProcess = processId;
|
||||
DEBUG_REPORT_LOG(true, ("Changing our Universe process to %lu\n",m_universeProcess));
|
||||
LOG("Universe", ("Changing our Universe process to %i\n",m_universeProcess));
|
||||
DEBUG_REPORT_LOG(true, ("dbProcess connected\n"));
|
||||
Archive::ReadIterator ri = static_cast<const GameNetworkMessage &>(message).getByteStream().begin();
|
||||
CentralGameServerDbProcessServerProcessId d(ri);
|
||||
|
||||
SetUniverseAuthoritativeMessage authMsg(m_universeProcess);
|
||||
CentralServer::getInstance().sendToAllGameServers(authMsg,true);
|
||||
const GameServerConnection * g = static_cast<const GameServerConnection *>(&source); //lint !e826 Suspicious pointer-to-pointer conversion
|
||||
NOT_NULL(g);
|
||||
onDatabaseProcessConnect(*g);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (message.isType("GameServerUniverseLoadedMessage"))
|
||||
{
|
||||
Archive::ReadIterator ri = static_cast<const GameNetworkMessage &>(message).getByteStream().begin();
|
||||
GameServerUniverseLoadedMessage d(ri);
|
||||
UNREF(d);
|
||||
case constcrc("CreateDynamicRegionCircleMessage") :
|
||||
{
|
||||
Archive::ReadIterator ri = static_cast<const GameNetworkMessage &>(message).getByteStream().begin();
|
||||
CreateDynamicRegionCircleMessage msg(ri);
|
||||
if (!m_databaseAuthoritative)
|
||||
CentralServer::getInstance().sendToGameServer(m_universeProcess, msg, true);
|
||||
break;
|
||||
}
|
||||
case constcrc("CreateDynamicRegionRectangleMessage") :
|
||||
{
|
||||
Archive::ReadIterator ri = static_cast<const GameNetworkMessage &>(message).getByteStream().begin();
|
||||
CreateDynamicRegionRectangleMessage msg(ri);
|
||||
if (!m_databaseAuthoritative)
|
||||
CentralServer::getInstance().sendToGameServer(m_universeProcess, msg, true);
|
||||
break;
|
||||
}
|
||||
case constcrc("CreateGroupMessage") :
|
||||
{
|
||||
Archive::ReadIterator ri = static_cast<const GameNetworkMessage &>(message).getByteStream().begin();
|
||||
CreateGroupMessage msg(ri);
|
||||
if (!m_databaseAuthoritative)
|
||||
CentralServer::getInstance().sendToGameServer(m_universeProcess, msg, true);
|
||||
break;
|
||||
}
|
||||
case constcrc("ChangeUniverseProcessMessage") :
|
||||
{
|
||||
Archive::ReadIterator ri = static_cast<const GameNetworkMessage &>(message).getByteStream().begin();
|
||||
ChangeUniverseProcessMessage msg(ri);
|
||||
uint32 processId = static_cast<uint32>(msg.getId());
|
||||
if (!m_databaseAuthoritative && CentralServer::getInstance().getGameServer(processId))
|
||||
{
|
||||
m_universeProcess = processId;
|
||||
DEBUG_REPORT_LOG(true, ("Changing our Universe process to %lu\n",m_universeProcess));
|
||||
LOG("Universe", ("Changing our Universe process to %i\n",m_universeProcess));
|
||||
|
||||
const GameServerConnection * g = static_cast<const GameServerConnection *>(&source); //lint !e826 Suspicious pointer-to-pointer conversion
|
||||
NOT_NULL(g);
|
||||
// DEBUG_REPORT_LOG(true,("m_serversLoadingUniverse->erase(%lu);\n",g->getProcessId()));
|
||||
IGNORE_RETURN(m_serversLoadingUniverse->erase(g->getProcessId()));
|
||||
SetUniverseAuthoritativeMessage authMsg(m_universeProcess);
|
||||
CentralServer::getInstance().sendToAllGameServers(authMsg,true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case constcrc("GameServerUniverseLoadedMessage") :
|
||||
{
|
||||
Archive::ReadIterator ri = static_cast<const GameNetworkMessage &>(message).getByteStream().begin();
|
||||
GameServerUniverseLoadedMessage d(ri);
|
||||
UNREF(d);
|
||||
|
||||
const GameServerConnection * g = static_cast<const GameServerConnection *>(&source); //lint !e826 Suspicious pointer-to-pointer conversion
|
||||
NOT_NULL(g);
|
||||
// DEBUG_REPORT_LOG(true,("m_serversLoadingUniverse->erase(%lu);\n",g->getProcessId()));
|
||||
IGNORE_RETURN(m_serversLoadingUniverse->erase(g->getProcessId()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// CentralServerPrecompiledHeader.cpp
|
||||
// copyright 2001 Verant Interactive
|
||||
// Author: Justin Randall
|
||||
|
||||
#include "FirstCentralServer.h"
|
||||
@@ -0,0 +1,84 @@
|
||||
#include "FirstCentralServer.h"
|
||||
#include "ConfigCentralServer.h"
|
||||
#include "CentralServer.h"
|
||||
|
||||
#include "sharedCompression/SetupSharedCompression.h"
|
||||
#include "sharedDebug/SetupSharedDebug.h"
|
||||
#include "sharedFile/SetupSharedFile.h"
|
||||
#include "sharedFoundation/SetupSharedFoundation.h"
|
||||
#include "sharedNetworkMessages/SetupSharedNetworkMessages.h"
|
||||
#include "sharedRandom/SetupSharedRandom.h"
|
||||
#include "sharedThread/SetupSharedThread.h"
|
||||
|
||||
#include <string>
|
||||
#include <time.h>
|
||||
|
||||
//_____________________________________________________________________
|
||||
/*
|
||||
int WINAPI WinMain(
|
||||
HINSTANCE hInstance, // handle to current instance
|
||||
HINSTANCE hPrevInstance, // handle to previous instance
|
||||
LPSTR lpCmdLine, // pointer to command line
|
||||
int nCmdShow // show state of window
|
||||
)
|
||||
*/
|
||||
int main(int argc, char ** argv)
|
||||
{ //lint !e1065 //WinMain conflicts with clib
|
||||
int i = 0;
|
||||
|
||||
// UNREF(hPrevInstance);
|
||||
// UNREF(nCmdShow);
|
||||
|
||||
SetupSharedThread::install();
|
||||
SetupSharedDebug::install(1024);
|
||||
|
||||
//-- setup foundation
|
||||
SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game);
|
||||
|
||||
// command line hack
|
||||
std::string cmdLine;
|
||||
for(i = 1; i < argc; ++i)
|
||||
{
|
||||
cmdLine += argv[i];
|
||||
if(i + 1 < argc)
|
||||
{
|
||||
cmdLine += " ";
|
||||
}
|
||||
}
|
||||
// setupFoundationData.hInstance = hInstance;
|
||||
setupFoundationData.commandLine = cmdLine.c_str();
|
||||
setupFoundationData.createWindow = false;
|
||||
setupFoundationData.clockUsesSleep = true;
|
||||
|
||||
SetupSharedFoundation::install (setupFoundationData);
|
||||
|
||||
SetupSharedCompression::install();
|
||||
|
||||
SetupSharedFile::install(false);
|
||||
|
||||
SetupSharedNetworkMessages::install();
|
||||
|
||||
ConfigCentralServer::install();
|
||||
|
||||
cmdLine = "";
|
||||
// now, the real command line
|
||||
for(i = 0; i < argc; ++i)
|
||||
{
|
||||
cmdLine += argv[i];
|
||||
if(i + 1 < argc)
|
||||
{
|
||||
cmdLine += " ";
|
||||
}
|
||||
}
|
||||
|
||||
CentralServer::getInstance().setCommandLine(cmdLine);
|
||||
|
||||
//-- run game
|
||||
SetupSharedFoundation::callbackWithExceptionHandling(CentralServer::run);
|
||||
|
||||
SetupSharedFoundation::remove();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________
|
||||
@@ -29,7 +29,7 @@ int main(int argc, char ** argv)
|
||||
SetupSharedFile::install(false);
|
||||
SetupSharedNetworkMessages::install();
|
||||
|
||||
SetupSharedRandom::install(static_cast<uint32>(time(NULL))); //lint !e1924 !e64 // NULL is a C-Style cast?
|
||||
SetupSharedRandom::install(static_cast<uint32>(time(nullptr))); //lint !e1924 !e64 // nullptr is a C-Style cast?
|
||||
|
||||
Os::setProgramName("ChatServer");
|
||||
//setup the server
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#include "sharedNetwork/Service.h"
|
||||
#include "UnicodeUtils.h"
|
||||
|
||||
#include "sharedFoundation/CrcConstexpr.hpp"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
CentralServerConnection::CentralServerConnection(const std::string & a, const unsigned short p) :
|
||||
@@ -62,63 +64,73 @@ void CentralServerConnection::onReceive(const Archive::ByteStream & message)
|
||||
GameNetworkMessage m(ri);
|
||||
|
||||
ri = message.begin();
|
||||
|
||||
const uint32 messageType = m.getType();
|
||||
|
||||
if(m.isType("EnumerateServers"))
|
||||
{
|
||||
static MessageDispatch::Transceiver<const EnumerateServers &> emitter;
|
||||
|
||||
EnumerateServers e(ri);
|
||||
emitter.emitMessage(e);
|
||||
}
|
||||
else if (m.isType("CustomerServiceServerChatServerServiceAddress"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::string, unsigned short> > msg(ri);
|
||||
|
||||
ChatServer::instance().connectToCustomerServiceServer(msg.getValue().first, msg.getValue().second);
|
||||
}
|
||||
else if(m.isType("RequestChatTransferAvatar"))
|
||||
{
|
||||
GenericValueTypeMessage<TransferCharacterData> request(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received RequestChatTransferAvatar from CentralServer. Forwarding request to ChatAPI. %s", request.getValue().toString().c_str()));
|
||||
ChatServer::requestTransferAvatar(request.getValue());
|
||||
}
|
||||
else if (m.isType("RenameCharacterMessageEx"))
|
||||
{
|
||||
RenameCharacterMessageEx const msg(ri);
|
||||
|
||||
// if the player requested the rename, also rename the chat
|
||||
// avatar, so mail, friends list, and ignore list will migrate
|
||||
if ((msg.getRenameCharacterMessageSource() == RenameCharacterMessageEx::RCMS_player_request) && !msg.getLastNameChangeOnly() && !ConfigFile::getKeyBool("CharacterRename", "disableRenameChatAvatar", false))
|
||||
switch(messageType) {
|
||||
case constcrc("EnumerateServers") :
|
||||
{
|
||||
std::string const oldName(Unicode::toLower(Unicode::wideToNarrow(msg.getOldName())));
|
||||
std::string const oldNameNormalized(oldName, 0, oldName.find(' '));
|
||||
ChatAvatarId const oldAvatar("SWG", ConfigChatServer::getClusterName(), oldNameNormalized);
|
||||
static MessageDispatch::Transceiver<const EnumerateServers &> emitter;
|
||||
|
||||
std::string const newName(Unicode::toLower(Unicode::wideToNarrow(msg.getNewName())));
|
||||
std::string const newNameNormalized(newName, 0, newName.find(' '));
|
||||
ChatAvatarId const newAvatar("SWG", ConfigChatServer::getClusterName(), newNameNormalized);
|
||||
|
||||
IGNORE_RETURN(ChatServer::getChatInterface()->RequestTransferAvatar(msg.getStationId(), oldAvatar.getName(), oldAvatar.getAPIAddress(), msg.getStationId(), newAvatar.getName(), newAvatar.getAPIAddress(), true, NULL));
|
||||
EnumerateServers e(ri);
|
||||
emitter.emitMessage(e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (m.isType("ChatDestroyAvatar"))
|
||||
{
|
||||
GenericValueTypeMessage<std::string> const msg(ri);
|
||||
ChatServer::getChatInterface()->DestroyAvatar(msg.getValue());
|
||||
}
|
||||
else if(m.isType("AllCluserGlobalChannel"))
|
||||
{
|
||||
typedef std::pair<std::pair<std::string,std::string>, bool> PayloadType;
|
||||
GenericValueTypeMessage<PayloadType> msg(ri);
|
||||
case constcrc("CustomerServiceServerChatServerServiceAddress") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::string, unsigned short> > msg(ri);
|
||||
|
||||
PayloadType const & payload = msg.getValue();
|
||||
std::string const & channelName = payload.first.first;
|
||||
std::string const & messageText = payload.first.second;
|
||||
bool const & isRemove = payload.second;
|
||||
ChatServer::instance().connectToCustomerServiceServer(msg.getValue().first, msg.getValue().second);
|
||||
break;
|
||||
}
|
||||
case constcrc("RequestChatTransferAvatar") :
|
||||
{
|
||||
GenericValueTypeMessage<TransferCharacterData> request(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received RequestChatTransferAvatar from CentralServer. Forwarding request to ChatAPI. %s", request.getValue().toString().c_str()));
|
||||
ChatServer::requestTransferAvatar(request.getValue());
|
||||
break;
|
||||
}
|
||||
case constcrc("RenameCharacterMessageEx") :
|
||||
{
|
||||
RenameCharacterMessageEx const msg(ri);
|
||||
|
||||
LOG("CustomerService", ("BroadcastVoiceChannel: ChatServer got AllCluserGlobalChannel on CentralServerConnection chan(%s) text(%s) remove(%d)",
|
||||
channelName.c_str(), messageText.c_str(), (isRemove?1:0)));
|
||||
ChatServer::requestBroadcastChannelMessage(channelName, messageText, isRemove);
|
||||
// if the player requested the rename, also rename the chat
|
||||
// avatar, so mail, friends list, and ignore list will migrate
|
||||
if ((msg.getRenameCharacterMessageSource() == RenameCharacterMessageEx::RCMS_player_request) && !msg.getLastNameChangeOnly() && !ConfigFile::getKeyBool("CharacterRename", "disableRenameChatAvatar", false))
|
||||
{
|
||||
std::string const oldName(Unicode::toLower(Unicode::wideToNarrow(msg.getOldName())));
|
||||
std::string const oldNameNormalized(oldName, 0, oldName.find(' '));
|
||||
ChatAvatarId const oldAvatar("SWG", ConfigChatServer::getClusterName(), oldNameNormalized);
|
||||
|
||||
std::string const newName(Unicode::toLower(Unicode::wideToNarrow(msg.getNewName())));
|
||||
std::string const newNameNormalized(newName, 0, newName.find(' '));
|
||||
ChatAvatarId const newAvatar("SWG", ConfigChatServer::getClusterName(), newNameNormalized);
|
||||
|
||||
IGNORE_RETURN(ChatServer::getChatInterface()->RequestTransferAvatar(msg.getStationId(), oldAvatar.getName(), oldAvatar.getAPIAddress(), msg.getStationId(), newAvatar.getName(), newAvatar.getAPIAddress(), true, nullptr));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatDestroyAvatar") :
|
||||
{
|
||||
GenericValueTypeMessage<std::string> const msg(ri);
|
||||
ChatServer::getChatInterface()->DestroyAvatar(msg.getValue());
|
||||
break;
|
||||
}
|
||||
case constcrc("AllCluserGlobalChannel") :
|
||||
{
|
||||
typedef std::pair<std::pair<std::string,std::string>, bool> PayloadType;
|
||||
GenericValueTypeMessage<PayloadType> msg(ri);
|
||||
|
||||
PayloadType const & payload = msg.getValue();
|
||||
std::string const & channelName = payload.first.first;
|
||||
std::string const & messageText = payload.first.second;
|
||||
bool const & isRemove = payload.second;
|
||||
|
||||
LOG("CustomerService", ("BroadcastVoiceChannel: ChatServer got AllCluserGlobalChannel on CentralServerConnection chan(%s) text(%s) remove(%d)",
|
||||
channelName.c_str(), messageText.c_str(), (isRemove?1:0)));
|
||||
ChatServer::requestBroadcastChannelMessage(channelName, messageText, isRemove);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -350,7 +350,7 @@ void ChatInterface::OnGetRoom(unsigned track, unsigned result, const ChatRoom *r
|
||||
if (room)
|
||||
makeRoomName(room, roomName);
|
||||
//printf("!!!!!!!!!!!!got room %s\n", roomName.c_str());
|
||||
if (strstr(roomName.c_str(), "group") == NULL)
|
||||
if (strstr(roomName.c_str(), "group") == nullptr)
|
||||
{
|
||||
ChatServer::putSystemAvatarInRoom(roomName);
|
||||
}
|
||||
@@ -373,7 +373,7 @@ void ChatInterface::OnGetRoom(unsigned track, unsigned result, const ChatRoom *r
|
||||
}
|
||||
}
|
||||
|
||||
ChatServerRoomOwner *owner = NULL;
|
||||
ChatServerRoomOwner *owner = nullptr;
|
||||
if (room)
|
||||
owner = getRoomOwner(room->getRoomID());
|
||||
|
||||
@@ -709,12 +709,12 @@ std::string makeCanonicalName(const std::string &characterName)
|
||||
{
|
||||
retVal = toUpper(tmp);
|
||||
}
|
||||
tmp = strtok(NULL, ".");
|
||||
tmp = strtok(nullptr, ".");
|
||||
if (tmp)
|
||||
{
|
||||
retVal += (dot + tmp);
|
||||
}
|
||||
tmp = strtok(NULL, ".");
|
||||
tmp = strtok(nullptr, ".");
|
||||
if (tmp)
|
||||
{
|
||||
retVal += (dot + tmp);
|
||||
@@ -796,7 +796,7 @@ void ChatInterface::DestroyAvatar(const std::string & characterName)
|
||||
|
||||
// track how many times we have called RequestGetAnyAvatar() for this particular DestroyAvatar
|
||||
// operation, so that we can stop if we somehow get stuck in an infinite loop
|
||||
unsigned const trackID = RequestGetAnyAvatar(ChatUnicodeString(avatar.getName()), ChatUnicodeString(avatar.getAPIAddress()), NULL);
|
||||
unsigned const trackID = RequestGetAnyAvatar(ChatUnicodeString(avatar.getName()), ChatUnicodeString(avatar.getAPIAddress()), nullptr);
|
||||
trackingRequestGetAnyAvatarForDestroy[trackID] = std::make_pair(std::make_pair(ChatUnicodeString(avatar.getName()), ChatUnicodeString(avatar.getAPIAddress())), 1);
|
||||
}
|
||||
|
||||
@@ -848,7 +848,7 @@ void ChatInterface::sendQueuedHeadersToClient()
|
||||
const unsigned long queuedHeadersSendTime = currentTime + static_cast<unsigned long>(s_intervalToSendHeadersToClientSeconds);
|
||||
|
||||
int numberHeadersSent = 0;
|
||||
const ChatPersistentMessageToClient * header = NULL;
|
||||
const ChatPersistentMessageToClient * header = nullptr;
|
||||
|
||||
for (std::map<ChatAvatarId, std::pair<unsigned long, std::deque<const ChatPersistentMessageToClient *> > >::iterator iter = queuedHeaders.begin(); iter != queuedHeaders.end();)
|
||||
{
|
||||
@@ -900,7 +900,7 @@ void ChatInterface::clearQueuedHeadersForAvatar(const ChatAvatarId & avatarId)
|
||||
|
||||
void ChatInterface::addQueuedHeaderForAvatar(const ChatAvatarId & avatarId, const ChatPersistentMessageToClient * header, unsigned long sendTime)
|
||||
{
|
||||
if (header == NULL)
|
||||
if (header == nullptr)
|
||||
return;
|
||||
|
||||
std::pair<unsigned long, std::deque<const ChatPersistentMessageToClient *> > & queuedHeader = queuedHeaders[avatarId];
|
||||
@@ -923,7 +923,7 @@ ChatServerAvatarOwner *ChatInterface::getAvatarOwner(const ChatAvatar *avatar)
|
||||
return (*f).second;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@@ -944,7 +944,7 @@ void ChatInterface::OnAddModerator(unsigned track, unsigned result, const ChatAv
|
||||
sequence = pair->sequence;
|
||||
|
||||
delete pair;
|
||||
pair = NULL;
|
||||
pair = nullptr;
|
||||
}
|
||||
|
||||
ChatAvatarId srcId;
|
||||
@@ -1057,7 +1057,7 @@ void ChatInterface::OnRemoveModerator(unsigned track, unsigned result, const Cha
|
||||
sequence = pair->sequence;
|
||||
|
||||
delete pair;
|
||||
pair = NULL;
|
||||
pair = nullptr;
|
||||
}
|
||||
|
||||
ChatAvatarId srcId;
|
||||
@@ -1178,7 +1178,7 @@ void ChatInterface::OnAddFriend(unsigned track, unsigned result, const ChatAvata
|
||||
ChatAvatarId d;
|
||||
makeAvatarId(destName, destAddress, d);
|
||||
|
||||
ChatServerAvatarOwner * mo = NULL;
|
||||
ChatServerAvatarOwner * mo = nullptr;
|
||||
if (srcAvatar)
|
||||
mo = getAvatarOwner(srcAvatar);
|
||||
|
||||
@@ -1206,7 +1206,7 @@ void ChatInterface::OnRemoveFriend(unsigned track, unsigned result, const ChatAv
|
||||
ChatAvatarId d;
|
||||
makeAvatarId(destName, destAddress, d);
|
||||
|
||||
ChatServerAvatarOwner * mo = NULL;
|
||||
ChatServerAvatarOwner * mo = nullptr;
|
||||
if (srcAvatar)
|
||||
mo = getAvatarOwner(srcAvatar);
|
||||
|
||||
@@ -1245,7 +1245,7 @@ void ChatInterface::OnIgnoreStatus(unsigned track, unsigned result, const ChatAv
|
||||
}
|
||||
}
|
||||
|
||||
ChatServerAvatarOwner * mo = NULL;
|
||||
ChatServerAvatarOwner * mo = nullptr;
|
||||
if (srcAvatar)
|
||||
mo = getAvatarOwner(srcAvatar);
|
||||
if(mo)
|
||||
@@ -1281,7 +1281,7 @@ void ChatInterface::OnFriendStatus(unsigned track, unsigned result, const ChatAv
|
||||
idList.push_back(id);
|
||||
}
|
||||
}
|
||||
ChatServerAvatarOwner * mo = NULL;
|
||||
ChatServerAvatarOwner * mo = nullptr;
|
||||
if (srcAvatar)
|
||||
mo = getAvatarOwner(srcAvatar);
|
||||
if(mo)
|
||||
@@ -1304,7 +1304,7 @@ void ChatInterface::OnReceiveFriendLogin(const ChatAvatar *srcAvatar, const Chat
|
||||
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ChatInterface - OnReceiveFriendLogin");
|
||||
UNREF(srcAddress);
|
||||
ChatServerAvatarOwner * owner = NULL;
|
||||
ChatServerAvatarOwner * owner = nullptr;
|
||||
if (destAvatar)
|
||||
owner = getAvatarOwner(destAvatar);
|
||||
if(owner)
|
||||
@@ -1332,7 +1332,7 @@ void ChatInterface::OnReceiveFriendLogout(const ChatAvatar *srcAvatar, const Cha
|
||||
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ChatInterface - OnReceiveFriendLogout");
|
||||
UNREF(srcAddress);
|
||||
ChatServerAvatarOwner * owner = NULL;
|
||||
ChatServerAvatarOwner * owner = nullptr;
|
||||
if (destAvatar)
|
||||
owner = getAvatarOwner(destAvatar);
|
||||
if(owner)
|
||||
@@ -1395,7 +1395,7 @@ void ChatInterface::OnRemoveIgnore(unsigned track, unsigned result, const ChatAv
|
||||
ChatAvatarId d;
|
||||
makeAvatarId(destName, destAddress, d);
|
||||
|
||||
ChatServerAvatarOwner * mo = NULL;
|
||||
ChatServerAvatarOwner * mo = nullptr;
|
||||
if (srcAvatar)
|
||||
mo = getAvatarOwner(srcAvatar);
|
||||
if(mo)
|
||||
@@ -1435,7 +1435,7 @@ void ChatInterface::OnLoginAvatar(unsigned track, unsigned result, const ChatAva
|
||||
if ((result == CHATRESULT_SUCCESS) && newAvatar)
|
||||
{
|
||||
// destroy chat avatar
|
||||
unsigned const trackID = RequestDestroyAvatar(newAvatar, NULL);
|
||||
unsigned const trackID = RequestDestroyAvatar(newAvatar, nullptr);
|
||||
trackingRequestGetAnyAvatarForDestroy[trackID] = iterFind->second;
|
||||
}
|
||||
|
||||
@@ -1504,7 +1504,7 @@ void ChatInterface::OnLoginAvatar(unsigned track, unsigned result, const ChatAva
|
||||
static Unicode::String wideFilter = Unicode::narrowToWide("");
|
||||
static ChatUnicodeString swgNode(wideSWG.data(), wideSWG.size());
|
||||
static ChatUnicodeString filter(wideFilter.data(), wideFilter.size());
|
||||
IGNORE_RETURN(RequestGetRoomSummaries(swgNode, filter, NULL));
|
||||
IGNORE_RETURN(RequestGetRoomSummaries(swgNode, filter, nullptr));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1525,11 +1525,11 @@ void ChatInterface::OnLoginAvatar(unsigned track, unsigned result, const ChatAva
|
||||
|
||||
if(ChatServer::isGod(f->second))
|
||||
{
|
||||
RequestSetAvatarAttributes(newAvatar, AVATARATTR_GM, NULL);
|
||||
RequestSetAvatarAttributes(newAvatar, AVATARATTR_GM, nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
RequestSetAvatarAttributes(newAvatar, 0, NULL);
|
||||
RequestSetAvatarAttributes(newAvatar, 0, nullptr);
|
||||
}
|
||||
|
||||
ChatServer::chatConnectedAvatar((*f).second, *newAvatar);
|
||||
@@ -1549,7 +1549,7 @@ void ChatInterface::OnLoginAvatar(unsigned track, unsigned result, const ChatAva
|
||||
//ChatServer::getFriendsList(id);
|
||||
|
||||
clearQueuedHeadersForAvatar(avId);
|
||||
IGNORE_RETURN(RequestGetPersistentHeaders(newAvatar, NULL));
|
||||
IGNORE_RETURN(RequestGetPersistentHeaders(newAvatar, nullptr));
|
||||
//REPORT_LOG(true, ("Connection to chat system for %s.%s.%s confirmed\n", avatar.GetGameCode().c_str(), avatar.GetGameServerName().c_str(), avatar.GetCharacterName().c_str()));
|
||||
}//lint !e429 Custodial pointer 'owner' has not been freed or returned // jrandall avatar owns it
|
||||
pendingAvatars.erase(f);
|
||||
@@ -1560,7 +1560,7 @@ void ChatInterface::OnLoginAvatar(unsigned track, unsigned result, const ChatAva
|
||||
// the time they connected to the connection server and the time
|
||||
// this message arrived from the chat backend.
|
||||
if (newAvatar)
|
||||
IGNORE_RETURN(RequestLogoutAvatar(newAvatar, NULL));
|
||||
IGNORE_RETURN(RequestLogoutAvatar(newAvatar, nullptr));
|
||||
}
|
||||
}
|
||||
ChatOnConnectAvatar const connect;
|
||||
@@ -1585,7 +1585,7 @@ void ChatInterface::OnCreateRoom(unsigned track,unsigned result, const ChatRoom
|
||||
static ChatUnicodeString swgNode(wideSWG.data(), wideSWG.size());
|
||||
static ChatUnicodeString filter(wideFilter.data(), wideFilter.size());
|
||||
//printf("!!!!Calling GetRoomSummaries from OnCreateRoom\n");
|
||||
//IGNORE_RETURN(RequestGetRoomSummaries(swgNode, filter, NULL));
|
||||
//IGNORE_RETURN(RequestGetRoomSummaries(swgNode, filter, nullptr));
|
||||
|
||||
ChatRoomData roomData;
|
||||
|
||||
@@ -1598,7 +1598,7 @@ void ChatInterface::OnCreateRoom(unsigned track,unsigned result, const ChatRoom
|
||||
//Unicode::String wideRoomName(newRoom->getRoomName().string_data, newRoom->getRoomName().string_length);
|
||||
std::string roomName;
|
||||
makeRoomName(newRoom, roomName);
|
||||
if (strstr(roomName.c_str(), "group") == NULL)
|
||||
if (strstr(roomName.c_str(), "group") == nullptr)
|
||||
{
|
||||
ChatServer::putSystemAvatarInRoom(roomName);
|
||||
}
|
||||
@@ -1644,7 +1644,7 @@ void ChatInterface::OnGetRoomSummaries(unsigned track, unsigned result, unsigned
|
||||
std::unordered_map<std::string, ChatServerRoomOwner>::const_iterator f = roomList.find(lowerRoomName);
|
||||
if(f == roomList.end())
|
||||
{
|
||||
RequestGetRoom(foundRooms[i].getRoomAddress(), NULL);
|
||||
RequestGetRoom(foundRooms[i].getRoomAddress(), nullptr);
|
||||
//ChatServerRoomOwner * o = new ChatServerRoomOwner((*i));
|
||||
//(*i)->SetRoomOwnerPtr(o);
|
||||
//IGNORE_RETURN(roomList.insert(std::make_pair(lowerRoomName, *o)));
|
||||
@@ -1664,7 +1664,7 @@ const ChatServerRoomOwner *ChatInterface::getRoomOwner(const std::string & roomN
|
||||
{
|
||||
return &((*f).second);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@@ -1680,7 +1680,7 @@ ChatServerRoomOwner *ChatInterface::getRoomOwner(unsigned roomId)
|
||||
}
|
||||
++f;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@@ -1727,13 +1727,13 @@ void ChatInterface::OnDestroyRoom(unsigned track, unsigned result, void *user)
|
||||
static Unicode::String wideFilter = Unicode::narrowToWide("");
|
||||
static ChatUnicodeString swgNode(wideSWG.data(), wideSWG.size());
|
||||
static ChatUnicodeString filter(wideFilter.data(), wideFilter.size());
|
||||
//IGNORE_RETURN(RequestGetRoomSummaries(swgNode, filter, NULL));
|
||||
//IGNORE_RETURN(RequestGetRoomSummaries(swgNode, filter, nullptr));
|
||||
|
||||
ChatAvatarId destroyer;
|
||||
|
||||
RoomOwnerSequencePair *pair = (RoomOwnerSequencePair *)user;
|
||||
|
||||
const ChatServerRoomOwner * owner = NULL;
|
||||
const ChatServerRoomOwner * owner = nullptr;
|
||||
unsigned sequence = 0;
|
||||
if (pair)
|
||||
{
|
||||
@@ -1805,7 +1805,7 @@ void ChatInterface::OnDestroyAvatar(unsigned track, unsigned result, const ChatA
|
||||
// stop if it looks like we're in an infinite loop
|
||||
if (iterFind->second.second <= 25)
|
||||
{
|
||||
unsigned const trackID = RequestGetAnyAvatar(iterFind->second.first.first, iterFind->second.first.second, NULL);
|
||||
unsigned const trackID = RequestGetAnyAvatar(iterFind->second.first.first, iterFind->second.first.second, nullptr);
|
||||
trackingRequestGetAnyAvatarForDestroy[trackID] = std::make_pair(iterFind->second.first, (iterFind->second.second + 1));
|
||||
}
|
||||
}
|
||||
@@ -1828,13 +1828,13 @@ void ChatInterface::OnGetAnyAvatar(unsigned track, unsigned result, const ChatAv
|
||||
// can only destroy the avatar if he is logged in
|
||||
if (loggedIn)
|
||||
{
|
||||
unsigned const trackID = RequestDestroyAvatar(foundAvatar, NULL);
|
||||
unsigned const trackID = RequestDestroyAvatar(foundAvatar, nullptr);
|
||||
trackingRequestGetAnyAvatarForDestroy[trackID] = iterFind->second;
|
||||
}
|
||||
// log in the chat avatar so we can destroy him
|
||||
else
|
||||
{
|
||||
unsigned const trackID = RequestLoginAvatar(foundAvatar->getUserID(), foundAvatar->getName(), foundAvatar->getAddress(), NULL);
|
||||
unsigned const trackID = RequestLoginAvatar(foundAvatar->getUserID(), foundAvatar->getName(), foundAvatar->getAddress(), nullptr);
|
||||
trackingRequestGetAnyAvatarForDestroy[trackID] = iterFind->second;
|
||||
}
|
||||
}
|
||||
@@ -1850,9 +1850,9 @@ void ChatInterface::OnReceiveForcedLogout(const ChatAvatar *oldAvatar)
|
||||
ChatServer::fileLog(false, "ChatInterface", "OnReceiveForcedLogout() oldAvatar(%s)", ChatServer::getFullChatAvatarName(oldAvatar).c_str());
|
||||
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ChatInterface - OnReceiveForcedLogout");
|
||||
if (oldAvatar == NULL)
|
||||
if (oldAvatar == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("We received an OnReceiveForcedLogout with a success result code but NULL data. This is an error that the API should never give."));
|
||||
DEBUG_WARNING(true, ("We received an OnReceiveForcedLogout with a success result code but nullptr data. This is an error that the API should never give."));
|
||||
return;
|
||||
}
|
||||
ChatAvatarId id;
|
||||
@@ -1876,9 +1876,9 @@ void ChatInterface::OnEnterRoom(unsigned track, unsigned result, const ChatAvata
|
||||
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ChatInterface - OnEnterRoom");
|
||||
|
||||
if (result == CHATRESULT_SUCCESS && (srcAvatar == NULL || destRoom == NULL))
|
||||
if (result == CHATRESULT_SUCCESS && (srcAvatar == nullptr || destRoom == nullptr))
|
||||
{
|
||||
DEBUG_WARNING(true, ("We received an OnEnterRoom with a success result code but NULL data. This is an error that the API should never give."));
|
||||
DEBUG_WARNING(true, ("We received an OnEnterRoom with a success result code but nullptr data. This is an error that the API should never give."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2097,9 +2097,9 @@ void ChatInterface::OnAddBan(unsigned track, unsigned result, const ChatAvatar *
|
||||
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ChatInterface - OnAddBan");
|
||||
|
||||
if (result == CHATRESULT_SUCCESS && (srcAvatar == NULL || destRoom == NULL))
|
||||
if (result == CHATRESULT_SUCCESS && (srcAvatar == nullptr || destRoom == nullptr))
|
||||
{
|
||||
DEBUG_WARNING(true, ("We received an OnAddBan with a success result code but NULL data. This is an error that the API should never give."));
|
||||
DEBUG_WARNING(true, ("We received an OnAddBan with a success result code but nullptr data. This is an error that the API should never give."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2113,7 +2113,7 @@ void ChatInterface::OnAddBan(unsigned track, unsigned result, const ChatAvatar *
|
||||
sequence = pair->sequence;
|
||||
|
||||
delete pair;
|
||||
pair = NULL;
|
||||
pair = nullptr;
|
||||
}
|
||||
|
||||
ChatAvatarId srcId;
|
||||
@@ -2218,9 +2218,9 @@ void ChatInterface::OnRemoveBan(unsigned track, unsigned result, const ChatAvata
|
||||
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ChatInterface - OnRemoveBan");
|
||||
|
||||
if (result == CHATRESULT_SUCCESS && (srcAvatar == NULL || destRoom == NULL))
|
||||
if (result == CHATRESULT_SUCCESS && (srcAvatar == nullptr || destRoom == nullptr))
|
||||
{
|
||||
DEBUG_WARNING(true, ("We received an OnRemoveBan with a success result code but NULL data. This is an error that the API should never give."));
|
||||
DEBUG_WARNING(true, ("We received an OnRemoveBan with a success result code but nullptr data. This is an error that the API should never give."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2234,7 +2234,7 @@ void ChatInterface::OnRemoveBan(unsigned track, unsigned result, const ChatAvata
|
||||
sequence = pair->sequence;
|
||||
|
||||
delete pair;
|
||||
pair = NULL;
|
||||
pair = nullptr;
|
||||
}
|
||||
|
||||
ChatAvatarId srcId;
|
||||
@@ -2337,23 +2337,21 @@ void ChatInterface::OnAddInvite(unsigned track, unsigned result, const ChatAvata
|
||||
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ChatInterface - OnAddInvite");
|
||||
|
||||
if (result == CHATRESULT_SUCCESS && (srcAvatar == NULL || destRoom == NULL))
|
||||
if (result == CHATRESULT_SUCCESS && (srcAvatar == nullptr || destRoom == nullptr))
|
||||
{
|
||||
DEBUG_WARNING(true, ("We received an OnAddInvite with a success result code but NULL data. This is an error that the API should never give."));
|
||||
DEBUG_WARNING(true, ("We received an OnAddInvite with a success result code but nullptr data. This is an error that the API should never give."));
|
||||
return;
|
||||
}
|
||||
|
||||
AvatarIdSequencePair *pair = (AvatarIdSequencePair *)user;
|
||||
|
||||
unsigned sequence = 0;
|
||||
ChatAvatarId destId;
|
||||
if (pair)
|
||||
{
|
||||
destId = pair->avatar;
|
||||
sequence = pair->sequence;
|
||||
|
||||
delete pair;
|
||||
pair = NULL;
|
||||
pair = nullptr;
|
||||
}
|
||||
|
||||
ChatAvatarId srcId;
|
||||
@@ -2378,7 +2376,7 @@ void ChatInterface::OnAddInvite(unsigned track, unsigned result, const ChatAvata
|
||||
{
|
||||
// Calling this on a room will cause the API to cache the room
|
||||
// and to receive room updates for the room.
|
||||
RequestGetRoom(destRoom->getAddress(), NULL);
|
||||
RequestGetRoom(destRoom->getAddress(), nullptr);
|
||||
|
||||
// Send the room data for the room the avatar was invited to join
|
||||
// since the room may be private and may be unknown to the player
|
||||
@@ -2455,9 +2453,9 @@ void ChatInterface::OnRemoveInvite(unsigned track, unsigned result, const ChatAv
|
||||
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ChatInterface - OnRemoveInvite");
|
||||
|
||||
if (result == CHATRESULT_SUCCESS && (srcAvatar == NULL || destRoom == NULL))
|
||||
if (result == CHATRESULT_SUCCESS && (srcAvatar == nullptr || destRoom == nullptr))
|
||||
{
|
||||
DEBUG_WARNING(true, ("We received an OnRemoveInvite with a success result code but NULL data. This is an error that the API should never give."));
|
||||
DEBUG_WARNING(true, ("We received an OnRemoveInvite with a success result code but nullptr data. This is an error that the API should never give."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2471,7 +2469,7 @@ void ChatInterface::OnRemoveInvite(unsigned track, unsigned result, const ChatAv
|
||||
sequence = pair->sequence;
|
||||
|
||||
delete pair;
|
||||
pair = NULL;
|
||||
pair = nullptr;
|
||||
}
|
||||
|
||||
std::string roomName;
|
||||
@@ -2555,9 +2553,9 @@ void ChatInterface::OnLeaveRoom(unsigned track, unsigned result, const ChatAvata
|
||||
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ChatInterface - OnLeaveRoom");
|
||||
|
||||
if (result == CHATRESULT_SUCCESS && (srcAvatar == NULL || destRoom == NULL))
|
||||
if (result == CHATRESULT_SUCCESS && (srcAvatar == nullptr || destRoom == nullptr))
|
||||
{
|
||||
DEBUG_WARNING(true, ("We received an OnLeaveRoom with a success result code but NULL data. This is an error that the API should never give."));
|
||||
DEBUG_WARNING(true, ("We received an OnLeaveRoom with a success result code but nullptr data. This is an error that the API should never give."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2645,15 +2643,13 @@ void ChatInterface::OnKickAvatar(unsigned track, unsigned result, const ChatAvat
|
||||
|
||||
AvatarIdSequencePair *pair = (AvatarIdSequencePair *)user;
|
||||
|
||||
unsigned sequence = 0;
|
||||
ChatAvatarId kickedId;
|
||||
if (pair)
|
||||
{
|
||||
kickedId = pair->avatar;
|
||||
sequence = pair->sequence;
|
||||
|
||||
delete pair;
|
||||
pair = NULL;
|
||||
pair = nullptr;
|
||||
}
|
||||
|
||||
std::string roomName;
|
||||
@@ -2755,9 +2751,9 @@ void ChatInterface::OnGetPersistentMessage(unsigned track, unsigned result, Chat
|
||||
ChatServer::fileLog(false, "ChatInterface", "OnGetPersistentMessage() track(%u) result(%u) destAvatar(%s)", track, result, ChatServer::getFullChatAvatarName(destAvatar).c_str());
|
||||
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ChatInterface - OnGetPersistentMessage");
|
||||
if (result == CHATRESULT_SUCCESS && (destAvatar == NULL))
|
||||
if (result == CHATRESULT_SUCCESS && (destAvatar == nullptr))
|
||||
{
|
||||
DEBUG_WARNING(true, ("We received an OnGetPersistentMessage with a success result code but NULL data. This is an error that the API should never give."));
|
||||
DEBUG_WARNING(true, ("We received an OnGetPersistentMessage with a success result code but nullptr data. This is an error that the API should never give."));
|
||||
return;
|
||||
}
|
||||
UNREF(user);
|
||||
@@ -2807,9 +2803,9 @@ void ChatInterface::OnGetPersistentHeaders(unsigned track, unsigned result, Chat
|
||||
ChatServer::fileLog(false, "ChatInterface", "OnGetPersistentHeaders() track(%u) result(%u) destAvatar(%s)", track, result, ChatServer::getFullChatAvatarName(destAvatar).c_str(), listLength);
|
||||
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ChatInterface - OnGetPersistentHeaders");
|
||||
if (result == CHATRESULT_SUCCESS && (destAvatar == NULL))
|
||||
if (result == CHATRESULT_SUCCESS && (destAvatar == nullptr))
|
||||
{
|
||||
DEBUG_WARNING(true, ("We received an OnGetPersistentHeaders with a success result code but NULL data. This is an error that the API should never give."));
|
||||
DEBUG_WARNING(true, ("We received an OnGetPersistentHeaders with a success result code but nullptr data. This is an error that the API should never give."));
|
||||
return;
|
||||
}
|
||||
UNREF(track);
|
||||
@@ -2876,9 +2872,9 @@ void ChatInterface::OnReceivePersistentMessage(const ChatAvatar *destAvatar, con
|
||||
ChatServer::fileLog(false, "ChatInterface", "OnReceivePersistentMessage() destAvatar(%s)", ChatServer::getFullChatAvatarName(destAvatar).c_str());
|
||||
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ChatInterface - OnReceivePersistentMessage");
|
||||
if (destAvatar == NULL)
|
||||
if (destAvatar == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("We received an OnREceivePersistentMessage with a success result code but NULL data. This is an error that the API should never give."));
|
||||
DEBUG_WARNING(true, ("We received an OnREceivePersistentMessage with a success result code but nullptr data. This is an error that the API should never give."));
|
||||
return;
|
||||
}
|
||||
if (!header)
|
||||
@@ -2910,9 +2906,9 @@ void ChatInterface::OnSendRoomMessage(unsigned track, unsigned result, const Cha
|
||||
ChatServer::fileLog(false, "ChatInterface", "OnSendRoomMessage() track(%u) result(%u) srcAvatar(%s) destRoom(%s)", track, result, ChatServer::getFullChatAvatarName(srcAvatar).c_str(), ChatServer::getChatRoomNameNarrow(destRoom).c_str());
|
||||
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ChatInterface - OnSendRoomMessage");
|
||||
if (result == CHATRESULT_SUCCESS && (srcAvatar == NULL || destRoom == NULL))
|
||||
if (result == CHATRESULT_SUCCESS && (srcAvatar == nullptr || destRoom == nullptr))
|
||||
{
|
||||
DEBUG_WARNING(true, ("We received an OnsendRoomMessage with a success result code but NULL data. This is an error that the API should never give."));
|
||||
DEBUG_WARNING(true, ("We received an OnsendRoomMessage with a success result code but nullptr data. This is an error that the API should never give."));
|
||||
return;
|
||||
}
|
||||
UNREF(srcAvatar);
|
||||
@@ -2931,7 +2927,7 @@ void ChatInterface::OnReceiveRoomMessage(const ChatAvatar *srcAvatar, const Chat
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ChatInterface - OnReceiveRoomMessage");
|
||||
if(! srcAvatar || ! destAvatar || ! destRoom)
|
||||
{
|
||||
DEBUG_WARNING(true, ("We received an OnREceiveRoomMessage with a success result code but NULL data. This is an error that the API should never give."));
|
||||
DEBUG_WARNING(true, ("We received an OnREceiveRoomMessage with a success result code but nullptr data. This is an error that the API should never give."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2995,9 +2991,9 @@ void ChatInterface::OnSendInstantMessage(unsigned track, unsigned result, const
|
||||
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ChatInterface - OnSendInstantMessage");
|
||||
|
||||
if (result == CHATRESULT_SUCCESS && (srcAvatar == NULL))
|
||||
if (result == CHATRESULT_SUCCESS && (srcAvatar == nullptr))
|
||||
{
|
||||
DEBUG_WARNING(true, ("We received an OnSendInstantMessage with a success result code but NULL data. This is an error that the API should never give."));
|
||||
DEBUG_WARNING(true, ("We received an OnSendInstantMessage with a success result code but nullptr data. This is an error that the API should never give."));
|
||||
return;
|
||||
}
|
||||
UNREF(srcAvatar);
|
||||
@@ -3015,9 +3011,9 @@ void ChatInterface::OnReceiveInstantMessage(const ChatAvatar *srcAvatar, const C
|
||||
ChatServer::fileLog(false, "ChatInterface", "OnReceiveInstantMessage() srcAvatar(%s) destAvatar(%s)", ChatServer::getFullChatAvatarName(srcAvatar).c_str(), ChatServer::getFullChatAvatarName(destAvatar).c_str());
|
||||
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ChatInterface - OnReceiveInstantMessage");
|
||||
if ((srcAvatar == NULL || destAvatar == NULL))
|
||||
if ((srcAvatar == nullptr || destAvatar == nullptr))
|
||||
{
|
||||
DEBUG_WARNING(true, ("We received an OnReceiveInstantMessage with a success result code but NULL data. This is an error that the API should never give."));
|
||||
DEBUG_WARNING(true, ("We received an OnReceiveInstantMessage with a success result code but nullptr data. This is an error that the API should never give."));
|
||||
return;
|
||||
}
|
||||
ChatAvatarId fromId;
|
||||
@@ -3052,9 +3048,9 @@ void ChatInterface::OnSendPersistentMessage(unsigned track, unsigned result, con
|
||||
ChatServer::fileLog(false, "ChatInterface", "OnSendPersistentMessage() track(%u) result(%u) srcAvatar(%s)", track, result, ChatServer::getFullChatAvatarName(srcAvatar).c_str());
|
||||
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ChatInterface - OnSendPersistentMessage");
|
||||
if (result == CHATRESULT_SUCCESS && (srcAvatar == NULL))
|
||||
if (result == CHATRESULT_SUCCESS && (srcAvatar == nullptr))
|
||||
{
|
||||
DEBUG_WARNING(true, ("We received an OnSendPersistentMessage with a success result code but NULL data. This is an error that the API should never give."));
|
||||
DEBUG_WARNING(true, ("We received an OnSendPersistentMessage with a success result code but nullptr data. This is an error that the API should never give."));
|
||||
return;
|
||||
}
|
||||
unsigned sequence = (unsigned)user;
|
||||
@@ -3120,7 +3116,7 @@ void ChatInterface::OnUpdatePersistentMessages(unsigned track, unsigned result,
|
||||
|
||||
ChatAvatarId targetChatAvatarId;
|
||||
|
||||
if (targetAvatar != NULL)
|
||||
if (targetAvatar != nullptr)
|
||||
{
|
||||
makeAvatarId(*targetAvatar, targetChatAvatarId);
|
||||
}
|
||||
@@ -3130,17 +3126,17 @@ void ChatInterface::OnUpdatePersistentMessages(unsigned track, unsigned result,
|
||||
ChatAvatarId sourceChatAvatarId;
|
||||
NetworkId const *tmpNetworkId = reinterpret_cast<NetworkId const *>(user);
|
||||
|
||||
if (tmpNetworkId != NULL)
|
||||
if (tmpNetworkId != nullptr)
|
||||
{
|
||||
ChatAvatar const *sourceAvatar = ChatServer::getAvatarByNetworkId(*tmpNetworkId);
|
||||
|
||||
if (sourceAvatar != NULL)
|
||||
if (sourceAvatar != nullptr)
|
||||
{
|
||||
makeAvatarId(*sourceAvatar, sourceChatAvatarId);
|
||||
}
|
||||
|
||||
delete tmpNetworkId;
|
||||
tmpNetworkId = NULL;
|
||||
tmpNetworkId = nullptr;
|
||||
}
|
||||
|
||||
ChatServer::fileLog(false, "ChatInterface", "OnUpdatePersistentMessage() track(%u) result(%u) sourceAvatar(%s) targetAvatar(%s)", track, result, sourceChatAvatarId.getFullName().c_str(), targetChatAvatarId.getFullName().c_str());
|
||||
|
||||
@@ -166,87 +166,6 @@ private:
|
||||
std::map<unsigned, std::pair<std::pair<ChatUnicodeString, ChatUnicodeString>, int> > trackingRequestGetAnyAvatarForDestroy;
|
||||
};
|
||||
|
||||
#if 0
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
class ChatInterface : public ChatAPI
|
||||
{
|
||||
public:
|
||||
ChatInterface (const std::string & strGameCode,
|
||||
const std::string & strGatewayServerIP,
|
||||
const unsigned short sGatewayServerPort,
|
||||
const std::string & strBackupGatewayServerIP,
|
||||
const unsigned short sBackupGatewayServerPort
|
||||
);
|
||||
|
||||
virtual ~ChatInterface (); //lint !e1510 base class 'ChatAPI' has no destructor // jrandall - this is beyond my control
|
||||
|
||||
|
||||
void checkRoomExpirations ();
|
||||
void ConnectPlayer (const unsigned int suid, const std::string & characterName, const NetworkId & networkId);
|
||||
void deferChatMessageFor (const NetworkId & id, const Archive::ByteStream & bs);
|
||||
void destroyRoomByName (const std::string & roomName);
|
||||
|
||||
const std::hash_map<std::string, ChatServerRoomOwner> & getRoomList () const;
|
||||
const ChatServerAvatarOwner *findAvatar(const ChatAvatarId & avatarId);
|
||||
|
||||
void leaveRoom (const ChatAvatarId & avatarId, const std::string & roomName);
|
||||
|
||||
//--- ChatAPI virtual overrides
|
||||
virtual void OnConnectAvatar (const std::string & track, const unsigned int resultCode, const ChatAvatar & avatar);
|
||||
virtual void OnAddFriend (const unsigned int sequence, const std::string & track, const unsigned int nResultCode, const ChatAvatar & requestingAvatar, const ChatAvatar & friendAvatar);
|
||||
virtual void OnRemoveFriend (const unsigned int sequence, const std::string & track, const unsigned int nResultCode, const ChatAvatar & requestingAvatar, const ChatAvatar & friendAvatar);
|
||||
virtual void OnAddIgnore (const unsigned int sequence, const std::string & track, const unsigned int nResultCode, const ChatAvatar & requestingAvatar, const ChatAvatar & ignoreAvatar);
|
||||
virtual void OnRemoveIgnore (const unsigned int sequence, const std::string & track, const unsigned int nResultCode, const ChatAvatar & requestingAvatar, const ChatAvatar & ignoreAvatar);
|
||||
virtual void OnAddRoomModerator (const unsigned int nSequenceID, const std::string & track, const unsigned int nResultCode, const ChatRoom & room, const unsigned int nRequestingAvatarUID, const ChatAvatar & moderator);
|
||||
virtual void OnCreateRoom (const unsigned int sequence, const std::string & track, const unsigned int nResultCode, const ChatRoom & room);
|
||||
virtual void OnDestroyRoom (const unsigned int nSequenceID, const std::string & track, const unsigned int nResultCode, const ChatRoom & room, const std::string & strCharacterName, const std::string & strGameServerName, const std::string & strGameCode);
|
||||
virtual void OnDisconnectAvatar (const std::string & track, const unsigned int nResultCode, const ChatAvatar & toAvatar);
|
||||
virtual void OnDisconnectAvatarNotify (const ChatAvatar & toAvatar);
|
||||
virtual void OnEnterRoom (const unsigned int nSequenceID, const std::string & track, const unsigned int nResultCode, const ChatRoom & room, const ChatAvatar & avatar);
|
||||
virtual void OnLeaveRoom (const unsigned int nSequenceID, const std::string & track, const unsigned int nResultCode, const ChatRoom & room, const ChatAvatar & avatar);
|
||||
virtual void OnReceiveInstantMessage (const ChatAvatar & toAvatar, const ChatAvatar & fromAvatar, const Unicode::String & ustrMessage, const Unicode::String & oob);
|
||||
virtual void OnReceivePersistentMessage (const unsigned int nSequenceID, const std::string & track, const unsigned int nResultCode, const ChatPersistentMessage & message);
|
||||
virtual void OnReceivePersistentMessageHeader (const ChatPersistentMessageHeader & header);
|
||||
virtual void OnReceivePersistentMessageHeaders (const unsigned int nSequenceID, const std::string & track, const unsigned int nResultCode, const ChatAvatar & toAvatar, const std::vector<ChatPersistentMessageHeader> & headers);
|
||||
virtual void OnReceiveRoomMessage (const unsigned int nSequenceID, const ChatRoom & room, const std::string & strFromCharacterName, const std::string & strFromGameServerName, const std::string & strFromGameCode, const Unicode::String & ustrMessage, const Unicode::String & outOfBand, unsigned messageID);
|
||||
virtual void OnConnect (const unsigned int resultCode);
|
||||
virtual void OnReceiveRooms (const std::string & track, const unsigned int nResultCode, const std::vector<ChatRoom*> & rooms);
|
||||
virtual void OnRemoveRoomModerator (const unsigned int nSequenceID, const std::string & track, const unsigned int nResultCode, const ChatRoom & room, const unsigned int nRequestingAvatarUID, const ChatAvatar & moderator);
|
||||
virtual void OnSendInstantMessage (const unsigned int nSequenceID, const std::string & track, const unsigned int nResultCode, const ChatAvatar & sendingAvatar);
|
||||
virtual void OnSendPersistentMessage (const unsigned int nSequenceID, const std::string & track, const unsigned int nResultCode, const ChatAvatar& sendingAvatar);
|
||||
virtual void OnSendRoomMessage (const unsigned int sequence, const std::string & track, const unsigned int resultCode);
|
||||
virtual void OnUpdateFriendStatus (const ChatAvatar & toAvatar, const ChatAvatar & fromAvatar, const bool bIsConnected);
|
||||
virtual void OnReceiveRoomInvitation (const std::string & strRoomName, const ChatAvatar & invitorAvatar, const ChatAvatar & inviteeAvatar);
|
||||
virtual void OnSendRoomInvitation (const unsigned int sequence, const std::string & track, const unsigned int resultCode, const ChatRoom & room, const bool isOnline, const ChatAvatar & invitor, const ChatAvatar & invitee);
|
||||
|
||||
const ChatServerRoomOwner * getRoomByName (const std::string & roomName) const;
|
||||
|
||||
void disconnectPlayer (const ChatAvatarId & avatarId);
|
||||
void queryRoom (const NetworkId & id, ConnectionServerConnection * connection, const unsigned int sequenceId, const std::string & roomName);
|
||||
void queryRoom (const NetworkId & id, ConnectionServerConnection * connection, const unsigned int sequenceId, const unsigned int roomId);
|
||||
void requestRoomList (const NetworkId & id, ConnectionServerConnection * connection);
|
||||
void sendMessageToAllAvatars (const GameNetworkMessage & message);
|
||||
bool sendMessageToPendingAvatar(const ChatAvatarId &id, const GameNetworkMessage &message);
|
||||
|
||||
private:
|
||||
void sendMessageToAvatar (const ChatAvatar & avatar, const GameNetworkMessage & message);
|
||||
void sendMessageToAvatar (const ChatAvatarId & avatar, const GameNetworkMessage & message);
|
||||
|
||||
private:
|
||||
ChatInterface & operator = (const ChatInterface & rhs);
|
||||
ChatInterface(const ChatInterface & source);
|
||||
std::hash_map<std::string, NetworkId> pendingAvatars;
|
||||
std::hash_map<NetworkId, std::vector<Archive::ByteStream>, NetworkId::Hash > deferredChatMessages;
|
||||
std::hash_map<std::string, ChatServerRoomOwner> roomList;
|
||||
std::map<ChatAvatarId, ChatServerAvatarOwner *> avatarMap;
|
||||
time_t lastRoomCheck;
|
||||
|
||||
}; //lint !e1712 default constructor not defined for class
|
||||
|
||||
#endif
|
||||
|
||||
std::string toLower(const std::string & source);
|
||||
std::string toUpper(const std::string & source);
|
||||
void makeRoomData(const ChatRoom & room, ChatRoomData & roomData);
|
||||
|
||||
@@ -162,7 +162,7 @@ void ChatServerNamespace::cleanChatLog()
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
ChatServer *ChatServer::m_instance = NULL;
|
||||
ChatServer *ChatServer::m_instance = nullptr;
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -250,7 +250,7 @@ if ((t3 - t2) > (1000 * 5))
|
||||
static Unicode::String wideFilter = Unicode::narrowToWide("");
|
||||
static ChatUnicodeString swgNode(wideSWG.data(), wideSWG.size());
|
||||
static ChatUnicodeString filter(wideFilter.data(), wideFilter.size());
|
||||
instance().chatInterface->RequestGetRoomSummaries(swgNode, filter, NULL);
|
||||
instance().chatInterface->RequestGetRoomSummaries(swgNode, filter, nullptr);
|
||||
}
|
||||
|
||||
++i;
|
||||
@@ -286,7 +286,7 @@ gameService(0),
|
||||
planetService(),
|
||||
ownerSystem(0),
|
||||
systemAvatarId("SWG", ConfigChatServer::getClusterName(), "SYSTEM"),
|
||||
customerServiceServerConnection(NULL),
|
||||
customerServiceServerConnection(nullptr),
|
||||
m_gameServerConnectionRegistry(),
|
||||
m_voiceChatIdMap()
|
||||
{
|
||||
@@ -452,7 +452,7 @@ void ChatServer::setOwnerSystem(const ChatAvatar * o)
|
||||
|
||||
Connection *connection = safe_cast<Connection *>(instance().centralServerConnection);
|
||||
|
||||
if (connection != NULL)
|
||||
if (connection != nullptr)
|
||||
{
|
||||
connection->send(bs, true);
|
||||
}
|
||||
@@ -618,7 +618,7 @@ const ChatAvatar * ChatServer::getAvatarByNetworkId(const NetworkId & id)
|
||||
{
|
||||
if (id.getValue() == 0)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
const ChatAvatar * result = 0;
|
||||
ChatAvatarList::const_iterator f = instance().chatAvatars.find(id);
|
||||
@@ -635,7 +635,7 @@ ChatServer::AvatarExtendedData * ChatServer::getAvatarExtendedDataByNetworkId(co
|
||||
{
|
||||
if (id.getValue() == 0)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
ChatServer::AvatarExtendedData * result = 0;
|
||||
ChatAvatarList::iterator f = instance().chatAvatars.find(id);
|
||||
@@ -783,7 +783,7 @@ void ChatServer::addFriend(const NetworkId & id, const unsigned int sequence, co
|
||||
|
||||
unsigned track = instance().chatInterface->RequestAddFriend(from, ChatUnicodeString(friendName.data(), friendName.length()),
|
||||
ChatUnicodeString(friendAddress.data(), friendAddress.length()),
|
||||
false, NULL);
|
||||
false, nullptr);
|
||||
instance().pendingRequests[track] = id;
|
||||
}
|
||||
else
|
||||
@@ -810,7 +810,7 @@ void ChatServer::removeFriend(const NetworkId & id, const unsigned int sequence,
|
||||
splitChatAvatarId(friendId, friendName, friendAddress);
|
||||
|
||||
unsigned track = instance().chatInterface->RequestRemoveFriend(from, ChatUnicodeString(friendName.data(), friendName.length()),
|
||||
ChatUnicodeString(friendAddress.data(), friendAddress.length()), NULL);
|
||||
ChatUnicodeString(friendAddress.data(), friendAddress.length()), nullptr);
|
||||
instance().pendingRequests[track] = id;
|
||||
}
|
||||
else
|
||||
@@ -829,7 +829,7 @@ void ChatServer::getFriendsList(const ChatAvatarId &characterName)
|
||||
const ChatAvatar *avatar = getAvatarByNetworkId(id);
|
||||
if (avatar)
|
||||
{
|
||||
unsigned track = instance().chatInterface->RequestFriendStatus(avatar, NULL);
|
||||
unsigned track = instance().chatInterface->RequestFriendStatus(avatar, nullptr);
|
||||
instance().pendingRequests[track] = id;
|
||||
}
|
||||
else
|
||||
@@ -857,7 +857,7 @@ void ChatServer::addIgnore(const NetworkId & id, const unsigned int sequence, co
|
||||
|
||||
unsigned track = instance().chatInterface->RequestAddIgnore(from, ChatUnicodeString(ignoreName.data(), ignoreName.length()),
|
||||
ChatUnicodeString(ignoreAddress.data(), ignoreAddress.length()),
|
||||
NULL);
|
||||
nullptr);
|
||||
instance().pendingRequests[track] = id;
|
||||
}
|
||||
else
|
||||
@@ -884,7 +884,7 @@ void ChatServer::removeIgnore(const NetworkId & id, const unsigned int sequence,
|
||||
splitChatAvatarId(ignoreId, ignoreName, ignoreAddress);
|
||||
|
||||
unsigned track = instance().chatInterface->RequestRemoveIgnore(from, ChatUnicodeString(ignoreName.data(), ignoreName.length()),
|
||||
ChatUnicodeString(ignoreAddress.data(), ignoreAddress.length()), NULL);
|
||||
ChatUnicodeString(ignoreAddress.data(), ignoreAddress.length()), nullptr);
|
||||
instance().pendingRequests[track] = id;
|
||||
}
|
||||
else
|
||||
@@ -905,7 +905,7 @@ void ChatServer::getIgnoreList(const ChatAvatarId &characterName)
|
||||
|
||||
if (avatar)
|
||||
{
|
||||
unsigned track = instance().chatInterface->RequestIgnoreStatus(avatar, NULL);
|
||||
unsigned track = instance().chatInterface->RequestIgnoreStatus(avatar, nullptr);
|
||||
instance().pendingRequests[track] = id;
|
||||
}
|
||||
else
|
||||
@@ -1160,7 +1160,7 @@ void ChatServer::createRoom(const NetworkId & id, const unsigned int sequence, c
|
||||
{
|
||||
roomAttr |= ROOMATTR_PRIVATE;
|
||||
}
|
||||
if (isSystemOwner && (strstr(roomName.c_str(), "system") != NULL))
|
||||
if (isSystemOwner && (strstr(roomName.c_str(), "system") != nullptr))
|
||||
{
|
||||
roomAttr |= ROOMATTR_PERSISTENT;
|
||||
}
|
||||
@@ -1193,7 +1193,7 @@ void ChatServer::deleteAllPersistentMessages(const NetworkId &sourceNetworkId, c
|
||||
|
||||
ChatAvatar const *avatar = getAvatarByNetworkId(targetNetworkId);
|
||||
|
||||
if (avatar != NULL)
|
||||
if (avatar != nullptr)
|
||||
{
|
||||
{
|
||||
NetworkId *tmpNetworkId = new NetworkId(sourceNetworkId);
|
||||
@@ -1225,7 +1225,7 @@ void ChatServer::deletePersistentMessage(const NetworkId &id, const unsigned int
|
||||
const ChatAvatar *avatar = getAvatarByNetworkId(id);
|
||||
if (avatar)
|
||||
{
|
||||
instance().chatInterface->RequestUpdatePersistentMessage(avatar, messageId, PERSISTENT_DELETED, NULL);
|
||||
instance().chatInterface->RequestUpdatePersistentMessage(avatar, messageId, PERSISTENT_DELETED, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1290,10 +1290,10 @@ void ChatServer::destroyRoom(const std::string & roomName)
|
||||
{
|
||||
ChatServer::fileLog(s_enableChatRoomLogs, "ChatServer", "destroyRoom() roomName(%s)", roomName.c_str());
|
||||
|
||||
if ((strstr(roomName.c_str(), ConfigChatServer::getClusterName()) != NULL) ||
|
||||
if ((strstr(roomName.c_str(), ConfigChatServer::getClusterName()) != nullptr) ||
|
||||
(strstr(roomName.c_str(), toLower(std::string(ConfigChatServer::getClusterName() ) ).c_str() ) ))
|
||||
{
|
||||
if ((strstr(roomName.c_str(), "GroupChat") != NULL) || (strstr(roomName.c_str(), "groupchat") != NULL))
|
||||
if ((strstr(roomName.c_str(), "GroupChat") != nullptr) || (strstr(roomName.c_str(), "groupchat") != nullptr))
|
||||
{
|
||||
size_t pos = roomName.rfind(".");
|
||||
if (pos != roomName.npos)
|
||||
@@ -1311,7 +1311,7 @@ void ChatServer::destroyRoom(const std::string & roomName)
|
||||
const ChatServerRoomOwner *owner = instance().chatInterface->getRoomOwner(roomName);
|
||||
if (!instance().ownerSystem)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Chat ownerSystem is NULL"));
|
||||
DEBUG_WARNING(true, ("Chat ownerSystem is nullptr"));
|
||||
return;
|
||||
}
|
||||
if (owner)
|
||||
@@ -1331,7 +1331,7 @@ void ChatServer::disconnectAvatar(const ChatAvatar & avatar)
|
||||
|
||||
if (&avatar == instance().ownerSystem)
|
||||
{
|
||||
instance().ownerSystem = NULL;
|
||||
instance().ownerSystem = nullptr;
|
||||
}
|
||||
ChatAvatarList::iterator i;
|
||||
for(i = instance().chatAvatars.begin(); i != instance().chatAvatars.end(); ++i)
|
||||
@@ -1423,7 +1423,7 @@ void ChatServer::enterRoom(const ChatAvatarId & id, const std::string & roomName
|
||||
const ChatAvatar *avatar = getAvatarByNetworkId(getNetworkIdByAvatarId(id));
|
||||
if (room && avatar)
|
||||
{
|
||||
instance().chatInterface->RequestEnterRoom(avatar, room->getAddress(), NULL);
|
||||
instance().chatInterface->RequestEnterRoom(avatar, room->getAddress(), nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1450,7 +1450,7 @@ void ChatServer::putSystemAvatarInRoom(const std::string & roomName)
|
||||
const ChatServerRoomOwner *room = instance().chatInterface->getRoomOwner(roomName);
|
||||
if (room && instance().ownerSystem)
|
||||
{
|
||||
instance().chatInterface->RequestEnterRoom(instance().ownerSystem, room->getAddress(), NULL);
|
||||
instance().chatInterface->RequestEnterRoom(instance().ownerSystem, room->getAddress(), nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1619,7 +1619,7 @@ void ChatServer::invite(const NetworkId & id, const ChatAvatarId & avatarId, con
|
||||
ChatServer::fileLog(s_enableChatRoomLogs, "ChatServer", "invite() id(%s) avatar(%s) roomName(%s)", id.getValueString().c_str(), avatarId.getFullName().c_str(), roomName.c_str());
|
||||
|
||||
// Try to get an invitor
|
||||
ChatAvatar const * invitor = NULL;
|
||||
ChatAvatar const * invitor = nullptr;
|
||||
if (id != NetworkId::cms_invalid)
|
||||
{
|
||||
invitor = getAvatarByNetworkId(id);
|
||||
@@ -1738,7 +1738,7 @@ void ChatServer::inviteGroupMembers(const NetworkId & id, const ChatAvatarId & a
|
||||
|
||||
void ChatServer::removeSystemAvatarFromRoom(const ChatRoom *room)
|
||||
{
|
||||
ChatServer::fileLog(s_enableChatRoomLogs, "ChatServer", "removeSystemAvatarFromRoom() room(%s)", (room != NULL) ? toNarrowString(room->getRoomName()).c_str() : "NULL");
|
||||
ChatServer::fileLog(s_enableChatRoomLogs, "ChatServer", "removeSystemAvatarFromRoom() room(%s)", (room != nullptr) ? toNarrowString(room->getRoomName()).c_str() : "nullptr");
|
||||
|
||||
if (!room || !instance().ownerSystem)
|
||||
{
|
||||
@@ -1754,7 +1754,7 @@ void ChatServer::removeSystemAvatarFromRoom(const ChatRoom *room)
|
||||
}
|
||||
}
|
||||
|
||||
instance().chatInterface->RequestLeaveRoom(instance().ownerSystem, room->getAddress(), NULL);
|
||||
instance().chatInterface->RequestLeaveRoom(instance().ownerSystem, room->getAddress(), nullptr);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@@ -1991,7 +1991,7 @@ void ChatServer::sendInstantMessage(const ChatAvatarId & from, const ChatAvatarI
|
||||
const NetworkId &toNetworkId = getNetworkIdByAvatarId(to);
|
||||
const ChatAvatar * toAvatar = getAvatarByNetworkId(toNetworkId);
|
||||
|
||||
if (toAvatar != NULL)
|
||||
if (toAvatar != nullptr)
|
||||
{
|
||||
ChatServer::fileLog(false, "ChatServer", "sendInstantMessage() resolved tell locally");
|
||||
|
||||
@@ -2022,7 +2022,7 @@ void ChatServer::sendInstantMessage(const ChatAvatarId & from, const ChatAvatarI
|
||||
IGNORE_RETURN(instance().chatInterface->RequestSendInstantMessage(fromAvatar,
|
||||
ChatUnicodeString(friendName.data(), friendName.size()),
|
||||
ChatUnicodeString(friendAddress.data(), friendAddress.size()),
|
||||
ChatUnicodeString(message.data(), message.size()), ChatUnicodeString(outOfBand.data(), outOfBand.size()), NULL));
|
||||
ChatUnicodeString(message.data(), message.size()), ChatUnicodeString(outOfBand.data(), outOfBand.size()), nullptr));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2054,7 +2054,7 @@ void ChatServer::sendInstantMessage(const NetworkId & fromId, const unsigned int
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (::time(NULL) < aed->unsquelchTime) // still in squelch period
|
||||
else if (::time(nullptr) < aed->unsquelchTime) // still in squelch period
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -2076,14 +2076,14 @@ void ChatServer::sendInstantMessage(const NetworkId & fromId, const unsigned int
|
||||
Unicode::String wideFrom;
|
||||
Unicode::String wideTo;
|
||||
|
||||
if (from != NULL)
|
||||
if (from != nullptr)
|
||||
{
|
||||
makeAvatarId(*from, fromAvatarId);
|
||||
wideFrom = (Unicode::narrowToWide(fromAvatarId.getFullName()));
|
||||
}
|
||||
|
||||
ChatAvatarId toAvatarId;
|
||||
if (toAvatar != NULL)
|
||||
if (toAvatar != nullptr)
|
||||
{
|
||||
ChatServer::fileLog(false, "ChatServer", "sendInstantMessage() resolved tell locally");
|
||||
|
||||
@@ -2158,7 +2158,7 @@ void ChatServer::sendPersistentMessage(const ChatAvatarId & from, const ChatAvat
|
||||
ChatUnicodeString(subject.data(), subject.size()),
|
||||
ChatUnicodeString(message.data(), message.size()),
|
||||
ChatUnicodeString(oob.data(), oob.size()),
|
||||
NULL
|
||||
nullptr
|
||||
);
|
||||
|
||||
Unicode::String log;
|
||||
@@ -2187,7 +2187,7 @@ void ChatServer::sendPersistentMessage(const NetworkId & fromId, const unsigned
|
||||
// to.cluster.c_str(), to.name.c_str());
|
||||
UNREF(sequenceId);
|
||||
ChatServer::AvatarExtendedData * aed = getAvatarExtendedDataByNetworkId(fromId);
|
||||
const ChatAvatar * from = (aed ? &(aed->chatAvatar) : NULL);
|
||||
const ChatAvatar * from = (aed ? &(aed->chatAvatar) : nullptr);
|
||||
if(from)
|
||||
{
|
||||
// see if player is squelched
|
||||
@@ -2197,7 +2197,7 @@ void ChatServer::sendPersistentMessage(const NetworkId & fromId, const unsigned
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (::time(NULL) < aed->unsquelchTime) // still in squelch period
|
||||
else if (::time(nullptr) < aed->unsquelchTime) // still in squelch period
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -2225,7 +2225,7 @@ void ChatServer::sendPersistentMessage(const NetworkId & fromId, const unsigned
|
||||
|
||||
ChatAvatarId fromAvatarId;
|
||||
|
||||
if (from != NULL)
|
||||
if (from != nullptr)
|
||||
{
|
||||
makeAvatarId(*from, fromAvatarId);
|
||||
}
|
||||
@@ -2255,7 +2255,7 @@ void ChatServer::sendRoomMessage(const ChatAvatarId &id, const std::string & roo
|
||||
|
||||
if (!instance().ownerSystem)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Chat ownerSystem is NULL"));
|
||||
DEBUG_WARNING(true, ("Chat ownerSystem is nullptr"));
|
||||
return;
|
||||
}
|
||||
// get room id
|
||||
@@ -2265,7 +2265,7 @@ void ChatServer::sendRoomMessage(const ChatAvatarId &id, const std::string & roo
|
||||
{
|
||||
const ChatAvatar *sender = instance().ownerSystem;
|
||||
|
||||
IGNORE_RETURN(instance().chatInterface->RequestSendRoomMessage(sender, (*f).second.getAddress(), ChatUnicodeString(msg.data(), msg.size()), ChatUnicodeString(oob.data(), oob.size()), NULL));
|
||||
IGNORE_RETURN(instance().chatInterface->RequestSendRoomMessage(sender, (*f).second.getAddress(), ChatUnicodeString(msg.data(), msg.size()), ChatUnicodeString(oob.data(), oob.size()), nullptr));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2280,7 +2280,7 @@ void ChatServer::sendRoomMessage(const NetworkId & id, const unsigned int sequen
|
||||
|
||||
UNREF(sequence);
|
||||
ChatServer::AvatarExtendedData * aed = getAvatarExtendedDataByNetworkId(id);
|
||||
const ChatAvatar * sender = (aed ? &(aed->chatAvatar) : NULL);
|
||||
const ChatAvatar * sender = (aed ? &(aed->chatAvatar) : nullptr);
|
||||
const ChatServerRoomOwner *room = instance().chatInterface->getRoomOwner(roomId);
|
||||
if(sender && room)
|
||||
{
|
||||
@@ -2296,7 +2296,7 @@ void ChatServer::sendRoomMessage(const NetworkId & id, const unsigned int sequen
|
||||
aed->nonSpatialCharCount += msg.size();
|
||||
|
||||
// sync chat character count with game server
|
||||
timeNow = ::time(NULL);
|
||||
timeNow = ::time(nullptr);
|
||||
if ((timeNow > aed->chatSpamNextTimeToSyncWithGameServer) || (timeNow > aed->chatSpamTimeEndInterval))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::pair<NetworkId, int>, std::pair<int, int> > > chatStatistics("ChatStatisticsCS", std::make_pair(std::make_pair(id, static_cast<int>(aed->chatSpamTimeEndInterval)), std::make_pair(aed->spatialCharCount, aed->nonSpatialCharCount)));
|
||||
@@ -2322,7 +2322,7 @@ void ChatServer::sendRoomMessage(const NetworkId & id, const unsigned int sequen
|
||||
allowToSpeak = false;
|
||||
squelched = true;
|
||||
}
|
||||
else if (::time(NULL) < aed->unsquelchTime) // still in squelch period
|
||||
else if (::time(nullptr) < aed->unsquelchTime) // still in squelch period
|
||||
{
|
||||
allowToSpeak = false;
|
||||
squelched = true;
|
||||
@@ -2393,7 +2393,7 @@ void ChatServer::sendStandardRoomMessage(const ChatAvatarId &senderId, const std
|
||||
}
|
||||
if (sender)
|
||||
{
|
||||
IGNORE_RETURN(instance().chatInterface->RequestSendRoomMessage(sender, (*f).second.getAddress(), ChatUnicodeString(msg.data(), msg.size()), ChatUnicodeString(oob.data(), oob.size()), NULL));
|
||||
IGNORE_RETURN(instance().chatInterface->RequestSendRoomMessage(sender, (*f).second.getAddress(), ChatUnicodeString(msg.data(), msg.size()), ChatUnicodeString(oob.data(), oob.size()), nullptr));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2505,7 +2505,7 @@ std::string ChatServer::getFullChatAvatarName(ChatAvatar const *chatAvatar)
|
||||
{
|
||||
std::string result;
|
||||
|
||||
if (chatAvatar != NULL)
|
||||
if (chatAvatar != nullptr)
|
||||
{
|
||||
result += toNarrowString(chatAvatar->getName());
|
||||
result += '.';
|
||||
@@ -2513,7 +2513,7 @@ std::string ChatServer::getFullChatAvatarName(ChatAvatar const *chatAvatar)
|
||||
}
|
||||
else
|
||||
{
|
||||
result = "NULL";
|
||||
result = "nullptr";
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -2539,7 +2539,7 @@ std::string ChatServer::getConnectionAddress(Connection const *connection)
|
||||
{
|
||||
std::string result;
|
||||
|
||||
if (connection != NULL)
|
||||
if (connection != nullptr)
|
||||
{
|
||||
char text[256];
|
||||
snprintf(text, sizeof(text), "%s:%d", connection->getRemoteAddress().c_str(), connection->getRemotePort());
|
||||
@@ -2547,7 +2547,7 @@ std::string ChatServer::getConnectionAddress(Connection const *connection)
|
||||
}
|
||||
else
|
||||
{
|
||||
result = "NULL";
|
||||
result = "nullptr";
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -2566,13 +2566,13 @@ Unicode::String ChatServer::getChatRoomName(ChatRoom const *chatRoom)
|
||||
{
|
||||
Unicode::String result;
|
||||
|
||||
if (chatRoom != NULL)
|
||||
if (chatRoom != nullptr)
|
||||
{
|
||||
result = toUnicodeString(chatRoom->getRoomName());
|
||||
}
|
||||
else
|
||||
{
|
||||
result = Unicode::narrowToWide("NULL");
|
||||
result = Unicode::narrowToWide("nullptr");
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -2582,12 +2582,12 @@ Unicode::String ChatServer::getChatRoomName(ChatRoom const *chatRoom)
|
||||
|
||||
void ChatServer::clearCustomerServiceServerConnection()
|
||||
{
|
||||
if (instance().customerServiceServerConnection != NULL)
|
||||
if (instance().customerServiceServerConnection != nullptr)
|
||||
{
|
||||
instance().customerServiceServerConnection->disconnect();
|
||||
}
|
||||
|
||||
instance().customerServiceServerConnection = NULL;
|
||||
instance().customerServiceServerConnection = nullptr;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -2596,7 +2596,7 @@ void ChatServer::connectToCustomerServiceServer(const std::string &address, cons
|
||||
{
|
||||
//DEBUG_REPORT_LOG(true, ("***ChatServer::connectToCustomerServiceServer() address(%s) port(%d)\n", address.c_str(), port));
|
||||
|
||||
if (instance().customerServiceServerConnection != NULL)
|
||||
if (instance().customerServiceServerConnection != nullptr)
|
||||
{
|
||||
instance().customerServiceServerConnection->disconnect();
|
||||
}
|
||||
@@ -2670,7 +2670,7 @@ bool ChatServer::isValidChatAvatarName(Unicode::String const &chatAvatarName)
|
||||
|
||||
void ChatServer::logChatMessage(Unicode::String const &logPlayer, Unicode::String const &fromPlayer, Unicode::String const &toPlayer, Unicode::String const &text, Unicode::String const &channel)
|
||||
{
|
||||
DEBUG_WARNING(toPlayer.empty(), ("toPlayer is NULL"));
|
||||
DEBUG_WARNING(toPlayer.empty(), ("toPlayer is nullptr"));
|
||||
|
||||
Unicode::String lowerLogPlayer(Unicode::toLower(logPlayer));
|
||||
Unicode::String lowerFromPlayer(Unicode::toLower(fromPlayer));
|
||||
@@ -2760,7 +2760,7 @@ void ChatServer::requestTransferAvatar(const TransferCharacterData & request)
|
||||
|
||||
ChatAvatarId destinationAvatar("SWG", destination, request.getDestinationCharacterName());
|
||||
|
||||
instance().chatInterface->RequestTransferAvatar(request.getSourceStationId(), makeChatUnicodeString(sourceAvatar.getName()), makeChatUnicodeString(sourceAvatar.getAPIAddress()), request.getDestinationStationId(), makeChatUnicodeString(destinationAvatar.getName()), makeChatUnicodeString(destinationAvatar.getAPIAddress()), true, NULL);
|
||||
instance().chatInterface->RequestTransferAvatar(request.getSourceStationId(), makeChatUnicodeString(sourceAvatar.getName()), makeChatUnicodeString(sourceAvatar.getAPIAddress()), request.getDestinationStationId(), makeChatUnicodeString(destinationAvatar.getName()), makeChatUnicodeString(destinationAvatar.getAPIAddress()), true, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2845,7 +2845,7 @@ void ChatServer::handleChatStatisticsFromGameServer(NetworkId const & character,
|
||||
// non-spatial chat to report to the game server
|
||||
else if (aed->nonSpatialCharCount != nonSpatialNumCharacters)
|
||||
{
|
||||
time_t const timeNow = ::time(NULL);
|
||||
time_t const timeNow = ::time(nullptr);
|
||||
if (timeNow > aed->chatSpamNextTimeToSyncWithGameServer)
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::pair<NetworkId, int>, std::pair<int, int> > > chatStatistics("ChatStatisticsCS", std::make_pair(std::make_pair(character, static_cast<int>(aed->chatSpamTimeEndInterval)), std::make_pair(aed->spatialCharCount, aed->nonSpatialCharCount)));
|
||||
@@ -2904,7 +2904,7 @@ void ChatServer::sendToGameServerById(unsigned const connectionId, GameNetworkMe
|
||||
|
||||
GameServerConnection *ChatServer::getGameServerConnectionFromId(unsigned int sequence)
|
||||
{
|
||||
GameServerConnection * result = NULL;
|
||||
GameServerConnection * result = nullptr;
|
||||
std::unordered_map<unsigned int, GameServerConnection *>::iterator f = m_gameServerConnectionRegistry.find(sequence);
|
||||
if(f != m_gameServerConnectionRegistry.end())
|
||||
{
|
||||
|
||||
@@ -86,7 +86,7 @@ const ChatRoom * ChatServerRoomOwner::getRoom() const
|
||||
if (chatInterface)
|
||||
return chatInterface->getRoom(roomID);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
@@ -44,9 +44,10 @@
|
||||
#include "sharedNetworkMessages/ChatUninviteFromRoom.h"
|
||||
#include "sharedNetworkMessages/VerifyPlayerNameMessage.h"
|
||||
#include "sharedNetworkMessages/VerifyPlayerNameResponseMessage.h"
|
||||
#include "sharedNetworkMessages/VoiceChatMiscMessages.h"
|
||||
#include "UnicodeUtils.h"
|
||||
|
||||
#include "sharedFoundation/CrcConstexpr.hpp"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
ConnectionServerConnection::ConnectionServerConnection(const std::string & a, const unsigned short p) :
|
||||
@@ -100,49 +101,54 @@ void ConnectionServerConnection::onReceive(const Archive::ByteStream & message)
|
||||
++count;
|
||||
|
||||
ri = message.begin();
|
||||
|
||||
const uint32 messageType = m.getType();
|
||||
|
||||
//LOG("ConnectionServerConnection", ("onReceive() message(%s)", m.getCmdName().c_str()));
|
||||
|
||||
if(m.isType("ChatConnectAvatar"))
|
||||
{
|
||||
//printf("ConnectionServerConnection -- ChatConnectAvatar\n");
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatConnectAvatar");
|
||||
ChatConnectAvatar c(ri);
|
||||
// break surname from last name
|
||||
std::string name = c.getCharacterName();
|
||||
size_t pos = name.find_first_of(" ");
|
||||
if(pos != std::string::npos)
|
||||
name = name.substr(0, pos);
|
||||
ChatServer::connectPlayer(this, c.getStationId(), name, c.getCharacterId(), c.getIsSecure(), c.getIsSubscribed());
|
||||
}
|
||||
else if(m.isType("ChatDisconnectAvatar"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatDisconnectAvatar");
|
||||
//printf("ConnectionServerConnection -- ChatDisconnectAvatar\n");
|
||||
static MessageDispatch::Transceiver<const ChatDisconnectAvatar &> disconn;
|
||||
ChatDisconnectAvatar d(ri);
|
||||
disconn.emitMessage(d);
|
||||
ChatServer::disconnectPlayer(d.getCharacterId());
|
||||
}
|
||||
else if(m.isType("GameClientMessage"))
|
||||
{
|
||||
// chat message forwarded by the connection server
|
||||
GameClientMessage c(ri);
|
||||
//deliverMessageToClientObject(c.getNetworkId(), c.getByteStream());
|
||||
Archive::ReadIterator cri = c.getByteStream().begin();
|
||||
GameNetworkMessage cm(cri);
|
||||
std::vector<NetworkId>::const_iterator i;
|
||||
for(i = c.getDistributionList().begin(); i != c.getDistributionList().end(); ++i)
|
||||
switch(messageType) {
|
||||
case constcrc("ChatConnectAvatar") :
|
||||
{
|
||||
const ChatAvatar * avatar = ChatServer::getAvatarByNetworkId(*i);
|
||||
if (!avatar && cm.isType("ChatInstantMessageToCharacter"))
|
||||
//printf("ConnectionServerConnection -- ChatConnectAvatar\n");
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatConnectAvatar");
|
||||
ChatConnectAvatar c(ri);
|
||||
// break surname from last name
|
||||
std::string name = c.getCharacterName();
|
||||
size_t pos = name.find_first_of(" ");
|
||||
if(pos != std::string::npos)
|
||||
name = name.substr(0, pos);
|
||||
ChatServer::connectPlayer(this, c.getStationId(), name, c.getCharacterId(), c.getIsSecure(), c.getIsSubscribed());
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatDisconnectAvatar") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatDisconnectAvatar");
|
||||
//printf("ConnectionServerConnection -- ChatDisconnectAvatar\n");
|
||||
static MessageDispatch::Transceiver<const ChatDisconnectAvatar &> disconn;
|
||||
ChatDisconnectAvatar d(ri);
|
||||
disconn.emitMessage(d);
|
||||
ChatServer::disconnectPlayer(d.getCharacterId());
|
||||
break;
|
||||
}
|
||||
case constcrc("GameClientMessage") :
|
||||
{
|
||||
// chat message forwarded by the connection server
|
||||
GameClientMessage c(ri);
|
||||
//deliverMessageToClientObject(c.getNetworkId(), c.getByteStream());
|
||||
Archive::ReadIterator cri = c.getByteStream().begin();
|
||||
GameNetworkMessage cm(cri);
|
||||
std::vector<NetworkId>::const_iterator i;
|
||||
for(i = c.getDistributionList().begin(); i != c.getDistributionList().end(); ++i)
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatInstantMessageToCharacter");
|
||||
//printf("!Sending via the shortcut\n");
|
||||
cri = c.getByteStream().begin();
|
||||
|
||||
if(cm.isType("ChatInstantMessageToCharacter"))
|
||||
const ChatAvatar * avatar = ChatServer::getAvatarByNetworkId(*i);
|
||||
const uint32 cmtype = cm.getType();
|
||||
|
||||
if (!avatar && cmtype == constcrc("ChatInstantMessageToCharacter"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatInstantMessageToCharacter");
|
||||
//printf("!Sending via the shortcut\n");
|
||||
cri = c.getByteStream().begin();
|
||||
|
||||
// deliver IM to character
|
||||
ChatInstantMessageToCharacter chat(cri);
|
||||
ChatAvatarId characterName = chat.getCharacterName();
|
||||
@@ -167,279 +173,246 @@ void ConnectionServerConnection::onReceive(const Archive::ByteStream & message)
|
||||
ChatServer::getChatInterface()->sendMessageToPendingAvatar(fromName, response);
|
||||
return;
|
||||
}
|
||||
|
||||
if(avatar)
|
||||
{
|
||||
cri = c.getByteStream().begin();
|
||||
|
||||
switch(cmtype) {
|
||||
case constcrc("ChatDeleteAllPersistentMessages") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatDeleteAllPersistentMessages");
|
||||
ChatDeleteAllPersistentMessages chatDeleteAllPersistentMessages(cri);
|
||||
ChatServer::deleteAllPersistentMessages(chatDeleteAllPersistentMessages.getSourceNetworkId(), chatDeleteAllPersistentMessages.getTargetNetworkId());
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatInstantMessageToCharacter") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatInstantMessageToCharacter");
|
||||
//printf("ConnectionServerConnection -- ChatInstantMessageToCharacter\n");
|
||||
// deliver IM to character
|
||||
ChatInstantMessageToCharacter chat(cri);
|
||||
ChatAvatarId characterName = chat.getCharacterName();
|
||||
if(characterName.gameCode.empty())
|
||||
characterName.gameCode = "SWG";
|
||||
if(characterName.cluster.empty())
|
||||
characterName.cluster = ConfigChatServer::getClusterName();
|
||||
|
||||
ChatServer::sendInstantMessage(*i, chat.getSequence(), characterName, chat.getMessage(), chat.getOutOfBand());
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatQueryRoom") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatQueryRoom");
|
||||
//printf("ConnectionServerConnection -- ChatQueryRoom\n");
|
||||
ChatQueryRoom chat(cri);
|
||||
ChatServer::queryRoom((*i), this, chat.getSequence(), chat.getRoomName());
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatPersistentMessageToServer") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatPeristentMessageToServer");
|
||||
//printf("ConnectionServerConnection -- ChatPersistentMessageToServer\n");
|
||||
ChatPersistentMessageToServer chat(cri);
|
||||
ChatAvatarId characterName = chat.getToCharacterName();
|
||||
if(characterName.gameCode.empty())
|
||||
characterName.gameCode = "SWG";
|
||||
if(characterName.cluster.empty())
|
||||
characterName.cluster = ConfigChatServer::getClusterName();
|
||||
|
||||
ChatServer::sendPersistentMessage((*i), chat.getSequence(), characterName, chat.getSubject(), chat.getMessage(), chat.getOutOfBand());
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatRequestPersistentMessage") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatRequestPersistentMessage");
|
||||
//printf("ConnectionServerConnection -- ChatRequestPersistentMessage\n");
|
||||
ChatRequestPersistentMessage chat(cri);
|
||||
ChatServer::requestPersistentMessage((*i), chat.getSequence(), chat.getMessageId());
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatDeletePersistentMessage") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatDeletePersistentMessage");
|
||||
//printf("ConnectionServerConnection -- ChatDeletePersistentMessage\n");
|
||||
ChatDeletePersistentMessage chat(cri);
|
||||
ChatServer::deletePersistentMessage((*i), chat.getMessageId());
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatCreateRoom") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatCreateRoom");
|
||||
//printf("ConnectionServerConnection -- ChatCreateRoom\n");
|
||||
ChatCreateRoom chat(cri);
|
||||
ChatServer::createRoom((*i), chat.getSequence(), chat.getRoomName(), chat.getIsModerated(), chat.getIsPublic(), chat.getRoomTitle());
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatEnterRoom") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatEnterRoom");
|
||||
//printf("ConnectionServerConnection -- ChatEnterRoom\n");
|
||||
// entering a room by name
|
||||
ChatEnterRoom chat(cri);
|
||||
ChatServer::enterRoom((*i), chat.getSequence(), chat.getRoomName());
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatEnterRoomById") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatEnterRoomById");
|
||||
//printf("ConnectionServerConnection -- ChatEnterRoomById\n");
|
||||
// entering a room by room id
|
||||
ChatEnterRoomById chat(cri);
|
||||
ChatServer::enterRoom((*i), chat.getSequence(), chat.getRoomId());
|
||||
break;
|
||||
|
||||
}
|
||||
case constcrc("ChatSendToRoom") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatSendToRoom");
|
||||
//printf("ConnectionServerConnection -- ChatSendToRoom\n");
|
||||
ChatSendToRoom chat(cri);
|
||||
ChatServer::sendRoomMessage((*i), chat.getSequence(), chat.getRoomId(), chat.getMessage(), chat.getOutOfBand());
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatRequestRoomList") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatRequestRoomList");
|
||||
//printf("ConnectionServerConnection -- ChatRequestRoomList\n");
|
||||
ChatServer::requestRoomList((*i), this);
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatDestroyRoom") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatDestroyRoom");
|
||||
//printf("ConnectionServerConnection -- ChatDestroyRoom\n");
|
||||
ChatDestroyRoom chat(cri);
|
||||
ChatServer::destroyRoom((*i), chat.getSequence(), chat.getRoomId());
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatAddModeratorToRoom") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatAddModeratorToRoom");
|
||||
//printf("ConnectionServerConnection -- ChatAddModeratorToRoom\n");
|
||||
ChatAddModeratorToRoom chat(cri);
|
||||
ChatServer::addModeratorToRoom(chat.getSequenceId(), (*i), chat.getAvatarId(), chat.getRoomName());
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatRemoveModeratorFromRoom") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatRemoveModeratorFromRoom");
|
||||
//printf("ConnectionServerConnection -- ChatREmoveModeratorFromRoom\n");
|
||||
ChatRemoveModeratorFromRoom chat(cri);
|
||||
ChatAvatarId characterName = chat.getAvatarId();
|
||||
if(characterName.gameCode.empty())
|
||||
characterName.gameCode = "SWG";
|
||||
if(characterName.cluster.empty())
|
||||
characterName.cluster = ConfigChatServer::getClusterName();
|
||||
ChatServer::removeModeratorFromRoom(chat.getSequenceId(), (*i), characterName, chat.getRoomName());
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatRemoveAvatarFromRoom") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatRemoveAvatarFromRoom");
|
||||
//printf("ConnectionServerConnection -- ChatREmoveAvatarFromRoom\n");
|
||||
ChatRemoveAvatarFromRoom chat(cri);
|
||||
ChatServer::removeAvatarFromRoom((*i), chat.getAvatarId(), chat.getRoomName());
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatKickAvatarFromRoom") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatKickAvatarFromRoom");
|
||||
//printf("ConnectionServerConnection -- ChatKickAvatarFromRoom\n");
|
||||
ChatKickAvatarFromRoom chat(cri);
|
||||
ChatServer::kickAvatarFromRoom((*i), chat.getAvatarId(), chat.getRoomName());
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatAddFriend") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatAddFriend");
|
||||
//printf("ConnectionServerConnection -- ChatAddFriend\n");
|
||||
ChatAddFriend chat(ri);
|
||||
ChatServer::addFriend((*i), chat.getSequence(), chat.getCharacterName());
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatInviteAvatarToRoom") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatInviteAvatarToRoom");
|
||||
//printf("ConnectionServerConnection -- ChatInviteAvatarToRoom\n");
|
||||
ChatInviteAvatarToRoom chat(cri);
|
||||
ChatAvatarId characterName = chat.getAvatarId();
|
||||
if(characterName.gameCode.empty())
|
||||
characterName.gameCode = "SWG";
|
||||
if(characterName.cluster.empty())
|
||||
characterName.cluster = ConfigChatServer::getClusterName();
|
||||
ChatServer::invite((*i), characterName, chat.getRoomName());
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatUninviteFromRoom") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatUninviteFromRoom");
|
||||
//printf("ConnectionServerConnection -- ChatUninviteAvatarToRoom\n");
|
||||
ChatUninviteFromRoom chat(cri);
|
||||
ChatAvatarId characterName = chat.getAvatar();
|
||||
if(characterName.gameCode.empty())
|
||||
characterName.gameCode = "SWG";
|
||||
if(characterName.cluster.empty())
|
||||
characterName.cluster = ConfigChatServer::getClusterName();
|
||||
ChatServer::uninvite((*i), chat.getSequence(), characterName, chat.getRoomName());
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatBanAvatarFromRoom") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatBanAvatarFromRoom");
|
||||
//printf("ConnectionServerConnection -- ChatBanAvatarFromRoom\n");
|
||||
ChatBanAvatarFromRoom chat(cri);
|
||||
ChatAvatarId characterName = chat.getAvatarId();
|
||||
if(characterName.gameCode.empty())
|
||||
characterName.gameCode = "SWG";
|
||||
if(characterName.cluster.empty())
|
||||
characterName.cluster = ConfigChatServer::getClusterName();
|
||||
ChatServer::banFromRoom(chat.getSequence(), (*i), characterName, chat.getRoomName());
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatUnbanAvatarFromRoom") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatUnbanAvatarFromRoom");
|
||||
//printf("ConnectionServerConnection -- ChatUnbanAvatarFromRoom\n");
|
||||
ChatUnbanAvatarFromRoom chat(cri);
|
||||
ChatAvatarId characterName = chat.getAvatarId();
|
||||
if(characterName.gameCode.empty())
|
||||
characterName.gameCode = "SWG";
|
||||
if(characterName.cluster.empty())
|
||||
characterName.cluster = ConfigChatServer::getClusterName();
|
||||
ChatServer::unbanFromRoom(chat.getSequence(), (*i), characterName, chat.getRoomName());
|
||||
break;
|
||||
}
|
||||
case constcrc("VerifyPlayerNameMessage") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - VerifyPlayerNameMessage");
|
||||
VerifyPlayerNameMessage message(cri);
|
||||
|
||||
bool const valid = ChatServer::isValidChatAvatarName(message.getPlayerName());
|
||||
|
||||
VerifyPlayerNameResponseMessage response(valid, message.getPlayerName());
|
||||
|
||||
ChatServer::fileLog(true, "ConnectionServerConnection", "onReceive() message(VerifyPlayerNameMessage) name(%s) valid(%s)", Unicode::wideToNarrow(message.getPlayerName()).c_str(), (valid ? "yes" : "no"));
|
||||
|
||||
sendToClient(message.getSourceNetworkId(), response);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @todo : how is a message sent to anyone with a station account?
|
||||
|
||||
else
|
||||
{
|
||||
// defer until avatar is connected to chat backend
|
||||
ChatServer::deferChatMessageFor((*i), message);
|
||||
}
|
||||
|
||||
}
|
||||
if(avatar)
|
||||
{
|
||||
cri = c.getByteStream().begin();
|
||||
|
||||
if(cm.isType("ChatDeleteAllPersistentMessages"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatDeleteAllPersistentMessages");
|
||||
ChatDeleteAllPersistentMessages chatDeleteAllPersistentMessages(cri);
|
||||
ChatServer::deleteAllPersistentMessages(chatDeleteAllPersistentMessages.getSourceNetworkId(), chatDeleteAllPersistentMessages.getTargetNetworkId());
|
||||
}
|
||||
else if(cm.isType("ChatInstantMessageToCharacter"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatInstantMessageToCharacter");
|
||||
//printf("ConnectionServerConnection -- ChatInstantMessageToCharacter\n");
|
||||
// deliver IM to character
|
||||
ChatInstantMessageToCharacter chat(cri);
|
||||
ChatAvatarId characterName = chat.getCharacterName();
|
||||
if(characterName.gameCode.empty())
|
||||
characterName.gameCode = "SWG";
|
||||
if(characterName.cluster.empty())
|
||||
characterName.cluster = ConfigChatServer::getClusterName();
|
||||
|
||||
ChatServer::sendInstantMessage(*i, chat.getSequence(), characterName, chat.getMessage(), chat.getOutOfBand());
|
||||
}
|
||||
else if(cm.isType("ChatQueryRoom"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatQueryRoom");
|
||||
//printf("ConnectionServerConnection -- ChatQueryRoom\n");
|
||||
ChatQueryRoom chat(cri);
|
||||
ChatServer::queryRoom((*i), this, chat.getSequence(), chat.getRoomName());
|
||||
}
|
||||
else if(cm.isType("ChatPersistentMessageToServer"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatPeristentMessageToServer");
|
||||
//printf("ConnectionServerConnection -- ChatPersistentMessageToServer\n");
|
||||
ChatPersistentMessageToServer chat(cri);
|
||||
ChatAvatarId characterName = chat.getToCharacterName();
|
||||
if(characterName.gameCode.empty())
|
||||
characterName.gameCode = "SWG";
|
||||
if(characterName.cluster.empty())
|
||||
characterName.cluster = ConfigChatServer::getClusterName();
|
||||
|
||||
ChatServer::sendPersistentMessage((*i), chat.getSequence(), characterName, chat.getSubject(), chat.getMessage(), chat.getOutOfBand());
|
||||
}
|
||||
else if(cm.isType("ChatRequestPersistentMessage"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatRequestPersistentMessage");
|
||||
//printf("ConnectionServerConnection -- ChatRequestPersistentMessage\n");
|
||||
ChatRequestPersistentMessage chat(cri);
|
||||
ChatServer::requestPersistentMessage((*i), chat.getSequence(), chat.getMessageId());
|
||||
}
|
||||
else if(cm.isType("ChatDeletePersistentMessage"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatDeletePersistentMessage");
|
||||
//printf("ConnectionServerConnection -- ChatDeletePersistentMessage\n");
|
||||
ChatDeletePersistentMessage chat(cri);
|
||||
ChatServer::deletePersistentMessage((*i), chat.getMessageId());
|
||||
}
|
||||
else if(cm.isType("ChatCreateRoom"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatCreateRoom");
|
||||
//printf("ConnectionServerConnection -- ChatCreateRoom\n");
|
||||
ChatCreateRoom chat(cri);
|
||||
ChatServer::createRoom((*i), chat.getSequence(), chat.getRoomName(), chat.getIsModerated(), chat.getIsPublic(), chat.getRoomTitle());
|
||||
}
|
||||
else if(cm.isType("ChatEnterRoom"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatEnterRoom");
|
||||
//printf("ConnectionServerConnection -- ChatEnterRoom\n");
|
||||
// entering a room by name
|
||||
ChatEnterRoom chat(cri);
|
||||
ChatServer::enterRoom((*i), chat.getSequence(), chat.getRoomName());
|
||||
}
|
||||
else if(cm.isType("ChatEnterRoomById"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatEnterRoomById");
|
||||
//printf("ConnectionServerConnection -- ChatEnterRoomById\n");
|
||||
// entering a room by room id
|
||||
ChatEnterRoomById chat(cri);
|
||||
ChatServer::enterRoom((*i), chat.getSequence(), chat.getRoomId());
|
||||
|
||||
}
|
||||
else if(cm.isType("ChatSendToRoom"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatSendToRoom");
|
||||
//printf("ConnectionServerConnection -- ChatSendToRoom\n");
|
||||
ChatSendToRoom chat(cri);
|
||||
ChatServer::sendRoomMessage((*i), chat.getSequence(), chat.getRoomId(), chat.getMessage(), chat.getOutOfBand());
|
||||
}
|
||||
else if(cm.isType("ChatRequestRoomList"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatRequestRoomList");
|
||||
//printf("ConnectionServerConnection -- ChatRequestRoomList\n");
|
||||
ChatServer::requestRoomList((*i), this);
|
||||
}
|
||||
else if(cm.isType("ChatDestroyRoom"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatDestroyRoom");
|
||||
//printf("ConnectionServerConnection -- ChatDestroyRoom\n");
|
||||
ChatDestroyRoom chat(cri);
|
||||
ChatServer::destroyRoom((*i), chat.getSequence(), chat.getRoomId());
|
||||
}
|
||||
else if(cm.isType("ChatAddModeratorToRoom"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatAddModeratorToRoom");
|
||||
//printf("ConnectionServerConnection -- ChatAddModeratorToRoom\n");
|
||||
ChatAddModeratorToRoom chat(cri);
|
||||
ChatServer::addModeratorToRoom(chat.getSequenceId(), (*i), chat.getAvatarId(), chat.getRoomName());
|
||||
}
|
||||
else if(cm.isType("ChatRemoveModeratorFromRoom"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatRemoveModeratorFromRoom");
|
||||
//printf("ConnectionServerConnection -- ChatREmoveModeratorFromRoom\n");
|
||||
ChatRemoveModeratorFromRoom chat(cri);
|
||||
ChatAvatarId characterName = chat.getAvatarId();
|
||||
if(characterName.gameCode.empty())
|
||||
characterName.gameCode = "SWG";
|
||||
if(characterName.cluster.empty())
|
||||
characterName.cluster = ConfigChatServer::getClusterName();
|
||||
ChatServer::removeModeratorFromRoom(chat.getSequenceId(), (*i), characterName, chat.getRoomName());
|
||||
}
|
||||
else if(cm.isType("ChatRemoveAvatarFromRoom"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatRemoveAvatarFromRoom");
|
||||
//printf("ConnectionServerConnection -- ChatREmoveAvatarFromRoom\n");
|
||||
ChatRemoveAvatarFromRoom chat(cri);
|
||||
ChatServer::removeAvatarFromRoom((*i), chat.getAvatarId(), chat.getRoomName());
|
||||
}
|
||||
else if(cm.isType("ChatKickAvatarFromRoom"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatKickAvatarFromRoom");
|
||||
//printf("ConnectionServerConnection -- ChatKickAvatarFromRoom\n");
|
||||
ChatKickAvatarFromRoom chat(cri);
|
||||
ChatServer::kickAvatarFromRoom((*i), chat.getAvatarId(), chat.getRoomName());
|
||||
}
|
||||
else if(cm.isType("ChatAddFriend"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatAddFriend");
|
||||
//printf("ConnectionServerConnection -- ChatAddFriend\n");
|
||||
ChatAddFriend chat(ri);
|
||||
ChatServer::addFriend((*i), chat.getSequence(), chat.getCharacterName());
|
||||
}
|
||||
else if(cm.isType("ChatInviteAvatarToRoom"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatInviteAvatarToRoom");
|
||||
//printf("ConnectionServerConnection -- ChatInviteAvatarToRoom\n");
|
||||
ChatInviteAvatarToRoom chat(cri);
|
||||
ChatAvatarId characterName = chat.getAvatarId();
|
||||
if(characterName.gameCode.empty())
|
||||
characterName.gameCode = "SWG";
|
||||
if(characterName.cluster.empty())
|
||||
characterName.cluster = ConfigChatServer::getClusterName();
|
||||
ChatServer::invite((*i), characterName, chat.getRoomName());
|
||||
}
|
||||
else if(cm.isType("ChatUninviteFromRoom"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatUninviteFromRoom");
|
||||
//printf("ConnectionServerConnection -- ChatUninviteAvatarToRoom\n");
|
||||
ChatUninviteFromRoom chat(cri);
|
||||
ChatAvatarId characterName = chat.getAvatar();
|
||||
if(characterName.gameCode.empty())
|
||||
characterName.gameCode = "SWG";
|
||||
if(characterName.cluster.empty())
|
||||
characterName.cluster = ConfigChatServer::getClusterName();
|
||||
ChatServer::uninvite((*i), chat.getSequence(), characterName, chat.getRoomName());
|
||||
}
|
||||
else if(cm.isType("ChatBanAvatarFromRoom"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatBanAvatarFromRoom");
|
||||
//printf("ConnectionServerConnection -- ChatBanAvatarFromRoom\n");
|
||||
ChatBanAvatarFromRoom chat(cri);
|
||||
ChatAvatarId characterName = chat.getAvatarId();
|
||||
if(characterName.gameCode.empty())
|
||||
characterName.gameCode = "SWG";
|
||||
if(characterName.cluster.empty())
|
||||
characterName.cluster = ConfigChatServer::getClusterName();
|
||||
ChatServer::banFromRoom(chat.getSequence(), (*i), characterName, chat.getRoomName());
|
||||
}
|
||||
else if(cm.isType("ChatUnbanAvatarFromRoom"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - ChatUnbanAvatarFromRoom");
|
||||
//printf("ConnectionServerConnection -- ChatUnbanAvatarFromRoom\n");
|
||||
ChatUnbanAvatarFromRoom chat(cri);
|
||||
ChatAvatarId characterName = chat.getAvatarId();
|
||||
if(characterName.gameCode.empty())
|
||||
characterName.gameCode = "SWG";
|
||||
if(characterName.cluster.empty())
|
||||
characterName.cluster = ConfigChatServer::getClusterName();
|
||||
ChatServer::unbanFromRoom(chat.getSequence(), (*i), characterName, chat.getRoomName());
|
||||
}
|
||||
else if(cm.isType("VerifyPlayerNameMessage"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("ConnectionServer - VerifyPlayerNameMessage");
|
||||
VerifyPlayerNameMessage message(cri);
|
||||
|
||||
bool const valid = ChatServer::isValidChatAvatarName(message.getPlayerName());
|
||||
|
||||
VerifyPlayerNameResponseMessage response(valid, message.getPlayerName());
|
||||
|
||||
ChatServer::fileLog(true, "ConnectionServerConnection", "onReceive() message(VerifyPlayerNameMessage) name(%s) valid(%s)", Unicode::wideToNarrow(message.getPlayerName()).c_str(), (valid ? "yes" : "no"));
|
||||
|
||||
sendToClient(message.getSourceNetworkId(), response);
|
||||
}
|
||||
|
||||
//messages to allow personal channels
|
||||
else if (cm.isType(VoiceChatRequestPersonalChannel::cms_name))
|
||||
{
|
||||
VoiceChatRequestPersonalChannel message(cri);
|
||||
|
||||
std::string userName, playerName;
|
||||
if(ChatServer::getVoiceChatLoginInfoFromId(message.getOwner(), userName, playerName))
|
||||
{
|
||||
std::list<std::string> modlist;
|
||||
modlist.push_back(userName);
|
||||
|
||||
if(message.getShouldCreate())
|
||||
{
|
||||
// 400 is the current vivox channel size limit when this was written
|
||||
ChatServer::requestGetChannel(message.getOwner(), ChatServer::getVChatInterface()->buildPersonalChannelName(message.getOwner()), false, false, 400, modlist);
|
||||
}
|
||||
else
|
||||
{
|
||||
ChatServer::getVChatInterface()->sendChannelData(message.getOwner(), ChatServer::getVChatInterface()->buildPersonalChannelName(message.getOwner()), "", true, true);
|
||||
}
|
||||
}
|
||||
//@TODO: error message?
|
||||
}
|
||||
else if (cm.isType(VoiceChatInvite::cms_name))
|
||||
{
|
||||
VoiceChatInvite message(cri);
|
||||
if(message.getChannelName() == ChatServer::getVChatInterface()->buildPersonalChannelName(message.getRequester()))
|
||||
{
|
||||
NetworkId targetId = message.getInviteeId();
|
||||
std::string const & targetName = message.getInviteeName();
|
||||
if(targetId.isValid() ||
|
||||
(!targetName.empty() && ChatServer::getVoiceChatLoginInfoFromName(targetName, targetId)))
|
||||
{
|
||||
ChatServer::requestInvitePlayerToChannel(message.getRequester(), targetId, message.getChannelName());
|
||||
}
|
||||
}
|
||||
//@TODO: error message?
|
||||
}
|
||||
else if (cm.isType(VoiceChatKick::cms_name))
|
||||
{
|
||||
VoiceChatKick message(cri);
|
||||
if(message.getChannelName() == ChatServer::getVChatInterface()->buildPersonalChannelName(message.getRequester()))
|
||||
{
|
||||
NetworkId targetId = message.getKickeeId();
|
||||
std::string const & targetName = message.getKickeeName();
|
||||
if(targetId.isValid() ||
|
||||
(!targetName.empty() && (ChatServer::getVoiceChatLoginInfoFromName(targetName, targetId))))
|
||||
{
|
||||
ChatServer::requestKickPlayerFromChannel(message.getRequester(), targetId, message.getChannelName());
|
||||
}
|
||||
}
|
||||
//@TODO: error message?
|
||||
}
|
||||
else if (cm.isType(VoiceChatRequestChannelInfo::cms_name))
|
||||
{
|
||||
VoiceChatRequestChannelInfo message(cri);
|
||||
ChatServer::requestChannelInfo(message.getRequester(), message.getChannelName());
|
||||
}
|
||||
}
|
||||
|
||||
// @todo : how is a message sent to anyone with a station account?
|
||||
|
||||
else
|
||||
{
|
||||
// defer until avatar is connected to chat backend
|
||||
ChatServer::deferChatMessageFor((*i), message);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,8 +34,7 @@
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
#include "UnicodeUtils.h"
|
||||
|
||||
#include "sharedNetworkMessages/VoiceChatChannelInfo.h"
|
||||
#include "sharedNetworkMessages/VoiceChatMiscMessages.h"
|
||||
#include "sharedFoundation/CrcConstexpr.hpp"
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
@@ -109,287 +108,275 @@ void GameServerConnection::onReceive(const Archive::ByteStream & message)
|
||||
//LOG("GameServerConnection", ("onReceive - %s", gameNetworkMessage.getCmdName().c_str()));
|
||||
//DEBUG_REPORT_LOG(true, ("***ChatServ: GameServerConnection::onReceive() message(%s)\n", gameNetworkMessage.getCmdName().c_str()));
|
||||
|
||||
if(gameNetworkMessage.isType("ChatDeleteAllPersistentMessages"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - ChatDeleteAllPersistentMessages");
|
||||
ChatDeleteAllPersistentMessages chatDeleteAllPersistentMessages(ri);
|
||||
ChatServer::deleteAllPersistentMessages(chatDeleteAllPersistentMessages.getSourceNetworkId(), chatDeleteAllPersistentMessages.getTargetNetworkId());
|
||||
}
|
||||
else if(gameNetworkMessage.isType("ChatCreateRoom"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - ChatCreateRoom");
|
||||
//printf("GameServerConnection -- ChatCreateRoom\n");
|
||||
ChatCreateRoom chat(ri);
|
||||
unsigned int sequence = chat.getSequence();
|
||||
ChatServer::addGameServerConnection(sequence, this);
|
||||
ChatServer::createRoom(NetworkId::cms_invalid, sequence, chat.getRoomName(), chat.getIsModerated(), chat.getIsPublic(), chat.getRoomTitle());
|
||||
}
|
||||
else if(gameNetworkMessage.isType("ChatRequestLog"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - ChatRequestLog");
|
||||
ChatRequestLog chatRequestLog(ri);
|
||||
std::vector<ChatLogEntry> chatLog;
|
||||
ChatServer::getChatLog(chatRequestLog.getPlayer(), chatLog);
|
||||
|
||||
ChatOnRequestLog chatOnRequestLog(chatRequestLog.getSequence(), chatLog);
|
||||
|
||||
static Archive::ByteStream a;
|
||||
a.clear();
|
||||
chatOnRequestLog.pack(a);
|
||||
|
||||
(static_cast<Connection *>(this))->send(a, true);
|
||||
}
|
||||
else if(gameNetworkMessage.isType("ChatDestroyRoomByName"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - ChatDestroyRoomByName");
|
||||
//printf("GameServerConnection -- ChatDestroyRoomByName\n");
|
||||
ChatDestroyRoomByName chat(ri);
|
||||
ChatServer::destroyRoom(chat.getRoomPath());
|
||||
}
|
||||
else if(gameNetworkMessage.isType("ChatPutAvatarInRoom"))
|
||||
{
|
||||
//printf("GameServerConnection -- ChatPutAvatarInRoom\n");
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - ChatPutAvatarInRoom");
|
||||
ChatPutAvatarInRoom chat(ri);
|
||||
ChatAvatarId id;
|
||||
id.cluster = ConfigChatServer::getClusterName();
|
||||
id.gameCode = m_gameCode;
|
||||
id.name = chat.getAvatarName();
|
||||
size_t pos = id.name.find(" ");
|
||||
if(pos != std::string::npos)
|
||||
id.name = id.name.substr(0, pos);
|
||||
ChatServer::enterRoom(id, chat.getRoomName(), chat.getForceCreate(), chat.getCreatePrivate());
|
||||
|
||||
}
|
||||
else if(gameNetworkMessage.isType("ChatInviteAvatarToRoom"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - ChatInviteAvatarToRoom");
|
||||
//printf("GameServerConnection -- ChatInviteAvatarToRoom\n");
|
||||
ChatInviteAvatarToRoom chat(ri);
|
||||
ChatAvatarId characterName = chat.getAvatarId();
|
||||
if(characterName.gameCode.empty())
|
||||
characterName.gameCode = "SWG";
|
||||
if(characterName.cluster.empty())
|
||||
characterName.cluster = ConfigChatServer::getClusterName();
|
||||
ChatServer::invite(NetworkId::cms_invalid, characterName, chat.getRoomName());
|
||||
}
|
||||
else if(gameNetworkMessage.isType("ChatInviteGroupMembersToRoom"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - ChatInviteGroupMembersToRoom");
|
||||
//printf("GameServerConnection -- ChatInviteGroupMembersToRoom\n");
|
||||
ChatInviteGroupMembersToRoom chat(ri);
|
||||
ChatServer::inviteGroupMembers(chat.getInvitorNetworkId(), chat.getGroupLeaderId(), chat.getRoomName(), chat.getInvitedMembers());
|
||||
}
|
||||
else if(gameNetworkMessage.isType("ChatUninviteFromRoom"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - ChatUninviteAvatarToRoom");
|
||||
//printf("GameServerConnection -- ChatUninviteAvatarFromRoom\n");
|
||||
ChatUninviteFromRoom chat(ri);
|
||||
ChatAvatarId characterName = chat.getAvatar();
|
||||
if(characterName.gameCode.empty())
|
||||
characterName.gameCode = "SWG";
|
||||
if(characterName.cluster.empty())
|
||||
characterName.cluster = ConfigChatServer::getClusterName();
|
||||
ChatServer::uninvite(ChatServer::getNetworkIdByAvatarId(characterName), chat.getSequence(), characterName, chat.getRoomName());
|
||||
}
|
||||
else if (gameNetworkMessage.isType("ChatChangeFriendStatus"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - ChatChangeFriendStatus");
|
||||
//printf("GameServerConnection -- ChatChangeFriendStatus\n");
|
||||
ChatChangeFriendStatus chat(ri);
|
||||
|
||||
if (chat.getAdd())
|
||||
const uint32 messageType = gameNetworkMessage.getType();
|
||||
|
||||
switch(messageType) {
|
||||
case constcrc("ChatDeleteAllPersistentMessages") :
|
||||
{
|
||||
ChatServer::addFriend(
|
||||
ChatServer::getNetworkIdByAvatarId(chat.getCharacterName()),
|
||||
chat.getSequence(), chat.getFriendName());
|
||||
}
|
||||
else
|
||||
{
|
||||
ChatServer::removeFriend(
|
||||
ChatServer::getNetworkIdByAvatarId(chat.getCharacterName()),
|
||||
chat.getSequence(), chat.getFriendName());
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - ChatDeleteAllPersistentMessages");
|
||||
ChatDeleteAllPersistentMessages chatDeleteAllPersistentMessages(ri);
|
||||
ChatServer::deleteAllPersistentMessages(chatDeleteAllPersistentMessages.getSourceNetworkId(), chatDeleteAllPersistentMessages.getTargetNetworkId());
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
else if (gameNetworkMessage.isType("ChatGetFriendsList"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - ChatGetFriendsList");
|
||||
//printf("GameServerConnection -- ChatGetFriendsList\n");
|
||||
ChatGetFriendsList chat(ri);
|
||||
|
||||
ChatServer::getFriendsList(chat.getCharacterName());
|
||||
}
|
||||
else if (gameNetworkMessage.isType("ChatChangeIgnoreStatus"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - ChatChangeIgnoreStatus");
|
||||
//printf("GameServerConnection -- ChatChangeIgnoreStatus\n");
|
||||
ChatChangeIgnoreStatus chat(ri);
|
||||
|
||||
if (chat.getIgnore())
|
||||
case constcrc("ChatCreateRoom") :
|
||||
{
|
||||
ChatServer::addIgnore(
|
||||
ChatServer::getNetworkIdByAvatarId(chat.getCharacterName()),
|
||||
chat.getSequence(), chat.getIgnoreName());
|
||||
}
|
||||
else
|
||||
{
|
||||
ChatServer::removeIgnore(
|
||||
ChatServer::getNetworkIdByAvatarId(chat.getCharacterName()),
|
||||
chat.getSequence(), chat.getIgnoreName());
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - ChatCreateRoom");
|
||||
//printf("GameServerConnection -- ChatCreateRoom\n");
|
||||
ChatCreateRoom chat(ri);
|
||||
unsigned int sequence = chat.getSequence();
|
||||
ChatServer::addGameServerConnection(sequence, this);
|
||||
ChatServer::createRoom(NetworkId::cms_invalid, sequence, chat.getRoomName(), chat.getIsModerated(), chat.getIsPublic(), chat.getRoomTitle());
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
else if (gameNetworkMessage.isType("ChatGetIgnoreList"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - ChatGetIgnoreList");
|
||||
//printf("GameServerConnection -- ChatGetIgnoreList\n");
|
||||
ChatGetIgnoreList chat(ri);
|
||||
|
||||
ChatServer::getIgnoreList(chat.getCharacterName());
|
||||
}
|
||||
else if(gameNetworkMessage.isType("ChatRemoveAvatarFromRoom"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - ChatRemoveAvatarFromRoom");
|
||||
//printf("GameServerConnection -- ChatRemoveAvatarFromRoom\n");
|
||||
ChatRemoveAvatarFromRoom chat(ri);
|
||||
ChatAvatarId id = chat.getAvatarId();
|
||||
size_t pos = id.name.find(" ");
|
||||
if(pos != std::string::npos)
|
||||
id.name = id.name.substr(0, pos);
|
||||
ChatServer::removeAvatarFromRoom(id, chat.getRoomName());
|
||||
}
|
||||
else if(gameNetworkMessage.isType("ChatMessageFromGame"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - ChatMessageFromGame");
|
||||
//printf("GameServerConnection -- ChatMessageFromGame\n");
|
||||
ChatMessageFromGame chat(ri);
|
||||
std::string recipient = chat.getTo();
|
||||
size_t pos = recipient.find(" ");
|
||||
if (pos != std::string::npos)
|
||||
case constcrc("ChatRequestLog") :
|
||||
{
|
||||
recipient = recipient.substr(0, pos);
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - ChatRequestLog");
|
||||
ChatRequestLog chatRequestLog(ri);
|
||||
std::vector<ChatLogEntry> chatLog;
|
||||
ChatServer::getChatLog(chatRequestLog.getPlayer(), chatLog);
|
||||
|
||||
ChatOnRequestLog chatOnRequestLog(chatRequestLog.getSequence(), chatLog);
|
||||
|
||||
static Archive::ByteStream a;
|
||||
a.clear();
|
||||
chatOnRequestLog.pack(a);
|
||||
|
||||
(static_cast<Connection *>(this))->send(a, true);
|
||||
break;
|
||||
}
|
||||
switch(chat.getMessageType())
|
||||
case constcrc("ChatDestroyRoomByName") :
|
||||
{
|
||||
case ChatMessageFromGame::INSTANT:
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - ChatDestroyRoomByName");
|
||||
//printf("GameServerConnection -- ChatDestroyRoomByName\n");
|
||||
ChatDestroyRoomByName chat(ri);
|
||||
ChatServer::destroyRoom(chat.getRoomPath());
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatPutAvatarInRoom") :
|
||||
{
|
||||
//printf("GameServerConnection -- ChatPutAvatarInRoom\n");
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - ChatPutAvatarInRoom");
|
||||
ChatPutAvatarInRoom chat(ri);
|
||||
ChatAvatarId id;
|
||||
id.cluster = ConfigChatServer::getClusterName();
|
||||
id.gameCode = m_gameCode;
|
||||
id.name = chat.getAvatarName();
|
||||
size_t pos = id.name.find(" ");
|
||||
if(pos != std::string::npos)
|
||||
id.name = id.name.substr(0, pos);
|
||||
ChatServer::enterRoom(id, chat.getRoomName(), chat.getForceCreate(), chat.getCreatePrivate());
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatInviteAvatarToRoom") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - ChatInviteAvatarToRoom");
|
||||
//printf("GameServerConnection -- ChatInviteAvatarToRoom\n");
|
||||
ChatInviteAvatarToRoom chat(ri);
|
||||
ChatAvatarId characterName = chat.getAvatarId();
|
||||
if(characterName.gameCode.empty())
|
||||
characterName.gameCode = "SWG";
|
||||
if(characterName.cluster.empty())
|
||||
characterName.cluster = ConfigChatServer::getClusterName();
|
||||
ChatServer::invite(NetworkId::cms_invalid, characterName, chat.getRoomName());
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatInviteGroupMembersToRoom") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - ChatInviteGroupMembersToRoom");
|
||||
//printf("GameServerConnection -- ChatInviteGroupMembersToRoom\n");
|
||||
ChatInviteGroupMembersToRoom chat(ri);
|
||||
ChatServer::inviteGroupMembers(chat.getInvitorNetworkId(), chat.getGroupLeaderId(), chat.getRoomName(), chat.getInvitedMembers());
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatUninviteFromRoom") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - ChatUninviteAvatarToRoom");
|
||||
//printf("GameServerConnection -- ChatUninviteAvatarFromRoom\n");
|
||||
ChatUninviteFromRoom chat(ri);
|
||||
ChatAvatarId characterName = chat.getAvatar();
|
||||
if(characterName.gameCode.empty())
|
||||
characterName.gameCode = "SWG";
|
||||
if(characterName.cluster.empty())
|
||||
characterName.cluster = ConfigChatServer::getClusterName();
|
||||
ChatServer::uninvite(ChatServer::getNetworkIdByAvatarId(characterName), chat.getSequence(), characterName, chat.getRoomName());
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatChangeFriendStatus") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - ChatChangeFriendStatus");
|
||||
//printf("GameServerConnection -- ChatChangeFriendStatus\n");
|
||||
ChatChangeFriendStatus chat(ri);
|
||||
|
||||
if (chat.getAdd())
|
||||
{
|
||||
ChatAvatarId from(chat.getFrom());
|
||||
if (from.cluster.empty())
|
||||
from.cluster = ConfigChatServer::getClusterName();
|
||||
if (from.gameCode.empty())
|
||||
from.gameCode = m_gameCode;
|
||||
ChatServer::addFriend(
|
||||
ChatServer::getNetworkIdByAvatarId(chat.getCharacterName()),
|
||||
chat.getSequence(), chat.getFriendName());
|
||||
}
|
||||
else
|
||||
{
|
||||
ChatServer::removeFriend(
|
||||
ChatServer::getNetworkIdByAvatarId(chat.getCharacterName()),
|
||||
chat.getSequence(), chat.getFriendName());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatGetFriendsList") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - ChatGetFriendsList");
|
||||
//printf("GameServerConnection -- ChatGetFriendsList\n");
|
||||
ChatGetFriendsList chat(ri);
|
||||
|
||||
ChatAvatarId to(recipient);
|
||||
if (to.cluster.empty())
|
||||
to.cluster = ConfigChatServer::getClusterName();
|
||||
if (to.gameCode.empty())
|
||||
to.gameCode = m_gameCode;
|
||||
ChatServer::getFriendsList(chat.getCharacterName());
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatChangeIgnoreStatus") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - ChatChangeIgnoreStatus");
|
||||
//printf("GameServerConnection -- ChatChangeIgnoreStatus\n");
|
||||
ChatChangeIgnoreStatus chat(ri);
|
||||
|
||||
ChatServer::sendInstantMessage(from, to, chat.getMessage(), chat.getOutOfBand());
|
||||
if (chat.getIgnore())
|
||||
{
|
||||
ChatServer::addIgnore(
|
||||
ChatServer::getNetworkIdByAvatarId(chat.getCharacterName()),
|
||||
chat.getSequence(), chat.getIgnoreName());
|
||||
}
|
||||
else
|
||||
{
|
||||
ChatServer::removeIgnore(
|
||||
ChatServer::getNetworkIdByAvatarId(chat.getCharacterName()),
|
||||
chat.getSequence(), chat.getIgnoreName());
|
||||
}
|
||||
break;
|
||||
case ChatMessageFromGame::PERSISTENT:
|
||||
{
|
||||
ChatAvatarId from(chat.getFrom());
|
||||
if (from.cluster.empty())
|
||||
from.cluster = ConfigChatServer::getClusterName();
|
||||
if (from.gameCode.empty())
|
||||
from.gameCode = m_gameCode;
|
||||
|
||||
ChatAvatarId to(recipient);
|
||||
if (to.cluster.empty())
|
||||
to.cluster = ConfigChatServer::getClusterName();
|
||||
if (to.gameCode.empty())
|
||||
to.gameCode = m_gameCode;
|
||||
|
||||
ChatServer::sendPersistentMessage(from, to, chat.getSubject(), chat.getMessage(), chat.getOutOfBand());
|
||||
}
|
||||
break;
|
||||
case ChatMessageFromGame::ROOM:
|
||||
{
|
||||
ChatAvatarId from(chat.getFrom());
|
||||
if (from.cluster.empty())
|
||||
from.cluster = ConfigChatServer::getClusterName();
|
||||
if (from.gameCode.empty())
|
||||
from.gameCode = m_gameCode;
|
||||
}
|
||||
case constcrc("ChatGetIgnoreList") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - ChatGetIgnoreList");
|
||||
//printf("GameServerConnection -- ChatGetIgnoreList\n");
|
||||
ChatGetIgnoreList chat(ri);
|
||||
|
||||
ChatServer::sendStandardRoomMessage(from, chat.getRoom(), chat.getMessage(), chat.getOutOfBand());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
REPORT_LOG(true, ("Unkown Game Chat Message type\n"));
|
||||
ChatServer::getIgnoreList(chat.getCharacterName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (gameNetworkMessage.isType("SetUnsquelchTime"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - SetUnsquelchTime");
|
||||
//printf("GameServerConnection -- SetUnsquelchTime\n");
|
||||
GenericValueTypeMessage<std::pair<NetworkId, int> > setUnsquelchTime(ri);
|
||||
case constcrc("ChatRemoveAvatarFromRoom") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - ChatRemoveAvatarFromRoom");
|
||||
//printf("GameServerConnection -- ChatRemoveAvatarFromRoom\n");
|
||||
ChatRemoveAvatarFromRoom chat(ri);
|
||||
ChatAvatarId id = chat.getAvatarId();
|
||||
size_t pos = id.name.find(" ");
|
||||
if(pos != std::string::npos)
|
||||
id.name = id.name.substr(0, pos);
|
||||
ChatServer::removeAvatarFromRoom(id, chat.getRoomName());
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatMessageFromGame") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - ChatMessageFromGame");
|
||||
//printf("GameServerConnection -- ChatMessageFromGame\n");
|
||||
ChatMessageFromGame chat(ri);
|
||||
std::string recipient = chat.getTo();
|
||||
size_t pos = recipient.find(" ");
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
recipient = recipient.substr(0, pos);
|
||||
}
|
||||
switch(chat.getMessageType())
|
||||
{
|
||||
case ChatMessageFromGame::INSTANT:
|
||||
{
|
||||
ChatAvatarId from(chat.getFrom());
|
||||
if (from.cluster.empty())
|
||||
from.cluster = ConfigChatServer::getClusterName();
|
||||
if (from.gameCode.empty())
|
||||
from.gameCode = m_gameCode;
|
||||
|
||||
ChatServer::setUnsquelchTime(setUnsquelchTime.getValue().first, static_cast<time_t>(setUnsquelchTime.getValue().second));
|
||||
}
|
||||
else if (gameNetworkMessage.isType("ChatStatisticsGS"))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - ChatStatisticsGS");
|
||||
//printf("GameServerConnection -- ChatStatisticsGS\n");
|
||||
GenericValueTypeMessage<std::pair<std::pair<std::pair<NetworkId, int>, int>, std::pair<int, int> > > chatStatistics(ri);
|
||||
ChatAvatarId to(recipient);
|
||||
if (to.cluster.empty())
|
||||
to.cluster = ConfigChatServer::getClusterName();
|
||||
if (to.gameCode.empty())
|
||||
to.gameCode = m_gameCode;
|
||||
|
||||
ChatServer::handleChatStatisticsFromGameServer(chatStatistics.getValue().first.first.first, static_cast<time_t>(chatStatistics.getValue().first.first.second), static_cast<time_t>(chatStatistics.getValue().first.second), chatStatistics.getValue().second.first, chatStatistics.getValue().second.second);
|
||||
}
|
||||
//it eats at my soul to participate in this elseif chain
|
||||
else if (gameNetworkMessage.isType(VoiceChatGetChannel::cms_name))
|
||||
{
|
||||
Archive::ReadIterator ri = message.begin();
|
||||
VoiceChatGetChannel createRoomMessage(ri);
|
||||
std::list<std::string> mods;
|
||||
ChatServer::instance().requestGetChannel(ReturnAddress(m_connectionId),createRoomMessage.getRoomName(), createRoomMessage.getIsPublic(), createRoomMessage.getIsPersistant(), createRoomMessage.getLimit(), mods);
|
||||
}
|
||||
else if (gameNetworkMessage.isType(VoiceChatDeleteChannel::cms_name))
|
||||
{
|
||||
Archive::ReadIterator ri = message.begin();
|
||||
VoiceChatDeleteChannel destroyRoomMessage(ri);
|
||||
ChatServer::instance().requestDeleteChannel(ReturnAddress(m_connectionId),destroyRoomMessage.getRoomName());
|
||||
}
|
||||
else if (gameNetworkMessage.isType(VoiceChatAddClientToChannel::cms_name))
|
||||
{
|
||||
Archive::ReadIterator ri = message.begin();
|
||||
VoiceChatAddClientToChannel addMessage(ri);
|
||||
ChatServer::instance().requestAddClientToChannel(addMessage.getClientId(), addMessage.getClientName(), addMessage.getChannelName(), addMessage.getForceShortlist());
|
||||
}
|
||||
else if (gameNetworkMessage.isType(VoiceChatRemoveClientFromChannel::cms_name))
|
||||
{
|
||||
Archive::ReadIterator ri = message.begin();
|
||||
VoiceChatRemoveClientFromChannel msg(ri);
|
||||
ChatServer::instance().requestRemoveClientFromChannel(msg.getClientId(), msg.getClientName(), msg.getChannelName());
|
||||
}
|
||||
else if (gameNetworkMessage.isType(VoiceChatChannelCommand::cms_name))
|
||||
{
|
||||
Archive::ReadIterator ri = message.begin();
|
||||
VoiceChatChannelCommand msg(ri);
|
||||
ChatServer::instance().requestChannelCommand(ReturnAddress(m_connectionId), msg.getSourceUserName(),msg.getTargetUserName(),msg.getChannelName(),msg.getCommandType(),msg.getBanTimeout());
|
||||
}
|
||||
else if (gameNetworkMessage.isType("BroadcastGlobalChannel"))
|
||||
{
|
||||
Archive::ReadIterator ri = message.begin();
|
||||
ChatServer::sendInstantMessage(from, to, chat.getMessage(), chat.getOutOfBand());
|
||||
}
|
||||
break;
|
||||
case ChatMessageFromGame::PERSISTENT:
|
||||
{
|
||||
ChatAvatarId from(chat.getFrom());
|
||||
if (from.cluster.empty())
|
||||
from.cluster = ConfigChatServer::getClusterName();
|
||||
if (from.gameCode.empty())
|
||||
from.gameCode = m_gameCode;
|
||||
|
||||
ChatAvatarId to(recipient);
|
||||
if (to.cluster.empty())
|
||||
to.cluster = ConfigChatServer::getClusterName();
|
||||
if (to.gameCode.empty())
|
||||
to.gameCode = m_gameCode;
|
||||
|
||||
ChatServer::sendPersistentMessage(from, to, chat.getSubject(), chat.getMessage(), chat.getOutOfBand());
|
||||
}
|
||||
break;
|
||||
case ChatMessageFromGame::ROOM:
|
||||
{
|
||||
ChatAvatarId from(chat.getFrom());
|
||||
if (from.cluster.empty())
|
||||
from.cluster = ConfigChatServer::getClusterName();
|
||||
if (from.gameCode.empty())
|
||||
from.gameCode = m_gameCode;
|
||||
|
||||
typedef std::pair<std::pair<std::string,std::string>, bool> PayloadType;
|
||||
GenericValueTypeMessage<PayloadType> msg(ri);
|
||||
ChatServer::sendStandardRoomMessage(from, chat.getRoom(), chat.getMessage(), chat.getOutOfBand());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
REPORT_LOG(true, ("Unkown Game Chat Message type\n"));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case constcrc("SetUnsquelchTime") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - SetUnsquelchTime");
|
||||
//printf("GameServerConnection -- SetUnsquelchTime\n");
|
||||
GenericValueTypeMessage<std::pair<NetworkId, int> > setUnsquelchTime(ri);
|
||||
|
||||
PayloadType const & payload = msg.getValue();
|
||||
std::string const & channelName = payload.first.first;
|
||||
std::string const & messageText = payload.first.second;
|
||||
bool const & isRemove = payload.second;
|
||||
ChatServer::setUnsquelchTime(setUnsquelchTime.getValue().first, static_cast<time_t>(setUnsquelchTime.getValue().second));
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatStatisticsGS") :
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("GameServerConnection - ChatStatisticsGS");
|
||||
//printf("GameServerConnection -- ChatStatisticsGS\n");
|
||||
GenericValueTypeMessage<std::pair<std::pair<std::pair<NetworkId, int>, int>, std::pair<int, int> > > chatStatistics(ri);
|
||||
|
||||
LOG("CustomerService", ("BroadcastVoiceChannel: ChatServer got BroadcastGlobalChannel on GameServerConnection chan(%s) text(%s) remove(%d)",
|
||||
channelName.c_str(), messageText.c_str(), (isRemove?1:0)));
|
||||
ChatServer::requestBroadcastChannelMessage(channelName, messageText, isRemove);
|
||||
}
|
||||
else if (gameNetworkMessage.isType("ChatDestroyAvatar"))
|
||||
{
|
||||
GenericValueTypeMessage<std::string> const msg(ri);
|
||||
ChatServer::getChatInterface()->DestroyAvatar(msg.getValue());
|
||||
ChatServer::handleChatStatisticsFromGameServer(chatStatistics.getValue().first.first.first, static_cast<time_t>(chatStatistics.getValue().first.first.second), static_cast<time_t>(chatStatistics.getValue().first.second), chatStatistics.getValue().second.first, chatStatistics.getValue().second.second);
|
||||
break;
|
||||
}
|
||||
case constcrc("BroadcastGlobalChannel") :
|
||||
{
|
||||
Archive::ReadIterator ri = message.begin();
|
||||
|
||||
typedef std::pair<std::pair<std::string,std::string>, bool> PayloadType;
|
||||
GenericValueTypeMessage<PayloadType> msg(ri);
|
||||
|
||||
PayloadType const & payload = msg.getValue();
|
||||
std::string const & channelName = payload.first.first;
|
||||
std::string const & messageText = payload.first.second;
|
||||
bool const & isRemove = payload.second;
|
||||
|
||||
LOG("CustomerService", ("ChatServer got BroadcastGlobalChannel on GameServerConnection chan(%s) text(%s) remove(%d)",
|
||||
channelName.c_str(), messageText.c_str(), (isRemove?1:0)));
|
||||
ChatServer::requestBroadcastChannelMessage(channelName, messageText, isRemove);
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatDestroyAvatar") :
|
||||
{
|
||||
GenericValueTypeMessage<std::string> const msg(ri);
|
||||
ChatServer::getChatInterface()->DestroyAvatar(msg.getValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -435,7 +435,7 @@ void VChatInterface::OnConnectionOpened( const char * address )
|
||||
ChatServer::fileLog(ms_voiceLoggingEnabled, ms_logLable, "OnConnectionOpened: %s", address);
|
||||
|
||||
|
||||
uint32 track = VChatAPI::GetAccount(ms_systemAvatarName, ConfigChatServer::getGameCode(), ConfigChatServer::getClusterName(), 0, 0, NULL);
|
||||
uint32 track = VChatAPI::GetAccount(ms_systemAvatarName, ConfigChatServer::getGameCode(), ConfigChatServer::getClusterName(), 0, 0, nullptr);
|
||||
ChatServer::fileLog(ms_voiceLoggingEnabled, ms_logLable, "Creating system avatar: %s track(%u)", getSystemLoginName().c_str(), track);
|
||||
}
|
||||
|
||||
@@ -477,7 +477,7 @@ void VChatInterface::OnGetAccount(unsigned track, unsigned result, unsigned user
|
||||
{
|
||||
requestConnectPlayer(info->suid,info->avatarName,info->id, info->failedAttempts+1);
|
||||
delete info;
|
||||
info = NULL;
|
||||
info = nullptr;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -501,7 +501,7 @@ void VChatInterface::OnGetAccount(unsigned track, unsigned result, unsigned user
|
||||
}
|
||||
|
||||
delete info;
|
||||
info = NULL;
|
||||
info = nullptr;
|
||||
}
|
||||
|
||||
void VChatInterface::OnGetChannelV2(unsigned track, unsigned result,
|
||||
@@ -639,7 +639,7 @@ void VChatInterface::OnGetAllChannels(unsigned track, unsigned result, const VCh
|
||||
|
||||
if(shouldRetry)
|
||||
{
|
||||
GetAllChannels(NULL);
|
||||
GetAllChannels(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -832,7 +832,7 @@ void VChatInterface::checkForCharacterChannelAdd(std::string const & name, std::
|
||||
data.m_channelPassword,
|
||||
data.m_channelURI,
|
||||
"en_US",
|
||||
NULL);
|
||||
nullptr);
|
||||
|
||||
(*iter).second.push_back(playerOID);
|
||||
|
||||
@@ -877,7 +877,7 @@ void VChatInterface::checkForCharacterChannelRemove(std::string const & name, st
|
||||
parseWorldName(std::string(avatar->getServer().c_str())),
|
||||
"SWG",
|
||||
"guild",
|
||||
NULL);
|
||||
nullptr);
|
||||
}
|
||||
|
||||
iter = (*chanIter).second.erase(iter);
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
#include "FirstChatServer.h"
|
||||
#include "ConfigChatServer.h"
|
||||
#include "ChatServer.h"
|
||||
#include "sharedCompression/SetupSharedCompression.h"
|
||||
#include "sharedDebug/SetupSharedDebug.h"
|
||||
#include "sharedFoundation/SetupSharedFoundation.h"
|
||||
#include "sharedNetworkMessages/SetupSharedNetworkMessages.h"
|
||||
#include "sharedThread/SetupSharedThread.h"
|
||||
|
||||
#include <string>
|
||||
#include <time.h>
|
||||
|
||||
int main( int argc, char ** argv )
|
||||
{
|
||||
SetupSharedThread::install();
|
||||
SetupSharedDebug::install(1024);
|
||||
|
||||
//-- setup foundation
|
||||
SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game);
|
||||
|
||||
//setupFoundationData.hInstance = hInstance;
|
||||
setupFoundationData.argc = argc;
|
||||
setupFoundationData.argv = argv;
|
||||
setupFoundationData.createWindow = false;
|
||||
setupFoundationData.clockUsesSleep = true;
|
||||
|
||||
SetupSharedFoundation::install (setupFoundationData);
|
||||
|
||||
SetupSharedCompression::install();
|
||||
|
||||
SetupSharedNetworkMessages::install();
|
||||
|
||||
//-- setup game server
|
||||
ConfigChatServer::install ();
|
||||
|
||||
//-- run game
|
||||
SetupSharedFoundation::callbackWithExceptionHandling(ChatServer::run);
|
||||
|
||||
SetupSharedFoundation::remove();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -61,7 +61,7 @@ int main(int argc, char ** argv)
|
||||
Unicode::UnicodeNarrowStringVector localeVector;
|
||||
localeVector.push_back(defaultLocale);
|
||||
|
||||
LocalizationManager::install (new TreeFile::TreeFileFactory, localeVector, debugStringIds, NULL, displayBadStringIds);
|
||||
LocalizationManager::install (new TreeFile::TreeFileFactory, localeVector, debugStringIds, nullptr, displayBadStringIds);
|
||||
ExitChain::add(LocalizationManager::remove, "LocalizationManager::remove");
|
||||
|
||||
DataTableManager::install();
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#include "sharedUtility/DataTable.h"
|
||||
#include "sharedUtility/DataTableManager.h"
|
||||
|
||||
#include "sharedFoundation/CrcConstexpr.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
// src/engine/client/library/clientGame/src/shared/core/AuctionManagerClient.cpp (s_maxBid)
|
||||
@@ -208,7 +210,7 @@ namespace AuctionNamespace
|
||||
if (iterAttr != searchableAttributeString->end())
|
||||
{
|
||||
applicableSearchCondition = true;
|
||||
return (NULL != strstr(iterAttr->second.c_str(), searchCondition.stringValue.c_str())); // lowercase is assumed (and required)
|
||||
return (nullptr != strstr(iterAttr->second.c_str(), searchCondition.stringValue.c_str())); // lowercase is assumed (and required)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,7 +244,7 @@ namespace AuctionNamespace
|
||||
if (iterAttr != searchableAttributeString->end())
|
||||
{
|
||||
applicableSearchCondition = true;
|
||||
return (NULL == strstr(iterAttr->second.c_str(), searchCondition.stringValue.c_str())); // lowercase is assumed (and required)
|
||||
return (nullptr == strstr(iterAttr->second.c_str(), searchCondition.stringValue.c_str())); // lowercase is assumed (and required)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,10 +295,10 @@ m_userDescription(userDescription),
|
||||
m_oobLength(oobLength),
|
||||
m_oobData(oobData),
|
||||
m_attributes(),
|
||||
m_searchableAttributeInt(NULL),
|
||||
m_searchableAttributeFloat(NULL),
|
||||
m_searchableAttributeString(NULL),
|
||||
m_highBid(NULL),
|
||||
m_searchableAttributeInt(nullptr),
|
||||
m_searchableAttributeFloat(nullptr),
|
||||
m_searchableAttributeString(nullptr),
|
||||
m_highBid(nullptr),
|
||||
m_item(new AuctionItem(itemId, itemType, itemTemplateId, itemTimer, itemNameLength, itemName, creatorId, itemSize)),
|
||||
m_sold(false),
|
||||
m_active(true),
|
||||
@@ -395,10 +397,10 @@ m_userDescription(userDescription),
|
||||
m_oobLength(oobLength),
|
||||
m_oobData(oobData),
|
||||
m_attributes(),
|
||||
m_searchableAttributeInt(NULL),
|
||||
m_searchableAttributeFloat(NULL),
|
||||
m_searchableAttributeString(NULL),
|
||||
m_highBid(NULL),
|
||||
m_searchableAttributeInt(nullptr),
|
||||
m_searchableAttributeFloat(nullptr),
|
||||
m_searchableAttributeString(nullptr),
|
||||
m_highBid(nullptr),
|
||||
m_item(new AuctionItem(itemId, itemType, itemTemplateId, itemTimer, itemNameLength, itemName, creatorId, itemSize)),
|
||||
m_sold(isSold),
|
||||
m_active(isActive),
|
||||
@@ -488,7 +490,7 @@ void Auction::Initialization()
|
||||
#ifdef _DEBUG
|
||||
for (int i = 0; i < static_cast<int>(AuctionQueryHeadersMessage::SCC_LAST); ++i)
|
||||
{
|
||||
s_searchConditionComparisonFn[i] = NULL;
|
||||
s_searchConditionComparisonFn[i] = nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -502,7 +504,7 @@ void Auction::Initialization()
|
||||
#ifdef _DEBUG
|
||||
for (int j = 0; j < static_cast<int>(AuctionQueryHeadersMessage::SCC_LAST); ++j)
|
||||
{
|
||||
DEBUG_FATAL((s_searchConditionComparisonFn[j] == NULL), ("s_searchConditionComparisonFn array is NULL at index (%d)", j));
|
||||
DEBUG_FATAL((s_searchConditionComparisonFn[j] == nullptr), ("s_searchConditionComparisonFn array is nullptr at index (%d)", j));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -659,7 +661,7 @@ const AuctionBid *Auction::GetPreviousBid() const
|
||||
{
|
||||
if (m_bids.size() <= 1)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -677,9 +679,9 @@ const AuctionBid *Auction::GetPreviousBid() const
|
||||
*/
|
||||
int Auction::GetActualBid(AuctionBid *bid)
|
||||
{
|
||||
assert(bid != NULL);
|
||||
assert(bid != nullptr);
|
||||
int bidNeeded = std::max(m_minBid, bid->GetBid());
|
||||
if (m_highBid != NULL)
|
||||
if (m_highBid != nullptr)
|
||||
{
|
||||
bidNeeded = m_highBid->GetBid();
|
||||
if (*bid > *m_highBid)
|
||||
@@ -765,7 +767,7 @@ AuctionResultCode Auction::AddBid(
|
||||
|
||||
AuctionBid *auctionBid = new AuctionBid(bidderId, bid, maxProxyBid);
|
||||
int newBidForHighBidder = GetActualBid(auctionBid);
|
||||
if (m_highBid != NULL)
|
||||
if (m_highBid != nullptr)
|
||||
{
|
||||
if (*auctionBid <= *m_highBid)
|
||||
{
|
||||
@@ -810,7 +812,7 @@ const AuctionBid *Auction::GetPlayerBid(const NetworkId & playerId) const
|
||||
}
|
||||
++iter;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -826,7 +828,7 @@ bool Auction::Update(int gameTime)
|
||||
//immediate sale
|
||||
DEBUG_REPORT_LOG(true, ("[Commodities Server Auction::Update] : Expiring immediate sale - Auction is active and sold.\n"));
|
||||
|
||||
if ((m_trackId != -1) && (CommodityServer::getInstance().getGameServer(m_trackId) != NULL))
|
||||
if ((m_trackId != -1) && (CommodityServer::getInstance().getGameServer(m_trackId) != nullptr))
|
||||
{
|
||||
Expire(true, false, m_trackId);
|
||||
m_trackId = -1;
|
||||
@@ -840,14 +842,14 @@ bool Auction::Update(int gameTime)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, ("[Commodities Server Auction::Update] : Auction expiring based on timer.\n"));
|
||||
|
||||
if ((m_trackId != -1) && (CommodityServer::getInstance().getGameServer(m_trackId) != NULL))
|
||||
if ((m_trackId != -1) && (CommodityServer::getInstance().getGameServer(m_trackId) != nullptr))
|
||||
{
|
||||
Expire(m_highBid != NULL, true, m_trackId);
|
||||
Expire(m_highBid != nullptr, true, m_trackId);
|
||||
m_trackId = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
Expire(m_highBid != NULL, true);
|
||||
Expire(m_highBid != nullptr, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -862,7 +864,7 @@ void Auction::Expire(bool sold, bool expiredBasedOnTimer, int track_id)
|
||||
|
||||
m_auctionTimer = 0;
|
||||
m_active = false;
|
||||
if (sold && m_highBid != NULL)
|
||||
if (sold && m_highBid != nullptr)
|
||||
{
|
||||
m_sold = true;
|
||||
}
|
||||
@@ -934,7 +936,7 @@ void Auction::Expire(bool sold, bool expiredBasedOnTimer, int track_id)
|
||||
m_location.SetVendorFirstTimerExpiredAuctionDate(time(0));
|
||||
}
|
||||
|
||||
DEBUG_REPORT_LOG(true, ("[Commodities Server Auction::Expire] : Sending OnAuctionExpired for non-sold auction and null high bid obj .\n"));
|
||||
DEBUG_REPORT_LOG(true, ("[Commodities Server Auction::Expire] : Sending OnAuctionExpired for non-sold auction and nullptr high bid obj .\n"));
|
||||
AuctionMarket::getInstance().OnAuctionExpired(
|
||||
GetCreatorId(), m_sold, m_flags,
|
||||
NetworkId::cms_invalid, 0, m_item->GetItemId(), 0,
|
||||
@@ -1107,8 +1109,8 @@ void Auction::BuildSearchableAttributeList()
|
||||
std::map<std::string, std::string> const & saAlias = CommoditiesAdvancedSearchAttribute::getSearchAttributeNameAliasesForGameObjectType(m_item->GetCategory());
|
||||
|
||||
// for factory crates, also include the attributes of the item inside the crate
|
||||
std::map<std::string, CommoditiesAdvancedSearchAttribute::SearchAttribute const *> const * saItemInsideFactoryCrate = NULL;
|
||||
std::map<std::string, std::string> const * saAliasItemInsideFactoryCrate = NULL;
|
||||
std::map<std::string, CommoditiesAdvancedSearchAttribute::SearchAttribute const *> const * saItemInsideFactoryCrate = nullptr;
|
||||
std::map<std::string, std::string> const * saAliasItemInsideFactoryCrate = nullptr;
|
||||
int gotItemInsideFactoryCrate = 0;
|
||||
|
||||
if (m_item->GetCategory() == SharedObjectTemplate::GOT_misc_factory_crate)
|
||||
@@ -1134,10 +1136,10 @@ void Auction::BuildSearchableAttributeList()
|
||||
saAliasItemInsideFactoryCrate = &(CommoditiesAdvancedSearchAttribute::getSearchAttributeNameAliasesForGameObjectType(gotItemInsideFactoryCrate));
|
||||
|
||||
if (saItemInsideFactoryCrate->empty())
|
||||
saItemInsideFactoryCrate = NULL;
|
||||
saItemInsideFactoryCrate = nullptr;
|
||||
|
||||
if (saAliasItemInsideFactoryCrate->empty())
|
||||
saAliasItemInsideFactoryCrate = NULL;
|
||||
saAliasItemInsideFactoryCrate = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1360,8 +1362,8 @@ void Auction::BuildSearchableAttributeList()
|
||||
if (!m_searchableAttributeString)
|
||||
m_searchableAttributeString = new std::map<uint32, std::string>;
|
||||
|
||||
static uint32 const shipCertAttributeCrc = Crc::calculate("ship_equipment_certification_search_attribute");
|
||||
static uint32 const astromechCertAttributeCrc = Crc::calculate("astromech_certification_search_attribute");
|
||||
static uint32 const shipCertAttributeCrc = constcrc("ship_equipment_certification_search_attribute");
|
||||
static uint32 const astromechCertAttributeCrc = constcrc("astromech_certification_search_attribute");
|
||||
|
||||
if (itemIsShipComponentOrShipFlightComputer)
|
||||
{
|
||||
|
||||
@@ -137,7 +137,7 @@ AuctionLocation::~AuctionLocation()
|
||||
|
||||
bool AuctionLocation::AddAuction(Auction *auction)
|
||||
{
|
||||
assert(auction != NULL);
|
||||
assert(auction != nullptr);
|
||||
if (IsVendorMarket() &&
|
||||
(!auction->IsActive() || !IsOwner(auction->GetCreatorId())))
|
||||
{
|
||||
@@ -189,7 +189,7 @@ void AuctionLocation::CancelVendorSale(Auction *auction)
|
||||
|
||||
bool AuctionLocation::RemoveAuction(Auction *auction)
|
||||
{
|
||||
assert(auction != NULL);
|
||||
assert(auction != nullptr);
|
||||
return RemoveAuction(auction->GetItem().GetItemId());
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ Auction *AuctionLocation::GetAuction(const NetworkId & itemId)
|
||||
return((*i).second);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace AuctionMarketNamespace
|
||||
Auction const * const auction,
|
||||
int const type,
|
||||
int const entranceCharge,
|
||||
AuctionBid const * const playerBid = NULL
|
||||
AuctionBid const * const playerBid = nullptr
|
||||
)
|
||||
{
|
||||
AuctionDataHeader *header = new AuctionDataHeader;
|
||||
@@ -301,7 +301,7 @@ namespace AuctionMarketNamespace
|
||||
std::map<std::string, int> attributeValue;
|
||||
};
|
||||
|
||||
GetItemAttributeDataRequest * getItemAttributeDataRequest = NULL;
|
||||
GetItemAttributeDataRequest * getItemAttributeDataRequest = nullptr;
|
||||
|
||||
void processItemAttributeData(std::map<NetworkId, Auction *> const & auctions);
|
||||
|
||||
@@ -394,8 +394,8 @@ void AuctionMarketNamespace::processItemAttributeData(std::map<NetworkId, Auctio
|
||||
|
||||
if (proceed)
|
||||
{
|
||||
std::map<std::string, CommoditiesAdvancedSearchAttribute::SearchAttribute const *> const * skipAttribute = NULL;
|
||||
std::map<std::string, std::string> const * skipAttributeAlias = NULL;
|
||||
std::map<std::string, CommoditiesAdvancedSearchAttribute::SearchAttribute const *> const * skipAttribute = nullptr;
|
||||
std::map<std::string, std::string> const * skipAttributeAlias = nullptr;
|
||||
if (getItemAttributeDataRequest->ignoreSearchableAttribute)
|
||||
{
|
||||
std::map<std::string, CommoditiesAdvancedSearchAttribute::SearchAttribute const *> const & sa = CommoditiesAdvancedSearchAttribute::getSearchAttributeForGameObjectType(iterAuction->second->GetItem().GetCategory());
|
||||
@@ -590,7 +590,7 @@ void AuctionMarketNamespace::processItemAttributeData(std::map<NetworkId, Auctio
|
||||
}
|
||||
|
||||
delete getItemAttributeDataRequest;
|
||||
getItemAttributeDataRequest = NULL;
|
||||
getItemAttributeDataRequest = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -862,7 +862,7 @@ void AuctionMarket::RemoveAuctionLocationFromPriorityQueue(const AuctionLocation
|
||||
|
||||
void AuctionMarket::AddAuction(Auction *auction)
|
||||
{
|
||||
assert(auction != NULL);
|
||||
assert(auction != nullptr);
|
||||
|
||||
AuctionLocation &location = auction->GetLocation();
|
||||
if (!location.IsOwner(auction->GetItem().GetOwnerId()))
|
||||
@@ -1979,7 +1979,7 @@ void AuctionMarket::AcceptHighBid(const AcceptHighBidMessage &message)
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server AcceptHighBidMessage] : ResponseId : %d.\n", message.GetResponseId()));
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server AcceptHighBidMessage] : TrackId : %d.\n", message.GetTrackId()));
|
||||
|
||||
Auction *auction = NULL;
|
||||
Auction *auction = nullptr;
|
||||
AuctionResultCode result = ARC_Success;
|
||||
std::map<NetworkId, Auction *>::iterator iter = m_auctions.find(
|
||||
message.GetAuctionId());
|
||||
@@ -1994,7 +1994,7 @@ void AuctionMarket::AcceptHighBid(const AcceptHighBidMessage &message)
|
||||
{
|
||||
result = ARC_NotItemOwner;
|
||||
}
|
||||
else if (auction->GetHighBid() == NULL)
|
||||
else if (auction->GetHighBid() == nullptr)
|
||||
{
|
||||
result = ARC_NoBids;
|
||||
}
|
||||
@@ -2525,19 +2525,19 @@ void AuctionMarket::QueryAuctionHeaders(
|
||||
int debugNumberLocationsMatched = 0;
|
||||
int debugNumberAuctionsTested = 0;
|
||||
|
||||
std::map<NetworkId, Auction *> *auctionsPtr = NULL;
|
||||
std::map<NetworkId, Auction *> *auctionsPtr = nullptr;
|
||||
int entranceCharge = 0;
|
||||
AuctionLocation *locationPtr = NULL;
|
||||
Auction *auctionPtr = NULL;
|
||||
AuctionLocation *locationPtr = nullptr;
|
||||
Auction *auctionPtr = nullptr;
|
||||
std::map<NetworkId, Auction *>::const_iterator auctionIterator;
|
||||
AuctionDataHeader *header = NULL;
|
||||
AuctionDataHeader *header = nullptr;
|
||||
bool checkItemTemplate;
|
||||
while (locationIter != locationIterEnd)
|
||||
{
|
||||
++debugNumberLocationsTested;
|
||||
|
||||
checkItemTemplate = false;
|
||||
auctionsPtr = NULL;
|
||||
auctionsPtr = nullptr;
|
||||
entranceCharge = 0;
|
||||
locationPtr = (*locationIter).second;
|
||||
|
||||
@@ -2606,7 +2606,7 @@ void AuctionMarket::QueryAuctionHeaders(
|
||||
|
||||
auctionPtr = (*auctionIterator).second;
|
||||
const AuctionItem &item = auctionPtr->GetItem();
|
||||
header = NULL;
|
||||
header = nullptr;
|
||||
|
||||
// Check to see if the item template matches
|
||||
if (searchForResourceContainer && (itemTemplateId != 0))
|
||||
@@ -4977,7 +4977,7 @@ void AuctionMarket::getAuctionLocationPriorityQueue(int requestingGameServerId,
|
||||
{
|
||||
std::string output;
|
||||
char buffer[2048];
|
||||
int const timeNow = static_cast<int>(::time(NULL));
|
||||
int const timeNow = static_cast<int>(::time(nullptr));
|
||||
for (std::set<std::pair<int, NetworkId> >::const_iterator iterPQ = m_priorityQueueAuctionLocation.begin(); iterPQ != m_priorityQueueAuctionLocation.end(); ++iterPQ)
|
||||
{
|
||||
if (count <= 0)
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
#include "sharedLog/Log.h"
|
||||
#include "sharedLog/SetupSharedLog.h"
|
||||
|
||||
#include "sharedFoundation/CrcConstexpr.hpp"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@@ -68,7 +71,9 @@ CommodityServer::~CommodityServer()
|
||||
|
||||
void CommodityServer::receiveMessage(const MessageDispatch::Emitter & source, const MessageDispatch::MessageBase & message)
|
||||
{
|
||||
if(message.isType("CommoditiesLoadDone"))
|
||||
const uint32 messageType = message.getType();
|
||||
|
||||
if(messageType == constcrc("CommoditiesLoadDone"))
|
||||
{
|
||||
m_commoditiesServerLoadDone = 1;
|
||||
|
||||
@@ -76,7 +81,7 @@ void CommodityServer::receiveMessage(const MessageDispatch::Emitter & source, co
|
||||
if (m_commoditiesServerLoadTime == -1)
|
||||
m_commoditiesServerLoadTime = (time(0) - m_timeCommoditiesServerStarted) / 60;
|
||||
}
|
||||
else if (message.isType("DatabaseServerConnectionClosed"))
|
||||
else if (messageType == constcrc("DatabaseServerConnectionClosed"))
|
||||
{
|
||||
WARNING(true, ("[Commodities Server] : No connection to the database server. Shutting down.\n"));
|
||||
exit(0);
|
||||
@@ -191,7 +196,7 @@ void CommodityServer::run()
|
||||
s_commodityServerMetricsData = new CommodityServerMetricsData;
|
||||
MetricsManager::install(s_commodityServerMetricsData, false, "CommoditiesServer", "", 0);
|
||||
|
||||
time_t timePrevious = ::time(NULL);
|
||||
time_t timePrevious = ::time(nullptr);
|
||||
time_t timeCurrent = timePrevious;
|
||||
|
||||
while (true)
|
||||
@@ -202,7 +207,7 @@ void CommodityServer::run()
|
||||
break;
|
||||
NetworkHandler::update();
|
||||
|
||||
timeCurrent = ::time(NULL);
|
||||
timeCurrent = ::time(nullptr);
|
||||
MetricsManager::update(static_cast<float>((timeCurrent - timePrevious) * 1000));
|
||||
timePrevious = timeCurrent;
|
||||
|
||||
@@ -229,18 +234,18 @@ void CommodityServer::run()
|
||||
// this is not a high priority thing, so wait until
|
||||
// the cluster has started and "stabilized" before
|
||||
// doing this; 3 hours should be adequate
|
||||
time_t timeToRequestExcludedType = ::time(NULL) + 10800;
|
||||
time_t timeToRequestExcludedType = ::time(nullptr) + 10800;
|
||||
|
||||
// one time request from the game server (any game server)
|
||||
// to receive the resource tree hierarchy to support
|
||||
// searching for resource container
|
||||
time_t timeToRequestResourceTree = ::time(NULL);
|
||||
time_t timeToRequestResourceTree = ::time(nullptr);
|
||||
|
||||
while(true)
|
||||
{
|
||||
NetworkHandler::update();
|
||||
|
||||
timeCurrent = ::time(NULL);
|
||||
timeCurrent = ::time(nullptr);
|
||||
MetricsManager::update(static_cast<float>((timeCurrent - timePrevious) * 1000));
|
||||
timePrevious = timeCurrent;
|
||||
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ void CommodityServerMetricsData::updateData()
|
||||
buffer[sizeof(buffer)-1] = '\0';
|
||||
}
|
||||
|
||||
m_mapAuctionsCountByGameObjectTypeIndex[iterGameObjectType->first] = addMetric(buffer, 0, NULL, false, false);
|
||||
m_mapAuctionsCountByGameObjectTypeIndex[iterGameObjectType->first] = addMetric(buffer, 0, nullptr, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+138
-126
@@ -21,6 +21,8 @@
|
||||
#include "serverNetworkMessages/GetMarketAuctionBidsMessage.h"
|
||||
#include "UnicodeUtils.h"
|
||||
|
||||
#include "sharedFoundation/CrcConstexpr.hpp"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
DatabaseServerConnection::DatabaseServerConnection(const std::string & a, const unsigned short p) :
|
||||
@@ -65,151 +67,161 @@ void DatabaseServerConnection::onReceive(const Archive::ByteStream & message)
|
||||
Archive::ReadIterator ri = message.begin();
|
||||
GameNetworkMessage msg(ri);
|
||||
ri = message.begin();
|
||||
|
||||
const uint32 messageType = msg.getType();
|
||||
|
||||
if (msg.isType("CommoditiesLoadDone"))
|
||||
{
|
||||
if (currentLocationCount != lastLocationCount)
|
||||
switch(messageType) {
|
||||
case constcrc("CommoditiesLoadDone") :
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d AuctionLocations record received\n", currentLocationCount));
|
||||
LOG("CommoditiesServer", ("%d AuctionLocations record received\n", currentLocationCount));
|
||||
lastLocationCount = currentLocationCount;
|
||||
}
|
||||
if (currentAuctionCount != lastAuctionCount)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d MarketAuctions record received\n", currentAuctionCount));
|
||||
LOG("CommoditiesServer", ("%d MarketAuctions record received\n", currentAuctionCount));
|
||||
lastAuctionCount = currentAuctionCount;
|
||||
}
|
||||
if (currentAuctionAttributeCount != lastAuctionAttributeCount)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d MarketAuctionAttributes record received\n", currentAuctionAttributeCount));
|
||||
LOG("CommoditiesServer", ("%d MarketAuctionAttributes record received\n", currentAuctionAttributeCount));
|
||||
lastAuctionAttributeCount = currentAuctionAttributeCount;
|
||||
}
|
||||
if (currentBidCount != lastBidCount)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d MarketAuctionBids record received\n", currentBidCount));
|
||||
LOG("CommoditiesServer", ("%d MarketAuctionBids record received", currentBidCount));
|
||||
lastBidCount = currentBidCount;
|
||||
}
|
||||
REPORT_LOG("DatabaseServerConnection", ("CommoditiesLoadDone Message received on connection with the database server\n"));
|
||||
CommoditiesLoadDoneMessage m(ri);
|
||||
REPORT_LOG("DatabaseServerConnection", ("%d rows received on Auction_Locations\n", m.getAuctionLocationsCount()));
|
||||
REPORT_LOG("DatabaseServerConnection", ("%d rows received on Market_Auctions\n", m.getMarketAuctionsCount()));
|
||||
REPORT_LOG("DatabaseServerConnection", ("%d rows received on Market_Auction_Attributes\n", m.getMarketAuctionAttributesCount()));
|
||||
REPORT_LOG("DatabaseServerConnection", ("%d rows received on Market_Auction_Bids\n", m.getMarketAuctionBidsCount()));
|
||||
LOG("CommoditiesServer", ("CommoditiesLoadDone Message received, %d rows Auction_Locations, %d rows Market_Auctions, %d rows Market_Auction_Attributes, %d rows Market_Auction_Bids", m.getAuctionLocationsCount(), m.getMarketAuctionsCount(), m.getMarketAuctionAttributesCount(), m.getMarketAuctionBidsCount()));
|
||||
|
||||
LOG("CommoditiesServer", ("Start build index for attribute search"));
|
||||
AuctionMarket::getInstance().BuildAuctionsSearchableAttributeList();
|
||||
LOG("CommoditiesServer", ("End build index for attribute search"));
|
||||
|
||||
emitMessage(m);
|
||||
}
|
||||
else if (msg.isType("GetAuctionLocationsMessage"))
|
||||
{
|
||||
GetAuctionLocationsMessage m(ri);
|
||||
const std::list<GetAuctionLocationsMessage::AuctionLocation> & auctionLocations = m.getAuctionLocations();
|
||||
for (std::list<GetAuctionLocationsMessage::AuctionLocation>::const_iterator iter = auctionLocations.begin(); iter != auctionLocations.end(); ++iter)
|
||||
{
|
||||
AuctionMarket::getInstance().onReceiveAuctionLocations(iter->locationId, iter->locationName, iter->ownerId, iter->salesTax, iter->salesTaxBankId, iter->emptyDate, iter->lastAccessDate, iter->inactiveDate, iter->status, iter->searchEnabled, iter->entranceCharge);
|
||||
currentLocationCount++;
|
||||
if (currentLocationCount - lastLocationCount >= 1000)
|
||||
if (currentLocationCount != lastLocationCount)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d AuctionLocations record received\n", currentLocationCount));
|
||||
LOG("CommoditiesServer", ("%d AuctionLocations record received", currentLocationCount));
|
||||
LOG("CommoditiesServer", ("%d AuctionLocations record received\n", currentLocationCount));
|
||||
lastLocationCount = currentLocationCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (msg.isType("GetMarketAuctionsMessage"))
|
||||
{
|
||||
if (currentLocationCount != lastLocationCount)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d AuctionLocations record received\n", currentLocationCount));
|
||||
LOG("CommoditiesServer", ("%d AuctionLocations record received\n", currentLocationCount));
|
||||
lastLocationCount = currentLocationCount;
|
||||
}
|
||||
GetMarketAuctionsMessage m(ri);
|
||||
const std::list<GetMarketAuctionsMessage::MarketAuction> & auctions = m.getAuctions();
|
||||
for (std::list<GetMarketAuctionsMessage::MarketAuction>::const_iterator iter = auctions.begin(); iter != auctions.end(); ++iter)
|
||||
{
|
||||
AuctionMarket::getInstance().onReceiveMarketAuctions(iter->itemId, iter->ownerId, iter->creatorId, iter->locationId, iter->minBid, iter->buyNowPrice, iter->auctionTimer, iter->oob, iter->userDescription, iter->category, iter->itemTemplateId, iter->itemName, iter->itemTimer, iter->active, iter->itemSize);
|
||||
currentAuctionCount++;
|
||||
if (currentAuctionCount - lastAuctionCount >= 10000)
|
||||
if (currentAuctionCount != lastAuctionCount)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d MarketAuctions record received\n", currentAuctionCount));
|
||||
LOG("CommoditiesServer", ("%d MarketAuctions record received", currentAuctionCount));
|
||||
LOG("CommoditiesServer", ("%d MarketAuctions record received\n", currentAuctionCount));
|
||||
lastAuctionCount = currentAuctionCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (msg.isType("GetMarketAuctionAttributesMessage"))
|
||||
{
|
||||
if (currentLocationCount != lastLocationCount)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d AuctionLocations record received\n", currentLocationCount));
|
||||
LOG("CommoditiesServer", ("%d AuctionLocations record received\n", currentLocationCount));
|
||||
lastLocationCount = currentLocationCount;
|
||||
}
|
||||
if (currentAuctionCount != lastAuctionCount)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d MarketAuctions record received\n", currentAuctionCount));
|
||||
LOG("CommoditiesServer", ("%d MarketAuctions record received\n", currentAuctionCount));
|
||||
lastAuctionCount = currentAuctionCount;
|
||||
}
|
||||
GetMarketAuctionAttributesMessage m(ri);
|
||||
const std::list<GetMarketAuctionAttributesMessage::MarketAuctionAttribute> & attributes = m.getAttributes();
|
||||
for (std::list<GetMarketAuctionAttributesMessage::MarketAuctionAttribute>::const_iterator iter = attributes.begin(); iter != attributes.end(); ++iter)
|
||||
{
|
||||
AuctionMarket::getInstance().onReceiveMarketAuctionAttributes(iter->itemId, iter->attributeName, iter->attributeValue);
|
||||
currentAuctionAttributeCount++;
|
||||
if (currentAuctionAttributeCount - lastAuctionAttributeCount >= 10000)
|
||||
if (currentAuctionAttributeCount != lastAuctionAttributeCount)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d MarketAuctionAttributes record received\n", currentAuctionAttributeCount));
|
||||
LOG("CommoditiesServer", ("%d MarketAuctionAttributes record received", currentAuctionAttributeCount));
|
||||
LOG("CommoditiesServer", ("%d MarketAuctionAttributes record received\n", currentAuctionAttributeCount));
|
||||
lastAuctionAttributeCount = currentAuctionAttributeCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (msg.isType("GetMarketAuctionBidsMessage"))
|
||||
{
|
||||
if (currentLocationCount != lastLocationCount)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d AuctionLocations record received\n", currentLocationCount));
|
||||
LOG("CommoditiesServer", ("%d AuctionLocations record received\n", currentLocationCount));
|
||||
lastLocationCount = currentLocationCount;
|
||||
}
|
||||
if (currentAuctionCount != lastAuctionCount)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d MarketAuctions record received\n", currentAuctionCount));
|
||||
LOG("CommoditiesServer", ("%d MarketAuctions record received\n", currentAuctionCount));
|
||||
lastAuctionCount = currentAuctionCount;
|
||||
}
|
||||
if (currentAuctionAttributeCount != lastAuctionAttributeCount)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d MarketAuctionAttributes record received\n", currentAuctionAttributeCount));
|
||||
LOG("CommoditiesServer", ("%d MarketAuctionAttributes record received\n", currentAuctionAttributeCount));
|
||||
lastAuctionAttributeCount = currentAuctionAttributeCount;
|
||||
}
|
||||
GetMarketAuctionBidsMessage m(ri);
|
||||
const std::list<GetMarketAuctionBidsMessage::MarketAuctionBid> & bids = m.getMarketAuctionBids();
|
||||
for (std::list<GetMarketAuctionBidsMessage::MarketAuctionBid>::const_iterator iter = bids.begin(); iter != bids.end(); ++iter)
|
||||
{
|
||||
AuctionMarket::getInstance().onReceiveMarketAuctionBids(iter->itemId, iter->bidderId, iter->bid, iter->maxProxyBid);
|
||||
currentBidCount++;
|
||||
if (currentBidCount - lastBidCount >= 1000)
|
||||
if (currentBidCount != lastBidCount)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d MarketAuctionBids record received\n", currentBidCount));
|
||||
LOG("CommoditiesServer", ("%d MarketAuctionBids record received\n", currentBidCount));
|
||||
LOG("CommoditiesServer", ("%d MarketAuctionBids record received", currentBidCount));
|
||||
lastBidCount = currentBidCount;
|
||||
}
|
||||
REPORT_LOG("DatabaseServerConnection", ("CommoditiesLoadDone Message received on connection with the database server\n"));
|
||||
CommoditiesLoadDoneMessage m(ri);
|
||||
REPORT_LOG("DatabaseServerConnection", ("%d rows received on Auction_Locations\n", m.getAuctionLocationsCount()));
|
||||
REPORT_LOG("DatabaseServerConnection", ("%d rows received on Market_Auctions\n", m.getMarketAuctionsCount()));
|
||||
REPORT_LOG("DatabaseServerConnection", ("%d rows received on Market_Auction_Attributes\n", m.getMarketAuctionAttributesCount()));
|
||||
REPORT_LOG("DatabaseServerConnection", ("%d rows received on Market_Auction_Bids\n", m.getMarketAuctionBidsCount()));
|
||||
LOG("CommoditiesServer", ("CommoditiesLoadDone Message received, %d rows Auction_Locations, %d rows Market_Auctions, %d rows Market_Auction_Attributes, %d rows Market_Auction_Bids", m.getAuctionLocationsCount(), m.getMarketAuctionsCount(), m.getMarketAuctionAttributesCount(), m.getMarketAuctionBidsCount()));
|
||||
|
||||
LOG("CommoditiesServer", ("Start build index for attribute search"));
|
||||
AuctionMarket::getInstance().BuildAuctionsSearchableAttributeList();
|
||||
LOG("CommoditiesServer", ("End build index for attribute search"));
|
||||
|
||||
emitMessage(m);
|
||||
break;
|
||||
}
|
||||
case constcrc("GetAuctionLocationsMessage") :
|
||||
{
|
||||
GetAuctionLocationsMessage m(ri);
|
||||
const std::list<GetAuctionLocationsMessage::AuctionLocation> & auctionLocations = m.getAuctionLocations();
|
||||
for (std::list<GetAuctionLocationsMessage::AuctionLocation>::const_iterator iter = auctionLocations.begin(); iter != auctionLocations.end(); ++iter)
|
||||
{
|
||||
AuctionMarket::getInstance().onReceiveAuctionLocations(iter->locationId, iter->locationName, iter->ownerId, iter->salesTax, iter->salesTaxBankId, iter->emptyDate, iter->lastAccessDate, iter->inactiveDate, iter->status, iter->searchEnabled, iter->entranceCharge);
|
||||
currentLocationCount++;
|
||||
if (currentLocationCount - lastLocationCount >= 1000)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d AuctionLocations record received\n", currentLocationCount));
|
||||
LOG("CommoditiesServer", ("%d AuctionLocations record received", currentLocationCount));
|
||||
lastLocationCount = currentLocationCount;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case constcrc("GetMarketAuctionsMessage") :
|
||||
{
|
||||
if (currentLocationCount != lastLocationCount)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d AuctionLocations record received\n", currentLocationCount));
|
||||
LOG("CommoditiesServer", ("%d AuctionLocations record received\n", currentLocationCount));
|
||||
lastLocationCount = currentLocationCount;
|
||||
}
|
||||
GetMarketAuctionsMessage m(ri);
|
||||
const std::list<GetMarketAuctionsMessage::MarketAuction> & auctions = m.getAuctions();
|
||||
for (std::list<GetMarketAuctionsMessage::MarketAuction>::const_iterator iter = auctions.begin(); iter != auctions.end(); ++iter)
|
||||
{
|
||||
AuctionMarket::getInstance().onReceiveMarketAuctions(iter->itemId, iter->ownerId, iter->creatorId, iter->locationId, iter->minBid, iter->buyNowPrice, iter->auctionTimer, iter->oob, iter->userDescription, iter->category, iter->itemTemplateId, iter->itemName, iter->itemTimer, iter->active, iter->itemSize);
|
||||
currentAuctionCount++;
|
||||
if (currentAuctionCount - lastAuctionCount >= 10000)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d MarketAuctions record received\n", currentAuctionCount));
|
||||
LOG("CommoditiesServer", ("%d MarketAuctions record received", currentAuctionCount));
|
||||
lastAuctionCount = currentAuctionCount;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case constcrc("GetMarketAuctionAttributesMessage") :
|
||||
{
|
||||
if (currentLocationCount != lastLocationCount)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d AuctionLocations record received\n", currentLocationCount));
|
||||
LOG("CommoditiesServer", ("%d AuctionLocations record received\n", currentLocationCount));
|
||||
lastLocationCount = currentLocationCount;
|
||||
}
|
||||
if (currentAuctionCount != lastAuctionCount)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d MarketAuctions record received\n", currentAuctionCount));
|
||||
LOG("CommoditiesServer", ("%d MarketAuctions record received\n", currentAuctionCount));
|
||||
lastAuctionCount = currentAuctionCount;
|
||||
}
|
||||
GetMarketAuctionAttributesMessage m(ri);
|
||||
const std::list<GetMarketAuctionAttributesMessage::MarketAuctionAttribute> & attributes = m.getAttributes();
|
||||
for (std::list<GetMarketAuctionAttributesMessage::MarketAuctionAttribute>::const_iterator iter = attributes.begin(); iter != attributes.end(); ++iter)
|
||||
{
|
||||
AuctionMarket::getInstance().onReceiveMarketAuctionAttributes(iter->itemId, iter->attributeName, iter->attributeValue);
|
||||
currentAuctionAttributeCount++;
|
||||
if (currentAuctionAttributeCount - lastAuctionAttributeCount >= 10000)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d MarketAuctionAttributes record received\n", currentAuctionAttributeCount));
|
||||
LOG("CommoditiesServer", ("%d MarketAuctionAttributes record received", currentAuctionAttributeCount));
|
||||
lastAuctionAttributeCount = currentAuctionAttributeCount;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case constcrc("GetMarketAuctionBidsMessage") :
|
||||
{
|
||||
if (currentLocationCount != lastLocationCount)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d AuctionLocations record received\n", currentLocationCount));
|
||||
LOG("CommoditiesServer", ("%d AuctionLocations record received\n", currentLocationCount));
|
||||
lastLocationCount = currentLocationCount;
|
||||
}
|
||||
if (currentAuctionCount != lastAuctionCount)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d MarketAuctions record received\n", currentAuctionCount));
|
||||
LOG("CommoditiesServer", ("%d MarketAuctions record received\n", currentAuctionCount));
|
||||
lastAuctionCount = currentAuctionCount;
|
||||
}
|
||||
if (currentAuctionAttributeCount != lastAuctionAttributeCount)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d MarketAuctionAttributes record received\n", currentAuctionAttributeCount));
|
||||
LOG("CommoditiesServer", ("%d MarketAuctionAttributes record received\n", currentAuctionAttributeCount));
|
||||
lastAuctionAttributeCount = currentAuctionAttributeCount;
|
||||
}
|
||||
GetMarketAuctionBidsMessage m(ri);
|
||||
const std::list<GetMarketAuctionBidsMessage::MarketAuctionBid> & bids = m.getMarketAuctionBids();
|
||||
for (std::list<GetMarketAuctionBidsMessage::MarketAuctionBid>::const_iterator iter = bids.begin(); iter != bids.end(); ++iter)
|
||||
{
|
||||
AuctionMarket::getInstance().onReceiveMarketAuctionBids(iter->itemId, iter->bidderId, iter->bid, iter->maxProxyBid);
|
||||
currentBidCount++;
|
||||
if (currentBidCount - lastBidCount >= 1000)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d MarketAuctionBids record received\n", currentBidCount));
|
||||
LOG("CommoditiesServer", ("%d MarketAuctionBids record received\n", currentBidCount));
|
||||
lastBidCount = currentBidCount;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case constcrc("DeleteCharacterMessage") :
|
||||
{
|
||||
DeleteCharacterMessage message(ri);
|
||||
AuctionMarket::getInstance().DeleteCharacter(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(msg.isType("DeleteCharacterMessage"))
|
||||
{
|
||||
DeleteCharacterMessage message(ri);
|
||||
AuctionMarket::getInstance().DeleteCharacter(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
#include "serverNetworkMessages/QueryVendorItemCountMessage.h"
|
||||
#include "serverNetworkMessages/UpdateVendorStatusMessage.h"
|
||||
|
||||
#include "sharedFoundation/CrcConstexpr.hpp"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
namespace GameServerConnectionNamespace
|
||||
@@ -88,201 +90,235 @@ void GameServerConnection::onReceive(const Archive::ByteStream & message)
|
||||
Archive::ReadIterator ri = message.begin();
|
||||
GameNetworkMessage msg(ri);
|
||||
ri = message.begin();
|
||||
|
||||
const uint32 messageType = msg.getType();
|
||||
|
||||
if(msg.isType("AcceptHighBidMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message AcceptHighBidMessage from game server id: %d.\n", m_gameServerId ));
|
||||
AcceptHighBidMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().AcceptHighBid(message);
|
||||
}
|
||||
else if(msg.isType("AddAuctionMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message AddAuctionMessage from game server id: %d.\n", m_gameServerId ));
|
||||
AddAuctionMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().AddAuction(message);
|
||||
}
|
||||
else if(msg.isType("AddBidMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message AddBidMessage from game server id: %d.\n", m_gameServerId ));
|
||||
AddBidMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().AddBid(message);
|
||||
}
|
||||
else if(msg.isType("AddImmediateAuctionMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message AddImmediateAuctionMessage from game server id: %d.\n", m_gameServerId ));
|
||||
AddImmediateAuctionMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().AddImmediateAuction(message);
|
||||
}
|
||||
else if(msg.isType("CancelAuctionMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message CancelAuctionMessage from game server id: %d.\n", m_gameServerId ));
|
||||
CancelAuctionMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().CancelAuction(message);
|
||||
}
|
||||
else if(msg.isType("CreateVendorMarketMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message CreateVendorMarketMessage from game server id: %d.\n", m_gameServerId ));
|
||||
CreateVendorMarketMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().CreateVendorMarket(message);
|
||||
}
|
||||
else if(msg.isType("DestroyVendorMarketMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message DestroyVendorMarketMessage from game server id: %d.\n", m_gameServerId ));
|
||||
DestroyVendorMarketMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().DestroyVendorMarket(message);
|
||||
}
|
||||
else if(msg.isType("DeleteAuctionLocationMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message DeleteAuctionLocationMessage from game server id: %d.\n", m_gameServerId ));
|
||||
DeleteAuctionLocationMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().DeleteAuctionLocation(message);
|
||||
}
|
||||
else if(msg.isType("GetItemDetailsMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message GetItemDetailsMessage from game server id: %d.\n", m_gameServerId ));
|
||||
GetItemDetailsMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().GetItemDetails(message);
|
||||
}
|
||||
else if(msg.isType("GetItemMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message GetItemMessage from game server id: %d.\n", m_gameServerId ));
|
||||
GetItemMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().GetItem(message);
|
||||
}
|
||||
else if(msg.isType("SetSalesTaxMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message SetSalesTaxMessage from game server id: %d.\n", m_gameServerId ));
|
||||
SetSalesTaxMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().SetSalesTax(message);
|
||||
}
|
||||
else if(msg.isType("GetVendorOwnerMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message GetVendorOwnerMessage from game server id: %d.\n", m_gameServerId ));
|
||||
GetVendorOwnerMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().GetVendorOwner(message);
|
||||
}
|
||||
else if(msg.isType("GetVendorValueMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message GetVendorValueMessage from game server id: %d.\n", m_gameServerId ));
|
||||
GetVendorValueMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().GetVendorValue(message);
|
||||
}
|
||||
else if(msg.isType("QueryAuctionHeadersMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message QueryAuctionHeadersMessage from game server id: %d.\n", m_gameServerId ));
|
||||
QueryAuctionHeadersMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().QueryAuctionHeaders(message);
|
||||
}
|
||||
else if(msg.isType("SetGameTimeMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message SetGameTimeMessage from game server id: %d.\n", m_gameServerId ));
|
||||
SetGameTimeMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().SetGameTime(message);
|
||||
}
|
||||
else if(msg.isType("CleanupInvalidItemRetrievalMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message CleanupInvalidItemRetrievalMessage from game server id: %d.\n", m_gameServerId ));
|
||||
CleanupInvalidItemRetrievalMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().CleanupInvalidItemRetrieval(message);
|
||||
}
|
||||
else if(msg.isType("QueryVendorItemCountMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message QueryVendorItemCountMessage from game server id: %d.\n", m_gameServerId ));
|
||||
QueryVendorItemCountMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().QueryVendorItemCount(message);
|
||||
}
|
||||
else if(msg.isType("GetPlayerVendorCountMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message GetPlayerVendorCountMessage from game server id: %d.\n", m_gameServerId ));
|
||||
GetPlayerVendorCountMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().GetPlayerVendorCount(message);
|
||||
}
|
||||
else if(msg.isType("UpdateVendorSearchOptionMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message UpdateVendorSearchOptionMessage from game server id: %d.\n", m_gameServerId ));
|
||||
UpdateVendorSearchOptionMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().UpdateVendorSearchOption(message);
|
||||
}
|
||||
else if(msg.isType("SetEntranceChargeMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(/*m_showAllDebugInfo*/ true, ("[Commodities Server] : Received message SetEntranceChargeMessage from game server id: %d.\n", m_gameServerId ));
|
||||
SetEntranceChargeMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().SetEntranceCharge(message);
|
||||
}
|
||||
else if(msg.isType("ResponseCommoditiesExcludedGotTypes"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message ResponseCommoditiesExcludedGotTypes from game server id: %d.\n", m_gameServerId ));
|
||||
GenericValueTypeMessage<std::map<int, std::string> > message(ri);
|
||||
AuctionMarket::getInstance().VerifyExcludedGotTypes(message.getValue());
|
||||
}
|
||||
else if(msg.isType("ResponseCommoditiesExcludedResourceClasses"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message ResponseCommoditiesExcludedResourceClasses from game server id: %d.\n", m_gameServerId ));
|
||||
GenericValueTypeMessage<std::set<std::string> > message(ri);
|
||||
AuctionMarket::getInstance().VerifyExcludedResourceClasses(message.getValue());
|
||||
}
|
||||
else if(msg.isType("ResponseResourceTreeHierarchy"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message ResponseResourceTreeHierarchy from game server id: %d.\n", m_gameServerId ));
|
||||
GenericValueTypeMessage<std::map<int, std::set<int> > > message(ri);
|
||||
AuctionMarket::getInstance().SetResourceTreeHierarchy(message.getValue());
|
||||
}
|
||||
else if(msg.isType("UpdateVendorStatusMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message UpdateVendorStatusMessage from game server id: %d.\n", m_gameServerId));
|
||||
UpdateVendorStatusMessage message(ri);
|
||||
AuctionMarket::getInstance().UpdateVendorStatus(message);
|
||||
}
|
||||
else if(msg.isType("UpdateVendorLocationMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message UpdateVendorLocationMessage from game server id: %d.\n", m_gameServerId));
|
||||
GenericValueTypeMessage<std::pair<NetworkId, std::string> > const message(ri);
|
||||
AuctionMarket::getInstance().UpdateVendorLocation(message.getValue().first, message.getValue().second);
|
||||
}
|
||||
else if(msg.isType("GetItemAttributeData"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::pair<NetworkId, std::string>, std::pair<std::pair<int, bool>, std::pair<bool, int> > > > const message(ri);
|
||||
AuctionMarket::getInstance().getItemAttributeData(m_gameServerId, message.getValue().first.first, message.getValue().first.second, message.getValue().second.first.first, message.getValue().second.first.second, message.getValue().second.second.first, message.getValue().second.second.second);
|
||||
}
|
||||
else if(msg.isType("GetItemAttributeDataValues"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::pair<NetworkId, std::pair<int, bool> >, std::pair<std::string, int> > > const message(ri);
|
||||
AuctionMarket::getInstance().getItemAttributeDataValues(m_gameServerId, message.getValue().first.first, message.getValue().first.second.first, message.getValue().first.second.second, message.getValue().second.first, message.getValue().second.second);
|
||||
}
|
||||
else if(msg.isType("GetItemAttribute"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<NetworkId, NetworkId> > const message(ri);
|
||||
AuctionMarket::getInstance().getItemAttribute(m_gameServerId, message.getValue().first, message.getValue().second);
|
||||
}
|
||||
else if(msg.isType("GetVendorInfoForPlayer"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::pair<NetworkId, NetworkId>, bool> > const message(ri);
|
||||
AuctionMarket::getInstance().getVendorInfoForPlayer(m_gameServerId, message.getValue().first.first, message.getValue().first.second, message.getValue().second);
|
||||
}
|
||||
else if(msg.isType("GetALPQ"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<NetworkId, int> > const message(ri);
|
||||
AuctionMarket::getInstance().getAuctionLocationPriorityQueue(m_gameServerId, message.getValue().first, message.getValue().second);
|
||||
switch(messageType) {
|
||||
case constcrc("AcceptHighBidMessage") :
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message AcceptHighBidMessage from game server id: %d.\n", m_gameServerId ));
|
||||
AcceptHighBidMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().AcceptHighBid(message);
|
||||
break;
|
||||
}
|
||||
case constcrc("AddAuctionMessage") :
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message AddAuctionMessage from game server id: %d.\n", m_gameServerId ));
|
||||
AddAuctionMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().AddAuction(message);
|
||||
break;
|
||||
}
|
||||
case constcrc("AddBidMessage") :
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message AddBidMessage from game server id: %d.\n", m_gameServerId ));
|
||||
AddBidMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().AddBid(message);
|
||||
break;
|
||||
}
|
||||
case constcrc("AddImmediateAuctionMessage") :
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message AddImmediateAuctionMessage from game server id: %d.\n", m_gameServerId ));
|
||||
AddImmediateAuctionMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().AddImmediateAuction(message);
|
||||
break;
|
||||
}
|
||||
case constcrc("CancelAuctionMessage") :
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message CancelAuctionMessage from game server id: %d.\n", m_gameServerId ));
|
||||
CancelAuctionMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().CancelAuction(message);
|
||||
break;
|
||||
}
|
||||
case constcrc("CreateVendorMarketMessage") :
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message CreateVendorMarketMessage from game server id: %d.\n", m_gameServerId ));
|
||||
CreateVendorMarketMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().CreateVendorMarket(message);
|
||||
break;
|
||||
}
|
||||
case constcrc("DestroyVendorMarketMessage") :
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message DestroyVendorMarketMessage from game server id: %d.\n", m_gameServerId ));
|
||||
DestroyVendorMarketMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().DestroyVendorMarket(message);
|
||||
break;
|
||||
}
|
||||
case constcrc("DeleteAuctionLocationMessage") :
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message DeleteAuctionLocationMessage from game server id: %d.\n", m_gameServerId ));
|
||||
DeleteAuctionLocationMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().DeleteAuctionLocation(message);
|
||||
break;
|
||||
}
|
||||
case constcrc("GetItemDetailsMessage") :
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message GetItemDetailsMessage from game server id: %d.\n", m_gameServerId ));
|
||||
GetItemDetailsMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().GetItemDetails(message);
|
||||
break;
|
||||
}
|
||||
case constcrc("GetItemMessage") :
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message GetItemMessage from game server id: %d.\n", m_gameServerId ));
|
||||
GetItemMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().GetItem(message);
|
||||
break;
|
||||
}
|
||||
case constcrc("SetSalesTaxMessage") :
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message SetSalesTaxMessage from game server id: %d.\n", m_gameServerId ));
|
||||
SetSalesTaxMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().SetSalesTax(message);
|
||||
break;
|
||||
}
|
||||
case constcrc("GetVendorOwnerMessage") :
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message GetVendorOwnerMessage from game server id: %d.\n", m_gameServerId ));
|
||||
GetVendorOwnerMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().GetVendorOwner(message);
|
||||
break;
|
||||
}
|
||||
case constcrc("GetVendorValueMessage") :
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message GetVendorValueMessage from game server id: %d.\n", m_gameServerId ));
|
||||
GetVendorValueMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().GetVendorValue(message);
|
||||
break;
|
||||
}
|
||||
case constcrc("QueryAuctionHeadersMessage") :
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message QueryAuctionHeadersMessage from game server id: %d.\n", m_gameServerId ));
|
||||
QueryAuctionHeadersMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().QueryAuctionHeaders(message);
|
||||
break;
|
||||
}
|
||||
case constcrc("SetGameTimeMessage") :
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message SetGameTimeMessage from game server id: %d.\n", m_gameServerId ));
|
||||
SetGameTimeMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().SetGameTime(message);
|
||||
break;
|
||||
}
|
||||
case constcrc("CleanupInvalidItemRetrievalMessage") :
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message CleanupInvalidItemRetrievalMessage from game server id: %d.\n", m_gameServerId ));
|
||||
CleanupInvalidItemRetrievalMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().CleanupInvalidItemRetrieval(message);
|
||||
break;
|
||||
}
|
||||
case constcrc("QueryVendorItemCountMessage") :
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message QueryVendorItemCountMessage from game server id: %d.\n", m_gameServerId ));
|
||||
QueryVendorItemCountMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().QueryVendorItemCount(message);
|
||||
break;
|
||||
}
|
||||
case constcrc("GetPlayerVendorCountMessage") :
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message GetPlayerVendorCountMessage from game server id: %d.\n", m_gameServerId ));
|
||||
GetPlayerVendorCountMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().GetPlayerVendorCount(message);
|
||||
break;
|
||||
}
|
||||
case constcrc("UpdateVendorSearchOptionMessage") :
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message UpdateVendorSearchOptionMessage from game server id: %d.\n", m_gameServerId ));
|
||||
UpdateVendorSearchOptionMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().UpdateVendorSearchOption(message);
|
||||
break;
|
||||
}
|
||||
case constcrc("SetEntranceChargeMessage") :
|
||||
{
|
||||
DEBUG_REPORT_LOG(/*m_showAllDebugInfo*/ true, ("[Commodities Server] : Received message SetEntranceChargeMessage from game server id: %d.\n", m_gameServerId ));
|
||||
SetEntranceChargeMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().SetEntranceCharge(message);
|
||||
break;
|
||||
}
|
||||
case constcrc("ResponseCommoditiesExcludedGotTypes") :
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message ResponseCommoditiesExcludedGotTypes from game server id: %d.\n", m_gameServerId ));
|
||||
GenericValueTypeMessage<std::map<int, std::string> > message(ri);
|
||||
AuctionMarket::getInstance().VerifyExcludedGotTypes(message.getValue());
|
||||
break;
|
||||
}
|
||||
case constcrc("ResponseCommoditiesExcludedResourceClasses") :
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message ResponseCommoditiesExcludedResourceClasses from game server id: %d.\n", m_gameServerId ));
|
||||
GenericValueTypeMessage<std::set<std::string> > message(ri);
|
||||
AuctionMarket::getInstance().VerifyExcludedResourceClasses(message.getValue());
|
||||
break;
|
||||
}
|
||||
case constcrc("ResponseResourceTreeHierarchy") :
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message ResponseResourceTreeHierarchy from game server id: %d.\n", m_gameServerId ));
|
||||
GenericValueTypeMessage<std::map<int, std::set<int> > > message(ri);
|
||||
AuctionMarket::getInstance().SetResourceTreeHierarchy(message.getValue());
|
||||
break;
|
||||
}
|
||||
case constcrc("UpdateVendorStatusMessage") :
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message UpdateVendorStatusMessage from game server id: %d.\n", m_gameServerId));
|
||||
UpdateVendorStatusMessage message(ri);
|
||||
AuctionMarket::getInstance().UpdateVendorStatus(message);
|
||||
break;
|
||||
}
|
||||
case constcrc("UpdateVendorLocationMessage") :
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message UpdateVendorLocationMessage from game server id: %d.\n", m_gameServerId));
|
||||
GenericValueTypeMessage<std::pair<NetworkId, std::string> > const message(ri);
|
||||
AuctionMarket::getInstance().UpdateVendorLocation(message.getValue().first, message.getValue().second);
|
||||
break;
|
||||
}
|
||||
case constcrc("GetItemAttributeData") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::pair<NetworkId, std::string>, std::pair<std::pair<int, bool>, std::pair<bool, int> > > > const message(ri);
|
||||
AuctionMarket::getInstance().getItemAttributeData(m_gameServerId, message.getValue().first.first, message.getValue().first.second, message.getValue().second.first.first, message.getValue().second.first.second, message.getValue().second.second.first, message.getValue().second.second.second);
|
||||
break;
|
||||
}
|
||||
case constcrc("GetItemAttributeDataValues") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::pair<NetworkId, std::pair<int, bool> >, std::pair<std::string, int> > > const message(ri);
|
||||
AuctionMarket::getInstance().getItemAttributeDataValues(m_gameServerId, message.getValue().first.first, message.getValue().first.second.first, message.getValue().first.second.second, message.getValue().second.first, message.getValue().second.second);
|
||||
break;
|
||||
}
|
||||
case constcrc("GetItemAttribute") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<NetworkId, NetworkId> > const message(ri);
|
||||
AuctionMarket::getInstance().getItemAttribute(m_gameServerId, message.getValue().first, message.getValue().second);
|
||||
break;
|
||||
}
|
||||
case constcrc("GetVendorInfoForPlayer") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::pair<NetworkId, NetworkId>, bool> > const message(ri);
|
||||
AuctionMarket::getInstance().getVendorInfoForPlayer(m_gameServerId, message.getValue().first.first, message.getValue().first.second, message.getValue().second);
|
||||
break;
|
||||
}
|
||||
case constcrc("GetALPQ") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<NetworkId, int> > const message(ri);
|
||||
AuctionMarket::getInstance().getAuctionLocationPriorityQueue(m_gameServerId, message.getValue().first, message.getValue().second);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
#include "FirstCommodityServer.h"
|
||||
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
#include "sharedCompression/SetupSharedCompression.h"
|
||||
#include "sharedDebug/SetupSharedDebug.h"
|
||||
#include "sharedFile/TreeFile.h"
|
||||
#include "sharedFile/SetupSharedFile.h"
|
||||
#include "sharedFoundation/ConfigFile.h"
|
||||
#include "sharedFoundation/ExitChain.h"
|
||||
#include "sharedFoundation/Os.h"
|
||||
#include "sharedFoundation/SetupSharedFoundation.h"
|
||||
#include "sharedGame/CommoditiesAdvancedSearchAttribute.h"
|
||||
#include "sharedGame/ConfigSharedGame.h"
|
||||
#include "sharedNetwork/SetupSharedNetwork.h"
|
||||
#include "sharedNetwork/NetworkHandler.h"
|
||||
#include "sharedNetworkMessages/SetupSharedNetworkMessages.h"
|
||||
#include "sharedThread/SetupSharedThread.h"
|
||||
#include "sharedUtility/DataTableManager.h"
|
||||
#include "CommodityServer.h"
|
||||
#include "ConfigCommodityServer.h"
|
||||
#include "LocalizationManager.h"
|
||||
#include "UnicodeUtils.h"
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
SetupSharedThread::install();
|
||||
SetupSharedDebug::install(1024);
|
||||
|
||||
//-- setup foundation
|
||||
SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game);
|
||||
|
||||
setupFoundationData.argc = argc;
|
||||
setupFoundationData.argv = argv;
|
||||
setupFoundationData.createWindow = false;
|
||||
setupFoundationData.clockUsesSleep = true;
|
||||
SetupSharedFoundation::install (setupFoundationData);
|
||||
|
||||
ConfigSharedGame::install();
|
||||
SetupSharedCompression::install();
|
||||
SetupSharedFile::install(false);
|
||||
SetupSharedNetworkMessages::install();
|
||||
|
||||
SetupSharedNetwork::SetupData networkSetupData;
|
||||
SetupSharedNetwork::getDefaultServerSetupData(networkSetupData);
|
||||
SetupSharedNetwork::install(networkSetupData);
|
||||
NetworkHandler::install();
|
||||
|
||||
ConfigCommodityServer::install();
|
||||
|
||||
const bool displayBadStringIds = ConfigSharedGame::getDisplayBadStringIds ();
|
||||
const bool debugStringIds = ConfigSharedGame::getDebugStringIds ();
|
||||
Unicode::NarrowString defaultLocale(ConfigSharedGame::getDefaultLocale ());
|
||||
Unicode::UnicodeNarrowStringVector localeVector;
|
||||
localeVector.push_back(defaultLocale);
|
||||
|
||||
LocalizationManager::install (new TreeFile::TreeFileFactory, localeVector, debugStringIds, NULL, displayBadStringIds);
|
||||
ExitChain::add(LocalizationManager::remove, "LocalizationManager::remove");
|
||||
|
||||
DataTableManager::install();
|
||||
CommoditiesAdvancedSearchAttribute::install();
|
||||
|
||||
//-- run server
|
||||
SetupSharedFoundation::callbackWithExceptionHandling(CommodityServer::run);
|
||||
|
||||
SetupSharedFoundation::remove();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@@ -37,7 +37,7 @@ int main(int argc, char ** argv)
|
||||
|
||||
SetupSharedFile::install(false);
|
||||
SetupSharedNetworkMessages::install();
|
||||
SetupSharedRandom::install(time(NULL));
|
||||
SetupSharedRandom::install(time(nullptr));
|
||||
|
||||
//setup the server
|
||||
NetworkHandler::install();
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
// CentralConnection.cpp
|
||||
// copyright 2001 Verant Interactive
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "FirstConnectionServer.h"
|
||||
#include "CentralConnection.h"
|
||||
|
||||
@@ -19,6 +14,8 @@
|
||||
#include "sharedNetworkMessages/ErrorMessage.h"
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
|
||||
#include "sharedFoundation/CrcConstexpr.hpp"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
CentralConnection::CentralConnection(const std::string & address, const unsigned short port) :
|
||||
@@ -67,68 +64,79 @@ void CentralConnection::onReceive(const Archive::ByteStream & message)
|
||||
Archive::ReadIterator ri = message.begin();
|
||||
const GameNetworkMessage msg(ri);
|
||||
ri = message.begin();
|
||||
|
||||
if(msg.isType("TransferLoginCharacterToSourceServer"))
|
||||
|
||||
switch(msg.getType())
|
||||
{
|
||||
GenericValueTypeMessage<TransferCharacterData> login(ri);
|
||||
// received a request to create a pseudoclient and connect it
|
||||
// to a game server.
|
||||
LOG("CustomerService", ("CharacterTransfer: ***ConnectionServer: Received TransferLoginCharacterToSourceServer request from CentralServer for %s\n", login.getValue().toString().c_str()));
|
||||
IGNORE_RETURN(PseudoClientConnection::tryToDeliverMessageTo(login.getValue().getSourceStationId(), message));
|
||||
}
|
||||
else if(msg.isType("TransferLoginCharacterToDestinationServer"))
|
||||
{
|
||||
GenericValueTypeMessage<TransferCharacterData> login(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: ***ConnectionServer: Received TransferLoginCharacterToDestinationServer request from CentralServer for %s", login.getValue().toString().c_str()));
|
||||
IGNORE_RETURN(PseudoClientConnection::tryToDeliverMessageTo(login.getValue().getDestinationStationId(), message));
|
||||
}
|
||||
else if(msg.isType("CtsSrcCharWrongPlanet"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<NetworkId, unsigned int> > const failureMsg(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: ***ConnectionServer: Received CtsSrcCharWrongPlanet error from CentralServer for character (%s) stationId (%u) because character is not one of the 10 original ground planets", failureMsg.getValue().first.getValueString().c_str(), failureMsg.getValue().second));
|
||||
IGNORE_RETURN(PseudoClientConnection::tryToDeliverMessageTo(failureMsg.getValue().second, message));
|
||||
}
|
||||
else if(msg.isType("TransferKickConnectedClients"))
|
||||
{
|
||||
GenericValueTypeMessage<unsigned int> kick(ri);
|
||||
ClientConnection * clientConnection = ConnectionServer::getClientConnection(kick.getValue());
|
||||
if(clientConnection)
|
||||
{
|
||||
ConnectionServer::dropClient(clientConnection, "TransferServer requests client drop");
|
||||
}
|
||||
}
|
||||
else if(msg.isType("TransferClosePseudoClientConnection"))
|
||||
{
|
||||
GenericValueTypeMessage<unsigned int> closeRequest(ri);
|
||||
PseudoClientConnection * pseudoClient = PseudoClientConnection::getPseudoClientConnection(closeRequest.getValue());
|
||||
delete pseudoClient;
|
||||
}
|
||||
else if(msg.isType("LoginDeniedRecentCTS"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<NetworkId, uint32> > loginDeniedRecentCTS(ri);
|
||||
ClientConnection * clientConnection = ConnectionServer::getClientConnection(loginDeniedRecentCTS.getValue().second);
|
||||
if (clientConnection)
|
||||
{
|
||||
LOG("CustomerService", ("Login:%s, character %s (%s) is a recent CTS that has not been persisted yet.", ClientConnection::describeAccount(clientConnection).c_str(), clientConnection->getCharacterName().c_str(), clientConnection->getCharacterId().getValueString().c_str()));
|
||||
ErrorMessage err("Login Failed", "The selected character has just been recently transferred and has not been completely initialized. In most cases, it takes about 15 minutes (but in some cases can take up to 2 hours) to complete initialization. Please try again later.");
|
||||
clientConnection->send(err, true);
|
||||
}
|
||||
}
|
||||
else if(msg.isType("LoginDeniedPendingPlayerRenameRequest"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<NetworkId, uint32> > loginDeniedPendingPlayerRenameRequest(ri);
|
||||
ClientConnection * clientConnection = ConnectionServer::getClientConnection(loginDeniedPendingPlayerRenameRequest.getValue().second);
|
||||
if (clientConnection)
|
||||
{
|
||||
LOG("CustomerService", ("Login:%s, character %s (%s) has a pending player requested character rename request.", ClientConnection::describeAccount(clientConnection).c_str(), clientConnection->getCharacterName().c_str(), clientConnection->getCharacterId().getValueString().c_str()));
|
||||
ErrorMessage err("Login Failed", "The selected character currently has a pending character rename request. It can take up to 30 minutes for the rename request to complete.");
|
||||
clientConnection->send(err, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerConnection::onReceive(message);
|
||||
case constcrc("TransferLoginCharacterToSourceServer") :
|
||||
{
|
||||
GenericValueTypeMessage<TransferCharacterData> login(ri);
|
||||
// received a request to create a pseudoclient and connect it
|
||||
// to a game server.
|
||||
LOG("CustomerService", ("CharacterTransfer: ***ConnectionServer: Received TransferLoginCharacterToSourceServer request from CentralServer for %s\n", login.getValue().toString().c_str()));
|
||||
IGNORE_RETURN(PseudoClientConnection::tryToDeliverMessageTo(login.getValue().getSourceStationId(), message));
|
||||
break;
|
||||
}
|
||||
case constcrc("TransferLoginCharacterToDestinationServer") :
|
||||
{
|
||||
GenericValueTypeMessage<TransferCharacterData> login(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: ***ConnectionServer: Received TransferLoginCharacterToDestinationServer request from CentralServer for %s", login.getValue().toString().c_str()));
|
||||
IGNORE_RETURN(PseudoClientConnection::tryToDeliverMessageTo(login.getValue().getDestinationStationId(), message));
|
||||
break;
|
||||
}
|
||||
case constcrc("CtsSrcCharWrongPlanet") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<NetworkId, unsigned int> > const failureMsg(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: ***ConnectionServer: Received CtsSrcCharWrongPlanet error from CentralServer for character (%s) stationId (%u) because character is not one of the 10 original ground planets", failureMsg.getValue().first.getValueString().c_str(), failureMsg.getValue().second));
|
||||
IGNORE_RETURN(PseudoClientConnection::tryToDeliverMessageTo(failureMsg.getValue().second, message));
|
||||
break;
|
||||
}
|
||||
case constcrc("TransferKickConnectedClients") :
|
||||
{
|
||||
GenericValueTypeMessage<unsigned int> kick(ri);
|
||||
ClientConnection * clientConnection = ConnectionServer::getClientConnection(kick.getValue());
|
||||
if(clientConnection)
|
||||
{
|
||||
ConnectionServer::dropClient(clientConnection, "TransferServer requests client drop");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case constcrc("TransferClosePseudoClientConnection") :
|
||||
{
|
||||
GenericValueTypeMessage<unsigned int> closeRequest(ri);
|
||||
PseudoClientConnection * pseudoClient = PseudoClientConnection::getPseudoClientConnection(closeRequest.getValue());
|
||||
delete pseudoClient;
|
||||
break;
|
||||
}
|
||||
case constcrc("LoginDeniedRecentCTS") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<NetworkId, uint32> > loginDeniedRecentCTS(ri);
|
||||
ClientConnection * clientConnection = ConnectionServer::getClientConnection(loginDeniedRecentCTS.getValue().second);
|
||||
if (clientConnection)
|
||||
{
|
||||
LOG("CustomerService", ("Login:%s, character %s (%s) is a recent CTS that has not been persisted yet.", ClientConnection::describeAccount(clientConnection).c_str(), clientConnection->getCharacterName().c_str(), clientConnection->getCharacterId().getValueString().c_str()));
|
||||
ErrorMessage err("Login Failed", "The selected character has just been recently transferred and has not been completely initialized. In most cases, it takes about 15 minutes (but in some cases can take up to 2 hours) to complete initialization. Please try again later.");
|
||||
clientConnection->send(err, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case constcrc("LoginDeniedPendingPlayerRenameRequest") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<NetworkId, uint32> > loginDeniedPendingPlayerRenameRequest(ri);
|
||||
ClientConnection * clientConnection = ConnectionServer::getClientConnection(loginDeniedPendingPlayerRenameRequest.getValue().second);
|
||||
if (clientConnection)
|
||||
{
|
||||
LOG("CustomerService", ("Login:%s, character %s (%s) has a pending player requested character rename request.", ClientConnection::describeAccount(clientConnection).c_str(), clientConnection->getCharacterName().c_str(), clientConnection->getCharacterId().getValueString().c_str()));
|
||||
ErrorMessage err("Login Failed", "The selected character currently has a pending character rename request. It can take up to 30 minutes for the rename request to complete.");
|
||||
clientConnection->send(err, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ServerConnection::onReceive(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@@ -17,38 +17,7 @@
|
||||
#include "sharedNetworkMessages/ChatOnLeaveRoom.h"
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/*
|
||||
void putClientsInRoom(const unsigned int roomId, const std::vector<NetworkId> & clients)
|
||||
{
|
||||
std::vector<NetworkId>::const_iterator i;
|
||||
for(i = clients.begin(); i != clients.end(); ++i)
|
||||
{
|
||||
|
||||
Client* client = ConnectionServer::getClient((*i));
|
||||
DEBUG_REPORT_LOG(!client, ("Error, could not map %s to a client\n", (*i).getValueString().c_str()));
|
||||
if (client)
|
||||
client->enterRoom(roomId);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/*
|
||||
void removeClientsFromRoom(const unsigned int roomId, const std::vector<NetworkId> & clients)
|
||||
{
|
||||
std::vector<NetworkId>::const_iterator i;
|
||||
for(i = clients.begin(); i != clients.end(); ++i)
|
||||
{
|
||||
|
||||
Client* client = ConnectionServer::getClient((*i));
|
||||
DEBUG_REPORT_LOG(!client, ("Error, could not map %s to a client\n", (*i).getValueString().c_str()));
|
||||
if (client)
|
||||
client->leaveRoom(roomId);
|
||||
}
|
||||
}
|
||||
*/
|
||||
//-----------------------------------------------------------------------
|
||||
#include "sharedFoundation/CrcConstexpr.hpp"
|
||||
|
||||
ChatServerConnection::ChatServerConnection(UdpConnectionMT * u, TcpClient * t) :
|
||||
ServerConnection(u, t),
|
||||
@@ -104,41 +73,17 @@ void ChatServerConnection::onReceive(const Archive::ByteStream & message)
|
||||
Archive::ReadIterator ri = message.begin();
|
||||
GameNetworkMessage m(ri);
|
||||
ri = message.begin();
|
||||
|
||||
if (m.isType("GameClientMessage"))
|
||||
{
|
||||
//we're receiving a message to forward to the client.
|
||||
//it is prefixed with NetworkId and reliable.
|
||||
const GameClientMessage msg(ri);
|
||||
|
||||
if (m.getType() == constcrc("GameClientMessage")) {
|
||||
//we're receiving a message to forward to the client.
|
||||
//it is prefixed with NetworkId and reliable.
|
||||
|
||||
const GameClientMessage msg(ri);
|
||||
Archive::ReadIterator mri(msg.getByteStream());
|
||||
GameNetworkMessage gnm(mri);
|
||||
mri = msg.getByteStream().begin();
|
||||
|
||||
// The connection server wants to trap room
|
||||
// enter/leave messages to cache clients
|
||||
// in particular rooms for autorecovery when
|
||||
// a chat server process is stopped then later
|
||||
// restarted
|
||||
//
|
||||
// ************ THIS CODE DOES NOT WORK ***********
|
||||
// The following code has been commented out since
|
||||
// everyone in the group is sent these messages but
|
||||
// the logic assumes that only the person entering
|
||||
// or leaving a chat room is sent the message.
|
||||
/*
|
||||
if(gnm.isType("ChatOnEnteredRoom"))
|
||||
{
|
||||
Archive::ReadIterator cri(msg.getByteStream());
|
||||
ChatOnEnteredRoom chat(cri);
|
||||
putClientsInRoom(chat.getRoomId(), msg.getDistributionList());
|
||||
}
|
||||
else if(gnm.isType("ChatOnLeaveRoom"))
|
||||
{
|
||||
Archive::ReadIterator cri(msg.getByteStream());
|
||||
ChatOnLeaveRoom chat(cri);
|
||||
removeClientsFromRoom(chat.getRoomId(), msg.getDistributionList());
|
||||
}
|
||||
*/
|
||||
|
||||
const uint32 messageType = gnm.getType();
|
||||
|
||||
const std::vector<NetworkId> & d = msg.getDistributionList();
|
||||
std::vector<NetworkId>::const_iterator i;
|
||||
@@ -167,46 +112,55 @@ void ChatServerConnection::onReceive(const Archive::ByteStream & message)
|
||||
DEBUG_REPORT_LOG(!client, ("Error, could not map %s to a client\n", (*i).getValueString().c_str()));
|
||||
if (client)
|
||||
{
|
||||
if (!gnm.isType("ChatStatisticsCS"))
|
||||
if (messageType != constcrc("ChatStatisticsCS")) {
|
||||
client->getClientConnection()->sendByteStream(msg.getByteStream(), msg.getReliable());
|
||||
|
||||
}
|
||||
|
||||
GameConnection *gc = client->getGameConnection();
|
||||
|
||||
if (gc)
|
||||
{
|
||||
if (gnm.isType("ChatOnGetFriendsList"))
|
||||
{
|
||||
Archive::ReadIterator cri(msg.getByteStream());
|
||||
ChatOnGetFriendsList c(cri);
|
||||
gc->send(c, true);
|
||||
//DEBUG_REPORT_LOG(true, ("Sending a ChatOnGetFriendsList msg to game server\n"));
|
||||
}
|
||||
else if (gnm.isType("ChatOnChangeIgnoreStatus"))
|
||||
{
|
||||
Archive::ReadIterator cri(msg.getByteStream());
|
||||
ChatOnChangeIgnoreStatus c(cri);
|
||||
gc->send(c, true);
|
||||
//DEBUG_REPORT_LOG(true, ("Sending a ChatOnChangeIgnoreStatus msg to game server\n"));
|
||||
}
|
||||
else if (gnm.isType("ChatOnChangeFriendStatus"))
|
||||
{
|
||||
Archive::ReadIterator cri(msg.getByteStream());
|
||||
ChatOnChangeFriendStatus c(cri);
|
||||
gc->send(c, true);
|
||||
//DEBUG_REPORT_LOG(true, ("Sending a ChatOnChangeFriendStatus msg to game server\n"));
|
||||
}
|
||||
else if (gnm.isType("ChatOnGetIgnoreList"))
|
||||
{
|
||||
Archive::ReadIterator cri(msg.getByteStream());
|
||||
ChatOnGetIgnoreList c(cri);
|
||||
gc->send(c, true);
|
||||
//DEBUG_REPORT_LOG(true, ("Sending a ChatOnGetIgnoreList msg to game server\n"));
|
||||
}
|
||||
else if (gnm.isType("ChatStatisticsCS"))
|
||||
{
|
||||
Archive::ReadIterator cri(msg.getByteStream());
|
||||
GenericValueTypeMessage<std::pair<std::pair<NetworkId, int>, std::pair<int, int> > > chatStatistics(cri);
|
||||
gc->send(chatStatistics, true);
|
||||
//DEBUG_REPORT_LOG(true, ("Sending a ChatStatisticsCS msg to game server\n"));
|
||||
switch(messageType) {
|
||||
case constcrc("ChatOnGetFriendsList") :
|
||||
{
|
||||
Archive::ReadIterator cri(msg.getByteStream());
|
||||
ChatOnGetFriendsList c(cri);
|
||||
gc->send(c, true);
|
||||
//DEBUG_REPORT_LOG(true, ("Sending a ChatOnGetFriendsList msg to game server\n"));
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatOnChangeIgnoreStatus") :
|
||||
{
|
||||
Archive::ReadIterator cri(msg.getByteStream());
|
||||
ChatOnChangeIgnoreStatus c(cri);
|
||||
gc->send(c, true);
|
||||
//DEBUG_REPORT_LOG(true, ("Sending a ChatOnChangeIgnoreStatus msg to game server\n"));
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatOnChangeFriendStatus") :
|
||||
{
|
||||
Archive::ReadIterator cri(msg.getByteStream());
|
||||
ChatOnChangeFriendStatus c(cri);
|
||||
gc->send(c, true);
|
||||
//DEBUG_REPORT_LOG(true, ("Sending a ChatOnChangeFriendStatus msg to game server\n"));
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatOnGetIgnoreList") :
|
||||
{
|
||||
Archive::ReadIterator cri(msg.getByteStream());
|
||||
ChatOnGetIgnoreList c(cri);
|
||||
gc->send(c, true);
|
||||
//DEBUG_REPORT_LOG(true, ("Sending a ChatOnGetIgnoreList msg to game server\n"));
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatStatisticsCS") :
|
||||
{
|
||||
Archive::ReadIterator cri(msg.getByteStream());
|
||||
GenericValueTypeMessage<std::pair<std::pair<NetworkId, int>, std::pair<int, int> > > chatStatistics(cri);
|
||||
gc->send(chatStatistics, true);
|
||||
//DEBUG_REPORT_LOG(true, ("Sending a ChatStatisticsCS msg to game server\n"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include "sharedNetworkMessages/DisconnectPlayerMessage.h"
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
|
||||
#include "sharedFoundation/CrcConstexpr.hpp"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
Client::Client(ClientConnection * cconn, const NetworkId& oid) :
|
||||
@@ -157,7 +159,9 @@ void Client::leaveRoom(const unsigned int roomId)
|
||||
|
||||
void Client::receiveMessage(const MessageDispatch::Emitter & source, const MessageDispatch::MessageBase & message)
|
||||
{
|
||||
if(message.isType("GameConnectionClosed"))
|
||||
const uint32 messageType = message.getType();
|
||||
|
||||
if(messageType == constcrc("GameConnectionClosed"))
|
||||
{
|
||||
// Game server has crashed. With luck, we'll get transferred to a new server shortly
|
||||
// So, clear our connection and put us on a queue. If we don't get transferred in a
|
||||
@@ -166,12 +170,12 @@ void Client::receiveMessage(const MessageDispatch::Emitter & source, const Messa
|
||||
m_gameConnection = 0;
|
||||
ConnectionServer::addRecoveringClient(getNetworkId());
|
||||
}
|
||||
else if(message.isType("ChatServerConnectionOpened"))
|
||||
else if(messageType == constcrc("ChatServerConnectionOpened"))
|
||||
{
|
||||
const ChatServerConnection & chatConnection = static_cast<const ChatServerConnection &>(source);
|
||||
setChatConnection(const_cast<ChatServerConnection*>(&chatConnection));
|
||||
}
|
||||
else if(message.isType("CustomerServiceConnectionOpened"))
|
||||
else if(messageType == constcrc("CustomerServiceConnectionOpened"))
|
||||
{
|
||||
const CustomerServiceConnection & customerServiceConnection = static_cast<const CustomerServiceConnection &>(source);
|
||||
setCustomerServiceConnection(const_cast<CustomerServiceConnection*>(&customerServiceConnection));
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -88,6 +88,7 @@ void ConfigConnectionServer::install(void)
|
||||
KEY_INT (lagReportThreshold, 10000);
|
||||
KEY_INT (defaultGameFeatures, 0xFFFFFFFF);
|
||||
KEY_INT (defaultSubscriptionFeatures, 0xFFFFFFFF);
|
||||
KEY_INT (maxConnectionsPerIP, 6);
|
||||
|
||||
KEY_BOOL (validateStationKey, false);
|
||||
KEY_STRING (sessionServers, "");
|
||||
@@ -113,6 +114,8 @@ void ConfigConnectionServer::install(void)
|
||||
KEY_INT (connectionServerNumber, 0);
|
||||
KEY_INT (fakeBuddyPoints, 0);
|
||||
|
||||
KEY_STRING (altPublicBindAddress, "");
|
||||
|
||||
int index = 0;
|
||||
char const * result = 0;
|
||||
do
|
||||
@@ -163,4 +166,11 @@ int ConfigConnectionServer::getFakeBuddyPoints()
|
||||
return data->fakeBuddyPoints;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const char * ConfigConnectionServer::getPublicBindAddress()
|
||||
{
|
||||
return data->altPublicBindAddress;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
@@ -42,6 +42,7 @@ public:
|
||||
int clientMaxDataHoldTime;
|
||||
int clientHashTableSize;
|
||||
int lagReportThreshold;
|
||||
int maxConnectionsPerIP;
|
||||
|
||||
bool validateStationKey;
|
||||
const char * sessionServers;
|
||||
@@ -68,6 +69,9 @@ public:
|
||||
|
||||
int connectionServerNumber;
|
||||
int fakeBuddyPoints;
|
||||
|
||||
|
||||
const char * altPublicBindAddress;
|
||||
};
|
||||
|
||||
|
||||
@@ -133,6 +137,9 @@ public:
|
||||
static int getConnectionServerNumber();
|
||||
static int getFakeBuddyPoints();
|
||||
|
||||
static const char * getPublicBindAddress();
|
||||
|
||||
static int getMaxConnectionsPerIP();
|
||||
private:
|
||||
static Data * data;
|
||||
};
|
||||
@@ -462,4 +469,10 @@ inline int ConfigConnectionServer::getConnectionServerNumber()
|
||||
return data->connectionServerNumber;
|
||||
}
|
||||
|
||||
|
||||
inline int ConfigConnectionServer::getMaxConnectionsPerIP()
|
||||
{
|
||||
return data->maxConnectionsPerIP;
|
||||
}
|
||||
|
||||
#endif // _ConfigConnectionServer_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -31,6 +31,8 @@
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
#include "unicodeArchive/UnicodeArchive.h"
|
||||
|
||||
#include "sharedFoundation/CrcConstexpr.hpp"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
GameConnection::GameConnection(const std::string & a, const unsigned short p) :
|
||||
@@ -81,266 +83,286 @@ void GameConnection::onReceive(const Archive::ByteStream & message)
|
||||
Archive::ReadIterator ri = message.begin();
|
||||
GameNetworkMessage m(ri);
|
||||
ri = message.begin();
|
||||
|
||||
const uint32 messageType = m.getType();
|
||||
|
||||
if (m.isType("GameClientMessage"))
|
||||
{
|
||||
//we're receiving a message to forward to the client.
|
||||
//it is prefixed with NetworkId and reliable.
|
||||
const GameClientMessage msg(ri);
|
||||
const std::vector<NetworkId> & v = msg.getDistributionList();
|
||||
std::vector<NetworkId>::const_iterator i;
|
||||
const bool reliable = msg.getReliable();
|
||||
|
||||
Service *service = ConnectionServer::getClientServicePrivate();
|
||||
LogicalPacket const * p = service->createPacket(msg.getByteStream().getBuffer(), static_cast<int>(msg.getByteStream().getSize()));
|
||||
for(i = v.begin(); i != v.end(); ++i)
|
||||
switch (messageType) {
|
||||
case constcrc("GameClientMessage") :
|
||||
{
|
||||
Client* client = ConnectionServer::getClient((*i));
|
||||
if (client)
|
||||
//we're receiving a message to forward to the client.
|
||||
//it is prefixed with NetworkId and reliable.
|
||||
const GameClientMessage msg(ri);
|
||||
const std::vector<NetworkId> & v = msg.getDistributionList();
|
||||
std::vector<NetworkId>::const_iterator i;
|
||||
const bool reliable = msg.getReliable();
|
||||
|
||||
Service *service = ConnectionServer::getClientServicePrivate();
|
||||
LogicalPacket const * p = service->createPacket(msg.getByteStream().getBuffer(), static_cast<int>(msg.getByteStream().getSize()));
|
||||
for(i = v.begin(); i != v.end(); ++i)
|
||||
{
|
||||
client->getClientConnection()->sendSharedPacket(p, reliable);
|
||||
Client* client = ConnectionServer::getClient((*i));
|
||||
if (client)
|
||||
{
|
||||
client->getClientConnection()->sendSharedPacket(p, reliable);
|
||||
}
|
||||
}
|
||||
service->releasePacket(p);
|
||||
|
||||
break;
|
||||
}
|
||||
service->releasePacket(p);
|
||||
}
|
||||
else if (m.isType("CreateTicketMessage"))
|
||||
{
|
||||
Archive::ReadIterator cri(m.getByteStream());
|
||||
CreateTicketMessage const c(cri);
|
||||
CustomerServiceConnection * const customerServiceConnection =
|
||||
const_cast<CustomerServiceConnection *>(ConnectionServer::getCustomerServiceConnection());
|
||||
if (customerServiceConnection)
|
||||
case constcrc("CreateTicketMessage") :
|
||||
{
|
||||
customerServiceConnection->send(c, true);
|
||||
}
|
||||
}
|
||||
else if(m.isType("ControlAssumed"))
|
||||
{
|
||||
ControlAssumed ca(ri);
|
||||
|
||||
static const std::string loginTrace("TRACE_LOGIN");
|
||||
LOG(loginTrace, ("Received Control Assumed Message from game server %lu for %s skipLoadScreen=%s", getGameServerId(), ca.getNetworkId().getValueString().c_str(), (ca.getSkipLoadScreen() ? "yes" : "no")));
|
||||
|
||||
Client *client = ConnectionServer::getClient(ca.getNetworkId());
|
||||
if (!client)
|
||||
{
|
||||
// perhaps it's a transfer client?
|
||||
PseudoClientConnection * pseudoClient = PseudoClientConnection::getPseudoClientConnection(ca.getNetworkId());
|
||||
if(! pseudoClient)
|
||||
Archive::ReadIterator cri(m.getByteStream());
|
||||
CreateTicketMessage const c(cri);
|
||||
CustomerServiceConnection * const customerServiceConnection =
|
||||
const_cast<CustomerServiceConnection *>(ConnectionServer::getCustomerServiceConnection());
|
||||
if (customerServiceConnection)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, ("Client %s was already dropped, notifying GameServer.\n", ca.getNetworkId().getValueString().c_str()));
|
||||
DropClient const drop(ca.getNetworkId());
|
||||
send(drop, true);
|
||||
return;
|
||||
customerServiceConnection->send(c, true);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
case constcrc("ControlAssumed") :
|
||||
{
|
||||
ControlAssumed ca(ri);
|
||||
|
||||
static const std::string loginTrace("TRACE_LOGIN");
|
||||
LOG(loginTrace, ("Received Control Assumed Message from game server %lu for %s skipLoadScreen=%s", getGameServerId(), ca.getNetworkId().getValueString().c_str(), (ca.getSkipLoadScreen() ? "yes" : "no")));
|
||||
|
||||
Client *client = ConnectionServer::getClient(ca.getNetworkId());
|
||||
if (!client)
|
||||
{
|
||||
pseudoClient->controlAssumed();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!client->getClientConnection())
|
||||
{
|
||||
WARNING_STRICT_FATAL(true, ("We have a client with no client connection\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (ca.getSkipLoadScreen())
|
||||
client->skipLoadScreen();
|
||||
|
||||
if (!client->getSkipLoadScreen())
|
||||
{
|
||||
CmdStartScene const startScene(
|
||||
ca.getNetworkId(),
|
||||
ca.getSceneName(),
|
||||
ca.getStartPosition(),
|
||||
ca.getStartYaw(),
|
||||
ca.getTemplateName(),
|
||||
ca.getTimeSeconds(),
|
||||
static_cast<int32>(::time(NULL)),
|
||||
ConfigConnectionServer::getDisableWorldSnapshot());
|
||||
client->getClientConnection()->send(startScene, true);
|
||||
}
|
||||
client->handleTransfer(ca.getSceneName(), this);
|
||||
|
||||
// record the time when play started for the character
|
||||
if (client->getClientConnection()->getStartPlayTime() == 0)
|
||||
{
|
||||
client->getClientConnection()->setStartPlayTime(::time(NULL));
|
||||
}
|
||||
|
||||
// update the play time info on the game server
|
||||
// must be called after client->handleTransfer() so the
|
||||
// client object has been updated to point to the correct
|
||||
// game server for the client->sendPlayTimeInfoToGameServer()
|
||||
// call to work properly
|
||||
client->getClientConnection()->sendPlayTimeInfoToGameServer();
|
||||
}
|
||||
else if (m.isType("ReplyBankCTSLoaded"))
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Game Connection received ReplyBankCTSLoaded message"));
|
||||
GenericValueTypeMessage<NetworkId> characterId(ri);
|
||||
|
||||
IGNORE_RETURN(PseudoClientConnection::tryToDeliverMessageTo(characterId.getValue(), message));
|
||||
}
|
||||
else if (m.isType("PackedHousesLoaded"))
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Game Connection received PackedHousesLoaded message"));
|
||||
GenericValueTypeMessage<NetworkId> characterId(ri);
|
||||
|
||||
IGNORE_RETURN(PseudoClientConnection::tryToDeliverMessageTo(characterId.getValue(), message));
|
||||
}
|
||||
else if (m.isType("NewGameServer"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, ("Received NewGameServerMessage.\n"));
|
||||
// a game server has connected. Add it to the map
|
||||
const NewGameServer newGameServer(ri);
|
||||
|
||||
setGameServerId(newGameServer.getServerId());
|
||||
setSceneName(newGameServer.getSceneName());
|
||||
|
||||
// set the GameServerId @todo
|
||||
// add it to the map if a game process
|
||||
ConnectionServer::addGameConnection(newGameServer.getServerId(), this);
|
||||
}
|
||||
|
||||
else if (m.isType("KickPlayer"))
|
||||
{
|
||||
const KickPlayer kickPlayer(ri);
|
||||
Client *client = ConnectionServer::getClient(kickPlayer.getNetworkId());
|
||||
if (client)
|
||||
client->kick(kickPlayer.getReason());
|
||||
}
|
||||
|
||||
else if (m.isType("TransferControlMessage"))
|
||||
{
|
||||
// a game server is giving up authority for an object we control
|
||||
const TransferControlMessage transferControl(ri);
|
||||
|
||||
DEBUG_REPORT_LOG(true, ("Received TransferControlMessage for %s.\n", transferControl.getNetworkId().getValueString().c_str()));
|
||||
//question, do we need to check scene here?
|
||||
Client* client = ConnectionServer::getClient(transferControl.getNetworkId());
|
||||
|
||||
if(client)
|
||||
{
|
||||
if (transferControl.getSkipLoadScreen())
|
||||
client->skipLoadScreen();
|
||||
if (client->getClientConnection())
|
||||
{
|
||||
ClientConnection* cconn = client->getClientConnection();
|
||||
GameConnection* newConnection = ConnectionServer::getGameConnection(transferControl.getGameServerId());
|
||||
if(cconn && newConnection)
|
||||
{
|
||||
//We have a client, and a game connection, so send the newClient message off to the game server in question.
|
||||
//It will respond with a control assumed message.
|
||||
NewClient const newClient(transferControl.getNetworkId(), cconn->getAccountName(), cconn->getRemoteAddress(), cconn->getIsSecure(), transferControl.getSkipLoadScreen(), cconn->getSUID(), &transferControl.getObservedObjects(), cconn->getGameFeatures(), cconn->getSubscriptionFeatures(), cconn->getEntitlementTotalTime(), cconn->getEntitlementEntitledTime(), cconn->getEntitlementTotalTimeSinceLastLogin(), cconn->getEntitlementEntitledTimeSinceLastLogin(), cconn->getBuddyPoints(), cconn->getConsumedRewardEvents(), cconn->getClaimedRewardItems(), cconn->isUsingAdminLogin(), cconn->getCanSkipTutorial());
|
||||
newConnection->send(newClient, true);
|
||||
// perhaps it's a transfer client?
|
||||
PseudoClientConnection * pseudoClient = PseudoClientConnection::getPseudoClientConnection(ca.getNetworkId());
|
||||
if(! pseudoClient)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, ("Client %s was already dropped, notifying GameServer.\n", ca.getNetworkId().getValueString().c_str()));
|
||||
DropClient const drop(ca.getNetworkId());
|
||||
send(drop, true);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
WARNING_STRICT_FATAL(true, ("A TransferControl message was received to transfer client %s to GameServer %lu, but that game server is no longer available. The client will be dropped.", transferControl.getNetworkId().getValueString().c_str(), transferControl.getGameServerId()));
|
||||
DropClient const drop(transferControl.getNetworkId());
|
||||
send(drop, true);
|
||||
pseudoClient->controlAssumed();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_WARNING(true, ("Received a TransferControllMessage but the client is no longer available. This might be a lost race between the connection server notifiying a game server that the client has disconnected, and the game server notifying the connection server that the client is transferring."));
|
||||
DropClient const drop(transferControl.getNetworkId());
|
||||
send(drop, true);
|
||||
}
|
||||
}
|
||||
else if(m.isType("ReplyTransferData") || m.isType("ApplyTransferDataSuccess") || m.isType("ApplyTransferDataFail"))
|
||||
{
|
||||
GenericValueTypeMessage<TransferCharacterData> reply(ri);
|
||||
if (!client->getClientConnection())
|
||||
{
|
||||
WARNING_STRICT_FATAL(true, ("We have a client with no client connection\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
IGNORE_RETURN(PseudoClientConnection::tryToDeliverMessageTo(reply.getValue().getCharacterId(), message));
|
||||
}
|
||||
else if (m.isType("ChatEnterRoomValidationResponse"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::pair<NetworkId, unsigned int>, unsigned int> > const reply(ri);
|
||||
if (ca.getSkipLoadScreen())
|
||||
client->skipLoadScreen();
|
||||
|
||||
Client* client = ConnectionServer::getClient(reply.getValue().first.first);
|
||||
if (client && client->getClientConnection())
|
||||
{
|
||||
client->getClientConnection()->handleChatEnterRoomValidationResponse(reply.getValue().second, reply.getValue().first.second);
|
||||
if (!client->getSkipLoadScreen())
|
||||
{
|
||||
CmdStartScene const startScene(
|
||||
ca.getNetworkId(),
|
||||
ca.getSceneName(),
|
||||
ca.getStartPosition(),
|
||||
ca.getStartYaw(),
|
||||
ca.getTemplateName(),
|
||||
ca.getTimeSeconds(),
|
||||
static_cast<int32>(::time(nullptr)),
|
||||
ConfigConnectionServer::getDisableWorldSnapshot());
|
||||
client->getClientConnection()->send(startScene, true);
|
||||
}
|
||||
client->handleTransfer(ca.getSceneName(), this);
|
||||
|
||||
// record the time when play started for the character
|
||||
if (client->getClientConnection()->getStartPlayTime() == 0)
|
||||
{
|
||||
client->getClientConnection()->setStartPlayTime(::time(nullptr));
|
||||
}
|
||||
|
||||
// update the play time info on the game server
|
||||
// must be called after client->handleTransfer() so the
|
||||
// client object has been updated to point to the correct
|
||||
// game server for the client->sendPlayTimeInfoToGameServer()
|
||||
// call to work properly
|
||||
client->getClientConnection()->sendPlayTimeInfoToGameServer();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (m.isType("ChatQueryRoomValidationResponse"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::pair<NetworkId, bool>, unsigned int> > const reply(ri);
|
||||
|
||||
Client* client = ConnectionServer::getClient(reply.getValue().first.first);
|
||||
if (client && client->getClientConnection())
|
||||
case constcrc("ReplyBankCTSLoaded") :
|
||||
{
|
||||
client->getClientConnection()->handleChatQueryRoomValidationResponse(reply.getValue().second, reply.getValue().first.second);
|
||||
LOG("CustomerService", ("CharacterTransfer: Game Connection received ReplyBankCTSLoaded message"));
|
||||
GenericValueTypeMessage<NetworkId> characterId(ri);
|
||||
|
||||
IGNORE_RETURN(PseudoClientConnection::tryToDeliverMessageTo(characterId.getValue(), message));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (m.isType("AccountFeatureIdRequest"))
|
||||
{
|
||||
AccountFeatureIdRequest * const msg = new AccountFeatureIdRequest(ri);
|
||||
|
||||
SessionApiClient * const sessionApiClient = ConnectionServer::getSessionApiClient();
|
||||
if (sessionApiClient)
|
||||
case constcrc("PackedHousesLoaded") :
|
||||
{
|
||||
// SessionApiClient will own (and delete) msg
|
||||
sessionApiClient->getFeatures(msg->getTargetStationId(), msg->getGameCode(), msg);
|
||||
LOG("CustomerService", ("CharacterTransfer: Game Connection received PackedHousesLoaded message"));
|
||||
GenericValueTypeMessage<NetworkId> characterId(ri);
|
||||
|
||||
IGNORE_RETURN(PseudoClientConnection::tryToDeliverMessageTo(characterId.getValue(), message));
|
||||
break;
|
||||
}
|
||||
case constcrc("NewGameServer") :
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, ("Received NewGameServerMessage.\n"));
|
||||
// a game server has connected. Add it to the map
|
||||
const NewGameServer newGameServer(ri);
|
||||
|
||||
setGameServerId(newGameServer.getServerId());
|
||||
setSceneName(newGameServer.getSceneName());
|
||||
|
||||
// set the GameServerId @todo
|
||||
// add it to the map if a game process
|
||||
ConnectionServer::addGameConnection(newGameServer.getServerId(), this);
|
||||
break;
|
||||
}
|
||||
else
|
||||
case constcrc("KickPlayer") :
|
||||
{
|
||||
// a cluster running without session authentication stores
|
||||
// account feature id information on the LoginServer, so
|
||||
// pass request to the LoginServer (via CentralServer)
|
||||
CentralConnection * const cc = ConnectionServer::getCentralConnection();
|
||||
if (cc)
|
||||
cc->send(*msg, true);
|
||||
|
||||
delete msg;
|
||||
const KickPlayer kickPlayer(ri);
|
||||
Client *client = ConnectionServer::getClient(kickPlayer.getNetworkId());
|
||||
if (client)
|
||||
client->kick(kickPlayer.getReason());
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (m.isType("AdjustAccountFeatureIdRequest"))
|
||||
{
|
||||
AdjustAccountFeatureIdRequest * const msg = new AdjustAccountFeatureIdRequest(ri);
|
||||
|
||||
SessionApiClient * const sessionApiClient = ConnectionServer::getSessionApiClient();
|
||||
if (sessionApiClient)
|
||||
case constcrc("TransferControlMessage") :
|
||||
{
|
||||
// SessionApiClient will own (and delete) msg
|
||||
sessionApiClient->getFeatures(msg->getTargetStationId(), msg->getGameCode(), msg);
|
||||
// a game server is giving up authority for an object we control
|
||||
const TransferControlMessage transferControl(ri);
|
||||
|
||||
DEBUG_REPORT_LOG(true, ("Received TransferControlMessage for %s.\n", transferControl.getNetworkId().getValueString().c_str()));
|
||||
//question, do we need to check scene here?
|
||||
Client* client = ConnectionServer::getClient(transferControl.getNetworkId());
|
||||
|
||||
if(client)
|
||||
{
|
||||
if (transferControl.getSkipLoadScreen())
|
||||
client->skipLoadScreen();
|
||||
if (client->getClientConnection())
|
||||
{
|
||||
ClientConnection* cconn = client->getClientConnection();
|
||||
GameConnection* newConnection = ConnectionServer::getGameConnection(transferControl.getGameServerId());
|
||||
if(cconn && newConnection)
|
||||
{
|
||||
//We have a client, and a game connection, so send the newClient message off to the game server in question.
|
||||
//It will respond with a control assumed message.
|
||||
NewClient const newClient(transferControl.getNetworkId(), cconn->getAccountName(), cconn->getRemoteAddress(), cconn->getIsSecure(), transferControl.getSkipLoadScreen(), cconn->getSUID(), &transferControl.getObservedObjects(), cconn->getGameFeatures(), cconn->getSubscriptionFeatures(), cconn->getEntitlementTotalTime(), cconn->getEntitlementEntitledTime(), cconn->getEntitlementTotalTimeSinceLastLogin(), cconn->getEntitlementEntitledTimeSinceLastLogin(), cconn->getBuddyPoints(), cconn->getConsumedRewardEvents(), cconn->getClaimedRewardItems(), cconn->isUsingAdminLogin(), cconn->getCanSkipTutorial());
|
||||
newConnection->send(newClient, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
WARNING_STRICT_FATAL(true, ("A TransferControl message was received to transfer client %s to GameServer %lu, but that game server is no longer available. The client will be dropped.", transferControl.getNetworkId().getValueString().c_str(), transferControl.getGameServerId()));
|
||||
DropClient const drop(transferControl.getNetworkId());
|
||||
send(drop, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_WARNING(true, ("Received a TransferControllMessage but the client is no longer available. This might be a lost race between the connection server notifiying a game server that the client has disconnected, and the game server notifying the connection server that the client is transferring."));
|
||||
DropClient const drop(transferControl.getNetworkId());
|
||||
send(drop, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
case constcrc("ReplyTransferData") :
|
||||
case constcrc("ApplyTransferDataSuccess") :
|
||||
case constcrc("ApplyTransferDataFail") :
|
||||
{
|
||||
// a cluster running without session authentication stores
|
||||
// account feature id information on the LoginServer, so
|
||||
// pass request to the LoginServer (via CentralServer)
|
||||
CentralConnection * const cc = ConnectionServer::getCentralConnection();
|
||||
if (cc)
|
||||
cc->send(*msg, true);
|
||||
GenericValueTypeMessage<TransferCharacterData> reply(ri);
|
||||
|
||||
delete msg;
|
||||
IGNORE_RETURN(PseudoClientConnection::tryToDeliverMessageTo(reply.getValue().getCharacterId(), message));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (m.isType("ClaimRewardsMessage"))
|
||||
{
|
||||
ClaimRewardsMessage * const msg = new ClaimRewardsMessage(ri);
|
||||
|
||||
SessionApiClient * const sessionApiClient = ConnectionServer::getSessionApiClient();
|
||||
if ((msg->getAccountFeatureId() > 0) && sessionApiClient)
|
||||
case constcrc("ChatEnterRoomValidationResponse") :
|
||||
{
|
||||
// SessionApiClient will own (and delete) msg
|
||||
sessionApiClient->getFeatures(msg->getStationId(), PlatformGameCode::SWG, msg);
|
||||
GenericValueTypeMessage<std::pair<std::pair<NetworkId, unsigned int>, unsigned int> > const reply(ri);
|
||||
|
||||
Client* client = ConnectionServer::getClient(reply.getValue().first.first);
|
||||
if (client && client->getClientConnection())
|
||||
{
|
||||
client->getClientConnection()->handleChatEnterRoomValidationResponse(reply.getValue().second, reply.getValue().first.second);
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
case constcrc("ChatQueryRoomValidationResponse") :
|
||||
{
|
||||
// a cluster running without session authentication stores
|
||||
// account feature id information on the LoginServer, so
|
||||
// pass request to the LoginServer (via CentralServer)
|
||||
CentralConnection * const cc = ConnectionServer::getCentralConnection();
|
||||
if (cc)
|
||||
cc->send(*msg, true);
|
||||
GenericValueTypeMessage<std::pair<std::pair<NetworkId, bool>, unsigned int> > const reply(ri);
|
||||
|
||||
delete msg;
|
||||
Client* client = ConnectionServer::getClient(reply.getValue().first.first);
|
||||
if (client && client->getClientConnection())
|
||||
{
|
||||
client->getClientConnection()->handleChatQueryRoomValidationResponse(reply.getValue().second, reply.getValue().first.second);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case constcrc("AccountFeatureIdRequest") :
|
||||
{
|
||||
AccountFeatureIdRequest * const msg = new AccountFeatureIdRequest(ri);
|
||||
|
||||
SessionApiClient * const sessionApiClient = ConnectionServer::getSessionApiClient();
|
||||
if (sessionApiClient)
|
||||
{
|
||||
// SessionApiClient will own (and delete) msg
|
||||
sessionApiClient->getFeatures(msg->getTargetStationId(), msg->getGameCode(), msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
// a cluster running without session authentication stores
|
||||
// account feature id information on the LoginServer, so
|
||||
// pass request to the LoginServer (via CentralServer)
|
||||
CentralConnection * const cc = ConnectionServer::getCentralConnection();
|
||||
if (cc)
|
||||
cc->send(*msg, true);
|
||||
|
||||
delete msg;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case constcrc("AdjustAccountFeatureIdRequest") :
|
||||
{
|
||||
AdjustAccountFeatureIdRequest * const msg = new AdjustAccountFeatureIdRequest(ri);
|
||||
|
||||
SessionApiClient * const sessionApiClient = ConnectionServer::getSessionApiClient();
|
||||
if (sessionApiClient)
|
||||
{
|
||||
// SessionApiClient will own (and delete) msg
|
||||
sessionApiClient->getFeatures(msg->getTargetStationId(), msg->getGameCode(), msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
// a cluster running without session authentication stores
|
||||
// account feature id information on the LoginServer, so
|
||||
// pass request to the LoginServer (via CentralServer)
|
||||
CentralConnection * const cc = ConnectionServer::getCentralConnection();
|
||||
if (cc)
|
||||
cc->send(*msg, true);
|
||||
|
||||
delete msg;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case constcrc("ClaimRewardsMessage") :
|
||||
{
|
||||
ClaimRewardsMessage * const msg = new ClaimRewardsMessage(ri);
|
||||
|
||||
SessionApiClient * const sessionApiClient = ConnectionServer::getSessionApiClient();
|
||||
if ((msg->getAccountFeatureId() > 0) && sessionApiClient)
|
||||
{
|
||||
// SessionApiClient will own (and delete) msg
|
||||
sessionApiClient->getFeatures(msg->getStationId(), PlatformGameCode::SWG, msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
// a cluster running without session authentication stores
|
||||
// account feature id information on the LoginServer, so
|
||||
// pass request to the LoginServer (via CentralServer)
|
||||
CentralConnection * const cc = ConnectionServer::getCentralConnection();
|
||||
if (cc)
|
||||
cc->send(*msg, true);
|
||||
|
||||
delete msg;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+161
-142
@@ -21,6 +21,8 @@
|
||||
#include "sharedUtility/StartingLocationData.h"
|
||||
#include "sharedUtility/StartingLocationManager.h"
|
||||
|
||||
#include "sharedFoundation/CrcConstexpr.hpp"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
namespace PseudoClientConnectionNamespace
|
||||
@@ -231,171 +233,186 @@ void PseudoClientConnection::receiveMessage(const Archive::ByteStream & message)
|
||||
const GameNetworkMessage msg(ri);
|
||||
ri = message.begin();
|
||||
|
||||
if(msg.isType("GameServerForLoginMessage"))
|
||||
{
|
||||
const GameServerForLoginMessage gameServerForLogin(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: *** ConnectionServer: Received GameServerForLoginMessage for %d, server=%d\n", gameServerForLogin.getStationId(), gameServerForLogin.getServer()));
|
||||
m_gameConnection = ConnectionServer::getGameConnection(gameServerForLogin.getServer());
|
||||
if(m_gameConnection)
|
||||
const uint32 messageType = msg.getType();
|
||||
|
||||
switch(messageType) {
|
||||
case constcrc("GameServerForLoginMessage") :
|
||||
{
|
||||
NetworkId characterId = m_transferCharacterData.getCharacterId();
|
||||
unsigned int stationId = m_trackStationId;
|
||||
if(m_transferCharacterData.getScriptDictionaryData().size())
|
||||
const GameServerForLoginMessage gameServerForLogin(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: *** ConnectionServer: Received GameServerForLoginMessage for %d, server=%d\n", gameServerForLogin.getStationId(), gameServerForLogin.getServer()));
|
||||
m_gameConnection = ConnectionServer::getGameConnection(gameServerForLogin.getServer());
|
||||
if(m_gameConnection)
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Setting up login for destination server"));
|
||||
characterId = m_transferCharacterData.getDestinationCharacterId();
|
||||
NetworkId characterId = m_transferCharacterData.getCharacterId();
|
||||
unsigned int stationId = m_trackStationId;
|
||||
if(m_transferCharacterData.getScriptDictionaryData().size())
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Setting up login for destination server"));
|
||||
characterId = m_transferCharacterData.getDestinationCharacterId();
|
||||
}
|
||||
std::vector<std::pair<NetworkId, std::string> > static const emptyStringVector;
|
||||
NewClient m(characterId, "TransferServer", NetworkHandler::getHostName(), true, false, stationId, nullptr, 0, 0, 0, 0, 0, 0, 0, emptyStringVector, emptyStringVector, m_transferCharacterData.getCSToolId() != 0, true);
|
||||
m_gameConnection->send(m, true);
|
||||
LOG("CustomerService", ("CharacterTransfer: Sent NewClient(%s, \"TransferServer\", \"%s\", true, false, %d, nullptr, 0, 0)\n", characterId.getValueString().c_str(), NetworkHandler::getHostName().c_str(), stationId));
|
||||
}
|
||||
std::vector<std::pair<NetworkId, std::string> > static const emptyStringVector;
|
||||
NewClient m(characterId, "TransferServer", NetworkHandler::getHostName(), true, false, stationId, NULL, 0, 0, 0, 0, 0, 0, 0, emptyStringVector, emptyStringVector, m_transferCharacterData.getCSToolId() != 0, true);
|
||||
m_gameConnection->send(m, true);
|
||||
LOG("CustomerService", ("CharacterTransfer: Sent NewClient(%s, \"TransferServer\", \"%s\", true, false, %d, NULL, 0, 0)\n", characterId.getValueString().c_str(), NetworkHandler::getHostName().c_str(), stationId));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(msg.isType("TransferLoginCharacterToSourceServer"))
|
||||
{
|
||||
// this is a message that will create a new pseudoclient connection
|
||||
LOG("CustomerService", ("CharacterTransfer: requestGameServerForLogin()"));
|
||||
GenericValueTypeMessage<TransferCharacterData> loginRequest(ri);
|
||||
const NetworkId & requestCharacterId = loginRequest.getValue().getCharacterId();
|
||||
if(requestCharacterId == NetworkId::cms_invalid || requestCharacterId != m_transferCharacterData.getCharacterId())
|
||||
case constcrc("TransferLoginCharacterToSourceServer") :
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: *** ERROR *** Received a request to login to source server for %s, but a transfer for %s is already in progress. Sending failure.", loginRequest.getValue().toString().c_str(), m_transferCharacterData.toString().c_str()));
|
||||
// this is a message that will create a new pseudoclient connection
|
||||
LOG("CustomerService", ("CharacterTransfer: requestGameServerForLogin()"));
|
||||
GenericValueTypeMessage<TransferCharacterData> loginRequest(ri);
|
||||
const NetworkId & requestCharacterId = loginRequest.getValue().getCharacterId();
|
||||
if(requestCharacterId == NetworkId::cms_invalid || requestCharacterId != m_transferCharacterData.getCharacterId())
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: *** ERROR *** Received a request to login to source server for %s, but a transfer for %s is already in progress. Sending failure.", loginRequest.getValue().toString().c_str(), m_transferCharacterData.toString().c_str()));
|
||||
GenericValueTypeMessage<TransferCharacterData> fail("ReplyTransferDataFail", m_transferCharacterData);
|
||||
ConnectionServer::sendToCentralProcess(fail);
|
||||
}
|
||||
else
|
||||
{
|
||||
requestGameServerForLogin();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case constcrc("TransferLoginCharacterToDestinationServer") :
|
||||
{
|
||||
GenericValueTypeMessage<TransferCharacterData> loginRequest(ri);
|
||||
const NetworkId & requestCharacterId = loginRequest.getValue().getCharacterId();
|
||||
if(requestCharacterId == NetworkId::cms_invalid || requestCharacterId != m_transferCharacterData.getCharacterId())
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: *** ERROR *** Received a request to login to destination server for %s, but a transfer for %s is already in progress. Sending failure.", loginRequest.getValue().toString().c_str(), m_transferCharacterData.toString().c_str()));
|
||||
GenericValueTypeMessage<TransferCharacterData> fail("ReplyTransferDataFail", m_transferCharacterData);
|
||||
ConnectionServer::sendToCentralProcess(fail);
|
||||
}
|
||||
else
|
||||
{
|
||||
// find a valid starting location
|
||||
std::vector<StartingLocationData> startingLocations;
|
||||
StartingLocationData bestLocation;
|
||||
startingLocations = StartingLocationManager::getLocations();
|
||||
if(! startingLocations.empty())
|
||||
{
|
||||
bestLocation = *(startingLocations.begin());
|
||||
}
|
||||
m_transferCharacterData.setScene(bestLocation.planet);
|
||||
m_transferCharacterData.setStartingCoordinates(Vector(bestLocation.x, bestLocation.y, bestLocation.z));
|
||||
|
||||
// start character creation process
|
||||
ConnectionCreateCharacter connectionCreate(
|
||||
m_transferCharacterData.getDestinationStationId(),
|
||||
Unicode::narrowToWide(m_transferCharacterData.getDestinationCharacterName()),
|
||||
m_transferCharacterData.getObjectTemplateName(),
|
||||
m_transferCharacterData.getScaleFactor(),
|
||||
bestLocation.name,
|
||||
m_transferCharacterData.getCustomizationData(),
|
||||
m_transferCharacterData.getHairTemplateName(),
|
||||
m_transferCharacterData.getHairAppearanceData(),
|
||||
m_transferCharacterData.getProfession(),
|
||||
false,
|
||||
m_transferCharacterData.getBiography(),
|
||||
false,
|
||||
m_transferCharacterData.getSkillTemplate(),
|
||||
m_transferCharacterData.getWorkingSkill(),
|
||||
false,
|
||||
true,
|
||||
0xFFFFFFFF); // assume all feature bits set, so that character creation will not be blocked by account features
|
||||
LOG("CustomerService", ("CharacterTransfer: Sending ConnectionCreateCharacter to CentralServer : %s", m_transferCharacterData.toString().c_str()));
|
||||
ConnectionServer::sendToCentralProcess(connectionCreate);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case constcrc("CtsSrcCharWrongPlanet") :
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: *** ERROR *** Source character is not one of the 10 original ground planets. Sending failure for %s.", m_transferCharacterData.toString().c_str()));
|
||||
GenericValueTypeMessage<TransferCharacterData> fail("ReplyTransferDataFail", m_transferCharacterData);
|
||||
ConnectionServer::sendToCentralProcess(fail);
|
||||
break;
|
||||
}
|
||||
else
|
||||
case constcrc("ReplyTransferData") :
|
||||
{
|
||||
// the game server has responded with valid transfer information.
|
||||
// upload the data to the transfer server (by way of the CentralServer)
|
||||
// and disconnect the client since there's nothing more needed to be
|
||||
// done here
|
||||
GenericValueTypeMessage<TransferCharacterData> reply(ri);
|
||||
m_transferCharacterData = reply.getValue();
|
||||
LOG("CustomerService", ("CharacterTransfer: Received ReplyTransferData %s", m_transferCharacterData.toString().c_str()));
|
||||
|
||||
CentralConnection * centralServerConnection = ConnectionServer::getCentralConnection();
|
||||
if(centralServerConnection)
|
||||
{
|
||||
const GenericValueTypeMessage<TransferCharacterData> transferReply("TransferReceiveDataFromGameServer", m_transferCharacterData);
|
||||
centralServerConnection->send(transferReply, true);
|
||||
}
|
||||
|
||||
DropClient dropMsg(m_transferCharacterData.getCharacterId());
|
||||
if(m_gameConnection)
|
||||
{
|
||||
m_gameConnection->send(dropMsg, true);
|
||||
}
|
||||
delete this;
|
||||
break;
|
||||
}
|
||||
case constcrc("ConnectionCreateCharacterSuccess") :
|
||||
{
|
||||
const ConnectionCreateCharacterSuccess success(ri);
|
||||
// woohoo! character has been created on the server!
|
||||
// Log the character back in, run the transfer scripts to
|
||||
// apply data in the script dictionary associated with the character
|
||||
LOG("CustomerService", ("CharacterTransfer: Received ConnectionCreateCharacterSuccess for %s", m_transferCharacterData.toString().c_str()));
|
||||
m_transferCharacterData.setDestinationCharacterId(success.getNetworkId());
|
||||
requestGameServerForLogin();
|
||||
s_pseudoClientConnectionMapByCharacterId[m_transferCharacterData.getDestinationCharacterId()] = this;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(msg.isType("TransferLoginCharacterToDestinationServer"))
|
||||
{
|
||||
GenericValueTypeMessage<TransferCharacterData> loginRequest(ri);
|
||||
const NetworkId & requestCharacterId = loginRequest.getValue().getCharacterId();
|
||||
if(requestCharacterId == NetworkId::cms_invalid || requestCharacterId != m_transferCharacterData.getCharacterId())
|
||||
case constcrc("ConnectionCreateCharacterFailed") :
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: *** ERROR *** Received a request to login to destination server for %s, but a transfer for %s is already in progress. Sending failure.", loginRequest.getValue().toString().c_str(), m_transferCharacterData.toString().c_str()));
|
||||
GenericValueTypeMessage<TransferCharacterData> fail("ReplyTransferDataFail", m_transferCharacterData);
|
||||
ConnectionServer::sendToCentralProcess(fail);
|
||||
}
|
||||
else
|
||||
{
|
||||
// find a valid starting location
|
||||
std::vector<StartingLocationData> startingLocations;
|
||||
StartingLocationData bestLocation;
|
||||
startingLocations = StartingLocationManager::getLocations();
|
||||
if(! startingLocations.empty())
|
||||
const ConnectionCreateCharacterFailed failed(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received ConnectionCreateCharacterFailed [%s, %s] for %s", failed.getErrorMessage().getDebugString().c_str(), failed.getOptionalDetailedErrorMessage().c_str(), m_transferCharacterData.toString().c_str()));
|
||||
s_pseudoClientConnectionMapByCharacterId[m_transferCharacterData.getDestinationCharacterId()] = this;
|
||||
GenericValueTypeMessage<TransferCharacterData> reply("TransferCreateCharacterFailed", m_transferCharacterData);
|
||||
CentralConnection * centralServerConnection = ConnectionServer::getCentralConnection();
|
||||
if(centralServerConnection)
|
||||
{
|
||||
bestLocation = *(startingLocations.begin());
|
||||
centralServerConnection->send(reply, true);
|
||||
}
|
||||
m_transferCharacterData.setScene(bestLocation.planet);
|
||||
m_transferCharacterData.setStartingCoordinates(Vector(bestLocation.x, bestLocation.y, bestLocation.z));
|
||||
|
||||
// start character creation process
|
||||
ConnectionCreateCharacter connectionCreate(
|
||||
m_transferCharacterData.getDestinationStationId(),
|
||||
Unicode::narrowToWide(m_transferCharacterData.getDestinationCharacterName()),
|
||||
m_transferCharacterData.getObjectTemplateName(),
|
||||
m_transferCharacterData.getScaleFactor(),
|
||||
bestLocation.name,
|
||||
m_transferCharacterData.getCustomizationData(),
|
||||
m_transferCharacterData.getHairTemplateName(),
|
||||
m_transferCharacterData.getHairAppearanceData(),
|
||||
m_transferCharacterData.getProfession(),
|
||||
false,
|
||||
m_transferCharacterData.getBiography(),
|
||||
false,
|
||||
m_transferCharacterData.getSkillTemplate(),
|
||||
m_transferCharacterData.getWorkingSkill(),
|
||||
false,
|
||||
true,
|
||||
0xFFFFFFFF); // assume all feature bits set, so that character creation will not be blocked by account features
|
||||
LOG("CustomerService", ("CharacterTransfer: Sending ConnectionCreateCharacter to CentralServer : %s", m_transferCharacterData.toString().c_str()));
|
||||
ConnectionServer::sendToCentralProcess(connectionCreate);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(msg.isType("CtsSrcCharWrongPlanet"))
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: *** ERROR *** Source character is not one of the 10 original ground planets. Sending failure for %s.", m_transferCharacterData.toString().c_str()));
|
||||
GenericValueTypeMessage<TransferCharacterData> fail("ReplyTransferDataFail", m_transferCharacterData);
|
||||
ConnectionServer::sendToCentralProcess(fail);
|
||||
}
|
||||
else if(msg.isType("ReplyTransferData"))
|
||||
{
|
||||
// the game server has responded with valid transfer information.
|
||||
// upload the data to the transfer server (by way of the CentralServer)
|
||||
// and disconnect the client since there's nothing more needed to be
|
||||
// done here
|
||||
GenericValueTypeMessage<TransferCharacterData> reply(ri);
|
||||
m_transferCharacterData = reply.getValue();
|
||||
LOG("CustomerService", ("CharacterTransfer: Received ReplyTransferData %s", m_transferCharacterData.toString().c_str()));
|
||||
|
||||
CentralConnection * centralServerConnection = ConnectionServer::getCentralConnection();
|
||||
if(centralServerConnection)
|
||||
case constcrc("ApplyTransferDataSuccess") :
|
||||
{
|
||||
const GenericValueTypeMessage<TransferCharacterData> transferReply("TransferReceiveDataFromGameServer", m_transferCharacterData);
|
||||
centralServerConnection->send(transferReply, true);
|
||||
GenericValueTypeMessage<TransferCharacterData> success(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received ApplyTransferDataSuccess from GameServer! %s", success.getValue().toString().c_str()));
|
||||
CentralConnection * centralServerConnection = ConnectionServer::getCentralConnection();
|
||||
if(centralServerConnection)
|
||||
{
|
||||
centralServerConnection->send(success, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
DropClient dropMsg(m_transferCharacterData.getCharacterId());
|
||||
if(m_gameConnection)
|
||||
case constcrc("ApplyTransferDataFail") :
|
||||
{
|
||||
m_gameConnection->send(dropMsg, true);
|
||||
GenericValueTypeMessage<TransferCharacterData> fail(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received ApplyTransferDataFail from GameServer! %s", fail.getValue().toString().c_str()));
|
||||
CentralConnection * centralServerConnection = ConnectionServer::getCentralConnection();
|
||||
if(centralServerConnection)
|
||||
{
|
||||
centralServerConnection->send(fail, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
delete this;
|
||||
}
|
||||
else if(msg.isType("ConnectionCreateCharacterSuccess"))
|
||||
{
|
||||
const ConnectionCreateCharacterSuccess success(ri);
|
||||
// woohoo! character has been created on the server!
|
||||
// Log the character back in, run the transfer scripts to
|
||||
// apply data in the script dictionary associated with the character
|
||||
LOG("CustomerService", ("CharacterTransfer: Received ConnectionCreateCharacterSuccess for %s", m_transferCharacterData.toString().c_str()));
|
||||
m_transferCharacterData.setDestinationCharacterId(success.getNetworkId());
|
||||
requestGameServerForLogin();
|
||||
s_pseudoClientConnectionMapByCharacterId[m_transferCharacterData.getDestinationCharacterId()] = this;
|
||||
}
|
||||
else if(msg.isType("ConnectionCreateCharacterFailed"))
|
||||
{
|
||||
const ConnectionCreateCharacterFailed failed(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received ConnectionCreateCharacterFailed [%s, %s] for %s", failed.getErrorMessage().getDebugString().c_str(), failed.getOptionalDetailedErrorMessage().c_str(), m_transferCharacterData.toString().c_str()));
|
||||
s_pseudoClientConnectionMapByCharacterId[m_transferCharacterData.getDestinationCharacterId()] = this;
|
||||
GenericValueTypeMessage<TransferCharacterData> reply("TransferCreateCharacterFailed", m_transferCharacterData);
|
||||
CentralConnection * centralServerConnection = ConnectionServer::getCentralConnection();
|
||||
if(centralServerConnection)
|
||||
case constcrc("ReplyBankCTSLoaded") :
|
||||
{
|
||||
centralServerConnection->send(reply, true);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received ReplyBankCTSLoaded from GameServer!"));
|
||||
onBankLoaded();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(msg.isType("ApplyTransferDataSuccess"))
|
||||
{
|
||||
GenericValueTypeMessage<TransferCharacterData> success(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received ApplyTransferDataSuccess from GameServer! %s", success.getValue().toString().c_str()));
|
||||
CentralConnection * centralServerConnection = ConnectionServer::getCentralConnection();
|
||||
if(centralServerConnection)
|
||||
case constcrc("PackedHousesLoaded") :
|
||||
{
|
||||
centralServerConnection->send(success, true);
|
||||
onPackedHousesLoaded();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(msg.isType("ApplyTransferDataFail"))
|
||||
{
|
||||
GenericValueTypeMessage<TransferCharacterData> fail(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received ApplyTransferDataFail from GameServer! %s", fail.getValue().toString().c_str()));
|
||||
CentralConnection * centralServerConnection = ConnectionServer::getCentralConnection();
|
||||
if(centralServerConnection)
|
||||
{
|
||||
centralServerConnection->send(fail, true);
|
||||
}
|
||||
}
|
||||
else if(msg.isType("ReplyBankCTSLoaded"))
|
||||
{
|
||||
LOG("CustomerService", ("CharacterTransfer: Received ReplyBankCTSLoaded from GameServer!"));
|
||||
onBankLoaded();
|
||||
}
|
||||
else if(msg.isType("PackedHousesLoaded"))
|
||||
{
|
||||
onPackedHousesLoaded();
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
@@ -433,7 +450,9 @@ bool PseudoClientConnection::tryToDeliverMessageTo(unsigned int stationId, const
|
||||
ri = message.begin();
|
||||
|
||||
bool result = false;
|
||||
if(msg.isType("TransferLoginCharacterToSourceServer") || msg.isType("TransferLoginCharacterToDestinationServer"))
|
||||
const uint32 messageType = msg.getType();
|
||||
|
||||
if(messageType == constcrc("TransferLoginCharacterToSourceServer") || messageType == constcrc("TransferLoginCharacterToDestinationServer"))
|
||||
{
|
||||
// this is a message that will create a new pseudoclient connection
|
||||
const GenericValueTypeMessage<TransferCharacterData> login(ri);
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
#include "sharedGame/PlatformFeatureBits.h"
|
||||
#include "sharedLog/Log.h"
|
||||
|
||||
#include "sharedFoundation/CrcConstexpr.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
@@ -303,23 +305,35 @@ void SessionApiClient::OnGetFeatures(const apiTrackingNumber trackingNumber,
|
||||
if (i != ms_getFeaturesTrackingNumberMap.end())
|
||||
{
|
||||
bool reuseMessage = false;
|
||||
AccountFeatureIdRequest const * accountFeatureIdRequest = NULL;
|
||||
AdjustAccountFeatureIdRequest const * adjustAccountFeatureIdRequest = NULL;
|
||||
AdjustAccountFeatureIdResponse * adjustAccountFeatureIdResponse = NULL;
|
||||
ClaimRewardsMessage * claimRewardsMessage = NULL;
|
||||
AccountFeatureIdRequest const * accountFeatureIdRequest = nullptr;
|
||||
AdjustAccountFeatureIdRequest const * adjustAccountFeatureIdRequest = nullptr;
|
||||
AdjustAccountFeatureIdResponse * adjustAccountFeatureIdResponse = nullptr;
|
||||
ClaimRewardsMessage * claimRewardsMessage = nullptr;
|
||||
|
||||
if (i->second->isType("AccountFeatureIdRequest"))
|
||||
accountFeatureIdRequest = dynamic_cast<AccountFeatureIdRequest const *>(i->second);
|
||||
else if (i->second->isType("AdjustAccountFeatureIdRequest"))
|
||||
adjustAccountFeatureIdRequest = dynamic_cast<AdjustAccountFeatureIdRequest const *>(i->second);
|
||||
else if (i->second->isType("AdjustAccountFeatureIdResponse"))
|
||||
adjustAccountFeatureIdResponse = dynamic_cast<AdjustAccountFeatureIdResponse *>(i->second);
|
||||
else if (i->second->isType("ClaimRewardsMessage"))
|
||||
claimRewardsMessage = dynamic_cast<ClaimRewardsMessage *>(i->second);
|
||||
const uint32 msgType = i->second->getType();
|
||||
|
||||
switch(msgType) {
|
||||
case constcrc("AccountFeatureIdRequest") : {
|
||||
accountFeatureIdRequest = dynamic_cast<AccountFeatureIdRequest const *>(i->second);
|
||||
break;
|
||||
}
|
||||
case constcrc("AdjustAccountFeatureIdRequest") : {
|
||||
adjustAccountFeatureIdRequest = dynamic_cast<AdjustAccountFeatureIdRequest const *>(i->second);
|
||||
break;
|
||||
}
|
||||
case constcrc("AdjustAccountFeatureIdResponse") : {
|
||||
adjustAccountFeatureIdResponse = dynamic_cast<AdjustAccountFeatureIdResponse *>(i->second);
|
||||
break;
|
||||
}
|
||||
case constcrc("ClaimRewardsMessage") : {
|
||||
claimRewardsMessage = dynamic_cast<ClaimRewardsMessage *>(i->second);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (result == RESULT_SUCCESS)
|
||||
{
|
||||
ClientConnection * clientConnection = NULL;
|
||||
ClientConnection * clientConnection = nullptr;
|
||||
if (accountFeatureIdRequest)
|
||||
clientConnection = ConnectionServer::getClientConnection(accountFeatureIdRequest->getTargetStationId());
|
||||
else if (adjustAccountFeatureIdRequest)
|
||||
@@ -391,7 +405,7 @@ void SessionApiClient::OnGetFeatures(const apiTrackingNumber trackingNumber,
|
||||
else
|
||||
{
|
||||
// if account already has the feature, adjust it, otherwise add the feature
|
||||
LoginAPI::Feature const * existingFeature = NULL;
|
||||
LoginAPI::Feature const * existingFeature = nullptr;
|
||||
|
||||
for (unsigned k = 0; k < featureCount; ++k)
|
||||
{
|
||||
@@ -444,7 +458,7 @@ void SessionApiClient::OnGetFeatures(const apiTrackingNumber trackingNumber,
|
||||
}
|
||||
else
|
||||
{
|
||||
LoginAPI::Feature const * newlyAddedFeature = NULL;
|
||||
LoginAPI::Feature const * newlyAddedFeature = nullptr;
|
||||
|
||||
for (unsigned k = 0; k < featureCount; ++k)
|
||||
{
|
||||
@@ -506,7 +520,7 @@ void SessionApiClient::OnGetFeatures(const apiTrackingNumber trackingNumber,
|
||||
else
|
||||
{
|
||||
// see if account already has the required feature
|
||||
LoginAPI::Feature const * existingFeature = NULL;
|
||||
LoginAPI::Feature const * existingFeature = nullptr;
|
||||
|
||||
for (unsigned k = 0; k < featureCount; ++k)
|
||||
{
|
||||
@@ -904,7 +918,7 @@ void SessionApiClient::validateClient (ClientConnection* client, const std::stri
|
||||
|
||||
void SessionApiClient::startPlay(const ClientConnection& client)
|
||||
{
|
||||
IGNORE_RETURN(SessionStartPlay(client.getSessionId().c_str(), ConfigConnectionServer::getClusterName(), client.getCharacterName().c_str(), NULL));
|
||||
IGNORE_RETURN(SessionStartPlay(client.getSessionId().c_str(), ConfigConnectionServer::getClusterName(), client.getCharacterName().c_str(), nullptr));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
#include "FirstConnectionServer.h"
|
||||
@@ -0,0 +1,58 @@
|
||||
#include "FirstConnectionServer.h"
|
||||
#include "ConfigConnectionServer.h"
|
||||
#include "ConnectionServer.h"
|
||||
|
||||
#include "sharedCompression/SetupSharedCompression.h"
|
||||
#include "sharedDebug/SetupSharedDebug.h"
|
||||
#include "sharedFile/SetupSharedFile.h"
|
||||
#include "sharedFoundation/PerThreadData.h"
|
||||
#include "sharedFoundation/SetupSharedFoundation.h"
|
||||
#include "sharedNetworkMessages/SetupSharedNetworkMessages.h"
|
||||
#include "sharedRandom/SetupSharedRandom.h"
|
||||
#include "sharedThread/SetupSharedThread.h"
|
||||
|
||||
#include <time.h>
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
// command line hack
|
||||
std::string cmdLine;
|
||||
for(int i = 1; i < argc; ++i)
|
||||
{
|
||||
cmdLine += argv[i];
|
||||
if(i + 1 < argc)
|
||||
{
|
||||
cmdLine += " ";
|
||||
}
|
||||
}
|
||||
|
||||
SetupSharedThread::install();
|
||||
SetupSharedDebug::install(1024);
|
||||
|
||||
//-- setup foundation
|
||||
SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game);
|
||||
|
||||
// setupFoundationData.hInstance = hInstance;
|
||||
setupFoundationData.commandLine = cmdLine.c_str();
|
||||
setupFoundationData.createWindow = false;
|
||||
setupFoundationData.clockUsesSleep = true;
|
||||
|
||||
SetupSharedFoundation::install (setupFoundationData);
|
||||
SetupSharedFile::install(false);
|
||||
SetupSharedCompression::install();
|
||||
|
||||
SetupSharedNetworkMessages::install();
|
||||
SetupSharedRandom::install(int(time(NULL)));
|
||||
|
||||
//-- setup game server
|
||||
ConfigConnectionServer::install ();
|
||||
|
||||
ConnectionServer::install();
|
||||
//-- run game
|
||||
SetupSharedFoundation::callbackWithExceptionHandling(ConnectionServer::run);
|
||||
ConnectionServer::remove();
|
||||
ConfigConnectionServer::remove();
|
||||
SetupSharedFoundation::remove();
|
||||
PerThreadData::threadRemove();
|
||||
return 0;
|
||||
}
|
||||
@@ -30,7 +30,7 @@ int main(int argc, char *argv[])
|
||||
SetupSharedFile::install(false);
|
||||
SetupSharedNetworkMessages::install();
|
||||
|
||||
SetupSharedRandom::install(static_cast<uint32>(time(NULL)));
|
||||
SetupSharedRandom::install(static_cast<uint32>(time(nullptr)));
|
||||
Os::setProgramName("CustomerServiceServer");
|
||||
ConfigCustomerServiceServer::install();
|
||||
NetworkHandler::install();
|
||||
|
||||
+4
-4
@@ -49,7 +49,7 @@ void CentralServerConnection::onConnectionOpened()
|
||||
|
||||
Service *chatServerService = CustomerServiceServer::getInstance().getChatServerService();
|
||||
|
||||
if (chatServerService != NULL)
|
||||
if (chatServerService != nullptr)
|
||||
{
|
||||
const std::string address(chatServerService->getBindAddress());
|
||||
const int port = chatServerService->getBindPort();
|
||||
@@ -62,7 +62,7 @@ void CentralServerConnection::onConnectionOpened()
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("CentralServerConnection", ("onConnectionOpened() ERROR: ChatServerService is NULL"));
|
||||
LOG("CentralServerConnection", ("onConnectionOpened() ERROR: ChatServerService is nullptr"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ void CentralServerConnection::onConnectionOpened()
|
||||
|
||||
Service *gameServerService = CustomerServiceServer::getInstance().getGameServerService();
|
||||
|
||||
if (gameServerService != NULL)
|
||||
if (gameServerService != nullptr)
|
||||
{
|
||||
const std::string address(gameServerService->getBindAddress());
|
||||
const int port = gameServerService->getBindPort();
|
||||
@@ -84,7 +84,7 @@ void CentralServerConnection::onConnectionOpened()
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("CentralServerConnection", ("onConnectionOpened() ERROR: GameServerService is NULL"));
|
||||
LOG("CentralServerConnection", ("onConnectionOpened() ERROR: GameServerService is nullptr"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,13 +64,13 @@ void ChatServerConnection::sendTo(GameNetworkMessage const &message)
|
||||
{
|
||||
LOG("ChatServerConnection", ("sendTo() message(%s)", message.getCmdName().c_str()));
|
||||
|
||||
if (s_connection != NULL)
|
||||
if (s_connection != nullptr)
|
||||
{
|
||||
s_connection->send(message, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("ChatServerConnection", ("sendTo() Unable to send, NULL ChatServerConnection"));
|
||||
LOG("ChatServerConnection", ("sendTo() Unable to send, nullptr ChatServerConnection"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -12,19 +12,19 @@
|
||||
|
||||
namespace ConfigCustomerServiceServerNamespace
|
||||
{
|
||||
const char * s_clusterName = NULL;
|
||||
const char * s_centralServerAddress = NULL;
|
||||
const char * s_clusterName = nullptr;
|
||||
const char * s_centralServerAddress = nullptr;
|
||||
int s_centralServerPort = 0;
|
||||
const char * s_gameCode = NULL;
|
||||
const char * s_csServerAddress = NULL;
|
||||
const char * s_gameCode = nullptr;
|
||||
const char * s_csServerAddress = nullptr;
|
||||
int s_csServerPort = 0;
|
||||
int s_maxPacketsPerSecond = 50;
|
||||
int s_requestTimeoutSeconds = 300;
|
||||
int s_maxAllowedNumberOfTickets = 1;
|
||||
int s_gameServicePort = 0;
|
||||
int s_chatServicePort = 0;
|
||||
const char* s_chatServiceBindInterface = NULL;
|
||||
const char* s_gameServiceBindInterface = NULL;
|
||||
const char* s_chatServiceBindInterface = nullptr;
|
||||
const char* s_gameServiceBindInterface = nullptr;
|
||||
bool s_writeTicketToBugLog = false;
|
||||
};
|
||||
|
||||
|
||||
+78
-61
@@ -24,6 +24,8 @@
|
||||
#include "sharedNetwork/NetworkSetupData.h"
|
||||
#include "UnicodeUtils.h"
|
||||
|
||||
#include "sharedFoundation/CrcConstexpr.hpp"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
ConnectionServerConnection::ConnectionServerConnection(const std::string & a, const unsigned short p) :
|
||||
@@ -62,11 +64,13 @@ void ConnectionServerConnection::onReceive(const Archive::ByteStream & message)
|
||||
|
||||
ri = message.begin();
|
||||
|
||||
if (m.isType("GameClientMessage"))
|
||||
if (m.getType() == constcrc("GameClientMessage"))
|
||||
{
|
||||
GameClientMessage c(ri);
|
||||
Archive::ReadIterator cri = c.getByteStream().begin();
|
||||
GameNetworkMessage cm(cri);
|
||||
|
||||
const uint32 messageType = cm.getType();
|
||||
|
||||
std::vector<NetworkId>::const_iterator i;
|
||||
for (i = c.getDistributionList().begin(); i != c.getDistributionList().end(); ++i)
|
||||
@@ -75,68 +79,81 @@ void ConnectionServerConnection::onReceive(const Archive::ByteStream & message)
|
||||
|
||||
NetworkId const &networkId = (*i);
|
||||
|
||||
if (cm.isType("RequestCategoriesMessage"))
|
||||
{
|
||||
RequestCategoriesMessage message(cri);
|
||||
CustomerServiceServer::getInstance().requestCategories(networkId, message.getLanguage());
|
||||
}
|
||||
else if (cm.isType("ConnectPlayerMessage"))
|
||||
{
|
||||
ConnectPlayerMessage message(cri);
|
||||
CustomerServiceServer::getInstance().requestRegisterCharacter(networkId, this, message.getStationId());
|
||||
}
|
||||
else if (cm.isType("DisconnectPlayerMessage"))
|
||||
{
|
||||
CustomerServiceServer::getInstance().requestUnRegisterCharacter(networkId);
|
||||
}
|
||||
else if (cm.isType("CreateTicketMessage"))
|
||||
{
|
||||
CreateTicketMessage message(cri);
|
||||
switch(messageType) {
|
||||
case constcrc("RequestCategoriesMessage") :
|
||||
{
|
||||
RequestCategoriesMessage message(cri);
|
||||
CustomerServiceServer::getInstance().requestCategories(networkId, message.getLanguage());
|
||||
break;
|
||||
}
|
||||
case constcrc("ConnectPlayerMessage") :
|
||||
{
|
||||
ConnectPlayerMessage message(cri);
|
||||
CustomerServiceServer::getInstance().requestRegisterCharacter(networkId, this, message.getStationId());
|
||||
break;
|
||||
}
|
||||
case constcrc("DisconnectPlayerMessage") :
|
||||
{
|
||||
CustomerServiceServer::getInstance().requestUnRegisterCharacter(networkId);
|
||||
break;
|
||||
}
|
||||
case constcrc("CreateTicketMessage") :
|
||||
{
|
||||
CreateTicketMessage message(cri);
|
||||
|
||||
CustomerServiceServer::getInstance().createTicket(networkId,
|
||||
message.getStationId(), message.getCharacterName(),
|
||||
message.getCategory(), message.getSubCategory(),
|
||||
message.getDetails(), message.getHiddenDetails(),
|
||||
message.getHarassingPlayerName(),
|
||||
message.getLanguage(), message.isBug()
|
||||
);
|
||||
}
|
||||
else if (cm.isType("AppendCommentMessage"))
|
||||
{
|
||||
AppendCommentMessage message(cri);
|
||||
CustomerServiceServer::getInstance().appendComment(networkId, message.getStationId(), message.getCharacterName(), message.getTicketId(), message.getComment());
|
||||
}
|
||||
else if (cm.isType("CancelTicketMessage"))
|
||||
{
|
||||
CancelTicketMessage message(cri);
|
||||
CustomerServiceServer::getInstance().cancelTicket(networkId, message.getStationId(), message.getTicketId(), message.getComment());
|
||||
}
|
||||
else if (cm.isType("GetTicketsMessage"))
|
||||
{
|
||||
GetTicketsMessage message(cri);
|
||||
CustomerServiceServer::getInstance().getTickets(networkId, message.getStationId());
|
||||
}
|
||||
else if (cm.isType("GetCommentsMessage"))
|
||||
{
|
||||
GetCommentsMessage message(cri);
|
||||
CustomerServiceServer::getInstance().getComments(networkId,
|
||||
message.getTicketId());
|
||||
}
|
||||
else if (cm.isType("SearchKnowledgeBaseMessage"))
|
||||
{
|
||||
SearchKnowledgeBaseMessage message(cri);
|
||||
CustomerServiceServer::getInstance().searchKnowledgeBase(networkId, message.getSearchString(), message.getLanguage());
|
||||
}
|
||||
else if (cm.isType("GetArticleMessage"))
|
||||
{
|
||||
GetArticleMessage message(cri);
|
||||
CustomerServiceServer::getInstance().getArticle(networkId, message.getId(), message.getLanguage());
|
||||
}
|
||||
else if (cm.isType("NewTicketActivityMessage"))
|
||||
{
|
||||
NewTicketActivityMessage message(cri);
|
||||
CustomerServiceServer::getInstance().createTicket(networkId,
|
||||
message.getStationId(), message.getCharacterName(),
|
||||
message.getCategory(), message.getSubCategory(),
|
||||
message.getDetails(), message.getHiddenDetails(),
|
||||
message.getHarassingPlayerName(),
|
||||
message.getLanguage(), message.isBug()
|
||||
);
|
||||
break;
|
||||
}
|
||||
case constcrc("AppendCommentMessage") :
|
||||
{
|
||||
AppendCommentMessage message(cri);
|
||||
CustomerServiceServer::getInstance().appendComment(networkId, message.getStationId(), message.getCharacterName(), message.getTicketId(), message.getComment());
|
||||
break;
|
||||
}
|
||||
case constcrc("CancelTicketMessage") :
|
||||
{
|
||||
CancelTicketMessage message(cri);
|
||||
CustomerServiceServer::getInstance().cancelTicket(networkId, message.getStationId(), message.getTicketId(), message.getComment());
|
||||
break;
|
||||
}
|
||||
case constcrc("GetTicketsMessage") :
|
||||
{
|
||||
GetTicketsMessage message(cri);
|
||||
CustomerServiceServer::getInstance().getTickets(networkId, message.getStationId());
|
||||
break;
|
||||
}
|
||||
case constcrc("GetCommentsMessage") :
|
||||
{
|
||||
GetCommentsMessage message(cri);
|
||||
CustomerServiceServer::getInstance().getComments(networkId,
|
||||
message.getTicketId());
|
||||
break;
|
||||
}
|
||||
case constcrc("SearchKnowledgeBaseMessage") :
|
||||
{
|
||||
SearchKnowledgeBaseMessage message(cri);
|
||||
CustomerServiceServer::getInstance().searchKnowledgeBase(networkId, message.getSearchString(), message.getLanguage());
|
||||
break;
|
||||
}
|
||||
case constcrc("GetArticleMessage") :
|
||||
{
|
||||
GetArticleMessage message(cri);
|
||||
CustomerServiceServer::getInstance().getArticle(networkId, message.getId(), message.getLanguage());
|
||||
break;
|
||||
}
|
||||
case constcrc("NewTicketActivityMessage") :
|
||||
{
|
||||
NewTicketActivityMessage message(cri);
|
||||
|
||||
CustomerServiceServer::getInstance().requestNewTicketActivity(networkId, message.getStationId());
|
||||
CustomerServiceServer::getInstance().requestNewTicketActivity(networkId, message.getStationId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+52
-52
@@ -38,7 +38,7 @@ using namespace CSAssist;
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CustomerServiceInterface::ClientInfo::ClientInfo()
|
||||
: m_connection(NULL)
|
||||
: m_connection(nullptr)
|
||||
, m_stationUserId(0)
|
||||
, m_ticketCount(-1)
|
||||
, m_pendingTicketCount(0)
|
||||
@@ -71,10 +71,10 @@ CustomerServiceInterface::~CustomerServiceInterface()
|
||||
delete m_japaneseCategoryList;
|
||||
|
||||
delete m_clientConnectionMap;
|
||||
m_clientConnectionMap = NULL;
|
||||
m_clientConnectionMap = nullptr;
|
||||
|
||||
delete m_suidToNetworkIdMap;
|
||||
m_suidToNetworkIdMap = NULL;
|
||||
m_suidToNetworkIdMap = nullptr;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@@ -97,8 +97,8 @@ void CustomerServiceInterface::OnConnectCSAssist(
|
||||
}
|
||||
|
||||
m_connectionToBackEndEstablised = true;
|
||||
m_englishCategoryTrack = requestGetIssueHierarchy(NULL, Unicode::narrowToWide("Default").data(), Unicode::narrowToWide("en").data());;
|
||||
m_japaneseCategoryTrack = requestGetIssueHierarchy(NULL, Unicode::narrowToWide("Default").data(), Unicode::narrowToWide("ja").data());;
|
||||
m_englishCategoryTrack = requestGetIssueHierarchy(nullptr, Unicode::narrowToWide("Default").data(), Unicode::narrowToWide("en").data());;
|
||||
m_japaneseCategoryTrack = requestGetIssueHierarchy(nullptr, Unicode::narrowToWide("Default").data(), Unicode::narrowToWide("ja").data());;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ void CustomerServiceInterface::OnConnectRejectedCSAssist(const CSAssistGameAPITr
|
||||
|
||||
void CustomerServiceInterface::parseIssueChild(CategoryList & categoryList, xmlNodePtr childPtr)
|
||||
{
|
||||
static CustomerServiceCategory *currentCategory = NULL;
|
||||
static CustomerServiceCategory *currentCategory = nullptr;
|
||||
xmlNodePtr child = childPtr->children;
|
||||
|
||||
//start element
|
||||
@@ -142,19 +142,19 @@ void CustomerServiceInterface::parseIssueChild(CategoryList & categoryList, xmlN
|
||||
|
||||
val = reinterpret_cast<char *>(xmlGetProp(childPtr, (const unsigned char *)"isBugType"));
|
||||
|
||||
bool const isBugType = (val != NULL) && (strcmp(val, "true") == 0);
|
||||
bool const isBugType = (val != nullptr) && (strcmp(val, "true") == 0);
|
||||
|
||||
// Check for service type
|
||||
|
||||
val = reinterpret_cast<char *>(xmlGetProp(childPtr, (const unsigned char *)"isServiceType"));
|
||||
|
||||
bool const isServiceType = (val != NULL) && (strcmp(val, "true") == 0);
|
||||
bool const isServiceType = (val != nullptr) && (strcmp(val, "true") == 0);
|
||||
|
||||
// Check if valid
|
||||
|
||||
val = reinterpret_cast<char *>(xmlGetProp(childPtr, (const unsigned char *)"invalid"));
|
||||
|
||||
bool const invalid = (val != NULL) && (strcmp(val, "true") == 0);
|
||||
bool const invalid = (val != nullptr) && (strcmp(val, "true") == 0);
|
||||
|
||||
if (!invalid)
|
||||
{
|
||||
@@ -187,9 +187,9 @@ void CustomerServiceInterface::parseIssueChild(CategoryList & categoryList, xmlN
|
||||
}
|
||||
}
|
||||
|
||||
while (child != NULL)
|
||||
while (child != nullptr)
|
||||
{
|
||||
if (child->name != NULL)
|
||||
if (child->name != nullptr)
|
||||
{
|
||||
parseIssueChild(categoryList, child);
|
||||
}
|
||||
@@ -204,7 +204,7 @@ void CustomerServiceInterface::parseIssueChild(CategoryList & categoryList, xmlN
|
||||
if (currentCategory)
|
||||
{
|
||||
delete currentCategory;
|
||||
currentCategory = NULL;
|
||||
currentCategory = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,13 +215,13 @@ void CustomerServiceInterface::parseIssueChild(CategoryList & categoryList, xmlN
|
||||
|
||||
void CustomerServiceInterface::parseIssueHierarchy(CategoryList & categoryList, Unicode::String const & xmlData)
|
||||
{
|
||||
xmlDocPtr xmlInfo = NULL;
|
||||
xmlDocPtr xmlInfo = nullptr;
|
||||
Unicode::UTF8String xmlDataUtf8(Unicode::wideToUTF8(xmlData));
|
||||
|
||||
if ((xmlInfo = xmlParseMemory(xmlDataUtf8.c_str(), xmlDataUtf8.length())) != NULL)
|
||||
if ((xmlInfo = xmlParseMemory(xmlDataUtf8.c_str(), xmlDataUtf8.length())) != nullptr)
|
||||
{
|
||||
xmlNodePtr xmlCurrent = xmlDocGetRootElement(xmlInfo);
|
||||
if (xmlCurrent != NULL)
|
||||
if (xmlCurrent != nullptr)
|
||||
{
|
||||
parseIssueChild(categoryList, xmlCurrent);
|
||||
}
|
||||
@@ -247,7 +247,7 @@ void CustomerServiceInterface::OnGetIssueHierarchy(
|
||||
return;
|
||||
}
|
||||
|
||||
if (hierarchyBody != NULL)
|
||||
if (hierarchyBody != nullptr)
|
||||
{
|
||||
if (track == m_englishCategoryTrack)
|
||||
{
|
||||
@@ -266,7 +266,7 @@ void CustomerServiceInterface::OnGetIssueHierarchy(
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("CSServer", ("ERROR: NULL hierarchy returned from platform...why did this happen?", track, modifyData, result, getErrorString(result)));
|
||||
LOG("CSServer", ("ERROR: nullptr hierarchy returned from platform...why did this happen?", track, modifyData, result, getErrorString(result)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,9 +282,9 @@ void CustomerServiceInterface::OnCreateTicket(
|
||||
CreateTicketResponseMessage message(result, ticket);
|
||||
const NetworkId *tmpNetworkId = reinterpret_cast<const NetworkId *>(userData);
|
||||
|
||||
LOG("CSServer", ("OnCreateTicket() track(%i) result(%i) (%s) networkId(%s) ticketId(%i)", track, result, getErrorString(result), (tmpNetworkId != NULL) ? tmpNetworkId->getValueString().c_str() : "NA", ticket));
|
||||
LOG("CSServer", ("OnCreateTicket() track(%i) result(%i) (%s) networkId(%s) ticketId(%i)", track, result, getErrorString(result), (tmpNetworkId != nullptr) ? tmpNetworkId->getValueString().c_str() : "NA", ticket));
|
||||
|
||||
if (tmpNetworkId != NULL)
|
||||
if (tmpNetworkId != nullptr)
|
||||
{
|
||||
if (result == CSASSIST_RESULT_SUCCESS)
|
||||
{
|
||||
@@ -296,7 +296,7 @@ void CustomerServiceInterface::OnCreateTicket(
|
||||
sendToClient(*tmpNetworkId, message);
|
||||
|
||||
delete tmpNetworkId;
|
||||
tmpNetworkId = NULL;
|
||||
tmpNetworkId = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,14 +312,14 @@ void CustomerServiceInterface::OnAppendTicketComment(
|
||||
AppendCommentResponseMessage message(result, ticket);
|
||||
const NetworkId *tmpNetworkId = reinterpret_cast<const NetworkId *>(userData);
|
||||
|
||||
LOG("CSServer", ("OnAppendTicketComment() track(%i) result(%i) (%s) networkId(%s) ticketId(%i)", track, result, getErrorString(result), (tmpNetworkId != NULL) ? tmpNetworkId->getValueString().c_str() : "NA", ticket));
|
||||
LOG("CSServer", ("OnAppendTicketComment() track(%i) result(%i) (%s) networkId(%s) ticketId(%i)", track, result, getErrorString(result), (tmpNetworkId != nullptr) ? tmpNetworkId->getValueString().c_str() : "NA", ticket));
|
||||
|
||||
if (tmpNetworkId != NULL)
|
||||
if (tmpNetworkId != nullptr)
|
||||
{
|
||||
sendToClient(*tmpNetworkId, message);
|
||||
|
||||
delete tmpNetworkId;
|
||||
tmpNetworkId = NULL;
|
||||
tmpNetworkId = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,9 +335,9 @@ void CustomerServiceInterface::OnCancelTicket(
|
||||
CancelTicketResponseMessage message(result, ticket);
|
||||
const NetworkId *tmpNetworkId = reinterpret_cast<const NetworkId *>(userData);
|
||||
|
||||
LOG("CSServer", ("OnCancelTicket() track(%i) result(%i) (%s) networkId(%s) ticketId(%i)", track, result, getErrorString(result), (tmpNetworkId != NULL) ? tmpNetworkId->getValueString().c_str() : "NA", ticket));
|
||||
LOG("CSServer", ("OnCancelTicket() track(%i) result(%i) (%s) networkId(%s) ticketId(%i)", track, result, getErrorString(result), (tmpNetworkId != nullptr) ? tmpNetworkId->getValueString().c_str() : "NA", ticket));
|
||||
|
||||
if (tmpNetworkId != NULL)
|
||||
if (tmpNetworkId != nullptr)
|
||||
{
|
||||
if (result == CSASSIST_RESULT_SUCCESS)
|
||||
{
|
||||
@@ -347,7 +347,7 @@ void CustomerServiceInterface::OnCancelTicket(
|
||||
sendToClient(*tmpNetworkId, message);
|
||||
|
||||
delete tmpNetworkId;
|
||||
tmpNetworkId = NULL;
|
||||
tmpNetworkId = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -378,9 +378,9 @@ void CustomerServiceInterface::OnGetTicketByCharacter(
|
||||
GetTicketsResponseMessage message(result, totalNumber, tickets);
|
||||
const NetworkId *tmpNetworkId = reinterpret_cast<const NetworkId *>(userData);
|
||||
|
||||
LOG("CSServer", ("OnGetTicketByCharacter() track(%i) result(%i) (%s) networkId(%s) totalNumber(%i) numberReturned(%i)", track, result, getErrorString(result), (tmpNetworkId != NULL) ? tmpNetworkId->getValueString().c_str() : "NA", totalNumber, numberReturned));
|
||||
LOG("CSServer", ("OnGetTicketByCharacter() track(%i) result(%i) (%s) networkId(%s) totalNumber(%i) numberReturned(%i)", track, result, getErrorString(result), (tmpNetworkId != nullptr) ? tmpNetworkId->getValueString().c_str() : "NA", totalNumber, numberReturned));
|
||||
|
||||
if (tmpNetworkId != NULL)
|
||||
if (tmpNetworkId != nullptr)
|
||||
{
|
||||
// Save the number of tickets this player has
|
||||
|
||||
@@ -396,7 +396,7 @@ void CustomerServiceInterface::OnGetTicketByCharacter(
|
||||
sendToClient(*tmpNetworkId, message);
|
||||
|
||||
delete tmpNetworkId;
|
||||
tmpNetworkId = NULL;
|
||||
tmpNetworkId = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -423,14 +423,14 @@ void CustomerServiceInterface::OnGetTicketComments(
|
||||
|
||||
const NetworkId *tmpNetworkId = reinterpret_cast<const NetworkId *>(userData);
|
||||
|
||||
LOG("CSServer", ("OnGetTicketComments() track(%i) result(%i) (%s) networkId(%s) numberRead(%i)", track, result, getErrorString(result), (tmpNetworkId != NULL) ? tmpNetworkId->getValueString().c_str() : "NA", numberRead));
|
||||
LOG("CSServer", ("OnGetTicketComments() track(%i) result(%i) (%s) networkId(%s) numberRead(%i)", track, result, getErrorString(result), (tmpNetworkId != nullptr) ? tmpNetworkId->getValueString().c_str() : "NA", numberRead));
|
||||
|
||||
if (tmpNetworkId != NULL)
|
||||
if (tmpNetworkId != nullptr)
|
||||
{
|
||||
sendToClient(*tmpNetworkId, message);
|
||||
|
||||
delete tmpNetworkId;
|
||||
tmpNetworkId = NULL;
|
||||
tmpNetworkId = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -455,14 +455,14 @@ void CustomerServiceInterface::OnSearchKB(
|
||||
SearchKnowledgeBaseResponseMessage message(result, searchResultsVector);
|
||||
const NetworkId *tmpNetworkId = reinterpret_cast<const NetworkId *>(userData);
|
||||
|
||||
LOG("CSServer", ("OnSearchKB() track(%i) result(%i) (%s) networkId(%s) numberRead(%i)", track, result, getErrorString(result), (tmpNetworkId != NULL) ? tmpNetworkId->getValueString().c_str() : "NA", numberRead));
|
||||
LOG("CSServer", ("OnSearchKB() track(%i) result(%i) (%s) networkId(%s) numberRead(%i)", track, result, getErrorString(result), (tmpNetworkId != nullptr) ? tmpNetworkId->getValueString().c_str() : "NA", numberRead));
|
||||
|
||||
if (tmpNetworkId != NULL)
|
||||
if (tmpNetworkId != nullptr)
|
||||
{
|
||||
sendToClient(*tmpNetworkId, message);
|
||||
|
||||
delete tmpNetworkId;
|
||||
tmpNetworkId = NULL;
|
||||
tmpNetworkId = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -482,12 +482,12 @@ void CustomerServiceInterface::OnGetKBArticle(
|
||||
{
|
||||
GetArticleResponseMessage message(result, Unicode::String(articleBody));
|
||||
const NetworkId *tmpNetworkId = reinterpret_cast<const NetworkId *>(userData);
|
||||
if (tmpNetworkId != NULL)
|
||||
if (tmpNetworkId != nullptr)
|
||||
{
|
||||
sendToClient(*tmpNetworkId, message);
|
||||
|
||||
delete tmpNetworkId;
|
||||
tmpNetworkId = NULL;
|
||||
tmpNetworkId = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -501,7 +501,7 @@ void CustomerServiceInterface::OnIssueHierarchyChanged(
|
||||
{
|
||||
LOG("CSServer", ("OnIssueHierarchyChanged()"));
|
||||
|
||||
requestGetIssueHierarchy(NULL, version, language);
|
||||
requestGetIssueHierarchy(nullptr, version, language);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@@ -512,9 +512,9 @@ void CustomerServiceInterface::OnNewTicketActivity(const CSAssistGameAPITrack tr
|
||||
|
||||
const NetworkId *tmpNetworkId = reinterpret_cast<const NetworkId *>(userData);
|
||||
|
||||
LOG("CSServer", ("OnNewTicketActivity() track(%i) result(%i) (%s) networkId(%s) activity(%s) ticket count(%i)", track, result, getErrorString(result), (tmpNetworkId != NULL) ? tmpNetworkId->getValueString().c_str() : "NA", NewActivityFlag ? "yes" : "no", HasTickets));
|
||||
LOG("CSServer", ("OnNewTicketActivity() track(%i) result(%i) (%s) networkId(%s) activity(%s) ticket count(%i)", track, result, getErrorString(result), (tmpNetworkId != nullptr) ? tmpNetworkId->getValueString().c_str() : "NA", NewActivityFlag ? "yes" : "no", HasTickets));
|
||||
|
||||
if (tmpNetworkId != NULL)
|
||||
if (tmpNetworkId != nullptr)
|
||||
{
|
||||
// Save the number of tickets this player has
|
||||
|
||||
@@ -530,7 +530,7 @@ void CustomerServiceInterface::OnNewTicketActivity(const CSAssistGameAPITrack tr
|
||||
sendToClient(*tmpNetworkId, message);
|
||||
|
||||
delete tmpNetworkId;
|
||||
tmpNetworkId = NULL;
|
||||
tmpNetworkId = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -540,12 +540,12 @@ void CustomerServiceInterface::OnMarkTicketRead(const CSAssistGameAPITrack track
|
||||
{
|
||||
const NetworkId *tmpNetworkId = reinterpret_cast<const NetworkId *>(userData);
|
||||
|
||||
LOG("CSServer", ("OnMarkTicketRead() track(%i) result(%i) (%s) networkId(%s)", track, result, getErrorString(result), (tmpNetworkId != NULL) ? tmpNetworkId->getValueString().c_str() : "NA"));
|
||||
LOG("CSServer", ("OnMarkTicketRead() track(%i) result(%i) (%s) networkId(%s)", track, result, getErrorString(result), (tmpNetworkId != nullptr) ? tmpNetworkId->getValueString().c_str() : "NA"));
|
||||
|
||||
if (tmpNetworkId != NULL)
|
||||
if (tmpNetworkId != nullptr)
|
||||
{
|
||||
delete tmpNetworkId;
|
||||
tmpNetworkId = NULL;
|
||||
tmpNetworkId = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -575,16 +575,16 @@ void CustomerServiceInterface::OnRegisterCharacter(const CSAssistGameAPITrack tr
|
||||
{
|
||||
const NetworkId *tmpNetworkId = reinterpret_cast<const NetworkId *>(userData);
|
||||
|
||||
LOG("CSServer", ("OnRegisterCharacter() track(%i) result(%i) (%s) networkId(%s)", track, result, getErrorString(result), (tmpNetworkId != NULL) ? tmpNetworkId->getValueString().c_str() : "NA"));
|
||||
LOG("CSServer", ("OnRegisterCharacter() track(%i) result(%i) (%s) networkId(%s)", track, result, getErrorString(result), (tmpNetworkId != nullptr) ? tmpNetworkId->getValueString().c_str() : "NA"));
|
||||
|
||||
if (tmpNetworkId != NULL)
|
||||
if (tmpNetworkId != nullptr)
|
||||
{
|
||||
ConnectPlayerResponseMessage message(result);
|
||||
|
||||
sendToClient(*tmpNetworkId, message);
|
||||
|
||||
delete tmpNetworkId;
|
||||
tmpNetworkId = NULL;
|
||||
tmpNetworkId = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -594,9 +594,9 @@ void CustomerServiceInterface::OnUnRegisterCharacter(const CSAssistGameAPITrack
|
||||
{
|
||||
const NetworkId *tmpNetworkId = reinterpret_cast<const NetworkId *>(userData);
|
||||
|
||||
LOG("CSServer", ("OnUnRegisterCharacter() track(%i) result(%i) (%s) networkId(%s)", track, result, getErrorString(result), (tmpNetworkId != NULL) ? tmpNetworkId->getValueString().c_str() : "NA"));
|
||||
LOG("CSServer", ("OnUnRegisterCharacter() track(%i) result(%i) (%s) networkId(%s)", track, result, getErrorString(result), (tmpNetworkId != nullptr) ? tmpNetworkId->getValueString().c_str() : "NA"));
|
||||
|
||||
if (tmpNetworkId != NULL)
|
||||
if (tmpNetworkId != nullptr)
|
||||
{
|
||||
// If the player was successfully unregistered, remove the local cached reference
|
||||
|
||||
@@ -606,7 +606,7 @@ void CustomerServiceInterface::OnUnRegisterCharacter(const CSAssistGameAPITrack
|
||||
}
|
||||
|
||||
delete tmpNetworkId;
|
||||
tmpNetworkId = NULL;
|
||||
tmpNetworkId = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -708,7 +708,7 @@ void CustomerServiceInterface::sendToClient(const NetworkId &player, const GameN
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("CSServer", ("sendToClient() Connection is NULL: networkId(%s) cmdName(%s)", player.getValueString().c_str(), message.getCmdName().c_str()));
|
||||
LOG("CSServer", ("sendToClient() Connection is nullptr: networkId(%s) cmdName(%s)", player.getValueString().c_str(), message.getCmdName().c_str()));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -779,7 +779,7 @@ void CustomerServiceInterface::requestUnRegisterCharacter(const NetworkId &reque
|
||||
LOG("CSServer", ("requestUnRegisterCharacter() networkId(%s) suid(%i)", requester.getValueString().c_str(), suid));
|
||||
|
||||
NetworkId *tmpNetworkId = new NetworkId(requester);
|
||||
CSAssistGameAPI::requestUnRegisterCharacter(reinterpret_cast<const void *>(tmpNetworkId), suid, NULL);
|
||||
CSAssistGameAPI::requestUnRegisterCharacter(reinterpret_cast<const void *>(tmpNetworkId), suid, nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+15
-15
@@ -49,7 +49,7 @@ namespace CustomerServiceServerNamespace
|
||||
|
||||
using namespace CustomerServiceServerNamespace;
|
||||
|
||||
CustomerServiceServer *CustomerServiceServer::m_instance = NULL;
|
||||
CustomerServiceServer *CustomerServiceServer::m_instance = nullptr;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@@ -83,12 +83,12 @@ CustomerServiceServer::PendingTicket::PendingTicket()
|
||||
|
||||
CustomerServiceServer::CustomerServiceServer() :
|
||||
m_callback(new MessageDispatch::Callback),
|
||||
m_centralServerConnection(NULL),
|
||||
m_centralServerConnection(nullptr),
|
||||
m_connectionServerSet(new ConnectionServerSet),
|
||||
m_done(false),
|
||||
m_csInterface(ConfigCustomerServiceServer::getCustomerServiceServerAddress(), ConfigCustomerServiceServer::getCustomerServiceServerPort(), ConfigCustomerServiceServer::getRequestTimeoutSeconds()),
|
||||
m_gameServerService(NULL),
|
||||
m_chatServerService(NULL),
|
||||
m_gameServerService(nullptr),
|
||||
m_chatServerService(nullptr),
|
||||
m_nextSequenceId(0),
|
||||
m_pendingTicketList(new PendingTicketList)
|
||||
{
|
||||
@@ -103,7 +103,7 @@ m_pendingTicketList(new PendingTicketList)
|
||||
m_callback->connect(*this, &CustomerServiceServer::onEnumerateServers);
|
||||
|
||||
char text[512];
|
||||
snprintf(text, sizeof(text), "CustomerServiceServer() - ServerName(%s) ServerPort(%i) GameCode(%s)", ConfigCustomerServiceServer::getCustomerServiceServerAddress(), ConfigCustomerServiceServer::getCustomerServiceServerPort(), ConfigCustomerServiceServer::getGameCode());
|
||||
snprintf(text, 512, "CustomerServiceServer() - ServerName(%s) ServerPort(%i) GameCode(%s)", ConfigCustomerServiceServer::getCustomerServiceServerAddress(), ConfigCustomerServiceServer::getCustomerServiceServerPort(), ConfigCustomerServiceServer::getGameCode());
|
||||
REPORT_LOG(true, ("%s\n", text));
|
||||
LOG("CSServer", ("%s", text));
|
||||
|
||||
@@ -113,7 +113,7 @@ m_pendingTicketList(new PendingTicketList)
|
||||
|
||||
m_csInterface.setMaxPacketsPerSecond(ConfigCustomerServiceServer::getMaxPacketsPerSecond());
|
||||
|
||||
m_csInterface.connectCSAssist(NULL,
|
||||
m_csInterface.connectCSAssist(nullptr,
|
||||
Unicode::narrowToWide(ConfigCustomerServiceServer::getGameCode()).data(),
|
||||
Unicode::narrowToWide(ConfigCustomerServiceServer::getClusterName()).data());
|
||||
|
||||
@@ -148,19 +148,19 @@ CustomerServiceServer::~CustomerServiceServer()
|
||||
m_centralServerConnection->disconnect();
|
||||
|
||||
delete m_callback;
|
||||
m_callback = NULL;
|
||||
m_callback = nullptr;
|
||||
|
||||
delete m_connectionServerSet;
|
||||
m_connectionServerSet = NULL;
|
||||
m_connectionServerSet = nullptr;
|
||||
|
||||
delete m_gameServerService;
|
||||
m_gameServerService = NULL;
|
||||
m_gameServerService = nullptr;
|
||||
|
||||
delete m_chatServerService;
|
||||
m_chatServerService = NULL;
|
||||
m_chatServerService = nullptr;
|
||||
|
||||
delete m_pendingTicketList;
|
||||
m_pendingTicketList = NULL;
|
||||
m_pendingTicketList = nullptr;
|
||||
|
||||
MetricsManager::remove();
|
||||
delete s_customerServiceServerMetricsData;
|
||||
@@ -233,7 +233,7 @@ void CustomerServiceServer::update()
|
||||
|
||||
CustomerServiceServer &CustomerServiceServer::getInstance()
|
||||
{
|
||||
if (m_instance == NULL)
|
||||
if (m_instance == nullptr)
|
||||
{
|
||||
m_instance = new CustomerServiceServer;
|
||||
}
|
||||
@@ -405,7 +405,7 @@ void CustomerServiceServer::getTickets(
|
||||
|
||||
NetworkId *tmpNetworkId = new NetworkId(requester);
|
||||
m_csInterface.requestGetTicketByCharacter(
|
||||
reinterpret_cast<const void *>(tmpNetworkId), suid, NULL,
|
||||
reinterpret_cast<const void *>(tmpNetworkId), suid, nullptr,
|
||||
start, count, markAsRead);
|
||||
}
|
||||
|
||||
@@ -475,7 +475,7 @@ void CustomerServiceServer::requestNewTicketActivity(const NetworkId &requester,
|
||||
|
||||
NetworkId *tmpNetworkId = new NetworkId(requester);
|
||||
|
||||
m_csInterface.requestNewTicketActivity(reinterpret_cast<const void *>(tmpNetworkId), suid, NULL);
|
||||
m_csInterface.requestNewTicketActivity(reinterpret_cast<const void *>(tmpNetworkId), suid, nullptr);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@@ -497,7 +497,7 @@ void CustomerServiceServer::requestRegisterCharacter(const NetworkId &requester,
|
||||
LOG("CSServer", ("CustomerServiceInterface::requestRegisterCharacter() - networkId(%s) suid(%i)", requester.getValueString().c_str(), suid));
|
||||
|
||||
NetworkId *tmpNetworkId = new NetworkId(requester);
|
||||
m_csInterface.requestRegisterCharacter(reinterpret_cast<const void *>(tmpNetworkId), suid, NULL, 0);
|
||||
m_csInterface.requestRegisterCharacter(reinterpret_cast<const void *>(tmpNetworkId), suid, nullptr, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,3 +78,7 @@ target_link_libraries(LogServer
|
||||
unicodeArchive
|
||||
${CMAKE_DL_LIBS}
|
||||
)
|
||||
|
||||
if(${BUILD_MULODI_LIB})
|
||||
target_link_libraries(LogServer mulodi)
|
||||
endif()
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user