From: Akiko Date: Tue, 19 May 2015 09:07:56 +0000 (+0200) Subject: - supermassive buildsystem restructure, includes restructure, types fixes and code... X-Git-Url: http://community.linux-addicted.net/gitweb/?a=commitdiff_plain;h=fb5e6fc2112a8432120447afc796b4e30bd455b4;p=tinns.git - supermassive buildsystem restructure, includes restructure, types fixes and code reduction (this one compiles nicely with gcc 5.1) --- diff --git a/CMakeLists.txt b/CMakeLists.txt index e632613..eb7bde2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,18 +34,16 @@ ENDIF (USE_MYSQL_INCLUDE_DIR) # compiler settings IF (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") MESSAGE ("Unix-like system: ${CMAKE_SYSTEM_NAME}") -SET (CMAKE_CXX_FLAGS "-std=c++1z -pthread -fdiagnostics-color=always -W -Wall -Wextra -Os") +SET (CMAKE_CXX_FLAGS "-std=c++14 -pthread -fdiagnostics-color=always -W -Wall -Wextra -Os") SET (CMAKE_C_FLAGS "-std=c11 -pthread -fdiagnostics-color=always -W -Wall -Wextra -Os") ELSEIF (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") MESSAGE ("Windows-like system: ${CMAKE_SYSTEM_NAME}") -SET (CMAKE_CXX_FLAGS "-std=c++1z -pthread -W -Wall -Wextra -Os") +SET (CMAKE_CXX_FLAGS "-std=c++14 -pthread -W -Wall -Wextra -Os") SET (CMAKE_C_FLAGS "-std=c11 -pthread -W -Wall -Wextra -Os") ELSE () MESSAGE (FATAL_ERROR "unsupported system: ${CMAKE_SYSTEM_NAME}") ENDIF () -#add_definitions (-std=c++0x -W -Wall -march=native -mtune=native -O2 -D_THREAD_SAFE -D_REENTRANT) - # source code stuff starts here -ADD_SUBDIRECTORY (server) -ADD_SUBDIRECTORY (tools) +ADD_SUBDIRECTORY (TinNS) +ADD_SUBDIRECTORY (Tools) diff --git a/docs/ISC Example.txt b/Docs/ISC Example.txt similarity index 100% rename from docs/ISC Example.txt rename to Docs/ISC Example.txt diff --git a/docs/ISC ProtDef.txt b/Docs/ISC ProtDef.txt similarity index 100% rename from docs/ISC ProtDef.txt rename to Docs/ISC ProtDef.txt diff --git a/docs/NPCs.txt b/Docs/NPCs.txt similarity index 100% rename from docs/NPCs.txt rename to Docs/NPCs.txt diff --git a/docs/Neocron1.ChatProtocol.pdf b/Docs/Neocron1.ChatProtocol.pdf similarity index 100% rename from docs/Neocron1.ChatProtocol.pdf rename to Docs/Neocron1.ChatProtocol.pdf diff --git a/docs/Neocron1.MainProtocol.pdf b/Docs/Neocron1.MainProtocol.pdf similarity index 100% rename from docs/Neocron1.MainProtocol.pdf rename to Docs/Neocron1.MainProtocol.pdf diff --git a/docs/TinNS.QuickInstallation.pdf b/Docs/TinNS.QuickInstallation.pdf similarity index 100% rename from docs/TinNS.QuickInstallation.pdf rename to Docs/TinNS.QuickInstallation.pdf diff --git a/docs/current_test_commands.txt b/Docs/current_test_commands.txt similarity index 100% rename from docs/current_test_commands.txt rename to Docs/current_test_commands.txt diff --git a/docs/how_npc_scripts_work.txt b/Docs/how_npc_scripts_work.txt similarity index 100% rename from docs/how_npc_scripts_work.txt rename to Docs/how_npc_scripts_work.txt diff --git a/docs/itemtypes.txt b/Docs/itemtypes.txt similarity index 100% rename from docs/itemtypes.txt rename to Docs/itemtypes.txt diff --git a/docs/subversion_logs_until_first_git_version.txt b/Docs/subversion_logs_until_first_git_version.txt similarity index 100% rename from docs/subversion_logs_until_first_git_version.txt rename to Docs/subversion_logs_until_first_git_version.txt diff --git a/LICENSE.txt b/LICENSE.txt index d511905..e37680c 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -278,62 +278,3 @@ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - 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 of the License, 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., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. diff --git a/Scripts/CodeCounter.sh b/Scripts/CodeCounter.sh new file mode 100755 index 0000000..0ed195d --- /dev/null +++ b/Scripts/CodeCounter.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +# code counter +LOG="/tmp/log.$$" +LINES=0 +C=0 + +find| grep "\.c$" >$LOG +find| grep "\.cpp$" >>$LOG +find| grep "\.cxx$" >>$LOG +find| grep "\.h$" >>$LOG +find| grep "\.hpp$" >>$LOG +find| grep "\.hxx$" >>$LOG +find| grep "\.sh$" >>$LOG +find| grep "\.S$" >>$LOG +find| grep "\.ts$" >>$LOG +find| grep "\.ui$" >>$LOG +find| grep "\.qrc$" >>$LOG +find| grep "\.bat$" >>$LOG +find| grep "\.cmake$" >>$LOG +find| grep "CMakeLists.txt" >>$LOG +while read L +do + C=$((C+1)) + W=$(cat $L|wc -l) + S=$(cat $L|wc -c) + SIZE=$((SIZE+S)) + LINES=$((LINES+W)) +done <$LOG +rm $LOG + +echo +echo "--- SOURCE CODE SUMMARY ---" +echo "source path: $(pwd)" +echo "source files: $C" +echo "lines of code: $LINES" +echo "size of code: $SIZE bytes" +echo diff --git a/TinNS/CMakeLists.txt b/TinNS/CMakeLists.txt new file mode 100644 index 0000000..829a977 --- /dev/null +++ b/TinNS/CMakeLists.txt @@ -0,0 +1 @@ +ADD_SUBDIRECTORY (Source) diff --git a/TinNS/Source/CMakeLists.txt b/TinNS/Source/CMakeLists.txt new file mode 100644 index 0000000..062d55f --- /dev/null +++ b/TinNS/Source/CMakeLists.txt @@ -0,0 +1,7 @@ +INCLUDE_DIRECTORIES (${CMAKE_CURRENT_SOURCE_DIR}) + +ADD_SUBDIRECTORY (Common) +ADD_SUBDIRECTORY (DevelopmentTools) +ADD_SUBDIRECTORY (GameServer) +ADD_SUBDIRECTORY (InfoServer) +ADD_SUBDIRECTORY (PatchServer) diff --git a/TinNS/Source/Common/CMakeLists.txt b/TinNS/Source/Common/CMakeLists.txt new file mode 100644 index 0000000..b395c72 --- /dev/null +++ b/TinNS/Source/Common/CMakeLists.txt @@ -0,0 +1 @@ +ADD_LIBRARY (Common Config.cxx Console.cxx FileSystem.cxx Message.cxx Misc.cxx Netcode.cxx RegEx.cxx) diff --git a/server/src/common/config.cpp b/TinNS/Source/Common/Config.cxx similarity index 58% rename from server/src/common/config.cpp rename to TinNS/Source/Common/Config.cxx index 2e04bdd..1d30b06 100644 --- a/server/src/common/config.cpp +++ b/TinNS/Source/Common/Config.cxx @@ -1,8 +1,5 @@ -#include "common/config.h" - #include -#include "common/console.h" -#include "common/misc.h" +#include "Common/Includes.hxx" PConfig::PConfig() { @@ -18,34 +15,34 @@ PConfig::~PConfig() bool PConfig::LoadOptions(const char* nConfigTemplate[][2], const char* nConfigFile, int nDepth) { - FILE *ConfigFile; - char line[255]; - std::string Opt, Val; - //int numOptions = 0; - int i; - bool Found; - bool NoError = true; - - ConfigFile = fopen(nConfigFile,"r"); - - if(!ConfigFile) - { - Console->Print("%s Cant open file \"%s\"", Console->ColorText(RED, BLACK, "[Error]"), nConfigFile); + FILE *ConfigFile; + char line[255]; + std::string Opt, Val; + //int numOptions = 0; + int i; + bool Found; + bool NoError = true; + + ConfigFile = fopen(nConfigFile,"r"); + + if(!ConfigFile) + { + Console->Print("%s Cant open file \"%s\"", Console->ColorText(RED, BLACK, "[Error]"), nConfigFile); return false; - } + } if(nDepth) Console->Print("%s Including file %s (nesting level %d)", Console->ColorText(GREEN, BLACK, "[Info]"), nConfigFile, nDepth); else - Console->Print("%s Loading configuration file %s", Console->ColorText(GREEN, BLACK, "[Info]"), nConfigFile); - - while(!feof(ConfigFile) && fgets(line, 255, ConfigFile)) - { - //Console->Print("LINE: '%s'", line); - if (line[0] == '/' && line[1] == '/') + Console->Print("%s Loading configuration file %s", Console->ColorText(GREEN, BLACK, "[Info]"), nConfigFile); + + while(!feof(ConfigFile) && fgets(line, 255, ConfigFile)) + { + //Console->Print("LINE: '%s'", line); + if (line[0] == '/' && line[1] == '/') continue; - - if(mOptValRegEx->Search(line)) + + if(mOptValRegEx->Search(line)) { Opt = mOptValRegEx->Match(1); Val = mOptValRegEx->Match(2); @@ -64,7 +61,7 @@ bool PConfig::LoadOptions(const char* nConfigTemplate[][2], const char* nConfigF int BasenamePos = StartName.rfind("/"); if(BasenamePos > 0) TargetName = StartName.substr(0, BasenamePos) + "/" + TargetName; - + NoError = LoadOptions(nConfigTemplate, TargetName.c_str(), nDepth+1) && NoError; continue; } @@ -80,7 +77,7 @@ bool PConfig::LoadOptions(const char* nConfigTemplate[][2], const char* nConfigF } i = 0; - Found = false; + Found = false; while(!Found && (nConfigTemplate[i][0][0] != '\0')) { if(!strcmp(Opt.c_str(), nConfigTemplate[i++][0])) @@ -90,18 +87,18 @@ bool PConfig::LoadOptions(const char* nConfigTemplate[][2], const char* nConfigF } } - if(!Opt.empty() && !Val.empty()) - { - //Console->Print("#%d [%s] [%s]", numOptions, Opt.c_str(), Val.c_str()); - if (Found) - { - if (GetOption(Opt) != "") - { - Console->Print("%s trying to set option %s more than once (old value '%s' - new value '%s' ignored)", Console->ColorText(YELLOW, BLACK, "[Warning]"), Opt.c_str(), GetOption(Opt).c_str(), Val.c_str()); - } - else - { - //Console->Print(GREEN, BLACK, "New option %s set to %s", Opt.c_str(), Val.c_str()); + if(!Opt.empty() && !Val.empty()) + { + //Console->Print("#%d [%s] [%s]", numOptions, Opt.c_str(), Val.c_str()); + if (Found) + { + if (GetOption(Opt) != "") + { + Console->Print("%s trying to set option %s more than once (old value '%s' - new value '%s' ignored)", Console->ColorText(YELLOW, BLACK, "[Warning]"), Opt.c_str(), GetOption(Opt).c_str(), Val.c_str()); + } + else + { + //Console->Print(GREEN, BLACK, "New option %s set to %s", Opt.c_str(), Val.c_str()); mOptions.insert(std::make_pair(Opt, Val)); } } @@ -109,13 +106,13 @@ bool PConfig::LoadOptions(const char* nConfigTemplate[][2], const char* nConfigF { Console->Print("%s option %s unknow and ignored (value %s)", Console->ColorText(YELLOW, BLACK, "[Warning]"), Opt.c_str(), Val.c_str()); } - } - } + } + } // Now check for completeness and set default values when needed and available if(!nDepth) // Check only if we're at top level (ie. not in an included file) { - i = 0; + i = 0; while(nConfigTemplate[i][0][0] != '\0') { if (GetOption(nConfigTemplate[i][0]) == "") @@ -137,52 +134,32 @@ bool PConfig::LoadOptions(const char* nConfigTemplate[][2], const char* nConfigF if (NoError) { - if(nDepth) - Console->Print("%s file included", Console->ColorText(GREEN, BLACK, "[Info]") ); - else + if(nDepth) + Console->Print("%s file included", Console->ColorText(GREEN, BLACK, "[Info]") ); + else Console->Print("%s Configuration file loaded", Console->ColorText(GREEN, BLACK, "[Success]") ); } else Console->Print(RED, BLACK, "[Error] Fatal errors found in configuration file"); - - return (NoError); + + return (NoError); } const std::string &PConfig::GetOption(const std::string Name) const { - static std::string NullString = ""; - OptionsMap::const_iterator i = mOptions.find(Name); - if(i!=mOptions.end()) - return i->second; + static std::string NullString = ""; + OptionsMap::const_iterator i = mOptions.find(Name); + if(i!=mOptions.end()) + return i->second; - return NullString; + return NullString; } int PConfig::GetOptionInt(const std::string Name) const { - OptionsMap::const_iterator i = mOptions.find(Name); - if(i!=mOptions.end()) - return atoi(i->second.c_str()); - - return 0; -} -/* -const std::string &PConfig::GetOption(const char *Name) const -{ - static std::string NullString = ""; - OptionsMap::const_iterator i = mOptions.find(Name); - if(i!=mOptions.end()) - return i->second; - - return NullString; -} - -int PConfig::GetOptionInt(const char *Name) const -{ - OptionsMap::const_iterator i = mOptions.find(Name); - if(i!=mOptions.end()) - return std::atoi(i->second.c_str()); + OptionsMap::const_iterator i = mOptions.find(Name); + if(i!=mOptions.end()) + return atoi(i->second.c_str()); - return 0; + return 0; } -*/ diff --git a/server/src/common/config.h b/TinNS/Source/Common/Config.hxx similarity index 56% rename from server/src/common/config.h rename to TinNS/Source/Common/Config.hxx index 6019055..0741022 100644 --- a/server/src/common/config.h +++ b/TinNS/Source/Common/Config.hxx @@ -1,29 +1,31 @@ #pragma once +#include #include #include -#include "common/regex++.h" - -class PConfig -{ - private : - typedef std::map OptionsMap; - OptionsMap mOptions; - RegEx* mOptValRegEx; - RegEx* mIncludeRegEx; - - bool LoadOptions(const char* nConfigTemplate[][2], const char* nConfigFile, int nDepth); - - public : - PConfig(); - ~PConfig(); - - inline bool LoadOptions(const char* nConfigTemplate[][2], const char* nConfigFile) - { return LoadOptions(nConfigTemplate, nConfigFile, 0); } - inline const std::string &GetOption(const char *Name) const { return GetOption((std::string) Name); } - const std::string &GetOption(const std::string Name) const; - int GetOptionInt(const char *Name) const { return GetOptionInt((std::string) Name); } - int GetOptionInt(const std::string Name) const; +#include + +class RegEx; + +class PConfig { +private: + typedef std::map OptionsMap; + OptionsMap mOptions; + RegEx *mOptValRegEx; + RegEx *mIncludeRegEx; + + bool LoadOptions(const char *nConfigTemplate[][2], const char *nConfigFile, int32_t nDepth); + +public: + PConfig(); + ~PConfig(); + + inline bool LoadOptions(const char *nConfigTemplate[][2], const char *nConfigFile) + { return LoadOptions(nConfigTemplate, nConfigFile, 0); } + inline const std::string &GetOption(const char *Name) const { return GetOption((std::string) Name); } + const std::string &GetOption(const std::string Name) const; + int32_t GetOptionInt(const char *Name) const { return GetOptionInt((std::string) Name); } + int32_t GetOptionInt(const std::string Name) const; }; // Max nested includes @@ -37,7 +39,7 @@ class PConfig Unkown options are rejected Duplicates, unkown and default use generate a warning in logs but don't break options loading Missing mandatory option generate an error in log and break option loading (imediate return false) - + The ConfigTemplate parameter must have the structure shown in the following exemple: const char* ConfigTemplate[][2] = { diff --git a/server/src/common/console.cpp b/TinNS/Source/Common/Console.cxx similarity index 95% rename from server/src/common/console.cpp rename to TinNS/Source/Common/Console.cxx index c8d70f1..cc12a3b 100644 --- a/server/src/common/console.cpp +++ b/TinNS/Source/Common/Console.cxx @@ -1,8 +1,7 @@ -#include "common/console.h" - +#include #include #include -#include +#include "Common/Includes.hxx" PConsole::PConsole(const char *nLogFile) { diff --git a/server/src/common/console.h b/TinNS/Source/Common/Console.hxx similarity index 90% rename from server/src/common/console.h rename to TinNS/Source/Common/Console.hxx index 9a0b428..8b610c4 100644 --- a/server/src/common/console.h +++ b/TinNS/Source/Common/Console.hxx @@ -1,11 +1,9 @@ #pragma once -#include -#include #include +#include -enum COLORS -{ +enum COLORS { BLACK, RED, GREEN, diff --git a/server/src/common/filesystem.cpp b/TinNS/Source/Common/FileSystem.cxx similarity index 95% rename from server/src/common/filesystem.cpp rename to TinNS/Source/Common/FileSystem.cxx index 2391f01..633b79d 100644 --- a/server/src/common/filesystem.cpp +++ b/TinNS/Source/Common/FileSystem.cxx @@ -1,9 +1,7 @@ -#include "common/filesystem.h" - -#include #include +#include #include -#include "common/console.h" +#include "Common/Includes.hxx" const int8_t DELIM = '/'; diff --git a/server/src/common/filesystem.h b/TinNS/Source/Common/FileSystem.hxx similarity index 91% rename from server/src/common/filesystem.h rename to TinNS/Source/Common/FileSystem.hxx index 45b31c8..00366bd 100644 --- a/server/src/common/filesystem.h +++ b/TinNS/Source/Common/FileSystem.hxx @@ -1,9 +1,8 @@ #pragma once -#include -#include -#include +#include #include +#include class PFile { friend class PFileSystem; @@ -25,7 +24,6 @@ public: }; #pragma pack(push, 1) -//#pragma pack(1) struct PPakHeader { int mID; int mNumFiles; diff --git a/TinNS/Source/Common/Includes.hxx b/TinNS/Source/Common/Includes.hxx new file mode 100644 index 0000000..0b2cc63 --- /dev/null +++ b/TinNS/Source/Common/Includes.hxx @@ -0,0 +1,11 @@ +#pragma once + +#include "Common/Config.hxx" +#include "Common/Console.hxx" +#include "Common/FileSystem.hxx" +#include "Common/Message.hxx" +#include "Common/Misc.hxx" +#include "Common/Netcode.hxx" +#include "Common/RegEx.hxx" +#include "Common/SVNrevision.hxx" +#include "Common/Version.hxx" diff --git a/server/src/common/message.cpp b/TinNS/Source/Common/Message.cxx similarity index 99% rename from server/src/common/message.cpp rename to TinNS/Source/Common/Message.cxx index 7abddba..cca2d3c 100644 --- a/server/src/common/message.cpp +++ b/TinNS/Source/Common/Message.cxx @@ -1,7 +1,5 @@ -#include "common/message.h" - #include -#include "common/console.h" +#include "Common/Includes.hxx" const uint16_t PMessage::smMsgSizes[] = {MESSAGE_SIZES_LIST}; PMsgData* PMessage::smMsgPoolHead[] = {MESSAGE_POOL_INIT}; diff --git a/TinNS/Source/Common/Message.hxx b/TinNS/Source/Common/Message.hxx new file mode 100644 index 0000000..30c19ee --- /dev/null +++ b/TinNS/Source/Common/Message.hxx @@ -0,0 +1,103 @@ +#pragma once + +#include + +#define MESSAGE_SIZES_LIST 32, 64, 128, 256, 512, 1024, 4096 +#define MESSAGE_POOL_INIT NULL, NULL, NULL, NULL, NULL, NULL, NULL +#define MESSAGE_POOL_COUNT_INIT 0, 0, 0, 0, 0, 0, 0 +#define MESSAGE_SIZES_NB 7 +#define MESSAGE_ALLOC_NB 4 + +struct PMsgData { + PMsgData* mNextMsgData; + uint8_t* mBuffer; // NB: no need to manage buffer deletion atm, as they will stay until server end +}; +//NB: putting mPoolId & mMaxSize in PMsgData rather than PMessage would be cleaner, but would put more mem overhead on each buffer +// Doesn't matter much as PMsgData management is done only through PMessage + +class PMessage { +private: + static const uint16_t smMsgSizes[MESSAGE_SIZES_NB]; + static PMsgData* smMsgPoolHead[MESSAGE_SIZES_NB]; + static int smMsgPoolCount[MESSAGE_SIZES_NB]; + static int smMsgCount; //Used to trace unreleased messages with CheckMsgCount() + + uint8_t mPoolId; + uint16_t mMaxSize; + PMsgData* mData; + uint16_t mUsedSize; + uint16_t mNextByteOffset; + + void GetMsgBuffer(uint16_t nRequestedSize = 0); // the requested size is just a hint to avoid internal reaffectation of buffer + void ReleaseMsgBuffer(); + void CheckAndExtend(uint16_t nRequestedSize); // This is SIZE checked, not max OFFSET + inline void UpdateUsedSize() { if (mNextByteOffset > mUsedSize) mUsedSize = mNextByteOffset; } + +public: + static void CheckMsgCount(); //To be used in a place where no new message should remain between calls + + PMessage(uint16_t nRequestedSize = 0); // max size will be extended as needed in later write accesses (up to max configured size) + PMessage(PMessage& nMessage); // creates a (size optimized, offset reset) copy of nMessage + inline ~PMessage() { ReleaseMsgBuffer(); --smMsgCount; } + + void SetNextByteOffset(uint16_t nPos); + inline void IncreaseNextByteOffset(uint16_t nIncrement) { SetNextByteOffset(mNextByteOffset + nIncrement); } + inline void SetNextByteAtEnd() { mNextByteOffset = mUsedSize; } + inline uint16_t GetNextByteOffset() { return mNextByteOffset; } + void ForceSize(uint16_t nUsedSize); + inline uint16_t GetSize() { return mUsedSize; } + inline uint16_t GetMaxSize() { return mMaxSize; } + inline bool EOM() {return (mNextByteOffset >= mUsedSize);} // End Of Message + + // Writing methods + uint8_t* GetMessageDataPointer(uint16_t nUsedSize); // extends buffer as needed by nUsedSize, and sets UsedSize at min nUsedSize + PMessage& Fill(uint8_t Value = 0, uint16_t StartOffset = 0, uint16_t FillSize = 0); // !!! Does NOT update UsedSize, fills only up to current maxSize + inline PMessage& Reset() { mNextByteOffset = mUsedSize = 0; return *this; } + inline PMessage& Clear() { return this->Fill(0).Reset(); } + PMessage& Write(const void* nData, uint16_t nLength); + PMessage& operator << (PMessage& nMessage); + PMessage& operator << (const char* nString); //for null terminated string ! Copies includes ending \0 + inline PMessage& operator << (std::string& nString) { return (*this << nString.c_str()); } + PMessage& operator << (uint8_t nU8); + inline PMessage& operator << (char nChar) { return (*this << (uint8_t) nChar);} + PMessage& operator << (uint16_t nU16); + PMessage& operator << (uint32_t nU32); + PMessage& operator << (float nF32); + + // Mixt methods + + //The next 3 methods do NOT update NextByteOffset, but DO increase message size (UsedSize ans MaxSize) as needed by nOffset. + uint8_t& U8Data(uint16_t nOffset); + uint16_t& U16Data(uint16_t nOffset); + uint32_t& U32Data(uint16_t nOffset); + float& F32Data(uint16_t nOffset); + + // *** didn't managed to overload [] operator :-/ + inline uint8_t& operator [] (uint16_t nOffset) { return U8Data(nOffset); } + //inline u16& operator [] (u16 nOffset) { return U16Data(nOffset); } + //u32& operator [] (u16 nOffset); + + // Really makes a different message instance, with all data copied (no data shared) + PMessage& operator = (PMessage& nMessage); + + // Reading methods + // ChunkNumber count from 0, return NULL for empty chunk (ie StartOffset is over UsedSize). NextByteOffset NOT updated + PMessage* GetChunk(uint16_t StartOffset, uint16_t ChunkSize, uint16_t ChunkNumber = 0); + + // Return pointer to the START of message data. + inline uint8_t const* GetMessageData() { return mData->mBuffer; } + + //Following methods do NOT extend message or Used, and return 0/empty string if over UsedSize + PMessage& operator >> (std::string& nString); //read up to null or EOM + PMessage& operator >> (uint8_t& nU8); + inline PMessage& operator >> (char& nChar) { return (*this >> (uint8_t&) nChar);} + PMessage& operator >> (uint16_t& nU16); + PMessage& operator >> (uint32_t& nU32); + PMessage& operator >> (float& nF32); + + // info/debug methods + static void ListPools(); + static void DumpPools(); + void Dump(); + void DumpHead(char* nComment = ""); +}; diff --git a/server/src/common/misc.cpp b/TinNS/Source/Common/Misc.cxx similarity index 94% rename from server/src/common/misc.cpp rename to TinNS/Source/Common/Misc.cxx index 7ed900f..1f8fa3b 100644 --- a/server/src/common/misc.cpp +++ b/TinNS/Source/Common/Misc.cxx @@ -1,10 +1,7 @@ -#include "common/misc.h" - -#include #include -#include +#include #include -#include "common/console.h" +#include "Common/Includes.hxx" uint32_t IPStringToDWord( const char *IP ) { diff --git a/server/src/common/misc.h b/TinNS/Source/Common/Misc.hxx similarity index 87% rename from server/src/common/misc.h rename to TinNS/Source/Common/Misc.hxx index dae6fb9..33bf941 100644 --- a/server/src/common/misc.h +++ b/TinNS/Source/Common/Misc.hxx @@ -1,14 +1,14 @@ #pragma once -#include +#include #include uint32_t IPStringToDWord(const char *IP); char *IPlongToString(const uint32_t IP); -std::string GetAccessString(int level); +std::string GetAccessString(int32_t level); //void GetSVNRev(char *version); -void PrintPacket(uint8_t *Packet, int PacketSize); +void PrintPacket(uint8_t *Packet, int32_t PacketSize); // Cleanup for strings read from .def void CleanUpString(std::string *nString); diff --git a/TinNS/Source/Common/Mutex.hxx b/TinNS/Source/Common/Mutex.hxx new file mode 100644 index 0000000..8e388fb --- /dev/null +++ b/TinNS/Source/Common/Mutex.hxx @@ -0,0 +1,43 @@ +#pragma once + +#include + +class Mutex { +private: + mutable pthread_mutex_t mut; + + void operator = (Mutex &mut) {} + + Mutex(const Mutex &mut) {} + +public: + Mutex() + { + pthread_mutexattr_t attr; + pthread_mutexattr_init(&attr); + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); + pthread_mutex_init(&mut, &attr); + pthread_mutexattr_destroy(&attr); + } + + virtual ~Mutex() + { + pthread_mutex_unlock(&mut); + pthread_mutex_destroy(&mut); + } + + int Lock() const + { + return (pthread_mutex_lock(&mut)); + } + + int TryLock() const + { + return (pthread_mutex_trylock(&mut)); + } + + int Unlock() const + { + return (pthread_mutex_unlock(&mut)); + } +}; diff --git a/server/src/common/netcode.cpp b/TinNS/Source/Common/Netcode.cxx similarity index 93% rename from server/src/common/netcode.cpp rename to TinNS/Source/Common/Netcode.cxx index 85c8676..47a968f 100644 --- a/server/src/common/netcode.cpp +++ b/TinNS/Source/Common/Netcode.cxx @@ -1,11 +1,8 @@ -#include "common/netcode.h" - #include #include #include #include -#include "common/console.h" -#include "common/config.h" +#include "Common/Includes.hxx" ConnectionTCP::ConnectionTCP(int sockfd, struct sockaddr_in addr, ServerSocket* server) { @@ -36,12 +33,12 @@ ConnectionTCP::~ConnectionTCP() mServerSocket->delSocketFromSet(mSockfd); } close(mSockfd); - + if (mReceiveBufferMsg) { delete mReceiveBufferMsg; } - + while (!mQueueIn.empty()) { delete mQueueIn.front(); @@ -61,17 +58,17 @@ char* ConnectionTCP::getRemoteAddress() bool ConnectionTCP::timeOut() const { - time_t now = std::time(NULL); - if((now-mLastActive) >= mTimeOutValue) - return true; + time_t now = std::time(NULL); + if((now-mLastActive) >= mTimeOutValue) + return true; - return false; + return false; } PMessage* ConnectionTCP::GetMessage() { PMessage* RetVal; - + if (mQueueIn.empty()) RetVal = NULL; else @@ -88,7 +85,7 @@ void ConnectionTCP::DeleteOutgoingMessages() { delete mQueueOut.front(); mQueueOut.pop(); - } + } } bool ConnectionTCP::update() // non optimal read-algorithm atm, but well ... :p @@ -100,7 +97,7 @@ bool ConnectionTCP::update() // non optimal read-algorithm atm, but well ... :p uint8_t* MsgStart; uint16_t MsgOffset; uint16_t MsgLen; - + //check if data is available for this socket and if yes, read into a new PMessage and put it on incoming queue if(mServerSocket->isDataAvailable(mSockfd)) { @@ -109,7 +106,7 @@ bool ConnectionTCP::update() // non optimal read-algorithm atm, but well ... :p { mReceiveBufferMsg = new PMessage(RECVBUFFERSIZE); } - + DataSize = mReceiveBufferMsg->GetSize(); numBytes = recv(mSockfd, (char*) mReceiveBufferMsg->GetMessageDataPointer(RECVBUFFERSIZE - DataSize) + DataSize, RECVBUFFERSIZE - DataSize, 0); // get the data @@ -119,13 +116,13 @@ bool ConnectionTCP::update() // non optimal read-algorithm atm, but well ... :p mbConnected = true; mReceiveBufferMsg->ForceSize(DataSize + numBytes); mLastActive = std::time(NULL); - + while(mReceiveBufferMsg && mReceiveBufferMsg->GetSize()) { DataStart = mReceiveBufferMsg->GetMessageData(); DataSize = mReceiveBufferMsg->GetSize(); MsgStart = (uint8_t*)memchr(DataStart, 0xfe, DataSize); - + if (MsgStart) { MsgOffset = MsgStart - DataStart; @@ -141,7 +138,7 @@ bool ConnectionTCP::update() // non optimal read-algorithm atm, but well ... :p { tmpMsg = mReceiveBufferMsg->GetChunk(MsgOffset, MsgLen + 3); // Change (MsgOffset, MsgLen + 3) to (MsgOffset + 3, MsgLen) to REMOVE head & length from message head mQueueIn.push(tmpMsg); - + if (MsgOffset + 3 + MsgLen < DataSize) { tmpMsg = mReceiveBufferMsg->GetChunk(MsgOffset + 3 + MsgLen, DataSize - (MsgOffset + 3 + MsgLen)); @@ -150,9 +147,9 @@ bool ConnectionTCP::update() // non optimal read-algorithm atm, but well ... :p { tmpMsg = NULL; } - + delete mReceiveBufferMsg; - mReceiveBufferMsg = tmpMsg; + mReceiveBufferMsg = tmpMsg; } } } @@ -169,49 +166,49 @@ bool ConnectionTCP::update() // non optimal read-algorithm atm, but well ... :p { mServerSocket->delSocketFromSet(mSockfd); } - close(mSockfd); + close(mSockfd); return false; } else { - if(errno != EAGAIN) + if(errno != EAGAIN) { // an error has occured -> output it to the console perror("tcp-receive"); Console->Print(RED, BLACK, "mSockfd:%d MaxRead:%d ", mSockfd, RECVBUFFERSIZE); } - } + } } // send data from outgoing queue flushSendBuffer(); // manage old write compatibility - while(! mQueueOut.empty()) - { + while(! mQueueOut.empty()) + { //Console->Print("ConnectionUDP::update() - OUT Data avail"); - tmpMsg = mQueueOut.front(); - int numBytes = send(mSockfd, (char*) tmpMsg->GetMessageData(), tmpMsg->GetSize(), 0); - if(numBytes == -1) // error while sending data -> output error-msg to console - { - if (errno == EAGAIN) - { - break; - } - else - { - perror("tcp-send"); - //close(mSockfd); + tmpMsg = mQueueOut.front(); + int numBytes = send(mSockfd, (char*) tmpMsg->GetMessageData(), tmpMsg->GetSize(), 0); + if(numBytes == -1) // error while sending data -> output error-msg to console + { + if (errno == EAGAIN) + { + break; + } + else + { + perror("tcp-send"); + //close(mSockfd); return false; } } else if(numBytes > 0) - { + { //Console->Print(GREEN, BLACK, "ConnectionTCP::update() - Data sent"); - mLastActive = std::time(NULL); + mLastActive = std::time(NULL); mQueueOut.pop(); // message written, we can remove it from queue delete tmpMsg; // and delete the message - } - } + } + } - return true; + return true; } /**** Old I/F compatibility functions ****/ @@ -219,23 +216,23 @@ bool ConnectionTCP::update() // non optimal read-algorithm atm, but well ... :p int ConnectionTCP::getRecvBufferSize() { PMessage* tmpMsg; - + if (mQueueIn.empty()) return 0; tmpMsg = mQueueIn.front(); - uint16_t _size = tmpMsg->GetSize()-tmpMsg->GetNextByteOffset(); - if (_size <= 0) - { - mQueueIn.pop(); - delete tmpMsg; + uint16_t _size = tmpMsg->GetSize()-tmpMsg->GetNextByteOffset(); + if (_size <= 0) + { + mQueueIn.pop(); + delete tmpMsg; if (mQueueIn.empty()) return 0; tmpMsg = mQueueIn.front(); - tmpMsg->SetNextByteOffset(0); - _size = tmpMsg->GetSize(); - } - return _size; + tmpMsg->SetNextByteOffset(0); + _size = tmpMsg->GetSize(); + } + return _size; } int ConnectionTCP::getSendBufferSize() @@ -260,7 +257,7 @@ void ConnectionTCP::flushSendBuffer() const uint8_t* ConnectionTCP::read(int* size) { PMessage* tmpMsg; -//Console->Print("ConnectionTCP::read() - trying to read up to %d bytes", *size); +//Console->Print("ConnectionTCP::read() - trying to read up to %d bytes", *size); if (mQueueIn.empty() || !size) { //Console->Print("ConnectionTCP::read() - no more packet"); @@ -268,36 +265,36 @@ const uint8_t* ConnectionTCP::read(int* size) } tmpMsg = mQueueIn.front(); - uint16_t _size = tmpMsg->GetSize()-tmpMsg->GetNextByteOffset(); + uint16_t _size = tmpMsg->GetSize()-tmpMsg->GetNextByteOffset(); //Console->Print("ConnectionTCP::read() - %d bytes remaining in current packet", _size); - if (_size <= 0) - { + if (_size <= 0) + { //Console->Print("ConnectionTCP::read() - trying next packet"); - mQueueIn.pop(); - delete tmpMsg; + mQueueIn.pop(); + delete tmpMsg; if (mQueueIn.empty()) { //Console->Print("ConnectionUDP::read() - no more packet"); return NULL; } tmpMsg = mQueueIn.front(); - _size = tmpMsg->GetSize(); - tmpMsg->SetNextByteOffset(0); - } - - if(*size==0) - { - *size=_size; - } - else - { - *size = std::min(*size, (int32_t)_size); - } - - uint8_t const* ptr = tmpMsg->GetMessageData() + tmpMsg->GetNextByteOffset(); - tmpMsg->SetNextByteOffset(tmpMsg->GetNextByteOffset()+ *size); + _size = tmpMsg->GetSize(); + tmpMsg->SetNextByteOffset(0); + } + + if(*size==0) + { + *size=_size; + } + else + { + *size = std::min(*size, (int32_t)_size); + } + + uint8_t const* ptr = tmpMsg->GetMessageData() + tmpMsg->GetNextByteOffset(); + tmpMsg->SetNextByteOffset(tmpMsg->GetNextByteOffset()+ *size); //Console->Print(GREEN, BLACK, "ConnectionTCP::read() - %d bytes read", *size); - return ptr; + return ptr; } int ConnectionTCP::write(const void* data, int size) @@ -308,43 +305,43 @@ int ConnectionTCP::write(const void* data, int size) //Console->Print("ConnectionTCP::write() creating new mSendBufferMsg"); mSendBufferMsg = new PMessage(SENDBUFFERSIZE); } - - mSendBufferMsg->Write(data, (uint16_t)size); + + mSendBufferMsg->Write(data, (uint16_t)size); //Console->Print(GREEN, BLACK, "ConnectionUDP::write() %d bytes written to mSendBufferMsg (total size %d)", size, mSendBufferMsg->GetSize()); - return size; + return size; } int ConnectionTCP::write(const char *String) { - if(!String) - return 0; + if(!String) + return 0; - return write(String, strlen(String)); + return write(String, strlen(String)); } int ConnectionTCP::write(uint8_t Data) { - return write(&Data, sizeof(uint8_t)); + return write(&Data, sizeof(uint8_t)); } int ConnectionTCP::write(uint16_t Data) { - return write(&Data, sizeof(uint16_t)); + return write(&Data, sizeof(uint16_t)); } int ConnectionTCP::write(uint32_t Data) { - return write(&Data, sizeof(uint32_t)); + return write(&Data, sizeof(uint32_t)); } int ConnectionTCP::write(float Data) { - return write(&Data, sizeof(float)); + return write(&Data, sizeof(float)); } int ConnectionTCP::write(double Data) { - return write(&Data, sizeof(double)); + return write(&Data, sizeof(double)); } ConnectionUDP::ConnectionUDP(int sockfd, int port, int remoteadress, int remoteport, ServerSocket* server) @@ -381,8 +378,8 @@ ConnectionUDP::ConnectionUDP(int sockfd, int port, int remoteadress, int remotep // memset(&(mRemoteAddr.sin_zero), '\0', 8); // zero the rest of the struct mSendBufferMsg = NULL; - mUDP_ID = 0; - mSessionID = SESSION_UDP_OFFSET; + mUDP_ID = 0; + mSessionID = SESSION_UDP_OFFSET; mLastUDPID = 0; mTransactionID = 0; } @@ -883,12 +880,12 @@ ServerSocket::ServerSocket() FD_ZERO(&m_ReadSetTCP); FD_ZERO(&m_MainSetUDP); FD_ZERO(&m_MainSetGlobal); - + m_FdMaxUDP=0; - + m_TimeOut.tv_sec = 0; m_TimeOut.tv_usec = 30; - + //m_LastUDPPort = 5000; } @@ -904,7 +901,6 @@ void ServerSocket::settimeout(int32_t timeout_sec, int32_t timeout_usec) m_TimeOut.tv_sec = timeout_sec; m_TimeOut.tv_usec = timeout_usec; } - } bool ServerSocket::open(int port) @@ -952,9 +948,9 @@ bool ServerSocket::open(int port) FD_ZERO(&m_ReadSetTCP); FD_ZERO(&m_MainSetUDP); FD_ZERO(&m_MainSetGlobal); - + m_FdMaxUDP=0; - + // add the listener to the master sets FD_SET(m_ListenerTCP, &m_MainSetTCP); FD_SET(m_ListenerTCP, &m_MainSetGlobal); @@ -971,14 +967,14 @@ void ServerSocket::update() { struct timeval tmp_TimeOut; int fdMax; - + // copy fd_sets from main-set to temp. read-set m_ReadSetTCP = m_MainSetGlobal; fdMax = std::max(m_FdMaxTCP, m_FdMaxUDP); - + //FD_ZERO(&m_ReadSetTCP); - //FD_SET (m_ListenerTCP, &m_ReadSetTCP); + //FD_SET (m_ListenerTCP, &m_ReadSetTCP); // select incoming data for tcp & udp tmp_TimeOut = m_TimeOut; //save m_TimeOut... will be modified by select @@ -986,7 +982,7 @@ void ServerSocket::update() { perror("select"); } - + //Select exit condition logging /* if ((tmp_TimeOut.tv_sec == 0) && (tmp_TimeOut.tv_usec == 0)) @@ -995,13 +991,13 @@ void ServerSocket::update() Console->LPrint(" Exiting select on timeout (remains %d sec and %d usec)", tmp_TimeOut.tv_sec, tmp_TimeOut.tv_usec); Console->LClose(); } - else + else { Console->LPrint(YELLOW, BLACK, "[Active]"); Console->LPrint(" Exiting select with remaining time %d sec and %d usec", tmp_TimeOut.tv_sec, tmp_TimeOut.tv_usec); Console->LClose(); } - */ + */ // check for new tcp connections if (FD_ISSET(m_ListenerTCP, &m_ReadSetTCP)) // we got one!! @@ -1079,7 +1075,7 @@ ConnectionUDP* ServerSocket::getUDPConnection(uint32_t remoteadress, int32_t rem while (bind(udpSockfd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)) == -1) { if (errno == EADDRINUSE) - { + { my_addr.sin_port = htons(++Port); if (Port > maxPort) { @@ -1088,7 +1084,7 @@ ConnectionUDP* ServerSocket::getUDPConnection(uint32_t remoteadress, int32_t rem } } else - { + { perror("udp-bind"); return NULL; } @@ -1100,10 +1096,10 @@ ConnectionUDP* ServerSocket::getUDPConnection(uint32_t remoteadress, int32_t rem { m_FdMaxUDP = udpSockfd; } - + ConnectionUDP* udpConn = new ConnectionUDP(udpSockfd, Port, remoteadress, remoteport, this); - //m_LastUDPPort++; + //m_LastUDPPort++; return udpConn; } diff --git a/server/src/common/netcode.h b/TinNS/Source/Common/Netcode.hxx similarity index 98% rename from server/src/common/netcode.h rename to TinNS/Source/Common/Netcode.hxx index b0db933..7ba4a63 100644 --- a/server/src/common/netcode.h +++ b/TinNS/Source/Common/Netcode.hxx @@ -1,11 +1,8 @@ #pragma once -#include -#include +#include #include -#include #include -#include "common/message.h" #define RECVBUFFERSIZE 4096 #define SENDBUFFERSIZE 4096 @@ -16,6 +13,7 @@ class ConnectionTCP; class ConnectionUDP; +class PMessage; class ServerSocket; class ConnectionTCP { diff --git a/server/src/common/regex++.cpp b/TinNS/Source/Common/RegEx.cxx similarity index 97% rename from server/src/common/regex++.cpp rename to TinNS/Source/Common/RegEx.cxx index b2417d7..da725cc 100644 --- a/server/src/common/regex++.cpp +++ b/TinNS/Source/Common/RegEx.cxx @@ -1,6 +1,5 @@ -#include "common/regex++.h" - #include +#include "Common/Includes.hxx" RegEx::RegEx(const char * regex, int options) { diff --git a/TinNS/Source/Common/RegEx.hxx b/TinNS/Source/Common/RegEx.hxx new file mode 100644 index 0000000..d012af6 --- /dev/null +++ b/TinNS/Source/Common/RegEx.hxx @@ -0,0 +1,35 @@ +#pragma once + +#include + +#ifndef _PCRE_H +#include "pcre.h" +#endif + +class RegEx { +private: + pcre *re; + pcre_extra *pe; + int32_t substrcount; + int32_t *ovector; + const char *lastsubject; + int32_t slen; + const char **matchlist; + + inline void ClearMatchList(void) + { + if (matchlist) + { + pcre_free_substring_list(matchlist); + matchlist = NULL; + } + } + +public: + RegEx(const char *regex, int32_t options = 0); + ~RegEx(); + inline int32_t SubStrings(void) const { return substrcount; } + bool Search(const char *subject, int32_t len = -1, int32_t options = 0); + bool SearchAgain(int32_t options = 0); + const char *Match(int32_t i = 1); +}; diff --git a/TinNS/Source/Common/SVNrevision.hxx b/TinNS/Source/Common/SVNrevision.hxx new file mode 100644 index 0000000..a04c733 --- /dev/null +++ b/TinNS/Source/Common/SVNrevision.hxx @@ -0,0 +1,4 @@ +#pragma once + +#define TINNS_SVN_REVISION "AKIKO_CMAKE_R3" + diff --git a/TinNS/Source/Common/Semaphore.hxx b/TinNS/Source/Common/Semaphore.hxx new file mode 100644 index 0000000..023982d --- /dev/null +++ b/TinNS/Source/Common/Semaphore.hxx @@ -0,0 +1,49 @@ +#pragma once + +#include + +class Semaphore { +private: + sem_t sem; + +public: + Semaphore(int init = 0) + { + sem_init(&sem, 0, init); + } + + virtual ~Semaphore() + { + sem_destroy(&sem); + } + + void Wait() const + { + sem_wait((sem_t *)&sem); + } + + int TryWait() const + { + return (sem_trywait((sem_t *)&sem) ? errno : 0); + } + + int Post() const + { + return (sem_post((sem_t *)&sem) ? errno : 0); + } + + int GetValue() const + { + int val = -1; + + sem_getvalue((sem_t *)&sem, &val); + + return (val); + } + + void Reset(int init = 0) + { + sem_destroy(&sem); + sem_init(&sem, 0, init); + } +}; diff --git a/server/src/include/tinns_thread.h b/TinNS/Source/Common/Thread.hxx similarity index 55% rename from server/src/include/tinns_thread.h rename to TinNS/Source/Common/Thread.hxx index 5b40ee7..70c0e8a 100644 --- a/server/src/include/tinns_thread.h +++ b/TinNS/Source/Common/Thread.hxx @@ -1,41 +1,8 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko +#pragma once - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - thread.h - main class of a C++ thread model using the POSIX way - - MODIFIED: 26 Sep 2005 Akiko - REASON: - started the implementaion of a thread model - MODIFIED: 28 Sep 2005 Akiko - REASON: - fixed the issue with gxx 3.4.3 and gcc 4.x -*/ - - -#ifndef THREAD_H -#define THREAD_H - -//this class needs mutex.h, semaphore.h and pthread.h, but it should all come -//from tinns.h +#include +#include +#include #define INVALID_HANDLE 0 @@ -197,66 +164,3 @@ class Thread { unsigned char Flags; }; }; - -/* - implementation without thread parameters -*/ - -/*template <> -class Thread { - private: - typedef struct Instance; - - public: - typedef pthread_t Handle; - typedef void (*Handler)(); - - protected: - Thread() { - } - - virtual void ThreadMain() = 0; - - static void Exit() { - pthread_exit(0); - } - - static void TextCancel() { - pthread_testcancel(); - } - - static Handle Self() { - return((Handle)pthread_self()); - } - - public: - static int Create(const Handler &Func, Handle *const &H = 0, const bool &CreateDetached = false, - const unsigned int &StackSize = 0, const bool &CancelEnable = false, - const bool &CancelAsync = false) { - M_Create().Locl(); - pthread_attr_t attr; - pthread_attr_init(&attr); - - if(CreateDetached) - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - - if(StackSize) - pthread_attr_setstacksize(&attr, StackSize); - - Instance I(0, Func, CancelEnable, CancelAsync); - - int run = pthread_create((pthread_t *)H, &attr, ThreadMainHandler, (void *)&I); - pthread_attr_destroy(&attr); - - if(!run) - S_Create().Wait(); - else if(H) - *H = INVALID_HANDLE; - - M_Create().Unlock(); - - return(errno); - } */ - -#endif - diff --git a/TinNS/Source/Common/Version.hxx b/TinNS/Source/Common/Version.hxx new file mode 100644 index 0000000..684ebd2 --- /dev/null +++ b/TinNS/Source/Common/Version.hxx @@ -0,0 +1,7 @@ +#pragma once + +#include "Common/SVNrevision.hxx" + +#define TINNS_PATCH_VERSION "0.0.2 Dev" +#define TINNS_INFO_VERSION "0.0.2 Dev" +#define TINNS_GAME_VERSION "0.1.38 Dev" diff --git a/server/src/dev-tools/CMakeLists.txt b/TinNS/Source/DevelopmentTools/CMakeLists.txt similarity index 100% rename from server/src/dev-tools/CMakeLists.txt rename to TinNS/Source/DevelopmentTools/CMakeLists.txt diff --git a/server/src/dev-tools/cleandepfile.c b/TinNS/Source/DevelopmentTools/cleandepfile.c similarity index 100% rename from server/src/dev-tools/cleandepfile.c rename to TinNS/Source/DevelopmentTools/cleandepfile.c diff --git a/server/src/dev-tools/getsvnrev.cpp b/TinNS/Source/DevelopmentTools/getsvnrev.cpp similarity index 100% rename from server/src/dev-tools/getsvnrev.cpp rename to TinNS/Source/DevelopmentTools/getsvnrev.cpp diff --git a/server/src/dev-tools/make-bin-tarball b/TinNS/Source/DevelopmentTools/make-bin-tarball similarity index 100% rename from server/src/dev-tools/make-bin-tarball rename to TinNS/Source/DevelopmentTools/make-bin-tarball diff --git a/server/src/dev-tools/make-src-tarball b/TinNS/Source/DevelopmentTools/make-src-tarball similarity index 100% rename from server/src/dev-tools/make-src-tarball rename to TinNS/Source/DevelopmentTools/make-src-tarball diff --git a/server/src/game/accounts.cpp b/TinNS/Source/GameServer/Accounts.cxx similarity index 60% rename from server/src/game/accounts.cpp rename to TinNS/Source/GameServer/Accounts.cxx index a1f0bbd..062599b 100644 --- a/server/src/game/accounts.cpp +++ b/TinNS/Source/GameServer/Accounts.cxx @@ -1,48 +1,5 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - accounts.cpp - - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL - MODIFIED: 26 Dec 2005 Namikon - REASON: - Added SQLLoad to PAccounts. First step in adding MySQL support to accounts - MODIFIED: 01 Jan 2006 Namikon - REASON: - Changed FmtTxt() to sprintf(). It does... uhm, the same :D - MODIFIED: 06 Jan 2006 Namikon - REASON: - Removed the old XML loading functions, and changed the SQL ones to work with the Global Neopolis/TinNS Database - - Added SetBannedStatus() to ban/unban an account (use SetBannedStatus(0) to unban a player) - MODIFIED: 03 Oct 2006 Hammag - REASON: - Fixed an issue in PAccount::SetBannedStatus() that was causing the "can't update banned status" error message. - - MODIFIED: 27 May 2007 Hammag - REASON: - Full changes for on-demand account access (no more memory-resident account data) - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for new build system - - clean ups -*/ - +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" /* NOTE ABOUT ACCESS LEVELS IN THE MYSQL DATABASE: @@ -58,8 +15,6 @@ a_status: 1 = Online 2 = Banned */ -#include "main.h" -#include "include/accounts.h" /** Static members **/ RegEx* PAccount::mUsernameRegexFilter = NULL; @@ -72,7 +27,7 @@ bool PAccount::SetUsernameRegexFilter(const char* RegexStr) delete mUsernameRegexFilter; mUsernameRegexFilter = NULL; } - + if(RegexStr) { try { @@ -92,7 +47,7 @@ bool PAccount::SetPasswordRegexFilter(const char* RegexStr) delete mPasswordRegexFilter; mPasswordRegexFilter = NULL; } - + if(RegexStr) { try { @@ -125,16 +80,16 @@ bool PAccount::IsPasswordWellFormed(const char *Password) return true; } -/** Instance members **/ +/** Instance members **/ PAccount::PAccount() { - mID = 0; - mLevel = PAL_BANNED; + mID = 0; + mLevel = PAL_BANNED; mStatus = PAS_OFFLINE; mBannedUntil = 0; } -PAccount::PAccount(const u32 AccountId) +PAccount::PAccount(const uint32_t AccountId) { char query[256]; mID = 0; @@ -158,7 +113,7 @@ bool PAccount::LoadFromQuery(char* query) { MYSQL_ROW row = 0; MYSQL_RES *result = 0; - + bool FinalResult = false; result = MySQL->InfoResQuery(query); @@ -193,7 +148,7 @@ bool PAccount::LoadFromQuery(char* query) { Console->Print(YELLOW, BLACK, "Failed to load AccountData from SQL; Nothing to load..."); } - + MySQL->FreeInfoSQLResult(result); return FinalResult; } @@ -224,19 +179,19 @@ bool PAccount::SetPassword(const std::string &Password) } } -bool PAccount::SetPasswordEncoded(const u8* PasswordData, int PassLen, const u8* Key) +bool PAccount::SetPasswordEncoded(const uint8_t* PasswordData, int PassLen, const uint8_t* Key) { - char Pass[128]; - - if(DecodePassword(PasswordData, PassLen, Key, Pass)) + char Pass[128]; + + if(DecodePassword(PasswordData, PassLen, Key, Pass)) { - return SetPassword((std::string)Pass); - } - else - { - Console->Print(RED, BLACK, "[Error]: user %s : malformed auth data (size=%d)", mName.c_str(), PassLen); - return false; - } + return SetPassword((std::string)Pass); + } + else + { + Console->Print(RED, BLACK, "[Error]: user %s : malformed auth data (size=%d)", mName.c_str(), PassLen); + return false; + } } bool PAccount::SetLevel(int newLevel) @@ -254,17 +209,17 @@ bool PAccount::SetLevel(int newLevel) std::string PAccount::GetLevelString() const { - switch(mLevel) - { - case PAL_BANNED : return "banned"; - case PAL_UNREGPLAYER : return "unregplayer"; - case PAL_REGPLAYER : return "regplayer"; - case PAL_VOLUNTEER : return "volunteer"; - case PAL_GM : return "gm"; - case PAL_ADMIN : return "admin"; - } - - return "custom"; + switch(mLevel) + { + case PAL_BANNED : return "banned"; + case PAL_UNREGPLAYER : return "unregplayer"; + case PAL_REGPLAYER : return "regplayer"; + case PAL_VOLUNTEER : return "volunteer"; + case PAL_GM : return "gm"; + case PAL_ADMIN : return "admin"; + } + + return "custom"; } bool PAccount::SetStatus(PAccountStatus Status) @@ -286,55 +241,55 @@ bool PAccount::SetBannedUntilTime(std::time_t BannedUntil) } } -bool PAccount::DecodePassword(const u8* PasswordData, int PassLen, const u8 *Key, char* ClearPassword) +bool PAccount::DecodePassword(const uint8_t* PasswordData, int PassLen, const uint8_t *Key, char* ClearPassword) { ClearPassword[0] = 0; - + if(PassLen < 128) - { - if(Key[0]>7) // TODO: >7 correct? - { - for(int i=0; i>1] = (char)(((PasswordData[i]&0xf0)>>4) - +((PasswordData[i+1]&0x0f)<<4)-Key[0]); - ClearPassword[PassLen>>1]=0; - } - else - { - for(int i=0; i7) // TODO: >7 correct? + { + for(int i=0; i>1] = (char)(((PasswordData[i]&0xf0)>>4) + +((PasswordData[i+1]&0x0f)<<4)-Key[0]); + ClearPassword[PassLen>>1]=0; + } + else + { + for(int i=0; iPrint(RED, BLACK, "[Error]: user %s : malformed auth data (size=%d)", mName.c_str(), PassLen); - return false; - } + return Authenticate(Pass); + } + else + { + Console->Print(RED, BLACK, "[Error]: user %s : malformed auth data (size=%d)", mName.c_str(), PassLen); + return false; + } } bool PAccount::Authenticate(const char *Password) const { - if(mID == 0) // User doesn't exist and that hasn't been checked ! - { - Console->Print(RED, BLACK, "[Bug]: user %s doesn't exist and was not checked by code !", mName.c_str()); - return false; - } - - return(mPassword == Password); + if(mID == 0) // User doesn't exist and that hasn't been checked ! + { + Console->Print(RED, BLACK, "[Bug]: user %s doesn't exist and was not checked by code !", mName.c_str()); + return false; + } + + return(mPassword == Password); } bool PAccount::Create() @@ -355,7 +310,7 @@ bool PAccount::Save(bool CreateMode) char escPassword[256]; MySQL->EscapeString(mName.c_str(), escUsername, 256); MySQL->EscapeString(mPassword.c_str(), escPassword, 256); - + std::string Query; Query = CreateMode ? "INSERT INTO" : "UPDATE"; Query += "accounts SET "; @@ -375,15 +330,15 @@ bool PAccount::Save(bool CreateMode) return true; } -u32 PAccount::GetCharIdBySlot(const u32 SlotId) +uint32_t PAccount::GetCharIdBySlot(const uint32_t SlotId) { char query[256]; - u32 CharId = 0; - + uint32_t CharId = 0; + MYSQL_ROW row = 0; MYSQL_RES *result = 0; - - snprintf(query, 256, "SELECT c_id FROM characters WHERE a_id = %d AND c_slot = %d LIMIT 1;", mID, SlotId); + + snprintf(query, 256, "SELECT c_id FROM characters WHERE a_id = %d AND c_slot = %d LIMIT 1;", mID, SlotId); result = MySQL->GameResQuery(query); if(result == NULL) @@ -397,14 +352,14 @@ u32 PAccount::GetCharIdBySlot(const u32 SlotId) { CharId = atoi(row[0]); } - + MySQL->FreeGameSQLResult(result); - + /*** Temporary workaround to cope with DB where c_slot is not set ***/ if(!CharId) { snprintf(query, 256, "SELECT c_id FROM characters WHERE a_id = %d ORDER BY c_slot ASC, c_id ASC LIMIT %d, 1;", mID, SlotId); - + result = MySQL->GameResQuery(query); if(result == NULL) { @@ -412,16 +367,16 @@ u32 PAccount::GetCharIdBySlot(const u32 SlotId) MySQL->ShowGameSQLError(); return 0; } - + if((row = mysql_fetch_row(result))) { CharId = atoi(row[0]); } - - MySQL->FreeGameSQLResult(result); + + MySQL->FreeGameSQLResult(result); } /*** End of workaround ***/ - + return CharId; } @@ -429,7 +384,7 @@ u32 PAccount::GetCharIdBySlot(const u32 SlotId) std::string PAccount::GetBannedTime() const { const char* unit[5] = {"seconds", "minutes", "hours", "days", "weeks"}; - + std::time_t timediff = mBannedUntil - std::time(NULL); if(timediff <=0) { diff --git a/TinNS/Source/GameServer/Accounts.hxx b/TinNS/Source/GameServer/Accounts.hxx new file mode 100644 index 0000000..7301c1e --- /dev/null +++ b/TinNS/Source/GameServer/Accounts.hxx @@ -0,0 +1,101 @@ +#pragma once + +#include +#include +#include + +class RegEx; + +/* +0 = unregistered user +1 = Registered user +30 = volunteer +50 = GM +100 = Admin +*/ + +// New way of AccountLevel handling: +// Every level is possible, the following values are only edge values. We need a bit control about that +#define PAL_BANNED -1 +#define PAL_UNREGPLAYER 0 +#define PAL_REGPLAYER 1 +#define PAL_VOLUNTEER 30 // Special Rank: 50/50 +#define PAL_GM 50 // Special Rank: 120/120 +#define PAL_ADMIN 100 // Special Rank: 127/127 + +// Max number of char slots per account +#define MAX_CHARS_PER_ACCOUNT 4 + +/* +0 = Offline +1 = Online +2 = Banned +*/ + +enum PAccountStatus +{ + PAS_OFFLINE = 0, + PAS_ONLINE = 1, + PAS_BANNED = 2 +}; + +class PAccount { + private : + // SQL Layout + enum { + a_id, + a_username, + a_password, + a_priv, + a_status, + a_bandate + }; + + // static members + static RegEx* mUsernameRegexFilter; + static RegEx* mPasswordRegexFilter; + + // instance members + uint32_t mID; + std::string mName; + std::string mPassword; + int mLevel; + PAccountStatus mStatus; + time_t mBannedUntil; + + bool LoadFromQuery(char* query); + bool DecodePassword(const uint8_t* PasswordData, int PassLen, const uint8_t *Key, char* ClearPassword); + + public : + PAccount(); + PAccount(const uint32_t AccountId); + PAccount(const char *Username); + + static bool SetUsernameRegexFilter(const char* RegexStr); + static bool SetPasswordRegexFilter(const char* RegexStr); + static bool IsUsernameWellFormed(const char *Username); + static bool IsPasswordWellFormed(const char *Password); + + inline uint32_t GetID() const { return mID; } + bool SetName(const std::string &Pass); + inline const std::string &GetName() const { return mName; } + bool SetPassword(const std::string &Pass); + bool SetPasswordEncoded(const uint8_t* PasswordData, int PassLen, const uint8_t *Key); + inline const std::string &GetPassword() const { return mPassword; } + bool SetLevel(int newLevel); + inline int GetLevel() const { return mLevel; } + std::string GetLevelString() const; + bool SetStatus(PAccountStatus Status); + inline PAccountStatus GetStatus() const { return mStatus; } + bool SetBannedUntilTime(time_t BannedUntil); + inline bool IsBanned() const { return (mBannedUntil > std::time(NULL)); } + std::string GetBannedTime() const; + + bool Authenticate(const uint8_t* PasswordData, int PassLen, const uint8_t *Key); + bool Authenticate(const char *Password) const; + + bool Create(); + bool Save(bool CreateMode = false); + + uint32_t GetCharIdBySlot(const uint32_t SlotId); +}; diff --git a/server/src/game/appartements.cpp b/TinNS/Source/GameServer/Appartements.cxx similarity index 75% rename from server/src/game/appartements.cpp rename to TinNS/Source/GameServer/Appartements.cxx index 0da9610..062ecc3 100644 --- a/server/src/game/appartements.cpp +++ b/TinNS/Source/GameServer/Appartements.cxx @@ -1,40 +1,7 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - appartements.cpp - appartements class - - MODIFIED: 20 Nov 2006 Hammag - REASON: - creation - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - -#include "main.h" - -#include "include/appartements.h" -#include "include/gamedefs.h" -#include "include/def_appartements.h" -#include "include/worlds.h" +#include +#include "GameServer/Includes.hxx" +#include "GameServer/Definitions/Includes.hxx" +#include "Common/Includes.hxx" PAppartements::PAppartements() { @@ -42,15 +9,15 @@ PAppartements::PAppartements() //PAppartements::~PAppartements() {}; -u32 PAppartements::CreateBaseAppartement(u32 nCharID, std::string nPassword, u8 nFactionID) +uint32_t PAppartements::CreateBaseAppartement(uint32_t nCharID, std::string nPassword, uint8_t nFactionID) { typedef std::vector< std::pair > PAppVector; // - - PAppVector CandidateApts; + + PAppVector CandidateApts; CandidateApts.reserve(32); - u16 j; + uint16_t j; int AppType; - + for (std::map::const_iterator i=GameDefs->Appartements()->ConstIteratorBegin(); i!=GameDefs->Appartements()->ConstIteratorEnd(); i++) { if (i->second->GetFaction() == nFactionID) @@ -66,13 +33,13 @@ if (gDevDebug) Console->Print("Added potential Apt of type %d in place %d", AppT } } } - + if(CandidateApts.size()) { j = GetRandom(CandidateApts.size()-1); if (gDevDebug) Console->Print("Apt n� %d chosen in %d for faction %d", j+1, CandidateApts.size(), nFactionID); -if (gDevDebug) Console->Print("Choosed Apt of type %d in place %d", CandidateApts[j].first, CandidateApts[j].second); +if (gDevDebug) Console->Print("Choosed Apt of type %d in place %d", CandidateApts[j].first, CandidateApts[j].second); char escPassword[256]; MySQL->EscapeString(nPassword.c_str(), escPassword, 256); @@ -92,7 +59,7 @@ if (gDevDebug) Console->Print("Choosed Apt of type %d in place %d", CandidateApt return 0; } -void PAppartements::DeleteCharAppartements(u32 nCharID) +void PAppartements::DeleteCharAppartements(uint32_t nCharID) { char query[256]; snprintf(query, 256, "DELETE FROM apartments WHERE (apt_owner='%u');", nCharID); @@ -107,15 +74,15 @@ void PAppartements::DeleteCharAppartements(u32 nCharID) if (gDevDebug) Console->Print(YELLOW, BLACK, "PAppartements::DeleteCharAppartements does not delete appartements content yet"); } -bool PAppartements::CanFreelyEnter(PChar* nChar, u32 nLocation) +bool PAppartements::CanFreelyEnter(PChar* nChar, uint32_t nLocation) { - u32 OwnerID = GetAptOwner(nLocation); + uint32_t OwnerID = GetAptOwner(nLocation); return (OwnerID == nChar->GetID()); - + // here we could manage Clan appartements access too. } -int PAppartements::GetAptID(unsigned int AptLoc, const u8 *pass) +int PAppartements::GetAptID(unsigned int AptLoc, const uint8_t *pass) { int type; MYSQL_RES *result; @@ -223,7 +190,7 @@ int PAppartements::GetAptLocation(int loc) MYSQL_ROW row; char query[255]; - if((u32)loc > PWorlds::mAptBaseWorldId) + if((uint32_t)loc > PWorlds::mAptBaseWorldId) loc = loc - PWorlds::mAptBaseWorldId; snprintf (query, 255, "SELECT apt_location FROM apartments WHERE apt_id = %i", loc); diff --git a/TinNS/Source/GameServer/Appartements.hxx b/TinNS/Source/GameServer/Appartements.hxx new file mode 100644 index 0000000..9643be0 --- /dev/null +++ b/TinNS/Source/GameServer/Appartements.hxx @@ -0,0 +1,20 @@ +#pragma once + +#include +#include + +class PChar; + +class PAppartements { +public: + PAppartements(); + //~PAppartements(); + + uint32_t CreateBaseAppartement(uint32_t nCharID, std::string nPassword, uint8_t nFactionID); + void DeleteCharAppartements(uint32_t nCharID); + bool CanFreelyEnter(PChar* nChar, uint32_t nLocation); + int GetAptID(unsigned int AptLoc, const uint8_t *pass); + int GetAptType(int AptID); + int GetAptOwner(int loc); + int GetAptLocation(int loc); +}; diff --git a/server/src/game/buddylist.cpp b/TinNS/Source/GameServer/BuddyList.cxx similarity index 66% rename from server/src/game/buddylist.cpp rename to TinNS/Source/GameServer/BuddyList.cxx index 558b6db..54f32f4 100644 --- a/server/src/game/buddylist.cpp +++ b/TinNS/Source/GameServer/BuddyList.cxx @@ -1,41 +1,8 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community +#include +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - buddylist.cpp - class for chat buddylist - - MODIFIED: 19 Sep 2006 Hammag - REASON: - creation - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem - - clean ups - - TODO: - link with a online char list, updated when needed (chars in/out, or list modified) -*/ - -#include "main.h" -#include "include/buddylist.h" - -PBuddyList::PBuddyList(u32 nOwnerCharID) +PBuddyList::PBuddyList(uint32_t nOwnerCharID) { mOwnerCharID = nOwnerCharID; mListMaxSize = mListSize = 0; @@ -49,7 +16,7 @@ PBuddyList::~PBuddyList() delete[] mCharIDList; } -bool PBuddyList::AddChar(u32 nBuddyCharID) +bool PBuddyList::AddChar(uint32_t nBuddyCharID) { char query[256]; @@ -77,10 +44,10 @@ bool PBuddyList::AddChar(u32 nBuddyCharID) return false; } -bool PBuddyList::RemoveChar(u32 nBuddyCharID) +bool PBuddyList::RemoveChar(uint32_t nBuddyCharID) { char query[256]; - u8 rEntry, i; + uint8_t rEntry, i; if ((rEntry = FindEntry(nBuddyCharID)) < mListSize) { @@ -111,7 +78,7 @@ bool PBuddyList::SQLLoad() char query[256]; MYSQL_RES *result; MYSQL_ROW row; - u8 EntriesNum; + uint8_t EntriesNum; snprintf(query, 256, "SELECT * FROM buddy_list WHERE (bud_charid='%u')", mOwnerCharID); result = MySQL->GameResQuery(query); @@ -139,9 +106,9 @@ bool PBuddyList::SQLLoad() return true; } -void PBuddyList::IncreaseMaxSize(u8 nNewMax) +void PBuddyList::IncreaseMaxSize(uint8_t nNewMax) { - u16 tmpSize; + uint16_t tmpSize; if (!nNewMax) { @@ -159,12 +126,12 @@ void PBuddyList::IncreaseMaxSize(u8 nNewMax) mListMaxSize = (tmpSize < 256) ? tmpSize : 255; - u32* tmpList = new u32[mListMaxSize]; + uint32_t* tmpList = new uint32_t[mListMaxSize]; if (mCharIDList) { if (mListSize) { - memcpy(tmpList, mCharIDList, sizeof(u32) * mListSize); + memcpy(tmpList, mCharIDList, sizeof(uint32_t) * mListSize); } delete[] mCharIDList; @@ -172,9 +139,9 @@ void PBuddyList::IncreaseMaxSize(u8 nNewMax) mCharIDList = tmpList; } -u8 PBuddyList::FindEntry(u32 CharID) +uint8_t PBuddyList::FindEntry(uint32_t CharID) { - u8 i = 255; + uint8_t i = 255; if (mCharIDList) { @@ -188,11 +155,11 @@ u8 PBuddyList::FindEntry(u32 CharID) return i; } -bool PBuddyList::IsInBuddy(u32 CharID) +bool PBuddyList::IsInBuddy(uint32_t CharID) { if (mCharIDList) { - for (u8 i = 0; i < mListSize; i++) + for (uint8_t i = 0; i < mListSize; i++) { if (mCharIDList[i] == CharID) return true; diff --git a/TinNS/Source/GameServer/BuddyList.hxx b/TinNS/Source/GameServer/BuddyList.hxx new file mode 100644 index 0000000..257c23d --- /dev/null +++ b/TinNS/Source/GameServer/BuddyList.hxx @@ -0,0 +1,35 @@ +#pragma once + +#include + +#define BUDDYLIST_ALLOC_SIZE 4 // atomicity of list entries allocation + +class PBuddyList { + private: + enum { // buddy_list DB Table fields + bud_id = 0, + bud_charid, + bud_buddyid + }; + + uint32_t mOwnerCharID; + uint8_t mListMaxSize; + uint8_t mListSize; + uint32_t* mCharIDList; + + void IncreaseMaxSize(uint8_t nNewMax = 0); + uint8_t FindEntry(uint32_t CharID); + + public: + PBuddyList(uint32_t nOwnerCharID); + ~PBuddyList(); + bool AddChar(uint32_t nBuddyCharID); + bool RemoveChar(uint32_t nBuddyCharID); + inline uint8_t Count() { return mListSize; } + uint16_t GetListDataSize() { return (sizeof(uint32_t) * mListSize); } + const void* GetListData() { return (const void*)mCharIDList; } + bool SQLLoad(); + + bool IsInBuddy(uint32_t CharID); +// bool SQLSave(); +}; diff --git a/TinNS/Source/GameServer/CMakeLists.txt b/TinNS/Source/GameServer/CMakeLists.txt new file mode 100644 index 0000000..479ed02 --- /dev/null +++ b/TinNS/Source/GameServer/CMakeLists.txt @@ -0,0 +1,18 @@ +INCLUDE_DIRECTORIES (${CURRENT_SOURCE_DIR} ${LUA53_INCLUDE_DIR}) + +ADD_SUBDIRECTORY (Decoder) +ADD_SUBDIRECTORY (Definitions) +ADD_SUBDIRECTORY (GameCommands) + +ADD_EXECUTABLE (GameServer + Accounts.cxx Appartements.cxx BuddyList.cxx Chars.cxx Chat.cxx Client.cxx ClientManager.cxx + Commands.cxx Container.cxx DoorTemplate.cxx FurnitureTemplate.cxx GameScript.cxx + GameServer.cxx GenrepList.cxx Includes.cxx Isc.cxx Inventory.cxx Item.cxx LuaEngine.cxx + Main.cxx MessageBuilder.cxx MultiPart.cxx Npc.cxx NpcAi.cxx NpcConversation.cxx NpcTemplate.cxx + Outpost.cxx RemoteConsole.cxx Server.cxx Skill.cxx Sql.cxx Subway.cxx Terminal.cxx + TerminalQueryDatabase.cxx TerminalReceiveDatabase.cxx TerminalTryAccess.cxx + TerminalUpdateDatabase.cxx Vehicle.cxx VehicleAccessRequest.cxx WorldActors.cxx + WorldDataTemplate.cxx Worlds.cxx Zoning.cxx) + +TARGET_LINK_LIBRARIES (GameServer Common Decoder Definitions GameCommands ${MYSQL_LIBRARY} ${PCRE_LIBRARY} + ${ZLIB_LIBRARY} ${RT_LIBRARY} ${LUA53_LIBRARY}) diff --git a/server/src/game/chars.cpp b/TinNS/Source/GameServer/Chars.cxx similarity index 82% rename from server/src/game/chars.cpp rename to TinNS/Source/GameServer/Chars.cxx index 99eb049..cd9f727 100644 --- a/server/src/game/chars.cpp +++ b/TinNS/Source/GameServer/Chars.cxx @@ -1,93 +1,40 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - chars.cpp - - MODIFIED: 22 Dec 2005 Namikon - REASON: - Added GPL - MODIFIED: 01 Jan 2006 Namikon - REASON: - Added SQLLoad() function to PChar and PChars - - Changed FmtTxt() to sprintf(). It does... uhm, the same :D - - Added IsOnline var and function - MODIFIED: 06 Jan 2005 Namikon - REASON: - Added colored console ouputs - - Removed XM Load() and Save() functions - - Rewrote parts of SQLLoad to work with the global NeoPolis / TinNS database - - Added FillinCharDetails to fill the baseline up with the char details - MODIFIED: 03 Oct 2006 Hammag - REASON: - PChar::CreateNewChar() and moved effective char creation from PChars to PChar - - added PChar::SQLDelete() - This method is put here because we want the char to be loaded when deleted from DB to avoid - any player to use it at the same time. - - added use of auto_save_period config option in PChars::update() - - removed old XML-storage related code - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for ne buildsystem - - clean ups - - TODO: - implement PChar::SQLDelete() -*/ - -#include "main.h" -#include "include/worlds.h" -#include "include/appartements.h" -#include "include/container.h" -#include "include/inventory.h" -#include "include/vhcaccessrequest.h" +#include +#include "GameServer/Includes.hxx" +#include "GameServer/Definitions/Includes.hxx" +#include "Common/Includes.hxx" // PCharCoordinates -void PCharCoordinates::SetInterpolate( PCharCoordinates& Pos1, PCharCoordinates& Pos2, f32 nCoef ) +void PCharCoordinates::SetInterpolate( PCharCoordinates& Pos1, PCharCoordinates& Pos2, float nCoef ) { if (( nCoef < 0 ) || ( nCoef > 1 ) ) { Console->Print( RED, BLACK, "[Error] PCharCoordinates::Interpolate : Invalid nCoef value: %f", nCoef ); nCoef = 0; } - f32 rCoef = 1 - nCoef; + float rCoef = 1 - nCoef; - mY = ( u16 )( rCoef * Pos1.mY + nCoef * Pos2.mY ); - mZ = ( u16 )( rCoef * Pos1.mZ + nCoef * Pos2.mZ ); - mX = ( u16 )( rCoef * Pos1.mX + nCoef * Pos2.mX ); - mUD = ( u8 )( rCoef * Pos1.mUD + nCoef * Pos2.mUD ); + mY = ( uint16_t )( rCoef * Pos1.mY + nCoef * Pos2.mY ); + mZ = ( uint16_t )( rCoef * Pos1.mZ + nCoef * Pos2.mZ ); + mX = ( uint16_t )( rCoef * Pos1.mX + nCoef * Pos2.mX ); + mUD = ( uint8_t )( rCoef * Pos1.mUD + nCoef * Pos2.mUD ); if ( abs( Pos1.mLR - Pos2.mLR ) < 90 ) { - mLR = ( u8 )( rCoef * Pos1.mLR + nCoef * Pos2.mLR ); + mLR = ( uint8_t )( rCoef * Pos1.mLR + nCoef * Pos2.mLR ); } else { - mLR = ( u8 )(( u16 )( rCoef * ( 180.0 + ( f32 )Pos1.mLR ) + nCoef * Pos2.mLR ) % 180 ); + mLR = ( uint8_t )(( uint16_t )( rCoef * ( 180.0 + ( float )Pos1.mLR ) + nCoef * Pos2.mLR ) % 180 ); } } -u16 mY; // Y-Position in world -u16 mZ; // Z-Position in world -u16 mX; // X-Position in world -u8 mUD; // Up - Mid - Down (d6 - 80 - 2a) -u8 mLR; // Compass direction (S..E..N..W..S [0-45-90-135-179]) -u8 mAct; // Last user action state +uint16_t mY; // Y-Position in world +uint16_t mZ; // Z-Position in world +uint16_t mX; // X-Position in world +uint8_t mUD; // Up - Mid - Down (d6 - 80 - 2a) +uint8_t mLR; // Compass direction (S..E..N..W..S [0-45-90-135-179]) +uint8_t mAct; // Last user action state -void PCharCoordinates::SetPosition( u16 nY, u16 nZ, u16 nX, u8 nUD, u8 nLR ) +void PCharCoordinates::SetPosition( uint16_t nY, uint16_t nZ, uint16_t nX, uint8_t nUD, uint8_t nLR ) { mY = nY; mZ = nZ; @@ -221,7 +168,7 @@ PChar::PChar() mSeatInUseObjectId = 0; mSeatInUseSeatId = 0; mVhcAccessRequestList = NULL; - + mContainerInExclusiveUse = NULL; mIsOnline = false; @@ -300,7 +247,7 @@ bool PChar::IsCharnameWellFormed( const char *Charname ) return true; } -void PChar::SetProfession( u32 Profession ) +void PChar::SetProfession( uint32_t Profession ) { const PDefCharKind *def = GameDefs->CharKinds()->GetDef( Profession ); if ( def == NULL ) @@ -317,23 +264,23 @@ void PChar::SetProfession( u32 Profession ) SetDirtyFlag(); } -u32 PChar::GetSkinFromCharType( u32 nType ) +uint32_t PChar::GetSkinFromCharType( uint32_t nType ) { const PDefCharacter* nDefCharacter = GameDefs->Chars()->GetDef( nType ); if ( nDefCharacter ) { - return (( u32 )( nDefCharacter->GetModel() ) ); + return (( uint32_t )( nDefCharacter->GetModel() ) ); } else return 0; } -inline u32 PChar::GetBaseModel() +inline uint32_t PChar::GetBaseModel() { return GetSkinFromCharType( GetType() ); } -void PChar::SetRealLook( u32 nHead, u32 nTorso, u32 nLegs ) +void PChar::SetRealLook( uint32_t nHead, uint32_t nTorso, uint32_t nLegs ) { mRealHead = nHead; mRealTorso = nTorso; @@ -342,7 +289,7 @@ void PChar::SetRealLook( u32 nHead, u32 nTorso, u32 nLegs ) ResetCurrentLook(); } -void PChar::GetRealLook( u32 &nSkin, u32 &nHead, u32 &nTorso, u32 &nLegs ) +void PChar::GetRealLook( uint32_t &nSkin, uint32_t &nHead, uint32_t &nTorso, uint32_t &nLegs ) { nSkin = GetBaseModel(); nHead = mRealHead; @@ -350,21 +297,21 @@ void PChar::GetRealLook( u32 &nSkin, u32 &nHead, u32 &nTorso, u32 &nLegs ) nLegs = mRealLegs; } -void PChar::SetCurrentLookFromCharType( u32 nType ) +void PChar::SetCurrentLookFromCharType( uint32_t nType ) { int iHead, iTorso, iLegs; - u32 nSkin, nHead, nTorso, nLegs; - u8 nColor, nBrightness; + uint32_t nSkin, nHead, nTorso, nLegs; + uint8_t nColor, nBrightness; const PDefCharacter* nDefCharacter = GameDefs->Chars()->GetDef( nType ); if ( nDefCharacter ) { - nSkin = ( u32 ) nDefCharacter->GetModel(); + nSkin = ( uint32_t ) nDefCharacter->GetModel(); iHead = nDefCharacter->GetHead(); iTorso = nDefCharacter->GetTorso(); iLegs = nDefCharacter->GetLegs(); - nColor = ( u8 )( 0xff & nDefCharacter->GetColor() ); - nBrightness = ( u8 )( 0xff & nDefCharacter->GetBrightness() ); + nColor = ( uint8_t )( 0xff & nDefCharacter->GetColor() ); + nBrightness = ( uint8_t )( 0xff & nDefCharacter->GetBrightness() ); if (( iHead < 0 ) || ( iTorso < 0 ) || ( iLegs < 0 ) ) @@ -383,7 +330,7 @@ void PChar::SetCurrentLookFromCharType( u32 nType ) } } -void PChar::SetCurrentLook( u32 nSkin, u32 nHead, u32 nTorso, u32 nLegs ) +void PChar::SetCurrentLook( uint32_t nSkin, uint32_t nHead, uint32_t nTorso, uint32_t nLegs ) { mSkin = nSkin; mHead = nHead; @@ -400,7 +347,7 @@ void PChar::ResetCurrentLook() } // GetCurrentLook will later have to take Power Armors and GM overrides into account -void PChar::GetCurrentLook( u32 &nSkin, u32 &nHead, u32 &nTorso, u32 &nLegs ) +void PChar::GetCurrentLook( uint32_t &nSkin, uint32_t &nHead, uint32_t &nTorso, uint32_t &nLegs ) { nSkin = mSkin; nHead = mHead; @@ -408,7 +355,7 @@ void PChar::GetCurrentLook( u32 &nSkin, u32 &nHead, u32 &nTorso, u32 &nLegs ) nLegs = mLegs; } -void PChar::SetCurrentBodyColor( u8 nHeadColor, u8 nTorsoColor, u8 nLegsColor, u8 nHeadDarkness, u8 nTorsoDarkness, u8 nLegsDarkness ) +void PChar::SetCurrentBodyColor( uint8_t nHeadColor, uint8_t nTorsoColor, uint8_t nLegsColor, uint8_t nHeadDarkness, uint8_t nTorsoDarkness, uint8_t nLegsDarkness ) { mHeadColor = nHeadColor; mTorsoColor = nTorsoColor; @@ -418,7 +365,7 @@ void PChar::SetCurrentBodyColor( u8 nHeadColor, u8 nTorsoColor, u8 nLegsColor, u mLegsDarkness = nLegsDarkness; } -void PChar::GetCurrentBodyColor( u8 &nHeadColor, u8 &nTorsoColor, u8 &nLegsColor, u8 &nHeadDarkness, u8 &nTorsoDarkness, u8 &nLegsDarkness ) +void PChar::GetCurrentBodyColor( uint8_t &nHeadColor, uint8_t &nTorsoColor, uint8_t &nLegsColor, uint8_t &nHeadDarkness, uint8_t &nTorsoDarkness, uint8_t &nLegsDarkness ) { nHeadColor = mHeadColor; nTorsoColor = mTorsoColor; @@ -458,7 +405,7 @@ void PChar::SetBaseSkills() Console->Print( YELLOW, BLACK, "PChar::SetBaseSkills() not fully functionnal - unused skill points will be lost" ); } -void PChar::SetBaseSubskills( u8 NSZNb, const char* NonZeroSubskills ) +void PChar::SetBaseSubskills( uint8_t NSZNb, const char* NonZeroSubskills ) { int i; @@ -473,8 +420,8 @@ void PChar::SetBaseSubskills( u8 NSZNb, const char* NonZeroSubskills ) void PChar::SetBaseInventory() { - u8 i; - u32 BaseItemID; + uint8_t i; + uint32_t BaseItemID; const PDefCharKind *def = GameDefs->CharKinds()->GetDef( mProfession ); //mCash = 5000; @@ -551,7 +498,7 @@ bool PChar::SQLLoad( int CharID ) // Gender int genvalue = atoi( row[c_sex] ); if (( genvalue == 0 ) || ( genvalue == 1 ) ) - mGender = static_cast( genvalue ); + mGender = static_cast( genvalue ); else { Console->Print( RED, BLACK, "Bad gender value: %d (Char ID %d)", genvalue, mID ); @@ -560,12 +507,12 @@ bool PChar::SQLLoad( int CharID ) // Profession int profvalue = atoi( row[c_profession] ); - SetProfession( static_cast( profvalue ) ); + SetProfession( static_cast( profvalue ) ); // Class //int classvalue = atoi(row[c_class]); //if(classvalue < 4) - // mClass = static_cast(classvalue); + // mClass = static_cast(classvalue); //else //{ // Console->Print(RED, BLACK, "Bad class value: %d (Char ID %d)", classvalue, mID); @@ -575,46 +522,46 @@ bool PChar::SQLLoad( int CharID ) // Faction int facvalue = atoi( row[c_faction] ); if ( GameDefs->Factions()->GetDef( facvalue ) ) - mFaction = static_cast( facvalue ); + mFaction = static_cast( facvalue ); else mFaction = 1; /* // Model int modvalue = atoi(row[c_model]); - mModel = static_cast(modvalue); + mModel = static_cast(modvalue); mModel = 10; */ int headvalue = atoi( row[c_head] ); int torsovalue = atoi( row[c_torso] ); int legsvalue = atoi( row[c_legs] ); - SetRealLook( static_cast( headvalue ), static_cast( torsovalue ), static_cast( legsvalue ) ); + SetRealLook( static_cast( headvalue ), static_cast( torsovalue ), static_cast( legsvalue ) ); // Type /* int typevalue = std::atoi(row[c_type]); - mType = static_cast(typevalue); + mType = static_cast(typevalue); //mType = 1; */ // Location int locvalue = atoi( row[c_location] ); - mLocation = static_cast( locvalue ); + mLocation = static_cast( locvalue ); //This assumption is not so good ... hardcoding jailed state linked with location ... if ( mLocation == 550 || mLocation == 551 ) mJailed = true; int posvalue = atoi( row[c_pos_x] ); - Coords.mX = static_cast( posvalue ); + Coords.mX = static_cast( posvalue ); posvalue = atoi( row[c_pos_y] ); - Coords.mY = static_cast( posvalue ); + Coords.mY = static_cast( posvalue ); posvalue = atoi( row[c_pos_z] ); - Coords.mZ = static_cast( posvalue ); + Coords.mZ = static_cast( posvalue ); posvalue = atoi( row[c_angle_ud] ); - Coords.mUD = static_cast( posvalue ); + Coords.mUD = static_cast( posvalue ); posvalue = atoi( row[c_angle_lr] ); - Coords.mLR = static_cast( posvalue ); + Coords.mLR = static_cast( posvalue ); int primapt = atoi( row[c_apt] ); - mPrimaryApt = static_cast( primapt ); + mPrimaryApt = static_cast( primapt ); mStartApt = mPrimaryApt; mSoullight = atoi( row[c_soullight] ); @@ -623,8 +570,8 @@ bool PChar::SQLLoad( int CharID ) LoadClanLevel(); // Cash - f32 cashvalue = atof( row[c_cash] ); - mCash = static_cast( cashvalue ); + float cashvalue = atof( row[c_cash] ); + mCash = static_cast( cashvalue ); // --------------------------------------------- // Loading skills --- MAIN Skills with SP and XP @@ -688,7 +635,7 @@ bool PChar::SQLLoad( int CharID ) mInventory.SQLLoad(); // temp value forcing, not get/saved from DB atm - mCombatRank = ( u8 )( random() % 127 ); // bad result there on randomness + mCombatRank = ( uint8_t )( random() % 127 ); // bad result there on randomness mSynaptic = 0; mIsDead = false; @@ -773,8 +720,8 @@ bool PChar::SQLCreate() // Specific method for creation in order to avoid existe } } -bool PChar::CreateNewChar( u32 Account, const std::string &Name, u32 Gender, u32 Profession, u32 Faction, - u32 Head, u32 Torso, u32 Legs, u8 NZSNb, const char *NonZeroSubskills, u32 Slot ) +bool PChar::CreateNewChar( uint32_t Account, const std::string &Name, uint32_t Gender, uint32_t Profession, uint32_t Faction, + uint32_t Head, uint32_t Torso, uint32_t Legs, uint8_t NZSNb, const char *NonZeroSubskills, uint32_t Slot ) { SetName( Name ); SetGender( Gender ); @@ -790,7 +737,7 @@ bool PChar::CreateNewChar( u32 Account, const std::string &Name, u32 Gender, u32 // This part will have to be rewritten with proper methods mSoullight = 10; - mCombatRank = ( u8 )( random() % 80 ); // bad result there on randomness + mCombatRank = ( uint8_t )( random() % 80 ); // bad result there on randomness mSynaptic = 0; mIsDead = false; @@ -976,7 +923,7 @@ void PChar::SetOnlineStatus( bool IsOnline ) return; } -u8 PChar::GetCombatRank() +uint8_t PChar::GetCombatRank() { // Override for Special Account Levels PAccount Acc(mAccount); @@ -991,7 +938,7 @@ u8 PChar::GetCombatRank() } -u8 PChar::GetMainRank() +uint8_t PChar::GetMainRank() { // Override for Special Account Levels PAccount Acc(mAccount); @@ -1003,20 +950,40 @@ u8 PChar::GetMainRank() return 50; else { - u16 total; + uint16_t total; total = Skill->GetMainSkill( MS_STR ) + Skill->GetMainSkill( MS_DEX ); total += Skill->GetMainSkill( MS_CON ) + Skill->GetMainSkill( MS_INT ); total += Skill->GetMainSkill( MS_PSI ); - return (( u8 )( total / 5 ) ); + return (( uint8_t )( total / 5 ) ); } } -u32 PChar::AddCash( u32 nAmount ) +bool PChar::AddGenrep(uint16_t nWorldID, uint16_t nStationID) +{ + return mGenrepList->AddGenrep(nWorldID, nStationID ); +} + +uint16_t PChar::GetGenrepListDataSize() +{ + return mGenrepList->GetListDataSize(); +} + +const void *PChar::GetGenrepListData() +{ + return mGenrepList->GetListData(); +} + +uint8_t PChar::GetGenrepCount() +{ + return mGenrepList->Count(); +} + +uint32_t PChar::AddCash( uint32_t nAmount ) { return SetCash(nAmount + mCash); } -u32 PChar::TakeCash( u32 nAmount ) +uint32_t PChar::TakeCash( uint32_t nAmount ) { if(nAmount > mCash) { @@ -1029,13 +996,13 @@ u32 PChar::TakeCash( u32 nAmount ) } } -u32 PChar::SetCash( u32 nCash ) +uint32_t PChar::SetCash( uint32_t nCash ) { //Console->Print("Trying to set cash to nCash: %d", nCash); if (( int )nCash > Config->GetOptionInt( "max_cash" ) ) { //Console->Print("Newcash would be more than dynamic maxcash, setting to maxcash"); - mCash = ( u32 )Config->GetOptionInt( "max_cash" ); + mCash = ( uint32_t )Config->GetOptionInt( "max_cash" ); } else if ( nCash > MAXCASH ) { @@ -1052,7 +1019,7 @@ u32 PChar::SetCash( u32 nCash ) } -bool PChar::SetQuickBeltActiveSlot( u8 nSlotID ) +bool PChar::SetQuickBeltActiveSlot( uint8_t nSlotID ) { if (( nSlotID == INV_WORN_QB_HAND ) || ( nSlotID == INV_WORN_QB_NONE ) ) { @@ -1076,7 +1043,7 @@ bool PChar::SetQuickBeltActiveSlot( u8 nSlotID ) return false; } -PSeatType PChar::GetSeatInUse( u32* nObjectId, u8* nSeatId ) +PSeatType PChar::GetSeatInUse( uint32_t* nObjectId, uint8_t* nSeatId ) { if ( nObjectId ) { @@ -1090,7 +1057,7 @@ PSeatType PChar::GetSeatInUse( u32* nObjectId, u8* nSeatId ) return mSeatInUseType; } -void PChar::SetSeatInUse( PSeatType nSeatType, u32 nObjectId, u8 nSeatId ) +void PChar::SetSeatInUse( PSeatType nSeatType, uint32_t nObjectId, uint8_t nSeatId ) { mSeatInUseType = nSeatType; mSeatInUseObjectId = nObjectId; @@ -1105,13 +1072,13 @@ PVhcAccessRequestList* PChar::GetVhcAccessRequestList() return mVhcAccessRequestList; } -void PChar::SetLookingAt( u16 nLocalCharID ) +void PChar::SetLookingAt( uint16_t nLocalCharID ) { mLookingAt = nLocalCharID; mLookAtTimestamp = std::time( NULL ); } -u16 PChar::GetLookingAt( u16 nMaxDelaySec ) +uint16_t PChar::GetLookingAt( uint16_t nMaxDelaySec ) { return ((( mLookAtTimestamp + nMaxDelaySec ) >= std::time( NULL ) ) ? mLookingAt : 0 ); } @@ -1152,7 +1119,7 @@ PChars::~PChars() delete i->second; } -bool PChars::LoadChar( u32 CharID ) +bool PChars::LoadChar( uint32_t CharID ) { if ( !CharID ) return false; @@ -1189,7 +1156,7 @@ bool PChars::AddChar( PChar* nChar ) } } -PChar* PChars::RemoveChar( u32 CharID ) +PChar* PChars::RemoveChar( uint32_t CharID ) { PChar* Result = NULL; @@ -1231,7 +1198,7 @@ void PChars::SQLSave() return; } -PChar* PChars::GetChar( u32 CharID ) const +PChar* PChars::GetChar( uint32_t CharID ) const { PChar *Result = 0; CharMap::const_iterator i = mChars.find( CharID ); @@ -1305,7 +1272,7 @@ void PChars::Update() } //MAX_CHARS_PER_ACCOUNT -int PChars::GetCharProfiles( const u32 AccountID, PCharProfile* CharSlotsArray, const u8 ArraySize ) +int PChars::GetCharProfiles( const uint32_t AccountID, PCharProfile* CharSlotsArray, const uint8_t ArraySize ) { char query[256]; int EntriesNb = 0; @@ -1325,7 +1292,7 @@ int PChars::GetCharProfiles( const u32 AccountID, PCharProfile* CharSlotsArray, //EntriesNb = mysql_num_rows(result); int SlotID; - u32 CharID; + uint32_t CharID; PChar* tmpChar = new PChar(); while (( row = mysql_fetch_row( result ) ) ) @@ -1342,7 +1309,7 @@ int PChars::GetCharProfiles( const u32 AccountID, PCharProfile* CharSlotsArray, CharSlotsArray[SlotID].CharID = CharID; CharSlotsArray[SlotID].Type = tmpChar->GetType(); - CharSlotsArray[SlotID].Location = static_cast( atoi( row[c_location] ) ); + CharSlotsArray[SlotID].Location = static_cast( atoi( row[c_location] ) ); CharSlotsArray[SlotID].Head = atoi( row[c_head] ); CharSlotsArray[SlotID].Torso = atoi( row[c_torso] ); CharSlotsArray[SlotID].Legs = atoi( row[c_legs] ); diff --git a/TinNS/Source/GameServer/Chars.hxx b/TinNS/Source/GameServer/Chars.hxx new file mode 100644 index 0000000..b2b3030 --- /dev/null +++ b/TinNS/Source/GameServer/Chars.hxx @@ -0,0 +1,335 @@ +#pragma once + +#include +#include +#include +#include "GameServer/Inventory.hxx" // FIXME: class design fault + +#define MAXCASH 1000000000 + +class PGenrepList; +class PSkillHandler; +class PVhcAccessRequestList; + +enum PSeatType { + seat_none = 0, + seat_chair, + seat_subway, + seat_vhc +}; + +class PCharCoordinates { + public: + uint16_t mY; // Y-Position in world // Y increases when going East + uint16_t mZ; // Z-Position in world // Z increases when going up + uint16_t mX; // X-Position in world // X increases when going South + uint8_t mUD; // Up - Mid - Down (d6 - 80 - 2a) + uint8_t mLR; // Compass direction (S..E..N..W..S [0-45-90-135-179]) + uint8_t mAct; // Last user action state + uint8_t mUnknown;// sometime sent by client with value != 0 (usual case) + // mAct: + // 0x00 NC has no focus (player alt+tab'ed out) + // 0x04 Char on ground/dead 00000100 + // 0x20 Char does nothing 00100000 + // 0x22 kneeing 00100010 + // 0x28 left step 00101000 + // 0x30 right step 00110000 + // 0x40 walking (not running) 01000000 // Seems to mean Running ? - to be verfied, with default walk/run mode !!! + // 0x60 forward 01100000 + // 0xA0 backward 10100000 + // bits: BFWRL.K. + + uint8_t mJumpingState; + + //inline PCharCoordinates() { mX = mY = mZ = mUD = mLR = mAct = mUnknown = mJumpingState = 0;} + void SetPosition( uint16_t nY, uint16_t nZ, uint16_t nX, uint8_t nUD = 0x80, uint8_t nLR = 0 ); + void SetInterpolate( PCharCoordinates& Pos1, PCharCoordinates& Pos2, float nCoef ); + + //Temp + uint16_t minPos[3]; + uint16_t maxPos[3]; + inline PCharCoordinates() { mX = mY = mZ = mUD = mLR = mAct = mUnknown = mJumpingState = 0; for(int i=0; i<3; ++i) { minPos[i] = 0xffff; maxPos[i] = 0; } } +}; + +class PChar +{ + private : + // static members + static RegEx* mCharnameRegexFilter; + + // instance members + uint32_t mID; + uint32_t mAccount; + uint8_t mSlot; + std::string mName; + uint32_t mGender; + uint32_t mClass; + //uint32_t mType; // Removed that and only keep GetType() + uint32_t mProfession; + uint32_t mFaction; + uint32_t mRealHead; // Base Skin elements, in complement of (computed) mType + uint32_t mRealTorso; // " Head shouldn't be changeable, except in case of surgery !!! + uint32_t mRealLegs; // " + uint32_t mSkin; // Current Skin elements. *** Not saved in DB atm *** + uint32_t mHead; // " + uint32_t mTorso; // " + uint32_t mLegs; // " + uint8_t mHeadColor; // " + uint8_t mTorsoColor; // " + uint8_t mLegsColor; // " + uint8_t mHeadDarkness; // " // 0=Bright, 255=dark + uint8_t mTorsoDarkness; // " + uint8_t mLegsDarkness; // " + // Skin scale factor setting remain to discover, provided they are somewhere for player chars ... + + bool mLocationLeased; // temp until char on-demand load/unload + uint32_t mLocation; + uint32_t mCash; + uint32_t mStartApt; // set same as PrimaryApt atm + uint32_t mPrimaryApt; + + // not saved in DB atm + PSeatType mSeatInUseType; + uint32_t mSeatInUseObjectId; + uint8_t mSeatInUseSeatId; + PVhcAccessRequestList* mVhcAccessRequestList; + + PContainer* mContainerInExclusiveUse; + + uint16_t mHealth; + uint16_t mMana; + uint16_t mStamina; + + int8_t mSoullight; + uint8_t mCombatRank; // *** Not got/saved from DB atm *** + uint8_t mSynaptic; // *** Not got/saved from DB atm *** + bool mIsDead; // *** Not got/saved from DB atm *** + + // Only one body effect supported atm. Should be extended later to multiple effects + uint8_t mBodyEffect; // *** Not got/saved from DB atm *** + uint8_t mBodyEffectDensity; // *** Not got/saved from DB atm *** + + uint8_t mSpeedOverride; // a hack to control move speed. Not saved in DB + + uint32_t mDirectCharID; // for Direct Chat // *** Not got/saved from DB atm *** + PBuddyList* mBuddyList; // For Buddy list Chat + uint32_t mActiveChatChannels; // Active chat channels flags // *** Not got/saved from DB atm *** + + PGenrepList* mGenrepList; // Character's GR list + + uint8_t mQuickBeltActiveSlot; // QB SlotID of item "in hand", or INV_WORN_QB_HAND or INV_WORN_QB_NONE + + uint16_t mLookingAt; // Zone charID of currently targeted player + std::time_t mLookAtTimestamp; // Lifetimer of lookat var + uint32_t mLastUsedWorldObjectId; // Last world object clicked on + + uint8_t mClanLevel; // 1-15 + uint16_t mClanID; + + bool mIsOnline; + bool mDirtyFlag; + + bool mShunned; + bool mJailed; + + uint32_t mDialogNPC; // NPCID the player talks to + uint16_t mCurrentDialogNode; // Node in .lua file we're at right now + + class PInventory mInventory; + + protected : + friend class PChars; + inline void SetID( uint32_t ID ) { mID = ID; } + inline void SetAccount( uint32_t Account ) { mAccount = Account; } + inline void SetCharSlot( uint8_t Slot ) { if ( Slot < 4 ) mSlot = Slot;} // TODO: set max slot according to server config + inline void SetName( const std::string &Name ) { mName = Name; } + inline void SetGender( uint32_t Gender ) { mGender = Gender; } + void SetProfession( uint32_t Profession ); + //inline void SetClass(uint32_t nClass) { mClass = nClass; } // mClass is defined by setting Profession + //inline void SetType(uint32_t Type) { mType = Type; } // Removed. Type is computed from Gender & Profession (??? is it not Gender + Class ???) + inline void SetFaction( uint32_t Faction ) { mFaction = Faction; } + //inline void SetModel(uint32_t Model) { mModel = Model; } // Inhibited for the moment. Base model is deduced from from Gender & Class (Profession) + void SetRealLook( uint32_t nHead, uint32_t nTorso, uint32_t nLegs ); + void SetBaseSkills(); + void SetBaseSubskills( uint8_t NZSNb, const char* NonZeroSubskills ); + void SetBaseInventory(); + + bool SQLCreate(); + + public : + PChar(); + ~PChar(); + + static bool SetCharnameRegexFilter( const char* RegexStr ); + static bool IsCharnameWellFormed( const char *Username ); + + PSkillHandler *Skill; + PCharCoordinates Coords; + + void SetCurrentLook( uint32_t nSkin, uint32_t nHead = 0, uint32_t nTorso = 0, uint32_t nLegs = 0 ); + void SetCurrentLookFromCharType( uint32_t nType ); + void ResetCurrentLook(); + + void SetCurrentBodyColor( uint8_t nHeadColor, uint8_t nTorsoColor, uint8_t nLegsColor, uint8_t nHeadDarkness = 0, uint8_t nTorsoDarkness = 0, uint8_t nLegsDarkness = 0 ); + inline void SetBodyEffect( uint8_t nEffect, uint8_t nDensity = 0 ) { mBodyEffect = nEffect; mBodyEffectDensity = nDensity; } + inline void SetSpeedOverride( uint8_t nSpeed = 255 ) { mSpeedOverride = nSpeed; } + + void SetLookingAt( uint16_t nLocalCharID ); + uint16_t GetLookingAt( uint16_t nMaxDelaySec = 1 ); + inline void SetLastUsedObject ( uint32_t nRawItemId ) { mLastUsedWorldObjectId = nRawItemId; } + inline uint32_t GetLastUsedObject () const { return mLastUsedWorldObjectId; } + + inline PInventory* GetInventory() { return &mInventory; } + inline uint32_t GetID() const { return mID; } + inline uint32_t GetAccount() const { return mAccount; } + inline const std::string &GetName() const { return mName; } + inline uint32_t GetGender() const { return mGender; } + inline uint32_t GetClass() const { return mClass; } + inline uint32_t GetType() const { return 2 * mClass + mGender; } + uint32_t GetSkinFromCharType( uint32_t nType ); + void GetRealLook( uint32_t &nSkin, uint32_t &nHead, uint32_t &nTorso, uint32_t &nLegs ); + void GetCurrentLook( uint32_t &nSkin, uint32_t &nHead, uint32_t &nTorso, uint32_t &nLegs ); + inline void GetBodyEffect( uint8_t &nEffect, uint8_t &nDensity ) { nEffect = mBodyEffect; nDensity = mBodyEffectDensity; } + + inline uint8_t GetQuickBeltActiveSlot() { return mQuickBeltActiveSlot; } + bool SetQuickBeltActiveSlot( uint8_t nSlotID ); + + void GetCurrentBodyColor( uint8_t &nHeadColor, uint8_t &nTorsoColor, uint8_t &nLegsColor, uint8_t &nHeadDarkness, uint8_t &nTorsoDarkness, uint8_t &nLegsDarkness ); + inline uint8_t GetSpeedOverride() { return mSpeedOverride; } + inline uint32_t GetBaseModel(); + inline uint32_t GetProfession() const { return mProfession; } + inline uint16_t GetMaxHealth() { return mHealth; } + inline uint16_t GetMaxMana() { return mMana; } + inline uint16_t GetMaxStamina() { return mStamina; } + inline uint16_t GetHealth() { return mHealth; } + inline uint16_t GetMana() { return mMana; } + inline uint16_t GetStamina() { return mStamina; } + inline uint32_t GetFaction() const { return mFaction; } + inline uint32_t GetLocation() const { return mLocation; } + + inline uint32_t GetCash() const { return mCash; } + uint32_t SetCash( uint32_t nCash ); // Does return the new cashvalue, NO udpmessage is sent out!! + uint32_t AddCash( uint32_t nAmount ); + uint32_t TakeCash( uint32_t nAmount ); + + inline uint32_t GetBaseApartment() const { return mPrimaryApt; } + + inline void SetJail( bool val ) { mJailed = val; }; + inline void SetShun( bool val ) { mShunned = val; }; + + inline bool IsJailed() { return mJailed; }; + inline bool IsShunned() { return mShunned; }; + + inline void SetDialogNPC( uint32_t nNPC ) { mDialogNPC = nNPC; }; + inline uint32_t GetDialogNPC() const { return mDialogNPC; }; + + inline void SetDialogNode( uint16_t nNode ) { mCurrentDialogNode = nNode; }; + inline uint16_t GetDialogNode() const { return mCurrentDialogNode; }; + + inline uint8_t GetClanLevel() const { return mClanLevel; }; + inline uint16_t GetClan() const { return mClanID; }; + void LoadClanLevel(); + + inline int8_t GetSoullight() const { return mSoullight; } + uint8_t GetMainRank(); + uint8_t GetCombatRank(); + inline uint8_t GetSynaptic() const { return mSynaptic; } + inline bool IsDead() const { return mIsDead; } + + inline bool SetDirectChat( uint32_t nBuddyCharID ) { mDirectCharID = nBuddyCharID; return true; } + inline uint32_t GetDirectChat() { return mDirectCharID; } + inline void SetActiveChannels( uint32_t nChannels ) { mActiveChatChannels = nChannels; } + inline uint32_t GetActiveChannels() { return mActiveChatChannels; } + + inline bool AddBuddy( uint32_t nBuddyCharID ) { return mBuddyList->AddChar( nBuddyCharID ); } + inline bool RemoveBuddy( uint32_t nBuddyCharID ) { return mBuddyList->RemoveChar( nBuddyCharID ); } + inline uint16_t GetBuddyListDataSize() { return mBuddyList->GetListDataSize(); } + inline const void* GetBuddyListData() { return mBuddyList->GetListData(); } + inline uint8_t GetBuddyCount() { return mBuddyList->Count(); } + inline bool IsBuddy( uint32_t CharID ) { return mBuddyList->IsInBuddy( CharID ); }; + + bool AddGenrep(uint16_t nWorldID, uint16_t nStationID); + uint16_t GetGenrepListDataSize(); + const void *GetGenrepListData(); + uint8_t GetGenrepCount(); + + inline bool IsDirty() const { return mDirtyFlag; } + inline bool IsAnyDirty() const { return mDirtyFlag || mInventory.IsDirty(); } + inline bool IsOnline() { return mIsOnline; } + void SetOnlineStatus( bool IsOnline ); + + bool CreateNewChar( uint32_t Account, const std::string &Name, uint32_t Gender, uint32_t Profession, uint32_t Faction, + uint32_t Head, uint32_t Torso, uint32_t Legs, uint8_t NZSNb, const char *NonZeroSubskills, uint32_t Slot ); + bool SQLLoad( int CharID ); + bool SQLSave(); + inline bool SQLSaveFull() { return SQLSave() && mInventory.SQLSave(); } + bool SQLDelete(); // not implemented yet + + inline void SetLocation( uint32_t Location ) { mLocation = Location; } + inline void SetDirtyFlag( bool Dirty = true ) { mDirtyFlag = Dirty; } + + // temp until char on-demand load/unload + inline void SetLocationLeased( bool nState = true ) { mLocationLeased = nState; } + inline bool GetLocationLeased() { return mLocationLeased; } + + PSeatType GetSeatInUse( uint32_t* nObjectId = NULL, uint8_t* nSeatId = NULL ); + void SetSeatInUse( PSeatType nSeatType, uint32_t nObjectId = 0, uint8_t nSeatId = 0 ); + + PVhcAccessRequestList* GetVhcAccessRequestList(); + + inline PContainer* GetContainerInExclusiveUse() { return mContainerInExclusiveUse; } + inline void SetContainerInExclusiveUse( PContainer* nContainer ) { mContainerInExclusiveUse = nContainer; } +}; + +struct PCharProfile +{ + uint32_t CharID; + uint16_t Type; + uint16_t Color0; + uint16_t Unknown1; + uint8_t Head; + uint8_t Torso; + uint8_t Legs; + uint32_t Location; + uint8_t NameLen; + uint8_t Unknown3; + uint8_t Unknown4; + uint8_t Unknown5; + uint8_t Unknown6; + uint8_t Unknown7; + uint8_t Unknown8; + uint8_t Unknown9; + uint8_t Unknown10; + uint8_t Unknown11; + uint8_t Unknown12; + std::string Name; + bool in_use; +}; + +class PChars +{ + private : + typedef std::map CharMap; + CharMap mChars; + uint32_t mLastID; + + std::time_t mAutoSavePeriod; + std::time_t mLastSave; + + public : + PChars(); + ~PChars(); + + bool LoadChar( uint32_t CharID ); + bool AddChar( PChar* nChar ); + PChar* RemoveChar( uint32_t CharID ); + + PChar* GetChar( uint32_t CharID ) const; + PChar* GetChar( const std::string &Name ) const; + bool CharExist( const std::string &Name ) const; + + void SQLSave(); + void Update(); + + int GetCharProfiles( const uint32_t AccountID, PCharProfile* CharSlotsArray, const uint8_t ArraySize ); // return effective entries nb +}; diff --git a/server/src/game/chat.cpp b/TinNS/Source/GameServer/Chat.cxx similarity index 85% rename from server/src/game/chat.cpp rename to TinNS/Source/GameServer/Chat.cxx index 257b6c1..9be8592 100644 --- a/server/src/game/chat.cpp +++ b/TinNS/Source/GameServer/Chat.cxx @@ -1,60 +1,11 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - chat.cpp - handles all ingame chat - - Authors: - - Namikon - - bakkdoor - - Akiko - - MODIFIED: 30 Nov 2005 Namikon/Akiko - REASON: - initial release by Namikon - MODIFIED: 11 Dec 2005 Namikon - REASON: - Added function SendDChat(Client, , ) to send a Direct to player - - Added Channel IDs for GameMaster (/gm) and Administrator (/admin) chat - - Added channel const's for sending chat packets - - Added function SendChat(Client, , , ) to send chat messages - See chat.h for a list of availeable 's - - MODIFIED: 17 Dec 2005 bakkdoor - REASON: - introduced new structure for chatsystem - - -> PChat class - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem - - clean ups - - TODO: - - Add "hooks" to process chatevents everywhere in the source <-- kind of done. you can use the global PChat Instance. - Check: - Chat->send(PClient* receiver, const u8* Channel, const char* AuthorNickName, char* text, bool debugOut=false); - Example: - Chat->send(receiverClient, CHAT_DIRECT, Chars->GetChar(authorClient->GetCharID())->GetName().c_str(), text); -*/ +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" -#include "main.h" -#include "include/msgbuilder.h" +// TODO:- Add "hooks" to process chatevents everywhere in the source <-- kind of done. you can use the global PChat Instance. +// Check: +// Chat->send(PClient* receiver, const uint8_t* Channel, const char* AuthorNickName, char* text, bool debugOut=false); +// Example: +// Chat->send(receiverClient, CHAT_DIRECT, Chars->GetChar(authorClient->GetCharID())->GetName().c_str(), text); PChat::PChat() { @@ -111,7 +62,7 @@ void PChat::sendBuddy(PClient* author, const char* text, bool debugOut) void PChat::sendConnectedList(PClient* receiver, bool debugOut) { - const char* text = "Connected Players are:]"; + const char* text = "Connected Players are:]"; send(receiver, CHAT_DIRECT, "[System", text, debugOut); int counter = 1; @@ -119,8 +70,8 @@ void PChat::sendConnectedList(PClient* receiver, bool debugOut) // send the list of currently connected players to receiver for(PClientMap::iterator it=ClientManager->getClientListBegin(); it!=ClientManager->getClientListEnd(); it++) { - char counterText[5]; - snprintf(counterText, 5, "%d", counter); + char counterText[5]; + snprintf(counterText, 5, "%d", counter); PChar* receiverChar = Chars->GetChar(it->second->GetCharID()); send(receiver, CHAT_DIRECT, (receiverChar ? receiverChar->GetName().c_str() : "*"), counterText, debugOut); @@ -134,7 +85,7 @@ void PChat::sendFrak(PClient* author, const char* text, bool debugOut) { // send the message to all clients that have same FactionID PChar* authorChar = Chars->GetChar(author->GetCharID()); - u32 FID = authorChar->GetFaction(); // get LocationID of author + uint32_t FID = authorChar->GetFaction(); // get LocationID of author for(PClientMap::iterator it=ClientManager->getClientListBegin(); it!=ClientManager->getClientListEnd(); it++) { @@ -155,7 +106,7 @@ void PChat::sendZone(PClient* author, const char* text, bool debugOut) { // send the message to all clients that have same ZoneID PChar* authorChar = Chars->GetChar(author->GetCharID()); - u32 ZID = authorChar->GetLocation(); // get LocationID of author + uint32_t ZID = authorChar->GetLocation(); // get LocationID of author for(PClientMap::iterator it=ClientManager->getClientListBegin(); it!=ClientManager->getClientListEnd(); it++) { @@ -175,7 +126,7 @@ void PChat::sendZone(PClient* author, const char* text, bool debugOut) void PChat::sendLocal(PClient* author, const char* text, bool debugOut) { PChar* authorChar = Chars->GetChar(author->GetCharID()); - u32 ZID = authorChar->GetLocation(); // get LocationID of author + uint32_t ZID = authorChar->GetLocation(); // get LocationID of author // send the message to all clients that are in Area (Radius = X (needs to be defined somewhere!)) for(PClientMap::iterator it=ClientManager->getClientListBegin(); it!=ClientManager->getClientListEnd(); it++) @@ -186,7 +137,7 @@ void PChat::sendLocal(PClient* author, const char* text, bool debugOut) PChar* receiverChar = Chars->GetChar(receiver->GetCharID()); if(receiverChar && (receiverChar->GetLocation() == ZID)) { - u16 distance = DistanceApprox((authorChar->Coords).mX, (authorChar->Coords).mY, (authorChar->Coords).mZ, (receiverChar->Coords).mX, (receiverChar->Coords).mY, (receiverChar->Coords).mZ); + uint16_t distance = DistanceApprox((authorChar->Coords).mX, (authorChar->Coords).mY, (authorChar->Coords).mZ, (receiverChar->Coords).mX, (receiverChar->Coords).mY, (receiverChar->Coords).mZ); if(distance < LOCALCHAT_MAXDISTANCE) { //sendLocalchat(receiver, author, text, debugOut); // Doesnt work! @@ -332,7 +283,7 @@ void PChat::sendTeam(PClient* author, const char* text, bool debugOut) } } -void PChat::sendPlayerDirect(PClient* author, const char* text, u32 destination, bool debugOut) +void PChat::sendPlayerDirect(PClient* author, const char* text, uint32_t destination, bool debugOut) { bool tmpTargetOnline = false; for(PClientMap::iterator it=ClientManager->getClientListBegin(); it!=ClientManager->getClientListEnd(); it++) @@ -348,7 +299,7 @@ void PChat::sendPlayerDirect(PClient* author, const char* text, u32 destination, if(tmpTargetOnline == false) { ConnectionTCP *Socket = author->getTCPConn(); - u8 DirectTargetNotOnline[] = {0xFE, 0x07, 0x00, 0x83, 0x18, 0x01, 0x81, 0x54, 0x00, 0x00}; + uint8_t DirectTargetNotOnline[] = {0xFE, 0x07, 0x00, 0x83, 0x18, 0x01, 0x81, 0x54, 0x00, 0x00}; Socket->write(DirectTargetNotOnline, sizeof(DirectTargetNotOnline)); Socket->flushSendBuffer(); @@ -373,7 +324,7 @@ void PChat::sendDirect(PClient* author, PClient* receiver, const char* text, boo ConnectionTCP *Socket = receiver->getTCPConn(); - u8 BasicDirectPacket[] = {0xFE, 0x20, 0x00, 0x83, 0x17, 0xB7, 0x5F, 0x00, 0x00, 0x0C, 0x04, 0x00}; + uint8_t BasicDirectPacket[] = {0xFE, 0x20, 0x00, 0x83, 0x17, 0xB7, 0x5F, 0x00, 0x00, 0x0C, 0x04, 0x00}; LenText = LenNick = fpp = 0; @@ -436,7 +387,7 @@ void PChat::sendLocalchat(PClient* receiver, PClient* author, const char* text, return; // IncreaseUDP could cause OOO here. Since this function is doing nothing, we disabled it char *LocalChatPacket; int overallsize = 0, LenText = 0; - u8 BasicLocal[] = { 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x1B }; + uint8_t BasicLocal[] = { 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x1B }; // Get size of Text to send do { @@ -469,11 +420,11 @@ void PChat::sendLocalchat(PClient* receiver, PClient* author, const char* text, // Add UdpID, SessionID, lenght and local charid receiver->IncreaseUDP_ID(); - *(u16*)&LocalChatPacket[1] = receiver->GetUDP_ID(); // UDP - *(u16*)&LocalChatPacket[3] = receiver->GetSessionID(); // Session - *(u8*)&LocalChatPacket[5] = overallsize - 6; // Packetlen - *(u16*)&LocalChatPacket[7] = receiver->GetUDP_ID(); // 2nd UDP - *(u16*)&LocalChatPacket[10] = author->GetLocalID(); // Local ID + *(uint16_t*)&LocalChatPacket[1] = receiver->GetUDP_ID(); // UDP + *(uint16_t*)&LocalChatPacket[3] = receiver->GetSessionID(); // Session + *(uint8_t*)&LocalChatPacket[5] = overallsize - 6; // Packetlen + *(uint16_t*)&LocalChatPacket[7] = receiver->GetUDP_ID(); // 2nd UDP + *(uint16_t*)&LocalChatPacket[10] = author->GetLocalID(); // Local ID // Sending local chat packet and removing dynamic array ConnectionUDP *Socket = receiver->getUDPConn(); @@ -754,15 +705,15 @@ void PChat::sendTeam70(PClient* author, const char* text, bool debugOut) } } -bool PChat::chanEnabled(PClient* Client, u32 channel) +bool PChat::chanEnabled(PClient* Client, uint32_t channel) { // Check if player has target channel enabled or disabled PChar* TargetChar = Chars->GetChar(Client->GetCharID()); if(!TargetChar) return false; - u32 actChans = TargetChar->GetActiveChannels(); - u32 check = actChans & channel; + uint32_t actChans = TargetChar->GetActiveChannels(); + uint32_t check = actChans & channel; if(check == channel) return true; @@ -770,12 +721,12 @@ bool PChat::chanEnabled(PClient* Client, u32 channel) return false; } -bool PChat::send(PClient* receiver, const u8* Channel, const char* AuthorNickName, const char* text, bool debugOut) +bool PChat::send(PClient* receiver, const uint8_t* Channel, const char* AuthorNickName, const char* text, bool debugOut) { char *ChatPacket; unsigned int packetsize = 0, c; int LenText, LenNick, fpp, d, e, loopout; - u8 TargetChannel[2]; + uint8_t TargetChannel[2]; //Console->Print("1: %#x", Channel[0]); //Console->Print("2: %#x", CHAT_BUDDY[0]); @@ -869,7 +820,7 @@ bool PChat::send(PClient* receiver, const u8* Channel, const char* AuthorNickNam ConnectionTCP *Socket = receiver->getTCPConn(); - u8 BasicChatPacket[] = {0xFE, 0x15, 0x00, 0x83, 0x17, 0x90, 0x03, 0x00, 0x00, 0x07, 0x05, 0x0F}; + uint8_t BasicChatPacket[] = {0xFE, 0x15, 0x00, 0x83, 0x17, 0x90, 0x03, 0x00, 0x00, 0x07, 0x05, 0x0F}; LenText = LenNick = fpp = 0; @@ -938,7 +889,7 @@ bool PChat::send(PClient* receiver, const u8* Channel, const char* AuthorNickNam -bool PChat::HandleGameChat(PClient *Client, const u8 *Packet) +bool PChat::HandleGameChat(PClient *Client, const uint8_t *Packet) { // if player is shunned, ignore all incomming chat and game commands. // ServerAdmins are not affected by any shuns. (Should never happen anyways...) @@ -946,7 +897,7 @@ bool PChat::HandleGameChat(PClient *Client, const u8 *Packet) int i, j, k; - u8 chattype = *(u8*)&Packet[7]; + uint8_t chattype = *(uint8_t*)&Packet[7]; // ----------------------------------------------- if(chattype == 0x1B) { // Local chat @@ -1000,146 +951,146 @@ bool PChat::HandleGameChat(PClient *Client, const u8 *Packet) // Console->Print("Channel no %#x %#x %#x %#x", Channel[0], Channel[1], Channel[2], Channel[3]); // First, check if packet is a direct-chat-packet - if(*(u8*)&Packet[8] == 0x04) { + if(*(uint8_t*)&Packet[8] == 0x04) { //Console->Print("Direct Chat: %s", ChatText); - sendPlayerDirect(Client, ChatText, *(u32*)&Packet[9], false); + sendPlayerDirect(Client, ChatText, *(uint32_t*)&Packet[9], false); //sendDirect(Client, ChatText, false); // "DIRECT> %s: %s", PlayerName, ChatText } - else if(*(u32*)Channel == CHANNEL_BUDDY) { + else if(*(uint32_t*)Channel == CHANNEL_BUDDY) { //Console->Print("Buddy Chat: %s", ChatText); sendBuddy(Client, ChatText, false); // "BUDDY> %s: %s", PlayerName, ChatText } - else if(*(u32*)Channel == CHANNEL_CLAN) { + else if(*(uint32_t*)Channel == CHANNEL_CLAN) { //Console->Print("Clan Chat: %s", ChatText); sendClan(Client, ChatText, false); // "CLAN> %s: %s", PlayerName, ChatText } - else if(*(u32*)Channel == CHANNEL_TEAM) { + else if(*(uint32_t*)Channel == CHANNEL_TEAM) { //Console->Print("Team Chat: %s", ChatText); sendTeam(Client, ChatText, false); // "TEAM> %s: %s", PlayerName, ChatText } - else if(*(u32*)Channel == CHANNEL_CUS_ZONE) { + else if(*(uint32_t*)Channel == CHANNEL_CUS_ZONE) { //Console->Print("Custom - Zone Chat: %s", ChatText); sendZone(Client, ChatText, false); // "ZONE> %s: %s", PlayerName, ChatText } - else if(*(u32*)Channel == CHANNEL_CUS_FRAKTION) { + else if(*(uint32_t*)Channel == CHANNEL_CUS_FRAKTION) { //Console->Print("Custom - Fraktion Chat: %s", ChatText); sendFrak(Client, ChatText, false); // "FRACTION> %s: %s", PlayerName, ChatText } - else if(*(u32*)Channel == CHANNEL_CUS_TRADE_CANYON) { + else if(*(uint32_t*)Channel == CHANNEL_CUS_TRADE_CANYON) { //Console->Print("Custom - Trade_Canyon Chat: %s", ChatText); sendTradeCS(Client, ChatText, false); // "TRADE - CS> %s: %s", PlayerName, ChatText } - else if(*(u32*)Channel == CHANNEL_CUS_TRADE_MB) { + else if(*(uint32_t*)Channel == CHANNEL_CUS_TRADE_MB) { //Console->Print("Custom - Trade_MB Chat: %s", ChatText); sendTradeMB(Client, ChatText, false); // "TRADE - MB> %s: %s", PlayerName, ChatText } - else if(*(u32*)Channel == CHANNEL_CUS_TRADE_NC) { + else if(*(uint32_t*)Channel == CHANNEL_CUS_TRADE_NC) { //Console->Print("Custom - Trade_NC Chat: %s", ChatText); sendTradeNC(Client, ChatText, false); // "TRADE - NC> %s: %s", PlayerName, ChatText } - else if(*(u32*)Channel == CHANNEL_CUS_TRADE_TH) { + else if(*(uint32_t*)Channel == CHANNEL_CUS_TRADE_TH) { //Console->Print("Custom - Trade_TH Chat: %s", ChatText); sendTradeTH(Client, ChatText, false); // "TRADE - TH> %s: %s", PlayerName, ChatText } - else if(*(u32*)Channel == CHANNEL_CUS_TRADE_WASTE) { + else if(*(uint32_t*)Channel == CHANNEL_CUS_TRADE_WASTE) { //Console->Print("Custom - Trade_Waste Chat: %s", ChatText); sendTradeWL(Client, ChatText, false); // "TRADE - WL> %s: %s", PlayerName, ChatText } - else if(*(u32*)Channel == CHANNEL_CUS_OOC) { + else if(*(uint32_t*)Channel == CHANNEL_CUS_OOC) { //Console->Print("Custom - OOC Chat: %s", ChatText); sendOOC(Client, ChatText, false); // "OOC> %s: %s", PlayerName, ChatText } - else if(*(u32*)Channel == CHANNEL_CUS_PLAYERHELP) { + else if(*(uint32_t*)Channel == CHANNEL_CUS_PLAYERHELP) { //Console->Print("Custom - PlayerToPlayerhelp Chat: %s", ChatText); sendHelp(Client, ChatText, false); // "HELP> %s: %s", PlayerName, ChatText } - else if(*(u32*)Channel == CHANNEL_CUS_CLANSEARCH) { + else if(*(uint32_t*)Channel == CHANNEL_CUS_CLANSEARCH) { //Console->Print("Custom - Clansearch Chat: %s", ChatText); sendClanSearch(Client, ChatText, false); // "CLANSEARCH> %s: %s", PlayerName, ChatText } - else if(*(u32*)Channel == CHANNEL_CUS_SERVICES_CANYON) { + else if(*(uint32_t*)Channel == CHANNEL_CUS_SERVICES_CANYON) { //Console->Print("Custom - Services_Canyon Chat: %s", ChatText); sendServicesCS(Client, ChatText, false); // "SKILL - CS> %s: %s", PlayerName, ChatText } - else if(*(u32*)Channel == CHANNEL_CUS_SERVICES_MB) { + else if(*(uint32_t*)Channel == CHANNEL_CUS_SERVICES_MB) { //Console->Print("Custom - Services_MB Chat: %s", ChatText); sendServicesMB(Client, ChatText, false); // "SKILL - MB> %s: %s", PlayerName, ChatText } - else if(*(u32*)Channel == CHANNEL_CUS_SERVICES_NC) { + else if(*(uint32_t*)Channel == CHANNEL_CUS_SERVICES_NC) { //Console->Print("Custom - Services_NC Chat: %s", ChatText); sendServicesNC(Client, ChatText, false); // "SKILL - NC> %s: %s", PlayerName, ChatText } - else if(*(u32*)Channel == CHANNEL_CUS_SERVICES_TH) { + else if(*(uint32_t*)Channel == CHANNEL_CUS_SERVICES_TH) { //Console->Print("Custom - Services_TH Chat: %s", ChatText); sendServicesTH(Client, ChatText, false); // "SKILL - TH> %s: %s", PlayerName, ChatText } - else if(*(u32*)Channel == CHANNEL_CUS_SERVICES_WASTE) { + else if(*(uint32_t*)Channel == CHANNEL_CUS_SERVICES_WASTE) { //Console->Print("Custom - Services_Waste Chat: %s", ChatText); sendServicesWL(Client, ChatText, false); // "SKILL - WL> %s: %s", PlayerName, ChatText } - else if(*(u32*)Channel == CHANNEL_CUS_TEAM_10) { + else if(*(uint32_t*)Channel == CHANNEL_CUS_TEAM_10) { //Console->Print("Custom - Team10 Chat: %s", ChatText); sendTeam10(Client, ChatText, false); // "TEAMSEARCH 10> %s: %s", PlayerName, ChatText } - else if(*(u32*)Channel == CHANNEL_CUS_TEAM_30) { + else if(*(uint32_t*)Channel == CHANNEL_CUS_TEAM_30) { //Console->Print("Custom - Team30 Chat: %s", ChatText); sendTeam30(Client, ChatText, false); // "EAMSEARCH 30> %s: %s", PlayerName, ChatText } - else if(*(u32*)Channel == CHANNEL_CUS_TEAM_50) { + else if(*(uint32_t*)Channel == CHANNEL_CUS_TEAM_50) { //Console->Print("Custom - Team50 Chat: %s", ChatText); sendTeam50(Client, ChatText, false); // "EAMSEARCH 50> %s: %s", PlayerName, ChatText } - else if(*(u32*)Channel == CHANNEL_CUS_TEAM_70) { + else if(*(uint32_t*)Channel == CHANNEL_CUS_TEAM_70) { //Console->Print("Custom - Team70 Chat: %s", ChatText); sendTeam70(Client, ChatText, false); // "EAMSEARCH 70> %s: %s", PlayerName, ChatText } - else if(*(u32*)Channel == CHANNEL_ADMIN) { + else if(*(uint32_t*)Channel == CHANNEL_ADMIN) { //Console->Print("Admin Chat: %s", ChatText); sendAdmin(Client, ChatText, false); // "ADMIN> %s: %s", PlayerName, ChatText } - else if(*(u32*)Channel == CHANNEL_GMADMIN) { + else if(*(uint32_t*)Channel == CHANNEL_GMADMIN) { //Console->Print("Admin Chat: %s", ChatText); sendGMAdmin(Client, ChatText, false); // "ADMIN> %s: %s", PlayerName, ChatText } - else if(*(u32*)Channel == CHANNEL_GMCHAT) { + else if(*(uint32_t*)Channel == CHANNEL_GMCHAT) { //Console->Print("GameMaster Chat: %s", ChatText); sendGM(Client, ChatText, false); // "GM> %s: %s", PlayerName, ChatText } else { - Console->Print("Unknown Chat-Channel: %#x", *(u32*)Channel); + Console->Print("Unknown Chat-Channel: %#x", *(uint32_t*)Channel); }; } } return (true); } -bool PChat::cmpr(const u8 *Array1, const u8 *Array2) { +bool PChat::cmpr(const uint8_t *Array1, const uint8_t *Array2) { if(Array1[0] == Array2[0] && Array1[1] == Array2[1]) { return true; } else { diff --git a/TinNS/Source/GameServer/Chat.hxx b/TinNS/Source/GameServer/Chat.hxx new file mode 100644 index 0000000..7d20a6e --- /dev/null +++ b/TinNS/Source/GameServer/Chat.hxx @@ -0,0 +1,152 @@ +#pragma once + +#include + +#define LOCALCHAT_MAXDISTANCE 1433 + +class PClient; + +class PChat { +public: + PChat(); + ~PChat(); + + // INCOMING CHAT + bool HandleGameChat(PClient *Client, const uint8_t *Packet); + bool cmpr(const uint8_t *Array1, const uint8_t *Array2); + + // this function is called by the other more specific functions and simply sends the data to the receiver-client + bool send(PClient* receiver, const uint8_t* Channel, const char* AuthorNickName, const char* text, bool debugOut=false); + + // this is for debugging and sends the current connected playerlist to the receiver-client + void sendConnectedList(PClient* receiver, bool debugOut=false); + + // specific channel functions: + void sendBuddy(PClient* author, const char* text, bool debugOut=false); + void sendLocal(PClient* author, const char* text, bool debugOut=false); + void sendClan(PClient* author, const char* text, bool debugOut=false); + void sendTeam(PClient* author, const char* text, bool debugOut=false); + void sendDirect(PClient* author, PClient* receiver, const char* text, bool debugOut=false); + void sendZone(PClient* author, const char* text, bool debugOut=false); + void sendFrak(PClient* author, const char* text, bool debugOut=false); + void sendTradeCS(PClient* author, const char* text, bool debugOut=false); + void sendTradeMB(PClient* author, const char* text, bool debugOut=false); + void sendTradeNC(PClient* author, const char* text, bool debugOut=false); + void sendTradeTH(PClient* author, const char* text, bool debugOut=false); + void sendTradeWL(PClient* author, const char* text, bool debugOut=false); + void sendOOC(PClient* author, const char* text, bool debugOut=false); + void sendHelp(PClient* author, const char* text, bool debugOut=false); + void sendClanSearch(PClient* author, const char* text, bool debugOut=false); + void sendServicesCS(PClient* author, const char* text, bool debugOut=false); + void sendServicesMB(PClient* author, const char* text, bool debugOut=false); + void sendServicesNC(PClient* author, const char* text, bool debugOut=false); + void sendServicesTH(PClient* author, const char* text, bool debugOut=false); + void sendServicesWL(PClient* author, const char* text, bool debugOut=false); + void sendTeam10(PClient* author, const char* text, bool debugOut=false); + void sendTeam30(PClient* author, const char* text, bool debugOut=false); + void sendTeam50(PClient* author, const char* text, bool debugOut=false); + void sendTeam70(PClient* author, const char* text, bool debugOut=false); + void sendAdmin(PClient* author, const char* text, bool debugOut=false); + void sendGM(PClient* author, const char* text, bool debugOut=false); + void sendGMAdmin(PClient* author, const char* text, bool debugOut=false); + + void sendBroadcast(const char* text, bool debugOut=false); + void sendOOCBroadcast(const char* text, bool debugOut=false); + void sendPlayerDirect(PClient* author, const char* text, uint32_t destination, bool debugOut=false); + void sendLocalchat(PClient* receiver, PClient* author, const char* text, bool debugOut=false); + bool chanEnabled(PClient* Client, uint32_t channel); +}; + +/** A WARNING: DO >N O T< (!!!) CHANGE >ANY< OF THE FOLLOWING VARIABLES UNLESS YOU KNOW EXACT WHAT YOU'RE DOING! **/ +/** You can easily mess up the entire chat subsystem. If you're unsure, ask Namikon first! **/ +/* +#################### + CHANNEL-CODES: + (INCOMING) +#################### +*/ +static const uint32_t CHANNEL_BUDDY = 0x00000000; // Buddy +static const uint32_t CHANNEL_CLAN = 0x00000002; // Clan +static const uint32_t CHANNEL_TEAM = 0x00000003; // Team +static const uint32_t CHANNEL_DIRECT = 0xFFFFFFFF; // Direct UNKNOWN YET +static const uint32_t CHANNEL_CUS_ZONE = 0x00000105; // Custom -> Zone +static const uint32_t CHANNEL_CUS_FRAKTION = 0x00000205; // Custom -> Fraktion +static const uint32_t CHANNEL_CUS_TRADE_CANYON = 0x00002005; // Custom -> Trade Canyon +static const uint32_t CHANNEL_CUS_TRADE_MB = 0x00000805; // Custom -> Trade MB +static const uint32_t CHANNEL_CUS_TRADE_NC = 0x00000405; // Custom -> Trade NC +static const uint32_t CHANNEL_CUS_TRADE_TH = 0x00001005; // Custom -> Trade TH +static const uint32_t CHANNEL_CUS_TRADE_WASTE = 0x00004005; // Custom -> Trade Wastelands +static const uint32_t CHANNEL_CUS_OOC = 0x04000005; // Custom -> OOC +static const uint32_t CHANNEL_CUS_PLAYERHELP = 0x02000005; // Custom -> Player 2 Player help +static const uint32_t CHANNEL_CUS_CLANSEARCH = 0x01000005; // Custom -> Searching Clan +static const uint32_t CHANNEL_CUS_SERVICES_CANYON = 0x00040005; // Custom -> Runner Services Canyon +static const uint32_t CHANNEL_CUS_SERVICES_MB = 0x00010005; // Custom -> Runner Services MB +static const uint32_t CHANNEL_CUS_SERVICES_NC = 0x00008005; // Custom -> Runner Services NC +static const uint32_t CHANNEL_CUS_SERVICES_TH = 0x00020005; // Custom -> Runner Services TH +static const uint32_t CHANNEL_CUS_SERVICES_WASTE = 0x00080005; // Custom -> Runner Services Wastelands +static const uint32_t CHANNEL_CUS_TEAM_10 = 0x00100005; // Custom -> Searching Team ~10 +static const uint32_t CHANNEL_CUS_TEAM_30 = 0x00200005; // Custom -> Searching Team ~30 +static const uint32_t CHANNEL_CUS_TEAM_50 = 0x00400005; // Custom -> Searching Team ~50 +static const uint32_t CHANNEL_CUS_TEAM_70 = 0x00800005; // Custom -> Searching Team ~70 +static const uint32_t CHANNEL_ADMIN = 0x000000FF; // Admin chat +static const uint32_t CHANNEL_GMADMIN = 0x000000FE; // Admin chat +static const uint32_t CHANNEL_GMCHAT = 0x000000FD; // GameMaster chat +/* +#################### + CHANNEL-CODES: + (OUTGOING) +#################### +*/ +static const uint8_t CHAT_BUDDY[] = {0x00, 0x10}; +static const uint8_t CHAT_LOCAL[] = {0x01, 0x10}; +static const uint8_t CHAT_CLAN[] = {0x02, 0x10}; +static const uint8_t CHAT_TEAM[] = {0x03, 0x10}; +static const uint8_t CHAT_DIRECT[] = {0x04, 0x10}; +static const uint8_t CHAT_ZONE[] = {0x05, 0x00}; +static const uint8_t CHAT_FRAK[] = {0x05, 0x01}; +static const uint8_t CHAT_TRADECS[] = {0x05, 0x05}; +static const uint8_t CHAT_TRADEMB[] = {0x05, 0x03}; +static const uint8_t CHAT_TRADENC[] = {0x05, 0x02}; +static const uint8_t CHAT_TRADETH[] = {0x05, 0x04}; +static const uint8_t CHAT_TRADEWL[] = {0x05, 0x06}; +static const uint8_t CHAT_OOC[] = {0x05, 0x12}; +static const uint8_t CHAT_HELP[] = {0x05, 0x11}; +static const uint8_t CHAT_CLANSEARCH[] = {0x05, 0x10}; +static const uint8_t CHAT_SERVICECS[] = {0x05, 0x0A}; +static const uint8_t CHAT_SERVICESMB[] = {0x05, 0x08}; +static const uint8_t CHAT_SERVICESNC[] = {0x05, 0x07}; +static const uint8_t CHAT_SERVICESTH[] = {0x05, 0x09}; +static const uint8_t CHAT_SERVICESWL[] = {0x05, 0x0B}; +static const uint8_t CHAT_TEAM10[] = {0x05, 0x0C}; +static const uint8_t CHAT_TEAM30[] = {0x05, 0x0D}; +static const uint8_t CHAT_TEAM50[] = {0x05, 0x0E}; +static const uint8_t CHAT_TEAM70[] = {0x05, 0x0F}; +static const uint8_t CHAT_ADMIN[] = {0xFF, 0x10}; +static const uint8_t CHAT_GMADMIN[] = {0xFE, 0x10}; +static const uint8_t CHAT_GM[] = {0xFD, 0x10}; + +/* +#################### + CHANNEL-CODES: +(EN/DISABLE-ABLE CHANNELS) +#################### +*/ +static const uint32_t C_ZONE = 1; +static const uint32_t C_FRAK = 2; +static const uint32_t C_TRADENC = 4; +static const uint32_t C_TRADEMB = 8; +static const uint32_t C_TRADETH = 16; +static const uint32_t C_TRADECS = 32; +static const uint32_t C_TRADEWL = 64; +static const uint32_t C_SERVICENC = 128; +static const uint32_t C_SERVICEMB = 256; +static const uint32_t C_SERVICETH = 512; +static const uint32_t C_SERVICECS = 1024; +static const uint32_t C_SERVICEWL = 2048; +static const uint32_t C_TEAM10 = 4096; +static const uint32_t C_TEAM30 = 8192; +static const uint32_t C_TEAM50 = 16384; +static const uint32_t C_TEAM70 = 32768; +static const uint32_t C_CLANSEARCH = 65536; +static const uint32_t C_HELP = 131072; +static const uint32_t C_OOC = 262144; diff --git a/server/src/game/client.cpp b/TinNS/Source/GameServer/Client.cxx similarity index 73% rename from server/src/game/client.cpp rename to TinNS/Source/GameServer/Client.cxx index 124ca42..7011b38 100644 --- a/server/src/game/client.cpp +++ b/TinNS/Source/GameServer/Client.cxx @@ -1,47 +1,6 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - client.cpp - - Authors: - - v00d00 - - Akiko - - Namikon - - MODIFIED: 30 Nov 2005 Akiko - REASON: - added GPL - - added modifications by Namikon - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - -#include "main.h" - -#include "include/worlds.h" -#include "include/msgbuilder.h" -#include "include/subway.h" -#include "decoder/udp_charmove.h" +#include "GameServer/Includes.hxx" +#include "GameServer/Decoder/Includes.hxx" +#include "Common/Includes.hxx" PClient::PClient( int Index ) { @@ -84,7 +43,89 @@ PClient::~PClient() } /// ****************************************************** -u16 PClient::GetUDP_ID() +bool PClient::GetDebugMode(PDebugMode nDebugID) +{ + return mDebugMode[nDebugID]; +} + +bool PClient::IsAcceptingNPCUpdates() +{ + return mAcceptNPCUpdates; +} + +void PClient::SetAcceptNPCUpdates(bool nVal) +{ + mAcceptNPCUpdates = nVal; +} + +bool PClient::IsZoning() +{ + return mZoning; +} + +void PClient::SetZoning(bool nVal) +{ + mZoning = nVal; + if (!nVal) + mVhcZoning = false; +} + +bool PClient::IsVhcZoning() +{ + return mVhcZoning; +} + +void PClient::SetVhcZoning(bool nVal) +{ + mVhcZoning = nVal; +} + +uint32_t PClient::GetIndex() const +{ + return mIndex; +} + +uint32_t PClient::GetID() const +{ + return mIndex; +} + +uint32_t PClient::GetLocalID() const +{ + return mIndex + 1; +} + +uint32_t PClient::GetCharID() const +{ + return mCharID; +} + +int PClient::GetRemoteUDPPort() const +{ + return mRemotePort; +} + +bool PClient::IsInRemoveActorMode() +{ + return mActorRemoveMode; +} + +void PClient::SetRemoveActorMode(bool nNewValue) +{ + mActorRemoveMode = nNewValue; +} + +void PClient::SetRemoteUDPPort(int port) +{ + mRemotePort = port; +} + +void PClient::SetCharID(int id) +{ + mCharID = id; +} + +uint16_t PClient::GetUDP_ID() { if ( m_UDPConnection ) return m_UDPConnection->GetUDP_ID(); @@ -109,7 +150,7 @@ void PClient::IncreaseUDP_ID() Console->Print( "%s Unable to increase UDP_ID, UDP ConnectionClass is not yet initialized!", Console->ColorText( RED, BLACK, "[WARNING]" ) ); } -u16 PClient::GetSessionID() +uint16_t PClient::GetSessionID() { if ( m_UDPConnection ) return m_UDPConnection->GetSessionID(); @@ -118,7 +159,7 @@ u16 PClient::GetSessionID() return 0; } -u16 PClient::GetTransactionID() +uint16_t PClient::GetTransactionID() { if ( m_UDPConnection ) return m_UDPConnection->GetTransactionID(); @@ -135,7 +176,7 @@ void PClient::ResetTransactionID() Console->Print( "%s Unable to reset UDP TransactionID, UDP ConnectionClass is not yet initialized!", Console->ColorText( RED, BLACK, "[WARNING]" ) ); } -void PClient::IncreaseTransactionID( u8 nInc ) +void PClient::IncreaseTransactionID( uint8_t nInc ) { if ( m_UDPConnection ) m_UDPConnection->IncreaseTransactionID( nInc ); @@ -145,7 +186,7 @@ void PClient::IncreaseTransactionID( u8 nInc ) void PClient::FillInUDP_ID( PMessage* nMessage ) { - u16 CurrPos; + uint16_t CurrPos; if (( nMessage->GetSize() > 9 ) && ( nMessage->U8Data( 0x00 ) == 0x13 ) ) { @@ -164,16 +205,46 @@ void PClient::FillInUDP_ID( PMessage* nMessage ) nMessage->U16Data( 0x03 ) = GetSessionID(); } -void PClient::FragmentAndSendUDPMessage( PMessage* nMessage, u8 nType ) +void PClient::setTCPConnection(ConnectionTCP *conn) +{ + m_TCPConnection = conn; + m_UDPConnection = nullptr; + mConnection = PCC_GAME; +} + +void PClient::setUDPConnection(ConnectionUDP *conn) +{ + m_UDPConnection = conn; +} + +ConnectionTCP *PClient::getTCPConn() +{ + return m_TCPConnection; +} + +ConnectionUDP *PClient::getUDPConn() +{ + return m_UDPConnection; +} + +void PClient::SendTCPMessage(PMessage *nMessage) +{ + if (m_TCPConnection) + m_TCPConnection->SendMessage(nMessage); + else + delete nMessage; +} + +void PClient::FragmentAndSendUDPMessage( PMessage* nMessage, uint8_t nType ) { PMessage* ChunkBuffer; PMessage* ChunkMsg; - const u16 ChunkSize = 220; - u16 StartIncUDPIDOnChunk = 0; - u16 IncludedHeaderSize = 0; + const uint16_t ChunkSize = 220; + uint16_t StartIncUDPIDOnChunk = 0; + uint16_t IncludedHeaderSize = 0; bool ReplaceFirstByte = false; - u8 ReplaceFirstByteValue = 0; - u16 MultiTriggeringSize = 0; + uint8_t ReplaceFirstByteValue = 0; + uint16_t MultiTriggeringSize = 0; switch ( nType ) { @@ -233,9 +304,9 @@ void PClient::FragmentAndSendUDPMessage( PMessage* nMessage, u8 nType ) nMessage->U8Data( IncludedHeaderSize ) = ReplaceFirstByteValue; } - u16 ChunksNum = ( nMessage->GetSize() - IncludedHeaderSize + ChunkSize - 1 ) / ChunkSize; + uint16_t ChunksNum = ( nMessage->GetSize() - IncludedHeaderSize + ChunkSize - 1 ) / ChunkSize; - for ( u16 ChunkID = 0; ChunkID < ChunksNum; ChunkID++ ) + for ( uint16_t ChunkID = 0; ChunkID < ChunksNum; ChunkID++ ) { ChunkBuffer = nMessage->GetChunk( IncludedHeaderSize, ChunkSize, ChunkID ); if ( ChunkBuffer == NULL ) @@ -250,16 +321,16 @@ void PClient::FragmentAndSendUDPMessage( PMessage* nMessage, u8 nType ) IncreaseUDP_ID(); } - *ChunkMsg << ( u8 )0x13; - *ChunkMsg << ( u16 )GetUDP_ID(); - *ChunkMsg << ( u16 )GetSessionID(); - *ChunkMsg << ( u8 )( 9 + ChunkBuffer->GetSize() ); - *ChunkMsg << ( u8 )0x03; - *ChunkMsg << ( u16 )GetUDP_ID(); - *ChunkMsg << ( u8 )0x07; // Fragmented - *ChunkMsg << ( u16 )ChunkID; - *ChunkMsg << ( u16 )ChunksNum; - *ChunkMsg << ( u8 )nType; + *ChunkMsg << ( uint8_t )0x13; + *ChunkMsg << ( uint16_t )GetUDP_ID(); + *ChunkMsg << ( uint16_t )GetSessionID(); + *ChunkMsg << ( uint8_t )( 9 + ChunkBuffer->GetSize() ); + *ChunkMsg << ( uint8_t )0x03; + *ChunkMsg << ( uint16_t )GetUDP_ID(); + *ChunkMsg << ( uint8_t )0x07; // Fragmented + *ChunkMsg << ( uint16_t )ChunkID; + *ChunkMsg << ( uint16_t )ChunksNum; + *ChunkMsg << ( uint8_t )nType; *ChunkMsg << *ChunkBuffer; delete ChunkBuffer; @@ -276,7 +347,13 @@ void PClient::FragmentAndSendUDPMessage( PMessage* nMessage, u8 nType ) } } -/// ****************************************************** +void PClient::SendUDPMessage(PMessage *nMessage, bool nVIP) +{ + if (m_UDPConnection) + m_UDPConnection->SendMessage(nMessage, nVIP); + else + delete nMessage; +} void PClient::SetDebugMode( PDebugMode nDebugID, bool nVal ) { @@ -289,7 +366,7 @@ void PClient::SetDebugMode( PDebugMode nDebugID, bool nVal ) mDebugMode[nDebugID] = nVal; } -bool PClient::ChangeCharLocation( u32 nLocation, bool DoForce ) +bool PClient::ChangeCharLocation( uint32_t nLocation, bool DoForce ) { if ( gDevDebug ) Console->Print( "%s PClient::ChangeCharLocation", Console->ColorText( CYAN, BLACK, "[DEBUG]" ) ); @@ -297,7 +374,7 @@ bool PClient::ChangeCharLocation( u32 nLocation, bool DoForce ) { mAcceptNPCUpdates = false; // Zone changed, reject NPC updates till initial NPC spawn PChar* tChar = GetChar(); - u32 CurrentLocation = tChar->GetLocation(); + uint32_t CurrentLocation = tChar->GetLocation(); if (( CurrentLocation == nLocation ) && !DoForce ) return true; @@ -321,8 +398,8 @@ bool PClient::ChangeCharLocation( u32 nLocation, bool DoForce ) if ( tChar->GetLocationLeased() ) { // TAke care of sitting chars - u32 ChairObjectId; - u8 tSeatId; + uint32_t ChairObjectId; + uint8_t tSeatId; PSeatType tSeatType; if (( tSeatType = tChar->GetSeatInUse( &ChairObjectId, &tSeatId ) ) ) { @@ -330,7 +407,7 @@ bool PClient::ChangeCharLocation( u32 nLocation, bool DoForce ) PSpawnedVehicle* tVhc = 0; if ( (tSeatType == seat_vhc) && IsVhcZoning() ) // If seat is vhc, { // Do additionnal check - if (( tVhc = nWorld->GetSpawnedVehicules()->GetVehicle( ChairObjectId ) ) ) + if (( tVhc = nWorld->GetSpawnedVehicles()->GetVehicle( ChairObjectId ) ) ) { if ( tVhc->GetSeatUser( tSeatId ) == tChar->GetID() ) { @@ -367,6 +444,26 @@ bool PClient::ChangeCharLocation( u32 nLocation, bool DoForce ) return false; } +int PClient::GetConnection() const +{ + return mConnection; +} + +const char *PClient::GetAddress() const +{ + return m_TCPConnection->getRemoteAddress(); +} + +uint32_t PClient::GetAccountID() const +{ + return mAccountID; +} + +int PClient::GetAccountLevel() const +{ + return mAccountLevel; +} + void PClient::GameDisconnect() { mAccountID = 0; @@ -398,8 +495,8 @@ void PClient::GameDisconnect() } /* // replaced by the lines above PSeatType cSeatType; - u32 cSeatObjectId; - u8 cSeatId; + uint32_t cSeatObjectId; + uint8_t cSeatId; PWorld* cWorld; cWorld = Worlds->GetWorld(tChar->GetLocation()); @@ -418,7 +515,7 @@ void PClient::GameDisconnect() } else if(cSeatType == seat_vhc) { - cWorld->GetSpawnedVehicules()->GetVehicle(cSeatObjectId)->UnsetSeatUser(cSeatId, GetLocalID()); + cWorld->GetSpawnedVehicles()->GetVehicle(cSeatObjectId)->UnsetSeatUser(cSeatId, GetLocalID()); tChar->SetSeatInUse(seat_none); } else @@ -475,6 +572,11 @@ void PClient::RefreshAccountInfo( PAccount *Account ) mAccountLevel = Account->GetLevel(); } +void PClient::LoggedIn(PAccount *Account) +{ + RefreshAccountInfo(Account); +} + void PClient::Update() { if ( m_TCPConnection ) @@ -522,7 +624,20 @@ PChar* PClient::GetChar() const } } -bool PClient::GetCharAwaitingWarpto( u16* PosX, u16* PosY, u16* PosZ ) +int PClient::getZoneID() const +{ + return m_ZoneID; +} + +void PClient::SetAwaitingWarpto(bool yesno, uint16_t NewX, uint16_t NewY, uint16_t NewZ) +{ + mAwaitingWarpto = yesno; + mTargetX = NewX; + mTargetY = NewY; + mTargetZ = NewZ; +} + +bool PClient::GetCharAwaitingWarpto( uint16_t* PosX, uint16_t* PosY, uint16_t* PosZ ) { if ( PosX ) *PosX = mTargetX; diff --git a/TinNS/Source/GameServer/Client.hxx b/TinNS/Source/GameServer/Client.hxx new file mode 100644 index 0000000..3dbcf57 --- /dev/null +++ b/TinNS/Source/GameServer/Client.hxx @@ -0,0 +1,172 @@ +#pragma once + +#include + +class ConnectionTCP; +class ConnectionUDP; +class PMessage; + +// TODO: - check that SetUDP_ID, and the mSessionID(UDP_ID_HIGH) real use, +// and if UDP_ID and mSessionID must be synced (like in NeoX) or not + +enum PClientConnection +{ + PCC_NONE = 0, + PCC_GAME = 1 +}; + +// AccountLevel handling is part of accounts.cpp +/* +enum PClientLevel +{ + PCL_BANNED = -1, + PCL_UNREGPLAYER = 0, + PCL_REGPLAYER = 1, + PCL_VOLUNTEER = 30, + PCL_GM = 50, + PCL_ADMIN = 100 +}; +*/ +#define DEBUG_MODES 3 +enum PDebugMode +{ + DBG_LOCATION = 0, + DBG_ITEMID = 1, + DBG_SUBWAY = 2, + DBG_ALL = DEBUG_MODES // must always be last, with DEBUG_MODES updated as needed +}; + + +class PClient +{ + private : + ConnectionTCP* m_TCPConnection; + ConnectionUDP* m_UDPConnection; + + uint32_t mAccountID; + int mAccountLevel; + uint32_t mIndex; + uint32_t mCharID; + +// uint16_t mUDP_ID; +// uint16_t mSessionID; +// uint16_t mTransactionID; + + // AccountLevel handling is part of accounts.cpp + //PClientLevel mLevel; + int mConnection; + int mRemotePort; + + bool mDebugMode[DEBUG_MODES]; + // new multiuser-chat implementation // + int m_ZoneID; + //int[4] m_IP; + + //******* + bool mActorRemoveMode; + //******* + bool mAwaitingWarpto; + uint16_t mTargetX; + uint16_t mTargetY; + uint16_t mTargetZ; + //******* + bool mAcceptNPCUpdates; + bool mZoning; + bool mVhcZoning; + + public : + PClient( int Index ); + ~PClient(); + + bool GetDebugMode(PDebugMode nDebugID); + void SetDebugMode(PDebugMode nDebugID, bool nVal = true); + + bool IsAcceptingNPCUpdates(); + void SetAcceptNPCUpdates(bool nVal); + bool IsZoning(); + void SetZoning(bool nVal = true); + bool IsVhcZoning(); + void SetVhcZoning(bool nVal = true); + + uint32_t GetIndex() const; // better use GetID() + uint32_t GetID() const; // for better coherency with other classes + uint32_t GetLocalID() const; + uint32_t GetCharID() const; + PChar* GetChar() const; + bool ChangeCharLocation(uint32_t nLocation, bool DoForce = false); + + int GetRemoteUDPPort() const; // Temp solution + + bool IsInRemoveActorMode(); + void SetRemoveActorMode(bool nNewValue); + + void SetRemoteUDPPort(int port); // Temp solution + void SetCharID(int id);//NEW added + + /* + inline uint16_t GetUDP_ID() const { return mUDP_ID; } + inline uint16_t GetSessionID() const { return SESSION_UDP_OFFSET + mUDP_ID ; } + inline uint16_t GetTransactionID() {return mTransactionID; } + void SetUDP_ID(int id); + inline void IncreaseUDP_ID() { SetUDP_ID(mUDP_ID + 1); } + inline void ResetTransactionID() { mTransactionID = 10170; } + + inline void IncreaseTransactionID(uint8_t nInc = 1) { mTransactionID += nInc; } + */ + + // All outgoing ID's and stuff is now part of the ConnectionUDP class itself! + // (which is not so good.... comment from Hammag) + // However, we still have full access to it through these functions + uint16_t GetUDP_ID(); + void SetUDP_ID( int id ); + void IncreaseUDP_ID(); + + uint16_t GetSessionID(); + + uint16_t GetTransactionID(); + void ResetTransactionID(); + void IncreaseTransactionID( uint8_t nInc = 1 ); + + void FillInUDP_ID( PMessage* nMessage ); + +// ************************************************************************ // + // AccountLevel handling is part of accounts.cpp + //inline PClientLevel GetLevel() const { return mLevel; } + + void setTCPConnection(ConnectionTCP *conn); + void setUDPConnection(ConnectionUDP *conn); + + ConnectionTCP* getTCPConn(); + ConnectionUDP* getUDPConn(); + + void SendTCPMessage(PMessage *nMessage); + void FragmentAndSendUDPMessage( PMessage* nMessage, uint8_t nType ); + void SendUDPMessage(PMessage *nMessage, bool nVIP = false); + + int GetConnection() const; + const char *GetAddress() const; + uint32_t GetAccountID() const; + int GetAccountLevel() const; + + void GameDisconnect(); + + void RefreshAccountInfo(PAccount *Account); + void LoggedIn(PAccount *Account); + void Update(); + + // new multiuser-chat implementation // + int getZoneID() const; + //inline int* getIP() const { return (int*) m_IP; } + + void SetAwaitingWarpto(bool yesno, uint16_t NewX, uint16_t NewY, uint16_t NewZ); + bool GetCharAwaitingWarpto(uint16_t* PosX = NULL, uint16_t* PosY = NULL, uint16_t* PosZ = NULL); + + // Char broadcasted effects + void InitWarpCircle(); + void InitCharVanish(); + + // used for dynamic ingame testing + uint8_t testval8; + uint16_t testval16; + uint32_t testval32; +}; diff --git a/server/src/game/clientmanager.cpp b/TinNS/Source/GameServer/ClientManager.cxx similarity index 68% rename from server/src/game/clientmanager.cpp rename to TinNS/Source/GameServer/ClientManager.cxx index 9f3cf73..efe902a 100644 --- a/server/src/game/clientmanager.cpp +++ b/TinNS/Source/GameServer/ClientManager.cxx @@ -1,59 +1,7 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - client.cpp - - Authors: - - bakkdoor - - Akiko - - MODIFIED: 13 Dec 2005 bakkdoor - REASON: - introduced - MODIFIED: 29 Jul 2006 Hammag - REASON: - Added UDP broadcast fonction - - Added "zone players say Hello" fonction - - Modified the ID used as would should avoid muliplying the IDs for the same client. - Now using Client.GetLocalID() as the key (=Client.mIndex + 1) which is used in NC protocol - - Modified getClientByID() - - Removed getClientID(). Simply do Client->GetLocalID() - - Modified deleteClientFromListByID() and renamed to deleteClientFromList() - - Modified destructor as to not destroy stored clients, which is already done in PServer - (even if it could well be done here in near futur) - - MODIFIED: 12 Aug 2006 Hammag - REASON: - implemented range filtering in UDPBroadcast() - - implemented the two versions of UDPBroadcast() - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem - - clean ups - - TODO: - these are just begining of modif, as the Client Manager is bound to be a major component for multiplayer management -*/ - -#include "main.h" - -#include "include/msgbuilder.h" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" + +// TODO: - these are just begining of modif, as the Client Manager is bound to be a major component for multiplayer management PClientManager::PClientManager() { @@ -95,7 +43,7 @@ bool PClientManager::addClientToList( PClient* newClient ) } // Check if a zone is in use -bool PClientManager::IsWorldInUse( u32 nWorldID ) const +bool PClientManager::IsWorldInUse( uint32_t nWorldID ) const { for ( PClientMap::const_iterator it = mClientList.begin(); it != mClientList.end(); it++ ) { @@ -109,7 +57,7 @@ bool PClientManager::IsWorldInUse( u32 nWorldID ) const } // Check if a rawObjectId belongs to a char is in use -PClient* PClientManager::GetClientByCharLocalId( u32 rawObjectId, u32 nWorldID ) const +PClient* PClientManager::GetClientByCharLocalId( uint32_t rawObjectId, uint32_t nWorldID ) const { PClient* nClient; for ( PClientMap::const_iterator it = mClientList.begin(); it != mClientList.end(); it++ ) @@ -124,7 +72,7 @@ PClient* PClientManager::GetClientByCharLocalId( u32 rawObjectId, u32 nWorldID ) return 0; } -void PClientManager::deleteClientFromList( u32 id ) +void PClientManager::deleteClientFromList( uint32_t id ) { PClientMap::iterator it = mClientList.find( id ); if ( it != mClientList.end() ) @@ -151,13 +99,13 @@ void PClientManager::deleteClientFromList( u32 id ) return false; } */ -PClient* PClientManager::getClientByID( u32 id ) const +PClient* PClientManager::getClientByID( uint32_t id ) const { PClientMap::const_iterator it = mClientList.find( id ); return (( it != mClientList.end() ) ? ( PClient* )( it->second ) : NULL ); } -PClient* PClientManager::getClientByChar( u32 CharID ) const +PClient* PClientManager::getClientByChar( uint32_t CharID ) const { for ( PClientMap::const_iterator it = mClientList.begin(); it != mClientList.end(); it++ ) { @@ -183,7 +131,7 @@ PClient* PClientManager::getClientByChar( const std::string &Name ) const return NULL; } -/* u32 PClientManager::getClientID(PClient* _client) +/* uint32_t PClientManager::getClientID(PClient* _client) { for(PClientMap::iterator it=mClientList.begin(); it!=mClientList

.end(); it++) { @@ -197,13 +145,13 @@ PClient* PClientManager::getClientByChar( const std::string &Name ) const } */ // Distance checking doesn't care for Z axis ATM -int PClientManager::UDPBroadcast( PMessage* nMessage, u32 nZoneID, u16 nX, u16 nY, u16 nZ, u16 nMaxDist, u32 nSkipCharId, bool nNPCPing ) +int PClientManager::UDPBroadcast( PMessage* nMessage, uint32_t nZoneID, uint16_t nX, uint16_t nY, uint16_t nZ, uint16_t nMaxDist, uint32_t nSkipCharId, bool nNPCPing ) { int msgCount = 0; PChar* nChar; PMessage* tmpMsg; PClient* itClient; - u16 Dapprox; + uint16_t Dapprox; for ( PClientMap::iterator it = mClientList.begin(); it != mClientList.end(); it++ ) { @@ -244,10 +192,10 @@ int PClientManager::UDPBroadcast( PMessage* nMessage, u32 nZoneID, u16 nX, u16 n return msgCount; } -int PClientManager::UDPBroadcast( PMessage* nMessage, PClient* nClient, u16 nMaxDist, bool nSkipSource, bool nNPCPing ) +int PClientManager::UDPBroadcast( PMessage* nMessage, PClient* nClient, uint16_t nMaxDist, bool nSkipSource, bool nNPCPing ) { PChar* nChar; - u32 skipCharId = nSkipSource ? nClient->GetCharID() : 0 ; + uint32_t skipCharId = nSkipSource ? nClient->GetCharID() : 0 ; if ( nClient && ( nChar = nClient->GetChar() ) ) { @@ -266,7 +214,7 @@ int PClientManager::SendUDPZoneWelcomeToClient( PClient* nClient ) PChar* nChar; PChar* itChar; PMessage* tmpMsg; - u32 nZoneID; + uint32_t nZoneID; PClient* itClient; if ( nClient && ( nChar = nClient->GetChar() ) ) // if nClient is set, always use its zone diff --git a/TinNS/Source/GameServer/ClientManager.hxx b/TinNS/Source/GameServer/ClientManager.hxx new file mode 100644 index 0000000..71eb2db --- /dev/null +++ b/TinNS/Source/GameServer/ClientManager.hxx @@ -0,0 +1,35 @@ +#pragma once + +#include +#include + +typedef std::map PClientMap; + +class PClientManager { +private: + //int mLastID; + PClientMap mClientList; + +public: + PClientManager(); + ~PClientManager(); + + PClientMap::iterator getClientListBegin() { return mClientList.begin(); } + PClientMap::iterator getClientListEnd() { return mClientList.end(); } + + bool addClientToList( PClient* newClient ); + //void deleteClientFromListByID(int id); + void deleteClientFromList( uint32_t id ); + //bool deleteClientFromList(PClient* delClient); // maybe no use for this... + PClient* getClientByID( uint32_t uint32_t ) const; // returns pointer to a client for further use + PClient* getClientByChar( uint32_t CharID ) const; + PClient* getClientByChar( const std::string &Name ) const; + // int getClientID(PClient* _client); do _client->GetLocalID() + bool IsWorldInUse( uint32_t nWorldID ) const; // Temp until world content fully managed by world + PClient* GetClientByCharLocalId( uint32_t rawObjectId, uint32_t nWorldID ) const; // Temp (called by world) until world content fuly managed by world + + // each function return the number of messages sent. + int UDPBroadcast( PMessage* nMessage, uint32_t nZoneID, uint16_t nX = 0, uint16_t nY = 0, uint16_t nZ = 0, uint16_t nMaxDist = 0, uint32_t nSkipCharId = 0, bool nNPCPing = false ); + int UDPBroadcast( PMessage* nMessage, PClient* nClient, uint16_t nMaxDist = 0, bool nSkipSource = false, bool nNPCPing = false ); + int SendUDPZoneWelcomeToClient( PClient* nClient ); +}; diff --git a/server/src/game/commands.cpp b/TinNS/Source/GameServer/Commands.cxx similarity index 88% rename from server/src/game/commands.cpp rename to TinNS/Source/GameServer/Commands.cxx index 7dc907d..0d6c973 100644 --- a/server/src/game/commands.cpp +++ b/TinNS/Source/GameServer/Commands.cxx @@ -1,46 +1,6 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - commands.cpp - handles ingame commands (@) - - Authors: - - Namikon - - bakkdoor - - Hammag - - - File rewritten on 20th Dec 2006 by Namikon - Note: Later, when we add multithread support to tinns, the FlushArgs() functions - have to be placed ONLY in con/destructor and nowhere else. - Besides that, no global GameCommands, we should do that with tmpCmd = new PCommands; -*/ -#include "main.h" - -#include "include/client.h" -#include "include/msgbuilder.h" -#include "include/worlds.h" -#include "include/worldactors.h" +#include +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" PCommands::PCommands() { @@ -103,38 +63,38 @@ void PCommands::HandleGameCommand(char *packet, PClient *Client) } // ok, we have the command, now read the args - // Loop till entire chatpacket is parsed or MAXARGS is reached + // Loop till entire chatpacket is parsed or MAXARGS is reached bool tEncapsedString = false; while (packet[posPacket] != '\0' && ArgC <= MAXARGS) { // First set tmpPos for next Arg to 0 tmpPos = 0; - - // Now loop until next space ' ' or end '\0' is reached - // Added extraction of encapsulated strings "test 123 123" + + // Now loop until next space ' ' or end '\0' is reached + // Added extraction of encapsulated strings "test 123 123" while (packet[posPacket] != ' ' || tEncapsedString == true) - { - // Watch out for >"< - if(packet[posPacket] == '"') - tEncapsedString = !tEncapsedString; - else - { - // Copy arg from chatpacket to final arg var - ArgV[ArgC][tmpPos] = packet[posPacket]; - tmpPos++; - } - // Increment tmpPos and posPacket - posPacket++; - if(packet[posPacket] == '\0') - break; + { + // Watch out for >"< + if(packet[posPacket] == '"') + tEncapsedString = !tEncapsedString; + else + { + // Copy arg from chatpacket to final arg var + ArgV[ArgC][tmpPos] = packet[posPacket]; + tmpPos++; + } + // Increment tmpPos and posPacket + posPacket++; + if(packet[posPacket] == '\0') + break; } - tEncapsedString = false; + tEncapsedString = false; // Reached either the end of packet or an whitespace // Terminate current ArgV ArgV[ArgC][tmpPos] = '\0'; - // Heh, we got one! Now more to next arg - ArgC++; + // Heh, we got one! Now more to next arg + ArgC++; // Search next arg (Maybe someone typed more than one whitespace) while (packet[posPacket] == ' ' && packet[posPacket] != '\0') @@ -318,15 +278,15 @@ void PCommands::HandleGameCommand(char *packet, PClient *Client) else if (strcmp(Command, "setsubskill") == 0) { doCmdSetSubSkill(); - } - else if (strcmp(Command, "npc") == 0) - { - doNPC(); - } - else if (strcmp(Command, "npcshop") == 0) - { - doNPC_Shop(); - } + } + else if (strcmp(Command, "npc") == 0) + { + doNPC(); + } + else if (strcmp(Command, "npcshop") == 0) + { + doNPC_Shop(); + } // Else: unknown command. Ignore } diff --git a/server/src/game/include/commands.h b/TinNS/Source/GameServer/Commands.hxx similarity index 73% rename from server/src/game/include/commands.h rename to TinNS/Source/GameServer/Commands.hxx index 16b6ced..e06d88e 100644 --- a/server/src/game/include/commands.h +++ b/TinNS/Source/GameServer/Commands.hxx @@ -1,41 +1,5 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko +#pragma once - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - commands.h - - Authors: - - Namikon - - MODIFIED: 11 Dec 2005 Namikon - REASON: - initial release - MODIFIED: 15 Dec 2005 Namikon - REASON: - Added SendRawFile(...) - -*/ - -#ifndef COMMANDS_H -#define COMMANDS_H #define MAXARGS 10 // Define the max nr. of args here. Should never be more than 4, but who knows... #define MAXDUMBSIZE 256 // Max size of packetdumb @@ -123,4 +87,3 @@ public: void HandleGameCommand(char *packet, PClient *Client); }; -#endif diff --git a/server/src/game/configtemplate.h b/TinNS/Source/GameServer/ConfigTemplate.hxx similarity index 75% rename from server/src/game/configtemplate.h rename to TinNS/Source/GameServer/ConfigTemplate.hxx index 00772a0..03aed73 100644 --- a/server/src/game/configtemplate.h +++ b/TinNS/Source/GameServer/ConfigTemplate.hxx @@ -1,38 +1,10 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ +#pragma once /* - Configuration template for gameserver - Used to set available/optional/required options when loading config - with a PConfig object. - - MODIFIED: 28 Sep 2006 Hammag - REASON: - added worlds_path entry - MODIFIED: 02 Oct 2006 Hammag - REASON: - added dev_debug entry - TODO: put a single data_directory entry as the root directory for all NC data - */ -const char* GameConfigTemplate[][2] = { +static const char *GameConfigTemplate[][2] = { // {option_name, default_value} if default_value is empty string, it means option is mandatory // List ends with empty string for option_name {"info_sql_host", "127.0.0.1"}, @@ -79,7 +51,7 @@ const char* GameConfigTemplate[][2] = { {"password_filter", "^[[:graph:]]{3,15}$"}, {"charname_filter", "^[a-z]+([\\-\\ ]?[a-z]+){0,2}$"}, {"clanname_filter", "^[a-z][\\w\\-\\ ]{2,14}$"}, - + // For futur use: // {"max_chars_per_account", "4"}, // {"multiple_logins_per_account", "0"}, // 0=nobody, 1=gm+ only, 2=everybody @@ -90,7 +62,7 @@ const char* GameConfigTemplate[][2] = { {"", ""} // do not change this line (end mark) }; -const char* CommandsTemplate[][2] = { +static const char *CommandsTemplate[][2] = { {"debug", "100"}, {"settime", "100"}, {"warp", "0"}, diff --git a/server/src/game/container.cpp b/TinNS/Source/GameServer/Container.cxx similarity index 79% rename from server/src/game/container.cpp rename to TinNS/Source/GameServer/Container.cxx index 00f03fe..aa60f3c 100644 --- a/server/src/game/container.cpp +++ b/TinNS/Source/GameServer/Container.cxx @@ -1,43 +1,10 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - container.cpp - base classe for containers - - MODIFIED: 28 Jul 2008 Hammag - REASON: - creation - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem - - clean ups -*/ - -#include "main.h" - -#include "include/item.h" -#include "include/container.h" +#include "GameServer/Includes.hxx" +#include "GameServer/Definitions/Includes.hxx" +#include "Common/Includes.hxx" /* --- PContainerEntry class --- */ -PContainerEntry::PContainerEntry( PItem* nItem, u8 X, u8 Y, u32 nInvID, bool SetDirty ) +PContainerEntry::PContainerEntry( PItem* nItem, uint8_t X, uint8_t Y, uint32_t nInvID, bool SetDirty ) { mItem = nItem; mPosX = X; @@ -54,15 +21,15 @@ PContainerEntry::PContainerEntry( MYSQL_ROW row ) mPosY = atoi( row[i_y] ); mDirtyFlag = false; - u32 nItemID = atoi( row[i_itemid] ); - u8 nStackSize = atoi( row[i_qty] ); + uint32_t nItemID = atoi( row[i_itemid] ); + uint8_t nStackSize = atoi( row[i_qty] ); // = std::atoi(row[i_type]); - u8 CurDur = atoi( row[i_curdur] ); - u8 Dmg = atoi( row[i_dmg] ); - u8 Freq = atoi( row[i_freq] ); - u8 Hand = atoi( row[i_hand] ); - u8 Rng = atoi( row[i_rng] ); - u8 Dur = atoi( row[i_maxdur] ); + uint8_t CurDur = atoi( row[i_curdur] ); + uint8_t Dmg = atoi( row[i_dmg] ); + uint8_t Freq = atoi( row[i_freq] ); + uint8_t Hand = atoi( row[i_hand] ); + uint8_t Rng = atoi( row[i_rng] ); + uint8_t Dur = atoi( row[i_maxdur] ); mItem = new PItem( nItemID, nStackSize, CurDur, Dur, Dmg, Freq, Hand, Rng ); } @@ -72,7 +39,7 @@ PContainerEntry::~PContainerEntry() delete mItem; } -bool PContainerEntry::SQLSave( u32 CharID, u32 InvLoc ) +bool PContainerEntry::SQLSave( uint32_t CharID, uint32_t InvLoc ) { std::string query, queryv; @@ -156,7 +123,7 @@ bool PContainerEntry::SQLDelete() /* --- PContainer class --- */ -PContainer::PContainer( u8 nMaxSlots ) +PContainer::PContainer( uint8_t nMaxSlots ) { mMaxSlots = ( nMaxSlots > CONTAINER_MAX_SIZE ? CONTAINER_MAX_SIZE : nMaxSlots ) ; if ( mMaxSlots ) @@ -171,18 +138,18 @@ PContainer::PContainer( u8 nMaxSlots ) PContainer::~PContainer() { - for ( u8 i = 0; i < mContContent->size(); ++i ) + for ( uint8_t i = 0; i < mContContent->size(); ++i ) delete mContContent->at( i ); if ( mExclusiveUseCharID ) Console->Print( RED, BLACK, "[ERROR] PContainer::~PContainer: Char %d still has exclusive access to container !!! Bad Pointer error will happen.", mExclusiveUseCharID ); } -bool PContainer::AddEntry( PContainerEntry* NewEntry, u8 nSlotId ) +bool PContainer::AddEntry( PContainerEntry* NewEntry, uint8_t nSlotId ) { if ( IsSlotAllowed( nSlotId ) ) { - for ( u8 i = mContContent->size(); i <= nSlotId; ++i ) // Extend as needed + for ( uint8_t i = mContContent->size(); i <= nSlotId; ++i ) // Extend as needed mContContent->push_back( static_cast(NULL) ); if ( mContContent->at( nSlotId ) ) { @@ -206,14 +173,14 @@ bool PContainer::AddEntry( PContainerEntry* NewEntry, u8 nSlotId ) --- --- */ } -void PContainer::SetEntryPosXY( PContainerEntry* nEntry, u8 nSlotId, u8 nPosX, u8 nPosY ) +void PContainer::SetEntryPosXY( PContainerEntry* nEntry, uint8_t nSlotId, uint8_t nPosX, uint8_t nPosY ) { nPosX = nPosY; nEntry->Set2DPos( nSlotId, 0 ); mDirtyFlag = mDirtyFlag || nEntry->mDirtyFlag; } -PContainerEntry* PContainer::RemoveEntry( u8 nSlotId ) +PContainerEntry* PContainer::RemoveEntry( uint8_t nSlotId ) { PContainerEntry* tEntry = NULL; @@ -225,14 +192,14 @@ PContainerEntry* PContainer::RemoveEntry( u8 nSlotId ) return tEntry; } -bool PContainer::GetFreeSlot( u8* nSlotId ) +bool PContainer::GetFreeSlot( uint8_t* nSlotId ) { return IsSlotFree( *nSlotId ); } -void PContainer::Compact( u8 startSlotId ) +void PContainer::Compact( uint8_t startSlotId ) { - u8 i, j; + uint8_t i, j; PContainerEntry* tEntry; for ( i = j = startSlotId; i < mContContent->size(); ++i ) @@ -257,7 +224,7 @@ void PContainer::Compact( u8 startSlotId ) } } -bool PContainer::StartUse( u32 nExclusiveUseCharID ) +bool PContainer::StartUse( uint32_t nExclusiveUseCharID ) { if ( mExclusiveUseCharID ) return false; @@ -268,7 +235,7 @@ bool PContainer::StartUse( u32 nExclusiveUseCharID ) } } -bool PContainer::EndUse( u32 nExclusiveUseCharID ) +bool PContainer::EndUse( uint32_t nExclusiveUseCharID ) { if ( nExclusiveUseCharID == mExclusiveUseCharID ) { @@ -294,8 +261,8 @@ bool PContainer::SQLLoad() char query[1024]; PContainerEntry* NewEntry; bool SaveDirtyFlag; - u8 nSlotId; - //u8 nPosX, nPosY, nSizeX, nSizeY; + uint8_t nSlotId; + //uint8_t nPosX, nPosY, nSizeX, nSizeY; /*if (!mContContent.empty()) { @@ -350,7 +317,7 @@ bool PContainer::SQLSave() PContainerEntry* ContEntry; bool SavedOK = true; - for ( u8 i = 0; i < mContContent->size(); ++i ) + for ( uint8_t i = 0; i < mContContent->size(); ++i ) { if (( ContEntry = mContContent->at( i ) ) ) { @@ -368,7 +335,7 @@ bool PContainer::SQLSave() return SavedOK; } -bool PContainer::IsSlotFree( u8 nSlotId ) +bool PContainer::IsSlotFree( uint8_t nSlotId ) { if ( !IsSlotAllowed( nSlotId ) ) return false; @@ -379,7 +346,7 @@ bool PContainer::IsSlotFree( u8 nSlotId ) return !( mContContent->at( nSlotId ) ); } -bool PContainer::AddItem( PItem* NewItem, u32 nInvID, u8 nPosX, u8 nPosY, bool SetDirty ) +bool PContainer::AddItem( PItem* NewItem, uint32_t nInvID, uint8_t nPosX, uint8_t nPosY, bool SetDirty ) { /* --- auto stacking not implemented yet 1 - if stackable, check if same item(S) exists @@ -409,13 +376,13 @@ bool PContainer::AddItem( PItem* NewItem, u32 nInvID, u8 nPosX, u8 nPosY, bool S } } -bool PContainer::MoveItem( u8 srcSlotId, u8 nCount, PContainer* dstContainer, u8 dstSlotId, u8 nPosX, u8 nPosY ) +bool PContainer::MoveItem( uint8_t srcSlotId, uint8_t nCount, PContainer* dstContainer, uint8_t dstSlotId, uint8_t nPosX, uint8_t nPosY ) { if ( dstContainer == this ) return this->MoveItem( srcSlotId, nCount, dstSlotId ); else if ( dstContainer->GetFreeSlot( &dstSlotId ) ) { - u8 savePosX, savePosY; + uint8_t savePosX, savePosY; PContainerEntry* tEntry = this->GetEntry( srcSlotId ); if ( tEntry ) { @@ -455,7 +422,7 @@ bool PContainer::MoveItem( u8 srcSlotId, u8 nCount, PContainer* dstContainer, u8 } // !!! Not partial move yet !!! -bool PContainer::MoveItem( u8 srcSlotId, u8 nCount, u8 dstSlotId ) +bool PContainer::MoveItem( uint8_t srcSlotId, uint8_t nCount, uint8_t dstSlotId ) { if ( !( IsSlotAllowed( srcSlotId ) && IsSlotAllowed( dstSlotId ) ) ) return false; @@ -483,7 +450,7 @@ std::vector< PContainerEntry* >* PContainer::GetEntries() { std::vector< PContainerEntry* >* Entries = new std::vector< PContainerEntry* >; - for ( u8 i = 0; i < mContContent->size(); ++i ) + for ( uint8_t i = 0; i < mContContent->size(); ++i ) { if ( mContContent->at( i ) ) Entries->push_back( mContContent->at( i ) ); @@ -492,7 +459,7 @@ std::vector< PContainerEntry* >* PContainer::GetEntries() return Entries; } -PContainerEntry* PContainer::GetEntry( u8 nSlotId ) +PContainerEntry* PContainer::GetEntry( uint8_t nSlotId ) { if ( nSlotId >= mContContent->size() ) return NULL; @@ -500,18 +467,18 @@ PContainerEntry* PContainer::GetEntry( u8 nSlotId ) return mContContent->at( nSlotId ); } -PItem* PContainer::GetItem( u8 nSlotId ) +PItem* PContainer::GetItem( uint8_t nSlotId ) { PContainerEntry* tEntry = this->GetEntry( nSlotId ); return ( tEntry ? tEntry->mItem : NULL ); } -u8 PContainer::RandomFill( u8 nItemCount, int nItemContainerDefIndex ) +uint8_t PContainer::RandomFill( uint8_t nItemCount, int nItemContainerDefIndex ) { PItem* nItem = NULL; const PDefItems* nItemDef; - u32 nItemSeqId; - u8 CreatedCount = 0; + uint32_t nItemSeqId; + uint8_t CreatedCount = 0; if ( !nItemCount ) nItemCount = mMaxSlots; @@ -521,18 +488,18 @@ u8 PContainer::RandomFill( u8 nItemCount, int nItemContainerDefIndex ) if ( nItemContainerDefIndex >= 0 ) { int newItemIdx, newItemIndex; - u8 newItemQuality; + uint8_t newItemQuality; const PDefItemContainer* containerDef = GameDefs->ItemContainers()->GetDef( nItemContainerDefIndex ); if ( containerDef ) { - for ( u8 i = 0; i < nItemCount; ++i ) + for ( uint8_t i = 0; i < nItemCount; ++i ) { newItemIdx = containerDef->GetRandomItemIdx(); if ( newItemIdx >= 0 ) { newItemIndex = containerDef->GetItemId( newItemIdx ); - newItemQuality = ( u8 )( 255 & int( 255.0 * containerDef->GetQuality( newItemIdx ) ) ); + newItemQuality = ( uint8_t )( 255 & int( 255.0 * containerDef->GetQuality( newItemIdx ) ) ); if ( newItemIndex <= 0 ) // Item group { newItemIndex = GameDefs->Items()->GetRandomItemIdFromGroup( -newItemIndex ); @@ -560,7 +527,7 @@ u8 PContainer::RandomFill( u8 nItemCount, int nItemContainerDefIndex ) { int NumItemsDefs = GameDefs->Items()->GetNumDefs(); - for ( u8 i = 0; i < nItemCount; ++i ) + for ( uint8_t i = 0; i < nItemCount; ++i ) { nItemSeqId = GetRandom( NumItemsDefs, 1 ); @@ -591,8 +558,8 @@ void PContainer::Dump() { PContainerEntry* tmpEntry; PItem* tmpItem; - u8 i; - //u8 y, x; + uint8_t i; + //uint8_t y, x; for ( i = 0; i < mContContent->size(); ++i ) { @@ -612,7 +579,7 @@ void PContainer::Dump() /* --- PContainerAutoCompact --- */ -PContainerEntry* PContainerAutoCompact::RemoveEntry( u8 nSlotId ) +PContainerEntry* PContainerAutoCompact::RemoveEntry( uint8_t nSlotId ) { PContainerEntry* tEntry = NULL; @@ -628,7 +595,7 @@ PContainerEntry* PContainerAutoCompact::RemoveEntry( u8 nSlotId ) return tEntry; } -bool PContainerAutoCompact::GetFreeSlot( u8* nSlotId ) // not optimal. A "first free from end" would be better at PContainer level +bool PContainerAutoCompact::GetFreeSlot( uint8_t* nSlotId ) // not optimal. A "first free from end" would be better at PContainer level { bool Found = false; @@ -641,7 +608,7 @@ bool PContainerAutoCompact::GetFreeSlot( u8* nSlotId ) // not optimal. A "first return ( Found || IsSlotAllowed( *nSlotId ) ); } -bool PContainerAutoCompact::MoveItem( u8 srcSlotId, u8 nCount, u8 dstSlotId ) +bool PContainerAutoCompact::MoveItem( uint8_t srcSlotId, uint8_t nCount, uint8_t dstSlotId ) { srcSlotId = nCount = dstSlotId; return false; @@ -649,7 +616,7 @@ bool PContainerAutoCompact::MoveItem( u8 srcSlotId, u8 nCount, u8 dstSlotId ) /* --- PContainer2D class --- */ -void PContainer2D::SetEntryPosXY( PContainerEntry* nEntry, u8 nSlotId, u8 nPosX, u8 nPosY ) +void PContainer2D::SetEntryPosXY( PContainerEntry* nEntry, uint8_t nSlotId, uint8_t nPosX, uint8_t nPosY ) { nSlotId = nSlotId; if (( nPosX >= INV_BACKPACK_COLS ) || ( nPosY == 255 ) ) @@ -662,7 +629,7 @@ void PContainer2D::SetEntryPosXY( PContainerEntry* nEntry, u8 nSlotId, u8 nPosX, /* --- PContainer2DWorkaround --- */ ///// -PContainer2DWorkaround::PContainer2DWorkaround( u8 nMaxSlots ) : PContainerWithHoles( nMaxSlots ) +PContainer2DWorkaround::PContainer2DWorkaround( uint8_t nMaxSlots ) : PContainerWithHoles( nMaxSlots ) { nMaxSlots = nMaxSlots; mNextFreeSlot = 0; @@ -678,13 +645,13 @@ PContainer2DWorkaround::~PContainer2DWorkaround() delete mContSpace[i]; } -bool PContainer2DWorkaround::AddEntry( PContainerEntry* tEntry, u8 nSlotId ) +bool PContainer2DWorkaround::AddEntry( PContainerEntry* tEntry, uint8_t nSlotId ) { if ( IsSlotAllowed( nSlotId ) ) { if ( FindValid2DPos( tEntry ) ) { - for ( u8 i = mContContent->size(); i <= nSlotId; ++i ) // Extend as needed + for ( uint8_t i = mContContent->size(); i <= nSlotId; ++i ) // Extend as needed mContContent->push_back( static_cast(NULL) ); if ( mContContent->at( nSlotId ) ) { @@ -712,7 +679,7 @@ bool PContainer2DWorkaround::AddEntry( PContainerEntry* tEntry, u8 nSlotId ) } -PContainerEntry* PContainer2DWorkaround::RemoveEntry( u8 nSlotId ) +PContainerEntry* PContainer2DWorkaround::RemoveEntry( uint8_t nSlotId ) { PContainerEntry* tEntry = NULL; @@ -726,7 +693,7 @@ PContainerEntry* PContainer2DWorkaround::RemoveEntry( u8 nSlotId ) return tEntry; } -bool PContainer2DWorkaround::GetFreeSlot( u8* nSlotId ) +bool PContainer2DWorkaround::GetFreeSlot( uint8_t* nSlotId ) { if ( IsSlotAllowed( mNextFreeSlot ) ) { @@ -737,7 +704,7 @@ bool PContainer2DWorkaround::GetFreeSlot( u8* nSlotId ) return false; } -void PContainer2DWorkaround::SetEntryPosXY( PContainerEntry* nEntry, u8 nSlotId, u8 nPosX, u8 nPosY ) +void PContainer2DWorkaround::SetEntryPosXY( PContainerEntry* nEntry, uint8_t nSlotId, uint8_t nPosX, uint8_t nPosY ) { nSlotId = nSlotId; if (( nPosX == 255 ) && ( nPosY == 255 ) ) @@ -761,7 +728,7 @@ void PContainer2DWorkaround::SetEntryPosXY( PContainerEntry* nEntry, u8 nSlotId, mDirtyFlag = mDirtyFlag || nEntry->mDirtyFlag; } -bool PContainer2DWorkaround::MoveItem( u8 srcSlotId, u8 nCount, u8 dstSlotId ) +bool PContainer2DWorkaround::MoveItem( uint8_t srcSlotId, uint8_t nCount, uint8_t dstSlotId ) { srcSlotId = nCount = dstSlotId; return false; @@ -777,7 +744,7 @@ void PContainer2DWorkaround::AddRow() } } -bool PContainer2DWorkaround::Is2DFree( u8 PosX, u8 PosY, u8 SizeX, u8 SizeY ) +bool PContainer2DWorkaround::Is2DFree( uint8_t PosX, uint8_t PosY, uint8_t SizeX, uint8_t SizeY ) { if (( PosX == 255 ) && ( PosY == 255 ) ) { @@ -786,7 +753,7 @@ bool PContainer2DWorkaround::Is2DFree( u8 PosX, u8 PosY, u8 SizeX, u8 SizeY ) if ( !Is2DPosAllowed( PosX, PosY, SizeX, SizeY ) ) return false; - u8 h, v; + uint8_t h, v; for ( v = 0; ( v < SizeY ) && ( PosY + v < mRows ) ; v++ ) // what is over existing rows is free { for ( h = 0; h < SizeX; h++ ) @@ -803,10 +770,10 @@ bool PContainer2DWorkaround::Is2DFree( u8 PosX, u8 PosY, u8 SizeX, u8 SizeY ) void PContainer2DWorkaround::SetUsed( PContainerEntry* nEntry, bool Value ) { - u8 PosX = nEntry->mPosX;; - u8 PosY = nEntry->mPosY; - u8 SizeX = nEntry->mItem->GetSizeX(); - u8 SizeY = nEntry->mItem->GetSizeY(); + uint8_t PosX = nEntry->mPosX;; + uint8_t PosY = nEntry->mPosY; + uint8_t SizeX = nEntry->mItem->GetSizeX(); + uint8_t SizeY = nEntry->mItem->GetSizeY(); if ( !Is2DPosAllowed( PosX, PosY, SizeX, SizeY ) ) return; @@ -814,7 +781,7 @@ void PContainer2DWorkaround::SetUsed( PContainerEntry* nEntry, bool Value ) while ( PosY + SizeY > mRows ) // add new rows when needed AddRow(); - u8 h, v; + uint8_t h, v; for ( v = 0; ( v < SizeY ) && ( PosY + v < mRows ) ; v++ ) { for ( h = 0; ( h < SizeX ) && ( PosX + h < mMaxCols ); h++ ) @@ -825,9 +792,9 @@ void PContainer2DWorkaround::SetUsed( PContainerEntry* nEntry, bool Value ) bool PContainer2DWorkaround::FindValid2DPos( PContainerEntry* nEntry ) { bool Found = false; - u8 SizeX = nEntry->mItem->GetSizeX(); - u8 SizeY = nEntry->mItem->GetSizeY(); - u8 dPosX, dPosY; + uint8_t SizeX = nEntry->mItem->GetSizeX(); + uint8_t SizeY = nEntry->mItem->GetSizeY(); + uint8_t dPosX, dPosY; if ( Is2DFree( nEntry->mPosX, nEntry->mPosY, SizeX, SizeY ) ) Found = true; @@ -869,7 +836,7 @@ void PContainer2DWorkaround::Dump() PContainer::Dump(); std::string tmpS; - u8 y, x; + uint8_t y, x; for ( y = 0 ; y < mRows; y++ ) { tmpS = ""; @@ -883,7 +850,7 @@ void PContainer2DWorkaround::Dump() } /* --- PContainerAutoFindFree --- */ -bool PContainerAutoFindFree::GetFreeSlot( u8* nSlotId ) +bool PContainerAutoFindFree::GetFreeSlot( uint8_t* nSlotId ) { bool Found = false; @@ -898,7 +865,7 @@ bool PContainerAutoFindFree::GetFreeSlot( u8* nSlotId ) } /* --- PContainerAutoCompactOnClose --- */ -bool PContainerAutoCompactOnClose::EndUse( u32 nExclusiveUseCharID ) +bool PContainerAutoCompactOnClose::EndUse( uint32_t nExclusiveUseCharID ) { if ( nExclusiveUseCharID == mExclusiveUseCharID ) { diff --git a/TinNS/Source/GameServer/Container.hxx b/TinNS/Source/GameServer/Container.hxx new file mode 100644 index 0000000..4037b79 --- /dev/null +++ b/TinNS/Source/GameServer/Container.hxx @@ -0,0 +1,194 @@ +#pragma once + +#include +#include +#ifdef MYSQL_INC_DIR +#include +#else +#include +#endif + +#define CONTAINER_MAX_SIZE 254 + +class PItem; + +class PContainerEntry { + friend class PContainer; + friend class PContainer2D; + friend class PMsgBuilder; + friend class PContainer2DWorkaround; + +private: + enum { + i_invid = 0, + i_charid, + i_invloc, + i_x, + i_y, + i_itemid, + //i_type, + i_flag, + i_qty, + i_sqty, + i_curdur, + i_dmg, + i_freq, + i_hand, + i_rng, + i_maxdur, + i_slots, + i_slt1, + i_slt2, + i_slt3, + i_slt4, + i_slt5, + i_atype, + i_conatin + }; + + PItem* mItem; + uint8_t mPosX; + uint8_t mPosY; + uint32_t mInvID; + bool mDirtyFlag; + + PContainerEntry(PItem* nItem, uint8_t X, uint8_t Y, uint32_t nInvID = 0, bool SetDirty = true); + PContainerEntry(MYSQL_ROW row); + + bool SQLSave(uint32_t CharID, uint32_t InvLoc); + bool SQLDelete(); + + inline void Set2DPos(uint8_t nPosX, uint8_t nPosY) { mDirtyFlag = mDirtyFlag || (mPosX != nPosX) || (mPosY != nPosY) ; mPosX = nPosX; mPosY = nPosY; } + +public: + ~PContainerEntry(); + + inline void Get2DPos(uint8_t* oPosX, uint8_t* oPosY) { *oPosX = mPosX; *oPosY = mPosY; } +}; + + + +class PContainer // Holes allowed, no autofind free slots +{ + protected: + uint8_t mMaxSlots; + std::vector< PContainerEntry* >* mContContent; + uint32_t mCharID; + uint32_t mInvLoc; + uint32_t mExclusiveUseCharID; + bool mDirtyFlag; + + inline bool IsSlotAllowed(uint8_t nSlotId) { return ((nSlotId < CONTAINER_MAX_SIZE) && (!mMaxSlots || (nSlotId < mMaxSlots))); } + virtual bool AddEntry(PContainerEntry* NewEntry, uint8_t nSlotId = 0); + virtual PContainerEntry* RemoveEntry(uint8_t nSlotId); + virtual bool GetFreeSlot(uint8_t* nSlotId); + void Compact(uint8_t startSlotId = 0); + + public: + PContainer(uint8_t nMaxSlots = 0); + virtual ~PContainer(); + + inline void SetInfo(uint32_t CharID, uint32_t InvLoc) { mCharID = CharID; mInvLoc = InvLoc; } + inline uint32_t GetOwnerId() { return mCharID; } + inline bool IsDirty() { return mDirtyFlag; } + inline void SetDirty() { mDirtyFlag = true; } + bool StartUse(uint32_t nExclusiveUseCharID = 0); + virtual bool EndUse(uint32_t nExclusiveUseCharID = 0); + bool SQLLoad(); + bool SQLSave(); + bool IsSlotFree(uint8_t nSlotId); + virtual bool AddItem(PItem* NewItem, uint32_t nInvID = 0, uint8_t nPosX = 0, uint8_t nPosY = 0, bool SetDirty = true); + virtual bool MoveItem(uint8_t srcSlotId, uint8_t nCount, uint8_t dstSlotId); + bool MoveItem(uint8_t srcSlotId, uint8_t nCount, PContainer* dstContainer, uint8_t dstSlotId = 0, uint8_t nPosX = 0, uint8_t nPosY = 0); + virtual void SetEntryPosXY(PContainerEntry* nEntry, uint8_t nSlotId, uint8_t nPosX = 0, uint8_t nPosY = 0); + + virtual uint8_t RandomFill(uint8_t nItemCount = 0, int nItemContainerDefIndex = -1); + PContainerEntry* GetEntry(uint8_t nSlotId); + std::vector< PContainerEntry* >* GetEntries(); + PItem* GetItem(uint8_t nSlotId); + virtual void Dump(); +}; + + +class PContainerWithHoles : public PContainer // Holes allowed, no autofind free slots +{ + public: + PContainerWithHoles(uint8_t nMaxSlots = 0) : PContainer(nMaxSlots){ nMaxSlots = nMaxSlots; } + virtual ~PContainerWithHoles() {} +}; + + +class PContainerAutoCompact : public PContainer // No holes allowed, automatic add to end slot (no control on insertion slot) +{ +protected: + virtual PContainerEntry* RemoveEntry(uint8_t nSlotId); + virtual bool GetFreeSlot(uint8_t* nSlotId); + +public: + PContainerAutoCompact(uint8_t nMaxSlots = 0) : PContainer(nMaxSlots){ nMaxSlots = nMaxSlots; } + virtual ~PContainerAutoCompact() {} + virtual bool MoveItem(uint8_t srcSlotId, uint8_t nCount, uint8_t dstSlotId); +}; + + +class PContainer2D : public PContainerAutoCompact // + slotId not used, non-significant XY used (no XY check yet) +{ + public: + PContainer2D(uint8_t nMaxSlots = 0) : PContainerAutoCompact(nMaxSlots){ nMaxSlots = nMaxSlots; } + virtual ~PContainer2D() {} + + virtual void SetEntryPosXY(PContainerEntry* nEntry, uint8_t nSlotId, uint8_t nPosX = 0, uint8_t nPosY = 0); +}; + +class PContainer2DWorkaround : public PContainerWithHoles // Holes allowed, autofind free slot (always increasing id) +{ +private: + uint8_t mNextFreeSlot; + std::vector< std::vector* > mContSpace; + uint8_t mMaxCols; + uint8_t mMaxRows; + uint8_t mRows; + + void AddRow(); + inline bool Is2DPosAllowed(uint8_t PosX, uint8_t PosY, uint8_t SizeX, uint8_t SizeY) + { + return ((PosX < mMaxCols-SizeX+1) && (PosY < mMaxRows-SizeY+1)); + } + bool Is2DFree(uint8_t PosX, uint8_t PosY, uint8_t SizeX, uint8_t SizeY); + bool FindValid2DPos(PContainerEntry* nEntry); + +protected: + bool AddEntry(PContainerEntry* NewEntry, uint8_t nSlotId = 0); + PContainerEntry* RemoveEntry(uint8_t nSlotId); + bool GetFreeSlot(uint8_t* nSlotId); + + public: + PContainer2DWorkaround(uint8_t nMaxSlots = 0); + ~PContainer2DWorkaround(); + + bool MoveItem(uint8_t srcSlotId, uint8_t nCount, uint8_t dstSlotId); + + void Set2DPosMax(uint8_t MaxPosX, uint8_t MaxPosY = 254) { mMaxCols = MaxPosX; mMaxRows = MaxPosY; } + void SetEntryPosXY(PContainerEntry* nEntry, uint8_t nSlotId, uint8_t nPosX = 0, uint8_t nPosY = 0); + void SetUsed(PContainerEntry* nEntry, bool Value = true); + void Dump(); +}; + +class PContainerAutoFindFree : public PContainerWithHoles // No holes kept after EndUse, automatic find first free slots (no control on insertion slot) +{ + protected: + virtual bool GetFreeSlot(uint8_t* nSlotId); + + public: + PContainerAutoFindFree(uint8_t nMaxSlots = 0) : PContainerWithHoles(nMaxSlots){ nMaxSlots = nMaxSlots; } + virtual ~PContainerAutoFindFree() {} +}; + +class PContainerAutoCompactOnClose : public PContainerAutoFindFree // No holes kept after EndUse, automatic find first free slots (no control on insertion slot) +{ + public: + PContainerAutoCompactOnClose(uint8_t nMaxSlots = 0) : PContainerAutoFindFree(nMaxSlots){ nMaxSlots = nMaxSlots; } + virtual ~PContainerAutoCompactOnClose() {} + + virtual bool EndUse(uint32_t nExclusiveUseCharID = 0); +}; diff --git a/TinNS/Source/GameServer/Decoder/CMakeLists.txt b/TinNS/Source/GameServer/Decoder/CMakeLists.txt new file mode 100644 index 0000000..f7d9bb9 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/CMakeLists.txt @@ -0,0 +1,7 @@ +ADD_LIBRARY (Decoder MessageDecoder.cxx Udp0x08.cxx Udp0x13.cxx Udp0x1f.cxx Udp0x22.cxx Udp0x2b.cxx + UdpAnalyser.cxx UdpAppartment.cxx UdpCharMove.cxx UdpChat.cxx UdpDeathRespawn.cxx + UdpEntityPositionRequest.cxx UdpHack.cxx UdpHeldItemAction.cxx UdpItemManualReload.cxx + UdpItemMove.cxx UdpItemUse.cxx UdpKillSelf.cxx UdpMultiPart.cxx UdpNpcDialog.cxx UdpOOO.cxx + UdpOutfitter.cxx UdpPacket0.cxx UdpPing.cxx UdpPopupResponse.cxx UdpPvpTrade.cxx + UdpQuickAccessBelt.cxx UdpRequestInfo.cxx UdpSubSkill.cxx UdpSync.cxx UdpTerminal.cxx + UdpUseObject.cxx UdpVehicle.cxx UdpWorldIdInfo.cxx UdpZoning.cxx) diff --git a/TinNS/Source/GameServer/Decoder/Includes.hxx b/TinNS/Source/GameServer/Decoder/Includes.hxx new file mode 100644 index 0000000..8e40015 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/Includes.hxx @@ -0,0 +1,37 @@ +#pragma once + +#include "GameServer/Decoder/MessageDecoder.hxx" +#include "GameServer/Decoder/Udp0x08.hxx" +#include "GameServer/Decoder/Udp0x13.hxx" +#include "GameServer/Decoder/Udp0x1f.hxx" +#include "GameServer/Decoder/Udp0x22.hxx" +#include "GameServer/Decoder/Udp0x2b.hxx" +#include "GameServer/Decoder/UdpAnalyser.hxx" +#include "GameServer/Decoder/UdpAppartment.hxx" +#include "GameServer/Decoder/UdpCharMove.hxx" +#include "GameServer/Decoder/UdpChat.hxx" +#include "GameServer/Decoder/UdpDeathRespawn.hxx" +#include "GameServer/Decoder/UdpEntityPositionRequest.hxx" +#include "GameServer/Decoder/UdpHack.hxx" +#include "GameServer/Decoder/UdpHeldItemAction.hxx" +#include "GameServer/Decoder/UdpItemManualReload.hxx" +#include "GameServer/Decoder/UdpItemMove.hxx" +#include "GameServer/Decoder/UdpItemUse.hxx" +#include "GameServer/Decoder/UdpKillSelf.hxx" +#include "GameServer/Decoder/UdpMultiPart.hxx" +#include "GameServer/Decoder/UdpNpcDialog.hxx" +#include "GameServer/Decoder/UdpOOO.hxx" +#include "GameServer/Decoder/UdpOutfitter.hxx" +#include "GameServer/Decoder/UdpPacket0.hxx" +#include "GameServer/Decoder/UdpPing.hxx" +#include "GameServer/Decoder/UdpPopupResponse.hxx" +#include "GameServer/Decoder/UdpPvpTrade.hxx" +#include "GameServer/Decoder/UdpQuickAccessBelt.hxx" +#include "GameServer/Decoder/UdpRequestInfo.hxx" +#include "GameServer/Decoder/UdpSubSkill.hxx" +#include "GameServer/Decoder/UdpSync.hxx" +#include "GameServer/Decoder/UdpTerminal.hxx" +#include "GameServer/Decoder/UdpUseObject.hxx" +#include "GameServer/Decoder/UdpVehicle.hxx" +#include "GameServer/Decoder/UdpWorldIdInfo.hxx" +#include "GameServer/Decoder/UdpZoning.hxx" diff --git a/TinNS/Source/GameServer/Decoder/MessageDecoder.cxx b/TinNS/Source/GameServer/Decoder/MessageDecoder.cxx new file mode 100644 index 0000000..fa36ad3 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/MessageDecoder.cxx @@ -0,0 +1,169 @@ +#include "GameServer/Decoder/Includes.hxx" +#include "Common/Includes.hxx" + +void PUdpMsgDecoder::Init(PMessage *nMessage, PClient *nClient) +{ + mDecodeData.mMessage = nMessage; + mDecodeData.mClient = nClient; + mDecodeData.mState = (nMessage && nClient) ? DECODE_MORE : DECODE_UNDEF; + mDecodeData.mUnknownType = 0; + mDecodeData.mHandling0x13Sub = false; + mDecodeData.Sub0x13Start = mDecodeData.Sub0x13StartNext = 0; + mPacketName.erase(); + mDecodeData.mName.str(mPacketName); + mDecodeData.mErrorDetail.erase(); + mDecodeData.mTraceKnownMsg = false; + mDecodeData.mTraceUnknownMsg = false; + mDecodeData.mTraceDump = false; + if (mCurrentAnalyser) + { + delete mCurrentAnalyser; + mCurrentAnalyser = nullptr; + } +} + +PUdpMsgDecoder::PUdpMsgDecoder() +{ + mCurrentAnalyser = nullptr; + Reset(); +} + +PUdpMsgDecoder::PUdpMsgDecoder(PMessage *nMessage, PClient *nClient) +{ + mCurrentAnalyser = nullptr; + Init(nMessage, nClient); +} + +PUdpMsgDecoder::~PUdpMsgDecoder() +{ + if (mCurrentAnalyser) + { + delete mCurrentAnalyser; + } +} + +bool PUdpMsgDecoder::Analyse() +{ + PUdpMsgAnalyser* nextAnalyser; + + if ((mDecodeData.mState & DECODE_MORE) || mDecodeData.mHandling0x13Sub) + { + if (mCurrentAnalyser) + { + delete mCurrentAnalyser; + mCurrentAnalyser = nullptr; + } + if (mDecodeData.mHandling0x13Sub) + { + mPacketName.erase(); + mDecodeData.mName.str(mPacketName); + mCurrentAnalyser = new PUdp0x13(&mDecodeData); + mDecodeData.mState = DECODE_MORE; + } + else + { + mCurrentAnalyser = new PUdpMsgAnalyser(&mDecodeData); + } + + while (mDecodeData.mState & DECODE_MORE) + { + nextAnalyser = mCurrentAnalyser->Analyse(); + if (mCurrentAnalyser != nextAnalyser) + { + delete mCurrentAnalyser; + mCurrentAnalyser = nextAnalyser; + } + } + } + return (!(mDecodeData.mState & (DECODE_MORE | DECODE_ERROR | DECODE_UNKNOWN))); +} + +bool PUdpMsgDecoder::Analyse(PMessage *nMessage, PClient *nClient) +{ + Init(nMessage, nClient); + return Analyse(); +} + +void PUdpMsgDecoder::Init(PMessage *nMessage, PClient *nClient, PGameState *nClientState) +{ + mDecodeData.mClientState = nClientState; + Init(nMessage, nClient); +} + +uint8_t PUdpMsgDecoder::GetState() +{ + return mDecodeData.mState; +} + +bool PUdpMsgDecoder::IsError() +{ + return (mDecodeData.mState & DECODE_ERROR); +} + +bool PUdpMsgDecoder::IsKnown() +{ + return (!(mDecodeData.mState & DECODE_UNKNOWN)); +} + +bool PUdpMsgDecoder::MoreSubMsg() +{ + return mDecodeData.mHandling0x13Sub; +} + +bool PUdpMsgDecoder::IsActionReady() +{ + return (mDecodeData.mState & DECODE_ACTION_READY); +} + +bool PUdpMsgDecoder::IsActionDone() +{ + return (mDecodeData.mState & DECODE_ACTION_DONE); +} + +bool PUdpMsgDecoder::IsTraceKnownMsg() +{ + return mDecodeData.mTraceKnownMsg; +} + +bool PUdpMsgDecoder::IsTraceUnknownMsg() +{ + return mDecodeData.mTraceUnknownMsg; +} + +bool PUdpMsgDecoder::IsTraceDump() +{ + return mDecodeData.mTraceDump; +} + +void PUdpMsgDecoder::DumpMsg() +{ + if (mDecodeData.mMessage) + mDecodeData.mMessage->Dump(); +} + +std::string const &PUdpMsgDecoder::GetName() +{ + return (mTmpName = mDecodeData.mName.str()); +} + +std::string const &PUdpMsgDecoder::GetError() +{ + return mDecodeData.mErrorDetail; +} + +bool PUdpMsgDecoder::DoAction() +{ + if (mDecodeData.mState & DECODE_ACTION_READY) + { + return mCurrentAnalyser->DoAction(); + } + else + { + return false; + } +} + +void PUdpMsgDecoder::Reset() +{ + Init(nullptr, nullptr); +} diff --git a/TinNS/Source/GameServer/Decoder/MessageDecoder.hxx b/TinNS/Source/GameServer/Decoder/MessageDecoder.hxx new file mode 100644 index 0000000..edf2a6b --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/MessageDecoder.hxx @@ -0,0 +1,73 @@ +#pragma once + +#include +#include +#include + +struct PGameState; +class PClient; +class PMessage; +class PUdpMsgAnalyser; + +#define DECODE_UNDEF 0 +#define DECODE_ERROR 1 // one error occured on the current decoding step +#define DECODE_UNKNOWN 2 // the current decoded (sub)message is unkown +#define DECODE_MORE 4 // more decoding needed for the (sub)message +#define DECODE_FINISHED 8 // decoding if finished for the whole message +#define DECODE_ACTION_READY 16 // an action is ready to be done +#define DECODE_ACTION_DONE 32 // the action triggered hasn't to be triggered again +#define DECODE_ACTION_IGNORED 64 // the action wasn't performed for some (good) reason (to combine or not with DONE) +#define DECODE_ACTION_FAILED 128 // the action failed totally or partially (to combine or not with DONE) + +struct PMsgDecodeData { + PMessage *mMessage; + PClient *mClient; + uint8_t mState; + uint8_t mUnknownType; + bool mHandling0x13Sub; + uint16_t Sub0x13Start; + uint16_t Sub0x13StartNext; + std::stringstream mName; + std::string mErrorDetail; + bool mTraceKnownMsg; + bool mTraceUnknownMsg; + bool mTraceDump; + PGameState *mClientState; // Temporary until State is put back in Client object +}; + +// UDP Message decoder +// boolean methods return true if successful + +class PUdpMsgDecoder { +private: + PMsgDecodeData mDecodeData; + PUdpMsgAnalyser *mCurrentAnalyser; + std::string mPacketName; + std::string mTmpName; + + void Init(PMessage *nMessage, PClient *nClient); + +public: + PUdpMsgDecoder(); + PUdpMsgDecoder(PMessage *nMessage, PClient *nClient); + ~PUdpMsgDecoder(); + + bool Analyse(); + bool Analyse(PMessage *nMessage, PClient *nClient); // Can be used on non initialized or already used object + // Temporary form until State is put back in Client object + void Init(PMessage *nMessage, PClient *nClient, PGameState *nClientState); + uint8_t GetState(); + bool IsError(); + bool IsKnown(); + bool MoreSubMsg(); + bool IsActionReady(); + bool IsActionDone(); + bool IsTraceKnownMsg(); + bool IsTraceUnknownMsg(); + bool IsTraceDump(); + void DumpMsg(); + std::string const &GetName(); + std::string const &GetError(); + bool DoAction(); + void Reset(); +}; diff --git a/TinNS/Source/GameServer/Decoder/Udp0x08.cxx b/TinNS/Source/GameServer/Decoder/Udp0x08.cxx new file mode 100644 index 0000000..ab5424a --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/Udp0x08.cxx @@ -0,0 +1,24 @@ +#include "GameServer/Decoder/Includes.hxx" +#include "GameServer/Includes.hxx" + +PUdp0x08::PUdp0x08(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData) +{ + nDecodeData->mName << "/0x08"; +} + +PUdpMsgAnalyser* PUdp0x08::Analyse() +{ + mDecodeData->mName << "=Client crash"; + mDecodeData->mState = DECODE_ACTION_READY | DECODE_FINISHED; + + return this; +} + +bool PUdp0x08::DoAction() +{ + // Client crashed, close connection from our side + GameServer->ClientDisconnected(mDecodeData->mClient); + mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED; + + return true; +} diff --git a/TinNS/Source/GameServer/Decoder/Udp0x08.hxx b/TinNS/Source/GameServer/Decoder/Udp0x08.hxx new file mode 100644 index 0000000..81b9443 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/Udp0x08.hxx @@ -0,0 +1,11 @@ +#pragma once + +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PUdp0x08 : public PUdpMsgAnalyser { +public: + PUdp0x08(PMsgDecodeData *nDecodeData); + //~PUdp0x08(); + PUdpMsgAnalyser* Analyse(); + bool DoAction(); +}; diff --git a/server/src/game/decoder/udp_0x13.cpp b/TinNS/Source/GameServer/Decoder/Udp0x13.cxx similarity index 72% rename from server/src/game/decoder/udp_0x13.cpp rename to TinNS/Source/GameServer/Decoder/Udp0x13.cxx index 3a89ad4..edd7e4e 100644 --- a/server/src/game/decoder/udp_0x13.cpp +++ b/TinNS/Source/GameServer/Decoder/Udp0x13.cxx @@ -1,49 +1,6 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - udp_0x13.cpp - decoder classes for UDP 0x13 messages - - CREATION: 31 Aug 2006 Hammag - - MODIFIED: - REASON: - -*/ - -#include "main.h" -#include "udp_0x13.h" - -#include "udp_OOO.h" -#include "udp_zoning.h" -#include "udp_0x1f.h" -#include "udp_0x22.h" -#include "udp_ping.h" -#include "udp_sync.h" -#include "udp_charmove.h" -#include "udp_packet0.h" -#include "udp_vhc.h" -#include "udp_0x2b.h" -#include "udp_itemmanualreload.h" -#include "udp_worldIDinfo.h" -#include "udp_multipart.h" +#include "GameServer/Decoder/Includes.hxx" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" /**** PUdp0x13 ****/ @@ -59,31 +16,31 @@ PUdpMsgAnalyser* PUdp0x13::Analyse() if ( ! mDecodeData->mHandling0x13Sub ) // First decoding pass { - //Console->Print(" --- New 0x13 msg"); - //TmpMsg->Dump(); + //Console->Print(" --- New 0x13 msg"); + //TmpMsg->Dump(); ( *TmpMsg ) >> ( mDecodeData->mClientState->UDP.mSequence ); // "LastPacket" ( *TmpMsg ) >> ( mDecodeData->mClientState->UDP.mServerPacketNum ); //PID mDecodeData->Sub0x13StartNext = 0; - } + } if ( TmpMsg->EOM() ) - { + { Console->Print( RED, BLACK, "PUdp0x13::Analyse(): Emptied 0x13 msg handling !!!" ); mDecodeData->mState = DECODE_FINISHED; mDecodeData->mHandling0x13Sub = false; nextAnalyser = this; mDecodeData->Sub0x13Start = mDecodeData->Sub0x13StartNext = 0; - } - else - { + } + else + { if ( mDecodeData->mHandling0x13Sub && mDecodeData->Sub0x13StartNext ) { TmpMsg->SetNextByteOffset( mDecodeData->Sub0x13StartNext ); //Console->Print("Multi 0x13 msg continuing at %d", TmpMsg->GetNextByteOffset()); } mDecodeData->Sub0x13Start = TmpMsg->GetNextByteOffset(); - u8 PSize = TmpMsg->U8Data( mDecodeData->Sub0x13Start ); - u16 EndOffset = mDecodeData->Sub0x13StartNext = mDecodeData->Sub0x13Start + 1 + PSize; + uint8_t PSize = TmpMsg->U8Data( mDecodeData->Sub0x13Start ); + uint16_t EndOffset = mDecodeData->Sub0x13StartNext = mDecodeData->Sub0x13Start + 1 + PSize; if ( EndOffset >= TmpMsg->GetSize() ) { @@ -105,17 +62,17 @@ PUdpMsgAnalyser* PUdp0x13::Analyse() } mDecodeData->mState = DECODE_MORE; - u8 MsgType = TmpMsg->U8Data( mDecodeData->Sub0x13Start + 1 ); - /*u16 PSeq = 0; // This will have to be handled to detected missing granted-delivery messages + uint8_t MsgType = TmpMsg->U8Data( mDecodeData->Sub0x13Start + 1 ); + /*uint16_t PSeq = 0; // This will have to be handled to detected missing granted-delivery messages if (MsgType == 0x03) - PSeq = *(u16*)&Buf[Offset+2];*/ + PSeq = *(uint16_t*)&Buf[Offset+2];*/ //Console->Print("0x13 Type: %d", MsgType); switch ( MsgType ) - { + { case 0x03: { mDecodeData->mName << "/0x03"; - u8 MsgSubType = TmpMsg->U8Data( TmpMsg->GetNextByteOffset() + 4 ); + uint8_t MsgSubType = TmpMsg->U8Data( TmpMsg->GetNextByteOffset() + 4 ); switch ( MsgSubType ) { case 0x01: // Out of order @@ -161,25 +118,25 @@ PUdpMsgAnalyser* PUdp0x13::Analyse() break; } } - break; + break; } case 0x0b: // Ping { nextAnalyser = new PUdpPing( mDecodeData ); - break; + break; } case 0x0c: // Baseline { nextAnalyser = new PUdpSync2( mDecodeData ); - break; + break; } case 0x1f: { mDecodeData->mName << "/0x1f"; - u8 MsgSubType = TmpMsg->U8Data( TmpMsg->GetNextByteOffset() + 4 ); + uint8_t MsgSubType = TmpMsg->U8Data( TmpMsg->GetNextByteOffset() + 4 ); if ( MsgSubType == 0x15 ) // Weapon reload animation start { nextAnalyser = new PUdpReloadAnimStart( mDecodeData ); @@ -189,7 +146,7 @@ PUdpMsgAnalyser* PUdp0x13::Analyse() mDecodeData->mUnknownType = MsgType; mDecodeData->mTraceUnknownMsg = true; } - break; + break; } case 0x20: // Char move @@ -201,8 +158,8 @@ PUdpMsgAnalyser* PUdp0x13::Analyse() case 0x27: // Sitting object info request { nextAnalyser = new PUdpRequestVhcInfo( mDecodeData ); - break; - } + break; + } case 0x2a: // "Packet0" { @@ -211,15 +168,15 @@ PUdpMsgAnalyser* PUdp0x13::Analyse() } case 0x2d: // sent when targeting another char - { + { nextAnalyser = new PUdpCharTargeting( mDecodeData ); break; - } + } case 0x32: // Vhc move - { + { mDecodeData->mName << "/0x32"; - u8 MsgSubType = TmpMsg->U8Data( TmpMsg->GetNextByteOffset() + 4 ); + uint8_t MsgSubType = TmpMsg->U8Data( TmpMsg->GetNextByteOffset() + 4 ); switch ( MsgSubType ) { case 0x00: // Subway position update @@ -239,13 +196,13 @@ PUdpMsgAnalyser* PUdp0x13::Analyse() } } break; - } + } default: - { + { mDecodeData->mUnknownType = MsgType; - break; - } + break; + } } if ( ! nextAnalyser ) @@ -253,6 +210,6 @@ PUdpMsgAnalyser* PUdp0x13::Analyse() nextAnalyser = new PUdpMsgUnknown( mDecodeData ); } - } + } return nextAnalyser; } diff --git a/TinNS/Source/GameServer/Decoder/Udp0x13.hxx b/TinNS/Source/GameServer/Decoder/Udp0x13.hxx new file mode 100644 index 0000000..7d93ffc --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/Udp0x13.hxx @@ -0,0 +1,11 @@ +#pragma once + +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PUdp0x13 : public PUdpMsgAnalyser { +public: + PUdp0x13(PMsgDecodeData *nDecodeData); + //~PUdp0x13(); + PUdpMsgAnalyser* Analyse(); + //bool DoAction(); +}; diff --git a/server/src/game/decoder/udp_0x1f.cpp b/TinNS/Source/GameServer/Decoder/Udp0x1f.cxx similarity index 71% rename from server/src/game/decoder/udp_0x1f.cpp rename to TinNS/Source/GameServer/Decoder/Udp0x1f.cxx index e143971..d51857c 100644 --- a/server/src/game/decoder/udp_0x1f.cpp +++ b/TinNS/Source/GameServer/Decoder/Udp0x1f.cxx @@ -1,57 +1,5 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_udp0x1f.cpp - decoder classes for UDP 0x13x03x1f messages - - CREATION: 6 Sep 2006 Hammag - - MODIFIED: - REASON: - - -*/ - -#include "main.h" -#include "udp_0x1f.h" - -#include "udp_zoning.h" -#include "udp_charmove.h" -#include "udp_vhc.h" -#include "udp_subskill.h" -#include "udp_chat.h" -#include "udp_useobject.h" -#include "udp_appartment.h" -#include "udp_quickaccessbelt.h" -#include "udp_itemmove.h" -#include "udp_hack.h" -#include "udp_outfitter.h" -#include "udp_helditemaction.h" -#include "udp_killself.h" -#include "udp_popupresponse.h" -#include "udp_itemmanualreload.h" -#include "udp_itemuse.h" -#include "udp_deathrespawn.h" -#include "udp_pvptrade.h" -#include "udp_npcdialog.h" +#include "GameServer/Decoder/Includes.hxx" +#include "Common/Includes.hxx" /**** PUdp0x1f ****/ @@ -64,19 +12,19 @@ PUdpMsgAnalyser* PUdp0x1f::Analyse() { PUdpMsgAnalyser* nextAnalyser = NULL; mDecodeData->mState = DECODE_MORE; - u8 MsgType = mDecodeData->mMessage->U8Data( mDecodeData->Sub0x13Start + 7 ); - u8 MsgSubType = mDecodeData->mMessage->U8Data( mDecodeData->Sub0x13Start + 8 ); + uint8_t MsgType = mDecodeData->mMessage->U8Data( mDecodeData->Sub0x13Start + 7 ); + uint8_t MsgSubType = mDecodeData->mMessage->U8Data( mDecodeData->Sub0x13Start + 8 ); switch ( MsgType ) { case 0x00: { - nextAnalyser = new PUdpHeldItemBasicAction( mDecodeData ); + nextAnalyser = new PUdpHeldItemBasicAction( mDecodeData ); break; } case 0x01: { - nextAnalyser = new PUdpHeldItemAimedAction( mDecodeData ); + nextAnalyser = new PUdpHeldItemAimedAction( mDecodeData ); break; } case 0x02: @@ -114,9 +62,9 @@ PUdpMsgAnalyser* PUdp0x1f::Analyse() nextAnalyser = new PUdpItemSlotUse( mDecodeData ); break; } - case 0x20: // Use item for hacking, launcher, "launcher" spell + case 0x20: // Use item for hacking, launcher, "launcher" spell { - nextAnalyser = new PUdpHeldItemLaunchingAction( mDecodeData ); + nextAnalyser = new PUdpHeldItemLaunchingAction( mDecodeData ); break; } case 0x22: diff --git a/TinNS/Source/GameServer/Decoder/Udp0x1f.hxx b/TinNS/Source/GameServer/Decoder/Udp0x1f.hxx new file mode 100644 index 0000000..0613a0c --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/Udp0x1f.hxx @@ -0,0 +1,11 @@ +#pragma once + +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PUdp0x1f : public PUdpMsgAnalyser { +public: + PUdp0x1f(PMsgDecodeData *nDecodeData); + //~PUdp0x1f(); + PUdpMsgAnalyser *Analyse(); + //bool DoAction(); +}; diff --git a/TinNS/Source/GameServer/Decoder/Udp0x22.cxx b/TinNS/Source/GameServer/Decoder/Udp0x22.cxx new file mode 100644 index 0000000..459666b --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/Udp0x22.cxx @@ -0,0 +1,51 @@ +#include "GameServer/Decoder/Includes.hxx" +#include "Common/Includes.hxx" + +/**** PUdp0x22 ****/ + +PUdp0x22::PUdp0x22(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData) +{ + nDecodeData->mName << "/0x22"; +} + +PUdpMsgAnalyser* PUdp0x22::Analyse() +{ + PUdpMsgAnalyser* nextAnalyser = NULL; + mDecodeData->mState = DECODE_MORE; + uint8_t MsgType = mDecodeData->mMessage->U8Data(mDecodeData->Sub0x13Start + 5); + switch(MsgType) // MsgType is probably uint16_t rather than uint8_t + { + case 0x03: // Zoning phase 2 + { + nextAnalyser = new PUdpZoning2(mDecodeData); + break; + } + case 0x06: // Char/Clan/Rank/Map Info request + { + nextAnalyser = new PUdpReqInfo(mDecodeData); + break; + } + case 0x0b: // Entity position request + { + nextAnalyser = new PUdpEntityPosRequest(mDecodeData); + break; + } + case 0x0d: // Zoning phase 1 + { + nextAnalyser = new PUdpZoning1(mDecodeData); + break; + } + default: + { + mDecodeData->mUnknownType = MsgType; + break; + } + } + + if (! nextAnalyser) + { + nextAnalyser = new PUdpMsgUnknown(mDecodeData); + } + + return nextAnalyser; +} diff --git a/TinNS/Source/GameServer/Decoder/Udp0x22.hxx b/TinNS/Source/GameServer/Decoder/Udp0x22.hxx new file mode 100644 index 0000000..aa946b3 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/Udp0x22.hxx @@ -0,0 +1,11 @@ +#pragma once + +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PUdp0x22 : public PUdpMsgAnalyser { +public: + PUdp0x22(PMsgDecodeData *nDecodeData); + //~PUdp0x22(); + PUdpMsgAnalyser *Analyse(); + //bool DoAction(); +}; diff --git a/TinNS/Source/GameServer/Decoder/Udp0x2b.cxx b/TinNS/Source/GameServer/Decoder/Udp0x2b.cxx new file mode 100644 index 0000000..28e9e5a --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/Udp0x2b.cxx @@ -0,0 +1,57 @@ +#include "GameServer/Decoder/Includes.hxx" +#include "Common/Includes.hxx" + +/**** PUdp0x2b ****/ + +PUdp0x2b::PUdp0x2b(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData) +{ + nDecodeData->mName << "/0x2b"; +} + +PUdpMsgAnalyser* PUdp0x2b::Analyse() +{ + PUdpMsgAnalyser* nextAnalyser = nullptr; + mDecodeData->mState = DECODE_MORE; + uint8_t MsgType = mDecodeData->mMessage->U8Data(mDecodeData->Sub0x13Start + 5); + switch(MsgType) + { + case 0x17: // ReceiveDB Terminal Command + { + nextAnalyser = new PUdpReceiveDB(mDecodeData); + break; + } + case 0x18: // UpdateDB Terminal Command + { + nextAnalyser = new PUdpUpdateDB(mDecodeData); + break; + } + case 0x19: // TryAccess Terminal Command + { + nextAnalyser = new PUdpTryAccessDB(mDecodeData); + break; + } + case 0x1b: // DB Query and Command + { + nextAnalyser = new PUdpQueryDB(mDecodeData); + break; + } + case 0x1f: // Citycom? + { + nextAnalyser = new PUdpTeminal0x1f(mDecodeData); + break; + } + + default: + { + mDecodeData->mUnknownType = MsgType; + break; + } + } + + if (! nextAnalyser) + { + nextAnalyser = new PUdpMsgUnknown(mDecodeData); + } + + return nextAnalyser; +} diff --git a/TinNS/Source/GameServer/Decoder/Udp0x2b.hxx b/TinNS/Source/GameServer/Decoder/Udp0x2b.hxx new file mode 100644 index 0000000..e3baa60 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/Udp0x2b.hxx @@ -0,0 +1,11 @@ +#pragma once + +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PUdp0x2b : public PUdpMsgAnalyser { +public: + PUdp0x2b(PMsgDecodeData *nDecodeData); + //~PUdp0x2b(); + PUdpMsgAnalyser *Analyse(); + //bool DoAction(); +}; diff --git a/server/src/game/decoder/udpanalyser.cpp b/TinNS/Source/GameServer/Decoder/UdpAnalyser.cxx similarity index 60% rename from server/src/game/decoder/udpanalyser.cpp rename to TinNS/Source/GameServer/Decoder/UdpAnalyser.cxx index d625b81..24d2aa3 100644 --- a/server/src/game/decoder/udpanalyser.cpp +++ b/TinNS/Source/GameServer/Decoder/UdpAnalyser.cxx @@ -1,43 +1,5 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udpanalyser.cpp - Analyser class top (used only by PUdpMsgDecoder) - Also includes the PUdpMsgUnknown derived class - - CREATION: 23 Aug 2006 Hammag - - MODIFIED: 30 Aug 2006 Hammag - REASON: - moved these two class in file distinct from PUdpMsgDecoder. - - made implementation - -*/ - -#include "main.h" -#include "udpanalyser.h" - -#include "udp_sync.h" -#include "udp_0x13.h" -#include "udp_0x08.h" +#include "GameServer/Decoder/Includes.hxx" +#include "Common/Includes.hxx" /**** PUdpMsgAnalyser ****/ @@ -58,7 +20,7 @@ PUdpMsgAnalyser::~PUdpMsgAnalyser() PUdpMsgAnalyser* PUdpMsgAnalyser::Analyse() { PUdpMsgAnalyser* nextAnalyser; - u8 MsgType; + uint8_t MsgType; mDecodeData->mState = DECODE_MORE; //mDecodeData->mTraceKnownMsg = true; // Don't want to trace all known messages diff --git a/TinNS/Source/GameServer/Decoder/UdpAnalyser.hxx b/TinNS/Source/GameServer/Decoder/UdpAnalyser.hxx new file mode 100644 index 0000000..8215ab5 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpAnalyser.hxx @@ -0,0 +1,38 @@ +#pragma once + +#include + +class PMsgDecodeData; + +class PUdpMsgAnalyser { + friend class PUdpMsgDecoder; + +protected: + PMsgDecodeData* mDecodeData; + +public: + PUdpMsgAnalyser(PMsgDecodeData *nDecodeData); + virtual ~PUdpMsgAnalyser(); + + virtual PUdpMsgAnalyser *Analyse(); + virtual bool DoAction(); + + static int32_t smAnaCount; // temp for check + +}; + +class PUdpMsgUnknown : public PUdpMsgAnalyser { +public: + PUdpMsgUnknown(PMsgDecodeData *nDecodeData); + //~PUdpMsgUnknown(); + + //bool DoAction(); +}; + +class PUdpMsgIgnore : public PUdpMsgAnalyser { +public: + PUdpMsgIgnore(PMsgDecodeData *nDecodeData); + //~PUdpMsgUnknown(); + + //bool DoAction(); +}; diff --git a/TinNS/Source/GameServer/Decoder/UdpAppartment.cxx b/TinNS/Source/GameServer/Decoder/UdpAppartment.cxx new file mode 100644 index 0000000..33e5ad6 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpAppartment.cxx @@ -0,0 +1,30 @@ +#include "GameServer/Decoder/Includes.hxx" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" + +/**** PUdpAptLocInfo ****/ + +PUdpAptLocInfo::PUdpAptLocInfo(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData) +{ + nDecodeData->mName << "/0x0a"; +} + +PUdpMsgAnalyser* PUdpAptLocInfo::Analyse() +{ + mDecodeData->mName << "=Requesting appartment location for NavRay"; + + mDecodeData->mState = DECODE_ACTION_READY | DECODE_FINISHED; + return this; +} + +bool PUdpAptLocInfo::DoAction() +{ +Console->Print("Got request for app data"); + PMessage* tmpMsg = MsgBuilder->BuildCharAptLocInfoMsg (mDecodeData->mClient); + + if (tmpMsg) + mDecodeData->mClient->SendUDPMessage(tmpMsg); + + mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED; + return true; +} diff --git a/TinNS/Source/GameServer/Decoder/UdpAppartment.hxx b/TinNS/Source/GameServer/Decoder/UdpAppartment.hxx new file mode 100644 index 0000000..ca627bf --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpAppartment.hxx @@ -0,0 +1,11 @@ +#pragma once + +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PUdpAptLocInfo : public PUdpMsgAnalyser { +public: + PUdpAptLocInfo(PMsgDecodeData *nDecodeData); + //~PUdpAptLocInfo(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; diff --git a/server/src/game/decoder/udp_charmove.cpp b/TinNS/Source/GameServer/Decoder/UdpCharMove.cxx similarity index 83% rename from server/src/game/decoder/udp_charmove.cpp rename to TinNS/Source/GameServer/Decoder/UdpCharMove.cxx index 7f6d585..7100914 100644 --- a/server/src/game/decoder/udp_charmove.cpp +++ b/TinNS/Source/GameServer/Decoder/UdpCharMove.cxx @@ -1,41 +1,7 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - udp_charmove.cpp - decoder classes for UDP char movement messages - - CREATION: 5 Sep 2006 Hammag - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - -#include "main.h" - -#include "udp_charmove.h" - -#include "include/worlds.h" -#include "include/vehicle.h" -#include "include/subway.h" - +#include +#include "GameServer/Decoder/Includes.hxx" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" #define JUMPHEIGHT 160 @@ -129,8 +95,8 @@ bool PUdpCharPosUpdate::DoAction() if ( ! (mInfoBitfield & 0x80) ) { - u32 nSeatableObjectId; - u8 nSeatId; + uint32_t nSeatableObjectId; + uint8_t nSeatId; if( nChar->GetSeatInUse(&nSeatableObjectId, &nSeatId) == seat_vhc ) { tmpMsg = MsgBuilder->BuildCharUseSeatMsg( nClient, nSeatableObjectId, nSeatId ); @@ -141,7 +107,7 @@ bool PUdpCharPosUpdate::DoAction() mInfoBitfield = 0x80; } } - + if ( mInfoBitfield & 0x80 ) // Sitting on chair { //tmpMsg = MsgBuilder->BuildCharSittingMsg(nClient, mChairItemID); @@ -209,7 +175,7 @@ bool PUdpCharPosUpdate::DoAction() ClientManager->UDPBroadcast(tmpMsg, nClient, 5000); // TODO: Get the range from config }*/ - u16 nSaveZ = nChar->Coords.mZ; + uint16_t nSaveZ = nChar->Coords.mZ; if(nChar->Coords.mJumpingState) { mInfoBitfield |= 0x02; // Update Z and Act only @@ -233,8 +199,8 @@ bool PUdpCharPosUpdate::DoAction() if ( IsRealMove && nClient->GetDebugMode( DBG_LOCATION ) ) { char DbgMessage[128]; - f32 f[3]; -// u32 h[3]; + float f[3]; +// uint32_t h[3]; f[0] = nChar->Coords.mY - 32000; f[1] = nChar->Coords.mZ - 32000; f[2] = nChar->Coords.mX - 32000; @@ -242,7 +208,7 @@ bool PUdpCharPosUpdate::DoAction() Chat->send( nClient, CHAT_GM, "Debug", DbgMessage ); } /*{ - u16 p[3]; + uint16_t p[3]; p[0] = nChar->Coords.mY; p[1] = nChar->Coords.mZ; p[2] = nChar->Coords.mX; @@ -303,19 +269,19 @@ bool PUdpCharExitChair::DoLeaveChair( PChar* nChar, PClient* nClient, PSpawnedVe } PMessage* tmpMsg; - u32 cSeatObjectId; - u8 cSeatId; + uint32_t cSeatObjectId; + uint8_t cSeatId; PSeatType cSeatType = nChar->GetSeatInUse( &cSeatObjectId, &cSeatId ); - u32 tNowTime = GameServer->GetGameTime(); + uint32_t tNowTime = GameServer->GetGameTime(); bool ReadyToExit = false; // This is only for investigation on subway timing if ( nClient->GetDebugMode( DBG_SUBWAY ) && ( cSeatType == seat_subway ) ) { char DbgMessage[80]; - u8 tCabId; + uint8_t tCabId; Subway->GetInfoIndex( cSeatObjectId, &tCabId ); - u8 tStationId = Subway->GetStation( cSeatObjectId, tNowTime ); + uint8_t tStationId = Subway->GetStation( cSeatObjectId, tNowTime ); std::string* StationName = Subway->GetStationName( tStationId ); std::string OpenState = ( Subway->IsDoorOpen( cSeatObjectId, tNowTime ) ? "open" : "closed" ); @@ -353,7 +319,7 @@ bool PUdpCharExitChair::DoLeaveChair( PChar* nChar, PClient* nClient, PSpawnedVe } else if ( cSeatType == seat_vhc ) { - PSpawnedVehicle* tVhc = tWorld->GetSpawnedVehicules()->GetVehicle( cSeatObjectId ); + PSpawnedVehicle* tVhc = tWorld->GetSpawnedVehicles()->GetVehicle( cSeatObjectId ); if ( tVhc && (!nVhc || (tVhc == nVhc) || nForce) ) { PVhcCoordinates tCoords = tVhc->GetPosition(); @@ -411,8 +377,8 @@ bool PUdpCharJump::DoAction() else // If not moving, jump now { if ( gDevDebug ) Console->Print( "%s Send static jump", Console->ColorText( CYAN, BLACK, "[DEBUG]" ) ); - u8 mInfoBitfield = 0x22; // Update Z and Act only - u16 nSaveZ = nChar->Coords.mZ; + uint8_t mInfoBitfield = 0x22; // Update Z and Act only + uint16_t nSaveZ = nChar->Coords.mZ; (nChar->Coords.mZ) += JUMPHEIGHT; PMessage* tmpMsg = MsgBuilder->BuildCharPosUpdate2Msg( nClient, mInfoBitfield ); nChar->Coords.mZ = nSaveZ; @@ -445,10 +411,10 @@ bool PUdpCharTargeting::DoAction() { PClient* nClient = mDecodeData->mClient; PChar* tChar = nClient->GetChar(); - u16 CharID = mDecodeData->mMessage->U16Data( mDecodeData->Sub0x13Start + 2 ); - u8 strangeval1 = mDecodeData->mMessage->U8Data( mDecodeData->Sub0x13Start + 4 ); - u8 strangeval2 = mDecodeData->mMessage->U8Data( mDecodeData->Sub0x13Start + 5 ); - u8 strangeval3 = mDecodeData->mMessage->U8Data( mDecodeData->Sub0x13Start + 6 ); + uint16_t CharID = mDecodeData->mMessage->U16Data( mDecodeData->Sub0x13Start + 2 ); + uint8_t strangeval1 = mDecodeData->mMessage->U8Data( mDecodeData->Sub0x13Start + 4 ); + uint8_t strangeval2 = mDecodeData->mMessage->U8Data( mDecodeData->Sub0x13Start + 5 ); + uint8_t strangeval3 = mDecodeData->mMessage->U8Data( mDecodeData->Sub0x13Start + 6 ); tChar->SetLookingAt( CharID ); diff --git a/TinNS/Source/GameServer/Decoder/UdpCharMove.hxx b/TinNS/Source/GameServer/Decoder/UdpCharMove.hxx new file mode 100644 index 0000000..e0cc96e --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpCharMove.hxx @@ -0,0 +1,56 @@ +#pragma once + +#include +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PChar; +class PClient; +class PSpawnedVehicle; + +class PUdpCharPosUpdate : public PUdpMsgAnalyser { +private: + uint8_t mInfoBitfield; + uint16_t mNewY; + uint16_t mNewZ; + uint16_t mNewX; + uint8_t mNewUD; + uint8_t mNewLR; + uint8_t mNewAct; + uint8_t mNewUnknown; + uint32_t mChairItemID; // uint16_t or uint32_t ??? + uint8_t mChairItemSeat; + +public: + PUdpCharPosUpdate(PMsgDecodeData *nDecodeData); + //~PUdpCharMoves(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; + +class PUdpCharExitChair : public PUdpMsgAnalyser { +public: + PUdpCharExitChair(PMsgDecodeData *nDecodeData); + //~PUdpCharExitChair(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); + + //nClient is optionnal, nVhc is to limit to that vhc, nForce to force exit event when cab door closed + static bool DoLeaveChair(PChar *nChar, PClient *nClient = nullptr, PSpawnedVehicle *nVhc = nullptr, + bool nForce = false); +}; + +class PUdpCharJump : public PUdpMsgAnalyser { +public: + PUdpCharJump(PMsgDecodeData *nDecodeData); + //~PUdpCharJump(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; + +class PUdpCharTargeting : public PUdpMsgAnalyser { +public: + PUdpCharTargeting(PMsgDecodeData *nDecodeData); + //~PUdpCharTargeting(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; diff --git a/server/src/game/decoder/udp_chat.cpp b/TinNS/Source/GameServer/Decoder/UdpChat.cxx similarity index 79% rename from server/src/game/decoder/udp_chat.cpp rename to TinNS/Source/GameServer/Decoder/UdpChat.cxx index 34641fb..95bfa38 100644 --- a/server/src/game/decoder/udp_chat.cpp +++ b/TinNS/Source/GameServer/Decoder/UdpChat.cxx @@ -1,50 +1,19 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_chat.h - decoder classes for UDP chat messages - - CREATION: 15 Sep 2006 Hammag - - MODIFIED: 11 Dec 2006 Hammag - REASON: - added PUdpChatChannels - -*/ - -#include "main.h" -#include "udp_chat.h" +#include "GameServer/Decoder/Includes.hxx" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" /**** PUdpChatLocal ****/ PUdpChatLocal::PUdpChatLocal(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData) { nDecodeData->mName << "/0x1b"; -} +} PUdpMsgAnalyser* PUdpChatLocal::Analyse() { mDecodeData->mName << "=Local chat"; mDecodeData->mState = DECODE_ACTION_READY | DECODE_FINISHED; - + return this; } @@ -53,11 +22,11 @@ bool PUdpChatLocal::DoAction() // temp Chat->HandleGameChat(mDecodeData->mClient, mDecodeData->mMessage->GetMessageData() + mDecodeData->Sub0x13Start); /*PMessage* cMsg = mDecodeData->mMessage; - u32 ClientTime = cMsg->U32Data(mDecodeData->Sub0x13Start+2); - + uint32_t ClientTime = cMsg->U32Data(mDecodeData->Sub0x13Start+2); + PMessage* tmpMsg = MsgBuilder->BuildPingMsg(mDecodeData->mClient, ClientTime); mDecodeData->mClient->SendUDPMessage(tmpMsg);*/ - + //cMsg->SetNextByteOffset(mDecodeData->Sub0x13StartNext); mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED; return true; @@ -68,16 +37,16 @@ bool PUdpChatLocal::DoAction() PUdpChatGlobal::PUdpChatGlobal(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData) { nDecodeData->mName << "/0x3b"; -} +} PUdpMsgAnalyser* PUdpChatGlobal::Analyse() { - //u16 dumb; + //uint16_t dumb; mDecodeData->mName << "=Global chat"; /* PMessage* nMsg = mDecodeData->mMessage; nMsg->SetNextByteOffset(mDecodeData->Sub0x13Start + 12); - *nMsg >> mVehicleID; // ? not u32 ??? + *nMsg >> mVehicleID; // ? not uint32_t ??? *nMsg >> dumb; *nMsg >> mVehicleSeat;*/ @@ -101,16 +70,16 @@ bool PUdpChatGlobal::DoAction() PUdpChatListAdd::PUdpChatListAdd(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData) { nDecodeData->mName << "/0x33"; -} +} PUdpMsgAnalyser* PUdpChatListAdd::Analyse() { mDecodeData->mName << "=Add char to chat list"; PMessage* nMsg = mDecodeData->mMessage; - u8 PSize = nMsg->U8Data(mDecodeData->Sub0x13Start); + uint8_t PSize = nMsg->U8Data(mDecodeData->Sub0x13Start); mChatList = mDecodeData->mMessage->U8Data(mDecodeData->Sub0x13Start + 8); - + if ((mChatList == 1) || (mChatList == 2)) { if ((PSize > 8) && (nMsg->U8Data(mDecodeData->Sub0x13StartNext -1) == 0)) @@ -123,7 +92,7 @@ PUdpMsgAnalyser* PUdpChatListAdd::Analyse() mDecodeData->mState = DECODE_ERROR; mDecodeData->mErrorDetail = "Invalid charname position"; } - + return this; } else @@ -138,9 +107,9 @@ bool PUdpChatListAdd::DoAction() PClient* nClient = mDecodeData->mClient; std::string AddedChar = mAddedCharname; PChar* tChar = Chars->GetChar(AddedChar); - u32 AddedCharID = (tChar ? tChar->GetID() : 0); + uint32_t AddedCharID = (tChar ? tChar->GetID() : 0); bool AddResult = false; - + if (AddedCharID) { switch(mChatList) @@ -148,22 +117,22 @@ bool PUdpChatListAdd::DoAction() case 1: { AddResult = nClient->GetChar()->SetDirectChat(AddedCharID); - break; + break; } case 2: { AddResult = nClient->GetChar()->AddBuddy(AddedCharID); - break; + break; } } } - + if (AddResult) { PMessage* tmpMsg = MsgBuilder->BuildChatAddMsg (nClient, AddedCharID, mChatList); nClient->SendUDPMessage(tmpMsg); } - + mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED; return true; } @@ -173,7 +142,7 @@ bool PUdpChatListAdd::DoAction() PUdpChatListRemove::PUdpChatListRemove(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData) { nDecodeData->mName << "/0x39"; -} +} PUdpMsgAnalyser* PUdpChatListRemove::Analyse() { @@ -182,7 +151,7 @@ PUdpMsgAnalyser* PUdpChatListRemove::Analyse() PMessage* nMsg = mDecodeData->mMessage; nMsg->SetNextByteOffset(mDecodeData->Sub0x13Start + 8); (*nMsg) >> mChatList; - + if ((mChatList == 1) || (mChatList == 2)) { (*nMsg) >> mRemovedCharID; @@ -199,9 +168,9 @@ PUdpMsgAnalyser* PUdpChatListRemove::Analyse() bool PUdpChatListRemove::DoAction() { PClient* nClient = mDecodeData->mClient; - + bool RemoveResult = false; - + if (mRemovedCharID) { switch(mChatList) @@ -209,23 +178,23 @@ bool PUdpChatListRemove::DoAction() case 1: { RemoveResult = nClient->GetChar()->SetDirectChat(0); - break; + break; } case 2: { RemoveResult = nClient->GetChar()->RemoveBuddy(mRemovedCharID); - break; + break; } } } - + // No known response yet ... /*if (AddResult) { PMessage* tmpMsg = MsgBuilder->BuildChatAddMsg (nClient, mRemovedCharID, mChatList); nClient->SendUDPMessage(tmpMsg); }*/ - + mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED; return true; } @@ -235,7 +204,7 @@ bool PUdpChatListRemove::DoAction() PUdpChatChannels::PUdpChatChannels(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData) { nDecodeData->mName << "/0x4c"; -} +} PUdpMsgAnalyser* PUdpChatChannels::Analyse() { @@ -244,7 +213,7 @@ PUdpMsgAnalyser* PUdpChatChannels::Analyse() PMessage* nMsg = mDecodeData->mMessage; nMsg->SetNextByteOffset(mDecodeData->Sub0x13Start + 8); (*nMsg) >> mChannelFlags; - + mDecodeData->mState = DECODE_ACTION_READY | DECODE_FINISHED; return this; } diff --git a/TinNS/Source/GameServer/Decoder/UdpChat.hxx b/TinNS/Source/GameServer/Decoder/UdpChat.hxx new file mode 100644 index 0000000..5abf6d8 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpChat.hxx @@ -0,0 +1,55 @@ +#pragma once + +#include +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PUdpChatLocal : public PUdpMsgAnalyser { +public: + PUdpChatLocal(PMsgDecodeData *nDecodeData); + //~PUdpChatLocal(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; + +class PUdpChatGlobal : public PUdpMsgAnalyser { +public: + PUdpChatGlobal(PMsgDecodeData *nDecodeData); + //~PUdpChatGlobal(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; + +class PUdpChatListAdd : public PUdpMsgAnalyser { +private: + uint8_t mChatList; // 1 = Direct, 2 = Buddy List + char *mAddedCharname; + +public: + PUdpChatListAdd(PMsgDecodeData *nDecodeData); + //~PUdpChatListAdd(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; + +class PUdpChatListRemove : public PUdpMsgAnalyser { +private: + uint8_t mChatList; + uint32_t mRemovedCharID; + +public: + PUdpChatListRemove(PMsgDecodeData *nDecodeData); + //~PUdpChatListRemove(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; + +class PUdpChatChannels : public PUdpMsgAnalyser { +private: + uint32_t mChannelFlags; // 1 bit per custom channel, starting from LSB, in same order as in chat i/f + +public: + PUdpChatChannels(PMsgDecodeData *nDecodeData); + //~PUdpChatChannels(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; diff --git a/server/src/game/decoder/udp_deathrespawn.cpp b/TinNS/Source/GameServer/Decoder/UdpDeathRespawn.cxx similarity index 53% rename from server/src/game/decoder/udp_deathrespawn.cpp rename to TinNS/Source/GameServer/Decoder/UdpDeathRespawn.cxx index b6dd979..b8f903f 100644 --- a/server/src/game/decoder/udp_deathrespawn.cpp +++ b/TinNS/Source/GameServer/Decoder/UdpDeathRespawn.cxx @@ -1,38 +1,5 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_deathrespawn.cpp - decoder classes for UDP respawn selection after death message - - CREATION: 10 May 2009 Hammag - - MODIFIED: - REASON: - - -*/ - -#include "main.h" -#include "udp_deathrespawn.h" -#include "udp_zoning.h" +#include "GameServer/Decoder/Includes.hxx" +#include "Common/Includes.hxx" /**** PUdpDeathRespawn ****/ diff --git a/TinNS/Source/GameServer/Decoder/UdpDeathRespawn.hxx b/TinNS/Source/GameServer/Decoder/UdpDeathRespawn.hxx new file mode 100644 index 0000000..a95e14d --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpDeathRespawn.hxx @@ -0,0 +1,16 @@ +#pragma once + +#include +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PUdpDeathRespawn : public PUdpMsgAnalyser { +private: + uint32_t mEntity; + uint32_t mWorldId; + +public: + PUdpDeathRespawn(PMsgDecodeData *nDecodeData); + //~PUdpDeathRespawn(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; diff --git a/server/src/game/decoder/udp_entityposreq.cpp b/TinNS/Source/GameServer/Decoder/UdpEntityPositionRequest.cxx similarity index 61% rename from server/src/game/decoder/udp_entityposreq.cpp rename to TinNS/Source/GameServer/Decoder/UdpEntityPositionRequest.cxx index 9e314f9..4c17db7 100644 --- a/server/src/game/decoder/udp_entityposreq.cpp +++ b/TinNS/Source/GameServer/Decoder/UdpEntityPositionRequest.cxx @@ -1,42 +1,6 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - udp_entityposreq.cpp - decoder classes for UDP entity position request messages - - CREATION: 8 jun 2007 Hammag - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "udp_entityposreq.h" - -#include "include/worlds.h" - +#include "GameServer/Decoder/Includes.hxx" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" PUdpEntityPosRequest::PUdpEntityPosRequest(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData) { @@ -53,7 +17,7 @@ PUdpMsgAnalyser* PUdpEntityPosRequest::Analyse() PMessage* nMsg = mDecodeData->mMessage; nMsg->SetNextByteOffset(mDecodeData->Sub0x13Start + 7); - *nMsg >> mEntityID; //(u16 ... or u32 ???) + *nMsg >> mEntityID; //(uint16_t ... or uint32_t ???) if(mEntityID >= WORLDDATATEMPLATE_MAXPOSITEMS) { @@ -75,16 +39,16 @@ bool PUdpEntityPosRequest::DoAction() PClient* nClient = mDecodeData->mClient; PChar* nChar = nClient->GetChar(); PWorld* currentWorld = Worlds->GetWorld(nChar->GetLocation()); - f32 fpX, fpY, fpZ; - u16 pX, pY, pZ; + float fpX, fpY, fpZ; + uint16_t pX, pY, pZ; if(currentWorld) { if((mEntityID < WORLDDATATEMPLATE_MAXPOSITEMS) && currentWorld->getPositionItemPosition(mEntityID, &fpX, &fpY, &fpZ)) { - pX = (u16) (fpX + 32000); - pY = (u16) (fpY + 32000); - pZ = (u16) (fpZ + 32000); + pX = (uint16_t) (fpX + 32000); + pY = (uint16_t) (fpY + 32000); + pZ = (uint16_t) (fpZ + 32000); if(gDevDebug) Console->Print(GREEN, BLACK, "Client %d - Sending pos for entity %d : X=%d Y=%d Z=%d", mDecodeData->mClient->GetID(), mEntityID, pX, pY, pZ); } @@ -93,7 +57,7 @@ if(gDevDebug) Console->Print(GREEN, BLACK, "Client %d - Sending pos for entity % pX = pY = pZ = 0; Console->Print("%s Client[%d] requested invalid position entity %d. Position reset.", Console->ColorText(YELLOW, BLACK, "[Notice]"), mDecodeData->mClient->GetID(), mEntityID); } - + PMessage* tmpMsg; tmpMsg = MsgBuilder->BuildEntityPositionMsg(nClient, pX, pY, pZ); nClient->SendUDPMessage(tmpMsg); diff --git a/TinNS/Source/GameServer/Decoder/UdpEntityPositionRequest.hxx b/TinNS/Source/GameServer/Decoder/UdpEntityPositionRequest.hxx new file mode 100644 index 0000000..a483d36 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpEntityPositionRequest.hxx @@ -0,0 +1,15 @@ +#pragma once + +#include +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PUdpEntityPosRequest : public PUdpMsgAnalyser { +private: + uint16_t mEntityID; // u16 or u32 ??? + +public: + PUdpEntityPosRequest(PMsgDecodeData *nDecodeData); + //~PUdpEntityPosRequest(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; diff --git a/server/src/game/decoder/udp_hack.cpp b/TinNS/Source/GameServer/Decoder/UdpHack.cxx similarity index 72% rename from server/src/game/decoder/udp_hack.cpp rename to TinNS/Source/GameServer/Decoder/UdpHack.cxx index e28f92f..35473c0 100644 --- a/server/src/game/decoder/udp_hack.cpp +++ b/TinNS/Source/GameServer/Decoder/UdpHack.cxx @@ -1,43 +1,7 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - udp_hack.cpp - decoder classes for UDP hacking related messages - - CREATION: 30 Dec 2006 Namikon - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "udp_hack.h" - -#include "include/worlds.h" -#include "include/furnituretemplate.h" -#include "include/doortemplate.h" +#include "GameServer/Decoder/Includes.hxx" +#include "GameServer/Definitions/Includes.hxx" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" /**** PUdpHackSuccess ****/ @@ -62,7 +26,7 @@ bool PUdpHackSuccess::DoAction() const PFurnitureItemTemplate* tFurnitureTemplate = NULL; const PDefWorldModel* tFurnitureModel = NULL; - u32 mRawItemID = mDecodeData->mMessage->U32Data(mDecodeData->Sub0x13Start+8); + uint32_t mRawItemID = mDecodeData->mMessage->U32Data(mDecodeData->Sub0x13Start+8); if(gDevDebug) Console->Print("DEBUG: Client %d successfully hacked object %d", mDecodeData->mClient->GetID(), mRawItemID); bool tHandleDynamicActor = false; @@ -79,7 +43,7 @@ bool PUdpHackSuccess::DoAction() else { // Dat files have smaller IDs - u32 ItemID = mRawItemID/1024 -1; + uint32_t ItemID = mRawItemID/1024 -1; // Now grab the template from .dat file tFurnitureTemplate = CurrentWorld->GetFurnitureItemTemplate(ItemID); diff --git a/TinNS/Source/GameServer/Decoder/UdpHack.hxx b/TinNS/Source/GameServer/Decoder/UdpHack.hxx new file mode 100644 index 0000000..bf8eccb --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpHack.hxx @@ -0,0 +1,19 @@ +#pragma once + +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PUdpHackFail : public PUdpMsgAnalyser { +public: + PUdpHackFail(PMsgDecodeData *nDecodeData); + //~PUdpHackFail(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; + +class PUdpHackSuccess : public PUdpMsgAnalyser { +public: + PUdpHackSuccess(PMsgDecodeData *nDecodeData); + //~PUdpHackSuccess(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; diff --git a/server/src/game/decoder/udp_helditemaction.cpp b/TinNS/Source/GameServer/Decoder/UdpHeldItemAction.cxx similarity index 83% rename from server/src/game/decoder/udp_helditemaction.cpp rename to TinNS/Source/GameServer/Decoder/UdpHeldItemAction.cxx index d5436dd..e0c0a35 100644 --- a/server/src/game/decoder/udp_helditemaction.cpp +++ b/TinNS/Source/GameServer/Decoder/UdpHeldItemAction.cxx @@ -1,39 +1,7 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_helditemaction.cpp - decoder classes for held item related messages - - CREATION: 20 Mar 2009 Hammag - - MODIFIED: - REASON: - - -*/ - -#include "main.h" -#include "udp_helditemaction.h" -#include "include/worlds.h" -#include "include/furnituretemplate.h" +#include "GameServer/Decoder/Includes.hxx" +#include "GameServer/Definitions/Includes.hxx" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" /**** PUdpHeldItemBasicAction ****/ @@ -84,7 +52,7 @@ PUdpMsgAnalyser* PUdpHeldItemAimedAction::Analyse() bool PUdpHeldItemAimedAction::DoAction() { - u16 maxBroadcastDistance = 0; // parameter. + uint16_t maxBroadcastDistance = 0; // parameter. PClient* nClient = mDecodeData->mClient; //PChar* tChar = nClient->GetChar(); // PCharCoordinates& nCharCoords = nClient->GetChar()->Coords; @@ -167,7 +135,7 @@ bool PUdpHeldItemLaunchingAction::DoAction() const PFurnitureItemTemplate* tFurnitureTemplate = NULL; const PDefWorldModel* tFurnitureModel = NULL; - u32 mRawItemID = mDecodeData->mMessage->U32Data( mDecodeData->Sub0x13Start + 24 ); + uint32_t mRawItemID = mDecodeData->mMessage->U32Data( mDecodeData->Sub0x13Start + 24 ); //if(gDevDebug) Console->Print("Client %d wants to hack itemID %d ***not managed yet***", mDecodeData->mClient->GetID(), mRawItemID); // First try to find out if we're hacking an dynamic actor @@ -182,7 +150,7 @@ bool PUdpHeldItemLaunchingAction::DoAction() else { // Dat files have smaller IDs - u32 ItemID = mRawItemID / 1024 - 1; + uint32_t ItemID = mRawItemID / 1024 - 1; // Now grab the template from .dat file tFurnitureTemplate = CurrentWorld->GetFurnitureItemTemplate( ItemID ); @@ -193,8 +161,8 @@ bool PUdpHeldItemLaunchingAction::DoAction() if ( tFurnitureModel ) // We have an valid worldobject? Fine. Then start the hackgame { - u8 tHackDifficult = tFurnitureModel->GetHackDifficulty(); - u8 tHackPenalty = tFurnitureModel->GetHackPenalty(); + uint8_t tHackDifficult = tFurnitureModel->GetHackDifficulty(); + uint8_t tHackPenalty = tFurnitureModel->GetHackPenalty(); // Print it! if(tHackDifficult) diff --git a/TinNS/Source/GameServer/Decoder/UdpHeldItemAction.hxx b/TinNS/Source/GameServer/Decoder/UdpHeldItemAction.hxx new file mode 100644 index 0000000..e12ee6a --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpHeldItemAction.hxx @@ -0,0 +1,57 @@ +#pragma once + +#include +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PUdpHeldItemBasicAction : public PUdpMsgAnalyser { +public: + PUdpHeldItemBasicAction(PMsgDecodeData *nDecodeData); + //~PUdpHeldItemBasicAction(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; + +class PUdpHeldItemAimedAction : public PUdpMsgAnalyser { +private: + uint16_t mWeaponId; + uint32_t mTargetRawItemID; + uint8_t mAiming; // 0: minimal + uint8_t mTargetedHeight; // 0: bottom to 26: top + uint8_t mScore; // ??? looks quite random... + +public: + PUdpHeldItemAimedAction(PMsgDecodeData *nDecodeData); + //~PUdpHeldItemAimedAction(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; + +class PUdpHeldItemLaunchingAction : public PUdpMsgAnalyser { +private: + uint16_t mWeaponId; + uint16_t mSourceY; + uint16_t mSourceZ; + uint16_t mSourceX; + uint8_t mSourceUD; + uint8_t mSourceLR; + uint16_t mUnknown1; + uint32_t mUnknown2; // client timestamp ? => TODO: compare with data from ping request + uint32_t mTargetRawItemID; + +public: + PUdpHeldItemLaunchingAction( PMsgDecodeData *nDecodeData ); + //~PUdpHeldItemLaunchingAction(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; + +class PUdpItemAddonActivation : public PUdpMsgAnalyser { +private: + uint8_t mAddonIdx; + +public: + PUdpItemAddonActivation(PMsgDecodeData *nDecodeData); + //~PUdpItemAddonActivation(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; diff --git a/server/src/game/decoder/udp_itemmanualreload.cpp b/TinNS/Source/GameServer/Decoder/UdpItemManualReload.cxx similarity index 60% rename from server/src/game/decoder/udp_itemmanualreload.cpp rename to TinNS/Source/GameServer/Decoder/UdpItemManualReload.cxx index f507d0e..3c81a4a 100644 --- a/server/src/game/decoder/udp_itemmanualreload.cpp +++ b/TinNS/Source/GameServer/Decoder/UdpItemManualReload.cxx @@ -1,42 +1,7 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - udp_itemmanualreload.cpp - decoder classes for UDP item manual reload messages - - CREATION: 9 May 2009 Hammag - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "udp_itemmanualreload.h" - -#include "include/container.h" - +#include "GameServer/Decoder/Includes.hxx" +#include "GameServer/Definitions/Includes.hxx" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" /**** PUdpItemManualReload ****/ @@ -63,14 +28,14 @@ bool PUdpItemManualReload::DoAction() { PClient* nClient = mDecodeData->mClient; PChar* tChar = nClient->GetChar(); - + if ( gDevDebug ) Console->Print( "%s Manual reload start", Console->ColorText( CYAN, BLACK, "[DEBUG]" ) ); - u8 activeSlot = tChar->GetQuickBeltActiveSlot(); + uint8_t activeSlot = tChar->GetQuickBeltActiveSlot(); if (( activeSlot != INV_WORN_QB_NONE ) && ( activeSlot != INV_WORN_QB_HAND ) ) { - u8 newAmmoCount = GetMaxLoadableAmmos( activeSlot ); + uint8_t newAmmoCount = GetMaxLoadableAmmos( activeSlot ); if ( newAmmoCount ) { PMessage* tmpMsg = MsgBuilder->BuildStartWeaponReloadMsg( nClient ); @@ -79,27 +44,27 @@ bool PUdpItemManualReload::DoAction() tmpMsg = new PMessage( 32 ); nClient->IncreaseUDP_ID(); - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x00; // Message length - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x25; - *tmpMsg << ( u8 )0x13; + *tmpMsg << ( uint8_t )0x00; // Message length + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x25; + *tmpMsg << ( uint8_t )0x13; nClient->IncreaseTransactionID(); - *tmpMsg << ( u16 )nClient->GetTransactionID(); - *tmpMsg << ( u8 )0x05; // cmd=Ammo count update - *tmpMsg << ( u8 )INV_LOC_WORN; - *tmpMsg << ( u8 )(INV_WORN_QB_START + activeSlot); // X - *tmpMsg << ( u8 )0x00; //(Y) - *tmpMsg << ( u8 )newAmmoCount; // Ammo count + *tmpMsg << ( uint16_t )nClient->GetTransactionID(); + *tmpMsg << ( uint8_t )0x05; // cmd=Ammo count update + *tmpMsg << ( uint8_t )INV_LOC_WORN; + *tmpMsg << ( uint8_t )(INV_WORN_QB_START + activeSlot); // X + *tmpMsg << ( uint8_t )0x00; //(Y) + *tmpMsg << ( uint8_t )newAmmoCount; // Ammo count - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); nClient->SendUDPMessage( tmpMsg ); } @@ -115,40 +80,40 @@ bool PUdpItemManualReload::DoAction() nClient->IncreaseUDP_ID(); nClient->IncreaseTransactionID(); - *tmpMsg << (u8)0x13; - *tmpMsg << (u16)nClient->GetUDP_ID(); - *tmpMsg << (u16)nClient->GetSessionID(); - - *tmpMsg << (u8)0x00; // Message length - *tmpMsg << (u8)0x03; - *tmpMsg << (u16)nClient->GetUDP_ID(); - *tmpMsg << (u8)0x1f; - *tmpMsg << (u16)nClient->GetLocalID(); - *tmpMsg << (u8)0x25; - *tmpMsg << (u8)0x13; - *tmpMsg << (u16)nClient->GetTransactionID(); - *tmpMsg << (u8)0x0a; // cmd=Ammo type update (?) - *tmpMsg << (u8)0x03; - *tmpMsg << (u8)0x02; - *tmpMsg << (u8)0x00; - *tmpMsg << (u8)0x00; - *tmpMsg << (u8)0x00; + *tmpMsg << (uint8_t)0x13; + *tmpMsg << (uint16_t)nClient->GetUDP_ID(); + *tmpMsg << (uint16_t)nClient->GetSessionID(); + + *tmpMsg << (uint8_t)0x00; // Message length + *tmpMsg << (uint8_t)0x03; + *tmpMsg << (uint16_t)nClient->GetUDP_ID(); + *tmpMsg << (uint8_t)0x1f; + *tmpMsg << (uint16_t)nClient->GetLocalID(); + *tmpMsg << (uint8_t)0x25; + *tmpMsg << (uint8_t)0x13; + *tmpMsg << (uint16_t)nClient->GetTransactionID(); + *tmpMsg << (uint8_t)0x0a; // cmd=Ammo type update (?) + *tmpMsg << (uint8_t)0x03; + *tmpMsg << (uint8_t)0x02; + *tmpMsg << (uint8_t)0x00; + *tmpMsg << (uint8_t)0x00; + *tmpMsg << (uint8_t)0x00; nClient->IncreaseTransactionID(); - *tmpMsg << (u16)nClient->GetTransactionID(); - *tmpMsg << (u8)0x05; // cmd=Ammo count update - *tmpMsg << (u8)INV_LOC_BACKPACK; - *tmpMsg << (u8)0x0e; // X - *tmpMsg << (u8)0x00; //(Y) - *tmpMsg << (u8)0x03; // Ammo count + *tmpMsg << (uint16_t)nClient->GetTransactionID(); + *tmpMsg << (uint8_t)0x05; // cmd=Ammo count update + *tmpMsg << (uint8_t)INV_LOC_BACKPACK; + *tmpMsg << (uint8_t)0x0e; // X + *tmpMsg << (uint8_t)0x00; //(Y) + *tmpMsg << (uint8_t)0x03; // Ammo count nClient->IncreaseTransactionID(); - *tmpMsg << (u16)nClient->GetTransactionID(); - *tmpMsg << (u8)0x05; // cmd=Ammo count update - *tmpMsg << (u8)INV_LOC_WORN; - *tmpMsg << (u8)0x03; // X - *tmpMsg << (u8)0x00; //(Y) - *tmpMsg << (u8)0x02; // Ammo count - - (*tmpMsg)[5] = (u8)(tmpMsg->GetSize() - 6); + *tmpMsg << (uint16_t)nClient->GetTransactionID(); + *tmpMsg << (uint8_t)0x05; // cmd=Ammo count update + *tmpMsg << (uint8_t)INV_LOC_WORN; + *tmpMsg << (uint8_t)0x03; // X + *tmpMsg << (uint8_t)0x00; //(Y) + *tmpMsg << (uint8_t)0x02; // Ammo count + + (*tmpMsg)[5] = (uint8_t)(tmpMsg->GetSize() - 6); tmpMsg->Dump(); nClient->SendUDPMessage(tmpMsg); */ @@ -157,7 +122,7 @@ bool PUdpItemManualReload::DoAction() c2:01:0a:00:02:00:00:00 ?? set ammo type ? c3:01:05:03:00:00:12 Update ammo left c4:01:05:02:00:00:0c Update ammo left - + tt:tt:02:loc:x:y delete item */ @@ -173,7 +138,7 @@ bool PUdpItemManualReload::DoAction() return true; } -u8 PUdpItemManualReload::GetMaxLoadableAmmos( u8 nBeltSlotId ) +uint8_t PUdpItemManualReload::GetMaxLoadableAmmos( uint8_t nBeltSlotId ) { PItem* activeItem = mDecodeData->mClient->GetChar()->GetInventory()->GetContainer( INV_DB_LOC_WORN )->GetItem( INV_WORN_QB_START + nBeltSlotId ); if ( activeItem && ( activeItem->GetType() == ITEM_TYPE_WEAPON ) ) diff --git a/TinNS/Source/GameServer/Decoder/UdpItemManualReload.hxx b/TinNS/Source/GameServer/Decoder/UdpItemManualReload.hxx new file mode 100644 index 0000000..53a5c11 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpItemManualReload.hxx @@ -0,0 +1,24 @@ +#pragma once + +#include +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PUdpItemManualReload : public PUdpMsgAnalyser { +private: + uint8_t mUnknown; + uint8_t GetMaxLoadableAmmos(uint8_t nBeltSlotId); + +public: + PUdpItemManualReload(PMsgDecodeData *nDecodeData); + //~PUdpItemManualReload(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; + +class PUdpReloadAnimStart : public PUdpMsgAnalyser { +public: + PUdpReloadAnimStart(PMsgDecodeData *nDecodeData); + //~PUdpReloadAnimStart(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; diff --git a/server/src/game/decoder/udp_itemmove.cpp b/TinNS/Source/GameServer/Decoder/UdpItemMove.cxx similarity index 82% rename from server/src/game/decoder/udp_itemmove.cpp rename to TinNS/Source/GameServer/Decoder/UdpItemMove.cxx index 5a1f56a..bd868ad 100644 --- a/server/src/game/decoder/udp_itemmove.cpp +++ b/TinNS/Source/GameServer/Decoder/UdpItemMove.cxx @@ -1,46 +1,6 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - udp_itemmove.cpp - decoder classes for UDP item move related messages - - CREATION: 30 Dec 2006 Namikon - - MODIFIED: 28 Aug 2007 Hammag - REASON: - Moved decoding part from DoAction() to Analyse(), use natural decode methods - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "udp_itemmove.h" - -#include "include/chars.h" -#include "include/inventory.h" -#include "include/container.h" - +#include "GameServer/Decoder/Includes.hxx" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" /**** PUdpItemMove ****/ @@ -77,8 +37,8 @@ bool PUdpItemMove::DoAction() bool MoveSucceded = false; PClient* nClient = mDecodeData->mClient; PChar* tChar = nClient->GetChar(); - u8 origDstX = mDstX; - u8 origDstY = mDstY; + uint8_t origDstX = mDstX; + uint8_t origDstY = mDstY; PContainerEntry* tEntry; PItem* tItem = NULL; @@ -169,7 +129,7 @@ bool PUdpItemMove::DoAction() return true; } -PContainer* PUdpItemMove::GetContainerByLoc( PChar* nChar, u8 nLoc ) +PContainer* PUdpItemMove::GetContainerByLoc( PChar* nChar, uint8_t nLoc ) { PContainer* tContainer = NULL; diff --git a/TinNS/Source/GameServer/Decoder/UdpItemMove.hxx b/TinNS/Source/GameServer/Decoder/UdpItemMove.hxx new file mode 100644 index 0000000..4cbd9cf --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpItemMove.hxx @@ -0,0 +1,55 @@ +#pragma once + +#include +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PContainer; + +class PUdpItemMove : public PUdpMsgAnalyser { +private: + uint8_t mSrcLoc; + uint8_t mSrcX; + uint8_t mSrcY; + uint8_t mDstLoc; + uint8_t mDstX; + uint8_t mDstY; + uint8_t mItemCnt; + +public: + PUdpItemMove(PMsgDecodeData *nDecodeData); + //~PUdpItemMove(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); + + static PContainer *GetContainerByLoc(PChar *nChar, uint8_t nLoc); +}; + +class PUdpItemMoveBP : public PUdpMsgAnalyser { +private: + uint8_t mSrcSlotId; + uint8_t mDumb; + uint8_t mDstX; + uint8_t mDstY; + +public: + PUdpItemMoveBP(PMsgDecodeData *nDecodeData); + //~PUdpItemMove(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; + +class PUdpItemDropOnItem : public PUdpMsgAnalyser { +private: + uint8_t mSrcLoc; + uint8_t mSrcX; + uint8_t mSrcY; + uint8_t mDstLoc; + uint8_t mDstX; + uint8_t mDstY; + +public: + PUdpItemDropOnItem(PMsgDecodeData *nDecodeData); + //~PUdpItemDropOnItem(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; diff --git a/server/src/game/decoder/udp_itemuse.cpp b/TinNS/Source/GameServer/Decoder/UdpItemUse.cxx similarity index 56% rename from server/src/game/decoder/udp_itemuse.cpp rename to TinNS/Source/GameServer/Decoder/UdpItemUse.cxx index 4f7eed9..237dcf7 100644 --- a/server/src/game/decoder/udp_itemuse.cpp +++ b/TinNS/Source/GameServer/Decoder/UdpItemUse.cxx @@ -1,38 +1,5 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_itemuse.cpp - decoder classes for UDP inventory item use messages - - CREATION: 9 May 2009 Hammag - - MODIFIED: - REASON: - - -*/ - -#include "main.h" -#include "udp_itemuse.h" - +#include "GameServer/Decoder/Includes.hxx" +#include "Common/Includes.hxx" /**** PUdpItemUse ****/ diff --git a/TinNS/Source/GameServer/Decoder/UdpItemUse.hxx b/TinNS/Source/GameServer/Decoder/UdpItemUse.hxx new file mode 100644 index 0000000..a211936 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpItemUse.hxx @@ -0,0 +1,18 @@ +#pragma once + +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PUdpItemUse : public PUdpMsgAnalyser { +/* private: + u16 mWeaponId; + u32 mTargetRawItemID; + u8 mUnknown2; + u8 mTargetedHeight; + u8 mScore; // ??? looks quite random... +*/ +public: + PUdpItemUse(PMsgDecodeData *nDecodeData); + //~PUdpItemUse(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; diff --git a/TinNS/Source/GameServer/Decoder/UdpKillSelf.cxx b/TinNS/Source/GameServer/Decoder/UdpKillSelf.cxx new file mode 100644 index 0000000..e0d3307 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpKillSelf.cxx @@ -0,0 +1,34 @@ +#include "GameServer/Decoder/Includes.hxx" +#include "GameServer/Includes.hxx" + +PUdpKillSelf::PUdpKillSelf( PMsgDecodeData* nDecodeData ) : PUdpMsgAnalyser( nDecodeData ) +{ + nDecodeData->mName << "/0x10"; +} + +PUdpMsgAnalyser* PUdpKillSelf::Analyse() +{ + mDecodeData->mName << "=Char Kill self"; + + mDecodeData->mState = DECODE_ACTION_READY | DECODE_FINISHED; + return this; +} + +bool PUdpKillSelf::DoAction() +{ + PClient* nClient = mDecodeData->mClient; + + PMessage* tmpMsg = MsgBuilder->BuildCharDeathMsg( nClient, 0 ); + ClientManager->UDPBroadcast( tmpMsg, nClient ); + + mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED; + return true; + + /* Server resp: + 13:a8:00:a8:e2: + 16: 03:a5:00:1b:01:10:00:80:24:ea:7c:cb:80:25:77:80:86:80:62:00:01:00: // Spwan belt object (?) + 09: 03:a6:00:1f:01:00:25:23:1c: // "UndefinedUseMsg" with arg 0x1c + 0b: 03:a7:00:1f:01:00:16:00:00:00:00: // Char Dead status + 0e: 03:a8:00:1f:01:00:25:13:10:19:02:02:0d:00 // Inventory delete item (=item dropped to belt) + */ +} diff --git a/TinNS/Source/GameServer/Decoder/UdpKillSelf.hxx b/TinNS/Source/GameServer/Decoder/UdpKillSelf.hxx new file mode 100644 index 0000000..9f64ae2 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpKillSelf.hxx @@ -0,0 +1,11 @@ +#pragma once + +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PUdpKillSelf : public PUdpMsgAnalyser { +public: + PUdpKillSelf(PMsgDecodeData *nDecodeData); + //~PUdpKillSelf(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; diff --git a/server/src/game/decoder/udp_multipart.cpp b/TinNS/Source/GameServer/Decoder/UdpMultiPart.cxx similarity index 54% rename from server/src/game/decoder/udp_multipart.cpp rename to TinNS/Source/GameServer/Decoder/UdpMultiPart.cxx index be79334..a2087bf 100644 --- a/server/src/game/decoder/udp_multipart.cpp +++ b/TinNS/Source/GameServer/Decoder/UdpMultiPart.cxx @@ -1,37 +1,6 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_multipart.cpp - decoder classes for UDP multipart messages (0x07) - - CREATION: 25 Oct 2009 Namikon - - MODIFIED: - REASON: - - -*/ - -#include "main.h" -#include "udp_multipart.h" +#include "GameServer/Decoder/Includes.hxx" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" /**** PUdpMultiPart ****/ @@ -46,7 +15,7 @@ PUdpMsgAnalyser* PUdpMultiPart::Analyse() PMessage* TmpMsg = mDecodeData->mMessage; - u8 tChunkSize = 0; + uint8_t tChunkSize = 0; ( *TmpMsg ) >> tChunkSize; TmpMsg->SetNextByteOffset( mDecodeData->Sub0x13Start + 5 ); diff --git a/TinNS/Source/GameServer/Decoder/UdpMultiPart.hxx b/TinNS/Source/GameServer/Decoder/UdpMultiPart.hxx new file mode 100644 index 0000000..f89977e --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpMultiPart.hxx @@ -0,0 +1,18 @@ +#pragma once + +#include +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PUdpMultiPart : public PUdpMsgAnalyser { +private: + uint16_t mChunkNr; + uint16_t mChunkTotal; + uint8_t mSequence; + PMessage *mChunk; + +public: + PUdpMultiPart(PMsgDecodeData *nDecodeData); + //~PUdpPing(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; diff --git a/server/src/game/decoder/udp_npcdialog.cpp b/TinNS/Source/GameServer/Decoder/UdpNpcDialog.cxx similarity index 79% rename from server/src/game/decoder/udp_npcdialog.cpp rename to TinNS/Source/GameServer/Decoder/UdpNpcDialog.cxx index 0855db8..75aad3e 100644 --- a/server/src/game/decoder/udp_npcdialog.cpp +++ b/TinNS/Source/GameServer/Decoder/UdpNpcDialog.cxx @@ -1,37 +1,6 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_npcdialog.cpp - decoder classes for UDP NPC Dialog-Messages - - CREATION: 13 Oct 2009 Namikon - - MODIFIED: - REASON: - - -*/ - -#include "main.h" -#include "udp_npcdialog.h" +#include "GameServer/Decoder/Includes.hxx" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" /**** PUdpNPCDialogClose ****/ diff --git a/TinNS/Source/GameServer/Decoder/UdpNpcDialog.hxx b/TinNS/Source/GameServer/Decoder/UdpNpcDialog.hxx new file mode 100644 index 0000000..014e9e1 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpNpcDialog.hxx @@ -0,0 +1,27 @@ +#pragma once + +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PUdpNPCDialogClose : public PUdpMsgAnalyser { +private: + uint16_t mPlayerID; + uint32_t mNPCID; + +public: + PUdpNPCDialogClose(PMsgDecodeData *nDecodeData); + //~PUdpNPCDialogClose(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; + +class PUdpNPCDialogAction : public PUdpMsgAnalyser { +private: + uint16_t mPlayerID; + uint8_t mAnswerNr; + +public: + PUdpNPCDialogAction(PMsgDecodeData *nDecodeData); + //~PUdpNPCDialogAction(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; diff --git a/TinNS/Source/GameServer/Decoder/UdpOOO.cxx b/TinNS/Source/GameServer/Decoder/UdpOOO.cxx new file mode 100644 index 0000000..5be7d73 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpOOO.cxx @@ -0,0 +1,29 @@ +#include "GameServer/Decoder/Includes.hxx" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" + +/**** PUdpOOO ****/ + +PUdpOOO::PUdpOOO(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData) +{ + nDecodeData->mName << "/0x01"; +} + +PUdpMsgAnalyser* PUdpOOO::Analyse() +{ + mDecodeData->mName << "=Out Of Order"; + mDecodeData->mState = DECODE_ACTION_READY | DECODE_FINISHED; + + return this; +} + +bool PUdpOOO::DoAction() +{ + uint16_t MissingUDP_ID = mDecodeData->mMessage->U16Data(mDecodeData->Sub0x13Start+5); + + mDecodeData->mClient->getUDPConn()->ReSendUDPMessage(MissingUDP_ID); + //Console->Print("%s Out of Order packet received ! (Client is missing UDPID %d) ***not managed yet***", Console->ColorText(YELLOW, BLACK, "[Notice]"), MissingUDP_ID); + + mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED; + return true; +} diff --git a/TinNS/Source/GameServer/Decoder/UdpOOO.hxx b/TinNS/Source/GameServer/Decoder/UdpOOO.hxx new file mode 100644 index 0000000..89c759c --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpOOO.hxx @@ -0,0 +1,11 @@ +#pragma once + +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PUdpOOO : public PUdpMsgAnalyser { +public: + PUdpOOO(PMsgDecodeData *nDecodeData); + //~PUdpPing(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; diff --git a/TinNS/Source/GameServer/Decoder/UdpOutfitter.cxx b/TinNS/Source/GameServer/Decoder/UdpOutfitter.cxx new file mode 100644 index 0000000..5a37704 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpOutfitter.cxx @@ -0,0 +1,53 @@ +#include "GameServer/Decoder/Includes.hxx" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" + +/**** PUdpOutfitter ****/ + +PUdpOutfitter::PUdpOutfitter(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData) +{ + nDecodeData->mName << "/0x2e"; +} + +PUdpMsgAnalyser* PUdpOutfitter::Analyse() +{ + mDecodeData->mName << "=Outfitter validation"; + + uint16_t tUnknown; + PMessage* nMsg = mDecodeData->mMessage; + nMsg->SetNextByteOffset(mDecodeData->Sub0x13Start + 8); + + (*nMsg) >> mSkin; + (*nMsg) >> tUnknown; + (*nMsg) >> mHead; + (*nMsg) >> mTorso; + (*nMsg) >> mLegs; + (*nMsg) >> mHeadColor; + (*nMsg) >> mTorsoColor; + (*nMsg) >> mLegsColor; + (*nMsg) >> mHeadDarkness; + (*nMsg) >> mTorsoDarkness; + (*nMsg) >> mLegsDarkness; + + mDecodeData->mState = DECODE_ACTION_READY | DECODE_FINISHED; + return this; +} + +bool PUdpOutfitter::DoAction() +{ + PClient* nClient = mDecodeData->mClient; + PChar* tChar = nClient->GetChar(); + + /* Some validity checks against char model and equipment can be done here */ + /* as well as payment */ + + tChar->SetCurrentLook(mSkin, mHead, mTorso, mLegs); + tChar->SetCurrentBodyColor(mHeadColor, mTorsoColor, mLegsColor, mHeadDarkness, mTorsoDarkness, mLegsDarkness); + + PMessage* tmpMsg = MsgBuilder->BuildCharHelloMsg(nClient); + ClientManager->UDPBroadcast(tmpMsg, nClient); + + + mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED; + return true; +} diff --git a/TinNS/Source/GameServer/Decoder/UdpOutfitter.hxx b/TinNS/Source/GameServer/Decoder/UdpOutfitter.hxx new file mode 100644 index 0000000..3dbe053 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpOutfitter.hxx @@ -0,0 +1,24 @@ +#pragma once + +#include +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PUdpOutfitter : public PUdpMsgAnalyser { +private: + uint32_t mSkin; + uint8_t mHead; + uint8_t mTorso; + uint8_t mLegs; + uint8_t mHeadColor; + uint8_t mTorsoColor; + uint8_t mLegsColor; + uint8_t mHeadDarkness; + uint8_t mTorsoDarkness; + uint8_t mLegsDarkness; + +public: + PUdpOutfitter(PMsgDecodeData *nDecodeData); + //~PUdpOutfitter(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; diff --git a/TinNS/Source/GameServer/Decoder/UdpPacket0.cxx b/TinNS/Source/GameServer/Decoder/UdpPacket0.cxx new file mode 100644 index 0000000..aa4feb7 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpPacket0.cxx @@ -0,0 +1,34 @@ +#include "GameServer/Decoder/Includes.hxx" +#include "GameServer/Includes.hxx" + +/**** PUdpPacket0 ****/ + +PUdpPacket0::PUdpPacket0(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData) +{ + nDecodeData->mName << "/0x2a"; +//nDecodeData->mTraceDump=true; +//mDecodeData->mTraceKnownMsg = true; +} + +PUdpMsgAnalyser* PUdpPacket0::Analyse() +{ + mDecodeData->mName << "=Packet0"; + mDecodeData->mState = DECODE_ACTION_READY | DECODE_FINISHED; + + return this; +} + +bool PUdpPacket0::DoAction() +{ + if (mDecodeData->mState & DECODE_ACTION_READY) + { + PMessage* tmpMsg = MsgBuilder->BuildPacket0Msg(mDecodeData->mClient); + mDecodeData->mClient->SendUDPMessage(tmpMsg); + + //mDecodeData->mMessage->SetNextByteOffset(mDecodeData->Sub0x13StartNext); + mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED; + return true; + } + else + return false; +} diff --git a/TinNS/Source/GameServer/Decoder/UdpPacket0.hxx b/TinNS/Source/GameServer/Decoder/UdpPacket0.hxx new file mode 100644 index 0000000..688815a --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpPacket0.hxx @@ -0,0 +1,11 @@ +#pragma once + +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PUdpPacket0 : public PUdpMsgAnalyser { +public: + PUdpPacket0(PMsgDecodeData *nDecodeData); + //~PUdpPacket0(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; diff --git a/TinNS/Source/GameServer/Decoder/UdpPing.cxx b/TinNS/Source/GameServer/Decoder/UdpPing.cxx new file mode 100644 index 0000000..022f756 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpPing.cxx @@ -0,0 +1,37 @@ +#include "GameServer/Decoder/Includes.hxx" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" + +/**** PUdpPing ****/ + +PUdpPing::PUdpPing( PMsgDecodeData* nDecodeData ) : PUdpMsgAnalyser( nDecodeData ) +{ + nDecodeData->mName << "/0x0b"; +} + +PUdpMsgAnalyser* PUdpPing::Analyse() +{ + mDecodeData->mName << "=Ping"; + + mClientTime = mDecodeData->mMessage->U32Data( mDecodeData->Sub0x13Start + 2 ); + + mDecodeData->mState = DECODE_ACTION_READY | DECODE_FINISHED; + return this; +} + +bool PUdpPing::DoAction() +{ + if ( mDecodeData->mState & DECODE_ACTION_READY ) + { + // if(gDevDebug) + // Console->Print( "%s PUdpPing: Client timestamp %d (0x%08x)", Console->ColorText( CYAN, BLACK, "[DEBUG]" ), mClientTime, mClientTime ); + + PMessage* tmpMsg = MsgBuilder->BuildPingMsg( mDecodeData->mClient, mClientTime ); + mDecodeData->mClient->SendUDPMessage( tmpMsg ); + + mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED; + return true; + } + else + return false; +} diff --git a/TinNS/Source/GameServer/Decoder/UdpPing.hxx b/TinNS/Source/GameServer/Decoder/UdpPing.hxx new file mode 100644 index 0000000..fdea776 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpPing.hxx @@ -0,0 +1,14 @@ +#pragma once + +#include +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PUdpPing : public PUdpMsgAnalyser { +private: + uint32_t mClientTime; + +public: + PUdpPing(PMsgDecodeData *nDecodeData); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; diff --git a/server/src/game/decoder/udp_popupresponse.cpp b/TinNS/Source/GameServer/Decoder/UdpPopupResponse.cxx similarity index 72% rename from server/src/game/decoder/udp_popupresponse.cpp rename to TinNS/Source/GameServer/Decoder/UdpPopupResponse.cxx index 3798b23..54587cc 100644 --- a/server/src/game/decoder/udp_popupresponse.cpp +++ b/TinNS/Source/GameServer/Decoder/UdpPopupResponse.cxx @@ -1,44 +1,7 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - udp_popupresponse.cpp - decoder classes for some UDP Popup response messages - - CREATION: 14 Apr 2009 Hammag - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "udp_popupresponse.h" -#include "udp_vhc.h" - -#include "include/vhcaccessrequest.h" -#include "include/worlds.h" - +#include "GameServer/Decoder/Includes.hxx" +#include "GameServer/Definitions/Includes.hxx" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" /**** PUdp0x1f ****/ @@ -51,7 +14,7 @@ PUdpMsgAnalyser* PUdpPopupResponse::Analyse() { PUdpMsgAnalyser* nextAnalyser = NULL; mDecodeData->mState = DECODE_MORE; - u8 MsgType = mDecodeData->mMessage->U8Data( mDecodeData->Sub0x13Start + 12 ); //u32 but only u8 used + uint8_t MsgType = mDecodeData->mMessage->U8Data( mDecodeData->Sub0x13Start + 12 ); //uint32_t but only uint8_t used switch ( MsgType ) { @@ -109,15 +72,15 @@ bool PUdpVentureWarpConfirm::DoAction() if ( mStatus == 1 ) { - u32 newLocation; + uint32_t newLocation; do { newLocation = Worlds->GetWorldIdFromWorldmap( GetRandom( PWorlds::mOutdoorWorldmapHSize, 0 ), GetRandom( PWorlds::mOutdoorWorldmapVSize, 0 ) ); } while ( ! newLocation ); - u16 nEntity = 10; - u16 nEntityType = 1; + uint16_t nEntity = 10; + uint16_t nEntityType = 1; PMessage* tmpMsg = MsgBuilder->BuildAptLiftUseMsg( nClient, newLocation, nEntity, nEntityType ); nClient->SendUDPMessage( tmpMsg ); @@ -163,8 +126,8 @@ bool PUdpVhcAccessResponse::DoAction() if ( nAccessRequests->RegisterResponse( mVhcAccessRequestId, ( mStatus == 1 ) ) ) { - u32 requesterCharId = 0; - u32 vehicleId = 0; + uint32_t requesterCharId = 0; + uint32_t vehicleId = 0; nAccessRequests->GetInfo( mVhcAccessRequestId, &requesterCharId, &vehicleId ); PClient* requesterClient = ClientManager->getClientByChar( requesterCharId ); PChar* requesterChar = ( requesterClient ? requesterClient->GetChar() : NULL ); @@ -174,7 +137,7 @@ bool PUdpVhcAccessResponse::DoAction() PWorld* CurrentWorld = Worlds->GetWorld( requesterChar->GetLocation() ); if ( CurrentWorld ) { - PSpawnedVehicle* tVhc = CurrentWorld->GetSpawnedVehicules()->GetVehicleByGlobalId( vehicleId ); + PSpawnedVehicle* tVhc = CurrentWorld->GetSpawnedVehicles()->GetVehicleByGlobalId( vehicleId ); if ( tVhc ) { diff --git a/TinNS/Source/GameServer/Decoder/UdpPopupResponse.hxx b/TinNS/Source/GameServer/Decoder/UdpPopupResponse.hxx new file mode 100644 index 0000000..5e696a2 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpPopupResponse.hxx @@ -0,0 +1,39 @@ +#pragma once + +#include +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PUdpPopupResponse : public PUdpMsgAnalyser { +public: + PUdpPopupResponse(PMsgDecodeData *nDecodeData); + //~PUdpPopupResponse(); + PUdpMsgAnalyser *Analyse(); + //bool DoAction(); +}; + +class PUdpVentureWarpConfirm : public PUdpMsgAnalyser { +private: + uint32_t mRawItemId; + uint16_t mStatus; + uint32_t mUnknown1; + uint16_t mUnknown2; + +public: + PUdpVentureWarpConfirm(PMsgDecodeData *nDecodeData); + //~PUdpVentureWarpConfirm(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; + +class PUdpVhcAccessResponse : public PUdpMsgAnalyser { +private: + uint32_t mVhcAccessRequestId; + uint16_t mStatus; + uint16_t mUnknown; + +public: + PUdpVhcAccessResponse(PMsgDecodeData *nDecodeData); + //~PUdpVhcAccessResponse(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; diff --git a/TinNS/Source/GameServer/Decoder/UdpPvpTrade.cxx b/TinNS/Source/GameServer/Decoder/UdpPvpTrade.cxx new file mode 100644 index 0000000..4e142a8 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpPvpTrade.cxx @@ -0,0 +1,23 @@ +#include "GameServer/Decoder/Includes.hxx" + +/**** PPvPTrade ****/ + +PUdpPvPTrade::PUdpPvPTrade(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData) +{ + nDecodeData->mName << "/0x3e"; +} + +PUdpMsgAnalyser* PUdpPvPTrade::Analyse() +{ + mDecodeData->mName << "=Switch PvP Trading"; + + mDecodeData->mState = DECODE_ACTION_READY | DECODE_FINISHED; + return this; +} + +bool PUdpPvPTrade::DoAction() +{ + // TODO: Handle client PvP trade switch on/off + mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED; + return true; +} diff --git a/TinNS/Source/GameServer/Decoder/UdpPvpTrade.hxx b/TinNS/Source/GameServer/Decoder/UdpPvpTrade.hxx new file mode 100644 index 0000000..7b61973 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpPvpTrade.hxx @@ -0,0 +1,11 @@ +#pragma once + +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PUdpPvPTrade : public PUdpMsgAnalyser { +public: + PUdpPvPTrade(PMsgDecodeData *nDecodeData); + //~PUdpPvPTrade(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; diff --git a/server/src/game/decoder/udp_quickaccessbelt.cpp b/TinNS/Source/GameServer/Decoder/UdpQuickAccessBelt.cxx similarity index 74% rename from server/src/game/decoder/udp_quickaccessbelt.cpp rename to TinNS/Source/GameServer/Decoder/UdpQuickAccessBelt.cxx index b108a07..7526e3a 100644 --- a/server/src/game/decoder/udp_quickaccessbelt.cpp +++ b/TinNS/Source/GameServer/Decoder/UdpQuickAccessBelt.cxx @@ -1,45 +1,6 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - udp_quickaccessbelt.cpp - decoder classes for UDP Quickaccessbelt related messages - - CREATION: 30 Dec 2006 Namikon - - MODIFIED: 01 Sep 2007 Hammag - REASON: - Put analysis code in Analyse() and change to use new item management methods - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "udp_quickaccessbelt.h" - -#include "include/container.h" -#include "include/inventory.h" - +#include "GameServer/Decoder/Includes.hxx" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" /**** PUdpItemSlotUse ****/ @@ -70,12 +31,12 @@ bool PUdpItemSlotUse::DoAction() PItem* targetItem = NULL; bool tUsable = false; bool tUsableInHand = false; - u16 nWeaponId = 0; + uint16_t nWeaponId = 0; if( gDevDebug ) Console->Print( "%s Client trying to activate item in slot %d.", Console->ColorText( CYAN, BLACK, "[DEBUG]" ), mTargetSlot ); - u8 currentActiveSlot = tChar->GetQuickBeltActiveSlot(); + uint8_t currentActiveSlot = tChar->GetQuickBeltActiveSlot(); if ( mTargetSlot == INV_WORN_QB_HAND ) { if( gDevDebug ) diff --git a/TinNS/Source/GameServer/Decoder/UdpQuickAccessBelt.hxx b/TinNS/Source/GameServer/Decoder/UdpQuickAccessBelt.hxx new file mode 100644 index 0000000..0f47787 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpQuickAccessBelt.hxx @@ -0,0 +1,15 @@ +#pragma once + +#include +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PUdpItemSlotUse : public PUdpMsgAnalyser { +private: + uint8_t mTargetSlot; + +public: + PUdpItemSlotUse(PMsgDecodeData *nDecodeData); + //~PUdpItemSlotUse(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; diff --git a/server/src/game/decoder/udp_reqinfo.cpp b/TinNS/Source/GameServer/Decoder/UdpRequestInfo.cxx similarity index 84% rename from server/src/game/decoder/udp_reqinfo.cpp rename to TinNS/Source/GameServer/Decoder/UdpRequestInfo.cxx index 116c015..7d5628f 100644 --- a/server/src/game/decoder/udp_reqinfo.cpp +++ b/TinNS/Source/GameServer/Decoder/UdpRequestInfo.cxx @@ -1,37 +1,7 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_reqinfo.cpp - decoder classes for UDP Char/Clan/Map info request messages - - CREATION: 6 Sep 2006 Hammag - - MODIFIED: - REASON: - - -*/ - -#include "main.h" -#include "udp_reqinfo.h" +#include +#include "GameServer/Decoder/Includes.hxx" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" /**** PUdpCharInfo ****/ @@ -166,7 +136,7 @@ bool PUdpReqInfo::DoAction() if (mRequestType == 7) { - u8 WorldMapData[] = { // Temp map for test, with Attack None/GR All security setting + uint8_t WorldMapData[] = { // Temp map for test, with Attack None/GR All security setting 0xd6, 0x07, 0x05, // BT@Simmons 0xfe, 0x07, 0x0b, // CM // No effect: not on OP zone 0xea, 0x07, 0x03, // Next // No effect: not on OP zone @@ -195,7 +165,7 @@ bool PUdpReqInfo::DoAction() // from normal reqinfo messages if(mRequestType == 3) { - u32 tFileLen = 0; + uint32_t tFileLen = 0; PFile* fLua = NULL; fLua = Filesystem->Open( "", (char*)Answer, Config->GetOption( "nc_data_path" ) ); std::string tLUAScript = ""; diff --git a/TinNS/Source/GameServer/Decoder/UdpRequestInfo.hxx b/TinNS/Source/GameServer/Decoder/UdpRequestInfo.hxx new file mode 100644 index 0000000..5e3163f --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpRequestInfo.hxx @@ -0,0 +1,16 @@ +#pragma once + +#include +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PUdpReqInfo : public PUdpMsgAnalyser { +private: + uint16_t mRequestType; + uint32_t mInfoId; + +public: + PUdpReqInfo(PMsgDecodeData *nDecodeData); + //~PUdpCharInfo(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; diff --git a/server/src/game/decoder/udp_subskill.cpp b/TinNS/Source/GameServer/Decoder/UdpSubSkill.cxx similarity index 60% rename from server/src/game/decoder/udp_subskill.cpp rename to TinNS/Source/GameServer/Decoder/UdpSubSkill.cxx index c047466..1179e1d 100644 --- a/server/src/game/decoder/udp_subskill.cpp +++ b/TinNS/Source/GameServer/Decoder/UdpSubSkill.cxx @@ -1,44 +1,13 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_subskill.h - decoder classes for UDP subskill increasing messages - - CREATION: 15 Sep 2006 Hammag - - MODIFIED: - REASON: - - -*/ - -#include "main.h" -#include "udp_subskill.h" +#include "GameServer/Decoder/Includes.hxx" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" /**** PUdpSubskillInc ****/ PUdpSubskillInc::PUdpSubskillInc(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData) { nDecodeData->mName << "/0x04"; -} +} PUdpMsgAnalyser* PUdpSubskillInc::Analyse() { @@ -46,7 +15,7 @@ PUdpMsgAnalyser* PUdpSubskillInc::Analyse() SubskillID = mDecodeData->mMessage->U16Data(mDecodeData->Sub0x13Start+9); mDecodeData->mState = DECODE_ACTION_READY | DECODE_FINISHED; - + return this; } diff --git a/TinNS/Source/GameServer/Decoder/UdpSubSkill.hxx b/TinNS/Source/GameServer/Decoder/UdpSubSkill.hxx new file mode 100644 index 0000000..4d1e394 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpSubSkill.hxx @@ -0,0 +1,15 @@ +#pragma once + +#include +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PUdpSubskillInc : public PUdpMsgAnalyser { +private: + uint16_t SubskillID; + +public: + PUdpSubskillInc(PMsgDecodeData *nDecodeData); + //~PUdpSubskillInc(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; diff --git a/server/src/game/decoder/udp_sync.cpp b/TinNS/Source/GameServer/Decoder/UdpSync.cxx similarity index 75% rename from server/src/game/decoder/udp_sync.cpp rename to TinNS/Source/GameServer/Decoder/UdpSync.cxx index 446c283..c26ff54 100644 --- a/server/src/game/decoder/udp_sync.cpp +++ b/TinNS/Source/GameServer/Decoder/UdpSync.cxx @@ -1,46 +1,9 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - udp_sync.cpp - decoder classes for UDP Sync messages - - CREATION: 30 Aug 2006 Hammag - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem - - TODO: - - put chunking code from PUdpSync2::DoAction() in a SendChunkedMessqage(PClient* nClient, PMessage* nMessage, u8 nChunkSize = 220) -*/ - - -#include "main.h" - -#include "udp_sync.h" - -#include "include/worlds.h" -#include "include/vehicle.h" +#include "GameServer/Decoder/Includes.hxx" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" +// TODO: - put chunking code from PUdpSync2::DoAction() in a SendChunkedMessqage(PClient* nClient, PMessage* nMessage, +// uint8_t nChunkSize = 220) /**** PUdpSync0 ****/ @@ -89,7 +52,7 @@ void PUdpSync0::GetToSync1( PMsgDecodeData* nDecodeData ) PClient* nClient = nDecodeData->mClient; nClient->SetZoning(); - u32 loc = nClient->GetChar()->GetLocation(); + uint32_t loc = nClient->GetChar()->GetLocation(); //Console->Print("inside HandleGame : Location: %d", loc); SendZone( nClient, loc ); @@ -130,21 +93,21 @@ bool PUdpSync1::DoAction() nClient->IncreaseUDP_ID(); - *tmpMsg << (u8)0x13; - *tmpMsg << (u16)nClient->GetUDP_ID(); - *tmpMsg << (u16)nClient->GetSessionID(); - *tmpMsg << (u8)0x0a; // Message length place; - *tmpMsg << (u8)0x03; - *tmpMsg << (u16)nClient->GetUDP_ID(); - *tmpMsg << (u8)0x23; - *tmpMsg << (u8)0x0f; - *tmpMsg << (u8)0x00; // ?? - *tmpMsg << (u8)0x03; // ?? - *tmpMsg << (u8)0x00; // ?? - *tmpMsg << (u8)0x01; // ?? - *tmpMsg << (u8)0x00; // ?? - - (*tmpMsg)[5] = (u8)(tmpMsg->GetSize() - 6); + *tmpMsg << (uint8_t)0x13; + *tmpMsg << (uint16_t)nClient->GetUDP_ID(); + *tmpMsg << (uint16_t)nClient->GetSessionID(); + *tmpMsg << (uint8_t)0x0a; // Message length place; + *tmpMsg << (uint8_t)0x03; + *tmpMsg << (uint16_t)nClient->GetUDP_ID(); + *tmpMsg << (uint8_t)0x23; + *tmpMsg << (uint8_t)0x0f; + *tmpMsg << (uint8_t)0x00; // ?? + *tmpMsg << (uint8_t)0x03; // ?? + *tmpMsg << (uint8_t)0x00; // ?? + *tmpMsg << (uint8_t)0x01; // ?? + *tmpMsg << (uint8_t)0x00; // ?? + + (*tmpMsg)[5] = (uint8_t)(tmpMsg->GetSize() - 6); nClient->SendUDPMessage(tmpMsg);*/ mDecodeData->mClientState->UDP.mState = PGameState::UDP::GUS_SYNC2; @@ -191,8 +154,8 @@ bool PUdpSync2::DoAction() nClient->SetZoning( false ); // If char is sitting (vhz zoning), send it now to client - u32 nSeatableObjectId; - u8 nSeatId; + uint32_t nSeatableObjectId; + uint8_t nSeatId; if( nClient->GetChar()->GetSeatInUse(&nSeatableObjectId, &nSeatId) ) { if( gDevDebug ) @@ -215,7 +178,7 @@ bool PUdpSync2::DoAction() PWorld* CurrentWorld = Worlds->GetWorld( nClient->GetChar()->GetLocation() ); if ( CurrentWorld ) { - PSpawnedVhcList* VhcList = CurrentWorld->GetSpawnedVehicules()->GetSpawnedVehicles(); + PSpawnedVhcList* VhcList = CurrentWorld->GetSpawnedVehicles()->GetSpawnedVehicles(); PSpawnedVehicle* VhcEntry; PMessage* VhcMsg; diff --git a/TinNS/Source/GameServer/Decoder/UdpSync.hxx b/TinNS/Source/GameServer/Decoder/UdpSync.hxx new file mode 100644 index 0000000..8841d52 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpSync.hxx @@ -0,0 +1,33 @@ +#pragma once + +#include +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PUdpSync0 : public PUdpMsgAnalyser { +public: + PUdpSync0(PMsgDecodeData *nDecodeData); + //~PUdpSync0(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); + + static void GetToSync1(PMsgDecodeData *nDecodeData); +}; + +class PUdpSync1 : public PUdpMsgAnalyser { +public: + PUdpSync1(PMsgDecodeData *nDecodeData); + //~PUdpSync1(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; + +class PUdpSync2 : public PUdpMsgAnalyser { +private: + uint32_t mClientTime; + +public: + PUdpSync2(PMsgDecodeData *nDecodeData); + //~PUdpSync2(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; diff --git a/server/src/game/decoder/udp_terminal.cpp b/TinNS/Source/GameServer/Decoder/UdpTerminal.cxx similarity index 81% rename from server/src/game/decoder/udp_terminal.cpp rename to TinNS/Source/GameServer/Decoder/UdpTerminal.cxx index d3f7453..486c63a 100644 --- a/server/src/game/decoder/udp_terminal.cpp +++ b/TinNS/Source/GameServer/Decoder/UdpTerminal.cxx @@ -1,47 +1,7 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - udp_terminal.cpp - decoder classes for UDP terminal related messages - - CREATION: 08 Jan 2007 Namikon - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "udp_terminal.h" -#include "udp_charmove.h" - -#include "include/terminal.h" -#include "include/vehicle.h" -#include "include/worlds.h" -#include "include/furnituretemplate.h" - #include +#include "GameServer/Decoder/Includes.hxx" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" /*******************************************************************************************/ /**** PUdpReceiveDB ****/ @@ -55,7 +15,7 @@ PUdpReceiveDB::PUdpReceiveDB( PMsgDecodeData* nDecodeData ) : PUdpMsgAnalyser( n PUdpMsgAnalyser* PUdpReceiveDB::Analyse() { PMessage* TmpMsg = mDecodeData->mMessage; - u16 Unknown3, OptionSize; + uint16_t Unknown3, OptionSize; mDecodeData->mName << "=ReceiveDB request from client"; @@ -96,9 +56,9 @@ bool PUdpReceiveDB::DoAction() if ( gDevDebug ) { Console->Print( "%s ReceiveDB request from client", Console->ColorText( CYAN, BLACK, "[DEBUG]" ) ); - Console->Print( "%s Open Terminal - Terminal session %04x (?) - Unknown1 %04x - DBId %04x - Unknown2 %02x", Console->ColorText( CYAN, BLACK, "[DEBUG]" ), mTerminalSessionId, mUnknown1, mDBId, mUnknown2 ); + Console->Print( "%s Open Terminal - Terminal session %04x (?) - Unknown1 %04x - DBId %04x - Unknown2 %02x", Console->ColorText( CYAN, BLACK, "[DEBUG]" ), mTerminalSessionId, mUnknown1, mDBId, mUnknown2 ); Console->Print( "%s Command: '%s'", Console->ColorText( CYAN, BLACK, "[DEBUG]" ), mCommandName.c_str() ); - for ( u8 i = 0; i < mOptionsCount; ++i ) + for ( uint8_t i = 0; i < mOptionsCount; ++i ) Console->Print( "%s Option %d: '%s'", Console->ColorText( CYAN, BLACK, "[DEBUG]" ), i, mOptions[i].c_str() ); } @@ -119,7 +79,7 @@ bool PUdpReceiveDB::DoAction() if ( !Result ) { Console->Print( "%s PUdpReceiveDB - Error or unknown command %s", Console->ColorText( RED, BLACK, "[WARNING]" ), mCommandName.c_str() ); - for ( u8 i = 0; i < mOptionsCount; ++i ) + for ( uint8_t i = 0; i < mOptionsCount; ++i ) Console->Print( "%s Option %d: '%s'", Console->ColorText( RED, BLACK, "[NOTICE]" ), i, mOptions[i].c_str() ); } @@ -135,16 +95,16 @@ bool PUdpReceiveDB::ActionVehicleListing() if ( mOptionsCount == 3 ) // CharId, StartVhcEntry, MaxVhcEntries { - if ((( u32 )atol( mOptions[0].c_str() ) ) != tChar->GetID() ) + if ((( uint32_t )atol( mOptions[0].c_str() ) ) != tChar->GetID() ) { // Err: invalid CharId. Can alert, But we don't care :-) (except if used for other terminal function) } // !!! some more check/regex on values to do before using !!! - u16 StartIndex = atoi( mOptions[1].c_str() ); - u16 MaxEntries = atoi( mOptions[2].c_str() ); + uint16_t StartIndex = atoi( mOptions[1].c_str() ); + uint16_t MaxEntries = atoi( mOptions[2].c_str() ); - u8 nStatus = 1; - u16 nErrcode = 0; + uint8_t nStatus = 1; + uint16_t nErrcode = 0; tmpMsg = MsgBuilder->BuildDBRequestStatusMsg( tClient, &mCommandName, nStatus, nErrcode ); tClient->SendUDPMessage( tmpMsg ); @@ -152,9 +112,9 @@ bool PUdpReceiveDB::ActionVehicleListing() PVhcInfoList* VhcList = Vehicles->GetCharVehicles( tChar->GetID(), MaxEntries, StartIndex ); if ( ! VhcList->empty() ) { - u16 NumEntries = VhcList->size(); + uint16_t NumEntries = VhcList->size(); std::string* Answer = new std::string[4 * NumEntries]; - u16 Index = 0; + uint16_t Index = 0; PVehicleInformation* EntryInfo; //Console->Print("VHc entries : %d", NumEntries); @@ -182,18 +142,18 @@ bool PUdpReceiveDB::ActionVehicleListing() return false; /* // Option1=CharId, Option2=resultEntryStart, Option3=maxResultEntries - S=> 03/2b/1a VehicleListing+0 + S=> 03/2b/1a VehicleListing+0 13 2a 00 7c be 19 03 2a 00 2b 1a 0f 00 01 00 00 56 65 68 69 63 6c .*.+......Vehicl 65 4c 69 73 74 69 6e 67 00 eListing. - S=> 03/2b/17 0f 00 08 00 04 00 <0f 00><04 00> + S=> 03/2b/17 0f 00 08 00 04 00 <0f 00><04 00> VehicleListing+0 (val: 0=stored) (val: 0-255) == - 03/2b/17 0f 00 01 00 04 00 <0f 00><04 00> + 03/2b/17 0f 00 01 00 04 00 <0f 00><04 00> 31 03 54 00 2b 17 0f 00 01 00 04 00 56 65 68 69 63 6c 65 4c 69 73 74 .....VehicleList 69 6e 67 00 06 00 32 35 32 37 37 00 03 00 36 30 ing...25277...60 @@ -209,13 +169,13 @@ bool PUdpReceiveDB::ActionVehicleControl() if ( mOptionsCount == 2 ) // VhcId, CharId { // !!! validate values !!! - u8 nStatus = 1; - u16 nErrcode = 0; + uint8_t nStatus = 1; + uint16_t nErrcode = 0; tmpMsg = MsgBuilder->BuildDBRequestStatusMsg( tClient, &mCommandName, nStatus, nErrcode ); tClient->SendUDPMessage( tmpMsg ); - u32 VhcId = ( u32 )atol( mOptions[0].c_str() ); + uint32_t VhcId = ( uint32_t )atol( mOptions[0].c_str() ); PVehicleInformation EntryInfo; if ( Vehicles->GetVehicleInfo( VhcId, &EntryInfo ) ) { @@ -260,7 +220,7 @@ PUdpUpdateDB::PUdpUpdateDB( PMsgDecodeData* nDecodeData ) : PUdpMsgAnalyser( nDe PUdpMsgAnalyser* PUdpUpdateDB::Analyse() { PMessage* TmpMsg = mDecodeData->mMessage; - u16 Unknown3, OptionSize; + uint16_t Unknown3, OptionSize; mDecodeData->mName << "=UpdateDB request from client"; @@ -298,7 +258,7 @@ bool PUdpUpdateDB::DoAction() Console->Print( "%s UpdateDB request from client", Console->ColorText( CYAN, BLACK, "[DEBUG]" ) ); Console->Print( "%s Open Terminal - Terminal session %04x (?)", Console->ColorText( CYAN, BLACK, "[DEBUG]" ), mTerminalSessionId ); Console->Print( "%s Command: '%s'", Console->ColorText( CYAN, BLACK, "[DEBUG]" ), mCommandName.c_str() ); - for ( u8 i = 0; i < mOptionsCount; ++i ) + for ( uint8_t i = 0; i < mOptionsCount; ++i ) Console->Print( "%s Option %d: '%s'", Console->ColorText( CYAN, BLACK, "[DEBUG]" ), i, mOptions[i].c_str() ); } bool Result = false; @@ -307,7 +267,7 @@ bool PUdpUpdateDB::DoAction() if ( !Result ) { Console->Print( "%s PUdpUpdateDB - Error or unknown command %s", Console->ColorText( RED, BLACK, "[WARNING]" ), mCommandName.c_str() ); - for ( u8 i = 0; i < mOptionsCount; ++i ) + for ( uint8_t i = 0; i < mOptionsCount; ++i ) Console->Print( "%s Option %d: '%s'", Console->ColorText( RED, BLACK, "[NOTICE]" ), i, mOptions[i].c_str() ); } mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED; @@ -325,7 +285,7 @@ PUdpTryAccessDB::PUdpTryAccessDB( PMsgDecodeData* nDecodeData ) : PUdpMsgAnalyse PUdpMsgAnalyser* PUdpTryAccessDB::Analyse() { PMessage* TmpMsg = mDecodeData->mMessage; - u16 Unknown3, OptionSize; + uint16_t Unknown3, OptionSize; mDecodeData->mName << "=TryAccess request from client"; @@ -375,7 +335,7 @@ PUdpQueryDB::PUdpQueryDB( PMsgDecodeData* nDecodeData ) : PUdpMsgAnalyser( nDeco PUdpMsgAnalyser* PUdpQueryDB::Analyse() { PMessage* TmpMsg = mDecodeData->mMessage; - u16 OptionSize; + uint16_t OptionSize; mDecodeData->mName << "=QueryDB request from client"; @@ -423,7 +383,7 @@ bool PUdpQueryDB::DoAction() Console->Print( "%s Open Terminal - Terminal session %04x (?)", Console->ColorText( CYAN, BLACK, "[DEBUG]" ), mTerminalSessionId ); Console->Print( "%s DBCommand: '%s'", Console->ColorText( CYAN, BLACK, "[DEBUG]" ), mDBCommandName.c_str() ); Console->Print( "%s Command: '%s'", Console->ColorText( CYAN, BLACK, "[DEBUG]" ), mCommandName.c_str() ); - for ( u8 i = 0; i < mOptionsCount; ++i ) + for ( uint8_t i = 0; i < mOptionsCount; ++i ) Console->Print( "%s Option %d: '%s'", Console->ColorText( CYAN, BLACK, "[DEBUG]" ), i, mOptions[i].c_str() ); } @@ -448,7 +408,7 @@ bool PUdpQueryDB::DoAction() if ( !Result ) { Console->Print( "%s PUdpQueryDB - Error or unknown command %s", Console->ColorText( RED, BLACK, "[WARNING]" ), mDBCommandName.c_str() ); - for ( u8 i = 0; i < mOptionsCount; ++i ) + for ( uint8_t i = 0; i < mOptionsCount; ++i ) Console->Print( "%s Option %d: '%s'", Console->ColorText( RED, BLACK, "[NOTICE]" ), i, mOptions[i].c_str() ); } @@ -464,12 +424,12 @@ bool PUdpQueryDB::ActionSpawnVehicle() if ( mOptionsCount == 3 ) // 0, VhcId, CharId { - u32 VhcId = ( u32 )atol( mOptions[1].c_str() ); - //u32 CharId = (u32)atol(mOptions[2].c_str()); + uint32_t VhcId = ( uint32_t )atol( mOptions[1].c_str() ); + //uint32_t CharId = (uint32_t)atol(mOptions[2].c_str()); // !!! validate values !!! // !!! + check CharId = current char && CharId is owner of VhcId - u8 nStatus = 1; // 1=OK, 0=Err - u16 nErrcode = 16; // 0=n/a 16=Already Spawned // MsdId = 2500+nErrcode [MISC] + uint8_t nStatus = 1; // 1=OK, 0=Err + uint16_t nErrcode = 16; // 0=n/a 16=Already Spawned // MsdId = 2500+nErrcode [MISC] tmpMsg = MsgBuilder->BuildDBRequestStatusMsg( tClient, &mCommandName, nStatus, nErrcode ); tClient->SendUDPMessage( tmpMsg ); @@ -482,15 +442,15 @@ bool PUdpQueryDB::ActionSpawnVehicle() const PFurnitureItemTemplate* tFurnitureTemplate = CurrentWorld->GetFurnitureItemTemplate( tChar->GetLastUsedObject() / 1024 - 1 ); if ( tFurnitureTemplate && ( tFurnitureTemplate->GetFunctionType() == 28 ) ) // vhc term { - f32 decal = 1000; // distance at which to spawn the vhc - f32 nPosX, nPosY, nPosZ; + float decal = 1000; // distance at which to spawn the vhc + float nPosX, nPosY, nPosZ; tFurnitureTemplate->GetPos( &nPosX, &nPosY, &nPosZ ); nPosX += 32000; nPosY += 32000; - f32 dX = ( tChar->Coords.mX - nPosX ); - f32 dY = ( tChar->Coords.mY - nPosY ); - f32 d = decal / sqrt( dX * dX + dY * dY ); - NewPosition.SetPosition( static_cast( nPosY + d * dY ), ( tChar->Coords ).mZ + 100, static_cast( nPosX + d * dX ), ( tChar->Coords ).mUD, 34683, 32403 ); + float dX = ( tChar->Coords.mX - nPosX ); + float dY = ( tChar->Coords.mY - nPosY ); + float d = decal / sqrt( dX * dX + dY * dY ); + NewPosition.SetPosition( static_cast( nPosY + d * dY ), ( tChar->Coords ).mZ + 100, static_cast( nPosX + d * dX ), ( tChar->Coords ).mUD, 34683, 32403 ); relativePos = true; } } @@ -518,12 +478,12 @@ bool PUdpQueryDB::ActionRepairVehicle() if ( mOptionsCount == 3 ) // 0, VhcId, CharId { - //u32 VhcId = (u32)atol(mOptions[1].c_str()); - //u32 CharId = (u32)atol(mOptions[2].c_str()); + //uint32_t VhcId = (uint32_t)atol(mOptions[1].c_str()); + //uint32_t CharId = (uint32_t)atol(mOptions[2].c_str()); // !!! validate values !!! - u8 nStatus = 1; // 1=OK, 0=Err - u16 nErrcode = 18; // 0=n/a 18=Still Spawned, 19=Not enough money + uint8_t nStatus = 1; // 1=OK, 0=Err + uint16_t nErrcode = 18; // 0=n/a 18=Still Spawned, 19=Not enough money tmpMsg = MsgBuilder->BuildDBRequestStatusMsg( tClient, &mCommandName, nStatus, nErrcode ); tClient->SendUDPMessage( tmpMsg ); @@ -545,25 +505,25 @@ bool PUdpQueryDB::ActionDismissVehicle() if ( mOptionsCount == 3 ) // 0, VhcId, CharId { - u32 VhcId = ( u32 )atol( mOptions[1].c_str() ); - //u32 CharId = (u32)atol(mOptions[2].c_str()); + uint32_t VhcId = ( uint32_t )atol( mOptions[1].c_str() ); + //uint32_t CharId = (uint32_t)atol(mOptions[2].c_str()); // !!! validate values !!! // !!! + check CharId = current char && CharId is owner of VjhcId // !!! Check vhc empty - u8 nStatus = 0; // 1=OK, 0=Err - u16 nErrcode = 17; // 0=n/a 17=Not Spawned + uint8_t nStatus = 0; // 1=OK, 0=Err + uint16_t nErrcode = 17; // 0=n/a 17=Not Spawned PVehicleInformation nInfo; - u32 tLocalId = 0; - u32 tLocation = 0; + uint32_t tLocalId = 0; + uint32_t tLocation = 0; PSpawnedVehicle* tVhc = Vehicles->GetSpawnedVehicle( VhcId ); if ( tVhc ) { tLocalId = tVhc->GetLocalId(); tLocation = tVhc->GetLocation(); - u32 tCharId; + uint32_t tCharId; PChar* tChar; - for ( u8 i = 0; i < tVhc->GetNumSeats(); ++i ) + for ( uint8_t i = 0; i < tVhc->GetNumSeats(); ++i ) { if (( tCharId = tVhc->GetSeatUser( i ) ) ) { diff --git a/TinNS/Source/GameServer/Decoder/UdpTerminal.hxx b/TinNS/Source/GameServer/Decoder/UdpTerminal.hxx new file mode 100644 index 0000000..2cabd91 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpTerminal.hxx @@ -0,0 +1,97 @@ +#pragma once + +#include +#include +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PUdpReceiveDB : public PUdpMsgAnalyser { +private: + static const uint8_t mMaxOptions = 9; // Largest: forum\forenlist.tsc(21, 114,...) + uint16_t mTerminalSessionId; + std::string mCommandName; + std::string mOptions[mMaxOptions]; + uint8_t mOptionsCount; + + uint16_t mUnknown1; + uint8_t mUnknown2; + uint16_t mDBId; + + bool ActionVehicleListing(); + bool ActionVehicleControl(); + +public: + PUdpReceiveDB(PMsgDecodeData *nDecodeData); + //~PUdpReceiveDB(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; + +class PUdpUpdateDB : public PUdpMsgAnalyser { +private: + static const uint8_t mMaxOptions = 7; // Largest: forum\bbcnewthread.tsc(66): + uint16_t mTerminalSessionId; + std::string mCommandName; + std::string mOptions[mMaxOptions]; + uint8_t mOptionsCount; + + uint16_t mUnknown1; + uint8_t mUnknown2; + uint16_t mDBId; + +public: + PUdpUpdateDB(PMsgDecodeData *nDecodeData); + //~PUdpUpdateDB(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; + +class PUdpTryAccessDB : public PUdpMsgAnalyser { +private: + static const uint8_t mMaxOptions = 9; // Largest: stockx\depot.tsc(227): + uint16_t mTerminalSessionId; + std::string mCommandName; + std::string mOptions[mMaxOptions]; + uint8_t mOptionsCount; + + uint16_t mUnknown1; + uint8_t mUnknown2; + uint16_t mDBId; + +public: + PUdpTryAccessDB(PMsgDecodeData *nDecodeData); + //~PUdpTryAccessDB(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; + +class PUdpQueryDB : public PUdpMsgAnalyser { // Also called "ServerMessage" in .tsc scripts! +private: + static const uint8_t mMaxOptions = 5; // Largest: politics\transcomment.tsc(36): + uint16_t mTerminalSessionId; + uint16_t mDBId; + std::string mDBCommandName; + std::string mCommandName; + std::string mOptions[mMaxOptions]; + uint8_t mOptionsCount; + + bool ActionSpawnVehicle(); + bool ActionRepairVehicle(); + bool ActionDismissVehicle(); + +public: + PUdpQueryDB(PMsgDecodeData *nDecodeData); + //~PUdpQueryDB(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; + +class PUdpTeminal0x1f : public PUdpMsgAnalyser { +private: + uint16_t mTerminalSessionId; + +public: + PUdpTeminal0x1f(PMsgDecodeData *nDecodeData); + //~PUdpTeminal0x1f(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; diff --git a/server/src/game/decoder/udp_useobject.cpp b/TinNS/Source/GameServer/Decoder/UdpUseObject.cxx similarity index 89% rename from server/src/game/decoder/udp_useobject.cpp rename to TinNS/Source/GameServer/Decoder/UdpUseObject.cxx index f556016..c063aa9 100644 --- a/server/src/game/decoder/udp_useobject.cpp +++ b/TinNS/Source/GameServer/Decoder/UdpUseObject.cxx @@ -1,54 +1,9 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko +#include "GameServer/Decoder/Includes.hxx" +#include "GameServer/Definitions/Includes.hxx" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - udp_useobject.cpp - decoder classes for object use related messages - - CREATION: 17 Sep 2006 Hammag - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem - - TODO: - - use only RawObjectIDs to avoid complication & errors -*/ - - -#include "main.h" - -#include "udp_useobject.h" -#include "udp_vhc.h" - -#include "include/worlds.h" -#include "include/furnituretemplate.h" -#include "include/doortemplate.h" -#include "include/appartements.h" -#include "include/container.h" -#include "include/subway.h" -#include "include/vhcaccessrequest.h" - - -u32 gVhcId = 0x3ff; +uint32_t gVhcId = 0x3ff; /**** PUdpVhcMove ****/ @@ -70,14 +25,14 @@ bool PUdpUseObject::DoAction() { PClient* nClient = mDecodeData->mClient; PChar* nChar = nClient->GetChar(); - u32 ItemID; + uint32_t ItemID; char DbgMessage[128]; PMessage* tmpMsg; bool tHandleDynamicActor = false; /*PMessage* cMsg = mDecodeData->mMessage; - u32 ClientTime = cMsg->U32Data(mDecodeData->Sub0x13Start+2); + uint32_t ClientTime = cMsg->U32Data(mDecodeData->Sub0x13Start+2); tmpMsg = MsgBuilder->BuildPingMsg(mDecodeData->mClient, ClientTime); mDecodeData->mClient->SendUDPMessage(tmpMsg);*/ @@ -98,7 +53,7 @@ bool PUdpUseObject::DoAction() if ( gDevDebug ) { - Console->Print( "Char at y=%f (0x%04x) z=%f (0x%04x) x=%f (0x%04x)", ( f32 )( nChar->Coords.mY - 32000 ), nChar->Coords.mY, ( f32 )( nChar->Coords.mZ - 32000 ), nChar->Coords.mZ, ( f32 )( nChar->Coords.mX - 32000 ), nChar->Coords.mX ); + Console->Print( "Char at y=%f (0x%04x) z=%f (0x%04x) x=%f (0x%04x)", ( float )( nChar->Coords.mY - 32000 ), nChar->Coords.mY, ( float )( nChar->Coords.mZ - 32000 ), nChar->Coords.mZ, ( float )( nChar->Coords.mX - 32000 ), nChar->Coords.mX ); if ( mRawItemID & 1023 ) Console->Print( "using item %d (0x%08x)", mRawItemID, mRawItemID ); else @@ -162,7 +117,7 @@ bool PUdpUseObject::DoAction() if ( nChar->GetSeatInUse() == seat_none ) // Refuse if Char is already sitting somewhere { - PSpawnedVehicle* tVhc = CurrentWorld->GetSpawnedVehicules()->GetVehicle( mRawItemID ); + PSpawnedVehicle* tVhc = CurrentWorld->GetSpawnedVehicles()->GetVehicle( mRawItemID ); if ( tVhc ) { if ( gDevDebug ) @@ -198,7 +153,7 @@ bool PUdpUseObject::DoAction() { PChar* ownerChar = ownerClient->GetChar(); // We could check for valid allowed access before adding a new one - u32 newReqId = ownerChar->GetVhcAccessRequestList()->Add( nChar->GetID(), tVhc->GetInformation().GetVehicleId() ); + uint32_t newReqId = ownerChar->GetVhcAccessRequestList()->Add( nChar->GetID(), tVhc->GetInformation().GetVehicleId() ); if ( newReqId ) { tmpMsg = MsgBuilder->BuildVhcAccessRequestMsg( ownerClient, newReqId, nChar->GetID(), nClient->GetID(), tVhc->GetInformation().GetVehicleId() ); @@ -222,7 +177,7 @@ bool PUdpUseObject::DoAction() vhcFound = true; if ( Subway->IsDoorOpen( mRawItemID, GameServer->GetGameTime() ) ) { - u8 freeSeat = Subway->GetFreeSeat( mRawItemID ); + uint8_t freeSeat = Subway->GetFreeSeat( mRawItemID ); if ( freeSeat && Subway->SetSeatUser( mRawItemID, freeSeat, nChar->GetID() ) ) { nChar->SetSeatInUse( seat_subway, mRawItemID, freeSeat ); @@ -263,7 +218,7 @@ bool PUdpUseObject::DoAction() if ( !( mDecodeData->mState & DECODE_ACTION_DONE ) ) // not a vhc nor a pc { - //Console->Print(">>> Searching world"); + //Console->Print(">>> Searching world"); // Is it a NPC ? PNPC* targetNPC = 0; PNPCWorld* currentNPCWorld = NPCManager->GetWorld( nChar->GetLocation() ); @@ -341,7 +296,7 @@ bool PUdpUseObject::DoAction() if ( tFurnitureModel->GetUseFlags() & ufChair ) { - u32 cSeatObjectId; + uint32_t cSeatObjectId; PSeatType cSeatType = nChar->GetSeatInUse( &cSeatObjectId ); if (( cSeatType == seat_none ) || ( cSeatType == seat_chair ) ) { @@ -387,12 +342,12 @@ bool PUdpUseObject::DoAction() { case 6: //Respawn Station (GenRep) { - u32 nLocation = nChar->GetLocation(); - u16 nEntity; + uint32_t nLocation = nChar->GetLocation(); + uint16_t nEntity; if ( Worlds->IsPotentialAppartement( nLocation ) ) { - nLocation = 0xffffffff; // (u32)-1; - nEntity = 0xffff; //(u16)-1; + nLocation = 0xffffffff; // (uint32_t)-1; + nEntity = 0xffff; //(uint16_t)-1; } else { @@ -408,7 +363,7 @@ bool PUdpUseObject::DoAction() nEntityInt = GameDefs->Respawns()->GetRespawnEntity( nChar->GetLocation(), WorldActors->GetLinkedObjectID( mRawItemID ) ); } - nEntity = ( nEntityInt < 0 ? 0xffff : ( u16 )nEntityInt ); + nEntity = ( nEntityInt < 0 ? 0xffff : ( uint16_t )nEntityInt ); } tmpMsg = MsgBuilder->BuildCharUseGenrepMsg( nClient, mRawItemID, nLocation, nEntity ); @@ -444,7 +399,7 @@ bool PUdpUseObject::DoAction() case 15: //HOLOMATCH EXIT { // temp hack + wrong entity... guess it works same as function 20 - u32 HoloNum = nChar->GetLocation() - 90000; // value 1 to 16, to transalte to 540..547 550..557 for worldmodel.def + uint32_t HoloNum = nChar->GetLocation() - 90000; // value 1 to 16, to transalte to 540..547 550..557 for worldmodel.def const PDefWorldModel* tHoloExitModel = GameDefs->WorldModels()->GetDef( 539 + HoloNum + ( HoloNum > 8 ? 2 : 0 ) ); if ( tHoloExitModel && ( tHoloExitModel->GetFunctionType() == 14 ) ) // we use the Holomatch entry. Takes care of bad zone id @@ -452,9 +407,9 @@ bool PUdpUseObject::DoAction() const PDefAppPlace* nAppPlace = GameDefs->AppPlaces()->GetDef( tHoloExitModel->GetFunctionValue() ); if ( nAppPlace ) { - u32 Location = nAppPlace->GetExitWorldID(); - u16 Entity = nAppPlace->GetExitWorldEntity(); - u8 SewerLevel = 0; + uint32_t Location = nAppPlace->GetExitWorldID(); + uint16_t Entity = nAppPlace->GetExitWorldEntity(); + uint8_t SewerLevel = 0; tmpMsg = MsgBuilder->BuildChangeLocationMsg( nClient, Location, Entity, SewerLevel, 0 ); //mRawItemID nClient->SendUDPMessage( tmpMsg ); @@ -490,9 +445,9 @@ bool PUdpUseObject::DoAction() } if ( nAppPlace ) { - u32 Location = nAppPlace->GetExitWorldID(); - u16 Entity = nAppPlace->GetExitWorldEntity(); - u8 SewerLevel = 0; + uint32_t Location = nAppPlace->GetExitWorldID(); + uint16_t Entity = nAppPlace->GetExitWorldEntity(); + uint8_t SewerLevel = 0; //if(((tFurnitureModel->GetFunctionType() == 20) && nAppPlace->GetSewerLevel()) || (tFurnitureModel->GetFunctionType() == 29)) if (( tFurnitureModel->GetFunctionType() == 20 ) || ( tFurnitureModel->GetFunctionType() == 29 ) ) { @@ -644,7 +599,7 @@ bool PUdpUseObject::DoAction() } else { - u32 linkobjID = WorldActors->GetLinkedObjectID( mRawItemID ); + uint32_t linkobjID = WorldActors->GetLinkedObjectID( mRawItemID ); if ( linkobjID ) { if ( nClient->GetAccountLevel() >= PAL_GM ) // Allow GameMasters and higher to just bypass HackButtons @@ -675,11 +630,11 @@ bool PUdpUseObject::DoAction() { if ( tFurnitureTemplate->GetLinkedObjectID() ) { - u32 OldCash = nChar->GetCash(); - u32 DoorFee = ( u32 )tFurnitureModel->GetFunctionValue(); + uint32_t OldCash = nChar->GetCash(); + uint32_t DoorFee = ( uint32_t )tFurnitureModel->GetFunctionValue(); if ( OldCash >= DoorFee ) { - u32 NewCash = nChar->SetCash( OldCash - DoorFee ); + uint32_t NewCash = nChar->SetCash( OldCash - DoorFee ); PMessage* tmpMsg_cash = MsgBuilder->BuildCharMoneyUpdateMsg( nClient, NewCash ); nClient->SendUDPMessage( tmpMsg_cash ); tmpMsg_cash = NULL; @@ -700,14 +655,14 @@ bool PUdpUseObject::DoAction() } else { - u32 linkobjID = WorldActors->GetLinkedObjectID( mRawItemID ); + uint32_t linkobjID = WorldActors->GetLinkedObjectID( mRawItemID ); if ( linkobjID ) { - u32 OldCash = nChar->GetCash(); - u32 DoorFee = ( u32 )tFurnitureModel->GetFunctionValue(); + uint32_t OldCash = nChar->GetCash(); + uint32_t DoorFee = ( uint32_t )tFurnitureModel->GetFunctionValue(); if ( OldCash >= DoorFee ) { - u32 NewCash = nChar->SetCash( OldCash - DoorFee ); + uint32_t NewCash = nChar->SetCash( OldCash - DoorFee ); PMessage* tmpMsg_cash = MsgBuilder->BuildCharMoneyUpdateMsg( nClient, NewCash ); nClient->SendUDPMessage( tmpMsg_cash ); tmpMsg_cash = NULL; @@ -765,7 +720,7 @@ bool PUdpUseObject::DoAction() } case 32: // Text message { - tmpMsg = MsgBuilder->BuildText100Msg( nClient, ( u8 )( 255 & tFurnitureModel->GetFunctionValue() ), mRawItemID ); + tmpMsg = MsgBuilder->BuildText100Msg( nClient, ( uint8_t )( 255 & tFurnitureModel->GetFunctionValue() ), mRawItemID ); nClient->SendUDPMessage( tmpMsg ); mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED; diff --git a/TinNS/Source/GameServer/Decoder/UdpUseObject.hxx b/TinNS/Source/GameServer/Decoder/UdpUseObject.hxx new file mode 100644 index 0000000..0b22681 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpUseObject.hxx @@ -0,0 +1,25 @@ +#pragma once + +#include +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PUdpUseObject : public PUdpMsgAnalyser { +private: + uint32_t mRawItemID; + + void OldHandler(); // Temp during migration only + +public: + PUdpUseObject(PMsgDecodeData *nDecodeData); + //~PUdpUseObject(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; + +class PUdpCloseItemContainer : public PUdpMsgAnalyser { +public: + PUdpCloseItemContainer(PMsgDecodeData *nDecodeData); + //~PUdpCloseItemContainer(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; diff --git a/server/src/game/decoder/udp_vhc.cpp b/TinNS/Source/GameServer/Decoder/UdpVehicle.cxx similarity index 82% rename from server/src/game/decoder/udp_vhc.cpp rename to TinNS/Source/GameServer/Decoder/UdpVehicle.cxx index 168bdbe..a593eca 100644 --- a/server/src/game/decoder/udp_vhc.cpp +++ b/TinNS/Source/GameServer/Decoder/UdpVehicle.cxx @@ -1,44 +1,6 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - udp_vhc.h - decoder classes for UDP vehicle related messages - - CREATION: 05 Sep 2006 Hammag - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "udp_vhc.h" - -#include "include/worlds.h" -#include "include/vehicle.h" -#include "include/subway.h" - +#include "GameServer/Decoder/Includes.hxx" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" /**** PUdpVhcMove ****/ @@ -133,7 +95,7 @@ bool PUdpVhcMove::DoAction() if ( CurrentWorld ) { - PSpawnedVehicle* tVhc = CurrentWorld->GetSpawnedVehicules()->GetVehicle( mVhcLocalId ); + PSpawnedVehicle* tVhc = CurrentWorld->GetSpawnedVehicles()->GetVehicle( mVhcLocalId ); if ( tVhc ) { //Todo: calc & mem Speed & Accel vectors @@ -148,21 +110,21 @@ bool PUdpVhcMove::DoAction() if( CurrentWorld->CheckVhcNeedZoning( &nPos ) ) { - u32 destWorldId; + uint32_t destWorldId; PVhcCoordinates destPos; if (( destWorldId = CurrentWorld->GetVhcZoningDestination( tVhc, &destPos ) ) ) { if ( nClient->GetDebugMode( DBG_LOCATION ) ) { - u8 pH = 0; - u8 pV = 0; + uint8_t pH = 0; + uint8_t pV = 0; Worlds->GetWorldmapFromWorldId( destWorldId, pH, pV ); char DbgMessage[128]; snprintf( DbgMessage, 128, "Vhc zoning to zone %c%02d (id %d)", ( 'a' + pV ), pH, destWorldId ); Chat->send( nClient, CHAT_GM, "Debug", DbgMessage ); } - + DoVhcZoning( tVhc, nClient->GetChar()->GetLocation(), destWorldId, &destPos ); } } @@ -176,19 +138,19 @@ bool PUdpVhcMove::DoAction() } // Failures are not managed yet -bool PUdpVhcMove::DoVhcZoning( PSpawnedVehicle* currVhc, u32 currWorldId, u32 destWorldId, PVhcCoordinates* destPos ) +bool PUdpVhcMove::DoVhcZoning( PSpawnedVehicle* currVhc, uint32_t currWorldId, uint32_t destWorldId, PVhcCoordinates* destPos ) { - u32 seatedCharsId[8]; - u32 vhcGlobalId = currVhc->GetVehicleId(); - u32 vhcLocalId = currVhc->GetLocalId(); + uint32_t seatedCharsId[8]; + uint32_t vhcGlobalId = currVhc->GetVehicleId(); + uint32_t vhcLocalId = currVhc->GetLocalId(); PVhcCoordinates currCoords = currVhc->GetPosition(); - u8 numSeats = currVhc->GetNumSeats(); - u32 sittingCharId; + uint8_t numSeats = currVhc->GetNumSeats(); + uint32_t sittingCharId; PClient* sittingClient; PClient* sittingClients[8]; PMessage* tmpMsg; - for ( u8 i = 0; i < numSeats; ++i ) + for ( uint8_t i = 0; i < numSeats; ++i ) { // Save seated chars list seatedCharsId[i] = sittingCharId = currVhc->GetSeatUser( i ); @@ -228,7 +190,7 @@ bool PUdpVhcMove::DoVhcZoning( PSpawnedVehicle* currVhc, u32 currWorldId, u32 de // Update chars seat in use and restore vhc used seats PChar* sittingChar; - for ( u8 i = 0; i < numSeats; ++i ) + for ( uint8_t i = 0; i < numSeats; ++i ) { if (( sittingClient = sittingClients[i] ) ) { @@ -243,7 +205,7 @@ bool PUdpVhcMove::DoVhcZoning( PSpawnedVehicle* currVhc, u32 currWorldId, u32 de } else { - for ( u8 i = 0; i < numSeats; ++i ) + for ( uint8_t i = 0; i < numSeats; ++i ) { if ( sittingClients[i] ) { @@ -271,7 +233,7 @@ PUdpMsgAnalyser* PUdpVhcUse::Analyse() PMessage* nMsg = mDecodeData->mMessage; nMsg->SetNextByteOffset( mDecodeData->Sub0x13Start + 12 ); - *nMsg >> mVehicleID; // u32 + *nMsg >> mVehicleID; // uint32_t *nMsg >> mVehicleSeat; if ( gDevDebug ) @@ -291,7 +253,7 @@ bool PUdpVhcUse::DoAction() PWorld* CurrentWorld = Worlds->GetWorld( nChar->GetLocation() ); if ( CurrentWorld ) { - PSpawnedVehicle* tVhc = CurrentWorld->GetSpawnedVehicules()->GetVehicle( mVehicleID ); + PSpawnedVehicle* tVhc = CurrentWorld->GetSpawnedVehicles()->GetVehicle( mVehicleID ); if ( tVhc ) { if ( tVhc->SetSeatUser( mVehicleSeat, nChar->GetID() ) ) // Char was able to sit @@ -313,13 +275,13 @@ bool PUdpVhcUse::DoAction() return true; } -void PUdpVhcUse::DoFreeSitting( PClient* nClient, PSpawnedVehicle* nVhc, u32 nRawVhcLocalId, u8 nSeatId ) +void PUdpVhcUse::DoFreeSitting( PClient* nClient, PSpawnedVehicle* nVhc, uint32_t nRawVhcLocalId, uint8_t nSeatId ) { PMessage* tmpMsg; if (( nVhc->GetNbFreeSeats() > 1 ) && ( nSeatId > nVhc->GetNumSeats() ) ) { - u8 freeSeats = nVhc->GetFreeSeatsFlags(); + uint8_t freeSeats = nVhc->GetFreeSeatsFlags(); tmpMsg = MsgBuilder->BuildCharUseVhcMsg( nClient, nRawVhcLocalId, nVhc->GetInformation().GetVehicleType(), freeSeats ); nClient->SendUDPMessage( tmpMsg ); // Open seat selection window } @@ -369,7 +331,7 @@ PUdpSubwayUpdate::PUdpSubwayUpdate( PMsgDecodeData* nDecodeData ) : PUdpMsgAnaly PUdpMsgAnalyser* PUdpSubwayUpdate::Analyse() { - u8 Dumb; + uint8_t Dumb; mDecodeData->mName << "=Subway update"; @@ -431,7 +393,7 @@ bool PUdpRequestVhcInfo::DoAction() if ( CurrentWorld ) { - PSpawnedVehicle* tVhc = CurrentWorld->GetSpawnedVehicules()->GetVehicle( mVehicleID ); + PSpawnedVehicle* tVhc = CurrentWorld->GetSpawnedVehicles()->GetVehicle( mVehicleID ); if ( tVhc ) { if ( gDevDebug ) diff --git a/TinNS/Source/GameServer/Decoder/UdpVehicle.hxx b/TinNS/Source/GameServer/Decoder/UdpVehicle.hxx new file mode 100644 index 0000000..bd93524 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpVehicle.hxx @@ -0,0 +1,66 @@ +#pragma once + +#include +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PSpawnedVehicle; +class PVhcCoordinates; + +class PUdpVhcMove : public PUdpMsgAnalyser { +private: + uint16_t mVhcLocalId; + uint16_t mNewY; + uint16_t mNewZ; + uint16_t mNewX; + uint16_t mNewLR; + uint16_t mNewRoll; + uint16_t mUnk1; // always 0x0001 ? + uint8_t mMoveType; + uint8_t mNewUD; + uint8_t mFF; // always 0xff ? + uint8_t mAction; // &1 = Left, &2 = Right, &4 = Forward, &8 = Backward + +public: + PUdpVhcMove(PMsgDecodeData *nDecodeData); + //~PUdpVhcMove(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); + bool DoVhcZoning(PSpawnedVehicle *currVhc, uint32_t currWorldId, uint32_t destWorldId, PVhcCoordinates *destPos); +}; + +class PUdpVhcUse : public PUdpMsgAnalyser { +private: + uint32_t mVehicleID; + uint8_t mVehicleSeat; + +public: + PUdpVhcUse(PMsgDecodeData *nDecodeData); + //~PUdpVhcUse(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); + static void DoFreeSitting(PClient *nClient, PSpawnedVehicle *nVhc, uint32_t nRawVhcLocalId, uint8_t nSeatId = 254); +}; + +class PUdpSubwayUpdate : public PUdpMsgAnalyser { +private: + uint32_t mVehicleID; + uint16_t mPosition; + uint8_t mDoorOpened; + +public: + PUdpSubwayUpdate(PMsgDecodeData *nDecodeData); + //~PUdpSubwayUpdate(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; + +class PUdpRequestVhcInfo : public PUdpMsgAnalyser { +private: + uint32_t mVehicleID; + +public: + PUdpRequestVhcInfo(PMsgDecodeData *nDecodeData); + //~PUdpRequestVhcInfo(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; diff --git a/server/src/game/decoder/udp_worldIDinfo.cpp b/TinNS/Source/GameServer/Decoder/UdpWorldIdInfo.cxx similarity index 60% rename from server/src/game/decoder/udp_worldIDinfo.cpp rename to TinNS/Source/GameServer/Decoder/UdpWorldIdInfo.cxx index f3f1a20..9d7b747 100644 --- a/server/src/game/decoder/udp_worldIDinfo.cpp +++ b/TinNS/Source/GameServer/Decoder/UdpWorldIdInfo.cxx @@ -1,37 +1,6 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_worldIDinfo.cpp - decoder classes for UDP "Request for more information about WorldID xx" - - CREATION: 20 Jun 2009 Namikon - - MODIFIED: - REASON: - - -*/ - -#include "main.h" -#include "udp_worldIDinfo.h" +#include "GameServer/Decoder/Includes.hxx" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" /**** PWorldIDInfoReq ****/ diff --git a/TinNS/Source/GameServer/Decoder/UdpWorldIdInfo.hxx b/TinNS/Source/GameServer/Decoder/UdpWorldIdInfo.hxx new file mode 100644 index 0000000..90b9c0b --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpWorldIdInfo.hxx @@ -0,0 +1,14 @@ +#pragma once + +#include +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PWorldIDInfoReq : public PUdpMsgAnalyser { + uint32_t mInfoId; + +public: + PWorldIDInfoReq(PMsgDecodeData *nDecodeData); + //~PWorldIDInfoReq(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; diff --git a/server/src/game/decoder/udp_zoning.cpp b/TinNS/Source/GameServer/Decoder/UdpZoning.cxx similarity index 79% rename from server/src/game/decoder/udp_zoning.cpp rename to TinNS/Source/GameServer/Decoder/UdpZoning.cxx index f7fc98d..f94e403 100644 --- a/server/src/game/decoder/udp_zoning.cpp +++ b/TinNS/Source/GameServer/Decoder/UdpZoning.cxx @@ -1,46 +1,8 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - udp_zoning.cpp - decoder classes for UDP Zoning messages - - CREATION: 06 Sep 2006 Hammag - - MODIFIED: 15 Dec 2006 Hammag - REASON: - added PUdpEndOfZoning management class - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "udp_zoning.h" -#include "udp_sync.h" - -#include "include/worlds.h" -#include "include/appartements.h" - +#include +#include "GameServer/Decoder/Includes.hxx" +#include "GameServer/Definitions/Includes.hxx" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" /**** PUdpZoning1 ****/ @@ -54,20 +16,20 @@ PUdpMsgAnalyser* PUdpZoning1::Analyse() mDecodeData->mName << "=Zoning phase 1"; PMessage* cMsg = mDecodeData->mMessage; - u8 dumb8; - u16 dumb16; + uint8_t dumb8; + uint16_t dumb16; //mUnknown = cMsg->U16Data(mDecodeData->Sub0x13Start+7); //mNewLocation = cMsg->U32Data(mDecodeData->Sub0x13Start+11); //mNewEntity = cMsg->U16Data(mDecodeData->Sub0x13Start+15); cMsg->SetNextByteOffset( mDecodeData->Sub0x13Start + 7 ); - *cMsg >> dumb8; // u8 = 0x01 in NC1, other in NC2.2 ? - *cMsg >> mUnknown; //u8 - *cMsg >> dumb16; //u16 unkown use - *cMsg >> mNewLocation; //u32 - *cMsg >> mNewEntity; //u16 - //*cMsg >> dumb16; //u16 0x0000 -//Console->Print("Zoning Stage 1: New location: %d, Entity %d, Unknown %d", mNewLocation, mNewEntity, (u16)mUnknown); + *cMsg >> dumb8; // uint8_t = 0x01 in NC1, other in NC2.2 ? + *cMsg >> mUnknown; //uint8_t + *cMsg >> dumb16; //uint16_t unkown use + *cMsg >> mNewLocation; //uint32_t + *cMsg >> mNewEntity; //uint16_t + //*cMsg >> dumb16; //uint16_t 0x0000 +//Console->Print("Zoning Stage 1: New location: %d, Entity %d, Unknown %d", mNewLocation, mNewEntity, (uint16_t)mUnknown); mDecodeData->mState = DECODE_ACTION_READY | DECODE_FINISHED; return this; @@ -91,7 +53,7 @@ bool PUdpZoning1::DoAction() PCharCoordinates &C = (mDecodeData->mClient->GetChar()->Coords); snprintf( DbgMessage, 128, "pos min/max y:%d/%d z:%d/%d x:%d/%d", C.minPos[0], C.maxPos[0], C.minPos[1], C.maxPos[1], C.minPos[2], C.maxPos[2] ); Chat->send( mDecodeData->mClient, CHAT_GM, "Debug", DbgMessage ); - + for(int i=0; i<3; i++) { C.minPos[i] = 0xffff; C.maxPos[i] = 0; } }*/ @@ -143,8 +105,8 @@ PUdpMsgAnalyser* PUdpGenrepZoning::Analyse() PMessage* cMsg = mDecodeData->mMessage; cMsg->SetNextByteOffset( mDecodeData->Sub0x13Start + 12 ); - *cMsg >> mNewLocation; // u32 - *cMsg >> mNewEntity; //u16 + *cMsg >> mNewLocation; // uint32_t + *cMsg >> mNewEntity; //uint16_t return this; } @@ -155,7 +117,7 @@ bool PUdpGenrepZoning::DoAction() return PUdpGenrepZoning::DoEffectiveZoning( mDecodeData->mClient, mNewLocation, mNewEntity ); } -bool PUdpGenrepZoning::DoEffectiveZoning( PClient* nClient, u32 nNewLocation, u16 nNewEntity ) +bool PUdpGenrepZoning::DoEffectiveZoning( PClient* nClient, uint32_t nNewLocation, uint16_t nNewEntity ) { PMessage* tmpMsg = MsgBuilder->BuildGenrepZoningMsg( nClient, nNewLocation, nNewEntity ); nClient->SendUDPMessage( tmpMsg ); @@ -189,10 +151,10 @@ PUdpMsgAnalyser* PUdpAptGRZoning::Analyse() bool PUdpAptGRZoning::DoAction() { /* - //u16 newEntity = cMsg->U16Data(mDecodeData->Sub0x13Start+12); // always 0x0047 ? Not a location/entity anyway... + //uint16_t newEntity = cMsg->U16Data(mDecodeData->Sub0x13Start+12); // always 0x0047 ? Not a location/entity anyway... - u32 newLocation = PWorlds::mAptBaseWorldId + nClient->GetChar()->GetBaseApartment(); - u16 newEntity = 0; + uint32_t newLocation = PWorlds::mAptBaseWorldId + nClient->GetChar()->GetBaseApartment(); + uint16_t newEntity = 0; */ mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED; @@ -201,8 +163,8 @@ bool PUdpAptGRZoning::DoAction() bool PUdpAptGRZoning::DoEffectiveZoning( PClient* nClient ) { - u32 newLocation = PWorlds::mAptBaseWorldId + nClient->GetChar()->GetBaseApartment(); - u16 newEntity = 0; + uint32_t newLocation = PWorlds::mAptBaseWorldId + nClient->GetChar()->GetBaseApartment(); + uint16_t newEntity = 0; PMessage* tmpMsg = MsgBuilder->BuildGenrepZoningMsg( nClient, newLocation, newEntity ); nClient->SendUDPMessage( tmpMsg ); @@ -290,7 +252,7 @@ PUdpMsgAnalyser* PUdpAppartmentAccess::Analyse() bool PUdpAppartmentAccess::DoAction() { PMessage* tmpMsg; - u32 AppLoc, Location, Entity; + uint32_t AppLoc, Location, Entity; PClient* nClient = mDecodeData->mClient; PChar* nChar = nClient->GetChar(); @@ -314,7 +276,7 @@ bool PUdpAppartmentAccess::DoAction() } else { - u32 Location = Appartements->GetAptID( mAppartmentPlace, ( u8* )mPassword ); + uint32_t Location = Appartements->GetAptID( mAppartmentPlace, ( uint8_t* )mPassword ); if ( Location > 1 ) { tmpMsg = MsgBuilder->BuildAptLiftUseMsg( nClient, Location, 1 ); diff --git a/TinNS/Source/GameServer/Decoder/UdpZoning.hxx b/TinNS/Source/GameServer/Decoder/UdpZoning.hxx new file mode 100644 index 0000000..9722fb3 --- /dev/null +++ b/TinNS/Source/GameServer/Decoder/UdpZoning.hxx @@ -0,0 +1,80 @@ +#pragma once + +#include +#include "GameServer/Decoder/UdpAnalyser.hxx" + +class PUdpZoning1 : public PUdpMsgAnalyser { +private: + uint32_t mNewLocation; + uint16_t mNewEntity; + uint8_t mUnknown; + +public: + PUdpZoning1(PMsgDecodeData *nDecodeData); + //~PUdpZoning1(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; + +class PUdpZoning2 : public PUdpMsgAnalyser { +public: + PUdpZoning2(PMsgDecodeData *nDecodeData); + //~PUdpZoning2(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; + +class PUdpGenrepZoning : public PUdpMsgAnalyser { +private: + uint32_t mNewLocation; + uint16_t mNewEntity; + +public: + PUdpGenrepZoning(PMsgDecodeData *nDecodeData); + //~PUdpGenrepZoning(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); + static bool DoEffectiveZoning(PClient *nClient, uint32_t nNewLocation, uint16_t nNewEntity); +}; + +class PUdpAptGRZoning : public PUdpMsgAnalyser { +public: + PUdpAptGRZoning(PMsgDecodeData *nDecodeData); + //~PUdpAptGRZoning(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); + static bool DoEffectiveZoning(PClient *nClient); +}; + +class PUdpAddGenrepToList : public PUdpMsgAnalyser { +private: + uint32_t mLocation; + uint16_t mEntity; + +public: + PUdpAddGenrepToList(PMsgDecodeData *nDecodeData); + //~PUdpAddGenrepToList(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; + +class PUdpAppartmentAccess : public PUdpMsgAnalyser { +private: + uint16_t mAppartmentPlace; + char *mPassword; + +public: + PUdpAppartmentAccess(PMsgDecodeData *nDecodeData); + //~PUdpAppartmentAccess(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; + + +class PUdpEndOfZoning : public PUdpMsgAnalyser { +public: + PUdpEndOfZoning(PMsgDecodeData *nDecodeData); + //~PUdpEndOfZoning(); + PUdpMsgAnalyser *Analyse(); + bool DoAction(); +}; diff --git a/TinNS/Source/GameServer/Definitions/ActionMod.cxx b/TinNS/Source/GameServer/Definitions/ActionMod.cxx new file mode 100644 index 0000000..ac24add --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/ActionMod.cxx @@ -0,0 +1,49 @@ +#include "GameServer/Definitions/Includes.hxx" + +PDefActionMod::PDefActionMod() +{ +} + +bool PDefActionMod::LoadFromDef( PTokenList *Tokens ) +{ + int Idx = 0; + int maxFields = 3; + for ( PTokenList::iterator i = Tokens->begin(); i != Tokens->end(); i++, Idx++ ) + { + switch ( Idx ) + { + case 0 : // setentry + break; + case 1 : + mIndex = atoi( i->c_str() ); break; + case 2 : + mStartValue = atof( i->c_str() ); break; + case 3 : + { + mNumOfSsq = atoi( i->c_str() ); + if( mNumOfSsq > 8 ) + mNumOfSsq = 8; + maxFields = 3 + 2 * mNumOfSsq; + break; + } + default : + if( (Idx >= 4) && (Idx <= maxFields) ) + { + if(Idx & 1) + { + mModFactor[(Idx - 4) / 2] = atof( i->c_str() ); + } + else + { + mSsqId[(Idx - 4) / 2] = atoi( i->c_str() ); + } + } + break; + } + + if ( Idx >= maxFields ) + break; + } + + return ((Idx == maxFields)); +} diff --git a/TinNS/Source/GameServer/Definitions/ActionMod.hxx b/TinNS/Source/GameServer/Definitions/ActionMod.hxx new file mode 100644 index 0000000..1c689c4 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/ActionMod.hxx @@ -0,0 +1,24 @@ +#pragma once + +#include +#include "GameServer/Definitions/Definition.hxx" + +class PDefActionMod : public PDef { +private: + //int mIndex; + float mStartValue; + int32_t mNumOfSsq; + int32_t mSsqId[8]; + float mModFactor[8]; + +public: + PDefActionMod(); + //~PDefActionMod(); + + bool LoadFromDef(PTokenList *Tokens); + + inline float GetStartValue() const { return mStartValue; } + inline int32_t GetNumOfSsq() const { return mNumOfSsq; } + inline int32_t GetSsqId(int32_t nIdx) const { return ( ((nIdx >= 0) && (nIdx < mNumOfSsq)) ? mSsqId[nIdx] : 0) ; } + inline float GetModFactor(int32_t nIdx) const { return ( ((nIdx >= 0) && (nIdx < mNumOfSsq)) ? mModFactor[nIdx] : 0) ; } +}; diff --git a/TinNS/Source/GameServer/Definitions/Ammo.cxx b/TinNS/Source/GameServer/Definitions/Ammo.cxx new file mode 100644 index 0000000..ad8fb12 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Ammo.cxx @@ -0,0 +1,36 @@ +#include "GameServer/Definitions/Includes.hxx" + +PDefAmmo::PDefAmmo() +{ + mShotId = mMagSize = mWeaponShotId = mDamageId = 0; +} + +bool PDefAmmo::LoadFromDef( PTokenList *Tokens ) +{ + int Idx = 0; + for ( PTokenList::iterator i = Tokens->begin(); i != Tokens->end(); i++, Idx++ ) + { + switch ( Idx ) + { + case 0 : // setentry + break; + case 1 : + mIndex = atoi( i->c_str() ); break; + case 2 : + mDamageId = atoi( i->c_str() ); break; + case 3 : + mWeaponShotId = atoi( i->c_str() ); break; + case 4 : + mMagSize = atoi( i->c_str() ); break; + case 5 : + mShotId = atoi( i->c_str() ); break; + default : + break; + } + + if ( Idx >= 5 ) + break; + } + + return ((Idx >= 4)); +} diff --git a/TinNS/Source/GameServer/Definitions/Ammo.hxx b/TinNS/Source/GameServer/Definitions/Ammo.hxx new file mode 100644 index 0000000..8ef4899 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Ammo.hxx @@ -0,0 +1,24 @@ +#pragma once + +#include +#include "GameServer/Definitions/Definition.hxx" + +class PDefAmmo : public PDef { +private: + //int32_t mIndex; + int32_t mDamageId; // related to damage.def + int32_t mWeaponShotId; // related to shots.def ? + int32_t mMagSize; + int32_t mShotId; // related to shots.def ??? strange: hardly ever set in ammo.def + +public: + PDefAmmo(); + //~PDefAmmo(); + + bool LoadFromDef( PTokenList *Tokens ); + + inline int32_t GetDamageId() const { return mDamageId; } + inline int32_t GetWeaponShotId() const { return mWeaponShotId; } + inline int32_t GetMagSize() const { return mMagSize; } + inline int32_t GetShotId() const { return mShotId; } +}; diff --git a/TinNS/Source/GameServer/Definitions/AppartementPlaces.cxx b/TinNS/Source/GameServer/Definitions/AppartementPlaces.cxx new file mode 100644 index 0000000..fa6078a --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/AppartementPlaces.cxx @@ -0,0 +1,35 @@ +#include "GameServer/Definitions/Includes.hxx" + +PDefAppPlace::PDefAppPlace() +{ +} + +bool PDefAppPlace::LoadFromDef(PTokenList *Tokens) +{ + int Idx=0; + for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++) + { + switch(Idx) + { + case 0: // setentry + continue; + + case 1: // index + mIndex = atoi(i->c_str()); break; + + case 2: // name + mName = *i; break; + + case 3: // Exit World + mExitWorldID = atoi(i->c_str()); break; + + case 4: // Exit World entity + mExitWorldEntity = atoi(i->c_str()); break; + + case 5: // Sewer level + mSewerLevel = atoi(i->c_str()); break; + } + } + + return true; +} diff --git a/TinNS/Source/GameServer/Definitions/AppartementPlaces.hxx b/TinNS/Source/GameServer/Definitions/AppartementPlaces.hxx new file mode 100644 index 0000000..18d0268 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/AppartementPlaces.hxx @@ -0,0 +1,25 @@ +#pragma once + +#include +#include +#include "GameServer/Definitions/Definition.hxx" + +class PDefAppPlace : public PDef { +private : + //int32_t mIndex; + std::string mName; + int32_t mExitWorldID; + int32_t mExitWorldEntity; + int32_t mSewerLevel; + +public : + PDefAppPlace(); + //~PDefAppPlace(); + + bool LoadFromDef(PTokenList *Tokens); + + inline const std::string &GetName() const { return mName; } + inline int32_t GetExitWorldID() const { return mExitWorldID; } + inline int32_t GetExitWorldEntity() const { return mExitWorldEntity; } + inline int32_t GetSewerLevel() const { return mSewerLevel; } +}; diff --git a/TinNS/Source/GameServer/Definitions/Appartements.cxx b/TinNS/Source/GameServer/Definitions/Appartements.cxx new file mode 100644 index 0000000..9f37a69 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Appartements.cxx @@ -0,0 +1,50 @@ +#include "GameServer/Definitions/Includes.hxx" + +PDefAppartement::PDefAppartement() +{ +} + +bool PDefAppartement::LoadFromDef(PTokenList *Tokens) +{ + mFaction = 0; + int Idx=0; + for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++) + { + switch(Idx) + { + case 0: // setentry + continue; + + case 1: // index + mIndex = atoi(i->c_str()); break; + + case 2: // name + mName = *i; break; + + case 3: // world name + mWorldName = *i; break; + + case 4: // value + mValue = atoi(i->c_str()); break; + + case 5: // number of places + mPlaceCount = atoi(i->c_str()); break; + + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + mPlace[Idx-6] = atoi(i->c_str()); break; + + case 14: // faction if base appartement + mFaction = atoi(i->c_str()); break; + } + } +//Console->Print("%04d:%s file:%s val:%d places:%d pl1:%d pl2:%d pl8:%d faction:%d", +// mIndex, mName.c_str(), mWorldName.c_str(), mValue, mPlaceCount, mPlace[0], mPlace[1], mPlace[7], mFaction); + return true; +} diff --git a/TinNS/Source/GameServer/Definitions/Appartements.hxx b/TinNS/Source/GameServer/Definitions/Appartements.hxx new file mode 100644 index 0000000..58dd293 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Appartements.hxx @@ -0,0 +1,37 @@ +#pragma once + +#include +#include +#include "GameServer/Definitions/Definition.hxx" +#include "GameServer/Definitions/Map.hxx" + +class PDefAppartement : public PDef { +private: + //int32_t mIndex; + std::string mName; + std::string mWorldName; + int32_t mValue; + int32_t mPlaceCount; + int32_t mPlace[8]; + int32_t mFaction; + +public: + PDefAppartement(); + //~PDefAppartement(); + + bool LoadFromDef(PTokenList *Tokens); + + inline int32_t GetID() const { return mIndex; } + inline const std::string &GetName() const { return mName; } + inline const std::string &GetWorldName() const { return mWorldName; } + inline int32_t GetValue() const { return mValue; } + inline int32_t GetPlaceCount() const { return mPlaceCount; } + inline int32_t GetPlace(int32_t nIdx) const { return ( (nIdx < mPlaceCount) ? mPlace[nIdx] : 0 ); } + inline int32_t GetFaction() const { return mFaction; } +}; + +class PDefAppartementsMap : public PDefMap { +public: + inline std::map::const_iterator ConstIteratorBegin() const { return mDefs.begin(); } + inline std::map::const_iterator ConstIteratorEnd() const { return mDefs.end(); } +}; diff --git a/TinNS/Source/GameServer/Definitions/BluePrintPieces.cxx b/TinNS/Source/GameServer/Definitions/BluePrintPieces.cxx new file mode 100644 index 0000000..95513f3 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/BluePrintPieces.cxx @@ -0,0 +1,43 @@ +#include "GameServer/Definitions/Includes.hxx" + +PDefBlueprintPieces::PDefBlueprintPieces() +{ +} + + +bool PDefBlueprintPieces::LoadFromDef( PTokenList *Tokens ) +{ + int Idx = 0; + int maxFields = 3; + for ( PTokenList::iterator i = Tokens->begin(); i != Tokens->end(); i++, Idx++ ) + { + switch ( Idx ) + { + case 0 : // setentry + break; + case 1 : + mIndex = atoi( i->c_str() ); break; + case 2 : + mMaxPieceNum = atoi( i->c_str() ); break; + case 3 : + { + mPieceNum = atoi( i->c_str() ); + if ( mPieceNum > 20 ) + mPieceNum = 20; + maxFields = 3 + mPieceNum; + break; + } + default : + if (( Idx >= 4 ) && ( Idx <= maxFields ) ) + { + mPieceId[ Idx - 4 ] = atoi( i->c_str() ); + } + break; + } + + if ( Idx >= maxFields ) + break; + } + + return (( Idx == maxFields ) ); +} diff --git a/TinNS/Source/GameServer/Definitions/BluePrintPieces.hxx b/TinNS/Source/GameServer/Definitions/BluePrintPieces.hxx new file mode 100644 index 0000000..c1cbd21 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/BluePrintPieces.hxx @@ -0,0 +1,22 @@ +#pragma once + +#include +#include "GameServer/Definitions/Definition.hxx" + +class PDefBlueprintPieces : public PDef { +private: + //int32_t mIndex; // related Item Type + int32_t mMaxPieceNum; + int32_t mPieceNum; + int32_t mPieceId[20]; + +public: + PDefBlueprintPieces(); + //~PDefBlueprint32_tPieces(); + + bool LoadFromDef( PTokenList *Tokens ); + + inline int32_t GetMaxPieceNum() const { return mMaxPieceNum; } + inline int32_t GetPieceNum() const { return mPieceNum; } + inline int32_t GetPieceId(int32_t nIdx) const { return ( ((nIdx >= 0) && (nIdx < mPieceNum)) ? mPieceId[nIdx] : 0) ; } +}; diff --git a/TinNS/Source/GameServer/Definitions/CMakeLists.txt b/TinNS/Source/GameServer/Definitions/CMakeLists.txt new file mode 100644 index 0000000..a32c0be --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/CMakeLists.txt @@ -0,0 +1,7 @@ +ADD_LIBRARY (Definitions ActionMod.cxx Ammo.cxx AppartementPlaces.cxx Appartements.cxx BluePrintPieces.cxx + CharacterActions.cxx CharacterKinds.cxx Characters.cxx Damage.cxx Definition.cxx Drugs.cxx + Factions.cxx GameDefinitions.cxx Hack.cxx Implants.cxx ItemContainer.cxx ItemMod.cxx + ItemRes.cxx Items.cxx Mission.cxx Npc.cxx NpcArmor.cxx NpcGroupSpawn.cxx Outposts.cxx + Parser.cxx Recycles.cxx Respawn.cxx Scripts.cxx Shots.cxx Skills.cxx SubSkills.cxx Trader.cxx + VehicleSits.cxx Vehicles.cxx Weapons.cxx Weather.cxx WorldDatParser.cxx WorldFile.cxx + WorldModels.cxx Worlds.cxx) diff --git a/TinNS/Source/GameServer/Definitions/CharacterActions.cxx b/TinNS/Source/GameServer/Definitions/CharacterActions.cxx new file mode 100644 index 0000000..ab62e2b --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/CharacterActions.cxx @@ -0,0 +1,47 @@ +#include "GameServer/Definitions/Includes.hxx" + +PDefCharAction::PDefCharAction() +{ +} + +bool PDefCharAction::LoadFromDef( PTokenList *Tokens ) +{ + int Idx = 0; + int maxFields = 2; + for ( PTokenList::iterator i = Tokens->begin(); i != Tokens->end(); i++, Idx++ ) + { + switch ( Idx ) + { + case 0 : // setentry + break; + case 1 : + mIndex = atoi( i->c_str() ); break; + case 2 : + { + mNumOfSsq = atoi( i->c_str() ); + if ( mNumOfSsq > 8 ) + mNumOfSsq = 8; + maxFields = 2 + 2 * mNumOfSsq; + break; + } + default : + if (( Idx >= 3 ) && ( Idx <= maxFields ) ) + { + if ( Idx & 1 ) + { + mSsqId[( Idx - 3 ) / 2] = atoi( i->c_str() ); + } + else + { + mModFactor[( Idx - 3 ) / 2] = atof( i->c_str() ); + } + } + break; + } + + if ( Idx >= maxFields ) + break; + } + + return (( Idx == maxFields ) ); +} diff --git a/TinNS/Source/GameServer/Definitions/CharacterActions.hxx b/TinNS/Source/GameServer/Definitions/CharacterActions.hxx new file mode 100644 index 0000000..6d2938b --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/CharacterActions.hxx @@ -0,0 +1,22 @@ +#pragma once + +#include +#include "GameServer/Definitions/Definition.hxx" + +class PDefCharAction : public PDef { +private: + //int32_t mIndex; + int32_t mNumOfSsq; + int32_t mSsqId[8]; + float mModFactor[8]; + +public: + PDefCharAction(); + //~PDefCharAction(); + + bool LoadFromDef( PTokenList *Tokens ); + + inline int32_t GetNumOfSsq() const { return mNumOfSsq; } + inline int32_t GetSsqId(int32_t nIdx) const { return ( ((nIdx >= 0) && (nIdx < mNumOfSsq)) ? mSsqId[nIdx] : 0) ; } + inline int32_t GetModFactor(int32_t nIdx) const { return ( ((nIdx >= 0) && (nIdx < mNumOfSsq)) ? mModFactor[nIdx] : 0) ; } +}; diff --git a/TinNS/Source/GameServer/Definitions/CharacterKinds.cxx b/TinNS/Source/GameServer/Definitions/CharacterKinds.cxx new file mode 100644 index 0000000..4ee96b9 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/CharacterKinds.cxx @@ -0,0 +1,152 @@ +#include +#include "GameServer/Definitions/Includes.hxx" +#include "GameServer/Includes.hxx" + +// charkinds are character templates used for player char creation + +PDefCharKind::PDefCharKind() +{ + mSkillInfo = 0; + memset(mInventory, 0, sizeof(mInventory)); +} + +PDefCharKind::~PDefCharKind() +{ + delete [] mSkillInfo; + for(PSkillPtsMap::const_iterator i=mSkillPts.begin(); i!=mSkillPts.end(); i++) + delete i->second; + for(PSubSkillPtsMap::const_iterator i=mSubSkillPts.begin(); i!=mSubSkillPts.end(); i++) + delete i->second; + for(PStartLevelMap::const_iterator i=mStartLevels.begin(); i!=mStartLevels.end(); i++) + delete i->second; +} + +bool PDefCharKind::LoadFromDef(PTokenList *Tokens) +{ + int NumSkills = GameDefs->Skills()->GetNumDefs(); + //int NumSubSkills = GameDefs->SubSkills()->GetNumDefs(); + + int SkillInfoStart = 4; + int TrainPtsStart = SkillInfoStart+NumSkills*3; + int LevelsStart = TrainPtsStart + 32*2; + int MoneyStart = LevelsStart + 16*2; + int InventoryStart = MoneyStart+1; + + mSkillInfo = new PSkillInfo[NumSkills]; + + int Idx=0; + for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++) + { + switch(Idx) + { + case 0 : // setentry + continue; + + case 1 : + mIndex = atoi(i->c_str()); break; + + case 2 : + mName = *i; break; + + case 3 : + mType = atoi(i->c_str()); break; + + } + + if((Idx >= SkillInfoStart) && (Idx < TrainPtsStart)) // skill info + { + int SkillIdx = (Idx-SkillInfoStart)/3; + int Value = atoi(i->c_str()); + + // start, max, grow per skill + switch((Idx-SkillInfoStart)%3) + { + case 0 : mSkillInfo[SkillIdx].mStart = Value; break; + case 1 : mSkillInfo[SkillIdx].mMax = Value; break; + case 2 : mSkillInfo[SkillIdx].mGrow = Value; break; + } + } else + // 32 skill/subskill train pts + if((Idx >= TrainPtsStart) && (Idx < LevelsStart)) + { + static int SkillIndex = 0; + int Index = Idx-TrainPtsStart; + if((Index&1)==0) + { + SkillIndex = atoi(i->c_str()); + } else + { + if(SkillIndex >= 1000) // skill + { + const PDefSkill *Skill = GameDefs->Skills()->GetDef(SkillIndex-1000); + if(Skill) + { + int Index = Skill->GetIndex()-1; + PSkillPtsInfo *CurrentSkillPts = new PSkillPtsInfo(); + CurrentSkillPts->mSkill = Index; + CurrentSkillPts->mPoints = atoi(i->c_str()); + mSkillPts.insert(std::make_pair(Index, CurrentSkillPts)); + } else + { + if(SkillIndex-1000 != 0) + Console->Print("Charkind def: invalid skill index %i", SkillIndex-1000); + } + } else // subskill + { + const PDefSubSkill *SubSkill = GameDefs->SubSkills()->GetDef(SkillIndex); + if(SubSkill) + { + int Index = SubSkill->GetIndex()-1; + PSubSkillPtsInfo *CurrentSubSkillPts = new PSubSkillPtsInfo(); + CurrentSubSkillPts->mSubSkill = Index; + CurrentSubSkillPts->mPoints = atoi(i->c_str()); + mSubSkillPts.insert(std::make_pair(Index, CurrentSubSkillPts)); + } else + { + if(SkillIndex != 0) + Console->Print("Charkind def: invalid subskill index %i", SkillIndex); + } + } + } + } else + // 16 subskill start levels + if((Idx >= LevelsStart) && (Idx < MoneyStart)) + { + static int LevelIndex = 0; + int Index = Idx-NumSkills*3+4+(32*2); + if((Index&1)==0) + { + LevelIndex = atoi(i->c_str()); + } else + { + if(LevelIndex > 0) + { + const PDefSubSkill *SubSkill = GameDefs->SubSkills()->GetDef(LevelIndex); + if(SubSkill) + { + PStartLevelInfo *Level = new PStartLevelInfo(); + Level->mSubSkill = SubSkill->GetIndex(); + Level->mLevel = atoi(i->c_str()); + mStartLevels.insert(std::make_pair(Level->mSubSkill, Level)); + } else + { + Console->Print("Charkind def: invalid subskill index %i", LevelIndex); + } + } + } + } else + // money + if((Idx >= MoneyStart) && (Idx < InventoryStart)) + { + mMoney = atoi(i->c_str()); + } else + // inventory + if((Idx >= InventoryStart) && (Idx < InventoryStart+8)) + { + mInventory[Idx-InventoryStart] = atoi(i->c_str()); + } + } + + return true; +} + diff --git a/TinNS/Source/GameServer/Definitions/CharacterKinds.hxx b/TinNS/Source/GameServer/Definitions/CharacterKinds.hxx new file mode 100644 index 0000000..4f86772 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/CharacterKinds.hxx @@ -0,0 +1,82 @@ +#pragma once + +#include +#include +#include +#include "GameServer/Definitions/Definition.hxx" + +struct PSkillInfo { + int32_t mStart; + int32_t mMax; + int32_t mGrow; + + inline PSkillInfo() + { + mStart = mMax = mGrow = 0; + } +}; + +struct PSkillPtsInfo { + int32_t mSkill; + int32_t mPoints; + + inline PSkillPtsInfo() + { + mSkill = mPoints = 0; + } +}; + +struct PSubSkillPtsInfo { + int32_t mSubSkill; + int32_t mPoints; + + inline PSubSkillPtsInfo() + { + mSubSkill = mPoints = 0; + } +}; + +struct PStartLevelInfo { + int32_t mSubSkill; + int32_t mLevel; + + inline PStartLevelInfo() + { + mSubSkill = mLevel = 0; + } + +}; + +class PDefCharKind : public PDef { +private: + typedef std::map PSkillPtsMap; + typedef std::map PSubSkillPtsMap; + typedef std::map PStartLevelMap; + + //int32_t mIndex; + std::string mName; + int32_t mType; + + // TODO: shouldnt this be a map? + PSkillInfo *mSkillInfo; + + PSkillPtsMap mSkillPts; + PSubSkillPtsMap mSubSkillPts; + PStartLevelMap mStartLevels; + int32_t mMoney; + uint32_t mInventory[8]; + +public: + PDefCharKind(); + ~PDefCharKind(); + + bool LoadFromDef(PTokenList *Tokens); + + inline const std::string &GetName() const { return mName; } + inline int32_t GetType() const { return mType; } + inline const PSkillInfo &GetSkillInfo(int32_t Skill) const { return mSkillInfo[Skill-1]; } + + inline int32_t GetStartMoney() const { return mMoney; } + inline uint32_t GetStartInventory(uint8_t Index) const { return ((Index < 7) ? mInventory[Index] : 0); } + // TODO: mission get() functions +}; diff --git a/TinNS/Source/GameServer/Definitions/Characters.cxx b/TinNS/Source/GameServer/Definitions/Characters.cxx new file mode 100644 index 0000000..95b2ddf --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Characters.cxx @@ -0,0 +1,55 @@ +#include "GameServer/Definitions/Includes.hxx" + +// characters.def contains all ingame characters (player types, npc's, monsters) + +PDefCharacter::PDefCharacter() +{ + mIndex = -1; + mName = "unknown"; + mModel = -1; +} + +bool PDefCharacter::LoadFromDef(PTokenList *Tokens) +{ + int Idx=0; + for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++) + { + switch(Idx) + { + case 0 : // setentry + continue; + + case 1 : + mIndex = atoi(i->c_str()); break; + + case 2 : + mName = *i; break; + + case 3 : + mModel = atoi(i->c_str()); break; + + case 4 : // 0 + continue; + + case 5 : + mHead = atoi(i->c_str()); break; + + case 6 : + mTorso = atoi(i->c_str()); break; + + case 7 : + mLegs = atoi(i->c_str()); break; + + case 8 : + mColor = atoi(i->c_str()); break; + + case 9 : + mBrightness = atoi(i->c_str()); break; + } + + if(Idx==9) + return true; + } + + return false; +} diff --git a/TinNS/Source/GameServer/Definitions/Characters.hxx b/TinNS/Source/GameServer/Definitions/Characters.hxx new file mode 100644 index 0000000..3abc2c0 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Characters.hxx @@ -0,0 +1,31 @@ +#pragma once + +#include +#include +#include "GameServer/Definitions/Definition.hxx" + +class PDefCharacter : public PDef { +private: + //int32_t mIndex; + std::string mName; + int32_t mModel; + int32_t mHead; + int32_t mTorso; + int32_t mLegs; + int32_t mColor; + int32_t mBrightness; + +public: + PDefCharacter(); + //~PDefCharacter(); + + bool LoadFromDef(PTokenList *Tokens); + + inline const std::string &GetName() const { return mName; } + inline int32_t GetModel() const { return mModel; } + inline int32_t GetHead() const { return mHead; } + inline int32_t GetTorso() const { return mTorso; } + inline int32_t GetLegs() const { return mLegs; } + inline int32_t GetColor() const { return mColor; } + inline int32_t GetBrightness() const { return mBrightness; } +}; diff --git a/server/src/game/def/def_damage.cpp b/TinNS/Source/GameServer/Definitions/Damage.cxx similarity index 62% rename from server/src/game/def/def_damage.cpp rename to TinNS/Source/GameServer/Definitions/Damage.cxx index e8e852e..9ddc793 100644 --- a/server/src/game/def/def_damage.cpp +++ b/TinNS/Source/GameServer/Definitions/Damage.cxx @@ -1,40 +1,4 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_damage.cpp - - CREATED: 04 Apr 2009 Hammag - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "include/def_damage.h" - +#include "GameServer/Definitions/Includes.hxx" PDefDamage::PDefDamage() { diff --git a/TinNS/Source/GameServer/Definitions/Damage.hxx b/TinNS/Source/GameServer/Definitions/Damage.hxx new file mode 100644 index 0000000..fd43914 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Damage.hxx @@ -0,0 +1,36 @@ +#pragma once + +#include +#include "GameServer/Definitions/Definition.hxx" + +class PDefDamage : public PDef { +private: + //int32_t mIndex; + //int32_t mSoundIndex; // no use + int32_t mDamageNum; + int32_t mDamageValue[4]; + int32_t mDamageEffect[4]; + int32_t mDamageType[4]; + /* int32_t mEffectNum; // Are effects needed ? (server or client triggered ?) + int32_t mEffectId[4]; // ? + int32_t mEffectTarget[4]; // float ? + int32_t mEffectValue[4]; // float ? + int32_t mEffectamorId[4]; // ???? + */ +public: + PDefDamage(); + //~PDefDamage(); + + bool LoadFromDef ( PTokenList *Tokens ); + + inline int32_t GetDamageNum() const { return mDamageNum; } + inline int32_t GetDamageValue ( int32_t nIdx ) const { return ( ( ( nIdx >= 0 ) && ( nIdx < mDamageNum ) ) ? mDamageValue[nIdx] : 0 ) ; } + inline int32_t GetDamageEffect ( int32_t nIdx ) const { return ( ( ( nIdx >= 0 ) && ( nIdx < mDamageNum ) ) ? mDamageEffect[nIdx] : 0 ) ; } + inline int32_t GetDamageType ( int32_t nIdx ) const { return ( ( ( nIdx >= 0 ) && ( nIdx < mDamageNum ) ) ? mDamageType[nIdx] : 0 ) ; } + /* inline int32_t GetEffectNum() const { return mEffectNum; } + inline int32_t GetEffectId(int32_t nIdx) const { return ( ((nIdx >= 0) && (nIdx < mEffectNum)) ? mEffectId[nIdx] : 0) ; } + inline int32_t GetEffectTarget(int32_t nIdx) const { return ( ((nIdx >= 0) && (nIdx < mEffectNum)) ? mEffectTarget[nIdx] : 0) ; } + inline int32_t GetEffectValue(int32_t nIdx) const { return ( ((nIdx >= 0) && (nIdx < mEffectNum)) ? mEffectValue[nIdx] : 0) ; } + inline int32_t GetEffectamorId(int32_t nIdx) const { return ( ((nIdx >= 0) && (nIdx < mEffectNum)) ? mEffectamorId[nIdx] : 0) ; } + */ +}; diff --git a/TinNS/Source/GameServer/Definitions/Definition.cxx b/TinNS/Source/GameServer/Definitions/Definition.cxx new file mode 100644 index 0000000..6eb9c6d --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Definition.cxx @@ -0,0 +1,27 @@ +#include "GameServer/Definitions/Includes.hxx" + +PDef::PDef() +: mIndex(0) +{ +} + +PDef::~PDef() +{ +} + +bool PDef::LoadFromDef(PTokenList *Tokens) +{ + Tokens = Tokens; + + return false; +} + +int32_t PDef::GetIndex() const +{ + return mIndex; +} + +const std::string &PDef::GetName() const +{ + return ""; +} diff --git a/TinNS/Source/GameServer/Definitions/Definition.hxx b/TinNS/Source/GameServer/Definitions/Definition.hxx new file mode 100644 index 0000000..c26e01d --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Definition.hxx @@ -0,0 +1,23 @@ +#pragma once + +#include +#include +#include + +typedef std::list PTokenList; + +/* mother class for PDef* classes */ +/* provides default members required for def file loading */ +class PDef { +protected: + int32_t mIndex; + +public: + PDef(); + virtual ~PDef(); + + bool LoadFromDef(PTokenList *Tokens); + + int32_t GetIndex() const; + const std::string &GetName() const; +}; diff --git a/server/src/game/def/def_drugs.cpp b/TinNS/Source/GameServer/Definitions/Drugs.cxx similarity index 54% rename from server/src/game/def/def_drugs.cpp rename to TinNS/Source/GameServer/Definitions/Drugs.cxx index 4326874..f21bbd0 100644 --- a/server/src/game/def/def_drugs.cpp +++ b/TinNS/Source/GameServer/Definitions/Drugs.cxx @@ -1,40 +1,4 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_drug.cpp - - CREATED: 04 Apr 2009 Hammag - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "include/def_drugs.h" - +#include "GameServer/Definitions/Includes.hxx" PDefDrug::PDefDrug() { diff --git a/TinNS/Source/GameServer/Definitions/Drugs.hxx b/TinNS/Source/GameServer/Definitions/Drugs.hxx new file mode 100644 index 0000000..76f8c4a --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Drugs.hxx @@ -0,0 +1,44 @@ +#pragma once + +#include +#include "GameServer/Definitions/Definition.hxx" + +class PDefDrug : public PDef { +protected: + //int32_t mIndex; + int32_t mType; + //int32_t mUseSound; + int32_t mDuration; + int32_t mChangeNum; + int32_t mChangeType[8]; // 1: bonus, 2:malus, ... other ? + float mChangeScale[8]; + int32_t mChangeTarget[8]; + +public: + PDefDrug(); + //~PDefDrug(); + + bool LoadFromDef( PTokenList *Tokens ); + + inline int32_t GetType() const { return mType; } + inline int32_t GetDuration() const { return mDuration; } + inline int32_t GetChangeNum() const { return mChangeNum; } + inline int32_t GetChangeType( int32_t nIdx ) const { return ((( nIdx >= 0 ) && ( nIdx < mChangeNum ) ) ? mChangeType[nIdx] : 0 ) ; } + inline float GetChangeScale( int32_t nIdx ) const { return ((( nIdx >= 0 ) && ( nIdx < mChangeNum ) ) ? mChangeScale[nIdx] : 0 ) ; } + inline int32_t GetChangeTarget( int32_t nIdx ) const { return ((( nIdx >= 0 ) && ( nIdx < mChangeNum ) ) ? mChangeTarget[nIdx] : 0 ) ; } +}; + +//type of drug: +//1 normal Drug +//2 Skill ver�ndernder PSI Spruch K�mpfer +//3 Skill ver�ndernder PSI Spruch Supporter +//4 Skill ver�ndernder PSI Spruch Resists +//6+A274 PSI entferne Sprcuh + +// drugeffects < 1000 Subskill +// <2000 Skill +// <2100 Energy (permanent) +// <2200 Maxenergy +// <2300 Armor +// <2400 Subskills +// 3000-3500 Actionmods diff --git a/TinNS/Source/GameServer/Definitions/Factions.cxx b/TinNS/Source/GameServer/Definitions/Factions.cxx new file mode 100644 index 0000000..2e5ab9a --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Factions.cxx @@ -0,0 +1,56 @@ +#include +#include "GameServer/Definitions/Includes.hxx" + +PDefFaction::PDefFaction() +{ + memset(mRelations, 0, sizeof(mRelations)); // ... array members supposed to by auto-initialized by C++ +} + +bool PDefFaction::LoadFromDef(PTokenList *Tokens) +{ + int Idx=0; + for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++) + { + // setfracc 19 "Monster" -1024 0 0 -1024 -1024 -1024 -1 + switch(Idx) + { + case 0 : // setfrac + continue; + + case 1 : + mIndex = atol(i->c_str()); break; + + case 2 : + mName = *i; + CleanUpString(&mName); + break; + + case 3 : + mStartValue = atol(i->c_str()); break; + + case 4: + mAffected = atol(i->c_str())!=0; break; + + case 5: + mSL = atol(i->c_str()); break; + + default : + { + if(Idx-6 < NUMFACTIONS) + mRelations[Idx-6] = atol(i->c_str()); break; + } + } + } + + return true; +} + +int PDefFaction::GetRelation(int Faction) const +{ + // faction 0 has no relations + if(Faction <= 0 || Faction > NUMFACTIONS) + return 0; + + return mRelations[Faction-1]; +} + diff --git a/TinNS/Source/GameServer/Definitions/Factions.hxx b/TinNS/Source/GameServer/Definitions/Factions.hxx new file mode 100644 index 0000000..22f35a4 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Factions.hxx @@ -0,0 +1,28 @@ +#pragma once + +#include +#include +#include "GameServer/Definitions/Definition.hxx" + +static const int32_t NUMFACTIONS = 20; // for faction relations only + +class PDefFaction : public PDef { +private : + //int32_t mIndex; + std::string mName; + int32_t mStartValue; + bool mAffected; + int32_t mSL; + int32_t mRelations[NUMFACTIONS]; +public : + PDefFaction(); + //~PDefFaction(); + + bool LoadFromDef(PTokenList *Tokens); + + inline const std::string &GetName() const { return mName; } + inline int32_t GetStartValue() const { return mStartValue; } + inline bool GetAffected() const { return mAffected; } + inline int32_t GetSL() const { return mSL; }; + int32_t GetRelation(int32_t Faction) const; +}; diff --git a/server/src/game/def/gamedefs.cpp b/TinNS/Source/GameServer/Definitions/GameDefinitions.cxx similarity index 63% rename from server/src/game/def/gamedefs.cpp rename to TinNS/Source/GameServer/Definitions/GameDefinitions.cxx index bd2292c..b056c3b 100644 --- a/server/src/game/def/gamedefs.cpp +++ b/TinNS/Source/GameServer/Definitions/GameDefinitions.cxx @@ -1,51 +1,6 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ +#include "GameServer/Definitions/Includes.hxx" /* - - gamedefs - this part loads "all" the definitions found in defs/ - - MODIFIED: 30 August 2005 Akiko - REASON: - added this fency header - - changed the path of every def file to fellow the TinNS way (loading by the config.xml) - - reformated code for easier reading - MODIFIED: 31 August 2005 Akiko - REASON: - updated paths for the def files - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL - MODIFIED: 06 Jan 2006 - REASON: - Added GetCharKindDef(), was missing somehow - MODIFIED: 21 Sep 2005 Hammag - REASON: - Added PDefWorldModel related stuff - - Added PDefAppPlace related stuff - - completed PGameDefs destructor - MODIFIED: 22 Sep 2005 Hammag - REASON: - Added PDefAppartement related stuff - - Added PDefRespawn related stuff - MODIFIED: 28 Sep 2005 Hammag - REASON: - Added PDefWorldFile related stuff - - MODIFIED: 07 Oct 2005 Hammag - REASON: - Added (inline) methods to get const iterators on Appartment and WorldFile maps - -------------------------------------------------------------------- WARNING: When adding new .def support, don't forget to add required stuff in PGameDefs::Init() @@ -59,11 +14,8 @@ appending pak_ to its name, - else tries to load the packed file from the .pak archive which name is derived from the last part of the path. - */ -#include "main.h" - PGameDefs::PGameDefs() {} PGameDefs::~PGameDefs() {} diff --git a/server/src/game/include/gamedefs.h b/TinNS/Source/GameServer/Definitions/GameDefinitions.hxx similarity index 79% rename from server/src/game/include/gamedefs.h rename to TinNS/Source/GameServer/Definitions/GameDefinitions.hxx index 32f221e..d1de8d8 100644 --- a/server/src/game/include/gamedefs.h +++ b/TinNS/Source/GameServer/Definitions/GameDefinitions.hxx @@ -1,49 +1,31 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - gamedefs.h - - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL - MODIFIED: 21 Sep 2005 Hammag - REASON: - Added PDefWorldModel related stuff - - Added PDefAppPlace related stuff - MODIFIED: 22 Sep 2005 Hammag - REASON: - Added PDefAppartement related stuff - - Added PDefRespawn related stuff - MODIFIED: 28 Sep 2005 Hammag - REASON: - Added PDefWorldFile related stuff - - MODIFIED: 07 Oct 2005 Hammag - REASON: - Added methods to get const iterators on Appartment and WorldFile maps - -*/ - -#ifndef GAMEDEFS_H -#define GAMEDEFS_H - -#include "defs.h" +#pragma once + +#include +#include "GameServer/Definitions/Definition.hxx" +#include "GameServer/Definitions/Implants.hxx" +#include "GameServer/Definitions/ItemContainer.hxx" +#include "GameServer/Definitions/ItemMod.hxx" +#include "GameServer/Definitions/ItemRes.hxx" +#include "GameServer/Definitions/Items.hxx" +#include "GameServer/Definitions/Mission.hxx" +#include "GameServer/Definitions/NpcArmor.hxx" +#include "GameServer/Definitions/NpcGroupSpawn.hxx" +#include "GameServer/Definitions/Npc.hxx" +#include "GameServer/Definitions/Outposts.hxx" +#include "GameServer/Definitions/Recycles.hxx" +#include "GameServer/Definitions/Respawn.hxx" +#include "GameServer/Definitions/Scripts.hxx" +#include "GameServer/Definitions/Shots.hxx" +#include "GameServer/Definitions/Skills.hxx" +#include "GameServer/Definitions/SubSkills.hxx" +#include "GameServer/Definitions/Trader.hxx" +#include "GameServer/Definitions/Vehicles.hxx" +#include "GameServer/Definitions/VehicleSits.hxx" +#include "GameServer/Definitions/Weapons.hxx" +#include "GameServer/Definitions/Weather.hxx" +#include "GameServer/Definitions/WorldFile.hxx" +#include "GameServer/Definitions/WorldModels.hxx" +#include "GameServer/Definitions/Worlds.hxx" typedef PDefMap PDefActionModsMap; typedef PDefMap PDefAmmosMap; @@ -86,9 +68,8 @@ class PDefScriptsMap; // ___Add new entries here in alpĥabetical order___ -class PGameDefs -{ - private : +class PGameDefs { +private: PDefActionModsMap mActionModsDefs; PDefAmmosMap mAmmosDefs; PDefAppartementsMap mAppartementsDefs; @@ -127,7 +108,7 @@ class PGameDefs PDefScriptsMap mScriptDefs; // ___Add new entries here___ - public : +public: PGameDefs(); ~PGameDefs(); @@ -170,7 +151,4 @@ class PGameDefs inline const PDefWorldModelsMap* WorldModels() const { return &mWorldModelsDefs; } inline const PDefScriptsMap* Scripts() const { return &mScriptDefs; } // ___Add new entries here___ - }; - -#endif diff --git a/TinNS/Source/GameServer/Definitions/Hack.cxx b/TinNS/Source/GameServer/Definitions/Hack.cxx new file mode 100644 index 0000000..202b60e --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Hack.cxx @@ -0,0 +1,27 @@ +#include "GameServer/Definitions/Includes.hxx" + +PDefHack::PDefHack() +{ +} + +bool PDefHack::LoadFromDef(PTokenList *Tokens) +{ + int Idx=0; + for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++) + { + switch(Idx) + { + case 0: // setentry + continue ; + + + case 1: // index + mIndex = atoi(i->c_str()); break; + + + } + } + + return true; +} + diff --git a/TinNS/Source/GameServer/Definitions/Hack.hxx b/TinNS/Source/GameServer/Definitions/Hack.hxx new file mode 100644 index 0000000..1a6b90a --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Hack.hxx @@ -0,0 +1,16 @@ +#pragma once + +#include "GameServer/Definitions/Definition.hxx" + +class PDefHack : public PDef { +private: + //int mIndex; + //qui aggiungere valori +public: + PDefHack(); + //~PDefHack(); + + bool LoadFromDef(PTokenList *Tokens); + + //qui aggiungere funzioni per i gets +}; diff --git a/server/src/game/def/def_implants.cpp b/TinNS/Source/GameServer/Definitions/Implants.cxx similarity index 52% rename from server/src/game/def/def_implants.cpp rename to TinNS/Source/GameServer/Definitions/Implants.cxx index 6c65167..1ec60b0 100644 --- a/server/src/game/def/def_implants.cpp +++ b/TinNS/Source/GameServer/Definitions/Implants.cxx @@ -1,40 +1,4 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_implants.cpp - - CREATED: 29 Apr 2009 Hammag - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "include/def_implants.h" - +#include "GameServer/Definitions/Includes.hxx" bool PDefImplant::LoadFromDef( PTokenList *Tokens ) { diff --git a/TinNS/Source/GameServer/Definitions/Implants.hxx b/TinNS/Source/GameServer/Definitions/Implants.hxx new file mode 100644 index 0000000..4f4ac83 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Implants.hxx @@ -0,0 +1,10 @@ +#pragma once + +#include "GameServer/Definitions/Definition.hxx" + +// Implants Id 1 to 5 correspond to OP Zone bonus: mine, factory, lab, fort and comlink respectively + +class PDefImplant : public PDefDrug { +public: + bool LoadFromDef( PTokenList *Tokens ); +}; diff --git a/TinNS/Source/GameServer/Definitions/Includes.hxx b/TinNS/Source/GameServer/Definitions/Includes.hxx new file mode 100644 index 0000000..06e0a0a --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Includes.hxx @@ -0,0 +1,44 @@ +#pragma once + +#include "GameServer/Definitions/ActionMod.hxx" +#include "GameServer/Definitions/Ammo.hxx" +#include "GameServer/Definitions/AppartementPlaces.hxx" +#include "GameServer/Definitions/Appartements.hxx" +#include "GameServer/Definitions/BluePrintPieces.hxx" +#include "GameServer/Definitions/CharacterActions.hxx" +#include "GameServer/Definitions/CharacterKinds.hxx" +#include "GameServer/Definitions/Characters.hxx" +#include "GameServer/Definitions/Damage.hxx" +#include "GameServer/Definitions/Definition.hxx" +#include "GameServer/Definitions/Drugs.hxx" +#include "GameServer/Definitions/Factions.hxx" +#include "GameServer/Definitions/GameDefinitions.hxx" +#include "GameServer/Definitions/Hack.hxx" +#include "GameServer/Definitions/Implants.hxx" +#include "GameServer/Definitions/ItemContainer.hxx" +#include "GameServer/Definitions/ItemMod.hxx" +#include "GameServer/Definitions/ItemRes.hxx" +#include "GameServer/Definitions/Items.hxx" +#include "GameServer/Definitions/Map.hxx" +#include "GameServer/Definitions/Mission.hxx" +#include "GameServer/Definitions/Npc.hxx" +#include "GameServer/Definitions/NpcArmor.hxx" +#include "GameServer/Definitions/NpcGroupSpawn.hxx" +#include "GameServer/Definitions/Outposts.hxx" +#include "GameServer/Definitions/Parser.hxx" +#include "GameServer/Definitions/Recycles.hxx" +#include "GameServer/Definitions/Respawn.hxx" +#include "GameServer/Definitions/Scripts.hxx" +#include "GameServer/Definitions/Shots.hxx" +#include "GameServer/Definitions/Skills.hxx" +#include "GameServer/Definitions/SubSkills.hxx" +#include "GameServer/Definitions/Trader.hxx" +#include "GameServer/Definitions/VehicleSits.hxx" +#include "GameServer/Definitions/Vehicles.hxx" +#include "GameServer/Definitions/Weapons.hxx" +#include "GameServer/Definitions/Weather.hxx" +#include "GameServer/Definitions/WorldDatParser.hxx" +#include "GameServer/Definitions/WorldDatStruct.hxx" +#include "GameServer/Definitions/WorldFile.hxx" +#include "GameServer/Definitions/WorldModels.hxx" +#include "GameServer/Definitions/Worlds.hxx" diff --git a/server/src/game/def/def_itemcontainer.cpp b/TinNS/Source/GameServer/Definitions/ItemContainer.cxx similarity index 62% rename from server/src/game/def/def_itemcontainer.cpp rename to TinNS/Source/GameServer/Definitions/ItemContainer.cxx index ffa480c..9e8e42c 100644 --- a/server/src/game/def/def_itemcontainer.cpp +++ b/TinNS/Source/GameServer/Definitions/ItemContainer.cxx @@ -1,40 +1,4 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_itemcontainer.cpp - - CREATED: 04 Apr 2009 Hammag - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "include/def_itemcontainer.h" - +#include "GameServer/Definitions/Includes.hxx" PDefItemContainer::PDefItemContainer() { diff --git a/TinNS/Source/GameServer/Definitions/ItemContainer.hxx b/TinNS/Source/GameServer/Definitions/ItemContainer.hxx new file mode 100644 index 0000000..5e8d395 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/ItemContainer.hxx @@ -0,0 +1,33 @@ +#pragma once + +#include +#include "GameServer/Definitions/Definition.hxx" + +class PDefItemContainer : public PDef { +private: + //int32_t mIndex; + int32_t mNumItemsAtOnce; + int32_t mRespawnTime; + int32_t mNumItems; + int32_t mItemId[6]; // <0: Group, >0: Item + float mQuality[6]; // usually <1, <=> % ? + int32_t mChance[6]; // a weight, not a % + + int32_t mCumulatedChance[6]; // Computed data in order to select random item entry + + void BuildCumulatedChance(); + +public: + PDefItemContainer(); + //~PDefItemContainer(); + + bool LoadFromDef( PTokenList *Tokens ); + + inline int32_t GetNumItemsAtOnce() const { return mNumItemsAtOnce; } + inline int32_t GetRespawnTime() const { return mRespawnTime; } + inline int32_t GetNumItems() const { return mNumItems; } + inline int32_t GetItemId(int32_t nIdx) const { return ( ((nIdx >= 0) && (nIdx < mNumItems)) ? mItemId[nIdx] : 0) ; } + inline float GetQuality(int32_t nIdx) const { return ( ((nIdx >= 0) && (nIdx < mNumItems)) ? mQuality[nIdx] : 0) ; } + inline int32_t GetChance(int32_t nIdx) const { return ( ((nIdx >= 0) && (nIdx < mNumItems)) ? mChance[nIdx] : 0) ; } + int32_t GetRandomItemIdx() const; // Return Idx based on Entry chance +}; diff --git a/server/src/game/def/def_itemmod.cpp b/TinNS/Source/GameServer/Definitions/ItemMod.cxx similarity index 56% rename from server/src/game/def/def_itemmod.cpp rename to TinNS/Source/GameServer/Definitions/ItemMod.cxx index b814d63..5a3a4b7 100644 --- a/server/src/game/def/def_itemmod.cpp +++ b/TinNS/Source/GameServer/Definitions/ItemMod.cxx @@ -1,40 +1,4 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_itemmod.cpp - - CREATED: 04 Apr 2009 Hammag - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "include/def_itemmod.h" - +#include "GameServer/Definitions/Includes.hxx" PDefItemMod::PDefItemMod() { diff --git a/TinNS/Source/GameServer/Definitions/ItemMod.hxx b/TinNS/Source/GameServer/Definitions/ItemMod.hxx new file mode 100644 index 0000000..fc7f870 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/ItemMod.hxx @@ -0,0 +1,32 @@ +#pragma once + +#include +#include +#include "GameServer/Definitions/Definition.hxx" + +class PDefItemMod : public PDef { +private: + //int32_t mIndex; + int32_t mType; // if mType > 0, it refers to a weapon type from weapons.def +1 + //int32_t mDuration; // "implant base build time" = ???? always 0 anyway... + int32_t mChangeNum; + int32_t mChangeTarget[4]; // qualifier id 0 - 7 item qualifier id 4=range + float mChangeValue[4]; + float mChangeScale[4]; + std::string mName; + //int32_t mIconId; + +public: + PDefItemMod(); + //~PDefItemMod(); + + bool LoadFromDef( PTokenList *Tokens ); + + inline const std::string &GetName() const { return mName; } + inline int32_t GetType() const { return mType; } + //inline int32_t GetDuration() const { return mDuration; } + inline int32_t GetChangeNum() const { return mChangeNum; } + inline int32_t GetChangeTarget(int32_t nIdx) const { return ( ((nIdx >= 0) && (nIdx < mChangeNum)) ? mChangeTarget[nIdx] : 0) ; } + inline float GetChangeValue(int32_t nIdx) const { return ( ((nIdx >= 0) && (nIdx < mChangeNum)) ? mChangeValue[nIdx] : 0) ; } + inline float GetChangeScale(int32_t nIdx) const { return ( ((nIdx >= 0) && (nIdx < mChangeNum)) ? mChangeScale[nIdx] : 0) ; } +}; diff --git a/TinNS/Source/GameServer/Definitions/ItemRes.cxx b/TinNS/Source/GameServer/Definitions/ItemRes.cxx new file mode 100644 index 0000000..933763f --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/ItemRes.cxx @@ -0,0 +1,47 @@ +#include "GameServer/Definitions/Includes.hxx" + +PDefItemRestriction::PDefItemRestriction() +{ +} + +bool PDefItemRestriction::LoadFromDef( PTokenList *Tokens ) +{ + int Idx = 0; + int maxFields = 2; + for ( PTokenList::iterator i = Tokens->begin(); i != Tokens->end(); i++, Idx++ ) + { + switch ( Idx ) + { + case 0 : // setentry + break; + case 1 : + mIndex = atoi( i->c_str() ); break; + case 2 : + { + mNumRestrictions = atoi( i->c_str() ); + if( mNumRestrictions > 6 ) + mNumRestrictions = 6; + maxFields = 2 + 2 * mNumRestrictions; + break; + } + default : + if( (Idx >= 3) && (Idx <= maxFields) ) + { + if(Idx & 1) + { + mSsqId[(Idx - 3) / 2] = atoi( i->c_str() ); + } + else + { + mMinValue[(Idx - 3) / 2] = atoi( i->c_str() ); + } + } + break; + } + + if ( Idx >= maxFields ) + break; + } + + return ((Idx == maxFields)); +} diff --git a/TinNS/Source/GameServer/Definitions/ItemRes.hxx b/TinNS/Source/GameServer/Definitions/ItemRes.hxx new file mode 100644 index 0000000..1f1d07b --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/ItemRes.hxx @@ -0,0 +1,22 @@ +#pragma once + +#include +#include "GameServer/Definitions/Definition.hxx" + +class PDefItemRestriction : public PDef { +private: + //int32_t mIndex; + int32_t mNumRestrictions; + int32_t mSsqId[6]; // Skill/Subs + int32_t mMinValue[6]; + +public: + PDefItemRestriction(); + //~PDefItemRestriction(); + + bool LoadFromDef( PTokenList *Tokens ); + + inline int32_t GetNumRestrictions() const { return mNumRestrictions; } + inline int32_t GetSsqId(int32_t nIdx) const { return ( ((nIdx >= 0) && (nIdx < mNumRestrictions)) ? mSsqId[nIdx] : 0) ; } + inline float GetMinValue(int32_t nIdx) const { return ( ((nIdx >= 0) && (nIdx < mNumRestrictions)) ? mMinValue[nIdx] : 0) ; } +}; diff --git a/server/src/game/def/def_items.cpp b/TinNS/Source/GameServer/Definitions/Items.cxx similarity index 78% rename from server/src/game/def/def_items.cpp rename to TinNS/Source/GameServer/Definitions/Items.cxx index f870547..ab1ab49 100644 --- a/server/src/game/def/def_items.cpp +++ b/TinNS/Source/GameServer/Definitions/Items.cxx @@ -1,48 +1,7 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko +#include "GameServer/Definitions/Includes.hxx" - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_item.cpp - - Authors: - - Akiko - - Namikon - - someone else? - - MODIFIED: Unknown date / Unknown author - REASON: - initial release by unknown - - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL - - MODIFIED: 10 Jul Hammag - REASON: - Full Item Def implementation -*/ - -#include "main.h" #define GAMEDEFS_DEFITEMSMAXSEQ 100 - PDefItems::PDefItems() { //mIndex = 0; diff --git a/TinNS/Source/GameServer/Definitions/Items.hxx b/TinNS/Source/GameServer/Definitions/Items.hxx new file mode 100644 index 0000000..0bf6903 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Items.hxx @@ -0,0 +1,77 @@ +#pragma once + +#include +#include +#include "GameServer/Definitions/Definition.hxx" + +class PDefItems : public PDef { +private: + //int32_t mIndex;//1 + std::string mName;//2 + int32_t mModel; // used for IG display + int32_t mType; + int32_t mValue1; + int32_t mValue2; + int32_t mValue3; + // int32_t mBmNum; // used IG for inventory display + // int32_t mmBmNumIndex; // used IG for inventory display + int32_t mSizeX; + int32_t mSizeY; + // int32_t mSmallbmnum; // used IG for inventory display + float mWeight; + int32_t mStackable; + float mFillWeight; + int32_t mQualifier; + int32_t mGfxMods; + int32_t mItemGroupID; + int32_t mTextDescID; + int32_t mBasePrice; + int32_t mTechlevel; + int32_t mItemflags; + // std::mShortname; // used IG for display on inventories Icons + +public: + PDefItems(); + //~PDefItems(); + + bool LoadFromDef(PTokenList *Tokens); + + inline const std::string &GetName() const { return mName; } + inline int32_t GetModel() const { return mModel; } + inline int32_t GetType() const { return mType; } + inline int32_t GetValue1() const { return mValue1; } + inline int32_t GetValue2() const { return mValue2; } + inline int32_t GetValue3() const { return mValue3; } + inline int32_t GetSizeX() const { return mSizeX; } + inline int32_t GetSizeY() const { return mSizeY; } + inline float GetWeight() const { return mWeight; } + inline bool IsStackable() const { return (mStackable == 1); } + inline float GetFillWeight() const { return mFillWeight; } + inline int32_t GetQualifier() const { return mQualifier; } + inline int32_t GetGfxMods() const { return mGfxMods; } + inline int32_t GetItemGroupID() const { return mItemGroupID; } + inline int32_t GetTextDescID() const { return mTextDescID; } + inline int32_t GetBasePrice() const { return mBasePrice; } + inline int32_t GetTechlevel() const { return mTechlevel; } + inline int32_t GetItemflags() const { return mItemflags; } +}; + +class PDefItemsMap : public PDefMap { +private: + std::map::const_iterator* mMapItCache; + int32_t mMapItCacheCount; + std::map > mItemGroups; + int32_t mMaxItemGroupId; + void BuildMapItCache(); + void BuildItemGroups(); + +public: + PDefItemsMap(); + ~PDefItemsMap(); + bool Load(const char* nName, const char* nFilename); + const PDefItems* GetDefBySeqIndex( int32_t nSeqIndex ) const; + int32_t GetRandomItemIdFromGroup( int32_t nGroupId ) const; + + inline std::map::const_iterator ConstIteratorBegin() const { return mDefs.begin(); } + inline std::map::const_iterator ConstIteratorEnd() const { return mDefs.end(); } +}; diff --git a/TinNS/Source/GameServer/Definitions/Map.hxx b/TinNS/Source/GameServer/Definitions/Map.hxx new file mode 100644 index 0000000..6939584 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Map.hxx @@ -0,0 +1,105 @@ +#pragma once + +#include +#include +#include +#include "GameServer/Definitions/Parser.hxx" +#include "Common/Includes.hxx" + +template +class PDefMap { +protected: + std::string mName; + std::map mDefs; + + void Clear() + { + for (auto it = mDefs.begin(); it != mDefs.end(); ++it) + delete it->second; + + mDefs.clear(); + } + +public: + PDefMap() + { + } + + ~PDefMap() + { + Clear(); + } + + bool Load(const char* nName, const char* nFilename) + { + mName = nName; + if(mName.empty()) + { + Console->Print( "%s Defs name not defined", Console->ColorText( RED, BLACK, "[ERROR]" ) ); + return (false); + } + + if(! *nFilename) + { + Console->Print( "%s Filename not defined for %s defs", Console->ColorText( RED, BLACK, "[ERROR]" ), mName.c_str() ); + return (false); + } + + PDefParser parser; + int32_t nDefs = 0, nErrors = 0; + + if ( parser.Parse( nFilename ) ) + { + const PDefTokenList &t = parser.GetTokens(); + + for ( PDefTokenList::const_iterator i = t.begin(); i != t.end(); i++ ) + { + T* entry = new T(); + bool insertfail = false; + bool loadfail = ! entry->LoadFromDef( *i ); + + if ( !loadfail ) + insertfail = ! mDefs.insert( std::make_pair( entry->GetIndex(), entry ) ).second; + + if ( loadfail || insertfail ) + { + if ( insertfail ) + Console->Print( "%s %s def error (duplicate id %i): %s", Console->ColorText( YELLOW, BLACK, "[NOTICE]" ), mName.c_str(), entry->GetIndex(), entry->GetName().c_str() ); + else + Console->Print( "%s def load error @ %i", Console->ColorText( YELLOW, BLACK, "[NOTICE]" ), mName.c_str(), nDefs + nErrors ); + ++nErrors; + delete entry; + } + else + ++nDefs; + } + } + else + { + Console->Print( "%s Error loading %s defs", Console->ColorText( YELLOW, BLACK, "[WARNING]" ), mName.c_str() ); + return (false); + } + + if ( nErrors > 0 ) + Console->Print( "%s Loaded %i %s defs, %i error(s).", Console->ColorText( RED, BLACK, "[WARNING]" ), nDefs, mName.c_str(), nErrors ); + else + Console->Print( "%s Loaded %i %s defs, %i error(s).", Console->ColorText( GREEN, BLACK, "[Success]" ), nDefs, mName.c_str(), nErrors ); + + return ( true ); + } + + int32_t GetNumDefs() const + { + return mDefs.size(); + } + + const T *GetDef(int32_t Index) const + { + T* Result; + + auto it = mDefs.find( Index ); + Result = ( ( it != mDefs.end() ) ? it->second : nullptr ); + + return ( Result ); + } +}; diff --git a/server/src/game/def/def_mission.cpp b/TinNS/Source/GameServer/Definitions/Mission.cxx similarity index 55% rename from server/src/game/def/def_mission.cpp rename to TinNS/Source/GameServer/Definitions/Mission.cxx index 76adb17..1d1aa78 100644 --- a/server/src/game/def/def_mission.cpp +++ b/TinNS/Source/GameServer/Definitions/Mission.cxx @@ -1,40 +1,6 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_mission.cpp - - CREATED: 04 Apr 2009 Hammag - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "include/def_mission.h" +#include "GameServer/Definitions/Includes.hxx" +const std::string EmptyString; PDefMission::PDefMission() { @@ -106,3 +72,78 @@ bool PDefMission::LoadFromDef ( PTokenList *Tokens ) return ( ( Idx >= 38 ) ); } + +int32_t PDefMission::GetSourceId() const +{ + return mSourceId; +} + +const std::string &PDefMission::GetStartDialog() const +{ + return mStartDialog; +} + +int32_t PDefMission::GetDescTextId() const +{ + return mDescTextId; +} + +int32_t PDefMission::GetNpcType(int32_t nIdx) const +{ + return ( ((nIdx >= 0) && (nIdx < 4)) ? mNpcType[nIdx] : 0); +} + +const std::string &PDefMission::GetNpcDialog(int32_t nIdx) const +{ + return ( ((nIdx >= 0) && (nIdx < 4)) ? mNpcDialog[nIdx] : EmptyString); +} + +int32_t PDefMission::GetNpcDialogStartState(int32_t nIdx) const +{ + return ( ((nIdx >= 0) && (nIdx < 4)) ? mNpcDialogStartState[nIdx] : 0); +} + +int32_t PDefMission::GetTargetType(int32_t nIdx) const +{ + return ( ((nIdx >= 0) && (nIdx < 4)) ? mTargetType[nIdx] : 0); +} + +int32_t PDefMission::GetTargetValue(int32_t nIdx, int32_t nValIdx) const +{ + return (((nIdx >= 0) && (nIdx < 4) && (nValIdx >= 0) && (nValIdx < 3)) ? mTargetValue[nIdx][nValIdx] : 0); +} + +int32_t PDefMission::GetEndMoney() const +{ + return mEndMoney; +} + +int32_t PDefMission::GetEndXp() const +{ + return mEndXp; +} + +int32_t PDefMission::GetMaxTime() const +{ + return mMaxTime; +} + +int32_t PDefMission::GetDifficulty() const +{ + return mDifficulty; +} + +int32_t PDefMission::GetMinFactionValue() const +{ + return mMinFactionValue; +} + +int32_t PDefMission::GetPoints() const +{ + return mPoints; +} + +int32_t PDefMission::GetFlags() const +{ + return mFlags; +} diff --git a/TinNS/Source/GameServer/Definitions/Mission.hxx b/TinNS/Source/GameServer/Definitions/Mission.hxx new file mode 100644 index 0000000..1b9b364 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Mission.hxx @@ -0,0 +1,65 @@ +#pragma once + +#include +#include +#include "GameServer/Definitions/Definition.hxx" + +class PDefMission : public PDef { +private: + //int32_t mIndex; + int32_t mSourceId; + std::string mStartDialog; + int32_t mDescTextId; + int32_t mNpcType[4]; + std::string mNpcDialog[4]; + int32_t mNpcDialogStartState[4]; + int32_t mTargetType[4]; + int32_t mTargetValue[4][3]; + int32_t mEndMoney; + int32_t mEndXp; + int32_t mMaxTime; + int32_t mDifficulty; + int32_t mMinFactionValue; + int32_t mPoints; + int32_t mFlags; + +public: + PDefMission(); + //~PDefMission(); + + bool LoadFromDef( PTokenList *Tokens ); + + int32_t GetSourceId() const; + const std::string &GetStartDialog() const; + int32_t GetDescTextId() const; + int32_t GetNpcType(int32_t nIdx) const; + const std::string &GetNpcDialog(int32_t nIdx) const; + int32_t GetNpcDialogStartState(int32_t nIdx) const; + int32_t GetTargetType(int32_t nIdx) const; + int32_t GetTargetValue(int32_t nIdx, int32_t nValIdx) const; + int32_t GetEndMoney() const ; + int32_t GetEndXp() const; + int32_t GetMaxTime() const; + int32_t GetDifficulty() const; + int32_t GetMinFactionValue() const; + int32_t GetPoints() const; + int32_t GetFlags() const; +}; + +/* +//mission source ID > 0 NPC Type for mission source < 0 Terminal ID for mission source + +//mission NPC Type > 0 NPC Type for mission NPC < 0 Fraction ID for mission NPC +//mission target Type 1 - kill NPC 2 - kill NPC type "3 - dialogtrigger" 4 - kill NPC type range 5-dialogtrigger + counter "6 - conquer outpost" 7 - conquer outpost + counter 8 - conquer + hold outpost 9-KillPlayer 10 - LootNPC 11 - LootNPCType + +//target value 1 ID of related mission NPC > 0 NPC Type of NPCs to kill < 0 FractionID of NPCs to kill "ID of related mission NPC" > 0 NPC Type of NPCs to kill ID of related mission NPC "> 0 outpost Type < 0 current outpost factionid" > 0 outpost type < 0 original outpost faction type > 0 outpost Type < 0 current outpost factionid PlayerFaction ID of related Mission NPC(0-4) > 0 NPC Type of NPCs to kill < 0 FractionID of NPCs to kill + +//target value 2 Count of NPCs to kill "ID of DialogTrigger" Count of NPCs to kill ID of DialogTrigger Count of outposts to conquer time to hold outpost Kill Cnt ItemID NPC Cnt + +//target value 3 Range of NPC Type Trigger Counter - must reach 0 to be successfull Max Leveldiff Item ID +//missionflags (bit field) +// NPC0 No Search 1 +// NPC1 No Search 2 +// NPC2 No Search 4 +// NPC3 No Search 8 +*/ diff --git a/server/src/game/def/def_npc.cpp b/TinNS/Source/GameServer/Definitions/Npc.cxx similarity index 57% rename from server/src/game/def/def_npc.cpp rename to TinNS/Source/GameServer/Definitions/Npc.cxx index 36a3c64..76fe682 100644 --- a/server/src/game/def/def_npc.cpp +++ b/TinNS/Source/GameServer/Definitions/Npc.cxx @@ -1,40 +1,4 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_npc.cpp - - CREATED: 04 Apr 2009 Hammag - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "include/def_npc.h" - +#include "GameServer/Definitions/Includes.hxx" PDefNpc::PDefNpc() { @@ -68,8 +32,8 @@ bool PDefNpc::LoadFromDef( PTokenList *Tokens ) mWeaponId = atoi( i->c_str() ); break; case 10 : mDialogScript = *i; - CleanUpString(&mDialogScript); - break; + CleanUpString(&mDialogScript); + break; case 11 : mCombat = atoi( i->c_str() ); break; case 12 : @@ -86,12 +50,12 @@ bool PDefNpc::LoadFromDef( PTokenList *Tokens ) mSkillScale = atof( i->c_str() ); break; case 18 : mStandardScript = *i; - CleanUpString(&mStandardScript); - break; + CleanUpString(&mStandardScript); + break; case 19 : mStandardParameter = *i; - CleanUpString(&mStandardParameter); - break; + CleanUpString(&mStandardParameter); + break; case 20 : mMass = atoi( i->c_str() ); break; case 24 : diff --git a/TinNS/Source/GameServer/Definitions/Npc.hxx b/TinNS/Source/GameServer/Definitions/Npc.hxx new file mode 100644 index 0000000..a30f5c8 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Npc.hxx @@ -0,0 +1,59 @@ +#pragma once + +#include +#include +#include "GameServer/Definitions/Definition.hxx" + +class PDefNpc : public PDef { +private: + //int32_t mIndex; + int32_t mModel; // <0: from characters.def, >0: from models.ini, [players] section (?) + //int32_t mSoundId; // always 0: not used + int32_t mNGT; // ? 1 - 4 + int32_t mGender; // 0 - 1 + int32_t mFaction; + int32_t mHealth; + int32_t mArmorId; // -1 or ref to NpcArmor + int32_t mWeaponId; + std::string mDialogScript; + int32_t mCombat; // ? 20 - 800 + int32_t mLoot; // 0 or ref to ItemContained + int32_t mMovementEnd; // 0 - 4 + int32_t mFunctionType; // 0 - 4 + float mModelScaling; // 0 - 0.9 + int32_t mMoneyLoose; // 0 - 190 + float mSkillScale; // 0 - 120 + std::string mStandardScript; + std::string mStandardParameter; + int32_t mMass; // 1 - 10000 + //int32_t mStartHour; // not used + //int32_t mEndHour; // not used + //std::string mTempScript; // not used + int32_t mFlags; // values: 513, 259, 256, 128, 64, 48, 35, 34, 33, 32, 2, 1, 0 + +public: + PDefNpc(); + //~PDefNpc(); + + bool LoadFromDef( PTokenList *Tokens ); + + inline int32_t GetModel() const { return mModel; } + inline int32_t GetNGT() const { return mNGT; } + inline int32_t GetGender() const { return mGender; } + inline int32_t GetFaction() const { return mFaction; } + inline int32_t GetHealth() const { return mHealth; } + inline int32_t GetArmorId() const { return mArmorId; } + inline int32_t GetWeaponId() const { return mWeaponId; } + inline const std::string &GetDialogScript() const { return mDialogScript; } + inline int32_t GetCombat() const { return mCombat; } + inline int32_t GetLoot() const { return mLoot; } + inline int32_t GetMovementEnd() const { return mMovementEnd; } + inline int32_t GetFunctionType() const { return mFunctionType; } + inline float GetModelScaling() const { return mModelScaling; } + inline int32_t GetMoneyLoose() const { return mMoneyLoose; } + inline float GetSkillScale() const { return mSkillScale; } + inline const std::string &GetStandardScript() const { return mStandardScript; } + inline const std::string &GetStandardParameter() const { return mStandardParameter; } + inline int32_t GetMass() const { return mMass; } + inline int32_t GetFlags() const { return mFlags; } +}; diff --git a/TinNS/Source/GameServer/Definitions/NpcArmor.cxx b/TinNS/Source/GameServer/Definitions/NpcArmor.cxx new file mode 100644 index 0000000..9e22e2f --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/NpcArmor.cxx @@ -0,0 +1,28 @@ +#include "GameServer/Definitions/Includes.hxx" + +PDefNpcArmor::PDefNpcArmor() +{ +} + +bool PDefNpcArmor::LoadFromDef ( PTokenList *Tokens ) +{ + int Idx=0; + for ( PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++ ) + { + switch ( Idx ) + { + case 0 : // setentry + break;; + case 1 : + mIndex = atoi ( i->c_str() ); break; + default : + if ( ( Idx - 2 ) < 7 ) + { + mValue[Idx - 2] = atoi ( i->c_str() ); + } + break; + } + } + + return ( Idx >= 8 ); +} diff --git a/TinNS/Source/GameServer/Definitions/NpcArmor.hxx b/TinNS/Source/GameServer/Definitions/NpcArmor.hxx new file mode 100644 index 0000000..c19bfc6 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/NpcArmor.hxx @@ -0,0 +1,18 @@ +#pragma once + +#include +#include "GameServer/Definitions/Definition.hxx" + +class PDefNpcArmor : public PDef { +private: + //int32_t mIndex; + int32_t mValue[7]; // force piercing fire energy xray psi poison + +public: + PDefNpcArmor(); + //~PDefNpcArmor(); + + bool LoadFromDef ( PTokenList *Tokens ); + + inline int32_t GetValue ( int32_t nIdx ) const { return ( ( ( nIdx >= 0 ) && ( nIdx < 7 ) ) ? mValue[nIdx] : 0 ) ; } +}; diff --git a/server/src/game/def/def_npcgroupspawn.cpp b/TinNS/Source/GameServer/Definitions/NpcGroupSpawn.cxx similarity index 62% rename from server/src/game/def/def_npcgroupspawn.cpp rename to TinNS/Source/GameServer/Definitions/NpcGroupSpawn.cxx index b18ded2..0054590 100644 --- a/server/src/game/def/def_npcgroupspawn.cpp +++ b/TinNS/Source/GameServer/Definitions/NpcGroupSpawn.cxx @@ -1,40 +1,6 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_npcgroupspawn.cpp - - CREATED: 04 Apr 2009 Hammag - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "include/def_npcgroupspawn.h" +#include "GameServer/Definitions/Includes.hxx" +const std::string EmptyString; PDefNpcGroupSpawn::PDefNpcGroupSpawn() { @@ -87,6 +53,41 @@ bool PDefNpcGroupSpawn::LoadFromDef( PTokenList *Tokens ) return ((Idx >= (3 + 5*mNumNpc))); } +int32_t PDefNpcGroupSpawn::GetIgnoreNearPC() const +{ + return mIgnoreNearPC; +} + +int32_t PDefNpcGroupSpawn::GetNumNpc() const +{ + return mNumNpc; +} + +int32_t PDefNpcGroupSpawn::GetNpcType(int32_t nIdx) const +{ + return ( ((nIdx >= 0) && (nIdx < mNumNpc)) ? mNpcType[nIdx] : 0); +} + +const std::string &PDefNpcGroupSpawn::GetScript(int32_t nIdx) const +{ + return ( ((nIdx >= 0) && (nIdx < mNumNpc)) ? mScript[nIdx] : EmptyString); +} + +const std::string &PDefNpcGroupSpawn::GetScriptParameter(int32_t nIdx) const +{ + return ( ((nIdx >= 0) && (nIdx < mNumNpc)) ? mScriptParameter[nIdx] : EmptyString); +} + +int32_t PDefNpcGroupSpawn::GetFunctionValue(int32_t nIdx) const +{ + return ( ((nIdx >= 0) && (nIdx < mNumNpc)) ? mFunctionValue[nIdx] : 0); +} + +int32_t PDefNpcGroupSpawn::GetSpawnChance(int32_t nIdx) const +{ + return ( ((nIdx >= 0) && (nIdx < mNumNpc)) ? mSpawnChance[nIdx] : 0); +} + /* class PDefNpcGroupSpawn : public PDef { diff --git a/TinNS/Source/GameServer/Definitions/NpcGroupSpawn.hxx b/TinNS/Source/GameServer/Definitions/NpcGroupSpawn.hxx new file mode 100644 index 0000000..6fe52b9 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/NpcGroupSpawn.hxx @@ -0,0 +1,31 @@ +#pragma once + +#include +#include +#include "GameServer/Definitions/Definition.hxx" + +class PDefNpcGroupSpawn : public PDef { +private: + //int32_t mIndex; + int32_t mIgnoreNearPC; + int32_t mNumNpc; // Size of the list. But that should be the size of the group... + int32_t mNpcType[8]; + std::string mScript[8]; + std::string mScriptParameter[8]; + int32_t mFunctionValue[8]; + int32_t mSpawnChance[8]; + +public: + PDefNpcGroupSpawn(); + //~PDefNpcGroupSpawn(); + + bool LoadFromDef( PTokenList *Tokens ); + + int32_t GetIgnoreNearPC() const; + int32_t GetNumNpc() const; + int32_t GetNpcType(int32_t nIdx) const; + const std::string& GetScript(int32_t nIdx) const; + const std::string& GetScriptParameter(int32_t nIdx) const; + int32_t GetFunctionValue(int32_t nIdx) const; + int32_t GetSpawnChance(int32_t nIdx) const; +}; diff --git a/TinNS/Source/GameServer/Definitions/Outposts.cxx b/TinNS/Source/GameServer/Definitions/Outposts.cxx new file mode 100644 index 0000000..8d98312 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Outposts.cxx @@ -0,0 +1,45 @@ +#include "GameServer/Definitions/Includes.hxx" + +PDefOutpost::PDefOutpost() +{ + for ( int i = 0; i < 8; ++i ) + mInfluenceZone[i] = 0; +} + +bool PDefOutpost::LoadFromDef ( PTokenList *Tokens ) +{ + int Idx=0; + for ( PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++ ) + { + switch ( Idx ) + { + case 0: // setentry + break; + case 1: // index + mIndex = atoi ( i->c_str() ); break; + case 2: + mName = *i; break; + case 3: + mType = atoi ( i->c_str() ); break; + case 4: + mStandardFaction = atoi ( i->c_str() ); break; + case 5: + mRevenue = atof ( i->c_str() ); break; + case 6: + mConquestReward = atof ( i->c_str() ); break; + case 7: + mMaxSecurity = atoi ( i->c_str() ); break; + default : + if ( ( Idx - 8 ) < 8 ) + { + mInfluenceZone[Idx - 8] = atoi ( i->c_str() ); + } + break; + } + + if ( Idx == 15 ) + break; + } + + return ( Idx >= 7 ); +} diff --git a/TinNS/Source/GameServer/Definitions/Outposts.hxx b/TinNS/Source/GameServer/Definitions/Outposts.hxx new file mode 100644 index 0000000..810e928 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Outposts.hxx @@ -0,0 +1,31 @@ +#pragma once + +#include +#include +#include "GameServer/Definitions/Definition.hxx" + +class PDefOutpost : public PDef { +private: + //int32_t mIndex; + std::string mName; + int32_t mType; + int32_t mStandardFaction; + float mRevenue; + float mConquestReward; + int32_t mMaxSecurity; + int32_t mInfluenceZone[8]; // ex: 12 for zone A12, 112 for B12 + +public: + PDefOutpost(); + //~PDefOutpost(); + + bool LoadFromDef( PTokenList *Tokens ); + + inline const std::string &GetName() const { return mName; } + inline int32_t GetType() const { return mType; } + inline int32_t GetStandardFaction() const { return mStandardFaction; } + inline float GetRevenue() const { return mRevenue; } + inline float GetConquestReward() const { return mConquestReward; } + inline int32_t GetMaxSecurity() const { return mMaxSecurity; } + inline int32_t GetInfluenceZone(int32_t nIdx) const { return ( ((nIdx >= 0) && (nIdx < 8)) ? mInfluenceZone[nIdx] : 0) ; } +}; diff --git a/TinNS/Source/GameServer/Definitions/Parser.cxx b/TinNS/Source/GameServer/Definitions/Parser.cxx new file mode 100644 index 0000000..a91e76a --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Parser.cxx @@ -0,0 +1,121 @@ +#include "GameServer/Definitions/Includes.hxx" +#include "GameServer/Includes.hxx" + +PDefParser::PDefParser() +{ +} + +PDefParser::~PDefParser() +{ + for(PDefTokenList::iterator i=mTokens.begin(); i!=mTokens.end(); i++) + delete *i; +} + +bool PDefParser::Parse(const char *File) +{ + PFile *f = Filesystem->Open("", File, Config->GetOption("nc_data_path")); + enum { NOPE, MAYBE, LINE, BLOCK, MAYBE_END } Comment = NOPE; + + if(f) + { + while(!f->Eof()) + { + std::string Str = f->ReadString(); + int Len = Str.length(); + if(Len <= 0) + continue; + + if(Str.substr(0, 3)!="set") + continue; + + //Console->Print("%s", Str.c_str());//NEW was commented , just to be sure of what we are reading + + PTokenList *List = new PTokenList(); + int Start=0, Tokens=0; + bool Quote=false; + for(int i=0; i= Start) + { + List->push_back(std::string(Str.substr(Start, (End-Start)+1))); + Tokens++; + break; + } + Quote=false; + } + if(Comment != BLOCK) + Comment=NOPE; + break; + } + + if(!Quote) + { + if(Comment < LINE && (Str[i]=='\t' || Str[i]==',' || Str[i]==' ' || Str[i]==';' || Str[i]=='|' || i==Len-1)) + { + int End=i-1; + if(End >= Start) + { + List->push_back(std::string(Str.substr(Start, (End-Start)+1))); + Tokens++; + } + Start=i+1; + } + + if(Str[i] <= ' ') + continue; + + if(Str[i]=='*') + { + if(Comment==MAYBE) + Comment=BLOCK; + else + if(Comment==BLOCK) + Comment=MAYBE_END; + } else + if(Str[i]=='/') + { + if(Comment==MAYBE) + { + // second slash, skip rest of line + Comment=LINE; + break; + } else + if(Comment==MAYBE_END) + { + Comment=NOPE; // comment block ends + Start=i+1; + } else + if(Comment != BLOCK) + Comment=MAYBE; // first slash + } else + { + if(Comment==MAYBE) + Comment=NOPE; // stand-alone slash + else + if(Comment==MAYBE_END) + Comment=BLOCK; // comment block did not end + } + } + + if(Str[i]=='"') + Quote ^= true; + } + + if(Tokens > 0) + mTokens.push_back(List); + else + delete List; + } + } else + { + Console->Print("%s PDefParser::Parse: could not open file %s", Console->ColorText( RED, BLACK, "[ERROR]" ), File); + return false; + } + + return true; +} diff --git a/TinNS/Source/GameServer/Definitions/Parser.hxx b/TinNS/Source/GameServer/Definitions/Parser.hxx new file mode 100644 index 0000000..c9f3741 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Parser.hxx @@ -0,0 +1,18 @@ +#pragma once + +#include +#include + +typedef std::list PTokenList; +typedef std::list PDefTokenList; + +class PDefParser { +private: + PDefTokenList mTokens; + +public: + PDefParser(); + ~PDefParser(); + bool Parse(const char *File); + inline const PDefTokenList &GetTokens() const { return mTokens; } +}; diff --git a/TinNS/Source/GameServer/Definitions/Recycles.cxx b/TinNS/Source/GameServer/Definitions/Recycles.cxx new file mode 100644 index 0000000..27e25ce --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Recycles.cxx @@ -0,0 +1,45 @@ +#include "GameServer/Definitions/Includes.hxx" + +PDefRecycle::PDefRecycle() +{ +} + +bool PDefRecycle::LoadFromDef( PTokenList *Tokens ) +{ + int Idx = 0; + int maxFields = 4; + for ( PTokenList::iterator i = Tokens->begin(); i != Tokens->end(); i++, Idx++ ) + { + switch ( Idx ) + { + case 0 : // setentry + break; + case 1 : + //mIndex = atoi ( i->c_str() ); + break; + case 2 : // We use resultitem as index + mIndex = mResultItemId = atoi ( i->c_str() ); break; + case 3: + mBuildTime = atoi ( i->c_str() ); break; + case 4 : + { + mNumParts = atoi ( i->c_str() ); + if ( mNumParts > 8 ) + mNumParts = 8; + maxFields = 4 + mNumParts; + break; + } + default : + if ( ( Idx >= 5 ) && ( Idx <= maxFields ) ) + { + mPartId[ Idx - 5 ] = atoi ( i->c_str() ); break; + } + break; + } + + if ( Idx >= 12 ) + break; + } + + return ( ( Idx >= 5 ) ); +} diff --git a/TinNS/Source/GameServer/Definitions/Recycles.hxx b/TinNS/Source/GameServer/Definitions/Recycles.hxx new file mode 100644 index 0000000..a4ccbea --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Recycles.hxx @@ -0,0 +1,24 @@ +#pragma once + +#include +#include "GameServer/Definitions/Definition.hxx" + +class PDefRecycle : public PDef { +private: + //int32_t mIndex; + int32_t mResultItemId; // We use resultitem as mIndex + int32_t mBuildTime; + int32_t mNumParts; + int32_t mPartId[8]; + +public: + PDefRecycle(); + //~PDefRecycle(); + + bool LoadFromDef( PTokenList *Tokens ); + + inline int32_t GetResultItemId() const { return mResultItemId; } + inline int32_t GetBuildTime() const { return mBuildTime; } + inline int32_t GetNumParts() const { return mNumParts; } + inline int32_t GetPartId(int32_t nIdx) const { return ( ((nIdx >= 0) && (nIdx < mNumParts)) ? mPartId[nIdx] : 0 ) ; } +}; diff --git a/server/src/game/def/def_respawn.cpp b/TinNS/Source/GameServer/Definitions/Respawn.cxx similarity index 50% rename from server/src/game/def/def_respawn.cpp rename to TinNS/Source/GameServer/Definitions/Respawn.cxx index 9a23f5c..bf992e7 100644 --- a/server/src/game/def/def_respawn.cpp +++ b/TinNS/Source/GameServer/Definitions/Respawn.cxx @@ -1,35 +1,4 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_respawn.cpp - - MODIFIED: 22 Sep 2006 Hammag - REASON: - Creation - -*/ - -#include "main.h" +#include "GameServer/Definitions/Includes.hxx" PDefRespawn::PDefRespawn() { @@ -69,13 +38,13 @@ bool PDefRespawn::LoadFromDef( PTokenList *Tokens ) } // class PDefRespawnMap defined in gamedefs.h -int PDefRespawnsMap::GetRespawnEntity( u32 nWorldID, u16 nGROrder ) const +int PDefRespawnsMap::GetRespawnEntity( uint32_t nWorldID, uint16_t nGROrder ) const { - u16 tOrder = 0; + uint16_t tOrder = 0; for ( std::map::const_iterator it = mDefs.begin(); it != mDefs.end(); it++ ) { - if (( u32 )( it->second->GetWorldID() ) == nWorldID ) + if (( uint32_t )( it->second->GetWorldID() ) == nWorldID ) { ++tOrder; if (( nWorldID == 1 ) || ( nWorldID == 2 ) ) // hack for zones 1 & 2 diff --git a/TinNS/Source/GameServer/Definitions/Respawn.hxx b/TinNS/Source/GameServer/Definitions/Respawn.hxx new file mode 100644 index 0000000..52b573d --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Respawn.hxx @@ -0,0 +1,32 @@ +#pragma once + +#include +#include +#include "GameServer/Definitions/Definition.hxx" + +class PDefRespawn : public PDef { +private: + //int32_t mIndex; + int32_t mWorldID; + int32_t mEntityID; // Station ID + int32_t mHazardLevel; + std::string mName; // Description + std::string mFlag; // ??? + +public: + PDefRespawn(); + //~PDefRespawn(); + + bool LoadFromDef(PTokenList *Tokens); + + inline int32_t GetWorldID() const { return mWorldID; } + inline int32_t GetEntityID() const { return mEntityID; } + inline int32_t GetHazardLevel() const { return mHazardLevel; } + inline const std::string &GetName() const { return mName; } + inline const std::string &GetFlag() const { return mFlag; } +}; + +class PDefRespawnsMap : public PDefMap { +public: + int32_t GetRespawnEntity( uint32_t nWorldID, uint16_t nGROrder ) const; +}; diff --git a/server/src/game/def/def_scripts.cpp b/TinNS/Source/GameServer/Definitions/Scripts.cxx similarity index 74% rename from server/src/game/def/def_scripts.cpp rename to TinNS/Source/GameServer/Definitions/Scripts.cxx index 67b833b..95b2a1e 100644 --- a/server/src/game/def/def_scripts.cpp +++ b/TinNS/Source/GameServer/Definitions/Scripts.cxx @@ -1,33 +1,4 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - -/* - def_scripts.cpp - - CREATED: 12 Oct 2009 Namikon -*/ - -#include "main.h" - +#include "GameServer/Definitions/Includes.hxx" PDefScripts::PDefScripts() { diff --git a/TinNS/Source/GameServer/Definitions/Scripts.hxx b/TinNS/Source/GameServer/Definitions/Scripts.hxx new file mode 100644 index 0000000..85ff527 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Scripts.hxx @@ -0,0 +1,31 @@ +#pragma once + +#include +#include +#include +#include "GameServer/Definitions/Definition.hxx" + +class PDefScripts : public PDef { +private: + //int32_t mIndex; + std::string mIdentifier; + std::string mLuaFile; + std::string mScriptHeader; + +public: + PDefScripts(); + //~PDefWeapon(); + + bool LoadFromDef( PTokenList *Tokens ); + + inline const std::string &GetIdentifier() const { return mIdentifier; } + inline const std::string &GetLuaFile() const { return mLuaFile; } + inline const std::string &GetScriptHeader() const { return mScriptHeader; } +}; + +class PDefScriptsMap : public PDefMap { +public: + //bool Load(const char* nName, const char* nFilename); + inline std::map::const_iterator ConstIteratorBegin() const { return mDefs.begin(); } + inline std::map::const_iterator ConstIteratorEnd() const { return mDefs.end(); } +}; diff --git a/TinNS/Source/GameServer/Definitions/Shots.cxx b/TinNS/Source/GameServer/Definitions/Shots.cxx new file mode 100644 index 0000000..a683635 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Shots.cxx @@ -0,0 +1,34 @@ +#include "GameServer/Definitions/Includes.hxx" + +PDefShot::PDefShot() +{ } + +bool PDefShot::LoadFromDef( PTokenList *Tokens ) +{ + int Idx = 0; + for ( PTokenList::iterator i = Tokens->begin(); i != Tokens->end(); i++, Idx++ ) + { + switch ( Idx ) + { + case 0 : // setentry + break; + case 1 : + mIndex = atoi( i->c_str() ); break; + case 2 : + mDamageId = atoi( i->c_str() ); break; + case 3 : + mMass = atoi( i->c_str() ); break; + case 4 : + mRadius = atoi( i->c_str() ); break; + case 5 : + mSpeed = atof( i->c_str() ); break; + default : + break; + } + + if ( Idx >= 5 ) + break; + } + + return (( Idx >= 5 ) ); +} diff --git a/TinNS/Source/GameServer/Definitions/Shots.hxx b/TinNS/Source/GameServer/Definitions/Shots.hxx new file mode 100644 index 0000000..32240d4 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Shots.hxx @@ -0,0 +1,28 @@ +#pragma once + +#include +#include "GameServer/Definitions/Definition.hxx" + +class PDefShot : public PDef { +private: + //int32_t mIndex; + int32_t mDamageId; + int32_t mMass; + int32_t mRadius; + float mSpeed; + //int32_t mHitSound; + //int32_t mCustomType; + //std::string mCustomFrameFx; + //std::string mCustomHitFx; + +public: + PDefShot(); + //~PDefShot(); + + bool LoadFromDef( PTokenList *Tokens ); + + inline int32_t GetDamageId() const { return mDamageId; } + inline int32_t GetMass() const { return mMass; } + inline int32_t GetRadius() const { return mRadius; } + inline int32_t GetSpeed() const { return mSpeed; } +}; diff --git a/TinNS/Source/GameServer/Definitions/Skills.cxx b/TinNS/Source/GameServer/Definitions/Skills.cxx new file mode 100644 index 0000000..14c28c5 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Skills.cxx @@ -0,0 +1,63 @@ +#include +#include "GameServer/Definitions/Includes.hxx" +#include "GameServer/Includes.hxx" + +// skill.def includes skill names and skill/subskill mapping + +PDefSkill::PDefSkill() +{ + mSubSkills = 0; + mNumSubSkills = 0; +} + +PDefSkill::~PDefSkill() +{ + delete [] mSubSkills; +} + +bool PDefSkill::LoadFromDef(PTokenList *Tokens) +{ + int Idx=0; + for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++) + { + switch(Idx) + { + case 0 : // setentry + continue; + + case 1 : + mIndex = atol(i->c_str()); break; + + case 2 : + mName = *i; break; + + case 3 : + mShortName = *i; break; + + case 4 : + { + mNumSubSkills = atol(i->c_str()); + mSubSkills = new int[mNumSubSkills]; + std::memset(mSubSkills, 0, sizeof(int)*mNumSubSkills); + break; + } + } + + if(Idx >= 5) + { + mSubSkills[Idx-5] = atoi(i->c_str()); + if(!GameDefs->SubSkills()->GetDef(mSubSkills[Idx-5])) + { + Console->Print("Skill def error: skill %s refers to nonexistant subskill %i", mShortName.c_str(), mSubSkills[Idx-5]); + return false; + } + } + } + + if(Idx-5 != mNumSubSkills) + { + Console->Print("Warning: skill %s has incorrect number of subskills", mShortName.c_str()); + Console->Print(" Expected %i, available %i", mNumSubSkills, Idx-5); + } + return true; +} diff --git a/TinNS/Source/GameServer/Definitions/Skills.hxx b/TinNS/Source/GameServer/Definitions/Skills.hxx new file mode 100644 index 0000000..dcf42f8 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Skills.hxx @@ -0,0 +1,24 @@ +#pragma once + +#include +#include +#include "GameServer/Definitions/Definition.hxx" + +class PDefSkill : public PDef { +private: + //int32_t mIndex; + std::string mName; + std::string mShortName; + int32_t mNumSubSkills; + int32_t *mSubSkills; +public: + PDefSkill(); + ~PDefSkill(); + + bool LoadFromDef(PTokenList *Tokens); + + inline const std::string &GetName() const { return mName; } + inline const std::string &GetShortName() const { return mShortName; } + inline int32_t GetNumSubSkills() const { return mNumSubSkills; } + inline int32_t GetSubSkill(int32_t Index) const { return mSubSkills[Index]; } +}; diff --git a/TinNS/Source/GameServer/Definitions/SubSkills.cxx b/TinNS/Source/GameServer/Definitions/SubSkills.cxx new file mode 100644 index 0000000..ac6512f --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/SubSkills.cxx @@ -0,0 +1,54 @@ +#include +#include "GameServer/Definitions/Includes.hxx" + +// subskill.def, names and parameters of all subskills + +PDefSubSkill::PDefSubSkill() +{ + mActionModifiers = 0; + mNumActionModifiers = 0; +} + +PDefSubSkill::~PDefSubSkill() +{ + delete [] mActionModifiers; +} + +bool PDefSubSkill::LoadFromDef(PTokenList *Tokens) +{ + int Idx=0; + for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++) + { + switch(Idx) + { + case 0 : // setentry + continue; + + case 1 : + mIndex = atoi(i->c_str()); break; + + case 2 : + mName = *i; break; + + case 3 : + mShortName = *i; break; + + case 4 : + mStrengthenFactor = static_cast(atof(i->c_str())); break; + + case 5 : + { + mNumActionModifiers = atoi(i->c_str()); + mActionModifiers = new int[mNumActionModifiers]; + std::memset(mActionModifiers, 0, sizeof(int)*mNumActionModifiers); + break; + } + } + + if(Idx>=6) + mActionModifiers[Idx-6] = atoi(i->c_str()); + } + + return true; +} + diff --git a/TinNS/Source/GameServer/Definitions/SubSkills.hxx b/TinNS/Source/GameServer/Definitions/SubSkills.hxx new file mode 100644 index 0000000..d2d1195 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/SubSkills.hxx @@ -0,0 +1,27 @@ +#pragma once + +#include +#include +#include "GameServer/Definitions/Definition.hxx" + +class PDefSubSkill : public PDef { +private: + //int32_t mIndex; + std::string mName; + std::string mShortName; + float mStrengthenFactor; + int32_t mNumActionModifiers; + int32_t *mActionModifiers; + +public: + PDefSubSkill(); + ~PDefSubSkill(); + + bool LoadFromDef(PTokenList *Tokens); + + inline const std::string &GetName() const { return mName; } + inline const std::string &GetShortName() const { return mShortName; } + inline float GetStrengthenFactor() const { return mStrengthenFactor; } + inline int32_t GetNumActionModifiers() const { return mNumActionModifiers; } + inline int32_t GetActionModifier(int32_t Index) const { return mActionModifiers[Index]; } +}; diff --git a/server/src/game/def/def_trader.cpp b/TinNS/Source/GameServer/Definitions/Trader.cxx similarity index 59% rename from server/src/game/def/def_trader.cpp rename to TinNS/Source/GameServer/Definitions/Trader.cxx index 7928c99..e61d7b7 100644 --- a/server/src/game/def/def_trader.cpp +++ b/TinNS/Source/GameServer/Definitions/Trader.cxx @@ -1,40 +1,4 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_trader.cpp - - CREATED: 04 Apr 2009 Hammag - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "include/def_trader.h" - +#include "GameServer/Definitions/Includes.hxx" PDefTrader::PDefTrader() { diff --git a/TinNS/Source/GameServer/Definitions/Trader.hxx b/TinNS/Source/GameServer/Definitions/Trader.hxx new file mode 100644 index 0000000..bd462c7 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Trader.hxx @@ -0,0 +1,51 @@ +#pragma once + +#include +#include "GameServer/Definitions/Definition.hxx" + +#define DEF_TRADER_MAXENTRIES 17 + +class PDefTrader : public PDef { +private: + //int32_t mIndex; + int32_t mType; + float mMaxWealth; + float mWealthRespawn; + int32_t mQuality; + int32_t mItemId[DEF_TRADER_MAXENTRIES]; // <0: item group + float mItemPriceScale[DEF_TRADER_MAXENTRIES]; // sometime string like "1/5" ??? <=> 0.2 or Sell:1 / Buy 5 ???? + +public: + PDefTrader(); + //~PDefTrader(); + + bool LoadFromDef( PTokenList *Tokens ); + + inline int32_t GetType() const { return mType; } + inline float GetMaxWealth() const { return mMaxWealth; } + inline float GetWealthRespawn() const { return mWealthRespawn; } + inline int32_t GetQuality() const { return mQuality; } + inline int32_t GetItemId(int32_t nIdx) const { return ( ((nIdx >= 0) && (nIdx < DEF_TRADER_MAXENTRIES)) ? mItemId[nIdx] : 0 ) ; } + inline float GetItemPriceScale(int32_t nIdx) const { return ( ((nIdx >= 0) && (nIdx < DEF_TRADER_MAXENTRIES)) ? mItemPriceScale[nIdx] : 0 ) ; } +}; +/* Trader/Buyer mType +// 1 weapons +// 2 ammo +// 3 armor +// 4 tools +// 5 psi equipment +// +// 10 chemicals +// 11 item parts +// 12 implants +// 13 bone enforcements +// +// 16 Buy anything +// +// 20 refreshments +// 21 drugs +// 22 medicaments +// 23 real estate +// 24 vehicles +// +*/ diff --git a/server/src/game/def/def_vehiclesits.cpp b/TinNS/Source/GameServer/Definitions/VehicleSits.cxx similarity index 51% rename from server/src/game/def/def_vehiclesits.cpp rename to TinNS/Source/GameServer/Definitions/VehicleSits.cxx index a7484cc..b67f3e3 100644 --- a/server/src/game/def/def_vehiclesits.cpp +++ b/TinNS/Source/GameServer/Definitions/VehicleSits.cxx @@ -1,40 +1,4 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_vehiclesits.cpp - - CREATED: 04 Apr 2009 Hammag - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "include/def_vehiclesits.h" - +#include "GameServer/Definitions/Includes.hxx" PDefVhcSeat::PDefVhcSeat() { diff --git a/TinNS/Source/GameServer/Definitions/VehicleSits.hxx b/TinNS/Source/GameServer/Definitions/VehicleSits.hxx new file mode 100644 index 0000000..e7c1a1e --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/VehicleSits.hxx @@ -0,0 +1,55 @@ +#pragma once + +#include +#include +#include "GameServer/Definitions/Definition.hxx" + +class PDefVhcSeat : public PDef { +private: + //int32_t mIndex; //Field 1 + int32_t mType; + std::string mName; //Field 3 + //BasePosX Y Z + //BaseAngleX Y Z + float mLeavePos[3]; //X Y Z - Fields 10-12 + float mLeaveAngle[3]; //X Y Z - Fields 13-15 + //FirePosX Y Z //Field 16 + //XLock Ylock MinX MaxX TurnSpeed ForceExternalCam ShowActor + //SitBone RotXBone RotYBone WeaponBone + int32_t mWeaponId; //Field 30 + int32_t mTL; + float mDamageFactor; + //SitAnimType SitYOffset //Field 33 + //SitFlags + +public: + PDefVhcSeat(); + //~PDefVhcSeat(); + + bool LoadFromDef( PTokenList *Tokens ); + + inline int32_t GetType() const { return mType; } + inline const std::string &GetName() const { return mName; } + inline float GetLeavePos(int32_t nIdx) const { return ( ((nIdx >= 0) && (nIdx < 3)) ? mLeavePos[nIdx] : 0) ; } + inline float GetLeaveAngle(int32_t nIdx) const { return ( ((nIdx >= 0) && (nIdx < 3)) ? mLeaveAngle[nIdx] : 0) ; } + inline int32_t GetWeaponId() const { return mWeaponId; } + inline int32_t GetTL() const { return mTL; } + inline float GetDamageFactor() const { return mDamageFactor; } +}; +/* +mType: +0 - Driver (Ground vhc) +1 - Gunner +2 - Passenger +3 - Driver/Gunner +4 - Pilot (Flying vhc) +5 - Pilot/Gunner (Flying vhc) +6 - Pilot (Senkrechtstarter ????) + +mFlags: +1 - Winkel f�r Spieler und Waffe wird auf Fahrzeugrichtung gelockt. Zielrichtung darf nur leicht von der Fahrzeugrichtung abweichen +2 - Spieler wird gelockt +4 - Waffe ist nicht um X Achse drehbar +8 - Waffe ist nicht um Y Achse drehbar +16 - Spielermodel um 180 Grad gedreht +*/ diff --git a/TinNS/Source/GameServer/Definitions/Vehicles.cxx b/TinNS/Source/GameServer/Definitions/Vehicles.cxx new file mode 100644 index 0000000..82a9629 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Vehicles.cxx @@ -0,0 +1,45 @@ +#include "GameServer/Definitions/Includes.hxx" + +PDefVhc::PDefVhc() +{ + mNumSeats = mArmor = mHealth = mModel = 0; + mName = "undefined"; + for(int i=0; i<8; ++i) + mSeatId[i] = -1; +} + +bool PDefVhc::LoadFromDef( PTokenList *Tokens ) +{ + int Idx = 0; + for ( PTokenList::iterator i = Tokens->begin(); i != Tokens->end(); i++, Idx++ ) + { + switch ( Idx ) + { + case 0 : // setentry + break; + case 1 : + mIndex = atoi( i->c_str() ); break; + case 2 : + mModel = atoi( i->c_str() ); break; + case 3 : + mName = *i; break; + case 34 : + mHealth = atoi( i->c_str() ); break; + case 35 : + mArmor = atoi( i->c_str() ); break; + default : + if( (Idx >= 16) && (Idx <= 23) ) + { + mSeatId[Idx - 16] = atoi( i->c_str() ); + if(mSeatId[Idx - 16] >= 0) // In theroy, we should check that it is a valid VhcSeat Index + ++mNumSeats; + } + break; + } + + if ( Idx >= 36 ) + break; + } + + return ((Idx >= 35)); +} diff --git a/TinNS/Source/GameServer/Definitions/Vehicles.hxx b/TinNS/Source/GameServer/Definitions/Vehicles.hxx new file mode 100644 index 0000000..122e6f2 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Vehicles.hxx @@ -0,0 +1,58 @@ +#pragma once + +#include +#include +#include "GameServer/Definitions/Definition.hxx" + +class PDefVhc : public PDef { +private: + //int32_t mIndex; // field 1 + int32_t mModel; + std::string mName; + /* + float mLeftFront; // field 4 + float mFront; + float mRightBack; + float mBack; + float mSideFriction; + float mDownFriction; + float mForwardFriction; + float mAcceleration; + float mBrakeFactor; + float mTurnSpeed; + float mFullTurnDelay; + int32_t mAnimClass; // field 15 + */ + int32_t mSeatId[8]; // fields 16 - 23 + /* + float mSpeedTiltFactor; // field 24 + float mSpeedGlideFactor; + float mMinHover; + float mMaxHover; + float mHoverLoopLen; + int32_t mWheelCnt; + float mWheelSpeed; + float mMaxDive; + int32_t mEffectsID; + int32_t mShowDebugBouncer; // field 33 + */ + int32_t mHealth; + int32_t mArmor; + //int32_t mSoundStartindex; // field 36 + + // Additionnal info + int32_t mNumSeats; + +public: + PDefVhc(); + //~PDefVhc(); + + bool LoadFromDef( PTokenList *Tokens ); + + inline int32_t GetModel() const { return mModel; } + inline const std::string &GetName() const { return mName; } + inline int32_t GetSeatId( int32_t nIdx ) const { return ((( nIdx >= 0 ) && ( nIdx < 8 ) ) ? mSeatId[nIdx] : -1) ; } + inline int32_t GetHealth() const { return mHealth; } + inline int32_t GetArmor() const { return mArmor; } + inline int32_t GetNumSeats() const { return mNumSeats; } +}; diff --git a/server/src/game/def/def_weapons.cpp b/TinNS/Source/GameServer/Definitions/Weapons.cxx similarity index 78% rename from server/src/game/def/def_weapons.cpp rename to TinNS/Source/GameServer/Definitions/Weapons.cxx index afb3f2e..4e5ea64 100644 --- a/server/src/game/def/def_weapons.cpp +++ b/TinNS/Source/GameServer/Definitions/Weapons.cxx @@ -1,40 +1,4 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_weapons.cpp - - CREATED: 29 Mar 2009 Hammag - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "include/def_weapons.h" - +#include "GameServer/Definitions/Includes.hxx" PDefWeapon::PDefWeapon() { diff --git a/TinNS/Source/GameServer/Definitions/Weapons.hxx b/TinNS/Source/GameServer/Definitions/Weapons.hxx new file mode 100644 index 0000000..f33126e --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Weapons.hxx @@ -0,0 +1,78 @@ +#pragma once + +#include +#include +#include "GameServer/Definitions/Definition.hxx" + +class PDefWeapon : public PDef { +private: + //int32_t mIndex; + std::string mName; + //int32_t mFpsmodel; + //int32_t mAttachmodel; + //int32_t mMunactor; + //float mDroptime; // useful ? + int32_t mItemIndex; + //int32_t effectcolor[3]; // R,G,B + //int32_t dynamiclight; + //float lighttime; + //int32_t soundindex; + //float mShotTime; // useful ? + int32_t mAmmoUse; + int32_t mPSIuse; + float mStaminaUse; + //float upthrow; + //int32_t weaponHold; // ??? + int32_t mWeaponType; + int32_t mDiscardable; + float mSkillFactor; + //int32_t mint32_tgtRad; + //int32_t maxtgtRad; + int32_t mMaxRange; + int32_t mAggressiveWeapon; + float mDamageMultiplicator; + int32_t mAmmoTypes[8]; + int32_t mAmmoStartFlags; // ??? + //int32_t customclasstype; // ? + //int32_t unknown // ? + int32_t mShotCnt; + //float shotduration; // maybe useful later ? + //std::string shotfx; + //float attachposx; + //float attachposy; + //float attachposz; + //float fpposx; + //float fpposy; + //float fpposz; + int32_t mBaseWeaponId; + //int32_t weaponcolor; + //int32_t reloadsound; + int32_t mItemModGroup; + int32_t mItemModGroupFlags; + int32_t mRareWeaponFx; + +public: + PDefWeapon(); + //~PDefWeapon(); + + bool LoadFromDef( PTokenList *Tokens ); + + inline const std::string &GetName() const { return mName; } + inline int32_t GetItemID() const { return mItemIndex; } + inline int32_t GetAmmoUse() const { return mAmmoUse; } + inline int32_t GetPsiUse() const { return mPSIuse; } + inline float GetStaminaUse() const { return mStaminaUse; } + inline int32_t GetWeaponType() const { return mWeaponType; } + inline bool IsDiscardable() const { return mDiscardable; } + inline float GetSkillFactor() const { return mSkillFactor; } + inline int32_t GetMaxRange() const { return mMaxRange; } + inline bool IsAggressiveWeapon() const { return mAggressiveWeapon; } + inline float GetDamageMultiplicator() const { return mDamageMultiplicator; } + inline int32_t GetAmmoType(int32_t nIdx) const { return ( ((nIdx >= 0) && (nIdx < 8)) ? mAmmoTypes[nIdx] : 0) ; } + inline int32_t GetAmmoStartFlags() const { return mAmmoStartFlags; } + inline int32_t GetShotCnt() const { return mShotCnt; } + inline int32_t GetBaseWeaponId() const { return mBaseWeaponId; } + inline int32_t GetItemModGroup() const { return mItemModGroup; } + inline int32_t GetItemModGroupFlags() const { return mItemModGroupFlags; } + inline int32_t GetRareWeaponFx() const { return mRareWeaponFx; } +}; diff --git a/TinNS/Source/GameServer/Definitions/Weather.cxx b/TinNS/Source/GameServer/Definitions/Weather.cxx new file mode 100644 index 0000000..151b28c --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Weather.cxx @@ -0,0 +1,45 @@ +#include "GameServer/Definitions/Includes.hxx" + +PDefWeather::PDefWeather() +{ + mNumWeathers = mSectionId = 0; + for(int i=0; i<8; ++i) + mDuration[i] = mWeatherId[i] = 0; +} + +bool PDefWeather::LoadFromDef( PTokenList *Tokens ) +{ + int Idx = 0; + for ( PTokenList::iterator i = Tokens->begin(); i != Tokens->end(); i++, Idx++ ) + { + switch ( Idx ) + { + case 0 : // setentry + break; + case 1 : + mIndex = atoi( i->c_str() ); break; + case 2 : + mSectionId = atoi( i->c_str() ); break; + case 3 : + mNumWeathers = atoi( i->c_str() ); break; + default : + if( (Idx >= 4) && (Idx <= (3 + 2*mNumWeathers)) && (Idx <= 19) ) + { + if(Idx & 1) + { + mDuration[int((Idx - 4)/2)] = atoi( i->c_str() ); + } + else + { + mWeatherId[int((Idx - 4)/2)] = atoi( i->c_str() ); + } + } + break; + } + + if ( Idx >= 19 ) + break; + } + + return ((Idx >= (3 + 2*mNumWeathers))); +} diff --git a/TinNS/Source/GameServer/Definitions/Weather.hxx b/TinNS/Source/GameServer/Definitions/Weather.hxx new file mode 100644 index 0000000..fa82531 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Weather.hxx @@ -0,0 +1,41 @@ +#pragma once + +#include +#include "GameServer/Definitions/Definition.hxx" + +//weathersectionid weathercnt weatherid length end +class PDefWeather : public PDef { +private: + //int32_t mIndex; + int32_t mSectionId; + int32_t mNumWeathers; + int32_t mWeatherId[8]; + int32_t mDuration[8]; + +public: + PDefWeather(); + //~PDefWeather(); + + bool LoadFromDef( PTokenList *Tokens ); + + inline int32_t GetSectionId() const { return mSectionId; } + inline int32_t GetNumWeathers() const { return mNumWeathers; } + inline int32_t GetWeatherId(int32_t nIdx) const { return ( ((nIdx >= 0) && (nIdx < mNumWeathers)) ? mWeatherId[nIdx] : 0 ) ; } + inline int32_t GetDuration(int32_t nIdx) const { return ( ((nIdx >= 0) && (nIdx < mNumWeathers)) ? mDuration[nIdx] : 0 ) ; } +}; + +/* mWeatherId +//BRIGHTSKY (1) +//SINGLECLOUDS (2) +//CLOUDY (3) + +//LIGHTRAIN (4) +//HEAVYRAIN (5) +//THUNDERSTORM (6) + +//SNOW (7) +//SANDSTORM (8) +//FALLOUT (9) + +//SEA_BRIGHTSKY (100) +*/ diff --git a/server/src/game/def/world_datparser.cpp b/TinNS/Source/GameServer/Definitions/WorldDatParser.cxx similarity index 79% rename from server/src/game/def/world_datparser.cpp rename to TinNS/Source/GameServer/Definitions/WorldDatParser.cxx index 38904c6..86a4354 100644 --- a/server/src/game/def/world_datparser.cpp +++ b/TinNS/Source/GameServer/Definitions/WorldDatParser.cxx @@ -1,52 +1,9 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko +#include +#include +#include "GameServer/Definitions/Includes.hxx" +#include "GameServer/Includes.hxx" - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - world_datparser.h - Class to parse .dat world files - - MODIFIED: 29 Sep 2006 Hammag - REASON: - Creation - -MODIFIED: 21 Jun 2009 Namikon -REASON: - Added NPC Template stuff - - reformatted for better reading - -*/ - -#include "main.h" - -#include "include/world_datparser.h" -#include "def/world_datstruct.h" - -#include "include/worlddatatemplate.h" -#include "include/furnituretemplate.h" -#include "include/doortemplate.h" -#include "include/npctemplate.h" - -#include - -const u16 nonDiscardUseFlags = ufTouchable | ufUsable | ufChair | ufToolTarget ; // furniture always to keep even if function type = 0 +const uint16_t nonDiscardUseFlags = ufTouchable | ufUsable | ufChair | ufToolTarget ; // furniture always to keep even if function type = 0 PWorldDatParser::PWorldDatParser() { @@ -64,9 +21,9 @@ int PWorldDatParser::LoadDatFile( const std::string& nFilename, PWorldDataTempla PSectionHeader SectionHeader; PSec2ElemHeader Sec2ElemHeader; - u32 FileLen; - u32 NextSectionOffset = 0; - u32 NextElementOffset; + uint32_t FileLen; + uint32_t NextSectionOffset = 0; + uint32_t NextElementOffset; bool ProcessOK; mWorld = nWorld; @@ -114,7 +71,7 @@ int PWorldDatParser::LoadDatFile( const std::string& nFilename, PWorldDataTempla f->Seek( NextSectionOffset ); // Make sure we are at the computed offset if (gDevDebug) Console->Print( "Reading next section header ... " ); - if (( u32 )( f->Read( &SectionHeader, sizeof( PSectionHeader ) ) ) < sizeof( PSectionHeader ) ) + if (( uint32_t )( f->Read( &SectionHeader, sizeof( PSectionHeader ) ) ) < sizeof( PSectionHeader ) ) { Filesystem->Close( f ); return -3; @@ -149,7 +106,7 @@ int PWorldDatParser::LoadDatFile( const std::string& nFilename, PWorldDataTempla //if ( gDevDebug ) // Console->Print( "Reading next element header ... " ); - if (( u32 )( f->Read( &Sec2ElemHeader, sizeof( PSec2ElemHeader ) ) ) < sizeof( PSec2ElemHeader ) ) + if (( uint32_t )( f->Read( &Sec2ElemHeader, sizeof( PSec2ElemHeader ) ) ) < sizeof( PSec2ElemHeader ) ) { Filesystem->Close( f ); return -3; @@ -209,28 +166,28 @@ int PWorldDatParser::LoadDatFile( const std::string& nFilename, PWorldDataTempla return 0; } -bool PWorldDatParser::ProcessSec2ElemType3( u32 nSize ) // furniture +bool PWorldDatParser::ProcessSec2ElemType3( uint32_t nSize ) // furniture { PSec2ElemType3a DataA; PSec2ElemType3b DataB; const PDefWorldModel* nWorldModel; std::string nName; - const u32 sza = sizeof( PSec2ElemType3a ); - const u32 szb = sizeof( PSec2ElemType3a ) + sizeof( PSec2ElemType3b ); + const uint32_t sza = sizeof( PSec2ElemType3a ); + const uint32_t szb = sizeof( PSec2ElemType3a ) + sizeof( PSec2ElemType3b ); if (( nSize != szb ) && ( nSize != sza ) ) { Console->Print( RED, BLACK, "[ERROR] Wrong size for Sec2ElemType3 (%d read vs %d or %d needed", nSize, sza, szb ); return false; } - if (( u32 )( f->Read( &DataA, sza ) ) < sza ) + if (( uint32_t )( f->Read( &DataA, sza ) ) < sza ) { Console->Print( RED, BLACK, "[ERROR] Unexpected end of file in Sec2ElemType3a" ); return false; } if ( nSize == szb ) { - if (( u32 )( f->Read( &DataB, sizeof( PSec2ElemType3b ) ) ) < sizeof( PSec2ElemType3b ) ) + if (( uint32_t )( f->Read( &DataB, sizeof( PSec2ElemType3b ) ) ) < sizeof( PSec2ElemType3b ) ) { Console->Print( RED, BLACK, "[ERROR] Unexpected end of file in Sec2ElemType3b" ); return false; @@ -299,7 +256,7 @@ bool PWorldDatParser::ProcessSec2ElemType3( u32 nSize ) // furniture // nItem->mBoxUpperX = DataB.mBoxUpperX; nItem->mDefWorldModel = nWorldModel; - /*u16 func=nWorldModel->GetFunctionType(); + /*uint16_t func=nWorldModel->GetFunctionType(); if((func==18) || (func==20) || (func==29)) Console->Print("gate model: %d", DataA.mWorldmodelID);*/ @@ -313,17 +270,17 @@ bool PWorldDatParser::ProcessSec2ElemType3( u32 nSize ) // furniture Radius += 5; // int pos values are change to match char pos scale (32000 centered) - nItem->mFrontPosY = ( u16 )( 32000 + DataA.mPosY + Radius * sinf( Angle ) ); - nItem->mFrontPosZ = ( u16 )( 32000 + DataA.mPosZ ); - nItem->mFrontPosX = ( u16 )( 32000 + DataA.mPosX + Radius * cosf( Angle ) ); - nItem->mFrontLR = ( u8 )( 0.5 * ( DataA.mRotZ + ( DataA.mRotZ < 0 ? 360 : 0 ) ) ); + nItem->mFrontPosY = ( uint16_t )( 32000 + DataA.mPosY + Radius * sinf( Angle ) ); + nItem->mFrontPosZ = ( uint16_t )( 32000 + DataA.mPosZ ); + nItem->mFrontPosX = ( uint16_t )( 32000 + DataA.mPosX + Radius * cosf( Angle ) ); + nItem->mFrontLR = ( uint8_t )( 0.5 * ( DataA.mRotZ + ( DataA.mRotZ < 0 ? 360 : 0 ) ) ); mWorld->AddFurnitureItem( nItem ); return true; } -bool PWorldDatParser::ProcessSec2ElemType5( u32 nSize ) // doors +bool PWorldDatParser::ProcessSec2ElemType5( uint32_t nSize ) // doors { PSec2ElemType5Start Data; char StringData[64]; @@ -333,19 +290,19 @@ bool PWorldDatParser::ProcessSec2ElemType5( u32 nSize ) // doors char* ActorString; char* ParamString; - const u32 sza = sizeof( PSec2ElemType5Start ); + const uint32_t sza = sizeof( PSec2ElemType5Start ); if (( nSize < sza ) ) { Console->Print( RED, BLACK, "[ERROR] Wrong size for Sec2ElemType5 (%d read vs %d needed", nSize, sza ); return false; } - if (( u32 )( f->Read( &Data, sza ) ) < sza ) + if (( uint32_t )( f->Read( &Data, sza ) ) < sza ) { Console->Print( RED, BLACK, "[ERROR] Unexpected end of file in Sec2ElemType5start" ); return false; } - u32 szb = Data.mActorStringSize + Data.mParamStringSize; + uint32_t szb = Data.mActorStringSize + Data.mParamStringSize; if ( nSize != ( sza + szb ) ) { @@ -359,7 +316,7 @@ bool PWorldDatParser::ProcessSec2ElemType5( u32 nSize ) // doors Console->Print( RED, BLACK, "[Warning] String data too long in Sec2ElemType5 End String. End will be ignored" ); szb = 64; } - if (( u32 )( f->Read( StringData, szb ) ) < szb ) + if (( uint32_t )( f->Read( StringData, szb ) ) < szb ) { Console->Print( RED, BLACK, "[ERROR] Unexpected end of file in Sec2ElemType5 End Strings" ); return false; @@ -426,7 +383,7 @@ bool PWorldDatParser::ProcessSec2ElemType5( u32 nSize ) // doors return true; } -bool PWorldDatParser::ProcessSec2NPCEntry( u32 nSize ) +bool PWorldDatParser::ProcessSec2NPCEntry( uint32_t nSize ) { PSec2NPC_EntryPart1 tNPCPartA; PSec2NPC_EntryPart2 tNPCPartB; @@ -434,8 +391,8 @@ bool PWorldDatParser::ProcessSec2NPCEntry( u32 nSize ) std::string tAngle; char tStrBuffer[64]; - u32 tSizeOfA = sizeof(tNPCPartA); - u32 tSizeOfB = sizeof(tNPCPartB); + uint32_t tSizeOfA = sizeof(tNPCPartA); + uint32_t tSizeOfB = sizeof(tNPCPartB); // Are we able to read enough bytes from the file? means: CAN we safely read our entire struct from the file? if ( nSize < tSizeOfA ) @@ -444,14 +401,14 @@ bool PWorldDatParser::ProcessSec2NPCEntry( u32 nSize ) return false; } // yes we can! So read it now. If we reach EOF, break - if (( u32 )( f->Read( &tNPCPartA, tSizeOfA ) ) < tSizeOfA ) + if (( uint32_t )( f->Read( &tNPCPartA, tSizeOfA ) ) < tSizeOfA ) { Console->Print( RED, BLACK, "[ERROR] Unexpected end of file in ProcessSec2NPCEntry" ); return false; } // Now we have the header. lets check if we have some waypoints for this NPC // Size of entire NPC entry in file - u32 tCompleteNPCSize = tSizeOfA + tNPCPartA.mActorStringSize + tNPCPartA.mAngleStringSize; + uint32_t tCompleteNPCSize = tSizeOfA + tNPCPartA.mActorStringSize + tNPCPartA.mAngleStringSize; if ( tNPCPartA.mHasAdditionalCoords > 0 ) { // It has additional coords, add 'em @@ -468,7 +425,7 @@ bool PWorldDatParser::ProcessSec2NPCEntry( u32 nSize ) // We are. Continue reading! // Assign the 2 strings and watch out for EOF! memset(tStrBuffer, 0, 64); - if (( u32 )( f->Read( tStrBuffer, tNPCPartA.mActorStringSize ) ) < tNPCPartA.mActorStringSize ) + if (( uint32_t )( f->Read( tStrBuffer, tNPCPartA.mActorStringSize ) ) < tNPCPartA.mActorStringSize ) { Console->Print( RED, BLACK, "[ERROR] Unexpected end of file in ProcessSec2NPCEntry mActorStringSize" ); return false; @@ -476,7 +433,7 @@ bool PWorldDatParser::ProcessSec2NPCEntry( u32 nSize ) tActorName = tStrBuffer; memset(tStrBuffer, 0, 64); - if (( u32 )( f->Read( tStrBuffer, tNPCPartA.mAngleStringSize ) ) < tNPCPartA.mAngleStringSize ) + if (( uint32_t )( f->Read( tStrBuffer, tNPCPartA.mAngleStringSize ) ) < tNPCPartA.mAngleStringSize ) { Console->Print( RED, BLACK, "[ERROR] Unexpected end of file in ProcessSec2NPCEntry mAngleStringSize" ); return false; @@ -505,13 +462,13 @@ bool PWorldDatParser::ProcessSec2NPCEntry( u32 nSize ) tNPC->SetAngle(tAngle); // Read additional Waypoints if available - u8 tCurrWayP = 0; + uint8_t tCurrWayP = 0; if ( tNPCPartA.mHasAdditionalCoords > 0 ) { while ( tCurrWayP < tNPCPartA.mHasAdditionalCoords ) { memset(&tNPCPartB, 0, tSizeOfB); - if (( u32 )( f->Read( &tNPCPartB, tSizeOfB ) ) < tSizeOfB ) + if (( uint32_t )( f->Read( &tNPCPartB, tSizeOfB ) ) < tSizeOfB ) { Console->Print( RED, BLACK, "[ERROR] Unexpected end of file in ProcessSec2NPCEntry while reading WayPoints" ); return false; diff --git a/TinNS/Source/GameServer/Definitions/WorldDatParser.hxx b/TinNS/Source/GameServer/Definitions/WorldDatParser.hxx new file mode 100644 index 0000000..dfe60bd --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/WorldDatParser.hxx @@ -0,0 +1,26 @@ +#pragma once + +#include +#include + +class PFile; +class PWorldDataTemplate; + +class PWorldDatParser { +private: + PFile* f; + std::string mNCDataPath; + + PWorldDataTemplate* mWorld; + bool mDiscardPassiveObjects; + + bool ProcessSec2ElemType3(uint32_t nSize); + bool ProcessSec2ElemType5(uint32_t nSize); + bool ProcessSec2NPCEntry(uint32_t nSize); + +public: + PWorldDatParser(); + ~PWorldDatParser(); + + int32_t LoadDatFile(const std::string& nFilename, PWorldDataTemplate* nWorld, const bool nDiscardPassiveObjects = true, const bool nTestAccesOnly = false); +}; diff --git a/TinNS/Source/GameServer/Definitions/WorldDatStruct.hxx b/TinNS/Source/GameServer/Definitions/WorldDatStruct.hxx new file mode 100644 index 0000000..0d1d4a1 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/WorldDatStruct.hxx @@ -0,0 +1,128 @@ +#pragma once + +#include + +struct PWorldFileHeader { + uint32_t mHeaderSize; // must be 08 00 00 00, = header size after this field + uint32_t mHeaderSig; // must be CF CF 0F 00 + uint32_t mSection; // must be 01 00 00 00 +}; + +struct PSectionHeader { + uint32_t mHeaderSize; // must be 0C 00 00 00 + uint32_t mHeaderSig; // must be CF FF 00 00 + uint32_t mSection; // 00 00 00 00 means end + uint32_t mDataSize; +}; + +struct PSec2ElemHeader { + uint32_t mHeaderSize; // must be 0C 00 00 00 + uint32_t mHeaderSig; // must be F1 FE FE 0F + uint32_t mElementType; // 1000003, 1000005 or 1000014 + uint32_t mDataSize; +}; + +struct PSec2ElemType3a { //static object ? + float mPosY; //= uint32_t16_t PosY - 32000 + float mPosZ; + float mPosX; + float mRotY; + float mRotZ; + float mRotX; + float mScale; //00 00 80 3F ? = float(1.000000) !!! => scale factor ????? + uint32_t mUnknown2; //01 00 00 00 ? + uint16_t mModelID; // point32_ts to models.ini + uint32_t mUnknown3; //00 00 00 00 ? + uint32_t mUnknown4; //00 00 00 00 ? + uint16_t mWorldmodelID; // point32_ts to worldmodel.def + uint16_t mUnknown5; //12 00 ? + uint32_t mObjectID; +}; + +struct PSec2ElemType3b { //this part is optional + float mBoxLowerY; //Bounding box, for useflag "64 - selfconstructing colisionbox" + float mBoxLowerZ; // int32_t32_t or uint32_t32_t ? + float mBoxLowerX; + float mBoxUpperY; + float mBoxUpperZ; + float mBoxUpperX; +}; + +struct PSec2ElemType5Start { //door + uint16_t mUnknown1; //18 00 + uint16_t mUnknown1bis; //00 00 ? varies + float mPosY; + float mPosZ; + float mPosX; + uint8_t mActorStringSize; //string size with ending 0 + uint8_t mParamStringSize; //string size with ending 0 + uint16_t mUnknown5; //00 00 ? second byte varies + uint16_t mDoorID; // but what is the link with ObjectID sent in Use message (can't find the base offset .. or 0x80 for doors ???) + uint16_t mWorldmodelID; //door type from worldmodel.def +}; +//Actor As String //null terminated string +//Params As String //null terminated string - for DDOOR, 2nd param is the ID of the other (half)door (*) +//param1 = 2 => simple lateral move ?, 3 => door frontal+lateral move (as at Typherra memorial) ? +//last param = 0/1 for lateral move direction ? no ... +//(*) here is the bug(?) that makes open only one half of a double door + +/* +struct PSec2ElemType6Start //npc +{ + uint16_t mUnknown1; //20 00 ? + uint16_t mUnknown2; //12 00 ? + float mPosY; + float mPosZ; + float mPosX; + uint32_t mNPCTypeID; //npc type in npc.def + uint8_t mActorStringSize; //string size with ending 0 + uint8_t mParamStringSize; //string size with ending 0 + uint16_t mNpcID; // kind of ? + uint32_t mUnknown3; //01 00 00 00 ? + uint16_t mUnknown4; //00 00 ? + uint16_t mUnknown5; //04 00 ? +}; + //Actor As String //null terminated string + //Params As String //null terminated string - Seem to be the facing angle in degres +struct PSec2ElemType6End +{ + float mPosY2; //second position for movement ? + float mPosZ2; // + float mPosX2; // +}; +*/ +struct PSec2NPC_EntryPart1 { + uint32_t mUnknown1; // Is always 0x20001200, in every log. maybe header for NPCs? + float mPosY; + float mPosZ; + float mPosX; + uint32_t mNPCTypeID; //npc type in npc.def + uint8_t mActorStringSize; //string size with ending 0 + uint8_t mAngleStringSize; //string size with ending 0 + uint16_t mNpcID; + uint8_t mHasAdditionalCoords; + uint8_t mUnknown2a; + uint8_t mUnknown2b; + uint8_t mUnknown2c; + uint16_t mTradeID; //mUnknown3; //00 00 ? + uint16_t mUnknown4; //04 00 ? +}; + +// uint32_t8_t mActorName[mActorStringSize]; +// uint32_t8_t mAngle[mAngleStringSize]; + +struct PSec2NPC_EntryPart2 { // Waypoint32_ts! or something like that... + float mPosY; + float mPosZ; + float mPosX; +}; + +// uint32_t16_t mStrSize; //non-zero terminated string size +// Name As String //non-zero terminated string +struct PSec2ElemType15End { //area definition/sound ? + float mUnknown1; + float mUnknown2; + float mUnknown3; + float mUnknown4; + float mUnknown5; +}; diff --git a/server/src/game/def/def_worldfile.cpp b/TinNS/Source/GameServer/Definitions/WorldFile.cxx similarity index 50% rename from server/src/game/def/def_worldfile.cpp rename to TinNS/Source/GameServer/Definitions/WorldFile.cxx index 75f4c68..66e1762 100644 --- a/server/src/game/def/def_worldfile.cpp +++ b/TinNS/Source/GameServer/Definitions/WorldFile.cxx @@ -1,95 +1,69 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - +#include "GameServer/Definitions/Includes.hxx" +#include "GameServer/Includes.hxx" /* - def_worldfile.cpp (infos from worlds/worlds.ini) - - MODIFIED: 28 Sep 2007 Hammag - REASON: - Creation - - NOTA: Some entries in worlds.ini share the same Id ... - e.g: 505: techtown_enter 1/1a/1b/2 - As we don't know what it means & how it is supposed to be handled, - we keep the first one for the moment. (this is managed in gamedef.cpp) - TODO: Add a config entry to select the Nth entry for each such case, - as well as a config entry to select the default entry to be kept (first/last) + NOTA: Some entries in worlds.ini share the same Id ... + e.g: 505: techtown_enter 1/1a/1b/2 + As we don't know what it means & how it is supposed to be handled, + we keep the first one for the moment. (this is managed in gamedef.cpp) + TODO: Add a config entry to select the Nth entry for each such case, + as well as a config entry to select the default entry to be kept (first/last) */ -#include "main.h" - PDefWorldFile::PDefWorldFile() { - mFileInWorldsDir = false; + mFileInWorldsDir = false; } bool PDefWorldFile::LoadFromDef(PTokenList *Tokens) { - int Idx=0; - int StartPos = 0; - int TailLen = 0; - int Len; - - for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++) - { - switch(Idx) - { - case 0: // setentry - continue; - - case 1: // index - mIndex = atoi(i->c_str()); break; - - case 2: // name - { - Len = (*i).length(); + int Idx=0; + int StartPos = 0; + int TailLen = 0; + int Len; + + for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++) + { + switch(Idx) + { + case 0: // setentry + continue; + + case 1: // index + mIndex = atoi(i->c_str()); break; + + case 2: // name + { + Len = (*i).length(); while((StartPos = (*i).find("\\",StartPos))>-1) (*i)[StartPos]='/'; StartPos = 0; - + if ((*i)[0] == '\"') StartPos = 1; - - if ( (*i).substr(StartPos,9) == "./worlds/" ) - { - mFileInWorldsDir = true; - StartPos += 9; - } - else if ( (*i).substr(StartPos,2) == "./" ) + + if ( (*i).substr(StartPos,9) == "./worlds/" ) + { + mFileInWorldsDir = true; + StartPos += 9; + } + else if ( (*i).substr(StartPos,2) == "./" ) StartPos += 2; - + if ((*i)[Len-1] == '\"') - TailLen = 1; - if ( (Len > (StartPos+TailLen+4)) && ((*i)[Len-TailLen-4] == '.') ) - TailLen += 4; - - mName = (*i).substr(StartPos,Len-StartPos-TailLen); // remove prefix, extension and doublequotes - - break; - } - } - } - - return (Idx == 3); + TailLen = 1; + if ( (Len > (StartPos+TailLen+4)) && ((*i)[Len-TailLen-4] == '.') ) + TailLen += 4; + + mName = (*i).substr(StartPos,Len-StartPos-TailLen); // remove prefix, extension and doublequotes + + break; + } + } + } + + return (Idx == 3); } // class PDefWorldFileMap defined in gamedefs.h @@ -101,7 +75,7 @@ bool PDefWorldFilesMap::Load(const char* nName, const char* nFilename) Console->Print( "%s Defs name not defined", Console->ColorText( RED, BLACK, "[ERROR]" ) ); return (false); } - + if(! *nFilename) { Console->Print( "%s Filename not defined for %s defs", Console->ColorText( RED, BLACK, "[ERROR]" ), mName.c_str() ); diff --git a/TinNS/Source/GameServer/Definitions/WorldFile.hxx b/TinNS/Source/GameServer/Definitions/WorldFile.hxx new file mode 100644 index 0000000..ea2c788 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/WorldFile.hxx @@ -0,0 +1,30 @@ +#pragma once + +#include +#include +#include +#include "GameServer/Definitions/Definition.hxx" + +class PDefWorldFile : public PDef { +private: + //int32_t mIndex; + std::string mName; // dat filename with ending extension and starting ./ or ./worlds/ REMOVED + bool mFileInWorldsDir; // TRUE if worlds/ must be appendend before mName to get real file name (dat file at least) + +public: + PDefWorldFile(); + //~PDefWorldFile(); + + bool LoadFromDef(PTokenList *Tokens); + + inline const std::string &GetName() const { return mName; } + inline const std::string GetBasicFileName() const { return (mFileInWorldsDir ? (std::string("worlds/") + mName) : mName); }; +}; + + +class PDefWorldFilesMap : public PDefMap { +public: + bool Load(const char* nName, const char* nFilename); + inline std::map::const_iterator ConstIteratorBegin() const { return mDefs.begin(); } + inline std::map::const_iterator ConstIteratorEnd() const { return mDefs.end(); } +}; diff --git a/TinNS/Source/GameServer/Definitions/WorldModels.cxx b/TinNS/Source/GameServer/Definitions/WorldModels.cxx new file mode 100644 index 0000000..b57113d --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/WorldModels.cxx @@ -0,0 +1,41 @@ +#include "GameServer/Definitions/Includes.hxx"" + +PDefWorldModel::PDefWorldModel() +{ +} + +bool PDefWorldModel::LoadFromDef(PTokenList *Tokens) +{ + int Idx=0; + for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++) + { + switch(Idx) + { + case 0: // setentry + continue; + + case 1: // index + mIndex = atoi(i->c_str()); break; + + case 2: // name + mName = *i; break; + + case 3: // use flag + mUseFlags = atoi(i->c_str()); break; + + case 4: // function type + mFunctionType = atoi(i->c_str()); break; + + case 5: // function value + mFunctionValue = atoi(i->c_str()); break; + + case 6: // hack difficulty + mHackDifficulty = atoi(i->c_str()); break; + + case 7: // hack penalty + mHackPenalty = atoi(i->c_str()); break; + } + } + + return true; +} diff --git a/TinNS/Source/GameServer/Definitions/WorldModels.hxx b/TinNS/Source/GameServer/Definitions/WorldModels.hxx new file mode 100644 index 0000000..11cb111 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/WorldModels.hxx @@ -0,0 +1,30 @@ +#pragma once + +#include +#include +#include "GameServer/Definitions/Definition.hxx" + +class PDefWorldModel : public PDef { +private: + //int32_t mIndex; + std::string mName; + int32_t mUseFlags; + int32_t mFunctionType; + int32_t mFunctionValue; + int32_t mHackDifficulty; + int32_t mHackPenalty; + +public: + PDefWorldModel(); + //~PDefWorldModel(); + + bool LoadFromDef(PTokenList *Tokens); + + inline int32_t GetID() const { return mIndex; } + inline const std::string &GetName() const { return mName; } + inline int32_t GetUseFlags() const { return mUseFlags; } + inline int32_t GetFunctionType() const { return mFunctionType; } + inline int32_t GetFunctionValue() const { return mFunctionValue; } + inline int32_t GetHackDifficulty() const { return mHackDifficulty; } + inline int32_t GetHackPenalty() const { return mHackPenalty; } +}; diff --git a/server/src/game/def/def_worlds.cpp b/TinNS/Source/GameServer/Definitions/Worlds.cxx similarity index 56% rename from server/src/game/def/def_worlds.cpp rename to TinNS/Source/GameServer/Definitions/Worlds.cxx index ff7c55a..fdb13eb 100644 --- a/server/src/game/def/def_worlds.cpp +++ b/TinNS/Source/GameServer/Definitions/Worlds.cxx @@ -1,44 +1,4 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_worlds.cpp - - Authors: - - Akiko - - Namikon - - someone else? - - MODIFIED: Unknown date / Unknown author - REASON: - initial release by unknown - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL - - MODIFIED: 07 Oct 2006 Hammag - REASON: - Added quotes and spaces trim to mName and mDatFile. -*/ - -#include "main.h" +#include "GameServer/Definitions/Includes.hxx" PDefWorld::PDefWorld() { diff --git a/TinNS/Source/GameServer/Definitions/Worlds.hxx b/TinNS/Source/GameServer/Definitions/Worlds.hxx new file mode 100644 index 0000000..9129479 --- /dev/null +++ b/TinNS/Source/GameServer/Definitions/Worlds.hxx @@ -0,0 +1,23 @@ +#pragma once + +#include +#include +#include "GameServer/Definitions/Definition.hxx" + +class PDefWorld : public PDef { +private: + //int32_t mIndex; + std::string mName; + std::string mDatFile; + int32_t mFlags; + +public: + PDefWorld(); + //~PDefWorld(); + + bool LoadFromDef(PTokenList *Tokens); + + inline const std::string &GetName() const { return mName; } + inline const std::string &GetDatFile() const { return mDatFile; } + inline int32_t GetFlags() const { return mFlags; } +}; diff --git a/TinNS/Source/GameServer/DoorTemplate.cxx b/TinNS/Source/GameServer/DoorTemplate.cxx new file mode 100644 index 0000000..94aa485 --- /dev/null +++ b/TinNS/Source/GameServer/DoorTemplate.cxx @@ -0,0 +1,116 @@ +#include +#include "GameServer/Includes.hxx" +#include "GameServer/Definitions/Includes.hxx" + +// TODO: - mem corruption occurs if mDoorParameters[] is given a size of 6, and that 6 max param can be accepted +// This bug occurs in world 105. Reason not found yet :-x + +const std::string EmptyString; + +PDoorTemplate::PDoorTemplate() +{ + mDoorID = 0; + mWorldmodelID = 0; + mDefWorldModel = NULL; + mIsDoubleDoor = false; + mIsTriggeredDoor = false; +} + +PDoorTemplate::~PDoorTemplate() +{ +} + +uint16_t PDoorTemplate::GetID() +{ + return mDoorID; +} + +uint16_t PDoorTemplate::GetUseFlags() +{ + return (mDefWorldModel ? mDefWorldModel->GetUseFlags() : 0); +} + +uint16_t PDoorTemplate::GetFunctionType() +{ + return (mDefWorldModel ? mDefWorldModel->GetFunctionType() : 0); +} + +int PDoorTemplate::GetFunctionValue() +{ + return (mDefWorldModel ? mDefWorldModel->GetFunctionValue() : 0); +} + +const std::string& PDoorTemplate::GetName() const +{ + return (mDefWorldModel ? mDefWorldModel->GetName() : EmptyString ); +} + +const PDefWorldModel *PDoorTemplate::GetDefWorldModel() const +{ + return mDefWorldModel; +} + +void PDoorTemplate::GetPos(float *nPosX, float *nPosY, float *nPosZ) const +{ + *nPosY = mPosY; + *nPosZ = mPosZ; + *nPosX = mPosX; +} + +uint16_t PDoorTemplate::GetOtherDoorID() +{ + return (mIsDoubleDoor ? mDoorParameters[1] : 0); +} + +bool PDoorTemplate::IsDoubleDoor() const +{ + return mIsDoubleDoor; +} + +bool PDoorTemplate::IsTriggeredDoor() const +{ + return mIsTriggeredDoor; +} + +void PDoorTemplate::SetDoorParameters(char* nDoorParametersString) +{ + char* SepPos; + int ParamNum = 0; +//Console->Print("door parameter: %s", nDoorParametersString); + while ( *nDoorParametersString && (SepPos = strchr(nDoorParametersString, ',')) && (ParamNum < 4)) + { + *SepPos = 0; + mDoorParameters[ParamNum++] = atoi(nDoorParametersString); + nDoorParametersString = SepPos + 1; + } + if (*nDoorParametersString) + { + if (ParamNum < 4) + mDoorParameters[ParamNum] = atoi(nDoorParametersString); + //else + // Console->Print(RED, BLACK, "[ERROR] More than 4 parameters in Sec2ElemType5 ParamString"); + } +} + +void PDoorTemplate::SetDoorTypeName(char* nDoorTypeName) +{ + mDoorTypeName = nDoorTypeName; + + if (mDoorTypeName == "DDOOR") + { + mIsDoubleDoor = true; + } + else if (mDoorTypeName == "TRIGDD") + { + mIsDoubleDoor = true; + mIsTriggeredDoor = true; + } + else if (mDoorTypeName == "TRIGDOOR") + { + mIsTriggeredDoor = true; + } + else if (mDoorTypeName == "NBUTTON") + { + mIsTriggeredDoor = false; + } +} diff --git a/TinNS/Source/GameServer/DoorTemplate.hxx b/TinNS/Source/GameServer/DoorTemplate.hxx new file mode 100644 index 0000000..e3bbd84 --- /dev/null +++ b/TinNS/Source/GameServer/DoorTemplate.hxx @@ -0,0 +1,47 @@ +#pragma once + +#include + +class PDefWorldModel; + +class PDoorTemplate { + friend class PWorldDatParser; + +private: + uint16_t mDoorID; + + // The commented out values are not loaded from dat file atm because they are not used yet. + //uint16_t mUnknown1; //18 00 + //uint16_t mUnknown1bis; //00 00 ? varies + float mPosY; + float mPosZ; + float mPosX; + //uint16_t mUnknown5; //00 00 ? second byte varies + uint16_t mWorldmodelID; //door type from worldmodel.def + + std::string mDoorTypeName; + int mDoorParameters[4]; + bool mIsDoubleDoor; + bool mIsTriggeredDoor; + + const PDefWorldModel* mDefWorldModel; + +public: + PDoorTemplate(); + ~PDoorTemplate(); + + uint16_t GetID(); + uint16_t GetUseFlags(); + uint16_t GetFunctionType(); + int GetFunctionValue(); + const std::string& GetName() const; /// !!!! + const PDefWorldModel *GetDefWorldModel() const; + + void GetPos(float *nPosX, float *nPosY, float *nPosZ) const; + uint16_t GetOtherDoorID(); + bool IsDoubleDoor() const; + bool IsTriggeredDoor() const; + + void SetDoorTypeName(char* nDoorTypeName); + void SetDoorParameters(char* nDoorParametersString); +}; diff --git a/TinNS/Source/GameServer/FurnitureTemplate.cxx b/TinNS/Source/GameServer/FurnitureTemplate.cxx new file mode 100644 index 0000000..bc29b37 --- /dev/null +++ b/TinNS/Source/GameServer/FurnitureTemplate.cxx @@ -0,0 +1,76 @@ +#include "GameServer/Includes.hxx" +#include "GameServer/Definitions/Includes.hxx" + +const std::string EmptyString; + +PFurnitureItemTemplate::PFurnitureItemTemplate() +{ + mObjectID = 0; + mModelID = 0; + mWorldmodelID = 0; + mDefWorldModel = NULL; + mLinkedObjectID = 0; +} + +PFurnitureItemTemplate::~PFurnitureItemTemplate() +{ +} + +uint32_t PFurnitureItemTemplate::GetID() const +{ + return mObjectID; +} + +uint16_t PFurnitureItemTemplate::GetUseFlags() const +{ + return (mDefWorldModel ? mDefWorldModel->GetUseFlags() : 0); +} + +uint16_t PFurnitureItemTemplate::GetFunctionType() const +{ + return (mDefWorldModel ? mDefWorldModel->GetFunctionType() : 0); +} + +int PFurnitureItemTemplate::GetFunctionValue() const +{ + return (mDefWorldModel ? mDefWorldModel->GetFunctionValue() : 0); +} + +const std::string &PFurnitureItemTemplate::GetName() const +{ + return (mDefWorldModel ? mDefWorldModel->GetName() : EmptyString); +} + +const PDefWorldModel *PFurnitureItemTemplate::GetDefWorldModel() const +{ + return mDefWorldModel; +} + +uint8_t PFurnitureItemTemplate::GetFrontLR() const +{ + return mFrontLR; +} + +void PFurnitureItemTemplate::GetFrontPos(uint16_t *nFrontPosX, uint16_t *nFrontPosY, uint16_t *nFrontPosZ) const +{ + *nFrontPosY = mFrontPosY; + *nFrontPosZ = mFrontPosZ; + *nFrontPosX = mFrontPosX; +} + +void PFurnitureItemTemplate::GetPos(float *nPosX, float *nPosY, float *nPosZ) const +{ + *nPosY = mPosY; + *nPosZ = mPosZ; + *nPosX = mPosX; +} + +void PFurnitureItemTemplate::SetLinkedObjectID(uint32_t nID) +{ + mLinkedObjectID = nID; +} + +uint32_t PFurnitureItemTemplate::GetLinkedObjectID() const +{ + return mLinkedObjectID; +} diff --git a/TinNS/Source/GameServer/FurnitureTemplate.hxx b/TinNS/Source/GameServer/FurnitureTemplate.hxx new file mode 100644 index 0000000..1e1abbb --- /dev/null +++ b/TinNS/Source/GameServer/FurnitureTemplate.hxx @@ -0,0 +1,111 @@ +#pragma once + +#include +#include + +class PDefWorldModel; + +enum { // Furniture Use flags (cumlative) + ufTouchable = 1, + ufUsable = 2, + ufNoCollision = 4, + ufChair = 8, + ufToolTarget = 16, + ufSelfCollisionBox = 64, + ufGraphicalEffect = 128, + ufNoSelectionBox = 256 +}; + +class PFurnitureItemTemplate { + friend class PWorldDatParser; + +private: + uint32_t mObjectID; + + // The commented out values are not loaded from dat file atm because they are not used yet. + float mPosY; //= mPosY from dat file + 32000, to be coherent with char Pos scale + float mPosZ; + float mPosX; + //float mRotY; + float mRotZ; + //float mRotX; + //uint32_t mScale; //00 00 80 3F ? = float(1.0000) scale factor ? // mostly used by holoscreens (passiv object) + //uint32_t mUnknown2; //01 00 00 00 ? + uint16_t mModelID; // points to models.ini + //uint32_t mUnknown3; //00 00 00 00 ? + //uint32_t mUnknown4; //00 00 00 00 ? + uint16_t mWorldmodelID; // points to worldmodel.def + //uint16_t mUnknown5; //12 00 ? // changes sometime (ex: c288 ...) + + //float mBoxLowerY; //Bounding box, for use when ufSelfCollisionBox is set in mUseFlags. + //float mBoxLowerZ; + //float mBoxLowerX; + //float mBoxUpperY; + //float mBoxUpperZ; + //float mBoxUpperX; + + uint16_t mFrontPosY; + uint16_t mFrontPosZ; + uint16_t mFrontPosX; + uint8_t mFrontLR; + + const PDefWorldModel* mDefWorldModel; + + uint32_t mLinkedObjectID; // for buttons, stores the corresponding triggered door + // fo GR, stores order of the GR entity (spawn point) to later choose from respawn.def data + + public: + PFurnitureItemTemplate(); + ~PFurnitureItemTemplate(); + + uint32_t GetID() const; + uint16_t GetUseFlags() const; + uint16_t GetFunctionType() const; + int GetFunctionValue() const; + const std::string &GetName() const; /// !!!! + const PDefWorldModel *GetDefWorldModel() const; + uint8_t GetFrontLR() const; + void GetFrontPos(uint16_t *nFrontPosX, uint16_t *nFrontPosY, uint16_t *nFrontPosZ) const; + void GetPos(float *nPosX, float *nPosY, float *nPosZ) const; + + void SetLinkedObjectID(uint32_t nID); + uint32_t GetLinkedObjectID() const; +}; + +// *** from worldmodel.def *** + +//function Type +// 0 - none +// 1 - Itemcontainer +// 2 - Terminal +// 3 - Outfitter +// 4 - Trader +// 5 - Mineral +// 6 - Respawn Station +// 7 - GoGuardian +// 8 - Hackterminal +// 9 - Appartement Eingang +// 10 - Appartement Ein/Ausgang +// 11 - Appartement Klingel/�ffner +// 12 - Standard Button +// 13 - Hack Button +// 14 - HOLOMATCH ENTRANCE +// 15 - HOLOMATCH EXIT +// 16 - HOLOMATCH REFRESH +// 17 - HOLOMATCH HEAL +// 18 - WORLDCHANGEACTOR +// 19 - CLANTERMINAL +// 20 - DATFILE WORLDCHANGE ACTOR +// 21 - LOCATION FOR 20 +// 22 - +// 23 - EINTRITTSGELD BUTTON +// 24- TUTORIALEXIT +// 25 - EXPLOSIVE +// 26 - Outpost Switch +// 27 - Old goguardian +// 28 - Fahrzeug Depot Interface +// 29 - Underground Exit +// 30 - Static FX (Value=Type. 1=Fire 2=Smoke 3=Steam 4=Sparkle) +// 31 - Venture Warp Station +// 32 - functionvalue+100 gibt eine Meldung aus der Text.ini [MISC] an. +// diff --git a/server/src/game/gamecommands/ban.cpp b/TinNS/Source/GameServer/GameCommands/Ban.cxx similarity index 66% rename from server/src/game/gamecommands/ban.cpp rename to TinNS/Source/GameServer/GameCommands/Ban.cxx index 97f103b..235aa0e 100644 --- a/server/src/game/gamecommands/ban.cpp +++ b/TinNS/Source/GameServer/GameCommands/Ban.cxx @@ -1,24 +1,5 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" +#include +#include "GameServer/Includes.hxx" void PCommands::doCmdban() { @@ -45,7 +26,7 @@ void PCommands::doCmdban() target = GetClientByNick(tmp_destNick); } - if(target == NULL) // If victim isnt found, return error + if(target == nullptr) // If victim isnt found, return error { Chat->send(source, CHAT_DIRECT, "System", "No such player"); return; @@ -61,7 +42,7 @@ void PCommands::doCmdban() char tmpTimeVal[10]; GetArgText(2, tmpTimeVal, 10); - int loop_i = 0; + int32_t loop_i = 0; char tmp_atoi[10]; while(isdigit(tmpTimeVal[loop_i]) != 0 && loop_i < 10) @@ -71,8 +52,8 @@ void PCommands::doCmdban() } char timefactor[1]; timefactor[0] = tmpTimeVal[loop_i]; - int timevalue = atoi(tmp_atoi); - int time_to_ban = 0; + int32_t timevalue = atoi(tmp_atoi); + int32_t time_to_ban = 0; if(strcasecmp(timefactor, "s") == 0 ) { @@ -95,8 +76,8 @@ void PCommands::doCmdban() Chat->send(source, CHAT_DIRECT, "Usage", "@ban ///"); return; } - - int final_bantime = std::time(NULL) + time_to_ban; + + int32_t final_bantime = std::time(nullptr) + time_to_ban; PAccount Acc(target->GetAccountID()); Acc.SetBannedUntilTime(final_bantime); Acc.Save(); diff --git a/server/src/game/gamecommands/brightness.cpp b/TinNS/Source/GameServer/GameCommands/Brightness.cxx similarity index 50% rename from server/src/game/gamecommands/brightness.cpp rename to TinNS/Source/GameServer/GameCommands/Brightness.cxx index a34ebf7..e285b30 100644 --- a/server/src/game/gamecommands/brightness.cpp +++ b/TinNS/Source/GameServer/GameCommands/Brightness.cxx @@ -1,24 +1,4 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" +#include "GameServer/Includes.hxx" void PCommands::doCmdbrightness() { @@ -42,17 +22,17 @@ void PCommands::doCmdbrightness() GetArgText(2, tmp_v2, 30); GetArgText(3, tmp_v3, 30); - u8 val1, val2, val3, val4, val5, val6; + uint8_t val1, val2, val3, val4, val5, val6; char effStr[128]; PMessage* tmpMsg; source->GetChar()->GetCurrentBodyColor(val1, val2, val3, val4, val5, val6); if(tmp_v1[0] != '-') - val4 = (u8)(atoi(tmp_v1) & 0xff); + val4 = (uint8_t)(atoi(tmp_v1) & 0xff); if((tmp_v2[0] != '-') && (tmp_v2[0] != '\0')) - val5 = (u8)(atoi(tmp_v2) & 0xff); + val5 = (uint8_t)(atoi(tmp_v2) & 0xff); if((tmp_v3[0] != '-') && (tmp_v3[0] != '\0')) - val6 = (u8)(atoi(tmp_v3) & 0xff); + val6 = (uint8_t)(atoi(tmp_v3) & 0xff); source->GetChar()->SetCurrentBodyColor(val1, val2, val3, val4, val5, val6); tmpMsg = MsgBuilder->BuildCharHelloMsg(source); diff --git a/TinNS/Source/GameServer/GameCommands/Broadcast.cxx b/TinNS/Source/GameServer/GameCommands/Broadcast.cxx new file mode 100644 index 0000000..2fcf278 --- /dev/null +++ b/TinNS/Source/GameServer/GameCommands/Broadcast.cxx @@ -0,0 +1,13 @@ +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" + +void PCommands::doCmdbroadcast() +{ + if(DumbMade == false) + { + Console->Print("%s Missing packetdumb in PCommands::doCmdbroadcast for declared broadcast function!", Console->ColorText(RED, BLACK, "[PANIC]")); + return; + } + + Chat->sendBroadcast(OrgPacketDumb+11); +} diff --git a/TinNS/Source/GameServer/GameCommands/CMakeLists.txt b/TinNS/Source/GameServer/GameCommands/CMakeLists.txt new file mode 100644 index 0000000..1834cce --- /dev/null +++ b/TinNS/Source/GameServer/GameCommands/CMakeLists.txt @@ -0,0 +1,5 @@ +ADD_LIBRARY (GameCommands Ban.cxx Brightness.cxx Broadcast.cxx Color.cxx Debug.cxx Effect.cxx GiveMoney.cxx + H.cxx Info.cxx Jail.cxx Kick.cxx ListBans.cxx Npc.cxx NpcShop.cxx Online.cxx RawF.cxx + Recall.cxx Remove.cxx SetLevel.cxx SetMainSkill.cxx SetSubSkill.cxx SetTime.cxx Shun.cxx + Skin.cxx SpawnActor.cxx Speed.cxx T.cxx TakeMoney.cxx Teleport.cxx Test.cxx UnBan.cxx + UnJail.cxx UnShun.cxx Uptime.cxx V.cxx Version.cxx Warp.cxx WarpTo.cxx Weather.cxx) diff --git a/TinNS/Source/GameServer/GameCommands/Color.cxx b/TinNS/Source/GameServer/GameCommands/Color.cxx new file mode 100644 index 0000000..f8bad49 --- /dev/null +++ b/TinNS/Source/GameServer/GameCommands/Color.cxx @@ -0,0 +1,43 @@ +#include "GameServer/Includes.hxx" + +void PCommands::doCmdcolor() +{ + bool SyntaxError = false; + if(ArgC < 1) + { + SyntaxError = true; + } + + if(SyntaxError == true) + { + Chat->send(source, CHAT_DIRECT, "Usage", "@color -| [-|] [-|]"); + return; + } + + char tmp_v1[30]; + char tmp_v2[30]; + char tmp_v3[30]; + + GetArgText(1, tmp_v1, 30); + GetArgText(2, tmp_v2, 30); + GetArgText(3, tmp_v3, 30); + + uint8_t val1, val2, val3, val4, val5, val6; + char effStr[128]; + PMessage* tmpMsg; + + source->GetChar()->GetCurrentBodyColor(val1, val2, val3, val4, val5, val6); + if(tmp_v1[0] != '-') + val1 = (uint8_t)(atoi(tmp_v1) & 0xff); + if((tmp_v2[0] != '-') && (tmp_v2[0] != '\0')) + val2 = (uint8_t)(atoi(tmp_v2) & 0xff); + if((tmp_v3[0] != '-') && (tmp_v3[0] != '\0')) + val3 = (uint8_t)(atoi(tmp_v3) & 0xff); + source->GetChar()->SetCurrentBodyColor(val1, val2, val3, val4, val5, val6); + + tmpMsg = MsgBuilder->BuildCharHelloMsg(source); + ClientManager->UDPBroadcast(tmpMsg, source); + snprintf(effStr, 127, "Body color set to values %d %d %d", val1, val2, val3); + effStr[127] = '\0'; + Chat->send(source, CHAT_DIRECT, "System", effStr); +} diff --git a/server/src/game/gamecommands/debug.cpp b/TinNS/Source/GameServer/GameCommands/Debug.cxx similarity index 64% rename from server/src/game/gamecommands/debug.cpp rename to TinNS/Source/GameServer/GameCommands/Debug.cxx index 6a63e3a..6b45f67 100644 --- a/server/src/game/gamecommands/debug.cpp +++ b/TinNS/Source/GameServer/GameCommands/Debug.cxx @@ -1,24 +1,5 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" +#include +#include "GameServer/Includes.hxx" void PCommands::doCmddebug() { @@ -27,7 +8,7 @@ void PCommands::doCmddebug() const char* DbgTarget = "all"; char DbgMessage[80]; const char* Usage = "@debug [loc[ation] | it[emid] | sub[way]] [0|1]"; - + if(ArgC > 0) { if(IsArgNumeric(1) == true) @@ -63,7 +44,7 @@ void PCommands::doCmddebug() } } } - + if (nWhat != DBG_ALL) { if(ArgC == 1) @@ -80,7 +61,7 @@ void PCommands::doCmddebug() } } } - + if (nHow != -1) { source->SetDebugMode(nWhat, nHow); diff --git a/TinNS/Source/GameServer/GameCommands/Effect.cxx b/TinNS/Source/GameServer/GameCommands/Effect.cxx new file mode 100644 index 0000000..926b92d --- /dev/null +++ b/TinNS/Source/GameServer/GameCommands/Effect.cxx @@ -0,0 +1,36 @@ +#include +#include +#include "GameServer/Includes.hxx" + +void PCommands::doCmdeffect() +{ + bool SyntaxError = false; + if(ArgC < 1) + { + SyntaxError = true; + } + + if(IsArgNumeric(1) == false) + SyntaxError = true; + + if(SyntaxError == true) + { + Chat->send(source, CHAT_DIRECT, "Usage", "@effect []"); + return; + } + + uint8_t val1, val2; + char effStr[128]; + PMessage* tmpMsg; + + val1 = (uint8_t)(GetArgInt(1) & 0xff); + val2 = (uint8_t)(GetArgInt(2) & 0xff); + + source->GetChar()->SetBodyEffect(val1, val2); + + tmpMsg = MsgBuilder->BuildCharHelloMsg(source); + ClientManager->UDPBroadcast(tmpMsg, source); + snprintf(effStr, 127, "Body effect set to value %d with density %d (but you can see it yourself)", val1, val2); + effStr[127] = '\0'; + Chat->send(source, CHAT_DIRECT, "System", effStr); +} diff --git a/server/src/game/gamecommands/givemoney.cpp b/TinNS/Source/GameServer/GameCommands/GiveMoney.cxx similarity index 62% rename from server/src/game/gamecommands/givemoney.cpp rename to TinNS/Source/GameServer/GameCommands/GiveMoney.cxx index d47af26..c7b50f3 100644 --- a/server/src/game/gamecommands/givemoney.cpp +++ b/TinNS/Source/GameServer/GameCommands/GiveMoney.cxx @@ -1,28 +1,8 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" +#include "GameServer/Includes.hxx" void PCommands::doCmdgivemoney() { - u32 cashtoadd = 0; + uint32_t cashtoadd = 0; bool SyntaxError = false; if(ArgC < 1) { @@ -35,7 +15,7 @@ void PCommands::doCmdgivemoney() } else { - cashtoadd = (u32)GetArgInt(1); + cashtoadd = (uint32_t)GetArgInt(1); } if(cashtoadd == 0) SyntaxError = true; @@ -72,9 +52,9 @@ void PCommands::doCmdgivemoney() return; } - u32 oldcashval = target->GetChar()->GetCash(); - u32 newcashvalue = target->GetChar()->SetCash(oldcashval + cashtoadd); - u32 diffcash = newcashvalue - oldcashval; + uint32_t oldcashval = target->GetChar()->GetCash(); + uint32_t newcashvalue = target->GetChar()->SetCash(oldcashval + cashtoadd); + uint32_t diffcash = newcashvalue - oldcashval; PMessage* tmpMsg_cash = MsgBuilder->BuildCharMoneyUpdateMsg(target, newcashvalue); target->SendUDPMessage(tmpMsg_cash); @@ -87,8 +67,8 @@ void PCommands::doCmdgivemoney() } else { - u32 oldcashval = source->GetChar()->GetCash(); - u32 newcashvalue = source->GetChar()->SetCash(oldcashval + cashtoadd); + uint32_t oldcashval = source->GetChar()->GetCash(); + uint32_t newcashvalue = source->GetChar()->SetCash(oldcashval + cashtoadd); PMessage* tmpMsg_cash = MsgBuilder->BuildCharMoneyUpdateMsg(source, newcashvalue); source->SendUDPMessage(tmpMsg_cash); diff --git a/server/src/game/gamecommands/h.cpp b/TinNS/Source/GameServer/GameCommands/H.cxx similarity index 59% rename from server/src/game/gamecommands/h.cpp rename to TinNS/Source/GameServer/GameCommands/H.cxx index 3d4ccd9..c39272e 100644 --- a/server/src/game/gamecommands/h.cpp +++ b/TinNS/Source/GameServer/GameCommands/H.cxx @@ -1,24 +1,4 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" +#include "GameServer/Includes.hxx" void PCommands::doCmd_dev_h() { @@ -35,7 +15,7 @@ void PCommands::doCmd_dev_h() /* u8 val1, val2, val3, val4; char tmpStr[128]; - + if(ArgC > 0) { val1 = (u8)(GetArgInt(1) & 0xff); @@ -51,7 +31,7 @@ void PCommands::doCmd_dev_h() val4 = 0x01; } - PMessage* tmpMsg = new PMessage(14); + PMessage* tmpMsg = new PMessage(14); *tmpMsg << (u8)0x13; *tmpMsg << (u16)0x0000; //source->GetUDP_ID(); // just placeholder, must be set outside diff --git a/server/src/game/gamecommands/info.cpp b/TinNS/Source/GameServer/GameCommands/Info.cxx similarity index 78% rename from server/src/game/gamecommands/info.cpp rename to TinNS/Source/GameServer/GameCommands/Info.cxx index b4f372b..c481ad7 100644 --- a/server/src/game/gamecommands/info.cpp +++ b/TinNS/Source/GameServer/GameCommands/Info.cxx @@ -1,24 +1,4 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" +#include "GameServer/Includes.hxx" void PCommands::doCmdinfo() { @@ -66,9 +46,9 @@ void PCommands::doCmdinfo() DIRECT> Info: Cash : %d // Chars->GetChar(source->GetCharID())->GetCash(); DIRECT> Info: Soullight : %d // Chars->GetChar(source->GetCharID())->GetSoullight(); */ - + PAccount Acc(target->GetAccountID()); - + // If source != target if(source->GetAccountID() != target->GetAccountID()) { @@ -98,7 +78,7 @@ void PCommands::doCmdinfo() snprintf(tmpInfo_AxxLv, 150, "AccessLevel: %d", Acc.GetLevel()); snprintf(tmpInfo_Loc, 150, "Current Loc: %d", Chars->GetChar(target->GetCharID())->GetLocation()); snprintf(tmpInfo_IP, 150, "IP address : %s", target->GetAddress()); - + tmpInfo_head[150] = '\0'; tmpInfo_cID[150] = '\0'; tmpInfo_aID[150] = '\0'; diff --git a/server/src/game/gamecommands/jail.cpp b/TinNS/Source/GameServer/GameCommands/Jail.cxx similarity index 68% rename from server/src/game/gamecommands/jail.cpp rename to TinNS/Source/GameServer/GameCommands/Jail.cxx index d3c60eb..3a715d8 100644 --- a/server/src/game/gamecommands/jail.cpp +++ b/TinNS/Source/GameServer/GameCommands/Jail.cxx @@ -1,24 +1,5 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" void PCommands::doCmdjail() { @@ -60,7 +41,7 @@ void PCommands::doCmdjail() return; } - u32 currLoc = target->GetChar()->GetLocation(); + uint32_t currLoc = target->GetChar()->GetLocation(); // Make sure that target player is not already in Regants if ( currLoc == 550 || currLoc == 551 ) { diff --git a/server/src/game/gamecommands/kick.cpp b/TinNS/Source/GameServer/GameCommands/Kick.cxx similarity index 67% rename from server/src/game/gamecommands/kick.cpp rename to TinNS/Source/GameServer/GameCommands/Kick.cxx index 49edb01..ffa22d2 100644 --- a/server/src/game/gamecommands/kick.cpp +++ b/TinNS/Source/GameServer/GameCommands/Kick.cxx @@ -1,24 +1,5 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" void PCommands::doCmdkick() { diff --git a/TinNS/Source/GameServer/GameCommands/ListBans.cxx b/TinNS/Source/GameServer/GameCommands/ListBans.cxx new file mode 100644 index 0000000..88c5fa5 --- /dev/null +++ b/TinNS/Source/GameServer/GameCommands/ListBans.cxx @@ -0,0 +1,8 @@ +#include "GameServer/Includes.hxx" + +void PCommands::doCmdlistbans() +{ + Chat->send(source, CHAT_DIRECT, "System", "Sorry, namikon was too lazy to code that ^^"); + Chat->send(source, CHAT_DIRECT, "System", "Please wait until the ban is removed automaticly or edit your sqlDB"); + return; +} diff --git a/server/src/game/gamecommands/npc.cpp b/TinNS/Source/GameServer/GameCommands/Npc.cxx similarity index 89% rename from server/src/game/gamecommands/npc.cpp rename to TinNS/Source/GameServer/GameCommands/Npc.cxx index 847c4ca..8737347 100644 --- a/server/src/game/gamecommands/npc.cpp +++ b/TinNS/Source/GameServer/GameCommands/Npc.cxx @@ -1,24 +1,7 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" +#include +#include "GameServer/Includes.hxx" +#include "GameServer/Definitions/Includes.hxx" +#include "Common/Includes.hxx" void PCommands::doNPC() { @@ -128,16 +111,16 @@ void PCommands::doNPC() if(ArgC == 3) GetArgText(3, tCustomName, 80); - u16 tNPCPosX = source->GetChar()->Coords.mX + 768; - u16 tNPCPosY = source->GetChar()->Coords.mY + 768; - u16 tNPCPosZ = source->GetChar()->Coords.mZ + 768; - u32 tLocation = source->GetChar()->GetLocation(); + uint16_t tNPCPosX = source->GetChar()->Coords.mX + 768; + uint16_t tNPCPosY = source->GetChar()->Coords.mY + 768; + uint16_t tNPCPosZ = source->GetChar()->Coords.mZ + 768; + uint32_t tLocation = source->GetChar()->GetLocation(); - u8 tAngle = source->GetChar()->Coords.mLR; + uint8_t tAngle = source->GetChar()->Coords.mLR; std::string tNPCAngle = Ssprintf( "%d", tAngle ); std::string tNPCScript = t_defNpc->GetStandardScript(); - u32 tNPCHealth = t_defNpc->GetHealth() * NPC_HEALTHFACTOR; + uint32_t tNPCHealth = t_defNpc->GetHealth() * NPC_HEALTHFACTOR; /*-------------------------------------------------------*/ // Get the highest NPC Id for current zone diff --git a/server/src/game/gamecommands/npc_shop.cpp b/TinNS/Source/GameServer/GameCommands/NpcShop.cxx similarity index 89% rename from server/src/game/gamecommands/npc_shop.cpp rename to TinNS/Source/GameServer/GameCommands/NpcShop.cxx index e7ffcf4..3224da5 100644 --- a/server/src/game/gamecommands/npc_shop.cpp +++ b/TinNS/Source/GameServer/GameCommands/NpcShop.cxx @@ -1,24 +1,6 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" +#include +#include "GameServer/Includes.hxx" +#include "GameServer/Definitions/Includes.hxx" void PCommands::doNPC_Shop() { @@ -218,7 +200,7 @@ void PCommands::doNPC_Shop() } else if(strncmp(tmp_npccommand, "setquality", 10) == 0) { - u8 tNewLv = (u8)GetArgInt(3); + uint8_t tNewLv = (uint8_t)GetArgInt(3); if(targetNPC->IsSQLNPC() == true) { char sqlq[200]; diff --git a/TinNS/Source/GameServer/GameCommands/Online.cxx b/TinNS/Source/GameServer/GameCommands/Online.cxx new file mode 100644 index 0000000..096d394 --- /dev/null +++ b/TinNS/Source/GameServer/GameCommands/Online.cxx @@ -0,0 +1,8 @@ +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" + +void PCommands::doCmdconlist() +{ + if (gDevDebug) Console->Print("IngameCommand: Sending connected-player-list to charID %d", source->GetCharID()); + Chat->sendConnectedList(source, false); +} diff --git a/server/src/game/gamecommands/README b/TinNS/Source/GameServer/GameCommands/README similarity index 100% rename from server/src/game/gamecommands/README rename to TinNS/Source/GameServer/GameCommands/README diff --git a/server/src/game/gamecommands/rawf.cpp b/TinNS/Source/GameServer/GameCommands/RawF.cxx similarity index 69% rename from server/src/game/gamecommands/rawf.cpp rename to TinNS/Source/GameServer/GameCommands/RawF.cxx index 917409d..0dab13a 100644 --- a/server/src/game/gamecommands/rawf.cpp +++ b/TinNS/Source/GameServer/GameCommands/RawF.cxx @@ -1,24 +1,6 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" +#include +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" void PCommands::doCmdrawf() { diff --git a/server/src/game/gamecommands/recall.cpp b/TinNS/Source/GameServer/GameCommands/Recall.cxx similarity index 71% rename from server/src/game/gamecommands/recall.cpp rename to TinNS/Source/GameServer/GameCommands/Recall.cxx index 5a73f4d..f9a4751 100644 --- a/server/src/game/gamecommands/recall.cpp +++ b/TinNS/Source/GameServer/GameCommands/Recall.cxx @@ -1,24 +1,5 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" void PCommands::doCmdrecall() { @@ -75,7 +56,7 @@ void PCommands::doCmdrecall() target->SendUDPMessage( tmpMsg_zone ); tmpMsg_zone = NULL; - u16 nNewX, nNewY, nNewZ; + uint16_t nNewX, nNewY, nNewZ; nNewX = source->GetChar()->Coords.mX; nNewY = source->GetChar()->Coords.mY; nNewZ = source->GetChar()->Coords.mZ; diff --git a/server/src/game/gamecommands/remove.cpp b/TinNS/Source/GameServer/GameCommands/Remove.cxx similarity index 61% rename from server/src/game/gamecommands/remove.cpp rename to TinNS/Source/GameServer/GameCommands/Remove.cxx index 4348b10..d52948a 100644 --- a/server/src/game/gamecommands/remove.cpp +++ b/TinNS/Source/GameServer/GameCommands/Remove.cxx @@ -1,24 +1,5 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" +#include +#include "GameServer/Includes.hxx" void PCommands::doCmdremove() { @@ -53,17 +34,17 @@ void PCommands::doCmdremove() if(IsArgNumeric(1) == true) { - u32 tTest = GetArgInt(1); + uint32_t tTest = GetArgInt(1); if(WorldActors->IsDynamicActor(tTest) == true) { Chat->send(source, CHAT_DIRECT, "System", "You cannot remove dynamic actors over their ID!"); return; } - u32 TargetID; + uint32_t TargetID; char delStr[128]; PMessage* tmpMsg; - TargetID = (u32)(atoi(tmp_v1) & 0xffffffff); + TargetID = (uint32_t)(atoi(tmp_v1) & 0xffffffff); tmpMsg = MsgBuilder->BuildFurnitureActivateMsg(source, TargetID, 5); ClientManager->UDPBroadcast(tmpMsg, source); diff --git a/server/src/game/gamecommands/setlevel.cpp b/TinNS/Source/GameServer/GameCommands/SetLevel.cxx similarity index 64% rename from server/src/game/gamecommands/setlevel.cpp rename to TinNS/Source/GameServer/GameCommands/SetLevel.cxx index 5e8cb42..ea23ff9 100644 --- a/server/src/game/gamecommands/setlevel.cpp +++ b/TinNS/Source/GameServer/GameCommands/SetLevel.cxx @@ -1,24 +1,4 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" +#include "GameServer/Includes.hxx" void PCommands::doCmdsetlevel() { diff --git a/server/src/game/gamecommands/setmainskill.cpp b/TinNS/Source/GameServer/GameCommands/SetMainSkill.cxx similarity index 71% rename from server/src/game/gamecommands/setmainskill.cpp rename to TinNS/Source/GameServer/GameCommands/SetMainSkill.cxx index a059afb..a778821 100644 --- a/server/src/game/gamecommands/setmainskill.cpp +++ b/TinNS/Source/GameServer/GameCommands/SetMainSkill.cxx @@ -1,29 +1,9 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" +#include "GameServer/Includes.hxx" void PCommands::doCmdSetMainSkill() { - u8 tNewLevel = 0; - u8 tMainSkill = 0; + uint8_t tNewLevel = 0; + uint8_t tMainSkill = 0; bool SyntaxError = false; if (ArgC < 2) @@ -34,12 +14,12 @@ void PCommands::doCmdSetMainSkill() if (IsArgNumeric(1) == false) SyntaxError = true; else - tMainSkill = (u16)GetArgInt(1); + tMainSkill = (uint16_t)GetArgInt(1); if (IsArgNumeric(2) == false) SyntaxError = true; else - tNewLevel = (u8)GetArgInt(2); + tNewLevel = (uint8_t)GetArgInt(2); if (tNewLevel == 0) SyntaxError = true; @@ -77,8 +57,8 @@ void PCommands::doCmdSetMainSkill() temp_target = source; // Now setting player's Skill tMainSkill to tNewLevel - u8 tOldLevel = 0; - u16 tNewSkillPoints = 0; + uint8_t tOldLevel = 0; + uint16_t tNewSkillPoints = 0; int tLevelDiff = 0; // Grab old Level @@ -108,7 +88,7 @@ void PCommands::doCmdSetMainSkill() char tmp[50]; snprintf(tmp, 50, "Setting Level to %d", tNewLevel); Chat->send(source, CHAT_DIRECT, "System", tmp); - //PMessage* PMsgBuilder::BuildLevelUpMessage( PClient* nClient, u8 nMainSkill, u8 nNewLevel, u16 nFreeSkillPoints) + //PMessage* PMsgBuilder::BuildLevelUpMessage( PClient* nClient, uint8_t nMainSkill, uint8_t nNewLevel, uint16_t nFreeSkillPoints) PMessage* tmpMsg_setLv = MsgBuilder->BuildLevelUpMessage(temp_target, tMainSkill, tNewLevel, tNewSkillPoints); temp_target->SendUDPMessage(tmpMsg_setLv); tmpMsg_setLv = NULL; diff --git a/server/src/game/gamecommands/setsubskill.cpp b/TinNS/Source/GameServer/GameCommands/SetSubSkill.cxx similarity index 67% rename from server/src/game/gamecommands/setsubskill.cpp rename to TinNS/Source/GameServer/GameCommands/SetSubSkill.cxx index 42dbf9a..f42118c 100644 --- a/server/src/game/gamecommands/setsubskill.cpp +++ b/TinNS/Source/GameServer/GameCommands/SetSubSkill.cxx @@ -1,29 +1,9 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" +#include "GameServer/Includes.hxx" void PCommands::doCmdSetSubSkill() { - u8 tNewLevel = 0; - u8 tSubSkill = 0; + uint8_t tNewLevel = 0; + uint8_t tSubSkill = 0; bool SyntaxError = false; if (ArgC < 2) @@ -34,12 +14,12 @@ void PCommands::doCmdSetSubSkill() if (IsArgNumeric(1) == false) SyntaxError = true; else - tSubSkill = (u16)GetArgInt(1); + tSubSkill = (uint16_t)GetArgInt(1); if (IsArgNumeric(2) == false) SyntaxError = true; else - tNewLevel = (u8)GetArgInt(2); + tNewLevel = (uint8_t)GetArgInt(2); if (tNewLevel == 0) SyntaxError = true; @@ -78,7 +58,7 @@ void PCommands::doCmdSetSubSkill() // Now setting player's Skill tMainSkill to tNewLevel - u8 tOldLevel = 0; + uint8_t tOldLevel = 0; int tLevelDiff = 0; // Grab old Level diff --git a/TinNS/Source/GameServer/GameCommands/SetTime.cxx b/TinNS/Source/GameServer/GameCommands/SetTime.cxx new file mode 100644 index 0000000..0b38078 --- /dev/null +++ b/TinNS/Source/GameServer/GameCommands/SetTime.cxx @@ -0,0 +1,17 @@ +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" + +void PCommands::doCmdsettime() +{ + if(ArgC < 1 && GetArgInt(1) == 0) + { + Chat->send(source, CHAT_DIRECT, "Usage", "@settime "); + return; + } + + int newtime = 0; + newtime = GetArgInt(1); + + GameServer->SetGameTime(newtime); + Console->Print("IngameCommand: CharID %d set ingametime to %d", source->GetCharID(), newtime); +} diff --git a/server/src/game/gamecommands/shun.cpp b/TinNS/Source/GameServer/GameCommands/Shun.cxx similarity index 61% rename from server/src/game/gamecommands/shun.cpp rename to TinNS/Source/GameServer/GameCommands/Shun.cxx index 8a39cc2..c899549 100644 --- a/server/src/game/gamecommands/shun.cpp +++ b/TinNS/Source/GameServer/GameCommands/Shun.cxx @@ -1,24 +1,4 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" +#include "GameServer/Includes.hxx" void PCommands::doCmdshun() { diff --git a/server/src/game/gamecommands/skin.cpp b/TinNS/Source/GameServer/GameCommands/Skin.cxx similarity index 74% rename from server/src/game/gamecommands/skin.cpp rename to TinNS/Source/GameServer/GameCommands/Skin.cxx index 64feec4..249fa29 100644 --- a/server/src/game/gamecommands/skin.cpp +++ b/TinNS/Source/GameServer/GameCommands/Skin.cxx @@ -1,24 +1,5 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" +#include +#include "GameServer/Includes.hxx" void PCommands::doCmdskin() { @@ -38,7 +19,7 @@ Usage: @skin # SyntaxError = true; } - u32 Skinval1, Skinval2, Skinval3, Skinval4; + uint32_t Skinval1, Skinval2, Skinval3, Skinval4; PChar *SkinChar = Chars->GetChar(source->GetCharID()); std::stringstream SkinChat; char SkinStr[128]; diff --git a/server/src/game/gamecommands/spawnactor.cpp b/TinNS/Source/GameServer/GameCommands/SpawnActor.cxx similarity index 64% rename from server/src/game/gamecommands/spawnactor.cpp rename to TinNS/Source/GameServer/GameCommands/SpawnActor.cxx index 87532b5..678a550 100644 --- a/server/src/game/gamecommands/spawnactor.cpp +++ b/TinNS/Source/GameServer/GameCommands/SpawnActor.cxx @@ -1,24 +1,4 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" +#include "GameServer/Includes.hxx" void PCommands::doCmdspawnactor() { @@ -33,11 +13,11 @@ void PCommands::doCmdspawnactor() SyntaxError = true; } - u16 tmpActorID = (u16)GetArgInt(1); - u16 tmpFunctionID = (u16)GetArgInt(2); - u16 tmpOption1 = 0; - u16 tmpOption2 = 0; - u16 tmpOption3 = 0; + uint16_t tmpActorID = (uint16_t)GetArgInt(1); + uint16_t tmpFunctionID = (uint16_t)GetArgInt(2); + uint16_t tmpOption1 = 0; + uint16_t tmpOption2 = 0; + uint16_t tmpOption3 = 0; if(ArgC > 2) { @@ -47,7 +27,7 @@ void PCommands::doCmdspawnactor() } else { - tmpOption1 = (u16)GetArgInt(3); + tmpOption1 = (uint16_t)GetArgInt(3); if(ArgC > 3) { if(IsArgNumeric(4) == false) @@ -56,7 +36,7 @@ void PCommands::doCmdspawnactor() } else { - tmpOption1 = (u16)GetArgInt(4); + tmpOption1 = (uint16_t)GetArgInt(4); if(ArgC > 4) { if(IsArgNumeric(4) == false) @@ -65,7 +45,7 @@ void PCommands::doCmdspawnactor() } else { - tmpOption1 = (u16)GetArgInt(5); + tmpOption1 = (uint16_t)GetArgInt(5); } } } diff --git a/TinNS/Source/GameServer/GameCommands/Speed.cxx b/TinNS/Source/GameServer/GameCommands/Speed.cxx new file mode 100644 index 0000000..8b86daa --- /dev/null +++ b/TinNS/Source/GameServer/GameCommands/Speed.cxx @@ -0,0 +1,35 @@ +#include "GameServer/Includes.hxx" + +void PCommands::doCmdspeed() +{ +// Speed override setting. +// Usage: @speed | # +// with = 0 (no move).. 254 , 255 or # meaning "no speed override" + + bool SyntaxError = false; + if(ArgC < 1) + { + SyntaxError = true; + } + + if(SyntaxError == true) + { + Chat->send(source, CHAT_DIRECT, "Usage", "@speed | 255 | #"); + return; + } + char tmpval[30]; + GetArgText(1, tmpval, 30); + + uint8_t val1; + char effStr[128]; + PMessage* tmpMsg; + + val1 = ((tmpval[0] == '#') ? 255 : (uint8_t)(atoi(tmpval) & 0xff)); + source->GetChar()->SetSpeedOverride(val1); + + tmpMsg = MsgBuilder->BuildCharHelloMsg(source); + ClientManager->UDPBroadcast(tmpMsg, source); + snprintf(effStr, 127, "Speed override set to value %d ", val1); + effStr[127] = '\0'; + Chat->send(source, CHAT_DIRECT, "System", effStr); +} diff --git a/server/src/game/gamecommands/t.cpp b/TinNS/Source/GameServer/GameCommands/T.cxx similarity index 60% rename from server/src/game/gamecommands/t.cpp rename to TinNS/Source/GameServer/GameCommands/T.cxx index a20da9b..49b70f4 100644 --- a/server/src/game/gamecommands/t.cpp +++ b/TinNS/Source/GameServer/GameCommands/T.cxx @@ -1,24 +1,7 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" +#include +#include +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" void PCommands::doCmd_dev_t() { @@ -36,27 +19,27 @@ void PCommands::doCmd_dev_t() if ( ArgC >= 2 ) { GetArgText( 1, Arg1, 30 ); - u32 targetObjectId = GetArgInt( 2 ) & 0xffffffff; + uint32_t targetObjectId = GetArgInt( 2 ) & 0xffffffff; if ( Arg1[0] == 't' ) { - u8 val1; + uint8_t val1; if ( ArgC >= 3 ) { int val2 = GetArgInt( 3 ); tmpMsg = new PMessage( 32 ); source->IncreaseUDP_ID(); - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )source->GetUDP_ID(); - *tmpMsg << ( u16 )source->GetSessionID(); - *tmpMsg << ( u8 )0x00; // Message length - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )source->GetUDP_ID(); - *tmpMsg << ( u8 )0x2d; - *tmpMsg << ( u32 )targetObjectId; - *tmpMsg << ( u8 )0x01; - *tmpMsg << ( u32 )val2; - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )source->GetUDP_ID(); + *tmpMsg << ( uint16_t )source->GetSessionID(); + *tmpMsg << ( uint8_t )0x00; // Message length + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )source->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x2d; + *tmpMsg << ( uint32_t )targetObjectId; + *tmpMsg << ( uint8_t )0x01; + *tmpMsg << ( uint32_t )val2; + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); source->SendUDPMessage( tmpMsg ); snprintf( tmpStr, 127, "Sent 13/03/2d msg to object id 0x%08x with values 6/%d", targetObjectId, val2 ); textMsg = tmpStr; @@ -66,17 +49,17 @@ void PCommands::doCmd_dev_t() if(val1 == 6) continue; tmpMsg = new PMessage( 15 ); source->IncreaseUDP_ID(); - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )source->GetUDP_ID(); - *tmpMsg << ( u16 )source->GetSessionID(); - *tmpMsg << ( u8 )0x00; // Message length - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )source->GetUDP_ID(); - *tmpMsg << ( u8 )0x2d; - *tmpMsg << ( u32 )targetObjectId; - *tmpMsg << ( u8 )val1; - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )source->GetUDP_ID(); + *tmpMsg << ( uint16_t )source->GetSessionID(); + *tmpMsg << ( uint8_t )0x00; // Message length + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )source->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x2d; + *tmpMsg << ( uint32_t )targetObjectId; + *tmpMsg << ( uint8_t )val1; + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); source->SendUDPMessage( tmpMsg ); snprintf( tmpStr, 127, "Sent 13/03/2d msg to object id 0x%08x with value %d", targetObjectId, val1 ); textMsg = tmpStr; @@ -84,14 +67,15 @@ void PCommands::doCmd_dev_t() Chat->send( source, CHAT_DIRECT, "System", textMsg ); source->getUDPConn()->update(); source->getTCPConn()->update(); - sleep(1); + //sleep(1); + std::this_thread::sleep_for(std::chrono::seconds(1)); } tmpMsg = NULL; } else if ( Arg1[0] == 'd' ) { - u8 val1 = 0x4a; // default values - u8 val2 = 0x1e; + uint8_t val1 = 0x4a; // default values + uint8_t val2 = 0x1e; if ( ArgC >= 3 ) val1 = GetArgInt( 3 ) & 0xff; @@ -103,9 +87,9 @@ void PCommands::doCmd_dev_t() } else if ( Arg1[0] == 'm' ) { - u8 nTxtGroupID = targetObjectId & 0xff; - u16 nTxtID = 10; - //u32 nVal = 0; + uint8_t nTxtGroupID = targetObjectId & 0xff; + uint16_t nTxtID = 10; + //uint32_t nVal = 0; if ( ArgC >= 3 ) nTxtID = GetArgInt( 3 ) & 0xffff; //if(ArgC >= 4) @@ -114,27 +98,27 @@ void PCommands::doCmd_dev_t() tmpMsg = new PMessage( 20 ); source->IncreaseUDP_ID(); - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )source->GetUDP_ID(); - *tmpMsg << ( u16 )source->GetSessionID(); - *tmpMsg << ( u8 )0x0e; // Message length - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )source->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )source->GetLocalID(); - *tmpMsg << ( u8 )0x25; // ?? - *tmpMsg << ( u8 )0x15; // ?? + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )source->GetUDP_ID(); + *tmpMsg << ( uint16_t )source->GetSessionID(); + *tmpMsg << ( uint8_t )0x0e; // Message length + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )source->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )source->GetLocalID(); + *tmpMsg << ( uint8_t )0x25; // ?? + *tmpMsg << ( uint8_t )0x15; // ?? *tmpMsg << nTxtGroupID; *tmpMsg << nTxtID; - *tmpMsg << ( u16 )0x00; // ?? - *tmpMsg << ( u8 )0x01; - *tmpMsg << ( u8 )0x04; - *tmpMsg << ( u32 )0x00; - //*tmpMsg << (u8)0x00; // ?? - //*tmpMsg << (u8)0x00; // ?? - //*tmpMsg << (u32)nVal; - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); + *tmpMsg << ( uint16_t )0x00; // ?? + *tmpMsg << ( uint8_t )0x01; + *tmpMsg << ( uint8_t )0x04; + *tmpMsg << ( uint32_t )0x00; + //*tmpMsg << (uint8_t)0x00; // ?? + //*tmpMsg << (uint8_t)0x00; // ?? + //*tmpMsg << (uint32_t)nVal; + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); snprintf( tmpStr, 127, "Using msg n %d from group %d", nTxtID, nTxtGroupID ); textMsg = tmpStr; @@ -144,36 +128,36 @@ void PCommands::doCmd_dev_t() else if ( Arg1[0] == 'e' ) { targetObjectId = 1004; //target=int - u16 nval = 5; - u8 nType = 1; // 1=+ 2=- - u16 nDur = 20; - u8 nparam = 1; + uint16_t nval = 5; + uint8_t nType = 1; // 1=+ 2=- + uint16_t nDur = 20; + uint8_t nparam = 1; nparam = GetArgInt( 2 ) && 0xff; tmpMsg = new PMessage( 32 ); source->IncreaseUDP_ID(); - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )source->GetUDP_ID(); - *tmpMsg << ( u16 )source->GetSessionID(); - *tmpMsg << ( u8 )0x0e; // Message length - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )source->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )source->GetLocalID(); - *tmpMsg << ( u8 )0x25; // ?? - *tmpMsg << ( u8 )0x06; // ?? - *tmpMsg << ( u8 )0x01; // 1 effect - *tmpMsg << ( u8 )0x01; // effect on intox level ???? - *tmpMsg << ( u16 )nDur; - *tmpMsg << ( u16 )(700+(targetObjectId % 100)); //item id Thyronol - *tmpMsg << ( u8 )nType; - *tmpMsg << ( u16 )(nval*100); //u32 in nc2.2 - *tmpMsg << ( u16 )targetObjectId; - - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )source->GetUDP_ID(); + *tmpMsg << ( uint16_t )source->GetSessionID(); + *tmpMsg << ( uint8_t )0x0e; // Message length + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )source->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )source->GetLocalID(); + *tmpMsg << ( uint8_t )0x25; // ?? + *tmpMsg << ( uint8_t )0x06; // ?? + *tmpMsg << ( uint8_t )0x01; // 1 effect + *tmpMsg << ( uint8_t )0x01; // effect on intox level ???? + *tmpMsg << ( uint16_t )nDur; + *tmpMsg << ( uint16_t )(700+(targetObjectId % 100)); //item id Thyronol + *tmpMsg << ( uint8_t )nType; + *tmpMsg << ( uint16_t )(nval*100); //uint32_t in nc2.2 + *tmpMsg << ( uint16_t )targetObjectId; + + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); snprintf( tmpStr, 127, "Sendind drug mod to stat %d, %s %d", targetObjectId, (nType == 1 ? "inc" : "dec"), nval ); textMsg = tmpStr; @@ -183,7 +167,7 @@ void PCommands::doCmd_dev_t() else if ( Arg1[0] == 'w' ) { /*targetObjectId &= 0xffff; - u16 val1 = 0; + uint16_t val1 = 0; if ( ArgC >= 3 ) val1 = GetArgInt( 3 ) & 0xffff; */ @@ -191,18 +175,18 @@ void PCommands::doCmd_dev_t() source->IncreaseUDP_ID(); - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )source->GetUDP_ID(); - *tmpMsg << ( u16 )source->GetSessionID(); - *tmpMsg << ( u8 )0x0a; // Message length place; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )source->GetUDP_ID(); - *tmpMsg << ( u8 )0x23; - *tmpMsg << ( u16 )0x0012; // cmd = ? - *tmpMsg << ( u16 )0x0007; - *tmpMsg << ( u32 )0x00000000; + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )source->GetUDP_ID(); + *tmpMsg << ( uint16_t )source->GetSessionID(); + *tmpMsg << ( uint8_t )0x0a; // Message length place; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )source->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x23; + *tmpMsg << ( uint16_t )0x0012; // cmd = ? + *tmpMsg << ( uint16_t )0x0007; + *tmpMsg << ( uint32_t )0x00000000; - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); snprintf( tmpStr, 127, "Sending w msg " ); textMsg = tmpStr; @@ -212,7 +196,7 @@ void PCommands::doCmd_dev_t() } else if ( Arg1[0] == 'x' ) { - u8 val1 = targetObjectId &= 0xff; + uint8_t val1 = targetObjectId &= 0xff; tmpMsg = MsgBuilder->BuildUndefineduseMsg( source, val1 ); @@ -251,8 +235,8 @@ void PCommands::doCmd_dev_t() } } - u32 val1; - u8 val2; + uint32_t val1; + uint8_t val2; char tmpStr[128]; static PMessage* tmpMsg = NULL; bool SetUDP_IDNeeded = true; @@ -271,7 +255,7 @@ void PCommands::doCmd_dev_t() if(Arg1[0] != '\0' && Arg2[0] != '\0') { val1 = atoi(Arg1); - val2 = (u8)(atoi(Arg2) & 0xff); + val2 = (uint8_t)(atoi(Arg2) & 0xff); //tmpMsg->U8Data(16 + val1) = val2; tmpMsg->U8Data(10 + val1) = val2; snprintf(tmpStr, 127, "Data #%d set to value 0x%02x", val1, val2); @@ -306,7 +290,7 @@ void PCommands::doCmd_dev_t() return; char tmpStr[128]; - u8 SubWay[] = {0x13, 0x71, 0x00, 0x9b, 0xde, + uint8_t SubWay[] = {0x13, 0x71, 0x00, 0x9b, 0xde, //Subway 1 (fc 03) 0x11, 0x03, 0x6d, 0x00, 0x28, 0x27, 0x00, 0xfc, 0x03, 0x00, 0x00, @@ -350,7 +334,7 @@ void PCommands::doCmd_dev_t() 0x03, 0x71, 0x00, 0x2d, 0xf7, 0x03, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00}; - u8 SubWay2[] = {0x13, 0x71, 0x00, 0x9b, 0xde, + uint8_t SubWay2[] = {0x13, 0x71, 0x00, 0x9b, 0xde, //Subway 7 (f6 03) 0x11, 0x03, 0x6d, 0x00, 0x28, 0x27, 0x00, 0xf6, 0x03, 0x00, 0x00, @@ -393,72 +377,72 @@ void PCommands::doCmd_dev_t() //SubWay List //Subway 1 source->IncreaseUDP_ID(); - *(u16*)&SubWay[7] = source->GetUDP_ID(); + *(uint16_t*)&SubWay[7] = source->GetUDP_ID(); source->IncreaseUDP_ID(); - *(u16*)&SubWay[25] = source->GetUDP_ID(); + *(uint16_t*)&SubWay[25] = source->GetUDP_ID(); //Subway 2 source->IncreaseUDP_ID(); - *(u16*)&SubWay[39] = source->GetUDP_ID(); + *(uint16_t*)&SubWay[39] = source->GetUDP_ID(); source->IncreaseUDP_ID(); - *(u16*)&SubWay[57] = source->GetUDP_ID(); + *(uint16_t*)&SubWay[57] = source->GetUDP_ID(); //Subway 3 source->IncreaseUDP_ID(); - *(u16*)&SubWay[71] = source->GetUDP_ID(); + *(uint16_t*)&SubWay[71] = source->GetUDP_ID(); source->IncreaseUDP_ID(); - *(u16*)&SubWay[89] = source->GetUDP_ID(); + *(uint16_t*)&SubWay[89] = source->GetUDP_ID(); //Subway 4 source->IncreaseUDP_ID(); - *(u16*)&SubWay[103] = source->GetUDP_ID(); + *(uint16_t*)&SubWay[103] = source->GetUDP_ID(); source->IncreaseUDP_ID(); - *(u16*)&SubWay[121] = source->GetUDP_ID(); + *(uint16_t*)&SubWay[121] = source->GetUDP_ID(); //Subway 5 source->IncreaseUDP_ID(); - *(u16*)&SubWay[135] = source->GetUDP_ID(); + *(uint16_t*)&SubWay[135] = source->GetUDP_ID(); source->IncreaseUDP_ID(); - *(u16*)&SubWay[153] = source->GetUDP_ID(); + *(uint16_t*)&SubWay[153] = source->GetUDP_ID(); //Subway 6 source->IncreaseUDP_ID(); - *(u16*)&SubWay[167] = source->GetUDP_ID(); + *(uint16_t*)&SubWay[167] = source->GetUDP_ID(); source->IncreaseUDP_ID(); - *(u16*)&SubWay[185] = source->GetUDP_ID(); + *(uint16_t*)&SubWay[185] = source->GetUDP_ID(); //Subway 7 source->IncreaseUDP_ID(); - *(u16*)&SubWay2[7] = source->GetUDP_ID(); + *(uint16_t*)&SubWay2[7] = source->GetUDP_ID(); source->IncreaseUDP_ID(); - *(u16*)&SubWay2[25] = source->GetUDP_ID(); + *(uint16_t*)&SubWay2[25] = source->GetUDP_ID(); //Subway 8 source->IncreaseUDP_ID(); - *(u16*)&SubWay2[39] = source->GetUDP_ID(); + *(uint16_t*)&SubWay2[39] = source->GetUDP_ID(); source->IncreaseUDP_ID(); - *(u16*)&SubWay2[57] = source->GetUDP_ID(); + *(uint16_t*)&SubWay2[57] = source->GetUDP_ID(); //Subway 9 source->IncreaseUDP_ID(); - *(u16*)&SubWay2[71] = source->GetUDP_ID(); + *(uint16_t*)&SubWay2[71] = source->GetUDP_ID(); source->IncreaseUDP_ID(); - *(u16*)&SubWay2[89] = source->GetUDP_ID(); + *(uint16_t*)&SubWay2[89] = source->GetUDP_ID(); //Subway 10 source->IncreaseUDP_ID(); - *(u16*)&SubWay2[103] = source->GetUDP_ID(); + *(uint16_t*)&SubWay2[103] = source->GetUDP_ID(); source->IncreaseUDP_ID(); - *(u16*)&SubWay2[121] = source->GetUDP_ID(); + *(uint16_t*)&SubWay2[121] = source->GetUDP_ID(); //Subway 11 source->IncreaseUDP_ID(); - *(u16*)&SubWay2[135] = source->GetUDP_ID(); + *(uint16_t*)&SubWay2[135] = source->GetUDP_ID(); source->IncreaseUDP_ID(); - *(u16*)&SubWay2[153] = source->GetUDP_ID(); + *(uint16_t*)&SubWay2[153] = source->GetUDP_ID(); - *(u16*)&SubWay[1] = source->GetUDP_ID(); - *(u16*)&SubWay[3] = source->GetSessionID(); + *(uint16_t*)&SubWay[1] = source->GetUDP_ID(); + *(uint16_t*)&SubWay[3] = source->GetSessionID(); PMessage* msg; msg = new PMessage(197); @@ -471,8 +455,8 @@ Console->Print("---- Not Working 1 ----"); msg->Dump(); source->SendUDPMessage(msg); - *(u16*)&SubWay2[1] = source->GetUDP_ID(); - *(u16*)&SubWay2[3] = source->GetSessionID(); + *(uint16_t*)&SubWay2[1] = source->GetUDP_ID(); + *(uint16_t*)&SubWay2[3] = source->GetSessionID(); msg = new PMessage(197); msg->Write(SubWay2, sizeof(SubWay2)); diff --git a/server/src/game/gamecommands/takemoney.cpp b/TinNS/Source/GameServer/GameCommands/TakeMoney.cxx similarity index 65% rename from server/src/game/gamecommands/takemoney.cpp rename to TinNS/Source/GameServer/GameCommands/TakeMoney.cxx index 771d2c7..0cd7968 100644 --- a/server/src/game/gamecommands/takemoney.cpp +++ b/TinNS/Source/GameServer/GameCommands/TakeMoney.cxx @@ -1,28 +1,8 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" +#include "GameServer/Includes.hxx" void PCommands::doCmdtakemoney() { - u32 cashtodel = 0; + uint32_t cashtodel = 0; bool SyntaxError = false; if(ArgC < 1) { @@ -35,7 +15,7 @@ void PCommands::doCmdtakemoney() } else { - cashtodel = (u32)GetArgInt(1); + cashtodel = (uint32_t)GetArgInt(1); } if(cashtodel == 0) return; @@ -72,13 +52,13 @@ void PCommands::doCmdtakemoney() return; } - u32 newcashvalue = 0; - u32 oldcashval = target->GetChar()->GetCash(); + uint32_t newcashvalue = 0; + uint32_t oldcashval = target->GetChar()->GetCash(); if(oldcashval >= cashtodel) newcashvalue = target->GetChar()->SetCash(oldcashval - cashtodel); - u32 diffcash = newcashvalue + oldcashval; + uint32_t diffcash = newcashvalue + oldcashval; PMessage* tmpMsg_cash = MsgBuilder->BuildCharMoneyUpdateMsg(target, newcashvalue); target->SendUDPMessage(tmpMsg_cash); @@ -91,8 +71,8 @@ void PCommands::doCmdtakemoney() } else { - u32 newcashvalue = 0; - u32 oldcashval = source->GetChar()->GetCash(); + uint32_t newcashvalue = 0; + uint32_t oldcashval = source->GetChar()->GetCash(); if(oldcashval >= cashtodel) newcashvalue = source->GetChar()->SetCash(oldcashval - cashtodel); diff --git a/server/src/game/gamecommands/teleport.cpp b/TinNS/Source/GameServer/GameCommands/Teleport.cxx similarity index 72% rename from server/src/game/gamecommands/teleport.cpp rename to TinNS/Source/GameServer/GameCommands/Teleport.cxx index 3320f00..7e3eb64 100644 --- a/server/src/game/gamecommands/teleport.cpp +++ b/TinNS/Source/GameServer/GameCommands/Teleport.cxx @@ -1,24 +1,5 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" void PCommands::doCmdteleport() { diff --git a/server/src/game/gamecommands/test.cpp b/TinNS/Source/GameServer/GameCommands/Test.cxx similarity index 57% rename from server/src/game/gamecommands/test.cpp rename to TinNS/Source/GameServer/GameCommands/Test.cxx index ec04531..beaf4fe 100644 --- a/server/src/game/gamecommands/test.cpp +++ b/TinNS/Source/GameServer/GameCommands/Test.cxx @@ -1,24 +1,5 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" +#include "GameServer/Includes.hxx" +#include "GameServer/Definitions/Includes.hxx" void PCommands::doCmdtest() { @@ -35,8 +16,8 @@ void PCommands::doCmdtest() targetNPC = currentNPCWorld->GetNPC( GetArgInt(2) ); if(!targetNPC) return; - // @test 15 - targetNPC->Attack(GetArgInt(3), (u8)GetArgInt(5), (u8)GetArgInt(4)); + // @test 15 + targetNPC->Attack(GetArgInt(3), (uint8_t)GetArgInt(5), (uint8_t)GetArgInt(4)); } } else if (GetArgInt(1) == 2) @@ -82,13 +63,13 @@ void PCommands::doCmdtest() /* - u8 val1 = 0; - u8 val2 = 0; - u8 val3 = 0; - u16 val4 = 0; - u16 val5 = 0; - // u16 val6 = 0; - // u8 val7 = 0; + uint8_t val1 = 0; + uint8_t val2 = 0; + uint8_t val3 = 0; + uint16_t val4 = 0; + uint16_t val5 = 0; + // uint16_t val6 = 0; + // uint8_t val7 = 0; bool SyntaxError = false; if(ArgC < 5) @@ -115,57 +96,57 @@ void PCommands::doCmdtest() { PMessage* tmpMsg1 = new PMessage(14); - *tmpMsg1 << (u8)0x13; - *tmpMsg1 << (u16)0x0000; // UDP ID placeholder - *tmpMsg1 << (u16)0x0000; // SessionID placeholder - *tmpMsg1 << (u8)0x08; // Len (static, always 0x08 - *tmpMsg1 << (u8)0x03; - *tmpMsg1 << (u16)0x0000; // Sub UDP ID placeholder - *tmpMsg1 << (u8)0x26; // Command FADE AWAY CHAR (kinda ^^) - *tmpMsg1 << (u8)0x00; - *tmpMsg1 << (u8)0x10; - *tmpMsg1 << (u8)0x00; - *tmpMsg1 << (u8)0x80; + *tmpMsg1 << (uint8_t)0x13; + *tmpMsg1 << (uint16_t)0x0000; // UDP ID placeholder + *tmpMsg1 << (uint16_t)0x0000; // SessionID placeholder + *tmpMsg1 << (uint8_t)0x08; // Len (static, always 0x08 + *tmpMsg1 << (uint8_t)0x03; + *tmpMsg1 << (uint16_t)0x0000; // Sub UDP ID placeholder + *tmpMsg1 << (uint8_t)0x26; // Command FADE AWAY CHAR (kinda ^^) + *tmpMsg1 << (uint8_t)0x00; + *tmpMsg1 << (uint8_t)0x10; + *tmpMsg1 << (uint8_t)0x00; + *tmpMsg1 << (uint8_t)0x80; ClientManager->UDPBroadcast(tmpMsg1, source); } - val1 = (u8)GetArgInt(1); - val2 = (u8)GetArgInt(2); - val3 = (u8)GetArgInt(3); - val4 = (u16)GetArgInt(4); - val5 = (u16)GetArgInt(5); - // val7 = (u16)GetArgInt(7); + val1 = (uint8_t)GetArgInt(1); + val2 = (uint8_t)GetArgInt(2); + val3 = (uint8_t)GetArgInt(3); + val4 = (uint16_t)GetArgInt(4); + val5 = (uint16_t)GetArgInt(5); + // val7 = (uint16_t)GetArgInt(7); //tmpMsg = MsgBuilder->BuildCharUseQBSlotMsg1(source, 59); //source->SendUDPMessage(tmpMsg); //tmpMsg = NULL; PMessage* tmpMsg = new PMessage(29); - *tmpMsg << (u8)0x13; - *tmpMsg << (u16)0x0000; - *tmpMsg << (u16)0x0000; - *tmpMsg << (u8)0x16; // Message length - *tmpMsg << (u8)0x03; - *tmpMsg << (u16)0x0000; - *tmpMsg << (u8)0x1b; - *tmpMsg << (u8)0x00; - *tmpMsg << (u8)0x10; - *tmpMsg << (u8)0x00; - *tmpMsg << (u8)0x80; - *tmpMsg << (u8)0x19; - *tmpMsg << (u8)0x55; - *tmpMsg << (u8)0x74; - *tmpMsg << (u8)0x80; - *tmpMsg << (u8)0x82; - *tmpMsg << (u8)0xc2; - *tmpMsg << (u8)0x84; - *tmpMsg << (u8)val1; - *tmpMsg << (u8)val2; - *tmpMsg << (u8)val3; - *tmpMsg << (u16)val4; - *tmpMsg << (u16)val5; - // *tmpMsg << (u8)0x69; - // *tmpMsg << (u8)0x00; + *tmpMsg << (uint8_t)0x13; + *tmpMsg << (uint16_t)0x0000; + *tmpMsg << (uint16_t)0x0000; + *tmpMsg << (uint8_t)0x16; // Message length + *tmpMsg << (uint8_t)0x03; + *tmpMsg << (uint16_t)0x0000; + *tmpMsg << (uint8_t)0x1b; + *tmpMsg << (uint8_t)0x00; + *tmpMsg << (uint8_t)0x10; + *tmpMsg << (uint8_t)0x00; + *tmpMsg << (uint8_t)0x80; + *tmpMsg << (uint8_t)0x19; + *tmpMsg << (uint8_t)0x55; + *tmpMsg << (uint8_t)0x74; + *tmpMsg << (uint8_t)0x80; + *tmpMsg << (uint8_t)0x82; + *tmpMsg << (uint8_t)0xc2; + *tmpMsg << (uint8_t)0x84; + *tmpMsg << (uint8_t)val1; + *tmpMsg << (uint8_t)val2; + *tmpMsg << (uint8_t)val3; + *tmpMsg << (uint16_t)val4; + *tmpMsg << (uint16_t)val5; + // *tmpMsg << (uint8_t)0x69; + // *tmpMsg << (uint8_t)0x00; ClientManager->UDPBroadcast(tmpMsg, source); @@ -185,11 +166,11 @@ void PCommands::doCmdtest() return; } - u16 itemID; + uint16_t itemID; char effStr[128]; PMessage* tmpMsg; - itemID = (u16)GetArgInt(1); + itemID = (uint16_t)GetArgInt(1); source->GetChar()->SetItemInHand(itemID); @@ -199,9 +180,9 @@ void PCommands::doCmdtest() effStr[127] = '\0'; Chat->send(source, CHAT_DIRECT, "System", effStr); =========================================================================== - u16 ItemToSpawn = 0; - u8 Quality = 0; - u8 Stack = 0; + uint16_t ItemToSpawn = 0; + uint8_t Quality = 0; + uint8_t Stack = 0; bool SyntaxError = false; if(ArgC < 3) @@ -212,7 +193,7 @@ void PCommands::doCmdtest() { if(IsArgNumeric(1) == true) { - ItemToSpawn = (u16)GetArgInt(1); + ItemToSpawn = (uint16_t)GetArgInt(1); if(ItemToSpawn == 0) { SyntaxError = true; @@ -225,7 +206,7 @@ void PCommands::doCmdtest() if(IsArgNumeric(2) == true) { - Quality = (u8)GetArgInt(2); + Quality = (uint8_t)GetArgInt(2); if(Quality == 0) { SyntaxError = true; @@ -238,7 +219,7 @@ void PCommands::doCmdtest() if(IsArgNumeric(3) == true) { - Stack = (u8)GetArgInt(3); + Stack = (uint8_t)GetArgInt(3); if(Stack == 0) { SyntaxError = true; @@ -258,26 +239,26 @@ void PCommands::doCmdtest() source->IncreaseUDP_ID(); source->IncreaseTransactionID(); - *tmpMsg << (u8)0x13; - *tmpMsg << (u16)source->GetUDP_ID(); - *tmpMsg << (u16)source->GetSessionID(); - *tmpMsg << (u8)0x16; // Message length - *tmpMsg << (u8)0x03; - *tmpMsg << (u16)source->GetUDP_ID(); - *tmpMsg << (u8)0x1f; - *tmpMsg << (u16)source->GetLocalID(); - *tmpMsg << (u8)0x25; // ?? - *tmpMsg << (u8)0x13; // ?? - *tmpMsg << (u16)source->GetTransactionID(); - *tmpMsg << (u8)0x18; // ?? - *tmpMsg << (u8)0x03; // ?? - *tmpMsg << (u8)0x01; // ?? - *tmpMsg << (u8)0x00; // ?? - *tmpMsg << (u8)0x05; // ?? - *tmpMsg << (u8)0x00; // ?? + *tmpMsg << (uint8_t)0x13; + *tmpMsg << (uint16_t)source->GetUDP_ID(); + *tmpMsg << (uint16_t)source->GetSessionID(); + *tmpMsg << (uint8_t)0x16; // Message length + *tmpMsg << (uint8_t)0x03; + *tmpMsg << (uint16_t)source->GetUDP_ID(); + *tmpMsg << (uint8_t)0x1f; + *tmpMsg << (uint16_t)source->GetLocalID(); + *tmpMsg << (uint8_t)0x25; // ?? + *tmpMsg << (uint8_t)0x13; // ?? + *tmpMsg << (uint16_t)source->GetTransactionID(); + *tmpMsg << (uint8_t)0x18; // ?? + *tmpMsg << (uint8_t)0x03; // ?? + *tmpMsg << (uint8_t)0x01; // ?? + *tmpMsg << (uint8_t)0x00; // ?? + *tmpMsg << (uint8_t)0x05; // ?? + *tmpMsg << (uint8_t)0x00; // ?? *tmpMsg << ItemToSpawn; - *tmpMsg << (u8)0x02; // ?? - *tmpMsg << (u8)0x01; // ?? + *tmpMsg << (uint8_t)0x02; // ?? + *tmpMsg << (uint8_t)0x01; // ?? *tmpMsg << Quality; *tmpMsg << Stack; diff --git a/TinNS/Source/GameServer/GameCommands/UnBan.cxx b/TinNS/Source/GameServer/GameCommands/UnBan.cxx new file mode 100644 index 0000000..4b83971 --- /dev/null +++ b/TinNS/Source/GameServer/GameCommands/UnBan.cxx @@ -0,0 +1,6 @@ +#include "GameServer/Includes.hxx" + +void PCommands::doCmdunban() +{ + Chat->send(source, CHAT_DIRECT, "System", "Unban is not yet possible, sorry."); +} diff --git a/server/src/game/gamecommands/unjail.cpp b/TinNS/Source/GameServer/GameCommands/UnJail.cxx similarity index 68% rename from server/src/game/gamecommands/unjail.cpp rename to TinNS/Source/GameServer/GameCommands/UnJail.cxx index 86b5b04..18e4c95 100644 --- a/server/src/game/gamecommands/unjail.cpp +++ b/TinNS/Source/GameServer/GameCommands/UnJail.cxx @@ -1,24 +1,5 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" void PCommands::doCmdunjail() { @@ -60,7 +41,7 @@ void PCommands::doCmdunjail() return; } - u32 currLoc = target->GetChar()->GetLocation(); + uint32_t currLoc = target->GetChar()->GetLocation(); // Make sure that target player is really in Regants if ( currLoc != 550 && currLoc != 551 ) { diff --git a/server/src/game/gamecommands/unshun.cpp b/TinNS/Source/GameServer/GameCommands/UnShun.cxx similarity index 61% rename from server/src/game/gamecommands/unshun.cpp rename to TinNS/Source/GameServer/GameCommands/UnShun.cxx index a397541..1754aeb 100644 --- a/server/src/game/gamecommands/unshun.cpp +++ b/TinNS/Source/GameServer/GameCommands/UnShun.cxx @@ -1,24 +1,4 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" +#include "GameServer/Includes.hxx" void PCommands::doCmdunshun() { diff --git a/server/src/game/gamecommands/uptime.cpp b/TinNS/Source/GameServer/GameCommands/Uptime.cxx similarity index 72% rename from server/src/game/gamecommands/uptime.cpp rename to TinNS/Source/GameServer/GameCommands/Uptime.cxx index f3a2dbb..281e369 100644 --- a/server/src/game/gamecommands/uptime.cpp +++ b/TinNS/Source/GameServer/GameCommands/Uptime.cxx @@ -1,31 +1,11 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" +#include "GameServer/Includes.hxx" void PCommands::doCmduptime() { // get difference between var uptime and current time - std::time_t Uptime = GameServer->GetStartTime(); - u32 TimeDiff = std::time(NULL) - Uptime; - u32 UpYears = 0, UpMonths = 0, UpWeeks = 0, UpDays = 0, UpHours = 0, UpMinutes = 0, UpSeconds = 0; + time_t Uptime = GameServer->GetStartTime(); + uint32_t TimeDiff = std::time(NULL) - Uptime; + uint32_t UpYears = 0, UpMonths = 0, UpWeeks = 0, UpDays = 0, UpHours = 0, UpMinutes = 0, UpSeconds = 0; char tmpY[21], tmpM[21], tmpW[21], tmpD[21], tmpH[21], tmpMi[21], tmpS[21]; // 1 min = 60 sec = 60 diff --git a/TinNS/Source/GameServer/GameCommands/V.cxx b/TinNS/Source/GameServer/GameCommands/V.cxx new file mode 100644 index 0000000..4eea77b --- /dev/null +++ b/TinNS/Source/GameServer/GameCommands/V.cxx @@ -0,0 +1,46 @@ +#include "GameServer/Includes.hxx" + +void PCommands::doCmd_dev_v() +{ + if(IsAdmin() == false) + return; + + char Arg1[30]; + + Arg1[0] = '\0'; + + if(ArgC > 0) + { + GetArgText(1, Arg1, 30); + } + + char tmpStr[128]; + int testmode = 1; // change here only for uint8_t/uint16_t/uint32_t testvalue use + + if(Arg1[0] != '\0') + { + switch(testmode) + { + case 0: source->testval8 = (uint8_t)(atoi(Arg1) & 0xff); break; + case 1: source->testval16 = (uint16_t)(atoi(Arg1) & 0xffff); break; + case 2: source->testval32 = (uint32_t)(atoi(Arg1) & 0xffffffff); break; + } + } + else + { + source->testval8 = 0; + source->testval16 = 0; + source->testval32 = 0; + } + + switch(testmode) + { + case 0: snprintf(tmpStr, 127, "Test value uint8_t set to 0x%02x (%d)", source->testval8, source->testval8); break; + case 1: snprintf(tmpStr, 127, "Test value uint16_t set to 0x%04x (%d)", source->testval16, source->testval16); break; + case 2: snprintf(tmpStr, 127, "Test value uint32_t set to 0x%08x (%d)", source->testval32, source->testval32); break; + default: tmpStr[0] = '\0'; + } + tmpStr[127] = '\0'; + Chat->send(source, CHAT_DIRECT, "System", tmpStr); + +} diff --git a/TinNS/Source/GameServer/GameCommands/Version.cxx b/TinNS/Source/GameServer/GameCommands/Version.cxx new file mode 100644 index 0000000..c694545 --- /dev/null +++ b/TinNS/Source/GameServer/GameCommands/Version.cxx @@ -0,0 +1,11 @@ +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" + +void PCommands::doCmdversion() +{ + char tmpChatMsg[300]; + snprintf(tmpChatMsg, 299, "You are on TinNS server %s runnig version %s - SVN Rev. %s", Config->GetOption("server_name").c_str(), ServerVersion, SVNRevision); + tmpChatMsg[299] = '\0'; + + Chat->send(source, CHAT_DIRECT, "System", tmpChatMsg); +} diff --git a/server/src/game/gamecommands/warp.cpp b/TinNS/Source/GameServer/GameCommands/Warp.cxx similarity index 63% rename from server/src/game/gamecommands/warp.cpp rename to TinNS/Source/GameServer/GameCommands/Warp.cxx index edc0ef5..06086b1 100644 --- a/server/src/game/gamecommands/warp.cpp +++ b/TinNS/Source/GameServer/GameCommands/Warp.cxx @@ -1,24 +1,5 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" void PCommands::doCmdwarp() { diff --git a/server/src/game/gamecommands/warpto.cpp b/TinNS/Source/GameServer/GameCommands/WarpTo.cxx similarity index 69% rename from server/src/game/gamecommands/warpto.cpp rename to TinNS/Source/GameServer/GameCommands/WarpTo.cxx index a668124..cc3e864 100644 --- a/server/src/game/gamecommands/warpto.cpp +++ b/TinNS/Source/GameServer/GameCommands/WarpTo.cxx @@ -1,24 +1,5 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" void PCommands::doCmdwarpto() { diff --git a/server/src/game/gamecommands/weather.cpp b/TinNS/Source/GameServer/GameCommands/Weather.cxx similarity index 57% rename from server/src/game/gamecommands/weather.cpp rename to TinNS/Source/GameServer/GameCommands/Weather.cxx index 0aded50..9a4b675 100644 --- a/server/src/game/gamecommands/weather.cpp +++ b/TinNS/Source/GameServer/GameCommands/Weather.cxx @@ -1,24 +1,4 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" +#include "GameServer/Includes.hxx" void PCommands::doCmdweather() { @@ -54,7 +34,7 @@ void PCommands::doCmdweather() else target = source; - PMessage* tmpMsg = MsgBuilder->BuildWeatherControlMsg(( u16 )wId ); + PMessage* tmpMsg = MsgBuilder->BuildWeatherControlMsg(( uint16_t )wId ); ClientManager->UDPBroadcast( tmpMsg, target ); char effStr[128]; diff --git a/server/src/game/gamescript.cpp.inhib b/TinNS/Source/GameServer/GameScript.cxx similarity index 59% rename from server/src/game/gamescript.cpp.inhib rename to TinNS/Source/GameServer/GameScript.cxx index 96a056f..e16caa7 100644 --- a/server/src/game/gamescript.cpp.inhib +++ b/TinNS/Source/GameServer/GameScript.cxx @@ -1,34 +1,15 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -#include "main.h" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" +#if 0 PGameScript::PGameScript() { } PGameScript::~PGameScript() { - for(HookMap::iterator it = mHooks.begin(); it != mHooks.end(); it++) - delete it->second; + for(HookMap::iterator it = mHooks.begin(); it != mHooks.end(); it++) + delete it->second; } bool PGameScript::LoadScripts() @@ -38,7 +19,7 @@ bool PGameScript::LoadScripts() bool PGameScript::Rehash() { Console->LPrint("Rehashing GameMonkey Scripts..."); - for(HookMap::iterator it = mHooks.end(); it != mHooks.begin(); it--) + for(HookMap::iterator it = mHooks.end(); it != mHooks.begin(); it--) mHooks.erase(it); if(LoadScripts() == true) @@ -60,7 +41,7 @@ void PGameScript::TriggerHook(PHookTypes hook) } -bool ScriptSys::ExecuteFile(const char* a_fileName) +bool PGameScript::ExecuteFile(const char* a_fileName) { FILE* scriptFile = NULL; char* fileString = NULL; @@ -120,4 +101,5 @@ int PGameScript::AddTwoIntegers(int valueA, int valueB) } return resultInt; -} \ No newline at end of file +} +#endif diff --git a/TinNS/Source/GameServer/GameScript.hxx b/TinNS/Source/GameServer/GameScript.hxx new file mode 100644 index 0000000..7df8946 --- /dev/null +++ b/TinNS/Source/GameServer/GameScript.hxx @@ -0,0 +1,27 @@ +#pragma once + +#if 0 +#include +#include + +enum PHookTypes { + HOOK_CHAT, + HOOK_TRADE, + HOOK_ZONE +}; + +class PGameScript { +private: + typedef std::map HookMap; + HookMap mHooks; + +public: + PGameScript(); + ~PGameScript(); + + bool LoadScripts(); + bool Rehash(); + void TriggerHook(PHookTypes hook); + bool ExecuteFile(const char* a_fileName); +}; +#endif diff --git a/server/src/game/gameserver.cpp b/TinNS/Source/GameServer/GameServer.cxx similarity index 73% rename from server/src/game/gameserver.cpp rename to TinNS/Source/GameServer/GameServer.cxx index d83c47e..9fbc426 100644 --- a/server/src/game/gameserver.cpp +++ b/TinNS/Source/GameServer/GameServer.cxx @@ -1,99 +1,16 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - gameserver.cpp - main file of the gameserver - - MODIFIED: 31 Aug 2005 Akiko - REASON: - added modifications by "Sting" to get a running gameserver again - - added this header - MODIFIED: 28 Sep 2005 Akiko - REASON: - define for game server port - MODIFIED: 29 Sep 2005 Sting (modified by Akiko) - REASON: - configurable UDP port for testing - - tidied up/corrected packet sent with most character stats (character now has monk stats for testing) - MODIFIED: 27 Nov 2005 Akiko - REASON: - added Namikons fix (IPStringToDWord) - - added bluehrs packet fix - MODIFIED: 17 Dec 2005 bakkdoor - REASON: - Due the new structure for chatsystem, changed HandleGameChat(Client, Packet); - to Chat->HandleGameChat(Client, Packet); - - Also added ClientManager->addClientToList and ClientManager->deleteClientFromList() - (check Update() & FinalizeClient()) - MODIFIED: 18 Dec 2005 Namikon - REASON: - Fixed several small issues in the main-packet if-clause (sizeof(), etc) - MODIFIED: 21 Dec 2005 Namikon - REASON: - Fixed zoning (for now). The basic packet is broken somehow, still working on that - MODIFIED: 25 Dec 2005 Namikon - REASON: - Basepacket 1 and 2 fixed. (Thanks to MaxxJag!) - - Zoning still works, same goes for skills/factions. - - Not sure about quickbelt and inventory, but it seems to be ok - MODIFIED: 26 Dec 2005 Namikon - REASON: - Added doors - - Added support for Worlditem usage (Gogo/Genrep/Appitem/...) - MODIFIED: 01 Jan 2006 Namikon - REASON: - Changed FmtTxt() to sprintf(). It does... uhm, the same :D - - Added SetOnlineStatus to do instand updates when char is logging in - MODIFIED: 02 Jan 2006 Namikon - REASON: - Added debug output function - MODIFIED: 06 Jan 2006 Namikon - REASON: - Added color to console outputs - MODIFIED: 01 Jul 2006 hammag - REASON: - added set timeout to 10 msec (for ReadSetTCP select) in Start() to avoid useless 100% CPU use - MODIFIED: 30 Jul 2006 hammag - REASON: - Fixed 0x13 0x03 0x1F message filters to enable other char than ID 1 to play ... :P - MODIFIED: 12 Aug 2006 hammag - REASON: - Fixed BuildCharPosUpdateMsg() to send correct characters orientation to other characters - MODIFIED: 26 Aug 2006 hammag - REASON: - removed use of GAME_PORT define as this info is available in Config object with a default value - MODIFIED: 17 Sep 2006 hammag - REASON: - Moved all UDP message management code to decoder classes - - Removed corresponding code from gameserver.cpp & .h - MODIFIED: 03 Oct 2006 hammag - REASON: - Added some more DB cleanup when a char is deleted (still incomplete and will later be done in PChar::SQLDelete() ) - MODIFIED: 10 Dec 2006 Namikon - REASON: - Added new variable "mServerStartupTime". Holds the unix timestamp uppon startup. Required for @uptime - and other time-based stuff - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem - - clean ups - - TODO: - - Deny login if char is already online (More information about the login procedure is necessary to do that) - - Take main loop timeout setting from config file - - Add Regex control to new char name validation - - Add Check of Char offline (and unloaded) before deleting (from the char choosing i/f) if multiple login - allowed for the same account - - Check if adding to Client to Client manager shouldn't be done only one UDP connection done ? - => Risk of sending UDP chat on non-socket ???? -*/ - - -#include "main.h" - -#include "include/msgdecoder.h" -#include "include/msgbuilder.h" -#include "include/appartements.h" - +#include +#include "GameServer/Includes.hxx" +#include "GameServer/Decoder/Includes.hxx" +#include "Common/Includes.hxx" + +// TODO: +// - Deny login if char is already online (More information about the login procedure is necessary to do that) +// - Take main loop timeout setting from config file +// - Add Regex control to new char name validation +// - Add Check of Char offline (and unloaded) before deleting (from the char choosing i/f) if multiple login +// allowed for the same account +// - Check if adding to Client to Client manager shouldn't be done only one UDP connection done ? +// => Risk of sending UDP chat on non-socket ???? PGameServer::PGameServer() { @@ -110,7 +27,7 @@ PGameServer::~PGameServer() void PGameServer::Start() { - u16 Port = Config->GetOptionInt( "gameserver_port" ); + uint16_t Port = Config->GetOptionInt( "gameserver_port" ); Console->LPrint( "Starting gameserver on port %i...", Port ); if ( ServerSock->open( Port ) ) @@ -130,7 +47,7 @@ void PGameServer::Start() struct timespec tmpTime; if ( !clock_gettime( CLOCK_REALTIME, &tmpTime ) ) { - srandom(( u32 )tmpTime.tv_sec ); + srandom(( uint32_t )tmpTime.tv_sec ); InitRandom( tmpTime.tv_sec ); //Console->Print("Initializing random generator. First value is %d", random()); } @@ -142,7 +59,7 @@ void PGameServer::Start() } -void PGameServer::SetGameTime( u32 newtime ) +void PGameServer::SetGameTime( uint32_t newtime ) { if ( clock_gettime( CLOCK_REALTIME, &mStartTime ) ) { @@ -154,11 +71,11 @@ void PGameServer::SetGameTime( u32 newtime ) mBaseGameTime = newtime; } -u32 PGameServer::GetGameTime() +uint32_t PGameServer::GetGameTime() { - //const u32 TimeFactor = 375; - const u32 TimeFactor = 1000; - const u32 nsTimeFactor = 1000000000 / TimeFactor; + //const uint32_t TimeFactor = 375; + const uint32_t TimeFactor = 1000; + const uint32_t nsTimeFactor = 1000000000 / TimeFactor; struct timespec tmpTime; @@ -224,16 +141,16 @@ void PGameServer::Update() } } -bool PGameServer::HandleHandshake( PGameState *State, const u8 *Packet, int PacketSize ) +bool PGameServer::HandleHandshake( PGameState *State, const uint8_t *Packet, int PacketSize ) { - //static const u8 HANDSHAKE1A[6]={0xfe, 0x03, 0x00, 0x80, 0x03, 0x68}; + //static const uint8_t HANDSHAKE1A[6]={0xfe, 0x03, 0x00, 0x80, 0x03, 0x68}; //PGameSocket *Socket = Client->GetGameSocket(); switch ( State->TCP.mState ) { case PGameState::TCP::GS_HANDSHAKE0 : { - if ( PacketSize == 6 && *( u16* )&Packet[3] == 0x0080 && Packet[5] == 0x78 ) + if ( PacketSize == 6 && *( uint16_t* )&Packet[3] == 0x0080 && Packet[5] == 0x78 ) { //FIXME: this packet seems to be unnecessary, // although it appears in traffic dumps @@ -244,7 +161,7 @@ bool PGameServer::HandleHandshake( PGameState *State, const u8 *Packet, int Pack } else { - Console->Print( YELLOW, BLACK, "[Notice] Gameserver protocol error (GS_HANDSHAKE0): invalid packet [%04x]", *( u16* )&Packet[3] ); + Console->Print( YELLOW, BLACK, "[Notice] Gameserver protocol error (GS_HANDSHAKE0): invalid packet [%04x]", *( uint16_t* )&Packet[3] ); return ( false ); } @@ -259,18 +176,18 @@ bool PGameServer::HandleHandshake( PGameState *State, const u8 *Packet, int Pack return true; } -bool PGameServer::HandleAuthenticate( PClient *Client, PGameState *State, const u8 *Packet, int PacketSize ) +bool PGameServer::HandleAuthenticate( PClient *Client, PGameState *State, const uint8_t *Packet, int PacketSize ) { ConnectionTCP *Socket = Client->getTCPConn(); - if ( PacketSize > 20 && *( u16* )&Packet[3] == 0x8084 ) + if ( PacketSize > 20 && *( uint16_t* )&Packet[3] == 0x8084 ) { // authentication method #1 - const u8 *Key = &Packet[5]; // password key - u16 ULen = *( u16* ) & Packet[16]; // username length - u16 PLen = *( u16* ) & Packet[18]; // password length + const uint8_t *Key = &Packet[5]; // password key + uint16_t ULen = *( uint16_t* ) & Packet[16]; // username length + uint16_t PLen = *( uint16_t* ) & Packet[18]; // password length char *UserName = ( char* ) & Packet[20]; // account name - const u8 *PW = &Packet[20+ULen]; // encoded password + const uint8_t *PW = &Packet[20+ULen]; // encoded password // Safety controls if ( 15 + ULen + PLen > PacketSize ) @@ -321,7 +238,7 @@ bool PGameServer::HandleAuthenticate( PClient *Client, PGameState *State, const if ( Failed ) { // TODO: is this packet correct here? - u8 AUTHFAILED[15] = {0xfe, 0x0c, 0x00, 0x83, 0x86, 0x05, 0x00, 0x06, 0x00, 'E', 'R', + uint8_t AUTHFAILED[15] = {0xfe, 0x0c, 0x00, 0x83, 0x86, 0x05, 0x00, 0x06, 0x00, 'E', 'R', 'R', 'O', 'R', 0 }; // TODO: send actual reason instead of ERROR @@ -333,24 +250,24 @@ bool PGameServer::HandleAuthenticate( PClient *Client, PGameState *State, const else { Client->LoggedIn( &Account ); - u8 AUTHOK[28] = {0xfe, 0x19, 0x00, 0x83, 0x81, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, + uint8_t AUTHOK[28] = {0xfe, 0x19, 0x00, 0x83, 0x81, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - *( u32* )&AUTHOK[5] = Account.GetID(); + *( uint32_t* )&AUTHOK[5] = Account.GetID(); Socket->write( AUTHOK, 28 ); State->TCP.mState = PGameState::TCP::GS_GAMEDATA; Console->Print( GREEN, BLACK, "[Info] Gameserver: User '%s' logged in", UserName ); } } - else if ( PacketSize > 29 && *( u16* )&Packet[3] == 0x0183 ) + else if ( PacketSize > 29 && *( uint16_t* )&Packet[3] == 0x0183 ) { // authentication method #2, sent when game starts - const u8 *Key = &Packet[13]; // password key - u16 PLen = *( u16* ) & Packet[25]; // password length - u16 ULen = *( u16* ) & Packet[27]; // username length + const uint8_t *Key = &Packet[13]; // password key + uint16_t PLen = *( uint16_t* ) & Packet[25]; // password length + uint16_t ULen = *( uint16_t* ) & Packet[27]; // username length char *UserName = ( char* ) & Packet[29]; // account name - const u8 *PW = &Packet[29+ULen]; // encoded password + const uint8_t *PW = &Packet[29+ULen]; // encoded password // Safety controls if ( 24 + ULen + PLen > PacketSize ) @@ -415,8 +332,8 @@ bool PGameServer::HandleAuthenticate( PClient *Client, PGameState *State, const if ( !Failed ) { - int value = *( u32* ) & Packet[21];//i think here we must read u32 instead of u8 - u32 CharID = Account.GetCharIdBySlot( value ); + int value = *( uint32_t* ) & Packet[21];//i think here we must read uint32_t instead of uint8_t + uint32_t CharID = Account.GetCharIdBySlot( value ); if ( Chars->LoadChar( CharID ) ) { @@ -433,46 +350,46 @@ bool PGameServer::HandleAuthenticate( PClient *Client, PGameState *State, const else { Client->LoggedIn( &Account ); - /*u8 AUTHOK[28]={0xfe, 0x19, 0x00, 0x83, 0x81, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, + /*uint8_t AUTHOK[28]={0xfe, 0x19, 0x00, 0x83, 0x81, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - *(u32*)&AUTHOK[5]=Account->GetID(); + *(uint32_t*)&AUTHOK[5]=Account->GetID(); Socket->Write(AUTHOK, 28);*/ - //Client->SetRemoteUDPAddr(*(u32*)&Packet[5], *(u16*)&Packet[9]); + //Client->SetRemoteUDPAddr(*(uint32_t*)&Packet[5], *(uint16_t*)&Packet[9]); State->TCP.mState = PGameState::TCP::GS_GETSTATUS; - Console->Print( "Gameserver: User '%s' entered game (%08x:%04x)", UserName, *( u32* )&Packet[5], *( u16* )&Packet[9] ); + Console->Print( "Gameserver: User '%s' entered game (%08x:%04x)", UserName, *( uint32_t* )&Packet[5], *( uint16_t* )&Packet[9] ); Client->SetRemoteUDPPort( *( int* )&Packet[9] ); } } else { - Console->Print( RED, BLACK, "[Notice] Gameserver protocol error (GS_AUTHENTICATE): invalid packet [%04x]", *( u16* )&Packet[3] ); + Console->Print( RED, BLACK, "[Notice] Gameserver protocol error (GS_AUTHENTICATE): invalid packet [%04x]", *( uint16_t* )&Packet[3] ); return ( false ); } return ( true ); } -bool PGameServer::HandleGameData( PClient *Client, PGameState *State, const u8 *Packet ) +bool PGameServer::HandleGameData( PClient *Client, PGameState *State, const uint8_t *Packet ) { - static const u8 GAMEDATA[5] = {0xfe, 0x02, 0x00, 0x87, 0x3a}; + static const uint8_t GAMEDATA[5] = {0xfe, 0x02, 0x00, 0x87, 0x3a}; ConnectionTCP *Socket = Client->getTCPConn(); - if ( *( u16* )&Packet[3] == 0x3787 ) + if ( *( uint16_t* )&Packet[3] == 0x3787 ) { Socket->write( GAMEDATA, 5 ); State->TCP.mState = PGameState::TCP::GS_REQUESTCHARS; } else { - Console->Print( RED, BLACK, "[Notice] Gameserver protocol error (GS_GAMEDATA): invalid packet [%04x]", *( u16* )&Packet[3] ); + Console->Print( RED, BLACK, "[Notice] Gameserver protocol error (GS_GAMEDATA): invalid packet [%04x]", *( uint16_t* )&Packet[3] ); return ( false ); } return ( true ); } -bool PGameServer::HandleRequestChars( PClient *Client, PGameState *State, const u8 *Packet ) +bool PGameServer::HandleRequestChars( PClient *Client, PGameState *State, const uint8_t *Packet ) { PAccount Account( Client->GetAccountID() ); @@ -483,16 +400,16 @@ bool PGameServer::HandleRequestChars( PClient *Client, PGameState *State, const struct PCharList { - u16 Unknown1; - u16 NumSlots; - u16 Unknown2; + uint16_t Unknown1; + uint16_t NumSlots; + uint16_t Unknown2; } CharList; PCharProfile CharEntry[MAX_CHARS_PER_ACCOUNT]; const int CHARBASESIZE = 28; - if ( *( u16* )&Packet[3] == 0x8284 ) + if ( *( uint16_t* )&Packet[3] == 0x8284 ) { CharList.NumSlots = MAX_CHARS_PER_ACCOUNT; int NameLengths = 0; @@ -536,8 +453,8 @@ bool PGameServer::HandleRequestChars( PClient *Client, PGameState *State, const } } - u8 PacketHeader[5] = {0xfe, 0x00, 0x00, 0x83, 0x85}; - *( u16* )&PacketHeader[1] = sizeof( u16 ) * 3 + ( MAX_CHARS_PER_ACCOUNT * CHARBASESIZE ) + NameLengths + 2; + uint8_t PacketHeader[5] = {0xfe, 0x00, 0x00, 0x83, 0x85}; + *( uint16_t* )&PacketHeader[1] = sizeof( uint16_t ) * 3 + ( MAX_CHARS_PER_ACCOUNT * CHARBASESIZE ) + NameLengths + 2; Socket->write( PacketHeader, 5 ); CharList.Unknown1 = 0x0000; @@ -571,7 +488,7 @@ bool PGameServer::HandleRequestChars( PClient *Client, PGameState *State, const if ( CharEntry[i].Name.length() > 0 ) { Socket->write( CharEntry[i].Name.c_str() ); - Socket->write(( u8 )0 ); + Socket->write(( uint8_t )0 ); } } @@ -579,21 +496,21 @@ bool PGameServer::HandleRequestChars( PClient *Client, PGameState *State, const } else { - Console->Print( RED, BLACK, "Gameserver protocol error (GS_REQUESTCHARS): invalid packet [%04x]", *( u16* )&Packet[3] ); + Console->Print( RED, BLACK, "Gameserver protocol error (GS_REQUESTCHARS): invalid packet [%04x]", *( uint16_t* )&Packet[3] ); return ( false ); } return ( true ); } -bool PGameServer::HandleCharList( PClient *Client, PGameState *State, const u8 *Packet, int PacketSize ) +bool PGameServer::HandleCharList( PClient *Client, PGameState *State, const uint8_t *Packet, int PacketSize ) { - static u8 Answer[10] = {0xfe, 0x07, 0x00, 0x83, 0x86, 0, 0, 0, 0, 0}; + static uint8_t Answer[10] = {0xfe, 0x07, 0x00, 0x83, 0x86, 0, 0, 0, 0, 0}; ConnectionTCP *Socket = Client->getTCPConn(); - if ( PacketSize > 9 && *( u16* )&Packet[3] == 0x8284 ) + if ( PacketSize > 9 && *( uint16_t* )&Packet[3] == 0x8284 ) { - u8 Mode = Packet[9]; + uint8_t Mode = Packet[9]; switch ( Mode ) { @@ -642,11 +559,11 @@ bool PGameServer::HandleCharList( PClient *Client, PGameState *State, const u8 * case 3: // delete char { PAccount Acc( Client->GetAccountID() ); - u8 Num = Packet[PacketSize-1]; + uint8_t Num = Packet[PacketSize-1]; if ( Acc.GetID() ) { - u32 CharID = Acc.GetCharIdBySlot( Num ); + uint32_t CharID = Acc.GetCharIdBySlot( Num ); // Also check that char is out of game if (( CharID != 0 ) && ( Chars->GetChar( CharID ) == NULL ) ) @@ -685,16 +602,16 @@ bool PGameServer::HandleCharList( PClient *Client, PGameState *State, const u8 * if ( PacketSize < 64 ) return ( false ); - u32 Slot = * ( u32* ) & Packet[30]; - //u32 nClass =* (u32*)&Packet[34]; // Not used - indirectly redundant with Profession - u32 Profession = * ( u32* ) & Packet[38]; - u32 Gender = * ( u32* ) & Packet[42]; - u32 Head = * ( u32* ) & Packet[46]; - u32 Torso = * ( u32* ) & Packet[50]; - u32 Legs = * ( u32* ) & Packet[54]; - u32 Faction = * ( u32* ) & Packet[58]; - u8 NameLen = Packet[62]; - u8 NZSNb = Packet[63]; + uint32_t Slot = * ( uint32_t* ) & Packet[30]; + //uint32_t nClass =* (uint32_t*)&Packet[34]; // Not used - indirectly redundant with Profession + uint32_t Profession = * ( uint32_t* ) & Packet[38]; + uint32_t Gender = * ( uint32_t* ) & Packet[42]; + uint32_t Head = * ( uint32_t* ) & Packet[46]; + uint32_t Torso = * ( uint32_t* ) & Packet[50]; + uint32_t Legs = * ( uint32_t* ) & Packet[54]; + uint32_t Faction = * ( uint32_t* ) & Packet[58]; + uint8_t NameLen = Packet[62]; + uint8_t NZSNb = Packet[63]; char TempName[256]; std::strncpy( TempName, ( const char* )&Packet[64], NameLen ); @@ -726,7 +643,7 @@ bool PGameServer::HandleCharList( PClient *Client, PGameState *State, const u8 * } else { - Console->Print( RED, BLACK, "[Notice] Gameserver protocol error (GS_CHARLIST): invalid packet [%04x]", *( u16* )&Packet[3] ); + Console->Print( RED, BLACK, "[Notice] Gameserver protocol error (GS_CHARLIST): invalid packet [%04x]", *( uint16_t* )&Packet[3] ); return ( false ); } @@ -734,20 +651,20 @@ bool PGameServer::HandleCharList( PClient *Client, PGameState *State, const u8 * return true; } -bool PGameServer::HandleGetStatus( PClient *Client, PGameState *State, const u8 *Packet ) +bool PGameServer::HandleGetStatus( PClient *Client, PGameState *State, const uint8_t *Packet ) { ConnectionTCP *Socket = Client->getTCPConn(); - if ( *( u16* )&Packet[3] == 0x3787 ) + if ( *( uint16_t* )&Packet[3] == 0x3787 ) { - static const u8 STATUS[9] = {0xfe, 0x06, 0x00, 0x87, 0x3a, 0x11, 0x00, 0x00, 0x00}; + static const uint8_t STATUS[9] = {0xfe, 0x06, 0x00, 0x87, 0x3a, 0x11, 0x00, 0x00, 0x00}; Socket->write( STATUS, 9 ); State->TCP.mState = PGameState::TCP::GS_GAMEINFO; } else { - Console->Print( RED, BLACK, "[Notice] Gameserver protocol error (GS_GETSTATUS): invalid packet [%04x]", *( u16* )&Packet[3] ); + Console->Print( RED, BLACK, "[Notice] Gameserver protocol error (GS_GETSTATUS): invalid packet [%04x]", *( uint16_t* )&Packet[3] ); return ( false ); } @@ -755,11 +672,11 @@ bool PGameServer::HandleGetStatus( PClient *Client, PGameState *State, const u8 return ( true ); } -bool PGameServer::HandleGameInfo( PClient *Client, PGameState *State, const u8 *Packet ) +bool PGameServer::HandleGameInfo( PClient *Client, PGameState *State, const uint8_t *Packet ) { // Console->Print("Inside HandleGameInfo");//NEW added - static u8 GameInfo[31] = {0xfe, 0x1c, 0x00, 0x83, 0x05, // header + static uint8_t GameInfo[31] = {0xfe, 0x1c, 0x00, 0x83, 0x05, // header 0x00, 0x00, 0x00, 0x00, // account id 0x00, 0x00, 0x00, 0x00, // char id 0x00, 0x00, 0x00, 0x00, // udp ip @@ -771,7 +688,7 @@ bool PGameServer::HandleGameInfo( PClient *Client, PGameState *State, const u8 * ConnectionTCP *Socket = Client->getTCPConn(); - if ( *( u16* )&Packet[3] == 0x3c87 ) + if ( *( uint16_t* )&Packet[3] == 0x3c87 ) { //int PortFix = Config->GetOptionInt("debug_mode"); @@ -783,7 +700,7 @@ bool PGameServer::HandleGameInfo( PClient *Client, PGameState *State, const u8 * ClientDisconnected( Client ); } - u16 Port = Client->getUDPConn()->getPort(); + uint16_t Port = Client->getUDPConn()->getPort(); if ( Port == 0 ) Console->Print( RED, BLACK, "Client->OpenUDP() failed" ); @@ -795,7 +712,7 @@ bool PGameServer::HandleGameInfo( PClient *Client, PGameState *State, const u8 * Console->Print(YELLOW, BLACK, "UDP Port set to non-standard for debugging!"); }; */ - u32 IP; + uint32_t IP; std::string IPServerString; // use [server_nat_ip] for server if client is NOT on [no_nat_net] (and [no_nat_net]!=0) if ( strcmp( Config->GetOption( "no_nat_net" ).c_str(), "0" ) && strncmp( Client->GetAddress(), Config->GetOption( "no_nat_net" ).c_str(), strlen( Config->GetOption( "no_nat_net" ).c_str() ) ) ) @@ -811,18 +728,18 @@ bool PGameServer::HandleGameInfo( PClient *Client, PGameState *State, const u8 * if ( IP == 0 ) IP = 0x0100007f; //Console->Print("IP-2 %d", IP); - *( u32* )&GameInfo[13] = IP; - *( u16* )&GameInfo[17] = Port; + *( uint32_t* )&GameInfo[13] = IP; + *( uint16_t* )&GameInfo[17] = Port; Console->Print( GREEN, BLACK, "[Info] Using UDP %s:%d on server", IPServerString.c_str(), Port ); - *( u32* )&GameInfo[5] = Client->GetAccountID(); - *( u32* )&GameInfo[9] = Client->GetCharID(); + *( uint32_t* )&GameInfo[5] = Client->GetAccountID(); + *( uint32_t* )&GameInfo[9] = Client->GetCharID(); Console->Print( GREEN, BLACK, "[Info] Serving char id :%d", Client->GetCharID() ); Socket->write( GameInfo, 31 ); Socket->flushSendBuffer(); - static const u8 READY[7] = {0xfe, 0x04, 0x00, 0x83, 0x0d, 0x00, 0x00}; + static const uint8_t READY[7] = {0xfe, 0x04, 0x00, 0x83, 0x0d, 0x00, 0x00}; Socket->write( READY, 7 ); State->TCP.mState = PGameState::TCP::GS_INGAME; @@ -871,7 +788,7 @@ bool PGameServer::HandleGameInfo( PClient *Client, PGameState *State, const u8 * } else { - Console->Print( RED, BLACK, "[Notice] Gameserver protocol error (GS_GAMEINFO): invalid packet [%04x]", *( u16* )&Packet[3] ); + Console->Print( RED, BLACK, "[Notice] Gameserver protocol error (GS_GAMEINFO): invalid packet [%04x]", *( uint16_t* )&Packet[3] ); return ( false ); } @@ -932,7 +849,7 @@ bool PGameServer::HandleGame( PClient *Client, PGameState *State ) bool PGameServer::ProcessClient( PClient *Client, PGameState *State ) { - static const u8 HANDSHAKE0A[6] = {0xfe, 0x03, 0x00, 0x80, 0x01, 0x66}; + static const uint8_t HANDSHAKE0A[6] = {0xfe, 0x03, 0x00, 0x80, 0x01, 0x66}; if ( !State ) { @@ -961,7 +878,7 @@ bool PGameServer::ProcessClient( PClient *Client, PGameState *State ) else { int PacketSize = 0; - const u8 *Packet = Socket->read( &PacketSize ); + const uint8_t *Packet = Socket->read( &PacketSize ); if ( PacketSize > 0 ) { diff --git a/server/src/game/include/gameserver.h b/TinNS/Source/GameServer/GameServer.hxx similarity index 55% rename from server/src/game/include/gameserver.h rename to TinNS/Source/GameServer/GameServer.hxx index f45511b..177c1da 100644 --- a/server/src/game/include/gameserver.h +++ b/TinNS/Source/GameServer/GameServer.hxx @@ -1,39 +1,8 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko +#pragma once - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - gameserver.h - - Authors: - - v00d00 - - Akiko - - MODIFIED: 30 Nov 2005 Akiko - REASON: - added GPL -*/ - -#ifndef GAMESERVER_H -#define GAMESERVER_H +#include +#include +#include struct PGameState { @@ -68,9 +37,9 @@ struct PGameState } mState; bool mSynced; - u16 mServerPacketNum; - u16 mSequence; - //u16 mClientPacketNum; + uint16_t mServerPacketNum; + uint16_t mSequence; + //uint16_t mClientPacketNum; } UDP; PGameState() @@ -91,9 +60,9 @@ class PUdpMsgDecoder; class PGameServer { private : - std::time_t mServerStartupTime; + time_t mServerStartupTime; int mNumClients; - u32 mBaseGameTime; + uint32_t mBaseGameTime; struct timespec mStartTime; typedef std::map GameStateMap; @@ -105,22 +74,22 @@ class PGameServer void FinalizeClient( PClient *Client, PGameState *State ); void FinalizeClientDelayed( PClient *Client, PGameState *State ); -// bool HandleHandshake(PClient *Client, PGameState *State, const u8 *Packet, int PacketSize); - bool HandleHandshake( PGameState *State, const u8 *Packet, int PacketSize ); +// bool HandleHandshake(PClient *Client, PGameState *State, const uint8_t *Packet, int PacketSize); + bool HandleHandshake( PGameState *State, const uint8_t *Packet, int PacketSize ); - bool HandleAuthenticate( PClient *Client, PGameState *State, const u8 *Packet, int PacketSize ); -// bool HandleGameData(PClient *Client, PGameState *State, const u8 *Packet, int PacketSize); - bool HandleGameData( PClient *Client, PGameState *State, const u8 *Packet ); + bool HandleAuthenticate( PClient *Client, PGameState *State, const uint8_t *Packet, int PacketSize ); +// bool HandleGameData(PClient *Client, PGameState *State, const uint8_t *Packet, int PacketSize); + bool HandleGameData( PClient *Client, PGameState *State, const uint8_t *Packet ); -// bool HandleRequestChars(PClient *Client, PGameState *State, const u8 *Packet, int PacketSize); - bool HandleRequestChars( PClient *Client, PGameState *State, const u8 *Packet ); +// bool HandleRequestChars(PClient *Client, PGameState *State, const uint8_t *Packet, int PacketSize); + bool HandleRequestChars( PClient *Client, PGameState *State, const uint8_t *Packet ); - bool HandleCharList( PClient *Client, PGameState *State, const u8 *Packet, int PacketSize ); -// bool HandleGetStatus(PClient *Client, PGameState *State, const u8 *Packet, int PacketSize); - bool HandleGetStatus( PClient *Client, PGameState *State, const u8 *Packet ); + bool HandleCharList( PClient *Client, PGameState *State, const uint8_t *Packet, int PacketSize ); +// bool HandleGetStatus(PClient *Client, PGameState *State, const uint8_t *Packet, int PacketSize); + bool HandleGetStatus( PClient *Client, PGameState *State, const uint8_t *Packet ); -// bool HandleGameInfo(PClient *Client, PGameState *State, const u8 *Packet, int PacketSize); - bool HandleGameInfo( PClient *Client, PGameState *State, const u8 *Packet ); +// bool HandleGameInfo(PClient *Client, PGameState *State, const uint8_t *Packet, int PacketSize); + bool HandleGameInfo( PClient *Client, PGameState *State, const uint8_t *Packet ); bool HandleGame( PClient *Client, PGameState *State ); @@ -132,13 +101,10 @@ class PGameServer void Update(); void ClientDisconnected( PClient *Client ); void UDPStreamClosed( PClient *Client ); - void SetGameTime( u32 newtime ); - u32 GetGameTime(); + void SetGameTime( uint32_t newtime ); + uint32_t GetGameTime(); - inline std::time_t GetStartTime() const { return mServerStartupTime; }; + inline time_t GetStartTime() const { return mServerStartupTime; }; PGameState* GetClientState( PClient* nClient ); }; - -#endif - diff --git a/server/src/game/genreplist.cpp b/TinNS/Source/GameServer/GenrepList.cxx similarity index 70% rename from server/src/game/genreplist.cpp rename to TinNS/Source/GameServer/GenrepList.cxx index 956bb88..743d979 100644 --- a/server/src/game/genreplist.cpp +++ b/TinNS/Source/GameServer/GenrepList.cxx @@ -1,40 +1,8 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community +#include +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - genreplist.cpp - classe for character genrep list - - MODIFIED: 20 Sep 2006 Hammag - REASON: - creation - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem - - clean ups -*/ - -#include "main.h" - -#include "include/genreplist.h" - -PGenrepList::PGenrepList(u32 nOwnerCharID) +PGenrepList::PGenrepList(uint32_t nOwnerCharID) { mOwnerCharID = nOwnerCharID; mListMaxSize = mListSize = 0; @@ -47,7 +15,7 @@ PGenrepList::~PGenrepList() delete[] mGenrepList; } -bool PGenrepList::AddGenrep(u16 nWorldID, u16 nStationID) +bool PGenrepList::AddGenrep(uint16_t nWorldID, uint16_t nStationID) { char query[256]; @@ -76,10 +44,10 @@ bool PGenrepList::AddGenrep(u16 nWorldID, u16 nStationID) return false; } -/*bool PGenrepList::RemoveChar(u32 nBuddyCharID) +/*bool PGenrepList::RemoveChar(uint32_t nBuddyCharID) { char query[256]; - u8 rEntry, i; + uint8_t rEntry, i; if ((rEntry = FindEntry(nBuddyCharID)) < mListSize) { @@ -110,7 +78,7 @@ bool PGenrepList::SQLLoad() char query[256]; MYSQL_RES *result; MYSQL_ROW row; - u8 EntriesNum; + uint8_t EntriesNum; snprintf(query, 256, "SELECT * FROM genrep WHERE (g_charid='%u')", mOwnerCharID); result = MySQL->GameResQuery(query); @@ -139,9 +107,9 @@ bool PGenrepList::SQLLoad() return true; } -void PGenrepList::IncreaseMaxSize(u8 nNewMax) +void PGenrepList::IncreaseMaxSize(uint8_t nNewMax) { - u16 tmpSize; + uint16_t tmpSize; if (!nNewMax) { @@ -171,9 +139,9 @@ void PGenrepList::IncreaseMaxSize(u8 nNewMax) mGenrepList = tmpList; } -u8 PGenrepList::FindEntry(u16 nWorldID, u16 nStationID) +uint8_t PGenrepList::FindEntry(uint16_t nWorldID, uint16_t nStationID) { - u8 i = 255; + uint8_t i = 255; if (mGenrepList) { diff --git a/TinNS/Source/GameServer/GenrepList.hxx b/TinNS/Source/GameServer/GenrepList.hxx new file mode 100644 index 0000000..ea47372 --- /dev/null +++ b/TinNS/Source/GameServer/GenrepList.hxx @@ -0,0 +1,39 @@ +#pragma once + +#include + +#define GENREPLIST_ALLOC_SIZE 4 // atomicity of list entries allocation + +class PGenrepList { +private: + enum { // genrep DB Table fields + g_id = 0, + g_worldid, + g_stationid, + g_charid + }; + struct PGenrepEntry + { + uint16_t mWorldID; + uint16_t mStationID; + }; + + uint32_t mOwnerCharID; + uint8_t mListMaxSize; + uint8_t mListSize; + PGenrepEntry* mGenrepList; + + void IncreaseMaxSize(uint8_t nNewMax = 0); + uint8_t FindEntry(uint16_t nWorldID, uint16_t nStationID); + + public: + PGenrepList(uint32_t nOwnerCharID); + ~PGenrepList(); + bool AddGenrep(uint16_t nWorldID, uint16_t nStationID); + //bool RemoveChar(uint32_t nBuddyCharID); + inline uint8_t Count() { return mListSize; } + uint16_t GetListDataSize() { return (sizeof(PGenrepEntry) * mListSize); } + const void* GetListData() { return (const void*)mGenrepList; } + bool SQLLoad(); +// bool SQLSave(); +}; diff --git a/server/src/game/globals.cpp b/TinNS/Source/GameServer/Includes.cxx similarity index 70% rename from server/src/game/globals.cpp rename to TinNS/Source/GameServer/Includes.cxx index 4e28699..28f3f3d 100644 --- a/server/src/game/globals.cpp +++ b/TinNS/Source/GameServer/Includes.cxx @@ -1,70 +1,9 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - globals.cpp - - MODIFIED: 12 September 2005 Akiko - REASON: - exchanged Pretender strings by TinNS - MODIFIED: 16 Dec 2005 bakkdoor - REASON: - Added global ClientManager and Chat Interface - MODIFIED: 22 Dec 2005 Namikon - REASON: - Added GPL - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added MySQL Support - - Fixed ShutdownTinns (Wont cause segmentation fault anymore) - MODIFIED: 06 Jan 2006 Namikon - REASON: - Added color to console outputs - - Added shiny and colored copyright box :D - MODIFIED: 22 Jul 2006 Hammag - REASON: - Added Server NOT NULL check to avoid segfault when shuting down during startup - MODIFIED: 27 Aug 2006 Hammag - REASON: - Implemented shared Config class use and config template to load conf. - - Added gameserver configtemplate.h include, - - Added new required parameters to Config->LoadOptions() - MODIFIED: 02 Oct 2006 Hammag - REASON: - Added gDevDebug global flag to control development debug outputs (flagged messaged, - dump-flagged messes, dev console->print) - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for buildsystem - - clean ups - - TODO: - Get logfile name from config file -*/ - - -#include "main.h" - -#include "configtemplate.h" -#include "include/isc.h" - -#include "include/msgbuilder.h" -#include "include/worlds.h" -#include "include/appartements.h" -#include "include/npc.h" -#include "include/subway.h" -#include "include/terminal.h" - -#include "include/version.h" +#include +#include "GameServer/Includes.hxx" +#include "GameServer/Definitions/Includes.hxx" +#include "Common/Includes.hxx" +// TODO: - Get logfile name from config file const char ServerVersion[] = TINNS_GAME_VERSION; const char SVNRevision[] = TINNS_SVN_REVISION; @@ -161,7 +100,7 @@ bool InitTinNS() Worlds->LoadWorlds(); WorldActors = new PWorldActors(); - LuaEngine = new PLuaEngine(); + LuaEngine = new PLuaEngine(); NPCManager = new PNPCManager(); Appartements = new PAppartements; @@ -177,14 +116,14 @@ bool InitTinNS() Console->Print("%s Could not creat password_filter PCRE '%s'", Console->ColorText(RED, BLACK, "[Error]"), Config->GetOption("password_filter").c_str()); return false; } - + if (!PChar::SetCharnameRegexFilter(Config->GetOption("charname_filter").c_str())) { Console->Print("%s Could not creat charname_filter PCRE '%s'", Console->ColorText(RED, BLACK, "[Error]"), Config->GetOption("charname_filter").c_str()); return false; } Chars = new PChars(); - + ServerSock = new ServerSocket(); Server = new PServer(); GameServer = new PGameServer(); @@ -199,9 +138,9 @@ bool InitTinNS() ISC = new PISC(); Terminal = new PTerminal(); - Outposts = new POutpost(); + Outposts = new POutpost(); - MultiPartHandler = new PMultiPart(); + MultiPartHandler = new PMultiPart(); return true; } @@ -257,4 +196,3 @@ void Shutdown() exit(0); } - diff --git a/TinNS/Source/GameServer/Includes.hxx b/TinNS/Source/GameServer/Includes.hxx new file mode 100644 index 0000000..e35b5f2 --- /dev/null +++ b/TinNS/Source/GameServer/Includes.hxx @@ -0,0 +1,89 @@ +#pragma once + +#include "GameServer/Accounts.hxx" +#include "GameServer/Appartements.hxx" +#include "GameServer/BuddyList.hxx" +#include "GameServer/Chars.hxx" +#include "GameServer/Chat.hxx" +#include "GameServer/Client.hxx" +#include "GameServer/ClientManager.hxx" +#include "GameServer/Commands.hxx" +#include "GameServer/ConfigTemplate.hxx" +#include "GameServer/Container.hxx" +#include "GameServer/DoorTemplate.hxx" +#include "GameServer/FurnitureTemplate.hxx" +#include "GameServer/GameScript.hxx" +#include "GameServer/GameServer.hxx" +#include "GameServer/GenrepList.hxx" +#include "GameServer/Inventory.hxx" +#include "GameServer/Isc.hxx" +#include "GameServer/Item.hxx" +#include "GameServer/LuaEngine.hxx" +#include "GameServer/Main.hxx" +#include "GameServer/MessageBuilder.hxx" +#include "GameServer/MultiPart.hxx" +#include "GameServer/Npc.hxx" +#include "GameServer/NpcTemplate.hxx" +#include "GameServer/Outpost.hxx" +#include "GameServer/RemoteConsole.hxx" +#include "GameServer/Server.hxx" +#include "GameServer/Skill.hxx" +#include "GameServer/Sql.hxx" +#include "GameServer/Subway.hxx" +#include "GameServer/Terminal.hxx" +#include "GameServer/Vehicle.hxx" +#include "GameServer/VehicleAccessRequest.hxx" +#include "GameServer/WorldActors.hxx" +#include "GameServer/WorldDataTemplate.hxx" +#include "GameServer/Worlds.hxx" +#include "GameServer/Zoning.hxx" + +extern class PLuaEngine *LuaEngine; + +extern class ServerSocket *ServerSock; +extern class PConsole *Console; +//extern class PRConsole *RemoteConsole; +extern class PConfig *Config; +extern class PConfig *CmdAccess; + +extern class PGameDefs *GameDefs; +extern class PFileSystem *Filesystem; +extern class PServer *Server; + +extern class PGameServer *GameServer; +extern class PChars *Chars; + +extern class PMsgBuilder *MsgBuilder; +extern class PWorlds *Worlds; +extern class PAppartements* Appartements; +extern class PWorldActors* WorldActors; +extern class PTerminal* Terminal; +//extern class gmMachine machine; // Virtual Machine instance + +//multiuser chat +extern class PClientManager *ClientManager; +extern class PNPCManager* NPCManager; +extern class PChat *Chat; +extern class PCommands *GameCommands; + +extern class POutpost *Outposts; +extern class PMultiPart *MultiPartHandler; + +// Development debug output control +extern bool gDevDebug; + +//MySQL-Support +extern class PMySQL* MySQL; + +//Vehicles +extern class PVehicles *Vehicles; +extern class PSubway* Subway; + +//Infoserver update +extern class PISC *ISC; + +extern const char ServerVersion[]; +extern const char SVNRevision[]; + +bool InitTinNS(); +void Shutdown(); diff --git a/server/src/game/inventory.cpp b/TinNS/Source/GameServer/Inventory.cxx similarity index 62% rename from server/src/game/inventory.cpp rename to TinNS/Source/GameServer/Inventory.cxx index fac330c..9d82354 100644 --- a/server/src/game/inventory.cpp +++ b/TinNS/Source/GameServer/Inventory.cxx @@ -1,42 +1,4 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - inventory.cpp - classes for inventories - (inventory, belt, armor, implants, gogo, processor(?), maybe other containers(?) ) - - MODIFIED: 10 Jul 2006 Hammag - REASON: - creation : Quick and dirty main inventory (backpack) management - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem - - clean ups -*/ - - -#include "main.h" - -#include "include/inventory.h" -#include "include/container.h" - +#include "GameServer/Includes.hxx" /* --- PInventory class --- */ @@ -56,7 +18,7 @@ PInventory::~PInventory () delete mGogo; } -void PInventory::SetCharId(u32 CharID) +void PInventory::SetCharId(uint32_t CharID) { mWorn->SetInfo(CharID, INV_DB_LOC_WORN); mBackpack->SetInfo(CharID, INV_DB_LOC_BACKPACK); @@ -66,7 +28,7 @@ void PInventory::SetCharId(u32 CharID) bool PInventory::SQLLoad() { return ( mWorn->SQLLoad() && mBackpack->SQLLoad() && mGogo->SQLLoad() ); - + /*bool ret = mWorn->SQLLoad() && mBackpack->SQLLoad() && mGogo->SQLLoad(); Console->Print(YELLOW, BLACK, "--- Worn Inventory ---"); mWorn->Dump(); @@ -88,7 +50,7 @@ bool PInventory::IsDirty() const return (mWorn && mWorn->IsDirty()) || (mBackpack && mBackpack->IsDirty()) || (mGogo && mGogo->IsDirty()); } -PContainer* PInventory::GetContainer(u8 nInvLoc) +PContainer* PInventory::GetContainer(uint8_t nInvLoc) { PContainer* tContainer; switch(nInvLoc) @@ -108,14 +70,14 @@ PContainer* PInventory::GetContainer(u8 nInvLoc) return tContainer; } -bool PInventory::AddItem(PItem *NewItem, u8 nInvLoc, u32 nInvID, u8 nPosX, u8 nPosY, bool SetDirty) +bool PInventory::AddItem(PItem *NewItem, uint8_t nInvLoc, uint32_t nInvID, uint8_t nPosX, uint8_t nPosY, bool SetDirty) { PContainer* destContainer = GetContainer(nInvLoc); return(destContainer ? destContainer->AddItem(NewItem, nInvID, nPosX, nPosY, SetDirty) : false); } /* -bool PInventory::QB_IsFree(u8 nSlot) +bool PInventory::QB_IsFree(uint8_t nSlot) { if(nSlot > 9) return false; @@ -127,7 +89,7 @@ bool PInventory::QB_IsFree(u8 nSlot) return false; } -void PInventory::QB_SetSlot(u8 nSlot, u16 nItemID) +void PInventory::QB_SetSlot(uint8_t nSlot, uint16_t nItemID) { if(nSlot > 9) return; @@ -135,7 +97,7 @@ void PInventory::QB_SetSlot(u8 nSlot, u16 nItemID) mQuickAccessBelt[nSlot] = nItemID; } -u16 PInventory::QB_GetSlot(u8 nSlot) +uint16_t PInventory::QB_GetSlot(uint8_t nSlot) { if(nSlot > 9) return 0; @@ -143,7 +105,7 @@ u16 PInventory::QB_GetSlot(u8 nSlot) return mQuickAccessBelt[nSlot]; } -void PInventory::QB_Move(u8 nSlotSRC, u8 nSlotDST) +void PInventory::QB_Move(uint8_t nSlotSRC, uint8_t nSlotDST) { if(nSlotSRC > 9 || nSlotDST > 9) return; diff --git a/TinNS/Source/GameServer/Inventory.hxx b/TinNS/Source/GameServer/Inventory.hxx new file mode 100644 index 0000000..2218a5c --- /dev/null +++ b/TinNS/Source/GameServer/Inventory.hxx @@ -0,0 +1,83 @@ +#pragma once + +#include + +//NC containers message locations +#define INV_LOC_GROUND 1 +#define INV_LOC_WORN 2 +#define INV_LOC_BACKPACK 3 +#define INV_LOC_BOX 4 +#define INV_LOC_NPCTRADE 5 +#define INV_LOC_GOGO 18 +#define INV_LOC_BOX2 255 +//PC-Trade window = ? + +//Inventory containers info +#define INV_WORN_QB_START 0 +#define INV_WORN_QB_END 9 +#define INV_WORN_QB_NONE 99 +#define INV_WORN_QB_HAND 11 + +#define INV_WORN_PROC_START 12 +#define INV_WORN_PROC_END 24 + +#define INV_WORN_IMP_START 26 +#define INV_WORN_IMP_END 38 + +#define INV_WORN_ARMOR_START 39 +#define INV_WORN_ARMOR_END 43 + +#define INV_WORN_COLS 44 +#define INV_WORN_MAXSLOTS 44 + + +#define INV_BACKPACK_COLS 10 + +#define INV_GOGO_COLS 5 +#define INV_GOGO_MAXSLOTS 50 + +#define INV_CABINET_COLS 5 +#define INV_CABINET_MAXSLOTS 33 + +// inv_loc values in database +#define INV_DB_LOC_GOGO 1 +#define INV_DB_LOC_WORN 2 +#define INV_DB_LOC_BACKPACK 3 + +class PItem; +class PContainer; +class PContainerWithHoles; +class PContainer2DWorkaround; +class PContainerAutoFindFree; + +class PInventory +{ + private: + PContainerWithHoles* mWorn; // PContainerLinearSlots + PContainer2DWorkaround* mBackpack; // PContainer2DAreas + PContainerAutoFindFree* mGogo; // PContainerLinearSlots + + public: + + PInventory(); + ~PInventory(); + + void SetCharId(uint32_t CharID); + bool SQLLoad(); + bool SQLSave(); + PContainer* GetContainer(uint8_t nInvLoc); + inline PContainer2DWorkaround* GetBackpackContainer() { return mBackpack; } + + bool IsDirty() const; + + bool AddItem(PItem* NewItem, uint8_t nInvLoc = INV_LOC_BACKPACK, uint32_t nInvID = 0, uint8_t nPosX = 0, uint8_t nPosY = 0, bool SetDirty = true); + //bool CheckItem(uint32_t ItemID, uint8_t StackSize = 1); + //PItem *GetItem(uint32_t ItemID, uint8_t StackSize = 1); + //PItem *GetItemByPos(uint8_t nPosX, uint8_t nPosY, uint8_t StackSize = 1); + //bool MoveItem(uint8_t oPosX, uint8_t oPosY, uint8_t dPosX, uint8_t dPosY); + + //bool QB_IsFree(uint8_t nSlot); + //void QB_SetSlot(uint8_t nSlot, uint16_t nItemID); + //uint16_t QB_GetSlot(uint8_t nSlot); + //void QB_Move(uint8_t nSlotSRC, uint8_t nSlotDST); +}; diff --git a/server/src/game/isc.cpp b/TinNS/Source/GameServer/Isc.cxx similarity index 71% rename from server/src/game/isc.cpp rename to TinNS/Source/GameServer/Isc.cxx index 8120de1..0fece43 100644 --- a/server/src/game/isc.cpp +++ b/TinNS/Source/GameServer/Isc.cxx @@ -1,41 +1,7 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - isc.cpp - - MODIFIED: Unknown date / Namikon - REASON: - initial release by Namikon - MODIFIED: 13 Oct 2006 Hammag - REASON: - Implemented MySQL isc method - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem - - TODO: - - implement ISC protocol -*/ - -#include "main.h" - -#include "include/isc.h" +// TODO: - implement ISC protocol PISC::PISC() { @@ -70,7 +36,7 @@ void PISC::Start() if (use_isc) Start_isc(); - + if (use_mysql) Start_mysql(); @@ -80,9 +46,9 @@ void PISC::Update() { if (use_isc) Update_isc(); - + if (use_mysql) - Update_mysql(); + Update_mysql(); } void PISC::Shutdown() @@ -92,7 +58,7 @@ void PISC::Shutdown() use_isc = false; Shutdown_isc(); } - + if (use_mysql) { use_mysql = false; @@ -104,28 +70,25 @@ void PISC::Shutdown() void PISC::Start_isc() { - u16 Port = Config->GetOptionInt("isc_infoserverport"); - if (Port == 0) - { - Console->Print("%s Unable to start ISC, isc_infoserverport setting is invalid"); - use_isc = false; - return; - } - Console->Print("Trying to connect to infoserver...", Port); - // Add function for initial connect here and store the connectioninfo somewhere + uint16_t Port = Config->GetOptionInt("isc_infoserverport"); + if (Port == 0) + { + Console->Print("%s Unable to start ISC, isc_infoserverport setting is invalid"); + use_isc = false; + return; + } + Console->Print("Trying to connect to infoserver...", Port); + // Add function for initial connect here and store the connectioninfo somewhere } void PISC::Update_isc() { - } void PISC::Shutdown_isc() { - } - /*** IMySQL mode specific ***/ void PISC::Start_mysql() @@ -137,18 +100,18 @@ void PISC::Start_mysql() Console->Print("%s value for 'isc_update_intervall' too low (%d). Set to 10 sec.", Console->ColorText(YELLOW, BLACK, "[Notice]"), mysql_update_intervall); mysql_update_intervall = 10; } - + mysql_delayed_update_intervall = Config->GetOptionInt("isc_delayed_update_intervall"); if (mysql_delayed_update_intervall < 0) { Console->Print("%s value for 'isc_delayed_update_intervall' is invalid (%d). Set to 0 sec (immediate update)", Console->ColorText(YELLOW, BLACK, "[Notice]"), mysql_delayed_update_intervall); mysql_delayed_update_intervall = 0; } - + mysql_last_update_time = 0; mysql_last_client_count = 0; mysql_last_count_decrease_time = 0; - + Update_mysql(); } @@ -157,7 +120,7 @@ void PISC::Update_mysql() bool do_update = false; std::time_t t = std::time(NULL); int client_count = Server->GetNumClients(); - + if (((t - mysql_last_update_time) >= mysql_update_intervall) || (client_count > mysql_last_client_count)) { do_update = true; @@ -181,7 +144,7 @@ void PISC::Update_mysql() mysql_last_count_decrease_time = 0; //if(gDevDebug) Console->Print("%s ISC : Canceling less clients time count", Console->ColorText(GREEN, BLACK, "[Debug]")); } - + if (do_update) { do_mysql_db_update(client_count); @@ -189,7 +152,6 @@ void PISC::Update_mysql() mysql_last_count_decrease_time = 0; mysql_last_update_time = std::time(NULL); } - } void PISC::Shutdown_mysql() diff --git a/server/src/game/include/isc.h b/TinNS/Source/GameServer/Isc.hxx similarity index 53% rename from server/src/game/include/isc.h rename to TinNS/Source/GameServer/Isc.hxx index abc8eb6..dc04f9e 100644 --- a/server/src/game/include/isc.h +++ b/TinNS/Source/GameServer/Isc.hxx @@ -1,37 +1,7 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko +#pragma once - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - -/* - isc.h - - MODIFIED: Unknown date / Namikon - REASON: - initial release by Namikon - MODIFIED: 13 Oct 2006 Hammag - REASON: - Implemented MySQL isc method - -*/ - -#ifndef ISC_H -#define ISC_H +#include +#include #define ISC_VER 2 @@ -39,10 +9,8 @@ #define ISC_CONNECTED 1 #define ISC_ADMIN 2 - -class PISC -{ - private: +class PISC { + private: enum PISC_Status { ISC_NOTCONNECTED, @@ -62,7 +30,7 @@ class PISC ISC_IDLE // Updateloop running } mLinkStatus; - u16 mConStatus; // Bitmask of Connection status + uint16_t mConStatus; // Bitmask of Connection status int isc_method; @@ -71,11 +39,11 @@ class PISC bool use_mysql; int m_server_id; - std::time_t mysql_update_intervall; - std::time_t mysql_delayed_update_intervall; - std::time_t mysql_last_update_time; + time_t mysql_update_intervall; + time_t mysql_delayed_update_intervall; + time_t mysql_last_update_time; int mysql_last_client_count; - std::time_t mysql_last_count_decrease_time; + time_t mysql_last_count_decrease_time; void Start_isc(); void Update_isc(); @@ -86,13 +54,11 @@ class PISC bool do_mysql_db_update(int players, bool shutdown = false); void Shutdown_mysql(); - public: - PISC(); - ~PISC(); + public: + PISC(); + ~PISC(); - void Start(); - void Update(); - void Shutdown(); + void Start(); + void Update(); + void Shutdown(); }; - -#endif diff --git a/TinNS/Source/GameServer/Item.cxx b/TinNS/Source/GameServer/Item.cxx new file mode 100644 index 0000000..ce2b4b1 --- /dev/null +++ b/TinNS/Source/GameServer/Item.cxx @@ -0,0 +1,180 @@ +#include "GameServer/Includes.hxx" +#include "GameServer/Definitions/Includes.hxx" + +PItem::PItem(uint32_t ItemID, uint8_t nStackSize, uint8_t CurDur, uint8_t MaxDur, uint8_t Dmg, uint8_t Freq, uint8_t Hand, uint8_t Rng) +{ + mDefItem = GameDefs->Items()->GetDef(ItemID); + if (mDefItem) { + mItemID = ItemID; + mStackable = mDefItem->IsStackable(); + mStackSize = mStackable ? nStackSize : 1; + + mLoadedAmmoId = 0; + mLoadedAmmoNb = 0; + + mPropertiesFlags = 0; + + mUsedSlots = mMaxSlots = 0; + mModificators = 0; + + mConstructorId = 0; + //mType = mDefItem->GetType(); + //mValue1 = mDefItem->GetValue1(); + //mValue2 = mDefItem->GetValue2(); + //mValue3 = mDefItem->GetValue3(); + //mSizeX = mDefItem->GetSizeX(); + //mSizeY = mDefItem->GetSizeY(); + //mWeight = mDefItem->GetWeight(); + //mFillWeight = mDefItem->GetFillWeight(); + //mQualifier = mDefItem->GetQualifier(); + //mItemGroupID = mDefItem->GetItemGroupID(); + //mBasePrice = mDefItem->GetBasePrice(); + //mTechlevel = mDefItem->GetTechlevel(); + //mItemflags = mDefItem->GetItemflags(); + + //if (!mStackable) // only non-stackable items can have quality stats (?) + //{ + // mStackSize = 1; + mCurDuration = CurDur; + mMaxDuration = MaxDur; + mDamages = Dmg; + mFrequency = Freq; + mHandling = Hand; + mRange = Rng; + //} + } + else + { + mItemID = 0; + Console->Print(YELLOW, BLACK, "PItem::PItem: Invalid item ID %d", ItemID); + } +} + +void PItem::MakeItemStandard(uint8_t GlobalQualityMin, uint8_t GlobalQualityMax) +{ + if(GlobalQualityMin > GlobalQualityMax) GlobalQualityMin = GlobalQualityMax; + + mCurDuration = 255; + mMaxDuration = 255; + if(GlobalQualityMin == GlobalQualityMax) + { + mDamages = GlobalQualityMin; + mFrequency = GlobalQualityMin; + mHandling = GlobalQualityMin; + mRange = GlobalQualityMin; + } + else + { + mDamages = (uint8_t) GetRandom(GlobalQualityMax, GlobalQualityMin); + mFrequency = (uint8_t) GetRandom(GlobalQualityMax, GlobalQualityMin); + mHandling = (uint8_t) GetRandom(GlobalQualityMax, GlobalQualityMin); + mRange = (uint8_t) GetRandom(GlobalQualityMax, GlobalQualityMin); + } +} + +uint32_t PItem::GetItemID() +{ + return mItemID; +} + +int PItem::GetType() +{ + return mDefItem->GetType(); +} + +uint8_t PItem::GetItemflags() +{ + return mDefItem->GetItemflags(); +} + +const std::string &PItem::GetName() const +{ + return mDefItem->GetName(); +} + +uint8_t PItem::GetSizeX() +{ + return mDefItem->GetSizeX(); +} + +uint8_t PItem::GetSizeY() +{ + return mDefItem->GetSizeY(); +} + +float PItem::GetWeight() +{ + return mStackSize * mDefItem->GetWeight(); +} + +float PItem::GetSingleUnitWeight() +{ + return mDefItem->GetWeight(); +} + +float PItem::GetFillWeight() +{ + return mDefItem->GetFillWeight(); +} + +uint32_t PItem::GetBasePrice() +{ + return mDefItem->GetBasePrice(); +} + +uint16_t PItem::GetTechlevel() +{ + return mDefItem->GetTechlevel(); +} + +int PItem::GetValue1() +{ + return mDefItem->GetValue1(); +} + +int PItem::GetValue2() +{ + return mDefItem->GetValue2(); +} + +int PItem::GetValue3() +{ + return mDefItem->GetValue3(); +} + +int PItem::GetQualifier() +{ + return mDefItem->GetQualifier(); +} + +bool PItem::IsStackable() +{ + return mDefItem->IsStackable(); +} + +uint8_t PItem::GetStackSize() +{ + return mStackSize; +} + +uint8_t PItem::AddToStack(uint8_t ItemNb) // returns nb of items not added +{ + uint8_t addedItems = 0; + if (mStackable) + { + addedItems = (ItemNb <= (MAX_ITEMSTACK_SIZE - mStackSize)) ? ItemNb : (MAX_ITEMSTACK_SIZE - mStackSize); + mStackSize += addedItems; + } + return (ItemNb - addedItems); +} + +uint8_t PItem::TakeFromStack(uint8_t ItemNb) +{ + uint8_t retreivedItems = 0; + if (mStackable) + { + retreivedItems = std::min(mStackSize, ItemNb); + mStackSize -= retreivedItems; + } + return retreivedItems; +} diff --git a/TinNS/Source/GameServer/Item.hxx b/TinNS/Source/GameServer/Item.hxx new file mode 100644 index 0000000..fbe9668 --- /dev/null +++ b/TinNS/Source/GameServer/Item.hxx @@ -0,0 +1,112 @@ +#pragma once + +#include +#include + +class PDefItems; + +// TODO: Add CreatorID (for "named" item), CurrentMunitionID, CurrentMunitionNb (for weapons & charge-items: muns, +// medkit, etc.) to DB, equipped/free slots, & corresponding code + +#define MAX_ITEMSTACK_SIZE 250 + +//Type +#define ITEM_TYPE_VARIOUS 0 +#define ITEM_TYPE_WEAPON 1 +#define ITEM_TYPE_AMMO 2 +#define ITEM_TYPE_HEALTH 3 +#define ITEM_TYPE_IMPLANT 4 +#define ITEM_TYPE_DRUG 5 +#define ITEM_TYPE_MOD 6 +#define ITEM_TYPE_GFXMOD 7 +#define ITEM_TYPE_BLUEPRINT 8 +#define ITEM_TYPE_ARMOR 9 +#define ITEM_TYPE_PSIMOD 10 +#define ITEM_TYPE_PSIMODREADY 11 +#define ITEM_TYPE_REPAIR 12 +#define ITEM_TYPE_RECYCLER 13 +#define ITEM_TYPE_DATACUBE 14 +#define ITEM_TYPE_CONSTRUCTOR 15 +#define ITEM_TYPE_RESEARCHER 16 +#define ITEM_TYPE_IMPLANTER 17 +#define ITEM_TYPE_APARTMENTKEY 18 +#define ITEM_TYPE_CLANKEY 19 +#define ITEM_TYPE_CASHCUBE 20 +#define ITEM_TYPE_AUTOWEAPON 21 +#define ITEM_TYPE_VHCKEY 22 +#define ITEM_TYPE_UNIDENTPART 24 +#define ITEM_TYPE_WRECKEDPART 25 +#define ITEM_TYPE_SALVAGE 26 +#define ITEM_TYPE_VHCCOMPONENT 27 +#define ITEM_TYPE_RECORDABLE 28 + +// gfxmodflags +#define ITEM_MOD_FLASHLIGHT 1 +#define ITEM_MOD_SCOP 2 +#define ITEM_MOD_SILENCER 4 +#define ITEM_MOD_LASERPOINTER 8 + +// itemflags: +#define ITEM_FLAG_RESEARCHABLE 1 +#define ITEM_FLAG_NO_DROP 2 +#define ITEM_FLAG_NO_MAX_REPAIRE_DECAY 4 +#define ITEM_FLAG_AMMO 8 // for loadable ammo +// not sure for ITEM_FLAG_AMMO + +class PItem { + friend class PContainerEntry; + friend class PMsgBuilder; + + private: + uint32_t mItemID; + const PDefItems* mDefItem; + + bool mStackable; + uint8_t mStackSize; + + uint32_t mLoadedAmmoId; + uint8_t mLoadedAmmoNb; + + uint8_t mPropertiesFlags; + + uint8_t mCurDuration; + uint8_t mMaxDuration; + uint8_t mDamages; + uint8_t mFrequency; + uint8_t mHandling; + uint8_t mRange; + + uint8_t mUsedSlots; + uint8_t mMaxSlots; + uint8_t mSlot[5]; + uint8_t mModificators; + + uint32_t mConstructorId; + + public: + PItem(uint32_t ItemID, uint8_t nStackSize = 1, uint8_t CurDur = 0, uint8_t MaxDur = 0, uint8_t Dmg = 0, uint8_t Freq = 0, uint8_t Hand = 0, uint8_t Rng = 0); + //~PItem(); + void MakeItemStandard(uint8_t GlobalQualityMin = 120, uint8_t GlobalQualityMax = 180); + + uint32_t GetItemID(); + int GetType(); + uint8_t GetItemflags(); + const std::string &GetName() const; + uint8_t GetSizeX(); + uint8_t GetSizeY(); + float GetWeight(); + float GetSingleUnitWeight(); + float GetFillWeight(); + uint32_t GetBasePrice(); + uint16_t GetTechlevel(); + int GetValue1(); + int GetValue2(); + int GetValue3(); + int GetQualifier(); + bool IsStackable(); + uint8_t GetStackSize(); + uint8_t AddToStack(uint8_t ItemNb); // return the nb of items NOT added + uint8_t TakeFromStack(uint8_t ItemNb); // return the nb of retreived items + + //mItemGroupID = def->GetItemGroupID(); +}; diff --git a/server/src/game/lua_engine.cpp b/TinNS/Source/GameServer/LuaEngine.cxx similarity index 90% rename from server/src/game/lua_engine.cpp rename to TinNS/Source/GameServer/LuaEngine.cxx index 7e2afd3..bbce3c3 100644 --- a/server/src/game/lua_engine.cpp +++ b/TinNS/Source/GameServer/LuaEngine.cxx @@ -1,34 +1,5 @@ -/* -TinNS (TinNS is not a Neocron Server) -Copyright (C) 2005 Linux Addicted Community -maintainer Akiko - -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 -of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301, USA. -*/ - -/* - -lua_engine.cpp - TinNS Lua engine for processing NPC scripts - -CREATION: 13 Oct 2009 Namikon - -*/ - -#include "main.h" -#include "include/msgbuilder.h" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" // ****************************************************************** // ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION @@ -109,7 +80,7 @@ int npcscript_callback(lua_State *nLua) int tAmount = lua_tointeger(nLua, 3); if (gDevDebug) Console->Print("TAKEMONEY from script"); - if(tClient->GetChar()->GetCash() < (u32)tAmount) + if(tClient->GetChar()->GetCash() < (uint32_t)tAmount) { // Cannot take cash, player has less than amount required LuaEngine->AddScriptResult(0); @@ -214,7 +185,7 @@ void PLuaEngine::ProcessDialogScript(PClient* nClient, std::string nLUAFile, int PChar* tChar = nClient->GetChar(); // Get current node ID the player is on - u16 tNodeID = tChar->GetDialogNode(); + uint16_t tNodeID = tChar->GetDialogNode(); // First, get the new node ID based on the answer the client gave us. DO NOT execute any commands from // Script yet. Resulting node is in mReturn_INT @@ -230,7 +201,7 @@ void PLuaEngine::ProcessDialogScript(PClient* nClient, std::string nLUAFile, int else { // Set the new node in client - tChar->SetDialogNode((u16)mReturn_INT); + tChar->SetDialogNode((uint16_t)mReturn_INT); // Now send the new node (together with the answer-buffer) to the client. // After this packet hits the client, it will show the given node PMessage* tmpMsg = MsgBuilder->BuildNPCDialogReplyMsg(nClient, tChar->GetDialogNode(), &mReturnValues); @@ -265,7 +236,7 @@ void PLuaEngine::AddScriptResult(int nResult) PLuaEngine::PLuaEngine() { - // New lua function + // New lua function mLua = luaL_newstate(); mRunning = false; } diff --git a/TinNS/Source/GameServer/LuaEngine.hxx b/TinNS/Source/GameServer/LuaEngine.hxx new file mode 100644 index 0000000..3b1c36c --- /dev/null +++ b/TinNS/Source/GameServer/LuaEngine.hxx @@ -0,0 +1,39 @@ +#pragma once + +#include + +#define PLUAENGINE_DEFAULT 0 +#define PLUAENGINE_GETANSWER 4096 +#define PLUAENGINE_EXECUTENODE 8192 + +class PLuaEngine { +private: + PClient* mTargetClient; + + bool mRunning; + lua_State *mLua; + + std::vector mReturnValues; + + + // Return Values + int mReturn_INT; + // std::string mReturn_STR; + // add more if needed... + + void CleanUp(); + bool ExecuteScript(std::string nLUAScript, int nNode, int nDialogClass = 0); + +public: + PLuaEngine(); + ~PLuaEngine(); + + // To check if LUA Script has syntax errors or whatever + bool CheckLUAFile(std::string nLUAScript); + void AddScriptResult(int nResult); + void ProcessDialogScript(PClient* nClient, std::string mLUAFile, int nAnswer); + inline PClient* GetBoundClient() { return mTargetClient; }; + + inline void SetReturnINT(int nValue) { mReturn_INT = nValue; }; + // inline void SetReturnSTR(std::string nValue) { mReturn_STR = nValue; }; +}; diff --git a/TinNS/Source/GameServer/Main.cxx b/TinNS/Source/GameServer/Main.cxx new file mode 100644 index 0000000..4a93545 --- /dev/null +++ b/TinNS/Source/GameServer/Main.cxx @@ -0,0 +1,57 @@ +#include +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" + +// for handling strg-c signal to shutdown in correct way +void signal_handler(int signal) +{ + if (signal == SIGINT) + { + //cout << "Shutting down TinNS" << endl; + + //exit(0); + Shutdown(); + } + else + { + psignal(signal, "Unkown signal: "); + } +} + +int main() +{ + // Connect signal with handlerfunction + signal(SIGINT, signal_handler); // TODO: change for sigaction() + + + if(!InitTinNS()) + { + if(Console) + Console->Print("%s Aborting startup.", Console->ColorText(RED, BLACK, "[Fatal]")); + Shutdown(); // exits with 0 ... + } + + //RemoteConsole->Start(); + GameServer->Start(); + //GameServer->SetGameTime(0); + ISC->Start(); + + Console->Print("Gameserver is now %s. Waiting for clients...", Console->ColorText(GREEN, BLACK, "Online")); + + + while(1) + { + ServerSock->update(); + NPCManager->Update(); + Server->Update(); + Chars->Update(); + GameServer->Update(); + PMessage::CheckMsgCount(); // Memory leak check + MySQL->Update(); // Memory leak check and MySQL keepalive + ISC->Update(); + Console->Update(); + MultiPartHandler->Update(); + } + + return 0; +} diff --git a/TinNS/Source/GameServer/Main.hxx b/TinNS/Source/GameServer/Main.hxx new file mode 100644 index 0000000..c5b65d7 --- /dev/null +++ b/TinNS/Source/GameServer/Main.hxx @@ -0,0 +1,52 @@ +#pragma once + +//#include "version.h" + +//basic includes +//#include "include/external.h" + +//tinns includes +//#include "include/types.h" +//#include "common/netcode.h" +/* +#include "../gamemonkey/gmMachine.h" +#include "../gamemonkey/gmCall.h" +*/ +//#include "common/console.h" +//#include "common/misc.h" + +// MySQL Support +/* +#ifdef MYSQL_INC_DIR +#include +#else +#include +#endif + +#include "include/sql.h" + +#include "common/config.h" +#include "common/filesystem.h" +#include "include/defparser.h" + +#include "include/skill.h" +#include "include/chars.h" +#include "include/accounts.h" +#include "include/client.h" +#include "include/server.h" +#include "include/gameserver.h" +#include "include/globals.h" +#include "include/defs.h" +#include "include/zoning.h" +#include "include/item.h" +#include "include/inventory.h" +#include "include/worldactors.h" +#include "include/npc.h" +#include "include/outpost.h" +#include "include/multipart.h" +#include "include/terminal.h" + +#include "include/lua_engine.h" +#include "include/chat.h" +#include "include/commands.h" +#include "include/clientmanager.h" */ diff --git a/TinNS/Source/GameServer/MessageBuilder.cxx b/TinNS/Source/GameServer/MessageBuilder.cxx new file mode 100644 index 0000000..c9cd3f9 --- /dev/null +++ b/TinNS/Source/GameServer/MessageBuilder.cxx @@ -0,0 +1,3664 @@ +#include +#include "GameServer/Includes.hxx" +#include "GameServer/Definitions/Includes.hxx" +#include "Common/Includes.hxx" + +PMessage* PMsgBuilder::BuildOutpostClanInfoMsg( PClient* nClient, uint32_t nClanID, uint8_t nFaction ) +{ + PMessage* tmpMsg = new PMessage(); + nClient->IncreaseUDP_ID(); + + *tmpMsg << (uint8_t)0x13; + *tmpMsg << (uint16_t)nClient->GetUDP_ID(); + *tmpMsg << (uint16_t)nClient->GetSessionID(); + *tmpMsg << (uint8_t)0x13; // Message length + *tmpMsg << (uint8_t)0x03; + *tmpMsg << (uint16_t)nClient->GetUDP_ID(); + *tmpMsg << (uint8_t)0x23; + + //*tmpMsg << (uint16_t)GetArgInt(2); + *tmpMsg << (uint16_t)14; + *tmpMsg << (uint8_t)0x00; + *tmpMsg << (float)nClanID; // ClanID float + *tmpMsg << (uint8_t)nFaction; // Faction + // The next 3 bytes are unknown. + // However, with this combination, the OP and its bonuses are + // set correctly; eg Own clan full bonus, friend clan 75%, etc + *tmpMsg << (uint8_t)0x06; // 6? 0x06 + *tmpMsg << (uint8_t)0x14; // 0? 0x14 + *tmpMsg << (uint8_t)0x0b; // 11? 0x0b + *tmpMsg << (uint32_t)nClanID; // ClanID uint32_t + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildCharHelloMsg( PClient* nClient ) +{ + PChar *nChar = nClient->GetChar(); + uint32_t nSkin, nHead, nTorso, nLegs; + uint8_t nHeadColor, nTorsoColor, nLegsColor, nHeadDarkness, nTorsoDarkness, nLegsDarkness; + + nChar->GetCurrentLook( nSkin, nHead, nTorso, nLegs ); + nChar->GetCurrentBodyColor( nHeadColor, nTorsoColor, nLegsColor, nHeadDarkness, nTorsoDarkness, nLegsDarkness ); + + PMessage* tmpMsg = new PMessage( ); + + uint8_t currentActiveSlot = nChar->GetQuickBeltActiveSlot(); + uint16_t weaponId = 0; + switch ( currentActiveSlot ) + { + case INV_WORN_QB_NONE: + //weaponId = 0; + break; + case INV_WORN_QB_HAND: + weaponId = 5; // <= TODO: set it somewhere + break; + default: + PItem* currentItem = nChar->GetInventory()->GetContainer( INV_LOC_WORN )->GetItem( INV_WORN_QB_START + currentActiveSlot ); + //Todo : item addons & effects + //ItemInHandID = currentItem->GetItemID(): + if ( currentItem ) + weaponId = currentItem->GetValue1(); + //else + //ItemInHandID = 0; + break; + } + + //nClient->IncreaseUDP_ID(); // This must be done outside + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )0x0000; //Client->GetUDP_ID(); // just placeholder, must be set outside + *tmpMsg << ( uint16_t )0x0000; // Client->GetSessionID(); // just placeholder, must be set outside + *tmpMsg << ( uint8_t )0x00; // size placeholder, set later in the function + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )0x0000; // Client->GetUDP_ID(); // just placeholder, must be set outside + *tmpMsg << ( uint8_t )0x25; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint32_t )nChar->GetID(); + + *tmpMsg << ( uint8_t )0x60; // 0x40 if current faction epic done (master), | 0x80 to display [afk] | 0x20 if LE in + *tmpMsg << ( uint8_t )(( nChar->GetSpeedOverride() == 255 ) ? 10 : nChar->GetSpeedOverride() ); // move speed, reset by client (and for him only) when getting fall damage + *tmpMsg << ( uint8_t )0x08; // ??? something to do with speed ? + *tmpMsg << ( uint16_t )weaponId; // WeaponID of the weapon in hand + *tmpMsg << ( uint8_t )0x01; // ??? + *tmpMsg << ( uint8_t )0x01; // ??? + *tmpMsg << ( uint8_t )( 128 + nChar->GetSoullight() ); + + *tmpMsg << ( uint8_t )nChar->GetMainRank(); // in fact, Ranks are of type int8_t, but it doesn't matter much + *tmpMsg << ( uint8_t )nChar->GetCombatRank(); + *tmpMsg << ( uint8_t )nChar->GetFaction(); + + *tmpMsg << ( uint8_t )0x00; // This was 0x21 for an GM, with faction 0x00. However, no visible change when set... + *tmpMsg << ( uint8_t )0x0f; // size of the next bloc (skin + ?clan?) + // Current skin + *tmpMsg << ( uint16_t )nSkin; + *tmpMsg << ( uint8_t )nHead; + *tmpMsg << ( uint8_t )nTorso; + *tmpMsg << ( uint8_t )nLegs; + // Skin colors + *tmpMsg << ( uint8_t )nHeadColor; + *tmpMsg << ( uint8_t )nTorsoColor; + *tmpMsg << ( uint8_t )nLegsColor; + *tmpMsg << ( uint8_t )nHeadDarkness; // (0=bright 255=dark) + *tmpMsg << ( uint8_t )nTorsoDarkness; + *tmpMsg << ( uint8_t )nLegsDarkness; + *tmpMsg << ( uint8_t )0x00; // ??? << not sure at all // eg: 0x3e + *tmpMsg << ( uint8_t )0x00; // eg: 0x03 + *tmpMsg << ( uint8_t )0x00; // eg: 0xa3 + *tmpMsg << ( uint8_t )0x00; // eg: 0x03 + + //Name + *tmpMsg << ( uint8_t )(( nChar->GetName() ).length() + 1 ); + *tmpMsg << ( nChar->GetName() ).c_str(); + //Body effects + uint8_t cBodyEffect, cEffectDensity; + nChar->GetBodyEffect( cBodyEffect, cEffectDensity ); + if ( cBodyEffect ) + { + *tmpMsg << ( uint8_t )0x06; // size of effect list : 6 bytes/effect. Only one supported atm + *tmpMsg << ( uint8_t )cBodyEffect; // effect type (0=none, effecive values 1 - 17) + *tmpMsg << ( uint8_t )cEffectDensity; // density: 0=max, 0xff=min (for some effects only) + *tmpMsg << ( uint8_t )0x00; // ??? + *tmpMsg << ( uint8_t )0x00; // ??? + *tmpMsg << ( uint8_t )0x00; // ??? + *tmpMsg << ( uint8_t )0x00; // ??? + } + else + { + *tmpMsg << ( uint8_t )0x00; // size of empty effect list + } + + // Clans working, yeah :D + uint16_t tClanVal = nChar->GetClan(); + if(tClanVal > 0) + { + uint8_t tClanLevel = nChar->GetClanLevel(); + uint32_t tmpVal; + tmpVal = tClanVal << 4; + tmpVal |= tClanLevel; + *tmpMsg << ( uint8_t )0x04; + *tmpMsg << ( uint32_t )tmpVal; + } + else + *tmpMsg << ( uint8_t )0x00; // ending null + // alternate interpretation to this "ending null"/optional bloc: + /* *tmpMsg << (uint8_t)0x04; // size of unknown bloc ... 0x00 when empty (aka the "ending null") + *tmpMsg << (uint8_t)0x0b; // vary ... ??? 0b, eb, ee, ... + *tmpMsg << (uint8_t)0x44; // vary ... ??? + *tmpMsg << (uint8_t)0x00; // these two seem always null + *tmpMsg << (uint8_t)0x00; */ + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildReqNPCScriptAnswerMsg( uint32_t nInfoId, std::string *nNPCScript ) + { + PMessage* tmpMsg; + + tmpMsg = new PMessage(); + + *tmpMsg << ( uint8_t )0x19; + *tmpMsg << ( uint16_t )0x0006; // InfoQuery + *tmpMsg << ( uint16_t )0x0003; // NPC Script + *tmpMsg << ( uint32_t )nInfoId; + *tmpMsg << nNPCScript->c_str(); + + return tmpMsg; + + } + +PMessage* PMsgBuilder::BuildYouGotEmailsMsg( PClient* nClient, uint8_t nMailCount ) + { + PMessage* tmpMsg = new PMessage(); + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x0c; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x3d; + *tmpMsg << ( uint8_t )0x0c; + *tmpMsg << ( uint8_t )0x00; + *tmpMsg << ( uint8_t )0x00; + *tmpMsg << ( uint8_t )0x00; + *tmpMsg << ( uint8_t )nMailCount; + + return tmpMsg; + } + +PMessage* PMsgBuilder::BuildReceiveDBAnswerMsg( PClient* nClient, PMessage* nResultBuffer, std::string *nCommandName, uint16_t nNumRows, uint16_t nNumFields) + { + PMessage* tmpMsg = new PMessage(); +/* nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )0x0000; + *tmpMsg << ( uint16_t )0x0000; + *tmpMsg << ( uint8_t )0x00; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x2b; + *tmpMsg << ( uint8_t )0x1a; + if(nCommandName->length() > 0) + *tmpMsg << ( uint8_t )0x01; + else + *tmpMsg << ( uint8_t )0x00; + + *tmpMsg << ( uint8_t )0x00; + *tmpMsg << ( uint8_t )0x00; + *tmpMsg << *nCommandName; + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + // 2nd message + *tmpMsg << ( uint16_t )(13 + nCommandName->length() + nResultBuffer->GetSize()); // ?? + */ + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x00; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x2b; + *tmpMsg << ( uint8_t )0x17; + *tmpMsg << ( uint16_t )(nCommandName->length()+1); + *tmpMsg << ( uint16_t )nNumRows; + *tmpMsg << ( uint16_t )nNumFields; + *tmpMsg << *nCommandName; + *tmpMsg << *nResultBuffer; + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + + return tmpMsg; + //len = (unsigned int)strlen(DB); + //SendBuffer[0] = 0x13; + //SendBuffer[5] = 11 + len; + //SendBuffer[6] = 0x03; + //Network_IncrementUDP (ClientNum); + //*(unsigned short*)&SendBuffer[7] = Client_Sockets[ClientNum].UDP_ID; + // SendBuffer[9] = 0x2b; + // SendBuffer[10] = 0x1a; + // *(unsigned short*)&SendBuffer[11] = len; + // if (num == 0) + // SendBuffer[13] = 0x00; + // else + // SendBuffer[13] = 0x01; + // SendBuffer[14] = 0x00; + // SendBuffer[15] = 0x00; + // strcpy (SendBuffer+16, DB); + // plen = 17+len; + + // SendBuffer[plen] = 13+len+slen; + // SendBuffer[plen+1] = 0x03; + // Network_IncrementUDP (ClientNum); + // *(unsigned short*)&SendBuffer[plen+2] = Client_Sockets[ClientNum].UDP_ID; + // *(unsigned short*)&SendBuffer[1] = Client_Sockets[ClientNum].UDP_ID; + // *(unsigned short*)&SendBuffer[3] = Client_Sockets[ClientNum].UDP_ID_HIGH; + // SendBuffer[plen+4] = 0x2b; + // SendBuffer[plen+5] = 0x17; + // *(unsigned short*)&SendBuffer[plen+6] = len+1; + // *(unsigned short*)&SendBuffer[plen+8] = num; + // *(unsigned short*)&SendBuffer[plen+10] = Fields; + // //Fieldnum is defined in each DB below + // strcpy (SendBuffer+plen+12, DB); + // plen += 13+len; + + // for (i=0;iIncreaseUDP_ID(); + + *tmpMsg << (uint8_t)0x13; + *tmpMsg << (uint16_t)nClient->GetUDP_ID(); + *tmpMsg << (uint16_t)nClient->GetSessionID(); + *tmpMsg << (uint8_t)0x00; + *tmpMsg << (uint8_t)0x03; + *tmpMsg << (uint16_t)nClient->GetUDP_ID(); + *tmpMsg << (uint8_t)0x2b; + *tmpMsg << (uint8_t)0x1a; + *tmpMsg << (uint16_t)(strlen(nArea)+1); + + if(nAllowed) + *tmpMsg << (uint8_t)0x01; + else + *tmpMsg << (uint8_t)0x00; + + *tmpMsg << (uint8_t)0x00; + *tmpMsg << (uint8_t)0x00; + *tmpMsg << nArea; + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + return tmpMsg; + } + +PMessage* PMsgBuilder::BuildReqInfoAnswerMsg( PClient* nClient, uint16_t nReqType, uint32_t nInfoId, void* nResponse, uint16_t nResponseLength ) +{ + PMessage* tmpMsg; + + tmpMsg = new PMessage( 18 + nResponseLength ); + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x00; // Message length placeholder; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x23; + *tmpMsg << ( uint16_t )0x0006; // cmd + *tmpMsg << ( uint16_t )nReqType; // wrong size here (uint32_t) for buffer size uint16_t in NeoX + *tmpMsg << ( uint32_t )nInfoId; + tmpMsg->Write( nResponse, nResponseLength ); + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildCharHealthUpdateMsg( PClient* nClient ) +{ + PMessage* tmpMsg = new PMessage( 14 ); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )0x0000; //Client->GetUDP_ID(); // just placeholder, must be set outside + *tmpMsg << ( uint16_t )0x0000; // Client->GetSessionID(); // just placeholder, must be set outside + *tmpMsg << ( uint8_t )0x00; // Message length placeholder; + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x30; + *tmpMsg << ( uint8_t )0x64; //Head Heath =Head HP/(3 *0.45)(with max Head HP = 45% of total) + *tmpMsg << ( uint8_t )0x64; //Body Heath =Body HP/(3 *0.35)(for max 35% of total) + *tmpMsg << ( uint8_t )0x64; //Feet Heath =Feet HP/(3 *0.20)(for max 20% of total) + *tmpMsg << ( uint8_t )0x01; // Sta/Mana ? + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildCharDeathMsg( PClient* nClient, uint32_t nKillerCharId ) +{ + PMessage* tmpMsg = new PMessage( 17 ); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )0x0000; //Client->GetUDP_ID(); // just placeholder, must be set outside + *tmpMsg << ( uint16_t )0x0000; // Client->GetSessionID(); // just placeholder, must be set outside + *tmpMsg << ( uint8_t )0x00; // Message length placeholder; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )0x0000; // Client->GetUDP_ID(); // just placeholder, must be set outside + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x16; + *tmpMsg << ( uint32_t )nKillerCharId; + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildCharPosUpdateMsg( PClient* nClient ) +{ + PMessage* tmpMsg = new PMessage( 32 ); + PChar* nChar = nClient->GetChar(); + + uint32_t cSeatObjectId; + uint8_t cSeatId; + PSeatType cSeatType = nChar->GetSeatInUse( &cSeatObjectId, &cSeatId ); + if ( cSeatType == seat_chair ) // temp ! Must migrate to RAW + { + cSeatObjectId = ( cSeatObjectId + 1 ) * 1024; + } + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )0x0000; //Client->GetUDP_ID(); // just placeholder, must be set outside + *tmpMsg << ( uint16_t )0x0000; // Client->GetSessionID(); // just placeholder, must be set outside + *tmpMsg << ( uint8_t )0x00; // Message length placeholder; + *tmpMsg << ( uint8_t )0x1b; + *tmpMsg << ( uint32_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x03; + if ( cSeatType ) + { + *tmpMsg << ( uint32_t )cSeatObjectId; + *tmpMsg << ( uint16_t )cSeatId; // testing... else 0x0000 + } + else + { + *tmpMsg << ( uint16_t )(( nChar->Coords ).mY ); + *tmpMsg << ( uint16_t )(( nChar->Coords ).mZ ); + *tmpMsg << ( uint16_t )(( nChar->Coords ).mX ); + } + *tmpMsg << ( uint16_t )( 31910 + ( nChar->Coords ).mUD - 50 ); // Up - Mid - Down mUD=(d6 - 80 - 2a) NeoX original offset: 31910 + *tmpMsg << ( uint16_t )( 31820 + ( nChar->Coords ).mLR*2 - 179 ); // Compass direction mLR=(S..E..N..W..S [0-45-90-135-179]) There still is a small buggy movement when slowly crossing the South axis from the right + if ( cSeatType ) + { + *tmpMsg << ( uint8_t )0x00; + *tmpMsg << ( uint8_t )0x10; + } + else + { + *tmpMsg << ( uint8_t )(( nChar->Coords ).mAct ); + *tmpMsg << ( uint8_t )0x00; + } + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildCharPosUpdate2Msg( PClient* nClient, uint8_t InfoBitfield ) +{ + PMessage* tmpMsg = new PMessage( 32 ); + PChar* nChar = nClient->GetChar(); + + if ( InfoBitfield == 0x80 ) + { + Console->Print( RED, BLACK, "[ERROR] PMsgBuilder::BuildCharPosUpdate2Msg : using InfoBitfield=0x80 forbidden. Using 0x7f instead." ); + InfoBitfield = 0x7f; + } + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )0x0000; //Client->GetUDP_ID(); // just placeholder, must be set outside + *tmpMsg << ( uint16_t )0x0000; // Client->GetSessionID(); // just placeholder, must be set outside + *tmpMsg << ( uint8_t )0x00; // Message length placeholder; + *tmpMsg << ( uint8_t )0x20; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )InfoBitfield; + + if ( InfoBitfield & 0x01 ) + { + *tmpMsg << ( uint16_t )(( nChar->Coords ).mY ); + } + if ( InfoBitfield & 0x02 ) + { + *tmpMsg << ( uint16_t )(( nChar->Coords ).mZ ); + } + if ( InfoBitfield & 0x04 ) + { + *tmpMsg << ( uint16_t )(( nChar->Coords ).mX ); + } + if ( InfoBitfield & 0x08 ) + { + *tmpMsg << ( uint8_t )(( nChar->Coords ).mUD ); + } + if ( InfoBitfield & 0x10 ) + { + *tmpMsg << ( uint8_t )(( nChar->Coords ).mLR ); + } + if ( InfoBitfield & 0x20 ) + { + *tmpMsg << ( uint8_t )(( nChar->Coords ).mAct ); + } + /*if(InfoBitfield & 0x40) // Not used (?) + { + *tmpMsg << (uint8_t)((nChar->Coords).mUnknown); + }*/ + /*if(InfoBitfield & 0x80) // mRoll ???? + { + *tmpMsg << (uint8_t)((nChar->Coords).mUnknown); + }*/ + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +/* +PMessage* PMsgBuilder::BuildCharSittingMsg( PClient* nClient ) +{ + PMessage* tmpMsg = new PMessage( 24 ); + PChar* nChar = nClient->GetChar(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )0x0000; //Client->GetUDP_ID(); // just placeholder, must be set outside + *tmpMsg << ( uint16_t )0x0000; // Client->GetSessionID(); // just placeholder, must be set outside + *tmpMsg << ( uint8_t )0x00; // Message length placeholder; + *tmpMsg << ( uint8_t )0x32; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x00; // Type = chair/subway ??? + *tmpMsg << ( uint8_t )0x00; + *tmpMsg << ( uint8_t )0x03; // Type = chair ??? + *tmpMsg << ( uint16_t )(( nChar->Coords ).mY ); + *tmpMsg << ( uint16_t )(( nChar->Coords ).mZ ); + *tmpMsg << ( uint16_t )(( nChar->Coords ).mX ); + *tmpMsg << ( uint16_t )( 31910 + ( nChar->Coords ).mUD - 50 ); // Up - Mid - Down mUD=(d6 - 80 - 2a) NeoX original offset: 31910 + *tmpMsg << ( uint16_t )( 31820 + ( nChar->Coords ).mLR*2 - 179 ); // Compass direction mLR=(S..E..N..W..S [0-45-90-135-179]) There still is a small buggy movement when slowly crossing the South axis from the right + *tmpMsg << ( uint8_t )(( nChar->Coords ).mAct ); + *tmpMsg << ( uint8_t )0x00; + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} +*/ + +PMessage* PMsgBuilder::BuildCharUseSeatMsg( PClient* nClient, uint32_t nRawObjectId, uint8_t nSeatId ) +{ + PMessage* tmpMsg = new PMessage( 18 ); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )0x0000; // nClient->GetUDP_ID() placeholder + *tmpMsg << ( uint16_t )0x0000; // nClient->GetSessionID()placeholder + + *tmpMsg << ( uint8_t )0x0c; // Sub message length; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )0x0000; // ++ nClient->GetUDP_ID() placeholder + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x21; + *tmpMsg << ( uint32_t )nRawObjectId; + *tmpMsg << ( uint8_t )nSeatId; // 0x00 for real chair, 1+ for subway cab + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildCharExitSeatMsg( PClient* nClient ) +{ + PMessage* tmpMsg = new PMessage( 22 ); + PChar* nChar = nClient->GetChar(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )0x0000; // nClient->GetUDP_ID() placeholder + *tmpMsg << ( uint16_t )0x0000; // nClient->GetSessionID()placeholder + *tmpMsg << ( uint8_t )0x00; // Message length placeholder; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )0x0000; // nClient->GetUDP_ID() placeholder + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x22; + *tmpMsg << ( uint16_t )(( nChar->Coords ).mY + 768 ) ; + *tmpMsg << ( uint16_t )(( nChar->Coords ).mZ + 768 ) ; + *tmpMsg << ( uint16_t )(( nChar->Coords ).mX + 768 ) ; + *tmpMsg << ( uint8_t )( nChar->Coords ).mUD; + *tmpMsg << ( uint8_t )( nChar->Coords ).mLR; + *tmpMsg << ( uint8_t )( nChar->Coords ).mAct; + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildPacket0Msg( PClient* nClient ) +{ + PMessage* tmpMsg = new PMessage( 70 ); + PChar* nChar = nClient->GetChar(); + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x00; // Message length placeholder; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x2c; + *tmpMsg << ( uint8_t )0x01; // ?? + *tmpMsg << ( uint8_t )0x01; // ?? + *tmpMsg << ( uint32_t )0x00000000; + *tmpMsg << ( float )(( nChar->Coords ).mY - 32000 ); + *tmpMsg << ( float )(( nChar->Coords ).mZ - 32000 ); + *tmpMsg << ( float )(( nChar->Coords ).mX - 32000 ); + *tmpMsg << ( uint32_t )0x00000000; + *tmpMsg << ( uint32_t )0x00000000; + *tmpMsg << ( uint32_t )0x00000000; + *tmpMsg << ( uint8_t )0x01; // ???? + *tmpMsg << ( uint8_t )0x00; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint8_t )0x07; + *tmpMsg << ( uint8_t )0x02; + *tmpMsg << ( uint8_t )0x00; + *tmpMsg << ( uint32_t )0x00000000; + *tmpMsg << ( uint32_t )0x00000000; + *tmpMsg << ( uint32_t )0x00000000; + *tmpMsg << ( uint32_t )0x00000000; + *tmpMsg << ( uint32_t )0x00000000; + *tmpMsg << ( uint32_t )0x00000000; + + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildPingMsg( PClient* nClient, uint32_t nClientTime ) +{ + PMessage* tmpMsg = new PMessage( 15 ); + uint32_t LocalTime = GameServer->GetGameTime(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x00; // Message length placeholder; + *tmpMsg << ( uint8_t )0x0b; + *tmpMsg << ( uint32_t )LocalTime; + *tmpMsg << ( uint32_t )nClientTime; + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildBaselineMsg( PClient* nClient ) +{ + PMessage* BaselineMsg = new PMessage( 512 ); + PMessage SectionMsg( 256 ); + + PChar *nChar = nClient->GetChar(); + const PDefCharKind *def = GameDefs->CharKinds()->GetDef( nChar->GetProfession() ); + PSkillHandler *Skill = nChar->Skill; + + nClient->IncreaseTransactionID( 3 ); + + // Head + *BaselineMsg << ( uint8_t )0x22; + *BaselineMsg << ( uint8_t )0x02; // ? + *BaselineMsg << ( uint8_t )0x01; // ? + + // ---- Section 1 ---- + *BaselineMsg << ( uint8_t )0x01; // section id + + SectionMsg << ( uint8_t )0xfa; // ? // // section content at offset 3 + SectionMsg << ( uint8_t )nChar->GetProfession(); + SectionMsg << ( uint16_t )nClient->GetTransactionID(); // Transaction ID ? 0x8aa0 + SectionMsg << ( uint32_t )nChar->GetID(); + SectionMsg << ( uint8_t )0x0e; // ? 0x0e in NeoX, 0x10 in Tinns ... doesn't seem to matter + SectionMsg << ( uint8_t )0x00; // ? + + *BaselineMsg << ( uint16_t )SectionMsg.GetSize(); + *BaselineMsg << SectionMsg; + SectionMsg.Reset(); + + // ---- Section 2 ---- + *BaselineMsg << ( uint8_t )0x02; // section id + SectionMsg << ( uint8_t )0x04; // ? // section content at offset 3 + SectionMsg << ( uint8_t )0x50; // ? + SectionMsg << ( uint16_t )500; // nChar->GetHealth(); + SectionMsg << ( uint16_t )500; // nChar->GetMaxHealth(); + SectionMsg << ( uint16_t )500; // nChar->GetMana(); + SectionMsg << ( uint16_t )500; // nChar->GetMaxMana(); + SectionMsg << ( uint16_t )500; // nChar->GetStamina(); + SectionMsg << ( uint16_t )500; // nChar->GetMaxStamina(); + SectionMsg << ( uint16_t )0x00ff; // ? + SectionMsg << ( uint16_t )0x00ff; // ? + SectionMsg << ( uint16_t )0x00e1; // (nChar->GetHealth() + 1); // ? Probably Head Health (45% of total) 0x0065 + SectionMsg << ( uint16_t )0x0147; // (nChar->GetHealth() + 1); // ? Torso Health (35% of total) + SectionMsg << ( uint16_t )0x0147; // (nChar->GetHealth() + 1); // ? Legs Health (20% of total) + SectionMsg << ( uint8_t )100; // 100 - SI + SectionMsg << ( uint8_t )0x80; // The lower this value is, the more your char has a "drug effect" on it 0x00 = unmoveable + SectionMsg << ( uint16_t )0x0000; + + *BaselineMsg << ( uint16_t )SectionMsg.GetSize(); + *BaselineMsg << SectionMsg; + SectionMsg.Reset(); + + // ---- Section 3 ---- + *BaselineMsg << ( uint8_t )0x03; // section id + + SectionMsg << ( uint8_t )0x06; // ? // section content at offset 3 + SectionMsg << ( uint8_t )0x09; // ? + SectionMsg << ( uint32_t )0x00000000; // ? + SectionMsg << ( uint32_t )0x00000000; // ? + SectionMsg << ( uint8_t )0x01; // ? + + SectionMsg << ( uint8_t )Skill->GetMainSkill( MS_STR ); + SectionMsg << ( uint16_t )Skill->GetSP( MS_STR ); + SectionMsg << ( uint32_t )Skill->GetXP( MS_STR ); + SectionMsg << ( uint8_t )def->GetSkillInfo( MS_STR ).mGrow; + SectionMsg << ( uint8_t )def->GetSkillInfo( MS_STR ).mMax; + + SectionMsg << ( uint8_t )Skill->GetMainSkill( MS_DEX ); + SectionMsg << ( uint16_t )Skill->GetSP( MS_DEX ); + SectionMsg << ( uint32_t )Skill->GetXP( MS_DEX ); + SectionMsg << ( uint8_t )def->GetSkillInfo( MS_DEX ).mGrow; + SectionMsg << ( uint8_t )def->GetSkillInfo( MS_DEX ).mMax; + + SectionMsg << ( uint8_t )Skill->GetMainSkill( MS_CON ); + SectionMsg << ( uint16_t )Skill->GetSP( MS_CON ); + SectionMsg << ( uint32_t )Skill->GetXP( MS_CON ); + SectionMsg << ( uint8_t )def->GetSkillInfo( MS_CON ).mGrow; + SectionMsg << ( uint8_t )def->GetSkillInfo( MS_CON ).mMax; + + SectionMsg << ( uint8_t )Skill->GetMainSkill( MS_INT ); + SectionMsg << ( uint16_t )Skill->GetSP( MS_INT ); + SectionMsg << ( uint32_t )Skill->GetXP( MS_INT ); + SectionMsg << ( uint8_t )def->GetSkillInfo( MS_INT ).mGrow; + SectionMsg << ( uint8_t )def->GetSkillInfo( MS_INT ).mMax; + + SectionMsg << ( uint8_t )Skill->GetMainSkill( MS_PSI ); + SectionMsg << ( uint16_t )Skill->GetSP( MS_PSI ); + SectionMsg << ( uint32_t )Skill->GetXP( MS_PSI ); + SectionMsg << ( uint8_t )def->GetSkillInfo( MS_PSI ).mGrow; + SectionMsg << ( uint8_t )def->GetSkillInfo( MS_PSI ).mMax; + + SectionMsg << ( uint16_t )0x0000; // ? + SectionMsg << ( uint8_t )0x00; // ? + SectionMsg << ( uint8_t )0x08; // ? + + *BaselineMsg << ( uint16_t )SectionMsg.GetSize(); + *BaselineMsg << SectionMsg; + SectionMsg.Reset(); + + // ---- Section 4 ---- + *BaselineMsg << ( uint8_t )0x04; // section id + + SectionMsg << ( uint8_t )0x2e; // ? // section content at offset 3 + SectionMsg << ( uint8_t )0x02; // ? + SectionMsg << ( uint8_t )0x00; // spare + SectionMsg << ( uint8_t )0x01; // cost + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_MC ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_MC ); + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_HC ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_HC ); + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_TRA ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_TRA ); + SectionMsg << ( uint8_t )0x00; // spare + SectionMsg << ( uint8_t )0x01; // cost + SectionMsg << ( uint8_t )0x00; // spare + SectionMsg << ( uint8_t )0x01; // cost + SectionMsg << ( uint8_t )0x00; // spare + SectionMsg << ( uint8_t )0x01; // cost + SectionMsg << ( uint8_t )0x00; // spare + SectionMsg << ( uint8_t )0x01; // cost + SectionMsg << ( uint8_t )0x00; // spare + SectionMsg << ( uint8_t )0x01; // cost + SectionMsg << ( uint8_t )0x00; // spare + SectionMsg << ( uint8_t )0x01; // cost + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_PC ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_PC ); + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_RC ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_RC ); + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_TC ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_TC ); + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_VHC ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_VHC ); + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_AGL ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_AGL ); + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_REP ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_REP ); + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_REC ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_REC ); + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_RCL ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_RCL ); + SectionMsg << ( uint8_t )0x00; // spare + SectionMsg << ( uint8_t )0x01; // cost + SectionMsg << ( uint8_t )0x00; // spare + SectionMsg << ( uint8_t )0x01; // cost + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_ATL ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_ATL ); + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_END ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_END ); + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_FOR ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_FOR ); + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_FIR ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_FIR ); + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_ENR ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_ENR ); + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_XRR ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_XRR ); + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_POR ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_POR ); + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_HLT ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_HLT ); + SectionMsg << ( uint8_t )0x00; // spare + SectionMsg << ( uint8_t )0x01; // cost + SectionMsg << ( uint8_t )0x00; // spare + SectionMsg << ( uint8_t )0x01; // cost + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_HCK ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_HCK ); + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_BRT ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_BRT ); + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_PSU ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_PSU ); + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_WEP ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_WEP ); + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_CST ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_CST ); + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_RES ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_RES ); + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_IMP ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_IMP ); + SectionMsg << ( uint8_t )0x00; // spare + SectionMsg << ( uint8_t )0x01; // cost + SectionMsg << ( uint8_t )0x00; // spare + SectionMsg << ( uint8_t )0x01; // cost + SectionMsg << ( uint8_t )0x00; // spare + SectionMsg << ( uint8_t )0x01; // cost + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_PPU ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_PPU ); + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_APU ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_APU ); + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_MST ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_MST ); + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_PPW ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_PPW ); + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_PSR ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_PSR ); + SectionMsg << ( uint8_t )Skill->GetSubSkill( SK_WPW ); + SectionMsg << ( uint8_t )Skill->GetSKPCost( SK_WPW ); + + *BaselineMsg << ( uint16_t )SectionMsg.GetSize(); + *BaselineMsg << SectionMsg; + SectionMsg.Reset(); + + // ---- Section 5 ---- + *BaselineMsg << ( uint8_t )0x05; // section id + + PMessage* ContentList = BuildContainerContentList( nChar->GetInventory()->GetContainer( INV_LOC_BACKPACK ), INV_LOC_BACKPACK ); + SectionMsg << *ContentList; + delete ContentList; + + *BaselineMsg << ( uint16_t )SectionMsg.GetSize(); + *BaselineMsg << SectionMsg; + SectionMsg.Reset(); + + // ---- Section 6 ---- + *BaselineMsg << ( uint8_t )0x06; // section id + + ContentList = BuildContainerContentList( nChar->GetInventory()->GetContainer( INV_LOC_WORN ), INV_LOC_WORN ); + SectionMsg << *ContentList; + delete ContentList; + + /* SectionMsg << (uint8_t)0x04; // QB/Armor/Implants items nb // section content at offset 3 + + // THIS IS A TEMP SOLUTION UNTIL WE HAVE ITEM STUFF WORKING ===== BEGIN + SectionMsg << (uint16_t)0x06; // Size of item + SectionMsg << (uint16_t)0x00; // Location: Quickbelt slot 0 + SectionMsg << (uint16_t)0x0051; // ItemID: 81, Flashlight + SectionMsg << (uint8_t)0x01; // Datatype + SectionMsg << (uint8_t)0x00; // Data + */ + + /**** + SectionMsg << (uint8_t)0x04; // QB/Armor/Implants items nb // section content at offset 3 + + // THIS IS A TEMP SOLUTION UNTIL WE HAVE ITEM STUFF WORKING ===== BEGIN + SectionMsg << (uint16_t)0x001b; // Size of item + SectionMsg << (uint8_t)0x00; // Location: Quickbelt slot 0 + SectionMsg << (uint8_t)0x00; // nop (Y) + SectionMsg << (uint16_t)0x0003; // ItemID: 3, assault riffle + SectionMsg << (uint8_t)(0x01|0x02|0x10|0x40); // Datatype + + //SectionMsg << (uint8_t)0x01; // for 0x80. Use ??? + + SectionMsg << (uint8_t)0x00; // Qty / remaining ammos + + SectionMsg << (uint8_t)0x06; // Qual entries + SectionMsg << (uint8_t)0x40; // current qual + SectionMsg << (uint8_t)0x80; // dmg + SectionMsg << (uint8_t)0xc0; // freq + SectionMsg << (uint8_t)0xa0; // handl + SectionMsg << (uint8_t)0xb0; // range + SectionMsg << (uint8_t)0xff; // max qual <= always last + + SectionMsg << (uint8_t)0x07; // addons bitflag: flashlight=1, scope, silencer, laserpointer + + SectionMsg << (uint8_t)0x02; // used slots + SectionMsg << (uint8_t)0x05; // max slots + SectionMsg << (uint16_t)1526; // slots / explo ammo + SectionMsg << (uint16_t)21; // riffle-barrel + SectionMsg << (uint16_t)0x0000; + SectionMsg << (uint16_t)0x0000; + SectionMsg << (uint16_t)0x0000; + *****/ + /* + SectionMsg << (uint16_t)0x06; // Size of item + SectionMsg << (uint8_t)0x01; // Location: Quickbelt slot 1 + SectionMsg << (uint8_t)0x00; // nop (Y) + SectionMsg << (uint16_t)0x0023; // ItemID: 35, Med Kit + SectionMsg << (uint8_t)0x01; // Data=ammo count + SectionMsg << (uint8_t)0x03; // Data + */ + /* + SectionMsg << (uint16_t)0x06; // Size of item + SectionMsg << (uint16_t)0x01; // Location: Quickbelt slot 0 + SectionMsg << (uint16_t)0x0055; // ItemID: 81, Flashlight + SectionMsg << (uint8_t)0x01; // Datatype + SectionMsg << (uint8_t)0x00; // Data + + SectionMsg << (uint16_t)0x06; // Size of item + SectionMsg << (uint16_t)0x02; // Location: Quickbelt slot 0 + SectionMsg << (uint16_t)0x176F; // ItemID: 81, Flashlight + SectionMsg << (uint8_t)0x01; // Datatype + SectionMsg << (uint8_t)0x00; // Data + + + SectionMsg << (uint16_t)0x08; // Size of item + SectionMsg << (uint16_t)0x1a; // Location: Brain #1 + SectionMsg << (uint16_t)0x08fc; // ItemID: Law enforcer + SectionMsg << (uint8_t)0x02; // Datatype. 02: Item Duration information follows + SectionMsg << (uint8_t)0x02; // SubDatatype02: Full itemdetails follow + SectionMsg << (uint8_t)0x2a; // Current duration + SectionMsg << (uint8_t)0x2a; // Max duration + */ +// nChar->GetInventory()->QB_SetSlot(0, 81); // Add Flashlight to QB slot 1 +// nChar->GetInventory()->QB_SetSlot(1, 85); // Add Flashlight to QB slot 1 +// nChar->GetInventory()->QB_SetSlot(2, 5999); // Add Flashlight to QB slot 1 + // THIS IS A TEMP SOLUTION UNTIL WE HAVE ITEM STUFF WORKING ===== END + /* + StatsBuffer[len+3] = 0; //Number of items + plen = 4; + for (i=0;iGetInventory()->GetContainer( INV_LOC_GOGO ), INV_LOC_GOGO ); + SectionMsg << *ContentList; + + delete ContentList; + + *BaselineMsg << ( uint16_t )SectionMsg.GetSize(); + *BaselineMsg << SectionMsg; + SectionMsg.Reset(); + + // ---- Section 8 ---- + *BaselineMsg << ( uint8_t )0x08; // section id + + uint32_t nSkin, nHead, nTorso, nLegs; + nChar->GetRealLook( nSkin, nHead, nTorso, nLegs ); + + SectionMsg << ( uint8_t )0x0a; // ? // section content at offset 3 + SectionMsg << ( uint32_t )nChar->GetCash(); + + // Genrep list + SectionMsg << ( uint16_t )nChar->GetGenrepCount(); //Number of GR tagged (Tinns value on uint8_t only) + SectionMsg << ( uint8_t )0x04; + if ( nChar->GetGenrepCount() ) // For each entry : (uint16_t)genrep.g_worldid, (uint16_t)genrep.g_stationid + { + SectionMsg.Write( nChar->GetGenrepListData(), nChar->GetGenrepListDataSize() ); + } + + SectionMsg << ( uint8_t )0x04; + SectionMsg << ( uint8_t )0x04; + SectionMsg << ( uint8_t )0x00; + + // Direct chat + if ( nChar->GetDirectChat() ) + { + SectionMsg << ( uint8_t )1; + SectionMsg << ( uint32_t )nChar->GetDirectChat(); + } + else + { + SectionMsg << ( uint8_t )0; + } + + // Buddy Chat + SectionMsg << ( uint8_t )nChar->GetBuddyCount(); //Number of Buddies + if ( nChar->GetBuddyCount() ) // For each buddy (uint32_t)buddy CharID + { + SectionMsg.Write( nChar->GetBuddyListData(), nChar->GetBuddyListDataSize() ); + } + SectionMsg << ( uint8_t )0x00; + + SectionMsg << ( uint16_t )nClient->GetTransactionID(); // ?? + //SectionMsg << (uint32_t)0x00000000; + SectionMsg << ( uint32_t )0x00000000; + SectionMsg << ( uint32_t )0x00000000; // Epic status ? + SectionMsg << ( uint16_t )nSkin; + SectionMsg << ( uint8_t )nHead; + SectionMsg << ( uint8_t )nTorso; + SectionMsg << ( uint8_t )nLegs; + SectionMsg << ( uint8_t )0x00; // Rank + SectionMsg << ( uint32_t )( nChar->GetBaseApartment() + PWorlds::mAptBaseWorldId ); // 0x22, 0x00, 0x00, 0x00, //Primary Apartment (GR activated) ??? + SectionMsg << ( uint8_t )0x01; // ? + SectionMsg << ( uint8_t )0x00; // ? + SectionMsg << ( uint8_t )0x00; // ? + SectionMsg << ( uint8_t )0x00; // ? + SectionMsg << ( uint8_t )0x00; // ? + + *BaselineMsg << ( uint16_t )SectionMsg.GetSize(); + *BaselineMsg << SectionMsg; + SectionMsg.Reset(); + + // ---- Section 9 ---- + *BaselineMsg << ( uint8_t )0x09; // section id + + SectionMsg << ( uint16_t )0x15; // Nb of factions // section content at offset 3 + SectionMsg << ( uint16_t )nChar->GetFaction(); + SectionMsg << ( uint8_t )0x04; // ? + SectionMsg << ( float ) 1000.0f*1000.0f; // 96.0f*9000.0f; // SL + // Faction Sympathies Points effective sympathie is Square root of these points, abs value rounded down (beware of the sign ! :p) + SectionMsg << ( float ) 1000.0f*1250.0f; // City Admin => 111 + SectionMsg << ( float ) 1000.0f*1000.0f; // Diamond => 100 + SectionMsg << ( float ) 1000.0f* -750.0f; // Next => -86 + SectionMsg << ( float ) 1000.0f*500.0f; // Tangent => 70 + SectionMsg << ( float ) 1000.0f* -250.0f; // Biotech => -50 + SectionMsg << ( float ) 1000.0f*0.0f; // ProtoPharm => 0 + SectionMsg << ( float ) 1000.0f*1000.0f; // Trader's Union + SectionMsg << ( float ) 1000.0f*1000.0f; // Tsunami + SectionMsg << ( float ) 1000.0f*1000.0f; // Black Dragons + SectionMsg << ( float ) 1000.0f*1000.0f; // City Mercs + SectionMsg << ( float ) 1000.0f*1000.0f; // Crahn Sect + SectionMsg << ( float ) 1000.0f*1000.0f; // Dome Of York + SectionMsg << ( float ) 1000.0f* -1000.0f; // Anarchy Breed + SectionMsg << ( float ) 1000.0f*1000.0f; // Fallen Angels + SectionMsg << ( float ) 1000.0f*1000.0f; // Twilight Guardian + SectionMsg << ( float ) 1000.0f* -1000.0f; // Regeant's Legacy + SectionMsg << ( float ) 1000.0f* -1000.0f; // Regeant's Mutants + SectionMsg << ( float ) 1000.0f* -1000.0f; // Insects + SectionMsg << ( float ) 1000.0f* -1000.0f; // Monsters + SectionMsg << ( float ) 1000.0f*1000.0f; // Unknown + SectionMsg << ( float ) 1000.0f*1000.0f; // Highest SL? + + SectionMsg << ( uint32_t )0x00000000; // Epic done Data : bit 2^FactionID set <=> Epic done + SectionMsg << ( uint8_t )nChar->GetFaction(); // Faction ??? wrong size ... + + *BaselineMsg << ( uint16_t )SectionMsg.GetSize(); + *BaselineMsg << SectionMsg; + SectionMsg.Reset(); + + // ---- Section 0a ---- + *BaselineMsg << ( uint8_t )0x0a; // section id + + // Clan data ? + *BaselineMsg << ( uint16_t )SectionMsg.GetSize(); + *BaselineMsg << SectionMsg; + SectionMsg.Reset(); + + // ---- Section 0b ---- + *BaselineMsg << ( uint8_t )0x0b; // section id + + SectionMsg << ( uint8_t )0x00; // ?? // section content at offset 3 + + *BaselineMsg << ( uint16_t )SectionMsg.GetSize(); + *BaselineMsg << SectionMsg; + SectionMsg.Reset(); + + // ---- Section 0d ---- + *BaselineMsg << ( uint8_t )0x0d; // section id + + SectionMsg << ( uint8_t )0xfa; // ?? // section content at offset 3 + SectionMsg << ( uint8_t )nChar->GetProfession(); + SectionMsg << ( uint16_t )nClient->GetTransactionID(); // ?? TransactionID ? 0x8aa0 + SectionMsg << ( uint32_t )nChar->GetID(); + + *BaselineMsg << ( uint16_t )SectionMsg.GetSize(); + *BaselineMsg << SectionMsg; + SectionMsg.Reset(); + + return BaselineMsg; +} + +PMessage* PMsgBuilder::BuildAliveRepMsg( PClient* nClient ) +{ + PMessage* tmpMsg = new PMessage( 7 ); + + // uint8_t up[] = {0x04, 0x01, 0x00, 0xe3, 0x6b, 0xe6, 0xee}; + *tmpMsg << ( uint8_t )0x04; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0xe3; // ? not always... + *tmpMsg << ( uint8_t )0x6b; // ? not always... + *tmpMsg << ( uint16_t )( nClient->getUDPConn()->getPort() ); // really ? + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildZoning1Msg( PClient* nClient, uint16_t nEntity, uint8_t nUnknown ) +{ + PMessage* tmpMsg = new PMessage( 42 ); + + nClient->IncreaseUDP_ID(); + nClient->IncreaseTransactionID(); // from NeoX + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x0c; // Message length place; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); // from NeoX + *tmpMsg << ( uint8_t )0x25; // ?? + *tmpMsg << ( uint8_t )0x13; // ?? + *tmpMsg << ( uint16_t )nClient->GetTransactionID(); // from NeoX / ?? right ??? + // In case of apt GR or NC2.2 ? + // *tmpMsg << (uint8_t)0x04; // len ? + // *tmpMsg << (uint32_t)AptWorldID; // len ? + // nClient->IncreaseTransactionID(); + // *tmpMsg << (uint16_t)nClient->GetTransactionID(); + *tmpMsg << ( uint8_t )0x0e; // cmd => but not for zoning, because used in non-zoning situation + *tmpMsg << ( uint8_t )0x02; // ?? from NeoX + //(*tmpMsg)[5] = (uint8_t)(tmpMsg->GetSize() - 6); + + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x17; // Message length place; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x23; + *tmpMsg << ( uint16_t )0x0004; // cmd + *tmpMsg << ( uint32_t )0x00000000; // from NeoX + *tmpMsg << ( uint32_t )0x00000000; // from NeoX + *tmpMsg << ( uint8_t )nUnknown; + *tmpMsg << ( uint16_t )nEntity; + *tmpMsg << ( uint16_t )0x0000; // from NeoX + *tmpMsg << ( uint16_t )nClient->GetTransactionID(); // from NeoX + *tmpMsg << ( uint16_t )0x0000; // from NeoX + + // We DO need this! This is a multiframe packet, and the first UDP/SessionID set *HAS* to be + // as high as the last UDP/SessionID set in the frame! + tmpMsg->U16Data( 1 ) = nClient->GetUDP_ID(); + tmpMsg->U16Data( 3 ) = nClient->GetSessionID(); + + //(*tmpMsg)[5] = (uint8_t)(tmpMsg->GetSize() - 6); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildZoningTCPReadyMsg() +{ + PMessage* tmpMsg = new PMessage( 7 ); + + //static const uint8_t READY[7] = {0xfe, 0x04, 0x00, 0x83, 0x0d, 0x00, 0x00}; + *tmpMsg << ( uint8_t )0xfe; + *tmpMsg << ( uint16_t )0x0004; //length + *tmpMsg << ( uint8_t )0x83; //cmd + *tmpMsg << ( uint8_t )0x0d; // sub-cmd + *tmpMsg << ( uint16_t )0x0000; + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildSendZoneTCPMsg( uint32_t nLocation, std::string *nWorldName ) +{ + PMessage* tmpMsg = new PMessage( 14 + nWorldName->size() ); + + *tmpMsg << ( uint8_t )0xfe; + *tmpMsg << ( uint16_t )0x0000; // size placeholder + *tmpMsg << ( uint8_t )0x83; + *tmpMsg << ( uint8_t )0x0c; + *tmpMsg << ( uint32_t )nLocation; + *tmpMsg << ( uint32_t )0x00000000; + tmpMsg->Write( nWorldName->c_str(), nWorldName->size() + 1 ); + + tmpMsg->U16Data( 1 ) = ( uint16_t )( tmpMsg->GetSize() - 3 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildZoning2Msg( PClient* nClient, uint32_t nClientTime ) +{ + PMessage* tmpMsg = new PMessage( 22 ); + + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x00; // Message length placeholder; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x0d; + *tmpMsg << ( uint32_t )GameServer->GetGameTime(); + + *tmpMsg << ( uint32_t )nClientTime; + + *tmpMsg << ( uint8_t )0xe5; // ??? varies + *tmpMsg << ( uint8_t )0x0a; // ??? varies + *tmpMsg << ( uint8_t )0xbb; // ??? varies + *tmpMsg << ( uint8_t )0x00; // ??? usually 0 + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildGenrepZoningMsg( PClient* nClient, uint32_t nLocation, uint16_t nEntity ) +{ + PMessage* tmpMsg = new PMessage( 50 ); + + nClient->IncreaseUDP_ID(); + + tmpMsg->Fill( 0 ); + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x00; // Message length placeholder; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x23; + *tmpMsg << ( uint16_t )0x000c; // cmd + tmpMsg->SetNextByteOffset( 38 ); + *tmpMsg << ( uint32_t )0xffffffff; + *tmpMsg << ( uint32_t )nLocation; + *tmpMsg << ( uint16_t )nEntity; + *tmpMsg << ( uint16_t )0x0000; + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildGenrepAddToListMsg( PClient* nClient, uint32_t nLocation, uint16_t nEntity ) +{ + PMessage* tmpMsg = new PMessage( 23 ); + + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x00; // Message length placeholder; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x3d; + *tmpMsg << ( uint32_t )0x00000002; + *tmpMsg << ( uint32_t )nLocation; + *tmpMsg << ( uint16_t )nEntity; + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildAptLiftUseMsg( PClient* nClient, uint32_t nLocation, uint16_t nEntity, uint8_t nEntityType ) +{ + PMessage* tmpMsg = new PMessage( 43 ); + + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + + *tmpMsg << ( uint8_t )0x0f; // Message length placeholder; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x38; + *tmpMsg << ( uint8_t )0x04; // Accepted (?) + *tmpMsg << ( uint8_t )nEntityType; // "Sewer Level" + *tmpMsg << ( uint32_t )nLocation; + *tmpMsg << ( uint16_t )nEntity; + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildAptLiftFailedMsg( PClient* nClient ) +{ + PMessage* tmpMsg = new PMessage( 14 ); + + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + + *tmpMsg << ( uint8_t )0x08; // Message length placeholder; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x38; + *tmpMsg << ( uint8_t )0x03; // Refused + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildChangeLocationMsg( PClient* nClient, uint32_t nLocation, uint16_t nEntity, uint8_t nEntityType, uint32_t nRawItemID ) +{ + PMessage* tmpMsg = new PMessage( 28 ); + + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + + if ( nRawItemID ) + { + *tmpMsg << ( uint8_t )0x06; // Sub message length; + *tmpMsg << ( uint8_t )0x2d; // Item use response; + *tmpMsg << ( uint32_t )nRawItemID; + *tmpMsg << ( uint8_t )0x0a; // Use allowed + } + + *tmpMsg << ( uint8_t )0x0f; // Sub message length; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x38; + *tmpMsg << ( uint8_t )0x04; // Accepted (?) + *tmpMsg << ( uint8_t )nEntityType; + *tmpMsg << ( uint32_t )nLocation; + *tmpMsg << ( uint16_t )nEntity; + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildEntityPositionMsg( PClient* nClient, uint16_t pX, uint16_t pY, uint16_t pZ ) +{ + PMessage* tmpMsg = new PMessage( 18 ); + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x00; // Message length placeholder; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x23; + *tmpMsg << ( uint16_t )0x000a; + *tmpMsg << ( uint16_t )( pY + 768 ); + *tmpMsg << ( uint16_t )( pZ + 768 ); + *tmpMsg << ( uint16_t )( pX + 768 ); + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildCharAptLocInfoMsg( PClient* nClient ) +{ + PMessage* tmpMsg = new PMessage( 21 ); + nClient->IncreaseUDP_ID(); + + int BaseAppId = nClient->GetChar()->GetBaseApartment(); + uint32_t AptLocation = ( uint32_t )Appartements->GetAptLocation( BaseAppId ); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x0f; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x3d; + *tmpMsg << ( uint32_t )0x0000000b; + *tmpMsg << ( uint32_t )AptLocation; + + return tmpMsg; +} + +// OLD FUNCTION, REWRITTEN BELOW +/* +PMessage* PMsgBuilder::BuildSubskillIncMsg( PClient* nClient, uint8_t nSubskill, uint16_t nSkillPoints ) +{ + PMessage* tmpMsg = new PMessage( 33 ); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + + nClient->IncreaseUDP_ID(); + *tmpMsg << ( uint8_t )0x09; // SubMessage length; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x25; + *tmpMsg << ( uint8_t )0x23; + *tmpMsg << ( uint8_t )0x41; // 0x28 ?? // 0x 18 // 0x2c + + nClient->IncreaseUDP_ID(); + nClient->IncreaseTransactionID(); // testing ... + *tmpMsg << ( uint8_t )0x11; // SubMessage length; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x25; + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetTransactionID(); // testing / 0x0000 ???? + *tmpMsg << ( uint8_t )0x09; // ? + *tmpMsg << ( uint16_t )nSubskill; + *tmpMsg << ( uint16_t )nClient->GetChar()->Skill->GetSubSkill( nSubskill ); // nSubskill ? + *tmpMsg << ( uint16_t )nSkillPoints; + + //(*tmpMsg)[5] = (uint8_t)(tmpMsg->GetSize() - 6); + + return tmpMsg; +} + */ +// NPC Dialog. Start dialog with NPC +PMessage* PMsgBuilder::BuildNPCStartDialogMsg( PClient* nClient, uint32_t nNPCWorldID, std::string *nDialogScript ) + { + PMessage* tmpMsg = new PMessage(); + nClient->IncreaseUDP_ID(); + + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t ) 0x0000; // UDP Placeholder + *tmpMsg << ( uint16_t ) 0x0000; // UDP Placeholder + *tmpMsg << ( uint8_t )0x00; // Message length + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x18; + *tmpMsg << ( uint32_t ) nNPCWorldID; + + // Todo: is this correct? random uint32_t value?? + *tmpMsg << ( uint16_t ) GetRandom( 65535, 4369 ); + *tmpMsg << ( uint16_t ) GetRandom( 65535, 4369 ); + *tmpMsg << ( uint32_t ) 0x0000; + *tmpMsg << nDialogScript->c_str(); + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x0a; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x1a; + *tmpMsg << ( uint8_t )0x00; + *tmpMsg << ( uint8_t )0x00; + *tmpMsg << ( uint8_t )0x00; + + tmpMsg->U16Data( 1 ) = nClient->GetUDP_ID(); + tmpMsg->U16Data( 3 ) = nClient->GetSessionID(); + + return tmpMsg; + } +// NPC Dialog. Send next node number in lua script to client +PMessage* PMsgBuilder::BuildNPCDialogReplyMsg( PClient* nClient, uint16_t nNextNode, std::vector*nResultBuffer) + { + PMessage* tmpMsg = new PMessage(); + + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID();; + *tmpMsg << ( uint16_t )nClient->GetSessionID();; + *tmpMsg << ( uint8_t )0x00; // SubMessage length; + + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID();; + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x1a; + *tmpMsg << ( uint16_t )nNextNode; + //*tmpMsg << ( uint8_t )nNumResults; + *tmpMsg << ( uint8_t )nResultBuffer->size(); + + std::vector::const_iterator it; + + for(it = nResultBuffer->begin(); it != nResultBuffer->end(); it++) + { + *tmpMsg << ( float )*(it); + } + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; + } + +PMessage* PMsgBuilder::BuildNPCBeginAllBuyerTradeMsg( PClient* nClient, int nWorldID ) + { + PMessage* tmpMsg = new PMessage(); + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x00; // Message length + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x26; + *tmpMsg << ( uint32_t ) nWorldID; + *tmpMsg << ( uint8_t )0x01; // Traders inventory + *tmpMsg << ( uint16_t )0xFFFF; // Traders inventory + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; + } + +PMessage* PMsgBuilder::BuildNPCShoppingListMsg( PClient* nClient, PMessage* nContentList, int nWorldID, uint8_t nItemQuality) + { + PMessage* tmpMsg = new PMessage(); + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x00; // Message length + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x26; + *tmpMsg << ( uint32_t ) nWorldID; + *tmpMsg << ( uint8_t )0x01; // Traders inventory + *tmpMsg << ( uint16_t )( nContentList->GetSize() / 6 ); // List entries + *tmpMsg << ( uint8_t )nItemQuality; // Items quality + *tmpMsg << *nContentList; + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; + } + +// ========================== +PMessage* PMsgBuilder::BuildNPCSingleInfoMsg( PClient* nClient, uint32_t nWorldID, uint16_t nTypeID, uint16_t nClothing, +uint16_t nNameID, uint16_t nPosY, uint16_t nPosZ, uint16_t nPosX, uint16_t nUnknown, +uint16_t nTraderID, std::string *nAngleStr, std::string *nNpcName, std::string *nCustomName) +// Initial NPC Packet that defines how the NPC look, etc + { +// uint8_t tMsgLen = 29 + nNpcName->size() + nAngleStr->size() + nCustomName->size(); + + PMessage* tmpMsg = new PMessage(); + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; // Begin UDP message + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x00; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x28; + *tmpMsg << ( uint8_t )0x00; + *tmpMsg << ( uint8_t )0x01; + *tmpMsg << ( uint32_t )nWorldID; + *tmpMsg << ( uint16_t )nTypeID; + *tmpMsg << ( uint16_t )nClothing; + *tmpMsg << ( uint16_t )nNameID; + *tmpMsg << ( uint16_t )nPosY; + *tmpMsg << ( uint16_t )nPosZ; + *tmpMsg << ( uint16_t )nPosX; + *tmpMsg << ( uint8_t )0x00; + *tmpMsg << ( uint16_t )nUnknown; + *tmpMsg << ( uint16_t )nTraderID; + *tmpMsg << nNpcName->c_str(); + *tmpMsg << nAngleStr->c_str(); + if(nCustomName->length() > 1) + *tmpMsg << nCustomName->c_str(); + + (*tmpMsg)[5] = (uint8_t)(tmpMsg->GetSize() - 6); + return tmpMsg; + } + +PMessage* PMsgBuilder::BuildNPCMassInfoMsg( uint32_t nWorldID, uint16_t nTypeID, uint16_t nClothing, +uint16_t nNameID, uint16_t nPosY, uint16_t nPosZ, uint16_t nPosX, uint16_t nHealth, +uint16_t nTraderID, std::string *nAngleStr, std::string *nNpcName, std::string *nCustomName) +// Initial NPC Packet that defines how the NPC look, etc + { +// uint8_t tMsgLen = 29 + nNpcName->size() + nAngleStr->size() + nCustomName->size(); + + PMessage* tmpMsg = new PMessage(); + + *tmpMsg << ( uint8_t )0x13; // Begin UDP message + *tmpMsg << ( uint16_t )0x0000; + *tmpMsg << ( uint16_t )0x0000; + *tmpMsg << ( uint8_t )0x00; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )0x0000; + *tmpMsg << ( uint8_t )0x28; + *tmpMsg << ( uint8_t )0x00; + *tmpMsg << ( uint8_t )0x01; + *tmpMsg << ( uint32_t )nWorldID; + *tmpMsg << ( uint16_t )nTypeID; + *tmpMsg << ( uint16_t )nClothing; + *tmpMsg << ( uint16_t )nNameID; + *tmpMsg << ( uint16_t )nPosY; + *tmpMsg << ( uint16_t )nPosZ; + *tmpMsg << ( uint16_t )nPosX; + *tmpMsg << ( uint8_t )0x00; + *tmpMsg << ( uint16_t )nHealth; + *tmpMsg << ( uint16_t )nTraderID; + *tmpMsg << nNpcName->c_str(); + *tmpMsg << nAngleStr->c_str(); + if(nCustomName->length() > 1) + *tmpMsg << nCustomName->c_str(); + + (*tmpMsg)[5] = (uint8_t)(tmpMsg->GetSize() - 6); + return tmpMsg; + } + +// ************** +PMessage* PMsgBuilder::BuildNPCUpdateMsg(uint32_t nWorldID, uint16_t nPosY, uint16_t nPosZ, uint16_t nPosX, uint8_t nActionBM, uint16_t nHealth, uint8_t nWeaponState, uint8_t nUnknown, uint32_t nTargetID) + { + PMessage* tmpMsg = new PMessage(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )0x0000; + *tmpMsg << ( uint16_t )0x0000; + *tmpMsg << ( uint8_t )0x00; // len + *tmpMsg << ( uint8_t )0x1b; // NPC Update + *tmpMsg << ( uint32_t )nWorldID; // NPCs world ID + *tmpMsg << ( uint8_t )0x1f; // Parameters + *tmpMsg << ( uint16_t )nPosY; // Position Y + *tmpMsg << ( uint16_t )nPosZ; // Position Z + *tmpMsg << ( uint16_t )nPosX; // Position X + *tmpMsg << ( uint8_t )nActionBM; // NPCs current action-bitmask + *tmpMsg << ( uint16_t )nHealth; // Health value + if(nTargetID > 0) + *tmpMsg << ( uint32_t )nTargetID; // WorldID of NPCs target (if any) + *tmpMsg << ( uint8_t )nUnknown; + *tmpMsg << ( uint8_t )nWeaponState; + + (*tmpMsg)[5] = (uint8_t)(tmpMsg->GetSize() - 6); + + return tmpMsg; + } +// ************** + +PMessage* PMsgBuilder::BuildNPCSingleAliveMsg( PClient* nClient, uint32_t nWorldID, uint16_t nX, uint16_t nY, uint16_t nZ, uint8_t nActionStatus, uint8_t nHealth, uint8_t nAction ) + { + PMessage* tmpMsg = new PMessage(); + + *tmpMsg << ( uint8_t )0x13; // Begin UDP message + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x11; + *tmpMsg << ( uint8_t )0x1B; + *tmpMsg << ( uint32_t )nWorldID; + *tmpMsg << ( uint8_t )0x1F; + *tmpMsg << ( uint16_t )nY; + *tmpMsg << ( uint16_t )nZ; + *tmpMsg << ( uint16_t )nX; + *tmpMsg << ( uint8_t )nActionStatus; + *tmpMsg << ( uint8_t )0x00; + *tmpMsg << ( uint8_t )nHealth; + *tmpMsg << ( uint8_t )0x00; + *tmpMsg << ( uint8_t )nAction; + + return tmpMsg; + } + +PMessage* PMsgBuilder::BuildNPCMassAliveMsg( uint32_t nWorldID, uint16_t nX, uint16_t nY, uint16_t nZ, uint8_t nActionStatus, uint8_t nHealth, uint8_t nAction ) + { + PMessage* tmpMsg = new PMessage(); + + *tmpMsg << ( uint8_t )0x13; // Begin UDP message + *tmpMsg << ( uint16_t )0x0000; + *tmpMsg << ( uint16_t )0x0000; + *tmpMsg << ( uint8_t )0x11; + *tmpMsg << ( uint8_t )0x1B; + *tmpMsg << ( uint32_t )nWorldID; + *tmpMsg << ( uint8_t )0x1F; + *tmpMsg << ( uint16_t )nY; + *tmpMsg << ( uint16_t )nZ; + *tmpMsg << ( uint16_t )nX; + *tmpMsg << ( uint8_t )nActionStatus; + *tmpMsg << ( uint8_t )0x00; + *tmpMsg << ( uint8_t )nHealth; + *tmpMsg << ( uint8_t )0x00; + *tmpMsg << ( uint8_t )nAction; + + return tmpMsg; + } + +PMessage* PMsgBuilder::BuildNPCMassUpdateMsg( uint32_t nWorldID, uint16_t nX, uint16_t nY, uint16_t nZ, uint8_t nActionStatus, uint8_t nHealth, uint16_t nTarget, uint8_t nAction ) + { + PMessage* tmpMsg = new PMessage(); + + *tmpMsg << ( uint8_t )0x13; // Begin UDP message + *tmpMsg << ( uint16_t )0x0000; + *tmpMsg << ( uint16_t )0x0000; + *tmpMsg << ( uint8_t )0x15; // Message length + *tmpMsg << ( uint8_t )0x1b; + *tmpMsg << ( uint32_t )nWorldID; + *tmpMsg << ( uint8_t )0x1F; + *tmpMsg << ( uint16_t )nY; + *tmpMsg << ( uint16_t )nZ; + *tmpMsg << ( uint16_t )nX; + *tmpMsg << ( uint8_t )nActionStatus; + *tmpMsg << ( uint8_t )0x77; // ? + *tmpMsg << ( uint8_t )nHealth; + *tmpMsg << ( uint16_t )nTarget; + *tmpMsg << ( uint8_t )0x00; // ? + *tmpMsg << ( uint8_t )0x00; // ? + *tmpMsg << ( uint8_t )0x00; // ? + *tmpMsg << ( uint8_t )nAction; + + return tmpMsg; + } + +// ========================== + +PMessage* PMsgBuilder::BuildNPCSingleUpdateMsg( PClient* nClient, uint32_t nWorldID, uint16_t nX, uint16_t nY, uint16_t nZ, uint8_t nActionStatus, uint8_t nHealth, uint16_t nTarget, uint8_t nAction ) + { + PMessage* tmpMsg = new PMessage(); + + *tmpMsg << ( uint8_t )0x13; // Begin UDP message + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x15; // Message length + *tmpMsg << ( uint8_t )0x1b; + *tmpMsg << ( uint32_t )nWorldID; + *tmpMsg << ( uint8_t )0x1F; + *tmpMsg << ( uint16_t )nY; + *tmpMsg << ( uint16_t )nZ; + *tmpMsg << ( uint16_t )nX; + *tmpMsg << ( uint8_t )nActionStatus; + *tmpMsg << ( uint8_t )0x77; // ? + *tmpMsg << ( uint8_t )nHealth; + *tmpMsg << ( uint16_t )nTarget; + *tmpMsg << ( uint8_t )0x00; // ? + *tmpMsg << ( uint8_t )0x00; // ? + *tmpMsg << ( uint8_t )0x00; // ? + *tmpMsg << ( uint8_t )nAction; + + return tmpMsg; + } +// ========================== +PMessage* PMsgBuilder::BuildSubskillIncMsg( PClient* nClient, uint8_t nSubskill, uint16_t nSkillPoints ) +{ + PMessage* tmpMsg = new PMessage( 33 ); + + nClient->IncreaseUDP_ID(); + uint16_t tFirstUDPID = nClient->GetUDP_ID(); + + nClient->IncreaseUDP_ID(); + uint16_t tSecondUDPID = nClient->GetUDP_ID(); + uint16_t tSecondSessionID = nClient->GetSessionID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )tSecondUDPID; + *tmpMsg << ( uint16_t )tSecondSessionID; + + *tmpMsg << ( uint8_t )0x09; // SubMessage length; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )tFirstUDPID; + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x25; + *tmpMsg << ( uint8_t )0x23; + *tmpMsg << ( uint8_t )0x27; + + nClient->IncreaseTransactionID(); + *tmpMsg << ( uint8_t )0x11; // SubMessage length; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )tSecondUDPID; + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x25; + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetTransactionID(); // testing / 0x0000 ???? + *tmpMsg << ( uint8_t )0x09; // ? + *tmpMsg << ( uint16_t )nSubskill; + *tmpMsg << ( uint16_t )nClient->GetChar()->Skill->GetSubSkill( nSubskill ); // nSubskill ? + *tmpMsg << ( uint16_t )nSkillPoints; + + //(*tmpMsg)[5] = (uint8_t)(tmpMsg->GetSize() - 6); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildLevelUpMessage( PClient* nClient, uint8_t nMainSkill, uint8_t nNewLevel, uint16_t nFreeSkillPoints) +{ + PMessage* tmpMsg = new PMessage(21); + nClient->IncreaseUDP_ID(); + + *tmpMsg << (uint8_t)0x13; + *tmpMsg << (uint16_t)nClient->GetUDP_ID(); + *tmpMsg << (uint16_t)nClient->GetSessionID(); + *tmpMsg << (uint8_t)0x0F; + *tmpMsg << (uint8_t)0x03; + *tmpMsg << (uint16_t)nClient->GetUDP_ID(); + *tmpMsg << (uint8_t)0x1F; + *tmpMsg << (uint16_t)nClient->GetLocalID(); + *tmpMsg << (uint8_t)0x25; + *tmpMsg << (uint8_t)0x0B; + *tmpMsg << (uint16_t)nMainSkill; + *tmpMsg << (uint8_t)nNewLevel; + *tmpMsg << (uint16_t)nFreeSkillPoints; + *tmpMsg << (uint8_t)0x00; + *tmpMsg << (uint8_t)0x00; + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildChatAddMsg( PClient* nClient, uint32_t nAddedCharID, uint8_t nMode ) +{ + PMessage* tmpMsg = new PMessage( 18 ); + + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + + *tmpMsg << ( uint8_t )0x00; // Message length placeholder; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x32; + *tmpMsg << ( uint8_t )nMode; + *tmpMsg << ( uint32_t )nAddedCharID; + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildDoorOpenMsg( uint32_t nRawItemID, bool nDoubleDoor ) +{ + //PMessage* tmpMsg = new PMessage(37); + PMessage* tmpMsg = new PMessage( 21 ); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )0x0000; //Client->GetUDP_ID(); // just placeholder, must be set outside + *tmpMsg << ( uint16_t )0x0000; // Client->GetSessionID(); // just placeholder, must be set outside + + *tmpMsg << ( uint8_t )0x0f; // Sub-message length; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )0x0000; //++Client->GetUDP_ID(); // just placeholder, must be set outside + *tmpMsg << ( uint8_t )0x1b; + *tmpMsg << ( uint32_t )nRawItemID; + *tmpMsg << ( uint8_t )0x20; //? + if ( nDoubleDoor ) + { + *tmpMsg << ( uint16_t )0x0005; //? + *tmpMsg << ( uint16_t )0x0000; //? + *tmpMsg << ( uint16_t )0x1500; //? + } + else + { + *tmpMsg << ( uint16_t )0x0000; //? + *tmpMsg << ( uint16_t )0x00c8; //? or 0x64 ? + *tmpMsg << ( uint16_t )0x10ff; //? + } + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +// Message from text.ini, section [MISC], id = 100+nTxtMsgId +PMessage* PMsgBuilder::BuildText100Msg( PClient* nClient, uint8_t nTxtMsgId, uint32_t nRawObjectID ) +{ + PMessage* tmpMsg = new PMessage( 17 ); + + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + + *tmpMsg << ( uint8_t )0x0c; // Message length; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x31; + *tmpMsg << ( uint8_t )nTxtMsgId; + *tmpMsg << ( uint32_t )nRawObjectID; + + //(*tmpMsg)[5] = (uint8_t)(tmpMsg->GetSize() - 6); + + return tmpMsg; +} + +// Same as BuildText100Msg, but here we can specify *ANY* text from text.ini, not limited to section [MISC] +// 1: [DIALOG] +// 2: [STATEMENT] +// 3: [GUI] + [playertextures] +// 4: [TERMINAL] +// 5: [MENU] +// 6: [MISC] +// 7: [ITEMDESC] +// 8: [HELPTEXT] +PMessage* PMsgBuilder::BuildTextIniMsg( PClient* nClient, uint8_t nTxtGroupID, uint16_t nTxtID ) +{ + PMessage* tmpMsg = new PMessage( 20 ); + + nClient->IncreaseUDP_ID(); + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x0e; // Message length + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x25; // ?? + *tmpMsg << ( uint8_t )0x15; // ?? + *tmpMsg << nTxtGroupID; + *tmpMsg << nTxtID; + *tmpMsg << ( uint8_t )0x00; // ?? + *tmpMsg << ( uint8_t )0x00; // ?? + *tmpMsg << ( uint8_t )0x00; // ?? + + //(*tmpMsg)[5] = (uint8_t)(tmpMsg->GetSize() - 6); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildCharInteractionMenuMsg( PClient* nClient, uint32_t nRawTargetID ) +{ + PMessage* tmpMsg = new PMessage( 17 ); + + nClient->IncreaseUDP_ID(); + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x0b; // Message length + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x4d; + *tmpMsg << ( uint32_t )nRawTargetID; + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildFurnitureActivateMsg( PClient* nClient, uint32_t nRawObjectID, uint8_t nActionValue ) +{ + PMessage* tmpMsg = new PMessage( 12 ); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + + *tmpMsg << ( uint8_t )0x06; // SubMessage length; + *tmpMsg << ( uint8_t )0x2d; + *tmpMsg << ( uint32_t )nRawObjectID; + *tmpMsg << ( uint8_t )nActionValue; // known valid are 5 (ring), 9 (remove) and 10 (clic) + + //(*tmpMsg)[5] = (uint8_t)(tmpMsg->GetSize() - 6); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildCharUseFurnitureMsg( PClient* nClient, uint32_t nRawObjectID ) +{ + PMessage* tmpMsg = new PMessage( 24 ); + + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + + *tmpMsg << ( uint8_t )0x06; // SubMessage length; + *tmpMsg << ( uint8_t )0x2d; + *tmpMsg << ( uint32_t )nRawObjectID; + *tmpMsg << ( uint8_t )0x0a; + + *tmpMsg << ( uint8_t )0x0b; // SubMessage length; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x17; + *tmpMsg << ( uint32_t )nRawObjectID; + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildCharUseVhcTerminalMsg( PClient* nClient, uint32_t nRawObjectID ) +{ + PMessage* tmpMsg = new PMessage( 24 ); + + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + + *tmpMsg << ( uint8_t )0x06; // SubMessage length; + *tmpMsg << ( uint8_t )0x2d; + *tmpMsg << ( uint32_t )nRawObjectID; + *tmpMsg << ( uint8_t )0x0a; + + *tmpMsg << ( uint8_t )0x07; // SubMessage length; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x4a; + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildCharUseGogoMsg( PClient* nClient ) +{ + PMessage* tmpMsg = new PMessage( 17 ); + + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + + *tmpMsg << ( uint8_t )0x0b; // Message length; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x3d; + *tmpMsg << ( uint32_t )0x0000000d; // cmd + + //(*tmpMsg)[5] = (uint8_t)(tmpMsg->GetSize() - 6); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildCharUseVentureWarpMsg( PClient* nClient, uint32_t nRawObjectID ) +{ + PMessage* tmpMsg = new PMessage( 17 ); + + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + + *tmpMsg << ( uint8_t )0x0b; // Message length; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x3d; + *tmpMsg << ( uint32_t )0x00000008; // cmd + *tmpMsg << ( uint32_t )0x00000007; // cmd ? + *tmpMsg << ( uint32_t )0x00000002; // ? + *tmpMsg << ( uint16_t )0x0004; // ? + *tmpMsg << nRawObjectID; + // *tmpMsg << (uint8_t)0x13; // ? Seems we can do without... + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildVhcAccessRequestMsg( PClient* nClient, uint32_t nRequestId, uint32_t nRequesterCharId, uint32_t nRequesterLocalId, uint32_t nVhcRawObjectID ) +{ + PMessage* tmpMsg = new PMessage( 40 ); + + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + + *tmpMsg << ( uint8_t )0x22; // Message length; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x3d; + *tmpMsg << ( uint32_t )0x00000008; // cmd + *tmpMsg << ( uint32_t )0x00000005; // cmd ? + *tmpMsg << ( uint32_t )nRequestId; + *tmpMsg << ( uint16_t )0x000c; // ? length ? + *tmpMsg << nRequesterCharId; //uint32_t + *tmpMsg << nRequesterLocalId; // ? uint32_t + *tmpMsg << nVhcRawObjectID; + *tmpMsg << ( uint8_t )0x08; // ? + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} +/* S->C +13:ff:00:72:d6:22: +03:ff:00:1f:03:00: +3d: +08:00:00:00: +05:00:00:00: +01:00:00:00: +0c:00: +2f:d8:01:00: +02:00:00:00: +5d:03:00:00: +08: +*/ + +/* C->S RESP: OK +13:79:00:ec:d5:17: +03:79:00:1f:03:00: +3d: +09:00:00:00: +06:00:00:00: +02:00:00:00: +01:00: +01:00 +*/ +/* C->S RESP: NOK +13:74:00:e7:d5:17: +03:74:00:1f:03:00: +3d: +09:00:00:00: +06:00:00:00: +01:00:00:00: +01:00: +00:00 + +*/ + +PMessage* PMsgBuilder::BuildCharUseGenrepMsg( PClient* nClient, uint32_t nRawObjectID, uint32_t nLocation, uint16_t nEntity ) +{ + PMessage* tmpMsg = new PMessage( 24 ); + + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + + *tmpMsg << ( uint8_t )0x06; // SubMessage length; + *tmpMsg << ( uint8_t )0x2d; + *tmpMsg << ( uint32_t )nRawObjectID; + *tmpMsg << ( uint8_t )0x0a; + + // this submessage is only needed to set to location/entity of the GR for a potential record in the char's GR list + *tmpMsg << ( uint8_t )0x0d; // SubMessage length; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x2d; + *tmpMsg << ( uint32_t )nLocation; + *tmpMsg << ( uint16_t )nEntity; + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildCharUseLiftMsg( PClient* nClient, uint32_t nRawObjectID, uint16_t nAptPlace ) +{ + PMessage* tmpMsg = new PMessage( 29 ); + + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + + *tmpMsg << ( uint8_t )0x06; // SubMessage length; + *tmpMsg << ( uint8_t )0x2d; + *tmpMsg << ( uint32_t )nRawObjectID; + *tmpMsg << ( uint8_t )0x0a; + + *tmpMsg << ( uint8_t )0x11; // SubMessage length; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x38; + *tmpMsg << ( uint8_t )0x01; + *tmpMsg << ( uint32_t )nRawObjectID; + *tmpMsg << ( uint16_t )nAptPlace; + *tmpMsg << ( uint16_t )0x0000; + *tmpMsg << ( uint8_t )0x00; + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildCharShowGlowCircleMsg( PClient* nClient ) +{ + PMessage* tmpMsg = new PMessage( 14 ); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )0x0000; // UDP ID placeholder + *tmpMsg << ( uint16_t )0x0000; // SessionID placeholder + *tmpMsg << ( uint8_t )0x08; // Len (static, always 0x08 + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )0x0000; // Sub UDP ID placeholder + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x3c; // Command SHOW GLOWING CIRCLE (kinda ^^) + *tmpMsg << ( uint8_t )0x01; // "on" ? + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildCharMoneyUpdateMsg( PClient* nClient, uint32_t nCredits ) +{ + PMessage* tmpMsg = new PMessage( 21 ); + nClient->IncreaseUDP_ID(); + nClient->IncreaseTransactionID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x0f; // Message length + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x25; // cmd + *tmpMsg << ( uint8_t )0x13; // cmd + *tmpMsg << ( uint16_t )nClient->GetTransactionID(); + *tmpMsg << ( uint8_t )0x04; // cmd + *tmpMsg << nCredits; + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildUndefineduseMsg( PClient* nClient, uint8_t nValue ) +{ + PMessage* tmpMsg = new PMessage( 15 ); + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x09; // Message length + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x25; + *tmpMsg << ( uint8_t )0x23; + *tmpMsg << nValue; + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildCharUseQBSlotMsg2( PClient* nClient, uint16_t nV1, uint16_t nV2, uint16_t nV3, uint16_t nV4, uint16_t nV5, uint16_t nV6, uint16_t nV7 ) +{ + // lol? Whats this? + PMessage* tmpMsg = new PMessage( 28 ); + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x16; // Message length + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x25; // cmd + *tmpMsg << ( uint8_t )0x22; // cmd + *tmpMsg << nV1; + *tmpMsg << nV2; + *tmpMsg << nV3; + *tmpMsg << nV4; + *tmpMsg << nV5; + *tmpMsg << nV6; + *tmpMsg << nV7; + /* *tmpMsg << (uint8_t)0x64; // ?? + *tmpMsg << (uint8_t)0x00; // ?? + *tmpMsg << (uint8_t)0x64; // ?? + *tmpMsg << (uint8_t)0x00; // ?? + *tmpMsg << (uint8_t)0x64; // ?? + *tmpMsg << (uint8_t)0x00; // ?? + *tmpMsg << (uint8_t)0x64; // ?? + *tmpMsg << (uint8_t)0x00; // ?? + *tmpMsg << (uint8_t)0x64; // ?? + *tmpMsg << (uint8_t)0x00; // ?? + *tmpMsg << (uint8_t)0x64; // ?? + *tmpMsg << (uint8_t)0x00; // ?? + *tmpMsg << (uint8_t)0x00; // ?? + *tmpMsg << (uint8_t)0x00; // ?? + */ + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildCharUseQBSlotMsg3( PClient* nClient, uint8_t nSlot ) +{ + PMessage* tmpMsg = new PMessage( 19 ); + nClient->IncreaseUDP_ID(); + nClient->IncreaseTransactionID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x0d; // Message length + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x25; // cmd + *tmpMsg << ( uint8_t )0x13; // cmd + *tmpMsg << ( uint16_t )nClient->GetTransactionID(); + *tmpMsg << ( uint8_t )0x0b; // cmd + *tmpMsg << nSlot; // ?? + *tmpMsg << ( uint8_t )0x00; // ?? + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildCharUseQBSlotMsg4( PClient* nClient, uint16_t nWeaponId ) +{ + PMessage* tmpMsg = new PMessage( 16 ); + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x0a; // Message length + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x2f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x02; // ?? + *tmpMsg << ( uint8_t )0x02; // ?? + *tmpMsg << nWeaponId; + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildContainerContentList( PContainer* nContainer, uint8_t nLocType ) +{ + PMessage* tmpMsg = new PMessage( 256 ); + std::vector< PContainerEntry* >* Entries = nContainer->GetEntries(); + PContainerEntry* tEntry; + PMessage* entryMsg; + +//Console->Print(YELLOW, BLACK, "BuildContainerContentList for loc %d", nLocType); + if ( nLocType != INV_LOC_BOX ) + { + if ( nLocType == INV_LOC_BACKPACK ) + *tmpMsg << ( uint16_t )Entries->size(); // items nb + else + *tmpMsg << ( uint8_t )Entries->size(); // items nb + } + + for ( uint16_t i = 0; i < Entries->size(); ++i ) + { + tEntry = Entries->at( i ); + entryMsg = BuildContainerContentEntry( tEntry, nLocType ); +//if(tEntry->mItem->mItemID == 390) +//{ +//Console->Print(YELLOW, BLACK, "BuildContainerContentList entry %d - size %d", i, entryMsg->GetSize()); +//entryMsg->Dump(); +//} + *tmpMsg << *entryMsg; + delete entryMsg; + } + + delete Entries; + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildContainerContentEntry( PContainerEntry* nEntry, uint8_t nLocType ) +{ + PMessage* tmpMsg = new PMessage( 16 ); + PItem* tItem; + uint8_t dataFlags, Qualifier; + + tItem = nEntry->mItem; + dataFlags = Qualifier = 0x00 ; + + if (( tItem->mItemID == 390 ) /* testing */ || tItem->mLoadedAmmoNb ) + { + dataFlags |= 0x01; + } + if (( tItem->GetType() == ITEM_TYPE_WEAPON ) || ( tItem->GetType() == ITEM_TYPE_BLUEPRINT ) || ( tItem->GetType() == ITEM_TYPE_WRECKEDPART )/*|| (tItem->GetType() == ITEM_TYPE_APARTMENTKEY) || (tItem->GetType() == ITEM_TYPE_CLANKEY) || (tItem->GetType() == ITEM_TYPE_VHCKEY) */ ) // testing loaded ammo type & BP attributes + { + dataFlags |= 0x20; + } + + switch ( tItem->GetType() ) + { + case ITEM_TYPE_WEAPON: + case ITEM_TYPE_AUTOWEAPON: + Qualifier = 6; + dataFlags |= 0x02; + break; + case ITEM_TYPE_IMPLANT: + case ITEM_TYPE_ARMOR: + Qualifier = 2; + dataFlags |= 0x02; + break; + default: + Qualifier = 0; + break; + } + + if ( tItem->IsStackable() && tItem->mStackSize ) + { + dataFlags |= 0x04; + } + + if (( tItem->mModificators ) || ( tItem->mItemID == 390 ) ) // TEST + dataFlags |= 0x10; + + if ( tItem->mMaxSlots || ( tItem->mItemID == 390 ) ) // TEST + dataFlags |= 0x40; + + + + if ( nLocType == INV_LOC_BOX ) + *tmpMsg << ( uint8_t )0x00; // Size of item placeholder + else + *tmpMsg << ( uint16_t )0x0000; // Size of item placeholder + + switch ( nLocType ) + { + case INV_LOC_WORN: + *tmpMsg << ( uint8_t )nEntry->mPosX; // X Location + *tmpMsg << ( uint8_t )0x00; // just nothing + break; + case INV_LOC_BACKPACK: + *tmpMsg << ( uint8_t )0x00; // just nothing again + *tmpMsg << ( uint8_t )nEntry->mPosX; // X Location + *tmpMsg << ( uint8_t )nEntry->mPosY; // Y Location + break; + case INV_LOC_GOGO: + *tmpMsg << ( uint8_t )nEntry->mPosX; + break; + case INV_LOC_BOX: + case INV_LOC_BOX2: + break; + default: + break; + } + + *tmpMsg << ( uint16_t )tItem->mItemID; // ItemID + *tmpMsg << ( uint8_t )dataFlags; // (0x01|0x02|0x04|0x10|0x20|0x40|0x80); // Datatypes + + if ( dataFlags & 0x01 ) + { + if ( tItem->GetType() == ITEM_TYPE_WEAPON ) // TESTING + *tmpMsg << ( uint8_t )6; // Remaining ammos + else + *tmpMsg << ( uint8_t )tItem->mLoadedAmmoNb; // Remaining ammos + } + + if ( dataFlags & 0x02 ) + { + *tmpMsg << ( uint8_t )Qualifier; // Qual entries + if ( Qualifier >= 2 ) + { + *tmpMsg << ( uint8_t )tItem->mCurDuration; // current qual + if ( Qualifier == 6 ) + { + *tmpMsg << ( uint8_t )tItem->mDamages; // dmg + *tmpMsg << ( uint8_t )tItem->mFrequency; // freq + *tmpMsg << ( uint8_t )tItem->mHandling; // handl + *tmpMsg << ( uint8_t )tItem->mRange; // range + } + *tmpMsg << ( uint8_t )tItem->mMaxDuration; // max qual + } + } + + if ( dataFlags & 0x10 ) + { + if ( tItem->mItemID == 390 ) // test + *tmpMsg << ( uint8_t )4; + else + *tmpMsg << ( uint8_t )tItem->mModificators; // addons bitflag: flashlight=1, scope, silencer, laserpointer + } + + if ( dataFlags & 0x40 ) + { + if ( tItem->mItemID == 390 ) // test + { + *tmpMsg << ( uint8_t )3; + *tmpMsg << ( uint8_t )3; + *tmpMsg << ( uint16_t )0x000b; // enlarged + *tmpMsg << ( uint16_t )0x05de; // phosophore + *tmpMsg << ( uint16_t )( -3 ); // silencer + } + else + { + + *tmpMsg << ( uint8_t )tItem->mUsedSlots; // used slots + *tmpMsg << ( uint8_t )tItem->mMaxSlots; // max slots + for ( uint8_t j = 0; j < tItem->mMaxSlots; ++j ) + *tmpMsg << ( uint16_t )(( j < tItem->mUsedSlots ) ? tItem->mSlot[j] : 0 ); // mod in slot + } + } + + if ( dataFlags & 0x20 ) // loaded ammo type ???? + { + uint16_t lengthFieldOffset = tmpMsg->GetNextByteOffset(); + *tmpMsg << ( uint16_t )0x0000; // length placeholder + + if ( tItem->GetType() == ITEM_TYPE_WEAPON ) + { + *tmpMsg << ( uint8_t )0x01; // ammo info + *tmpMsg << ( uint8_t )0x04; // total length ? + *tmpMsg << ( uint8_t )0x00; // + baseammo => current ammoId. 0xff => undefined + *tmpMsg << ( uint8_t )0xff; // supported ammos bitmap (all here) + } + + if ( false && ( tItem->GetType() == ITEM_TYPE_APARTMENTKEY ) ) // activated Apartment key + { + *tmpMsg << ( uint8_t )0x02; // ammo info + *tmpMsg << ( uint8_t )0x06; // total length + *tmpMsg << ( uint32_t )123456; // apartmentObjectID ? + } + + if ( false && ( tItem->GetType() == ITEM_TYPE_CLANKEY ) ) // activated ClanKey + { + *tmpMsg << ( uint8_t )0x04; // BP of... info + *tmpMsg << ( uint8_t )0x0a; // total length + *tmpMsg << ( uint32_t )1234; // ClanID ? + *tmpMsg << ( uint32_t )123456; // apartmentObjectID ? + } + + if ( tItem->GetType() == ITEM_TYPE_BLUEPRINT ) // BP + { + *tmpMsg << ( uint8_t )0x05; // BP of... info + *tmpMsg << ( uint8_t )0x06; // total length + *tmpMsg << ( uint32_t )486; // ItemID ("Tangent Sniper Rifle") + } + + if ( false && ( tItem->GetType() == ITEM_TYPE_VHCKEY ) ) // activated VHC Key + { + *tmpMsg << ( uint8_t )0x08; // VHC Key + *tmpMsg << ( uint8_t )0x0a; // total length + *tmpMsg << ( uint32_t )654321; // vhcObjectID ? + *tmpMsg << ( uint32_t )123456; // Owner CharID ? + } + + if ( false && ( tItem->GetType() == ITEM_TYPE_WRECKEDPART ) ) // Identified rare part + { + *tmpMsg << ( uint8_t )0x09; // Rare part + *tmpMsg << ( uint8_t )0x05; // total length + *tmpMsg << ( uint16_t )453; // Rare Item ID ? REDEEMER + *tmpMsg << ( uint8_t )0; // ?? + } + + if (( tItem->mConstructorId ) || ( tItem->mItemID == 390 ) ) // Named item /itemId 390: test + { + *tmpMsg << ( uint8_t )0x0a; // constructor info + *tmpMsg << ( uint8_t )0x06; // total length + //*tmpMsg << (uint32_t)tItem->mConstructorId; // charID + *tmpMsg << ( uint32_t )2; + } + + tmpMsg->U16Data( lengthFieldOffset ) = tmpMsg->GetNextByteOffset() - lengthFieldOffset - 2; + } + + if ( dataFlags & 0x04 ) + { + *tmpMsg << ( uint32_t )tItem->mStackSize; + } + + + if ( nLocType == INV_LOC_BOX ) + tmpMsg->U8Data( 0 ) = tmpMsg->GetSize() - 1; + else + tmpMsg->U16Data( 0 ) = tmpMsg->GetSize() - 2; + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildCharOpenContainerMsg( PClient* nClient, uint32_t nContainerID, PContainer* nContainer ) +{ + PMessage* ContentList = BuildContainerContentList( nContainer, INV_LOC_BOX ); + + PMessage* tmpMsg = new PMessage(); + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x00; // Message length + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x26; + *tmpMsg << nContainerID; + *tmpMsg << ( uint8_t )0x00; // Always the same on item containers? // 0x01 for Trader (NeoX gameclient 3608) + *tmpMsg << ( uint8_t )0x64; // Always the same on item containers? + *tmpMsg << ( uint8_t )0x00; // Always the same on item containers? + *tmpMsg << ( uint8_t )0x08; // 0x08 when container is filled, 0x00 when not? At least it works.. + + *tmpMsg << ( uint16_t )( ContentList->GetSize() ); + *tmpMsg << *ContentList; + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + delete ContentList; + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildItemMoveMsg( PClient* nClient, uint8_t nSource, uint8_t nSrcX, uint8_t nSrcY, uint8_t nDestination, uint8_t nDestX, uint8_t nDestY, uint8_t nItemCnt ) +{ + PMessage* tmpMsg = new PMessage( 26 ); + nClient->IncreaseUDP_ID(); + nClient->IncreaseTransactionID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x14; // Message length + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x25; + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetTransactionID(); + *tmpMsg << ( uint8_t )0x14; // ItemMove Answer + *tmpMsg << nSource; + *tmpMsg << nSrcX; + *tmpMsg << nSrcY; + *tmpMsg << nDestination; + *tmpMsg << nDestX; + *tmpMsg << nDestY; + *tmpMsg << nItemCnt; + *tmpMsg << ( uint8_t )0x00; // ?? + *tmpMsg << ( uint8_t )0x00; // ?? + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildBoxItemMoveMsg( PClient* nClient, PContainerEntry* nEntry, uint8_t nSrcX, uint8_t nSrcY, uint8_t nDestination, uint8_t nDestX, uint8_t nDestY, uint8_t nItemCnt ) +{ + PMessage* tmpMsg = new PMessage( 64 ); + PMessage* entryMsg = BuildContainerContentEntry( nEntry, INV_LOC_BOX2 ); + + nClient->IncreaseUDP_ID(); + nClient->IncreaseTransactionID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + + *tmpMsg << ( uint8_t )0x09; // Message length + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x25; + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetTransactionID(); + *tmpMsg << ( uint8_t )0x17; // BoxItemMove Answer Src + *tmpMsg << ( uint8_t )INV_LOC_BOX; // Src = Box + *tmpMsg << nSrcX; + *tmpMsg << nSrcY; + *tmpMsg << nItemCnt; + *tmpMsg << ( uint8_t )0x00; // Qty high + *tmpMsg << ( uint8_t )0x18; // BoxItemMove Answer Dst + *tmpMsg << nDestination; + *tmpMsg << nDestX; + *tmpMsg << nDestY; + *tmpMsg << *entryMsg; + *tmpMsg << ( uint8_t )0x12; // ? vary ... + *tmpMsg << ( uint8_t )0x00; + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + delete entryMsg; + return tmpMsg; +} + +/*PMessage* PMsgBuilder::BuildItemAmmoUpdateMsg (PClient* nClient, PContainerEntry* nEntry, uint8_t nSrcX, uint8_t nSrcY, uint8_t nDestination, uint8_t nDestX, uint8_t nDestY, uint8_t nItemCnt) +{ + PMessage* tmpMsg = new PMessage(64); + PMessage* entryMsg = BuildContainerContentEntry(nEntry, INV_LOC_BOX2); + + nClient->IncreaseUDP_ID(); + nClient->IncreaseTransactionID(); + + *tmpMsg << (uint8_t)0x13; + *tmpMsg << (uint16_t)nClient->GetUDP_ID(); + *tmpMsg << (uint16_t)nClient->GetSessionID(); + + *tmpMsg << (uint8_t)0x09; // Message length + *tmpMsg << (uint8_t)0x03; + *tmpMsg << (uint16_t)nClient->GetUDP_ID(); + *tmpMsg << (uint8_t)0x1f; + *tmpMsg << (uint16_t)nClient->GetLocalID(); + *tmpMsg << (uint8_t)0x25; + *tmpMsg << (uint8_t)0x13; + *tmpMsg << (uint16_t)nClient->GetTransactionID(); + *tmpMsg << (uint8_t)0x17; // BoxItemMove Answer Src + *tmpMsg << (uint8_t)INV_LOC_BOX; // Src = Box + *tmpMsg << nSrcX; + *tmpMsg << nSrcY; + *tmpMsg << nItemCnt; + *tmpMsg << (uint8_t)0x00; // Qty high + *tmpMsg << (uint8_t)0x18; // BoxItemMove Answer Dst + *tmpMsg << nDestination; + *tmpMsg << nDestX; + *tmpMsg << nDestY; + *tmpMsg << *entryMsg; + *tmpMsg << (uint8_t)0x12; // ? vary ... + *tmpMsg << (uint8_t)0x00; + + (*tmpMsg)[5] = (uint8_t)(tmpMsg->GetSize() - 6); + + delete entryMsg; + return tmpMsg; +}*/ +/* Resp: +03:33:00:1f:01:00:25:13 +c2:01:0a:00:02:00:00:00 ?? +c3:01:05:03:00:00:12 Update ammo left +c4:01:05:02:00:00:0c Update ammo left +*/ + +PMessage* PMsgBuilder::BuildStartHackGameMsg( PClient* nClient, uint32_t nWorldObjID, uint8_t nHackDifficult ) +{ + PMessage* tmpMsg = new PMessage( 22 ); + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x10; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x28; + *tmpMsg << nWorldObjID; + *tmpMsg << nHackDifficult; + *tmpMsg << ( uint8_t )0x28; + *tmpMsg << ( uint8_t )0x5c; + *tmpMsg << ( uint8_t )0xcf; + *tmpMsg << ( uint8_t )0x3e; + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildSubwaySpawnMsg( PClient* nClient, bool IsSecondMessage ) +{ + PMessage* tmpMsg = new PMessage( 197 ); + uint16_t First = IsSecondMessage ? 6 : 0; + uint16_t Last = IsSecondMessage ? 10 : 5; + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )0x0000; // placeholder for UDP_ID; + *tmpMsg << ( uint16_t )0x0000; // placeholder for SessionID(); + + for ( uint16_t i = First; ( i <= Last ); i++ ) + { + nClient->IncreaseUDP_ID(); + *tmpMsg << ( uint8_t )0x11; //msg size + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x28; + *tmpMsg << ( uint16_t )0x0027; + *tmpMsg << ( uint32_t )( PSubway::mCabsBaseId + i ); + *tmpMsg << ( uint16_t )0x0000; + *tmpMsg << ( uint8_t )0x00; + *tmpMsg << ( uint16_t )Subway->mSubways[i].mPosition; + *tmpMsg << ( uint8_t )0x00; + *tmpMsg << ( uint8_t )Subway->mSubways[i].mDoorOpened;; + + nClient->IncreaseUDP_ID(); // vhc health update + *tmpMsg << ( uint8_t )0x0d; //msg size + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x2d; + *tmpMsg << ( uint32_t )( PSubway::mCabsBaseId + i ); + *tmpMsg << ( uint8_t )0x0a; + *tmpMsg << ( uint32_t )PSubway::mCabsBaseHealth; + } + + tmpMsg->U16Data( 1 ) = nClient->GetUDP_ID(); + tmpMsg->U16Data( 3 ) = nClient->GetSessionID(); + + return tmpMsg; +} + +/* +PMessage* PMsgBuilder::BuildSubwayFullUpdateMsg(PClient* nClient) +{ + PMessage* tmpMsg = new PMessage(148); + *tmpMsg << (uint8_t)0x13; + *tmpMsg << (uint16_t)0x0000; // placeholder for UDP_ID; + *tmpMsg << (uint16_t)0x0000; // placeholder for SessionID(); + + for(uint8_t i=0; iIncreaseUDP_ID(); + *tmpMsg << (uint8_t)0x0c; //msg size + *tmpMsg << (uint8_t)0x03; + *tmpMsg << (uint16_t)nClient->GetUDP_ID(); + *tmpMsg << (uint8_t)0x32; + *tmpMsg << (uint32_t)(PSubway::mCabsBaseId + i); + *tmpMsg << (uint8_t)0x00; + *tmpMsg << (uint16_t)Subway->mSubways[i].mPosition; + *tmpMsg << (uint8_t)Subway->mSubways[i].mDoorOpened;; + } + + tmpMsg->U16Data(1) = nClient->GetUDP_ID(); + tmpMsg->U16Data(3) = nClient->GetSessionID(); + + return tmpMsg; +} +*/ + +PMessage* PMsgBuilder::BuildSubwaySingleUpdateMsg( uint32_t nVehicleID, uint16_t nPosition, uint8_t nDoorOpened ) +{ + PMessage* tmpMsg = new PMessage( 18 ); + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )0x0000; // placeholder for UDP_ID; + *tmpMsg << ( uint16_t )0x0000; // placeholder for SessionID(); + + *tmpMsg << ( uint8_t )0x0c; //msg size + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )0x0000; // ++UDP_ID placeholder + *tmpMsg << ( uint8_t )0x32; + *tmpMsg << ( uint32_t )nVehicleID; + *tmpMsg << ( uint8_t )0x00; + *tmpMsg << ( uint16_t )nPosition; + *tmpMsg << ( uint8_t )nDoorOpened; + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildSpawnWorldObjectMsg( uint16_t nModelID, uint16_t nFunctionID, uint32_t nWOID, uint16_t nPosX, uint16_t nPosY, uint16_t nPosZ, uint8_t nRotX, uint8_t nRotY, uint8_t nRotZ ) +{ + PMessage* tmpMsg = new PMessage( 31 ); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )0x0000; // UDP placeholder + *tmpMsg << ( uint16_t )0x0000; // Session placeholder + *tmpMsg << ( uint8_t )0x16; // Message length + *tmpMsg << ( uint8_t )0x03; // 0x03 commandset + *tmpMsg << ( uint16_t )0x0000; // UDP placeholder + *tmpMsg << ( uint8_t )0x1b; // Subcommandset + *tmpMsg << ( uint32_t )nWOID; // WorldobjectID + + *tmpMsg << ( uint8_t )0x19; // Positiondata follows + *tmpMsg << ( uint16_t )nPosY; + *tmpMsg << ( uint16_t )nPosZ; + *tmpMsg << ( uint16_t )nPosX; + *tmpMsg << ( uint8_t )nRotY; // Rotation X + *tmpMsg << ( uint8_t )nRotZ; // Rotation Y + *tmpMsg << ( uint8_t )nRotX; // Rotation Z + *tmpMsg << ( uint16_t )nModelID; + *tmpMsg << ( uint16_t )nFunctionID; + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildRemoveWorldObjectMsg( uint32_t nWOID ) +{ + PMessage* tmpMsg = new PMessage( 14 ); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )0x0000; // UDP ID placeholder + *tmpMsg << ( uint16_t )0x0000; // SessionID placeholder + *tmpMsg << ( uint8_t )0x08; // Len (static, always 0x08 + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )0x0000; // Sub UDP ID placeholder + *tmpMsg << ( uint8_t )0x26; // Command FADE AWAY CHAR (kinda ^^) + *tmpMsg << ( uint32_t )nWOID; // WorldobjectID + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildDBRequestStatusMsg( PClient* nClient, std::string *nCommandName, uint8_t nStatus, uint16_t nErrCode ) +{ + PMessage* tmpMsg = new PMessage( 32 ); + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x14; // Message length + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x2b; + *tmpMsg << ( uint8_t )0x1a; + *tmpMsg << ( uint16_t )( nCommandName->size() + 1 ); + *tmpMsg << ( uint8_t )nStatus; + *tmpMsg << ( uint16_t )nErrCode; + *tmpMsg << ( *nCommandName ); + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildDBAnswerMsg( PClient* nClient, std::string *nCommandName, std::string *nAnswerData, uint16_t nRows, uint16_t nCols ) +{ + uint8_t i, j, k; + PMessage* tmpMsg = new PMessage( 32 ); + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x14; // Message length + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x2b; + *tmpMsg << ( uint8_t )0x17; + *tmpMsg << ( uint16_t )( nCommandName->size() + 1 ); + *tmpMsg << ( uint16_t )nRows; + *tmpMsg << ( uint16_t )nCols; + *tmpMsg << ( *nCommandName ); + + for ( i = 0, k = 0; i < nRows; ++i ) + { + for ( j = 0; j < nCols; ++j, ++k ) + { + *tmpMsg << ( uint16_t )( nAnswerData[k].size() + 1 ); + *tmpMsg << nAnswerData[k]; + } + } + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildCharUseVhcMsg( PClient* nClient, uint32_t nRawObjectID, uint16_t nVhcType, uint16_t nAvailableSeats ) +{ + PMessage* tmpMsg = new PMessage( 24 ); + + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + + *tmpMsg << ( uint8_t )0x13; // Message length; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x3d; + *tmpMsg << ( uint32_t )0x0000000e; // cmd + *tmpMsg << nRawObjectID; + *tmpMsg << nVhcType; + *tmpMsg << nAvailableSeats; // Bit flags + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildVhcInfoMsg( PClient* nClient, PSpawnedVehicle* nVehicle ) +{ + PMessage* tmpMsg = new PMessage( 32 ); + PVhcCoordinates VhcPos = nVehicle->GetPosition(); + PVehicleInformation VhcInfo = nVehicle->GetInformation(); + + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + + *tmpMsg << ( uint8_t )0x00; // Message length placeholder; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x28; + *tmpMsg << ( uint16_t )0x0031; + *tmpMsg << ( uint32_t )nVehicle->GetLocalId(); + *tmpMsg << ( uint8_t )0x02; + *tmpMsg << ( uint16_t )( VhcPos.GetY() + 768 ); + *tmpMsg << ( uint16_t )( VhcPos.GetZ() + 768 ); + *tmpMsg << ( uint16_t )( VhcPos.GetX() + 768 ); + *tmpMsg << ( uint8_t )VhcPos.GetUD(); + *tmpMsg << ( uint16_t )VhcPos.GetLR(); + *tmpMsg << ( uint16_t )VhcPos.GetRoll(); + *tmpMsg << ( uint8_t )VhcInfo.GetVehicleType(); + *tmpMsg << ( uint8_t )0xff; + *tmpMsg << ( uint32_t )0x00000000; + *tmpMsg << ( uint16_t )0x0000; + *tmpMsg << ( uint8_t )0x00; + *tmpMsg << ( uint8_t )0x01; // ? changes + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +/*PMessage* PMsgBuilder::BuildVhcInfoMsg( PClient* nClient, PSpawnedVehicle* nVehicle ) +{ + PMessage* tmpMsg = new PMessage( 32 ); + PVhcCoordinates VhcPos = nVehicle->GetPosition(); + PVehicleInformation VhcInfo = nVehicle->GetInformation(); + + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + + *tmpMsg << ( uint8_t )0x00; // Message length placeholder; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x28; + *tmpMsg << ( uint16_t )0x0031; + *tmpMsg << ( uint32_t )nVehicle->GetLocalId(); + *tmpMsg << ( uint8_t )0x02; + *tmpMsg << ( uint16_t )( VhcPos.GetY() + 768 ); + *tmpMsg << ( uint16_t )( VhcPos.GetZ() + 768 ); + *tmpMsg << ( uint16_t )( VhcPos.GetX() + 768 ); + *tmpMsg << ( uint8_t )VhcPos.GetUD(); + *tmpMsg << ( uint16_t )VhcPos.GetLR(); + *tmpMsg << ( uint16_t )VhcPos.GetRoll(); + *tmpMsg << ( uint8_t )VhcInfo.GetVehicleType(); + *tmpMsg << ( uint32_t )0x00000000; + *tmpMsg << ( uint32_t )0x00000000; + *tmpMsg << ( uint32_t )0x00000000; + *tmpMsg << ( uint16_t )0x0000; + uint32_t tCharId; + for(uint8_t i = 0; i < 8; ++i) + { + if( (tCharId = nVehicle->GetSeatUser(i)) ) + { + *tmpMsg << tCharId; + } + else + { + *tmpMsg << ( uint32_t )0xffffffff; + } + *tmpMsg << i; + *tmpMsg << ( uint16_t )0x0000; + } + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +}*/ +/* ???? +13 f7 00 49 bf +5d +03 f7 00 +28 31 00 +c9 03 00 00 = Object ID +02 +47 ff +00 cd +c3 c3 +d7 +d7 ec +00 00 +29 +2b 65 35 8b 8c 6c 7f 80 96 +5f 26 00 80 00 +ff ff ff ff 00 00 00 +ff ff ff ff 01 00 00 +ff ff ff ff 02 00 00 +ff ff ff ff 03 00 00 +ff ff ff ff 04 00 00 +ff ff ff ff 05 00 00 +ff ff ff ff 06 00 00 +ff ff ff ff 07 00 00 + +*/ + +PMessage* PMsgBuilder::BuildVhcHealthUpdateMsg( PSpawnedVehicle* nVehicle ) +{ + PMessage* tmpMsg = new PMessage( 19 ); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )0x0000; // placeholder for UDP_ID; + *tmpMsg << ( uint16_t )0x0000; // placeholder for SessionID(); + + *tmpMsg << ( uint8_t )0x0d; //msg size + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )0x0000; // placeholder for ++UDP_ID + *tmpMsg << ( uint8_t )0x2d; + *tmpMsg << ( uint32_t )nVehicle->GetLocalId(); + *tmpMsg << ( uint8_t )0x0a; // Health update + *tmpMsg << ( float )( nVehicle->GetInformation().GetHealth() ); + + return tmpMsg; +} + +// NB: same as BuildCharSittingMsg. To be merged later when classes are adapted +PMessage* PMsgBuilder::BuildVhcPosUpdateMsg( PSpawnedVehicle* nVehicle ) +{ + PMessage* tmpMsg = new PMessage( 33 ); + PVhcCoordinates VhcPos = nVehicle->GetPosition(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )0x0000; //Client->GetUDP_ID(); // just placeholder, must be set outside + *tmpMsg << ( uint16_t )0x0000; // Client->GetSessionID(); // just placeholder, must be set outside + + *tmpMsg << ( uint8_t )0x00; // Message length placeholder; + *tmpMsg << ( uint8_t )0x32; + *tmpMsg << ( uint16_t )( nVehicle->GetLocalId() & 0xffff ); + *tmpMsg << ( uint8_t )0x03; // We suppose we use move type 3, as in client message + *tmpMsg << ( uint16_t )( VhcPos.GetY() + 768 ); // +768 or +0 ??? All Char/Vhc/NPC/Objet offset to clean up... + *tmpMsg << ( uint16_t )( VhcPos.GetZ() + 768 ); + *tmpMsg << ( uint16_t )( VhcPos.GetX() + 768 ); + *tmpMsg << ( uint8_t )VhcPos.GetUD(); + *tmpMsg << ( uint16_t )VhcPos.GetLR(); + *tmpMsg << ( uint16_t )VhcPos.GetRoll(); + *tmpMsg << ( uint16_t )VhcPos.GetUnknown(); + *tmpMsg << ( uint8_t )0x00; + *tmpMsg << ( uint8_t )VhcPos.GetAct(); + /* What is that for ???? + *tmpMsg << ( uint8_t )0x02; // <= these two uint8_t corresond to mUnknown... = additionnal data ? + *tmpMsg << ( uint8_t )0x00; // maybe weapon related ? + *tmpMsg << ( uint16_t )0x0000; + *tmpMsg << ( uint16_t )0x0001; + *tmpMsg << ( uint16_t )0x8000; + *tmpMsg << ( uint16_t )0x8000; + */ + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildVhcPosUpdate2Msg( PSpawnedVehicle* nVehicle ) +{ + PMessage* tmpMsg = new PMessage( 28 ); + PVhcCoordinates VhcPos = nVehicle->GetPosition(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )0x0000; // placeholder for UDP_ID; + *tmpMsg << ( uint16_t )0x0000; // placeholder for SessionID(); + + *tmpMsg << ( uint8_t )0x00; //msg size + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )0x0000; // ++UDP_ID placeholder + *tmpMsg << ( uint8_t )0x32; + *tmpMsg << ( uint16_t )( nVehicle->GetLocalId() & 0xffff ); + *tmpMsg << ( uint8_t )0x03; // 0x07 in nc2.2, and one more field (same a received msg) + *tmpMsg << ( uint16_t )( VhcPos.GetY() + 768 ); // +768 or +0 ??? All Char/Vhc/NPC/Objet offset to clean up... + *tmpMsg << ( uint16_t )( VhcPos.GetZ() + 768 ); + *tmpMsg << ( uint16_t )( VhcPos.GetX() + 768 ); + *tmpMsg << ( uint8_t )VhcPos.GetUD(); + *tmpMsg << ( uint16_t )VhcPos.GetLR(); + *tmpMsg << ( uint16_t )VhcPos.GetRoll(); + *tmpMsg << ( uint16_t )VhcPos.GetUnknown(); + *tmpMsg << ( uint8_t )VhcPos.GetFF(); + *tmpMsg << ( uint8_t )VhcPos.GetAct(); + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +/* +ground vhc in NC1 +C->S +[...] 32:fb:03:03:d4:8c:2f:84:a0:7b:7b:bf:c6:53:28:01:00:ff:05 +S->C +[...] 32: fb:03: 03: d4:8c: 2f:84: a0:7b: 7b: bf:c6: 53:28: 01:00:ff:05 + + *nMsg >> mVhcLocalId; + *nMsg >> mMoveType; // 0 for subway, 3 for nc1 vhc, 7 for nc2 vhc // uint8_t + *nMsg >> mNewY; + *nMsg >> mNewZ; + *nMsg >> mNewX; + *nMsg >> mNewUD; // uint8_t + *nMsg >> mNewLR; + *nMsg >> mNewRoll; + *nMsg >> mUnk1; + *nMsg >> mFF; // uint8_t + *nMsg >> mAction; // uint8_t + +quad in NC2.2 +C->S +[...] 32:c9:03:07:28:65:35:8b:8c:6c:7f:09:99:45:26:10:80:01:00:ff:05 +S->C +[...] 32:c9:03:07:28:65:35:8b:8c:6c:7f:09:99:45:26:10:80:01:00:ff:05 + +glider in NC2.2 +C->S +[...] 32:4b:03:07:13:57:a9:88:89:af:86:c1:89:ec:81:64:82:01:00:ff:00 +S->C +[...] 32:4b:03:07:98:57:c8:88:59:b0:83:5c:88:13:81:64:82:01:00:ff:00: +[...] 32:4b:03:07:13:57:a9:88:89:af:86:c1:89:ec:81:64:82:01:00:ff:00: + + +*/ +PMessage* PMsgBuilder::BuildTraderItemListMsg( PClient* nClient, uint32_t nTraderNpcID ) //, PContainer* nContainer) +{ +// PMessage* ContentList = BuildContainerContentList(nContainer, INV_LOC_BOX); +// Tmp manual content list: + PMessage* ContentList = new PMessage(); + float PriceCoef = 1 / 1.379942; + uint8_t Quality = 255; // Range 0 - 255 + + //Item 1: + *ContentList << ( uint16_t )0x05e6; // Item Id "Clan key for CityAdmin" + *ContentList << ( uint32_t )304567; // Base (?) Item price = item.def price / 1.97 + // Displayed price is this price * 1.38 . Is this faction/barter factor ? + //Item 2: + *ContentList << ( uint16_t )0x05e7; // Item Id "Clan key for Diamond Real Estate" + *ContentList << ( uint32_t )( 420285 * PriceCoef ); + //Item 3: + *ContentList << ( uint16_t )0x05e8; // Item Id "Clan key for N.E.X.T." + *ContentList << ( uint32_t )( 420285 * PriceCoef ); + //Item 4: + *ContentList << ( uint16_t )0x060f; // Item Id "PLAZA - 2nd Lev. Apartment" + *ContentList << ( uint32_t )( 245166 * PriceCoef ); + //Item 5: + *ContentList << ( uint16_t )0x065c; // Item Id "Normal Viarosso Apartment Alamo Living" + *ContentList << ( uint32_t )( 840571 * PriceCoef ); + //Item 6: + *ContentList << ( uint16_t )0x065d; // Item Id "Luxus Viarosso Apartment Alamo Living" + *ContentList << ( uint32_t )( 1260856 * PriceCoef ); + + //Item 7: + *ContentList << ( uint16_t )355; // Item Id "HEW �Liquid Fire� Rifle" + *ContentList << ( uint32_t )( 1260856 * PriceCoef ); + + PMessage* tmpMsg = new PMessage(); + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x00; // Message length + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x26; + *tmpMsg << nTraderNpcID; + *tmpMsg << ( uint8_t )0x01; // Traders inventory + *tmpMsg << ( uint16_t )( ContentList->GetSize() / 6 ); // List entries + *tmpMsg << ( uint8_t )Quality; // Items quality + *tmpMsg << *ContentList; + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + delete ContentList; + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildStartWeaponReloadMsg( PClient* nClient ) +{ + PMessage* tmpMsg = new PMessage( 16 ); + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x00; // Message length + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x25; // cmd + *tmpMsg << ( uint8_t )0x16; // cmd + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildStartWeaponReloadAnimMsg( PClient* nClient ) +{ + PMessage* tmpMsg = new PMessage( 13 ); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )0x0000; // placeholder for UDP_ID; + *tmpMsg << ( uint16_t )0x0000; // placeholder for SessionID(); + + *tmpMsg << ( uint8_t )0x00; // Message length placeholder; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )0x0000; // placeholder for UDP_ID; + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x15; // cmd + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildHeldItemUseMsg( uint16_t nUserCharLocalId, uint16_t nWeaponId, uint32_t nTargetRawItemID, uint8_t nAiming, uint8_t nTargetedHeight, uint8_t nScore ) +{ + PMessage* tmpMsg = new PMessage( 22 ); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )0x0000; // placeholder for UDP_ID; + *tmpMsg << ( uint16_t )0x0000; // placeholder for SessionID(); + + *tmpMsg << ( uint8_t )0x00; // Message length placeholder; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )0x0000; // placeholder for UDP_ID; + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nUserCharLocalId; + *tmpMsg << ( uint8_t )0x01; // cmd + *tmpMsg << ( uint16_t )nWeaponId; + *tmpMsg << ( uint32_t )nTargetRawItemID; + *tmpMsg << ( uint8_t )nAiming; + *tmpMsg << ( uint8_t )nTargetedHeight; + *tmpMsg << ( uint8_t )nScore; + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildHeldItemUse2Msg( uint16_t nUserCharLocalId, uint32_t nTargetRawItemID ) +{ + PMessage* tmpMsg = new PMessage( 18 ); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )0x0000; // placeholder for UDP_ID; + *tmpMsg << ( uint16_t )0x0000; // placeholder for SessionID(); + + *tmpMsg << ( uint8_t )0x00; // Message length placeholder; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )0x0000; // placeholder for UDP_ID; + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nUserCharLocalId; + *tmpMsg << ( uint8_t )0x2c; // cmd + *tmpMsg << ( uint8_t )0x09; // cmd + *tmpMsg << ( uint32_t )nTargetRawItemID; + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildHeldItemUse3Msg( PClient* nClient, uint16_t nUnknown1, uint16_t nUnknown2, uint16_t nUnknown3, uint16_t nUnknown4 ) +{ + PMessage* tmpMsg = new PMessage( 22 ); + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x00; // Message length + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x25; // cmd + *tmpMsg << ( uint8_t )0x1a; // cmd + *tmpMsg << ( uint16_t )nUnknown1; + *tmpMsg << ( uint16_t )nUnknown2; + *tmpMsg << ( uint16_t )nUnknown3; + *tmpMsg << ( uint16_t )nUnknown4; + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildHeldItemUse4Msg( uint16_t nUserCharLocalId, uint32_t nTargetRawItemID, uint16_t nUnknown1, uint16_t nUnknown2, uint8_t nTargetedHeight ) +{ + PMessage* tmpMsg = new PMessage( 23 ); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )0x0000; // placeholder for UDP_ID; + *tmpMsg << ( uint16_t )0x0000; // placeholder for SessionID(); + + *tmpMsg << ( uint8_t )0x00; // Message length placeholder; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )0x0000; // placeholder for UDP_ID; + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nUserCharLocalId; + *tmpMsg << ( uint8_t )0x2c; // cmd + *tmpMsg << ( uint8_t )0x01; // cmd + *tmpMsg << ( uint16_t )nUnknown1; + *tmpMsg << ( uint16_t )nUnknown2; + *tmpMsg << ( uint32_t )nTargetRawItemID; + *tmpMsg << ( uint8_t )nTargetedHeight; + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildHeldItemAddonActivationMsg( PClient* nClient, uint8_t nState ) +{ + PMessage* tmpMsg = new PMessage( 15 ); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )0x0000; // placeholder for UDP_ID; + *tmpMsg << ( uint16_t )0x0000; // placeholder for SessionID(); + + *tmpMsg << ( uint8_t )0x00; // Message length placeholder; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )0x0000; // placeholder for UDP_ID; + *tmpMsg << ( uint8_t )0x2f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint16_t )0x0001; // cmd ? + *tmpMsg << ( uint8_t )( 0x60 | nState ); + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildWeatherControlMsg( uint16_t nWeatherId ) +{ + PMessage* tmpMsg = new PMessage( 13 ); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )0x0000; // placeholder for UDP_ID; + *tmpMsg << ( uint16_t )0x0000; // placeholder for SessionID(); + + *tmpMsg << ( uint8_t )0x00; // Message length placeholder; + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )0x0000; // placeholder for UDP_ID; + *tmpMsg << ( uint8_t )0x2e; + *tmpMsg << ( uint8_t )0x01; // cmd + *tmpMsg << ( uint16_t )nWeatherId; //see at bottom of weather.def + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildCharUseTimedDrugMsg( PClient* nClient, const PDefDrug* nDrugDef, uint16_t nItemId ) +{ + PMessage* tmpMsg = new PMessage( 60 ); + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x00; // Message length + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x25; // cmd + *tmpMsg << ( uint8_t )0x06; // cmd + *tmpMsg << ( uint8_t )nDrugDef->GetChangeNum(); + *tmpMsg << ( uint8_t )0x01; // ??? not working if 0, no apparent change if > 1 + *tmpMsg << ( uint16_t )nDrugDef->GetDuration(); + *tmpMsg << ( uint16_t )nItemId; + for( uint8_t i = 0; i < nDrugDef->GetChangeNum(); ++i ) + { + *tmpMsg << ( uint8_t )nDrugDef->GetChangeType( i ); + *tmpMsg << ( uint16_t )( nDrugDef->GetChangeScale( i ) * 100 ); + *tmpMsg << ( uint16_t )nDrugDef->GetChangeTarget( i ); + } + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildCharUseInstantDrugMsg( PClient* nClient, const PDefDrug* nDrugDef ) +{ + PMessage* tmpMsg = new PMessage( 60 ); + nClient->IncreaseUDP_ID(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x00; // Message length + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x25; // cmd + *tmpMsg << ( uint8_t )0x07; // cmd + *tmpMsg << ( uint8_t )nDrugDef->GetChangeNum(); + *tmpMsg << ( uint8_t )0x02; // ??? other values not tested + for( uint8_t i = 0; i < nDrugDef->GetChangeNum(); ++i ) + { + *tmpMsg << ( uint8_t )nDrugDef->GetChangeType( i ); + *tmpMsg << ( float )( nDrugDef->GetChangeScale( i ) * 100 ); // float in nc2.2 - uint16_t in nc1 ??? + *tmpMsg << ( uint16_t )nDrugDef->GetChangeTarget( i ); + } + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + Console->Print( "%s PMsgBuilder::BuildCharUseInstantDrugMsg : data format not tested", Console->ColorText( YELLOW, BLACK, "[WARNING]" ) ); + + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildCharUseRecreationUnitMsg( PClient* nClient, uint32_t nObjectId ) +{ + PMessage* tmpMsg = new PMessage( 16 ); + nClient->IncreaseUDP_ID(); +/* + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint16_t )nClient->GetSessionID(); + *tmpMsg << ( uint8_t )0x00; // Message length + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )nClient->GetUDP_ID(); + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )nClient->GetLocalID(); + *tmpMsg << ( uint8_t )0x25; // cmd + *tmpMsg << ( uint8_t )0x16; // cmd + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); +*/ + Console->Print( "%s PMsgBuilder::BuildCharUseRecreationUnitMsg : not implemented (target: 0x%08x)", Console->ColorText( YELLOW, BLACK,"[WARNING]" ), nObjectId ); + return tmpMsg; +} + +// For testing - packet to be broadcasted to zone +PMessage* PMsgBuilder::BuildNpcDeathMsg( PClient* nClient, uint32_t nNpcId, uint8_t unknown1, uint8_t unknown2 ) +{ + PMessage* tmpMsg = new PMessage( 19 ); + PChar *nChar = nClient->GetChar(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )0x0000; // placeholder for UDP_ID; + *tmpMsg << ( uint16_t )0x0000; // placeholder for SessionID(); + + *tmpMsg << ( uint8_t )0x00; // Message length placeholder; + *tmpMsg << ( uint8_t )0x1b; + *tmpMsg << ( uint32_t )nNpcId; + *tmpMsg << ( uint8_t )0x1f; + *tmpMsg << ( uint16_t )( nChar->Coords.mY + 768 + 30 ); //move Npc near to char :p + *tmpMsg << ( uint16_t )( nChar->Coords.mZ + 768 + 0 ); + *tmpMsg << ( uint16_t )( nChar->Coords.mX + 768 + 30 ); + *tmpMsg << ( uint8_t )2; // ??? 0x01=look at target, 0x02=?, 0x10 = kneel, 0x80 = die + *tmpMsg << ( uint8_t )1; //0=> dead on health 0 / else alive on health 0. Changes in caps + *tmpMsg << ( uint8_t )96; // health => 0 alive if prec >0 1-127 alive, <0 dead (ie uint8_t 128-255 = neg signed values) + *tmpMsg << ( uint16_t )259; // targetId (N)PC - Here: left copbot at NC entrance (zone 2008) + *tmpMsg << ( uint8_t )0x00; // ? doesn't seem to change in caps + *tmpMsg << ( uint8_t )0x00; // ? doesn't seem to change in caps + *tmpMsg << ( uint8_t )0; // ? changes in caps + *tmpMsg << ( uint8_t )0; // ? changes in caps // moving speed somewhere ? + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + unknown2 = unknown1; // so that gcc doesn't complain if these vars are not used + return tmpMsg; +} + +PMessage* PMsgBuilder::BuildNpcCleanupMsg( uint32_t nNpcId, uint8_t nCmd ) +{ + PMessage* tmpMsg = new PMessage(); + + *tmpMsg << ( uint8_t )0x13; + *tmpMsg << ( uint16_t )0x0000; + *tmpMsg << ( uint16_t )0x0000; + *tmpMsg << ( uint8_t )0x00; // Message length + *tmpMsg << ( uint8_t )0x03; + *tmpMsg << ( uint16_t )0x0000; + *tmpMsg << ( uint8_t )0x2d; + *tmpMsg << ( uint32_t )nNpcId; + *tmpMsg << ( uint8_t )nCmd; // 6: npc/vhc "cleanup", 1: kill npc + msg "no reward, too small" + + ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 ); + + return tmpMsg; + } + + +/* +void Cmd_GiveItem (int ItemId, int Amount, int ClientNum) +{ + unsigned char SendBuffer[256]; + +// Inventory_AddNewItem (&Client_Sockets[ClientNum].CharInfo, ItemId, Amount); + SendBuffer[0] = 0x13; + SendBuffer[5] = 0x1b; + SendBuffer[6] = 0x03; + Network_IncrementUDP (ClientNum); + *(unsigned short*)&SendBuffer[7] = Client_Sockets[ClientNum].UDP_ID; + SendBuffer[9] = 0x1f; + *(unsigned short*)&SendBuffer[10] = Client_Sockets[ClientNum].CharInfo.MapID; + SendBuffer[12] = 0x25; + SendBuffer[13] = 0x13; + Client_Sockets[ClientNum].TransactionID++; + *(unsigned short*)&SendBuffer[14] = Client_Sockets[ClientNum].TransactionID;//Transaction ID + SendBuffer[16] = 0x18; + SendBuffer[17] = 0x03; //Location + SendBuffer[18] = 0xff; // \/ + SendBuffer[19] = 0xff; //Anywhere + SendBuffer[20] = 0x08; + SendBuffer[21] = 0x00; + *(unsigned short*)&SendBuffer[22] = ItemId; //Item Id + SendBuffer[24] = 0x05; + SendBuffer[25] = 0x01; + *(unsigned short*)&SendBuffer[26] = Amount; //Quantity + SendBuffer[28] = 0x00; + SendBuffer[29] = 0x00; + *(unsigned short*)&SendBuffer[30] = Client_Sockets[ClientNum].CharInfo.ItemTransactionID; //Id of Purchased Item (Client sends another packet for placement of new item) + + *(unsigned short*)&SendBuffer[1] = Client_Sockets[ClientNum].UDP_ID; + *(unsigned short*)&SendBuffer[3] = Client_Sockets[ClientNum].UDP_ID_HIGH; + + Network_SendUDP (SendBuffer, 32, ClientNum); +} +*/ + +/* Unkown use packets (from nc2.2) +13:81:00:81:e2: 0c: 03:81:00:23: 12:00: 07:00:00:00:00:00 // weather related ? + +13:56:00:56:e2: 40: 03:56:00:1f:01:00:25:13: f1:18:13:01:77:05:48:c7: f2:18:13:02:16:74:61:c7: f3:18:13:03:17:74:61:c7: f4:18:13:04:18:74:61:c7: f5:18:13:05:1f:2a:60:c7: f6:18:13:06:1f:2a:60:c7: f7:18:13:0b:3e:8f:6d:c7 + +13:5c:00:5c:e2: 0c: 03:5c:00:1f:01:00:25:13: f8:18:0e:02 + +13:xx:xx:xx:xx: 09: 03:68:00:2d: 6d:03:00:00: 06 // Action update ? other NPC update ? some vanish ? +*/ diff --git a/TinNS/Source/GameServer/MessageBuilder.hxx b/TinNS/Source/GameServer/MessageBuilder.hxx new file mode 100644 index 0000000..df307f5 --- /dev/null +++ b/TinNS/Source/GameServer/MessageBuilder.hxx @@ -0,0 +1,147 @@ +#pragma once + +#include +#include +#include + +class PClient; +class PDefDrug; +class PMessage; +class PContainerEntry; +class PContainer; +class PSpawnedVehicle; + +class PMsgBuilder { +public: + PMsgBuilder() {}; + ~PMsgBuilder() {}; + +// Following methods for broadcasted messages do NOT include UDP_ID increment +// when needed, nor UDP_ID / SessionID setting +// as these must be set on a destination client basis + PMessage* BuildCharHelloMsg( PClient* nClient ); + PMessage* BuildCharHealthUpdateMsg( PClient* nClient ); + PMessage* BuildCharDeathMsg( PClient* nClient, uint32_t nKillerCharId = 0 ); + PMessage* BuildCharPosUpdateMsg( PClient* nClient ); + PMessage* BuildCharPosUpdate2Msg( PClient* nClient, uint8_t InfoBitfield = 0x7f ); + //PMessage* BuildCharSittingMsg( PClient* nClient ); // Not used anymore, done by BuildCharPosUpdateMsg + PMessage* BuildCharExitSeatMsg( PClient* nClient ); + PMessage* BuildDoorOpenMsg( uint32_t nRawItemID, bool nDoubleDoor = false ); + PMessage* BuildCharUseSeatMsg( PClient* nClient, uint32_t nRawObjectId, uint8_t nSeatId = 0 ); + PMessage* BuildCharShowGlowCircleMsg( PClient* nClient ); + + PMessage* BuildSpawnWorldObjectMsg( uint16_t nModelID, uint16_t nFunctionID, uint32_t nWOID, uint16_t nPosX, uint16_t nPosY, uint16_t nPosZ, uint8_t nRotX, uint8_t nRotY, uint8_t nRotZ ); + PMessage* BuildRemoveWorldObjectMsg( uint32_t nWOID ); + PMessage* BuildWeatherControlMsg( uint16_t nWeatherId ); + + PMessage* BuildSubwaySingleUpdateMsg( uint32_t nVehicleID, uint16_t nPosition, uint8_t nDoorOpened ); + PMessage* BuildVhcHealthUpdateMsg( PSpawnedVehicle* nVehicle ); + PMessage* BuildVhcPosUpdateMsg( PSpawnedVehicle* nVehicle ); + PMessage* BuildVhcPosUpdate2Msg( PSpawnedVehicle* nVehicle ); + + PMessage* BuildStartWeaponReloadAnimMsg( PClient* nClient ); + PMessage* BuildHeldItemUseMsg( uint16_t nUserCharLocalId, uint16_t nWeaponId, uint32_t nTargetRawItemID, uint8_t nAiming, uint8_t nTargetedHeight, uint8_t nScore = 0 ); + PMessage* BuildHeldItemUse2Msg( uint16_t nUserCharLocalId, uint32_t nTargetRawItemID ); + PMessage* BuildHeldItemUse4Msg( uint16_t nUserCharLocalId, uint32_t nTargetRawItemID, uint16_t nUnknown1, uint16_t nUnknown2, uint8_t nTargetedHeight ); + PMessage* BuildHeldItemAddonActivationMsg( PClient* nClient, uint8_t nState ); + + // Temp. NPC update message for testing + PMessage* BuildNpcDeathMsg( PClient* nClient, uint32_t nNpcId, uint8_t unknown1 = 0x4a, uint8_t npcAction = 0x1e ); + + PMessage* BuildNPCMassInfoMsg( uint32_t nWorldID, uint16_t nTypeID, uint16_t nClothing, uint16_t nNameID, uint16_t nPosY, uint16_t nPosZ, uint16_t nPosX, uint16_t nHealth, uint16_t nTraderID, std::string *nAngleStr, std::string *nNpcName, std::string *nCustomName); + PMessage* BuildNPCMassAliveMsg( uint32_t nWorldID, uint16_t nX, uint16_t nY, uint16_t nZ, uint8_t nActionStatus, uint8_t nHealth, uint8_t nAction ); + PMessage* BuildNPCMassUpdateMsg( uint32_t nWorldID, uint16_t nX, uint16_t nY, uint16_t nZ, uint8_t nActionStatus, uint8_t nHealth, uint16_t nTarget, uint8_t nAction ); + // Moved here since its a zone broadcast! + PMessage* BuildNpcCleanupMsg( uint32_t nNpcId, uint8_t nCmd = 6 ); // see implementation about nCmd + +// Following methods for unicast messages DO include UDP_ID increment and +// UDP_ID / SessionID setting when needed (at least for now) + PMessage* BuildOutpostClanInfoMsg( PClient* nClient, uint32_t nClanID, uint8_t nFaction ); + PMessage* BuildTryAccessAnswerMsg(PClient* nClient, char *nArea, bool nAllowed); + PMessage* BuildReceiveDBAnswerMsg( PClient* nClient, PMessage* nResultBuffer, std::string* nCommandName, uint16_t nNumRows, uint16_t nNumFields); + PMessage* BuildYouGotEmailsMsg( PClient* nClient, uint8_t nMailCount ); + + PMessage* BuildNPCStartDialogMsg( PClient* nClient, uint32_t nNPCWorldID, std::string *nDialogScript ); + PMessage* BuildNPCDialogReplyMsg( PClient* nClient, uint16_t nNextNode, std::vector*nResultBuffer); + PMessage* BuildReqNPCScriptAnswerMsg( uint32_t nInfoId, std::string *nNPCScript ); + PMessage* BuildNPCShoppingListMsg( PClient* nClient, PMessage* nContentList, int nWorldID, uint8_t nItemQuality); + PMessage* BuildNPCBeginAllBuyerTradeMsg( PClient* nClient, int nWorldID ); + + PMessage* BuildNPCSingleInfoMsg( PClient* nClient, uint32_t nWorldID, uint16_t nTypeID, uint16_t nClothing, uint16_t nNameID, uint16_t nPosY, uint16_t nPosZ, uint16_t nPosX, uint16_t nHealth, uint16_t nTraderID, std::string *nAngleStr, std::string *nNpcName, std::string *nCustomName); + PMessage* BuildNPCSingleAliveMsg( PClient* nClient, uint32_t nWorldID, uint16_t nX, uint16_t nY, uint16_t nZ, uint8_t nActionStatus, uint8_t nHealth, uint8_t nAction ); + PMessage* BuildNPCSingleUpdateMsg( PClient* nClient, uint32_t nWorldID, uint16_t nX, uint16_t nY, uint16_t nZ, uint8_t nActionStatus, uint8_t nHealth, uint16_t nTarget, uint8_t nAction ); + + // NEW for testing. Combined update message + PMessage* BuildNPCUpdateMsg(uint32_t nWorldID, uint16_t nPosY, uint16_t nPosZ, uint16_t nPosX, uint8_t nActionBM, uint16_t nHealth, uint8_t nWeaponState, uint8_t nUnknown, uint32_t nTargetID = 0); + + PMessage* BuildReqInfoAnswerMsg( PClient* nClient, uint16_t nReqType, uint32_t nInfoId, void* nResponse, uint16_t nResponseLength ); + + PMessage* BuildPacket0Msg( PClient* nClient ); + PMessage* BuildPingMsg( PClient* nClient, uint32_t nClientTime ); + PMessage* BuildBaselineMsg( PClient* nClient ); + PMessage* BuildAliveRepMsg( PClient* nClient ); + + PMessage* BuildZoning1Msg( PClient* nClient, uint16_t nEntity, uint8_t nUnknown = 0 ); + PMessage* BuildZoningTCPReadyMsg(); + PMessage* BuildSendZoneTCPMsg( uint32_t nLocation, std::string* nWorldName ); + PMessage* BuildZoning2Msg( PClient* nClient, uint32_t nClientTime ); + PMessage* BuildGenrepZoningMsg( PClient* nClient, uint32_t nLocation, uint16_t nEntity ); + + PMessage* BuildGenrepAddToListMsg( PClient* nClient, uint32_t nLocation, uint16_t nEntity ); + + PMessage* BuildAptLiftUseMsg( PClient* nClient, uint32_t nLocation, uint16_t nEntity, uint8_t nEntityType = 0 ); + PMessage* BuildAptLiftFailedMsg( PClient* nClient ); + PMessage* BuildChangeLocationMsg( PClient* nClient, uint32_t nLocation, uint16_t nEntity, uint8_t nEntityType = 0, uint32_t nRawItemID = 0 ); + PMessage* BuildEntityPositionMsg( PClient* nClient, uint16_t pX, uint16_t pY, uint16_t pZ ); + + PMessage* BuildCharAptLocInfoMsg( PClient* nClient ); + + PMessage* BuildLevelUpMessage( PClient* nClient, uint8_t nMainSkill, uint8_t nNewLevel, uint16_t nFreeSkillPoints); + PMessage* BuildSubskillIncMsg( PClient* nClient, uint8_t nSubskill, uint16_t nSkillPoints ); + PMessage* BuildChatAddMsg( PClient* nClient, uint32_t nAddedCharID, uint8_t nMode ); // mode = 1 for Direct, 2 for Buddy + + PMessage* BuildText100Msg( PClient* nClient, uint8_t nTxtMsgId, uint32_t nRawObjectID ); + PMessage* BuildTextIniMsg( PClient* nClient, uint8_t nTxtGroupID, uint16_t nTxtID ); + + PMessage* BuildCharInteractionMenuMsg( PClient* nClient, uint32_t nRawTargetID ); + + PMessage* BuildFurnitureActivateMsg( PClient* nClient, uint32_t nRawObjectID, uint8_t nActionValue ); + PMessage* BuildCharUseFurnitureMsg( PClient* nClient, uint32_t nRawObjectID ); + PMessage* BuildCharUseVhcTerminalMsg( PClient* nClient, uint32_t nRawObjectID ); + PMessage* BuildCharUseGogoMsg( PClient* nClient ); + PMessage* BuildCharUseVentureWarpMsg( PClient* nClient, uint32_t nRawObjectID ); + PMessage* BuildVhcAccessRequestMsg (PClient* nClient, uint32_t nRequestId, uint32_t nRequesterCharId, uint32_t nRequesterLocalId, uint32_t nVhcRawObjectID ); + PMessage* BuildCharUseGenrepMsg( PClient* nClient, uint32_t nRawObjectID, uint32_t nLocation, uint16_t nEntity ); + PMessage* BuildCharUseLiftMsg( PClient* nClient, uint32_t nRawObjectID, uint16_t nAptPlace ); + PMessage* BuildCharUseVhcMsg( PClient* nClient, uint32_t nRawObjectID, uint16_t nVhcType, uint16_t nAvailableSeats ); + + PMessage* BuildCharMoneyUpdateMsg( PClient* nClient, uint32_t nCredits ); + PMessage* BuildUndefineduseMsg( PClient* nClient, uint8_t nValue ); + PMessage* BuildCharUseQBSlotMsg2( PClient* nClient, uint16_t nV1 = 100, uint16_t nV2 = 100, uint16_t nV3 = 100, uint16_t nV4 = 100, uint16_t nV5 = 100, uint16_t nV6 = 100, uint16_t nV7 = 0 ); + PMessage* BuildCharUseQBSlotMsg3( PClient* nClient, uint8_t nSlot ); + PMessage* BuildCharUseQBSlotMsg4( PClient* nClient, uint16_t nWeaponId ); + PMessage* BuildContainerContentList( PContainer* nContainer, uint8_t nLocType ); + PMessage* BuildContainerContentEntry( PContainerEntry* nEntry, uint8_t nLocType ); + + PMessage* BuildCharOpenContainerMsg( PClient* nClient, uint32_t nContainerID, PContainer* nContainer ); + PMessage* BuildItemMoveMsg( PClient* nClient, uint8_t nSource, uint8_t nSrcX, uint8_t nSrcY, uint8_t nDestination, uint8_t nDestX, uint8_t nDestY, uint8_t nItemCnt ); + PMessage* BuildBoxItemMoveMsg( PClient* nClient, PContainerEntry* nEntry, uint8_t nSrcX, uint8_t nSrcY, uint8_t nDestination, uint8_t nDestX, uint8_t nDestY, uint8_t nItemCnt ); + PMessage* BuildStartWeaponReloadMsg( PClient* nClient ); + + PMessage* BuildStartHackGameMsg( PClient* nClient, uint32_t nWorldObjID, uint8_t nHackDifficult ); + + PMessage* BuildSubwaySpawnMsg( PClient* nClient, bool IsSecondMessage ); + //PMessage* BuildSubwayFullUpdateMsg(PClient* nClient); + PMessage* BuildVhcInfoMsg( PClient* nClient, PSpawnedVehicle* nVehicle ); + + PMessage* BuildDBRequestStatusMsg( PClient* nClient, std::string* nCommandName, uint8_t nStatus, uint16_t nErrCode ); + PMessage* BuildDBAnswerMsg( PClient* nClient, std::string* nCommandName, std::string* nAnswerData, uint16_t nRows, uint16_t nCols ); + + PMessage* BuildTraderItemListMsg( PClient* nClient, uint32_t nTraderNpcID ); + + PMessage* BuildHeldItemUse3Msg( PClient* nClient, uint16_t nUnknown1, uint16_t nUnknown2, uint16_t nUnknown3, uint16_t nUnknown4 ); + + PMessage* BuildCharUseTimedDrugMsg( PClient* nClient, const PDefDrug* nDrugDef, uint16_t nItemId ); + PMessage* BuildCharUseInstantDrugMsg( PClient* nClient, const PDefDrug* nDrugDef ); + PMessage* BuildCharUseRecreationUnitMsg( PClient* nClient, uint32_t nObjectId ); +}; diff --git a/server/src/game/multipart.cpp b/TinNS/Source/GameServer/MultiPart.cxx similarity index 82% rename from server/src/game/multipart.cpp rename to TinNS/Source/GameServer/MultiPart.cxx index c5732ad..a3b23f7 100644 --- a/server/src/game/multipart.cpp +++ b/TinNS/Source/GameServer/MultiPart.cxx @@ -1,34 +1,5 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - multipart.cpp - Handling of incomming multipart messages - - CREATION: 31 Aug 2006 Hammag - - MODIFIED: - REASON: - -*/ - -#include "main.h" +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" PMultiPart::PMultiPart() { @@ -39,7 +10,7 @@ PMultiPart::~PMultiPart() } -void PMultiPart::AssembleChunk(u16 nSequence) +void PMultiPart::AssembleChunk(uint16_t nSequence) { // Get the sequence number PMultipartMap::iterator it; @@ -87,7 +58,7 @@ void PMultiPart::AssembleChunk(u16 nSequence) it->second.smTimeStamp = 0; //tmpMsg->Dump(); - // Note: At this point, the reassembled message should be pushed back to the messagedecoder. But since the size of the packets there is always u8 + // Note: At this point, the reassembled message should be pushed back to the messagedecoder. But since the size of the packets there is always uint8_t // it wont work with these oversized packets. // I decided to process the Assembled packet right here, since the only function in clients known to send oversized frames is UpdateDB ProcessPacket(it->second.smClient, tmpMsg); @@ -102,15 +73,15 @@ void PMultiPart::ProcessPacket(PClient *nClient, PMessage *tmpMsg) mDBId = 0; // Make sure we have an UpdateDB call, otherwise break and error - u8 MsgSubType = tmpMsg->U8Data(0); - u8 TerminalAction = tmpMsg->U8Data(1); + uint8_t MsgSubType = tmpMsg->U8Data(0); + uint8_t TerminalAction = tmpMsg->U8Data(1); if(MsgSubType != 0x21 || TerminalAction != 0x18) { Console->Print("%s [PMultiPart::ProcessPacket] Unsupportet multipart message. Type %02x", Console->ColorText(RED, BLACK, "ERROR"), MsgSubType); return; } - u16 tCmdLen, Unknown3, OptionSize; + uint16_t tCmdLen, Unknown3, OptionSize; tmpMsg->SetNextByteOffset( 14 ); ( *tmpMsg ) >> tCmdLen; @@ -136,7 +107,7 @@ void PMultiPart::ProcessPacket(PClient *nClient, PMessage *tmpMsg) { Console->Print( "%s Fragmented UpdateDB request from client; DBID: %d", Console->ColorText( YELLOW, BLACK, "[DEBUG]" ), mDBId ); Console->Print( "%s Command: '%s'", Console->ColorText( YELLOW, BLACK, "[DEBUG]" ), mCommandName.c_str() ); - for ( u8 i = 0; i < mOptionsCount; ++i ) + for ( uint8_t i = 0; i < mOptionsCount; ++i ) Console->Print( "%s Option %d: '%s'", Console->ColorText( YELLOW, BLACK, "[DEBUG]" ), i, mOptions[i].c_str() ); }*/ Terminal->HandleUpdateDB(nClient, 0, &mCommandName, mOptions, mOptionsCount, mDBId, 0); @@ -163,7 +134,7 @@ void PMultiPart::Update() } // Adds an multipart frame -void PMultiPart::AddMultiPartChunk(PClient *nClient, PMessage *nChunk, u16 nChunkNumber, u16 nChunkTotal, u8 nSequence) +void PMultiPart::AddMultiPartChunk(PClient *nClient, PMessage *nChunk, uint16_t nChunkNumber, uint16_t nChunkTotal, uint8_t nSequence) { // Search for Sequence ID in our map PMultipartMap::iterator it; diff --git a/TinNS/Source/GameServer/MultiPart.hxx b/TinNS/Source/GameServer/MultiPart.hxx new file mode 100644 index 0000000..ef9bd29 --- /dev/null +++ b/TinNS/Source/GameServer/MultiPart.hxx @@ -0,0 +1,50 @@ +#pragma once + +#include +#include +#include + +#define MAX_SEQUENCE_LIFE 10 // In seconds + +typedef struct // A single chunk of any multipart sequence +{ + uint16_t smChunkNr; + //uint16_t smChunkTotal; + PMessage* smChunk; +} s_MessageChunk; + +typedef std::vector vecMsgChunk; // The vector of an specific multipart sequence, containing all chunks +typedef struct +{ + time_t smTimeStamp; // To keep track of sequence's lifetimer + uint16_t smChunkTotal; // Total amount of chunks for this sequence + vecMsgChunk smvChunk; // The chunkvector + PClient *smClient; // Required to call terminal class +} s_SequenceEntry; + +typedef std::map PMultipartMap; // Map of all vectors, indexed by sequencenumber + + +class PMultiPart +{ + private: + PMultipartMap MsgMap; + void AssembleChunk(uint16_t nSequence); + void ProcessPacket(PClient *nClient, PMessage *tmpMsg); + +// Required to process packets here + static const uint8_t mMaxOptions = 7; + std::string mCommandName; + std::string mOptions[mMaxOptions]; + uint8_t mOptionsCount; + uint16_t mDBId; +// --------------------------------- + + public: + PMultiPart(); + ~PMultiPart(); + + void Update(); // Check for complete/timed out sequences + // Adds an multipart frame + void AddMultiPartChunk(PClient *nClient, PMessage *nChunk, uint16_t nChunkNumber, uint16_t nChunkTotal, uint8_t nSequence); +}; diff --git a/server/src/game/npc.cpp b/TinNS/Source/GameServer/Npc.cxx similarity index 91% rename from server/src/game/npc.cpp rename to TinNS/Source/GameServer/Npc.cxx index f78a897..bf585b9 100644 --- a/server/src/game/npc.cpp +++ b/TinNS/Source/GameServer/Npc.cxx @@ -1,45 +1,15 @@ - /* -TinNS (TinNS is not a Neocron Server) -Copyright (C) 2005 Linux Addicted Community -maintainer Akiko - -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 -of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301, USA. - */ - - /* - -npc.cpp - Management class for NPC worldactors - -CREATION: 04 Jan 2007 Namikon - -MODIFIED: 28 Apr 2009 Hammag -REASON: changed worlds/zones Id from u16 (wrong !!!) to u32 - - */ - -#include "main.h" -#include "include/npc.h" -#include "include/worlds.h" -#include "include/npctemplate.h" -#include "include/worlddatatemplate.h" -#include "include/msgbuilder.h" - - ///*********************************************************************** - -// Reload LUA script while running, in case we modified it and dont want to restart the entire server +#include +#include +#include "GameServer/Includes.hxx" +#include "GameServer/Definitions/Includes.hxx" +#include "Common/Includes.hxx" + +void PNPC::PushUpdateTimer() +{ + mNextUpdate = std::time(nullptr) + GetRandom(NPC_HEARTBEAT_MAX, NPC_HEARTBEAT_MIN); +}; + +// Reload LUA script while running, in case we modified it and dont want to restart the entire server bool PNPC::ReloadLUAScript() { // Erase current LUA script @@ -48,26 +18,26 @@ bool PNPC::ReloadLUAScript() // Reload it return LoadLUAScript(); } - -bool PNPC::DEF_Load(u32 nWorldID) + +bool PNPC::DEF_Load(uint32_t nWorldID) { if ( gDevDebug ) Console->Print( "[DEBUG] Now loading NPC data for NPC id %d from DEF", mWorldID ); const PNPCTemplate* t_defNPC = Worlds->GetWorld(nWorldID)->GetNPCTemplate(mWorldID); - - mNameID = (u16)t_defNPC->GetNPCTypeID(); // 16 or 32?? + + mNameID = (uint16_t)t_defNPC->GetNPCTypeID(); // 16 or 32?? const PDefNpc* t_NpcTypeDef = GameDefs->Npcs()->GetDef(mNameID); if(!t_NpcTypeDef) { Console->Print("%s [PNPC::DEF_Load()] Unknown NPC Type %d in .dat file found", Console->ColorText(RED,BLACK, "[Error]"), mNameID); return false; } - + // TODO: Find out what exactly these TypeID and ClothingID values do and where they are generated/read // Possible (working) solution: Random seed for name generation that happens clientside mTypeID = GetRandom(32767, 1); mClothing = GetRandom(32767, 1); // ------------- - + mPosX = t_defNPC->GetPosX()+32768; mPosY = t_defNPC->GetPosY()+32768; mPosZ = t_defNPC->GetPosZ()+32768; @@ -79,7 +49,7 @@ bool PNPC::DEF_Load(u32 nWorldID) mFaction = t_NpcTypeDef->GetFaction(); // WorldID Fix 10.10.2009 mFromDEF = true; - + mName = t_defNPC->GetActorName(); @@ -201,7 +171,7 @@ bool PNPC::SQL_Load() bool PNPC::LoadLUAScript() { - u32 tFileLen = 0; + uint32_t tFileLen = 0; PFile* fLua = NULL; std::string tLuaFile = ""; std::string tHDRFile = ""; @@ -329,7 +299,7 @@ bool PNPC::LoadLUAScript() return false; } } - + void PNPC::Die() { if ( gDevDebug ) Console->Print( "[DEBUG] NPC dying now" ); @@ -338,7 +308,7 @@ bool PNPC::LoadLUAScript() mRespawn = std::time( NULL ) + NPC_RESPAWN_AFTER; mDirty = true; } - + void PNPC::Update() { // Has to be changed for mobs later @@ -388,7 +358,7 @@ void PNPC::InitVars() mNextUpdate = std::time(NULL) + GetRandom(30, 10); } -void PNPC::Attack( u32 nWorldID, u8 nType, u8 nUnknown ) +void PNPC::Attack( uint32_t nWorldID, uint8_t nType, uint8_t nUnknown ) { mDirty = true; mTarget = nWorldID; @@ -396,7 +366,7 @@ void PNPC::Attack( u32 nWorldID, u8 nType, u8 nUnknown ) mWeaponStatus = nType; mUnknown = nUnknown; } - + PNPC::PNPC( int nSQLID ) { InitVars(); @@ -407,8 +377,8 @@ void PNPC::Attack( u32 nWorldID, u8 nType, u8 nUnknown ) else mSuccess = true; } - -PNPC::PNPC( int nDEFID, u32 nWorldID ) + +PNPC::PNPC( int nDEFID, uint32_t nWorldID ) { InitVars(); //if(gDevDebug) Console->Print("[DEBUG] New NPC instance created. ID is %d", nSQLID); @@ -418,13 +388,13 @@ PNPC::PNPC( int nDEFID, u32 nWorldID ) else mSuccess = true; } - + PNPC::~PNPC() { //if(gDevDebug) Console->Print("[DEBUG] NPC ID %d terminated", mID); } /* - u8 PNPC::GetActionStatus() + uint8_t PNPC::GetActionStatus() { if ( mDeath == true ) { @@ -451,7 +421,7 @@ void PNPCWorld::BroadcastNewNPC(PNPC* nNpc) } -bool PNPCWorld::AddNPC(u32 nSQL_ID, u32 nRaw_ID) +bool PNPCWorld::AddNPC(uint32_t nSQL_ID, uint32_t nRaw_ID) { PNPC* tmpNpc = new PNPC( nSQL_ID ); if(tmpNpc->mSuccess == true) @@ -472,7 +442,7 @@ bool PNPCWorld::AddNPC(u32 nSQL_ID, u32 nRaw_ID) return true; } -void PNPCWorld::DelNPC(u32 nWorldID) +void PNPCWorld::DelNPC(uint32_t nWorldID) { PNPCMap::iterator it = mNPCs.find( nWorldID ); if ( it == mNPCs.end() ) @@ -498,7 +468,7 @@ void PNPCWorld::SendSingleNPCInfo( PClient* nClient, PNPC* nNpc ) nClient->SendUDPMessage( tmpMsg ); return; } - + void PNPCWorld::MSG_SendNPCs( PClient* nClient ) { PNPC* nNpc = NULL; @@ -523,7 +493,7 @@ bool PNPCWorld::LoadNPCfromSQL() MYSQL_RES *result = NULL; MYSQL_ROW row; char query[100]; - + snprintf( query, 100, "SELECT * FROM `npc_spawns` WHERE `npc_location` = %d", mWorldID ); //if(gDevDebug) Console->Print("[DEBUG] Query is: %s", query); result = MySQL->GameResQuery( query ); @@ -543,7 +513,7 @@ bool PNPCWorld::LoadNPCfromSQL() } //if(gDevDebug) Console->Print("[DEBUG] Found NPCs, now adding!"); PNPC* tmpNpc = NULL; - u32 tRawID = 0; + uint32_t tRawID = 0; int tSQLID = 0; while (( row = mysql_fetch_row( result ) ) ) { @@ -566,14 +536,14 @@ bool PNPCWorld::LoadNPCfromSQL() MySQL->FreeGameSQLResult( result ); return true; } - + bool PNPCWorld::LoadNPCfromDEF() { const PNPCsMap* tNPCmap = Worlds->GetWorld(mWorldID)->GetNPCMap(); // Get the NPC Map for this world - + PNPC* tmpNpc = NULL; - u32 tDEFID = 0; - + uint32_t tDEFID = 0; + for ( PNPCsMap::const_iterator i = tNPCmap->begin(); i != tNPCmap->end(); i++ ) { // call PNPC with NPC ID and WorldID @@ -592,11 +562,11 @@ bool PNPCWorld::LoadNPCfromDEF() if ( gDevDebug ) Console->Print( "[DEBUG] NPC Load from .def done" ); return true; } - - PNPCWorld::PNPCWorld( u32 nWorldID ) + + PNPCWorld::PNPCWorld( uint32_t nWorldID ) { //if(gDevDebug) Console->Print("[DEBUG] New world got initialized! Now starting to add NPCs. (WorldID %d)", nWorldID); - + // Assign WorldValues now mCreation = std::time( NULL ); mWorldID = nWorldID; @@ -604,7 +574,7 @@ bool PNPCWorld::LoadNPCfromDEF() LoadNPCfromSQL(); LoadNPCfromDEF(); } - + PNPCWorld::~PNPCWorld() { if ( gDevDebug ) Console->Print( "[DEBUG] Erasing all NPCs" ); @@ -697,7 +667,7 @@ void PNPCWorld::Update() return; } */ - PNPC* PNPCWorld::GetNPC( u32 nNPCID ) + PNPC* PNPCWorld::GetNPC( uint32_t nNPCID ) { if ( gDevDebug ) Console->Print( "[DEBUG] Searching for NPC %d in list", nNPCID ); PNPCMap::const_iterator it = mNPCs.find( nNPCID ); @@ -706,15 +676,15 @@ void PNPCWorld::Update() else return it->second; } - + ///*********************************************************************** - + PNPCManager::PNPCManager() { if ( gDevDebug ) Console->Print( "[DEBUG] NPCManager wakeup!" ); // Nothing yet } - + PNPCManager::~PNPCManager() { if ( gDevDebug ) Console->Print( "[DEBUG] NPCManager shutdown" ); @@ -724,16 +694,16 @@ void PNPCWorld::Update() mWorlds.erase( it ); } } - + void PNPCManager::InitPlayer( PClient* nClient ) { if ( gDevDebug ) Console->Print( "[DEBUG] Player entered zone, doing init" ); // Ok, player entered zone. First, get zone! - u32 nZone = nClient->GetChar()->GetLocation(); + uint32_t nZone = nClient->GetChar()->GetLocation(); if ( gDevDebug ) Console->Print( "[DEBUG] Now searching for zone %d in list", nZone ); // Search worldmanager for this zone PNPCWorld* tmpWorld = GetWorld( nZone ); - + if ( tmpWorld != NULL ) { if ( gDevDebug ) Console->Print( "[DEBUG] World found, poking MSG_SendNPCs" ); @@ -756,8 +726,8 @@ void PNPCWorld::Update() //tmpWorld->MSG_SendAlive( nClient ); // Force instand-update of NPCs for this client } } - - PNPCWorld* PNPCManager::InitWorld( u32 nWorldID ) + + PNPCWorld* PNPCManager::InitWorld( uint32_t nWorldID ) { if ( gDevDebug ) Console->Print( "[DEBUG] InitWorld triggered: ID %d", nWorldID ); PNPCWorld* tmpWorld = NULL; @@ -775,14 +745,14 @@ void PNPCWorld::Update() return NULL; } } - + void PNPCManager::Update() { static std::time_t lastdebug = std::time( NULL ); // Loop all worlds // if(lastdebug < std::time(NULL)) // if(gDevDebug) Console->Print("[DEBUG] WorldLoop still running..."); - + for ( PNPCWorldMap::iterator it = mWorlds.begin(); it != mWorlds.end(); it++ ) { // Make sure target still exists @@ -801,7 +771,7 @@ void PNPCWorld::Update() { //if(lastdebug < std::time(NULL)) // if(gDevDebug) Console->Print("[DEBUG] World not in use. Checking lifetimer..."); - + if (( tWorld->mCreation + ZONE_RESET_AFTER ) <= std::time( NULL ) ) //if(tWorld->mCreation <= std::time(NULL)) { @@ -826,8 +796,8 @@ void PNPCWorld::Update() //if(gDevDebug) Console->Print("[DEBUG] next updateloopmsg in 3 seconds"); } } - - PNPCWorld* PNPCManager::GetWorld( u32 nWorldID ) + + PNPCWorld* PNPCManager::GetWorld( uint32_t nWorldID ) { if ( gDevDebug ) Console->Print( "[DEBUG] Trying to get instance for worldid %d", nWorldID ); PNPCWorldMap::const_iterator it = mWorlds.find( nWorldID ); diff --git a/server/src/game/include/npc.h b/TinNS/Source/GameServer/Npc.hxx similarity index 59% rename from server/src/game/include/npc.h rename to TinNS/Source/GameServer/Npc.hxx index 1f254c3..30835d2 100644 --- a/server/src/game/include/npc.h +++ b/TinNS/Source/GameServer/Npc.hxx @@ -1,38 +1,11 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko +#pragma once - 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 - of the License, or (at your option) any later version. +#include +#include +#include +#include +#include - 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - npc.h - Management class for NPC worldactors - - CREATION: 04 Jan 2007 Namikon - - MODIFIED: 28 Apr 2009 Hammag - REASON: changed worlds Id from u16 (wrong !!!) to u32 - -*/ - -#ifndef NPC_H -#define NPC_H - // Healthfactor for NPCs (see old npc.def) #define NPC_HEALTHFACTOR 15 @@ -78,13 +51,13 @@ class PNPC; class PNPCWorld; -typedef std::map PNPCMap; -typedef std::map PNPCWorldMap; +typedef std::map PNPCMap; +typedef std::map PNPCWorldMap; typedef struct { - u16 ItemID; - u32 Price; + uint16_t ItemID; + uint32_t Price; } stShopListEntry; class PNPC @@ -113,31 +86,31 @@ private: npc_scripting }; - std::time_t mNextUpdate; // Timestamp for next heartbeat - std::time_t mNextEnemyCheck; // Timestamp for next enemycheck - inline void PushUpdateTimer() { mNextUpdate = std::time(NULL) + GetRandom(NPC_HEARTBEAT_MAX, NPC_HEARTBEAT_MIN); }; + time_t mNextUpdate; // Timestamp for next heartbeat + time_t mNextEnemyCheck; // Timestamp for next enemycheck + void PushUpdateTimer(); // SQL values - u32 mID; - u32 mWorldID; - u16 mNameID; - u16 mTypeID; - u16 mClothing; - u16 mPosX; - u16 mPosY; - u16 mPosZ; - s8 mAngle; - u16 mLoot; - u16 mTrader; - u8 mItemQuality; // Used for Shopping stuff - u8 mUnknown; + uint32_t mID; + uint32_t mWorldID; + uint16_t mNameID; + uint16_t mTypeID; + uint16_t mClothing; + uint16_t mPosX; + uint16_t mPosY; + uint16_t mPosZ; + int8_t mAngle; + uint16_t mLoot; + uint16_t mTrader; + uint8_t mItemQuality; // Used for Shopping stuff + uint8_t mUnknown; std::string mDialogScript; std::string mLUAFile; // Load File; Preloaded uppon NPC creation std::vector mVectItemsInShop; // We need to keep track of the itemorder for shopping - void AddToVectorList(u16 nItemID, u32 nPrice); - inline const stShopListEntry* GetItemNum(u32 nIdx) const { if(nIdx > mVectItemsInShop.size()) { return NULL; } else { return &mVectItemsInShop[nIdx]; }}; + void AddToVectorList(uint16_t nItemID, uint32_t nPrice); + inline const stShopListEntry* GetItemNum(uint32_t nIdx) const { if(nIdx > mVectItemsInShop.size()) { return NULL; } else { return &mVectItemsInShop[nIdx]; }}; bool mScripting; // Manual override to disable scripting for an NPC TRUE: Scripts will be executed FALSE: Scripts will be ignored @@ -145,15 +118,15 @@ private: std::string mCustomName; std::string mCustomLua; - std::time_t mRespawn; // Respawn timer + time_t mRespawn; // Respawn timer // Runtime values //bool mDeath; // Death... - u8 mFaction; // NPC's faction + uint8_t mFaction; // NPC's faction - u16 mHealth; // NPC Current Health-Value - u16 mMaxHealth; // NPC Max Health value - u32 mTarget; // Current focused player + uint16_t mHealth; // NPC Current Health-Value + uint16_t mMaxHealth; // NPC Max Health value + uint32_t mTarget; // Current focused player bool mDirty; // Needs update to clients // WorldID Fix 10.10.2009 @@ -161,8 +134,8 @@ private: bool mSuccess; // NPC load successfull? - u8 mAction; // Current action - inline u8 GetActionStatus() const { return mAction; }; + uint8_t mAction; // Current action + inline uint8_t GetActionStatus() const { return mAction; }; // 00000001 ( 1) 0x01: Attack-Mode (Depends on WeaponStatus) // 00000010 ( 2) 0x02: ? // 00000100 ( 4) 0x04: ? @@ -172,23 +145,23 @@ private: // 01000000 ( 64) 0x40: Idle // 10000000 (128) 0x80: Die - u8 mWeaponStatus; - inline u8 GetWeaponStatus() const { return mWeaponStatus; }; + uint8_t mWeaponStatus; + inline uint8_t GetWeaponStatus() const { return mWeaponStatus; }; // 00001111 (15) 0x0F: Follow given target with eyes / Put weapon away if pulled // 00010000 (16) 0x10: Pull weapon if not pulled / If pulled, attack // 00010001 (17) 0x11: Pull weapon and attack bool SQL_Load(); - bool DEF_Load(u32 nWorldID); + bool DEF_Load(uint32_t nWorldID); PNPC( int nSQLID ); - PNPC( int nDEFID, u32 nWorldID ); + PNPC( int nDEFID, uint32_t nWorldID ); ~PNPC(); void InitVars(); - void ContentListAddItem(PMessage* nContentList, u16 nItemID, u32 nBasePrice = 0, bool nAddToList = true); - void ContentListAddItemGroup(PMessage* nContentList, u32 nItemGroupID); + void ContentListAddItem(PMessage* nContentList, uint16_t nItemID, uint32_t nBasePrice = 0, bool nAddToList = true); + void ContentListAddItemGroup(PMessage* nContentList, uint32_t nItemGroupID); void StartDialog( PClient* nClient/*, string &nDialogscript */); bool DoSQLShoppingList( PClient* nClient, PMessage* nContentList ); @@ -196,16 +169,16 @@ private: bool IsAllbuyer( PClient* nClient ); bool LoadLUAScript(); - inline u32 GetRealWorldID() { if(mFromDEF == true) return mWorldID+255; else return mWorldID; }; + inline uint32_t GetRealWorldID() { if(mFromDEF == true) return mWorldID+255; else return mWorldID; }; public: friend class PNPCWorld; inline void StopAttack() { mDirty = true; mAction = NPC_ACTIONSTATE_IDLE; mWeaponStatus = NPC_SHOOT_IDLE; }; - inline void Attack( PClient* nClient, u8 nType = NPC_SHOOT_SINGLE, u8 nUnknown = 90 ) { Attack(nClient->GetChar()->GetID(), nType, nUnknown); }; - void Attack( u32 nWorldID, u8 nType = NPC_SHOOT_SINGLE, u8 nUnknown = 90 ); + inline void Attack( PClient* nClient, uint8_t nType = NPC_SHOOT_SINGLE, uint8_t nUnknown = 90 ) { Attack(nClient->GetChar()->GetID(), nType, nUnknown); }; + void Attack( uint32_t nWorldID, uint8_t nType = NPC_SHOOT_SINGLE, uint8_t nUnknown = 90 ); - inline void Move( u16 nNewX, u16 nNewY, u16 nNewZ ) + inline void Move( uint16_t nNewX, uint16_t nNewY, uint16_t nNewZ ) { mPosX = nNewX; mPosY = nNewY; @@ -216,27 +189,26 @@ public: void Die(); // ... die? void Update(); // Check respawn timer void StartConversation( PClient* nClient ); - void DoConversation( PClient* nClient, u8 nAnswer ) ; + void DoConversation( PClient* nClient, uint8_t nAnswer ) ; // GameCommands bool ReloadLUAScript(); bool ReloadShopList(); - bool SetShopQuality(u8 nNewVal); + bool SetShopQuality(uint8_t nNewVal); inline bool IsSQLNPC() const { return !mFromDEF; }; inline int GetNPCID() const { return mWorldID; }; inline int GetNPCSQLID() const { return mID; }; - inline void SetTrader( u16 nTraderDef ) { mTrader = nTraderDef; }; + inline void SetTrader( uint16_t nTraderDef ) { mTrader = nTraderDef; }; inline void SetScripting(bool nVal) { mScripting = nVal; }; - inline u8 GetFaction() const { return mFaction; }; + inline uint8_t GetFaction() const { return mFaction; }; }; // ***************************************** -class PNPCWorld -{ +class PNPCWorld { private: - std::time_t mCreation; // Creation time. (Required to check zone-reset timer - std::time_t mLastAliveMsg; // Time of last "ping" message to keep NPCs in world + time_t mCreation; // Creation time. (Required to check zone-reset timer + time_t mLastAliveMsg; // Time of last "ping" message to keep NPCs in world PNPCMap mNPCs; PNPCMap::iterator GetNPCListBegin() @@ -250,9 +222,9 @@ private: bool mSuccessfullInit; - u32 mWorldID; + uint32_t mWorldID; - PNPCWorld( u32 nWorldID ); + PNPCWorld( uint32_t nWorldID ); ~PNPCWorld(); void Update(); @@ -271,12 +243,12 @@ private: public: friend class PNPCManager; - PNPC* GetNPC( u32 nNPCID ); + PNPC* GetNPC( uint32_t nNPCID ); // Functions to add/remove an NPC while server is running void SendSingleNPCInfo( PClient* nClient, PNPC* nNpc ); // Send - bool AddNPC(u32 nSQL_ID, u32 nRaw_ID); // Load single SQL NPC from given SQL ID - void DelNPC(u32 nWorldID); // Remove given NPC from list. Works for *all* npcs + bool AddNPC(uint32_t nSQL_ID, uint32_t nRaw_ID); // Load single SQL NPC from given SQL ID + void DelNPC(uint32_t nWorldID); // Remove given NPC from list. Works for *all* npcs // but uppon zone reset they're back. }; @@ -300,10 +272,8 @@ public: ~PNPCManager(); void Update(); - PNPCWorld* InitWorld( u32 nWorldID ); + PNPCWorld* InitWorld( uint32_t nWorldID ); - PNPCWorld* GetWorld( u32 nWorldID ); + PNPCWorld* GetWorld( uint32_t nWorldID ); void InitPlayer( PClient* nClient ); // Player is entering zone }; - -#endif diff --git a/server/src/game/npc_ai.cpp b/TinNS/Source/GameServer/NpcAi.cxx similarity index 92% rename from server/src/game/npc_ai.cpp rename to TinNS/Source/GameServer/NpcAi.cxx index 501d45d..aa4606e 100644 --- a/server/src/game/npc_ai.cpp +++ b/TinNS/Source/GameServer/NpcAi.cxx @@ -1,11 +1,12 @@ -#include "main.h" -#include "include/npc.h" +#include "GameServer/Includes.hxx" +#include "GameServer/Definitions/Includes.hxx" +#include "Common/Includes.hxx" // First try of an "AI" :P void PNPCWorld::CheckForEnemies(PNPC* nNPC) { //return; - std::time_t tNow = time(NULL); + time_t tNow = time(NULL); // Is it time for next enemy check? // Temp: Skip that for IDs below 1000 @@ -20,7 +21,7 @@ void PNPCWorld::CheckForEnemies(PNPC* nNPC) // Loop all NPCs in my world // tNearestEnemy[0] = WorldID | tNearestEnemy[1] = Distance to us - u32 tNearestEnemy[2] = {0,0}; + uint32_t tNearestEnemy[2] = {0,0}; for ( PNPCMap::iterator it = mNPCs.begin(); it != mNPCs.end(); it++ ) { @@ -31,7 +32,7 @@ void PNPCWorld::CheckForEnemies(PNPC* nNPC) if(tNPC->GetRealWorldID() == nNPC->GetRealWorldID()) continue; - u16 tDistance = DistanceApprox(nNPC->mPosX, nNPC->mPosY, nNPC->mPosZ, tNPC->mPosX, tNPC->mPosY, tNPC->mPosZ); + uint16_t tDistance = DistanceApprox(nNPC->mPosX, nNPC->mPosY, nNPC->mPosZ, tNPC->mPosX, tNPC->mPosY, tNPC->mPosZ); // Is NPC infight? if(nNPC->GetActionStatus() == NPC_ACTIONSTATE_ATTACK) diff --git a/server/src/game/npc_conversation.cpp b/TinNS/Source/GameServer/NpcConversation.cxx similarity index 82% rename from server/src/game/npc_conversation.cpp rename to TinNS/Source/GameServer/NpcConversation.cxx index 05a4c82..0528819 100644 --- a/server/src/game/npc_conversation.cpp +++ b/TinNS/Source/GameServer/NpcConversation.cxx @@ -1,42 +1,8 @@ -/* -TinNS (TinNS is not a Neocron Server) -Copyright (C) 2005 Linux Addicted Community -maintainer Akiko +#include "GameServer/Includes.hxx" +#include "GameServer/Definitions/Includes.hxx" +#include "Common/Includes.hxx" -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 -of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301, USA. -*/ - -/* - -npc_conversation.cpp - Split up file for NPC conversations (Trade and QuestStuff) - -CREATION: 11 Oct 2009 Namikon - -*/ - -#include "main.h" -#include "include/npc.h" -#include "include/worlds.h" -#include "include/npctemplate.h" -#include "include/worlddatatemplate.h" -#include "include/msgbuilder.h" - -///*********************************************************************** - -bool PNPC::SetShopQuality(u8 nNewVal) +bool PNPC::SetShopQuality(uint8_t nNewVal) { // Ignore that setting if NPC is loaded from .def if(mFromDEF == true) @@ -56,7 +22,7 @@ bool PNPC::ReloadShopList() return true; } -void PNPC::AddToVectorList(u16 nItemID, u32 nPrice) +void PNPC::AddToVectorList(uint16_t nItemID, uint32_t nPrice) { stShopListEntry tEntry; tEntry.ItemID = nItemID; @@ -65,18 +31,18 @@ void PNPC::AddToVectorList(u16 nItemID, u32 nPrice) mVectItemsInShop.push_back(tEntry); } -void PNPC::ContentListAddItem(PMessage* nContentList, u16 nItemID, u32 nBasePrice, bool nAddToList) +void PNPC::ContentListAddItem(PMessage* nContentList, uint16_t nItemID, uint32_t nBasePrice, bool nAddToList) { // Items with baseprice = 0 are ignored! if(nBasePrice == 0) return; // Modify baseprice with Config value - f32 tPerCent = Config->GetOptionInt("item_price"); + float tPerCent = Config->GetOptionInt("item_price"); tPerCent = tPerCent / 100; - u32 tPrice = nBasePrice * tPerCent; - *nContentList << ( u16 ) nItemID; - *nContentList << ( u32 )( tPrice ); + uint32_t tPrice = nBasePrice * tPerCent; + *nContentList << ( uint16_t ) nItemID; + *nContentList << ( uint32_t )( tPrice ); if(nAddToList) AddToVectorList(nItemID, tPrice); @@ -84,7 +50,7 @@ void PNPC::ContentListAddItem(PMessage* nContentList, u16 nItemID, u32 nBasePric if (gDevDebug) Console->Print("[PNPC::ContentListAddItem] Adding item: ID: %d Price: %u", nItemID, tPrice); } -void PNPC::ContentListAddItemGroup(PMessage* nContentList, u32 nItemGroupID) +void PNPC::ContentListAddItemGroup(PMessage* nContentList, uint32_t nItemGroupID) { const PDefItems* tDefItems = NULL; std::map::const_iterator itStart = GameDefs->Items()->ConstIteratorBegin(); @@ -92,11 +58,11 @@ void PNPC::ContentListAddItemGroup(PMessage* nContentList, u32 nItemGroupID) for ( std::map::const_iterator i = itStart; i != itEnd; i++ ) { tDefItems = i->second; - if((u32)tDefItems->GetItemGroupID() == nItemGroupID) + if((uint32_t)tDefItems->GetItemGroupID() == nItemGroupID) { // Pricing: Use Baseprice // If Baseprice is 0, use Quality * Techlevel * 2 - u32 tPrice = tDefItems->GetBasePrice(); + uint32_t tPrice = tDefItems->GetBasePrice(); if(tPrice == 0) { tPrice = tDefItems->GetTechlevel() * mItemQuality * 2; @@ -131,7 +97,7 @@ bool PNPC::DoSQLShoppingList( PClient* nClient, PMessage* nContentList ) return false; } - f32 tPerCent = Config->GetOptionInt("item_price"); + float tPerCent = Config->GetOptionInt("item_price"); tPerCent = tPerCent / 100; while((row = mysql_fetch_row(result))) @@ -141,7 +107,7 @@ bool PNPC::DoSQLShoppingList( PClient* nClient, PMessage* nContentList ) { // Pricing: If no value in DB is set, use Baseprice // If Baseprice is 0, use Quality * Techlevel * 2 - u32 tPrice = atoi(row[3]); + uint32_t tPrice = atoi(row[3]); if(tPrice == 0) { tPrice = t_item->GetBasePrice(); @@ -153,10 +119,10 @@ bool PNPC::DoSQLShoppingList( PClient* nClient, PMessage* nContentList ) // Modify price as told in config tPrice = tPrice * tPerCent; - u16 tItemID = atoi(row[2]); + uint16_t tItemID = atoi(row[2]); - *nContentList << ( u16 ) tItemID; - *nContentList << ( u32 ) tPrice; + *nContentList << ( uint16_t ) tItemID; + *nContentList << ( uint32_t ) tPrice; // Store item position in list for later trade stuff AddToVectorList(tItemID, tPrice); @@ -230,7 +196,7 @@ void PNPC::StartDialog( PClient* nClient/*, string &nDialogscript*/ ) t_ScriptName = mDialogScript; } - u32 tWorldID = GetRealWorldID(); + uint32_t tWorldID = GetRealWorldID(); // Starts dialog with NPC // First, set required values in client's char nClient->GetChar()->SetDialogNPC(mWorldID); @@ -248,7 +214,7 @@ void PNPC::StartConversation( PClient* nClient ) { // Set Offset to mWorldID // .def NPCs need this offset in order to work - u32 tRealID = GetRealWorldID(); + uint32_t tRealID = GetRealWorldID(); // Check if NPC has script for talking // OR @@ -358,7 +324,7 @@ void PNPC::StartConversation( PClient* nClient ) // DoConversation: // nClient : The client which startet the conversation / is doing it right now // nAnswer: the Answer the player clicked -void PNPC::DoConversation( PClient* nClient, u8 nAnswer ) +void PNPC::DoConversation( PClient* nClient, uint8_t nAnswer ) { // LUA Engine v3: Let the LuaEngine handle everything! LuaEngine->ProcessDialogScript(nClient, mLUAFile, nAnswer); diff --git a/TinNS/Source/GameServer/NpcTemplate.cxx b/TinNS/Source/GameServer/NpcTemplate.cxx new file mode 100644 index 0000000..565eeb8 --- /dev/null +++ b/TinNS/Source/GameServer/NpcTemplate.cxx @@ -0,0 +1,40 @@ +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" + +PNPCTemplate::PNPCTemplate() +{ + mUnknown1 = 0; + mPosY = 0.0f; + mPosZ = 0.0f; + mPosX = 0.0f; + mNPCTypeID = 0; + mActorStringSize = 0; + mAngleStringSize = 0; + mNpcID = 0; + mHasAdditionalCoords = 0; + mUnknown2a = 0; + mUnknown2b = 0; + mUnknown2c = 0; + /*mUnknown3*/mTradeID = 0; + mUnknown4 = 0; + mActorName = ""; + mAngle = ""; +} + +PNPCTemplate::~PNPCTemplate() +{ + // Cleanup waypoints + for ( PWaypointMap::iterator i = mWayPoints.begin(); i != mWayPoints.end(); i++ ) + delete i->second; +} + +void PNPCTemplate::AddWayPoint(float nX, float nY, float nZ, uint8_t nID) +{ + struct s_floatcoords *tWayPoint = new s_floatcoords; + tWayPoint->mX = nX; + tWayPoint->mY = nY; + tWayPoint->mZ = nZ; + + if ( mWayPoints.insert( std::make_pair( nID, tWayPoint)).second ) + if ( gDevDebug ) Console->Print( "%s Waypoint %d (X %0.1f Y %0.1f Z %0.1f) added to NPC", Console->ColorText( CYAN, BLACK, "[DEBUG]" ), nID, nX, nY, nZ ); +} diff --git a/TinNS/Source/GameServer/NpcTemplate.hxx b/TinNS/Source/GameServer/NpcTemplate.hxx new file mode 100644 index 0000000..36af4d9 --- /dev/null +++ b/TinNS/Source/GameServer/NpcTemplate.hxx @@ -0,0 +1,192 @@ +#pragma once + +#include +#include + +struct s_floatcoords { + float mX; + float mY; + float mZ; +}; +typedef std::map PWaypointMap; + +class PNPCTemplate { + friend class PWorldDatParser; + +private: + + PWaypointMap mWayPoints; + + uint32_t mUnknown1; // Is always 0x20001200, in every log. maybe header for NPCs? + float mPosY; + float mPosZ; + float mPosX; + uint32_t mNPCTypeID; //npc type in npc.def + uint8_t mActorStringSize; //string size with ending 0 + uint8_t mAngleStringSize; //string size with ending 0 + uint16_t mNpcID; + uint8_t mHasAdditionalCoords; // Seems to be the NUMBER OF additional Coords for the NPC ("Coords" = X/Y/Z in float, not uint16_t!!) + uint8_t mUnknown2a; + uint8_t mUnknown2b; + uint8_t mUnknown2c; + uint16_t mTradeID; //mUnknown3; //00 00 ? + uint16_t mUnknown4; //04 00 ? + std::string mActorName; + std::string mAngle; + + /* // Not sure about that. Commented out until someone finds out how to deal with those "extra" informations + float mWaypoint1_Y; + float mWaypoint1_Z; + float mWaypoint1_X; + float mWaypoint2_Y; + float mWaypoint2_Z; + float mWaypoint2_X; + float mWaypoint3_Y; + float mWaypoint3_Z; + float mWaypoint3_X; + float mWaypoint4_Y; + float mWaypoint4_Z; + float mWaypoint4_X; + float mWaypoint5_Y; + float mWaypoint5_Z; + float mWaypoint5_X; + */ + +public: + PNPCTemplate(); + ~PNPCTemplate(); + + void AddWayPoint(float nX, float nY, float nZ, uint8_t nID); + // TODO: Add GetWaypoint function + + inline uint32_t GetUnknown1() const + { + return mUnknown1; + }; + inline float GetPosX() const + { + return mPosY; + }; + inline float GetPosY() const + { + return mPosZ; + }; + inline float GetPosZ() const + { + return mPosX; + }; + inline uint32_t GetNPCTypeID() const + { + return mNPCTypeID; + }; + inline uint8_t GetActorStrSize() const + { + return mActorStringSize; + }; + inline uint8_t GetAngleStrSize() const + { + return mAngleStringSize; + }; + inline uint16_t GetNpcID() const + { + return mNpcID; + }; + inline uint8_t GetHasAdditionalCoords() const + { + return mHasAdditionalCoords; + }; + inline uint8_t GetUnknown2a() const + { + return mUnknown2a; + }; + inline uint8_t GetUnknown2b() const + { + return mUnknown2b; + }; + inline uint8_t GetUnknown2c() const + { + return mUnknown2c; + }; + inline uint16_t /*GetUnknown3*/GetTradeID() const + { + return mTradeID;//mUnknown3; + }; + inline uint16_t GetUnknown4() const + { + return mUnknown4; + }; + inline std::string GetActorName() const + { + return mActorName; + }; + inline std::string GetAngle() const + { + return mAngle; + }; + + + inline void SetUnknown1( uint32_t nValue ) + { + mUnknown1 = nValue; + }; + inline void SetPosX( float nValue ) + { + mPosY = nValue; + }; + inline void SetPosY( float nValue ) + { + mPosZ = nValue; + }; + inline void SetPosZ( float nValue ) + { + mPosX = nValue; + }; + inline void SetNPCTypeID( uint32_t nValue ) + { + mNPCTypeID = nValue; + }; + inline void SetActorStrSize( uint8_t nValue ) + { + mActorStringSize = nValue; + }; + inline void SetAngleStrSize( uint8_t nValue ) + { + mAngleStringSize = nValue; + }; + inline void SetNpcID( uint16_t nValue ) + { + mNpcID = nValue; + }; + inline void SetHasAdditionalCoords( uint8_t nValue ) + { + mHasAdditionalCoords = nValue; + }; + inline void SetUnknown2a( uint8_t nValue ) + { + mUnknown2a = nValue; + }; + inline void SetUnknown2b( uint8_t nValue ) + { + mUnknown2b = nValue; + }; + inline void SetUnknown2c( uint8_t nValue ) + { + mUnknown2c = nValue; + }; + inline void /*SetUnknown3*/SetTradeID( uint16_t nValue ) + { + /*mUnknown3*/mTradeID = nValue; + }; + inline void SetUnknown4( uint16_t nValue ) + { + mUnknown4 = nValue; + }; + inline void SetActorName( std::string nValue ) + { + mActorName = nValue; + }; + inline void SetAngle( std::string nValue ) + { + mAngle = nValue; + }; +}; diff --git a/server/src/game/outpost.cpp b/TinNS/Source/GameServer/Outpost.cxx similarity index 69% rename from server/src/game/outpost.cpp rename to TinNS/Source/GameServer/Outpost.cxx index ae54c8c..2ed10e8 100644 --- a/server/src/game/outpost.cpp +++ b/TinNS/Source/GameServer/Outpost.cxx @@ -1,34 +1,6 @@ -/* -TinNS (TinNS is not a Neocron Server) -Copyright (C) 2005 Linux Addicted Community -maintainer Akiko - -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 -of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301, USA. -*/ - -/* - -outpost.cpp - TinNS outpost handling - -CREATION: 24 Oct 2009 Namikon - -*/ - -#include "main.h" -#include "include/msgbuilder.h" +#include "GameServer/Includes.hxx" +#include "GameServer/Definitions/Includes.hxx" +#include "Common/Includes.hxx" POutpost::POutpost() { @@ -38,7 +10,7 @@ POutpost::~POutpost() { } -u32 POutpost::GetCurrentClan(u32 nOutpostID) +uint32_t POutpost::GetCurrentClan(uint32_t nOutpostID) { MYSQL_RES *result = NULL; char tQuery[200]; @@ -59,14 +31,14 @@ u32 POutpost::GetCurrentClan(u32 nOutpostID) return 0; } - u32 tClanID = atoi(mysql_fetch_row(result)[0]); + uint32_t tClanID = atoi(mysql_fetch_row(result)[0]); MySQL->FreeGameSQLResult(result); return tClanID; } // Check if given nZoneID is an outpost area -bool POutpost::IsZoneOPArea(u32 nZoneID) +bool POutpost::IsZoneOPArea(uint32_t nZoneID) { // Outpost ID == WorldID // Outpost Underground = WorldID + 2000 @@ -119,8 +91,8 @@ void POutpost::SendOPAreaData(PClient* nClient) row = mysql_fetch_row(result); - u32 tClanID = atoi(row[0]); - u8 tFactionID = atoi(row[1]); + uint32_t tClanID = atoi(row[0]); + uint8_t tFactionID = atoi(row[1]); MySQL->FreeGameSQLResult(result); diff --git a/TinNS/Source/GameServer/Outpost.hxx b/TinNS/Source/GameServer/Outpost.hxx new file mode 100644 index 0000000..13d6415 --- /dev/null +++ b/TinNS/Source/GameServer/Outpost.hxx @@ -0,0 +1,13 @@ +#pragma once + +#include + +class POutpost { +public: + POutpost(); + ~POutpost(); + + bool IsZoneOPArea(uint32_t nZoneID); // checks if given zoneID is either outpost zone or underground of OP + void SendOPAreaData(PClient* nClient); // Sends OP data to client (Owning clan/faction) + uint32_t GetCurrentClan(uint32_t nOutpostID); // Get current ClanID of given Outpost +}; diff --git a/TinNS/Source/GameServer/RemoteConsole.cxx b/TinNS/Source/GameServer/RemoteConsole.cxx new file mode 100644 index 0000000..3417479 --- /dev/null +++ b/TinNS/Source/GameServer/RemoteConsole.cxx @@ -0,0 +1,230 @@ +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" + +#if 0 +static const int RCON_INPUTLEN = 512; + +struct PRConClient +{ + enum + { + RCCS_AUTH, + RCCS_AUTH_USER, + RCCS_AUTH_PASS, + RCCS_VALID, + RCCS_DISCONNECT + } mState; + + PSocket *mSocket; + PAccount *mAccount; + char mInput[RCON_INPUTLEN]; + int mInputLen; + bool mEcho; + std::clock_t mSleep, mSleepStart; + int mNumFailures; + + inline PRConClient(NLsocket &Sock) + { + mSocket = new PSocket(Sock); + mAccount = 0; + mInputLen = 0; + mEcho = true; + mSleep = 0; + mSleepStart = 0; + mNumFailures = 0; + } + + inline ~PRConClient() + { + delete mSocket; + } + + inline void Print(const char *Fmt, ...) + { + static char Str[256]; + va_list args; + va_start(args, Fmt); + vsnprintf(Str, 255, Fmt, args); + va_end(args); + mSocket->Write(Str); + } + +}; + +PRConsole::PRConsole() +{ + mListener = NL_INVALID; +} + +PRConsole::~PRConsole() +{ + if(mListener != NL_INVALID) + nlClose(mListener); + + for(ClientList::iterator i=mClients.begin(); i!=mClients.end(); i++) + delete *i; +} + +void PRConsole::Start() +{ + // CHECK FOR rconsole enabled!!! + Console->LPrint("Starting remote console..."); + uint16_t Port = Config->GetOptionInt("rconsole_port"); + mListener = nlOpen(Port, NL_TCP); + if(mListener == NL_INVALID) + { + Console->LPrint(RED, BLACK, "[ERROR]"); + Console->LPrint(" Remote console failed"); + Console->LClose(); + return; + } + + Console->LPrint(GREEN, BLACK, "Success"); + Console->LClose(); + nlListen(mListener); +} + +void PRConsole::Update() +{ + if(mListener==NL_INVALID) + return; + + NLsocket temp = nlAcceptConnection(mListener); + if(temp != NL_INVALID) + { + // TODO: print client ip addr + Console->Print("RConsole: client connected"); + PRConClient *cl = new PRConClient(temp); + cl->mState = PRConClient::RCCS_AUTH; + mClients.push_back(cl); + cl->Print("TinNS shell [%s]\r\n", TINNS_VERSION); + } + + for(ClientList::iterator i=mClients.begin(); i!=mClients.end();) + { + ClientList::iterator j=i; + PRConClient *cl = *i; + ++i; + if(!cl->mSocket->Update() || cl->mSocket->TimeOut()) + { + Console->Print("RConsole: client disconnected"); + mClients.erase(j); + delete cl; + continue; + } + + if(cl->mSleep > 0) + { + std::clock_t t = std::clock(); + cl->mSleep -= (t-cl->mSleepStart); + cl->mSleepStart = t; + + if(cl->mSleep < 0) + cl->mSleep = 0; + + // flush socket while sleeping + int Size=0; + cl->mSocket->Read(&Size); + + continue; + } + + if(cl->mState==PRConClient::RCCS_AUTH) + { + cl->Print("\r\nlogin: "); + cl->mState = PRConClient::RCCS_AUTH_USER; + } + + const uint8_t *Buf = 0; + int Size=0; + if((bool)(Buf = cl->mSocket->Read(&Size))) + { + for(int i=0; imInputLen < RCON_INPUTLEN) + { + switch(Buf[i]) + { + case 0x08 : + { + if(cl->mInputLen > 0) + { + if(cl->mEcho) + cl->mSocket->Write(Buf[i]); + cl->mInput[cl->mInputLen]=0; + --cl->mInputLen; + } + break; + } + + case '\n' : + { + if(cl->mEcho) + cl->mSocket->Write(Buf[i]); + cl->mInput[cl->mInputLen]=0; + ProcessClient(cl); + cl->mInputLen = 0; + break; + } + + default : + { + cl->mInput[cl->mInputLen++]=Buf[i]; + if(cl->mEcho) + cl->mSocket->Write(Buf[i]); + break; + } + } + } + } + } +} + +void PRConsole::ProcessClient(PRConClient* Client) +{ + Console->Print(">%s", Client->mInput); + if(Client->mInputLen > 1) + { + if(Client->mInput[Client->mInputLen-1] == '\r') + Client->mInput[Client->mInputLen-1]=0; + + if(Client->mState == PRConClient::RCCS_AUTH_USER) + { + Client->mAccount = Database->GetAccount(Client->mInput); + Client->mState = PRConClient::RCCS_AUTH_PASS; + Client->Print("password: "); + Client->mEcho = false; + } else + if(Client->mState == PRConClient::RCCS_AUTH_PASS) + { + Client->mEcho = true; + if((!Client->mAccount) || (Client->mAccount->GetPassword() != Client->mInput) || (!Client->mAccount->IsConsoleAllowed())) + { + Client->Print("Invalid user or password\r\n"); + Client->mSleepStart = std::clock(); + ++Client->mNumFailures; + if(Client->mNumFailures >= 3) + { + // sleep 1 minute + Client->mSleep = 60*CLOCKS_PER_SEC; + Client->mNumFailures = 0; + } else + Client->mSleep = 5*CLOCKS_PER_SEC; + + Client->mState = PRConClient::RCCS_AUTH; + } else + { + Client->Print("\r\n\nUser %s logged in\r\n", Client->mAccount->GetName().c_str()); + Client->mState = PRConClient::RCCS_VALID; + // disconnect after 30 minutes lacking socket activity + Client->mSocket->SetTimeOutValue(1800); + Prompt(Client); + } + } + } +} + +void PRConsole::Prompt(PRConClient *Client) +{ + Client->Print("$ ", Client->mAccount->GetName().c_str(), Config->GetOption("server_name").c_str()); +} +#endif diff --git a/TinNS/Source/GameServer/RemoteConsole.hxx b/TinNS/Source/GameServer/RemoteConsole.hxx new file mode 100644 index 0000000..82bea20 --- /dev/null +++ b/TinNS/Source/GameServer/RemoteConsole.hxx @@ -0,0 +1,22 @@ +#pragma once + +#if 0 +#include + +struct PRConClient; + +class PRConsole { +private : + typedef std::list ClientList; + ClientList mClients; + + void ProcessClient(PRConClient* Client); + void Prompt(PRConClient *Client); +public : + PRConsole(); + ~PRConsole(); + + void Start(); + void Update(); +}; +#endif diff --git a/TinNS/Source/GameServer/Server.cxx b/TinNS/Source/GameServer/Server.cxx new file mode 100644 index 0000000..a5f9932 --- /dev/null +++ b/TinNS/Source/GameServer/Server.cxx @@ -0,0 +1,82 @@ +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" + +PServer::PServer() +{ + mNumClients = 0; + mMaxClients = Config->GetOptionInt("maxclients"); + mGMSlots = Config->GetOptionInt("gm_slots"); + if(mMaxClients==0) + mMaxClients=1; + if(mGMSlots==0) + mGMSlots=1; + Console->Print("Max clients: %i / GM slots: %i", mMaxClients, mGMSlots); + mClients.reserve(mMaxClients + mGMSlots); + for(int i=0; i= mMaxClients+mGMSlots) + return 0; + + return mClients[Client]; +} + +void PServer::Update() +{ + for(int i=0; iUpdate(); + if(mClients[i]->GetConnection()==PCC_NONE && mClients[i]->getTCPConn() == 0) + { + Console->Print("Removing client %i...", i); + delete mClients[i]; + mClients[i]=0; + --mNumClients; + } + } + } +} + +void PServer::Shutdown() +{ + Console->Print("======================"); + Console->Print("Shutting down Gameserver..."); + for(int i=0; i +#include + +class PClient; + +class PServer{ +private: + int32_t mMaxClients; + int32_t mGMSlots; + int32_t mNumClients; + std::vector mClients; + +public: + PServer(); + ~PServer(); + + inline int32_t GetMaxClients() const { return mMaxClients; } + inline int32_t GetGMSlots() const { return mGMSlots; } + inline int32_t GetNumClients() const { return mNumClients; } + int NewClient(); + PClient *GetClient(int Client) const; + void Update(); + void Shutdown(); +}; diff --git a/server/src/game/skill.cpp b/TinNS/Source/GameServer/Skill.cxx similarity index 91% rename from server/src/game/skill.cpp rename to TinNS/Source/GameServer/Skill.cxx index 74b76b2..f47ae4d 100644 --- a/server/src/game/skill.cpp +++ b/TinNS/Source/GameServer/Skill.cxx @@ -1,44 +1,4 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - skill.cpp - - Authors: - - Namikon - - MODIFIED: 18 Dec 2005 Namikon - REASON: - Initial Release - MODIFIED: 01 Jan 2006 Namikon - REASON: - Initial Release - - Added SetMainSkill() - - Added SetSubSkill() - - Added SetXP() - - Added SetSP() - - Removed IncreaseSubSkill and IncreaseMainSkill - -*/ -#include "main.h" +#include "GameServer/Includes.hxx" void PSkillHandler::SetMainSkill(MAIN_SKILLS Skill, int value) { diff --git a/server/src/game/include/skill.h b/TinNS/Source/GameServer/Skill.hxx similarity index 63% rename from server/src/game/include/skill.h rename to TinNS/Source/GameServer/Skill.hxx index 74a93c6..cbd0867 100644 --- a/server/src/game/include/skill.h +++ b/TinNS/Source/GameServer/Skill.hxx @@ -1,61 +1,8 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko +#pragma once - 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 - of the License, or (at your option) any later version. +#include - 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - skill.h - - Authors: - - Namikon - - bakkdoor - - MODIFIED: 17 Dec 2005 Namikon - REASON: - Initial Release - MODIFIED: 17 Dec 2005 bakkdoor - REASON: - Fixed some typos and small bugs - MODIFIED: 18 Dec 2005 Namikon - REASON: - Moved Structs to new file, added vars for XP and SkillPoints - - Added initial skillhandling - MODIFIED: 01 Jan 2006 Namikon - REASON: - Added SetMainSkill() - - Added SetSubSkill() - - Added SetXP() - - Added SetSP() - - Removed IncreaseSubSkill and IncreaseMainSkill - - Fixed typo in SUB_SKILLS enum - MODIFIED: 19 Sep 2006 Hammag - REASON: - Added destructor for struct PSkills in order to free allocated memory - and avoid memory leak. - MODIFIED: 25 Nov 2006 Hammag - REASON: - Changed from enums (MAIN_SKILLS & SUB_SKILLS) to define, because there is no - simple way to call methods with enum-type params when using arbitrary data (from the client in the present case). - Values should even be taken from def_skills & def_subskills, with global constants - -*/ - -#ifndef SKILL_H -#define SKILL_H - -#define SUB_SKILLS u8 +#define SUB_SKILLS uint8_t #define SK_MC 1 #define SK_HC 2 #define SK_TRA 3 @@ -89,14 +36,13 @@ #define SK_PSR 44 #define SK_WPW 45 -#define MAIN_SKILLS u8 +#define MAIN_SKILLS uint8_t #define MS_STR 1 #define MS_DEX 2 #define MS_CON 3 #define MS_INT 4 #define MS_PSI 5 - class PSkillHandler { private: @@ -107,11 +53,11 @@ private: int mSTR; int mDEX; int mPSI; - unsigned short mINTsp; - unsigned short mCONsp; - unsigned short mSTRsp; - unsigned short mDEXsp; - unsigned short mPSIsp; + uint16_t mINTsp; + uint16_t mCONsp; + uint16_t mSTRsp; + uint16_t mDEXsp; + uint16_t mPSIsp; float mINTxp; float mCONxp; float mSTRxp; @@ -257,8 +203,6 @@ public: int IncreaseSubSkill(SUB_SKILLS Skill); - unsigned short GetSP(MAIN_SKILLS Skill); + uint16_t GetSP(MAIN_SKILLS Skill); float GetXP(MAIN_SKILLS Skill); }; - -#endif diff --git a/server/src/game/sql.cpp b/TinNS/Source/GameServer/Sql.cxx similarity index 78% rename from server/src/game/sql.cpp rename to TinNS/Source/GameServer/Sql.cxx index 9616c25..ff2fd8e 100644 --- a/server/src/game/sql.cpp +++ b/TinNS/Source/GameServer/Sql.cxx @@ -1,64 +1,6 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - sql.cpp - handles all mysql interactions - - Authors: - - Namikon - - bakkdoor - - MODIFIED: 24 Dec 2005 Namikon - REASON: - initial release by Namikon - MODIFIED: 26 Dec 2005 Namikon - REASON: - Fixed Connect and Query function - - Added GetWorldDoorType() for door interaction - - Added GetWorldItemType() for item interaction - - Added GetWorldItemOption() for item interaction - MODIFIED: 30 Dec 2005 bakkdoor - REASON: - changed mysql_init() parameter to null to prevent segfault - - added checking for dbHandle to prevent segfault - MODIFIED: 01 Jan 2006 Namikon - REASON: - Removed 2 Console outputs in ResQuery() - - Added missing "return NULL" to ResQuery - MODIFIED: 06 Jan 2006 Namikon - REASON: - Added color to console outputs - - Changed a few lines on the Get* functions (another std::atoi thing) - MODIFIED: 26 Jul 2006 Hammag - REASON: - Added CheckResCount() for DB Res memory leak tracking (to be done in the main loop) - rather than through Info/GameResQuery() - - fixed InfoDBInuse and GameDBInuse updating - - inhibited Info/GameDBInuse warning message in Info/GameResQuery() - MODIFIED: 27 Sep 2006 Hammag - REASON: - Added GetAptLocation() method - - Modified Apt & Item info methods as they should work, but it doesn't match the DB - So commented out some changes - DB shouln't be used anymore for that soon anyway - MODIFIED: 25 Jun 2007 Hammag - REASON: - Moved all Appartements related methods to PAppartements class - -*/ -#include "main.h" +#include +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" PMySQL::PMySQL() { @@ -303,15 +245,15 @@ void PMySQL::FreeGameSQLResult(MYSQL_RES *res) Console->Print("PMySQL::FreeGameSQLResult: Nothing to free..."); } -u32 PMySQL::EscapeString(const char* nText, char* dText, u32 dMaxLength) +uint32_t PMySQL::EscapeString(const char* nText, char* dText, uint32_t dMaxLength) { - u32 nLength = strlen(nText); - u32 tMax = (dMaxLength - 1)/2; + uint32_t nLength = strlen(nText); + uint32_t tMax = (dMaxLength - 1)/2; if(nLength > tMax) { nLength = tMax; } - + return mysql_real_escape_string(game_dbHandle, dText, nText, nLength); } diff --git a/TinNS/Source/GameServer/Sql.hxx b/TinNS/Source/GameServer/Sql.hxx new file mode 100644 index 0000000..ed028b3 --- /dev/null +++ b/TinNS/Source/GameServer/Sql.hxx @@ -0,0 +1,64 @@ +#pragma once + +#include +#include +#ifdef MYSQL_INC_DIR +#include +#else +#include +#endif + +// TODO: take all non-pure SQL DB access stuff out of this class + +class PMySQL { +private: + int info_port; + char info_host[100]; + char info_userName[100]; + char info_password[100]; + char info_database[100]; + MYSQL *info_dbHandle; + std::time_t mKeepaliveDelay; + std::time_t mLastKeepaliveSent; + + int game_port; + char game_host[100]; + char game_userName[100]; + char game_password[100]; + char game_database[100]; + MYSQL *game_dbHandle; + + int GameDBInuse; + int InfoDBInuse; + +public: + PMySQL(); + ~PMySQL(); + + void Update(); + void CheckResCount(); + + inline MYSQL *GetInfoHandle() { return info_dbHandle; }; + inline MYSQL *GetGameHandle() { return game_dbHandle; }; + + bool Connect(); + + int InfoQuery(const char *query); + MYSQL_RES *InfoResQuery(const char *query); + int GameQuery(const char *query); + MYSQL_RES *GameResQuery(const char *query); + + /*int GetWorldItemType(unsigned short ID, int Location); + int GetWorldItemOption(unsigned short ID, int Location, int option); + int GetWorldDoorType(unsigned int ID, int Location);*/ + + void ShowInfoSQLError(); + void ShowGameSQLError(); + void FreeGameSQLResult(MYSQL_RES *res); + void FreeInfoSQLResult(MYSQL_RES *res); + + inline uint32_t GetLastGameInsertId() { return mysql_insert_id(game_dbHandle); }; + inline uint32_t GetLastInfoInsertId() { return mysql_insert_id(info_dbHandle); }; + + uint32_t EscapeString(const char* nText, char* dText, uint32_t dMaxLength); +}; diff --git a/server/src/game/subway.cpp b/TinNS/Source/GameServer/Subway.cxx similarity index 61% rename from server/src/game/subway.cpp rename to TinNS/Source/GameServer/Subway.cxx index 8a1a298..f2ced03 100644 --- a/server/src/game/subway.cpp +++ b/TinNS/Source/GameServer/Subway.cxx @@ -1,33 +1,5 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - subway.h - subway class - - MODIFIED: 9 Nov 2007 Hammag - REASON: - creation - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" /* (Real time) @@ -35,70 +7,62 @@ Full cycle = 328860 ms Network delay = TBD Offset =MOD(M86-122778+(M85*29896);328860) - */ - -#include "main.h" - -#include "include/subway.h" -#include "include/chars.h" // for PCharCoordinates only - - // Determines relative position of cabs, but how ??? -const u16 PSubway::mSubwayInitData [] = {0x4396, 0x4387, 0x4370, 0x4352, 0x4334, 0x4316, 0x42f0, 0x42b4, 0x4270, 0x41f0, 0x0000}; -const u32 PSubway::mCabLoopTime = 328860; -const u32 PSubway::mCab0TimeOffset = 122778; -const s32 PSubway::mTimingAdjust = 0; -const u32 PSubway::mCabIntervalTime = 29896; -const u32 PSubway::mOpenDoorOffset [] = { 0, 42500, 83000, 146800, 170700, 226200, 262800, 303200 }; -const u32 PSubway::mOpenDoorDuration [] = { 8500, 6900, 12000, 7500, 8800, 9000, 8500, 9300 }; +const uint16_t PSubway::mSubwayInitData [] = {0x4396, 0x4387, 0x4370, 0x4352, 0x4334, 0x4316, 0x42f0, 0x42b4, 0x4270, 0x41f0, 0x0000}; +const uint32_t PSubway::mCabLoopTime = 328860; +const uint32_t PSubway::mCab0TimeOffset = 122778; +const int32_t PSubway::mTimingAdjust = 0; +const uint32_t PSubway::mCabIntervalTime = 29896; +const uint32_t PSubway::mOpenDoorOffset [] = { 0, 42500, 83000, 146800, 170700, 226200, 262800, 303200 }; +const uint32_t PSubway::mOpenDoorDuration [] = { 8500, 6900, 12000, 7500, 8800, 9000, 8500, 9300 }; const char* PSubway::mSubwayStationName[] = { "Pla => Oz", "Vr => Oz", "Pp => Oz", "Oz end", "Oz => Pla", "Pp => Pla", "Vr => Pla", "Pla end" }; PCharCoordinates PSubway::mCabExitPositions [2][mStationsNumber]; PSubway::PSubway() { - for(u8 i=0; iPrint(RED, BLACK, "[Error] PSubway::GetTimeOffset : invalid cab VhcId %d", nVhcId); @@ -108,30 +72,30 @@ u32 PSubway::GetTimeOffset(u32 nVhcId, u32 nTime) return ((nTime + mCabLoopTime - mCab0TimeOffset + mTimingAdjust + (tIndex * mCabIntervalTime)) % mCabLoopTime); } -u8 PSubway::GetStation(u32 nVhcId, u32 nTime, u32* TimeOffset) -{ - s8 i; - - u32 tTimeOffset = GetTimeOffset(nVhcId, nTime); +uint8_t PSubway::GetStation(uint32_t nVhcId, uint32_t nTime, uint32_t* TimeOffset) +{ + int8_t i; + + uint32_t tTimeOffset = GetTimeOffset(nVhcId, nTime); if(TimeOffset) { *TimeOffset = tTimeOffset; } - + for(i = mStationsNumber-1; (i >= 0) && (tTimeOffset < mOpenDoorOffset[i]); --i) ; return i; } -bool PSubway::IsDoorOpen(u32 nVhcId, u32 nTime) +bool PSubway::IsDoorOpen(uint32_t nVhcId, uint32_t nTime) { - u32 TimeOffset; - u8 tStation; - + uint32_t TimeOffset; + uint8_t tStation; + if(!GetInfoIndex(nVhcId)) { Console->Print(RED, BLACK, "[Error] PSubway::IsDoorOpen : invalid cab VhcId %d", nVhcId); - return false; + return false; } else { @@ -140,7 +104,7 @@ bool PSubway::IsDoorOpen(u32 nVhcId, u32 nTime) } } -std::string* PSubway::GetStationName(u8 nStationId) +std::string* PSubway::GetStationName(uint8_t nStationId) { if(nStationId < mStationsNumber) { @@ -153,7 +117,7 @@ std::string* PSubway::GetStationName(u8 nStationId) } } -bool PSubway::GetStationExitPosition(PCharCoordinates* nPosition, u8 nStationId, f32 nCoef) +bool PSubway::GetStationExitPosition(PCharCoordinates* nPosition, uint8_t nStationId, float nCoef) { if(nStationId < mStationsNumber) { @@ -164,17 +128,17 @@ bool PSubway::GetStationExitPosition(PCharCoordinates* nPosition, u8 nStationId, { Console->Print(RED, BLACK, "[Error] PSubway::SetStationExitPosition : invalid subway station %d", nStationId); return false; - } + } } -bool PSubway::GetInfoIndex(u32 nVhcId, u8 *Index) +bool PSubway::GetInfoIndex(uint32_t nVhcId, uint8_t *Index) { - s32 tIndex = nVhcId - mCabsBaseId; + int32_t tIndex = nVhcId - mCabsBaseId; if ((tIndex >= 0) && (tIndex < mCabsNumber)) { if(Index) { - *Index = (u8)tIndex; + *Index = (uint8_t)tIndex; } return true; } @@ -182,15 +146,15 @@ bool PSubway::GetInfoIndex(u32 nVhcId, u8 *Index) return false; } -bool PSubway::UpdateInfo(u32 nVhcId, u16 nPosition, u8 nDoorOpened) +bool PSubway::UpdateInfo(uint32_t nVhcId, uint16_t nPosition, uint8_t nDoorOpened) { - u8 tIndex; + uint8_t tIndex; if(GetInfoIndex(nVhcId, &tIndex)) { mSubways[tIndex].mPosition = nPosition; //if(mSubways[tIndex].mDoorOpened != nDoorOpened) // Console->Print("[DEBUG] Subway cab %08x : door now %s ", nVhcId, nDoorOpened ? "opened" : "closed" ); - + mSubways[tIndex].mDoorOpened = nDoorOpened; return true; @@ -199,9 +163,9 @@ bool PSubway::UpdateInfo(u32 nVhcId, u16 nPosition, u8 nDoorOpened) return false; } -u16 PSubway::GetPosition(u32 nVhcId) +uint16_t PSubway::GetPosition(uint32_t nVhcId) { - u8 tIndex; + uint8_t tIndex; if(GetInfoIndex(nVhcId, &tIndex)) { return mSubways[tIndex].mPosition; @@ -210,13 +174,13 @@ u16 PSubway::GetPosition(u32 nVhcId) return 0; } -u8 PSubway::GetFreeSeat(u32 nVhcId) +uint8_t PSubway::GetFreeSeat(uint32_t nVhcId) { - u8 tIndex; - u8 tSeatFound = 0; + uint8_t tIndex; + uint8_t tSeatFound = 0; if(GetInfoIndex(nVhcId, &tIndex)) { - for(u8 j=0; j<4; j++) + for(uint8_t j=0; j<4; j++) { if(! mSubways[tIndex].mSeatUsersId[j]) { @@ -230,9 +194,9 @@ u8 PSubway::GetFreeSeat(u32 nVhcId) return 0; } -bool PSubway::SetSeatUser(u32 nVhcId, u8 nSeat, u32 nCharId) +bool PSubway::SetSeatUser(uint32_t nVhcId, uint8_t nSeat, uint32_t nCharId) { - u8 tIndex; + uint8_t tIndex; if(GetInfoIndex(nVhcId, &tIndex) && (nSeat >= 1) && (nSeat <= 4)) { @@ -247,9 +211,9 @@ bool PSubway::SetSeatUser(u32 nVhcId, u8 nSeat, u32 nCharId) return false; } -bool PSubway::UnsetSeatUser(u32 nVhcId, u8 nSeat, u32 nCharId) +bool PSubway::UnsetSeatUser(uint32_t nVhcId, uint8_t nSeat, uint32_t nCharId) { - u8 tIndex; + uint8_t tIndex; if(GetInfoIndex(nVhcId, &tIndex) && (nSeat >= 1) && (nSeat <= 4)) { diff --git a/TinNS/Source/GameServer/Subway.hxx b/TinNS/Source/GameServer/Subway.hxx new file mode 100644 index 0000000..40197e3 --- /dev/null +++ b/TinNS/Source/GameServer/Subway.hxx @@ -0,0 +1,56 @@ +#pragma once + +#include +#include + +class PSubway { + friend class PMsgBuilder; + + struct PSubwayInfo + { + uint16_t mVhcId; + uint16_t mPosition; + uint8_t mDoorOpened; + uint32_t mSeatUsersId[4]; + }; + + public: + static const uint16_t mCabsNumber = 11; + static const uint32_t mCabsBaseId = 0x03f2; + static const uint32_t mCabsBaseHealth = 100; //should take that from .def instead... + static const uint8_t mStationsNumber = 8; + + private: + static const uint16_t mSubwayInitData []; + static const uint32_t mCabLoopTime; + static const uint32_t mCab0TimeOffset; + static const int32_t mTimingAdjust; + static const uint32_t mCabIntervalTime; + static const uint32_t mOpenDoorOffset []; + static const uint32_t mOpenDoorDuration []; + static const char* mSubwayStationName []; + static PCharCoordinates mCabExitPositions [2][mStationsNumber]; + + PSubwayInfo mSubways[mCabsNumber]; + +public: + bool GetInfoIndex(uint32_t nVhcId, uint8_t *Index = NULL); + + public: + PSubway(); + //~PSubway(); + + inline bool IsValidSubwayCab(uint32_t nVhcId) {return GetInfoIndex(nVhcId); } + bool UpdateInfo(uint32_t nVhcId, uint16_t nPosition, uint8_t nDoorOpened); + uint16_t GetPosition(uint32_t nVhcId); + + uint32_t GetTimeOffset(uint32_t nVhcId, uint32_t nTime); + uint8_t GetStation(uint32_t nVhcId, uint32_t nTime, uint32_t* TimeOffset = NULL); + bool IsDoorOpen(uint32_t nVhcId, uint32_t nTime); + std::string* GetStationName(uint8_t nStationId); + bool GetStationExitPosition(PCharCoordinates* nPosition, uint8_t nStationId, float nCoef = 0.5); + + uint8_t GetFreeSeat(uint32_t nVhcId); + bool SetSeatUser(uint32_t nVhcId, uint8_t nSeat, uint32_t nCharId); + bool UnsetSeatUser(uint32_t nVhcId, uint8_t nSeat, uint32_t nCharId); +}; diff --git a/server/src/game/terminal.cpp b/TinNS/Source/GameServer/Terminal.cxx similarity index 50% rename from server/src/game/terminal.cpp rename to TinNS/Source/GameServer/Terminal.cxx index 0577627..48525ff 100644 --- a/server/src/game/terminal.cpp +++ b/TinNS/Source/GameServer/Terminal.cxx @@ -1,40 +1,6 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - terminal.cpp - Management class for Terminal actions (Citycom, keys, vehicledepot, ...) - - MODIFIED: 08 Jan 2007 Namikon - REASON: - Created - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" -#include "include/terminal.h" -#include "include/msgbuilder.h" - +#include +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" PTerminal::PTerminal() { @@ -48,7 +14,7 @@ void PTerminal::EraseVars() mResultFields = 0; } -u8 PTerminal::GetNewEmailCount(PClient* nClient, bool nNoticeClient) +uint8_t PTerminal::GetNewEmailCount(PClient* nClient, bool nNoticeClient) { MYSQL_RES *result = NULL; MYSQL_ROW row; @@ -74,7 +40,7 @@ u8 PTerminal::GetNewEmailCount(PClient* nClient, bool nNoticeClient) if(gDevDebug) Console->Print("[DEBUG] Found new email, sending notice"); row = mysql_fetch_row(result); - u8 tRetVal = (u8)atoi(row[0]); + uint8_t tRetVal = (uint8_t)atoi(row[0]); MySQL->FreeGameSQLResult(result); if(nNoticeClient) @@ -85,4 +51,3 @@ u8 PTerminal::GetNewEmailCount(PClient* nClient, bool nNoticeClient) return tRetVal; } - diff --git a/TinNS/Source/GameServer/Terminal.hxx b/TinNS/Source/GameServer/Terminal.hxx new file mode 100644 index 0000000..6e92092 --- /dev/null +++ b/TinNS/Source/GameServer/Terminal.hxx @@ -0,0 +1,29 @@ +#pragma once + +#include + +class PTerminal { +private: + void SendTryAccessAnswer(PClient* nClient, char *nArea, bool nAllowed); + char mSQLQuery[500]; + + int mResultFields; + void EraseVars(); + + char mConPrefix[50]; + + inline bool ChkOpt(uint8_t nNumOptions, uint8_t nReqOpt) { if(nNumOptions < nReqOpt) return false; else return true; }; + bool DoStockXCheck(PClient* nClient, int nAmountEntered, int nNewAmount); + +public: + PTerminal(); + //~PTerminal(); + // Check accesslevel of Player for various Terminal actions + bool CheckAccess(PClient* nClient, char *nArea, uint16_t nCmdNr, char *nOption1, char *nOption2, char *nOption3); + uint8_t GetNewEmailCount(PClient* nClient, bool nNoticeClient = true); + // Handle ReceiveDB queries + bool HandleQueryDB(PClient* nClient, std::string *nDBCommandName, std::string *nCommandName, std::string *nOptions, uint8_t nNumOptions); + bool HandleReceiveDB(PClient* nClient, uint16_t mTerminalSessionId, std::string *nCommandName, std::string *nOptions, uint8_t nNumOptions, uint16_t nDBID, uint8_t nUnknown); + bool HandleTryAccess(PClient* nClient, uint16_t mTerminalSessionId, std::string *nCommandName, std::string *nOptions, uint8_t nNumOptions, uint16_t nDBID, uint8_t nUnknown, bool nCheckOnly = false); + bool HandleUpdateDB(PClient* nClient, uint16_t mTerminalSessionId, std::string *nCommandName, std::string *nOptions, uint8_t nNumOptions, uint16_t nDBID, uint8_t nUnknown); +}; diff --git a/server/src/game/terminal_querydb.cpp b/TinNS/Source/GameServer/TerminalQueryDatabase.cxx similarity index 81% rename from server/src/game/terminal_querydb.cpp rename to TinNS/Source/GameServer/TerminalQueryDatabase.cxx index f01d0c7..ecc03ac 100644 --- a/server/src/game/terminal_querydb.cpp +++ b/TinNS/Source/GameServer/TerminalQueryDatabase.cxx @@ -1,41 +1,8 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko +#include +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - terminal_querydb.cpp - Management class for Terminal actions (Citycom, keys, vehicledepot, ...) - > Sub-File for terminal "ReceiveDB" command - - MODIFIED: 18 Oct 2009 Namikon - REASON: - Created - -*/ - -#include "main.h" -#include "include/terminal.h" -#include "include/msgbuilder.h" - - -bool PTerminal::HandleQueryDB(PClient* nClient, std::string *nDBCommandName, std::string *nCommandName, std::string *nOptions, u8 nNumOptions) +bool PTerminal::HandleQueryDB(PClient* nClient, std::string *nDBCommandName, std::string *nCommandName, std::string *nOptions, uint8_t nNumOptions) { EraseVars(); diff --git a/server/src/game/terminal_receivedb.cpp b/TinNS/Source/GameServer/TerminalReceiveDatabase.cxx similarity index 95% rename from server/src/game/terminal_receivedb.cpp rename to TinNS/Source/GameServer/TerminalReceiveDatabase.cxx index d107638..29a7c61 100644 --- a/server/src/game/terminal_receivedb.cpp +++ b/TinNS/Source/GameServer/TerminalReceiveDatabase.cxx @@ -1,43 +1,8 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko +#include +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - terminal_receivedb.cpp - Management class for Terminal actions (Citycom, keys, vehicledepot, ...) - Sub-File for terminal "ReceiveDB" command - - MODIFIED: 12 Jan 2007 Namikon - REASON: - Created - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "include/terminal.h" -#include "include/msgbuilder.h" - -bool PTerminal::HandleReceiveDB(PClient* nClient, u16 mTerminalSessionId, std::string *nCommandName, std::string *nOptions, u8 nNumOptions, u16 nDBID, u8 nUnknown) +bool PTerminal::HandleReceiveDB(PClient* nClient, uint16_t mTerminalSessionId, std::string *nCommandName, std::string *nOptions, uint8_t nNumOptions, uint16_t nDBID, uint8_t nUnknown) { EraseVars(); int nAccessLevel = nClient->GetAccountLevel(); @@ -1027,7 +992,7 @@ bool PTerminal::HandleReceiveDB(PClient* nClient, u16 mTerminalSessionId, std::s // Loop all result fields and push answers into Message for (int t = 0; t < mResultFields; t++) { - *tDBResult << ( u16 )(strlen(row[t]) + 1); + *tDBResult << ( uint16_t )(strlen(row[t]) + 1); *tDBResult << row[t]; } } diff --git a/server/src/game/terminal_tryaccess.cpp b/TinNS/Source/GameServer/TerminalTryAccess.cxx similarity index 90% rename from server/src/game/terminal_tryaccess.cpp rename to TinNS/Source/GameServer/TerminalTryAccess.cxx index 79602a2..af52fcb 100644 --- a/server/src/game/terminal_tryaccess.cpp +++ b/TinNS/Source/GameServer/TerminalTryAccess.cxx @@ -1,47 +1,13 @@ - /* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - */ - - - - /* - terminal_tryaccess.cpp - Management class for Terminal actions (Citycom, keys, vehicledepot, ...) - > Sub-File for terminal "TryAccess" command - - MODIFIED: 12 Jan 2007 Namikon - REASON: - Created - MODIFIED: 20 Oct 2009 Namikon - REASON: - Rewritten - - */ - -#include "main.h" -#include "include/terminal.h" -#include "include/msgbuilder.h" - +#include +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" + bool PTerminal::DoStockXCheck(PClient* nClient, int nAmountEntered, int nNewAmount) { MYSQL_RES *result = NULL; char qry[100]; int tDepotAmount = 0; - + // First check if we BUY or SELL stockx snprintf(qry, 100, "SELECT sxd_amount FROM stockx_depots WHERE sxd_playerid = %d", nClient->GetChar()->GetID()); result = MySQL->GameResQuery(qry); @@ -51,12 +17,12 @@ bool PTerminal::DoStockXCheck(PClient* nClient, int nAmountEntered, int nNewAmou MySQL->ShowGameSQLError(); return false; } - + if(mysql_num_rows(result) > 0) tDepotAmount = atoi(mysql_fetch_row(result)[0]); - + MySQL->FreeGameSQLResult(result); - + if(nNewAmount == tDepotAmount) // We are going to SELL stockx { if(nAmountEntered > tDepotAmount) // Want to sell more than we have? @@ -75,64 +41,64 @@ bool PTerminal::DoStockXCheck(PClient* nClient, int nAmountEntered, int nNewAmou { return false; } - + // Everything went fine return true; } - -bool PTerminal::HandleTryAccess(PClient* nClient, u16 mTerminalSessionId, std::string *nCommandName, std::string *nOptions, u8 nNumOptions, u16 nDBID, u8 nUnknown, bool nCheckOnly) + +bool PTerminal::HandleTryAccess(PClient* nClient, uint16_t mTerminalSessionId, std::string *nCommandName, std::string *nOptions, uint8_t nNumOptions, uint16_t nDBID, uint8_t nUnknown, bool nCheckOnly) { // Empty buffer EraseVars(); - + // Stop gcc annoying about unused var - u8 dummy2 = nUnknown; - u16 dummy3 = mTerminalSessionId; + uint8_t dummy2 = nUnknown; + uint16_t dummy3 = mTerminalSessionId; dummy3 = dummy2; - + char mSQLQuery[500]; bool tGetResultFromSQL = false; bool tAllowed = false; int nAccessLevel = nClient->GetAccountLevel(); int tCharID = nClient->GetChar()->GetID(); - + switch(nDBID) { case 13: // Access to Neocronicle as GameMaster if(nAccessLevel >= PAL_VOLUNTEER) tAllowed = true; break; - + case 63: // Access to Outpost security status; ClanLevel >= 3 if(!ChkOpt(nNumOptions, 1)) break; tGetResultFromSQL = true; snprintf(mSQLQuery, 500, "SELECT count(*) FROM clanlevels INNER JOIN clans ON (cll_clanid = cl_id) INNER JOIN outposts ON (o_clan = cl_id) WHERE (o_outnum = %d AND cll_charid = %d AND cll_level >= 3)", atoi(nOptions[0].c_str()), tCharID); break; - + case 64: // Clan: ClanWars if(!ChkOpt(nNumOptions, 1)) break; tGetResultFromSQL = true; snprintf(mSQLQuery, 500, "SELECT count(*) FROM clanlevels INNER JOIN clans ON (cll_clanid = cl_id) WHERE (cl_id = %d AND cll_charid = %d AND cll_level >= 14)", atoi(nOptions[0].c_str()), tCharID); break; - + case 72: // Clan: AdminMemberAccess & AdminMoneyAccess if(!ChkOpt(nNumOptions, 1)) break; tGetResultFromSQL = true; snprintf(mSQLQuery, 500, "SELECT count(*) FROM clanlevels INNER JOIN clans ON (cll_clanid = cl_id) WHERE (cl_id = %d AND cll_charid = %d AND cll_level >= 9)", atoi(nOptions[0].c_str()), tCharID); break; - + case 73: // Clan: AdminInviteMember if(!ChkOpt(nNumOptions, 1)) break; tGetResultFromSQL = true; snprintf(mSQLQuery, 500, "SELECT count(*) FROM clanlevels INNER JOIN clans ON (cll_clanid = cl_id) WHERE (cl_id = %d AND cll_charid = %d AND cll_level >= 10)", atoi(nOptions[0].c_str()), tCharID); break; - + case 74: // Clan: AdminLevelAccess & AdminChangeRank if(!ChkOpt(nNumOptions, 1)) break; tGetResultFromSQL = true; snprintf(mSQLQuery, 500, "SELECT count(*) FROM clanlevels INNER JOIN clans ON (cll_clanid = cl_id) WHERE (cl_id = %d AND cll_charid = %d AND cll_level >= 12)", atoi(nOptions[0].c_str()), tCharID); break; - + case 88: // Clan: Money transfer Check if Option1 (Entered value) is lower or equal Option2 (Either my money or clan money) if(!ChkOpt(nNumOptions, 2)) break; if((atoi(nOptions[0].c_str()) <= atoi(nOptions[1].c_str())) && (atoi(nOptions[0].c_str()) > 0 )) // This is an not-very-well check, we do the real check later when its about to transfer the money! @@ -355,6 +321,6 @@ bool PTerminal::HandleTryAccess(PClient* nClient, u16 mTerminalSessionId, std::s PMessage* tmpMsg = MsgBuilder->BuildTryAccessAnswerMsg(nClient, tCmd, tAllowed); nClient->SendUDPMessage(tmpMsg); } - + return tAllowed; } diff --git a/server/src/game/terminal_updatedb.cpp b/TinNS/Source/GameServer/TerminalUpdateDatabase.cxx similarity index 92% rename from server/src/game/terminal_updatedb.cpp rename to TinNS/Source/GameServer/TerminalUpdateDatabase.cxx index b5a4626..96a57b1 100644 --- a/server/src/game/terminal_updatedb.cpp +++ b/TinNS/Source/GameServer/TerminalUpdateDatabase.cxx @@ -1,43 +1,9 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko +#include +#include +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - terminal_upcatedb.cpp - Management class for Terminal actions (Citycom, keys, vehicledepot, ...) - Sub-File for terminal "UpdateDB" command - - MODIFIED: 12 Jan 2007 Namikon - REASON: - Created - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" -#include "include/terminal.h" -#include "include/msgbuilder.h" - - -bool PTerminal::HandleUpdateDB(PClient* nClient, u16 mTerminalSessionId, std::string *nCommandName, std::string *nOptions, u8 nNumOptions, u16 nDBID, u8 nUnknown) +bool PTerminal::HandleUpdateDB(PClient* nClient, uint16_t mTerminalSessionId, std::string *nCommandName, std::string *nOptions, uint8_t nNumOptions, uint16_t nDBID, uint8_t nUnknown) { std::ostringstream tLongSQL; // omg my eyes... Stringstream is one of the worst inventions ever! Stick with printf syntax!!111 char tShortSQL[1024]; // Use this for small updates that will not exceed 1kb diff --git a/server/src/game/vehicle.cpp b/TinNS/Source/GameServer/Vehicle.cxx similarity index 69% rename from server/src/game/vehicle.cpp rename to TinNS/Source/GameServer/Vehicle.cxx index 56e79f0..2eb6e05 100644 --- a/server/src/game/vehicle.cpp +++ b/TinNS/Source/GameServer/Vehicle.cxx @@ -1,65 +1,26 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - vehicle.cpp - Vehicle handling - - Authors: - - Namikon - - Akiko - - MODIFIED: 08 Jan 2006 Namikon - REASON: - initial release by Namikon - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "include/vehicle.h" -#include "include/worlds.h" - +#include "GameServer/Includes.hxx" +#include "GameServer/Definitions/Includes.hxx" +#include "Common/Includes.hxx" // PVhcCoordinates -void PVhcCoordinates::SetInterpolate( const PVhcCoordinates& Pos1, const PVhcCoordinates& Pos2, f32 nCoef ) +void PVhcCoordinates::SetInterpolate( const PVhcCoordinates& Pos1, const PVhcCoordinates& Pos2, float nCoef ) { if (( nCoef < 0 ) || ( nCoef > 1 ) ) { Console->Print( RED, BLACK, "[Error] PVhcCoordinates::Interpolate : Invalid nCoef value: %f", nCoef ); nCoef = 0; } - f32 rCoef = 1 - nCoef; - - mY = ( u16 )( rCoef * Pos1.mY + nCoef * Pos2.mY ); - mZ = ( u16 )( rCoef * Pos1.mZ + nCoef * Pos2.mZ ); - mX = ( u16 )( rCoef * Pos1.mX + nCoef * Pos2.mX ); - mUD = ( u8 )( rCoef * Pos1.mUD + nCoef * Pos2.mUD ); - mLR = ( u16 )( rCoef * Pos1.mLR + nCoef * Pos2.mLR ); - mRoll = ( u16 )( rCoef * Pos1.mRoll + nCoef * Pos2.mRoll ); + float rCoef = 1 - nCoef; + + mY = ( uint16_t )( rCoef * Pos1.mY + nCoef * Pos2.mY ); + mZ = ( uint16_t )( rCoef * Pos1.mZ + nCoef * Pos2.mZ ); + mX = ( uint16_t )( rCoef * Pos1.mX + nCoef * Pos2.mX ); + mUD = ( uint8_t )( rCoef * Pos1.mUD + nCoef * Pos2.mUD ); + mLR = ( uint16_t )( rCoef * Pos1.mLR + nCoef * Pos2.mLR ); + mRoll = ( uint16_t )( rCoef * Pos1.mRoll + nCoef * Pos2.mRoll ); } -void PVhcCoordinates::SetPosition( u16 nY, u16 nZ, u16 nX, u8 nUD, u16 nLR, u16 nRoll, u8 nAct, u16 nUnknown, u8 nFF ) +void PVhcCoordinates::SetPosition( uint16_t nY, uint16_t nZ, uint16_t nX, uint8_t nUD, uint16_t nLR, uint16_t nRoll, uint8_t nAct, uint16_t nUnknown, uint8_t nFF ) { mY = nY; mZ = nZ; @@ -74,20 +35,20 @@ void PVhcCoordinates::SetPosition( u16 nY, u16 nZ, u16 nX, u8 nUD, u16 nLR, u16 // PVehicleInformation //Tmp -const u8 VhcTypes[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, +const uint8_t VhcTypes[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 50, 60, 62, 64, 65, 70 }; // (adv.) assault gliders discarded because not ok #define VHC_DISABLE_NOVULARI #ifndef VHC_DISABLE_NOVULARI -const u8 VhcTypesNum = 19; +const uint8_t VhcTypesNum = 19; #else -const u8 VhcTypesNum = 18; +const uint8_t VhcTypesNum = 18; #endif -bool PVehicleInformation::Load( u32 nVehicleId ) +bool PVehicleInformation::Load( uint32_t nVehicleId ) { - u8 i; - u8 nVId = nVehicleId % 100; //Tmp + uint8_t i; + uint8_t nVId = nVehicleId % 100; //Tmp for ( i = 0; ( i < VhcTypesNum ) && ( VhcTypes[i] < nVId ); i++ ) ; //Tmp if (( i < VhcTypesNum ) && ( VhcTypes[i] == nVId ) ) //Tmp { @@ -120,7 +81,7 @@ bool PVehicleInformation::Destroy() return false; } -bool PVehicleInformation::SetStatus( u8 nStatus ) +bool PVehicleInformation::SetStatus( uint8_t nStatus ) { if (( mStatus != 2 ) && ( nStatus <= 2 ) ) { @@ -132,9 +93,9 @@ bool PVehicleInformation::SetStatus( u8 nStatus ) } // PSpawnedVehicule -const u8 PSpawnedVehicle::mSeatsFlags[] = { 1, 2, 4, 8, 16, 32, 64, 128 }; +const uint8_t PSpawnedVehicle::mSeatsFlags[] = { 1, 2, 4, 8, 16, 32, 64, 128 }; -PSpawnedVehicle::PSpawnedVehicle( u32 nLocalId, PVehicleInformation const* nVhcInfo, u32 nLocation, PVhcCoordinates const* nVhcPos ) +PSpawnedVehicle::PSpawnedVehicle( uint32_t nLocalId, PVehicleInformation const* nVhcInfo, uint32_t nLocation, PVhcCoordinates const* nVhcPos ) { mLocalId = nLocalId; mInfo = *nVhcInfo; @@ -169,7 +130,7 @@ PSpawnedVehicle::PSpawnedVehicle( u32 nLocalId, PVehicleInformation const* nVhcI } } -void PSpawnedVehicle::SetLocation( u32 nLocation ) +void PSpawnedVehicle::SetLocation( uint32_t nLocation ) { mLocation = nLocation; } @@ -195,7 +156,7 @@ int PSpawnedVehicle::GetNumSeats() const return mVhcDef->GetNumSeats(); } -bool PSpawnedVehicle::SetSeatUser( u8 nSeatId, u32 nCharId ) +bool PSpawnedVehicle::SetSeatUser( uint8_t nSeatId, uint32_t nCharId ) { if ( nSeatId < mVhcDef->GetNumSeats() ) { @@ -210,7 +171,7 @@ bool PSpawnedVehicle::SetSeatUser( u8 nSeatId, u32 nCharId ) return false; } -bool PSpawnedVehicle::UnsetSeatUser( u8 nSeatId, u32 nCharId ) +bool PSpawnedVehicle::UnsetSeatUser( uint8_t nSeatId, uint32_t nCharId ) { if ( nSeatId < mVhcDef->GetNumSeats() ) { @@ -225,7 +186,7 @@ bool PSpawnedVehicle::UnsetSeatUser( u8 nSeatId, u32 nCharId ) return false; } -bool PSpawnedVehicle::IsCharInside( u32 nCharId ) const +bool PSpawnedVehicle::IsCharInside( uint32_t nCharId ) const { for ( int i = 0; i < mVhcDef->GetNumSeats(); ++i ) { @@ -235,7 +196,7 @@ bool PSpawnedVehicle::IsCharInside( u32 nCharId ) const return false; } -u8 PSpawnedVehicle::GetFirstFreeSeat() const +uint8_t PSpawnedVehicle::GetFirstFreeSeat() const { for ( int i = 0; i < mVhcDef->GetNumSeats(); ++i ) { @@ -245,9 +206,9 @@ u8 PSpawnedVehicle::GetFirstFreeSeat() const return 255; } -/*u8 PSpawnedVehicle::GetFreeSeats() const +/*uint8_t PSpawnedVehicle::GetFreeSeats() const { - u8 bitField = 0; + uint8_t bitField = 0; for(int i = mVhcDef->GetNumSeats() - 1; i >= 0 ; --i) { @@ -276,7 +237,7 @@ bool PVehicles::RegisterSpawnedVehicle( PSpawnedVehicle* nSpawnedVehicle ) return Result.second; } -bool PVehicles::UnregisterSpawnedVehicle( u32 nVehicleId ) +bool PVehicles::UnregisterSpawnedVehicle( uint32_t nVehicleId ) { PSpawnedVhcMap::iterator it = mSpawnedVehicles.find( nVehicleId ); if ( it != mSpawnedVehicles.end() ) @@ -290,21 +251,21 @@ bool PVehicles::UnregisterSpawnedVehicle( u32 nVehicleId ) } } -//u32 PVehicles::CreateVehicle(u32 nOwnerChar, u8 mVehicleType) {} -//bool PVehicles::RegisterVehicleOwner(u32 nVehicleId, u32 nOwnerChar) {} -//bool PVehicles::DestroyVehicle(u32 nVehicleId) {} +//uint32_t PVehicles::CreateVehicle(uint32_t nOwnerChar, uint8_t mVehicleType) {} +//bool PVehicles::RegisterVehicleOwner(uint32_t nVehicleId, uint32_t nOwnerChar) {} +//bool PVehicles::DestroyVehicle(uint32_t nVehicleId) {} -bool PVehicles::IsValidVehicle( u32 nVehicleId, bool nCheckOwner, u32 nOwnerId ) const +bool PVehicles::IsValidVehicle( uint32_t nVehicleId, bool nCheckOwner, uint32_t nOwnerId ) const { // Look in DB // tmp - u32 tVehicleId = nVehicleId; tVehicleId = tVehicleId; + uint32_t tVehicleId = nVehicleId; tVehicleId = tVehicleId; bool tCheckOwner = nCheckOwner; tCheckOwner = tCheckOwner; - u32 tOwnerId = nOwnerId; tOwnerId = tOwnerId; + uint32_t tOwnerId = nOwnerId; tOwnerId = tOwnerId; return true; // tmp } -PSpawnedVehicle* PVehicles::GetSpawnedVehicle( u32 nVehicleId ) const +PSpawnedVehicle* PVehicles::GetSpawnedVehicle( uint32_t nVehicleId ) const { PSpawnedVhcMap::const_iterator it = mSpawnedVehicles.find( nVehicleId ); if ( it != mSpawnedVehicles.end() ) @@ -317,7 +278,7 @@ PSpawnedVehicle* PVehicles::GetSpawnedVehicle( u32 nVehicleId ) const } } -bool PVehicles::GetVehicleInfo( u32 nVehicleId, PVehicleInformation* nInfo ) const +bool PVehicles::GetVehicleInfo( uint32_t nVehicleId, PVehicleInformation* nInfo ) const { PSpawnedVehicle* tVhc = GetSpawnedVehicle( nVehicleId ); if ( tVhc ) @@ -331,18 +292,18 @@ bool PVehicles::GetVehicleInfo( u32 nVehicleId, PVehicleInformation* nInfo ) con } } -PVhcInfoList* PVehicles::GetCharVehicles( u32 nCharId, u16 nMaxCount, u16 nStartIndex ) +PVhcInfoList* PVehicles::GetCharVehicles( uint32_t nCharId, uint16_t nMaxCount, uint16_t nStartIndex ) { PVhcInfoList* Entries = new PVhcInfoList(); PVehicleInformation* InfoEntry; // Tmp implementation - u16 LimitIndex = nStartIndex + nMaxCount; + uint16_t LimitIndex = nStartIndex + nMaxCount; if ( !nMaxCount || ( VhcTypesNum < LimitIndex ) ) { LimitIndex = VhcTypesNum; } - for ( u16 i = nStartIndex; ( i < LimitIndex ) ; ++i ) + for ( uint16_t i = nStartIndex; ( i < LimitIndex ) ; ++i ) { InfoEntry = new PVehicleInformation(); if ( GetVehicleInfo( nCharId * 100 + VhcTypes[i], InfoEntry ) ) @@ -358,7 +319,7 @@ PVhcInfoList* PVehicles::GetCharVehicles( u32 nCharId, u16 nMaxCount, u16 nStart return Entries; } -PSpawnedVehicle* PVehicles::SpawnVehicle( u32 nVehicleId, u32 nLocation, PVhcCoordinates const* nVhcPos ) +PSpawnedVehicle* PVehicles::SpawnVehicle( uint32_t nVehicleId, uint32_t nLocation, PVhcCoordinates const* nVhcPos ) { PSpawnedVehicle* newVhc = NULL; PWorld* cWorld; @@ -370,7 +331,7 @@ PSpawnedVehicle* PVehicles::SpawnVehicle( u32 nVehicleId, u32 nLocation, PVhcCoo if ( cWorld && GetVehicleInfo( nVehicleId, &nVhcInfo ) ) { - newVhc = cWorld->GetSpawnedVehicules()->SpawnVehicle( &nVhcInfo, nVhcPos ); + newVhc = cWorld->GetSpawnedVehicles()->SpawnVehicle( &nVhcInfo, nVhcPos ); if ( newVhc ) { if ( !RegisterSpawnedVehicle( newVhc ) ) @@ -390,7 +351,7 @@ PSpawnedVehicle* PVehicles::SpawnVehicle( u32 nVehicleId, u32 nLocation, PVhcCoo return newVhc; } -bool PVehicles::UnspawnVehicle( u32 nVehicleId ) +bool PVehicles::UnspawnVehicle( uint32_t nVehicleId ) { PWorld* cWorld; bool Result = false; @@ -407,7 +368,7 @@ bool PVehicles::UnspawnVehicle( u32 nVehicleId ) Console->Print( RED, BLACK, "[Error] PVehicles::UnspawnVehicle : Could not save vhc %d", nVehicleId ); } - Result = cWorld->GetSpawnedVehicules()->UnspawnVehicle( it->second->GetLocalId() ); + Result = cWorld->GetSpawnedVehicles()->UnspawnVehicle( it->second->GetLocalId() ); if ( Result ) { if ( !UnregisterSpawnedVehicle( nVehicleId ) ) @@ -438,7 +399,7 @@ PSpawnedVehicles::~PSpawnedVehicles() PSpawnedVehicle* PSpawnedVehicles::SpawnVehicle( PVehicleInformation const* nVhcInfo, PVhcCoordinates const* nVhcPos ) { PSpawnedVehicle* newVhc = NULL; - u32 nSize; + uint32_t nSize; if ( nVhcInfo->GetStatus() == 0 ) // only if in garage { @@ -467,7 +428,7 @@ PSpawnedVehicle* PSpawnedVehicles::SpawnVehicle( PVehicleInformation const* nVhc return newVhc; } -PSpawnedVehicle* PSpawnedVehicles::GetVehicle( u32 nLocalId ) +PSpawnedVehicle* PSpawnedVehicles::GetVehicle( uint32_t nLocalId ) { if (( nLocalId <= mVhcBaseLocalId ) && ( nLocalId > ( mVhcBaseLocalId - mSpawnedVehicles.size() ) ) ) { @@ -479,7 +440,7 @@ PSpawnedVehicle* PSpawnedVehicles::GetVehicle( u32 nLocalId ) } } -PSpawnedVehicle* PSpawnedVehicles::GetVehicleByGlobalId( u32 nVehicleId ) const +PSpawnedVehicle* PSpawnedVehicles::GetVehicleByGlobalId( uint32_t nVehicleId ) const { for ( PSpawnedVhcVector::const_iterator it = mSpawnedVehicles.begin(); it != mSpawnedVehicles.end(); it++ ) { @@ -492,9 +453,9 @@ PSpawnedVehicle* PSpawnedVehicles::GetVehicleByGlobalId( u32 nVehicleId ) const return NULL; } -bool PSpawnedVehicles::UnspawnVehicle( u32 nLocalId ) +bool PSpawnedVehicles::UnspawnVehicle( uint32_t nLocalId ) { - u16 Index; + uint16_t Index; PSpawnedVehicle* tVhc; if (( nLocalId <= mVhcBaseLocalId ) && ( nLocalId > ( mVhcBaseLocalId - mSpawnedVehicles.size() ) ) ) diff --git a/TinNS/Source/GameServer/Vehicle.hxx b/TinNS/Source/GameServer/Vehicle.hxx new file mode 100644 index 0000000..d7c407b --- /dev/null +++ b/TinNS/Source/GameServer/Vehicle.hxx @@ -0,0 +1,188 @@ +#pragma once + +#include +#include +#include +#include + +class PDefVhc; + +class PVhcCoordinates { + friend class PSpawnedVehicle; + + private: + uint16_t mY; // Y-Position in world + uint16_t mZ; // Z-Position in world + uint16_t mX; // X-Position in world + uint8_t mUD; // Up - Mid - Down (d6 - 80 - 2a) // Pitch + uint16_t mLR; // Yaw + uint16_t mRoll; + uint16_t mUnknown; // Usually 0x0001 + uint8_t mFF; // Usually 0xff ... + uint8_t mAct; // Last user action state + // mAct: bit field + //0x00 = not moving + //0x01 = Left + //0x02 = Right + //0x04 = Forward + //0x08 = Back + //0x20 = Pushing down + //0x40 = Pulling up + + public: + inline PVhcCoordinates() { mX = mY = mZ = mAct = 0; mUD = 128; mLR = 34683; mRoll = 32403;} + + void SetPosition( uint16_t nY, uint16_t nZ, uint16_t nX, uint8_t nUD, uint16_t nLR, uint16_t nRoll, uint8_t nAct = 0, uint16_t nUnknown = 1, uint8_t nFF = 0xff ); + void SetInterpolate( const PVhcCoordinates& Pos1, const PVhcCoordinates& Pos2, float nCoef ); + inline uint16_t GetX() const { return mX; } + inline uint16_t GetY() const { return mY; } + inline uint16_t GetZ() const { return mZ; } + inline uint8_t GetUD() const { return mUD; } + inline uint16_t GetLR() const { return mLR; } + inline uint16_t GetRoll() const { return mRoll; } + inline uint8_t GetAct() const { return mAct; } + inline uint8_t GetUnknown() const { return mUnknown; } + inline uint8_t GetFF() const { return mFF; } +}; + +class PVehicleInformation +{ + friend class PSpawnedVehicle; + friend class PVehicles; + + private: + uint32_t mVehicleId; + uint32_t mOwnerCharId; + uint32_t mHealth; // or float ??? + uint8_t mVehicleType; + uint8_t mStatus; //vhcStatus 0:parking, 1:in_service, 2:destroyed + + public: + inline PVehicleInformation( uint32_t nVehicleId = 0, uint32_t nOwnerCharId = 0, uint32_t nHealth = 0, uint8_t nVehicleType = 0, uint8_t nStatus = 0 ) : + mVehicleId( nVehicleId ), + mOwnerCharId( nOwnerCharId ), + mHealth( nHealth ), + mVehicleType( nVehicleType ), + mStatus( nStatus ) + { } + + inline uint32_t GetVehicleId() const { return mVehicleId; } + inline uint32_t GetOwnerCharId() const { return mOwnerCharId; } + inline uint32_t GetHealth() const { return mHealth; } // or float ??? + inline uint8_t GetVehicleType() const { return mVehicleType; } + inline uint8_t GetStatus() const { return mStatus; } + bool SetStatus( uint8_t nStatus ); + + bool Load( uint32_t nVehicleId ); + bool Save(); + bool Destroy(); +}; + +class PSpawnedVehicle +{ + private: + static const uint8_t mSeatsFlags[]; + + private: + uint32_t mLocalId; + PVehicleInformation mInfo; + uint32_t mLocation; + PVhcCoordinates mCoords; + const PDefVhc* mVhcDef; + + uint32_t mSeatUserId[8]; + uint8_t mFreeSeatsFlags; + uint8_t mNbFreeSeats; + + uint16_t minmax[4][2]; //Temp + + public: + PSpawnedVehicle( uint32_t nLocalId, PVehicleInformation const* nVhcInfo, uint32_t nLocation, PVhcCoordinates const* nVhcPos ); + + inline uint32_t GetVehicleId() const { return mInfo.mVehicleId; } + inline uint32_t GetLocalId() const { return mLocalId; } + inline const PVhcCoordinates& GetPosition() const { return mCoords; } + inline const PVehicleInformation& GetInformation() const { return mInfo; } + inline bool SetStatus( uint8_t nStatus ) { return mInfo.SetStatus( nStatus ); } + + void SetLocation( uint32_t nLocation ); + inline uint32_t GetLocation() const { return mLocation; } + void SetPosition( PVhcCoordinates const* nVhcPos ); + + inline bool Save() { return mInfo.Save(); } + + int GetNumSeats() const; + inline uint32_t GetSeatUser( uint8_t nSeatId ) const { return (( nSeatId < 8 ) ? mSeatUserId[nSeatId] : 0 ); } + bool SetSeatUser( uint8_t nSeatId, uint32_t nCharId ); + bool UnsetSeatUser( uint8_t nSeatId, uint32_t nCharId ); + bool IsCharInside( uint32_t nCharId ) const; + inline uint8_t GetFreeSeatsFlags() const { return mFreeSeatsFlags; } + inline uint8_t GetNbFreeSeats() const { return mNbFreeSeats; } + uint8_t GetFirstFreeSeat() const; + + //SetHealth(const uint32_t nHealth); + //uint32_t DoDamage(const uint32_t nHealthDec); + //uint32_t DoRepair(const uint32_t nHealthInc); +}; + +typedef std::map PSpawnedVhcMap; +typedef std::queue PVhcInfoList; +class PVehicles +{ + private: + PSpawnedVhcMap mSpawnedVehicles; + + bool RegisterSpawnedVehicle( PSpawnedVehicle* nSpawnedVehicle ); + bool UnregisterSpawnedVehicle( uint32_t nVehicleId ); + + public: + PVehicles(); + ~PVehicles(); + + //uint32_t CreateVehicle(uint32_t nOwnerChar, uint8_t mVehicleType); + //bool RegisterVehicleOwner(uint32_t nVehiculeId, uint32_t nOwnerChar); + //bool DestroyVehicle(uint32_t nVehiculeId); + bool IsValidVehicle( uint32_t nVehicleId, bool nCheckOwner = false, uint32_t nOwnerId = 0 ) const; + inline bool IsSpawned( uint32_t nVehicleId ) const { return ( mSpawnedVehicles.find( nVehicleId ) != mSpawnedVehicles.end() ); } + PSpawnedVehicle* GetSpawnedVehicle( uint32_t nVehicleId ) const; + bool GetVehicleInfo( uint32_t nVehicleId, PVehicleInformation* nInfo ) const; + PSpawnedVehicle* SpawnVehicle( uint32_t nVehicleId, uint32_t nLocation, PVhcCoordinates const* nVhcPos ); // Refuses for subway zone atm + bool UnspawnVehicle( uint32_t nVehicleId ); + + PVhcInfoList* GetCharVehicles( uint32_t nCharId, uint16_t nMaxCount = 0, uint16_t nStartIndex = 0 ); + +}; + +typedef std::vector PSpawnedVhcVector; +typedef std::queue PSpawnedVhcList; + +class PSpawnedVehicles +{ + friend class PWorld; + + public: + static const uint32_t mVhcBaseLocalId = 0x03fd; //Vhc local Id are allocated downward from this value. Could br 0x3ff, but 0x3fe is used as "target" when shooting nowhere + static const uint16_t mMaxLocalVhc = 127; + + inline static bool IsPotentialSpawnedVehicle( uint32_t nLocalId ) + { return (( nLocalId <= mVhcBaseLocalId ) && (( mVhcBaseLocalId - nLocalId ) < mMaxLocalVhc ) ); } + + private: + PSpawnedVhcVector mSpawnedVehicles; + uint16_t mNextFreeHint; + uint32_t mLocation; + + inline void SetLocation( uint32_t nLocation ) { mLocation = nLocation; } + + public: + PSpawnedVehicles(); + ~PSpawnedVehicles(); + + inline bool IsSpawned( uint32_t nLocalId ) const { return (( nLocalId <= mVhcBaseLocalId ) && (( mVhcBaseLocalId - nLocalId ) < mSpawnedVehicles.size() ) && mSpawnedVehicles[mVhcBaseLocalId-nLocalId] ); } + PSpawnedVehicle* SpawnVehicle( PVehicleInformation const* nVhcInfo, PVhcCoordinates const* nVhcPos ); + PSpawnedVehicle* GetVehicle( uint32_t nLocalId ); + PSpawnedVehicle* GetVehicleByGlobalId( uint32_t nVehicleId ) const; + bool UnspawnVehicle( uint32_t nVehicleId ); + + PSpawnedVhcList* GetSpawnedVehicles() const; +}; diff --git a/server/src/game/vhcaccessrequest.cpp b/TinNS/Source/GameServer/VehicleAccessRequest.cxx similarity index 65% rename from server/src/game/vhcaccessrequest.cpp rename to TinNS/Source/GameServer/VehicleAccessRequest.cxx index 11e3fcd..38a97b4 100644 --- a/server/src/game/vhcaccessrequest.cpp +++ b/TinNS/Source/GameServer/VehicleAccessRequest.cxx @@ -1,42 +1,4 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - vhcaccessrequest.cpp - classe for pendinf vhc access requests - - Authors: - - Hammag - - Akiko - - CREATION: 14 Apr 2009 Hammag - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "include/vhcaccessrequest.h" - +#include "GameServer/Includes.hxx" PVhcAccessRequest::PVhcAccessRequest() { @@ -45,7 +7,7 @@ PVhcAccessRequest::PVhcAccessRequest() mTimestamp = 0; } -PVhcAccessRequest::PVhcAccessRequest( u32 nRequesterCharId, u32 nVhcGlobalId ) +PVhcAccessRequest::PVhcAccessRequest( uint32_t nRequesterCharId, uint32_t nVhcGlobalId ) { mCharId = nRequesterCharId; mVhcGlobalId = nVhcGlobalId; @@ -54,10 +16,10 @@ PVhcAccessRequest::PVhcAccessRequest( u32 nRequesterCharId, u32 nVhcGlobalId ) } /* -typedef std::map PVhcAccessRequestMap; +typedef std::map PVhcAccessRequestMap; PVhcAccessRequestMap mActiveRequests; -u32 mNextRequestId; +uint32_t mNextRequestId; std::time_t mResponseWaitTime; // How long do we wait for owner answer std::time_t mCheckWaitTime; // How long do we wait for user access check (0: remaining time from mResponseWaitTime) @@ -109,12 +71,12 @@ void PVhcAccessRequestList::SetParameters( std::time_t nResponseWaitTime, std::t mReuseWaitTime = nReuseWaitTime; } -u32 PVhcAccessRequestList::Add( u32 nRequesterCharId, u32 nVhcGlobalId ) +uint32_t PVhcAccessRequestList::Add( uint32_t nRequesterCharId, uint32_t nVhcGlobalId ) { DropTimedOut(); // We could check for existing entries before PVhcAccessRequest newReq( nRequesterCharId, nVhcGlobalId ); - u32 newId = mNextRequestId; + uint32_t newId = mNextRequestId; mActiveRequests[newId] = newReq; if ( ++mNextRequestId == 0 ) @@ -123,7 +85,7 @@ u32 PVhcAccessRequestList::Add( u32 nRequesterCharId, u32 nVhcGlobalId ) return ( newId ); } -bool PVhcAccessRequestList::GetInfo(u32 nRequestId, u32* oRequesterCharId, u32* oVehicleId) const +bool PVhcAccessRequestList::GetInfo(uint32_t nRequestId, uint32_t* oRequesterCharId, uint32_t* oVehicleId) const { PVhcAccessRequestMap::const_iterator it = mActiveRequests.find( nRequestId ); if ( it != mActiveRequests.end() ) @@ -136,7 +98,7 @@ bool PVhcAccessRequestList::GetInfo(u32 nRequestId, u32* oRequesterCharId, u32* return false; } -bool PVhcAccessRequestList::RegisterResponse( u32 nRequestId, bool nStatus ) +bool PVhcAccessRequestList::RegisterResponse( uint32_t nRequestId, bool nStatus ) { DropTimedOut(); PVhcAccessRequestMap::iterator it = mActiveRequests.find( nRequestId ); @@ -160,7 +122,7 @@ bool PVhcAccessRequestList::RegisterResponse( u32 nRequestId, bool nStatus ) return false; } -bool PVhcAccessRequestList::Check( u32 nRequestId, u32 nRequesterCharId, u32 nVhcGlobalId ) +bool PVhcAccessRequestList::Check( uint32_t nRequestId, uint32_t nRequesterCharId, uint32_t nVhcGlobalId ) { DropTimedOut(); PVhcAccessRequestMap::iterator it = mActiveRequests.find( nRequestId ); diff --git a/TinNS/Source/GameServer/VehicleAccessRequest.hxx b/TinNS/Source/GameServer/VehicleAccessRequest.hxx new file mode 100644 index 0000000..fbee1bf --- /dev/null +++ b/TinNS/Source/GameServer/VehicleAccessRequest.hxx @@ -0,0 +1,42 @@ +#pragma once + +#include +#include +#include + +class PVhcAccessRequest { +public: + //uint32_t mRequestId; + time_t mTimestamp; + uint32_t mCharId; + uint32_t mVhcGlobalId; + uint8_t mStatus; // 0: no answer yet, 1: access allowed (refused req are dropped) 2: result checked + + PVhcAccessRequest(); + PVhcAccessRequest(uint32_t nRequesterCharId, uint32_t nVhcGlobalId); +}; + +class PVhcAccessRequestList { + typedef std::map PVhcAccessRequestMap; + +private: + PVhcAccessRequestMap mActiveRequests; + uint32_t mNextRequestId; + + time_t mResponseWaitTime; // How long do we wait for owner answer + time_t mCheckWaitTime; // How long do we wait for user access check (0: remaining time from mResponseWaitTime) + time_t mReuseWaitTime; // How long do we allow user to re-use the autorization after first check + + void DropTimedOut(); + +public: + PVhcAccessRequestList() ; + ~PVhcAccessRequestList(); + + void SetParameters(time_t nResponseWaitTime, time_t nCheckWaitTime, time_t nReuseWaitTime); + + uint32_t Add(uint32_t nRequesterCharId, uint32_t nVhcGlobalId); + bool GetInfo(uint32_t nRequestId, uint32_t* oRequesterCharId, uint32_t* oVehicleId) const; + bool RegisterResponse(uint32_t nRequestId, bool nStatus); + bool Check(uint32_t nRequestId, uint32_t nRequesterCharId = 0, uint32_t nVhcGlobalId = 0); +}; diff --git a/server/src/game/worldactors.cpp b/TinNS/Source/GameServer/WorldActors.cxx similarity index 79% rename from server/src/game/worldactors.cpp rename to TinNS/Source/GameServer/WorldActors.cxx index f111965..36f75d3 100644 --- a/server/src/game/worldactors.cpp +++ b/TinNS/Source/GameServer/WorldActors.cxx @@ -1,44 +1,6 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - worldactors.cpp - Management class for dynamic worldactors - - Authors: - - Namikon - - Akiko - - CREATION: 02 Jan 2007 Namikon - - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "include/worldactors.h" -#include "include/worlds.h" -#include "include/msgbuilder.h" - +#include "GameServer/Includes.hxx" +#include "GameServer/Definitions/Includes.hxx" +#include "Common/Includes.hxx" PWorldActors::PWorldActors() { @@ -49,19 +11,19 @@ PWorldActors::~PWorldActors() { } -void PWorldActors::SpawnWA(u32 nWorld, u16 nActorID, u16 nFunctionID, u32 nWOID, u16 nPosX, u16 nPosY, u16 nPosZ, u8 nRotX, u8 nRotY, u8 nRotZ) +void PWorldActors::SpawnWA(uint32_t nWorld, uint16_t nActorID, uint16_t nFunctionID, uint32_t nWOID, uint16_t nPosX, uint16_t nPosY, uint16_t nPosZ, uint8_t nRotX, uint8_t nRotY, uint8_t nRotZ) { PMessage* tmpMsg = MsgBuilder->BuildSpawnWorldObjectMsg(nActorID, nFunctionID, nWOID, nPosX, nPosY, nPosZ, nRotX, nRotY, nRotZ); ClientManager->UDPBroadcast(tmpMsg, nWorld); } -void PWorldActors::VanishWA(u32 nWorld, u32 nWAid) -{ +void PWorldActors::VanishWA(uint32_t nWorld, uint32_t nWAid) +{ PMessage* tmpMsg = MsgBuilder->BuildRemoveWorldObjectMsg(nWAid); ClientManager->UDPBroadcast(tmpMsg, nWorld); } -u32 PWorldActors::GetNextFreeWAID() +uint32_t PWorldActors::GetNextFreeWAID() { if (gDevDebug) Console->Print("DEBUG: Getting next free worldactor ID..."); MYSQL_RES *result = NULL; @@ -82,7 +44,7 @@ u32 PWorldActors::GetNextFreeWAID() } row = mysql_fetch_row(result); - u32 newWAid; + uint32_t newWAid; if(mysql_num_rows(result) == 1) { newWAid = atoi(row[wa_actor_id]); @@ -106,7 +68,7 @@ void PWorldActors::InitWorld(PClient* nClient) { DoActorCheck(); if (gDevDebug) Console->Print("DEBUG: Initializing WorldActors for client..."); - u32 tZone = nClient->GetChar()->GetLocation(); + uint32_t tZone = nClient->GetChar()->GetLocation(); MYSQL_RES *result = NULL; MYSQL_ROW row; char query[100]; @@ -130,21 +92,21 @@ void PWorldActors::InitWorld(PClient* nClient) } if (gDevDebug) Console->Print("DEBUG: We have dynamic actors, building message..."); PMessage* tmpActorSpawn = new PMessage(256); - *tmpActorSpawn << (u8)0x13; - *tmpActorSpawn << (u16)0x0000; // Placeholder - *tmpActorSpawn << (u16)0x0000; // Placeholder + *tmpActorSpawn << (uint8_t)0x13; + *tmpActorSpawn << (uint16_t)0x0000; // Placeholder + *tmpActorSpawn << (uint16_t)0x0000; // Placeholder - u16 tFuncID = 0; - u16 tOpt1 = 0; - u32 tActorID = 0; + uint16_t tFuncID = 0; + uint16_t tOpt1 = 0; + uint32_t tActorID = 0; bool tActorOk = false; while((row = mysql_fetch_row(result))) { - tFuncID = (u16)atoi(row[wa_actor_type]); - tOpt1 = (u16)atoi(row[wa_option1]); - tActorID = (u32)atoi(row[wa_actor_id]); + tFuncID = (uint16_t)atoi(row[wa_actor_type]); + tOpt1 = (uint16_t)atoi(row[wa_option1]); + tActorID = (uint32_t)atoi(row[wa_actor_id]); // First make sure we have an VALID worldactor here tActorOk = false; if(IsValidWAFunction(tFuncID) == true) @@ -166,19 +128,19 @@ void PWorldActors::InitWorld(PClient* nClient) { // Build multiframe message nClient->IncreaseUDP_ID(); - *tmpActorSpawn << (u8)0x16; - *tmpActorSpawn << (u8)0x03; - *tmpActorSpawn << (u16)nClient->GetUDP_ID(); - *tmpActorSpawn << (u8)0x1b; + *tmpActorSpawn << (uint8_t)0x16; + *tmpActorSpawn << (uint8_t)0x03; + *tmpActorSpawn << (uint16_t)nClient->GetUDP_ID(); + *tmpActorSpawn << (uint8_t)0x1b; *tmpActorSpawn << tActorID; - *tmpActorSpawn << (u8)0x19; - *tmpActorSpawn << (u16)atoi(row[wa_posY]); - *tmpActorSpawn << (u16)atoi(row[wa_posZ]); - *tmpActorSpawn << (u16)atoi(row[wa_posX]); - *tmpActorSpawn << (u8)atoi(row[wa_rotY]); - *tmpActorSpawn << (u8)atoi(row[wa_rotZ]); - *tmpActorSpawn << (u8)atoi(row[wa_rotX]); - *tmpActorSpawn << (u16)atoi(row[wa_actor_model]); + *tmpActorSpawn << (uint8_t)0x19; + *tmpActorSpawn << (uint16_t)atoi(row[wa_posY]); + *tmpActorSpawn << (uint16_t)atoi(row[wa_posZ]); + *tmpActorSpawn << (uint16_t)atoi(row[wa_posX]); + *tmpActorSpawn << (uint8_t)atoi(row[wa_rotY]); + *tmpActorSpawn << (uint8_t)atoi(row[wa_rotZ]); + *tmpActorSpawn << (uint8_t)atoi(row[wa_rotX]); + *tmpActorSpawn << (uint16_t)atoi(row[wa_actor_model]); *tmpActorSpawn << tFuncID; if((tmpActorSpawn->GetSize() + 23) >= (tmpActorSpawn->GetMaxSize() - tmpActorSpawn->GetSize())) { @@ -190,9 +152,9 @@ void PWorldActors::InitWorld(PClient* nClient) // ReInit message tmpActorSpawn = new PMessage(256); - *tmpActorSpawn << (u8)0x13; - *tmpActorSpawn << (u16)0x0000; // Placeholder - *tmpActorSpawn << (u16)0x0000; // Placeholder + *tmpActorSpawn << (uint8_t)0x13; + *tmpActorSpawn << (uint16_t)0x0000; // Placeholder + *tmpActorSpawn << (uint16_t)0x0000; // Placeholder //if (gDevDebug) Console->Print("DEBUG: Done. Starting over!"); } } @@ -213,22 +175,22 @@ void PWorldActors::InitWorld(PClient* nClient) MySQL->FreeGameSQLResult(result); } -u32 PWorldActors::AddWorldActor(PClient* nClient, u16 nActorID, u16 nFuncID, u16 nOpt1, u16 nOpt2, u16 nOpt3) +uint32_t PWorldActors::AddWorldActor(PClient* nClient, uint16_t nActorID, uint16_t nFuncID, uint16_t nOpt1, uint16_t nOpt2, uint16_t nOpt3) { PChar *tChar = nClient->GetChar(); - u16 tPosX = tChar->Coords.mX + 768; - u16 tPosY = tChar->Coords.mY + 768; - u16 tPosZ = tChar->Coords.mZ + 768; - u16 tLoc = tChar->GetLocation(); + uint16_t tPosX = tChar->Coords.mX + 768; + uint16_t tPosY = tChar->Coords.mY + 768; + uint16_t tPosZ = tChar->Coords.mZ + 768; + uint16_t tLoc = tChar->GetLocation(); //if (gDevDebug) Console->Print("DEBUG: Adding worldactor %d function %d to world %d", nActorID, nFuncID, tLoc); - return AddWorldActor(tLoc, nActorID, nFuncID, tPosX, tPosY, tPosZ, (u8)194, (u8)128, (u8)128, nOpt1, nOpt2, nOpt3); + return AddWorldActor(tLoc, nActorID, nFuncID, tPosX, tPosY, tPosZ, (uint8_t)194, (uint8_t)128, (uint8_t)128, nOpt1, nOpt2, nOpt3); } -u32 PWorldActors::AddWorldActor(u32 nWorldID, u16 nActorID, u16 nFuncID, u16 nPosX, u16 nPosY, u16 nPosZ, u8 nRotX, u8 nRotY, u8 nRotZ, u16 nOpt1, u16 nOpt2, u16 nOpt3) +uint32_t PWorldActors::AddWorldActor(uint32_t nWorldID, uint16_t nActorID, uint16_t nFuncID, uint16_t nPosX, uint16_t nPosY, uint16_t nPosZ, uint8_t nRotX, uint8_t nRotY, uint8_t nRotZ, uint16_t nOpt1, uint16_t nOpt2, uint16_t nOpt3) { if (gDevDebug) Console->Print("DEBUG: Adding new worldactor: ActorModel: %d, Function: %d, Option1: %d", nActorID, nFuncID, nOpt1); - u32 tNextWAID = GetNextFreeWAID(); // Grab next free WorldActorID + uint32_t tNextWAID = GetNextFreeWAID(); // Grab next free WorldActorID //if (gDevDebug) Console->Print("DEBUG: Next ID will be: %d", tNextWAID); char query[512]; @@ -250,10 +212,10 @@ u32 PWorldActors::AddWorldActor(u32 nWorldID, u16 nActorID, u16 nFuncID, u16 nPo return tNextWAID; } -void PWorldActors::DelWorldActor(PClient* nClient, u32 nWAid) +void PWorldActors::DelWorldActor(PClient* nClient, uint32_t nWAid) { char query[100]; - u16 tLoc = nClient->GetChar()->GetLocation(); + uint16_t tLoc = nClient->GetChar()->GetLocation(); if (gDevDebug) Console->Print("DEBUG: Removing worldactor %d from world %d", nWAid, tLoc); snprintf(query, 100, "DELETE FROM `world_actors` WHERE `wa_actor_map` = %d AND `wa_actor_id` = %d", tLoc, nWAid); @@ -269,7 +231,7 @@ void PWorldActors::DelWorldActor(PClient* nClient, u32 nWAid) VanishWA(tLoc, nWAid); } -void PWorldActors::GetWAoption(u32 nWAid, u16 nWorld, u16 &nValue1, u16 &nValue2, u16 &nValue3) +void PWorldActors::GetWAoption(uint32_t nWAid, uint16_t nWorld, uint16_t &nValue1, uint16_t &nValue2, uint16_t &nValue3) { MYSQL_RES *result = NULL; MYSQL_ROW row; @@ -303,7 +265,7 @@ void PWorldActors::GetWAoption(u32 nWAid, u16 nWorld, u16 &nValue1, u16 &nValue2 MySQL->FreeGameSQLResult(result); } -int PWorldActors::GetWASQLID(u32 nWAid, u32 nWorld) +int PWorldActors::GetWASQLID(uint32_t nWAid, uint32_t nWorld) { MYSQL_RES *result = NULL; MYSQL_ROW row; @@ -333,7 +295,7 @@ int PWorldActors::GetWASQLID(u32 nWAid, u32 nWorld) return tWAid; } -bool PWorldActors::IsDynamicActor(u32 nWAid) +bool PWorldActors::IsDynamicActor(uint32_t nWAid) { MYSQL_RES *result = NULL; char query[100]; @@ -369,7 +331,7 @@ bool PWorldActors::IsDynamicActor(u32 nWAid) return false; } /* Not needed. Better re-spawn the actor -bool PWorldActors::EditWorldActor(u32 nWorldID, int nOption1, int nOption2, int nOption3) +bool PWorldActors::EditWorldActor(uint32_t nWorldID, int nOption1, int nOption2, int nOption3) { if(IsDynamicActor(nWorldID) == false) // Make sure we really have this actor in DB return false; @@ -407,7 +369,7 @@ bool PWorldActors::EditWorldActor(u32 nWorldID, int nOption1, int nOption2, int return true; } */ -int PWorldActors::GetWorldActorFunctionID(u32 nWAid) +int PWorldActors::GetWorldActorFunctionID(uint32_t nWAid) { MYSQL_RES *result = NULL; MYSQL_ROW row; @@ -437,15 +399,15 @@ int PWorldActors::GetWorldActorFunctionID(u32 nWAid) return tFuncID; } -void PWorldActors::GetFrontPos(u32 nWAID, u16* mX, u16* mY, u16* mZ) +void PWorldActors::GetFrontPos(uint32_t nWAID, uint16_t* mX, uint16_t* mY, uint16_t* mZ) { MYSQL_RES *result = NULL; MYSQL_ROW row; char query[100]; - u16 tNewX = 0; - u16 tNewY = 0; - u16 tNewZ = 0; + uint16_t tNewX = 0; + uint16_t tNewY = 0; + uint16_t tNewZ = 0; snprintf(query, 100, "SELECT * FROM `world_actors` WHERE `wa_actor_id` = %d", nWAID); @@ -465,9 +427,9 @@ void PWorldActors::GetFrontPos(u32 nWAID, u16* mX, u16* mY, u16* mZ) } row = mysql_fetch_row(result); - tNewX = (u16)atoi(row[wa_posX]); - tNewY = (u16)atoi(row[wa_posY]); - tNewZ = (u16)atoi(row[wa_posZ]); + tNewX = (uint16_t)atoi(row[wa_posX]); + tNewY = (uint16_t)atoi(row[wa_posY]); + tNewZ = (uint16_t)atoi(row[wa_posZ]); if(tNewX > 0) *mX = tNewX - 768; if(tNewY > 0) *mY = tNewY - 768; @@ -478,7 +440,7 @@ void PWorldActors::GetFrontPos(u32 nWAID, u16* mX, u16* mY, u16* mZ) return; } -int PWorldActors::GetLinkedObjectID(u32 nWAID) +int PWorldActors::GetLinkedObjectID(uint32_t nWAID) { MYSQL_RES *result = NULL; MYSQL_ROW row; @@ -530,7 +492,7 @@ bool PWorldActors::RequiresLinkedObject(int nFunctionID) return false; } -bool PWorldActors::IsValidLinkedObject(PClient *nClient, u16 nOption1, int nFunctionID) +bool PWorldActors::IsValidLinkedObject(PClient *nClient, uint16_t nOption1, int nFunctionID) { /* diff --git a/server/src/game/include/worldactors.h b/TinNS/Source/GameServer/WorldActors.hxx similarity index 56% rename from server/src/game/include/worldactors.h rename to TinNS/Source/GameServer/WorldActors.hxx index 83a6225..423327b 100644 --- a/server/src/game/include/worldactors.h +++ b/TinNS/Source/GameServer/WorldActors.hxx @@ -1,34 +1,8 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - worldactors.h - Management class for dynamic worldactors +#pragma once - CREATION: 02 Jan 2007 Namikon +#include - MODIFIED: - REASON: - - -*/ +class PClient; /* Current known WorldActors: @@ -100,17 +74,12 @@ Current known WorldActors: */ - -#ifndef WORLDACTORS_H -#define WORLDACTORS_H - // Start from this offset (00 00 80 00) #define DYNACTORIDSTART 8388608 -class PWorldActors -{ +class PWorldActors { private: - // SQL Layout + // SQL Layout enum { wa_id, @@ -129,13 +98,13 @@ class PWorldActors wa_option3 }; - void SpawnWA(u32 nWorld, u16 nActorID, u16 nFunctionID, u32 nWOID, u16 nPosX, u16 nPosY, u16 nPosZ, u8 nRotX, u8 nRotY, u8 nRotZ); - void VanishWA(u32 nWorld, u32 nWAid); + void SpawnWA(uint32_t nWorld, uint16_t nActorID, uint16_t nFunctionID, uint32_t nWOID, uint16_t nPosX, uint16_t nPosY, uint16_t nPosZ, uint8_t nRotX, uint8_t nRotY, uint8_t nRotZ); + void VanishWA(uint32_t nWorld, uint32_t nWAid); // Get next availeable WorldactorID. First, try to find ID in known .dat files, then // Get the currently highest ID from SQL and add +1 // select distinct wi_worlditem_id from world_items order by wi_worlditem_id desc limit 1; - u32 GetNextFreeWAID(); + uint32_t GetNextFreeWAID(); public: PWorldActors(); @@ -147,31 +116,31 @@ class PWorldActors // Add new worldactor to database and spawn it. Returns created WorldID // Position is taken from nClient, same as the worldID and calls the mainfunction // The function values are optional (used for interactive objects, gogo or genrep) - u32 AddWorldActor(PClient* nClient, u16 nActorID, u16 nFuncID, u16 nOpt1 = 0, u16 nOpt2 = 0, u16 nOpt3 = 0); + uint32_t AddWorldActor(PClient* nClient, uint16_t nActorID, uint16_t nFuncID, uint16_t nOpt1 = 0, uint16_t nOpt2 = 0, uint16_t nOpt3 = 0); // Add new worldactor to database and spawn it. Returns created WorldID // The function values are optional (used for interactive objects, gogo or genrep) - u32 AddWorldActor(u32 nWorldID, u16 nActorID, u16 nFuncID, u16 nPosX, u16 nPosY, u16 nPosZ, u8 nRotX, u8 nRotY, u8 nRotZ, u16 nOpt1 = 0, u16 nOpt2 = 0, u16 nOpt3 = 0); + uint32_t AddWorldActor(uint32_t nWorldID, uint16_t nActorID, uint16_t nFuncID, uint16_t nPosX, uint16_t nPosY, uint16_t nPosZ, uint8_t nRotX, uint8_t nRotY, uint8_t nRotZ, uint16_t nOpt1 = 0, uint16_t nOpt2 = 0, uint16_t nOpt3 = 0); // Remove worldactor in given world from SQL and game - void DelWorldActor(PClient* nClient, u32 nWAid); + void DelWorldActor(PClient* nClient, uint32_t nWAid); // Get functionvalues for worldactor - void GetWAoption(u32 nWAid, u16 nWorld, u16 &nValue1, u16 &nValue2, u16 &nValue3); + void GetWAoption(uint32_t nWAid, uint16_t nWorld, uint16_t &nValue1, uint16_t &nValue2, uint16_t &nValue3); // Get SQL ID from world and worldID - int GetWASQLID(u32 nWAid, u32 nWorld); + int GetWASQLID(uint32_t nWAid, uint32_t nWorld); // Check if actorID is dynamic - bool IsDynamicActor(u32 nWAid); + bool IsDynamicActor(uint32_t nWAid); // Not needed. Better re-spawn the actor - //bool EditWorldActor(u32 nWorldID, int nOption1 = -1, int nOption2 = -1, int nOption3 = -1); + //bool EditWorldActor(uint32_t nWorldID, int nOption1 = -1, int nOption2 = -1, int nOption3 = -1); - int GetWorldActorFunctionID(u32 nWAid); + int GetWorldActorFunctionID(uint32_t nWAid); - void GetFrontPos(u32 nWAID, u16* mX, u16* mY, u16* mZ); // For chairs - int GetLinkedObjectID(u32 nWAID); // OptionValue 1 is used for linked object! + void GetFrontPos(uint32_t nWAID, uint16_t* mX, uint16_t* mY, uint16_t* mZ); // For chairs + int GetLinkedObjectID(uint32_t nWAID); // OptionValue 1 is used for linked object! // Check if given functionID does exist bool IsValidWAFunction(int nFunctionID); @@ -180,10 +149,8 @@ class PWorldActors bool RequiresLinkedObject(int nFunctionID); // Checks if the given worldobjectID is valid for this type of functionID - bool IsValidLinkedObject(PClient *nClient, u16 nOption1, int nFunctionID); + bool IsValidLinkedObject(PClient *nClient, uint16_t nOption1, int nFunctionID); // Checks for double actor-IDs and deletes them from DB void DoActorCheck(); }; - -#endif diff --git a/server/src/game/worlddatatemplate.cpp b/TinNS/Source/GameServer/WorldDataTemplate.cxx similarity index 78% rename from server/src/game/worlddatatemplate.cpp rename to TinNS/Source/GameServer/WorldDataTemplate.cxx index c349f8a..003863d 100644 --- a/server/src/game/worlddatatemplate.cpp +++ b/TinNS/Source/GameServer/WorldDataTemplate.cxx @@ -1,43 +1,6 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - -/* - worlddatatemplate.cpp - world data template (from worlds .dat files) class - - MODIFIED: 04 Oct 2006 Hammag - REASON: - creation - - MODIFIED: 21 Jun 2009 Namikon - REASON: - Added NPC Template stuff - -*/ - - -#include "main.h" - -#include "include/worlddatatemplate.h" -#include "include/world_datparser.h" -#include "include/furnituretemplate.h" -#include "include/doortemplate.h" -#include "include/npctemplate.h" +#include "GameServer/Includes.hxx" +#include "GameServer/Definitions/Includes.hxx" +#include "Common/Includes.hxx" PWorldDataTemplate::PWorldDataTemplate() { @@ -109,7 +72,7 @@ bool PWorldDataTemplate::LoadDatFile( const std::string& WorldTemplateName, cons return false; } -u32 PWorldDataTemplate::AddFurnitureItem( PFurnitureItemTemplate* nItem ) +uint32_t PWorldDataTemplate::AddFurnitureItem( PFurnitureItemTemplate* nItem ) { if ( nItem ) { @@ -138,12 +101,12 @@ u32 PWorldDataTemplate::AddFurnitureItem( PFurnitureItemTemplate* nItem ) mPositionItems[v] = nItem; /* Console->Print("Position entity %d (id 0x%x) added to world template", v, nItem->GetID()); - f32 fpX, fpY, fpZ; - u16 pX, pY, pZ; + float fpX, fpY, fpZ; + uint16_t pX, pY, pZ; nItem->GetPos(&fpX, &fpY, &fpZ); - pX = (u16) (fpX + 32000); - pY = (u16) (fpY + 32000); - pZ = (u16) (fpZ + 32000); + pX = (uint16_t) (fpX + 32000); + pY = (uint16_t) (fpY + 32000); + pZ = (uint16_t) (fpZ + 32000); Console->Print("Position Y=%f (0x%04x) Z=%f (0x%04x) X=%f (0x%04x)", fpY, pY, fpZ, pZ, fpX, pX); */ } @@ -162,7 +125,7 @@ u32 PWorldDataTemplate::AddFurnitureItem( PFurnitureItemTemplate* nItem ) return 0; } -const PFurnitureItemTemplate* PWorldDataTemplate::GetFurnitureItem( u32 ItemID ) +const PFurnitureItemTemplate* PWorldDataTemplate::GetFurnitureItem( uint32_t ItemID ) { PFurnitureItemsMap::const_iterator it = mFurnitureItems.find( ItemID ); if ( it == mFurnitureItems.end() ) @@ -171,7 +134,7 @@ const PFurnitureItemTemplate* PWorldDataTemplate::GetFurnitureItem( u32 ItemID ) return it->second; } -bool PWorldDataTemplate::getPositionItemPosition( u8 PosID, f32* pX, f32* pY, f32* pZ ) +bool PWorldDataTemplate::getPositionItemPosition( uint8_t PosID, float* pX, float* pY, float* pZ ) { if (( PosID < WORLDDATATEMPLATE_MAXPOSITEMS ) && mPositionItems[PosID] ) { @@ -181,7 +144,7 @@ bool PWorldDataTemplate::getPositionItemPosition( u8 PosID, f32* pX, f32* pY, f3 return false; } -u32 PWorldDataTemplate::AddDoor( PDoorTemplate* nDoor ) +uint32_t PWorldDataTemplate::AddDoor( PDoorTemplate* nDoor ) { if ( nDoor ) { @@ -198,7 +161,7 @@ u32 PWorldDataTemplate::AddDoor( PDoorTemplate* nDoor ) return 0; } -const PDoorTemplate* PWorldDataTemplate::GetDoor( u32 DoorID ) +const PDoorTemplate* PWorldDataTemplate::GetDoor( uint32_t DoorID ) { PDoorsMap::const_iterator it = mDoors.find( DoorID ); if ( it == mDoors.end() ) @@ -208,7 +171,7 @@ const PDoorTemplate* PWorldDataTemplate::GetDoor( u32 DoorID ) } -u32 PWorldDataTemplate::AddNPC( PNPCTemplate* nNPC ) +uint32_t PWorldDataTemplate::AddNPC( PNPCTemplate* nNPC ) { if ( nNPC ) { @@ -225,7 +188,7 @@ u32 PWorldDataTemplate::AddNPC( PNPCTemplate* nNPC ) return 0; } -const PNPCTemplate* PWorldDataTemplate::GetNPC( u32 NPCID ) +const PNPCTemplate* PWorldDataTemplate::GetNPC( uint32_t NPCID ) { PNPCsMap::const_iterator it = mNPCs.find( NPCID ); if ( it == mNPCs.end() ) @@ -236,12 +199,12 @@ const PNPCTemplate* PWorldDataTemplate::GetNPC( u32 NPCID ) void PWorldDataTemplate::SetLinkedObjects() { - f32 xI, yI, zI; - f32 xD, yD, zD; - f32 D2, minD2; - u32 minObjID; - u16 fnctType; - u16 tGROrder = 0; + float xI, yI, zI; + float xD, yD, zD; + float D2, minD2; + uint32_t minObjID; + uint16_t fnctType; + uint16_t tGROrder = 0; for ( PFurnitureItemsMap::iterator it = mFurnitureItems.begin(); it != mFurnitureItems.end(); it++ ) { diff --git a/TinNS/Source/GameServer/WorldDataTemplate.hxx b/TinNS/Source/GameServer/WorldDataTemplate.hxx new file mode 100644 index 0000000..d93f4ba --- /dev/null +++ b/TinNS/Source/GameServer/WorldDataTemplate.hxx @@ -0,0 +1,74 @@ +#pragma once + +#include +#include + +#define WORLDDATATEMPLATE_MAXPOSITEMS 11 + +class PFurnitureItemTemplate; +typedef std::map PFurnitureItemsMap; + +class PDoorTemplate; +typedef std::map PDoorsMap; + +class PNPCTemplate; +typedef std::map PNPCsMap; + +class PWorldDataTemplate +{ +private: + std::string mName; // (datfile) relative path+filename without leading ./ or ./worlds/ nor .dat extension + std::string mBspName; // (bsp file) relative path+filename without leading ./ or ./worlds/ nor .bsp extension + PFurnitureItemsMap mFurnitureItems; + PDoorsMap mDoors; + PNPCsMap mNPCs; + PFurnitureItemTemplate* mPositionItems[WORLDDATATEMPLATE_MAXPOSITEMS]; + + int mUseCount; + + void DatFileDataCleanup(); + void SetLinkedObjects(); // This method implements some workarouds for some world objects on which we lack info. + +public: + PWorldDataTemplate(); + ~PWorldDataTemplate(); + + bool LoadDatFile(const std::string& WorldTemplateName, const std::string& nFilename, const bool nTestAccesOnly = false); + inline const std::string& GetName() + { + return mName; + } + inline const std::string& GetBspName() + { + return mBspName; + } + + inline void IncreaseUseCount() + { + ++mUseCount; + } + inline int DecreaseUseCount() + { + return (mUseCount ? --mUseCount : 0); + } + inline int GetUseCount() + { + return mUseCount; + } + + uint32_t AddFurnitureItem(PFurnitureItemTemplate* nItem); + const PFurnitureItemTemplate* GetFurnitureItem(uint32_t ItemID); + bool getPositionItemPosition(uint8_t PosID, float* pX, float* pY, float* pZ); + + uint32_t AddDoor(PDoorTemplate* nDoor); + const PDoorTemplate* GetDoor(uint32_t DoorID); + + uint32_t AddNPC(PNPCTemplate* nNPC); + + // External functions for NPCManager + const PNPCTemplate* GetNPC(uint32_t NPCID); + inline const PNPCsMap *GetNPCMap() const + { + return &mNPCs; + }; // called by class PNPCWorld to get all NPCs for this world +}; diff --git a/server/src/game/worlds.cpp b/TinNS/Source/GameServer/Worlds.cxx similarity index 84% rename from server/src/game/worlds.cpp rename to TinNS/Source/GameServer/Worlds.cxx index 2921d92..5efc667 100644 --- a/server/src/game/worlds.cpp +++ b/TinNS/Source/GameServer/Worlds.cxx @@ -1,55 +1,15 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - worlds.cpp - world class and world map class - - MODIFIED: 06 Oct 2006 Hammag - REASON: - creation - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "common/filesystem.h" -#include "include/def_worlds.h" -#include "include/gamedefs.h" -#include "include/furnituretemplate.h" -#include "include/worlddatatemplate.h" -#include "include/worlds.h" -#include "include/appartements.h" -#include "include/vehicle.h" - #include - +#include "GameServer/Includes.hxx" +#include "GameServer/Definitions/Includes.hxx" +#include "Common/Includes.hxx" /**** PWorld ****/ -u16 const PWorld::mZoneOutLimitOffset = 0x100; -u16 const PWorld::mBottomZoneOutLimit = 0x4800 - PWorld::mZoneOutLimitOffset; -u16 const PWorld::mBottomZoneInLimit = 0x4a00; -u16 const PWorld::mTopZoneOutLimit = 0xb200 + PWorld::mZoneOutLimitOffset; -u16 const PWorld::mTopZoneInLimit = 0xb000; +uint16_t const PWorld::mZoneOutLimitOffset = 0x100; +uint16_t const PWorld::mBottomZoneOutLimit = 0x4800 - PWorld::mZoneOutLimitOffset; +uint16_t const PWorld::mBottomZoneInLimit = 0x4a00; +uint16_t const PWorld::mTopZoneOutLimit = 0xb200 + PWorld::mZoneOutLimitOffset; +uint16_t const PWorld::mTopZoneInLimit = 0xb000; +const std::string EmptyString; PWorld::PWorld() { @@ -62,7 +22,7 @@ PWorld::~PWorld() { } -bool PWorld::Load( u32 nWorldID ) +bool PWorld::Load( uint32_t nWorldID ) { std::string WorldTemplateName; std::string tFileName; @@ -157,7 +117,27 @@ bool PWorld::Load( u32 nWorldID ) return true; } -const PDefWorldModel* PWorld::GetFurnitureItemModel( u32 nItemID ) +std::string PWorld::GetName() +{ + return ( mWorldDataTemplate ? mWorldDataTemplate->GetName() : EmptyString ); +} + +std::string PWorld::GetBspName() +{ + return ( mWorldDataTemplate ? mWorldDataTemplate->GetBspName() : EmptyString ); +} + +bool PWorld::IsAppartment() +{ + return mIsAppartment; +} + +const PFurnitureItemTemplate *PWorld::GetFurnitureItemTemplate( uint32_t nItemID ) +{ + return ( mWorldDataTemplate ? mWorldDataTemplate->GetFurnitureItem( nItemID ) : NULL ) ; +} + +const PDefWorldModel *PWorld::GetFurnitureItemModel(uint32_t nItemID) { if ( mWorldDataTemplate ) { @@ -165,10 +145,20 @@ const PDefWorldModel* PWorld::GetFurnitureItemModel( u32 nItemID ) if ( tFurniture ) return tFurniture->GetDefWorldModel(); } - return NULL; + return nullptr; +} + +const PDoorTemplate *PWorld::GetDoor(uint32_t nDoorID) +{ + return (mWorldDataTemplate ? mWorldDataTemplate->GetDoor(nDoorID) : nullptr); +} + +bool PWorld::getPositionItemPosition(uint8_t PosID, float *pX, float *pY, float *pZ) +{ + return (mWorldDataTemplate ? mWorldDataTemplate->getPositionItemPosition(PosID, pX, pY, pZ) : false); } -bool PWorld::CharUseChair( int CharLocalID, u32 nItemID ) +bool PWorld::CharUseChair( int CharLocalID, uint32_t nItemID ) { PChairsInUseMap::iterator it = mChairsInUseMap.find( nItemID ); if ( it == mChairsInUseMap.end() ) // chair is free @@ -195,7 +185,7 @@ bool PWorld::CharUseChair( int CharLocalID, u32 nItemID ) } } -void PWorld::CharLeaveChair( int CharLocalID, u32 nItemID ) +void PWorld::CharLeaveChair( int CharLocalID, uint32_t nItemID ) { PChairsInUseMap::iterator it = mChairsInUseMap.find( nItemID ); if (( it != mChairsInUseMap.end() ) && ( it->second == CharLocalID ) ) // chair is in use by this char @@ -206,12 +196,17 @@ void PWorld::CharLeaveChair( int CharLocalID, u32 nItemID ) } } -PClient* PWorld::GetClientByCharLocalId( u32 rawObjectId ) const +PClient* PWorld::GetClientByCharLocalId( uint32_t rawObjectId ) const { // Temp implementation return ClientManager->GetClientByCharLocalId( rawObjectId, mID ); } +PSpawnedVehicles *PWorld::GetSpawnedVehicles() +{ + return &mSpawnedVehicles; +} + bool PWorld::CheckVhcNeedZoning( PVhcCoordinates const* nPos ) const { if ( ( nPos->GetX() <= mBottomZoneOutLimit ) || ( nPos->GetX() >= mTopZoneOutLimit ) || ( nPos->GetY() <= mBottomZoneOutLimit ) || ( nPos->GetY() >= mTopZoneOutLimit ) ) @@ -220,14 +215,14 @@ bool PWorld::CheckVhcNeedZoning( PVhcCoordinates const* nPos ) const return false; } -u32 PWorld::GetVhcZoningDestination( PSpawnedVehicle const* nVhc, PVhcCoordinates* nPos ) const +uint32_t PWorld::GetVhcZoningDestination( PSpawnedVehicle const* nVhc, PVhcCoordinates* nPos ) const { - u32 destWorldId = 0; - s16 vChange = 0; - s16 hChange = 0; + uint32_t destWorldId = 0; + int16_t vChange = 0; + int16_t hChange = 0; PVhcCoordinates const vhcPos = nVhc->GetPosition(); - u16 posX = vhcPos.GetX(); - u16 posY = vhcPos.GetY(); + uint16_t posX = vhcPos.GetX(); + uint16_t posY = vhcPos.GetY(); if ( posX <= mBottomZoneOutLimit ) { @@ -250,9 +245,9 @@ u32 PWorld::GetVhcZoningDestination( PSpawnedVehicle const* nVhc, PVhcCoordinate if ( vChange || hChange ) { //Console->Print( YELLOW, BLACK, "[DEBUG] Limit Reached V:%d H:%d mapId:%d", vChange,hChange,mID ); - u8 currH = 0; - u8 currV = 0; - s16 newH, newV; + uint8_t currH = 0; + uint8_t currV = 0; + int16_t newH, newV; if ( Worlds->GetWorldmapFromWorldId( mID, currH, currV ) ) { @@ -295,14 +290,24 @@ u32 PWorld::GetVhcZoningDestination( PSpawnedVehicle const* nVhc, PVhcCoordinate return destWorldId; } +const PNPCsMap *PWorld::GetNPCMap() const +{ + return (mWorldDataTemplate ? mWorldDataTemplate->GetNPCMap() : nullptr); +} + +const PNPCTemplate *PWorld::GetNPCTemplate(uint32_t nNPCID) const +{ + return (mWorldDataTemplate ? mWorldDataTemplate->GetNPC(nNPCID) : nullptr); +} + /**** PWorlds ****/ -u32 const PWorlds::mNcSubwayWorldId = 1000; -u32 const PWorlds::mAptBaseWorldId = 100000; -u32 const PWorlds::mOutdoorBaseWorldId = 2001; -u32 const PWorlds::mOutdoorWorldIdVIncrement = 20; -u8 const PWorlds::mOutdoorWorldmapHSize = 16; -u8 const PWorlds::mOutdoorWorldmapVSize = 11; -u32 const PWorlds::mOutdoorMaxWorldId = PWorlds::mOutdoorBaseWorldId + PWorlds::mOutdoorWorldIdVIncrement * ( PWorlds::mOutdoorWorldmapVSize - 1 ) + PWorlds::mOutdoorWorldmapHSize - 1; +uint32_t const PWorlds::mNcSubwayWorldId = 1000; +uint32_t const PWorlds::mAptBaseWorldId = 100000; +uint32_t const PWorlds::mOutdoorBaseWorldId = 2001; +uint32_t const PWorlds::mOutdoorWorldIdVIncrement = 20; +uint8_t const PWorlds::mOutdoorWorldmapHSize = 16; +uint8_t const PWorlds::mOutdoorWorldmapVSize = 11; +uint32_t const PWorlds::mOutdoorMaxWorldId = PWorlds::mOutdoorBaseWorldId + PWorlds::mOutdoorWorldIdVIncrement * ( PWorlds::mOutdoorWorldmapVSize - 1 ) + PWorlds::mOutdoorWorldmapHSize - 1; PWorlds::PWorlds() { @@ -617,7 +622,7 @@ bool PWorlds::LoadWorlds() // once Load is done, only WorldDataTemplate registre return true; } -bool PWorlds::IsValidWorld( u32 nWorldID ) const +bool PWorlds::IsValidWorld( uint32_t nWorldID ) const { if ( nWorldID > PWorlds::mAptBaseWorldId ) { @@ -647,7 +652,7 @@ bool PWorlds::IsValidWorld( u32 nWorldID ) const } } -PWorld* PWorlds::LeaseWorld( u32 nWorldID, const bool nPreloadPhase ) +PWorld* PWorlds::LeaseWorld( uint32_t nWorldID, const bool nPreloadPhase ) { PWorldsMap::iterator it; @@ -715,7 +720,7 @@ PWorld* PWorlds::LeaseWorld( u32 nWorldID, const bool nPreloadPhase ) } } -PWorld* PWorlds::GetWorld( u32 nWorldID ) +PWorld* PWorlds::GetWorld( uint32_t nWorldID ) { PWorldsMap* tMap; PWorldsMap::iterator it; @@ -734,7 +739,7 @@ PWorld* PWorlds::GetWorld( u32 nWorldID ) } } -void PWorlds::ReleaseWorld( u32 nWorldID ) // no dynamic unload is performed atm + don't forget spawned vhc ! +void PWorlds::ReleaseWorld( uint32_t nWorldID ) // no dynamic unload is performed atm + don't forget spawned vhc ! { PWorld* tWorld = GetWorld( nWorldID ); if ( tWorld ) @@ -756,7 +761,7 @@ void PWorlds::ReleaseWorld( u32 nWorldID ) // no dynamic unload is performed atm } } -bool PWorlds::IsAppartment( u32 nWorldID ) +bool PWorlds::IsAppartment( uint32_t nWorldID ) { return (( nWorldID > PWorlds::mAptBaseWorldId ) && IsValidWorld( nWorldID ) ); } @@ -767,9 +772,9 @@ void PWorlds::Update() void PWorlds::Shutdown() {} -u32 PWorlds::GetWorldIdFromWorldmap( u8 mapH, u8 mapV ) const +uint32_t PWorlds::GetWorldIdFromWorldmap( uint8_t mapH, uint8_t mapV ) const { - u32 loc = 0; + uint32_t loc = 0; if (( mapH < mOutdoorWorldmapHSize ) && ( mapV < mOutdoorWorldmapVSize ) ) { loc = mOutdoorBaseWorldId + mOutdoorWorldIdVIncrement * mapV + mapH; @@ -779,7 +784,7 @@ u32 PWorlds::GetWorldIdFromWorldmap( u8 mapH, u8 mapV ) const return loc; } -bool PWorlds::GetWorldmapFromWorldId( u32 nWorldId, u8& mapH, u8& mapV ) const +bool PWorlds::GetWorldmapFromWorldId( uint32_t nWorldId, uint8_t& mapH, uint8_t& mapV ) const { if (( nWorldId >= mOutdoorBaseWorldId ) && ( nWorldId <= mOutdoorMaxWorldId ) ) { diff --git a/TinNS/Source/GameServer/Worlds.hxx b/TinNS/Source/GameServer/Worlds.hxx new file mode 100644 index 0000000..4b3090d --- /dev/null +++ b/TinNS/Source/GameServer/Worlds.hxx @@ -0,0 +1,124 @@ +#pragma once + +#include +#include +#include + +class PDefWorldModel; + +typedef std::map PNPCsMap; +typedef std::map PChairsInUseMap; + +class PWorld { + friend class PWorlds; + +public: + static uint16_t const mZoneOutLimitOffset; + static uint16_t const mBottomZoneOutLimit; + static uint16_t const mBottomZoneInLimit; + static uint16_t const mTopZoneOutLimit; + static uint16_t const mTopZoneInLimit; + +private: + uint32_t mID; + bool mIsAppartment; + int32_t mUseCount; + PWorldDataTemplate* mWorldDataTemplate; + PChairsInUseMap mChairsInUseMap; + PSpawnedVehicles mSpawnedVehicles; + + inline void IncreaseUseCount() + { + ++mUseCount; + } + inline int32_t DecreaseUseCount() + { + return ( mUseCount ? --mUseCount : 0 ); + } + inline int32_t GetUseCount() + { + return mUseCount; + } + bool Load( uint32_t nWorldID ); + +public: + PWorld(); + ~PWorld(); + + std::string GetName(); + std::string GetBspName(); + bool IsAppartment(); + const PFurnitureItemTemplate* GetFurnitureItemTemplate( uint32_t nItemID ); + const PDefWorldModel *GetFurnitureItemModel(uint32_t nItemID); + const PDoorTemplate *GetDoor(uint32_t nDoorID); + bool getPositionItemPosition(uint8_t PosID, float *pX, float *pY, float *pZ); + + bool CharUseChair( int32_t CharLocalID, uint32_t nItemID ); + void CharLeaveChair( int32_t CharLocalID, uint32_t nItemID ); + + PClient* GetClientByCharLocalId( uint32_t rawObjectId ) const; // returns Client if object is a PC char, and 0 if not. + + PSpawnedVehicles *GetSpawnedVehicles(); + bool CheckVhcNeedZoning(PVhcCoordinates const *nPos) const; + uint32_t GetVhcZoningDestination(PSpawnedVehicle const* nVhc, PVhcCoordinates* nPos = 0) const; + + // Evil thing... bounced through stuff :| wasnt able to find a better solution for this + const PNPCsMap *GetNPCMap() const; + const PNPCTemplate *GetNPCTemplate(uint32_t nNPCID) const; +}; + + +typedef std::map PWorldsMap; +typedef std::map PWorldDataTemplatesMap; + +class PWorlds +{ + friend class PWorld; + +public: + static uint32_t const mNcSubwayWorldId; + static uint32_t const mAptBaseWorldId; + static uint32_t const mOutdoorBaseWorldId; + static uint32_t const mOutdoorWorldIdVIncrement; + static uint8_t const mOutdoorWorldmapHSize; + static uint8_t const mOutdoorWorldmapVSize; + static uint32_t const mOutdoorMaxWorldId; + +private: + bool mPreloadWorldsTemplates; + bool mPreloadStaticWorlds; + + PWorldsMap mStaticWorldsMap; // lists all valid static worlds, with second=NULL if not loaded + PWorldsMap mOnDemandWorldsMap; // mostly appartments. Could be used for instance dungeons too, but instance dungeons are crap :p + PWorldDataTemplatesMap mWorldDataTemplatesMap; + + bool LeaseWorldDataTemplate( const std::string& nBspName, const std::string& nFileName, const bool nPreloadPhase = false ); + void ReleaseWorldDataTemplate( const std::string& nFileName ); + void UnloadWorldDataTemplate( const std::string& nFileName ); + PWorldDataTemplate* GetWorldDataTemplate( const std::string& nFileName ); + PWorld* LeaseWorld( uint32_t nWorldID, const bool nPreloadPhase ); + +public: + PWorlds(); + ~PWorlds(); + + bool LoadWorlds(); + bool IsValidWorld( uint32_t nWorldID ) const; + inline PWorld* LeaseWorld( uint32_t nWorldID ) + { + return LeaseWorld( nWorldID, false ); + } + PWorld* GetWorld( uint32_t nWorldID ); + void ReleaseWorld( uint32_t nWorldID ); + bool IsAppartment( uint32_t nWorldID ); + inline bool IsPotentialAppartement( uint32_t nWorldID ) + { + return ( nWorldID > PWorlds::mAptBaseWorldId ); + } + + void Update(); + void Shutdown(); + + uint32_t GetWorldIdFromWorldmap( uint8_t mapH, uint8_t mapV ) const; // H & V pos are 0-based + bool GetWorldmapFromWorldId( uint32_t nWorldId, uint8_t& mapH, uint8_t& mapV ) const; +}; diff --git a/TinNS/Source/GameServer/Zoning.cxx b/TinNS/Source/GameServer/Zoning.cxx new file mode 100644 index 0000000..8f35f74 --- /dev/null +++ b/TinNS/Source/GameServer/Zoning.cxx @@ -0,0 +1,36 @@ +#include "GameServer/Includes.hxx" +#include "Common/Includes.hxx" + +// TODO: Put get the fallback world from config +// Check for file existence before sending info to client to avoid client crash and bad location in char info + +void SendZone(PClient *Client, uint32_t loc) +{ + //TODO : FIX case for worldroute and 5 missing id 505 + std::string worldName; + ConnectionTCP *Socket = Client->getTCPConn(); + //PChar *Char = Chars->GetChar(Client->GetCharID()); + + Socket->SetTimeOutValue(0xffff); + + PWorld* CurrentWorld = Worlds->GetWorld(loc); + if (CurrentWorld) + { + worldName = CurrentWorld->GetBspName(); + if (worldName.empty()) + { + worldName = "plaza/plaza_p1"; // Should be a config entry + Console->Print("Client %d: Empty name for world %d. Redirecting to %s", Console->ColorText(RED, BLACK, "Warning"), Client->GetID(), loc, worldName.c_str()); + loc = 1; + } + } + else + { + worldName = "plaza/plaza_p1"; // Should be a config entry + Console->Print("Client %d: Invalid or not loaded world %d. Redirecting to %s", Console->ColorText(YELLOW, BLACK, "Warning"), Client->GetID(), loc, worldName.c_str()); + loc = 1; + } + + PMessage* cMsg = MsgBuilder->BuildSendZoneTCPMsg(loc, &worldName); + Client->SendTCPMessage(cMsg); +} diff --git a/TinNS/Source/GameServer/Zoning.hxx b/TinNS/Source/GameServer/Zoning.hxx new file mode 100644 index 0000000..6f6950c --- /dev/null +++ b/TinNS/Source/GameServer/Zoning.hxx @@ -0,0 +1,8 @@ +#pragma once + +#include + +class PClient; + +//void SendZone(PClient *Client, PGameState *State,int loc); +void SendZone(PClient *Client, uint32_t loc); diff --git a/server/src/info/accounts.cpp b/TinNS/Source/InfoServer/Accounts.cxx similarity index 56% rename from server/src/info/accounts.cpp rename to TinNS/Source/InfoServer/Accounts.cxx index f6789f0..9872c0c 100644 --- a/server/src/info/accounts.cpp +++ b/TinNS/Source/InfoServer/Accounts.cxx @@ -1,48 +1,5 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - accounts.cpp - - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL - MODIFIED: 26 Dec 2005 Namikon - REASON: - Added SQLLoad to PAccounts. First step in adding MySQL support to accounts - MODIFIED: 01 Jan 2006 Namikon - REASON: - Changed FmtTxt() to sprintf(). It does... uhm, the same :D - MODIFIED: 06 Jan 2006 Namikon - REASON: - Removed the old XML loading functions, and changed the SQL ones to work with the Global Neopolis/TinNS Database - - Added SetBannedStatus() to ban/unban an account (use SetBannedStatus(0) to unban a player) - MODIFIED: 03 Oct 2006 Hammag - REASON: - Fixed an issue in PAccount::SetBannedStatus() that was causing the "can't update banned status" error message. - MODIFIED: 27 May 2007 Hammag - REASON: - Full changes for on-demand account access (no more memory-resident account data) - - - MODIFIED: 02 Feb 2008 Hammag - REASON: - Correction of the account creation/update SQL query (thank to drhawk ;) ) -*/ - +#include "InfoServer/Includes.hxx" +#include "Common/Includes.hxx" /* NOTE ABOUT ACCESS LEVELS IN THE MYSQL DATABASE: @@ -58,12 +15,10 @@ a_status: 1 = Online 2 = Banned */ -#include "main.h" -#include "accounts.h" /** Static members **/ -RegEx* PAccount::mUsernameRegexFilter = NULL; -RegEx* PAccount::mPasswordRegexFilter = NULL; +RegEx* PAccount::mUsernameRegexFilter = nullptr; +RegEx* PAccount::mPasswordRegexFilter = nullptr; bool PAccount::SetUsernameRegexFilter(const char* RegexStr) { @@ -72,7 +27,7 @@ bool PAccount::SetUsernameRegexFilter(const char* RegexStr) delete mUsernameRegexFilter; mUsernameRegexFilter = NULL; } - + if(RegexStr) { try { @@ -92,7 +47,7 @@ bool PAccount::SetPasswordRegexFilter(const char* RegexStr) delete mPasswordRegexFilter; mPasswordRegexFilter = NULL; } - + if(RegexStr) { try { @@ -125,16 +80,16 @@ bool PAccount::IsPasswordWellFormed(const char *Password) return true; } -/** Instance members **/ +/** Instance members **/ PAccount::PAccount() { - mID = 0; - mLevel = PAL_BANNED; + mID = 0; + mLevel = PAL_BANNED; mStatus = PAS_OFFLINE; mBannedUntil = 0; } -PAccount::PAccount(const u32 AccountId) +PAccount::PAccount(const uint32_t AccountId) { char query[256]; mID = 0; @@ -158,7 +113,7 @@ bool PAccount::LoadFromQuery(char* query) { MYSQL_ROW row = 0; MYSQL_RES *result = 0; - + bool FinalResult = false; //result = MySQL->InfoResQuery(query); @@ -195,12 +150,17 @@ bool PAccount::LoadFromQuery(char* query) { Console->Print(YELLOW, BLACK, "Failed to load AccountData from SQL; Nothing to load..."); } - + //MySQL->FreeInfoSQLResult(result); MySQL->FreeSQLResult(result); return FinalResult; } +uint32_t PAccount::GetID() const +{ + return mID; +} + bool PAccount::SetName(const std::string &Username) { if(IsUsernameWellFormed(Username.c_str())) @@ -214,6 +174,11 @@ bool PAccount::SetName(const std::string &Username) } } +const std::string &PAccount::GetName() const +{ + return mName; +} + bool PAccount::SetPassword(const std::string &Password) { if(IsPasswordWellFormed(Password.c_str())) @@ -227,19 +192,24 @@ bool PAccount::SetPassword(const std::string &Password) } } -bool PAccount::SetPasswordEncoded(const u8* PasswordData, int PassLen, const u8* Key) +bool PAccount::SetPasswordEncoded(const uint8_t* PasswordData, int PassLen, const uint8_t* Key) { - char Pass[128]; - - if(DecodePassword(PasswordData, PassLen, Key, Pass)) + char Pass[128]; + + if(DecodePassword(PasswordData, PassLen, Key, Pass)) { - return SetPassword((std::string)Pass); - } - else - { - Console->Print(RED, BLACK, "[Error]: user %s : malformed auth data (size=%d)", mName.c_str(), PassLen); - return false; - } + return SetPassword((std::string)Pass); + } + else + { + Console->Print(RED, BLACK, "[Error]: user %s : malformed auth data (size=%d)", mName.c_str(), PassLen); + return false; + } +} + +const std::string &PAccount::GetPassword() const +{ + return mPassword; } bool PAccount::SetLevel(int newLevel) @@ -255,19 +225,24 @@ bool PAccount::SetLevel(int newLevel) } } +int32_t PAccount::GetLevel() const +{ + return mLevel; +} + std::string PAccount::GetLevelString() const { - switch(mLevel) - { - case PAL_BANNED : return "banned"; - case PAL_UNREGPLAYER : return "unregplayer"; - case PAL_REGPLAYER : return "regplayer"; - case PAL_VOLUNTEER : return "volunteer"; - case PAL_GM : return "gm"; - case PAL_ADMIN : return "admin"; - } - - return "custom"; + switch(mLevel) + { + case PAL_BANNED : return "banned"; + case PAL_UNREGPLAYER : return "unregplayer"; + case PAL_REGPLAYER : return "regplayer"; + case PAL_VOLUNTEER : return "volunteer"; + case PAL_GM : return "gm"; + case PAL_ADMIN : return "admin"; + } + + return "custom"; } bool PAccount::SetStatus(PAccountStatus Status) @@ -276,6 +251,11 @@ bool PAccount::SetStatus(PAccountStatus Status) return true; } +PAccountStatus PAccount::GetStatus() const +{ + return mStatus; +} + bool PAccount::SetBannedUntilTime(std::time_t BannedUntil) { if ((BannedUntil == 0) || (BannedUntil > std::time(NULL))) @@ -289,55 +269,60 @@ bool PAccount::SetBannedUntilTime(std::time_t BannedUntil) } } -bool PAccount::DecodePassword(const u8* PasswordData, int PassLen, const u8 *Key, char* ClearPassword) +bool PAccount::IsBanned() const +{ + return (mBannedUntil > std::time(nullptr)); +} + +bool PAccount::DecodePassword(const uint8_t* PasswordData, int PassLen, const uint8_t *Key, char* ClearPassword) { ClearPassword[0] = 0; - + if(PassLen < 128) - { - if(Key[0]>7) // TODO: >7 correct? - { - for(int i=0; i>1] = (char)(((PasswordData[i]&0xf0)>>4) - +((PasswordData[i+1]&0x0f)<<4)-Key[0]); - ClearPassword[PassLen>>1]=0; - } - else - { - for(int i=0; i7) // TODO: >7 correct? + { + for(int i=0; i>1] = (char)(((PasswordData[i]&0xf0)>>4) + +((PasswordData[i+1]&0x0f)<<4)-Key[0]); + ClearPassword[PassLen>>1]=0; + } + else + { + for(int i=0; iPrint(RED, BLACK, "[Error]: user %s : malformed auth data (size=%d)", mName.c_str(), PassLen); - return false; - } + return Authenticate(Pass); + } + else + { + Console->Print(RED, BLACK, "[Error]: user %s : malformed auth data (size=%d)", mName.c_str(), PassLen); + return false; + } } bool PAccount::Authenticate(const char *Password) const { - if(mID == 0) // User doesn't exist and that hasn't been checked ! - { - Console->Print(RED, BLACK, "[Bug]: user %s doesn't exist and was not checked by code !", mName.c_str()); - return false; - } - - return(mPassword == Password); + if(mID == 0) // User doesn't exist and that hasn't been checked ! + { + Console->Print(RED, BLACK, "[Bug]: user %s doesn't exist and was not checked by code !", mName.c_str()); + return false; + } + + return(mPassword == Password); } bool PAccount::Create() @@ -359,7 +344,7 @@ bool PAccount::Save(bool CreateMode) char escPassword[256]; MySQL->EscapeString(mName.c_str(), escUsername, 256); MySQL->EscapeString(mPassword.c_str(), escPassword, 256); - + std::string Query; Query = CreateMode ? "INSERT INTO" : "UPDATE"; Query += " accounts SET "; @@ -367,11 +352,11 @@ bool PAccount::Save(bool CreateMode) Query += Ssprintf(", a_priv = %d, a_status = %d, a_bandate = %d", mLevel, mStatus, mBannedUntil); if(!CreateMode ) { - Query += Ssprintf(" a_lastused = NOW()"); + Query += Ssprintf(" a_lastused = NOW()"); Query += Ssprintf(" WHERE a_id = %d LIMIT 1", mID); } else - Query += Ssprintf(" a_creationdate = NOW()"); + Query += Ssprintf(" a_creationdate = NOW()"); //if(MySQL->InfoQuery(Query.c_str())) if(MySQL->Query(Query.c_str())) @@ -387,7 +372,7 @@ bool PAccount::Save(bool CreateMode) std::string PAccount::GetBannedTime() const { const char* unit[5] = {"seconds", "minutes", "hours", "days", "weeks"}; - + std::time_t timediff = mBannedUntil - std::time(NULL); if(timediff <=0) { diff --git a/TinNS/Source/InfoServer/Accounts.hxx b/TinNS/Source/InfoServer/Accounts.hxx new file mode 100644 index 0000000..96bd185 --- /dev/null +++ b/TinNS/Source/InfoServer/Accounts.hxx @@ -0,0 +1,103 @@ +#pragma once + +#include +#include +#include + +class RegEx; + +/* +0 = unregistered user +1 = Registered user +30 = volunteer +50 = GM +100 = Admin +*/ + +// New way of AccountLevel handling: +// Every level is possible, the following values are only edge values. We need a bit control about that +#define PAL_BANNED -1 +#define PAL_UNREGPLAYER 0 +#define PAL_REGPLAYER 1 +#define PAL_VOLUNTEER 30 +#define PAL_GM 50 +#define PAL_ADMIN 100 + +// Max number of char slots per account +#define MAX_CHARS_PER_ACCOUNT 4 + +/* +0 = Offline +1 = Online +2 = Banned +*/ + +enum PAccountStatus +{ + PAS_OFFLINE = 0, + PAS_ONLINE = 1, + PAS_BANNED = 2 +}; + +class PAccount +{ + private : + // SQL Layout + enum { + a_id, + a_username, + a_password, + a_priv, + a_status, + a_bandate, + a_emailaddress, + a_creationdate, + a_lastused + }; + + // static members + static RegEx *mUsernameRegexFilter; + static RegEx *mPasswordRegexFilter; + + // instance members + uint32_t mID; + std::string mName; + std::string mPassword; + int32_t mLevel; + PAccountStatus mStatus; + std::time_t mBannedUntil; + + bool LoadFromQuery(char *query); + bool DecodePassword(const uint8_t *PasswordData, int32_t PassLen, const uint8_t *Key, char *ClearPassword); + +public: + PAccount(); + PAccount(const uint32_t AccountId); + PAccount(const char *Username); + + static bool SetUsernameRegexFilter(const char *RegexStr); + static bool SetPasswordRegexFilter(const char *RegexStr); + static bool IsUsernameWellFormed(const char *Username); + static bool IsPasswordWellFormed(const char *Password); + + uint32_t GetID() const; + bool SetName(const std::string &Pass); + const std::string &GetName() const; + bool SetPassword(const std::string &Pass); + bool SetPasswordEncoded(const uint8_t *PasswordData, int32_t PassLen, const uint8_t *Key); + const std::string &GetPassword() const; + bool SetLevel(int32_t newLevel); + int32_t GetLevel() const; + std::string GetLevelString() const; + bool SetStatus(PAccountStatus Status); + PAccountStatus GetStatus() const; + bool SetBannedUntilTime(std::time_t BannedUntil); + bool IsBanned() const; + std::string GetBannedTime() const; + bool Authenticate(const uint8_t *PasswordData, int32_t PassLen, const uint8_t *Key); + bool Authenticate(const char *Password) const; + bool Create(); + bool Save(bool CreateMode = false); + + //u32 GetCharIdBySlot(const u32 SlotId); +}; diff --git a/TinNS/Source/InfoServer/CMakeLists.txt b/TinNS/Source/InfoServer/CMakeLists.txt new file mode 100644 index 0000000..da661d4 --- /dev/null +++ b/TinNS/Source/InfoServer/CMakeLists.txt @@ -0,0 +1,2 @@ +ADD_EXECUTABLE (InfoServer Accounts.cxx Client.cxx Includes.cxx InfoServer.cxx Main.cxx Server.cxx Sql.cxx) +TARGET_LINK_LIBRARIES (InfoServer Common ${MYSQL_LIBRARY} ${PCRE_LIBRARY}) diff --git a/TinNS/Source/InfoServer/Client.cxx b/TinNS/Source/InfoServer/Client.cxx new file mode 100644 index 0000000..12ea790 --- /dev/null +++ b/TinNS/Source/InfoServer/Client.cxx @@ -0,0 +1,84 @@ +#include "InfoServer/Includes.hxx" +#include "Common/Includes.hxx" + +PClient::PClient(int32_t Index) +{ + mIndex = Index; + mConnection = PCC_NONE; + mAccountID = 0; +} + +PClient::~PClient() +{ + if(m_TCPConnection) + { + delete m_TCPConnection; + } +} + +int32_t PClient::GetIndex() const +{ + return mIndex; +} + +void PClient::setTCPConnection(ConnectionTCP *conn) +{ + m_TCPConnection = conn; mConnection = PCC_INFO; +} + +ConnectionTCP *PClient::getTCPConn() const +{ + return m_TCPConnection; +} + +int32_t PClient::GetConnection() const +{ + return mConnection; +} + +const char *PClient::GetAddress() const +{ + return m_TCPConnection->getRemoteAddress(); +} + +void PClient::setAccountID(uint32_t nAccountID) +{ + mAccountID = nAccountID; +} + +uint32_t PClient::getAccountID() +{ + return mAccountID; +} + +void PClient::InfoDisconnect() +{ + if(m_TCPConnection) + { + delete m_TCPConnection; + } + m_TCPConnection = 0; + + //mConnection &= ~PCC_INFO; + mConnection = PCC_NONE; + mAccountID = 0; +} + +void PClient::Update() +{ + if(m_TCPConnection) + { + if(m_TCPConnection->timeOut()) + { + Console->Print("InfoSocket: Client %i: timeout", mIndex); + InfoServer->ClientDisconnected(this); + } + else + { + if(!m_TCPConnection->update()) + { + InfoServer->ClientDisconnected(this); + } + } + } +} diff --git a/TinNS/Source/InfoServer/Client.hxx b/TinNS/Source/InfoServer/Client.hxx new file mode 100644 index 0000000..44d284b --- /dev/null +++ b/TinNS/Source/InfoServer/Client.hxx @@ -0,0 +1,33 @@ +#pragma once + +#include + +class ConnectionTCP; + +enum PClientConnection +{ + PCC_NONE = 0, + PCC_INFO = 1 +}; + +class PClient { +private: + ConnectionTCP* m_TCPConnection; + int32_t mIndex; + int32_t mConnection; + uint32_t mAccountID; + +public: + PClient(int32_t Index); + ~PClient(); + + int32_t GetIndex() const; + void setTCPConnection(ConnectionTCP *conn); + ConnectionTCP *getTCPConn() const; + int32_t GetConnection() const; + const char *GetAddress() const; + void setAccountID(uint32_t nAccountID); + uint32_t getAccountID(); + void InfoDisconnect(); + void Update(); +}; diff --git a/server/src/info/configtemplate.h b/TinNS/Source/InfoServer/ConfigTemplate.hxx similarity index 53% rename from server/src/info/configtemplate.h rename to TinNS/Source/InfoServer/ConfigTemplate.hxx index 82a3ff4..92eced8 100644 --- a/server/src/info/configtemplate.h +++ b/TinNS/Source/InfoServer/ConfigTemplate.hxx @@ -1,30 +1,6 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community +#pragma once - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - Configuration template for infoserver - Used to set available/optional/required options when loading config - with a PConfig object. -*/ - -const char* InfoConfigTemplate[][2] = { +static const char *InfoConfigTemplate[][2] = { // {option_name, default_value} if default_value is empty string, it means option is mandatory // List ends with empty string for option_name {"sql_host", "127.0.0.1"}, // should be renanmed to info_sql_host @@ -46,8 +22,7 @@ const char* InfoConfigTemplate[][2] = { {"password_filter", "^[[:graph:]]{3,15}$"}, {"sqlite_databasefile", "infoDB.s3db"}, {"database_type", "sqlite"}, - - + // For futur use: // {"max_chars_per_account", "4"}, diff --git a/server/src/info/globals.cpp b/TinNS/Source/InfoServer/Includes.cxx similarity index 54% rename from server/src/info/globals.cpp rename to TinNS/Source/InfoServer/Includes.cxx index 2c026e1..28ea027 100644 --- a/server/src/info/globals.cpp +++ b/TinNS/Source/InfoServer/Includes.cxx @@ -1,43 +1,6 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - MODIFIED: 27 Aug 2006 Hammag - REASON: - Implemented shared Config class use and config template to load conf. - - Added gameserver configtemplate.h include, - - Added new required parameters to Config->LoadOptions() - - Added AdditionnalConfigChecks() local function, called after config loading - taken from inital infoserver's PConfig::VerifyValues - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" -#include "configtemplate.h" - -#include "include/version.h" - +#include +#include "InfoServer/Includes.hxx" +#include "Common/Includes.hxx" const char ServerVersion[] = TINNS_INFO_VERSION; const char SVNRevision[] = TINNS_SVN_REVISION; @@ -52,69 +15,69 @@ PInfoServer *InfoServer = 0; bool Init() { - Console = new PConsole("log/infoserver.log"); // Make that from config file !!! - Console->Print("Starting TinNS Infoserver"); - Console->Print(WHITE, BLUE, "/-------------------------------------------------------------------\\"); - Console->Print(WHITE, BLUE, "| TinNS (TinNS is not a Neocron Server) |"); + Console = new PConsole("log/infoserver.log"); // Make that from config file !!! + Console->Print("Starting TinNS Infoserver"); + Console->Print(WHITE, BLUE, "/-------------------------------------------------------------------\\"); + Console->Print(WHITE, BLUE, "| TinNS (TinNS is not a Neocron Server) |"); Console->Print(WHITE, BLUE, "| Copyright (C) 2005 Linux Addicted Community |"); - Console->Print(WHITE, BLUE, "| maintainer Akiko |"); - Console->Print(WHITE, BLUE, "| ========================================== |"); - Console->Print(WHITE, BLUE, "| Head coders: The packet analyzing team: |"); - Console->Print(WHITE, BLUE, "| - Akiko - MaxxJag |"); - Console->Print(WHITE, BLUE, "| - bakkdoor - Sting |"); - Console->Print(WHITE, BLUE, "| - Namikon - Balm |"); - Console->Print(WHITE, BLUE, "| - Hammag |"); - Console->Print(WHITE, BLUE, "|-------------------------------------------------------------------|"); - Console->Print(WHITE, BLUE, "| This project would'nt be at its current stage without the help |"); + Console->Print(WHITE, BLUE, "| maintainer Akiko |"); + Console->Print(WHITE, BLUE, "| ========================================== |"); + Console->Print(WHITE, BLUE, "| Head coders: The packet analyzing team: |"); + Console->Print(WHITE, BLUE, "| - Akiko - MaxxJag |"); + Console->Print(WHITE, BLUE, "| - bakkdoor - Sting |"); + Console->Print(WHITE, BLUE, "| - Namikon - Balm |"); + Console->Print(WHITE, BLUE, "| - Hammag |"); + Console->Print(WHITE, BLUE, "|-------------------------------------------------------------------|"); + Console->Print(WHITE, BLUE, "| This project would'nt be at its current stage without the help |"); Console->Print(WHITE, BLUE, "| from the NeoPolis team, special thanks to you guys! |"); - Console->Print(WHITE, BLUE, "|-------------------------------------------------------------------|"); - Console->Print(WHITE, BLUE, "| This project is under GPL, see any source file for more details |"); - Console->Print(WHITE, BLUE, "\\-------------------------------------------------------------------/"); - - //char svnrev[10]; - //GetSVNRev(svnrev); - Console->LPrint("You are running TinNS Infoserver version"); - Console->LPrint(GREEN, BLACK, " %s", ServerVersion); - Console->LPrint(WHITE, BLACK, " - SVN Rev"); - Console->LPrint(GREEN, BLACK, " %s", SVNRevision); - Console->LClose(); - - Config = new PConfig(); - if(!Config->LoadOptions(InfoConfigTemplate, "./conf/infoserver.conf")) - return false; //Shutdown(); + Console->Print(WHITE, BLUE, "|-------------------------------------------------------------------|"); + Console->Print(WHITE, BLUE, "| This project is under GPL, see any source file for more details |"); + Console->Print(WHITE, BLUE, "\\-------------------------------------------------------------------/"); + + //char svnrev[10]; + //GetSVNRev(svnrev); + Console->LPrint("You are running TinNS Infoserver version"); + Console->LPrint(GREEN, BLACK, " %s", ServerVersion); + Console->LPrint(WHITE, BLACK, " - SVN Rev"); + Console->LPrint(GREEN, BLACK, " %s", SVNRevision); + Console->LClose(); + + Config = new PConfig(); + if(!Config->LoadOptions(InfoConfigTemplate, "./conf/infoserver.conf")) + return false; //Shutdown(); if(!AdditionnalConfigChecks()) return false; //Shutdown(); - ServerSock = new ServerSocket(); - Server = new PServer(); - - MySQL = new PMySQL(); + ServerSock = new ServerSocket(); + Server = new PServer(); + + MySQL = new PMySQL(); if(MySQL->Connect() == false) - return false; //Shutdown(); + return false; //Shutdown(); - InfoServer = new PInfoServer(); - //Accounts = new PAccounts(); // To be removed + InfoServer = new PInfoServer(); + //Accounts = new PAccounts(); // To be removed - return true; + return true; } void Shutdown() { if(Server) Server->Shutdown(); - if(InfoServer) delete InfoServer; - if(MySQL) delete MySQL; - if(Config) delete Config; - if(Console) delete Console; - if(ServerSock) delete ServerSock; + if(InfoServer) delete InfoServer; + if(MySQL) delete MySQL; + if(Config) delete Config; + if(Console) delete Console; + if(ServerSock) delete ServerSock; exit(0); } bool AdditionnalConfigChecks() { //NOTA: empty config values are never accepted by PConfig objects - + int numErr, numWarn; - + //std::string sqlhost = Config->GetOption("sql_host"); std::string sqlusername = Config->GetOption("sql_username"); //std::string sqlpassword = Config->GetOption("sql_password"); @@ -208,17 +171,15 @@ bool AdditionnalConfigChecks() Console->Print("%s Config: minlevel has to be between 0 and 255", Console->ColorText(RED, BLACK, "[Error]")); numErr++; } - + if(maxclients < 1 ) { Console->Print("%s Config: maxclients has to be higher or equal to 1", Console->ColorText(RED, BLACK, "[Error]")); numErr++; } - + if(numErr == 0 /*&& numWarn == 0*/) return true; else return false; } - - diff --git a/TinNS/Source/InfoServer/Includes.hxx b/TinNS/Source/InfoServer/Includes.hxx new file mode 100644 index 0000000..eff92ed --- /dev/null +++ b/TinNS/Source/InfoServer/Includes.hxx @@ -0,0 +1,24 @@ +#pragma once + +#include "InfoServer/Accounts.hxx" +#include "InfoServer/ConfigTemplate.hxx" +#include "InfoServer/Client.hxx" +#include "InfoServer/InfoServer.hxx" +#include "InfoServer/Server.hxx" +#include "InfoServer/Sql.hxx" + +extern class ServerSocket* ServerSock; +extern class PConsole *Console; +extern class PServer *Server; +extern class PConfig *Config; +extern class PInfoServer *InfoServer; + +extern class PMySQL* MySQL; +//extern class PAccounts* Accounts; // To be removed + +extern const char ServerVersion[]; +extern const char SVNRevision[]; + +bool Init(); +void Shutdown(); +bool AdditionnalConfigChecks(); diff --git a/TinNS/Source/InfoServer/InfoServer.cxx b/TinNS/Source/InfoServer/InfoServer.cxx new file mode 100644 index 0000000..3d92783 --- /dev/null +++ b/TinNS/Source/InfoServer/InfoServer.cxx @@ -0,0 +1,576 @@ +#include +#include "InfoServer/Includes.hxx" +#include "Common/Includes.hxx" + +struct PInfoState +{ + enum State + { + IS_UNKNOWN, + IS_CONNECTED, + IS_HANDSHAKE0, + IS_AUTHENTICATE, + IS_SERVERLIST + } mState; + + bool mWaitSend; // wait-for-completition flag + PInfoState() + { + mState = IS_UNKNOWN; + mWaitSend = false; + }; +}; + +PInfoServer::PInfoServer() +{ + //mNumClients = 1; + mLivecheckInterval = Config->GetOptionInt("gameserver_livecheck"); +} + +PInfoServer::~PInfoServer() +{ + Console->Print("Closing Infoserver..."); + + ServerSock->closeServer(); + + for(InfoStateMap::iterator i=ClientStates.begin(); i!=ClientStates.end(); i++) + delete i->second; +} + +void PInfoServer::Start() +{ + uint16_t Port = Config->GetOptionInt("infoserver_port"); + Console->LPrint("Starting Infoserver on port %i...", Port); + + if(ServerSock->open(Port)) + { + Console->LPrint(GREEN, BLACK, "Success"); + Console->LClose(); + } + else + { + Console->LPrint(RED, BLACK, "Failed"); + Console->LClose(); + } + ServerSock->settimeout(0, 10000); + GSLiveCheck(); +} + +void PInfoServer::Update() +{ + if(ServerSock->newConnection()) + { + int32_t clid = Server->NewClient(); + if(clid!=-1) + { + Console->Print(GREEN, BLACK, "Infoserver: client [%i] connected", clid); + PClient *Client = Server->GetClient(clid); + + ConnectionTCP* tcpConn = ServerSock->getTCPConnection(); + Client->setTCPConnection(tcpConn); + + Console->Print("Client address: %s", Client->GetAddress()); + //++mNumClients; + + PInfoState *state = new PInfoState(); + ClientStates.insert(std::make_pair(Client, state)); + state->mState = PInfoState::IS_CONNECTED; + } else + { + Console->Print("Infoserver: Client connection refused (server full?)"); + } + } + + for(InfoStateMap::iterator i=ClientStates.begin(); i!=ClientStates.end();) + { + PClient *Client = i->first; + PInfoState *State = i->second; + // node gets erased in FinalizeClient, increment iterator now + ++i; + if(!ProcessClient(Client, State)) + FinalizeClient(Client, State); + } +} + +void PInfoServer::GSLiveCheck() +{ + MYSQL_ROW row; + MYSQL_RES *result; + char query[256]; + snprintf (query, 256, "SELECT *, (NOW()< (`s_lastupdate` + INTERVAL %d SECOND)) FROM `server_list`", mLivecheckInterval); + + result = MySQL->ResQuery(query); + if (result == nullptr) + { + Console->Print("Livecheck: %s unable to read server list!", Console->ColorText(RED, BLACK, "[Warning]")); + MySQL->ShowSQLError(); + return; + } + if(mysql_num_rows(result) == 0) + { + Console->Print("Livecheck: %s no gameserver found!", Console->ColorText(RED, BLACK, "[Warning]")); + MySQL->FreeSQLResult(result); + return; + } + + ServerMap::iterator it; + while((row = mysql_fetch_row(result))) + { + it = Serverlist.find(atoi(row[s_id])); + if(it != Serverlist.end()) + { + strncpy(it->second.mName, row[s_name], MAX_SERVER_NAME_LENGTH); + it->second.mLanIp = IPStringToDWord(row[s_lanaddr]); + it->second.mWanIp = IPStringToDWord(row[s_wanaddr]); + it->second.mPort = atoi(row[s_port]); + it->second.mPlayers = atoi(row[s_players]); + /* Prepared for future addon Servers by Accesslevel */ + // it->second.mMinLv = atoi(row[s_minlv]); + /* ------------------------------------------------ */ + + // ToDo: If statement correct? Maybe GSLiveCheck() has + // to be called every mLinvecheckInterval seconds.... We'll + // see when Gameserver has been rewritten + + if(row[s_timecheck] && (atoi(row[s_timecheck]) == 1)) + { + it->second.mLasttimestamp = atol(row[s_lastupdate]); + it->second.mOnline = true; + } + else + { + it->second.mOnline = false; + } + + it->second.mUpdated = true; + } + else + { + GameServers tmpServer; + + strncpy(tmpServer.mName, row[s_name], MAX_SERVER_NAME_LENGTH); + tmpServer.mLanIp = IPStringToDWord(row[s_lanaddr]); + tmpServer.mWanIp = IPStringToDWord(row[s_wanaddr]); + tmpServer.mLasttimestamp = atol(row[s_lastupdate]); + tmpServer.mPlayers = atoi(row[s_players]); + tmpServer.mPort = atoi(row[s_port]); + tmpServer.mOnline = true; + tmpServer.mUpdated = true; + Console->Print("Added GameServer %s", tmpServer.mName); + /* Prepared for future addon Servers by Accesslevel */ + // tmpServer.mMinLv = atoi(row[s_minlv]); + /* ------------------------------------------------ */ + + Serverlist.insert(std::make_pair(atoi(row[s_id]), tmpServer)); + } + } + MySQL->FreeSQLResult(result); + + for(ServerMap::iterator it = Serverlist.begin(); it != Serverlist.end(); it++) + { + if(it->second.mUpdated == false) + Serverlist.erase(it); + else + it->second.mUpdated = false; + } + +} + +void PInfoServer::ClientDisconnected(PClient *Client) +{ + InfoStateMap::iterator node = ClientStates.find(Client); + if(node == ClientStates.end()) + return; + + PInfoState *State = node->second; + FinalizeClient(Client, State); +} + +bool PInfoServer::HandleHandshake(PInfoState *State, const uint8_t *Packet, int32_t PacketSize) +{ + //static const uint8_t HANDSHAKE1A[6]={0xfe, 0x03, 0x00, 0x80, 0x03, 0x68}; + + switch(State->mState) + { + case PInfoState::IS_HANDSHAKE0 : + { + if(PacketSize==6 && *(uint16_t*)&Packet[3]==0x0080 && Packet[5]==0x78) + { + //FIXME: this packet seems to be unnecessary, although it appears in traffic dumps + // (causes clientside "Wrong protocol" errors) + //Socket->Write(HANDSHAKE1A, 6); + State->mState = PInfoState::IS_AUTHENTICATE; + } + else + { + Console->Print(RED, BLACK, "Infoserver protocol error (IS_HANDSHAKE0): invalid packet [%04x]", *(uint16_t*)&Packet[3]); + return false; + } + break; + } + default: + break; + } + + return true; +} + +bool PInfoServer::HandleAuthenticate(PClient *Client, PInfoState *State, const uint8_t *Packet, int32_t PacketSize) +{ + int32_t returnval = 0; + // ReturnValue values: + // 0: No error + // -1: Wrong/Unknown username + // -2: Wrong Password + // -3: Malformed Auth Data. Please relog + // -4: Database error, contact admin + // -5: No such account, Account created. Please relog + // -6: Could not create autoaccount, PW too short + // -7: Could not create autoaccount, Name too short + // -8: Could not create autoaccount, PW and Name too short + // -9: Duplicate entry for Username! Contact Admin + // -10: User is banned + // -11: Insufficient access rights + // -12: Account is not yet activated (accesslevel = 0) + // -99: General fault. Contact admin + ConnectionTCP *Socket = Client->getTCPConn(); + PAccount* currentAccount = NULL; + + if (PacketSize > 20 && *(uint16_t *)&Packet[3] == 0x8084) + { + const uint8_t *Key = &Packet[5]; // password key + uint16_t ULen = *(uint16_t *)&Packet[16]; // username length + uint16_t PLen = *(uint16_t *)&Packet[18]; // password length + char *UserName = (char *)&Packet[20]; // account name + const uint8_t *PW = &Packet[20 + ULen]; // encoded password + + if (UserName[ULen-1]) // Check that string is well terminated + { + Console->Print("Infoserver: Client [%d]: Username was not NULL-terminated !", Client->GetIndex()); + returnval = -1; + } + else + { + currentAccount = new PAccount(UserName); + if(!currentAccount->GetID()) + { + if(Config->GetOptionInt("auto_accounts")) // Autoaccount + { + delete currentAccount; + currentAccount = new PAccount(); + + if(!currentAccount->SetName(UserName)) // !!! len + { + returnval = -7; + } + if(!currentAccount->SetPasswordEncoded(PW, PLen, Key)) + { + returnval = returnval ? -8 : -6; + } + + if(!returnval) + { + if(currentAccount->Create()) + { + returnval = -5; + } + else + { + returnval = -4; + } + } + } + else + { + returnval = -1; + } + } + else + { + if(currentAccount->Authenticate(PW, PLen, Key)) + { // Username & Password correct + if(currentAccount->IsBanned()) + { + returnval = -10; + } + else if(currentAccount->GetLevel() < Config->GetOptionInt("minlevel")) // insufficient access rights + { + returnval = -11; + } + else if(Config->GetOptionInt("require_validation") == 1 && currentAccount->GetLevel() == PAL_UNREGPLAYER) + { + returnval = -12; + } + else + { + Client->setAccountID(currentAccount->GetID()); + returnval = 0; + } + + } + else + { + returnval = -2; + } + } + } + + bool Failed = false; + if(returnval == 0) + { + uint8_t AUTHOK[28]={0xfe, 0x19, 0x00, 0x83, 0x81, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00 }; + *(uint32_t *)&AUTHOK[5] = currentAccount->GetID(); + Socket->write(AUTHOK, 28); + State->mState = PInfoState::IS_SERVERLIST; + } + else + { + Console->Print("Infoserver: User '%s': authentication failed. Errorcode %d", UserName, returnval); + Failed = true; // auth failed + } + if(Failed == true) + { + std::string errorReason; + switch(returnval) + { + // It seems that the client cuts the line off after 40 chars... +// |1 |10 |20 |30 |40 |50 |60 |70 |80 + case -99: + { + //errorReason = "General fault in processing your login request"; + errorReason = "General fault while login request"; + break; + } + case -12: + { + //errorReason = "Account not activated. Please check your EMails"; + errorReason = "Error: Your account is not activated"; + break; + } + case -11: + { + //errorReason = "Login rejected. You have to be " + GetAccessString(Config->GetOptionInt("minlevel")) + " or higher"; + errorReason = "Level " + GetAccessString(Config->GetOptionInt("minlevel")) + " or higher required"; + break; + } + case -10: + { + errorReason = "You are banned for " + currentAccount->GetBannedTime(); + break; + } + case -9: + { + //errorReason = "Duplicate entry for this login. Contact Admin"; + errorReason = "Duplicate entry found. Contact Admin"; + break; + } + case -8: + { + //errorReason = "Autoaccount failed, name and password too short"; + errorReason = "AutoAcc failed, name and pwd too short"; + break; + } + case -7: + { + errorReason = "Autoaccount failed, name is too short"; + break; + } + case -6: + { + //errorReason = "Autoaccount failed, password is too short"; + errorReason = "Autoaccount failed, pwd is too short"; + break; + } + case -5: + { + errorReason = "New Account created, please login again"; + break; + } + case -4: + { + errorReason = "Database error, contact Administrator"; + break; + } + case -3: + { + errorReason = "Malformed AuthData. Please login again"; + break; + } + case -2: + { + errorReason = "Wrong password"; + break; + } + case -1: + { + errorReason = "Unknown username"; + break; + } + } + uint8_t AUTHFAILED_HEADER[] = {0xfe, 0x0c, 0x00, 0x83, 0x86, 0x05, 0x00, 0x06, 0x00}; + uint8_t AUTHFAILED_FOOTER[] = {0x00, 0x40}; + *(uint16_t *)&AUTHFAILED_HEADER[1] = errorReason.size() + 8; + *(uint16_t *)&AUTHFAILED_HEADER[7] = errorReason.size() + 1; + //*(uint8_t*)&AUTHFAILED_FOOTER[1] = {0x40}; + + Socket->write(AUTHFAILED_HEADER, sizeof(AUTHFAILED_HEADER)); + Socket->write(errorReason.c_str(), errorReason.size()); + Socket->write(AUTHFAILED_FOOTER, sizeof(AUTHFAILED_FOOTER)); + FinalizeClientDelayed(Client, State); + State->mState=PInfoState::IS_UNKNOWN; + } + } + else + { + Console->Print(RED, BLACK, "Infoserver protocol error (IS_AUTHENTICATE): invalid packet [%04x]", + *(uint16_t *)&Packet[3]); + return false; + } + + return true; +} + +bool PInfoServer::HandleServerList(PClient *Client, const uint8_t *Packet, int32_t PacketSize) +{ + uint8_t SERVERLIST_HEAD[] = {0xfe, 0x00, 0x00, 0x83, 0x83, 0x01, 0x00, 0x0d, 0x00}; + uint8_t SERVERLIST[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + uint8_t SERVERLIST_FOOTER[] = {0x00}; + + ConnectionTCP *Socket = Client->getTCPConn(); + + uint32_t tID = *(uint32_t *)&Packet[5]; + PAccount* currentAccount = new PAccount(Client->getAccountID()); + uint32_t aID = currentAccount->GetID(); + + if(!aID || (aID != tID)) + { + Console->Print("%s invalid userID %d (auth with id %d)", Console->ColorText(YELLOW, BLACK, "Warning:"), tID, aID); + delete currentAccount; + return false; + } + + if(currentAccount->GetLevel() < Config->GetOptionInt("minlevel")) + { + Console->Print("%s someone tried to bypass the login process! UserID %d", Console->ColorText(RED, BLACK, "Warning:"), aID); + delete currentAccount; + return false; + } + + if(PacketSize == 31 && *(uint16_t *)&Packet[3]==0x8284) + { + GSLiveCheck(); // Perform livecheck to have up-to-date data + + int32_t len = 0; + int32_t num = 0; + for(ServerMap::iterator it = Serverlist.begin(); it != Serverlist.end(); it++) + { + num++; + len += 14 + strlen(it->second.mName); + } + + *(uint16_t *)&SERVERLIST_HEAD[1] = len; + *(uint8_t *)&SERVERLIST_HEAD[5] = num; + Socket->write(SERVERLIST_HEAD, sizeof(SERVERLIST_HEAD)); + + for(ServerMap::iterator it = Serverlist.begin(); it != Serverlist.end(); it++) + { + /* Prepared for future addon Servers by Accesslevel */ +// if(accesslevel >= it->second.mMinLv) +// { + /* ------------------------------------------------ */ + // Todo: Set correct lan/wan IP here! + *(uint32_t *)&SERVERLIST[0] = it->second.mLanIp; + *(uint16_t *)&SERVERLIST[4] = it->second.mPort; + *(uint8_t *)&SERVERLIST[8] = strlen(it->second.mName) + 1; + *(uint16_t *)&SERVERLIST[9] = it->second.mPlayers; + if(it->second.mOnline == true) + { + Console->Print("Sending server name: %s ip: %s player: %d port: %d online: yes", it->second.mName, + IPlongToString(it->second.mLanIp), it->second.mPlayers, it->second.mPort); + *(uint16_t *)&SERVERLIST[11] = 1; + } + else if(it->second.mOnline == false) + { + Console->Print("Sending server name: %s ip: %s player: %d port: %d online: no", it->second.mName, + IPlongToString(it->second.mLanIp), it->second.mPlayers, it->second.mPort); + *(uint16_t *)&SERVERLIST[11] = 0; + } + Socket->write(SERVERLIST, sizeof(SERVERLIST)); + Socket->write(it->second.mName, strlen(it->second.mName)); + Socket->write(SERVERLIST_FOOTER, sizeof(SERVERLIST_FOOTER)); + /* Prepared for future addon Servers by Accesslevel */ +// } + /* ------------------------------------------------ */ + } + } + else + { + Console->Print(RED, BLACK, "Infoserver protocol error (IS_SERVERLIST): invalid packet [%04x]", + *(uint16_t *)&Packet[3]); + delete currentAccount; + return false; + } + delete currentAccount; + return true; +} + +bool PInfoServer::ProcessClient(PClient *Client, PInfoState *State) +{ + static const uint8_t HANDSHAKE0A[6]={0xfe, 0x03, 0x00, 0x80, 0x01, 0x66}; + + if(!State) + { + InfoStateMap::iterator node = ClientStates.find(Client); + if(node == ClientStates.end()) + return false; + + State = node->second; + } + + ConnectionTCP *Socket = Client->getTCPConn(); + + if(State->mWaitSend && Socket->getSendBufferSize()==0) + return false; + + if(State->mState==PInfoState::IS_CONNECTED) + { + Socket->write(HANDSHAKE0A, 6); + State->mState = PInfoState::IS_HANDSHAKE0; + } + + int32_t PacketSize=0; + const uint8_t *Packet = Socket->read(&PacketSize); + if(PacketSize > 0) + { + switch(State->mState) + { + case PInfoState::IS_HANDSHAKE0: + return HandleHandshake(State, Packet, PacketSize); + + case PInfoState::IS_AUTHENTICATE: + return HandleAuthenticate(Client, State, Packet, PacketSize); + + case PInfoState::IS_SERVERLIST: + return HandleServerList(Client, Packet, PacketSize); + default: + break; + } + } + return true; +} + +void PInfoServer::FinalizeClient(PClient *Client, PInfoState *State) +{ + Console->Print(RED, BLACK, "Infoserver: client %s disconnected", Client->GetAddress()); + Client->InfoDisconnect(); + ClientStates.erase(Client); + delete State; +} + +void PInfoServer::FinalizeClientDelayed(PClient *Client, PInfoState *State) +{ + Console->Print("Infoserver: client %i is about to be disconnected", Client->GetIndex()); + State->mWaitSend = true; +} diff --git a/TinNS/Source/InfoServer/InfoServer.hxx b/TinNS/Source/InfoServer/InfoServer.hxx new file mode 100644 index 0000000..350391b --- /dev/null +++ b/TinNS/Source/InfoServer/InfoServer.hxx @@ -0,0 +1,64 @@ +#pragma once + +#include +#include + +class PClient; +struct PInfoState; + +#define MAX_SERVER_NAME_LENGTH 45 +struct GameServers { + char mName[MAX_SERVER_NAME_LENGTH]; + uint32_t mLanIp; + uint32_t mWanIp; + int16_t mPort; + int32_t mPlayers; + bool mOnline; + bool mUpdated; + time_t mLasttimestamp; +/* Prepared for future addon Servers by Accesslevel */ +// int mMinLv; +/* ------------------------------------------------ */ +}; + +class PInfoServer { +private: + // SQL layout + enum { + s_id, + s_name, + s_wanaddr, + s_port, + s_players, + s_lastupdate, + s_lanaddr, + s_timecheck // computed field, not in table ! + }; + //int mNumClients; + typedef std::map InfoStateMap; + InfoStateMap ClientStates; + + typedef std::map ServerMap; + ServerMap Serverlist; + + //time_t mLastLivecheck; + int mLivecheckInterval; + void GSLiveCheck(); + +protected: + bool ProcessClient(PClient *Client, PInfoState *State = nullptr); + void FinalizeClient(PClient *Client, PInfoState *State); + void FinalizeClientDelayed(PClient *Client, PInfoState *State); + + bool HandleHandshake(PInfoState *State, const uint8_t *Packet, int32_t PacketSize); + bool HandleAuthenticate(PClient *Client, PInfoState *State, const uint8_t *Packet, int32_t PacketSize); + bool HandleServerList(PClient *Client, const uint8_t *Packet, int32_t PacketSize); + +public: + PInfoServer(); + ~PInfoServer(); + + void Start(); + void Update(); + void ClientDisconnected(PClient *Client); +}; diff --git a/TinNS/Source/InfoServer/Main.cxx b/TinNS/Source/InfoServer/Main.cxx new file mode 100644 index 0000000..0c87d5e --- /dev/null +++ b/TinNS/Source/InfoServer/Main.cxx @@ -0,0 +1,35 @@ +#include +#include "InfoServer/Includes.hxx" +#include "Common/Includes.hxx" + +void signal_handler(int signal) +{ + if (signal == SIGINT) + Shutdown(); +} + +int main() +{ + signal(SIGINT, signal_handler); + + if (!Init()) + { + if(Console) + Console->Print("%s Aborting startup.", Console->ColorText(RED, BLACK, "[Fatal]")); + Shutdown(); // exits with 0 ... + } + + InfoServer->Start(); + Console->Print("Infoserver is now %s. Waiting for clients...", Console->ColorText(GREEN, BLACK, "Online")); + + while (true) + { + ServerSock->update(); + Server->Update(); + InfoServer->Update(); + MySQL->Update(); // MySQL keepalive + Console->Update(); + } + + return 0; +} diff --git a/TinNS/Source/InfoServer/Server.cxx b/TinNS/Source/InfoServer/Server.cxx new file mode 100644 index 0000000..370063f --- /dev/null +++ b/TinNS/Source/InfoServer/Server.cxx @@ -0,0 +1,80 @@ +#include "InfoServer/Includes.hxx" +#include "Common/Includes.hxx" + +PServer::PServer() +{ + mMaxClients = Config->GetOptionInt("maxclients"); + + mClients.reserve(mMaxClients); + mNumClients = 0; + for (int32_t i=0; i= mMaxClients) + return 0; + + return mClients[Client]; +} + +void PServer::Update() +{ + for (int32_t i=0; iUpdate(); + if(mClients[i]->GetConnection()==PCC_NONE && mClients[i]->getTCPConn() == 0) + { + Console->Print("Removing client ..."); + delete mClients[i]; + mClients[i]=0; + --mNumClients; + } + } + } +} + +void PServer::Shutdown() +{ + Console->Print("======================"); + Console->Print("Shutting down Infoserver..."); + for (int32_t i=0; i +#include + +class PClient; + +class PServer { +private: + int32_t mMaxClients; + int32_t mNumClients; + std::vector mClients; + +public: + PServer(); + ~PServer(); + + int32_t GetNumClients() const; + int32_t NewClient(); + PClient *GetClient(int32_t Client) const; + void Update(); + void Shutdown(); +}; diff --git a/server/src/info/sql.cpp b/TinNS/Source/InfoServer/Sql.cxx similarity index 59% rename from server/src/info/sql.cpp rename to TinNS/Source/InfoServer/Sql.cxx index 0513752..6dbdf96 100644 --- a/server/src/info/sql.cpp +++ b/TinNS/Source/InfoServer/Sql.cxx @@ -1,25 +1,6 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -#include "main.h" +#include +#include "InfoServer/Includes.hxx" +#include "Common/Includes.hxx" PMySQL::PMySQL() { @@ -29,7 +10,7 @@ PMySQL::PMySQL() strncpy(password, Config->GetOption("sql_password").c_str(), 100); strncpy(database, Config->GetOption("global_sql_database").c_str(), 100); - mKeepaliveDelay = (std::time_t) (Config->GetOptionInt("mysql_wait_timeout") * 0.9) ; // we take 90% of the wait_timeout to trigger keepalive + mKeepaliveDelay = (time_t) (Config->GetOptionInt("mysql_wait_timeout") * 0.9) ; // we take 90% of the wait_timeout to trigger keepalive if (mKeepaliveDelay == 0) { Console->Print("%s MySQL keepalive disabled by config", Console->ColorText(GREEN, BLACK, "[Info]")); @@ -49,9 +30,9 @@ PMySQL::~PMySQL() } void PMySQL::Update() -{ +{ // MySQL keepalive - std::time_t t = std::time(NULL); + time_t t = std::time(NULL); if ((mKeepaliveDelay > 0) && ((t - mLastKeepaliveSent) > mKeepaliveDelay)) { MYSQL_RES *result; @@ -66,35 +47,40 @@ void PMySQL::Update() return; } else - FreeSQLResult(result); - + FreeSQLResult(result); + mLastKeepaliveSent = std::time(NULL); //Console->Print("%s MySQL keepalive sent", Console->ColorText(GREEN, BLACK, "[Debug]")); } } +MYSQL *PMySQL::GetHandle() +{ + return dbHandle; +} + bool PMySQL::Connect() { Console->LPrint("Establishing link to MySQL Database..."); - dbHandle = mysql_init(NULL); + dbHandle = mysql_init(NULL); - if(dbHandle) - { - //Console->Print("MySQL-Handle successfully initialized."); - } - else - { - Console->LPrint(RED, BLACK, "[ERROR]"); - Console->LClose(); - Console->Print(" MySQL-Handle couldn't be created!"); - exit(0); - } + if(dbHandle) + { + //Console->Print("MySQL-Handle successfully initialized."); + } + else + { + Console->LPrint(RED, BLACK, "[ERROR]"); + Console->LClose(); + Console->Print(" MySQL-Handle couldn't be created!"); + exit(0); + } if(!mysql_real_connect(dbHandle, host, userName, password, database, port, NULL, 0)) { - Console->LPrint(RED, BLACK, "[ERROR]"); - Console->LClose(); + Console->LPrint(RED, BLACK, "[ERROR]"); + Console->LClose(); Console->Print("Unable to connect to MySQL Database. MySQL returned: %s", mysql_error(dbHandle)); return false; } @@ -108,7 +94,7 @@ bool PMySQL::Connect() MYSQL_RES *PMySQL::ResQuery(const char *query) { - int sql_result = 0; + int32_t sql_result = 0; MYSQL_RES *result; sql_result = mysql_real_query(dbHandle, query, strlen(query)); @@ -125,9 +111,9 @@ MYSQL_RES *PMySQL::ResQuery(const char *query) return result; } -int PMySQL::Query(const char *query) +int32_t PMySQL::Query(const char *query) { - int sql_result = 0; + int32_t sql_result = 0; sql_result = mysql_real_query(dbHandle, query, strlen(query)); return sql_result; @@ -143,14 +129,19 @@ void PMySQL::FreeSQLResult(MYSQL_RES *res) mysql_free_result(res); } -u32 PMySQL::EscapeString(const char* nText, char* dText, u32 dMaxLength) +uint32_t PMySQL::GetLastInsertId() { - u32 nLength = strlen(nText); - u32 tMax = (dMaxLength - 1)/2; + return mysql_insert_id(dbHandle); +} + +uint32_t PMySQL::EscapeString(const char *nText, char *dText, uint32_t dMaxLength) +{ + uint32_t nLength = strlen(nText); + uint32_t tMax = (dMaxLength - 1)/2; if(nLength > tMax) { nLength = tMax; } - + return mysql_real_escape_string(dbHandle, dText, nText, nLength); } diff --git a/TinNS/Source/InfoServer/Sql.hxx b/TinNS/Source/InfoServer/Sql.hxx new file mode 100644 index 0000000..c58dc27 --- /dev/null +++ b/TinNS/Source/InfoServer/Sql.hxx @@ -0,0 +1,35 @@ +#pragma once + +#include +#ifdef MYSQL_INC_DIR +#include +#else +#include +#endif + +class PMySQL { +private: + int32_t port; + char host[100]; + char userName[100]; + char password[100]; + char database[100]; + MYSQL *dbHandle; + time_t mKeepaliveDelay; + time_t mLastKeepaliveSent; + +public: + PMySQL(); + ~PMySQL(); + + void Update(); + MYSQL *GetHandle(); + + bool Connect(); + int32_t Query(const char *query); + MYSQL_RES *ResQuery(const char *query); + void ShowSQLError(); + void FreeSQLResult(MYSQL_RES *res); + uint32_t GetLastInsertId(); + uint32_t EscapeString(const char *nText, char *dText, uint32_t dMaxLength); +}; diff --git a/TinNS/Source/PatchServer/CMakeLists.txt b/TinNS/Source/PatchServer/CMakeLists.txt new file mode 100644 index 0000000..0cdda9b --- /dev/null +++ b/TinNS/Source/PatchServer/CMakeLists.txt @@ -0,0 +1,2 @@ +ADD_EXECUTABLE (PatchServer Client.cxx Includes.cxx PatchServer.cxx Main.cxx Server.cxx) +TARGET_LINK_LIBRARIES (PatchServer Common ${PCRE_LIBRARY} ${RT_LIBRARY} ${ZLIB_LIBRARY}) diff --git a/TinNS/Source/PatchServer/Client.cxx b/TinNS/Source/PatchServer/Client.cxx new file mode 100644 index 0000000..e4b5036 --- /dev/null +++ b/TinNS/Source/PatchServer/Client.cxx @@ -0,0 +1,71 @@ +#include "PatchServer/Includes.hxx" +#include "Common/Includes.hxx" + +PClient::PClient(int32_t Index) +{ + mIndex = Index; + mConnection = PCC_NONE; +} + +PClient::~PClient() +{ + if(m_TCPConnection) + { + delete m_TCPConnection; + } +} + +int32_t PClient::GetIndex() const +{ + return mIndex; +} + +int32_t PClient::GetConnection() const +{ + return mConnection; +} + +const char *PClient::GetAddress() const +{ + return m_TCPConnection->getRemoteAddress(); +} + +void PClient::setTCPConnection(ConnectionTCP *conn) +{ + m_TCPConnection = conn; + mConnection = PCC_PATCH; +} + +ConnectionTCP *PClient::getTCPConn() +{ + return m_TCPConnection; +} + +void PClient::Update() +{ + if(m_TCPConnection) + { + if(m_TCPConnection->timeOut()) + { + Console->Print("Patchsocket: Client %i: timeout", mIndex); + PatchServer->ClientDisconnected(this); + } + else + { + if(!m_TCPConnection->update()) + { + PatchServer->ClientDisconnected(this); + } + } + } +} + +void PClient::PatchDisconnect() +{ + if(m_TCPConnection) + { + delete m_TCPConnection; + } + mConnection = PCC_NONE; + m_TCPConnection = 0; +} diff --git a/TinNS/Source/PatchServer/Client.hxx b/TinNS/Source/PatchServer/Client.hxx new file mode 100644 index 0000000..c0abe39 --- /dev/null +++ b/TinNS/Source/PatchServer/Client.hxx @@ -0,0 +1,29 @@ +#pragma once + +#include + +class ConnectionTCP; + +enum PClientConnection { + PCC_NONE = 0, + PCC_PATCH = 1 +}; + +class PClient { +private: + ConnectionTCP *m_TCPConnection; + int32_t mIndex; + int32_t mConnection; + +public: + PClient(int32_t Index); + ~PClient(); + + int32_t GetIndex() const; + int32_t GetConnection() const; + const char *GetAddress() const; + void setTCPConnection(ConnectionTCP *conn); + ConnectionTCP *getTCPConn(); + void Update(); + void PatchDisconnect(); +}; diff --git a/TinNS/Source/PatchServer/ConfigTemplate.hxx b/TinNS/Source/PatchServer/ConfigTemplate.hxx new file mode 100644 index 0000000..4b58417 --- /dev/null +++ b/TinNS/Source/PatchServer/ConfigTemplate.hxx @@ -0,0 +1,16 @@ +#pragma once + +static const char *PatchConfigTemplate[][2] = { + // {option_name, default_value} if default_value is empty string, it means option is mandatory + // List ends with empty string for option_name + {"server_version", "200"}, + {"patchserver_port", "8040"}, + {"patches_path", "./patches"}, + {"file_path", "./files"}, + {"max_file_xfers", "5"}, + {"patch_packet_size", "512"}, + {"maxclients", "5"}, + {"gm_slots", "2"}, + + {"", ""} // do not change this line (end mark) +}; diff --git a/TinNS/Source/PatchServer/Includes.cxx b/TinNS/Source/PatchServer/Includes.cxx new file mode 100644 index 0000000..b6551de --- /dev/null +++ b/TinNS/Source/PatchServer/Includes.cxx @@ -0,0 +1,61 @@ +#include "PatchServer/Includes.hxx" +#include "Common/Includes.hxx" + +const char ServerVersion[] = TINNS_PATCH_VERSION; +const char SVNRevision[] = TINNS_SVN_REVISION; + +ServerSocket* ServerSock = 0; +PConsole *Console = 0; +PServer *Server = 0; +PConfig *Config = 0; +PFileSystem *Filesystem = 0; +PPatchServer *PatchServer = 0; + +bool InitTinNS() +{ + Console = new PConsole("log/patchserver.log"); // Make that from config file !!! + Console->Print("Starting TinNS Patchserver..."); + Console->Print(WHITE, BLUE, "/-------------------------------------------------------------------\\"); + Console->Print(WHITE, BLUE, "| TinNS (TinNS is not a Neocron Server) |"); + Console->Print(WHITE, BLUE, "| Copyright (C) 2005 Linux Addicted Community |"); + Console->Print(WHITE, BLUE, "| maintainer Akiko |"); + Console->Print(WHITE, BLUE, "| ========================================== |"); + Console->Print(WHITE, BLUE, "| Head coders: The packet analyzing team: |"); + Console->Print(WHITE, BLUE, "| - Akiko - MaxxJag |"); + Console->Print(WHITE, BLUE, "| - bakkdoor - Sting |"); + Console->Print(WHITE, BLUE, "| - Namikon - Balm |"); + Console->Print(WHITE, BLUE, "| - Hammag |"); + Console->Print(WHITE, BLUE, "|-------------------------------------------------------------------|"); + Console->Print(WHITE, BLUE, "| This project would'nt be at its current stage without the help |"); + Console->Print(WHITE, BLUE, "| from the NeoPolis team, special thanks to you guys! |"); + Console->Print(WHITE, BLUE, "|-------------------------------------------------------------------|"); + Console->Print(WHITE, BLUE, "| This project is under GPL, see any source file for more details |"); + Console->Print(WHITE, BLUE, "\\-------------------------------------------------------------------/"); + + //char svnrev[10]; + //GetSVNRev(svnrev); + Console->LPrint("You are running TinNS Patchserver version"); + Console->LPrint(GREEN, BLACK, " %s", ServerVersion); + Console->LPrint(WHITE, BLACK, " - SVN Rev"); + Console->LPrint(GREEN, BLACK, " %s", SVNRevision); + Console->LClose(); + + Config = new PConfig(); + if(!Config->LoadOptions(PatchConfigTemplate ,"./conf/patchserver.conf")) + Shutdown(); + + ServerSock = new ServerSocket(); + Server = new PServer(); + PatchServer = new PPatchServer(); + + return true; +} + +void Shutdown() +{ + if(PatchServer) delete PatchServer; + if(Config) delete Config; + if(Console) delete Console; + if(ServerSock) delete ServerSock; + exit(0); +} diff --git a/TinNS/Source/PatchServer/Includes.hxx b/TinNS/Source/PatchServer/Includes.hxx new file mode 100644 index 0000000..b6fd386 --- /dev/null +++ b/TinNS/Source/PatchServer/Includes.hxx @@ -0,0 +1,19 @@ +#pragma once + +#include "PatchServer/Client.hxx" +#include "PatchServer/ConfigTemplate.hxx" +#include "PatchServer/PatchServer.hxx" +#include "PatchServer/Server.hxx" + +extern class ServerSocket* ServerSock; +extern class PConsole *Console; +extern class PConfig *Config; +extern class PFileSystem *Filesystem; +extern class PServer *Server; +extern class PPatchServer *PatchServer; + +extern const char ServerVersion[]; +extern const char SVNRevision[]; + +bool InitTinNS(); +void Shutdown(); diff --git a/TinNS/Source/PatchServer/Main.cxx b/TinNS/Source/PatchServer/Main.cxx new file mode 100644 index 0000000..c2d4d83 --- /dev/null +++ b/TinNS/Source/PatchServer/Main.cxx @@ -0,0 +1,36 @@ +#include +#include +#include +#include "PatchServer/Includes.hxx" +#include "Common/Includes.hxx" + +void signal_handler(int signal) +{ + if (signal == SIGINT) + Shutdown(); + else + psignal(signal, "Unkown signal: "); +} + +int main() +{ + signal(SIGINT, signal_handler); + + + if (!InitTinNS()) + while (true) + std::this_thread::sleep_for(std::chrono::seconds(1)); + + PatchServer->Start(); + Console->Print("Patchserver is now %s. Waiting for clients...", Console->ColorText(GREEN, BLACK, "Online")); + + while (true) + { + ServerSock->update(); + Server->Update(); + PatchServer->Update(); + // sched_yield(); + } + + return 0; +} diff --git a/server/src/patch/patchserver.cpp b/TinNS/Source/PatchServer/PatchServer.cxx similarity index 65% rename from server/src/patch/patchserver.cpp rename to TinNS/Source/PatchServer/PatchServer.cxx index 01c0e86..ae4c1e7 100644 --- a/server/src/patch/patchserver.cpp +++ b/TinNS/Source/PatchServer/PatchServer.cxx @@ -1,57 +1,11 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - patchserver.cpp - - Authors: - - Akiko - - Namikon - - someone else? - - MODIFIED: Unknown date / Unknown author - REASON: - initial release by unknown - - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL - MODIFIED: 06 Jan 2006 Namikon - REASON: - Added color to console outputs - - MODIFIED: 01 Jul 2006 hammag - REASON: - added set timeout to 10 msec (for ReadSetTCP select) in Start() - to avoid useless 100% CPU use - MODIFIED: 11 Dec 2006 hammag - REASON: - Display the client id in Client connection message rather than the always increasing mNumClients - - Removed use of mNumClients in PPatchServer. the count is done in PServer. - - ToDo: - - Take main loop timeout setting from config file -*/ - -#include "main.h" - -struct PPatchState -{ +#include +#include +#include "PatchServer/Includes.hxx" +#include "Common/Includes.hxx" + +const uint16_t PATCH_PORT = 7000; + +struct PPatchState { enum State { PS_UNKNOWN, @@ -64,16 +18,16 @@ struct PPatchState PS_SENDFILE } mState; - u16 mSerial; + uint16_t mSerial; - u32 mCurrentPatch; - u32 mPatchOffset; - u32 mPatchSize; + uint32_t mCurrentPatch; + uint32_t mPatchOffset; + uint32_t mPatchSize; std::FILE *mPatchFile; std::string mCurrentFile; - u32 mFileOffset; - u32 mFileSize; + uint32_t mFileOffset; + uint32_t mFileSize; PFile *mSendFile; bool mWaitSend; // wait-for-completition flag @@ -120,7 +74,7 @@ PPatchServer::~PPatchServer() void PPatchServer::Start() { - u16 Port = Config->GetOptionInt("patchserver_port"); + uint16_t Port = Config->GetOptionInt("patchserver_port"); if(Port==0) Port=PATCH_PORT; @@ -143,7 +97,7 @@ void PPatchServer::Update() if(ServerSock->newConnection()) { - int clid = Server->NewClient(); + int32_t clid = Server->NewClient(); if(clid!=-1) { Console->Print(GREEN, BLACK, "Patchserver: client [%i] connected", clid); @@ -206,9 +160,9 @@ void PPatchServer::ClientDisconnected(PClient *Client) FinalizeClient(Client, State); } -bool PPatchServer::HandleHandshake(PClient *Client, PPatchState *State, const u8 *Packet, int PacketSize) +bool PPatchServer::HandleHandshake(PClient *Client, PPatchState *State, const uint8_t *Packet, int32_t PacketSize) { - static const u8 HANDSHAKE1A[6]={0xfe, 0x03, 0x00, 0x80, 0x01, 0x73}; + static const uint8_t HANDSHAKE1A[6]={0xfe, 0x03, 0x00, 0x80, 0x01, 0x73}; ConnectionTCP *Socket = Client->getTCPConn(); @@ -216,13 +170,13 @@ bool PPatchServer::HandleHandshake(PClient *Client, PPatchState *State, const u8 { case PPatchState::PS_HANDSHAKE0 : { - if(PacketSize==6 && *(u16*)&Packet[3]==0x0280 && Packet[5]==0x64) + if(PacketSize==6 && *(uint16_t*)&Packet[3]==0x0280 && Packet[5]==0x64) { Socket->write(HANDSHAKE1A, sizeof(HANDSHAKE1A)); State->mState = PPatchState::PS_HANDSHAKE1; } else { - Console->Print("Patchserver protocol error (PS_HANDSHAKE0): invalid packet [%04x]", *(u16*)&Packet[3]); + Console->Print("Patchserver protocol error (PS_HANDSHAKE0): invalid packet [%04x]", *(uint16_t*)&Packet[3]); return false; } @@ -231,11 +185,11 @@ bool PPatchServer::HandleHandshake(PClient *Client, PPatchState *State, const u8 case PPatchState::PS_HANDSHAKE1 : { - if(PacketSize==6 && *(u16*)&Packet[3]==0x0080 && Packet[5]==0x6c) + if(PacketSize==6 && *(uint16_t*)&Packet[3]==0x0080 && Packet[5]==0x6c) State->mState = PPatchState::PS_VERSIONREQUEST; else { - Console->Print("Patchserver protocol error (PS_HANDSHAKE1): invalid packet [%04x]", *(u16*)&Packet[3]); + Console->Print("Patchserver protocol error (PS_HANDSHAKE1): invalid packet [%04x]", *(uint16_t*)&Packet[3]); return false; } break; @@ -247,39 +201,39 @@ bool PPatchServer::HandleHandshake(PClient *Client, PPatchState *State, const u8 return true; } -bool PPatchServer::HandleVersionRequest(PClient *Client, PPatchState *State, const u8 *Packet, int PacketSize) +bool PPatchServer::HandleVersionRequest(PClient *Client, PPatchState *State, const uint8_t *Packet, int32_t PacketSize) { - static u8 VERSIONPACKET[13]={0xfe, 0x0a, 0x00, 0x37, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + static uint8_t VERSIONPACKET[13]={0xfe, 0x0a, 0x00, 0x37, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; ConnectionTCP *Socket = Client->getTCPConn(); - if(PacketSize==9 && *(u16*)&Packet[3]==0x007b) + if(PacketSize==9 && *(uint16_t*)&Packet[3]==0x007b) { - State->mSerial = *(u16*)&Packet[7]; - *(u16*)&VERSIONPACKET[7]=State->mSerial; - u32 ver = Config->GetOptionInt("server_version"); - *(u32*)&VERSIONPACKET[9]=ver; + State->mSerial = *(uint16_t*)&Packet[7]; + *(uint16_t*)&VERSIONPACKET[7]=State->mSerial; + uint32_t ver = Config->GetOptionInt("server_version"); + *(uint32_t*)&VERSIONPACKET[9]=ver; Socket->write(VERSIONPACKET, 13); State->mState = PPatchState::PS_GETPATCHORFILE; } else { - Console->Print("Patchserver protocol error (PS_VERSIONREQUEST): invalid packet [%04x]", *(u16*)&Packet[3]); + Console->Print("Patchserver protocol error (PS_VERSIONREQUEST): invalid packet [%04x]", *(uint16_t*)&Packet[3]); return false; } return true; } -bool PPatchServer::HandleFileRequests(PClient *Client, PPatchState *State, const u8 *Packet, int PacketSize) +bool PPatchServer::HandleFileRequests(PClient *Client, PPatchState *State, const uint8_t *Packet, int32_t PacketSize) { - static u8 STARTPATCH[13]={0xfe, 0x0a, 0x00, 0x38, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - static u8 STARTFILE[13]={0xfe, 0x0a, 0x00, 0x3b, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - static u8 FILEERROR[9]={0xfe, 0x06, 0x00, 0x3d, 0x02, 0x00, 0x00, 0x00, 0x00}; + static uint8_t STARTPATCH[13]={0xfe, 0x0a, 0x00, 0x38, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + static uint8_t STARTFILE[13]={0xfe, 0x0a, 0x00, 0x3b, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + static uint8_t FILEERROR[9]={0xfe, 0x06, 0x00, 0x3d, 0x02, 0x00, 0x00, 0x00, 0x00}; ConnectionTCP *Socket = Client->getTCPConn(); // request patch - if(PacketSize==13 && *(u16*)&Packet[3]==0x007c) + if(PacketSize==13 && *(uint16_t*)&Packet[3]==0x007c) { - int nmax = Config->GetOptionInt("max_file_xfers"); + int32_t nmax = Config->GetOptionInt("max_file_xfers"); if(mNumFileTransfers>=nmax) { Console->Print("Patchserver: max file xfers exceed, killing client %i", Client->GetIndex()); @@ -297,20 +251,20 @@ bool PPatchServer::HandleFileRequests(PClient *Client, PPatchState *State, const State->mSendFile=0; --mNumFileTransfers; } - State->mSerial = *(u16*)&Packet[7]; - State->mCurrentPatch = *(u32*)&Packet[9]; + State->mSerial = *(uint16_t*)&Packet[7]; + State->mCurrentPatch = *(uint32_t*)&Packet[9]; Console->Print("Patchserver: Patch request from client %i (v%i)", Client->GetIndex(), State->mCurrentPatch); if((bool)(State->mPatchSize = StartPatch(State))) { Console->Print("Patchserver: Patch is available, %d bytes", State->mPatchSize); - *(u16*)&STARTPATCH[7]=State->mSerial; - *(u32*)&STARTPATCH[9]=State->mPatchSize; + *(uint16_t*)&STARTPATCH[7]=State->mSerial; + *(uint32_t*)&STARTPATCH[9]=State->mPatchSize; Socket->write(STARTPATCH, 13); State->mState = PPatchState::PS_SENDPATCH; } else { Console->Print("Patchserver: Patch not available"); - *(u16*)&FILEERROR[7]=State->mSerial; + *(uint16_t*)&FILEERROR[7]=State->mSerial; Socket->write(FILEERROR, 9); FinalizeClientDelayed(Client, State); State->mState=PPatchState::PS_UNKNOWN; @@ -318,9 +272,9 @@ bool PPatchServer::HandleFileRequests(PClient *Client, PPatchState *State, const } } else // request file - if(PacketSize > 9 && *(u16*)&Packet[3]==0x004d) + if(PacketSize > 9 && *(uint16_t*)&Packet[3]==0x004d) { - int nmax = Config->GetOptionInt("max_file_xfers"); + int32_t nmax = Config->GetOptionInt("max_file_xfers"); if(mNumFileTransfers>=nmax) { Console->Print("Patchserver: max file xfers exceed, killing client %i", Client->GetIndex()); @@ -339,7 +293,7 @@ bool PPatchServer::HandleFileRequests(PClient *Client, PPatchState *State, const --mNumFileTransfers; } // request file - State->mSerial = *(u16*)&Packet[7]; + State->mSerial = *(uint16_t*)&Packet[7]; char fn[256]; strncpy(fn, (const char*)&Packet[10], Packet[9]); fn[Packet[9]]=0; @@ -349,14 +303,14 @@ bool PPatchServer::HandleFileRequests(PClient *Client, PPatchState *State, const if((bool)(State->mFileSize = StartFile(State))) { Console->Print("Patchserver: File %s is available, %d bytes", State->mCurrentFile.c_str(), State->mFileSize); - *(u16*)&STARTFILE[7]=State->mSerial; - *(u32*)&STARTFILE[9]=State->mFileSize; + *(uint16_t*)&STARTFILE[7]=State->mSerial; + *(uint32_t*)&STARTFILE[9]=State->mFileSize; Socket->write(STARTFILE, 13); State->mState = PPatchState::PS_SENDFILE; } else { Console->Print("Patchserver: Requested file %s not available", State->mCurrentFile.c_str()); - *(u16*)&FILEERROR[7]=State->mSerial; + *(uint16_t*)&FILEERROR[7]=State->mSerial; Socket->write(FILEERROR, 9); FinalizeClientDelayed(Client, State); State->mState=PPatchState::PS_UNKNOWN; @@ -364,11 +318,11 @@ bool PPatchServer::HandleFileRequests(PClient *Client, PPatchState *State, const } } else // send patch data - if(PacketSize==17 && *(u16*)&Packet[3]==0x007d) + if(PacketSize==17 && *(uint16_t*)&Packet[3]==0x007d) { - State->mSerial = *(u16*)&Packet[7]; - State->mCurrentPatch = *(u32*)&Packet[9]; - State->mPatchOffset = *(u32*)&Packet[13]; + State->mSerial = *(uint16_t*)&Packet[7]; + State->mCurrentPatch = *(uint32_t*)&Packet[9]; + State->mPatchOffset = *(uint32_t*)&Packet[13]; if(!SendPatchData(Client, State)) { Console->Print("Patchserver: SendPatchData failed on client %i", Client->GetIndex()); @@ -378,10 +332,10 @@ bool PPatchServer::HandleFileRequests(PClient *Client, PPatchState *State, const } } else // send file data - if(PacketSize > 13 && *(u16*)&Packet[3]==0x00037) + if(PacketSize > 13 && *(uint16_t*)&Packet[3]==0x00037) { - State->mSerial = *(u16*)&Packet[7]; - State->mFileOffset = *(u32*)&Packet[9]; + State->mSerial = *(uint16_t*)&Packet[7]; + State->mFileOffset = *(uint32_t*)&Packet[9]; if(!SendFileData(Client, State)) { Console->Print("Patchserver: SendFileData failed on client %i", Client->GetIndex()); @@ -398,7 +352,7 @@ bool PPatchServer::HandleFileRequests(PClient *Client, PPatchState *State, const return true; } -u32 PPatchServer::StartPatch(PPatchState *State) +uint32_t PPatchServer::StartPatch(PPatchState *State) { std::stringstream path; char patchname[13]; @@ -409,7 +363,7 @@ u32 PPatchServer::StartPatch(PPatchState *State) { ++mNumFileTransfers; fseek(State->mPatchFile, 0, SEEK_END); - u32 size = ftell(State->mPatchFile); + uint32_t size = ftell(State->mPatchFile); fseek(State->mPatchFile, 0, SEEK_SET); return size; } @@ -421,29 +375,29 @@ bool PPatchServer::SendPatchData(PClient *Client, PPatchState *State) const if(!State->mPatchFile) return false; - u16 size = Config->GetOptionInt("patch_packet_size"); + uint16_t size = Config->GetOptionInt("patch_packet_size"); - const int BUFFERSIZE = 4082; + const int32_t BUFFERSIZE = 4082; - size = std::min(BUFFERSIZE, std::max((s32)size, 64)); - static u8 Buffer[BUFFERSIZE+13]; + size = std::min(BUFFERSIZE, std::max((int32_t)size, 64)); + static uint8_t Buffer[BUFFERSIZE+13]; if(fseek(State->mPatchFile, State->mPatchOffset, SEEK_SET)!=0) return false; size = fread(&Buffer[13], 1, size, State->mPatchFile); Buffer[0]=0xfe; - *(u16*)&Buffer[1]=size+10; + *(uint16_t*)&Buffer[1]=size+10; Buffer[3]=0x39; Buffer[4]=0x02; Buffer[5]=0x00; Buffer[6]=0x00; - *(u16*)&Buffer[7]=State->mSerial; - *(u32*)&Buffer[9]=size; + *(uint16_t*)&Buffer[7]=State->mSerial; + *(uint32_t*)&Buffer[9]=size; return Client->getTCPConn()->write(Buffer, size+13)==size+13; } -u32 PPatchServer::StartFile(PPatchState *State) +uint32_t PPatchServer::StartFile(PPatchState *State) { // security checks: reject file paths containing ':', '..' or slashes/backslashes at the beginning if((State->mCurrentFile.find(':') != std::string::npos) @@ -460,7 +414,7 @@ u32 PPatchServer::StartFile(PPatchState *State) if(State->mSendFile) { ++mNumFileTransfers; - u32 size = State->mSendFile->GetSize(); + uint32_t size = State->mSendFile->GetSize(); return size; } return 0; @@ -471,30 +425,30 @@ bool PPatchServer::SendFileData(PClient *Client, PPatchState *State) const if(!State->mSendFile) return false; - u16 size = Config->GetOptionInt("patch_packet_size"); + uint16_t size = Config->GetOptionInt("patch_packet_size"); - const int BUFFERSIZE = 4082; + const int32_t BUFFERSIZE = 4082; - size = std::min(BUFFERSIZE, std::max((s32)size, 1)); - static u8 Buffer[BUFFERSIZE+13]; + size = std::min(BUFFERSIZE, std::max((int32_t)size, 1)); + static uint8_t Buffer[BUFFERSIZE+13]; State->mSendFile->Seek(State->mFileOffset); size = State->mSendFile->Read(&Buffer[13], size); Buffer[0]=0xfe; - *(u16*)&Buffer[1]=size+10; + *(uint16_t*)&Buffer[1]=size+10; Buffer[3]=0x3c; Buffer[4]=0x02; Buffer[5]=0x00; Buffer[6]=0x00; - *(u16*)&Buffer[7]=State->mSerial; - *(u32*)&Buffer[9]=size; + *(uint16_t*)&Buffer[7]=State->mSerial; + *(uint32_t*)&Buffer[9]=size; return Client->getTCPConn()->write(Buffer, size+13)==size+13; } bool PPatchServer::ProcessClient(PClient *Client, PPatchState *State) { - static const u8 HANDSHAKE0A[6]={0xfe, 0x03, 0x00, 0x80, 0x03, 0x6b}; + static const uint8_t HANDSHAKE0A[6]={0xfe, 0x03, 0x00, 0x80, 0x03, 0x6b}; if(!State) { @@ -520,8 +474,8 @@ bool PPatchServer::ProcessClient(PClient *Client, PPatchState *State) Socket->flushSendBuffer(); } - int PacketSize=0; - const u8 *Packet = Socket->read(&PacketSize); + int32_t PacketSize = 0; + const uint8_t *Packet = Socket->read(&PacketSize); if(PacketSize > 0) { switch(State->mState) diff --git a/TinNS/Source/PatchServer/PatchServer.hxx b/TinNS/Source/PatchServer/PatchServer.hxx new file mode 100644 index 0000000..9d517b2 --- /dev/null +++ b/TinNS/Source/PatchServer/PatchServer.hxx @@ -0,0 +1,38 @@ +#pragma once + +#include +#include + +class PClient; +struct PPatchState; + +class PPatchServer { +private: + int mNumClients; + int mNumFileTransfers; + typedef std::map PatchStateMap; + PatchStateMap ClientStates; + +protected: + bool ProcessClient(PClient *Client, PPatchState *State = nullptr); +// uint32_t StartPatch(PClient *Client, PPatchState *State); + uint32_t StartPatch(PPatchState *State); + bool SendPatchData(PClient *Client, PPatchState *State) const; +// u32 StartFile(PClient *Client, PPatchState *State); + uint32_t StartFile(PPatchState *State); + bool SendFileData(PClient *Client, PPatchState *State) const; + void FinalizeClient(PClient *Client, PPatchState *State); + void FinalizeClientDelayed(PClient *Client, PPatchState *State); + + bool HandleHandshake(PClient *Client, PPatchState *State, const uint8_t *Packet, int32_t PacketSize); + bool HandleVersionRequest(PClient *Client, PPatchState *State, const uint8_t *Packet, int32_t PacketSize); + bool HandleFileRequests(PClient *Client, PPatchState *State, const uint8_t *Packet, int32_t PacketSize); + +public: + PPatchServer(); + ~PPatchServer(); + + void Start(); + void Update(); + void ClientDisconnected(PClient *Client); +}; diff --git a/TinNS/Source/PatchServer/Server.cxx b/TinNS/Source/PatchServer/Server.cxx new file mode 100644 index 0000000..0ee9260 --- /dev/null +++ b/TinNS/Source/PatchServer/Server.cxx @@ -0,0 +1,95 @@ +#include "PatchServer/Includes.hxx" +#include "Common/Includes.hxx" + +PServer::PServer() +{ + mNumClients = 0; + mMaxClients = Config->GetOptionInt("maxclients"); + mGMSlots = Config->GetOptionInt("gm_slots"); + + if (mMaxClients==0) + mMaxClients=1; + if (mGMSlots==0) + mGMSlots=1; + mClients.reserve(mMaxClients + mGMSlots); + for (int32_t i=0; iPrint("%d %d", mMaxClients, mGMSlots); + if (mNumClients==mMaxClients+mGMSlots) + return -1; + for (int32_t i=0; i= mMaxClients+mGMSlots) + return 0; + + return mClients[Client]; +} + +void PServer::Update() +{ + for (int32_t i=0; iUpdate(); + if (mClients[i]->GetConnection()==PCC_NONE && mClients[i]->getTCPConn() == 0) + { + Console->Print("Removing client ..."); + delete mClients[i]; + mClients[i]=0; + --mNumClients; + } + } + } +} + +void PServer::Shutdown() +{ + Console->Print("======================"); + Console->Print("Shutting down Patchserver..."); + for (int32_t i=0; i +#include + +class PClient; + +class PServer { +private: + int32_t mMaxClients; + int32_t mGMSlots; + int32_t mNumClients; + std::vector mClients; + +public: + PServer(); + ~PServer(); + + int32_t GetMaxClients() const; + int32_t GetGMSlots() const; + int32_t GetNumClients() const; + int32_t NewClient(); + PClient *GetClient(int32_t Client) const; + void Update(); + void Shutdown(); +}; diff --git a/server/conf/commands.conf b/TinNS/conf/commands.conf similarity index 100% rename from server/conf/commands.conf rename to TinNS/conf/commands.conf diff --git a/server/conf/gameserver.conf b/TinNS/conf/gameserver.conf similarity index 100% rename from server/conf/gameserver.conf rename to TinNS/conf/gameserver.conf diff --git a/server/conf/global.conf b/TinNS/conf/global.conf similarity index 100% rename from server/conf/global.conf rename to TinNS/conf/global.conf diff --git a/server/conf/infoserver.conf b/TinNS/conf/infoserver.conf similarity index 100% rename from server/conf/infoserver.conf rename to TinNS/conf/infoserver.conf diff --git a/server/conf/patchserver.conf b/TinNS/conf/patchserver.conf similarity index 100% rename from server/conf/patchserver.conf rename to TinNS/conf/patchserver.conf diff --git a/server/data/scripts/lua/zippy.lua b/TinNS/data/scripts/lua/zippy.lua similarity index 100% rename from server/data/scripts/lua/zippy.lua rename to TinNS/data/scripts/lua/zippy.lua diff --git a/server/database/DB_v8/DB_v8_patch001.sql b/TinNS/database/DB_v8/DB_v8_patch001.sql similarity index 100% rename from server/database/DB_v8/DB_v8_patch001.sql rename to TinNS/database/DB_v8/DB_v8_patch001.sql diff --git a/server/database/DB_v8/TinNS_GameDB_rev8_BaseData.sql b/TinNS/database/DB_v8/TinNS_GameDB_rev8_BaseData.sql similarity index 100% rename from server/database/DB_v8/TinNS_GameDB_rev8_BaseData.sql rename to TinNS/database/DB_v8/TinNS_GameDB_rev8_BaseData.sql diff --git a/server/database/DB_v8/changes.txt b/TinNS/database/DB_v8/changes.txt similarity index 100% rename from server/database/DB_v8/changes.txt rename to TinNS/database/DB_v8/changes.txt diff --git a/server/database/DB_v8/patch_gamedb_rev7_to_rev8.sql b/TinNS/database/DB_v8/patch_gamedb_rev7_to_rev8.sql similarity index 100% rename from server/database/DB_v8/patch_gamedb_rev7_to_rev8.sql rename to TinNS/database/DB_v8/patch_gamedb_rev7_to_rev8.sql diff --git a/server/database/DB_v8/readme.txt b/TinNS/database/DB_v8/readme.txt similarity index 100% rename from server/database/DB_v8/readme.txt rename to TinNS/database/DB_v8/readme.txt diff --git a/server/database/DB_v8/unified_game_DB_rev8.sql b/TinNS/database/DB_v8/unified_game_DB_rev8.sql similarity index 100% rename from server/database/DB_v8/unified_game_DB_rev8.sql rename to TinNS/database/DB_v8/unified_game_DB_rev8.sql diff --git a/server/database/DB_v8/unified_infoDB_rev8.sql b/TinNS/database/DB_v8/unified_infoDB_rev8.sql similarity index 100% rename from server/database/DB_v8/unified_infoDB_rev8.sql rename to TinNS/database/DB_v8/unified_infoDB_rev8.sql diff --git a/server/database/GameDB.sql b/TinNS/database/GameDB.sql similarity index 100% rename from server/database/GameDB.sql rename to TinNS/database/GameDB.sql diff --git a/server/database/GameDB_migration_rev107-rev108.sql b/TinNS/database/GameDB_migration_rev107-rev108.sql similarity index 100% rename from server/database/GameDB_migration_rev107-rev108.sql rename to TinNS/database/GameDB_migration_rev107-rev108.sql diff --git a/server/database/GameDB_migration_rev81-rev82.sql b/TinNS/database/GameDB_migration_rev81-rev82.sql similarity index 100% rename from server/database/GameDB_migration_rev81-rev82.sql rename to TinNS/database/GameDB_migration_rev81-rev82.sql diff --git a/server/database/GameDB_patch_rev133-rev134.sql b/TinNS/database/GameDB_patch_rev133-rev134.sql similarity index 100% rename from server/database/GameDB_patch_rev133-rev134.sql rename to TinNS/database/GameDB_patch_rev133-rev134.sql diff --git a/server/database/GameDB_patch_rev134-rev140.sql b/TinNS/database/GameDB_patch_rev134-rev140.sql similarity index 100% rename from server/database/GameDB_patch_rev134-rev140.sql rename to TinNS/database/GameDB_patch_rev134-rev140.sql diff --git a/server/database/InfoDB.sql b/TinNS/database/InfoDB.sql similarity index 100% rename from server/database/InfoDB.sql rename to TinNS/database/InfoDB.sql diff --git a/server/database/infoDB.s3db b/TinNS/database/infoDB.s3db similarity index 100% rename from server/database/infoDB.s3db rename to TinNS/database/infoDB.s3db diff --git a/server/init.d/tinns b/TinNS/init.d/tinns similarity index 100% rename from server/init.d/tinns rename to TinNS/init.d/tinns diff --git a/Tools/CMakeLists.txt b/Tools/CMakeLists.txt new file mode 100644 index 0000000..c8150eb --- /dev/null +++ b/Tools/CMakeLists.txt @@ -0,0 +1,2 @@ +ADD_SUBDIRECTORY (PakDecompress) +ADD_SUBDIRECTORY (VFSviewer) diff --git a/Tools/PakDecompress/CMakeLists.txt b/Tools/PakDecompress/CMakeLists.txt new file mode 100644 index 0000000..333bf27 --- /dev/null +++ b/Tools/PakDecompress/CMakeLists.txt @@ -0,0 +1,2 @@ +ADD_EXECUTABLE (PakDecompress PakDecompress.cxx) +TARGET_LINK_LIBRARIES (PakDecompress ${ZLIB_LIBRARY}) diff --git a/Tools/PakDecompress/PakDecompress.cxx b/Tools/PakDecompress/PakDecompress.cxx new file mode 100644 index 0000000..b1f1776 --- /dev/null +++ b/Tools/PakDecompress/PakDecompress.cxx @@ -0,0 +1,189 @@ +#include +#include +#include +#include +#include +#include + +#define CHUNK 262144 + +int inf(FILE *source, FILE *dest, bool details) +{ + int ret; + char check; + unsigned have; + z_stream strm; + unsigned char in[CHUNK]; + unsigned char out[CHUNK]; + + strm.zalloc = Z_NULL; + strm.zfree = Z_NULL; + strm.opaque = Z_NULL; + strm.avail_in = 0; + strm.next_in = Z_NULL; + ret = inflateInit(&strm); + + if (ret != Z_OK) + return(ret); + + check = fgetc(source); + if(check == 'x') + { + if(details == true) std::cout << "Found zLibfile" << std::endl; + fseek(source, 0, SEEK_SET); + } + else + { + fseek(source, 16, SEEK_SET); + check = fgetc(source); + if(check == 'x') + { + if(details == true) std::cout << "Found Neocron file" << std::endl; + fseek(source, 16, SEEK_SET); + } + else + { + if(details == true) std::cout << "Error: No compatible file!" << std::endl; + return -3; + } + } + + do { + strm.avail_in = fread(in, 1, CHUNK, source); + + if (ferror(source)) { + (void)inflateEnd(&strm); + + return(Z_ERRNO); + } + + if (strm.avail_in == 0) + break; + strm.next_in = in; + + do { + strm.avail_out = CHUNK; + strm.next_out = out; + ret = inflate(&strm, Z_NO_FLUSH); + assert(ret != Z_STREAM_ERROR); + + switch(ret) { + case Z_NEED_DICT: + ret = Z_DATA_ERROR; + case Z_DATA_ERROR: + case Z_MEM_ERROR: + (void)inflateEnd(&strm); + return(ret); + } + + have = CHUNK - strm.avail_out; + + if (fwrite(out, 1, have, dest) != have || ferror(dest)) { + (void)inflateEnd(&strm); + + return(Z_ERRNO); + } + } while (strm.avail_out == 0); + + assert(strm.avail_in == 0); + } while (ret != Z_STREAM_END); + + (void)inflateEnd(&strm); + + return(ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR); +} + +void zerr(int ret) +{ + fputs("zpipe: ", stderr); + + switch(ret) { + case Z_ERRNO: + if (ferror(stdin)) + fputs("error reading stdin\n", stderr); + if (ferror(stdout)) + fputs("error writing stdout\n", stderr); + break; + case Z_STREAM_ERROR: + fputs("invalid compression level\n", stderr); + break; + case Z_DATA_ERROR: + fputs("invalid or incomplete deflate data\n", stderr); + break; + case Z_MEM_ERROR: + fputs("out of memory\n", stderr); + break; + case Z_VERSION_ERROR: + fputs("zlib version mismatch!\n", stderr); + } +} + +int main(int argc, char **argv) { + int ret; + long inSize; + long outSize; + bool details = false; + FILE *inFile; + FILE *outFile; + std::string src; + std::string dst; + + if(argc == 2) { + src = argv[1]; + dst = strcat(argv[1], ".decompressed"); + } + else if(argc > 2 && strcmp(argv[1], argv[2])) { + src = argv[1]; + dst = argv[2]; + } + else { + std::cout << "Usage: pak_decompress source " << std::endl; + return(0); + } + if(argc == 4) + { + if(argv[3][0] == '1') details = true; + else if(argv[3][0] == '0') details = false; + } + + inFile = fopen(src.c_str(), "rb"); + outFile = fopen(dst.c_str(), "wb"); + + if(inFile == NULL) + { + std::cout << "Cannot open InFile" << std::endl; + return(-1); + } + if(outFile == NULL) + { + std::cout << "Cannot open OutFile" << std::endl; + return(-2); + } + ret = inf(inFile, outFile, details); + + /* just to be sure - we got to the end */ + fseek(inFile, 0, SEEK_END); + fseek(outFile, 0, SEEK_END); + inSize = ftell(inFile); + outSize = ftell(outFile); + + fclose(outFile); + fclose(inFile); + + if(ret == Z_OK && details == true) + { + std::cout << "bytes read: " << inSize << std::endl; + std::cout << "bytes written: " << outSize << std::endl; + std::cout << "compression ratio: " << (100-((float)inSize/(float)outSize*100)) << "%" << std::endl; + } + else if(ret == Z_OK && details == false) + { + std::cout << "[OK] " << src.c_str() << std::endl; + } + else if(ret != Z_OK && details == false) + { + std::cout << "[ERROR] " << src.c_str() << std::endl; + } + + return(ret); +} diff --git a/Tools/VFSviewer/CMakeLists.txt b/Tools/VFSviewer/CMakeLists.txt new file mode 100644 index 0000000..b57f3f5 --- /dev/null +++ b/Tools/VFSviewer/CMakeLists.txt @@ -0,0 +1,2 @@ +ADD_EXECUTABLE (VFSviewer VfsViewer.c) +TARGET_LINK_LIBRARIES (VFSviewer ${ZLIB_LIBRARY}) diff --git a/Tools/VFSviewer/VfsViewer.c b/Tools/VFSviewer/VfsViewer.c new file mode 100644 index 0000000..3662ea4 --- /dev/null +++ b/Tools/VFSviewer/VfsViewer.c @@ -0,0 +1,60 @@ +#include +#include + +typedef unsigned int u32; +typedef unsigned char u8; + +int main(int argc, char *argv[]) { + // structure of the file informtion inside the virtual FS + struct t_file_header { + u32 id; + u32 offset; + u32 csize; + u32 dsize; + u32 len_name; + u8 *name; + }; + // structure of the virtual FS + struct t_vfs_header { + u32 id; + u32 file_count; + struct t_file_header *files; + u8 *data; + }; + + if (argc == 2) { + FILE *fd; + struct t_vfs_header vfs_file; + + fd = fopen(argv[1], "rb"); + + // reading the vfs header including the amount of files in the virtual FS + fread(&vfs_file.id, sizeof(u32), 1, fd); + fread(&vfs_file.file_count, sizeof(u32), 1, fd); + + struct t_file_header files[vfs_file.file_count]; + + // reading all information from the vfs into an array and print some of them + u32 i; + for (i = 0; i < vfs_file.file_count; i++) { + fread(&files[i].id, sizeof(u32), 1, fd); + fread(&files[i].offset, sizeof(u32), 1, fd); + fread(&files[i].csize, sizeof(u32), 1, fd); + fread(&files[i].dsize, sizeof(u32), 1 ,fd); + fread(&files[i].len_name, sizeof(u32), 1, fd); + + files[i].name = (u8 *)malloc(sizeof(u8)*files[i].len_name); + fread(files[i].name, sizeof(u8), files[i].len_name, fd); + //fseek(fd, files[i].len_name, SEEK_CUR); + + printf("Filenumber %4i: %50s (%7i/%7i) ID-%2i\n", i, files[i].name, files[i].csize, files[i].dsize, files[i].id); + } + + fclose(fd); + } else { + printf("Usage: vfs_viewer \n"); + exit(1); + } + + exit(0); +} diff --git a/cmake_distclean.sh b/cmake_distclean.sh index d0f6648..7793178 100755 --- a/cmake_distclean.sh +++ b/cmake_distclean.sh @@ -4,91 +4,45 @@ rm -rf CMakeCache.txt rm -rf cmake_install.cmake rm -rf Makefile rm -rf CMakeFiles/ -rm -rf tools/cmake_install.cmake -rm -rf tools/Makefile -rm -rf tools/CMakeFiles/ -rm -rf tools/pak_decompress/cmake_install.cmake -rm -rf tools/pak_decompress/Makefile -rm -rf tools/pak_decompress/CMakeFiles/ -rm -rf tools/vfs_viewer/cmake_install.cmake -rm -rf tools/vfs_viewer/Makefile -rm -rf tools/vfs_viewer/CMakeFiles/ -rm -rf server/cmake_install.cmake -rm -rf server/Makefile server/CMakeFiles/ -rm -rf server/src/cmake_install.cmake -rm -rf server/src/Makefile server/src/CMakeFiles/ -rm -rf server/src/common/cmake_install.cmake -rm -rf server/src/common/Makefile -rm -rf server/src/common/CMakeFiles/ -rm -rf server/src/common/config/cmake_install.cmake -rm -rf server/src/common/config/Makefile -rm -rf server/src/common/config/CMakeFiles/ -rm -rf server/src/common/console/cmake_install.cmake -rm -rf server/src/common/console/Makefile -rm -rf server/src/common/console/CMakeFiles/ -rm -rf server/src/common/filesystem/cmake_install.cmake -rm -rf server/src/common/filesystem/Makefile -rm -rf server/src/common/filesystem/CMakeFiles/ -rm -rf server/src/common/misc/cmake_install.cmake -rm -rf server/src/common/misc/Makefile -rm -rf server/src/common/misc/CMakeFiles/ -rm -rf server/src/common/netcode/cmake_install.cmake -rm -rf server/src/common/netcode/Makefile -rm -rf server/src/common/netcode/CMakeFiles/ -rm -rf server/src/common/regex/cmake_install.cmake -rm -rf server/src/common/regex/Makefile -rm -rf server/src/common/regex/CMakeFiles/ -rm -rf server/src/dev-tools/cmake_install.cmake -rm -rf server/src/dev-tools/Makefile -rm -rf server/src/dev-tools/CMakeFiles/ -rm -rf server/src/game/cmake_install.cmake -rm -rf server/src/game/Makefile -rm -rf server/src/game/CMakeFiles/ -rm -rf server/src/game/decoder/cmake_install.cmake -rm -rf server/src/game/decoder/Makefile -rm -rf server/src/game/decoder/CMakeFiles/ -rm -rf server/src/game/def/cmake_install.cmake -rm -rf server/src/game/def/Makefile -rm -rf server/src/game/def/CMakeFiles/ -rm -rf server/src/game/gamecommands/cmake_install.cmake -rm -rf server/src/game/gamecommands/Makefile -rm -rf server/src/game/gamecommands/CMakeFiles/ -rm -rf server/src/info/cmake_install.cmake -rm -rf server/src/info/Makefile -rm -rf server/src/info/CMakeFiles/ -rm -rf server/src/patch/cmake_install.cmake -rm -rf server/src/patch/Makefile -rm -rf server/src/patch/CMakeFiles/ -# code counter - -LOG="/tmp/log.$$" -LINES=0 -C=0 +rm -rf Tools/cmake_install.cmake +rm -rf Tools/Makefile +rm -rf Tools/CMakeFiles/ +rm -rf Tools/PakDecompress/cmake_install.cmake +rm -rf Tools/PakDecompress/Makefile +rm -rf Tools/PakDecompress/CMakeFiles/ +rm -rf Tools/VFSviewer/cmake_install.cmake +rm -rf Tools/VFSviewer/Makefile +rm -rf Tools/VFSviewer/CMakeFiles/ -find|grep "\.c$" >$LOG -find|grep "\.cpp$" >>$LOG -find|grep "\.h$" >>$LOG -find|grep "\.hpp$" >>$LOG -find|grep "\.sh$" >>$LOG -find|grep "\.S$" >>$LOG -find|grep "install-script$" >>$LOG -find|grep "bar$" >>$LOG -find|grep "colors$" >>$LOG -find|grep "function$" >>$LOG -while read L -do - C=$((C+1)) - W=$(cat $L|wc -l) - S=$(cat $L|wc -c) - SIZE=$((SIZE+S)) - LINES=$((LINES+W)) -done <$LOG -rm $LOG +rm -rf TinNS/cmake_install.cmake +rm -rf TinNS/Makefile TinNS/CMakeFiles/ +rm -rf TinNS/Source/cmake_install.cmake +rm -rf TinNS/Source/Makefile TinNS/Source/CMakeFiles/ +rm -rf TinNS/Source/Common/cmake_install.cmake +rm -rf TinNS/Source/Common/Makefile +rm -rf TinNS/Source/Common/CMakeFiles/ +rm -rf TinNS/Source/DevelopmentTools/cmake_install.cmake +rm -rf TinNS/Source/DevelopmentTools/Makefile +rm -rf TinNS/Source/DevelopmentTools/CMakeFiles/ +rm -rf TinNS/Source/GameServer/cmake_install.cmake +rm -rf TinNS/Source/GameServer/Makefile +rm -rf TinNS/Source/GameServer/CMakeFiles/ +rm -rf TinNS/Source/GameServer/Decoder/cmake_install.cmake +rm -rf TinNS/Source/GameServer/Decoder/Makefile +rm -rf TinNS/Source/GameServer/Decoder/CMakeFiles/ +rm -rf TinNS/Source/GameServer/Definitions/cmake_install.cmake +rm -rf TinNS/Source/GameServer/Definitions/Makefile +rm -rf TinNS/Source/GameServer/Definitions/CMakeFiles/ +rm -rf TinNS/Source/GameServer/GameCommands/cmake_install.cmake +rm -rf TinNS/Source/GameServer/GameCommands/Makefile +rm -rf TinNS/Source/GameServer/GameCommands/CMakeFiles/ +rm -rf TinNS/Source/InfoServer/cmake_install.cmake +rm -rf TinNS/Source/InfoServer/Makefile +rm -rf TinNS/Source/InfoServer/CMakeFiles/ +rm -rf TinNS/Source/PatchServer/cmake_install.cmake +rm -rf TinNS/Source/PatchServer/Makefile +rm -rf TinNS/Source/PatchServer/CMakeFiles/ -echo -echo "--- REPOSITORY SUMMARY ---" -echo "source files: $C (c/cpp/h/hpp/sh/S)" -echo "lines of code: $LINES" -echo "size of code: $SIZE bytes" -echo +# code counter +Scripts/CodeCounter.sh diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt deleted file mode 100644 index 70ac51a..0000000 --- a/server/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -ADD_SUBDIRECTORY (src) diff --git a/server/src/CMakeLists.txt b/server/src/CMakeLists.txt deleted file mode 100644 index 1ad7f2e..0000000 --- a/server/src/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# move base dir to src -INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/server/src) - -ADD_SUBDIRECTORY (common) -ADD_SUBDIRECTORY (dev-tools) -ADD_SUBDIRECTORY (game) -ADD_SUBDIRECTORY (info) -ADD_SUBDIRECTORY (patch) diff --git a/server/src/common/CMakeLists.txt b/server/src/common/CMakeLists.txt deleted file mode 100644 index 4b49e05..0000000 --- a/server/src/common/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -ADD_LIBRARY (common config.cpp console.cpp filesystem.cpp misc.cpp message.cpp netcode.cpp regex++.cpp) diff --git a/server/src/common/message.h b/server/src/common/message.h deleted file mode 100644 index f38f4df..0000000 --- a/server/src/common/message.h +++ /dev/null @@ -1,103 +0,0 @@ -#pragma once - -#include - -#define MESSAGE_SIZES_LIST 32, 64, 128, 256, 512, 1024, 4096 -#define MESSAGE_POOL_INIT NULL, NULL, NULL, NULL, NULL, NULL, NULL -#define MESSAGE_POOL_COUNT_INIT 0, 0, 0, 0, 0, 0, 0 -#define MESSAGE_SIZES_NB 7 -#define MESSAGE_ALLOC_NB 4 - -struct PMsgData { - PMsgData* mNextMsgData; - uint8_t* mBuffer; // NB: no need to manage buffer deletion atm, as they will stay until server end -}; -//NB: putting mPoolId & mMaxSize in PMsgData rather than PMessage would be cleaner, but would put more mem overhead on each buffer -// Doesn't matter much as PMsgData management is done only through PMessage - -class PMessage { - private: - static const uint16_t smMsgSizes[MESSAGE_SIZES_NB]; - static PMsgData* smMsgPoolHead[MESSAGE_SIZES_NB]; - static int smMsgPoolCount[MESSAGE_SIZES_NB]; - static int smMsgCount; //Used to trace unreleased messages with CheckMsgCount() - - uint8_t mPoolId; - uint16_t mMaxSize; - PMsgData* mData; - uint16_t mUsedSize; - uint16_t mNextByteOffset; - - void GetMsgBuffer(uint16_t nRequestedSize = 0); // the requested size is just a hint to avoid internal reaffectation of buffer - void ReleaseMsgBuffer(); - void CheckAndExtend(uint16_t nRequestedSize); // This is SIZE checked, not max OFFSET - inline void UpdateUsedSize() { if (mNextByteOffset > mUsedSize) mUsedSize = mNextByteOffset; } - - public: - static void CheckMsgCount(); //To be used in a place where no new message should remain between calls - - PMessage(uint16_t nRequestedSize = 0); // max size will be extended as needed in later write accesses (up to max configured size) - PMessage(PMessage& nMessage); // creates a (size optimized, offset reset) copy of nMessage - inline ~PMessage() { ReleaseMsgBuffer(); --smMsgCount; } - - void SetNextByteOffset(uint16_t nPos); - inline void IncreaseNextByteOffset(uint16_t nIncrement) { SetNextByteOffset(mNextByteOffset + nIncrement); } - inline void SetNextByteAtEnd() { mNextByteOffset = mUsedSize; } - inline uint16_t GetNextByteOffset() { return mNextByteOffset; } - void ForceSize(uint16_t nUsedSize); - inline uint16_t GetSize() { return mUsedSize; } - inline uint16_t GetMaxSize() { return mMaxSize; } - inline bool EOM() {return (mNextByteOffset >= mUsedSize);} // End Of Message - - // Writing methods - uint8_t* GetMessageDataPointer(uint16_t nUsedSize); // extends buffer as needed by nUsedSize, and sets UsedSize at min nUsedSize - PMessage& Fill(uint8_t Value = 0, uint16_t StartOffset = 0, uint16_t FillSize = 0); // !!! Does NOT update UsedSize, fills only up to current maxSize - inline PMessage& Reset() { mNextByteOffset = mUsedSize = 0; return *this; } - inline PMessage& Clear() { return this->Fill(0).Reset(); } - PMessage& Write(const void* nData, uint16_t nLength); - PMessage& operator << (PMessage& nMessage); - PMessage& operator << (const char* nString); //for null terminated string ! Copies includes ending \0 - inline PMessage& operator << (std::string& nString) { return (*this << nString.c_str()); } - PMessage& operator << (uint8_t nU8); - inline PMessage& operator << (char nChar) { return (*this << (uint8_t) nChar);} - PMessage& operator << (uint16_t nU16); - PMessage& operator << (uint32_t nU32); - PMessage& operator << (float nF32); - - // Mixt methods - - //The next 3 methods do NOT update NextByteOffset, but DO increase message size (UsedSize ans MaxSize) as needed by nOffset. - uint8_t& U8Data(uint16_t nOffset); - uint16_t& U16Data(uint16_t nOffset); - uint32_t& U32Data(uint16_t nOffset); - float& F32Data(uint16_t nOffset); - - // *** didn't managed to overload [] operator :-/ - inline uint8_t& operator [] (uint16_t nOffset) { return U8Data(nOffset); } - //inline u16& operator [] (u16 nOffset) { return U16Data(nOffset); } - //u32& operator [] (u16 nOffset); - - // Really makes a different message instance, with all data copied (no data shared) - PMessage& operator = (PMessage& nMessage); - - // Reading methods - // ChunkNumber count from 0, return NULL for empty chunk (ie StartOffset is over UsedSize). NextByteOffset NOT updated - PMessage* GetChunk(uint16_t StartOffset, uint16_t ChunkSize, uint16_t ChunkNumber = 0); - - // Return pointer to the START of message data. - inline uint8_t const* GetMessageData() { return mData->mBuffer; } - - //Following methods do NOT extend message or Used, and return 0/empty string if over UsedSize - PMessage& operator >> (std::string& nString); //read up to null or EOM - PMessage& operator >> (uint8_t& nU8); - inline PMessage& operator >> (char& nChar) { return (*this >> (uint8_t&) nChar);} - PMessage& operator >> (uint16_t& nU16); - PMessage& operator >> (uint32_t& nU32); - PMessage& operator >> (float& nF32); - - // info/debug methods - static void ListPools(); - static void DumpPools(); - void Dump(); - void DumpHead(char* nComment = ""); -}; diff --git a/server/src/common/regex++.h b/server/src/common/regex++.h deleted file mode 100644 index edbff07..0000000 --- a/server/src/common/regex++.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -#include - -#ifndef _PCRE_H -#include "pcre.h" -#endif - -class RegEx { -private: - pcre * re; - pcre_extra * pe; - int substrcount; - int * ovector; - const char * lastsubject; - int slen; - const char * * matchlist; - - inline void ClearMatchList(void) - { - if (matchlist) - { - pcre_free_substring_list(matchlist); - matchlist = NULL; - } - } - -public: - RegEx(const char * regex, int options = 0); - ~RegEx(); - inline int SubStrings(void) const { return substrcount; } - bool Search(const char * subject, int len = -1, int options = 0); - bool SearchAgain(int options = 0); - const char * Match(int i = 1); -}; diff --git a/server/src/game/CMakeLists.txt b/server/src/game/CMakeLists.txt deleted file mode 100644 index 64be2d1..0000000 --- a/server/src/game/CMakeLists.txt +++ /dev/null @@ -1,50 +0,0 @@ -INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/server/src/game ${LUA53_INCLUDE_DIR}) - -ADD_EXECUTABLE (gameserver - # decoder stuff - decoder/msgdecoder.cpp decoder/udp_0x13.cpp decoder/udp_0x1f.cpp decoder/udp_0x22.cpp - decoder/udp_0x2b.cpp decoder/udpanalyser.cpp decoder/udp_appartment.cpp - decoder/udp_charmove.cpp decoder/udp_chat.cpp decoder/udp_deathrespawn.cpp - decoder/udp_entityposreq.cpp decoder/udp_hack.cpp decoder/udp_helditemaction.cpp - decoder/udp_0x08.cpp decoder/udp_OOO.cpp decoder/udp_itemmanualreload.cpp - decoder/udp_itemmove.cpp decoder/udp_itemuse.cpp decoder/udp_killself.cpp - decoder/udp_outfitter.cpp decoder/udp_packet0.cpp decoder/udp_ping.cpp - decoder/udp_popupresponse.cpp decoder/udp_quickaccessbelt.cpp decoder/udp_reqinfo.cpp - decoder/udp_subskill.cpp decoder/udp_sync.cpp decoder/udp_terminal.cpp - decoder/udp_useobject.cpp decoder/udp_vhc.cpp decoder/udp_zoning.cpp - decoder/udp_worldIDinfo.cpp decoder/udp_multipart.cpp decoder/udp_pvptrade.cpp - decoder/udp_npcdialog.cpp - # def file stuff - def/def_actionmod.cpp def/def_ammo.cpp def/def_appartements.cpp def/def_appplaces.cpp - def/def_blueprintpieces.cpp def/def_characters.cpp def/def_charaction.cpp def/def_charkinds.cpp - def/def_damage.cpp def/def_drugs.cpp def/def_factions.cpp def/def_hack.cpp def/def_implants.cpp - def/def_itemcontainer.cpp def/def_itemmod.cpp def/def_itemres.cpp def/def_items.cpp - def/def_mission.cpp def/def_npcarmor.cpp def/def_npc.cpp def/def_npcgroupspawn.cpp - def/def_outposts.cpp def/defparser.cpp def/def_recycles.cpp def/def_respawn.cpp - def/def_shots.cpp def/def_skills.cpp def/def_subskills.cpp def/def_trader.cpp - def/def_vehicles.cpp def/def_vehiclesits.cpp def/def_weapons.cpp def/def_weather.cpp - def/def_worldfile.cpp def/def_worldmodels.cpp def/def_worlds.cpp def/gamedefs.cpp - def/world_datparser.cpp def/def_scripts.cpp - # gamecommands stuff - gamecommands/ban.cpp gamecommands/brightness.cpp gamecommands/broadcast.cpp - gamecommands/color.cpp gamecommands/debug.cpp gamecommands/effect.cpp - gamecommands/givemoney.cpp gamecommands/h.cpp gamecommands/info.cpp gamecommands/npc_shop.cpp - gamecommands/jail.cpp gamecommands/kick.cpp gamecommands/listbans.cpp gamecommands/online.cpp - gamecommands/rawf.cpp gamecommands/recall.cpp gamecommands/remove.cpp gamecommands/setlevel.cpp - gamecommands/settime.cpp gamecommands/setsubskill.cpp gamecommands/shun.cpp - gamecommands/setmainskill.cpp gamecommands/skin.cpp gamecommands/spawnactor.cpp - gamecommands/speed.cpp gamecommands/takemoney.cpp gamecommands/t.cpp gamecommands/teleport.cpp - gamecommands/test.cpp gamecommands/unban.cpp gamecommands/unjail.cpp gamecommands/unshun.cpp - gamecommands/uptime.cpp gamecommands/v.cpp gamecommands/version.cpp gamecommands/warp.cpp - gamecommands/warpto.cpp gamecommands/weather.cpp gamecommands/npc.cpp - # gameserver stuff - globals.cpp terminal_querydb.cpp multipart.cpp accounts.cpp appartements.cpp buddylist.cpp - chars.cpp chat.cpp client.cpp clientmanager.cpp commands.cpp container.cpp doortemplate.cpp - furnituretemplate.cpp gameserver.cpp genreplist.cpp inventory.cpp isc.cpp item.cpp main.cpp - lua_engine.cpp msgbuilder.cpp npc.cpp server.cpp skill.cpp sql.cpp subway.cpp terminal.cpp - terminal_receivedb.cpp terminal_tryaccess.cpp npc_conversation.cpp terminal_updatedb.cpp - vehicle.cpp vhcaccessrequest.cpp worldactors.cpp worlddatatemplate.cpp worlds.cpp zoning.cpp - outpost.cpp npc_ai.cpp npctemplate.cpp) - -TARGET_LINK_LIBRARIES (gameserver common ${MYSQL_LIBRARY} ${PCRE_LIBRARY} ${ZLIB_LIBRARY} ${RT_LIBRARY} - ${LUA53_LIBRARY}) diff --git a/server/src/game/decoder/main.h b/server/src/game/decoder/main.h deleted file mode 100644 index 0e6dd6b..0000000 --- a/server/src/game/decoder/main.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - main.h - main include file, contains all needed includes and important definitions - - MODIFIED: 30 Aug 2006 Hammag - REASON: - created - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#ifndef MAIN_H -#define MAIN_H - -//#include "version.h" - -//basic includes -#include "include/external.h" - -//tinns includes -#include "include/types.h" -#include "common/config.h" - -#include "common/console.h" -#include "common/misc.h" - -#include "common/netcode.h" - -#include "include/msgdecoder.h" -#include "udpanalyser.h" - - -/* -#include "../gamemonkey/gmMachine.h" -#include "../gamemonkey/gmCall.h" -*/ - -#include "common/filesystem.h" - -// MySQL Support // shouldn't be needed as DB-objects access class should do that -#ifdef MYSQL_INC_DIR -#include -#else -#include -#endif - -#include "include/sql.h" - -#include "include/skill.h" - -#include "include/chars.h" -#include "include/accounts.h" -#include "include/defs.h" -#include "include/client.h" -#include "include/server.h" -#include "include/gameserver.h" -#include "include/globals.h" -#include "include/zoning.h" -#include "include/item.h" -#include "include/inventory.h" - -#include "include/chat.h" -#include "include/commands.h" -#include "include/clientmanager.h" -#include "include/msgbuilder.h" -#include "include/worldactors.h" -#include "include/npc.h" -#include "include/outpost.h" -#include "include/multipart.h" -#include "include/terminal.h" - -#endif - diff --git a/server/src/game/decoder/msgdecoder.cpp b/server/src/game/decoder/msgdecoder.cpp deleted file mode 100644 index b684bd5..0000000 --- a/server/src/game/decoder/msgdecoder.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - - msgdecoder.cpp - top class for NC messages decoding - - CREATION: 23 Aug 2006 Hammag - - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "include/msgdecoder.h" -#include "udp_0x13.h" - - -// PUdpMsgDecoder - -/* - PMsgDecodeData mDecodeData; - PUdpMsgAnalyser* mCurrentAnalyser; -*/ - -void PUdpMsgDecoder::Init(PMessage* nMessage, PClient* nClient) -{ - mDecodeData.mMessage = nMessage; - mDecodeData.mClient = nClient; - mDecodeData.mState = (nMessage && nClient) ? DECODE_MORE : DECODE_UNDEF; - mDecodeData.mUnknownType = 0; - mDecodeData.mHandling0x13Sub = false; - mDecodeData.Sub0x13Start = mDecodeData.Sub0x13StartNext = 0; - mPacketName.erase(); - mDecodeData.mName.str(mPacketName); - mDecodeData.mErrorDetail.erase(); - mDecodeData.mTraceKnownMsg = false; - mDecodeData.mTraceUnknownMsg = false; - mDecodeData.mTraceDump = false; - if (mCurrentAnalyser) - { - delete mCurrentAnalyser; - mCurrentAnalyser = NULL; - } - -} - -PUdpMsgDecoder::PUdpMsgDecoder() -{ - mCurrentAnalyser = NULL; - Reset(); -} - -PUdpMsgDecoder::PUdpMsgDecoder(PMessage* nMessage, PClient* nClient) -{ - mCurrentAnalyser = NULL; - Init(nMessage, nClient); -} - -PUdpMsgDecoder::~PUdpMsgDecoder() -{ - if (mCurrentAnalyser) - { - delete mCurrentAnalyser; - } -} - -bool PUdpMsgDecoder::Analyse() -{ - PUdpMsgAnalyser* nextAnalyser; - - if ((mDecodeData.mState & DECODE_MORE) || mDecodeData.mHandling0x13Sub) - { - if (mCurrentAnalyser) - { - delete mCurrentAnalyser; - mCurrentAnalyser = NULL; - } - if (mDecodeData.mHandling0x13Sub) - { - mPacketName.erase(); - mDecodeData.mName.str(mPacketName); - mCurrentAnalyser = new PUdp0x13(&mDecodeData); - mDecodeData.mState = DECODE_MORE; - } - else - { - mCurrentAnalyser = new PUdpMsgAnalyser(&mDecodeData); - } - - while (mDecodeData.mState & DECODE_MORE) - { - nextAnalyser = mCurrentAnalyser->Analyse(); - if (mCurrentAnalyser != nextAnalyser) - { - delete mCurrentAnalyser; - mCurrentAnalyser = nextAnalyser; - } - } - } - return (!(mDecodeData.mState & (DECODE_MORE | DECODE_ERROR | DECODE_UNKNOWN))); -} - -bool PUdpMsgDecoder::Analyse(PMessage* nMessage, PClient* nClient) -{ - Init(nMessage, nClient); - return Analyse(); -} - -bool PUdpMsgDecoder::DoAction() -{ - if (mDecodeData.mState & DECODE_ACTION_READY) - { - return mCurrentAnalyser->DoAction(); - } - else - { - return false; - } -} diff --git a/server/src/game/decoder/udp_0x08.cpp b/server/src/game/decoder/udp_0x08.cpp deleted file mode 100644 index 3fd9982..0000000 --- a/server/src/game/decoder/udp_0x08.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - udp_0x08.cpp - decoder classes for UDP 0x08 messages - - CREATION: 05 Jan 2007 Namikon - - MODIFIED: - REASON: - -*/ - -#include "main.h" -#include "udp_0x08.h" - - -PUdp0x08::PUdp0x08(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData) -{ - nDecodeData->mName << "/0x08"; -} - -PUdpMsgAnalyser* PUdp0x08::Analyse() -{ - mDecodeData->mName << "=Client crash"; - mDecodeData->mState = DECODE_ACTION_READY | DECODE_FINISHED; - - return this; -} - -bool PUdp0x08::DoAction() -{ - // Client crashed, close connection from our side - GameServer->ClientDisconnected(mDecodeData->mClient); - mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED; - - return true; -} diff --git a/server/src/game/decoder/udp_0x08.h b/server/src/game/decoder/udp_0x08.h deleted file mode 100644 index 3f3b7ef..0000000 --- a/server/src/game/decoder/udp_0x08.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_0x08.h - decoder classes for UDP 0x08 messages - - CREATION: 05 Jan 2007 Namikon - - MODIFIED: - REASON: - -*/ - -#ifndef UDP0X08_H -#define UDP0X08_H - -class PUdp0x08 : public PUdpMsgAnalyser -{ - public: - PUdp0x08(PMsgDecodeData* nDecodeData); - //~PUdp0x08(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -#endif diff --git a/server/src/game/decoder/udp_0x13.h b/server/src/game/decoder/udp_0x13.h deleted file mode 100644 index 9dc4a21..0000000 --- a/server/src/game/decoder/udp_0x13.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_0x13.h - decoder classes for UDP 0x13 messages - - CREATION: 31 Aug 2006 Hammag - - MODIFIED: - REASON: - - -*/ - -#ifndef UDP0X13_H -#define UDP0X13_H - -class PUdp0x13 : public PUdpMsgAnalyser -{ - public: - PUdp0x13(PMsgDecodeData* nDecodeData); - //~PUdp0x13(); - PUdpMsgAnalyser* Analyse(); - //bool DoAction(); -}; - -#endif diff --git a/server/src/game/decoder/udp_0x1f.h b/server/src/game/decoder/udp_0x1f.h deleted file mode 100644 index 47debaa..0000000 --- a/server/src/game/decoder/udp_0x1f.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_udp0x1f.h - decoder classes for UDP 0x13x03x1f messages - - CREATION: 6 Sep 2006 Hammag - - MODIFIED: - REASON: - - -*/ - -#ifndef UDP0X1F_H -#define UDP0X1F_H - -class PUdp0x1f : public PUdpMsgAnalyser -{ - public: - PUdp0x1f(PMsgDecodeData* nDecodeData); - //~PUdp0x1f(); - PUdpMsgAnalyser* Analyse(); - //bool DoAction(); -}; - -#endif diff --git a/server/src/game/decoder/udp_0x22.cpp b/server/src/game/decoder/udp_0x22.cpp deleted file mode 100644 index aa80a4c..0000000 --- a/server/src/game/decoder/udp_0x22.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_udp0x22.cpp - decoder classes for UDP 0x13x03x22 messages - - CREATION: 6 Sep 2006 Hammag - - MODIFIED: - REASON: - - -*/ - -#include "main.h" -#include "udp_0x22.h" - -#include "udp_reqinfo.h" -#include "udp_zoning.h" -#include "udp_entityposreq.h" - -/**** PUdp0x22 ****/ - -PUdp0x22::PUdp0x22(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData) -{ - nDecodeData->mName << "/0x22"; -} - -PUdpMsgAnalyser* PUdp0x22::Analyse() -{ - PUdpMsgAnalyser* nextAnalyser = NULL; - mDecodeData->mState = DECODE_MORE; - u8 MsgType = mDecodeData->mMessage->U8Data(mDecodeData->Sub0x13Start + 5); - switch(MsgType) // MsgType is probably u16 rather than u8 - { - case 0x03: // Zoning phase 2 - { - nextAnalyser = new PUdpZoning2(mDecodeData); - break; - } - case 0x06: // Char/Clan/Rank/Map Info request - { - nextAnalyser = new PUdpReqInfo(mDecodeData); - break; - } - case 0x0b: // Entity position request - { - nextAnalyser = new PUdpEntityPosRequest(mDecodeData); - break; - } - case 0x0d: // Zoning phase 1 - { - nextAnalyser = new PUdpZoning1(mDecodeData); - break; - } - default: - { - mDecodeData->mUnknownType = MsgType; - break; - } - } - - if (! nextAnalyser) - { - nextAnalyser = new PUdpMsgUnknown(mDecodeData); - } - - return nextAnalyser; -} diff --git a/server/src/game/decoder/udp_0x22.h b/server/src/game/decoder/udp_0x22.h deleted file mode 100644 index 5d00741..0000000 --- a/server/src/game/decoder/udp_0x22.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_udp0x22.h - decoder classes for UDP 0x13x03x22 messages - - CREATION: 6 Sep 2006 Hammag - - MODIFIED: - REASON: - - -*/ - -#ifndef UDP0X22_H -#define UDP0X22_H - -class PUdp0x22 : public PUdpMsgAnalyser -{ - public: - PUdp0x22(PMsgDecodeData* nDecodeData); - //~PUdp0x22(); - PUdpMsgAnalyser* Analyse(); - //bool DoAction(); -}; - -#endif diff --git a/server/src/game/decoder/udp_0x2b.cpp b/server/src/game/decoder/udp_0x2b.cpp deleted file mode 100644 index c1b9b3d..0000000 --- a/server/src/game/decoder/udp_0x2b.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_udp0x2b.cpp - decoder classes for UDP 0x13x03x2b messages - - CREATION: 8 Jan 2007 Namikon - - MODIFIED: - REASON: - - -*/ - -#include "main.h" -#include "udp_0x2b.h" -#include "udp_terminal.h" - -/**** PUdp0x2b ****/ - -PUdp0x2b::PUdp0x2b(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData) -{ - nDecodeData->mName << "/0x2b"; -} - -PUdpMsgAnalyser* PUdp0x2b::Analyse() -{ - PUdpMsgAnalyser* nextAnalyser = NULL; - mDecodeData->mState = DECODE_MORE; - u8 MsgType = mDecodeData->mMessage->U8Data(mDecodeData->Sub0x13Start + 5); - switch(MsgType) - { - case 0x17: // ReceiveDB Terminal Command - { - nextAnalyser = new PUdpReceiveDB(mDecodeData); - break; - } - case 0x18: // UpdateDB Terminal Command - { - nextAnalyser = new PUdpUpdateDB(mDecodeData); - break; - } - case 0x19: // TryAccess Terminal Command - { - nextAnalyser = new PUdpTryAccessDB(mDecodeData); - break; - } - case 0x1b: // DB Query and Command - { - nextAnalyser = new PUdpQueryDB(mDecodeData); - break; - } - case 0x1f: // Citycom? - { - nextAnalyser = new PUdpTeminal0x1f(mDecodeData); - break; - } - - default: - { - mDecodeData->mUnknownType = MsgType; - break; - } - } - - if (! nextAnalyser) - { - nextAnalyser = new PUdpMsgUnknown(mDecodeData); - } - - return nextAnalyser; -} diff --git a/server/src/game/decoder/udp_0x2b.h b/server/src/game/decoder/udp_0x2b.h deleted file mode 100644 index a4d45f8..0000000 --- a/server/src/game/decoder/udp_0x2b.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_udp0x2b.h - decoder classes for UDP 0x13x03x2b messages - - CREATION: 8 Jan 2007 Namikon - - MODIFIED: - REASON: - - -*/ - -#ifndef UDP0X2B_H -#define UDP0X2B_H - -class PUdp0x2b : public PUdpMsgAnalyser -{ - public: - PUdp0x2b(PMsgDecodeData* nDecodeData); - //~PUdp0x2b(); - PUdpMsgAnalyser* Analyse(); - //bool DoAction(); -}; - -#endif diff --git a/server/src/game/decoder/udp_OOO.cpp b/server/src/game/decoder/udp_OOO.cpp deleted file mode 100644 index 25fb335..0000000 --- a/server/src/game/decoder/udp_OOO.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_OOO.cpp - decoder classe for UDP Out Of Order message - - CREATION: 5 Sep 2006 Hammag - - MODIFIED: - REASON: - - -*/ - -#include "main.h" -#include "udp_OOO.h" - -/**** PUdpOOO ****/ - -PUdpOOO::PUdpOOO(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData) -{ - nDecodeData->mName << "/0x01"; -} - -PUdpMsgAnalyser* PUdpOOO::Analyse() -{ - mDecodeData->mName << "=Out Of Order"; - mDecodeData->mState = DECODE_ACTION_READY | DECODE_FINISHED; - - return this; -} - -bool PUdpOOO::DoAction() -{ - u16 MissingUDP_ID = mDecodeData->mMessage->U16Data(mDecodeData->Sub0x13Start+5); - - mDecodeData->mClient->getUDPConn()->ReSendUDPMessage(MissingUDP_ID); - //Console->Print("%s Out of Order packet received ! (Client is missing UDPID %d) ***not managed yet***", Console->ColorText(YELLOW, BLACK, "[Notice]"), MissingUDP_ID); - - mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED; - return true; -} diff --git a/server/src/game/decoder/udp_OOO.h b/server/src/game/decoder/udp_OOO.h deleted file mode 100644 index 9dffb23..0000000 --- a/server/src/game/decoder/udp_OOO.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_OOO.h - decoder classe for UDP Out Of Order message - - CREATION: 5 Sep 2006 Hammag - - MODIFIED: - REASON: - - -*/ - -#ifndef UDPOOO_H -#define UDPOOO_H - -class PUdpOOO : public PUdpMsgAnalyser -{ - public: - PUdpOOO(PMsgDecodeData* nDecodeData); - //~PUdpPing(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -#endif diff --git a/server/src/game/decoder/udp_appartment.cpp b/server/src/game/decoder/udp_appartment.cpp deleted file mode 100644 index a80b6be..0000000 --- a/server/src/game/decoder/udp_appartment.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_appartment.cpp - decoder classes for Navray apt location request messages - - CREATION: 23 Dec 2006 Namikon - - MODIFIED: 13 may 2007 Hammag - REASON: corrected this header - -*/ - -#include "main.h" -#include "udp_appartment.h" - -/**** PUdpAptLocInfo ****/ - -PUdpAptLocInfo::PUdpAptLocInfo(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData) -{ - nDecodeData->mName << "/0x0a"; -} - -PUdpMsgAnalyser* PUdpAptLocInfo::Analyse() -{ - mDecodeData->mName << "=Requesting appartment location for NavRay"; - - mDecodeData->mState = DECODE_ACTION_READY | DECODE_FINISHED; - return this; -} - -bool PUdpAptLocInfo::DoAction() -{ -Console->Print("Got request for app data"); - PMessage* tmpMsg = MsgBuilder->BuildCharAptLocInfoMsg (mDecodeData->mClient); - - if (tmpMsg) - mDecodeData->mClient->SendUDPMessage(tmpMsg); - - mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED; - return true; -} diff --git a/server/src/game/decoder/udp_appartment.h b/server/src/game/decoder/udp_appartment.h deleted file mode 100644 index fd9bc2a..0000000 --- a/server/src/game/decoder/udp_appartment.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_appartment.h - decoder classes for Navray apt location request messages - - CREATION: 23 Dec 2006 Namikon - - MODIFIED: 13 may 2007 Hammag - REASON: corrected this header - -*/ - -#ifndef UDPAPPARTMENT_H -#define UDPAPPARTMENT_H - -class PUdpAptLocInfo : public PUdpMsgAnalyser -{ - public: - PUdpAptLocInfo(PMsgDecodeData* nDecodeData); - //~PUdpAptLocInfo(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -#endif diff --git a/server/src/game/decoder/udp_charmove.h b/server/src/game/decoder/udp_charmove.h deleted file mode 100644 index 9736fd8..0000000 --- a/server/src/game/decoder/udp_charmove.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_charmove.h - decoder classes for UDP char movement messages - - CREATION: 5 Sep 2006 Hammag - - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - -#ifndef UDPCHARMOVE_H -#define UDPCHARMOVE_H - -#include "include/msgdecoder.h" -#include "udpanalyser.h" - -class PUdpCharPosUpdate : public PUdpMsgAnalyser -{ - private: - u8 mInfoBitfield; - u16 mNewY; - u16 mNewZ; - u16 mNewX; - u8 mNewUD; - u8 mNewLR; - u8 mNewAct; - u8 mNewUnknown; - u32 mChairItemID; // u16 or u32 ??? - u8 mChairItemSeat; - - public: - PUdpCharPosUpdate(PMsgDecodeData* nDecodeData); - //~PUdpCharMoves(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -class PUdpCharExitChair : public PUdpMsgAnalyser -{ - public: - PUdpCharExitChair(PMsgDecodeData* nDecodeData); - //~PUdpCharExitChair(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); - - //nClient is optionnal, nVhc is to limit to that vhc, nForce to force exit event when cab door closed - static bool DoLeaveChair(PChar* nChar, PClient* nClient = NULL, PSpawnedVehicle* nVhc = NULL, bool nForce = false); -}; - -class PUdpCharJump : public PUdpMsgAnalyser -{ - public: - PUdpCharJump(PMsgDecodeData* nDecodeData); - //~PUdpCharJump(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -class PUdpCharTargeting : public PUdpMsgAnalyser -{ - public: - PUdpCharTargeting(PMsgDecodeData* nDecodeData); - //~PUdpCharTargeting(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; -#endif diff --git a/server/src/game/decoder/udp_chat.h b/server/src/game/decoder/udp_chat.h deleted file mode 100644 index 8ccd966..0000000 --- a/server/src/game/decoder/udp_chat.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_chat.h - decoder classes for UDP chat messages - - CREATION: 15 Sep 2006 Hammag - - MODIFIED: 11 Dec 2006 Hammag - REASON: - added PUdpChatChannels - -*/ - -#ifndef UDPCHAT_H -#define UDPCHAT_H - -class PUdpChatLocal : public PUdpMsgAnalyser -{ - public: - PUdpChatLocal(PMsgDecodeData* nDecodeData); - //~PUdpChatLocal(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -class PUdpChatGlobal : public PUdpMsgAnalyser -{ - private: - - public: - PUdpChatGlobal(PMsgDecodeData* nDecodeData); - //~PUdpChatGlobal(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -class PUdpChatListAdd : public PUdpMsgAnalyser -{ - private: - u8 mChatList; // 1 = Direct, 2 = Buddy List - char* mAddedCharname; - - public: - PUdpChatListAdd(PMsgDecodeData* nDecodeData); - //~PUdpChatListAdd(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -class PUdpChatListRemove : public PUdpMsgAnalyser -{ - private: - u8 mChatList; - u32 mRemovedCharID; - - public: - PUdpChatListRemove(PMsgDecodeData* nDecodeData); - //~PUdpChatListRemove(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -class PUdpChatChannels : public PUdpMsgAnalyser -{ - private: - u32 mChannelFlags; // 1 bit per custom channel, starting from LSB, in same order as in chat i/f - - public: - PUdpChatChannels(PMsgDecodeData* nDecodeData); - //~PUdpChatChannels(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -#endif diff --git a/server/src/game/decoder/udp_deathrespawn.h b/server/src/game/decoder/udp_deathrespawn.h deleted file mode 100644 index 358564e..0000000 --- a/server/src/game/decoder/udp_deathrespawn.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_deathrespawn.h - decoder classes for UDP respawn selection after death message - - CREATION: 10 May 2009 Hammag - - MODIFIED: - REASON: - - -*/ - -#ifndef UDPDEATHRESPAWN_H -#define UDPDEATHRESPAWN_H - -class PUdpDeathRespawn : public PUdpMsgAnalyser -{ - private: - u32 mEntity; - u32 mWorldId; - - public: - PUdpDeathRespawn( PMsgDecodeData* nDecodeData ); - //~PUdpDeathRespawn(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -#endif diff --git a/server/src/game/decoder/udp_entityposreq.h b/server/src/game/decoder/udp_entityposreq.h deleted file mode 100644 index f4f37bc..0000000 --- a/server/src/game/decoder/udp_entityposreq.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_entityposreq.h - decoder classes for UDP entity position request messages - - CREATION: 8 jun 2007 Hammag - - MODIFIED: - REASON: - - -*/ - -#ifndef UDPENTITYPOS_H -#define UDPENTITYPOS_H - -class PUdpEntityPosRequest : public PUdpMsgAnalyser -{ - private: - u16 mEntityID; // u16 or u32 ??? - - - public: - PUdpEntityPosRequest(PMsgDecodeData* nDecodeData); - //~PUdpEntityPosRequest(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -#endif diff --git a/server/src/game/decoder/udp_hack.h b/server/src/game/decoder/udp_hack.h deleted file mode 100644 index ffcb9fe..0000000 --- a/server/src/game/decoder/udp_hack.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_hack.h - decoder classes for UDP hacking related messages - - CREATION: 30 Dec 2006 Namikon - - MODIFIED: - REASON: - - -*/ - -#ifndef UDPHACK_H -#define UDPHACK_H - -class PUdpHackFail : public PUdpMsgAnalyser -{ - public: - PUdpHackFail( PMsgDecodeData* nDecodeData ); - //~PUdpHackFail(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -class PUdpHackSuccess : public PUdpMsgAnalyser -{ - public: - PUdpHackSuccess( PMsgDecodeData* nDecodeData ); - //~PUdpHackSuccess(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -#endif diff --git a/server/src/game/decoder/udp_helditemaction.h b/server/src/game/decoder/udp_helditemaction.h deleted file mode 100644 index 9645821..0000000 --- a/server/src/game/decoder/udp_helditemaction.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_helditemaction.h - decoder classes for held item related messages - - CREATION: 20 Mar 2009 Hammag - - MODIFIED: - REASON: - - -*/ - -#ifndef HELDITEMACTION_H -#define HELDITEMACTION_H - -class PUdpHeldItemBasicAction : public PUdpMsgAnalyser -{ - public: - PUdpHeldItemBasicAction( PMsgDecodeData* nDecodeData ); - //~PUdpHeldItemBasicAction(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -class PUdpHeldItemAimedAction : public PUdpMsgAnalyser -{ - - private: - u16 mWeaponId; - u32 mTargetRawItemID; - u8 mAiming; // 0: minimal - u8 mTargetedHeight; // 0: bottom to 26: top - u8 mScore; // ??? looks quite random... - - public: - PUdpHeldItemAimedAction( PMsgDecodeData* nDecodeData ); - //~PUdpHeldItemAimedAction(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -class PUdpHeldItemLaunchingAction : public PUdpMsgAnalyser -{ - private: - u16 mWeaponId; - u16 mSourceY; - u16 mSourceZ; - u16 mSourceX; - u8 mSourceUD; - u8 mSourceLR; - u16 mUnknown1; - u32 mUnknown2; // client timestamp ? => TODO: compare with data from ping request - u32 mTargetRawItemID; - - public: - PUdpHeldItemLaunchingAction( PMsgDecodeData* nDecodeData ); - //~PUdpHeldItemLaunchingAction(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - - -class PUdpItemAddonActivation : public PUdpMsgAnalyser -{ - private: - u8 mAddonIdx; - - public: - PUdpItemAddonActivation( PMsgDecodeData* nDecodeData ); - //~PUdpItemAddonActivation(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; -#endif diff --git a/server/src/game/decoder/udp_itemmanualreload.h b/server/src/game/decoder/udp_itemmanualreload.h deleted file mode 100644 index 2b296e9..0000000 --- a/server/src/game/decoder/udp_itemmanualreload.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - -udp_itemmanualreload.h - decoder classes for UDP item manual reload messages - - CREATION: 9 May 2009 Hammag - - MODIFIED: - REASON: - - -*/ - -#ifndef MANUALITEMRELOAD_H -#define MANUALITEMRELOAD_H - -class PUdpItemManualReload : public PUdpMsgAnalyser -{ - private: - u8 mUnknown; - u8 GetMaxLoadableAmmos( u8 nBeltSlotId ); - - public: - PUdpItemManualReload(PMsgDecodeData* nDecodeData); - //~PUdpItemManualReload(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -class PUdpReloadAnimStart : public PUdpMsgAnalyser -{ - public: - PUdpReloadAnimStart( PMsgDecodeData* nDecodeData ); - //~PUdpReloadAnimStart(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -#endif diff --git a/server/src/game/decoder/udp_itemmove.h b/server/src/game/decoder/udp_itemmove.h deleted file mode 100644 index 334d6c7..0000000 --- a/server/src/game/decoder/udp_itemmove.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_itemmove.h - decoder classes for UDP item move related messages - - CREATION: 30 Dec 2006 Namikon - - MODIFIED: - REASON: - - -*/ - -#ifndef UDPITEMMOVE_H -#define UDPITEMMOVE_H - -class PUdpItemMove : public PUdpMsgAnalyser -{ - private: - u8 mSrcLoc; - u8 mSrcX; - u8 mSrcY; - u8 mDstLoc; - u8 mDstX; - u8 mDstY; - u8 mItemCnt; - - public: - PUdpItemMove(PMsgDecodeData* nDecodeData); - //~PUdpItemMove(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); - - static PContainer* GetContainerByLoc(PChar* nChar, u8 nLoc); -}; - -class PUdpItemMoveBP : public PUdpMsgAnalyser -{ - private: - u8 mSrcSlotId; - u8 mDumb; - u8 mDstX; - u8 mDstY; - - public: - PUdpItemMoveBP(PMsgDecodeData* nDecodeData); - //~PUdpItemMove(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -class PUdpItemDropOnItem : public PUdpMsgAnalyser -{ - private: - u8 mSrcLoc; - u8 mSrcX; - u8 mSrcY; - u8 mDstLoc; - u8 mDstX; - u8 mDstY; - - public: - PUdpItemDropOnItem(PMsgDecodeData* nDecodeData); - //~PUdpItemDropOnItem(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -#endif diff --git a/server/src/game/decoder/udp_itemuse.h b/server/src/game/decoder/udp_itemuse.h deleted file mode 100644 index 9b2d7e0..0000000 --- a/server/src/game/decoder/udp_itemuse.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_itemuse.h - decoder classes for UDP inventory item use messages - - CREATION: 9 May 2009 Hammag - - MODIFIED: - REASON: - - -*/ - -#ifndef ITEMUSE_H -#define ITEMUSE_H - -class PUdpItemUse : public PUdpMsgAnalyser -{ -/* private: - u16 mWeaponId; - u32 mTargetRawItemID; - u8 mUnknown2; - u8 mTargetedHeight; - u8 mScore; // ??? looks quite random... -*/ - public: - PUdpItemUse( PMsgDecodeData* nDecodeData ); - //~PUdpItemUse(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -#endif diff --git a/server/src/game/decoder/udp_killself.cpp b/server/src/game/decoder/udp_killself.cpp deleted file mode 100644 index 441b53d..0000000 --- a/server/src/game/decoder/udp_killself.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_killself.cpp - decoder classe for UDP /set kill_self 1 messages - - CREATION: 13 Apr 2009 Hammag - -*/ - - -#include "main.h" -#include "udp_killself.h" - -PUdpKillSelf::PUdpKillSelf( PMsgDecodeData* nDecodeData ) : PUdpMsgAnalyser( nDecodeData ) -{ - nDecodeData->mName << "/0x10"; -} - -PUdpMsgAnalyser* PUdpKillSelf::Analyse() -{ - mDecodeData->mName << "=Char Kill self"; - - mDecodeData->mState = DECODE_ACTION_READY | DECODE_FINISHED; - return this; -} - -bool PUdpKillSelf::DoAction() -{ - PClient* nClient = mDecodeData->mClient; - - PMessage* tmpMsg = MsgBuilder->BuildCharDeathMsg( nClient, 0 ); - ClientManager->UDPBroadcast( tmpMsg, nClient ); - - mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED; - return true; - - /* Server resp: - 13:a8:00:a8:e2: - 16: 03:a5:00:1b:01:10:00:80:24:ea:7c:cb:80:25:77:80:86:80:62:00:01:00: // Spwan belt object (?) - 09: 03:a6:00:1f:01:00:25:23:1c: // "UndefinedUseMsg" with arg 0x1c - 0b: 03:a7:00:1f:01:00:16:00:00:00:00: // Char Dead status - 0e: 03:a8:00:1f:01:00:25:13:10:19:02:02:0d:00 // Inventory delete item (=item dropped to belt) - */ -} diff --git a/server/src/game/decoder/udp_killself.h b/server/src/game/decoder/udp_killself.h deleted file mode 100644 index 19ddf47..0000000 --- a/server/src/game/decoder/udp_killself.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_killself.h - decoder classe for UDP /set kill_self 1 messages - - CREATION: 13 Apr 2009 Hammag - -*/ - -#ifndef UDPKILLSELF_H -#define UDPKILLSELF_H - -class PUdpKillSelf : public PUdpMsgAnalyser -{ - public: - PUdpKillSelf(PMsgDecodeData* nDecodeData); - //~PUdpKillSelf(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -#endif diff --git a/server/src/game/decoder/udp_multipart.h b/server/src/game/decoder/udp_multipart.h deleted file mode 100644 index e338158..0000000 --- a/server/src/game/decoder/udp_multipart.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_multipart.h - decoder classes for UDP multipart messages (0x07) - - CREATION: 25 Oct 2009 Namikon - - MODIFIED: - REASON: - - -*/ - -#ifndef UDPMULTIPART_H -#define UDPMULTIPART_H - -class PUdpMultiPart : public PUdpMsgAnalyser -{ - private: - u16 mChunkNr; - u16 mChunkTotal; - u8 mSequence; - PMessage* mChunk; - - public: - PUdpMultiPart( PMsgDecodeData* nDecodeData ); - //~PUdpPing(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -#endif diff --git a/server/src/game/decoder/udp_npcdialog.h b/server/src/game/decoder/udp_npcdialog.h deleted file mode 100644 index 5638b84..0000000 --- a/server/src/game/decoder/udp_npcdialog.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_npcdialog.h - decoder classes for UDP NPC Dialog-Messages - - CREATION: 13 Oct 2009 Namikon - - MODIFIED: - REASON: - - -*/ - -#ifndef UDPNPCDIALOG_H -#define UDPNPCDIALOG_H - -class PUdpNPCDialogClose : public PUdpMsgAnalyser -{ - private: - u16 mPlayerID; - u32 mNPCID; - - public: - PUdpNPCDialogClose( PMsgDecodeData* nDecodeData ); - //~PUdpNPCDialogClose(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -class PUdpNPCDialogAction : public PUdpMsgAnalyser -{ - private: - u16 mPlayerID; - u8 mAnswerNr; - - public: - PUdpNPCDialogAction( PMsgDecodeData* nDecodeData ); - //~PUdpNPCDialogAction(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -#endif diff --git a/server/src/game/decoder/udp_outfitter.cpp b/server/src/game/decoder/udp_outfitter.cpp deleted file mode 100644 index c414e49..0000000 --- a/server/src/game/decoder/udp_outfitter.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_outfitter.cpp - decoder classes for UDP outfitter related messages - - CREATION: 20 Mar 2009 Hammag - - MODIFIED: - REASON: - - -*/ - -#include "main.h" -#include "udp_outfitter.h" - - -/**** PUdpOutfitter ****/ - -PUdpOutfitter::PUdpOutfitter(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData) -{ - nDecodeData->mName << "/0x2e"; -} - -PUdpMsgAnalyser* PUdpOutfitter::Analyse() -{ - mDecodeData->mName << "=Outfitter validation"; - - u16 tUnknown; - PMessage* nMsg = mDecodeData->mMessage; - nMsg->SetNextByteOffset(mDecodeData->Sub0x13Start + 8); - - (*nMsg) >> mSkin; - (*nMsg) >> tUnknown; - (*nMsg) >> mHead; - (*nMsg) >> mTorso; - (*nMsg) >> mLegs; - (*nMsg) >> mHeadColor; - (*nMsg) >> mTorsoColor; - (*nMsg) >> mLegsColor; - (*nMsg) >> mHeadDarkness; - (*nMsg) >> mTorsoDarkness; - (*nMsg) >> mLegsDarkness; - - mDecodeData->mState = DECODE_ACTION_READY | DECODE_FINISHED; - return this; -} - -bool PUdpOutfitter::DoAction() -{ - PClient* nClient = mDecodeData->mClient; - PChar* tChar = nClient->GetChar(); - - /* Some validity checks against char model and equipment can be done here */ - /* as well as payment */ - - tChar->SetCurrentLook(mSkin, mHead, mTorso, mLegs); - tChar->SetCurrentBodyColor(mHeadColor, mTorsoColor, mLegsColor, mHeadDarkness, mTorsoDarkness, mLegsDarkness); - - PMessage* tmpMsg = MsgBuilder->BuildCharHelloMsg(nClient); - ClientManager->UDPBroadcast(tmpMsg, nClient); - - - mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED; - return true; -} \ No newline at end of file diff --git a/server/src/game/decoder/udp_outfitter.h b/server/src/game/decoder/udp_outfitter.h deleted file mode 100644 index b6c72e2..0000000 --- a/server/src/game/decoder/udp_outfitter.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_outfitter.h - decoder classes for UDP outfitter related messages - - CREATION: 20 Mar 2009 Hammag - - MODIFIED: - REASON: - - -*/ - -#ifndef UDPOUTFITTER_H -#define UDPOUTFITTER_H - -class PUdpOutfitter : public PUdpMsgAnalyser -{ - private: - u32 mSkin; - u8 mHead; - u8 mTorso; - u8 mLegs; - u8 mHeadColor; - u8 mTorsoColor; - u8 mLegsColor; - u8 mHeadDarkness; - u8 mTorsoDarkness; - u8 mLegsDarkness; - - public: - PUdpOutfitter(PMsgDecodeData* nDecodeData); - //~PUdpOutfitter(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -#endif diff --git a/server/src/game/decoder/udp_packet0.cpp b/server/src/game/decoder/udp_packet0.cpp deleted file mode 100644 index f8c3b76..0000000 --- a/server/src/game/decoder/udp_packet0.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_packet0.h - decoder classes for UDP "Packet0" messages - - CREATION: 31 Aug 2006 Hammag - - MODIFIED: - REASON: - - -*/ - -#include "main.h" -#include "udp_packet0.h" - -/**** PUdpPacket0 ****/ - -PUdpPacket0::PUdpPacket0(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData) -{ - nDecodeData->mName << "/0x2a"; -//nDecodeData->mTraceDump=true; -//mDecodeData->mTraceKnownMsg = true; -} - -PUdpMsgAnalyser* PUdpPacket0::Analyse() -{ - mDecodeData->mName << "=Packet0"; - mDecodeData->mState = DECODE_ACTION_READY | DECODE_FINISHED; - - return this; -} - -bool PUdpPacket0::DoAction() -{ - if (mDecodeData->mState & DECODE_ACTION_READY) - { - PMessage* tmpMsg = MsgBuilder->BuildPacket0Msg(mDecodeData->mClient); - mDecodeData->mClient->SendUDPMessage(tmpMsg); - - //mDecodeData->mMessage->SetNextByteOffset(mDecodeData->Sub0x13StartNext); - mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED; - return true; - } - else - return false; -} diff --git a/server/src/game/decoder/udp_packet0.h b/server/src/game/decoder/udp_packet0.h deleted file mode 100644 index cde160f..0000000 --- a/server/src/game/decoder/udp_packet0.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_packet0.h - decoder classes for UDP "Packet0" messages - - CREATION: 31 Aug 2006 Hammag - - MODIFIED: - REASON: - - -*/ - -#ifndef UDPPACKET0_H -#define UDPPACKET0_H - -class PUdpPacket0 : public PUdpMsgAnalyser -{ - public: - PUdpPacket0(PMsgDecodeData* nDecodeData); - //~PUdpPacket0(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -#endif diff --git a/server/src/game/decoder/udp_ping.cpp b/server/src/game/decoder/udp_ping.cpp deleted file mode 100644 index 7258bf0..0000000 --- a/server/src/game/decoder/udp_ping.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_ping.cpp - decoder classes for UDP Ping messages - - CREATION: 31 Aug 2006 Hammag - - MODIFIED: - REASON: - - -*/ - -#include "main.h" -#include "udp_ping.h" - -/**** PUdpPing ****/ - -PUdpPing::PUdpPing( PMsgDecodeData* nDecodeData ) : PUdpMsgAnalyser( nDecodeData ) -{ - nDecodeData->mName << "/0x0b"; -} - -PUdpMsgAnalyser* PUdpPing::Analyse() -{ - mDecodeData->mName << "=Ping"; - - mClientTime = mDecodeData->mMessage->U32Data( mDecodeData->Sub0x13Start + 2 ); - - mDecodeData->mState = DECODE_ACTION_READY | DECODE_FINISHED; - return this; -} - -bool PUdpPing::DoAction() -{ - if ( mDecodeData->mState & DECODE_ACTION_READY ) - { - // if(gDevDebug) - // Console->Print( "%s PUdpPing: Client timestamp %d (0x%08x)", Console->ColorText( CYAN, BLACK, "[DEBUG]" ), mClientTime, mClientTime ); - - PMessage* tmpMsg = MsgBuilder->BuildPingMsg( mDecodeData->mClient, mClientTime ); - mDecodeData->mClient->SendUDPMessage( tmpMsg ); - - mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED; - return true; - } - else - return false; -} diff --git a/server/src/game/decoder/udp_ping.h b/server/src/game/decoder/udp_ping.h deleted file mode 100644 index 88299b2..0000000 --- a/server/src/game/decoder/udp_ping.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_ping.h - decoder classes for UDP Ping messages - - CREATION: 31 Aug 2006 Hammag - - MODIFIED: - REASON: - - -*/ - -#ifndef UDPPING_H -#define UDPPING_H - -class PUdpPing : public PUdpMsgAnalyser -{ - private: - u32 mClientTime; - - public: - PUdpPing( PMsgDecodeData* nDecodeData ); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -#endif diff --git a/server/src/game/decoder/udp_popupresponse.h b/server/src/game/decoder/udp_popupresponse.h deleted file mode 100644 index a6106b8..0000000 --- a/server/src/game/decoder/udp_popupresponse.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_popupresponse.cpp - decoder classes for some UDP Popup response messages - - CREATION: 14 Apr 2009 Hammag -*/ - - -#ifndef UDPPOPUPRESP_H -#define UDPPOPUPRESP_H - -class PUdpPopupResponse : public PUdpMsgAnalyser -{ - public: - PUdpPopupResponse( PMsgDecodeData* nDecodeData ); - //~PUdpPopupResponse(); - PUdpMsgAnalyser* Analyse(); - //bool DoAction(); -}; - -class PUdpVentureWarpConfirm : public PUdpMsgAnalyser -{ - private: - u32 mRawItemId; - u16 mStatus; - u32 mUnknown1; - u16 mUnknown2; - public: - PUdpVentureWarpConfirm( PMsgDecodeData* nDecodeData ); - //~PUdpVentureWarpConfirm(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -class PUdpVhcAccessResponse : public PUdpMsgAnalyser -{ - private: - u32 mVhcAccessRequestId; - u16 mStatus; - u16 mUnknown; - public: - PUdpVhcAccessResponse( PMsgDecodeData* nDecodeData ); - //~PUdpVhcAccessResponse(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -#endif diff --git a/server/src/game/decoder/udp_pvptrade.cpp b/server/src/game/decoder/udp_pvptrade.cpp deleted file mode 100644 index bbb3554..0000000 --- a/server/src/game/decoder/udp_pvptrade.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_pvptrade.cpp - decoder classes for UDP "Request for more information about WorldID xx" - - CREATION: 20 Jun 2009 Namikon - - MODIFIED: 4 Jul 2009 Hammag - REASON: Corrected class name - -*/ - -#include "main.h" -#include "udp_pvptrade.h" - -/**** PPvPTrade ****/ - -PUdpPvPTrade::PUdpPvPTrade(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData) -{ - nDecodeData->mName << "/0x3e"; -} - -PUdpMsgAnalyser* PUdpPvPTrade::Analyse() -{ - mDecodeData->mName << "=Switch PvP Trading"; - - mDecodeData->mState = DECODE_ACTION_READY | DECODE_FINISHED; - return this; -} - -bool PUdpPvPTrade::DoAction() -{ - // TODO: Handle client PvP trade switch on/off - mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED; - return true; -} diff --git a/server/src/game/decoder/udp_pvptrade.h b/server/src/game/decoder/udp_pvptrade.h deleted file mode 100644 index 27f7afa..0000000 --- a/server/src/game/decoder/udp_pvptrade.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_pvptrade.h - decoder classes for UDP "Request for more information about WorldID xx" - - CREATION: 20 Jun 2009 Namikon - - MODIFIED: 4 Jul 2009 Hammag - REASON: Corrected class name - -*/ - -#ifndef UDPPVPTRADE_H -#define UDPPVPTRADE_H - -class PUdpPvPTrade : public PUdpMsgAnalyser -{ -public: - PUdpPvPTrade(PMsgDecodeData* nDecodeData); - //~PUdpPvPTrade(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -#endif diff --git a/server/src/game/decoder/udp_quickaccessbelt.h b/server/src/game/decoder/udp_quickaccessbelt.h deleted file mode 100644 index 3a79c5f..0000000 --- a/server/src/game/decoder/udp_quickaccessbelt.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_quickaccessbelt.h - decoder classes for UDP Quickaccessbelt related messages - - CREATION: 30 Dec 2006 Namikon - - MODIFIED: - REASON: - - -*/ - -#ifndef UDPITEMSLOT_H -#define UDPITEMSLOT_H - -class PUdpItemSlotUse : public PUdpMsgAnalyser -{ - private: - u8 mTargetSlot; - - public: - PUdpItemSlotUse(PMsgDecodeData* nDecodeData); - //~PUdpItemSlotUse(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -#endif diff --git a/server/src/game/decoder/udp_reqinfo.h b/server/src/game/decoder/udp_reqinfo.h deleted file mode 100644 index 9c02e27..0000000 --- a/server/src/game/decoder/udp_reqinfo.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_reqinfo.h - decoder classes for UDP Char info request messages - - CREATION: 6 Sep 2006 Hammag - - MODIFIED: - REASON: - - -*/ - -#ifndef UDPREQINFO_H -#define UDPREQINFO_H - -class PUdpReqInfo : public PUdpMsgAnalyser -{ - private: - u16 mRequestType; - u32 mInfoId; - - public: - PUdpReqInfo(PMsgDecodeData* nDecodeData); - //~PUdpCharInfo(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -#endif diff --git a/server/src/game/decoder/udp_subskill.h b/server/src/game/decoder/udp_subskill.h deleted file mode 100644 index 8720ce1..0000000 --- a/server/src/game/decoder/udp_subskill.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_subskill.h - decoder classes for UDP subskill increasing messages - - CREATION: 15 Sep 2006 Hammag - - MODIFIED: - REASON: - - -*/ - -#ifndef UDPSUBSKILL_H -#define UDPSUBSKILL_H - -class PUdpSubskillInc : public PUdpMsgAnalyser -{ - private: - u16 SubskillID; - - public: - PUdpSubskillInc(PMsgDecodeData* nDecodeData); - //~PUdpSubskillInc(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -#endif diff --git a/server/src/game/decoder/udp_sync.h b/server/src/game/decoder/udp_sync.h deleted file mode 100644 index 3326de8..0000000 --- a/server/src/game/decoder/udp_sync.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_sync.h - decoder classes for UDP Sync messages - - CREATION: 30 Aug 2006 Hammag - - MODIFIED: - REASON: - - -*/ - -#ifndef UDPSYNC_H -#define UDPSYNC_H - -class PUdpSync0 : public PUdpMsgAnalyser -{ - public: - PUdpSync0( PMsgDecodeData* nDecodeData ); - //~PUdpSync0(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); - - static void GetToSync1( PMsgDecodeData* nDecodeData ); -}; - -class PUdpSync1 : public PUdpMsgAnalyser -{ - public: - PUdpSync1( PMsgDecodeData* nDecodeData ); - //~PUdpSync1(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -class PUdpSync2 : public PUdpMsgAnalyser -{ - private: - u32 mClientTime; - - public: - PUdpSync2( PMsgDecodeData* nDecodeData ); - //~PUdpSync2(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -#endif diff --git a/server/src/game/decoder/udp_terminal.h b/server/src/game/decoder/udp_terminal.h deleted file mode 100644 index 3d4870b..0000000 --- a/server/src/game/decoder/udp_terminal.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_terminal.h - decoder classes for UDP terminal related messages - - CREATION: 8 Jan 2007 Namikon - - MODIFIED: - REASON: - - -*/ - -#ifndef UDPTERMINAL_H -#define UDPTERMINAL_H - - - -class PUdpReceiveDB : public PUdpMsgAnalyser -{ - private: - static const u8 mMaxOptions = 9; // Largest: forum\forenlist.tsc(21, 114,...) - u16 mTerminalSessionId; - std::string mCommandName; - std::string mOptions[mMaxOptions]; - u8 mOptionsCount; - - u16 mUnknown1; - u8 mUnknown2; - u16 mDBId; - - bool ActionVehicleListing(); - bool ActionVehicleControl(); - - public: - PUdpReceiveDB(PMsgDecodeData* nDecodeData); - //~PUdpReceiveDB(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -class PUdpUpdateDB : public PUdpMsgAnalyser -{ - private: - static const u8 mMaxOptions = 7; // Largest: forum\bbcnewthread.tsc(66): - u16 mTerminalSessionId; - std::string mCommandName; - std::string mOptions[mMaxOptions]; - u8 mOptionsCount; - - u16 mUnknown1; - u8 mUnknown2; - u16 mDBId; - - public: - PUdpUpdateDB(PMsgDecodeData* nDecodeData); - //~PUdpUpdateDB(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -class PUdpTryAccessDB : public PUdpMsgAnalyser -{ - private: - static const u8 mMaxOptions = 9; // Largest: stockx\depot.tsc(227): - u16 mTerminalSessionId; - std::string mCommandName; - std::string mOptions[mMaxOptions]; - u8 mOptionsCount; - - u16 mUnknown1; - u8 mUnknown2; - u16 mDBId; - - public: - PUdpTryAccessDB(PMsgDecodeData* nDecodeData); - //~PUdpTryAccessDB(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -class PUdpQueryDB : public PUdpMsgAnalyser // Also called "ServerMessage" in .tsc scripts! -{ - private: - static const u8 mMaxOptions = 5; // Largest: politics\transcomment.tsc(36): - u16 mTerminalSessionId; - u16 mDBId; - std::string mDBCommandName; - std::string mCommandName; - std::string mOptions[mMaxOptions]; - u8 mOptionsCount; - - bool ActionSpawnVehicle(); - bool ActionRepairVehicle(); - bool ActionDismissVehicle(); - - public: - PUdpQueryDB(PMsgDecodeData* nDecodeData); - //~PUdpQueryDB(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -class PUdpTeminal0x1f : public PUdpMsgAnalyser -{ - private: - u16 mTerminalSessionId; - - public: - PUdpTeminal0x1f(PMsgDecodeData* nDecodeData); - //~PUdpTeminal0x1f(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - - -#endif diff --git a/server/src/game/decoder/udp_useobject.h b/server/src/game/decoder/udp_useobject.h deleted file mode 100644 index f87a2b0..0000000 --- a/server/src/game/decoder/udp_useobject.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_useobject.h - decoder classes for object use related messages - - CREATION: 17 Sep 2006 Hammag - - MODIFIED: - REASON: - - -*/ - -#ifndef UDPUSEOBJECT_H -#define UDPUSEOBJECT_H - -class PUdpUseObject : public PUdpMsgAnalyser -{ - private: - u32 mRawItemID; - - void OldHandler(); // Temp during migration only - - public: - PUdpUseObject(PMsgDecodeData* nDecodeData); - //~PUdpUseObject(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -class PUdpCloseItemContainer : public PUdpMsgAnalyser -{ - private: - - public: - PUdpCloseItemContainer(PMsgDecodeData* nDecodeData); - //~PUdpCloseItemContainer(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; -#endif diff --git a/server/src/game/decoder/udp_vhc.h b/server/src/game/decoder/udp_vhc.h deleted file mode 100644 index bca7a2b..0000000 --- a/server/src/game/decoder/udp_vhc.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_vhc.h - decoder classes for UDP vehicle related messages - - CREATION: 5 Sep 2006 Hammag - - MODIFIED: - REASON: - - -*/ - -#ifndef UDPVHC_H -#define UDPVHC_H - -class PSpawnedVehicle; -class PVhcCoordinates; - -class PUdpVhcMove : public PUdpMsgAnalyser -{ - private: - u16 mVhcLocalId; - u16 mNewY; - u16 mNewZ; - u16 mNewX; - u16 mNewLR; - u16 mNewRoll; - u16 mUnk1; // always 0x0001 ? - u8 mMoveType; - u8 mNewUD; - u8 mFF; // always 0xff ? - u8 mAction; // &1 = Left, &2 = Right, &4 = Forward, &8 = Backward - public: - PUdpVhcMove( PMsgDecodeData* nDecodeData ); - //~PUdpVhcMove(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); - bool DoVhcZoning( PSpawnedVehicle* currVhc, u32 currWorldId, u32 destWorldId, PVhcCoordinates* destPos ); -}; - -class PUdpVhcUse : public PUdpMsgAnalyser -{ - private: - u32 mVehicleID; - u8 mVehicleSeat; - - public: - PUdpVhcUse( PMsgDecodeData* nDecodeData ); - //~PUdpVhcUse(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); - static void DoFreeSitting(PClient* nClient, PSpawnedVehicle* nVhc, u32 nRawVhcLocalId, u8 nSeatId = 254); -}; - -class PUdpSubwayUpdate : public PUdpMsgAnalyser -{ - private: - u32 mVehicleID; - u16 mPosition; - u8 mDoorOpened; - - public: - PUdpSubwayUpdate( PMsgDecodeData* nDecodeData ); - //~PUdpSubwayUpdate(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -class PUdpRequestVhcInfo : public PUdpMsgAnalyser -{ - private: - u32 mVehicleID; - - public: - PUdpRequestVhcInfo( PMsgDecodeData* nDecodeData ); - //~PUdpRequestVhcInfo(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -#endif diff --git a/server/src/game/decoder/udp_worldIDinfo.h b/server/src/game/decoder/udp_worldIDinfo.h deleted file mode 100644 index 8d60d3e..0000000 --- a/server/src/game/decoder/udp_worldIDinfo.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_worldIDinfo.h - decoder classes for UDP "Request for more information about WorldID xx" - - CREATION: 20 Jun 2009 Namikon - - MODIFIED: - REASON: - - -*/ - -#ifndef UDPWORLDIDINFO_H -#define UDPWORLDIDINFO_H - -class PWorldIDInfoReq : public PUdpMsgAnalyser -{ - u32 mInfoId; - -public: - PWorldIDInfoReq(PMsgDecodeData* nDecodeData); - //~PWorldIDInfoReq(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -#endif diff --git a/server/src/game/decoder/udp_zoning.h b/server/src/game/decoder/udp_zoning.h deleted file mode 100644 index 37a4b0e..0000000 --- a/server/src/game/decoder/udp_zoning.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udp_zoning.h - decoder classes for UDP Zoning messages - - CREATION: 6 Sep 2006 Hammag - - MODIFIED: 15 Dec 2006 Hammag - REASON: - added PUdpEndOfZoning management class - -*/ - -#ifndef UDPZONING_H -#define UDPZONING_H - -class PUdpZoning1 : public PUdpMsgAnalyser -{ - private: - u32 mNewLocation; - u16 mNewEntity; - u8 mUnknown; - public: - PUdpZoning1( PMsgDecodeData* nDecodeData ); - //~PUdpZoning1(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -class PUdpZoning2 : public PUdpMsgAnalyser -{ - public: - PUdpZoning2( PMsgDecodeData* nDecodeData ); - //~PUdpZoning2(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -class PUdpGenrepZoning : public PUdpMsgAnalyser -{ - private: - u32 mNewLocation; - u16 mNewEntity; - - public: - PUdpGenrepZoning( PMsgDecodeData* nDecodeData ); - //~PUdpGenrepZoning(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); - static bool DoEffectiveZoning( PClient* nClient, u32 nNewLocation, u16 nNewEntity ); -}; - -class PUdpAptGRZoning : public PUdpMsgAnalyser -{ - public: - PUdpAptGRZoning( PMsgDecodeData* nDecodeData ); - //~PUdpAptGRZoning(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); - static bool DoEffectiveZoning( PClient* nClient ); -}; - -class PUdpAddGenrepToList : public PUdpMsgAnalyser -{ - private: - u32 mLocation; - u16 mEntity; - - public: - PUdpAddGenrepToList( PMsgDecodeData* nDecodeData ); - //~PUdpAddGenrepToList(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -class PUdpAppartmentAccess : public PUdpMsgAnalyser -{ - private: - u16 mAppartmentPlace; - char* mPassword; - - public: - PUdpAppartmentAccess( PMsgDecodeData* nDecodeData ); - //~PUdpAppartmentAccess(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - - -class PUdpEndOfZoning : public PUdpMsgAnalyser -{ - private: - - public: - PUdpEndOfZoning( PMsgDecodeData* nDecodeData ); - //~PUdpEndOfZoning(); - PUdpMsgAnalyser* Analyse(); - bool DoAction(); -}; - -#endif diff --git a/server/src/game/decoder/udpanalyser.h b/server/src/game/decoder/udpanalyser.h deleted file mode 100644 index 61627c2..0000000 --- a/server/src/game/decoder/udpanalyser.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - udpanalyser.h - Analyser class top (used only by PUdpMsgDecoder) - Also includes the PUdpMsgUnknown derived class - and the PUdpMsgIgnore derived class - - CREATION: 23 Aug 2006 Hammag - - MODIFIED: 30 Aug 2006 Hammag - REASON: - moved these two class in file distinct from PUdpMsgDecoder. - -*/ - -#ifndef UDPANALYSER_H -#define UDPANALYSER_H - -class PUdpMsgAnalyser -{ - friend class PUdpMsgDecoder; - - protected: - PMsgDecodeData* mDecodeData; - - public: - PUdpMsgAnalyser(PMsgDecodeData* nDecodeData); - virtual ~PUdpMsgAnalyser(); - - virtual PUdpMsgAnalyser* Analyse(); - virtual bool DoAction(); - - static int smAnaCount; // temp for check - -}; - -class PUdpMsgUnknown : public PUdpMsgAnalyser -{ - public: - PUdpMsgUnknown(PMsgDecodeData* nDecodeData); - //~PUdpMsgUnknown(); - - //bool DoAction(); -}; - -class PUdpMsgIgnore : public PUdpMsgAnalyser -{ - public: - PUdpMsgIgnore(PMsgDecodeData* nDecodeData); - //~PUdpMsgUnknown(); - - //bool DoAction(); -}; - -#endif diff --git a/server/src/game/def/def_actionmod.cpp b/server/src/game/def/def_actionmod.cpp deleted file mode 100644 index 44dee7c..0000000 --- a/server/src/game/def/def_actionmod.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_actionmod.cpp - - CREATED: 04 Apr 2009 Hammag - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "include/def_actionmod.h" - - -PDefActionMod::PDefActionMod() -{ -} - -bool PDefActionMod::LoadFromDef( PTokenList *Tokens ) -{ - int Idx = 0; - int maxFields = 3; - for ( PTokenList::iterator i = Tokens->begin(); i != Tokens->end(); i++, Idx++ ) - { - switch ( Idx ) - { - case 0 : // setentry - break; - case 1 : - mIndex = atoi( i->c_str() ); break; - case 2 : - mStartValue = atof( i->c_str() ); break; - case 3 : - { - mNumOfSsq = atoi( i->c_str() ); - if( mNumOfSsq > 8 ) - mNumOfSsq = 8; - maxFields = 3 + 2 * mNumOfSsq; - break; - } - default : - if( (Idx >= 4) && (Idx <= maxFields) ) - { - if(Idx & 1) - { - mModFactor[(Idx - 4) / 2] = atof( i->c_str() ); - } - else - { - mSsqId[(Idx - 4) / 2] = atoi( i->c_str() ); - } - } - break; - } - - if ( Idx >= maxFields ) - break; - } - - return ((Idx == maxFields)); -} diff --git a/server/src/game/def/def_ammo.cpp b/server/src/game/def/def_ammo.cpp deleted file mode 100644 index 218a554..0000000 --- a/server/src/game/def/def_ammo.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_ammo.cpp - - CREATED: 04 Apr 2009 Hammag - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "include/def_ammo.h" - - -PDefAmmo::PDefAmmo() -{ - mShotId = mMagSize = mWeaponShotId = mDamageId = 0; -} - -bool PDefAmmo::LoadFromDef( PTokenList *Tokens ) -{ - int Idx = 0; - for ( PTokenList::iterator i = Tokens->begin(); i != Tokens->end(); i++, Idx++ ) - { - switch ( Idx ) - { - case 0 : // setentry - break; - case 1 : - mIndex = atoi( i->c_str() ); break; - case 2 : - mDamageId = atoi( i->c_str() ); break; - case 3 : - mWeaponShotId = atoi( i->c_str() ); break; - case 4 : - mMagSize = atoi( i->c_str() ); break; - case 5 : - mShotId = atoi( i->c_str() ); break; - default : - break; - } - - if ( Idx >= 5 ) - break; - } - - return ((Idx >= 4)); -} diff --git a/server/src/game/def/def_appartements.cpp b/server/src/game/def/def_appartements.cpp deleted file mode 100644 index 5e05b8f..0000000 --- a/server/src/game/def/def_appartements.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_appartements.cpp - - MODIFIED: 22 Sep 2006 Hammag - REASON: - Creation - -*/ - -#include "main.h" - -PDefAppartement::PDefAppartement() -{ -} - -bool PDefAppartement::LoadFromDef(PTokenList *Tokens) -{ - mFaction = 0; - int Idx=0; - for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++) - { - switch(Idx) - { - case 0: // setentry - continue; - - case 1: // index - mIndex = atoi(i->c_str()); break; - - case 2: // name - mName = *i; break; - - case 3: // world name - mWorldName = *i; break; - - case 4: // value - mValue = atoi(i->c_str()); break; - - case 5: // number of places - mPlaceCount = atoi(i->c_str()); break; - - case 6: - case 7: - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - mPlace[Idx-6] = atoi(i->c_str()); break; - - case 14: // faction if base appartement - mFaction = atoi(i->c_str()); break; - } - } -//Console->Print("%04d:%s file:%s val:%d places:%d pl1:%d pl2:%d pl8:%d faction:%d", -// mIndex, mName.c_str(), mWorldName.c_str(), mValue, mPlaceCount, mPlace[0], mPlace[1], mPlace[7], mFaction); - return true; -} diff --git a/server/src/game/def/def_appplaces.cpp b/server/src/game/def/def_appplaces.cpp deleted file mode 100644 index 3c4797a..0000000 --- a/server/src/game/def/def_appplaces.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - -/* - def_appplaces.cpp - - Created: 21 Sep 2006 Hammag - REASON: - -*/ - -#include "main.h" - -PDefAppPlace::PDefAppPlace() -{ -} - -bool PDefAppPlace::LoadFromDef(PTokenList *Tokens) -{ - int Idx=0; - for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++) - { - switch(Idx) - { - case 0: // setentry - continue; - - case 1: // index - mIndex = atoi(i->c_str()); break; - - case 2: // name - mName = *i; break; - - case 3: // Exit World - mExitWorldID = atoi(i->c_str()); break; - - case 4: // Exit World entity - mExitWorldEntity = atoi(i->c_str()); break; - - case 5: // Sewer level - mSewerLevel = atoi(i->c_str()); break; - } - } - - return true; -} diff --git a/server/src/game/def/def_blueprintpieces.cpp b/server/src/game/def/def_blueprintpieces.cpp deleted file mode 100644 index 76819ed..0000000 --- a/server/src/game/def/def_blueprintpieces.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_blueprintpieces.cpp - - CREATED: 04 Apr 2009 Hammag - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "include/def_blueprintpieces.h" - - -PDefBlueprintPieces::PDefBlueprintPieces() -{ -} - - -bool PDefBlueprintPieces::LoadFromDef( PTokenList *Tokens ) -{ - int Idx = 0; - int maxFields = 3; - for ( PTokenList::iterator i = Tokens->begin(); i != Tokens->end(); i++, Idx++ ) - { - switch ( Idx ) - { - case 0 : // setentry - break; - case 1 : - mIndex = atoi( i->c_str() ); break; - case 2 : - mMaxPieceNum = atoi( i->c_str() ); break; - case 3 : - { - mPieceNum = atoi( i->c_str() ); - if ( mPieceNum > 20 ) - mPieceNum = 20; - maxFields = 3 + mPieceNum; - break; - } - default : - if (( Idx >= 4 ) && ( Idx <= maxFields ) ) - { - mPieceId[ Idx - 4 ] = atoi( i->c_str() ); - } - break; - } - - if ( Idx >= maxFields ) - break; - } - - return (( Idx == maxFields ) ); -} diff --git a/server/src/game/def/def_characters.cpp b/server/src/game/def/def_characters.cpp deleted file mode 100644 index a744265..0000000 --- a/server/src/game/def/def_characters.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_characters.cpp - - Authors: - - Akiko - - Namikon - - someone else? - - MODIFIED: Unknown date / Unknown author - REASON: - initial release by unknown - - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL -*/ - -#include "main.h" - -// characters.def contains all ingame characters (player types, npc's, monsters) - -PDefCharacter::PDefCharacter() -{ - mIndex = -1; - mName = "unknown"; - mModel = -1; -} - -bool PDefCharacter::LoadFromDef(PTokenList *Tokens) -{ - int Idx=0; - for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++) - { - switch(Idx) - { - case 0 : // setentry - continue; - - case 1 : - mIndex = atoi(i->c_str()); break; - - case 2 : - mName = *i; break; - - case 3 : - mModel = atoi(i->c_str()); break; - - case 4 : // 0 - continue; - - case 5 : - mHead = atoi(i->c_str()); break; - - case 6 : - mTorso = atoi(i->c_str()); break; - - case 7 : - mLegs = atoi(i->c_str()); break; - - case 8 : - mColor = atoi(i->c_str()); break; - - case 9 : - mBrightness = atoi(i->c_str()); break; - } - - if(Idx==9) - return true; - } - - return false; -} - diff --git a/server/src/game/def/def_charaction.cpp b/server/src/game/def/def_charaction.cpp deleted file mode 100644 index 2eeb0fc..0000000 --- a/server/src/game/def/def_charaction.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_charaction.cpp - - CREATED: 04 Apr 2009 Hammag - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "include/def_charaction.h" - - -PDefCharAction::PDefCharAction() -{ -} - -bool PDefCharAction::LoadFromDef( PTokenList *Tokens ) -{ - int Idx = 0; - int maxFields = 2; - for ( PTokenList::iterator i = Tokens->begin(); i != Tokens->end(); i++, Idx++ ) - { - switch ( Idx ) - { - case 0 : // setentry - break; - case 1 : - mIndex = atoi( i->c_str() ); break; - case 2 : - { - mNumOfSsq = atoi( i->c_str() ); - if ( mNumOfSsq > 8 ) - mNumOfSsq = 8; - maxFields = 2 + 2 * mNumOfSsq; - break; - } - default : - if (( Idx >= 3 ) && ( Idx <= maxFields ) ) - { - if ( Idx & 1 ) - { - mSsqId[( Idx - 3 ) / 2] = atoi( i->c_str() ); - } - else - { - mModFactor[( Idx - 3 ) / 2] = atof( i->c_str() ); - } - } - break; - } - - if ( Idx >= maxFields ) - break; - } - - return (( Idx == maxFields ) ); -} diff --git a/server/src/game/def/def_charkinds.cpp b/server/src/game/def/def_charkinds.cpp deleted file mode 100644 index dc940b7..0000000 --- a/server/src/game/def/def_charkinds.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_charkinds.cpp - - Authors: - - Akiko - - Namikon - - someone else? - - MODIFIED: Unknown date / Unknown author - REASON: - initial release by unknown - - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL -*/ - -#include "main.h" - -// charkinds are character templates used for player char creation - -PDefCharKind::PDefCharKind() -{ - mSkillInfo = 0; - memset(mInventory, 0, sizeof(mInventory)); -} - -PDefCharKind::~PDefCharKind() -{ - delete [] mSkillInfo; - for(PSkillPtsMap::const_iterator i=mSkillPts.begin(); i!=mSkillPts.end(); i++) - delete i->second; - for(PSubSkillPtsMap::const_iterator i=mSubSkillPts.begin(); i!=mSubSkillPts.end(); i++) - delete i->second; - for(PStartLevelMap::const_iterator i=mStartLevels.begin(); i!=mStartLevels.end(); i++) - delete i->second; -} - -bool PDefCharKind::LoadFromDef(PTokenList *Tokens) -{ - int NumSkills = GameDefs->Skills()->GetNumDefs(); - //int NumSubSkills = GameDefs->SubSkills()->GetNumDefs(); - - int SkillInfoStart = 4; - int TrainPtsStart = SkillInfoStart+NumSkills*3; - int LevelsStart = TrainPtsStart + 32*2; - int MoneyStart = LevelsStart + 16*2; - int InventoryStart = MoneyStart+1; - - mSkillInfo = new PSkillInfo[NumSkills]; - - int Idx=0; - for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++) - { - switch(Idx) - { - case 0 : // setentry - continue; - - case 1 : - mIndex = atoi(i->c_str()); break; - - case 2 : - mName = *i; break; - - case 3 : - mType = atoi(i->c_str()); break; - - } - - if((Idx >= SkillInfoStart) && (Idx < TrainPtsStart)) // skill info - { - int SkillIdx = (Idx-SkillInfoStart)/3; - int Value = atoi(i->c_str()); - - // start, max, grow per skill - switch((Idx-SkillInfoStart)%3) - { - case 0 : mSkillInfo[SkillIdx].mStart = Value; break; - case 1 : mSkillInfo[SkillIdx].mMax = Value; break; - case 2 : mSkillInfo[SkillIdx].mGrow = Value; break; - } - } else - // 32 skill/subskill train pts - if((Idx >= TrainPtsStart) && (Idx < LevelsStart)) - { - static int SkillIndex = 0; - int Index = Idx-TrainPtsStart; - if((Index&1)==0) - { - SkillIndex = atoi(i->c_str()); - } else - { - if(SkillIndex >= 1000) // skill - { - const PDefSkill *Skill = GameDefs->Skills()->GetDef(SkillIndex-1000); - if(Skill) - { - int Index = Skill->GetIndex()-1; - PSkillPtsInfo *CurrentSkillPts = new PSkillPtsInfo(); - CurrentSkillPts->mSkill = Index; - CurrentSkillPts->mPoints = atoi(i->c_str()); - mSkillPts.insert(std::make_pair(Index, CurrentSkillPts)); - } else - { - if(SkillIndex-1000 != 0) - Console->Print("Charkind def: invalid skill index %i", SkillIndex-1000); - } - } else // subskill - { - const PDefSubSkill *SubSkill = GameDefs->SubSkills()->GetDef(SkillIndex); - if(SubSkill) - { - int Index = SubSkill->GetIndex()-1; - PSubSkillPtsInfo *CurrentSubSkillPts = new PSubSkillPtsInfo(); - CurrentSubSkillPts->mSubSkill = Index; - CurrentSubSkillPts->mPoints = atoi(i->c_str()); - mSubSkillPts.insert(std::make_pair(Index, CurrentSubSkillPts)); - } else - { - if(SkillIndex != 0) - Console->Print("Charkind def: invalid subskill index %i", SkillIndex); - } - } - } - } else - // 16 subskill start levels - if((Idx >= LevelsStart) && (Idx < MoneyStart)) - { - static int LevelIndex = 0; - int Index = Idx-NumSkills*3+4+(32*2); - if((Index&1)==0) - { - LevelIndex = atoi(i->c_str()); - } else - { - if(LevelIndex > 0) - { - const PDefSubSkill *SubSkill = GameDefs->SubSkills()->GetDef(LevelIndex); - if(SubSkill) - { - PStartLevelInfo *Level = new PStartLevelInfo(); - Level->mSubSkill = SubSkill->GetIndex(); - Level->mLevel = atoi(i->c_str()); - mStartLevels.insert(std::make_pair(Level->mSubSkill, Level)); - } else - { - Console->Print("Charkind def: invalid subskill index %i", LevelIndex); - } - } - } - } else - // money - if((Idx >= MoneyStart) && (Idx < InventoryStart)) - { - mMoney = atoi(i->c_str()); - } else - // inventory - if((Idx >= InventoryStart) && (Idx < InventoryStart+8)) - { - mInventory[Idx-InventoryStart] = atoi(i->c_str()); - } - } - - return true; -} - diff --git a/server/src/game/def/def_factions.cpp b/server/src/game/def/def_factions.cpp deleted file mode 100644 index 5daf3fd..0000000 --- a/server/src/game/def/def_factions.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_factions.cpp - - Authors: - - Akiko - - Namikon - - someone else? - - MODIFIED: Unknown date / Unknown author - REASON: - initial release by unknown - - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL -*/ - -#include "main.h" - -PDefFaction::PDefFaction() -{ - memset(mRelations, 0, sizeof(mRelations)); // ... array members supposed to by auto-initialized by C++ -} - -bool PDefFaction::LoadFromDef(PTokenList *Tokens) -{ - int Idx=0; - for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++) - { - // setfracc 19 "Monster" -1024 0 0 -1024 -1024 -1024 -1 - switch(Idx) - { - case 0 : // setfrac - continue; - - case 1 : - mIndex = atol(i->c_str()); break; - - case 2 : - mName = *i; - CleanUpString(&mName); - break; - - case 3 : - mStartValue = atol(i->c_str()); break; - - case 4: - mAffected = atol(i->c_str())!=0; break; - - case 5: - mSL = atol(i->c_str()); break; - - default : - { - if(Idx-6 < NUMFACTIONS) - mRelations[Idx-6] = atol(i->c_str()); break; - } - } - } - - return true; -} - -int PDefFaction::GetRelation(int Faction) const -{ - // faction 0 has no relations - if(Faction <= 0 || Faction > NUMFACTIONS) - return 0; - - return mRelations[Faction-1]; -} - diff --git a/server/src/game/def/def_hack.cpp b/server/src/game/def/def_hack.cpp deleted file mode 100644 index 63926f4..0000000 --- a/server/src/game/def/def_hack.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_hack.cpp - - Authors: - - Akiko - - Namikon - - someone else? - - MODIFIED: Unknown date / Unknown author - REASON: - initial release by unknown - - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL -*/ - -#include "main.h" - -PDefHack::PDefHack() -{ -} - -bool PDefHack::LoadFromDef(PTokenList *Tokens) -{ - int Idx=0; - for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++) - { - switch(Idx) - { - case 0: // setentry - continue ; - - - case 1: // index - mIndex = atoi(i->c_str()); break; - - - } - } - - return true; -} - diff --git a/server/src/game/def/def_itemres.cpp b/server/src/game/def/def_itemres.cpp deleted file mode 100644 index 1bd7047..0000000 --- a/server/src/game/def/def_itemres.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_itemres.cpp - - CREATED: 04 Apr 2009 Hammag - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "include/def_itemres.h" - - -PDefItemRestriction::PDefItemRestriction() -{ -} - -bool PDefItemRestriction::LoadFromDef( PTokenList *Tokens ) -{ - int Idx = 0; - int maxFields = 2; - for ( PTokenList::iterator i = Tokens->begin(); i != Tokens->end(); i++, Idx++ ) - { - switch ( Idx ) - { - case 0 : // setentry - break; - case 1 : - mIndex = atoi( i->c_str() ); break; - case 2 : - { - mNumRestrictions = atoi( i->c_str() ); - if( mNumRestrictions > 6 ) - mNumRestrictions = 6; - maxFields = 2 + 2 * mNumRestrictions; - break; - } - default : - if( (Idx >= 3) && (Idx <= maxFields) ) - { - if(Idx & 1) - { - mSsqId[(Idx - 3) / 2] = atoi( i->c_str() ); - } - else - { - mMinValue[(Idx - 3) / 2] = atoi( i->c_str() ); - } - } - break; - } - - if ( Idx >= maxFields ) - break; - } - - return ((Idx == maxFields)); -} diff --git a/server/src/game/def/def_npcarmor.cpp b/server/src/game/def/def_npcarmor.cpp deleted file mode 100644 index dcb34ea..0000000 --- a/server/src/game/def/def_npcarmor.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_npcarmor.cpp - - CREATED: 04 Apr 2009 Hammag - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "include/def_npcarmor.h" - - -PDefNpcArmor::PDefNpcArmor() -{ -} - -bool PDefNpcArmor::LoadFromDef ( PTokenList *Tokens ) -{ - int Idx=0; - for ( PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++ ) - { - switch ( Idx ) - { - case 0 : // setentry - break;; - case 1 : - mIndex = atoi ( i->c_str() ); break; - default : - if ( ( Idx - 2 ) < 7 ) - { - mValue[Idx - 2] = atoi ( i->c_str() ); - } - break; - } - } - - return ( Idx >= 8 ); -} diff --git a/server/src/game/def/def_outposts.cpp b/server/src/game/def/def_outposts.cpp deleted file mode 100644 index 3c1919a..0000000 --- a/server/src/game/def/def_outposts.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_outposts.cpp - - CREATED: 04 Apr 2009 Hammag - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "include/def_outposts.h" - - -PDefOutpost::PDefOutpost() -{ - for ( int i = 0; i < 8; ++i ) - mInfluenceZone[i] = 0; -} - -bool PDefOutpost::LoadFromDef ( PTokenList *Tokens ) -{ - int Idx=0; - for ( PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++ ) - { - switch ( Idx ) - { - case 0: // setentry - break; - case 1: // index - mIndex = atoi ( i->c_str() ); break; - case 2: - mName = *i; break; - case 3: - mType = atoi ( i->c_str() ); break; - case 4: - mStandardFaction = atoi ( i->c_str() ); break; - case 5: - mRevenue = atof ( i->c_str() ); break; - case 6: - mConquestReward = atof ( i->c_str() ); break; - case 7: - mMaxSecurity = atoi ( i->c_str() ); break; - default : - if ( ( Idx - 8 ) < 8 ) - { - mInfluenceZone[Idx - 8] = atoi ( i->c_str() ); - } - break; - } - - if ( Idx == 15 ) - break; - } - - return ( Idx >= 7 ); -} diff --git a/server/src/game/def/def_recycles.cpp b/server/src/game/def/def_recycles.cpp deleted file mode 100644 index 7d12884..0000000 --- a/server/src/game/def/def_recycles.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_recycles.cpp - - CREATED: 04 Apr 2009 Hammag - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "include/def_recycles.h" - - -PDefRecycle::PDefRecycle() -{ -} - -bool PDefRecycle::LoadFromDef( PTokenList *Tokens ) -{ - int Idx = 0; - int maxFields = 4; - for ( PTokenList::iterator i = Tokens->begin(); i != Tokens->end(); i++, Idx++ ) - { - switch ( Idx ) - { - case 0 : // setentry - break; - case 1 : - //mIndex = atoi ( i->c_str() ); - break; - case 2 : // We use resultitem as index - mIndex = mResultItemId = atoi ( i->c_str() ); break; - case 3: - mBuildTime = atoi ( i->c_str() ); break; - case 4 : - { - mNumParts = atoi ( i->c_str() ); - if ( mNumParts > 8 ) - mNumParts = 8; - maxFields = 4 + mNumParts; - break; - } - default : - if ( ( Idx >= 5 ) && ( Idx <= maxFields ) ) - { - mPartId[ Idx - 5 ] = atoi ( i->c_str() ); break; - } - break; - } - - if ( Idx >= 12 ) - break; - } - - return ( ( Idx >= 5 ) ); -} diff --git a/server/src/game/def/def_shots.cpp b/server/src/game/def/def_shots.cpp deleted file mode 100644 index 4b9ee0e..0000000 --- a/server/src/game/def/def_shots.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_shots.cpp - - CREATED: 04 Apr 2009 Hammag - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "include/def_shots.h" - - -PDefShot::PDefShot() -{ } - -bool PDefShot::LoadFromDef( PTokenList *Tokens ) -{ - int Idx = 0; - for ( PTokenList::iterator i = Tokens->begin(); i != Tokens->end(); i++, Idx++ ) - { - switch ( Idx ) - { - case 0 : // setentry - break; - case 1 : - mIndex = atoi( i->c_str() ); break; - case 2 : - mDamageId = atoi( i->c_str() ); break; - case 3 : - mMass = atoi( i->c_str() ); break; - case 4 : - mRadius = atoi( i->c_str() ); break; - case 5 : - mSpeed = atof( i->c_str() ); break; - default : - break; - } - - if ( Idx >= 5 ) - break; - } - - return (( Idx >= 5 ) ); -} diff --git a/server/src/game/def/def_skills.cpp b/server/src/game/def/def_skills.cpp deleted file mode 100644 index f0bf1e5..0000000 --- a/server/src/game/def/def_skills.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_skills.cpp - - Authors: - - Akiko - - Namikon - - someone else? - - MODIFIED: Unknown date / Unknown author - REASON: - initial release by unknown - - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL -*/ - -#include "main.h" - -// skill.def includes skill names and skill/subskill mapping - -PDefSkill::PDefSkill() -{ - mSubSkills = 0; - mNumSubSkills = 0; -} - -PDefSkill::~PDefSkill() -{ - delete [] mSubSkills; -} - -bool PDefSkill::LoadFromDef(PTokenList *Tokens) -{ - int Idx=0; - for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++) - { - switch(Idx) - { - case 0 : // setentry - continue; - - case 1 : - mIndex = atol(i->c_str()); break; - - case 2 : - mName = *i; break; - - case 3 : - mShortName = *i; break; - - case 4 : - { - mNumSubSkills = atol(i->c_str()); - mSubSkills = new int[mNumSubSkills]; - std::memset(mSubSkills, 0, sizeof(int)*mNumSubSkills); - break; - } - } - - if(Idx >= 5) - { - mSubSkills[Idx-5] = atoi(i->c_str()); - if(!GameDefs->SubSkills()->GetDef(mSubSkills[Idx-5])) - { - Console->Print("Skill def error: skill %s refers to nonexistant subskill %i", mShortName.c_str(), mSubSkills[Idx-5]); - return false; - } - } - } - - if(Idx-5 != mNumSubSkills) - { - Console->Print("Warning: skill %s has incorrect number of subskills", mShortName.c_str()); - Console->Print(" Expected %i, available %i", mNumSubSkills, Idx-5); - } - return true; -} diff --git a/server/src/game/def/def_subskills.cpp b/server/src/game/def/def_subskills.cpp deleted file mode 100644 index b414d82..0000000 --- a/server/src/game/def/def_subskills.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_subskills.cpp - - Authors: - - Akiko - - Namikon - - someone else? - - MODIFIED: Unknown date / Unknown author - REASON: - initial release by unknown - - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL -*/ - -#include "main.h" - -// subskill.def, names and parameters of all subskills - -PDefSubSkill::PDefSubSkill() -{ - mActionModifiers = 0; - mNumActionModifiers = 0; -} - -PDefSubSkill::~PDefSubSkill() -{ - delete [] mActionModifiers; -} - -bool PDefSubSkill::LoadFromDef(PTokenList *Tokens) -{ - int Idx=0; - for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++) - { - switch(Idx) - { - case 0 : // setentry - continue; - - case 1 : - mIndex = atoi(i->c_str()); break; - - case 2 : - mName = *i; break; - - case 3 : - mShortName = *i; break; - - case 4 : - mStrengthenFactor = static_cast(atof(i->c_str())); break; - - case 5 : - { - mNumActionModifiers = atoi(i->c_str()); - mActionModifiers = new int[mNumActionModifiers]; - std::memset(mActionModifiers, 0, sizeof(int)*mNumActionModifiers); - break; - } - } - - if(Idx>=6) - mActionModifiers[Idx-6] = atoi(i->c_str()); - } - - return true; -} - diff --git a/server/src/game/def/def_vehicles.cpp b/server/src/game/def/def_vehicles.cpp deleted file mode 100644 index ac21e2a..0000000 --- a/server/src/game/def/def_vehicles.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_vehicles.cpp - - CREATED: 04 Apr 2009 Hammag - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "include/def_vehicles.h" - - -PDefVhc::PDefVhc() -{ - mNumSeats = mArmor = mHealth = mModel = 0; - mName = "undefined"; - for(int i=0; i<8; ++i) - mSeatId[i] = -1; -} - -bool PDefVhc::LoadFromDef( PTokenList *Tokens ) -{ - int Idx = 0; - for ( PTokenList::iterator i = Tokens->begin(); i != Tokens->end(); i++, Idx++ ) - { - switch ( Idx ) - { - case 0 : // setentry - break; - case 1 : - mIndex = atoi( i->c_str() ); break; - case 2 : - mModel = atoi( i->c_str() ); break; - case 3 : - mName = *i; break; - case 34 : - mHealth = atoi( i->c_str() ); break; - case 35 : - mArmor = atoi( i->c_str() ); break; - default : - if( (Idx >= 16) && (Idx <= 23) ) - { - mSeatId[Idx - 16] = atoi( i->c_str() ); - if(mSeatId[Idx - 16] >= 0) // In theroy, we should check that it is a valid VhcSeat Index - ++mNumSeats; - } - break; - } - - if ( Idx >= 36 ) - break; - } - - return ((Idx >= 35)); -} diff --git a/server/src/game/def/def_weather.cpp b/server/src/game/def/def_weather.cpp deleted file mode 100644 index eff7858..0000000 --- a/server/src/game/def/def_weather.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_weather.cpp - - CREATED: 04 Apr 2009 Hammag - - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "include/def_weather.h" - - -PDefWeather::PDefWeather() -{ - mNumWeathers = mSectionId = 0; - for(int i=0; i<8; ++i) - mDuration[i] = mWeatherId[i] = 0; -} - -bool PDefWeather::LoadFromDef( PTokenList *Tokens ) -{ - int Idx = 0; - for ( PTokenList::iterator i = Tokens->begin(); i != Tokens->end(); i++, Idx++ ) - { - switch ( Idx ) - { - case 0 : // setentry - break; - case 1 : - mIndex = atoi( i->c_str() ); break; - case 2 : - mSectionId = atoi( i->c_str() ); break; - case 3 : - mNumWeathers = atoi( i->c_str() ); break; - default : - if( (Idx >= 4) && (Idx <= (3 + 2*mNumWeathers)) && (Idx <= 19) ) - { - if(Idx & 1) - { - mDuration[int((Idx - 4)/2)] = atoi( i->c_str() ); - } - else - { - mWeatherId[int((Idx - 4)/2)] = atoi( i->c_str() ); - } - } - break; - } - - if ( Idx >= 19 ) - break; - } - - return ((Idx >= (3 + 2*mNumWeathers))); -} diff --git a/server/src/game/def/def_worldmodels.cpp b/server/src/game/def/def_worldmodels.cpp deleted file mode 100644 index f5de348..0000000 --- a/server/src/game/def/def_worldmodels.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - -/* - def_WorldModels.cpp - - Created: 21 Sep 2006 Hammag - REASON: - -*/ - -#include "main.h" - -PDefWorldModel::PDefWorldModel() -{ -} - -bool PDefWorldModel::LoadFromDef(PTokenList *Tokens) -{ - int Idx=0; - for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++) - { - switch(Idx) - { - case 0: // setentry - continue; - - case 1: // index - mIndex = atoi(i->c_str()); break; - - case 2: // name - mName = *i; break; - - case 3: // use flag - mUseFlags = atoi(i->c_str()); break; - - case 4: // function type - mFunctionType = atoi(i->c_str()); break; - - case 5: // function value - mFunctionValue = atoi(i->c_str()); break; - - case 6: // hack difficulty - mHackDifficulty = atoi(i->c_str()); break; - - case 7: // hack penalty - mHackPenalty = atoi(i->c_str()); break; - } - } - - return true; -} diff --git a/server/src/game/def/defparser.cpp b/server/src/game/def/defparser.cpp deleted file mode 100644 index b1288a3..0000000 --- a/server/src/game/def/defparser.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - defparser.cpp - - Authors: - - Akiko - - Namikon - - someone else? - - MODIFIED: Unknown date / Unknown author - REASON: - initial release by unknown - - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL -*/ - -#include "main.h" - -PDefParser::PDefParser() -{ -} - -PDefParser::~PDefParser() -{ - for(PDefTokenList::iterator i=mTokens.begin(); i!=mTokens.end(); i++) - delete *i; -} - -bool PDefParser::Parse(const char *File) -{ - PFile *f = Filesystem->Open("", File, Config->GetOption("nc_data_path")); - enum { NOPE, MAYBE, LINE, BLOCK, MAYBE_END } Comment = NOPE; - - if(f) - { - while(!f->Eof()) - { - std::string Str = f->ReadString(); - int Len = Str.length(); - if(Len <= 0) - continue; - - if(Str.substr(0, 3)!="set") - continue; - - //Console->Print("%s", Str.c_str());//NEW was commented , just to be sure of what we are reading - - PTokenList *List = new PTokenList(); - int Start=0, Tokens=0; - bool Quote=false; - for(int i=0; i= Start) - { - List->push_back(std::string(Str.substr(Start, (End-Start)+1))); - Tokens++; - break; - } - Quote=false; - } - if(Comment != BLOCK) - Comment=NOPE; - break; - } - - if(!Quote) - { - if(Comment < LINE && (Str[i]=='\t' || Str[i]==',' || Str[i]==' ' || Str[i]==';' || Str[i]=='|' || i==Len-1)) - { - int End=i-1; - if(End >= Start) - { - List->push_back(std::string(Str.substr(Start, (End-Start)+1))); - Tokens++; - } - Start=i+1; - } - - if(Str[i] <= ' ') - continue; - - if(Str[i]=='*') - { - if(Comment==MAYBE) - Comment=BLOCK; - else - if(Comment==BLOCK) - Comment=MAYBE_END; - } else - if(Str[i]=='/') - { - if(Comment==MAYBE) - { - // second slash, skip rest of line - Comment=LINE; - break; - } else - if(Comment==MAYBE_END) - { - Comment=NOPE; // comment block ends - Start=i+1; - } else - if(Comment != BLOCK) - Comment=MAYBE; // first slash - } else - { - if(Comment==MAYBE) - Comment=NOPE; // stand-alone slash - else - if(Comment==MAYBE_END) - Comment=BLOCK; // comment block did not end - } - } - - if(Str[i]=='"') - Quote ^= true; - } - - if(Tokens > 0) - mTokens.push_back(List); - else - delete List; - } - } else - { - Console->Print("%s PDefParser::Parse: could not open file %s", Console->ColorText( RED, BLACK, "[ERROR]" ), File); - return false; - } - - return true; -} diff --git a/server/src/game/def/main.h b/server/src/game/def/main.h deleted file mode 100644 index d70e4f9..0000000 --- a/server/src/game/def/main.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - main.h - main include file, contains all needed includes and important definitions - - MODIFIED: 30 Aug 2006 Hammag - REASON: - created - MODIFIED: 21 Sep 2006 Hammag - REASON: - added def_worldmodels related stuff - MODIFIED: 22 Sep 2006 Hammag - REASON: - added def_appartements related stuff - - added def_appplaces related stuff - - added def_respawn related stuff - MODIFIED: 28 Sep 2006 Hammag - REASON: - added def_worldfile (worlds.ini) related stuff - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - -#ifndef MAIN_H -#define MAIN_H - -//#include "version.h" - -//basic includes -#include "include/external.h" - -//tinns includes -#include "include/types.h" -#include "common/config.h" - -#include "common/console.h" -#include "common/misc.h" - -#include "include/globals.h" - -#include "common/filesystem.h" -#include "include/defparser.h" -#include "include/defs.h" - - -// The following defines are NOT used anymore -#define DEF_CHARACTERS "defs/characters.def" -#define DEF_SKILLS "defs/skills.def" -#define DEF_SUBSKILLS "defs/subskill.def" -#define DEF_CHARKINDS "defs/charkinds.def" -#define DEF_WORLDINFO "defs/worldinfo.def" -#define DEF_FRACTIONS "defs/fractions.def" -#define DEF_HACK "defs/hack.def" -#define DEF_ITEMS "defs/items.def" -#define DEF_WORLDMODEL "defs/worldmodel.def" -#define DEF_APPPLACES "defs/appplaces.def" -#define DEF_APPARTEMENTS "defs/appartements.def" -#define DEF_RESPAWN "defs/respawn.def" -#define DEF_WEAPONS "defs/weapons.def" -#define DEF_AMMO "defs/ammo.def" -#define DEF_BLUEPRINTPIECES "defs/blueprintpieces.def" -#define DEF_DAMMAGE "defs/dammage.def" -#define DEF_DRUGS "defs/drugs.def" -#define DEF_IMPLANTS "defs/implants.def" -#define DEF_ITEMMOD "defs/itemmod.def" -#define DEF_ITEMRES "defs/itemres.def" -#define DEF_NPC "defs/npc.def" -#define DEF_NPCARMOR "defs/npcarmor.def" -#define DEF_NPCGROUPSPAWN "defs/npcgroupspawn.def" -#define DEF_NPCLOOT "defs/npcloot.def" -#define DEF_OUTPOSTS "defs/outposts.def" -#define DEF_RECYCLES "defs/recycles.def" -#define DEF_TRADER "defs/trader.def" -#define DEF_VEHICLES "defs/vehicles.def" -#define DEF_VEHICLESEATS "defs/vehiclesits.def" -#define WRLD_WORLDFILE "worlds/worlds.ini" - -#endif - diff --git a/server/src/game/def/world_datstruct.h b/server/src/game/def/world_datstruct.h deleted file mode 100644 index d686d5d..0000000 --- a/server/src/game/def/world_datstruct.h +++ /dev/null @@ -1,168 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - -/* - world_datstruct.h - .dat world files internal structures - - MODIFIED: 29 Sep 2006 Hammag - REASON: - Creation -*/ - -#ifndef WORLD_DATSTRUCT_H -#define WORLD_DATSTRUCT_H - -struct PWorldFileHeader -{ - u32 mHeaderSize; // must be 08 00 00 00, = header size after this field - u32 mHeaderSig; // must be CF CF 0F 00 - u32 mSection; // must be 01 00 00 00 -}; - -struct PSectionHeader -{ - u32 mHeaderSize; // must be 0C 00 00 00 - u32 mHeaderSig; // must be CF FF 00 00 - u32 mSection; // 00 00 00 00 means end - u32 mDataSize; -}; - -struct PSec2ElemHeader -{ - u32 mHeaderSize; // must be 0C 00 00 00 - u32 mHeaderSig; // must be F1 FE FE 0F - u32 mElementType; // 1000003, 1000005 or 1000014 - u32 mDataSize; -}; - -struct PSec2ElemType3a //static object ? -{ - f32 mPosY; //= u16 PosY - 32000 - f32 mPosZ; - f32 mPosX; - f32 mRotY; - f32 mRotZ; - f32 mRotX; - f32 mScale; //00 00 80 3F ? = float(1.000000) !!! => scale factor ????? - u32 mUnknown2; //01 00 00 00 ? - u16 mModelID; // points to models.ini - u32 mUnknown3; //00 00 00 00 ? - u32 mUnknown4; //00 00 00 00 ? - u16 mWorldmodelID; // points to worldmodel.def - u16 mUnknown5; //12 00 ? - u32 mObjectID; -}; -struct PSec2ElemType3b //this part is optional -{ - f32 mBoxLowerY; //Bounding box, for useflag "64 - selfconstructing colisionbox" - f32 mBoxLowerZ; // s32 or u32 ? - f32 mBoxLowerX; - f32 mBoxUpperY; - f32 mBoxUpperZ; - f32 mBoxUpperX; -}; - -struct PSec2ElemType5Start //door -{ - u16 mUnknown1; //18 00 - u16 mUnknown1bis; //00 00 ? varies - f32 mPosY; - f32 mPosZ; - f32 mPosX; - u8 mActorStringSize; //string size with ending 0 - u8 mParamStringSize; //string size with ending 0 - u16 mUnknown5; //00 00 ? second byte varies - u16 mDoorID; // but what is the link with ObjectID sent in Use message (can't find the base offset .. or 0x80 for doors ???) - u16 mWorldmodelID; //door type from worldmodel.def -}; -//Actor As String //null terminated string -//Params As String //null terminated string - for DDOOR, 2nd param is the ID of the other (half)door (*) -//param1 = 2 => simple lateral move ?, 3 => door frontal+lateral move (as at Typherra memorial) ? -//last param = 0/1 for lateral move direction ? no ... -//(*) here is the bug(?) that makes open only one half of a double door - -/* -struct PSec2ElemType6Start //npc -{ - u16 mUnknown1; //20 00 ? - u16 mUnknown2; //12 00 ? - f32 mPosY; - f32 mPosZ; - f32 mPosX; - u32 mNPCTypeID; //npc type in npc.def - u8 mActorStringSize; //string size with ending 0 - u8 mParamStringSize; //string size with ending 0 - u16 mNpcID; // kind of ? - u32 mUnknown3; //01 00 00 00 ? - u16 mUnknown4; //00 00 ? - u16 mUnknown5; //04 00 ? -}; - //Actor As String //null terminated string - //Params As String //null terminated string - Seem to be the facing angle in degres -struct PSec2ElemType6End -{ - f32 mPosY2; //second position for movement ? - f32 mPosZ2; // - f32 mPosX2; // -}; -*/ -struct PSec2NPC_EntryPart1 -{ - u32 mUnknown1; // Is always 0x20001200, in every log. maybe header for NPCs? - f32 mPosY; - f32 mPosZ; - f32 mPosX; - u32 mNPCTypeID; //npc type in npc.def - u8 mActorStringSize; //string size with ending 0 - u8 mAngleStringSize; //string size with ending 0 - u16 mNpcID; - u8 mHasAdditionalCoords; - u8 mUnknown2a; - u8 mUnknown2b; - u8 mUnknown2c; - u16 mTradeID; //mUnknown3; //00 00 ? - u16 mUnknown4; //04 00 ? -}; - -// u8 mActorName[mActorStringSize]; -// u8 mAngle[mAngleStringSize]; - -struct PSec2NPC_EntryPart2 // Waypoints! or something like that... -{ - f32 mPosY; - f32 mPosZ; - f32 mPosX; -}; - - -// u16 mStrSize; //non-zero terminated string size -// Name As String //non-zero terminated string -struct PSec2ElemType15End //area definition/sound ? -{ - f32 mUnknown1; - f32 mUnknown2; - f32 mUnknown3; - f32 mUnknown4; - f32 mUnknown5; -}; - -#endif diff --git a/server/src/game/doortemplate.cpp b/server/src/game/doortemplate.cpp deleted file mode 100644 index d3e5321..0000000 --- a/server/src/game/doortemplate.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - -/* - doortemplate.cpp - world door template class - - MODIFIED: 05 Nov 2006 Hammag - REASON: - creation - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem - - TODO: - mem corruption occurs if mDoorParameters[] is given a size of 6, and that 6 max param can be accepted - This bug occurs in world 105. Reason not found yet :-x -*/ - - -#include "main.h" - -#include "include/doortemplate.h" - -PDoorTemplate::PDoorTemplate() -{ - mDoorID = 0; - mWorldmodelID = 0; - mDefWorldModel = NULL; - mIsDoubleDoor = false; - mIsTriggeredDoor = false; -} - -PDoorTemplate::~PDoorTemplate() -{ - -} - -void PDoorTemplate::SetDoorParameters(char* nDoorParametersString) -{ - char* SepPos; - int ParamNum = 0; -//Console->Print("door parameter: %s", nDoorParametersString); - while ( *nDoorParametersString && (SepPos = strchr(nDoorParametersString, ',')) && (ParamNum < 4)) - { - *SepPos = 0; - mDoorParameters[ParamNum++] = atoi(nDoorParametersString); - nDoorParametersString = SepPos + 1; - } - if (*nDoorParametersString) - { - if (ParamNum < 4) - mDoorParameters[ParamNum] = atoi(nDoorParametersString); - //else - // Console->Print(RED, BLACK, "[ERROR] More than 4 parameters in Sec2ElemType5 ParamString"); - } -} - -void PDoorTemplate::SetDoorTypeName(char* nDoorTypeName) -{ - mDoorTypeName = nDoorTypeName; - - if (mDoorTypeName == "DDOOR") - { - mIsDoubleDoor = true; - } - else if (mDoorTypeName == "TRIGDD") - { - mIsDoubleDoor = true; - mIsTriggeredDoor = true; - } - else if (mDoorTypeName == "TRIGDOOR") - { - mIsTriggeredDoor = true; - } - else if (mDoorTypeName == "NBUTTON") - { - mIsTriggeredDoor = false; - } -} diff --git a/server/src/game/furnituretemplate.cpp b/server/src/game/furnituretemplate.cpp deleted file mode 100644 index 4525aaa..0000000 --- a/server/src/game/furnituretemplate.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - -/* - furnituretemplate.cpp - world furniture template class - - MODIFIED: 04 Oct 2006 Hammag - REASON: - creation - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "include/furnituretemplate.h" - -PFurnitureItemTemplate::PFurnitureItemTemplate() -{ - mObjectID = 0; - mModelID = 0; - mWorldmodelID = 0; - mDefWorldModel = NULL; - mLinkedObjectID = 0; -} - -PFurnitureItemTemplate::~PFurnitureItemTemplate() -{ - -} diff --git a/server/src/game/gamecommands/broadcast.cpp b/server/src/game/gamecommands/broadcast.cpp deleted file mode 100644 index 301dcad..0000000 --- a/server/src/game/gamecommands/broadcast.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" - -void PCommands::doCmdbroadcast() -{ - if(DumbMade == false) - { - Console->Print("%s Missing packetdumb in PCommands::doCmdbroadcast for declared broadcast function!", Console->ColorText(RED, BLACK, "[PANIC]")); - return; - } - - Chat->sendBroadcast(OrgPacketDumb+11); -} diff --git a/server/src/game/gamecommands/color.cpp b/server/src/game/gamecommands/color.cpp deleted file mode 100644 index 1d861f4..0000000 --- a/server/src/game/gamecommands/color.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" - -void PCommands::doCmdcolor() -{ - bool SyntaxError = false; - if(ArgC < 1) - { - SyntaxError = true; - } - - if(SyntaxError == true) - { - Chat->send(source, CHAT_DIRECT, "Usage", "@color -| [-|] [-|]"); - return; - } - - char tmp_v1[30]; - char tmp_v2[30]; - char tmp_v3[30]; - - GetArgText(1, tmp_v1, 30); - GetArgText(2, tmp_v2, 30); - GetArgText(3, tmp_v3, 30); - - u8 val1, val2, val3, val4, val5, val6; - char effStr[128]; - PMessage* tmpMsg; - - source->GetChar()->GetCurrentBodyColor(val1, val2, val3, val4, val5, val6); - if(tmp_v1[0] != '-') - val1 = (u8)(atoi(tmp_v1) & 0xff); - if((tmp_v2[0] != '-') && (tmp_v2[0] != '\0')) - val2 = (u8)(atoi(tmp_v2) & 0xff); - if((tmp_v3[0] != '-') && (tmp_v3[0] != '\0')) - val3 = (u8)(atoi(tmp_v3) & 0xff); - source->GetChar()->SetCurrentBodyColor(val1, val2, val3, val4, val5, val6); - - tmpMsg = MsgBuilder->BuildCharHelloMsg(source); - ClientManager->UDPBroadcast(tmpMsg, source); - snprintf(effStr, 127, "Body color set to values %d %d %d", val1, val2, val3); - effStr[127] = '\0'; - Chat->send(source, CHAT_DIRECT, "System", effStr); -} diff --git a/server/src/game/gamecommands/effect.cpp b/server/src/game/gamecommands/effect.cpp deleted file mode 100644 index 8f602c6..0000000 --- a/server/src/game/gamecommands/effect.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" - -void PCommands::doCmdeffect() -{ - bool SyntaxError = false; - if(ArgC < 1) - { - SyntaxError = true; - } - - if(IsArgNumeric(1) == false) - SyntaxError = true; - - if(SyntaxError == true) - { - Chat->send(source, CHAT_DIRECT, "Usage", "@effect []"); - return; - } - - u8 val1, val2; - char effStr[128]; - PMessage* tmpMsg; - - val1 = (u8)(GetArgInt(1) & 0xff); - val2 = (u8)(GetArgInt(2) & 0xff); - - source->GetChar()->SetBodyEffect(val1, val2); - - tmpMsg = MsgBuilder->BuildCharHelloMsg(source); - ClientManager->UDPBroadcast(tmpMsg, source); - snprintf(effStr, 127, "Body effect set to value %d with density %d (but you can see it yourself)", val1, val2); - effStr[127] = '\0'; - Chat->send(source, CHAT_DIRECT, "System", effStr); -} diff --git a/server/src/game/gamecommands/listbans.cpp b/server/src/game/gamecommands/listbans.cpp deleted file mode 100644 index e82f97f..0000000 --- a/server/src/game/gamecommands/listbans.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" - -void PCommands::doCmdlistbans() -{ - Chat->send(source, CHAT_DIRECT, "System", "Sorry, namikon was too lazy to code that ^^"); - Chat->send(source, CHAT_DIRECT, "System", "Please wait until the ban is removed automaticly or edit your sqlDB"); - return; -} diff --git a/server/src/game/gamecommands/main.h b/server/src/game/gamecommands/main.h deleted file mode 100644 index 349dce9..0000000 --- a/server/src/game/gamecommands/main.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - main.h - main include file, contains all needed includes and important definitions - - MODIFIED: 30 Aug 2006 Hammag - REASON: - created - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - -#ifndef MAIN_H -#define MAIN_H - -//#include "version.h" - -//basic includes -#include "include/external.h" - -//tinns includes -#include "include/types.h" -#include "common/config.h" - -#include "common/console.h" -#include "common/misc.h" - -#include "common/netcode.h" - -#include "include/globals.h" - -/* -#include "../gamemonkey/gmMachine.h" -#include "../gamemonkey/gmCall.h" -*/ - -// MySQL Support // shouldn't be needed as DB-objects access class should do that -#ifdef MYSQL_INC_DIR -#include -#else -#include -#endif - -#include "include/sql.h" - -#include "common/filesystem.h" -#include "include/defparser.h" - -#include "include/skill.h" - -#include "include/chars.h" -#include "include/accounts.h" -#include "include/defs.h" -#include "include/client.h" -#include "include/server.h" -#include "include/gameserver.h" -#include "include/zoning.h" -#include "include/item.h" -#include "include/inventory.h" - -#include "include/chat.h" -#include "include/commands.h" -#include "include/clientmanager.h" -#include "include/msgbuilder.h" -#include "include/worlds.h" -#include "include/worldactors.h" -#include "include/npc.h" - -#endif - diff --git a/server/src/game/gamecommands/online.cpp b/server/src/game/gamecommands/online.cpp deleted file mode 100644 index a7080cb..0000000 --- a/server/src/game/gamecommands/online.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" - -void PCommands::doCmdconlist() -{ - if (gDevDebug) Console->Print("IngameCommand: Sending connected-player-list to charID %d", source->GetCharID()); - Chat->sendConnectedList(source, false); -} diff --git a/server/src/game/gamecommands/settime.cpp b/server/src/game/gamecommands/settime.cpp deleted file mode 100644 index 4d67ed8..0000000 --- a/server/src/game/gamecommands/settime.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" - -void PCommands::doCmdsettime() -{ - if(ArgC < 1 && GetArgInt(1) == 0) - { - Chat->send(source, CHAT_DIRECT, "Usage", "@settime "); - return; - } - - int newtime = 0; - newtime = GetArgInt(1); - - GameServer->SetGameTime(newtime); - Console->Print("IngameCommand: CharID %d set ingametime to %d", source->GetCharID(), newtime); -} diff --git a/server/src/game/gamecommands/speed.cpp b/server/src/game/gamecommands/speed.cpp deleted file mode 100644 index a3a4e58..0000000 --- a/server/src/game/gamecommands/speed.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" - -void PCommands::doCmdspeed() -{ -// Speed override setting. -// Usage: @speed | # -// with = 0 (no move).. 254 , 255 or # meaning "no speed override" - - bool SyntaxError = false; - if(ArgC < 1) - { - SyntaxError = true; - } - - if(SyntaxError == true) - { - Chat->send(source, CHAT_DIRECT, "Usage", "@speed | 255 | #"); - return; - } - char tmpval[30]; - GetArgText(1, tmpval, 30); - - u8 val1; - char effStr[128]; - PMessage* tmpMsg; - - val1 = ((tmpval[0] == '#') ? 255 : (u8)(atoi(tmpval) & 0xff)); - source->GetChar()->SetSpeedOverride(val1); - - tmpMsg = MsgBuilder->BuildCharHelloMsg(source); - ClientManager->UDPBroadcast(tmpMsg, source); - snprintf(effStr, 127, "Speed override set to value %d ", val1); - effStr[127] = '\0'; - Chat->send(source, CHAT_DIRECT, "System", effStr); -} diff --git a/server/src/game/gamecommands/unban.cpp b/server/src/game/gamecommands/unban.cpp deleted file mode 100644 index ce0a0b0..0000000 --- a/server/src/game/gamecommands/unban.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" - -void PCommands::doCmdunban() -{ - Chat->send(source, CHAT_DIRECT, "System", "Unban is not yet possible, sorry."); -} diff --git a/server/src/game/gamecommands/v.cpp b/server/src/game/gamecommands/v.cpp deleted file mode 100644 index 0e8c8e7..0000000 --- a/server/src/game/gamecommands/v.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" - -void PCommands::doCmd_dev_v() -{ - if(IsAdmin() == false) - return; - - char Arg1[30]; - - Arg1[0] = '\0'; - - if(ArgC > 0) - { - GetArgText(1, Arg1, 30); - } - - char tmpStr[128]; - int testmode = 1; // change here only for u8/u16/u32 testvalue use - - if(Arg1[0] != '\0') - { - switch(testmode) - { - case 0: source->testval8 = (u8)(atoi(Arg1) & 0xff); break; - case 1: source->testval16 = (u16)(atoi(Arg1) & 0xffff); break; - case 2: source->testval32 = (u32)(atoi(Arg1) & 0xffffffff); break; - } - } - else - { - source->testval8 = 0; - source->testval16 = 0; - source->testval32 = 0; - } - - switch(testmode) - { - case 0: snprintf(tmpStr, 127, "Test value u8 set to 0x%02x (%d)", source->testval8, source->testval8); break; - case 1: snprintf(tmpStr, 127, "Test value u16 set to 0x%04x (%d)", source->testval16, source->testval16); break; - case 2: snprintf(tmpStr, 127, "Test value u32 set to 0x%08x (%d)", source->testval32, source->testval32); break; - default: tmpStr[0] = '\0'; - } - tmpStr[127] = '\0'; - Chat->send(source, CHAT_DIRECT, "System", tmpStr); - -} diff --git a/server/src/game/gamecommands/version.cpp b/server/src/game/gamecommands/version.cpp deleted file mode 100644 index 104f172..0000000 --- a/server/src/game/gamecommands/version.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "main.h" - -void PCommands::doCmdversion() -{ - char tmpChatMsg[300]; - snprintf(tmpChatMsg, 299, "You are on TinNS server %s runnig version %s - SVN Rev. %s", Config->GetOption("server_name").c_str(), ServerVersion, SVNRevision); - tmpChatMsg[299] = '\0'; - - Chat->send(source, CHAT_DIRECT, "System", tmpChatMsg); -} diff --git a/server/src/game/include/accounts.h b/server/src/game/include/accounts.h deleted file mode 100644 index 92c3402..0000000 --- a/server/src/game/include/accounts.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - accounts.h - - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL - MODIFIED: 26 Dec 2005 Namikon - REASON: - Added load/save functions for SQL DB - MODIFIED: 01 Jan 2005 Namikon - REASON: - Added bool var for ingame debug outputs for administrators - MODIFIED: 06 Jan 2005 Namikon - REASON: - Added SetBannedStatus() to ban/unban an account (use SetBannedStatus(0) to unban a player) - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - -#ifndef ACCOUNTS_H -#define ACCOUNTS_H - -#ifdef _MSC_VER - #pragma once -#endif - -#include "common/regex++.h" - -/* -0 = unregistered user -1 = Registered user -30 = volunteer -50 = GM -100 = Admin -*/ - -// New way of AccountLevel handling: -// Every level is possible, the following values are only edge values. We need a bit control about that -#define PAL_BANNED -1 -#define PAL_UNREGPLAYER 0 -#define PAL_REGPLAYER 1 -#define PAL_VOLUNTEER 30 // Special Rank: 50/50 -#define PAL_GM 50 // Special Rank: 120/120 -#define PAL_ADMIN 100 // Special Rank: 127/127 - -// Max number of char slots per account -#define MAX_CHARS_PER_ACCOUNT 4 - -/* -0 = Offline -1 = Online -2 = Banned -*/ - -enum PAccountStatus -{ - PAS_OFFLINE = 0, - PAS_ONLINE = 1, - PAS_BANNED = 2 -}; - -class PAccount -{ - private : - // SQL Layout - enum { - a_id, - a_username, - a_password, - a_priv, - a_status, - a_bandate - }; - - // static members - static RegEx* mUsernameRegexFilter; - static RegEx* mPasswordRegexFilter; - - // instance members - u32 mID; - std::string mName; - std::string mPassword; - int mLevel; - PAccountStatus mStatus; - std::time_t mBannedUntil; - - bool LoadFromQuery(char* query); - bool DecodePassword(const u8* PasswordData, int PassLen, const u8 *Key, char* ClearPassword); - - public : - PAccount(); - PAccount(const u32 AccountId); - PAccount(const char *Username); - - static bool SetUsernameRegexFilter(const char* RegexStr); - static bool SetPasswordRegexFilter(const char* RegexStr); - static bool IsUsernameWellFormed(const char *Username); - static bool IsPasswordWellFormed(const char *Password); - - inline u32 GetID() const { return mID; } - bool SetName(const std::string &Pass); - inline const std::string &GetName() const { return mName; } - bool SetPassword(const std::string &Pass); - bool SetPasswordEncoded(const u8* PasswordData, int PassLen, const u8 *Key); - inline const std::string &GetPassword() const { return mPassword; } - bool SetLevel(int newLevel); - inline int GetLevel() const { return mLevel; } - std::string GetLevelString() const; - bool SetStatus(PAccountStatus Status); - inline PAccountStatus GetStatus() const { return mStatus; } - bool SetBannedUntilTime(std::time_t BannedUntil); - inline bool IsBanned() const { return (mBannedUntil > std::time(NULL)); } - std::string GetBannedTime() const; - - bool Authenticate(const u8* PasswordData, int PassLen, const u8 *Key); - bool Authenticate(const char *Password) const; - - bool Create(); - bool Save(bool CreateMode = false); - - u32 GetCharIdBySlot(const u32 SlotId); -}; - -#endif - diff --git a/server/src/game/include/appartements.h b/server/src/game/include/appartements.h deleted file mode 100644 index 7978c5d..0000000 --- a/server/src/game/include/appartements.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - appartements.h - appartements class - - MODIFIED: 20 Nov 2006 Hammag - REASON: - creation - -*/ - -#ifndef APPARTEMENTS_H -#define APPARTEMENTS_H - -class PChar; - -class PAppartements -{ - private: - - public: - PAppartements(); - //~PAppartements(); - - u32 CreateBaseAppartement(u32 nCharID, std::string nPassword, u8 nFactionID); - void DeleteCharAppartements(u32 nCharID); - bool CanFreelyEnter(PChar* nChar, u32 nLocation); - int GetAptID(unsigned int AptLoc, const u8 *pass); - int GetAptType(int AptID); - int GetAptOwner(int loc); - int GetAptLocation(int loc); -}; - -#endif diff --git a/server/src/game/include/buddylist.h b/server/src/game/include/buddylist.h deleted file mode 100644 index 5a1f464..0000000 --- a/server/src/game/include/buddylist.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - buddylist.h - classe for chat buddylist - - MODIFIED: 19 Sep 2006 Hammag - REASON: - creation - -*/ - -#ifndef BUDDYLIST_H -#define BUDDYLIST_H - -#define BUDDYLIST_ALLOC_SIZE 4 // atomicity of list entries allocation - -class PBuddyList -{ - private: - enum { // buddy_list DB Table fields - bud_id = 0, - bud_charid, - bud_buddyid - }; - - u32 mOwnerCharID; - u8 mListMaxSize; - u8 mListSize; - u32* mCharIDList; - - void IncreaseMaxSize(u8 nNewMax = 0); - u8 FindEntry(u32 CharID); - - public: - PBuddyList(u32 nOwnerCharID); - ~PBuddyList(); - bool AddChar(u32 nBuddyCharID); - bool RemoveChar(u32 nBuddyCharID); - inline u8 Count() { return mListSize; } - u16 GetListDataSize() { return (sizeof(u32) * mListSize); } - const void* GetListData() { return (const void*)mCharIDList; } - bool SQLLoad(); - - bool IsInBuddy(u32 CharID); -// bool SQLSave(); -}; - -#endif diff --git a/server/src/game/include/chars.h b/server/src/game/include/chars.h deleted file mode 100644 index e3e42d5..0000000 --- a/server/src/game/include/chars.h +++ /dev/null @@ -1,392 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - chars.h - this is the main file with the main function - - Authors: - - Namikon - - Akiko - - MODIFIED: 22 Dec 2005 Namikon - REASON: - Added GPL - MODIFIED: 01 Jan 2006 Namikon - REASON: - Added SQLLoad() function to PChar and PChars - - Added enum for charlist SQL Database - - Added IsOnline var and inline func for Onlinestatus of char - MODIFIED: 26 Jul 2006 Namikon - REASON: - Added Health/MaxHealth, idem for Mana & Stamin - TODO: - fix real current Health vs MaxHealth, also in char load/save - - MODIFIED: 03 Oct 2006 Hammag - REASON: - PChar::CreateNewChar() and moved effective char creation from PChars to PChar - - added PChar::SQLDelete() - This method is put here because we want the char to be loaded when deleted from DB to avoid - any player to use it at the same time. - - added use of auto_save_period config option in PChars::update() - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for new build system - - clean ups -*/ - -#ifndef CHARS_H -#define CHARS_H - -#ifdef _MSC_VER -#pragma once -#endif - -#define MAXCASH 1000000000 - -#include "inventory.h" -#include "buddylist.h" -#include "genreplist.h" -#include "common/regex++.h" -class PVhcAccessRequestList; - -enum PSeatType -{ - seat_none = 0, - seat_chair, - seat_subway, - seat_vhc -}; - -class PCharCoordinates -{ - public: - u16 mY; // Y-Position in world // Y increases when going East - u16 mZ; // Z-Position in world // Z increases when going up - u16 mX; // X-Position in world // X increases when going South - u8 mUD; // Up - Mid - Down (d6 - 80 - 2a) - u8 mLR; // Compass direction (S..E..N..W..S [0-45-90-135-179]) - u8 mAct; // Last user action state - u8 mUnknown;// sometime sent by client with value != 0 (usual case) - // mAct: - // 0x00 NC has no focus (player alt+tab'ed out) - // 0x04 Char on ground/dead 00000100 - // 0x20 Char does nothing 00100000 - // 0x22 kneeing 00100010 - // 0x28 left step 00101000 - // 0x30 right step 00110000 - // 0x40 walking (not running) 01000000 // Seems to mean Running ? - to be verfied, with default walk/run mode !!! - // 0x60 forward 01100000 - // 0xA0 backward 10100000 - // bits: BFWRL.K. - - u8 mJumpingState; - - //inline PCharCoordinates() { mX = mY = mZ = mUD = mLR = mAct = mUnknown = mJumpingState = 0;} - void SetPosition( u16 nY, u16 nZ, u16 nX, u8 nUD = 0x80, u8 nLR = 0 ); - void SetInterpolate( PCharCoordinates& Pos1, PCharCoordinates& Pos2, f32 nCoef ); - - //Temp - u16 minPos[3]; - u16 maxPos[3]; - inline PCharCoordinates() { mX = mY = mZ = mUD = mLR = mAct = mUnknown = mJumpingState = 0; for(int i=0; i<3; ++i) { minPos[i] = 0xffff; maxPos[i] = 0; } } -}; - -class PChar -{ - private : - // static members - static RegEx* mCharnameRegexFilter; - - // instance members - u32 mID; - u32 mAccount; - u8 mSlot; - std::string mName; - u32 mGender; - u32 mClass; - //u32 mType; // Removed that and only keep GetType() - u32 mProfession; - u32 mFaction; - u32 mRealHead; // Base Skin elements, in complement of (computed) mType - u32 mRealTorso; // " Head shouldn't be changeable, except in case of surgery !!! - u32 mRealLegs; // " - u32 mSkin; // Current Skin elements. *** Not saved in DB atm *** - u32 mHead; // " - u32 mTorso; // " - u32 mLegs; // " - u8 mHeadColor; // " - u8 mTorsoColor; // " - u8 mLegsColor; // " - u8 mHeadDarkness; // " // 0=Bright, 255=dark - u8 mTorsoDarkness; // " - u8 mLegsDarkness; // " - // Skin scale factor setting remain to discover, provided they are somewhere for player chars ... - - bool mLocationLeased; // temp until char on-demand load/unload - u32 mLocation; - u32 mCash; - u32 mStartApt; // set same as PrimaryApt atm - u32 mPrimaryApt; - - // not saved in DB atm - PSeatType mSeatInUseType; - u32 mSeatInUseObjectId; - u8 mSeatInUseSeatId; - PVhcAccessRequestList* mVhcAccessRequestList; - - PContainer* mContainerInExclusiveUse; - - u16 mHealth; - u16 mMana; - u16 mStamina; - - s8 mSoullight; - u8 mCombatRank; // *** Not got/saved from DB atm *** - u8 mSynaptic; // *** Not got/saved from DB atm *** - bool mIsDead; // *** Not got/saved from DB atm *** - - // Only one body effect supported atm. Should be extended later to multiple effects - u8 mBodyEffect; // *** Not got/saved from DB atm *** - u8 mBodyEffectDensity; // *** Not got/saved from DB atm *** - - u8 mSpeedOverride; // a hack to control move speed. Not saved in DB - - u32 mDirectCharID; // for Direct Chat // *** Not got/saved from DB atm *** - PBuddyList* mBuddyList; // For Buddy list Chat - u32 mActiveChatChannels; // Active chat channels flags // *** Not got/saved from DB atm *** - - PGenrepList* mGenrepList; // Character's GR list - - u8 mQuickBeltActiveSlot; // QB SlotID of item "in hand", or INV_WORN_QB_HAND or INV_WORN_QB_NONE - - u16 mLookingAt; // Zone charID of currently targeted player - std::time_t mLookAtTimestamp; // Lifetimer of lookat var - u32 mLastUsedWorldObjectId; // Last world object clicked on - - u8 mClanLevel; // 1-15 - u16 mClanID; - - bool mIsOnline; - bool mDirtyFlag; - - bool mShunned; - bool mJailed; - - u32 mDialogNPC; // NPCID the player talks to - u16 mCurrentDialogNode; // Node in .lua file we're at right now - - class PInventory mInventory; - - protected : - friend class PChars; - inline void SetID( u32 ID ) { mID = ID; } - inline void SetAccount( u32 Account ) { mAccount = Account; } - inline void SetCharSlot( u8 Slot ) { if ( Slot < 4 ) mSlot = Slot;} // TODO: set max slot according to server config - inline void SetName( const std::string &Name ) { mName = Name; } - inline void SetGender( u32 Gender ) { mGender = Gender; } - void SetProfession( u32 Profession ); - //inline void SetClass(u32 nClass) { mClass = nClass; } // mClass is defined by setting Profession - //inline void SetType(u32 Type) { mType = Type; } // Removed. Type is computed from Gender & Profession (??? is it not Gender + Class ???) - inline void SetFaction( u32 Faction ) { mFaction = Faction; } - //inline void SetModel(u32 Model) { mModel = Model; } // Inhibited for the moment. Base model is deduced from from Gender & Class (Profession) - void SetRealLook( u32 nHead, u32 nTorso, u32 nLegs ); - void SetBaseSkills(); - void SetBaseSubskills( u8 NZSNb, const char* NonZeroSubskills ); - void SetBaseInventory(); - - bool SQLCreate(); - - public : - PChar(); - ~PChar(); - - static bool SetCharnameRegexFilter( const char* RegexStr ); - static bool IsCharnameWellFormed( const char *Username ); - - PSkillHandler *Skill; - PCharCoordinates Coords; - - void SetCurrentLook( u32 nSkin, u32 nHead = 0, u32 nTorso = 0, u32 nLegs = 0 ); - void SetCurrentLookFromCharType( u32 nType ); - void ResetCurrentLook(); - - void SetCurrentBodyColor( u8 nHeadColor, u8 nTorsoColor, u8 nLegsColor, u8 nHeadDarkness = 0, u8 nTorsoDarkness = 0, u8 nLegsDarkness = 0 ); - inline void SetBodyEffect( u8 nEffect, u8 nDensity = 0 ) { mBodyEffect = nEffect; mBodyEffectDensity = nDensity; } - inline void SetSpeedOverride( u8 nSpeed = 255 ) { mSpeedOverride = nSpeed; } - - void SetLookingAt( u16 nLocalCharID ); - u16 GetLookingAt( u16 nMaxDelaySec = 1 ); - inline void SetLastUsedObject ( u32 nRawItemId ) { mLastUsedWorldObjectId = nRawItemId; } - inline u32 GetLastUsedObject () const { return mLastUsedWorldObjectId; } - - inline PInventory* GetInventory() { return &mInventory; } - inline u32 GetID() const { return mID; } - inline u32 GetAccount() const { return mAccount; } - inline const std::string &GetName() const { return mName; } - inline u32 GetGender() const { return mGender; } - inline u32 GetClass() const { return mClass; } - inline u32 GetType() const { return 2 * mClass + mGender; } - u32 GetSkinFromCharType( u32 nType ); - void GetRealLook( u32 &nSkin, u32 &nHead, u32 &nTorso, u32 &nLegs ); - void GetCurrentLook( u32 &nSkin, u32 &nHead, u32 &nTorso, u32 &nLegs ); - inline void GetBodyEffect( u8 &nEffect, u8 &nDensity ) { nEffect = mBodyEffect; nDensity = mBodyEffectDensity; } - - inline u8 GetQuickBeltActiveSlot() { return mQuickBeltActiveSlot; } - bool SetQuickBeltActiveSlot( u8 nSlotID ); - - void GetCurrentBodyColor( u8 &nHeadColor, u8 &nTorsoColor, u8 &nLegsColor, u8 &nHeadDarkness, u8 &nTorsoDarkness, u8 &nLegsDarkness ); - inline u8 GetSpeedOverride() { return mSpeedOverride; } - inline u32 GetBaseModel(); - inline u32 GetProfession() const { return mProfession; } - inline u16 GetMaxHealth() { return mHealth; } - inline u16 GetMaxMana() { return mMana; } - inline u16 GetMaxStamina() { return mStamina; } - inline u16 GetHealth() { return mHealth; } - inline u16 GetMana() { return mMana; } - inline u16 GetStamina() { return mStamina; } - inline u32 GetFaction() const { return mFaction; } - inline u32 GetLocation() const { return mLocation; } - - inline u32 GetCash() const { return mCash; } - u32 SetCash( u32 nCash ); // Does return the new cashvalue, NO udpmessage is sent out!! - u32 AddCash( u32 nAmount ); - u32 TakeCash( u32 nAmount ); - - inline u32 GetBaseApartment() const { return mPrimaryApt; } - - inline void SetJail( bool val ) { mJailed = val; }; - inline void SetShun( bool val ) { mShunned = val; }; - - inline bool IsJailed() { return mJailed; }; - inline bool IsShunned() { return mShunned; }; - - inline void SetDialogNPC( u32 nNPC ) { mDialogNPC = nNPC; }; - inline u32 GetDialogNPC() const { return mDialogNPC; }; - - inline void SetDialogNode( u16 nNode ) { mCurrentDialogNode = nNode; }; - inline u16 GetDialogNode() const { return mCurrentDialogNode; }; - - inline u8 GetClanLevel() const { return mClanLevel; }; - inline u16 GetClan() const { return mClanID; }; - void LoadClanLevel(); - - inline s8 GetSoullight() const { return mSoullight; } - u8 GetMainRank(); - u8 GetCombatRank(); - inline u8 GetSynaptic() const { return mSynaptic; } - inline bool IsDead() const { return mIsDead; } - - inline bool SetDirectChat( u32 nBuddyCharID ) { mDirectCharID = nBuddyCharID; return true; } - inline u32 GetDirectChat() { return mDirectCharID; } - inline void SetActiveChannels( u32 nChannels ) { mActiveChatChannels = nChannels; } - inline u32 GetActiveChannels() { return mActiveChatChannels; } - - inline bool AddBuddy( u32 nBuddyCharID ) { return mBuddyList->AddChar( nBuddyCharID ); } - inline bool RemoveBuddy( u32 nBuddyCharID ) { return mBuddyList->RemoveChar( nBuddyCharID ); } - inline u16 GetBuddyListDataSize() { return mBuddyList->GetListDataSize(); } - inline const void* GetBuddyListData() { return mBuddyList->GetListData(); } - inline u8 GetBuddyCount() { return mBuddyList->Count(); } - inline bool IsBuddy( u32 CharID ) { return mBuddyList->IsInBuddy( CharID ); }; - - inline bool AddGenrep( u16 nWorldID, u16 nStationID ) { return mGenrepList->AddGenrep( nWorldID, nStationID ); } - inline u16 GetGenrepListDataSize() { return mGenrepList->GetListDataSize(); } - inline const void* GetGenrepListData() { return mGenrepList->GetListData(); } - inline u8 GetGenrepCount() { return mGenrepList->Count(); } - - inline bool IsDirty() const { return mDirtyFlag; } - inline bool IsAnyDirty() const { return mDirtyFlag || mInventory.IsDirty(); } - inline bool IsOnline() { return mIsOnline; } - void SetOnlineStatus( bool IsOnline ); - - bool CreateNewChar( u32 Account, const std::string &Name, u32 Gender, u32 Profession, u32 Faction, - u32 Head, u32 Torso, u32 Legs, u8 NZSNb, const char *NonZeroSubskills, u32 Slot ); - bool SQLLoad( int CharID ); - bool SQLSave(); - inline bool SQLSaveFull() { return SQLSave() && mInventory.SQLSave(); } - bool SQLDelete(); // not implemented yet - - inline void SetLocation( u32 Location ) { mLocation = Location; } - inline void SetDirtyFlag( bool Dirty = true ) { mDirtyFlag = Dirty; } - - // temp until char on-demand load/unload - inline void SetLocationLeased( bool nState = true ) { mLocationLeased = nState; } - inline bool GetLocationLeased() { return mLocationLeased; } - - PSeatType GetSeatInUse( u32* nObjectId = NULL, u8* nSeatId = NULL ); - void SetSeatInUse( PSeatType nSeatType, u32 nObjectId = 0, u8 nSeatId = 0 ); - - PVhcAccessRequestList* GetVhcAccessRequestList(); - - inline PContainer* GetContainerInExclusiveUse() { return mContainerInExclusiveUse; } - inline void SetContainerInExclusiveUse( PContainer* nContainer ) { mContainerInExclusiveUse = nContainer; } -}; - -struct PCharProfile -{ - u32 CharID; - u16 Type; - u16 Color0; - u16 Unknown1; - u8 Head; - u8 Torso; - u8 Legs; - u32 Location; - u8 NameLen; - u8 Unknown3; - u8 Unknown4; - u8 Unknown5; - u8 Unknown6; - u8 Unknown7; - u8 Unknown8; - u8 Unknown9; - u8 Unknown10; - u8 Unknown11; - u8 Unknown12; - std::string Name; - bool in_use; -}; - -class PChars -{ - private : - typedef std::map CharMap; - CharMap mChars; - u32 mLastID; - - std::time_t mAutoSavePeriod; - std::time_t mLastSave; - - public : - PChars(); - ~PChars(); - - bool LoadChar( u32 CharID ); - bool AddChar( PChar* nChar ); - PChar* RemoveChar( u32 CharID ); - - PChar* GetChar( u32 CharID ) const; - PChar* GetChar( const std::string &Name ) const; - bool CharExist( const std::string &Name ) const; - - void SQLSave(); - void Update(); - - int GetCharProfiles( const u32 AccountID, PCharProfile* CharSlotsArray, const u8 ArraySize ); // return effective entries nb -}; - -#endif diff --git a/server/src/game/include/chat.h b/server/src/game/include/chat.h deleted file mode 100644 index 80595c5..0000000 --- a/server/src/game/include/chat.h +++ /dev/null @@ -1,198 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - chat.h - - Authors: - - Namikon - - bakkdoor - - MODIFIED: 30 Nov 2005 Namikon/Akiko - REASON: - initial release by Namikon - - MODIFIED: 11 Dec 2005 Namikon - REASON: - Added function SendDChat(Client, , ) to send a Direct to player - - Added Channel IDs for GameMaster (/gm) and Administrator (/admin) chat - - Added channel const's for sending chat packets - - Added function SendChat(Client, , , ) to send chat messages - For , use one of the u8 constants listet below - - MODIFIED: 17 Dec 2005 bakkdoor - REASON: - introduced new structure for chatsystem - - -> PChat class -*/ - -#ifndef CHAT_H -#define CHAT_H -#define LOCALCHAT_MAXDISTANCE 1433 - -class PChat -{ - private: - - public: - PChat(); - ~PChat(); - - // INCOMING CHAT - bool HandleGameChat(PClient *Client, const u8 *Packet); - bool cmpr(const u8 *Array1, const u8 *Array2); - - // this function is called by the other more specific functions and simply sends the data to the receiver-client - bool send(PClient* receiver, const u8* Channel, const char* AuthorNickName, const char* text, bool debugOut=false); - - // this is for debugging and sends the current connected playerlist to the receiver-client - void sendConnectedList(PClient* receiver, bool debugOut=false); - - // specific channel functions: - void sendBuddy(PClient* author, const char* text, bool debugOut=false); - void sendLocal(PClient* author, const char* text, bool debugOut=false); - void sendClan(PClient* author, const char* text, bool debugOut=false); - void sendTeam(PClient* author, const char* text, bool debugOut=false); - void sendDirect(PClient* author, PClient* receiver, const char* text, bool debugOut=false); - void sendZone(PClient* author, const char* text, bool debugOut=false); - void sendFrak(PClient* author, const char* text, bool debugOut=false); - void sendTradeCS(PClient* author, const char* text, bool debugOut=false); - void sendTradeMB(PClient* author, const char* text, bool debugOut=false); - void sendTradeNC(PClient* author, const char* text, bool debugOut=false); - void sendTradeTH(PClient* author, const char* text, bool debugOut=false); - void sendTradeWL(PClient* author, const char* text, bool debugOut=false); - void sendOOC(PClient* author, const char* text, bool debugOut=false); - void sendHelp(PClient* author, const char* text, bool debugOut=false); - void sendClanSearch(PClient* author, const char* text, bool debugOut=false); - void sendServicesCS(PClient* author, const char* text, bool debugOut=false); - void sendServicesMB(PClient* author, const char* text, bool debugOut=false); - void sendServicesNC(PClient* author, const char* text, bool debugOut=false); - void sendServicesTH(PClient* author, const char* text, bool debugOut=false); - void sendServicesWL(PClient* author, const char* text, bool debugOut=false); - void sendTeam10(PClient* author, const char* text, bool debugOut=false); - void sendTeam30(PClient* author, const char* text, bool debugOut=false); - void sendTeam50(PClient* author, const char* text, bool debugOut=false); - void sendTeam70(PClient* author, const char* text, bool debugOut=false); - void sendAdmin(PClient* author, const char* text, bool debugOut=false); - void sendGM(PClient* author, const char* text, bool debugOut=false); - void sendGMAdmin(PClient* author, const char* text, bool debugOut=false); - - void sendBroadcast(const char* text, bool debugOut=false); - void sendOOCBroadcast(const char* text, bool debugOut=false); - void sendPlayerDirect(PClient* author, const char* text, u32 destination, bool debugOut=false); - void sendLocalchat(PClient* receiver, PClient* author, const char* text, bool debugOut=false); - bool chanEnabled(PClient* Client, u32 channel); - -}; - -/** A WARNING: DO >N O T< (!!!) CHANGE >ANY< OF THE FOLLOWING VARIABLES UNLESS YOU KNOW EXACT WHAT YOU'RE DOING! **/ -/** You can easily mess up the entire chat subsystem. If you're unsure, ask Namikon first! **/ -/* -#################### - CHANNEL-CODES: - (INCOMING) -#################### -*/ -static const u32 CHANNEL_BUDDY = 0x00000000; // Buddy -static const u32 CHANNEL_CLAN = 0x00000002; // Clan -static const u32 CHANNEL_TEAM = 0x00000003; // Team -static const u32 CHANNEL_DIRECT = 0xFFFFFFFF; // Direct UNKNOWN YET -static const u32 CHANNEL_CUS_ZONE = 0x00000105; // Custom -> Zone -static const u32 CHANNEL_CUS_FRAKTION = 0x00000205; // Custom -> Fraktion -static const u32 CHANNEL_CUS_TRADE_CANYON = 0x00002005; // Custom -> Trade Canyon -static const u32 CHANNEL_CUS_TRADE_MB = 0x00000805; // Custom -> Trade MB -static const u32 CHANNEL_CUS_TRADE_NC = 0x00000405; // Custom -> Trade NC -static const u32 CHANNEL_CUS_TRADE_TH = 0x00001005; // Custom -> Trade TH -static const u32 CHANNEL_CUS_TRADE_WASTE = 0x00004005; // Custom -> Trade Wastelands -static const u32 CHANNEL_CUS_OOC = 0x04000005; // Custom -> OOC -static const u32 CHANNEL_CUS_PLAYERHELP = 0x02000005; // Custom -> Player 2 Player help -static const u32 CHANNEL_CUS_CLANSEARCH = 0x01000005; // Custom -> Searching Clan -static const u32 CHANNEL_CUS_SERVICES_CANYON = 0x00040005; // Custom -> Runner Services Canyon -static const u32 CHANNEL_CUS_SERVICES_MB = 0x00010005; // Custom -> Runner Services MB -static const u32 CHANNEL_CUS_SERVICES_NC = 0x00008005; // Custom -> Runner Services NC -static const u32 CHANNEL_CUS_SERVICES_TH = 0x00020005; // Custom -> Runner Services TH -static const u32 CHANNEL_CUS_SERVICES_WASTE = 0x00080005; // Custom -> Runner Services Wastelands -static const u32 CHANNEL_CUS_TEAM_10 = 0x00100005; // Custom -> Searching Team ~10 -static const u32 CHANNEL_CUS_TEAM_30 = 0x00200005; // Custom -> Searching Team ~30 -static const u32 CHANNEL_CUS_TEAM_50 = 0x00400005; // Custom -> Searching Team ~50 -static const u32 CHANNEL_CUS_TEAM_70 = 0x00800005; // Custom -> Searching Team ~70 -static const u32 CHANNEL_ADMIN = 0x000000FF; // Admin chat -static const u32 CHANNEL_GMADMIN = 0x000000FE; // Admin chat -static const u32 CHANNEL_GMCHAT = 0x000000FD; // GameMaster chat -/* -#################### - CHANNEL-CODES: - (OUTGOING) -#################### -*/ -static const u8 CHAT_BUDDY[] = {0x00, 0x10}; -static const u8 CHAT_LOCAL[] = {0x01, 0x10}; -static const u8 CHAT_CLAN[] = {0x02, 0x10}; -static const u8 CHAT_TEAM[] = {0x03, 0x10}; -static const u8 CHAT_DIRECT[] = {0x04, 0x10}; -static const u8 CHAT_ZONE[] = {0x05, 0x00}; -static const u8 CHAT_FRAK[] = {0x05, 0x01}; -static const u8 CHAT_TRADECS[] = {0x05, 0x05}; -static const u8 CHAT_TRADEMB[] = {0x05, 0x03}; -static const u8 CHAT_TRADENC[] = {0x05, 0x02}; -static const u8 CHAT_TRADETH[] = {0x05, 0x04}; -static const u8 CHAT_TRADEWL[] = {0x05, 0x06}; -static const u8 CHAT_OOC[] = {0x05, 0x12}; -static const u8 CHAT_HELP[] = {0x05, 0x11}; -static const u8 CHAT_CLANSEARCH[] = {0x05, 0x10}; -static const u8 CHAT_SERVICECS[] = {0x05, 0x0A}; -static const u8 CHAT_SERVICESMB[] = {0x05, 0x08}; -static const u8 CHAT_SERVICESNC[] = {0x05, 0x07}; -static const u8 CHAT_SERVICESTH[] = {0x05, 0x09}; -static const u8 CHAT_SERVICESWL[] = {0x05, 0x0B}; -static const u8 CHAT_TEAM10[] = {0x05, 0x0C}; -static const u8 CHAT_TEAM30[] = {0x05, 0x0D}; -static const u8 CHAT_TEAM50[] = {0x05, 0x0E}; -static const u8 CHAT_TEAM70[] = {0x05, 0x0F}; -static const u8 CHAT_ADMIN[] = {0xFF, 0x10}; -static const u8 CHAT_GMADMIN[] = {0xFE, 0x10}; -static const u8 CHAT_GM[] = {0xFD, 0x10}; - -/* -#################### - CHANNEL-CODES: -(EN/DISABLE-ABLE CHANNELS) -#################### -*/ -static const u32 C_ZONE = 1; -static const u32 C_FRAK = 2; -static const u32 C_TRADENC = 4; -static const u32 C_TRADEMB = 8; -static const u32 C_TRADETH = 16; -static const u32 C_TRADECS = 32; -static const u32 C_TRADEWL = 64; -static const u32 C_SERVICENC = 128; -static const u32 C_SERVICEMB = 256; -static const u32 C_SERVICETH = 512; -static const u32 C_SERVICECS = 1024; -static const u32 C_SERVICEWL = 2048; -static const u32 C_TEAM10 = 4096; -static const u32 C_TEAM30 = 8192; -static const u32 C_TEAM50 = 16384; -static const u32 C_TEAM70 = 32768; -static const u32 C_CLANSEARCH = 65536; -static const u32 C_HELP = 131072; -static const u32 C_OOC = 262144; -#endif diff --git a/server/src/game/include/client.h b/server/src/game/include/client.h deleted file mode 100644 index 832eb25..0000000 --- a/server/src/game/include/client.h +++ /dev/null @@ -1,228 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - client.h - - Authors: - - v00d00 - - Akiko - - Namikon - - bakkdoor - - MODIFIED: 30 Nov 2005 Akiko - REASON: - added GPL - - added stuff from Namikon - MODIFIED: 13 Dec 2005 bakkdoor - REASON: - added multiuser chat - MODIFIED: 27 Jul 2006 Hammag - REASON: - added mTransactionID member - - re-added IncreaseUDP_ID() // but I don't understand well what SetUDP_ID() does ... - MODIFIED: 05 Aug 2006 Hammag - REASON: - changed TMP_UDP_PORT/SetTMPUDPPort()/GetTMPUDPPort() to mRemotePort/SetRemoteUDPPort()/GetRemoteUDPPort() - which corresponds to the real purpose of these members - - added GetID() as an alias os GetIndex() for better coherency with other classes - MODIFIED: 09 Oct 2006 Hammag - REASON: - added GetDebugMode() and SetDebugMode() methods - - - TODO: - check that SetUDP_ID, and the mSessionID(UDP_ID_HIGH) real use, - and if UDP_ID and mSessionID must be synced (like in NeoX) or not - -*/ - -#ifndef CLIENT_H -#define CLIENT_H - -enum PClientConnection -{ - PCC_NONE = 0, - PCC_GAME = 1 -}; - -// AccountLevel handling is part of accounts.cpp -/* -enum PClientLevel -{ - PCL_BANNED = -1, - PCL_UNREGPLAYER = 0, - PCL_REGPLAYER = 1, - PCL_VOLUNTEER = 30, - PCL_GM = 50, - PCL_ADMIN = 100 -}; -*/ -#define DEBUG_MODES 3 -enum PDebugMode -{ - DBG_LOCATION = 0, - DBG_ITEMID = 1, - DBG_SUBWAY = 2, - DBG_ALL = DEBUG_MODES // must always be last, with DEBUG_MODES updated as needed -}; - - -class PClient -{ - private : - ConnectionTCP* m_TCPConnection; - ConnectionUDP* m_UDPConnection; - - u32 mAccountID; - int mAccountLevel; - u32 mIndex; - u32 mCharID; - -// u16 mUDP_ID; -// u16 mSessionID; -// u16 mTransactionID; - - // AccountLevel handling is part of accounts.cpp - //PClientLevel mLevel; - int mConnection; - int mRemotePort; - - bool mDebugMode[DEBUG_MODES]; - // new multiuser-chat implementation // - int m_ZoneID; - //int[4] m_IP; - - //******* - bool mActorRemoveMode; - //******* - bool mAwaitingWarpto; - u16 mTargetX; - u16 mTargetY; - u16 mTargetZ; - //******* - bool mAcceptNPCUpdates; - bool mZoning; - bool mVhcZoning; - - - protected : - public : - PClient( int Index ); - ~PClient(); - - inline bool GetDebugMode( PDebugMode nDebugID ) { return mDebugMode[nDebugID]; } - void SetDebugMode( PDebugMode nDebugID, bool nVal = true ); - - inline bool IsAcceptingNPCUpdates() { return mAcceptNPCUpdates; } - inline void SetAcceptNPCUpdates( bool nVal ) { mAcceptNPCUpdates = nVal; } - inline bool IsZoning() { return mZoning; } - inline void SetZoning( bool nVal = true ) { mZoning = nVal; if ( !nVal ) mVhcZoning = false; } - inline bool IsVhcZoning() { return mVhcZoning; } - inline void SetVhcZoning( bool nVal = true ) { mVhcZoning = nVal; } - - inline u32 GetIndex() const { return mIndex; } // better use GetID() - inline u32 GetID() const { return mIndex; } // for better coherency with other classes - inline u32 GetLocalID() const { return mIndex + 1; } - inline u32 GetCharID() const { return mCharID; } - PChar* GetChar() const; - bool ChangeCharLocation( u32 nLocation, bool DoForce = false ); - - inline int GetRemoteUDPPort() const { return mRemotePort; } // Temp solution - - inline bool IsInRemoveActorMode() { return mActorRemoveMode; } - inline void SetRemoveActorMode( bool nNewValue ) { mActorRemoveMode = nNewValue; } - - inline void SetRemoteUDPPort( int port ) { mRemotePort = port; } // Temp solution - inline void SetCharID( int id ) { mCharID = id; }//NEW added - - /* - inline u16 GetUDP_ID() const { return mUDP_ID; } - inline u16 GetSessionID() const { return SESSION_UDP_OFFSET + mUDP_ID ; } - inline u16 GetTransactionID() {return mTransactionID; } - void SetUDP_ID(int id); - inline void IncreaseUDP_ID() { SetUDP_ID(mUDP_ID + 1); } - inline void ResetTransactionID() { mTransactionID = 10170; } - - inline void IncreaseTransactionID(u8 nInc = 1) { mTransactionID += nInc; } - */ - - // All outgoing ID's and stuff is now part of the ConnectionUDP class itself! - // (which is not so good.... comment from Hammag) - // However, we still have full access to it through these functions - u16 GetUDP_ID(); - void SetUDP_ID( int id ); - void IncreaseUDP_ID(); - - u16 GetSessionID(); - - u16 GetTransactionID(); - void ResetTransactionID(); - void IncreaseTransactionID( u8 nInc = 1 ); - - void FillInUDP_ID( PMessage* nMessage ); - -// ************************************************************************ // - // AccountLevel handling is part of accounts.cpp - //inline PClientLevel GetLevel() const { return mLevel; } - - inline void setTCPConnection( ConnectionTCP* conn ) { m_TCPConnection = conn; m_UDPConnection = 0; mConnection = PCC_GAME; } - inline void setUDPConnection( ConnectionUDP* conn ) { m_UDPConnection = conn; } - - inline ConnectionTCP* getTCPConn() { return m_TCPConnection; } - inline ConnectionUDP* getUDPConn() { return m_UDPConnection; } - - inline void SendTCPMessage( PMessage* nMessage ) { if ( m_TCPConnection ) { m_TCPConnection->SendMessage( nMessage ); } else { delete nMessage; } } - void FragmentAndSendUDPMessage( PMessage* nMessage, u8 nType ); - inline void SendUDPMessage( PMessage* nMessage, bool nVIP = false ) { if ( m_UDPConnection ) { m_UDPConnection->SendMessage( nMessage, nVIP ); } else { delete nMessage; } } - - inline int GetConnection() const { return mConnection; } - inline const char *GetAddress() const { return m_TCPConnection->getRemoteAddress(); } - inline u32 GetAccountID() const { return mAccountID; } - inline int GetAccountLevel() const { return mAccountLevel; } - - void GameDisconnect(); - - void RefreshAccountInfo( PAccount* Account ); - inline void LoggedIn( PAccount* Account ) { RefreshAccountInfo( Account ); } - void Update(); - - // new multiuser-chat implementation // - inline int getZoneID() const { return m_ZoneID; } // example: canyon 650 (for local-channel...every client with same AreaID get the chatmsg) - //inline int* getIP() const { return (int*) m_IP; } - - inline void SetAwaitingWarpto( bool yesno, u16 NewX, u16 NewY, u16 NewZ ) - { - mAwaitingWarpto = yesno; - mTargetX = NewX; - mTargetY = NewY; - mTargetZ = NewZ; - } - bool GetCharAwaitingWarpto( u16* PosX = NULL, u16* PosY = NULL, u16* PosZ = NULL ); - - // Char broadcasted effects - void InitWarpCircle(); - void InitCharVanish(); - - // used for dynamic ingame testing - u8 testval8; - u16 testval16; - u32 testval32; -}; - -#endif - diff --git a/server/src/game/include/clientmanager.h b/server/src/game/include/clientmanager.h deleted file mode 100644 index 6f6cb77..0000000 --- a/server/src/game/include/clientmanager.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - clientmanager.h - - Authors: - - bakkdoor - - MODIFIED: 13 Dec 2005 bakkdoor - REASON: - introduced - MODIFIED: 29 Jul 2006 Hammag - REASON: - added UDP broadcast fonction - - added "zone players say Hello" fonction - - changed type ClientMap to PClientMap, changed members name prefix m_ to m - - MODIFIED: 12 Aug 2006 Hammag - REASON: - duplicated UDPBroadcast() in two prototypes - -*/ - -#ifndef CLIENTMANAGER_H -#define CLIENTMANAGER_H - -typedef std::map PClientMap; - -class PClientManager -{ - private: - //int mLastID; - PClientMap mClientList; - - public: - PClientManager(); - ~PClientManager(); - - PClientMap::iterator getClientListBegin() { return mClientList.begin(); } - PClientMap::iterator getClientListEnd() { return mClientList.end(); } - - bool addClientToList( PClient* newClient ); - //void deleteClientFromListByID(int id); - void deleteClientFromList( u32 id ); - //bool deleteClientFromList(PClient* delClient); // maybe no use for this... - PClient* getClientByID( u32 u32 ) const; // returns pointer to a client for further use - PClient* getClientByChar( u32 CharID ) const; - PClient* getClientByChar( const std::string &Name ) const; - // int getClientID(PClient* _client); do _client->GetLocalID() - bool IsWorldInUse( u32 nWorldID ) const; // Temp until world content fully managed by world - PClient* GetClientByCharLocalId( u32 rawObjectId, u32 nWorldID ) const; // Temp (called by world) until world content fuly managed by world - - // each function return the number of messages sent. - int UDPBroadcast( PMessage* nMessage, u32 nZoneID, u16 nX = 0, u16 nY = 0, u16 nZ = 0, u16 nMaxDist = 0, u32 nSkipCharId = 0, bool nNPCPing = false ); - int UDPBroadcast( PMessage* nMessage, PClient* nClient, u16 nMaxDist = 0, bool nSkipSource = false, bool nNPCPing = false ); - int SendUDPZoneWelcomeToClient( PClient* nClient ); - -}; - -#endif - diff --git a/server/src/game/include/container.h b/server/src/game/include/container.h deleted file mode 100644 index aae6f87..0000000 --- a/server/src/game/include/container.h +++ /dev/null @@ -1,232 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - container.h - base classe for containers - - - MODIFIED: 28 Jul 2008 Hammag - REASON: - creation - -*/ - -#ifndef CONTAINER_H -#define CONTAINER_H - -#define CONTAINER_MAX_SIZE 254 - -class PItem; - -class PContainerEntry -{ - friend class PContainer; - friend class PContainer2D; - friend class PMsgBuilder; - - friend class PContainer2DWorkaround; - - private: - enum { - i_invid = 0, - i_charid, - i_invloc, - i_x, - i_y, - i_itemid, - //i_type, - i_flag, - i_qty, - i_sqty, - i_curdur, - i_dmg, - i_freq, - i_hand, - i_rng, - i_maxdur, - i_slots, - i_slt1, - i_slt2, - i_slt3, - i_slt4, - i_slt5, - i_atype, - i_conatin - }; - - PItem* mItem; - u8 mPosX; - u8 mPosY; - u32 mInvID; - bool mDirtyFlag; - - PContainerEntry(PItem* nItem, u8 X, u8 Y, u32 nInvID = 0, bool SetDirty = true); - PContainerEntry(MYSQL_ROW row); - - bool SQLSave(u32 CharID, u32 InvLoc); - bool SQLDelete(); - - inline void Set2DPos(u8 nPosX, u8 nPosY) { mDirtyFlag = mDirtyFlag || (mPosX != nPosX) || (mPosY != nPosY) ; mPosX = nPosX; mPosY = nPosY; } - - public: - ~PContainerEntry(); - - inline void Get2DPos(u8* oPosX, u8* oPosY) { *oPosX = mPosX; *oPosY = mPosY; } -}; - - - -class PContainer // Holes allowed, no autofind free slots -{ - protected: - u8 mMaxSlots; - std::vector< PContainerEntry* >* mContContent; - u32 mCharID; - u32 mInvLoc; - u32 mExclusiveUseCharID; - bool mDirtyFlag; - - inline bool IsSlotAllowed(u8 nSlotId) { return ((nSlotId < CONTAINER_MAX_SIZE) && (!mMaxSlots || (nSlotId < mMaxSlots))); } - virtual bool AddEntry(PContainerEntry* NewEntry, u8 nSlotId = 0); - virtual PContainerEntry* RemoveEntry(u8 nSlotId); - virtual bool GetFreeSlot(u8* nSlotId); - void Compact(u8 startSlotId = 0); - - public: - PContainer(u8 nMaxSlots = 0); - virtual ~PContainer(); - - inline void SetInfo(u32 CharID, u32 InvLoc) { mCharID = CharID; mInvLoc = InvLoc; } - inline u32 GetOwnerId() { return mCharID; } - - inline bool IsDirty() { return mDirtyFlag; } - inline void SetDirty() { mDirtyFlag = true; } - - bool StartUse(u32 nExclusiveUseCharID = 0); - virtual bool EndUse(u32 nExclusiveUseCharID = 0); - - bool SQLLoad(); - bool SQLSave(); - - bool IsSlotFree(u8 nSlotId); - virtual bool AddItem(PItem* NewItem, u32 nInvID = 0, u8 nPosX = 0, u8 nPosY = 0, bool SetDirty = true); - - virtual bool MoveItem(u8 srcSlotId, u8 nCount, u8 dstSlotId); - bool MoveItem(u8 srcSlotId, u8 nCount, PContainer* dstContainer, u8 dstSlotId = 0, u8 nPosX = 0, u8 nPosY = 0); - virtual void SetEntryPosXY(PContainerEntry* nEntry, u8 nSlotId, u8 nPosX = 0, u8 nPosY = 0); - - virtual u8 RandomFill(u8 nItemCount = 0, int nItemContainerDefIndex = -1); - - PContainerEntry* GetEntry(u8 nSlotId); - std::vector< PContainerEntry* >* GetEntries(); - PItem* GetItem(u8 nSlotId); - - virtual void Dump(); -}; - - -class PContainerWithHoles : public PContainer // Holes allowed, no autofind free slots -{ - public: - PContainerWithHoles(u8 nMaxSlots = 0) : PContainer(nMaxSlots){ nMaxSlots = nMaxSlots; } - virtual ~PContainerWithHoles() {} -}; - - -class PContainerAutoCompact : public PContainer // No holes allowed, automatic add to end slot (no control on insertion slot) -{ - protected: - virtual PContainerEntry* RemoveEntry(u8 nSlotId); - virtual bool GetFreeSlot(u8* nSlotId); - - public: - PContainerAutoCompact(u8 nMaxSlots = 0) : PContainer(nMaxSlots){ nMaxSlots = nMaxSlots; } - virtual ~PContainerAutoCompact() {} - - virtual bool MoveItem(u8 srcSlotId, u8 nCount, u8 dstSlotId); -}; - - -class PContainer2D : public PContainerAutoCompact // + slotId not used, non-significant XY used (no XY check yet) -{ - public: - PContainer2D(u8 nMaxSlots = 0) : PContainerAutoCompact(nMaxSlots){ nMaxSlots = nMaxSlots; } - virtual ~PContainer2D() {} - - virtual void SetEntryPosXY(PContainerEntry* nEntry, u8 nSlotId, u8 nPosX = 0, u8 nPosY = 0); -}; - -class PContainer2DWorkaround : public PContainerWithHoles // Holes allowed, autofind free slot (always increasing id) -{ - private: - u8 mNextFreeSlot; - std::vector< std::vector* > mContSpace; - u8 mMaxCols; - u8 mMaxRows; - u8 mRows; - - void AddRow(); - - inline bool Is2DPosAllowed(u8 PosX, u8 PosY, u8 SizeX, u8 SizeY) - { - return ((PosX < mMaxCols-SizeX+1) && (PosY < mMaxRows-SizeY+1)); - } - bool Is2DFree(u8 PosX, u8 PosY, u8 SizeX, u8 SizeY); - bool FindValid2DPos(PContainerEntry* nEntry); - - - protected: - bool AddEntry(PContainerEntry* NewEntry, u8 nSlotId = 0); - PContainerEntry* RemoveEntry(u8 nSlotId); - bool GetFreeSlot(u8* nSlotId); - - public: - PContainer2DWorkaround(u8 nMaxSlots = 0); - ~PContainer2DWorkaround(); - - bool MoveItem(u8 srcSlotId, u8 nCount, u8 dstSlotId); - - void Set2DPosMax(u8 MaxPosX, u8 MaxPosY = 254) { mMaxCols = MaxPosX; mMaxRows = MaxPosY; } - void SetEntryPosXY(PContainerEntry* nEntry, u8 nSlotId, u8 nPosX = 0, u8 nPosY = 0); - void SetUsed(PContainerEntry* nEntry, bool Value = true); - void Dump(); -}; - -class PContainerAutoFindFree : public PContainerWithHoles // No holes kept after EndUse, automatic find first free slots (no control on insertion slot) -{ - protected: - virtual bool GetFreeSlot(u8* nSlotId); - - public: - PContainerAutoFindFree(u8 nMaxSlots = 0) : PContainerWithHoles(nMaxSlots){ nMaxSlots = nMaxSlots; } - virtual ~PContainerAutoFindFree() {} -}; - -class PContainerAutoCompactOnClose : public PContainerAutoFindFree // No holes kept after EndUse, automatic find first free slots (no control on insertion slot) -{ - public: - PContainerAutoCompactOnClose(u8 nMaxSlots = 0) : PContainerAutoFindFree(nMaxSlots){ nMaxSlots = nMaxSlots; } - virtual ~PContainerAutoCompactOnClose() {} - - virtual bool EndUse(u32 nExclusiveUseCharID = 0); -}; - -#endif diff --git a/server/src/game/include/def.h b/server/src/game/include/def.h deleted file mode 100644 index ed95d6f..0000000 --- a/server/src/game/include/def.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - def.h - - CREATED: 03 Apr 2009 Hammag -*/ - -#ifndef DEF_H -#define DEF_H - -extern const std::string EmptyString; - -/* mother class for PDef* classes */ -/* provides default members required for def file loading */ -class PDef -{ - protected : - int mIndex; - - public : - PDef() : mIndex(0) {}; - //~PDef() {}; - - inline bool LoadFromDef( PTokenList *Tokens ) { Tokens = Tokens; return false; }; - - inline int GetIndex() const { return mIndex; } - inline const std::string &GetName() const { return EmptyString; } -}; - -#endif - diff --git a/server/src/game/include/def_actionmod.h b/server/src/game/include/def_actionmod.h deleted file mode 100644 index 277f620..0000000 --- a/server/src/game/include/def_actionmod.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - def_actionmod.h - - CREATED: 31 Mar 2009 Hammag -*/ - -#ifndef DEF_ACTIONMOD_H -#define DEF_ACTIONMOD_H - -#include "def.h" - -class PDefActionMod : public PDef -{ - private : - //int mIndex; - float mStartValue; - int mNumOfSsq; - int mSsqId[8]; - float mModFactor[8]; - - public : - PDefActionMod(); - //~PDefActionMod(); - - bool LoadFromDef( PTokenList *Tokens ); - - inline float GetStartValue() const { return mStartValue; } - inline int GetNumOfSsq() const { return mNumOfSsq; } - inline int GetSsqId(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < mNumOfSsq)) ? mSsqId[nIdx] : 0) ; } - inline float GetModFactor(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < mNumOfSsq)) ? mModFactor[nIdx] : 0) ; } -}; - -#endif diff --git a/server/src/game/include/def_ammo.h b/server/src/game/include/def_ammo.h deleted file mode 100644 index a9425e5..0000000 --- a/server/src/game/include/def_ammo.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - def_ammo.h - - CREATED: 02 Apr 2009 Hammag -*/ - -#ifndef DEF_AMMO_H -#define DEF_AMMO_H - -#include "def.h" - -class PDefAmmo : public PDef -{ - private : - //int mIndex; - int mDamageId; // related to damage.def - int mWeaponShotId; // related to shots.def ? - int mMagSize; - int mShotId; // related to shots.def ??? strange: hardly ever set in ammo.def - - public : - PDefAmmo(); - //~PDefAmmo(); - - bool LoadFromDef( PTokenList *Tokens ); - - inline int GetDamageId() const { return mDamageId; } - inline int GetWeaponShotId() const { return mWeaponShotId; } - inline int GetMagSize() const { return mMagSize; } - inline int GetShotId() const { return mShotId; } -}; - -#endif diff --git a/server/src/game/include/def_appartements.h b/server/src/game/include/def_appartements.h deleted file mode 100644 index fd8f93b..0000000 --- a/server/src/game/include/def_appartements.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_appartements.h - - MODIFIED: 22 Sep 2006 Hammag - REASON: - Creation - -*/ - -#ifndef DEF_APPARTEMENTS_H -#define DEF_APPARTEMENTS_H - -#include "def.h" - -class PDefAppartement : public PDef -{ - private : - //int mIndex; - std::string mName; - std::string mWorldName; - int mValue; - int mPlaceCount; - int mPlace[8]; - int mFaction; - - public : - PDefAppartement(); - //~PDefAppartement(); - - bool LoadFromDef(PTokenList *Tokens); - - inline int GetID() const { return mIndex; } - inline const std::string &GetName() const { return mName; } - inline const std::string &GetWorldName() const { return mWorldName; } - inline int GetValue() const { return mValue; } - inline int GetPlaceCount() const { return mPlaceCount; } - inline int GetPlace(int nIdx) const { return ( (nIdx < mPlaceCount) ? mPlace[nIdx] : 0 ); } - inline int GetFaction() const { return mFaction; } -}; - - -class PDefAppartementsMap : public PDefMap -{ - public: - inline std::map::const_iterator ConstIteratorBegin() const { return mDefs.begin(); } - inline std::map::const_iterator ConstIteratorEnd() const { return mDefs.end(); } -}; - -#endif diff --git a/server/src/game/include/def_appplaces.h b/server/src/game/include/def_appplaces.h deleted file mode 100644 index ce35c33..0000000 --- a/server/src/game/include/def_appplaces.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - -/* - def_appplaces.h - - Created: 21 Sep 2006 Hammag - REASON: - -*/ - -#ifndef DEF_APPPLACES_H -#define DEF_APPPLACES_H - -#include "def.h" - -class PDefAppPlace : public PDef -{ - private : - //int mIndex; - std::string mName; - int mExitWorldID; - int mExitWorldEntity; - int mSewerLevel; - - public : - PDefAppPlace(); - //~PDefAppPlace(); - - bool LoadFromDef(PTokenList *Tokens); - - inline const std::string &GetName() const { return mName; } - inline int GetExitWorldID() const { return mExitWorldID; } - inline int GetExitWorldEntity() const { return mExitWorldEntity; } - inline int GetSewerLevel() const { return mSewerLevel; } - -}; - -#endif diff --git a/server/src/game/include/def_blueprintpieces.h b/server/src/game/include/def_blueprintpieces.h deleted file mode 100644 index c08fceb..0000000 --- a/server/src/game/include/def_blueprintpieces.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_blueprintpieces.h - - CREATED: 31 Mar 2009 Hammag -*/ - -#ifndef DEF_BLUEPRINTPIECES_H -#define DEF_BLUEPRINTPIECES_H - -#include "def.h" - -class PDefBlueprintPieces : public PDef -{ - private : - //int mIndex; // related Item Type - int mMaxPieceNum; - int mPieceNum; - int mPieceId[20]; - - public : - PDefBlueprintPieces(); - //~PDefBlueprintPieces(); - - bool LoadFromDef( PTokenList *Tokens ); - - inline int GetMaxPieceNum() const { return mMaxPieceNum; } - inline int GetPieceNum() const { return mPieceNum; } - inline int GetPieceId(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < mPieceNum)) ? mPieceId[nIdx] : 0) ; } -}; - -#endif diff --git a/server/src/game/include/def_characters.h b/server/src/game/include/def_characters.h deleted file mode 100644 index ac83801..0000000 --- a/server/src/game/include/def_characters.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_characters.h - - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL - - MODIFIED: 29 Jul 2006 Hammag - REASON: - Added skin modifiers fields -*/ - -#ifndef DEF_CHARACTERS_H -#define DEF_CHARACTERS_H - -#include "def.h" - -class PDefCharacter : public PDef -{ - private : - //int mIndex; - std::string mName; - int mModel; - int mHead; - int mTorso; - int mLegs; - int mColor; - int mBrightness; - - public : - PDefCharacter(); - //~PDefCharacter(); - - bool LoadFromDef(PTokenList *Tokens); - - inline const std::string &GetName() const { return mName; } - inline int GetModel() const { return mModel; } - inline int GetHead() const { return mHead; } - inline int GetTorso() const { return mTorso; } - inline int GetLegs() const { return mLegs; } - inline int GetColor() const { return mColor; } - inline int GetBrightness() const { return mBrightness; } -}; - -#endif - diff --git a/server/src/game/include/def_charaction.h b/server/src/game/include/def_charaction.h deleted file mode 100644 index d78cd7d..0000000 --- a/server/src/game/include/def_charaction.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_charaction.h - - CREATED: 31 Mar 2009 Hammag -*/ - -#ifndef DEF_CHARACTION_H -#define DEF_CHARACTION_H - -#include "def.h" - -class PDefCharAction : public PDef -{ - private : - //int mIndex; - int mNumOfSsq; - int mSsqId[8]; - float mModFactor[8]; - - public : - PDefCharAction(); - //~PDefCharAction(); - - bool LoadFromDef( PTokenList *Tokens ); - - inline int GetNumOfSsq() const { return mNumOfSsq; } - inline int GetSsqId(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < mNumOfSsq)) ? mSsqId[nIdx] : 0) ; } - inline int GetModFactor(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < mNumOfSsq)) ? mModFactor[nIdx] : 0) ; } -}; - -#endif diff --git a/server/src/game/include/def_charkinds.h b/server/src/game/include/def_charkinds.h deleted file mode 100644 index ce2fd7e..0000000 --- a/server/src/game/include/def_charkinds.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_charkinds.h - - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL -*/ - -#ifndef DEF_CHARKINDS_H -#define DEF_CHARKINDS_H - -#include "def.h" - -struct PSkillInfo -{ - int mStart; - int mMax; - int mGrow; - - inline PSkillInfo() - { - mStart = mMax = mGrow = 0; - } -}; - -struct PSkillPtsInfo -{ - int mSkill; - int mPoints; - - inline PSkillPtsInfo() - { - mSkill = mPoints = 0; - } -}; - -struct PSubSkillPtsInfo -{ - int mSubSkill; - int mPoints; - - inline PSubSkillPtsInfo() - { - mSubSkill = mPoints = 0; - } -}; - -struct PStartLevelInfo -{ - int mSubSkill; - int mLevel; - - inline PStartLevelInfo() - { - mSubSkill = mLevel = 0; - } - -}; - -class PDefCharKind : public PDef -{ - private : - typedef std::map PSkillPtsMap; - typedef std::map PSubSkillPtsMap; - typedef std::map PStartLevelMap; - - //int mIndex; - std::string mName; - int mType; - - // TODO: shouldnt this be a map? - PSkillInfo *mSkillInfo; - - PSkillPtsMap mSkillPts; - PSubSkillPtsMap mSubSkillPts; - PStartLevelMap mStartLevels; - int mMoney; - u32 mInventory[8]; - public : - PDefCharKind(); - ~PDefCharKind(); - - bool LoadFromDef(PTokenList *Tokens); - - inline const std::string &GetName() const { return mName; } - inline int GetType() const { return mType; } - inline const PSkillInfo &GetSkillInfo(int Skill) const { return mSkillInfo[Skill-1]; } - - inline int GetStartMoney() const { return mMoney; } - inline u32 GetStartInventory(u8 Index) const { return ((Index < 7) ? mInventory[Index] : 0); } - // TODO: mission get() functions -}; - -#endif - diff --git a/server/src/game/include/def_damage.h b/server/src/game/include/def_damage.h deleted file mode 100644 index 3ee337f..0000000 --- a/server/src/game/include/def_damage.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_damage.h - - CREATED: 31 Mar 2009 Hammag -*/ - -#ifndef DEF_DAMAGE_H -#define DEF_DAMAGE_H - -#include "def.h" - -class PDefDamage : public PDef -{ - private : - //int mIndex; - //int mSoundIndex; // no use - int mDamageNum; - int mDamageValue[4]; - int mDamageEffect[4]; - int mDamageType[4]; - /* int mEffectNum; // Are effects needed ? (server or client triggered ?) - int mEffectId[4]; // ? - int mEffectTarget[4]; // float ? - int mEffectValue[4]; // float ? - int mEffectamorId[4]; // ???? - */ - public : - PDefDamage(); - //~PDefDamage(); - - bool LoadFromDef ( PTokenList *Tokens ); - - inline int GetDamageNum() const { return mDamageNum; } - inline int GetDamageValue ( int nIdx ) const { return ( ( ( nIdx >= 0 ) && ( nIdx < mDamageNum ) ) ? mDamageValue[nIdx] : 0 ) ; } - inline int GetDamageEffect ( int nIdx ) const { return ( ( ( nIdx >= 0 ) && ( nIdx < mDamageNum ) ) ? mDamageEffect[nIdx] : 0 ) ; } - inline int GetDamageType ( int nIdx ) const { return ( ( ( nIdx >= 0 ) && ( nIdx < mDamageNum ) ) ? mDamageType[nIdx] : 0 ) ; } - /* inline int GetEffectNum() const { return mEffectNum; } - inline int GetEffectId(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < mEffectNum)) ? mEffectId[nIdx] : 0) ; } - inline int GetEffectTarget(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < mEffectNum)) ? mEffectTarget[nIdx] : 0) ; } - inline int GetEffectValue(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < mEffectNum)) ? mEffectValue[nIdx] : 0) ; } - inline int GetEffectamorId(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < mEffectNum)) ? mEffectamorId[nIdx] : 0) ; } - */ -}; - -#endif diff --git a/server/src/game/include/def_drugs.h b/server/src/game/include/def_drugs.h deleted file mode 100644 index 17c80c6..0000000 --- a/server/src/game/include/def_drugs.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - def_drug.h - - CREATED: 31 Mar 2009 Hammag -*/ - -#ifndef DEF_DRUG_H -#define DEF_DRUG_H - -#include "def.h" - -class PDefDrug : public PDef -{ - protected : - //int mIndex; - int mType; - //int mUseSound; - int mDuration; - int mChangeNum; - int mChangeType[8]; // 1: bonus, 2:malus, ... other ? - float mChangeScale[8]; - int mChangeTarget[8]; - - public : - PDefDrug(); - //~PDefDrug(); - - bool LoadFromDef( PTokenList *Tokens ); - - inline int GetType() const { return mType; } - inline int GetDuration() const { return mDuration; } - inline int GetChangeNum() const { return mChangeNum; } - inline int GetChangeType( int nIdx ) const { return ((( nIdx >= 0 ) && ( nIdx < mChangeNum ) ) ? mChangeType[nIdx] : 0 ) ; } - inline float GetChangeScale( int nIdx ) const { return ((( nIdx >= 0 ) && ( nIdx < mChangeNum ) ) ? mChangeScale[nIdx] : 0 ) ; } - inline int GetChangeTarget( int nIdx ) const { return ((( nIdx >= 0 ) && ( nIdx < mChangeNum ) ) ? mChangeTarget[nIdx] : 0 ) ; } -}; - -//type of drug: -//1 normal Drug -//2 Skill ver�ndernder PSI Spruch K�mpfer -//3 Skill ver�ndernder PSI Spruch Supporter -//4 Skill ver�ndernder PSI Spruch Resists -//6+A274 PSI entferne Sprcuh - -// drugeffects < 1000 Subskill -// <2000 Skill -// <2100 Energy (permanent) -// <2200 Maxenergy -// <2300 Armor -// <2400 Subskills -// 3000-3500 Actionmods - -#endif diff --git a/server/src/game/include/def_factions.h b/server/src/game/include/def_factions.h deleted file mode 100644 index 51e0ffa..0000000 --- a/server/src/game/include/def_factions.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_factions.h - - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL -*/ - -#ifndef DEF_FACTIONS_H -#define DEF_FACTIONS_H - -#include "def.h" - -static const int NUMFACTIONS = 20; // for faction relations only - -class PDefFaction : public PDef -{ - private : - //int mIndex; - std::string mName; - int mStartValue; - bool mAffected; - int mSL; - int mRelations[NUMFACTIONS]; - public : - PDefFaction(); - //~PDefFaction(); - - bool LoadFromDef(PTokenList *Tokens); - - inline const std::string &GetName() const { return mName; } - inline int GetStartValue() const { return mStartValue; } - inline bool GetAffected() const { return mAffected; } - inline int GetSL() const { return mSL; }; - int GetRelation(int Faction) const; -}; - -#endif - diff --git a/server/src/game/include/def_hack.h b/server/src/game/include/def_hack.h deleted file mode 100644 index de074d3..0000000 --- a/server/src/game/include/def_hack.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_hack.h - - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL -*/ - -#ifndef DEF_HACK_H -#define DEF_HACK_H - -#include "def.h" - -class PDefHack : public PDef -{ - private : - //int mIndex; - //qui aggiungere valori - public : - PDefHack(); - //~PDefHack(); - - bool LoadFromDef(PTokenList *Tokens); - - //qui aggiungere funzioni per i gets -}; - -#endif - diff --git a/server/src/game/include/def_implants.h b/server/src/game/include/def_implants.h deleted file mode 100644 index a3e4e7a..0000000 --- a/server/src/game/include/def_implants.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - def_implants.h - - CREATED: 02 Apr 2009 Hammag -*/ - -#ifndef DEF_IMPLANTS_H -#define DEF_IMPLANTS_H - -#include "def_drugs.h" - -// Implants Id 1 to 5 correspond to OP Zone bonus: mine, factory, lab, fort and comlink respectively - -class PDefImplant : public PDefDrug -{ - public: - bool LoadFromDef( PTokenList *Tokens ); -}; - -#endif diff --git a/server/src/game/include/def_itemcontainer.h b/server/src/game/include/def_itemcontainer.h deleted file mode 100644 index 7e9796c..0000000 --- a/server/src/game/include/def_itemcontainer.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - def_itemcontainer.h - - CREATED: 02 Apr 2009 Hammag -*/ - -#ifndef DEF_ITEMCONTAINER_H -#define DEF_ITEMCONTAINER_H - -#include "def.h" - -class PDefItemContainer : public PDef -{ - private : - //int mIndex; - int mNumItemsAtOnce; - int mRespawnTime; - int mNumItems; - int mItemId[6]; // <0: Group, >0: Item - float mQuality[6]; // usually <1, <=> % ? - int mChance[6]; // a weight, not a % - - int mCumulatedChance[6]; // Computed data in order to select random item entry - - void BuildCumulatedChance(); - - public : - PDefItemContainer(); - //~PDefItemContainer(); - - bool LoadFromDef( PTokenList *Tokens ); - - inline int GetNumItemsAtOnce() const { return mNumItemsAtOnce; } - inline int GetRespawnTime() const { return mRespawnTime; } - inline int GetNumItems() const { return mNumItems; } - inline int GetItemId(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < mNumItems)) ? mItemId[nIdx] : 0) ; } - inline float GetQuality(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < mNumItems)) ? mQuality[nIdx] : 0) ; } - inline int GetChance(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < mNumItems)) ? mChance[nIdx] : 0) ; } - int GetRandomItemIdx() const; // Return Idx based on Entry chance -}; - -#endif diff --git a/server/src/game/include/def_itemmod.h b/server/src/game/include/def_itemmod.h deleted file mode 100644 index 40f6e21..0000000 --- a/server/src/game/include/def_itemmod.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - def_itemmod.h - - CREATED: 31 Mar 2009 Hammag -*/ - -#ifndef DEF_ITEMMOD_H -#define DEF_ITEMMOD_H - -#include "def.h" - -class PDefItemMod : public PDef -{ - private : - //int mIndex; - int mType; // if mType > 0, it refers to a weapon type from weapons.def +1 - //int mDuration; // "implant base build time" = ???? always 0 anyway... - int mChangeNum; - int mChangeTarget[4]; // qualifier id 0 - 7 item qualifier id 4=range - float mChangeValue[4]; - float mChangeScale[4]; - std::string mName; - //int mIconId; - - public : - PDefItemMod(); - //~PDefItemMod(); - - bool LoadFromDef( PTokenList *Tokens ); - - inline const std::string &GetName() const { return mName; } - inline int GetType() const { return mType; } - //inline int GetDuration() const { return mDuration; } - inline int GetChangeNum() const { return mChangeNum; } - inline int GetChangeTarget(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < mChangeNum)) ? mChangeTarget[nIdx] : 0) ; } - inline float GetChangeValue(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < mChangeNum)) ? mChangeValue[nIdx] : 0) ; } - inline float GetChangeScale(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < mChangeNum)) ? mChangeScale[nIdx] : 0) ; } -}; - -#endif diff --git a/server/src/game/include/def_itemres.h b/server/src/game/include/def_itemres.h deleted file mode 100644 index d599861..0000000 --- a/server/src/game/include/def_itemres.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - def_itemres.h - - CREATED: 02 Apr 2009 Hammag -*/ - -#ifndef DEF_ITEMRESTRICTION_H -#define DEF_ITEMRESTRICTION_H - -#include "def.h" - -class PDefItemRestriction : public PDef -{ - private : - //int mIndex; - int mNumRestrictions; - int mSsqId[6]; // Skill/Subs - int mMinValue[6]; - - public : - PDefItemRestriction(); - //~PDefItemRestriction(); - - bool LoadFromDef( PTokenList *Tokens ); - - inline int GetNumRestrictions() const { return mNumRestrictions; } - inline int GetSsqId(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < mNumRestrictions)) ? mSsqId[nIdx] : 0) ; } - inline float GetMinValue(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < mNumRestrictions)) ? mMinValue[nIdx] : 0) ; } -}; - -#endif diff --git a/server/src/game/include/def_items.h b/server/src/game/include/def_items.h deleted file mode 100644 index 88db9b9..0000000 --- a/server/src/game/include/def_items.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_items.h - - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL - - MODIFIED: 10 Jul Hammag - REASON: - Full Item Def implementation -*/ - -#ifndef DEF_ITEMS_H -#define DEF_ITEMS_H - -#include "def.h" - -class PDefItems : public PDef -{ - private : - - //int mIndex;//1 - std::string mName;//2 - int mModel; // used for IG display - int mType; - int mValue1; - int mValue2; - int mValue3; - // int mBmNum; // used IG for inventory display - // int mmBmNumIndex; // used IG for inventory display - int mSizeX; - int mSizeY; - // int mSmallbmnum; // used IG for inventory display - float mWeight; - int mStackable; - float mFillWeight; - int mQualifier; - int mGfxMods; - int mItemGroupID; - int mTextDescID; - int mBasePrice; - int mTechlevel; - int mItemflags; - // std::mShortname; // used IG for display on inventories Icons - - public : - PDefItems(); - //~PDefItems(); - - bool LoadFromDef(PTokenList *Tokens); - - inline const std::string &GetName() const { return mName; } - inline int GetModel() const { return mModel; } - inline int GetType() const { return mType; } - inline int GetValue1() const { return mValue1; } - inline int GetValue2() const { return mValue2; } - inline int GetValue3() const { return mValue3; } - inline int GetSizeX() const { return mSizeX; } - inline int GetSizeY() const { return mSizeY; } - inline float GetWeight() const { return mWeight; } - inline bool IsStackable() const { return (mStackable == 1); } - inline float GetFillWeight() const { return mFillWeight; } - inline int GetQualifier() const { return mQualifier; } - inline int GetGfxMods() const { return mGfxMods; } - inline int GetItemGroupID() const { return mItemGroupID; } - inline int GetTextDescID() const { return mTextDescID; } - inline int GetBasePrice() const { return mBasePrice; } - inline int GetTechlevel() const { return mTechlevel; } - inline int GetItemflags() const { return mItemflags; } -}; - - -class PDefItemsMap : public PDefMap -{ - private: - std::map::const_iterator* mMapItCache; - int mMapItCacheCount; - std::map > mItemGroups; - int mMaxItemGroupId; - void BuildMapItCache(); - void BuildItemGroups(); - - public: - PDefItemsMap(); - ~PDefItemsMap(); - bool Load(const char* nName, const char* nFilename); - const PDefItems* GetDefBySeqIndex( int nSeqIndex ) const; - int GetRandomItemIdFromGroup( int nGroupId ) const; - - inline std::map::const_iterator ConstIteratorBegin() const { return mDefs.begin(); } - inline std::map::const_iterator ConstIteratorEnd() const { return mDefs.end(); } -}; - -#endif diff --git a/server/src/game/include/def_mission.h b/server/src/game/include/def_mission.h deleted file mode 100644 index 7ff31b7..0000000 --- a/server/src/game/include/def_mission.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - def_mission.h - - CREATED: 02 Apr 2009 Hammag -*/ - -#ifndef DEF_MISSION_H -#define DEF_MISSION_H - -#include "def.h" - -class PDefMission : public PDef -{ - private : - //int mIndex; - int mSourceId; - std::string mStartDialog; - int mDescTextId; - int mNpcType[4]; - std::string mNpcDialog[4]; - int mNpcDialogStartState[4]; - int mTargetType[4]; - int mTargetValue[4][3]; - int mEndMoney; - int mEndXp; - int mMaxTime; - int mDifficulty; - int mMinFactionValue; - int mPoints; - int mFlags; - - public : - PDefMission(); - //~PDefMission(); - - bool LoadFromDef( PTokenList *Tokens ); - - inline int GetSourceId() const { return mSourceId; } - inline const std::string &GetStartDialog() const { return mStartDialog; } - inline int GetDescTextId() const { return mDescTextId; } - inline int GetNpcType(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < 4)) ? mNpcType[nIdx] : 0) ; } - inline const std::string &GetNpcDialog(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < 4)) ? mNpcDialog[nIdx] : EmptyString) ; } - inline int GetNpcDialogStartState(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < 4)) ? mNpcDialogStartState[nIdx] : 0) ; } - inline int GetTargetType(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < 4)) ? mTargetType[nIdx] : 0) ; } - inline int GetTargetValue(int nIdx, int nValIdx) const { return ( ((nIdx >= 0) && (nIdx < 4) && (nValIdx >= 0) && (nValIdx < 3)) ? mTargetValue[nIdx][nValIdx] : 0) ; } - inline int GetEndMoney() const { return mEndMoney; } - inline int GetEndXp() const { return mEndXp; } - inline int GetMaxTime() const { return mMaxTime; } - inline int GetDifficulty() const { return mDifficulty; } - inline int GetMinFactionValue() const { return mMinFactionValue; } - inline int GetPoints() const { return mPoints; } - inline int GetFlags() const { return mFlags; } -}; - -/* -//mission source ID > 0 NPC Type for mission source < 0 Terminal ID for mission source - -//mission NPC Type > 0 NPC Type for mission NPC < 0 Fraction ID for mission NPC -//mission target Type 1 - kill NPC 2 - kill NPC type "3 - dialogtrigger" 4 - kill NPC type range 5-dialogtrigger + counter "6 - conquer outpost" 7 - conquer outpost + counter 8 - conquer + hold outpost 9-KillPlayer 10 - LootNPC 11 - LootNPCType - -//target value 1 ID of related mission NPC > 0 NPC Type of NPCs to kill < 0 FractionID of NPCs to kill "ID of related mission NPC" > 0 NPC Type of NPCs to kill ID of related mission NPC "> 0 outpost Type < 0 current outpost factionid" > 0 outpost type < 0 original outpost faction type > 0 outpost Type < 0 current outpost factionid PlayerFaction ID of related Mission NPC(0-4) > 0 NPC Type of NPCs to kill < 0 FractionID of NPCs to kill - -//target value 2 Count of NPCs to kill "ID of DialogTrigger" Count of NPCs to kill ID of DialogTrigger Count of outposts to conquer time to hold outpost Kill Cnt ItemID NPC Cnt - -//target value 3 Range of NPC Type Trigger Counter - must reach 0 to be successfull Max Leveldiff Item ID -//missionflags (bit field) -// NPC0 No Search 1 -// NPC1 No Search 2 -// NPC2 No Search 4 -// NPC3 No Search 8 -*/ -#endif diff --git a/server/src/game/include/def_npc.h b/server/src/game/include/def_npc.h deleted file mode 100644 index e3b3069..0000000 --- a/server/src/game/include/def_npc.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - def_npc.h - - CREATED: 03 Apr 2009 Hammag -*/ - -#ifndef DEF_NPC_H -#define DEF_NPC_H - -#include "def.h" - -class PDefNpc : public PDef -{ - private : - //int mIndex; - int mModel; // <0: from characters.def, >0: from models.ini, [players] section (?) - //int mSoundId; // always 0: not used - int mNGT; // ? 1 - 4 - int mGender; // 0 - 1 - int mFaction; - int mHealth; - int mArmorId; // -1 or ref to NpcArmor - int mWeaponId; - std::string mDialogScript; - int mCombat; // ? 20 - 800 - int mLoot; // 0 or ref to ItemContained - int mMovementEnd; // 0 - 4 - int mFunctionType; // 0 - 4 - float mModelScaling; // 0 - 0.9 - int mMoneyLoose; // 0 - 190 - float mSkillScale; // 0 - 120 - std::string mStandardScript; - std::string mStandardParameter; - int mMass; // 1 - 10000 - //int mStartHour; // not used - //int mEndHour; // not used - //std::string mTempScript; // not used - int mFlags; // values: 513, 259, 256, 128, 64, 48, 35, 34, 33, 32, 2, 1, 0 - - public : - PDefNpc(); - //~PDefNpc(); - - bool LoadFromDef( PTokenList *Tokens ); - - inline int GetModel() const { return mModel; } - inline int GetNGT() const { return mNGT; } - inline int GetGender() const { return mGender; } - inline int GetFaction() const { return mFaction; } - inline int GetHealth() const { return mHealth; } - inline int GetArmorId() const { return mArmorId; } - inline int GetWeaponId() const { return mWeaponId; } - inline const std::string &GetDialogScript() const { return mDialogScript; } - inline int GetCombat() const { return mCombat; } - inline int GetLoot() const { return mLoot; } - inline int GetMovementEnd() const { return mMovementEnd; } - inline int GetFunctionType() const { return mFunctionType; } - inline float GetModelScaling() const { return mModelScaling; } - inline int GetMoneyLoose() const { return mMoneyLoose; } - inline float GetSkillScale() const { return mSkillScale; } - inline const std::string &GetStandardScript() const { return mStandardScript; } - inline const std::string &GetStandardParameter() const { return mStandardParameter; } - inline int GetMass() const { return mMass; } - inline int GetFlags() const { return mFlags; } -}; - -#endif - diff --git a/server/src/game/include/def_npcarmor.h b/server/src/game/include/def_npcarmor.h deleted file mode 100644 index 6e48e5b..0000000 --- a/server/src/game/include/def_npcarmor.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - def_npcarmor.h - - CREATED: 04 Apr 2009 Hammag -*/ - -#ifndef DEF_NPCARMOR_H -#define DEF_NPCARMOR_H - -#include "def.h" - -class PDefNpcArmor : public PDef -{ - private : - //int mIndex; - int mValue[7]; // force piercing fire energy xray psi poison - - public : - PDefNpcArmor(); - //~PDefNpcArmor(); - - bool LoadFromDef ( PTokenList *Tokens ); - - inline int GetValue ( int nIdx ) const { return ( ( ( nIdx >= 0 ) && ( nIdx < 7 ) ) ? mValue[nIdx] : 0 ) ; } -}; - -#endif diff --git a/server/src/game/include/def_npcgroupspawn.h b/server/src/game/include/def_npcgroupspawn.h deleted file mode 100644 index 9f4f5e2..0000000 --- a/server/src/game/include/def_npcgroupspawn.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - def_npcgroupspawn.h - - CREATED: 03 Apr 2009 Hammag -*/ - -#ifndef DEF_NPCGROUPSPAWN_H -#define DEF_NPCGROUPSPAWN_H - -#include "def.h" - -class PDefNpcGroupSpawn : public PDef -{ - private : - //int mIndex; - int mIgnoreNearPC; - int mNumNpc; // Size of the list. But that should be the size of the group... - int mNpcType[8]; - std::string mScript[8]; - std::string mScriptParameter[8]; - int mFunctionValue[8]; - int mSpawnChance[8]; - - public : - PDefNpcGroupSpawn(); - //~PDefNpcGroupSpawn(); - - bool LoadFromDef( PTokenList *Tokens ); - - inline int GetIgnoreNearPC() const { return mIgnoreNearPC; } - inline int GetNumNpc() const { return mNumNpc; } - inline int GetNpcType(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < mNumNpc)) ? mNpcType[nIdx] : 0) ; } - inline const std::string& GetScript(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < mNumNpc)) ? mScript[nIdx] : EmptyString) ; } - inline const std::string& GetScriptParameter(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < mNumNpc)) ? mScriptParameter[nIdx] : EmptyString) ; } - inline int GetFunctionValue(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < mNumNpc)) ? mFunctionValue[nIdx] : 0) ; } - inline int GetSpawnChance(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < mNumNpc)) ? mSpawnChance[nIdx] : 0) ; } -}; - -#endif - diff --git a/server/src/game/include/def_outposts.h b/server/src/game/include/def_outposts.h deleted file mode 100644 index ba626f7..0000000 --- a/server/src/game/include/def_outposts.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - def_outposts.h - - CREATED: 03 Apr 2009 Hammag -*/ - -#ifndef DEF_OUTPOSTS_H -#define DEF_OUTPOSTS_H - -#include "def.h" - -class PDefOutpost : public PDef -{ - private : - //int mIndex; - std::string mName; - int mType; - int mStandardFaction; - float mRevenue; - float mConquestReward; - int mMaxSecurity; - int mInfluenceZone[8]; // ex: 12 for zone A12, 112 for B12 - - public : - PDefOutpost(); - //~PDefOutpost(); - - bool LoadFromDef( PTokenList *Tokens ); - - inline const std::string &GetName() const { return mName; } - inline int GetType() const { return mType; } - inline int GetStandardFaction() const { return mStandardFaction; } - inline float GetRevenue() const { return mRevenue; } - inline float GetConquestReward() const { return mConquestReward; } - inline int GetMaxSecurity() const { return mMaxSecurity; } - inline int GetInfluenceZone(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < 8)) ? mInfluenceZone[nIdx] : 0) ; } -}; - -#endif - diff --git a/server/src/game/include/def_recycles.h b/server/src/game/include/def_recycles.h deleted file mode 100644 index b03b8ae..0000000 --- a/server/src/game/include/def_recycles.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - def_recycles.h - - CREATED: 03 Apr 2009 Hammag -*/ - -#ifndef DEF_RECYCLES_H -#define DEF_RECYCLES_H - -#include "def.h" - -class PDefRecycle : public PDef -{ - private : - //int mIndex; - int mResultItemId; // We use resultitem as mIndex - int mBuildTime; - int mNumParts; - int mPartId[8]; - - public : - PDefRecycle(); - //~PDefRecycle(); - - bool LoadFromDef( PTokenList *Tokens ); - - inline int GetResultItemId() const { return mResultItemId; } - inline int GetBuildTime() const { return mBuildTime; } - inline int GetNumParts() const { return mNumParts; } - inline int GetPartId(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < mNumParts)) ? mPartId[nIdx] : 0 ) ; } -}; - -#endif - diff --git a/server/src/game/include/def_respawn.h b/server/src/game/include/def_respawn.h deleted file mode 100644 index 3ede3f9..0000000 --- a/server/src/game/include/def_respawn.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_respawn.h - - MODIFIED: 22 Sep 2006 Hammag - REASON: - Creation - -*/ - -#ifndef DEF_RESPAWN_H -#define DEF_RESPAWN_H - -#include "def.h" - -class PDefRespawn : public PDef -{ - private : - //int mIndex; - int mWorldID; - int mEntityID; // Station ID - int mHazardLevel; - std::string mName; // Description - std::string mFlag; // ??? - - public : - PDefRespawn(); - //~PDefRespawn(); - - bool LoadFromDef(PTokenList *Tokens); - - inline int GetWorldID() const { return mWorldID; } - inline int GetEntityID() const { return mEntityID; } - inline int GetHazardLevel() const { return mHazardLevel; } - inline const std::string &GetName() const { return mName; } - inline const std::string &GetFlag() const { return mFlag; } - -}; - - -class PDefRespawnsMap : public PDefMap -{ - public: - int GetRespawnEntity( u32 nWorldID, u16 nGROrder ) const; -}; - -#endif diff --git a/server/src/game/include/def_scripts.h b/server/src/game/include/def_scripts.h deleted file mode 100644 index 04bc0b5..0000000 --- a/server/src/game/include/def_scripts.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_scripts.h - - CREATED: 12 Oct 2009 Namikon -*/ - -#ifndef DEF_SCRIPTS_H -#define DEF_SCRIPTS_H - -#include "def.h" - -class PDefScripts : public PDef -{ - private : - //int mIndex; - std::string mIdentifier; - std::string mLuaFile; - std::string mScriptHeader; - - public : - PDefScripts(); - //~PDefWeapon(); - - bool LoadFromDef( PTokenList *Tokens ); - - inline const std::string &GetIdentifier() const { return mIdentifier; } - inline const std::string &GetLuaFile() const { return mLuaFile; } - inline const std::string &GetScriptHeader() const { return mScriptHeader; } -}; - -class PDefScriptsMap : public PDefMap -{ - public: - //bool Load(const char* nName, const char* nFilename); - inline std::map::const_iterator ConstIteratorBegin() const { return mDefs.begin(); } - inline std::map::const_iterator ConstIteratorEnd() const { return mDefs.end(); } -}; - -#endif diff --git a/server/src/game/include/def_shots.h b/server/src/game/include/def_shots.h deleted file mode 100644 index 128b12c..0000000 --- a/server/src/game/include/def_shots.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - def_shots.h - - CREATED: 03 Apr 2009 Hammag -*/ - -#ifndef DEF_SHOTS_H -#define DEF_SHOTS_H - -#include "def.h" - -class PDefShot : public PDef -{ - private : - //int mIndex; - int mDamageId; - int mMass; - int mRadius; - float mSpeed; - //int mHitSound; - //int mCustomType; - //std::string mCustomFrameFx; - //std::string mCustomHitFx; - - public : - PDefShot(); - //~PDefShot(); - - bool LoadFromDef( PTokenList *Tokens ); - - inline int GetDamageId() const { return mDamageId; } - inline int GetMass() const { return mMass; } - inline int GetRadius() const { return mRadius; } - inline int GetSpeed() const { return mSpeed; } -}; - -#endif - diff --git a/server/src/game/include/def_skills.h b/server/src/game/include/def_skills.h deleted file mode 100644 index b70675b..0000000 --- a/server/src/game/include/def_skills.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_skills.h - - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL -*/ - -#ifndef DEF_SKILLS_H -#define DEF_SKILLS_H - -#include "def.h" - -class PDefSkill : public PDef -{ - private : - //int mIndex; - std::string mName; - std::string mShortName; - int mNumSubSkills; - int *mSubSkills; - public : - PDefSkill(); - ~PDefSkill(); - - bool LoadFromDef(PTokenList *Tokens); - - inline const std::string &GetName() const { return mName; } - inline const std::string &GetShortName() const { return mShortName; } - inline int GetNumSubSkills() const { return mNumSubSkills; } - inline int GetSubSkill(int Index) const { return mSubSkills[Index]; } -}; - -#endif - diff --git a/server/src/game/include/def_subskills.h b/server/src/game/include/def_subskills.h deleted file mode 100644 index f7d0390..0000000 --- a/server/src/game/include/def_subskills.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_subskill.h - - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL -*/ - -#ifndef DEF_SUBSKILLS_H -#define DEF_SUBSKILLS_H - -#include "def.h" - -class PDefSubSkill : public PDef -{ - private : - //int mIndex; - std::string mName; - std::string mShortName; - float mStrengthenFactor; - int mNumActionModifiers; - int *mActionModifiers; - public : - PDefSubSkill(); - ~PDefSubSkill(); - - bool LoadFromDef(PTokenList *Tokens); - - inline const std::string &GetName() const { return mName; } - inline const std::string &GetShortName() const { return mShortName; } - inline float GetStrengthenFactor() const { return mStrengthenFactor; } - inline int GetNumActionModifiers() const { return mNumActionModifiers; } - inline int GetActionModifier(int Index) const { return mActionModifiers[Index]; } -}; - -#endif - diff --git a/server/src/game/include/def_trader.h b/server/src/game/include/def_trader.h deleted file mode 100644 index bbb246d..0000000 --- a/server/src/game/include/def_trader.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - def_trader.h - - CREATED: 03 Apr 2009 Hammag -*/ - -#ifndef DEF_TRADER_H -#define DEF_TRADER_H - -#include "def.h" -#define DEF_TRADER_MAXENTRIES 17 - -class PDefTrader : public PDef -{ - private : - //int mIndex; - int mType; - float mMaxWealth; - float mWealthRespawn; - int mQuality; - int mItemId[DEF_TRADER_MAXENTRIES]; // <0: item group - float mItemPriceScale[DEF_TRADER_MAXENTRIES]; // sometime string like "1/5" ??? <=> 0.2 or Sell:1 / Buy 5 ???? - - public : - PDefTrader(); - //~PDefTrader(); - - bool LoadFromDef( PTokenList *Tokens ); - - inline int GetType() const { return mType; } - inline float GetMaxWealth() const { return mMaxWealth; } - inline float GetWealthRespawn() const { return mWealthRespawn; } - inline int GetQuality() const { return mQuality; } - inline int GetItemId(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < DEF_TRADER_MAXENTRIES)) ? mItemId[nIdx] : 0 ) ; } - inline float GetItemPriceScale(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < DEF_TRADER_MAXENTRIES)) ? mItemPriceScale[nIdx] : 0 ) ; } -}; -/* Trader/Buyer mType -// 1 weapons -// 2 ammo -// 3 armor -// 4 tools -// 5 psi equipment -// -// 10 chemicals -// 11 item parts -// 12 implants -// 13 bone enforcements -// -// 16 Buy anything -// -// 20 refreshments -// 21 drugs -// 22 medicaments -// 23 real estates -// 24 vehicles -// -*/ -#endif - diff --git a/server/src/game/include/def_vehicles.h b/server/src/game/include/def_vehicles.h deleted file mode 100644 index 9ffcca2..0000000 --- a/server/src/game/include/def_vehicles.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - def_vehicles.h - - CREATED: 03 Apr 2009 Hammag -*/ - -#ifndef DEF_VEHICLES_H -#define DEF_VEHICLES_H - -#include "def.h" - -class PDefVhc : public PDef -{ - private : - //int mIndex; // field 1 - int mModel; - std::string mName; - /* - float mLeftFront; // field 4 - float mFront; - float mRightBack; - float mBack; - float mSideFriction; - float mDownFriction; - float mForwardFriction; - float mAcceleration; - float mBrakeFactor; - float mTurnSpeed; - float mFullTurnDelay; - int mAnimClass; // field 15 - */ - int mSeatId[8]; // fields 16 - 23 - /* - float mSpeedTiltFactor; // field 24 - float mSpeedGlideFactor; - float mMinHover; - float mMaxHover; - float mHoverLoopLen; - int mWheelCnt; - float mWheelSpeed; - float mMaxDive; - int mEffectsID; - int mShowDebugBouncer; // field 33 - */ - int mHealth; - int mArmor; - //int mSoundStartindex; // field 36 - - // Additionnal info - int mNumSeats; - - public : - PDefVhc(); - //~PDefVhc(); - - bool LoadFromDef( PTokenList *Tokens ); - - inline int GetModel() const { return mModel; } - inline const std::string &GetName() const { return mName; } - inline int GetSeatId( int nIdx ) const { return ((( nIdx >= 0 ) && ( nIdx < 8 ) ) ? mSeatId[nIdx] : -1) ; } - inline int GetHealth() const { return mHealth; } - inline int GetArmor() const { return mArmor; } - inline int GetNumSeats() const { return mNumSeats; } -}; - -#endif - diff --git a/server/src/game/include/def_vehiclesits.h b/server/src/game/include/def_vehiclesits.h deleted file mode 100644 index 310ff77..0000000 --- a/server/src/game/include/def_vehiclesits.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - def_vehiclesits.h - - CREATED: 03 Apr 2009 Hammag -*/ - -#ifndef DEF_VEHICLESEATS_H -#define DEF_VEHICLESEATS_H - -#include "def.h" - -class PDefVhcSeat : public PDef -{ - private : - //int mIndex; //Field 1 - int mType; - std::string mName; //Field 3 - //BasePosX Y Z - //BaseAngleX Y Z - float mLeavePos[3]; //X Y Z - Fields 10-12 - float mLeaveAngle[3]; //X Y Z - Fields 13-15 - //FirePosX Y Z //Field 16 - //XLock Ylock MinX MaxX TurnSpeed ForceExternalCam ShowActor - //SitBone RotXBone RotYBone WeaponBone - int mWeaponId; //Field 30 - int mTL; - float mDamageFactor; - //SitAnimType SitYOffset //Field 33 - //SitFlags - - public : - PDefVhcSeat(); - //~PDefVhcSeat(); - - bool LoadFromDef( PTokenList *Tokens ); - - inline int GetType() const { return mType; } - inline const std::string &GetName() const { return mName; } - inline float GetLeavePos(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < 3)) ? mLeavePos[nIdx] : 0) ; } - inline float GetLeaveAngle(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < 3)) ? mLeaveAngle[nIdx] : 0) ; } - inline int GetWeaponId() const { return mWeaponId; } - inline int GetTL() const { return mTL; } - inline float GetDamageFactor() const { return mDamageFactor; } -}; -/* -mType: -0 - Driver (Ground vhc) -1 - Gunner -2 - Passenger -3 - Driver/Gunner -4 - Pilot (Flying vhc) -5 - Pilot/Gunner (Flying vhc) -6 - Pilot (Senkrechtstarter ????) - -mFlags: -1 - Winkel f�r Spieler und Waffe wird auf Fahrzeugrichtung gelockt. Zielrichtung darf nur leicht von der Fahrzeugrichtung abweichen -2 - Spieler wird gelockt -4 - Waffe ist nicht um X Achse drehbar -8 - Waffe ist nicht um Y Achse drehbar -16 - Spielermodel um 180 Grad gedreht -*/ -#endif - diff --git a/server/src/game/include/def_weapons.h b/server/src/game/include/def_weapons.h deleted file mode 100644 index bebdab7..0000000 --- a/server/src/game/include/def_weapons.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_weapons.h - - CREATED: 29 Mar 2009 Hammag -*/ - -#ifndef DEF_WEAPONS_H -#define DEF_WEAPONS_H - -#include "def.h" - -class PDefWeapon : public PDef -{ - private : - //int mIndex; - std::string mName; - //int mFpsmodel; - //int mAttachmodel; - //int mMunactor; - //float mDroptime; // useful ? - int mItemIndex; - //int effectcolor[3]; // R,G,B - //int dynamiclight; - //float lighttime; - //int soundindex; - //float mShotTime; // useful ? - int mAmmoUse; - int mPSIuse; - float mStaminaUse; - //float upthrow; - //int weaponHold; // ??? - int mWeaponType; - int mDiscardable; - float mSkillFactor; - //int mintgtRad; - //int maxtgtRad; - int mMaxRange; - int mAggressiveWeapon; - float mDamageMultiplicator; - int mAmmoTypes[8]; - int mAmmoStartFlags; // ??? - //int customclasstype; // ? - //int unknown // ? - int mShotCnt; - //float shotduration; // maybe useful later ? - //std::string shotfx; - //float attachposx; - //float attachposy; - //float attachposz; - //float fpposx; - //float fpposy; - //float fpposz; - int mBaseWeaponId; - //int weaponcolor; - //int reloadsound; - int mItemModGroup; - int mItemModGroupFlags; - int mRareWeaponFx; - - public : - PDefWeapon(); - //~PDefWeapon(); - - bool LoadFromDef( PTokenList *Tokens ); - - inline const std::string &GetName() const { return mName; } - inline int GetItemID() const { return mItemIndex; } - inline int GetAmmoUse() const { return mAmmoUse; } - inline int GetPsiUse() const { return mPSIuse; } - inline float GetStaminaUse() const { return mStaminaUse; } - inline int GetWeaponType() const { return mWeaponType; } - inline bool IsDiscardable() const { return mDiscardable; } - inline float GetSkillFactor() const { return mSkillFactor; } - inline int GetMaxRange() const { return mMaxRange; } - inline bool IsAggressiveWeapon() const { return mAggressiveWeapon; } - inline float GetDamageMultiplicator() const { return mDamageMultiplicator; } - inline int GetAmmoType(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < 8)) ? mAmmoTypes[nIdx] : 0) ; } - inline int GetAmmoStartFlags() const { return mAmmoStartFlags; } - inline int GetShotCnt() const { return mShotCnt; } - inline int GetBaseWeaponId() const { return mBaseWeaponId; } - inline int GetItemModGroup() const { return mItemModGroup; } - inline int GetItemModGroupFlags() const { return mItemModGroupFlags; } - inline int GetRareWeaponFx() const { return mRareWeaponFx; } -}; - -#endif diff --git a/server/src/game/include/def_weather.h b/server/src/game/include/def_weather.h deleted file mode 100644 index 5d7a016..0000000 --- a/server/src/game/include/def_weather.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - def_weather.h - - CREATED: 03 Apr 2009 Hammag -*/ - -#ifndef DEF_WEATHER_H -#define DEF_WEATHER_H - -#include "def.h" -//weathersectionid weathercnt weatherid length end -class PDefWeather : public PDef -{ - private : - //int mIndex; - int mSectionId; - int mNumWeathers; - int mWeatherId[8]; - int mDuration[8]; - - public : - PDefWeather(); - //~PDefWeather(); - - bool LoadFromDef( PTokenList *Tokens ); - - inline int GetSectionId() const { return mSectionId; } - inline int GetNumWeathers() const { return mNumWeathers; } - inline int GetWeatherId(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < mNumWeathers)) ? mWeatherId[nIdx] : 0 ) ; } - inline int GetDuration(int nIdx) const { return ( ((nIdx >= 0) && (nIdx < mNumWeathers)) ? mDuration[nIdx] : 0 ) ; } -}; - -/* mWeatherId -//BRIGHTSKY (1) -//SINGLECLOUDS (2) -//CLOUDY (3) - -//LIGHTRAIN (4) -//HEAVYRAIN (5) -//THUNDERSTORM (6) - -//SNOW (7) -//SANDSTORM (8) -//FALLOUT (9) - -//SEA_BRIGHTSKY (100) -*/ -#endif - diff --git a/server/src/game/include/def_worldfile.h b/server/src/game/include/def_worldfile.h deleted file mode 100644 index b5dfbd3..0000000 --- a/server/src/game/include/def_worldfile.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_worldfile.h (infos from worlds/worlds.ini) - - MODIFIED: 28 Sep 2007 Hammag - REASON: - Creation -*/ - -#ifndef DEF_WORLDFILE_H -#define DEF_WORLDFILE_H - -#include "def.h" - -class PDefWorldFile : public PDef -{ - private : - //int mIndex; - std::string mName; // dat filename with ending extension and starting ./ or ./worlds/ REMOVED - bool mFileInWorldsDir; // TRUE if worlds/ must be appendend before mName to get real file name (dat file at least) - - public : - PDefWorldFile(); - //~PDefWorldFile(); - - bool LoadFromDef(PTokenList *Tokens); - - inline const std::string &GetName() const { return mName; } - inline const std::string GetBasicFileName() const { return (mFileInWorldsDir ? (std::string("worlds/") + mName) : mName); }; -}; - - -class PDefWorldFilesMap : public PDefMap -{ - public: - bool Load(const char* nName, const char* nFilename); - inline std::map::const_iterator ConstIteratorBegin() const { return mDefs.begin(); } - inline std::map::const_iterator ConstIteratorEnd() const { return mDefs.end(); } -}; - -#endif diff --git a/server/src/game/include/def_worldmodels.h b/server/src/game/include/def_worldmodels.h deleted file mode 100644 index 3d4ff27..0000000 --- a/server/src/game/include/def_worldmodels.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - -/* - def_WorldModels.h - - Created: 21 Sep 2006 Hammag - REASON: - -*/ - -#ifndef DEF_WORLDMODELS_H -#define DEF_WORLDMODELS_H - -#include "def.h" - -class PDefWorldModel : public PDef -{ - private : - //int mIndex; - std::string mName; - int mUseFlags; - int mFunctionType; - int mFunctionValue; - int mHackDifficulty; - int mHackPenalty; - - public : - PDefWorldModel(); - //~PDefWorldModel(); - - bool LoadFromDef(PTokenList *Tokens); - - inline int GetID() const { return mIndex; } - inline const std::string &GetName() const { return mName; } - inline int GetUseFlags() const { return mUseFlags; } - inline int GetFunctionType() const { return mFunctionType; } - inline int GetFunctionValue() const { return mFunctionValue; } - inline int GetHackDifficulty() const { return mHackDifficulty; } - inline int GetHackPenalty() const { return mHackPenalty; } - -}; - -#endif diff --git a/server/src/game/include/def_worlds.h b/server/src/game/include/def_worlds.h deleted file mode 100644 index 3b94bf6..0000000 --- a/server/src/game/include/def_worlds.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - def_worlds.h - - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL -*/ - -#ifndef DEF_WORLDS_H -#define DEF_WORLDS_H - -#include "def.h" - -class PDefWorld : public PDef -{ - private : - //int mIndex; - std::string mName; - std::string mDatFile; - int mFlags; - public : - PDefWorld(); - //~PDefWorld(); - - bool LoadFromDef(PTokenList *Tokens); - - inline const std::string &GetName() const { return mName; } - inline const std::string &GetDatFile() const { return mDatFile; } - inline int GetFlags() const { return mFlags; } -}; - -#endif diff --git a/server/src/game/include/defmap.h b/server/src/game/include/defmap.h deleted file mode 100644 index 9bc5038..0000000 --- a/server/src/game/include/defmap.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - defmap.h - Definiton of template class for def maps. - - CREATED: 30 Mar 2009 Hammag -*/ - -template class PDefMap -{ - protected: - std::string mName; - std::map mDefs; - - void Clear(); - - public: - PDefMap () {}; - ~PDefMap (); - - bool Load(const char* nName, const char* nFilename); - inline int GetNumDefs() const { return mDefs.size(); } - const T* GetDef( int Index ) const; -}; - -template PDefMap::~PDefMap() -{ - Clear(); -} - -template void PDefMap::Clear() -{ - for ( typename std::map::iterator i = mDefs.begin(); i != mDefs.end(); i++ ) - delete i->second; - mDefs.clear(); -} - -template bool PDefMap::Load(const char* nName, const char* nFilename) -{ - mName = nName; - if(mName.empty()) - { - Console->Print( "%s Defs name not defined", Console->ColorText( RED, BLACK, "[ERROR]" ) ); - return (false); - } - - if(! *nFilename) - { - Console->Print( "%s Filename not defined for %s defs", Console->ColorText( RED, BLACK, "[ERROR]" ), mName.c_str() ); - return (false); - } - - PDefParser parser; - int nDefs = 0, nErrors = 0; - - if ( parser.Parse( nFilename ) ) - { - const PDefTokenList &t = parser.GetTokens(); - - for ( PDefTokenList::const_iterator i = t.begin(); i != t.end(); i++ ) - { - T* entry = new T(); - bool insertfail = false; - bool loadfail = ! entry->LoadFromDef( *i ); - - if ( !loadfail ) - insertfail = ! mDefs.insert( std::make_pair( entry->GetIndex(), entry ) ).second; - - if ( loadfail || insertfail ) - { - if ( insertfail ) - Console->Print( "%s %s def error (duplicate id %i): %s", Console->ColorText( YELLOW, BLACK, "[NOTICE]" ), mName.c_str(), entry->GetIndex(), entry->GetName().c_str() ); - else - Console->Print( "%s def load error @ %i", Console->ColorText( YELLOW, BLACK, "[NOTICE]" ), mName.c_str(), nDefs + nErrors ); - ++nErrors; - delete entry; - } - else - ++nDefs; - } - } - else - { - Console->Print( "%s Error loading %s defs", Console->ColorText( YELLOW, BLACK, "[WARNING]" ), mName.c_str() ); - return (false); - } - - if ( nErrors > 0 ) - Console->Print( "%s Loaded %i %s defs, %i error(s).", Console->ColorText( RED, BLACK, "[WARNING]" ), nDefs, mName.c_str(), nErrors ); - else - Console->Print( "%s Loaded %i %s defs, %i error(s).", Console->ColorText( GREEN, BLACK, "[Success]" ), nDefs, mName.c_str(), nErrors ); - - return ( true ); -} - -template const T* PDefMap::GetDef( int Index ) const -{ - T* Result; - - typename std::map::const_iterator i = mDefs.find( Index ); - Result = ( ( i != mDefs.end() ) ? i->second : NULL ); - - return ( Result ); -} diff --git a/server/src/game/include/defparser.h b/server/src/game/include/defparser.h deleted file mode 100644 index 332662c..0000000 --- a/server/src/game/include/defparser.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - defparser.h - - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL -*/ - -#ifndef DEFPARSER_H -#define DEFPARSER_H - -#ifdef _MSC_VER - #pragma once -#endif - -typedef std::list PTokenList; -typedef std::list PDefTokenList; - -class PDefParser -{ - private : - PDefTokenList mTokens; - public : - PDefParser(); - ~PDefParser(); - bool Parse(const char *File); - inline const PDefTokenList &GetTokens() const { return mTokens; } -}; - -#endif - diff --git a/server/src/game/include/defs.h b/server/src/game/include/defs.h deleted file mode 100644 index 64bb6ed..0000000 --- a/server/src/game/include/defs.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - defs.h - include file for all def_* files related stuff used by all modules - - MODIFIED: 21 Sep 2006 Hammag - REASON: - created - -*/ - -#ifndef DEFS_H -#define DEFS_H - -#include "defparser.h" -#include "defmap.h" - -#include "def_actionmod.h" -#include "def_ammo.h" -#include "def_appartements.h" -#include "def_appplaces.h" -#include "def_blueprintpieces.h" -#include "def_characters.h" -#include "def_charaction.h" -#include "def_charkinds.h" -#include "def_damage.h" -#include "def_drugs.h" -#include "def_factions.h" -#include "def_hack.h" -#include "def_implants.h" -#include "def_itemcontainer.h" -#include "def_itemmod.h" -#include "def_itemres.h" -#include "def_items.h" -#include "def_mission.h" -#include "def_npcarmor.h" -#include "def_npcgroupspawn.h" -#include "def_npc.h" -#include "def_outposts.h" -#include "def_recycles.h" -#include "def_respawn.h" -#include "def_shots.h" -#include "def_skills.h" -#include "def_subskills.h" -#include "def_trader.h" -#include "def_vehicles.h" -#include "def_vehiclesits.h" -#include "def_weapons.h" -#include "def_weather.h" -#include "def_worlds.h" -#include "def_worldfile.h" -#include "def_worldmodels.h" -#include "def_scripts.h" - -#include "gamedefs.h" - -#endif - diff --git a/server/src/game/include/doortemplate.h b/server/src/game/include/doortemplate.h deleted file mode 100644 index fc8f9d1..0000000 --- a/server/src/game/include/doortemplate.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - -/* - doortemplate.h - world door template class - - MODIFIED: 05 Nov 2006 Hammag - REASON: - creation - -*/ - - -#ifndef DOORTEMPLATE_H -#define DOORTEMPLATE_H - -#include "def_worldmodels.h" - -class PDoorTemplate -{ - friend class PWorldDatParser; - - private: - u16 mDoorID; - - // The commented out values are not loaded from dat file atm because they are not used yet. - //u16 mUnknown1; //18 00 - //u16 mUnknown1bis; //00 00 ? varies - f32 mPosY; - f32 mPosZ; - f32 mPosX; - //u16 mUnknown5; //00 00 ? second byte varies - u16 mWorldmodelID; //door type from worldmodel.def - - std::string mDoorTypeName; - int mDoorParameters[4]; - bool mIsDoubleDoor; - bool mIsTriggeredDoor; - - const PDefWorldModel* mDefWorldModel; - - public: - PDoorTemplate(); - ~PDoorTemplate(); - - inline u16 GetID() { return mDoorID; } - inline u16 GetUseFlags() { return (mDefWorldModel ? mDefWorldModel->GetUseFlags() : 0); } - inline u16 GetFunctionType() { return (mDefWorldModel ? mDefWorldModel->GetFunctionType() : 0); } - inline int GetFunctionValue() { return (mDefWorldModel ? mDefWorldModel->GetFunctionValue() : 0); } - inline const std::string& GetName() const { return (mDefWorldModel ? mDefWorldModel->GetName() : EmptyString ); } /// !!!! - inline const PDefWorldModel* GetDefWorldModel() const { return mDefWorldModel; } - - inline void GetPos(f32* nPosX, f32* nPosY, f32* nPosZ) const { *nPosY = mPosY; *nPosZ = mPosZ; *nPosX = mPosX;} - inline u16 GetOtherDoorID() { return ( mIsDoubleDoor ? mDoorParameters[1] : 0 ); } - inline bool IsDoubleDoor() const { return mIsDoubleDoor; } - inline bool IsTriggeredDoor() const { return mIsTriggeredDoor; } - - void SetDoorTypeName(char* nDoorTypeName); - void SetDoorParameters(char* nDoorParametersString); -}; - -#endif diff --git a/server/src/game/include/furnituretemplate.h b/server/src/game/include/furnituretemplate.h deleted file mode 100644 index 9f84ebb..0000000 --- a/server/src/game/include/furnituretemplate.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - -/* - furnituretemplate.h - world furniture template class - - MODIFIED: 04 Oct 2006 Hammag - REASON: - creation - -*/ - - -#ifndef FURNITURETEMPLATE_H -#define FURNITURETEMPLATE_H - -#include "def_worldmodels.h" - -enum // Furniture Use flags (cumlative) -{ - ufTouchable = 1, - ufUsable = 2, - ufNoCollision = 4, - ufChair = 8, - ufToolTarget = 16, - ufSelfCollisionBox = 64, - ufGraphicalEffect = 128, - ufNoSelectionBox = 256 -}; - -class PFurnitureItemTemplate -{ - friend class PWorldDatParser; - - private: - u32 mObjectID; - - // The commented out values are not loaded from dat file atm because they are not used yet. - f32 mPosY; //= mPosY from dat file + 32000, to be coherent with char Pos scale - f32 mPosZ; - f32 mPosX; - //f32 mRotY; - f32 mRotZ; - //f32 mRotX; - //u32 mScale; //00 00 80 3F ? = float(1.0000) scale factor ? // mostly used by holoscreens (passiv object) - //u32 mUnknown2; //01 00 00 00 ? - u16 mModelID; // points to models.ini - //u32 mUnknown3; //00 00 00 00 ? - //u32 mUnknown4; //00 00 00 00 ? - u16 mWorldmodelID; // points to worldmodel.def - //u16 mUnknown5; //12 00 ? // changes sometime (ex: c288 ...) - - //f32 mBoxLowerY; //Bounding box, for use when ufSelfCollisionBox is set in mUseFlags. - //f32 mBoxLowerZ; - //f32 mBoxLowerX; - //f32 mBoxUpperY; - //f32 mBoxUpperZ; - //f32 mBoxUpperX; - - u16 mFrontPosY; - u16 mFrontPosZ; - u16 mFrontPosX; - u8 mFrontLR; - - const PDefWorldModel* mDefWorldModel; - - u32 mLinkedObjectID; // for buttons, stores the corresponding triggered door - // fo GR, stores order of the GR entity (spawn point) to later choose from respawn.def data - - public: - PFurnitureItemTemplate(); - ~PFurnitureItemTemplate(); - - inline u32 GetID() const { return mObjectID; } - inline u16 GetUseFlags() const { return ( mDefWorldModel ? mDefWorldModel->GetUseFlags() : 0 ); } - inline u16 GetFunctionType() const { return ( mDefWorldModel ? mDefWorldModel->GetFunctionType() : 0 ); } - inline int GetFunctionValue() const{ return ( mDefWorldModel ? mDefWorldModel->GetFunctionValue() : 0 ); } - inline const std::string& GetName() const { return ( mDefWorldModel ? mDefWorldModel->GetName() : EmptyString ); } /// !!!! - inline const PDefWorldModel* GetDefWorldModel() const { return mDefWorldModel; } - inline u8 GetFrontLR() const { return mFrontLR; } - inline void GetFrontPos( u16* nFrontPosX, u16* nFrontPosY, u16* nFrontPosZ ) const { *nFrontPosY = mFrontPosY; *nFrontPosZ = mFrontPosZ; *nFrontPosX = mFrontPosX;} - inline void GetPos( f32* nPosX, f32* nPosY, f32* nPosZ ) const { *nPosY = mPosY; *nPosZ = mPosZ; *nPosX = mPosX;} - - inline void SetLinkedObjectID( u32 nID ) { mLinkedObjectID = nID; } - inline u32 GetLinkedObjectID() const { return mLinkedObjectID; } - -}; - -#endif - -// *** from worldmodel.def *** - -//function Type -// 0 - none -// 1 - Itemcontainer -// 2 - Terminal -// 3 - Outfitter -// 4 - Trader -// 5 - Mineral -// 6 - Respawn Station -// 7 - GoGuardian -// 8 - Hackterminal -// 9 - Appartement Eingang -// 10 - Appartement Ein/Ausgang -// 11 - Appartement Klingel/�ffner -// 12 - Standard Button -// 13 - Hack Button -// 14 - HOLOMATCH ENTRANCE -// 15 - HOLOMATCH EXIT -// 16 - HOLOMATCH REFRESH -// 17 - HOLOMATCH HEAL -// 18 - WORLDCHANGEACTOR -// 19 - CLANTERMINAL -// 20 - DATFILE WORLDCHANGE ACTOR -// 21 - LOCATION FOR 20 -// 22 - -// 23 - EINTRITTSGELD BUTTON -// 24- TUTORIALEXIT -// 25 - EXPLOSIVE -// 26 - Outpost Switch -// 27 - Old goguardian -// 28 - Fahrzeug Depot Interface -// 29 - Underground Exit -// 30 - Static FX (Value=Type. 1=Fire 2=Smoke 3=Steam 4=Sparkle) -// 31 - Venture Warp Station -// 32 - functionvalue+100 gibt eine Meldung aus der Text.ini [MISC] an. -// diff --git a/server/src/game/include/gamescript.h b/server/src/game/include/gamescript.h deleted file mode 100644 index 382bbe7..0000000 --- a/server/src/game/include/gamescript.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -#ifndef GAMESCRIPT_H -#define GAMESCRIPT_H - -enum PHookTypes -{ - HOOK_CHAT, - HOOK_TRADE, - HOOK_ZONE -}; - -class PGameScript -{ - private: - typedef std::map HookMap; - HookMap mHooks; - - public: - PGameScript(); - ~PGameScript(); - - bool LoadScripts(); - bool Rehash(); - void TriggerHook(PHookTypes hook); -}; - -#endif diff --git a/server/src/game/include/genreplist.h b/server/src/game/include/genreplist.h deleted file mode 100644 index 043945d..0000000 --- a/server/src/game/include/genreplist.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - genreplist.h - classe for character genrep list - - MODIFIED: 20 Sep 2006 Hammag - REASON: - creation - -*/ - -#ifndef GENREPLIST_H -#define GENREPLIST_H - -#define GENREPLIST_ALLOC_SIZE 4 // atomicity of list entries allocation - -class PGenrepList -{ - private: - enum { // genrep DB Table fields - g_id = 0, - g_worldid, - g_stationid, - g_charid - }; - struct PGenrepEntry - { - u16 mWorldID; - u16 mStationID; - }; - - u32 mOwnerCharID; - u8 mListMaxSize; - u8 mListSize; - PGenrepEntry* mGenrepList; - - void IncreaseMaxSize(u8 nNewMax = 0); - u8 FindEntry(u16 nWorldID, u16 nStationID); - - public: - PGenrepList(u32 nOwnerCharID); - ~PGenrepList(); - bool AddGenrep(u16 nWorldID, u16 nStationID); - //bool RemoveChar(u32 nBuddyCharID); - inline u8 Count() { return mListSize; } - u16 GetListDataSize() { return (sizeof(PGenrepEntry) * mListSize); } - const void* GetListData() { return (const void*)mGenrepList; } - bool SQLLoad(); -// bool SQLSave(); -}; - -#endif diff --git a/server/src/game/include/globals.h b/server/src/game/include/globals.h deleted file mode 100644 index 634f328..0000000 --- a/server/src/game/include/globals.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - globals.h - - MODIFIED: 12 September 2005 Akiko - REASON: - exchanged Pretender Strings by TinNS - - removed some Windows specific code - MODIFIED: 16 Dec 2005 bakkdoor - REASON: - Added global ClientManager and Chat Interface - MODIFIED: 22 Dec 2005 Namikon - REASON: - Added GPL - -*/ - -#ifndef GLOBALS_H -#define GLOBALS_H - -extern class PLuaEngine *LuaEngine; - -extern class ServerSocket *ServerSock; -extern class PConsole *Console; -//extern class PRConsole *RemoteConsole; -extern class PConfig *Config; -extern class PConfig *CmdAccess; - -extern class PGameDefs *GameDefs; -extern class PFileSystem *Filesystem; -extern class PServer *Server; - -extern class PGameServer *GameServer; -extern class PChars *Chars; - -extern class PMsgBuilder *MsgBuilder; -extern class PWorlds *Worlds; -extern class PAppartements* Appartements; -extern class PWorldActors* WorldActors; -extern class PTerminal* Terminal; -//extern class gmMachine machine; // Virtual Machine instance - -//multiuser chat -extern class PClientManager *ClientManager; -extern class PNPCManager* NPCManager; -extern class PChat *Chat; -extern class PCommands *GameCommands; - -extern class POutpost *Outposts; -extern class PMultiPart *MultiPartHandler; - -// Development debug output control -extern bool gDevDebug; - -//MySQL-Support -extern class PMySQL* MySQL; - -//Vehicles -extern class PVehicles *Vehicles; -extern class PSubway* Subway; - -//Infoserver update -extern class PISC *ISC; - -//Empty string -extern const std::string EmptyString; - -extern const char ServerVersion[]; -extern const char SVNRevision[]; - -bool InitTinNS(); -void Shutdown(); - -#endif - diff --git a/server/src/game/include/inventory.h b/server/src/game/include/inventory.h deleted file mode 100644 index 6c20906..0000000 --- a/server/src/game/include/inventory.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - inventory.h - classes for inventories - (inventory, belt, armor, implants, gogo, processor(?), maybe other containers(?) ) - - MODIFIED: 10 Jul 2006 Hammag - REASON: - creation - - -*/ - -#ifndef INVENTORY_H -#define INVENTORY_H - -//NC containers message locations -#define INV_LOC_GROUND 1 -#define INV_LOC_WORN 2 -#define INV_LOC_BACKPACK 3 -#define INV_LOC_BOX 4 -#define INV_LOC_NPCTRADE 5 -#define INV_LOC_GOGO 18 -#define INV_LOC_BOX2 255 -//PC-Trade window = ? - -//Inventory containers info -#define INV_WORN_QB_START 0 -#define INV_WORN_QB_END 9 -#define INV_WORN_QB_NONE 99 -#define INV_WORN_QB_HAND 11 - -#define INV_WORN_PROC_START 12 -#define INV_WORN_PROC_END 24 - -#define INV_WORN_IMP_START 26 -#define INV_WORN_IMP_END 38 - -#define INV_WORN_ARMOR_START 39 -#define INV_WORN_ARMOR_END 43 - -#define INV_WORN_COLS 44 -#define INV_WORN_MAXSLOTS 44 - - -#define INV_BACKPACK_COLS 10 - -#define INV_GOGO_COLS 5 -#define INV_GOGO_MAXSLOTS 50 - -#define INV_CABINET_COLS 5 -#define INV_CABINET_MAXSLOTS 33 - -// inv_loc values in database -#define INV_DB_LOC_GOGO 1 -#define INV_DB_LOC_WORN 2 -#define INV_DB_LOC_BACKPACK 3 - -class PItem; -class PContainer; -class PContainerWithHoles; -class PContainer2DWorkaround; -class PContainerAutoFindFree; - -class PInventory -{ - private: - PContainerWithHoles* mWorn; // PContainerLinearSlots - PContainer2DWorkaround* mBackpack; // PContainer2DAreas - PContainerAutoFindFree* mGogo; // PContainerLinearSlots - - public: - - PInventory(); - ~PInventory(); - - void SetCharId(u32 CharID); - bool SQLLoad(); - bool SQLSave(); - PContainer* GetContainer(u8 nInvLoc); - inline PContainer2DWorkaround* GetBackpackContainer() { return mBackpack; } - - bool IsDirty() const; - - bool AddItem(PItem* NewItem, u8 nInvLoc = INV_LOC_BACKPACK, u32 nInvID = 0, u8 nPosX = 0, u8 nPosY = 0, bool SetDirty = true); - //bool CheckItem(u32 ItemID, u8 StackSize = 1); - //PItem *GetItem(u32 ItemID, u8 StackSize = 1); - //PItem *GetItemByPos(u8 nPosX, u8 nPosY, u8 StackSize = 1); - //bool MoveItem(u8 oPosX, u8 oPosY, u8 dPosX, u8 dPosY); - - //bool QB_IsFree(u8 nSlot); - //void QB_SetSlot(u8 nSlot, u16 nItemID); - //u16 QB_GetSlot(u8 nSlot); - //void QB_Move(u8 nSlotSRC, u8 nSlotDST); -}; - -#endif diff --git a/server/src/game/include/item.h b/server/src/game/include/item.h deleted file mode 100644 index aaed849..0000000 --- a/server/src/game/include/item.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - item.h - item class - - MODIFIED: 11 Jul 2006 Hammag - REASON: - creation - - TODO: Add CreatorID (for "named" item), CurrentMunitionID, CurrentMunitionNb (for weapons & charge-items: muns, medkit, etc.) to DB, equipped/free slots, & corresponding code -*/ - -#ifndef ITEM_H -#define ITEM_H - -#define MAX_ITEMSTACK_SIZE 250 - -//Type -#define ITEM_TYPE_VARIOUS 0 -#define ITEM_TYPE_WEAPON 1 -#define ITEM_TYPE_AMMO 2 -#define ITEM_TYPE_HEALTH 3 -#define ITEM_TYPE_IMPLANT 4 -#define ITEM_TYPE_DRUG 5 -#define ITEM_TYPE_MOD 6 -#define ITEM_TYPE_GFXMOD 7 -#define ITEM_TYPE_BLUEPRINT 8 -#define ITEM_TYPE_ARMOR 9 -#define ITEM_TYPE_PSIMOD 10 -#define ITEM_TYPE_PSIMODREADY 11 -#define ITEM_TYPE_REPAIR 12 -#define ITEM_TYPE_RECYCLER 13 -#define ITEM_TYPE_DATACUBE 14 -#define ITEM_TYPE_CONSTRUCTOR 15 -#define ITEM_TYPE_RESEARCHER 16 -#define ITEM_TYPE_IMPLANTER 17 -#define ITEM_TYPE_APARTMENTKEY 18 -#define ITEM_TYPE_CLANKEY 19 -#define ITEM_TYPE_CASHCUBE 20 -#define ITEM_TYPE_AUTOWEAPON 21 -#define ITEM_TYPE_VHCKEY 22 -#define ITEM_TYPE_UNIDENTPART 24 -#define ITEM_TYPE_WRECKEDPART 25 -#define ITEM_TYPE_SALVAGE 26 -#define ITEM_TYPE_VHCCOMPONENT 27 -#define ITEM_TYPE_RECORDABLE 28 - - - -// gfxmodflags -#define ITEM_MOD_FLASHLIGHT 1 -#define ITEM_MOD_SCOP 2 -#define ITEM_MOD_SILENCER 4 -#define ITEM_MOD_LASERPOINTER 8 - -// itemflags: -#define ITEM_FLAG_RESEARCHABLE 1 -#define ITEM_FLAG_NO_DROP 2 -#define ITEM_FLAG_NO_MAX_REPAIRE_DECAY 4 -#define ITEM_FLAG_AMMO 8 // for loadable ammo -// not sure for ITEM_FLAG_AMMO - -class PItem -{ - friend class PContainerEntry; - friend class PMsgBuilder; - - private: - u32 mItemID; - const PDefItems* mDefItem; - - bool mStackable; - u8 mStackSize; - - u32 mLoadedAmmoId; - u8 mLoadedAmmoNb; - - u8 mPropertiesFlags; - - u8 mCurDuration; - u8 mMaxDuration; - u8 mDamages; - u8 mFrequency; - u8 mHandling; - u8 mRange; - - u8 mUsedSlots; - u8 mMaxSlots; - u8 mSlot[5]; - u8 mModificators; - - u32 mConstructorId; - - public: - PItem(u32 ItemID, u8 nStackSize = 1, u8 CurDur = 0, u8 MaxDur = 0, u8 Dmg = 0, u8 Freq = 0, u8 Hand = 0, u8 Rng = 0); - //~PItem(); - void MakeItemStandard(u8 GlobalQualityMin = 120, u8 GlobalQualityMax = 180); - - inline u32 GetItemID() {return mItemID; } - - inline int GetType() { return mDefItem->GetType(); } - inline u8 GetItemflags() { return mDefItem->GetItemflags(); } - inline const std::string &GetName() const { return mDefItem->GetName(); } - inline u8 GetSizeX() { return mDefItem->GetSizeX(); } - inline u8 GetSizeY() { return mDefItem->GetSizeY(); } - inline float GetWeight() { return mStackSize * mDefItem->GetWeight(); } - inline float GetSingleUnitWeight() { return mDefItem->GetWeight(); } - inline float GetFillWeight() { return mDefItem->GetFillWeight(); } - inline u32 GetBasePrice() { return mDefItem->GetBasePrice(); } - inline u16 GetTechlevel() { return mDefItem->GetTechlevel(); } - inline int GetValue1() { return mDefItem->GetValue1(); } - inline int GetValue2() { return mDefItem->GetValue2(); } - inline int GetValue3() { return mDefItem->GetValue3(); } - inline int GetQualifier() { return mDefItem->GetQualifier(); } - - inline bool IsStackable() { return mDefItem->IsStackable(); } - inline u8 GetStackSize() { return mStackSize; } - u8 AddToStack(u8 ItemNb); // return the nb of items NOT added - u8 TakeFromStack(u8 ItemNb); // return the nb of retreived items - - //mItemGroupID = def->GetItemGroupID(); - -}; - -#endif diff --git a/server/src/game/include/lua_engine.h b/server/src/game/include/lua_engine.h deleted file mode 100644 index 0d4e146..0000000 --- a/server/src/game/include/lua_engine.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -TinNS (TinNS is not a Neocron Server) -Copyright (C) 2005 Linux Addicted Community -maintainer Akiko - -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 -of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301, USA. -*/ - -/* - -lua_engine.h - TinNS Lua engine for processing NPC scripts - -CREATION: 13 Oct 2009 Namikon - -*/ - -#ifndef PLUA_H -#define PLUA_H - -extern "C" { - #include - #include - #include -} - -#define PLUAENGINE_DEFAULT 0 -#define PLUAENGINE_GETANSWER 4096 -#define PLUAENGINE_EXECUTENODE 8192 - -class PLuaEngine -{ - private: - PClient* mTargetClient; - - bool mRunning; - lua_State *mLua; - - std::vector mReturnValues; - - - // Return Values - int mReturn_INT; -// std::string mReturn_STR; - // add more if needed... - - void CleanUp(); - bool ExecuteScript(std::string nLUAScript, int nNode, int nDialogClass = 0); - - public: - PLuaEngine(); - ~PLuaEngine(); - - // To check if LUA Script has syntax errors or whatever - bool CheckLUAFile(std::string nLUAScript); - void AddScriptResult(int nResult); - void ProcessDialogScript(PClient* nClient, std::string mLUAFile, int nAnswer); - inline PClient* GetBoundClient() { return mTargetClient; }; - - inline void SetReturnINT(int nValue) { mReturn_INT = nValue; }; - // inline void SetReturnSTR(std::string nValue) { mReturn_STR = nValue; }; -}; - - -#endif diff --git a/server/src/game/include/msgbuilder.h b/server/src/game/include/msgbuilder.h deleted file mode 100644 index eed5da4..0000000 --- a/server/src/game/include/msgbuilder.h +++ /dev/null @@ -1,180 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - msgbuilder.h - a classes to build NC messages - - CREATION: 30 Aug 2006 Hammag - - MODIFIED: - REASON: - - -*/ - -#ifndef MSGBUILDER_H -#define MSGBUILDER_H - -class PClient; -class PMessage; -class PContainerEntry; -class PContainer; -class PSpawnedVehicle; - -class PMsgBuilder -{ -private: - -public: - PMsgBuilder() {}; - ~PMsgBuilder() {}; - -// Following methods for broadcasted messages do NOT include UDP_ID increment -// when needed, nor UDP_ID / SessionID setting -// as these must be set on a destination client basis - PMessage* BuildCharHelloMsg( PClient* nClient ); - PMessage* BuildCharHealthUpdateMsg( PClient* nClient ); - PMessage* BuildCharDeathMsg( PClient* nClient, u32 nKillerCharId = 0 ); - PMessage* BuildCharPosUpdateMsg( PClient* nClient ); - PMessage* BuildCharPosUpdate2Msg( PClient* nClient, u8 InfoBitfield = 0x7f ); - //PMessage* BuildCharSittingMsg( PClient* nClient ); // Not used anymore, done by BuildCharPosUpdateMsg - PMessage* BuildCharExitSeatMsg( PClient* nClient ); - PMessage* BuildDoorOpenMsg( u32 nRawItemID, bool nDoubleDoor = false ); - PMessage* BuildCharUseSeatMsg( PClient* nClient, u32 nRawObjectId, u8 nSeatId = 0 ); - PMessage* BuildCharShowGlowCircleMsg( PClient* nClient ); - - PMessage* BuildSpawnWorldObjectMsg( u16 nModelID, u16 nFunctionID, u32 nWOID, u16 nPosX, u16 nPosY, u16 nPosZ, u8 nRotX, u8 nRotY, u8 nRotZ ); - PMessage* BuildRemoveWorldObjectMsg( u32 nWOID ); - PMessage* BuildWeatherControlMsg( u16 nWeatherId ); - - PMessage* BuildSubwaySingleUpdateMsg( u32 nVehicleID, u16 nPosition, u8 nDoorOpened ); - PMessage* BuildVhcHealthUpdateMsg( PSpawnedVehicle* nVehicle ); - PMessage* BuildVhcPosUpdateMsg( PSpawnedVehicle* nVehicle ); - PMessage* BuildVhcPosUpdate2Msg( PSpawnedVehicle* nVehicle ); - - PMessage* BuildStartWeaponReloadAnimMsg( PClient* nClient ); - PMessage* BuildHeldItemUseMsg( u16 nUserCharLocalId, u16 nWeaponId, u32 nTargetRawItemID, u8 nAiming, u8 nTargetedHeight, u8 nScore = 0 ); - PMessage* BuildHeldItemUse2Msg( u16 nUserCharLocalId, u32 nTargetRawItemID ); - PMessage* BuildHeldItemUse4Msg( u16 nUserCharLocalId, u32 nTargetRawItemID, u16 nUnknown1, u16 nUnknown2, u8 nTargetedHeight ); - PMessage* BuildHeldItemAddonActivationMsg( PClient* nClient, u8 nState ); - - // Temp. NPC update message for testing - PMessage* BuildNpcDeathMsg( PClient* nClient, u32 nNpcId, u8 unknown1 = 0x4a, u8 npcAction = 0x1e ); - - PMessage* BuildNPCMassInfoMsg( u32 nWorldID, u16 nTypeID, u16 nClothing, u16 nNameID, u16 nPosY, u16 nPosZ, u16 nPosX, u16 nHealth, u16 nTraderID, std::string *nAngleStr, std::string *nNpcName, std::string *nCustomName); - PMessage* BuildNPCMassAliveMsg( u32 nWorldID, u16 nX, u16 nY, u16 nZ, u8 nActionStatus, u8 nHealth, u8 nAction ); - PMessage* BuildNPCMassUpdateMsg( u32 nWorldID, u16 nX, u16 nY, u16 nZ, u8 nActionStatus, u8 nHealth, u16 nTarget, u8 nAction ); - // Moved here since its a zone broadcast! - PMessage* BuildNpcCleanupMsg( u32 nNpcId, u8 nCmd = 6 ); // see implementation about nCmd - -// Following methods for unicast messages DO include UDP_ID increment and -// UDP_ID / SessionID setting when needed (at least for now) - PMessage* BuildOutpostClanInfoMsg( PClient* nClient, u32 nClanID, u8 nFaction ); - PMessage* BuildTryAccessAnswerMsg(PClient* nClient, char *nArea, bool nAllowed); - PMessage* BuildReceiveDBAnswerMsg( PClient* nClient, PMessage* nResultBuffer, std::string* nCommandName, u16 nNumRows, u16 nNumFields); - PMessage* BuildYouGotEmailsMsg( PClient* nClient, u8 nMailCount ); - - PMessage* BuildNPCStartDialogMsg( PClient* nClient, u32 nNPCWorldID, std::string *nDialogScript ); - PMessage* BuildNPCDialogReplyMsg( PClient* nClient, u16 nNextNode, std::vector*nResultBuffer); - PMessage* BuildReqNPCScriptAnswerMsg( u32 nInfoId, std::string *nNPCScript ); - PMessage* BuildNPCShoppingListMsg( PClient* nClient, PMessage* nContentList, int nWorldID, u8 nItemQuality); - PMessage* BuildNPCBeginAllBuyerTradeMsg( PClient* nClient, int nWorldID ); - - PMessage* BuildNPCSingleInfoMsg( PClient* nClient, u32 nWorldID, u16 nTypeID, u16 nClothing, u16 nNameID, u16 nPosY, u16 nPosZ, u16 nPosX, u16 nHealth, u16 nTraderID, std::string *nAngleStr, std::string *nNpcName, std::string *nCustomName); - PMessage* BuildNPCSingleAliveMsg( PClient* nClient, u32 nWorldID, u16 nX, u16 nY, u16 nZ, u8 nActionStatus, u8 nHealth, u8 nAction ); - PMessage* BuildNPCSingleUpdateMsg( PClient* nClient, u32 nWorldID, u16 nX, u16 nY, u16 nZ, u8 nActionStatus, u8 nHealth, u16 nTarget, u8 nAction ); - - // NEW for testing. Combined update message - PMessage* BuildNPCUpdateMsg(u32 nWorldID, u16 nPosY, u16 nPosZ, u16 nPosX, u8 nActionBM, u16 nHealth, u8 nWeaponState, u8 nUnknown, u32 nTargetID = 0); - - PMessage* BuildReqInfoAnswerMsg( PClient* nClient, u16 nReqType, u32 nInfoId, void* nResponse, u16 nResponseLength ); - - PMessage* BuildPacket0Msg( PClient* nClient ); - PMessage* BuildPingMsg( PClient* nClient, u32 nClientTime ); - PMessage* BuildBaselineMsg( PClient* nClient ); - PMessage* BuildAliveRepMsg( PClient* nClient ); - - PMessage* BuildZoning1Msg( PClient* nClient, u16 nEntity, u8 nUnknown = 0 ); - PMessage* BuildZoningTCPReadyMsg(); - PMessage* BuildSendZoneTCPMsg( u32 nLocation, std::string* nWorldName ); - PMessage* BuildZoning2Msg( PClient* nClient, u32 nClientTime ); - PMessage* BuildGenrepZoningMsg( PClient* nClient, u32 nLocation, u16 nEntity ); - - PMessage* BuildGenrepAddToListMsg( PClient* nClient, u32 nLocation, u16 nEntity ); - - PMessage* BuildAptLiftUseMsg( PClient* nClient, u32 nLocation, u16 nEntity, u8 nEntityType = 0 ); - PMessage* BuildAptLiftFailedMsg( PClient* nClient ); - PMessage* BuildChangeLocationMsg( PClient* nClient, u32 nLocation, u16 nEntity, u8 nEntityType = 0, u32 nRawItemID = 0 ); - PMessage* BuildEntityPositionMsg( PClient* nClient, u16 pX, u16 pY, u16 pZ ); - - PMessage* BuildCharAptLocInfoMsg( PClient* nClient ); - - PMessage* BuildLevelUpMessage( PClient* nClient, u8 nMainSkill, u8 nNewLevel, u16 nFreeSkillPoints); - PMessage* BuildSubskillIncMsg( PClient* nClient, u8 nSubskill, u16 nSkillPoints ); - PMessage* BuildChatAddMsg( PClient* nClient, u32 nAddedCharID, u8 nMode ); // mode = 1 for Direct, 2 for Buddy - - PMessage* BuildText100Msg( PClient* nClient, u8 nTxtMsgId, u32 nRawObjectID ); - PMessage* BuildTextIniMsg( PClient* nClient, u8 nTxtGroupID, u16 nTxtID ); - - PMessage* BuildCharInteractionMenuMsg( PClient* nClient, u32 nRawTargetID ); - - PMessage* BuildFurnitureActivateMsg( PClient* nClient, u32 nRawObjectID, u8 nActionValue ); - PMessage* BuildCharUseFurnitureMsg( PClient* nClient, u32 nRawObjectID ); - PMessage* BuildCharUseVhcTerminalMsg( PClient* nClient, u32 nRawObjectID ); - PMessage* BuildCharUseGogoMsg( PClient* nClient ); - PMessage* BuildCharUseVentureWarpMsg( PClient* nClient, u32 nRawObjectID ); - PMessage* BuildVhcAccessRequestMsg (PClient* nClient, u32 nRequestId, u32 nRequesterCharId, u32 nRequesterLocalId, u32 nVhcRawObjectID ); - PMessage* BuildCharUseGenrepMsg( PClient* nClient, u32 nRawObjectID, u32 nLocation, u16 nEntity ); - PMessage* BuildCharUseLiftMsg( PClient* nClient, u32 nRawObjectID, u16 nAptPlace ); - PMessage* BuildCharUseVhcMsg( PClient* nClient, u32 nRawObjectID, u16 nVhcType, u16 nAvailableSeats ); - - PMessage* BuildCharMoneyUpdateMsg( PClient* nClient, u32 nCredits ); - PMessage* BuildUndefineduseMsg( PClient* nClient, u8 nValue ); - PMessage* BuildCharUseQBSlotMsg2( PClient* nClient, u16 nV1 = 100, u16 nV2 = 100, u16 nV3 = 100, u16 nV4 = 100, u16 nV5 = 100, u16 nV6 = 100, u16 nV7 = 0 ); - PMessage* BuildCharUseQBSlotMsg3( PClient* nClient, u8 nSlot ); - PMessage* BuildCharUseQBSlotMsg4( PClient* nClient, u16 nWeaponId ); - PMessage* BuildContainerContentList( PContainer* nContainer, u8 nLocType ); - PMessage* BuildContainerContentEntry( PContainerEntry* nEntry, u8 nLocType ); - - PMessage* BuildCharOpenContainerMsg( PClient* nClient, u32 nContainerID, PContainer* nContainer ); - PMessage* BuildItemMoveMsg( PClient* nClient, u8 nSource, u8 nSrcX, u8 nSrcY, u8 nDestination, u8 nDestX, u8 nDestY, u8 nItemCnt ); - PMessage* BuildBoxItemMoveMsg( PClient* nClient, PContainerEntry* nEntry, u8 nSrcX, u8 nSrcY, u8 nDestination, u8 nDestX, u8 nDestY, u8 nItemCnt ); - PMessage* BuildStartWeaponReloadMsg( PClient* nClient ); - - PMessage* BuildStartHackGameMsg( PClient* nClient, u32 nWorldObjID, u8 nHackDifficult ); - - PMessage* BuildSubwaySpawnMsg( PClient* nClient, bool IsSecondMessage ); - //PMessage* BuildSubwayFullUpdateMsg(PClient* nClient); - PMessage* BuildVhcInfoMsg( PClient* nClient, PSpawnedVehicle* nVehicle ); - - PMessage* BuildDBRequestStatusMsg( PClient* nClient, std::string* nCommandName, u8 nStatus, u16 nErrCode ); - PMessage* BuildDBAnswerMsg( PClient* nClient, std::string* nCommandName, std::string* nAnswerData, u16 nRows, u16 nCols ); - - PMessage* BuildTraderItemListMsg( PClient* nClient, u32 nTraderNpcID ); - - PMessage* BuildHeldItemUse3Msg( PClient* nClient, u16 nUnknown1, u16 nUnknown2, u16 nUnknown3, u16 nUnknown4 ); - - PMessage* BuildCharUseTimedDrugMsg( PClient* nClient, const PDefDrug* nDrugDef, u16 nItemId ); - PMessage* BuildCharUseInstantDrugMsg( PClient* nClient, const PDefDrug* nDrugDef ); - PMessage* BuildCharUseRecreationUnitMsg( PClient* nClient, u32 nObjectId ); -}; - -#endif diff --git a/server/src/game/include/msgdecoder.h b/server/src/game/include/msgdecoder.h deleted file mode 100644 index a1a03cf..0000000 --- a/server/src/game/include/msgdecoder.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - msgdecoder.h - top class for NC messages decoding - - CREATION: 23 Aug 2006 Hammag - - MODIFIED: - REASON: - - -*/ - -#ifndef MSGDECODER_H -#define MSGDECODER_H - -struct PGameState; -class PClient; -class PMessage; -class PUdpMsgAnalyser; - -#define DECODE_UNDEF 0 -#define DECODE_ERROR 1 // one error occured on the current decoding step -#define DECODE_UNKNOWN 2 // the current decoded (sub)message is unkown -#define DECODE_MORE 4 // more decoding needed for the (sub)message -#define DECODE_FINISHED 8 // decoding if finished for the whole message -#define DECODE_ACTION_READY 16 // an action is ready to be done -#define DECODE_ACTION_DONE 32 // the action triggered hasn't to be triggered again -#define DECODE_ACTION_IGNORED 64 // the action wasn't performed for some (good) reason (to combine or not with DONE) -#define DECODE_ACTION_FAILED 128 // the action failed totally or partially (to combine or not with DONE) - - -struct PMsgDecodeData -{ - PMessage* mMessage; - PClient* mClient; - u8 mState; - u8 mUnknownType; - bool mHandling0x13Sub; - u16 Sub0x13Start; - u16 Sub0x13StartNext; - std::stringstream mName; - std::string mErrorDetail; - bool mTraceKnownMsg; - bool mTraceUnknownMsg; - bool mTraceDump; - PGameState* mClientState; // Temporary until State is put back in Client object -}; - -// UDP Message decoder -// boolean methods return true if successful - -class PUdpMsgDecoder -{ - private: - PMsgDecodeData mDecodeData; - PUdpMsgAnalyser* mCurrentAnalyser; - std::string mPacketName; - std::string mTmpName; - - void Init(PMessage* nMessage, PClient* nClient); - - public: - PUdpMsgDecoder(); - PUdpMsgDecoder(PMessage* nMessage, PClient* nClient); - ~PUdpMsgDecoder(); - - bool Analyse(); - bool Analyse(PMessage* nMessage, PClient* nClient); // Can be used on non initialized or already used object - // Temporary form until State is put back in Client object - inline void Init(PMessage* nMessage, PClient* nClient, PGameState *nClientState) { mDecodeData.mClientState = nClientState; Init(nMessage, nClient); } - inline u8 GetState() { return mDecodeData.mState; } - inline bool IsError() { return (mDecodeData.mState & DECODE_ERROR); } - inline bool IsKnown() { return (!(mDecodeData.mState & DECODE_UNKNOWN)); } - inline bool MoreSubMsg() { return mDecodeData.mHandling0x13Sub; } - inline bool IsActionReady() { return (mDecodeData.mState & DECODE_ACTION_READY); } - inline bool IsActionDone() { return (mDecodeData.mState & DECODE_ACTION_DONE); } - inline bool IsTraceKnownMsg() { return mDecodeData.mTraceKnownMsg; } - inline bool IsTraceUnknownMsg() { return mDecodeData.mTraceUnknownMsg; } - inline bool IsTraceDump() { return mDecodeData.mTraceDump; } - inline void DumpMsg() { if (mDecodeData.mMessage) mDecodeData.mMessage->Dump(); } - inline std::string const &GetName() { return (mTmpName = mDecodeData.mName.str()); } - inline std::string const &GetError() { return mDecodeData.mErrorDetail; } - bool DoAction(); - inline void Reset() { Init(NULL, NULL); } -}; - -#endif diff --git a/server/src/game/include/multipart.h b/server/src/game/include/multipart.h deleted file mode 100644 index 10f16fd..0000000 --- a/server/src/game/include/multipart.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - multipart.h - Handling of incomming multipart messages - - CREATION: 31 Aug 2006 Hammag - - MODIFIED: - REASON: - -*/ - -#ifndef MULTIPART_H -#define MULTIPART_H - -#define MAX_SEQUENCE_LIFE 10 // In seconds - -typedef struct // A single chunk of any multipart sequence -{ - u16 smChunkNr; - //u16 smChunkTotal; - PMessage* smChunk; -} s_MessageChunk; - -typedef std::vector vecMsgChunk; // The vector of an specific multipart sequence, containing all chunks -typedef struct -{ - time_t smTimeStamp; // To keep track of sequence's lifetimer - u16 smChunkTotal; // Total amount of chunks for this sequence - vecMsgChunk smvChunk; // The chunkvector - PClient *smClient; // Required to call terminal class -} s_SequenceEntry; - -typedef std::map PMultipartMap; // Map of all vectors, indexed by sequencenumber - - -class PMultiPart -{ - private: - PMultipartMap MsgMap; - void AssembleChunk(u16 nSequence); - void ProcessPacket(PClient *nClient, PMessage *tmpMsg); - -// Required to process packets here - static const u8 mMaxOptions = 7; - std::string mCommandName; - std::string mOptions[mMaxOptions]; - u8 mOptionsCount; - u16 mDBId; -// --------------------------------- - - public: - PMultiPart(); - ~PMultiPart(); - - void Update(); // Check for complete/timed out sequences - // Adds an multipart frame - void AddMultiPartChunk(PClient *nClient, PMessage *nChunk, u16 nChunkNumber, u16 nChunkTotal, u8 nSequence); -}; - -#endif diff --git a/server/src/game/include/npctemplate.h b/server/src/game/include/npctemplate.h deleted file mode 100644 index c90ac67..0000000 --- a/server/src/game/include/npctemplate.h +++ /dev/null @@ -1,222 +0,0 @@ -/* -TinNS (TinNS is not a Neocron Server) -Copyright (C) 2005 Linux Addicted Community - -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 -of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301, USA. -*/ - - -/* -npctemplate.h - NPC template class - -MODIFIED: 21 Jun 2009 Namikon -REASON: - creation - -*/ - -#ifndef NPCTEMPLATE_H -#define NPCTEMPLATE_H -struct s_f32coords -{ - f32 mX; - f32 mY; - f32 mZ; -}; -typedef std::map PWaypointMap; - -class PNPCTemplate -{ - friend class PWorldDatParser; - -private: - - PWaypointMap mWayPoints; - - u32 mUnknown1; // Is always 0x20001200, in every log. maybe header for NPCs? - f32 mPosY; - f32 mPosZ; - f32 mPosX; - u32 mNPCTypeID; //npc type in npc.def - u8 mActorStringSize; //string size with ending 0 - u8 mAngleStringSize; //string size with ending 0 - u16 mNpcID; - u8 mHasAdditionalCoords; // Seems to be the NUMBER OF additional Coords for the NPC ("Coords" = X/Y/Z in f32, not u16!!) - u8 mUnknown2a; - u8 mUnknown2b; - u8 mUnknown2c; - u16 mTradeID; //mUnknown3; //00 00 ? - u16 mUnknown4; //04 00 ? - std::string mActorName; - std::string mAngle; - - /* // Not sure about that. Commented out until someone finds out how to deal with those "extra" informations - f32 mWaypoint1_Y; - f32 mWaypoint1_Z; - f32 mWaypoint1_X; - f32 mWaypoint2_Y; - f32 mWaypoint2_Z; - f32 mWaypoint2_X; - f32 mWaypoint3_Y; - f32 mWaypoint3_Z; - f32 mWaypoint3_X; - f32 mWaypoint4_Y; - f32 mWaypoint4_Z; - f32 mWaypoint4_X; - f32 mWaypoint5_Y; - f32 mWaypoint5_Z; - f32 mWaypoint5_X; - */ - -public: - PNPCTemplate(); - ~PNPCTemplate(); - - void AddWayPoint(f32 nX, f32 nY, f32 nZ, u8 nID); - // TODO: Add GetWaypoint function - - inline u32 GetUnknown1() const - { - return mUnknown1; - }; - inline f32 GetPosX() const - { - return mPosY; - }; - inline f32 GetPosY() const - { - return mPosZ; - }; - inline f32 GetPosZ() const - { - return mPosX; - }; - inline u32 GetNPCTypeID() const - { - return mNPCTypeID; - }; - inline u8 GetActorStrSize() const - { - return mActorStringSize; - }; - inline u8 GetAngleStrSize() const - { - return mAngleStringSize; - }; - inline u16 GetNpcID() const - { - return mNpcID; - }; - inline u8 GetHasAdditionalCoords() const - { - return mHasAdditionalCoords; - }; - inline u8 GetUnknown2a() const - { - return mUnknown2a; - }; - inline u8 GetUnknown2b() const - { - return mUnknown2b; - }; - inline u8 GetUnknown2c() const - { - return mUnknown2c; - }; - inline u16 /*GetUnknown3*/GetTradeID() const - { - return mTradeID;//mUnknown3; - }; - inline u16 GetUnknown4() const - { - return mUnknown4; - }; - inline std::string GetActorName() const - { - return mActorName; - }; - inline std::string GetAngle() const - { - return mAngle; - }; - - - inline void SetUnknown1( u32 nValue ) - { - mUnknown1 = nValue; - }; - inline void SetPosX( f32 nValue ) - { - mPosY = nValue; - }; - inline void SetPosY( f32 nValue ) - { - mPosZ = nValue; - }; - inline void SetPosZ( f32 nValue ) - { - mPosX = nValue; - }; - inline void SetNPCTypeID( u32 nValue ) - { - mNPCTypeID = nValue; - }; - inline void SetActorStrSize( u8 nValue ) - { - mActorStringSize = nValue; - }; - inline void SetAngleStrSize( u8 nValue ) - { - mAngleStringSize = nValue; - }; - inline void SetNpcID( u16 nValue ) - { - mNpcID = nValue; - }; - inline void SetHasAdditionalCoords( u8 nValue ) - { - mHasAdditionalCoords = nValue; - }; - inline void SetUnknown2a( u8 nValue ) - { - mUnknown2a = nValue; - }; - inline void SetUnknown2b( u8 nValue ) - { - mUnknown2b = nValue; - }; - inline void SetUnknown2c( u8 nValue ) - { - mUnknown2c = nValue; - }; - inline void /*SetUnknown3*/SetTradeID( u16 nValue ) - { - /*mUnknown3*/mTradeID = nValue; - }; - inline void SetUnknown4( u16 nValue ) - { - mUnknown4 = nValue; - }; - inline void SetActorName( std::string nValue ) - { - mActorName = nValue; - }; - inline void SetAngle( std::string nValue ) - { - mAngle = nValue; - }; -}; - -#endif diff --git a/server/src/game/include/outpost.h b/server/src/game/include/outpost.h deleted file mode 100644 index 22e5c50..0000000 --- a/server/src/game/include/outpost.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -TinNS (TinNS is not a Neocron Server) -Copyright (C) 2005 Linux Addicted Community -maintainer Akiko - -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 -of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301, USA. -*/ - -/* - -outpost.h - TinNS outpost handling - -CREATION: 24 Oct 2009 Namikon - -*/ - -class POutpost -{ - private: - - public: - POutpost(); - ~POutpost(); - - bool IsZoneOPArea(u32 nZoneID); // checks if given zoneID is either outpost zone or underground of OP - void SendOPAreaData(PClient* nClient); // Sends OP data to client (Owning clan/faction) - u32 GetCurrentClan(u32 nOutpostID); // Get current ClanID of given Outpost -}; - diff --git a/server/src/game/include/rconsole.h b/server/src/game/include/rconsole.h deleted file mode 100644 index 21a59dd..0000000 --- a/server/src/game/include/rconsole.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - rconsole.h - - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL -*/ - -#ifndef RCONSOLE_H -#define RCONSOLE_H - -#ifdef _MSC_VER - #pragma once -#endif - -class PRConsole -{ - private : - typedef std::list ClientList; - ClientList mClients; - - void ProcessClient(PRConClient* Client); - void Prompt(PRConClient *Client); - public : - PRConsole(); - ~PRConsole(); - - void Start(); - void Update(); -}; - -#endif - diff --git a/server/src/game/include/server.h b/server/src/game/include/server.h deleted file mode 100644 index 7bb29f0..0000000 --- a/server/src/game/include/server.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - server.h - - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL -*/ - -#ifndef SERVER_H -#define SERVER_H - -class PServer -{ - private : - int mMaxClients; - int mGMSlots; - int mNumClients; - std::vector mClients; - protected : - public : - PServer(); - ~PServer(); - - inline int GetMaxClients() const { return mMaxClients; } - inline int GetGMSlots() const { return mGMSlots; } - inline int GetNumClients() const { return mNumClients; } - int NewClient(); - PClient *GetClient(int Client) const; - void Update(); - void Shutdown(); -}; - -#endif - diff --git a/server/src/game/include/sql.h b/server/src/game/include/sql.h deleted file mode 100644 index dbb8dc2..0000000 --- a/server/src/game/include/sql.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - sql.h - handles all mysql interactions - - Authors: - - Namikon - - bakkdoor - - MODIFIED: 24 Dec 2005 Namikon - REASON: - initial release by Namikon - MODIFIED: 26 Dec 2005 Namikon - REASON: - Added GetWorldDoorType() for door interaction - - Added GetWorldItemType() for item interaction - - Added FmtTxt() for printf() like parsing of text - - Added GetWorldItemOption() for item interaction - MODIFIED: 30 Dec 2005 bakkdoor - REASON: - changed mysql_init() parameter to null to prevent segfault - - added checking for dbHandle to prevent segfault - MODIFIED: 07 Jul 2006 Hammag - REASON: - Added GetLastGameInsertId() and GetLastInfoInsertId() - MODIFIED: 26 Jul 2006 Hammag - REASON: - Added CheckResCount() for DB Res memory leak tracking (to be done in the main loop) - rather than through Info/GameResQuery() - - fixed InfoDBInuse and GameDBInuse updating - - inhibited Info/GameDBInuse warning message in Info/GameResQuery() - MODIFIED: 27 Sep 2006 Hammag - REASON: - Added GetAptLocation() method - MODIFIED: 12 Oct 2006 Hammag - REASON: - Added Update() method - - added mKeepaliveDelay and mLastKeepaliveSent members - MODIFIED: 25 Jun 2007 Hammag - REASON: - Moved all Appartements related methods to PAppartements class - - TODO: take all non-pure SQL DB access stuff out of this class -*/ - -#ifndef MYSQL_H -#define MYSQL_H - -class PMySQL -{ - private: - int info_port; - char info_host[100]; - char info_userName[100]; - char info_password[100]; - char info_database[100]; - MYSQL *info_dbHandle; - std::time_t mKeepaliveDelay; - std::time_t mLastKeepaliveSent; - - int game_port; - char game_host[100]; - char game_userName[100]; - char game_password[100]; - char game_database[100]; - MYSQL *game_dbHandle; - - int GameDBInuse; - int InfoDBInuse; - - public: - PMySQL(); - ~PMySQL(); - - void Update(); - void CheckResCount(); - - inline MYSQL *GetInfoHandle() { return info_dbHandle; }; - inline MYSQL *GetGameHandle() { return game_dbHandle; }; - - bool Connect(); - - int InfoQuery(const char *query); - MYSQL_RES *InfoResQuery(const char *query); - int GameQuery(const char *query); - MYSQL_RES *GameResQuery(const char *query); - - /*int GetWorldItemType(unsigned short ID, int Location); - int GetWorldItemOption(unsigned short ID, int Location, int option); - int GetWorldDoorType(unsigned int ID, int Location);*/ - - void ShowInfoSQLError(); - void ShowGameSQLError(); - void FreeGameSQLResult(MYSQL_RES *res); - void FreeInfoSQLResult(MYSQL_RES *res); - - inline u32 GetLastGameInsertId() { return mysql_insert_id(game_dbHandle); }; - inline u32 GetLastInfoInsertId() { return mysql_insert_id(info_dbHandle); }; - - u32 EscapeString(const char* nText, char* dText, u32 dMaxLength); -}; -#endif diff --git a/server/src/game/include/subway.h b/server/src/game/include/subway.h deleted file mode 100644 index a5de337..0000000 --- a/server/src/game/include/subway.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - subway.h - subway class - - MODIFIED: 9 Nov 2007 Hammag - REASON: - creation - -*/ - -#ifndef SUBWAY_H -#define SUBWAY_H - -class PSubway -{ - friend class PMsgBuilder; - - struct PSubwayInfo - { - u16 mVhcId; - u16 mPosition; - u8 mDoorOpened; - u32 mSeatUsersId[4]; - }; - - public: - static const u16 mCabsNumber = 11; - static const u32 mCabsBaseId = 0x03f2; - static const u32 mCabsBaseHealth = 100; //should take that from .def instead... - static const u8 mStationsNumber = 8; - - private: - static const u16 mSubwayInitData []; - static const u32 mCabLoopTime; - static const u32 mCab0TimeOffset; - static const s32 mTimingAdjust; - static const u32 mCabIntervalTime; - static const u32 mOpenDoorOffset []; - static const u32 mOpenDoorDuration []; - static const char* mSubwayStationName []; - static PCharCoordinates mCabExitPositions [2][mStationsNumber]; - - PSubwayInfo mSubways[mCabsNumber]; - -public: - bool GetInfoIndex(u32 nVhcId, u8 *Index = NULL); - - public: - PSubway(); - //~PSubway(); - - inline bool IsValidSubwayCab(u32 nVhcId) {return GetInfoIndex(nVhcId); } - bool UpdateInfo(u32 nVhcId, u16 nPosition, u8 nDoorOpened); - u16 GetPosition(u32 nVhcId); - - u32 GetTimeOffset(u32 nVhcId, u32 nTime); - u8 GetStation(u32 nVhcId, u32 nTime, u32* TimeOffset = NULL); - bool IsDoorOpen(u32 nVhcId, u32 nTime); - std::string* GetStationName(u8 nStationId); - bool GetStationExitPosition(PCharCoordinates* nPosition, u8 nStationId, f32 nCoef = 0.5); - - u8 GetFreeSeat(u32 nVhcId); - bool SetSeatUser(u32 nVhcId, u8 nSeat, u32 nCharId); - bool UnsetSeatUser(u32 nVhcId, u8 nSeat, u32 nCharId); -}; - -#endif diff --git a/server/src/game/include/terminal.h b/server/src/game/include/terminal.h deleted file mode 100644 index d94ec97..0000000 --- a/server/src/game/include/terminal.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - terminal.h - Management class for Terminal actions (Citycom, keys, vehicledepot, ...) - - MODIFIED: 08 Jan 2007 Namikon - REASON: - Created - -*/ - -#ifndef TERMINAL_H -#define TERMINAL_H - -class PTerminal -{ - private: - void SendTryAccessAnswer(PClient* nClient, char *nArea, bool nAllowed); - char mSQLQuery[500]; - - int mResultFields; - void EraseVars(); - - char mConPrefix[50]; - - inline bool ChkOpt(u8 nNumOptions, u8 nReqOpt) { if(nNumOptions < nReqOpt) return false; else return true; }; - bool DoStockXCheck(PClient* nClient, int nAmountEntered, int nNewAmount); - - public: - PTerminal(); - //~PTerminal(); - // Check accesslevel of Player for various Terminal actions - bool CheckAccess(PClient* nClient, char *nArea, u16 nCmdNr, char *nOption1, char *nOption2, char *nOption3); - u8 GetNewEmailCount(PClient* nClient, bool nNoticeClient = true); - // Handle ReceiveDB queries - bool HandleQueryDB(PClient* nClient, std::string *nDBCommandName, std::string *nCommandName, std::string *nOptions, u8 nNumOptions); - bool HandleReceiveDB(PClient* nClient, u16 mTerminalSessionId, std::string *nCommandName, std::string *nOptions, u8 nNumOptions, u16 nDBID, u8 nUnknown); - bool HandleTryAccess(PClient* nClient, u16 mTerminalSessionId, std::string *nCommandName, std::string *nOptions, u8 nNumOptions, u16 nDBID, u8 nUnknown, bool nCheckOnly = false); - bool HandleUpdateDB(PClient* nClient, u16 mTerminalSessionId, std::string *nCommandName, std::string *nOptions, u8 nNumOptions, u16 nDBID, u8 nUnknown); -}; - -#endif diff --git a/server/src/game/include/vehicle.h b/server/src/game/include/vehicle.h deleted file mode 100644 index fb08a9a..0000000 --- a/server/src/game/include/vehicle.h +++ /dev/null @@ -1,220 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - vehicle.h - Vehicle handling - - Authors: - - Namikon - - MODIFIED: 08 Jan 2006 Namikon - REASON: - initial release by Namikon -*/ - -#ifndef VEHICLE_H -#define VEHICLE_H - -class PDefVhc; - -class PVhcCoordinates -{ - friend class PSpawnedVehicle; - - private: - u16 mY; // Y-Position in world - u16 mZ; // Z-Position in world - u16 mX; // X-Position in world - u8 mUD; // Up - Mid - Down (d6 - 80 - 2a) // Pitch - u16 mLR; // Yaw - u16 mRoll; - u16 mUnknown; // Usually 0x0001 - u8 mFF; // Usually 0xff ... - u8 mAct; // Last user action state - // mAct: bit field - //0x00 = not moving - //0x01 = Left - //0x02 = Right - //0x04 = Forward - //0x08 = Back - //0x20 = Pushing down - //0x40 = Pulling up - - public: - inline PVhcCoordinates() { mX = mY = mZ = mAct = 0; mUD = 128; mLR = 34683; mRoll = 32403;} - - void SetPosition( u16 nY, u16 nZ, u16 nX, u8 nUD, u16 nLR, u16 nRoll, u8 nAct = 0, u16 nUnknown = 1, u8 nFF = 0xff ); - void SetInterpolate( const PVhcCoordinates& Pos1, const PVhcCoordinates& Pos2, f32 nCoef ); - inline u16 GetX() const { return mX; } - inline u16 GetY() const { return mY; } - inline u16 GetZ() const { return mZ; } - inline u8 GetUD() const { return mUD; } - inline u16 GetLR() const { return mLR; } - inline u16 GetRoll() const { return mRoll; } - inline u8 GetAct() const { return mAct; } - inline u8 GetUnknown() const { return mUnknown; } - inline u8 GetFF() const { return mFF; } -}; - -class PVehicleInformation -{ - friend class PSpawnedVehicle; - friend class PVehicles; - - private: - u32 mVehicleId; - u32 mOwnerCharId; - u32 mHealth; // or f32 ??? - u8 mVehicleType; - u8 mStatus; //vhcStatus 0:parking, 1:in_service, 2:destroyed - - public: - inline PVehicleInformation( u32 nVehicleId = 0, u32 nOwnerCharId = 0, u32 nHealth = 0, u8 nVehicleType = 0, u8 nStatus = 0 ) : - mVehicleId( nVehicleId ), - mOwnerCharId( nOwnerCharId ), - mHealth( nHealth ), - mVehicleType( nVehicleType ), - mStatus( nStatus ) - { } - - inline u32 GetVehicleId() const { return mVehicleId; } - inline u32 GetOwnerCharId() const { return mOwnerCharId; } - inline u32 GetHealth() const { return mHealth; } // or f32 ??? - inline u8 GetVehicleType() const { return mVehicleType; } - inline u8 GetStatus() const { return mStatus; } - bool SetStatus( u8 nStatus ); - - bool Load( u32 nVehicleId ); - bool Save(); - bool Destroy(); -}; - -class PSpawnedVehicle -{ - private: - static const u8 mSeatsFlags[]; - - private: - u32 mLocalId; - PVehicleInformation mInfo; - u32 mLocation; - PVhcCoordinates mCoords; - const PDefVhc* mVhcDef; - - u32 mSeatUserId[8]; - u8 mFreeSeatsFlags; - u8 mNbFreeSeats; - - u16 minmax[4][2]; //Temp - - public: - PSpawnedVehicle( u32 nLocalId, PVehicleInformation const* nVhcInfo, u32 nLocation, PVhcCoordinates const* nVhcPos ); - - inline u32 GetVehicleId() const { return mInfo.mVehicleId; } - inline u32 GetLocalId() const { return mLocalId; } - inline const PVhcCoordinates& GetPosition() const { return mCoords; } - inline const PVehicleInformation& GetInformation() const { return mInfo; } - inline bool SetStatus( u8 nStatus ) { return mInfo.SetStatus( nStatus ); } - - void SetLocation( u32 nLocation ); - inline u32 GetLocation() const { return mLocation; } - void SetPosition( PVhcCoordinates const* nVhcPos ); - - inline bool Save() { return mInfo.Save(); } - - int GetNumSeats() const; - inline u32 GetSeatUser( u8 nSeatId ) const { return (( nSeatId < 8 ) ? mSeatUserId[nSeatId] : 0 ); } - bool SetSeatUser( u8 nSeatId, u32 nCharId ); - bool UnsetSeatUser( u8 nSeatId, u32 nCharId ); - bool IsCharInside( u32 nCharId ) const; - inline u8 GetFreeSeatsFlags() const { return mFreeSeatsFlags; } - inline u8 GetNbFreeSeats() const { return mNbFreeSeats; } - u8 GetFirstFreeSeat() const; - - //SetHealth(const u32 nHealth); - //u32 DoDamage(const u32 nHealthDec); - //u32 DoRepair(const u32 nHealthInc); -}; - -typedef std::map PSpawnedVhcMap; -typedef std::queue PVhcInfoList; -class PVehicles -{ - private: - PSpawnedVhcMap mSpawnedVehicles; - - bool RegisterSpawnedVehicle( PSpawnedVehicle* nSpawnedVehicle ); - bool UnregisterSpawnedVehicle( u32 nVehicleId ); - - public: - PVehicles(); - ~PVehicles(); - - //u32 CreateVehicle(u32 nOwnerChar, u8 mVehicleType); - //bool RegisterVehicleOwner(u32 nVehiculeId, u32 nOwnerChar); - //bool DestroyVehicle(u32 nVehiculeId); - bool IsValidVehicle( u32 nVehicleId, bool nCheckOwner = false, u32 nOwnerId = 0 ) const; - inline bool IsSpawned( u32 nVehicleId ) const { return ( mSpawnedVehicles.find( nVehicleId ) != mSpawnedVehicles.end() ); } - PSpawnedVehicle* GetSpawnedVehicle( u32 nVehicleId ) const; - bool GetVehicleInfo( u32 nVehicleId, PVehicleInformation* nInfo ) const; - PSpawnedVehicle* SpawnVehicle( u32 nVehicleId, u32 nLocation, PVhcCoordinates const* nVhcPos ); // Refuses for subway zone atm - bool UnspawnVehicle( u32 nVehicleId ); - - PVhcInfoList* GetCharVehicles( u32 nCharId, u16 nMaxCount = 0, u16 nStartIndex = 0 ); - -}; - -typedef std::vector PSpawnedVhcVector; -typedef std::queue PSpawnedVhcList; - -class PSpawnedVehicles -{ - friend class PWorld; - - public: - static const u32 mVhcBaseLocalId = 0x03fd; //Vhc local Id are allocated downward from this value. Could br 0x3ff, but 0x3fe is used as "target" when shooting nowhere - static const u16 mMaxLocalVhc = 127; - - inline static bool IsPotentialSpawnedVehicle( u32 nLocalId ) - { return (( nLocalId <= mVhcBaseLocalId ) && (( mVhcBaseLocalId - nLocalId ) < mMaxLocalVhc ) ); } - - private: - PSpawnedVhcVector mSpawnedVehicles; - u16 mNextFreeHint; - u32 mLocation; - - inline void SetLocation( u32 nLocation ) { mLocation = nLocation; } - - public: - PSpawnedVehicles(); - ~PSpawnedVehicles(); - - inline bool IsSpawned( u32 nLocalId ) const { return (( nLocalId <= mVhcBaseLocalId ) && (( mVhcBaseLocalId - nLocalId ) < mSpawnedVehicles.size() ) && mSpawnedVehicles[mVhcBaseLocalId-nLocalId] ); } - PSpawnedVehicle* SpawnVehicle( PVehicleInformation const* nVhcInfo, PVhcCoordinates const* nVhcPos ); - PSpawnedVehicle* GetVehicle( u32 nLocalId ); - PSpawnedVehicle* GetVehicleByGlobalId( u32 nVehicleId ) const; - bool UnspawnVehicle( u32 nVehicleId ); - - PSpawnedVhcList* GetSpawnedVehicles() const; -}; - -#endif diff --git a/server/src/game/include/vhcaccessrequest.h b/server/src/game/include/vhcaccessrequest.h deleted file mode 100644 index 7769488..0000000 --- a/server/src/game/include/vhcaccessrequest.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - vhcaccessrequest.h - classe for pendinf vhc access requests - - - CREATION: 14 Apr 2009 Hammag - -*/ - -#ifndef VHCACCESSREQ_H -#define VHCACCESSREQ_H - -class PVhcAccessRequest -{ - public: - //u32 mRequestId; - std::time_t mTimestamp; - u32 mCharId; - u32 mVhcGlobalId; - u8 mStatus; // 0: no answer yet, 1: access allowed (refused req are dropped) 2: result checked - - PVhcAccessRequest(); - PVhcAccessRequest(u32 nRequesterCharId, u32 nVhcGlobalId); -}; - -class PVhcAccessRequestList -{ - typedef std::map PVhcAccessRequestMap; - - private: - PVhcAccessRequestMap mActiveRequests; - u32 mNextRequestId; - - std::time_t mResponseWaitTime; // How long do we wait for owner answer - std::time_t mCheckWaitTime; // How long do we wait for user access check (0: remaining time from mResponseWaitTime) - std::time_t mReuseWaitTime; // How long do we allow user to re-use the autorization after first check - - void DropTimedOut(); - - public: - PVhcAccessRequestList() ; - ~PVhcAccessRequestList(); - - void SetParameters(std::time_t nResponseWaitTime, std::time_t nCheckWaitTime, std::time_t nReuseWaitTime); - - u32 Add(u32 nRequesterCharId, u32 nVhcGlobalId); - bool GetInfo(u32 nRequestId, u32* oRequesterCharId, u32* oVehicleId) const; - bool RegisterResponse(u32 nRequestId, bool nStatus); - bool Check(u32 nRequestId, u32 nRequesterCharId = 0, u32 nVhcGlobalId = 0); -}; - -#endif diff --git a/server/src/game/include/world_datparser.h b/server/src/game/include/world_datparser.h deleted file mode 100644 index 5da7924..0000000 --- a/server/src/game/include/world_datparser.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - world_datparser.h - Class to parse .dat world files - - MODIFIED: 29 Sep 2006 Hammag - REASON: - Creation -*/ - -#ifndef WORLD_DATPARSER_H -#define WORLD_DATPARSER_H - -class PFile; -class PWorldDataTemplate; - -class PWorldDatParser -{ -private : - PFile* f; - std::string mNCDataPath; - - PWorldDataTemplate* mWorld; - bool mDiscardPassiveObjects; - - bool ProcessSec2ElemType3(u32 nSize); - bool ProcessSec2ElemType5(u32 nSize); - bool ProcessSec2NPCEntry(u32 nSize); - -public : - PWorldDatParser(); - ~PWorldDatParser(); - - int LoadDatFile(const std::string& nFilename, PWorldDataTemplate* nWorld, const bool nDiscardPassiveObjects = true, const bool nTestAccesOnly = false); - -}; - -#endif diff --git a/server/src/game/include/worlddatatemplate.h b/server/src/game/include/worlddatatemplate.h deleted file mode 100644 index 6720870..0000000 --- a/server/src/game/include/worlddatatemplate.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - -/* - worlddatatemplate.cpp - world data template (from worlds .dat files) class - - MODIFIED: 04 Oct 2006 Hammag - REASON: - creation - - MODIFIED: 21 Jun 2009 Namikon - REASON: - Added NPC Template stuff - -*/ - - -#ifndef WORLDDATATEMPLATE_H -#define WORLDDATATEMPLATE_H - -#define WORLDDATATEMPLATE_MAXPOSITEMS 11 - -class PFurnitureItemTemplate; -typedef std::map PFurnitureItemsMap; - -class PDoorTemplate; -typedef std::map PDoorsMap; - -class PNPCTemplate; -typedef std::map PNPCsMap; - -class PWorldDataTemplate -{ -private: - std::string mName; // (datfile) relative path+filename without leading ./ or ./worlds/ nor .dat extension - std::string mBspName; // (bsp file) relative path+filename without leading ./ or ./worlds/ nor .bsp extension - PFurnitureItemsMap mFurnitureItems; - PDoorsMap mDoors; - PNPCsMap mNPCs; - PFurnitureItemTemplate* mPositionItems[WORLDDATATEMPLATE_MAXPOSITEMS]; - - int mUseCount; - - void DatFileDataCleanup(); - void SetLinkedObjects(); // This method implements some workarouds for some world objects on which we lack info. - -public: - PWorldDataTemplate(); - ~PWorldDataTemplate(); - - bool LoadDatFile(const std::string& WorldTemplateName, const std::string& nFilename, const bool nTestAccesOnly = false); - inline const std::string& GetName() - { - return mName; - } - inline const std::string& GetBspName() - { - return mBspName; - } - - inline void IncreaseUseCount() - { - ++mUseCount; - } - inline int DecreaseUseCount() - { - return (mUseCount ? --mUseCount : 0); - } - inline int GetUseCount() - { - return mUseCount; - } - - u32 AddFurnitureItem(PFurnitureItemTemplate* nItem); - const PFurnitureItemTemplate* GetFurnitureItem(u32 ItemID); - bool getPositionItemPosition(u8 PosID, f32* pX, f32* pY, f32* pZ); - - u32 AddDoor(PDoorTemplate* nDoor); - const PDoorTemplate* GetDoor(u32 DoorID); - - u32 AddNPC(PNPCTemplate* nNPC); - - // External functions for NPCManager - const PNPCTemplate* GetNPC(u32 NPCID); - inline const PNPCsMap *GetNPCMap() const - { - return &mNPCs; - }; // called by class PNPCWorld to get all NPCs for this world -}; - -#endif diff --git a/server/src/game/include/worlds.h b/server/src/game/include/worlds.h deleted file mode 100644 index 3906779..0000000 --- a/server/src/game/include/worlds.h +++ /dev/null @@ -1,181 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - -/* - worlds.h - world class and world map class - - MODIFIED: 06 Oct 2006 Hammag - REASON: - creation - -*/ - - -#ifndef WORLDS_H -#define WORLDS_H - -#include "worlddatatemplate.h" -#include "vehicle.h" - -typedef std::map PChairsInUseMap; - -class PWorld -{ - friend class PWorlds; - -public: - static u16 const mZoneOutLimitOffset; - static u16 const mBottomZoneOutLimit; - static u16 const mBottomZoneInLimit; - static u16 const mTopZoneOutLimit; - static u16 const mTopZoneInLimit; - -private: - u32 mID; - bool mIsAppartment; - int mUseCount; - PWorldDataTemplate* mWorldDataTemplate; - PChairsInUseMap mChairsInUseMap; - PSpawnedVehicles mSpawnedVehicles; - - inline void IncreaseUseCount() - { - ++mUseCount; - } - inline int DecreaseUseCount() - { - return ( mUseCount ? --mUseCount : 0 ); - } - inline int GetUseCount() - { - return mUseCount; - } - bool Load( u32 nWorldID ); - -public: - PWorld(); - ~PWorld(); - - inline std::string GetName() - { - return ( mWorldDataTemplate ? mWorldDataTemplate->GetName() : EmptyString ); - } - inline std::string GetBspName() - { - return ( mWorldDataTemplate ? mWorldDataTemplate->GetBspName() : EmptyString ); - } - inline bool IsAppartment() - { - return mIsAppartment; - } - inline const PFurnitureItemTemplate* GetFurnitureItemTemplate( u32 nItemID ) - { - return ( mWorldDataTemplate ? mWorldDataTemplate->GetFurnitureItem( nItemID ) : NULL ) ; - } - const PDefWorldModel* GetFurnitureItemModel( u32 nItemID ); - inline const PDoorTemplate* GetDoor( u32 nDoorID ) - { - return ( mWorldDataTemplate ? mWorldDataTemplate->GetDoor( nDoorID ) : NULL ); - } - inline bool getPositionItemPosition( u8 PosID, f32* pX, f32* pY, f32* pZ ) - { - return ( mWorldDataTemplate ? mWorldDataTemplate->getPositionItemPosition( PosID, pX, pY, pZ ) : false ); - } - - bool CharUseChair( int CharLocalID, u32 nItemID ); - void CharLeaveChair( int CharLocalID, u32 nItemID ); - - PClient* GetClientByCharLocalId( u32 rawObjectId ) const; // returns Client if object is a PC char, and 0 if not. - - inline PSpawnedVehicles* GetSpawnedVehicules() - { - return &mSpawnedVehicles; - } - bool CheckVhcNeedZoning( PVhcCoordinates const* nPos ) const; - u32 GetVhcZoningDestination( PSpawnedVehicle const* nVhc, PVhcCoordinates* nPos = 0 ) const; - - // Evil thing... bounced through stuff :| wasnt able to find a better solution for this - inline const PNPCsMap *GetNPCMap() const - { - return (mWorldDataTemplate ? mWorldDataTemplate->GetNPCMap() : NULL); - }; - inline const PNPCTemplate *GetNPCTemplate( u32 nNPCID ) const - { - return (mWorldDataTemplate ? mWorldDataTemplate->GetNPC( nNPCID ) : NULL ); - }; -}; - - -typedef std::map PWorldsMap; -typedef std::map PWorldDataTemplatesMap; - -class PWorlds -{ - friend class PWorld; - -public: - static u32 const mNcSubwayWorldId; - static u32 const mAptBaseWorldId; - static u32 const mOutdoorBaseWorldId; - static u32 const mOutdoorWorldIdVIncrement; - static u8 const mOutdoorWorldmapHSize; - static u8 const mOutdoorWorldmapVSize; - static u32 const mOutdoorMaxWorldId; - -private: - bool mPreloadWorldsTemplates; - bool mPreloadStaticWorlds; - - PWorldsMap mStaticWorldsMap; // lists all valid static worlds, with second=NULL if not loaded - PWorldsMap mOnDemandWorldsMap; // mostly appartments. Could be used for instance dungeons too, but instance dungeons are crap :p - PWorldDataTemplatesMap mWorldDataTemplatesMap; - - bool LeaseWorldDataTemplate( const std::string& nBspName, const std::string& nFileName, const bool nPreloadPhase = false ); - void ReleaseWorldDataTemplate( const std::string& nFileName ); - void UnloadWorldDataTemplate( const std::string& nFileName ); - PWorldDataTemplate* GetWorldDataTemplate( const std::string& nFileName ); - PWorld* LeaseWorld( u32 nWorldID, const bool nPreloadPhase ); - -public: - PWorlds(); - ~PWorlds(); - - bool LoadWorlds(); - bool IsValidWorld( u32 nWorldID ) const; - inline PWorld* LeaseWorld( u32 nWorldID ) - { - return LeaseWorld( nWorldID, false ); - } - PWorld* GetWorld( u32 nWorldID ); - void ReleaseWorld( u32 nWorldID ); - bool IsAppartment( u32 nWorldID ); - inline bool IsPotentialAppartement( u32 nWorldID ) - { - return ( nWorldID > PWorlds::mAptBaseWorldId ); - } - - void Update(); - void Shutdown(); - - u32 GetWorldIdFromWorldmap( u8 mapH, u8 mapV ) const; // H & V pos are 0-based - bool GetWorldmapFromWorldId( u32 nWorldId, u8& mapH, u8& mapV ) const; -}; - -#endif diff --git a/server/src/game/include/zoning.h b/server/src/game/include/zoning.h deleted file mode 100644 index b79007d..0000000 --- a/server/src/game/include/zoning.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - zoning.h - - Authors: - - Namikon - - MODIFIED: XX Dec 2005 Namikon - REASON: - Initial Release - MODIFIED: 23 Dec 2005 Namikon - REASON: - Added GPL - MODIFIED: 28 Jul 2005 Hammag - REASON: - changed loc parameter type from int to u32 - -*/ - -#ifndef ZONING_H -#define ZONING_H - -//void SendZone(PClient *Client, PGameState *State,int loc); -void SendZone(PClient *Client, u32 loc); - -#endif - diff --git a/server/src/game/item.cpp b/server/src/game/item.cpp deleted file mode 100644 index ca80477..0000000 --- a/server/src/game/item.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - item.cpp - item class - - MODIFIED: 11 Jul 2006 Hammag - REASON: - creation - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#include "main.h" - -#include "include/item.h" -#include "include/gamedefs.h" -#include "include/def_items.h" - - -PItem::PItem(u32 ItemID, u8 nStackSize, u8 CurDur, u8 MaxDur, u8 Dmg, u8 Freq, u8 Hand, u8 Rng) -{ - mDefItem = GameDefs->Items()->GetDef(ItemID); - if (mDefItem) { - mItemID = ItemID; - mStackable = mDefItem->IsStackable(); - mStackSize = mStackable ? nStackSize : 1; - - mLoadedAmmoId = 0; - mLoadedAmmoNb = 0; - - mPropertiesFlags = 0; - - mUsedSlots = mMaxSlots = 0; - mModificators = 0; - - mConstructorId = 0; - //mType = mDefItem->GetType(); - //mValue1 = mDefItem->GetValue1(); - //mValue2 = mDefItem->GetValue2(); - //mValue3 = mDefItem->GetValue3(); - //mSizeX = mDefItem->GetSizeX(); - //mSizeY = mDefItem->GetSizeY(); - //mWeight = mDefItem->GetWeight(); - //mFillWeight = mDefItem->GetFillWeight(); - //mQualifier = mDefItem->GetQualifier(); - //mItemGroupID = mDefItem->GetItemGroupID(); - //mBasePrice = mDefItem->GetBasePrice(); - //mTechlevel = mDefItem->GetTechlevel(); - //mItemflags = mDefItem->GetItemflags(); - - //if (!mStackable) // only non-stackable items can have quality stats (?) - //{ - // mStackSize = 1; - mCurDuration = CurDur; - mMaxDuration = MaxDur; - mDamages = Dmg; - mFrequency = Freq; - mHandling = Hand; - mRange = Rng; - //} - } - else - { - mItemID = 0; - Console->Print(YELLOW, BLACK, "PItem::PItem: Invalid item ID %d", ItemID); - } -} - -void PItem::MakeItemStandard(u8 GlobalQualityMin, u8 GlobalQualityMax) -{ - if(GlobalQualityMin > GlobalQualityMax) GlobalQualityMin = GlobalQualityMax; - - mCurDuration = 255; - mMaxDuration = 255; - if(GlobalQualityMin == GlobalQualityMax) - { - mDamages = GlobalQualityMin; - mFrequency = GlobalQualityMin; - mHandling = GlobalQualityMin; - mRange = GlobalQualityMin; - } - else - { - mDamages = (u8) GetRandom(GlobalQualityMax, GlobalQualityMin); - mFrequency = (u8) GetRandom(GlobalQualityMax, GlobalQualityMin); - mHandling = (u8) GetRandom(GlobalQualityMax, GlobalQualityMin); - mRange = (u8) GetRandom(GlobalQualityMax, GlobalQualityMin); - } - -} - -u8 PItem::AddToStack(u8 ItemNb) // returns nb of items not added -{ - u8 addedItems = 0; - if (mStackable) - { - addedItems = (ItemNb <= (MAX_ITEMSTACK_SIZE - mStackSize)) ? ItemNb : (MAX_ITEMSTACK_SIZE - mStackSize); - mStackSize += addedItems; - } - return (ItemNb - addedItems); -} - -u8 PItem::TakeFromStack(u8 ItemNb) -{ - u8 retreivedItems = 0; - if (mStackable) - { - retreivedItems = std::min(mStackSize, ItemNb); - mStackSize -= retreivedItems; - } - return retreivedItems; -} diff --git a/server/src/game/main.cpp b/server/src/game/main.cpp deleted file mode 100644 index 0fcb977..0000000 --- a/server/src/game/main.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - main.cpp - this is the main file with the main function - - MODIFIED: 12 Sep 2005 Akiko - REASON: - removed some of the Windows specific code - - replaced SleepEx method by the Linux equivalent - MODIFIED: 26 Sep 2005 Akiko - REASON: - added GPL - MODIFIED: 23 Dec 2005 bakkdoor - REASON: - Added & signalHandler -> catch strg-c and shutdown nicely - MODIFIED: 25 Dec 2005 Namikon - REASON: - Fixed shutdown procedure, wont cause segfault anymore - MODIFIED: 06 Jan 2006 Namikon - REASON: - Added color to console outputs - MODIFIED: 01 Jul 2006 Hammag - REASON: - commented out sched_yield() in main loop, as it is - not needed anymore with a right timeout for ReadSetTCP select - MODIFIED: 26 Jul 2006 Hammag - REASON: - added memory leak check in the main loop for unreleased DB Ressources and messages - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem - - cleanups - - dos linefeeds -> unix linefeeds -*/ - - -#include "main.h" - -#include "include/worlddatatemplate.h" // temp -#include "include/worlds.h" // temp - -#include "include/isc.h" - - -// for handling strg-c signal to shutdown in correct way -void signal_handler(int signal) -{ - if (signal == SIGINT) - { - //cout << "Shutting down TinNS" << endl; - - //exit(0); - Shutdown(); - } - else - { - psignal(signal, "Unkown signal: "); - } -} - -int main() -{ - // Connect signal with handlerfunction - signal(SIGINT, signal_handler); // TODO: change for sigaction() - - - if(!InitTinNS()) - { - if(Console) - Console->Print("%s Aborting startup.", Console->ColorText(RED, BLACK, "[Fatal]")); - Shutdown(); // exits with 0 ... - } - - //RemoteConsole->Start(); - GameServer->Start(); - //GameServer->SetGameTime(0); - ISC->Start(); - - Console->Print("Gameserver is now %s. Waiting for clients...", Console->ColorText(GREEN, BLACK, "Online")); - - - while(1) - { - ServerSock->update(); - NPCManager->Update(); - Server->Update(); - Chars->Update(); - GameServer->Update(); - PMessage::CheckMsgCount(); // Memory leak check - MySQL->Update(); // Memory leak check and MySQL keepalive - ISC->Update(); - Console->Update(); - MultiPartHandler->Update(); - } - - return 0; -} diff --git a/server/src/game/main.h b/server/src/game/main.h deleted file mode 100644 index 8ee6e00..0000000 --- a/server/src/game/main.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - main.h - main include file, contains all needed includes and important definitions - - MODIFIED: 31 Aug 2005 Akiko - REASON: - updating def file definitions to match the changes in gamedefs.cpp - - added define for charfiles path - - added define for database path - MODIFIED: 26 Sep 2005 Akiko - REASON: - reformated code - - added GPL - - added infoserver default port as define - - added my threading model (mutex.h, semaphore.h, thread.h) - - added basic includes pthread.h, semaphore.h and errno.h - MODIFIED: 28 Sep 2005 Akiko - REASON: - added define for game server port - MODIFIED: 30 Nov 2005 Akiko - REASON: - added chat.h for the chat part from Namikon - MODIFIED: 02 Dec 2005 Akiko - REASON: - commented out mutex.h, thread.h, semaphore.h - MODIFIED: 22 Dec 2005 Namikon/bakkdoor - REASON: - Added commands.h, skill.h, clientmanager.h - MODIFIED: 23 Dec 2005 bakkdoor - REASON: - Added for main.cpp -> catch strg-c and shutdown nicely - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added mysql.h, sql.h for MySQL support - MODIFIED: 01 Jan 2006 Namikon - REASON: - Moved skill.h before chars.h (char.h needs skill.h now) - MODIFIED: 30 May 2006 Namikon - REASON: - Removed all useless includes to complete the server splitup; Also renamed tinns.h to main.h - MODIFIED: 6 Jul 2006 Hammag - REASON: - moved include "types.h" before include "../netcode/main.h" to permit compile - MODIFIED: 10 Jul 2006 Hammag - REASON: - added inventory.h - REASON: - added item.h - MODIFIED: 26 Jul 2006 Hammag - REASON: - removed #define GAME_PORT which is not used anymore (now in config file) - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem - - cleaned up a bit -*/ - -#ifndef MAIN_H -#define MAIN_H - -//#include "version.h" - -//basic includes -#include "include/external.h" - -//tinns includes -#include "include/types.h" -#include "common/netcode.h" -/* -#include "../gamemonkey/gmMachine.h" -#include "../gamemonkey/gmCall.h" -*/ -#include "common/console.h" -#include "common/misc.h" - -// MySQL Support -#ifdef MYSQL_INC_DIR -#include -#else -#include -#endif - -#include "include/sql.h" - -#include "common/config.h" -#include "common/filesystem.h" -#include "include/defparser.h" - -#include "include/skill.h" -#include "include/chars.h" -#include "include/accounts.h" -#include "include/client.h" -#include "include/server.h" -#include "include/gameserver.h" -#include "include/globals.h" -#include "include/defs.h" -#include "include/zoning.h" -#include "include/item.h" -#include "include/inventory.h" -#include "include/worldactors.h" -#include "include/npc.h" -#include "include/outpost.h" -#include "include/multipart.h" -#include "include/terminal.h" - -#include "include/lua_engine.h" -#include "include/chat.h" -#include "include/commands.h" -#include "include/clientmanager.h" - -#endif - diff --git a/server/src/game/msgbuilder.cpp b/server/src/game/msgbuilder.cpp deleted file mode 100644 index 285f64e..0000000 --- a/server/src/game/msgbuilder.cpp +++ /dev/null @@ -1,3701 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - msgbuilder.h - a classes to build NC messages - - CREATION: 30 Aug 2006 Hammag - - MODIFIED: - REASON: - - -*/ - -#include "main.h" -#include "include/msgbuilder.h" - -#include "include/worlds.h" -#include "include/appartements.h" -#include "include/vehicle.h" -#include "include/subway.h" -#include "include/item.h" -#include "include/container.h" - -PMessage* PMsgBuilder::BuildOutpostClanInfoMsg( PClient* nClient, u32 nClanID, u8 nFaction ) -{ - PMessage* tmpMsg = new PMessage(); - nClient->IncreaseUDP_ID(); - - *tmpMsg << (u8)0x13; - *tmpMsg << (u16)nClient->GetUDP_ID(); - *tmpMsg << (u16)nClient->GetSessionID(); - *tmpMsg << (u8)0x13; // Message length - *tmpMsg << (u8)0x03; - *tmpMsg << (u16)nClient->GetUDP_ID(); - *tmpMsg << (u8)0x23; - - //*tmpMsg << (u16)GetArgInt(2); - *tmpMsg << (u16)14; - *tmpMsg << (u8)0x00; - *tmpMsg << (f32)nClanID; // ClanID f32 - *tmpMsg << (u8)nFaction; // Faction - // The next 3 bytes are unknown. - // However, with this combination, the OP and its bonuses are - // set correctly; eg Own clan full bonus, friend clan 75%, etc - *tmpMsg << (u8)0x06; // 6? 0x06 - *tmpMsg << (u8)0x14; // 0? 0x14 - *tmpMsg << (u8)0x0b; // 11? 0x0b - *tmpMsg << (u32)nClanID; // ClanID u32 - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildCharHelloMsg( PClient* nClient ) -{ - PChar *nChar = nClient->GetChar(); - u32 nSkin, nHead, nTorso, nLegs; - u8 nHeadColor, nTorsoColor, nLegsColor, nHeadDarkness, nTorsoDarkness, nLegsDarkness; - - nChar->GetCurrentLook( nSkin, nHead, nTorso, nLegs ); - nChar->GetCurrentBodyColor( nHeadColor, nTorsoColor, nLegsColor, nHeadDarkness, nTorsoDarkness, nLegsDarkness ); - - PMessage* tmpMsg = new PMessage( ); - - u8 currentActiveSlot = nChar->GetQuickBeltActiveSlot(); - u16 weaponId = 0; - switch ( currentActiveSlot ) - { - case INV_WORN_QB_NONE: - //weaponId = 0; - break; - case INV_WORN_QB_HAND: - weaponId = 5; // <= TODO: set it somewhere - break; - default: - PItem* currentItem = nChar->GetInventory()->GetContainer( INV_LOC_WORN )->GetItem( INV_WORN_QB_START + currentActiveSlot ); - //Todo : item addons & effects - //ItemInHandID = currentItem->GetItemID(): - if ( currentItem ) - weaponId = currentItem->GetValue1(); - //else - //ItemInHandID = 0; - break; - } - - //nClient->IncreaseUDP_ID(); // This must be done outside - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )0x0000; //Client->GetUDP_ID(); // just placeholder, must be set outside - *tmpMsg << ( u16 )0x0000; // Client->GetSessionID(); // just placeholder, must be set outside - *tmpMsg << ( u8 )0x00; // size placeholder, set later in the function - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )0x0000; // Client->GetUDP_ID(); // just placeholder, must be set outside - *tmpMsg << ( u8 )0x25; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u32 )nChar->GetID(); - - *tmpMsg << ( u8 )0x60; // 0x40 if current faction epic done (master), | 0x80 to display [afk] | 0x20 if LE in - *tmpMsg << ( u8 )(( nChar->GetSpeedOverride() == 255 ) ? 10 : nChar->GetSpeedOverride() ); // move speed, reset by client (and for him only) when getting fall damage - *tmpMsg << ( u8 )0x08; // ??? something to do with speed ? - *tmpMsg << ( u16 )weaponId; // WeaponID of the weapon in hand - *tmpMsg << ( u8 )0x01; // ??? - *tmpMsg << ( u8 )0x01; // ??? - *tmpMsg << ( u8 )( 128 + nChar->GetSoullight() ); - - *tmpMsg << ( u8 )nChar->GetMainRank(); // in fact, Ranks are of type s8, but it doesn't matter much - *tmpMsg << ( u8 )nChar->GetCombatRank(); - *tmpMsg << ( u8 )nChar->GetFaction(); - - *tmpMsg << ( u8 )0x00; // This was 0x21 for an GM, with faction 0x00. However, no visible change when set... - *tmpMsg << ( u8 )0x0f; // size of the next bloc (skin + ?clan?) - // Current skin - *tmpMsg << ( u16 )nSkin; - *tmpMsg << ( u8 )nHead; - *tmpMsg << ( u8 )nTorso; - *tmpMsg << ( u8 )nLegs; - // Skin colors - *tmpMsg << ( u8 )nHeadColor; - *tmpMsg << ( u8 )nTorsoColor; - *tmpMsg << ( u8 )nLegsColor; - *tmpMsg << ( u8 )nHeadDarkness; // (0=bright 255=dark) - *tmpMsg << ( u8 )nTorsoDarkness; - *tmpMsg << ( u8 )nLegsDarkness; - *tmpMsg << ( u8 )0x00; // ??? << not sure at all // eg: 0x3e - *tmpMsg << ( u8 )0x00; // eg: 0x03 - *tmpMsg << ( u8 )0x00; // eg: 0xa3 - *tmpMsg << ( u8 )0x00; // eg: 0x03 - - //Name - *tmpMsg << ( u8 )(( nChar->GetName() ).length() + 1 ); - *tmpMsg << ( nChar->GetName() ).c_str(); - //Body effects - u8 cBodyEffect, cEffectDensity; - nChar->GetBodyEffect( cBodyEffect, cEffectDensity ); - if ( cBodyEffect ) - { - *tmpMsg << ( u8 )0x06; // size of effect list : 6 bytes/effect. Only one supported atm - *tmpMsg << ( u8 )cBodyEffect; // effect type (0=none, effecive values 1 - 17) - *tmpMsg << ( u8 )cEffectDensity; // density: 0=max, 0xff=min (for some effects only) - *tmpMsg << ( u8 )0x00; // ??? - *tmpMsg << ( u8 )0x00; // ??? - *tmpMsg << ( u8 )0x00; // ??? - *tmpMsg << ( u8 )0x00; // ??? - } - else - { - *tmpMsg << ( u8 )0x00; // size of empty effect list - } - - // Clans working, yeah :D - u16 tClanVal = nChar->GetClan(); - if(tClanVal > 0) - { - u8 tClanLevel = nChar->GetClanLevel(); - u32 tmpVal; - tmpVal = tClanVal << 4; - tmpVal |= tClanLevel; - *tmpMsg << ( u8 )0x04; - *tmpMsg << ( u32 )tmpVal; - } - else - *tmpMsg << ( u8 )0x00; // ending null - // alternate interpretation to this "ending null"/optional bloc: - /* *tmpMsg << (u8)0x04; // size of unknown bloc ... 0x00 when empty (aka the "ending null") - *tmpMsg << (u8)0x0b; // vary ... ??? 0b, eb, ee, ... - *tmpMsg << (u8)0x44; // vary ... ??? - *tmpMsg << (u8)0x00; // these two seem always null - *tmpMsg << (u8)0x00; */ - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildReqNPCScriptAnswerMsg( u32 nInfoId, std::string *nNPCScript ) - { - PMessage* tmpMsg; - - tmpMsg = new PMessage(); - - *tmpMsg << ( u8 )0x19; - *tmpMsg << ( u16 )0x0006; // InfoQuery - *tmpMsg << ( u16 )0x0003; // NPC Script - *tmpMsg << ( u32 )nInfoId; - *tmpMsg << nNPCScript->c_str(); - - return tmpMsg; - - } - -PMessage* PMsgBuilder::BuildYouGotEmailsMsg( PClient* nClient, u8 nMailCount ) - { - PMessage* tmpMsg = new PMessage(); - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x0c; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x3d; - *tmpMsg << ( u8 )0x0c; - *tmpMsg << ( u8 )0x00; - *tmpMsg << ( u8 )0x00; - *tmpMsg << ( u8 )0x00; - *tmpMsg << ( u8 )nMailCount; - - return tmpMsg; - } - -PMessage* PMsgBuilder::BuildReceiveDBAnswerMsg( PClient* nClient, PMessage* nResultBuffer, std::string *nCommandName, u16 nNumRows, u16 nNumFields) - { - PMessage* tmpMsg = new PMessage(); -/* nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )0x0000; - *tmpMsg << ( u16 )0x0000; - *tmpMsg << ( u8 )0x00; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x2b; - *tmpMsg << ( u8 )0x1a; - if(nCommandName->length() > 0) - *tmpMsg << ( u8 )0x01; - else - *tmpMsg << ( u8 )0x00; - - *tmpMsg << ( u8 )0x00; - *tmpMsg << ( u8 )0x00; - *tmpMsg << *nCommandName; - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - // 2nd message - *tmpMsg << ( u16 )(13 + nCommandName->length() + nResultBuffer->GetSize()); // ?? - */ - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x00; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x2b; - *tmpMsg << ( u8 )0x17; - *tmpMsg << ( u16 )(nCommandName->length()+1); - *tmpMsg << ( u16 )nNumRows; - *tmpMsg << ( u16 )nNumFields; - *tmpMsg << *nCommandName; - *tmpMsg << *nResultBuffer; - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - - return tmpMsg; - //len = (unsigned int)strlen(DB); - //SendBuffer[0] = 0x13; - //SendBuffer[5] = 11 + len; - //SendBuffer[6] = 0x03; - //Network_IncrementUDP (ClientNum); - //*(unsigned short*)&SendBuffer[7] = Client_Sockets[ClientNum].UDP_ID; - // SendBuffer[9] = 0x2b; - // SendBuffer[10] = 0x1a; - // *(unsigned short*)&SendBuffer[11] = len; - // if (num == 0) - // SendBuffer[13] = 0x00; - // else - // SendBuffer[13] = 0x01; - // SendBuffer[14] = 0x00; - // SendBuffer[15] = 0x00; - // strcpy (SendBuffer+16, DB); - // plen = 17+len; - - // SendBuffer[plen] = 13+len+slen; - // SendBuffer[plen+1] = 0x03; - // Network_IncrementUDP (ClientNum); - // *(unsigned short*)&SendBuffer[plen+2] = Client_Sockets[ClientNum].UDP_ID; - // *(unsigned short*)&SendBuffer[1] = Client_Sockets[ClientNum].UDP_ID; - // *(unsigned short*)&SendBuffer[3] = Client_Sockets[ClientNum].UDP_ID_HIGH; - // SendBuffer[plen+4] = 0x2b; - // SendBuffer[plen+5] = 0x17; - // *(unsigned short*)&SendBuffer[plen+6] = len+1; - // *(unsigned short*)&SendBuffer[plen+8] = num; - // *(unsigned short*)&SendBuffer[plen+10] = Fields; - // //Fieldnum is defined in each DB below - // strcpy (SendBuffer+plen+12, DB); - // plen += 13+len; - - // for (i=0;iIncreaseUDP_ID(); - - *tmpMsg << (u8)0x13; - *tmpMsg << (u16)nClient->GetUDP_ID(); - *tmpMsg << (u16)nClient->GetSessionID(); - *tmpMsg << (u8)0x00; - *tmpMsg << (u8)0x03; - *tmpMsg << (u16)nClient->GetUDP_ID(); - *tmpMsg << (u8)0x2b; - *tmpMsg << (u8)0x1a; - *tmpMsg << (u16)(strlen(nArea)+1); - - if(nAllowed) - *tmpMsg << (u8)0x01; - else - *tmpMsg << (u8)0x00; - - *tmpMsg << (u8)0x00; - *tmpMsg << (u8)0x00; - *tmpMsg << nArea; - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - return tmpMsg; - } - -PMessage* PMsgBuilder::BuildReqInfoAnswerMsg( PClient* nClient, u16 nReqType, u32 nInfoId, void* nResponse, u16 nResponseLength ) -{ - PMessage* tmpMsg; - - tmpMsg = new PMessage( 18 + nResponseLength ); - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x00; // Message length placeholder; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x23; - *tmpMsg << ( u16 )0x0006; // cmd - *tmpMsg << ( u16 )nReqType; // wrong size here (u32) for buffer size u16 in NeoX - *tmpMsg << ( u32 )nInfoId; - tmpMsg->Write( nResponse, nResponseLength ); - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildCharHealthUpdateMsg( PClient* nClient ) -{ - PMessage* tmpMsg = new PMessage( 14 ); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )0x0000; //Client->GetUDP_ID(); // just placeholder, must be set outside - *tmpMsg << ( u16 )0x0000; // Client->GetSessionID(); // just placeholder, must be set outside - *tmpMsg << ( u8 )0x00; // Message length placeholder; - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x30; - *tmpMsg << ( u8 )0x64; //Head Heath =Head HP/(3 *0.45)(with max Head HP = 45% of total) - *tmpMsg << ( u8 )0x64; //Body Heath =Body HP/(3 *0.35)(for max 35% of total) - *tmpMsg << ( u8 )0x64; //Feet Heath =Feet HP/(3 *0.20)(for max 20% of total) - *tmpMsg << ( u8 )0x01; // Sta/Mana ? - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildCharDeathMsg( PClient* nClient, u32 nKillerCharId ) -{ - PMessage* tmpMsg = new PMessage( 17 ); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )0x0000; //Client->GetUDP_ID(); // just placeholder, must be set outside - *tmpMsg << ( u16 )0x0000; // Client->GetSessionID(); // just placeholder, must be set outside - *tmpMsg << ( u8 )0x00; // Message length placeholder; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )0x0000; // Client->GetUDP_ID(); // just placeholder, must be set outside - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x16; - *tmpMsg << ( u32 )nKillerCharId; - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildCharPosUpdateMsg( PClient* nClient ) -{ - PMessage* tmpMsg = new PMessage( 32 ); - PChar* nChar = nClient->GetChar(); - - u32 cSeatObjectId; - u8 cSeatId; - PSeatType cSeatType = nChar->GetSeatInUse( &cSeatObjectId, &cSeatId ); - if ( cSeatType == seat_chair ) // temp ! Must migrate to RAW - { - cSeatObjectId = ( cSeatObjectId + 1 ) * 1024; - } - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )0x0000; //Client->GetUDP_ID(); // just placeholder, must be set outside - *tmpMsg << ( u16 )0x0000; // Client->GetSessionID(); // just placeholder, must be set outside - *tmpMsg << ( u8 )0x00; // Message length placeholder; - *tmpMsg << ( u8 )0x1b; - *tmpMsg << ( u32 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x03; - if ( cSeatType ) - { - *tmpMsg << ( u32 )cSeatObjectId; - *tmpMsg << ( u16 )cSeatId; // testing... else 0x0000 - } - else - { - *tmpMsg << ( u16 )(( nChar->Coords ).mY ); - *tmpMsg << ( u16 )(( nChar->Coords ).mZ ); - *tmpMsg << ( u16 )(( nChar->Coords ).mX ); - } - *tmpMsg << ( u16 )( 31910 + ( nChar->Coords ).mUD - 50 ); // Up - Mid - Down mUD=(d6 - 80 - 2a) NeoX original offset: 31910 - *tmpMsg << ( u16 )( 31820 + ( nChar->Coords ).mLR*2 - 179 ); // Compass direction mLR=(S..E..N..W..S [0-45-90-135-179]) There still is a small buggy movement when slowly crossing the South axis from the right - if ( cSeatType ) - { - *tmpMsg << ( u8 )0x00; - *tmpMsg << ( u8 )0x10; - } - else - { - *tmpMsg << ( u8 )(( nChar->Coords ).mAct ); - *tmpMsg << ( u8 )0x00; - } - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildCharPosUpdate2Msg( PClient* nClient, u8 InfoBitfield ) -{ - PMessage* tmpMsg = new PMessage( 32 ); - PChar* nChar = nClient->GetChar(); - - if ( InfoBitfield == 0x80 ) - { - Console->Print( RED, BLACK, "[ERROR] PMsgBuilder::BuildCharPosUpdate2Msg : using InfoBitfield=0x80 forbidden. Using 0x7f instead." ); - InfoBitfield = 0x7f; - } - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )0x0000; //Client->GetUDP_ID(); // just placeholder, must be set outside - *tmpMsg << ( u16 )0x0000; // Client->GetSessionID(); // just placeholder, must be set outside - *tmpMsg << ( u8 )0x00; // Message length placeholder; - *tmpMsg << ( u8 )0x20; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )InfoBitfield; - - if ( InfoBitfield & 0x01 ) - { - *tmpMsg << ( u16 )(( nChar->Coords ).mY ); - } - if ( InfoBitfield & 0x02 ) - { - *tmpMsg << ( u16 )(( nChar->Coords ).mZ ); - } - if ( InfoBitfield & 0x04 ) - { - *tmpMsg << ( u16 )(( nChar->Coords ).mX ); - } - if ( InfoBitfield & 0x08 ) - { - *tmpMsg << ( u8 )(( nChar->Coords ).mUD ); - } - if ( InfoBitfield & 0x10 ) - { - *tmpMsg << ( u8 )(( nChar->Coords ).mLR ); - } - if ( InfoBitfield & 0x20 ) - { - *tmpMsg << ( u8 )(( nChar->Coords ).mAct ); - } - /*if(InfoBitfield & 0x40) // Not used (?) - { - *tmpMsg << (u8)((nChar->Coords).mUnknown); - }*/ - /*if(InfoBitfield & 0x80) // mRoll ???? - { - *tmpMsg << (u8)((nChar->Coords).mUnknown); - }*/ - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -/* -PMessage* PMsgBuilder::BuildCharSittingMsg( PClient* nClient ) -{ - PMessage* tmpMsg = new PMessage( 24 ); - PChar* nChar = nClient->GetChar(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )0x0000; //Client->GetUDP_ID(); // just placeholder, must be set outside - *tmpMsg << ( u16 )0x0000; // Client->GetSessionID(); // just placeholder, must be set outside - *tmpMsg << ( u8 )0x00; // Message length placeholder; - *tmpMsg << ( u8 )0x32; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x00; // Type = chair/subway ??? - *tmpMsg << ( u8 )0x00; - *tmpMsg << ( u8 )0x03; // Type = chair ??? - *tmpMsg << ( u16 )(( nChar->Coords ).mY ); - *tmpMsg << ( u16 )(( nChar->Coords ).mZ ); - *tmpMsg << ( u16 )(( nChar->Coords ).mX ); - *tmpMsg << ( u16 )( 31910 + ( nChar->Coords ).mUD - 50 ); // Up - Mid - Down mUD=(d6 - 80 - 2a) NeoX original offset: 31910 - *tmpMsg << ( u16 )( 31820 + ( nChar->Coords ).mLR*2 - 179 ); // Compass direction mLR=(S..E..N..W..S [0-45-90-135-179]) There still is a small buggy movement when slowly crossing the South axis from the right - *tmpMsg << ( u8 )(( nChar->Coords ).mAct ); - *tmpMsg << ( u8 )0x00; - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} -*/ - -PMessage* PMsgBuilder::BuildCharUseSeatMsg( PClient* nClient, u32 nRawObjectId, u8 nSeatId ) -{ - PMessage* tmpMsg = new PMessage( 18 ); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )0x0000; // nClient->GetUDP_ID() placeholder - *tmpMsg << ( u16 )0x0000; // nClient->GetSessionID()placeholder - - *tmpMsg << ( u8 )0x0c; // Sub message length; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )0x0000; // ++ nClient->GetUDP_ID() placeholder - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x21; - *tmpMsg << ( u32 )nRawObjectId; - *tmpMsg << ( u8 )nSeatId; // 0x00 for real chair, 1+ for subway cab - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildCharExitSeatMsg( PClient* nClient ) -{ - PMessage* tmpMsg = new PMessage( 22 ); - PChar* nChar = nClient->GetChar(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )0x0000; // nClient->GetUDP_ID() placeholder - *tmpMsg << ( u16 )0x0000; // nClient->GetSessionID()placeholder - *tmpMsg << ( u8 )0x00; // Message length placeholder; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )0x0000; // nClient->GetUDP_ID() placeholder - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x22; - *tmpMsg << ( u16 )(( nChar->Coords ).mY + 768 ) ; - *tmpMsg << ( u16 )(( nChar->Coords ).mZ + 768 ) ; - *tmpMsg << ( u16 )(( nChar->Coords ).mX + 768 ) ; - *tmpMsg << ( u8 )( nChar->Coords ).mUD; - *tmpMsg << ( u8 )( nChar->Coords ).mLR; - *tmpMsg << ( u8 )( nChar->Coords ).mAct; - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildPacket0Msg( PClient* nClient ) -{ - PMessage* tmpMsg = new PMessage( 70 ); - PChar* nChar = nClient->GetChar(); - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x00; // Message length placeholder; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x2c; - *tmpMsg << ( u8 )0x01; // ?? - *tmpMsg << ( u8 )0x01; // ?? - *tmpMsg << ( u32 )0x00000000; - *tmpMsg << ( f32 )(( nChar->Coords ).mY - 32000 ); - *tmpMsg << ( f32 )(( nChar->Coords ).mZ - 32000 ); - *tmpMsg << ( f32 )(( nChar->Coords ).mX - 32000 ); - *tmpMsg << ( u32 )0x00000000; - *tmpMsg << ( u32 )0x00000000; - *tmpMsg << ( u32 )0x00000000; - *tmpMsg << ( u8 )0x01; // ???? - *tmpMsg << ( u8 )0x00; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u8 )0x07; - *tmpMsg << ( u8 )0x02; - *tmpMsg << ( u8 )0x00; - *tmpMsg << ( u32 )0x00000000; - *tmpMsg << ( u32 )0x00000000; - *tmpMsg << ( u32 )0x00000000; - *tmpMsg << ( u32 )0x00000000; - *tmpMsg << ( u32 )0x00000000; - *tmpMsg << ( u32 )0x00000000; - - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildPingMsg( PClient* nClient, u32 nClientTime ) -{ - PMessage* tmpMsg = new PMessage( 15 ); - u32 LocalTime = GameServer->GetGameTime(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x00; // Message length placeholder; - *tmpMsg << ( u8 )0x0b; - *tmpMsg << ( u32 )LocalTime; - *tmpMsg << ( u32 )nClientTime; - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildBaselineMsg( PClient* nClient ) -{ - PMessage* BaselineMsg = new PMessage( 512 ); - PMessage SectionMsg( 256 ); - - PChar *nChar = nClient->GetChar(); - const PDefCharKind *def = GameDefs->CharKinds()->GetDef( nChar->GetProfession() ); - PSkillHandler *Skill = nChar->Skill; - - nClient->IncreaseTransactionID( 3 ); - - // Head - *BaselineMsg << ( u8 )0x22; - *BaselineMsg << ( u8 )0x02; // ? - *BaselineMsg << ( u8 )0x01; // ? - - // ---- Section 1 ---- - *BaselineMsg << ( u8 )0x01; // section id - - SectionMsg << ( u8 )0xfa; // ? // // section content at offset 3 - SectionMsg << ( u8 )nChar->GetProfession(); - SectionMsg << ( u16 )nClient->GetTransactionID(); // Transaction ID ? 0x8aa0 - SectionMsg << ( u32 )nChar->GetID(); - SectionMsg << ( u8 )0x0e; // ? 0x0e in NeoX, 0x10 in Tinns ... doesn't seem to matter - SectionMsg << ( u8 )0x00; // ? - - *BaselineMsg << ( u16 )SectionMsg.GetSize(); - *BaselineMsg << SectionMsg; - SectionMsg.Reset(); - - // ---- Section 2 ---- - *BaselineMsg << ( u8 )0x02; // section id - SectionMsg << ( u8 )0x04; // ? // section content at offset 3 - SectionMsg << ( u8 )0x50; // ? - SectionMsg << ( u16 )500; // nChar->GetHealth(); - SectionMsg << ( u16 )500; // nChar->GetMaxHealth(); - SectionMsg << ( u16 )500; // nChar->GetMana(); - SectionMsg << ( u16 )500; // nChar->GetMaxMana(); - SectionMsg << ( u16 )500; // nChar->GetStamina(); - SectionMsg << ( u16 )500; // nChar->GetMaxStamina(); - SectionMsg << ( u16 )0x00ff; // ? - SectionMsg << ( u16 )0x00ff; // ? - SectionMsg << ( u16 )0x00e1; // (nChar->GetHealth() + 1); // ? Probably Head Health (45% of total) 0x0065 - SectionMsg << ( u16 )0x0147; // (nChar->GetHealth() + 1); // ? Torso Health (35% of total) - SectionMsg << ( u16 )0x0147; // (nChar->GetHealth() + 1); // ? Legs Health (20% of total) - SectionMsg << ( u8 )100; // 100 - SI - SectionMsg << ( u8 )0x80; // The lower this value is, the more your char has a "drug effect" on it 0x00 = unmoveable - SectionMsg << ( u16 )0x0000; - - *BaselineMsg << ( u16 )SectionMsg.GetSize(); - *BaselineMsg << SectionMsg; - SectionMsg.Reset(); - - // ---- Section 3 ---- - *BaselineMsg << ( u8 )0x03; // section id - - SectionMsg << ( u8 )0x06; // ? // section content at offset 3 - SectionMsg << ( u8 )0x09; // ? - SectionMsg << ( u32 )0x00000000; // ? - SectionMsg << ( u32 )0x00000000; // ? - SectionMsg << ( u8 )0x01; // ? - - SectionMsg << ( u8 )Skill->GetMainSkill( MS_STR ); - SectionMsg << ( u16 )Skill->GetSP( MS_STR ); - SectionMsg << ( u32 )Skill->GetXP( MS_STR ); - SectionMsg << ( u8 )def->GetSkillInfo( MS_STR ).mGrow; - SectionMsg << ( u8 )def->GetSkillInfo( MS_STR ).mMax; - - SectionMsg << ( u8 )Skill->GetMainSkill( MS_DEX ); - SectionMsg << ( u16 )Skill->GetSP( MS_DEX ); - SectionMsg << ( u32 )Skill->GetXP( MS_DEX ); - SectionMsg << ( u8 )def->GetSkillInfo( MS_DEX ).mGrow; - SectionMsg << ( u8 )def->GetSkillInfo( MS_DEX ).mMax; - - SectionMsg << ( u8 )Skill->GetMainSkill( MS_CON ); - SectionMsg << ( u16 )Skill->GetSP( MS_CON ); - SectionMsg << ( u32 )Skill->GetXP( MS_CON ); - SectionMsg << ( u8 )def->GetSkillInfo( MS_CON ).mGrow; - SectionMsg << ( u8 )def->GetSkillInfo( MS_CON ).mMax; - - SectionMsg << ( u8 )Skill->GetMainSkill( MS_INT ); - SectionMsg << ( u16 )Skill->GetSP( MS_INT ); - SectionMsg << ( u32 )Skill->GetXP( MS_INT ); - SectionMsg << ( u8 )def->GetSkillInfo( MS_INT ).mGrow; - SectionMsg << ( u8 )def->GetSkillInfo( MS_INT ).mMax; - - SectionMsg << ( u8 )Skill->GetMainSkill( MS_PSI ); - SectionMsg << ( u16 )Skill->GetSP( MS_PSI ); - SectionMsg << ( u32 )Skill->GetXP( MS_PSI ); - SectionMsg << ( u8 )def->GetSkillInfo( MS_PSI ).mGrow; - SectionMsg << ( u8 )def->GetSkillInfo( MS_PSI ).mMax; - - SectionMsg << ( u16 )0x0000; // ? - SectionMsg << ( u8 )0x00; // ? - SectionMsg << ( u8 )0x08; // ? - - *BaselineMsg << ( u16 )SectionMsg.GetSize(); - *BaselineMsg << SectionMsg; - SectionMsg.Reset(); - - // ---- Section 4 ---- - *BaselineMsg << ( u8 )0x04; // section id - - SectionMsg << ( u8 )0x2e; // ? // section content at offset 3 - SectionMsg << ( u8 )0x02; // ? - SectionMsg << ( u8 )0x00; // spare - SectionMsg << ( u8 )0x01; // cost - SectionMsg << ( u8 )Skill->GetSubSkill( SK_MC ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_MC ); - SectionMsg << ( u8 )Skill->GetSubSkill( SK_HC ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_HC ); - SectionMsg << ( u8 )Skill->GetSubSkill( SK_TRA ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_TRA ); - SectionMsg << ( u8 )0x00; // spare - SectionMsg << ( u8 )0x01; // cost - SectionMsg << ( u8 )0x00; // spare - SectionMsg << ( u8 )0x01; // cost - SectionMsg << ( u8 )0x00; // spare - SectionMsg << ( u8 )0x01; // cost - SectionMsg << ( u8 )0x00; // spare - SectionMsg << ( u8 )0x01; // cost - SectionMsg << ( u8 )0x00; // spare - SectionMsg << ( u8 )0x01; // cost - SectionMsg << ( u8 )0x00; // spare - SectionMsg << ( u8 )0x01; // cost - SectionMsg << ( u8 )Skill->GetSubSkill( SK_PC ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_PC ); - SectionMsg << ( u8 )Skill->GetSubSkill( SK_RC ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_RC ); - SectionMsg << ( u8 )Skill->GetSubSkill( SK_TC ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_TC ); - SectionMsg << ( u8 )Skill->GetSubSkill( SK_VHC ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_VHC ); - SectionMsg << ( u8 )Skill->GetSubSkill( SK_AGL ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_AGL ); - SectionMsg << ( u8 )Skill->GetSubSkill( SK_REP ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_REP ); - SectionMsg << ( u8 )Skill->GetSubSkill( SK_REC ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_REC ); - SectionMsg << ( u8 )Skill->GetSubSkill( SK_RCL ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_RCL ); - SectionMsg << ( u8 )0x00; // spare - SectionMsg << ( u8 )0x01; // cost - SectionMsg << ( u8 )0x00; // spare - SectionMsg << ( u8 )0x01; // cost - SectionMsg << ( u8 )Skill->GetSubSkill( SK_ATL ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_ATL ); - SectionMsg << ( u8 )Skill->GetSubSkill( SK_END ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_END ); - SectionMsg << ( u8 )Skill->GetSubSkill( SK_FOR ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_FOR ); - SectionMsg << ( u8 )Skill->GetSubSkill( SK_FIR ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_FIR ); - SectionMsg << ( u8 )Skill->GetSubSkill( SK_ENR ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_ENR ); - SectionMsg << ( u8 )Skill->GetSubSkill( SK_XRR ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_XRR ); - SectionMsg << ( u8 )Skill->GetSubSkill( SK_POR ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_POR ); - SectionMsg << ( u8 )Skill->GetSubSkill( SK_HLT ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_HLT ); - SectionMsg << ( u8 )0x00; // spare - SectionMsg << ( u8 )0x01; // cost - SectionMsg << ( u8 )0x00; // spare - SectionMsg << ( u8 )0x01; // cost - SectionMsg << ( u8 )Skill->GetSubSkill( SK_HCK ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_HCK ); - SectionMsg << ( u8 )Skill->GetSubSkill( SK_BRT ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_BRT ); - SectionMsg << ( u8 )Skill->GetSubSkill( SK_PSU ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_PSU ); - SectionMsg << ( u8 )Skill->GetSubSkill( SK_WEP ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_WEP ); - SectionMsg << ( u8 )Skill->GetSubSkill( SK_CST ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_CST ); - SectionMsg << ( u8 )Skill->GetSubSkill( SK_RES ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_RES ); - SectionMsg << ( u8 )Skill->GetSubSkill( SK_IMP ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_IMP ); - SectionMsg << ( u8 )0x00; // spare - SectionMsg << ( u8 )0x01; // cost - SectionMsg << ( u8 )0x00; // spare - SectionMsg << ( u8 )0x01; // cost - SectionMsg << ( u8 )0x00; // spare - SectionMsg << ( u8 )0x01; // cost - SectionMsg << ( u8 )Skill->GetSubSkill( SK_PPU ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_PPU ); - SectionMsg << ( u8 )Skill->GetSubSkill( SK_APU ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_APU ); - SectionMsg << ( u8 )Skill->GetSubSkill( SK_MST ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_MST ); - SectionMsg << ( u8 )Skill->GetSubSkill( SK_PPW ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_PPW ); - SectionMsg << ( u8 )Skill->GetSubSkill( SK_PSR ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_PSR ); - SectionMsg << ( u8 )Skill->GetSubSkill( SK_WPW ); - SectionMsg << ( u8 )Skill->GetSKPCost( SK_WPW ); - - *BaselineMsg << ( u16 )SectionMsg.GetSize(); - *BaselineMsg << SectionMsg; - SectionMsg.Reset(); - - // ---- Section 5 ---- - *BaselineMsg << ( u8 )0x05; // section id - - PMessage* ContentList = BuildContainerContentList( nChar->GetInventory()->GetContainer( INV_LOC_BACKPACK ), INV_LOC_BACKPACK ); - SectionMsg << *ContentList; - delete ContentList; - - *BaselineMsg << ( u16 )SectionMsg.GetSize(); - *BaselineMsg << SectionMsg; - SectionMsg.Reset(); - - // ---- Section 6 ---- - *BaselineMsg << ( u8 )0x06; // section id - - ContentList = BuildContainerContentList( nChar->GetInventory()->GetContainer( INV_LOC_WORN ), INV_LOC_WORN ); - SectionMsg << *ContentList; - delete ContentList; - - /* SectionMsg << (u8)0x04; // QB/Armor/Implants items nb // section content at offset 3 - - // THIS IS A TEMP SOLUTION UNTIL WE HAVE ITEM STUFF WORKING ===== BEGIN - SectionMsg << (u16)0x06; // Size of item - SectionMsg << (u16)0x00; // Location: Quickbelt slot 0 - SectionMsg << (u16)0x0051; // ItemID: 81, Flashlight - SectionMsg << (u8)0x01; // Datatype - SectionMsg << (u8)0x00; // Data - */ - - /**** - SectionMsg << (u8)0x04; // QB/Armor/Implants items nb // section content at offset 3 - - // THIS IS A TEMP SOLUTION UNTIL WE HAVE ITEM STUFF WORKING ===== BEGIN - SectionMsg << (u16)0x001b; // Size of item - SectionMsg << (u8)0x00; // Location: Quickbelt slot 0 - SectionMsg << (u8)0x00; // nop (Y) - SectionMsg << (u16)0x0003; // ItemID: 3, assault riffle - SectionMsg << (u8)(0x01|0x02|0x10|0x40); // Datatype - - //SectionMsg << (u8)0x01; // for 0x80. Use ??? - - SectionMsg << (u8)0x00; // Qty / remaining ammos - - SectionMsg << (u8)0x06; // Qual entries - SectionMsg << (u8)0x40; // current qual - SectionMsg << (u8)0x80; // dmg - SectionMsg << (u8)0xc0; // freq - SectionMsg << (u8)0xa0; // handl - SectionMsg << (u8)0xb0; // range - SectionMsg << (u8)0xff; // max qual <= always last - - SectionMsg << (u8)0x07; // addons bitflag: flashlight=1, scope, silencer, laserpointer - - SectionMsg << (u8)0x02; // used slots - SectionMsg << (u8)0x05; // max slots - SectionMsg << (u16)1526; // slots / explo ammo - SectionMsg << (u16)21; // riffle-barrel - SectionMsg << (u16)0x0000; - SectionMsg << (u16)0x0000; - SectionMsg << (u16)0x0000; - *****/ - /* - SectionMsg << (u16)0x06; // Size of item - SectionMsg << (u8)0x01; // Location: Quickbelt slot 1 - SectionMsg << (u8)0x00; // nop (Y) - SectionMsg << (u16)0x0023; // ItemID: 35, Med Kit - SectionMsg << (u8)0x01; // Data=ammo count - SectionMsg << (u8)0x03; // Data - */ - /* - SectionMsg << (u16)0x06; // Size of item - SectionMsg << (u16)0x01; // Location: Quickbelt slot 0 - SectionMsg << (u16)0x0055; // ItemID: 81, Flashlight - SectionMsg << (u8)0x01; // Datatype - SectionMsg << (u8)0x00; // Data - - SectionMsg << (u16)0x06; // Size of item - SectionMsg << (u16)0x02; // Location: Quickbelt slot 0 - SectionMsg << (u16)0x176F; // ItemID: 81, Flashlight - SectionMsg << (u8)0x01; // Datatype - SectionMsg << (u8)0x00; // Data - - - SectionMsg << (u16)0x08; // Size of item - SectionMsg << (u16)0x1a; // Location: Brain #1 - SectionMsg << (u16)0x08fc; // ItemID: Law enforcer - SectionMsg << (u8)0x02; // Datatype. 02: Item Duration information follows - SectionMsg << (u8)0x02; // SubDatatype02: Full itemdetails follow - SectionMsg << (u8)0x2a; // Current duration - SectionMsg << (u8)0x2a; // Max duration - */ -// nChar->GetInventory()->QB_SetSlot(0, 81); // Add Flashlight to QB slot 1 -// nChar->GetInventory()->QB_SetSlot(1, 85); // Add Flashlight to QB slot 1 -// nChar->GetInventory()->QB_SetSlot(2, 5999); // Add Flashlight to QB slot 1 - // THIS IS A TEMP SOLUTION UNTIL WE HAVE ITEM STUFF WORKING ===== END - /* - StatsBuffer[len+3] = 0; //Number of items - plen = 4; - for (i=0;iGetInventory()->GetContainer( INV_LOC_GOGO ), INV_LOC_GOGO ); - SectionMsg << *ContentList; - - delete ContentList; - - *BaselineMsg << ( u16 )SectionMsg.GetSize(); - *BaselineMsg << SectionMsg; - SectionMsg.Reset(); - - // ---- Section 8 ---- - *BaselineMsg << ( u8 )0x08; // section id - - u32 nSkin, nHead, nTorso, nLegs; - nChar->GetRealLook( nSkin, nHead, nTorso, nLegs ); - - SectionMsg << ( u8 )0x0a; // ? // section content at offset 3 - SectionMsg << ( u32 )nChar->GetCash(); - - // Genrep list - SectionMsg << ( u16 )nChar->GetGenrepCount(); //Number of GR tagged (Tinns value on u8 only) - SectionMsg << ( u8 )0x04; - if ( nChar->GetGenrepCount() ) // For each entry : (u16)genrep.g_worldid, (u16)genrep.g_stationid - { - SectionMsg.Write( nChar->GetGenrepListData(), nChar->GetGenrepListDataSize() ); - } - - SectionMsg << ( u8 )0x04; - SectionMsg << ( u8 )0x04; - SectionMsg << ( u8 )0x00; - - // Direct chat - if ( nChar->GetDirectChat() ) - { - SectionMsg << ( u8 )1; - SectionMsg << ( u32 )nChar->GetDirectChat(); - } - else - { - SectionMsg << ( u8 )0; - } - - // Buddy Chat - SectionMsg << ( u8 )nChar->GetBuddyCount(); //Number of Buddies - if ( nChar->GetBuddyCount() ) // For each buddy (u32)buddy CharID - { - SectionMsg.Write( nChar->GetBuddyListData(), nChar->GetBuddyListDataSize() ); - } - SectionMsg << ( u8 )0x00; - - SectionMsg << ( u16 )nClient->GetTransactionID(); // ?? - //SectionMsg << (u32)0x00000000; - SectionMsg << ( u32 )0x00000000; - SectionMsg << ( u32 )0x00000000; // Epic status ? - SectionMsg << ( u16 )nSkin; - SectionMsg << ( u8 )nHead; - SectionMsg << ( u8 )nTorso; - SectionMsg << ( u8 )nLegs; - SectionMsg << ( u8 )0x00; // Rank - SectionMsg << ( u32 )( nChar->GetBaseApartment() + PWorlds::mAptBaseWorldId ); // 0x22, 0x00, 0x00, 0x00, //Primary Apartment (GR activated) ??? - SectionMsg << ( u8 )0x01; // ? - SectionMsg << ( u8 )0x00; // ? - SectionMsg << ( u8 )0x00; // ? - SectionMsg << ( u8 )0x00; // ? - SectionMsg << ( u8 )0x00; // ? - - *BaselineMsg << ( u16 )SectionMsg.GetSize(); - *BaselineMsg << SectionMsg; - SectionMsg.Reset(); - - // ---- Section 9 ---- - *BaselineMsg << ( u8 )0x09; // section id - - SectionMsg << ( u16 )0x15; // Nb of factions // section content at offset 3 - SectionMsg << ( u16 )nChar->GetFaction(); - SectionMsg << ( u8 )0x04; // ? - SectionMsg << ( f32 ) 1000.0f*1000.0f; // 96.0f*9000.0f; // SL - // Faction Sympathies Points effective sympathie is Square root of these points, abs value rounded down (beware of the sign ! :p) - SectionMsg << ( f32 ) 1000.0f*1250.0f; // City Admin => 111 - SectionMsg << ( f32 ) 1000.0f*1000.0f; // Diamond => 100 - SectionMsg << ( f32 ) 1000.0f* -750.0f; // Next => -86 - SectionMsg << ( f32 ) 1000.0f*500.0f; // Tangent => 70 - SectionMsg << ( f32 ) 1000.0f* -250.0f; // Biotech => -50 - SectionMsg << ( f32 ) 1000.0f*0.0f; // ProtoPharm => 0 - SectionMsg << ( f32 ) 1000.0f*1000.0f; // Trader's Union - SectionMsg << ( f32 ) 1000.0f*1000.0f; // Tsunami - SectionMsg << ( f32 ) 1000.0f*1000.0f; // Black Dragons - SectionMsg << ( f32 ) 1000.0f*1000.0f; // City Mercs - SectionMsg << ( f32 ) 1000.0f*1000.0f; // Crahn Sect - SectionMsg << ( f32 ) 1000.0f*1000.0f; // Dome Of York - SectionMsg << ( f32 ) 1000.0f* -1000.0f; // Anarchy Breed - SectionMsg << ( f32 ) 1000.0f*1000.0f; // Fallen Angels - SectionMsg << ( f32 ) 1000.0f*1000.0f; // Twilight Guardian - SectionMsg << ( f32 ) 1000.0f* -1000.0f; // Regeant's Legacy - SectionMsg << ( f32 ) 1000.0f* -1000.0f; // Regeant's Mutants - SectionMsg << ( f32 ) 1000.0f* -1000.0f; // Insects - SectionMsg << ( f32 ) 1000.0f* -1000.0f; // Monsters - SectionMsg << ( f32 ) 1000.0f*1000.0f; // Unknown - SectionMsg << ( f32 ) 1000.0f*1000.0f; // Highest SL? - - SectionMsg << ( u32 )0x00000000; // Epic done Data : bit 2^FactionID set <=> Epic done - SectionMsg << ( u8 )nChar->GetFaction(); // Faction ??? wrong size ... - - *BaselineMsg << ( u16 )SectionMsg.GetSize(); - *BaselineMsg << SectionMsg; - SectionMsg.Reset(); - - // ---- Section 0a ---- - *BaselineMsg << ( u8 )0x0a; // section id - - // Clan data ? - *BaselineMsg << ( u16 )SectionMsg.GetSize(); - *BaselineMsg << SectionMsg; - SectionMsg.Reset(); - - // ---- Section 0b ---- - *BaselineMsg << ( u8 )0x0b; // section id - - SectionMsg << ( u8 )0x00; // ?? // section content at offset 3 - - *BaselineMsg << ( u16 )SectionMsg.GetSize(); - *BaselineMsg << SectionMsg; - SectionMsg.Reset(); - - // ---- Section 0d ---- - *BaselineMsg << ( u8 )0x0d; // section id - - SectionMsg << ( u8 )0xfa; // ?? // section content at offset 3 - SectionMsg << ( u8 )nChar->GetProfession(); - SectionMsg << ( u16 )nClient->GetTransactionID(); // ?? TransactionID ? 0x8aa0 - SectionMsg << ( u32 )nChar->GetID(); - - *BaselineMsg << ( u16 )SectionMsg.GetSize(); - *BaselineMsg << SectionMsg; - SectionMsg.Reset(); - - return BaselineMsg; -} - -PMessage* PMsgBuilder::BuildAliveRepMsg( PClient* nClient ) -{ - PMessage* tmpMsg = new PMessage( 7 ); - - // u8 up[] = {0x04, 0x01, 0x00, 0xe3, 0x6b, 0xe6, 0xee}; - *tmpMsg << ( u8 )0x04; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0xe3; // ? not always... - *tmpMsg << ( u8 )0x6b; // ? not always... - *tmpMsg << ( u16 )( nClient->getUDPConn()->getPort() ); // really ? - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildZoning1Msg( PClient* nClient, u16 nEntity, u8 nUnknown ) -{ - PMessage* tmpMsg = new PMessage( 42 ); - - nClient->IncreaseUDP_ID(); - nClient->IncreaseTransactionID(); // from NeoX - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x0c; // Message length place; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); // from NeoX - *tmpMsg << ( u8 )0x25; // ?? - *tmpMsg << ( u8 )0x13; // ?? - *tmpMsg << ( u16 )nClient->GetTransactionID(); // from NeoX / ?? right ??? - // In case of apt GR or NC2.2 ? - // *tmpMsg << (u8)0x04; // len ? - // *tmpMsg << (u32)AptWorldID; // len ? - // nClient->IncreaseTransactionID(); - // *tmpMsg << (u16)nClient->GetTransactionID(); - *tmpMsg << ( u8 )0x0e; // cmd => but not for zoning, because used in non-zoning situation - *tmpMsg << ( u8 )0x02; // ?? from NeoX - //(*tmpMsg)[5] = (u8)(tmpMsg->GetSize() - 6); - - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x17; // Message length place; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x23; - *tmpMsg << ( u16 )0x0004; // cmd - *tmpMsg << ( u32 )0x00000000; // from NeoX - *tmpMsg << ( u32 )0x00000000; // from NeoX - *tmpMsg << ( u8 )nUnknown; - *tmpMsg << ( u16 )nEntity; - *tmpMsg << ( u16 )0x0000; // from NeoX - *tmpMsg << ( u16 )nClient->GetTransactionID(); // from NeoX - *tmpMsg << ( u16 )0x0000; // from NeoX - - // We DO need this! This is a multiframe packet, and the first UDP/SessionID set *HAS* to be - // as high as the last UDP/SessionID set in the frame! - tmpMsg->U16Data( 1 ) = nClient->GetUDP_ID(); - tmpMsg->U16Data( 3 ) = nClient->GetSessionID(); - - //(*tmpMsg)[5] = (u8)(tmpMsg->GetSize() - 6); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildZoningTCPReadyMsg() -{ - PMessage* tmpMsg = new PMessage( 7 ); - - //static const u8 READY[7] = {0xfe, 0x04, 0x00, 0x83, 0x0d, 0x00, 0x00}; - *tmpMsg << ( u8 )0xfe; - *tmpMsg << ( u16 )0x0004; //length - *tmpMsg << ( u8 )0x83; //cmd - *tmpMsg << ( u8 )0x0d; // sub-cmd - *tmpMsg << ( u16 )0x0000; - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildSendZoneTCPMsg( u32 nLocation, std::string *nWorldName ) -{ - PMessage* tmpMsg = new PMessage( 14 + nWorldName->size() ); - - *tmpMsg << ( u8 )0xfe; - *tmpMsg << ( u16 )0x0000; // size placeholder - *tmpMsg << ( u8 )0x83; - *tmpMsg << ( u8 )0x0c; - *tmpMsg << ( u32 )nLocation; - *tmpMsg << ( u32 )0x00000000; - tmpMsg->Write( nWorldName->c_str(), nWorldName->size() + 1 ); - - tmpMsg->U16Data( 1 ) = ( u16 )( tmpMsg->GetSize() - 3 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildZoning2Msg( PClient* nClient, u32 nClientTime ) -{ - PMessage* tmpMsg = new PMessage( 22 ); - - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x00; // Message length placeholder; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x0d; - *tmpMsg << ( u32 )GameServer->GetGameTime(); - - *tmpMsg << ( u32 )nClientTime; - - *tmpMsg << ( u8 )0xe5; // ??? varies - *tmpMsg << ( u8 )0x0a; // ??? varies - *tmpMsg << ( u8 )0xbb; // ??? varies - *tmpMsg << ( u8 )0x00; // ??? usually 0 - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildGenrepZoningMsg( PClient* nClient, u32 nLocation, u16 nEntity ) -{ - PMessage* tmpMsg = new PMessage( 50 ); - - nClient->IncreaseUDP_ID(); - - tmpMsg->Fill( 0 ); - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x00; // Message length placeholder; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x23; - *tmpMsg << ( u16 )0x000c; // cmd - tmpMsg->SetNextByteOffset( 38 ); - *tmpMsg << ( u32 )0xffffffff; - *tmpMsg << ( u32 )nLocation; - *tmpMsg << ( u16 )nEntity; - *tmpMsg << ( u16 )0x0000; - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildGenrepAddToListMsg( PClient* nClient, u32 nLocation, u16 nEntity ) -{ - PMessage* tmpMsg = new PMessage( 23 ); - - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x00; // Message length placeholder; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x3d; - *tmpMsg << ( u32 )0x00000002; - *tmpMsg << ( u32 )nLocation; - *tmpMsg << ( u16 )nEntity; - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildAptLiftUseMsg( PClient* nClient, u32 nLocation, u16 nEntity, u8 nEntityType ) -{ - PMessage* tmpMsg = new PMessage( 43 ); - - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - - *tmpMsg << ( u8 )0x0f; // Message length placeholder; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x38; - *tmpMsg << ( u8 )0x04; // Accepted (?) - *tmpMsg << ( u8 )nEntityType; // "Sewer Level" - *tmpMsg << ( u32 )nLocation; - *tmpMsg << ( u16 )nEntity; - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildAptLiftFailedMsg( PClient* nClient ) -{ - PMessage* tmpMsg = new PMessage( 14 ); - - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - - *tmpMsg << ( u8 )0x08; // Message length placeholder; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x38; - *tmpMsg << ( u8 )0x03; // Refused - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildChangeLocationMsg( PClient* nClient, u32 nLocation, u16 nEntity, u8 nEntityType, u32 nRawItemID ) -{ - PMessage* tmpMsg = new PMessage( 28 ); - - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - - if ( nRawItemID ) - { - *tmpMsg << ( u8 )0x06; // Sub message length; - *tmpMsg << ( u8 )0x2d; // Item use response; - *tmpMsg << ( u32 )nRawItemID; - *tmpMsg << ( u8 )0x0a; // Use allowed - } - - *tmpMsg << ( u8 )0x0f; // Sub message length; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x38; - *tmpMsg << ( u8 )0x04; // Accepted (?) - *tmpMsg << ( u8 )nEntityType; - *tmpMsg << ( u32 )nLocation; - *tmpMsg << ( u16 )nEntity; - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildEntityPositionMsg( PClient* nClient, u16 pX, u16 pY, u16 pZ ) -{ - PMessage* tmpMsg = new PMessage( 18 ); - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x00; // Message length placeholder; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x23; - *tmpMsg << ( u16 )0x000a; - *tmpMsg << ( u16 )( pY + 768 ); - *tmpMsg << ( u16 )( pZ + 768 ); - *tmpMsg << ( u16 )( pX + 768 ); - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildCharAptLocInfoMsg( PClient* nClient ) -{ - PMessage* tmpMsg = new PMessage( 21 ); - nClient->IncreaseUDP_ID(); - - int BaseAppId = nClient->GetChar()->GetBaseApartment(); - u32 AptLocation = ( u32 )Appartements->GetAptLocation( BaseAppId ); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x0f; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x3d; - *tmpMsg << ( u32 )0x0000000b; - *tmpMsg << ( u32 )AptLocation; - - return tmpMsg; -} - -// OLD FUNCTION, REWRITTEN BELOW -/* -PMessage* PMsgBuilder::BuildSubskillIncMsg( PClient* nClient, u8 nSubskill, u16 nSkillPoints ) -{ - PMessage* tmpMsg = new PMessage( 33 ); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - - nClient->IncreaseUDP_ID(); - *tmpMsg << ( u8 )0x09; // SubMessage length; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x25; - *tmpMsg << ( u8 )0x23; - *tmpMsg << ( u8 )0x41; // 0x28 ?? // 0x 18 // 0x2c - - nClient->IncreaseUDP_ID(); - nClient->IncreaseTransactionID(); // testing ... - *tmpMsg << ( u8 )0x11; // SubMessage length; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x25; - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetTransactionID(); // testing / 0x0000 ???? - *tmpMsg << ( u8 )0x09; // ? - *tmpMsg << ( u16 )nSubskill; - *tmpMsg << ( u16 )nClient->GetChar()->Skill->GetSubSkill( nSubskill ); // nSubskill ? - *tmpMsg << ( u16 )nSkillPoints; - - //(*tmpMsg)[5] = (u8)(tmpMsg->GetSize() - 6); - - return tmpMsg; -} - */ -// NPC Dialog. Start dialog with NPC -PMessage* PMsgBuilder::BuildNPCStartDialogMsg( PClient* nClient, u32 nNPCWorldID, std::string *nDialogScript ) - { - PMessage* tmpMsg = new PMessage(); - nClient->IncreaseUDP_ID(); - - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 ) 0x0000; // UDP Placeholder - *tmpMsg << ( u16 ) 0x0000; // UDP Placeholder - *tmpMsg << ( u8 )0x00; // Message length - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x18; - *tmpMsg << ( u32 ) nNPCWorldID; - - // Todo: is this correct? random u32 value?? - *tmpMsg << ( u16 ) GetRandom( 65535, 4369 ); - *tmpMsg << ( u16 ) GetRandom( 65535, 4369 ); - *tmpMsg << ( u32 ) 0x0000; - *tmpMsg << nDialogScript->c_str(); - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x0a; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x1a; - *tmpMsg << ( u8 )0x00; - *tmpMsg << ( u8 )0x00; - *tmpMsg << ( u8 )0x00; - - tmpMsg->U16Data( 1 ) = nClient->GetUDP_ID(); - tmpMsg->U16Data( 3 ) = nClient->GetSessionID(); - - return tmpMsg; - } -// NPC Dialog. Send next node number in lua script to client -PMessage* PMsgBuilder::BuildNPCDialogReplyMsg( PClient* nClient, u16 nNextNode, std::vector*nResultBuffer) - { - PMessage* tmpMsg = new PMessage(); - - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID();; - *tmpMsg << ( u16 )nClient->GetSessionID();; - *tmpMsg << ( u8 )0x00; // SubMessage length; - - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID();; - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x1a; - *tmpMsg << ( u16 )nNextNode; - //*tmpMsg << ( u8 )nNumResults; - *tmpMsg << ( u8 )nResultBuffer->size(); - - std::vector::const_iterator it; - - for(it = nResultBuffer->begin(); it != nResultBuffer->end(); it++) - { - *tmpMsg << ( f32 )*(it); - } - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; - } - -PMessage* PMsgBuilder::BuildNPCBeginAllBuyerTradeMsg( PClient* nClient, int nWorldID ) - { - PMessage* tmpMsg = new PMessage(); - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x00; // Message length - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x26; - *tmpMsg << ( u32 ) nWorldID; - *tmpMsg << ( u8 )0x01; // Traders inventory - *tmpMsg << ( u16 )0xFFFF; // Traders inventory - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; - } - -PMessage* PMsgBuilder::BuildNPCShoppingListMsg( PClient* nClient, PMessage* nContentList, int nWorldID, u8 nItemQuality) - { - PMessage* tmpMsg = new PMessage(); - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x00; // Message length - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x26; - *tmpMsg << ( u32 ) nWorldID; - *tmpMsg << ( u8 )0x01; // Traders inventory - *tmpMsg << ( u16 )( nContentList->GetSize() / 6 ); // List entries - *tmpMsg << ( u8 )nItemQuality; // Items quality - *tmpMsg << *nContentList; - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; - } - -// ========================== -PMessage* PMsgBuilder::BuildNPCSingleInfoMsg( PClient* nClient, u32 nWorldID, u16 nTypeID, u16 nClothing, -u16 nNameID, u16 nPosY, u16 nPosZ, u16 nPosX, u16 nUnknown, -u16 nTraderID, std::string *nAngleStr, std::string *nNpcName, std::string *nCustomName) -// Initial NPC Packet that defines how the NPC look, etc - { -// u8 tMsgLen = 29 + nNpcName->size() + nAngleStr->size() + nCustomName->size(); - - PMessage* tmpMsg = new PMessage(); - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; // Begin UDP message - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x00; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x28; - *tmpMsg << ( u8 )0x00; - *tmpMsg << ( u8 )0x01; - *tmpMsg << ( u32 )nWorldID; - *tmpMsg << ( u16 )nTypeID; - *tmpMsg << ( u16 )nClothing; - *tmpMsg << ( u16 )nNameID; - *tmpMsg << ( u16 )nPosY; - *tmpMsg << ( u16 )nPosZ; - *tmpMsg << ( u16 )nPosX; - *tmpMsg << ( u8 )0x00; - *tmpMsg << ( u16 )nUnknown; - *tmpMsg << ( u16 )nTraderID; - *tmpMsg << nNpcName->c_str(); - *tmpMsg << nAngleStr->c_str(); - if(nCustomName->length() > 1) - *tmpMsg << nCustomName->c_str(); - - (*tmpMsg)[5] = (u8)(tmpMsg->GetSize() - 6); - return tmpMsg; - } - -PMessage* PMsgBuilder::BuildNPCMassInfoMsg( u32 nWorldID, u16 nTypeID, u16 nClothing, -u16 nNameID, u16 nPosY, u16 nPosZ, u16 nPosX, u16 nHealth, -u16 nTraderID, std::string *nAngleStr, std::string *nNpcName, std::string *nCustomName) -// Initial NPC Packet that defines how the NPC look, etc - { -// u8 tMsgLen = 29 + nNpcName->size() + nAngleStr->size() + nCustomName->size(); - - PMessage* tmpMsg = new PMessage(); - - *tmpMsg << ( u8 )0x13; // Begin UDP message - *tmpMsg << ( u16 )0x0000; - *tmpMsg << ( u16 )0x0000; - *tmpMsg << ( u8 )0x00; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )0x0000; - *tmpMsg << ( u8 )0x28; - *tmpMsg << ( u8 )0x00; - *tmpMsg << ( u8 )0x01; - *tmpMsg << ( u32 )nWorldID; - *tmpMsg << ( u16 )nTypeID; - *tmpMsg << ( u16 )nClothing; - *tmpMsg << ( u16 )nNameID; - *tmpMsg << ( u16 )nPosY; - *tmpMsg << ( u16 )nPosZ; - *tmpMsg << ( u16 )nPosX; - *tmpMsg << ( u8 )0x00; - *tmpMsg << ( u16 )nHealth; - *tmpMsg << ( u16 )nTraderID; - *tmpMsg << nNpcName->c_str(); - *tmpMsg << nAngleStr->c_str(); - if(nCustomName->length() > 1) - *tmpMsg << nCustomName->c_str(); - - (*tmpMsg)[5] = (u8)(tmpMsg->GetSize() - 6); - return tmpMsg; - } - -// ************** -PMessage* PMsgBuilder::BuildNPCUpdateMsg(u32 nWorldID, u16 nPosY, u16 nPosZ, u16 nPosX, u8 nActionBM, u16 nHealth, u8 nWeaponState, u8 nUnknown, u32 nTargetID) - { - PMessage* tmpMsg = new PMessage(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )0x0000; - *tmpMsg << ( u16 )0x0000; - *tmpMsg << ( u8 )0x00; // len - *tmpMsg << ( u8 )0x1b; // NPC Update - *tmpMsg << ( u32 )nWorldID; // NPCs world ID - *tmpMsg << ( u8 )0x1f; // Parameters - *tmpMsg << ( u16 )nPosY; // Position Y - *tmpMsg << ( u16 )nPosZ; // Position Z - *tmpMsg << ( u16 )nPosX; // Position X - *tmpMsg << ( u8 )nActionBM; // NPCs current action-bitmask - *tmpMsg << ( u16 )nHealth; // Health value - if(nTargetID > 0) - *tmpMsg << ( u32 )nTargetID; // WorldID of NPCs target (if any) - *tmpMsg << ( u8 )nUnknown; - *tmpMsg << ( u8 )nWeaponState; - - (*tmpMsg)[5] = (u8)(tmpMsg->GetSize() - 6); - - return tmpMsg; - } -// ************** - -PMessage* PMsgBuilder::BuildNPCSingleAliveMsg( PClient* nClient, u32 nWorldID, u16 nX, u16 nY, u16 nZ, u8 nActionStatus, u8 nHealth, u8 nAction ) - { - PMessage* tmpMsg = new PMessage(); - - *tmpMsg << ( u8 )0x13; // Begin UDP message - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x11; - *tmpMsg << ( u8 )0x1B; - *tmpMsg << ( u32 )nWorldID; - *tmpMsg << ( u8 )0x1F; - *tmpMsg << ( u16 )nY; - *tmpMsg << ( u16 )nZ; - *tmpMsg << ( u16 )nX; - *tmpMsg << ( u8 )nActionStatus; - *tmpMsg << ( u8 )0x00; - *tmpMsg << ( u8 )nHealth; - *tmpMsg << ( u8 )0x00; - *tmpMsg << ( u8 )nAction; - - return tmpMsg; - } - -PMessage* PMsgBuilder::BuildNPCMassAliveMsg( u32 nWorldID, u16 nX, u16 nY, u16 nZ, u8 nActionStatus, u8 nHealth, u8 nAction ) - { - PMessage* tmpMsg = new PMessage(); - - *tmpMsg << ( u8 )0x13; // Begin UDP message - *tmpMsg << ( u16 )0x0000; - *tmpMsg << ( u16 )0x0000; - *tmpMsg << ( u8 )0x11; - *tmpMsg << ( u8 )0x1B; - *tmpMsg << ( u32 )nWorldID; - *tmpMsg << ( u8 )0x1F; - *tmpMsg << ( u16 )nY; - *tmpMsg << ( u16 )nZ; - *tmpMsg << ( u16 )nX; - *tmpMsg << ( u8 )nActionStatus; - *tmpMsg << ( u8 )0x00; - *tmpMsg << ( u8 )nHealth; - *tmpMsg << ( u8 )0x00; - *tmpMsg << ( u8 )nAction; - - return tmpMsg; - } - -PMessage* PMsgBuilder::BuildNPCMassUpdateMsg( u32 nWorldID, u16 nX, u16 nY, u16 nZ, u8 nActionStatus, u8 nHealth, u16 nTarget, u8 nAction ) - { - PMessage* tmpMsg = new PMessage(); - - *tmpMsg << ( u8 )0x13; // Begin UDP message - *tmpMsg << ( u16 )0x0000; - *tmpMsg << ( u16 )0x0000; - *tmpMsg << ( u8 )0x15; // Message length - *tmpMsg << ( u8 )0x1b; - *tmpMsg << ( u32 )nWorldID; - *tmpMsg << ( u8 )0x1F; - *tmpMsg << ( u16 )nY; - *tmpMsg << ( u16 )nZ; - *tmpMsg << ( u16 )nX; - *tmpMsg << ( u8 )nActionStatus; - *tmpMsg << ( u8 )0x77; // ? - *tmpMsg << ( u8 )nHealth; - *tmpMsg << ( u16 )nTarget; - *tmpMsg << ( u8 )0x00; // ? - *tmpMsg << ( u8 )0x00; // ? - *tmpMsg << ( u8 )0x00; // ? - *tmpMsg << ( u8 )nAction; - - return tmpMsg; - } - -// ========================== - -PMessage* PMsgBuilder::BuildNPCSingleUpdateMsg( PClient* nClient, u32 nWorldID, u16 nX, u16 nY, u16 nZ, u8 nActionStatus, u8 nHealth, u16 nTarget, u8 nAction ) - { - PMessage* tmpMsg = new PMessage(); - - *tmpMsg << ( u8 )0x13; // Begin UDP message - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x15; // Message length - *tmpMsg << ( u8 )0x1b; - *tmpMsg << ( u32 )nWorldID; - *tmpMsg << ( u8 )0x1F; - *tmpMsg << ( u16 )nY; - *tmpMsg << ( u16 )nZ; - *tmpMsg << ( u16 )nX; - *tmpMsg << ( u8 )nActionStatus; - *tmpMsg << ( u8 )0x77; // ? - *tmpMsg << ( u8 )nHealth; - *tmpMsg << ( u16 )nTarget; - *tmpMsg << ( u8 )0x00; // ? - *tmpMsg << ( u8 )0x00; // ? - *tmpMsg << ( u8 )0x00; // ? - *tmpMsg << ( u8 )nAction; - - return tmpMsg; - } -// ========================== -PMessage* PMsgBuilder::BuildSubskillIncMsg( PClient* nClient, u8 nSubskill, u16 nSkillPoints ) -{ - PMessage* tmpMsg = new PMessage( 33 ); - - nClient->IncreaseUDP_ID(); - u16 tFirstUDPID = nClient->GetUDP_ID(); - - nClient->IncreaseUDP_ID(); - u16 tSecondUDPID = nClient->GetUDP_ID(); - u16 tSecondSessionID = nClient->GetSessionID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )tSecondUDPID; - *tmpMsg << ( u16 )tSecondSessionID; - - *tmpMsg << ( u8 )0x09; // SubMessage length; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )tFirstUDPID; - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x25; - *tmpMsg << ( u8 )0x23; - *tmpMsg << ( u8 )0x27; - - nClient->IncreaseTransactionID(); - *tmpMsg << ( u8 )0x11; // SubMessage length; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )tSecondUDPID; - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x25; - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetTransactionID(); // testing / 0x0000 ???? - *tmpMsg << ( u8 )0x09; // ? - *tmpMsg << ( u16 )nSubskill; - *tmpMsg << ( u16 )nClient->GetChar()->Skill->GetSubSkill( nSubskill ); // nSubskill ? - *tmpMsg << ( u16 )nSkillPoints; - - //(*tmpMsg)[5] = (u8)(tmpMsg->GetSize() - 6); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildLevelUpMessage( PClient* nClient, u8 nMainSkill, u8 nNewLevel, u16 nFreeSkillPoints) -{ - PMessage* tmpMsg = new PMessage(21); - nClient->IncreaseUDP_ID(); - - *tmpMsg << (u8)0x13; - *tmpMsg << (u16)nClient->GetUDP_ID(); - *tmpMsg << (u16)nClient->GetSessionID(); - *tmpMsg << (u8)0x0F; - *tmpMsg << (u8)0x03; - *tmpMsg << (u16)nClient->GetUDP_ID(); - *tmpMsg << (u8)0x1F; - *tmpMsg << (u16)nClient->GetLocalID(); - *tmpMsg << (u8)0x25; - *tmpMsg << (u8)0x0B; - *tmpMsg << (u16)nMainSkill; - *tmpMsg << (u8)nNewLevel; - *tmpMsg << (u16)nFreeSkillPoints; - *tmpMsg << (u8)0x00; - *tmpMsg << (u8)0x00; - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildChatAddMsg( PClient* nClient, u32 nAddedCharID, u8 nMode ) -{ - PMessage* tmpMsg = new PMessage( 18 ); - - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - - *tmpMsg << ( u8 )0x00; // Message length placeholder; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x32; - *tmpMsg << ( u8 )nMode; - *tmpMsg << ( u32 )nAddedCharID; - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildDoorOpenMsg( u32 nRawItemID, bool nDoubleDoor ) -{ - //PMessage* tmpMsg = new PMessage(37); - PMessage* tmpMsg = new PMessage( 21 ); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )0x0000; //Client->GetUDP_ID(); // just placeholder, must be set outside - *tmpMsg << ( u16 )0x0000; // Client->GetSessionID(); // just placeholder, must be set outside - - *tmpMsg << ( u8 )0x0f; // Sub-message length; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )0x0000; //++Client->GetUDP_ID(); // just placeholder, must be set outside - *tmpMsg << ( u8 )0x1b; - *tmpMsg << ( u32 )nRawItemID; - *tmpMsg << ( u8 )0x20; //? - if ( nDoubleDoor ) - { - *tmpMsg << ( u16 )0x0005; //? - *tmpMsg << ( u16 )0x0000; //? - *tmpMsg << ( u16 )0x1500; //? - } - else - { - *tmpMsg << ( u16 )0x0000; //? - *tmpMsg << ( u16 )0x00c8; //? or 0x64 ? - *tmpMsg << ( u16 )0x10ff; //? - } - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -// Message from text.ini, section [MISC], id = 100+nTxtMsgId -PMessage* PMsgBuilder::BuildText100Msg( PClient* nClient, u8 nTxtMsgId, u32 nRawObjectID ) -{ - PMessage* tmpMsg = new PMessage( 17 ); - - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - - *tmpMsg << ( u8 )0x0c; // Message length; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x31; - *tmpMsg << ( u8 )nTxtMsgId; - *tmpMsg << ( u32 )nRawObjectID; - - //(*tmpMsg)[5] = (u8)(tmpMsg->GetSize() - 6); - - return tmpMsg; -} - -// Same as BuildText100Msg, but here we can specify *ANY* text from text.ini, not limited to section [MISC] -// 1: [DIALOG] -// 2: [STATEMENT] -// 3: [GUI] + [playertextures] -// 4: [TERMINAL] -// 5: [MENU] -// 6: [MISC] -// 7: [ITEMDESC] -// 8: [HELPTEXT] -PMessage* PMsgBuilder::BuildTextIniMsg( PClient* nClient, u8 nTxtGroupID, u16 nTxtID ) -{ - PMessage* tmpMsg = new PMessage( 20 ); - - nClient->IncreaseUDP_ID(); - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x0e; // Message length - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x25; // ?? - *tmpMsg << ( u8 )0x15; // ?? - *tmpMsg << nTxtGroupID; - *tmpMsg << nTxtID; - *tmpMsg << ( u8 )0x00; // ?? - *tmpMsg << ( u8 )0x00; // ?? - *tmpMsg << ( u8 )0x00; // ?? - - //(*tmpMsg)[5] = (u8)(tmpMsg->GetSize() - 6); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildCharInteractionMenuMsg( PClient* nClient, u32 nRawTargetID ) -{ - PMessage* tmpMsg = new PMessage( 17 ); - - nClient->IncreaseUDP_ID(); - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x0b; // Message length - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x4d; - *tmpMsg << ( u32 )nRawTargetID; - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildFurnitureActivateMsg( PClient* nClient, u32 nRawObjectID, u8 nActionValue ) -{ - PMessage* tmpMsg = new PMessage( 12 ); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - - *tmpMsg << ( u8 )0x06; // SubMessage length; - *tmpMsg << ( u8 )0x2d; - *tmpMsg << ( u32 )nRawObjectID; - *tmpMsg << ( u8 )nActionValue; // known valid are 5 (ring), 9 (remove) and 10 (clic) - - //(*tmpMsg)[5] = (u8)(tmpMsg->GetSize() - 6); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildCharUseFurnitureMsg( PClient* nClient, u32 nRawObjectID ) -{ - PMessage* tmpMsg = new PMessage( 24 ); - - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - - *tmpMsg << ( u8 )0x06; // SubMessage length; - *tmpMsg << ( u8 )0x2d; - *tmpMsg << ( u32 )nRawObjectID; - *tmpMsg << ( u8 )0x0a; - - *tmpMsg << ( u8 )0x0b; // SubMessage length; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x17; - *tmpMsg << ( u32 )nRawObjectID; - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildCharUseVhcTerminalMsg( PClient* nClient, u32 nRawObjectID ) -{ - PMessage* tmpMsg = new PMessage( 24 ); - - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - - *tmpMsg << ( u8 )0x06; // SubMessage length; - *tmpMsg << ( u8 )0x2d; - *tmpMsg << ( u32 )nRawObjectID; - *tmpMsg << ( u8 )0x0a; - - *tmpMsg << ( u8 )0x07; // SubMessage length; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x4a; - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildCharUseGogoMsg( PClient* nClient ) -{ - PMessage* tmpMsg = new PMessage( 17 ); - - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - - *tmpMsg << ( u8 )0x0b; // Message length; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x3d; - *tmpMsg << ( u32 )0x0000000d; // cmd - - //(*tmpMsg)[5] = (u8)(tmpMsg->GetSize() - 6); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildCharUseVentureWarpMsg( PClient* nClient, u32 nRawObjectID ) -{ - PMessage* tmpMsg = new PMessage( 17 ); - - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - - *tmpMsg << ( u8 )0x0b; // Message length; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x3d; - *tmpMsg << ( u32 )0x00000008; // cmd - *tmpMsg << ( u32 )0x00000007; // cmd ? - *tmpMsg << ( u32 )0x00000002; // ? - *tmpMsg << ( u16 )0x0004; // ? - *tmpMsg << nRawObjectID; - // *tmpMsg << (u8)0x13; // ? Seems we can do without... - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildVhcAccessRequestMsg( PClient* nClient, u32 nRequestId, u32 nRequesterCharId, u32 nRequesterLocalId, u32 nVhcRawObjectID ) -{ - PMessage* tmpMsg = new PMessage( 40 ); - - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - - *tmpMsg << ( u8 )0x22; // Message length; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x3d; - *tmpMsg << ( u32 )0x00000008; // cmd - *tmpMsg << ( u32 )0x00000005; // cmd ? - *tmpMsg << ( u32 )nRequestId; - *tmpMsg << ( u16 )0x000c; // ? length ? - *tmpMsg << nRequesterCharId; //u32 - *tmpMsg << nRequesterLocalId; // ? u32 - *tmpMsg << nVhcRawObjectID; - *tmpMsg << ( u8 )0x08; // ? - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} -/* S->C -13:ff:00:72:d6:22: -03:ff:00:1f:03:00: -3d: -08:00:00:00: -05:00:00:00: -01:00:00:00: -0c:00: -2f:d8:01:00: -02:00:00:00: -5d:03:00:00: -08: -*/ - -/* C->S RESP: OK -13:79:00:ec:d5:17: -03:79:00:1f:03:00: -3d: -09:00:00:00: -06:00:00:00: -02:00:00:00: -01:00: -01:00 -*/ -/* C->S RESP: NOK -13:74:00:e7:d5:17: -03:74:00:1f:03:00: -3d: -09:00:00:00: -06:00:00:00: -01:00:00:00: -01:00: -00:00 - -*/ - -PMessage* PMsgBuilder::BuildCharUseGenrepMsg( PClient* nClient, u32 nRawObjectID, u32 nLocation, u16 nEntity ) -{ - PMessage* tmpMsg = new PMessage( 24 ); - - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - - *tmpMsg << ( u8 )0x06; // SubMessage length; - *tmpMsg << ( u8 )0x2d; - *tmpMsg << ( u32 )nRawObjectID; - *tmpMsg << ( u8 )0x0a; - - // this submessage is only needed to set to location/entity of the GR for a potential record in the char's GR list - *tmpMsg << ( u8 )0x0d; // SubMessage length; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x2d; - *tmpMsg << ( u32 )nLocation; - *tmpMsg << ( u16 )nEntity; - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildCharUseLiftMsg( PClient* nClient, u32 nRawObjectID, u16 nAptPlace ) -{ - PMessage* tmpMsg = new PMessage( 29 ); - - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - - *tmpMsg << ( u8 )0x06; // SubMessage length; - *tmpMsg << ( u8 )0x2d; - *tmpMsg << ( u32 )nRawObjectID; - *tmpMsg << ( u8 )0x0a; - - *tmpMsg << ( u8 )0x11; // SubMessage length; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x38; - *tmpMsg << ( u8 )0x01; - *tmpMsg << ( u32 )nRawObjectID; - *tmpMsg << ( u16 )nAptPlace; - *tmpMsg << ( u16 )0x0000; - *tmpMsg << ( u8 )0x00; - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildCharShowGlowCircleMsg( PClient* nClient ) -{ - PMessage* tmpMsg = new PMessage( 14 ); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )0x0000; // UDP ID placeholder - *tmpMsg << ( u16 )0x0000; // SessionID placeholder - *tmpMsg << ( u8 )0x08; // Len (static, always 0x08 - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )0x0000; // Sub UDP ID placeholder - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x3c; // Command SHOW GLOWING CIRCLE (kinda ^^) - *tmpMsg << ( u8 )0x01; // "on" ? - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildCharMoneyUpdateMsg( PClient* nClient, u32 nCredits ) -{ - PMessage* tmpMsg = new PMessage( 21 ); - nClient->IncreaseUDP_ID(); - nClient->IncreaseTransactionID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x0f; // Message length - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x25; // cmd - *tmpMsg << ( u8 )0x13; // cmd - *tmpMsg << ( u16 )nClient->GetTransactionID(); - *tmpMsg << ( u8 )0x04; // cmd - *tmpMsg << nCredits; - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildUndefineduseMsg( PClient* nClient, u8 nValue ) -{ - PMessage* tmpMsg = new PMessage( 15 ); - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x09; // Message length - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x25; - *tmpMsg << ( u8 )0x23; - *tmpMsg << nValue; - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildCharUseQBSlotMsg2( PClient* nClient, u16 nV1, u16 nV2, u16 nV3, u16 nV4, u16 nV5, u16 nV6, u16 nV7 ) -{ - // lol? Whats this? - PMessage* tmpMsg = new PMessage( 28 ); - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x16; // Message length - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x25; // cmd - *tmpMsg << ( u8 )0x22; // cmd - *tmpMsg << nV1; - *tmpMsg << nV2; - *tmpMsg << nV3; - *tmpMsg << nV4; - *tmpMsg << nV5; - *tmpMsg << nV6; - *tmpMsg << nV7; - /* *tmpMsg << (u8)0x64; // ?? - *tmpMsg << (u8)0x00; // ?? - *tmpMsg << (u8)0x64; // ?? - *tmpMsg << (u8)0x00; // ?? - *tmpMsg << (u8)0x64; // ?? - *tmpMsg << (u8)0x00; // ?? - *tmpMsg << (u8)0x64; // ?? - *tmpMsg << (u8)0x00; // ?? - *tmpMsg << (u8)0x64; // ?? - *tmpMsg << (u8)0x00; // ?? - *tmpMsg << (u8)0x64; // ?? - *tmpMsg << (u8)0x00; // ?? - *tmpMsg << (u8)0x00; // ?? - *tmpMsg << (u8)0x00; // ?? - */ - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildCharUseQBSlotMsg3( PClient* nClient, u8 nSlot ) -{ - PMessage* tmpMsg = new PMessage( 19 ); - nClient->IncreaseUDP_ID(); - nClient->IncreaseTransactionID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x0d; // Message length - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x25; // cmd - *tmpMsg << ( u8 )0x13; // cmd - *tmpMsg << ( u16 )nClient->GetTransactionID(); - *tmpMsg << ( u8 )0x0b; // cmd - *tmpMsg << nSlot; // ?? - *tmpMsg << ( u8 )0x00; // ?? - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildCharUseQBSlotMsg4( PClient* nClient, u16 nWeaponId ) -{ - PMessage* tmpMsg = new PMessage( 16 ); - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x0a; // Message length - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x2f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x02; // ?? - *tmpMsg << ( u8 )0x02; // ?? - *tmpMsg << nWeaponId; - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildContainerContentList( PContainer* nContainer, u8 nLocType ) -{ - PMessage* tmpMsg = new PMessage( 256 ); - std::vector< PContainerEntry* >* Entries = nContainer->GetEntries(); - PContainerEntry* tEntry; - PMessage* entryMsg; - -//Console->Print(YELLOW, BLACK, "BuildContainerContentList for loc %d", nLocType); - if ( nLocType != INV_LOC_BOX ) - { - if ( nLocType == INV_LOC_BACKPACK ) - *tmpMsg << ( u16 )Entries->size(); // items nb - else - *tmpMsg << ( u8 )Entries->size(); // items nb - } - - for ( u16 i = 0; i < Entries->size(); ++i ) - { - tEntry = Entries->at( i ); - entryMsg = BuildContainerContentEntry( tEntry, nLocType ); -//if(tEntry->mItem->mItemID == 390) -//{ -//Console->Print(YELLOW, BLACK, "BuildContainerContentList entry %d - size %d", i, entryMsg->GetSize()); -//entryMsg->Dump(); -//} - *tmpMsg << *entryMsg; - delete entryMsg; - } - - delete Entries; - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildContainerContentEntry( PContainerEntry* nEntry, u8 nLocType ) -{ - PMessage* tmpMsg = new PMessage( 16 ); - PItem* tItem; - u8 dataFlags, Qualifier; - - tItem = nEntry->mItem; - dataFlags = Qualifier = 0x00 ; - - if (( tItem->mItemID == 390 ) /* testing */ || tItem->mLoadedAmmoNb ) - { - dataFlags |= 0x01; - } - if (( tItem->GetType() == ITEM_TYPE_WEAPON ) || ( tItem->GetType() == ITEM_TYPE_BLUEPRINT ) || ( tItem->GetType() == ITEM_TYPE_WRECKEDPART )/*|| (tItem->GetType() == ITEM_TYPE_APARTMENTKEY) || (tItem->GetType() == ITEM_TYPE_CLANKEY) || (tItem->GetType() == ITEM_TYPE_VHCKEY) */ ) // testing loaded ammo type & BP attributes - { - dataFlags |= 0x20; - } - - switch ( tItem->GetType() ) - { - case ITEM_TYPE_WEAPON: - case ITEM_TYPE_AUTOWEAPON: - Qualifier = 6; - dataFlags |= 0x02; - break; - case ITEM_TYPE_IMPLANT: - case ITEM_TYPE_ARMOR: - Qualifier = 2; - dataFlags |= 0x02; - break; - default: - Qualifier = 0; - break; - } - - if ( tItem->IsStackable() && tItem->mStackSize ) - { - dataFlags |= 0x04; - } - - if (( tItem->mModificators ) || ( tItem->mItemID == 390 ) ) // TEST - dataFlags |= 0x10; - - if ( tItem->mMaxSlots || ( tItem->mItemID == 390 ) ) // TEST - dataFlags |= 0x40; - - - - if ( nLocType == INV_LOC_BOX ) - *tmpMsg << ( u8 )0x00; // Size of item placeholder - else - *tmpMsg << ( u16 )0x0000; // Size of item placeholder - - switch ( nLocType ) - { - case INV_LOC_WORN: - *tmpMsg << ( u8 )nEntry->mPosX; // X Location - *tmpMsg << ( u8 )0x00; // just nothing - break; - case INV_LOC_BACKPACK: - *tmpMsg << ( u8 )0x00; // just nothing again - *tmpMsg << ( u8 )nEntry->mPosX; // X Location - *tmpMsg << ( u8 )nEntry->mPosY; // Y Location - break; - case INV_LOC_GOGO: - *tmpMsg << ( u8 )nEntry->mPosX; - break; - case INV_LOC_BOX: - case INV_LOC_BOX2: - break; - default: - break; - } - - *tmpMsg << ( u16 )tItem->mItemID; // ItemID - *tmpMsg << ( u8 )dataFlags; // (0x01|0x02|0x04|0x10|0x20|0x40|0x80); // Datatypes - - if ( dataFlags & 0x01 ) - { - if ( tItem->GetType() == ITEM_TYPE_WEAPON ) // TESTING - *tmpMsg << ( u8 )6; // Remaining ammos - else - *tmpMsg << ( u8 )tItem->mLoadedAmmoNb; // Remaining ammos - } - - if ( dataFlags & 0x02 ) - { - *tmpMsg << ( u8 )Qualifier; // Qual entries - if ( Qualifier >= 2 ) - { - *tmpMsg << ( u8 )tItem->mCurDuration; // current qual - if ( Qualifier == 6 ) - { - *tmpMsg << ( u8 )tItem->mDamages; // dmg - *tmpMsg << ( u8 )tItem->mFrequency; // freq - *tmpMsg << ( u8 )tItem->mHandling; // handl - *tmpMsg << ( u8 )tItem->mRange; // range - } - *tmpMsg << ( u8 )tItem->mMaxDuration; // max qual - } - } - - if ( dataFlags & 0x10 ) - { - if ( tItem->mItemID == 390 ) // test - *tmpMsg << ( u8 )4; - else - *tmpMsg << ( u8 )tItem->mModificators; // addons bitflag: flashlight=1, scope, silencer, laserpointer - } - - if ( dataFlags & 0x40 ) - { - if ( tItem->mItemID == 390 ) // test - { - *tmpMsg << ( u8 )3; - *tmpMsg << ( u8 )3; - *tmpMsg << ( u16 )0x000b; // enlarged - *tmpMsg << ( u16 )0x05de; // phosophore - *tmpMsg << ( u16 )( -3 ); // silencer - } - else - { - - *tmpMsg << ( u8 )tItem->mUsedSlots; // used slots - *tmpMsg << ( u8 )tItem->mMaxSlots; // max slots - for ( u8 j = 0; j < tItem->mMaxSlots; ++j ) - *tmpMsg << ( u16 )(( j < tItem->mUsedSlots ) ? tItem->mSlot[j] : 0 ); // mod in slot - } - } - - if ( dataFlags & 0x20 ) // loaded ammo type ???? - { - u16 lengthFieldOffset = tmpMsg->GetNextByteOffset(); - *tmpMsg << ( u16 )0x0000; // length placeholder - - if ( tItem->GetType() == ITEM_TYPE_WEAPON ) - { - *tmpMsg << ( u8 )0x01; // ammo info - *tmpMsg << ( u8 )0x04; // total length ? - *tmpMsg << ( u8 )0x00; // + baseammo => current ammoId. 0xff => undefined - *tmpMsg << ( u8 )0xff; // supported ammos bitmap (all here) - } - - if ( false && ( tItem->GetType() == ITEM_TYPE_APARTMENTKEY ) ) // activated Apartment key - { - *tmpMsg << ( u8 )0x02; // ammo info - *tmpMsg << ( u8 )0x06; // total length - *tmpMsg << ( u32 )123456; // apartmentObjectID ? - } - - if ( false && ( tItem->GetType() == ITEM_TYPE_CLANKEY ) ) // activated ClanKey - { - *tmpMsg << ( u8 )0x04; // BP of... info - *tmpMsg << ( u8 )0x0a; // total length - *tmpMsg << ( u32 )1234; // ClanID ? - *tmpMsg << ( u32 )123456; // apartmentObjectID ? - } - - if ( tItem->GetType() == ITEM_TYPE_BLUEPRINT ) // BP - { - *tmpMsg << ( u8 )0x05; // BP of... info - *tmpMsg << ( u8 )0x06; // total length - *tmpMsg << ( u32 )486; // ItemID ("Tangent Sniper Rifle") - } - - if ( false && ( tItem->GetType() == ITEM_TYPE_VHCKEY ) ) // activated VHC Key - { - *tmpMsg << ( u8 )0x08; // VHC Key - *tmpMsg << ( u8 )0x0a; // total length - *tmpMsg << ( u32 )654321; // vhcObjectID ? - *tmpMsg << ( u32 )123456; // Owner CharID ? - } - - if ( false && ( tItem->GetType() == ITEM_TYPE_WRECKEDPART ) ) // Identified rare part - { - *tmpMsg << ( u8 )0x09; // Rare part - *tmpMsg << ( u8 )0x05; // total length - *tmpMsg << ( u16 )453; // Rare Item ID ? REDEEMER - *tmpMsg << ( u8 )0; // ?? - } - - if (( tItem->mConstructorId ) || ( tItem->mItemID == 390 ) ) // Named item /itemId 390: test - { - *tmpMsg << ( u8 )0x0a; // constructor info - *tmpMsg << ( u8 )0x06; // total length - //*tmpMsg << (u32)tItem->mConstructorId; // charID - *tmpMsg << ( u32 )2; - } - - tmpMsg->U16Data( lengthFieldOffset ) = tmpMsg->GetNextByteOffset() - lengthFieldOffset - 2; - } - - if ( dataFlags & 0x04 ) - { - *tmpMsg << ( u32 )tItem->mStackSize; - } - - - if ( nLocType == INV_LOC_BOX ) - tmpMsg->U8Data( 0 ) = tmpMsg->GetSize() - 1; - else - tmpMsg->U16Data( 0 ) = tmpMsg->GetSize() - 2; - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildCharOpenContainerMsg( PClient* nClient, u32 nContainerID, PContainer* nContainer ) -{ - PMessage* ContentList = BuildContainerContentList( nContainer, INV_LOC_BOX ); - - PMessage* tmpMsg = new PMessage(); - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x00; // Message length - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x26; - *tmpMsg << nContainerID; - *tmpMsg << ( u8 )0x00; // Always the same on item containers? // 0x01 for Trader (NeoX gameclient 3608) - *tmpMsg << ( u8 )0x64; // Always the same on item containers? - *tmpMsg << ( u8 )0x00; // Always the same on item containers? - *tmpMsg << ( u8 )0x08; // 0x08 when container is filled, 0x00 when not? At least it works.. - - *tmpMsg << ( u16 )( ContentList->GetSize() ); - *tmpMsg << *ContentList; - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - delete ContentList; - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildItemMoveMsg( PClient* nClient, u8 nSource, u8 nSrcX, u8 nSrcY, u8 nDestination, u8 nDestX, u8 nDestY, u8 nItemCnt ) -{ - PMessage* tmpMsg = new PMessage( 26 ); - nClient->IncreaseUDP_ID(); - nClient->IncreaseTransactionID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x14; // Message length - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x25; - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetTransactionID(); - *tmpMsg << ( u8 )0x14; // ItemMove Answer - *tmpMsg << nSource; - *tmpMsg << nSrcX; - *tmpMsg << nSrcY; - *tmpMsg << nDestination; - *tmpMsg << nDestX; - *tmpMsg << nDestY; - *tmpMsg << nItemCnt; - *tmpMsg << ( u8 )0x00; // ?? - *tmpMsg << ( u8 )0x00; // ?? - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildBoxItemMoveMsg( PClient* nClient, PContainerEntry* nEntry, u8 nSrcX, u8 nSrcY, u8 nDestination, u8 nDestX, u8 nDestY, u8 nItemCnt ) -{ - PMessage* tmpMsg = new PMessage( 64 ); - PMessage* entryMsg = BuildContainerContentEntry( nEntry, INV_LOC_BOX2 ); - - nClient->IncreaseUDP_ID(); - nClient->IncreaseTransactionID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - - *tmpMsg << ( u8 )0x09; // Message length - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x25; - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetTransactionID(); - *tmpMsg << ( u8 )0x17; // BoxItemMove Answer Src - *tmpMsg << ( u8 )INV_LOC_BOX; // Src = Box - *tmpMsg << nSrcX; - *tmpMsg << nSrcY; - *tmpMsg << nItemCnt; - *tmpMsg << ( u8 )0x00; // Qty high - *tmpMsg << ( u8 )0x18; // BoxItemMove Answer Dst - *tmpMsg << nDestination; - *tmpMsg << nDestX; - *tmpMsg << nDestY; - *tmpMsg << *entryMsg; - *tmpMsg << ( u8 )0x12; // ? vary ... - *tmpMsg << ( u8 )0x00; - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - delete entryMsg; - return tmpMsg; -} - -/*PMessage* PMsgBuilder::BuildItemAmmoUpdateMsg (PClient* nClient, PContainerEntry* nEntry, u8 nSrcX, u8 nSrcY, u8 nDestination, u8 nDestX, u8 nDestY, u8 nItemCnt) -{ - PMessage* tmpMsg = new PMessage(64); - PMessage* entryMsg = BuildContainerContentEntry(nEntry, INV_LOC_BOX2); - - nClient->IncreaseUDP_ID(); - nClient->IncreaseTransactionID(); - - *tmpMsg << (u8)0x13; - *tmpMsg << (u16)nClient->GetUDP_ID(); - *tmpMsg << (u16)nClient->GetSessionID(); - - *tmpMsg << (u8)0x09; // Message length - *tmpMsg << (u8)0x03; - *tmpMsg << (u16)nClient->GetUDP_ID(); - *tmpMsg << (u8)0x1f; - *tmpMsg << (u16)nClient->GetLocalID(); - *tmpMsg << (u8)0x25; - *tmpMsg << (u8)0x13; - *tmpMsg << (u16)nClient->GetTransactionID(); - *tmpMsg << (u8)0x17; // BoxItemMove Answer Src - *tmpMsg << (u8)INV_LOC_BOX; // Src = Box - *tmpMsg << nSrcX; - *tmpMsg << nSrcY; - *tmpMsg << nItemCnt; - *tmpMsg << (u8)0x00; // Qty high - *tmpMsg << (u8)0x18; // BoxItemMove Answer Dst - *tmpMsg << nDestination; - *tmpMsg << nDestX; - *tmpMsg << nDestY; - *tmpMsg << *entryMsg; - *tmpMsg << (u8)0x12; // ? vary ... - *tmpMsg << (u8)0x00; - - (*tmpMsg)[5] = (u8)(tmpMsg->GetSize() - 6); - - delete entryMsg; - return tmpMsg; -}*/ -/* Resp: -03:33:00:1f:01:00:25:13 -c2:01:0a:00:02:00:00:00 ?? -c3:01:05:03:00:00:12 Update ammo left -c4:01:05:02:00:00:0c Update ammo left -*/ - -PMessage* PMsgBuilder::BuildStartHackGameMsg( PClient* nClient, u32 nWorldObjID, u8 nHackDifficult ) -{ - PMessage* tmpMsg = new PMessage( 22 ); - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x10; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x28; - *tmpMsg << nWorldObjID; - *tmpMsg << nHackDifficult; - *tmpMsg << ( u8 )0x28; - *tmpMsg << ( u8 )0x5c; - *tmpMsg << ( u8 )0xcf; - *tmpMsg << ( u8 )0x3e; - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildSubwaySpawnMsg( PClient* nClient, bool IsSecondMessage ) -{ - PMessage* tmpMsg = new PMessage( 197 ); - u16 First = IsSecondMessage ? 6 : 0; - u16 Last = IsSecondMessage ? 10 : 5; - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )0x0000; // placeholder for UDP_ID; - *tmpMsg << ( u16 )0x0000; // placeholder for SessionID(); - - for ( u16 i = First; ( i <= Last ); i++ ) - { - nClient->IncreaseUDP_ID(); - *tmpMsg << ( u8 )0x11; //msg size - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x28; - *tmpMsg << ( u16 )0x0027; - *tmpMsg << ( u32 )( PSubway::mCabsBaseId + i ); - *tmpMsg << ( u16 )0x0000; - *tmpMsg << ( u8 )0x00; - *tmpMsg << ( u16 )Subway->mSubways[i].mPosition; - *tmpMsg << ( u8 )0x00; - *tmpMsg << ( u8 )Subway->mSubways[i].mDoorOpened;; - - nClient->IncreaseUDP_ID(); // vhc health update - *tmpMsg << ( u8 )0x0d; //msg size - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x2d; - *tmpMsg << ( u32 )( PSubway::mCabsBaseId + i ); - *tmpMsg << ( u8 )0x0a; - *tmpMsg << ( u32 )PSubway::mCabsBaseHealth; - } - - tmpMsg->U16Data( 1 ) = nClient->GetUDP_ID(); - tmpMsg->U16Data( 3 ) = nClient->GetSessionID(); - - return tmpMsg; -} - -/* -PMessage* PMsgBuilder::BuildSubwayFullUpdateMsg(PClient* nClient) -{ - PMessage* tmpMsg = new PMessage(148); - *tmpMsg << (u8)0x13; - *tmpMsg << (u16)0x0000; // placeholder for UDP_ID; - *tmpMsg << (u16)0x0000; // placeholder for SessionID(); - - for(u8 i=0; iIncreaseUDP_ID(); - *tmpMsg << (u8)0x0c; //msg size - *tmpMsg << (u8)0x03; - *tmpMsg << (u16)nClient->GetUDP_ID(); - *tmpMsg << (u8)0x32; - *tmpMsg << (u32)(PSubway::mCabsBaseId + i); - *tmpMsg << (u8)0x00; - *tmpMsg << (u16)Subway->mSubways[i].mPosition; - *tmpMsg << (u8)Subway->mSubways[i].mDoorOpened;; - } - - tmpMsg->U16Data(1) = nClient->GetUDP_ID(); - tmpMsg->U16Data(3) = nClient->GetSessionID(); - - return tmpMsg; -} -*/ - -PMessage* PMsgBuilder::BuildSubwaySingleUpdateMsg( u32 nVehicleID, u16 nPosition, u8 nDoorOpened ) -{ - PMessage* tmpMsg = new PMessage( 18 ); - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )0x0000; // placeholder for UDP_ID; - *tmpMsg << ( u16 )0x0000; // placeholder for SessionID(); - - *tmpMsg << ( u8 )0x0c; //msg size - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )0x0000; // ++UDP_ID placeholder - *tmpMsg << ( u8 )0x32; - *tmpMsg << ( u32 )nVehicleID; - *tmpMsg << ( u8 )0x00; - *tmpMsg << ( u16 )nPosition; - *tmpMsg << ( u8 )nDoorOpened; - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildSpawnWorldObjectMsg( u16 nModelID, u16 nFunctionID, u32 nWOID, u16 nPosX, u16 nPosY, u16 nPosZ, u8 nRotX, u8 nRotY, u8 nRotZ ) -{ - PMessage* tmpMsg = new PMessage( 31 ); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )0x0000; // UDP placeholder - *tmpMsg << ( u16 )0x0000; // Session placeholder - *tmpMsg << ( u8 )0x16; // Message length - *tmpMsg << ( u8 )0x03; // 0x03 commandset - *tmpMsg << ( u16 )0x0000; // UDP placeholder - *tmpMsg << ( u8 )0x1b; // Subcommandset - *tmpMsg << ( u32 )nWOID; // WorldobjectID - - *tmpMsg << ( u8 )0x19; // Positiondata follows - *tmpMsg << ( u16 )nPosY; - *tmpMsg << ( u16 )nPosZ; - *tmpMsg << ( u16 )nPosX; - *tmpMsg << ( u8 )nRotY; // Rotation X - *tmpMsg << ( u8 )nRotZ; // Rotation Y - *tmpMsg << ( u8 )nRotX; // Rotation Z - *tmpMsg << ( u16 )nModelID; - *tmpMsg << ( u16 )nFunctionID; - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildRemoveWorldObjectMsg( u32 nWOID ) -{ - PMessage* tmpMsg = new PMessage( 14 ); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )0x0000; // UDP ID placeholder - *tmpMsg << ( u16 )0x0000; // SessionID placeholder - *tmpMsg << ( u8 )0x08; // Len (static, always 0x08 - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )0x0000; // Sub UDP ID placeholder - *tmpMsg << ( u8 )0x26; // Command FADE AWAY CHAR (kinda ^^) - *tmpMsg << ( u32 )nWOID; // WorldobjectID - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildDBRequestStatusMsg( PClient* nClient, std::string *nCommandName, u8 nStatus, u16 nErrCode ) -{ - PMessage* tmpMsg = new PMessage( 32 ); - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x14; // Message length - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x2b; - *tmpMsg << ( u8 )0x1a; - *tmpMsg << ( u16 )( nCommandName->size() + 1 ); - *tmpMsg << ( u8 )nStatus; - *tmpMsg << ( u16 )nErrCode; - *tmpMsg << ( *nCommandName ); - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildDBAnswerMsg( PClient* nClient, std::string *nCommandName, std::string *nAnswerData, u16 nRows, u16 nCols ) -{ - u8 i, j, k; - PMessage* tmpMsg = new PMessage( 32 ); - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x14; // Message length - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x2b; - *tmpMsg << ( u8 )0x17; - *tmpMsg << ( u16 )( nCommandName->size() + 1 ); - *tmpMsg << ( u16 )nRows; - *tmpMsg << ( u16 )nCols; - *tmpMsg << ( *nCommandName ); - - for ( i = 0, k = 0; i < nRows; ++i ) - { - for ( j = 0; j < nCols; ++j, ++k ) - { - *tmpMsg << ( u16 )( nAnswerData[k].size() + 1 ); - *tmpMsg << nAnswerData[k]; - } - } - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildCharUseVhcMsg( PClient* nClient, u32 nRawObjectID, u16 nVhcType, u16 nAvailableSeats ) -{ - PMessage* tmpMsg = new PMessage( 24 ); - - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - - *tmpMsg << ( u8 )0x13; // Message length; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x3d; - *tmpMsg << ( u32 )0x0000000e; // cmd - *tmpMsg << nRawObjectID; - *tmpMsg << nVhcType; - *tmpMsg << nAvailableSeats; // Bit flags - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildVhcInfoMsg( PClient* nClient, PSpawnedVehicle* nVehicle ) -{ - PMessage* tmpMsg = new PMessage( 32 ); - PVhcCoordinates VhcPos = nVehicle->GetPosition(); - PVehicleInformation VhcInfo = nVehicle->GetInformation(); - - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - - *tmpMsg << ( u8 )0x00; // Message length placeholder; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x28; - *tmpMsg << ( u16 )0x0031; - *tmpMsg << ( u32 )nVehicle->GetLocalId(); - *tmpMsg << ( u8 )0x02; - *tmpMsg << ( u16 )( VhcPos.GetY() + 768 ); - *tmpMsg << ( u16 )( VhcPos.GetZ() + 768 ); - *tmpMsg << ( u16 )( VhcPos.GetX() + 768 ); - *tmpMsg << ( u8 )VhcPos.GetUD(); - *tmpMsg << ( u16 )VhcPos.GetLR(); - *tmpMsg << ( u16 )VhcPos.GetRoll(); - *tmpMsg << ( u8 )VhcInfo.GetVehicleType(); - *tmpMsg << ( u8 )0xff; - *tmpMsg << ( u32 )0x00000000; - *tmpMsg << ( u16 )0x0000; - *tmpMsg << ( u8 )0x00; - *tmpMsg << ( u8 )0x01; // ? changes - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -/*PMessage* PMsgBuilder::BuildVhcInfoMsg( PClient* nClient, PSpawnedVehicle* nVehicle ) -{ - PMessage* tmpMsg = new PMessage( 32 ); - PVhcCoordinates VhcPos = nVehicle->GetPosition(); - PVehicleInformation VhcInfo = nVehicle->GetInformation(); - - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - - *tmpMsg << ( u8 )0x00; // Message length placeholder; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x28; - *tmpMsg << ( u16 )0x0031; - *tmpMsg << ( u32 )nVehicle->GetLocalId(); - *tmpMsg << ( u8 )0x02; - *tmpMsg << ( u16 )( VhcPos.GetY() + 768 ); - *tmpMsg << ( u16 )( VhcPos.GetZ() + 768 ); - *tmpMsg << ( u16 )( VhcPos.GetX() + 768 ); - *tmpMsg << ( u8 )VhcPos.GetUD(); - *tmpMsg << ( u16 )VhcPos.GetLR(); - *tmpMsg << ( u16 )VhcPos.GetRoll(); - *tmpMsg << ( u8 )VhcInfo.GetVehicleType(); - *tmpMsg << ( u32 )0x00000000; - *tmpMsg << ( u32 )0x00000000; - *tmpMsg << ( u32 )0x00000000; - *tmpMsg << ( u16 )0x0000; - u32 tCharId; - for(u8 i = 0; i < 8; ++i) - { - if( (tCharId = nVehicle->GetSeatUser(i)) ) - { - *tmpMsg << tCharId; - } - else - { - *tmpMsg << ( u32 )0xffffffff; - } - *tmpMsg << i; - *tmpMsg << ( u16 )0x0000; - } - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -}*/ -/* ???? -13 f7 00 49 bf -5d -03 f7 00 -28 31 00 -c9 03 00 00 = Object ID -02 -47 ff -00 cd -c3 c3 -d7 -d7 ec -00 00 -29 -2b 65 35 8b 8c 6c 7f 80 96 -5f 26 00 80 00 -ff ff ff ff 00 00 00 -ff ff ff ff 01 00 00 -ff ff ff ff 02 00 00 -ff ff ff ff 03 00 00 -ff ff ff ff 04 00 00 -ff ff ff ff 05 00 00 -ff ff ff ff 06 00 00 -ff ff ff ff 07 00 00 - -*/ - -PMessage* PMsgBuilder::BuildVhcHealthUpdateMsg( PSpawnedVehicle* nVehicle ) -{ - PMessage* tmpMsg = new PMessage( 19 ); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )0x0000; // placeholder for UDP_ID; - *tmpMsg << ( u16 )0x0000; // placeholder for SessionID(); - - *tmpMsg << ( u8 )0x0d; //msg size - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )0x0000; // placeholder for ++UDP_ID - *tmpMsg << ( u8 )0x2d; - *tmpMsg << ( u32 )nVehicle->GetLocalId(); - *tmpMsg << ( u8 )0x0a; // Health update - *tmpMsg << ( f32 )( nVehicle->GetInformation().GetHealth() ); - - return tmpMsg; -} - -// NB: same as BuildCharSittingMsg. To be merged later when classes are adapted -PMessage* PMsgBuilder::BuildVhcPosUpdateMsg( PSpawnedVehicle* nVehicle ) -{ - PMessage* tmpMsg = new PMessage( 33 ); - PVhcCoordinates VhcPos = nVehicle->GetPosition(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )0x0000; //Client->GetUDP_ID(); // just placeholder, must be set outside - *tmpMsg << ( u16 )0x0000; // Client->GetSessionID(); // just placeholder, must be set outside - - *tmpMsg << ( u8 )0x00; // Message length placeholder; - *tmpMsg << ( u8 )0x32; - *tmpMsg << ( u16 )( nVehicle->GetLocalId() & 0xffff ); - *tmpMsg << ( u8 )0x03; // We suppose we use move type 3, as in client message - *tmpMsg << ( u16 )( VhcPos.GetY() + 768 ); // +768 or +0 ??? All Char/Vhc/NPC/Objet offset to clean up... - *tmpMsg << ( u16 )( VhcPos.GetZ() + 768 ); - *tmpMsg << ( u16 )( VhcPos.GetX() + 768 ); - *tmpMsg << ( u8 )VhcPos.GetUD(); - *tmpMsg << ( u16 )VhcPos.GetLR(); - *tmpMsg << ( u16 )VhcPos.GetRoll(); - *tmpMsg << ( u16 )VhcPos.GetUnknown(); - *tmpMsg << ( u8 )0x00; - *tmpMsg << ( u8 )VhcPos.GetAct(); - /* What is that for ???? - *tmpMsg << ( u8 )0x02; // <= these two u8 corresond to mUnknown... = additionnal data ? - *tmpMsg << ( u8 )0x00; // maybe weapon related ? - *tmpMsg << ( u16 )0x0000; - *tmpMsg << ( u16 )0x0001; - *tmpMsg << ( u16 )0x8000; - *tmpMsg << ( u16 )0x8000; - */ - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildVhcPosUpdate2Msg( PSpawnedVehicle* nVehicle ) -{ - PMessage* tmpMsg = new PMessage( 28 ); - PVhcCoordinates VhcPos = nVehicle->GetPosition(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )0x0000; // placeholder for UDP_ID; - *tmpMsg << ( u16 )0x0000; // placeholder for SessionID(); - - *tmpMsg << ( u8 )0x00; //msg size - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )0x0000; // ++UDP_ID placeholder - *tmpMsg << ( u8 )0x32; - *tmpMsg << ( u16 )( nVehicle->GetLocalId() & 0xffff ); - *tmpMsg << ( u8 )0x03; // 0x07 in nc2.2, and one more field (same a received msg) - *tmpMsg << ( u16 )( VhcPos.GetY() + 768 ); // +768 or +0 ??? All Char/Vhc/NPC/Objet offset to clean up... - *tmpMsg << ( u16 )( VhcPos.GetZ() + 768 ); - *tmpMsg << ( u16 )( VhcPos.GetX() + 768 ); - *tmpMsg << ( u8 )VhcPos.GetUD(); - *tmpMsg << ( u16 )VhcPos.GetLR(); - *tmpMsg << ( u16 )VhcPos.GetRoll(); - *tmpMsg << ( u16 )VhcPos.GetUnknown(); - *tmpMsg << ( u8 )VhcPos.GetFF(); - *tmpMsg << ( u8 )VhcPos.GetAct(); - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -/* -ground vhc in NC1 -C->S -[...] 32:fb:03:03:d4:8c:2f:84:a0:7b:7b:bf:c6:53:28:01:00:ff:05 -S->C -[...] 32: fb:03: 03: d4:8c: 2f:84: a0:7b: 7b: bf:c6: 53:28: 01:00:ff:05 - - *nMsg >> mVhcLocalId; - *nMsg >> mMoveType; // 0 for subway, 3 for nc1 vhc, 7 for nc2 vhc // u8 - *nMsg >> mNewY; - *nMsg >> mNewZ; - *nMsg >> mNewX; - *nMsg >> mNewUD; // u8 - *nMsg >> mNewLR; - *nMsg >> mNewRoll; - *nMsg >> mUnk1; - *nMsg >> mFF; // u8 - *nMsg >> mAction; // u8 - -quad in NC2.2 -C->S -[...] 32:c9:03:07:28:65:35:8b:8c:6c:7f:09:99:45:26:10:80:01:00:ff:05 -S->C -[...] 32:c9:03:07:28:65:35:8b:8c:6c:7f:09:99:45:26:10:80:01:00:ff:05 - -glider in NC2.2 -C->S -[...] 32:4b:03:07:13:57:a9:88:89:af:86:c1:89:ec:81:64:82:01:00:ff:00 -S->C -[...] 32:4b:03:07:98:57:c8:88:59:b0:83:5c:88:13:81:64:82:01:00:ff:00: -[...] 32:4b:03:07:13:57:a9:88:89:af:86:c1:89:ec:81:64:82:01:00:ff:00: - - -*/ -PMessage* PMsgBuilder::BuildTraderItemListMsg( PClient* nClient, u32 nTraderNpcID ) //, PContainer* nContainer) -{ -// PMessage* ContentList = BuildContainerContentList(nContainer, INV_LOC_BOX); -// Tmp manual content list: - PMessage* ContentList = new PMessage(); - f32 PriceCoef = 1 / 1.379942; - u8 Quality = 255; // Range 0 - 255 - - //Item 1: - *ContentList << ( u16 )0x05e6; // Item Id "Clan key for CityAdmin" - *ContentList << ( u32 )304567; // Base (?) Item price = item.def price / 1.97 - // Displayed price is this price * 1.38 . Is this faction/barter factor ? - //Item 2: - *ContentList << ( u16 )0x05e7; // Item Id "Clan key for Diamond Real Estate" - *ContentList << ( u32 )( 420285 * PriceCoef ); - //Item 3: - *ContentList << ( u16 )0x05e8; // Item Id "Clan key for N.E.X.T." - *ContentList << ( u32 )( 420285 * PriceCoef ); - //Item 4: - *ContentList << ( u16 )0x060f; // Item Id "PLAZA - 2nd Lev. Apartment" - *ContentList << ( u32 )( 245166 * PriceCoef ); - //Item 5: - *ContentList << ( u16 )0x065c; // Item Id "Normal Viarosso Apartment Alamo Living" - *ContentList << ( u32 )( 840571 * PriceCoef ); - //Item 6: - *ContentList << ( u16 )0x065d; // Item Id "Luxus Viarosso Apartment Alamo Living" - *ContentList << ( u32 )( 1260856 * PriceCoef ); - - //Item 7: - *ContentList << ( u16 )355; // Item Id "HEW �Liquid Fire� Rifle" - *ContentList << ( u32 )( 1260856 * PriceCoef ); - - PMessage* tmpMsg = new PMessage(); - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x00; // Message length - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x26; - *tmpMsg << nTraderNpcID; - *tmpMsg << ( u8 )0x01; // Traders inventory - *tmpMsg << ( u16 )( ContentList->GetSize() / 6 ); // List entries - *tmpMsg << ( u8 )Quality; // Items quality - *tmpMsg << *ContentList; - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - delete ContentList; - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildStartWeaponReloadMsg( PClient* nClient ) -{ - PMessage* tmpMsg = new PMessage( 16 ); - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x00; // Message length - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x25; // cmd - *tmpMsg << ( u8 )0x16; // cmd - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildStartWeaponReloadAnimMsg( PClient* nClient ) -{ - PMessage* tmpMsg = new PMessage( 13 ); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )0x0000; // placeholder for UDP_ID; - *tmpMsg << ( u16 )0x0000; // placeholder for SessionID(); - - *tmpMsg << ( u8 )0x00; // Message length placeholder; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )0x0000; // placeholder for UDP_ID; - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x15; // cmd - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildHeldItemUseMsg( u16 nUserCharLocalId, u16 nWeaponId, u32 nTargetRawItemID, u8 nAiming, u8 nTargetedHeight, u8 nScore ) -{ - PMessage* tmpMsg = new PMessage( 22 ); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )0x0000; // placeholder for UDP_ID; - *tmpMsg << ( u16 )0x0000; // placeholder for SessionID(); - - *tmpMsg << ( u8 )0x00; // Message length placeholder; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )0x0000; // placeholder for UDP_ID; - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nUserCharLocalId; - *tmpMsg << ( u8 )0x01; // cmd - *tmpMsg << ( u16 )nWeaponId; - *tmpMsg << ( u32 )nTargetRawItemID; - *tmpMsg << ( u8 )nAiming; - *tmpMsg << ( u8 )nTargetedHeight; - *tmpMsg << ( u8 )nScore; - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildHeldItemUse2Msg( u16 nUserCharLocalId, u32 nTargetRawItemID ) -{ - PMessage* tmpMsg = new PMessage( 18 ); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )0x0000; // placeholder for UDP_ID; - *tmpMsg << ( u16 )0x0000; // placeholder for SessionID(); - - *tmpMsg << ( u8 )0x00; // Message length placeholder; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )0x0000; // placeholder for UDP_ID; - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nUserCharLocalId; - *tmpMsg << ( u8 )0x2c; // cmd - *tmpMsg << ( u8 )0x09; // cmd - *tmpMsg << ( u32 )nTargetRawItemID; - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildHeldItemUse3Msg( PClient* nClient, u16 nUnknown1, u16 nUnknown2, u16 nUnknown3, u16 nUnknown4 ) -{ - PMessage* tmpMsg = new PMessage( 22 ); - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x00; // Message length - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x25; // cmd - *tmpMsg << ( u8 )0x1a; // cmd - *tmpMsg << ( u16 )nUnknown1; - *tmpMsg << ( u16 )nUnknown2; - *tmpMsg << ( u16 )nUnknown3; - *tmpMsg << ( u16 )nUnknown4; - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildHeldItemUse4Msg( u16 nUserCharLocalId, u32 nTargetRawItemID, u16 nUnknown1, u16 nUnknown2, u8 nTargetedHeight ) -{ - PMessage* tmpMsg = new PMessage( 23 ); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )0x0000; // placeholder for UDP_ID; - *tmpMsg << ( u16 )0x0000; // placeholder for SessionID(); - - *tmpMsg << ( u8 )0x00; // Message length placeholder; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )0x0000; // placeholder for UDP_ID; - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nUserCharLocalId; - *tmpMsg << ( u8 )0x2c; // cmd - *tmpMsg << ( u8 )0x01; // cmd - *tmpMsg << ( u16 )nUnknown1; - *tmpMsg << ( u16 )nUnknown2; - *tmpMsg << ( u32 )nTargetRawItemID; - *tmpMsg << ( u8 )nTargetedHeight; - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildHeldItemAddonActivationMsg( PClient* nClient, u8 nState ) -{ - PMessage* tmpMsg = new PMessage( 15 ); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )0x0000; // placeholder for UDP_ID; - *tmpMsg << ( u16 )0x0000; // placeholder for SessionID(); - - *tmpMsg << ( u8 )0x00; // Message length placeholder; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )0x0000; // placeholder for UDP_ID; - *tmpMsg << ( u8 )0x2f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u16 )0x0001; // cmd ? - *tmpMsg << ( u8 )( 0x60 | nState ); - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildWeatherControlMsg( u16 nWeatherId ) -{ - PMessage* tmpMsg = new PMessage( 13 ); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )0x0000; // placeholder for UDP_ID; - *tmpMsg << ( u16 )0x0000; // placeholder for SessionID(); - - *tmpMsg << ( u8 )0x00; // Message length placeholder; - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )0x0000; // placeholder for UDP_ID; - *tmpMsg << ( u8 )0x2e; - *tmpMsg << ( u8 )0x01; // cmd - *tmpMsg << ( u16 )nWeatherId; //see at bottom of weather.def - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildCharUseTimedDrugMsg( PClient* nClient, const PDefDrug* nDrugDef, u16 nItemId ) -{ - PMessage* tmpMsg = new PMessage( 60 ); - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x00; // Message length - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x25; // cmd - *tmpMsg << ( u8 )0x06; // cmd - *tmpMsg << ( u8 )nDrugDef->GetChangeNum(); - *tmpMsg << ( u8 )0x01; // ??? not working if 0, no apparent change if > 1 - *tmpMsg << ( u16 )nDrugDef->GetDuration(); - *tmpMsg << ( u16 )nItemId; - for( u8 i = 0; i < nDrugDef->GetChangeNum(); ++i ) - { - *tmpMsg << ( u8 )nDrugDef->GetChangeType( i ); - *tmpMsg << ( u16 )( nDrugDef->GetChangeScale( i ) * 100 ); - *tmpMsg << ( u16 )nDrugDef->GetChangeTarget( i ); - } - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildCharUseInstantDrugMsg( PClient* nClient, const PDefDrug* nDrugDef ) -{ - PMessage* tmpMsg = new PMessage( 60 ); - nClient->IncreaseUDP_ID(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x00; // Message length - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x25; // cmd - *tmpMsg << ( u8 )0x07; // cmd - *tmpMsg << ( u8 )nDrugDef->GetChangeNum(); - *tmpMsg << ( u8 )0x02; // ??? other values not tested - for( u8 i = 0; i < nDrugDef->GetChangeNum(); ++i ) - { - *tmpMsg << ( u8 )nDrugDef->GetChangeType( i ); - *tmpMsg << ( f32 )( nDrugDef->GetChangeScale( i ) * 100 ); // f32 in nc2.2 - u16 in nc1 ??? - *tmpMsg << ( u16 )nDrugDef->GetChangeTarget( i ); - } - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - Console->Print( "%s PMsgBuilder::BuildCharUseInstantDrugMsg : data format not tested", Console->ColorText( YELLOW, BLACK, "[WARNING]" ) ); - - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildCharUseRecreationUnitMsg( PClient* nClient, u32 nObjectId ) -{ - PMessage* tmpMsg = new PMessage( 16 ); - nClient->IncreaseUDP_ID(); -/* - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u16 )nClient->GetSessionID(); - *tmpMsg << ( u8 )0x00; // Message length - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )nClient->GetUDP_ID(); - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )nClient->GetLocalID(); - *tmpMsg << ( u8 )0x25; // cmd - *tmpMsg << ( u8 )0x16; // cmd - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); -*/ - Console->Print( "%s PMsgBuilder::BuildCharUseRecreationUnitMsg : not implemented (target: 0x%08x)", Console->ColorText( YELLOW, BLACK,"[WARNING]" ), nObjectId ); - return tmpMsg; -} - -// For testing - packet to be broadcasted to zone -PMessage* PMsgBuilder::BuildNpcDeathMsg( PClient* nClient, u32 nNpcId, u8 unknown1, u8 unknown2 ) -{ - PMessage* tmpMsg = new PMessage( 19 ); - PChar *nChar = nClient->GetChar(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )0x0000; // placeholder for UDP_ID; - *tmpMsg << ( u16 )0x0000; // placeholder for SessionID(); - - *tmpMsg << ( u8 )0x00; // Message length placeholder; - *tmpMsg << ( u8 )0x1b; - *tmpMsg << ( u32 )nNpcId; - *tmpMsg << ( u8 )0x1f; - *tmpMsg << ( u16 )( nChar->Coords.mY + 768 + 30 ); //move Npc near to char :p - *tmpMsg << ( u16 )( nChar->Coords.mZ + 768 + 0 ); - *tmpMsg << ( u16 )( nChar->Coords.mX + 768 + 30 ); - *tmpMsg << ( u8 )2; // ??? 0x01=look at target, 0x02=?, 0x10 = kneel, 0x80 = die - *tmpMsg << ( u8 )1; //0=> dead on health 0 / else alive on health 0. Changes in caps - *tmpMsg << ( u8 )96; // health => 0 alive if prec >0 1-127 alive, <0 dead (ie u8 128-255 = neg signed values) - *tmpMsg << ( u16 )259; // targetId (N)PC - Here: left copbot at NC entrance (zone 2008) - *tmpMsg << ( u8 )0x00; // ? doesn't seem to change in caps - *tmpMsg << ( u8 )0x00; // ? doesn't seem to change in caps - *tmpMsg << ( u8 )0; // ? changes in caps - *tmpMsg << ( u8 )0; // ? changes in caps // moving speed somewhere ? - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - unknown2 = unknown1; // so that gcc doesn't complain if these vars are not used - return tmpMsg; -} - -PMessage* PMsgBuilder::BuildNpcCleanupMsg( u32 nNpcId, u8 nCmd ) -{ - PMessage* tmpMsg = new PMessage(); - - *tmpMsg << ( u8 )0x13; - *tmpMsg << ( u16 )0x0000; - *tmpMsg << ( u16 )0x0000; - *tmpMsg << ( u8 )0x00; // Message length - *tmpMsg << ( u8 )0x03; - *tmpMsg << ( u16 )0x0000; - *tmpMsg << ( u8 )0x2d; - *tmpMsg << ( u32 )nNpcId; - *tmpMsg << ( u8 )nCmd; // 6: npc/vhc "cleanup", 1: kill npc + msg "no reward, too small" - - ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 ); - - return tmpMsg; - } - - -/* -void Cmd_GiveItem (int ItemId, int Amount, int ClientNum) -{ - unsigned char SendBuffer[256]; - -// Inventory_AddNewItem (&Client_Sockets[ClientNum].CharInfo, ItemId, Amount); - SendBuffer[0] = 0x13; - SendBuffer[5] = 0x1b; - SendBuffer[6] = 0x03; - Network_IncrementUDP (ClientNum); - *(unsigned short*)&SendBuffer[7] = Client_Sockets[ClientNum].UDP_ID; - SendBuffer[9] = 0x1f; - *(unsigned short*)&SendBuffer[10] = Client_Sockets[ClientNum].CharInfo.MapID; - SendBuffer[12] = 0x25; - SendBuffer[13] = 0x13; - Client_Sockets[ClientNum].TransactionID++; - *(unsigned short*)&SendBuffer[14] = Client_Sockets[ClientNum].TransactionID;//Transaction ID - SendBuffer[16] = 0x18; - SendBuffer[17] = 0x03; //Location - SendBuffer[18] = 0xff; // \/ - SendBuffer[19] = 0xff; //Anywhere - SendBuffer[20] = 0x08; - SendBuffer[21] = 0x00; - *(unsigned short*)&SendBuffer[22] = ItemId; //Item Id - SendBuffer[24] = 0x05; - SendBuffer[25] = 0x01; - *(unsigned short*)&SendBuffer[26] = Amount; //Quantity - SendBuffer[28] = 0x00; - SendBuffer[29] = 0x00; - *(unsigned short*)&SendBuffer[30] = Client_Sockets[ClientNum].CharInfo.ItemTransactionID; //Id of Purchased Item (Client sends another packet for placement of new item) - - *(unsigned short*)&SendBuffer[1] = Client_Sockets[ClientNum].UDP_ID; - *(unsigned short*)&SendBuffer[3] = Client_Sockets[ClientNum].UDP_ID_HIGH; - - Network_SendUDP (SendBuffer, 32, ClientNum); -} -*/ - -/* Unkown use packets (from nc2.2) -13:81:00:81:e2: 0c: 03:81:00:23: 12:00: 07:00:00:00:00:00 // weather related ? - -13:56:00:56:e2: 40: 03:56:00:1f:01:00:25:13: f1:18:13:01:77:05:48:c7: f2:18:13:02:16:74:61:c7: f3:18:13:03:17:74:61:c7: f4:18:13:04:18:74:61:c7: f5:18:13:05:1f:2a:60:c7: f6:18:13:06:1f:2a:60:c7: f7:18:13:0b:3e:8f:6d:c7 - -13:5c:00:5c:e2: 0c: 03:5c:00:1f:01:00:25:13: f8:18:0e:02 - -13:xx:xx:xx:xx: 09: 03:68:00:2d: 6d:03:00:00: 06 // Action update ? other NPC update ? some vanish ? -*/ diff --git a/server/src/game/npctemplate.cpp b/server/src/game/npctemplate.cpp deleted file mode 100644 index 1971819..0000000 --- a/server/src/game/npctemplate.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - -/* -npctemplate.cpp - NPC template class - -MODIFIED: 21 Jun 2009 Namikon -REASON: - creation - -*/ - - -#include "main.h" -#include "include/npctemplate.h" - -PNPCTemplate::PNPCTemplate() -{ - mUnknown1 = 0; - mPosY = 0.0f; - mPosZ = 0.0f; - mPosX = 0.0f; - mNPCTypeID = 0; - mActorStringSize = 0; - mAngleStringSize = 0; - mNpcID = 0; - mHasAdditionalCoords = 0; - mUnknown2a = 0; - mUnknown2b = 0; - mUnknown2c = 0; - /*mUnknown3*/mTradeID = 0; - mUnknown4 = 0; - mActorName = ""; - mAngle = ""; -} - -PNPCTemplate::~PNPCTemplate() -{ - // Cleanup waypoints - for ( PWaypointMap::iterator i = mWayPoints.begin(); i != mWayPoints.end(); i++ ) - delete i->second; -} - -void PNPCTemplate::AddWayPoint(f32 nX, f32 nY, f32 nZ, u8 nID) -{ - struct s_f32coords *tWayPoint = new s_f32coords; - tWayPoint->mX = nX; - tWayPoint->mY = nY; - tWayPoint->mZ = nZ; - - if ( mWayPoints.insert( std::make_pair( nID, tWayPoint)).second ) - if ( gDevDebug ) Console->Print( "%s Waypoint %d (X %0.1f Y %0.1f Z %0.1f) added to NPC", Console->ColorText( CYAN, BLACK, "[DEBUG]" ), nID, nX, nY, nZ ); -} diff --git a/server/src/game/rconsole.cpp.inhib b/server/src/game/rconsole.cpp.inhib deleted file mode 100644 index 285c78e..0000000 --- a/server/src/game/rconsole.cpp.inhib +++ /dev/null @@ -1,265 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - rconsole.cpp - - Authors: - - Akiko - - Namikon - - someone else? - - MODIFIED: Unknown date / Unknown author - REASON: - initial release by unknown - - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL -*/ - -#include "main.h" - -static const int RCON_INPUTLEN = 512; - -struct PRConClient -{ - enum - { - RCCS_AUTH, - RCCS_AUTH_USER, - RCCS_AUTH_PASS, - RCCS_VALID, - RCCS_DISCONNECT - } mState; - - PSocket *mSocket; - PAccount *mAccount; - char mInput[RCON_INPUTLEN]; - int mInputLen; - bool mEcho; - std::clock_t mSleep, mSleepStart; - int mNumFailures; - - inline PRConClient(NLsocket &Sock) - { - mSocket = new PSocket(Sock); - mAccount = 0; - mInputLen = 0; - mEcho = true; - mSleep = 0; - mSleepStart = 0; - mNumFailures = 0; - } - - inline ~PRConClient() - { - delete mSocket; - } - - inline void Print(const char *Fmt, ...) - { - static char Str[256]; - va_list args; - va_start(args, Fmt); - vsnprintf(Str, 255, Fmt, args); - va_end(args); - mSocket->Write(Str); - } - -}; - -PRConsole::PRConsole() -{ - mListener = NL_INVALID; -} - -PRConsole::~PRConsole() -{ - if(mListener != NL_INVALID) - nlClose(mListener); - - for(ClientList::iterator i=mClients.begin(); i!=mClients.end(); i++) - delete *i; -} - -void PRConsole::Start() -{ - // CHECK FOR rconsole enabled!!! - Console->LPrint("Starting remote console..."); - u16 Port = Config->GetOptionInt("rconsole_port"); - mListener = nlOpen(Port, NL_TCP); - if(mListener == NL_INVALID) - { - Console->LPrint(RED, BLACK, "[ERROR]"); - Console->LPrint(" Remote console failed"); - Console->LClose(); - return; - } - - Console->LPrint(GREEN, BLACK, "Success"); - Console->LClose(); - nlListen(mListener); -} - -void PRConsole::Update() -{ - if(mListener==NL_INVALID) - return; - - NLsocket temp = nlAcceptConnection(mListener); - if(temp != NL_INVALID) - { - // TODO: print client ip addr - Console->Print("RConsole: client connected"); - PRConClient *cl = new PRConClient(temp); - cl->mState = PRConClient::RCCS_AUTH; - mClients.push_back(cl); - cl->Print("TinNS shell [%s]\r\n", TINNS_VERSION); - } - - for(ClientList::iterator i=mClients.begin(); i!=mClients.end();) - { - ClientList::iterator j=i; - PRConClient *cl = *i; - ++i; - if(!cl->mSocket->Update() || cl->mSocket->TimeOut()) - { - Console->Print("RConsole: client disconnected"); - mClients.erase(j); - delete cl; - continue; - } - - if(cl->mSleep > 0) - { - std::clock_t t = std::clock(); - cl->mSleep -= (t-cl->mSleepStart); - cl->mSleepStart = t; - - if(cl->mSleep < 0) - cl->mSleep = 0; - - // flush socket while sleeping - int Size=0; - cl->mSocket->Read(&Size); - - continue; - } - - if(cl->mState==PRConClient::RCCS_AUTH) - { - cl->Print("\r\nlogin: "); - cl->mState = PRConClient::RCCS_AUTH_USER; - } - - const u8 *Buf = 0; - int Size=0; - if((bool)(Buf = cl->mSocket->Read(&Size))) - { - for(int i=0; imInputLen < RCON_INPUTLEN) - { - switch(Buf[i]) - { - case 0x08 : - { - if(cl->mInputLen > 0) - { - if(cl->mEcho) - cl->mSocket->Write(Buf[i]); - cl->mInput[cl->mInputLen]=0; - --cl->mInputLen; - } - break; - } - - case '\n' : - { - if(cl->mEcho) - cl->mSocket->Write(Buf[i]); - cl->mInput[cl->mInputLen]=0; - ProcessClient(cl); - cl->mInputLen = 0; - break; - } - - default : - { - cl->mInput[cl->mInputLen++]=Buf[i]; - if(cl->mEcho) - cl->mSocket->Write(Buf[i]); - break; - } - } - } - } - } -} - -void PRConsole::ProcessClient(PRConClient* Client) -{ - Console->Print(">%s", Client->mInput); - if(Client->mInputLen > 1) - { - if(Client->mInput[Client->mInputLen-1] == '\r') - Client->mInput[Client->mInputLen-1]=0; - - if(Client->mState == PRConClient::RCCS_AUTH_USER) - { - Client->mAccount = Database->GetAccount(Client->mInput); - Client->mState = PRConClient::RCCS_AUTH_PASS; - Client->Print("password: "); - Client->mEcho = false; - } else - if(Client->mState == PRConClient::RCCS_AUTH_PASS) - { - Client->mEcho = true; - if((!Client->mAccount) || (Client->mAccount->GetPassword() != Client->mInput) || (!Client->mAccount->IsConsoleAllowed())) - { - Client->Print("Invalid user or password\r\n"); - Client->mSleepStart = std::clock(); - ++Client->mNumFailures; - if(Client->mNumFailures >= 3) - { - // sleep 1 minute - Client->mSleep = 60*CLOCKS_PER_SEC; - Client->mNumFailures = 0; - } else - Client->mSleep = 5*CLOCKS_PER_SEC; - - Client->mState = PRConClient::RCCS_AUTH; - } else - { - Client->Print("\r\n\nUser %s logged in\r\n", Client->mAccount->GetName().c_str()); - Client->mState = PRConClient::RCCS_VALID; - // disconnect after 30 minutes lacking socket activity - Client->mSocket->SetTimeOutValue(1800); - Prompt(Client); - } - } - } -} - -void PRConsole::Prompt(PRConClient *Client) -{ - Client->Print("$ ", Client->mAccount->GetName().c_str(), Config->GetOption("server_name").c_str()); -} diff --git a/server/src/game/server.cpp b/server/src/game/server.cpp deleted file mode 100644 index df19173..0000000 --- a/server/src/game/server.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - server.cpp - - Authors: - - Akiko - - Namikon - - someone else? - - MODIFIED: Unknown date / Unknown author - REASON: - initial release by unknown - - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL -*/ -#include "main.h" - -PServer::PServer() -{ - mNumClients = 0; - mMaxClients = Config->GetOptionInt("maxclients"); - mGMSlots = Config->GetOptionInt("gm_slots"); - if(mMaxClients==0) - mMaxClients=1; - if(mGMSlots==0) - mGMSlots=1; - Console->Print("Max clients: %i / GM slots: %i", mMaxClients, mGMSlots); - mClients.reserve(mMaxClients + mGMSlots); - for(int i=0; i= mMaxClients+mGMSlots) - return 0; - - return mClients[Client]; -} - -void PServer::Update() -{ - for(int i=0; iUpdate(); - if(mClients[i]->GetConnection()==PCC_NONE && mClients[i]->getTCPConn() == 0) - { - Console->Print("Removing client %i...", i); - delete mClients[i]; - mClients[i]=0; - --mNumClients; - } - } - } -} - -void PServer::Shutdown() -{ - Console->Print("======================"); - Console->Print("Shutting down Gameserver..."); - for(int i=0; i - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - Zoning - makes changing of maps possible ingame - - Authors: - - initial release by unknown person - - Sting - - Akiko - - Namikon - - MODIFIED: 23 August 2005 by Sting - REASON: - TO match up with defs/pak_worldinfo.def from patch 200 - - MODIFIED: 27 Aug 2005 by Akiko - REASON: - reformated for better reading - - thinking about a way to optimize the case statements - MODIFIED: 28 Aug 2005 by Akiko - REASON: - continued reformating - MODIFIED: 26 Oct 2005 Akiko - REASON: - fixed a bug -> loc is a int, and the location is a 16 bit value - - added GPL - MODIFIED: 27 Nov 2005 Akiko - REASON: - fixed a very stupid bug (loc) - MODIFIED: 04 Dec 2005 Akiko - REASON: - copying int to char array (loc) correctly now - MODIFIED: 07 Jan 2006 Namikon - REASON: - Fixed zoning to / from wastelands to / from city sectors (packet1 was wrong, thanks Maxx!!) - MODIFIED: 08 Jan 2006 Namikon - REASON: - Added appartment handling - - Fixed minimap - MODIFIED: 17 Jan 2006 Namikon - REASON: - File rewritten. Now, only 1 packet is send, like the real servers (that one fixed subway) - - Fixed several worldnames - MODIFIED: 26 Jul 2006 Hammag - REASON: - Fixed world 1086 (area mc5) worldname (from NeoX source) - - MODIFIED: 28 Sep 2006 Hammag - REASON: - Zone filename in now taken from appartments.def (for app zoning) or from worlds.ini (general case) - rather than hardcoded. - - MODIFIED: 09 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem - - TODO: Put get the fallback world from config - Check for file existence before sending info to client to avoid client crash and bad location in char info - -*/ - - -#include "main.h" - -#include "include/worlds.h" -#include "include/appartements.h" -#include "include/msgbuilder.h" - - -void SendZone(PClient *Client, u32 loc) -{ - //TODO : FIX case for worldroute and 5 missing id 505 - std::string worldName; - ConnectionTCP *Socket = Client->getTCPConn(); - //PChar *Char = Chars->GetChar(Client->GetCharID()); - - Socket->SetTimeOutValue(0xffff); - - PWorld* CurrentWorld = Worlds->GetWorld(loc); - if (CurrentWorld) - { - worldName = CurrentWorld->GetBspName(); - if (worldName.empty()) - { - worldName = "plaza/plaza_p1"; // Should be a config entry - Console->Print("Client %d: Empty name for world %d. Redirecting to %s", Console->ColorText(RED, BLACK, "Warning"), Client->GetID(), loc, worldName.c_str()); - loc = 1; - } - } - else - { - worldName = "plaza/plaza_p1"; // Should be a config entry - Console->Print("Client %d: Invalid or not loaded world %d. Redirecting to %s", Console->ColorText(YELLOW, BLACK, "Warning"), Client->GetID(), loc, worldName.c_str()); - loc = 1; - } - - PMessage* cMsg = MsgBuilder->BuildSendZoneTCPMsg(loc, &worldName); - Client->SendTCPMessage(cMsg); -} diff --git a/server/src/include/external.h b/server/src/include/external.h deleted file mode 100644 index 8d78051..0000000 --- a/server/src/include/external.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - external.h - include file for all common external standard libs - - MODIFIED: 31 Aug 2005 Akiko - REASON: - updating def file definitions to match the changes in gamedefs.cpp - - added define for charfiles path - - added define for database path - MODIFIED: 26 Sep 2005 Akiko - REASON: - reformated code - - added GPL - - added infoserver default port as define - - added my threading model (mutex.h, semaphore.h, thread.h) - - added basic includes pthread.h, semaphore.h and errno.h - MODIFIED: 28 Sep 2005 Akiko - REASON: - added define for game server port - MODIFIED: 30 Nov 2005 Akiko - REASON: - added chat.h for the chat part from Namikon - MODIFIED: 02 Dec 2005 Akiko - REASON: - commented out mutex.h, thread.h, semaphore.h - MODIFIED: 22 Dec 2005 Namikon/bakkdoor - REASON: - Added commands.h, skill.h, clientmanager.h - MODIFIED: 23 Dec 2005 bakkdoor - REASON: - Added for main.cpp -> catch strg-c and shutdown nicely - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added mysql.h, sql.h for MySQL support - MODIFIED: 01 Jan 2006 Namikon - REASON: - Moved skill.h before chars.h (char.h needs skill.h now) - MODIFIED: 30 May 2006 Namikon - REASON: - Removed all useless includes to complete the server splitup; Also renamed tinns.h to main.h - MODIFIED: 6 Jul 2006 Hammag - REASON: - moved include "types.h" before include "../netcode/main.h" to permit compile - MODIFIED: 10 Jul 2006 Hammag - REASON: - added inventory.h - REASON: - added item.h - - MODIFIED: 26 Aug 2006 Hammag - REASON: - splitted from main.h, keeping external includes in this single file - for all source tree - -*/ - -#ifndef EXTERNAL_H -#define EXTERNAL_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif diff --git a/server/src/include/svnrevision.h b/server/src/include/svnrevision.h deleted file mode 100644 index 6111157..0000000 --- a/server/src/include/svnrevision.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - THIS FILE IS GENERATED BY THE MAKE COMMAND make svnrev - It is to be updated by this command before each revision commit operation - PLEASE DON'T MODIFY BY HAND -*/ - -#ifndef SVN_REV_DEF -#define SVN_REV_DEF - -#define TINNS_SVN_REVISION "AKIKO_CMAKE_R2" - -#endif - diff --git a/server/src/include/tinns_mutex.h b/server/src/include/tinns_mutex.h deleted file mode 100644 index 4c8bc8b..0000000 --- a/server/src/include/tinns_mutex.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - mutex.h - part of a C++ thread model using the POSIX way - - MODIFIED: 26 Sep 2005 Akiko - REASON: - started the implementaion of a thread model -*/ - - -#ifndef MUTEX_H -#define MUTEX_H - -//this class needs pthread.h, but it should come from tinns.h - -class Mutex { - private: - mutable pthread_mutex_t mut; - void operator = (Mutex &mut) { - } - Mutex(const Mutex &mut) { - } - - public: - Mutex() { - pthread_mutexattr_t attr; - pthread_mutexattr_init(&attr); - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&mut, &attr); - pthread_mutexattr_destroy(&attr); - } - - virtual ~Mutex() { - pthread_mutex_unlock(&mut); - pthread_mutex_destroy(&mut); - } - - int Lock() const { - return(pthread_mutex_lock(&mut)); - } - - int TryLock() const { - return(pthread_mutex_trylock(&mut)); - } - - int Unlock() const { - return(pthread_mutex_unlock(&mut)); - } -}; - -#endif - diff --git a/server/src/include/tinns_semaphore.h b/server/src/include/tinns_semaphore.h deleted file mode 100644 index 735b81d..0000000 --- a/server/src/include/tinns_semaphore.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - semaphore.h - part of the C++ threading model (an very efficently way - of dealing with threads) - also a POSIX way - - MODIFIED: 26 Sep 2005 Akiko - REASON: - started threading model -*/ - -#ifndef SEMAPHORE_H -#define SEMAPHORE_H - -//this class uses semaphore.h, but it should come from tinns.h - -class Semaphore { - private: - sem_t sem; - - public: - Semaphore(int init = 0) { - sem_init(&sem, 0, init); - } - - virtual ~Semaphore() { - sem_destroy(&sem); - } - - void Wait() const { - sem_wait((sem_t *)&sem); - } - - int TryWait() const { - return(sem_trywait((sem_t *)&sem) ? errno : 0); - } - - int Post() const { - return(sem_post((sem_t *)&sem) ? errno : 0); - } - - int GetValue() const { - int val = -1; - - sem_getvalue((sem_t *)&sem, &val); - - return(val); - } - - void Reset(int init = 0) { - sem_destroy(&sem); - sem_init(&sem, 0, init); - } -}; - -#endif - diff --git a/server/src/include/types.h b/server/src/include/types.h deleted file mode 100644 index 1c26202..0000000 --- a/server/src/include/types.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - types.h - - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL -*/ - -#ifndef TYPES_H -#define TYPES_H - -// basic type definitions - -#ifdef WIN32 - typedef signed char s8; - typedef unsigned char u8; - typedef signed short s16; - typedef unsigned short u16; - typedef signed int s32; - typedef unsigned int u32; -// #ifdef _MSC_VER -// typedef signed __int64 s64; -// typedef unsigned __int64 u64; -// #endif // _MSC_VER - typedef float f32; - typedef double f64; -#else // no WIN32 - typedef signed char s8; - typedef unsigned char u8; - typedef signed short s16; - typedef unsigned short u16; - typedef signed int s32; - typedef unsigned int u32; - //typedef signed int64 s64; - //typedef unsigned int64 u64; - typedef float f32; - typedef double f64; -#endif // LINUX - -#endif diff --git a/server/src/include/version.h b/server/src/include/version.h deleted file mode 100644 index 79d0654..0000000 --- a/server/src/include/version.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -#ifndef VERSION_H -#define VERSION_H - -#include "svnrevision.h" - -#define TINNS_PATCH_VERSION "0.0.2 Dev" -#define TINNS_INFO_VERSION "0.0.2 Dev" -#define TINNS_GAME_VERSION "0.1.38 Dev" - -#endif - diff --git a/server/src/info/CMakeLists.txt b/server/src/info/CMakeLists.txt deleted file mode 100644 index 8962ecf..0000000 --- a/server/src/info/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -ADD_EXECUTABLE (infoserver accounts.cpp client.cpp globals.cpp infoserver.cpp main.cpp server.cpp sql.cpp) -TARGET_LINK_LIBRARIES (infoserver common ${MYSQL_LIBRARY} ${PCRE_LIBRARY}) diff --git a/server/src/info/accounts.h b/server/src/info/accounts.h deleted file mode 100644 index b779a74..0000000 --- a/server/src/info/accounts.h +++ /dev/null @@ -1,147 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - accounts.h - - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL - MODIFIED: 26 Dec 2005 Namikon - REASON: - Added load/save functions for SQL DB - MODIFIED: 01 Jan 2005 Namikon - REASON: - Added bool var for ingame debug outputs for administrators - MODIFIED: 06 Jan 2005 Namikon - REASON: - Added SetBannedStatus() to ban/unban an account (use SetBannedStatus(0) to unban a player) - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - -#ifndef ACCOUNTS_H -#define ACCOUNTS_H - -#ifdef _MSC_VER - #pragma once -#endif - -#include "common/regex++.h" - -/* -0 = unregistered user -1 = Registered user -30 = volunteer -50 = GM -100 = Admin -*/ - -// New way of AccountLevel handling: -// Every level is possible, the following values are only edge values. We need a bit control about that -#define PAL_BANNED -1 -#define PAL_UNREGPLAYER 0 -#define PAL_REGPLAYER 1 -#define PAL_VOLUNTEER 30 -#define PAL_GM 50 -#define PAL_ADMIN 100 - -// Max number of char slots per account -#define MAX_CHARS_PER_ACCOUNT 4 - -/* -0 = Offline -1 = Online -2 = Banned -*/ - -enum PAccountStatus -{ - PAS_OFFLINE = 0, - PAS_ONLINE = 1, - PAS_BANNED = 2 -}; - -class PAccount -{ - private : - // SQL Layout - enum { - a_id, - a_username, - a_password, - a_priv, - a_status, - a_bandate, - a_emailaddress, - a_creationdate, - a_lastused - }; - - // static members - static RegEx* mUsernameRegexFilter; - static RegEx* mPasswordRegexFilter; - - // instance members - u32 mID; - std::string mName; - std::string mPassword; - int mLevel; - PAccountStatus mStatus; - std::time_t mBannedUntil; - - bool LoadFromQuery(char* query); - bool DecodePassword(const u8* PasswordData, int PassLen, const u8 *Key, char* ClearPassword); - - public : - PAccount(); - PAccount(const u32 AccountId); - PAccount(const char *Username); - - static bool SetUsernameRegexFilter(const char* RegexStr); - static bool SetPasswordRegexFilter(const char* RegexStr); - static bool IsUsernameWellFormed(const char *Username); - static bool IsPasswordWellFormed(const char *Password); - - inline u32 GetID() const { return mID; } - bool SetName(const std::string &Pass); - inline const std::string &GetName() const { return mName; } - bool SetPassword(const std::string &Pass); - bool SetPasswordEncoded(const u8* PasswordData, int PassLen, const u8* Key); - inline const std::string &GetPassword() const { return mPassword; } - bool SetLevel(int newLevel); - inline int GetLevel() const { return mLevel; } - std::string GetLevelString() const; - bool SetStatus(PAccountStatus Status); - inline PAccountStatus GetStatus() const { return mStatus; } - bool SetBannedUntilTime(std::time_t BannedUntil); - inline bool IsBanned() const { return (mBannedUntil > std::time(NULL)); } - std::string GetBannedTime() const; - - bool Authenticate(const u8* PasswordData, int PassLen, const u8 *Key); - bool Authenticate(const char *Password) const; - - bool Create(); - bool Save(bool CreateMode = false); - - //u32 GetCharIdBySlot(const u32 SlotId); -}; - -#endif - diff --git a/server/src/info/client.cpp b/server/src/info/client.cpp deleted file mode 100644 index 8e801cc..0000000 --- a/server/src/info/client.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -#include "main.h" - -PClient::PClient(int Index) -{ - mIndex = Index; - mConnection = PCC_NONE; - mAccountID = 0; -} - -PClient::~PClient() -{ - if(m_TCPConnection) - { - delete m_TCPConnection; - } -} - -void PClient::InfoDisconnect() -{ - if(m_TCPConnection) - { - delete m_TCPConnection; - } - m_TCPConnection = 0; - - //mConnection &= ~PCC_INFO; - mConnection = PCC_NONE; - mAccountID = 0; -} - -void PClient::Update() -{ - if(m_TCPConnection) - { - if(m_TCPConnection->timeOut()) - { - Console->Print("InfoSocket: Client %i: timeout", mIndex); - InfoServer->ClientDisconnected(this); - } - else - { - if(!m_TCPConnection->update()) - { - InfoServer->ClientDisconnected(this); - } - } - } -} diff --git a/server/src/info/client.h b/server/src/info/client.h deleted file mode 100644 index 25bc05a..0000000 --- a/server/src/info/client.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -#ifndef CLIENT_H -#define CLIENT_H - -#ifdef _MSC_VER - #pragma once -#endif - -enum PClientConnection -{ - PCC_NONE = 0, - PCC_INFO = 1 -}; - -class PClient -{ - private : - ConnectionTCP* m_TCPConnection; - int mIndex; - int mConnection; - u32 mAccountID; - - protected : - public : - PClient(int Index); - ~PClient(); - - inline int GetIndex() const { return mIndex; } - - void setTCPConnection(ConnectionTCP* conn) { m_TCPConnection = conn; mConnection = PCC_INFO; } - inline ConnectionTCP* getTCPConn() const { return m_TCPConnection; } - - inline int GetConnection() const { return mConnection; } - inline const char *GetAddress() const { return m_TCPConnection->getRemoteAddress(); } - - inline void setAccountID(u32 nAccountID) { mAccountID = nAccountID; } - inline u32 getAccountID() { return mAccountID; } - - void InfoDisconnect(); - - void Update(); -}; - -#endif - diff --git a/server/src/info/globals.h b/server/src/info/globals.h deleted file mode 100644 index 649489b..0000000 --- a/server/src/info/globals.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - globals.h - - MODIFIED: 12 September 2005 Akiko - REASON: - exchanged Pretender Strings by TinNS - - removed some Windows specific code - MODIFIED: 16 Dec 2005 bakkdoor - REASON: - Added global ClientManager and Chat Interface - MODIFIED: 22 Dec 2005 Namikon - REASON: - Added GPL - MODIFIED: 27 Aug 2006 Hammag - REASON: - Added AdditionnalConfigChecks() local function - -*/ - -#ifndef GLOBALS_H -#define GLOBALS_H - -#ifdef _MSC_VER - #pragma once -#endif - -extern class ServerSocket* ServerSock; -extern class PConsole *Console; -extern class PServer *Server; -extern class PConfig *Config; -extern class PInfoServer *InfoServer; - -extern class PMySQL* MySQL; -//extern class PAccounts* Accounts; // To be removed - -extern const char ServerVersion[]; -extern const char SVNRevision[]; - -bool Init(); -void Shutdown(); -bool AdditionnalConfigChecks(); - -#endif - diff --git a/server/src/info/infoserver.cpp b/server/src/info/infoserver.cpp deleted file mode 100644 index 561e9b1..0000000 --- a/server/src/info/infoserver.cpp +++ /dev/null @@ -1,608 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - -/* - MODIFIED: 01 Jul 2006 hammag - REASON: - added set timeout to 10 msec (for ReadSetTCP select) in Start() - to avoid useless 100% CPU use - MODIFIED: 27 Aug 2006 hammag - REASON: - Removed INFO_PORT use as value is available from config - MODIFIED: 27 Aug 2006 hammag - REASON: - Modified GSLiveCheck() to be independant of gameserver time (no time sync needed between servers) - MODIFIED: 27 Aug 2006 hammag - REASON: - Display the client id in Client connection message rather than the always increasing mNumClients - - Removed use of mNumClients in PInfoServer. the count is done in PServer. - - ToDo: - - Take main loop timeout setting from config file -*/ - -#include "main.h" - -struct PInfoState -{ - enum State - { - IS_UNKNOWN, - IS_CONNECTED, - IS_HANDSHAKE0, - IS_AUTHENTICATE, - IS_SERVERLIST - } mState; - - bool mWaitSend; // wait-for-completition flag - PInfoState() - { - mState = IS_UNKNOWN; - mWaitSend = false; - }; -}; - -PInfoServer::PInfoServer() -{ - //mNumClients = 1; - mLivecheckInterval = Config->GetOptionInt("gameserver_livecheck"); -} - -PInfoServer::~PInfoServer() -{ - Console->Print("Closing Infoserver..."); - - ServerSock->closeServer(); - - for(InfoStateMap::iterator i=ClientStates.begin(); i!=ClientStates.end(); i++) - delete i->second; -} - -void PInfoServer::Start() -{ - u16 Port = Config->GetOptionInt("infoserver_port"); - Console->LPrint("Starting Infoserver on port %i...", Port); - - if(ServerSock->open(Port)) - { - Console->LPrint(GREEN, BLACK, "Success"); - Console->LClose(); - } - else - { - Console->LPrint(RED, BLACK, "Failed"); - Console->LClose(); - } - ServerSock->settimeout(0, 10000); - GSLiveCheck(); -} - -void PInfoServer::Update() -{ - if(ServerSock->newConnection()) - { - int clid = Server->NewClient(); - if(clid!=-1) - { - Console->Print(GREEN, BLACK, "Infoserver: client [%i] connected", clid); - PClient *Client = Server->GetClient(clid); - - ConnectionTCP* tcpConn = ServerSock->getTCPConnection(); - Client->setTCPConnection(tcpConn); - - Console->Print("Client address: %s", Client->GetAddress()); - //++mNumClients; - - PInfoState *state = new PInfoState(); - ClientStates.insert(std::make_pair(Client, state)); - state->mState = PInfoState::IS_CONNECTED; - } else - { - Console->Print("Infoserver: Client connection refused (server full?)"); - } - } - - for(InfoStateMap::iterator i=ClientStates.begin(); i!=ClientStates.end();) - { - PClient *Client = i->first; - PInfoState *State = i->second; - // node gets erased in FinalizeClient, increment iterator now - ++i; - if(!ProcessClient(Client, State)) - FinalizeClient(Client, State); - } -} - -void PInfoServer::GSLiveCheck() -{ - MYSQL_ROW row; - MYSQL_RES *result; - char query[256]; - snprintf (query, 256, "SELECT *, (NOW()< (`s_lastupdate` + INTERVAL %d SECOND)) FROM `server_list`", mLivecheckInterval); - - result = MySQL->ResQuery(query); - if(result == NULL) - { - Console->Print("Livecheck: %s unable to read server list!", Console->ColorText(RED, BLACK, "[Warning]")); - MySQL->ShowSQLError(); - return; - } - if(mysql_num_rows(result) == 0) - { - Console->Print("Livecheck: %s no gameserver found!", Console->ColorText(RED, BLACK, "[Warning]")); - MySQL->FreeSQLResult(result); - return; - } - - ServerMap::iterator it; - while((row = mysql_fetch_row(result))) - { - it = Serverlist.find(atoi(row[s_id])); - if(it != Serverlist.end()) - { - strncpy(it->second.mName, row[s_name], MAX_SERVER_NAME_LENGTH); - it->second.mLanIp = IPStringToDWord(row[s_lanaddr]); - it->second.mWanIp = IPStringToDWord(row[s_wanaddr]); - it->second.mPort = atoi(row[s_port]); - it->second.mPlayers = atoi(row[s_players]); - /* Prepared for future addon Servers by Accesslevel */ - // it->second.mMinLv = atoi(row[s_minlv]); - /* ------------------------------------------------ */ - - // ToDo: If statement correct? Maybe GSLiveCheck() has - // to be called every mLinvecheckInterval seconds.... We'll - // see when Gameserver has been rewritten - - if(row[s_timecheck] && (atoi(row[s_timecheck]) == 1)) - { - it->second.mLasttimestamp = atol(row[s_lastupdate]); - it->second.mOnline = true; - } - else - { - it->second.mOnline = false; - } - - it->second.mUpdated = true; - } - else - { - GameServers tmpServer; - - strncpy(tmpServer.mName, row[s_name], MAX_SERVER_NAME_LENGTH); - tmpServer.mLanIp = IPStringToDWord(row[s_lanaddr]); - tmpServer.mWanIp = IPStringToDWord(row[s_wanaddr]); - tmpServer.mLasttimestamp = atol(row[s_lastupdate]); - tmpServer.mPlayers = atoi(row[s_players]); - tmpServer.mPort = atoi(row[s_port]); - tmpServer.mOnline = true; - tmpServer.mUpdated = true; - Console->Print("Added GameServer %s", tmpServer.mName); - /* Prepared for future addon Servers by Accesslevel */ - // tmpServer.mMinLv = atoi(row[s_minlv]); - /* ------------------------------------------------ */ - - Serverlist.insert(std::make_pair(atoi(row[s_id]), tmpServer)); - } - } - MySQL->FreeSQLResult(result); - - for(ServerMap::iterator it = Serverlist.begin(); it != Serverlist.end(); it++) - { - if(it->second.mUpdated == false) - Serverlist.erase(it); - else - it->second.mUpdated = false; - } - -} - -void PInfoServer::ClientDisconnected(PClient *Client) -{ - InfoStateMap::iterator node = ClientStates.find(Client); - if(node == ClientStates.end()) - return; - - PInfoState *State = node->second; - FinalizeClient(Client, State); -} - -bool PInfoServer::HandleHandshake(PInfoState *State, const u8 *Packet, int PacketSize) -{ - //static const u8 HANDSHAKE1A[6]={0xfe, 0x03, 0x00, 0x80, 0x03, 0x68}; - - switch(State->mState) - { - case PInfoState::IS_HANDSHAKE0 : - { - if(PacketSize==6 && *(u16*)&Packet[3]==0x0080 && Packet[5]==0x78) - { - //FIXME: this packet seems to be unnecessary, although it appears in traffic dumps - // (causes clientside "Wrong protocol" errors) - //Socket->Write(HANDSHAKE1A, 6); - State->mState = PInfoState::IS_AUTHENTICATE; - } - else - { - Console->Print(RED, BLACK, "Infoserver protocol error (IS_HANDSHAKE0): invalid packet [%04x]", *(u16*)&Packet[3]); - return false; - } - break; - } - default: - break; - } - - return true; -} - -bool PInfoServer::HandleAuthenticate(PClient *Client, PInfoState *State, const u8 *Packet, int PacketSize) -{ - int returnval = 0; - // ReturnValue values: - // 0: No error - // -1: Wrong/Unknown username - // -2: Wrong Password - // -3: Malformed Auth Data. Please relog - // -4: Database error, contact admin - // -5: No such account, Account created. Please relog - // -6: Could not create autoaccount, PW too short - // -7: Could not create autoaccount, Name too short - // -8: Could not create autoaccount, PW and Name too short - // -9: Duplicate entry for Username! Contact Admin - // -10: User is banned - // -11: Insufficient access rights - // -12: Account is not yet activated (accesslevel = 0) - // -99: General fault. Contact admin - ConnectionTCP *Socket = Client->getTCPConn(); - PAccount* currentAccount = NULL; - - if(PacketSize > 20 && *(u16*)&Packet[3]==0x8084) - { - const u8 *Key = &Packet[5]; // password key - u16 ULen = *(u16*)&Packet[16]; // username length - u16 PLen = *(u16*)&Packet[18]; // password length - char *UserName = (char*)&Packet[20]; // account name - const u8 *PW = &Packet[20+ULen]; // encoded password - - if(UserName[ULen-1]) // Check that string is well terminated - { - Console->Print("Infoserver: Client [%d]: Username was not NULL-terminated !", Client->GetIndex()); - returnval = -1; - } - else - { - currentAccount = new PAccount(UserName); - if(!currentAccount->GetID()) - { - if(Config->GetOptionInt("auto_accounts")) // Autoaccount - { - delete currentAccount; - currentAccount = new PAccount(); - - if(!currentAccount->SetName(UserName)) // !!! len - { - returnval = -7; - } - if(!currentAccount->SetPasswordEncoded(PW, PLen, Key)) - { - returnval = returnval ? -8 : -6; - } - - if(!returnval) - { - if(currentAccount->Create()) - { - returnval = -5; - } - else - { - returnval = -4; - } - } - } - else - { - returnval = -1; - } - } - else - { - if(currentAccount->Authenticate(PW, PLen, Key)) - { // Username & Password correct - if(currentAccount->IsBanned()) - { - returnval = -10; - } - else if(currentAccount->GetLevel() < Config->GetOptionInt("minlevel")) // insufficient access rights - { - returnval = -11; - } - else if(Config->GetOptionInt("require_validation") == 1 && currentAccount->GetLevel() == PAL_UNREGPLAYER) - { - returnval = -12; - } - else - { - Client->setAccountID(currentAccount->GetID()); - returnval = 0; - } - - } - else - { - returnval = -2; - } - } - } - - bool Failed = false; - if(returnval == 0) - { - u8 AUTHOK[28]={0xfe, 0x19, 0x00, 0x83, 0x81, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00 }; - *(u32*)&AUTHOK[5] = currentAccount->GetID(); - Socket->write(AUTHOK, 28); - State->mState = PInfoState::IS_SERVERLIST; - } - else - { - Console->Print("Infoserver: User '%s': authentication failed. Errorcode %d", UserName, returnval); - Failed = true; // auth failed - } - if(Failed == true) - { - std::string errorReason; - switch(returnval) - { - // It seems that the client cuts the line off after 40 chars... -// |1 |10 |20 |30 |40 |50 |60 |70 |80 - case -99: - { - //errorReason = "General fault in processing your login request"; - errorReason = "General fault while login request"; - break; - } - case -12: - { - //errorReason = "Account not activated. Please check your EMails"; - errorReason = "Error: Your account is not activated"; - break; - } - case -11: - { - //errorReason = "Login rejected. You have to be " + GetAccessString(Config->GetOptionInt("minlevel")) + " or higher"; - errorReason = "Level " + GetAccessString(Config->GetOptionInt("minlevel")) + " or higher required"; - break; - } - case -10: - { - errorReason = "You are banned for " + currentAccount->GetBannedTime(); - break; - } - case -9: - { - //errorReason = "Duplicate entry for this login. Contact Admin"; - errorReason = "Duplicate entry found. Contact Admin"; - break; - } - case -8: - { - //errorReason = "Autoaccount failed, name and password too short"; - errorReason = "AutoAcc failed, name and pwd too short"; - break; - } - case -7: - { - errorReason = "Autoaccount failed, name is too short"; - break; - } - case -6: - { - //errorReason = "Autoaccount failed, password is too short"; - errorReason = "Autoaccount failed, pwd is too short"; - break; - } - case -5: - { - errorReason = "New Account created, please login again"; - break; - } - case -4: - { - errorReason = "Database error, contact Administrator"; - break; - } - case -3: - { - errorReason = "Malformed AuthData. Please login again"; - break; - } - case -2: - { - errorReason = "Wrong password"; - break; - } - case -1: - { - errorReason = "Unknown username"; - break; - } - } - u8 AUTHFAILED_HEADER[] = {0xfe, 0x0c, 0x00, 0x83, 0x86, 0x05, 0x00, 0x06, 0x00}; - u8 AUTHFAILED_FOOTER[] = {0x00, 0x40}; - *(u16*)&AUTHFAILED_HEADER[1] = errorReason.size() + 8; - *(u16*)&AUTHFAILED_HEADER[7] = errorReason.size() + 1; - //*(u8*)&AUTHFAILED_FOOTER[1] = {0x40}; - - Socket->write(AUTHFAILED_HEADER, sizeof(AUTHFAILED_HEADER)); - Socket->write(errorReason.c_str(), errorReason.size()); - Socket->write(AUTHFAILED_FOOTER, sizeof(AUTHFAILED_FOOTER)); - FinalizeClientDelayed(Client, State); - State->mState=PInfoState::IS_UNKNOWN; - } - } - else - { - Console->Print(RED, BLACK, "Infoserver protocol error (IS_AUTHENTICATE): invalid packet [%04x]", *(u16*)&Packet[3]); - return false; - } - - return true; -} - -bool PInfoServer::HandleServerList(PClient *Client, const u8 *Packet, int PacketSize) -{ - u8 SERVERLIST_HEAD[] = {0xfe, 0x00, 0x00, 0x83, 0x83, 0x01, 0x00, 0x0d, 0x00}; - u8 SERVERLIST[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - u8 SERVERLIST_FOOTER[] = {0x00}; - - ConnectionTCP *Socket = Client->getTCPConn(); - - u32 tID = *(u32*)&Packet[5]; - PAccount* currentAccount = new PAccount(Client->getAccountID()); - u32 aID = currentAccount->GetID(); - - if(!aID || (aID != tID)) - { - Console->Print("%s invalid userID %d (auth with id %d)", Console->ColorText(YELLOW, BLACK, "Warning:"), tID, aID); - delete currentAccount; - return false; - } - - if(currentAccount->GetLevel() < Config->GetOptionInt("minlevel")) - { - Console->Print("%s someone tried to bypass the login process! UserID %d", Console->ColorText(RED, BLACK, "Warning:"), aID); - delete currentAccount; - return false; - } - - if(PacketSize == 31 && *(u16*)&Packet[3]==0x8284) - { - GSLiveCheck(); // Perform livecheck to have up-to-date data - - int len = 0; - int num = 0; - for(ServerMap::iterator it = Serverlist.begin(); it != Serverlist.end(); it++) - { - num++; - len += 14 + strlen(it->second.mName); - } - - *(u16*)&SERVERLIST_HEAD[1] = len; - *(u8*)&SERVERLIST_HEAD[5] = num; - Socket->write(SERVERLIST_HEAD, sizeof(SERVERLIST_HEAD)); - - for(ServerMap::iterator it = Serverlist.begin(); it != Serverlist.end(); it++) - { - /* Prepared for future addon Servers by Accesslevel */ -// if(accesslevel >= it->second.mMinLv) -// { - /* ------------------------------------------------ */ - // Todo: Set correct lan/wan IP here! - *(u32*)&SERVERLIST[0] = it->second.mLanIp; - *(u16*)&SERVERLIST[4] = it->second.mPort; - *(u8*)&SERVERLIST[8] = strlen(it->second.mName) + 1; - *(u16*)&SERVERLIST[9] = it->second.mPlayers; - if(it->second.mOnline == true) - { - Console->Print("Sending server name: %s ip: %s player: %d port: %d online: yes", it->second.mName, IPlongToString(it->second.mLanIp), it->second.mPlayers, it->second.mPort); - *(u16*)&SERVERLIST[11] = 1; - } - else if(it->second.mOnline == false) - { - Console->Print("Sending server name: %s ip: %s player: %d port: %d online: no", it->second.mName, IPlongToString(it->second.mLanIp), it->second.mPlayers, it->second.mPort); - *(u16*)&SERVERLIST[11] = 0; - } - Socket->write(SERVERLIST, sizeof(SERVERLIST)); - Socket->write(it->second.mName, strlen(it->second.mName)); - Socket->write(SERVERLIST_FOOTER, sizeof(SERVERLIST_FOOTER)); - /* Prepared for future addon Servers by Accesslevel */ -// } - /* ------------------------------------------------ */ - } - } - else - { - Console->Print(RED, BLACK, "Infoserver protocol error (IS_SERVERLIST): invalid packet [%04x]", *(u16*)&Packet[3]); - delete currentAccount; - return false; - } - delete currentAccount; - return true; -} - -bool PInfoServer::ProcessClient(PClient *Client, PInfoState *State) -{ - static const u8 HANDSHAKE0A[6]={0xfe, 0x03, 0x00, 0x80, 0x01, 0x66}; - - if(!State) - { - InfoStateMap::iterator node = ClientStates.find(Client); - if(node == ClientStates.end()) - return false; - - State = node->second; - } - - ConnectionTCP *Socket = Client->getTCPConn(); - - if(State->mWaitSend && Socket->getSendBufferSize()==0) - return false; - - if(State->mState==PInfoState::IS_CONNECTED) - { - Socket->write(HANDSHAKE0A, 6); - State->mState = PInfoState::IS_HANDSHAKE0; - } - - int PacketSize=0; - const u8 *Packet = Socket->read(&PacketSize); - if(PacketSize > 0) - { - switch(State->mState) - { - case PInfoState::IS_HANDSHAKE0: - return HandleHandshake(State, Packet, PacketSize); - - case PInfoState::IS_AUTHENTICATE: - return HandleAuthenticate(Client, State, Packet, PacketSize); - - case PInfoState::IS_SERVERLIST: - return HandleServerList(Client, Packet, PacketSize); - default: - break; - } - } - return true; -} - -void PInfoServer::FinalizeClient(PClient *Client, PInfoState *State) -{ - Console->Print(RED, BLACK, "Infoserver: client %s disconnected", Client->GetAddress()); - Client->InfoDisconnect(); - ClientStates.erase(Client); - delete State; -} - -void PInfoServer::FinalizeClientDelayed(PClient *Client, PInfoState *State) -{ - Console->Print("Infoserver: client %i is about to be disconnected", Client->GetIndex()); - State->mWaitSend = true; -} diff --git a/server/src/info/infoserver.h b/server/src/info/infoserver.h deleted file mode 100644 index 8cab98c..0000000 --- a/server/src/info/infoserver.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -#ifndef INFOSERVER_H -#define INFOSERVER_H - -#ifdef _MSC_VER - #pragma once -#endif - -#define MAX_SERVER_NAME_LENGTH 45 -struct GameServers -{ - char mName[MAX_SERVER_NAME_LENGTH]; - unsigned int mLanIp; - unsigned int mWanIp; - short mPort; - int mPlayers; - bool mOnline; - bool mUpdated; - long mLasttimestamp; -/* Prepared for future addon Servers by Accesslevel */ -// int mMinLv; -/* ------------------------------------------------ */ -}; - -class PInfoServer -{ - private : - // SQL layout - enum { - s_id, - s_name, - s_wanaddr, - s_port, - s_players, - s_lastupdate, - s_lanaddr, - s_timecheck // computed field, not in table ! - }; - //int mNumClients; - typedef std::map InfoStateMap; - InfoStateMap ClientStates; - - typedef std::map ServerMap; - ServerMap Serverlist; - - //time_t mLastLivecheck; - int mLivecheckInterval; - void GSLiveCheck(); - - protected : - bool ProcessClient(PClient *Client, PInfoState *State=NULL); - void FinalizeClient(PClient *Client, PInfoState *State); - void FinalizeClientDelayed(PClient *Client, PInfoState *State); - - bool HandleHandshake(PInfoState *State, const u8 *Packet, int PacketSize); - bool HandleAuthenticate(PClient *Client, PInfoState *State, const u8 *Packet, int PacketSize); - bool HandleServerList(PClient *Client, const u8 *Packet, int PacketSize); - public : - PInfoServer(); - ~PInfoServer(); - - void Start(); - void Update(); - void ClientDisconnected(PClient *Client); -}; - -#endif diff --git a/server/src/info/main.cpp b/server/src/info/main.cpp deleted file mode 100644 index 8ad0528..0000000 --- a/server/src/info/main.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - MODIFIED: 01 Jul 2006 hammag - REASON: - commented out sched_yield() in main loop, as it is - not needed anymore with a right timeout for ReadSetTCP select - -*/ - -#include "main.h" - -void signal_handler(int signal) -{ - if (signal == SIGINT) - { - Shutdown(); - } -} - -int main() -{ - signal(SIGINT, signal_handler); - - if(!Init()) - { - if(Console) - Console->Print("%s Aborting startup.", Console->ColorText(RED, BLACK, "[Fatal]")); - Shutdown(); // exits with 0 ... - } - - InfoServer->Start(); - Console->Print("Infoserver is now %s. Waiting for clients...", Console->ColorText(GREEN, BLACK, "Online")); - - while(1) - { - ServerSock->update(); - Server->Update(); - InfoServer->Update(); - MySQL->Update(); // MySQL keepalive - Console->Update(); - } - - return 0; -} diff --git a/server/src/info/main.h b/server/src/info/main.h deleted file mode 100644 index ebceffa..0000000 --- a/server/src/info/main.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - MODIFIED: 06 Jul 2006 Hammag - REASON: - moved include "types.h" before include "../netcode/main.h" to enable compile - MODIFIED: 27 Aug 2006 Hammag - REASON: - replaced MAX_INFO_CLIENTS define by config setting - - removed INFO_PORT define not used anymore - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - - -#ifndef MAIN_H -#define MAIN_H - -//#include "version.h" - -//basic includes -#include "include/external.h" - -//tinns includes -#include "include/types.h" -#include "common/netcode.h" - -// MySQL Support -#ifdef MYSQL_INC_DIR -#include -#else -#include -#endif - -#include "sql.h" -#include "common/console.h" -#include "common/config.h" -#include "accounts.h" -#include "client.h" -#include "server.h" -#include "infoserver.h" -#include "common/misc.h" -#include "globals.h" - -#endif diff --git a/server/src/info/server.cpp b/server/src/info/server.cpp deleted file mode 100644 index fba8060..0000000 --- a/server/src/info/server.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - - MODIFIED: 27 Aug 2005 Hammag - REASON: - Use mMaxClient member instead of MAX_INFO_CLIENTS define - -*/ - -#include "main.h" - -PServer::PServer() -{ - mMaxClients = Config->GetOptionInt("maxclients"); - - mClients.reserve(mMaxClients); - mNumClients = 0; - for(int i=0; i= mMaxClients) - return 0; - - return mClients[Client]; -} - -void PServer::Update() -{ - for(int i=0; iUpdate(); - if(mClients[i]->GetConnection()==PCC_NONE && mClients[i]->getTCPConn() == 0) - { - Console->Print("Removing client ..."); - delete mClients[i]; - mClients[i]=0; - --mNumClients; - } - } - } -} - -void PServer::Shutdown() -{ - Console->Print("======================"); - Console->Print("Shutting down Infoserver..."); - for(int i=0; i - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - server.h - - MODIFIED: 25 Dec 2005 Namikon - REASON: - Added GPL - MODIFIED: 27 Aug 2005 Hammag - REASON: - Added mMaxClient member -*/ - -#ifndef SERVER_H -#define SERVER_H - -#ifdef _MSC_VER - #pragma once -#endif - -class PServer -{ - private : - int mMaxClients; - int mNumClients; - std::vector mClients; - protected : - public : - PServer(); - ~PServer(); - - inline int GetNumClients() const { return mNumClients; } - int NewClient(); - PClient *GetClient(int Client) const; - void Update(); - void Shutdown(); -}; - -#endif - diff --git a/server/src/info/sql.h b/server/src/info/sql.h deleted file mode 100644 index 319f3f2..0000000 --- a/server/src/info/sql.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -#ifndef SQL_H -#define SQL_H - -#ifdef _MSC_VER - #pragma once -#endif - -class PMySQL -{ - private: - int port; - char host[100]; - char userName[100]; - char password[100]; - char database[100]; - MYSQL *dbHandle; - std::time_t mKeepaliveDelay; - std::time_t mLastKeepaliveSent; - - public: - PMySQL(); - ~PMySQL(); - - void Update(); - inline MYSQL *GetHandle() { return dbHandle; }; - - bool Connect(); - int Query(const char *query); - MYSQL_RES *ResQuery(const char *query); - void ShowSQLError(); - void FreeSQLResult(MYSQL_RES *res); - inline u32 GetLastInsertId() { return mysql_insert_id(dbHandle); }; - - u32 EscapeString(const char* nText, char* dText, u32 dMaxLength); -}; -#endif diff --git a/server/src/patch/CMakeLists.txt b/server/src/patch/CMakeLists.txt deleted file mode 100644 index 3154f2b..0000000 --- a/server/src/patch/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -ADD_EXECUTABLE (patchserver client.cpp globals.cpp patchserver.cpp main.cpp server.cpp) -TARGET_LINK_LIBRARIES (patchserver common ${PCRE_LIBRARY} ${ZLIB_LIBRARY}) diff --git a/server/src/patch/client.cpp b/server/src/patch/client.cpp deleted file mode 100644 index cf4691b..0000000 --- a/server/src/patch/client.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -#include "main.h" - -PClient::PClient(int Index) -{ - mIndex = Index; - mConnection = PCC_NONE; -} - -PClient::~PClient() -{ - if(m_TCPConnection) - { - delete m_TCPConnection; - } -} - -void PClient::Update() -{ - if(m_TCPConnection) - { - if(m_TCPConnection->timeOut()) - { - Console->Print("Patchsocket: Client %i: timeout", mIndex); - PatchServer->ClientDisconnected(this); - } - else - { - if(!m_TCPConnection->update()) - { - PatchServer->ClientDisconnected(this); - } - } - } -} - -void PClient::PatchDisconnect() -{ - if(m_TCPConnection) - { - delete m_TCPConnection; - } - mConnection = PCC_NONE; - m_TCPConnection = 0; -} diff --git a/server/src/patch/client.h b/server/src/patch/client.h deleted file mode 100644 index 0eeb1c6..0000000 --- a/server/src/patch/client.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -#ifndef CLIENT_H -#define CLIENT_H - -enum PClientConnection -{ - PCC_NONE = 0, - PCC_PATCH = 1 -}; -class PClient -{ - private : - ConnectionTCP* m_TCPConnection; - int mIndex; - int mConnection; - - - protected : - public : - PClient(int Index); - ~PClient(); - - inline int GetIndex() const { return mIndex; } - - inline int GetConnection() const { return mConnection; } - inline const char *GetAddress() const { return m_TCPConnection->getRemoteAddress(); } - - void setTCPConnection(ConnectionTCP* conn) { m_TCPConnection = conn; mConnection = PCC_PATCH; } - - inline ConnectionTCP* getTCPConn() { return m_TCPConnection; } - - void Update(); - - void PatchDisconnect(); -}; - -#endif - diff --git a/server/src/patch/configtemplate.h b/server/src/patch/configtemplate.h deleted file mode 100644 index daeac00..0000000 --- a/server/src/patch/configtemplate.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/* - Configuration template for patchserver - Used to set available/optional/required options when loading config - with a PConfig object. -*/ - -const char* PatchConfigTemplate[][2] = { - // {option_name, default_value} if default_value is empty string, it means option is mandatory - // List ends with empty string for option_name - {"server_version", "200"}, - {"patchserver_port", "8040"}, - {"patches_path", "./patches"}, - {"file_path", "./files"}, - {"max_file_xfers", "5"}, - {"patch_packet_size", "512"}, - {"maxclients", "5"}, - {"gm_slots", "2"}, - - {"", ""} // do not change this line (end mark) -}; diff --git a/server/src/patch/globals.cpp b/server/src/patch/globals.cpp deleted file mode 100644 index 94b5ade..0000000 --- a/server/src/patch/globals.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - MODIFIED: 27 Aug 2006 Hammag - REASON: - Implemented shared Config class use and config template to load conf. - - Added gameserver configtemplate.h include, - - Added new required parameters to Config->LoadOptions() - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem - - TODO: - Get logfile name from config file -*/ - - -#include "main.h" - -#include "configtemplate.h" - -#include "include/version.h" - - -const char ServerVersion[] = TINNS_PATCH_VERSION; -const char SVNRevision[] = TINNS_SVN_REVISION; - -ServerSocket* ServerSock = 0; -PConsole *Console = 0; -PServer *Server = 0; -PConfig *Config = 0; -PFileSystem *Filesystem = 0; -PPatchServer *PatchServer = 0; - -bool InitTinNS() -{ - Console = new PConsole("log/patchserver.log"); // Make that from config file !!! - Console->Print("Starting TinNS Patchserver..."); - Console->Print(WHITE, BLUE, "/-------------------------------------------------------------------\\"); - Console->Print(WHITE, BLUE, "| TinNS (TinNS is not a Neocron Server) |"); - Console->Print(WHITE, BLUE, "| Copyright (C) 2005 Linux Addicted Community |"); - Console->Print(WHITE, BLUE, "| maintainer Akiko |"); - Console->Print(WHITE, BLUE, "| ========================================== |"); - Console->Print(WHITE, BLUE, "| Head coders: The packet analyzing team: |"); - Console->Print(WHITE, BLUE, "| - Akiko - MaxxJag |"); - Console->Print(WHITE, BLUE, "| - bakkdoor - Sting |"); - Console->Print(WHITE, BLUE, "| - Namikon - Balm |"); - Console->Print(WHITE, BLUE, "| - Hammag |"); - Console->Print(WHITE, BLUE, "|-------------------------------------------------------------------|"); - Console->Print(WHITE, BLUE, "| This project would'nt be at its current stage without the help |"); - Console->Print(WHITE, BLUE, "| from the NeoPolis team, special thanks to you guys! |"); - Console->Print(WHITE, BLUE, "|-------------------------------------------------------------------|"); - Console->Print(WHITE, BLUE, "| This project is under GPL, see any source file for more details |"); - Console->Print(WHITE, BLUE, "\\-------------------------------------------------------------------/"); - - //char svnrev[10]; - //GetSVNRev(svnrev); - Console->LPrint("You are running TinNS Patchserver version"); - Console->LPrint(GREEN, BLACK, " %s", ServerVersion); - Console->LPrint(WHITE, BLACK, " - SVN Rev"); - Console->LPrint(GREEN, BLACK, " %s", SVNRevision); - Console->LClose(); - - Config = new PConfig(); - if(!Config->LoadOptions(PatchConfigTemplate ,"./conf/patchserver.conf")) - Shutdown(); - - ServerSock = new ServerSocket(); - Server = new PServer(); - PatchServer = new PPatchServer(); - - return true; -} - -void Shutdown() -{ - if(PatchServer) delete PatchServer; - if(Config) delete Config; - if(Console) delete Console; - if(ServerSock) delete ServerSock; - exit(0); -} - diff --git a/server/src/patch/globals.h b/server/src/patch/globals.h deleted file mode 100644 index bb5eb16..0000000 --- a/server/src/patch/globals.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -#ifndef GLOBALS_H -#define GLOBALS_H - -extern class ServerSocket* ServerSock; -extern class PConsole *Console; -extern class PConfig *Config; -extern class PFileSystem *Filesystem; -extern class PServer *Server; -extern class PPatchServer *PatchServer; - -extern const char ServerVersion[]; -extern const char SVNRevision[]; - -bool InitTinNS(); -void Shutdown(); - -#endif - diff --git a/server/src/patch/main.cpp b/server/src/patch/main.cpp deleted file mode 100644 index b2c7e80..0000000 --- a/server/src/patch/main.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - - - MODIFIED: 01 Jul 2006 hammag - REASON: - commented out sched_yield() in main loop, as it is - not needed anymore with a right timeout for ReadSetTCP select - -*/ -#include "main.h" - -// for handling strg-c signal to shutdown in correct way -void signal_handler(int signal) -{ - if (signal == SIGINT) - { - Shutdown(); - } - else - { - psignal(signal, "Unkown signal: "); - } -} - -int main() -{ - // Connect signal with handlerfunction - signal(SIGINT, signal_handler); - - - if(!InitTinNS()) - while(1) - sleep(1); - - PatchServer->Start(); - Console->Print("Patchserver is now %s. Waiting for clients...", Console->ColorText(GREEN, BLACK, "Online")); - - while(1) - { - ServerSock->update(); - Server->Update(); - PatchServer->Update(); - // sched_yield(); - } - - - return 0; -} - diff --git a/server/src/patch/main.h b/server/src/patch/main.h deleted file mode 100644 index 2628a17..0000000 --- a/server/src/patch/main.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - -/* - MODIFIED: 06 Jul 2006 Hammag - REASON: - moved include "types.h" before include "../netcode/main.h" to permit compile - MODIFIED: 10 Jun 2009 Akiko - REASON: - adjusted includes for new buildsystem -*/ - -#ifndef MAIN_H -#define MAIN_H - -//#include "version.h" - -#define PATCH_PORT 7000 -#define MAX_PATCH_CLIENTS 50 - -//basic includes -#include "include/external.h" - -//tinns includes -#include "include/types.h" -#include "common/netcode.h" - -#include "common/console.h" -#include "common/config.h" -#include "common/filesystem.h" -#include "client.h" -#include "server.h" -#include "patchserver.h" -#include "common/misc.h" -#include "globals.h" - -#endif - diff --git a/server/src/patch/patchserver.h b/server/src/patch/patchserver.h deleted file mode 100644 index 790da48..0000000 --- a/server/src/patch/patchserver.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -#ifndef PATCHSERVER_H -#define PATCHSERVER_H - -#ifdef _MSC_VER - #pragma once -#endif - -class PPatchServer -{ - private : - int mNumClients; - int mNumFileTransfers; - typedef std::map PatchStateMap; - PatchStateMap ClientStates; - protected : - bool ProcessClient(PClient *Client, PPatchState *State=0); -// u32 StartPatch(PClient *Client, PPatchState *State); - u32 StartPatch(PPatchState *State); - bool SendPatchData(PClient *Client, PPatchState *State) const; -// u32 StartFile(PClient *Client, PPatchState *State); - u32 StartFile(PPatchState *State); - bool SendFileData(PClient *Client, PPatchState *State) const; - void FinalizeClient(PClient *Client, PPatchState *State); - void FinalizeClientDelayed(PClient *Client, PPatchState *State); - - bool HandleHandshake(PClient *Client, PPatchState *State, const u8 *Packet, int PacketSize); - bool HandleVersionRequest(PClient *Client, PPatchState *State, const u8 *Packet, int PacketSize); - bool HandleFileRequests(PClient *Client, PPatchState *State, const u8 *Packet, int PacketSize); - public : - PPatchServer(); - ~PPatchServer(); - - void Start(); - void Update(); - void ClientDisconnected(PClient *Client); -}; - -#endif - diff --git a/server/src/patch/server.cpp b/server/src/patch/server.cpp deleted file mode 100644 index 8337b01..0000000 --- a/server/src/patch/server.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - Copyright (C) 2005 Linux Addicted Community - maintainer Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -#include "main.h" - -PServer::PServer() -{ - mNumClients = 0; - mMaxClients = Config->GetOptionInt("maxclients"); - mGMSlots = Config->GetOptionInt("gm_slots"); - - if(mMaxClients==0) - mMaxClients=1; - if(mGMSlots==0) - mGMSlots=1; - mClients.reserve(mMaxClients + mGMSlots); - for(int i=0; iPrint("%d %d", mMaxClients, mGMSlots); - if(mNumClients==mMaxClients+mGMSlots) - return -1; - for(int i=0; i= mMaxClients+mGMSlots) - return 0; - - return mClients[Client]; -} - -void PServer::Update() -{ - for(int i=0; iUpdate(); - if(mClients[i]->GetConnection()==PCC_NONE && mClients[i]->getTCPConn() == 0) - { - Console->Print("Removing client ..."); - delete mClients[i]; - mClients[i]=0; - --mNumClients; - } - } - } -} - -void PServer::Shutdown() -{ - Console->Print("======================"); - Console->Print("Shutting down Patchserver..."); - for(int i=0; i - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -#ifndef SERVER_H -#define SERVER_H - -class PServer -{ - private : - int mMaxClients; - int mGMSlots; - int mNumClients; - std::vector mClients; - protected : - public : - PServer(); - ~PServer(); - - inline int GetMaxClients() const { return mMaxClients; } - inline int GetGMSlots() const { return mGMSlots; } - inline int GetNumClients() const { return mNumClients; } - int NewClient(); - PClient *GetClient(int Client) const; - void Update(); - void Shutdown(); -}; - -#endif - diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt deleted file mode 100644 index 8a99738..0000000 --- a/tools/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -ADD_SUBDIRECTORY (pak_decompress) -ADD_SUBDIRECTORY (vfs_viewer) diff --git a/tools/pak_decompress/CMakeLists.txt b/tools/pak_decompress/CMakeLists.txt deleted file mode 100644 index b3f2c76..0000000 --- a/tools/pak_decompress/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -ADD_EXECUTABLE (pak_decompress pak_decompress.cpp) -TARGET_LINK_LIBRARIES (pak_decompress ${ZLIB_LIBRARY}) diff --git a/tools/pak_decompress/pak_decompress.cpp b/tools/pak_decompress/pak_decompress.cpp deleted file mode 100644 index d5e7738..0000000 --- a/tools/pak_decompress/pak_decompress.cpp +++ /dev/null @@ -1,238 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - pak_decompress - pak file decompression tool - Copyright (C) 2005 Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - pak_decompress - a decompression tool for single pak files - - MODIFIED: 23 Sep 2005 Akiko - REASON: - started this tool - MODIFIED: 26 Sep 2005 Akiko - REASON: - added printing of some information - MODIFIED: 26 Oct 2005 Akiko - REASON: - fixed an issue belonging to portability - MODIFIED: 06 Dec 2005 Akiko - REASON: - compression ration fixed - MODIFIED: 09 Dec 2005 Akiko - REASON: - fixed typo - - compression ratio - MODIFIED: 21 Dec 2006 Namikon - REASON: - Added errorcheck for in/output file - - Added check for NC and normal zLib files - MODIFIED: 15 Jun 2009 Akiko - REASON: - fixed warning - - TODO: - time needed for decompression - - ideas for a compression tool -*/ - -#include -#include -#include -#include -#include -#include - -#define CHUNK 262144 - -int inf(FILE *source, FILE *dest, bool details) -{ - int ret; - char check; - unsigned have; - z_stream strm; - unsigned char in[CHUNK]; - unsigned char out[CHUNK]; - - strm.zalloc = Z_NULL; - strm.zfree = Z_NULL; - strm.opaque = Z_NULL; - strm.avail_in = 0; - strm.next_in = Z_NULL; - ret = inflateInit(&strm); - - if (ret != Z_OK) - return(ret); - - check = fgetc(source); - if(check == 'x') - { - if(details == true) std::cout << "Found zLibfile" << std::endl; - fseek(source, 0, SEEK_SET); - } - else - { - fseek(source, 16, SEEK_SET); - check = fgetc(source); - if(check == 'x') - { - if(details == true) std::cout << "Found Neocron file" << std::endl; - fseek(source, 16, SEEK_SET); - } - else - { - if(details == true) std::cout << "Error: No compatible file!" << std::endl; - return -3; - } - } - - do { - strm.avail_in = fread(in, 1, CHUNK, source); - - if (ferror(source)) { - (void)inflateEnd(&strm); - - return(Z_ERRNO); - } - - if (strm.avail_in == 0) - break; - strm.next_in = in; - - do { - strm.avail_out = CHUNK; - strm.next_out = out; - ret = inflate(&strm, Z_NO_FLUSH); - assert(ret != Z_STREAM_ERROR); - - switch(ret) { - case Z_NEED_DICT: - ret = Z_DATA_ERROR; - case Z_DATA_ERROR: - case Z_MEM_ERROR: - (void)inflateEnd(&strm); - return(ret); - } - - have = CHUNK - strm.avail_out; - - if (fwrite(out, 1, have, dest) != have || ferror(dest)) { - (void)inflateEnd(&strm); - - return(Z_ERRNO); - } - } while (strm.avail_out == 0); - - assert(strm.avail_in == 0); - } while (ret != Z_STREAM_END); - - (void)inflateEnd(&strm); - - return(ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR); -} - -void zerr(int ret) -{ - fputs("zpipe: ", stderr); - - switch(ret) { - case Z_ERRNO: - if (ferror(stdin)) - fputs("error reading stdin\n", stderr); - if (ferror(stdout)) - fputs("error writing stdout\n", stderr); - break; - case Z_STREAM_ERROR: - fputs("invalid compression level\n", stderr); - break; - case Z_DATA_ERROR: - fputs("invalid or incomplete deflate data\n", stderr); - break; - case Z_MEM_ERROR: - fputs("out of memory\n", stderr); - break; - case Z_VERSION_ERROR: - fputs("zlib version mismatch!\n", stderr); - } -} - -int main(int argc, char **argv) { - int ret; - long inSize; - long outSize; - bool details = false; - FILE *inFile; - FILE *outFile; - std::string src; - std::string dst; - - if(argc == 2) { - src = argv[1]; - dst = strcat(argv[1], ".decompressed"); - } - else if(argc > 2 && strcmp(argv[1], argv[2])) { - src = argv[1]; - dst = argv[2]; - } - else { - std::cout << "Usage: pak_decompress source " << std::endl; - return(0); - } - if(argc == 4) - { - if(argv[3][0] == '1') details = true; - else if(argv[3][0] == '0') details = false; - } - - inFile = fopen(src.c_str(), "rb"); - outFile = fopen(dst.c_str(), "wb"); - - if(inFile == NULL) - { - std::cout << "Cannot open InFile" << std::endl; - return(-1); - } - if(outFile == NULL) - { - std::cout << "Cannot open OutFile" << std::endl; - return(-2); - } - ret = inf(inFile, outFile, details); - - /* just to be sure - we got to the end */ - fseek(inFile, 0, SEEK_END); - fseek(outFile, 0, SEEK_END); - inSize = ftell(inFile); - outSize = ftell(outFile); - - fclose(outFile); - fclose(inFile); - - if(ret == Z_OK && details == true) - { - std::cout << "bytes read: " << inSize << std::endl; - std::cout << "bytes written: " << outSize << std::endl; - std::cout << "compression ratio: " << (100-((float)inSize/(float)outSize*100)) << "%" << std::endl; - } - else if(ret == Z_OK && details == false) - { - std::cout << "[OK] " << src.c_str() << std::endl; - } - else if(ret != Z_OK && details == false) - { - std::cout << "[ERROR] " << src.c_str() << std::endl; - } - - return(ret); -} - - diff --git a/tools/pak_decompress/pak_decompress.jar b/tools/pak_decompress/pak_decompress.jar deleted file mode 100644 index 7758c1e..0000000 Binary files a/tools/pak_decompress/pak_decompress.jar and /dev/null differ diff --git a/tools/vfs_viewer/CMakeLists.txt b/tools/vfs_viewer/CMakeLists.txt deleted file mode 100644 index bba6633..0000000 --- a/tools/vfs_viewer/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -ADD_EXECUTABLE (vfs_viewer vfs_viewer.c) -TARGET_LINK_LIBRARIES (vfs_viewer ${ZLIB_LIBRARY}) diff --git a/tools/vfs_viewer/vfs_viewer.c b/tools/vfs_viewer/vfs_viewer.c deleted file mode 100644 index dfb9b04..0000000 --- a/tools/vfs_viewer/vfs_viewer.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - TinNS (TinNS is not a Neocron Server) - vfs_viewer.c - NC virutal file system decompression/browsing tool - Copyright (C) 2005 Akiko - - 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 - of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - - -/* - vfs_viewer.c - - Authors: - - Akiko - - ToDo: - - remove memory leaks, a lot of memory gets reserved but not freed - - adding decompressing - - adding file selection for decompressing - - adding a nice gui (kde/ncurses) - - MODIFIED: 09 Dec 2005 Akiko - REASON: - initial release - - just a output fix -*/ - -#include -#include - -typedef unsigned int u32; -typedef unsigned char u8; - -int main(int argc, char *argv[]) { - // structure of the file informtion inside the virtual FS - struct t_file_header { - u32 id; - u32 offset; - u32 csize; - u32 dsize; - u32 len_name; - u8 *name; - }; - // structure of the virtual FS - struct t_vfs_header { - u32 id; - u32 file_count; - struct t_file_header *files; - u8 *data; - }; - - if (argc == 2) { - FILE *fd; - struct t_vfs_header vfs_file; - - fd = fopen(argv[1], "rb"); - - // reading the vfs header including the amount of files in the virtual FS - fread(&vfs_file.id, sizeof(u32), 1, fd); - fread(&vfs_file.file_count, sizeof(u32), 1, fd); - - struct t_file_header files[vfs_file.file_count]; - - // reading all information from the vfs into an array and print some of them - u32 i; - for (i = 0; i < vfs_file.file_count; i++) { - fread(&files[i].id, sizeof(u32), 1, fd); - fread(&files[i].offset, sizeof(u32), 1, fd); - fread(&files[i].csize, sizeof(u32), 1, fd); - fread(&files[i].dsize, sizeof(u32), 1 ,fd); - fread(&files[i].len_name, sizeof(u32), 1, fd); - - files[i].name = (u8 *)malloc(sizeof(u8)*files[i].len_name); - fread(files[i].name, sizeof(u8), files[i].len_name, fd); - //fseek(fd, files[i].len_name, SEEK_CUR); - - printf("Filenumber %4i: %50s (%7i/%7i) ID-%2i\n", i, files[i].name, files[i].csize, files[i].dsize, files[i].id); - } - - fclose(fd); - } else { - printf("Usage: vfs_viewer \n"); - exit(1); - } - - exit(0); -} -