diff --git a/src/engine/build/linux/platformDefs.mak b/src/engine/build/linux/platformDefs.mak deleted file mode 100644 index 059c7642d..000000000 --- a/src/engine/build/linux/platformDefs.mak +++ /dev/null @@ -1,3 +0,0 @@ -PLATFORM =linux -#PLATFORM_DEFINES =-DLINUX -DJNI_IBM_JAVA -PLATFORM_DEFINES =-DLINUX diff --git a/src/engine/client/application/Miff/src/linux/BISON.HAI b/src/engine/client/application/Miff/src/linux/BISON.HAI deleted file mode 100644 index 999b55591..000000000 --- a/src/engine/client/application/Miff/src/linux/BISON.HAI +++ /dev/null @@ -1,334 +0,0 @@ - -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; -} - -$ diff --git a/src/engine/client/application/Miff/src/linux/InputFileHandler.cpp b/src/engine/client/application/Miff/src/linux/InputFileHandler.cpp deleted file mode 100644 index ead23d7c9..000000000 --- a/src/engine/client/application/Miff/src/linux/InputFileHandler.cpp +++ /dev/null @@ -1,136 +0,0 @@ -//=========================================================================== -// -// 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(unlink(filename)); -} - - -//=========================================================================== -//============================================================ End-of-file == -//=========================================================================== - diff --git a/src/engine/client/application/Miff/src/linux/InputFileHandler.h b/src/engine/client/application/Miff/src/linux/InputFileHandler.h deleted file mode 100644 index 9e4734fe5..000000000 --- a/src/engine/client/application/Miff/src/linux/InputFileHandler.h +++ /dev/null @@ -1,71 +0,0 @@ -#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__ diff --git a/src/engine/client/application/Miff/src/linux/OutputFileHandler.cpp b/src/engine/client/application/Miff/src/linux/OutputFileHandler.cpp deleted file mode 100644 index 1c8ffe96f..000000000 --- a/src/engine/client/application/Miff/src/linux/OutputFileHandler.cpp +++ /dev/null @@ -1,164 +0,0 @@ -//=========================================================================== -// -// 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; -} - -//=========================================================================== - diff --git a/src/engine/client/application/Miff/src/linux/OutputFileHandler.h b/src/engine/client/application/Miff/src/linux/OutputFileHandler.h deleted file mode 100644 index 5f4eaf580..000000000 --- a/src/engine/client/application/Miff/src/linux/OutputFileHandler.h +++ /dev/null @@ -1,80 +0,0 @@ -#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__ diff --git a/src/engine/client/application/Miff/src/linux/bison.simple b/src/engine/client/application/Miff/src/linux/bison.simple deleted file mode 100644 index 5f8f386e6..000000000 --- a/src/engine/client/application/Miff/src/linux/bison.simple +++ /dev/null @@ -1,698 +0,0 @@ -/* -*-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 -#else /* not sparc */ -#if defined (MSDOS) && !defined (__TURBOC__) -#include -#else /* not MSDOS, or __TURBOC__ */ -#if defined(_AIX) -#include - #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; -} diff --git a/src/engine/client/application/Miff/src/linux/mIFF.dox b/src/engine/client/application/Miff/src/linux/mIFF.dox deleted file mode 100644 index 4c46d600b..000000000 --- a/src/engine/client/application/Miff/src/linux/mIFF.dox +++ /dev/null @@ -1,62 +0,0 @@ -// NOTE: this makes it more convinient for me to make the help screen fancier... -// blah... not that anybody cares... - -printf("\ -Usage:\n\ - mIFF {-%c |--%s=}\n\ - [{-%c |--%s=} | {-%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 ,--%s=\n\ - [required] specifies the input path for IFF source file.\n", SNAME_INPUT_FILE, LNAME_INPUT_FILE); -printf("\ - -%c ,--%s=\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 \":\"\n\ - #pragma directory \"\"\n\ - #pragma filename \"\"\n\ - #pragma 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); diff --git a/src/engine/client/application/Miff/src/linux/miff.cpp b/src/engine/client/application/Miff/src/linux/miff.cpp deleted file mode 100644 index 032f56407..000000000 --- a/src/engine/client/application/Miff/src/linux/miff.cpp +++ /dev/null @@ -1,958 +0,0 @@ -//=========================================================================== -// -// 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 // for memset() -#include // FILE stuff -#include // for getcwd() -#include // for tolower() - -//================================================= 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[8]; // 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[512]; - -// switches to be sent to mIFF Compiler -char sourceBuffer[bufferSize]; -char outFileName[512]; // 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[256]; -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.argc = argc; - SetupSharedFoundationData.argv = argv; - SetupSharedFoundation::install (SetupSharedFoundationData); - - SetupSharedCompression::install(); - - SetupSharedFile::install(false); - - TreeFile::addSearchAbsolute(0); - TreeFile::addSearchPath (".", 0); - - SetupSharedFoundation::callbackWithExceptionHandling(callbackFunction); - SetupSharedFoundation::remove(); - - SetupSharedThread::remove(); - return static_cast (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(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 -nostdinc -nostdinc++ -x c++ -pedantic -Wall -dD -H %s 'miff.$$$'", sourceName); - } - else if (!useCCCP && !verboseMode) - { - sprintf(shellCommand, "cpp -nostdinc -nostdinc++ -x c++ -pedantic -Wall -dD %s 'miff.$$$'", sourceName); - } - else if (useCCCP && verboseMode) - { - sprintf(shellCommand, "cccp -nostdinc -nostdinc++ -x c++ -pedantic -Wall -dD -H %s 'miff.$$$'", sourceName); - } - else - sprintf(shellCommand, "cccp -nostdinc -nostdinc++ -x c++ -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(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 == -//=========================================================================== - diff --git a/src/engine/client/application/Miff/src/linux/parser.lex b/src/engine/client/application/Miff/src/linux/parser.lex deleted file mode 100644 index 3989ec880..000000000 --- a/src/engine/client/application/Miff/src/linux/parser.lex +++ /dev/null @@ -1,517 +0,0 @@ -%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 -#include - -/*--------------------------------** -** 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(); - } - -<> { - /* 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[256]; -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); -} diff --git a/src/engine/client/application/Miff/src/linux/parser.yac b/src/engine/client/application/Miff/src/linux/parser.yac deleted file mode 100644 index 8412cbea6..000000000 --- a/src/engine/client/application/Miff/src/linux/parser.yac +++ /dev/null @@ -1,1003 +0,0 @@ -%expect 1 -%{ -/*-----------------------------------------------------------------------------** -** FILE: parser.yac ** -** (c) 1998 - Bootprint GTInteractive ** -** ** -** DESCRIPTION: parser for mIFF ** -** ** -** AUTHOR: Hideki Ikeda ** -** HISTORY: ** -** ** -** Notes: companion to parser.lex ** -**-----------------------------------------------------------------------------*/ - -/*---------------** -** C declaration ** -**---------------*/ -#pragma warning (disable: 4005) /* macro redefinition - bision.simple redefines alloca() */ -#pragma warning (disable: 4127) /* conditional expression is constant - in bison.simple */ -#pragma warning (disable: 4131) /* uses old-style declarator - mostly in bison.simple */ -#pragma warning (disable: 4244) /* possible loss of data due to conversion from one type to another - bision.simple */ -#pragma warning (disable: 4701) /* local variable ('yyval' in first case) may be used without having been initialed */ -// #pragma warning (disable: 6311) /* compiler malloc.h: see previous definition of alloca() */ - -/* include files */ -#include /* for pow() and stuff */ -#include -#include /* for toupper() */ -#include /* for wide character (16bit) strings */ - -#include - -/*----------------------------------------------------------------** -** debug options, turn these on to TEST ONLY! don't leave these ** -** switch on, it's annoying as hell in console mode! ** -** NOTE: if you turn YYERROR_VERBOSE on, you MUST have YYDEBUG! ** -** IMHO, it's better off using primitive printf() method to debug ** -**----------------------------------------------------------------*/ -#define YYERROR_VERBOSE 1 -#define YYDEBUG 1 - -#undef YYERROR_VERBOSE -#undef YYDEBUG - -/* external prototype declaration */ -extern void MIFFMessage(char *message); /* found in mIFF.CPP */ -extern char * MIFFallocString(int sizeOfString); -extern void MIFFfreeString(char * pointer); -extern int validateTargetFilename(char *fname, int fnameSize); /* found mIFF.CPP */ -extern void yyerror(char *); -extern int yylex(void); -extern void setCurrentLineNumber(int lineNum, char * fileName, int mysteryNum); -extern void MIFFSetIFFName(const char *newFileName); -extern void MIFFinsertForm(const char *formName); -extern void MIFFinsertChunk(const char *chunkName); -extern void MIFFinsertChunkData(void * buffer, unsigned bufferSize); -extern int MIFFloadRawData(char *fname, void * buffer, unsigned maxBufferSize); -extern void MIFFexitChunk(void); -extern void MIFFexitForm(void); -extern unsigned long MIFFgetLabelHash(char *inputStream); - -/* local prototype declaration */ -void initGlobalVars(void); -void checkArgs(void); -void checkPragmas(void); - -void includeBinary(char *fname); - -void write32(long i32); -void write16(short i16); -void write8(char i8); -void writeU32(unsigned long ui32); -void writeU16(unsigned short ui16); -void writeU8(unsigned char u8); -void writeDouble(double d); -void writeFloat(float f); -void writeString(char *s); -void writeString16(char *s); -void writeLabelHash(char *s); -void writeTag(char *tag); -void writeSize(unsigned long size); -void writeData(void *dataPtr, unsigned dataSize); - -void initSymTable(void); -long searchEnumSymbolTable(char *symString); -long getEnumValue(long index); -void addEnumSymbol(char *symString, long value); -void parseESCstring(char *str, char *targetBuffer, int sizeOfTarget); - -/*----------------------------------------------** -** Global vars used by all functions and parser ** -**----------------------------------------------*/ -char err_msg[256]; -int errorFlag; - -/*-----------------------------------------------------------------------------** -** NOTE: this symbol table is ONLY used to construct symbols for enum table!!! ** -**-----------------------------------------------------------------------------*/ -#define MAX_SYMBOLS (1024) /* total number of symbols it can grow to... */ -#define MAX_SYMCHARS (128) /* I label thee insane if you have more the 128 char for your variable! */ -struct structEnumSymTableType -{ - char symbol[MAX_SYMCHARS]; - long value; -}; - -struct structEnumSymTableType symbolEnumTable[MAX_SYMBOLS]; -unsigned currSymIndex = 0; -long lastValue = -1; -char id[MAX_SYMCHARS]; - -/* vars set by pragmas */ -#define MAX_BUFFER_SIZE (16 * 1024 * 1024) -#define MAX_STRING_SIZE (512) -char drive[8]; -char directory[MAX_STRING_SIZE/2]; -char filename[MAX_STRING_SIZE/2]; -char extension[8]; -char outFileName[MAX_STRING_SIZE]; -int usePragmas; - -/*------------------------------------------------------------------------** -** The IRONY of these so-called temp-data's that are GLOBAL is ** -** that they aren't temp if functions called within are also using it ** -** This really gives me the creeps and goosbumps! DOWN with GLOBAL VARS! ** -**------------------------------------------------------------------------*/ -int iTemp, jTemp; -char byteTemp; -short wordTemp; -char tempStr[MAX_STRING_SIZE]; - -%} - -/*--------------------** -** Bison declarations ** -**--------------------*/ -%union { - long ltype; - double dtype; - char *stype; - char chtype; - - int tokentype; -} - -/*------------------------------------------------** -** define tokens defined in lex file ** -** NOTE: all LITERALs are treated as signed long ** -** all FLOAT_LITERALs are treated as double ** -**------------------------------------------------*/ -%token CHAR_LIT -%token STR_LIT -%token IDENTIFIER -%token LIT -%token FLOAT_LIT - -/* all command tokens are type */ -%token INT32 -%token INT16 -%token INT8 -%token UINT32 -%token UINT16 -%token UINT8 -%token FLOAT -%token DOUBLE -%token STRING -%token WSTRING -%token LABELHASH - -%token FORM -%token CHUNK -%token PRAGMA -%token PRAGMA_DRIVE PRAGMA_DIR PRAGMA_FNAME PRAGMA_EXT -%token ENUMSTRUCT -%token INCLUDESOURCE -%token INCLUDEBIN -%token INCLUDEIFF -%token SIN -%token COS -%token TAN -%token ACOS -%token ASIN -%token ATAN -%token POUND -%token SHIFTRIGHT -%token SHIFTLEFT -%token RAISEDPOWER - -%% - -/*------------------------------------------------------------------------** -** Begin Grammar rules ** -** ** -** Note: if possible, always try to use left recurrsion rather then right ** -** to save stack depth... ** -**------------------------------------------------------------------------*/ -mIFFSource: - { - /* initialize some global varibles before we start */ - initGlobalVars(); - checkArgs(); - } - preprocessor - { - /* take care of any mIFF related preprocessors that we might encounter */ - checkPragmas(); - } - body - ; - -/*----------------------** -** Preprocessor handler ** -**----------------------*/ -preprocessor: { /* we don't really have to have preprocessor */} - | preprocessor pragma - | preprocessor debugInfo /* we have to have debugInfo or else pragma gets confused when it finds a # line */ - ; - -pragma: PRAGMA PRAGMA_DRIVE STR_LIT { - if (usePragmas) - { - strcpy(drive, $3); - if (strlen(drive) > 2) - { - sprintf(err_msg, "Drive [%s] is not a valid drive [must be in C: format]", drive); - yyerror(err_msg); - } - drive[1] = ':'; - drive[2] = 0; - } - MIFFfreeString($3); - } - | PRAGMA PRAGMA_DIR STR_LIT { - if (usePragmas) - { - strcpy(directory, $3); - if (directory[strlen(directory)] != '\\') - directory[strlen(directory)] = '\\'; - directory[strlen(directory) + 1] = 0; - } - MIFFfreeString($3); - } - | PRAGMA PRAGMA_FNAME STR_LIT { - if (usePragmas) - strcpy(filename, $3); - MIFFfreeString($3); - } - | PRAGMA PRAGMA_EXT STR_LIT { - if (usePragmas) - strcpy(extension, $3); - MIFFfreeString($3); - } - | PRAGMA IDENTIFIER STR_LIT { - sprintf(err_msg, "Unknown PRAGMA identifier [%s]", $2); - yyerror(err_msg); - MIFFfreeString($2); - MIFFfreeString($3); - } - ; - -/*-------------------------------------------------------** -** This is the #line pragmas in a format of: ** -** # lineNum "FileName" mysteryNumber ** -** We call setCurrentLineNumber so when an error occurs, ** -** it will be sync'd to correct filename and linenumber ** -**-------------------------------------------------------*/ -debugInfo: POUND LIT STR_LIT { setCurrentLineNumber($2, $3, 0); MIFFfreeString($3);} - | POUND LIT STR_LIT LIT { setCurrentLineNumber($2, $3, $4); MIFFfreeString($3);} - ; - -/*-----------------------** -** The main body section ** -**-----------------------*/ -body: /* body can be empty */ - | body form formbody - | body chunk chunkbody - | body enumSection - | body includesource { /* do nothing... should not exist if went thru the preprocessor */ } - | body includeIFF - | body debugInfo - ; - -/*------------------------** -** Enumeration definition ** -**------------------------*/ -enumSection: ENUMSTRUCT enumDeclare '{' enumBody '}' enumType ';' { /* enumSection */ } - ; - -enumDeclare: { /* could have no declaration */ lastValue = -1; } - | IDENTIFIER { /* enumDeclare: ID */ lastValue = -1; MIFFfreeString($1);} - ; - -enumBody: { /* enumBody: can be empty list */ } - | enumAssign { /* enumAssign */ } - | enumBody ',' enumAssign { /* enumAssign, enumBody */ } - ; - -enumAssign: IDENTIFIER '=' exprL { - addEnumSymbol($1, $3); - MIFFfreeString($1); - } - | IDENTIFIER { /* in this case, inc 1 from last count */ - addEnumSymbol($1, ++lastValue); - MIFFfreeString($1); - } - ; - -enumType: /* type declaration can be empty */ - | enumList - ; - -enumList: IDENTIFIER { /* enumList: just ID */ MIFFfreeString($1);} - | enumList ',' IDENTIFIER { /* enumList: ID, enumList */ MIFFfreeString($3);} - ; - -/*----------------------------** -** different types of include ** -**----------------------------*/ -includesource: INCLUDESOURCE STR_LIT { /* do nothing... because CCCP/preprocessor takes care of this*/ MIFFfreeString($2);} - ; - -includebin: INCLUDEBIN STR_LIT { includeBinary($2); MIFFfreeString($2);} - ; - -includeIFF: INCLUDEIFF STR_LIT { includeBinary($2); MIFFfreeString($2);} - ; - -/*------------------** -** the FORM section ** -**------------------*/ -form: FORM STR_LIT { - /* first make sure we have 4 char for FORM name */ - if (strlen($2) > 4) - { - sprintf(err_msg, "FORM name %s greater then 4 char", $2); - yyerror(err_msg); - } - else if (!errorFlag) - { - /* pack the string with ' ' (spaces) if less then 4 chars */ - strcpy(tempStr, $2); - if (strlen(tempStr) < 4) - { - /* pack the string */ - for (iTemp = strlen(tempStr);iTemp < 4; iTemp++) - { - tempStr[iTemp] = ' '; /* pack it with space */ - } - } - - /* let's make sure we don't have a smart ass who wants to do form "FORM" */ - if ((toupper(tempStr[0]) == 'F') && - (toupper(tempStr[1]) == 'O') && - (toupper(tempStr[2]) == 'R') && - (toupper(tempStr[3]) == 'M')) - { - yyerror("FORM name CANNOT BE 'FORM'... nice try bozo!"); - } - - /* FORM */ - MIFFinsertForm(tempStr); - } - MIFFfreeString($2); - } - ; - -formbody: '{' formelements '}' { if (!errorFlag) MIFFexitForm(); }; - -formelements: body { /* recursion of multiple depth in form is allowed */ } - | INCLUDEBIN STR_LIT { - yyerror("Found attempt to include binary file inside FORM\nBinary file inclusion ONLY allowed inside a CHUNK!\nError"); - MIFFfreeString($2); - } - ; - -/*-------------------** -** the CHUNK section ** -**-------------------*/ -chunk: CHUNK STR_LIT { - /* first make sure we have 4 char for CHUNK name */ - if (strlen($2) > 4) - { - sprintf(err_msg, "CHUNK name %s greater then 4 char", $2); - yyerror(err_msg); - } - else if (!errorFlag) - { - /* pack the string with ' ' (spaces) if less then 4 chars */ - strcpy(tempStr, $2); - if (strlen(tempStr) < 4) - { - /* pack the string */ - for (iTemp = strlen(tempStr);iTemp < 4; iTemp++) - { - tempStr[iTemp] = ' '; /* pack it with space */ - } - } - - /* let's make sure we don't have a smart ass who wants to do chunk "FORM" */ - if ((toupper(tempStr[0]) == 'F') && - (toupper(tempStr[1]) == 'O') && - (toupper(tempStr[2]) == 'R') && - (toupper(tempStr[3]) == 'M')) - { - yyerror("CHUNK name CANNOT BE 'FORM'... nice try bozo!"); - } - - MIFFinsertChunk(tempStr); - } - MIFFfreeString($2); - } - ; - -chunkbody: '{' chunkelements '}' { if (!errorFlag) MIFFexitChunk(); }; - -chunkelements: /* can be empty */ - | chunkelements memalloc - | chunkelements includebin - | chunkelements debugInfo - | chunkelements includeIFF { yyerror("Found attempt to include IFF (binary) file inside CHUNK\nIFF inclusion ONLY allowed outside a CHUNK!\nError"); } - ; - -memalloc: INT32 l32AllocExpr { } - | INT16 l16AllocExpr { } - | INT8 l8AllocExpr { } - | UINT32 lU32AllocExpr { } - | UINT16 lU16AllocExpr { } - | UINT8 lU8AllocExpr { } - | FLOAT fAllocExpr { } - | DOUBLE dAllocExpr { } - | LABELHASH STR_LIT { - writeLabelHash($2); - } - | STRING STR_LIT { writeString($2); - /* now, add a NULL termination for this string */ - byteTemp = 0; write8(byteTemp); - MIFFfreeString($2); - } - | WSTRING STR_LIT { writeString16($2); - /* now, add a NULL termination for this string */ - wordTemp = 0; write16(wordTemp); - MIFFfreeString($2); - } - ; - -l32AllocExpr: exprL { write32($1); } - | l32AllocExpr ',' exprL { write32($3); } - ; - -l16AllocExpr: exprL { write16((short) $1); } - | l16AllocExpr ',' exprL { write16((short) $3); } - ; - -l8AllocExpr: exprL { write8((char) $1); } - | l8AllocExpr ',' exprL { write8((char) $3); } - ; - -lU32AllocExpr: exprL { writeU32($1); } - | lU32AllocExpr ',' exprL { writeU32($3); } - ; - -lU16AllocExpr: exprL { writeU16((unsigned short) $1); } - | lU16AllocExpr ',' exprL { writeU16((unsigned short) $3); } - ; - -lU8AllocExpr: exprL { writeU8((unsigned char) $1); } - | lU8AllocExpr ',' exprL { writeU8((unsigned char) $3); } - ; - -fAllocExpr: exprD { writeFloat((float) $1); } - | fAllocExpr ',' exprD { writeFloat((float) $3); } - ; - -dAllocExpr: exprD { writeDouble($1); } - | dAllocExpr ',' exprD { writeDouble($3); } - ; - - -/*-------------------------** -** expression for integers ** -**-------------------------*/ -exprL: exprL '+' factorL { $$ = $1 + $3; } - | exprL '-' factorL { $$ = $1 - $3; } - | exprL SHIFTLEFT factorL { $$ = $1 << $3; } - | exprL SHIFTRIGHT factorL { $$ = $1 >> $3; } - | exprL '&' factorL { $$ = $1 & $3; } - | exprL '|' factorL { $$ = $1 | $3; } - | exprL '^' factorL { $$ = $1 ^ $3; } - | factorL { $$ = ($1); } - ; - -factorL: factorL '*' termL { $$ = $1 * $3; } - | factorL '/' termL { $$ = $1 / $3; } - | factorL '%' termL { $$ = $1 % $3; } - | termL { $$ = ($1); } - ; - -termL: LIT { $$ = $1; } - | '~' termL { $$ = ~$2; } /* bitwise NOT */ - | '-' termL { $$ = -$2; } /* Unary minus */ - | '+' termL { $$ = $2; } /* Unary plus */ - | '(' exprL ')' { $$ = ($2); } - | IDENTIFIER { /* assume it's enum symbol */ - $$ = (signed long) getEnumValue(searchEnumSymbolTable($1)); - MIFFfreeString($1); - } - ; - -/*-----------------------** -** expression for floats ** -**-----------------------*/ -exprD: exprD '+' factorD { $$ = $1 + $3; } - | exprD '-' factorD { $$ = $1 - $3; } - | exprD RAISEDPOWER factorD { $$ = pow($1, $3);} /* exponentiation */ - | factorD { $$ = ($1); } - ; - -factorD: factorD '*' termD { $$ = $1 * $3; } - | factorD '/' termD { $$ = $1 / $3; } - | termD { $$ = ($1); } - ; - -termD: FLOAT_LIT { $$ = $1; } - | LIT { $$ = (double) $1; } /* we should be able to handle values that are integer and treat it as float */ - | '-' termD { $$ = -$2; } /* Unary minus */ - | '+' termD { $$ = $2; } /* Unary plus */ - | '(' exprD ')' { $$ = ($2); } - | SIN '(' exprD ')' { $$ = sin( $3 ); } - | COS '(' exprD ')' { $$ = cos( $3 ); } - | TAN '(' exprD ')' { $$ = tan( $3 ); } - | ACOS '(' exprD ')' { $$ = acos( $3 ); } - | ASIN '(' exprD ')' { $$ = asin( $3 ); } - | ATAN '(' exprD ')' { $$ = atan( $3 ); } - | IDENTIFIER { /* assume it's enum symbol */ - $$ = (signed long) getEnumValue(searchEnumSymbolTable($1)); - MIFFfreeString($1); - } - ; - -%% - -/*-------------------------------------------** -** and now... the supporting C functions... ** -**-------------------------------------------*/ -void initGlobalVars(void) -{ - /* assign defaults */ - drive[0] = 0; - directory[0] = 0; - filename[0] = 0; - extension[0] = 0; - err_msg[0] = 0; - usePragmas = 1; /* default to #pragmas enabled because as a stand-alone .YAC, we have no knowledge of outFileName */ - - errorFlag = 0; - - initSymTable(); -} - -void checkPragmas(void) -{ - int indexOriginal, indexDest; - char _tempStr[512]; - - if (usePragmas) - { - /* check after pre processor if output target is still NULL */ - if (!drive[0] && !errorFlag) - { - yyerror("Drive pragma not defined"); - errorFlag = 1; - } - if (!directory[0] && !errorFlag) - { - yyerror("Directory pragma not defined"); - errorFlag = 1; - } - if (!filename[0] && !errorFlag) - { - yyerror("Filename pragma not defined"); - errorFlag = 1; - } - if (!extension[0] && !errorFlag) - { - yyerror("Extension pragma not defined"); - errorFlag = 1; - } - - if (!errorFlag) - { - /* create an output file */ - strcpy(_tempStr, directory); /* copy directory to _tempStr because we'll be messing with directory */ - for (indexOriginal = 0, indexDest = 0; indexOriginal < (int) strlen(_tempStr); indexOriginal++) - { - /* search for double-slashes and convert it to single slash */ - if ((_tempStr[indexOriginal] == '\\') && (_tempStr[indexOriginal+1] == '\\')) - { - directory[indexDest] = '\\'; - indexOriginal++; - } - else - directory[indexDest] = _tempStr[indexOriginal]; /* copy current position of _tempStr to directory */ - indexDest++; - directory[indexDest] = 0; /* force NULL termination */ - } - sprintf(outFileName, "%s%s%s%s", drive, directory, filename, extension); - } - } /* if usePragmas */ - - MIFFSetIFFName(outFileName); /* tell mIFF we want to use this filename instead of whatever it has! */ -} - -/*--------------------------------------------------------------------------------------** -** This function is called early in the process to find out if usePragma flag was set ** -** in the command line or not. If it was, mIFF already has the outfile and will stuff ** -** it into the outFileName data pool. Even if mIFF had an idea of what the output file ** -** name is, if usePragma flag returned said it is true, then #pragas in the mIFF source ** -** is used instead and overrides whatever file name it has returned. ** -** see usePragmas() for more details. ** -**--------------------------------------------------------------------------------------*/ -void checkArgs(void) -{ - /* request an external function (found in either mIFF.CPP or mIFFView.CPP) to see if pragmas and filename was set... */ - usePragmas = validateTargetFilename(outFileName, sizeof(outFileName)); -} - -/*----------------------------** -** Write to FILE functions... ** -**----------------------------*/ -void write32(long i32) -{ - MIFFinsertChunkData(&i32, sizeof(long)); -} - -void write16(short i16) -{ - MIFFinsertChunkData(&i16, sizeof(short)); -} - -void write8(char i8) -{ - MIFFinsertChunkData(&i8, sizeof(char)); -} - -void writeU32(unsigned long ui32) -{ - MIFFinsertChunkData(&ui32, sizeof(long)); -} - -void writeU16(unsigned short ui16) -{ - MIFFinsertChunkData(&ui16, sizeof(short)); -} - -void writeU8(unsigned char ui8) -{ - MIFFinsertChunkData(&ui8, sizeof(char)); -} - -void writeDouble(double d) -{ - MIFFinsertChunkData(&d, sizeof(double)); -} - -void writeFloat(float f) -{ - MIFFinsertChunkData(&f, sizeof(float)); -} - -void writeString(char *s) -{ - char tempS[MAX_STRING_SIZE]; - parseESCstring(s, tempS, MAX_STRING_SIZE); - - MIFFinsertChunkData(tempS, strlen(tempS)); -} - -void writeString16(char *s) -{ - char tempS[MAX_STRING_SIZE]; - int charCount = 0; - wchar_t wtempStr[512]; /* just to be on the safe side, allocating huge array... */ - - parseESCstring(s, tempS, MAX_STRING_SIZE); - - /* make sure string length is less then the allocated wchar size */ - if ((strlen(tempS) * sizeof(wchar_t)) > (512* sizeof(wchar_t))) - yyerror("wstring: 16bit string too long to handle in buffer!\n"); - else - { - /* call MultiByteString to WideCharString function */ - charCount = mbstowcs(wtempStr, tempS, strlen(tempS)); - writeData(wtempStr, charCount * sizeof(wchar_t)); - } -} - -void writeLabelHash(char *s) -{ - writeU32(MIFFgetLabelHash(s)); -} - -/* search from escape string such as \n and convert it to actual byte */ -void parseESCstring(char *str, char *targetBuffer, int sizeOfTarget) -{ - char *sPtr = str; - int strIndex = 0; - char numString[32]; /* hopefully, never go over 3 char i.e. \x0FF */ - int numIndex = 0; - int tempNum = 0; - int exitParser = 0; - int loopFlag = 0; - - /* memory hog but cute way to convert ascii hex to number */ - int hexTable[256]; - memset(hexTable, 0xFF, 256); - hexTable['0'] = 0x00; - hexTable['1'] = 0x01; - hexTable['2'] = 0x02; - hexTable['3'] = 0x03; - hexTable['4'] = 0x04; - hexTable['5'] = 0x05; - hexTable['6'] = 0x06; - hexTable['7'] = 0x07; - hexTable['8'] = 0x08; - hexTable['9'] = 0x09; - hexTable['A'] = 0x0A; hexTable['a'] = 0x0A; - hexTable['B'] = 0x0B; hexTable['b'] = 0x0B; - hexTable['C'] = 0x0C; hexTable['c'] = 0x0C; - hexTable['D'] = 0x0D; hexTable['d'] = 0x0D; - hexTable['E'] = 0x0E; hexTable['e'] = 0x0E; - hexTable['F'] = 0x0F; hexTable['f'] = 0x0F; - - memset(targetBuffer, 0, sizeOfTarget); - while ((*sPtr) && !exitParser) /* assume we can go until NULL termination */ - { - /* check for escape sequences */ - if (*sPtr == '\\') - { - sPtr++; /* check out next character */ - switch (tolower(*sPtr)) - { - case 'a': /* BELL */ - { - targetBuffer[strIndex++] = '\a'; - break; - } - - case 'b': /* BACKSPACE */ - { - targetBuffer[strIndex++] = '\b'; - break; - } - - case 'f': /* FORMFEED */ - { - targetBuffer[strIndex++] = '\a'; - break; - } - - case 'n': /* NEWLINE */ - { - targetBuffer[strIndex++] = '\n'; - break; - } - - case 'r': /* CARRIAGE RETURN */ - { - targetBuffer[strIndex++] = '\r'; - break; - } - - case 't': /* TAB */ - { - targetBuffer[strIndex++] = '\t'; - break; - } - - case 'v': /* VERTICAL TAB */ - { - targetBuffer[strIndex++] = '\v'; - break; - } - - case '\'': /* SINGLE QUOTE */ - { - targetBuffer[strIndex++] = '\''; - break; - } - - case '\"': /* DOUBLE QUOTE */ - { - targetBuffer[strIndex++] = '\"'; - break; - } - - case '\\': /* BACKSLASH */ - { - targetBuffer[strIndex++] = '\\'; - break; - } - - case '?': /* LITERAL QUESTION MARK */ - { - targetBuffer[strIndex++] = '\?'; - break; - } - - case '0': /* ASCII octal */ - case '1': /* ASCII octal */ - case '2': /* ASCII octal */ - case '3': /* ASCII octal */ - case '4': /* ASCII octal */ - case '5': /* ASCII octal */ - case '6': /* ASCII octal */ - case '7': /* ASCII octal */ - { - /* read until non-digit encountered - if octal value is greater then \377 (400 or more) it is bigger the 255! */ - numIndex = 0; - - while ((*sPtr >= '0') && (*sPtr <= '7') && (*sPtr)) - { - numString[numIndex++] = *sPtr; - sPtr++; - if (numIndex > 3) - { - sprintf(err_msg, "Escape sequence Octal numbers greater then\noctal o400 (256 decimal)! [more then 3 digits]", *sPtr); - yyerror(err_msg); - exitParser = 1; - } - } - - /* now we should have string of octal number in numString */ - if (!exitParser) - { - if (numIndex == 3) - tempNum = (hexTable[numString[0]] * 64) + (hexTable[numString[1]] * 8) + hexTable[numString[2]]; - else if (numIndex == 2) - tempNum = (hexTable[numString[0]] * 8) + hexTable[numString[1]]; - else - tempNum = hexTable[numString[0]]; - - if (tempNum > 255) - { - sprintf(err_msg, "Escape sequence Octal numbers greater then\noctal o400 (256 decimal)!", tempNum); - yyerror(err_msg); - exitParser = 1; - } - - if (!exitParser) - targetBuffer[strIndex++] = tempNum; - } - break; - } - - case 'x': /* ASCII hex */ - { - /* we have to make sure the hex value is less then 256! */ - numIndex = 0; - loopFlag = 1; - sPtr++; /* skip the 'x' */ - - while ((0xFF != hexTable[*sPtr]) && (*sPtr)) - { - numString[numIndex++] = *sPtr; - sPtr++; - if (numIndex > 3) - { - sprintf(err_msg, "Escape sequence HEX numbers greater then 0x100\n(256 decimal)! [more then 3 digits]", *sPtr); - yyerror(err_msg); - exitParser = 1; - } - } - - if (!exitParser) - { - if (numIndex == 3) - tempNum = (hexTable[numString[0]] * 0x100) + (hexTable[numString[1]] * 0x10) + hexTable[numString[2]]; - else if (numIndex == 2) - tempNum = (hexTable[numString[0]] * 0x10) + hexTable[numString[1]]; - else - tempNum = hexTable[numString[0]]; - } - - if (tempNum > 255) - { - sprintf(err_msg, "Escape sequence HEX numbers greater then 0x100\n(256 decimal)!", *sPtr); - yyerror(err_msg); - exitParser = 1; - } - - if (!exitParser) - targetBuffer[strIndex++] = tempNum; - - break; - } - - case '8': - case '9': - { - /* they tried to do octal mode, but 8 and 9 is not in the definition of octal */ - yyerror("Attempted to enter escape sequence with non-octal value"); - exitParser = 1; - break; - } - - default: - sprintf(err_msg, "Unknown ESCape sequence \\%c found in string.\n", *sPtr); - yyerror(err_msg); - exitParser = 1; - break; - } - } - else - targetBuffer[strIndex++] = *sPtr; - sPtr++; - } -} - - -void writeData(void *dataPtr, unsigned dataSize) -{ - MIFFinsertChunkData(dataPtr, dataSize); -} - - -/* NOTE: includeBinary modifies fsize for the caller to access for adjusting the chunk size */ -void includeBinary(char *fname) -{ - char buffer[MAX_BUFFER_SIZE+1]; - int fsize = 0; - - fsize = MIFFloadRawData(fname, buffer, MAX_BUFFER_SIZE); - MIFFinsertChunkData(buffer, fsize); -} - -/*--------------------------------------------------------------------------------** -** Following functions below are all used for constructing, adding, and searching ** -** the symbol table created by enum keyword. It is at this moment, set in a way ** -** that if two identical symbols are added to the list, it will use the first ** -** symbol added to the list and ignores the rest (because of forward search) ** -**--------------------------------------------------------------------------------*/ -void initSymTable(void) -{ - memset(symbolEnumTable, 0, sizeof(struct structEnumSymTableType) * MAX_SYMBOLS); - currSymIndex = 0; - lastValue = -1; -} - -/* Searches thru the symbol table and returns the index */ -long searchEnumSymbolTable(char *symString) -{ - long index = 0; - int found = 0; - while ((0 != symbolEnumTable[index].symbol[0]) && !found) - { - - if (0 == strcmp(symbolEnumTable[index].symbol, symString)) - { - found = 1; - break; - } - else - index++; - } - - if (!found) - { - index = -1; - sprintf(err_msg, "Undefined symbol %s", symString); - yyerror(err_msg); - } - - return(index); -} - -long getEnumValue(long index) -{ - if (index >= 0) - return(symbolEnumTable[index].value); - return(-1); -} - -void addEnumSymbol(char *symString, long value) -{ - if (MAX_SYMCHARS < strlen(symString)) - { - /* somebody insane decided to use variable longer then max size! */ - sprintf(err_msg, "%s is longer then %d characters! [value: %d]", symString, MAX_SYMCHARS, value); - yyerror(err_msg); - } - else - { - strcpy(symbolEnumTable[currSymIndex].symbol, symString); - symbolEnumTable[currSymIndex].value = value; - lastValue = value; - currSymIndex++; - if (MAX_SYMBOLS < currSymIndex) - { - sprintf(err_msg, "Symbol table reached maximum size of %d", MAX_SYMBOLS); - yyerror(err_msg); - } - } -} diff --git a/src/engine/shared/application/ArmorExporterTool/src/linux/dummy.cpp b/src/engine/shared/application/ArmorExporterTool/src/linux/dummy.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/engine/shared/application/CoreWeaponExporterTool/src/linux/dummy.cpp b/src/engine/shared/application/CoreWeaponExporterTool/src/linux/dummy.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/engine/shared/application/DataTableTool/src/linux/dummy.cpp b/src/engine/shared/application/DataTableTool/src/linux/dummy.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/engine/shared/application/TemplateCompiler/src/linux/FirstTemplateCompiler.cpp b/src/engine/shared/application/TemplateCompiler/src/linux/FirstTemplateCompiler.cpp deleted file mode 100644 index ef9c16dc0..000000000 --- a/src/engine/shared/application/TemplateCompiler/src/linux/FirstTemplateCompiler.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "FirstTemplateCompiler.h" diff --git a/src/engine/shared/application/TemplateCompiler/src/linux/FirstTemplateCompiler.h b/src/engine/shared/application/TemplateCompiler/src/linux/FirstTemplateCompiler.h deleted file mode 100644 index d06501059..000000000 --- a/src/engine/shared/application/TemplateCompiler/src/linux/FirstTemplateCompiler.h +++ /dev/null @@ -1,9 +0,0 @@ -#include "sharedFoundationTypes/FoundationTypes.h" -#include "sharedDebug/FirstSharedDebug.h" -#include "sharedFoundation/FirstSharedFoundation.h" -#include -#include -#include -#include -#include - diff --git a/src/engine/shared/application/TemplateDefinitionCompiler/src/linux/FirstTemplateDefinitionCompiler.cpp b/src/engine/shared/application/TemplateDefinitionCompiler/src/linux/FirstTemplateDefinitionCompiler.cpp deleted file mode 100644 index 7f0e4151d..000000000 --- a/src/engine/shared/application/TemplateDefinitionCompiler/src/linux/FirstTemplateDefinitionCompiler.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#include "FirstTemplateDefinitionCompiler.h" - diff --git a/src/engine/shared/application/TemplateDefinitionCompiler/src/linux/FirstTemplateDefinitionCompiler.h b/src/engine/shared/application/TemplateDefinitionCompiler/src/linux/FirstTemplateDefinitionCompiler.h deleted file mode 100644 index d06501059..000000000 --- a/src/engine/shared/application/TemplateDefinitionCompiler/src/linux/FirstTemplateDefinitionCompiler.h +++ /dev/null @@ -1,9 +0,0 @@ -#include "sharedFoundationTypes/FoundationTypes.h" -#include "sharedDebug/FirstSharedDebug.h" -#include "sharedFoundation/FirstSharedFoundation.h" -#include -#include -#include -#include -#include - diff --git a/src/engine/shared/application/Turf/src/linux/FirstTurf.h b/src/engine/shared/application/Turf/src/linux/FirstTurf.h deleted file mode 100644 index f95425fa0..000000000 --- a/src/engine/shared/application/Turf/src/linux/FirstTurf.h +++ /dev/null @@ -1,17 +0,0 @@ -// ====================================================================== -// -// FirstTerrainViewer.h -// copyright 2001, sony online entertainment -// -// ====================================================================== - -#ifndef INCLUDED_FirstTerrainViewer_H -#define INCLUDED_FirstTerrainViewer_H - -// ====================================================================== - -#include "sharedFoundation/FirstSharedFoundation.h" - -// ====================================================================== - -#endif diff --git a/src/engine/shared/application/WeaponExporterTool/src/linux/dummy.cpp b/src/engine/shared/application/WeaponExporterTool/src/linux/dummy.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/engine/shared/library/sharedDatabaseInterface/src/linux/SQLC_Defs.h b/src/engine/shared/library/sharedDatabaseInterface/src/linux/SQLC_Defs.h deleted file mode 100644 index 6443b953e..000000000 --- a/src/engine/shared/library/sharedDatabaseInterface/src/linux/SQLC_Defs.h +++ /dev/null @@ -1,18 +0,0 @@ -/* SQLC_Defs.h - * - * This file includes common definitions needed by the other SQLClasses header files. - * (Don't include this file directly -- files that require it will include it.) - * - * Note that this file is specific to each OS, because what header files are - * needed varies in each OS. In particular, Unix versions don't want windows.h. - * - * ODBC versions: includes definitions of ODBC datatypes needed by the various - * SQLClasses - */ - -#ifndef _SQLC_DEFS_H -#define _SQLC_DEFS_H - -#include - -#endif diff --git a/src/engine/shared/library/sharedDebug/src/linux/ConfigSharedDebugLinux.cpp b/src/engine/shared/library/sharedDebug/src/linux/ConfigSharedDebugLinux.cpp deleted file mode 100644 index e50ad47cc..000000000 --- a/src/engine/shared/library/sharedDebug/src/linux/ConfigSharedDebugLinux.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// ====================================================================== -// -// ConfigSharedDebugLinux.cpp -// Copyright 2002 Sony Online Entertainment, Inc. -// All Rights Reserved. -// -// ====================================================================== - -#include "sharedDebug/FirstSharedDebug.h" -#include "sharedDebug/ConfigSharedDebugLinux.h" - -#include "sharedDebug/Profiler.h" -#include "sharedFoundation/ConfigFile.h" - -//=================================================================== - -namespace ConfigSharedDebugLinuxNamespace -{ - bool s_useTty; - const char *s_debugMonitorOutputFilename; - bool s_logTtySetup; -} - -using namespace ConfigSharedDebugLinuxNamespace; - -//=================================================================== - -#define KEY_BOOL(a,b) (s_ ## a = ConfigFile::getKeyBool("SharedDebugLinux", #a, b)) -#define KEY_STRING(a,b) (s_ ## a = ConfigFile::getKeyString("SharedDebugLinux", #a, b)) -// #define KEY_INT(a,b) (s_ ## a = ConfigFile::getKeyInt("ClientAnimation", #a, b)) -// #define KEY_FLOAT(a,b) (s_ ## a = ConfigFile::getKeyFloat("ClientAnimation", #a, b)) - -//=================================================================== - -void ConfigSharedDebugLinux::install(void) -{ - KEY_BOOL(useTty, false); - KEY_STRING(debugMonitorOutputFilename, "ttySpecifier.txt"); - KEY_BOOL(logTtySetup, false); - - //-- Handle startup profiler handling here. - // @todo this should move into ConfigSharedDebug or be loaded - // by Profiler. Profiler can't load this config file option - // because the Profiler is installed prior to the config file - // system. - Profiler::enableProfilerOutput(ConfigFile::getKeyBool("SharedDebugLinux", "reportProfiler", false)); -} - -// ------------------------------------------------------------------ - -bool ConfigSharedDebugLinux::getUseTty() -{ - return s_useTty; -} - -// ------------------------------------------------------------------ - -char const *ConfigSharedDebugLinux::getDebugMonitorOutputFilename() -{ - return s_debugMonitorOutputFilename; -} - -// ------------------------------------------------------------------ - -bool ConfigSharedDebugLinux::getLogTtySetup() -{ - return s_logTtySetup; -} - -//=================================================================== diff --git a/src/engine/shared/library/sharedDebug/src/linux/ConfigSharedDebugLinux.h b/src/engine/shared/library/sharedDebug/src/linux/ConfigSharedDebugLinux.h deleted file mode 100644 index 9d23544d3..000000000 --- a/src/engine/shared/library/sharedDebug/src/linux/ConfigSharedDebugLinux.h +++ /dev/null @@ -1,29 +0,0 @@ -// ====================================================================== -// -// ConfigSharedDebugLinux.h -// Copyright 2002 Sony Online Entertainment, Inc. -// All Rights Reserved. -// -// ====================================================================== - -#ifndef INCLUDED_ConfigSharedDebugLinux_H -#define INCLUDED_ConfigSharedDebugLinux_H - -//=================================================================== - -class ConfigSharedDebugLinux -{ -public: - - static void install(); - - static bool getUseTty(); - static char const *getDebugMonitorOutputFilename(); - static bool getLogTtySetup(); - -}; - -//=================================================================== - -#endif - diff --git a/src/engine/shared/library/sharedDebug/src/linux/DebugHelp.cpp b/src/engine/shared/library/sharedDebug/src/linux/DebugHelp.cpp deleted file mode 100644 index e5e0c980a..000000000 --- a/src/engine/shared/library/sharedDebug/src/linux/DebugHelp.cpp +++ /dev/null @@ -1,677 +0,0 @@ -// ====================================================================== -// -// DebugHelp.cpp -// Copyright 2001-2003 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedDebug/FirstSharedDebug.h" -#include "sharedDebug/DebugHelp.h" -#include "sharedSynchronization/Mutex.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -// ====================================================================== - -class SymbolCache -{ -public: - - struct SymbolInfo - { - char const *srcLib; - char const *srcFile; - int srcLine; - bool found; - }; - - static void clear(); - static SymbolInfo const &lookup(void const *addr); - static char const *uniqueString(char const *s); - static void *memPoolAllocate(size_t size); - static const size_t cms_memPoolMaxBytes = 8*1024*1024; - -private: - static size_t ms_memPoolUsed; - static char ms_memPool[cms_memPoolMaxBytes]; - static char *ms_memPoolFreeList; - static Mutex ms_memPoolMutex; - static SymbolInfo ms_nullSym; -}; - -// ---------------------------------------------------------------------- - -template -class SymbolCacheAllocator -{ -public: - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef T * pointer; - typedef T const * const_pointer; - typedef T & reference; - typedef T const & const_reference; - typedef T value_type; - -public: - SymbolCacheAllocator() {} - template SymbolCacheAllocator(SymbolCacheAllocator const &) {} - template struct rebind { typedef SymbolCacheAllocator other; }; - - pointer allocate(size_type n, const_pointer = 0) { return reinterpret_cast(SymbolCache::memPoolAllocate(n*sizeof(value_type))); } - void deallocate(const_pointer p, size_type n) {} - pointer address(reference x) const { return &x; } - const_pointer address(const_reference x) const { return &x; } - size_type max_size() const { return SymbolCache::cms_memPoolMaxBytes; } - void construct(pointer p, value_type const & x) { new(p) value_type(x); } - void destroy(pointer p) { p->~value_type(); } -}; - -// ---------------------------------------------------------------------- - -size_t SymbolCache::ms_memPoolUsed; -char SymbolCache::ms_memPool[SymbolCache::cms_memPoolMaxBytes]; -char *SymbolCache::ms_memPoolFreeList; -Mutex SymbolCache::ms_memPoolMutex; -SymbolCache::SymbolInfo SymbolCache::ms_nullSym; -typedef std::map, SymbolCacheAllocator > > SymbolMap; -typedef std::vector > UniqueStringVector; -static SymbolMap ms_cacheMap; -static UniqueStringVector ms_uniqueStringVector; - -// ---------------------------------------------------------------------- - -static Elf32_Shdr const *elfGetObjSectionHeader(void const *objBaseAddr, int sectionIndex) -{ - Elf32_Ehdr const *eh = reinterpret_cast(objBaseAddr); - if (sectionIndex >= 0 && sectionIndex < eh->e_shnum) - return reinterpret_cast(static_cast(objBaseAddr)+eh->e_shoff+sectionIndex*eh->e_shentsize); - return 0; -} - -// ---------------------------------------------------------------------- - -static char const *elfGetObjSectionData(void const *objBaseAddr, int sectionIndex) -{ - Elf32_Shdr const *sh = elfGetObjSectionHeader(objBaseAddr, sectionIndex); - if (sh) - return reinterpret_cast(objBaseAddr)+sh->sh_offset; - return 0; -} - -// ---------------------------------------------------------------------- - -static unsigned int elfGetObjSectionSize(void const *objBaseAddr, int sectionIndex) -{ - Elf32_Shdr const *sh = elfGetObjSectionHeader(objBaseAddr, sectionIndex); - if (sh) - return sh->sh_size; - return 0; -} - -// ---------------------------------------------------------------------- - -static char const *elfGetObjSectionName(void const *objBaseAddr, int sectionIndex) -{ - Elf32_Ehdr const *eh = reinterpret_cast(objBaseAddr); - char const *sectionStr = elfGetObjSectionData(objBaseAddr, eh->e_shstrndx); - if (sectionStr) - { - Elf32_Shdr const *sh = elfGetObjSectionHeader(objBaseAddr, sectionIndex); - if (sh) - return sectionStr+sh->sh_name; - } - return 0; -} - -// ---------------------------------------------------------------------- - -static int elfGetObjSectionByName(void const *objBaseAddr, char const *sectionName) -{ - int n = reinterpret_cast(objBaseAddr)->e_shnum; - for (int i = 0; i < n; ++i) - if (!strcmp(elfGetObjSectionName(objBaseAddr, i), sectionName)) - return i; - return -1; -} - -// ---------------------------------------------------------------------- - -inline unsigned int dwarfGet(char const *src, u_int8_t &dest) -{ - memcpy(&dest, src, sizeof(u_int8_t)); - return sizeof(u_int8_t); -} - -// ---------------------------------------------------------------------- - -inline unsigned int dwarfGet(char const *src, u_int16_t &dest) -{ - memcpy(&dest, src, sizeof(u_int16_t)); - return sizeof(u_int16_t); -} - -// ---------------------------------------------------------------------- - -inline unsigned int dwarfGet(char const *src, u_int32_t &dest) -{ - memcpy(&dest, src, sizeof(u_int32_t)); - return sizeof(u_int32_t); -} - -// ---------------------------------------------------------------------- - -class LEB128 -{ -public: - operator int() const { return value; } - int value; -}; - -// ---------------------------------------------------------------------- - -inline unsigned int dwarfGet(char const *src, LEB128 &dest) -{ - unsigned int pos = 0; - int shift = 7; - int byte = ((u_int8_t*)src)[pos++]; - dest.value = byte; - while (byte >= 0x80) - { - byte = ((u_int8_t *)src)[pos++] ^ 1; - dest.value ^= byte << shift; - shift += 7; - } - if (shift < 32 && (byte & 0x40)) - dest.value |= -(1L<= 0x80) - { - byte = ((u_int8_t *)src)[pos++] ^ 1; - dest.value ^= byte << shift; - shift += 7; - } - return pos; -} - -// ---------------------------------------------------------------------- - -static bool dwarfSearch(char const *dwarfLines, unsigned int linesLength, void const *addr, Dl_info const &info, char const *&retSrcFile, int &retSrcLine) -{ - enum - { - DW_LNE_end_sequence = 1, - DW_LNE_set_address = 2, - - DW_LNS_copy = 1, - DW_LNS_advance_pc = 2, - DW_LNS_advance_line = 3, - DW_LNS_set_file = 4, - DW_LNS_set_column = 5, - DW_LNS_negate_stmt = 6, - DW_LNS_set_basic_block = 7, - DW_LNS_const_add_pc = 8, - DW_LNS_fixed_advance_pc = 9, - }; -//// - void const *bestOverAddr = reinterpret_cast(0xffffffff); - void const *bestUnderAddr = 0; - char const *bestUnderSrcFileTable = 0; - int bestUnderSrcFileNum = 0; - int bestUnderSrcLine = 0; - - unsigned int stmtProgMaxLen = linesLength; - u_int32_t stmtProgLen = 0; - - for (unsigned int progBeginOffset = 0; progBeginOffset < linesLength; progBeginOffset += stmtProgLen+4, stmtProgMaxLen -= stmtProgLen+4) - { - char const *stmtProg = dwarfLines+progBeginOffset; - // get program length - stmtProg += dwarfGet(stmtProg, stmtProgLen); - if (stmtProgLen < 12 || stmtProgLen+4 > stmtProgMaxLen) - continue; - - char const *stmtProgEnd = stmtProg+stmtProgLen; - stmtProg += 2; // skip version - // get prologue length - u_int32_t stmtProgPrologueLen; stmtProg += dwarfGet(stmtProg, stmtProgPrologueLen); - if (stmtProgPrologueLen+10 > stmtProgMaxLen) - continue; - - char const *stmtProgStart = stmtProg; - u_int8_t stmtProgMinInstructionLen; stmtProg += dwarfGet(stmtProg, stmtProgMinInstructionLen); - if (stmtProgMinInstructionLen == 0) - continue; - ++stmtProg; // skip default_is_stmt - int8_t stmtProgLineBase; stmtProg += dwarfGet(stmtProg, *(u_int8_t*)&stmtProgLineBase); - u_int8_t stmtProgLineRange; stmtProg += dwarfGet(stmtProg, stmtProgLineRange); - if (stmtProgLineRange == 0) - continue; - u_int8_t stmtProgOpcodeBase; stmtProg += dwarfGet(stmtProg, stmtProgOpcodeBase); - u_int8_t const *stmtProgOpcodeLengths = reinterpret_cast(stmtProg); - stmtProg += stmtProgOpcodeBase-1; - // include dirs here - while (*stmtProg) - while (*stmtProg++); - char const *stmtProgFilenames = stmtProg; - stmtProg = stmtProgStart+stmtProgPrologueLen; - - // run program - - while (stmtProg < stmtProgEnd) - { - int progFile = 0; - int progLine = 1; - u_int32_t progAddr = 0; - bool done = false; - bool valid = false; - - while (!done) - { - u_int8_t opcode = *stmtProg++; - if (opcode < stmtProgOpcodeBase) - { - switch (opcode) - { - case 0: // extended - { - u_int8_t size, extendedOpcode; - stmtProg += dwarfGet(stmtProg, size); - stmtProg += dwarfGet(stmtProg, extendedOpcode); - switch (extendedOpcode) - { - case DW_LNE_end_sequence: - valid = true; - done = true; - break; - case DW_LNE_set_address: - stmtProg += dwarfGet(stmtProg, progAddr); - break; - default: // unimplemented extended opcode, skip parms - stmtProg += size-1; - break; - } - } - break; - case DW_LNS_advance_pc: - { - LEB128u incr; stmtProg += dwarfGet(stmtProg, incr); - progAddr += incr*stmtProgMinInstructionLen; - } - break; - case DW_LNS_const_add_pc: - progAddr += (255-stmtProgOpcodeBase)/stmtProgLineRange*stmtProgMinInstructionLen; - break; - case DW_LNS_fixed_advance_pc: - { - u_int16_t incr; stmtProg += dwarfGet(stmtProg, incr); - progAddr += incr; - } - break; - case DW_LNS_advance_line: - { - LEB128 incr; stmtProg += dwarfGet(stmtProg, incr); - progLine += incr; - } - break; - case DW_LNS_set_file: - { - LEB128u fileNum; stmtProg += dwarfGet(stmtProg, fileNum); - progFile = fileNum-1; - } - break; - case DW_LNS_copy: - valid = true; - break; - // ignored - case DW_LNS_set_column: - { - LEB128u col; stmtProg += dwarfGet(stmtProg, col); - } - break; - case DW_LNS_negate_stmt: - case DW_LNS_set_basic_block: - break; - default: - { - // unimplemented standard opcode - // look up standard opcode length and skip that many LEB128u's - LEB128u temp; - for (int i = 0; i < stmtProgOpcodeLengths[opcode-1]; ++i) - stmtProg += dwarfGet(stmtProg, temp); - } - break; - } - } - else // special opcode - { - progLine += stmtProgLineBase+(opcode-stmtProgOpcodeBase)%stmtProgLineRange; - progAddr += (opcode-stmtProgOpcodeBase)/stmtProgLineRange*stmtProgMinInstructionLen; - valid = true; - } - - if (valid) - { - unsigned int addrOffset = 0; - if (progAddr < reinterpret_cast(info.dli_fbase)) - addrOffset = reinterpret_cast(info.dli_fbase); - const void *testAddr = reinterpret_cast(progAddr+addrOffset); - if (testAddr >= addr) - { - if (testAddr < bestOverAddr) - bestOverAddr = testAddr; - } - else if (testAddr > bestUnderAddr) - { - bestUnderAddr = testAddr; - bestUnderSrcFileTable = stmtProgFilenames; - bestUnderSrcFileNum = progFile; - bestUnderSrcLine = progLine; - } - } - } - } - } - - if (bestUnderAddr && bestOverAddr != reinterpret_cast(0xffffffff)) - { - char const *srcFile = bestUnderSrcFileTable+1; - for (int i = 0; i < bestUnderSrcFileNum; ++i) - { - while (*srcFile++); - srcFile += 3; - } - retSrcFile = SymbolCache::uniqueString(srcFile); - retSrcLine = bestUnderSrcLine; - return true; - } - return false; -} - -// ---------------------------------------------------------------------- - -static bool dwarfFind(void const *addr, Dl_info const &info, char const *& retSrcFile, int &retSrcLine) -{ - bool found = false; - int fd = open(info.dli_fname, O_RDONLY); - if (fd != -1) - { - int fileSize = lseek(fd, 0, SEEK_END); - lseek(fd, 0, SEEK_SET); - void const *mappedAddr = reinterpret_cast(mmap(0, fileSize, PROT_READ, MAP_PRIVATE, fd, 0)); - close(fd); - if (mappedAddr != MAP_FAILED) - { - int dwarfLinesIndex = elfGetObjSectionByName(mappedAddr, ".debug_line"); - if (dwarfLinesIndex != -1) - { - try - { - found = dwarfSearch( - elfGetObjSectionData(mappedAddr, dwarfLinesIndex), - elfGetObjSectionSize(mappedAddr, dwarfLinesIndex), - addr, - info, - retSrcFile, - retSrcLine); - } - catch (std::bad_alloc &) - { - munmap(const_cast(mappedAddr), fileSize); - throw std::bad_alloc(); - } - } - munmap(const_cast(mappedAddr), fileSize); - } - } - return found; -} - -// ---------------------------------------------------------------------- - -struct Stab -{ - unsigned int n_strx; // index into string table - unsigned char n_type; // type of stab entry - char n_other; - unsigned short n_desc; // for N_SLINE entries, line number - unsigned int n_value; // value of symbol -}; - -// ---------------------------------------------------------------------- - -static bool stabSearch(Stab const *stab, unsigned int stabSize, char const *stabStr, void const *addr, Dl_info const &info, char const *&retSrcFile, int &retSrcLine) -{ - enum - { - N_UNDF = 0, // undefined - N_FUN = 0x24, // function - N_SLINE = 0x44, // source line - N_SO = 0x64, // source file name - N_SOL = 0x84 // local source file name - }; - - unsigned int stabCount = stabSize/sizeof(Stab); - char const *srcFile = ""; - void const *funcBase = 0; - int foundSrcLine = -1; - - for (unsigned int i = 0; i < stabCount; ++i, ++stab) - { - if (stab->n_type == N_UNDF) // new stabs section, do a recursive search of it - { - if (stabSearch(stab+1, stab->n_desc*sizeof(Stab), stabStr, addr, info, retSrcFile, retSrcLine)) - return true; - i += stab->n_desc; - stab += stab->n_desc; - srcFile = ""; - continue; - } - else if (stab->n_type == N_SO || stab->n_type == N_SOL) // source or header file specification - srcFile = stabStr+stab->n_strx; - else if (stab->n_type == N_FUN) // function specification - { - // This may not be terribly accurate - it's attempting to differentiate between already relocated symbols (main program) - // and shared libs, which need to be offset by their file base - if (reinterpret_cast(stab->n_value) > info.dli_fbase) - funcBase = reinterpret_cast(stab->n_value); - else - funcBase = reinterpret_cast(reinterpret_cast(info.dli_fbase)+stab->n_value); - foundSrcLine = -1; - } - else if (stab->n_type == N_SLINE && addr >= funcBase) // source line - { - if (stab->n_value < reinterpret_cast(addr)-reinterpret_cast(funcBase)) - foundSrcLine = stab->n_desc; - else - { - retSrcLine = foundSrcLine == -1 ? stab->n_desc : foundSrcLine; - retSrcFile = SymbolCache::uniqueString(srcFile); - return true; - } - } - } - - return false; -} - -// ---------------------------------------------------------------------- - -static bool stabsFind(void const *addr, Dl_info const &info, char const *& retSrcFile, int &retSrcLine) -{ - bool found = false; - int fd = open(info.dli_fname, O_RDONLY); - if (fd != -1) - { - int fileSize = lseek(fd, 0, SEEK_END); - lseek(fd, 0, SEEK_SET); - void const *mappedAddr = reinterpret_cast(mmap(0, fileSize, PROT_READ, MAP_PRIVATE, fd, 0)); - close(fd); - if (mappedAddr != MAP_FAILED) - { - int stabIndex = elfGetObjSectionByName(mappedAddr, ".stab"); - int stabStrIndex = elfGetObjSectionByName(mappedAddr, ".stabstr"); - if (stabIndex != -1 && stabStrIndex != -1) - { - try - { - found = stabSearch( - reinterpret_cast(elfGetObjSectionData(mappedAddr, stabIndex)), - elfGetObjSectionSize(mappedAddr, stabIndex), - elfGetObjSectionData(mappedAddr, stabStrIndex), - addr, - info, - retSrcFile, - retSrcLine); - } - catch (std::bad_alloc &) - { - munmap(const_cast(mappedAddr), fileSize); - throw std::bad_alloc(); - } - } - munmap(const_cast(mappedAddr), fileSize); - } - } - return found; -} - -// ---------------------------------------------------------------------- - -SymbolCache::SymbolInfo const &SymbolCache::lookup(void const *addr) -{ - SymbolMap::const_iterator i = ms_cacheMap.find(addr); - if (i != ms_cacheMap.end()) - return (*i).second; - - // allow for running out of the fixed memory pool and recover gracefully - for (int tries = 0; tries < 2; ++tries) - { - try - { - SymbolInfo &symInfo = ms_cacheMap[addr]; - Dl_info info; - if (dladdr(addr, &info)) - { - symInfo.srcLib = uniqueString(info.dli_fname); - if ( stabsFind(addr, info, symInfo.srcFile, symInfo.srcLine) - || dwarfFind(addr, info, symInfo.srcFile, symInfo.srcLine)) - symInfo.found = true; - } - return symInfo; - } - catch (std::bad_alloc &) - { - ms_uniqueStringVector.clear(); - ms_cacheMap.clear(); - ms_memPoolUsed = 0; - } - } - - return ms_nullSym; -} - -// ---------------------------------------------------------------------- - -char const *SymbolCache::uniqueString(char const *s) -{ - for (UniqueStringVector::const_iterator i = ms_uniqueStringVector.begin(); i != ms_uniqueStringVector.end(); ++i) - if (!strcmp(s, *i)) - return *i; - char *newString = static_cast(memPoolAllocate((strlen(s)+8)&(~7))); - strcpy(newString, s); - ms_uniqueStringVector.push_back(newString); - return newString; -} - -// ---------------------------------------------------------------------- - -void *SymbolCache::memPoolAllocate(size_t size) -{ - ms_memPoolMutex.enter(); - if (ms_memPoolUsed+size > cms_memPoolMaxBytes) - { - ms_memPoolMutex.leave(); - throw std::bad_alloc(); - } - void *ret = ms_memPool+ms_memPoolUsed; - ms_memPoolUsed += size; - ms_memPoolMutex.leave(); - return ret; -} - -// ---------------------------------------------------------------------- - -bool lookupAddressInfo(void const *addr, char *retSrcLib, char *retSrcFile, int &retSrcLine, int stringBufLengths) -{ - SymbolCache::SymbolInfo const &symInfo = SymbolCache::lookup(addr); - if (retSrcLib && symInfo.srcLib) - { - strncpy(retSrcLib, symInfo.srcLib, stringBufLengths); - retSrcLib[stringBufLengths-1] = '\0'; - } - if (symInfo.found && retSrcFile) - { - strncpy(retSrcFile, symInfo.srcFile, stringBufLengths); - retSrcFile[stringBufLengths-1] = '\0'; - } - retSrcLine = symInfo.srcLine; - return symInfo.found; -} - -//// -// ====================================================================== - -void DebugHelp::install() -{ -} - -// ---------------------------------------------------------------------- - -void DebugHelp::remove() -{ -} - -// ---------------------------------------------------------------------- - -bool DebugHelp::lookupAddress(uint32 address, char *libName, char *fileName, int fileNameLength, int &line) -{ - return lookupAddressInfo(reinterpret_cast(address), libName, fileName, line, fileNameLength); -} - -// ---------------------------------------------------------------------- - -void DebugHelp::getCallStack(uint32 *callStack, int sizeOfCallStack) -{ - for (int i = 0; i < sizeOfCallStack; ++i) - callStack[i] = 0; - IGNORE_RETURN(backtrace(reinterpret_cast(callStack), sizeOfCallStack)); -} - -// ====================================================================== - diff --git a/src/engine/shared/library/sharedDebug/src/linux/DebugHelp.h b/src/engine/shared/library/sharedDebug/src/linux/DebugHelp.h deleted file mode 100644 index 5068ea1d3..000000000 --- a/src/engine/shared/library/sharedDebug/src/linux/DebugHelp.h +++ /dev/null @@ -1,33 +0,0 @@ -// ====================================================================== -// -// DebugHelp.h -// copyright 2000 Verant Interactive -// -// ====================================================================== - -#ifndef DEBUG_HELP_H -#define DEBUG_HELP_H - -#include "sharedDebug/FirstSharedDebug.h" - -// ====================================================================== - -typedef unsigned long uint32; - -// ====================================================================== - -class DebugHelp -{ -public: - - static void install(); - static void remove(); - - static void getCallStack(uint32 *callStack, int sizeOfCallStack); - static bool lookupAddress(uint32 address, char *libName, char *fileName, int fileNameLength, int &line); -}; - -// ====================================================================== - -#endif - diff --git a/src/engine/shared/library/sharedDebug/src/linux/DebugMonitor.cpp b/src/engine/shared/library/sharedDebug/src/linux/DebugMonitor.cpp deleted file mode 100644 index 59cd24bc1..000000000 --- a/src/engine/shared/library/sharedDebug/src/linux/DebugMonitor.cpp +++ /dev/null @@ -1,445 +0,0 @@ -// ====================================================================== -// -// DebugMonitor.cpp -// Copyright 2002, Sony Online Entertainment.h -// All rights reserved. -// -// ====================================================================== - -#include "sharedDebug/FirstSharedDebug.h" -#include "sharedDebug/DebugMonitor.h" - -#ifdef _DEBUG - -#include "sharedDebug/ConfigSharedDebugLinux.h" -#include "sharedDebug/Profiler.h" -#include "sharedFoundation/ConfigSharedFoundation.h" - -#include -#include -#include -#include -#include - -// ====================================================================== - -namespace DebugMonitorNamespace -{ - bool s_installed; - SCREEN *s_initialScreen; - WINDOW *s_initialWindow; - - FILE *s_ttyOutputFile; - FILE *s_ttyInputFile; - SCREEN *s_outputScreen; - WINDOW *s_outputWindow; -} - -using namespace DebugMonitorNamespace; - -// ====================================================================== -// Install the debug monitor subsystem -// -// Remarks: -// -// This routine will first attempt to install the selected debug monitor. - -void DebugMonitor::install(void) -{ - DEBUG_FATAL(s_installed, ("DebugMonitor already installed.")); - - //-- Check if user wants to use a TTY for the DebugMonitor. - if (!ConfigSharedDebugLinux::getUseTty()) - { - // Do not use the DebugMonitor. - DEBUG_REPORT_LOG(ConfigSharedDebugLinux::getLogTtySetup(), ("DebugMonitor: skipping install, ConfigSharedDebugLinux/useTty is false.\n")); - return; - } - - //-- Open and retrieve the name of the TTY file for output from the TTY Specification file. - char const *const configFilename = ConfigSharedDebugLinux::getDebugMonitorOutputFilename(); - - if (!configFilename || (*configFilename == '\0')) - { - DEBUG_WARNING(true, ("DebugMonitor(): skipping installation, no debugMonitorOutputFilename specified.")); - return; - } - - char ttyFilename[1024]; - - if (configFilename[0] != '@') - { - // filename is the real output filename (usually a device) for DebugMonitor output. - strncpy(ttyFilename, configFilename, sizeof(ttyFilename) - 1); - ttyFilename[sizeof(ttyFilename)-1] = 0; - } - else - { - // filename is actually an indirection filename, the contents of this file contains the real filename. - FILE *ttySpecifierFile = fopen(configFilename + 1, "r"); - if (!ttySpecifierFile) - { - DEBUG_WARNING(true, ("DebugMonitor: failed to open tty specifier file [%s]: [%s].", configFilename + 1, strerror(errno))); - return; - } - - // Retrieve the TTY file name. - fgets(ttyFilename, sizeof(ttyFilename), ttySpecifierFile); - fclose(ttySpecifierFile); - } - - // Strip trailing newline from TTY filename. - const int filenameLength = strlen(ttyFilename); - if (filenameLength > 0) - { - // chop off trailing newline if present. - if (ttyFilename[filenameLength - 1] == '\n') - ttyFilename[filenameLength - 1] = '\0'; - } - - //-- Open the TTY file for output. - DEBUG_REPORT_LOG(ConfigSharedDebugLinux::getLogTtySetup(), ("DebugMonitor: opening TTY file [%s] for reading and writing.\n", ttyFilename)); - FILE *s_ttyOutputFile = fopen(ttyFilename, "w"); - if (!s_ttyOutputFile) - { - DEBUG_WARNING(true, ("DebugMonitor: failed to open tty file for output [%s]: [%s].", ttyFilename, strerror(errno))); - return; - } - - //-- Open the TTY file for input. - FILE *s_ttyInputFile = fopen(ttyFilename, "r"); - if (!s_ttyInputFile) - { - DEBUG_WARNING(true, ("DebugMonitor: failed to open tty file for input [%s]: [%s].", ttyFilename, strerror(errno))); - fclose(s_ttyOutputFile); - return; - } - -#if 1 - // NOTE: -TRF- I would not expect this chunk of termios setup - // code to be necessary. My expectation is that it should - // be handled by the curs_inopts (see man page) options I have - // selected below. Alas, these are needed. - - //-- Setup profiler window input mode. - const int inputFd = STDIN_FILENO; - - // Get terminal attributes. - termios terminalAttributes; - if (tcgetattr(inputFd, &terminalAttributes) != 0) - { - DEBUG_WARNING(true, ("DebugMonitor: tcgetattr failed [%s].", strerror(errno))); - return; - } - - // Turn off line-processing mode. We want a character at a time. - terminalAttributes.c_lflag &= ~ICANON; - - // Turn off echo. - terminalAttributes.c_lflag &= ~ECHO; - - // Specify that read should return immediately (non-blocking). - terminalAttributes.c_cc[VMIN] = 0; - terminalAttributes.c_cc[VTIME] = 0; - - // Set terminal attributes. - if (tcsetattr(inputFd, TCSAFLUSH, &terminalAttributes) != 0) - { - DEBUG_WARNING(true, ("DebugMonitor: tcsetattr failed [%s].", strerror(errno))); - return; - } -#endif - - //-- Create a curses screen to represent the DebugMonitor output tty. - // NOTE: for now the curses input is hooked up to the application's - // standard input. Later we may want to change that to - // handle input from the output terminal, particularly to - // handle profiler modifications when the output window - // is active. - s_outputScreen = newterm(NULL, s_ttyOutputFile, stdin); - if (!s_outputScreen) - { - DEBUG_WARNING(true, ("DebugMonitor: newterm() failed [%s].", strerror(errno))); - fclose(s_ttyOutputFile); - fclose(s_ttyInputFile); - return; - } - - //-- Initialize the curses library. - s_initialWindow = initscr(); - if (!s_initialWindow) - { - DEBUG_WARNING(true, ("DebugMonitor: initscr(): failed [%s].", strerror(errno))); - fclose(s_ttyOutputFile); - fclose(s_ttyInputFile); - return; - } - - //-- Restore the stdout window to its previous state. We won't use stdout. - endwin(); - - //-- Set the default terminal to be the output TTY's terminal screen. - s_initialScreen = set_term(s_outputScreen); - if (!s_initialScreen) - { - DEBUG_WARNING(true, ("DebugMonitor: set_term(): failed [%s].", strerror(errno))); - delscreen(s_outputScreen); - fclose(s_ttyOutputFile); - fclose(s_ttyInputFile); - return; - } - - //-- Create the curses WINDOW at the full size of the TTY. - s_outputWindow = newwin(0, 0, 0, 0); - if (!s_outputWindow) - { - DEBUG_WARNING(true, ("DebugMonitor: newwin(): failed [%s].", strerror(errno))); - delscreen(s_outputScreen); - fclose(s_ttyOutputFile); - fclose(s_ttyInputFile); - return; - } - - //-- Destroy curses data structures associated with the stdout TTY - delwin(s_initialWindow); - delscreen(s_initialScreen); - - //-- Additional profiler input setup. - // Allow translation of arrow keys. - if (keypad(s_outputWindow, true) == ERR) - { - DEBUG_WARNING(true, ("DebugMonitor: keypad() failed [%s].", strerror(errno))); - return; - } - - //-- Add the removal routine to the ExitChain. - s_installed = true; - - // NOTE: this can't go on the exit chain because the MemoryManager - // will write to it way late in processing. - //ExitChain::add(remove, "DebugMonitor"); -} - -// ---------------------------------------------------------------------- - -void DebugMonitor::remove(void) -{ - if (!s_installed) - { - // Exit silently rather than FATAL. There's any number of reasons why - // we might not be installed, and the ExitChain does not call remove, - // so this should be valid. - return; - } - - s_installed = false; - - //-- Restore the TTY's state. - endwin(); - - //-- Delete curses data structures associated with the output terminal. - delwin(s_outputWindow); - s_outputWindow = 0; - - delscreen(s_outputScreen); - s_outputScreen = 0; - - //-- Close file handle to output terminal. - fclose(s_ttyOutputFile); - s_ttyOutputFile = 0; - - fclose(s_ttyInputFile); - s_ttyInputFile = 0; -} - -// ---------------------------------------------------------------------- -/** - * Set the debug window's z-order. - */ - -void DebugMonitor::setBehindWindow(HWND window) -{ - UNREF(window); -} - -// ---------------------------------------------------------------------- -/** - * Clear the debug monitor and home the cursor. - * - * If the mono monitor is not installed, this routine does nothing. - * - * This routine will clear the contents of the debug monitor, reset the screen - * offset to 0, and move the cursor to the upper left corner of the screen. - * - * @see DebugMonitor::home(), DebugMonitor::clearToCursor() - */ - -void DebugMonitor::clearScreen(void) -{ - //-- Ignore request if DebugMonitor isn't installed. - if (!s_installed) - return; - - //-- Tell curses to clear the virtual screen. The actual - // clear will not take effect until the next showOutput() call - // is made. - IGNORE_RETURN(wclear(s_outputWindow)); - - //-- Goto upper left corner. - gotoXY(0, 0); -} - -// ---------------------------------------------------------------------- -/** - * Clear the debug monitor to the current cursor position and home the cursor. - * - * If the debug monitor is not installed, this routine does nothing. - * - * This routine will clear the contents of the debug monitor only up to the - * cursor position. If the cursor is not very far down on the screen, - * this routine may be significantly more efficient clearing the screen. - * - * It will also move the cursor to the upper left corner of the screen. - * - * @see DebugMonitor::clearScreen(), DebugMonitor::home() - */ - -void DebugMonitor::clearToCursor(void) -{ - //-- Ignore request if DebugMonitor isn't installed. - if (!s_installed) - return; - - //-- I don't see this functionality in curses. Just clear - // the entire screen. - clearScreen(); -} - -// ---------------------------------------------------------------------- -/** - * Position the cursor on the debug monitor screen. - * - * If the debug monitor is not installed, this routine does nothing. - * - * All printing happens at the cursor position. - * - * @param x New X position for the cursor - * @param y New Y position for the cursor - */ - -void DebugMonitor::gotoXY(int x, int y) -{ - //-- Ignore request if DebugMonitor isn't installed. - if (!s_installed) - return; - - //-- Move the cursor position to the specified location. - const int result = wmove(s_outputWindow, y, x); - DEBUG_REPORT_LOG(result == ERR, ("DebugMonitor: wmove(%d, %d) failed [%s].\n", y, x, strerror(errno))); - UNREF(result); -} - -// ---------------------------------------------------------------------- -/** - * Display a string on the debug monitor. - * * If the debug monitor is not installed, this routine does nothing. - * - * Printing occurs from the cursor position. - * - * Newline characters '\n' will cause the cursor position to advance to the - * beginning of the next line. If the cursor is already on the last line of - * the screen, the screen will scroll up one line and the cursor will move to - * the beginning of the last line. - * - * The backspace character '\b' will cause the cursor to move one character - * backwards. If at the beginning of the line, the cursor will move to the - * end of the previous line. If already on the first line of the screen, the - * cursor position and screen contents will be unchanged. - * - * All other characters are placed directly into the text frame buffer. - * After each character, the cursor will be logically advanced one - * character forward. If the cursor was on the last column, it will advance - * to the next line. If the cursor was already on the last line, the screen - * will be scrolled up one line and the cursor will move to the beginning of - * the last line. - * - * @param string String to display on the debug monitor - */ - -void DebugMonitor::print(const char *string) -{ - //-- Ignore request if DebugMonitor isn't installed. - if (!s_installed) - return; - - const int result = wprintw(s_outputWindow, const_cast(string)); - DEBUG_REPORT_LOG(result == ERR, ("WARNING: DebugMonitor: wprintw failed [%s].\n", strerror(errno))); - UNREF(result); -} - -// ---------------------------------------------------------------------- -/** - * Ensure all changes to the DebugMonitor have taken effect by the time - * this function returns. - * - * Note: some platforms may do nothing here. The Win32 platform does not - * require flushing. The Linux platform does. Call it assuming - * that it is needed. It will be a no-op when not required. - */ - -void DebugMonitor::flushOutput() -{ - //-- Ignore request if DebugMonitor isn't installed. - if (!s_installed) - return; - - //-- Tell curses to refresh the output window so that - // the virtual curses display is rendered to the real - // terminal display. - const int result = wrefresh(s_outputWindow); - DEBUG_REPORT_LOG(result == ERR, ("WARNING: DebugMonitor: wrefresh failed [%s].\n", strerror(errno))); - UNREF(result); - - //-- Handle tty input here. This is somewhat hacky. Unix tty input - // and output currently are intimately tied to the profiler. Later - // this can be separated out so we can handle multiple TTYs for - // multiple purposes, such as for handling a TTY-based popup debug - // menu for on-the-fly options changing. - const int input = wgetch(s_outputWindow); - if (input != ERR) - { -#if 0 - DEBUG_REPORT_LOG(true, ("DebugMonitor: received key [index=%d].\n", input)); -#endif - - //-- Handle input. - switch (input) - { - case '8': - case KEY_UP: - Profiler::selectionMoveUp(); - break; - - case '9': - case KEY_DOWN: - Profiler::selectionMoveDown(); - break; - - case '0': - case 10: - case KEY_LEFT: - case KEY_RIGHT: - Profiler::selectionToggleExpanded(); - break; - - default: - // Nothing to do. - break; - } - } -} - -// ====================================================================== - -#endif - diff --git a/src/engine/shared/library/sharedDebug/src/linux/DebugMonitor.h b/src/engine/shared/library/sharedDebug/src/linux/DebugMonitor.h deleted file mode 100644 index 092f01c6d..000000000 --- a/src/engine/shared/library/sharedDebug/src/linux/DebugMonitor.h +++ /dev/null @@ -1,67 +0,0 @@ -// ====================================================================== -// -// DebugMonitor.h -// Portions Copyright 1998, Bootprint Entertainment, Inc. -// Portions Copyright 2002, Sony Online Entertainment, Inc. -// -// ====================================================================== - -#ifndef INCLUDED_DebugMonitor_H -#define INCLUDED_DebugMonitor_H - -// ====================================================================== - -#ifdef _DEBUG - -class DebugMonitor -{ -private: - -public: - - static void install(void); - static void remove(void); - - typedef void* HWND; - - static void setBehindWindow(HWND window); - - static void clearScreen(void); - static void clearToCursor(void); - - static void home(void); - static void gotoXY(int x, int y); - static void print(const char *string); - - static void flushOutput(); -}; - -#endif - -// ====================================================================== -// Move the cursor to the upper left hand corner of the mono monitor screen -// -// Remarks: -// -// If the debug monitor is not installed, this routine does nothing. -// -// All printing happens at the cursor position. -// -// This routine is identical to calling gotoXY(0,0); -// -// See Also: -// -// DebugMonitor::gotoXY() - -#ifdef _DEBUG - -inline void DebugMonitor::home(void) -{ - gotoXY(0,0); -} - -#endif - -// ====================================================================== - -#endif diff --git a/src/engine/shared/library/sharedDebug/src/linux/PerformanceTimer.cpp b/src/engine/shared/library/sharedDebug/src/linux/PerformanceTimer.cpp deleted file mode 100644 index 68c36d8cb..000000000 --- a/src/engine/shared/library/sharedDebug/src/linux/PerformanceTimer.cpp +++ /dev/null @@ -1,125 +0,0 @@ -//=================================================================== // -// -// PerformanceTimer.cpp -// copyright 2000-2004 Sony Online Entertainment -// All Rights Reserved -// -//=================================================================== - -#include "sharedFoundation/FirstSharedFoundation.h" -#include "sharedDebug/PerformanceTimer.h" - -//=================================================================== - -#include - -//=================================================================== - -void PerformanceTimer::install() -{ -} - -//------------------------------------------------------------------- - -PerformanceTimer::PerformanceTimer() -{ - startTime.tv_sec = 0; - startTime.tv_usec = 0; - stopTime.tv_sec = 0; - stopTime.tv_usec = 0; -} - -//------------------------------------------------------------------- - -PerformanceTimer::~PerformanceTimer() -{ -} - -//------------------------------------------------------------------- - -void PerformanceTimer::start() -{ - int const result = gettimeofday(&startTime, NULL); - FATAL(result != 0,("PerformanceTimer::start failed")); -} - -//------------------------------------------------------------------- - -void PerformanceTimer::resume() -{ - long sec = stopTime.tv_sec - startTime.tv_sec; - long usec = stopTime.tv_usec - startTime.tv_usec; - if(usec < 0) - { - --sec; - usec += 1000000; - } - - int const result = gettimeofday(&startTime, NULL); - FATAL(result != 0,("PerformanceTimer::resume failed")); - - startTime.tv_sec -= sec; - startTime.tv_usec -= usec; - if(startTime.tv_usec < 0) - { - --startTime.tv_sec; - startTime.tv_usec += 1000000; - } -} - -//------------------------------------------------------------------- - -void PerformanceTimer::stop() -{ - int result = gettimeofday(&stopTime, NULL); - FATAL(result != 0,("PerformanceTimer::start failed")); -} - -//------------------------------------------------------------------- - -float PerformanceTimer::getElapsedTime() const -{ - long sec = stopTime.tv_sec - startTime.tv_sec; - long usec = stopTime.tv_usec - startTime.tv_usec; - if(usec < 0) - { - --sec; - usec += 1000000; - } - return static_cast(sec) +(static_cast(usec) / 1000000.0f); -} - -//------------------------------------------------------------------- - -float PerformanceTimer::getSplitTime() const -{ - timeval currentTime; - - int const result = gettimeofday(¤tTime, NULL); - FATAL(result != 0,("PerformanceTimer::getSplitTime failed")); - - long sec = currentTime.tv_sec - startTime.tv_sec; - long usec = currentTime.tv_usec - startTime.tv_usec; - if(usec < 0) - { - --sec; - usec += 1000000; - } - - return static_cast(sec) +(static_cast(usec) / 1000000.0f); -} - -//------------------------------------------------------------------- - -void PerformanceTimer::logElapsedTime(const char* string) const -{ - UNREF(string); - -#ifdef _DEBUG - static char buffer [1000]; - sprintf(buffer, "%s : %1.5f seconds\n", string ? string : "null", getElapsedTime()); - DEBUG_REPORT_LOG_PRINT(true, ("%s", buffer)); -#endif -} - -//------------------------------------------------------------------- diff --git a/src/engine/shared/library/sharedDebug/src/linux/PerformanceTimer.h b/src/engine/shared/library/sharedDebug/src/linux/PerformanceTimer.h deleted file mode 100644 index 4e933ae18..000000000 --- a/src/engine/shared/library/sharedDebug/src/linux/PerformanceTimer.h +++ /dev/null @@ -1,51 +0,0 @@ -//=================================================================== // -// -// PerformanceTimer.h -// copyright 2000-2004 Sony Online Entertainment -// All Rights Reserved -// -//=================================================================== - -#ifndef INCLUDED_PerformaceTimer_H -#define INCLUDED_PerformaceTimer_H - -//=================================================================== - -#include -#include - -//=================================================================== - -class PerformanceTimer -{ -public: - - static void install(); - -public: - - PerformanceTimer(); - ~PerformanceTimer(); - - void start(); - void resume(); - void stop(); - - float getElapsedTime() const; - float getSplitTime() const; - void logElapsedTime(const char* string) const; - -private: - - timeval startTime; - timeval stopTime; - -private: - - PerformanceTimer(PerformanceTimer const &); - PerformanceTimer & operator=(PerformanceTimer const &); -}; - -//=================================================================== - -#endif diff --git a/src/engine/shared/library/sharedDebug/src/linux/ProfilerTimer.cpp b/src/engine/shared/library/sharedDebug/src/linux/ProfilerTimer.cpp deleted file mode 100644 index 73aa4150e..000000000 --- a/src/engine/shared/library/sharedDebug/src/linux/ProfilerTimer.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// ====================================================================== -// -// ProfilerTimer.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedDebug/FirstSharedDebug.h" -#include "sharedDebug/ProfilerTimer.h" - -// ====================================================================== - -void ProfilerTimer::install() -{ -} - -// ---------------------------------------------------------------------- - -void ProfilerTimer::getTime(Type &time) -{ - timeval tv; - gettimeofday(&tv, 0); - time = static_cast(tv.tv_sec)*static_cast(1000000)+static_cast(tv.tv_usec); -} - -// ---------------------------------------------------------------------- - -void ProfilerTimer::getCalibratedTime(Type &time, Type &frequency) -{ - getTime(time); - frequency = 1000000; -} - -void ProfilerTimer::getFrequency(Type &frequency) -{ - frequency = 1000000; -} - -// ====================================================================== diff --git a/src/engine/shared/library/sharedDebug/src/linux/ProfilerTimer.h b/src/engine/shared/library/sharedDebug/src/linux/ProfilerTimer.h deleted file mode 100644 index c5a5ae751..000000000 --- a/src/engine/shared/library/sharedDebug/src/linux/ProfilerTimer.h +++ /dev/null @@ -1,29 +0,0 @@ -// ====================================================================== -// -// ProfilerTimer.h -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_ProfilerTimer_H -#define INCLUDED_ProfilerTimer_H - -// ====================================================================== - -class ProfilerTimer -{ -public: - - typedef uint64 Type; - -public: - - static void install(); - static void getTime(Type &type); - static void getCalibratedTime(Type &time, Type &frequency); - static void getFrequency(Type &frequency); -}; - -// ====================================================================== - -#endif diff --git a/src/engine/shared/library/sharedFile/src/linux/OsFile.cpp b/src/engine/shared/library/sharedFile/src/linux/OsFile.cpp deleted file mode 100644 index a132016f1..000000000 --- a/src/engine/shared/library/sharedFile/src/linux/OsFile.cpp +++ /dev/null @@ -1,123 +0,0 @@ -// ====================================================================== -// -// OsFile.cpp -// Copyright 2002, Sony Online Entertainment Inc. -// All Rights Reserved. -// -// ====================================================================== - -#include "sharedFile/FirstSharedFile.h" -#include "sharedFile/OsFile.h" - -#include -#include -#include -#include - -// ====================================================================== - -void OsFile::install() -{ -} - -// ---------------------------------------------------------------------- - -bool OsFile::exists(const char *fileName) -{ - struct stat statBuffer; - if (stat(fileName, &statBuffer) != 0) - return false; - - if (S_ISDIR(statBuffer.st_mode)) - return false; - - return true; -} - -// ---------------------------------------------------------------------- - -int OsFile::getFileSize(const char *fileName) -{ - struct stat statBuffer; - int fileSize = 0; - - if (stat(fileName, &statBuffer) == 0) - { - fileSize = static_cast(statBuffer.st_size); - } - return fileSize; -} - -// ---------------------------------------------------------------------- - -OsFile *OsFile::open(const char *fileName, bool randomAccess) -{ - UNREF(randomAccess); - - if (!exists(fileName)) - return 0; - - // attempt to open the file - const int handle = ::open(fileName, O_RDONLY); - FATAL(handle < 0, ("OsFile::open failed to open file %s, errno=%d, which does exist.", fileName, errno)); - - return new OsFile(handle, DuplicateString(fileName)); -} - -// ---------------------------------------------------------------------- - -OsFile::OsFile(int handle, char *fileName) -: - m_handle(handle), - m_length(0), - m_offset(0), - m_fileName(fileName) -{ - m_length = lseek(m_handle, 0, SEEK_END); - lseek(m_handle, 0, SEEK_SET); -} - -// ---------------------------------------------------------------------- - -OsFile::~OsFile() -{ - close(m_handle); - delete [] m_fileName; -} - -// ---------------------------------------------------------------------- - -int OsFile::length() const -{ - return m_length; -} - -// ---------------------------------------------------------------------- - -void OsFile::seek(int newFilePosition) -{ - if (m_offset != newFilePosition) - { - const int result = lseek(m_handle, newFilePosition, SEEK_SET); - DEBUG_FATAL(result != newFilePosition, ("SetFilePointer failed")); - UNREF(result); - m_offset = newFilePosition; - } -} - -// ---------------------------------------------------------------------- - -int OsFile::read(void *destinationBuffer, int numberOfBytes) -{ - int result = 0; - do - { - result = ::read(m_handle, destinationBuffer, numberOfBytes); - DEBUG_FATAL((result < 0 && errno != EAGAIN), ("Read failed for %s: %d %d %s", m_fileName, result, errno, strerror(errno))); - } while (result < 0); - - m_offset += result; - return result; -} - -// ====================================================================== diff --git a/src/engine/shared/library/sharedFile/src/linux/OsFile.h b/src/engine/shared/library/sharedFile/src/linux/OsFile.h deleted file mode 100644 index c7fdec5a8..000000000 --- a/src/engine/shared/library/sharedFile/src/linux/OsFile.h +++ /dev/null @@ -1,51 +0,0 @@ -// ====================================================================== -// -// OsFile.h -// Copyright 2002, Sony Online Entertainment Inc. -// All Rights Reserved. -// -// ====================================================================== - -#ifndef INCLUDED_OsFile_H -#define INCLUDED_OsFile_H - -// ====================================================================== - -class OsFile -{ -public: - - static void install(); - - static bool exists(const char *fileName); - static int getFileSize(const char *fileName); - static OsFile *open(const char *fileName, bool randomAccess=false); - -public: - - ~OsFile(); - - int length() const; - int tell() const; - void seek(int newFilePosition); - int read(void *destinationBuffer, int numberOfBytes); - -private: - - OsFile(int handle, char *fileName); - - OsFile(); - OsFile(const OsFile &); - OsFile &operator =(const OsFile &); - -private: - - int m_handle; - int m_length; - int m_offset; - char *m_fileName; -}; - -// ====================================================================== - -#endif diff --git a/src/engine/shared/library/sharedFoundation/src/linux/ByteOrder.h b/src/engine/shared/library/sharedFoundation/src/linux/ByteOrder.h deleted file mode 100644 index 0a3ff3348..000000000 --- a/src/engine/shared/library/sharedFoundation/src/linux/ByteOrder.h +++ /dev/null @@ -1,20 +0,0 @@ -// ====================================================================== -// -// ByteOrder.h -// jeff grills -// -// copyright 1998 Bootprint Entertainment -// -// ====================================================================== - -#ifndef BYTE_ORDER_H -#define BYTE_ORDER_H - -// ====================================================================== - -#include "../../../../../../engine/shared/library/sharedFoundation/include/public/sharedFoundation/FirstPlatform.h" - -// ====================================================================== - -#endif - diff --git a/src/engine/shared/library/sharedFoundation/src/linux/ConfigSharedFoundation.cpp b/src/engine/shared/library/sharedFoundation/src/linux/ConfigSharedFoundation.cpp deleted file mode 100644 index 79aab4350..000000000 --- a/src/engine/shared/library/sharedFoundation/src/linux/ConfigSharedFoundation.cpp +++ /dev/null @@ -1,289 +0,0 @@ -// ====================================================================== -// -// ConfigSharedFoundation.cpp -// copyright 1998 Bootprint Entertainment -// copyright 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedFoundation/FirstSharedFoundation.h" -#include "sharedFoundation/ConfigSharedFoundation.h" - -#include "sharedFoundation/ConfigFile.h" - -// ====================================================================== - -const int c_defaultFatalCallStackDepth = 32; -const int c_defaultWarningCallStackDepth = 8; - -// ====================================================================== - -namespace ConfigSharedFoundationNamespace -{ - real ms_frameRateLimit; - real ms_minFrameRate; - bool ms_noExceptionHandling; - - bool ms_fpuExceptionPrecision; - bool ms_fpuExceptionUnderflow; - bool ms_fpuExceptionOverflow; - bool ms_fpuExceptionZeroDivide; - bool ms_fpuExceptionDenormal; - bool ms_fpuExceptionInvalid; - - bool ms_demoMode; - - bool ms_useRemoteDebug; - int ms_defaultRemoteDebugPort; - - bool ms_profilerExpandAllBranches = true; - - bool ms_memoryManagerReportAllocations; - bool ms_memoryManagerReportOnOutOfMemory; - - bool ms_useMemoryBlockManager; - bool ms_memoryBlockManagerDebugDumpOnRemove; - - int ms_fatalCallStackDepth; - int ms_warningCallStackDepth; - bool ms_lookUpCallStackNames; - - bool ms_alwaysCanSeeWorldCell; - - bool ms_verboseWarnings; - - float ms_debugReportLongFrameTime; -} - -using namespace ConfigSharedFoundationNamespace; - -// ====================================================================== - -#define KEY_INT(a,b) (ms_ ## a = ConfigFile::getKeyInt("SharedFoundation", #a, b)) -#define KEY_BOOL(a,b) (ms_ ## a = ConfigFile::getKeyBool("SharedFoundation", #a, b)) -#define KEY_FLOAT(a,b) (ms_ ## a = ConfigFile::getKeyFloat("SharedFoundation", #a, b)) -// #define KEY_STRING(a,b) (ms_ ## a = ConfigFile::getKeyString("SharedFoundation", #a, b)) - -// ====================================================================== -// Determine the Platform-specific configuration information -// -// Remarks: -// -// This routine inspects the ConfigFile class to set some variables for rapid access -// by the rest of the engine. - -void ConfigSharedFoundation::install (const Defaults &defaults) -{ - KEY_BOOL(noExceptionHandling, false); - - KEY_BOOL(fpuExceptionPrecision, false); - KEY_BOOL(fpuExceptionUnderflow, false); - KEY_BOOL(fpuExceptionOverflow, false); - KEY_BOOL(fpuExceptionZeroDivide, false); - KEY_BOOL(fpuExceptionDenormal, false); - KEY_BOOL(fpuExceptionInvalid, false); - - KEY_BOOL(demoMode, false); - - KEY_FLOAT(frameRateLimit, defaults.frameRateLimit); - KEY_FLOAT(minFrameRate, 0.0f); - - KEY_BOOL(useRemoteDebug, false); - KEY_INT(defaultRemoteDebugPort, 4445); - - KEY_BOOL(profilerExpandAllBranches, true); - KEY_BOOL(memoryManagerReportAllocations, true); - KEY_BOOL(memoryManagerReportOnOutOfMemory, true); - - KEY_BOOL(useMemoryBlockManager, true); - KEY_BOOL(memoryBlockManagerDebugDumpOnRemove, false); - - KEY_INT(fatalCallStackDepth, c_defaultFatalCallStackDepth); - KEY_INT(warningCallStackDepth, c_defaultWarningCallStackDepth); - KEY_BOOL(lookUpCallStackNames, true); - - KEY_BOOL(alwaysCanSeeWorldCell, false); - - KEY_BOOL(verboseWarnings, false); - - KEY_FLOAT(debugReportLongFrameTime, 0.25f); -} - -// ====================================================================== -/** - * Return the frame rate limit value for the game. - * - * @return The initial frame rate limiter value - */ - -real ConfigSharedFoundation::getFrameRateLimit(void) -{ - return ms_frameRateLimit; -} - -// ---------------------------------------------------------------------- -/** - * Return the minimum frame rate limit value for the game. Frame that take longer - * will be set to the minimum and a message will be logged. - * - * @return The minimum frame rate value - */ - -real ConfigSharedFoundation::getMinFrameRate(void) -{ - return ms_minFrameRate; -} - -// ---------------------------------------------------------------------- -/** - * Return whether to run with exception handling enabled. - * - * @return True to run without exception handling - */ - -bool ConfigSharedFoundation::getNoExceptionHandling(void) -{ - return ms_noExceptionHandling; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getFpuExceptionPrecision(void) -{ - return ms_fpuExceptionPrecision; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getFpuExceptionUnderflow(void) -{ - return ms_fpuExceptionUnderflow; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getFpuExceptionOverflow(void) -{ - return ms_fpuExceptionOverflow; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getFpuExceptionZeroDivide(void) -{ - return ms_fpuExceptionZeroDivide; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getFpuExceptionDenormal(void) -{ - return ms_fpuExceptionDenormal; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getFpuExceptionInvalid(void) -{ - return ms_fpuExceptionInvalid; -} - -// ---------------------------------------------------------------------- - -int ConfigSharedFoundation::getFatalCallStackDepth() -{ - return ms_fatalCallStackDepth; -} - -// ---------------------------------------------------------------------- - -int ConfigSharedFoundation::getWarningCallStackDepth() -{ - return ms_warningCallStackDepth; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getProfilerExpandAllBranches() -{ - return ms_profilerExpandAllBranches; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getUseRemoteDebug() -{ - return ms_useRemoteDebug; -} - -// ---------------------------------------------------------------------- - -int ConfigSharedFoundation::getDefaultRemoteDebugPort() -{ - return ms_defaultRemoteDebugPort; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getDemoMode() -{ - return ms_demoMode; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getAlwaysCanSeeWorldCell() -{ - return ms_alwaysCanSeeWorldCell; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getLookUpCallStackNames() -{ - return ms_lookUpCallStackNames; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getMemoryManagerReportAllocations() -{ - return ms_memoryManagerReportAllocations; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getMemoryManagerReportOnOutOfMemory() -{ - return ms_memoryManagerReportOnOutOfMemory; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getUseMemoryBlockManager() -{ - return ms_useMemoryBlockManager; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getMemoryBlockManagerDebugDumpOnRemove () -{ - return ms_memoryBlockManagerDebugDumpOnRemove; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getVerboseWarnings() -{ - return ms_verboseWarnings; -} - -// ---------------------------------------------------------------------- - -float ConfigSharedFoundation::getDebugReportLongFrameTime() -{ - return ms_debugReportLongFrameTime; -} - -// ====================================================================== diff --git a/src/engine/shared/library/sharedFoundation/src/linux/ConfigSharedFoundation.h b/src/engine/shared/library/sharedFoundation/src/linux/ConfigSharedFoundation.h deleted file mode 100644 index ace081843..000000000 --- a/src/engine/shared/library/sharedFoundation/src/linux/ConfigSharedFoundation.h +++ /dev/null @@ -1,64 +0,0 @@ -// ====================================================================== -// -// ConfigSharedFoundation.h -// copyright 1998 Bootprint Entertainment -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_ConfigSharedFoundation_H -#define INCLUDED_ConfigSharedFoundation_H - -// ====================================================================== - -class ConfigSharedFoundation -{ -public: - - struct Defaults - { - real frameRateLimit; - }; - -public: - - static void install (const Defaults &defaults); - - static real getFrameRateLimit(); - static real getMinFrameRate(); - static bool getNoExceptionHandling(); - - static bool getFpuExceptionPrecision(); - static bool getFpuExceptionUnderflow(); - static bool getFpuExceptionOverflow(); - static bool getFpuExceptionZeroDivide(); - static bool getFpuExceptionDenormal(); - static bool getFpuExceptionInvalid(); - - static bool getDemoMode(); - - static bool getUseRemoteDebug(); - static int getDefaultRemoteDebugPort(); - - static bool getProfilerExpandAllBranches(); - - static bool getMemoryManagerReportAllocations(); - static bool getMemoryManagerReportOnOutOfMemory(); - - static bool getUseMemoryBlockManager(); - static bool getMemoryBlockManagerDebugDumpOnRemove(); - - static int getFatalCallStackDepth(); - static int getWarningCallStackDepth(); - static bool getLookUpCallStackNames(); - - static bool getAlwaysCanSeeWorldCell(); - - static bool getVerboseWarnings(); - - static float getDebugReportLongFrameTime(); -}; - -// ====================================================================== - -#endif diff --git a/src/engine/shared/library/sharedFoundation/src/linux/FirstPlatform.h b/src/engine/shared/library/sharedFoundation/src/linux/FirstPlatform.h deleted file mode 100644 index 1ab235dc0..000000000 --- a/src/engine/shared/library/sharedFoundation/src/linux/FirstPlatform.h +++ /dev/null @@ -1,54 +0,0 @@ -// ====================================================================== -// -// FirstPlatform.h -// jeff grills -// -// copyright 1998 Bootprint Entertainment -// -// ====================================================================== - -#ifndef FIRST_PLATFORM_H -#define FIRST_PLATFORM_H - -// ====================================================================== - -#include - -#define DLLEXPORT - -// ====================================================================== - -// C4514 unreferenced inline function has been removed -// C4710 inline function not expanded -// C4291 no matching operator delete found; memory will not be freed if initialization throws an exception - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../../../../../engine/shared/library/sharedFoundation/include/public/sharedFoundation/PlatformGlue.h" -#include "sharedMemoryManager/MemoryManager.h" - - -// ====================================================================== - -template -inline int ComGetReferenceCount(T *t) -{ - t->AddRef(); - return t->Release(); -} - -// ====================================================================== - -#define FATAL_HR(a,b) FATAL(FAILED(b), (a, HRESULT_CODE(b))) -#define DEBUG_FATAL_HR(a,b) DEBUG_FATAL(FAILED(b), (a, HRESULT_CODE(b))) - -// ====================================================================== - -#endif diff --git a/src/engine/shared/library/sharedFoundation/src/linux/FloatingPointUnit.cpp b/src/engine/shared/library/sharedFoundation/src/linux/FloatingPointUnit.cpp deleted file mode 100644 index 3ad0c9498..000000000 --- a/src/engine/shared/library/sharedFoundation/src/linux/FloatingPointUnit.cpp +++ /dev/null @@ -1,266 +0,0 @@ -// ====================================================================== -// -// FloatingPointUnit.cpp -// jeff grills -// -// copyright 1999 Bootprint Entertainment -// -// ====================================================================== - -#include "sharedFoundation/FirstSharedFoundation.h" -#include "sharedFoundation/FloatingPointUnit.h" - -#include "sharedFoundation/ConfigSharedFoundation.h" - -// ====================================================================== - -int FloatingPointUnit::updateNumber; -WORD FloatingPointUnit::status; -FloatingPointUnit::Precision FloatingPointUnit::precision; -FloatingPointUnit::Rounding FloatingPointUnit::rounding; -bool FloatingPointUnit::exceptionEnabled[E_max]; - -// ====================================================================== - -const WORD PRECISION_MASK = BINARY4(0000,0011,0000,0000); -const WORD PRECISION_24 = BINARY4(0000,0000,0000,0000); -const WORD PRECISION_53 = BINARY4(0000,0010,0000,0000); -const WORD PRECISION_64 = BINARY4(0000,0011,0000,0000); - -const WORD ROUND_MASK = BINARY4(0000,1100,0000,0000); -const WORD ROUND_NEAREST = BINARY4(0000,0000,0000,0000); -const WORD ROUND_CHOP = BINARY4(0000,1100,0000,0000); -const WORD ROUND_DOWN = BINARY4(0000,0100,0000,0000); -const WORD ROUND_UP = BINARY4(0000,1000,0000,0000); - -const WORD EXCEPTION_PRECISION = BINARY4(0000,0000,0010,0000); -const WORD EXCEPTION_UNDERFLOW = BINARY4(0000,0000,0001,0000); -const WORD EXCEPTION_OVERFLOW = BINARY4(0000,0000,0000,1000); -const WORD EXCEPTION_ZERO_DIVIDE = BINARY4(0000,0000,0000,0100); -const WORD EXCEPTION_DENORMAL = BINARY4(0000,0000,0000,0010); -const WORD EXCEPTION_INVALID = BINARY4(0000,0000,0000,0001); -const WORD EXCEPTION_ALL = BINARY4(0000,0000,0011,1111); - -// ====================================================================== - -void FloatingPointUnit::install(void) -{ - precision = P_24; - rounding = R_roundToNearestOrEven; - memset(exceptionEnabled, 0, sizeof(exceptionEnabled)); - - // preserve all other bits - status = getControlWord(); - status &= ~(PRECISION_MASK | ROUND_MASK | EXCEPTION_ALL); - - // set to single precision, rounding, and all exceptions masked - status |= PRECISION_24 | ROUND_NEAREST | EXCEPTION_ALL; - - // check the config platform flags to see if we should enable some exceptions - if (ConfigSharedFoundation::getFpuExceptionPrecision()) - { - exceptionEnabled[E_precision] = true; - status &= ~EXCEPTION_PRECISION; - } - - if (ConfigSharedFoundation::getFpuExceptionUnderflow()) - { - exceptionEnabled[E_underflow] = true; - status &= ~EXCEPTION_UNDERFLOW; - } - - if (ConfigSharedFoundation::getFpuExceptionOverflow()) - { - exceptionEnabled[E_overflow] = true; - status &= ~EXCEPTION_OVERFLOW; - } - - if (ConfigSharedFoundation::getFpuExceptionZeroDivide()) - { - exceptionEnabled[E_zeroDivide] = true; - status &= ~EXCEPTION_ZERO_DIVIDE; - } - - if (ConfigSharedFoundation::getFpuExceptionDenormal()) - { - exceptionEnabled[E_denormal] = true; - status &= ~EXCEPTION_DENORMAL; - } - - if (ConfigSharedFoundation::getFpuExceptionInvalid()) - { - exceptionEnabled[E_invalid] = true; - status &= ~EXCEPTION_INVALID; - } - - setControlWord(status); -} - -// ---------------------------------------------------------------------- - -void FloatingPointUnit::update(void) -{ - WORD currentStatus = getControlWord(); - - if (currentStatus != status) - { - DEBUG_REPORT_LOG_PRINT(true, ("FPU: update=%d, in mode=%04x, should be in mode=%04x", updateNumber, static_cast(currentStatus), static_cast(status))); - setControlWord(status); - } - - ++updateNumber; -} - -// ---------------------------------------------------------------------- - -WORD FloatingPointUnit::getControlWord(void) -{ - //TODO wtf is this asm statement? -#if 0 - WORD controlWord = 0; - __asm fnstcw controlWord; - return controlWord; -#else - return status; -#endif -} - -// ---------------------------------------------------------------------- - -void FloatingPointUnit::setControlWord(WORD controlWord) -{ - //TODO see above? - - UNREF(controlWord); -#if 0 - __asm fldcw controlWord; -#endif -} - -// ---------------------------------------------------------------------- - -void FloatingPointUnit::setPrecision(Precision newPrecision) -{ - WORD bits = 0; - - switch (precision) - { - case P_24: - bits = PRECISION_24; - break; - - case P_53: - bits = PRECISION_53; - break; - - case P_64: - bits = PRECISION_64; - break; - - case P_max: - default: - DEBUG_FATAL(true, ("bad case")); - } - - // record the current state - precision = newPrecision; - - // set the proper bit pattern - status &= ~PRECISION_MASK; - status |= bits; - - // slam it into the FPU - setControlWord(status); -} - -// ---------------------------------------------------------------------- - -void FloatingPointUnit::setRounding(Rounding newRounding) -{ - WORD bits = 0; - - switch (newRounding) - { - case R_roundToNearestOrEven: - bits = ROUND_NEAREST; - break; - - case R_chop: - bits = ROUND_CHOP; - break; - - case R_roundDown: - bits = ROUND_DOWN; - break; - - case R_roundUp: - bits = ROUND_UP; - break; - - case R_max: - default: - DEBUG_FATAL(true, ("bad case")); - } - - // record the current state - rounding = newRounding; - - // set the proper bit pattern - status &= ~ROUND_MASK; - status |= bits; - - // slam it into the FPU - setControlWord(status); -} - -// ---------------------------------------------------------------------- - -void FloatingPointUnit::setExceptionEnabled(Exception exception, bool enabled) -{ - WORD bits = 0; - - switch (exception) - { - case E_precision: - bits = EXCEPTION_PRECISION; - break; - - case E_underflow: - bits = EXCEPTION_UNDERFLOW; - break; - - case E_overflow: - bits = EXCEPTION_OVERFLOW; - break; - - case E_zeroDivide: - bits = EXCEPTION_ZERO_DIVIDE; - break; - - case E_denormal: - bits = EXCEPTION_DENORMAL; - break; - - case E_invalid: - bits = EXCEPTION_INVALID; - break; - - case E_max: - default: - DEBUG_FATAL(true, ("bad case")); - } - - // record the current state - exceptionEnabled[exception] = enabled; - - // twiddle the bit appropriately. these bits masks, so set the bit to disable the exception, clear the bit to enable it. - if (enabled) - status &= ~bits; - else - status |= bits; - - // slam it into the FPU - setControlWord(status); -} - -// ====================================================================== diff --git a/src/engine/shared/library/sharedFoundation/src/linux/FloatingPointUnit.h b/src/engine/shared/library/sharedFoundation/src/linux/FloatingPointUnit.h deleted file mode 100644 index d435343af..000000000 --- a/src/engine/shared/library/sharedFoundation/src/linux/FloatingPointUnit.h +++ /dev/null @@ -1,102 +0,0 @@ -// ====================================================================== -// -// FloatingPointUnit.h -// jeff grills -// -// copyright 1999 Bootprint Entertainment -// -// ====================================================================== - -#ifndef FLOATING_POINT_UNIT_H -#define FLOATING_POINT_UNIT_H - -// ====================================================================== - -class FloatingPointUnit -{ -public: - - enum Precision - { - P_24, - P_53, - P_64, - - P_max - }; - - enum Rounding - { - R_roundToNearestOrEven, - R_chop, - R_roundDown, - R_roundUp, - - R_max - }; - - enum Exception - { - E_precision, - E_underflow, - E_overflow, - E_zeroDivide, - E_denormal, - E_invalid, - - E_max - }; - -private: - - static int updateNumber; - static WORD status; - static Precision precision; - static Rounding rounding; - static bool exceptionEnabled[E_max]; - -public: - - static WORD getControlWord(void); - static void setControlWord(WORD controlWord); - -public: - - static void install(void); - - static void update(void); - - static void setPrecision(Precision newPrecision); - static void setRounding(Rounding newRounding); - static void setExceptionEnabled(Exception exception, bool enabled); - - static Precision getPrecision(void); - static Rounding getRounding(void); - static bool getExceptionEnabled(Exception exception); -}; - -// ====================================================================== - -inline FloatingPointUnit::Precision FloatingPointUnit::getPrecision(void) -{ - return precision; -} - -// ---------------------------------------------------------------------- - -inline FloatingPointUnit::Rounding FloatingPointUnit::getRounding(void) -{ - return rounding; -} - -// ---------------------------------------------------------------------- - -inline bool FloatingPointUnit::getExceptionEnabled(Exception exception) -{ - DEBUG_FATAL(static_cast(exception) < 0 || static_cast(exception) >= static_cast(E_max), ("exception out of range")); //lint !e568 // non-negative quantity is never less than 0 - return exceptionEnabled[exception]; -} - -// ====================================================================== - -#endif diff --git a/src/engine/shared/library/sharedFoundation/src/linux/Os.cpp b/src/engine/shared/library/sharedFoundation/src/linux/Os.cpp deleted file mode 100644 index e9f2b6217..000000000 --- a/src/engine/shared/library/sharedFoundation/src/linux/Os.cpp +++ /dev/null @@ -1,468 +0,0 @@ -// ====================================================================== -// -// Os.cpp -// jeff grills -// -// copyright 1998 Bootprint Entertainment -// -// ====================================================================== - -#include "sharedFoundation/FirstSharedFoundation.h" -#include "sharedFoundation/Os.h" - -#include "sharedFoundation/Clock.h" -#include "sharedFoundation/ConfigSharedFoundation.h" -#include "sharedDebug/DebugMonitor.h" -#include "sharedFoundation/ExitChain.h" -#include "sharedFoundation/FloatingPointUnit.h" -#include "sharedIoWin/IoWinManager.h" - -#include -#include - -// ====================================================================== - -bool Os::installed; -bool Os::runInBackground; -int Os::numberOfUpdates; -int Os::menuValue; -bool Os::paused; -bool Os::wasPaused; -bool Os::gameOver; -bool Os::shouldReturnFromAbort; -char Os::programName[PROGRAM_NAME_SIZE]; -char *Os::shortProgramName; -pthread_t Os::mainThreadId; -bool Os::threadDied; - -bool Os::isMp; -int Os::processorCount; - -// ---------------------------------------------------------------------- - -namespace OsNamespace -{ - class UncatchableException - { - }; -} - - -// ---------------------------------------------------------------------- -/** - * Install the Os subsystem for non-games. - * - * This routine is supported for all platforms, although different platforms may - * require different arguments to this routine. - * - * This routine will add Os::remove to the ExitChain. - * - * @see Os::remove() - */ - -void Os::install(void) -{ - installCommon(); -} - -// ---------------------------------------------------------------------- -/** - * This routine will remove the Os subsystem. - * - * This routine should not be called directly. It will be called from the ExitChain. - * - * @see Os::install() - */ - -void Os::remove(void) -{ - DEBUG_FATAL(!installed, ("not installed")); - installed = false; -} - -// ---------------------------------------------------------------------- - -void Os::installCommon(void) -{ - DEBUG_FATAL(installed, ("already installed")); - - ExitChain::add(Os::remove, "Os::remove", 0, true); - -#if 0 //TODO For now we won't screw with the priority of the process - HANDLE threadHandle = GetCurrentThread(); - DEBUG_FATAL(!SetThreadPriority(threadHandle, THREAD_PRIORITY_ABOVE_NORMAL), ("Failed to set game thread priority")); -#endif - - numberOfUpdates = 0; - mainThreadId = pthread_self(); - - // get the name of the executable -//Can't find UNIX call for this: DWORD result = GetModuleFileName(NULL, programName, sizeof(programName)); - strcpy(programName, "TempName"); - DWORD result = 1; - - - FATAL(result == 0, ("GetModuleFileName failed")); - - // get the file name without the path - shortProgramName = strrchr(programName, '\\'); - if (shortProgramName) - ++shortProgramName; - else - shortProgramName = programName; - - // determine the number of processors by parsing /proc/cpuinfo - processorCount = 1; - FILE * f = fopen("/proc/cpuinfo", "r"); - if (f) - { - char buffer[512]; - while (!feof(f)) - { - fgets(buffer, 512, f); - if (strncmp(buffer, "processor\t: ", 12)==0) - { - processorCount = atoi(buffer+12)+1; - } - } - fclose(f); - } - isMp = processorCount > 1; - - // switch into single-precision floating point mode - FloatingPointUnit::install(); - - installed = true; -} - -// ---------------------------------------------------------------------- - -bool Os::isMainThread(void) -{ - // if the Os class hasn't been installed, then assume we are the main thread. - // otherwise, check to see if our thread id is the main thread id - return !installed || (pthread_self() == mainThreadId); -} - -// ---------------------------------------------------------------------- -/** - * Terminate the application because of an error condition. - * - * This routine is supported for all platforms. - * - * This routine should not be called directly. The engine and game should use the - * FATAL macro to terminate the application because of an error. - * - * Calling Os::returnFromAbort() will cause the routine to do nothing but return - * immediately. - * - * @see Os::returnFromAbort(), FATAL() - */ -#include -void Os::abort(void) -{ - if (!isMainThread()) - { - threadDied = true; - pthread_exit(NULL); - } - - if (!shouldReturnFromAbort) - { - // let the C runtime deal with the abnormal termination - int * dummy = NULL; - int forceCrash = *dummy; - UNREF(forceCrash); - for (;;) - { - // One of these should work: - pthread_kill(pthread_self(), SIGSEGV); - ::kill(0,SIGSEGV); - ::abort(); - OsNamespace::UncatchableException ex; - throw ex; - sleep(10); - } - } -} -//----------------------------------------------------------------- -/** -* Create the specified directory and all of it's parents. -* @param directory the path to a directory -* @return always true currently -*/ - -bool Os::createDirectories (const char *directory) -{ - //-- construct list of subdirectories all the way down to root - std::stack directoryStack; - - std::string currentDirectory = directory; - - static const char path_seps [] = { '\\', '/', 0 }; - - // build the stack - while (!currentDirectory.empty()) - { - // remove trailing backslash - if (currentDirectory[currentDirectory.size()-1] == '\\' || currentDirectory[currentDirectory.size()-1] == '/') - IGNORE_RETURN(currentDirectory.erase(currentDirectory.size()-1)); - - if (currentDirectory[currentDirectory.size()-1] == ':') - { - // we've hit something like c: - break; - } - - if (!currentDirectory.empty()) - directoryStack.push(currentDirectory); - - // now strip off current directory - size_t previousDirIndex = currentDirectory.find_last_of (path_seps); - if (previousDirIndex == currentDirectory.npos) - break; - else - IGNORE_RETURN(currentDirectory.erase(previousDirIndex)); - } - - //-- build all directories specified by the initial directory - while (!directoryStack.empty()) - { - // get the directory - currentDirectory = directoryStack.top(); - directoryStack.pop(); - - // try to create it (don't pass any security attributes) - IGNORE_RETURN (mkdir (currentDirectory.c_str(), 0)); - } - - return true; -} -// ---------------------------------------------------------------------- -/** - * Write out a file. - * - * The file name and where the file is written is system-dependent. - * - * @param fileName Name of the file to write - * @param data Data buffer to write to the file - */ - -bool Os::writeFile(const char *fileName, const void *data, int length) // Length of the data bufferto write -{ - BOOL result; - HANDLE handle; - DWORD written; - - // open the file for writing - handle = CreateFile(fileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - - // check if it was opened - if (handle == INVALID_HANDLE_VALUE) - return false; - - // attempt to write the data - result = WriteFile(handle, data, static_cast(length), &written, NULL); - - // make sure the data was written okay - if (!result || written != static_cast(length)) - { - static_cast(CloseHandle(handle)); - return false; - } - - // close the file - result = CloseHandle(handle); - - // make sure the close was sucessful - if (!result) - return false; - - return true; -} - -// ---------------------------------------------------------------------- -/** - * Update the Os subsystem. - * - * This routine is supported for all platforms. - * - * For the Win* platforms, this routine will process the windows message pump. - */ - -bool Os::update(void) -{ - static int ppid = getppid(); - - FloatingPointUnit::update(); - - ++numberOfUpdates; - -#if 0 -#ifdef _DEBUG - - if (DEBUG_FLAG_PLATFORM(validateHeap)) - { - PROFILER_START("validate heap"); - MemoryManager::validate(); - PROFILER_STOP("validate heap"); - } - -#endif -#endif - - Clock::update(); - - wasPaused = false; - - // if our parent's pid has changed, we tell our caller it should exit - if (getppid() != ppid) - { - WARNING(true, ("Parent process exited!")); - // reset the parent process id, so we don't keep spamming warnings for processes that don't exit because of this - ppid = getppid(); - return false; - } - - return true; -} - -// ---------------------------------------------------------------------- -/** - * Formats a message error using GetLastError() and FormatMessge(). - * - * The buffer returned from this function is dynamically allocated to prevent - * issues with this routine being called from multiple threads. The caller - * must delete the buffer when it is done. - * - * @return A dynamically allocated buffer containing the error message - */ - -char *Os::getLastError(void) -{ - return DuplicateString(strerror(errno)); -} - -// ---------------------------------------------------------------------- - -bool Os::getAbsolutePath(const char *relativePath, char *absolutePath, int absolutePathBufferSize) -{ - // realpath sucks and could cause a buffer overrun. however, it's better than writing it ourselves for now. - char *result = realpath(relativePath, absolutePath); - if (!result) - return false; - - FATAL(istrlen(absolutePath)+1 > absolutePathBufferSize, ("buffer overrun")); - return true; -} - -// ---------------------------------------------------------------------- -/** - * Get the actual system time, in seconds since the epoch. - * - * Do not use this for most game systems, since it does not take into account - * clock sku, game loop times, etc. - */ -time_t Os::getRealSystemTime(void) -{ - return time(0); -} - -// ---------------------------------------------------------------------- -/** - * Convert a time in seconds since the epoch to GMT. - * - */ - -void Os::convertTimeToGMT(const time_t &time, tm &zulu) -{ - zulu=*gmtime(&time); // gmtime uses a single static tm structure. Yuck! -} - -// ---------------------------------------------------------------------- -/** - * Convert a tm structure to the time in seconds since the epoch. - * - */ - -time_t Os::convertGMTToTime(const tm &zulu) -{ - return mktime(const_cast(&zulu)); -} - -// ---------------------------------------------------------------------- -/** - * Get a unique identifier for this thread. - * - * @return A unique identifier for this thread. - */ - -Os::ThreadId Os::getThreadId() -{ - return pthread_self(); -} - -// ---------------------------------------------------------------------- -/** - * Assign the given thread a reasonable name (only works for MSDev 6.0 debugger) - * Since this is Linux-specific, make sure this fuction does nothing - * - */ - -void Os::setThreadName(DWORD threadID, const char* threadName) -{ -} - -// ---------------------------------------------------------------------- -/** - * Cause the current thread to sleep for a period of time. If the period is - * zero, the current thread yields it's timeslice. - */ - -void Os::sleep(int ms) -{ - if (ms == 0) - { - sched_yield(); - } - else - { - usleep(ms * 1000); - } -} - -// ---------------------------------------------------------------------- -/** - * Copy text to the system clipboard. - * - * This routine can be used if the application wants to make some data easily available for pasting (like crash call stacks). - */ - -bool Os::copyTextToClipboard(const char *text) -{ - UNREF(text); - return false; -} - -// ---------------------------------------------------------------------- - -Os::OsPID_t Os::getProcessId() -{ - return getpid(); -} - -// ---------------------------------------------------------------------- - -void Os::setProgramName(const char * name) -{ - strncpy(programName, name, Os::PROGRAM_NAME_SIZE); -} - -// ---------------------------------------------------------------------- - -bool Os::isFocused() -{ - return true; -} - -// ---------------------------------------------------------------------- diff --git a/src/engine/shared/library/sharedFoundation/src/linux/Os.h b/src/engine/shared/library/sharedFoundation/src/linux/Os.h deleted file mode 100644 index 44778b4ec..000000000 --- a/src/engine/shared/library/sharedFoundation/src/linux/Os.h +++ /dev/null @@ -1,264 +0,0 @@ -// ====================================================================== -// -// Os.h -// jeff grills -// -// copyright 1998 Bootprint Entertainment -// -// ====================================================================== - -#ifndef OS_H -#define OS_H - -#include - -// ====================================================================== - -struct DebugMenuEntry; - -// ====================================================================== - -class Os -{ -public: - - typedef pthread_t ThreadId; - typedef pid_t OsPID_t; - - enum - { - MAX_PATH_LENGTH = 512 - }; - - typedef void (*QueueCharacterHookFunction)(int keyboard, int character); - typedef void (*SetSystemMouseCursorPositionHookFunction)(int x, int y); - typedef void (*QueueKeyDownHookFunction)(int keyboard, int character); - - -private: - - Os(void); - Os(const Os &); - Os &operator =(const Os &); - - enum - { - PROGRAM_NAME_SIZE = 512 - }; - -private: - - static void remove(void); - - static void installCommon(void); - -private: - - static bool installed; - static bool runInBackground; - static int numberOfUpdates; - static int menuValue; - static DebugMenuEntry *debugMenuGame; - static bool paused; - static bool wasPaused; - static bool gameOver; - static bool shouldReturnFromAbort; - static bool wantPopupDebugMenu; - static char programName[PROGRAM_NAME_SIZE]; - static char *shortProgramName; - static pthread_t mainThreadId; - static bool threadDied; - static bool isMp; - static int processorCount; - - -public: - - static void install(void); - - static bool isGameOver(void); - static bool isMainThread(void); - static bool wasApplicationPaused(void); - - static bool update(void); - - static void returnFromAbort(void); - static void abort(void); - - static void requestPopupDebugMenu(); - - static bool createDirectories (const char *dirname); - - static bool writeFile(const char *fileName, const void *data, int length); - - static int getNumberOfUpdates(void); - - static char *getLastError(void); - - static void setThreadName(DWORD threadID, const char* name); - static ThreadId getThreadId(); - - static const char *getProgramName(void); - static const char *getShortProgramName(void); - static void setProgramName(const char * name); - - static bool getAbsolutePath(const char *relativePath, char *absolutePath, int absolutePathBufferSize); - - static void sleep(int ms); - - static time_t getRealSystemTime(void); - static void convertTimeToGMT(const time_t &time, tm &zulu); - static time_t convertGMTToTime(const tm &zulu); - - static bool isMultiprocessor(); - static int getProcessorCount(); - - static bool copyTextToClipboard(const char *text); - - static bool wasFocusLost(); - static void setQueueCharacterHookFunction(QueueCharacterHookFunction queueCharacterHookFunction); - static void setSetSystemMouseCursorPositionHookFunction(SetSystemMouseCursorPositionHookFunction setSystemMouseCursorPositionHookFunction); - static OsPID_t getProcessId(); - static bool isFocused(); - - static void setQueueKeyDownHookFunction(QueueKeyDownHookFunction queueKeyDownHookFunction); -}; - -// ---------------------------------------------------------------------- -/** - * Return the full name of the running executable. - * - * The program name will include the path as well. - * - * @return The full name of the running executable - * @see Os::getShortProgramName() - */ - -inline const char *Os::getProgramName(void) -{ - return programName; -} - -// ---------------------------------------------------------------------- -/** - * Return the short name of the running executable. - * - * The program name will not include the path, but will just be the file name. - * - * @return The short name of the running executable - * @see Os::getProgramName() - */ - -inline const char *Os::getShortProgramName(void) -{ - return shortProgramName; -} - -// ---------------------------------------------------------------------- -/** - * Cause Os::abort() to return instead of abort the process. - * - * This routine should not be called directly by users. - * - * This routine is provided so that structured exception handling can catch - * an exception, call Fatal to run the ExitChain, and rethrow the exception - * so that the debugger will catch it. - */ - -inline void Os::returnFromAbort(void) -{ - shouldReturnFromAbort = true; -} - -// ---------------------------------------------------------------------- -/** - * Check if the Os knows the game needs to shut down. - * - * The Os can decide that the game need to end for a number of reasons, - * including closing the application or shutting the machine down. - * - * @return True if the game should quit, otherwise false - */ - -inline bool Os::isGameOver(void) -{ - return gameOver; -} - -// ---------------------------------------------------------------------- -/** - * Return the number of updates that the have occurred. - * - * @return This value is updated during the Os::update() routine. - */ - -inline int Os::getNumberOfUpdates(void) -{ - return numberOfUpdates; -} - -// ---------------------------------------------------------------------- -/** - * Indicate whether or not the application was paused. - * - * @return True if the application was in the background (paused), otherwise false - */ - -inline bool Os::wasApplicationPaused(void) -{ - return wasPaused; -} - -// ---------------------------------------------------------------------- -/** - * Return a flag indicating whether we are running a multiprocessor machine or not. - * - * @return True if the machine has more than one processor, false if not. - */ - -inline bool Os::isMultiprocessor(void) -{ - return isMp; -} - -// ---------------------------------------------------------------------- -/** - * Return the number of processors. - * - * @return The number of processors in the machine. - */ - -inline int Os::getProcessorCount(void) -{ - return processorCount; -} - -// ---------------------------------------------------------------------- - -inline bool Os::wasFocusLost() -{ - return false; -} - -// ---------------------------------------------------------------------- - -inline void Os::setQueueCharacterHookFunction(QueueCharacterHookFunction queueCharacterHookFunction) -{ -} - -// ---------------------------------------------------------------------- - -inline void Os::setSetSystemMouseCursorPositionHookFunction(SetSystemMouseCursorPositionHookFunction setSystemMouseCursorPositionHookFunction) -{ -} - -// ---------------------------------------------------------------------- - -inline void Os::setQueueKeyDownHookFunction(QueueKeyDownHookFunction) -{ -} - - -// ---------------------------------------------------------------------- - -#endif diff --git a/src/engine/shared/library/sharedFoundation/src/linux/PerThreadData.cpp b/src/engine/shared/library/sharedFoundation/src/linux/PerThreadData.cpp deleted file mode 100644 index 3d7f8584f..000000000 --- a/src/engine/shared/library/sharedFoundation/src/linux/PerThreadData.cpp +++ /dev/null @@ -1,161 +0,0 @@ -// ====================================================================== -// -// PerThreadData.cpp -// jeff grills -// -// copyright 1998 Bootprint Entertainment -// -// ====================================================================== - -#include "sharedFoundation/FirstSharedFoundation.h" -#include "sharedFoundation/PerThreadData.h" - -#include "sharedSynchronization/Gate.h" - -// ====================================================================== - -pthread_key_t PerThreadData::slot; -bool PerThreadData::slotCreated=false; - -// ====================================================================== -// Install the per-thread-data subsystem -// -// Remarks: -// -// This routine will install the per-thread-data subsystem that is required for several -// other subsystems in the engine. It should be called from the primary thread before -// any other threads have been created. It will also call threadInstall() for the -// primary thread. -// -// See Also: -// -// PerThreadData::remove() - -void PerThreadData::install(void) -{ - if (pthread_key_create(&slot, 0)!=0) - { - FATAL(true, ("pthread_key_create failed")); - } - slotCreated=true; - - threadInstall(); -} - -// ---------------------------------------------------------------------- -/** - * Remove the per-thread-subsystem. - * - * This routine should be called by the primary thread after all other threads have - * terminated, and no other uses of per-thread-data will occur. - * - * @see PerThreadData::install() - */ - -void PerThreadData::remove(void) -{ - threadRemove(); - - if (pthread_key_delete(slot)!=0) - { - FATAL(true, ("pthread_key_delete failed")); - } - - slotCreated=false; -} - -// ---------------------------------------------------------------------- -/** - * Get access to the per-thread-data. - * - * This routine will verify the per-thread-data subsystem has been installed and the - * threadInstall() function has been called for the current thread. - * - * @return A pointer to the per-thread-data. - */ - -PerThreadData::Data *PerThreadData::getData(bool allowReturnNull) -{ - UNREF(allowReturnNull); - - if (!slotCreated) - { - DEBUG_FATAL(true && !allowReturnNull, ("not installed")); - return NULL; - } - - Data * const data = reinterpret_cast(pthread_getspecific(slot)); - DEBUG_FATAL(!data && !allowReturnNull, ("not installed for this thread")); - return data; -} - -// ---------------------------------------------------------------------- -/** - * Create the per-thread-data for a new thread. - * - * This routine should be called in a thread before the first usage of per-thread-data. - * - * If the client is calling this function on a thread that existed before the engine was - * installed, the client should set isNewThread to false. Setting isNewThread to false - * prevents the function from validating that the thread's TLS is NULL. For threads existing - * before the engine is installed, the TLS data for the thread is undefined. - * - * @param isNewThread [IN] true if the thread was created after the engine was installed, false otherwise - * @see PerThreadData::threadRemove() - */ - -void PerThreadData::threadInstall(bool isNewThread) -{ - UNREF(isNewThread); - - DEBUG_FATAL(!slotCreated, ("not installed")); - - // only check for already-set data if this is supposed to be a new thread - DEBUG_FATAL(isNewThread && pthread_getspecific(slot), ("already installed for this thread")); - - // create the data - Data * const data = new Data; - - // initialize the data - memset(data, 0, sizeof(*data)); - - //create the event for file streaming reads - data->readGate = new Gate(false); - - // set the data into the thread slot - const BOOL result = pthread_setspecific(slot, data); - UNREF(result); - DEBUG_FATAL(result, ("pthread_setspecific failed")); //NB: unlike Windows, returns 0 on success. -} //lint !e429 // Warning -- Custodial pointer 'data' has not been freed or returned) // stored int thread-local-storage - -// ---------------------------------------------------------------------- -/** - * Destroythe per-thread-data for a terminating thread. - * - * This routine should be called in a thread after the last usage of per-thread-data. - * - * @see PerThreadData::threadInstall() - */ - -void PerThreadData::threadRemove(void) -{ - DEBUG_FATAL(!slotCreated, ("not installed")); - DEBUG_FATAL(!pthread_getspecific(slot), ("thread not installed")); - - // get the data - Data *data = getData(); - - //close the event used for file streaming reads - delete data->readGate; - data->readGate = NULL; - - // wipe the data in the thread slot - const BOOL result2 = pthread_setspecific(slot, NULL); - UNREF(result2); - DEBUG_FATAL(result2, ("TlsSetValue failed")); //NB: unlike Windows, returns 0 on success. - - // free the memory - delete data; -} - -// ====================================================================== diff --git a/src/engine/shared/library/sharedFoundation/src/linux/PerThreadData.h b/src/engine/shared/library/sharedFoundation/src/linux/PerThreadData.h deleted file mode 100644 index 596e65a3e..000000000 --- a/src/engine/shared/library/sharedFoundation/src/linux/PerThreadData.h +++ /dev/null @@ -1,232 +0,0 @@ -// ====================================================================== -// -// PerThreadData.h -// jeff grills -// -// copyright 1998 Bootprint Entertainment -// -// ====================================================================== - -#ifndef PER_THREAD_DATA_H -#define PER_THREAD_DATA_H - -// ====================================================================== - -#include "../../../../../../engine/shared/library/sharedFoundation/include/public/sharedFoundation/ExitChain.h" - -class Gate; - -// ====================================================================== -/** - * Provide thread local storage functionality. - * - * This class' purpose is to allow each thread to maintain some storage that is local and private to each thread. - * The system must be installed before use. Each thread that may use per-thread-data will also need to call the - * threadInstall() routine after creation and threadRemove() just before termination of the thread. - */ -class PerThreadData -{ -private: - - struct Data - { - bool exitChainRunning; - bool exitChainFataling; - ExitChain::Entry *exitChainFirstEntry; - - int debugPrintFlags; - - Gate *readGate; - }; - - static pthread_key_t slot; - static bool slotCreated; - -private: - - static Data *getData(bool allowReturnNull=false); - -private: - - PerThreadData(void); - PerThreadData(const PerThreadData &); - PerThreadData &operator =(const PerThreadData &); - -public: - - static void install(void); - static void remove(void); - - static void threadInstall(bool isNewThread = true); - static void threadRemove(void); - - static bool isThreadInstalled(void); - - static bool getExitChainRunning(void); - static void setExitChainRunning(bool newValue); - - static bool getExitChainFataling(void); - static void setExitChainFataling(bool newValue); - - static ExitChain::Entry *getExitChainFirstEntry(void); - static void setExitChainFirstEntry(ExitChain::Entry *newValue); - - static int getDebugPrintFlags(void); - static void setDebugPrintFlags(int newValue); - - static Gate *getFileStreamerReadGate(void); -}; - -// ====================================================================== -/** - * Determine if the per-thread-data is available for this thread - * - * Return value: - * - * True if the per-thread-data is installed correctly, false otherwise - * - * Remarks: - * - * This routine is not intended for general use; it should only be used by the ExitChain class. - * - * -TRF- looks like Win98 does not zero out a new TLS slot for - * threads existing at the time of slot creation. Thus, if you build a - * plugin that only initializes the engine the first time it is - * used, and other threads already exist in the app, those threads - * will contain bogus non-null data in the TLS slot. If the plugin really - * wants to do lazy initialization of the engine, it will need - * to handle calling PerThreadData::threadInstall() for all existing threads - * (except the thread that initialized the engine, which already - * has its PerThreadData::threadInstall() called). - */ - -inline bool PerThreadData::isThreadInstalled(void) -{ - return (getData(true) != NULL); -} - -// ---------------------------------------------------------------------- -/** - * Get the exit chain running flag value. - * - * This routine is not intended for general use; it should only be used by the ExitChain class. - * - * @return True if the exit chain is running, false otherwise. - * @see ExitChain::isRunning() - */ - -inline bool PerThreadData::getExitChainRunning(void) -{ - return getData()->exitChainRunning; -} - -// ---------------------------------------------------------------------- -/** - * Set the exit chain running flag value. - * - * This routine is not intended for general use; it should only be used by the ExitChain class. - * - * @param newValue New value for the exit chain running flag - */ - -inline void PerThreadData::setExitChainRunning(bool newValue) -{ - getData()->exitChainRunning = newValue; -} - -// ---------------------------------------------------------------------- -/** - * Get the exit chain fataling flag value. - * - * This routine is not intended for general use; it should only be used by the ExitChain class. - * - * @return True if the exit chain is fataling, false otherwise. - * @see ExitChain::isFataling() - */ - -inline bool PerThreadData::getExitChainFataling(void) -{ - return getData()->exitChainFataling; -} - -// ---------------------------------------------------------------------- -/** - * Set the exit chain fataling flag value. - * - * This routine is not intended for general use; it should only be used by the ExitChain class. - * - * @param newValue New value for the exit chain fataling flag - */ - -inline void PerThreadData::setExitChainFataling(bool newValue) -{ - getData()->exitChainFataling = newValue; -} - -// ---------------------------------------------------------------------- -/** - * Get the first entry for the exit chain. - * - * This routine is not intended for general use; it should only be used by the ExitChain class. - * This routine may return NULL. - * - * @return Pointer to the first entry on the exit chain - * @see ExitChain::isFataling() - */ - -inline ExitChain::Entry *PerThreadData::getExitChainFirstEntry(void) -{ - return getData()->exitChainFirstEntry; -} - -// ---------------------------------------------------------------------- -/** - * Set the exit chain fataling flag value. - * - * This routine is not intended for general use; it should only be used by the ExitChain class. - * The parameter to this routine may be NULL. - * - * @param newValue New value for the exit chain first entry - */ - -inline void PerThreadData::setExitChainFirstEntry(ExitChain::Entry *newValue) -{ - getData()->exitChainFirstEntry = newValue; -} - -// ---------------------------------------------------------------------- -/** - * Get the debug print flags. - * - * This routine is not intended for general use; it should only be used by the DebugPrint functions. - * - * @return Current value of the debug print flags - */ - -inline int PerThreadData::getDebugPrintFlags(void) -{ - return getData()->debugPrintFlags; -} - -// ---------------------------------------------------------------------- -/** - * Set the debug print flags value. - * - * This routine is not intended for general use; it should only be used by the DebugPrint functions. - */ - -inline void PerThreadData::setDebugPrintFlags(int newValue) -{ - getData()->debugPrintFlags = newValue; -} - -// ---------------------------------------------------------------------- - -inline Gate *PerThreadData::getFileStreamerReadGate(void) -{ - return getData()->readGate; -} - -// ====================================================================== - -#endif diff --git a/src/engine/shared/library/sharedFoundation/src/linux/PlatformGlue.cpp b/src/engine/shared/library/sharedFoundation/src/linux/PlatformGlue.cpp deleted file mode 100644 index e2d7da295..000000000 --- a/src/engine/shared/library/sharedFoundation/src/linux/PlatformGlue.cpp +++ /dev/null @@ -1,273 +0,0 @@ -#include "sharedFoundation/FirstSharedFoundation.h" -#include "sharedFoundation/PlatformGlue.h" -#include - - -real abs(real x) -{ - return fabs(x); -} - -int _stricmp(const char* string1, const char* string2) -{ - int first, second; - - do - { - first = toupper(*string1); - second = toupper(*string2); - string1++; - string2++; - } while (first && first==second); - - return (first - second); -} - -char* _itoa(int value, char* stringOut, int radix) -{ - DEBUG_FATAL((radix != 10), ("itoa only supprts base 10")); - sprintf(stringOut, "%d", value); - return stringOut; -} - -bool QueryPerformanceCounter(__int64* time) -{ - struct timeval tv; - gettimeofday(&tv, NULL); - *time = static_cast(tv.tv_sec); - *time = (*time * 1000000) + static_cast(tv.tv_usec); - - return TRUE; -} - -bool QueryPerformanceFrequency(__int64 *freq) -{ - *freq = CLOCKS_PER_SEC; - return TRUE; - -} - -void Sleep(DWORD msecs) -{ - //Sleep takes a time to sleep in milliseconds. - usleep(msecs*1000); //usleep works with microseconds -} - -int GetLastError() -{ - return errno; -} - -void OutputDebugString(const char* stringOut) -{ - fprintf(stderr,"%s",stringOut); -} - - -//File Support -BOOL WriteFile(FILE* hFile, const void* lpBuffer, DWORD numBytesToWrite, DWORD* numBytesWritten, void* unsup) -{ - int retval; - - if(unsup) - return FALSE; //Windows doesn't support this overrlap buffer - - retval = fwrite(lpBuffer, sizeof(char), numBytesToWrite, hFile); - *numBytesWritten = retval; - return (retval < 0) ? FALSE : TRUE; - -} - -BOOL ReadFile(FILE* hFile, void* lpBuffer, DWORD numBytesToRead, DWORD* numBytesRead, void* unsup) -{ - int retval; - - if(unsup) - return FALSE; //Windows doesn't support this overrlap buffer - - retval = fread(lpBuffer, sizeof(char), numBytesToRead, hFile); - *numBytesRead = retval; - return (retval <= 0) ? FALSE : TRUE; - -} - -DWORD SetFilePointer(FILE* hFile, long lDistanceToMove, long* lpDistanceToMoveHigh, DWORD dwMoveMethod) -{ - //Mimics the Win32 function to set the position of a file pointer. return -1 on failure else current position. - - int retval; - retval = fseek(hFile, lDistanceToMove, dwMoveMethod); - - return (retval == 0) ? ftell(hFile) : -1; -} - -//TODO Consider using a call to open() instead of fopen() to get a better mapping of parameters to Win32 -FILE* CreateFile(const char* fileName, DWORD access, DWORD shareMode, void* unsupA, DWORD creationDisposition, DWORD flagsAndAttributes, FILE* unsupB) -{ - FILE* retval = 0; - - DEBUG_FATAL(flagsAndAttributes != FILE_ATTRIBUTE_NORMAL, ("Unsupported File mode call to CreateFile()")); - DEBUG_FATAL(unsupB != NULL, ("Unsupported File mode call to CreateFile()")); - //DEBUG_FATAL(shareMode != 0, ("Unsupported File mode call to CreateFile()")); - DEBUG_FATAL(unsupA != 0, ("Unsupported File mode call to CreateFile()")); - - switch(creationDisposition) - { - case CREATE_NEW: - retval = fopen(fileName, "r"); - if (retval) - { - fclose(retval); - retval = NULL; - } - else - { - fclose(retval); - retval = fopen(fileName, "w"); - } - break; - - case CREATE_ALWAYS: - retval = fopen(fileName, "w"); - break; - - case OPEN_EXISTING: - retval = fopen(fileName, "r"); - if ((access & GENERIC_WRITE) && retval) - { - fclose(retval); - retval = fopen(fileName, "a"); - rewind(retval); - } - break; - - case OPEN_ALWAYS: - if (access & GENERIC_WRITE) - { - retval = fopen(fileName, "a"); - rewind(retval); - } - else - { - retval = fopen(fileName, "r"); - } - break; - - case TRUNCATE_EXISTING: - DEBUG_FATAL(!(access & GENERIC_WRITE),("Must open truncate file with write access")); - retval = fopen(fileName, "w"); - break; - } - - return retval; -} - - -BOOL CloseHandle(FILE* hFile) -{ - int retval = fclose(hFile); - return (retval == 0) ? TRUE : FALSE; -} - -//TODO There must be a more elegant UNIX command to get file size...fstat() needs filename -DWORD GetFileSize(FILE* hFile, DWORD* lpHighSize) -{ - long int curPos; - DWORD endPos; - curPos = ftell(hFile); - fseek(hFile, 0, SEEK_END); - endPos = ftell(hFile); - fseek(hFile, curPos, SEEK_SET); - return endPos; - -#if 0 -//This is what I want to do, but I have no file des number - struct stat buf; - fstat(hFile, &buf); - return buf->st_size; -#endif -} - -BOOL FileExists(const char* filename) -{ - BOOL retval = false; - - struct stat info; - if (stat(filename, &info) == 0) - { - if (S_ISREG(info.st_mode)) - retval = true; - } - - return retval; -} - - - -//Memory Functions - -void* VirtualAlloc(void* location, DWORD size, DWORD flAllocationType, DWORD flProtect) -{ - if (location) - return location; - - return malloc(size); -} - -BOOL VirtualFree(void* location, DWORD size, DWORD freeType) -{ - free(location); - return TRUE; -} - -BOOL VirtualProtect(void* location, DWORD size, DWORD newProtect, DWORD* oldProect) -{ - //Unused. Function stub for compatibility - return TRUE; -} - -BOOL IsBadReadPtr(const void* location, unsigned int size) -{ - //unused - return TRUE; -} - -void MessageBox (void* unused, const char* message, const char* unused2, int flags) -{ - OutputDebugString(message); -} - -char *ConvertCommandLine(int argc, char ** argv) -{ - static char buffer[2048]; - - int totalSize=0; - for (int i=0; i1023) - { - int argIndex = 0; - fprintf(stderr, "Exceeded command line args length of %d. Total size is %d\n", sizeof(buffer), totalSize); - for(argIndex = 0; argIndex < argc; ++argIndex) - { - fprintf(stderr, "argv[%d]=\"%s\"\n", argIndex, argv[argIndex]); - } - FATAL(true,("Command line exceeds maximum length.")); - } - - buffer[0]='\0'; - - for (int i=0; i -#include -#include - -#include -#include -#include - -typedef unsigned short int WORD; -typedef unsigned long int DWORD; -typedef bool BOOL; -typedef long long __int64; //lint !e13 !e19 // Error: 13 (Bad type), Error: 19 (Useless declaration) // -TRF- Lint preprocessor discrepency, @todo look into this. -typedef __int64 LARGE_INTEGER; - -const BOOL FALSE = 0; -const BOOL TRUE = 1; - - -float abs(float x); -int _stricmp(const char* string1, const char* string2); - -//String to numeric conversions -char* _itoa(int value, char* stringOut, int radix); - -//Format specifier for non-portable printf -#define UINT64_FORMAT_SPECIFIER "%llu" -#define INT64_FORMAT_SPECIFIER "%lli" - -//Constant definition macro for 64 bit values -#define UINT64_LITERAL(a) a ## ull -#define INT64_LITERAL(a) a ## ll - -bool QueryPerformanceCounter(__int64 *time); -bool QueryPerformanceFrequency(__int64 *freq); -void Sleep(DWORD msecs); -int GetLastError(); -void OutputDebugString(const char* stringOut); - -//File Support -#include -#include -#include - -typedef FILE* HANDLE; - -#define INVALID_HANDLE_VALUE NULL //Have to use a #define because this may be a FILE* - - -const int GENERIC_READ = 1 << 0; -const int GENERIC_WRITE = 1 << 1; - -const int CREATE_NEW = 1; -const int CREATE_ALWAYS = 2; -const int OPEN_EXISTING = 3; -const int OPEN_ALWAYS = 4; -const int TRUNCATE_EXISTING = 5; - -const DWORD FILE_ATTRIBUTE_NORMAL = 1; - -const int FILE_CURRENT = SEEK_CUR; -const int FILE_BEGIN = SEEK_SET; -const int FILE_END = SEEK_END; - -const int FILE_SHARE_READ = 1; - -BOOL WriteFile(FILE* hFile, const void* lpBuffer, DWORD numBytesToWrite, DWORD* numBytesWritten, void* unsup=NULL); -BOOL ReadFile(FILE* hFile, void* lpBuffer, DWORD numBytesToWrite, DWORD* numBytesRead, void* unsup=NULL); -DWORD SetFilePointer(FILE* hFile, long lDistanceToMove, long* lpDistanceToMoveHigh, DWORD dwMoveMethod); -FILE* CreateFile(const char* fileName, DWORD access, DWORD shareMode, void* unsupA, DWORD creationDisposition, DWORD flagsAndAttributes, FILE* unsup2); -BOOL CloseHandle(FILE* hFile); -DWORD GetFileSize(FILE* hFile, DWORD* lpHighSize); -BOOL FileExists(const char* fileName); - - -//Memory Support - -const int MEM_RESERVE = 0; -const int MEM_COMMIT = 1; -const int PAGE_READWRITE = 0; -const int MEM_RELEASE = 0; -const int PAGE_NOACCESS = 0; - -void* VirtualAlloc(void* location, DWORD size, DWORD flAllocationType, DWORD flProtect); -BOOL VirtualFree(void* location, DWORD size, DWORD freeType); -BOOL VirtualProtect(void* location, DWORD size, DWORD newProtect, DWORD* oldProect); -BOOL IsBadReadPtr(const void* location, unsigned int size); - -//Misc output stuff - -const int MB_OK = 0; -const int MB_ICONEXCLAMATION = 1; -void MessageBox (void* unused, const char* message, const char* unused2, int flags); -char *ConvertCommandLine(int argc, char ** argv); - -//String functions -#define _vsnprintf vsnprintf - -//----------------------------------------------------------------- - -inline int _strnicmp (const char * a, const char * b, size_t count) -{ - return ::strncasecmp (a, b, count); -} - -//----------------------------------------------------------------- - -inline int _open(const char *filename, int oflag) { return open(filename, oflag); } -inline int _open(const char *filename, int oflag, mode_t pmode) { return open(filename, oflag, pmode); } -inline int _creat(const char *filename, mode_t pmode) { return creat(filename, pmode); } -inline int _close(int fd) { return close(fd); } -inline int _write(int fd, const void *buffer, unsigned int count) { return write(fd, buffer, count); } -inline int _dup(int fd) { return dup(fd); } -inline int _dup2(int oldfd, int newfd) { return dup2(oldfd, newfd); } -inline long _lseek(int fd, long offset, int origin) { return lseek(fd, offset, origin); } -inline int _read(int fd, void *buffer, unsigned int count) { return read(fd, buffer, count); } -inline long _tell(int fd) { return _lseek(fd,0,SEEK_CUR); } -inline int _umask(int pmode) { return umask(pmode); } -inline int _unlink(const char *pathname) { return unlink(pathname); } - -//----------------------------------------------------------------- - -#endif //INCLUDED_MISC_H diff --git a/src/engine/shared/library/sharedFoundation/src/linux/SetupSharedFoundation.cpp b/src/engine/shared/library/sharedFoundation/src/linux/SetupSharedFoundation.cpp deleted file mode 100644 index 0a2fc1ec9..000000000 --- a/src/engine/shared/library/sharedFoundation/src/linux/SetupSharedFoundation.cpp +++ /dev/null @@ -1,185 +0,0 @@ -// ====================================================================== -// -// SetupSharedFoundation.cpp -// copyright 1998 Bootprint Entertainment -// copyright 2001 - 2002 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedFoundation/FirstSharedFoundation.h" -#include "sharedFoundation/SetupSharedFoundation.h" - -#include "sharedDebug/ConfigSharedDebugLinux.h" -#include "sharedDebug/DebugMonitor.h" -#include "sharedDebug/Profiler.h" -#include "sharedFoundation/Clock.h" -#include "sharedFoundation/CommandLine.h" -#include "sharedFoundation/ConfigFile.h" -#include "sharedFoundation/ConfigSharedFoundation.h" -#include "sharedFoundation/CrcLowerString.h" -#include "sharedFoundation/ExitChain.h" -#include "sharedFoundation/Os.h" -#include "sharedFoundation/PerThreadData.h" -#include "sharedFoundation/StaticCallbackEntry.h" - -#include -#include - -// ====================================================================== -/** - * Install the engine. - * - * The settings in the Data structure will determine which subsystems - * get initialized. - */ - -void SetupSharedFoundation::install(const Data &data) -{ - // and get the command line stuff in quick so we can make decisions based on the command line settings - CommandLine::install(); - ConfigFile::install(); - - if (data.lpCmdLine) - CommandLine::absorbString(data.lpCmdLine); - if (data.argc) - CommandLine::absorbStrings(const_cast(data.argv+1), data.argc-1); - -#if 0 - //currently there's a problem that we cannot override the defaults here. - if (data.configFile) - IGNORE_RETURN(ConfigFile::loadFile(data.configFile)); -#endif - - // get the post command-line text for the ConfigFile (key-value pairs) - const char *configString = CommandLine::getPostCommandLineString(); - if (configString) - ConfigFile::loadFromCommandLine(configString); - - //@todo there is a lot of stuff in win32 setup not here...like exitchain - Profiler::registerDebugFlags(); -#if _DEBUG - MemoryManager::registerDebugFlags(); -#endif//_DEBUG - - // Setup Linux DebugMonitor support. - // @todo fix this dependency: DebugMonitor really should be moved into Foundation the way things currently are. TRF is following the existing win32 setup. -#ifdef _DEBUG - ConfigSharedDebugLinux::install(); - DebugMonitor::install(); -#endif - - // setup the engine configuration - ConfigSharedFoundation::Defaults defaults; - defaults.frameRateLimit = data.frameRateLimit; - ConfigSharedFoundation::install(defaults); - SetWarningStrictFatal(ConfigFile::getKeyBool("SharedDebug", "strict", false)); - Report::install(); - Clock::install(data.runInBackground, false); - - PersistentCrcString::install(); - CrcLowerString::install(); - StaticCallbackEntry::install(); -} - -// ---------------------------------------------------------------------- -// Call a function with appropriate exception handling (not) -// -// Remarks: -// -// this is stubbed and exception handling is ignored currently - -void SetupSharedFoundation::callbackWithExceptionHandling( - void (*callback)(void) // Routine to call with exception handling - ) -{ - if (ConfigSharedFoundation::getNoExceptionHandling()) - { - callback(); - } - else - { -#if 0 - try - { - callback(); - } - catch (__exception * mathException) - { - FATAL(true, ("Math Exception: %s\n", mathException->name)); - } - catch (const char* message) - { - FATAL(true, ("Character Exception: %s\n", message)); - } - catch(std::exception & m) - { - const char * c = m.what(); - FATAL(true, ("Std::exception: %s\n", c)); - } - catch(...) - { - FATAL(true, ("Unknown exception\n")); - } -#else - callback(); -#endif - } -} - -// ---------------------------------------------------------------------- -/** - * Uninstall the engine. - * - * This routine will properly uninstall the engine componenets that were - * installed by SetupSharedFoundation::install(). - */ - -void SetupSharedFoundation::remove(void) -{ - ExitChain::quit(); - - if (GetNumberOfWarnings()) - REPORT(true, Report::RF_print | Report::RF_log | Report::RF_dialog, ("%d warnings logged", GetNumberOfWarnings())); - - // this routine can't be on the exit chain because the exit chain depends upon the PerThreadData class being around - //PerThreadData::remove(); -} - -// ---------------------------------------------------------------------- - -SetupSharedFoundation::Data::Data(Defaults defaults) -{ - Zero(*this); - - switch (defaults) - { - case D_game: - runInBackground = true; - - lpCmdLine = NULL; - argc = 0; - argv = NULL; - - configFile = NULL; - - frameRateLimit = CONST_REAL(0); - break; - - case D_console: - runInBackground = true; - - lpCmdLine = NULL; - argc = 0; - argv = NULL; - - configFile = NULL; - - frameRateLimit = CONST_REAL(0); - break; - - default: - DEBUG_FATAL(true, ("unknown case")); - } -} - -// ====================================================================== diff --git a/src/engine/shared/library/sharedFoundation/src/linux/SetupSharedFoundation.h b/src/engine/shared/library/sharedFoundation/src/linux/SetupSharedFoundation.h deleted file mode 100644 index 1d05421aa..000000000 --- a/src/engine/shared/library/sharedFoundation/src/linux/SetupSharedFoundation.h +++ /dev/null @@ -1,58 +0,0 @@ -// ====================================================================== -// -// SetupSharedFoundation.h -// copyright 1998 Bootprint Entertainment -// copyright 2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_SetupSharedFoundation_H -#define INCLUDED_SetupSharedFoundation_H - -// ====================================================================== - -struct DebugMenuEntry; - -// ====================================================================== - -class SetupSharedFoundation -{ -public: - - struct Data - { - // allow running in background - bool runInBackground; - - // pointer to command line - char* lpCmdLine; - int argc; - char **argv; - - const char *configFile; - - real frameRateLimit; - - public: - - enum Defaults - { - D_game, - D_console - }; - - Data(Defaults defaults); - }; - -public: - - static void install(const Data &data); - static void remove(void); - - static void callbackWithExceptionHandling(void (*callback)(void)); - -}; - -// ====================================================================== - -#endif diff --git a/src/engine/shared/library/sharedFoundation/src/linux/vsnprintf.cpp b/src/engine/shared/library/sharedFoundation/src/linux/vsnprintf.cpp deleted file mode 100644 index 6b4c5647f..000000000 --- a/src/engine/shared/library/sharedFoundation/src/linux/vsnprintf.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// ====================================================================== -// -// vsnprintf.cpp -// jeff grills -// -// copyright 1998 Bootprint Entertainment -// -// ====================================================================== - -#include "sharedFoundation/FirstSharedFoundation.h" -#include "sharedFoundation/vsnprintf.h" - -#include - -// ====================================================================== -// Format a printf-style string into a text buffer of fixed size -// -// Return value: -// -// The number of characters written into the buffer, or -1 if the buffer was too small -// -// Remarks: -// -// If the buffer would overflow, the null terminating character is not written and -1 -// will be returned. - -#ifdef _MSC_VER - -int vsnprintf(char *buffer, size_t count, const char *format, va_list va) -{ - return _vsnprintf(buffer, count, format, va); -} - -#endif -// ====================================================================== diff --git a/src/engine/shared/library/sharedFoundation/src/linux/vsnprintf.h b/src/engine/shared/library/sharedFoundation/src/linux/vsnprintf.h deleted file mode 100644 index 2dc530903..000000000 --- a/src/engine/shared/library/sharedFoundation/src/linux/vsnprintf.h +++ /dev/null @@ -1,24 +0,0 @@ -// ====================================================================== -// -// vsnprintf.h -// jeff grills -// -// copyright 1998 Bootprint Entertainment -// -// ====================================================================== - -#ifndef VSNPRINTF_H -#define VSNPRINTF_H - -// ====================================================================== - -#ifdef _MSC_VER - -int vsnprintf(char *buffer, size_t count, const char *format, va_list va); - -#endif - -// ====================================================================== - -#endif - diff --git a/src/engine/shared/library/sharedFoundation/src/win32/Os.cpp b/src/engine/shared/library/sharedFoundation/src/win32/Os.cpp index 928979e5d..2a8e88136 100644 --- a/src/engine/shared/library/sharedFoundation/src/win32/Os.cpp +++ b/src/engine/shared/library/sharedFoundation/src/win32/Os.cpp @@ -18,7 +18,6 @@ #include "sharedFoundation/Clock.h" #include "sharedFoundation/ConfigFile.h" #include "sharedFoundation/ConfigSharedFoundation.h" -#include "sharedFoundation/CrashReportInformation.h" #include "sharedFoundation/ExitChain.h" #include "sharedFoundation/FloatingPointUnit.h" #include "sharedFoundation/Production.h" @@ -80,7 +79,6 @@ namespace OsNamespace Os::IMEHookFunction ms_IMEHookFunction; Os::QueueKeyDownHookFunction ms_queueKeyDownHookFunction; - int ms_processorCount; int ms_debugKeyIndex; int ms_SystemMouseCursorPositionX; int ms_SystemMouseCursorPositionY; @@ -245,106 +243,6 @@ void Os::installCommon() // switch into single-precision floating point mode FloatingPointUnit::install(); - // get the amount of memory - MEMORYSTATUS memoryStatus; - GlobalMemoryStatus(&memoryStatus); - CrashReportInformation::addStaticText("Ram: %dmb\n", memoryStatus.dwTotalPhys / (1024 * 1024)); - - // log the os information - { - OSVERSIONINFO versionInfo; - Zero(versionInfo); - versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx(&versionInfo); - CrashReportInformation::addStaticText("Os1: %d.%d.%d\n", versionInfo.dwMajorVersion, versionInfo.dwMinorVersion, versionInfo.dwBuildNumber); - - char const * os = "Unknown"; - - char CDECL pwine_get_version; - HMODULE hntdll = GetModuleHandle("ntdll.dll"); - - switch (versionInfo.dwMajorVersion) { - case 4: - switch (versionInfo.dwMinorVersion){ - case 10: - os = "Windows 98"; - break; - case 90: - os = "Windows ME"; - break; - } - break; - case 5: - switch (versionInfo.dwMinorVersion) { - case 0: - os = "Windows 2000"; - break; - case 1: - os = "Windows XP"; - break; - case 2: - os = "Windows 2003"; - break; - } - break; - case 6: - switch (versionInfo.dwMinorVersion){ - case 0: - os = "Windows Vista"; - break; - case 1: - os = "Windows 7"; - break; - case 2: - os = "Windows 8"; - break; - case 3: - os = "Windows 8.1"; - break; - } - break; - case 10: - os = "Windows 10"; - break; - } - - //detect WINE - if (hntdll) - { - pwine_get_version = (char)GetProcAddress(hntdll, "wine_get_version"); - if (pwine_get_version) - { - os = strcat("Wine ", &pwine_get_version); - } - } - - CrashReportInformation::addStaticText("Os2: %s %s\n", os, versionInfo.szCSDVersion); - } - - // get the number of processors - SYSTEM_INFO si; - GetSystemInfo(&si); - ms_processorCount = static_cast(si.dwNumberOfProcessors); - REPORT_LOG (ConfigSharedFoundation::getVerboseHardwareLogging(), ("Processor Count: %i\n", ms_processorCount)); - CrashReportInformation::addStaticText("NumProc: %d\n", ms_processorCount); - - { - HKEY key; - LONG result = RegOpenKeyEx (HKEY_LOCAL_MACHINE, "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", 0, KEY_EXECUTE, &key); - - if (result == ERROR_SUCCESS) - { - DWORD data; - DWORD type = REG_DWORD; - DWORD size = sizeof (data); - result = RegQueryValueEx (key, "~MHz", NULL, &type, reinterpret_cast (&data), &size); - if ((result == ERROR_SUCCESS) && (size > 0)) - REPORT_LOG (ConfigSharedFoundation::getVerboseHardwareLogging(), ("Processor Speed: %i MHz\n", data)); - - RegCloseKey (key); - } - } - if (!GetKeyboardLayoutName(ms_keyboardLayout)) ms_keyboardLayout[0] = '\0'; @@ -495,30 +393,6 @@ bool Os::wasFocusLost() return ms_wasFocusLost; } -// ---------------------------------------------------------------------- -/** - * Return a flag indicating whether we are running a multiprocessor machine or not. - * - * @return True if the machine has more than one processor, false if not. - */ - -bool Os::isMultiprocessor() -{ - return ms_processorCount > 1; -} - -// ---------------------------------------------------------------------- -/** - * Return the number of processors. - * - * @return The number of processors in the machine. - */ - -int Os::getProcessorCount() -{ - return ms_processorCount; -} - // ---------------------------------------------------------------------- bool Os::isMainThread() @@ -1662,10 +1536,7 @@ bool Os::isFocused() bool Os::launchBrowser(std::string const & website) { std::string URL("http://"); - if (strncmp(URL.c_str(), website.c_str(),7)!=0) - URL+=website; - else - URL=website; + URL=website; int result = reinterpret_cast(ShellExecute(NULL, "open", URL.c_str(), NULL, NULL, SW_SHOWNORMAL)); return (result > 32); } diff --git a/src/engine/shared/library/sharedFoundation/src/win32/Os.h b/src/engine/shared/library/sharedFoundation/src/win32/Os.h index afb3be403..92ea8ef01 100644 --- a/src/engine/shared/library/sharedFoundation/src/win32/Os.h +++ b/src/engine/shared/library/sharedFoundation/src/win32/Os.h @@ -109,9 +109,6 @@ public: static void convertTimeToGMT(const time_t &time, tm &zulu); static time_t convertGMTToTime(const tm &zulu); - static bool isMultiprocessor(); - static int getProcessorCount(); - static void buildRelativePath(const char *baseDirectory, const char *targetPathname, std::string &relativePath); static bool getAbsolutePath(const char *relativePath, char *absolutePath, int absolutePathBufferSize); diff --git a/src/engine/shared/library/sharedFoundationTypes/src/linux/FoundationTypesLinux.h b/src/engine/shared/library/sharedFoundationTypes/src/linux/FoundationTypesLinux.h deleted file mode 100644 index 386c4ffb4..000000000 --- a/src/engine/shared/library/sharedFoundationTypes/src/linux/FoundationTypesLinux.h +++ /dev/null @@ -1,30 +0,0 @@ -// PRIVATE. Do not export this header file outside the package. - -#ifndef INCLUDED_FoundationTypesLinux_H -#define INCLUDED_FoundationTypesLinux_H - -// ====================================================================== -// specify what platform we're running on. - -#define PLATFORM_UNIX -#define PLATFORM_LINUX - -#include -// ====================================================================== -// basic types that we assume to be around - -typedef unsigned int uint; -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned long uint32; -typedef signed char int8; -typedef signed short int16; -typedef signed long int32; -typedef signed long long int int64; -typedef unsigned long long int uint64; -typedef float real; -typedef FILE* FILE_HANDLE; - -#endif - - diff --git a/src/engine/shared/library/sharedLog/src/linux/StderrLogger.cpp b/src/engine/shared/library/sharedLog/src/linux/StderrLogger.cpp deleted file mode 100644 index 963684d27..000000000 --- a/src/engine/shared/library/sharedLog/src/linux/StderrLogger.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// ====================================================================== -// -// StderrLogger.cpp -// -// Copyright 2003 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedLog/FirstSharedLog.h" -#include "sharedLog/StderrLogger.h" -#include "sharedLog/Log.h" -#include -#include - -// ====================================================================== - -namespace StderrLoggerNamespace -{ - bool s_installed; - int s_oldStderr; - int s_stderrPipe[2]; -} -using namespace StderrLoggerNamespace; - -// ====================================================================== - -void StderrLogger::install() -{ - DEBUG_FATAL(s_installed, ("StderrLogger already installed")); - s_installed = true; - s_oldStderr = dup(2); - pipe(s_stderrPipe); - dup2(s_stderrPipe[1], 2); - fcntl(s_stderrPipe[0], F_SETFL, O_NONBLOCK); -} - -// ---------------------------------------------------------------------- - -void StderrLogger::remove() -{ - DEBUG_FATAL(!s_installed, ("StderrLogger not installed")); - dup2(s_oldStderr, 2); - close(s_stderrPipe[0]); - close(s_stderrPipe[1]); - s_installed = false; -} - -// ---------------------------------------------------------------------- - -void StderrLogger::update() -{ - if (!s_installed) - return; - - char buf[8192]; - int nRead = read(s_stderrPipe[0], buf, sizeof(buf)-1); - if (nRead > 0) - { - int startPos = 0; - while (startPos < nRead) - { - int endPos = startPos; - while (buf[endPos] != '\n' && endPos < nRead) - ++endPos; - buf[endPos] = 0; - if (endPos > startPos) - LOG("stderr", ("%s", buf+startPos)); - startPos = endPos+1; - } - } -} - -// ====================================================================== - diff --git a/src/engine/shared/library/sharedMemoryManager/src/linux/OsMemory.cpp b/src/engine/shared/library/sharedMemoryManager/src/linux/OsMemory.cpp deleted file mode 100644 index 6a63523ba..000000000 --- a/src/engine/shared/library/sharedMemoryManager/src/linux/OsMemory.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// ====================================================================== -// -// OsMemory.cpp -// -// Copyright 2002 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedMemoryManager/FirstSharedMemoryManager.h" -#include "sharedMemoryManager/OsMemory.h" - -// ====================================================================== - -void OsMemory::install() -{ -} - -// ---------------------------------------------------------------------- - -void OsMemory::remove() -{ -} - -// ---------------------------------------------------------------------- - -void *OsMemory::commit(void *, size_t bytes) -{ - return ::malloc(bytes); -} - -// ---------------------------------------------------------------------- - -bool OsMemory::free(void *addr, size_t) -{ - ::free(addr); - - return true; -} - -// ====================================================================== diff --git a/src/engine/shared/library/sharedMemoryManager/src/linux/OsMemory.h b/src/engine/shared/library/sharedMemoryManager/src/linux/OsMemory.h deleted file mode 100644 index 8bc52ae51..000000000 --- a/src/engine/shared/library/sharedMemoryManager/src/linux/OsMemory.h +++ /dev/null @@ -1,29 +0,0 @@ -// ====================================================================== -// -// OsMemory.h -// -// Copyright 2002 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_OsMemory_H -#define INCLUDED_OsMemory_H - -// ====================================================================== - -class OsMemory -{ -public: - static void install(); - static void remove(); - - static void * reserve(size_t bytes); - static void * commit(void *addr, size_t bytes); - static bool free(void *addr, size_t bytes); - static bool protect(void *addr, size_t bytes, bool allowAccess); -}; - -// ====================================================================== - -#endif // INCLUDED_OsMemory_H - diff --git a/src/engine/shared/library/sharedMemoryManager/src/linux/OsNewDel.cpp b/src/engine/shared/library/sharedMemoryManager/src/linux/OsNewDel.cpp deleted file mode 100644 index 553adc93c..000000000 --- a/src/engine/shared/library/sharedMemoryManager/src/linux/OsNewDel.cpp +++ /dev/null @@ -1,134 +0,0 @@ -// ====================================================================== -// -// OsNewDel.cpp -// -// Copyright 2002 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedMemoryManager/FirstSharedMemoryManager.h" -#include "sharedMemoryManager/MemoryManager.h" -#include "sharedMemoryManager/OsNewDel.h" - -#include -#include -#include - -static MemoryManager memoryManager __attribute__ ((init_priority (101))); - -#define USE_LIBC_MALLOC_HOOKS 0 - -#if USE_LIBC_MALLOC_HOOKS -extern "C" -{ - void memoryManagerFreeHook(__malloc_ptr_t __ptr, __const __malloc_ptr_t) - { - delete[] (char *)__ptr; - } - - __malloc_ptr_t memoryManagerMallocHook(size_t __size, const __malloc_ptr_t) - { - return new char[__size]; - } - - __malloc_ptr_t memoryManagerReallocHook(__malloc_ptr_t __ptr, size_t size, __const __malloc_ptr_t) - { - if(! __ptr) - return new char[size]; - - return MemoryManager::reallocate(__ptr, size); - } - - __malloc_ptr_t memoryManagerMemAlignHook(size_t alignment, size_t size, __const __malloc_ptr_t) - { - DEBUG_FATAL(true, ("memalign not implemented!")); - return new char[size]; - } - - static void memoryManagerMallocInitializeHook(void) - { - __free_hook = memoryManagerFreeHook; - __malloc_hook = memoryManagerMallocHook; - __realloc_hook = memoryManagerReallocHook; - __memalign_hook = memoryManagerMemAlignHook; - } - void (*__malloc_initialize_hook) (void) = memoryManagerMallocInitializeHook; -} - -#endif//USE_LIBC_MALLOC_HOOKS - -// ====================================================================== - -void *operator new(size_t size, MemoryManagerNotALeak) throw (std::bad_alloc) -{ - return MemoryManager::allocate(size, reinterpret_cast(__builtin_return_address(0)), false, false); -} - -// ---------------------------------------------------------------------- - -void *operator new(size_t size) throw (std::bad_alloc) -{ - return MemoryManager::allocate(size, reinterpret_cast(__builtin_return_address(0)), false, true); -} - -// ---------------------------------------------------------------------- - -void *operator new[](size_t size) throw (std::bad_alloc) -{ - return MemoryManager::allocate(size, reinterpret_cast(__builtin_return_address(0)), true, true); -} - -// ---------------------------------------------------------------------- - -void *operator new(size_t size, const char *file, int line) throw (std::bad_alloc) -{ - return MemoryManager::allocate(size, reinterpret_cast(__builtin_return_address(0)), false, true); -} - -// ---------------------------------------------------------------------- - -void *operator new[](size_t size, const char *file, int line) throw (std::bad_alloc) -{ - return MemoryManager::allocate(size, reinterpret_cast(__builtin_return_address(0)), true, true); -} - -// ---------------------------------------------------------------------- - -void operator delete(void *pointer) throw() -{ - if (pointer) - MemoryManager::free(pointer, false); -} - -// ---------------------------------------------------------------------- - -void operator delete[](void *pointer) throw() -{ - if (pointer) - MemoryManager::free(pointer, true); -} - -// ---------------------------------------------------------------------- - -void operator delete(void *pointer, const char *file, int line) throw() -{ - UNREF(file); - UNREF(line); - - if (pointer) - MemoryManager::free(pointer, false); -} - -// ---------------------------------------------------------------------- - -void operator delete[](void *pointer, const char *file, int line) throw() -{ - UNREF(file); - UNREF(line); - - if (pointer) - MemoryManager::free(pointer, true); -} - -// ====================================================================== - diff --git a/src/engine/shared/library/sharedMemoryManager/src/linux/OsNewDel.h b/src/engine/shared/library/sharedMemoryManager/src/linux/OsNewDel.h deleted file mode 100644 index ad3d4df87..000000000 --- a/src/engine/shared/library/sharedMemoryManager/src/linux/OsNewDel.h +++ /dev/null @@ -1,33 +0,0 @@ -// ====================================================================== -// -// OsNewDel.h -// -// Copyright 2002 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_OsNewDel_H -#define INCLUDED_OsNewDel_H - -// ====================================================================== - -enum MemoryManagerNotALeak -{ - MM_notALeak -}; - -void *operator new(size_t size, MemoryManagerNotALeak) throw(std::bad_alloc); -void *operator new(size_t size) throw(std::bad_alloc); -void *operator new[](size_t size) throw(std::bad_alloc); -void *operator new(size_t size, char const *file, int line) throw(std::bad_alloc); -void *operator new[](size_t size, char const *file, int line) throw(std::bad_alloc); - -void operator delete(void *pointer) throw(); -void operator delete[](void *pointer) throw(); -void operator delete(void *pointer, char const *file, int line) throw(); -void operator delete[](void *pointer, char const *file, int line) throw(); - -// ====================================================================== - -#endif // INCLUDED_OsNewDel_H - diff --git a/src/engine/shared/library/sharedNetwork/src/linux/Address.cpp b/src/engine/shared/library/sharedNetwork/src/linux/Address.cpp deleted file mode 100644 index 3832558fd..000000000 --- a/src/engine/shared/library/sharedNetwork/src/linux/Address.cpp +++ /dev/null @@ -1,372 +0,0 @@ -//--------------------------------------------------------------------- - -#include "FirstSharedNetwork.h" -#include "Address.h" -#include -#include -#include -#include -#include -#include - -//--------------------------------------------------------------------- - -Address::Address() : -addr4(new struct sockaddr_in), -hostAddress("0.0.0.0") -{ - memset(addr4, 0, sizeof(struct sockaddr_in)); - addr4->sin_family = AF_INET; -} - -//--------------------------------------------------------------------- - -Address::Address(const std::string & newHostAddress, unsigned short newHostPort) : -addr4(new struct sockaddr_in), -hostAddress(newHostAddress) -{ - struct hostent * h; - unsigned long u; - - memset(addr4, 0, sizeof(struct sockaddr_in)); - addr4->sin_port = htons(newHostPort); - addr4->sin_family = AF_INET; - // was an address supplied? - if(hostAddress.size() > 0) - { - // Is the first byte a number? (IP names begin with an alpha) - if(!isdigit(hostAddress[0])) - { - // The first byte is a letter, resolve it - if( (h = gethostbyname(hostAddress.c_str())) != 0) - { - memcpy(&addr4->sin_addr, h->h_addr_list[0], sizeof(addr4->sin_addr)); - } - else - { - // boom! grab the entry from the h_addr member instead! - if( (h = gethostbyname(hostAddress.c_str())) != 0) - { - memcpy(&addr4->sin_addr, h->h_addr, sizeof(addr4->sin_addr)); - } - else - { - // no resolution, INADDR_ANY - memset(&addr4->sin_addr, 0, sizeof(addr4->sin_addr)); - - // in debug, fail, something is wrong. - // potential problems - an insanely bogus address was - // passed or the host system is misconfigured and cannot - // resolve the name - assert(false); - } - } - char addrbuf[17] = {"\0"}; - unsigned char * a = (unsigned char *)&addr4->sin_addr; - snprintf(addrbuf, sizeof(addrbuf), "%u.%u.%u.%u", a[0], a[1], a[2], a[3]); - hostAddress = addrbuf; - } - else - { - // A dotted decimal ip number string was supplied. Convert for sin_addr - u = inet_addr(hostAddress.c_str()); - memcpy(&addr4->sin_addr, &u, sizeof(addr4->sin_addr)); - } - } - else - { - // nothing was supplied, assign INADDR_ANY - addr4->sin_addr.s_addr = INADDR_ANY; - } -} - -//--------------------------------------------------------------------- - -Address::Address(const Address & source) : -addr4(new struct sockaddr_in), -hostAddress(source.hostAddress) -{ - *addr4 = *source.addr4; -} - -//--------------------------------------------------------------------- - -Address::Address(const struct sockaddr_in & ipv4addr) : -addr4(new struct sockaddr_in), -hostAddress("") -{ - convertFromSockAddr(ipv4addr); -} - -//--------------------------------------------------------------------- - -Address::~Address() -{ - delete addr4; -} - -//--------------------------------------------------------------------- - -Address & Address::operator = (const Address & rhs) -{ - if(this != &rhs) - { - hostAddress = rhs.hostAddress; - *addr4 = *rhs.addr4; - } - return *this; -} - -//--------------------------------------------------------------------- - -Address & Address::operator = (const struct sockaddr_in & rhs) -{ - convertFromSockAddr(rhs); - return *this; -} - -//--------------------------------------------------------------------- - -void Address::convertFromSockAddr(const struct sockaddr_in & source) -{ - // extract IP bytes from ipv4add4 - const unsigned char * ip; - char name[17] = {"\0"}; - - ip = reinterpret_cast(&source.sin_addr); - snprintf(name, 17, "%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]); //lint !e534 - hostAddress = name; - *addr4 = source; -} - -//--------------------------------------------------------------------- -/** - @brief get a human readable host address - - Example: - \code - void foo(struct sockaddr_in & a) - { - Address b(a); - printf("address = %%s\\n", b.getHostAddress().c_str()); - } - \endcode - - @return A human readable host address string - - @author Justin Randall -*/ -const std::string & Address::getHostAddress() const -{ - return hostAddress; -} - -//--------------------------------------------------------------------- -/** - @brief get the port associated with this address - - Example: - \code - void foo(struct sockaddr_in & a) - { - Address b(a); - printf("port = %%i\\n", b.getHostPort()); - } - \endcode - - @return A human readable port in host-byte order associated with - this address. - - @author Justin Randall -*/ -const unsigned short Address::getHostPort() const -{ - return ntohs(addr4->sin_port); -} - -//--------------------------------------------------------------------- -/** - @brief get the BSD sockaddr describing this address - - Example: - \code - void foo(SOCKET s, unsigned char * d, int l, const Address & a) - { - int t = sizeof(struct sockaddr_in); - sendto(s, s, l, 0, reinterpret_cast(&(a.getSockAddr4())), t); - } - \endcode - - @return a BSD sockaddr that describes this IPv4 address - - @author Justin Randall -*/ -const struct sockaddr_in & Address::getSockAddr4() const -{ - return *addr4; -} - -//--------------------------------------------------------------------- -/** - @brief equality operator - - The equality operator compares the ip address, ip port, - and address family to establish equality. - - Example: - \code - Address a("127.0.0.1", 55443); - Address b; - - b = a; - assert(b == a); - \endcode - - @return True of the right hand side is equal to this address - - @author Justin Randall -*/ -const bool Address::operator == (const Address & rhs) const -{ - return (addr4->sin_addr.s_addr == rhs.addr4->sin_addr.s_addr && - addr4->sin_family == rhs.addr4->sin_family && - addr4->sin_port == rhs.addr4->sin_port); -} - -//--------------------------------------------------------------------- -/** - @brief less-than comparison operator - - The < comparison operator compares the IP number and port. If - the IP numbers are identical, but the left hand side port is - less than the right hand side port, the operator will return - true. - - @return true if the left hand side's IP number is less than - the right hand side IP number. If the numbers are equal, it - will return true if the left hand side IP port is less - than the right hand side port. Otherwise it returns false. - - @author Justin Randall -*/ -const bool Address::operator < (const Address & rhs) const -{ - return(addr4->sin_addr.s_addr < rhs.addr4->sin_addr.s_addr || - addr4->sin_addr.s_addr == rhs.addr4->sin_addr.s_addr && - addr4->sin_port < rhs.addr4->sin_port); -} - -//--------------------------------------------------------------------- -/** - @brief inequality operator - - Leverages the equality operator, so whenever == returns true, - this returns false, and visa versa. - - @return true if the right hand side is not equal to the left - hand side. False if they are equal. - - @see Adress::operator== - - @author Justin Randall -*/ -const bool Address::operator != (const Address & rhs) const -{ - return(! (rhs == *this)); -} - -//--------------------------------------------------------------------- -/** - @brief greater-than comparison operator - - The > comparison operator compares the IP number and port. If - the IP numbers are identical, but the right hand side port is - lesser than the left hand side port, the operator will return - true. - - @return true if the left hand side's IP number is greater than - the right hand side IP number. If the numbers are equal, it - will return true if the left hand side IP port is greater - than the right hand side port. Otherwise it returns false. - - @author Justin Randall -*/ -const bool Address::operator > (const Address & rhs) const -{ - return(addr4->sin_addr.s_addr > rhs.addr4->sin_addr.s_addr || - addr4->sin_addr.s_addr == rhs.addr4->sin_addr.s_addr && - addr4->sin_port > rhs.addr4->sin_port); -} - -//--------------------------------------------------------------------- -/** - @brief a hash_map support routine - - The STL hash_map (present in most STL implementations) requires - a size_t return from a hash function to identify which bucket - a particular value should reside in. On 32 bit or better platforms - the sockaddr_in.sin_addr.s_addr member is small enough to - qualify as a hash-result, provides reasonably unique values - and is reproducable given an address input. - - Example: - \code - typedef std::hash_map AddressMap; - \endcode - - @return the ip number member of a sockaddr_in struct - - @author Justin Randall -*/ -size_t Address::hashFunction() const -{ - return addr4->sin_addr.s_addr; -} - -//--------------------------------------------------------------------- -/** - @brief STL map support routine - - STL maps (including hash_maps) require unique keys, and therefore - need to compare a key for equality with an existing target. - - The functor uses Address::operator = for the comparison. - - Example: - \code - typedef std::hash_map AddressMap; - \endcode - - @return true if the left hand side and right hand side are equal - using Address::operator = - @see Address::operator= - -*/ -bool Address::EqualFunction::operator () (const Address & lhs, const Address & rhs) const -{ - return lhs == rhs; -} - -//--------------------------------------------------------------------- -/** - @brief STL hash_map support routine - - The HashFunction::operator() invokes Address::hashFunction to - determine an appropriate hash for the address. - - Example: - \code - typedef std::hash_map AddressMap; - \endcode - - @see Address::hashFunction - - @author Justin Randall -*/ -size_t Address::HashFunction::operator () (const Address & a) const -{ - return a.hashFunction(); -} -//--------------------------------------------------------------------- - - diff --git a/src/engine/shared/library/sharedNetwork/src/linux/NetworkGetHostName.cpp b/src/engine/shared/library/sharedNetwork/src/linux/NetworkGetHostName.cpp deleted file mode 100644 index a68bba8d3..000000000 --- a/src/engine/shared/library/sharedNetwork/src/linux/NetworkGetHostName.cpp +++ /dev/null @@ -1,141 +0,0 @@ -// NetworkGetHostName.cpp -// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved. -// Author: Justin Randall - -//----------------------------------------------------------------------- - -#include "FirstSharedNetwork.h" -#include "Address.h" -#include "sharedNetwork/NetworkHandler.h" -#include -#include -#include -#include -#include -#include -#include - -//----------------------------------------------------------------------- - -struct HN -{ - HN(); - std::string hostName; -}; - -//----------------------------------------------------------------------- - -HN::HN() -{ - char name[512] = {"\0"}; - if(gethostname(name, sizeof(name)) == 0) - { - Address a(name, 0); - //hostName = name; - hostName = a.getHostAddress(); - } -} - -//----------------------------------------------------------------------- - -const std::string & NetworkHandler::getHostName() -{ - static HN hn; - return hn.hostName; -} - -//----------------------------------------------------------------------- - -const std::string & NetworkHandler::getHumanReadableHostName() -{ - char name[512] = {"\0"}; - static std::string nameString; - if(nameString.empty()) - { - if(gethostname(name, sizeof(name)) == 0) - { - name[sizeof(name) - 1] = 0; - //hostName = name; - nameString = name; - } - } - return nameString; -} - -//----------------------------------------------------------------------- - -struct HL -{ - HL(); - std::vector > addrList; -}; - -//----------------------------------------------------------------------- - -HL::HL() : -addrList() -{ - struct ifconf ifc; - int sock = socket(AF_INET, SOCK_DGRAM, 0); - - // create a socket to perform SIOCGIFCONF on - if(sock > -1) - { - // determine buffer size to receive array of if_req's, initialize it - // when length is appropriate - int reqSize = 100 * sizeof(struct ifreq); - int lastReqSize = reqSize; - for(;;) - { - char * buf = new char[reqSize]; - ifc.ifc_len = reqSize; - ifc.ifc_buf = buf; - memset(ifc.ifc_buf, 0, reqSize); - if (ioctl(sock, SIOCGIFCONF, &ifc) < 0) - { - if (errno != EINVAL || lastReqSize != 0) - { - WARNING(true, ("Error getting interface list: %s", strerror(errno))); - delete buf; - return; - } - } - else - { - if(ifc.ifc_len == lastReqSize) - break; // we have the reqs - lastReqSize = ifc.ifc_len; - } - - // need more buffer space for request - reqSize += sizeof(struct ifreq); - delete [] buf; - } - - int reqCount = reqSize / sizeof(struct ifreq); - int i; - ifreq * reqs = (struct ifreq *)ifc.ifc_buf; - for(i = 0; i < reqCount; ++i) - { - struct sockaddr_in * sa = (struct sockaddr_in *)&reqs[i].ifr_addr; - if(sa->sin_family == AF_INET) - { - char addrbuf[17] = {"\0"}; - unsigned char * a = (unsigned char *)&sa->sin_addr; - snprintf(addrbuf, sizeof(addrbuf), "%u.%u.%u.%u", a[0], a[1], a[2], a[3]); - addrList.push_back(std::make_pair(std::string(reqs[i].ifr_name), std::string(addrbuf))); - } - } - - } -} - -//----------------------------------------------------------------------- - -const std::vector > & NetworkHandler::getInterfaceAddresses() -{ - static HL hl; - return hl.addrList; -} - -//----------------------------------------------------------------------- diff --git a/src/engine/shared/library/sharedNetwork/src/linux/Sock.cpp b/src/engine/shared/library/sharedNetwork/src/linux/Sock.cpp deleted file mode 100644 index 22b293589..000000000 --- a/src/engine/shared/library/sharedNetwork/src/linux/Sock.cpp +++ /dev/null @@ -1,236 +0,0 @@ -//--------------------------------------------------------------------- -#pragma warning(disable : 4127) - -#include "FirstSharedNetwork.h" -#include -#include "Sock.h" -#include -#include -#include -#include -#include -#include - -const int INVALID_SOCKET = 0xFFFFFFFF; - -//--------------------------------------------------------------------- - -Sock::Sock() : -handle(INVALID_SOCKET), -lastError(Sock::SOCK_NO_ERROR), -bindAddress() -{ -} - -//--------------------------------------------------------------------- - -Sock::~Sock() -{ - // ensure we don't block, and that pending - // data is sent with a graceful shutdown - int err; - err = close(handle); - assert(err == 0); - handle = INVALID_SOCKET; -} - -//--------------------------------------------------------------------- -/** - @brief Bind the socket to the specified local address -*/ -bool Sock::bind(const Address & newBindAddress) -{ - bool result = false; - - int enable = 1; - setsockopt(handle, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable)); - - bindAddress = newBindAddress; - assert(handle != INVALID_SOCKET); - socklen_t namelen = sizeof(struct sockaddr_in); - int err = ::bind(handle, reinterpret_cast(&(bindAddress.getSockAddr4())), namelen); - if(err == 0) - { - result = true; - struct sockaddr_in a; - int r; - r = getsockname(handle, reinterpret_cast(&a), &namelen); - assert(r == 0); - bindAddress = a; - } - else - { - result = false; - } - - assert(err == 0); - return result; -} - -//--------------------------------------------------------------------- - -bool Sock::bind() -{ - bool result = false; - struct sockaddr_in a; - socklen_t namelen = sizeof(struct sockaddr_in); - memset(&a, 0, sizeof(struct sockaddr_in)); - a.sin_family = AF_INET; - a.sin_port = 0; - a.sin_addr.s_addr = INADDR_ANY; - assert(handle != INVALID_SOCKET); - int err = ::bind(handle, reinterpret_cast(&a), namelen); - if(err == 0) - { - result = true; - int r; - r = getsockname(handle, reinterpret_cast(&a), &namelen); - assert(r == 0); - bindAddress = a; - } - assert(err == 0); - return result; -} - -//--------------------------------------------------------------------- - -bool Sock::canRecv() const -{ - pollfd r; - r.fd = handle; - r.events = POLLIN | POLLPRI | POLLERR; - - int err = poll(&r, 1, 0); - - if(err < 0) - { - switch(errno) - { - case EINTR: // the system has interrupted the call, it's too busy to send right now - break; - default: - break; - } - } - - return (err > 0); -} - -//--------------------------------------------------------------------- - -bool Sock::canSend() const -{ - pollfd w; - w.fd = handle; - w.events = POLLOUT | POLLERR; - int err = poll(&w, 1, 0); - - if(err < 0) - { - switch(errno) - { - case EINTR: // the system has interrupted the call, it's too busy to send right now - break; - default: - break; - } - } - - return (err > 0); -} - -//--------------------------------------------------------------------- - -const unsigned int Sock::getInputBytesPending() const -{ - unsigned long int bytes = 0; - int err; - err = ioctl(handle, FIONREAD, &bytes); //lint !e1924 (I don't know WHAT Microsoft is doing here!) - assert(err == 0); - return bytes; -} - -//--------------------------------------------------------------------- - -const std::string Sock::getLastError() const -{ - std::string errString; - - switch(errno) - { - case EBADF: - errString = "The argument s is not a valid descriptor."; - break; - case ENOTSOCK: - errString = "The argument s is a file, not a socket."; - break; - case ENOPROTOOPT: - errString = "The option is unknown at the level indicated."; - break; - case EFAULT: - errString = "The address pointed to by optval is not in a valid part of the process address space. For getsockopt, this error may also be returned if optlen is not in a valid part of the process address space."; - break; - case ENOTTY: - errString = "The scoket handle is not associated with a character special device."; - break; - case EINVAL: - errString = "argument is not valid."; - break; - case EAGAIN: - errString = "EAGAIN"; - break; - case EDEADLK: - errString = "EDEADLK"; - break; - case ECONNRESET: - errString = "The connection was reset by the peer."; - lastError = CONNECTION_RESET; - break; - default: - errString = strerror(errno); - break; - } - - return errString; -} - -//--------------------------------------------------------------------- - -void Sock::getPeerName(struct sockaddr_in & target, int s) -{ - socklen_t namelen = sizeof(struct sockaddr_in); - int err; - err = getpeername(s, reinterpret_cast(&(target)), &namelen); - assert(err != -1); -} - -//----------------------------------------------------------------------- -/** @brief determine the maximum message size that may be sent on this socket -*/ -const unsigned int Sock::getMaxMessageSendSize() const -{ - int maxMsgSize = 1500; - /** @todo get msg size via IP interface on Linux - int optlen = sizeof(int); - int result = getsockopt(handle, SOL_SOCKET, SO_MAX_MSG_SIZE, reinterpret_cast(&maxMsgSize), &optlen); - if(result != 0) - { - perror("Sock::getMaxMessageSendSize() : getsockopt()"); - } - */ - return static_cast(maxMsgSize); -} - -//--------------------------------------------------------------------- - -void Sock::setNonBlocking() const -{ - assert(handle != INVALID_SOCKET); - unsigned long int nb = 1; - int err; - err = ioctl(handle, FIONBIO, &nb); //lint !e569 // loss of precision in the FIONBIO macro, beyond my control - assert(err == 0); -} - -//--------------------------------------------------------------------- - diff --git a/src/engine/shared/library/sharedNetwork/src/linux/Sock.h b/src/engine/shared/library/sharedNetwork/src/linux/Sock.h deleted file mode 100644 index bdc1b4be5..000000000 --- a/src/engine/shared/library/sharedNetwork/src/linux/Sock.h +++ /dev/null @@ -1,128 +0,0 @@ -// ====================================================================== -// -// Sock.h -// -// Copyright 2003 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_Sock_H -#define INCLUDED_Sock_H - -// ====================================================================== - -#include "sharedNetwork/Address.h" - -// ====================================================================== - -const unsigned int SOCK_ERROR = 0xFFFFFFFF; - -/** - @brief a BSD socket abstraction - - Sock abstracts BSD sockets for platform independant operation. It - also provides common socket operations to simplify socket management. - - @see BroadcastSock - @see TcpSock - @see UdpSock - - @author Justin Randall -*/ -class Sock -{ -public: - /** - @brief failure states for a socket - */ - enum ErrorCodes - { - SOCK_NO_ERROR, - CONNECTION_FAILED, - CONNECTION_CLOSED, - CONNECTION_RESET - }; - - Sock(); - virtual ~Sock() = 0; - bool bind(const Address & bindAddress); - bool bind(); - bool canSend() const; - bool canRecv() const; - const Address & getBindAddress() const; - const int getHandle() const; - const unsigned int getInputBytesPending() const; - const std::string getLastError() const; - const enum ErrorCodes getLastErrorCode() const; - const unsigned int getMaxMessageSendSize() const; - static void getPeerName(struct sockaddr_in & target, int s); - -private: - // disabled - Sock(const Sock & source); - Sock & operator= (const Sock & source); - -protected: - void setNonBlocking() const; -protected: - int handle; - - /** - @brief support for setting/getting last error from derived - sock classes - */ - mutable enum ErrorCodes lastError; -private: - Address bindAddress; -}; - -//--------------------------------------------------------------------- -/** - @brief return the local address of the socket - - Until a socket is bound, the bind address may be reported as - 0.0.0.0:0 - - @return a const Address reference describing the local address - of the socket. - - @author Justin Randall -*/ -inline const Address & Sock::getBindAddress() const -{ - return bindAddress; -} - -//--------------------------------------------------------------------- -/** - @brief return the platform specific socket handle - - the handle returned is not portable and should only be used locally - for Sock specific operations. - - @author Justin Randall -*/ -inline const int Sock::getHandle() const -{ - return handle; -} - -//--------------------------------------------------------------------- -/** - @brief get the last error code on the socket - - @return the last error code on the socket - - @see Sock::ErrorCodes - - @author Justin Randall -*/ -inline const enum Sock::ErrorCodes Sock::getLastErrorCode() const -{ - return lastError; -} - -//--------------------------------------------------------------------- - -#endif // _Sock_H - diff --git a/src/engine/shared/library/sharedNetwork/src/linux/TcpClient.cpp b/src/engine/shared/library/sharedNetwork/src/linux/TcpClient.cpp deleted file mode 100644 index 8dfa16057..000000000 --- a/src/engine/shared/library/sharedNetwork/src/linux/TcpClient.cpp +++ /dev/null @@ -1,610 +0,0 @@ -//--------------------------------------------------------------------- - -#include "sharedNetwork/FirstSharedNetwork.h" -#include "TcpClient.h" -#include "TcpServer.h" - -#include "Archive/Archive.h" -#include "sharedFoundation/Clock.h" -#include "sharedFoundation/Os.h" -#include "sharedLog/Log.h" -#include "sharedLog/NetLogConnection.h" -#include "sharedNetwork/Connection.h" -#include "sharedNetwork/ConfigSharedNetwork.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//----------------------------------------------------------------------- - -const unsigned long KEEPALIVE_MS = 1000; - -//----------------------------------------------------------------------- - -namespace TcpClientNamespace -{ - std::set s_pendingConnectionSends; - std::set s_tcpClients; - bool s_installed = false; -} - -using namespace TcpClientNamespace; - -//--------------------------------------------------------------------- - -TcpClient::TcpClient (int sockHandle, TcpServer * server) : -m_socket(sockHandle), -m_tcpServer(server), -m_pendingSend(), -m_connection(0), -m_recvBuffer(0), -m_recvBufferLength(0), -m_remoteAddress(), -m_refCount(0), -m_connected (true), -m_lastSendTime(0), -m_bindPort(0), -m_rawTCP( false ) -{ - s_tcpClients.insert(this); - setSockOptions(); - - struct sockaddr_in target; - socklen_t namelen = sizeof(struct sockaddr_in); - if (getpeername(sockHandle, reinterpret_cast(&target), &namelen) == 0) - m_remoteAddress = target; - struct sockaddr_in bindAddr; - - if(getsockname(sockHandle, reinterpret_cast(&bindAddr), &namelen) == 0) - { - m_bindPort = ntohs(bindAddr.sin_port); - } -} - -// ---------------------------------------------------------------------- - -TcpClient::TcpClient (const std::string & a, const unsigned short port) : -m_socket(-1), -m_tcpServer(0), -m_connection(0), -m_recvBuffer(0), -m_recvBufferLength(0), -m_remoteAddress(a, port), -m_refCount(0), -m_connected (false), -m_lastSendTime(0), -m_bindPort(0), -m_rawTCP( false ) -{ - FATAL(! s_installed, ("TcpClient is not installed!")); - - s_tcpClients.insert(this); - setupSocket(); -} - -//--------------------------------------------------------------------- - -TcpClient::~TcpClient() -{ - FATAL(m_refCount > 0, ("Attempting to destroy a TcpClient while references still exist!")); - std::set::iterator f = s_tcpClients.find(this); - if(f != s_tcpClients.end()) - s_tcpClients.erase(f); - f = s_pendingConnectionSends.find(this); - if(f != s_pendingConnectionSends.end()) - s_pendingConnectionSends.erase(f); - - delete[] m_recvBuffer; - if(m_socket != -1) - close (m_socket); -} - -//--------------------------------------------------------------------- - -void TcpClient::addRef() -{ - m_refCount++; -} - -//--------------------------------------------------------------------- -std::string const &TcpClient::getRemoteAddress() const -{ - return m_remoteAddress.getHostAddress(); -} - -//--------------------------------------------------------------------- - -unsigned short TcpClient::getRemotePort() const -{ - return m_remoteAddress.getHostPort(); -} - -//--------------------------------------------------------------------- - -void TcpClient::setSockOptions() -{ - int optval = 1; - setsockopt(m_socket, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)); - setsockopt(m_socket, IPPROTO_TCP, TCP_NODELAY, &optval, sizeof(optval)); - ioctl(m_socket, FIONBIO, &optval); -} - -//--------------------------------------------------------------------- - - -void TcpClient::commit() -{ - int sent = 0; - const unsigned char * ptr = m_pendingSend.getBuffer(); - const unsigned char * const end = ptr + m_pendingSend.getSize(); - static Archive::ByteStream s_localScratchBuffer; - s_localScratchBuffer.clear(); - int retries = 0; - static const int maxRetries = ConfigSharedNetwork::getMaxTCPRetries(); - bool sentSomething = false; - - do - { - // attempt to push pending data to socket - sent = ::send (m_socket, ptr, end - ptr, MSG_NOSIGNAL); - if(sent == -1) - { - // failed - switch(errno) - { - // because it would block on a non-blocking socket - case EAGAIN: - case ENOBUFS: - case ENOMEM: - case EINTR: - { - retries++; - // requeue - break; - } - // an unhandled error (connection reset, for example) - default: - { - m_pendingSend.clear(); - perror("send: "); - if (m_connection) - m_connection->setDisconnectReason("TcpClient::commit send returned -1, errno=%d", errno); - onConnectionClosed(); - return; - break; - } - } - } - else if(sent > 0) - { - sentSomething=true; - ptr += sent; - if(sent < end - ptr) - { - // data was passed to the socket, but not all - // of it could be committed, keep trying! - retries = 0; - Os::sleep(1); - } - } - else if(sent == 0) - { - // tried to send and got nothing through (should have returned an error, but be thorough) - retries ++; - Os::sleep(1); - } - - } while(ptr < end && retries < maxRetries); - - if(ptr == end) - { - // all data was committed, clear pending buffer - m_pendingSend.clear(); - } - else - { - // bailed out before all data was committed, save unsent data for - // next pass on commit() - if (sentSomething) - { - s_localScratchBuffer.put(ptr, end - ptr); - m_pendingSend.clear(); - m_pendingSend.put(s_localScratchBuffer.getBuffer(), s_localScratchBuffer.getSize()); - } - s_pendingConnectionSends.insert(this); - } - - // clean up local accounting - s_localScratchBuffer.clear(); -} - -//--------------------------------------------------------------------- - -void TcpClient::flush() -{ - if (m_connected && m_pendingSend.getSize() > 0) - { - // flush pending buffer - commit(); - } -} - -//----------------------------------------------------------------------- - -void TcpClient::flushPendingWrites() -{ - std::set sends = s_pendingConnectionSends; - s_pendingConnectionSends.clear(); - - for (std::set::const_iterator i = sends.begin(); i != sends.end(); ++i) - { - TcpClient * const c = *i; - - if (c->m_connected) - { - c->flush(); - - if ( c->m_connection - && c->m_pendingSend.getSize() - && ConfigSharedNetwork::getLogSendingTooMuchData() - && !dynamic_cast(c->m_connection)) - { - WARNING(true, ("(%s) Failed to commit %d bytes this frame to %s:%d. This process is sending more data than the remote can receive!", c->m_connection->getConnectionDescription().c_str(), c->m_pendingSend.getSize(), c->getRemoteAddress().c_str(), c->getRemotePort())); - LOG("Network", ("(%s) Failed to commit %d bytes this frame to %s:%d. This process is sending more data than the remote can receive!", c->m_connection->getConnectionDescription().c_str(), c->m_pendingSend.getSize(), c->getRemoteAddress().c_str(), c->getRemotePort())); - } - } - } -} - -//--------------------------------------------------------------------- - -unsigned short TcpClient::getBindPort() const -{ - return m_bindPort; -} - -//--------------------------------------------------------------------- - -int TcpClient::getSocket() const -{ - return m_socket; -} - -//--------------------------------------------------------------------- - -void TcpClient::install() -{ - FATAL(s_installed, ("TcpClient is already installed!")); - s_installed = true; - signal(SIGPIPE, SIG_IGN); -} - -//--------------------------------------------------------------------- - -void TcpClient::onConnectionClosed() -{ - if (m_connection) - m_connection->setDisconnectReason("TcpClient::onConnectionClosed called"); - m_connected = false; - shutdown(m_socket, SHUT_RDWR); - if(m_tcpServer) - { - m_tcpServer->removeClient(this); - } - close(m_socket); - m_socket = -1; - if(m_connection) - { - NetworkHandler::onTerminate(m_connection); - } -} - -//--------------------------------------------------------------------- - -void TcpClient::onConnectionOpened() -{ - // Get the local port this socket was bound to. If - // a client socket repeatedly attempts to connect to a local - // service that should be listening on a port that the operating - // system may assign AND the service isn't actually running and - // using the port, the client socket may connect to itself. - // For example, A client connecting to 127.0.0.1:50005, the operating - // system may assign the client socket port 50005 and the connection - // succeeds, but it is in fact a connection to itself, meaning the - // client isn't actually talking to any valid service. - struct sockaddr_in bindAddr; - socklen_t addrLen = sizeof(struct sockaddr_in); - if(getsockname(m_socket, reinterpret_cast(&bindAddr), &addrLen) == 0) - { - m_bindPort = ntohs(bindAddr.sin_port); - } - - // this *might* be a valid connection to a remote address, but - // to easily catch all cases of loopback connections, attempt a - // reconnect if the remote port is identical to the local port - if(m_remoteAddress.getHostPort() == m_bindPort && ! m_tcpServer) - { - shutdown(m_socket, SHUT_RDWR); - DEBUG_FATAL(m_tcpServer, ("Detected a loopback client connection on a TCP SERVER!!!")); - close(m_socket); - m_socket = -1; - - // reconnect the socket - // address and port info is initialized in the constructor - setupSocket(); - LOG("Network", ("Detected a loopback, closing socket and reconnecting")); - } - else - { - m_connected = true; - if(m_connection) - { - m_connection->onConnectionOpened(); - } - flush(); - } -} - -//--------------------------------------------------------------------- - -void TcpClient::onReceive (const unsigned char * const recvBuf, const int bytes) -{ - if(m_connection) - { - m_connection->receive(recvBuf, bytes); - } -} - -//--------------------------------------------------------------------- - -void TcpClient::queryConnect () -{ - struct pollfd pfd; - pfd.fd = m_socket; - pfd.events = POLLOUT; - pfd.revents = 0; - int pollResult = poll(&pfd, 1, 0); - if(pollResult > 0) - { - if (pfd.revents & POLLERR) - { - if (m_connection) - m_connection->setDisconnectReason("TcpClient::queryConnect POLLERR"); - onConnectionClosed(); - } - else if (pfd.revents & POLLHUP) - { - if (m_connection) - m_connection->setDisconnectReason("TcpClient::queryConnect POLLHUP"); - onConnectionClosed(); - } - else - { - onConnectionOpened(); - } - } -} - -//----------------------------------------------------------------------- - -void TcpClient::release() -{ - m_refCount--; - if(m_refCount == 0) - { - if (m_connected) - { - if (m_connection) - m_connection->setDisconnectReason("TcpClient::release called"); - onConnectionClosed(); - } - delete this; - } -} - -//----------------------------------------------------------------------- - -void TcpClient::remove() -{ - FATAL(!s_installed, ("TcpClient already removed!")); - std::set::iterator i; - for(i = s_tcpClients.begin(); i != s_tcpClients.end(); ++i) - { - TcpClient * c = (*i); - c->release(); - } - s_installed = false; -} - -//--------------------------------------------------------------------- - -void TcpClient::send(const unsigned char * const buffer, const int bufferLen) -{ - if (bufferLen) - { - m_lastSendTime = Clock::getFrameStartTimeMs(); - s_pendingConnectionSends.insert(this); - if( !m_rawTCP ) - Archive::put(m_pendingSend, bufferLen); - m_pendingSend.put(buffer, bufferLen); - - static int const tcpMinimumFrame = ConfigSharedNetwork::getTcpMinimumFrame(); - if (static_cast(m_pendingSend.getSize()) >= tcpMinimumFrame) - flush(); - } -} - -//----------------------------------------------------------------------- - -void TcpClient::setConnection(Connection * c) -{ - m_connection = c; -} - -//--------------------------------------------------------------------- - -void TcpClient::checkKeepalive() -{ - if (m_connected) - { - unsigned long const timeNow = Clock::getFrameStartTimeMs(); - if (timeNow-m_lastSendTime > KEEPALIVE_MS) - { - m_lastSendTime = timeNow; - s_pendingConnectionSends.insert(this); - Archive::put(m_pendingSend, 0); - } - } -} - -//--------------------------------------------------------------------- - -void TcpClient::update() -{ - addRef(); - if(!m_connected) - { - queryConnect(); - } - - if(m_connected) - { - struct pollfd pfd; - pfd.fd = m_socket; - pfd.events = POLLIN|POLLHUP; - pfd.revents = 0; - int pollResult = poll (&pfd, 1, 0); - // POLLERR is mutually exclusive with POLLIN and POLLHUP. - // POLLIN and POLLHUP are not consistent cross-platform. Additionally, - // a POLLHUP doesn't mean that there's not data available. The best, - // cross-platform way to check for disconnection is to see if either - // POLLHUP or POLLIN are set, and then read from the socket. - // In cases where there's data, we'll just end up checking it next - // frame anyway. In cases where there's no data, it means we've - // disconnected so we can handle cleanup. - if (pollResult) - { - if (m_recvBuffer == NULL) - { - m_recvBufferLength = 1500; - m_recvBuffer = new unsigned char [m_recvBufferLength]; - } - int bytesReceived = recv(m_socket, m_recvBuffer, m_recvBufferLength, 0); - if (bytesReceived > 0) - { - onReceive(m_recvBuffer, bytesReceived); - } - else if (bytesReceived == -1) - { - switch (errno) - { - case EAGAIN: - case EINTR: - break; - default: - if (m_connection) - m_connection->setDisconnectReason("TcpClient::update recv returned -1, errno=%d", errno); - onConnectionClosed(); - break; - } - } - - else if (bytesReceived == 0) - { - // peer closed connection - - - - if (m_connection) - { - // Log this, as it's a pretty deep change. - LOG("Network", ("(%s) Read zero bytes on a successful poll (POLLIN|POLLHUP). Closing socket since we think it is closed.", m_connection->getConnectionDescription().c_str())); - m_connection->setDisconnectReason("TcpClient::update recv returned 0"); - } - else - { - LOG("Network", ("(null connection object) Read zero bytes on a successful poll (POLLIN|POLLHUP). Closing socket since we think it is closed.")); - } - onConnectionClosed(); - } - - if (bytesReceived == m_recvBufferLength) - { - // grow the buffer - delete [] m_recvBuffer; - m_recvBufferLength = m_recvBufferLength * 2; - m_recvBuffer = new unsigned char [m_recvBufferLength]; - } - } - } - release(); -} - -// ---------------------------------------------------------------------- - -void TcpClient::setupSocket() -{ - FATAL(! s_installed, ("TcpClient is not installed!")); - - protoent * p = getprotobyname ("tcp"); - const int entry = p->p_proto; - m_socket = socket (AF_INET, SOCK_STREAM, entry); - if (m_socket != -1) - { - setSockOptions(); - - int nameLen = sizeof (struct sockaddr_in); - int result; - result = connect (m_socket, reinterpret_cast (&m_remoteAddress.getSockAddr4 () ), nameLen); - if(result == -1) - { - switch(errno) - { - case EINPROGRESS: - case EALREADY: - break; - default: - perror("connect "); - if (m_connection) - m_connection->setDisconnectReason("TcpClient::TcpClient connect returned -1, errno=%d", errno); - onConnectionClosed(); - break; - } - } - else - { - struct sockaddr_in bindAddr; - socklen_t addrLen = sizeof(struct sockaddr_in); - if(getsockname(m_socket, reinterpret_cast(&bindAddr), &addrLen) == 0) - { - m_bindPort = ntohs(bindAddr.sin_port); - } - } - } -} - -// ---------------------------------------------------------------------- -void TcpClient::setRawTCP( bool bNewValue ) -{ - m_rawTCP = bNewValue; -} - -// ---------------------------------------------------------------------- - -void TcpClient::clearTcpServer() -{ - m_tcpServer = 0; -} - -// ====================================================================== - diff --git a/src/engine/shared/library/sharedNetwork/src/linux/TcpClient.h b/src/engine/shared/library/sharedNetwork/src/linux/TcpClient.h deleted file mode 100644 index dce06df5a..000000000 --- a/src/engine/shared/library/sharedNetwork/src/linux/TcpClient.h +++ /dev/null @@ -1,89 +0,0 @@ -// TcpClient.h -// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved. -// Author: Justin Randall - -#ifndef _INCLUDED_TcpClient_H -#define _INCLUDED_TcpClient_H - -//----------------------------------------------------------------------- - -#include "Archive/ByteStream.h" -#include "sharedNetwork/Address.h" -#include - -//----------------------------------------------------------------------- - -class Connection; -class TcpServer; - -//----------------------------------------------------------------------- - -class TcpClient -{ -public: - TcpClient(int sock, TcpServer *); - TcpClient(const std::string & address, const unsigned short port); - - void addRef(); - static void install(); - void release(); - static void remove(); - void send(const unsigned char * const buffer, const int length); - - unsigned short getBindPort() const; - std::string const &getRemoteAddress() const; - unsigned short getRemotePort() const; - void setPendingSendAllocatedSizeLimit(unsigned int limit); - - // only used by clients - void update(); - static void flushPendingWrites(); - -protected: - friend class TcpServer; - friend class Connection; - - void setSockOptions(); - void commit(); - int getSocket() const; - void onConnectionClosed(); - void onConnectionOpened(); - void onReceive(const unsigned char * const recvBuf, const int bytes); - void queryConnect(); - void queueReceive(); - void setConnection(Connection *); - void checkKeepalive(); - void clearTcpServer(); - void setRawTCP( bool bNewValue ); - -private: - TcpClient & operator = (const TcpClient & rhs); - TcpClient(const TcpClient & source); - ~TcpClient(); - void flush (); - void setupSocket(); - int m_socket; - TcpServer * m_tcpServer; - Archive::ByteStream m_pendingSend; - Connection * m_connection; - unsigned char * m_recvBuffer; - int m_recvBufferLength; - Address m_remoteAddress; - int m_refCount; - bool m_connected; - unsigned long m_lastSendTime; - unsigned short m_bindPort; - bool m_rawTCP; -}; - -//----------------------------------------------------------------------- - -inline void TcpClient::setPendingSendAllocatedSizeLimit(const unsigned int limit) -{ - m_pendingSend.setAllocatedSizeLimit(limit); -} - -//----------------------------------------------------------------------- - -#endif // _INCLUDED_TcpClient_H - diff --git a/src/engine/shared/library/sharedNetwork/src/linux/TcpServer.cpp b/src/engine/shared/library/sharedNetwork/src/linux/TcpServer.cpp deleted file mode 100644 index 2ca1b53bc..000000000 --- a/src/engine/shared/library/sharedNetwork/src/linux/TcpServer.cpp +++ /dev/null @@ -1,238 +0,0 @@ -// TcpServer.cpp -// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved. -// Author: Justin Randall - -//--------------------------------------------------------------------- - -#include "sharedNetwork/FirstSharedNetwork.h" -#include "TcpServer.h" - -#include "sharedNetwork/Connection.h" -#include "sharedNetwork/Service.h" -#include "TcpClient.h" -#include -#include -#include -#include -#include -#include -#include - -//--------------------------------------------------------------------- - -TcpServer::TcpServer(Service * service, const std::string & a, const unsigned short port) : -m_bindAddress(a, port), -m_handle(-1), -m_service(service), -m_connections(), -m_connectionSockets(), -m_inputBuffer(0), -m_inputBufferSize(0) -{ - protoent * p = getprotobyname("tcp"); - if(p) - { - int entry = p->p_proto; - m_handle = socket(AF_INET, SOCK_STREAM, entry); - FATAL(m_handle == -1, ("Failed to create a server socket %s:%d", a.c_str(), port)); - int optval = 1; - if(m_handle != -1) - { - int optResult = setsockopt(m_handle, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)); - FATAL(optResult == -1, ("Failed to set socket option SO_REUSEADDR")); - unsigned long nb = 1; - int ctlResult = ioctl(m_handle, FIONBIO, &nb); - FATAL(ctlResult == -1, ("Failed to set socket non-blocking")); - socklen_t addrlen = sizeof(struct sockaddr_in); - int bindResult = bind(m_handle, (struct sockaddr *)(&m_bindAddress.getSockAddr4()), addrlen); - FATAL(bindResult != 0, ("Failed to bind to port %d", port)); - if(bindResult == 0) - { - int result = listen(m_handle, 256); - if(result == -1) - perror("listen "); - FATAL(result == -1, ("Failed to start listening on port %d", port)); - struct sockaddr_in b; - getsockname(m_handle, (struct sockaddr *)(&b), &addrlen); - m_bindAddress = b; - } - } - } -} - -//--------------------------------------------------------------------- - -TcpServer::~TcpServer() -{ - close(m_handle); - for (std::map::const_iterator i = m_connections.begin(); i != m_connections.end(); ++i) - (*i).second->clearTcpServer(); -} - -//--------------------------------------------------------------------- - -const std::string & TcpServer::getBindAddress() const -{ - return m_bindAddress.getHostAddress(); -} - -//--------------------------------------------------------------------- - -const unsigned short TcpServer::getBindPort() const -{ - return m_bindAddress.getHostPort(); -} - -//--------------------------------------------------------------------- - -void TcpServer::onConnectionClosed(TcpClient * c) -{ - if(c) - { - std::set::iterator f = m_pendingDestroys.find(c); - if(f == m_pendingDestroys.end()) - { - m_pendingDestroys.insert(c); - } - } -} - -//--------------------------------------------------------------------- -void TcpServer::removeClient(TcpClient * c) -{ - std::map::iterator f = m_connections.find(c->getSocket()); - if(f != m_connections.end()) - { -// c->release(); - m_connections.erase(f); - } - - std::vector::iterator s; - for(s = m_connectionSockets.begin(); s != m_connectionSockets.end(); ++s) - { - if((*s).fd == c->getSocket()) - { - m_connectionSockets.erase(s); - break; - } - } -} - -//--------------------------------------------------------------------- - -void TcpServer::update() -{ - struct pollfd pfd; - pfd.fd = m_handle; - pfd.events = POLLIN; - pfd.revents = 0; - - int result = poll(&pfd, 1, 0); - if(result > 0) - { - // connection established - struct sockaddr_in addr; - socklen_t len = sizeof(struct sockaddr_in); - int newSock = accept(m_handle, (struct sockaddr *)(&addr), &len); - if(newSock != -1) - { - TcpClient * ptc = new TcpClient(newSock, this); - ptc->addRef(); - m_connections.insert(std::make_pair(newSock, ptc)); - struct pollfd readFd; - readFd.fd = ptc->getSocket(); - readFd.events = POLLIN|POLLERR|POLLHUP; - readFd.revents = 0; - m_connectionSockets.push_back(readFd); - ptc->onConnectionOpened(); - if(m_service) - m_service->onConnectionOpened(ptc); - ptc->release(); - } - } - - struct pollfd * clients = &m_connectionSockets[0]; - - int readResult = poll (clients, m_connectionSockets.size (), 0); - if (readResult > 0) - { - std::vector::iterator i; - std::vector cs = m_connectionSockets; - for (i = cs.begin (); i != cs.end (); ++i) - { - if ((*i).revents & POLLERR) - { - std::map::iterator f = m_connections.find ( (*i).fd ); - if (f != m_connections.end ()) - { - TcpClient * c = (*f).second; - if (c->m_connection) - c->m_connection->setDisconnectReason("TcpServer::update POLLERR"); - c->onConnectionClosed(); - } - } - // POLLERR is mutually exclusive with POLLIN and POLLHUP. - // POLLIN and POLLHUP are not consistent cross-platform. Additionally, - // a POLLHUP doesn't mean that there's not data available. The best, - // cross-platform way to check for disconnection is to see if either - // POLLHUP or POLLIN are set, and then read from the socket. - // In cases where there's data, we'll just end up checking it next - // frame anyway. In cases where there's no data, it means we've - // disconnected so we can handle cleanup. - else if( (*i).revents & (POLLIN|POLLHUP) ) - { - - if (m_inputBuffer == 0) - { - m_inputBuffer = new unsigned char[1500]; - m_inputBufferSize = 1500; - } - int bytesReceived = recv ( (*i).fd, m_inputBuffer, m_inputBufferSize, 0); - std::map::iterator f = m_connections.find ( (*i).fd ); - if (f != m_connections.end ()) - { - TcpClient * c = (*f).second; - std::set::iterator pd = m_pendingDestroys.find(c); - if(pd == m_pendingDestroys.end()) - { - c->addRef(); - if(bytesReceived > 0) - { - c->onReceive(m_inputBuffer, bytesReceived); - } - else if (bytesReceived == -1) - { - if (c->m_connection) - c->m_connection->setDisconnectReason("TcpServer::update recv returned %d, errno=%d", bytesReceived, errno); - c->onConnectionClosed(); - } - else if (bytesReceived == 0) - { - // 0 bytes received on a read is the guaranteed signal for a - // closed connection. - if (c->m_connection) - c->m_connection->setDisconnectReason("TcpServer::update recv returned no bytes, singaling a closed socket (bytes=%d, errno=%d", bytesReceived, errno); - c->onConnectionClosed(); - } - c->release(); - } - } - if (bytesReceived == m_inputBufferSize) - { - delete [] m_inputBuffer; - m_inputBufferSize = m_inputBufferSize * 2; - m_inputBuffer = new unsigned char [m_inputBufferSize]; - } - } - } - std::set::iterator pdIter; - for(pdIter = m_pendingDestroys.begin(); pdIter != m_pendingDestroys.end(); ++pdIter) - { - removeClient((*pdIter)); - } - m_pendingDestroys.clear(); - } -} - -//--------------------------------------------------------------------- - diff --git a/src/engine/shared/library/sharedNetwork/src/linux/TcpServer.h b/src/engine/shared/library/sharedNetwork/src/linux/TcpServer.h deleted file mode 100644 index 50bccb007..000000000 --- a/src/engine/shared/library/sharedNetwork/src/linux/TcpServer.h +++ /dev/null @@ -1,52 +0,0 @@ -// TcpServer.h -// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved. -// Author: Justin Randall - -#ifndef _INCLUDED_TcpServer_H -#define _INCLUDED_TcpServer_H - -//----------------------------------------------------------------------- - -#include "Address.h" -#include -#include -#include -#include - -//----------------------------------------------------------------------- - -class Service; -class TcpClient; - -//----------------------------------------------------------------------- - -class TcpServer -{ -public: - TcpServer(Service * service, const std::string & bindAddress, const unsigned short bindPort); - ~TcpServer(); - - const std::string & getBindAddress () const; - const unsigned short getBindPort () const; - void onConnectionClosed (TcpClient *); - void removeClient (TcpClient *); - void update (); - -private: - TcpServer & operator = (const TcpServer & rhs); - TcpServer(const TcpServer & source); - -private: - Address m_bindAddress; - int m_handle; - Service * m_service; - std::map m_connections; - std::vector m_connectionSockets; - unsigned char * m_inputBuffer; - int m_inputBufferSize; - std::set m_pendingDestroys; -}; - -//----------------------------------------------------------------------- - -#endif // _INCLUDED_TcpServer_H diff --git a/src/engine/shared/library/sharedNetwork/src/linux/UdpSock.cpp b/src/engine/shared/library/sharedNetwork/src/linux/UdpSock.cpp deleted file mode 100644 index 673b6f9a8..000000000 --- a/src/engine/shared/library/sharedNetwork/src/linux/UdpSock.cpp +++ /dev/null @@ -1,63 +0,0 @@ - -//--------------------------------------------------------------------- - -#include "FirstSharedNetwork.h" -#include -#include -#include -#include -#include "sharedNetwork/UdpSock.h" - -const int INVALID_SOCKET = 0xFFFFFFFF; - -//--------------------------------------------------------------------- - -UdpSock::UdpSock() : -Sock() -{ - handle = socket(AF_INET, SOCK_DGRAM, 17); - assert(handle != INVALID_SOCKET); - setNonBlocking(); -} - -//--------------------------------------------------------------------- - -UdpSock::~UdpSock() -{ -} - -//--------------------------------------------------------------------- - -const unsigned int UdpSock::recvFrom(Address & outAddr, void * targetBuffer, const unsigned int bufferSize) const -{ - socklen_t fromLen = sizeof(struct sockaddr_in); - struct sockaddr_in addr; - unsigned int result = ::recvfrom(handle, static_cast(targetBuffer), static_cast(bufferSize), 0, reinterpret_cast(&addr), &fromLen); //lint !e732 // MS wants an int, should be unsigned IMO - outAddr = addr; - return result; -} - -//--------------------------------------------------------------------- - -const unsigned int UdpSock::sendTo(const Address & targetAddress, const void * sourceBuffer, const unsigned int length) const -{ - unsigned int bytesSent = 0; - if(canSend()) - { - socklen_t toLen = sizeof(struct sockaddr_in); - bytesSent = ::sendto(handle, sourceBuffer, static_cast(length), 0, reinterpret_cast(&(targetAddress.getSockAddr4())), toLen); //lint !e732 // MS wants an int, should be unsigned IMO - } - return bytesSent; -} - -//----------------------------------------------------------------------- - -void UdpSock::enableBroadcast() -{ - int optval = 1; - socklen_t optlen = sizeof(int); - setsockopt(handle, SOL_SOCKET, SO_BROADCAST, &optval, optlen); -} - -//--------------------------------------------------------------------- - diff --git a/src/engine/shared/library/sharedRegex/src/linux/RegexServices.cpp b/src/engine/shared/library/sharedRegex/src/linux/RegexServices.cpp deleted file mode 100644 index ea5464e78..000000000 --- a/src/engine/shared/library/sharedRegex/src/linux/RegexServices.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// ====================================================================== -// -// RegexServices.cpp -// Copyright 2003 Sony Online Entertainment, Inc. -// All Rights Reserved. -// -// ====================================================================== - -#include "sharedRegex/FirstSharedRegex.h" -#include "sharedRegex/RegexServices.h" - -// ====================================================================== - -void *RegexServices::allocateMemory(size_t byteCount) -{ - return new char[byteCount]; -} - -// ---------------------------------------------------------------------- - -void RegexServices::freeMemory(void *pointer) -{ - delete [] reinterpret_cast(pointer); -} - -// ====================================================================== diff --git a/src/engine/shared/library/sharedRegex/src/linux/RegexServices.h b/src/engine/shared/library/sharedRegex/src/linux/RegexServices.h deleted file mode 100644 index 762c80de9..000000000 --- a/src/engine/shared/library/sharedRegex/src/linux/RegexServices.h +++ /dev/null @@ -1,25 +0,0 @@ -// ====================================================================== -// -// RegexServices.h -// Copyright 2003 Sony Online Entertainment, Inc. -// All Rights Reserved. -// -// ====================================================================== - -#ifndef INCLUDED_RegexServices_H -#define INCLUDED_RegexServices_H - -// ====================================================================== - -class RegexServices -{ -public: - - static void *allocateMemory(size_t byteCount); - static void freeMemory(void *pointer); - -}; - -// ====================================================================== - -#endif diff --git a/src/engine/shared/library/sharedSynchronization/src/linux/ConditionVariable.cpp b/src/engine/shared/library/sharedSynchronization/src/linux/ConditionVariable.cpp deleted file mode 100644 index 7a01259db..000000000 --- a/src/engine/shared/library/sharedSynchronization/src/linux/ConditionVariable.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// ====================================================================== -// -// ConditionVariable.cpp -// Acy Stapp -// -// Copyright 6/19/2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedFoundation/FirstSharedFoundation.h" -#include "sharedSynchronization/ConditionVariable.h" - -ConditionVariable::ConditionVariable(Mutex &m) - : _mutex(m) -{ - pthread_cond_init(&cond, 0); -} - -ConditionVariable::~ConditionVariable() -{ - pthread_cond_destroy(&cond); -} - -void ConditionVariable::wait() -{ - pthread_cond_wait(&cond, &_mutex.getInternalMutex()); -} - -void ConditionVariable::signal() -{ - pthread_cond_signal(&cond); -} - -void ConditionVariable::broadcast() -{ - pthread_cond_broadcast(&cond); -} - diff --git a/src/engine/shared/library/sharedSynchronization/src/linux/ConditionVariable.h b/src/engine/shared/library/sharedSynchronization/src/linux/ConditionVariable.h deleted file mode 100644 index 5ce3bf172..000000000 --- a/src/engine/shared/library/sharedSynchronization/src/linux/ConditionVariable.h +++ /dev/null @@ -1,34 +0,0 @@ -// ====================================================================== -// -// ConditionVariable.h -// Acy Stapp -// -// Copyright 6/19/2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_ConditionVariable_h -#define INCLUDED_ConditionVariable_h - -#include "sharedSynchronization/Mutex.h" - -class ConditionVariable -{ -public: - ConditionVariable(Mutex &m); - ~ConditionVariable(); - void wait(); - // You must own the mutex before calling signal. - void signal(); - void broadcast(); - Mutex &mutex() { return _mutex; } -private: - ConditionVariable(const ConditionVariable &o); - ConditionVariable &operator =(const ConditionVariable &o); - - Mutex &_mutex; - pthread_cond_t cond; -}; - - -#endif diff --git a/src/engine/shared/library/sharedSynchronization/src/linux/Gate.cpp b/src/engine/shared/library/sharedSynchronization/src/linux/Gate.cpp deleted file mode 100644 index 677df742c..000000000 --- a/src/engine/shared/library/sharedSynchronization/src/linux/Gate.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// ====================================================================== -// -// Gate.cpp -// Acy Stapp -// -// Copyright 6/19/2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedFoundation/FirstSharedFoundation.h" -#include "sharedSynchronization/Gate.h" - -Gate::Gate(bool open) -: cond(lock) -{ - opened = open; -} - -Gate::~Gate() -{ -} - -void Gate::wait() -{ - lock.enter(); - while (!opened) - cond.wait(); - lock.leave(); -} - -void Gate::close() -{ - lock.enter(); - opened = false; - lock.leave(); -} - -void Gate::open() -{ - lock.enter(); - opened = true; - cond.broadcast(); - lock.leave(); -} - diff --git a/src/engine/shared/library/sharedSynchronization/src/linux/Gate.h b/src/engine/shared/library/sharedSynchronization/src/linux/Gate.h deleted file mode 100644 index 9f1266e1f..000000000 --- a/src/engine/shared/library/sharedSynchronization/src/linux/Gate.h +++ /dev/null @@ -1,35 +0,0 @@ -// ====================================================================== -// -// Gate.h -// Acy Stapp -// -// Copyright 6/19/2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_Gate_h -#define INCLUDED_Gate_h - -#include "sharedSynchronization/ConditionVariable.h" - -class Gate -{ -public: - Gate(bool open); - ~Gate(); - - void wait(); - - void close(); - void open(); -private: - Gate(const Gate &o); - Gate &operator =(const Gate &o); - - Mutex lock; - bool opened; - ConditionVariable cond; -}; - - -#endif diff --git a/src/engine/shared/library/sharedSynchronization/src/linux/InterlockedInteger.h b/src/engine/shared/library/sharedSynchronization/src/linux/InterlockedInteger.h deleted file mode 100644 index 856333957..000000000 --- a/src/engine/shared/library/sharedSynchronization/src/linux/InterlockedInteger.h +++ /dev/null @@ -1,63 +0,0 @@ -// ====================================================================== -// -// InterlockedInteger.h -// Acy Stapp -// -// Copyright 6/19/2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_InterlockedInteger_h -#define INCLUDED_InterlockedInteger_h - -// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -class InterlockedInteger -{ -public: - explicit InterlockedInteger(int initialValue=0); - int operator =(int); // returns prior value (exchange) - int operator ++(); // returns new value - int operator --(); // returns new value - operator int() const { return value; } -private: - InterlockedInteger(const InterlockedInteger &o); - InterlockedInteger &operator =(const InterlockedInteger &o); - pthread_mutex_t lock; - volatile int value; -}; - -inline InterlockedInteger::InterlockedInteger(int i_value) -: value(i_value) -{ - pthread_mutex_init(&lock, 0); -} - -inline int InterlockedInteger::operator =(int i_value) -{ - pthread_mutex_lock(&lock); - int oldvalue = value; - value = i_value; - pthread_mutex_unlock(&lock); - return oldvalue; -} - -inline int InterlockedInteger::operator ++() -{ - pthread_mutex_lock(&lock); - int newvalue = value+1; - value = newvalue; - pthread_mutex_unlock(&lock); - return newvalue; -} - -inline int InterlockedInteger::operator --() -{ - pthread_mutex_lock(&lock); - int newvalue = value-1; - value = newvalue; - pthread_mutex_unlock(&lock); - return newvalue; -} - -#endif diff --git a/src/engine/shared/library/sharedSynchronization/src/linux/InterlockedVoidPointer.h b/src/engine/shared/library/sharedSynchronization/src/linux/InterlockedVoidPointer.h deleted file mode 100644 index 04da79aeb..000000000 --- a/src/engine/shared/library/sharedSynchronization/src/linux/InterlockedVoidPointer.h +++ /dev/null @@ -1,53 +0,0 @@ -// ====================================================================== -// -// InterlockedVoidPointer.h -// Acy Stapp -// -// Copyright 6/19/2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_InterlockedVoidPointer_h -#define INCLUDED_InterlockedVoidPointer_h - -#include "sharedSynchronization/Mutex.h" - -// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -class InterlockedVoidPointer -{ -public: - explicit InterlockedVoidPointer(void * initialValue=0); - void * compareExchange(void * compare, void * exchange); // compare and exchange if same - operator void * () const { return reinterpret_cast(value); } -private: - InterlockedVoidPointer(const InterlockedVoidPointer &o); - InterlockedVoidPointer &operator =(const InterlockedVoidPointer &o); - Mutex lock; - void * volatile value; -}; - -template -class InterlockedPointer: public InterlockedVoidPointer -{ -public: - explicit InterlockedPointer(T * initialValue): InterlockedVoidPointer(initialValue) {} - operator T * () const { return static_cast(value); } -}; - -inline InterlockedVoidPointer::InterlockedVoidPointer(void * initialValue) -: value(initialValue) -{ -} - -inline void * InterlockedVoidPointer::compareExchange(void * compare, void * exchange) -{ - lock.enter(); - void * temp = value; - if (temp == compare) - value = exchange; - lock.leave(); - return temp; -} - -#endif \ No newline at end of file diff --git a/src/engine/shared/library/sharedSynchronization/src/linux/Mutex.cpp b/src/engine/shared/library/sharedSynchronization/src/linux/Mutex.cpp deleted file mode 100644 index d51144330..000000000 --- a/src/engine/shared/library/sharedSynchronization/src/linux/Mutex.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// ====================================================================== -// -// Mutex.cpp -// Acy Stapp -// -// Copyright 6/19/2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedFoundation/FirstSharedFoundation.h" -#include "sharedSynchronization/Mutex.h" - -Mutex::Mutex() -{ - pthread_mutex_init(&mutex, 0); -} - -Mutex::~Mutex() -{ - pthread_mutex_destroy(&mutex); -} - -void Mutex::enter() -{ - pthread_mutex_lock(&mutex); -} - -void Mutex::leave() -{ - pthread_mutex_unlock(&mutex); -} - diff --git a/src/engine/shared/library/sharedSynchronization/src/linux/Mutex.h b/src/engine/shared/library/sharedSynchronization/src/linux/Mutex.h deleted file mode 100644 index be679dab0..000000000 --- a/src/engine/shared/library/sharedSynchronization/src/linux/Mutex.h +++ /dev/null @@ -1,31 +0,0 @@ -// ====================================================================== -// -// Mutex.h -// Acy Stapp -// -// Copyright 6/19/2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_Mutex_h -#define INCLUDED_Mutex_h - -class Mutex -{ -public: - Mutex(); - ~Mutex(); - - void enter(); - void leave(); - - pthread_mutex_t &getInternalMutex() { return mutex; } -private: - Mutex(const Mutex &o); - Mutex &operator =(const Mutex &o); - - pthread_mutex_t mutex; -}; - - -#endif diff --git a/src/engine/shared/library/sharedSynchronization/src/linux/RecursiveMutex.cpp b/src/engine/shared/library/sharedSynchronization/src/linux/RecursiveMutex.cpp deleted file mode 100644 index a902b404a..000000000 --- a/src/engine/shared/library/sharedSynchronization/src/linux/RecursiveMutex.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// ====================================================================== -// -// RecursiveMutex.cpp -// Acy Stapp -// -// Copyright 6/19/2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedFoundation/FirstSharedFoundation.h" -#include "sharedSynchronization/RecursiveMutex.h" - -RecursiveMutex::RecursiveMutex() -{ - pthread_mutexattr_t attributes; - - pthread_mutexattr_init(&attributes); - pthread_mutexattr_settype(&attributes,PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&mutex,&attributes); - pthread_mutexattr_destroy(&attributes); -} - -RecursiveMutex::~RecursiveMutex() -{ - pthread_mutex_destroy(&mutex); -} - -void RecursiveMutex::enter() -{ - pthread_mutex_lock(&mutex); -} - -void RecursiveMutex::leave() -{ - pthread_mutex_unlock(&mutex); -} - diff --git a/src/engine/shared/library/sharedSynchronization/src/linux/RecursiveMutex.h b/src/engine/shared/library/sharedSynchronization/src/linux/RecursiveMutex.h deleted file mode 100644 index 494160103..000000000 --- a/src/engine/shared/library/sharedSynchronization/src/linux/RecursiveMutex.h +++ /dev/null @@ -1,31 +0,0 @@ -// ====================================================================== -// -// RecursiveMutex.h -// Acy Stapp -// -// Copyright 6/19/2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_RecursiveMutex_h -#define INCLUDED_RecursiveMutex_h - -#include "sharedSynchronization/InterlockedInteger.h" - -class RecursiveMutex -{ -public: - RecursiveMutex(); - ~RecursiveMutex(); - - void enter(); - void leave(); -private: - RecursiveMutex(const RecursiveMutex &o); - RecursiveMutex &operator =(const RecursiveMutex &o); - - pthread_mutex_t mutex; -}; - -#endif - diff --git a/src/engine/shared/library/sharedSynchronization/src/linux/Semaphore.cpp b/src/engine/shared/library/sharedSynchronization/src/linux/Semaphore.cpp deleted file mode 100644 index 7950243dd..000000000 --- a/src/engine/shared/library/sharedSynchronization/src/linux/Semaphore.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// ====================================================================== -// -// Semaphore.cpp -// Acy Stapp -// -// Copyright 6/19/2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedFoundation/FirstSharedFoundation.h" -#include "sharedSynchronization/Semaphore.h" - -Semaphore::Semaphore(int count, int initial) -{ - sem_init(&sem, false, initial); -} - -Semaphore::~Semaphore() -{ - sem_destroy(&sem); -} - -void Semaphore::wait() -{ - sem_wait(&sem); -} - -void Semaphore::wait(unsigned int maxDurationMs) -{ - timespec ts; - ts.tv_sec = maxDurationMs/1000000; - ts.tv_nsec = maxDurationMs%1000000; - sem_timedwait(&sem, &ts); -} - -void Semaphore::signal(int count) -{ - sem_post(&sem); -} - diff --git a/src/engine/shared/library/sharedSynchronization/src/linux/Semaphore.h b/src/engine/shared/library/sharedSynchronization/src/linux/Semaphore.h deleted file mode 100644 index e108ae6fa..000000000 --- a/src/engine/shared/library/sharedSynchronization/src/linux/Semaphore.h +++ /dev/null @@ -1,30 +0,0 @@ -// ====================================================================== -// -// Semaphore.h -// Acy Stapp -// -// Copyright 6/19/2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_Semaphore_h -#define INCLUDED_Semaphore_h - -class Semaphore -{ -public: - Semaphore(int count=0x7FFFFFFF, int initial=0); - ~Semaphore(); - - void wait(); - void wait(unsigned int maxDurationMs); - void signal(int count=1); -private: - Semaphore(const Semaphore &o); - Semaphore &operator =(const Semaphore &o); - - sem_t sem; -}; - -#endif - diff --git a/src/engine/shared/library/sharedTemplateDefinition/src/linux/FirstSharedTemplateDefinition.cpp b/src/engine/shared/library/sharedTemplateDefinition/src/linux/FirstSharedTemplateDefinition.cpp deleted file mode 100644 index b156d0fd4..000000000 --- a/src/engine/shared/library/sharedTemplateDefinition/src/linux/FirstSharedTemplateDefinition.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "sharedTemplateDefinition/FirstSharedTemplateDefinition.h" diff --git a/src/engine/shared/library/sharedThread/src/linux/Thread.cpp b/src/engine/shared/library/sharedThread/src/linux/Thread.cpp deleted file mode 100644 index 90de4e552..000000000 --- a/src/engine/shared/library/sharedThread/src/linux/Thread.cpp +++ /dev/null @@ -1,159 +0,0 @@ -// ====================================================================== -// -// Thread.cpp -// Acy Stapp -// -// Copyright 6/19/2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedFoundation/FirstSharedFoundation.h" -#include "sharedThread/Thread.h" - -#include "sharedFoundation/ExitChain.h" -#include "sharedFoundation/Os.h" -#include "sharedFoundation/PerThreadData.h" -#include - -class MainThread: public Thread -{ -public: - MainThread(const std::string &name): Thread(name) {} -protected: - void run() {} -private: - MainThread(const MainThread &o); - MainThread &operator =(const MainThread &o); -}; - -pthread_key_t Thread::implindex; -Thread * Thread::mainThread; - -void Thread::install() -{ - DEBUG_FATAL(mainThread, ("Thread::install: already installed")); - ExitChain::add(remove, "Thread::remove"); - - pthread_key_create(&implindex, 0); - mainThread = new MainThread("Main"); - mainThread->attach(); -} - -void Thread::remove() -{ - DEBUG_FATAL(!mainThread, ("Thread::remove: not installed")); - DEBUG_FATAL(mainThread->refcount > 1, ("Someone still holds the main thread")); - delete mainThread; - pthread_key_delete(implindex); - - mainThread = 0; -} - -Thread::Thread(const std::string &i_name) -: refcount(1), name(i_name) -{ - doneFlag = false; -} - -void Thread::start() -{ - pthread_create(&thread, 0, threadFunc, this); - pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0); -} - -void Thread::attach() -{ - thread = pthread_self(); - pthread_setspecific(implindex, this); -} - -Thread::~Thread() -{ - pthread_detach(thread); -} - -void * Thread::threadFunc(void * i) -{ - Thread * impl = static_cast(i); - pthread_setspecific(implindex, impl); - pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0); - Os::setThreadName(impl->thread, impl->name.c_str()); - PerThreadData::threadInstall(true); - impl->run(); - PerThreadData::threadRemove(); - impl->kill(); - return 0; -} - -void Thread::kill() -{ - int t = getCurrentThread()->thread; - doneFlag = true; - deref(); - if (this == getCurrentThread()) - { - pthread_exit(0); - } - else - { - pthread_cancel(t); - } -} - -bool Thread::done() -{ - return doneFlag; -} - -void Thread::wait() -{ - if (!doneFlag) - { - void * junk; - pthread_join(thread, &junk); - } -} - -static inline int interpPriority(float t, int policy) -{ - return (int)(sched_get_priority_max(policy)*t + sched_get_priority_min(policy)*(1-t)); -} - -void Thread::setPriority(ePriority priority) -{ - static int policies[] = - { - SCHED_OTHER, - SCHED_OTHER, - SCHED_OTHER, - SCHED_OTHER, - SCHED_FIFO - }; - static int priorities[] = - { - interpPriority(0.0, SCHED_OTHER), - interpPriority(0.25, SCHED_OTHER), - interpPriority(0.5, SCHED_OTHER), - interpPriority(0.75, SCHED_OTHER), - interpPriority(0.75, SCHED_FIFO) - }; - sched_param p; - p.sched_priority = priorities[priority]; - pthread_setschedparam(thread, policies[priority], &p); -} - -// Make sure the header-only files compile :) - -#if 0 - -#include "sharedSynchronization/CountingSemaphore.h" -#include "sharedSynchronization/BlockingPointer.h" -#include "sharedSynchronization/BlockingQueue.h" -#include "sharedSynchronization/WriteOnce.h" - -Mutex t; -BlockingQueue bqint(t, 0, 0); -BlockingPointer bpint(t, 0, 0); -WriteOnce woint; - -#endif diff --git a/src/engine/shared/library/sharedThread/src/linux/Thread.h b/src/engine/shared/library/sharedThread/src/linux/Thread.h deleted file mode 100644 index 0c2faf80d..000000000 --- a/src/engine/shared/library/sharedThread/src/linux/Thread.h +++ /dev/null @@ -1,100 +0,0 @@ -// ====================================================================== -// -// Thread.h -// Acy Stapp -// -// Copyright 6/19/2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_Thread_h -#define INCLUDED_Thread_h - -#include "sharedSynchronization/InterlockedInteger.h" -#include - -class Thread -{ - template friend class TypedThreadHandle; -public: - static void install(); - static void remove(); - - Thread(const std::string &i_name=std::string()); - - void kill(); - bool done(); - void wait(); - - enum ePriority - { - kIdle = 0, - kLow = 1, - kNormal = 2, - kHigh = 3, - kCritical = 4 - }; - void setPriority(ePriority priority); - - const std::string &getName() const; - void setName(const std::string &i_name); - - static Thread * getCurrentThread(); - static Thread * getMainThread(); -protected: - virtual ~Thread(); - virtual void run()=0; - - pthread_t thread; - - InterlockedInteger refcount; -private: - Thread(const Thread &o); - Thread &operator =(const Thread &o); - - void start(); - void attach(); // pick up the currently running thread - - void ref(); - void deref(); - - bool doneFlag; - - std::string name; - - static pthread_key_t implindex; - static Thread * mainThread; - static void * threadFunc(void * data); -}; - -inline void Thread::ref() -{ - ++refcount; -} - -inline void Thread::deref() -{ - if (--refcount == 0) delete this; -} - -inline Thread * Thread::getCurrentThread() -{ - return static_cast(pthread_getspecific(implindex)); -} - -inline Thread * Thread::getMainThread() -{ - return mainThread; -} - -inline const std::string &Thread::getName() const -{ - return name; -} - -inline void Thread::setName(const std::string &i_name) -{ - name = i_name; -} - -#endif diff --git a/src/external/3rd/library/java/include/linux/jawt_md.h b/src/external/3rd/library/java/include/linux/jawt_md.h deleted file mode 100644 index 7f5498eab..000000000 --- a/src/external/3rd/library/java/include/linux/jawt_md.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * @(#)jawt_md.h 1.4 00/02/02 - * - * Copyright 1999, 2000 Sun Microsystems, Inc. All Rights Reserved. - * - * This software is the proprietary information of Sun Microsystems, Inc. - * Use is subject to license terms. - * - */ - -#ifndef _JAVASOFT_JAWT_MD_H_ -#define _JAVASOFT_JAWT_MD_H_ - -#include -#include -#include -#include "jawt.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * X11-specific declarations for AWT native interface. - * See notes in jawt.h for an example of use. - */ -typedef struct jawt_X11DrawingSurfaceInfo { - Drawable drawable; - Display* display; - VisualID visualID; - Colormap colormapID; - int depth; -} JAWT_X11DrawingSurfaceInfo; - -#ifdef __cplusplus -} -#endif - -#endif /* !_JAVASOFT_JAWT_MD_H_ */ diff --git a/src/external/3rd/library/java/include/linux/jni_md.h b/src/external/3rd/library/java/include/linux/jni_md.h deleted file mode 100644 index 9e953161e..000000000 --- a/src/external/3rd/library/java/include/linux/jni_md.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * @(#)jni_md.h 1.12 00/02/02 - * - * Copyright 1996-2000 Sun Microsystems, Inc. All Rights Reserved. - * - * This software is the proprietary information of Sun Microsystems, Inc. - * Use is subject to license terms. - * - */ - -#ifndef _JAVASOFT_JNI_MD_H_ -#define _JAVASOFT_JNI_MD_H_ - -#define JNIEXPORT -#define JNIIMPORT -#define JNICALL - -#ifdef _LP64 /* 64-bit Solaris */ -typedef int jint; -#else -typedef long jint; -#endif -typedef long long jlong; -typedef signed char jbyte; - -#endif /* !_JAVASOFT_JNI_MD_H_ */ diff --git a/src/external/3rd/library/pcre/4.1/linux/include/pcre/pcre.h b/src/external/3rd/library/pcre/4.1/linux/include/pcre/pcre.h deleted file mode 100644 index 82e3dedd5..000000000 --- a/src/external/3rd/library/pcre/4.1/linux/include/pcre/pcre.h +++ /dev/null @@ -1,184 +0,0 @@ -/************************************************* -* Perl-Compatible Regular Expressions * -*************************************************/ - -/* Copyright (c) 1997-2003 University of Cambridge */ - -#ifndef _PCRE_H -#define _PCRE_H - -/* The file pcre.h is build by "configure". Do not edit it; instead -make changes to pcre.in. */ - -#define PCRE_MAJOR 4 -#define PCRE_MINOR 1 -#define PCRE_DATE 12-Mar-2003 - -/* Win32 uses DLL by default */ - -#ifdef _WIN32 -# ifdef PCRE_DEFINITION -# ifdef DLL_EXPORT -# define PCRE_DATA_SCOPE __declspec(dllexport) -# endif -# else -# ifndef PCRE_STATIC -# define PCRE_DATA_SCOPE __declspec(dllimport) -# endif -# endif -#endif -#ifndef PCRE_DATA_SCOPE -# define PCRE_DATA_SCOPE extern -#endif - -/* Have to include stdlib.h in order to ensure that size_t is defined; -it is needed here for malloc. */ - -#include - -/* Allow for C++ users */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Options */ - -#define PCRE_CASELESS 0x0001 -#define PCRE_MULTILINE 0x0002 -#define PCRE_DOTALL 0x0004 -#define PCRE_EXTENDED 0x0008 -#define PCRE_ANCHORED 0x0010 -#define PCRE_DOLLAR_ENDONLY 0x0020 -#define PCRE_EXTRA 0x0040 -#define PCRE_NOTBOL 0x0080 -#define PCRE_NOTEOL 0x0100 -#define PCRE_UNGREEDY 0x0200 -#define PCRE_NOTEMPTY 0x0400 -#define PCRE_UTF8 0x0800 -#define PCRE_NO_AUTO_CAPTURE 0x1000 - -/* Exec-time and get/set-time error codes */ - -#define PCRE_ERROR_NOMATCH (-1) -#define PCRE_ERROR_NULL (-2) -#define PCRE_ERROR_BADOPTION (-3) -#define PCRE_ERROR_BADMAGIC (-4) -#define PCRE_ERROR_UNKNOWN_NODE (-5) -#define PCRE_ERROR_NOMEMORY (-6) -#define PCRE_ERROR_NOSUBSTRING (-7) -#define PCRE_ERROR_MATCHLIMIT (-8) -#define PCRE_ERROR_CALLOUT (-9) /* Never used by PCRE itself */ - -/* Request types for pcre_fullinfo() */ - -#define PCRE_INFO_OPTIONS 0 -#define PCRE_INFO_SIZE 1 -#define PCRE_INFO_CAPTURECOUNT 2 -#define PCRE_INFO_BACKREFMAX 3 -#define PCRE_INFO_FIRSTBYTE 4 -#define PCRE_INFO_FIRSTCHAR 4 /* For backwards compatibility */ -#define PCRE_INFO_FIRSTTABLE 5 -#define PCRE_INFO_LASTLITERAL 6 -#define PCRE_INFO_NAMEENTRYSIZE 7 -#define PCRE_INFO_NAMECOUNT 8 -#define PCRE_INFO_NAMETABLE 9 -#define PCRE_INFO_STUDYSIZE 10 - -/* Request types for pcre_config() */ - -#define PCRE_CONFIG_UTF8 0 -#define PCRE_CONFIG_NEWLINE 1 -#define PCRE_CONFIG_LINK_SIZE 2 -#define PCRE_CONFIG_POSIX_MALLOC_THRESHOLD 3 -#define PCRE_CONFIG_MATCH_LIMIT 4 - -/* Bit flags for the pcre_extra structure */ - -#define PCRE_EXTRA_STUDY_DATA 0x0001 -#define PCRE_EXTRA_MATCH_LIMIT 0x0002 -#define PCRE_EXTRA_CALLOUT_DATA 0x0004 - -/* Types */ - -struct real_pcre; /* declaration; the definition is private */ -typedef struct real_pcre pcre; - -/* The structure for passing additional data to pcre_exec(). This is defined in -such as way as to be extensible. */ - -typedef struct pcre_extra { - unsigned long int flags; /* Bits for which fields are set */ - void *study_data; /* Opaque data from pcre_study() */ - unsigned long int match_limit; /* Maximum number of calls to match() */ - void *callout_data; /* Data passed back in callouts */ -} pcre_extra; - -/* The structure for passing out data via the pcre_callout_function. We use a -structure so that new fields can be added on the end in future versions, -without changing the API of the function, thereby allowing old clients to work -without modification. */ - -typedef struct pcre_callout_block { - int version; /* Identifies version of block */ - /* ------------------------ Version 0 ------------------------------- */ - int callout_number; /* Number compiled into pattern */ - int *offset_vector; /* The offset vector */ - const char *subject; /* The subject being matched */ - int subject_length; /* The length of the subject */ - int start_match; /* Offset to start of this match attempt */ - int current_position; /* Where we currently are */ - int capture_top; /* Max current capture */ - int capture_last; /* Most recently closed capture */ - void *callout_data; /* Data passed in with the call */ - /* ------------------------------------------------------------------ */ -} pcre_callout_block; - -/* Indirection for store get and free functions. These can be set to -alternative malloc/free functions if required. There is also an optional -callout function that is triggered by the (?) regex item. Some magic is -required for Win32 DLL; it is null on other OS. For Virtual Pascal, these -have to be different again. */ - -#ifndef VPCOMPAT -PCRE_DATA_SCOPE void *(*pcre_malloc)(size_t); -PCRE_DATA_SCOPE void (*pcre_free)(void *); -PCRE_DATA_SCOPE int (*pcre_callout)(pcre_callout_block *); -#else /* VPCOMPAT */ -extern void *pcre_malloc(size_t); -extern void pcre_free(void *); -extern int pcre_callout(pcre_callout_block *); -#endif /* VPCOMPAT */ - -/* Exported PCRE functions */ - -extern pcre *pcre_compile(const char *, int, const char **, - int *, const unsigned char *); -extern int pcre_config(int, void *); -extern int pcre_copy_named_substring(const pcre *, const char *, - int *, int, const char *, char *, int); -extern int pcre_copy_substring(const char *, int *, int, int, - char *, int); -extern int pcre_exec(const pcre *, const pcre_extra *, - const char *, int, int, int, int *, int); -extern void pcre_free_substring(const char *); -extern void pcre_free_substring_list(const char **); -extern int pcre_fullinfo(const pcre *, const pcre_extra *, int, - void *); -extern int pcre_get_named_substring(const pcre *, const char *, - int *, int, const char *, const char **); -extern int pcre_get_stringnumber(const pcre *, const char *); -extern int pcre_get_substring(const char *, int *, int, int, - const char **); -extern int pcre_get_substring_list(const char *, int *, int, - const char ***); -extern int pcre_info(const pcre *, int *, int *); -extern const unsigned char *pcre_maketables(void); -extern pcre_extra *pcre_study(const pcre *, int, const char **); -extern const char *pcre_version(void); - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* End of pcre.h */ diff --git a/src/external/3rd/library/pcre/4.1/linux/include/pcre/pcreposix.h b/src/external/3rd/library/pcre/4.1/linux/include/pcre/pcreposix.h deleted file mode 100644 index 05a0d7d6f..000000000 --- a/src/external/3rd/library/pcre/4.1/linux/include/pcre/pcreposix.h +++ /dev/null @@ -1,88 +0,0 @@ -/************************************************* -* Perl-Compatible Regular Expressions * -*************************************************/ - -/* Copyright (c) 1997-2003 University of Cambridge */ - -#ifndef _PCREPOSIX_H -#define _PCREPOSIX_H - -/* This is the header for the POSIX wrapper interface to the PCRE Perl- -Compatible Regular Expression library. It defines the things POSIX says should -be there. I hope. */ - -/* Have to include stdlib.h in order to ensure that size_t is defined. */ - -#include - -/* Allow for C++ users */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Options defined by POSIX. */ - -#define REG_ICASE 0x01 -#define REG_NEWLINE 0x02 -#define REG_NOTBOL 0x04 -#define REG_NOTEOL 0x08 - -/* These are not used by PCRE, but by defining them we make it easier -to slot PCRE into existing programs that make POSIX calls. */ - -#define REG_EXTENDED 0 -#define REG_NOSUB 0 - -/* Error values. Not all these are relevant or used by the wrapper. */ - -enum { - REG_ASSERT = 1, /* internal error ? */ - REG_BADBR, /* invalid repeat counts in {} */ - REG_BADPAT, /* pattern error */ - REG_BADRPT, /* ? * + invalid */ - REG_EBRACE, /* unbalanced {} */ - REG_EBRACK, /* unbalanced [] */ - REG_ECOLLATE, /* collation error - not relevant */ - REG_ECTYPE, /* bad class */ - REG_EESCAPE, /* bad escape sequence */ - REG_EMPTY, /* empty expression */ - REG_EPAREN, /* unbalanced () */ - REG_ERANGE, /* bad range inside [] */ - REG_ESIZE, /* expression too big */ - REG_ESPACE, /* failed to get memory */ - REG_ESUBREG, /* bad back reference */ - REG_INVARG, /* bad argument */ - REG_NOMATCH /* match failed */ -}; - - -/* The structure representing a compiled regular expression. */ - -typedef struct { - void *re_pcre; - size_t re_nsub; - size_t re_erroffset; -} regex_t; - -/* The structure in which a captured offset is returned. */ - -typedef int regoff_t; - -typedef struct { - regoff_t rm_so; - regoff_t rm_eo; -} regmatch_t; - -/* The functions */ - -extern int regcomp(regex_t *, const char *, int); -extern int regexec(regex_t *, const char *, size_t, regmatch_t *, int); -extern size_t regerror(int, const regex_t *, char *, size_t); -extern void regfree(regex_t *); - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* End of pcreposix.h */ diff --git a/src/external/3rd/library/pcre/4.1/linux/lib/libpcre.a b/src/external/3rd/library/pcre/4.1/linux/lib/libpcre.a deleted file mode 100644 index 309cdb0c4..000000000 Binary files a/src/external/3rd/library/pcre/4.1/linux/lib/libpcre.a and /dev/null differ diff --git a/src/external/3rd/library/pcre/4.1/linux/lib/libpcre.la b/src/external/3rd/library/pcre/4.1/linux/lib/libpcre.la deleted file mode 100644 index 9eb4467db..000000000 --- a/src/external/3rd/library/pcre/4.1/linux/lib/libpcre.la +++ /dev/null @@ -1,32 +0,0 @@ -# libpcre.la - a libtool library file -# Generated by ltmain.sh - GNU libtool 1.4.3 (1.922.2.110 2002/10/23 01:39:54) -# -# Please DO NOT delete this file! -# It is necessary for linking the library. - -# The name that we can dlopen(3). -dlname='libpcre.so.0' - -# Names of this library. -library_names='libpcre.so.0.0.1 libpcre.so.0 libpcre.so' - -# The name of the static archive. -old_library='libpcre.a' - -# Libraries that this one depends upon. -dependency_libs='' - -# Version information for libpcre. -current=0 -age=0 -revision=1 - -# Is this an already installed library? -installed=yes - -# Files to dlopen/dlpreopen -dlopen='' -dlpreopen='' - -# Directory that this library needs to be installed in: -libdir='/home/tfiala/swg/current/src/external/3rd/library/pcre/4.1/linux/lib' diff --git a/src/external/3rd/library/pcre/4.1/linux/lib/libpcre.so.0.0.1 b/src/external/3rd/library/pcre/4.1/linux/lib/libpcre.so.0.0.1 deleted file mode 100644 index 3da39c822..000000000 Binary files a/src/external/3rd/library/pcre/4.1/linux/lib/libpcre.so.0.0.1 and /dev/null differ diff --git a/src/external/3rd/library/pcre/4.1/linux/lib/libpcreposix.a b/src/external/3rd/library/pcre/4.1/linux/lib/libpcreposix.a deleted file mode 100644 index d8adbf0b5..000000000 Binary files a/src/external/3rd/library/pcre/4.1/linux/lib/libpcreposix.a and /dev/null differ diff --git a/src/external/3rd/library/pcre/4.1/linux/lib/libpcreposix.la b/src/external/3rd/library/pcre/4.1/linux/lib/libpcreposix.la deleted file mode 100644 index ff969a30c..000000000 --- a/src/external/3rd/library/pcre/4.1/linux/lib/libpcreposix.la +++ /dev/null @@ -1,32 +0,0 @@ -# libpcreposix.la - a libtool library file -# Generated by ltmain.sh - GNU libtool 1.4.3 (1.922.2.110 2002/10/23 01:39:54) -# -# Please DO NOT delete this file! -# It is necessary for linking the library. - -# The name that we can dlopen(3). -dlname='libpcreposix.so.0' - -# Names of this library. -library_names='libpcreposix.so.0.0.0 libpcreposix.so.0 libpcreposix.so' - -# The name of the static archive. -old_library='libpcreposix.a' - -# Libraries that this one depends upon. -dependency_libs=' -L/home/tfiala/transfer/pcre-4.1 /home/tfiala/swg/current/src/external/3rd/library/pcre/4.1/linux/lib/libpcre.la' - -# Version information for libpcreposix. -current=0 -age=0 -revision=0 - -# Is this an already installed library? -installed=yes - -# Files to dlopen/dlpreopen -dlopen='' -dlpreopen='' - -# Directory that this library needs to be installed in: -libdir='/home/tfiala/swg/current/src/external/3rd/library/pcre/4.1/linux/lib' diff --git a/src/external/3rd/library/pcre/4.1/linux/lib/libpcreposix.so.0.0.0 b/src/external/3rd/library/pcre/4.1/linux/lib/libpcreposix.so.0.0.0 deleted file mode 100644 index 4b495b021..000000000 Binary files a/src/external/3rd/library/pcre/4.1/linux/lib/libpcreposix.so.0.0.0 and /dev/null differ diff --git a/src/external/3rd/library/perforce/lib/linux/libclient.a b/src/external/3rd/library/perforce/lib/linux/libclient.a deleted file mode 100644 index a8a39960c..000000000 Binary files a/src/external/3rd/library/perforce/lib/linux/libclient.a and /dev/null differ diff --git a/src/external/3rd/library/perforce/lib/linux/librpc.a b/src/external/3rd/library/perforce/lib/linux/librpc.a deleted file mode 100644 index 5ae498146..000000000 Binary files a/src/external/3rd/library/perforce/lib/linux/librpc.a and /dev/null differ diff --git a/src/external/3rd/library/perforce/lib/linux/libsupp.a b/src/external/3rd/library/perforce/lib/linux/libsupp.a deleted file mode 100644 index 32ecef4f2..000000000 Binary files a/src/external/3rd/library/perforce/lib/linux/libsupp.a and /dev/null differ diff --git a/src/external/3rd/library/platform/utils/Base/linux/Archive.h b/src/external/3rd/library/platform/utils/Base/linux/Archive.h deleted file mode 100644 index bb623b499..000000000 --- a/src/external/3rd/library/platform/utils/Base/linux/Archive.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef BASE_LINUX_ARCHIVE_H -#define BASE_LINUX_ARCHIVE_H - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif - -namespace Base -{ - - -#ifdef PACK_BIG_ENDIAN - - inline double byteSwap(double value) { byteReverse(&value); return value; } - inline float byteSwap(float value) { byteReverse(&value); return value; } - inline uint64 byteSwap(uint64 value) { byteReverse(&value); return value; } - inline int64 byteSwap(int64 value) { byteReverse(&value); return value; } - inline uint32 byteSwap(uint32 value) { byteReverse(&value); return value; } - inline int32 byteSwap(int32 value) { byteReverse(&value); return value; } - inline uint16 byteSwap(uint16 value) { byteReverse(&value); return value; } - inline int16 byteSwap(int16 value) { byteReverse(&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 diff --git a/src/external/3rd/library/platform/utils/Base/linux/BlockAllocator.cpp b/src/external/3rd/library/platform/utils/Base/linux/BlockAllocator.cpp deleted file mode 100644 index 00d01ec99..000000000 --- a/src/external/3rd/library/platform/utils/Base/linux/BlockAllocator.cpp +++ /dev/null @@ -1,110 +0,0 @@ -#include "../BlockAllocator.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - BlockAllocator::BlockAllocator() - { - for(unsigned i = 0; i < 31; i++) - { - m_blocks[i] = NULL; - } - } - - BlockAllocator::~BlockAllocator() - { - // free all allocated memory blocks - for(unsigned i = 0; i < 31; i++) - { - while(m_blocks[i] != NULL) - { - unsigned *tmp = m_blocks[i]; - m_blocks[i] = (unsigned *)*m_blocks[i]; - free(tmp); - } - } - } - -// Allocate a block that is the next power of two greater than the # of bytes passed. -// 33 bytes yields a 64 byte block of memory and so forth. - - void *BlockAllocator::getBlock(unsigned bytes) - { - unsigned accum = 16, bits = 16; - unsigned *handle = NULL; - - // Perform a binary search looking for the highest bit. - - while(bits != 0) - { - // If bytes is less than the bit we're testing for, subtract half - // from the bit value and repeat - if(bytes < (unsigned)(1 << accum)) - { - bits /= 2; - accum -= bits; - } - // If bytes is greater than the bit we're testing for, add half - // from the but value and repeat - else if(bytes > (unsigned)(1 << accum)) - { - bits /= 2; - accum += bits; - } - // Got lucky and hit the value dead on - else - { - break; - } - } - // At this point accum contains the most significant bit index, increment - accum++; - if(accum < 2) - { - accum = 2; - } - - // Note that when memory is actually allocated, 8 extra bytes will be allocated.at the front - // The first integer is the address of the next block of memory when the block is in the allocator - // The second integer is the bit length of the block - // Memory is allocated on 4 byte boundaries to sidestep byte alignment problems - - - // Check if the allocator already has a block of that size - if(m_blocks[accum] == 0) - { - // remove the pre allocated block from the linked list - handle = (unsigned *)calloc(((1 << accum) / 4) + 2, sizeof(unsigned)); - handle[1] = accum; - handle[0] = 0; - } - else - { - // Allocate a new block - handle = m_blocks[accum]; - m_blocks[accum] = (unsigned *)handle[0]; - handle[0] = 0; - } - // return a pointer that skips over the header used for the allocator's purposes - return(handle + 2); - } - - void BlockAllocator::returnBlock(unsigned *handle) - { - // C++ allows for safe deletion of a NULL pointer - if(handle) - { - // Update the allocator linked list, insert this entry at the head - *(handle - 2) = (unsigned)m_blocks[*(handle - 1)]; - // Add this entry to the proper linked list node - m_blocks[*(handle - 1)] = (handle - 2); - } - } -}; -#ifdef EXTERNAL_DISTRO -}; -#endif diff --git a/src/external/3rd/library/platform/utils/Base/linux/Event.cpp b/src/external/3rd/library/platform/utils/Base/linux/Event.cpp deleted file mode 100644 index a3cce3b15..000000000 --- a/src/external/3rd/library/platform/utils/Base/linux/Event.cpp +++ /dev/null @@ -1,103 +0,0 @@ -//////////////////////////////////////// -// Event.cpp -// -// Purpose: -// 1. Implementation of the CEvent class. -// -// Revisions: -// 07/10/2001 Created -// - -#if defined(_REENTRANT) - - -#include "Event.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - CEvent::CEvent() : - mMutex(), - mCond(), - mThreadCount(0) - { - pthread_mutex_init(&mMutex, NULL); - pthread_cond_init(&mCond, NULL); - } - - CEvent::~CEvent() - { - pthread_cond_destroy(&mCond); - pthread_mutex_destroy(&mMutex); - } - - bool CEvent::Signal() - { - pthread_mutex_lock(&mMutex); - if (mThreadCount == 0) - mThreadCount = SIGNALED; - pthread_cond_signal(&mCond); - - pthread_mutex_unlock(&mMutex); - - return true; - } - - int32 CEvent::Wait(uint32 timeout) - { - int result; - - pthread_mutex_lock(&mMutex); - if (mThreadCount == SIGNALED) - { - mThreadCount = 0; - pthread_mutex_unlock(&mMutex); - - return eWAIT_SIGNAL; - } - - if (!timeout) - { - mThreadCount++; - result = pthread_cond_wait(&mCond, &mMutex); - mThreadCount--; - - pthread_mutex_unlock(&mMutex); - } - else - { - struct timeval now; - struct timespec abs_timeout; - - gettimeofday(&now, NULL); - abs_timeout.tv_sec = now.tv_sec + timeout/1000; - abs_timeout.tv_nsec = now.tv_usec * 1000 + (timeout%1000)*1000000; - abs_timeout.tv_sec += abs_timeout.tv_nsec / 1000000000; - abs_timeout.tv_nsec %= 1000000000; - - mThreadCount++; - result = pthread_cond_timedwait(&mCond, &mMutex, &abs_timeout); - mThreadCount--; - - pthread_mutex_unlock(&mMutex); - } - - if (result == 0 || result == EINTR) - return eWAIT_SIGNAL; - else if (result == ETIMEDOUT) - return eWAIT_TIMEOUT; - else - return eWAIT_ERROR; - } - -} - -#ifdef EXTERNAL_DISTRO -}; -#endif -#endif // #if defined(_REENTRANT) diff --git a/src/external/3rd/library/platform/utils/Base/linux/Event.h b/src/external/3rd/library/platform/utils/Base/linux/Event.h deleted file mode 100644 index 4801a9b20..000000000 --- a/src/external/3rd/library/platform/utils/Base/linux/Event.h +++ /dev/null @@ -1,74 +0,0 @@ -//////////////////////////////////////// -// Event.h -// -// Purpose: -// 1. Declair the CEvent class that encapsulates the functionality of a -// single-locking semaphore. -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_LINUX_EVENT_H -#define BASE_LINUX_EVENT_H - -#if !defined(_REENTRANT) -# pragma message( "Excluding Base::CEvent - requires multi-threaded compile. (_REENTRANT)" ) -#else - - -#include -#include "Platform.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - //////////////////////////////////////// - // Class: - // CEvent - // - // Purpose: - // Encapsulates the functionality of a singal-locking semaphore. - // This class is valuable for thread syncronization when a thead's - // execution needs to be dependent upon another thread. - // - // Public Methods: - // Signal() : Signals a thread that has called Wait() so that it can - // continue execution. This function returns true if the waiting - // thread was signalled successfully, otherwise false is returned. - // Wait() : Halts the calling thread's execution indefinately until - // a Singal() call is made by an external thread. If the thread is - // successfully signalled, the function returns eWAIT_SIGNAL. If - // timeout period expires without a signal, eWAIT_TIMEOUT is returned. - // If the function fails, eWAIT_ERROR is returned. - // - class CEvent - { - public: - CEvent(); - virtual ~CEvent(); - - bool Signal(); - int32 Wait(uint32 timeout = 0); - - public: - enum { eWAIT_ERROR, eWAIT_SIGNAL, eWAIT_TIMEOUT }; - enum { SIGNALED = -1 }; - private: - pthread_mutex_t mMutex; - pthread_cond_t mCond; - int mThreadCount; - }; - -} -#ifdef EXTERNAL_DISTRO -}; -#endif -#endif // #if defined(_MT) - -#endif // BASE_LINUX_EVENT_H diff --git a/src/external/3rd/library/platform/utils/Base/linux/Logger.cpp b/src/external/3rd/library/platform/utils/Base/linux/Logger.cpp deleted file mode 100644 index f305703d5..000000000 --- a/src/external/3rd/library/platform/utils/Base/linux/Logger.cpp +++ /dev/null @@ -1,390 +0,0 @@ -#include "../Logger.h" -#include "Mutex.h" -#include - -using namespace std; - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - -const char file_sep = '/'; - -Logger::Logger(const char *prefix, int level, unsigned size, bool rollDate) -: m_defaultLevel(level), m_defaultSize(size), m_dirPrefix(prefix), m_rollDate(rollDate) -{ - char buf[1024]; - FILE *logDir = NULL; - - logDir = fopen(m_dirPrefix.c_str(), "r+"); - if(errno == ENOENT) - { - cmkdir(m_dirPrefix.c_str(), 0755); - } - else if(logDir != NULL) - { - fclose(logDir); - } - - tm now; - time_t t = time(NULL); - localtime_r(&t, &now); - - memcpy(&m_lastDateTime, &now, sizeof(tm)); - if(m_rollDate) - { - sprintf(buf, "%s%c%2.2d-%2.2d-%2.2d", m_dirPrefix.c_str(), file_sep, (now.tm_mon + 1), now.tm_mday, (now.tm_year % 100)); - } - else - { - sprintf(buf, "%s", m_dirPrefix.c_str()); - } - logDir = fopen(buf, "r+"); - if(errno == ENOENT) - { - cmkdir(buf, 0755); - } - else if(logDir != NULL) - { - fclose(logDir); - } - m_logPrefix = buf; -} - -Logger::~Logger() -{ - map::iterator iter; - for(iter = m_logTable.begin(); iter != m_logTable.end(); iter++) - { - log((*iter).first, LOG_FILEONLY, "---=== Log Stopped ===---"); - fflush((*iter).second->file); - fclose((*iter).second->file); - delete((*iter).second); - - } - m_logTable.clear(); -} - -void Logger::flush(unsigned logenum) -{ - map::iterator iter = m_logTable.find(logenum); - - if(iter != m_logTable.end()) - { - LogInfo *info = (*iter).second; - fflush(info->file); - info->used = 0; - } -} - -void Logger::flushAll() -{ - map::iterator iter; - - for(iter = m_logTable.begin(); iter != m_logTable.end(); iter++) - { - LogInfo *info = (*iter).second; - fflush(info->file); - info->used = 0; - } -} - -void Logger::addLog(const char *id, unsigned logenum, int level, unsigned size) -{ - LogInfo *newLog = new LogInfo; - newLog->filename = m_logPrefix + file_sep + id + ".log"; - newLog->name = id; - newLog->used = 0; - newLog->max = size; - newLog->last = 0; - newLog->level = level; - - m_logTable.insert(pair(logenum, newLog)); - - if(strcmp("stdout", id) == 0) - { - newLog->file = stdout; - } - else if(strcmp("stderr", id) == 0) - { - newLog->file = stderr; - } - else - { - newLog->file = fopen(newLog->filename.c_str(), "a+"); - } - log(logenum, LOG_FILEONLY, "---=== Log Started ===---"); -} - -void Logger::addLog(const char *id, unsigned logenum) -{ - LogInfo *newLog = new LogInfo; - newLog->filename = m_logPrefix + file_sep + id + ".log"; - newLog->name = id; - newLog->used = 0; - newLog->max = m_defaultSize; - newLog->last = 0; - newLog->level = m_defaultLevel; - - m_logTable.insert(pair(logenum, newLog)); - - if(strcmp("stdout", id) == 0) - { - newLog->file = stdout; - } - else if(strcmp("stderr", id) == 0) - { - newLog->file = stderr; - } - else - { - newLog->file = fopen(newLog->filename.c_str(), "a+"); - } - log(logenum, LOG_FILEONLY, "---===Log Started ===---"); -} - -void Logger::updateLog(unsigned logenum, int level, unsigned size) -{ - map::iterator iter = m_logTable.find(logenum); - - if(iter != m_logTable.end()) - { - (*iter).second->level = level; - (*iter).second->max = size; - } -} - -void Logger::removeLog(unsigned logenum) -{ - map::iterator iter = m_logTable.find(logenum); - - if(iter != m_logTable.end()) - { - log((*iter).first, LOG_ALWAYS, "---=== Log Stopped ===---"); - fflush((*iter).second->file); - fclose((*iter).second->file); - delete((*iter).second); - } -} - -void Logger::logSimple(unsigned logenum, int level, const char *message) -{ - map::iterator iter = m_logTable.find(logenum); - if(iter == m_logTable.end()) - { - return; - } - time_t t = time(NULL); - LogInfo *info = (*iter).second; - if(level >= info->level) - { - return; - } - if(level == LOG_FILEONLY && ((info->file == stderr) || (info->file == stdout))) - { - return; - } - if(info->last != t) - { - memcpy(&info->ts, localtime(&t), sizeof(tm)); - info->last = t; - } - - if(m_rollDate && info->ts.tm_mday != m_lastDateTime.tm_mday) - { -#if defined(_REENTRANT) - rLock.Lock(); -#endif - if(info->ts.tm_mday != m_lastDateTime.tm_mday) - { - memcpy(&m_lastDateTime, &info->ts, sizeof(tm)); - rollDate(t); - } -#if defined(_REENTRANT) - rLock.Unlock(); -#endif - } - if(iter != m_logTable.end()) - { - if(info->max > 0) - { - int tmp = fprintf(info->file, "[%2.2d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d] %s\n", (info->ts.tm_mon + 1), info->ts.tm_mday, (info->ts.tm_year % 100), info->ts.tm_hour, info->ts.tm_min, info->ts.tm_sec, message); - info->used += tmp; - if(info->used > info->max) - { - fflush(info->file); - info->used = 0; - } - } - else - { - fprintf(info->file, "[%2.2d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d] %s\n", (info->ts.tm_mon + 1), info->ts.tm_mday, (info->ts.tm_year % 100), info->ts.tm_hour, info->ts.tm_min, info->ts.tm_sec, message); - fflush(info->file); - } - } -} -void Logger::log(unsigned logenum, int level, const char *message, ...) -{ - char buf[2048]; - va_list varg; - va_start(varg, message); - vsnprintf(buf, 2047, message, varg); - buf[2047] = 0; - va_end(varg); - - map::iterator iter = m_logTable.find(logenum); - if(iter == m_logTable.end()) - { - return; - } - time_t t = time(NULL); - LogInfo *info = (*iter).second; - if(level >= info->level) - { - return; - } - if(level == LOG_FILEONLY && ((info->file == stderr) || (info->file == stdout))) - { - return; - } - if(info->last != t) - { - localtime_r(&t, &info->ts); - info->last = t; - } - if(m_rollDate && info->ts.tm_mday != m_lastDateTime.tm_mday) - { -#if defined(_REENTRANT) - rLock.Lock(); -#endif - if(info->ts.tm_mday != m_lastDateTime.tm_mday) - { - memcpy(&m_lastDateTime, &info->ts, sizeof(tm)); - rollDate(t); - } -#if defined(_REENTRANT) - rLock.Unlock(); -#endif - } - - if(iter != m_logTable.end()) - { - if(info->max > 0) - { - int tmp = fprintf(info->file, "[%2.2d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d] %s\n", (info->ts.tm_mon + 1), info->ts.tm_mday, (info->ts.tm_year % 100), info->ts.tm_hour, info->ts.tm_min, info->ts.tm_sec, buf); - info->used += tmp; - if(info->used > info->max) - { - fflush(info->file); - info->used = 0; - } - } - else - { - fprintf(info->file, "[%2.2d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d] %s\n", (info->ts.tm_mon + 1), info->ts.tm_mday, (info->ts.tm_year % 100), info->ts.tm_hour, info->ts.tm_min, info->ts.tm_sec, buf); - fflush(info->file); - } - } -} - -void Logger::rollDate(time_t t) -{ - char buf[80]; - FILE *logDir = NULL; - - logDir = fopen(m_dirPrefix.c_str(), "r+"); - if(errno == ENOENT) - { - cmkdir(m_dirPrefix.c_str(), 0755); - } - else if(logDir != NULL) - { - fclose(logDir); - } - - tm now; - localtime_r(&t, &now); - - sprintf(buf, "%s%c%2.2d-%2.2d-%2.2d", m_dirPrefix.c_str(), file_sep, (now.tm_mon + 1), now.tm_mday, (now.tm_year % 100)); - logDir = fopen(buf, "r+"); - - if(errno == ENOENT) - { - cmkdir(buf, 0755); - } - else if(logDir != NULL) - { - fclose(logDir); - } - m_logPrefix = buf; - - map::iterator iter; - for(iter = m_logTable.begin(); iter != m_logTable.end(); iter++) - { - (*iter).second->filename = m_logPrefix + file_sep + (*iter).second->name.c_str() + ".log"; - fflush((*iter).second->file); - fclose((*iter).second->file); - (*iter).second->file = fopen((*iter).second->filename.c_str(), "a+"); - memcpy(&((*iter).second->ts), &now, sizeof(tm)); - } -} - -// mkdir function that creates intermediate directories -void Logger::cmkdir(const char *dir, int mode) -{ - char dirbuf[128]; - strncpy(dirbuf, dir, 127); - dirbuf[127] = 0; - char *j = dirbuf, *i = dirbuf; - int handle; - - while(*i) - { - if(*i == file_sep) - { - (*i) = 0; -// handle = open(j, O_EXCL); // Ben's original code -// if((handle > 0) || (errno != EISDIR && errno != ENOENT)) -// { -// perror("Logger::cmkdir():"); -// abort(); -// } - -// This doesnt work under Linux, it returns a valid handle -// Instead: see if file exists. If it doesnt, create directory ok -// If it exists, do stat to see if it is a dir. -// If it is a dir, then ok, create the directory. -// If it is a file, error -// ging 9-16-2002 - - handle = open(j, O_RDONLY); - if (handle > 0) - { - struct stat stat_buffer; - int ret = fstat(handle,&stat_buffer); - if ((ret == -1) || ((stat_buffer.st_mode | S_IFDIR) == 0)) - { - perror("Logger::cmkdir():"); - abort(); - } - } - - mkdir(j, mode); - close(handle); - (*i) = file_sep; - } - else if(*(i + 1) == 0) - { - mkdir(j, mode); - } - i++; - } -} -#ifdef EXTERNAL_DISTRO -}; -#endif -}; diff --git a/src/external/3rd/library/platform/utils/Base/linux/Mutex.cpp b/src/external/3rd/library/platform/utils/Base/linux/Mutex.cpp deleted file mode 100644 index 36fe5b292..000000000 --- a/src/external/3rd/library/platform/utils/Base/linux/Mutex.cpp +++ /dev/null @@ -1,40 +0,0 @@ -//////////////////////////////////////// -// Mutex.cpp -// -// Purpose: -// 1. Implementation of the CMutex class. -// -// Revisions: -// 07/10/2001 Created -// - -#if defined(_REENTRANT) - - -#include "Mutex.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - -CMutex::CMutex() - { - mInitialized = (pthread_mutex_init(&mMutex, 0) == 0); - } - -CMutex::~CMutex() - { - if (mInitialized) - pthread_mutex_destroy(&mMutex); - } - -} -#ifdef EXTERNAL_DISTRO -}; -#endif - -#endif // #if defined(_REENTRANT) diff --git a/src/external/3rd/library/platform/utils/Base/linux/Mutex.h b/src/external/3rd/library/platform/utils/Base/linux/Mutex.h deleted file mode 100644 index dd56e3fcc..000000000 --- a/src/external/3rd/library/platform/utils/Base/linux/Mutex.h +++ /dev/null @@ -1,79 +0,0 @@ -//////////////////////////////////////// -// Mutex.h -// -// Purpose: -// 1. Declair the CMutex class that encapsulates the functionality of a -// mutually-exclusive device. -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_LINUX_MUTEX_H -#define BASE_LINUX_MUTEX_H - -#if !defined(_REENTRANT) -# pragma message( "Excluding Base::CMutex - requires multi-threaded compile. (_REENTRANT)" ) -#else - - -#include "Platform.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - //////////////////////////////////////// - // Class: - // CMutex - // - // Purpose: - // Encapsulates the functionality of a mutually-exclusive device. - // This class is valuable for protecting against race conditions - // within threaded applications. The CMutex class can be used to - // only allow a single thread to run within a specified code - // segment at a time. - // - // Public Methods: - // Lock() : Locks the mutex. If the mutex is already locked, the - // operating system will block the calling thread until another - // thread has unlocked the mutex. - // Unlock() : Unlocks the mutex. - // - class CMutex - { - public: - CMutex(); - ~CMutex(); - - void Lock(); - void Unlock(); - private: - pthread_mutex_t mMutex; - bool mInitialized; - }; - - inline void CMutex::Lock(void) - { - if (mInitialized) - pthread_mutex_lock(&mMutex); - } - - inline void CMutex::Unlock(void) - { - if (mInitialized) - pthread_mutex_unlock(&mMutex); - } - -} -#ifdef EXTERNAL_DISTRO -}; -#endif -#endif // #if defined(_MT) - -#endif // BASE_LINUX_MUTEX_H - diff --git a/src/external/3rd/library/platform/utils/Base/linux/Platform.cpp b/src/external/3rd/library/platform/utils/Base/linux/Platform.cpp deleted file mode 100644 index 4b24492c9..000000000 --- a/src/external/3rd/library/platform/utils/Base/linux/Platform.cpp +++ /dev/null @@ -1,55 +0,0 @@ -//////////////////////////////////////// -// Platform.cpp -// -// Purpose: -// 1. Implementation of the global functionality declaired in Platform.h. -// -// Revisions: -// 07/10/2001 Created -// - -#include -#include "Platform.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - // Implementation of microsoft strlwr extension - // This non-ANSI function is not supported under UNIX - void _strlwr(char * s) - { - while (*s) - { - *s = tolower(*s); - s++; - } - } - - // Implementation of microsoft strlwr extension - // This non-ANSI function is not supported under UNIX - void _strupr(char * s) - { - while (*s) - { - *s = toupper(*s); - s++; - } - } - - - CTimer::CTimer() : - mTimer(0) - { - } - - -} -#ifdef EXTERNAL_DISTRO -}; -#endif - diff --git a/src/external/3rd/library/platform/utils/Base/linux/Platform.h b/src/external/3rd/library/platform/utils/Base/linux/Platform.h deleted file mode 100644 index 41da39728..000000000 --- a/src/external/3rd/library/platform/utils/Base/linux/Platform.h +++ /dev/null @@ -1,112 +0,0 @@ -//////////////////////////////////////// -// 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. -// strlwr() : Alters the contents of a string, making it all lower-case. -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_LINUX_PLATFORM_H -#define BASE_LINUX_PLATFORM_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Types.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - uint64 getTimer(void); - uint64 getTimerFrequency(void); - void sleep(uint32 ms); - - inline uint64 getTimer(void) - { - uint64 t; - struct timeval tv; - - gettimeofday(&tv, 0); - t = tv.tv_sec; - t = t * 1000000; - t += tv.tv_usec; - return t; - } - - inline uint64 getTimerFrequency(void) - { - uint64 f = 1000000; - return f; - } - - inline void sleep(uint32 ms) - { - usleep(static_cast(ms * 1000)); - } - - void _strlwr(char * s); - void _strupr(char * s); - - - 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_LINUX_PLATFORM_H diff --git a/src/external/3rd/library/platform/utils/Base/linux/Thread.cpp b/src/external/3rd/library/platform/utils/Base/linux/Thread.cpp deleted file mode 100644 index 2bc4f26b2..000000000 --- a/src/external/3rd/library/platform/utils/Base/linux/Thread.cpp +++ /dev/null @@ -1,274 +0,0 @@ -//////////////////////////////////////// -// Thread.cpp -// -// Purpose: -// 1. Implementation of the CThread class. -// -// Revisions: -// 07/10/2001 Created -// - -#if defined(_REENTRANT) - - -#include -#include -#include "Thread.h" - -using namespace std; - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - void *threadProc(void *threadPtr) - { - CThread &thread = *((CThread*)threadPtr); - thread.mThreadActive = true; - thread.ThreadProc(); - thread.mThreadActive = false; - - return 0; - } - - CThread::CThread() - { - mThreadID = 0; - mThreadActive = false; - mThreadContinue = false; - } - - CThread::~CThread() - { - StopThread(); - } - - void CThread::StartThread() - { - mThreadContinue = true; - pthread_create(&mThreadID,0,threadProc,this); - while (!IsThreadActive()) - Base::sleep(1); - } - - int32 CThread::StopThread(int timeout) - { - timeout += time(0); - - mThreadContinue = false; - while (mThreadActive && time(0)OnStartup(this); - while (mThreadContinue) - { - mParent->OnIdle(this); - mSemaphore.Wait(mParent->GetTimeOut()*1000); - - if (mFunction) - { - mFunction(mArgument); - mArgument = NULL; - mFunction = NULL; - } - else if (mParent->OnDestory(this)) - mThreadContinue = false; - } - } - - -//////////////////////////////////////////////////////////////////////////////// - - - CThreadPool::CThreadPool(uint32 maxThreads, uint32 minThreads, uint32 timeout) : - mMutex(), - mIdleMember(), - mBusyMember(), - mNullMember(), - mThreadCount(0), - mMaxThreads(maxThreads), - mMinThreads(minThreads), - mTimeOut(timeout) - { - if (mMaxThreads == 0) mMaxThreads = 1; - if (mMinThreads == 0) mMinThreads = 1; - if (mMinThreads > mMaxThreads) mMinThreads = mMaxThreads; - - for (uint32 i=0; i::iterator setIterator; - - //////////////////////////////////////// - // (1) Destory all busy member threads - mMutex.Lock(); - setIterator = mBusyMember.begin(); - while (setIterator != mBusyMember.end()) - (*setIterator++)->Destroy(); - mMutex.Unlock(); - - //////////////////////////////////////// - // (2) Destory all idle member threads - while (mThreadCount) - { - mMutex.Lock(); - setIterator = mIdleMember.begin(); - while (setIterator != mIdleMember.end()) - (*setIterator++)->Destroy(); - mMutex.Unlock(); - - sleep(1); - } - - //////////////////////////////////////// - // (3) Delete the null member threads - mMutex.Lock(); - while (!mNullMember.empty()) - { - delete mNullMember.front(); - mNullMember.pop_front(); - } - mMutex.Unlock(); - } - - bool CThreadPool::Execute(void( *function )( void * ), void * arg) - { - mMutex.Lock(); - - //////////////////////////////////////// - // (1) If no idle members, return false to indicate that no threads - // were available. If the thread count is below the max, create - // a new thread. - if (mIdleMember.empty()) - { - if (mThreadCount < mMaxThreads) - new CMember(this); - mMutex.Unlock(); - return false; - } - - //////////////////////////////////////// - // (2) Delete any null member threads. - while (!mNullMember.empty()) - { - delete mNullMember.front(); - mNullMember.pop_front(); - } - - //////////////////////////////////////// - // (3) Move the first idle thread to the busy set and signal the - // thread to execute the specified function. - CMember * member = *(mIdleMember.begin()); - mIdleMember.erase(member); - mBusyMember.insert(member); - member->Execute(function,arg); - - mMutex.Unlock(); - return true; - } - - uint32 CThreadPool::GetTimeOut() - { - return mTimeOut; - } - - void CThreadPool::OnStartup(CMember * member) - { - mMutex.Lock(); - - mThreadCount++; - mIdleMember.insert(member); - - mMutex.Unlock(); - } - - void CThreadPool::OnIdle(CMember * member) - { - mMutex.Lock(); - - mBusyMember.erase(member); - mIdleMember.insert(member); - - mMutex.Unlock(); - } - - bool CThreadPool::OnDestory(CMember * member) - { - set::iterator setIterator; - - mMutex.Lock(); - - bool result = (setIterator = mIdleMember.find(member)) != mIdleMember.end(); - if (result) - { - mNullMember.push_back(member); - mIdleMember.erase(setIterator); - mThreadCount--; - } - - mMutex.Unlock(); - - return result; - } - - -//////////////////////////////////////////////////////////////////////////////// - - -} - -#ifdef EXTERNAL_DISTRO -}; -#endif -#endif // #if defined(_REENTRANT) diff --git a/src/external/3rd/library/platform/utils/Base/linux/Thread.h b/src/external/3rd/library/platform/utils/Base/linux/Thread.h deleted file mode 100644 index 4d42274b6..000000000 --- a/src/external/3rd/library/platform/utils/Base/linux/Thread.h +++ /dev/null @@ -1,146 +0,0 @@ -//////////////////////////////////////// -// Thread.h -// -// Purpose: -// 1. Declair the CThread class that encapsulates threading functionality. -// This abstract base class in intended to be used to encapsulate -// individual tasks that require threading in derived classes. -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_LINUX_THREAD_H -#define BASE_LINUX_THREAD_H - -#if !defined(_REENTRANT) -# pragma message( "Excluding Base::CThread - requires multi-threaded compile. (_REENTRANT)" ) -#else - - -#pragma warning( disable : 4786) - -#include -#include -#include "Platform.h" -#include "Mutex.h" -#include "Event.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - //////////////////////////////////////// - // Class: - // CThread - // - // Purpose: - // Encapsulates threading functionality. Creating classes derived - // from CThread provides an easy way to encapsulate tasks that require - // their own thread. - // - // Public Methods: - // StartThread() : Creates the low-level thread handle and begins executing - // the CThread::ThreadProc() function within the new thread. - // StopThread() : Signals the ThreadProc() function to stop executing using - // the mThreadContinue member variable, and waits for the ThreadProc() - // function to exit. By default, the function will block for a maximum - // of 5 seconds before exiting without the thread halting. - // IsThreadActive() : Returns true if the physical thread is still executing - // within the ThreadProc() function, otherwise it returns false. - // ThreadProc() : Pure-virtual function that will be executed when the StartThread() - // function is called. Derived classes must implement this function. The - // mThreadContinue member variable should be used internal the the ThreadProc() - // function to indicate whether it should continue executing or exit. - // Protected Attributes: - // mThreadContinue : Boolean value indicating to the ThreadProc() function - // whether to continue executing or to exit. If mThreadContinue is true, - // ThreadProc() should continue, otherwise ThreadProc() should exit. It - // left up to the derived class to implement a ThreadProc() function that - // uses the mThreadContinue member. - // - // - class CThread - { - friend void * threadProc(void *); - - public: - enum { eSTOP_SUCCESS, eSTOP_TIMEOUT }; - public: - CThread(); - virtual ~CThread(); - - void StartThread(); - int32 StopThread(int timeout=5); - bool IsThreadActive() { return mThreadActive; } - - protected: - virtual void ThreadProc() {} - - protected: - bool mThreadContinue; - private: - pthread_t mThreadID; - bool mThreadActive; - }; - - - class CThreadPool - { - private: - class CMember : public CThread - { - public: - CMember(CThreadPool * parent); - virtual ~CMember(); - - bool Execute(void( *function )( void * ), void * arg); - void Destroy(); - - protected: - virtual void ThreadProc(); - - private: - CThreadPool * mParent; - void( * mFunction )( void * ); - void * mArgument; - CEvent mSemaphore; - }; - friend class CMember; - - public: - CThreadPool(uint32 maxThreads, uint32 minThreads=1, uint32 timeout=15*60); - ~CThreadPool(); - - bool Execute(void( *function )( void * ), void * arg); - - private: - uint32 GetTimeOut(); - void OnStartup(CMember * member); - void OnIdle(CMember * member); - bool OnDestory(CMember * member); - - private: - CMutex mMutex; - std::set mIdleMember; - std::set mBusyMember; - std::list mNullMember; - uint32 mThreadCount; - - uint32 mMaxThreads; - uint32 mMinThreads; - uint32 mTimeOut; - }; - - -} -#ifdef EXTERNAL_DISTRO -}; -#endif -#endif // #if defined(_REENTRANT) - -#endif // BASE_LINUX_THREAD_H diff --git a/src/external/3rd/library/platform/utils/Base/linux/Types.h b/src/external/3rd/library/platform/utils/Base/linux/Types.h deleted file mode 100644 index bc869bac6..000000000 --- a/src/external/3rd/library/platform/utils/Base/linux/Types.h +++ /dev/null @@ -1,42 +0,0 @@ -//////////////////////////////////////// -// Types.h -// -// Purpose: -// 1. Define integer types that are unambiguous with respect to size -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_LINUX_TYPES_H -#define BASE_LINUX_TYPES_H - -#include - -#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 signed short int16; -typedef unsigned short uint16; - -typedef int32_t int32; -typedef u_int32_t uint32; -typedef int64_t int64; -typedef u_int64_t uint64; -} -#ifdef EXTERNAL_DISTRO -}; -#endif -#endif // BASE_LINUX_TYPES_H - diff --git a/src/external/3rd/library/soePlatform/Base/linux/Event.cpp b/src/external/3rd/library/soePlatform/Base/linux/Event.cpp deleted file mode 100644 index 797bbcd7d..000000000 --- a/src/external/3rd/library/soePlatform/Base/linux/Event.cpp +++ /dev/null @@ -1,82 +0,0 @@ -//////////////////////////////////////// -// Event.cpp -// -// Purpose: -// 1. Implementation of the CEvent class. -// -// Revisions: -// 07/10/2001 Created -// - -#include "./Event.h" - -namespace Base -{ - - CEvent::CEvent() - { - mInitialized = false; - if (pthread_cond_init( &mCond, NULL ) != 0) - { - return; - } - - if (pthread_mutex_init( &mMutex, NULL ) != 0) - { - pthread_cond_destroy( &mCond ); - return; - } - mInitialized = true; - } - - CEvent::~CEvent() - { - if (mInitialized) - { - pthread_cond_destroy(&mCond); - pthread_mutex_destroy(&mMutex); - } - } - - int32 CEvent::Wait(uint32 timeout) - { - if (!mInitialized) - return CEvent::eWAIT_ERROR; - - int result; - if (!timeout) - result = pthread_cond_wait(&mCond, &mMutex); - else - { - struct timespec wake_time; - - // linux 2.0 is not fully POSIX compliant with high-resolution timers - // so we use the older gettimeofday() - struct timeval tv; - - // get high resolution time and convert to POSIX 4 struct - if (gettimeofday(&tv, NULL) != 0) - return CEvent::eWAIT_ERROR; - TIMEVAL_TO_TIMESPEC(&tv, &wake_time); - - // add time out - wake_time.tv_sec += timeout/1000; - wake_time.tv_nsec += (timeout%1000)*1000000; - - // normalize new time - wake_time.tv_sec += wake_time.tv_nsec / 1000000000; - wake_time.tv_nsec %= 1000000000; - - // wait on condition with time out - result = pthread_cond_timedwait(&mCond, &mMutex, &wake_time ); - } - - if (result == 0 || result == EINTR) - return CEvent::eWAIT_SIGNAL; - else if (result == ETIMEDOUT) - return CEvent::eWAIT_TIMEOUT; - else - return CEvent::eWAIT_ERROR; - } - -} diff --git a/src/external/3rd/library/soePlatform/Base/linux/Event.h b/src/external/3rd/library/soePlatform/Base/linux/Event.h deleted file mode 100644 index b92a76730..000000000 --- a/src/external/3rd/library/soePlatform/Base/linux/Event.h +++ /dev/null @@ -1,67 +0,0 @@ -//////////////////////////////////////// -// Event.h -// -// Purpose: -// 1. Declair the CEvent class that encapsulates the functionality of a -// single-locking semaphore. -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_LINUX_EVENT_H -#define BASE_LINUX_EVENT_H - -#include "Platform.h" - -namespace Base -{ - - //////////////////////////////////////// - // Class: - // CEvent - // - // Purpose: - // Encapsulates the functionality of a singal-locking semaphore. - // This class is valuable for thread syncronization when a thead's - // execution needs to be dependent upon another thread. - // - // Public Methods: - // Signal() : Signals a thread that has called Wait() so that it can - // continue execution. This function returns true if the waiting - // thread was signalled successfully, otherwise false is returned. - // Wait() : Halts the calling thread's execution indefinately until - // a Singal() call is made by an external thread. If the thread is - // successfully signalled, the function returns eWAIT_SIGNAL. If - // timeout period expires without a signal, eWAIT_TIMEOUT is returned. - // If the function fails, eWAIT_ERROR is returned. - // - class CEvent - { - public: - CEvent(); - virtual ~CEvent(); - - bool Signal(); - int32 Wait(uint32 timeout = 0); - - public: - enum { eWAIT_ERROR, eWAIT_SIGNAL, eWAIT_TIMEOUT }; - private: - pthread_mutex_t mMutex; - pthread_cond_t mCond; - bool mInitialized; - }; - - inline bool CEvent::Signal() - { - if (!mInitialized) - return false; - - pthread_cond_signal(&mCond); - return true; - } - -} - -#endif // BASE_LINUX_EVENT_H diff --git a/src/external/3rd/library/soePlatform/Base/linux/Mutex.cpp b/src/external/3rd/library/soePlatform/Base/linux/Mutex.cpp deleted file mode 100644 index 6018b3855..000000000 --- a/src/external/3rd/library/soePlatform/Base/linux/Mutex.cpp +++ /dev/null @@ -1,28 +0,0 @@ -//////////////////////////////////////// -// Mutex.cpp -// -// Purpose: -// 1. Implementation of the CMutex class. -// -// Revisions: -// 07/10/2001 Created -// - -#include "./Mutex.h" - -namespace Base -{ - -CMutex::CMutex() - { - mInitialized = (pthread_mutex_init(&mMutex, 0) == 0); - } - -CMutex::~CMutex() - { - if (mInitialized) - pthread_mutex_destroy(&mMutex); - } - -} - diff --git a/src/external/3rd/library/soePlatform/Base/linux/Mutex.h b/src/external/3rd/library/soePlatform/Base/linux/Mutex.h deleted file mode 100644 index 09b9426c8..000000000 --- a/src/external/3rd/library/soePlatform/Base/linux/Mutex.h +++ /dev/null @@ -1,65 +0,0 @@ -//////////////////////////////////////// -// Mutex.h -// -// Purpose: -// 1. Declair the CMutex class that encapsulates the functionality of a -// mutually-exclusive device. -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_LINUX_MUTEX_H -#define BASE_LINUX_MUTEX_H - -#include "Platform.h" - -namespace Base -{ - - //////////////////////////////////////// - // Class: - // CMutex - // - // Purpose: - // Encapsulates the functionality of a mutually-exclusive device. - // This class is valuable for protecting against race conditions - // within threaded applications. The CMutex class can be used to - // only allow a single thread to run within a specified code - // segment at a time. - // - // Public Methods: - // Lock() : Locks the mutex. If the mutex is already locked, the - // operating system will block the calling thread until another - // thread has unlocked the mutex. - // Unlock() : Unlocks the mutex. - // - class CMutex - { - public: - CMutex(); - ~CMutex(); - - void Lock(); - void Unlock(); - private: - pthread_mutex_t mMutex; - bool mInitialized; - }; - - inline void CMutex::Lock(void) - { - if (mInitialized) - pthread_mutex_lock(&mMutex); - } - - inline void CMutex::Unlock(void) - { - if (mInitialized) - pthread_mutex_unlock(&mMutex); - } - -} - -#endif // BASE_LINUX_MUTEX_H - diff --git a/src/external/3rd/library/soePlatform/Base/linux/Platform.cpp b/src/external/3rd/library/soePlatform/Base/linux/Platform.cpp deleted file mode 100644 index 3b8198dde..000000000 --- a/src/external/3rd/library/soePlatform/Base/linux/Platform.cpp +++ /dev/null @@ -1,39 +0,0 @@ -//////////////////////////////////////// -// Platform.cpp -// -// Purpose: -// 1. Implementation of the global functionality declaired in Platform.h. -// -// Revisions: -// 07/10/2001 Created -// - -#include -#include "Platform.h" - -namespace Base -{ - - // Implementation of microsoft strlwr extension - // This non-ANSI function is not supported under UNIX - void _strlwr(char * s) - { - while (*s) - { - *s = tolower(*s); - s++; - } - } - - // Implementation of microsoft strlwr extension - // This non-ANSI function is not supported under UNIX - void _strupr(char * s) - { - while (*s) - { - *s = toupper(*s); - s++; - } - } -} - diff --git a/src/external/3rd/library/soePlatform/Base/linux/Platform.h b/src/external/3rd/library/soePlatform/Base/linux/Platform.h deleted file mode 100644 index 22981d63f..000000000 --- a/src/external/3rd/library/soePlatform/Base/linux/Platform.h +++ /dev/null @@ -1,77 +0,0 @@ -//////////////////////////////////////// -// 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. -// strlwr() : Alters the contents of a string, making it all lower-case. -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_LINUX_PLATFORM_H -#define BASE_LINUX_PLATFORM_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Types.h" - -namespace Base -{ -int64 getTimer(void); -int64 getTimerFrequency(void); -void sleep(uint32 ms); - -inline int64 getTimer(void) - { - int64 t; - struct timeval tv; - - gettimeofday(&tv, 0); - t = tv.tv_sec; - t = t * 1000000; - t += tv.tv_usec; - return t; - } - -inline int64 getTimerFrequency(void) - { - int64 f = 1000000; - return f; - } - -inline void sleep(uint32 ms) - { - usleep(static_cast(ms * 1000)); - } - -void _strlwr(char * s); -void _strupr(char * s); - -} - -#endif // BASE_LINUX_PLATFORM_H - diff --git a/src/external/3rd/library/soePlatform/Base/linux/Thread.cpp b/src/external/3rd/library/soePlatform/Base/linux/Thread.cpp deleted file mode 100644 index 2c1c1e8d2..000000000 --- a/src/external/3rd/library/soePlatform/Base/linux/Thread.cpp +++ /dev/null @@ -1,63 +0,0 @@ -//////////////////////////////////////// -// Thread.cpp -// -// Purpose: -// 1. Implementation of the CThread class. -// -// Revisions: -// 07/10/2001 Created -// - -#include -#include "./Thread.h" - -namespace Base -{ - - void *threadProc(void *threadPtr) - { - CThread &thread = *((CThread*)threadPtr); - thread.mThreadActive = true; - thread.ThreadProc(); - thread.mThreadActive = false; - - return 0; - } - - CThread::CThread() - { - mThreadID = 0; - mThreadActive = false; - mThreadContinue = false; - } - - CThread::~CThread() - { - StopThread(); - } - - void CThread::StartThread() - { - mThreadContinue = true; - pthread_create(&mThreadID,0,threadProc,this); - while (!IsThreadActive()) - Base::sleep(1); - } - - int32 CThread::StopThread(int timeout) - { - timeout += time(0); - - mThreadContinue = false; - while (mThreadActive && time(0) - -namespace Base -{ -#define INT32_MAX 0x7FFFFFFF -#define INT32_MIN 0x80000000 -#define UINT32_MAX 0xFFFFFFFF - -typedef signed char int8; -typedef unsigned char uint8; -typedef signed short int16; -typedef unsigned short uint16; - -typedef int32_t int32; -typedef u_int32_t uint32; -typedef int64_t int64; -typedef u_int64_t uint64; -} - -#endif // BASE_LINUX_TYPES_H - diff --git a/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/Archive.h b/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/Archive.h deleted file mode 100644 index bb623b499..000000000 --- a/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/Archive.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef BASE_LINUX_ARCHIVE_H -#define BASE_LINUX_ARCHIVE_H - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif - -namespace Base -{ - - -#ifdef PACK_BIG_ENDIAN - - inline double byteSwap(double value) { byteReverse(&value); return value; } - inline float byteSwap(float value) { byteReverse(&value); return value; } - inline uint64 byteSwap(uint64 value) { byteReverse(&value); return value; } - inline int64 byteSwap(int64 value) { byteReverse(&value); return value; } - inline uint32 byteSwap(uint32 value) { byteReverse(&value); return value; } - inline int32 byteSwap(int32 value) { byteReverse(&value); return value; } - inline uint16 byteSwap(uint16 value) { byteReverse(&value); return value; } - inline int16 byteSwap(int16 value) { byteReverse(&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 diff --git a/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/BlockAllocator.cpp b/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/BlockAllocator.cpp deleted file mode 100644 index 00d01ec99..000000000 --- a/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/BlockAllocator.cpp +++ /dev/null @@ -1,110 +0,0 @@ -#include "../BlockAllocator.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - BlockAllocator::BlockAllocator() - { - for(unsigned i = 0; i < 31; i++) - { - m_blocks[i] = NULL; - } - } - - BlockAllocator::~BlockAllocator() - { - // free all allocated memory blocks - for(unsigned i = 0; i < 31; i++) - { - while(m_blocks[i] != NULL) - { - unsigned *tmp = m_blocks[i]; - m_blocks[i] = (unsigned *)*m_blocks[i]; - free(tmp); - } - } - } - -// Allocate a block that is the next power of two greater than the # of bytes passed. -// 33 bytes yields a 64 byte block of memory and so forth. - - void *BlockAllocator::getBlock(unsigned bytes) - { - unsigned accum = 16, bits = 16; - unsigned *handle = NULL; - - // Perform a binary search looking for the highest bit. - - while(bits != 0) - { - // If bytes is less than the bit we're testing for, subtract half - // from the bit value and repeat - if(bytes < (unsigned)(1 << accum)) - { - bits /= 2; - accum -= bits; - } - // If bytes is greater than the bit we're testing for, add half - // from the but value and repeat - else if(bytes > (unsigned)(1 << accum)) - { - bits /= 2; - accum += bits; - } - // Got lucky and hit the value dead on - else - { - break; - } - } - // At this point accum contains the most significant bit index, increment - accum++; - if(accum < 2) - { - accum = 2; - } - - // Note that when memory is actually allocated, 8 extra bytes will be allocated.at the front - // The first integer is the address of the next block of memory when the block is in the allocator - // The second integer is the bit length of the block - // Memory is allocated on 4 byte boundaries to sidestep byte alignment problems - - - // Check if the allocator already has a block of that size - if(m_blocks[accum] == 0) - { - // remove the pre allocated block from the linked list - handle = (unsigned *)calloc(((1 << accum) / 4) + 2, sizeof(unsigned)); - handle[1] = accum; - handle[0] = 0; - } - else - { - // Allocate a new block - handle = m_blocks[accum]; - m_blocks[accum] = (unsigned *)handle[0]; - handle[0] = 0; - } - // return a pointer that skips over the header used for the allocator's purposes - return(handle + 2); - } - - void BlockAllocator::returnBlock(unsigned *handle) - { - // C++ allows for safe deletion of a NULL pointer - if(handle) - { - // Update the allocator linked list, insert this entry at the head - *(handle - 2) = (unsigned)m_blocks[*(handle - 1)]; - // Add this entry to the proper linked list node - m_blocks[*(handle - 1)] = (handle - 2); - } - } -}; -#ifdef EXTERNAL_DISTRO -}; -#endif diff --git a/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/Event.cpp b/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/Event.cpp deleted file mode 100644 index a3cce3b15..000000000 --- a/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/Event.cpp +++ /dev/null @@ -1,103 +0,0 @@ -//////////////////////////////////////// -// Event.cpp -// -// Purpose: -// 1. Implementation of the CEvent class. -// -// Revisions: -// 07/10/2001 Created -// - -#if defined(_REENTRANT) - - -#include "Event.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - CEvent::CEvent() : - mMutex(), - mCond(), - mThreadCount(0) - { - pthread_mutex_init(&mMutex, NULL); - pthread_cond_init(&mCond, NULL); - } - - CEvent::~CEvent() - { - pthread_cond_destroy(&mCond); - pthread_mutex_destroy(&mMutex); - } - - bool CEvent::Signal() - { - pthread_mutex_lock(&mMutex); - if (mThreadCount == 0) - mThreadCount = SIGNALED; - pthread_cond_signal(&mCond); - - pthread_mutex_unlock(&mMutex); - - return true; - } - - int32 CEvent::Wait(uint32 timeout) - { - int result; - - pthread_mutex_lock(&mMutex); - if (mThreadCount == SIGNALED) - { - mThreadCount = 0; - pthread_mutex_unlock(&mMutex); - - return eWAIT_SIGNAL; - } - - if (!timeout) - { - mThreadCount++; - result = pthread_cond_wait(&mCond, &mMutex); - mThreadCount--; - - pthread_mutex_unlock(&mMutex); - } - else - { - struct timeval now; - struct timespec abs_timeout; - - gettimeofday(&now, NULL); - abs_timeout.tv_sec = now.tv_sec + timeout/1000; - abs_timeout.tv_nsec = now.tv_usec * 1000 + (timeout%1000)*1000000; - abs_timeout.tv_sec += abs_timeout.tv_nsec / 1000000000; - abs_timeout.tv_nsec %= 1000000000; - - mThreadCount++; - result = pthread_cond_timedwait(&mCond, &mMutex, &abs_timeout); - mThreadCount--; - - pthread_mutex_unlock(&mMutex); - } - - if (result == 0 || result == EINTR) - return eWAIT_SIGNAL; - else if (result == ETIMEDOUT) - return eWAIT_TIMEOUT; - else - return eWAIT_ERROR; - } - -} - -#ifdef EXTERNAL_DISTRO -}; -#endif -#endif // #if defined(_REENTRANT) diff --git a/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/Event.h b/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/Event.h deleted file mode 100644 index 4801a9b20..000000000 --- a/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/Event.h +++ /dev/null @@ -1,74 +0,0 @@ -//////////////////////////////////////// -// Event.h -// -// Purpose: -// 1. Declair the CEvent class that encapsulates the functionality of a -// single-locking semaphore. -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_LINUX_EVENT_H -#define BASE_LINUX_EVENT_H - -#if !defined(_REENTRANT) -# pragma message( "Excluding Base::CEvent - requires multi-threaded compile. (_REENTRANT)" ) -#else - - -#include -#include "Platform.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - //////////////////////////////////////// - // Class: - // CEvent - // - // Purpose: - // Encapsulates the functionality of a singal-locking semaphore. - // This class is valuable for thread syncronization when a thead's - // execution needs to be dependent upon another thread. - // - // Public Methods: - // Signal() : Signals a thread that has called Wait() so that it can - // continue execution. This function returns true if the waiting - // thread was signalled successfully, otherwise false is returned. - // Wait() : Halts the calling thread's execution indefinately until - // a Singal() call is made by an external thread. If the thread is - // successfully signalled, the function returns eWAIT_SIGNAL. If - // timeout period expires without a signal, eWAIT_TIMEOUT is returned. - // If the function fails, eWAIT_ERROR is returned. - // - class CEvent - { - public: - CEvent(); - virtual ~CEvent(); - - bool Signal(); - int32 Wait(uint32 timeout = 0); - - public: - enum { eWAIT_ERROR, eWAIT_SIGNAL, eWAIT_TIMEOUT }; - enum { SIGNALED = -1 }; - private: - pthread_mutex_t mMutex; - pthread_cond_t mCond; - int mThreadCount; - }; - -} -#ifdef EXTERNAL_DISTRO -}; -#endif -#endif // #if defined(_MT) - -#endif // BASE_LINUX_EVENT_H diff --git a/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/Mutex.cpp b/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/Mutex.cpp deleted file mode 100644 index 36fe5b292..000000000 --- a/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/Mutex.cpp +++ /dev/null @@ -1,40 +0,0 @@ -//////////////////////////////////////// -// Mutex.cpp -// -// Purpose: -// 1. Implementation of the CMutex class. -// -// Revisions: -// 07/10/2001 Created -// - -#if defined(_REENTRANT) - - -#include "Mutex.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - -CMutex::CMutex() - { - mInitialized = (pthread_mutex_init(&mMutex, 0) == 0); - } - -CMutex::~CMutex() - { - if (mInitialized) - pthread_mutex_destroy(&mMutex); - } - -} -#ifdef EXTERNAL_DISTRO -}; -#endif - -#endif // #if defined(_REENTRANT) diff --git a/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/Mutex.h b/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/Mutex.h deleted file mode 100644 index dd56e3fcc..000000000 --- a/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/Mutex.h +++ /dev/null @@ -1,79 +0,0 @@ -//////////////////////////////////////// -// Mutex.h -// -// Purpose: -// 1. Declair the CMutex class that encapsulates the functionality of a -// mutually-exclusive device. -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_LINUX_MUTEX_H -#define BASE_LINUX_MUTEX_H - -#if !defined(_REENTRANT) -# pragma message( "Excluding Base::CMutex - requires multi-threaded compile. (_REENTRANT)" ) -#else - - -#include "Platform.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - //////////////////////////////////////// - // Class: - // CMutex - // - // Purpose: - // Encapsulates the functionality of a mutually-exclusive device. - // This class is valuable for protecting against race conditions - // within threaded applications. The CMutex class can be used to - // only allow a single thread to run within a specified code - // segment at a time. - // - // Public Methods: - // Lock() : Locks the mutex. If the mutex is already locked, the - // operating system will block the calling thread until another - // thread has unlocked the mutex. - // Unlock() : Unlocks the mutex. - // - class CMutex - { - public: - CMutex(); - ~CMutex(); - - void Lock(); - void Unlock(); - private: - pthread_mutex_t mMutex; - bool mInitialized; - }; - - inline void CMutex::Lock(void) - { - if (mInitialized) - pthread_mutex_lock(&mMutex); - } - - inline void CMutex::Unlock(void) - { - if (mInitialized) - pthread_mutex_unlock(&mMutex); - } - -} -#ifdef EXTERNAL_DISTRO -}; -#endif -#endif // #if defined(_MT) - -#endif // BASE_LINUX_MUTEX_H - diff --git a/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/Platform.cpp b/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/Platform.cpp deleted file mode 100644 index 4b24492c9..000000000 --- a/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/Platform.cpp +++ /dev/null @@ -1,55 +0,0 @@ -//////////////////////////////////////// -// Platform.cpp -// -// Purpose: -// 1. Implementation of the global functionality declaired in Platform.h. -// -// Revisions: -// 07/10/2001 Created -// - -#include -#include "Platform.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - // Implementation of microsoft strlwr extension - // This non-ANSI function is not supported under UNIX - void _strlwr(char * s) - { - while (*s) - { - *s = tolower(*s); - s++; - } - } - - // Implementation of microsoft strlwr extension - // This non-ANSI function is not supported under UNIX - void _strupr(char * s) - { - while (*s) - { - *s = toupper(*s); - s++; - } - } - - - CTimer::CTimer() : - mTimer(0) - { - } - - -} -#ifdef EXTERNAL_DISTRO -}; -#endif - diff --git a/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/Platform.h b/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/Platform.h deleted file mode 100644 index 41da39728..000000000 --- a/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/Platform.h +++ /dev/null @@ -1,112 +0,0 @@ -//////////////////////////////////////// -// 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. -// strlwr() : Alters the contents of a string, making it all lower-case. -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_LINUX_PLATFORM_H -#define BASE_LINUX_PLATFORM_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Types.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - uint64 getTimer(void); - uint64 getTimerFrequency(void); - void sleep(uint32 ms); - - inline uint64 getTimer(void) - { - uint64 t; - struct timeval tv; - - gettimeofday(&tv, 0); - t = tv.tv_sec; - t = t * 1000000; - t += tv.tv_usec; - return t; - } - - inline uint64 getTimerFrequency(void) - { - uint64 f = 1000000; - return f; - } - - inline void sleep(uint32 ms) - { - usleep(static_cast(ms * 1000)); - } - - void _strlwr(char * s); - void _strupr(char * s); - - - 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_LINUX_PLATFORM_H diff --git a/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/Thread.cpp b/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/Thread.cpp deleted file mode 100644 index 2bc4f26b2..000000000 --- a/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/Thread.cpp +++ /dev/null @@ -1,274 +0,0 @@ -//////////////////////////////////////// -// Thread.cpp -// -// Purpose: -// 1. Implementation of the CThread class. -// -// Revisions: -// 07/10/2001 Created -// - -#if defined(_REENTRANT) - - -#include -#include -#include "Thread.h" - -using namespace std; - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - void *threadProc(void *threadPtr) - { - CThread &thread = *((CThread*)threadPtr); - thread.mThreadActive = true; - thread.ThreadProc(); - thread.mThreadActive = false; - - return 0; - } - - CThread::CThread() - { - mThreadID = 0; - mThreadActive = false; - mThreadContinue = false; - } - - CThread::~CThread() - { - StopThread(); - } - - void CThread::StartThread() - { - mThreadContinue = true; - pthread_create(&mThreadID,0,threadProc,this); - while (!IsThreadActive()) - Base::sleep(1); - } - - int32 CThread::StopThread(int timeout) - { - timeout += time(0); - - mThreadContinue = false; - while (mThreadActive && time(0)OnStartup(this); - while (mThreadContinue) - { - mParent->OnIdle(this); - mSemaphore.Wait(mParent->GetTimeOut()*1000); - - if (mFunction) - { - mFunction(mArgument); - mArgument = NULL; - mFunction = NULL; - } - else if (mParent->OnDestory(this)) - mThreadContinue = false; - } - } - - -//////////////////////////////////////////////////////////////////////////////// - - - CThreadPool::CThreadPool(uint32 maxThreads, uint32 minThreads, uint32 timeout) : - mMutex(), - mIdleMember(), - mBusyMember(), - mNullMember(), - mThreadCount(0), - mMaxThreads(maxThreads), - mMinThreads(minThreads), - mTimeOut(timeout) - { - if (mMaxThreads == 0) mMaxThreads = 1; - if (mMinThreads == 0) mMinThreads = 1; - if (mMinThreads > mMaxThreads) mMinThreads = mMaxThreads; - - for (uint32 i=0; i::iterator setIterator; - - //////////////////////////////////////// - // (1) Destory all busy member threads - mMutex.Lock(); - setIterator = mBusyMember.begin(); - while (setIterator != mBusyMember.end()) - (*setIterator++)->Destroy(); - mMutex.Unlock(); - - //////////////////////////////////////// - // (2) Destory all idle member threads - while (mThreadCount) - { - mMutex.Lock(); - setIterator = mIdleMember.begin(); - while (setIterator != mIdleMember.end()) - (*setIterator++)->Destroy(); - mMutex.Unlock(); - - sleep(1); - } - - //////////////////////////////////////// - // (3) Delete the null member threads - mMutex.Lock(); - while (!mNullMember.empty()) - { - delete mNullMember.front(); - mNullMember.pop_front(); - } - mMutex.Unlock(); - } - - bool CThreadPool::Execute(void( *function )( void * ), void * arg) - { - mMutex.Lock(); - - //////////////////////////////////////// - // (1) If no idle members, return false to indicate that no threads - // were available. If the thread count is below the max, create - // a new thread. - if (mIdleMember.empty()) - { - if (mThreadCount < mMaxThreads) - new CMember(this); - mMutex.Unlock(); - return false; - } - - //////////////////////////////////////// - // (2) Delete any null member threads. - while (!mNullMember.empty()) - { - delete mNullMember.front(); - mNullMember.pop_front(); - } - - //////////////////////////////////////// - // (3) Move the first idle thread to the busy set and signal the - // thread to execute the specified function. - CMember * member = *(mIdleMember.begin()); - mIdleMember.erase(member); - mBusyMember.insert(member); - member->Execute(function,arg); - - mMutex.Unlock(); - return true; - } - - uint32 CThreadPool::GetTimeOut() - { - return mTimeOut; - } - - void CThreadPool::OnStartup(CMember * member) - { - mMutex.Lock(); - - mThreadCount++; - mIdleMember.insert(member); - - mMutex.Unlock(); - } - - void CThreadPool::OnIdle(CMember * member) - { - mMutex.Lock(); - - mBusyMember.erase(member); - mIdleMember.insert(member); - - mMutex.Unlock(); - } - - bool CThreadPool::OnDestory(CMember * member) - { - set::iterator setIterator; - - mMutex.Lock(); - - bool result = (setIterator = mIdleMember.find(member)) != mIdleMember.end(); - if (result) - { - mNullMember.push_back(member); - mIdleMember.erase(setIterator); - mThreadCount--; - } - - mMutex.Unlock(); - - return result; - } - - -//////////////////////////////////////////////////////////////////////////////// - - -} - -#ifdef EXTERNAL_DISTRO -}; -#endif -#endif // #if defined(_REENTRANT) diff --git a/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/Thread.h b/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/Thread.h deleted file mode 100644 index 4d42274b6..000000000 --- a/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/Thread.h +++ /dev/null @@ -1,146 +0,0 @@ -//////////////////////////////////////// -// Thread.h -// -// Purpose: -// 1. Declair the CThread class that encapsulates threading functionality. -// This abstract base class in intended to be used to encapsulate -// individual tasks that require threading in derived classes. -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_LINUX_THREAD_H -#define BASE_LINUX_THREAD_H - -#if !defined(_REENTRANT) -# pragma message( "Excluding Base::CThread - requires multi-threaded compile. (_REENTRANT)" ) -#else - - -#pragma warning( disable : 4786) - -#include -#include -#include "Platform.h" -#include "Mutex.h" -#include "Event.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - //////////////////////////////////////// - // Class: - // CThread - // - // Purpose: - // Encapsulates threading functionality. Creating classes derived - // from CThread provides an easy way to encapsulate tasks that require - // their own thread. - // - // Public Methods: - // StartThread() : Creates the low-level thread handle and begins executing - // the CThread::ThreadProc() function within the new thread. - // StopThread() : Signals the ThreadProc() function to stop executing using - // the mThreadContinue member variable, and waits for the ThreadProc() - // function to exit. By default, the function will block for a maximum - // of 5 seconds before exiting without the thread halting. - // IsThreadActive() : Returns true if the physical thread is still executing - // within the ThreadProc() function, otherwise it returns false. - // ThreadProc() : Pure-virtual function that will be executed when the StartThread() - // function is called. Derived classes must implement this function. The - // mThreadContinue member variable should be used internal the the ThreadProc() - // function to indicate whether it should continue executing or exit. - // Protected Attributes: - // mThreadContinue : Boolean value indicating to the ThreadProc() function - // whether to continue executing or to exit. If mThreadContinue is true, - // ThreadProc() should continue, otherwise ThreadProc() should exit. It - // left up to the derived class to implement a ThreadProc() function that - // uses the mThreadContinue member. - // - // - class CThread - { - friend void * threadProc(void *); - - public: - enum { eSTOP_SUCCESS, eSTOP_TIMEOUT }; - public: - CThread(); - virtual ~CThread(); - - void StartThread(); - int32 StopThread(int timeout=5); - bool IsThreadActive() { return mThreadActive; } - - protected: - virtual void ThreadProc() {} - - protected: - bool mThreadContinue; - private: - pthread_t mThreadID; - bool mThreadActive; - }; - - - class CThreadPool - { - private: - class CMember : public CThread - { - public: - CMember(CThreadPool * parent); - virtual ~CMember(); - - bool Execute(void( *function )( void * ), void * arg); - void Destroy(); - - protected: - virtual void ThreadProc(); - - private: - CThreadPool * mParent; - void( * mFunction )( void * ); - void * mArgument; - CEvent mSemaphore; - }; - friend class CMember; - - public: - CThreadPool(uint32 maxThreads, uint32 minThreads=1, uint32 timeout=15*60); - ~CThreadPool(); - - bool Execute(void( *function )( void * ), void * arg); - - private: - uint32 GetTimeOut(); - void OnStartup(CMember * member); - void OnIdle(CMember * member); - bool OnDestory(CMember * member); - - private: - CMutex mMutex; - std::set mIdleMember; - std::set mBusyMember; - std::list mNullMember; - uint32 mThreadCount; - - uint32 mMaxThreads; - uint32 mMinThreads; - uint32 mTimeOut; - }; - - -} -#ifdef EXTERNAL_DISTRO -}; -#endif -#endif // #if defined(_REENTRANT) - -#endif // BASE_LINUX_THREAD_H diff --git a/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/Types.h b/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/Types.h deleted file mode 100644 index bc869bac6..000000000 --- a/src/external/3rd/library/soePlatform/CSAssist/utils/Base/linux/Types.h +++ /dev/null @@ -1,42 +0,0 @@ -//////////////////////////////////////// -// Types.h -// -// Purpose: -// 1. Define integer types that are unambiguous with respect to size -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_LINUX_TYPES_H -#define BASE_LINUX_TYPES_H - -#include - -#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 signed short int16; -typedef unsigned short uint16; - -typedef int32_t int32; -typedef u_int32_t uint32; -typedef int64_t int64; -typedef u_int64_t uint64; -} -#ifdef EXTERNAL_DISTRO -}; -#endif -#endif // BASE_LINUX_TYPES_H - diff --git a/src/external/3rd/library/soePlatform/CTServiceGameAPI/Base/linux/Archive.h b/src/external/3rd/library/soePlatform/CTServiceGameAPI/Base/linux/Archive.h deleted file mode 100644 index bb623b499..000000000 --- a/src/external/3rd/library/soePlatform/CTServiceGameAPI/Base/linux/Archive.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef BASE_LINUX_ARCHIVE_H -#define BASE_LINUX_ARCHIVE_H - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif - -namespace Base -{ - - -#ifdef PACK_BIG_ENDIAN - - inline double byteSwap(double value) { byteReverse(&value); return value; } - inline float byteSwap(float value) { byteReverse(&value); return value; } - inline uint64 byteSwap(uint64 value) { byteReverse(&value); return value; } - inline int64 byteSwap(int64 value) { byteReverse(&value); return value; } - inline uint32 byteSwap(uint32 value) { byteReverse(&value); return value; } - inline int32 byteSwap(int32 value) { byteReverse(&value); return value; } - inline uint16 byteSwap(uint16 value) { byteReverse(&value); return value; } - inline int16 byteSwap(int16 value) { byteReverse(&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 diff --git a/src/external/3rd/library/soePlatform/CTServiceGameAPI/Base/linux/Platform.cpp b/src/external/3rd/library/soePlatform/CTServiceGameAPI/Base/linux/Platform.cpp deleted file mode 100644 index 4b24492c9..000000000 --- a/src/external/3rd/library/soePlatform/CTServiceGameAPI/Base/linux/Platform.cpp +++ /dev/null @@ -1,55 +0,0 @@ -//////////////////////////////////////// -// Platform.cpp -// -// Purpose: -// 1. Implementation of the global functionality declaired in Platform.h. -// -// Revisions: -// 07/10/2001 Created -// - -#include -#include "Platform.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - // Implementation of microsoft strlwr extension - // This non-ANSI function is not supported under UNIX - void _strlwr(char * s) - { - while (*s) - { - *s = tolower(*s); - s++; - } - } - - // Implementation of microsoft strlwr extension - // This non-ANSI function is not supported under UNIX - void _strupr(char * s) - { - while (*s) - { - *s = toupper(*s); - s++; - } - } - - - CTimer::CTimer() : - mTimer(0) - { - } - - -} -#ifdef EXTERNAL_DISTRO -}; -#endif - diff --git a/src/external/3rd/library/soePlatform/CTServiceGameAPI/Base/linux/Platform.h b/src/external/3rd/library/soePlatform/CTServiceGameAPI/Base/linux/Platform.h deleted file mode 100644 index 41da39728..000000000 --- a/src/external/3rd/library/soePlatform/CTServiceGameAPI/Base/linux/Platform.h +++ /dev/null @@ -1,112 +0,0 @@ -//////////////////////////////////////// -// 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. -// strlwr() : Alters the contents of a string, making it all lower-case. -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_LINUX_PLATFORM_H -#define BASE_LINUX_PLATFORM_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Types.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - uint64 getTimer(void); - uint64 getTimerFrequency(void); - void sleep(uint32 ms); - - inline uint64 getTimer(void) - { - uint64 t; - struct timeval tv; - - gettimeofday(&tv, 0); - t = tv.tv_sec; - t = t * 1000000; - t += tv.tv_usec; - return t; - } - - inline uint64 getTimerFrequency(void) - { - uint64 f = 1000000; - return f; - } - - inline void sleep(uint32 ms) - { - usleep(static_cast(ms * 1000)); - } - - void _strlwr(char * s); - void _strupr(char * s); - - - 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_LINUX_PLATFORM_H diff --git a/src/external/3rd/library/soePlatform/CTServiceGameAPI/Base/linux/Types.h b/src/external/3rd/library/soePlatform/CTServiceGameAPI/Base/linux/Types.h deleted file mode 100644 index bc869bac6..000000000 --- a/src/external/3rd/library/soePlatform/CTServiceGameAPI/Base/linux/Types.h +++ /dev/null @@ -1,42 +0,0 @@ -//////////////////////////////////////// -// Types.h -// -// Purpose: -// 1. Define integer types that are unambiguous with respect to size -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_LINUX_TYPES_H -#define BASE_LINUX_TYPES_H - -#include - -#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 signed short int16; -typedef unsigned short uint16; - -typedef int32_t int32; -typedef u_int32_t uint32; -typedef int64_t int64; -typedef u_int64_t uint64; -} -#ifdef EXTERNAL_DISTRO -}; -#endif -#endif // BASE_LINUX_TYPES_H - diff --git a/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/Archive.h b/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/Archive.h deleted file mode 100644 index bb623b499..000000000 --- a/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/Archive.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef BASE_LINUX_ARCHIVE_H -#define BASE_LINUX_ARCHIVE_H - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif - -namespace Base -{ - - -#ifdef PACK_BIG_ENDIAN - - inline double byteSwap(double value) { byteReverse(&value); return value; } - inline float byteSwap(float value) { byteReverse(&value); return value; } - inline uint64 byteSwap(uint64 value) { byteReverse(&value); return value; } - inline int64 byteSwap(int64 value) { byteReverse(&value); return value; } - inline uint32 byteSwap(uint32 value) { byteReverse(&value); return value; } - inline int32 byteSwap(int32 value) { byteReverse(&value); return value; } - inline uint16 byteSwap(uint16 value) { byteReverse(&value); return value; } - inline int16 byteSwap(int16 value) { byteReverse(&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 diff --git a/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/BlockAllocator.cpp b/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/BlockAllocator.cpp deleted file mode 100644 index 00d01ec99..000000000 --- a/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/BlockAllocator.cpp +++ /dev/null @@ -1,110 +0,0 @@ -#include "../BlockAllocator.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - BlockAllocator::BlockAllocator() - { - for(unsigned i = 0; i < 31; i++) - { - m_blocks[i] = NULL; - } - } - - BlockAllocator::~BlockAllocator() - { - // free all allocated memory blocks - for(unsigned i = 0; i < 31; i++) - { - while(m_blocks[i] != NULL) - { - unsigned *tmp = m_blocks[i]; - m_blocks[i] = (unsigned *)*m_blocks[i]; - free(tmp); - } - } - } - -// Allocate a block that is the next power of two greater than the # of bytes passed. -// 33 bytes yields a 64 byte block of memory and so forth. - - void *BlockAllocator::getBlock(unsigned bytes) - { - unsigned accum = 16, bits = 16; - unsigned *handle = NULL; - - // Perform a binary search looking for the highest bit. - - while(bits != 0) - { - // If bytes is less than the bit we're testing for, subtract half - // from the bit value and repeat - if(bytes < (unsigned)(1 << accum)) - { - bits /= 2; - accum -= bits; - } - // If bytes is greater than the bit we're testing for, add half - // from the but value and repeat - else if(bytes > (unsigned)(1 << accum)) - { - bits /= 2; - accum += bits; - } - // Got lucky and hit the value dead on - else - { - break; - } - } - // At this point accum contains the most significant bit index, increment - accum++; - if(accum < 2) - { - accum = 2; - } - - // Note that when memory is actually allocated, 8 extra bytes will be allocated.at the front - // The first integer is the address of the next block of memory when the block is in the allocator - // The second integer is the bit length of the block - // Memory is allocated on 4 byte boundaries to sidestep byte alignment problems - - - // Check if the allocator already has a block of that size - if(m_blocks[accum] == 0) - { - // remove the pre allocated block from the linked list - handle = (unsigned *)calloc(((1 << accum) / 4) + 2, sizeof(unsigned)); - handle[1] = accum; - handle[0] = 0; - } - else - { - // Allocate a new block - handle = m_blocks[accum]; - m_blocks[accum] = (unsigned *)handle[0]; - handle[0] = 0; - } - // return a pointer that skips over the header used for the allocator's purposes - return(handle + 2); - } - - void BlockAllocator::returnBlock(unsigned *handle) - { - // C++ allows for safe deletion of a NULL pointer - if(handle) - { - // Update the allocator linked list, insert this entry at the head - *(handle - 2) = (unsigned)m_blocks[*(handle - 1)]; - // Add this entry to the proper linked list node - m_blocks[*(handle - 1)] = (handle - 2); - } - } -}; -#ifdef EXTERNAL_DISTRO -}; -#endif diff --git a/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/Event.cpp b/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/Event.cpp deleted file mode 100644 index a3cce3b15..000000000 --- a/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/Event.cpp +++ /dev/null @@ -1,103 +0,0 @@ -//////////////////////////////////////// -// Event.cpp -// -// Purpose: -// 1. Implementation of the CEvent class. -// -// Revisions: -// 07/10/2001 Created -// - -#if defined(_REENTRANT) - - -#include "Event.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - CEvent::CEvent() : - mMutex(), - mCond(), - mThreadCount(0) - { - pthread_mutex_init(&mMutex, NULL); - pthread_cond_init(&mCond, NULL); - } - - CEvent::~CEvent() - { - pthread_cond_destroy(&mCond); - pthread_mutex_destroy(&mMutex); - } - - bool CEvent::Signal() - { - pthread_mutex_lock(&mMutex); - if (mThreadCount == 0) - mThreadCount = SIGNALED; - pthread_cond_signal(&mCond); - - pthread_mutex_unlock(&mMutex); - - return true; - } - - int32 CEvent::Wait(uint32 timeout) - { - int result; - - pthread_mutex_lock(&mMutex); - if (mThreadCount == SIGNALED) - { - mThreadCount = 0; - pthread_mutex_unlock(&mMutex); - - return eWAIT_SIGNAL; - } - - if (!timeout) - { - mThreadCount++; - result = pthread_cond_wait(&mCond, &mMutex); - mThreadCount--; - - pthread_mutex_unlock(&mMutex); - } - else - { - struct timeval now; - struct timespec abs_timeout; - - gettimeofday(&now, NULL); - abs_timeout.tv_sec = now.tv_sec + timeout/1000; - abs_timeout.tv_nsec = now.tv_usec * 1000 + (timeout%1000)*1000000; - abs_timeout.tv_sec += abs_timeout.tv_nsec / 1000000000; - abs_timeout.tv_nsec %= 1000000000; - - mThreadCount++; - result = pthread_cond_timedwait(&mCond, &mMutex, &abs_timeout); - mThreadCount--; - - pthread_mutex_unlock(&mMutex); - } - - if (result == 0 || result == EINTR) - return eWAIT_SIGNAL; - else if (result == ETIMEDOUT) - return eWAIT_TIMEOUT; - else - return eWAIT_ERROR; - } - -} - -#ifdef EXTERNAL_DISTRO -}; -#endif -#endif // #if defined(_REENTRANT) diff --git a/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/Event.h b/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/Event.h deleted file mode 100644 index 4801a9b20..000000000 --- a/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/Event.h +++ /dev/null @@ -1,74 +0,0 @@ -//////////////////////////////////////// -// Event.h -// -// Purpose: -// 1. Declair the CEvent class that encapsulates the functionality of a -// single-locking semaphore. -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_LINUX_EVENT_H -#define BASE_LINUX_EVENT_H - -#if !defined(_REENTRANT) -# pragma message( "Excluding Base::CEvent - requires multi-threaded compile. (_REENTRANT)" ) -#else - - -#include -#include "Platform.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - //////////////////////////////////////// - // Class: - // CEvent - // - // Purpose: - // Encapsulates the functionality of a singal-locking semaphore. - // This class is valuable for thread syncronization when a thead's - // execution needs to be dependent upon another thread. - // - // Public Methods: - // Signal() : Signals a thread that has called Wait() so that it can - // continue execution. This function returns true if the waiting - // thread was signalled successfully, otherwise false is returned. - // Wait() : Halts the calling thread's execution indefinately until - // a Singal() call is made by an external thread. If the thread is - // successfully signalled, the function returns eWAIT_SIGNAL. If - // timeout period expires without a signal, eWAIT_TIMEOUT is returned. - // If the function fails, eWAIT_ERROR is returned. - // - class CEvent - { - public: - CEvent(); - virtual ~CEvent(); - - bool Signal(); - int32 Wait(uint32 timeout = 0); - - public: - enum { eWAIT_ERROR, eWAIT_SIGNAL, eWAIT_TIMEOUT }; - enum { SIGNALED = -1 }; - private: - pthread_mutex_t mMutex; - pthread_cond_t mCond; - int mThreadCount; - }; - -} -#ifdef EXTERNAL_DISTRO -}; -#endif -#endif // #if defined(_MT) - -#endif // BASE_LINUX_EVENT_H diff --git a/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/Mutex.cpp b/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/Mutex.cpp deleted file mode 100644 index 36fe5b292..000000000 --- a/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/Mutex.cpp +++ /dev/null @@ -1,40 +0,0 @@ -//////////////////////////////////////// -// Mutex.cpp -// -// Purpose: -// 1. Implementation of the CMutex class. -// -// Revisions: -// 07/10/2001 Created -// - -#if defined(_REENTRANT) - - -#include "Mutex.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - -CMutex::CMutex() - { - mInitialized = (pthread_mutex_init(&mMutex, 0) == 0); - } - -CMutex::~CMutex() - { - if (mInitialized) - pthread_mutex_destroy(&mMutex); - } - -} -#ifdef EXTERNAL_DISTRO -}; -#endif - -#endif // #if defined(_REENTRANT) diff --git a/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/Mutex.h b/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/Mutex.h deleted file mode 100644 index dd56e3fcc..000000000 --- a/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/Mutex.h +++ /dev/null @@ -1,79 +0,0 @@ -//////////////////////////////////////// -// Mutex.h -// -// Purpose: -// 1. Declair the CMutex class that encapsulates the functionality of a -// mutually-exclusive device. -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_LINUX_MUTEX_H -#define BASE_LINUX_MUTEX_H - -#if !defined(_REENTRANT) -# pragma message( "Excluding Base::CMutex - requires multi-threaded compile. (_REENTRANT)" ) -#else - - -#include "Platform.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - //////////////////////////////////////// - // Class: - // CMutex - // - // Purpose: - // Encapsulates the functionality of a mutually-exclusive device. - // This class is valuable for protecting against race conditions - // within threaded applications. The CMutex class can be used to - // only allow a single thread to run within a specified code - // segment at a time. - // - // Public Methods: - // Lock() : Locks the mutex. If the mutex is already locked, the - // operating system will block the calling thread until another - // thread has unlocked the mutex. - // Unlock() : Unlocks the mutex. - // - class CMutex - { - public: - CMutex(); - ~CMutex(); - - void Lock(); - void Unlock(); - private: - pthread_mutex_t mMutex; - bool mInitialized; - }; - - inline void CMutex::Lock(void) - { - if (mInitialized) - pthread_mutex_lock(&mMutex); - } - - inline void CMutex::Unlock(void) - { - if (mInitialized) - pthread_mutex_unlock(&mMutex); - } - -} -#ifdef EXTERNAL_DISTRO -}; -#endif -#endif // #if defined(_MT) - -#endif // BASE_LINUX_MUTEX_H - diff --git a/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/Platform.cpp b/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/Platform.cpp deleted file mode 100644 index eeadd498b..000000000 --- a/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/Platform.cpp +++ /dev/null @@ -1,55 +0,0 @@ -//////////////////////////////////////// -// Platform.cpp -// -// Purpose: -// 1. Implementation of the global functionality declaired in Platform.h. -// -// Revisions: -// 07/10/2001 Created -// - -#include -#include "Platform.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - // Implementation of microsoft strlwr extension - // This non-ANSI function is not supported under UNIX - void strlwr(char * s) - { - while (*s) - { - *s = tolower(*s); - s++; - } - } - - // Implementation of microsoft strlwr extension - // This non-ANSI function is not supported under UNIX - void strupr(char * s) - { - while (*s) - { - *s = toupper(*s); - s++; - } - } - - - CTimer::CTimer() : - mTimer(0) - { - } - - -} -#ifdef EXTERNAL_DISTRO -}; -#endif - diff --git a/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/Platform.h b/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/Platform.h deleted file mode 100644 index 9e6d51b49..000000000 --- a/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/Platform.h +++ /dev/null @@ -1,112 +0,0 @@ -//////////////////////////////////////// -// 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. -// strlwr() : Alters the contents of a string, making it all lower-case. -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_LINUX_PLATFORM_H -#define BASE_LINUX_PLATFORM_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Types.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - uint64 getTimer(void); - uint64 getTimerFrequency(void); - void sleep(uint32 ms); - - inline uint64 getTimer(void) - { - uint64 t; - struct timeval tv; - - gettimeofday(&tv, 0); - t = tv.tv_sec; - t = t * 1000000; - t += tv.tv_usec; - return t; - } - - inline uint64 getTimerFrequency(void) - { - uint64 f = 1000000; - return f; - } - - inline void sleep(uint32 ms) - { - usleep(static_cast(ms * 1000)); - } - - void strlwr(char * s); - void strupr(char * s); - - - 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_LINUX_PLATFORM_H diff --git a/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/Thread.cpp b/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/Thread.cpp deleted file mode 100644 index a4b1e3a2e..000000000 --- a/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/Thread.cpp +++ /dev/null @@ -1,299 +0,0 @@ -//////////////////////////////////////// -// Thread.cpp -// -// Purpose: -// 1. Implementation of the CThread class. -// -// Revisions: -// 07/10/2001 Created -// - -#if defined(_REENTRANT) - - -#include -#include -#include "Thread.h" - -using namespace std; - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - void *threadProc(void *threadPtr) - { - CThread &thread = *((CThread*)threadPtr); - thread.mThreadActive = true; - thread.ThreadProc(); - thread.mThreadActive = false; - - return 0; - } - - CThread::CThread() - { - mThreadID = 0; - mThreadActive = false; - mThreadContinue = false; - } - - CThread::~CThread() - { - StopThread(); - } - - void CThread::StartThread() - { - mThreadContinue = true; - if (pthread_create(&mThreadID,0,threadProc,this) == 0) - pthread_detach(mThreadID); - while (!IsThreadActive()) - Base::sleep(1); - } - - int32 CThread::StopThread(int timeout) - { - timeout += time(0); - - mThreadContinue = false; - while (mThreadActive && time(0)OnStartup(this); - while (mThreadContinue) - { - mParent->OnIdle(this); - mSemaphore.Wait(mParent->GetTimeOut()*1000); - - if (mFunction) - { - mFunction(mArgument); - mArgument = NULL; - mFunction = NULL; - } - else if (mParent->OnDestory(this)) - mThreadContinue = false; - } - } - - -//////////////////////////////////////////////////////////////////////////////// - - - CThreadPool::CThreadPool(uint32 maxThreads, uint32 minThreads, uint32 timeout) : - mMutex(), - mIdleMember(), - mBusyMember(), - mNullMember(), - mThreadCount(0), - mMaxThreads(maxThreads), - mMinThreads(minThreads), - mTimeOut(timeout) - { - if (mMaxThreads == 0) mMaxThreads = 1; - if (mMinThreads == 0) mMinThreads = 1; - if (mMinThreads > mMaxThreads) mMinThreads = mMaxThreads; - - for (uint32 i=0; i::iterator setIterator; - - //////////////////////////////////////// - // (1) Destory all busy member threads - mMutex.Lock(); - setIterator = mBusyMember.begin(); - while (setIterator != mBusyMember.end()) - (*setIterator++)->Destroy(); - mMutex.Unlock(); - - //////////////////////////////////////// - // (2) Destory all idle member threads - while (mThreadCount) - { - mMutex.Lock(); - setIterator = mIdleMember.begin(); - while (setIterator != mIdleMember.end()) - (*setIterator++)->Destroy(); - mMutex.Unlock(); - - sleep(1); - } - - //////////////////////////////////////// - // (3) Delete the null member threads - mMutex.Lock(); - while (!mNullMember.empty()) - { - delete mNullMember.front(); - mNullMember.pop_front(); - } - mMutex.Unlock(); - } - - bool CThreadPool::Execute(void( *function )( void * ), void * arg, uint32 poolGrowthSize ) - { - mMutex.Lock(); - - //////////////////////////////////////// - // (1) If no idle members, return false to indicate that no threads - // were available. If the thread count is below the max, create - // a new thread. - if (mIdleMember.empty()) - { - if (mThreadCount < mMaxThreads) - { - if (!poolGrowthSize) - poolGrowthSize = mMinThreads; - - if ((mThreadCount + poolGrowthSize) > mMaxThreads) - poolGrowthSize = mMaxThreads - mThreadCount; - - for (uint32 i(0); i < poolGrowthSize; i++) - new CMember(this); - mMutex.Unlock(); - time_t idleTimeout = time(0) + 5; - while(mIdleMember.empty()) - { - if (time(0) >= idleTimeout) - { - return false; - } - Base::sleep(10); - } - mMutex.Lock(); - - } - else - { - mMutex.Unlock(); - return false; - } - } - - //////////////////////////////////////// - // (2) Delete any null member threads. - while (!mNullMember.empty()) - { - delete mNullMember.front(); - mNullMember.pop_front(); - } - - //////////////////////////////////////// - // (3) Move the first idle thread to the busy set and signal the - // thread to execute the specified function. - CMember * member = *(mIdleMember.begin()); - mIdleMember.erase(member); - mBusyMember.insert(member); - member->Execute(function,arg); - - mMutex.Unlock(); - return true; - } - - uint32 CThreadPool::GetTimeOut() - { - return mTimeOut; - } - - void CThreadPool::OnStartup(CMember * member) - { - mMutex.Lock(); - - mThreadCount++; - mIdleMember.insert(member); - - mMutex.Unlock(); - } - - void CThreadPool::OnIdle(CMember * member) - { - mMutex.Lock(); - - mBusyMember.erase(member); - mIdleMember.insert(member); - - mMutex.Unlock(); - } - - bool CThreadPool::OnDestory(CMember * member) - { - set::iterator setIterator; - - mMutex.Lock(); - - bool result = (setIterator = mIdleMember.find(member)) != mIdleMember.end(); - if (result) - { - mNullMember.push_back(member); - mIdleMember.erase(setIterator); - mThreadCount--; - } - - mMutex.Unlock(); - - return result; - } - - -//////////////////////////////////////////////////////////////////////////////// - - -} - -#ifdef EXTERNAL_DISTRO -}; -#endif -#endif // #if defined(_REENTRANT) diff --git a/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/Thread.h b/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/Thread.h deleted file mode 100644 index bb6d1cb2d..000000000 --- a/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/Thread.h +++ /dev/null @@ -1,146 +0,0 @@ -//////////////////////////////////////// -// Thread.h -// -// Purpose: -// 1. Declair the CThread class that encapsulates threading functionality. -// This abstract base class in intended to be used to encapsulate -// individual tasks that require threading in derived classes. -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_LINUX_THREAD_H -#define BASE_LINUX_THREAD_H - -#if !defined(_REENTRANT) -# pragma message( "Excluding Base::CThread - requires multi-threaded compile. (_REENTRANT)" ) -#else - - -#pragma warning( disable : 4786) - -#include -#include -#include "Platform.h" -#include "Mutex.h" -#include "Event.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - //////////////////////////////////////// - // Class: - // CThread - // - // Purpose: - // Encapsulates threading functionality. Creating classes derived - // from CThread provides an easy way to encapsulate tasks that require - // their own thread. - // - // Public Methods: - // StartThread() : Creates the low-level thread handle and begins executing - // the CThread::ThreadProc() function within the new thread. - // StopThread() : Signals the ThreadProc() function to stop executing using - // the mThreadContinue member variable, and waits for the ThreadProc() - // function to exit. By default, the function will block for a maximum - // of 5 seconds before exiting without the thread halting. - // IsThreadActive() : Returns true if the physical thread is still executing - // within the ThreadProc() function, otherwise it returns false. - // ThreadProc() : Pure-virtual function that will be executed when the StartThread() - // function is called. Derived classes must implement this function. The - // mThreadContinue member variable should be used internal the the ThreadProc() - // function to indicate whether it should continue executing or exit. - // Protected Attributes: - // mThreadContinue : Boolean value indicating to the ThreadProc() function - // whether to continue executing or to exit. If mThreadContinue is true, - // ThreadProc() should continue, otherwise ThreadProc() should exit. It - // left up to the derived class to implement a ThreadProc() function that - // uses the mThreadContinue member. - // - // - class CThread - { - friend void * threadProc(void *); - - public: - enum { eSTOP_SUCCESS, eSTOP_TIMEOUT }; - public: - CThread(); - virtual ~CThread(); - - void StartThread(); - int32 StopThread(int timeout=5); - bool IsThreadActive() { return mThreadActive; } - - protected: - virtual void ThreadProc() {} - - protected: - bool mThreadContinue; - private: - pthread_t mThreadID; - bool mThreadActive; - }; - - - class CThreadPool - { - private: - class CMember : public CThread - { - public: - CMember(CThreadPool * parent); - virtual ~CMember(); - - bool Execute(void( *function )( void * ), void * arg); - void Destroy(); - - protected: - virtual void ThreadProc(); - - private: - CThreadPool * mParent; - void( * mFunction )( void * ); - void * mArgument; - CEvent mSemaphore; - }; - friend class CMember; - - public: - CThreadPool(uint32 maxThreads, uint32 minThreads=1, uint32 timeout=15*60); - virtual ~CThreadPool(); - - virtual bool Execute(void( *function )( void * ), void * arg, uint32 poolGrowthSize = 0); - - private: - uint32 GetTimeOut(); - void OnStartup(CMember * member); - void OnIdle(CMember * member); - bool OnDestory(CMember * member); - - private: - CMutex mMutex; - std::set mIdleMember; - std::set mBusyMember; - std::list mNullMember; - uint32 mThreadCount; - - uint32 mMaxThreads; - uint32 mMinThreads; - uint32 mTimeOut; - }; - - -} -#ifdef EXTERNAL_DISTRO -}; -#endif -#endif // #if defined(_REENTRANT) - -#endif // BASE_LINUX_THREAD_H diff --git a/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/Types.h b/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/Types.h deleted file mode 100644 index bc869bac6..000000000 --- a/src/external/3rd/library/soePlatform/ChatAPI2/ChatAPI/utils/Base/linux/Types.h +++ /dev/null @@ -1,42 +0,0 @@ -//////////////////////////////////////// -// Types.h -// -// Purpose: -// 1. Define integer types that are unambiguous with respect to size -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_LINUX_TYPES_H -#define BASE_LINUX_TYPES_H - -#include - -#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 signed short int16; -typedef unsigned short uint16; - -typedef int32_t int32; -typedef u_int32_t uint32; -typedef int64_t int64; -typedef u_int64_t uint64; -} -#ifdef EXTERNAL_DISTRO -}; -#endif -#endif // BASE_LINUX_TYPES_H - diff --git a/src/external/3rd/library/zlib/lib/linux/libz.a b/src/external/3rd/library/zlib/lib/linux/libz.a deleted file mode 100644 index 793bb72a2..000000000 Binary files a/src/external/3rd/library/zlib/lib/linux/libz.a and /dev/null differ diff --git a/src/external/ours/library/archive/src/linux/ArchiveMutex.cpp b/src/external/ours/library/archive/src/linux/ArchiveMutex.cpp deleted file mode 100644 index 30a6b10ff..000000000 --- a/src/external/ours/library/archive/src/linux/ArchiveMutex.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// ====================================================================== -// -// -// Copyright 6/19/2001 Sony Online Entertainment -// -// ====================================================================== - - -#include "ArchiveMutex.h" - -namespace Archive -{ - -ArchiveMutex::ArchiveMutex() -{ - pthread_mutex_init(&mutex, 0); -} - -ArchiveMutex::~ArchiveMutex() -{ - pthread_mutex_destroy(&mutex); -} - -void ArchiveMutex::enter() -{ - pthread_mutex_lock(&mutex); -} - -void ArchiveMutex::leave() -{ - pthread_mutex_unlock(&mutex); -} - -} diff --git a/src/external/ours/library/archive/src/linux/ArchiveMutex.h b/src/external/ours/library/archive/src/linux/ArchiveMutex.h deleted file mode 100644 index d676b69c8..000000000 --- a/src/external/ours/library/archive/src/linux/ArchiveMutex.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef _ArchiveMutex_H -#define _ArchiveMutex_H - -#include - -namespace Archive -{ - - class ArchiveMutex - { - - public: - ArchiveMutex(); - ~ArchiveMutex(); - void enter(); - void leave(); - - pthread_mutex_t &getInternalMutex() { return mutex; } - private: - ArchiveMutex(const ArchiveMutex &o); - ArchiveMutex &operator =(const ArchiveMutex &o); - - pthread_mutex_t mutex; - - }; -}; - - - -#endif diff --git a/src/game/server/application/PhonyApp/src/linux/main.cpp b/src/game/server/application/PhonyApp/src/linux/main.cpp deleted file mode 100644 index 88acf0449..000000000 --- a/src/game/server/application/PhonyApp/src/linux/main.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -namespace MemoryManagerNamespace -{ - void getMemoryManagerParams(int & maxBytes, bool & commitAll) - { - maxBytes = 256 * 1024 * 1024; - commitAll = false; - } -} - -int main(int argc, char ** argv) -{ -} diff --git a/src/game/server/application/SwgGameServer/build/win32/SwgGameServer.vcproj b/src/game/server/application/SwgGameServer/build/win32/SwgGameServer.vcproj deleted file mode 100644 index 5d861941e..000000000 --- a/src/game/server/application/SwgGameServer/build/win32/SwgGameServer.vcproj +++ /dev/null @@ -1,961 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/game/server/application/SwgGameServer/build/win32/SwgGameServer.vcxproj b/src/game/server/application/SwgGameServer/build/win32/SwgGameServer.vcxproj deleted file mode 100644 index d08f979df..000000000 --- a/src/game/server/application/SwgGameServer/build/win32/SwgGameServer.vcxproj +++ /dev/null @@ -1,281 +0,0 @@ - - - - - Debug - Win32 - - - Optimized - Win32 - - - Release - Win32 - - - - {6D8D49D8-7832-441F-B61B-E5F2C4B42D49} - Win32Proj - - - - Application - v120 - false - MultiByte - - - Application - v120 - false - MultiByte - - - Application - v120 - false - MultiByte - - - - - - - - - - - - - - - - <_ProjectFileVersion>12.0.30501.0 - - - ..\..\..\..\..\..\compile\win32\$(ProjectName)\$(Configuration)\ - ..\..\..\..\..\..\compile\win32\$(ProjectName)\$(Configuration)\ - true - - - ..\..\..\..\..\..\compile\win32\$(ProjectName)\$(Configuration)\ - ..\..\..\..\..\..\compile\win32\$(ProjectName)\$(Configuration)\ - true - - - ..\..\..\..\..\..\compile\win32\$(ProjectName)\$(Configuration)\ - ..\..\..\..\..\..\compile\win32\$(ProjectName)\$(Configuration)\ - false - - - - Disabled - OnlyExplicitInline - ..\..\..\..\..\..\engine\server\library\serverGame\include\public;..\..\..\..\..\..\engine\server\library\serverNetworkMessages\include\public;..\..\..\..\..\..\engine\server\library\serverPathfinding\include\public;..\..\..\..\..\..\engine\server\library\serverScript\include\public;..\..\..\..\..\..\engine\server\library\serverUtility\include\public;..\..\..\..\..\..\engine\server\library\serverCommodityAPI\include\public;..\..\..\..\..\..\engine\server\library\serverCommodityAPI\src\shared;..\..\..\..\..\..\engine\server\library\serverCommodityAPI\src\shared\NetworkMessages;..\..\..\..\..\..\engine\server\library\serverCommodityAPI\src\win32;..\..\..\..\..\..\engine\shared\library\sharedCollision\include\public;..\..\..\..\..\..\engine\shared\library\sharedCommandParser\include\public;..\..\..\..\..\..\engine\shared\library\sharedDebug\include\public;..\..\..\..\..\..\engine\shared\library\sharedFile\include\public;..\..\..\..\..\..\engine\shared\library\sharedFoundation\include\public;..\..\..\..\..\..\engine\shared\library\sharedFoundationtypes\include\public;..\..\..\..\..\..\engine\shared\library\sharedGame\include\public;..\..\..\..\..\..\engine\shared\library\sharedImage\include\public;..\..\..\..\..\..\engine\shared\library\sharedLog\include\public;..\..\..\..\..\..\engine\shared\library\sharedMath\include\public;..\..\..\..\..\..\engine\shared\library\sharedMathArchive\include\public;..\..\..\..\..\..\engine\shared\library\sharedMemoryManager\include\public;..\..\..\..\..\..\engine\shared\library\sharedMemoryBlockManager\include\public;..\..\..\..\..\..\engine\shared\library\sharedMessageDispatch\include\public;..\..\..\..\..\..\engine\shared\library\sharedNetwork\include\public;..\..\..\..\..\..\engine\shared\library\sharedNetworkMessages\include\public;..\..\..\..\..\..\engine\shared\library\sharedObject\include\public;..\..\..\..\..\..\engine\shared\library\sharedPathfinding\include\public;..\..\..\..\..\..\engine\shared\library\sharedRandom\include\public;..\..\..\..\..\..\engine\shared\library\sharedRegex\include\public;..\..\..\..\..\..\engine\shared\library\sharedRemoteDebugServer\include\public;..\..\..\..\..\..\engine\shared\library\sharedSkillSystem\include\public;..\..\..\..\..\..\engine\shared\library\sharedSynchronization\include\public;..\..\..\..\..\..\engine\shared\library\sharedTerrain\include\public;..\..\..\..\..\..\engine\shared\library\sharedThread\include\public;..\..\..\..\..\..\engine\shared\library\sharedUtility\include\public;..\..\..\..\..\..\external\3rd\library\java\include;..\..\..\..\..\..\external\3rd\library\java\include\win32;..\..\..\..\..\..\external\3rd\library\stlport453\stlport;..\..\..\..\..\..\external\3rd\library\boost;..\..\..\..\..\..\external\ours\library\archive\include;..\..\..\..\..\..\external\ours\library\fileInterface\include\public;..\..\..\..\..\..\external\ours\library\localization\include;..\..\..\..\..\..\external\ours\library\localizationArchive\include\public;..\..\..\..\..\..\external\ours\library\singleton\include;..\..\..\..\..\..\external\ours\library\unicode\include;..\..\..\..\..\..\external\ours\library\unicodeArchive\include\public;..\..\..\..\..\server\library\swgServerNetworkMessages\include\public;..\..\..\..\..\shared\library\swgSharedNetworkMessages\include\public;..\..\..\..\..\shared\library\swgSharedUtility\include\public;..\..\include\private;..\..\include\public;..\..\src\shared\combat;..\..\src\shared\console;..\..\src\shared\core;..\..\src\shared\lint;..\..\src\win32;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_MBCS;DEBUG_LEVEL=2;_CRT_SECURE_NO_DEPRECATE=1;_USE_32BIT_TIME_T=1;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - true - true - true - FirstSwgGameServer.h - $(OutDir)$(ProjectName).pch - $(OutDir) - $(OutDir) - $(OutDir)$(ProjectName)_d.pdb - Level4 - false - true - ProgramDatabase - Default - true - false - - - winmm.lib;ws2_32.lib;libpcre.a;libxml2-win32-release.lib;mswsock.lib;%(AdditionalDependencies) - $(OutDir)$(ProjectName)_d.exe - ..\..\..\..\..\..\external\3rd\library\stlport453\lib\win32;..\..\..\..\..\..\external\3rd\library\pcre\4.1\win32\lib;..\..\..\..\..\..\external\3rd\library\libxml2-2.6.7.win32\lib;%(AdditionalLibraryDirectories) - libcmt;libc;%(IgnoreSpecificDefaultLibraries) - true - $(OutDir)$(ProjectName)_d.pdb - Console - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - - - Full - OnlyExplicitInline - true - Speed - false - ..\..\..\..\..\..\engine\server\library\serverGame\include\public;..\..\..\..\..\..\engine\server\library\serverNetworkMessages\include\public;..\..\..\..\..\..\engine\server\library\serverPathfinding\include\public;..\..\..\..\..\..\engine\server\library\serverScript\include\public;..\..\..\..\..\..\engine\server\library\serverUtility\include\public;..\..\..\..\..\..\engine\server\library\serverCommodityAPI\include\public;..\..\..\..\..\..\engine\server\library\serverCommodityAPI\src\shared;..\..\..\..\..\..\engine\server\library\serverCommodityAPI\src\shared\NetworkMessages;..\..\..\..\..\..\engine\server\library\serverCommodityAPI\src\win32;..\..\..\..\..\..\engine\shared\library\sharedCollision\include\public;..\..\..\..\..\..\engine\shared\library\sharedCommandParser\include\public;..\..\..\..\..\..\engine\shared\library\sharedDebug\include\public;..\..\..\..\..\..\engine\shared\library\sharedFile\include\public;..\..\..\..\..\..\engine\shared\library\sharedFoundation\include\public;..\..\..\..\..\..\engine\shared\library\sharedFoundationtypes\include\public;..\..\..\..\..\..\engine\shared\library\sharedGame\include\public;..\..\..\..\..\..\engine\shared\library\sharedImage\include\public;..\..\..\..\..\..\engine\shared\library\sharedLog\include\public;..\..\..\..\..\..\engine\shared\library\sharedMath\include\public;..\..\..\..\..\..\engine\shared\library\sharedMathArchive\include\public;..\..\..\..\..\..\engine\shared\library\sharedMemoryManager\include\public;..\..\..\..\..\..\engine\shared\library\sharedMemoryBlockManager\include\public;..\..\..\..\..\..\engine\shared\library\sharedMessageDispatch\include\public;..\..\..\..\..\..\engine\shared\library\sharedNetwork\include\public;..\..\..\..\..\..\engine\shared\library\sharedNetworkMessages\include\public;..\..\..\..\..\..\engine\shared\library\sharedObject\include\public;..\..\..\..\..\..\engine\shared\library\sharedPathfinding\include\public;..\..\..\..\..\..\engine\shared\library\sharedRandom\include\public;..\..\..\..\..\..\engine\shared\library\sharedRegex\include\public;..\..\..\..\..\..\engine\shared\library\sharedRemoteDebugServer\include\public;..\..\..\..\..\..\engine\shared\library\sharedSkillSystem\include\public;..\..\..\..\..\..\engine\shared\library\sharedSynchronization\include\public;..\..\..\..\..\..\engine\shared\library\sharedTerrain\include\public;..\..\..\..\..\..\engine\shared\library\sharedThread\include\public;..\..\..\..\..\..\engine\shared\library\sharedUtility\include\public;..\..\..\..\..\..\external\3rd\library\java\include;..\..\..\..\..\..\external\3rd\library\java\include\win32;..\..\..\..\..\..\external\3rd\library\stlport453\stlport;..\..\..\..\..\..\external\3rd\library\boost;..\..\..\..\..\..\external\ours\library\archive\include;..\..\..\..\..\..\external\ours\library\fileInterface\include\public;..\..\..\..\..\..\external\ours\library\localization\include;..\..\..\..\..\..\external\ours\library\localizationArchive\include\public;..\..\..\..\..\..\external\ours\library\singleton\include;..\..\..\..\..\..\external\ours\library\unicode\include;..\..\..\..\..\..\external\ours\library\unicodeArchive\include\public;..\..\..\..\..\server\library\swgServerNetworkMessages\include\public;..\..\..\..\..\shared\library\swgSharedNetworkMessages\include\public;..\..\..\..\..\shared\library\swgSharedUtility\include\public;..\..\include\private;..\..\include\public;..\..\src\shared\combat;..\..\src\shared\console;..\..\src\shared\core;..\..\src\shared\lint;..\..\src\win32;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_MBCS;DEBUG_LEVEL=1;_CRT_SECURE_NO_DEPRECATE=1;_USE_32BIT_TIME_T=1;_CONSOLE;%(PreprocessorDefinitions) - true - MultiThreadedDebug - true - true - true - FirstSwgGameServer.h - $(OutDir)$(ProjectName).pch - $(OutDir) - $(OutDir) - $(OutDir)$(ProjectName)_o.pdb - Level4 - false - true - ProgramDatabase - Default - true - false - - - winmm.lib;ws2_32.lib;libpcre.a;libxml2-win32-release.lib;mswsock.lib;%(AdditionalDependencies) - $(OutDir)$(ProjectName)_o.exe - ..\..\..\..\..\..\external\3rd\library\stlport453\lib\win32;..\..\..\..\..\..\external\3rd\library\pcre\4.1\win32\lib;..\..\..\..\..\..\external\3rd\library\libxml2-2.6.7.win32\lib;%(AdditionalLibraryDirectories) - libcmt;libc;%(IgnoreSpecificDefaultLibraries) - true - $(OutDir)$(ProjectName)_o.pdb - Console - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - - - MaxSpeed - OnlyExplicitInline - true - Speed - true - ..\..\..\..\..\..\engine\server\library\serverGame\include\public;..\..\..\..\..\..\engine\server\library\serverNetworkMessages\include\public;..\..\..\..\..\..\engine\server\library\serverPathfinding\include\public;..\..\..\..\..\..\engine\server\library\serverScript\include\public;..\..\..\..\..\..\engine\server\library\serverUtility\include\public;..\..\..\..\..\..\engine\server\library\serverCommodityAPI\include\public;..\..\..\..\..\..\engine\server\library\serverCommodityAPI\src\shared;..\..\..\..\..\..\engine\server\library\serverCommodityAPI\src\shared\NetworkMessages;..\..\..\..\..\..\engine\server\library\serverCommodityAPI\src\win32;..\..\..\..\..\..\engine\shared\library\sharedCollision\include\public;..\..\..\..\..\..\engine\shared\library\sharedCommandParser\include\public;..\..\..\..\..\..\engine\shared\library\sharedDebug\include\public;..\..\..\..\..\..\engine\shared\library\sharedFile\include\public;..\..\..\..\..\..\engine\shared\library\sharedFoundation\include\public;..\..\..\..\..\..\engine\shared\library\sharedFoundationtypes\include\public;..\..\..\..\..\..\engine\shared\library\sharedGame\include\public;..\..\..\..\..\..\engine\shared\library\sharedImage\include\public;..\..\..\..\..\..\engine\shared\library\sharedLog\include\public;..\..\..\..\..\..\engine\shared\library\sharedMath\include\public;..\..\..\..\..\..\engine\shared\library\sharedMathArchive\include\public;..\..\..\..\..\..\engine\shared\library\sharedMemoryManager\include\public;..\..\..\..\..\..\engine\shared\library\sharedMemoryBlockManager\include\public;..\..\..\..\..\..\engine\shared\library\sharedMessageDispatch\include\public;..\..\..\..\..\..\engine\shared\library\sharedNetwork\include\public;..\..\..\..\..\..\engine\shared\library\sharedNetworkMessages\include\public;..\..\..\..\..\..\engine\shared\library\sharedObject\include\public;..\..\..\..\..\..\engine\shared\library\sharedPathfinding\include\public;..\..\..\..\..\..\engine\shared\library\sharedRandom\include\public;..\..\..\..\..\..\engine\shared\library\sharedRegex\include\public;..\..\..\..\..\..\engine\shared\library\sharedRemoteDebugServer\include\public;..\..\..\..\..\..\engine\shared\library\sharedSkillSystem\include\public;..\..\..\..\..\..\engine\shared\library\sharedSynchronization\include\public;..\..\..\..\..\..\engine\shared\library\sharedTerrain\include\public;..\..\..\..\..\..\engine\shared\library\sharedThread\include\public;..\..\..\..\..\..\engine\shared\library\sharedUtility\include\public;..\..\..\..\..\..\external\3rd\library\java\include;..\..\..\..\..\..\external\3rd\library\java\include\win32;..\..\..\..\..\..\external\3rd\library\stlport453\stlport;..\..\..\..\..\..\external\3rd\library\boost;..\..\..\..\..\..\external\ours\library\archive\include;..\..\..\..\..\..\external\ours\library\fileInterface\include\public;..\..\..\..\..\..\external\ours\library\localization\include;..\..\..\..\..\..\external\ours\library\localizationArchive\include\public;..\..\..\..\..\..\external\ours\library\singleton\include;..\..\..\..\..\..\external\ours\library\unicode\include;..\..\..\..\..\..\external\ours\library\unicodeArchive\include\public;..\..\..\..\..\server\library\swgServerNetworkMessages\include\public;..\..\..\..\..\shared\library\swgSharedNetworkMessages\include\public;..\..\..\..\..\shared\library\swgSharedUtility\include\public;..\..\include\private;..\..\include\public;..\..\src\shared\combat;..\..\src\shared\console;..\..\src\shared\core;..\..\src\shared\lint;..\..\src\win32;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_MBCS;DEBUG_LEVEL=0;_CRT_SECURE_NO_DEPRECATE=1;_USE_32BIT_TIME_T=1;_CONSOLE;%(PreprocessorDefinitions) - true - MultiThreaded - true - true - true - FirstSwgGameServer.h - $(OutDir)$(ProjectName).pch - $(OutDir) - $(OutDir) - $(OutDir)$(ProjectName)_r.pdb - Level4 - false - true - ProgramDatabase - Default - true - false - - - winmm.lib;ws2_32.lib;libpcre.a;libxml2-win32-release.lib;mswsock.lib;%(AdditionalDependencies) - $(OutDir)$(ProjectName)_r.exe - ..\..\..\..\..\..\external\3rd\library\stlport453\lib\win32;..\..\..\..\..\..\external\3rd\library\pcre\4.1\win32\lib;..\..\..\..\..\..\external\3rd\library\libxml2-2.6.7.win32\lib;%(AdditionalLibraryDirectories) - libcmtd;libc;%(IgnoreSpecificDefaultLibraries) - true - $(OutDir)$(ProjectName)_r.pdb - Console - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - - - MaxSpeed - - - MaxSpeed - - - MaxSpeed - - - MaxSpeed - - - MaxSpeed - - - MaxSpeed - - - - MaxSpeed - - - MaxSpeed - - - MaxSpeed - - - MaxSpeed - - - MaxSpeed - - - MaxSpeed - - - MaxSpeed - - - MaxSpeed - - - MaxSpeed - - - MaxSpeed - - - Create - Create - Create - - - MaxSpeed - - - - - - - - - - - - - - - - - - - - - - - - - true - true - true - - - - - - \ No newline at end of file diff --git a/src/game/server/application/SwgGameServer/build/win32/ignoreLibraries.rsp b/src/game/server/application/SwgGameServer/build/win32/ignoreLibraries.rsp deleted file mode 100644 index 0a9ce4f3e..000000000 --- a/src/game/server/application/SwgGameServer/build/win32/ignoreLibraries.rsp +++ /dev/null @@ -1 +0,0 @@ -libc diff --git a/src/game/server/application/SwgGameServer/build/win32/ignoreLibraries_d.rsp b/src/game/server/application/SwgGameServer/build/win32/ignoreLibraries_d.rsp deleted file mode 100644 index 5bae4d44f..000000000 --- a/src/game/server/application/SwgGameServer/build/win32/ignoreLibraries_d.rsp +++ /dev/null @@ -1 +0,0 @@ -libcmt diff --git a/src/game/server/application/SwgGameServer/build/win32/ignoreLibraries_o.rsp b/src/game/server/application/SwgGameServer/build/win32/ignoreLibraries_o.rsp deleted file mode 100644 index 5bae4d44f..000000000 --- a/src/game/server/application/SwgGameServer/build/win32/ignoreLibraries_o.rsp +++ /dev/null @@ -1 +0,0 @@ -libcmt diff --git a/src/game/server/application/SwgGameServer/build/win32/ignoreLibraries_r.rsp b/src/game/server/application/SwgGameServer/build/win32/ignoreLibraries_r.rsp deleted file mode 100644 index c0d84d50c..000000000 --- a/src/game/server/application/SwgGameServer/build/win32/ignoreLibraries_r.rsp +++ /dev/null @@ -1,2 +0,0 @@ -libcmtd - diff --git a/src/game/server/application/SwgGameServer/build/win32/includePaths.rsp b/src/game/server/application/SwgGameServer/build/win32/includePaths.rsp deleted file mode 100644 index cb22014a8..000000000 --- a/src/game/server/application/SwgGameServer/build/win32/includePaths.rsp +++ /dev/null @@ -1,56 +0,0 @@ -../../../../../../engine/server/library/serverGame/include/public -../../../../../../engine/server/library/serverNetworkMessages/include/public -../../../../../../engine/server/library/serverPathfinding/include/public -../../../../../../engine/server/library/serverScript/include/public -../../../../../../engine/server/library/serverUtility/include/public -../../../../../../engine/server/library/serverCommodityAPI/include/public -../../../../../../engine/server/library/serverCommodityAPI/src/shared -../../../../../../engine/server/library/serverCommodityAPI/src/shared/NetworkMessages -../../../../../../engine/server/library/serverCommodityAPI/src/win32 -../../../../../../engine/shared/library/sharedCollision/include/public -../../../../../../engine/shared/library/sharedCommandParser/include/public -../../../../../../engine/shared/library/sharedDebug/include/public -../../../../../../engine/shared/library/sharedFile/include/public -../../../../../../engine/shared/library/sharedFoundation/include/public -../../../../../../engine/shared/library/sharedFoundationtypes/include/public -../../../../../../engine/shared/library/sharedGame/include/public -../../../../../../engine/shared/library/sharedImage/include/public -../../../../../../engine/shared/library/sharedLog/include/public -../../../../../../engine/shared/library/sharedMath/include/public -../../../../../../engine/shared/library/sharedMathArchive/include/public -../../../../../../engine/shared/library/sharedMemoryManager/include/public -../../../../../../engine/shared/library/sharedMemoryBlockManager/include/public -../../../../../../engine/shared/library/sharedMessageDispatch/include/public -../../../../../../engine/shared/library/sharedNetwork/include/public -../../../../../../engine/shared/library/sharedNetworkMessages/include/public -../../../../../../engine/shared/library/sharedObject/include/public -../../../../../../engine/shared/library/sharedPathfinding/include/public -../../../../../../engine/shared/library/sharedRandom/include/public -../../../../../../engine/shared/library/sharedRegex/include/public -../../../../../../engine/shared/library/sharedRemoteDebugServer/include/public -../../../../../../engine/shared/library/sharedSkillSystem/include/public -../../../../../../engine/shared/library/sharedSynchronization/include/public -../../../../../../engine/shared/library/sharedTerrain/include/public -../../../../../../engine/shared/library/sharedThread/include/public -../../../../../../engine/shared/library/sharedUtility/include/public -../../../../../../external/3rd/library/java/include -../../../../../../external/3rd/library/java/include/win32 -../../../../../../external/3rd/library/stlport453/stlport -../../../../../../external/3rd/library/boost -../../../../../../external/ours/library/archive/include -../../../../../../external/ours/library/fileInterface/include/public -../../../../../../external/ours/library/localization/include -../../../../../../external/ours/library/localizationArchive/include/public -../../../../../../external/ours/library/singleton/include -../../../../../../external/ours/library/unicode/include -../../../../../../external/ours/library/unicodeArchive/include/public -../../../../../server/library/swgServerNetworkMessages/include/public -../../../../../shared/library/swgSharedNetworkMessages/include/public -../../../../../shared/library/swgSharedUtility/include/public -../../include/private -../../include/public -../../src/shared/combat -../../src/shared/console -../../src/shared/core -../../src/shared/lint -../../src/win32 diff --git a/src/game/server/application/SwgGameServer/build/win32/libraries.rsp b/src/game/server/application/SwgGameServer/build/win32/libraries.rsp deleted file mode 100644 index e5a9117a8..000000000 --- a/src/game/server/application/SwgGameServer/build/win32/libraries.rsp +++ /dev/null @@ -1,5 +0,0 @@ -winmm.lib -ws2_32.lib -libpcre.a -libxml2-win32-release.lib -mswsock.lib diff --git a/src/game/server/application/SwgGameServer/build/win32/libraryPaths.rsp b/src/game/server/application/SwgGameServer/build/win32/libraryPaths.rsp deleted file mode 100644 index c5557c8a5..000000000 --- a/src/game/server/application/SwgGameServer/build/win32/libraryPaths.rsp +++ /dev/null @@ -1,3 +0,0 @@ -../../../../../../external/3rd/library/stlport453/lib/win32 -../../../../../../external/3rd/library/pcre/4.1/win32/lib -../../../../../../external/3rd/library/libxml2-2.6.7.win32/lib diff --git a/src/game/server/application/SwgGameServer/build/win32/settings.rsp b/src/game/server/application/SwgGameServer/build/win32/settings.rsp deleted file mode 100644 index 22497d972..000000000 --- a/src/game/server/application/SwgGameServer/build/win32/settings.rsp +++ /dev/null @@ -1,4 +0,0 @@ -console -noPchDirectory -Zm200 -debugInline diff --git a/src/game/server/application/SwgGameServer/codegen/README b/src/game/server/application/SwgGameServer/codegen/README deleted file mode 100644 index 89c0f7965..000000000 --- a/src/game/server/application/SwgGameServer/codegen/README +++ /dev/null @@ -1,32 +0,0 @@ -Using maketable.pl - -This PERL script can generate some of the more boring sections of the database code. To run it, -feed in the header files for the object declarations like so: - -./maketable.pl ../src/shared/object/*.h - -It outputs several files. The text of these files should be pasted into sections of the server -code. These sections are set off with comments like this: - -//----------------------------------------------------------------------------- -// From savepackage.auto -// BEGIN AUTO_GENERATED CODE ############################# - - .... - -// END AUTO_GENERATED CODE ############################# - -The utility putauto.pl will paste in any autogenerated files. Run it like this: - -./putauto.pl - -The script putall will run putauto.pl on all the necessary files, except for create.ddl - -These are the output files: -sql.auto (sql for creating tables, goes into create.ddl) -Schema.h.auto (goes into Schema.h) -ObjectQueries.cpp.auto (etc.) -ObjectQueries.h.auto -MakeDBPackage.cpp.auto -DatabasePackage.h.auto -DatabasePackage.cpp.auto diff --git a/src/game/server/application/SwgGameServer/codegen/bindmap.def b/src/game/server/application/SwgGameServer/codegen/bindmap.def deleted file mode 100644 index 28fc2211a..000000000 --- a/src/game/server/application/SwgGameServer/codegen/bindmap.def +++ /dev/null @@ -1,3 +0,0 @@ -integer BindableLong -float BindableDouble -char(1) BindableBool diff --git a/src/game/server/application/SwgGameServer/codegen/maketable.pl b/src/game/server/application/SwgGameServer/codegen/maketable.pl deleted file mode 100644 index a4021b14b..000000000 --- a/src/game/server/application/SwgGameServer/codegen/maketable.pl +++ /dev/null @@ -1,372 +0,0 @@ -#!/usr/bin/perl - -# This auto-gens some of the more boring code for dealing with -# database objects. The generated code needs to be cut-and -# pasted into the appropriate files. The idea is to save -# typing and reduce errors, not to fully automate the system. - -open (TYPEMAP,"typemap.def"); -while ($_=) -{ - chop; - ($c,$db,$cast) = split /\t/; - $typemap{$c}=$db; - if ($cast ne "") - { - $cast{$c}=1; - } -} -close (TYPEMAP); - -open (BINDMAP,"bindmap.def"); -while ($_=) -{ - chop; - ($db,$bindable) = split /\t/; - $bindablemap{$db}=$bindable; -} -close (BINDMAP); - -while (<>) -{ - if(/\/\/.*BPM/) - { - &parseBPM(); - } -} - -open (SQL,">sql.auto"); -open (SCHEMA,">Schema.h.auto"); -open (QUERY,">ObjectQueries.cpp.auto"); -open (QUERYH,">ObjectQueries.h.auto"); -open (MAKEPACKAGE,">MakeDBPackage.cpp.auto"); -open (PACKAGEH,">DatabasePackage.h.auto"); -open (SAVEPACKAGE,">DatabasePackage.cpp.auto"); - -# Print out the tables -foreach $tablename (sort keys %columns) -{ - # build a list of columns, including those from inherited classes - $col=""; - for ($dep=$depend{$tablename}; $dep ne ""; $dep=$depend{$dep}) - { - $col=$col.$columns{$dep}; - } - - $col=$col.$columns{$tablename}; - - ######################################################## - # print out the table creation script - ######################################################## - - print SQL "create table ".&dbIzeName($tablename)."s\n(\n"; - @tabledef = (); - push (@tabledef, "\tobject_id integer"); - foreach $colrec (split /\|/,$col) - { - ($name,$type) = split / /,$colrec; - if ($typemap{$type} eq "") - { -# push (@tabledef, "--\t".$name." ".$type) - } - else - { - push (@tabledef, "\t".&dbIzeName($name)." ".$typemap{$type}); - } - } - - print SQL join (",\n",@tabledef); - print SQL "\n);\n\n"; - - ######################################################## - # print out the row object - ######################################################## - - print SCHEMA "struct ".$tablename."Row : public DB::Row\n{\n"; - print SCHEMA "\tDB::BindableLong object_id;\n"; - foreach $colrec (split /\|/,$col) - { - ($name,$type) = split / /,$colrec; - if ($typemap{$type} ne "") - { - print SCHEMA "\tDB::".$bindablemap{$typemap{$type}}." ".&dbIzeName($name).";\n"; - } - } - print SCHEMA "};\n\n"; - - ######################################################## - #print out the query class declaration - ######################################################## - - print QUERYH "class ".$tablename."Query : public DB::ModeQuery\n{\n"; - print QUERYH "\t".$tablename."Query(const ".$tablename."Query&); // disable\n"; - print QUERYH "\t".$tablename."Query& operator=(const ".$tablename."Query&); // disable\n"; - print QUERYH "public:\n"; - print QUERYH "\t".$tablename."Query() {}\n\n"; - print QUERYH "\tbool bind();\n"; - print QUERYH "\tchar *getSQL();\n"; - print QUERYH "};\n\n"; - - ######################################################## - #print out the bind function - ######################################################## - - $count=1; - $bind="bool ".$tablename."Query::bind()\n{\n"; - $bind=$bind."\t".$tablename."Row *myData=dynamic_cast<".$tablename."Row*>(data);\n"; - $bind=$bind."\tswitch (mode)\n\t{\n"; - - $bindObjId="\t\t\tif (!myData->object_id.bindParameter(1,this)) return false;\n"; - - $updSection="\t\tcase mode_UPDATE:\n\t\tcase mode_INSERT:\n"; - $selSection="\t\tcase mode_SELECT:\n".$bindObjId."\n"; - foreach $colrec (split /\|/,$col) - { - ($name,$type) = split / /,$colrec; - if ($typemap{$type} ne "") - { - $updSection=$updSection."\t\t\tif (!myData->".&dbIzeName($name).".bindParameter(".$count.",this)) return false;\n"; - $selSection=$selSection."\t\t\tif (!myData->".&dbIzeName($name).".bindCol(".$count.",this)) return false;\n"; - $count++; - } - } - $updSection=$updSection."\n\t\t\tif (!myData->object_id.bindParameter($count,this)) return false;\n"; - - - $bind=$bind.$updSection."\t\t\tbreak;\n\n".$selSection."\t\t\tbreak;\n\n"; - $bind=$bind."\t\tcase mode_DELETE:\n".$bindObjId."\t\t\tbreak;\n\n"; - $bind=$bind."\t\tdefault:\n\t\t\tDEBUG_FATAL(true,(\"Bad query mode.\"));\n"; - $bind=$bind."\t}\n\treturn true;\n}\n\n"; - print QUERY $bind; #fix object_id -- should be last for update,insert - - - ######################################################## - # Print out the SQL - ######################################################## - - @columnNames=(); - foreach $colrec (split /\|/,$col) - { - ($name,$type) = split / /,$colrec; - if ($typemap{$type} ne "") - { - push @columnNames,&dbIzeName($name); - } - } - - print QUERY "char *".$tablename."Query::getSQL()\n{\n\tswitch(mode)\n\t{\n"; - print QUERY "\t\tcase mode_UPDATE:\n"; - print QUERY "\t\t\treturn (\"update ".&dbIzeName($tablename)."s set "; - print QUERY join("=?, ",@columnNames)."=? where object_id=?\");\n"; - - print QUERY "\t\tcase mode_INSERT:\n"; - print QUERY "\t\t\treturn (\"insert into ".&dbIzeName($tablename)."s ("; - print QUERY join(", ",@columnNames).", object_id) values ("; - foreach $temp (@columnNames) { print QUERY "?, ";} - print QUERY "?)\");\n"; - - print QUERY "\t\tcase mode_DELETE:\n"; - print QUERY "\t\t\treturn (\"delete from ".&dbIzeName($tablename)."s where object_id=?\");\n"; - - print QUERY "\t\tcase mode_SELECT:\n"; - print QUERY "\t\t\treturn (\"select "; - print QUERY join(", ",@columnNames); - print QUERY " from ".&dbIzeName($tablename)."s where object_id=?\");\n"; - - print QUERY "\t\tdefault:\n"; - print QUERY "\t\t\tDEBUG_FATAL(true,(\"Bad query mode.\"));\n"; - - print QUERY "\t}\n\treturn 0; // this is unreachable but here to avoid compiler warning\n}\n\n"; - - ######################################################## - # Print out the Package declaration - ######################################################## - - print PACKAGEH "class ".$tablename."Package : public ServerObjectPackage\n{\n"; - print PACKAGEH "public:\n"; - print PACKAGEH "\t".$tablename."Package() {}\n\n"; - - print PACKAGEH "\tvirtual void finishLoad(Snapshot *snap, DB::Session *ses);\n"; - print PACKAGEH "\tvirtual void save(Snapshot *snap, DB::Session *ses);\n"; - - print PACKAGEH "private:\n"; - print PACKAGEH "\t".$tablename."Package(const ".$tablename."Package&); //disable\n"; - print PACKAGEH "\t".$tablename."Package& operator=(const ".$tablename."Package&); // disable\n\n"; - print PACKAGEH "\tDBSchema::".$tablename."Row data;\n\n"; - - print PACKAGEH "\tfriend class ::".$tablename.";\n};\n\n"; - - ######################################################## - # Print out the CreatePacakge functions - ######################################################## - - print MAKEPACKAGE "DBPackage::ServerObjectPackage* ".$tablename."::MakeDBPackage(void) const\n{\n"; - print MAKEPACKAGE "\tDBPackage::".$tablename."Package *buffer=new DBPackage::".$tablename."Package;\n"; - print MAKEPACKAGE "\tbuffer->status=databaseStatus;\n"; - print MAKEPACKAGE "\tMakeDBPackage(buffer);\n"; - print MAKEPACKAGE "\treturn buffer;\n}\n\n"; - - print MAKEPACKAGE "void ".$tablename."::MakeDBPackage(DBPackage::ServerObjectPackage *buffer) const\n{\n"; - print MAKEPACKAGE "\tDBPackage::".$tablename."Package *myBuffer=dynamic_cast(buffer);\n"; - print MAKEPACKAGE "\tNOT_NULL(myBuffer);\n\n"; - print MAKEPACKAGE "\tmyBuffer->data.object_id=getNetworkId();\n"; - foreach $colrec (split /\|/,$col) - { - ($name,$type) = split / /,$colrec; - if ($typemap{$type} ne "") - { - print MAKEPACKAGE "\tmyBuffer->data.".&dbIzeName($name)."=".&getterName($name)."();\n"; - } - } - print MAKEPACKAGE "\n\tNetworkObject::MakeDBPackage(buffer);\n}\n\n"; - - ######################################################## - # Print out the LoadFromPackage functions - ######################################################## - - #constructor -- going away -# if ($depend{$tablename} eq "") -# { -# print MAKEPACKAGE $tablename."::".$tablename."(DBPackage::ServerObjectPackage *buffer) : NetworkObject(buffer)\n"; -# } -# else -# { -# print MAKEPACKAGE $tablename."::".$tablename."(DBPackage::ServerObjectPackage *buffer) : ".$depend{$tablename}."(buffer)\n"; -# } - -# print MAKEPACKAGE "{\n"; -# print MAKEPACKAGE "\tDBPackage::".$tablename."Package *myPackage=dynamic_cast(buffer);\n"; -# print MAKEPACKAGE "\tDEBUG_FATAL(myPackage==0,(\"Attempt to create a ".$tablename." from something that isn't a ".$tablename."Package\"));\n\n"; - -# foreach $colrec (split /\|/,$col) -# { -# ($name,$type) = split / /,$colrec; -# if ($typemap{$type} ne "") -# { -# if ($cast{$type} ne "") -# { -# print MAKEPACKAGE "\t".&setterName($name)."(static_cast<".$type.">(myPackage->data.".&dbIzeName($name).".getValue()));\n"; -# } -# else -# { -# print MAKEPACKAGE "\t".&setterName($name)."(myPackage->data.".&dbIzeName($name).".getValue());\n"; -# } -# } -# } -# print MAKEPACKAGE "}\n\n"; - - #loadFromDBPackage -- keep - print MAKEPACKAGE "void ".$tablename."::loadFromDBPackage(DBPackage::ServerObjectPackage *buffer)\n"; - print MAKEPACKAGE "{\n"; - print MAKEPACKAGE "\tDBPackage::".$tablename."Package *myPackage=dynamic_cast(buffer);\n"; - print MAKEPACKAGE "\tDEBUG_FATAL(myPackage==0,(\"Attempt to create object %i, a ".$tablename." from something that isn't a ".$tablename."Package. May indicate that the object's type_id doesn't match its template.\",buffer->getObjectId()));\n\n"; - print MAKEPACKAGE "\tNetworkObject::loadFromDBPackage(buffer);\n\n"; - foreach $colrec (split /\|/,$col) - { - ($name,$type) = split / /,$colrec; - if ($typemap{$type} ne "") - { - if ($cast{$type} ne "") - { - print MAKEPACKAGE "\t".&setterName($name)."(static_cast<".$type.">(myPackage->data.".&dbIzeName($name).".getValue()));\n"; - } - else - { - print MAKEPACKAGE "\t".&setterName($name)."(myPackage->data.".&dbIzeName($name).".getValue());\n"; - } - } - } - print MAKEPACKAGE "}\n\n"; - - ######################################################## - # Print out the save & load package functions - ######################################################## - - print SAVEPACKAGE "void DBPackage::".$tablename."Package::finishLoad(Snapshot *snap, DB::Session *ses)\n"; - print SAVEPACKAGE "{\n"; - print SAVEPACKAGE "\tUNREF(ses);\n"; - print SAVEPACKAGE "\tUNREF(snap);\n\n"; - - print SAVEPACKAGE "\tDBQuery::".$tablename."Query q;\n"; - print SAVEPACKAGE "\tq.selectMode();\n"; - print SAVEPACKAGE "\tdata.object_id=baseData.object_id;\n"; - print SAVEPACKAGE "\tq.setData(&data);\n\n"; - - print SAVEPACKAGE "\tses->exec(&q);\n"; - print SAVEPACKAGE "\tif (!q.fetch())\n"; - print SAVEPACKAGE "\t{\n"; - print SAVEPACKAGE "\t\tFATAL (true,(\"Unable to retrive additional data needed by object %i\",baseData.object_id.getValue()));\n"; - print SAVEPACKAGE "\t}\n\n"; - - print SAVEPACKAGE "\tq.done();\n"; - print SAVEPACKAGE "}\n\n"; - - print SAVEPACKAGE "void DBPackage::".$tablename."Package::save(Snapshot *snap, DB::Session *ses)\n"; - print SAVEPACKAGE "{\n"; - print SAVEPACKAGE "\tDBQuery::".$tablename."Query q;\n\n"; - - print SAVEPACKAGE "\tswitch(status)\n"; - print SAVEPACKAGE "\t{\n"; - print SAVEPACKAGE "\t\tcase ::NetworkObject::NEW_OBJECT:\n"; - print SAVEPACKAGE "\t\t\tq.insertMode();\n"; - print SAVEPACKAGE "\t\t\tbreak;\n\n"; - - print SAVEPACKAGE "\t\tcase ::NetworkObject::CHANGED:\n"; - print SAVEPACKAGE "\t\t\tq.updateMode();\n"; - print SAVEPACKAGE "\t\t\tbreak;\n\n"; - - print SAVEPACKAGE "\t\tdefault:\n"; - print SAVEPACKAGE "\t\t\tFATAL(true,(\"Unsupported database status.\"));\n"; - print SAVEPACKAGE "\t}\n\n"; - - print SAVEPACKAGE "\tq.setData(&data);\n"; - print SAVEPACKAGE "\tses->exec(&q);\n"; - print SAVEPACKAGE "\tq.done();\n"; - - print SAVEPACKAGE "\tServerObjectPackage::save(snap,ses);\n"; - print SAVEPACKAGE "}\n\n"; - -} - - -sub parseBPM -{ - $_ =~ /BPM\s*(\w*)/; - $tablename=$1; - if ($_ =~ /BPM\s*\w+\s*\:\s*(\w+)/) - { - $depend{$tablename} = $1; - } - $_=<>; - while (!($_ =~ /\/\/.*EPM/)) - { - if ($_ =~ /([^\s]+)\s+([^\s]+)\;/) - { - ($type,$name)=($1,$2); - $columns{$tablename}=$columns{$tablename}.$name." ".$type."|"; - } - $_=<>; - } -} - -sub dbIzeName -{ - my($name)=@_; - $name =~ s/([a-z])([A-Z])/$1_$2/g; - $name =~ tr/[A-Z]/[a-z]/; - return $name; -} - -sub getterName -{ - my($name)=@_; - $name = "get".ucfirst ($name); - return $name; -} - -sub setterName -{ - my($name)=@_; - $name = "set".ucfirst ($name); - return $name; -} diff --git a/src/game/server/application/SwgGameServer/codegen/putall b/src/game/server/application/SwgGameServer/codegen/putall deleted file mode 100644 index 9363f9cbe..000000000 --- a/src/game/server/application/SwgGameServer/codegen/putall +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -./maketable.pl ../src/shared/object/*.h - -p4 open ../src/shared/database/Schema.h ../src/shared/database/ObjectQueries.cpp ../src/shared/database/ObjectQueries.h ../src/shared/database/MakeDBPackage.cpp ../src/shared/database/DatabasePackage.h ../src/shared/database/DatabasePackage.cpp ../../database/schema/create.ddl - -./putauto.pl ../src/shared/database/Schema.h ../src/shared/database/ObjectQueries.cpp ../src/shared/database/ObjectQueries.h ../src/shared/database/MakeDBPackage.cpp ../src/shared/database/DatabasePackage.h ../src/shared/database/DatabasePackage.cpp ../../database/schema/create.ddl - -p4 revert -a ../src/shared/database/Schema.h ../src/shared/database/ObjectQueries.cpp ../src/shared/database/ObjectQueries.h ../src/shared/database/MakeDBPackage.cpp ../src/shared/database/DatabasePackage.h ../src/shared/database/DatabasePackage.cpp ../../database/schema/create.ddl diff --git a/src/game/server/application/SwgGameServer/codegen/putauto.pl b/src/game/server/application/SwgGameServer/codegen/putauto.pl deleted file mode 100644 index bde1f12de..000000000 --- a/src/game/server/application/SwgGameServer/codegen/putauto.pl +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/perl - -@files=@ARGV; - -foreach $file (@files) -{ - print "Working on $file\n"; - - open (INFILE,$file); - open (OUTFILE,">".$file.".tmp"); - while () - { - print OUTFILE $_; - if ((/\/\/\s*From\s+([^\s]+)/) || - (/--\s*From\s+([^\s]+)/)) - { - $from=$1; - } - if ((/\/\/ BEGIN AUTO_GENERATED CODE\s*\#/) || - (/-- BEGIN AUTO_GENERATED CODE/)) - { - &insertFile($from); - while (!(/\/\/ END AUTO_GENERATED CODE\s*\#/) && - !(/-- END AUTO_GENERATED CODE/)) - { - $_=; - } - print OUTFILE $_; - } - } - close (OUTFILE); - close(INFILE); - - $rc=system("diff --brief $file.tmp $file"); - if ($rc!=0) - { - system ("cp $file.tmp $file"); - } - system("rm $file.tmp"); -} - -sub insertFile -{ - print OUTFILE "\n"; - - my($filename)=@_; - open (INSFILE,$filename); - while () - { - print OUTFILE $_; - } - close INSFILE; -} - diff --git a/src/game/server/application/SwgGameServer/codegen/typemap.def b/src/game/server/application/SwgGameServer/codegen/typemap.def deleted file mode 100644 index 9f11c2993..000000000 --- a/src/game/server/application/SwgGameServer/codegen/typemap.def +++ /dev/null @@ -1,8 +0,0 @@ -int integer -bool char(1) -NetworkId integer -Gender integer cast -ArmorEffectiveness integer -real float cast -StringId integer -InstallationType integer cast diff --git a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/CSHandler.h b/src/game/server/application/SwgGameServer/include/public/SwgGameServer/CSHandler.h deleted file mode 100644 index 6bf81604c..000000000 --- a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/CSHandler.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../src/shared/core/CSHandler.h" diff --git a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/CombatEngine.h b/src/game/server/application/SwgGameServer/include/public/SwgGameServer/CombatEngine.h deleted file mode 100644 index 5b002800d..000000000 --- a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/CombatEngine.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../src/shared/combat/CombatEngine.h" diff --git a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/ConfigCombatEngine.h b/src/game/server/application/SwgGameServer/include/public/SwgGameServer/ConfigCombatEngine.h deleted file mode 100644 index 76a8e8d6d..000000000 --- a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/ConfigCombatEngine.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../src/shared/combat/ConfigCombatEngine.h" diff --git a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/ConsoleCommandParserCombatEngine.h b/src/game/server/application/SwgGameServer/include/public/SwgGameServer/ConsoleCommandParserCombatEngine.h deleted file mode 100644 index c960efd41..000000000 --- a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/ConsoleCommandParserCombatEngine.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../src/shared/console/ConsoleCommandParserCombatEngine.h" diff --git a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/ConsoleCommandParserCombatEngineQueue.h b/src/game/server/application/SwgGameServer/include/public/SwgGameServer/ConsoleCommandParserCombatEngineQueue.h deleted file mode 100644 index 3a9f078bd..000000000 --- a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/ConsoleCommandParserCombatEngineQueue.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../src/shared/console/ConsoleCommandParserCombatEngineQueue.h" diff --git a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/FirstSwgGameServer.h b/src/game/server/application/SwgGameServer/include/public/SwgGameServer/FirstSwgGameServer.h deleted file mode 100644 index a74eb34f0..000000000 --- a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/FirstSwgGameServer.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../src/shared/core/FirstSwgGameServer.h" diff --git a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/JediManagerController.h b/src/game/server/application/SwgGameServer/include/public/SwgGameServer/JediManagerController.h deleted file mode 100644 index 484732f75..000000000 --- a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/JediManagerController.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../src/shared/controller/JediManagerController.h" diff --git a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/JediManagerObject.h b/src/game/server/application/SwgGameServer/include/public/SwgGameServer/JediManagerObject.h deleted file mode 100644 index 6df75c479..000000000 --- a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/JediManagerObject.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../src/shared/object/JediManagerObject.h" diff --git a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/ServerJediManagerObjectTemplate.h b/src/game/server/application/SwgGameServer/include/public/SwgGameServer/ServerJediManagerObjectTemplate.h deleted file mode 100644 index 11a37d7d7..000000000 --- a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/ServerJediManagerObjectTemplate.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../src/shared/objectTemplate/ServerJediManagerObjectTemplate.h" diff --git a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/SwgCreatureObject.h b/src/game/server/application/SwgGameServer/include/public/SwgGameServer/SwgCreatureObject.h deleted file mode 100644 index 01ffb8e3c..000000000 --- a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/SwgCreatureObject.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../src/shared/object/SwgCreatureObject.h" diff --git a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/SwgGameServer.h b/src/game/server/application/SwgGameServer/include/public/SwgGameServer/SwgGameServer.h deleted file mode 100644 index 117487ffa..000000000 --- a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/SwgGameServer.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../src/shared/core/SwgGameServer.h" diff --git a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/SwgPlayerCreatureController.h b/src/game/server/application/SwgGameServer/include/public/SwgGameServer/SwgPlayerCreatureController.h deleted file mode 100644 index eadbbe2c3..000000000 --- a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/SwgPlayerCreatureController.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../src/shared/controller/SwgPlayerCreatureController.h" diff --git a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/SwgPlayerObject.h b/src/game/server/application/SwgGameServer/include/public/SwgGameServer/SwgPlayerObject.h deleted file mode 100644 index b829af65e..000000000 --- a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/SwgPlayerObject.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../src/shared/object/SwgPlayerObject.h" diff --git a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/SwgServerCreatureObjectTemplate.h b/src/game/server/application/SwgGameServer/include/public/SwgGameServer/SwgServerCreatureObjectTemplate.h deleted file mode 100644 index f65a64853..000000000 --- a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/SwgServerCreatureObjectTemplate.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../src/shared/objectTemplate/SwgServerCreatureObjectTemplate.h" diff --git a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/SwgServerPlayerObjectTemplate.h b/src/game/server/application/SwgGameServer/include/public/SwgGameServer/SwgServerPlayerObjectTemplate.h deleted file mode 100644 index f5e6eb27c..000000000 --- a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/SwgServerPlayerObjectTemplate.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../src/shared/objectTemplate/SwgServerPlayerObjectTemplate.h" diff --git a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/SwgServerUniverse.h b/src/game/server/application/SwgGameServer/include/public/SwgGameServer/SwgServerUniverse.h deleted file mode 100644 index f62506fd1..000000000 --- a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/SwgServerUniverse.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../src/shared/core/SwgServerUniverse.h" diff --git a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/WorldSnapshotParser.h b/src/game/server/application/SwgGameServer/include/public/SwgGameServer/WorldSnapshotParser.h deleted file mode 100644 index 1e973f479..000000000 --- a/src/game/server/application/SwgGameServer/include/public/SwgGameServer/WorldSnapshotParser.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../src/shared/snapshot/WorldSnapshotParser.h" diff --git a/src/game/server/application/SwgGameServer/project.lnt b/src/game/server/application/SwgGameServer/project.lnt deleted file mode 100644 index 6c97b54bb..000000000 --- a/src/game/server/application/SwgGameServer/project.lnt +++ /dev/null @@ -1,59 +0,0 @@ --i../../../../external/3rd/library/stlport453/stlport --i../../../../external/ours/library/unicode/include --i../../../../external/ours/library/localization/include/ --i../../../../external/ours/library/unicodeArchive/include --i../../../../engine/shared/library/sharedDebug/include/public --i../../../../engine/shared/library/sharedFile/include/public --i../../../../engine/shared/library/sharedFoundation/include/public --i../../../../engine/shared/library/sharedFoundationTypes/include/public --i../../../../engine/shared/library/sharedIoWin/include/public --i../../../../engine/shared/library/sharedMath/include/public --i../../../../engine/shared/library/sharedLog/include/public --i../../../../engine/shared/library/sharedMathArchive/include/public --i../../../../engine/shared/library/sharedMemoryManager/include/public --i../../../../engine/shared/library/sharedRandom/include/public --i../../../../engine/shared/library/sharedStatusWindow/include/public --i../../../../engine/shared/library/sharedSynchronization/include/public --i../../../../engine/shared/library/sharedThread/include/public --i../../../../engine/shared/library/sharedMessageDispatch/include/public --i../../../../engine/shared/library/sharedTerrain/include/public --i../../../../engine/shared/library/sharedUtility/include/public --i../../../../external/ours/library/vnlv3 --i../../../../engine/shared/library/sharedNetwork/include/public --i../../../../external/ours/library/singleton/include --i../../../../engine/server/library/serverKeyShare/include/public --i../../../../engine/shared/library/sharedNetworkMessages/include/public --i../../../../engine/shared/library/sharedCommandParser/include/public --i../../../../external/ours/library/archive/include --i../../../../engine/server/library/serverUtility/include/public --i../../../../engine/server/library/serverNetworkMessages/include/public --i../../../../engine/shared/library/sharedObject/include/public --i../../../../engine/shared/library/sharedGame/include/public --i../../../../engine/shared/library/sharedImage/include/public --i../../../../engine/server/library/serverGame/include/public --i../../../shared/library/swgSharedUtility/include/public --i../../../shared/library/swgSharedNetworkMessages/include/public --i../../library/swgServerNetworkMessages/include/public --i../../../../engine/server/library/serverScript/include/public --iinclude/public/SwgGameServer --isrc/shared --isrc/shared/lint --iinclude/public --iinclude/private - -std.lnt -swg-gen.lnt -swg-stlport.lnt -swg-win.lnt - -+libdir(../../../../external/3rd/library/stl/stlport) - --elib(*) --e1736 // redundant access specifier (info) --e1075 // std::string forward declaration is causing lots of this --e1550 // Warning: 1550 - exception 'bad_alloc' thrown by function is not on throw-list of function 'CentralServerConnection::cloneConnectionCallback(void) const' (we don't handle or throw them) --e1774 // Could use dynamic_cast to downcast polymorphic type --e725 // Expected positive indentendation from line XXX --e769 // header not referenced (though included by way of a "first" header for PCH under windows) --e10 // expecting a function (no idea why this happens, looks like macros included from standard C libs) --e641 // Converting enum to int diff --git a/src/game/server/application/SwgGameServer/src/linux/main.cpp b/src/game/server/application/SwgGameServer/src/linux/main.cpp deleted file mode 100644 index 8c52d1116..000000000 --- a/src/game/server/application/SwgGameServer/src/linux/main.cpp +++ /dev/null @@ -1,141 +0,0 @@ -#include "FirstSwgGameServer.h" -#include "serverGame/GameServer.h" - -#include "LocalizationManager.h" -#include "serverGame/SetupServerGame.h" -#include "serverPathfinding/SetupServerPathfinding.h" -#include "serverScript/SetupScript.h" -#include "serverUtility/SetupServerUtility.h" -#include "sharedDebug/SetupSharedDebug.h" -#include "sharedFile/SetupSharedFile.h" -#include "sharedFile/TreeFile.h" -#include "sharedFoundation/ConfigFile.h" -#include "sharedFoundation/ExitChain.h" -#include "sharedFoundation/Os.h" -#include "sharedFoundation/SetupSharedFoundation.h" -#include "sharedGame/SetupSharedGame.h" -#include "sharedImage/SetupSharedImage.h" -#include "sharedLog/LogManager.h" -#include "sharedLog/SetupSharedLog.h" -#include "sharedMath/SetupSharedMath.h" -#include "sharedNetwork/NetworkHandler.h" -#include "sharedNetwork/SetupSharedNetwork.h" -#include "sharedObject/SetupSharedObject.h" -#include "sharedRandom/SetupSharedRandom.h" -#include "sharedRegex/SetupSharedRegex.h" -#include "sharedTerrain/SetupSharedTerrain.h" -#include "sharedThread/SetupSharedThread.h" -#include "sharedUtility/SetupSharedUtility.h" -#include "sharedNetworkMessages/SetupSharedNetworkMessages.h" -#include "SwgGameServer/SwgGameServer.h" -#include "SwgGameServer/WorldSnapshotParser.h" -#include "swgSharedNetworkMessages/SetupSwgSharedNetworkMessages.h" -#include "swgServerNetworkMessages/SetupSwgServerNetworkMessages.h" - - -// ====================================================================== - -int main(int argc, char ** argv) -{ - SetupSharedThread::install(); - SetupSharedDebug::install(1024); - - //-- setup foundation - SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game); - setupFoundationData.lpCmdLine = ConvertCommandLine(argc,argv); - setupFoundationData.runInBackground = true; - SetupSharedFoundation::install (setupFoundationData); - - SetupServerUtility::install(); - - SetupSharedRegex::install(); - - SetupSharedFile::install(false); - SetupSharedMath::install(); - - SetupSharedNetwork::SetupData networkSetupData; - SetupSharedNetwork::getDefaultServerSetupData(networkSetupData); - SetupSharedNetwork::install(networkSetupData); - - SetupSharedUtility::Data setupUtilityData; - SetupSharedUtility::setupGameData (setupUtilityData); - SetupSharedUtility::install (setupUtilityData); - - SetupSharedNetworkMessages::install(); - SetupSwgSharedNetworkMessages::install(); - SetupSwgServerNetworkMessages::install(); - - SetupSharedRandom::install(time(0));//lint !e732 - { - SetupSharedObject::Data data; - SetupSharedObject::setupDefaultGameData(data); - // we want the SlotIdManager initialized, but we don't need the associated hardpoint names on the server. - SetupSharedObject::addSlotIdManagerData(data, false); - // we want movement table information on this server - SetupSharedObject::addMovementTableData(data); - // we want CustomizationData support on this server. - SetupSharedObject::addCustomizationSupportData(data); - // we want POB ejection point override support. - SetupSharedObject::addPobEjectionTransformData(data); - // objects should not automatically alter their children and contents - data.objectsAlterChildrenAndContents = false; - SetupSharedObject::install(data); - } - - char tmp[92]; - sprintf(tmp, "SwgGameServer:%d", Os::getProcessId()); - SetupSharedLog::install(tmp); - - TreeFile::addSearchAbsolute(0); - TreeFile::addSearchPath(".",0); - - SetupSharedImage::Data setupImageData; - SetupSharedImage::setupDefaultData (setupImageData); - SetupSharedImage::install (setupImageData); - - SetupSharedGame::Data setupSharedGameData; - setupSharedGameData.setUseMountValidScaleRangeTable(true); - setupSharedGameData.setUseClientCombatManagerSupport(true); - SetupSharedGame::install (setupSharedGameData); - - SetupSharedTerrain::Data setupSharedTerrainData; - SetupSharedTerrain::setupGameData (setupSharedTerrainData); - SetupSharedTerrain::install (setupSharedTerrainData); - - SetupScript::Data setupScriptData; - SetupScript::setupDefaultGameData(setupScriptData); - SetupScript::install(); - - SetupServerPathfinding::install(); - - //-- setup game server - SetupServerGame::install(); - - NetworkHandler::install(); - Os::setProgramName("SwgGameServer"); - SwgGameServer::install(); - -#ifdef _DEBUG - //-- see if the game server is being run in a mode to parse the database dump to create planetary snapshot files - const char* const createWorldSnapshots = ConfigFile::getKeyString("WorldSnapshot", "createWorldSnapshots", 0); - if (createWorldSnapshots) - { - WorldSnapshotParser::createWorldSnapshots (createWorldSnapshots); - } - else -#endif - { - //-- run game - SetupSharedFoundation::callbackWithExceptionHandling(GameServer::run); - } - - NetworkHandler::remove(); - SetupServerGame::remove(); - - SetupSharedLog::remove(); - SetupSharedFoundation::remove(); - SetupSharedThread::remove (); - - return 0; -} - diff --git a/src/game/server/application/SwgGameServer/src/shared/combat/CombatEngine.cpp b/src/game/server/application/SwgGameServer/src/shared/combat/CombatEngine.cpp deleted file mode 100644 index 15fc34f72..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/combat/CombatEngine.cpp +++ /dev/null @@ -1,740 +0,0 @@ -//======================================================================== -// -// CombatEngine.cpp -// -// copyright 2001 Sony Online Entertainment -// -//======================================================================== - - -#include "FirstSwgGameServer.h" -#include "CombatEngine.h" - -#include "ConfigCombatEngine.h" -#include "serverGame/Client.h" -#include "serverGame/ConfigServerGame.h" //@todo code reorg, need another cfg file -#include "serverGame/ConsoleManager.h" -#include "serverGame/ContainerInterface.h" -#include "serverGame/CreatureController.h" -#include "serverGame/CreatureObject.h" -#include "serverGame/ServerObject.h" -#include "serverGame/ServerWorld.h" -#include "serverGame/TangibleObject.h" -#include "serverGame/WeaponObject.h" -#include "serverScript/GameScriptObject.h" -#include "serverScript/ScriptFunctionTable.h" -#include "serverScript/ScriptParameters.h" -#include "sharedFoundation/ConfigFile.h" -#include "sharedFoundation/ConstCharCrcLowerString.h" -#include "sharedFoundation/GameControllerMessage.h" -#include "sharedFoundation/GameControllerMessage.h" -#include "sharedFoundation/Misc.h" -#include "sharedGame/CommandTable.h" -#include "sharedGame/GameObjectTypes.h" -#include "sharedGame/SharedObjectTemplate.h" -#include "sharedNetworkMessages/MessageQueueGenericValueType.h" -#include "sharedNetworkMessages/MessageQueueNetworkId.h" -#include "sharedTerrain/TerrainObject.h" -#include "swgServerNetworkMessages/MessageQueueCombatDamageList.h" -#include "swgServerNetworkMessages/MessageQueueDirectDamage.h" -#include "swgSharedNetworkMessages/CombatActionCompleteMessage.h" -#include "swgSharedNetworkMessages/MessageQueueCombatAction.h" -#include "swgSharedNetworkMessages/MessageQueueCombatDamage.h" - -#include - -static const std::string UNSKILLED_COMMAND("unskilled"); -static const ConstCharCrcLowerString COMBAT_TARGET_COMMAND("combattarget"); -static const ConstCharCrcLowerString AIM_COMMAND("aim"); -static const ConstCharCrcLowerString DEFAULT_ATTACK_COMMAND("defaultattack"); - - -//------------------------------------------------------------------------ -// static class variables - -uint16 CombatEngine::ms_nextActionId = 0; - - -//------------------------------------------------------------------------ -// class functions - -/** - * Initializes the combat engine. - */ -void CombatEngine::install(void) -{ - ConfigCombatEngine::install(); - - // set up command queue combat functions - CommandTable::addCppFunction("aim", aim); - - ExitChain::add(CombatEngine::remove, "CombatEngine::remove"); -} // CombatEngine::install - -/** - * Cleans up the combat engine. - */ -void CombatEngine::remove(void) -{ - ConfigCombatEngine::remove(); -} // CombatEngine::remove - -/** - * Reloads the combat data values from the combat config file. - * - * @return true on success, false on fail - */ -bool CombatEngine::reloadCombatData(void) -{ - // @todo: can we synchronize this between servers? - ConfigCombatEngine::remove(); - ConfigCombatEngine::install(); - return true; -} // CombatEngine::reloadCombatData - -/** - * Adds an aim to an attacker's next attack. - * - * @param actor the attacker - */ -void CombatEngine::aim(const Command &, const NetworkId & actor, const NetworkId &, const Unicode::String &) -{ - CachedNetworkId attackerId(actor); - TangibleObject * attacker = dynamic_cast(attackerId.getObject()); - - if (attacker != NULL) - { - attacker->addAim(); - } -} // CombatEngine::aim - -/** - * Adds a target action to the end of an object's action queue. - * - * @param attacker the object attacking - * @param targets who is being targeted - * - * @return true on success, false on fail - */ -bool CombatEngine::addTargetAction(TangibleObject & attacker, - const CombatEngineData::TargetIdList & targets) -{ - // @todo: support tangible attacks - CreatureObject * const creatureAttacker = attacker.asCreatureObject (); - if (creatureAttacker == NULL) - { - WARNING_STRICT_FATAL(true, ("Tangible attackers not supported yet")); - return false; - } - - creatureAttacker->commandQueueEnqueue(CommandTable::getCommand( - COMBAT_TARGET_COMMAND.getCrc()), targets[0], Unicode::String()); - return true; -} // CombatEngine::addTargetAction - -/** - * Adds an attack action to the end of an object's action queue. - * - * @param attacker the object attacking - * @param weapon the weapon being used (0 = attacker's primary weapon) - * @param weaponMode the mode of the weapon being used (0 = primary, -1 = current mode) - * - * @return true on success, false on fail - */ -bool CombatEngine::addAttackAction(TangibleObject & attacker, - const NetworkId & weapon, int weaponMode) -{ - // @todo: support tangible attacks - CreatureObject * const creatureAttacker = attacker.asCreatureObject (); - if (creatureAttacker == NULL) - { - WARNING_STRICT_FATAL(true, ("Tangible attackers not supported yet")); - return false; - } - - // set up the weapon id and mode into a params string - char buffer[64]; - sprintf(buffer, "%s %d", weapon.getValueString().c_str(), weaponMode); - Unicode::String params(Unicode::narrowToWide(buffer)); - - creatureAttacker->commandQueueEnqueue(CommandTable::getCommand( - DEFAULT_ATTACK_COMMAND.getCrc()), NetworkId::cms_invalid, params); - return true; -} // CombatEngine::addAttackAction - -/** - * Adds an aim action to the end of an object's action queue. - * - * @param attacker the object attacking - * - * @return true on success, false on fail - */ -bool CombatEngine::addAimAction(TangibleObject & attacker) -{ - if (!attacker.isInCombat()) - return false; - - // @todo: support tangible attacks - CreatureObject * const creatureAttacker = attacker.asCreatureObject (); - if (creatureAttacker == NULL) - { - WARNING_STRICT_FATAL(true, ("Tangible attackers not supported yet")); - return false; - } - - creatureAttacker->commandQueueEnqueue(CommandTable::getCommand( - AIM_COMMAND.getCrc()), NetworkId::cms_invalid, Unicode::String()); - return true; -} // CombatEngine::addAimAction - -/** - * Determines the specific damage to apply to the defender after a successful - * attack. - * - * @param attacker the attacker - * @param defender the defender - * @param weapon the attacker's weapon - * @param damageAmount base damage done - * @param hitLocation where the defender was hit - * - * @return true on success, false if there was an error - */ -bool CombatEngine::onSuccessfulAttack(const TangibleObject & attacker, - TangibleObject & defender, const WeaponObject & weapon, int damageAmount, - int hitLocation) -{ - const bool creatureDefender = defender.asCreatureObject() != NULL; - const bool isVehicle = GameObjectTypes::isTypeOf (defender.getGameObjectType (), SharedObjectTemplate::GOT_vehicle); - - // if attacking an object, always hit location 0 - if (!creatureDefender || isVehicle) - hitLocation = 0; - - // get the damage profile for the hit location - const ConfigCombatEngine::SkeletonAttackMod & skeletonAttackMod = - ConfigCombatEngine::getSkeletonAttackMod(static_cast(defender.getCombatSkeleton())); - if (hitLocation < 0 || hitLocation >= static_cast(skeletonAttackMod.attackMods.size())) - return false; - const ConfigCombatEngineData::BodyAttackMod & hitLocationData = - skeletonAttackMod.attackMods[static_cast(hitLocation)]; - - // put a attribMod structure on the defender's damage list for each type of - // damage received - DamageList damageList; - if (creatureDefender && !isVehicle) - { - computeCreatureDamage(&hitLocationData, damageAmount, damageList); - } - else - { - computeObjectDamage(&hitLocationData, damageAmount, damageList); - } - if (damageList.empty()) - return false; - - // determine if the defender was wounded - bool isWounded = false; - - if (creatureDefender && !isVehicle) - { - float woundChance = weapon.getWoundChance() + ConfigCombatEngine::getWoundChance(); - if (hitLocation) - woundChance += hitLocationData.toWoundBonus; - if (Random::randomReal(0.0f, 100.0f) <= woundChance) - isWounded = true; - } - - // apply the damage - if (defender.isAuthoritative()) - { - // Ensure the combat data has been initialized - defender.createCombatData(); - - CombatEngineData::DefenseData & defenseData = defender.getCombatData()->defenseData; - defenseData.damage.push_back(CombatEngineData::DamageData()); - CombatEngineData::DamageData &damageData = defenseData.damage.back(); - damageData.attackerId = attacker.getNetworkId(); - damageData.weaponId = weapon.getNetworkId(); - damageData.damageType = static_cast(static_cast(weapon.getDamageType())); - damageData.hitLocationIndex = static_cast(hitLocation); - damageData.damage.insert(damageData.damage.end(), damageList.begin(), damageList.end()); - damageData.wounded = isWounded; - } - else - { - TangibleController * const tangibleController = (defender.getController() != NULL) ? defender.getController()->asTangibleController() : NULL; - - if (tangibleController == NULL) - { - WARNING_STRICT_FATAL(true, ("CombatEngine::onSuccessfulAttack non-auth " - "defender %s doesn't have a TangibleController!", - defender.getNetworkId().getValueString().c_str())); - return false; - } - - // send the damage info to the authoritative object - MessageQueueCombatDamageList * message = new MessageQueueCombatDamageList(); - NOT_NULL(message); - CombatEngineData::DamageData & damageData = message->addDamage(); - - damageData.attackerId = attacker.getNetworkId(); - damageData.weaponId = weapon.getNetworkId(); - damageData.damageType = static_cast(static_cast(weapon.getDamageType())); - damageData.hitLocationIndex = static_cast(hitLocation); - damageData.damage.insert(damageData.damage.end(), damageList.begin(), damageList.end()); - damageData.wounded = isWounded; - - tangibleController->appendMessage( - CM_combatDamageList, - 0.0f, - message, - GameControllerMessageFlags::SEND | - GameControllerMessageFlags::RELIABLE | - GameControllerMessageFlags::DEST_AUTH_SERVER - ); - }//lint !e429 // Custodial pointer 'message' has not been freed or returned // the controller queue will manage freeing the memory - - return true; -} // CombatEngine::onSuccessfulAttack - -/** - * Determines the specific damage to apply to the defender after a successful - * attack. - * - * @param attacker the attacker - * @param defender the defender - * @param damageAmount base damage done - * @param hitLocation where the defender was hit - * - * @return true on success, false if there was an error - */ -bool CombatEngine::onSuccessfulAttack(const TangibleObject & attacker, - TangibleObject & defender, int damageAmount, - int hitLocation) -{ - const bool creatureDefender = defender.asCreatureObject() != NULL; - const bool isVehicle = GameObjectTypes::isTypeOf (defender.getGameObjectType (), SharedObjectTemplate::GOT_vehicle); - - // if attacking an object, always hit location 0 - if (!creatureDefender || isVehicle) - hitLocation = 0; - - // get the damage profile for the hit location - const ConfigCombatEngine::SkeletonAttackMod & skeletonAttackMod = - ConfigCombatEngine::getSkeletonAttackMod(static_cast(defender.getCombatSkeleton())); - if (hitLocation < 0 || hitLocation >= static_cast(skeletonAttackMod.attackMods.size())) - return false; - const ConfigCombatEngineData::BodyAttackMod & hitLocationData = - skeletonAttackMod.attackMods[static_cast(hitLocation)]; - - // put a attribMod structure on the defender's damage list for each type of - // damage received - DamageList damageList; - if (creatureDefender && !isVehicle) - { - computeCreatureDamage(&hitLocationData, damageAmount, damageList); - } - else - { - computeObjectDamage(&hitLocationData, damageAmount, damageList); - } - if (damageList.empty()) - return false; - - // determine if the defender was wounded - bool isWounded = false; - - // apply the damage - if (defender.isAuthoritative()) - { - // Ensure the combat data has been initialized - defender.createCombatData(); - - CombatEngineData::DefenseData & defenseData = defender.getCombatData()->defenseData; - defenseData.damage.push_back(CombatEngineData::DamageData()); - CombatEngineData::DamageData &damageData = defenseData.damage.back(); - damageData.attackerId = attacker.getNetworkId(); - damageData.hitLocationIndex = static_cast(hitLocation); - damageData.damage.insert(damageData.damage.end(), damageList.begin(), damageList.end()); - damageData.wounded = isWounded; - } - else - { - TangibleController * const tangibleController = (defender.getController() != NULL) ? defender.getController()->asTangibleController() : NULL; - - if (tangibleController == NULL) - { - WARNING_STRICT_FATAL(true, ("CombatEngine::onSuccessfulAttack non-auth " - "defender %s doesn't have a TangibleController!", - defender.getNetworkId().getValueString().c_str())); - return false; - } - - // send the damage info to the authoritative object - MessageQueueCombatDamageList * message = new MessageQueueCombatDamageList(); - NOT_NULL(message); - CombatEngineData::DamageData & damageData = message->addDamage(); - - damageData.attackerId = attacker.getNetworkId(); - damageData.hitLocationIndex = static_cast(hitLocation); - damageData.damage.insert(damageData.damage.end(), damageList.begin(), damageList.end()); - damageData.wounded = isWounded; - - tangibleController->appendMessage( - CM_combatDamageList, - 0.0f, - message, - GameControllerMessageFlags::SEND | - GameControllerMessageFlags::RELIABLE | - GameControllerMessageFlags::DEST_AUTH_SERVER - ); - }//lint !e429 // Custodial pointer 'message' has not been freed or returned // the controller queue will manage freeing the memory - - return true; -} // CombatEngine::onSuccessfulAttack - -/** - * Damages an object. This damage is immediately applied to the object, outside - * the combat loop. - * - * @param defender the defender - * @param weapon the weapon the defender is hit by - * @param damageAmount base damage done - * @param hitLocation where the defender was hit - * - * @return true on success, false if there was an error - */ -bool CombatEngine::damage(TangibleObject & defender, const WeaponObject & weapon, - int damageAmount, int hitLocation) -{ - if (defender.isAuthoritative()) - { - CreatureObject * const critter = defender.asCreatureObject(); - const bool isVehicle = GameObjectTypes::isTypeOf (defender.getGameObjectType (), SharedObjectTemplate::GOT_vehicle); - - // if attacking an object, always hit location 0 - if (critter == NULL || isVehicle) - hitLocation = 0; - - // get the damage profile for the hit location - const ConfigCombatEngine::SkeletonAttackMod & skeletonAttackMod = - ConfigCombatEngine::getSkeletonAttackMod(static_cast(defender.getCombatSkeleton())); - if (hitLocation < 0 || hitLocation >= static_cast(skeletonAttackMod.attackMods.size())) - return false; - const ConfigCombatEngineData::BodyAttackMod & hitLocationData = - skeletonAttackMod.attackMods[static_cast(hitLocation)]; - - // put a attribMod structure on the defender's damage list for each type of - // damage received - DamageList damageList; - if (critter != NULL && !isVehicle) - { - computeCreatureDamage(&hitLocationData, damageAmount, damageList); - } - else - { - computeObjectDamage(&hitLocationData, damageAmount, damageList); - } - if (damageList.empty()) - return false; - - // determine if the defender was wounded - bool isWounded = false; - if (critter && !isVehicle) - { - float woundChance = weapon.getWoundChance() + ConfigCombatEngine::getWoundChance(); - if (hitLocation) - woundChance += hitLocationData.toWoundBonus; - if (Random::randomReal(0.0f, 100.0f) <= woundChance) - isWounded = true; - } - - // apply the damage - CombatEngineData::DamageData damageData; - damageData.attackerId = NetworkId::cms_invalid; - damageData.weaponId = weapon.getNetworkId(); - damageData.damageType = static_cast(static_cast(weapon.getDamageType())); - damageData.hitLocationIndex = static_cast(hitLocation); - damageData.damage.insert(damageData.damage.end(), damageList.begin(), damageList.end()); - damageData.wounded = isWounded; - - if (critter != NULL || !defender.isDisabled()) - { - // update the object's hit points or attributes for the damage - defender.applyDamage(damageData); - } - } - - return true; -} // CombatEngine::damage - -/** - * Damages an object. This damage is immediately applied to the object, outside - * the combat loop. - * - * @param defender the object to be damaged - * @param damageType the type of damage being done - * @param hitLocation the hit location of the damage - * @param damage the amount of damage to do - */ -void CombatEngine::damage(TangibleObject & defender, - ServerWeaponObjectTemplate::DamageType damageType, uint16 hitLocation, - int damageDone) -{ - if (defender.isAuthoritative()) - { - CreatureObject *critter = defender.asCreatureObject(); - const bool isVehicle = GameObjectTypes::isTypeOf (defender.getGameObjectType (), SharedObjectTemplate::GOT_vehicle); - - // if attacking an object, always hit location 0 - if (critter == NULL || isVehicle) - hitLocation = 0; - - // get the damage profile for the hit location - const ConfigCombatEngine::SkeletonAttackMod & skeletonAttackMod = - ConfigCombatEngine::getSkeletonAttackMod(static_cast(defender.getCombatSkeleton())); - if (hitLocation >= static_cast(skeletonAttackMod.attackMods.size())) - return; - const ConfigCombatEngineData::BodyAttackMod & hitLocationData = - skeletonAttackMod.attackMods[static_cast(hitLocation)]; - - // get the damage - DamageList damageList; - if (critter && !isVehicle) - CombatEngine::computeCreatureDamage(&hitLocationData, damageDone, damageList); - else - CombatEngine::computeObjectDamage(&hitLocationData, damageDone, damageList); - - if (damageList.empty()) - return; - - // apply the damage - CombatEngineData::DamageData damageData; - damageData.attackerId = NetworkId::cms_invalid; - damageData.weaponId = NetworkId::cms_invalid; - damageData.damageType = static_cast(static_cast(damageType)); - damageData.hitLocationIndex = hitLocation; - damageData.damage.insert(damageData.damage.end(), damageList.begin(), damageList.end()); - - if (critter != NULL || !defender.isDisabled()) - { - // update the object's hit points or attributes for the damage - defender.applyDamage(damageData); - } - } - else - { - defender.sendControllerMessageToAuthServer(CM_directDamage, - new MessageQueueDirectDamage(damageType, hitLocation, damageDone)); - } -} // CombatEngine::damage - -/** - * Damages all objects within a given area. - * - * @param center the center of the area to damage - * @param radius the radius of the area to damage - * @param damageType the type of damage being done - * @param damage the amount of damage to do - */ -void CombatEngine::damage(const Vector ¢er, float radius, - ServerWeaponObjectTemplate::DamageType damageType, int damageDone) -{ - // determine the damage that will occur to creatures and non-creatures - DamageList creatureDamageList, objectDamageList; - computeCreatureDamage(0, damageDone, creatureDamageList); - computeObjectDamage(0, damageDone, objectDamageList); - if (creatureDamageList.empty() && objectDamageList.empty()) - return; - - // get everything in the damage area - std::vector targetList; - ServerWorld::findObjectsInRange(center, radius, targetList); - if (targetList.empty()) - return; - - std::vector::iterator iter; - for (iter = targetList.begin(); iter != targetList.end(); ++iter) - { - ServerObject * const obj = *iter; - if (!obj) - continue; - - TangibleObject * const defender = obj->asTangibleObject (); - if (!defender) - continue; - - const bool isVehicle = GameObjectTypes::isTypeOf (defender->getGameObjectType (), SharedObjectTemplate::GOT_vehicle); - - // apply the damage - { - // Ensure the combat data has been initialized - defender->createCombatData(); - - CombatEngineData::DefenseData & defenseData = defender->getCombatData()->defenseData; - defenseData.damage.push_back(CombatEngineData::DamageData()); - CombatEngineData::DamageData &damageData = defenseData.damage.back(); - damageData.attackerId = NetworkId::cms_invalid; - damageData.weaponId = NetworkId::cms_invalid; - damageData.damageType = static_cast(static_cast(damageType)); - damageData.hitLocationIndex = 0; - - if (defender->asCreatureObject () && !isVehicle) - { - damageData.damage.insert(damageData.damage.end(), - creatureDamageList.begin(), creatureDamageList.end()); - } - else - { - damageData.damage.insert(damageData.damage.end(), - objectDamageList.begin(), objectDamageList.end()); - } - } - } -} // CombatEngine::damage - -/** - * Determines how a creature will be damaged. - * - * @param hitLocation where on the defender the damage occurred - * @param damageType the type of damage being done - * @param damage the amount of damage to do - * @param damageList list to be filled in with attribMods caused by the damage - */ -void CombatEngine::computeCreatureDamage( - const ConfigCombatEngineData::BodyAttackMod *hitLocation, - int damageDone, - DamageList & damageList) -{ - // put all damage into health - damageList.push_back(AttribMod::AttribMod()); - AttribMod::AttribMod & attribMod = damageList.back(); - attribMod.tag = 0; - attribMod.attrib = Attributes::Health; - attribMod.value = -damageDone; - attribMod.attack = 0.0f; - attribMod.sustain = 0.0f; - attribMod.decay = ServerWeaponObjectTemplate::AMDS_pool; - attribMod.flags = AttribMod::AMF_directDamage; -} // CombatEngine::computeCreatureDamage - -/** - * Determines how a non-creature will be damaged. - * - * @param hitLocation where on the defender the damage occurred - * @param damageType the type of damage being done - * @param damage the amount of damage to do - * @param damageList list to be filled in with attribMods caused by the damage - */ -void CombatEngine::computeObjectDamage( - const ConfigCombatEngineData::BodyAttackMod *hitLocation, - int damageDone, - DamageList & damageList) -{ - int actualDamage = static_cast(floor(damageDone * 1.0f + 0.5f)); //lint !e747 Significant prototype coercion (arg. no. 1) float to double - if (actualDamage == 0) - return; - - // create an attribMod structure for damage received - if (hitLocation && hitLocation->damageBonus[0] != 0) - { - if (hitLocation->damageBonus[0] > 0) - { - actualDamage += static_cast(floor(actualDamage * hitLocation-> - damageBonus[0] + 0.5f)); //lint !e747 Significant prototype coercion (arg. no. 1) float to double - } - else - { - actualDamage += static_cast(ceil(actualDamage * hitLocation-> - damageBonus[0] - 0.5f)); //lint !e747 Significant prototype coercion (arg. no. 1) float to double - } - } - damageList.push_back(AttribMod::AttribMod()); - AttribMod::AttribMod & attribMod = damageList.back(); - attribMod.tag = 0; - attribMod.attrib = ServerObjectTemplate::AT_health; - attribMod.value = -actualDamage; - attribMod.attack = 0.0f; - attribMod.sustain = 0.0f; - attribMod.decay = ServerWeaponObjectTemplate::AMDS_pool; //lint !e641 Converting enum 'AttribModDecaySpecial' to int - attribMod.flags = AttribMod::AMF_directDamage; -} // CombatEngine::computeObjectDamage - -/** - * Applies combat damage done during execute() to an object. Should be called as - * part of the object's alter function. - * - * @param object the object to damage - */ -void CombatEngine::alter(TangibleObject & object) -{ - NOT_NULL(object.getController()); - - if ( (object.getCombatData() == NULL) - || object.getCombatData()->defenseData.damage.empty()) - { - return; - } - - std::vector &damageData = object.getCombatData()->defenseData.damage; - std::vector::iterator iter; - - if (object.isAuthoritative()) - { - // if the object is a creature, get it's attributes - Attributes::Value currentAttribs[Attributes::NumberOfAttributes]; - CreatureObject * const critter = object.asCreatureObject (); - if (critter != NULL) - { - for (int i = 0; i < Attributes::NumberOfAttributes; ++i) - currentAttribs[i] = critter->getAttribute(i); - } - else - { - // @todo: handle damage to objects - } - // update the object - // to guard against the list changing while we are iterating over it, - // we will iterate using index rather than iterator - for (std::vector::size_type i = 0; object.isInCombat() && i < damageData.size(); ++i) - { - // since armor == hp now, we need to double check that the object - // is in combat, since a non-creature could be removed by just - // damaging their armor - if (object.isInCombat()) - { - // update the object's hit points or attributes for the damage - object.applyDamage(damageData[i]); - } - } - }//lint !e550 Symbol 'currentAttribs' (line 2653) not accessed // yes it is - else - { - TangibleController * const tangibleController = object.getController()->asTangibleController(); - - if (tangibleController == NULL) - { - WARNING_STRICT_FATAL(true, ("CombatEngine::alter non-auth " - "object %s doesn't have a TangibleController!", - object.getNetworkId().getValueString().c_str())); - return; - } - - // send the damage info to the authoritative object - MessageQueueCombatDamageList * message = new MessageQueueCombatDamageList(); - NOT_NULL(message); - for (iter = damageData.begin(); iter != damageData.end(); ++iter) - message->addDamage(*iter); - tangibleController->appendMessage( - CM_combatDamageList, - 0.0f, - message, - GameControllerMessageFlags::SEND | - GameControllerMessageFlags::RELIABLE | - GameControllerMessageFlags::DEST_AUTH_SERVER - ); - }//lint !e429 Custodial pointer 'message' has not been freed or returned // Controller handles message destruction - - object.clearDamageList(); -} // CombatEngine::alter - diff --git a/src/game/server/application/SwgGameServer/src/shared/combat/CombatEngine.h b/src/game/server/application/SwgGameServer/src/shared/combat/CombatEngine.h deleted file mode 100644 index 5748254a2..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/combat/CombatEngine.h +++ /dev/null @@ -1,74 +0,0 @@ -//======================================================================== -// -// CombatEngine.h -// -// copyright 2001 Sony Online Entertainment -// -//======================================================================== - - -#ifndef _INCLUDED_CombatEngine_H -#define _INCLUDED_CombatEngine_H - -#include "sharedGame/AttribMod.h" -#include "sharedObject/CachedNetworkId.h" -#include "serverGame/ServerWeaponObjectTemplate.h" -#include "swgSharedUtility/CombatEngineData.h" -#include - -class Command; -class CreatureObject; - - -//------------------------------------------------------------------- -// class CombatEngine - -class CombatEngine -{ -public: - typedef std::vector DamageList; - -public: - - static void install(void); - static void remove(void); - - static bool reloadCombatData(void); - - // command queue hooks - static void aim(const Command & command, const NetworkId & actor, - const NetworkId & target, const Unicode::String & params); - - // queue actions - static bool addTargetAction(TangibleObject & attacker, const CombatEngineData::TargetIdList & targets); - static bool addAttackAction(TangibleObject & attacker, const NetworkId & weapon, int weaponMode); - static bool addAimAction(TangibleObject & attacker); - - static bool onSuccessfulAttack(const TangibleObject & attacker, TangibleObject & defender, const WeaponObject & weapon, int damage, int hitLocation); - static bool onSuccessfulAttack(const TangibleObject & attacker, TangibleObject & defender, int damage, int hitLocation); - static bool damage(TangibleObject & defender, const WeaponObject & weapon, int damageAmount, int hitLocation); - static void damage(TangibleObject & defender, ServerWeaponObjectTemplate::DamageType damageType, uint16 hitLocation, int damage); - static void damage(const Vector ¢er, float radius, ServerWeaponObjectTemplate::DamageType damageType, int damage); - static void alter(TangibleObject & object); - -private: - - static uint16 ms_nextActionId; // id to link attack messages with damage messages - static uint16 getNextActionId(void); - - static void computeCreatureDamage( - const ConfigCombatEngineData::BodyAttackMod *hitLocation, - int damage, DamageList & damageList); - static void computeObjectDamage( - const ConfigCombatEngineData::BodyAttackMod *hitLocation, - int damage, DamageList & damageList); -}; - - -inline uint16 CombatEngine::getNextActionId(void) -{ - return ++ms_nextActionId; -} - - -#endif // _INCLUDED_CombatEngine_H diff --git a/src/game/server/application/SwgGameServer/src/shared/combat/ConfigCombatEngine.cpp b/src/game/server/application/SwgGameServer/src/shared/combat/ConfigCombatEngine.cpp deleted file mode 100644 index 8b42da06d..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/combat/ConfigCombatEngine.cpp +++ /dev/null @@ -1,279 +0,0 @@ -//======================================================================== -// -// ConfigCombatEngine.h -// -// copyright 2001 Sony Online Entertainment -// -//======================================================================== - -#include "FirstSwgGameServer.h" -#include "ConfigCombatEngine.h" -#include "sharedFile/TreeFile.h" -#include "sharedFoundation/ConfigFile.h" -#include "sharedFoundation/CrcLowerString.h" -#include "swgSharedUtility/CombatEngineData.h" - -#include -#include "combat.def" - - -#define KEY_INT(a,b) (m_data.a = ConfigFile::getKeyInt("CombatEngine", #a, b)) - - -//------------------------------------------------------------------- -// local statics - -namespace ConfigCombatEngineNameSpace -{ - typedef std::map BoneMap; - BoneMap ms_boneMap; -} - -//------------------------------------------------------------------- - -using namespace ConfigCombatEngineNameSpace; - - -//------------------------------------------------------------------- -// static member variables - -ConfigCombatEngine::Data ConfigCombatEngine::m_data; -float ConfigCombatEngine::m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorHeavy+1][ServerArmorTemplate::AR_armorHeavy+1]; - -void ConfigCombatEngine::install(void) -{ - static const std::string CONFIG_FILE("abstract/combat/combat_consts.iff"); - Iff file; - - ms_boneMap.insert(BoneMap::value_type(CrcLowerString("CSB_body"), static_cast(CSB_body))); - ms_boneMap.insert(BoneMap::value_type(CrcLowerString("CSB_head"), static_cast(CSB_head))); - ms_boneMap.insert(BoneMap::value_type(CrcLowerString("CSB_rightArm"), static_cast(CSB_rightArm))); - ms_boneMap.insert(BoneMap::value_type(CrcLowerString("CSB_leftArm"), static_cast(CSB_leftArm))); - ms_boneMap.insert(BoneMap::value_type(CrcLowerString("CSB_rightLeg"), static_cast(CSB_rightLeg))); - ms_boneMap.insert(BoneMap::value_type(CrcLowerString("CSB_leftLeg"), static_cast(CSB_leftLeg))); - - installFromConfigFile(); - - if (!TreeFile::exists(CONFIG_FILE.c_str())) - return; - if (!file.open(CONFIG_FILE.c_str(), true)) - return; - - Tag type = file.getCurrentName(); - if (type != TAG(C,O,M,C)) - return; - file.enterForm(); - Tag version = file.getCurrentName(); - - switch (version) - { - case TAG(0,0,0,0): - parseVersion0(file); - break; - default: - break; - } - - file.exitForm(); - file.close(); -} // ConfigCombatEngine::install - -/** - * Loads config info from the [CombatEngine] config file section. - */ -void ConfigCombatEngine::installFromConfigFile(void) -{ - KEY_INT(debugQueues, 0); - KEY_INT(debugTargeting, 0); - KEY_INT(debugAttack, 0); - KEY_INT(debugDefense, 0); - KEY_INT(debugDamage, 0); - KEY_INT(debugExplosion, 0); -} // ConfigCombatEngine::installFromConfigFile - -void ConfigCombatEngine::parseVersion0(Iff & file) -{ -std::string paramName, tempString; -ConfigCombatEngineData::BodyAttackMod bodyAttackMod; -ConfigCombatEngine::SkeletonAttackMod skeletonAttackMod; - - //-- Initialize data structures. - memset(&bodyAttackMod, 0, sizeof(bodyAttackMod)); - memset(&skeletonAttackMod, 0, sizeof(skeletonAttackMod)); - - file.enterForm(); - - for (;;) - { - if (file.atEndOfForm()) - break; - - file.enterChunk(); - - file.read_string(paramName); - if (paramName == "maxAims") - { - m_data.maxAims = file.read_uint8(); - } - else if (paramName == "kineticObjectDamage") - { - m_data.kineticObjectDamage = static_cast(file.read_uint8()) / 100.0f; - } - else if (paramName == "energyObjectDamage") - { - m_data.energyObjectDamage = static_cast(file.read_uint8()) / 100.0f; - } - else if (paramName == "blastObjectDamage") - { - m_data.blastObjectDamage = static_cast(file.read_uint8()) / 100.0f; - } - else if (paramName == "stunObjectDamage") - { - m_data.stunObjectDamage = static_cast(file.read_uint8()) / 100.0f; - } - else if (paramName == "restraintObjectDamage") - { - m_data.restraintObjectDamage = static_cast(file.read_uint8()) / 100.0f; - } - else if (paramName == "elementalObjectDamage") - { - m_data.elementalObjectDamage = static_cast(file.read_uint8()) / 100.0f; - } - else if (paramName == "weaponLowerThanArmorRating") - { - m_data.weaponLowerThanArmorRating = static_cast(file.read_uint8()) / 100.0f; - } - else if (paramName == "weaponHigherThanArmorRating") - { - m_data.weaponHigherThanArmorRating = static_cast(file.read_uint8()) / 100.0f; - } - else if (paramName == "woundChance") - { - m_data.woundChance = static_cast(file.read_uint8()) / 100.0f; - } - else if (paramName == "woundPercent") - { - m_data.woundPercent = static_cast(file.read_uint8()) / 100.0f; - } - else if (paramName == "shockWoundPercent") - { - m_data.shockWoundPercent = static_cast(file.read_uint8()) / 100.0f; - } - else if (paramName == "numberSkeletons") - { - m_data.numberSkeletons = file.read_uint8() + 1; - // set up all-body skeleton - bodyAttackMod.name = ""; - bodyAttackMod.modelBoneName = ""; - bodyAttackMod.toHitChance = 100; - bodyAttackMod.toWoundBonus = 0; - bodyAttackMod.combatSkeletonBone = 0; - bodyAttackMod.damageBonus[Attributes::Health] = 0; - bodyAttackMod.damageBonus[Attributes::Action] = 0; - bodyAttackMod.damageBonus[Attributes::Mind] = 0; - skeletonAttackMod.name = ""; - skeletonAttackMod.numHitLocations = 1; - skeletonAttackMod.script = ""; - skeletonAttackMod.attackMods.clear(); - skeletonAttackMod.attackMods.push_back(bodyAttackMod); - m_data.skeletonAttackMods.push_back(skeletonAttackMod); - } - else if (paramName == "skeletonAttackMod") - { - skeletonAttackMod.attackMods.clear(); - size_t skeletonIndex = file.read_uint8() + 1; - while (m_data.skeletonAttackMods.size() <= skeletonIndex) - m_data.skeletonAttackMods.push_back(skeletonAttackMod); - ConfigCombatEngine::SkeletonAttackMod & skeleton = m_data.skeletonAttackMods[skeletonIndex]; - file.read_string(tempString); - skeleton.name = tempString; - skeleton.numHitLocations = file.read_uint8(); - file.read_string(tempString); - skeleton.script = tempString; - } - else if (paramName == "skeletonAttackLoc") - { - size_t skeletonIndex = file.read_uint8() + 1; - size_t locIndex = file.read_uint8(); - while (m_data.skeletonAttackMods.size() <= skeletonIndex) - m_data.skeletonAttackMods.push_back(skeletonAttackMod); - ConfigCombatEngine::SkeletonAttackMod & skeleton = m_data.skeletonAttackMods[skeletonIndex]; - while (skeleton.attackMods.size() <= locIndex) - skeleton.attackMods.push_back(bodyAttackMod); - ConfigCombatEngineData::BodyAttackMod & bodyLoc = skeleton.attackMods[locIndex]; - file.read_string(tempString); - bodyLoc.name = tempString; - file.read_string(tempString); - bodyLoc.modelBoneName = tempString; - bodyLoc.toHitChance = file.read_uint8(); - bodyLoc.toWoundBonus = static_cast(file.read_uint8()) / 100.0f; - bodyLoc.damageBonus[Attributes::Health] = static_cast(file.read_uint8()) / 100.0f; - bodyLoc.damageBonus[Attributes::Action] = static_cast(file.read_uint8()) / 100.0f; - bodyLoc.damageBonus[Attributes::Mind] = static_cast(file.read_uint8()) / 100.0f; - } - file.exitChunk(); - } - - file.exitForm(); - - setupRatingDifferenceDamageReduction(); -} // ConfigCombatEngine::parseVersion0 - -//------------------------------------------------------------------- - -void ConfigCombatEngine::remove(void) -{ - m_data.skeletonAttackMods.clear(); - ms_boneMap.clear(); -} // ConfigCombatEngine::remove - -//------------------------------------------------------------------- - -float ConfigCombatEngine::getObjectDamageSpread( - ServerWeaponObjectTemplate::DamageType damageType) -{ - switch (damageType) - { - case ServerWeaponObjectTemplate::DT_kinetic: - return m_data.kineticObjectDamage; - case ServerWeaponObjectTemplate::DT_energy: - return m_data.energyObjectDamage; - case ServerWeaponObjectTemplate::DT_blast: - return m_data.blastObjectDamage; - case ServerWeaponObjectTemplate::DT_stun: - return m_data.stunObjectDamage; - case ServerWeaponObjectTemplate::DT_restraint: - return m_data.restraintObjectDamage; - default: - break; - }//lint !e788 enum constant not used - return 1.0f; -} // ConfigCombatEngine::getObjectDamageSpread - -//------------------------------------------------------------------- - -/** - * Sets up the RatingDifferenceDamageReduction table. - */ -void ConfigCombatEngine::setupRatingDifferenceDamageReduction(void) -{ - m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorNone][ServerArmorTemplate::AR_armorNone] = 1.0f; - m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorNone][ServerArmorTemplate::AR_armorLight] = m_data.weaponLowerThanArmorRating; - m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorNone][ServerArmorTemplate::AR_armorMedium] = m_data.weaponLowerThanArmorRating * m_data.weaponLowerThanArmorRating; - m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorNone][ServerArmorTemplate::AR_armorHeavy] = m_data.weaponLowerThanArmorRating * m_data.weaponLowerThanArmorRating * m_data.weaponLowerThanArmorRating; - - m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorLight][ServerArmorTemplate::AR_armorNone] = m_data.weaponHigherThanArmorRating; - m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorLight][ServerArmorTemplate::AR_armorLight] = 1.0f; - m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorLight][ServerArmorTemplate::AR_armorMedium] = m_data.weaponLowerThanArmorRating; - m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorLight][ServerArmorTemplate::AR_armorHeavy] = m_data.weaponLowerThanArmorRating * m_data.weaponLowerThanArmorRating; - - m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorMedium][ServerArmorTemplate::AR_armorNone] = m_data.weaponHigherThanArmorRating * m_data.weaponHigherThanArmorRating; - m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorMedium][ServerArmorTemplate::AR_armorLight] = m_data.weaponHigherThanArmorRating; - m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorMedium][ServerArmorTemplate::AR_armorMedium] = 1.0f; - m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorMedium][ServerArmorTemplate::AR_armorHeavy] = m_data.weaponLowerThanArmorRating; - - m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorHeavy][ServerArmorTemplate::AR_armorNone] = m_data.weaponHigherThanArmorRating * m_data.weaponHigherThanArmorRating * m_data.weaponHigherThanArmorRating; - m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorHeavy][ServerArmorTemplate::AR_armorLight] = m_data.weaponHigherThanArmorRating * m_data.weaponHigherThanArmorRating; - m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorHeavy][ServerArmorTemplate::AR_armorMedium] = m_data.weaponHigherThanArmorRating; - m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorHeavy][ServerArmorTemplate::AR_armorHeavy] = 1.0f; -} // ConfigCombatEngine::setupRatingDifferenceDamageReduction diff --git a/src/game/server/application/SwgGameServer/src/shared/combat/ConfigCombatEngine.h b/src/game/server/application/SwgGameServer/src/shared/combat/ConfigCombatEngine.h deleted file mode 100644 index 65b63d80c..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/combat/ConfigCombatEngine.h +++ /dev/null @@ -1,229 +0,0 @@ -//======================================================================== -// -// ConfigCombatEngine.h -// -// copyright 2001 Sony Online Entertainment -// -//======================================================================== - - -#ifndef _INCLUDED_ConfigCombatEngine_H -#define _INCLUDED_ConfigCombatEngine_H - -#include "serverGame/ServerArmorTemplate.h" -#include "serverGame/ServerTangibleObjectTemplate.h" -#include "serverGame/ServerWeaponObjectTemplate.h" -#include "swgSharedUtility/CombatEngineData.h" -#include "swgSharedUtility/Attributes.def" - - -//------------------------------------------------------------------- -// namespace ConfigCombatEngineData - -namespace ConfigCombatEngineData -{ - struct BodyAttackMod - { - std::string name; - std::string modelBoneName; // name of a 3d-model bone to associate with - uint32 combatSkeletonBone; - int toHitChance; - float toWoundBonus; - float damageBonus[Attributes::NumberOfAttributes]; - }; -};//lint !e19 Useless declaration - - -//------------------------------------------------------------------- -// class ConfigCombatEngine - -class ConfigCombatEngine -{ -public: - - struct AggressionMod - { - float time; - int toHit; - }; - - struct SkeletonAttackMod - { - std::string name; - int numHitLocations; - std::string script; - std::vector attackMods; - }; - - struct Data - { - int maxAims; - int numberSkeletons; - std::vector skeletonAttackMods; - float kineticObjectDamage; - float energyObjectDamage; - float blastObjectDamage; - float stunObjectDamage; - float restraintObjectDamage; - float elementalObjectDamage; - float weaponLowerThanArmorRating; - float weaponHigherThanArmorRating; - float woundChance; - float woundPercent; - float shockWoundPercent; - int numCombatStates; - - int debugQueues; - int debugTargeting; - int debugAttack; - int debugDefense; - int debugDamage; - int debugExplosion; - }; - -public: - - static void install (void); - static void remove (void); - - static int getMaxAims(void); - static int getNumberSkeletons(void); - static const SkeletonAttackMod & getSkeletonAttackMod(ServerTangibleObjectTemplate::CombatSkeleton skeleton); - static float getKineticObjectDamage(void); - static float getEnergyObjectDamage(void); - static float getBlastObjectDamage(void); - static float getStunObjectDamage(void); - static float getRestraintObjectDamage(void); - static float getElementalObjectDamage(void); - static float getObjectDamageSpread(ServerWeaponObjectTemplate::DamageType damageType); - static float getWoundChance(void); - static float getWoundPercent(void); - static float getShockWoundPercent(void); - - static int getDebugQueues(void); - static int getDebugTargeting(void); - static int getDebugAttack(void); - static int getDebugDefense(void); - static int getDebugDamage(void); - static int getDebugExplosion(void); - -private: - - static Data m_data; -// static ConfigCombatEngineData::BodyAttackMod m_bodyAttackMod; -// static SkeletonAttackMod m_skeletonAttackMod; - static float m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::ArmorRating_Last+1][ServerArmorTemplate::ArmorRating_Last+1]; //lint !e641 converting enum to int - - static void installFromConfigFile(void); - static void parseVersion0(Iff & file); - static void setupRatingDifferenceDamageReduction(void); -}; - - -//----------------------------------------------------------------------- - -inline int ConfigCombatEngine::getMaxAims(void) -{ - return m_data.maxAims; -} // ConfigCombatEngine::getMaxAims - -inline int ConfigCombatEngine::getNumberSkeletons(void) -{ - return m_data.numberSkeletons; -} // ConfigCombatEngine::getNumberSkeletons - -inline const ConfigCombatEngine::SkeletonAttackMod & - ConfigCombatEngine::getSkeletonAttackMod( - ServerTangibleObjectTemplate::CombatSkeleton skeleton) -{ - int sk = static_cast(skeleton); - if (sk < 0 || static_cast(skeleton) >= - m_data.skeletonAttackMods.size()) - { - WARNING_STRICT_FATAL(true, ("ConfigCombatEngine::SkeletonAttackMod " - "requested invalid skeleton %d", skeleton)); - // if we're not strict, use the default skeleton values - skeleton = ServerTangibleObjectTemplate::CS_none; - } - return m_data.skeletonAttackMods[skeleton]; //lint !e641 Converting enum CombatSkeleton to int -} // ConfigCombatEngine::getSkeletonAttackMods - -inline float ConfigCombatEngine::getKineticObjectDamage(void) -{ - return m_data.kineticObjectDamage; -} // ConfigCombatEngine::getKineticObjectDamage - -inline float ConfigCombatEngine::getEnergyObjectDamage(void) -{ - return m_data.energyObjectDamage; -} // ConfigCombatEngine::getEnergyObjectDamage - -inline float ConfigCombatEngine::getBlastObjectDamage(void) -{ - return m_data.blastObjectDamage; -} // ConfigCombatEngine::getBlastObjectDamage - -inline float ConfigCombatEngine::getStunObjectDamage(void) -{ - return m_data.stunObjectDamage; -} // ConfigCombatEngine::getStunObjectDamage - -inline float ConfigCombatEngine::getRestraintObjectDamage(void) -{ - return m_data.restraintObjectDamage; -} // ConfigCombatEngine::getRestraintObjectDamage - -inline float ConfigCombatEngine::getElementalObjectDamage(void) -{ - return m_data.elementalObjectDamage; -} // ConfigCombatEngine::getElementalObjectDamage - -inline float ConfigCombatEngine::getWoundChance(void) -{ - return m_data.woundChance; -} // ConfigCombatEngine::getWoundChance - -inline float ConfigCombatEngine::getWoundPercent(void) -{ - return m_data.woundPercent; -} // ConfigCombatEngine::getWoundPercent - -inline float ConfigCombatEngine::getShockWoundPercent(void) -{ - return m_data.shockWoundPercent; -} // ConfigCombatEngine::getShockWoundPercent - -inline int ConfigCombatEngine::getDebugQueues(void) -{ - return m_data.debugQueues; -} // ConfigCombatEngine::getDebugQueues - -inline int ConfigCombatEngine::getDebugTargeting(void) -{ - return m_data.debugTargeting; -} // ConfigCombatEngine::getDebugTargeting - -inline int ConfigCombatEngine::getDebugAttack(void) -{ - return m_data.debugAttack; -} // ConfigCombatEngine::getDebugAttack - -inline int ConfigCombatEngine::getDebugDefense(void) -{ - return m_data.debugDefense; -} // ConfigCombatEngine::getDebugDefense - -inline int ConfigCombatEngine::getDebugDamage(void) -{ - return m_data.debugDamage; -} // ConfigCombatEngine::getDebugDamage - -inline int ConfigCombatEngine::getDebugExplosion(void) -{ - return m_data.debugExplosion; -} // ConfigCombatEngine::getDebugExplosion - -//----------------------------------------------------------------------- - - -#endif // _INCLUDED_ConfigCombatEngine_H diff --git a/src/game/server/application/SwgGameServer/src/shared/combat/combat.def b/src/game/server/application/SwgGameServer/src/shared/combat/combat.def deleted file mode 100644 index a8d3d8d2e..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/combat/combat.def +++ /dev/null @@ -1,32 +0,0 @@ -// ====================================================================== -// -// combat.def -// copyright (c) 2001 Sony Online Entertainment -// -// ***IMPORTTANT: This file is mirrored in dsrc/include -// -// ====================================================================== - -#ifndef INCLUDED_combat_DEF -#define INCLUDED_combat_DEF - -// id's for combat skeleton "bones" so when we know where a creature got hit we know what -// item was protecting that area -// -// IMPORTANT: the skeleton location names in the combat.cfg file should map to these -// -enum CombatSkeletonBone -{ - CSB_body = 0x0001, - CSB_head = 0x0002, - CSB_rightArm = 0x0004, - CSB_leftArm = 0x0008, - CSB_rightLeg = 0x0010, - CSB_leftLeg = 0x0020 -}; - - -#endif - - - diff --git a/src/game/server/application/SwgGameServer/src/shared/console/ConsoleCommandParserCombatEngine.cpp b/src/game/server/application/SwgGameServer/src/shared/console/ConsoleCommandParserCombatEngine.cpp deleted file mode 100644 index 021b77b66..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/console/ConsoleCommandParserCombatEngine.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// ====================================================================== -// -// ConsoleCommandParserCombatEngine.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "FirstSwgGameServer.h" -#include "CombatEngine.h" - -#include "UnicodeUtils.h" -#include "ConsoleCommandParserCombatEngine.h" -#include "ConsoleCommandParserCombatEngineQueue.h" -#include "serverGame/ServerWorld.h" -#include "serverGame/CreatureController.h" -#include "serverGame/CreatureObject.h" -#include "serverGame/WeaponObject.h" - -#include - - -// ====================================================================== - -static const CommandParser::CmdInfo cmds[] = -{ - {"reload", 0, "", "Reloads the combat data from the config file."}, - {"", 0, "", ""} // this must be last -}; - - -//----------------------------------------------------------------- - -ConsoleCommandParserCombatEngine::ConsoleCommandParserCombatEngine (void) : -CommandParser ("combat", 0, "...", "Combat related commands.", 0) -{ - createDelegateCommands (cmds); - IGNORE_RETURN(addSubCommand(new ConsoleCommandParserCombatEngineQueue()));//lint !e1524 (owned by the base class command parser) -} - -//----------------------------------------------------------------- - -bool ConsoleCommandParserCombatEngine::performParsing (const NetworkId & userId, const StringVector_t & argv, const String_t & originalCommand, String_t & result, const CommandParser * node) -{ - NOT_NULL (node); - UNREF (userId); - - UNREF(originalCommand); - - //----------------------------------------------------------------- - if (isAbbrev( argv [0], "reload")) - { - if (CombatEngine::reloadCombatData()) - result += getErrorMessage(argv[0], ERR_SUCCESS); - else - result += getErrorMessage(argv[0], ERR_NO_ERROR_MSG); - } - - //----------------------------------------------------------------- - - else - { - result += getErrorMessage(argv[0], ERR_NO_HANDLER); - } - - return true; -} - -// --------------------------------------------------------------------- - - - - -// ====================================================================== diff --git a/src/game/server/application/SwgGameServer/src/shared/console/ConsoleCommandParserCombatEngine.h b/src/game/server/application/SwgGameServer/src/shared/console/ConsoleCommandParserCombatEngine.h deleted file mode 100644 index 45095b161..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/console/ConsoleCommandParserCombatEngine.h +++ /dev/null @@ -1,48 +0,0 @@ -// ====================================================================== -// -// ConsoleCommandParserCombatEngine.h -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_ConsoleCommandParserCombatEngine_H -#define INCLUDED_ConsoleCommandParserCombatEngine_H - -#include "sharedCommandParser/CommandParser.h" - -// ====================================================================== - -/** -* Commands that are related to the combat engine -*/ - -class ConsoleCommandParserCombatEngine : public CommandParser -{ -public: - ConsoleCommandParserCombatEngine (); - virtual bool performParsing (const NetworkId & userId, - const StringVector_t & argv, - const String_t & originalCommand, - String_t & result, - const CommandParser * node); - -private: - ConsoleCommandParserCombatEngine (const ConsoleCommandParserCombatEngine & rhs); - ConsoleCommandParserCombatEngine & operator= (const ConsoleCommandParserCombatEngine & rhs); -}; - -// ====================================================================== - -#endif // INCLUDED_ConsoleCommandParserCombatEngine_H - - - - - - - - - - - - diff --git a/src/game/server/application/SwgGameServer/src/shared/console/ConsoleCommandParserCombatEngineQueue.cpp b/src/game/server/application/SwgGameServer/src/shared/console/ConsoleCommandParserCombatEngineQueue.cpp deleted file mode 100644 index a38c78c25..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/console/ConsoleCommandParserCombatEngineQueue.cpp +++ /dev/null @@ -1,198 +0,0 @@ -// ====================================================================== -// -// ConsoleCommandParserCombatEngineQueue.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "FirstSwgGameServer.h" -#include "ConsoleCommandParserCombatEngineQueue.h" - -#include "CombatEngine.h" -#include "UnicodeUtils.h" -#include "serverGame/ServerWorld.h" -#include "serverGame/CreatureObject.h" -#include "serverGame/TangibleObject.h" -#include "sharedFoundation/NetworkIdArchive.h" - -// ====================================================================== - -static const CommandParser::CmdInfo cmds[] = -{ - {"target", 1, "", "Target an object (oid 0 = no target)."}, - {"attack", 0, " ", "Attack current target with weapon."}, - {"aim", 0, "", "Add aim."}, - {"attitude", 1, "", "Change combat attitude (queued)."}, - {"posture", 1, "", "Change combat posture (queued)."}, - {"", 0, "", ""} // this must be last -}; - - -//----------------------------------------------------------------- - -ConsoleCommandParserCombatEngineQueue::ConsoleCommandParserCombatEngineQueue (void) : -CommandParser ("queue", 0, "...", "Action queue commands.", 0) -{ - createDelegateCommands (cmds); -} - -//----------------------------------------------------------------- - - -bool ConsoleCommandParserCombatEngineQueue::performParsing (const NetworkId & userId, - const StringVector_t & argv, const String_t & originalCommand, String_t & result, - const CommandParser * node) -{ - NOT_NULL (node); - UNREF (userId); - - UNREF(originalCommand); - - //----------------------------------------------------------------- - if (isAbbrev( argv [0], "target")) - { - Object *object = ServerWorld::findObjectByNetworkId(userId); - if (! object) - { - result += getErrorMessage(argv[0], ERR_INVALID_USER); - return true; - } - TangibleObject *attacker = dynamic_cast(object); - if (! attacker) - { - result += getErrorMessage(argv[0], ERR_BAD_ATTACKER); - return true; - } - - CombatEngineData::TargetIdList targets; - CachedNetworkId oid((Unicode::wideToNarrow(argv[1]))); //lint !e747 Info: 747 - Significant prototype coercion (arg. no. 1) int to long long - if (oid.getValue() != 0) - { - targets.push_back(oid); - } - - if (CombatEngine::addTargetAction(*attacker, targets)) - result += getErrorMessage(argv[0], ERR_SUCCESS); - else - result += getErrorMessage(argv[0], ERR_QUEUE_COMMAND_FAIL); - } - - //----------------------------------------------------------------- - - else if (isAbbrev( argv [0], "attack")) - { - Object *object = ServerWorld::findObjectByNetworkId(userId); - if (! object) - { - result += getErrorMessage(argv[0], ERR_INVALID_USER); - return true; - } - TangibleObject *attacker = dynamic_cast(object); - if (! attacker) - { - result += getErrorMessage(argv[0], ERR_BAD_ATTACKER); - return true; - } - - NetworkId weapon; - unsigned int mode = 0; - if (argv.size() >= 2) - weapon = NetworkId(Unicode::wideToNarrow(argv[1])); - if (argv.size() >= 3) - mode = strtoul(Unicode::wideToNarrow(argv[2]).c_str (), 0, 10); - if (CombatEngine::addAttackAction(*attacker, weapon, static_cast(mode))) - result += getErrorMessage(argv[0], ERR_SUCCESS); - else - result += getErrorMessage(argv[0], ERR_QUEUE_COMMAND_FAIL); - } - - //----------------------------------------------------------------- - - else if (isAbbrev( argv [0], "aim")) - { - Object *object = ServerWorld::findObjectByNetworkId(userId); - if (! object) - { - result += getErrorMessage(argv[0], ERR_INVALID_USER); - return true; - } - TangibleObject *attacker = dynamic_cast(object); - if (! attacker) - { - result += getErrorMessage(argv[0], ERR_BAD_ATTACKER); - return true; - } - - if (CombatEngine::addAimAction(*attacker)) - result += getErrorMessage(argv[0], ERR_SUCCESS); - else - result += getErrorMessage(argv[0], ERR_QUEUE_COMMAND_FAIL); - } - - //----------------------------------------------------------------- - - else if (isAbbrev( argv [0], "attitude")) - { - Object *object = ServerWorld::findObjectByNetworkId(userId); - if (! object) - { - result += getErrorMessage(argv[0], ERR_INVALID_USER); - return true; - } - TangibleObject *attacker = dynamic_cast(object); - if (! attacker) - { - result += getErrorMessage(argv[0], ERR_BAD_ATTACKER); - return true; - } - -// int attitude = strtoul(Unicode::wideToNarrow(argv[1]).c_str (), 0, 10); - -// if (CombatEngine::addAttitudeAction(*attacker, attitude)) -// result += getErrorMessage(argv[0], ERR_SUCCESS); -// else - result += getErrorMessage(argv[0], ERR_QUEUE_COMMAND_FAIL); - } - - //----------------------------------------------------------------- - - else if (isAbbrev( argv [0], "posture")) - { - Object *object = ServerWorld::findObjectByNetworkId(userId); - if (! object) - { - result += getErrorMessage(argv[0], ERR_INVALID_USER); - return true; - } - CreatureObject *attacker = dynamic_cast(object); - if (! attacker) - { - result += getErrorMessage(argv[0], ERR_BAD_ATTACKER); - return true; - } - -// Postures::Enumerator posture = static_cast(strtoul( -// Unicode::wideToNarrow(argv[1]).c_str (), 0, 10)); - -// if (CombatEngine::addPostureAction(*attacker, posture)) -// result += getErrorMessage(argv[0], ERR_SUCCESS); -// else - result += getErrorMessage(argv[0], ERR_QUEUE_COMMAND_FAIL); - } - - //----------------------------------------------------------------- - - else - { - result += getErrorMessage(argv[0], ERR_NO_HANDLER); - } - - return true; -} - -// --------------------------------------------------------------------- - - - - -// ====================================================================== diff --git a/src/game/server/application/SwgGameServer/src/shared/console/ConsoleCommandParserCombatEngineQueue.h b/src/game/server/application/SwgGameServer/src/shared/console/ConsoleCommandParserCombatEngineQueue.h deleted file mode 100644 index e3c33f395..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/console/ConsoleCommandParserCombatEngineQueue.h +++ /dev/null @@ -1,48 +0,0 @@ -// ====================================================================== -// -// ConsoleCommandParserCombatEngineQueue.h -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_ConsoleCommandParserCombatEngineQueue_H -#define INCLUDED_ConsoleCommandParserCombatEngineQueue_H - -#include "sharedCommandParser/CommandParser.h" - -// ====================================================================== - -/** -* Commands that are related to the combat engine -*/ - -class ConsoleCommandParserCombatEngineQueue : public CommandParser -{ -public: - ConsoleCommandParserCombatEngineQueue (); - virtual bool performParsing (const NetworkId & userId, - const StringVector_t & argv, - const String_t & originalCommand, - String_t & result, - const CommandParser * node); - -private: - ConsoleCommandParserCombatEngineQueue (const ConsoleCommandParserCombatEngineQueue & rhs); - ConsoleCommandParserCombatEngineQueue & operator= (const ConsoleCommandParserCombatEngineQueue & rhs); -}; - -// ====================================================================== - -#endif // INCLUDED_ConsoleCommandParserCombatEngineQueue_H - - - - - - - - - - - - diff --git a/src/game/server/application/SwgGameServer/src/shared/controller/JediManagerController.cpp b/src/game/server/application/SwgGameServer/src/shared/controller/JediManagerController.cpp deleted file mode 100644 index 80099996d..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/controller/JediManagerController.cpp +++ /dev/null @@ -1,205 +0,0 @@ -//======================================================================== -// -// JediManagerController.cpp -// -// copyright 2001 Sony Online Entertainment -// -//======================================================================== - -#include "FirstSwgGameServer.h" -#include "SwgGameServer/JediManagerController.h" -#include "sharedNetworkMessages/MessageQueueGenericValueType.h" -#include "SwgGameServer/JediManagerObject.h" -#include "swgServerNetworkMessages/MessageQueueJediData.h" -#include "swgServerNetworkMessages/MessageQueueJediLocation.h" -#include "swgServerNetworkMessages/MessageQueueRequestJediBounty.h" - - -//----------------------------------------------------------------------- - -JediManagerController::JediManagerController(JediManagerObject * newOwner) : - UniverseController(newOwner) -{ -} - -//----------------------------------------------------------------------- - -JediManagerController::~JediManagerController() -{ -} - -//----------------------------------------------------------------------- - -void JediManagerController::handleMessage (const int message, const float value, const MessageQueue::Data* const data, const uint32 flags) -{ - JediManagerObject * owner = dynamic_cast(getOwner()); - NOT_NULL(owner); - - switch (message) - { - case CM_removeJedi: - { - const MessageQueueGenericValueType * const msg = safe_cast *>(data); - if (msg != NULL) - { - owner->removeJedi(msg->getValue()); - } - } - break; - case CM_addJedi: - { - const MessageQueueJediData * const msg = safe_cast(data); - if (msg != NULL) - { - owner->addJedi(msg->getId(), - msg->getName(), - msg->getLocation(), - msg->getScene(), - msg->getVisibility(), - msg->getBountyValue(), - msg->getLevel(), - msg->getHoursAlive(), - msg->getState(), - msg->getSpentJediSkillPoints(), - msg->getFaction() - ); - } - } - break; - case CM_updateJedi: - { - const MessageQueueJediData * const msg = safe_cast(data); - if (msg != NULL) - { - owner->updateJedi(msg->getId(), - msg->getVisibility(), - msg->getBountyValue(), - msg->getLevel(), - msg->getHoursAlive() - ); - } - } - break; - case CM_updateJediState: - { - const MessageQueueGenericValueType > * const msg = safe_cast > *>(data); - if (msg != NULL) - { - owner->updateJedi(msg->getValue().first, - static_cast(msg->getValue().second) - ); - } - } - break; - case CM_updateJediBounties: - { -/* - const MessageQueueGenericValueType > > * const msg = safe_cast > > *>(data); - if (msg != NULL) - { - owner->updateJedi(msg->getValue().first, - msg->getValue().second - ); - } -*/ - } - break; - case CM_updateJediLocation: - { - const MessageQueueJediLocation * const msg = safe_cast(data); - if (msg != NULL) - { - owner->updateJediLocation(msg->getId(), - msg->getLocation(), - msg->getScene() - ); - } - } - break; - case CM_setJediOffline: - { - const MessageQueueJediLocation * const msg = safe_cast(data); - if (msg != NULL) - { - owner->setJediOffline(msg->getId(), - msg->getLocation(), - msg->getScene() - ); - } - } - break; - case CM_requestJediBounty: - { - const MessageQueueRequestJediBounty * const msg = safe_cast(data); - if (msg != NULL) - { - owner->requestJediBounty(msg->getTargetId(), - msg->getHunterId(), - msg->getSuccessCallback(), - msg->getFailCallback(), - msg->getCallbackObjectId() - ); - } - } - break; - case CM_removeJediBounty: - { - const MessageQueueGenericValueType > * const msg = safe_cast > *>(data); - if (msg != NULL) - { - owner->removeJediBounty(msg->getValue().first, msg->getValue().second); - } - } - break; - case CM_removeAllJediBounties: - { - const MessageQueueGenericValueType * const msg = safe_cast *>(data); - if (msg != NULL) - { - owner->removeAllJediBounties(msg->getValue()); - } - } - break; - case CM_updateJediSpentJediSkillPoints: - { - const MessageQueueGenericValueType > * const msg = safe_cast > *>(data); - if (msg != NULL) - { - owner->updateJediSpentJediSkillPoints(msg->getValue().first, msg->getValue().second); - } - } - break; - case CM_updateJediFaction: - { - const MessageQueueGenericValueType > * const msg = safe_cast > *>(data); - if (msg != NULL) - { - owner->updateJediFaction(msg->getValue().first, msg->getValue().second); - } - } - break; - case CM_updateJediScriptData: - { - const MessageQueueGenericValueType > > * const msg = safe_cast > > *>(data); - if (msg != NULL) - { - owner->updateJediScriptData(msg->getValue().first, msg->getValue().second.first, msg->getValue().second.second); - } - } - break; - case CM_removeJediScriptData: - { - const MessageQueueGenericValueType > * const msg = safe_cast > *>(data); - if (msg != NULL) - { - owner->removeJediScriptData(msg->getValue().first, msg->getValue().second); - } - } - break; - default: - UniverseController::handleMessage(message, value, data, flags); - break; - } -} - -//----------------------------------------------------------------------- diff --git a/src/game/server/application/SwgGameServer/src/shared/controller/JediManagerController.h b/src/game/server/application/SwgGameServer/src/shared/controller/JediManagerController.h deleted file mode 100644 index 5804367ed..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/controller/JediManagerController.h +++ /dev/null @@ -1,42 +0,0 @@ -//======================================================================== -// -// JediManagerController.h -// -// copyright 2001 Sony Online Entertainment -// -//======================================================================== - -#ifndef INCLUDED_JediManagerController_H -#define INCLUDED_JediManagerController_H - -#include "serverGame/UniverseController.h" - -class JediManagerObject; - - -//---------------------------------------------------------------------- - - -/** - * A generic controller for all JediManager Objects. - */ -class JediManagerController : public UniverseController -{ -public: - explicit JediManagerController (JediManagerObject * newOwner); - virtual ~JediManagerController (void); - -protected: - virtual void handleMessage (int message, float value, const MessageQueue::Data* data, uint32 flags); - -private: - JediManagerController (void); - JediManagerController (const JediManagerController & other); - JediManagerController& operator= (const JediManagerController & other); -}; - - -//----------------------------------------------------------------------- - - -#endif // INCLUDED_JediManagerController_H diff --git a/src/game/server/application/SwgGameServer/src/shared/controller/SwgPlayerCreatureController.cpp b/src/game/server/application/SwgGameServer/src/shared/controller/SwgPlayerCreatureController.cpp deleted file mode 100644 index dea874be8..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/controller/SwgPlayerCreatureController.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// ====================================================================== -// -// SwgPlayerCreatureController.cpp -// -// Copyright 2002 Sony Online Entertainment -// -// ====================================================================== - -#include "FirstSwgGameServer.h" -#include "SwgGameServer/SwgPlayerCreatureController.h" - -#include "sharedNetworkMessages/MessageQueueGenericValueType.h" -#include "SwgGameServer/SwgCreatureObject.h" -#include "SwgGameServer/SwgPlayerObject.h" - - -// ====================================================================== - -SwgPlayerCreatureController::SwgPlayerCreatureController(SwgCreatureObject *newOwner) : - PlayerCreatureController(newOwner) -{ -} - -// ---------------------------------------------------------------------- - -SwgPlayerCreatureController::~SwgPlayerCreatureController() -{ -} - -// ---------------------------------------------------------------------- - -void SwgPlayerCreatureController::handleMessage (const int message, const float value, const MessageQueue::Data* const data, const uint32 flags) -{ - SwgCreatureObject * const owner = safe_cast(getOwner()); - SwgPlayerObject * playerOwner = safe_cast(getPlayerObject(owner)); - NOT_NULL(playerOwner); - - switch (message) - { - case CM_setJediState: - { - const MessageQueueGenericValueType * const msg = dynamic_cast *>(data); - if (msg != NULL) - playerOwner->setJediState(static_cast(msg->getValue())); - } - break; - - default: - PlayerCreatureController::handleMessage(message, value, data, flags); - break; - } -} - -// ---------------------------------------------------------------------- - diff --git a/src/game/server/application/SwgGameServer/src/shared/controller/SwgPlayerCreatureController.h b/src/game/server/application/SwgGameServer/src/shared/controller/SwgPlayerCreatureController.h deleted file mode 100644 index e7b668cf1..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/controller/SwgPlayerCreatureController.h +++ /dev/null @@ -1,43 +0,0 @@ -//======================================================================== -// -// SwgPlayerCreatureController.h -// -// copyright 2001 Sony Online Entertainment -// -//======================================================================== - -#ifndef INCLUDED_SwgPlayerCreatureController_H -#define INCLUDED_SwgPlayerCreatureController_H - -//----------------------------------------------------------------------- - -#include "serverGame/PlayerCreatureController.h" - - -//----------------------------------------------------------------------- - -class SwgCreatureObject; - - -//----------------------------------------------------------------------- - -class SwgPlayerCreatureController : public PlayerCreatureController -{ -public: - explicit SwgPlayerCreatureController (SwgCreatureObject * newOwner); - ~SwgPlayerCreatureController (); - -protected: - virtual void handleMessage (int message, float value, const MessageQueue::Data* data, uint32 flags); - -private: - // Disabled. - SwgPlayerCreatureController (void); - SwgPlayerCreatureController (const SwgPlayerCreatureController & other); - SwgPlayerCreatureController& operator= (const SwgPlayerCreatureController & other); -}; - -//-------------------------------------------------------------------- - -#endif // INCLUDED_SwgPlayerCreatureController_H - diff --git a/src/game/server/application/SwgGameServer/src/shared/core/CSHandler.cpp b/src/game/server/application/SwgGameServer/src/shared/core/CSHandler.cpp deleted file mode 100644 index d51dbfb21..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/core/CSHandler.cpp +++ /dev/null @@ -1,1517 +0,0 @@ -// CSHandler.cpp -//-------------------------- -// Copyright 2005 Sony Online Entertainment - -#include "FirstSwgGameServer.h" -#include "CSHandler.h" - -#include "serverGame/ConfigServerGame.h" -#include "serverGame/ConsoleManager.h" -#include "serverGame/ContainerInterface.h" -#include "serverGame/CreatureObject.h" -#include "serverGame/NameManager.h" -#include "serverGame/PlayerCreationManagerServer.h" -#include "serverGame/PlayerCreatureController.h" -#include "serverGame/PlayerObject.h" -#include "serverGame/ServerObject.h" -#include "serverGame/ServerWorld.h" -#include "serverGame/ShipObject.h" -#include "serverNetworkMessages/GameServerCSRequestMessage.h" -#include "serverNetworkMessages/GameServerCSResponseMessage.h" -#include "serverNetworkMessages/RenameCharacterMessage.h" -#include "serverScript/GameScriptObject.h" -#include "serverScript/JavaLibrary.h" -#include "serverScript/ScriptParameters.h" -#include "sharedFoundation/DynamicVariableList.h" -#include "sharedFoundation/DynamicVariableListNestedList.h" -#include "sharedFoundation/DynamicVariableLocationData.h" -#include "sharedLog/Log.h" -#include "sharedNetworkMessages/GenericValueTypeMessage.h" -#include "sharedObject/SlottedContainer.h" -#include "sharedObject/VolumeContainer.h" -#include "SwgGameServer.h" -#include "Unicode.h" -#include "UnicodeUtils.h" - -#define REGISTER_CS_CMD(_name_,_access_) \ - CSHandlerNamespace::cmdMap[ #_name_ ] = CSHandlerEntry( #_name_, _access_, &CSHandler::handle_##_name_ ); - -#define CS_CMD(_name_) void CSHandler::handle_##_name_( CSHandlerRequest & request, GameServerCSResponseMessage & msg ) - -namespace CSHandlerNamespace -{ - const int smallBufferSize = 64; - const int largeBufferSize = 256; - - typedef std::map< std::string, std::string > CSLogData; - typedef std::vector< std::string > CSArgs; - std::map< std::string, CSHandlerEntry > cmdMap; - - // from CommandCppFuncs.cpp - ShipObject const *getFirstPackedShipForCreature(CreatureObject const &creature) - { - ServerObject const * const datapad = creature.getDatapad(); - if (datapad) - { - Container const * const container = ContainerInterface::getContainer(*datapad); - if (container) - { - for (ContainerConstIterator i = container->begin(); i != container->end(); ++i) - { - ServerObject const * const content = safe_cast((*i).getObject()); - if ( content - && content->getGameObjectType() == SharedObjectTemplate::GOT_data_ship_control_device - && !content->isBeingDestroyed()) - { - Container const * const scdContainer = ContainerInterface::getContainer(*content); - if (scdContainer) - { - for (ContainerConstIterator j = scdContainer->begin(); j != scdContainer->end(); ++j) - { - ServerObject const * const scdContent = safe_cast((*j).getObject()); - if (scdContent && !scdContent->isBeingDestroyed() && scdContent->asShipObject()) - return scdContent->asShipObject(); - } - } - } - } - } - } - return 0; - } - - std::string getOneArg( std::string input, unsigned &position ) - { - unsigned pos; // where we stop looking - unsigned lastpos; // the last character in our argument. - // bounds checking. - if( position < 0 || position >= input.length() ) - { - return ""; - } - // skip whitespace - while( input[ position ] == ' ' && position < input.length() ) - { - ++position; - } - - if( position == input.length() ) - return ""; - // see if the first character is a quote. - if( input[ position ] == '"' ) - { - // if it is... - // skip over the quote. - pos = ++position; - // look for the next quote. - while( 1 ) - { - pos = input.find( '"', pos ); - // if we don't find one, assume the end of the line. - if( pos == std::string::npos ) - { - pos = input.length(); - lastpos = pos - 1; - break; - } - else - { - // and verify that it's not preceded by a backslash. - if( input[ pos - 1 ] != '\\' ) - { - lastpos = pos; - break; - } - else - { - pos++; - } - } - } - } - else - { - // otherwise, just look for a space. - pos = input.find( ' ', position ); - // if we don't find a space, assume the end of the line. - if( pos == std::string::npos ) - { - pos = input.length(); - } - lastpos = pos; - } - - - // build the string. - std::string output = input.substr( position, lastpos - position ); - - // modify the position. Assume that the caller will do bounds checking. - position = pos + 1; - return output; - - } - - void getArgs( std::string input, std::vector< std::string > & output ) - { - unsigned pos = 0; - while ( pos < input.length() ) - { - std::string temp = getOneArg( input, pos ); - output.push_back( temp ); - } - } - void log( CSLogData & data ) - { - std::string logline = ""; - bool b_first = true; - for( CSLogData::iterator it = data.begin(); it != data.end(); ++it ) - { - if( b_first ) - { - b_first = false; - } - else - { - logline += ";"; - } - logline = logline + it->first + "=" + it->second; - } - LOG( "CustomerService", ( "CSTool: %s", logline.c_str() ) ); - } - - void log( CSHandlerRequest &req, CSLogData &data ) - { - // add the additional fields and pass to log. - data[ "user" ] = req.m_name; - log( data ); - } - - void addObjVarToString( std::string & response, - const std::string & prefix, - DynamicVariableList::NestedList::const_iterator &objVar ) - { - char buffer[ smallBufferSize ]; - - // print the data - switch (objVar.getType()) - { - case DynamicVariable::INT: - { - int value=0; - objVar.getValue(value); - IGNORE_RETURN(_itoa(value, buffer, 10)); - // print the name - response += prefix + objVar.getName(); - response += ":"; - response += buffer; - response += "\r\n"; - } - break; - case DynamicVariable::INT_ARRAY: - { - std::vector value; - objVar.getValue(value); - std::string text = "["; - size_t count = value.size(); - for (size_t j = 0; j < count; ++j) - { - IGNORE_RETURN(_itoa(value[j], buffer, 10)); - text += buffer; - if (j + 1 < count) - text += ", "; - } - text += "]\r\n"; - // print the name - response += prefix + objVar.getName(); - response += ":"; - response += text; - } - break; - case DynamicVariable::REAL: - { - real value = 0; - objVar.getValue(value); - snprintf(buffer, sizeof( buffer ) -1 , "%f\r\n", value); - buffer[ sizeof( buffer ) -1 ] = 0; - // print the name - response += prefix + objVar.getName(); - response += ":"; - - response += buffer; - } - break; - case DynamicVariable::REAL_ARRAY: - { - std::vector value; - objVar.getValue(value); - std::string text = "["; - size_t count = value.size(); - for (size_t j = 0; j < count; ++j) - { - snprintf(buffer, sizeof( buffer ) - 1, "%f", value[j]); - buffer[ sizeof( buffer ) - 1 ] = 0; - text += buffer; - if (j + 1 < count) - text += ", "; - } - text += "]\n"; - // print the name - response += prefix + objVar.getName(); - response += ":"; - - response += text; - } - break; - case DynamicVariable::STRING: - { - Unicode::String value; - objVar.getValue(value); - // print the name - response += prefix + objVar.getName(); - response += ":"; - - response += Unicode::wideToNarrow( value ); - response += "\r\n"; - } - break; - case DynamicVariable::STRING_ARRAY: - { - // print the name - response += prefix + objVar.getName(); - response += ":"; - - std::vector value; - objVar.getValue(value); - response += "[[\r\n"; - size_t count = value.size(); - for (size_t j = 0; j < count; ++j) - { - response += Unicode::wideToNarrow( value[j] ); - response += "\r\n"; - } - response += "]]\r\n"; - } - break; - case DynamicVariable::NETWORK_ID: - { - // print the name - response += prefix + objVar.getName(); - response += ":"; - - NetworkId value; - objVar.getValue(value); - response += "(NetworkId)"; - response += value.getValueString(); - response += "\r\n"; - } - break; - case DynamicVariable::NETWORK_ID_ARRAY: - { - // print the name - response += prefix + objVar.getName(); - response += ":"; - - std::vector value; - objVar.getValue(value); - std::string text = "(NetworkId)["; - size_t count = value.size(); - for (size_t j = 0; j < count; ++j) - { - text += value[j].getValueString(); - if (j + 1 < count) - text += ", "; - } - text += "]\r\n"; - response += text; - } - break; - case DynamicVariable::LOCATION: - { - // print the name - response += prefix + objVar.getName(); - response += ":"; - - DynamicVariableLocationData value; - objVar.getValue(value); - response += "(x="; - snprintf(buffer, sizeof( buffer ) -1 , "%f", value.pos.x); - buffer[ sizeof( buffer ) - 1 ] = 0; - response += buffer; - response += ", y="; - snprintf(buffer, sizeof( buffer ) - 1, "%f", value.pos.y); - buffer[ sizeof( buffer ) - 1 ] = 0; - response += buffer; - response += ", z="; - snprintf(buffer, sizeof( buffer ) - 1, "%f", value.pos.z); - buffer[ sizeof( buffer ) - 1 ] = 0; - response += buffer; - response += ", scene="; - response += value.scene; - response += ", cell="; - response += value.cell.getValueString(); - response += ")\r\n"; - } - break; - case DynamicVariable::LOCATION_ARRAY: - { - // print the name - response += prefix + objVar.getName(); - response += ":"; - - std::vector value; - objVar.getValue(value); - int k; - int nameLength = objVar.getName().size(); - response += "[\r\n"; - size_t count = value.size(); - for (size_t j = 0; j < count; ++j) - { - for (k = 0; k < nameLength; ++k) - response += " "; - response += "(x="; - snprintf(buffer, sizeof( buffer ) - 1, "%f", value[ j ].pos.x); - buffer[ sizeof( buffer ) - 1 ] = 0; - response += buffer; - response += ", y="; - snprintf(buffer, sizeof( buffer ) - 1, "%f", value[ j ].pos.y); - buffer[ sizeof( buffer ) - 1 ] = 0; - response += buffer; - response += ", z="; - snprintf(buffer, sizeof( buffer ) - 1, "%f", value[ j ].pos.z); - buffer[ sizeof( buffer ) - 1 ] = 0; - response += buffer; - response += ", scene="; - response += value[ j ].scene; - response += ", cell="; - response += value[ j ].cell.getValueString(); - // response += ")\r\n"; } - for (k = 0; k < nameLength; ++k) - response += " "; - response += "]\r\n"; - } - } - break; - case DynamicVariable::LIST: - { - // call recursively - std::string newPrefix = prefix + objVar.getName() + "."; - const DynamicVariableList::NestedList &list = objVar.getNestedList(); - for(DynamicVariableList::NestedList::const_iterator newObjvar = list.begin(); - newObjvar != list.end(); - ++newObjvar) - { - addObjVarToString( response, newPrefix, newObjvar ); - } - } - break; - case DynamicVariable::STRING_ID: - { - StringId value; - objVar.getValue(value); - response += "(StringId)"; - response += value.getDebugString(); - response += "\r\n"; - } - break; - case DynamicVariable::STRING_ID_ARRAY: - { - std::vector value; - objVar.getValue(value); - std::string text = "(StringId)["; - size_t count = value.size(); - for (size_t j = 0; j < count; ++j) - { - text += value[j].getDebugString(); - if (j + 1 < count) - text += ", "; - } - text += "]\r\n"; - response += text; - } - break; - case DynamicVariable::TRANSFORM: - { - Transform value; - objVar.getValue(value); - response += "(Transform)"; - //response += getDebugString(value); - response += "\r\n"; - } - break; - case DynamicVariable::TRANSFORM_ARRAY: - { - std::vector value; - objVar.getValue(value); - std::string text = "(Transform)["; - size_t count = value.size(); - for (size_t j = 0; j < count; ++j) - { - // text += getDebugString(value[j]); - if (j + 1 < count) - text += ", "; - } - text += "]\r\n"; - response += text; - } - break; - case DynamicVariable::VECTOR: - { - Vector value; - objVar.getValue(value); - response += "(Vector)"; - // response += getDebugString(value); - response += "\r\n"; - } - break; - case DynamicVariable::VECTOR_ARRAY: - { - std::vector value; - objVar.getValue(value); - std::string text = "(Vector)["; - size_t count = value.size(); - for (size_t j = 0; j < count; ++j) - { - // text += getDebugString(value[j]); - if (j + 1 < count) - text += ", "; - } - text += "]\n"; - response += text; - } - break; - } - - } - - void addItemInfo(const VolumeContainer * container, int & num, std::map & stats) - { - if(!container) - return; - char stringbuffer[CSHandlerNamespace::largeBufferSize]; - std::vector objList; - for (ContainerConstIterator iter(container->begin()); - iter != container->end(); ++iter) - { - char catbuffer[ CSHandlerNamespace::smallBufferSize ]; - const CachedNetworkId & objId = (*iter); - const TangibleObject * obj = safe_cast(objId.getObject()); - std::string category = "Item-"; - snprintf( catbuffer, sizeof( catbuffer ) - 1, "%s%d", category.c_str(), num++ ); - catbuffer[ sizeof( catbuffer ) -1 ] = 0; - snprintf( stringbuffer, sizeof( stringbuffer ) - 1, "%s(%s)", Unicode::wideToNarrow( obj->getObjectName() ).c_str(), - obj->getNetworkId().getValueString().c_str() ); - stringbuffer[ sizeof( stringbuffer ) - 1 ] = 0; - stats[ catbuffer ] = stringbuffer; - - // recurse if necessary. - const VolumeContainer * obj_as_container = ContainerInterface::getVolumeContainer(*obj); - if( obj_as_container ) - { - addItemInfo( obj_as_container, num, stats ); - } - } - } -} - -CSHandler* CSHandler::sm_instance = 0; - -CSHandler::CSHandler() -{ - registerCommands(); -} - -CSHandler::~ CSHandler() -{ -} - -void CSHandler::install() -{ - if( !sm_instance ) - sm_instance = new CSHandler(); - -} - -void CSHandler::remove() -{ - if( sm_instance ) - delete sm_instance; -} - -CSHandler & CSHandler::getInstance() -{ - NOT_NULL( sm_instance ); - return *sm_instance; -} - -void CSHandler::handle( GameServerCSRequestMessage & request ) -{ - DEBUG_REPORT_LOG( true, ( "Handling command" ) ); - const std::string &original = request.getCommandString(); - std::string command; - std::string args; - - unsigned pos = original.find( " " ); - if( pos == std::string::npos ) - { - command = original; - } - else - { - command = original.substr( 0, pos ); - args = original.substr( pos + 1, original.length() - ( pos + 1 ) ); - } - - DEBUG_REPORT_LOG( true, ( "Command is %s", command.c_str() ) ); - - // find the command - std::map< std::string, CSHandlerEntry >::iterator it = CSHandlerNamespace::cmdMap.find( command ); - if( it != CSHandlerNamespace::cmdMap.end() ) - { - // build the proto-response - GameServerCSResponseMessage msg( request ); - - std::string username = request.getUserName(); - - // build the cs request - CSHandlerRequest req( command, args, request.getAccessLevel(), username ); - - // check the access - if( req.m_access >= it->second.access ) - { - // and fire it off. - CSHandlerFunc func = it->second.handlerFunc; - ( this->*func )( req, msg ); - } - - } - else - { - // try passing it off to the console parser. - //ConsoleMgr::processStringForCSHandler( original ); - // JavaLibrary::instance()->runScripts(m_owner->getNetworkId(), funcName, "Ouf", params); - } -} - -void CSHandler::registerCommands() -{ - REGISTER_CS_CMD( get_pc_info, 4 ); - REGISTER_CS_CMD( set_bank_credits, 4 ); - REGISTER_CS_CMD( undelete_item, 4 ); - REGISTER_CS_CMD( list_objvars, 4 ); - REGISTER_CS_CMD( set_objvar, 4 ); - REGISTER_CS_CMD( remove_objvar, 4 ); - REGISTER_CS_CMD( dump_info, 4 ); - REGISTER_CS_CMD( rename_player, 4 ); - - REGISTER_CS_CMD( freeze, 4 ); - REGISTER_CS_CMD( unfreeze, 4 ); - - REGISTER_CS_CMD( get_player_id, 4 ); - REGISTER_CS_CMD( get_player_items, 4 ); - - REGISTER_CS_CMD( move_object, 4 ); - - REGISTER_CS_CMD( create_crafted_object, 4 ); - - REGISTER_CS_CMD( delete_object, 4 ); - - REGISTER_CS_CMD( adjust_lots, 4 ); - - REGISTER_CS_CMD( warp_player, 4 ); -} - -void addIntData( std::map< std::string, std::string > & data, const std::string & stat, int amount ) -{ - char buffer[ CSHandlerNamespace::smallBufferSize ]; - snprintf( buffer, sizeof( buffer ) - 1, "%d", amount ); - buffer[ sizeof( buffer ) - 1 ] = 0; - data[ stat ] = buffer; -} - - - -enum ArgType -{ - STRING_ARGUMENT = 0, - REAL_ARGUMENT, - INT_ARGUMENT -}; - -int getArgumentType(const std::string &arg) -{ - bool foundDecimal = false; - - size_t count = arg.length(); - for (size_t i = 0; i < count; ++i) - { - if (!isdigit(arg[i])) - { - if (arg[i] != '.' || foundDecimal) - return STRING_ARGUMENT; - foundDecimal = true; - } - } - if (foundDecimal) - return REAL_ARGUMENT; - return INT_ARGUMENT; -} - -CS_CMD( warp_player ) -{ - CSHandlerNamespace::CSArgs args; - CSHandlerNamespace::getArgs( request.m_args, args ); - - if( args.size() < 5 ) - return; - - // format: target planet x y z - NetworkId target_id( args[ 0 ] ); - CreatureObject *target = CreatureObject::getCreatureObject( target_id ); - if( !( target && target->isAuthoritative() ) ) - return; - - std::string planet = args[ 1 ]; - float x=0.0f, y=0.0f, z=0.0f; - sscanf( args[2].c_str(), "%f", &x ); - sscanf( args[3].c_str(), "%f", &y ); - sscanf( args[4].c_str(), "%f", &z ); - - Vector newPosition_w(x, y, z); - Vector newPosition_p(0.0f, 0.0f, 0.0f); - NetworkId newContainer; - TangibleObject *targetTangible = target; - - if (targetTangible) - { - if (!ServerWorld::isSpaceScene() && !strncmp(planet.c_str(), "space_", 5) && targetTangible->asCreatureObject()) - { - // don't allow CS Tool to warp to space from ground. - return; - - // NOTE RHanz: This code is commented out due to lack of an obvious unified interface - // for setting up launches (ie, having to manually set objvars) - // to space in this usage case. The code is exactly the same (except var names) - // as the code for planetwarp (in CommandCppFuncs.cpp). If CS actually does need to - // move people from ground to space for admin purposes, you should be able to simply uncomment - // the below section of code. - - //// going to space from the ground, so require a ship and set launch information - //ShipObject const * const ship = CSHandlerNamespace::getFirstPackedShipForCreature(*targetTangible->asCreatureObject()); - //if (!ship) - //{ - // return; - //} - - //DynamicVariableLocationData const loc(targetTangible->getPosition_w(), ServerWorld::getSceneId(), NetworkId::cms_invalid); - //targetTangible->setObjVarItem("space.launch.worldLoc", loc); - //targetTangible->setObjVarItem("space.launch.ship", ship->getNetworkId()); - //targetTangible->setObjVarItem("space.launch.startIndex", static_cast(0)); - } - if(!target->getClient()) - { - // character is in the save queue. This is currently not supported. Planetwarping - // appears to break the PseudoClientConnection system. - msg.setResponse( "Unable to warp player:\r\n" ); - SwgGameServer::getInstance().sendToCentralServer(msg); - return; - } - CSHandlerNamespace::CSLogData data; - data[ "command" ] = "warp_player"; - data[ "target_id" ] = args[ 0 ]; - data[ "planet" ] = args[ 1 ]; - char buf[ CSHandlerNamespace::largeBufferSize ]; - snprintf( buf, CSHandlerNamespace::largeBufferSize,"%.02f %.02f %.02f", x, y, z ); - data[ "location" ] = buf; - GameServer::getInstance().requestSceneWarp(CachedNetworkId(*targetTangible), planet, newPosition_w, newContainer, newPosition_p); - } -} - -CS_CMD( adjust_lots ) -{ - CSHandlerNamespace::CSArgs args; - CSHandlerNamespace::getArgs( request.m_args, args ); - - if( args.size() < 2 ) - return; // not enough arguments. - - NetworkId target_id( args[ 0 ] ); - CreatureObject *target = CreatureObject::getCreatureObject( target_id ); - if( !( target && target->isAuthoritative() ) ) - return; - PlayerObject * player = PlayerCreatureController::getPlayerObject( target ); - if( !player ) - return; // not a player, can't adjust lots. - - int count = atoi( args[ 1 ].c_str() ); - - CSHandlerNamespace::CSLogData data; - data[ "command" ] = "adjust_lots"; - data[ "target_id" ] = args[ 0 ]; - data[ "amount" ] = args[ 1 ]; - CSHandlerNamespace::log( request, data ); - - player->adjustLotCount( count ); - -} - -CS_CMD( create_crafted_object ) -{ - CSHandlerNamespace::CSArgs args; - CSHandlerNamespace::getArgs( request.m_args, args ); - // args should be: - // destination schematic quality - - if( args.size() < 2 ) - return; - - NetworkId target_id( args[ 0 ] ); - CreatureObject *target = CreatureObject::getCreatureObject( target_id ); - if( !( target && target->isAuthoritative() ) ) - return; - ServerObject *inventory = target->getInventory(); - if( inventory == NULL ) - return; - DEBUG_REPORT_LOG( true, ( "Trying to make %s\n", args[ 1 ].c_str())); - GameScriptObject * script = target->getScriptObject(); - if( script ) - { - ScriptParams params; - params.addParam(target_id); - params.addParam(args[ 1 ].c_str()); - script->trigAllScripts(Scripting::TRIG_CS_CREATE_STATIC_ITEM, params); - - } - CSHandlerNamespace::CSLogData data; - data[ "command" ] = "create_crafted_object"; - data[ "target_id" ] = args[ 0 ]; - data[ "schematic" ] = args[ 1 ]; - CSHandlerNamespace::log( request, data ); -} - -// informational command. no logs needed. -CS_CMD( get_player_items ) -{ - std::transform( request.m_args.begin(), request.m_args.end(), request.m_args.begin(), tolower ); - - CSHandlerNamespace::CSArgs args; - CSHandlerNamespace::getArgs( request.m_args, args ); - if( args.size() < 1 ) - return; // no player - - // get the player ID - - - if( args.size() > 0 ) - { - NetworkId player_id = NameManager::getInstance().getPlayerId( args[ 0 ] ); - - // get the object - const CreatureObject* const creatureActor = CreatureObject::getCreatureObject(player_id); - - if( !creatureActor ) - return; - - - // are we authoritative? - if( creatureActor->isAuthoritative() ) - { - // if so, built a list of items - std::string response; - const ServerObject * inventory = creatureActor->getInventory(); - if( inventory ) - { - - std::map< std::string, std::string > stats; - const VolumeContainer * inventoryContainer = ContainerInterface::getVolumeContainer(*inventory); - if (inventoryContainer ) - { - - int item_num = 0; - std::vector objList; - for (ContainerConstIterator iter(inventoryContainer->begin()); - iter != inventoryContainer->end(); ++iter) - { - char catbuffer[ CSHandlerNamespace::smallBufferSize ]; - char stringbuffer[ CSHandlerNamespace::largeBufferSize ]; - const CachedNetworkId & objId = (*iter); - const TangibleObject * obj = safe_cast(objId.getObject()); - std::string category = "Item-"; - snprintf( catbuffer, sizeof( catbuffer ) - 1, "%s%d", category.c_str(), item_num++ ); - snprintf( stringbuffer, sizeof( stringbuffer ) - 1,"%s(%s)", Unicode::wideToNarrow( obj->getObjectName() ).c_str(), - obj->getNetworkId().getValueString().c_str() ); - catbuffer[ sizeof( catbuffer ) - 1 ] = 0; - stringbuffer[ sizeof( stringbuffer ) -1 ] = 0; - stats[ catbuffer ] = stringbuffer; - } - } - // and send it back. - std::map< std::string, std::string >::iterator it = stats.begin(); - response = "item list\r\n"; - while( it != stats.end() ) - { - response = response + it->first + ":" + it->second + "\r\n"; - it++; - } - msg.setResponse( response ); - SwgGameServer::getInstance().sendToCentralServer( msg ); - } - } - } -} - -CS_CMD( move_object ) -{ - CSHandlerNamespace::CSArgs args; - CSHandlerNamespace::getArgs( request.m_args, args ); - if( args.size() < 2 ) - return; - - NetworkId oid( args[ 1 ] ); - NetworkId player( args[ 0 ] ); - - if( !( oid.isValid() && player.isValid() ) ) - return; // bad args or this wasn't confirmed as an offline char. - if (oid < ConfigServerGame::getMaxGoldNetworkId()) - return; - else - { - ServerObject *object = ServerObject::getServerObject( oid ); - if (!( object && object->isAuthoritative() ) ) - return; - else - { - if (!NameManager::getInstance().isPlayer(player)) - return; - else - { - msg.setResponse( "Moving object:\r\n" ); - SwgGameServer::getInstance().sendToCentralServer( msg ); - CSHandlerNamespace::CSLogData data; - data[ "command" ] = "move_object"; - object->moveToPlayerAndUnload(player); - data[ "object" ] = args[ 1 ]; - data[ "target_char" ] = args[ 0 ]; - CSHandlerNamespace::log( request, data ); - - } - } - - } -} - -CS_CMD( freeze ) -{ - DEBUG_REPORT_LOG( true, ( "Trying to freeze\n" ) ); - CSHandlerNamespace::CSArgs args; - CSHandlerNamespace::getArgs( request.m_args, args ); - - if( args.size() < 1 ) - return; - - NetworkId id( args[ 0 ].c_str() ); - if( id.isValid() ) - { - ServerObject * const object = ServerWorld::findObjectByNetworkId(id); - - if( !object ) - return; - if( object->isAuthoritative() ) - { - JavaLibrary::freezePlayer( id ); - CSHandlerNamespace::CSLogData data; - data[ "target" ] = args[ 0 ]; - data[ "command" ] = "freeze"; - CSHandlerNamespace::log( request, data ); - DEBUG_REPORT_LOG( true, ( "really doing freeze %s\n", id.getValueString().c_str() ) ); - } - } - -} - -CS_CMD( unfreeze ) -{ - CSHandlerNamespace::CSArgs args; - CSHandlerNamespace::getArgs( request.m_args, args ); - - if( args.size() < 1 ) - return; - - NetworkId id( args[ 0 ].c_str() ); - if( id.isValid() ) - { - ServerObject * const object = ServerWorld::findObjectByNetworkId(id); - - if( !object ) - return; - if( object->isAuthoritative() ) - { - CSHandlerNamespace::CSLogData data; - data[ "target" ] = args[ 0 ]; - data[ "command" ] = "unfreeze"; - CSHandlerNamespace::log( request, data ); - JavaLibrary::unFreezePlayer( id ); - } - } - -} - -CS_CMD( dump_info ) -{ - // LocalRefPtr local_ref; - DEBUG_REPORT_LOG( true, ( "dump_info" ) ); - NetworkId id( request.m_args ); - if( id.isValid() ) - { - ServerObject * const object = ServerWorld::findObjectByNetworkId(id); - if (object && object->isAuthoritative()) - { - DEBUG_REPORT_LOG( true, ( "Valid ID\n" ) ); - std::string returned_value; - - returned_value = GameScriptObject::callDumpTargetInfo( id ); - std::string response; - response = "Character info dump:\r\n"; - response = response + returned_value; - msg.setResponse( response ); - SwgGameServer::getInstance().sendToCentralServer( msg ); - } - - - } - // JavaStringPtr javaResult= callStaticStringMethod(, getVarNameMid); - // JavaLibrary::convert(*javaCustomVarName, nativeCustomVarName); -} - - -CS_CMD( remove_objvar ) -{ - std::string objid; - std::string objvar; - - CSHandlerNamespace::CSArgs args; - CSHandlerNamespace::getArgs( request.m_args, args ); - if( args.size() < 2 ) - return; - - objid = args[ 0 ]; - objvar = args[ 1 ]; - - NetworkId specifiedNetworkId( objid ); - ServerObject * const object = ServerWorld::findObjectByNetworkId(specifiedNetworkId); - - if( !( object && object->isAuthoritative() ) ) - return; - - object->removeObjVarItem(objvar); - CSHandlerNamespace::CSLogData data; - data[ "target" ] = args[ 0 ]; - data[ "command" ] = "remove_objvar"; - data[ "objvar" ] = args[ 1 ]; - CSHandlerNamespace::log( request, data ); -} - -CS_CMD( set_objvar ) -{ - // set_objvar [itemid] [objvar] [value] - std::string objid; - std::string objvar; - std::string objvarvalue; - - CSHandlerNamespace::CSArgs args; - CSHandlerNamespace::getArgs( request.m_args, args ); - - if( args.size() < 3 ) - { - return; - } - - objid = args[ 0 ]; - objvar = args[ 1 ]; - objvarvalue = args[ 2 ]; - NetworkId specifiedNetworkId( objid ); - ServerObject * const object = ServerWorld::findObjectByNetworkId(specifiedNetworkId); - if( !( object && object->isAuthoritative() ) ) - { - return; - } - - - switch (getArgumentType(objvarvalue)) - { - case INT_ARGUMENT: - object->setObjVarItem(objvar, atoi(objvarvalue.c_str())); - break; - case REAL_ARGUMENT: - object->setObjVarItem(objvar, static_cast(atof(objvarvalue.c_str()))); - break; - case STRING_ARGUMENT: - object->setObjVarItem(objvar, objvarvalue); - break; - default: - break; - } - CSHandlerNamespace::CSLogData data; - data[ "target" ] = args[ 0 ]; - data[ "command" ] = "set_objvar"; - data[ "objvar" ] = args[ 1 ]; - data[ "value" ] = args[ 2 ]; - CSHandlerNamespace::log( request, data ); -} - -// this is kind of sloppy. Code is copied from consolecommandparserobjvar.cpp, and modified to work. -// realistically, it seems like objvars should internally be able to print their own value as a string without -// having to rely on code to do it each time. -CS_CMD( list_objvars ) -{ - DEBUG_REPORT_LOG( true, ( "Got list_objvars command\n" ) ); - CSHandlerNamespace::CSArgs args; - CSHandlerNamespace::getArgs( request.m_args, args ); - - if( args.size() < 1 ) - { - DEBUG_REPORT_LOG( true, ( "not enough args\n" ) ); - return; - } - - - std::string response; - - response = "Objvar list for "; - response = response + args[ 0 ] + "\r\n"; - // get the obj - - - NetworkId specifiedNetworkId = NetworkId(args[ 0 ]); - - ServerObject * const specifiedServerObject = ServerWorld::findObjectByNetworkId(specifiedNetworkId); - // iterate objvars - - if( !( specifiedServerObject && specifiedServerObject->isAuthoritative() ) ) - { - DEBUG_REPORT_LOG( true, ( "Item not found\n" ) ); - return; - } - - DynamicVariableList::NestedList objvarList = specifiedServerObject->getObjVars(); - - // char buffer[ CSHandlerNamespace::smallBufferSize ]; - // add to response string - for (DynamicVariableList::NestedList::const_iterator objVar(objvarList.begin()); objVar!=objvarList.end(); ++objVar) - { - CSHandlerNamespace::addObjVarToString( response, "", objVar ); - } - // send response. - msg.setResponse( response ); - SwgGameServer::getInstance().sendToCentralServer( msg ); - -} - - -CS_CMD( delete_object ) -{ - CSHandlerNamespace::CSArgs args; - CSHandlerNamespace::getArgs( request.m_args, args ); - - if( args.size() < 1 ) - return; - - - const NetworkId oid (args[0]); - ServerObject *object = ServerObject::getServerObject( oid ); - - if (object == NULL) - { - return; - } - else if (object->getClient()) - { - return; - } - else if (!object->isAuthoritative()) - { - return; - } - else - { - CSHandlerNamespace::CSLogData data; - data[ "target" ] = args[ 0 ]; - data[ "command" ] = "delete_object"; - CSHandlerNamespace::log( request, data ); - object->permanentlyDestroy(DeleteReasons::God); - } - return; -} - -CS_CMD( rename_player ) -{ - CSHandlerNamespace::CSArgs args; - DEBUG_REPORT_LOG( true, ( "rename_player" ) ); - CSHandlerNamespace::getArgs( request.m_args, args ); - if( args.size() < 3 ) - { - return; - } - std::transform( args[ 0 ].begin(), args[ 0 ].end(), args[ 0 ].begin(), tolower ); - - - NetworkId player_id = NameManager::getInstance().getPlayerId( args[ 0 ] ); - - // only execute on the authoritative object. exit early for all others - // to avoid spam. - ServerObject *object = ServerObject::getServerObject( player_id ); - if( !( object && object->isAuthoritative() ) ) - { - return; - } - - std::string lowertarget = args[1]; - std::transform( lowertarget.begin(), lowertarget.end(), lowertarget.begin(), tolower ); - - NetworkId target_check = NameManager::getInstance().getPlayerId( lowertarget ); - if( target_check.isValid() ) - { - // invalid name, already used by someone. - msg.setResponse( "Could not rename player, name in use:\r\n" ); - SwgGameServer::getInstance().sendToCentralServer( msg ); - return; - } - if( player_id.isValid() ) - { - // null id to pass to the playercreationmanager. - NetworkId source( "0" ); - - DEBUG_REPORT_LOG( true, ( "Attempting to rename %s.", args[ 0 ].c_str() ) ); - PlayerCreationManagerServer::renamePlayer( static_cast(RenameCharacterMessageEx::RCMS_cs_tool), NameManager::getInstance().getPlayerStationId(player_id), player_id, Unicode::narrowToWide( args[ 1 ] ), object->getAssignedObjectName(), source ); - CSHandlerNamespace::CSLogData data; - msg.setResponse( "Rename player complete:\r\n" ); - SwgGameServer::getInstance().sendToCentralServer( msg ); - data[ "target" ] = args[ 0 ]; - data[ "command" ] = "rename_player"; - data[ "new_name" ] = args[ 1 ]; - CSHandlerNamespace::log( request, data ); - } - else - { - DEBUG_REPORT_LOG( true, ( "Could not rename player. %s not found", args[ 0 ].c_str() ) ); - } - -} - -CS_CMD( set_bank_credits ) -{ - CSHandlerNamespace::CSArgs args; - CSHandlerNamespace::getArgs( request.m_args, args ); - if( args.size() < 2 ) - { - return; - } - - std::transform( args[ 0 ].begin(), args[ 0 ].end(), args[ 0 ].begin(), tolower ); - int amount = atoi( args[ 1 ].c_str() ); - - DEBUG_REPORT_LOG( true, ( "set_bank_credits: %d\n", amount ) ); - NetworkId player_id = NameManager::getInstance().getPlayerId( args[ 0 ] ); - if( player_id.isValid() ) - { - CreatureObject* creatureActor = CreatureObject::getCreatureObject(player_id); - PlayerObject const * const player = PlayerCreatureController::getPlayerObject(creatureActor); - - if( ( player != NULL ) && ( player->isAuthoritative() ) ) - { - amount -= creatureActor->getBankBalance(); - DEBUG_REPORT_LOG( true, ( "Amount to modify by: %d (%d current balance)\n", amount, creatureActor->getBankBalance() ) ); - if( amount < 0 ) - { - DEBUG_REPORT_LOG( true, ( "Transferring to\n" ) ); - creatureActor->transferBankCreditsTo( "cs_" "stub", amount * -1 ); - } - else - { - DEBUG_REPORT_LOG( true, ( "Transferring from\n" ) ); - creatureActor->transferBankCreditsFrom( "cs_" "stub", amount ); - - } - msg.setResponse( "Successfully modified bank amount" ); - CSHandlerNamespace::CSLogData data; - data[ "target" ] = args[ 0 ]; - data[ "command" ] = "set_bank_credits"; - data[ "amount" ] = args[ 1 ]; - CSHandlerNamespace::log( request, data ); - SwgGameServer::getInstance().sendToCentralServer( msg ); - } - } - -} - -CS_CMD( get_pc_info ) -{ - // see if we have the character. - std::transform( request.m_args.begin(), request.m_args.end(), request.m_args.begin(), tolower ); - DEBUG_REPORT_LOG( true, ( "Got get_pc_info for %s\n", request.m_args.c_str() ) ); - NetworkId player_id = NameManager::getInstance().getPlayerId( request.m_args ); - if( player_id.isValid() ) - { - DEBUG_REPORT_LOG( true, ( "Found player.\n" ) ); - // get the info on the player. - const CreatureObject* const creatureActor = CreatureObject::getCreatureObject(player_id); - if (!( creatureActor && creatureActor->isAuthoritative() ) ) - { - return; - } - - char stringbuffer[ CSHandlerNamespace::smallBufferSize ]; // for formatted output. - std::map< std::string, std::string > stats; - - //get the bind location - Vector bindLoc; - std::string bindPlanet; - NetworkId bindId; - if (creatureActor->getObjVars().hasItem("bind.facility")) - { - creatureActor->getObjVars().getItem("bind.facility", bindId); - } - if(bindId != NetworkId::cms_invalid) - { - const ServerObject* const bindObject = ServerObject::getServerObject(bindId); - if (bindObject != NULL) - { - bindLoc = bindObject->getPosition_w(); - snprintf( stringbuffer, sizeof( stringbuffer ) -1, "%02f %02f %02f", bindLoc.x, bindLoc.y, bindLoc.z ); - stringbuffer[ sizeof( stringbuffer ) - 1 ] = 0; - stats[ "Bind Location" ] = stringbuffer; - bindPlanet = bindObject->getSceneId(); - stats[ "Bind Planet" ] = bindPlanet; - } - } - - //get the bankId - // Vector bankLoc(0, 0, 0); - std::string bankPlanet; - if (creatureActor->getObjVars().hasItem("banking_bankid")) - { - creatureActor->getObjVars().getItem("banking_bankid", bankPlanet); - stats[ "Bank Planet" ] = bankPlanet; - } - - - const ServerObject * inventory = creatureActor->getInventory(); - if( inventory ) - { - - const VolumeContainer * inventoryContainer = ContainerInterface::getVolumeContainer(*inventory); - if (inventoryContainer ) - { - int item_num = 0; - CSHandlerNamespace::addItemInfo(inventoryContainer,item_num,stats); - } - } - - - int item_num = 0; - const SlottedContainer * p_equipment = creatureActor->getSlottedContainerProperty(); - for( ContainerConstIterator it = p_equipment->begin(); - it != p_equipment->end(); - it++ ) - { - Object * const object = (*it).getObject(); - char catbuffer[ CSHandlerNamespace::smallBufferSize ]; - - if( object && object->asServerObject() ) - { - snprintf( catbuffer, sizeof( catbuffer ) - 1, "Equipment-%d", item_num++ ); - catbuffer[ sizeof( catbuffer ) - 1 ] = 0; - snprintf( stringbuffer, sizeof( stringbuffer ) -1, "%s(%s)", Unicode::wideToNarrow( object->asServerObject()->getObjectName() ).c_str(), object->asServerObject()->getNetworkId().getValueString().c_str() ); - stringbuffer[ sizeof( stringbuffer ) - 1 ] = 0; - stats[ catbuffer ] = stringbuffer; - } - - } - - //get the residence location - Vector resLoc; - std::string resPlanet; - - /* creatureActor->getAllBuffs(); - creatureActor->getAllShipsInDatapad();*/ - - // attributes - addIntData( stats, "Action", creatureActor->getAttribute( Attributes::Action ) ); - addIntData( stats, "Constitution", creatureActor->getAttribute( Attributes::Constitution ) ); - addIntData( stats, "Health", creatureActor->getAttribute( Attributes::Health ) ); - addIntData( stats, "Mind", creatureActor->getAttribute( Attributes::Mind ) ); - addIntData( stats, "Stamina", creatureActor->getAttribute( Attributes::Stamina ) ); - addIntData( stats, "Willpower", creatureActor->getAttribute( Attributes::Willpower ) ); - - stats[ "Character ID" ] = player_id.getValueString(); - - // skills - - const CreatureObject::SkillList & skills = creatureActor->getSkillList(); - int temp_int = 0; - for( CreatureObject::SkillList::iterator slit = skills.begin(); - slit != skills.end(); - ++slit ) - { - snprintf( stringbuffer, sizeof( stringbuffer ) - 1, "%d", temp_int ); - stringbuffer[ sizeof( stringbuffer ) -1 ] = 0; - std::string category = "Skill-"; - category = category + stringbuffer; - stats[ category ] = ( *slit )->getSkillName(); - temp_int++; - } - - // add experience into the data - const std::map< std::string, int > & exp = creatureActor->getExperiencePoints(); - - for( std::map< std::string, int >::const_iterator expit = exp.begin(); - expit != exp.end(); - ++expit ) - { - std::string category = "Experience-"; - category += expit->first; - addIntData( stats, category, expit->second ); - } - - // money - snprintf( stringbuffer, sizeof( stringbuffer ) - 1, "%d", creatureActor->getCashBalance() ); - stringbuffer[ sizeof( stringbuffer ) - 1 ] = 0; - stats[ "Credits" ] = stringbuffer; - - snprintf( stringbuffer, sizeof( stringbuffer ) - 1, "%d", creatureActor->getBankBalance() ); - stringbuffer[ sizeof( stringbuffer ) - 1 ] = 0; - stats[ "Bank Credits" ] = stringbuffer; - - // residence info - PlayerObject const * const player = PlayerCreatureController::getPlayerObject(creatureActor); - if (player != NULL) - { - NetworkId houseNetworkId = creatureActor->getHouse(); - const ServerObject* const resObject = ServerObject::getServerObject(houseNetworkId); - if (resObject != NULL) - { - resLoc = resObject->getPosition_w(); - snprintf( stringbuffer, sizeof( stringbuffer ) - 1 , "%02f %02f %02f", resLoc.x, resLoc.y, resLoc.z ); - stringbuffer[ sizeof( stringbuffer ) - 1 ] = 0; - stats[ "Residence Location" ] = stringbuffer; - resPlanet = resObject->getSceneId(); - stats[ "Residence Planet" ] = resPlanet; - } - addIntData( stats, "Account ID", player->getStationId() ); - - } - - //get the spouse's name - Unicode::String spouseName = Unicode::emptyString; - if (creatureActor->getObjVars().hasItem("marriage.spouseName")) - { - creatureActor->getObjVars().getItem("marriage.spouseName", spouseName); - stats[ "Spouse Name" ] = Unicode::wideToNarrow( spouseName ); - } - - //get the number of used lots - int lots = creatureActor->getMaxNumberOfLots(); - - if(player) - { - int lotsUsed = player->getAccountNumLots(); - lots -= lotsUsed; - snprintf( stringbuffer, sizeof( stringbuffer ) - 1, "%d", lots ); - stringbuffer[ sizeof( stringbuffer ) - 1 ] = 0; - stats[ "Lots Available" ] = stringbuffer; - } - - //get the faction standing - int factionAlignment = creatureActor->getPvpFaction(); - snprintf( stringbuffer, sizeof( stringbuffer ) - 1, "%d", factionAlignment ); - stringbuffer[ sizeof( stringbuffer ) - 1 ] = 0; - stats[ "Faction" ] = stringbuffer; - int factionDeclareType = creatureActor->getPvpType(); - snprintf( stringbuffer, sizeof( stringbuffer ) - 1, "%d", factionDeclareType ); - stringbuffer[ sizeof( stringbuffer ) - 1 ] = 0; - stats[ "PvP Type" ] = stringbuffer; - - addIntData( stats, "Guild ID", creatureActor->getGuildId() ); - - // TODO: Move this into its own function. - - // build the response based on our map. - std:: string response = "Stats for player "; - response += request.m_args + "\r\n"; - std::map< std::string, std::string >::iterator statit = stats.begin(); - while( statit != stats.end() ) - { - response += statit->first + ": " + statit->second + "\r\n"; - ++statit; - } - msg.setResponse( response ); - SwgGameServer::getInstance().sendToCentralServer( msg ); - } -} - -CS_CMD( undelete_item ) -{ - CSHandlerNamespace::CSArgs args; - CSHandlerNamespace::getArgs( request.m_args, args ); - if(args.size() < 3) - return; - NetworkId characterId(args[0]); - NetworkId itemId(args[ 1 ]); - bool bMove = false; - if (args[2] == "move") - { - bMove = true; - } - GenericValueTypeMessage, std::string>, bool > > dbmsg("UndeleteItemForCsMessage", std::make_pair(std::make_pair(std::make_pair(characterId, itemId), request.m_args), bMove)); - GameServer::getInstance().sendToDatabaseServer(dbmsg); - CSHandlerNamespace::CSLogData data; - data["character_id"]=args[0]; - data[ "item_id"] = args[ 1 ]; - data[ "command" ] = "undelete_item"; - CSHandlerNamespace::log( request, data ); - msg.setResponse( "Undelete command sent.\r\n" ); - -} - -CS_CMD( get_player_id ) -{ - std::transform( request.m_args.begin(), request.m_args.end(), request.m_args.begin(), tolower ); - - CSHandlerNamespace::CSArgs args; - CSHandlerNamespace::getArgs( request.m_args, args ); - if( args.size() > 0 ) - { - NetworkId player_id = NameManager::getInstance().getPlayerId( args[ 0 ] ); - // build the response - std::string response; - response = "Player Id found\r\ncharactername:" + args[ 0 ] + "\r\ncharacter id:" + player_id.getValueString() + "\r\n"; - - msg.setResponse( response ); - SwgGameServer::getInstance().sendToCentralServer( msg ); - } -} - - -CSHandlerEntry::CSHandlerEntry() : -access( 0 ), -handlerFunc( 0 ) -{ - -} - -CSHandlerEntry::CSHandlerEntry( const std::string & name, uint32 accessLevel, CSHandlerFunc handler ) : -sCommand( name ), -access( accessLevel ), -handlerFunc( handler ) -{ -} - -CSHandlerRequest::CSHandlerRequest( const std::string & command, - const std::string & args, - const uint32 access, - const std::string & username ) : -m_command( command ), -m_args( args ), -m_access( access ), -m_name( username ) -{ -} diff --git a/src/game/server/application/SwgGameServer/src/shared/core/CSHandler.h b/src/game/server/application/SwgGameServer/src/shared/core/CSHandler.h deleted file mode 100644 index d41eac665..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/core/CSHandler.h +++ /dev/null @@ -1,91 +0,0 @@ -//CSHandler.h -// copyright 2005 Sony Online Entertainment -//----------------------------------------------- -// handler class for CS requests. - -#ifndef _CSHANDLER_H -#define _CSHANDLER_H - - - - -#define DECLARE_CS_HANDLER( _name_ ) void handle_##_name_( CSHandlerRequest & request, GameServerCSResponseMessage & msg ); - -class GameServerCSRequestMessage; -class GameServerCSResponseMessage; - -class CSHandlerRequest -{ -public: - CSHandlerRequest( const std::string & command, - const std::string & args, - const uint32 access, - const std::string & username ); - - std::string m_command; - std::string m_args; - uint32 m_access; - std::string m_name; -}; - -class CSHandler -{ - public: - - static void remove(); - - void handle( GameServerCSRequestMessage & request ); - static void install(); - static CSHandler& getInstance(); - - // handlers - DECLARE_CS_HANDLER( get_pc_info ); - DECLARE_CS_HANDLER( set_bank_credits ); - DECLARE_CS_HANDLER( undelete_item ); - DECLARE_CS_HANDLER( list_objvars ); - DECLARE_CS_HANDLER( set_objvar ); - DECLARE_CS_HANDLER( remove_objvar ); - DECLARE_CS_HANDLER( dump_info ); - DECLARE_CS_HANDLER( rename_player ); - - DECLARE_CS_HANDLER( freeze ); - DECLARE_CS_HANDLER( unfreeze ); - - DECLARE_CS_HANDLER( get_player_id ); - DECLARE_CS_HANDLER( get_player_items ); - - DECLARE_CS_HANDLER( move_object ); - DECLARE_CS_HANDLER( delete_object ); - - DECLARE_CS_HANDLER( create_crafted_object ); - - DECLARE_CS_HANDLER( adjust_lots ); - - DECLARE_CS_HANDLER( warp_player ); - - private: - void registerCommands(); - - static CSHandler * sm_instance; - CSHandler(); - virtual ~CSHandler(); - -}; - - -typedef void( CSHandler::*CSHandlerFunc )( CSHandlerRequest &, GameServerCSResponseMessage & ); - -class CSHandlerEntry -{ -public: - CSHandlerEntry(); - CSHandlerEntry( const std::string & name, uint32 access, CSHandlerFunc handler ); - std::string sCommand; - uint32 access; - CSHandlerFunc handlerFunc; - -private: - -}; -#endif // _CSHANDLER_H - diff --git a/src/game/server/application/SwgGameServer/src/shared/core/FirstSwgGameServer.h b/src/game/server/application/SwgGameServer/src/shared/core/FirstSwgGameServer.h deleted file mode 100644 index a7c23bb01..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/core/FirstSwgGameServer.h +++ /dev/null @@ -1,25 +0,0 @@ -// ====================================================================== -// -// FirstSwgGameServer.h -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_FirstSwgGameServer_H -#define INCLUDED_FirstSwgGameServer_H - -// ====================================================================== - -#pragma warning ( disable : 4503 ) // name truncated (STL) -#include "../../../../../../engine/shared/library/sharedFoundation/include/public/sharedFoundation/FirstSharedFoundation.h" -#include "sharedDebug/FirstSharedDebug.h" -#include "sharedMemoryManager/FirstSharedMemoryManager.h" - -#include "StringId.h" - - -// ====================================================================== - -#endif - - diff --git a/src/game/server/application/SwgGameServer/src/shared/core/SwgGameServer.cpp b/src/game/server/application/SwgGameServer/src/shared/core/SwgGameServer.cpp deleted file mode 100644 index 1b310ffd5..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/core/SwgGameServer.cpp +++ /dev/null @@ -1,141 +0,0 @@ -// ====================================================================== -// -// SwgGameServer.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "FirstSwgGameServer.h" -#include "SwgGameServer/SwgGameServer.h" -#include "serverGame/CommoditiesMarket.h" -#include "serverGame/PreloadManager.h" -#include "serverNetworkMessages/BountyHunterTargetListMessage.h" -#include "serverNetworkMessages/GameServerCSRequestMessage.h" -#include "serverNetworkMessages/GameServerCSResponseMessage.h" -#include "sharedDebug/Profiler.h" -#include "sharedGame/AppearanceManager.h" -#include "sharedLog/Log.h" -#include "sharedMessageDispatch/MessageManager.h" -#include "sharedNetworkMessages/GenericValueTypeMessage.h" -#include "SwgGameServer/CombatEngine.h" -#include "SwgGameServer/JediManagerObject.h" -#include "SwgGameServer/ServerJediManagerObjectTemplate.h" -#include "SwgGameServer/SwgServerCreatureObjectTemplate.h" -#include "SwgGameServer/SwgServerPlayerObjectTemplate.h" -#include "SwgGameServer/SwgServerUniverse.h" -#include "SwgGameServer/CSHandler.h" - - -//#undef PROFILE_INDIVIDUAL_MESSAGES -#define PROFILE_INDIVIDUAL_MESSAGES 1 - -#ifdef PROFILE_INDIVIDUAL_MESSAGES - #define MESSAGE_PROFILER_BLOCK(a) PROFILER_AUTO_BLOCK_DEFINE(a) -#else - #define MESSAGE_PROFILER_BLOCK(a) NOP -#endif - - -//----------------------------------------------------------------------- - -SwgGameServer::SwgGameServer() : - GameServer() -{ - connectToMessage("BountyHunterTargetListMessage"); - connectToMessage("DeleteCharacterNotificationMessage"); -} - -//----------------------------------------------------------------------- - -SwgGameServer::~SwgGameServer() -{ -} - -//----------------------------------------------------------------------- - -void SwgGameServer::install() -{ - DEBUG_FATAL (ms_instance != NULL, ("already installed")); - ms_instance = new SwgGameServer; - - SwgServerUniverse::install(); - CombatEngine::install(); - ServerJediManagerObjectTemplate::install(); - SwgServerCreatureObjectTemplate::install(); - SwgServerPlayerObjectTemplate::install(); - // the preload manager MUST be installed after the SwgServer... templates - PreloadManager::install(); - CommoditiesMarket::install(); - - CSHandler::install(); -} - -//----------------------------------------------------------------------- - -void SwgGameServer::initialize() -{ - GameServer::initialize(); -} - -//----------------------------------------------------------------------- - -void SwgGameServer::shutdown() -{ - GameServer::shutdown(); - CommoditiesMarket::remove(); - CSHandler::remove(); -} - -void SwgGameServer::handleCSRequest( GameServerCSRequestMessage & request ) -{ - CSHandler::getInstance().handle( request ); -} - -//----------------------------------------------------------------------- - -void SwgGameServer::receiveMessage(const MessageDispatch::Emitter & source, const MessageDispatch::MessageBase & message) -{ - static Archive::ReadIterator ri; - static Archive::ByteStream bs; - - PROFILER_AUTO_BLOCK_DEFINE("SwgGameServer::receiveMessage"); - - if (message.isType("BountyHunterTargetListMessage")) - { - DEBUG_REPORT_LOG(true, ("SwgGameServer: got BountyHunterTargetListMessage\n")); - MESSAGE_PROFILER_BLOCK("BountyHunterTargetListMessage"); - ri = static_cast(message).getByteStream().begin(); - const BountyHunterTargetListMessage * msg = new BountyHunterTargetListMessage(ri); - - JediManagerObject * jediManager = static_cast( - ServerUniverse::getInstance()).getJediManager(); - - if (jediManager != NULL && jediManager->isAuthoritative()) - { - jediManager->addJediBounties(*msg); - delete msg; - } - else - { - LOG("BountyHunterTargetList", ("Queuing BountyHunterTargetList from DB because JediManagerObject is not yet ready")); - JediManagerObject::queueBountyHunterTargetListFromDB(msg); - } - } - else if (message.isType("DeleteCharacterNotificationMessage")) - { - ri = static_cast(message).getByteStream().begin(); - const GenericValueTypeMessage msg(ri); - - JediManagerObject * jediManager = static_cast( - ServerUniverse::getInstance()).getJediManager(); - - if (jediManager != NULL) - { - jediManager->characterBeingDeleted(msg.getValue()); - } - } - - // GameServer::receiveMessage does some bookkeeping stuff, so always call it - GameServer::receiveMessage(source, message); -} - diff --git a/src/game/server/application/SwgGameServer/src/shared/core/SwgGameServer.h b/src/game/server/application/SwgGameServer/src/shared/core/SwgGameServer.h deleted file mode 100644 index 1e5c27a41..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/core/SwgGameServer.h +++ /dev/null @@ -1,36 +0,0 @@ -// ====================================================================== -// -// SwgGameServer.h -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_SwgGameServer_H -#define INCLUDED_SwgGameServer_H - -#include "serverGame/GameServer.h" - -class SwgGameServer : public GameServer -{ -public: - - virtual ~SwgGameServer(); - - static void install(); - - virtual void receiveMessage(const MessageDispatch::Emitter & source, const MessageDispatch::MessageBase & message); - - virtual void handleCSRequest( GameServerCSRequestMessage & request ); - -protected: - SwgGameServer(); - virtual void initialize (); - virtual void shutdown (); - -private: - SwgGameServer (const SwgGameServer & source); - SwgGameServer & operator = (const SwgGameServer & rhs); -}; - - -#endif diff --git a/src/game/server/application/SwgGameServer/src/shared/core/SwgServerUniverse.cpp b/src/game/server/application/SwgGameServer/src/shared/core/SwgServerUniverse.cpp deleted file mode 100644 index 3d743c935..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/core/SwgServerUniverse.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// ====================================================================== -// -// SwgServerUniverse.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "FirstSwgGameServer.h" -#include "SwgGameServer/SwgServerUniverse.h" -#include "serverGame/ConfigServerGame.h" -#include "serverGame/ServerObjectTemplate.h" -#include "serverGame/ServerWorld.h" -#include "sharedObject/ObjectTemplateList.h" -#include "SwgGameServer/JediManagerObject.h" - - -// ====================================================================== - -void SwgServerUniverse::install() -{ - Universe::installDerived(new SwgServerUniverse); - ServerUniverse::install(); -} - -// ---------------------------------------------------------------------- - -SwgServerUniverse::SwgServerUniverse() : - ServerUniverse (), - m_jediManager (NULL) -{ -} - -// ---------------------------------------------------------------------- - -SwgServerUniverse::~SwgServerUniverse() -{ -} - -// ---------------------------------------------------------------------- - -/** - * Check the Universe Objects. Spawn new objects as - * needed, update the amount remaining on all the resource pools, etc. - * - * May be time consuming, so this should not be called every frame. - */ - -void SwgServerUniverse::updateAndValidateData() -{ - WARNING_STRICT_FATAL(!isAuthoritative(), ("UpdateAndValidateData() should " - "only be called on the process that is authoritative for UniverseObjects.\n")); - - // create Jedi manager - if (m_jediManager == NULL) - { - const ServerObjectTemplate * objTemplate = safe_cast(ObjectTemplateList::fetch(ConfigServerGame::getJediManagerTemplate())); - m_jediManager = safe_cast(ServerWorld::createNewObject(*objTemplate, Transform::identity, 0, false)); - NOT_NULL(m_jediManager); - registerJediManager(*m_jediManager); - m_jediManager->addToWorld(); - objTemplate->releaseReference(); - } - - ServerUniverse::updateAndValidateData(); -} - - -// ====================================================================== diff --git a/src/game/server/application/SwgGameServer/src/shared/core/SwgServerUniverse.h b/src/game/server/application/SwgGameServer/src/shared/core/SwgServerUniverse.h deleted file mode 100644 index 624f2d075..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/core/SwgServerUniverse.h +++ /dev/null @@ -1,62 +0,0 @@ -// ====================================================================== -// -// SwgServerUniverse.h -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_SwgServerUniverse_H -#define INCLUDED_SwgServerUniverse_H - -#include "serverGame/ServerUniverse.h" - -class JediManagerObject; - - -// ====================================================================== - -/** -* Singleton that manages Universe objects and functions that are global -* to the entire game universe. -*/ -class SwgServerUniverse : public ServerUniverse -{ -public: - static void install(); - -public: - JediManagerObject * getJediManager () const; - void registerJediManager(JediManagerObject & jediManager); - -protected: - virtual void updateAndValidateData(); - -private: - JediManagerObject * m_jediManager; - -private: - SwgServerUniverse(); - virtual ~SwgServerUniverse(); - - SwgServerUniverse(SwgServerUniverse const &); - SwgServerUniverse & operator=(SwgServerUniverse const &); -}; - -// ====================================================================== - -inline JediManagerObject * SwgServerUniverse::getJediManager() const -{ - return m_jediManager; -} - -// ---------------------------------------------------------------------- - -inline void SwgServerUniverse::registerJediManager(JediManagerObject & jediManager) -{ - m_jediManager = &jediManager; -} - -// ====================================================================== - - -#endif diff --git a/src/game/server/application/SwgGameServer/src/shared/lint/ServerObjectLint.cpp b/src/game/server/application/SwgGameServer/src/shared/lint/ServerObjectLint.cpp deleted file mode 100644 index a8dd455b6..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/lint/ServerObjectLint.cpp +++ /dev/null @@ -1,122 +0,0 @@ - - -#include "FirstSwgGameServer.h" -#include "ServerObjectLint.h" - -#include "serverGame/ObjectIdManager.h" -#include "serverGame/ServerWorld.h" -#include "sharedFoundation/NetworkId.h" - -#include "serverGame/ServerArmorTemplate.h" -#include "serverGame/ServerBuildingObjectTemplate.h" -#include "serverGame/ServerCellObjectTemplate.h" -#include "serverGame/ServerCreatureObjectTemplate.h" -#include "serverGame/ServerDraftSchematicObjectTemplate.h" -#include "serverGame/ServerInstallationObjectTemplate.h" -#include "serverGame/ServerMissionObjectTemplate.h" -#include "serverGame/ServerManufactureSchematicObjectTemplate.h" -#include "serverGame/ServerMissionObjectTemplate.h" -#include "serverGame/ServerObject.h" -#include "serverGame/ServerObjectTemplate.h" -#include "serverGame/ServerPlanetObjectTemplate.h" -#include "serverGame/ServerResourceContainerObjectTemplate.h" -#include "serverGame/ServerStaticObjectTemplate.h" -#include "serverGame/ServerUniverse.h" -#include "serverGame/ServerVehicleObjectTemplate.h" -#include "serverGame/ServerWeaponObjectTemplate.h" - -#include "sharedGame/SharedBuildingObjectTemplate.h" -#include "sharedGame/SharedCellObjectTemplate.h" -#include "sharedGame/SharedCreatureObjectTemplate.h" -#include "sharedGame/SharedDraftSchematicObjectTemplate.h" -#include "sharedGame/SharedInstallationObjectTemplate.h" -#include "sharedGame/SharedResourceContainerObjectTemplate.h" -#include "sharedGame/SharedStaticObjectTemplate.h" -#include "sharedGame/SharedTerrainSurfaceObjectTemplate.h" -#include "sharedGame/SharedVehicleObjectTemplate.h" -#include "sharedGame/SharedWeaponObjectTemplate.h" - -#include - -void ServerObjectLint::install() -{ - ObjectIdManager::getInstance().addBlock(100,10000000); //lint !e747 Significant prototype coercion (arg. no. 1) int to long long -} - -void ServerObjectLint::run(const std::vector & templateList) -{ - install(); - - /* - ServerArmorTemplate::install(true); - ServerBuildingObjectTemplate::install(true); - ServerCellObjectTemplate::install(); - ServerCreatureObjectTemplate::install(true); - ServerDraftSchematicObjectTemplate::install(true); - ServerInstallationObjectTemplate::install(true); - ServerIntangibleObjectTemplate::install(true); - ServerManufactureSchematicObjectTemplate::install(true); - ServerMissionBoardObjectTemplate::install(true); - ServerMissionObjectTemplate::install(true); - ServerObjectTemplate::install(true); - ServerPlanetObjectTemplate::install(true); - ServerResourceClassObjectTemplate::install(true); - ServerResourceContainerObjectTemplate::install(true); - ServerResourcePoolObjectTemplate::install(true); - ServerResourceTypeObjectTemplate::install(true); - ServerStaticObjectTemplate::install(true); - ServerTangibleObjectTemplate::install(true); - ServerVehicleObjectTemplate::install(true); - ServerWeaponObjectTemplate::install(true); - - SharedBuildingObjectTemplate::install(true); - SharedCellObjectTemplate::install(true); - SharedCreatureObjectTemplate::install(true); - SharedDraftSchematicObjectTemplate::install(true); - SharedInstallationObjectTemplate::install(true); - SharedIntangibleObjectTemplate::install(true); - SharedObjectTemplate::install(true); - SharedResourceContainerObjectTemplate::install(true); - SharedStaticObjectTemplate::install(true); - SharedTangibleObjectTemplate::install(true); - SharedTerrainSurfaceObjectTemplate::install(true); - SharedVehicleObjectTemplate::install(true); - SharedWeaponObjectTemplate::install(true); -*/ - ServerWorld::install(); - - - std::vector::const_iterator i = templateList.begin(); - FILE * output = fopen("server_object_lint.sln", "w"); //lint !e64 Type mismatch (initialization) (struct _IO_FILE * = int) - FATAL(!output, ("Could not create output file")); - for (; i != templateList.end(); ++i) - { - if (i->find("base") != std::string::npos) - { - //Don't try to instantiate base templtates - IGNORE_RETURN(fprintf(output, "Skipping %s because it is a base class.\n", i->c_str())); //lint !e64 !e119 - continue; - } - DEBUG_REPORT_LOG(true, ("Now processing %s...\n", i->c_str())); - IGNORE_RETURN(fprintf(output, "Now processing %s...\n", i->c_str()));//lint !e64 !e119 - IGNORE_RETURN(fflush(output)); - - ServerObject* obj = ServerWorld::createObjectFromTemplate((*i), NetworkId(static_cast(1))); - DEBUG_REPORT_LOG(!obj, ("***ERROR: Could not create %s\n", i->c_str())); - DEBUG_REPORT_LOG(obj,("Successfully created %s\n", i->c_str())); - if (!obj) - IGNORE_RETURN(fprintf(output, "***ERROR: Could not create %s\n", i->c_str())); //lint !e64 !e119 - else - { - IGNORE_RETURN(fprintf(output, "Successfully created %s\n", i->c_str())); //lint !e64 !e119 - obj->serverObjectInitializeFirstTimeObject(0, Transform::identity); - delete obj; - obj = 0; - } - } - DEBUG_REPORT_LOG(true, ("-----Done with Server Objects ----\n")); - IGNORE_RETURN(fprintf(output, ("-----Done with Server Objects ----\n"))); //lint !e64 !e119 - IGNORE_RETURN(fclose(output)); - -} - diff --git a/src/game/server/application/SwgGameServer/src/shared/lint/ServerObjectLint.h b/src/game/server/application/SwgGameServer/src/shared/lint/ServerObjectLint.h deleted file mode 100644 index dee4865a6..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/lint/ServerObjectLint.h +++ /dev/null @@ -1,16 +0,0 @@ - -#include -#include - - -class ServerObjectLint -{ - public: - static void run(const std::vector & templateList); - static void install(); - - private: - ServerObjectLint(); - ServerObjectLint(const ServerObjectLint&); - ServerObjectLint& operator= (const ServerObjectLint&); -}; diff --git a/src/game/server/application/SwgGameServer/src/shared/object/JediManagerObject.cpp b/src/game/server/application/SwgGameServer/src/shared/object/JediManagerObject.cpp deleted file mode 100644 index a2b4f8825..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/object/JediManagerObject.cpp +++ /dev/null @@ -1,1489 +0,0 @@ -// ====================================================================== -// -// JediManagerObject.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "FirstSwgGameServer.h" -#include "SwgGameServer/JediManagerObject.h" - -#include "UnicodeUtils.h" -#include "boost/smart_ptr.hpp" -#include "serverGame/ConfigServerGame.h" -#include "serverGame/GameServer.h" -#include "serverGame/MessageToQueue.h" -#include "serverGame/PlayerObject.h" -#include "serverNetworkMessages/BountyHunterTargetListMessage.h" -#include "serverNetworkMessages/BountyHunterTargetMessage.h" -#include "serverScript/GameScriptObject.h" -#include "serverScript/ScriptDictionary.h" -#include "serverScript/ScriptParameters.h" -#include "sharedFoundation/GameControllerMessage.h" -#include "sharedLog/Log.h" -#include "sharedNetworkMessages/MessageQueueGenericValueType.h" -#include "sharedObject/NetworkIdManager.h" -#include "SwgGameServer/JediManagerController.h" -#include "SwgGameServer/ServerJediManagerObjectTemplate.h" -#include "SwgGameServer/SwgCreatureObject.h" -#include "SwgGameServer/SwgServerUniverse.h" -#include "swgServerNetworkMessages/MessageQueueJediData.h" -#include "swgServerNetworkMessages/MessageQueueJediLocation.h" -#include "swgServerNetworkMessages/MessageQueueRequestJediBounty.h" - - -static const int IGNORE_JEDI_STAT = INT_MAX; - - -// ====================================================================== - -namespace JediManagerObjectNamespace -{ - // the bounty hunter target list loaded from the DB; we store it here - // and wait until the JediManagerObject object is created, and then - // read it into the JediManagerObject object - const BountyHunterTargetListMessage * s_queuedBountyHunterTargetListFromDB = NULL; -} - -using namespace JediManagerObjectNamespace; - -// ---------------------------------------------------------------------- - -/** - * Class constructor. - */ -JediManagerObject::JediManagerObject(const ServerJediManagerObjectTemplate *newTemplate) : - UniverseObject(newTemplate), - m_jediId(), - m_holes(), - m_jediName(), - m_jediLocation(), - m_jediScene(), - m_jediVisibility(), - m_jediBountyValue(), - m_jediLevel(), - m_jediBounties(), - m_jediHoursAlive(), - m_jediState(), - m_jediOnline(), - m_jediSpentJediSkillPoints(), - m_jediFaction(), - m_jediScriptData(), - m_jediScriptDataNames(), - m_bountyHunterTargetsReceivedFromDB(false) -{ - addMembersToPackages(); -} // JediManagerObject::JediManagerObject - -// ---------------------------------------------------------------------- - -/** - * Class destructor. - */ -JediManagerObject::~JediManagerObject() -{ -} // JediManagerObject::~JediManagerObject - -// ---------------------------------------------------------------------- - -/** - * Sets up auto-sync data. - */ -void JediManagerObject::addMembersToPackages() -{ - addServerVariable_np (m_jediId); - addServerVariable_np (m_holes); - addServerVariable_np (m_jediName); - addServerVariable_np (m_jediLocation); - addServerVariable_np (m_jediScene); - addServerVariable_np (m_jediVisibility); - addServerVariable_np (m_jediBountyValue); - addServerVariable_np (m_jediLevel); - addServerVariable_np (m_jediBounties); - addServerVariable_np (m_bountyHunters); - addServerVariable_np (m_jediHoursAlive); - addServerVariable_np (m_jediState); - addServerVariable_np (m_jediOnline); - addServerVariable_np (m_jediSpentJediSkillPoints); - addServerVariable_np (m_jediFaction); - addServerVariable_np (m_jediScriptData); - addServerVariable_np (m_jediScriptDataNames); - addServerVariable_np (m_bountyHunterTargetsReceivedFromDB); -} // JediManagerObject::addMembersToPackages - -// ---------------------------------------------------------------------- - -/** - * Initializes data for a newly created object. - */ -void JediManagerObject::initializeFirstTimeObject() -{ - UniverseObject::initializeFirstTimeObject(); -} // JediManagerObject::initializeFirstTimeObject - -// ---------------------------------------------------------------------- - -/** - * Initializes an object just proxied. - */ -void JediManagerObject::endBaselines() -{ - UniverseObject::endBaselines(); -} // JediManagerObject::endBaselines - -// ---------------------------------------------------------------------- - -/** - * Final setup for universe objects. Registers this object with the universe. - */ -void JediManagerObject::setupUniverse() -{ - static_cast(SwgServerUniverse::getInstance()).registerJediManager(*this); -} // JediManagerObject::setupUniverse - -// ---------------------------------------------------------------------- - -void JediManagerObject::onServerUniverseGainedAuthority() -{ - if (s_queuedBountyHunterTargetListFromDB) - { - addJediBounties(*s_queuedBountyHunterTargetListFromDB); - - delete s_queuedBountyHunterTargetListFromDB; - s_queuedBountyHunterTargetListFromDB = NULL; - } -} - -// ---------------------------------------------------------------------- - -/** - * Creates the controller for this object. - */ -Controller * JediManagerObject::createDefaultController() -{ - Controller * controller = new JediManagerController(this); - NOT_NULL(controller); - - setController(controller); - return controller; -} // JediManagerObject::createDefaultController - -// ---------------------------------------------------------------------- - -void JediManagerObject::conclude() -{ - if (ConfigServerGame::getLogJediConcludes()) - REPORT_LOG(true, ("Jedi manager concluding\n")); - UniverseObject::conclude(); -} - -// ---------------------------------------------------------------------- - -/** - * Adds a Jedi to the list of Jedi online. - * - * @param id id of the Jedi - * @param name name of the Jedi - * @param location the world location of the Jedi - * @param scene the scene the Jedi is in - * @param visibility how visible the Jedi is - * @param bountyValue the bountyValue on the Jedi - * @param level the level of the Jedi - * @param hoursAlive how long the Jedi has been alive - * @param state the Jedi state - * @param spentJediSkillPoints number of skills points the Jedi has spent on Jedi skills - * @param faction the Jedi's pvp faction - */ -void JediManagerObject::addJedi(const NetworkId & id, const Unicode::String & name, - const Vector & location, const std::string & scene, int visibility, int bountyValue, - int level, int hoursAlive, int state, int spentJediSkillPoints, int faction) -{ - WARNING_DEBUG_FATAL(!isInitialized(), ("JediManagerObject::addJedi when not " - "initialized")); - - if (isAuthoritative()) - { - // make sure we aren't adding a duplicate Jedi - Archive::AutoDeltaMap::const_iterator const indexIter = m_jediId.find(id); - const int index = (indexIter == m_jediId.end() ? -1 : indexIter->second); - if (index == -1) - { - if (bountyValue > 0) - { - LOG("CustomerService", ("Jedi: Adding %s to the Jedi manager with a bounty value of %d", - PlayerObject::getAccountDescription(id).c_str(), bountyValue)); - - // add the Jedi - if (m_holes.empty()) - { - m_jediName.push_back(name); - m_jediLocation.push_back(location); - m_jediScene.push_back(scene); - m_jediVisibility.push_back(visibility); - m_jediBountyValue.push_back(bountyValue); - m_jediLevel.push_back(level); - m_jediBounties.push_back(std::vector()); - m_jediHoursAlive.push_back(hoursAlive); - m_jediState.push_back(state); - m_jediOnline.push_back(1); - m_jediSpentJediSkillPoints.push_back(spentJediSkillPoints); - m_jediFaction.push_back(faction); - - m_jediId.set(id, m_jediName.size() - 1); - } - else - { - const int hole = m_holes.back(); - m_holes.pop_back(); - - m_jediName.set(hole, name); - m_jediLocation.set(hole, location); - m_jediScene.set(hole, scene); - m_jediVisibility.set(hole, visibility); - m_jediBountyValue.set(hole, bountyValue); - m_jediLevel.set(hole, level); - m_jediBounties.set(hole, std::vector()); - m_jediHoursAlive.set(hole, hoursAlive); - m_jediState.set(hole, state); - m_jediOnline.set(hole, 1); - m_jediSpentJediSkillPoints.set(hole, spentJediSkillPoints); - m_jediFaction.set(hole, faction); - - m_jediId.set(id, hole); - } - - if (location.x == 0 && location.y == 0 && location.z == 0) - { - LOG("CustomerService", ("Jedi: %s has a location of 0 0 0", - PlayerObject::getAccountDescription(id).c_str())); - } - } - } - else - { - // if bountyValue is 0 and Jedi doesn't have any - // more bounty hunters hunting him, remove him - if ((bountyValue <= 0) && (m_jediBounties[index].empty())) - { - removeJedi(id); - } - else - { - if (bountyValue != m_jediBountyValue[index]) - { - LOG("CustomerService", ("Jedi: Updating Jedi %s bounty value from %d to %d", - PlayerObject::getAccountDescription(id).c_str(), m_jediBountyValue[index], bountyValue)); - } - - m_jediName.set(index, name); - m_jediLocation.set(index, location); - m_jediScene.set(index, scene); - m_jediVisibility.set(index, visibility); - m_jediBountyValue.set(index, bountyValue); - m_jediLevel.set(index,level); - m_jediState.set(index, state); - m_jediOnline.set(index, 1); - m_jediSpentJediSkillPoints.set(index, spentJediSkillPoints); - m_jediFaction.set(index, faction); - - if (location.x == 0 && location.y == 0 && location.z == 0) - { - LOG("CustomerService", ("Jedi: %s has a location of 0 0 0", - PlayerObject::getAccountDescription(id).c_str())); - } - } - } - } - else - { - sendControllerMessageToAuthServer(CM_addJedi, - new MessageQueueJediData(id, name, location, scene, visibility, bountyValue, - level, hoursAlive, state, spentJediSkillPoints, faction)); - } - - // in theory this should happen automatically via the auto delta code or when - // we send the controller message, but on live this appears not to be happening - if (ConfigServerGame::getForceJediConcludes()) - addObjectToConcludeList(); -} // JediManagerObject::addJedi - -// ---------------------------------------------------------------------- - -/** - * Tags a Jedi as being offline. - * - * @param id id of the Jedi - * @param location final world location of the Jedi - * @param scene final scene of the Jedi - */ -void JediManagerObject::setJediOffline(const NetworkId & id, const Vector & location, - const std::string & scene) -{ - WARNING_DEBUG_FATAL(!isInitialized(), ("JediManagerObject::setJediOffline " - "when not initialized")); - - if (isAuthoritative()) - { - // make sure we aren't adding a duplicate Jedi - Archive::AutoDeltaMap::const_iterator const indexIter = m_jediId.find(id); - const int index = (indexIter == m_jediId.end() ? -1 : indexIter->second); - if (index >= 0) - { - LOG("CustomerService", ("Jedi: Flagging Jedi %s as offline", - PlayerObject::getAccountDescription(id).c_str())); - m_jediLocation.set(index, location); - m_jediScene.set(index, scene); - m_jediOnline.set(index, 0); - - if (location.x == 0 && location.y == 0 && location.z == 0) - { - LOG("CustomerService", ("Jedi: %s has a location of 0 0 0", - PlayerObject::getAccountDescription(id).c_str())); - } - } - else - { - LOG("CustomerService", ("Jedi: setJediOffline called " - " for unknown Jedi %s", PlayerObject::getAccountDescription(id).c_str())); - } - } - else - { - sendControllerMessageToAuthServer(CM_setJediOffline, - new MessageQueueJediLocation(id, location, scene)); - } - - // in theory this should happen automatically via the auto delta code or when - // we send the controller message, but on live this appears not to be happening - if (ConfigServerGame::getForceJediConcludes()) - addObjectToConcludeList(); -} // JediManagerObject::setJediOffline - -// ---------------------------------------------------------------------- - -/** - * Removes a Jedi from the list of Jedi online. - * - * @param id id of the Jedi - */ -void JediManagerObject::removeJedi(const NetworkId & id) -{ - WARNING_DEBUG_FATAL(!isInitialized(), ("JediManagerObject::removeJedi " - "when not initialized")); - - if (isAuthoritative()) - { - Archive::AutoDeltaMap::const_iterator const indexIter = m_jediId.find(id); - const int index = (indexIter == m_jediId.end() ? -1 : indexIter->second); - if (index >= 0) - { - LOG("CustomerService", ("Jedi: Removing %s from the Jedi manager", - PlayerObject::getAccountDescription(id).c_str())); - - { - const std::vector & bounties = m_jediBounties[index]; - for (std::vector::const_iterator i = bounties.begin(); i != bounties.end(); ++i) - { - adjustBountyCount(*i, -1); - - // tell the db about the change - GameServer::getInstance().sendToDatabaseServer(BountyHunterTargetMessage(*i, NetworkId::cms_invalid)); - - // tell the hunter to update their pvp status - MessageToQueue::getInstance().sendMessageToC(*i, "C++UpdatePvp", "", 0, false); - } - } - - // mark the location in the vectors as removed - IGNORE_RETURN(m_jediId.erase(id)); - m_holes.push_back(index); - - // find and remove all the Jedi script data - { - char buffer[1024]; - for (Archive::AutoDeltaSet::const_iterator i = m_jediScriptDataNames.begin(); - i != m_jediScriptDataNames.end(); ++i) - { - snprintf(buffer, sizeof(buffer), "%d|%s", index, (*i).c_str()); - m_jediScriptData.erase(buffer); - } - } - } - else - { - LOG("CustomerService", ("Jedi: removeJedi asked to " - "remove unknown Jedi %s", PlayerObject::getAccountDescription(id).c_str())); - } - } - else - { - sendControllerMessageToAuthServer(CM_removeJedi, - new MessageQueueGenericValueType(id)); - } - - // in theory this should happen automatically via the auto delta code or when - // we send the controller message, but on live this appears not to be happening - if (ConfigServerGame::getForceJediConcludes()) - addObjectToConcludeList(); -} // JediManagerObject::removeJedi - -// ---------------------------------------------------------------------- - -/** - * A character is being deleted - * - * @param id id of the character - */ -void JediManagerObject::characterBeingDeleted(const NetworkId & id) -{ - WARNING_DEBUG_FATAL(!isInitialized(), ("JediManagerObject::jediBeingDeleted " - "when not initialized")); - - // stop tracking the character - Archive::AutoDeltaMap::const_iterator const indexIter = m_jediId.find(id); - const int index = (indexIter == m_jediId.end() ? -1 : indexIter->second); - if (index >= 0) - { - // tell all bounty hunters currently hunting the jedi to cancel their bounty mission - ScriptParams params; - params.addParam(id, "target"); - - ScriptDictionaryPtr dictionary; - GameScriptObject::makeScriptDictionary(params, dictionary); - if (dictionary.get() != NULL) - { - dictionary->serialize(); - - const std::vector & bounties = m_jediBounties[index]; - for (std::vector::const_iterator i = bounties.begin(); i != bounties.end(); ++i) - { - MessageToQueue::getInstance().sendMessageToJava(*i, - "handleBountyMissionIncomplete", dictionary->getSerializedData(), 0, true); - } - } - else - { - WARNING(true, ("JediManagerObject::characterBeingDeleted error converting " - "params")); - } - - // remove the jedi - removeJedi(id); - } - - // remove all bounties that the deleted character is hunting - std::vector jedis; - getBountyHunterBounties(id, jedis); - - for (std::vector::const_iterator iter = jedis.begin(); iter != jedis.end(); ++iter) - { - removeJediBounty(*iter, id); - } -} // JediManagerObject::characterBeingDeleted - -// ---------------------------------------------------------------------- - -/** - * Updates the data for a Jedi in the list of Jedi online. If a data param - * is < 0, it will be ignored. - * - * @param id id of the Jedi - * @param visibility how visible the Jedi is - * @param bountyValue the bounty value of the Jedi - * @param level the level of the Jedi - * @param hoursAlive how long the Jedi has been alive - */ -void JediManagerObject::updateJedi(const NetworkId & id, int visibility, - int bountyValue, int level, int hoursAlive) -{ - WARNING_DEBUG_FATAL(!isInitialized(), ("JediManagerObject::updateJedi(1) " - "when not initialized")); - - if (isAuthoritative()) - { - Archive::AutoDeltaMap::const_iterator const indexIter = m_jediId.find(id); - const int index = (indexIter == m_jediId.end() ? -1 : indexIter->second); - if (index >= 0) - { - if (visibility >= 0 && visibility != m_jediVisibility.get(index)) - { - LOG("CustomerService", ("Jedi: Setting Jedi %s visibility to %d", - PlayerObject::getAccountDescription(id).c_str(), visibility)); - m_jediVisibility.set(index, visibility); - } - if (bountyValue >= 0 && bountyValue != m_jediBountyValue.get(index)) - { - LOG("CustomerService", ("Jedi: Setting Jedi %s bounty value to %d", - PlayerObject::getAccountDescription(id).c_str(), bountyValue)); - m_jediBountyValue.set(index, bountyValue); - } - if (level >= 0 && level != m_jediLevel.get(index)) - { - LOG("CustomerService", ("Jedi: Setting Jedi %s level to %d", - PlayerObject::getAccountDescription(id).c_str(), level)); - m_jediLevel.set(index, level); - } - if (hoursAlive >= 0 && hoursAlive != m_jediHoursAlive.get(index)) - { - LOG("CustomerService", ("Jedi: Setting Jedi %s hoursAlive to %d", - PlayerObject::getAccountDescription(id).c_str(), hoursAlive)); - m_jediHoursAlive.set(index, hoursAlive); - } - } - else - { - LOG("CustomerService", ("Jedi: updateJedi(1) called for " - "unknown Jedi %s", PlayerObject::getAccountDescription(id).c_str())); - } - } - else - { - sendControllerMessageToAuthServer(CM_updateJedi, new MessageQueueJediData( - id, Unicode::emptyString, Vector(), "", visibility, bountyValue, level, hoursAlive, - 0, 0, 0)); - } - - // in theory this should happen automatically via the auto delta code or when - // we send the controller message, but on live this appears not to be happening - if (ConfigServerGame::getForceJediConcludes()) - addObjectToConcludeList(); -} // JediManagerObject::updateJedi(int, int) - -// ---------------------------------------------------------------------- - -/** - * Updates the data for a Jedi in the list of Jedi online. - * - * @param id id of the Jedi - * @param state the new state for the Jedi - */ -void JediManagerObject::updateJedi(const NetworkId & id, JediState state) -{ - WARNING_DEBUG_FATAL(!isInitialized(), ("JediManagerObject::updateJedi(2) " - "when not initialized")); - - if (isAuthoritative()) - { - Archive::AutoDeltaMap::const_iterator const indexIter = m_jediId.find(id); - const int index = (indexIter == m_jediId.end() ? -1 : indexIter->second); - if (index >= 0) - { - if (state != m_jediState.get(index)) - { - LOG("CustomerService", ("Jedi: Setting Jedi %s state to %d", - PlayerObject::getAccountDescription(id).c_str(), static_cast(state))); - m_jediState.set(index, state); - } - } - else - { - LOG("CustomerService", ("Jedi: updateJedi(2) called for " - "unknown Jedi %s", PlayerObject::getAccountDescription(id).c_str())); - } - } - else - { - sendControllerMessageToAuthServer(CM_updateJediState, - new MessageQueueGenericValueType >( - std::make_pair(id, static_cast(state)))); - } - - // in theory this should happen automatically via the auto delta code or when - // we send the controller message, but on live this appears not to be happening - if (ConfigServerGame::getForceJediConcludes()) - addObjectToConcludeList(); -} // JediManagerObject::updateJedi(JediState) - -// ---------------------------------------------------------------------- - -/** - * Updates the bounty data for a Jedi in the list of Jedi online. - * - * @param id id of the Jedi - * @param bounties list of the bounty hunters tracking the Jedi - * -void JediManagerObject::updateJedi(const NetworkId & id, - const std::vector & bounties) const -{ - WARNING_DEBUG_FATAL(!isInitialized(), ("JediManagerObject::updateJedi(3) " - "when not initialized")); - - if (isAuthoritative()) - { - Archive::AutoDeltaMap::const_iterator const indexIter = m_jediId.find(id); - const int index = (indexIter == m_jediId.end() ? -1 : indexIter->second); - if (index >= 0) - { - LOG("CustomerService", ("Jedi: Updating bounties on Jedi %s", - PlayerObject::getAccountDescription(id).c_str())); - m_jediBounties.set(index, bounties); - } - else - { - LOG("CustomerService", ("Jedi: updateJedi(3) called for " - "unknown Jedi %s", PlayerObject::getAccountDescription(id).c_str())); - } - } - else - { - sendControllerMessageToAuthServer(CM_updateJediBounties, - new MessageQueueGenericValueType > >( - std::make_pair(id, bounties))); - } - - // in theory this should happen automatically via the auto delta code or when - // we send the controller message, but on live this appears not to be happening - if (ConfigServerGame::getForceJediConcludes()) - addObjectToConcludeList(); -} // JediManagerObject::updateJedi(const std::vector &) -*/ -// ---------------------------------------------------------------------- - -/** - * Updates the location for a Jedi. - * - * @param id id of the Jedi - * @param location the Jedi location - * @param scene the Jedi scene - */ -void JediManagerObject::updateJediLocation(const NetworkId & id, const Vector & location, - const std::string & scene) -{ - WARNING_DEBUG_FATAL(!isInitialized(), ("JediManagerObject::updateJediLocation " - "when not initialized")); - - if (isAuthoritative()) - { - Archive::AutoDeltaMap::const_iterator const indexIter = m_jediId.find(id); - const int index = (indexIter == m_jediId.end() ? -1 : indexIter->second); - if (index >= 0) - { - if (scene != m_jediScene.get(index)) - { - LOG("CustomerService", ("Jedi: Updating scene for Jedi %s to %s", - PlayerObject::getAccountDescription(id).c_str(), scene.c_str())); - m_jediScene.set(index, scene); - } - m_jediLocation.set(index, location); - if (location.x == 0 && location.y == 0 && location.z == 0) - { - LOG("CustomerService", ("Jedi: %s has a location of 0 0 0", - PlayerObject::getAccountDescription(id).c_str())); - } - if (!m_jediOnline.get(index)) - { - LOG("CustomerService", ("Jedi: Jedi %s was offline but we received a position update, so we are marking them online.",PlayerObject::getAccountDescription(id).c_str(), scene.c_str())); - m_jediOnline.set(index, 1); - } - } - else - { - LOG("CustomerService", ("Jedi: updateJediLocation called " - "for unknown Jedi %s", PlayerObject::getAccountDescription(id).c_str())); - } - } - else - { - sendControllerMessageToAuthServer(CM_updateJediLocation, - new MessageQueueJediLocation(id, location, scene)); - } - - // in theory this should happen automatically via the auto delta code or when - // we send the controller message, but on live this appears not to be happening - if (ConfigServerGame::getForceJediConcludes()) - addObjectToConcludeList(); -} // JediManagerObject::updateJediLocation - -// ---------------------------------------------------------------------- - -/** - * Updates the number of skill points spent on Jedi skills for a Jedi. - * - * @param id id of the Jedi - * @param spentJediSkillPoints the number of skill points the Jedi has spent on Jedi skills - */ -void JediManagerObject::updateJediSpentJediSkillPoints(const NetworkId & id, int spentJediSkillPoints) -{ - WARNING_DEBUG_FATAL(!isInitialized(), ("JediManagerObject::updateJediSpentJediSkillPoints " - "when not initialized")); - - if (isAuthoritative()) - { - Archive::AutoDeltaMap::const_iterator const indexIter = m_jediId.find(id); - const int index = (indexIter == m_jediId.end() ? -1 : indexIter->second); - if (index >= 0) - { - if (spentJediSkillPoints != m_jediSpentJediSkillPoints.get(index)) - { - LOG("CustomerService", ("Jedi: Updating spent Jedi skill points for Jedi %s from %d to %d", - PlayerObject::getAccountDescription(id).c_str(), m_jediSpentJediSkillPoints.get(index), spentJediSkillPoints)); - m_jediSpentJediSkillPoints.set(index, spentJediSkillPoints); - } - } - else - { - LOG("CustomerService", ("Jedi: updateJediSpentJediSkillPoints called " - "for unknown Jedi %s", PlayerObject::getAccountDescription(id).c_str())); - } - } - else - { - sendControllerMessageToAuthServer(CM_updateJediSpentJediSkillPoints, - new MessageQueueGenericValueType >( - std::make_pair(id, spentJediSkillPoints))); - } - - // in theory this should happen automatically via the auto delta code or when - // we send the controller message, but on live this appears not to be happening - if (ConfigServerGame::getForceJediConcludes()) - addObjectToConcludeList(); -} // JediManagerObject::updateJediSpentJediSkillPoints - -// ---------------------------------------------------------------------- - -/** - * Updates the faction of a Jedi. - * - * @param id id of the Jedi - * @param faction the Jedi's faction - */ -void JediManagerObject::updateJediFaction(const NetworkId & id, int faction) -{ - WARNING_DEBUG_FATAL(!isInitialized(), ("JediManagerObject::updateJediFaction " - "when not initialized")); - - if (isAuthoritative()) - { - Archive::AutoDeltaMap::const_iterator const indexIter = m_jediId.find(id); - const int index = (indexIter == m_jediId.end() ? -1 : indexIter->second); - if (index >= 0) - { - if (faction != m_jediFaction.get(index)) - { - LOG("CustomerService", ("Jedi: Updating Jedi faction for Jedi %s from %d to %d", - PlayerObject::getAccountDescription(id).c_str(), m_jediFaction.get(index), faction)); - m_jediFaction.set(index, faction); - } - } - else - { - LOG("CustomerService", ("Jedi: updateJediFaction called for unknown " - "Jedi %s", PlayerObject::getAccountDescription(id).c_str())); - } - } - else - { - sendControllerMessageToAuthServer(CM_updateJediFaction, - new MessageQueueGenericValueType >( - std::make_pair(id, faction))); - } - - // in theory this should happen automatically via the auto delta code or when - // we send the controller message, but on live this appears not to be happening - if (ConfigServerGame::getForceJediConcludes()) - addObjectToConcludeList(); -} // JediManagerObject::updateJediFaction - -// ---------------------------------------------------------------------- - -/** - * Adds an arbitrary name->int pair to the info for a Jedi. - * - * @param id the Jedi's id - * @param name the data name - * @param value the data value - */ -void JediManagerObject::updateJediScriptData(const NetworkId & id, const std::string & name, int value) -{ - WARNING_DEBUG_FATAL(!isInitialized(), ("JediManagerObject::updateJediScriptData " - "when not initialized")); - - if (isAuthoritative()) - { - Archive::AutoDeltaMap::const_iterator const indexIter = m_jediId.find(id); - const int index = (indexIter == m_jediId.end() ? -1 : indexIter->second); - if (index >= 0) - { - LOG("CustomerService", ("Jedi: Updating script data on Jedi %s. Data " - "name = %s, value = %d", PlayerObject::getAccountDescription(id).c_str(), - name.c_str(), value)); - char buffer[1024]; - if (snprintf(buffer, sizeof(buffer), "%d|%s", index, name.c_str()) > 0) - { - m_jediScriptData.set(buffer, value); - m_jediScriptDataNames.insert(name); - } - } - else - { - LOG("CustomerService", ("Jedi: updateJediScriptData called for " - "unknown Jedi %s", PlayerObject::getAccountDescription(id).c_str())); - } - } - else - { - sendControllerMessageToAuthServer(CM_updateJediScriptData, - new MessageQueueGenericValueType > >( - std::make_pair(id, std::make_pair(name, value)))); - } - - // in theory this should happen automatically via the auto delta code or when - // we send the controller message, but on live this appears not to be happening - if (ConfigServerGame::getForceJediConcludes()) - addObjectToConcludeList(); -} // JediManagerObject::updateJediScriptData - -// ---------------------------------------------------------------------- - -/** - * Removes an arbitrary name->int pair to the info for a Jedi. - * - * @param id the Jedi's id - * @param name the data name - */ -void JediManagerObject::removeJediScriptData(const NetworkId & id, const std::string & name) -{ - WARNING_DEBUG_FATAL(!isInitialized(), ("JediManagerObject::removeJediScriptData " - "when not initialized")); - - if (isAuthoritative()) - { - Archive::AutoDeltaMap::const_iterator const indexIter = m_jediId.find(id); - const int index = (indexIter == m_jediId.end() ? -1 : indexIter->second); - if (index >= 0) - { - LOG("CustomerService", ("Jedi: Removing script data on Jedi %s. Data " - "name = %s", PlayerObject::getAccountDescription(id).c_str(), - name.c_str())); - char buffer[1024]; - snprintf(buffer, sizeof(buffer), "%d|%s", index, name.c_str()); - m_jediScriptData.erase(buffer); - } - else - { - LOG("CustomerService", ("Jedi: removeJediScriptData called for " - "unknown Jedi %s", PlayerObject::getAccountDescription(id).c_str())); - } - } - else - { - sendControllerMessageToAuthServer(CM_removeJediScriptData, - new MessageQueueGenericValueType >( - std::make_pair(id, name))); - } - - // in theory this should happen automatically via the auto delta code or when - // we send the controller message, but on live this appears not to be happening - if (ConfigServerGame::getForceJediConcludes()) - addObjectToConcludeList(); -} // JediManagerObject::removeJediScriptData - -// ---------------------------------------------------------------------- - -/** - * Called by a script requesting Jedi with certain parameters. Limits are passed - * in for statistics that the caller is interested in; the Jedi returned will - * have the requested value or greater for the statistic if the value given is - * >= 0, or less than the statistic if the value given is < 0. If the statistic - * should be ignored, IGNORE_JEDI_STAT should be passed in as the limit value. - * The exception to this is the minLevel and maxLevel parameters, which always - * specify the (inclusive) minLevel and maxLevel filter - * - * @param visibility how visible the Jedi is - * @param bountyValue bounty value of the Jedi - * @param minLevel minimum Jedi level (inclusive) - * @param maxLevel maximum Jedi level (inclusive) - * @param bounties how many bounties the Jedi has on him - * @param hoursAlive how long the Jedi has been alive - * @param state which Jedi states we're interested in - * @param returnParams params that will be filled in with the Jedi data - */ -void JediManagerObject::getJedi(int visibility, int bountyValue, int minLevel, int maxLevel, - int hoursAlive, int bounties, int state, ScriptParams & returnParams) const -{ - // unfortunately we have to create new data to store the Jedi info, - // since the ScriptParams class wasn't set up to be passed as a return - // value like we're using it. - - // the returnParams will be responsible for destructing these - std::vector * jediId = new std::vector; - std::vector * jediName = new std::vector; - std::vector * jediLocation = new std::vector; - std::vector * jediScene = new std::vector; - std::vector * jediVisibility = new std::vector; - std::vector * jediBountyValue = new std::vector; - std::vector * jediLevel = new std::vector; - std::vector *> * jediBounties = new std::vector *>; - std::vector * jediHoursAlive = new std::vector; - std::vector * jediState = new std::vector; - std::deque * jediOnline = new std::deque; - std::vector * jediSpentJediSkillPoints = new std::vector; - std::vector * jediFaction = new std::vector; - std::map *> jediScriptData; - - // initialize the jedi script data map - { - for (Archive::AutoDeltaSet::const_iterator iter = m_jediScriptDataNames.begin(); - iter != m_jediScriptDataNames.end(); ++iter) - { - jediScriptData.insert(std::make_pair(*iter, new std::vector)); - } - } - - // check each Jedi to see if they meet the requirements - for (Archive::AutoDeltaMap::const_iterator i = m_jediId.begin(); i != m_jediId.end(); ++i) - { - if (m_jediName[i->second].empty()) - continue; - - // filter out Jedi who don't meet the requirements - if (visibility != IGNORE_JEDI_STAT) - { - if (visibility >= 0 && m_jediVisibility[i->second] < visibility) - continue; - else if (visibility < 0 && m_jediVisibility[i->second] >= -visibility) - continue; - } - if (bountyValue != IGNORE_JEDI_STAT) - { - if (bountyValue >= 0 && m_jediBountyValue[i->second] < bountyValue) - continue; - else if (bountyValue < 0 && m_jediBountyValue[i->second] >= -bountyValue) - continue; - } - if ((m_jediLevel[i->second] <= 0) || (m_jediLevel[i->second] < minLevel) || (m_jediLevel[i->second] > maxLevel)) - continue; - if (hoursAlive != IGNORE_JEDI_STAT) - { - if (hoursAlive >= 0 && m_jediHoursAlive[i->second] < hoursAlive) - continue; - else if (hoursAlive < 0 && m_jediHoursAlive[i->second] >= -hoursAlive) - continue; - } - if (bounties != IGNORE_JEDI_STAT) - { - if (bounties >= 0 && m_jediBounties[i->second].size() < static_cast(bounties)) - continue; - else if (bounties < 0 && m_jediBounties[i->second].size() >= static_cast(-bounties)) - continue; - } - if (state != IGNORE_JEDI_STAT) - { - if ((state & m_jediState[i->second]) == 0) - continue; - } - // this Jedi is ok - jediId->push_back(i->first); - jediName->push_back(new Unicode::String(m_jediName[i->second])); - jediLocation->push_back(new Vector(m_jediLocation[i->second])); - char * scene = new char[m_jediScene[i->second].size() + 1]; - strcpy(scene, m_jediScene[i->second].c_str()); - jediScene->push_back(scene); - jediVisibility->push_back(m_jediVisibility[i->second]); - jediBountyValue->push_back(m_jediBountyValue[i->second]); - jediLevel->push_back(m_jediLevel[i->second]); - jediBounties->push_back(new std::vector(m_jediBounties[i->second])); - jediHoursAlive->push_back(m_jediHoursAlive[i->second]); - jediState->push_back(m_jediState[i->second]); - jediOnline->push_back(static_cast(m_jediOnline[i->second])); - jediSpentJediSkillPoints->push_back(m_jediSpentJediSkillPoints[i->second]); - jediFaction->push_back(m_jediFaction[i->second]); - - // find the script data for the Jedi - char buffer[1024]; - for (Archive::AutoDeltaSet::const_iterator j = m_jediScriptDataNames.begin(); - j != m_jediScriptDataNames.end(); ++j) - { - std::vector * dataList = (*jediScriptData.find(*j)).second; - NOT_NULL(dataList); - snprintf(buffer, sizeof(buffer), "%d|%s", i->second, (*j).c_str()); - Archive::AutoDeltaMap::const_iterator result = - m_jediScriptData.find(buffer); - if (result != m_jediScriptData.end()) - { - dataList->push_back((*result).second); - } - else - { - dataList->push_back(0); - } - } - } - - returnParams.addParam(*jediId, "id", true); - returnParams.addParam(*jediName, "name", true); - returnParams.addParam(*jediLocation, "location", true); - returnParams.addParam(*jediScene, "scene", true); - returnParams.addParam(*jediVisibility, "visibility", true); - returnParams.addParam(*jediBountyValue, "bountyValue", true); - returnParams.addParam(*jediLevel, "level", true); - returnParams.addParam(*jediBounties, "bounties", true); - returnParams.addParam(*jediHoursAlive, "hoursAlive", true); - returnParams.addParam(*jediState, "state", true); - returnParams.addParam(*jediOnline, "online", true); - returnParams.addParam(*jediSpentJediSkillPoints, "spentJediSkillPoints", true); - returnParams.addParam(*jediFaction, "faction", true); - - { - for (std::map *>::const_iterator iter = jediScriptData.begin(); - iter != jediScriptData.end(); ++iter) - { - returnParams.addParam(*((*iter).second), (*iter).first, true); - } - } -} // JediManagerObject::getJedi - -// ---------------------------------------------------------------------- - -/** - * Called by a script requesting a specific Jedi. - * - * @param id the id of the Jedi - * @param returnParams params that will be filled in with the Jedi data - */ -void JediManagerObject::getJedi(const NetworkId & id, ScriptParams & returnParams) const -{ - Archive::AutoDeltaMap::const_iterator const indexIter = m_jediId.find(id); - const int index = (indexIter == m_jediId.end() ? -1 : indexIter->second); - if (index < 0) - return; - - returnParams.addParam(id, "id"); - returnParams.addParam(m_jediName[index], "name"); - returnParams.addParam(m_jediLocation[index], "location"); - returnParams.addParam(m_jediScene[index].c_str(), "scene"); - returnParams.addParam(m_jediVisibility[index], "visibility"); - returnParams.addParam(m_jediBountyValue[index], "bountyValue"); - returnParams.addParam(m_jediLevel[index], "level"); - returnParams.addParam(m_jediBounties[index], "bounties"); - returnParams.addParam(m_jediHoursAlive[index], "hoursAlive"); - returnParams.addParam(m_jediState[index], "state"); - returnParams.addParam(static_cast(m_jediOnline[index]), "online"); - returnParams.addParam(m_jediSpentJediSkillPoints[index], "spentJediSkillPoints"); - returnParams.addParam(m_jediFaction[index], "faction"); - - - // add the script data - char buffer[1024]; - for (Archive::AutoDeltaSet::const_iterator i = m_jediScriptDataNames.begin(); - i != m_jediScriptDataNames.end(); ++i) - { - snprintf(buffer, sizeof(buffer), "%d|%s", index, (*i).c_str()); - Archive::AutoDeltaMap::const_iterator result = - m_jediScriptData.find(buffer); - if (result != m_jediScriptData.end()) - { - returnParams.addParam((*result).second, *i); - } - else - { - returnParams.addParam(0, *i); - } - } -} // JediManagerObject::getJedi - -// ---------------------------------------------------------------------- - -/** - * Returns the location of a Jedi. - * - * @param id id of the Jedi - * @param location filled with the Jedi location - * @param scene filled with the Jedi scene - * - * @return true if the location/scene data is valid, false if we couldn't find - * the Jedi - */ -bool JediManagerObject::getJediLocation(const NetworkId & id, Vector & location, - std::string & scene) const -{ - Archive::AutoDeltaMap::const_iterator const indexIter = m_jediId.find(id); - const int index = (indexIter == m_jediId.end() ? -1 : indexIter->second); - if (index < 0) - return false; - - location = m_jediLocation[index]; - scene = m_jediScene[index]; - return true; -} // JediManagerObject::getJediLocation - -// ---------------------------------------------------------------------- - -/** - * Sets up the Jedi bounties from the database. - * - * @param msg the message from the database listing all the Jedi and who - * is hunting them - */ -void JediManagerObject::addJediBounties(const BountyHunterTargetListMessage & msg) -{ - if (!isAuthoritative()) - return; - - if (m_bountyHunterTargetsReceivedFromDB.get()) - { - WARNING(true, ("JediManagerObject::addJediBounties() - attempting to apply BountyHunterTargetList from DB a second time")); - return; - } - - typedef std::vector< std::pair< NetworkId, NetworkId > > BountyList; - const BountyList & bountyList = msg.getTargetList(); - for (BountyList::const_iterator i = bountyList.begin(); i != bountyList.end(); ++i) - { - const NetworkId & jediId = (*i).second; - const NetworkId & hunterId = (*i).first; - - LOG("BountyHunterTargetList",("adding bounty from DB bh=%s jedi=%s", hunterId.getValueString().c_str(), jediId.getValueString().c_str())); - - if (jediId == NetworkId::cms_invalid || hunterId == NetworkId::cms_invalid) - continue; - - Archive::AutoDeltaMap::const_iterator const indexIter = m_jediId.find(jediId); - int index = (indexIter == m_jediId.end() ? -1 : indexIter->second); - if (index < 0) - { - // we need to add the Jedi - if (m_holes.empty()) - { - m_jediName.push_back(Unicode::String()); - m_jediLocation.push_back(Vector()); - m_jediScene.push_back(""); - m_jediVisibility.push_back(0); - m_jediBountyValue.push_back(0); - m_jediLevel.push_back(0); - m_jediBounties.push_back(std::vector()); - m_jediHoursAlive.push_back(0); - m_jediState.push_back(0); - m_jediOnline.push_back(0); - m_jediSpentJediSkillPoints.push_back(0); - m_jediFaction.push_back(0); - - index = m_jediName.size() - 1; - } - else - { - index = m_holes.back(); - m_holes.pop_back(); - - m_jediName.set(index, Unicode::String()); - m_jediLocation.set(index, Vector()); - m_jediScene.set(index, ""); - m_jediVisibility.set(index, 0); - m_jediBountyValue.set(index, 0); - m_jediLevel.set(index, 0); - m_jediBounties.set(index, std::vector()); - m_jediHoursAlive.set(index, 0); - m_jediState.set(index, 0); - m_jediOnline.set(index, 0); - m_jediSpentJediSkillPoints.set(index, 0); - m_jediFaction.set(index, 0); - } - - m_jediId.set(jediId, index); - } - - if (std::find(m_jediBounties[index].begin(), m_jediBounties[index].end(), hunterId) == m_jediBounties[index].end()) - { - std::vector hunters = m_jediBounties[index]; - hunters.push_back(hunterId); - m_jediBounties.set(index, hunters); - - adjustBountyCount(hunterId, 1); - } - } - - m_bountyHunterTargetsReceivedFromDB = true; -} // JediManagerObject::addJediBounties - -// ---------------------------------------------------------------------- - -/** - * Requests to assign a bounty hunter to track down a Jedi. - * - * @param target the Jedi to hunt - * @param hunter the bounty hunter - * @param successCallback name of a messageHandler than will be called if the - * bounty was assigned - * @param failCallback name of a messageHandler than will be called if the - * bounty was not assigned - * @param callbackObj the object that will receive the callback - */ -void JediManagerObject::requestJediBounty(const NetworkId & targetId, - const NetworkId & hunterId, const std::string & successCallback, - const std::string & failCallback, const NetworkId & callbackObjectId) -{ - if (isAuthoritative()) - { - bool success = false; - int bounties = 0; - - // find the target and see how many bounties they have on them - Archive::AutoDeltaMap::const_iterator const indexIter = m_jediId.find(targetId); - const int index = (indexIter == m_jediId.end() ? -1 : indexIter->second); - if (index >= 0) - { - bounties = m_jediBounties[index].size(); - if (bounties < ConfigServerGame::getMaxJediBounties()) - { - success = true; - // only add the hunter to the list if he isn't on there already - if (std::find(m_jediBounties[index].begin(), m_jediBounties[index].end(), hunterId) == m_jediBounties[index].end()) - { - std::vector hunters = m_jediBounties[index]; - hunters.push_back(hunterId); - m_jediBounties.set(index, hunters); - ++bounties; - - adjustBountyCount(hunterId, 1); - - // tell the db about the change - GameServer::getInstance().sendToDatabaseServer(BountyHunterTargetMessage(hunterId, targetId)); - } - } - } - - if (callbackObjectId != NetworkId::cms_invalid) - { - // send the success or fail message - ScriptParams params; - params.addParam(targetId, "jedi"); - params.addParam(hunterId, "hunter"); - params.addParam(bounties, "bounties"); - - ScriptDictionaryPtr dictionary; - GameScriptObject::makeScriptDictionary(params, dictionary); - if (dictionary.get() != NULL) - { - dictionary->serialize(); - if (success) - { - MessageToQueue::getInstance().sendMessageToJava(callbackObjectId, - successCallback, dictionary->getSerializedData(), 0, true); - } - else - { - MessageToQueue::getInstance().sendMessageToJava(callbackObjectId, - failCallback, dictionary->getSerializedData(), 0, true); - } - } - else - { - WARNING(true, ("JediManagerObject::requestJediBounty error converting " - "params")); - } - } - - // tell the hunter to update their pvp status; this must be done after the - // callback notification message above to give script a chance to finish - // initializing the bounty mission so that we have all the information - // required to calculate pvp status - if (success) - MessageToQueue::getInstance().sendMessageToC(hunterId, "C++UpdatePvp", "", 10, false); - } - else - { - sendControllerMessageToAuthServer(CM_requestJediBounty, - new MessageQueueRequestJediBounty(targetId, hunterId, successCallback, - failCallback, callbackObjectId)); - } -} // JediManagerObject::requestJediBounty - -// ---------------------------------------------------------------------- - -/** - * Removes a bounty from a Jedi. - * - * @param targetId the Jedi - * @param hunterId the id of the bounty hunter to remove - */ -void JediManagerObject::removeJediBounty(const NetworkId & targetId, - const NetworkId & hunterId) -{ - if (isAuthoritative()) - { - // find the target and see how many bounties they have on them - Archive::AutoDeltaMap::const_iterator const indexIter = m_jediId.find(targetId); - const int index = (indexIter == m_jediId.end() ? -1 : indexIter->second); - if (index >= 0) - { - std::vector hunters = m_jediBounties[index]; - std::vector::iterator i = std::find(hunters.begin(), hunters.end(), hunterId); - if (i != hunters.end()) - { - hunters.erase(i); - - // must always do this even if we end up calling removeJedi() below, - // because removeJedi() also processes the hunters list, so we need - // to remove the hunter from the hunters list or else removeJedi() - // will remove the hunter again - m_jediBounties.set(index, hunters); - adjustBountyCount(hunterId, -1); - - // if bountyValue is 0 and Jedi doesn't have any - // more bounty hunters hunting him, remove him - if ((m_jediBountyValue[index] <= 0) && (hunters.empty())) - { - removeJedi(targetId); - } - - // tell the db about the change - GameServer::getInstance().sendToDatabaseServer(BountyHunterTargetMessage(hunterId, NetworkId::cms_invalid)); - - // tell the hunter to update their pvp status - MessageToQueue::getInstance().sendMessageToC(hunterId, "C++UpdatePvp", "", 0, false); - } - } - } - else - { - sendControllerMessageToAuthServer(CM_removeJediBounty, - new MessageQueueGenericValueType >( - std::make_pair(targetId, hunterId))); - } -} // JediManagerObject::removeJediBounty - -// ---------------------------------------------------------------------- - -/** - * Removes all the bounties on a Jedi. - * - * @param targetId the Jedi - */ -void JediManagerObject::removeAllJediBounties(const NetworkId & targetId) -{ - if (isAuthoritative()) - { - // find the target and see how many bounties they have on them - Archive::AutoDeltaMap::const_iterator const indexIter = m_jediId.find(targetId); - const int index = (indexIter == m_jediId.end() ? -1 : indexIter->second); - if (index >= 0) - { - std::vector hunters = m_jediBounties[index]; - for (std::vector::const_iterator i = hunters.begin(); i != hunters.end(); ++i) - { - adjustBountyCount(*i,-1); - - // tell the db about the change - GameServer::getInstance().sendToDatabaseServer(BountyHunterTargetMessage(*i, NetworkId::cms_invalid)); - - // tell the hunter to update their pvp status - MessageToQueue::getInstance().sendMessageToC(*i, "C++UpdatePvp", "", 0, false); - } - - // must always do this even if we end up calling removeJedi() below, - // because removeJedi() also processes the hunters list, so we need - // to remove all the hunter from the hunters list or else removeJedi() - // will remove the hunters again - hunters.clear(); - m_jediBounties.set(index, hunters); - - // if bountyValue is 0 and Jedi doesn't have any - // more bounty hunters hunting him, remove him - if (m_jediBountyValue[index] <= 0) - { - removeJedi(targetId); - } - } - } - else - { - sendControllerMessageToAuthServer(CM_removeAllJediBounties, - new MessageQueueGenericValueType(targetId)); - } -} // JediManagerObject::removeJediBounty - -// ---------------------------------------------------------------------- - -/** - * Tests if a Jedi is being hunted by a given bounty hunter. - * - * @param targetId the id of the Jedi - * @param hunterId the id of the bounty hunter - * - * @return true if the Jedi is being hunted, false if not - */ -bool JediManagerObject::hasBountyOnJedi(const NetworkId & targetId, - const NetworkId & hunterId) const -{ - Archive::AutoDeltaMap::const_iterator const indexIter = m_jediId.find(targetId); - const int index = (indexIter == m_jediId.end() ? -1 : indexIter->second); - if (index >= 0) - { - const std::vector & hunters = m_jediBounties[index]; - return std::find(hunters.begin(), hunters.end(), hunterId) != hunters.end(); - } - return false; -} // JediManagerObject::hasBountyOnJedi - -// ---------------------------------------------------------------------- - -/** - * Tests if a given bounty hunter is hunting any Jedis - * - * @param hunterId the id of the bounty hunter - * - * @return true if the bounty hunter is hunting someone, false if not - */ -bool JediManagerObject::hasBountyOnJedi(NetworkId const & hunterId) const -{ - Archive::AutoDeltaMap::const_iterator i=m_bountyHunters.find(hunterId); - if (i==m_bountyHunters.end() || i->second<=0) - return false; - else - return true; -} - -// ---------------------------------------------------------------------- - -void JediManagerObject::queueBountyHunterTargetListFromDB(const BountyHunterTargetListMessage * bhtlm) -{ - WARNING(s_queuedBountyHunterTargetListFromDB && bhtlm, ("JediManagerObject::queueBountyHunterTargetListFromDB() - attempting to queue another BountyHunterTargetList from DB")); - - delete s_queuedBountyHunterTargetListFromDB; - s_queuedBountyHunterTargetListFromDB = bhtlm; -} - -// ---------------------------------------------------------------------- - -const std::vector & JediManagerObject::getJediBounties(const NetworkId & targetId) const -{ - const static std::vector EMPTY_ARRAY; - - Archive::AutoDeltaMap::const_iterator const indexIter = m_jediId.find(targetId); - const int index = (indexIter == m_jediId.end() ? -1 : indexIter->second); - if (index >= 0) - { - return m_jediBounties[index]; - } - return EMPTY_ARRAY; -} // JediManagerObject::getJediBounties - -// ---------------------------------------------------------------------- - -void JediManagerObject::getBountyHunterBounties(const NetworkId & hunterId, std::vector & jedis) const -{ - jedis.clear(); - - for (Archive::AutoDeltaMap::const_iterator iter = m_jediId.begin(); iter != m_jediId.end(); ++iter) - { - if (std::find(m_jediBounties[iter->second].begin(), m_jediBounties[iter->second].end(), hunterId) != m_jediBounties[iter->second].end()) - jedis.push_back(iter->first); - } -} - -// ---------------------------------------------------------------------- - -void JediManagerObject::adjustBountyCount(NetworkId const & hunterId, int const adjustment) -{ - Archive::AutoDeltaMap::const_iterator i = m_bountyHunters.find(hunterId); - int const oldBountyCount = (i!=m_bountyHunters.end()) ? i->second : 0; - int const newBountyCount = oldBountyCount + adjustment; - WARNING_DEBUG_FATAL(newBountyCount < 0,("Programmer bug: the bounty count for bounty hunter %s when below 0.", hunterId.getValueString().c_str())); - - if (newBountyCount <= 0) - m_bountyHunters.erase(hunterId); - else - m_bountyHunters.set(hunterId, newBountyCount); -} - -// ====================================================================== diff --git a/src/game/server/application/SwgGameServer/src/shared/object/JediManagerObject.h b/src/game/server/application/SwgGameServer/src/shared/object/JediManagerObject.h deleted file mode 100644 index 4caf3469a..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/object/JediManagerObject.h +++ /dev/null @@ -1,111 +0,0 @@ -// ====================================================================== -// -// JediManagerObject.h -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_JediManagerObject_H -#define INCLUDED_JediManagerObject_H - -#include "serverGame/UniverseObject.h" -#include "swgSharedUtility/JediConstants.h" - -class BountyHunterTargetListMessage; -class ScriptParams; -class ServerJediManagerObjectTemplate; -class Vector; - - -// ====================================================================== - -/** - * Keeps track of what Jedi are online and grants bounty missions for them. - */ -class JediManagerObject : public UniverseObject -{ -public: - JediManagerObject(const ServerJediManagerObjectTemplate* newTemplate); - virtual ~JediManagerObject(); - - void addMembersToPackages(); - - virtual void setupUniverse(); - virtual void onServerUniverseGainedAuthority(); - virtual Controller* createDefaultController(); - virtual void conclude(); - - void addJedi(const NetworkId & id, const Unicode::String & name, const Vector & location, const std::string & scene, int visibility, int bountyValue, int level, int hoursAlive, int state, int spentJediSkillPoints, int faction); - void setJediOffline(const NetworkId & id, const Vector & location, const std::string & scene); - void removeJedi(const NetworkId & id); - void characterBeingDeleted(const NetworkId & id); - void updateJedi(const NetworkId & id, int visibility, int bountyValue, int level, int hoursAlive); - void updateJedi(const NetworkId & id, JediState state); -// void updateJedi(const NetworkId & id, const std::vector & bounties) const; - void updateJediLocation(const NetworkId & id, const Vector & location, const std::string & scene); - void updateJediSpentJediSkillPoints(const NetworkId & id, int spentJediSkillPoints); - void updateJediFaction(const NetworkId & id, int faction); - void updateJediScriptData(const NetworkId & id, const std::string & name, int value); - void removeJediScriptData(const NetworkId & id, const std::string & name); - - void getJedi(int visibility, int bountyValue, int minLevel, int maxLevel, int hoursAlive, int bounties, int state, ScriptParams & returnParams) const; - void getJedi(const NetworkId & id, ScriptParams & returnParams) const; - bool getJediLocation(const NetworkId & id, Vector & location, std::string & scene) const; - void addJediBounties(const BountyHunterTargetListMessage & msg); - void requestJediBounty(const NetworkId & targetId, const NetworkId & hunterId, const std::string & successCallback, const std::string & failCallback, const NetworkId & callbackObjectId); - void removeJediBounty(const NetworkId & targetId, const NetworkId & hunterId); - void removeAllJediBounties(const NetworkId & targetId); - const std::vector & getJediBounties(const NetworkId & targetId) const; - void getBountyHunterBounties(const NetworkId & hunterId, std::vector & jedis) const; - - bool hasBountyOnJedi(const NetworkId & targetId, const NetworkId & hunterId) const; - bool hasBountyOnJedi(NetworkId const & hunterId) const; - - static void queueBountyHunterTargetListFromDB(const BountyHunterTargetListMessage * bhtlm); - -protected: - virtual void initializeFirstTimeObject(); - virtual void endBaselines(); - -private: - JediManagerObject(const JediManagerObject&); - JediManagerObject & operator=(const JediManagerObject&); - - void adjustBountyCount(NetworkId const & hunterId, int adjustment); - -private: - // most of the jedi information are kept in vectors, which makes it very expensive - // to search, so we're going to keep a map to store the index in the vector where - // the jedi information is kept; to prevent updating the indices whenever an item is - // deleted from the vector, we will never delete items from the vector, but we - // will keep track of places in the vector that has been deleted (i.e. the "holes") - // so that when a new item is added, we add it to one of the "hole" in the vector - Archive::AutoDeltaMap m_jediId; - Archive::AutoDeltaVector m_holes; - - Archive::AutoDeltaVector m_jediName; - Archive::AutoDeltaVector m_jediLocation; - Archive::AutoDeltaVector m_jediScene; - Archive::AutoDeltaVector m_jediVisibility; - Archive::AutoDeltaVector m_jediBountyValue; - Archive::AutoDeltaVector m_jediLevel; - Archive::AutoDeltaVector > m_jediBounties; // each element of this vector is a vector of bounty hunters that are chasing the jedi - Archive::AutoDeltaMap m_bountyHunters; // map of bounty hunter id --> number of jedis being chased - Archive::AutoDeltaVector m_jediHoursAlive; - Archive::AutoDeltaVector m_jediState; - // this should actuall be a vector of bool, but it won't compile in VC - Archive::AutoDeltaVector m_jediOnline; - Archive::AutoDeltaVector m_jediSpentJediSkillPoints; - Archive::AutoDeltaVector m_jediFaction; - Archive::AutoDeltaMap m_jediScriptData; - - // this contains all the names that are used to make up the key value in m_jediScriptData - Archive::AutoDeltaSet m_jediScriptDataNames; - - // indicates whether the bounty hunter target list has been received from the DB - Archive::AutoDeltaVariable m_bountyHunterTargetsReceivedFromDB; -}; - -// ====================================================================== - -#endif diff --git a/src/game/server/application/SwgGameServer/src/shared/object/SwgCreatureObject.cpp b/src/game/server/application/SwgGameServer/src/shared/object/SwgCreatureObject.cpp deleted file mode 100644 index e1ab4b18b..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/object/SwgCreatureObject.cpp +++ /dev/null @@ -1,338 +0,0 @@ -//======================================================================== -// -// SwgCreatureObject.cpp -// -// copyright 2001 Sony Online Entertainment -// -//======================================================================== - -#include "FirstSwgGameServer.h" -#include "SwgGameServer/SwgCreatureObject.h" -#include "serverGame/PlayerCreatureController.h" -#include "serverGame/PlayerObject.h" -#include "serverGame/ServerCreatureObjectTemplate.h" -#include "serverNetworkMessages/MessageToPayload.h" -#include "SwgGameServer/JediManagerObject.h" -#include "SwgGameServer/SwgPlayerCreatureController.h" -#include "SwgGameServer/SwgPlayerObject.h" -#include "SwgGameServer/SwgServerUniverse.h" - - -//---------------------------------------------------------------------- - -/** - * Class constructor. - */ -SwgCreatureObject::SwgCreatureObject(const ServerCreatureObjectTemplate* newTemplate) : - CreatureObject(newTemplate) -{ -} // SwgCreatureObject::SwgCreatureObject - -//---------------------------------------------------------------------- - -/** - * Class destructor. - */ -SwgCreatureObject::~SwgCreatureObject() -{ - //-- This must be the first line in the destructor to invalidate any watchers watching this object - nullWatchers(); - -} // SwgCreatureObject::~SwgCreatureObject - -//---------------------------------------------------------------------- - -/** - * Creates a default controller for this object. - * - * @return the object's controller - */ -Controller* SwgCreatureObject::createDefaultController () -{ - const ServerCreatureObjectTemplate * myTemplate = safe_cast< - const ServerCreatureObjectTemplate *>(getObjectTemplate()); - - Controller * controller = 0; - if (myTemplate->getCanCreateAvatar()) - { - controller = new SwgPlayerCreatureController(this); - } - else - { - controller = CreatureObject::createDefaultController(); - } - - setController(controller); - return controller; -} // CreatureObject::createDefaultController - -//---------------------------------------------------------------------- - -/** - * Called to alter the creature. - */ -float SwgCreatureObject::alter(float time) -{ - if (isAuthoritative() && isPlayerControlled() && (getBountyValue() > 0)) - { - PlayerObject * const player = PlayerCreatureController::getPlayerObject(this); - if (player) - { - SwgPlayerObject * swgPlayer = safe_cast(player); - swgPlayer->updateJediLocationTime(time); - } - } - return CreatureObject::alter(time); -} // SwgCreatureObject::alter - -//---------------------------------------------------------------------- - -/** - * Called when the creature is being removed from the world. - */ -void SwgCreatureObject::onRemovingFromWorld() -{ - // if we are a Jedi, flag ourself as offline - if (isAuthoritative() && isPlayerControlled() && (getBountyValue() > 0)) - { - JediManagerObject * const jediManager = static_cast(ServerUniverse::getInstance()).getJediManager(); - if (jediManager != NULL) - { - jediManager->setJediOffline(getNetworkId(), getPosition_w(), getSceneId()); - } - } - - CreatureObject::onRemovingFromWorld(); -} // SwgCreatureObject::onRemovingFromWorld - -//---------------------------------------------------------------------- - -/** - * Called when the creature is being deleted from the game. - */ -void SwgCreatureObject::onPermanentlyDestroyed() -{ - // if we are a Jedi, remove ourself from the Jedi manager - if (isAuthoritative() && isPlayerControlled() && (getBountyValue() > 0)) - { - JediManagerObject * const jediManager = static_cast(ServerUniverse::getInstance()).getJediManager(); - if (jediManager != NULL) - { - jediManager->removeJedi(getNetworkId()); - } - } - - CreatureObject::onPermanentlyDestroyed(); -} // SwgCreatureObject::onPermanentlyDestroyed - -//---------------------------------------------------------------------- - -/** - * Handles messages to this object. - * - * @param message the message - */ -void SwgCreatureObject::handleCMessageTo (const MessageToPayload &message) -{ - CreatureObject::handleCMessageTo (message); -} // SwgCreatureObject::handleCMessageTo - -//---------------------------------------------------------------------- - -/** -* Checks if a player is a Jedi or not. -*/ -bool SwgCreatureObject::isJedi(void) const -{ - if (!isPlayerControlled()) - return false; - - PlayerObject const * const player = PlayerCreatureController::getPlayerObject(this); - if (player) - { - SwgPlayerObject const * const swgPlayer = safe_cast(player); - return swgPlayer->isJedi(); - } - - return false; -} // SwgCreatureObject::isJedi - -//----------------------------------------------------------------------- - -/** -* Returns the number of skill points that have been spent on Jedi skills. -*/ -const int SwgCreatureObject::getSpentJediSkillPoints() const -{ - int result = 0; - - /* skill points no longer exist - const SkillList & skills = getSkillList(); - for (SkillList::const_iterator i = skills.begin(); i != skills.end(); ++i) - { - if (*i) - { - // per Dave White, we only care about skills starting with "force_discipline" - if ((*i)->getSkillName().find("force_discipline") == 0) - result += (*i)->getSkillPointCost(); - } - else - { - WARNING(true, ("Creature %s had a null in their skill list", getNetworkId().getValueString().c_str())); - } - } - */ - return result; -} // SwgCreatureObject::getSpentJediSkillPoints - -//---------------------------------------------------------------------- - -/** - * Tests if this creature has a bounty on another creature. - * - * @param target the creature to test if we have a bounty on - * - * @return true if we have a bounty on the target, false if not - */ -bool SwgCreatureObject::hasBounty(const CreatureObject & target) const -{ - const SwgCreatureObject * swgTarget = dynamic_cast( - &target); - if (swgTarget == NULL) - return false; - - JediManagerObject * jediManager = static_cast( - ServerUniverse::getInstance()).getJediManager(); - NOT_NULL(jediManager); - - return jediManager->hasBountyOnJedi(target.getNetworkId(), getNetworkId()); -} // SwgCreatureObject::hasBounty - -// ---------------------------------------------------------------------- - -/** - * Tests if this creature has a bounty on any other creature. - * - * @return true if we have a bounty, false if not - */ -bool SwgCreatureObject::hasBounty() const -{ - JediManagerObject * jediManager = static_cast( - ServerUniverse::getInstance()).getJediManager(); - NOT_NULL(jediManager); - - return jediManager->hasBountyOnJedi(getNetworkId()); -} - -// ---------------------------------------------------------------------- - -std::vector const & SwgCreatureObject::getJediBountiesOnMe() const -{ - JediManagerObject * jediManager = static_cast( - ServerUniverse::getInstance()).getJediManager(); - NOT_NULL(jediManager); - - return jediManager->getJediBounties(getNetworkId()); -} - -// ---------------------------------------------------------------------- - -int SwgCreatureObject::getBountyValue() const -{ - int bountyValue; - if (getObjVars().getItem("bounty.amount", bountyValue)) - return bountyValue; - - return 0; -} - -//------------------------------------------------------------------------------------------ - -const bool SwgCreatureObject::grantSkill(const SkillObject & newSkill) -{ - return CreatureObject::grantSkill(newSkill); -} // SwgCreatureObject::grantSkill - -//----------------------------------------------------------------------- - -void SwgCreatureObject::revokeSkill(const SkillObject & oldSkill) -{ - CreatureObject::revokeSkill(oldSkill); -} // SwgCreatureObject::revokeSkill - -//------------------------------------------------------------------------------------------ - -void SwgCreatureObject::endBaselines() -{ - CreatureObject::endBaselines(); - - // if the player has a bounty value, register him with the bounty manager - if (isAuthoritative() && isPlayerControlled()) - { - int bountyValue = getBountyValue(); - if (bountyValue > 0) - { - SwgPlayerObject const * player = safe_cast(PlayerCreatureController::getPlayerObject(this)); - if (player) - { - JediManagerObject * jediManager = static_cast(ServerUniverse::getInstance()).getJediManager(); - if (jediManager) - { - jediManager->addJedi(getNetworkId(), getObjectName(), - getPosition_w(), getSceneId(), player->getJediVisibility(), - bountyValue, getLevel(), - 0, player->getJediState(), getSpentJediSkillPoints(), getPvpFaction()); - } - } - } - } -} - -//------------------------------------------------------------------------------------------ - -void SwgCreatureObject::onAddedToWorld() -{ - CreatureObject::onAddedToWorld(); - if (isAuthoritative() && isPlayerControlled() && (getBountyValue() > 0)) - { - JediManagerObject * jediManager = static_cast(ServerUniverse::getInstance()).getJediManager(); - if (jediManager != NULL) - { - jediManager->updateJediLocation(getNetworkId(), getPosition_w(), getSceneId()); - } - } -} - -//------------------------------------------------------------------------------------------ - -void SwgCreatureObject::levelChanged() const -{ - CreatureObject::levelChanged(); - - // If the player has a bounty value, update the level with the bounty manager - if (isAuthoritative() && isPlayerControlled() && (getBountyValue() > 0)) - { - JediManagerObject * jediManager = static_cast(ServerUniverse::getInstance()).getJediManager(); - if (jediManager) - { - jediManager->updateJedi(getNetworkId(), -1, -1, getLevel(), -1); - } - } -} - -//------------------------------------------------------------------------------------------ - -void SwgCreatureObject::setPvpFaction(Pvp::FactionId factionId) -{ - Pvp::FactionId oldId = getPvpFaction(); - CreatureObject::setPvpFaction(factionId); - Pvp::FactionId newId = getPvpFaction(); - if ((oldId != newId) && isAuthoritative() && isPlayerControlled() && (getBountyValue() > 0)) - { - JediManagerObject * jediManager = static_cast(ServerUniverse::getInstance()).getJediManager(); - if (jediManager != NULL) - { - jediManager->updateJediFaction(getNetworkId(), newId); - } - } -} diff --git a/src/game/server/application/SwgGameServer/src/shared/object/SwgCreatureObject.h b/src/game/server/application/SwgGameServer/src/shared/object/SwgCreatureObject.h deleted file mode 100644 index 8473a4e87..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/object/SwgCreatureObject.h +++ /dev/null @@ -1,61 +0,0 @@ -//======================================================================== -// -// SwgCreatureObject.h -// -// copyright 2001 Sony Online Entertainment -// -//======================================================================== - -#ifndef INCLUDED_SwgCreatureObject_H -#define INCLUDED_SwgCreatureObject_H - -#include "serverGame/CreatureObject.h" - - -class ServerCreatureObjectTemplate; - - -//---------------------------------------------------------------------- - -class SwgCreatureObject : public CreatureObject -{ -public: - explicit SwgCreatureObject(const ServerCreatureObjectTemplate * newTemplate); - virtual ~SwgCreatureObject(); - - virtual void handleCMessageTo (const MessageToPayload &message); - - bool isJedi(void) const; - const int getSpentJediSkillPoints() const; - - virtual Controller* createDefaultController(); - virtual float alter(float time); - virtual void onRemovingFromWorld(); - virtual void onPermanentlyDestroyed(); - - virtual bool hasBounty(const CreatureObject & target) const; - virtual bool hasBounty() const; - virtual std::vector const & getJediBountiesOnMe() const; - int getBountyValue() const; - - virtual const bool grantSkill(const SkillObject & newSkill); - virtual void revokeSkill(const SkillObject & oldSkill); - - virtual void setPvpFaction(Pvp::FactionId factionId); - -protected: - virtual void endBaselines(); - virtual void onAddedToWorld(); - virtual void levelChanged() const; - -private: - SwgCreatureObject(); - SwgCreatureObject(const SwgCreatureObject& rhs); - SwgCreatureObject& operator=(const SwgCreatureObject& rhs); -}; - - -//---------------------------------------------------------------------- - - -#endif // INCLUDED_SwgCreatureObject_H diff --git a/src/game/server/application/SwgGameServer/src/shared/object/SwgPlayerObject.cpp b/src/game/server/application/SwgGameServer/src/shared/object/SwgPlayerObject.cpp deleted file mode 100644 index ef587054f..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/object/SwgPlayerObject.cpp +++ /dev/null @@ -1,374 +0,0 @@ -//======================================================================== -// -// SwgCreatureObject.cpp -// -// copyright 2001 Sony Online Entertainment -// -//======================================================================== - -#include "FirstSwgGameServer.h" -#include "SwgGameServer/SwgCreatureObject.h" -#include "SwgGameServer/SwgPlayerObject.h" -#include "serverGame/ConfigServerGame.h" -#include "serverGame/CreatureObject.h" -#include "serverGame/PlayerObject.h" -#include "serverNetworkMessages/MessageToPayload.h" -#include "sharedFoundation/DynamicVariableList.h" -#include "sharedNetworkMessages/MessageQueueGenericValueType.h" -#include "SwgGameServer/JediManagerObject.h" -#include "SwgGameServer/SwgServerUniverse.h" -#include "serverGame/PlayerCreatureController.h" - - -//---------------------------------------------------------------------- - -// jedi/force power objvars -const static std::string OBJVAR_JEDI("jedi"); -const static std::string OBJVAR_JEDI_STATE("jedi.state"); -const static std::string OBJVAR_FORCE_REGEN_RATE("jedi.regenrate"); -const static std::string OBJVAR_FORCE_REGEN_VALUE("jedi.regenvalue"); -const static std::string OBJVAR_JEDI_VISIBILITY("jedi.visibility"); -const static std::string OBJVAR_JEDI_BOUNTIES("jedi.objKillers"); - - -//---------------------------------------------------------------------- - -/** - * Class constructor. - */ -SwgPlayerObject::SwgPlayerObject(const ServerPlayerObjectTemplate* newTemplate) : - PlayerObject(newTemplate), - m_updateJediLocationTime(0), - m_jediState(0) -{ - addMembersToPackages(); -} // SwgCreatureObject::SwgCreatureObject - -//---------------------------------------------------------------------- - -/** - * Class destructor. - */ -SwgPlayerObject::~SwgPlayerObject() -{ -} // SwgPlayerObject::~SwgPlayerObject - -//---------------------------------------------------------------------- - -/** - * Sets up auto-sync data. - */ -void SwgPlayerObject::addMembersToPackages() -{ - //@todo: do we want to make a game equivalent of package.txt and Packager.cpp? - addFirstParentAuthClientServerVariable_np (m_jediState); -} // SwgPlayerObject::addMembersToPackages - -//---------------------------------------------------------------------- - -/** - * Initializes data for a proxy object. - */ -void SwgPlayerObject::endBaselines() -{ - PlayerObject::endBaselines(); - - if (isAuthoritative()) - { - // get the jediState from the objvar - int jediState = 0; - if (getObjVars().getItem(OBJVAR_JEDI_STATE, jediState)) - m_jediState = static_cast(jediState); - } -} // SwgPlayerObject::endBaselines - -//---------------------------------------------------------------------- - -/** - * Called when we are made authoritative. - */ -void SwgPlayerObject::virtualOnSetAuthority() -{ - PlayerObject::virtualOnSetAuthority(); - - const SwgCreatureObject * owner = safe_cast(getCreatureObject()); - if ((owner != NULL) && owner->isPlayerControlled() && (owner->getBountyValue() > 0)) - { - // tell the Jedi manager our position - JediManagerObject * jediManager = static_cast( - ServerUniverse::getInstance()).getJediManager(); - if (jediManager != NULL) - { - jediManager->updateJediLocation(owner->getNetworkId(), - owner->getPosition_w(), owner->getSceneId()); - } - m_updateJediLocationTime = 0; - } -} // SwgPlayerObject::virtualOnSetAuthority - -//---------------------------------------------------------------------- - -/** - * Sets the Jedi state for the player. - * - * @param state the new state - */ -void SwgPlayerObject::setJediState(JediState state) -{ - if (state == JS_none || - state == JS_forceSensitive || - state == JS_jedi || - state == JS_forceRankedLight || - state == JS_forceRankedDark - ) - { - if (isAuthoritative()) - { - // get our current state for comparison - JediState oldState = getJediState(); - bool oldIsJedi = isJedi(); - - m_jediState = state; - if (state == JS_none) - { - if (oldState != JS_none) - { - // we are no longer force sensitive - removeObjVarItem(OBJVAR_JEDI); - setMaxForcePower(0); - } - } - else - { - setObjVarItem(OBJVAR_JEDI_STATE, state); - if (oldState == JS_none) - { - // we are newly force sensitive - // note that our max force power needs to be set separately - WARNING(getForcePowerRegenRate() > 0, ("SwgPlayerObject::setJediState, " - "resetting force power regen for player %s that has a non-zero " - "regen value %f", getAccountDescription(getCreatureObject()).c_str(), - getForcePowerRegenRate())); - setForcePowerRegenRate(ConfigServerGame::getMinForcePowerRegenRate()); - } - } - - // check if our Jedi status has turned on or off - if (!oldIsJedi && isJedi()) - { - setJediVisibility(0); - } - } - else - { - sendControllerMessageToAuthServer(CM_setJediState, - new MessageQueueGenericValueType(static_cast(state))); - } - } - else - { - WARNING(true, ("setJediState for player %s invalid state %d", - getAccountDescription(getCreatureObject()).c_str(), state)); - } -} - -//---------------------------------------------------------------------- - -/** - * Updates the time from when we sent the Jedi manager our position. - * - * @param time time since the last call - */ -void SwgPlayerObject::updateJediLocationTime(float time) -{ - if (isAuthoritative()) - { - m_updateJediLocationTime += time; - if (m_updateJediLocationTime > static_cast( - ConfigServerGame::getJediUpdateLocationTimeSeconds())) - { - m_updateJediLocationTime = 0; - - // tell the Jedi manager our position - JediManagerObject * jediManager = static_cast( - ServerUniverse::getInstance()).getJediManager(); - if (jediManager != NULL) - { - const CreatureObject * owner = getCreatureObject(); - if (owner->isInWorld()) - { - jediManager->updateJediLocation(owner->getNetworkId(), - owner->getPosition_w(), owner->getSceneId()); - } - } - } - } -} // SwgPlayerObject::updateJediLocationTime - -//---------------------------------------------------------------------- - -/** - * Sets the visibility of a Jedi. - * - * @param visibility the visibility value - */ -void SwgPlayerObject::setJediVisibility(int visibility) -{ - if (!isJedi()) - return; - - if (visibility < 0) - visibility = 0; - - setObjVarItem(OBJVAR_JEDI_VISIBILITY, visibility); -} // SwgPlayerObject::setJediVisibility - -//---------------------------------------------------------------------- - -/** - * Returns the visibility of a Jedi. - * - * @return the visibility of the Jedi - */ -int SwgPlayerObject::getJediVisibility(void) const -{ - if (!isJedi()) - return 0; - - int visibility; - if (!getObjVars().getItem(OBJVAR_JEDI_VISIBILITY,visibility)) - { - WARNING(true, ("Jedi %s doesn't have a visibility objvar, adding one", - getNetworkId().getValueString().c_str())); - const_cast(this)->setJediVisibility(0); - return 0; - } - return visibility; -} // SwgPlayerObject::getJediVisibility - -//---------------------------------------------------------------------- - -/** - * Adds a bounty hunter to the list of players hunting this Jedi. - * - * @param hunter the bounty hunter's id - */ -/* -void SwgPlayerObject::addJediBounty(const NetworkId & hunter) -{ - if (!isJedi()) - return; - - std::vector bounties; - if (getObjVars().getItem(OBJVAR_JEDI_BOUNTIES, bounties)) - { - // make sure we don't have the hunter already on our list - if (std::find(bounties.begin(), bounties.end(), hunter) == bounties.end()) - { - bounties.push_back(hunter); - setObjVarItem(OBJVAR_JEDI_BOUNTIES, bounties); - } - } - - // note that since this function should only be called due to the Jedi - // manager being updated, so we don't forward this to the manager like - // we do with setJediBounties -} // SwgPlayerObject::addJediBounty -*/ - -//---------------------------------------------------------------------- - -/** - * Removes a bounty hunter from the list of players hunting this Jedi. - * - * @param hunter the bounty hunter's id - */ -/* -void SwgPlayerObject::removeJediBounty(const NetworkId & hunter) -{ - if (!isJedi()) - return; - - std::vector bounties; - if (getObjVars().getItem(OBJVAR_JEDI_BOUNTIES, bounties)) - { - std::vector::iterator i = std::find(bounties.begin(), - bounties.end(), hunter); - if (i != bounties.end()) - { - bounties.erase(i); - setObjVarItem(OBJVAR_JEDI_BOUNTIES, bounties); - } - } - - // note that since this function should only be called due to the Jedi - // manager being updated, so we don't forward this to the manager like - // we do with setJediBounties -} // SwgPlayerObject::removeJediBounty -*/ - -//---------------------------------------------------------------------- - -/** - * Sets the bounties on a Jedi. - * - * @param bounties the number of bounties - * -void SwgPlayerObject::setJediBounties(const std::vector & bounties) -{ - if (!isJedi()) - return; - - setObjVarItem(OBJVAR_JEDI_BOUNTIES, bounties); - - // update the Jedi manager - JediManagerObject * jediManager = static_cast( - ServerUniverse::getInstance()).getJediManager(); - if (jediManager != NULL) - { - const CreatureObject * owner = getCreatureObject(); - jediManager->updateJedi(owner->getNetworkId(), bounties); - } -} // SwgPlayerObject::setJediBounties -*/ -//---------------------------------------------------------------------- - -/** - * Returns the bounties on a Jedi once for old characters. Once this function is - * called for a player, assume the Jedi manager is authoritative for who - * has bounties on this Jedi. - * - * @param bounties vector to be filled in with the ids of the players - * hunting the Jedi - * - * @return true if bounties has good data, false if not - */ -/* -bool SwgPlayerObject::getJediBounties(std::vector & bounties) -{ - if (!isJedi()) - return false; - - bounties.clear(); - SwgCreatureObject * owner = safe_cast(getCreatureObject()); - if (owner != NULL) - { - if (owner->getObjVars().getItem(OBJVAR_JEDI_BOUNTIES, bounties)) - { - // remove the objvar, the Jedi manager is authoritative for this data - owner->removeObjVarItem(OBJVAR_JEDI_BOUNTIES); - } - } - return true; -} // SwgPlayerObject::getJediBounties -*/ -/** - * Calculates whether a player is a jedi - * - * @return true if the player is a jedi - */ -bool SwgPlayerObject::isJedi() const -{ - return (getJediState() & (JS_jedi | JS_forceRankedLight | JS_forceRankedDark)) != 0; -} - diff --git a/src/game/server/application/SwgGameServer/src/shared/object/SwgPlayerObject.h b/src/game/server/application/SwgGameServer/src/shared/object/SwgPlayerObject.h deleted file mode 100644 index 2e5f61505..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/object/SwgPlayerObject.h +++ /dev/null @@ -1,66 +0,0 @@ -//======================================================================== -// -// SwgPlayerObject.h -// -// copyright 2001 Sony Online Entertainment -// -//======================================================================== - -#ifndef INCLUDED_SwgPlayerObject_H -#define INCLUDED_SwgPlayerObject_H - -#include "serverGame/PlayerObject.h" -#include "swgSharedUtility/JediConstants.h" - -class ServerPlayerObjectTemplate; - - -//---------------------------------------------------------------------- - -class SwgPlayerObject : public PlayerObject -{ -public: - explicit SwgPlayerObject(const ServerPlayerObjectTemplate * newTemplate); - virtual ~SwgPlayerObject(); - - // Jedi functions - virtual bool isJedi(void) const; - JediState getJediState() const; - void setJediState(JediState state); - void updateJediLocationTime(float time); - void setJediVisibility(int visibility); - int getJediVisibility(void) const; -// void addJediBounty(const NetworkId & hunter); -// void removeJediBounty(const NetworkId & hunter); -// void setJediBounties(const std::vector & bounties); -// bool getJediBounties(std::vector & bounties); - -protected: - virtual void endBaselines(); - virtual void virtualOnSetAuthority(); - -private: - void addMembersToPackages(); - -// bool getJediBounties(std::vector & bounties); - -private: - SwgPlayerObject(); - SwgPlayerObject(const SwgPlayerObject & rhs); - SwgPlayerObject & operator=(const SwgPlayerObject & rhs); - -private: - float m_updateJediLocationTime; - Archive::AutoDeltaVariable m_jediState; -}; - - -//---------------------------------------------------------------------- - -inline JediState SwgPlayerObject::getJediState() const -{ - return static_cast(m_jediState.get()); -} - - -#endif // INCLUDED_SwgPlayerObject_H diff --git a/src/game/server/application/SwgGameServer/src/shared/objectTemplate/ServerJediManagerObjectTemplate.cpp b/src/game/server/application/SwgGameServer/src/shared/objectTemplate/ServerJediManagerObjectTemplate.cpp deleted file mode 100644 index 90edb0a34..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/objectTemplate/ServerJediManagerObjectTemplate.cpp +++ /dev/null @@ -1,186 +0,0 @@ -//======================================================================== -// -// ServerJediManagerObjectTemplate.cpp -// -//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be -//overwritten the next time the template definition is compiled. Do not -//make changes to code inside these blocks. -// -// copyright 2001 Sony Online Entertainment -// -//======================================================================== - -#include "FirstSwgGameServer.h" -#include "ServerJediManagerObjectTemplate.h" -#include "sharedDebug/DataLint.h" -#include "sharedFile/Iff.h" -#include "sharedObject/ObjectTemplate.h" -#include "sharedObject/ObjectTemplateList.h" -#include "SwgGameServer/JediManagerObject.h" -//@BEGIN TFD TEMPLATE REFS -//@END TFD TEMPLATE REFS -#include - -const std::string DefaultString(""); -const StringId DefaultStringId("", 0); -const Vector DefaultVector(0,0,0); -const TriggerVolumeData DefaultTriggerVolumeData; - -bool ServerJediManagerObjectTemplate::ms_allowDefaultTemplateParams = true; - - -/** - * Class constructor. - */ -ServerJediManagerObjectTemplate::ServerJediManagerObjectTemplate(const std::string & filename) -//@BEGIN TFD INIT - : ServerUniverseObjectTemplate(filename) - ,m_versionOk(true) -//@END TFD INIT -{ -} // ServerJediManagerObjectTemplate::ServerJediManagerObjectTemplate - -/** - * Class destructor. - */ -ServerJediManagerObjectTemplate::~ServerJediManagerObjectTemplate() -{ -//@BEGIN TFD CLEANUP -//@END TFD CLEANUP -} // ServerJediManagerObjectTemplate::~ServerJediManagerObjectTemplate - -/** - * Static function used to register this template. - */ -void ServerJediManagerObjectTemplate::registerMe(void) -{ - ObjectTemplateList::registerTemplate(ServerJediManagerObjectTemplate_tag, create); -} // ServerJediManagerObjectTemplate::registerMe - -/** - * Creates a ServerJediManagerObjectTemplate template. - * - * @return a new instance of the template - */ -ObjectTemplate * ServerJediManagerObjectTemplate::create(const std::string & filename) -{ - return new ServerJediManagerObjectTemplate(filename); -} // ServerJediManagerObjectTemplate::create - -/** - * Returns the template id. - * - * @return the template id - */ -Tag ServerJediManagerObjectTemplate::getId(void) const -{ - return ServerJediManagerObjectTemplate_tag; -} // ServerJediManagerObjectTemplate::getId - -/** - * Returns this template's version. - * - * @return the version - */ -Tag ServerJediManagerObjectTemplate::getTemplateVersion(void) const -{ - return m_templateVersion; -} // ServerJediManagerObjectTemplate::getTemplateVersion - -/** - * Returns the highest version of this template or it's base templates. - * - * @return the highest version - */ -Tag ServerJediManagerObjectTemplate::getHighestTemplateVersion(void) const -{ - if (m_baseData == NULL) - return m_templateVersion; - const ServerJediManagerObjectTemplate * base = dynamic_cast(m_baseData); - if (base == NULL) - return m_templateVersion; - return std::max(m_templateVersion, base->getHighestTemplateVersion()); -} // ServerJediManagerObjectTemplate::getHighestTemplateVersion - -/** - * Creates a new object from this template. - * - * @return the object - */ -Object * ServerJediManagerObjectTemplate::createObject(void) const -{ - return new JediManagerObject(this); -} // ServerJediManagerObjectTemplate::createObject - -//@BEGIN TFD -#ifdef _DEBUG -/** - * Special function used by datalint. Checks for duplicate values in base and derived templates. - */ -void ServerJediManagerObjectTemplate::testValues(void) const -{ - ServerUniverseObjectTemplate::testValues(); -} // ServerJediManagerObjectTemplate::testValues -#endif - -/** - * Loads the template data from an iff file. We should already be in the form - * for this template. - * - * @param file file to load from - */ -void ServerJediManagerObjectTemplate::load(Iff &file) -{ -static const int MAX_NAME_SIZE = 256; -char paramName[MAX_NAME_SIZE]; - - if (file.getCurrentName() != ServerJediManagerObjectTemplate_tag) - { - ServerUniverseObjectTemplate::load(file); - return; - } - - file.enterForm(); - m_templateVersion = file.getCurrentName(); - if (m_templateVersion == TAG(D,E,R,V)) - { - file.enterForm(); - file.enterChunk(); - std::string baseFilename; - file.read_string(baseFilename); - file.exitChunk(); - const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename); - DEBUG_WARNING(base == NULL, ("was unable to load base template %s", baseFilename.c_str())); - if (m_baseData == base && base != NULL) - base->releaseReference(); - else - { - if (m_baseData != NULL) - m_baseData->releaseReference(); - m_baseData = base; - } - file.exitForm(); - m_templateVersion = file.getCurrentName(); - } - if (getHighestTemplateVersion() != TAG(0,0,0,0)) - { - if (DataLint::isEnabled()) - DEBUG_WARNING(true, ("template %s version out of date", file.getFileName())); - m_versionOk = false; - } - - file.enterForm(); - - file.enterChunk(); - int paramCount = file.read_int32(); - file.exitChunk(); - UNREF(paramName); - UNREF(paramCount); - - file.exitForm(); - ServerUniverseObjectTemplate::load(file); - file.exitForm(); - return; -} // ServerJediManagerObjectTemplate::load - -//@END TFD diff --git a/src/game/server/application/SwgGameServer/src/shared/objectTemplate/ServerJediManagerObjectTemplate.h b/src/game/server/application/SwgGameServer/src/shared/objectTemplate/ServerJediManagerObjectTemplate.h deleted file mode 100644 index 89add3bd8..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/objectTemplate/ServerJediManagerObjectTemplate.h +++ /dev/null @@ -1,87 +0,0 @@ -//======================================================================== -// -// ServerJediManagerObjectTemplate.h -// -//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be -//overwritten the next time the template definition is compiled. Do not -//make changes to code inside these blocks. -// -// copyright 2001 Sony Online Entertainment -// -//======================================================================== - -#ifndef _INCLUDED_ServerJediManagerObjectTemplate_H -#define _INCLUDED_ServerJediManagerObjectTemplate_H - -#include "serverGame/ServerUniverseObjectTemplate.h" -#include "../../../../../../engine/shared/library/sharedFoundation/include/public/sharedFoundation/DynamicVariable.h" -#include "sharedUtility/TemplateParameter.h" - - -class Vector; -typedef StructParam StructParamOT; -//@BEGIN TFD TEMPLATE REFS -//@END TFD TEMPLATE REFS - - -class ServerJediManagerObjectTemplate : public ServerUniverseObjectTemplate -{ -public: -//@BEGIN TFD ID - enum - { - ServerJediManagerObjectTemplate_tag = TAG(J,E,D,I) - }; -//@END TFD ID -public: - ServerJediManagerObjectTemplate(const std::string & filename); - virtual ~ServerJediManagerObjectTemplate(); - - virtual Tag getId(void) const; - virtual Tag getTemplateVersion(void) const; - virtual Tag getHighestTemplateVersion(void) const; - static void install(bool allowDefaultTemplateParams = true); - -//@BEGIN TFD -public: - -#ifdef _DEBUG -public: - // special code used by datalint - virtual void testValues(void) const; -#endif - -protected: - virtual void load(Iff &file); - -private: -//@END TFD - -public: - // user functions - virtual Object * createObject(void) const; - -private: - Tag m_templateVersion; // the template version - bool m_versionOk; // flag that the template version loaded is the one we expect - static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling - - static void registerMe(void); - static ObjectTemplate * create(const std::string & filename); - - // no copying - ServerJediManagerObjectTemplate(const ServerJediManagerObjectTemplate &); - ServerJediManagerObjectTemplate & operator =(const ServerJediManagerObjectTemplate &); -}; - - -inline void ServerJediManagerObjectTemplate::install(bool allowDefaultTemplateParams) -{ - ms_allowDefaultTemplateParams = allowDefaultTemplateParams; -//@BEGIN TFD INSTALL - ServerJediManagerObjectTemplate::registerMe(); -//@END TFD INSTALL -} - - -#endif // _INCLUDED_ServerJediManagerObjectTemplate_H diff --git a/src/game/server/application/SwgGameServer/src/shared/objectTemplate/SwgServerCreatureObjectTemplate.cpp b/src/game/server/application/SwgGameServer/src/shared/objectTemplate/SwgServerCreatureObjectTemplate.cpp deleted file mode 100644 index 81fd99fd4..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/objectTemplate/SwgServerCreatureObjectTemplate.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//======================================================================== -// -// SwgServerCreatureObjectTemplate.cpp -// -// copyright 2001 Sony Online Entertainment -// -//======================================================================== - -#include "FirstSwgGameServer.h" -#include "SwgGameServer/SwgServerCreatureObjectTemplate.h" -#include "sharedObject/ObjectTemplateList.h" -#include "SwgGameServer/SwgCreatureObject.h" - - -/** - * Class constructor. - */ -SwgServerCreatureObjectTemplate::SwgServerCreatureObjectTemplate(const std::string & filename) : - ServerCreatureObjectTemplate(filename) -{ -} // SwgServerCreatureObjectTemplate::SwgServerCreatureObjectTemplate - -/** - * Class destructor. - */ -SwgServerCreatureObjectTemplate::~SwgServerCreatureObjectTemplate() -{ -} // SwgServerCreatureObjectTemplate::~SwgServerCreatureObjectTemplate - -/** - * Replaces the ServerCreatureObjectTemplate tag->create mapping with our own. - */ -void SwgServerCreatureObjectTemplate::install(void) -{ - ObjectTemplateList::assignBinding(ServerCreatureObjectTemplate_tag, create); -} // SwgServerCreatureObjectTemplate::install - -/** - * Creates a SwgServerCreatureObjectTemplate template. - * - * @return a new instance of the template - */ -ObjectTemplate * SwgServerCreatureObjectTemplate::create(const std::string & filename) -{ - return new SwgServerCreatureObjectTemplate(filename); -} // SwgServerCreatureObjectTemplate::create - -/** - * Creates a new object from this template. - * - * @return the object - */ -Object * SwgServerCreatureObjectTemplate::createObject(void) const -{ - return new SwgCreatureObject(this); -} // SwgServerCreatureObjectTemplate::createObject - diff --git a/src/game/server/application/SwgGameServer/src/shared/objectTemplate/SwgServerCreatureObjectTemplate.h b/src/game/server/application/SwgGameServer/src/shared/objectTemplate/SwgServerCreatureObjectTemplate.h deleted file mode 100644 index cd2ed3947..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/objectTemplate/SwgServerCreatureObjectTemplate.h +++ /dev/null @@ -1,33 +0,0 @@ -//======================================================================== -// -// SwgServerCreatureObjectTemplate.h -// -// copyright 2001 Sony Online Entertainment -// -//======================================================================== - -#ifndef _INCLUDED_SwgServerCreatureObjectTemplate_H -#define _INCLUDED_SwgServerCreatureObjectTemplate_H - -#include "serverGame/ServerCreatureObjectTemplate.h" - - -class SwgServerCreatureObjectTemplate : public ServerCreatureObjectTemplate -{ -public: - SwgServerCreatureObjectTemplate(const std::string & filename); - virtual ~SwgServerCreatureObjectTemplate(); - - static void install(void); - virtual Object * createObject(void) const; - -private: - static ObjectTemplate * create(const std::string & filename); - - // no copying - SwgServerCreatureObjectTemplate(const SwgServerCreatureObjectTemplate &); - SwgServerCreatureObjectTemplate & operator =(const SwgServerCreatureObjectTemplate &); -}; - - -#endif // _INCLUDED_SwgServerCreatureObjectTemplate_H diff --git a/src/game/server/application/SwgGameServer/src/shared/objectTemplate/SwgServerPlayerObjectTemplate.cpp b/src/game/server/application/SwgGameServer/src/shared/objectTemplate/SwgServerPlayerObjectTemplate.cpp deleted file mode 100644 index 2669b8aa7..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/objectTemplate/SwgServerPlayerObjectTemplate.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//======================================================================== -// -// SwgServerPlayerObjectTemplate.cpp -// -// copyright 2001 Sony Online Entertainment -// -//======================================================================== - -#include "FirstSwgGameServer.h" -#include "SwgGameServer/SwgServerPlayerObjectTemplate.h" -#include "sharedObject/ObjectTemplateList.h" -#include "SwgGameServer/SwgPlayerObject.h" - - -/** - * Class constructor. - */ -SwgServerPlayerObjectTemplate::SwgServerPlayerObjectTemplate(const std::string & filename) : - ServerPlayerObjectTemplate(filename) -{ -} // SwgServerPlayerObjectTemplate::SwgServerPlayerObjectTemplate - -/** - * Class destructor. - */ -SwgServerPlayerObjectTemplate::~SwgServerPlayerObjectTemplate() -{ -} // SwgServerPlayerObjectTemplate::~SwgServerPlayerObjectTemplate - -/** - * Replaces the ServerCreatureObjectTemplate tag->create mapping with our own. - */ -void SwgServerPlayerObjectTemplate::install(void) -{ - ObjectTemplateList::assignBinding(ServerPlayerObjectTemplate_tag, create); -} // SwgServerPlayerObjectTemplate::install - -/** - * Creates a SwgServerPlayerObjectTemplate template. - * - * @return a new instance of the template - */ -ObjectTemplate * SwgServerPlayerObjectTemplate::create(const std::string & filename) -{ - return new SwgServerPlayerObjectTemplate(filename); -} // SwgServerPlayerObjectTemplate::create - -/** - * Creates a new object from this template. - * - * @return the object - */ -Object * SwgServerPlayerObjectTemplate::createObject(void) const -{ - return new SwgPlayerObject(this); -} // SwgServerPlayerObjectTemplate::createObject - diff --git a/src/game/server/application/SwgGameServer/src/shared/objectTemplate/SwgServerPlayerObjectTemplate.h b/src/game/server/application/SwgGameServer/src/shared/objectTemplate/SwgServerPlayerObjectTemplate.h deleted file mode 100644 index b62d77733..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/objectTemplate/SwgServerPlayerObjectTemplate.h +++ /dev/null @@ -1,33 +0,0 @@ -//======================================================================== -// -// SwgServerPlayerObjectTemplate.h -// -// copyright 2001 Sony Online Entertainment -// -//======================================================================== - -#ifndef _INCLUDED_SwgServerPlayerObjectTemplate_H -#define _INCLUDED_SwgServerPlayerObjectTemplate_H - -#include "serverGame/ServerPlayerObjectTemplate.h" - - -class SwgServerPlayerObjectTemplate : public ServerPlayerObjectTemplate -{ -public: - SwgServerPlayerObjectTemplate(const std::string & filename); - virtual ~SwgServerPlayerObjectTemplate(); - - static void install(void); - virtual Object * createObject(void) const; - -private: - static ObjectTemplate * create(const std::string & filename); - - // no copying - SwgServerPlayerObjectTemplate(const SwgServerPlayerObjectTemplate &); - SwgServerPlayerObjectTemplate & operator =(const SwgServerPlayerObjectTemplate &); -}; - - -#endif // _INCLUDED_SwgServerPlayerObjectTemplate_H diff --git a/src/game/server/application/SwgGameServer/src/shared/snapshot/WorldSnapshotParser.cpp b/src/game/server/application/SwgGameServer/src/shared/snapshot/WorldSnapshotParser.cpp deleted file mode 100644 index 998a835d1..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/snapshot/WorldSnapshotParser.cpp +++ /dev/null @@ -1,366 +0,0 @@ -//=================================================================== -// -// WorldSnapshotParser.cpp -// asommers -// -// copyright 2002, sony online entertainment -// -//=================================================================== - -#include "FirstSwgGameServer.h" -#include "SwgGameServer/WorldSnapshotParser.h" - -#include "serverGame/ServerBuildingObjectTemplate.h" -#include "serverGame/ServerCellObjectTemplate.h" -#include "serverGame/ServerObjectTemplate.h" -#include "serverGame/ServerStaticObjectTemplate.h" -#include "serverGame/ServerTangibleObjectTemplate.h" -#include "serverGame/ServerWorld.h" -#include "sharedFile/TreeFile.h" -#include "sharedFoundation/ConstCharCrcString.h" -#include "sharedFoundation/PointerDeleter.h" -#include "sharedGame/SharedObjectTemplate.h" -#include "sharedObject/ObjectTemplateList.h" -#include "sharedObject/PortalPropertyTemplate.h" -#include "sharedUtility/WorldSnapshotReaderWriter.h" -#include "sharedMath/Quaternion.h" -#include "sharedMath/Transform.h" -#include "sharedMath/Vector.h" - -#include -#include -#include -#include - -//=================================================================== - -namespace -{ - //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - const char* const ms_serverCellObjectTemplateName = "object/cell/cell.iff"; - - typedef std::map PlanetMap; - PlanetMap ms_planetMap; - - //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - static void install () - { - IGNORE_RETURN (ms_planetMap.insert (std::make_pair (std::string ("corellia"), new WorldSnapshotReaderWriter))); - IGNORE_RETURN (ms_planetMap.insert (std::make_pair (std::string ("dantooine"), new WorldSnapshotReaderWriter))); - IGNORE_RETURN (ms_planetMap.insert (std::make_pair (std::string ("dathomir"), new WorldSnapshotReaderWriter))); - IGNORE_RETURN (ms_planetMap.insert (std::make_pair (std::string ("dungeon1"), new WorldSnapshotReaderWriter))); - IGNORE_RETURN (ms_planetMap.insert (std::make_pair (std::string ("endor"), new WorldSnapshotReaderWriter))); - IGNORE_RETURN (ms_planetMap.insert (std::make_pair (std::string ("lok"), new WorldSnapshotReaderWriter))); - IGNORE_RETURN (ms_planetMap.insert (std::make_pair (std::string ("naboo"), new WorldSnapshotReaderWriter))); - IGNORE_RETURN (ms_planetMap.insert (std::make_pair (std::string ("rori"), new WorldSnapshotReaderWriter))); - IGNORE_RETURN (ms_planetMap.insert (std::make_pair (std::string ("talus"), new WorldSnapshotReaderWriter))); - IGNORE_RETURN (ms_planetMap.insert (std::make_pair (std::string ("tatooine"), new WorldSnapshotReaderWriter))); - IGNORE_RETURN (ms_planetMap.insert (std::make_pair (std::string ("yavin4"), new WorldSnapshotReaderWriter))); - } - - //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - static void remove () - { - std::for_each (ms_planetMap.begin (), ms_planetMap.end (), PointerDeleterPairSecond ()); - ms_planetMap.clear (); - } - - //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void advancePastWhitespace (const char*& buffer) - { - NOT_NULL (buffer); - while (*buffer && (*buffer == ' ' || *buffer == '\t' || *buffer == '\r' || *buffer == '\n')) - ++buffer; - } - - //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void advancePastToken (const char*& buffer) - { - NOT_NULL (buffer); - while (*buffer && !(*buffer == ' ' || *buffer == '\t' || *buffer == '\r' || *buffer == '\n')) - ++buffer; - - advancePastWhitespace (buffer); - } - - //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -} - -//=================================================================== - -void WorldSnapshotParser::createWorldSnapshots (const char* const filename) -{ - //-- make sure the file exists - FILE* infile = fopen (filename, "rt"); - FATAL (!infile, ("%s does not exist", filename)); - - //-- install - install (); - - DEBUG_REPORT_LOG_PRINT (true, ("----- START: WorldSnapshotParser::createWorldSnapshots -----\n")); - - //-- setup parsing - char buffer [1024]; - char planetName [32]; - int networkIdInt; - Vector position; - Quaternion orientation; - int containedByNetworkIdInt; - char serverObjectTemplateName [256]; - int cellIndex; - uint32 portalLayoutCrc; - std::vector objectTemplateList; - std::vector validNetworkIdList; - -/* - select scene_id||chr(9)|| - object_id||chr(9)|| - x||chr(9)|| - y||chr(9)|| - z||chr(9)|| - quaternion_w||chr(9)|| - quaternion_x||chr(9)|| - quaternion_y||chr(9)|| - quaternion_z||chr(9)|| - contained_by||chr(9)|| - object_template_crc||chr(10) - cell_index where object_template == ms_serverCellObjectTemplateName - -*/ - - //-- scan each line of the file - bool quit = false; - while (!quit && fgets (buffer, 1024, infile) != 0) - { - const char* current = buffer; - - //-- skip past blank lines - advancePastWhitespace (current); - if (*current == 0) - continue; - - //-- start parsing parameters - sscanf (current, "%s", planetName); - advancePastToken (current); - - sscanf (current, "%i", &networkIdInt); - advancePastToken (current); - - sscanf (current, "%f", &position.x); - advancePastToken (current); - - sscanf (current, "%f", &position.y); - advancePastToken (current); - - sscanf (current, "%f", &position.z); - advancePastToken (current); - - sscanf (current, "%f", &orientation.w); - advancePastToken (current); - - sscanf (current, "%f", &orientation.x); - advancePastToken (current); - - sscanf (current, "%f", &orientation.y); - advancePastToken (current); - - sscanf (current, "%f", &orientation.z); - advancePastToken (current); - - sscanf (current, "%i", &containedByNetworkIdInt); - advancePastToken (current); - - char possibleServerObjectTemplateName [256]; - sscanf (current, "%s", possibleServerObjectTemplateName); - advancePastToken (current); - - if (possibleServerObjectTemplateName [0] == 'o') - strcpy (serverObjectTemplateName, possibleServerObjectTemplateName); - else - strcpy (serverObjectTemplateName, ObjectTemplateList::lookUp (static_cast (atoi (possibleServerObjectTemplateName))).getString ()); - - //-- check to see of the object is a cell, and if so, read a cell index (all cells have a cell index) - cellIndex = 0; - if (strcmp (serverObjectTemplateName, ms_serverCellObjectTemplateName) == 0) - { - sscanf (current, "%i", &cellIndex); - advancePastToken (current); - } - - //-- check to see if the object is at the origin - if (containedByNetworkIdInt == 0 && position == Vector::zero) - { - DEBUG_REPORT_LOG_PRINT (true, ("skipping %i - object %s is at the origin of the world on planet %s\n", networkIdInt, serverObjectTemplateName, planetName)); - continue; - } - - //-- check to see if the object is too close to the origin - if (containedByNetworkIdInt == 0 && position.magnitude () < 10.f) - { - DEBUG_REPORT_LOG_PRINT (true, ("skipping %i - object %s is suspiciously close to the origin of the world on planet %s\n", networkIdInt, serverObjectTemplateName, planetName)); - continue; - } - - //-- check to see of the line has a portal crc (may be there, may not) - portalLayoutCrc = 0; - sscanf (current, "%lu", &portalLayoutCrc); - - //-- find the planet - const std::string planetNameString (planetName); - PlanetMap::iterator iter = ms_planetMap.find (planetNameString); - if (iter != ms_planetMap.end ()) - { - WorldSnapshotReaderWriter* const worldSnapshotWriter = iter->second; - NOT_NULL (worldSnapshotWriter); - - //-- verify that the object has a valid contained by object - if (containedByNetworkIdInt != 0) - { - std::sort (validNetworkIdList.begin (), validNetworkIdList.end ()); - if (!std::binary_search (validNetworkIdList.begin (), validNetworkIdList.end (), containedByNetworkIdInt)) - { - DEBUG_REPORT_LOG_PRINT (true, ("skipping %i - containedByNetworkId %i not found for %s\n", networkIdInt, containedByNetworkIdInt, serverObjectTemplateName)); - continue; - } - } - - //-- check to see that the server object template exists - if (!TreeFile::exists (serverObjectTemplateName)) - { - DEBUG_REPORT_LOG_PRINT (true, ("skipping %i - server object template %s does not exist\n", networkIdInt, serverObjectTemplateName)); - continue; - } - - //-- check to see that the object template is of the correct type - const ServerObjectTemplate* const serverObjectTemplate = dynamic_cast (ObjectTemplateList::fetch (serverObjectTemplateName)); - if (!serverObjectTemplate) - { - DEBUG_REPORT_LOG_PRINT (true, ("skipping %i - object template %s is not a valid ServerObjectTemplate\n", networkIdInt, serverObjectTemplateName)); - continue; - } - - objectTemplateList.push_back (serverObjectTemplate); - - if (!(serverObjectTemplate->getId () == ServerBuildingObjectTemplate::ServerBuildingObjectTemplate_tag || - serverObjectTemplate->getId () == ServerCellObjectTemplate::ServerCellObjectTemplate_tag || - serverObjectTemplate->getId () == ServerTangibleObjectTemplate::ServerTangibleObjectTemplate_tag || - serverObjectTemplate->getId () == ServerStaticObjectTemplate::ServerStaticObjectTemplate_tag)) - { - char tagString [5]; - ConvertTagToString (serverObjectTemplate->getId (), tagString); - DEBUG_REPORT_LOG_PRINT (true, ("skipping %i - object template %s not building, cell, or static [%s]\n", networkIdInt, serverObjectTemplateName, tagString)); - continue; - } - - //-- compute the transform - Transform transform_p; - orientation.getTransform (&transform_p); - transform_p.setPosition_p (position); - - //-- extract any necessary variables from the object template - const std::string& sharedObjectTemplateName = serverObjectTemplate->getSharedTemplate (); - - //-- check to see that the shared object template exists - if (!TreeFile::exists (sharedObjectTemplateName.c_str ())) - { - DEBUG_REPORT_LOG_PRINT (true, ("skipping %i - server object template %s specifies shared object template %s which does not exist\n", networkIdInt, serverObjectTemplateName, sharedObjectTemplateName.c_str ())); - continue; - } - - const float radius = serverObjectTemplate->getUpdateRanges (ServerObjectTemplate::UR_far); - - //-- verify portalLayoutCrc - { - //-- make sure the shared template could be loaded - const SharedObjectTemplate* const sharedObjectTemplate = safe_cast (ObjectTemplateList::fetch (sharedObjectTemplateName.c_str ())); - if (!sharedObjectTemplate) - { - DEBUG_REPORT_LOG_PRINT (true, ("skipping %i - server object template %s specifies shared object template %s which could not be loaded\n", networkIdInt, serverObjectTemplateName, sharedObjectTemplateName.c_str ())); - continue; - } - - objectTemplateList.push_back (sharedObjectTemplate); - - //-- - const std::string& portalLayoutFilename = sharedObjectTemplate->getPortalLayoutFilename (); - if (!portalLayoutFilename.empty ()) - { - uint32 extractedPortalLayoutCrc; - if (!PortalPropertyTemplate::extractPortalLayoutCrc (portalLayoutFilename.c_str (), extractedPortalLayoutCrc)) - { - DEBUG_REPORT_LOG_PRINT (true, ("skipping %i - server object template %s specifies shared object template %s with portal layout file %s which could not extract portal layout crc\n", networkIdInt, serverObjectTemplateName, sharedObjectTemplateName.c_str (), portalLayoutFilename.c_str ())); - continue; - } - - if (portalLayoutCrc != extractedPortalLayoutCrc) - { - DEBUG_REPORT_LOG_PRINT (true, ("skipping %i - server object template %s specifies shared object template %s with portal layout file %s with mismatched crcs [%lu != %lu] <%s %1.2f, %1.2f>\n", networkIdInt, serverObjectTemplateName, sharedObjectTemplateName.c_str (), portalLayoutFilename.c_str (), portalLayoutCrc, extractedPortalLayoutCrc, planetName, position.x, position.z)); - continue; - } - } - } - - //-- add the object to the list of valid objects - validNetworkIdList.push_back (networkIdInt); - - //-- add to writer - worldSnapshotWriter->addObject ( - networkIdInt, - containedByNetworkIdInt, - ConstCharCrcString(sharedObjectTemplateName.c_str()), - cellIndex, - transform_p, - radius, - portalLayoutCrc); - -// DEBUG_REPORT_LOG_PRINT (true, ("added %s - %s, %s\n", networkIdString, planetName, sharedObjectTemplateName.c_str ())); - } - else - { - DEBUG_REPORT_LOG_PRINT (true, ("skipping %i - unknown planet %s\n", networkIdInt, planetName)); - } - } - - //-- release all object templates - { - uint i; - for (i = 0; i < objectTemplateList.size (); ++i) - objectTemplateList [i]->releaseReference (); - - objectTemplateList.clear (); - } - - DEBUG_REPORT_LOG_PRINT (true, ("----- SUMMARY: WorldSnapshotParser::createWorldSnapshots -----\n")); - - //-- write the planet maps - { - PlanetMap::iterator iter = ms_planetMap.begin (); - for (; iter != ms_planetMap.end (); ++iter) - { - const WorldSnapshotReaderWriter* const writer = iter->second; - - const std::string fileName = iter->first + ".ws"; - if (!writer->save (fileName.c_str ())) - DEBUG_WARNING (true, ("could not save world snapshot file %s", fileName.c_str ())); - -#ifdef _DEBUG - const int numberOfNodes = writer->getNumberOfNodes (); - const int totalNumberOfNodes = writer->getTotalNumberOfNodes (); - DEBUG_REPORT_LOG_PRINT (true, ("%s has %i root objects and %i total objects\n", iter->first.c_str (), numberOfNodes, totalNumberOfNodes)); -#endif - } - } - - //-- remove - remove (); - - DEBUG_REPORT_LOG_PRINT (true, ("----- END: WorldSnapshotParser::createWorldSnapshots -----\n")); -} - -//=================================================================== - diff --git a/src/game/server/application/SwgGameServer/src/shared/snapshot/WorldSnapshotParser.h b/src/game/server/application/SwgGameServer/src/shared/snapshot/WorldSnapshotParser.h deleted file mode 100644 index 981e4457a..000000000 --- a/src/game/server/application/SwgGameServer/src/shared/snapshot/WorldSnapshotParser.h +++ /dev/null @@ -1,25 +0,0 @@ -//=================================================================== -// -// WorldSnapshotParser.h -// asommers -// -// copyright 2002, sony online entertainment -// -//=================================================================== - -#ifndef INCLUDED_WorldSnapshotParser_H -#define INCLUDED_WorldSnapshotParser_H - -//=================================================================== - -class WorldSnapshotParser -{ -public: - - static void createWorldSnapshots (const char* const filename); -}; - -//=================================================================== - -#endif - diff --git a/src/game/server/application/SwgGameServer/src/win32/FirstSwgGameServer.cpp b/src/game/server/application/SwgGameServer/src/win32/FirstSwgGameServer.cpp deleted file mode 100644 index 9716e6e87..000000000 --- a/src/game/server/application/SwgGameServer/src/win32/FirstSwgGameServer.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "FirstSwgGameServer.h" diff --git a/src/game/server/application/SwgGameServer/src/win32/WinMain.cpp b/src/game/server/application/SwgGameServer/src/win32/WinMain.cpp deleted file mode 100644 index 161eb59b5..000000000 --- a/src/game/server/application/SwgGameServer/src/win32/WinMain.cpp +++ /dev/null @@ -1,555 +0,0 @@ -#include "FirstSwgGameServer.h" -#include "serverGame/GameServer.h" - -#include "LocalizationManager.h" -#include "serverGame/SetupServerGame.h" -#include "serverGame/ServerWorld.h" -#include "serverGame/ServerObjectTemplate.h" -#include "ServerObjectLint.h" -#include "serverPathfinding/SetupServerPathfinding.h" -#include "serverScript/SetupScript.h" -#include "serverUtility/SetupServerUtility.h" -#include "sharedDebug/SetupSharedDebug.h" -#include "sharedFile/SetupSharedFile.h" -#include "sharedFile/TreeFile.h" -#include "sharedFoundation/ConfigFile.h" -#include "sharedFoundation/ExitChain.h" -#include "sharedFoundation/FormattedString.h" -#include "sharedFoundation/Os.h" -#include "sharedFoundation/SetupSharedFoundation.h" -#include "sharedGame/SetupSharedGame.h" -#include "sharedGame/SharedObjectTemplate.h" -#include "sharedImage/SetupSharedImage.h" -#include "sharedLog/LogManager.h" -#include "sharedLog/SetupSharedLog.h" -#include "sharedMath/SetupSharedMath.h" -#include "sharedNetwork/NetworkHandler.h" -#include "sharedNetwork/SetupSharedNetwork.h" -#include "sharedObject/SetupSharedObject.h" -#include "sharedObject/ObjectTemplateList.h" -#include "sharedRandom/SetupSharedRandom.h" -#include "sharedRegex/SetupSharedRegex.h" -#include "sharedRemoteDebugServer/SharedRemoteDebugServer.h" -#include "sharedTerrain/SetupSharedTerrain.h" -#include "sharedThread/SetupSharedThread.h" -#include "sharedUtility/SetupSharedUtility.h" -#include "sharedNetworkMessages/SetupSharedNetworkMessages.h" -#include "SwgGameServer/SwgGameServer.h" -#include "SwgGameServer/WorldSnapshotParser.h" -#include "swgSharedNetworkMessages/SetupSwgSharedNetworkMessages.h" -#include "swgServerNetworkMessages/SetupSwgServerNetworkMessages.h" - -#include -#include -#include - -#include - -#ifdef _DEBUG -#include "sharedDebug/DataLint.h" -#include "sharedDebug/PerformanceTimer.h" -#include "sharedFoundation/Os.h" -#include "sharedObject/Object.h" -#include "sharedObject/ObjectTemplate.h" - -void runDataLint(char const *responsePath); -void verifyUpdateRanges (const char* filename); -#endif // _DEBUG - -//_____________________________________________________________________ -/* -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) -{ - int i = 0; - -// UNREF(hPrevInstance); -// UNREF(nCmdShow); -//-- 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; - - SetupSharedThread::install(); - SetupSharedDebug::install(1024); - - SetupSharedFoundation::install (setupFoundationData); - - SetupServerUtility::install(); - - SetupSharedRegex::install(); - - SetupSharedFile::install(false); - - SetupSharedNetwork::SetupData networkSetupData; - SetupSharedNetwork::getDefaultServerSetupData(networkSetupData); - SetupSharedNetwork::install(networkSetupData); - - SetupSharedMath::install(); - - SetupSharedUtility::Data setupUtilityData; - SetupSharedUtility::setupGameData (setupUtilityData); - SetupSharedUtility::install (setupUtilityData); - - SetupSharedRandom::install(int(time(NULL))); - { - SetupSharedObject::Data data; - SetupSharedObject::setupDefaultGameData(data); - // we want the SlotIdManager initialized, but we don't need the associated hardpoint names on the server. - SetupSharedObject::addSlotIdManagerData(data, false); - // we want movement table information on this server - SetupSharedObject::addMovementTableData(data); - // we want CustomizationData support on this server. - SetupSharedObject::addCustomizationSupportData(data); - // we want POB ejection point override support. - SetupSharedObject::addPobEjectionTransformData(data); - // objects should not automatically alter their children and contents - data.objectsAlterChildrenAndContents = false; - SetupSharedObject::install(data); - } - - SetupSharedLog::install(FormattedString<92>().sprintf("SwgGameServer:%d", Os::getProcessId())); - - TreeFile::addSearchAbsolute(0); - TreeFile::addSearchPath(".",0); - - SetupSharedNetworkMessages::install(); - SetupSwgServerNetworkMessages::install(); - SetupSwgSharedNetworkMessages::install(); - - SetupSharedImage::Data setupImageData; - SetupSharedImage::setupDefaultData (setupImageData); - SetupSharedImage::install (setupImageData); - - SetupSharedGame::Data setupSharedGameData; - setupSharedGameData.setUseMountValidScaleRangeTable(true); - setupSharedGameData.setUseClientCombatManagerSupport(true); - SetupSharedGame::install (setupSharedGameData); - - SetupSharedTerrain::Data setupSharedTerrainData; - SetupSharedTerrain::setupGameData (setupSharedTerrainData); - SetupSharedTerrain::install (setupSharedTerrainData); - - SetupScript::Data setupScriptData; - SetupScript::setupDefaultGameData(setupScriptData); - SetupScript::install(); - - SetupServerPathfinding::install(); - - //-- setup game server - SetupServerGame::install(); - - SharedRemoteDebugServer::install(); - - //-- setup game server - cmdLine = ""; - // now, the real command line - for(i = 0; i < argc; ++i) - { - cmdLine += argv[i]; - if(i + 1 < argc) - { - cmdLine += " "; - } - } - - - Archive::ByteStream bs; - UNREF(bs); - - NetworkHandler::install(); - SwgGameServer::install(); - GameServer::getInstance().setCommandLine(cmdLine); - -#ifdef _DEBUG - //-- see if the game server is being run in a mode to parse the database dump to create planetary snapshot files - const char* const createWorldSnapshots = ConfigFile::getKeyString("WorldSnapshot", "createWorldSnapshots", 0); - if (createWorldSnapshots) - { - WorldSnapshotParser::createWorldSnapshots (createWorldSnapshots); - } - else - //-- see if the gameserver is to be run in a mode to scan update ranges - if (ConfigFile::getKeyBool ("SwgGameServer", "verifyUpdateRanges", false)) - { - ServerWorld::install (); - verifyUpdateRanges ("../../exe/win32/serverobjecttemplates.txt"); - ServerWorld::remove (); - } - else - if (!ConfigFile::getKeyBool("SwgGameServer/DataLint", "disable", true)) - { - runDataLint("../../exe/win32/DataLintServer.rsp"); - } - else -#endif // _DEBUG - { - //-- run game - SetupSharedFoundation::callbackWithExceptionHandling(GameServer::run); - } - - NetworkHandler::remove(); - SetupServerGame::remove(); - - SharedRemoteDebugServer::remove(); - SetupSharedLog::remove(); - SetupSharedFoundation::remove(); - SetupSharedThread::remove (); - - return 0; -} - -#ifdef _DEBUG - -void verifyUpdateRanges (const char* const filename) -{ - FILE* const infile = fopen (filename, "rt"); - if (!infile) - { - DEBUG_REPORT_LOG (true, ("verifyUpdateRanges: response file %s could not be opened\n", filename)); - return; - } - - char serverObjectTemplateName [1024]; - while (fscanf (infile, "%s", serverObjectTemplateName) != EOF) - { - //-- does the name contain test? - if (strstr (serverObjectTemplateName, "test") != 0) - { - DEBUG_REPORT_LOG (true, ("verifyUpdateRanges: skipping test object template %s\n", serverObjectTemplateName)); - continue; - } - - if (strstr (serverObjectTemplateName, "e3_") != 0) - { - DEBUG_REPORT_LOG (true, ("verifyUpdateRanges: skipping test object template %s\n", serverObjectTemplateName)); - continue; - } - - //-- get the object template - const ObjectTemplate* const objectTemplate = ObjectTemplateList::fetch (serverObjectTemplateName); - if (!objectTemplate) - { - DEBUG_REPORT_LOG (true, ("verifyUpdateRanges: %s is not a valid object template\n", serverObjectTemplateName)); - continue; - } - - //-- make sure its a server object template - const ServerObjectTemplate* const serverObjectTemplate = dynamic_cast (objectTemplate); - if (!serverObjectTemplate) - { - objectTemplate->releaseReference (); - DEBUG_REPORT_LOG (true, ("verifyUpdateRanges: %s is not a valid server object template\n", serverObjectTemplateName)); - continue; - } - - //-- make sure it has a shared object template - const std::string& sharedObjectTemplateName = serverObjectTemplate->getSharedTemplate (); - if (sharedObjectTemplateName.empty ()) - { - objectTemplate->releaseReference (); - continue; - } - - //-- make sure the shared template exists - const SharedObjectTemplate* const sharedObjectTemplate = safe_cast (ObjectTemplateList::fetch (sharedObjectTemplateName.c_str ())); - if (!sharedObjectTemplate) - { - DEBUG_REPORT_LOG (true, ("verifyUpdateRanges: %s is not a valid shared object template for server object template %s\n", sharedObjectTemplateName.c_str (), serverObjectTemplateName)); - objectTemplate->releaseReference (); - continue; - } - - const float farUpdateRange = serverObjectTemplate->getUpdateRanges (ServerObjectTemplate::UR_far); - DEBUG_REPORT_LOG (true, ("OK:\t%s\t%s\t%1.1f\n", serverObjectTemplateName, sharedObjectTemplateName.c_str (), farUpdateRange)); - objectTemplate->releaseReference (); - } - - fclose(infile); -} - -static std::string currentLintedAsset; -static int m_startIndex = 0; -static int m_numberOfFilesToLint = -1; - -//----------------------------------------------------------------------------- -static int ExceptionHandler(LPEXCEPTION_POINTERS exceptionPointers) -{ - UNREF(exceptionPointers); - - static bool entered = false; - - // make the routine safe from re-entrance - - if (entered) - { - return EXCEPTION_CONTINUE_SEARCH; - } - - entered = true; - - // tell the Os not to abort so we can rethrow the exception - - Os::returnFromAbort(); - - // Let the ExitChain do its job - - DataLint::pushAsset(currentLintedAsset.c_str()); - FATAL(true, ("ExceptionHandler invoked - A crash just occured. The asset is bad or it is constructed improperly with DataLint.")); - DataLint::popAsset(); - - // rethrow the exception so that the debugger can catch it - - return EXCEPTION_CONTINUE_SEARCH; //lint !e527 // Unreachable -} - -//----------------------------------------------------------------------------- -static void lintType(char const *filePath, DataLint::AssetType const assetType, bool const skip) -{ - DataLint::setCurrentAssetType(assetType); - - static int assetNumber = 0; - - if (!skip) - { - DEBUG_REPORT_LOG (true, ("%5i Linting file %s... ", assetNumber, filePath)); - - bool failed = false; - - try - { - switch (assetType) - { - case DataLint::AT_objectTemplate: - { - const ObjectTemplate *objectTemplate = ObjectTemplateList::fetch(filePath); - if (objectTemplate) - { - objectTemplate->testValues(); - - // if file has the directory "base" in it's path, don't - // create an object - if (strstr(filePath, "/base/") == NULL) - { - Object* const object = objectTemplate->createObject (); - if (object != NULL) - delete object; - } - - objectTemplate->releaseReference(); - } - else - { - failed = true; - } - } - break; - case DataLint::AT_unSupported: - { - } - break; - - } - - if (failed) - { - DEBUG_REPORT_LOG (true, ("failed\n")); - } - else - { - DEBUG_REPORT_LOG (true, ("ok\n")); - } - } - catch (FatalException const &e) - { - DEBUG_REPORT_LOG (true, ("failed\n")); - - DataLint::logWarning(e.getMessage()); - } - } - - ++assetNumber; -} - -//----------------------------------------------------------------------------- -static void makeMicrosoftHappyAboutObjectUnWinding(char const *filePath, DataLint::AssetType const assetType, bool const skip) -{ - __try - { - lintType(filePath, assetType, skip); - } - __except (ExceptionHandler(GetExceptionInformation())) - { - } -} - -//----------------------------------------------------------------------------- -static void lint(char const *dataTypeString, DataLint::AssetType const assetType) -{ - DataLint::StringPairList stringPairList(DataLint::getList(assetType)); - DataLint::StringPairList::const_iterator dataLintStringListIter = stringPairList.begin(); - - DEBUG_REPORT_LOG_PRINT(1, ("Linting %d %s assets\n", stringPairList.size(), dataTypeString)); - - int currentIndex = 0; - for (; dataLintStringListIter != stringPairList.end(); ++dataLintStringListIter) - { - { - if ((currentIndex % 10) == 0) - { - //-- see if a file exists to abort - - FILE *file = fopen("stoplint.dat", "rt"); - - if (file) - { - fclose(file); - DEBUG_REPORT_LOG_PRINT(1, ("Stopping all DataLint processing for %s.\n", dataTypeString)); - DataLint::logWarning("Forced DataLint stop. Delete \"stoplint.dat\" to DataLint all the assets."); - break; - } - } - } - - char const *filePath = dataLintStringListIter->first.c_str(); - currentLintedAsset = dataLintStringListIter->second.c_str(); - - //DataLint::pushAsset(filePath); - makeMicrosoftHappyAboutObjectUnWinding(filePath, assetType, (currentIndex < m_startIndex)); - //DataLint::popAsset(); - - DataLint::clearAssetStack(); - ++currentIndex; - - if ((m_numberOfFilesToLint != -1) && (currentIndex >= (m_startIndex + m_numberOfFilesToLint))) - { - break; - } - } -} - -//----------------------------------------------------------------------------- -void runDataLint(char const *responsePath) -{ - ServerObjectLint::install(); - ServerWorld::install(); - DataLint::setServerMode(); - - PerformanceTimer performanceTimer; - performanceTimer.start(); - - FILE *fp = fopen(responsePath, "r"); - - if (fp) - { - // Default to start with the first asset - - m_startIndex = ConfigFile::getKeyInt("SwgGameServer/DataLint", "startIndex", 0); - - // Default to lint all assets - - m_numberOfFilesToLint = ConfigFile::getKeyInt("SwgGameServer/DataLint", "numberOfFilesToLint", -1); - - // Verify this is a valid resonse file - - char text[4096]; - fgets(text, sizeof(text), fp); - - if (strstr(text, "Valid DataLint Rsp") == NULL) - { - DEBUG_REPORT_LOG_PRINT(1, ("DataLint: Invalid Rsp file: %s\n", responsePath)); - -#ifdef WIN32 - char text[4096]; - sprintf(text, "Invalid Rsp file specified: %s. Make sure to run DataLintRspBuilder before running DataLint.", responsePath); - MessageBox(NULL, text, "DataLint Error!", MB_OK | MB_ICONERROR); -#endif // WIN32 - } - else - { - DataLint::install(); - - typedef std::vector StringList; - StringList stringList; - stringList.reserve(32768); - - DEBUG_REPORT_LOG_PRINT(1, ("Loading assets to lint from: %s\n", responsePath)); - - while (fgets(text, sizeof(text), fp)) - { - // Remove the newline character - - char *newLineTest = strchr(text, '\n'); - - if (newLineTest) - { - *newLineTest = '\0'; - } - - // Add the files to the master file list - - stringList.push_back(text); - } - - fclose(fp); - - // Add files to data lint - - DEBUG_REPORT_LOG_PRINT(1, ("Adding %d assets to DataLint to be categorized\n", stringList.size())); - - StringList::iterator stringListIter = stringList.begin(); - - for (; stringListIter != stringList.end(); ++stringListIter) - { - DataLint::addFilePath((*stringListIter).c_str()); - } - - if (ConfigFile::getKeyBool("SwgGameServer/DataLint", "objectTemplate", true)) - { - lint("Objects Template", DataLint::AT_objectTemplate); - } - - DataLint::report(); - } - } - else - { - DEBUG_REPORT_LOG_PRINT(1, ("Bad response path specified: %s", responsePath)); - -#ifdef WIN32 - char text[4096]; - sprintf(text, "Bad response file specified: %s. Make sure to run DataLintRspBuilder before running DataLint.", responsePath); - MessageBox(NULL, text, "DataLint Error!", MB_OK | MB_ICONERROR); -#endif // WIN32 - } - - // Dump the time required to data lint - - performanceTimer.stop(); - float const dataLintTime = performanceTimer.getElapsedTime(); - int const seconds = static_cast(dataLintTime) % 60; - int const minutes = (static_cast(dataLintTime) - seconds) / 60; - DEBUG_REPORT_LOG_PRINT(1, ("DateLint took: %dm %ds\n", minutes, seconds)); -} -#endif // _DEBUG - -//_____________________________________________________________________