# 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)
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.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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.
-
- <signature of Ty Coon>, 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.
--- /dev/null
+#!/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
--- /dev/null
+ADD_SUBDIRECTORY (Source)
--- /dev/null
+INCLUDE_DIRECTORIES (${CMAKE_CURRENT_SOURCE_DIR})
+
+ADD_SUBDIRECTORY (Common)
+ADD_SUBDIRECTORY (DevelopmentTools)
+ADD_SUBDIRECTORY (GameServer)
+ADD_SUBDIRECTORY (InfoServer)
+ADD_SUBDIRECTORY (PatchServer)
--- /dev/null
+ADD_LIBRARY (Common Config.cxx Console.cxx FileSystem.cxx Message.cxx Misc.cxx Netcode.cxx RegEx.cxx)
-#include "common/config.h"\r
-\r
#include <cstring>\r
-#include "common/console.h"\r
-#include "common/misc.h"\r
+#include "Common/Includes.hxx"\r
\r
PConfig::PConfig()\r
{\r
\r
bool PConfig::LoadOptions(const char* nConfigTemplate[][2], const char* nConfigFile, int nDepth)\r
{\r
- FILE *ConfigFile;\r
- char line[255];\r
- std::string Opt, Val;\r
- //int numOptions = 0;\r
- int i;\r
- bool Found;\r
- bool NoError = true;\r
- \r
- ConfigFile = fopen(nConfigFile,"r");\r
-\r
- if(!ConfigFile)\r
- {\r
- Console->Print("%s Cant open file \"%s\"", Console->ColorText(RED, BLACK, "[Error]"), nConfigFile);\r
+ FILE *ConfigFile;\r
+ char line[255];\r
+ std::string Opt, Val;\r
+ //int numOptions = 0;\r
+ int i;\r
+ bool Found;\r
+ bool NoError = true;\r
+\r
+ ConfigFile = fopen(nConfigFile,"r");\r
+\r
+ if(!ConfigFile)\r
+ {\r
+ Console->Print("%s Cant open file \"%s\"", Console->ColorText(RED, BLACK, "[Error]"), nConfigFile);\r
return false;\r
- }\r
+ }\r
\r
if(nDepth)\r
Console->Print("%s Including file %s (nesting level %d)", Console->ColorText(GREEN, BLACK, "[Info]"), nConfigFile, nDepth);\r
else\r
- Console->Print("%s Loading configuration file %s", Console->ColorText(GREEN, BLACK, "[Info]"), nConfigFile);\r
- \r
- while(!feof(ConfigFile) && fgets(line, 255, ConfigFile))\r
- {\r
- //Console->Print("LINE: '%s'", line);\r
- if (line[0] == '/' && line[1] == '/')\r
+ Console->Print("%s Loading configuration file %s", Console->ColorText(GREEN, BLACK, "[Info]"), nConfigFile);\r
+\r
+ while(!feof(ConfigFile) && fgets(line, 255, ConfigFile))\r
+ {\r
+ //Console->Print("LINE: '%s'", line);\r
+ if (line[0] == '/' && line[1] == '/')\r
continue;\r
- \r
- if(mOptValRegEx->Search(line))\r
+\r
+ if(mOptValRegEx->Search(line))\r
{\r
Opt = mOptValRegEx->Match(1);\r
Val = mOptValRegEx->Match(2);\r
int BasenamePos = StartName.rfind("/");\r
if(BasenamePos > 0)\r
TargetName = StartName.substr(0, BasenamePos) + "/" + TargetName;\r
- \r
+\r
NoError = LoadOptions(nConfigTemplate, TargetName.c_str(), nDepth+1) && NoError;\r
continue;\r
}\r
}\r
\r
i = 0;\r
- Found = false; \r
+ Found = false;\r
while(!Found && (nConfigTemplate[i][0][0] != '\0'))\r
{\r
if(!strcmp(Opt.c_str(), nConfigTemplate[i++][0]))\r
}\r
}\r
\r
- if(!Opt.empty() && !Val.empty())\r
- {\r
- //Console->Print("#%d [%s] [%s]", numOptions, Opt.c_str(), Val.c_str());\r
- if (Found)\r
- {\r
- if (GetOption(Opt) != "")\r
- {\r
- 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());\r
- }\r
- else\r
- {\r
- //Console->Print(GREEN, BLACK, "New option %s set to %s", Opt.c_str(), Val.c_str());\r
+ if(!Opt.empty() && !Val.empty())\r
+ {\r
+ //Console->Print("#%d [%s] [%s]", numOptions, Opt.c_str(), Val.c_str());\r
+ if (Found)\r
+ {\r
+ if (GetOption(Opt) != "")\r
+ {\r
+ 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());\r
+ }\r
+ else\r
+ {\r
+ //Console->Print(GREEN, BLACK, "New option %s set to %s", Opt.c_str(), Val.c_str());\r
mOptions.insert(std::make_pair(Opt, Val));\r
}\r
}\r
{\r
Console->Print("%s option %s unknow and ignored (value %s)", Console->ColorText(YELLOW, BLACK, "[Warning]"), Opt.c_str(), Val.c_str());\r
}\r
- }\r
- }\r
+ }\r
+ }\r
\r
// Now check for completeness and set default values when needed and available\r
if(!nDepth) // Check only if we're at top level (ie. not in an included file)\r
{\r
- i = 0; \r
+ i = 0;\r
while(nConfigTemplate[i][0][0] != '\0')\r
{\r
if (GetOption(nConfigTemplate[i][0]) == "")\r
\r
if (NoError)\r
{\r
- if(nDepth)\r
- Console->Print("%s file included", Console->ColorText(GREEN, BLACK, "[Info]") );\r
- else\r
+ if(nDepth)\r
+ Console->Print("%s file included", Console->ColorText(GREEN, BLACK, "[Info]") );\r
+ else\r
Console->Print("%s Configuration file loaded", Console->ColorText(GREEN, BLACK, "[Success]") );\r
}\r
else\r
Console->Print(RED, BLACK, "[Error] Fatal errors found in configuration file");\r
- \r
- return (NoError);\r
+\r
+ return (NoError);\r
}\r
\r
const std::string &PConfig::GetOption(const std::string Name) const\r
{\r
- static std::string NullString = "";\r
- OptionsMap::const_iterator i = mOptions.find(Name);\r
- if(i!=mOptions.end())\r
- return i->second;\r
+ static std::string NullString = "";\r
+ OptionsMap::const_iterator i = mOptions.find(Name);\r
+ if(i!=mOptions.end())\r
+ return i->second;\r
\r
- return NullString;\r
+ return NullString;\r
}\r
\r
int PConfig::GetOptionInt(const std::string Name) const\r
{\r
- OptionsMap::const_iterator i = mOptions.find(Name);\r
- if(i!=mOptions.end())\r
- return atoi(i->second.c_str());\r
-\r
- return 0;\r
-}\r
-/* \r
-const std::string &PConfig::GetOption(const char *Name) const\r
-{\r
- static std::string NullString = "";\r
- OptionsMap::const_iterator i = mOptions.find(Name);\r
- if(i!=mOptions.end())\r
- return i->second;\r
-\r
- return NullString;\r
-}\r
-\r
-int PConfig::GetOptionInt(const char *Name) const\r
-{\r
- OptionsMap::const_iterator i = mOptions.find(Name);\r
- if(i!=mOptions.end())\r
- return std::atoi(i->second.c_str());\r
+ OptionsMap::const_iterator i = mOptions.find(Name);\r
+ if(i!=mOptions.end())\r
+ return atoi(i->second.c_str());\r
\r
- return 0;\r
+ return 0;\r
}\r
-*/\r
#pragma once\r
\r
+#include <cstdint>\r
#include <iostream>\r
#include <map>\r
-#include "common/regex++.h"\r
-\r
-class PConfig\r
-{\r
- private :\r
- typedef std::map<std::string, std::string> OptionsMap;\r
- OptionsMap mOptions;\r
- RegEx* mOptValRegEx;\r
- RegEx* mIncludeRegEx;\r
- \r
- bool LoadOptions(const char* nConfigTemplate[][2], const char* nConfigFile, int nDepth);\r
- \r
- public :\r
- PConfig();\r
- ~PConfig();\r
-\r
- inline bool LoadOptions(const char* nConfigTemplate[][2], const char* nConfigFile)\r
- { return LoadOptions(nConfigTemplate, nConfigFile, 0); }\r
- inline const std::string &GetOption(const char *Name) const { return GetOption((std::string) Name); }\r
- const std::string &GetOption(const std::string Name) const;\r
- int GetOptionInt(const char *Name) const { return GetOptionInt((std::string) Name); }\r
- int GetOptionInt(const std::string Name) const;\r
+#include <string>\r
+\r
+class RegEx;\r
+\r
+class PConfig {\r
+private:\r
+ typedef std::map<std::string, std::string> OptionsMap;\r
+ OptionsMap mOptions;\r
+ RegEx *mOptValRegEx;\r
+ RegEx *mIncludeRegEx;\r
+\r
+ bool LoadOptions(const char *nConfigTemplate[][2], const char *nConfigFile, int32_t nDepth);\r
+\r
+public:\r
+ PConfig();\r
+ ~PConfig();\r
+\r
+ inline bool LoadOptions(const char *nConfigTemplate[][2], const char *nConfigFile)\r
+ { return LoadOptions(nConfigTemplate, nConfigFile, 0); }\r
+ inline const std::string &GetOption(const char *Name) const { return GetOption((std::string) Name); }\r
+ const std::string &GetOption(const std::string Name) const;\r
+ int32_t GetOptionInt(const char *Name) const { return GetOptionInt((std::string) Name); }\r
+ int32_t GetOptionInt(const std::string Name) const;\r
};\r
\r
// Max nested includes\r
Unkown options are rejected\r
Duplicates, unkown and default use generate a warning in logs but don't break options loading\r
Missing mandatory option generate an error in log and break option loading (imediate return false)\r
- \r
+\r
The ConfigTemplate parameter must have the structure shown in the following exemple:\r
\r
const char* ConfigTemplate[][2] = {\r
-#include "common/console.h"\r
-\r
+#include <cstdarg>\r
#include <sstream>\r
#include <cstring>\r
-#include <cstdarg>\r
+#include "Common/Includes.hxx"\r
\r
PConsole::PConsole(const char *nLogFile)\r
{\r
#pragma once\r
\r
-#include <iostream>\r
-#include <fstream>\r
#include <chrono>\r
+#include <fstream>\r
\r
-enum COLORS\r
-{\r
+enum COLORS {\r
BLACK,\r
RED,\r
GREEN,\r
-#include "common/filesystem.h"\r
-\r
-#include <sstream>\r
#include <cstring>\r
+#include <sstream>\r
#include <zlib.h>\r
-#include "common/console.h"\r
+#include "Common/Includes.hxx"\r
\r
const int8_t DELIM = '/';\r
\r
#pragma once\r
\r
-#include <iostream>\r
-#include <vector>\r
-#include <string>\r
+#include <cstdint>\r
#include <map>\r
+#include <vector>\r
\r
class PFile {\r
friend class PFileSystem;\r
};\r
\r
#pragma pack(push, 1)\r
-//#pragma pack(1)\r
struct PPakHeader {\r
int mID;\r
int mNumFiles;\r
--- /dev/null
+#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"
-#include "common/message.h"
-
#include <cstring>
-#include "common/console.h"
+#include "Common/Includes.hxx"
const uint16_t PMessage::smMsgSizes[] = {MESSAGE_SIZES_LIST};
PMsgData* PMessage::smMsgPoolHead[] = {MESSAGE_POOL_INIT};
--- /dev/null
+#pragma once
+
+#include <cstdint>
+
+#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 = "");
+};
-#include "common/misc.h"\r
-\r
-#include <cstring>\r
#include <cstdarg>\r
-#include <netinet/in.h>\r
+#include <cstring>\r
#include <arpa/inet.h>\r
-#include "common/console.h"\r
+#include "Common/Includes.hxx"\r
\r
uint32_t IPStringToDWord( const char *IP )\r
{\r
#pragma once\r
\r
-#include <iostream>\r
+#include <cstdint>\r
#include <string>\r
\r
uint32_t IPStringToDWord(const char *IP);\r
char *IPlongToString(const uint32_t IP);\r
-std::string GetAccessString(int level);\r
+std::string GetAccessString(int32_t level);\r
//void GetSVNRev(char *version);\r
\r
-void PrintPacket(uint8_t *Packet, int PacketSize);\r
+void PrintPacket(uint8_t *Packet, int32_t PacketSize);\r
\r
// Cleanup for strings read from .def\r
void CleanUpString(std::string *nString);\r
--- /dev/null
+#pragma once\r
+\r
+#include <pthread.h>\r
+\r
+class Mutex {\r
+private:\r
+ mutable pthread_mutex_t mut;\r
+\r
+ void operator = (Mutex &mut) {}\r
+\r
+ Mutex(const Mutex &mut) {}\r
+\r
+public:\r
+ Mutex()\r
+ {\r
+ pthread_mutexattr_t attr;\r
+ pthread_mutexattr_init(&attr);\r
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);\r
+ pthread_mutex_init(&mut, &attr);\r
+ pthread_mutexattr_destroy(&attr);\r
+ }\r
+\r
+ virtual ~Mutex()\r
+ {\r
+ pthread_mutex_unlock(&mut);\r
+ pthread_mutex_destroy(&mut);\r
+ }\r
+\r
+ int Lock() const\r
+ {\r
+ return (pthread_mutex_lock(&mut));\r
+ }\r
+\r
+ int TryLock() const\r
+ {\r
+ return (pthread_mutex_trylock(&mut));\r
+ }\r
+\r
+ int Unlock() const\r
+ {\r
+ return (pthread_mutex_unlock(&mut));\r
+ }\r
+};\r
-#include "common/netcode.h"
-
#include <cstring>
#include <fcntl.h>
#include <unistd.h>
#include <arpa/inet.h>
-#include "common/console.h"
-#include "common/config.h"
+#include "Common/Includes.hxx"
ConnectionTCP::ConnectionTCP(int sockfd, struct sockaddr_in addr, ServerSocket* server)
{
mServerSocket->delSocketFromSet(mSockfd);
}
close(mSockfd);
-
+
if (mReceiveBufferMsg)
{
delete mReceiveBufferMsg;
}
-
+
while (!mQueueIn.empty())
{
delete mQueueIn.front();
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
{
delete mQueueOut.front();
mQueueOut.pop();
- }
+ }
}
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))
{
{
mReceiveBufferMsg = new PMessage(RECVBUFFERSIZE);
}
-
+
DataSize = mReceiveBufferMsg->GetSize();
numBytes = recv(mSockfd, (char*) mReceiveBufferMsg->GetMessageDataPointer(RECVBUFFERSIZE - DataSize) + DataSize, RECVBUFFERSIZE - DataSize, 0); // get the data
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;
{
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));
{
tmpMsg = NULL;
}
-
+
delete mReceiveBufferMsg;
- mReceiveBufferMsg = tmpMsg;
+ mReceiveBufferMsg = tmpMsg;
}
}
}
{
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 ****/
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()
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");
}
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)
//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)
// 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;
}
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;
}
m_TimeOut.tv_sec = timeout_sec;
m_TimeOut.tv_usec = timeout_usec;
}
-
}
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);
{
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
{
perror("select");
}
-
+
//Select exit condition logging
/*
if ((tmp_TimeOut.tv_sec == 0) && (tmp_TimeOut.tv_usec == 0))
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!!
while (bind(udpSockfd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)) == -1)
{
if (errno == EADDRINUSE)
- {
+ {
my_addr.sin_port = htons(++Port);
if (Port > maxPort)
{
}
}
else
- {
+ {
perror("udp-bind");
return NULL;
}
{
m_FdMaxUDP = udpSockfd;
}
-
+
ConnectionUDP* udpConn = new ConnectionUDP(udpSockfd, Port, remoteadress, remoteport, this);
- //m_LastUDPPort++;
+ //m_LastUDPPort++;
return udpConn;
}
#pragma once
-#include <iostream>
-#include <chrono>
+#include <cstdint>
#include <queue>
-#include <map>
#include <netinet/in.h>
-#include "common/message.h"
#define RECVBUFFERSIZE 4096
#define SENDBUFFERSIZE 4096
class ConnectionTCP;
class ConnectionUDP;
+class PMessage;
class ServerSocket;
class ConnectionTCP {
-#include "common/regex++.h"
-
#include <cstring>
+#include "Common/Includes.hxx"
RegEx::RegEx(const char * regex, int options)
{
--- /dev/null
+#pragma once
+
+#include <cstdint>
+
+#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);
+};
--- /dev/null
+#pragma once
+
+#define TINNS_SVN_REVISION "AKIKO_CMAKE_R3"
+
--- /dev/null
+#pragma once\r
+\r
+#include <semaphore.h>\r
+\r
+class Semaphore {\r
+private:\r
+ sem_t sem;\r
+\r
+public:\r
+ Semaphore(int init = 0)\r
+ {\r
+ sem_init(&sem, 0, init);\r
+ }\r
+\r
+ virtual ~Semaphore()\r
+ {\r
+ sem_destroy(&sem);\r
+ }\r
+\r
+ void Wait() const\r
+ {\r
+ sem_wait((sem_t *)&sem);\r
+ }\r
+\r
+ int TryWait() const\r
+ {\r
+ return (sem_trywait((sem_t *)&sem) ? errno : 0);\r
+ }\r
+\r
+ int Post() const\r
+ {\r
+ return (sem_post((sem_t *)&sem) ? errno : 0);\r
+ }\r
+\r
+ int GetValue() const\r
+ {\r
+ int val = -1;\r
+\r
+ sem_getvalue((sem_t *)&sem, &val);\r
+\r
+ return (val);\r
+ }\r
+\r
+ void Reset(int init = 0)\r
+ {\r
+ sem_destroy(&sem);\r
+ sem_init(&sem, 0, init);\r
+ }\r
+};\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
+#pragma once\r
\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- thread.h - main class of a C++ thread model using the POSIX way\r
-\r
- MODIFIED: 26 Sep 2005 Akiko\r
- REASON: - started the implementaion of a thread model\r
- MODIFIED: 28 Sep 2005 Akiko\r
- REASON: - fixed the issue with gxx 3.4.3 and gcc 4.x\r
-*/\r
-\r
-\r
-#ifndef THREAD_H\r
-#define THREAD_H\r
-\r
-//this class needs mutex.h, semaphore.h and pthread.h, but it should all come\r
-//from tinns.h\r
+#include <mutex.h>\r
+#include <semaphore.h>\r
+#include <pthread.h>\r
\r
#define INVALID_HANDLE 0\r
\r
unsigned char Flags;\r
};\r
};\r
-\r
-/*\r
- implementation without thread parameters\r
-*/\r
-\r
-/*template <>\r
-class Thread<void> {\r
- private:\r
- typedef struct Instance;\r
-\r
- public:\r
- typedef pthread_t Handle;\r
- typedef void (*Handler)();\r
-\r
- protected:\r
- Thread<void>() {\r
- }\r
-\r
- virtual void ThreadMain() = 0;\r
-\r
- static void Exit() {\r
- pthread_exit(0);\r
- }\r
-\r
- static void TextCancel() {\r
- pthread_testcancel();\r
- }\r
-\r
- static Handle Self() {\r
- return((Handle)pthread_self());\r
- }\r
-\r
- public:\r
- static int Create(const Handler &Func, Handle *const &H = 0, const bool &CreateDetached = false,\r
- const unsigned int &StackSize = 0, const bool &CancelEnable = false,\r
- const bool &CancelAsync = false) {\r
- M_Create().Locl();\r
- pthread_attr_t attr;\r
- pthread_attr_init(&attr);\r
-\r
- if(CreateDetached)\r
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);\r
-\r
- if(StackSize)\r
- pthread_attr_setstacksize(&attr, StackSize);\r
-\r
- Instance I(0, Func, CancelEnable, CancelAsync);\r
-\r
- int run = pthread_create((pthread_t *)H, &attr, ThreadMainHandler, (void *)&I);\r
- pthread_attr_destroy(&attr);\r
-\r
- if(!run)\r
- S_Create().Wait();\r
- else if(H)\r
- *H = INVALID_HANDLE;\r
-\r
- M_Create().Unlock();\r
-\r
- return(errno);\r
- } */\r
-\r
-#endif\r
-\r
--- /dev/null
+#pragma once\r
+\r
+#include "Common/SVNrevision.hxx"\r
+\r
+#define TINNS_PATCH_VERSION "0.0.2 Dev"\r
+#define TINNS_INFO_VERSION "0.0.2 Dev"\r
+#define TINNS_GAME_VERSION "0.1.38 Dev"\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- accounts.cpp\r
-\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL\r
- MODIFIED: 26 Dec 2005 Namikon\r
- REASON: - Added SQLLoad to PAccounts. First step in adding MySQL support to accounts\r
- MODIFIED: 01 Jan 2006 Namikon\r
- REASON: - Changed FmtTxt() to sprintf(). It does... uhm, the same :D\r
- MODIFIED: 06 Jan 2006 Namikon\r
- REASON: - Removed the old XML loading functions, and changed the SQL ones to work with the Global Neopolis/TinNS Database\r
- - Added SetBannedStatus(<unix timestamp>) to ban/unban an account (use SetBannedStatus(0) to unban a player)\r
- MODIFIED: 03 Oct 2006 Hammag\r
- REASON: - Fixed an issue in PAccount::SetBannedStatus() that was causing the "can't update banned status" error message.\r
-\r
- MODIFIED: 27 May 2007 Hammag\r
- REASON: - Full changes for on-demand account access (no more memory-resident account data)\r
- MODIFIED: 09 Jun 2009 Akiko\r
- REASON: - adjusted includes for new build system\r
- - clean ups\r
-*/\r
-\r
+#include "GameServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
/*\r
NOTE ABOUT ACCESS LEVELS IN THE MYSQL DATABASE:\r
1 = Online\r
2 = Banned\r
*/\r
-#include "main.h"\r
-#include "include/accounts.h"\r
\r
/** Static members **/\r
RegEx* PAccount::mUsernameRegexFilter = NULL;\r
delete mUsernameRegexFilter;\r
mUsernameRegexFilter = NULL;\r
}\r
- \r
+\r
if(RegexStr)\r
{\r
try {\r
delete mPasswordRegexFilter;\r
mPasswordRegexFilter = NULL;\r
}\r
- \r
+\r
if(RegexStr)\r
{\r
try {\r
return true;\r
}\r
\r
-/** Instance members **/ \r
+/** Instance members **/\r
PAccount::PAccount()\r
{\r
- mID = 0;\r
- mLevel = PAL_BANNED;\r
+ mID = 0;\r
+ mLevel = PAL_BANNED;\r
mStatus = PAS_OFFLINE;\r
mBannedUntil = 0;\r
}\r
\r
-PAccount::PAccount(const u32 AccountId)\r
+PAccount::PAccount(const uint32_t AccountId)\r
{\r
char query[256];\r
mID = 0;\r
{\r
MYSQL_ROW row = 0;\r
MYSQL_RES *result = 0;\r
- \r
+\r
bool FinalResult = false;\r
\r
result = MySQL->InfoResQuery(query);\r
{\r
Console->Print(YELLOW, BLACK, "Failed to load AccountData from SQL; Nothing to load...");\r
}\r
- \r
+\r
MySQL->FreeInfoSQLResult(result);\r
return FinalResult;\r
}\r
}\r
}\r
\r
-bool PAccount::SetPasswordEncoded(const u8* PasswordData, int PassLen, const u8* Key)\r
+bool PAccount::SetPasswordEncoded(const uint8_t* PasswordData, int PassLen, const uint8_t* Key)\r
{\r
- char Pass[128];\r
- \r
- if(DecodePassword(PasswordData, PassLen, Key, Pass))\r
+ char Pass[128];\r
+\r
+ if(DecodePassword(PasswordData, PassLen, Key, Pass))\r
{\r
- return SetPassword((std::string)Pass);\r
- }\r
- else\r
- {\r
- Console->Print(RED, BLACK, "[Error]: user %s : malformed auth data (size=%d)", mName.c_str(), PassLen);\r
- return false;\r
- }\r
+ return SetPassword((std::string)Pass);\r
+ }\r
+ else\r
+ {\r
+ Console->Print(RED, BLACK, "[Error]: user %s : malformed auth data (size=%d)", mName.c_str(), PassLen);\r
+ return false;\r
+ }\r
}\r
\r
bool PAccount::SetLevel(int newLevel)\r
\r
std::string PAccount::GetLevelString() const\r
{\r
- switch(mLevel)\r
- {\r
- case PAL_BANNED : return "banned";\r
- case PAL_UNREGPLAYER : return "unregplayer";\r
- case PAL_REGPLAYER : return "regplayer";\r
- case PAL_VOLUNTEER : return "volunteer";\r
- case PAL_GM : return "gm";\r
- case PAL_ADMIN : return "admin";\r
- }\r
-\r
- return "custom";\r
+ switch(mLevel)\r
+ {\r
+ case PAL_BANNED : return "banned";\r
+ case PAL_UNREGPLAYER : return "unregplayer";\r
+ case PAL_REGPLAYER : return "regplayer";\r
+ case PAL_VOLUNTEER : return "volunteer";\r
+ case PAL_GM : return "gm";\r
+ case PAL_ADMIN : return "admin";\r
+ }\r
+\r
+ return "custom";\r
}\r
\r
bool PAccount::SetStatus(PAccountStatus Status)\r
}\r
}\r
\r
-bool PAccount::DecodePassword(const u8* PasswordData, int PassLen, const u8 *Key, char* ClearPassword)\r
+bool PAccount::DecodePassword(const uint8_t* PasswordData, int PassLen, const uint8_t *Key, char* ClearPassword)\r
{\r
ClearPassword[0] = 0;\r
- \r
+\r
if(PassLen < 128)\r
- {\r
- if(Key[0]>7) // TODO: >7 correct?\r
- {\r
- for(int i=0; i<PassLen; i+=2)\r
- ClearPassword[i>>1] = (char)(((PasswordData[i]&0xf0)>>4)\r
- +((PasswordData[i+1]&0x0f)<<4)-Key[0]);\r
- ClearPassword[PassLen>>1]=0;\r
- }\r
- else\r
- {\r
- for(int i=0; i<PassLen; i++)\r
- ClearPassword[i] = (char)(PasswordData[i]-Key[0]);\r
- ClearPassword[PassLen]=0;\r
- }\r
- return true;\r
- }\r
- else\r
- return false;\r
+ {\r
+ if(Key[0]>7) // TODO: >7 correct?\r
+ {\r
+ for(int i=0; i<PassLen; i+=2)\r
+ ClearPassword[i>>1] = (char)(((PasswordData[i]&0xf0)>>4)\r
+ +((PasswordData[i+1]&0x0f)<<4)-Key[0]);\r
+ ClearPassword[PassLen>>1]=0;\r
+ }\r
+ else\r
+ {\r
+ for(int i=0; i<PassLen; i++)\r
+ ClearPassword[i] = (char)(PasswordData[i]-Key[0]);\r
+ ClearPassword[PassLen]=0;\r
+ }\r
+ return true;\r
+ }\r
+ else\r
+ return false;\r
}\r
\r
-bool PAccount::Authenticate(const u8* PasswordData, int PassLen, const u8 *Key)\r
+bool PAccount::Authenticate(const uint8_t* PasswordData, int PassLen, const uint8_t *Key)\r
{\r
- char Pass[128];\r
- \r
- if(DecodePassword(PasswordData, PassLen, Key, Pass))\r
+ char Pass[128];\r
+\r
+ if(DecodePassword(PasswordData, PassLen, Key, Pass))\r
{\r
- return Authenticate(Pass);\r
- }\r
- else\r
- {\r
- Console->Print(RED, BLACK, "[Error]: user %s : malformed auth data (size=%d)", mName.c_str(), PassLen);\r
- return false;\r
- }\r
+ return Authenticate(Pass);\r
+ }\r
+ else\r
+ {\r
+ Console->Print(RED, BLACK, "[Error]: user %s : malformed auth data (size=%d)", mName.c_str(), PassLen);\r
+ return false;\r
+ }\r
}\r
\r
bool PAccount::Authenticate(const char *Password) const\r
{\r
- if(mID == 0) // User doesn't exist and that hasn't been checked !\r
- {\r
- Console->Print(RED, BLACK, "[Bug]: user %s doesn't exist and was not checked by code !", mName.c_str());\r
- return false;\r
- }\r
- \r
- return(mPassword == Password);\r
+ if(mID == 0) // User doesn't exist and that hasn't been checked !\r
+ {\r
+ Console->Print(RED, BLACK, "[Bug]: user %s doesn't exist and was not checked by code !", mName.c_str());\r
+ return false;\r
+ }\r
+\r
+ return(mPassword == Password);\r
}\r
\r
bool PAccount::Create()\r
char escPassword[256];\r
MySQL->EscapeString(mName.c_str(), escUsername, 256);\r
MySQL->EscapeString(mPassword.c_str(), escPassword, 256);\r
- \r
+\r
std::string Query;\r
Query = CreateMode ? "INSERT INTO" : "UPDATE";\r
Query += "accounts SET ";\r
return true;\r
}\r
\r
-u32 PAccount::GetCharIdBySlot(const u32 SlotId)\r
+uint32_t PAccount::GetCharIdBySlot(const uint32_t SlotId)\r
{\r
char query[256];\r
- u32 CharId = 0;\r
- \r
+ uint32_t CharId = 0;\r
+\r
MYSQL_ROW row = 0;\r
MYSQL_RES *result = 0;\r
- \r
- snprintf(query, 256, "SELECT c_id FROM characters WHERE a_id = %d AND c_slot = %d LIMIT 1;", mID, SlotId); \r
+\r
+ snprintf(query, 256, "SELECT c_id FROM characters WHERE a_id = %d AND c_slot = %d LIMIT 1;", mID, SlotId);\r
\r
result = MySQL->GameResQuery(query);\r
if(result == NULL)\r
{\r
CharId = atoi(row[0]);\r
}\r
- \r
+\r
MySQL->FreeGameSQLResult(result);\r
- \r
+\r
/*** Temporary workaround to cope with DB where c_slot is not set ***/\r
if(!CharId)\r
{\r
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);\r
- \r
+\r
result = MySQL->GameResQuery(query);\r
if(result == NULL)\r
{\r
MySQL->ShowGameSQLError();\r
return 0;\r
}\r
- \r
+\r
if((row = mysql_fetch_row(result)))\r
{\r
CharId = atoi(row[0]);\r
}\r
- \r
- MySQL->FreeGameSQLResult(result); \r
+\r
+ MySQL->FreeGameSQLResult(result);\r
}\r
/*** End of workaround ***/\r
- \r
+\r
return CharId;\r
}\r
\r
std::string PAccount::GetBannedTime() const\r
{\r
const char* unit[5] = {"seconds", "minutes", "hours", "days", "weeks"};\r
- \r
+\r
std::time_t timediff = mBannedUntil - std::time(NULL);\r
if(timediff <=0)\r
{\r
--- /dev/null
+#pragma once\r
+\r
+#include <chrono>\r
+#include <cstdint>\r
+#include <string>\r
+\r
+class RegEx;\r
+\r
+/*\r
+0 = unregistered user\r
+1 = Registered user\r
+30 = volunteer\r
+50 = GM\r
+100 = Admin\r
+*/\r
+\r
+// New way of AccountLevel handling:\r
+// Every level is possible, the following values are only edge values. We need a bit control about that\r
+#define PAL_BANNED -1\r
+#define PAL_UNREGPLAYER 0\r
+#define PAL_REGPLAYER 1\r
+#define PAL_VOLUNTEER 30 // Special Rank: 50/50\r
+#define PAL_GM 50 // Special Rank: 120/120\r
+#define PAL_ADMIN 100 // Special Rank: 127/127\r
+\r
+// Max number of char slots per account\r
+#define MAX_CHARS_PER_ACCOUNT 4\r
+\r
+/*\r
+0 = Offline\r
+1 = Online\r
+2 = Banned\r
+*/\r
+\r
+enum PAccountStatus\r
+{\r
+ PAS_OFFLINE = 0,\r
+ PAS_ONLINE = 1,\r
+ PAS_BANNED = 2\r
+};\r
+\r
+class PAccount {\r
+ private :\r
+ // SQL Layout\r
+ enum {\r
+ a_id,\r
+ a_username,\r
+ a_password,\r
+ a_priv,\r
+ a_status,\r
+ a_bandate\r
+ };\r
+\r
+ // static members\r
+ static RegEx* mUsernameRegexFilter;\r
+ static RegEx* mPasswordRegexFilter;\r
+\r
+ // instance members\r
+ uint32_t mID;\r
+ std::string mName;\r
+ std::string mPassword;\r
+ int mLevel;\r
+ PAccountStatus mStatus;\r
+ time_t mBannedUntil;\r
+\r
+ bool LoadFromQuery(char* query);\r
+ bool DecodePassword(const uint8_t* PasswordData, int PassLen, const uint8_t *Key, char* ClearPassword);\r
+\r
+ public :\r
+ PAccount();\r
+ PAccount(const uint32_t AccountId);\r
+ PAccount(const char *Username);\r
+\r
+ static bool SetUsernameRegexFilter(const char* RegexStr);\r
+ static bool SetPasswordRegexFilter(const char* RegexStr);\r
+ static bool IsUsernameWellFormed(const char *Username);\r
+ static bool IsPasswordWellFormed(const char *Password);\r
+\r
+ inline uint32_t GetID() const { return mID; }\r
+ bool SetName(const std::string &Pass);\r
+ inline const std::string &GetName() const { return mName; }\r
+ bool SetPassword(const std::string &Pass);\r
+ bool SetPasswordEncoded(const uint8_t* PasswordData, int PassLen, const uint8_t *Key);\r
+ inline const std::string &GetPassword() const { return mPassword; }\r
+ bool SetLevel(int newLevel);\r
+ inline int GetLevel() const { return mLevel; }\r
+ std::string GetLevelString() const;\r
+ bool SetStatus(PAccountStatus Status);\r
+ inline PAccountStatus GetStatus() const { return mStatus; }\r
+ bool SetBannedUntilTime(time_t BannedUntil);\r
+ inline bool IsBanned() const { return (mBannedUntil > std::time(NULL)); }\r
+ std::string GetBannedTime() const;\r
+\r
+ bool Authenticate(const uint8_t* PasswordData, int PassLen, const uint8_t *Key);\r
+ bool Authenticate(const char *Password) const;\r
+\r
+ bool Create();\r
+ bool Save(bool CreateMode = false);\r
+\r
+ uint32_t GetCharIdBySlot(const uint32_t SlotId);\r
+};\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- appartements.cpp - appartements class\r
-\r
- MODIFIED: 20 Nov 2006 Hammag\r
- REASON: - creation\r
- MODIFIED: 09 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
-*/\r
-\r
-#include "main.h"\r
-\r
-#include "include/appartements.h"\r
-#include "include/gamedefs.h"\r
-#include "include/def_appartements.h"\r
-#include "include/worlds.h"\r
+#include <cstring>\r
+#include "GameServer/Includes.hxx"\r
+#include "GameServer/Definitions/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
PAppartements::PAppartements()\r
{\r
\r
//PAppartements::~PAppartements() {};\r
\r
-u32 PAppartements::CreateBaseAppartement(u32 nCharID, std::string nPassword, u8 nFactionID)\r
+uint32_t PAppartements::CreateBaseAppartement(uint32_t nCharID, std::string nPassword, uint8_t nFactionID)\r
{\r
typedef std::vector< std::pair<int, int> > PAppVector; //<AppType, AppPlace>\r
- \r
- PAppVector CandidateApts; \r
+\r
+ PAppVector CandidateApts;\r
CandidateApts.reserve(32);\r
- u16 j;\r
+ uint16_t j;\r
int AppType;\r
- \r
+\r
for (std::map<int, PDefAppartement*>::const_iterator i=GameDefs->Appartements()->ConstIteratorBegin(); i!=GameDefs->Appartements()->ConstIteratorEnd(); i++)\r
{\r
if (i->second->GetFaction() == nFactionID)\r
}\r
}\r
}\r
- \r
+\r
if(CandidateApts.size())\r
{\r
j = GetRandom(CandidateApts.size()-1);\r
if (gDevDebug) Console->Print("Apt n� %d chosen in %d for faction %d", j+1, CandidateApts.size(), nFactionID);\r
\r
-if (gDevDebug) Console->Print("Choosed Apt of type %d in place %d", CandidateApts[j].first, CandidateApts[j].second); \r
+if (gDevDebug) Console->Print("Choosed Apt of type %d in place %d", CandidateApts[j].first, CandidateApts[j].second);\r
\r
char escPassword[256];\r
MySQL->EscapeString(nPassword.c_str(), escPassword, 256);\r
return 0;\r
}\r
\r
-void PAppartements::DeleteCharAppartements(u32 nCharID)\r
+void PAppartements::DeleteCharAppartements(uint32_t nCharID)\r
{\r
char query[256];\r
snprintf(query, 256, "DELETE FROM apartments WHERE (apt_owner='%u');", nCharID);\r
if (gDevDebug) Console->Print(YELLOW, BLACK, "PAppartements::DeleteCharAppartements does not delete appartements content yet"); \r
}\r
\r
-bool PAppartements::CanFreelyEnter(PChar* nChar, u32 nLocation)\r
+bool PAppartements::CanFreelyEnter(PChar* nChar, uint32_t nLocation)\r
{\r
- u32 OwnerID = GetAptOwner(nLocation);\r
+ uint32_t OwnerID = GetAptOwner(nLocation);\r
return (OwnerID == nChar->GetID());\r
- \r
+\r
// here we could manage Clan appartements access too.\r
}\r
\r
-int PAppartements::GetAptID(unsigned int AptLoc, const u8 *pass)\r
+int PAppartements::GetAptID(unsigned int AptLoc, const uint8_t *pass)\r
{\r
int type;\r
MYSQL_RES *result;\r
MYSQL_ROW row;\r
char query[255];\r
\r
- if((u32)loc > PWorlds::mAptBaseWorldId)\r
+ if((uint32_t)loc > PWorlds::mAptBaseWorldId)\r
loc = loc - PWorlds::mAptBaseWorldId;\r
\r
snprintf (query, 255, "SELECT apt_location FROM apartments WHERE apt_id = %i", loc);\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include <string>\r
+\r
+class PChar;\r
+\r
+class PAppartements {\r
+public:\r
+ PAppartements();\r
+ //~PAppartements();\r
+\r
+ uint32_t CreateBaseAppartement(uint32_t nCharID, std::string nPassword, uint8_t nFactionID);\r
+ void DeleteCharAppartements(uint32_t nCharID);\r
+ bool CanFreelyEnter(PChar* nChar, uint32_t nLocation);\r
+ int GetAptID(unsigned int AptLoc, const uint8_t *pass);\r
+ int GetAptType(int AptID);\r
+ int GetAptOwner(int loc);\r
+ int GetAptLocation(int loc);\r
+};\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
+#include <cstring>\r
+#include "GameServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- buddylist.cpp - class for chat buddylist\r
-\r
- MODIFIED: 19 Sep 2006 Hammag\r
- REASON: - creation\r
- MODIFIED: 09 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
- - clean ups\r
-\r
- TODO: - link with a online char list, updated when needed (chars in/out, or list modified)\r
-*/\r
-\r
-#include "main.h"\r
-#include "include/buddylist.h"\r
-\r
-PBuddyList::PBuddyList(u32 nOwnerCharID)\r
+PBuddyList::PBuddyList(uint32_t nOwnerCharID)\r
{\r
mOwnerCharID = nOwnerCharID;\r
mListMaxSize = mListSize = 0;\r
delete[] mCharIDList;\r
}\r
\r
-bool PBuddyList::AddChar(u32 nBuddyCharID)\r
+bool PBuddyList::AddChar(uint32_t nBuddyCharID)\r
{\r
char query[256];\r
\r
return false;\r
}\r
\r
-bool PBuddyList::RemoveChar(u32 nBuddyCharID)\r
+bool PBuddyList::RemoveChar(uint32_t nBuddyCharID)\r
{\r
char query[256];\r
- u8 rEntry, i;\r
+ uint8_t rEntry, i;\r
\r
if ((rEntry = FindEntry(nBuddyCharID)) < mListSize)\r
{\r
char query[256];\r
MYSQL_RES *result;\r
MYSQL_ROW row;\r
- u8 EntriesNum;\r
+ uint8_t EntriesNum;\r
\r
snprintf(query, 256, "SELECT * FROM buddy_list WHERE (bud_charid='%u')", mOwnerCharID);\r
result = MySQL->GameResQuery(query);\r
return true;\r
}\r
\r
-void PBuddyList::IncreaseMaxSize(u8 nNewMax)\r
+void PBuddyList::IncreaseMaxSize(uint8_t nNewMax)\r
{\r
- u16 tmpSize;\r
+ uint16_t tmpSize;\r
\r
if (!nNewMax)\r
{\r
\r
mListMaxSize = (tmpSize < 256) ? tmpSize : 255;\r
\r
- u32* tmpList = new u32[mListMaxSize];\r
+ uint32_t* tmpList = new uint32_t[mListMaxSize];\r
if (mCharIDList)\r
{\r
if (mListSize)\r
{\r
- memcpy(tmpList, mCharIDList, sizeof(u32) * mListSize);\r
+ memcpy(tmpList, mCharIDList, sizeof(uint32_t) * mListSize);\r
}\r
\r
delete[] mCharIDList;\r
mCharIDList = tmpList;\r
}\r
\r
-u8 PBuddyList::FindEntry(u32 CharID)\r
+uint8_t PBuddyList::FindEntry(uint32_t CharID)\r
{\r
- u8 i = 255;\r
+ uint8_t i = 255;\r
\r
if (mCharIDList)\r
{\r
return i;\r
}\r
\r
-bool PBuddyList::IsInBuddy(u32 CharID)\r
+bool PBuddyList::IsInBuddy(uint32_t CharID)\r
{\r
if (mCharIDList)\r
{\r
- for (u8 i = 0; i < mListSize; i++)\r
+ for (uint8_t i = 0; i < mListSize; i++)\r
{\r
if (mCharIDList[i] == CharID)\r
return true;\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+\r
+#define BUDDYLIST_ALLOC_SIZE 4 // atomicity of list entries allocation\r
+\r
+class PBuddyList {\r
+ private:\r
+ enum { // buddy_list DB Table fields\r
+ bud_id = 0,\r
+ bud_charid,\r
+ bud_buddyid\r
+ };\r
+\r
+ uint32_t mOwnerCharID;\r
+ uint8_t mListMaxSize;\r
+ uint8_t mListSize;\r
+ uint32_t* mCharIDList;\r
+\r
+ void IncreaseMaxSize(uint8_t nNewMax = 0);\r
+ uint8_t FindEntry(uint32_t CharID);\r
+\r
+ public:\r
+ PBuddyList(uint32_t nOwnerCharID);\r
+ ~PBuddyList();\r
+ bool AddChar(uint32_t nBuddyCharID);\r
+ bool RemoveChar(uint32_t nBuddyCharID);\r
+ inline uint8_t Count() { return mListSize; }\r
+ uint16_t GetListDataSize() { return (sizeof(uint32_t) * mListSize); }\r
+ const void* GetListData() { return (const void*)mCharIDList; }\r
+ bool SQLLoad();\r
+\r
+ bool IsInBuddy(uint32_t CharID);\r
+// bool SQLSave();\r
+};\r
--- /dev/null
+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})
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- chars.cpp\r
-\r
- MODIFIED: 22 Dec 2005 Namikon\r
- REASON: - Added GPL\r
- MODIFIED: 01 Jan 2006 Namikon\r
- REASON: - Added SQLLoad() function to PChar and PChars\r
- - Changed FmtTxt() to sprintf(). It does... uhm, the same :D\r
- - Added IsOnline var and function\r
- MODIFIED: 06 Jan 2005 Namikon\r
- REASON: - Added colored console ouputs\r
- - Removed XM Load() and Save() functions\r
- - Rewrote parts of SQLLoad to work with the global NeoPolis / TinNS database\r
- - Added FillinCharDetails to fill the baseline up with the char details\r
- MODIFIED: 03 Oct 2006 Hammag\r
- REASON: - PChar::CreateNewChar() and moved effective char creation from PChars to PChar\r
- - added PChar::SQLDelete()\r
- This method is put here because we want the char to be loaded when deleted from DB to avoid\r
- any player to use it at the same time.\r
- - added use of auto_save_period config option in PChars::update()\r
- - removed old XML-storage related code\r
- MODIFIED: 09 Jun 2009 Akiko\r
- REASON: - adjusted includes for ne buildsystem\r
- - clean ups\r
-\r
- TODO: - implement PChar::SQLDelete()\r
-*/\r
-\r
-#include "main.h"\r
-#include "include/worlds.h"\r
-#include "include/appartements.h"\r
-#include "include/container.h"\r
-#include "include/inventory.h"\r
-#include "include/vhcaccessrequest.h"\r
+#include <cstring>\r
+#include "GameServer/Includes.hxx"\r
+#include "GameServer/Definitions/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
// PCharCoordinates\r
-void PCharCoordinates::SetInterpolate( PCharCoordinates& Pos1, PCharCoordinates& Pos2, f32 nCoef )\r
+void PCharCoordinates::SetInterpolate( PCharCoordinates& Pos1, PCharCoordinates& Pos2, float nCoef )\r
{\r
if (( nCoef < 0 ) || ( nCoef > 1 ) )\r
{\r
Console->Print( RED, BLACK, "[Error] PCharCoordinates::Interpolate : Invalid nCoef value: %f", nCoef );\r
nCoef = 0;\r
}\r
- f32 rCoef = 1 - nCoef;\r
+ float rCoef = 1 - nCoef;\r
\r
- mY = ( u16 )( rCoef * Pos1.mY + nCoef * Pos2.mY );\r
- mZ = ( u16 )( rCoef * Pos1.mZ + nCoef * Pos2.mZ );\r
- mX = ( u16 )( rCoef * Pos1.mX + nCoef * Pos2.mX );\r
- mUD = ( u8 )( rCoef * Pos1.mUD + nCoef * Pos2.mUD );\r
+ mY = ( uint16_t )( rCoef * Pos1.mY + nCoef * Pos2.mY );\r
+ mZ = ( uint16_t )( rCoef * Pos1.mZ + nCoef * Pos2.mZ );\r
+ mX = ( uint16_t )( rCoef * Pos1.mX + nCoef * Pos2.mX );\r
+ mUD = ( uint8_t )( rCoef * Pos1.mUD + nCoef * Pos2.mUD );\r
if ( abs( Pos1.mLR - Pos2.mLR ) < 90 )\r
{\r
- mLR = ( u8 )( rCoef * Pos1.mLR + nCoef * Pos2.mLR );\r
+ mLR = ( uint8_t )( rCoef * Pos1.mLR + nCoef * Pos2.mLR );\r
}\r
else\r
{\r
- mLR = ( u8 )(( u16 )( rCoef * ( 180.0 + ( f32 )Pos1.mLR ) + nCoef * Pos2.mLR ) % 180 );\r
+ mLR = ( uint8_t )(( uint16_t )( rCoef * ( 180.0 + ( float )Pos1.mLR ) + nCoef * Pos2.mLR ) % 180 );\r
}\r
}\r
\r
-u16 mY; // Y-Position in world\r
-u16 mZ; // Z-Position in world\r
-u16 mX; // X-Position in world\r
-u8 mUD; // Up - Mid - Down (d6 - 80 - 2a)\r
-u8 mLR; // Compass direction (S..E..N..W..S [0-45-90-135-179])\r
-u8 mAct; // Last user action state\r
+uint16_t mY; // Y-Position in world\r
+uint16_t mZ; // Z-Position in world\r
+uint16_t mX; // X-Position in world\r
+uint8_t mUD; // Up - Mid - Down (d6 - 80 - 2a)\r
+uint8_t mLR; // Compass direction (S..E..N..W..S [0-45-90-135-179])\r
+uint8_t mAct; // Last user action state\r
\r
-void PCharCoordinates::SetPosition( u16 nY, u16 nZ, u16 nX, u8 nUD, u8 nLR )\r
+void PCharCoordinates::SetPosition( uint16_t nY, uint16_t nZ, uint16_t nX, uint8_t nUD, uint8_t nLR )\r
{\r
mY = nY;\r
mZ = nZ;\r
mSeatInUseObjectId = 0;\r
mSeatInUseSeatId = 0;\r
mVhcAccessRequestList = NULL;\r
- \r
+\r
mContainerInExclusiveUse = NULL;\r
\r
mIsOnline = false;\r
return true;\r
}\r
\r
-void PChar::SetProfession( u32 Profession )\r
+void PChar::SetProfession( uint32_t Profession )\r
{\r
const PDefCharKind *def = GameDefs->CharKinds()->GetDef( Profession );\r
if ( def == NULL )\r
SetDirtyFlag();\r
}\r
\r
-u32 PChar::GetSkinFromCharType( u32 nType )\r
+uint32_t PChar::GetSkinFromCharType( uint32_t nType )\r
{\r
const PDefCharacter* nDefCharacter = GameDefs->Chars()->GetDef( nType );\r
if ( nDefCharacter )\r
{\r
- return (( u32 )( nDefCharacter->GetModel() ) );\r
+ return (( uint32_t )( nDefCharacter->GetModel() ) );\r
}\r
else\r
return 0;\r
}\r
\r
-inline u32 PChar::GetBaseModel()\r
+inline uint32_t PChar::GetBaseModel()\r
{\r
return GetSkinFromCharType( GetType() );\r
}\r
\r
-void PChar::SetRealLook( u32 nHead, u32 nTorso, u32 nLegs )\r
+void PChar::SetRealLook( uint32_t nHead, uint32_t nTorso, uint32_t nLegs )\r
{\r
mRealHead = nHead;\r
mRealTorso = nTorso;\r
ResetCurrentLook();\r
}\r
\r
-void PChar::GetRealLook( u32 &nSkin, u32 &nHead, u32 &nTorso, u32 &nLegs )\r
+void PChar::GetRealLook( uint32_t &nSkin, uint32_t &nHead, uint32_t &nTorso, uint32_t &nLegs )\r
{\r
nSkin = GetBaseModel();\r
nHead = mRealHead;\r
nLegs = mRealLegs;\r
}\r
\r
-void PChar::SetCurrentLookFromCharType( u32 nType )\r
+void PChar::SetCurrentLookFromCharType( uint32_t nType )\r
{\r
int iHead, iTorso, iLegs;\r
- u32 nSkin, nHead, nTorso, nLegs;\r
- u8 nColor, nBrightness;\r
+ uint32_t nSkin, nHead, nTorso, nLegs;\r
+ uint8_t nColor, nBrightness;\r
\r
const PDefCharacter* nDefCharacter = GameDefs->Chars()->GetDef( nType );\r
if ( nDefCharacter )\r
{\r
- nSkin = ( u32 ) nDefCharacter->GetModel();\r
+ nSkin = ( uint32_t ) nDefCharacter->GetModel();\r
iHead = nDefCharacter->GetHead();\r
iTorso = nDefCharacter->GetTorso();\r
iLegs = nDefCharacter->GetLegs();\r
- nColor = ( u8 )( 0xff & nDefCharacter->GetColor() );\r
- nBrightness = ( u8 )( 0xff & nDefCharacter->GetBrightness() );\r
+ nColor = ( uint8_t )( 0xff & nDefCharacter->GetColor() );\r
+ nBrightness = ( uint8_t )( 0xff & nDefCharacter->GetBrightness() );\r
\r
\r
if (( iHead < 0 ) || ( iTorso < 0 ) || ( iLegs < 0 ) )\r
}\r
}\r
\r
-void PChar::SetCurrentLook( u32 nSkin, u32 nHead, u32 nTorso, u32 nLegs )\r
+void PChar::SetCurrentLook( uint32_t nSkin, uint32_t nHead, uint32_t nTorso, uint32_t nLegs )\r
{\r
mSkin = nSkin;\r
mHead = nHead;\r
}\r
\r
// GetCurrentLook will later have to take Power Armors and GM overrides into account\r
-void PChar::GetCurrentLook( u32 &nSkin, u32 &nHead, u32 &nTorso, u32 &nLegs )\r
+void PChar::GetCurrentLook( uint32_t &nSkin, uint32_t &nHead, uint32_t &nTorso, uint32_t &nLegs )\r
{\r
nSkin = mSkin;\r
nHead = mHead;\r
nLegs = mLegs;\r
}\r
\r
-void PChar::SetCurrentBodyColor( u8 nHeadColor, u8 nTorsoColor, u8 nLegsColor, u8 nHeadDarkness, u8 nTorsoDarkness, u8 nLegsDarkness )\r
+void PChar::SetCurrentBodyColor( uint8_t nHeadColor, uint8_t nTorsoColor, uint8_t nLegsColor, uint8_t nHeadDarkness, uint8_t nTorsoDarkness, uint8_t nLegsDarkness )\r
{\r
mHeadColor = nHeadColor;\r
mTorsoColor = nTorsoColor;\r
mLegsDarkness = nLegsDarkness;\r
}\r
\r
-void PChar::GetCurrentBodyColor( u8 &nHeadColor, u8 &nTorsoColor, u8 &nLegsColor, u8 &nHeadDarkness, u8 &nTorsoDarkness, u8 &nLegsDarkness )\r
+void PChar::GetCurrentBodyColor( uint8_t &nHeadColor, uint8_t &nTorsoColor, uint8_t &nLegsColor, uint8_t &nHeadDarkness, uint8_t &nTorsoDarkness, uint8_t &nLegsDarkness )\r
{\r
nHeadColor = mHeadColor;\r
nTorsoColor = mTorsoColor;\r
Console->Print( YELLOW, BLACK, "PChar::SetBaseSkills() not fully functionnal - unused skill points will be lost" );\r
}\r
\r
-void PChar::SetBaseSubskills( u8 NSZNb, const char* NonZeroSubskills )\r
+void PChar::SetBaseSubskills( uint8_t NSZNb, const char* NonZeroSubskills )\r
{\r
int i;\r
\r
\r
void PChar::SetBaseInventory()\r
{\r
- u8 i;\r
- u32 BaseItemID;\r
+ uint8_t i;\r
+ uint32_t BaseItemID;\r
const PDefCharKind *def = GameDefs->CharKinds()->GetDef( mProfession );\r
\r
//mCash = 5000;\r
// Gender\r
int genvalue = atoi( row[c_sex] );\r
if (( genvalue == 0 ) || ( genvalue == 1 ) )\r
- mGender = static_cast<u32>( genvalue );\r
+ mGender = static_cast<uint32_t>( genvalue );\r
else\r
{\r
Console->Print( RED, BLACK, "Bad gender value: %d (Char ID %d)", genvalue, mID );\r
\r
// Profession\r
int profvalue = atoi( row[c_profession] );\r
- SetProfession( static_cast<u32>( profvalue ) );\r
+ SetProfession( static_cast<uint32_t>( profvalue ) );\r
\r
// Class\r
//int classvalue = atoi(row[c_class]);\r
//if(classvalue < 4)\r
- // mClass = static_cast<u32>(classvalue);\r
+ // mClass = static_cast<uint32_t>(classvalue);\r
//else\r
//{\r
// Console->Print(RED, BLACK, "Bad class value: %d (Char ID %d)", classvalue, mID);\r
// Faction\r
int facvalue = atoi( row[c_faction] );\r
if ( GameDefs->Factions()->GetDef( facvalue ) )\r
- mFaction = static_cast<u32>( facvalue );\r
+ mFaction = static_cast<uint32_t>( facvalue );\r
else\r
mFaction = 1;\r
\r
/* // Model\r
int modvalue = atoi(row[c_model]);\r
- mModel = static_cast<u32>(modvalue);\r
+ mModel = static_cast<uint32_t>(modvalue);\r
mModel = 10; */\r
int headvalue = atoi( row[c_head] );\r
int torsovalue = atoi( row[c_torso] );\r
int legsvalue = atoi( row[c_legs] );\r
- SetRealLook( static_cast<u32>( headvalue ), static_cast<u32>( torsovalue ), static_cast<u32>( legsvalue ) );\r
+ SetRealLook( static_cast<uint32_t>( headvalue ), static_cast<uint32_t>( torsovalue ), static_cast<uint32_t>( legsvalue ) );\r
\r
// Type\r
/*\r
int typevalue = std::atoi(row[c_type]);\r
- mType = static_cast<u32>(typevalue);\r
+ mType = static_cast<uint32_t>(typevalue);\r
//mType = 1; */\r
\r
// Location\r
int locvalue = atoi( row[c_location] );\r
- mLocation = static_cast<u32>( locvalue );\r
+ mLocation = static_cast<uint32_t>( locvalue );\r
\r
//This assumption is not so good ... hardcoding jailed state linked with location ...\r
if ( mLocation == 550 || mLocation == 551 )\r
mJailed = true;\r
\r
int posvalue = atoi( row[c_pos_x] );\r
- Coords.mX = static_cast<u16>( posvalue );\r
+ Coords.mX = static_cast<uint16_t>( posvalue );\r
posvalue = atoi( row[c_pos_y] );\r
- Coords.mY = static_cast<u16>( posvalue );\r
+ Coords.mY = static_cast<uint16_t>( posvalue );\r
posvalue = atoi( row[c_pos_z] );\r
- Coords.mZ = static_cast<u16>( posvalue );\r
+ Coords.mZ = static_cast<uint16_t>( posvalue );\r
posvalue = atoi( row[c_angle_ud] );\r
- Coords.mUD = static_cast<u8>( posvalue );\r
+ Coords.mUD = static_cast<uint8_t>( posvalue );\r
posvalue = atoi( row[c_angle_lr] );\r
- Coords.mLR = static_cast<u8>( posvalue );\r
+ Coords.mLR = static_cast<uint8_t>( posvalue );\r
\r
int primapt = atoi( row[c_apt] );\r
- mPrimaryApt = static_cast<u32>( primapt );\r
+ mPrimaryApt = static_cast<uint32_t>( primapt );\r
mStartApt = mPrimaryApt;\r
\r
mSoullight = atoi( row[c_soullight] );\r
LoadClanLevel();\r
\r
// Cash\r
- f32 cashvalue = atof( row[c_cash] );\r
- mCash = static_cast<u32>( cashvalue );\r
+ float cashvalue = atof( row[c_cash] );\r
+ mCash = static_cast<uint32_t>( cashvalue );\r
\r
// ---------------------------------------------\r
// Loading skills --- MAIN Skills with SP and XP\r
mInventory.SQLLoad();\r
\r
// temp value forcing, not get/saved from DB atm\r
- mCombatRank = ( u8 )( random() % 127 ); // bad result there on randomness\r
+ mCombatRank = ( uint8_t )( random() % 127 ); // bad result there on randomness\r
mSynaptic = 0;\r
mIsDead = false;\r
\r
}\r
}\r
\r
-bool PChar::CreateNewChar( u32 Account, const std::string &Name, u32 Gender, u32 Profession, u32 Faction,\r
- u32 Head, u32 Torso, u32 Legs, u8 NZSNb, const char *NonZeroSubskills, u32 Slot )\r
+bool PChar::CreateNewChar( uint32_t Account, const std::string &Name, uint32_t Gender, uint32_t Profession, uint32_t Faction,\r
+ uint32_t Head, uint32_t Torso, uint32_t Legs, uint8_t NZSNb, const char *NonZeroSubskills, uint32_t Slot )\r
{\r
SetName( Name );\r
SetGender( Gender );\r
\r
// This part will have to be rewritten with proper methods\r
mSoullight = 10;\r
- mCombatRank = ( u8 )( random() % 80 ); // bad result there on randomness\r
+ mCombatRank = ( uint8_t )( random() % 80 ); // bad result there on randomness\r
mSynaptic = 0;\r
mIsDead = false;\r
\r
return;\r
}\r
\r
-u8 PChar::GetCombatRank()\r
+uint8_t PChar::GetCombatRank()\r
{\r
// Override for Special Account Levels\r
PAccount Acc(mAccount);\r
}\r
\r
\r
-u8 PChar::GetMainRank()\r
+uint8_t PChar::GetMainRank()\r
{\r
// Override for Special Account Levels\r
PAccount Acc(mAccount);\r
return 50;\r
else\r
{\r
- u16 total;\r
+ uint16_t total;\r
total = Skill->GetMainSkill( MS_STR ) + Skill->GetMainSkill( MS_DEX );\r
total += Skill->GetMainSkill( MS_CON ) + Skill->GetMainSkill( MS_INT );\r
total += Skill->GetMainSkill( MS_PSI );\r
- return (( u8 )( total / 5 ) );\r
+ return (( uint8_t )( total / 5 ) );\r
}\r
}\r
\r
-u32 PChar::AddCash( u32 nAmount )\r
+bool PChar::AddGenrep(uint16_t nWorldID, uint16_t nStationID)\r
+{\r
+ return mGenrepList->AddGenrep(nWorldID, nStationID );\r
+}\r
+\r
+uint16_t PChar::GetGenrepListDataSize()\r
+{\r
+ return mGenrepList->GetListDataSize();\r
+}\r
+\r
+const void *PChar::GetGenrepListData()\r
+{\r
+ return mGenrepList->GetListData();\r
+}\r
+\r
+uint8_t PChar::GetGenrepCount()\r
+{\r
+ return mGenrepList->Count();\r
+}\r
+\r
+uint32_t PChar::AddCash( uint32_t nAmount )\r
{\r
return SetCash(nAmount + mCash);\r
}\r
\r
-u32 PChar::TakeCash( u32 nAmount )\r
+uint32_t PChar::TakeCash( uint32_t nAmount )\r
{\r
if(nAmount > mCash)\r
{\r
}\r
}\r
\r
-u32 PChar::SetCash( u32 nCash )\r
+uint32_t PChar::SetCash( uint32_t nCash )\r
{\r
//Console->Print("Trying to set cash to nCash: %d", nCash);\r
if (( int )nCash > Config->GetOptionInt( "max_cash" ) )\r
{\r
//Console->Print("Newcash would be more than dynamic maxcash, setting to maxcash");\r
- mCash = ( u32 )Config->GetOptionInt( "max_cash" );\r
+ mCash = ( uint32_t )Config->GetOptionInt( "max_cash" );\r
}\r
else if ( nCash > MAXCASH )\r
{\r
}\r
\r
\r
-bool PChar::SetQuickBeltActiveSlot( u8 nSlotID )\r
+bool PChar::SetQuickBeltActiveSlot( uint8_t nSlotID )\r
{\r
if (( nSlotID == INV_WORN_QB_HAND ) || ( nSlotID == INV_WORN_QB_NONE ) )\r
{\r
return false;\r
}\r
\r
-PSeatType PChar::GetSeatInUse( u32* nObjectId, u8* nSeatId )\r
+PSeatType PChar::GetSeatInUse( uint32_t* nObjectId, uint8_t* nSeatId )\r
{\r
if ( nObjectId )\r
{\r
return mSeatInUseType;\r
}\r
\r
-void PChar::SetSeatInUse( PSeatType nSeatType, u32 nObjectId, u8 nSeatId )\r
+void PChar::SetSeatInUse( PSeatType nSeatType, uint32_t nObjectId, uint8_t nSeatId )\r
{\r
mSeatInUseType = nSeatType;\r
mSeatInUseObjectId = nObjectId;\r
return mVhcAccessRequestList;\r
}\r
\r
-void PChar::SetLookingAt( u16 nLocalCharID )\r
+void PChar::SetLookingAt( uint16_t nLocalCharID )\r
{\r
mLookingAt = nLocalCharID;\r
mLookAtTimestamp = std::time( NULL );\r
}\r
\r
-u16 PChar::GetLookingAt( u16 nMaxDelaySec )\r
+uint16_t PChar::GetLookingAt( uint16_t nMaxDelaySec )\r
{\r
return ((( mLookAtTimestamp + nMaxDelaySec ) >= std::time( NULL ) ) ? mLookingAt : 0 );\r
}\r
delete i->second;\r
}\r
\r
-bool PChars::LoadChar( u32 CharID )\r
+bool PChars::LoadChar( uint32_t CharID )\r
{\r
if ( !CharID )\r
return false;\r
}\r
}\r
\r
-PChar* PChars::RemoveChar( u32 CharID )\r
+PChar* PChars::RemoveChar( uint32_t CharID )\r
{\r
PChar* Result = NULL;\r
\r
return;\r
}\r
\r
-PChar* PChars::GetChar( u32 CharID ) const\r
+PChar* PChars::GetChar( uint32_t CharID ) const\r
{\r
PChar *Result = 0;\r
CharMap::const_iterator i = mChars.find( CharID );\r
}\r
\r
//MAX_CHARS_PER_ACCOUNT\r
-int PChars::GetCharProfiles( const u32 AccountID, PCharProfile* CharSlotsArray, const u8 ArraySize )\r
+int PChars::GetCharProfiles( const uint32_t AccountID, PCharProfile* CharSlotsArray, const uint8_t ArraySize )\r
{\r
char query[256];\r
int EntriesNb = 0;\r
\r
//EntriesNb = mysql_num_rows(result);\r
int SlotID;\r
- u32 CharID;\r
+ uint32_t CharID;\r
PChar* tmpChar = new PChar();\r
\r
while (( row = mysql_fetch_row( result ) ) )\r
\r
CharSlotsArray[SlotID].CharID = CharID;\r
CharSlotsArray[SlotID].Type = tmpChar->GetType();\r
- CharSlotsArray[SlotID].Location = static_cast<u32>( atoi( row[c_location] ) );\r
+ CharSlotsArray[SlotID].Location = static_cast<uint32_t>( atoi( row[c_location] ) );\r
CharSlotsArray[SlotID].Head = atoi( row[c_head] );\r
CharSlotsArray[SlotID].Torso = atoi( row[c_torso] );\r
CharSlotsArray[SlotID].Legs = atoi( row[c_legs] );\r
--- /dev/null
+#pragma once\r
+\r
+#include <chrono>\r
+#include <cstdint>\r
+#include <map>\r
+#include "GameServer/Inventory.hxx" // FIXME: class design fault\r
+\r
+#define MAXCASH 1000000000\r
+\r
+class PGenrepList;\r
+class PSkillHandler;\r
+class PVhcAccessRequestList;\r
+\r
+enum PSeatType {\r
+ seat_none = 0,\r
+ seat_chair,\r
+ seat_subway,\r
+ seat_vhc\r
+};\r
+\r
+class PCharCoordinates {\r
+ public:\r
+ uint16_t mY; // Y-Position in world // Y increases when going East\r
+ uint16_t mZ; // Z-Position in world // Z increases when going up\r
+ uint16_t mX; // X-Position in world // X increases when going South\r
+ uint8_t mUD; // Up - Mid - Down (d6 - 80 - 2a)\r
+ uint8_t mLR; // Compass direction (S..E..N..W..S [0-45-90-135-179])\r
+ uint8_t mAct; // Last user action state\r
+ uint8_t mUnknown;// sometime sent by client with value != 0 (usual case)\r
+ // mAct:\r
+ // 0x00 NC has no focus (player alt+tab'ed out)\r
+ // 0x04 Char on ground/dead 00000100\r
+ // 0x20 Char does nothing 00100000\r
+ // 0x22 kneeing 00100010\r
+ // 0x28 left step 00101000\r
+ // 0x30 right step 00110000\r
+ // 0x40 walking (not running) 01000000 // Seems to mean Running ? - to be verfied, with default walk/run mode !!!\r
+ // 0x60 forward 01100000\r
+ // 0xA0 backward 10100000\r
+ // bits: BFWRL.K.\r
+\r
+ uint8_t mJumpingState;\r
+\r
+ //inline PCharCoordinates() { mX = mY = mZ = mUD = mLR = mAct = mUnknown = mJumpingState = 0;}\r
+ void SetPosition( uint16_t nY, uint16_t nZ, uint16_t nX, uint8_t nUD = 0x80, uint8_t nLR = 0 );\r
+ void SetInterpolate( PCharCoordinates& Pos1, PCharCoordinates& Pos2, float nCoef );\r
+\r
+ //Temp\r
+ uint16_t minPos[3];\r
+ uint16_t maxPos[3];\r
+ inline PCharCoordinates() { mX = mY = mZ = mUD = mLR = mAct = mUnknown = mJumpingState = 0; for(int i=0; i<3; ++i) { minPos[i] = 0xffff; maxPos[i] = 0; } }\r
+};\r
+\r
+class PChar\r
+{\r
+ private :\r
+ // static members\r
+ static RegEx* mCharnameRegexFilter;\r
+\r
+ // instance members\r
+ uint32_t mID;\r
+ uint32_t mAccount;\r
+ uint8_t mSlot;\r
+ std::string mName;\r
+ uint32_t mGender;\r
+ uint32_t mClass;\r
+ //uint32_t mType; // Removed that and only keep GetType()\r
+ uint32_t mProfession;\r
+ uint32_t mFaction;\r
+ uint32_t mRealHead; // Base Skin elements, in complement of (computed) mType\r
+ uint32_t mRealTorso; // " Head shouldn't be changeable, except in case of surgery !!!\r
+ uint32_t mRealLegs; // "\r
+ uint32_t mSkin; // Current Skin elements. *** Not saved in DB atm ***\r
+ uint32_t mHead; // "\r
+ uint32_t mTorso; // "\r
+ uint32_t mLegs; // "\r
+ uint8_t mHeadColor; // "\r
+ uint8_t mTorsoColor; // "\r
+ uint8_t mLegsColor; // "\r
+ uint8_t mHeadDarkness; // " // 0=Bright, 255=dark\r
+ uint8_t mTorsoDarkness; // "\r
+ uint8_t mLegsDarkness; // "\r
+ // Skin scale factor setting remain to discover, provided they are somewhere for player chars ...\r
+\r
+ bool mLocationLeased; // temp until char on-demand load/unload\r
+ uint32_t mLocation;\r
+ uint32_t mCash;\r
+ uint32_t mStartApt; // set same as PrimaryApt atm\r
+ uint32_t mPrimaryApt;\r
+\r
+ // not saved in DB atm\r
+ PSeatType mSeatInUseType;\r
+ uint32_t mSeatInUseObjectId;\r
+ uint8_t mSeatInUseSeatId;\r
+ PVhcAccessRequestList* mVhcAccessRequestList;\r
+\r
+ PContainer* mContainerInExclusiveUse;\r
+\r
+ uint16_t mHealth;\r
+ uint16_t mMana;\r
+ uint16_t mStamina;\r
+\r
+ int8_t mSoullight;\r
+ uint8_t mCombatRank; // *** Not got/saved from DB atm ***\r
+ uint8_t mSynaptic; // *** Not got/saved from DB atm ***\r
+ bool mIsDead; // *** Not got/saved from DB atm ***\r
+\r
+ // Only one body effect supported atm. Should be extended later to multiple effects\r
+ uint8_t mBodyEffect; // *** Not got/saved from DB atm ***\r
+ uint8_t mBodyEffectDensity; // *** Not got/saved from DB atm ***\r
+\r
+ uint8_t mSpeedOverride; // a hack to control move speed. Not saved in DB\r
+\r
+ uint32_t mDirectCharID; // for Direct Chat // *** Not got/saved from DB atm ***\r
+ PBuddyList* mBuddyList; // For Buddy list Chat\r
+ uint32_t mActiveChatChannels; // Active chat channels flags // *** Not got/saved from DB atm ***\r
+\r
+ PGenrepList* mGenrepList; // Character's GR list\r
+\r
+ uint8_t mQuickBeltActiveSlot; // QB SlotID of item "in hand", or INV_WORN_QB_HAND or INV_WORN_QB_NONE\r
+\r
+ uint16_t mLookingAt; // Zone charID of currently targeted player\r
+ std::time_t mLookAtTimestamp; // Lifetimer of lookat var\r
+ uint32_t mLastUsedWorldObjectId; // Last world object clicked on\r
+\r
+ uint8_t mClanLevel; // 1-15\r
+ uint16_t mClanID;\r
+\r
+ bool mIsOnline;\r
+ bool mDirtyFlag;\r
+\r
+ bool mShunned;\r
+ bool mJailed;\r
+\r
+ uint32_t mDialogNPC; // NPCID the player talks to\r
+ uint16_t mCurrentDialogNode; // Node in .lua file we're at right now\r
+\r
+ class PInventory mInventory;\r
+\r
+ protected :\r
+ friend class PChars;\r
+ inline void SetID( uint32_t ID ) { mID = ID; }\r
+ inline void SetAccount( uint32_t Account ) { mAccount = Account; }\r
+ inline void SetCharSlot( uint8_t Slot ) { if ( Slot < 4 ) mSlot = Slot;} // TODO: set max slot according to server config\r
+ inline void SetName( const std::string &Name ) { mName = Name; }\r
+ inline void SetGender( uint32_t Gender ) { mGender = Gender; }\r
+ void SetProfession( uint32_t Profession );\r
+ //inline void SetClass(uint32_t nClass) { mClass = nClass; } // mClass is defined by setting Profession\r
+ //inline void SetType(uint32_t Type) { mType = Type; } // Removed. Type is computed from Gender & Profession (??? is it not Gender + Class ???)\r
+ inline void SetFaction( uint32_t Faction ) { mFaction = Faction; }\r
+ //inline void SetModel(uint32_t Model) { mModel = Model; } // Inhibited for the moment. Base model is deduced from from Gender & Class (Profession)\r
+ void SetRealLook( uint32_t nHead, uint32_t nTorso, uint32_t nLegs );\r
+ void SetBaseSkills();\r
+ void SetBaseSubskills( uint8_t NZSNb, const char* NonZeroSubskills );\r
+ void SetBaseInventory();\r
+\r
+ bool SQLCreate();\r
+\r
+ public :\r
+ PChar();\r
+ ~PChar();\r
+\r
+ static bool SetCharnameRegexFilter( const char* RegexStr );\r
+ static bool IsCharnameWellFormed( const char *Username );\r
+\r
+ PSkillHandler *Skill;\r
+ PCharCoordinates Coords;\r
+\r
+ void SetCurrentLook( uint32_t nSkin, uint32_t nHead = 0, uint32_t nTorso = 0, uint32_t nLegs = 0 );\r
+ void SetCurrentLookFromCharType( uint32_t nType );\r
+ void ResetCurrentLook();\r
+\r
+ void SetCurrentBodyColor( uint8_t nHeadColor, uint8_t nTorsoColor, uint8_t nLegsColor, uint8_t nHeadDarkness = 0, uint8_t nTorsoDarkness = 0, uint8_t nLegsDarkness = 0 );\r
+ inline void SetBodyEffect( uint8_t nEffect, uint8_t nDensity = 0 ) { mBodyEffect = nEffect; mBodyEffectDensity = nDensity; }\r
+ inline void SetSpeedOverride( uint8_t nSpeed = 255 ) { mSpeedOverride = nSpeed; }\r
+\r
+ void SetLookingAt( uint16_t nLocalCharID );\r
+ uint16_t GetLookingAt( uint16_t nMaxDelaySec = 1 );\r
+ inline void SetLastUsedObject ( uint32_t nRawItemId ) { mLastUsedWorldObjectId = nRawItemId; }\r
+ inline uint32_t GetLastUsedObject () const { return mLastUsedWorldObjectId; }\r
+\r
+ inline PInventory* GetInventory() { return &mInventory; }\r
+ inline uint32_t GetID() const { return mID; }\r
+ inline uint32_t GetAccount() const { return mAccount; }\r
+ inline const std::string &GetName() const { return mName; }\r
+ inline uint32_t GetGender() const { return mGender; }\r
+ inline uint32_t GetClass() const { return mClass; }\r
+ inline uint32_t GetType() const { return 2 * mClass + mGender; }\r
+ uint32_t GetSkinFromCharType( uint32_t nType );\r
+ void GetRealLook( uint32_t &nSkin, uint32_t &nHead, uint32_t &nTorso, uint32_t &nLegs );\r
+ void GetCurrentLook( uint32_t &nSkin, uint32_t &nHead, uint32_t &nTorso, uint32_t &nLegs );\r
+ inline void GetBodyEffect( uint8_t &nEffect, uint8_t &nDensity ) { nEffect = mBodyEffect; nDensity = mBodyEffectDensity; }\r
+\r
+ inline uint8_t GetQuickBeltActiveSlot() { return mQuickBeltActiveSlot; }\r
+ bool SetQuickBeltActiveSlot( uint8_t nSlotID );\r
+\r
+ void GetCurrentBodyColor( uint8_t &nHeadColor, uint8_t &nTorsoColor, uint8_t &nLegsColor, uint8_t &nHeadDarkness, uint8_t &nTorsoDarkness, uint8_t &nLegsDarkness );\r
+ inline uint8_t GetSpeedOverride() { return mSpeedOverride; }\r
+ inline uint32_t GetBaseModel();\r
+ inline uint32_t GetProfession() const { return mProfession; }\r
+ inline uint16_t GetMaxHealth() { return mHealth; }\r
+ inline uint16_t GetMaxMana() { return mMana; }\r
+ inline uint16_t GetMaxStamina() { return mStamina; }\r
+ inline uint16_t GetHealth() { return mHealth; }\r
+ inline uint16_t GetMana() { return mMana; }\r
+ inline uint16_t GetStamina() { return mStamina; }\r
+ inline uint32_t GetFaction() const { return mFaction; }\r
+ inline uint32_t GetLocation() const { return mLocation; }\r
+\r
+ inline uint32_t GetCash() const { return mCash; }\r
+ uint32_t SetCash( uint32_t nCash ); // Does return the new cashvalue, NO udpmessage is sent out!!\r
+ uint32_t AddCash( uint32_t nAmount );\r
+ uint32_t TakeCash( uint32_t nAmount );\r
+\r
+ inline uint32_t GetBaseApartment() const { return mPrimaryApt; }\r
+\r
+ inline void SetJail( bool val ) { mJailed = val; };\r
+ inline void SetShun( bool val ) { mShunned = val; };\r
+\r
+ inline bool IsJailed() { return mJailed; };\r
+ inline bool IsShunned() { return mShunned; };\r
+\r
+ inline void SetDialogNPC( uint32_t nNPC ) { mDialogNPC = nNPC; };\r
+ inline uint32_t GetDialogNPC() const { return mDialogNPC; };\r
+\r
+ inline void SetDialogNode( uint16_t nNode ) { mCurrentDialogNode = nNode; };\r
+ inline uint16_t GetDialogNode() const { return mCurrentDialogNode; };\r
+\r
+ inline uint8_t GetClanLevel() const { return mClanLevel; };\r
+ inline uint16_t GetClan() const { return mClanID; };\r
+ void LoadClanLevel();\r
+\r
+ inline int8_t GetSoullight() const { return mSoullight; }\r
+ uint8_t GetMainRank();\r
+ uint8_t GetCombatRank();\r
+ inline uint8_t GetSynaptic() const { return mSynaptic; }\r
+ inline bool IsDead() const { return mIsDead; }\r
+\r
+ inline bool SetDirectChat( uint32_t nBuddyCharID ) { mDirectCharID = nBuddyCharID; return true; }\r
+ inline uint32_t GetDirectChat() { return mDirectCharID; }\r
+ inline void SetActiveChannels( uint32_t nChannels ) { mActiveChatChannels = nChannels; }\r
+ inline uint32_t GetActiveChannels() { return mActiveChatChannels; }\r
+\r
+ inline bool AddBuddy( uint32_t nBuddyCharID ) { return mBuddyList->AddChar( nBuddyCharID ); }\r
+ inline bool RemoveBuddy( uint32_t nBuddyCharID ) { return mBuddyList->RemoveChar( nBuddyCharID ); }\r
+ inline uint16_t GetBuddyListDataSize() { return mBuddyList->GetListDataSize(); }\r
+ inline const void* GetBuddyListData() { return mBuddyList->GetListData(); }\r
+ inline uint8_t GetBuddyCount() { return mBuddyList->Count(); }\r
+ inline bool IsBuddy( uint32_t CharID ) { return mBuddyList->IsInBuddy( CharID ); };\r
+\r
+ bool AddGenrep(uint16_t nWorldID, uint16_t nStationID);\r
+ uint16_t GetGenrepListDataSize();\r
+ const void *GetGenrepListData();\r
+ uint8_t GetGenrepCount();\r
+\r
+ inline bool IsDirty() const { return mDirtyFlag; }\r
+ inline bool IsAnyDirty() const { return mDirtyFlag || mInventory.IsDirty(); }\r
+ inline bool IsOnline() { return mIsOnline; }\r
+ void SetOnlineStatus( bool IsOnline );\r
+\r
+ bool CreateNewChar( uint32_t Account, const std::string &Name, uint32_t Gender, uint32_t Profession, uint32_t Faction,\r
+ uint32_t Head, uint32_t Torso, uint32_t Legs, uint8_t NZSNb, const char *NonZeroSubskills, uint32_t Slot );\r
+ bool SQLLoad( int CharID );\r
+ bool SQLSave();\r
+ inline bool SQLSaveFull() { return SQLSave() && mInventory.SQLSave(); }\r
+ bool SQLDelete(); // not implemented yet\r
+\r
+ inline void SetLocation( uint32_t Location ) { mLocation = Location; }\r
+ inline void SetDirtyFlag( bool Dirty = true ) { mDirtyFlag = Dirty; }\r
+\r
+ // temp until char on-demand load/unload\r
+ inline void SetLocationLeased( bool nState = true ) { mLocationLeased = nState; }\r
+ inline bool GetLocationLeased() { return mLocationLeased; }\r
+\r
+ PSeatType GetSeatInUse( uint32_t* nObjectId = NULL, uint8_t* nSeatId = NULL );\r
+ void SetSeatInUse( PSeatType nSeatType, uint32_t nObjectId = 0, uint8_t nSeatId = 0 );\r
+\r
+ PVhcAccessRequestList* GetVhcAccessRequestList();\r
+\r
+ inline PContainer* GetContainerInExclusiveUse() { return mContainerInExclusiveUse; }\r
+ inline void SetContainerInExclusiveUse( PContainer* nContainer ) { mContainerInExclusiveUse = nContainer; }\r
+};\r
+\r
+struct PCharProfile\r
+{\r
+ uint32_t CharID;\r
+ uint16_t Type;\r
+ uint16_t Color0;\r
+ uint16_t Unknown1;\r
+ uint8_t Head;\r
+ uint8_t Torso;\r
+ uint8_t Legs;\r
+ uint32_t Location;\r
+ uint8_t NameLen;\r
+ uint8_t Unknown3;\r
+ uint8_t Unknown4;\r
+ uint8_t Unknown5;\r
+ uint8_t Unknown6;\r
+ uint8_t Unknown7;\r
+ uint8_t Unknown8;\r
+ uint8_t Unknown9;\r
+ uint8_t Unknown10;\r
+ uint8_t Unknown11;\r
+ uint8_t Unknown12;\r
+ std::string Name;\r
+ bool in_use;\r
+};\r
+\r
+class PChars\r
+{\r
+ private :\r
+ typedef std::map<uint32_t, PChar*> CharMap;\r
+ CharMap mChars;\r
+ uint32_t mLastID;\r
+\r
+ std::time_t mAutoSavePeriod;\r
+ std::time_t mLastSave;\r
+\r
+ public :\r
+ PChars();\r
+ ~PChars();\r
+\r
+ bool LoadChar( uint32_t CharID );\r
+ bool AddChar( PChar* nChar );\r
+ PChar* RemoveChar( uint32_t CharID );\r
+\r
+ PChar* GetChar( uint32_t CharID ) const;\r
+ PChar* GetChar( const std::string &Name ) const;\r
+ bool CharExist( const std::string &Name ) const;\r
+\r
+ void SQLSave();\r
+ void Update();\r
+\r
+ int GetCharProfiles( const uint32_t AccountID, PCharProfile* CharSlotsArray, const uint8_t ArraySize ); // return effective entries nb\r
+};\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- chat.cpp - handles all ingame chat\r
-\r
- Authors:\r
- - Namikon\r
- - bakkdoor\r
- - Akiko\r
-\r
- MODIFIED: 30 Nov 2005 Namikon/Akiko\r
- REASON: - initial release by Namikon\r
- MODIFIED: 11 Dec 2005 Namikon\r
- REASON: - Added function SendDChat(Client, <text>, <nick>) to send a Direct to player\r
- - Added Channel IDs for GameMaster (/gm) and Administrator (/admin) chat\r
- - Added channel const's for sending chat packets\r
- - Added function SendChat(Client, <channel>, <text>, <nick>) to send chat messages\r
- See chat.h for a list of availeable <channel>'s\r
-\r
- MODIFIED: 17 Dec 2005 bakkdoor\r
- REASON: - introduced new structure for chatsystem\r
- - -> PChat class\r
- MODIFIED: 09 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
- - clean ups\r
-\r
- TODO:\r
- - Add "hooks" to process chatevents everywhere in the source <-- kind of done. you can use the global PChat Instance.\r
- Check:\r
- Chat->send(PClient* receiver, const u8* Channel, const char* AuthorNickName, char* text, bool debugOut=false);\r
- Example:\r
- Chat->send(receiverClient, CHAT_DIRECT, Chars->GetChar(authorClient->GetCharID())->GetName().c_str(), text);\r
-*/\r
+#include "GameServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
-#include "main.h"\r
-#include "include/msgbuilder.h"\r
+// TODO:- Add "hooks" to process chatevents everywhere in the source <-- kind of done. you can use the global PChat Instance.\r
+// Check:\r
+// Chat->send(PClient* receiver, const uint8_t* Channel, const char* AuthorNickName, char* text, bool debugOut=false);\r
+// Example:\r
+// Chat->send(receiverClient, CHAT_DIRECT, Chars->GetChar(authorClient->GetCharID())->GetName().c_str(), text);\r
\r
PChat::PChat()\r
{\r
\r
void PChat::sendConnectedList(PClient* receiver, bool debugOut)\r
{\r
- const char* text = "Connected Players are:]";\r
+ const char* text = "Connected Players are:]";\r
send(receiver, CHAT_DIRECT, "[System", text, debugOut);\r
\r
int counter = 1;\r
// send the list of currently connected players to receiver\r
for(PClientMap::iterator it=ClientManager->getClientListBegin(); it!=ClientManager->getClientListEnd(); it++)\r
{\r
- char counterText[5];\r
- snprintf(counterText, 5, "%d", counter);\r
+ char counterText[5];\r
+ snprintf(counterText, 5, "%d", counter);\r
\r
PChar* receiverChar = Chars->GetChar(it->second->GetCharID());\r
send(receiver, CHAT_DIRECT, (receiverChar ? receiverChar->GetName().c_str() : "*"), counterText, debugOut);\r
{\r
// send the message to all clients that have same FactionID\r
PChar* authorChar = Chars->GetChar(author->GetCharID());\r
- u32 FID = authorChar->GetFaction(); // get LocationID of author\r
+ uint32_t FID = authorChar->GetFaction(); // get LocationID of author\r
\r
for(PClientMap::iterator it=ClientManager->getClientListBegin(); it!=ClientManager->getClientListEnd(); it++)\r
{\r
{\r
// send the message to all clients that have same ZoneID\r
PChar* authorChar = Chars->GetChar(author->GetCharID());\r
- u32 ZID = authorChar->GetLocation(); // get LocationID of author\r
+ uint32_t ZID = authorChar->GetLocation(); // get LocationID of author\r
\r
for(PClientMap::iterator it=ClientManager->getClientListBegin(); it!=ClientManager->getClientListEnd(); it++)\r
{\r
void PChat::sendLocal(PClient* author, const char* text, bool debugOut)\r
{\r
PChar* authorChar = Chars->GetChar(author->GetCharID());\r
- u32 ZID = authorChar->GetLocation(); // get LocationID of author\r
+ uint32_t ZID = authorChar->GetLocation(); // get LocationID of author\r
\r
// send the message to all clients that are in Area (Radius = X (needs to be defined somewhere!))\r
for(PClientMap::iterator it=ClientManager->getClientListBegin(); it!=ClientManager->getClientListEnd(); it++)\r
PChar* receiverChar = Chars->GetChar(receiver->GetCharID());\r
if(receiverChar && (receiverChar->GetLocation() == ZID))\r
{\r
- u16 distance = DistanceApprox((authorChar->Coords).mX, (authorChar->Coords).mY, (authorChar->Coords).mZ, (receiverChar->Coords).mX, (receiverChar->Coords).mY, (receiverChar->Coords).mZ);\r
+ uint16_t distance = DistanceApprox((authorChar->Coords).mX, (authorChar->Coords).mY, (authorChar->Coords).mZ, (receiverChar->Coords).mX, (receiverChar->Coords).mY, (receiverChar->Coords).mZ);\r
if(distance < LOCALCHAT_MAXDISTANCE)\r
{\r
//sendLocalchat(receiver, author, text, debugOut); // Doesnt work!\r
}\r
}\r
\r
-void PChat::sendPlayerDirect(PClient* author, const char* text, u32 destination, bool debugOut)\r
+void PChat::sendPlayerDirect(PClient* author, const char* text, uint32_t destination, bool debugOut)\r
{\r
bool tmpTargetOnline = false;\r
for(PClientMap::iterator it=ClientManager->getClientListBegin(); it!=ClientManager->getClientListEnd(); it++)\r
if(tmpTargetOnline == false)\r
{\r
ConnectionTCP *Socket = author->getTCPConn();\r
- u8 DirectTargetNotOnline[] = {0xFE, 0x07, 0x00, 0x83, 0x18, 0x01, 0x81, 0x54, 0x00, 0x00};\r
+ uint8_t DirectTargetNotOnline[] = {0xFE, 0x07, 0x00, 0x83, 0x18, 0x01, 0x81, 0x54, 0x00, 0x00};\r
\r
Socket->write(DirectTargetNotOnline, sizeof(DirectTargetNotOnline));\r
Socket->flushSendBuffer();\r
\r
ConnectionTCP *Socket = receiver->getTCPConn();\r
\r
- u8 BasicDirectPacket[] = {0xFE, 0x20, 0x00, 0x83, 0x17, 0xB7, 0x5F, 0x00, 0x00, 0x0C, 0x04, 0x00};\r
+ uint8_t BasicDirectPacket[] = {0xFE, 0x20, 0x00, 0x83, 0x17, 0xB7, 0x5F, 0x00, 0x00, 0x0C, 0x04, 0x00};\r
\r
LenText = LenNick = fpp = 0;\r
\r
return; // IncreaseUDP could cause OOO here. Since this function is doing nothing, we disabled it\r
char *LocalChatPacket;\r
int overallsize = 0, LenText = 0;\r
- u8 BasicLocal[] = { 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x1B };\r
+ uint8_t BasicLocal[] = { 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x1B };\r
\r
// Get size of Text to send\r
do {\r
\r
// Add UdpID, SessionID, lenght and local charid\r
receiver->IncreaseUDP_ID();\r
- *(u16*)&LocalChatPacket[1] = receiver->GetUDP_ID(); // UDP\r
- *(u16*)&LocalChatPacket[3] = receiver->GetSessionID(); // Session\r
- *(u8*)&LocalChatPacket[5] = overallsize - 6; // Packetlen\r
- *(u16*)&LocalChatPacket[7] = receiver->GetUDP_ID(); // 2nd UDP\r
- *(u16*)&LocalChatPacket[10] = author->GetLocalID(); // Local ID\r
+ *(uint16_t*)&LocalChatPacket[1] = receiver->GetUDP_ID(); // UDP\r
+ *(uint16_t*)&LocalChatPacket[3] = receiver->GetSessionID(); // Session\r
+ *(uint8_t*)&LocalChatPacket[5] = overallsize - 6; // Packetlen\r
+ *(uint16_t*)&LocalChatPacket[7] = receiver->GetUDP_ID(); // 2nd UDP\r
+ *(uint16_t*)&LocalChatPacket[10] = author->GetLocalID(); // Local ID\r
\r
// Sending local chat packet and removing dynamic array\r
ConnectionUDP *Socket = receiver->getUDPConn();\r
}\r
}\r
\r
-bool PChat::chanEnabled(PClient* Client, u32 channel)\r
+bool PChat::chanEnabled(PClient* Client, uint32_t channel)\r
{\r
// Check if player has target channel enabled or disabled\r
PChar* TargetChar = Chars->GetChar(Client->GetCharID());\r
if(!TargetChar)\r
return false;\r
\r
- u32 actChans = TargetChar->GetActiveChannels();\r
- u32 check = actChans & channel;\r
+ uint32_t actChans = TargetChar->GetActiveChannels();\r
+ uint32_t check = actChans & channel;\r
\r
if(check == channel)\r
return true;\r
return false;\r
}\r
\r
-bool PChat::send(PClient* receiver, const u8* Channel, const char* AuthorNickName, const char* text, bool debugOut)\r
+bool PChat::send(PClient* receiver, const uint8_t* Channel, const char* AuthorNickName, const char* text, bool debugOut)\r
{\r
char *ChatPacket;\r
unsigned int packetsize = 0, c;\r
int LenText, LenNick, fpp, d, e, loopout;\r
- u8 TargetChannel[2];\r
+ uint8_t TargetChannel[2];\r
\r
//Console->Print("1: %#x", Channel[0]);\r
//Console->Print("2: %#x", CHAT_BUDDY[0]);\r
\r
ConnectionTCP *Socket = receiver->getTCPConn();\r
\r
- u8 BasicChatPacket[] = {0xFE, 0x15, 0x00, 0x83, 0x17, 0x90, 0x03, 0x00, 0x00, 0x07, 0x05, 0x0F};\r
+ uint8_t BasicChatPacket[] = {0xFE, 0x15, 0x00, 0x83, 0x17, 0x90, 0x03, 0x00, 0x00, 0x07, 0x05, 0x0F};\r
\r
LenText = LenNick = fpp = 0;\r
\r
\r
\r
\r
-bool PChat::HandleGameChat(PClient *Client, const u8 *Packet)\r
+bool PChat::HandleGameChat(PClient *Client, const uint8_t *Packet)\r
{\r
// if player is shunned, ignore all incomming chat and game commands.\r
// ServerAdmins are not affected by any shuns. (Should never happen anyways...)\r
\r
int i, j, k;\r
\r
- u8 chattype = *(u8*)&Packet[7];\r
+ uint8_t chattype = *(uint8_t*)&Packet[7];\r
// -----------------------------------------------\r
if(chattype == 0x1B) {\r
// Local chat\r
// Console->Print("Channel no %#x %#x %#x %#x", Channel[0], Channel[1], Channel[2], Channel[3]);\r
\r
// First, check if packet is a direct-chat-packet\r
- if(*(u8*)&Packet[8] == 0x04) {\r
+ if(*(uint8_t*)&Packet[8] == 0x04) {\r
//Console->Print("Direct Chat: %s", ChatText);\r
- sendPlayerDirect(Client, ChatText, *(u32*)&Packet[9], false);\r
+ sendPlayerDirect(Client, ChatText, *(uint32_t*)&Packet[9], false);\r
//sendDirect(Client, ChatText, false);\r
// "DIRECT> %s: %s", PlayerName, ChatText\r
}\r
- else if(*(u32*)Channel == CHANNEL_BUDDY) {\r
+ else if(*(uint32_t*)Channel == CHANNEL_BUDDY) {\r
//Console->Print("Buddy Chat: %s", ChatText);\r
sendBuddy(Client, ChatText, false);\r
// "BUDDY> %s: %s", PlayerName, ChatText\r
}\r
- else if(*(u32*)Channel == CHANNEL_CLAN) {\r
+ else if(*(uint32_t*)Channel == CHANNEL_CLAN) {\r
//Console->Print("Clan Chat: %s", ChatText);\r
sendClan(Client, ChatText, false);\r
// "CLAN> %s: %s", PlayerName, ChatText\r
}\r
- else if(*(u32*)Channel == CHANNEL_TEAM) {\r
+ else if(*(uint32_t*)Channel == CHANNEL_TEAM) {\r
//Console->Print("Team Chat: %s", ChatText);\r
sendTeam(Client, ChatText, false);\r
// "TEAM> %s: %s", PlayerName, ChatText\r
}\r
- else if(*(u32*)Channel == CHANNEL_CUS_ZONE) {\r
+ else if(*(uint32_t*)Channel == CHANNEL_CUS_ZONE) {\r
//Console->Print("Custom - Zone Chat: %s", ChatText);\r
sendZone(Client, ChatText, false);\r
// "ZONE> %s: %s", PlayerName, ChatText\r
}\r
- else if(*(u32*)Channel == CHANNEL_CUS_FRAKTION) {\r
+ else if(*(uint32_t*)Channel == CHANNEL_CUS_FRAKTION) {\r
//Console->Print("Custom - Fraktion Chat: %s", ChatText);\r
sendFrak(Client, ChatText, false);\r
// "FRACTION> %s: %s", PlayerName, ChatText\r
}\r
- else if(*(u32*)Channel == CHANNEL_CUS_TRADE_CANYON) {\r
+ else if(*(uint32_t*)Channel == CHANNEL_CUS_TRADE_CANYON) {\r
//Console->Print("Custom - Trade_Canyon Chat: %s", ChatText);\r
sendTradeCS(Client, ChatText, false);\r
// "TRADE - CS> %s: %s", PlayerName, ChatText\r
}\r
- else if(*(u32*)Channel == CHANNEL_CUS_TRADE_MB) {\r
+ else if(*(uint32_t*)Channel == CHANNEL_CUS_TRADE_MB) {\r
//Console->Print("Custom - Trade_MB Chat: %s", ChatText);\r
sendTradeMB(Client, ChatText, false);\r
// "TRADE - MB> %s: %s", PlayerName, ChatText\r
}\r
- else if(*(u32*)Channel == CHANNEL_CUS_TRADE_NC) {\r
+ else if(*(uint32_t*)Channel == CHANNEL_CUS_TRADE_NC) {\r
//Console->Print("Custom - Trade_NC Chat: %s", ChatText);\r
sendTradeNC(Client, ChatText, false);\r
// "TRADE - NC> %s: %s", PlayerName, ChatText\r
}\r
- else if(*(u32*)Channel == CHANNEL_CUS_TRADE_TH) {\r
+ else if(*(uint32_t*)Channel == CHANNEL_CUS_TRADE_TH) {\r
//Console->Print("Custom - Trade_TH Chat: %s", ChatText);\r
sendTradeTH(Client, ChatText, false);\r
// "TRADE - TH> %s: %s", PlayerName, ChatText\r
}\r
- else if(*(u32*)Channel == CHANNEL_CUS_TRADE_WASTE) {\r
+ else if(*(uint32_t*)Channel == CHANNEL_CUS_TRADE_WASTE) {\r
//Console->Print("Custom - Trade_Waste Chat: %s", ChatText);\r
sendTradeWL(Client, ChatText, false);\r
// "TRADE - WL> %s: %s", PlayerName, ChatText\r
}\r
- else if(*(u32*)Channel == CHANNEL_CUS_OOC) {\r
+ else if(*(uint32_t*)Channel == CHANNEL_CUS_OOC) {\r
//Console->Print("Custom - OOC Chat: %s", ChatText);\r
sendOOC(Client, ChatText, false);\r
// "OOC> %s: %s", PlayerName, ChatText\r
}\r
- else if(*(u32*)Channel == CHANNEL_CUS_PLAYERHELP) {\r
+ else if(*(uint32_t*)Channel == CHANNEL_CUS_PLAYERHELP) {\r
//Console->Print("Custom - PlayerToPlayerhelp Chat: %s", ChatText);\r
sendHelp(Client, ChatText, false);\r
// "HELP> %s: %s", PlayerName, ChatText\r
}\r
- else if(*(u32*)Channel == CHANNEL_CUS_CLANSEARCH) {\r
+ else if(*(uint32_t*)Channel == CHANNEL_CUS_CLANSEARCH) {\r
//Console->Print("Custom - Clansearch Chat: %s", ChatText);\r
sendClanSearch(Client, ChatText, false);\r
// "CLANSEARCH> %s: %s", PlayerName, ChatText\r
}\r
- else if(*(u32*)Channel == CHANNEL_CUS_SERVICES_CANYON) {\r
+ else if(*(uint32_t*)Channel == CHANNEL_CUS_SERVICES_CANYON) {\r
//Console->Print("Custom - Services_Canyon Chat: %s", ChatText);\r
sendServicesCS(Client, ChatText, false);\r
// "SKILL - CS> %s: %s", PlayerName, ChatText\r
}\r
- else if(*(u32*)Channel == CHANNEL_CUS_SERVICES_MB) {\r
+ else if(*(uint32_t*)Channel == CHANNEL_CUS_SERVICES_MB) {\r
//Console->Print("Custom - Services_MB Chat: %s", ChatText);\r
sendServicesMB(Client, ChatText, false);\r
// "SKILL - MB> %s: %s", PlayerName, ChatText\r
}\r
- else if(*(u32*)Channel == CHANNEL_CUS_SERVICES_NC) {\r
+ else if(*(uint32_t*)Channel == CHANNEL_CUS_SERVICES_NC) {\r
//Console->Print("Custom - Services_NC Chat: %s", ChatText);\r
sendServicesNC(Client, ChatText, false);\r
// "SKILL - NC> %s: %s", PlayerName, ChatText\r
}\r
- else if(*(u32*)Channel == CHANNEL_CUS_SERVICES_TH) {\r
+ else if(*(uint32_t*)Channel == CHANNEL_CUS_SERVICES_TH) {\r
//Console->Print("Custom - Services_TH Chat: %s", ChatText);\r
sendServicesTH(Client, ChatText, false);\r
// "SKILL - TH> %s: %s", PlayerName, ChatText\r
}\r
- else if(*(u32*)Channel == CHANNEL_CUS_SERVICES_WASTE) {\r
+ else if(*(uint32_t*)Channel == CHANNEL_CUS_SERVICES_WASTE) {\r
//Console->Print("Custom - Services_Waste Chat: %s", ChatText);\r
sendServicesWL(Client, ChatText, false);\r
// "SKILL - WL> %s: %s", PlayerName, ChatText\r
}\r
- else if(*(u32*)Channel == CHANNEL_CUS_TEAM_10) {\r
+ else if(*(uint32_t*)Channel == CHANNEL_CUS_TEAM_10) {\r
//Console->Print("Custom - Team10 Chat: %s", ChatText);\r
sendTeam10(Client, ChatText, false);\r
// "TEAMSEARCH 10> %s: %s", PlayerName, ChatText\r
}\r
- else if(*(u32*)Channel == CHANNEL_CUS_TEAM_30) {\r
+ else if(*(uint32_t*)Channel == CHANNEL_CUS_TEAM_30) {\r
//Console->Print("Custom - Team30 Chat: %s", ChatText);\r
sendTeam30(Client, ChatText, false);\r
// "EAMSEARCH 30> %s: %s", PlayerName, ChatText\r
}\r
- else if(*(u32*)Channel == CHANNEL_CUS_TEAM_50) {\r
+ else if(*(uint32_t*)Channel == CHANNEL_CUS_TEAM_50) {\r
//Console->Print("Custom - Team50 Chat: %s", ChatText);\r
sendTeam50(Client, ChatText, false);\r
// "EAMSEARCH 50> %s: %s", PlayerName, ChatText\r
}\r
- else if(*(u32*)Channel == CHANNEL_CUS_TEAM_70) {\r
+ else if(*(uint32_t*)Channel == CHANNEL_CUS_TEAM_70) {\r
//Console->Print("Custom - Team70 Chat: %s", ChatText);\r
sendTeam70(Client, ChatText, false);\r
// "EAMSEARCH 70> %s: %s", PlayerName, ChatText\r
}\r
- else if(*(u32*)Channel == CHANNEL_ADMIN) {\r
+ else if(*(uint32_t*)Channel == CHANNEL_ADMIN) {\r
//Console->Print("Admin Chat: %s", ChatText);\r
sendAdmin(Client, ChatText, false);\r
// "ADMIN> %s: %s", PlayerName, ChatText\r
}\r
- else if(*(u32*)Channel == CHANNEL_GMADMIN) {\r
+ else if(*(uint32_t*)Channel == CHANNEL_GMADMIN) {\r
//Console->Print("Admin Chat: %s", ChatText);\r
sendGMAdmin(Client, ChatText, false);\r
// "ADMIN> %s: %s", PlayerName, ChatText\r
}\r
- else if(*(u32*)Channel == CHANNEL_GMCHAT) {\r
+ else if(*(uint32_t*)Channel == CHANNEL_GMCHAT) {\r
//Console->Print("GameMaster Chat: %s", ChatText);\r
sendGM(Client, ChatText, false);\r
// "GM> %s: %s", PlayerName, ChatText\r
}\r
else {\r
- Console->Print("Unknown Chat-Channel: %#x", *(u32*)Channel);\r
+ Console->Print("Unknown Chat-Channel: %#x", *(uint32_t*)Channel);\r
};\r
}\r
}\r
return (true);\r
}\r
\r
-bool PChat::cmpr(const u8 *Array1, const u8 *Array2) {\r
+bool PChat::cmpr(const uint8_t *Array1, const uint8_t *Array2) {\r
if(Array1[0] == Array2[0] && Array1[1] == Array2[1]) {\r
return true;\r
} else {\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+\r
+#define LOCALCHAT_MAXDISTANCE 1433\r
+\r
+class PClient;\r
+\r
+class PChat {\r
+public:\r
+ PChat();\r
+ ~PChat();\r
+\r
+ // INCOMING CHAT\r
+ bool HandleGameChat(PClient *Client, const uint8_t *Packet);\r
+ bool cmpr(const uint8_t *Array1, const uint8_t *Array2);\r
+\r
+ // this function is called by the other more specific functions and simply sends the data to the receiver-client\r
+ bool send(PClient* receiver, const uint8_t* Channel, const char* AuthorNickName, const char* text, bool debugOut=false);\r
+\r
+ // this is for debugging and sends the current connected playerlist to the receiver-client\r
+ void sendConnectedList(PClient* receiver, bool debugOut=false);\r
+\r
+ // specific channel functions:\r
+ void sendBuddy(PClient* author, const char* text, bool debugOut=false);\r
+ void sendLocal(PClient* author, const char* text, bool debugOut=false);\r
+ void sendClan(PClient* author, const char* text, bool debugOut=false);\r
+ void sendTeam(PClient* author, const char* text, bool debugOut=false);\r
+ void sendDirect(PClient* author, PClient* receiver, const char* text, bool debugOut=false);\r
+ void sendZone(PClient* author, const char* text, bool debugOut=false);\r
+ void sendFrak(PClient* author, const char* text, bool debugOut=false);\r
+ void sendTradeCS(PClient* author, const char* text, bool debugOut=false);\r
+ void sendTradeMB(PClient* author, const char* text, bool debugOut=false);\r
+ void sendTradeNC(PClient* author, const char* text, bool debugOut=false);\r
+ void sendTradeTH(PClient* author, const char* text, bool debugOut=false);\r
+ void sendTradeWL(PClient* author, const char* text, bool debugOut=false);\r
+ void sendOOC(PClient* author, const char* text, bool debugOut=false);\r
+ void sendHelp(PClient* author, const char* text, bool debugOut=false);\r
+ void sendClanSearch(PClient* author, const char* text, bool debugOut=false);\r
+ void sendServicesCS(PClient* author, const char* text, bool debugOut=false);\r
+ void sendServicesMB(PClient* author, const char* text, bool debugOut=false);\r
+ void sendServicesNC(PClient* author, const char* text, bool debugOut=false);\r
+ void sendServicesTH(PClient* author, const char* text, bool debugOut=false);\r
+ void sendServicesWL(PClient* author, const char* text, bool debugOut=false);\r
+ void sendTeam10(PClient* author, const char* text, bool debugOut=false);\r
+ void sendTeam30(PClient* author, const char* text, bool debugOut=false);\r
+ void sendTeam50(PClient* author, const char* text, bool debugOut=false);\r
+ void sendTeam70(PClient* author, const char* text, bool debugOut=false);\r
+ void sendAdmin(PClient* author, const char* text, bool debugOut=false);\r
+ void sendGM(PClient* author, const char* text, bool debugOut=false);\r
+ void sendGMAdmin(PClient* author, const char* text, bool debugOut=false);\r
+\r
+ void sendBroadcast(const char* text, bool debugOut=false);\r
+ void sendOOCBroadcast(const char* text, bool debugOut=false);\r
+ void sendPlayerDirect(PClient* author, const char* text, uint32_t destination, bool debugOut=false);\r
+ void sendLocalchat(PClient* receiver, PClient* author, const char* text, bool debugOut=false);\r
+ bool chanEnabled(PClient* Client, uint32_t channel);\r
+};\r
+\r
+/** A WARNING: DO >N O T< (!!!) CHANGE >ANY< OF THE FOLLOWING VARIABLES UNLESS YOU KNOW EXACT WHAT YOU'RE DOING! **/\r
+/** You can easily mess up the entire chat subsystem. If you're unsure, ask Namikon first! **/\r
+/*\r
+####################\r
+ CHANNEL-CODES:\r
+ (INCOMING)\r
+####################\r
+*/\r
+static const uint32_t CHANNEL_BUDDY = 0x00000000; // Buddy\r
+static const uint32_t CHANNEL_CLAN = 0x00000002; // Clan\r
+static const uint32_t CHANNEL_TEAM = 0x00000003; // Team\r
+static const uint32_t CHANNEL_DIRECT = 0xFFFFFFFF; // Direct UNKNOWN YET\r
+static const uint32_t CHANNEL_CUS_ZONE = 0x00000105; // Custom -> Zone\r
+static const uint32_t CHANNEL_CUS_FRAKTION = 0x00000205; // Custom -> Fraktion\r
+static const uint32_t CHANNEL_CUS_TRADE_CANYON = 0x00002005; // Custom -> Trade Canyon\r
+static const uint32_t CHANNEL_CUS_TRADE_MB = 0x00000805; // Custom -> Trade MB\r
+static const uint32_t CHANNEL_CUS_TRADE_NC = 0x00000405; // Custom -> Trade NC\r
+static const uint32_t CHANNEL_CUS_TRADE_TH = 0x00001005; // Custom -> Trade TH\r
+static const uint32_t CHANNEL_CUS_TRADE_WASTE = 0x00004005; // Custom -> Trade Wastelands\r
+static const uint32_t CHANNEL_CUS_OOC = 0x04000005; // Custom -> OOC\r
+static const uint32_t CHANNEL_CUS_PLAYERHELP = 0x02000005; // Custom -> Player 2 Player help\r
+static const uint32_t CHANNEL_CUS_CLANSEARCH = 0x01000005; // Custom -> Searching Clan\r
+static const uint32_t CHANNEL_CUS_SERVICES_CANYON = 0x00040005; // Custom -> Runner Services Canyon\r
+static const uint32_t CHANNEL_CUS_SERVICES_MB = 0x00010005; // Custom -> Runner Services MB\r
+static const uint32_t CHANNEL_CUS_SERVICES_NC = 0x00008005; // Custom -> Runner Services NC\r
+static const uint32_t CHANNEL_CUS_SERVICES_TH = 0x00020005; // Custom -> Runner Services TH\r
+static const uint32_t CHANNEL_CUS_SERVICES_WASTE = 0x00080005; // Custom -> Runner Services Wastelands\r
+static const uint32_t CHANNEL_CUS_TEAM_10 = 0x00100005; // Custom -> Searching Team ~10\r
+static const uint32_t CHANNEL_CUS_TEAM_30 = 0x00200005; // Custom -> Searching Team ~30\r
+static const uint32_t CHANNEL_CUS_TEAM_50 = 0x00400005; // Custom -> Searching Team ~50\r
+static const uint32_t CHANNEL_CUS_TEAM_70 = 0x00800005; // Custom -> Searching Team ~70\r
+static const uint32_t CHANNEL_ADMIN = 0x000000FF; // Admin chat\r
+static const uint32_t CHANNEL_GMADMIN = 0x000000FE; // Admin chat\r
+static const uint32_t CHANNEL_GMCHAT = 0x000000FD; // GameMaster chat\r
+/*\r
+####################\r
+ CHANNEL-CODES:\r
+ (OUTGOING)\r
+####################\r
+*/\r
+static const uint8_t CHAT_BUDDY[] = {0x00, 0x10};\r
+static const uint8_t CHAT_LOCAL[] = {0x01, 0x10};\r
+static const uint8_t CHAT_CLAN[] = {0x02, 0x10};\r
+static const uint8_t CHAT_TEAM[] = {0x03, 0x10};\r
+static const uint8_t CHAT_DIRECT[] = {0x04, 0x10};\r
+static const uint8_t CHAT_ZONE[] = {0x05, 0x00};\r
+static const uint8_t CHAT_FRAK[] = {0x05, 0x01};\r
+static const uint8_t CHAT_TRADECS[] = {0x05, 0x05};\r
+static const uint8_t CHAT_TRADEMB[] = {0x05, 0x03};\r
+static const uint8_t CHAT_TRADENC[] = {0x05, 0x02};\r
+static const uint8_t CHAT_TRADETH[] = {0x05, 0x04};\r
+static const uint8_t CHAT_TRADEWL[] = {0x05, 0x06};\r
+static const uint8_t CHAT_OOC[] = {0x05, 0x12};\r
+static const uint8_t CHAT_HELP[] = {0x05, 0x11};\r
+static const uint8_t CHAT_CLANSEARCH[] = {0x05, 0x10};\r
+static const uint8_t CHAT_SERVICECS[] = {0x05, 0x0A};\r
+static const uint8_t CHAT_SERVICESMB[] = {0x05, 0x08};\r
+static const uint8_t CHAT_SERVICESNC[] = {0x05, 0x07};\r
+static const uint8_t CHAT_SERVICESTH[] = {0x05, 0x09};\r
+static const uint8_t CHAT_SERVICESWL[] = {0x05, 0x0B};\r
+static const uint8_t CHAT_TEAM10[] = {0x05, 0x0C};\r
+static const uint8_t CHAT_TEAM30[] = {0x05, 0x0D};\r
+static const uint8_t CHAT_TEAM50[] = {0x05, 0x0E};\r
+static const uint8_t CHAT_TEAM70[] = {0x05, 0x0F};\r
+static const uint8_t CHAT_ADMIN[] = {0xFF, 0x10};\r
+static const uint8_t CHAT_GMADMIN[] = {0xFE, 0x10};\r
+static const uint8_t CHAT_GM[] = {0xFD, 0x10};\r
+\r
+/*\r
+####################\r
+ CHANNEL-CODES:\r
+(EN/DISABLE-ABLE CHANNELS)\r
+####################\r
+*/\r
+static const uint32_t C_ZONE = 1;\r
+static const uint32_t C_FRAK = 2;\r
+static const uint32_t C_TRADENC = 4;\r
+static const uint32_t C_TRADEMB = 8;\r
+static const uint32_t C_TRADETH = 16;\r
+static const uint32_t C_TRADECS = 32;\r
+static const uint32_t C_TRADEWL = 64;\r
+static const uint32_t C_SERVICENC = 128;\r
+static const uint32_t C_SERVICEMB = 256;\r
+static const uint32_t C_SERVICETH = 512;\r
+static const uint32_t C_SERVICECS = 1024;\r
+static const uint32_t C_SERVICEWL = 2048;\r
+static const uint32_t C_TEAM10 = 4096;\r
+static const uint32_t C_TEAM30 = 8192;\r
+static const uint32_t C_TEAM50 = 16384;\r
+static const uint32_t C_TEAM70 = 32768;\r
+static const uint32_t C_CLANSEARCH = 65536;\r
+static const uint32_t C_HELP = 131072;\r
+static const uint32_t C_OOC = 262144;\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- client.cpp\r
-\r
- Authors:\r
- - v00d00\r
- - Akiko\r
- - Namikon\r
-\r
- MODIFIED: 30 Nov 2005 Akiko\r
- REASON: - added GPL\r
- - added modifications by Namikon\r
- MODIFIED: 09 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
-*/\r
-\r
-#include "main.h"\r
-\r
-#include "include/worlds.h"\r
-#include "include/msgbuilder.h"\r
-#include "include/subway.h"\r
-#include "decoder/udp_charmove.h"\r
+#include "GameServer/Includes.hxx"\r
+#include "GameServer/Decoder/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
PClient::PClient( int Index )\r
{\r
}\r
/// ******************************************************\r
\r
-u16 PClient::GetUDP_ID()\r
+bool PClient::GetDebugMode(PDebugMode nDebugID)\r
+{\r
+ return mDebugMode[nDebugID];\r
+}\r
+\r
+bool PClient::IsAcceptingNPCUpdates()\r
+{\r
+ return mAcceptNPCUpdates;\r
+}\r
+\r
+void PClient::SetAcceptNPCUpdates(bool nVal)\r
+{\r
+ mAcceptNPCUpdates = nVal;\r
+}\r
+\r
+bool PClient::IsZoning()\r
+{\r
+ return mZoning;\r
+}\r
+\r
+void PClient::SetZoning(bool nVal)\r
+{\r
+ mZoning = nVal;\r
+ if (!nVal)\r
+ mVhcZoning = false;\r
+}\r
+\r
+bool PClient::IsVhcZoning()\r
+{\r
+ return mVhcZoning;\r
+}\r
+\r
+void PClient::SetVhcZoning(bool nVal)\r
+{\r
+ mVhcZoning = nVal;\r
+}\r
+\r
+uint32_t PClient::GetIndex() const\r
+{\r
+ return mIndex;\r
+}\r
+\r
+uint32_t PClient::GetID() const\r
+{\r
+ return mIndex;\r
+}\r
+\r
+uint32_t PClient::GetLocalID() const\r
+{\r
+ return mIndex + 1;\r
+}\r
+\r
+uint32_t PClient::GetCharID() const\r
+{\r
+ return mCharID;\r
+}\r
+\r
+int PClient::GetRemoteUDPPort() const\r
+{\r
+ return mRemotePort;\r
+}\r
+\r
+bool PClient::IsInRemoveActorMode()\r
+{\r
+ return mActorRemoveMode;\r
+}\r
+\r
+void PClient::SetRemoveActorMode(bool nNewValue)\r
+{\r
+ mActorRemoveMode = nNewValue;\r
+}\r
+\r
+void PClient::SetRemoteUDPPort(int port)\r
+{\r
+ mRemotePort = port;\r
+}\r
+\r
+void PClient::SetCharID(int id)\r
+{\r
+ mCharID = id;\r
+}\r
+\r
+uint16_t PClient::GetUDP_ID()\r
{\r
if ( m_UDPConnection )\r
return m_UDPConnection->GetUDP_ID();\r
Console->Print( "%s Unable to increase UDP_ID, UDP ConnectionClass is not yet initialized!", Console->ColorText( RED, BLACK, "[WARNING]" ) );\r
}\r
\r
-u16 PClient::GetSessionID()\r
+uint16_t PClient::GetSessionID()\r
{\r
if ( m_UDPConnection )\r
return m_UDPConnection->GetSessionID();\r
return 0;\r
}\r
\r
-u16 PClient::GetTransactionID()\r
+uint16_t PClient::GetTransactionID()\r
{\r
if ( m_UDPConnection )\r
return m_UDPConnection->GetTransactionID();\r
Console->Print( "%s Unable to reset UDP TransactionID, UDP ConnectionClass is not yet initialized!", Console->ColorText( RED, BLACK, "[WARNING]" ) );\r
}\r
\r
-void PClient::IncreaseTransactionID( u8 nInc )\r
+void PClient::IncreaseTransactionID( uint8_t nInc )\r
{\r
if ( m_UDPConnection )\r
m_UDPConnection->IncreaseTransactionID( nInc );\r
\r
void PClient::FillInUDP_ID( PMessage* nMessage )\r
{\r
- u16 CurrPos;\r
+ uint16_t CurrPos;\r
\r
if (( nMessage->GetSize() > 9 ) && ( nMessage->U8Data( 0x00 ) == 0x13 ) )\r
{\r
nMessage->U16Data( 0x03 ) = GetSessionID();\r
}\r
\r
-void PClient::FragmentAndSendUDPMessage( PMessage* nMessage, u8 nType )\r
+void PClient::setTCPConnection(ConnectionTCP *conn)\r
+{\r
+ m_TCPConnection = conn;\r
+ m_UDPConnection = nullptr;\r
+ mConnection = PCC_GAME;\r
+}\r
+\r
+void PClient::setUDPConnection(ConnectionUDP *conn)\r
+{\r
+ m_UDPConnection = conn;\r
+}\r
+\r
+ConnectionTCP *PClient::getTCPConn()\r
+{\r
+ return m_TCPConnection;\r
+}\r
+\r
+ConnectionUDP *PClient::getUDPConn()\r
+{\r
+ return m_UDPConnection;\r
+}\r
+\r
+void PClient::SendTCPMessage(PMessage *nMessage)\r
+{\r
+ if (m_TCPConnection)\r
+ m_TCPConnection->SendMessage(nMessage);\r
+ else\r
+ delete nMessage;\r
+}\r
+\r
+void PClient::FragmentAndSendUDPMessage( PMessage* nMessage, uint8_t nType )\r
{\r
PMessage* ChunkBuffer;\r
PMessage* ChunkMsg;\r
- const u16 ChunkSize = 220;\r
- u16 StartIncUDPIDOnChunk = 0;\r
- u16 IncludedHeaderSize = 0;\r
+ const uint16_t ChunkSize = 220;\r
+ uint16_t StartIncUDPIDOnChunk = 0;\r
+ uint16_t IncludedHeaderSize = 0;\r
bool ReplaceFirstByte = false;\r
- u8 ReplaceFirstByteValue = 0;\r
- u16 MultiTriggeringSize = 0;\r
+ uint8_t ReplaceFirstByteValue = 0;\r
+ uint16_t MultiTriggeringSize = 0;\r
\r
switch ( nType )\r
{\r
nMessage->U8Data( IncludedHeaderSize ) = ReplaceFirstByteValue;\r
}\r
\r
- u16 ChunksNum = ( nMessage->GetSize() - IncludedHeaderSize + ChunkSize - 1 ) / ChunkSize;\r
+ uint16_t ChunksNum = ( nMessage->GetSize() - IncludedHeaderSize + ChunkSize - 1 ) / ChunkSize;\r
\r
- for ( u16 ChunkID = 0; ChunkID < ChunksNum; ChunkID++ )\r
+ for ( uint16_t ChunkID = 0; ChunkID < ChunksNum; ChunkID++ )\r
{\r
ChunkBuffer = nMessage->GetChunk( IncludedHeaderSize, ChunkSize, ChunkID );\r
if ( ChunkBuffer == NULL )\r
IncreaseUDP_ID();\r
}\r
\r
- *ChunkMsg << ( u8 )0x13;\r
- *ChunkMsg << ( u16 )GetUDP_ID();\r
- *ChunkMsg << ( u16 )GetSessionID();\r
- *ChunkMsg << ( u8 )( 9 + ChunkBuffer->GetSize() );\r
- *ChunkMsg << ( u8 )0x03;\r
- *ChunkMsg << ( u16 )GetUDP_ID();\r
- *ChunkMsg << ( u8 )0x07; // Fragmented\r
- *ChunkMsg << ( u16 )ChunkID;\r
- *ChunkMsg << ( u16 )ChunksNum;\r
- *ChunkMsg << ( u8 )nType;\r
+ *ChunkMsg << ( uint8_t )0x13;\r
+ *ChunkMsg << ( uint16_t )GetUDP_ID();\r
+ *ChunkMsg << ( uint16_t )GetSessionID();\r
+ *ChunkMsg << ( uint8_t )( 9 + ChunkBuffer->GetSize() );\r
+ *ChunkMsg << ( uint8_t )0x03;\r
+ *ChunkMsg << ( uint16_t )GetUDP_ID();\r
+ *ChunkMsg << ( uint8_t )0x07; // Fragmented\r
+ *ChunkMsg << ( uint16_t )ChunkID;\r
+ *ChunkMsg << ( uint16_t )ChunksNum;\r
+ *ChunkMsg << ( uint8_t )nType;\r
*ChunkMsg << *ChunkBuffer;\r
\r
delete ChunkBuffer;\r
}\r
}\r
\r
-/// ******************************************************\r
+void PClient::SendUDPMessage(PMessage *nMessage, bool nVIP)\r
+{\r
+ if (m_UDPConnection)\r
+ m_UDPConnection->SendMessage(nMessage, nVIP);\r
+ else\r
+ delete nMessage;\r
+}\r
\r
void PClient::SetDebugMode( PDebugMode nDebugID, bool nVal )\r
{\r
mDebugMode[nDebugID] = nVal;\r
}\r
\r
-bool PClient::ChangeCharLocation( u32 nLocation, bool DoForce )\r
+bool PClient::ChangeCharLocation( uint32_t nLocation, bool DoForce )\r
{\r
if ( gDevDebug )\r
Console->Print( "%s PClient::ChangeCharLocation", Console->ColorText( CYAN, BLACK, "[DEBUG]" ) );\r
{\r
mAcceptNPCUpdates = false; // Zone changed, reject NPC updates till initial NPC spawn\r
PChar* tChar = GetChar();\r
- u32 CurrentLocation = tChar->GetLocation();\r
+ uint32_t CurrentLocation = tChar->GetLocation();\r
if (( CurrentLocation == nLocation ) && !DoForce )\r
return true;\r
\r
if ( tChar->GetLocationLeased() )\r
{\r
// TAke care of sitting chars\r
- u32 ChairObjectId;\r
- u8 tSeatId;\r
+ uint32_t ChairObjectId;\r
+ uint8_t tSeatId;\r
PSeatType tSeatType;\r
if (( tSeatType = tChar->GetSeatInUse( &ChairObjectId, &tSeatId ) ) )\r
{\r
PSpawnedVehicle* tVhc = 0;\r
if ( (tSeatType == seat_vhc) && IsVhcZoning() ) // If seat is vhc,\r
{ // Do additionnal check\r
- if (( tVhc = nWorld->GetSpawnedVehicules()->GetVehicle( ChairObjectId ) ) )\r
+ if (( tVhc = nWorld->GetSpawnedVehicles()->GetVehicle( ChairObjectId ) ) )\r
{\r
if ( tVhc->GetSeatUser( tSeatId ) == tChar->GetID() )\r
{\r
return false;\r
}\r
\r
+int PClient::GetConnection() const\r
+{\r
+ return mConnection;\r
+}\r
+\r
+const char *PClient::GetAddress() const\r
+{\r
+ return m_TCPConnection->getRemoteAddress();\r
+}\r
+\r
+uint32_t PClient::GetAccountID() const\r
+{\r
+ return mAccountID;\r
+}\r
+\r
+int PClient::GetAccountLevel() const\r
+{\r
+ return mAccountLevel;\r
+}\r
+\r
void PClient::GameDisconnect()\r
{\r
mAccountID = 0;\r
}\r
/* // replaced by the lines above\r
PSeatType cSeatType;\r
- u32 cSeatObjectId;\r
- u8 cSeatId;\r
+ uint32_t cSeatObjectId;\r
+ uint8_t cSeatId;\r
PWorld* cWorld;\r
\r
cWorld = Worlds->GetWorld(tChar->GetLocation());\r
}\r
else if(cSeatType == seat_vhc)\r
{\r
- cWorld->GetSpawnedVehicules()->GetVehicle(cSeatObjectId)->UnsetSeatUser(cSeatId, GetLocalID());\r
+ cWorld->GetSpawnedVehicles()->GetVehicle(cSeatObjectId)->UnsetSeatUser(cSeatId, GetLocalID());\r
tChar->SetSeatInUse(seat_none);\r
}\r
else\r
mAccountLevel = Account->GetLevel();\r
}\r
\r
+void PClient::LoggedIn(PAccount *Account)\r
+{\r
+ RefreshAccountInfo(Account);\r
+}\r
+\r
void PClient::Update()\r
{\r
if ( m_TCPConnection )\r
}\r
}\r
\r
-bool PClient::GetCharAwaitingWarpto( u16* PosX, u16* PosY, u16* PosZ )\r
+int PClient::getZoneID() const\r
+{\r
+ return m_ZoneID;\r
+}\r
+\r
+void PClient::SetAwaitingWarpto(bool yesno, uint16_t NewX, uint16_t NewY, uint16_t NewZ)\r
+{\r
+ mAwaitingWarpto = yesno;\r
+ mTargetX = NewX;\r
+ mTargetY = NewY;\r
+ mTargetZ = NewZ;\r
+}\r
+\r
+bool PClient::GetCharAwaitingWarpto( uint16_t* PosX, uint16_t* PosY, uint16_t* PosZ )\r
{\r
if ( PosX )\r
*PosX = mTargetX;\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+\r
+class ConnectionTCP;\r
+class ConnectionUDP;\r
+class PMessage;\r
+\r
+// TODO: - check that SetUDP_ID, and the mSessionID(UDP_ID_HIGH) real use,\r
+// and if UDP_ID and mSessionID must be synced (like in NeoX) or not\r
+\r
+enum PClientConnection\r
+{\r
+ PCC_NONE = 0,\r
+ PCC_GAME = 1\r
+};\r
+\r
+// AccountLevel handling is part of accounts.cpp\r
+/*\r
+enum PClientLevel\r
+{\r
+ PCL_BANNED = -1,\r
+ PCL_UNREGPLAYER = 0,\r
+ PCL_REGPLAYER = 1,\r
+ PCL_VOLUNTEER = 30,\r
+ PCL_GM = 50,\r
+ PCL_ADMIN = 100\r
+};\r
+*/\r
+#define DEBUG_MODES 3\r
+enum PDebugMode\r
+{\r
+ DBG_LOCATION = 0,\r
+ DBG_ITEMID = 1,\r
+ DBG_SUBWAY = 2,\r
+ DBG_ALL = DEBUG_MODES // must always be last, with DEBUG_MODES updated as needed\r
+};\r
+\r
+\r
+class PClient\r
+{\r
+ private :\r
+ ConnectionTCP* m_TCPConnection;\r
+ ConnectionUDP* m_UDPConnection;\r
+\r
+ uint32_t mAccountID;\r
+ int mAccountLevel;\r
+ uint32_t mIndex;\r
+ uint32_t mCharID;\r
+\r
+// uint16_t mUDP_ID;\r
+// uint16_t mSessionID;\r
+// uint16_t mTransactionID;\r
+\r
+ // AccountLevel handling is part of accounts.cpp\r
+ //PClientLevel mLevel;\r
+ int mConnection;\r
+ int mRemotePort;\r
+\r
+ bool mDebugMode[DEBUG_MODES];\r
+ // new multiuser-chat implementation //\r
+ int m_ZoneID;\r
+ //int[4] m_IP;\r
+\r
+ //*******\r
+ bool mActorRemoveMode;\r
+ //*******\r
+ bool mAwaitingWarpto;\r
+ uint16_t mTargetX;\r
+ uint16_t mTargetY;\r
+ uint16_t mTargetZ;\r
+ //*******\r
+ bool mAcceptNPCUpdates;\r
+ bool mZoning;\r
+ bool mVhcZoning;\r
+\r
+ public :\r
+ PClient( int Index );\r
+ ~PClient();\r
+\r
+ bool GetDebugMode(PDebugMode nDebugID);\r
+ void SetDebugMode(PDebugMode nDebugID, bool nVal = true);\r
+\r
+ bool IsAcceptingNPCUpdates();\r
+ void SetAcceptNPCUpdates(bool nVal);\r
+ bool IsZoning();\r
+ void SetZoning(bool nVal = true);\r
+ bool IsVhcZoning();\r
+ void SetVhcZoning(bool nVal = true);\r
+\r
+ uint32_t GetIndex() const; // better use GetID()\r
+ uint32_t GetID() const; // for better coherency with other classes\r
+ uint32_t GetLocalID() const;\r
+ uint32_t GetCharID() const;\r
+ PChar* GetChar() const;\r
+ bool ChangeCharLocation(uint32_t nLocation, bool DoForce = false);\r
+\r
+ int GetRemoteUDPPort() const; // Temp solution\r
+\r
+ bool IsInRemoveActorMode();\r
+ void SetRemoveActorMode(bool nNewValue);\r
+\r
+ void SetRemoteUDPPort(int port); // Temp solution\r
+ void SetCharID(int id);//NEW added\r
+\r
+ /*\r
+ inline uint16_t GetUDP_ID() const { return mUDP_ID; }\r
+ inline uint16_t GetSessionID() const { return SESSION_UDP_OFFSET + mUDP_ID ; }\r
+ inline uint16_t GetTransactionID() {return mTransactionID; }\r
+ void SetUDP_ID(int id);\r
+ inline void IncreaseUDP_ID() { SetUDP_ID(mUDP_ID + 1); }\r
+ inline void ResetTransactionID() { mTransactionID = 10170; }\r
+\r
+ inline void IncreaseTransactionID(uint8_t nInc = 1) { mTransactionID += nInc; }\r
+ */\r
+\r
+ // All outgoing ID's and stuff is now part of the ConnectionUDP class itself!\r
+ // (which is not so good.... comment from Hammag)\r
+ // However, we still have full access to it through these functions\r
+ uint16_t GetUDP_ID();\r
+ void SetUDP_ID( int id );\r
+ void IncreaseUDP_ID();\r
+\r
+ uint16_t GetSessionID();\r
+\r
+ uint16_t GetTransactionID();\r
+ void ResetTransactionID();\r
+ void IncreaseTransactionID( uint8_t nInc = 1 );\r
+\r
+ void FillInUDP_ID( PMessage* nMessage );\r
+\r
+// ************************************************************************ //\r
+ // AccountLevel handling is part of accounts.cpp\r
+ //inline PClientLevel GetLevel() const { return mLevel; }\r
+\r
+ void setTCPConnection(ConnectionTCP *conn);\r
+ void setUDPConnection(ConnectionUDP *conn);\r
+\r
+ ConnectionTCP* getTCPConn();\r
+ ConnectionUDP* getUDPConn();\r
+\r
+ void SendTCPMessage(PMessage *nMessage);\r
+ void FragmentAndSendUDPMessage( PMessage* nMessage, uint8_t nType );\r
+ void SendUDPMessage(PMessage *nMessage, bool nVIP = false);\r
+\r
+ int GetConnection() const;\r
+ const char *GetAddress() const;\r
+ uint32_t GetAccountID() const;\r
+ int GetAccountLevel() const;\r
+\r
+ void GameDisconnect();\r
+\r
+ void RefreshAccountInfo(PAccount *Account);\r
+ void LoggedIn(PAccount *Account);\r
+ void Update();\r
+\r
+ // new multiuser-chat implementation //\r
+ int getZoneID() const;\r
+ //inline int* getIP() const { return (int*) m_IP; }\r
+\r
+ void SetAwaitingWarpto(bool yesno, uint16_t NewX, uint16_t NewY, uint16_t NewZ);\r
+ bool GetCharAwaitingWarpto(uint16_t* PosX = NULL, uint16_t* PosY = NULL, uint16_t* PosZ = NULL);\r
+\r
+ // Char broadcasted effects\r
+ void InitWarpCircle();\r
+ void InitCharVanish();\r
+\r
+ // used for dynamic ingame testing\r
+ uint8_t testval8;\r
+ uint16_t testval16;\r
+ uint32_t testval32;\r
+};\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- client.cpp\r
-\r
- Authors:\r
- - bakkdoor\r
- - Akiko\r
-\r
- MODIFIED: 13 Dec 2005 bakkdoor\r
- REASON: - introduced\r
- MODIFIED: 29 Jul 2006 Hammag\r
- REASON: - Added UDP broadcast fonction\r
- - Added "zone players say Hello" fonction\r
- - Modified the ID used as would should avoid muliplying the IDs for the same client.\r
- Now using Client.GetLocalID() as the key (=Client.mIndex + 1) which is used in NC protocol\r
- - Modified getClientByID()\r
- - Removed getClientID(). Simply do Client->GetLocalID()\r
- - Modified deleteClientFromListByID() and renamed to deleteClientFromList()\r
- - Modified destructor as to not destroy stored clients, which is already done in PServer\r
- (even if it could well be done here in near futur)\r
-\r
- MODIFIED: 12 Aug 2006 Hammag\r
- REASON: - implemented range filtering in UDPBroadcast()\r
- - implemented the two versions of UDPBroadcast()\r
- MODIFIED: 09 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
- - clean ups\r
-\r
- TODO: - these are just begining of modif, as the Client Manager is bound to be a major component for multiplayer management\r
-*/\r
-\r
-#include "main.h"\r
-\r
-#include "include/msgbuilder.h"\r
+#include "GameServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
+\r
+// TODO: - these are just begining of modif, as the Client Manager is bound to be a major component for multiplayer management\r
\r
PClientManager::PClientManager()\r
{\r
}\r
\r
// Check if a zone is in use\r
-bool PClientManager::IsWorldInUse( u32 nWorldID ) const\r
+bool PClientManager::IsWorldInUse( uint32_t nWorldID ) const\r
{\r
for ( PClientMap::const_iterator it = mClientList.begin(); it != mClientList.end(); it++ )\r
{\r
}\r
\r
// Check if a rawObjectId belongs to a char is in use\r
-PClient* PClientManager::GetClientByCharLocalId( u32 rawObjectId, u32 nWorldID ) const\r
+PClient* PClientManager::GetClientByCharLocalId( uint32_t rawObjectId, uint32_t nWorldID ) const\r
{\r
PClient* nClient;\r
for ( PClientMap::const_iterator it = mClientList.begin(); it != mClientList.end(); it++ )\r
return 0;\r
}\r
\r
-void PClientManager::deleteClientFromList( u32 id )\r
+void PClientManager::deleteClientFromList( uint32_t id )\r
{\r
PClientMap::iterator it = mClientList.find( id );\r
if ( it != mClientList.end() )\r
return false;\r
} */\r
\r
-PClient* PClientManager::getClientByID( u32 id ) const\r
+PClient* PClientManager::getClientByID( uint32_t id ) const\r
{\r
PClientMap::const_iterator it = mClientList.find( id );\r
return (( it != mClientList.end() ) ? ( PClient* )( it->second ) : NULL );\r
}\r
\r
-PClient* PClientManager::getClientByChar( u32 CharID ) const\r
+PClient* PClientManager::getClientByChar( uint32_t CharID ) const\r
{\r
for ( PClientMap::const_iterator it = mClientList.begin(); it != mClientList.end(); it++ )\r
{\r
return NULL;\r
}\r
\r
-/* u32 PClientManager::getClientID(PClient* _client)\r
+/* uint32_t PClientManager::getClientID(PClient* _client)\r
{\r
for(PClientMap::iterator it=mClientList.begin(); it!=mClientList<p align="center"></p>.end(); it++)\r
{\r
} */\r
\r
// Distance checking doesn't care for Z axis ATM\r
-int PClientManager::UDPBroadcast( PMessage* nMessage, u32 nZoneID, u16 nX, u16 nY, u16 nZ, u16 nMaxDist, u32 nSkipCharId, bool nNPCPing )\r
+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 )\r
{\r
int msgCount = 0;\r
PChar* nChar;\r
PMessage* tmpMsg;\r
PClient* itClient;\r
- u16 Dapprox;\r
+ uint16_t Dapprox;\r
\r
for ( PClientMap::iterator it = mClientList.begin(); it != mClientList.end(); it++ )\r
{\r
return msgCount;\r
}\r
\r
-int PClientManager::UDPBroadcast( PMessage* nMessage, PClient* nClient, u16 nMaxDist, bool nSkipSource, bool nNPCPing )\r
+int PClientManager::UDPBroadcast( PMessage* nMessage, PClient* nClient, uint16_t nMaxDist, bool nSkipSource, bool nNPCPing )\r
{\r
PChar* nChar;\r
- u32 skipCharId = nSkipSource ? nClient->GetCharID() : 0 ;\r
+ uint32_t skipCharId = nSkipSource ? nClient->GetCharID() : 0 ;\r
\r
if ( nClient && ( nChar = nClient->GetChar() ) )\r
{\r
PChar* nChar;\r
PChar* itChar;\r
PMessage* tmpMsg;\r
- u32 nZoneID;\r
+ uint32_t nZoneID;\r
PClient* itClient;\r
\r
if ( nClient && ( nChar = nClient->GetChar() ) ) // if nClient is set, always use its zone\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include <map>\r
+\r
+typedef std::map<uint32_t, PClient*> PClientMap;\r
+\r
+class PClientManager {\r
+private:\r
+ //int mLastID;\r
+ PClientMap mClientList;\r
+\r
+public:\r
+ PClientManager();\r
+ ~PClientManager();\r
+\r
+ PClientMap::iterator getClientListBegin() { return mClientList.begin(); }\r
+ PClientMap::iterator getClientListEnd() { return mClientList.end(); }\r
+\r
+ bool addClientToList( PClient* newClient );\r
+ //void deleteClientFromListByID(int id);\r
+ void deleteClientFromList( uint32_t id );\r
+ //bool deleteClientFromList(PClient* delClient); // maybe no use for this...\r
+ PClient* getClientByID( uint32_t uint32_t ) const; // returns pointer to a client for further use\r
+ PClient* getClientByChar( uint32_t CharID ) const;\r
+ PClient* getClientByChar( const std::string &Name ) const;\r
+ // int getClientID(PClient* _client); do _client->GetLocalID()\r
+ bool IsWorldInUse( uint32_t nWorldID ) const; // Temp until world content fully managed by world\r
+ PClient* GetClientByCharLocalId( uint32_t rawObjectId, uint32_t nWorldID ) const; // Temp (called by world) until world content fuly managed by world\r
+\r
+ // each function return the number of messages sent.\r
+ 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 );\r
+ int UDPBroadcast( PMessage* nMessage, PClient* nClient, uint16_t nMaxDist = 0, bool nSkipSource = false, bool nNPCPing = false );\r
+ int SendUDPZoneWelcomeToClient( PClient* nClient );\r
+};\r
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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 (@<command>)
-
- 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 <cstring>
+#include "GameServer/Includes.hxx"
+#include "Common/Includes.hxx"
PCommands::PCommands()
{
}
// ok, we have the command, now read the args
- // Loop till entire chatpacket is parsed or MAXARGS is reached\r
+ // 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;
- \r
- // Now loop until next space ' ' or end '\0' is reached\r
- // Added extraction of encapsulated strings "test 123 123"\r
+
+ // Now loop until next space ' ' or end '\0' is reached
+ // Added extraction of encapsulated strings "test 123 123"
while (packet[posPacket] != ' ' || tEncapsedString == true)
- {\r
- // Watch out for >"<\r
- if(packet[posPacket] == '"')\r
- tEncapsedString = !tEncapsedString;\r
- else\r
- {\r
- // Copy arg from chatpacket to final arg var\r
- ArgV[ArgC][tmpPos] = packet[posPacket];\r
- tmpPos++;\r
- }\r
- // Increment tmpPos and posPacket\r
- posPacket++;\r
- if(packet[posPacket] == '\0')\r
- break;\r
+ {
+ // 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;\r
+ 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\r
- ArgC++;\r
+ // 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')
else if (strcmp(Command, "setsubskill") == 0)
{
doCmdSetSubSkill();
- }\r
- else if (strcmp(Command, "npc") == 0)\r
- {\r
- doNPC();\r
- }\r
- else if (strcmp(Command, "npcshop") == 0)\r
- {\r
- doNPC_Shop();\r
- }\r
+ }
+ else if (strcmp(Command, "npc") == 0)
+ {
+ doNPC();
+ }
+ else if (strcmp(Command, "npcshop") == 0)
+ {
+ doNPC_Shop();
+ }
// Else: unknown command. Ignore
}
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
+#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
void HandleGameCommand(char *packet, PClient *Client);
};
-#endif
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
+#pragma once\r
\r
/*\r
- Configuration template for gameserver\r
- Used to set available/optional/required options when loading config\r
- with a PConfig object.\r
-\r
- MODIFIED: 28 Sep 2006 Hammag\r
- REASON: - added worlds_path entry\r
- MODIFIED: 02 Oct 2006 Hammag\r
- REASON: - added dev_debug entry\r
-\r
TODO: put a single data_directory entry as the root directory for all NC data\r
-\r
*/\r
\r
-const char* GameConfigTemplate[][2] = {\r
+static const char *GameConfigTemplate[][2] = {\r
// {option_name, default_value} if default_value is empty string, it means option is mandatory\r
// List ends with empty string for option_name\r
{"info_sql_host", "127.0.0.1"},\r
{"password_filter", "^[[:graph:]]{3,15}$"},\r
{"charname_filter", "^[a-z]+([\\-\\ ]?[a-z]+){0,2}$"},\r
{"clanname_filter", "^[a-z][\\w\\-\\ ]{2,14}$"},\r
- \r
+\r
// For futur use:\r
// {"max_chars_per_account", "4"},\r
// {"multiple_logins_per_account", "0"}, // 0=nobody, 1=gm+ only, 2=everybody\r
{"", ""} // do not change this line (end mark)\r
};\r
\r
-const char* CommandsTemplate[][2] = {\r
+static const char *CommandsTemplate[][2] = {\r
{"debug", "100"},\r
{"settime", "100"},\r
{"warp", "0"},\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- container.cpp - base classe for containers\r
-\r
- MODIFIED: 28 Jul 2008 Hammag\r
- REASON: - creation\r
- MODIFIED: 09 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
- - clean ups\r
-*/\r
-\r
-#include "main.h"\r
-\r
-#include "include/item.h"\r
-#include "include/container.h"\r
+#include "GameServer/Includes.hxx"\r
+#include "GameServer/Definitions/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
/* --- PContainerEntry class --- */\r
\r
-PContainerEntry::PContainerEntry( PItem* nItem, u8 X, u8 Y, u32 nInvID, bool SetDirty )\r
+PContainerEntry::PContainerEntry( PItem* nItem, uint8_t X, uint8_t Y, uint32_t nInvID, bool SetDirty )\r
{\r
mItem = nItem;\r
mPosX = X;\r
mPosY = atoi( row[i_y] );\r
mDirtyFlag = false;\r
\r
- u32 nItemID = atoi( row[i_itemid] );\r
- u8 nStackSize = atoi( row[i_qty] );\r
+ uint32_t nItemID = atoi( row[i_itemid] );\r
+ uint8_t nStackSize = atoi( row[i_qty] );\r
// = std::atoi(row[i_type]);\r
- u8 CurDur = atoi( row[i_curdur] );\r
- u8 Dmg = atoi( row[i_dmg] );\r
- u8 Freq = atoi( row[i_freq] );\r
- u8 Hand = atoi( row[i_hand] );\r
- u8 Rng = atoi( row[i_rng] );\r
- u8 Dur = atoi( row[i_maxdur] );\r
+ uint8_t CurDur = atoi( row[i_curdur] );\r
+ uint8_t Dmg = atoi( row[i_dmg] );\r
+ uint8_t Freq = atoi( row[i_freq] );\r
+ uint8_t Hand = atoi( row[i_hand] );\r
+ uint8_t Rng = atoi( row[i_rng] );\r
+ uint8_t Dur = atoi( row[i_maxdur] );\r
\r
mItem = new PItem( nItemID, nStackSize, CurDur, Dur, Dmg, Freq, Hand, Rng );\r
}\r
delete mItem;\r
}\r
\r
-bool PContainerEntry::SQLSave( u32 CharID, u32 InvLoc )\r
+bool PContainerEntry::SQLSave( uint32_t CharID, uint32_t InvLoc )\r
{\r
std::string query, queryv;\r
\r
\r
/* --- PContainer class --- */\r
\r
-PContainer::PContainer( u8 nMaxSlots )\r
+PContainer::PContainer( uint8_t nMaxSlots )\r
{\r
mMaxSlots = ( nMaxSlots > CONTAINER_MAX_SIZE ? CONTAINER_MAX_SIZE : nMaxSlots ) ;\r
if ( mMaxSlots )\r
\r
PContainer::~PContainer()\r
{\r
- for ( u8 i = 0; i < mContContent->size(); ++i )\r
+ for ( uint8_t i = 0; i < mContContent->size(); ++i )\r
delete mContContent->at( i );\r
\r
if ( mExclusiveUseCharID )\r
Console->Print( RED, BLACK, "[ERROR] PContainer::~PContainer: Char %d still has exclusive access to container !!! Bad Pointer error will happen.", mExclusiveUseCharID );\r
}\r
\r
-bool PContainer::AddEntry( PContainerEntry* NewEntry, u8 nSlotId )\r
+bool PContainer::AddEntry( PContainerEntry* NewEntry, uint8_t nSlotId )\r
{\r
if ( IsSlotAllowed( nSlotId ) )\r
{\r
- for ( u8 i = mContContent->size(); i <= nSlotId; ++i ) // Extend as needed\r
+ for ( uint8_t i = mContContent->size(); i <= nSlotId; ++i ) // Extend as needed\r
mContContent->push_back( static_cast<PContainerEntry*>(NULL) );\r
if ( mContContent->at( nSlotId ) )\r
{\r
--- --- */\r
}\r
\r
-void PContainer::SetEntryPosXY( PContainerEntry* nEntry, u8 nSlotId, u8 nPosX, u8 nPosY )\r
+void PContainer::SetEntryPosXY( PContainerEntry* nEntry, uint8_t nSlotId, uint8_t nPosX, uint8_t nPosY )\r
{\r
nPosX = nPosY;\r
nEntry->Set2DPos( nSlotId, 0 );\r
mDirtyFlag = mDirtyFlag || nEntry->mDirtyFlag;\r
}\r
\r
-PContainerEntry* PContainer::RemoveEntry( u8 nSlotId )\r
+PContainerEntry* PContainer::RemoveEntry( uint8_t nSlotId )\r
{\r
PContainerEntry* tEntry = NULL;\r
\r
return tEntry;\r
}\r
\r
-bool PContainer::GetFreeSlot( u8* nSlotId )\r
+bool PContainer::GetFreeSlot( uint8_t* nSlotId )\r
{\r
return IsSlotFree( *nSlotId );\r
}\r
\r
-void PContainer::Compact( u8 startSlotId )\r
+void PContainer::Compact( uint8_t startSlotId )\r
{\r
- u8 i, j;\r
+ uint8_t i, j;\r
PContainerEntry* tEntry;\r
\r
for ( i = j = startSlotId; i < mContContent->size(); ++i )\r
}\r
}\r
\r
-bool PContainer::StartUse( u32 nExclusiveUseCharID )\r
+bool PContainer::StartUse( uint32_t nExclusiveUseCharID )\r
{\r
if ( mExclusiveUseCharID )\r
return false;\r
}\r
}\r
\r
-bool PContainer::EndUse( u32 nExclusiveUseCharID )\r
+bool PContainer::EndUse( uint32_t nExclusiveUseCharID )\r
{\r
if ( nExclusiveUseCharID == mExclusiveUseCharID )\r
{\r
char query[1024];\r
PContainerEntry* NewEntry;\r
bool SaveDirtyFlag;\r
- u8 nSlotId;\r
- //u8 nPosX, nPosY, nSizeX, nSizeY;\r
+ uint8_t nSlotId;\r
+ //uint8_t nPosX, nPosY, nSizeX, nSizeY;\r
\r
/*if (!mContContent.empty())\r
{\r
PContainerEntry* ContEntry;\r
bool SavedOK = true;\r
\r
- for ( u8 i = 0; i < mContContent->size(); ++i )\r
+ for ( uint8_t i = 0; i < mContContent->size(); ++i )\r
{\r
if (( ContEntry = mContContent->at( i ) ) )\r
{\r
return SavedOK;\r
}\r
\r
-bool PContainer::IsSlotFree( u8 nSlotId )\r
+bool PContainer::IsSlotFree( uint8_t nSlotId )\r
{\r
if ( !IsSlotAllowed( nSlotId ) )\r
return false;\r
return !( mContContent->at( nSlotId ) );\r
}\r
\r
-bool PContainer::AddItem( PItem* NewItem, u32 nInvID, u8 nPosX, u8 nPosY, bool SetDirty )\r
+bool PContainer::AddItem( PItem* NewItem, uint32_t nInvID, uint8_t nPosX, uint8_t nPosY, bool SetDirty )\r
{\r
/* --- auto stacking not implemented yet\r
1 - if stackable, check if same item(S) exists\r
}\r
}\r
\r
-bool PContainer::MoveItem( u8 srcSlotId, u8 nCount, PContainer* dstContainer, u8 dstSlotId, u8 nPosX, u8 nPosY )\r
+bool PContainer::MoveItem( uint8_t srcSlotId, uint8_t nCount, PContainer* dstContainer, uint8_t dstSlotId, uint8_t nPosX, uint8_t nPosY )\r
{\r
if ( dstContainer == this )\r
return this->MoveItem( srcSlotId, nCount, dstSlotId );\r
else if ( dstContainer->GetFreeSlot( &dstSlotId ) )\r
{\r
- u8 savePosX, savePosY;\r
+ uint8_t savePosX, savePosY;\r
PContainerEntry* tEntry = this->GetEntry( srcSlotId );\r
if ( tEntry )\r
{\r
}\r
\r
// !!! Not partial move yet !!!\r
-bool PContainer::MoveItem( u8 srcSlotId, u8 nCount, u8 dstSlotId )\r
+bool PContainer::MoveItem( uint8_t srcSlotId, uint8_t nCount, uint8_t dstSlotId )\r
{\r
if ( !( IsSlotAllowed( srcSlotId ) && IsSlotAllowed( dstSlotId ) ) )\r
return false;\r
{\r
std::vector< PContainerEntry* >* Entries = new std::vector< PContainerEntry* >;\r
\r
- for ( u8 i = 0; i < mContContent->size(); ++i )\r
+ for ( uint8_t i = 0; i < mContContent->size(); ++i )\r
{\r
if ( mContContent->at( i ) )\r
Entries->push_back( mContContent->at( i ) );\r
return Entries;\r
}\r
\r
-PContainerEntry* PContainer::GetEntry( u8 nSlotId )\r
+PContainerEntry* PContainer::GetEntry( uint8_t nSlotId )\r
{\r
if ( nSlotId >= mContContent->size() )\r
return NULL;\r
return mContContent->at( nSlotId );\r
}\r
\r
-PItem* PContainer::GetItem( u8 nSlotId )\r
+PItem* PContainer::GetItem( uint8_t nSlotId )\r
{\r
PContainerEntry* tEntry = this->GetEntry( nSlotId );\r
return ( tEntry ? tEntry->mItem : NULL );\r
}\r
\r
-u8 PContainer::RandomFill( u8 nItemCount, int nItemContainerDefIndex )\r
+uint8_t PContainer::RandomFill( uint8_t nItemCount, int nItemContainerDefIndex )\r
{\r
PItem* nItem = NULL;\r
const PDefItems* nItemDef;\r
- u32 nItemSeqId;\r
- u8 CreatedCount = 0;\r
+ uint32_t nItemSeqId;\r
+ uint8_t CreatedCount = 0;\r
\r
if ( !nItemCount )\r
nItemCount = mMaxSlots;\r
if ( nItemContainerDefIndex >= 0 )\r
{\r
int newItemIdx, newItemIndex;\r
- u8 newItemQuality;\r
+ uint8_t newItemQuality;\r
\r
const PDefItemContainer* containerDef = GameDefs->ItemContainers()->GetDef( nItemContainerDefIndex );\r
if ( containerDef )\r
{\r
- for ( u8 i = 0; i < nItemCount; ++i )\r
+ for ( uint8_t i = 0; i < nItemCount; ++i )\r
{\r
newItemIdx = containerDef->GetRandomItemIdx();\r
if ( newItemIdx >= 0 )\r
{\r
newItemIndex = containerDef->GetItemId( newItemIdx );\r
- newItemQuality = ( u8 )( 255 & int( 255.0 * containerDef->GetQuality( newItemIdx ) ) );\r
+ newItemQuality = ( uint8_t )( 255 & int( 255.0 * containerDef->GetQuality( newItemIdx ) ) );\r
if ( newItemIndex <= 0 ) // Item group\r
{\r
newItemIndex = GameDefs->Items()->GetRandomItemIdFromGroup( -newItemIndex );\r
{\r
int NumItemsDefs = GameDefs->Items()->GetNumDefs();\r
\r
- for ( u8 i = 0; i < nItemCount; ++i )\r
+ for ( uint8_t i = 0; i < nItemCount; ++i )\r
{\r
nItemSeqId = GetRandom( NumItemsDefs, 1 );\r
\r
{\r
PContainerEntry* tmpEntry;\r
PItem* tmpItem;\r
- u8 i;\r
- //u8 y, x;\r
+ uint8_t i;\r
+ //uint8_t y, x;\r
\r
for ( i = 0; i < mContContent->size(); ++i )\r
{\r
\r
\r
/* --- PContainerAutoCompact --- */\r
-PContainerEntry* PContainerAutoCompact::RemoveEntry( u8 nSlotId )\r
+PContainerEntry* PContainerAutoCompact::RemoveEntry( uint8_t nSlotId )\r
{\r
PContainerEntry* tEntry = NULL;\r
\r
return tEntry;\r
}\r
\r
-bool PContainerAutoCompact::GetFreeSlot( u8* nSlotId ) // not optimal. A "first free from end" would be better at PContainer level\r
+bool PContainerAutoCompact::GetFreeSlot( uint8_t* nSlotId ) // not optimal. A "first free from end" would be better at PContainer level\r
{\r
bool Found = false;\r
\r
return ( Found || IsSlotAllowed( *nSlotId ) );\r
}\r
\r
-bool PContainerAutoCompact::MoveItem( u8 srcSlotId, u8 nCount, u8 dstSlotId )\r
+bool PContainerAutoCompact::MoveItem( uint8_t srcSlotId, uint8_t nCount, uint8_t dstSlotId )\r
{\r
srcSlotId = nCount = dstSlotId;\r
return false;\r
\r
/* --- PContainer2D class --- */\r
\r
-void PContainer2D::SetEntryPosXY( PContainerEntry* nEntry, u8 nSlotId, u8 nPosX, u8 nPosY )\r
+void PContainer2D::SetEntryPosXY( PContainerEntry* nEntry, uint8_t nSlotId, uint8_t nPosX, uint8_t nPosY )\r
{\r
nSlotId = nSlotId;\r
if (( nPosX >= INV_BACKPACK_COLS ) || ( nPosY == 255 ) )\r
\r
/* --- PContainer2DWorkaround --- */\r
/////\r
-PContainer2DWorkaround::PContainer2DWorkaround( u8 nMaxSlots ) : PContainerWithHoles( nMaxSlots )\r
+PContainer2DWorkaround::PContainer2DWorkaround( uint8_t nMaxSlots ) : PContainerWithHoles( nMaxSlots )\r
{\r
nMaxSlots = nMaxSlots;\r
mNextFreeSlot = 0;\r
delete mContSpace[i];\r
}\r
\r
-bool PContainer2DWorkaround::AddEntry( PContainerEntry* tEntry, u8 nSlotId )\r
+bool PContainer2DWorkaround::AddEntry( PContainerEntry* tEntry, uint8_t nSlotId )\r
{\r
if ( IsSlotAllowed( nSlotId ) )\r
{\r
if ( FindValid2DPos( tEntry ) )\r
{\r
- for ( u8 i = mContContent->size(); i <= nSlotId; ++i ) // Extend as needed\r
+ for ( uint8_t i = mContContent->size(); i <= nSlotId; ++i ) // Extend as needed\r
mContContent->push_back( static_cast<PContainerEntry *>(NULL) );\r
if ( mContContent->at( nSlotId ) )\r
{\r
\r
}\r
\r
-PContainerEntry* PContainer2DWorkaround::RemoveEntry( u8 nSlotId )\r
+PContainerEntry* PContainer2DWorkaround::RemoveEntry( uint8_t nSlotId )\r
{\r
PContainerEntry* tEntry = NULL;\r
\r
return tEntry;\r
}\r
\r
-bool PContainer2DWorkaround::GetFreeSlot( u8* nSlotId )\r
+bool PContainer2DWorkaround::GetFreeSlot( uint8_t* nSlotId )\r
{\r
if ( IsSlotAllowed( mNextFreeSlot ) )\r
{\r
return false;\r
}\r
\r
-void PContainer2DWorkaround::SetEntryPosXY( PContainerEntry* nEntry, u8 nSlotId, u8 nPosX, u8 nPosY )\r
+void PContainer2DWorkaround::SetEntryPosXY( PContainerEntry* nEntry, uint8_t nSlotId, uint8_t nPosX, uint8_t nPosY )\r
{\r
nSlotId = nSlotId;\r
if (( nPosX == 255 ) && ( nPosY == 255 ) )\r
mDirtyFlag = mDirtyFlag || nEntry->mDirtyFlag;\r
}\r
\r
-bool PContainer2DWorkaround::MoveItem( u8 srcSlotId, u8 nCount, u8 dstSlotId )\r
+bool PContainer2DWorkaround::MoveItem( uint8_t srcSlotId, uint8_t nCount, uint8_t dstSlotId )\r
{\r
srcSlotId = nCount = dstSlotId;\r
return false;\r
}\r
}\r
\r
-bool PContainer2DWorkaround::Is2DFree( u8 PosX, u8 PosY, u8 SizeX, u8 SizeY )\r
+bool PContainer2DWorkaround::Is2DFree( uint8_t PosX, uint8_t PosY, uint8_t SizeX, uint8_t SizeY )\r
{\r
if (( PosX == 255 ) && ( PosY == 255 ) )\r
{\r
if ( !Is2DPosAllowed( PosX, PosY, SizeX, SizeY ) )\r
return false;\r
\r
- u8 h, v;\r
+ uint8_t h, v;\r
for ( v = 0; ( v < SizeY ) && ( PosY + v < mRows ) ; v++ ) // what is over existing rows is free\r
{\r
for ( h = 0; h < SizeX; h++ )\r
\r
void PContainer2DWorkaround::SetUsed( PContainerEntry* nEntry, bool Value )\r
{\r
- u8 PosX = nEntry->mPosX;;\r
- u8 PosY = nEntry->mPosY;\r
- u8 SizeX = nEntry->mItem->GetSizeX();\r
- u8 SizeY = nEntry->mItem->GetSizeY();\r
+ uint8_t PosX = nEntry->mPosX;;\r
+ uint8_t PosY = nEntry->mPosY;\r
+ uint8_t SizeX = nEntry->mItem->GetSizeX();\r
+ uint8_t SizeY = nEntry->mItem->GetSizeY();\r
\r
if ( !Is2DPosAllowed( PosX, PosY, SizeX, SizeY ) )\r
return;\r
while ( PosY + SizeY > mRows ) // add new rows when needed\r
AddRow();\r
\r
- u8 h, v;\r
+ uint8_t h, v;\r
for ( v = 0; ( v < SizeY ) && ( PosY + v < mRows ) ; v++ )\r
{\r
for ( h = 0; ( h < SizeX ) && ( PosX + h < mMaxCols ); h++ )\r
bool PContainer2DWorkaround::FindValid2DPos( PContainerEntry* nEntry )\r
{\r
bool Found = false;\r
- u8 SizeX = nEntry->mItem->GetSizeX();\r
- u8 SizeY = nEntry->mItem->GetSizeY();\r
- u8 dPosX, dPosY;\r
+ uint8_t SizeX = nEntry->mItem->GetSizeX();\r
+ uint8_t SizeY = nEntry->mItem->GetSizeY();\r
+ uint8_t dPosX, dPosY;\r
\r
if ( Is2DFree( nEntry->mPosX, nEntry->mPosY, SizeX, SizeY ) )\r
Found = true;\r
PContainer::Dump();\r
\r
std::string tmpS;\r
- u8 y, x;\r
+ uint8_t y, x;\r
for ( y = 0 ; y < mRows; y++ )\r
{\r
tmpS = "";\r
}\r
\r
/* --- PContainerAutoFindFree --- */\r
-bool PContainerAutoFindFree::GetFreeSlot( u8* nSlotId )\r
+bool PContainerAutoFindFree::GetFreeSlot( uint8_t* nSlotId )\r
{\r
bool Found = false;\r
\r
}\r
\r
/* --- PContainerAutoCompactOnClose --- */\r
-bool PContainerAutoCompactOnClose::EndUse( u32 nExclusiveUseCharID )\r
+bool PContainerAutoCompactOnClose::EndUse( uint32_t nExclusiveUseCharID )\r
{\r
if ( nExclusiveUseCharID == mExclusiveUseCharID )\r
{\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include <vector>\r
+#ifdef MYSQL_INC_DIR\r
+#include <mysql/mysql.h>\r
+#else\r
+#include <mysql.h>\r
+#endif\r
+\r
+#define CONTAINER_MAX_SIZE 254\r
+\r
+class PItem;\r
+\r
+class PContainerEntry {\r
+ friend class PContainer;\r
+ friend class PContainer2D;\r
+ friend class PMsgBuilder;\r
+ friend class PContainer2DWorkaround;\r
+\r
+private:\r
+ enum {\r
+ i_invid = 0,\r
+ i_charid,\r
+ i_invloc,\r
+ i_x,\r
+ i_y,\r
+ i_itemid,\r
+ //i_type,\r
+ i_flag,\r
+ i_qty,\r
+ i_sqty,\r
+ i_curdur,\r
+ i_dmg,\r
+ i_freq,\r
+ i_hand,\r
+ i_rng,\r
+ i_maxdur,\r
+ i_slots,\r
+ i_slt1,\r
+ i_slt2,\r
+ i_slt3,\r
+ i_slt4,\r
+ i_slt5,\r
+ i_atype,\r
+ i_conatin\r
+ };\r
+\r
+ PItem* mItem;\r
+ uint8_t mPosX;\r
+ uint8_t mPosY;\r
+ uint32_t mInvID;\r
+ bool mDirtyFlag;\r
+\r
+ PContainerEntry(PItem* nItem, uint8_t X, uint8_t Y, uint32_t nInvID = 0, bool SetDirty = true);\r
+ PContainerEntry(MYSQL_ROW row);\r
+\r
+ bool SQLSave(uint32_t CharID, uint32_t InvLoc);\r
+ bool SQLDelete();\r
+\r
+ inline void Set2DPos(uint8_t nPosX, uint8_t nPosY) { mDirtyFlag = mDirtyFlag || (mPosX != nPosX) || (mPosY != nPosY) ; mPosX = nPosX; mPosY = nPosY; }\r
+\r
+public:\r
+ ~PContainerEntry();\r
+\r
+ inline void Get2DPos(uint8_t* oPosX, uint8_t* oPosY) { *oPosX = mPosX; *oPosY = mPosY; }\r
+};\r
+\r
+\r
+\r
+class PContainer // Holes allowed, no autofind free slots\r
+{\r
+ protected:\r
+ uint8_t mMaxSlots;\r
+ std::vector< PContainerEntry* >* mContContent;\r
+ uint32_t mCharID;\r
+ uint32_t mInvLoc;\r
+ uint32_t mExclusiveUseCharID;\r
+ bool mDirtyFlag;\r
+\r
+ inline bool IsSlotAllowed(uint8_t nSlotId) { return ((nSlotId < CONTAINER_MAX_SIZE) && (!mMaxSlots || (nSlotId < mMaxSlots))); }\r
+ virtual bool AddEntry(PContainerEntry* NewEntry, uint8_t nSlotId = 0);\r
+ virtual PContainerEntry* RemoveEntry(uint8_t nSlotId);\r
+ virtual bool GetFreeSlot(uint8_t* nSlotId);\r
+ void Compact(uint8_t startSlotId = 0);\r
+\r
+ public:\r
+ PContainer(uint8_t nMaxSlots = 0);\r
+ virtual ~PContainer();\r
+\r
+ inline void SetInfo(uint32_t CharID, uint32_t InvLoc) { mCharID = CharID; mInvLoc = InvLoc; }\r
+ inline uint32_t GetOwnerId() { return mCharID; }\r
+ inline bool IsDirty() { return mDirtyFlag; }\r
+ inline void SetDirty() { mDirtyFlag = true; }\r
+ bool StartUse(uint32_t nExclusiveUseCharID = 0);\r
+ virtual bool EndUse(uint32_t nExclusiveUseCharID = 0);\r
+ bool SQLLoad();\r
+ bool SQLSave();\r
+ bool IsSlotFree(uint8_t nSlotId);\r
+ virtual bool AddItem(PItem* NewItem, uint32_t nInvID = 0, uint8_t nPosX = 0, uint8_t nPosY = 0, bool SetDirty = true);\r
+ virtual bool MoveItem(uint8_t srcSlotId, uint8_t nCount, uint8_t dstSlotId);\r
+ bool MoveItem(uint8_t srcSlotId, uint8_t nCount, PContainer* dstContainer, uint8_t dstSlotId = 0, uint8_t nPosX = 0, uint8_t nPosY = 0);\r
+ virtual void SetEntryPosXY(PContainerEntry* nEntry, uint8_t nSlotId, uint8_t nPosX = 0, uint8_t nPosY = 0);\r
+\r
+ virtual uint8_t RandomFill(uint8_t nItemCount = 0, int nItemContainerDefIndex = -1);\r
+ PContainerEntry* GetEntry(uint8_t nSlotId);\r
+ std::vector< PContainerEntry* >* GetEntries();\r
+ PItem* GetItem(uint8_t nSlotId);\r
+ virtual void Dump();\r
+};\r
+\r
+\r
+class PContainerWithHoles : public PContainer // Holes allowed, no autofind free slots\r
+{\r
+ public:\r
+ PContainerWithHoles(uint8_t nMaxSlots = 0) : PContainer(nMaxSlots){ nMaxSlots = nMaxSlots; }\r
+ virtual ~PContainerWithHoles() {}\r
+};\r
+\r
+\r
+class PContainerAutoCompact : public PContainer // No holes allowed, automatic add to end slot (no control on insertion slot)\r
+{\r
+protected:\r
+ virtual PContainerEntry* RemoveEntry(uint8_t nSlotId);\r
+ virtual bool GetFreeSlot(uint8_t* nSlotId);\r
+\r
+public:\r
+ PContainerAutoCompact(uint8_t nMaxSlots = 0) : PContainer(nMaxSlots){ nMaxSlots = nMaxSlots; }\r
+ virtual ~PContainerAutoCompact() {}\r
+ virtual bool MoveItem(uint8_t srcSlotId, uint8_t nCount, uint8_t dstSlotId);\r
+};\r
+\r
+\r
+class PContainer2D : public PContainerAutoCompact // + slotId not used, non-significant XY used (no XY check yet)\r
+{\r
+ public:\r
+ PContainer2D(uint8_t nMaxSlots = 0) : PContainerAutoCompact(nMaxSlots){ nMaxSlots = nMaxSlots; }\r
+ virtual ~PContainer2D() {}\r
+\r
+ virtual void SetEntryPosXY(PContainerEntry* nEntry, uint8_t nSlotId, uint8_t nPosX = 0, uint8_t nPosY = 0);\r
+};\r
+\r
+class PContainer2DWorkaround : public PContainerWithHoles // Holes allowed, autofind free slot (always increasing id)\r
+{\r
+private:\r
+ uint8_t mNextFreeSlot;\r
+ std::vector< std::vector<bool>* > mContSpace;\r
+ uint8_t mMaxCols;\r
+ uint8_t mMaxRows;\r
+ uint8_t mRows;\r
+\r
+ void AddRow();\r
+ inline bool Is2DPosAllowed(uint8_t PosX, uint8_t PosY, uint8_t SizeX, uint8_t SizeY)\r
+ {\r
+ return ((PosX < mMaxCols-SizeX+1) && (PosY < mMaxRows-SizeY+1));\r
+ }\r
+ bool Is2DFree(uint8_t PosX, uint8_t PosY, uint8_t SizeX, uint8_t SizeY);\r
+ bool FindValid2DPos(PContainerEntry* nEntry);\r
+\r
+protected:\r
+ bool AddEntry(PContainerEntry* NewEntry, uint8_t nSlotId = 0);\r
+ PContainerEntry* RemoveEntry(uint8_t nSlotId);\r
+ bool GetFreeSlot(uint8_t* nSlotId);\r
+\r
+ public:\r
+ PContainer2DWorkaround(uint8_t nMaxSlots = 0);\r
+ ~PContainer2DWorkaround();\r
+\r
+ bool MoveItem(uint8_t srcSlotId, uint8_t nCount, uint8_t dstSlotId);\r
+\r
+ void Set2DPosMax(uint8_t MaxPosX, uint8_t MaxPosY = 254) { mMaxCols = MaxPosX; mMaxRows = MaxPosY; }\r
+ void SetEntryPosXY(PContainerEntry* nEntry, uint8_t nSlotId, uint8_t nPosX = 0, uint8_t nPosY = 0);\r
+ void SetUsed(PContainerEntry* nEntry, bool Value = true);\r
+ void Dump();\r
+};\r
+\r
+class PContainerAutoFindFree : public PContainerWithHoles // No holes kept after EndUse, automatic find first free slots (no control on insertion slot)\r
+{\r
+ protected:\r
+ virtual bool GetFreeSlot(uint8_t* nSlotId);\r
+\r
+ public:\r
+ PContainerAutoFindFree(uint8_t nMaxSlots = 0) : PContainerWithHoles(nMaxSlots){ nMaxSlots = nMaxSlots; }\r
+ virtual ~PContainerAutoFindFree() {}\r
+};\r
+\r
+class PContainerAutoCompactOnClose : public PContainerAutoFindFree // No holes kept after EndUse, automatic find first free slots (no control on insertion slot)\r
+{\r
+ public:\r
+ PContainerAutoCompactOnClose(uint8_t nMaxSlots = 0) : PContainerAutoFindFree(nMaxSlots){ nMaxSlots = nMaxSlots; }\r
+ virtual ~PContainerAutoCompactOnClose() {}\r
+\r
+ virtual bool EndUse(uint32_t nExclusiveUseCharID = 0);\r
+};\r
--- /dev/null
+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)
--- /dev/null
+#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"
--- /dev/null
+#include "GameServer/Decoder/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
+\r
+void PUdpMsgDecoder::Init(PMessage *nMessage, PClient *nClient)\r
+{\r
+ mDecodeData.mMessage = nMessage;\r
+ mDecodeData.mClient = nClient;\r
+ mDecodeData.mState = (nMessage && nClient) ? DECODE_MORE : DECODE_UNDEF;\r
+ mDecodeData.mUnknownType = 0;\r
+ mDecodeData.mHandling0x13Sub = false;\r
+ mDecodeData.Sub0x13Start = mDecodeData.Sub0x13StartNext = 0;\r
+ mPacketName.erase();\r
+ mDecodeData.mName.str(mPacketName);\r
+ mDecodeData.mErrorDetail.erase();\r
+ mDecodeData.mTraceKnownMsg = false;\r
+ mDecodeData.mTraceUnknownMsg = false;\r
+ mDecodeData.mTraceDump = false;\r
+ if (mCurrentAnalyser)\r
+ {\r
+ delete mCurrentAnalyser;\r
+ mCurrentAnalyser = nullptr;\r
+ }\r
+}\r
+\r
+PUdpMsgDecoder::PUdpMsgDecoder()\r
+{\r
+ mCurrentAnalyser = nullptr;\r
+ Reset();\r
+}\r
+\r
+PUdpMsgDecoder::PUdpMsgDecoder(PMessage *nMessage, PClient *nClient)\r
+{\r
+ mCurrentAnalyser = nullptr;\r
+ Init(nMessage, nClient);\r
+}\r
+\r
+PUdpMsgDecoder::~PUdpMsgDecoder()\r
+{\r
+ if (mCurrentAnalyser)\r
+ {\r
+ delete mCurrentAnalyser;\r
+ }\r
+}\r
+\r
+bool PUdpMsgDecoder::Analyse()\r
+{\r
+ PUdpMsgAnalyser* nextAnalyser;\r
+\r
+ if ((mDecodeData.mState & DECODE_MORE) || mDecodeData.mHandling0x13Sub)\r
+ {\r
+ if (mCurrentAnalyser)\r
+ {\r
+ delete mCurrentAnalyser;\r
+ mCurrentAnalyser = nullptr;\r
+ }\r
+ if (mDecodeData.mHandling0x13Sub)\r
+ {\r
+ mPacketName.erase();\r
+ mDecodeData.mName.str(mPacketName);\r
+ mCurrentAnalyser = new PUdp0x13(&mDecodeData);\r
+ mDecodeData.mState = DECODE_MORE;\r
+ }\r
+ else\r
+ {\r
+ mCurrentAnalyser = new PUdpMsgAnalyser(&mDecodeData);\r
+ }\r
+\r
+ while (mDecodeData.mState & DECODE_MORE)\r
+ {\r
+ nextAnalyser = mCurrentAnalyser->Analyse();\r
+ if (mCurrentAnalyser != nextAnalyser)\r
+ {\r
+ delete mCurrentAnalyser;\r
+ mCurrentAnalyser = nextAnalyser;\r
+ }\r
+ }\r
+ }\r
+ return (!(mDecodeData.mState & (DECODE_MORE | DECODE_ERROR | DECODE_UNKNOWN)));\r
+}\r
+\r
+bool PUdpMsgDecoder::Analyse(PMessage *nMessage, PClient *nClient)\r
+{\r
+ Init(nMessage, nClient);\r
+ return Analyse();\r
+}\r
+\r
+void PUdpMsgDecoder::Init(PMessage *nMessage, PClient *nClient, PGameState *nClientState)\r
+{\r
+ mDecodeData.mClientState = nClientState;\r
+ Init(nMessage, nClient);\r
+}\r
+\r
+uint8_t PUdpMsgDecoder::GetState()\r
+{\r
+ return mDecodeData.mState;\r
+}\r
+\r
+bool PUdpMsgDecoder::IsError()\r
+{\r
+ return (mDecodeData.mState & DECODE_ERROR);\r
+}\r
+\r
+bool PUdpMsgDecoder::IsKnown()\r
+{\r
+ return (!(mDecodeData.mState & DECODE_UNKNOWN));\r
+}\r
+\r
+bool PUdpMsgDecoder::MoreSubMsg()\r
+{\r
+ return mDecodeData.mHandling0x13Sub;\r
+}\r
+\r
+bool PUdpMsgDecoder::IsActionReady()\r
+{\r
+ return (mDecodeData.mState & DECODE_ACTION_READY);\r
+}\r
+\r
+bool PUdpMsgDecoder::IsActionDone()\r
+{\r
+ return (mDecodeData.mState & DECODE_ACTION_DONE);\r
+}\r
+\r
+bool PUdpMsgDecoder::IsTraceKnownMsg()\r
+{\r
+ return mDecodeData.mTraceKnownMsg;\r
+}\r
+\r
+bool PUdpMsgDecoder::IsTraceUnknownMsg()\r
+{\r
+ return mDecodeData.mTraceUnknownMsg;\r
+}\r
+\r
+bool PUdpMsgDecoder::IsTraceDump()\r
+{\r
+ return mDecodeData.mTraceDump;\r
+}\r
+\r
+void PUdpMsgDecoder::DumpMsg()\r
+{\r
+ if (mDecodeData.mMessage)\r
+ mDecodeData.mMessage->Dump();\r
+}\r
+\r
+std::string const &PUdpMsgDecoder::GetName()\r
+{\r
+ return (mTmpName = mDecodeData.mName.str());\r
+}\r
+\r
+std::string const &PUdpMsgDecoder::GetError()\r
+{\r
+ return mDecodeData.mErrorDetail;\r
+}\r
+\r
+bool PUdpMsgDecoder::DoAction()\r
+{\r
+ if (mDecodeData.mState & DECODE_ACTION_READY)\r
+ {\r
+ return mCurrentAnalyser->DoAction();\r
+ }\r
+ else\r
+ {\r
+ return false;\r
+ }\r
+}\r
+\r
+void PUdpMsgDecoder::Reset()\r
+{\r
+ Init(nullptr, nullptr);\r
+}\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include <sstream>\r
+#include <string>\r
+\r
+struct PGameState;\r
+class PClient;\r
+class PMessage;\r
+class PUdpMsgAnalyser;\r
+\r
+#define DECODE_UNDEF 0\r
+#define DECODE_ERROR 1 // one error occured on the current decoding step\r
+#define DECODE_UNKNOWN 2 // the current decoded (sub)message is unkown\r
+#define DECODE_MORE 4 // more decoding needed for the (sub)message\r
+#define DECODE_FINISHED 8 // decoding if finished for the whole message\r
+#define DECODE_ACTION_READY 16 // an action is ready to be done\r
+#define DECODE_ACTION_DONE 32 // the action triggered hasn't to be triggered again\r
+#define DECODE_ACTION_IGNORED 64 // the action wasn't performed for some (good) reason (to combine or not with DONE)\r
+#define DECODE_ACTION_FAILED 128 // the action failed totally or partially (to combine or not with DONE)\r
+\r
+struct PMsgDecodeData {\r
+ PMessage *mMessage;\r
+ PClient *mClient;\r
+ uint8_t mState;\r
+ uint8_t mUnknownType;\r
+ bool mHandling0x13Sub;\r
+ uint16_t Sub0x13Start;\r
+ uint16_t Sub0x13StartNext;\r
+ std::stringstream mName;\r
+ std::string mErrorDetail;\r
+ bool mTraceKnownMsg;\r
+ bool mTraceUnknownMsg;\r
+ bool mTraceDump;\r
+ PGameState *mClientState; // Temporary until State is put back in Client object\r
+};\r
+\r
+// UDP Message decoder\r
+// boolean methods return true if successful\r
+\r
+class PUdpMsgDecoder {\r
+private:\r
+ PMsgDecodeData mDecodeData;\r
+ PUdpMsgAnalyser *mCurrentAnalyser;\r
+ std::string mPacketName;\r
+ std::string mTmpName;\r
+\r
+ void Init(PMessage *nMessage, PClient *nClient);\r
+\r
+public:\r
+ PUdpMsgDecoder();\r
+ PUdpMsgDecoder(PMessage *nMessage, PClient *nClient);\r
+ ~PUdpMsgDecoder();\r
+\r
+ bool Analyse();\r
+ bool Analyse(PMessage *nMessage, PClient *nClient); // Can be used on non initialized or already used object\r
+ // Temporary form until State is put back in Client object\r
+ void Init(PMessage *nMessage, PClient *nClient, PGameState *nClientState);\r
+ uint8_t GetState();\r
+ bool IsError();\r
+ bool IsKnown();\r
+ bool MoreSubMsg();\r
+ bool IsActionReady();\r
+ bool IsActionDone();\r
+ bool IsTraceKnownMsg();\r
+ bool IsTraceUnknownMsg();\r
+ bool IsTraceDump();\r
+ void DumpMsg();\r
+ std::string const &GetName();\r
+ std::string const &GetError();\r
+ bool DoAction();\r
+ void Reset();\r
+};\r
--- /dev/null
+#include "GameServer/Decoder/Includes.hxx"\r
+#include "GameServer/Includes.hxx"\r
+\r
+PUdp0x08::PUdp0x08(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData)\r
+{\r
+ nDecodeData->mName << "/0x08";\r
+}\r
+\r
+PUdpMsgAnalyser* PUdp0x08::Analyse()\r
+{\r
+ mDecodeData->mName << "=Client crash";\r
+ mDecodeData->mState = DECODE_ACTION_READY | DECODE_FINISHED;\r
+\r
+ return this;\r
+}\r
+\r
+bool PUdp0x08::DoAction()\r
+{\r
+ // Client crashed, close connection from our side\r
+ GameServer->ClientDisconnected(mDecodeData->mClient);\r
+ mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED;\r
+\r
+ return true;\r
+}\r
--- /dev/null
+#pragma once\r
+\r
+#include "GameServer/Decoder/UdpAnalyser.hxx"\r
+\r
+class PUdp0x08 : public PUdpMsgAnalyser {\r
+public:\r
+ PUdp0x08(PMsgDecodeData *nDecodeData);\r
+ //~PUdp0x08();\r
+ PUdpMsgAnalyser* Analyse();\r
+ bool DoAction();\r
+};\r
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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 ****/
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() )
{
}
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
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 );
mDecodeData->mUnknownType = MsgType;
mDecodeData->mTraceUnknownMsg = true;
}
- break;
+ break;
}
case 0x20: // Char move
case 0x27: // Sitting object info request
{
nextAnalyser = new PUdpRequestVhcInfo( mDecodeData );
- break;
- }
+ break;
+ }
case 0x2a: // "Packet0"
{
}
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
}
}
break;
- }
+ }
default:
- {
+ {
mDecodeData->mUnknownType = MsgType;
- break;
- }
+ break;
+ }
}
if ( ! nextAnalyser )
nextAnalyser = new PUdpMsgUnknown( mDecodeData );
}
- }
+ }
return nextAnalyser;
}
--- /dev/null
+#pragma once\r
+\r
+#include "GameServer/Decoder/UdpAnalyser.hxx"\r
+\r
+class PUdp0x13 : public PUdpMsgAnalyser {\r
+public:\r
+ PUdp0x13(PMsgDecodeData *nDecodeData);\r
+ //~PUdp0x13();\r
+ PUdpMsgAnalyser* Analyse();\r
+ //bool DoAction();\r
+};\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- udp_udp0x1f.cpp - decoder classes for UDP 0x13x03x1f messages\r
-\r
- CREATION: 6 Sep 2006 Hammag\r
-\r
- MODIFIED:\r
- REASON: -\r
-\r
-*/\r
-\r
-#include "main.h"\r
-#include "udp_0x1f.h"\r
-\r
-#include "udp_zoning.h"\r
-#include "udp_charmove.h"\r
-#include "udp_vhc.h"\r
-#include "udp_subskill.h"\r
-#include "udp_chat.h"\r
-#include "udp_useobject.h"\r
-#include "udp_appartment.h"\r
-#include "udp_quickaccessbelt.h"\r
-#include "udp_itemmove.h"\r
-#include "udp_hack.h"\r
-#include "udp_outfitter.h"\r
-#include "udp_helditemaction.h"\r
-#include "udp_killself.h"\r
-#include "udp_popupresponse.h"\r
-#include "udp_itemmanualreload.h"\r
-#include "udp_itemuse.h"\r
-#include "udp_deathrespawn.h"\r
-#include "udp_pvptrade.h"\r
-#include "udp_npcdialog.h"\r
+#include "GameServer/Decoder/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
/**** PUdp0x1f ****/\r
\r
{\r
PUdpMsgAnalyser* nextAnalyser = NULL;\r
mDecodeData->mState = DECODE_MORE;\r
- u8 MsgType = mDecodeData->mMessage->U8Data( mDecodeData->Sub0x13Start + 7 );\r
- u8 MsgSubType = mDecodeData->mMessage->U8Data( mDecodeData->Sub0x13Start + 8 );\r
+ uint8_t MsgType = mDecodeData->mMessage->U8Data( mDecodeData->Sub0x13Start + 7 );\r
+ uint8_t MsgSubType = mDecodeData->mMessage->U8Data( mDecodeData->Sub0x13Start + 8 );\r
\r
switch ( MsgType )\r
{\r
case 0x00:\r
{\r
- nextAnalyser = new PUdpHeldItemBasicAction( mDecodeData );\r
+ nextAnalyser = new PUdpHeldItemBasicAction( mDecodeData );\r
break;\r
}\r
case 0x01:\r
{\r
- nextAnalyser = new PUdpHeldItemAimedAction( mDecodeData );\r
+ nextAnalyser = new PUdpHeldItemAimedAction( mDecodeData );\r
break;\r
}\r
case 0x02:\r
nextAnalyser = new PUdpItemSlotUse( mDecodeData );\r
break;\r
}\r
- case 0x20: // Use item for hacking, launcher, "launcher" spell\r
+ case 0x20: // Use item for hacking, launcher, "launcher" spell\r
{\r
- nextAnalyser = new PUdpHeldItemLaunchingAction( mDecodeData );\r
+ nextAnalyser = new PUdpHeldItemLaunchingAction( mDecodeData );\r
break;\r
}\r
case 0x22:\r
--- /dev/null
+#pragma once\r
+\r
+#include "GameServer/Decoder/UdpAnalyser.hxx"\r
+\r
+class PUdp0x1f : public PUdpMsgAnalyser {\r
+public:\r
+ PUdp0x1f(PMsgDecodeData *nDecodeData);\r
+ //~PUdp0x1f();\r
+ PUdpMsgAnalyser *Analyse();\r
+ //bool DoAction();\r
+};\r
--- /dev/null
+#include "GameServer/Decoder/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
+\r
+/**** PUdp0x22 ****/\r
+\r
+PUdp0x22::PUdp0x22(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData)\r
+{\r
+ nDecodeData->mName << "/0x22";\r
+}\r
+\r
+PUdpMsgAnalyser* PUdp0x22::Analyse()\r
+{\r
+ PUdpMsgAnalyser* nextAnalyser = NULL;\r
+ mDecodeData->mState = DECODE_MORE;\r
+ uint8_t MsgType = mDecodeData->mMessage->U8Data(mDecodeData->Sub0x13Start + 5);\r
+ switch(MsgType) // MsgType is probably uint16_t rather than uint8_t\r
+ {\r
+ case 0x03: // Zoning phase 2\r
+ {\r
+ nextAnalyser = new PUdpZoning2(mDecodeData);\r
+ break;\r
+ }\r
+ case 0x06: // Char/Clan/Rank/Map Info request\r
+ {\r
+ nextAnalyser = new PUdpReqInfo(mDecodeData);\r
+ break;\r
+ }\r
+ case 0x0b: // Entity position request\r
+ {\r
+ nextAnalyser = new PUdpEntityPosRequest(mDecodeData);\r
+ break;\r
+ }\r
+ case 0x0d: // Zoning phase 1\r
+ {\r
+ nextAnalyser = new PUdpZoning1(mDecodeData);\r
+ break;\r
+ }\r
+ default:\r
+ {\r
+ mDecodeData->mUnknownType = MsgType;\r
+ break;\r
+ }\r
+ }\r
+\r
+ if (! nextAnalyser)\r
+ {\r
+ nextAnalyser = new PUdpMsgUnknown(mDecodeData);\r
+ }\r
+\r
+ return nextAnalyser;\r
+}\r
--- /dev/null
+#pragma once\r
+\r
+#include "GameServer/Decoder/UdpAnalyser.hxx"\r
+\r
+class PUdp0x22 : public PUdpMsgAnalyser {\r
+public:\r
+ PUdp0x22(PMsgDecodeData *nDecodeData);\r
+ //~PUdp0x22();\r
+ PUdpMsgAnalyser *Analyse();\r
+ //bool DoAction();\r
+};\r
--- /dev/null
+#include "GameServer/Decoder/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
+\r
+/**** PUdp0x2b ****/\r
+\r
+PUdp0x2b::PUdp0x2b(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData)\r
+{\r
+ nDecodeData->mName << "/0x2b";\r
+}\r
+\r
+PUdpMsgAnalyser* PUdp0x2b::Analyse()\r
+{\r
+ PUdpMsgAnalyser* nextAnalyser = nullptr;\r
+ mDecodeData->mState = DECODE_MORE;\r
+ uint8_t MsgType = mDecodeData->mMessage->U8Data(mDecodeData->Sub0x13Start + 5);\r
+ switch(MsgType)\r
+ {\r
+ case 0x17: // ReceiveDB Terminal Command\r
+ {\r
+ nextAnalyser = new PUdpReceiveDB(mDecodeData);\r
+ break;\r
+ }\r
+ case 0x18: // UpdateDB Terminal Command\r
+ {\r
+ nextAnalyser = new PUdpUpdateDB(mDecodeData);\r
+ break;\r
+ }\r
+ case 0x19: // TryAccess Terminal Command\r
+ {\r
+ nextAnalyser = new PUdpTryAccessDB(mDecodeData);\r
+ break;\r
+ }\r
+ case 0x1b: // DB Query and Command\r
+ {\r
+ nextAnalyser = new PUdpQueryDB(mDecodeData);\r
+ break;\r
+ }\r
+ case 0x1f: // Citycom?\r
+ {\r
+ nextAnalyser = new PUdpTeminal0x1f(mDecodeData);\r
+ break;\r
+ }\r
+\r
+ default:\r
+ {\r
+ mDecodeData->mUnknownType = MsgType;\r
+ break;\r
+ }\r
+ }\r
+\r
+ if (! nextAnalyser)\r
+ {\r
+ nextAnalyser = new PUdpMsgUnknown(mDecodeData);\r
+ }\r
+\r
+ return nextAnalyser;\r
+}\r
--- /dev/null
+#pragma once\r
+\r
+#include "GameServer/Decoder/UdpAnalyser.hxx"\r
+\r
+class PUdp0x2b : public PUdpMsgAnalyser {\r
+public:\r
+ PUdp0x2b(PMsgDecodeData *nDecodeData);\r
+ //~PUdp0x2b();\r
+ PUdpMsgAnalyser *Analyse();\r
+ //bool DoAction();\r
+};\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- udpanalyser.cpp - Analyser class top (used only by PUdpMsgDecoder)\r
- Also includes the PUdpMsgUnknown derived class\r
-\r
- CREATION: 23 Aug 2006 Hammag\r
-\r
- MODIFIED: 30 Aug 2006 Hammag\r
- REASON: - moved these two class in file distinct from PUdpMsgDecoder.\r
- - made implementation\r
-\r
-*/\r
-\r
-#include "main.h"\r
-#include "udpanalyser.h"\r
-\r
-#include "udp_sync.h"\r
-#include "udp_0x13.h"\r
-#include "udp_0x08.h"\r
+#include "GameServer/Decoder/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
/**** PUdpMsgAnalyser ****/\r
\r
PUdpMsgAnalyser* PUdpMsgAnalyser::Analyse()\r
{\r
PUdpMsgAnalyser* nextAnalyser;\r
- u8 MsgType;\r
+ uint8_t MsgType;\r
\r
mDecodeData->mState = DECODE_MORE;\r
//mDecodeData->mTraceKnownMsg = true; // Don't want to trace all known messages\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+\r
+class PMsgDecodeData;\r
+\r
+class PUdpMsgAnalyser {\r
+ friend class PUdpMsgDecoder;\r
+\r
+protected:\r
+ PMsgDecodeData* mDecodeData;\r
+\r
+public:\r
+ PUdpMsgAnalyser(PMsgDecodeData *nDecodeData);\r
+ virtual ~PUdpMsgAnalyser();\r
+\r
+ virtual PUdpMsgAnalyser *Analyse();\r
+ virtual bool DoAction();\r
+\r
+ static int32_t smAnaCount; // temp for check\r
+\r
+};\r
+\r
+class PUdpMsgUnknown : public PUdpMsgAnalyser {\r
+public:\r
+ PUdpMsgUnknown(PMsgDecodeData *nDecodeData);\r
+ //~PUdpMsgUnknown();\r
+\r
+ //bool DoAction();\r
+};\r
+\r
+class PUdpMsgIgnore : public PUdpMsgAnalyser {\r
+public:\r
+ PUdpMsgIgnore(PMsgDecodeData *nDecodeData);\r
+ //~PUdpMsgUnknown();\r
+\r
+ //bool DoAction();\r
+};\r
--- /dev/null
+#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;
+}
--- /dev/null
+#pragma once\r
+\r
+#include "GameServer/Decoder/UdpAnalyser.hxx"\r
+\r
+class PUdpAptLocInfo : public PUdpMsgAnalyser {\r
+public:\r
+ PUdpAptLocInfo(PMsgDecodeData *nDecodeData);\r
+ //~PUdpAptLocInfo();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
- udp_charmove.cpp - decoder classes for UDP char movement messages\r
-\r
- CREATION: 5 Sep 2006 Hammag\r
-\r
- MODIFIED: 10 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
-*/\r
-\r
-#include "main.h"\r
-\r
-#include "udp_charmove.h"\r
-\r
-#include "include/worlds.h"\r
-#include "include/vehicle.h"\r
-#include "include/subway.h"\r
-\r
+#include <string>\r
+#include "GameServer/Decoder/Includes.hxx"\r
+#include "GameServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
#define JUMPHEIGHT 160\r
\r
\r
if ( ! (mInfoBitfield & 0x80) )\r
{\r
- u32 nSeatableObjectId;\r
- u8 nSeatId;\r
+ uint32_t nSeatableObjectId;\r
+ uint8_t nSeatId;\r
if( nChar->GetSeatInUse(&nSeatableObjectId, &nSeatId) == seat_vhc )\r
{\r
tmpMsg = MsgBuilder->BuildCharUseSeatMsg( nClient, nSeatableObjectId, nSeatId );\r
mInfoBitfield = 0x80;\r
}\r
}\r
- \r
+\r
if ( mInfoBitfield & 0x80 ) // Sitting on chair\r
{\r
//tmpMsg = MsgBuilder->BuildCharSittingMsg(nClient, mChairItemID);\r
ClientManager->UDPBroadcast(tmpMsg, nClient, 5000); // TODO: Get the range from config\r
}*/\r
\r
- u16 nSaveZ = nChar->Coords.mZ;\r
+ uint16_t nSaveZ = nChar->Coords.mZ;\r
if(nChar->Coords.mJumpingState)\r
{\r
mInfoBitfield |= 0x02; // Update Z and Act only\r
if ( IsRealMove && nClient->GetDebugMode( DBG_LOCATION ) )\r
{\r
char DbgMessage[128];\r
- f32 f[3];\r
-// u32 h[3];\r
+ float f[3];\r
+// uint32_t h[3];\r
f[0] = nChar->Coords.mY - 32000;\r
f[1] = nChar->Coords.mZ - 32000;\r
f[2] = nChar->Coords.mX - 32000;\r
Chat->send( nClient, CHAT_GM, "Debug", DbgMessage );\r
}\r
/*{\r
- u16 p[3];\r
+ uint16_t p[3];\r
p[0] = nChar->Coords.mY;\r
p[1] = nChar->Coords.mZ;\r
p[2] = nChar->Coords.mX;\r
}\r
\r
PMessage* tmpMsg;\r
- u32 cSeatObjectId;\r
- u8 cSeatId;\r
+ uint32_t cSeatObjectId;\r
+ uint8_t cSeatId;\r
PSeatType cSeatType = nChar->GetSeatInUse( &cSeatObjectId, &cSeatId );\r
- u32 tNowTime = GameServer->GetGameTime();\r
+ uint32_t tNowTime = GameServer->GetGameTime();\r
bool ReadyToExit = false;\r
\r
// This is only for investigation on subway timing\r
if ( nClient->GetDebugMode( DBG_SUBWAY ) && ( cSeatType == seat_subway ) )\r
{\r
char DbgMessage[80];\r
- u8 tCabId;\r
+ uint8_t tCabId;\r
Subway->GetInfoIndex( cSeatObjectId, &tCabId );\r
- u8 tStationId = Subway->GetStation( cSeatObjectId, tNowTime );\r
+ uint8_t tStationId = Subway->GetStation( cSeatObjectId, tNowTime );\r
std::string* StationName = Subway->GetStationName( tStationId );\r
std::string OpenState = ( Subway->IsDoorOpen( cSeatObjectId, tNowTime ) ? "open" : "closed" );\r
\r
}\r
else if ( cSeatType == seat_vhc )\r
{\r
- PSpawnedVehicle* tVhc = tWorld->GetSpawnedVehicules()->GetVehicle( cSeatObjectId );\r
+ PSpawnedVehicle* tVhc = tWorld->GetSpawnedVehicles()->GetVehicle( cSeatObjectId );\r
if ( tVhc && (!nVhc || (tVhc == nVhc) || nForce) )\r
{\r
PVhcCoordinates tCoords = tVhc->GetPosition();\r
else // If not moving, jump now\r
{\r
if ( gDevDebug ) Console->Print( "%s Send static jump", Console->ColorText( CYAN, BLACK, "[DEBUG]" ) );\r
- u8 mInfoBitfield = 0x22; // Update Z and Act only\r
- u16 nSaveZ = nChar->Coords.mZ;\r
+ uint8_t mInfoBitfield = 0x22; // Update Z and Act only\r
+ uint16_t nSaveZ = nChar->Coords.mZ;\r
(nChar->Coords.mZ) += JUMPHEIGHT;\r
PMessage* tmpMsg = MsgBuilder->BuildCharPosUpdate2Msg( nClient, mInfoBitfield );\r
nChar->Coords.mZ = nSaveZ;\r
{\r
PClient* nClient = mDecodeData->mClient;\r
PChar* tChar = nClient->GetChar();\r
- u16 CharID = mDecodeData->mMessage->U16Data( mDecodeData->Sub0x13Start + 2 );\r
- u8 strangeval1 = mDecodeData->mMessage->U8Data( mDecodeData->Sub0x13Start + 4 );\r
- u8 strangeval2 = mDecodeData->mMessage->U8Data( mDecodeData->Sub0x13Start + 5 );\r
- u8 strangeval3 = mDecodeData->mMessage->U8Data( mDecodeData->Sub0x13Start + 6 );\r
+ uint16_t CharID = mDecodeData->mMessage->U16Data( mDecodeData->Sub0x13Start + 2 );\r
+ uint8_t strangeval1 = mDecodeData->mMessage->U8Data( mDecodeData->Sub0x13Start + 4 );\r
+ uint8_t strangeval2 = mDecodeData->mMessage->U8Data( mDecodeData->Sub0x13Start + 5 );\r
+ uint8_t strangeval3 = mDecodeData->mMessage->U8Data( mDecodeData->Sub0x13Start + 6 );\r
\r
tChar->SetLookingAt( CharID );\r
\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include "GameServer/Decoder/UdpAnalyser.hxx"\r
+\r
+class PChar;\r
+class PClient;\r
+class PSpawnedVehicle;\r
+\r
+class PUdpCharPosUpdate : public PUdpMsgAnalyser {\r
+private:\r
+ uint8_t mInfoBitfield;\r
+ uint16_t mNewY;\r
+ uint16_t mNewZ;\r
+ uint16_t mNewX;\r
+ uint8_t mNewUD;\r
+ uint8_t mNewLR;\r
+ uint8_t mNewAct;\r
+ uint8_t mNewUnknown;\r
+ uint32_t mChairItemID; // uint16_t or uint32_t ???\r
+ uint8_t mChairItemSeat;\r
+\r
+public:\r
+ PUdpCharPosUpdate(PMsgDecodeData *nDecodeData);\r
+ //~PUdpCharMoves();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
+\r
+class PUdpCharExitChair : public PUdpMsgAnalyser {\r
+public:\r
+ PUdpCharExitChair(PMsgDecodeData *nDecodeData);\r
+ //~PUdpCharExitChair();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+\r
+ //nClient is optionnal, nVhc is to limit to that vhc, nForce to force exit event when cab door closed\r
+ static bool DoLeaveChair(PChar *nChar, PClient *nClient = nullptr, PSpawnedVehicle *nVhc = nullptr,\r
+ bool nForce = false);\r
+};\r
+\r
+class PUdpCharJump : public PUdpMsgAnalyser {\r
+public:\r
+ PUdpCharJump(PMsgDecodeData *nDecodeData);\r
+ //~PUdpCharJump();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
+\r
+class PUdpCharTargeting : public PUdpMsgAnalyser {\r
+public:\r
+ PUdpCharTargeting(PMsgDecodeData *nDecodeData);\r
+ //~PUdpCharTargeting();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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;
}
// 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;
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;*/
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))
mDecodeData->mState = DECODE_ERROR;
mDecodeData->mErrorDetail = "Invalid charname position";
}
-
+
return this;
}
else
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)
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;
}
PUdpChatListRemove::PUdpChatListRemove(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData)
{
nDecodeData->mName << "/0x39";
-}
+}
PUdpMsgAnalyser* PUdpChatListRemove::Analyse()
{
PMessage* nMsg = mDecodeData->mMessage;
nMsg->SetNextByteOffset(mDecodeData->Sub0x13Start + 8);
(*nMsg) >> mChatList;
-
+
if ((mChatList == 1) || (mChatList == 2))
{
(*nMsg) >> mRemovedCharID;
bool PUdpChatListRemove::DoAction()
{
PClient* nClient = mDecodeData->mClient;
-
+
bool RemoveResult = false;
-
+
if (mRemovedCharID)
{
switch(mChatList)
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;
}
PUdpChatChannels::PUdpChatChannels(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData)
{
nDecodeData->mName << "/0x4c";
-}
+}
PUdpMsgAnalyser* PUdpChatChannels::Analyse()
{
PMessage* nMsg = mDecodeData->mMessage;
nMsg->SetNextByteOffset(mDecodeData->Sub0x13Start + 8);
(*nMsg) >> mChannelFlags;
-
+
mDecodeData->mState = DECODE_ACTION_READY | DECODE_FINISHED;
return this;
}
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include "GameServer/Decoder/UdpAnalyser.hxx"\r
+\r
+class PUdpChatLocal : public PUdpMsgAnalyser {\r
+public:\r
+ PUdpChatLocal(PMsgDecodeData *nDecodeData);\r
+ //~PUdpChatLocal();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
+\r
+class PUdpChatGlobal : public PUdpMsgAnalyser {\r
+public:\r
+ PUdpChatGlobal(PMsgDecodeData *nDecodeData);\r
+ //~PUdpChatGlobal();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
+\r
+class PUdpChatListAdd : public PUdpMsgAnalyser {\r
+private:\r
+ uint8_t mChatList; // 1 = Direct, 2 = Buddy List\r
+ char *mAddedCharname;\r
+\r
+public:\r
+ PUdpChatListAdd(PMsgDecodeData *nDecodeData);\r
+ //~PUdpChatListAdd();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
+\r
+class PUdpChatListRemove : public PUdpMsgAnalyser {\r
+private:\r
+ uint8_t mChatList;\r
+ uint32_t mRemovedCharID;\r
+\r
+public:\r
+ PUdpChatListRemove(PMsgDecodeData *nDecodeData);\r
+ //~PUdpChatListRemove();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
+\r
+class PUdpChatChannels : public PUdpMsgAnalyser {\r
+private:\r
+ uint32_t mChannelFlags; // 1 bit per custom channel, starting from LSB, in same order as in chat i/f\r
+\r
+public:\r
+ PUdpChatChannels(PMsgDecodeData *nDecodeData);\r
+ //~PUdpChatChannels();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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 ****/
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#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();
+};
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- udp_entityposreq.cpp - decoder classes for UDP entity position request messages\r
-\r
- CREATION: 8 jun 2007 Hammag\r
-\r
- MODIFIED: 10 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
-*/\r
-\r
-\r
-#include "main.h"\r
-\r
-#include "udp_entityposreq.h"\r
-\r
-#include "include/worlds.h"\r
-\r
+#include "GameServer/Decoder/Includes.hxx"\r
+#include "GameServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
PUdpEntityPosRequest::PUdpEntityPosRequest(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData)\r
{\r
PMessage* nMsg = mDecodeData->mMessage;\r
nMsg->SetNextByteOffset(mDecodeData->Sub0x13Start + 7);\r
\r
- *nMsg >> mEntityID; //(u16 ... or u32 ???)\r
+ *nMsg >> mEntityID; //(uint16_t ... or uint32_t ???)\r
\r
if(mEntityID >= WORLDDATATEMPLATE_MAXPOSITEMS)\r
{\r
PClient* nClient = mDecodeData->mClient;\r
PChar* nChar = nClient->GetChar();\r
PWorld* currentWorld = Worlds->GetWorld(nChar->GetLocation());\r
- f32 fpX, fpY, fpZ;\r
- u16 pX, pY, pZ;\r
+ float fpX, fpY, fpZ;\r
+ uint16_t pX, pY, pZ;\r
\r
if(currentWorld)\r
{\r
if((mEntityID < WORLDDATATEMPLATE_MAXPOSITEMS) && currentWorld->getPositionItemPosition(mEntityID, &fpX, &fpY, &fpZ))\r
{\r
- pX = (u16) (fpX + 32000);\r
- pY = (u16) (fpY + 32000);\r
- pZ = (u16) (fpZ + 32000);\r
+ pX = (uint16_t) (fpX + 32000);\r
+ pY = (uint16_t) (fpY + 32000);\r
+ pZ = (uint16_t) (fpZ + 32000);\r
\r
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);\r
}\r
pX = pY = pZ = 0;\r
Console->Print("%s Client[%d] requested invalid position entity %d. Position reset.", Console->ColorText(YELLOW, BLACK, "[Notice]"), mDecodeData->mClient->GetID(), mEntityID);\r
}\r
- \r
+\r
PMessage* tmpMsg;\r
tmpMsg = MsgBuilder->BuildEntityPositionMsg(nClient, pX, pY, pZ);\r
nClient->SendUDPMessage(tmpMsg);\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include "GameServer/Decoder/UdpAnalyser.hxx"\r
+\r
+class PUdpEntityPosRequest : public PUdpMsgAnalyser {\r
+private:\r
+ uint16_t mEntityID; // u16 or u32 ???\r
+\r
+public:\r
+ PUdpEntityPosRequest(PMsgDecodeData *nDecodeData);\r
+ //~PUdpEntityPosRequest();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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 ****/
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;
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);
--- /dev/null
+#pragma once\r
+\r
+#include "GameServer/Decoder/UdpAnalyser.hxx"\r
+\r
+class PUdpHackFail : public PUdpMsgAnalyser {\r
+public:\r
+ PUdpHackFail(PMsgDecodeData *nDecodeData);\r
+ //~PUdpHackFail();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
+\r
+class PUdpHackSuccess : public PUdpMsgAnalyser {\r
+public:\r
+ PUdpHackSuccess(PMsgDecodeData *nDecodeData);\r
+ //~PUdpHackSuccess();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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 ****/
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;
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
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 );
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)
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#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();
+};
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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 ****/
{
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 );
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 );
}
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);
*/
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
*/
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 ) )
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#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();
+};
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- udp_itemmove.cpp - decoder classes for UDP item move related messages\r
-\r
- CREATION: 30 Dec 2006 Namikon\r
-\r
- MODIFIED: 28 Aug 2007 Hammag\r
- REASON: - Moved decoding part from DoAction() to Analyse(), use natural decode methods\r
- MODIFIED: 10 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
-*/\r
-\r
-\r
-#include "main.h"\r
-\r
-#include "udp_itemmove.h"\r
-\r
-#include "include/chars.h"\r
-#include "include/inventory.h"\r
-#include "include/container.h"\r
-\r
+#include "GameServer/Decoder/Includes.hxx"\r
+#include "GameServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
/**** PUdpItemMove ****/\r
\r
bool MoveSucceded = false;\r
PClient* nClient = mDecodeData->mClient;\r
PChar* tChar = nClient->GetChar();\r
- u8 origDstX = mDstX;\r
- u8 origDstY = mDstY;\r
+ uint8_t origDstX = mDstX;\r
+ uint8_t origDstY = mDstY;\r
PContainerEntry* tEntry;\r
\r
PItem* tItem = NULL;\r
return true;\r
}\r
\r
-PContainer* PUdpItemMove::GetContainerByLoc( PChar* nChar, u8 nLoc )\r
+PContainer* PUdpItemMove::GetContainerByLoc( PChar* nChar, uint8_t nLoc )\r
{\r
PContainer* tContainer = NULL;\r
\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include "GameServer/Decoder/UdpAnalyser.hxx"\r
+\r
+class PContainer;\r
+\r
+class PUdpItemMove : public PUdpMsgAnalyser {\r
+private:\r
+ uint8_t mSrcLoc;\r
+ uint8_t mSrcX;\r
+ uint8_t mSrcY;\r
+ uint8_t mDstLoc;\r
+ uint8_t mDstX;\r
+ uint8_t mDstY;\r
+ uint8_t mItemCnt;\r
+\r
+public:\r
+ PUdpItemMove(PMsgDecodeData *nDecodeData);\r
+ //~PUdpItemMove();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+\r
+ static PContainer *GetContainerByLoc(PChar *nChar, uint8_t nLoc);\r
+};\r
+\r
+class PUdpItemMoveBP : public PUdpMsgAnalyser {\r
+private:\r
+ uint8_t mSrcSlotId;\r
+ uint8_t mDumb;\r
+ uint8_t mDstX;\r
+ uint8_t mDstY;\r
+\r
+public:\r
+ PUdpItemMoveBP(PMsgDecodeData *nDecodeData);\r
+ //~PUdpItemMove();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
+\r
+class PUdpItemDropOnItem : public PUdpMsgAnalyser {\r
+private:\r
+ uint8_t mSrcLoc;\r
+ uint8_t mSrcX;\r
+ uint8_t mSrcY;\r
+ uint8_t mDstLoc;\r
+ uint8_t mDstX;\r
+ uint8_t mDstY;\r
+\r
+public:\r
+ PUdpItemDropOnItem(PMsgDecodeData *nDecodeData);\r
+ //~PUdpItemDropOnItem();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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 ****/
--- /dev/null
+#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();
+};
--- /dev/null
+#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)
+ */
+}
--- /dev/null
+#pragma once
+
+#include "GameServer/Decoder/UdpAnalyser.hxx"
+
+class PUdpKillSelf : public PUdpMsgAnalyser {
+public:
+ PUdpKillSelf(PMsgDecodeData *nDecodeData);
+ //~PUdpKillSelf();
+ PUdpMsgAnalyser *Analyse();
+ bool DoAction();
+};
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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 ****/
PMessage* TmpMsg = mDecodeData->mMessage;
- u8 tChunkSize = 0;
+ uint8_t tChunkSize = 0;
( *TmpMsg ) >> tChunkSize;
TmpMsg->SetNextByteOffset( mDecodeData->Sub0x13Start + 5 );
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#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();
+};
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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 ****/
--- /dev/null
+#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();
+};
--- /dev/null
+#include "GameServer/Decoder/Includes.hxx"\r
+#include "GameServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
+\r
+/**** PUdpOOO ****/\r
+\r
+PUdpOOO::PUdpOOO(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData)\r
+{\r
+ nDecodeData->mName << "/0x01";\r
+}\r
+\r
+PUdpMsgAnalyser* PUdpOOO::Analyse()\r
+{\r
+ mDecodeData->mName << "=Out Of Order";\r
+ mDecodeData->mState = DECODE_ACTION_READY | DECODE_FINISHED;\r
+\r
+ return this;\r
+}\r
+\r
+bool PUdpOOO::DoAction()\r
+{\r
+ uint16_t MissingUDP_ID = mDecodeData->mMessage->U16Data(mDecodeData->Sub0x13Start+5);\r
+\r
+ mDecodeData->mClient->getUDPConn()->ReSendUDPMessage(MissingUDP_ID);\r
+ //Console->Print("%s Out of Order packet received ! (Client is missing UDPID %d) ***not managed yet***", Console->ColorText(YELLOW, BLACK, "[Notice]"), MissingUDP_ID);\r
+\r
+ mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED;\r
+ return true;\r
+}\r
--- /dev/null
+#pragma once\r
+\r
+#include "GameServer/Decoder/UdpAnalyser.hxx"\r
+\r
+class PUdpOOO : public PUdpMsgAnalyser {\r
+public:\r
+ PUdpOOO(PMsgDecodeData *nDecodeData);\r
+ //~PUdpPing();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
--- /dev/null
+#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;
+}
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#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();
+};
--- /dev/null
+#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;
+}
--- /dev/null
+#pragma once\r
+\r
+#include "GameServer/Decoder/UdpAnalyser.hxx"\r
+\r
+class PUdpPacket0 : public PUdpMsgAnalyser {\r
+public:\r
+ PUdpPacket0(PMsgDecodeData *nDecodeData);\r
+ //~PUdpPacket0();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
--- /dev/null
+#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;
+}
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include "GameServer/Decoder/UdpAnalyser.hxx"\r
+\r
+class PUdpPing : public PUdpMsgAnalyser {\r
+private:\r
+ uint32_t mClientTime;\r
+\r
+public:\r
+ PUdpPing(PMsgDecodeData *nDecodeData);\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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 ****/
{
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 )
{
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 );
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 );
PWorld* CurrentWorld = Worlds->GetWorld( requesterChar->GetLocation() );
if ( CurrentWorld )
{
- PSpawnedVehicle* tVhc = CurrentWorld->GetSpawnedVehicules()->GetVehicleByGlobalId( vehicleId );
+ PSpawnedVehicle* tVhc = CurrentWorld->GetSpawnedVehicles()->GetVehicleByGlobalId( vehicleId );
if ( tVhc )
{
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#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();
+};
--- /dev/null
+#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;
+}
--- /dev/null
+#pragma once
+
+#include "GameServer/Decoder/UdpAnalyser.hxx"
+
+class PUdpPvPTrade : public PUdpMsgAnalyser {
+public:
+ PUdpPvPTrade(PMsgDecodeData *nDecodeData);
+ //~PUdpPvPTrade();
+ PUdpMsgAnalyser *Analyse();
+ bool DoAction();
+};
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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 ****/
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 )
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include "GameServer/Decoder/UdpAnalyser.hxx"\r
+\r
+class PUdpItemSlotUse : public PUdpMsgAnalyser {\r
+private:\r
+ uint8_t mTargetSlot;\r
+\r
+public:\r
+ PUdpItemSlotUse(PMsgDecodeData *nDecodeData);\r
+ //~PUdpItemSlotUse();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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 <cstring>
+#include "GameServer/Decoder/Includes.hxx"
+#include "GameServer/Includes.hxx"
+#include "Common/Includes.hxx"
/**** PUdpCharInfo ****/
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
// 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 = "";
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include "GameServer/Decoder/UdpAnalyser.hxx"\r
+\r
+class PUdpReqInfo : public PUdpMsgAnalyser {\r
+private:\r
+ uint16_t mRequestType;\r
+ uint32_t mInfoId;\r
+\r
+public:\r
+ PUdpReqInfo(PMsgDecodeData *nDecodeData);\r
+ //~PUdpCharInfo();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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()
{
SubskillID = mDecodeData->mMessage->U16Data(mDecodeData->Sub0x13Start+9);
mDecodeData->mState = DECODE_ACTION_READY | DECODE_FINISHED;
-
+
return this;
}
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include "GameServer/Decoder/UdpAnalyser.hxx"\r
+\r
+class PUdpSubskillInc : public PUdpMsgAnalyser {\r
+private:\r
+ uint16_t SubskillID;\r
+\r
+public:\r
+ PUdpSubskillInc(PMsgDecodeData *nDecodeData);\r
+ //~PUdpSubskillInc();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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 ****/
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 );
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;
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 )
PWorld* CurrentWorld = Worlds->GetWorld( nClient->GetChar()->GetLocation() );
if ( CurrentWorld )
{
- PSpawnedVhcList* VhcList = CurrentWorld->GetSpawnedVehicules()->GetSpawnedVehicles();
+ PSpawnedVhcList* VhcList = CurrentWorld->GetSpawnedVehicles()->GetSpawnedVehicles();
PSpawnedVehicle* VhcEntry;
PMessage* VhcMsg;
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include "GameServer/Decoder/UdpAnalyser.hxx"\r
+\r
+class PUdpSync0 : public PUdpMsgAnalyser {\r
+public:\r
+ PUdpSync0(PMsgDecodeData *nDecodeData);\r
+ //~PUdpSync0();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+\r
+ static void GetToSync1(PMsgDecodeData *nDecodeData);\r
+};\r
+\r
+class PUdpSync1 : public PUdpMsgAnalyser {\r
+public:\r
+ PUdpSync1(PMsgDecodeData *nDecodeData);\r
+ //~PUdpSync1();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
+\r
+class PUdpSync2 : public PUdpMsgAnalyser {\r
+private:\r
+ uint32_t mClientTime;\r
+\r
+public:\r
+ PUdpSync2(PMsgDecodeData *nDecodeData);\r
+ //~PUdpSync2();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- udp_terminal.cpp - decoder classes for UDP terminal related messages\r
-\r
- CREATION: 08 Jan 2007 Namikon\r
-\r
- MODIFIED: 10 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
-*/\r
-\r
-\r
-#include "main.h"\r
-\r
-#include "udp_terminal.h"\r
-#include "udp_charmove.h"\r
-\r
-#include "include/terminal.h"\r
-#include "include/vehicle.h"\r
-#include "include/worlds.h"\r
-#include "include/furnituretemplate.h"\r
-\r
#include <cmath>\r
+#include "GameServer/Decoder/Includes.hxx"\r
+#include "GameServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
/*******************************************************************************************/\r
/**** PUdpReceiveDB ****/\r
PUdpMsgAnalyser* PUdpReceiveDB::Analyse()\r
{\r
PMessage* TmpMsg = mDecodeData->mMessage;\r
- u16 Unknown3, OptionSize;\r
+ uint16_t Unknown3, OptionSize;\r
\r
mDecodeData->mName << "=ReceiveDB request from client";\r
\r
if ( gDevDebug )\r
{\r
Console->Print( "%s ReceiveDB request from client", Console->ColorText( CYAN, BLACK, "[DEBUG]" ) );\r
- Console->Print( "%s Open Terminal - Terminal session %04x (?) - Unknown1 %04x - DBId %04x - Unknown2 %02x", Console->ColorText( CYAN, BLACK, "[DEBUG]" ), mTerminalSessionId, mUnknown1, mDBId, mUnknown2 );\r
+ Console->Print( "%s Open Terminal - Terminal session %04x (?) - Unknown1 %04x - DBId %04x - Unknown2 %02x", Console->ColorText( CYAN, BLACK, "[DEBUG]" ), mTerminalSessionId, mUnknown1, mDBId, mUnknown2 );\r
Console->Print( "%s Command: '%s'", Console->ColorText( CYAN, BLACK, "[DEBUG]" ), mCommandName.c_str() );\r
- for ( u8 i = 0; i < mOptionsCount; ++i )\r
+ for ( uint8_t i = 0; i < mOptionsCount; ++i )\r
Console->Print( "%s Option %d: '%s'", Console->ColorText( CYAN, BLACK, "[DEBUG]" ), i, mOptions[i].c_str() );\r
}\r
\r
if ( !Result )\r
{\r
Console->Print( "%s PUdpReceiveDB - Error or unknown command %s", Console->ColorText( RED, BLACK, "[WARNING]" ), mCommandName.c_str() );\r
- for ( u8 i = 0; i < mOptionsCount; ++i )\r
+ for ( uint8_t i = 0; i < mOptionsCount; ++i )\r
Console->Print( "%s Option %d: '%s'", Console->ColorText( RED, BLACK, "[NOTICE]" ), i, mOptions[i].c_str() );\r
}\r
\r
\r
if ( mOptionsCount == 3 ) // CharId, StartVhcEntry, MaxVhcEntries\r
{\r
- if ((( u32 )atol( mOptions[0].c_str() ) ) != tChar->GetID() )\r
+ if ((( uint32_t )atol( mOptions[0].c_str() ) ) != tChar->GetID() )\r
{\r
// Err: invalid CharId. Can alert, But we don't care :-) (except if used for other terminal function)\r
}\r
// !!! some more check/regex on values to do before using !!!\r
- u16 StartIndex = atoi( mOptions[1].c_str() );\r
- u16 MaxEntries = atoi( mOptions[2].c_str() );\r
+ uint16_t StartIndex = atoi( mOptions[1].c_str() );\r
+ uint16_t MaxEntries = atoi( mOptions[2].c_str() );\r
\r
- u8 nStatus = 1;\r
- u16 nErrcode = 0;\r
+ uint8_t nStatus = 1;\r
+ uint16_t nErrcode = 0;\r
\r
tmpMsg = MsgBuilder->BuildDBRequestStatusMsg( tClient, &mCommandName, nStatus, nErrcode );\r
tClient->SendUDPMessage( tmpMsg );\r
PVhcInfoList* VhcList = Vehicles->GetCharVehicles( tChar->GetID(), MaxEntries, StartIndex );\r
if ( ! VhcList->empty() )\r
{\r
- u16 NumEntries = VhcList->size();\r
+ uint16_t NumEntries = VhcList->size();\r
std::string* Answer = new std::string[4 * NumEntries];\r
- u16 Index = 0;\r
+ uint16_t Index = 0;\r
PVehicleInformation* EntryInfo;\r
//Console->Print("VHc entries : %d", NumEntries);\r
\r
return false;\r
/*\r
// Option1=CharId, Option2=resultEntryStart, Option3=maxResultEntries\r
- S=> 03/2b/1a <u16 size incl 0><u8 bool succes ?><u16 err code ?>VehicleListing+0\r
+ S=> 03/2b/1a <uint16_t size incl 0><uint8_t bool succes ?><uint16_t err code ?>VehicleListing+0\r
13 2a 00 7c be 19\r
03 2a 00 2b 1a 0f 00 01 00 00 56 65 68 69 63 6c .*.+......Vehicl\r
65 4c 69 73 74 69 6e 67 00 eListing.\r
- S=> 03/2b/17 0f 00 08 00 04 00 <0f 00><u16 entries nb><04 00>\r
+ S=> 03/2b/17 0f 00 08 00 04 00 <0f 00><uint16_t entries nb><04 00>\r
VehicleListing+0\r
<id_size incl 0><id_string +0>\r
<type_size><type_id_string? +0>\r
<status_size><status_string +0> (val: 0=stored)\r
<health_size><health_string +0> (val: 0-255)\r
==\r
- 03/2b/17 0f 00 01 00 04 00 <0f 00><u16 entries nb><04 00>\r
+ 03/2b/17 0f 00 01 00 04 00 <0f 00><uint16_t entries nb><04 00>\r
31\r
03 54 00 2b 17 0f 00 01 00 04 00 56 65 68 69 63 6c 65 4c 69 73 74 .....VehicleList\r
69 6e 67 00 06 00 32 35 32 37 37 00 03 00 36 30 ing...25277...60\r
if ( mOptionsCount == 2 ) // VhcId, CharId\r
{\r
// !!! validate values !!!\r
- u8 nStatus = 1;\r
- u16 nErrcode = 0;\r
+ uint8_t nStatus = 1;\r
+ uint16_t nErrcode = 0;\r
\r
tmpMsg = MsgBuilder->BuildDBRequestStatusMsg( tClient, &mCommandName, nStatus, nErrcode );\r
tClient->SendUDPMessage( tmpMsg );\r
\r
- u32 VhcId = ( u32 )atol( mOptions[0].c_str() );\r
+ uint32_t VhcId = ( uint32_t )atol( mOptions[0].c_str() );\r
PVehicleInformation EntryInfo;\r
if ( Vehicles->GetVehicleInfo( VhcId, &EntryInfo ) )\r
{\r
PUdpMsgAnalyser* PUdpUpdateDB::Analyse()\r
{\r
PMessage* TmpMsg = mDecodeData->mMessage;\r
- u16 Unknown3, OptionSize;\r
+ uint16_t Unknown3, OptionSize;\r
\r
mDecodeData->mName << "=UpdateDB request from client";\r
\r
Console->Print( "%s UpdateDB request from client", Console->ColorText( CYAN, BLACK, "[DEBUG]" ) );\r
Console->Print( "%s Open Terminal - Terminal session %04x (?)", Console->ColorText( CYAN, BLACK, "[DEBUG]" ), mTerminalSessionId );\r
Console->Print( "%s Command: '%s'", Console->ColorText( CYAN, BLACK, "[DEBUG]" ), mCommandName.c_str() );\r
- for ( u8 i = 0; i < mOptionsCount; ++i )\r
+ for ( uint8_t i = 0; i < mOptionsCount; ++i )\r
Console->Print( "%s Option %d: '%s'", Console->ColorText( CYAN, BLACK, "[DEBUG]" ), i, mOptions[i].c_str() );\r
}\r
bool Result = false;\r
if ( !Result )\r
{\r
Console->Print( "%s PUdpUpdateDB - Error or unknown command %s", Console->ColorText( RED, BLACK, "[WARNING]" ), mCommandName.c_str() );\r
- for ( u8 i = 0; i < mOptionsCount; ++i )\r
+ for ( uint8_t i = 0; i < mOptionsCount; ++i )\r
Console->Print( "%s Option %d: '%s'", Console->ColorText( RED, BLACK, "[NOTICE]" ), i, mOptions[i].c_str() );\r
}\r
mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED;\r
PUdpMsgAnalyser* PUdpTryAccessDB::Analyse()\r
{\r
PMessage* TmpMsg = mDecodeData->mMessage;\r
- u16 Unknown3, OptionSize;\r
+ uint16_t Unknown3, OptionSize;\r
\r
mDecodeData->mName << "=TryAccess request from client";\r
\r
PUdpMsgAnalyser* PUdpQueryDB::Analyse()\r
{\r
PMessage* TmpMsg = mDecodeData->mMessage;\r
- u16 OptionSize;\r
+ uint16_t OptionSize;\r
\r
mDecodeData->mName << "=QueryDB request from client";\r
\r
Console->Print( "%s Open Terminal - Terminal session %04x (?)", Console->ColorText( CYAN, BLACK, "[DEBUG]" ), mTerminalSessionId );\r
Console->Print( "%s DBCommand: '%s'", Console->ColorText( CYAN, BLACK, "[DEBUG]" ), mDBCommandName.c_str() );\r
Console->Print( "%s Command: '%s'", Console->ColorText( CYAN, BLACK, "[DEBUG]" ), mCommandName.c_str() );\r
- for ( u8 i = 0; i < mOptionsCount; ++i )\r
+ for ( uint8_t i = 0; i < mOptionsCount; ++i )\r
Console->Print( "%s Option %d: '%s'", Console->ColorText( CYAN, BLACK, "[DEBUG]" ), i, mOptions[i].c_str() );\r
}\r
\r
if ( !Result )\r
{\r
Console->Print( "%s PUdpQueryDB - Error or unknown command %s", Console->ColorText( RED, BLACK, "[WARNING]" ), mDBCommandName.c_str() );\r
- for ( u8 i = 0; i < mOptionsCount; ++i )\r
+ for ( uint8_t i = 0; i < mOptionsCount; ++i )\r
Console->Print( "%s Option %d: '%s'", Console->ColorText( RED, BLACK, "[NOTICE]" ), i, mOptions[i].c_str() );\r
}\r
\r
\r
if ( mOptionsCount == 3 ) // 0, VhcId, CharId\r
{\r
- u32 VhcId = ( u32 )atol( mOptions[1].c_str() );\r
- //u32 CharId = (u32)atol(mOptions[2].c_str());\r
+ uint32_t VhcId = ( uint32_t )atol( mOptions[1].c_str() );\r
+ //uint32_t CharId = (uint32_t)atol(mOptions[2].c_str());\r
// !!! validate values !!!\r
// !!! + check CharId = current char && CharId is owner of VhcId\r
- u8 nStatus = 1; // 1=OK, 0=Err\r
- u16 nErrcode = 16; // 0=n/a 16=Already Spawned // MsdId = 2500+nErrcode [MISC]\r
+ uint8_t nStatus = 1; // 1=OK, 0=Err\r
+ uint16_t nErrcode = 16; // 0=n/a 16=Already Spawned // MsdId = 2500+nErrcode [MISC]\r
\r
tmpMsg = MsgBuilder->BuildDBRequestStatusMsg( tClient, &mCommandName, nStatus, nErrcode );\r
tClient->SendUDPMessage( tmpMsg );\r
const PFurnitureItemTemplate* tFurnitureTemplate = CurrentWorld->GetFurnitureItemTemplate( tChar->GetLastUsedObject() / 1024 - 1 );\r
if ( tFurnitureTemplate && ( tFurnitureTemplate->GetFunctionType() == 28 ) ) // vhc term\r
{\r
- f32 decal = 1000; // distance at which to spawn the vhc\r
- f32 nPosX, nPosY, nPosZ;\r
+ float decal = 1000; // distance at which to spawn the vhc\r
+ float nPosX, nPosY, nPosZ;\r
tFurnitureTemplate->GetPos( &nPosX, &nPosY, &nPosZ );\r
nPosX += 32000;\r
nPosY += 32000;\r
- f32 dX = ( tChar->Coords.mX - nPosX );\r
- f32 dY = ( tChar->Coords.mY - nPosY );\r
- f32 d = decal / sqrt( dX * dX + dY * dY );\r
- NewPosition.SetPosition( static_cast<u16>( nPosY + d * dY ), ( tChar->Coords ).mZ + 100, static_cast<u16>( nPosX + d * dX ), ( tChar->Coords ).mUD, 34683, 32403 );\r
+ float dX = ( tChar->Coords.mX - nPosX );\r
+ float dY = ( tChar->Coords.mY - nPosY );\r
+ float d = decal / sqrt( dX * dX + dY * dY );\r
+ NewPosition.SetPosition( static_cast<uint16_t>( nPosY + d * dY ), ( tChar->Coords ).mZ + 100, static_cast<uint16_t>( nPosX + d * dX ), ( tChar->Coords ).mUD, 34683, 32403 );\r
relativePos = true;\r
}\r
}\r
\r
if ( mOptionsCount == 3 ) // 0, VhcId, CharId\r
{\r
- //u32 VhcId = (u32)atol(mOptions[1].c_str());\r
- //u32 CharId = (u32)atol(mOptions[2].c_str());\r
+ //uint32_t VhcId = (uint32_t)atol(mOptions[1].c_str());\r
+ //uint32_t CharId = (uint32_t)atol(mOptions[2].c_str());\r
// !!! validate values !!!\r
\r
- u8 nStatus = 1; // 1=OK, 0=Err\r
- u16 nErrcode = 18; // 0=n/a 18=Still Spawned, 19=Not enough money\r
+ uint8_t nStatus = 1; // 1=OK, 0=Err\r
+ uint16_t nErrcode = 18; // 0=n/a 18=Still Spawned, 19=Not enough money\r
\r
tmpMsg = MsgBuilder->BuildDBRequestStatusMsg( tClient, &mCommandName, nStatus, nErrcode );\r
tClient->SendUDPMessage( tmpMsg );\r
\r
if ( mOptionsCount == 3 ) // 0, VhcId, CharId\r
{\r
- u32 VhcId = ( u32 )atol( mOptions[1].c_str() );\r
- //u32 CharId = (u32)atol(mOptions[2].c_str());\r
+ uint32_t VhcId = ( uint32_t )atol( mOptions[1].c_str() );\r
+ //uint32_t CharId = (uint32_t)atol(mOptions[2].c_str());\r
// !!! validate values !!!\r
// !!! + check CharId = current char && CharId is owner of VjhcId\r
// !!! Check vhc empty\r
- u8 nStatus = 0; // 1=OK, 0=Err\r
- u16 nErrcode = 17; // 0=n/a 17=Not Spawned\r
+ uint8_t nStatus = 0; // 1=OK, 0=Err\r
+ uint16_t nErrcode = 17; // 0=n/a 17=Not Spawned\r
PVehicleInformation nInfo;\r
- u32 tLocalId = 0;\r
- u32 tLocation = 0;\r
+ uint32_t tLocalId = 0;\r
+ uint32_t tLocation = 0;\r
\r
PSpawnedVehicle* tVhc = Vehicles->GetSpawnedVehicle( VhcId );\r
if ( tVhc )\r
{\r
tLocalId = tVhc->GetLocalId();\r
tLocation = tVhc->GetLocation();\r
- u32 tCharId;\r
+ uint32_t tCharId;\r
PChar* tChar;\r
- for ( u8 i = 0; i < tVhc->GetNumSeats(); ++i )\r
+ for ( uint8_t i = 0; i < tVhc->GetNumSeats(); ++i )\r
{\r
if (( tCharId = tVhc->GetSeatUser( i ) ) )\r
{\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include <string>\r
+#include "GameServer/Decoder/UdpAnalyser.hxx"\r
+\r
+class PUdpReceiveDB : public PUdpMsgAnalyser {\r
+private:\r
+ static const uint8_t mMaxOptions = 9; // Largest: forum\forenlist.tsc(21, 114,...)\r
+ uint16_t mTerminalSessionId;\r
+ std::string mCommandName;\r
+ std::string mOptions[mMaxOptions];\r
+ uint8_t mOptionsCount;\r
+\r
+ uint16_t mUnknown1;\r
+ uint8_t mUnknown2;\r
+ uint16_t mDBId;\r
+\r
+ bool ActionVehicleListing();\r
+ bool ActionVehicleControl();\r
+\r
+public:\r
+ PUdpReceiveDB(PMsgDecodeData *nDecodeData);\r
+ //~PUdpReceiveDB();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
+\r
+class PUdpUpdateDB : public PUdpMsgAnalyser {\r
+private:\r
+ static const uint8_t mMaxOptions = 7; // Largest: forum\bbcnewthread.tsc(66):\r
+ uint16_t mTerminalSessionId;\r
+ std::string mCommandName;\r
+ std::string mOptions[mMaxOptions];\r
+ uint8_t mOptionsCount;\r
+\r
+ uint16_t mUnknown1;\r
+ uint8_t mUnknown2;\r
+ uint16_t mDBId;\r
+\r
+public:\r
+ PUdpUpdateDB(PMsgDecodeData *nDecodeData);\r
+ //~PUdpUpdateDB();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
+\r
+class PUdpTryAccessDB : public PUdpMsgAnalyser {\r
+private:\r
+ static const uint8_t mMaxOptions = 9; // Largest: stockx\depot.tsc(227):\r
+ uint16_t mTerminalSessionId;\r
+ std::string mCommandName;\r
+ std::string mOptions[mMaxOptions];\r
+ uint8_t mOptionsCount;\r
+\r
+ uint16_t mUnknown1;\r
+ uint8_t mUnknown2;\r
+ uint16_t mDBId;\r
+\r
+public:\r
+ PUdpTryAccessDB(PMsgDecodeData *nDecodeData);\r
+ //~PUdpTryAccessDB();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
+\r
+class PUdpQueryDB : public PUdpMsgAnalyser { // Also called "ServerMessage" in .tsc scripts!\r
+private:\r
+ static const uint8_t mMaxOptions = 5; // Largest: politics\transcomment.tsc(36):\r
+ uint16_t mTerminalSessionId;\r
+ uint16_t mDBId;\r
+ std::string mDBCommandName;\r
+ std::string mCommandName;\r
+ std::string mOptions[mMaxOptions];\r
+ uint8_t mOptionsCount;\r
+\r
+ bool ActionSpawnVehicle();\r
+ bool ActionRepairVehicle();\r
+ bool ActionDismissVehicle();\r
+\r
+public:\r
+ PUdpQueryDB(PMsgDecodeData *nDecodeData);\r
+ //~PUdpQueryDB();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
+\r
+class PUdpTeminal0x1f : public PUdpMsgAnalyser {\r
+private:\r
+ uint16_t mTerminalSessionId;\r
+\r
+public:\r
+ PUdpTeminal0x1f(PMsgDecodeData *nDecodeData);\r
+ //~PUdpTeminal0x1f();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
+#include "GameServer/Decoder/Includes.hxx"\r
+#include "GameServer/Definitions/Includes.hxx"\r
+#include "GameServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- udp_useobject.cpp - decoder classes for object use related messages\r
-\r
- CREATION: 17 Sep 2006 Hammag\r
-\r
- MODIFIED: 10 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
-\r
- TODO:\r
- - use only RawObjectIDs to avoid complication & errors\r
-*/\r
-\r
-\r
-#include "main.h"\r
-\r
-#include "udp_useobject.h"\r
-#include "udp_vhc.h"\r
-\r
-#include "include/worlds.h"\r
-#include "include/furnituretemplate.h"\r
-#include "include/doortemplate.h"\r
-#include "include/appartements.h"\r
-#include "include/container.h"\r
-#include "include/subway.h"\r
-#include "include/vhcaccessrequest.h"\r
-\r
-\r
-u32 gVhcId = 0x3ff;\r
+uint32_t gVhcId = 0x3ff;\r
\r
/**** PUdpVhcMove ****/\r
\r
{\r
PClient* nClient = mDecodeData->mClient;\r
PChar* nChar = nClient->GetChar();\r
- u32 ItemID;\r
+ uint32_t ItemID;\r
char DbgMessage[128];\r
PMessage* tmpMsg;\r
\r
bool tHandleDynamicActor = false;\r
\r
/*PMessage* cMsg = mDecodeData->mMessage;\r
- u32 ClientTime = cMsg->U32Data(mDecodeData->Sub0x13Start+2);\r
+ uint32_t ClientTime = cMsg->U32Data(mDecodeData->Sub0x13Start+2);\r
\r
tmpMsg = MsgBuilder->BuildPingMsg(mDecodeData->mClient, ClientTime);\r
mDecodeData->mClient->SendUDPMessage(tmpMsg);*/\r
\r
if ( gDevDebug )\r
{\r
- 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 );\r
+ 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 );\r
if ( mRawItemID & 1023 )\r
Console->Print( "using item %d (0x%08x)", mRawItemID, mRawItemID );\r
else\r
\r
if ( nChar->GetSeatInUse() == seat_none ) // Refuse if Char is already sitting somewhere\r
{\r
- PSpawnedVehicle* tVhc = CurrentWorld->GetSpawnedVehicules()->GetVehicle( mRawItemID );\r
+ PSpawnedVehicle* tVhc = CurrentWorld->GetSpawnedVehicles()->GetVehicle( mRawItemID );\r
if ( tVhc )\r
{\r
if ( gDevDebug )\r
{\r
PChar* ownerChar = ownerClient->GetChar();\r
// We could check for valid allowed access before adding a new one\r
- u32 newReqId = ownerChar->GetVhcAccessRequestList()->Add( nChar->GetID(), tVhc->GetInformation().GetVehicleId() );\r
+ uint32_t newReqId = ownerChar->GetVhcAccessRequestList()->Add( nChar->GetID(), tVhc->GetInformation().GetVehicleId() );\r
if ( newReqId )\r
{\r
tmpMsg = MsgBuilder->BuildVhcAccessRequestMsg( ownerClient, newReqId, nChar->GetID(), nClient->GetID(), tVhc->GetInformation().GetVehicleId() );\r
vhcFound = true;\r
if ( Subway->IsDoorOpen( mRawItemID, GameServer->GetGameTime() ) )\r
{\r
- u8 freeSeat = Subway->GetFreeSeat( mRawItemID );\r
+ uint8_t freeSeat = Subway->GetFreeSeat( mRawItemID );\r
if ( freeSeat && Subway->SetSeatUser( mRawItemID, freeSeat, nChar->GetID() ) )\r
{\r
nChar->SetSeatInUse( seat_subway, mRawItemID, freeSeat );\r
\r
if ( !( mDecodeData->mState & DECODE_ACTION_DONE ) ) // not a vhc nor a pc\r
{\r
- //Console->Print(">>> Searching world");\r
+ //Console->Print(">>> Searching world");\r
// Is it a NPC ?\r
PNPC* targetNPC = 0;\r
PNPCWorld* currentNPCWorld = NPCManager->GetWorld( nChar->GetLocation() );\r
\r
if ( tFurnitureModel->GetUseFlags() & ufChair )\r
{\r
- u32 cSeatObjectId;\r
+ uint32_t cSeatObjectId;\r
PSeatType cSeatType = nChar->GetSeatInUse( &cSeatObjectId );\r
if (( cSeatType == seat_none ) || ( cSeatType == seat_chair ) )\r
{\r
{\r
case 6: //Respawn Station (GenRep)\r
{\r
- u32 nLocation = nChar->GetLocation();\r
- u16 nEntity;\r
+ uint32_t nLocation = nChar->GetLocation();\r
+ uint16_t nEntity;\r
if ( Worlds->IsPotentialAppartement( nLocation ) )\r
{\r
- nLocation = 0xffffffff; // (u32)-1;\r
- nEntity = 0xffff; //(u16)-1;\r
+ nLocation = 0xffffffff; // (uint32_t)-1;\r
+ nEntity = 0xffff; //(uint16_t)-1;\r
}\r
else\r
{\r
nEntityInt = GameDefs->Respawns()->GetRespawnEntity( nChar->GetLocation(), WorldActors->GetLinkedObjectID( mRawItemID ) );\r
}\r
\r
- nEntity = ( nEntityInt < 0 ? 0xffff : ( u16 )nEntityInt );\r
+ nEntity = ( nEntityInt < 0 ? 0xffff : ( uint16_t )nEntityInt );\r
}\r
\r
tmpMsg = MsgBuilder->BuildCharUseGenrepMsg( nClient, mRawItemID, nLocation, nEntity );\r
case 15: //HOLOMATCH EXIT\r
{\r
// temp hack + wrong entity... guess it works same as function 20\r
- u32 HoloNum = nChar->GetLocation() - 90000; // value 1 to 16, to transalte to 540..547 550..557 for worldmodel.def\r
+ uint32_t HoloNum = nChar->GetLocation() - 90000; // value 1 to 16, to transalte to 540..547 550..557 for worldmodel.def\r
\r
const PDefWorldModel* tHoloExitModel = GameDefs->WorldModels()->GetDef( 539 + HoloNum + ( HoloNum > 8 ? 2 : 0 ) );\r
if ( tHoloExitModel && ( tHoloExitModel->GetFunctionType() == 14 ) ) // we use the Holomatch entry. Takes care of bad zone id\r
const PDefAppPlace* nAppPlace = GameDefs->AppPlaces()->GetDef( tHoloExitModel->GetFunctionValue() );\r
if ( nAppPlace )\r
{\r
- u32 Location = nAppPlace->GetExitWorldID();\r
- u16 Entity = nAppPlace->GetExitWorldEntity();\r
- u8 SewerLevel = 0;\r
+ uint32_t Location = nAppPlace->GetExitWorldID();\r
+ uint16_t Entity = nAppPlace->GetExitWorldEntity();\r
+ uint8_t SewerLevel = 0;\r
\r
tmpMsg = MsgBuilder->BuildChangeLocationMsg( nClient, Location, Entity, SewerLevel, 0 ); //mRawItemID\r
nClient->SendUDPMessage( tmpMsg );\r
}\r
if ( nAppPlace )\r
{\r
- u32 Location = nAppPlace->GetExitWorldID();\r
- u16 Entity = nAppPlace->GetExitWorldEntity();\r
- u8 SewerLevel = 0;\r
+ uint32_t Location = nAppPlace->GetExitWorldID();\r
+ uint16_t Entity = nAppPlace->GetExitWorldEntity();\r
+ uint8_t SewerLevel = 0;\r
//if(((tFurnitureModel->GetFunctionType() == 20) && nAppPlace->GetSewerLevel()) || (tFurnitureModel->GetFunctionType() == 29))\r
if (( tFurnitureModel->GetFunctionType() == 20 ) || ( tFurnitureModel->GetFunctionType() == 29 ) )\r
{\r
}\r
else\r
{\r
- u32 linkobjID = WorldActors->GetLinkedObjectID( mRawItemID );\r
+ uint32_t linkobjID = WorldActors->GetLinkedObjectID( mRawItemID );\r
if ( linkobjID )\r
{\r
if ( nClient->GetAccountLevel() >= PAL_GM ) // Allow GameMasters and higher to just bypass HackButtons\r
{\r
if ( tFurnitureTemplate->GetLinkedObjectID() )\r
{\r
- u32 OldCash = nChar->GetCash();\r
- u32 DoorFee = ( u32 )tFurnitureModel->GetFunctionValue();\r
+ uint32_t OldCash = nChar->GetCash();\r
+ uint32_t DoorFee = ( uint32_t )tFurnitureModel->GetFunctionValue();\r
if ( OldCash >= DoorFee )\r
{\r
- u32 NewCash = nChar->SetCash( OldCash - DoorFee );\r
+ uint32_t NewCash = nChar->SetCash( OldCash - DoorFee );\r
PMessage* tmpMsg_cash = MsgBuilder->BuildCharMoneyUpdateMsg( nClient, NewCash );\r
nClient->SendUDPMessage( tmpMsg_cash );\r
tmpMsg_cash = NULL;\r
}\r
else\r
{\r
- u32 linkobjID = WorldActors->GetLinkedObjectID( mRawItemID );\r
+ uint32_t linkobjID = WorldActors->GetLinkedObjectID( mRawItemID );\r
if ( linkobjID )\r
{\r
- u32 OldCash = nChar->GetCash();\r
- u32 DoorFee = ( u32 )tFurnitureModel->GetFunctionValue();\r
+ uint32_t OldCash = nChar->GetCash();\r
+ uint32_t DoorFee = ( uint32_t )tFurnitureModel->GetFunctionValue();\r
if ( OldCash >= DoorFee )\r
{\r
- u32 NewCash = nChar->SetCash( OldCash - DoorFee );\r
+ uint32_t NewCash = nChar->SetCash( OldCash - DoorFee );\r
PMessage* tmpMsg_cash = MsgBuilder->BuildCharMoneyUpdateMsg( nClient, NewCash );\r
nClient->SendUDPMessage( tmpMsg_cash );\r
tmpMsg_cash = NULL;\r
}\r
case 32: // Text message\r
{\r
- tmpMsg = MsgBuilder->BuildText100Msg( nClient, ( u8 )( 255 & tFurnitureModel->GetFunctionValue() ), mRawItemID );\r
+ tmpMsg = MsgBuilder->BuildText100Msg( nClient, ( uint8_t )( 255 & tFurnitureModel->GetFunctionValue() ), mRawItemID );\r
nClient->SendUDPMessage( tmpMsg );\r
\r
mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED;\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include "GameServer/Decoder/UdpAnalyser.hxx"\r
+\r
+class PUdpUseObject : public PUdpMsgAnalyser {\r
+private:\r
+ uint32_t mRawItemID;\r
+\r
+ void OldHandler(); // Temp during migration only\r
+\r
+public:\r
+ PUdpUseObject(PMsgDecodeData *nDecodeData);\r
+ //~PUdpUseObject();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
+\r
+class PUdpCloseItemContainer : public PUdpMsgAnalyser {\r
+public:\r
+ PUdpCloseItemContainer(PMsgDecodeData *nDecodeData);\r
+ //~PUdpCloseItemContainer();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- udp_vhc.h - decoder classes for UDP vehicle related messages\r
-\r
- CREATION: 05 Sep 2006 Hammag\r
-\r
- MODIFIED: 10 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
-*/\r
-\r
-\r
-#include "main.h"\r
-\r
-#include "udp_vhc.h"\r
-\r
-#include "include/worlds.h"\r
-#include "include/vehicle.h"\r
-#include "include/subway.h"\r
-\r
+#include "GameServer/Decoder/Includes.hxx"\r
+#include "GameServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
/**** PUdpVhcMove ****/\r
\r
\r
if ( CurrentWorld )\r
{\r
- PSpawnedVehicle* tVhc = CurrentWorld->GetSpawnedVehicules()->GetVehicle( mVhcLocalId );\r
+ PSpawnedVehicle* tVhc = CurrentWorld->GetSpawnedVehicles()->GetVehicle( mVhcLocalId );\r
if ( tVhc )\r
{\r
//Todo: calc & mem Speed & Accel vectors\r
\r
if( CurrentWorld->CheckVhcNeedZoning( &nPos ) )\r
{\r
- u32 destWorldId;\r
+ uint32_t destWorldId;\r
PVhcCoordinates destPos;\r
\r
if (( destWorldId = CurrentWorld->GetVhcZoningDestination( tVhc, &destPos ) ) )\r
{\r
if ( nClient->GetDebugMode( DBG_LOCATION ) )\r
{\r
- u8 pH = 0;\r
- u8 pV = 0;\r
+ uint8_t pH = 0;\r
+ uint8_t pV = 0;\r
Worlds->GetWorldmapFromWorldId( destWorldId, pH, pV );\r
char DbgMessage[128];\r
snprintf( DbgMessage, 128, "Vhc zoning to zone %c%02d (id %d)", ( 'a' + pV ), pH, destWorldId );\r
Chat->send( nClient, CHAT_GM, "Debug", DbgMessage );\r
}\r
- \r
+\r
DoVhcZoning( tVhc, nClient->GetChar()->GetLocation(), destWorldId, &destPos );\r
}\r
}\r
}\r
\r
// Failures are not managed yet\r
-bool PUdpVhcMove::DoVhcZoning( PSpawnedVehicle* currVhc, u32 currWorldId, u32 destWorldId, PVhcCoordinates* destPos )\r
+bool PUdpVhcMove::DoVhcZoning( PSpawnedVehicle* currVhc, uint32_t currWorldId, uint32_t destWorldId, PVhcCoordinates* destPos )\r
{\r
- u32 seatedCharsId[8];\r
- u32 vhcGlobalId = currVhc->GetVehicleId();\r
- u32 vhcLocalId = currVhc->GetLocalId();\r
+ uint32_t seatedCharsId[8];\r
+ uint32_t vhcGlobalId = currVhc->GetVehicleId();\r
+ uint32_t vhcLocalId = currVhc->GetLocalId();\r
PVhcCoordinates currCoords = currVhc->GetPosition();\r
- u8 numSeats = currVhc->GetNumSeats();\r
- u32 sittingCharId;\r
+ uint8_t numSeats = currVhc->GetNumSeats();\r
+ uint32_t sittingCharId;\r
PClient* sittingClient;\r
PClient* sittingClients[8];\r
PMessage* tmpMsg;\r
\r
- for ( u8 i = 0; i < numSeats; ++i )\r
+ for ( uint8_t i = 0; i < numSeats; ++i )\r
{\r
// Save seated chars list\r
seatedCharsId[i] = sittingCharId = currVhc->GetSeatUser( i );\r
\r
// Update chars seat in use and restore vhc used seats\r
PChar* sittingChar;\r
- for ( u8 i = 0; i < numSeats; ++i )\r
+ for ( uint8_t i = 0; i < numSeats; ++i )\r
{\r
if (( sittingClient = sittingClients[i] ) )\r
{\r
}\r
else\r
{\r
- for ( u8 i = 0; i < numSeats; ++i )\r
+ for ( uint8_t i = 0; i < numSeats; ++i )\r
{\r
if ( sittingClients[i] )\r
{\r
\r
PMessage* nMsg = mDecodeData->mMessage;\r
nMsg->SetNextByteOffset( mDecodeData->Sub0x13Start + 12 );\r
- *nMsg >> mVehicleID; // u32\r
+ *nMsg >> mVehicleID; // uint32_t\r
*nMsg >> mVehicleSeat;\r
\r
if ( gDevDebug )\r
PWorld* CurrentWorld = Worlds->GetWorld( nChar->GetLocation() );\r
if ( CurrentWorld )\r
{\r
- PSpawnedVehicle* tVhc = CurrentWorld->GetSpawnedVehicules()->GetVehicle( mVehicleID );\r
+ PSpawnedVehicle* tVhc = CurrentWorld->GetSpawnedVehicles()->GetVehicle( mVehicleID );\r
if ( tVhc )\r
{\r
if ( tVhc->SetSeatUser( mVehicleSeat, nChar->GetID() ) ) // Char was able to sit\r
return true;\r
}\r
\r
-void PUdpVhcUse::DoFreeSitting( PClient* nClient, PSpawnedVehicle* nVhc, u32 nRawVhcLocalId, u8 nSeatId )\r
+void PUdpVhcUse::DoFreeSitting( PClient* nClient, PSpawnedVehicle* nVhc, uint32_t nRawVhcLocalId, uint8_t nSeatId )\r
{\r
PMessage* tmpMsg;\r
\r
if (( nVhc->GetNbFreeSeats() > 1 ) && ( nSeatId > nVhc->GetNumSeats() ) )\r
{\r
- u8 freeSeats = nVhc->GetFreeSeatsFlags();\r
+ uint8_t freeSeats = nVhc->GetFreeSeatsFlags();\r
tmpMsg = MsgBuilder->BuildCharUseVhcMsg( nClient, nRawVhcLocalId, nVhc->GetInformation().GetVehicleType(), freeSeats );\r
nClient->SendUDPMessage( tmpMsg ); // Open seat selection window\r
}\r
\r
PUdpMsgAnalyser* PUdpSubwayUpdate::Analyse()\r
{\r
- u8 Dumb;\r
+ uint8_t Dumb;\r
\r
mDecodeData->mName << "=Subway update";\r
\r
\r
if ( CurrentWorld )\r
{\r
- PSpawnedVehicle* tVhc = CurrentWorld->GetSpawnedVehicules()->GetVehicle( mVehicleID );\r
+ PSpawnedVehicle* tVhc = CurrentWorld->GetSpawnedVehicles()->GetVehicle( mVehicleID );\r
if ( tVhc )\r
{\r
if ( gDevDebug )\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include "GameServer/Decoder/UdpAnalyser.hxx"\r
+\r
+class PSpawnedVehicle;\r
+class PVhcCoordinates;\r
+\r
+class PUdpVhcMove : public PUdpMsgAnalyser {\r
+private:\r
+ uint16_t mVhcLocalId;\r
+ uint16_t mNewY;\r
+ uint16_t mNewZ;\r
+ uint16_t mNewX;\r
+ uint16_t mNewLR;\r
+ uint16_t mNewRoll;\r
+ uint16_t mUnk1; // always 0x0001 ?\r
+ uint8_t mMoveType;\r
+ uint8_t mNewUD;\r
+ uint8_t mFF; // always 0xff ?\r
+ uint8_t mAction; // &1 = Left, &2 = Right, &4 = Forward, &8 = Backward\r
+\r
+public:\r
+ PUdpVhcMove(PMsgDecodeData *nDecodeData);\r
+ //~PUdpVhcMove();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+ bool DoVhcZoning(PSpawnedVehicle *currVhc, uint32_t currWorldId, uint32_t destWorldId, PVhcCoordinates *destPos);\r
+};\r
+\r
+class PUdpVhcUse : public PUdpMsgAnalyser {\r
+private:\r
+ uint32_t mVehicleID;\r
+ uint8_t mVehicleSeat;\r
+\r
+public:\r
+ PUdpVhcUse(PMsgDecodeData *nDecodeData);\r
+ //~PUdpVhcUse();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+ static void DoFreeSitting(PClient *nClient, PSpawnedVehicle *nVhc, uint32_t nRawVhcLocalId, uint8_t nSeatId = 254);\r
+};\r
+\r
+class PUdpSubwayUpdate : public PUdpMsgAnalyser {\r
+private:\r
+ uint32_t mVehicleID;\r
+ uint16_t mPosition;\r
+ uint8_t mDoorOpened;\r
+\r
+public:\r
+ PUdpSubwayUpdate(PMsgDecodeData *nDecodeData);\r
+ //~PUdpSubwayUpdate();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
+\r
+class PUdpRequestVhcInfo : public PUdpMsgAnalyser {\r
+private:\r
+ uint32_t mVehicleID;\r
+\r
+public:\r
+ PUdpRequestVhcInfo(PMsgDecodeData *nDecodeData);\r
+ //~PUdpRequestVhcInfo();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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 ****/
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#include "GameServer/Decoder/UdpAnalyser.hxx"
+
+class PWorldIDInfoReq : public PUdpMsgAnalyser {
+ uint32_t mInfoId;
+
+public:
+ PWorldIDInfoReq(PMsgDecodeData *nDecodeData);
+ //~PWorldIDInfoReq();
+ PUdpMsgAnalyser *Analyse();
+ bool DoAction();
+};
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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 <cstring>
+#include "GameServer/Decoder/Includes.hxx"
+#include "GameServer/Definitions/Includes.hxx"
+#include "GameServer/Includes.hxx"
+#include "Common/Includes.hxx"
/**** PUdpZoning1 ****/
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;
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; }
}*/
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;
}
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 );
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;
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 );
bool PUdpAppartmentAccess::DoAction()
{
PMessage* tmpMsg;
- u32 AppLoc, Location, Entity;
+ uint32_t AppLoc, Location, Entity;
PClient* nClient = mDecodeData->mClient;
PChar* nChar = nClient->GetChar();
}
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 );
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include "GameServer/Decoder/UdpAnalyser.hxx"\r
+\r
+class PUdpZoning1 : public PUdpMsgAnalyser {\r
+private:\r
+ uint32_t mNewLocation;\r
+ uint16_t mNewEntity;\r
+ uint8_t mUnknown;\r
+\r
+public:\r
+ PUdpZoning1(PMsgDecodeData *nDecodeData);\r
+ //~PUdpZoning1();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
+\r
+class PUdpZoning2 : public PUdpMsgAnalyser {\r
+public:\r
+ PUdpZoning2(PMsgDecodeData *nDecodeData);\r
+ //~PUdpZoning2();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
+\r
+class PUdpGenrepZoning : public PUdpMsgAnalyser {\r
+private:\r
+ uint32_t mNewLocation;\r
+ uint16_t mNewEntity;\r
+\r
+public:\r
+ PUdpGenrepZoning(PMsgDecodeData *nDecodeData);\r
+ //~PUdpGenrepZoning();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+ static bool DoEffectiveZoning(PClient *nClient, uint32_t nNewLocation, uint16_t nNewEntity);\r
+};\r
+\r
+class PUdpAptGRZoning : public PUdpMsgAnalyser {\r
+public:\r
+ PUdpAptGRZoning(PMsgDecodeData *nDecodeData);\r
+ //~PUdpAptGRZoning();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+ static bool DoEffectiveZoning(PClient *nClient);\r
+};\r
+\r
+class PUdpAddGenrepToList : public PUdpMsgAnalyser {\r
+private:\r
+ uint32_t mLocation;\r
+ uint16_t mEntity;\r
+\r
+public:\r
+ PUdpAddGenrepToList(PMsgDecodeData *nDecodeData);\r
+ //~PUdpAddGenrepToList();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
+\r
+class PUdpAppartmentAccess : public PUdpMsgAnalyser {\r
+private:\r
+ uint16_t mAppartmentPlace;\r
+ char *mPassword;\r
+\r
+public:\r
+ PUdpAppartmentAccess(PMsgDecodeData *nDecodeData);\r
+ //~PUdpAppartmentAccess();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
+\r
+\r
+class PUdpEndOfZoning : public PUdpMsgAnalyser {\r
+public:\r
+ PUdpEndOfZoning(PMsgDecodeData *nDecodeData);\r
+ //~PUdpEndOfZoning();\r
+ PUdpMsgAnalyser *Analyse();\r
+ bool DoAction();\r
+};\r
--- /dev/null
+#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));
+}
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#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) ; }
+};
--- /dev/null
+#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));
+}
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#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; }
+};
--- /dev/null
+#include "GameServer/Definitions/Includes.hxx"\r
+\r
+PDefAppPlace::PDefAppPlace()\r
+{\r
+}\r
+\r
+bool PDefAppPlace::LoadFromDef(PTokenList *Tokens)\r
+{\r
+ int Idx=0;\r
+ for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++)\r
+ {\r
+ switch(Idx)\r
+ {\r
+ case 0: // setentry\r
+ continue;\r
+\r
+ case 1: // index\r
+ mIndex = atoi(i->c_str()); break;\r
+\r
+ case 2: // name\r
+ mName = *i; break;\r
+\r
+ case 3: // Exit World\r
+ mExitWorldID = atoi(i->c_str()); break;\r
+\r
+ case 4: // Exit World entity\r
+ mExitWorldEntity = atoi(i->c_str()); break;\r
+\r
+ case 5: // Sewer level\r
+ mSewerLevel = atoi(i->c_str()); break;\r
+ }\r
+ }\r
+\r
+ return true;\r
+}\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include <string>\r
+#include "GameServer/Definitions/Definition.hxx"\r
+\r
+class PDefAppPlace : public PDef {\r
+private :\r
+ //int32_t mIndex;\r
+ std::string mName;\r
+ int32_t mExitWorldID;\r
+ int32_t mExitWorldEntity;\r
+ int32_t mSewerLevel;\r
+\r
+public :\r
+ PDefAppPlace();\r
+ //~PDefAppPlace();\r
+\r
+ bool LoadFromDef(PTokenList *Tokens);\r
+\r
+ inline const std::string &GetName() const { return mName; }\r
+ inline int32_t GetExitWorldID() const { return mExitWorldID; }\r
+ inline int32_t GetExitWorldEntity() const { return mExitWorldEntity; }\r
+ inline int32_t GetSewerLevel() const { return mSewerLevel; }\r
+};\r
--- /dev/null
+#include "GameServer/Definitions/Includes.hxx"\r
+\r
+PDefAppartement::PDefAppartement()\r
+{\r
+}\r
+\r
+bool PDefAppartement::LoadFromDef(PTokenList *Tokens)\r
+{\r
+ mFaction = 0;\r
+ int Idx=0;\r
+ for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++)\r
+ {\r
+ switch(Idx)\r
+ {\r
+ case 0: // setentry\r
+ continue;\r
+\r
+ case 1: // index\r
+ mIndex = atoi(i->c_str()); break;\r
+\r
+ case 2: // name\r
+ mName = *i; break;\r
+\r
+ case 3: // world name\r
+ mWorldName = *i; break;\r
+\r
+ case 4: // value\r
+ mValue = atoi(i->c_str()); break;\r
+\r
+ case 5: // number of places\r
+ mPlaceCount = atoi(i->c_str()); break;\r
+\r
+ case 6:\r
+ case 7:\r
+ case 8:\r
+ case 9:\r
+ case 10:\r
+ case 11:\r
+ case 12:\r
+ case 13:\r
+ mPlace[Idx-6] = atoi(i->c_str()); break;\r
+\r
+ case 14: // faction if base appartement\r
+ mFaction = atoi(i->c_str()); break;\r
+ }\r
+ }\r
+//Console->Print("%04d:%s file:%s val:%d places:%d pl1:%d pl2:%d pl8:%d faction:%d",\r
+// mIndex, mName.c_str(), mWorldName.c_str(), mValue, mPlaceCount, mPlace[0], mPlace[1], mPlace[7], mFaction);\r
+ return true;\r
+}\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include <string>\r
+#include "GameServer/Definitions/Definition.hxx"\r
+#include "GameServer/Definitions/Map.hxx"\r
+\r
+class PDefAppartement : public PDef {\r
+private:\r
+ //int32_t mIndex;\r
+ std::string mName;\r
+ std::string mWorldName;\r
+ int32_t mValue;\r
+ int32_t mPlaceCount;\r
+ int32_t mPlace[8];\r
+ int32_t mFaction;\r
+\r
+public:\r
+ PDefAppartement();\r
+ //~PDefAppartement();\r
+\r
+ bool LoadFromDef(PTokenList *Tokens);\r
+\r
+ inline int32_t GetID() const { return mIndex; }\r
+ inline const std::string &GetName() const { return mName; }\r
+ inline const std::string &GetWorldName() const { return mWorldName; }\r
+ inline int32_t GetValue() const { return mValue; }\r
+ inline int32_t GetPlaceCount() const { return mPlaceCount; }\r
+ inline int32_t GetPlace(int32_t nIdx) const { return ( (nIdx < mPlaceCount) ? mPlace[nIdx] : 0 ); }\r
+ inline int32_t GetFaction() const { return mFaction; }\r
+};\r
+\r
+class PDefAppartementsMap : public PDefMap<PDefAppartement> {\r
+public:\r
+ inline std::map<int32_t, PDefAppartement*>::const_iterator ConstIteratorBegin() const { return mDefs.begin(); }\r
+ inline std::map<int32_t, PDefAppartement*>::const_iterator ConstIteratorEnd() const { return mDefs.end(); }\r
+};\r
--- /dev/null
+#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 ) );
+}
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#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) ; }
+};
--- /dev/null
+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)
--- /dev/null
+#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 ) );
+}
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#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) ; }
+};
--- /dev/null
+#include <cstring>\r
+#include "GameServer/Definitions/Includes.hxx"\r
+#include "GameServer/Includes.hxx"\r
+\r
+// charkinds are character templates used for player char creation\r
+\r
+PDefCharKind::PDefCharKind()\r
+{\r
+ mSkillInfo = 0;\r
+ memset(mInventory, 0, sizeof(mInventory));\r
+}\r
+\r
+PDefCharKind::~PDefCharKind()\r
+{\r
+ delete [] mSkillInfo;\r
+ for(PSkillPtsMap::const_iterator i=mSkillPts.begin(); i!=mSkillPts.end(); i++)\r
+ delete i->second;\r
+ for(PSubSkillPtsMap::const_iterator i=mSubSkillPts.begin(); i!=mSubSkillPts.end(); i++)\r
+ delete i->second;\r
+ for(PStartLevelMap::const_iterator i=mStartLevels.begin(); i!=mStartLevels.end(); i++)\r
+ delete i->second;\r
+}\r
+\r
+bool PDefCharKind::LoadFromDef(PTokenList *Tokens)\r
+{\r
+ int NumSkills = GameDefs->Skills()->GetNumDefs();\r
+ //int NumSubSkills = GameDefs->SubSkills()->GetNumDefs();\r
+\r
+ int SkillInfoStart = 4;\r
+ int TrainPtsStart = SkillInfoStart+NumSkills*3;\r
+ int LevelsStart = TrainPtsStart + 32*2;\r
+ int MoneyStart = LevelsStart + 16*2;\r
+ int InventoryStart = MoneyStart+1;\r
+\r
+ mSkillInfo = new PSkillInfo[NumSkills];\r
+\r
+ int Idx=0;\r
+ for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++)\r
+ {\r
+ switch(Idx)\r
+ {\r
+ case 0 : // setentry\r
+ continue;\r
+\r
+ case 1 :\r
+ mIndex = atoi(i->c_str()); break;\r
+\r
+ case 2 :\r
+ mName = *i; break;\r
+\r
+ case 3 :\r
+ mType = atoi(i->c_str()); break;\r
+\r
+ }\r
+\r
+ if((Idx >= SkillInfoStart) && (Idx < TrainPtsStart)) // skill info\r
+ {\r
+ int SkillIdx = (Idx-SkillInfoStart)/3;\r
+ int Value = atoi(i->c_str());\r
+\r
+ // start, max, grow per skill\r
+ switch((Idx-SkillInfoStart)%3)\r
+ {\r
+ case 0 : mSkillInfo[SkillIdx].mStart = Value; break;\r
+ case 1 : mSkillInfo[SkillIdx].mMax = Value; break;\r
+ case 2 : mSkillInfo[SkillIdx].mGrow = Value; break;\r
+ }\r
+ } else\r
+ // 32 skill/subskill train pts\r
+ if((Idx >= TrainPtsStart) && (Idx < LevelsStart))\r
+ {\r
+ static int SkillIndex = 0;\r
+ int Index = Idx-TrainPtsStart;\r
+ if((Index&1)==0)\r
+ {\r
+ SkillIndex = atoi(i->c_str());\r
+ } else\r
+ {\r
+ if(SkillIndex >= 1000) // skill\r
+ {\r
+ const PDefSkill *Skill = GameDefs->Skills()->GetDef(SkillIndex-1000);\r
+ if(Skill)\r
+ {\r
+ int Index = Skill->GetIndex()-1;\r
+ PSkillPtsInfo *CurrentSkillPts = new PSkillPtsInfo();\r
+ CurrentSkillPts->mSkill = Index;\r
+ CurrentSkillPts->mPoints = atoi(i->c_str());\r
+ mSkillPts.insert(std::make_pair(Index, CurrentSkillPts));\r
+ } else\r
+ {\r
+ if(SkillIndex-1000 != 0)\r
+ Console->Print("Charkind def: invalid skill index %i", SkillIndex-1000);\r
+ }\r
+ } else // subskill\r
+ {\r
+ const PDefSubSkill *SubSkill = GameDefs->SubSkills()->GetDef(SkillIndex);\r
+ if(SubSkill)\r
+ {\r
+ int Index = SubSkill->GetIndex()-1;\r
+ PSubSkillPtsInfo *CurrentSubSkillPts = new PSubSkillPtsInfo();\r
+ CurrentSubSkillPts->mSubSkill = Index;\r
+ CurrentSubSkillPts->mPoints = atoi(i->c_str());\r
+ mSubSkillPts.insert(std::make_pair(Index, CurrentSubSkillPts));\r
+ } else\r
+ {\r
+ if(SkillIndex != 0)\r
+ Console->Print("Charkind def: invalid subskill index %i", SkillIndex);\r
+ }\r
+ }\r
+ }\r
+ } else\r
+ // 16 subskill start levels\r
+ if((Idx >= LevelsStart) && (Idx < MoneyStart))\r
+ {\r
+ static int LevelIndex = 0;\r
+ int Index = Idx-NumSkills*3+4+(32*2);\r
+ if((Index&1)==0)\r
+ {\r
+ LevelIndex = atoi(i->c_str());\r
+ } else\r
+ {\r
+ if(LevelIndex > 0)\r
+ {\r
+ const PDefSubSkill *SubSkill = GameDefs->SubSkills()->GetDef(LevelIndex);\r
+ if(SubSkill)\r
+ {\r
+ PStartLevelInfo *Level = new PStartLevelInfo();\r
+ Level->mSubSkill = SubSkill->GetIndex();\r
+ Level->mLevel = atoi(i->c_str());\r
+ mStartLevels.insert(std::make_pair(Level->mSubSkill, Level));\r
+ } else\r
+ {\r
+ Console->Print("Charkind def: invalid subskill index %i", LevelIndex);\r
+ }\r
+ }\r
+ }\r
+ } else\r
+ // money\r
+ if((Idx >= MoneyStart) && (Idx < InventoryStart))\r
+ {\r
+ mMoney = atoi(i->c_str());\r
+ } else\r
+ // inventory\r
+ if((Idx >= InventoryStart) && (Idx < InventoryStart+8))\r
+ {\r
+ mInventory[Idx-InventoryStart] = atoi(i->c_str());\r
+ }\r
+ }\r
+ \r
+ return true;\r
+}\r
+\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include <map>\r
+#include <string>\r
+#include "GameServer/Definitions/Definition.hxx"\r
+\r
+struct PSkillInfo {\r
+ int32_t mStart;\r
+ int32_t mMax;\r
+ int32_t mGrow;\r
+\r
+ inline PSkillInfo()\r
+ {\r
+ mStart = mMax = mGrow = 0;\r
+ }\r
+};\r
+\r
+struct PSkillPtsInfo {\r
+ int32_t mSkill;\r
+ int32_t mPoints;\r
+\r
+ inline PSkillPtsInfo()\r
+ {\r
+ mSkill = mPoints = 0;\r
+ }\r
+};\r
+\r
+struct PSubSkillPtsInfo {\r
+ int32_t mSubSkill;\r
+ int32_t mPoints;\r
+\r
+ inline PSubSkillPtsInfo()\r
+ {\r
+ mSubSkill = mPoints = 0;\r
+ }\r
+};\r
+\r
+struct PStartLevelInfo {\r
+ int32_t mSubSkill;\r
+ int32_t mLevel;\r
+\r
+ inline PStartLevelInfo()\r
+ {\r
+ mSubSkill = mLevel = 0;\r
+ }\r
+\r
+};\r
+\r
+class PDefCharKind : public PDef {\r
+private:\r
+ typedef std::map<int32_t, PSkillPtsInfo*> PSkillPtsMap;\r
+ typedef std::map<int32_t, PSubSkillPtsInfo*> PSubSkillPtsMap;\r
+ typedef std::map<int32_t, PStartLevelInfo*> PStartLevelMap;\r
+\r
+ //int32_t mIndex;\r
+ std::string mName;\r
+ int32_t mType;\r
+\r
+ // TODO: shouldnt this be a map?\r
+ PSkillInfo *mSkillInfo;\r
+\r
+ PSkillPtsMap mSkillPts;\r
+ PSubSkillPtsMap mSubSkillPts;\r
+ PStartLevelMap mStartLevels;\r
+ int32_t mMoney;\r
+ uint32_t mInventory[8];\r
+\r
+public:\r
+ PDefCharKind();\r
+ ~PDefCharKind();\r
+\r
+ bool LoadFromDef(PTokenList *Tokens);\r
+\r
+ inline const std::string &GetName() const { return mName; }\r
+ inline int32_t GetType() const { return mType; }\r
+ inline const PSkillInfo &GetSkillInfo(int32_t Skill) const { return mSkillInfo[Skill-1]; }\r
+\r
+ inline int32_t GetStartMoney() const { return mMoney; }\r
+ inline uint32_t GetStartInventory(uint8_t Index) const { return ((Index < 7) ? mInventory[Index] : 0); }\r
+ // TODO: mission get() functions\r
+};\r
--- /dev/null
+#include "GameServer/Definitions/Includes.hxx"\r
+\r
+// characters.def contains all ingame characters (player types, npc's, monsters)\r
+\r
+PDefCharacter::PDefCharacter()\r
+{\r
+ mIndex = -1;\r
+ mName = "unknown";\r
+ mModel = -1;\r
+}\r
+\r
+bool PDefCharacter::LoadFromDef(PTokenList *Tokens)\r
+{\r
+ int Idx=0;\r
+ for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++)\r
+ {\r
+ switch(Idx)\r
+ {\r
+ case 0 : // setentry\r
+ continue;\r
+\r
+ case 1 :\r
+ mIndex = atoi(i->c_str()); break;\r
+\r
+ case 2 :\r
+ mName = *i; break;\r
+\r
+ case 3 :\r
+ mModel = atoi(i->c_str()); break;\r
+\r
+ case 4 : // 0\r
+ continue;\r
+\r
+ case 5 :\r
+ mHead = atoi(i->c_str()); break;\r
+\r
+ case 6 :\r
+ mTorso = atoi(i->c_str()); break;\r
+\r
+ case 7 :\r
+ mLegs = atoi(i->c_str()); break;\r
+\r
+ case 8 :\r
+ mColor = atoi(i->c_str()); break;\r
+\r
+ case 9 :\r
+ mBrightness = atoi(i->c_str()); break;\r
+ }\r
+\r
+ if(Idx==9)\r
+ return true;\r
+ }\r
+\r
+ return false;\r
+}\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include <string>\r
+#include "GameServer/Definitions/Definition.hxx"\r
+\r
+class PDefCharacter : public PDef {\r
+private:\r
+ //int32_t mIndex;\r
+ std::string mName;\r
+ int32_t mModel;\r
+ int32_t mHead;\r
+ int32_t mTorso;\r
+ int32_t mLegs;\r
+ int32_t mColor;\r
+ int32_t mBrightness;\r
+\r
+public:\r
+ PDefCharacter();\r
+ //~PDefCharacter();\r
+\r
+ bool LoadFromDef(PTokenList *Tokens);\r
+\r
+ inline const std::string &GetName() const { return mName; }\r
+ inline int32_t GetModel() const { return mModel; }\r
+ inline int32_t GetHead() const { return mHead; }\r
+ inline int32_t GetTorso() const { return mTorso; }\r
+ inline int32_t GetLegs() const { return mLegs; }\r
+ inline int32_t GetColor() const { return mColor; }\r
+ inline int32_t GetBrightness() const { return mBrightness; }\r
+};\r
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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()
{
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#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) ; }
+ */
+};
--- /dev/null
+#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 "";
+}
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#include <list>
+#include <string>
+
+typedef std::list<std::string> 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;
+};
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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()
{
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#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
--- /dev/null
+#include <cstring>\r
+#include "GameServer/Definitions/Includes.hxx"\r
+\r
+PDefFaction::PDefFaction()\r
+{\r
+ memset(mRelations, 0, sizeof(mRelations)); // ... array members supposed to by auto-initialized by C++\r
+}\r
+\r
+bool PDefFaction::LoadFromDef(PTokenList *Tokens)\r
+{\r
+ int Idx=0;\r
+ for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++)\r
+ {\r
+ // setfracc 19 "Monster" -1024 0 0 -1024 -1024 -1024 -1\r
+ switch(Idx)\r
+ {\r
+ case 0 : // setfrac\r
+ continue;\r
+\r
+ case 1 :\r
+ mIndex = atol(i->c_str()); break;\r
+\r
+ case 2 :\r
+ mName = *i;\r
+ CleanUpString(&mName);\r
+ break;\r
+\r
+ case 3 :\r
+ mStartValue = atol(i->c_str()); break;\r
+\r
+ case 4:\r
+ mAffected = atol(i->c_str())!=0; break;\r
+\r
+ case 5:\r
+ mSL = atol(i->c_str()); break;\r
+\r
+ default :\r
+ {\r
+ if(Idx-6 < NUMFACTIONS)\r
+ mRelations[Idx-6] = atol(i->c_str()); break;\r
+ }\r
+ }\r
+ }\r
+\r
+ return true;\r
+}\r
+\r
+int PDefFaction::GetRelation(int Faction) const\r
+{\r
+ // faction 0 has no relations\r
+ if(Faction <= 0 || Faction > NUMFACTIONS)\r
+ return 0;\r
+\r
+ return mRelations[Faction-1];\r
+}\r
+\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include <string>\r
+#include "GameServer/Definitions/Definition.hxx"\r
+\r
+static const int32_t NUMFACTIONS = 20; // for faction relations only\r
+\r
+class PDefFaction : public PDef {\r
+private :\r
+ //int32_t mIndex;\r
+ std::string mName;\r
+ int32_t mStartValue;\r
+ bool mAffected;\r
+ int32_t mSL;\r
+ int32_t mRelations[NUMFACTIONS];\r
+public :\r
+ PDefFaction();\r
+ //~PDefFaction();\r
+\r
+ bool LoadFromDef(PTokenList *Tokens);\r
+\r
+ inline const std::string &GetName() const { return mName; }\r
+ inline int32_t GetStartValue() const { return mStartValue; }\r
+ inline bool GetAffected() const { return mAffected; }\r
+ inline int32_t GetSL() const { return mSL; };\r
+ int32_t GetRelation(int32_t Faction) const;\r
+};\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
+#include "GameServer/Definitions/Includes.hxx"\r
\r
/*\r
-\r
- gamedefs - this part loads "all" the definitions found in defs/\r
-\r
- MODIFIED: 30 August 2005 Akiko\r
- REASON: - added this fency header\r
- - changed the path of every def file to fellow the TinNS way (loading by the config.xml)\r
- - reformated code for easier reading\r
- MODIFIED: 31 August 2005 Akiko\r
- REASON: - updated paths for the def files\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL\r
- MODIFIED: 06 Jan 2006\r
- REASON: - Added GetCharKindDef(), was missing somehow\r
- MODIFIED: 21 Sep 2005 Hammag\r
- REASON: - Added PDefWorldModel related stuff\r
- - Added PDefAppPlace related stuff\r
- - completed PGameDefs destructor\r
- MODIFIED: 22 Sep 2005 Hammag\r
- REASON: - Added PDefAppartement related stuff\r
- - Added PDefRespawn related stuff\r
- MODIFIED: 28 Sep 2005 Hammag\r
- REASON: - Added PDefWorldFile related stuff\r
-\r
- MODIFIED: 07 Oct 2005 Hammag\r
- REASON: - Added (inline) methods to get const iterators on Appartment and WorldFile maps\r
-\r
--------------------------------------------------------------------\r
WARNING:\r
When adding new .def support, don't forget to add required stuff in PGameDefs::Init()\r
appending pak_ to its name,\r
- else tries to load the packed file from the .pak archive which name is\r
derived from the last part of the path.\r
-\r
*/\r
\r
-#include "main.h"\r
-\r
PGameDefs::PGameDefs() {}\r
PGameDefs::~PGameDefs() {}\r
\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- gamedefs.h\r
-\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL\r
- MODIFIED: 21 Sep 2005 Hammag\r
- REASON: - Added PDefWorldModel related stuff\r
- - Added PDefAppPlace related stuff\r
- MODIFIED: 22 Sep 2005 Hammag\r
- REASON: - Added PDefAppartement related stuff\r
- - Added PDefRespawn related stuff\r
- MODIFIED: 28 Sep 2005 Hammag\r
- REASON: - Added PDefWorldFile related stuff\r
-\r
- MODIFIED: 07 Oct 2005 Hammag\r
- REASON: - Added methods to get const iterators on Appartment and WorldFile maps\r
-\r
-*/\r
-\r
-#ifndef GAMEDEFS_H\r
-#define GAMEDEFS_H\r
-\r
-#include "defs.h"\r
+#pragma once\r
+\r
+#include <cstdint>\r
+#include "GameServer/Definitions/Definition.hxx"\r
+#include "GameServer/Definitions/Implants.hxx"\r
+#include "GameServer/Definitions/ItemContainer.hxx"\r
+#include "GameServer/Definitions/ItemMod.hxx"\r
+#include "GameServer/Definitions/ItemRes.hxx"\r
+#include "GameServer/Definitions/Items.hxx"\r
+#include "GameServer/Definitions/Mission.hxx"\r
+#include "GameServer/Definitions/NpcArmor.hxx"\r
+#include "GameServer/Definitions/NpcGroupSpawn.hxx"\r
+#include "GameServer/Definitions/Npc.hxx"\r
+#include "GameServer/Definitions/Outposts.hxx"\r
+#include "GameServer/Definitions/Recycles.hxx"\r
+#include "GameServer/Definitions/Respawn.hxx"\r
+#include "GameServer/Definitions/Scripts.hxx"\r
+#include "GameServer/Definitions/Shots.hxx"\r
+#include "GameServer/Definitions/Skills.hxx"\r
+#include "GameServer/Definitions/SubSkills.hxx"\r
+#include "GameServer/Definitions/Trader.hxx"\r
+#include "GameServer/Definitions/Vehicles.hxx"\r
+#include "GameServer/Definitions/VehicleSits.hxx"\r
+#include "GameServer/Definitions/Weapons.hxx"\r
+#include "GameServer/Definitions/Weather.hxx"\r
+#include "GameServer/Definitions/WorldFile.hxx"\r
+#include "GameServer/Definitions/WorldModels.hxx"\r
+#include "GameServer/Definitions/Worlds.hxx"\r
\r
typedef PDefMap<PDefActionMod> PDefActionModsMap;\r
typedef PDefMap<PDefAmmo> PDefAmmosMap;\r
// ___Add new entries here in alpĥabetical order___\r
\r
\r
-class PGameDefs\r
-{\r
- private :\r
+class PGameDefs {\r
+private:\r
PDefActionModsMap mActionModsDefs;\r
PDefAmmosMap mAmmosDefs;\r
PDefAppartementsMap mAppartementsDefs;\r
PDefScriptsMap mScriptDefs;\r
// ___Add new entries here___\r
\r
- public :\r
+public:\r
PGameDefs();\r
~PGameDefs();\r
\r
inline const PDefWorldModelsMap* WorldModels() const { return &mWorldModelsDefs; }\r
inline const PDefScriptsMap* Scripts() const { return &mScriptDefs; }\r
// ___Add new entries here___\r
-\r
};\r
-\r
-#endif\r
--- /dev/null
+#include "GameServer/Definitions/Includes.hxx"\r
+\r
+PDefHack::PDefHack()\r
+{\r
+}\r
+\r
+bool PDefHack::LoadFromDef(PTokenList *Tokens)\r
+{\r
+ int Idx=0;\r
+ for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++)\r
+ {\r
+ switch(Idx)\r
+ {\r
+ case 0: // setentry\r
+ continue ;\r
+\r
+\r
+ case 1: // index\r
+ mIndex = atoi(i->c_str()); break;\r
+\r
+\r
+ }\r
+ }\r
+\r
+ return true;\r
+}\r
+\r
--- /dev/null
+#pragma once\r
+\r
+#include "GameServer/Definitions/Definition.hxx"\r
+\r
+class PDefHack : public PDef {\r
+private:\r
+ //int mIndex;\r
+ //qui aggiungere valori\r
+public:\r
+ PDefHack();\r
+ //~PDefHack();\r
+\r
+ bool LoadFromDef(PTokenList *Tokens);\r
+\r
+ //qui aggiungere funzioni per i gets\r
+};\r
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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 )
{
--- /dev/null
+#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 );
+};
--- /dev/null
+#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"
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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()
{
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#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
+};
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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()
{
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#include <string>
+#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) ; }
+};
--- /dev/null
+#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));
+}
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#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) ; }
+};
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
+#include "GameServer/Definitions/Includes.hxx"\r
\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- def_item.cpp\r
-\r
- Authors:\r
- - Akiko\r
- - Namikon\r
- - someone else?\r
-\r
- MODIFIED: Unknown date / Unknown author\r
- REASON: - initial release by unknown\r
-\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL\r
-\r
- MODIFIED: 10 Jul Hammag\r
- REASON: - Full Item Def implementation\r
-*/\r
-\r
-#include "main.h"\r
#define GAMEDEFS_DEFITEMSMAXSEQ 100\r
\r
-\r
PDefItems::PDefItems()\r
{\r
//mIndex = 0;\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include <map>\r
+#include "GameServer/Definitions/Definition.hxx"\r
+\r
+class PDefItems : public PDef {\r
+private:\r
+ //int32_t mIndex;//1\r
+ std::string mName;//2\r
+ int32_t mModel; // used for IG display\r
+ int32_t mType;\r
+ int32_t mValue1;\r
+ int32_t mValue2;\r
+ int32_t mValue3;\r
+ // int32_t mBmNum; // used IG for inventory display\r
+ // int32_t mmBmNumIndex; // used IG for inventory display\r
+ int32_t mSizeX;\r
+ int32_t mSizeY;\r
+ // int32_t mSmallbmnum; // used IG for inventory display\r
+ float mWeight;\r
+ int32_t mStackable;\r
+ float mFillWeight;\r
+ int32_t mQualifier;\r
+ int32_t mGfxMods;\r
+ int32_t mItemGroupID;\r
+ int32_t mTextDescID;\r
+ int32_t mBasePrice;\r
+ int32_t mTechlevel;\r
+ int32_t mItemflags;\r
+ // std::mShortname; // used IG for display on inventories Icons\r
+\r
+public:\r
+ PDefItems();\r
+ //~PDefItems();\r
+\r
+ bool LoadFromDef(PTokenList *Tokens);\r
+\r
+ inline const std::string &GetName() const { return mName; }\r
+ inline int32_t GetModel() const { return mModel; }\r
+ inline int32_t GetType() const { return mType; }\r
+ inline int32_t GetValue1() const { return mValue1; }\r
+ inline int32_t GetValue2() const { return mValue2; }\r
+ inline int32_t GetValue3() const { return mValue3; }\r
+ inline int32_t GetSizeX() const { return mSizeX; }\r
+ inline int32_t GetSizeY() const { return mSizeY; }\r
+ inline float GetWeight() const { return mWeight; }\r
+ inline bool IsStackable() const { return (mStackable == 1); }\r
+ inline float GetFillWeight() const { return mFillWeight; }\r
+ inline int32_t GetQualifier() const { return mQualifier; }\r
+ inline int32_t GetGfxMods() const { return mGfxMods; }\r
+ inline int32_t GetItemGroupID() const { return mItemGroupID; }\r
+ inline int32_t GetTextDescID() const { return mTextDescID; }\r
+ inline int32_t GetBasePrice() const { return mBasePrice; }\r
+ inline int32_t GetTechlevel() const { return mTechlevel; }\r
+ inline int32_t GetItemflags() const { return mItemflags; }\r
+};\r
+\r
+class PDefItemsMap : public PDefMap<PDefItems> {\r
+private:\r
+ std::map<int32_t, PDefItems*>::const_iterator* mMapItCache;\r
+ int32_t mMapItCacheCount;\r
+ std::map<int32_t, std::vector<int32_t> > mItemGroups;\r
+ int32_t mMaxItemGroupId;\r
+ void BuildMapItCache();\r
+ void BuildItemGroups();\r
+\r
+public:\r
+ PDefItemsMap();\r
+ ~PDefItemsMap();\r
+ bool Load(const char* nName, const char* nFilename);\r
+ const PDefItems* GetDefBySeqIndex( int32_t nSeqIndex ) const;\r
+ int32_t GetRandomItemIdFromGroup( int32_t nGroupId ) const;\r
+\r
+ inline std::map<int32_t, PDefItems*>::const_iterator ConstIteratorBegin() const { return mDefs.begin(); }\r
+ inline std::map<int32_t, PDefItems*>::const_iterator ConstIteratorEnd() const { return mDefs.end(); }\r
+};\r
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#include <map>
+#include <string>
+#include "GameServer/Definitions/Parser.hxx"
+#include "Common/Includes.hxx"
+
+template <class T>
+class PDefMap {
+protected:
+ std::string mName;
+ std::map<int32_t, T *> 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 );
+ }
+};
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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()
{
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;
+}
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#include <string>
+#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
+*/
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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()
{
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 :
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 :
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#include <string>
+#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; }
+};
--- /dev/null
+#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 );
+}
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#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 ) ; }
+};
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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()
{
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
{
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#include <string>
+#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;
+};
--- /dev/null
+#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 );
+}
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#include <string>
+#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) ; }
+};
--- /dev/null
+#include "GameServer/Definitions/Includes.hxx"\r
+#include "GameServer/Includes.hxx"\r
+\r
+PDefParser::PDefParser()\r
+{\r
+}\r
+\r
+PDefParser::~PDefParser()\r
+{\r
+ for(PDefTokenList::iterator i=mTokens.begin(); i!=mTokens.end(); i++)\r
+ delete *i;\r
+}\r
+\r
+bool PDefParser::Parse(const char *File)\r
+{\r
+ PFile *f = Filesystem->Open("", File, Config->GetOption("nc_data_path"));\r
+ enum { NOPE, MAYBE, LINE, BLOCK, MAYBE_END } Comment = NOPE;\r
+\r
+ if(f)\r
+ {\r
+ while(!f->Eof())\r
+ {\r
+ std::string Str = f->ReadString();\r
+ int Len = Str.length();\r
+ if(Len <= 0)\r
+ continue;\r
+\r
+ if(Str.substr(0, 3)!="set")\r
+ continue;\r
+\r
+ //Console->Print("%s", Str.c_str());//NEW was commented , just to be sure of what we are reading\r
+\r
+ PTokenList *List = new PTokenList();\r
+ int Start=0, Tokens=0;\r
+ bool Quote=false;\r
+ for(int i=0; i<Len; i++)\r
+ {\r
+ if(Str[i]=='\r' || Str[i]=='\n' || Str[i]=='|' || Str[i]==';')\r
+ {\r
+ if(Comment < LINE)\r
+ {\r
+ int End=i-1;\r
+ if(End >= Start)\r
+ {\r
+ List->push_back(std::string(Str.substr(Start, (End-Start)+1)));\r
+ Tokens++;\r
+ break;\r
+ }\r
+ Quote=false;\r
+ }\r
+ if(Comment != BLOCK)\r
+ Comment=NOPE;\r
+ break;\r
+ }\r
+\r
+ if(!Quote)\r
+ {\r
+ if(Comment < LINE && (Str[i]=='\t' || Str[i]==',' || Str[i]==' ' || Str[i]==';' || Str[i]=='|' || i==Len-1))\r
+ {\r
+ int End=i-1;\r
+ if(End >= Start)\r
+ {\r
+ List->push_back(std::string(Str.substr(Start, (End-Start)+1)));\r
+ Tokens++;\r
+ }\r
+ Start=i+1;\r
+ }\r
+\r
+ if(Str[i] <= ' ')\r
+ continue;\r
+\r
+ if(Str[i]=='*')\r
+ {\r
+ if(Comment==MAYBE)\r
+ Comment=BLOCK;\r
+ else\r
+ if(Comment==BLOCK)\r
+ Comment=MAYBE_END;\r
+ } else\r
+ if(Str[i]=='/')\r
+ {\r
+ if(Comment==MAYBE)\r
+ {\r
+ // second slash, skip rest of line\r
+ Comment=LINE;\r
+ break;\r
+ } else\r
+ if(Comment==MAYBE_END)\r
+ {\r
+ Comment=NOPE; // comment block ends\r
+ Start=i+1;\r
+ } else\r
+ if(Comment != BLOCK)\r
+ Comment=MAYBE; // first slash\r
+ } else\r
+ {\r
+ if(Comment==MAYBE)\r
+ Comment=NOPE; // stand-alone slash\r
+ else\r
+ if(Comment==MAYBE_END)\r
+ Comment=BLOCK; // comment block did not end\r
+ }\r
+ }\r
+\r
+ if(Str[i]=='"')\r
+ Quote ^= true;\r
+ }\r
+\r
+ if(Tokens > 0)\r
+ mTokens.push_back(List);\r
+ else\r
+ delete List;\r
+ }\r
+ } else\r
+ {\r
+ Console->Print("%s PDefParser::Parse: could not open file %s", Console->ColorText( RED, BLACK, "[ERROR]" ), File);\r
+ return false;\r
+ }\r
+\r
+ return true;\r
+}\r
--- /dev/null
+#pragma once\r
+\r
+#include <list>\r
+#include <string>\r
+\r
+typedef std::list<std::string> PTokenList;\r
+typedef std::list<PTokenList *> PDefTokenList;\r
+\r
+class PDefParser {\r
+private:\r
+ PDefTokenList mTokens;\r
+\r
+public:\r
+ PDefParser();\r
+ ~PDefParser();\r
+ bool Parse(const char *File);\r
+ inline const PDefTokenList &GetTokens() const { return mTokens; }\r
+};\r
--- /dev/null
+#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 ) );
+}
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#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 ) ; }
+};
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- def_respawn.cpp\r
-\r
- MODIFIED: 22 Sep 2006 Hammag\r
- REASON: - Creation\r
-\r
-*/\r
-\r
-#include "main.h"\r
+#include "GameServer/Definitions/Includes.hxx"\r
\r
PDefRespawn::PDefRespawn()\r
{\r
}\r
\r
// class PDefRespawnMap defined in gamedefs.h\r
-int PDefRespawnsMap::GetRespawnEntity( u32 nWorldID, u16 nGROrder ) const\r
+int PDefRespawnsMap::GetRespawnEntity( uint32_t nWorldID, uint16_t nGROrder ) const\r
{\r
- u16 tOrder = 0;\r
+ uint16_t tOrder = 0;\r
\r
for ( std::map<int, PDefRespawn*>::const_iterator it = mDefs.begin(); it != mDefs.end(); it++ )\r
{\r
- if (( u32 )( it->second->GetWorldID() ) == nWorldID )\r
+ if (( uint32_t )( it->second->GetWorldID() ) == nWorldID )\r
{\r
++tOrder;\r
if (( nWorldID == 1 ) || ( nWorldID == 2 ) ) // hack for zones 1 & 2\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include <string>\r
+#include "GameServer/Definitions/Definition.hxx"\r
+\r
+class PDefRespawn : public PDef {\r
+private:\r
+ //int32_t mIndex;\r
+ int32_t mWorldID;\r
+ int32_t mEntityID; // Station ID\r
+ int32_t mHazardLevel;\r
+ std::string mName; // Description\r
+ std::string mFlag; // ???\r
+\r
+public:\r
+ PDefRespawn();\r
+ //~PDefRespawn();\r
+\r
+ bool LoadFromDef(PTokenList *Tokens);\r
+\r
+ inline int32_t GetWorldID() const { return mWorldID; }\r
+ inline int32_t GetEntityID() const { return mEntityID; }\r
+ inline int32_t GetHazardLevel() const { return mHazardLevel; }\r
+ inline const std::string &GetName() const { return mName; }\r
+ inline const std::string &GetFlag() const { return mFlag; }\r
+};\r
+\r
+class PDefRespawnsMap : public PDefMap<PDefRespawn> {\r
+public:\r
+ int32_t GetRespawnEntity( uint32_t nWorldID, uint16_t nGROrder ) const;\r
+};\r
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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()
{
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#include <map>
+#include <string>
+#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<PDefScripts> {
+public:
+ //bool Load(const char* nName, const char* nFilename);
+ inline std::map<int32_t, PDefScripts*>::const_iterator ConstIteratorBegin() const { return mDefs.begin(); }
+ inline std::map<int32_t, PDefScripts*>::const_iterator ConstIteratorEnd() const { return mDefs.end(); }
+};
--- /dev/null
+#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 ) );
+}
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#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; }
+};
--- /dev/null
+#include <cstring>\r
+#include "GameServer/Definitions/Includes.hxx"\r
+#include "GameServer/Includes.hxx"\r
+\r
+// skill.def includes skill names and skill/subskill mapping\r
+\r
+PDefSkill::PDefSkill()\r
+{\r
+ mSubSkills = 0;\r
+ mNumSubSkills = 0;\r
+}\r
+\r
+PDefSkill::~PDefSkill()\r
+{\r
+ delete [] mSubSkills;\r
+}\r
+\r
+bool PDefSkill::LoadFromDef(PTokenList *Tokens)\r
+{\r
+ int Idx=0;\r
+ for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++)\r
+ {\r
+ switch(Idx)\r
+ {\r
+ case 0 : // setentry\r
+ continue;\r
+\r
+ case 1 :\r
+ mIndex = atol(i->c_str()); break;\r
+\r
+ case 2 :\r
+ mName = *i; break;\r
+\r
+ case 3 :\r
+ mShortName = *i; break;\r
+\r
+ case 4 :\r
+ {\r
+ mNumSubSkills = atol(i->c_str());\r
+ mSubSkills = new int[mNumSubSkills];\r
+ std::memset(mSubSkills, 0, sizeof(int)*mNumSubSkills);\r
+ break;\r
+ }\r
+ }\r
+\r
+ if(Idx >= 5)\r
+ {\r
+ mSubSkills[Idx-5] = atoi(i->c_str());\r
+ if(!GameDefs->SubSkills()->GetDef(mSubSkills[Idx-5]))\r
+ {\r
+ Console->Print("Skill def error: skill %s refers to nonexistant subskill %i", mShortName.c_str(), mSubSkills[Idx-5]);\r
+ return false;\r
+ }\r
+ }\r
+ }\r
+\r
+ if(Idx-5 != mNumSubSkills)\r
+ {\r
+ Console->Print("Warning: skill %s has incorrect number of subskills", mShortName.c_str());\r
+ Console->Print(" Expected %i, available %i", mNumSubSkills, Idx-5);\r
+ }\r
+ return true;\r
+}\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include <string>\r
+#include "GameServer/Definitions/Definition.hxx"\r
+\r
+class PDefSkill : public PDef {\r
+private:\r
+ //int32_t mIndex;\r
+ std::string mName;\r
+ std::string mShortName;\r
+ int32_t mNumSubSkills;\r
+ int32_t *mSubSkills;\r
+public:\r
+ PDefSkill();\r
+ ~PDefSkill();\r
+\r
+ bool LoadFromDef(PTokenList *Tokens);\r
+\r
+ inline const std::string &GetName() const { return mName; }\r
+ inline const std::string &GetShortName() const { return mShortName; }\r
+ inline int32_t GetNumSubSkills() const { return mNumSubSkills; }\r
+ inline int32_t GetSubSkill(int32_t Index) const { return mSubSkills[Index]; }\r
+};\r
--- /dev/null
+#include <cstring>\r
+#include "GameServer/Definitions/Includes.hxx"\r
+\r
+// subskill.def, names and parameters of all subskills\r
+\r
+PDefSubSkill::PDefSubSkill()\r
+{\r
+ mActionModifiers = 0;\r
+ mNumActionModifiers = 0;\r
+}\r
+\r
+PDefSubSkill::~PDefSubSkill()\r
+{\r
+ delete [] mActionModifiers;\r
+}\r
+\r
+bool PDefSubSkill::LoadFromDef(PTokenList *Tokens)\r
+{\r
+ int Idx=0;\r
+ for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++)\r
+ {\r
+ switch(Idx)\r
+ {\r
+ case 0 : // setentry\r
+ continue;\r
+\r
+ case 1 :\r
+ mIndex = atoi(i->c_str()); break;\r
+\r
+ case 2 :\r
+ mName = *i; break;\r
+\r
+ case 3 :\r
+ mShortName = *i; break;\r
+\r
+ case 4 :\r
+ mStrengthenFactor = static_cast<float>(atof(i->c_str())); break;\r
+\r
+ case 5 :\r
+ {\r
+ mNumActionModifiers = atoi(i->c_str());\r
+ mActionModifiers = new int[mNumActionModifiers];\r
+ std::memset(mActionModifiers, 0, sizeof(int)*mNumActionModifiers);\r
+ break;\r
+ }\r
+ }\r
+\r
+ if(Idx>=6)\r
+ mActionModifiers[Idx-6] = atoi(i->c_str());\r
+ }\r
+\r
+ return true;\r
+}\r
+\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include <string>\r
+#include "GameServer/Definitions/Definition.hxx"\r
+\r
+class PDefSubSkill : public PDef {\r
+private:\r
+ //int32_t mIndex;\r
+ std::string mName;\r
+ std::string mShortName;\r
+ float mStrengthenFactor;\r
+ int32_t mNumActionModifiers;\r
+ int32_t *mActionModifiers;\r
+\r
+public:\r
+ PDefSubSkill();\r
+ ~PDefSubSkill();\r
+\r
+ bool LoadFromDef(PTokenList *Tokens);\r
+\r
+ inline const std::string &GetName() const { return mName; }\r
+ inline const std::string &GetShortName() const { return mShortName; }\r
+ inline float GetStrengthenFactor() const { return mStrengthenFactor; }\r
+ inline int32_t GetNumActionModifiers() const { return mNumActionModifiers; }\r
+ inline int32_t GetActionModifier(int32_t Index) const { return mActionModifiers[Index]; }\r
+};\r
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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()
{
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#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
+//
+*/
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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()
{
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#include <string>
+#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
+*/
--- /dev/null
+#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));
+}
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#include <string>
+#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; }
+};
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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()
{
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#include <string>
+#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; }
+};
--- /dev/null
+#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)));
+}
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#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)
+*/
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
+#include <cmath>\r
+#include <cstring>\r
+#include "GameServer/Definitions/Includes.hxx"\r
+#include "GameServer/Includes.hxx"\r
\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- world_datparser.h\r
- Class to parse .dat world files\r
-\r
- MODIFIED: 29 Sep 2006 Hammag\r
- REASON: - Creation\r
-\r
-MODIFIED: 21 Jun 2009 Namikon\r
-REASON: - Added NPC Template stuff\r
- - reformatted for better reading\r
-\r
-*/\r
-\r
-#include "main.h"\r
-\r
-#include "include/world_datparser.h"\r
-#include "def/world_datstruct.h"\r
-\r
-#include "include/worlddatatemplate.h"\r
-#include "include/furnituretemplate.h"\r
-#include "include/doortemplate.h"\r
-#include "include/npctemplate.h"\r
-\r
-#include <math.h>\r
-\r
-const u16 nonDiscardUseFlags = ufTouchable | ufUsable | ufChair | ufToolTarget ; // furniture always to keep even if function type = 0\r
+const uint16_t nonDiscardUseFlags = ufTouchable | ufUsable | ufChair | ufToolTarget ; // furniture always to keep even if function type = 0\r
\r
PWorldDatParser::PWorldDatParser()\r
{\r
PSectionHeader SectionHeader;\r
PSec2ElemHeader Sec2ElemHeader;\r
\r
- u32 FileLen;\r
- u32 NextSectionOffset = 0;\r
- u32 NextElementOffset;\r
+ uint32_t FileLen;\r
+ uint32_t NextSectionOffset = 0;\r
+ uint32_t NextElementOffset;\r
bool ProcessOK;\r
\r
mWorld = nWorld;\r
f->Seek( NextSectionOffset ); // Make sure we are at the computed offset\r
if (gDevDebug)\r
Console->Print( "Reading next section header ... " );\r
- if (( u32 )( f->Read( &SectionHeader, sizeof( PSectionHeader ) ) ) < sizeof( PSectionHeader ) )\r
+ if (( uint32_t )( f->Read( &SectionHeader, sizeof( PSectionHeader ) ) ) < sizeof( PSectionHeader ) )\r
{\r
Filesystem->Close( f );\r
return -3;\r
\r
//if ( gDevDebug )\r
// Console->Print( "Reading next element header ... " );\r
- if (( u32 )( f->Read( &Sec2ElemHeader, sizeof( PSec2ElemHeader ) ) ) < sizeof( PSec2ElemHeader ) )\r
+ if (( uint32_t )( f->Read( &Sec2ElemHeader, sizeof( PSec2ElemHeader ) ) ) < sizeof( PSec2ElemHeader ) )\r
{\r
Filesystem->Close( f );\r
return -3;\r
return 0;\r
}\r
\r
-bool PWorldDatParser::ProcessSec2ElemType3( u32 nSize ) // furniture\r
+bool PWorldDatParser::ProcessSec2ElemType3( uint32_t nSize ) // furniture\r
{\r
PSec2ElemType3a DataA;\r
PSec2ElemType3b DataB;\r
const PDefWorldModel* nWorldModel;\r
std::string nName;\r
- const u32 sza = sizeof( PSec2ElemType3a );\r
- const u32 szb = sizeof( PSec2ElemType3a ) + sizeof( PSec2ElemType3b );\r
+ const uint32_t sza = sizeof( PSec2ElemType3a );\r
+ const uint32_t szb = sizeof( PSec2ElemType3a ) + sizeof( PSec2ElemType3b );\r
\r
if (( nSize != szb ) && ( nSize != sza ) )\r
{\r
Console->Print( RED, BLACK, "[ERROR] Wrong size for Sec2ElemType3 (%d read vs %d or %d needed", nSize, sza, szb );\r
return false;\r
}\r
- if (( u32 )( f->Read( &DataA, sza ) ) < sza )\r
+ if (( uint32_t )( f->Read( &DataA, sza ) ) < sza )\r
{\r
Console->Print( RED, BLACK, "[ERROR] Unexpected end of file in Sec2ElemType3a" );\r
return false;\r
}\r
if ( nSize == szb )\r
{\r
- if (( u32 )( f->Read( &DataB, sizeof( PSec2ElemType3b ) ) ) < sizeof( PSec2ElemType3b ) )\r
+ if (( uint32_t )( f->Read( &DataB, sizeof( PSec2ElemType3b ) ) ) < sizeof( PSec2ElemType3b ) )\r
{\r
Console->Print( RED, BLACK, "[ERROR] Unexpected end of file in Sec2ElemType3b" );\r
return false;\r
// nItem->mBoxUpperX = DataB.mBoxUpperX;\r
\r
nItem->mDefWorldModel = nWorldModel;\r
- /*u16 func=nWorldModel->GetFunctionType();\r
+ /*uint16_t func=nWorldModel->GetFunctionType();\r
if((func==18) || (func==20) || (func==29))\r
Console->Print("gate model: %d", DataA.mWorldmodelID);*/\r
\r
Radius += 5;\r
\r
// int pos values are change to match char pos scale (32000 centered)\r
- nItem->mFrontPosY = ( u16 )( 32000 + DataA.mPosY + Radius * sinf( Angle ) );\r
- nItem->mFrontPosZ = ( u16 )( 32000 + DataA.mPosZ );\r
- nItem->mFrontPosX = ( u16 )( 32000 + DataA.mPosX + Radius * cosf( Angle ) );\r
- nItem->mFrontLR = ( u8 )( 0.5 * ( DataA.mRotZ + ( DataA.mRotZ < 0 ? 360 : 0 ) ) );\r
+ nItem->mFrontPosY = ( uint16_t )( 32000 + DataA.mPosY + Radius * sinf( Angle ) );\r
+ nItem->mFrontPosZ = ( uint16_t )( 32000 + DataA.mPosZ );\r
+ nItem->mFrontPosX = ( uint16_t )( 32000 + DataA.mPosX + Radius * cosf( Angle ) );\r
+ nItem->mFrontLR = ( uint8_t )( 0.5 * ( DataA.mRotZ + ( DataA.mRotZ < 0 ? 360 : 0 ) ) );\r
\r
mWorld->AddFurnitureItem( nItem );\r
\r
return true;\r
}\r
\r
-bool PWorldDatParser::ProcessSec2ElemType5( u32 nSize ) // doors\r
+bool PWorldDatParser::ProcessSec2ElemType5( uint32_t nSize ) // doors\r
{\r
PSec2ElemType5Start Data;\r
char StringData[64];\r
char* ActorString;\r
char* ParamString;\r
\r
- const u32 sza = sizeof( PSec2ElemType5Start );\r
+ const uint32_t sza = sizeof( PSec2ElemType5Start );\r
\r
if (( nSize < sza ) )\r
{\r
Console->Print( RED, BLACK, "[ERROR] Wrong size for Sec2ElemType5 (%d read vs %d needed", nSize, sza );\r
return false;\r
}\r
- if (( u32 )( f->Read( &Data, sza ) ) < sza )\r
+ if (( uint32_t )( f->Read( &Data, sza ) ) < sza )\r
{\r
Console->Print( RED, BLACK, "[ERROR] Unexpected end of file in Sec2ElemType5start" );\r
return false;\r
}\r
- u32 szb = Data.mActorStringSize + Data.mParamStringSize;\r
+ uint32_t szb = Data.mActorStringSize + Data.mParamStringSize;\r
\r
if ( nSize != ( sza + szb ) )\r
{\r
Console->Print( RED, BLACK, "[Warning] String data too long in Sec2ElemType5 End String. End will be ignored" );\r
szb = 64;\r
}\r
- if (( u32 )( f->Read( StringData, szb ) ) < szb )\r
+ if (( uint32_t )( f->Read( StringData, szb ) ) < szb )\r
{\r
Console->Print( RED, BLACK, "[ERROR] Unexpected end of file in Sec2ElemType5 End Strings" );\r
return false;\r
return true;\r
}\r
\r
-bool PWorldDatParser::ProcessSec2NPCEntry( u32 nSize )\r
+bool PWorldDatParser::ProcessSec2NPCEntry( uint32_t nSize )\r
{\r
PSec2NPC_EntryPart1 tNPCPartA;\r
PSec2NPC_EntryPart2 tNPCPartB;\r
std::string tAngle;\r
char tStrBuffer[64];\r
\r
- u32 tSizeOfA = sizeof(tNPCPartA);\r
- u32 tSizeOfB = sizeof(tNPCPartB);\r
+ uint32_t tSizeOfA = sizeof(tNPCPartA);\r
+ uint32_t tSizeOfB = sizeof(tNPCPartB);\r
\r
// Are we able to read enough bytes from the file? means: CAN we safely read our entire struct from the file?\r
if ( nSize < tSizeOfA )\r
return false;\r
}\r
// yes we can! So read it now. If we reach EOF, break\r
- if (( u32 )( f->Read( &tNPCPartA, tSizeOfA ) ) < tSizeOfA )\r
+ if (( uint32_t )( f->Read( &tNPCPartA, tSizeOfA ) ) < tSizeOfA )\r
{\r
Console->Print( RED, BLACK, "[ERROR] Unexpected end of file in ProcessSec2NPCEntry" );\r
return false;\r
}\r
// Now we have the header. lets check if we have some waypoints for this NPC\r
// Size of entire NPC entry in file\r
- u32 tCompleteNPCSize = tSizeOfA + tNPCPartA.mActorStringSize + tNPCPartA.mAngleStringSize;\r
+ uint32_t tCompleteNPCSize = tSizeOfA + tNPCPartA.mActorStringSize + tNPCPartA.mAngleStringSize;\r
if ( tNPCPartA.mHasAdditionalCoords > 0 )\r
{\r
// It has additional coords, add 'em\r
// We are. Continue reading!\r
// Assign the 2 strings and watch out for EOF!\r
memset(tStrBuffer, 0, 64);\r
- if (( u32 )( f->Read( tStrBuffer, tNPCPartA.mActorStringSize ) ) < tNPCPartA.mActorStringSize )\r
+ if (( uint32_t )( f->Read( tStrBuffer, tNPCPartA.mActorStringSize ) ) < tNPCPartA.mActorStringSize )\r
{\r
Console->Print( RED, BLACK, "[ERROR] Unexpected end of file in ProcessSec2NPCEntry mActorStringSize" );\r
return false;\r
tActorName = tStrBuffer;\r
\r
memset(tStrBuffer, 0, 64);\r
- if (( u32 )( f->Read( tStrBuffer, tNPCPartA.mAngleStringSize ) ) < tNPCPartA.mAngleStringSize )\r
+ if (( uint32_t )( f->Read( tStrBuffer, tNPCPartA.mAngleStringSize ) ) < tNPCPartA.mAngleStringSize )\r
{\r
Console->Print( RED, BLACK, "[ERROR] Unexpected end of file in ProcessSec2NPCEntry mAngleStringSize" );\r
return false;\r
tNPC->SetAngle(tAngle);\r
\r
// Read additional Waypoints if available\r
- u8 tCurrWayP = 0;\r
+ uint8_t tCurrWayP = 0;\r
if ( tNPCPartA.mHasAdditionalCoords > 0 )\r
{\r
while ( tCurrWayP < tNPCPartA.mHasAdditionalCoords )\r
{\r
memset(&tNPCPartB, 0, tSizeOfB);\r
- if (( u32 )( f->Read( &tNPCPartB, tSizeOfB ) ) < tSizeOfB )\r
+ if (( uint32_t )( f->Read( &tNPCPartB, tSizeOfB ) ) < tSizeOfB )\r
{\r
Console->Print( RED, BLACK, "[ERROR] Unexpected end of file in ProcessSec2NPCEntry while reading WayPoints" );\r
return false;\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include <string>\r
+\r
+class PFile;\r
+class PWorldDataTemplate;\r
+\r
+class PWorldDatParser {\r
+private:\r
+ PFile* f;\r
+ std::string mNCDataPath;\r
+\r
+ PWorldDataTemplate* mWorld;\r
+ bool mDiscardPassiveObjects;\r
+\r
+ bool ProcessSec2ElemType3(uint32_t nSize);\r
+ bool ProcessSec2ElemType5(uint32_t nSize);\r
+ bool ProcessSec2NPCEntry(uint32_t nSize);\r
+\r
+public:\r
+ PWorldDatParser();\r
+ ~PWorldDatParser();\r
+\r
+ int32_t LoadDatFile(const std::string& nFilename, PWorldDataTemplate* nWorld, const bool nDiscardPassiveObjects = true, const bool nTestAccesOnly = false);\r
+};\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+\r
+struct PWorldFileHeader {\r
+ uint32_t mHeaderSize; // must be 08 00 00 00, = header size after this field\r
+ uint32_t mHeaderSig; // must be CF CF 0F 00\r
+ uint32_t mSection; // must be 01 00 00 00\r
+};\r
+\r
+struct PSectionHeader {\r
+ uint32_t mHeaderSize; // must be 0C 00 00 00\r
+ uint32_t mHeaderSig; // must be CF FF 00 00\r
+ uint32_t mSection; // 00 00 00 00 means end\r
+ uint32_t mDataSize;\r
+};\r
+\r
+struct PSec2ElemHeader {\r
+ uint32_t mHeaderSize; // must be 0C 00 00 00\r
+ uint32_t mHeaderSig; // must be F1 FE FE 0F\r
+ uint32_t mElementType; // 1000003, 1000005 or 1000014\r
+ uint32_t mDataSize;\r
+};\r
+\r
+struct PSec2ElemType3a { //static object ?\r
+ float mPosY; //= uint32_t16_t PosY - 32000\r
+ float mPosZ;\r
+ float mPosX;\r
+ float mRotY;\r
+ float mRotZ;\r
+ float mRotX;\r
+ float mScale; //00 00 80 3F ? = float(1.000000) !!! => scale factor ?????\r
+ uint32_t mUnknown2; //01 00 00 00 ?\r
+ uint16_t mModelID; // point32_ts to models.ini\r
+ uint32_t mUnknown3; //00 00 00 00 ?\r
+ uint32_t mUnknown4; //00 00 00 00 ?\r
+ uint16_t mWorldmodelID; // point32_ts to worldmodel.def\r
+ uint16_t mUnknown5; //12 00 ?\r
+ uint32_t mObjectID;\r
+};\r
+\r
+struct PSec2ElemType3b { //this part is optional\r
+ float mBoxLowerY; //Bounding box, for useflag "64 - selfconstructing colisionbox"\r
+ float mBoxLowerZ; // int32_t32_t or uint32_t32_t ?\r
+ float mBoxLowerX;\r
+ float mBoxUpperY;\r
+ float mBoxUpperZ;\r
+ float mBoxUpperX;\r
+};\r
+\r
+struct PSec2ElemType5Start { //door\r
+ uint16_t mUnknown1; //18 00\r
+ uint16_t mUnknown1bis; //00 00 ? varies\r
+ float mPosY;\r
+ float mPosZ;\r
+ float mPosX;\r
+ uint8_t mActorStringSize; //string size with ending 0\r
+ uint8_t mParamStringSize; //string size with ending 0\r
+ uint16_t mUnknown5; //00 00 ? second byte varies\r
+ uint16_t mDoorID; // but what is the link with ObjectID sent in Use message (can't find the base offset .. or 0x80 for doors ???)\r
+ uint16_t mWorldmodelID; //door type from worldmodel.def\r
+};\r
+//Actor As String //null terminated string\r
+//Params As String //null terminated string - for DDOOR, 2nd param is the ID of the other (half)door (*)\r
+//param1 = 2 => simple lateral move ?, 3 => door frontal+lateral move (as at Typherra memorial) ?\r
+//last param = 0/1 for lateral move direction ? no ...\r
+//(*) here is the bug(?) that makes open only one half of a double door\r
+\r
+/*\r
+struct PSec2ElemType6Start //npc\r
+{\r
+ uint16_t mUnknown1; //20 00 ?\r
+ uint16_t mUnknown2; //12 00 ?\r
+ float mPosY;\r
+ float mPosZ;\r
+ float mPosX;\r
+ uint32_t mNPCTypeID; //npc type in npc.def\r
+ uint8_t mActorStringSize; //string size with ending 0\r
+ uint8_t mParamStringSize; //string size with ending 0\r
+ uint16_t mNpcID; // kind of ?\r
+ uint32_t mUnknown3; //01 00 00 00 ?\r
+ uint16_t mUnknown4; //00 00 ?\r
+ uint16_t mUnknown5; //04 00 ?\r
+};\r
+ //Actor As String //null terminated string\r
+ //Params As String //null terminated string - Seem to be the facing angle in degres\r
+struct PSec2ElemType6End\r
+{\r
+ float mPosY2; //second position for movement ?\r
+ float mPosZ2; //\r
+ float mPosX2; //\r
+};\r
+*/\r
+struct PSec2NPC_EntryPart1 {\r
+ uint32_t mUnknown1; // Is always 0x20001200, in every log. maybe header for NPCs?\r
+ float mPosY;\r
+ float mPosZ;\r
+ float mPosX;\r
+ uint32_t mNPCTypeID; //npc type in npc.def\r
+ uint8_t mActorStringSize; //string size with ending 0\r
+ uint8_t mAngleStringSize; //string size with ending 0\r
+ uint16_t mNpcID;\r
+ uint8_t mHasAdditionalCoords;\r
+ uint8_t mUnknown2a;\r
+ uint8_t mUnknown2b;\r
+ uint8_t mUnknown2c;\r
+ uint16_t mTradeID; //mUnknown3; //00 00 ?\r
+ uint16_t mUnknown4; //04 00 ?\r
+};\r
+\r
+// uint32_t8_t mActorName[mActorStringSize];\r
+// uint32_t8_t mAngle[mAngleStringSize];\r
+\r
+struct PSec2NPC_EntryPart2 { // Waypoint32_ts! or something like that...\r
+ float mPosY;\r
+ float mPosZ;\r
+ float mPosX;\r
+};\r
+\r
+// uint32_t16_t mStrSize; //non-zero terminated string size\r
+// Name As String //non-zero terminated string\r
+struct PSec2ElemType15End { //area definition/sound ?\r
+ float mUnknown1;\r
+ float mUnknown2;\r
+ float mUnknown3;\r
+ float mUnknown4;\r
+ float mUnknown5;\r
+};\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
+#include "GameServer/Definitions/Includes.hxx"\r
+#include "GameServer/Includes.hxx"\r
\r
/*\r
- def_worldfile.cpp (infos from worlds/worlds.ini)\r
-\r
- MODIFIED: 28 Sep 2007 Hammag\r
- REASON: - Creation\r
- \r
- NOTA: Some entries in worlds.ini share the same Id ...\r
- e.g: 505: techtown_enter 1/1a/1b/2\r
- As we don't know what it means & how it is supposed to be handled,\r
- we keep the first one for the moment. (this is managed in gamedef.cpp)\r
- TODO: Add a config entry to select the Nth entry for each such case,\r
- as well as a config entry to select the default entry to be kept (first/last)\r
+ NOTA: Some entries in worlds.ini share the same Id ...\r
+ e.g: 505: techtown_enter 1/1a/1b/2\r
+ As we don't know what it means & how it is supposed to be handled,\r
+ we keep the first one for the moment. (this is managed in gamedef.cpp)\r
+ TODO: Add a config entry to select the Nth entry for each such case,\r
+ as well as a config entry to select the default entry to be kept (first/last)\r
*/\r
\r
-#include "main.h"\r
-\r
PDefWorldFile::PDefWorldFile()\r
{\r
- mFileInWorldsDir = false;\r
+ mFileInWorldsDir = false;\r
}\r
\r
bool PDefWorldFile::LoadFromDef(PTokenList *Tokens)\r
{\r
- int Idx=0;\r
- int StartPos = 0;\r
- int TailLen = 0;\r
- int Len;\r
- \r
- for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++)\r
- {\r
- switch(Idx)\r
- {\r
- case 0: // setentry\r
- continue;\r
-\r
- case 1: // index\r
- mIndex = atoi(i->c_str()); break;\r
-\r
- case 2: // name\r
- {\r
- Len = (*i).length();\r
+ int Idx=0;\r
+ int StartPos = 0;\r
+ int TailLen = 0;\r
+ int Len;\r
+\r
+ for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++)\r
+ {\r
+ switch(Idx)\r
+ {\r
+ case 0: // setentry\r
+ continue;\r
+\r
+ case 1: // index\r
+ mIndex = atoi(i->c_str()); break;\r
+\r
+ case 2: // name\r
+ {\r
+ Len = (*i).length();\r
\r
while((StartPos = (*i).find("\\",StartPos))>-1)\r
(*i)[StartPos]='/';\r
StartPos = 0;\r
- \r
+\r
if ((*i)[0] == '\"')\r
StartPos = 1;\r
- \r
- if ( (*i).substr(StartPos,9) == "./worlds/" )\r
- {\r
- mFileInWorldsDir = true;\r
- StartPos += 9;\r
- }\r
- else if ( (*i).substr(StartPos,2) == "./" )\r
+\r
+ if ( (*i).substr(StartPos,9) == "./worlds/" )\r
+ {\r
+ mFileInWorldsDir = true;\r
+ StartPos += 9;\r
+ }\r
+ else if ( (*i).substr(StartPos,2) == "./" )\r
StartPos += 2;\r
- \r
+\r
if ((*i)[Len-1] == '\"')\r
- TailLen = 1; \r
- if ( (Len > (StartPos+TailLen+4)) && ((*i)[Len-TailLen-4] == '.') )\r
- TailLen += 4;\r
- \r
- mName = (*i).substr(StartPos,Len-StartPos-TailLen); // remove prefix, extension and doublequotes \r
- \r
- break;\r
- }\r
- }\r
- }\r
-\r
- return (Idx == 3);\r
+ TailLen = 1;\r
+ if ( (Len > (StartPos+TailLen+4)) && ((*i)[Len-TailLen-4] == '.') )\r
+ TailLen += 4;\r
+\r
+ mName = (*i).substr(StartPos,Len-StartPos-TailLen); // remove prefix, extension and doublequotes\r
+\r
+ break;\r
+ }\r
+ }\r
+ }\r
+\r
+ return (Idx == 3);\r
}\r
\r
// class PDefWorldFileMap defined in gamedefs.h\r
Console->Print( "%s Defs name not defined", Console->ColorText( RED, BLACK, "[ERROR]" ) );\r
return (false);\r
}\r
- \r
+\r
if(! *nFilename)\r
{\r
Console->Print( "%s Filename not defined for %s defs", Console->ColorText( RED, BLACK, "[ERROR]" ), mName.c_str() );\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include <map>\r
+#include <string>\r
+#include "GameServer/Definitions/Definition.hxx"\r
+\r
+class PDefWorldFile : public PDef {\r
+private:\r
+ //int32_t mIndex;\r
+ std::string mName; // dat filename with ending extension and starting ./ or ./worlds/ REMOVED\r
+ bool mFileInWorldsDir; // TRUE if worlds/ must be appendend before mName to get real file name (dat file at least)\r
+\r
+public:\r
+ PDefWorldFile();\r
+ //~PDefWorldFile();\r
+\r
+ bool LoadFromDef(PTokenList *Tokens);\r
+\r
+ inline const std::string &GetName() const { return mName; }\r
+ inline const std::string GetBasicFileName() const { return (mFileInWorldsDir ? (std::string("worlds/") + mName) : mName); };\r
+};\r
+\r
+\r
+class PDefWorldFilesMap : public PDefMap<PDefWorldFile> {\r
+public:\r
+ bool Load(const char* nName, const char* nFilename);\r
+ inline std::map<int32_t, PDefWorldFile*>::const_iterator ConstIteratorBegin() const { return mDefs.begin(); }\r
+ inline std::map<int32_t, PDefWorldFile*>::const_iterator ConstIteratorEnd() const { return mDefs.end(); }\r
+};\r
--- /dev/null
+#include "GameServer/Definitions/Includes.hxx""\r
+\r
+PDefWorldModel::PDefWorldModel()\r
+{\r
+}\r
+\r
+bool PDefWorldModel::LoadFromDef(PTokenList *Tokens)\r
+{\r
+ int Idx=0;\r
+ for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++)\r
+ {\r
+ switch(Idx)\r
+ {\r
+ case 0: // setentry\r
+ continue;\r
+\r
+ case 1: // index\r
+ mIndex = atoi(i->c_str()); break;\r
+\r
+ case 2: // name\r
+ mName = *i; break;\r
+\r
+ case 3: // use flag\r
+ mUseFlags = atoi(i->c_str()); break;\r
+\r
+ case 4: // function type\r
+ mFunctionType = atoi(i->c_str()); break;\r
+\r
+ case 5: // function value\r
+ mFunctionValue = atoi(i->c_str()); break;\r
+ \r
+ case 6: // hack difficulty\r
+ mHackDifficulty = atoi(i->c_str()); break;\r
+\r
+ case 7: // hack penalty\r
+ mHackPenalty = atoi(i->c_str()); break;\r
+ }\r
+ }\r
+\r
+ return true;\r
+}\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include <string>\r
+#include "GameServer/Definitions/Definition.hxx"\r
+\r
+class PDefWorldModel : public PDef {\r
+private:\r
+ //int32_t mIndex;\r
+ std::string mName;\r
+ int32_t mUseFlags;\r
+ int32_t mFunctionType;\r
+ int32_t mFunctionValue;\r
+ int32_t mHackDifficulty;\r
+ int32_t mHackPenalty;\r
+\r
+public:\r
+ PDefWorldModel();\r
+ //~PDefWorldModel();\r
+\r
+ bool LoadFromDef(PTokenList *Tokens);\r
+\r
+ inline int32_t GetID() const { return mIndex; }\r
+ inline const std::string &GetName() const { return mName; }\r
+ inline int32_t GetUseFlags() const { return mUseFlags; }\r
+ inline int32_t GetFunctionType() const { return mFunctionType; }\r
+ inline int32_t GetFunctionValue() const { return mFunctionValue; }\r
+ inline int32_t GetHackDifficulty() const { return mHackDifficulty; }\r
+ inline int32_t GetHackPenalty() const { return mHackPenalty; }\r
+};\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- def_worlds.cpp\r
-\r
- Authors:\r
- - Akiko\r
- - Namikon\r
- - someone else?\r
-\r
- MODIFIED: Unknown date / Unknown author\r
- REASON: - initial release by unknown\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL\r
-\r
- MODIFIED: 07 Oct 2006 Hammag\r
- REASON: - Added quotes and spaces trim to mName and mDatFile.\r
-*/\r
-\r
-#include "main.h"\r
+#include "GameServer/Definitions/Includes.hxx"\r
\r
PDefWorld::PDefWorld()\r
{\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include <string>\r
+#include "GameServer/Definitions/Definition.hxx"\r
+\r
+class PDefWorld : public PDef {\r
+private:\r
+ //int32_t mIndex;\r
+ std::string mName;\r
+ std::string mDatFile;\r
+ int32_t mFlags;\r
+\r
+public:\r
+ PDefWorld();\r
+ //~PDefWorld();\r
+\r
+ bool LoadFromDef(PTokenList *Tokens);\r
+\r
+ inline const std::string &GetName() const { return mName; }\r
+ inline const std::string &GetDatFile() const { return mDatFile; }\r
+ inline int32_t GetFlags() const { return mFlags; }\r
+};\r
--- /dev/null
+#include <cstring>\r
+#include "GameServer/Includes.hxx"\r
+#include "GameServer/Definitions/Includes.hxx"\r
+\r
+// TODO: - mem corruption occurs if mDoorParameters[] is given a size of 6, and that 6 max param can be accepted\r
+// This bug occurs in world 105. Reason not found yet :-x\r
+\r
+const std::string EmptyString;\r
+\r
+PDoorTemplate::PDoorTemplate()\r
+{\r
+ mDoorID = 0;\r
+ mWorldmodelID = 0;\r
+ mDefWorldModel = NULL;\r
+ mIsDoubleDoor = false;\r
+ mIsTriggeredDoor = false;\r
+}\r
+\r
+PDoorTemplate::~PDoorTemplate()\r
+{\r
+}\r
+\r
+uint16_t PDoorTemplate::GetID()\r
+{\r
+ return mDoorID;\r
+}\r
+\r
+uint16_t PDoorTemplate::GetUseFlags()\r
+{\r
+ return (mDefWorldModel ? mDefWorldModel->GetUseFlags() : 0);\r
+}\r
+\r
+uint16_t PDoorTemplate::GetFunctionType()\r
+{\r
+ return (mDefWorldModel ? mDefWorldModel->GetFunctionType() : 0);\r
+}\r
+\r
+int PDoorTemplate::GetFunctionValue()\r
+{\r
+ return (mDefWorldModel ? mDefWorldModel->GetFunctionValue() : 0);\r
+}\r
+\r
+const std::string& PDoorTemplate::GetName() const\r
+{\r
+ return (mDefWorldModel ? mDefWorldModel->GetName() : EmptyString );\r
+}\r
+\r
+const PDefWorldModel *PDoorTemplate::GetDefWorldModel() const\r
+{\r
+ return mDefWorldModel;\r
+}\r
+\r
+void PDoorTemplate::GetPos(float *nPosX, float *nPosY, float *nPosZ) const\r
+{\r
+ *nPosY = mPosY;\r
+ *nPosZ = mPosZ;\r
+ *nPosX = mPosX;\r
+}\r
+\r
+uint16_t PDoorTemplate::GetOtherDoorID()\r
+{\r
+ return (mIsDoubleDoor ? mDoorParameters[1] : 0);\r
+}\r
+\r
+bool PDoorTemplate::IsDoubleDoor() const\r
+{\r
+ return mIsDoubleDoor;\r
+}\r
+\r
+bool PDoorTemplate::IsTriggeredDoor() const\r
+{\r
+ return mIsTriggeredDoor;\r
+}\r
+\r
+void PDoorTemplate::SetDoorParameters(char* nDoorParametersString)\r
+{\r
+ char* SepPos;\r
+ int ParamNum = 0;\r
+//Console->Print("door parameter: %s", nDoorParametersString);\r
+ while ( *nDoorParametersString && (SepPos = strchr(nDoorParametersString, ',')) && (ParamNum < 4))\r
+ {\r
+ *SepPos = 0;\r
+ mDoorParameters[ParamNum++] = atoi(nDoorParametersString);\r
+ nDoorParametersString = SepPos + 1;\r
+ }\r
+ if (*nDoorParametersString)\r
+ {\r
+ if (ParamNum < 4)\r
+ mDoorParameters[ParamNum] = atoi(nDoorParametersString);\r
+ //else\r
+ // Console->Print(RED, BLACK, "[ERROR] More than 4 parameters in Sec2ElemType5 ParamString");\r
+ }\r
+}\r
+\r
+void PDoorTemplate::SetDoorTypeName(char* nDoorTypeName)\r
+{\r
+ mDoorTypeName = nDoorTypeName;\r
+\r
+ if (mDoorTypeName == "DDOOR")\r
+ {\r
+ mIsDoubleDoor = true;\r
+ }\r
+ else if (mDoorTypeName == "TRIGDD")\r
+ {\r
+ mIsDoubleDoor = true;\r
+ mIsTriggeredDoor = true;\r
+ }\r
+ else if (mDoorTypeName == "TRIGDOOR")\r
+ {\r
+ mIsTriggeredDoor = true;\r
+ }\r
+ else if (mDoorTypeName == "NBUTTON")\r
+ {\r
+ mIsTriggeredDoor = false;\r
+ }\r
+}\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+\r
+class PDefWorldModel;\r
+\r
+class PDoorTemplate {\r
+ friend class PWorldDatParser;\r
+\r
+private:\r
+ uint16_t mDoorID;\r
+\r
+ // The commented out values are not loaded from dat file atm because they are not used yet.\r
+ //uint16_t mUnknown1; //18 00\r
+ //uint16_t mUnknown1bis; //00 00 ? varies\r
+ float mPosY;\r
+ float mPosZ;\r
+ float mPosX;\r
+ //uint16_t mUnknown5; //00 00 ? second byte varies\r
+ uint16_t mWorldmodelID; //door type from worldmodel.def\r
+\r
+ std::string mDoorTypeName;\r
+ int mDoorParameters[4];\r
+ bool mIsDoubleDoor;\r
+ bool mIsTriggeredDoor;\r
+\r
+ const PDefWorldModel* mDefWorldModel;\r
+\r
+public:\r
+ PDoorTemplate();\r
+ ~PDoorTemplate();\r
+\r
+ uint16_t GetID();\r
+ uint16_t GetUseFlags();\r
+ uint16_t GetFunctionType();\r
+ int GetFunctionValue();\r
+ const std::string& GetName() const; /// !!!!\r
+ const PDefWorldModel *GetDefWorldModel() const;\r
+\r
+ void GetPos(float *nPosX, float *nPosY, float *nPosZ) const;\r
+ uint16_t GetOtherDoorID();\r
+ bool IsDoubleDoor() const;\r
+ bool IsTriggeredDoor() const;\r
+\r
+ void SetDoorTypeName(char* nDoorTypeName);\r
+ void SetDoorParameters(char* nDoorParametersString);\r
+};\r
--- /dev/null
+#include "GameServer/Includes.hxx"\r
+#include "GameServer/Definitions/Includes.hxx"\r
+\r
+const std::string EmptyString;\r
+\r
+PFurnitureItemTemplate::PFurnitureItemTemplate()\r
+{\r
+ mObjectID = 0;\r
+ mModelID = 0;\r
+ mWorldmodelID = 0;\r
+ mDefWorldModel = NULL;\r
+ mLinkedObjectID = 0;\r
+}\r
+\r
+PFurnitureItemTemplate::~PFurnitureItemTemplate()\r
+{\r
+}\r
+\r
+uint32_t PFurnitureItemTemplate::GetID() const\r
+{\r
+ return mObjectID;\r
+}\r
+\r
+uint16_t PFurnitureItemTemplate::GetUseFlags() const\r
+{\r
+ return (mDefWorldModel ? mDefWorldModel->GetUseFlags() : 0);\r
+}\r
+\r
+uint16_t PFurnitureItemTemplate::GetFunctionType() const\r
+{\r
+ return (mDefWorldModel ? mDefWorldModel->GetFunctionType() : 0);\r
+}\r
+\r
+int PFurnitureItemTemplate::GetFunctionValue() const\r
+{\r
+ return (mDefWorldModel ? mDefWorldModel->GetFunctionValue() : 0);\r
+}\r
+\r
+const std::string &PFurnitureItemTemplate::GetName() const\r
+{\r
+ return (mDefWorldModel ? mDefWorldModel->GetName() : EmptyString);\r
+}\r
+\r
+const PDefWorldModel *PFurnitureItemTemplate::GetDefWorldModel() const\r
+{\r
+ return mDefWorldModel;\r
+}\r
+\r
+uint8_t PFurnitureItemTemplate::GetFrontLR() const\r
+{\r
+ return mFrontLR;\r
+}\r
+\r
+void PFurnitureItemTemplate::GetFrontPos(uint16_t *nFrontPosX, uint16_t *nFrontPosY, uint16_t *nFrontPosZ) const\r
+{\r
+ *nFrontPosY = mFrontPosY;\r
+ *nFrontPosZ = mFrontPosZ;\r
+ *nFrontPosX = mFrontPosX;\r
+}\r
+\r
+void PFurnitureItemTemplate::GetPos(float *nPosX, float *nPosY, float *nPosZ) const\r
+{\r
+ *nPosY = mPosY;\r
+ *nPosZ = mPosZ;\r
+ *nPosX = mPosX;\r
+}\r
+\r
+void PFurnitureItemTemplate::SetLinkedObjectID(uint32_t nID)\r
+{\r
+ mLinkedObjectID = nID;\r
+}\r
+\r
+uint32_t PFurnitureItemTemplate::GetLinkedObjectID() const\r
+{\r
+ return mLinkedObjectID;\r
+}\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include <string>\r
+\r
+class PDefWorldModel;\r
+\r
+enum { // Furniture Use flags (cumlative)\r
+ ufTouchable = 1,\r
+ ufUsable = 2,\r
+ ufNoCollision = 4,\r
+ ufChair = 8,\r
+ ufToolTarget = 16,\r
+ ufSelfCollisionBox = 64,\r
+ ufGraphicalEffect = 128,\r
+ ufNoSelectionBox = 256\r
+};\r
+\r
+class PFurnitureItemTemplate {\r
+ friend class PWorldDatParser;\r
+\r
+private:\r
+ uint32_t mObjectID;\r
+\r
+ // The commented out values are not loaded from dat file atm because they are not used yet.\r
+ float mPosY; //= mPosY from dat file + 32000, to be coherent with char Pos scale\r
+ float mPosZ;\r
+ float mPosX;\r
+ //float mRotY;\r
+ float mRotZ;\r
+ //float mRotX;\r
+ //uint32_t mScale; //00 00 80 3F ? = float(1.0000) scale factor ? // mostly used by holoscreens (passiv object)\r
+ //uint32_t mUnknown2; //01 00 00 00 ?\r
+ uint16_t mModelID; // points to models.ini\r
+ //uint32_t mUnknown3; //00 00 00 00 ?\r
+ //uint32_t mUnknown4; //00 00 00 00 ?\r
+ uint16_t mWorldmodelID; // points to worldmodel.def\r
+ //uint16_t mUnknown5; //12 00 ? // changes sometime (ex: c288 ...)\r
+\r
+ //float mBoxLowerY; //Bounding box, for use when ufSelfCollisionBox is set in mUseFlags.\r
+ //float mBoxLowerZ;\r
+ //float mBoxLowerX;\r
+ //float mBoxUpperY;\r
+ //float mBoxUpperZ;\r
+ //float mBoxUpperX;\r
+\r
+ uint16_t mFrontPosY;\r
+ uint16_t mFrontPosZ;\r
+ uint16_t mFrontPosX;\r
+ uint8_t mFrontLR;\r
+\r
+ const PDefWorldModel* mDefWorldModel;\r
+\r
+ uint32_t mLinkedObjectID; // for buttons, stores the corresponding triggered door\r
+ // fo GR, stores order of the GR entity (spawn point) to later choose from respawn.def data\r
+\r
+ public:\r
+ PFurnitureItemTemplate();\r
+ ~PFurnitureItemTemplate();\r
+\r
+ uint32_t GetID() const;\r
+ uint16_t GetUseFlags() const;\r
+ uint16_t GetFunctionType() const;\r
+ int GetFunctionValue() const;\r
+ const std::string &GetName() const; /// !!!!\r
+ const PDefWorldModel *GetDefWorldModel() const;\r
+ uint8_t GetFrontLR() const;\r
+ void GetFrontPos(uint16_t *nFrontPosX, uint16_t *nFrontPosY, uint16_t *nFrontPosZ) const;\r
+ void GetPos(float *nPosX, float *nPosY, float *nPosZ) const;\r
+\r
+ void SetLinkedObjectID(uint32_t nID);\r
+ uint32_t GetLinkedObjectID() const;\r
+};\r
+\r
+// *** from worldmodel.def ***\r
+\r
+//function Type\r
+// 0 - none\r
+// 1 - Itemcontainer\r
+// 2 - Terminal\r
+// 3 - Outfitter\r
+// 4 - Trader\r
+// 5 - Mineral\r
+// 6 - Respawn Station\r
+// 7 - GoGuardian\r
+// 8 - Hackterminal\r
+// 9 - Appartement Eingang\r
+// 10 - Appartement Ein/Ausgang\r
+// 11 - Appartement Klingel/�ffner\r
+// 12 - Standard Button\r
+// 13 - Hack Button\r
+// 14 - HOLOMATCH ENTRANCE\r
+// 15 - HOLOMATCH EXIT\r
+// 16 - HOLOMATCH REFRESH\r
+// 17 - HOLOMATCH HEAL\r
+// 18 - WORLDCHANGEACTOR\r
+// 19 - CLANTERMINAL\r
+// 20 - DATFILE WORLDCHANGE ACTOR\r
+// 21 - LOCATION FOR 20\r
+// 22 -\r
+// 23 - EINTRITTSGELD BUTTON\r
+// 24- TUTORIALEXIT\r
+// 25 - EXPLOSIVE\r
+// 26 - Outpost Switch\r
+// 27 - Old goguardian\r
+// 28 - Fahrzeug Depot Interface\r
+// 29 - Underground Exit\r
+// 30 - Static FX (Value=Type. 1=Fire 2=Smoke 3=Steam 4=Sparkle)\r
+// 31 - Venture Warp Station\r
+// 32 - functionvalue+100 gibt eine Meldung aus der Text.ini [MISC] an.\r
+//\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-#include "main.h"\r
+#include <cstring>\r
+#include "GameServer/Includes.hxx"\r
\r
void PCommands::doCmdban()\r
{\r
target = GetClientByNick(tmp_destNick);\r
}\r
\r
- if(target == NULL) // If victim isnt found, return error\r
+ if(target == nullptr) // If victim isnt found, return error\r
{\r
Chat->send(source, CHAT_DIRECT, "System", "No such player");\r
return;\r
char tmpTimeVal[10];\r
GetArgText(2, tmpTimeVal, 10);\r
\r
- int loop_i = 0;\r
+ int32_t loop_i = 0;\r
char tmp_atoi[10];\r
\r
while(isdigit(tmpTimeVal[loop_i]) != 0 && loop_i < 10)\r
}\r
char timefactor[1];\r
timefactor[0] = tmpTimeVal[loop_i];\r
- int timevalue = atoi(tmp_atoi);\r
- int time_to_ban = 0;\r
+ int32_t timevalue = atoi(tmp_atoi);\r
+ int32_t time_to_ban = 0;\r
\r
if(strcasecmp(timefactor, "s") == 0 )\r
{\r
Chat->send(source, CHAT_DIRECT, "Usage", "@ban <charID or nickname> <xS(econds)>/<xM(inutes)>/<xH(ours)>/<xD(ays)>");\r
return;\r
}\r
- \r
- int final_bantime = std::time(NULL) + time_to_ban;\r
+\r
+ int32_t final_bantime = std::time(nullptr) + time_to_ban;\r
PAccount Acc(target->GetAccountID());\r
Acc.SetBannedUntilTime(final_bantime);\r
Acc.Save();\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-#include "main.h"\r
+#include "GameServer/Includes.hxx"\r
\r
void PCommands::doCmdbrightness()\r
{\r
GetArgText(2, tmp_v2, 30);\r
GetArgText(3, tmp_v3, 30);\r
\r
- u8 val1, val2, val3, val4, val5, val6;\r
+ uint8_t val1, val2, val3, val4, val5, val6;\r
char effStr[128];\r
PMessage* tmpMsg;\r
\r
source->GetChar()->GetCurrentBodyColor(val1, val2, val3, val4, val5, val6);\r
if(tmp_v1[0] != '-')\r
- val4 = (u8)(atoi(tmp_v1) & 0xff);\r
+ val4 = (uint8_t)(atoi(tmp_v1) & 0xff);\r
if((tmp_v2[0] != '-') && (tmp_v2[0] != '\0'))\r
- val5 = (u8)(atoi(tmp_v2) & 0xff);\r
+ val5 = (uint8_t)(atoi(tmp_v2) & 0xff);\r
if((tmp_v3[0] != '-') && (tmp_v3[0] != '\0'))\r
- val6 = (u8)(atoi(tmp_v3) & 0xff);\r
+ val6 = (uint8_t)(atoi(tmp_v3) & 0xff);\r
source->GetChar()->SetCurrentBodyColor(val1, val2, val3, val4, val5, val6);\r
\r
tmpMsg = MsgBuilder->BuildCharHelloMsg(source);\r
--- /dev/null
+#include "GameServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
+\r
+void PCommands::doCmdbroadcast()\r
+{\r
+ if(DumbMade == false)\r
+ {\r
+ Console->Print("%s Missing packetdumb in PCommands::doCmdbroadcast for declared broadcast function!", Console->ColorText(RED, BLACK, "[PANIC]"));\r
+ return;\r
+ }\r
+\r
+ Chat->sendBroadcast(OrgPacketDumb+11);\r
+}\r
--- /dev/null
+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)
--- /dev/null
+#include "GameServer/Includes.hxx"\r
+\r
+void PCommands::doCmdcolor()\r
+{\r
+ bool SyntaxError = false;\r
+ if(ArgC < 1)\r
+ {\r
+ SyntaxError = true;\r
+ }\r
+\r
+ if(SyntaxError == true)\r
+ {\r
+ Chat->send(source, CHAT_DIRECT, "Usage", "@color -|<head color: 0..255> [-|<torso color>] [-|<legs color>]");\r
+ return;\r
+ }\r
+\r
+ char tmp_v1[30];\r
+ char tmp_v2[30];\r
+ char tmp_v3[30];\r
+\r
+ GetArgText(1, tmp_v1, 30);\r
+ GetArgText(2, tmp_v2, 30);\r
+ GetArgText(3, tmp_v3, 30);\r
+\r
+ uint8_t val1, val2, val3, val4, val5, val6;\r
+ char effStr[128];\r
+ PMessage* tmpMsg;\r
+\r
+ source->GetChar()->GetCurrentBodyColor(val1, val2, val3, val4, val5, val6);\r
+ if(tmp_v1[0] != '-')\r
+ val1 = (uint8_t)(atoi(tmp_v1) & 0xff);\r
+ if((tmp_v2[0] != '-') && (tmp_v2[0] != '\0'))\r
+ val2 = (uint8_t)(atoi(tmp_v2) & 0xff);\r
+ if((tmp_v3[0] != '-') && (tmp_v3[0] != '\0'))\r
+ val3 = (uint8_t)(atoi(tmp_v3) & 0xff);\r
+ source->GetChar()->SetCurrentBodyColor(val1, val2, val3, val4, val5, val6);\r
+\r
+ tmpMsg = MsgBuilder->BuildCharHelloMsg(source);\r
+ ClientManager->UDPBroadcast(tmpMsg, source);\r
+ snprintf(effStr, 127, "Body color set to values %d %d %d", val1, val2, val3);\r
+ effStr[127] = '\0';\r
+ Chat->send(source, CHAT_DIRECT, "System", effStr);\r
+}\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-#include "main.h"\r
+#include <cstring>\r
+#include "GameServer/Includes.hxx"\r
\r
void PCommands::doCmddebug()\r
{\r
const char* DbgTarget = "all";\r
char DbgMessage[80];\r
const char* Usage = "@debug [loc[ation] | it[emid] | sub[way]] [0|1]";\r
- \r
+\r
if(ArgC > 0)\r
{\r
if(IsArgNumeric(1) == true)\r
}\r
}\r
}\r
- \r
+\r
if (nWhat != DBG_ALL)\r
{\r
if(ArgC == 1)\r
}\r
}\r
}\r
- \r
+\r
if (nHow != -1)\r
{\r
source->SetDebugMode(nWhat, nHow);\r
--- /dev/null
+#include <cstdint>\r
+#include <cstdio>\r
+#include "GameServer/Includes.hxx"\r
+\r
+void PCommands::doCmdeffect()\r
+{\r
+ bool SyntaxError = false;\r
+ if(ArgC < 1)\r
+ {\r
+ SyntaxError = true;\r
+ }\r
+\r
+ if(IsArgNumeric(1) == false)\r
+ SyntaxError = true;\r
+\r
+ if(SyntaxError == true)\r
+ {\r
+ Chat->send(source, CHAT_DIRECT, "Usage", "@effect <effect: 0=none, 1 .. 17> [<density: 0=max .. 255=min>]");\r
+ return;\r
+ }\r
+\r
+ uint8_t val1, val2;\r
+ char effStr[128];\r
+ PMessage* tmpMsg;\r
+\r
+ val1 = (uint8_t)(GetArgInt(1) & 0xff);\r
+ val2 = (uint8_t)(GetArgInt(2) & 0xff);\r
+\r
+ source->GetChar()->SetBodyEffect(val1, val2);\r
+\r
+ tmpMsg = MsgBuilder->BuildCharHelloMsg(source);\r
+ ClientManager->UDPBroadcast(tmpMsg, source);\r
+ snprintf(effStr, 127, "Body effect set to value %d with density %d (but you can see it yourself)", val1, val2);\r
+ effStr[127] = '\0';\r
+ Chat->send(source, CHAT_DIRECT, "System", effStr);\r
+}\r
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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)
{
}
else
{
- cashtoadd = (u32)GetArgInt(1);
+ cashtoadd = (uint32_t)GetArgInt(1);
}
if(cashtoadd == 0)
SyntaxError = true;
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);
}
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);
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-#include "main.h"\r
+#include "GameServer/Includes.hxx"\r
\r
void PCommands::doCmd_dev_h()\r
{\r
/*\r
u8 val1, val2, val3, val4;\r
char tmpStr[128];\r
- \r
+\r
if(ArgC > 0)\r
{\r
val1 = (u8)(GetArgInt(1) & 0xff);\r
val4 = 0x01;\r
}\r
\r
- PMessage* tmpMsg = new PMessage(14); \r
+ PMessage* tmpMsg = new PMessage(14);\r
\r
*tmpMsg << (u8)0x13;\r
*tmpMsg << (u16)0x0000; //source->GetUDP_ID(); // just placeholder, must be set outside\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-#include "main.h"\r
+#include "GameServer/Includes.hxx"\r
\r
void PCommands::doCmdinfo()\r
{\r
DIRECT> Info: Cash : %d // Chars->GetChar(source->GetCharID())->GetCash();\r
DIRECT> Info: Soullight : %d // Chars->GetChar(source->GetCharID())->GetSoullight();\r
*/\r
- \r
+\r
PAccount Acc(target->GetAccountID());\r
- \r
+\r
// If source != target\r
if(source->GetAccountID() != target->GetAccountID())\r
{\r
snprintf(tmpInfo_AxxLv, 150, "AccessLevel: %d", Acc.GetLevel());\r
snprintf(tmpInfo_Loc, 150, "Current Loc: %d", Chars->GetChar(target->GetCharID())->GetLocation());\r
snprintf(tmpInfo_IP, 150, "IP address : %s", target->GetAddress());\r
- \r
+\r
tmpInfo_head[150] = '\0';\r
tmpInfo_cID[150] = '\0';\r
tmpInfo_aID[150] = '\0';\r
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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()
{
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 )
{
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-#include "main.h"\r
+#include "GameServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
void PCommands::doCmdkick()\r
{\r
--- /dev/null
+#include "GameServer/Includes.hxx"\r
+\r
+void PCommands::doCmdlistbans()\r
+{\r
+ Chat->send(source, CHAT_DIRECT, "System", "Sorry, namikon was too lazy to code that ^^");\r
+ Chat->send(source, CHAT_DIRECT, "System", "Please wait until the ban is removed automaticly or edit your sqlDB");\r
+ return;\r
+}\r
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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 <cstring>
+#include "GameServer/Includes.hxx"
+#include "GameServer/Definitions/Includes.hxx"
+#include "Common/Includes.hxx"
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
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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 <cstring>
+#include "GameServer/Includes.hxx"
+#include "GameServer/Definitions/Includes.hxx"
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];
--- /dev/null
+#include "GameServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
+\r
+void PCommands::doCmdconlist()\r
+{\r
+ if (gDevDebug) Console->Print("IngameCommand: Sending connected-player-list to charID %d", source->GetCharID());\r
+ Chat->sendConnectedList(source, false);\r
+}\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-#include "main.h"\r
+#include <cstring>\r
+#include "GameServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
void PCommands::doCmdrawf()\r
{\r
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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()
{
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;
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-#include "main.h"\r
+#include <cstring>\r
+#include "GameServer/Includes.hxx"\r
\r
void PCommands::doCmdremove()\r
{\r
\r
if(IsArgNumeric(1) == true)\r
{\r
- u32 tTest = GetArgInt(1);\r
+ uint32_t tTest = GetArgInt(1);\r
if(WorldActors->IsDynamicActor(tTest) == true)\r
{\r
Chat->send(source, CHAT_DIRECT, "System", "You cannot remove dynamic actors over their ID!");\r
return;\r
}\r
- u32 TargetID;\r
+ uint32_t TargetID;\r
char delStr[128];\r
PMessage* tmpMsg;\r
\r
- TargetID = (u32)(atoi(tmp_v1) & 0xffffffff);\r
+ TargetID = (uint32_t)(atoi(tmp_v1) & 0xffffffff);\r
tmpMsg = MsgBuilder->BuildFurnitureActivateMsg(source, TargetID, 5);\r
\r
ClientManager->UDPBroadcast(tmpMsg, source);\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-#include "main.h"\r
+#include "GameServer/Includes.hxx"\r
\r
void PCommands::doCmdsetlevel()\r
{\r
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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)
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;
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
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;
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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)
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;
// Now setting player's Skill tMainSkill to tNewLevel
- u8 tOldLevel = 0;
+ uint8_t tOldLevel = 0;
int tLevelDiff = 0;
// Grab old Level
--- /dev/null
+#include "GameServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
+\r
+void PCommands::doCmdsettime()\r
+{\r
+ if(ArgC < 1 && GetArgInt(1) == 0)\r
+ {\r
+ Chat->send(source, CHAT_DIRECT, "Usage", "@settime <raw timevalue>");\r
+ return;\r
+ }\r
+\r
+ int newtime = 0;\r
+ newtime = GetArgInt(1);\r
+\r
+ GameServer->SetGameTime(newtime);\r
+ Console->Print("IngameCommand: CharID %d set ingametime to %d", source->GetCharID(), newtime);\r
+}\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-#include "main.h"\r
+#include "GameServer/Includes.hxx"\r
\r
void PCommands::doCmdshun()\r
{\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-#include "main.h"\r
+#include <sstream>\r
+#include "GameServer/Includes.hxx"\r
\r
void PCommands::doCmdskin()\r
{\r
SyntaxError = true;\r
}\r
\r
- u32 Skinval1, Skinval2, Skinval3, Skinval4;\r
+ uint32_t Skinval1, Skinval2, Skinval3, Skinval4;\r
PChar *SkinChar = Chars->GetChar(source->GetCharID());\r
std::stringstream SkinChat;\r
char SkinStr[128];\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-#include "main.h"\r
+#include "GameServer/Includes.hxx"\r
\r
void PCommands::doCmdspawnactor()\r
{\r
SyntaxError = true;\r
}\r
\r
- u16 tmpActorID = (u16)GetArgInt(1);\r
- u16 tmpFunctionID = (u16)GetArgInt(2);\r
- u16 tmpOption1 = 0;\r
- u16 tmpOption2 = 0;\r
- u16 tmpOption3 = 0;\r
+ uint16_t tmpActorID = (uint16_t)GetArgInt(1);\r
+ uint16_t tmpFunctionID = (uint16_t)GetArgInt(2);\r
+ uint16_t tmpOption1 = 0;\r
+ uint16_t tmpOption2 = 0;\r
+ uint16_t tmpOption3 = 0;\r
\r
if(ArgC > 2)\r
{\r
}\r
else\r
{\r
- tmpOption1 = (u16)GetArgInt(3);\r
+ tmpOption1 = (uint16_t)GetArgInt(3);\r
if(ArgC > 3)\r
{\r
if(IsArgNumeric(4) == false)\r
}\r
else\r
{\r
- tmpOption1 = (u16)GetArgInt(4);\r
+ tmpOption1 = (uint16_t)GetArgInt(4);\r
if(ArgC > 4)\r
{\r
if(IsArgNumeric(4) == false)\r
}\r
else\r
{\r
- tmpOption1 = (u16)GetArgInt(5);\r
+ tmpOption1 = (uint16_t)GetArgInt(5);\r
}\r
}\r
}\r
--- /dev/null
+#include "GameServer/Includes.hxx"\r
+\r
+void PCommands::doCmdspeed()\r
+{\r
+// Speed override setting.\r
+// Usage: @speed <newspeed> | #\r
+// with <speed> = 0 (no move).. 254 , 255 or # meaning "no speed override"\r
+\r
+ bool SyntaxError = false;\r
+ if(ArgC < 1)\r
+ {\r
+ SyntaxError = true;\r
+ }\r
+\r
+ if(SyntaxError == true)\r
+ {\r
+ Chat->send(source, CHAT_DIRECT, "Usage", "@speed <newspeed: 0 .. 254 > | 255 | #");\r
+ return;\r
+ }\r
+ char tmpval[30];\r
+ GetArgText(1, tmpval, 30);\r
+\r
+ uint8_t val1;\r
+ char effStr[128];\r
+ PMessage* tmpMsg;\r
+\r
+ val1 = ((tmpval[0] == '#') ? 255 : (uint8_t)(atoi(tmpval) & 0xff));\r
+ source->GetChar()->SetSpeedOverride(val1);\r
+\r
+ tmpMsg = MsgBuilder->BuildCharHelloMsg(source);\r
+ ClientManager->UDPBroadcast(tmpMsg, source);\r
+ snprintf(effStr, 127, "Speed override set to value %d ", val1);\r
+ effStr[127] = '\0';\r
+ Chat->send(source, CHAT_DIRECT, "System", effStr);\r
+}\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-#include "main.h"\r
+#include <chrono>\r
+#include <thread>\r
+#include "GameServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
void PCommands::doCmd_dev_t()\r
{\r
if ( ArgC >= 2 )\r
{\r
GetArgText( 1, Arg1, 30 );\r
- u32 targetObjectId = GetArgInt( 2 ) & 0xffffffff;\r
+ uint32_t targetObjectId = GetArgInt( 2 ) & 0xffffffff;\r
if ( Arg1[0] == 't' )\r
{\r
- u8 val1;\r
+ uint8_t val1;\r
if ( ArgC >= 3 )\r
{\r
int val2 = GetArgInt( 3 );\r
tmpMsg = new PMessage( 32 );\r
source->IncreaseUDP_ID();\r
- *tmpMsg << ( u8 )0x13;\r
- *tmpMsg << ( u16 )source->GetUDP_ID();\r
- *tmpMsg << ( u16 )source->GetSessionID();\r
- *tmpMsg << ( u8 )0x00; // Message length\r
- *tmpMsg << ( u8 )0x03;\r
- *tmpMsg << ( u16 )source->GetUDP_ID();\r
- *tmpMsg << ( u8 )0x2d;\r
- *tmpMsg << ( u32 )targetObjectId;\r
- *tmpMsg << ( u8 )0x01;\r
- *tmpMsg << ( u32 )val2;\r
- \r
- ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 );\r
+ *tmpMsg << ( uint8_t )0x13;\r
+ *tmpMsg << ( uint16_t )source->GetUDP_ID();\r
+ *tmpMsg << ( uint16_t )source->GetSessionID();\r
+ *tmpMsg << ( uint8_t )0x00; // Message length\r
+ *tmpMsg << ( uint8_t )0x03;\r
+ *tmpMsg << ( uint16_t )source->GetUDP_ID();\r
+ *tmpMsg << ( uint8_t )0x2d;\r
+ *tmpMsg << ( uint32_t )targetObjectId;\r
+ *tmpMsg << ( uint8_t )0x01;\r
+ *tmpMsg << ( uint32_t )val2;\r
+\r
+ ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 );\r
source->SendUDPMessage( tmpMsg );\r
snprintf( tmpStr, 127, "Sent 13/03/2d msg to object id 0x%08x with values 6/%d", targetObjectId, val2 );\r
textMsg = tmpStr;\r
if(val1 == 6) continue;\r
tmpMsg = new PMessage( 15 );\r
source->IncreaseUDP_ID();\r
- *tmpMsg << ( u8 )0x13;\r
- *tmpMsg << ( u16 )source->GetUDP_ID();\r
- *tmpMsg << ( u16 )source->GetSessionID();\r
- *tmpMsg << ( u8 )0x00; // Message length\r
- *tmpMsg << ( u8 )0x03;\r
- *tmpMsg << ( u16 )source->GetUDP_ID();\r
- *tmpMsg << ( u8 )0x2d;\r
- *tmpMsg << ( u32 )targetObjectId;\r
- *tmpMsg << ( u8 )val1; \r
- \r
- ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 );\r
+ *tmpMsg << ( uint8_t )0x13;\r
+ *tmpMsg << ( uint16_t )source->GetUDP_ID();\r
+ *tmpMsg << ( uint16_t )source->GetSessionID();\r
+ *tmpMsg << ( uint8_t )0x00; // Message length\r
+ *tmpMsg << ( uint8_t )0x03;\r
+ *tmpMsg << ( uint16_t )source->GetUDP_ID();\r
+ *tmpMsg << ( uint8_t )0x2d;\r
+ *tmpMsg << ( uint32_t )targetObjectId;\r
+ *tmpMsg << ( uint8_t )val1;\r
+\r
+ ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 );\r
source->SendUDPMessage( tmpMsg );\r
snprintf( tmpStr, 127, "Sent 13/03/2d msg to object id 0x%08x with value %d", targetObjectId, val1 );\r
textMsg = tmpStr;\r
Chat->send( source, CHAT_DIRECT, "System", textMsg );\r
source->getUDPConn()->update();\r
source->getTCPConn()->update();\r
- sleep(1);\r
+ //sleep(1);\r
+ std::this_thread::sleep_for(std::chrono::seconds(1));\r
}\r
tmpMsg = NULL;\r
}\r
else if ( Arg1[0] == 'd' )\r
{\r
- u8 val1 = 0x4a; // default values\r
- u8 val2 = 0x1e;\r
+ uint8_t val1 = 0x4a; // default values\r
+ uint8_t val2 = 0x1e;\r
\r
if ( ArgC >= 3 )\r
val1 = GetArgInt( 3 ) & 0xff;\r
}\r
else if ( Arg1[0] == 'm' )\r
{\r
- u8 nTxtGroupID = targetObjectId & 0xff;\r
- u16 nTxtID = 10;\r
- //u32 nVal = 0;\r
+ uint8_t nTxtGroupID = targetObjectId & 0xff;\r
+ uint16_t nTxtID = 10;\r
+ //uint32_t nVal = 0;\r
if ( ArgC >= 3 )\r
nTxtID = GetArgInt( 3 ) & 0xffff;\r
//if(ArgC >= 4)\r
tmpMsg = new PMessage( 20 );\r
\r
source->IncreaseUDP_ID();\r
- *tmpMsg << ( u8 )0x13;\r
- *tmpMsg << ( u16 )source->GetUDP_ID();\r
- *tmpMsg << ( u16 )source->GetSessionID();\r
- *tmpMsg << ( u8 )0x0e; // Message length\r
- *tmpMsg << ( u8 )0x03;\r
- *tmpMsg << ( u16 )source->GetUDP_ID();\r
- *tmpMsg << ( u8 )0x1f;\r
- *tmpMsg << ( u16 )source->GetLocalID();\r
- *tmpMsg << ( u8 )0x25; // ??\r
- *tmpMsg << ( u8 )0x15; // ??\r
+ *tmpMsg << ( uint8_t )0x13;\r
+ *tmpMsg << ( uint16_t )source->GetUDP_ID();\r
+ *tmpMsg << ( uint16_t )source->GetSessionID();\r
+ *tmpMsg << ( uint8_t )0x0e; // Message length\r
+ *tmpMsg << ( uint8_t )0x03;\r
+ *tmpMsg << ( uint16_t )source->GetUDP_ID();\r
+ *tmpMsg << ( uint8_t )0x1f;\r
+ *tmpMsg << ( uint16_t )source->GetLocalID();\r
+ *tmpMsg << ( uint8_t )0x25; // ??\r
+ *tmpMsg << ( uint8_t )0x15; // ??\r
*tmpMsg << nTxtGroupID;\r
*tmpMsg << nTxtID;\r
- *tmpMsg << ( u16 )0x00; // ??\r
- *tmpMsg << ( u8 )0x01;\r
- *tmpMsg << ( u8 )0x04;\r
- *tmpMsg << ( u32 )0x00;\r
- //*tmpMsg << (u8)0x00; // ??\r
- //*tmpMsg << (u8)0x00; // ??\r
- //*tmpMsg << (u32)nVal;\r
-\r
- ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 );\r
+ *tmpMsg << ( uint16_t )0x00; // ??\r
+ *tmpMsg << ( uint8_t )0x01;\r
+ *tmpMsg << ( uint8_t )0x04;\r
+ *tmpMsg << ( uint32_t )0x00;\r
+ //*tmpMsg << (uint8_t)0x00; // ??\r
+ //*tmpMsg << (uint8_t)0x00; // ??\r
+ //*tmpMsg << (uint32_t)nVal;\r
+\r
+ ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 );\r
snprintf( tmpStr, 127, "Using msg n %d from group %d", nTxtID, nTxtGroupID );\r
textMsg = tmpStr;\r
\r
else if ( Arg1[0] == 'e' )\r
{\r
targetObjectId = 1004; //target=int\r
- u16 nval = 5;\r
- u8 nType = 1; // 1=+ 2=-\r
- u16 nDur = 20;\r
- u8 nparam = 1;\r
+ uint16_t nval = 5;\r
+ uint8_t nType = 1; // 1=+ 2=-\r
+ uint16_t nDur = 20;\r
+ uint8_t nparam = 1;\r
\r
nparam = GetArgInt( 2 ) && 0xff;\r
\r
tmpMsg = new PMessage( 32 );\r
\r
source->IncreaseUDP_ID();\r
- *tmpMsg << ( u8 )0x13;\r
- *tmpMsg << ( u16 )source->GetUDP_ID();\r
- *tmpMsg << ( u16 )source->GetSessionID();\r
- *tmpMsg << ( u8 )0x0e; // Message length\r
- *tmpMsg << ( u8 )0x03;\r
- *tmpMsg << ( u16 )source->GetUDP_ID();\r
- *tmpMsg << ( u8 )0x1f;\r
- *tmpMsg << ( u16 )source->GetLocalID();\r
- *tmpMsg << ( u8 )0x25; // ??\r
- *tmpMsg << ( u8 )0x06; // ??\r
- *tmpMsg << ( u8 )0x01; // 1 effect\r
- *tmpMsg << ( u8 )0x01; // effect on intox level ????\r
- *tmpMsg << ( u16 )nDur;\r
- *tmpMsg << ( u16 )(700+(targetObjectId % 100)); //item id Thyronol\r
- *tmpMsg << ( u8 )nType;\r
- *tmpMsg << ( u16 )(nval*100); //u32 in nc2.2\r
- *tmpMsg << ( u16 )targetObjectId;\r
-\r
-\r
- ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 );\r
+ *tmpMsg << ( uint8_t )0x13;\r
+ *tmpMsg << ( uint16_t )source->GetUDP_ID();\r
+ *tmpMsg << ( uint16_t )source->GetSessionID();\r
+ *tmpMsg << ( uint8_t )0x0e; // Message length\r
+ *tmpMsg << ( uint8_t )0x03;\r
+ *tmpMsg << ( uint16_t )source->GetUDP_ID();\r
+ *tmpMsg << ( uint8_t )0x1f;\r
+ *tmpMsg << ( uint16_t )source->GetLocalID();\r
+ *tmpMsg << ( uint8_t )0x25; // ??\r
+ *tmpMsg << ( uint8_t )0x06; // ??\r
+ *tmpMsg << ( uint8_t )0x01; // 1 effect\r
+ *tmpMsg << ( uint8_t )0x01; // effect on intox level ????\r
+ *tmpMsg << ( uint16_t )nDur;\r
+ *tmpMsg << ( uint16_t )(700+(targetObjectId % 100)); //item id Thyronol\r
+ *tmpMsg << ( uint8_t )nType;\r
+ *tmpMsg << ( uint16_t )(nval*100); //uint32_t in nc2.2\r
+ *tmpMsg << ( uint16_t )targetObjectId;\r
+\r
+\r
+ ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 );\r
snprintf( tmpStr, 127, "Sendind drug mod to stat %d, %s %d", targetObjectId, (nType == 1 ? "inc" : "dec"), nval );\r
textMsg = tmpStr;\r
\r
else if ( Arg1[0] == 'w' )\r
{\r
/*targetObjectId &= 0xffff;\r
- u16 val1 = 0;\r
+ uint16_t val1 = 0;\r
if ( ArgC >= 3 )\r
val1 = GetArgInt( 3 ) & 0xffff;\r
*/\r
\r
source->IncreaseUDP_ID();\r
\r
- *tmpMsg << ( u8 )0x13;\r
- *tmpMsg << ( u16 )source->GetUDP_ID();\r
- *tmpMsg << ( u16 )source->GetSessionID();\r
- *tmpMsg << ( u8 )0x0a; // Message length place;\r
- *tmpMsg << ( u8 )0x03;\r
- *tmpMsg << ( u16 )source->GetUDP_ID();\r
- *tmpMsg << ( u8 )0x23;\r
- *tmpMsg << ( u16 )0x0012; // cmd = ?\r
- *tmpMsg << ( u16 )0x0007;\r
- *tmpMsg << ( u32 )0x00000000;\r
+ *tmpMsg << ( uint8_t )0x13;\r
+ *tmpMsg << ( uint16_t )source->GetUDP_ID();\r
+ *tmpMsg << ( uint16_t )source->GetSessionID();\r
+ *tmpMsg << ( uint8_t )0x0a; // Message length place;\r
+ *tmpMsg << ( uint8_t )0x03;\r
+ *tmpMsg << ( uint16_t )source->GetUDP_ID();\r
+ *tmpMsg << ( uint8_t )0x23;\r
+ *tmpMsg << ( uint16_t )0x0012; // cmd = ?\r
+ *tmpMsg << ( uint16_t )0x0007;\r
+ *tmpMsg << ( uint32_t )0x00000000;\r
\r
- ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 );\r
+ ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 );\r
\r
snprintf( tmpStr, 127, "Sending w msg " );\r
textMsg = tmpStr;\r
}\r
else if ( Arg1[0] == 'x' )\r
{\r
- u8 val1 = targetObjectId &= 0xff;\r
+ uint8_t val1 = targetObjectId &= 0xff;\r
\r
tmpMsg = MsgBuilder->BuildUndefineduseMsg( source, val1 );\r
\r
}\r
}\r
\r
- u32 val1;\r
- u8 val2;\r
+ uint32_t val1;\r
+ uint8_t val2;\r
char tmpStr[128];\r
static PMessage* tmpMsg = NULL;\r
bool SetUDP_IDNeeded = true;\r
if(Arg1[0] != '\0' && Arg2[0] != '\0')\r
{\r
val1 = atoi(Arg1);\r
- val2 = (u8)(atoi(Arg2) & 0xff);\r
+ val2 = (uint8_t)(atoi(Arg2) & 0xff);\r
//tmpMsg->U8Data(16 + val1) = val2;\r
tmpMsg->U8Data(10 + val1) = val2;\r
snprintf(tmpStr, 127, "Data #%d set to value 0x%02x", val1, val2);\r
return;\r
\r
char tmpStr[128];\r
- u8 SubWay[] = {0x13, 0x71, 0x00, 0x9b, 0xde,\r
+ uint8_t SubWay[] = {0x13, 0x71, 0x00, 0x9b, 0xde,\r
//Subway 1 (fc 03)\r
0x11,\r
0x03, 0x6d, 0x00, 0x28, 0x27, 0x00, 0xfc, 0x03, 0x00, 0x00,\r
0x03, 0x71, 0x00, 0x2d, 0xf7, 0x03, 0x00, 0x00, 0x0a, 0x00,\r
0x00, 0x00, 0x00};\r
\r
- u8 SubWay2[] = {0x13, 0x71, 0x00, 0x9b, 0xde,\r
+ uint8_t SubWay2[] = {0x13, 0x71, 0x00, 0x9b, 0xde,\r
//Subway 7 (f6 03)\r
0x11,\r
0x03, 0x6d, 0x00, 0x28, 0x27, 0x00, 0xf6, 0x03, 0x00, 0x00,\r
//SubWay List\r
//Subway 1\r
source->IncreaseUDP_ID();\r
- *(u16*)&SubWay[7] = source->GetUDP_ID();\r
+ *(uint16_t*)&SubWay[7] = source->GetUDP_ID();\r
source->IncreaseUDP_ID();\r
- *(u16*)&SubWay[25] = source->GetUDP_ID();\r
+ *(uint16_t*)&SubWay[25] = source->GetUDP_ID();\r
\r
//Subway 2\r
source->IncreaseUDP_ID();\r
- *(u16*)&SubWay[39] = source->GetUDP_ID();\r
+ *(uint16_t*)&SubWay[39] = source->GetUDP_ID();\r
source->IncreaseUDP_ID();\r
- *(u16*)&SubWay[57] = source->GetUDP_ID();\r
+ *(uint16_t*)&SubWay[57] = source->GetUDP_ID();\r
\r
//Subway 3\r
source->IncreaseUDP_ID();\r
- *(u16*)&SubWay[71] = source->GetUDP_ID();\r
+ *(uint16_t*)&SubWay[71] = source->GetUDP_ID();\r
source->IncreaseUDP_ID();\r
- *(u16*)&SubWay[89] = source->GetUDP_ID();\r
+ *(uint16_t*)&SubWay[89] = source->GetUDP_ID();\r
\r
//Subway 4\r
source->IncreaseUDP_ID();\r
- *(u16*)&SubWay[103] = source->GetUDP_ID();\r
+ *(uint16_t*)&SubWay[103] = source->GetUDP_ID();\r
source->IncreaseUDP_ID();\r
- *(u16*)&SubWay[121] = source->GetUDP_ID();\r
+ *(uint16_t*)&SubWay[121] = source->GetUDP_ID();\r
\r
//Subway 5\r
source->IncreaseUDP_ID();\r
- *(u16*)&SubWay[135] = source->GetUDP_ID();\r
+ *(uint16_t*)&SubWay[135] = source->GetUDP_ID();\r
source->IncreaseUDP_ID();\r
- *(u16*)&SubWay[153] = source->GetUDP_ID();\r
+ *(uint16_t*)&SubWay[153] = source->GetUDP_ID();\r
\r
//Subway 6\r
source->IncreaseUDP_ID();\r
- *(u16*)&SubWay[167] = source->GetUDP_ID();\r
+ *(uint16_t*)&SubWay[167] = source->GetUDP_ID();\r
source->IncreaseUDP_ID();\r
- *(u16*)&SubWay[185] = source->GetUDP_ID();\r
+ *(uint16_t*)&SubWay[185] = source->GetUDP_ID();\r
\r
//Subway 7\r
source->IncreaseUDP_ID();\r
- *(u16*)&SubWay2[7] = source->GetUDP_ID();\r
+ *(uint16_t*)&SubWay2[7] = source->GetUDP_ID();\r
source->IncreaseUDP_ID();\r
- *(u16*)&SubWay2[25] = source->GetUDP_ID();\r
+ *(uint16_t*)&SubWay2[25] = source->GetUDP_ID();\r
\r
//Subway 8\r
source->IncreaseUDP_ID();\r
- *(u16*)&SubWay2[39] = source->GetUDP_ID();\r
+ *(uint16_t*)&SubWay2[39] = source->GetUDP_ID();\r
source->IncreaseUDP_ID();\r
- *(u16*)&SubWay2[57] = source->GetUDP_ID();\r
+ *(uint16_t*)&SubWay2[57] = source->GetUDP_ID();\r
\r
//Subway 9\r
source->IncreaseUDP_ID();\r
- *(u16*)&SubWay2[71] = source->GetUDP_ID();\r
+ *(uint16_t*)&SubWay2[71] = source->GetUDP_ID();\r
source->IncreaseUDP_ID();\r
- *(u16*)&SubWay2[89] = source->GetUDP_ID();\r
+ *(uint16_t*)&SubWay2[89] = source->GetUDP_ID();\r
\r
//Subway 10\r
source->IncreaseUDP_ID();\r
- *(u16*)&SubWay2[103] = source->GetUDP_ID();\r
+ *(uint16_t*)&SubWay2[103] = source->GetUDP_ID();\r
source->IncreaseUDP_ID();\r
- *(u16*)&SubWay2[121] = source->GetUDP_ID();\r
+ *(uint16_t*)&SubWay2[121] = source->GetUDP_ID();\r
\r
//Subway 11\r
source->IncreaseUDP_ID();\r
- *(u16*)&SubWay2[135] = source->GetUDP_ID();\r
+ *(uint16_t*)&SubWay2[135] = source->GetUDP_ID();\r
source->IncreaseUDP_ID();\r
- *(u16*)&SubWay2[153] = source->GetUDP_ID();\r
+ *(uint16_t*)&SubWay2[153] = source->GetUDP_ID();\r
\r
- *(u16*)&SubWay[1] = source->GetUDP_ID();\r
- *(u16*)&SubWay[3] = source->GetSessionID();\r
+ *(uint16_t*)&SubWay[1] = source->GetUDP_ID();\r
+ *(uint16_t*)&SubWay[3] = source->GetSessionID();\r
\r
PMessage* msg;\r
msg = new PMessage(197);\r
msg->Dump();\r
source->SendUDPMessage(msg);\r
\r
- *(u16*)&SubWay2[1] = source->GetUDP_ID();\r
- *(u16*)&SubWay2[3] = source->GetSessionID();\r
+ *(uint16_t*)&SubWay2[1] = source->GetUDP_ID();\r
+ *(uint16_t*)&SubWay2[3] = source->GetSessionID();\r
\r
msg = new PMessage(197);\r
msg->Write(SubWay2, sizeof(SubWay2));\r
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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)
{
}
else
{
- cashtodel = (u32)GetArgInt(1);
+ cashtodel = (uint32_t)GetArgInt(1);
}
if(cashtodel == 0)
return;
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);
}
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);
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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()
{
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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()
{
targetNPC = currentNPCWorld->GetNPC( GetArgInt(2) );\r
if(!targetNPC)\r
return;\r
- // @test 15 <npcID> <target_to_attack> <unknown u8 value>\r
- targetNPC->Attack(GetArgInt(3), (u8)GetArgInt(5), (u8)GetArgInt(4));\r
+ // @test 15 <npcID> <target_to_attack> <unknown uint8_t value>\r
+ targetNPC->Attack(GetArgInt(3), (uint8_t)GetArgInt(5), (uint8_t)GetArgInt(4));\r
}\r
}\r
else if (GetArgInt(1) == 2)\r
/*
- 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)
{
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);
return;
}
- u16 itemID;
+ uint16_t itemID;
char effStr[128];
PMessage* tmpMsg;
- itemID = (u16)GetArgInt(1);
+ itemID = (uint16_t)GetArgInt(1);
source->GetChar()->SetItemInHand(itemID);
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)
{
if(IsArgNumeric(1) == true)
{
- ItemToSpawn = (u16)GetArgInt(1);
+ ItemToSpawn = (uint16_t)GetArgInt(1);
if(ItemToSpawn == 0)
{
SyntaxError = true;
if(IsArgNumeric(2) == true)
{
- Quality = (u8)GetArgInt(2);
+ Quality = (uint8_t)GetArgInt(2);
if(Quality == 0)
{
SyntaxError = true;
if(IsArgNumeric(3) == true)
{
- Stack = (u8)GetArgInt(3);
+ Stack = (uint8_t)GetArgInt(3);
if(Stack == 0)
{
SyntaxError = true;
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;
--- /dev/null
+#include "GameServer/Includes.hxx"\r
+\r
+void PCommands::doCmdunban()\r
+{\r
+ Chat->send(source, CHAT_DIRECT, "System", "Unban is not yet possible, sorry.");\r
+}\r
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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()
{
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 )
{
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-#include "main.h"\r
+#include "GameServer/Includes.hxx"\r
\r
void PCommands::doCmdunshun()\r
{\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-#include "main.h"\r
+#include "GameServer/Includes.hxx"\r
\r
void PCommands::doCmduptime()\r
{\r
// get difference between var uptime and current time\r
- std::time_t Uptime = GameServer->GetStartTime();\r
- u32 TimeDiff = std::time(NULL) - Uptime;\r
- u32 UpYears = 0, UpMonths = 0, UpWeeks = 0, UpDays = 0, UpHours = 0, UpMinutes = 0, UpSeconds = 0;\r
+ time_t Uptime = GameServer->GetStartTime();\r
+ uint32_t TimeDiff = std::time(NULL) - Uptime;\r
+ uint32_t UpYears = 0, UpMonths = 0, UpWeeks = 0, UpDays = 0, UpHours = 0, UpMinutes = 0, UpSeconds = 0;\r
char tmpY[21], tmpM[21], tmpW[21], tmpD[21], tmpH[21], tmpMi[21], tmpS[21];\r
\r
// 1 min = 60 sec = 60\r
--- /dev/null
+#include "GameServer/Includes.hxx"\r
+\r
+void PCommands::doCmd_dev_v()\r
+{\r
+ if(IsAdmin() == false)\r
+ return;\r
+\r
+ char Arg1[30];\r
+\r
+ Arg1[0] = '\0';\r
+\r
+ if(ArgC > 0)\r
+ {\r
+ GetArgText(1, Arg1, 30);\r
+ }\r
+\r
+ char tmpStr[128];\r
+ int testmode = 1; // change here only for uint8_t/uint16_t/uint32_t testvalue use\r
+\r
+ if(Arg1[0] != '\0')\r
+ {\r
+ switch(testmode)\r
+ {\r
+ case 0: source->testval8 = (uint8_t)(atoi(Arg1) & 0xff); break;\r
+ case 1: source->testval16 = (uint16_t)(atoi(Arg1) & 0xffff); break;\r
+ case 2: source->testval32 = (uint32_t)(atoi(Arg1) & 0xffffffff); break;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ source->testval8 = 0;\r
+ source->testval16 = 0;\r
+ source->testval32 = 0;\r
+ }\r
+\r
+ switch(testmode)\r
+ {\r
+ case 0: snprintf(tmpStr, 127, "Test value uint8_t set to 0x%02x (%d)", source->testval8, source->testval8); break;\r
+ case 1: snprintf(tmpStr, 127, "Test value uint16_t set to 0x%04x (%d)", source->testval16, source->testval16); break;\r
+ case 2: snprintf(tmpStr, 127, "Test value uint32_t set to 0x%08x (%d)", source->testval32, source->testval32); break;\r
+ default: tmpStr[0] = '\0';\r
+ }\r
+ tmpStr[127] = '\0';\r
+ Chat->send(source, CHAT_DIRECT, "System", tmpStr);\r
+\r
+}\r
--- /dev/null
+#include "GameServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
+\r
+void PCommands::doCmdversion()\r
+{\r
+ char tmpChatMsg[300];\r
+ snprintf(tmpChatMsg, 299, "You are on TinNS server %s runnig version %s - SVN Rev. %s", Config->GetOption("server_name").c_str(), ServerVersion, SVNRevision);\r
+ tmpChatMsg[299] = '\0';\r
+\r
+ Chat->send(source, CHAT_DIRECT, "System", tmpChatMsg);\r
+}\r
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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()
{
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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()
{
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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()
{
else
target = source;
- PMessage* tmpMsg = MsgBuilder->BuildWeatherControlMsg(( u16 )wId );
+ PMessage* tmpMsg = MsgBuilder->BuildWeatherControlMsg(( uint16_t )wId );
ClientManager->UDPBroadcast( tmpMsg, target );
char effStr[128];
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-#include "main.h"\r
+#include "GameServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
+#if 0\r
PGameScript::PGameScript()\r
{\r
}\r
\r
PGameScript::~PGameScript()\r
{\r
- for(HookMap::iterator it = mHooks.begin(); it != mHooks.end(); it++)\r
- delete it->second;\r
+ for(HookMap::iterator it = mHooks.begin(); it != mHooks.end(); it++)\r
+ delete it->second;\r
}\r
\r
bool PGameScript::LoadScripts()\r
bool PGameScript::Rehash()\r
{\r
Console->LPrint("Rehashing GameMonkey Scripts...");\r
- for(HookMap::iterator it = mHooks.end(); it != mHooks.begin(); it--)\r
+ for(HookMap::iterator it = mHooks.end(); it != mHooks.begin(); it--)\r
mHooks.erase(it);\r
\r
if(LoadScripts() == true)\r
}\r
\r
\r
-bool ScriptSys::ExecuteFile(const char* a_fileName)\r
+bool PGameScript::ExecuteFile(const char* a_fileName)\r
{\r
FILE* scriptFile = NULL;\r
char* fileString = NULL;\r
}\r
\r
return resultInt;\r
-}
\ No newline at end of file
+}\r
+#endif\r
--- /dev/null
+#pragma once\r
+\r
+#if 0\r
+#include <map>\r
+#include <string>\r
+\r
+enum PHookTypes {\r
+ HOOK_CHAT,\r
+ HOOK_TRADE,\r
+ HOOK_ZONE\r
+};\r
+\r
+class PGameScript {\r
+private:\r
+ typedef std::map<PHookTypes, std::string> HookMap;\r
+ HookMap mHooks;\r
+\r
+public:\r
+ PGameScript();\r
+ ~PGameScript();\r
+\r
+ bool LoadScripts();\r
+ bool Rehash();\r
+ void TriggerHook(PHookTypes hook);\r
+ bool ExecuteFile(const char* a_fileName);\r
+};\r
+#endif\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- gameserver.cpp - main file of the gameserver\r
-\r
- MODIFIED: 31 Aug 2005 Akiko\r
- REASON: - added modifications by "Sting" to get a running gameserver again\r
- - added this header\r
- MODIFIED: 28 Sep 2005 Akiko\r
- REASON: - define for game server port\r
- MODIFIED: 29 Sep 2005 Sting (modified by Akiko)\r
- REASON: - configurable UDP port for testing\r
- - tidied up/corrected packet sent with most character stats (character now has monk stats for testing)\r
- MODIFIED: 27 Nov 2005 Akiko\r
- REASON: - added Namikons fix (IPStringToDWord)\r
- - added bluehrs packet fix\r
- MODIFIED: 17 Dec 2005 bakkdoor\r
- REASON: - Due the new structure for chatsystem, changed HandleGameChat(Client, Packet);\r
- to Chat->HandleGameChat(Client, Packet);\r
- - Also added ClientManager->addClientToList and ClientManager->deleteClientFromList()\r
- (check Update() & FinalizeClient())\r
- MODIFIED: 18 Dec 2005 Namikon\r
- REASON: - Fixed several small issues in the main-packet if-clause (sizeof(<char>), etc)\r
- MODIFIED: 21 Dec 2005 Namikon\r
- REASON: - Fixed zoning (for now). The basic packet is broken somehow, still working on that\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Basepacket 1 and 2 fixed. (Thanks to MaxxJag!)\r
- - Zoning still works, same goes for skills/factions.\r
- - Not sure about quickbelt and inventory, but it seems to be ok\r
- MODIFIED: 26 Dec 2005 Namikon\r
- REASON: - Added doors\r
- - Added support for Worlditem usage (Gogo/Genrep/Appitem/...)\r
- MODIFIED: 01 Jan 2006 Namikon\r
- REASON: - Changed FmtTxt() to sprintf(). It does... uhm, the same :D\r
- - Added SetOnlineStatus to do instand updates when char is logging in\r
- MODIFIED: 02 Jan 2006 Namikon\r
- REASON: - Added debug output function\r
- MODIFIED: 06 Jan 2006 Namikon\r
- REASON: - Added color to console outputs\r
- MODIFIED: 01 Jul 2006 hammag\r
- REASON: - added set timeout to 10 msec (for ReadSetTCP select) in Start() to avoid useless 100% CPU use\r
- MODIFIED: 30 Jul 2006 hammag\r
- REASON: - Fixed 0x13 0x03 0x1F message filters to enable other char than ID 1 to play ... :P\r
- MODIFIED: 12 Aug 2006 hammag\r
- REASON: - Fixed BuildCharPosUpdateMsg() to send correct characters orientation to other characters\r
- MODIFIED: 26 Aug 2006 hammag\r
- REASON: - removed use of GAME_PORT define as this info is available in Config object with a default value\r
- MODIFIED: 17 Sep 2006 hammag\r
- REASON: - Moved all UDP message management code to decoder classes\r
- - Removed corresponding code from gameserver.cpp & .h\r
- MODIFIED: 03 Oct 2006 hammag\r
- REASON: - Added some more DB cleanup when a char is deleted (still incomplete and will later be done in PChar::SQLDelete() )\r
- MODIFIED: 10 Dec 2006 Namikon\r
- REASON: - Added new variable "mServerStartupTime". Holds the unix timestamp uppon startup. Required for @uptime\r
- and other time-based stuff\r
- MODIFIED: 09 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
- - clean ups\r
-\r
- TODO:\r
- - Deny login if char is already online (More information about the login procedure is necessary to do that)\r
- - Take main loop timeout setting from config file\r
- - Add Regex control to new char name validation\r
- - Add Check of Char offline (and unloaded) before deleting (from the char choosing i/f) if multiple login\r
- allowed for the same account\r
- - Check if adding to Client to Client manager shouldn't be done only one UDP connection done ?\r
- => Risk of sending UDP chat on non-socket ????\r
-*/\r
-\r
-\r
-#include "main.h"\r
-\r
-#include "include/msgdecoder.h"\r
-#include "include/msgbuilder.h"\r
-#include "include/appartements.h"\r
-\r
+#include <cstring>\r
+#include "GameServer/Includes.hxx"\r
+#include "GameServer/Decoder/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
+\r
+// TODO:\r
+// - Deny login if char is already online (More information about the login procedure is necessary to do that)\r
+// - Take main loop timeout setting from config file\r
+// - Add Regex control to new char name validation\r
+// - Add Check of Char offline (and unloaded) before deleting (from the char choosing i/f) if multiple login\r
+// allowed for the same account\r
+// - Check if adding to Client to Client manager shouldn't be done only one UDP connection done ?\r
+// => Risk of sending UDP chat on non-socket ????\r
\r
PGameServer::PGameServer()\r
{\r
\r
void PGameServer::Start()\r
{\r
- u16 Port = Config->GetOptionInt( "gameserver_port" );\r
+ uint16_t Port = Config->GetOptionInt( "gameserver_port" );\r
Console->LPrint( "Starting gameserver on port %i...", Port );\r
\r
if ( ServerSock->open( Port ) )\r
struct timespec tmpTime;\r
if ( !clock_gettime( CLOCK_REALTIME, &tmpTime ) )\r
{\r
- srandom(( u32 )tmpTime.tv_sec );\r
+ srandom(( uint32_t )tmpTime.tv_sec );\r
InitRandom( tmpTime.tv_sec );\r
//Console->Print("Initializing random generator. First value is %d", random());\r
}\r
\r
}\r
\r
-void PGameServer::SetGameTime( u32 newtime )\r
+void PGameServer::SetGameTime( uint32_t newtime )\r
{\r
if ( clock_gettime( CLOCK_REALTIME, &mStartTime ) )\r
{\r
mBaseGameTime = newtime;\r
}\r
\r
-u32 PGameServer::GetGameTime()\r
+uint32_t PGameServer::GetGameTime()\r
{\r
- //const u32 TimeFactor = 375;\r
- const u32 TimeFactor = 1000;\r
- const u32 nsTimeFactor = 1000000000 / TimeFactor;\r
+ //const uint32_t TimeFactor = 375;\r
+ const uint32_t TimeFactor = 1000;\r
+ const uint32_t nsTimeFactor = 1000000000 / TimeFactor;\r
\r
struct timespec tmpTime;\r
\r
}\r
}\r
\r
-bool PGameServer::HandleHandshake( PGameState *State, const u8 *Packet, int PacketSize )\r
+bool PGameServer::HandleHandshake( PGameState *State, const uint8_t *Packet, int PacketSize )\r
{\r
- //static const u8 HANDSHAKE1A[6]={0xfe, 0x03, 0x00, 0x80, 0x03, 0x68};\r
+ //static const uint8_t HANDSHAKE1A[6]={0xfe, 0x03, 0x00, 0x80, 0x03, 0x68};\r
//PGameSocket *Socket = Client->GetGameSocket();\r
\r
switch ( State->TCP.mState )\r
{\r
case PGameState::TCP::GS_HANDSHAKE0 :\r
{\r
- if ( PacketSize == 6 && *( u16* )&Packet[3] == 0x0080 && Packet[5] == 0x78 )\r
+ if ( PacketSize == 6 && *( uint16_t* )&Packet[3] == 0x0080 && Packet[5] == 0x78 )\r
{\r
//FIXME: this packet seems to be unnecessary,\r
// although it appears in traffic dumps\r
}\r
else\r
{\r
- Console->Print( YELLOW, BLACK, "[Notice] Gameserver protocol error (GS_HANDSHAKE0): invalid packet [%04x]", *( u16* )&Packet[3] );\r
+ Console->Print( YELLOW, BLACK, "[Notice] Gameserver protocol error (GS_HANDSHAKE0): invalid packet [%04x]", *( uint16_t* )&Packet[3] );\r
return ( false );\r
}\r
\r
return true;\r
}\r
\r
-bool PGameServer::HandleAuthenticate( PClient *Client, PGameState *State, const u8 *Packet, int PacketSize )\r
+bool PGameServer::HandleAuthenticate( PClient *Client, PGameState *State, const uint8_t *Packet, int PacketSize )\r
{\r
ConnectionTCP *Socket = Client->getTCPConn();\r
\r
- if ( PacketSize > 20 && *( u16* )&Packet[3] == 0x8084 )\r
+ if ( PacketSize > 20 && *( uint16_t* )&Packet[3] == 0x8084 )\r
{\r
// authentication method #1\r
- const u8 *Key = &Packet[5]; // password key\r
- u16 ULen = *( u16* ) & Packet[16]; // username length\r
- u16 PLen = *( u16* ) & Packet[18]; // password length\r
+ const uint8_t *Key = &Packet[5]; // password key\r
+ uint16_t ULen = *( uint16_t* ) & Packet[16]; // username length\r
+ uint16_t PLen = *( uint16_t* ) & Packet[18]; // password length\r
char *UserName = ( char* ) & Packet[20]; // account name\r
- const u8 *PW = &Packet[20+ULen]; // encoded password\r
+ const uint8_t *PW = &Packet[20+ULen]; // encoded password\r
\r
// Safety controls\r
if ( 15 + ULen + PLen > PacketSize )\r
if ( Failed )\r
{\r
// TODO: is this packet correct here?\r
- u8 AUTHFAILED[15] = {0xfe, 0x0c, 0x00, 0x83, 0x86, 0x05, 0x00, 0x06, 0x00, 'E', 'R',\r
+ uint8_t AUTHFAILED[15] = {0xfe, 0x0c, 0x00, 0x83, 0x86, 0x05, 0x00, 0x06, 0x00, 'E', 'R',\r
'R', 'O', 'R', 0\r
};\r
// TODO: send actual reason instead of ERROR\r
else\r
{\r
Client->LoggedIn( &Account );\r
- u8 AUTHOK[28] = {0xfe, 0x19, 0x00, 0x83, 0x81, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,\r
+ uint8_t AUTHOK[28] = {0xfe, 0x19, 0x00, 0x83, 0x81, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,\r
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
0x00, 0x00, 0x00, 0x00, 0x00, 0x00\r
};\r
- *( u32* )&AUTHOK[5] = Account.GetID();\r
+ *( uint32_t* )&AUTHOK[5] = Account.GetID();\r
Socket->write( AUTHOK, 28 );\r
State->TCP.mState = PGameState::TCP::GS_GAMEDATA;\r
Console->Print( GREEN, BLACK, "[Info] Gameserver: User '%s' logged in", UserName );\r
}\r
}\r
- else if ( PacketSize > 29 && *( u16* )&Packet[3] == 0x0183 )\r
+ else if ( PacketSize > 29 && *( uint16_t* )&Packet[3] == 0x0183 )\r
{\r
// authentication method #2, sent when game starts\r
- const u8 *Key = &Packet[13]; // password key\r
- u16 PLen = *( u16* ) & Packet[25]; // password length\r
- u16 ULen = *( u16* ) & Packet[27]; // username length\r
+ const uint8_t *Key = &Packet[13]; // password key\r
+ uint16_t PLen = *( uint16_t* ) & Packet[25]; // password length\r
+ uint16_t ULen = *( uint16_t* ) & Packet[27]; // username length\r
char *UserName = ( char* ) & Packet[29]; // account name\r
- const u8 *PW = &Packet[29+ULen]; // encoded password\r
+ const uint8_t *PW = &Packet[29+ULen]; // encoded password\r
\r
// Safety controls\r
if ( 24 + ULen + PLen > PacketSize )\r
\r
if ( !Failed )\r
{\r
- int value = *( u32* ) & Packet[21];//i think here we must read u32 instead of u8\r
- u32 CharID = Account.GetCharIdBySlot( value );\r
+ int value = *( uint32_t* ) & Packet[21];//i think here we must read uint32_t instead of uint8_t\r
+ uint32_t CharID = Account.GetCharIdBySlot( value );\r
\r
if ( Chars->LoadChar( CharID ) )\r
{\r
else\r
{\r
Client->LoggedIn( &Account );\r
- /*u8 AUTHOK[28]={0xfe, 0x19, 0x00, 0x83, 0x81, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,\r
+ /*uint8_t AUTHOK[28]={0xfe, 0x19, 0x00, 0x83, 0x81, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,\r
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
0x00, 0x00, 0x00, 0x00, 0x00, 0x00};\r
- *(u32*)&AUTHOK[5]=Account->GetID();\r
+ *(uint32_t*)&AUTHOK[5]=Account->GetID();\r
Socket->Write(AUTHOK, 28);*/\r
- //Client->SetRemoteUDPAddr(*(u32*)&Packet[5], *(u16*)&Packet[9]);\r
+ //Client->SetRemoteUDPAddr(*(uint32_t*)&Packet[5], *(uint16_t*)&Packet[9]);\r
State->TCP.mState = PGameState::TCP::GS_GETSTATUS;\r
- Console->Print( "Gameserver: User '%s' entered game (%08x:%04x)", UserName, *( u32* )&Packet[5], *( u16* )&Packet[9] );\r
+ Console->Print( "Gameserver: User '%s' entered game (%08x:%04x)", UserName, *( uint32_t* )&Packet[5], *( uint16_t* )&Packet[9] );\r
Client->SetRemoteUDPPort( *( int* )&Packet[9] );\r
}\r
}\r
else\r
{\r
- Console->Print( RED, BLACK, "[Notice] Gameserver protocol error (GS_AUTHENTICATE): invalid packet [%04x]", *( u16* )&Packet[3] );\r
+ Console->Print( RED, BLACK, "[Notice] Gameserver protocol error (GS_AUTHENTICATE): invalid packet [%04x]", *( uint16_t* )&Packet[3] );\r
return ( false );\r
}\r
\r
return ( true );\r
}\r
\r
-bool PGameServer::HandleGameData( PClient *Client, PGameState *State, const u8 *Packet )\r
+bool PGameServer::HandleGameData( PClient *Client, PGameState *State, const uint8_t *Packet )\r
{\r
- static const u8 GAMEDATA[5] = {0xfe, 0x02, 0x00, 0x87, 0x3a};\r
+ static const uint8_t GAMEDATA[5] = {0xfe, 0x02, 0x00, 0x87, 0x3a};\r
ConnectionTCP *Socket = Client->getTCPConn();\r
\r
- if ( *( u16* )&Packet[3] == 0x3787 )\r
+ if ( *( uint16_t* )&Packet[3] == 0x3787 )\r
{\r
Socket->write( GAMEDATA, 5 );\r
State->TCP.mState = PGameState::TCP::GS_REQUESTCHARS;\r
}\r
else\r
{\r
- Console->Print( RED, BLACK, "[Notice] Gameserver protocol error (GS_GAMEDATA): invalid packet [%04x]", *( u16* )&Packet[3] );\r
+ Console->Print( RED, BLACK, "[Notice] Gameserver protocol error (GS_GAMEDATA): invalid packet [%04x]", *( uint16_t* )&Packet[3] );\r
return ( false );\r
}\r
\r
return ( true );\r
}\r
\r
-bool PGameServer::HandleRequestChars( PClient *Client, PGameState *State, const u8 *Packet )\r
+bool PGameServer::HandleRequestChars( PClient *Client, PGameState *State, const uint8_t *Packet )\r
{\r
PAccount Account( Client->GetAccountID() );\r
\r
\r
struct PCharList\r
{\r
- u16 Unknown1;\r
- u16 NumSlots;\r
- u16 Unknown2;\r
+ uint16_t Unknown1;\r
+ uint16_t NumSlots;\r
+ uint16_t Unknown2;\r
} CharList;\r
\r
PCharProfile CharEntry[MAX_CHARS_PER_ACCOUNT];\r
\r
const int CHARBASESIZE = 28;\r
\r
- if ( *( u16* )&Packet[3] == 0x8284 )\r
+ if ( *( uint16_t* )&Packet[3] == 0x8284 )\r
{\r
CharList.NumSlots = MAX_CHARS_PER_ACCOUNT;\r
int NameLengths = 0;\r
}\r
}\r
\r
- u8 PacketHeader[5] = {0xfe, 0x00, 0x00, 0x83, 0x85};\r
- *( u16* )&PacketHeader[1] = sizeof( u16 ) * 3 + ( MAX_CHARS_PER_ACCOUNT * CHARBASESIZE ) + NameLengths + 2;\r
+ uint8_t PacketHeader[5] = {0xfe, 0x00, 0x00, 0x83, 0x85};\r
+ *( uint16_t* )&PacketHeader[1] = sizeof( uint16_t ) * 3 + ( MAX_CHARS_PER_ACCOUNT * CHARBASESIZE ) + NameLengths + 2;\r
Socket->write( PacketHeader, 5 );\r
\r
CharList.Unknown1 = 0x0000;\r
if ( CharEntry[i].Name.length() > 0 )\r
{\r
Socket->write( CharEntry[i].Name.c_str() );\r
- Socket->write(( u8 )0 );\r
+ Socket->write(( uint8_t )0 );\r
}\r
}\r
\r
}\r
else\r
{\r
- Console->Print( RED, BLACK, "Gameserver protocol error (GS_REQUESTCHARS): invalid packet [%04x]", *( u16* )&Packet[3] );\r
+ Console->Print( RED, BLACK, "Gameserver protocol error (GS_REQUESTCHARS): invalid packet [%04x]", *( uint16_t* )&Packet[3] );\r
return ( false );\r
}\r
\r
return ( true );\r
}\r
\r
-bool PGameServer::HandleCharList( PClient *Client, PGameState *State, const u8 *Packet, int PacketSize )\r
+bool PGameServer::HandleCharList( PClient *Client, PGameState *State, const uint8_t *Packet, int PacketSize )\r
{\r
- static u8 Answer[10] = {0xfe, 0x07, 0x00, 0x83, 0x86, 0, 0, 0, 0, 0};\r
+ static uint8_t Answer[10] = {0xfe, 0x07, 0x00, 0x83, 0x86, 0, 0, 0, 0, 0};\r
ConnectionTCP *Socket = Client->getTCPConn();\r
\r
- if ( PacketSize > 9 && *( u16* )&Packet[3] == 0x8284 )\r
+ if ( PacketSize > 9 && *( uint16_t* )&Packet[3] == 0x8284 )\r
{\r
- u8 Mode = Packet[9];\r
+ uint8_t Mode = Packet[9];\r
\r
switch ( Mode )\r
{\r
case 3: // delete char\r
{\r
PAccount Acc( Client->GetAccountID() );\r
- u8 Num = Packet[PacketSize-1];\r
+ uint8_t Num = Packet[PacketSize-1];\r
\r
if ( Acc.GetID() )\r
{\r
- u32 CharID = Acc.GetCharIdBySlot( Num );\r
+ uint32_t CharID = Acc.GetCharIdBySlot( Num );\r
\r
// Also check that char is out of game\r
if (( CharID != 0 ) && ( Chars->GetChar( CharID ) == NULL ) )\r
if ( PacketSize < 64 )\r
return ( false );\r
\r
- u32 Slot = * ( u32* ) & Packet[30];\r
- //u32 nClass =* (u32*)&Packet[34]; // Not used - indirectly redundant with Profession\r
- u32 Profession = * ( u32* ) & Packet[38];\r
- u32 Gender = * ( u32* ) & Packet[42];\r
- u32 Head = * ( u32* ) & Packet[46];\r
- u32 Torso = * ( u32* ) & Packet[50];\r
- u32 Legs = * ( u32* ) & Packet[54];\r
- u32 Faction = * ( u32* ) & Packet[58];\r
- u8 NameLen = Packet[62];\r
- u8 NZSNb = Packet[63];\r
+ uint32_t Slot = * ( uint32_t* ) & Packet[30];\r
+ //uint32_t nClass =* (uint32_t*)&Packet[34]; // Not used - indirectly redundant with Profession\r
+ uint32_t Profession = * ( uint32_t* ) & Packet[38];\r
+ uint32_t Gender = * ( uint32_t* ) & Packet[42];\r
+ uint32_t Head = * ( uint32_t* ) & Packet[46];\r
+ uint32_t Torso = * ( uint32_t* ) & Packet[50];\r
+ uint32_t Legs = * ( uint32_t* ) & Packet[54];\r
+ uint32_t Faction = * ( uint32_t* ) & Packet[58];\r
+ uint8_t NameLen = Packet[62];\r
+ uint8_t NZSNb = Packet[63];\r
\r
char TempName[256];\r
std::strncpy( TempName, ( const char* )&Packet[64], NameLen );\r
}\r
else\r
{\r
- Console->Print( RED, BLACK, "[Notice] Gameserver protocol error (GS_CHARLIST): invalid packet [%04x]", *( u16* )&Packet[3] );\r
+ Console->Print( RED, BLACK, "[Notice] Gameserver protocol error (GS_CHARLIST): invalid packet [%04x]", *( uint16_t* )&Packet[3] );\r
\r
return ( false );\r
}\r
return true;\r
}\r
\r
-bool PGameServer::HandleGetStatus( PClient *Client, PGameState *State, const u8 *Packet )\r
+bool PGameServer::HandleGetStatus( PClient *Client, PGameState *State, const uint8_t *Packet )\r
{\r
ConnectionTCP *Socket = Client->getTCPConn();\r
\r
- if ( *( u16* )&Packet[3] == 0x3787 )\r
+ if ( *( uint16_t* )&Packet[3] == 0x3787 )\r
{\r
- static const u8 STATUS[9] = {0xfe, 0x06, 0x00, 0x87, 0x3a, 0x11, 0x00, 0x00, 0x00};\r
+ static const uint8_t STATUS[9] = {0xfe, 0x06, 0x00, 0x87, 0x3a, 0x11, 0x00, 0x00, 0x00};\r
\r
Socket->write( STATUS, 9 );\r
State->TCP.mState = PGameState::TCP::GS_GAMEINFO;\r
}\r
else\r
{\r
- Console->Print( RED, BLACK, "[Notice] Gameserver protocol error (GS_GETSTATUS): invalid packet [%04x]", *( u16* )&Packet[3] );\r
+ Console->Print( RED, BLACK, "[Notice] Gameserver protocol error (GS_GETSTATUS): invalid packet [%04x]", *( uint16_t* )&Packet[3] );\r
\r
return ( false );\r
}\r
return ( true );\r
}\r
\r
-bool PGameServer::HandleGameInfo( PClient *Client, PGameState *State, const u8 *Packet )\r
+bool PGameServer::HandleGameInfo( PClient *Client, PGameState *State, const uint8_t *Packet )\r
{\r
// Console->Print("Inside HandleGameInfo");//NEW added\r
\r
- static u8 GameInfo[31] = {0xfe, 0x1c, 0x00, 0x83, 0x05, // header\r
+ static uint8_t GameInfo[31] = {0xfe, 0x1c, 0x00, 0x83, 0x05, // header\r
0x00, 0x00, 0x00, 0x00, // account id\r
0x00, 0x00, 0x00, 0x00, // char id\r
0x00, 0x00, 0x00, 0x00, // udp ip\r
\r
ConnectionTCP *Socket = Client->getTCPConn();\r
\r
- if ( *( u16* )&Packet[3] == 0x3c87 )\r
+ if ( *( uint16_t* )&Packet[3] == 0x3c87 )\r
{\r
//int PortFix = Config->GetOptionInt("debug_mode");\r
\r
ClientDisconnected( Client );\r
}\r
\r
- u16 Port = Client->getUDPConn()->getPort();\r
+ uint16_t Port = Client->getUDPConn()->getPort();\r
\r
if ( Port == 0 )\r
Console->Print( RED, BLACK, "Client->OpenUDP() failed" );\r
Console->Print(YELLOW, BLACK, "UDP Port set to non-standard for debugging!");\r
}; */\r
\r
- u32 IP;\r
+ uint32_t IP;\r
std::string IPServerString;\r
// use [server_nat_ip] for server if client is NOT on [no_nat_net] (and [no_nat_net]!=0)\r
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() ) ) )\r
if ( IP == 0 )\r
IP = 0x0100007f;\r
//Console->Print("IP-2 %d", IP);\r
- *( u32* )&GameInfo[13] = IP;\r
- *( u16* )&GameInfo[17] = Port;\r
+ *( uint32_t* )&GameInfo[13] = IP;\r
+ *( uint16_t* )&GameInfo[17] = Port;\r
Console->Print( GREEN, BLACK, "[Info] Using UDP %s:%d on server", IPServerString.c_str(), Port );\r
\r
- *( u32* )&GameInfo[5] = Client->GetAccountID();\r
- *( u32* )&GameInfo[9] = Client->GetCharID();\r
+ *( uint32_t* )&GameInfo[5] = Client->GetAccountID();\r
+ *( uint32_t* )&GameInfo[9] = Client->GetCharID();\r
Console->Print( GREEN, BLACK, "[Info] Serving char id :%d", Client->GetCharID() );\r
\r
Socket->write( GameInfo, 31 );\r
Socket->flushSendBuffer();\r
\r
- static const u8 READY[7] = {0xfe, 0x04, 0x00, 0x83, 0x0d, 0x00, 0x00};\r
+ static const uint8_t READY[7] = {0xfe, 0x04, 0x00, 0x83, 0x0d, 0x00, 0x00};\r
Socket->write( READY, 7 );\r
\r
State->TCP.mState = PGameState::TCP::GS_INGAME;\r
}\r
else\r
{\r
- Console->Print( RED, BLACK, "[Notice] Gameserver protocol error (GS_GAMEINFO): invalid packet [%04x]", *( u16* )&Packet[3] );\r
+ Console->Print( RED, BLACK, "[Notice] Gameserver protocol error (GS_GAMEINFO): invalid packet [%04x]", *( uint16_t* )&Packet[3] );\r
return ( false );\r
}\r
\r
\r
bool PGameServer::ProcessClient( PClient *Client, PGameState *State )\r
{\r
- static const u8 HANDSHAKE0A[6] = {0xfe, 0x03, 0x00, 0x80, 0x01, 0x66};\r
+ static const uint8_t HANDSHAKE0A[6] = {0xfe, 0x03, 0x00, 0x80, 0x01, 0x66};\r
\r
if ( !State )\r
{\r
else\r
{\r
int PacketSize = 0;\r
- const u8 *Packet = Socket->read( &PacketSize );\r
+ const uint8_t *Packet = Socket->read( &PacketSize );\r
\r
if ( PacketSize > 0 )\r
{\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
+#pragma once\r
\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- gameserver.h\r
-\r
- Authors:\r
- - v00d00\r
- - Akiko\r
-\r
- MODIFIED: 30 Nov 2005 Akiko\r
- REASON: - added GPL\r
-*/\r
-\r
-#ifndef GAMESERVER_H\r
-#define GAMESERVER_H\r
+#include <chrono>\r
+#include <cstdint>\r
+#include <map>\r
\r
struct PGameState\r
{\r
} mState;\r
\r
bool mSynced;\r
- u16 mServerPacketNum;\r
- u16 mSequence;\r
- //u16 mClientPacketNum;\r
+ uint16_t mServerPacketNum;\r
+ uint16_t mSequence;\r
+ //uint16_t mClientPacketNum;\r
} UDP;\r
\r
PGameState()\r
class PGameServer\r
{\r
private :\r
- std::time_t mServerStartupTime;\r
+ time_t mServerStartupTime;\r
int mNumClients;\r
- u32 mBaseGameTime;\r
+ uint32_t mBaseGameTime;\r
struct timespec mStartTime;\r
\r
typedef std::map<PClient*, struct PGameState*> GameStateMap;\r
void FinalizeClient( PClient *Client, PGameState *State );\r
void FinalizeClientDelayed( PClient *Client, PGameState *State );\r
\r
-// bool HandleHandshake(PClient *Client, PGameState *State, const u8 *Packet, int PacketSize);\r
- bool HandleHandshake( PGameState *State, const u8 *Packet, int PacketSize );\r
+// bool HandleHandshake(PClient *Client, PGameState *State, const uint8_t *Packet, int PacketSize);\r
+ bool HandleHandshake( PGameState *State, const uint8_t *Packet, int PacketSize );\r
\r
- bool HandleAuthenticate( PClient *Client, PGameState *State, const u8 *Packet, int PacketSize );\r
-// bool HandleGameData(PClient *Client, PGameState *State, const u8 *Packet, int PacketSize);\r
- bool HandleGameData( PClient *Client, PGameState *State, const u8 *Packet );\r
+ bool HandleAuthenticate( PClient *Client, PGameState *State, const uint8_t *Packet, int PacketSize );\r
+// bool HandleGameData(PClient *Client, PGameState *State, const uint8_t *Packet, int PacketSize);\r
+ bool HandleGameData( PClient *Client, PGameState *State, const uint8_t *Packet );\r
\r
-// bool HandleRequestChars(PClient *Client, PGameState *State, const u8 *Packet, int PacketSize);\r
- bool HandleRequestChars( PClient *Client, PGameState *State, const u8 *Packet );\r
+// bool HandleRequestChars(PClient *Client, PGameState *State, const uint8_t *Packet, int PacketSize);\r
+ bool HandleRequestChars( PClient *Client, PGameState *State, const uint8_t *Packet );\r
\r
- bool HandleCharList( PClient *Client, PGameState *State, const u8 *Packet, int PacketSize );\r
-// bool HandleGetStatus(PClient *Client, PGameState *State, const u8 *Packet, int PacketSize);\r
- bool HandleGetStatus( PClient *Client, PGameState *State, const u8 *Packet );\r
+ bool HandleCharList( PClient *Client, PGameState *State, const uint8_t *Packet, int PacketSize );\r
+// bool HandleGetStatus(PClient *Client, PGameState *State, const uint8_t *Packet, int PacketSize);\r
+ bool HandleGetStatus( PClient *Client, PGameState *State, const uint8_t *Packet );\r
\r
-// bool HandleGameInfo(PClient *Client, PGameState *State, const u8 *Packet, int PacketSize);\r
- bool HandleGameInfo( PClient *Client, PGameState *State, const u8 *Packet );\r
+// bool HandleGameInfo(PClient *Client, PGameState *State, const uint8_t *Packet, int PacketSize);\r
+ bool HandleGameInfo( PClient *Client, PGameState *State, const uint8_t *Packet );\r
\r
bool HandleGame( PClient *Client, PGameState *State );\r
\r
void Update();\r
void ClientDisconnected( PClient *Client );\r
void UDPStreamClosed( PClient *Client );\r
- void SetGameTime( u32 newtime );\r
- u32 GetGameTime();\r
+ void SetGameTime( uint32_t newtime );\r
+ uint32_t GetGameTime();\r
\r
- inline std::time_t GetStartTime() const { return mServerStartupTime; };\r
+ inline time_t GetStartTime() const { return mServerStartupTime; };\r
\r
PGameState* GetClientState( PClient* nClient );\r
};\r
-\r
-#endif\r
-\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
+#include <cstring>\r
+#include "GameServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- genreplist.cpp - classe for character genrep list\r
-\r
- MODIFIED: 20 Sep 2006 Hammag\r
- REASON: - creation\r
- MODIFIED: 09 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
- - clean ups\r
-*/\r
-\r
-#include "main.h"\r
-\r
-#include "include/genreplist.h"\r
-\r
-PGenrepList::PGenrepList(u32 nOwnerCharID)\r
+PGenrepList::PGenrepList(uint32_t nOwnerCharID)\r
{\r
mOwnerCharID = nOwnerCharID;\r
mListMaxSize = mListSize = 0;\r
delete[] mGenrepList;\r
}\r
\r
-bool PGenrepList::AddGenrep(u16 nWorldID, u16 nStationID)\r
+bool PGenrepList::AddGenrep(uint16_t nWorldID, uint16_t nStationID)\r
{\r
char query[256];\r
\r
return false;\r
}\r
\r
-/*bool PGenrepList::RemoveChar(u32 nBuddyCharID)\r
+/*bool PGenrepList::RemoveChar(uint32_t nBuddyCharID)\r
{\r
char query[256];\r
- u8 rEntry, i;\r
+ uint8_t rEntry, i;\r
\r
if ((rEntry = FindEntry(nBuddyCharID)) < mListSize)\r
{\r
char query[256];\r
MYSQL_RES *result;\r
MYSQL_ROW row;\r
- u8 EntriesNum;\r
+ uint8_t EntriesNum;\r
\r
snprintf(query, 256, "SELECT * FROM genrep WHERE (g_charid='%u')", mOwnerCharID);\r
result = MySQL->GameResQuery(query);\r
return true;\r
}\r
\r
-void PGenrepList::IncreaseMaxSize(u8 nNewMax)\r
+void PGenrepList::IncreaseMaxSize(uint8_t nNewMax)\r
{\r
- u16 tmpSize;\r
+ uint16_t tmpSize;\r
\r
if (!nNewMax)\r
{\r
mGenrepList = tmpList;\r
}\r
\r
-u8 PGenrepList::FindEntry(u16 nWorldID, u16 nStationID)\r
+uint8_t PGenrepList::FindEntry(uint16_t nWorldID, uint16_t nStationID)\r
{\r
- u8 i = 255;\r
+ uint8_t i = 255;\r
\r
if (mGenrepList)\r
{\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+\r
+#define GENREPLIST_ALLOC_SIZE 4 // atomicity of list entries allocation\r
+\r
+class PGenrepList {\r
+private:\r
+ enum { // genrep DB Table fields\r
+ g_id = 0,\r
+ g_worldid,\r
+ g_stationid,\r
+ g_charid\r
+ };\r
+ struct PGenrepEntry\r
+ {\r
+ uint16_t mWorldID;\r
+ uint16_t mStationID;\r
+ };\r
+\r
+ uint32_t mOwnerCharID;\r
+ uint8_t mListMaxSize;\r
+ uint8_t mListSize;\r
+ PGenrepEntry* mGenrepList;\r
+\r
+ void IncreaseMaxSize(uint8_t nNewMax = 0);\r
+ uint8_t FindEntry(uint16_t nWorldID, uint16_t nStationID);\r
+\r
+ public:\r
+ PGenrepList(uint32_t nOwnerCharID);\r
+ ~PGenrepList();\r
+ bool AddGenrep(uint16_t nWorldID, uint16_t nStationID);\r
+ //bool RemoveChar(uint32_t nBuddyCharID);\r
+ inline uint8_t Count() { return mListSize; }\r
+ uint16_t GetListDataSize() { return (sizeof(PGenrepEntry) * mListSize); }\r
+ const void* GetListData() { return (const void*)mGenrepList; }\r
+ bool SQLLoad();\r
+// bool SQLSave();\r
+};\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
- globals.cpp\r
-\r
- MODIFIED: 12 September 2005 Akiko\r
- REASON: - exchanged Pretender strings by TinNS\r
- MODIFIED: 16 Dec 2005 bakkdoor\r
- REASON: - Added global ClientManager and Chat Interface\r
- MODIFIED: 22 Dec 2005 Namikon\r
- REASON: - Added GPL\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added MySQL Support\r
- - Fixed ShutdownTinns (Wont cause segmentation fault anymore)\r
- MODIFIED: 06 Jan 2006 Namikon\r
- REASON: - Added color to console outputs\r
- - Added shiny and colored copyright box :D\r
- MODIFIED: 22 Jul 2006 Hammag\r
- REASON: - Added Server NOT NULL check to avoid segfault when shuting down during startup\r
- MODIFIED: 27 Aug 2006 Hammag\r
- REASON: - Implemented shared Config class use and config template to load conf.\r
- - Added gameserver configtemplate.h include,\r
- - Added new required parameters to Config->LoadOptions()\r
- MODIFIED: 02 Oct 2006 Hammag\r
- REASON: - Added gDevDebug global flag to control development debug outputs (flagged messaged,\r
- dump-flagged messes, dev console->print)\r
- MODIFIED: 09 Jun 2009 Akiko\r
- REASON: - adjusted includes for buildsystem\r
- - clean ups\r
-\r
- TODO: - Get logfile name from config file\r
-*/\r
-\r
-\r
-#include "main.h"\r
-\r
-#include "configtemplate.h"\r
-#include "include/isc.h"\r
-\r
-#include "include/msgbuilder.h"\r
-#include "include/worlds.h"\r
-#include "include/appartements.h"\r
-#include "include/npc.h"\r
-#include "include/subway.h"\r
-#include "include/terminal.h"\r
-\r
-#include "include/version.h"\r
+#include <cstring>\r
+#include "GameServer/Includes.hxx"\r
+#include "GameServer/Definitions/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
+// TODO: - Get logfile name from config file\r
\r
const char ServerVersion[] = TINNS_GAME_VERSION;\r
const char SVNRevision[] = TINNS_SVN_REVISION;\r
Worlds->LoadWorlds();\r
\r
WorldActors = new PWorldActors();\r
- LuaEngine = new PLuaEngine();\r
+ LuaEngine = new PLuaEngine();\r
\r
NPCManager = new PNPCManager();\r
Appartements = new PAppartements;\r
Console->Print("%s Could not creat password_filter PCRE '%s'", Console->ColorText(RED, BLACK, "[Error]"), Config->GetOption("password_filter").c_str());\r
return false;\r
}\r
- \r
+\r
if (!PChar::SetCharnameRegexFilter(Config->GetOption("charname_filter").c_str()))\r
{\r
Console->Print("%s Could not creat charname_filter PCRE '%s'", Console->ColorText(RED, BLACK, "[Error]"), Config->GetOption("charname_filter").c_str());\r
return false;\r
}\r
Chars = new PChars();\r
- \r
+\r
ServerSock = new ServerSocket();\r
Server = new PServer();\r
GameServer = new PGameServer();\r
ISC = new PISC();\r
Terminal = new PTerminal();\r
\r
- Outposts = new POutpost();\r
+ Outposts = new POutpost();\r
\r
- MultiPartHandler = new PMultiPart();\r
+ MultiPartHandler = new PMultiPart();\r
\r
return true;\r
}\r
\r
exit(0);\r
}\r
-\r
--- /dev/null
+#pragma once\r
+\r
+#include "GameServer/Accounts.hxx"\r
+#include "GameServer/Appartements.hxx"\r
+#include "GameServer/BuddyList.hxx"\r
+#include "GameServer/Chars.hxx"\r
+#include "GameServer/Chat.hxx"\r
+#include "GameServer/Client.hxx"\r
+#include "GameServer/ClientManager.hxx"\r
+#include "GameServer/Commands.hxx"\r
+#include "GameServer/ConfigTemplate.hxx"\r
+#include "GameServer/Container.hxx"\r
+#include "GameServer/DoorTemplate.hxx"\r
+#include "GameServer/FurnitureTemplate.hxx"\r
+#include "GameServer/GameScript.hxx"\r
+#include "GameServer/GameServer.hxx"\r
+#include "GameServer/GenrepList.hxx"\r
+#include "GameServer/Inventory.hxx"\r
+#include "GameServer/Isc.hxx"\r
+#include "GameServer/Item.hxx"\r
+#include "GameServer/LuaEngine.hxx"\r
+#include "GameServer/Main.hxx"\r
+#include "GameServer/MessageBuilder.hxx"\r
+#include "GameServer/MultiPart.hxx"\r
+#include "GameServer/Npc.hxx"\r
+#include "GameServer/NpcTemplate.hxx"\r
+#include "GameServer/Outpost.hxx"\r
+#include "GameServer/RemoteConsole.hxx"\r
+#include "GameServer/Server.hxx"\r
+#include "GameServer/Skill.hxx"\r
+#include "GameServer/Sql.hxx"\r
+#include "GameServer/Subway.hxx"\r
+#include "GameServer/Terminal.hxx"\r
+#include "GameServer/Vehicle.hxx"\r
+#include "GameServer/VehicleAccessRequest.hxx"\r
+#include "GameServer/WorldActors.hxx"\r
+#include "GameServer/WorldDataTemplate.hxx"\r
+#include "GameServer/Worlds.hxx"\r
+#include "GameServer/Zoning.hxx"\r
+\r
+extern class PLuaEngine *LuaEngine;\r
+\r
+extern class ServerSocket *ServerSock;\r
+extern class PConsole *Console;\r
+//extern class PRConsole *RemoteConsole;\r
+extern class PConfig *Config;\r
+extern class PConfig *CmdAccess;\r
+\r
+extern class PGameDefs *GameDefs;\r
+extern class PFileSystem *Filesystem;\r
+extern class PServer *Server;\r
+\r
+extern class PGameServer *GameServer;\r
+extern class PChars *Chars;\r
+\r
+extern class PMsgBuilder *MsgBuilder;\r
+extern class PWorlds *Worlds;\r
+extern class PAppartements* Appartements;\r
+extern class PWorldActors* WorldActors;\r
+extern class PTerminal* Terminal;\r
+//extern class gmMachine machine; // Virtual Machine instance\r
+\r
+//multiuser chat\r
+extern class PClientManager *ClientManager;\r
+extern class PNPCManager* NPCManager;\r
+extern class PChat *Chat;\r
+extern class PCommands *GameCommands;\r
+\r
+extern class POutpost *Outposts;\r
+extern class PMultiPart *MultiPartHandler;\r
+\r
+// Development debug output control\r
+extern bool gDevDebug;\r
+\r
+//MySQL-Support\r
+extern class PMySQL* MySQL;\r
+\r
+//Vehicles\r
+extern class PVehicles *Vehicles;\r
+extern class PSubway* Subway;\r
+\r
+//Infoserver update\r
+extern class PISC *ISC;\r
+\r
+extern const char ServerVersion[];\r
+extern const char SVNRevision[];\r
+\r
+bool InitTinNS();\r
+void Shutdown();\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- inventory.cpp - classes for inventories\r
- (inventory, belt, armor, implants, gogo, processor(?), maybe other containers(?) )\r
-\r
- MODIFIED: 10 Jul 2006 Hammag\r
- REASON: - creation : Quick and dirty main inventory (backpack) management\r
- MODIFIED: 09 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
- - clean ups\r
-*/\r
-\r
-\r
-#include "main.h"\r
-\r
-#include "include/inventory.h"\r
-#include "include/container.h"\r
-\r
+#include "GameServer/Includes.hxx"\r
\r
/* --- PInventory class --- */\r
\r
delete mGogo;\r
}\r
\r
-void PInventory::SetCharId(u32 CharID)\r
+void PInventory::SetCharId(uint32_t CharID)\r
{\r
mWorn->SetInfo(CharID, INV_DB_LOC_WORN);\r
mBackpack->SetInfo(CharID, INV_DB_LOC_BACKPACK);\r
bool PInventory::SQLLoad()\r
{\r
return ( mWorn->SQLLoad() && mBackpack->SQLLoad() && mGogo->SQLLoad() );\r
- \r
+\r
/*bool ret = mWorn->SQLLoad() && mBackpack->SQLLoad() && mGogo->SQLLoad();\r
Console->Print(YELLOW, BLACK, "--- Worn Inventory ---");\r
mWorn->Dump();\r
return (mWorn && mWorn->IsDirty()) || (mBackpack && mBackpack->IsDirty()) || (mGogo && mGogo->IsDirty());\r
}\r
\r
-PContainer* PInventory::GetContainer(u8 nInvLoc)\r
+PContainer* PInventory::GetContainer(uint8_t nInvLoc)\r
{\r
PContainer* tContainer;\r
switch(nInvLoc)\r
return tContainer;\r
}\r
\r
-bool PInventory::AddItem(PItem *NewItem, u8 nInvLoc, u32 nInvID, u8 nPosX, u8 nPosY, bool SetDirty)\r
+bool PInventory::AddItem(PItem *NewItem, uint8_t nInvLoc, uint32_t nInvID, uint8_t nPosX, uint8_t nPosY, bool SetDirty)\r
{\r
PContainer* destContainer = GetContainer(nInvLoc);\r
return(destContainer ? destContainer->AddItem(NewItem, nInvID, nPosX, nPosY, SetDirty) : false);\r
}\r
\r
/*\r
-bool PInventory::QB_IsFree(u8 nSlot)\r
+bool PInventory::QB_IsFree(uint8_t nSlot)\r
{\r
if(nSlot > 9)\r
return false;\r
return false;\r
}\r
\r
-void PInventory::QB_SetSlot(u8 nSlot, u16 nItemID)\r
+void PInventory::QB_SetSlot(uint8_t nSlot, uint16_t nItemID)\r
{\r
if(nSlot > 9)\r
return;\r
mQuickAccessBelt[nSlot] = nItemID;\r
}\r
\r
-u16 PInventory::QB_GetSlot(u8 nSlot)\r
+uint16_t PInventory::QB_GetSlot(uint8_t nSlot)\r
{\r
if(nSlot > 9)\r
return 0;\r
return mQuickAccessBelt[nSlot];\r
}\r
\r
-void PInventory::QB_Move(u8 nSlotSRC, u8 nSlotDST)\r
+void PInventory::QB_Move(uint8_t nSlotSRC, uint8_t nSlotDST)\r
{\r
if(nSlotSRC > 9 || nSlotDST > 9)\r
return;\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+\r
+//NC containers message locations\r
+#define INV_LOC_GROUND 1\r
+#define INV_LOC_WORN 2\r
+#define INV_LOC_BACKPACK 3\r
+#define INV_LOC_BOX 4\r
+#define INV_LOC_NPCTRADE 5\r
+#define INV_LOC_GOGO 18\r
+#define INV_LOC_BOX2 255\r
+//PC-Trade window = ?\r
+\r
+//Inventory containers info\r
+#define INV_WORN_QB_START 0\r
+#define INV_WORN_QB_END 9\r
+#define INV_WORN_QB_NONE 99\r
+#define INV_WORN_QB_HAND 11\r
+\r
+#define INV_WORN_PROC_START 12\r
+#define INV_WORN_PROC_END 24\r
+\r
+#define INV_WORN_IMP_START 26\r
+#define INV_WORN_IMP_END 38\r
+\r
+#define INV_WORN_ARMOR_START 39\r
+#define INV_WORN_ARMOR_END 43\r
+\r
+#define INV_WORN_COLS 44\r
+#define INV_WORN_MAXSLOTS 44\r
+\r
+\r
+#define INV_BACKPACK_COLS 10\r
+\r
+#define INV_GOGO_COLS 5\r
+#define INV_GOGO_MAXSLOTS 50\r
+\r
+#define INV_CABINET_COLS 5\r
+#define INV_CABINET_MAXSLOTS 33\r
+\r
+// inv_loc values in database\r
+#define INV_DB_LOC_GOGO 1\r
+#define INV_DB_LOC_WORN 2\r
+#define INV_DB_LOC_BACKPACK 3\r
+\r
+class PItem;\r
+class PContainer;\r
+class PContainerWithHoles;\r
+class PContainer2DWorkaround;\r
+class PContainerAutoFindFree;\r
+\r
+class PInventory\r
+{\r
+ private:\r
+ PContainerWithHoles* mWorn; // PContainerLinearSlots\r
+ PContainer2DWorkaround* mBackpack; // PContainer2DAreas\r
+ PContainerAutoFindFree* mGogo; // PContainerLinearSlots\r
+\r
+ public:\r
+\r
+ PInventory();\r
+ ~PInventory();\r
+\r
+ void SetCharId(uint32_t CharID);\r
+ bool SQLLoad();\r
+ bool SQLSave();\r
+ PContainer* GetContainer(uint8_t nInvLoc);\r
+ inline PContainer2DWorkaround* GetBackpackContainer() { return mBackpack; }\r
+\r
+ bool IsDirty() const;\r
+\r
+ 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);\r
+ //bool CheckItem(uint32_t ItemID, uint8_t StackSize = 1);\r
+ //PItem *GetItem(uint32_t ItemID, uint8_t StackSize = 1);\r
+ //PItem *GetItemByPos(uint8_t nPosX, uint8_t nPosY, uint8_t StackSize = 1);\r
+ //bool MoveItem(uint8_t oPosX, uint8_t oPosY, uint8_t dPosX, uint8_t dPosY);\r
+\r
+ //bool QB_IsFree(uint8_t nSlot);\r
+ //void QB_SetSlot(uint8_t nSlot, uint16_t nItemID);\r
+ //uint16_t QB_GetSlot(uint8_t nSlot);\r
+ //void QB_Move(uint8_t nSlotSRC, uint8_t nSlotDST);\r
+};\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
+#include "GameServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
- isc.cpp\r
-\r
- MODIFIED: Unknown date / Namikon\r
- REASON: - initial release by Namikon\r
- MODIFIED: 13 Oct 2006 Hammag\r
- REASON: - Implemented MySQL isc method\r
- MODIFIED: 09 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
-\r
- TODO:\r
- - implement ISC protocol\r
-*/\r
-\r
-#include "main.h"\r
-\r
-#include "include/isc.h"\r
+// TODO: - implement ISC protocol\r
\r
PISC::PISC()\r
{\r
\r
if (use_isc)\r
Start_isc();\r
- \r
+\r
if (use_mysql)\r
Start_mysql();\r
\r
{\r
if (use_isc)\r
Update_isc();\r
- \r
+\r
if (use_mysql)\r
- Update_mysql(); \r
+ Update_mysql();\r
}\r
\r
void PISC::Shutdown()\r
use_isc = false;\r
Shutdown_isc();\r
}\r
- \r
+\r
if (use_mysql)\r
{\r
use_mysql = false;\r
\r
void PISC::Start_isc()\r
{\r
- u16 Port = Config->GetOptionInt("isc_infoserverport");\r
- if (Port == 0)\r
- {\r
- Console->Print("%s Unable to start ISC, isc_infoserverport setting is invalid");\r
- use_isc = false;\r
- return;\r
- }\r
- Console->Print("Trying to connect to infoserver...", Port);\r
- // Add function for initial connect here and store the connectioninfo somewhere\r
+ uint16_t Port = Config->GetOptionInt("isc_infoserverport");\r
+ if (Port == 0)\r
+ {\r
+ Console->Print("%s Unable to start ISC, isc_infoserverport setting is invalid");\r
+ use_isc = false;\r
+ return;\r
+ }\r
+ Console->Print("Trying to connect to infoserver...", Port);\r
+ // Add function for initial connect here and store the connectioninfo somewhere\r
}\r
\r
void PISC::Update_isc()\r
{\r
- \r
}\r
\r
void PISC::Shutdown_isc()\r
{\r
- \r
}\r
\r
-\r
/*** IMySQL mode specific ***/\r
\r
void PISC::Start_mysql()\r
Console->Print("%s value for 'isc_update_intervall' too low (%d). Set to 10 sec.", Console->ColorText(YELLOW, BLACK, "[Notice]"), mysql_update_intervall);\r
mysql_update_intervall = 10;\r
}\r
- \r
+\r
mysql_delayed_update_intervall = Config->GetOptionInt("isc_delayed_update_intervall");\r
if (mysql_delayed_update_intervall < 0)\r
{\r
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);\r
mysql_delayed_update_intervall = 0;\r
}\r
- \r
+\r
mysql_last_update_time = 0;\r
mysql_last_client_count = 0;\r
mysql_last_count_decrease_time = 0;\r
- \r
+\r
Update_mysql();\r
}\r
\r
bool do_update = false;\r
std::time_t t = std::time(NULL);\r
int client_count = Server->GetNumClients();\r
- \r
+\r
if (((t - mysql_last_update_time) >= mysql_update_intervall) || (client_count > mysql_last_client_count))\r
{\r
do_update = true;\r
mysql_last_count_decrease_time = 0;\r
//if(gDevDebug) Console->Print("%s ISC : Canceling less clients time count", Console->ColorText(GREEN, BLACK, "[Debug]")); \r
}\r
- \r
+\r
if (do_update)\r
{\r
do_mysql_db_update(client_count);\r
mysql_last_count_decrease_time = 0;\r
mysql_last_update_time = std::time(NULL);\r
}\r
- \r
}\r
\r
void PISC::Shutdown_mysql()\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
+#pragma once\r
\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-/*\r
- isc.h\r
-\r
- MODIFIED: Unknown date / Namikon\r
- REASON: - initial release by Namikon\r
- MODIFIED: 13 Oct 2006 Hammag\r
- REASON: - Implemented MySQL isc method\r
-\r
-*/\r
-\r
-#ifndef ISC_H\r
-#define ISC_H\r
+#include <chrono>\r
+#include <cstdint>\r
\r
#define ISC_VER 2\r
\r
#define ISC_CONNECTED 1\r
#define ISC_ADMIN 2\r
\r
-\r
-class PISC\r
-{\r
- private:\r
+class PISC {\r
+ private:\r
enum PISC_Status\r
{\r
ISC_NOTCONNECTED,\r
ISC_IDLE // Updateloop running\r
} mLinkStatus;\r
\r
- u16 mConStatus; // Bitmask of Connection status\r
+ uint16_t mConStatus; // Bitmask of Connection status\r
\r
int isc_method;\r
\r
\r
bool use_mysql;\r
int m_server_id;\r
- std::time_t mysql_update_intervall;\r
- std::time_t mysql_delayed_update_intervall;\r
- std::time_t mysql_last_update_time;\r
+ time_t mysql_update_intervall;\r
+ time_t mysql_delayed_update_intervall;\r
+ time_t mysql_last_update_time;\r
int mysql_last_client_count;\r
- std::time_t mysql_last_count_decrease_time;\r
+ time_t mysql_last_count_decrease_time;\r
\r
void Start_isc();\r
void Update_isc();\r
bool do_mysql_db_update(int players, bool shutdown = false);\r
void Shutdown_mysql();\r
\r
- public:\r
- PISC();\r
- ~PISC();\r
+ public:\r
+ PISC();\r
+ ~PISC();\r
\r
- void Start();\r
- void Update();\r
- void Shutdown();\r
+ void Start();\r
+ void Update();\r
+ void Shutdown();\r
};\r
-\r
-#endif\r
--- /dev/null
+#include "GameServer/Includes.hxx"\r
+#include "GameServer/Definitions/Includes.hxx"\r
+\r
+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)\r
+{\r
+ mDefItem = GameDefs->Items()->GetDef(ItemID);\r
+ if (mDefItem) {\r
+ mItemID = ItemID;\r
+ mStackable = mDefItem->IsStackable();\r
+ mStackSize = mStackable ? nStackSize : 1;\r
+\r
+ mLoadedAmmoId = 0;\r
+ mLoadedAmmoNb = 0;\r
+\r
+ mPropertiesFlags = 0;\r
+\r
+ mUsedSlots = mMaxSlots = 0;\r
+ mModificators = 0;\r
+\r
+ mConstructorId = 0;\r
+ //mType = mDefItem->GetType();\r
+ //mValue1 = mDefItem->GetValue1();\r
+ //mValue2 = mDefItem->GetValue2();\r
+ //mValue3 = mDefItem->GetValue3();\r
+ //mSizeX = mDefItem->GetSizeX();\r
+ //mSizeY = mDefItem->GetSizeY();\r
+ //mWeight = mDefItem->GetWeight();\r
+ //mFillWeight = mDefItem->GetFillWeight();\r
+ //mQualifier = mDefItem->GetQualifier();\r
+ //mItemGroupID = mDefItem->GetItemGroupID();\r
+ //mBasePrice = mDefItem->GetBasePrice();\r
+ //mTechlevel = mDefItem->GetTechlevel();\r
+ //mItemflags = mDefItem->GetItemflags();\r
+\r
+ //if (!mStackable) // only non-stackable items can have quality stats (?)\r
+ //{\r
+ // mStackSize = 1;\r
+ mCurDuration = CurDur;\r
+ mMaxDuration = MaxDur;\r
+ mDamages = Dmg;\r
+ mFrequency = Freq;\r
+ mHandling = Hand;\r
+ mRange = Rng;\r
+ //}\r
+ }\r
+ else\r
+ {\r
+ mItemID = 0;\r
+ Console->Print(YELLOW, BLACK, "PItem::PItem: Invalid item ID %d", ItemID);\r
+ }\r
+}\r
+\r
+void PItem::MakeItemStandard(uint8_t GlobalQualityMin, uint8_t GlobalQualityMax)\r
+{\r
+ if(GlobalQualityMin > GlobalQualityMax) GlobalQualityMin = GlobalQualityMax;\r
+\r
+ mCurDuration = 255;\r
+ mMaxDuration = 255;\r
+ if(GlobalQualityMin == GlobalQualityMax)\r
+ {\r
+ mDamages = GlobalQualityMin;\r
+ mFrequency = GlobalQualityMin;\r
+ mHandling = GlobalQualityMin;\r
+ mRange = GlobalQualityMin;\r
+ }\r
+ else\r
+ {\r
+ mDamages = (uint8_t) GetRandom(GlobalQualityMax, GlobalQualityMin);\r
+ mFrequency = (uint8_t) GetRandom(GlobalQualityMax, GlobalQualityMin);\r
+ mHandling = (uint8_t) GetRandom(GlobalQualityMax, GlobalQualityMin);\r
+ mRange = (uint8_t) GetRandom(GlobalQualityMax, GlobalQualityMin);\r
+ }\r
+}\r
+\r
+uint32_t PItem::GetItemID()\r
+{\r
+ return mItemID;\r
+}\r
+\r
+int PItem::GetType()\r
+{\r
+ return mDefItem->GetType();\r
+}\r
+\r
+uint8_t PItem::GetItemflags()\r
+{\r
+ return mDefItem->GetItemflags();\r
+}\r
+\r
+const std::string &PItem::GetName() const\r
+{\r
+ return mDefItem->GetName();\r
+}\r
+\r
+uint8_t PItem::GetSizeX()\r
+{\r
+ return mDefItem->GetSizeX();\r
+}\r
+\r
+uint8_t PItem::GetSizeY()\r
+{\r
+ return mDefItem->GetSizeY();\r
+}\r
+\r
+float PItem::GetWeight()\r
+{\r
+ return mStackSize * mDefItem->GetWeight();\r
+}\r
+\r
+float PItem::GetSingleUnitWeight()\r
+{\r
+ return mDefItem->GetWeight();\r
+}\r
+\r
+float PItem::GetFillWeight()\r
+{\r
+ return mDefItem->GetFillWeight();\r
+}\r
+\r
+uint32_t PItem::GetBasePrice()\r
+{\r
+ return mDefItem->GetBasePrice();\r
+}\r
+\r
+uint16_t PItem::GetTechlevel()\r
+{\r
+ return mDefItem->GetTechlevel();\r
+}\r
+\r
+int PItem::GetValue1()\r
+{\r
+ return mDefItem->GetValue1();\r
+}\r
+\r
+int PItem::GetValue2()\r
+{\r
+ return mDefItem->GetValue2();\r
+}\r
+\r
+int PItem::GetValue3()\r
+{\r
+ return mDefItem->GetValue3();\r
+}\r
+\r
+int PItem::GetQualifier()\r
+{\r
+ return mDefItem->GetQualifier();\r
+}\r
+\r
+bool PItem::IsStackable()\r
+{\r
+ return mDefItem->IsStackable();\r
+}\r
+\r
+uint8_t PItem::GetStackSize()\r
+{\r
+ return mStackSize;\r
+}\r
+\r
+uint8_t PItem::AddToStack(uint8_t ItemNb) // returns nb of items not added\r
+{\r
+ uint8_t addedItems = 0;\r
+ if (mStackable)\r
+ {\r
+ addedItems = (ItemNb <= (MAX_ITEMSTACK_SIZE - mStackSize)) ? ItemNb : (MAX_ITEMSTACK_SIZE - mStackSize);\r
+ mStackSize += addedItems;\r
+ }\r
+ return (ItemNb - addedItems);\r
+}\r
+\r
+uint8_t PItem::TakeFromStack(uint8_t ItemNb)\r
+{\r
+ uint8_t retreivedItems = 0;\r
+ if (mStackable)\r
+ {\r
+ retreivedItems = std::min(mStackSize, ItemNb);\r
+ mStackSize -= retreivedItems;\r
+ }\r
+ return retreivedItems;\r
+}\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include <string>\r
+\r
+class PDefItems;\r
+\r
+// TODO: Add CreatorID (for "named" item), CurrentMunitionID, CurrentMunitionNb (for weapons & charge-items: muns,\r
+// medkit, etc.) to DB, equipped/free slots, & corresponding code\r
+\r
+#define MAX_ITEMSTACK_SIZE 250\r
+\r
+//Type\r
+#define ITEM_TYPE_VARIOUS 0\r
+#define ITEM_TYPE_WEAPON 1\r
+#define ITEM_TYPE_AMMO 2\r
+#define ITEM_TYPE_HEALTH 3\r
+#define ITEM_TYPE_IMPLANT 4\r
+#define ITEM_TYPE_DRUG 5\r
+#define ITEM_TYPE_MOD 6\r
+#define ITEM_TYPE_GFXMOD 7\r
+#define ITEM_TYPE_BLUEPRINT 8\r
+#define ITEM_TYPE_ARMOR 9\r
+#define ITEM_TYPE_PSIMOD 10\r
+#define ITEM_TYPE_PSIMODREADY 11\r
+#define ITEM_TYPE_REPAIR 12\r
+#define ITEM_TYPE_RECYCLER 13\r
+#define ITEM_TYPE_DATACUBE 14\r
+#define ITEM_TYPE_CONSTRUCTOR 15\r
+#define ITEM_TYPE_RESEARCHER 16\r
+#define ITEM_TYPE_IMPLANTER 17\r
+#define ITEM_TYPE_APARTMENTKEY 18\r
+#define ITEM_TYPE_CLANKEY 19\r
+#define ITEM_TYPE_CASHCUBE 20\r
+#define ITEM_TYPE_AUTOWEAPON 21\r
+#define ITEM_TYPE_VHCKEY 22\r
+#define ITEM_TYPE_UNIDENTPART 24\r
+#define ITEM_TYPE_WRECKEDPART 25\r
+#define ITEM_TYPE_SALVAGE 26\r
+#define ITEM_TYPE_VHCCOMPONENT 27\r
+#define ITEM_TYPE_RECORDABLE 28\r
+\r
+// gfxmodflags\r
+#define ITEM_MOD_FLASHLIGHT 1\r
+#define ITEM_MOD_SCOP 2\r
+#define ITEM_MOD_SILENCER 4\r
+#define ITEM_MOD_LASERPOINTER 8\r
+\r
+// itemflags:\r
+#define ITEM_FLAG_RESEARCHABLE 1\r
+#define ITEM_FLAG_NO_DROP 2\r
+#define ITEM_FLAG_NO_MAX_REPAIRE_DECAY 4\r
+#define ITEM_FLAG_AMMO 8 // for loadable ammo\r
+// not sure for ITEM_FLAG_AMMO\r
+\r
+class PItem {\r
+ friend class PContainerEntry;\r
+ friend class PMsgBuilder;\r
+\r
+ private:\r
+ uint32_t mItemID;\r
+ const PDefItems* mDefItem;\r
+\r
+ bool mStackable;\r
+ uint8_t mStackSize;\r
+\r
+ uint32_t mLoadedAmmoId;\r
+ uint8_t mLoadedAmmoNb;\r
+\r
+ uint8_t mPropertiesFlags;\r
+\r
+ uint8_t mCurDuration;\r
+ uint8_t mMaxDuration;\r
+ uint8_t mDamages;\r
+ uint8_t mFrequency;\r
+ uint8_t mHandling;\r
+ uint8_t mRange;\r
+\r
+ uint8_t mUsedSlots;\r
+ uint8_t mMaxSlots;\r
+ uint8_t mSlot[5];\r
+ uint8_t mModificators;\r
+\r
+ uint32_t mConstructorId;\r
+\r
+ public:\r
+ 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);\r
+ //~PItem();\r
+ void MakeItemStandard(uint8_t GlobalQualityMin = 120, uint8_t GlobalQualityMax = 180);\r
+\r
+ uint32_t GetItemID();\r
+ int GetType();\r
+ uint8_t GetItemflags();\r
+ const std::string &GetName() const;\r
+ uint8_t GetSizeX();\r
+ uint8_t GetSizeY();\r
+ float GetWeight();\r
+ float GetSingleUnitWeight();\r
+ float GetFillWeight();\r
+ uint32_t GetBasePrice();\r
+ uint16_t GetTechlevel();\r
+ int GetValue1();\r
+ int GetValue2();\r
+ int GetValue3();\r
+ int GetQualifier();\r
+ bool IsStackable();\r
+ uint8_t GetStackSize();\r
+ uint8_t AddToStack(uint8_t ItemNb); // return the nb of items NOT added\r
+ uint8_t TakeFromStack(uint8_t ItemNb); // return the nb of retreived items\r
+\r
+ //mItemGroupID = def->GetItemGroupID();\r
+};\r
-/*
-TinNS (TinNS is not a Neocron Server)
-Copyright (C) 2005 Linux Addicted Community
-maintainer Akiko <akiko@gmx.org>
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public 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
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);
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
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);
PLuaEngine::PLuaEngine()
{
- // New lua function
+ // New lua function
mLua = luaL_newstate();
mRunning = false;
}
--- /dev/null
+#pragma once
+
+#include <lua.hpp>
+
+#define PLUAENGINE_DEFAULT 0
+#define PLUAENGINE_GETANSWER 4096
+#define PLUAENGINE_EXECUTENODE 8192
+
+class PLuaEngine {
+private:
+ PClient* mTargetClient;
+
+ bool mRunning;
+ lua_State *mLua;
+
+ std::vector<int> 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; };
+};
--- /dev/null
+#include <csignal>
+#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;
+}
--- /dev/null
+#pragma once\r
+\r
+//#include "version.h"\r
+\r
+//basic includes\r
+//#include "include/external.h"\r
+\r
+//tinns includes\r
+//#include "include/types.h"\r
+//#include "common/netcode.h"\r
+/*\r
+#include "../gamemonkey/gmMachine.h"\r
+#include "../gamemonkey/gmCall.h"\r
+*/\r
+//#include "common/console.h"\r
+//#include "common/misc.h"\r
+\r
+// MySQL Support\r
+/*\r
+#ifdef MYSQL_INC_DIR\r
+#include <mysql/mysql.h>\r
+#else\r
+#include <mysql.h>\r
+#endif\r
+\r
+#include "include/sql.h"\r
+\r
+#include "common/config.h"\r
+#include "common/filesystem.h"\r
+#include "include/defparser.h"\r
+\r
+#include "include/skill.h"\r
+#include "include/chars.h"\r
+#include "include/accounts.h"\r
+#include "include/client.h"\r
+#include "include/server.h"\r
+#include "include/gameserver.h"\r
+#include "include/globals.h"\r
+#include "include/defs.h"\r
+#include "include/zoning.h"\r
+#include "include/item.h"\r
+#include "include/inventory.h"\r
+#include "include/worldactors.h"\r
+#include "include/npc.h"\r
+#include "include/outpost.h"\r
+#include "include/multipart.h"\r
+#include "include/terminal.h"\r
+\r
+#include "include/lua_engine.h"\r
+#include "include/chat.h"\r
+#include "include/commands.h"\r
+#include "include/clientmanager.h" */\r
--- /dev/null
+#include <cstring>
+#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 )\r
+ {\r
+ PMessage* tmpMsg;\r
+ \r
+ tmpMsg = new PMessage();\r
+ \r
+ *tmpMsg << ( uint8_t )0x19;\r
+ *tmpMsg << ( uint16_t )0x0006; // InfoQuery\r
+ *tmpMsg << ( uint16_t )0x0003; // NPC Script\r
+ *tmpMsg << ( uint32_t )nInfoId;\r
+ *tmpMsg << nNPCScript->c_str();\r
+ \r
+ return tmpMsg;\r
+ \r
+ }\r
+ \r
+PMessage* PMsgBuilder::BuildYouGotEmailsMsg( PClient* nClient, uint8_t nMailCount )\r
+ {\r
+ PMessage* tmpMsg = new PMessage();\r
+ nClient->IncreaseUDP_ID();\r
+ \r
+ *tmpMsg << ( uint8_t )0x13;\r
+ *tmpMsg << ( uint16_t )nClient->GetUDP_ID();\r
+ *tmpMsg << ( uint16_t )nClient->GetSessionID();\r
+ *tmpMsg << ( uint8_t )0x0c;\r
+ *tmpMsg << ( uint8_t )0x03;\r
+ *tmpMsg << ( uint16_t )nClient->GetUDP_ID();\r
+ *tmpMsg << ( uint8_t )0x1f;\r
+ *tmpMsg << ( uint16_t )nClient->GetLocalID();\r
+ *tmpMsg << ( uint8_t )0x3d;\r
+ *tmpMsg << ( uint8_t )0x0c;\r
+ *tmpMsg << ( uint8_t )0x00;\r
+ *tmpMsg << ( uint8_t )0x00;\r
+ *tmpMsg << ( uint8_t )0x00;\r
+ *tmpMsg << ( uint8_t )nMailCount;\r
+ \r
+ return tmpMsg;\r
+ }\r
+ \r
+PMessage* PMsgBuilder::BuildReceiveDBAnswerMsg( PClient* nClient, PMessage* nResultBuffer, std::string *nCommandName, uint16_t nNumRows, uint16_t nNumFields)\r
+ {\r
+ PMessage* tmpMsg = new PMessage();\r
+/* nClient->IncreaseUDP_ID();\r
+ \r
+ *tmpMsg << ( uint8_t )0x13;\r
+ *tmpMsg << ( uint16_t )0x0000;\r
+ *tmpMsg << ( uint16_t )0x0000;\r
+ *tmpMsg << ( uint8_t )0x00;\r
+ *tmpMsg << ( uint8_t )0x03;\r
+ *tmpMsg << ( uint16_t )nClient->GetUDP_ID();\r
+ *tmpMsg << ( uint8_t )0x2b;\r
+ *tmpMsg << ( uint8_t )0x1a;\r
+ if(nCommandName->length() > 0)\r
+ *tmpMsg << ( uint8_t )0x01;\r
+ else\r
+ *tmpMsg << ( uint8_t )0x00;\r
+ \r
+ *tmpMsg << ( uint8_t )0x00;\r
+ *tmpMsg << ( uint8_t )0x00;\r
+ *tmpMsg << *nCommandName;\r
+ ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 );\r
+ \r
+ // 2nd message\r
+ *tmpMsg << ( uint16_t )(13 + nCommandName->length() + nResultBuffer->GetSize()); // ??\r
+ */\r
+ nClient->IncreaseUDP_ID();\r
+ \r
+ *tmpMsg << ( uint8_t )0x13;\r
+ *tmpMsg << ( uint16_t )nClient->GetUDP_ID();\r
+ *tmpMsg << ( uint16_t )nClient->GetSessionID();\r
+ *tmpMsg << ( uint8_t )0x00;\r
+ *tmpMsg << ( uint8_t )0x03;\r
+ *tmpMsg << ( uint16_t )nClient->GetUDP_ID();\r
+ *tmpMsg << ( uint8_t )0x2b;\r
+ *tmpMsg << ( uint8_t )0x17;\r
+ *tmpMsg << ( uint16_t )(nCommandName->length()+1);\r
+ *tmpMsg << ( uint16_t )nNumRows;\r
+ *tmpMsg << ( uint16_t )nNumFields;\r
+ *tmpMsg << *nCommandName;\r
+ *tmpMsg << *nResultBuffer;\r
+ \r
+ ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 );\r
+ \r
+ \r
+ return tmpMsg;\r
+ //len = (unsigned int)strlen(DB);\r
+ //SendBuffer[0] = 0x13;\r
+ //SendBuffer[5] = 11 + len;\r
+ //SendBuffer[6] = 0x03;\r
+ //Network_IncrementUDP (ClientNum);\r
+ //*(unsigned short*)&SendBuffer[7] = Client_Sockets[ClientNum].UDP_ID;\r
+ // SendBuffer[9] = 0x2b;\r
+ // SendBuffer[10] = 0x1a;\r
+ // *(unsigned short*)&SendBuffer[11] = len;\r
+ // if (num == 0)\r
+ // SendBuffer[13] = 0x00;\r
+ // else\r
+ // SendBuffer[13] = 0x01;\r
+ // SendBuffer[14] = 0x00;\r
+ // SendBuffer[15] = 0x00;\r
+ // strcpy (SendBuffer+16, DB);\r
+ // plen = 17+len;\r
+ \r
+ // SendBuffer[plen] = 13+len+slen;\r
+ // SendBuffer[plen+1] = 0x03;\r
+ // Network_IncrementUDP (ClientNum);\r
+ // *(unsigned short*)&SendBuffer[plen+2] = Client_Sockets[ClientNum].UDP_ID;\r
+ // *(unsigned short*)&SendBuffer[1] = Client_Sockets[ClientNum].UDP_ID;\r
+ // *(unsigned short*)&SendBuffer[3] = Client_Sockets[ClientNum].UDP_ID_HIGH;\r
+ // SendBuffer[plen+4] = 0x2b;\r
+ // SendBuffer[plen+5] = 0x17;\r
+ // *(unsigned short*)&SendBuffer[plen+6] = len+1;\r
+ // *(unsigned short*)&SendBuffer[plen+8] = num;\r
+ // *(unsigned short*)&SendBuffer[plen+10] = Fields;\r
+ // //Fieldnum is defined in each DB below\r
+ // strcpy (SendBuffer+plen+12, DB);\r
+ // plen += 13+len;\r
+ \r
+ // for (i=0;i<slen;i++)\r
+ // SendBuffer[plen+i] = TempBuffer[i];\r
+ \r
+ \r
+ }\r
+ \r
+ \r
+PMessage* PMsgBuilder::BuildTryAccessAnswerMsg(PClient* nClient, char *nArea, bool nAllowed)\r
+ {\r
+ PMessage* tmpMsg = new PMessage();\r
+ //uint8_t i = (uint8_t)strlen(nArea);\r
+ \r
+ nClient->IncreaseUDP_ID();\r
+ \r
+ *tmpMsg << (uint8_t)0x13;\r
+ *tmpMsg << (uint16_t)nClient->GetUDP_ID();\r
+ *tmpMsg << (uint16_t)nClient->GetSessionID();\r
+ *tmpMsg << (uint8_t)0x00;\r
+ *tmpMsg << (uint8_t)0x03;\r
+ *tmpMsg << (uint16_t)nClient->GetUDP_ID();\r
+ *tmpMsg << (uint8_t)0x2b;\r
+ *tmpMsg << (uint8_t)0x1a;\r
+ *tmpMsg << (uint16_t)(strlen(nArea)+1);\r
+ \r
+ if(nAllowed)\r
+ *tmpMsg << (uint8_t)0x01;\r
+ else\r
+ *tmpMsg << (uint8_t)0x00;\r
+ \r
+ *tmpMsg << (uint8_t)0x00;\r
+ *tmpMsg << (uint8_t)0x00;\r
+ *tmpMsg << nArea;\r
+ \r
+ ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 );\r
+ return tmpMsg;\r
+ }\r
+
+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;i<MAX_INVENTORY;i++)
+ {
+ for (t=0;t<128;t++)
+ {
+ if (CurrentChar.QuickBelt[t]-1 != i)
+ continue;
+ *(unsigned short*)&StatsBuffer[len+plen] = 6; //Data size of item
+ *(unsigned short*)&StatsBuffer[len+plen+2] = t; //X position in Inventory
+ *(unsigned short*)&StatsBuffer[len+plen+4] = CurrentChar.ItemList[CurrentChar.QuickBelt[t]-1].ItemID; //Item ID
+ *(unsigned short*)&StatsBuffer[len+plen+6] = CurrentChar.ItemList[CurrentChar.QuickBelt[t]-1].Qty; //Quantity
+ plen += 8;
+ *(unsigned short*)&StatsBuffer[len+3] += 1; //Add to item
+ break;
+ }
+ */
+ /*if (CurrentChar.Inventory[i].ItemID == 0) //Last Item
+ break;
+ if (CurrentChar.Inventory[i].Location != 2) //Not Quickbelt, skip it
+ continue;
+ if (Def_GetItemType(CurrentChar.Inventory[i].ItemID) == 1)
+ {
+ //18 00 01 00 08 00 63 00 06 ff c8 c8 c8 c8 ff 00 01 00 28 04 00 01 04 ff 01
+ //12 00 11 5f 07 23 00 06 eb a4 99 a3 a5 ff 04 00 01 04 ff 01
+ //13 00 05 00 03 02 23 00 06 6d c4 c4 c4 c4 ff 04 00 01 04 ff 00
+ //17 00 05 9d 01 73 28 06 13 c1 c1 c1 c1 ff 00 01 01 f1 05 04
+ //|Size|Slot|ItemID|??? |? |Du| Stats |MD|?????????????????|
+ *(unsigned short*)&StatsBuffer[len+plen] = 19; //Size
+ *(unsigned short*)&StatsBuffer[len+plen+2] = CurrentChar.Inventory[i].LocX; //Slot
+ *(unsigned short*)&StatsBuffer[len+plen+4] = CurrentChar.Inventory[i].ItemID;//Item ID
+ StatsBuffer[len+plen+6] = 0x23; //0x73 = Ranged, 0x63 = close/spell
+ StatsBuffer[len+plen+7] = CurrentChar.Inventory[i].Qty; //Quantity
+ StatsBuffer[len+plen+8] = 0x06; //0x06
+ StatsBuffer[len+plen+9] = CurrentChar.Inventory[i].CurDur; //Current Durability
+ StatsBuffer[len+plen+10] = CurrentChar.Inventory[i].Damage; //Stats
+ StatsBuffer[len+plen+11] = CurrentChar.Inventory[i].Freq; //Stats
+ StatsBuffer[len+plen+12] = CurrentChar.Inventory[i].Hand; //Stats
+ StatsBuffer[len+plen+13] = CurrentChar.Inventory[i].Rng; //Stats
+ StatsBuffer[len+plen+14] = CurrentChar.Inventory[i].MaxDur; //Max Durability
+ StatsBuffer[len+plen+15] = 0x04; //Size or part
+ StatsBuffer[len+plen+16] = 0x00; //follow or ?
+ StatsBuffer[len+plen+17] = 0x01; //Ammo loaded?
+ StatsBuffer[len+plen+18] = 0x04; //0x04 if not named, 0x0a if named
+ StatsBuffer[len+plen+19] = 0x05; //0x06 if named, 0xff for no ammo needed, no idea otherwise
+ StatsBuffer[len+plen+20] = 0x0f; //Binary representation of ammo allowed 0x01 = normal
+ plen+=21;
+ }
+ else
+ {
+ *(unsigned short*)&StatsBuffer[len+plen] = 6; //Size of Item Data
+ *(unsigned short*)&StatsBuffer[len+plen+2] = CurrentChar.Inventory[i].LocX; //Slot
+ *(unsigned short*)&StatsBuffer[len+plen+4] = CurrentChar.Inventory[i].ItemID; //Item ID
+ *(unsigned short*)&StatsBuffer[len+plen+6] = CurrentChar.Inventory[i].Qty; //Quantity
+ plen+= 8;
+ }
+ StatsBuffer[len+3] += 1;*/
+
+ *BaselineMsg << ( uint16_t )SectionMsg.GetSize();
+ *BaselineMsg << SectionMsg;
+ SectionMsg.Reset();
+
+ // ---- Section 7 ----
+ *BaselineMsg << ( uint8_t )0x07; // section id
+
+ SectionMsg << ( uint8_t )0x00; // ?? // section content at offset 3
+
+ *BaselineMsg << ( uint16_t )SectionMsg.GetSize();
+ *BaselineMsg << SectionMsg;
+ SectionMsg.Reset();
+
+ // ---- Section 0c ----
+ *BaselineMsg << ( uint8_t )0x0c; // section id
+
+ ContentList = BuildContainerContentList( nChar->GetInventory()->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;
+}
+ */\r
+// NPC Dialog. Start dialog with NPC\r
+PMessage* PMsgBuilder::BuildNPCStartDialogMsg( PClient* nClient, uint32_t nNPCWorldID, std::string *nDialogScript )\r
+ {\r
+ PMessage* tmpMsg = new PMessage();\r
+ nClient->IncreaseUDP_ID();\r
+ \r
+ \r
+ *tmpMsg << ( uint8_t )0x13;\r
+ *tmpMsg << ( uint16_t ) 0x0000; // UDP Placeholder\r
+ *tmpMsg << ( uint16_t ) 0x0000; // UDP Placeholder\r
+ *tmpMsg << ( uint8_t )0x00; // Message length\r
+ *tmpMsg << ( uint8_t )0x03;\r
+ *tmpMsg << ( uint16_t )nClient->GetUDP_ID();\r
+ *tmpMsg << ( uint8_t )0x1f;\r
+ *tmpMsg << ( uint16_t )nClient->GetLocalID();\r
+ *tmpMsg << ( uint8_t )0x18;\r
+ *tmpMsg << ( uint32_t ) nNPCWorldID;\r
+ \r
+ // Todo: is this correct? random uint32_t value??\r
+ *tmpMsg << ( uint16_t ) GetRandom( 65535, 4369 );\r
+ *tmpMsg << ( uint16_t ) GetRandom( 65535, 4369 );\r
+ *tmpMsg << ( uint32_t ) 0x0000;\r
+ *tmpMsg << nDialogScript->c_str();\r
+ ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 );\r
+ \r
+ nClient->IncreaseUDP_ID();\r
+ \r
+ *tmpMsg << ( uint8_t )0x0a;\r
+ *tmpMsg << ( uint8_t )0x03;\r
+ *tmpMsg << ( uint16_t )nClient->GetUDP_ID();\r
+ *tmpMsg << ( uint8_t )0x1f;\r
+ *tmpMsg << ( uint16_t )nClient->GetLocalID();\r
+ *tmpMsg << ( uint8_t )0x1a;\r
+ *tmpMsg << ( uint8_t )0x00;\r
+ *tmpMsg << ( uint8_t )0x00;\r
+ *tmpMsg << ( uint8_t )0x00;\r
+ \r
+ tmpMsg->U16Data( 1 ) = nClient->GetUDP_ID();\r
+ tmpMsg->U16Data( 3 ) = nClient->GetSessionID();\r
+ \r
+ return tmpMsg;\r
+ }\r
+// NPC Dialog. Send next node number in lua script to client\r
+PMessage* PMsgBuilder::BuildNPCDialogReplyMsg( PClient* nClient, uint16_t nNextNode, std::vector<int>*nResultBuffer)\r
+ {\r
+ PMessage* tmpMsg = new PMessage();\r
+ \r
+ nClient->IncreaseUDP_ID();\r
+ \r
+ *tmpMsg << ( uint8_t )0x13;\r
+ *tmpMsg << ( uint16_t )nClient->GetUDP_ID();;\r
+ *tmpMsg << ( uint16_t )nClient->GetSessionID();;\r
+ *tmpMsg << ( uint8_t )0x00; // SubMessage length;\r
+ \r
+ *tmpMsg << ( uint8_t )0x03;\r
+ *tmpMsg << ( uint16_t )nClient->GetUDP_ID();;\r
+ *tmpMsg << ( uint8_t )0x1f;\r
+ *tmpMsg << ( uint16_t )nClient->GetLocalID();\r
+ *tmpMsg << ( uint8_t )0x1a;\r
+ *tmpMsg << ( uint16_t )nNextNode;\r
+ //*tmpMsg << ( uint8_t )nNumResults;\r
+ *tmpMsg << ( uint8_t )nResultBuffer->size();\r
+ \r
+ std::vector<int>::const_iterator it;\r
+ \r
+ for(it = nResultBuffer->begin(); it != nResultBuffer->end(); it++)\r
+ {\r
+ *tmpMsg << ( float )*(it);\r
+ }\r
+ \r
+ ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 );\r
+ \r
+ return tmpMsg;\r
+ }\r
+
+PMessage* PMsgBuilder::BuildNPCBeginAllBuyerTradeMsg( PClient* nClient, int nWorldID )\r
+ {\r
+ PMessage* tmpMsg = new PMessage();\r
+ nClient->IncreaseUDP_ID();\r
+ \r
+ *tmpMsg << ( uint8_t )0x13;\r
+ *tmpMsg << ( uint16_t )nClient->GetUDP_ID();\r
+ *tmpMsg << ( uint16_t )nClient->GetSessionID();\r
+ *tmpMsg << ( uint8_t )0x00; // Message length\r
+ *tmpMsg << ( uint8_t )0x03;\r
+ *tmpMsg << ( uint16_t )nClient->GetUDP_ID();\r
+ *tmpMsg << ( uint8_t )0x1f;\r
+ *tmpMsg << ( uint16_t )nClient->GetLocalID();\r
+ *tmpMsg << ( uint8_t )0x26;\r
+ *tmpMsg << ( uint32_t ) nWorldID;\r
+ *tmpMsg << ( uint8_t )0x01; // Traders inventory\r
+ *tmpMsg << ( uint16_t )0xFFFF; // Traders inventory\r
+ \r
+ ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 );\r
+ \r
+ return tmpMsg;\r
+ }\r
+ \r
+PMessage* PMsgBuilder::BuildNPCShoppingListMsg( PClient* nClient, PMessage* nContentList, int nWorldID, uint8_t nItemQuality)\r
+ {\r
+ PMessage* tmpMsg = new PMessage();\r
+ nClient->IncreaseUDP_ID();\r
+ \r
+ *tmpMsg << ( uint8_t )0x13;\r
+ *tmpMsg << ( uint16_t )nClient->GetUDP_ID();\r
+ *tmpMsg << ( uint16_t )nClient->GetSessionID();\r
+ *tmpMsg << ( uint8_t )0x00; // Message length\r
+ *tmpMsg << ( uint8_t )0x03;\r
+ *tmpMsg << ( uint16_t )nClient->GetUDP_ID();\r
+ *tmpMsg << ( uint8_t )0x1f;\r
+ *tmpMsg << ( uint16_t )nClient->GetLocalID();\r
+ *tmpMsg << ( uint8_t )0x26;\r
+ *tmpMsg << ( uint32_t ) nWorldID;\r
+ *tmpMsg << ( uint8_t )0x01; // Traders inventory\r
+ *tmpMsg << ( uint16_t )( nContentList->GetSize() / 6 ); // List entries\r
+ *tmpMsg << ( uint8_t )nItemQuality; // Items quality\r
+ *tmpMsg << *nContentList;\r
+ \r
+ ( *tmpMsg )[5] = ( uint8_t )( tmpMsg->GetSize() - 6 );\r
+ \r
+ return tmpMsg;\r
+ }\r
+ \r
+// ==========================\r
+PMessage* PMsgBuilder::BuildNPCSingleInfoMsg( PClient* nClient, uint32_t nWorldID, uint16_t nTypeID, uint16_t nClothing,\r
+uint16_t nNameID, uint16_t nPosY, uint16_t nPosZ, uint16_t nPosX, uint16_t nUnknown,\r
+uint16_t nTraderID, std::string *nAngleStr, std::string *nNpcName, std::string *nCustomName)\r
+// Initial NPC Packet that defines how the NPC look, etc\r
+ {\r
+// uint8_t tMsgLen = 29 + nNpcName->size() + nAngleStr->size() + nCustomName->size();\r
+ \r
+ PMessage* tmpMsg = new PMessage();\r
+ nClient->IncreaseUDP_ID();\r
+ \r
+ *tmpMsg << ( uint8_t )0x13; // Begin UDP message\r
+ *tmpMsg << ( uint16_t )nClient->GetUDP_ID();\r
+ *tmpMsg << ( uint16_t )nClient->GetSessionID();\r
+ *tmpMsg << ( uint8_t )0x00;\r
+ *tmpMsg << ( uint8_t )0x03;\r
+ *tmpMsg << ( uint16_t )nClient->GetUDP_ID();\r
+ *tmpMsg << ( uint8_t )0x28;\r
+ *tmpMsg << ( uint8_t )0x00;\r
+ *tmpMsg << ( uint8_t )0x01;\r
+ *tmpMsg << ( uint32_t )nWorldID;\r
+ *tmpMsg << ( uint16_t )nTypeID;\r
+ *tmpMsg << ( uint16_t )nClothing;\r
+ *tmpMsg << ( uint16_t )nNameID;\r
+ *tmpMsg << ( uint16_t )nPosY;\r
+ *tmpMsg << ( uint16_t )nPosZ;\r
+ *tmpMsg << ( uint16_t )nPosX;\r
+ *tmpMsg << ( uint8_t )0x00;\r
+ *tmpMsg << ( uint16_t )nUnknown;\r
+ *tmpMsg << ( uint16_t )nTraderID;\r
+ *tmpMsg << nNpcName->c_str();\r
+ *tmpMsg << nAngleStr->c_str();\r
+ if(nCustomName->length() > 1)\r
+ *tmpMsg << nCustomName->c_str();\r
+ \r
+ (*tmpMsg)[5] = (uint8_t)(tmpMsg->GetSize() - 6);\r
+ return tmpMsg;\r
+ }\r
+ \r
+PMessage* PMsgBuilder::BuildNPCMassInfoMsg( uint32_t nWorldID, uint16_t nTypeID, uint16_t nClothing,\r
+uint16_t nNameID, uint16_t nPosY, uint16_t nPosZ, uint16_t nPosX, uint16_t nHealth,\r
+uint16_t nTraderID, std::string *nAngleStr, std::string *nNpcName, std::string *nCustomName)\r
+// Initial NPC Packet that defines how the NPC look, etc\r
+ {\r
+// uint8_t tMsgLen = 29 + nNpcName->size() + nAngleStr->size() + nCustomName->size();\r
+ \r
+ PMessage* tmpMsg = new PMessage();\r
+ \r
+ *tmpMsg << ( uint8_t )0x13; // Begin UDP message\r
+ *tmpMsg << ( uint16_t )0x0000;\r
+ *tmpMsg << ( uint16_t )0x0000;\r
+ *tmpMsg << ( uint8_t )0x00;\r
+ *tmpMsg << ( uint8_t )0x03;\r
+ *tmpMsg << ( uint16_t )0x0000;\r
+ *tmpMsg << ( uint8_t )0x28;\r
+ *tmpMsg << ( uint8_t )0x00;\r
+ *tmpMsg << ( uint8_t )0x01;\r
+ *tmpMsg << ( uint32_t )nWorldID;\r
+ *tmpMsg << ( uint16_t )nTypeID;\r
+ *tmpMsg << ( uint16_t )nClothing;\r
+ *tmpMsg << ( uint16_t )nNameID;\r
+ *tmpMsg << ( uint16_t )nPosY;\r
+ *tmpMsg << ( uint16_t )nPosZ;\r
+ *tmpMsg << ( uint16_t )nPosX;\r
+ *tmpMsg << ( uint8_t )0x00;\r
+ *tmpMsg << ( uint16_t )nHealth;\r
+ *tmpMsg << ( uint16_t )nTraderID;\r
+ *tmpMsg << nNpcName->c_str();\r
+ *tmpMsg << nAngleStr->c_str();\r
+ if(nCustomName->length() > 1)\r
+ *tmpMsg << nCustomName->c_str();\r
+ \r
+ (*tmpMsg)[5] = (uint8_t)(tmpMsg->GetSize() - 6);\r
+ return tmpMsg;\r
+ }\r
+ \r
+// **************\r
+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)\r
+ {\r
+ PMessage* tmpMsg = new PMessage();\r
+ \r
+ *tmpMsg << ( uint8_t )0x13;\r
+ *tmpMsg << ( uint16_t )0x0000;\r
+ *tmpMsg << ( uint16_t )0x0000;\r
+ *tmpMsg << ( uint8_t )0x00; // len\r
+ *tmpMsg << ( uint8_t )0x1b; // NPC Update\r
+ *tmpMsg << ( uint32_t )nWorldID; // NPCs world ID\r
+ *tmpMsg << ( uint8_t )0x1f; // Parameters\r
+ *tmpMsg << ( uint16_t )nPosY; // Position Y\r
+ *tmpMsg << ( uint16_t )nPosZ; // Position Z\r
+ *tmpMsg << ( uint16_t )nPosX; // Position X\r
+ *tmpMsg << ( uint8_t )nActionBM; // NPCs current action-bitmask\r
+ *tmpMsg << ( uint16_t )nHealth; // Health value\r
+ if(nTargetID > 0)\r
+ *tmpMsg << ( uint32_t )nTargetID; // WorldID of NPCs target (if any)\r
+ *tmpMsg << ( uint8_t )nUnknown;\r
+ *tmpMsg << ( uint8_t )nWeaponState;\r
+ \r
+ (*tmpMsg)[5] = (uint8_t)(tmpMsg->GetSize() - 6);\r
+ \r
+ return tmpMsg;\r
+ }\r
+// **************\r
+ \r
+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 )\r
+ {\r
+ PMessage* tmpMsg = new PMessage();\r
+ \r
+ *tmpMsg << ( uint8_t )0x13; // Begin UDP message\r
+ *tmpMsg << ( uint16_t )nClient->GetUDP_ID();\r
+ *tmpMsg << ( uint16_t )nClient->GetSessionID();\r
+ *tmpMsg << ( uint8_t )0x11;\r
+ *tmpMsg << ( uint8_t )0x1B;\r
+ *tmpMsg << ( uint32_t )nWorldID;\r
+ *tmpMsg << ( uint8_t )0x1F;\r
+ *tmpMsg << ( uint16_t )nY;\r
+ *tmpMsg << ( uint16_t )nZ;\r
+ *tmpMsg << ( uint16_t )nX;\r
+ *tmpMsg << ( uint8_t )nActionStatus;\r
+ *tmpMsg << ( uint8_t )0x00;\r
+ *tmpMsg << ( uint8_t )nHealth;\r
+ *tmpMsg << ( uint8_t )0x00;\r
+ *tmpMsg << ( uint8_t )nAction;\r
+ \r
+ return tmpMsg;\r
+ }\r
+ \r
+PMessage* PMsgBuilder::BuildNPCMassAliveMsg( uint32_t nWorldID, uint16_t nX, uint16_t nY, uint16_t nZ, uint8_t nActionStatus, uint8_t nHealth, uint8_t nAction )\r
+ {\r
+ PMessage* tmpMsg = new PMessage();\r
+ \r
+ *tmpMsg << ( uint8_t )0x13; // Begin UDP message\r
+ *tmpMsg << ( uint16_t )0x0000;\r
+ *tmpMsg << ( uint16_t )0x0000;\r
+ *tmpMsg << ( uint8_t )0x11;\r
+ *tmpMsg << ( uint8_t )0x1B;\r
+ *tmpMsg << ( uint32_t )nWorldID;\r
+ *tmpMsg << ( uint8_t )0x1F;\r
+ *tmpMsg << ( uint16_t )nY;\r
+ *tmpMsg << ( uint16_t )nZ;\r
+ *tmpMsg << ( uint16_t )nX;\r
+ *tmpMsg << ( uint8_t )nActionStatus;\r
+ *tmpMsg << ( uint8_t )0x00;\r
+ *tmpMsg << ( uint8_t )nHealth;\r
+ *tmpMsg << ( uint8_t )0x00;\r
+ *tmpMsg << ( uint8_t )nAction;\r
+ \r
+ return tmpMsg;\r
+ }\r
+ \r
+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 )\r
+ {\r
+ PMessage* tmpMsg = new PMessage();\r
+ \r
+ *tmpMsg << ( uint8_t )0x13; // Begin UDP message\r
+ *tmpMsg << ( uint16_t )0x0000;\r
+ *tmpMsg << ( uint16_t )0x0000;\r
+ *tmpMsg << ( uint8_t )0x15; // Message length\r
+ *tmpMsg << ( uint8_t )0x1b;\r
+ *tmpMsg << ( uint32_t )nWorldID;\r
+ *tmpMsg << ( uint8_t )0x1F;\r
+ *tmpMsg << ( uint16_t )nY;\r
+ *tmpMsg << ( uint16_t )nZ;\r
+ *tmpMsg << ( uint16_t )nX;\r
+ *tmpMsg << ( uint8_t )nActionStatus;\r
+ *tmpMsg << ( uint8_t )0x77; // ?\r
+ *tmpMsg << ( uint8_t )nHealth;\r
+ *tmpMsg << ( uint16_t )nTarget;\r
+ *tmpMsg << ( uint8_t )0x00; // ?\r
+ *tmpMsg << ( uint8_t )0x00; // ?\r
+ *tmpMsg << ( uint8_t )0x00; // ?\r
+ *tmpMsg << ( uint8_t )nAction;\r
+ \r
+ return tmpMsg;\r
+ }\r
+ \r
+// ==========================\r
+ \r
+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 )\r
+ {\r
+ PMessage* tmpMsg = new PMessage();\r
+ \r
+ *tmpMsg << ( uint8_t )0x13; // Begin UDP message\r
+ *tmpMsg << ( uint16_t )nClient->GetUDP_ID();\r
+ *tmpMsg << ( uint16_t )nClient->GetSessionID();\r
+ *tmpMsg << ( uint8_t )0x15; // Message length\r
+ *tmpMsg << ( uint8_t )0x1b;\r
+ *tmpMsg << ( uint32_t )nWorldID;\r
+ *tmpMsg << ( uint8_t )0x1F;\r
+ *tmpMsg << ( uint16_t )nY;\r
+ *tmpMsg << ( uint16_t )nZ;\r
+ *tmpMsg << ( uint16_t )nX;\r
+ *tmpMsg << ( uint8_t )nActionStatus;\r
+ *tmpMsg << ( uint8_t )0x77; // ?\r
+ *tmpMsg << ( uint8_t )nHealth;\r
+ *tmpMsg << ( uint16_t )nTarget;\r
+ *tmpMsg << ( uint8_t )0x00; // ?\r
+ *tmpMsg << ( uint8_t )0x00; // ?\r
+ *tmpMsg << ( uint8_t )0x00; // ?\r
+ *tmpMsg << ( uint8_t )nAction;\r
+ \r
+ return tmpMsg;\r
+ }\r
+// ==========================\r
+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; i<PSubway::mCabsNumber; i++)
+ {
+ nClient->IncreaseUDP_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;
+ }\r
+ \r
+
+/*
+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 ?
+*/
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#include <string>
+#include <vector>
+
+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);\r
+ PMessage* BuildNPCMassAliveMsg( uint32_t nWorldID, uint16_t nX, uint16_t nY, uint16_t nZ, uint8_t nActionStatus, uint8_t nHealth, uint8_t nAction );\r
+ 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 );\r
+ // Moved here since its a zone broadcast!\r
+ PMessage* BuildNpcCleanupMsg( uint32_t nNpcId, uint8_t nCmd = 6 ); // see implementation about nCmd\r
+
+// 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 );\r
+ PMessage* BuildTryAccessAnswerMsg(PClient* nClient, char *nArea, bool nAllowed);\r
+ PMessage* BuildReceiveDBAnswerMsg( PClient* nClient, PMessage* nResultBuffer, std::string* nCommandName, uint16_t nNumRows, uint16_t nNumFields);\r
+ PMessage* BuildYouGotEmailsMsg( PClient* nClient, uint8_t nMailCount );\r
+ \r
+ PMessage* BuildNPCStartDialogMsg( PClient* nClient, uint32_t nNPCWorldID, std::string *nDialogScript );\r
+ PMessage* BuildNPCDialogReplyMsg( PClient* nClient, uint16_t nNextNode, std::vector<int>*nResultBuffer);\r
+ PMessage* BuildReqNPCScriptAnswerMsg( uint32_t nInfoId, std::string *nNPCScript );\r
+ PMessage* BuildNPCShoppingListMsg( PClient* nClient, PMessage* nContentList, int nWorldID, uint8_t nItemQuality);\r
+ PMessage* BuildNPCBeginAllBuyerTradeMsg( PClient* nClient, int nWorldID );\r
+ \r
+ 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);\r
+ 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 );\r
+ 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 );\r
+ \r
+ // NEW for testing. Combined update message\r
+ 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);\r
+ \r
+ 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 );
+};
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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()
{
}
-void PMultiPart::AssembleChunk(u16 nSequence)
+void PMultiPart::AssembleChunk(uint16_t nSequence)
{
// Get the sequence number
PMultipartMap::iterator it;
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);
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;
{
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);
}
// 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;
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#include <map>
+#include <vector>
+
+#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<s_MessageChunk> 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<uint8_t, s_SequenceEntry> PMultipartMap; // Map of all vectors, indexed by sequencenumber <uint8_t>
+
+
+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);
+};
- /*
-TinNS (TinNS is not a Neocron Server)
-Copyright (C) 2005 Linux Addicted Community
-maintainer Akiko <akiko@gmx.org>
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public 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"\r
-#include "include/msgbuilder.h"\r
-
- ///***********************************************************************
-\r
-// Reload LUA script while running, in case we modified it and dont want to restart the entire server\r
+#include <algorithm>
+#include <cstring>
+#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()\r
{\r
// Erase current LUA script\r
// Reload it\r
return LoadLUAScript();\r
}\r
-
-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??\r
+
+ mNameID = (uint16_t)t_defNPC->GetNPCTypeID(); // 16 or 32??\r
const PDefNpc* t_NpcTypeDef = GameDefs->Npcs()->GetDef(mNameID);\r
if(!t_NpcTypeDef)\r
{\r
Console->Print("%s [PNPC::DEF_Load()] Unknown NPC Type %d in .dat file found", Console->ColorText(RED,BLACK, "[Error]"), mNameID);\r
return false;\r
}
-
+
// TODO: Find out what exactly these TypeID and ClothingID values do and where they are generated/read\r
// 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;
mFaction = t_NpcTypeDef->GetFaction();
// WorldID Fix 10.10.2009
mFromDEF = true;
-
+
mName = t_defNPC->GetActorName();
\r
\r
\r
bool PNPC::LoadLUAScript()\r
{\r
- u32 tFileLen = 0;\r
+ uint32_t tFileLen = 0;\r
PFile* fLua = NULL;\r
std::string tLuaFile = "";\r
std::string tHDRFile = "";\r
return false;\r
}\r
}\r
-
+
void PNPC::Die()
{
if ( gDevDebug ) Console->Print( "[DEBUG] NPC dying now" );
mRespawn = std::time( NULL ) + NPC_RESPAWN_AFTER;
mDirty = true;
}
-
+
void PNPC::Update()
{\r
// Has to be changed for mobs later
mNextUpdate = std::time(NULL) + GetRandom(30, 10);
}
\r
-void PNPC::Attack( u32 nWorldID, u8 nType, u8 nUnknown )\r
+void PNPC::Attack( uint32_t nWorldID, uint8_t nType, uint8_t nUnknown )\r
{\r
mDirty = true;\r
mTarget = nWorldID;\r
mWeaponStatus = nType;\r
mUnknown = nUnknown;\r
}\r
-
+
PNPC::PNPC( int nSQLID )
{
InitVars();
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);
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 )
{
}\r
\r
\r
-bool PNPCWorld::AddNPC(u32 nSQL_ID, u32 nRaw_ID)\r
+bool PNPCWorld::AddNPC(uint32_t nSQL_ID, uint32_t nRaw_ID)\r
{\r
PNPC* tmpNpc = new PNPC( nSQL_ID );\r
if(tmpNpc->mSuccess == true)\r
return true;\r
}\r
\r
-void PNPCWorld::DelNPC(u32 nWorldID)\r
+void PNPCWorld::DelNPC(uint32_t nWorldID)\r
{\r
PNPCMap::iterator it = mNPCs.find( nWorldID );\r
if ( it == mNPCs.end() )\r
nClient->SendUDPMessage( tmpMsg );\r
return;\r
}\r
-
+
void PNPCWorld::MSG_SendNPCs( PClient* nClient )
{\r
PNPC* nNpc = NULL;\r
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 );
}
//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 ) ) )
{
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
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;
LoadNPCfromSQL();
LoadNPCfromDEF();
}
-
+
PNPCWorld::~PNPCWorld()
{
if ( gDevDebug ) Console->Print( "[DEBUG] Erasing all NPCs" );
return;\r
}
*/\r
- 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 );
else
return it->second;
}
-
+
///***********************************************************************
-
+
PNPCManager::PNPCManager()
{
if ( gDevDebug ) Console->Print( "[DEBUG] NPCManager wakeup!" );
// Nothing yet
}
-
+
PNPCManager::~PNPCManager()
{
if ( gDevDebug ) Console->Print( "[DEBUG] NPCManager shutdown" );
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" );
//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;
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
{
//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))
{
//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 );
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
+#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 <chrono>
+#include <cstdint>
+#include <map>
+#include <vector>
+#include <string>
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
- \r
// Healthfactor for NPCs (see old npc.def)\r
#define NPC_HEALTHFACTOR 15\r
\r
class PNPC;
class PNPCWorld;
-typedef std::map<u32, PNPC*> PNPCMap;
-typedef std::map<u32, PNPCWorld*> PNPCWorldMap;
+typedef std::map<uint32_t, PNPC*> PNPCMap;
+typedef std::map<uint32_t, PNPCWorld*> PNPCWorldMap;
\r
typedef struct
{
- u16 ItemID;\r
- u32 Price;
+ uint16_t ItemID;\r
+ uint32_t Price;
} stShopListEntry;
\r
class PNPC
npc_scripting
};
\r
- std::time_t mNextUpdate; // Timestamp for next heartbeat\r
- std::time_t mNextEnemyCheck; // Timestamp for next enemycheck\r
- inline void PushUpdateTimer() { mNextUpdate = std::time(NULL) + GetRandom(NPC_HEARTBEAT_MAX, NPC_HEARTBEAT_MIN); };\r
+ time_t mNextUpdate; // Timestamp for next heartbeat\r
+ time_t mNextEnemyCheck; // Timestamp for next enemycheck\r
+ 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;\r
- u8 mItemQuality; // Used for Shopping stuff\r
- u8 mUnknown;\r
+ 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;\r
+ uint8_t mItemQuality; // Used for Shopping stuff\r
+ uint8_t mUnknown;\r
\r
std::string mDialogScript;\r
std::string mLUAFile; // Load File; Preloaded uppon NPC creation\r
\r
std::vector<stShopListEntry> mVectItemsInShop; // We need to keep track of the itemorder for shopping\r
- void AddToVectorList(u16 nItemID, u32 nPrice);\r
- inline const stShopListEntry* GetItemNum(u32 nIdx) const { if(nIdx > mVectItemsInShop.size()) { return NULL; } else { return &mVectItemsInShop[nIdx]; }};\r
+ void AddToVectorList(uint16_t nItemID, uint32_t nPrice);\r
+ inline const stShopListEntry* GetItemNum(uint32_t nIdx) const { if(nIdx > mVectItemsInShop.size()) { return NULL; } else { return &mVectItemsInShop[nIdx]; }};\r
\r
bool mScripting; // Manual override to disable scripting for an NPC TRUE: Scripts will be executed FALSE: Scripts will be ignored\r
std::string mCustomName;
std::string mCustomLua;
- std::time_t mRespawn; // Respawn timer
+ time_t mRespawn; // Respawn timer
// Runtime values
//bool mDeath; // Death...\r
- u8 mFaction; // NPC's faction\r
+ uint8_t mFaction; // NPC's faction\r
- u16 mHealth; // NPC Current Health-Value\r
- u16 mMaxHealth; // NPC Max Health value\r
- u32 mTarget; // Current focused player
+ uint16_t mHealth; // NPC Current Health-Value\r
+ uint16_t mMaxHealth; // NPC Max Health value\r
+ uint32_t mTarget; // Current focused player
bool mDirty; // Needs update to clients
// WorldID Fix 10.10.2009
bool mSuccess; // NPC load successfull?\r
\r
- u8 mAction; // Current action\r
- inline u8 GetActionStatus() const { return mAction; };\r
+ uint8_t mAction; // Current action\r
+ inline uint8_t GetActionStatus() const { return mAction; };\r
// 00000001 ( 1) 0x01: Attack-Mode (Depends on WeaponStatus)\r
// 00000010 ( 2) 0x02: ?\r
// 00000100 ( 4) 0x04: ?\r
// 01000000 ( 64) 0x40: Idle\r
// 10000000 (128) 0x80: Die\r
\r
- u8 mWeaponStatus;\r
- inline u8 GetWeaponStatus() const { return mWeaponStatus; };\r
+ uint8_t mWeaponStatus;\r
+ inline uint8_t GetWeaponStatus() const { return mWeaponStatus; };\r
// 00001111 (15) 0x0F: Follow given target with eyes / Put weapon away if pulled\r
// 00010000 (16) 0x10: Pull weapon if not pulled / If pulled, attack\r
// 00010001 (17) 0x11: Pull weapon and attack\r
\r
bool SQL_Load();
- bool DEF_Load(u32 nWorldID);
+ bool DEF_Load(uint32_t nWorldID);
\r
PNPC( int nSQLID );\r
- PNPC( int nDEFID, u32 nWorldID );\r
+ PNPC( int nDEFID, uint32_t nWorldID );\r
~PNPC();\r
\r
void InitVars();\r
- void ContentListAddItem(PMessage* nContentList, u16 nItemID, u32 nBasePrice = 0, bool nAddToList = true);\r
- void ContentListAddItemGroup(PMessage* nContentList, u32 nItemGroupID);\r
+ void ContentListAddItem(PMessage* nContentList, uint16_t nItemID, uint32_t nBasePrice = 0, bool nAddToList = true);\r
+ void ContentListAddItemGroup(PMessage* nContentList, uint32_t nItemGroupID);\r
void StartDialog( PClient* nClient/*, string &nDialogscript */);\r
\r
bool DoSQLShoppingList( PClient* nClient, PMessage* nContentList );\r
bool IsAllbuyer( PClient* nClient );\r
bool LoadLUAScript();\r
\r
- 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;
\r
inline void StopAttack() { mDirty = true; mAction = NPC_ACTIONSTATE_IDLE; mWeaponStatus = NPC_SHOOT_IDLE; };\r
- inline void Attack( PClient* nClient, u8 nType = NPC_SHOOT_SINGLE, u8 nUnknown = 90 ) { Attack(nClient->GetChar()->GetID(), nType, nUnknown); };\r
- void Attack( u32 nWorldID, u8 nType = NPC_SHOOT_SINGLE, u8 nUnknown = 90 );\r
+ inline void Attack( PClient* nClient, uint8_t nType = NPC_SHOOT_SINGLE, uint8_t nUnknown = 90 ) { Attack(nClient->GetChar()->GetID(), nType, nUnknown); };\r
+ void Attack( uint32_t nWorldID, uint8_t nType = NPC_SHOOT_SINGLE, uint8_t nUnknown = 90 );\r
\r
- 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;
void Die(); // ... die?
void Update(); // Check respawn timer
void StartConversation( PClient* nClient );\r
- void DoConversation( PClient* nClient, u8 nAnswer ) ;\r
+ void DoConversation( PClient* nClient, uint8_t nAnswer ) ;\r
\r
// GameCommands\r
bool ReloadLUAScript();\r
bool ReloadShopList();\r
- bool SetShopQuality(u8 nNewVal);\r
+ bool SetShopQuality(uint8_t nNewVal);\r
inline bool IsSQLNPC() const { return !mFromDEF; };\r
inline int GetNPCID() const { return mWorldID; };\r
inline int GetNPCSQLID() const { return mID; };\r
- inline void SetTrader( u16 nTraderDef ) { mTrader = nTraderDef; };\r
+ inline void SetTrader( uint16_t nTraderDef ) { mTrader = nTraderDef; };\r
inline void SetScripting(bool nVal) { mScripting = nVal; };\r
- inline u8 GetFaction() const { return mFaction; };\r
+ inline uint8_t GetFaction() const { return mFaction; };\r
};
// *****************************************
-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()
bool mSuccessfullInit;
- u32 mWorldID;
+ uint32_t mWorldID;
- PNPCWorld( u32 nWorldID );
+ PNPCWorld( uint32_t nWorldID );
~PNPCWorld();
void Update();
public:
friend class PNPCManager;
- PNPC* GetNPC( u32 nNPCID );\r
+ PNPC* GetNPC( uint32_t nNPCID );\r
\r
// Functions to add/remove an NPC while server is running\r
void SendSingleNPCInfo( PClient* nClient, PNPC* nNpc ); // Send\r
- bool AddNPC(u32 nSQL_ID, u32 nRaw_ID); // Load single SQL NPC from given SQL ID\r
- void DelNPC(u32 nWorldID); // Remove given NPC from list. Works for *all* npcs\r
+ bool AddNPC(uint32_t nSQL_ID, uint32_t nRaw_ID); // Load single SQL NPC from given SQL ID\r
+ void DelNPC(uint32_t nWorldID); // Remove given NPC from list. Works for *all* npcs\r
// but uppon zone reset they're back.
};
~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
-#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
// 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++ )
{
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)
-/*
-TinNS (TinNS is not a Neocron Server)
-Copyright (C) 2005 Linux Addicted Community
-maintainer Akiko <akiko@gmx.org>
+#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)
return true;
}
-void PNPC::AddToVectorList(u16 nItemID, u32 nPrice)
+void PNPC::AddToVectorList(uint16_t nItemID, uint32_t nPrice)
{
stShopListEntry tEntry;
tEntry.ItemID = nItemID;
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);
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<int, PDefItems*>::const_iterator itStart = GameDefs->Items()->ConstIteratorBegin();
for ( std::map<int, PDefItems*>::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;
return false;
}
- f32 tPerCent = Config->GetOptionInt("item_price");
+ float tPerCent = Config->GetOptionInt("item_price");
tPerCent = tPerCent / 100;
while((row = mysql_fetch_row(result)))
{
// 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();
// 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);
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);
{
// 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
// 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);
--- /dev/null
+#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 );
+}
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#include <map>
+
+struct s_floatcoords {
+ float mX;
+ float mY;
+ float mZ;
+};
+typedef std::map<uint32_t, s_floatcoords*> 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;
+ };
+};
-/*
-TinNS (TinNS is not a Neocron Server)
-Copyright (C) 2005 Linux Addicted Community
-maintainer Akiko <akiko@gmx.org>
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public 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()
{
{
}
-u32 POutpost::GetCurrentClan(u32 nOutpostID)
+uint32_t POutpost::GetCurrentClan(uint32_t nOutpostID)
{
MYSQL_RES *result = NULL;
char tQuery[200];
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
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);
--- /dev/null
+#pragma once
+
+#include <cstdint>
+
+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
+};
--- /dev/null
+#include "GameServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
+\r
+#if 0\r
+static const int RCON_INPUTLEN = 512;\r
+\r
+struct PRConClient\r
+{\r
+ enum\r
+ {\r
+ RCCS_AUTH,\r
+ RCCS_AUTH_USER,\r
+ RCCS_AUTH_PASS,\r
+ RCCS_VALID,\r
+ RCCS_DISCONNECT\r
+ } mState;\r
+\r
+ PSocket *mSocket;\r
+ PAccount *mAccount;\r
+ char mInput[RCON_INPUTLEN];\r
+ int mInputLen;\r
+ bool mEcho;\r
+ std::clock_t mSleep, mSleepStart;\r
+ int mNumFailures;\r
+\r
+ inline PRConClient(NLsocket &Sock)\r
+ {\r
+ mSocket = new PSocket(Sock);\r
+ mAccount = 0;\r
+ mInputLen = 0;\r
+ mEcho = true;\r
+ mSleep = 0;\r
+ mSleepStart = 0;\r
+ mNumFailures = 0;\r
+ }\r
+\r
+ inline ~PRConClient()\r
+ {\r
+ delete mSocket;\r
+ }\r
+\r
+ inline void Print(const char *Fmt, ...)\r
+ {\r
+ static char Str[256];\r
+ va_list args;\r
+ va_start(args, Fmt);\r
+ vsnprintf(Str, 255, Fmt, args);\r
+ va_end(args);\r
+ mSocket->Write(Str);\r
+ }\r
+\r
+};\r
+\r
+PRConsole::PRConsole()\r
+{\r
+ mListener = NL_INVALID;\r
+}\r
+\r
+PRConsole::~PRConsole()\r
+{\r
+ if(mListener != NL_INVALID)\r
+ nlClose(mListener);\r
+\r
+ for(ClientList::iterator i=mClients.begin(); i!=mClients.end(); i++)\r
+ delete *i;\r
+}\r
+\r
+void PRConsole::Start()\r
+{\r
+ // CHECK FOR rconsole enabled!!!\r
+ Console->LPrint("Starting remote console...");\r
+ uint16_t Port = Config->GetOptionInt("rconsole_port");\r
+ mListener = nlOpen(Port, NL_TCP);\r
+ if(mListener == NL_INVALID)\r
+ {\r
+ Console->LPrint(RED, BLACK, "[ERROR]");\r
+ Console->LPrint(" Remote console failed");\r
+ Console->LClose();\r
+ return;\r
+ }\r
+\r
+ Console->LPrint(GREEN, BLACK, "Success");\r
+ Console->LClose();\r
+ nlListen(mListener);\r
+}\r
+\r
+void PRConsole::Update()\r
+{\r
+ if(mListener==NL_INVALID)\r
+ return;\r
+\r
+ NLsocket temp = nlAcceptConnection(mListener);\r
+ if(temp != NL_INVALID)\r
+ {\r
+ // TODO: print client ip addr\r
+ Console->Print("RConsole: client connected");\r
+ PRConClient *cl = new PRConClient(temp);\r
+ cl->mState = PRConClient::RCCS_AUTH;\r
+ mClients.push_back(cl);\r
+ cl->Print("TinNS shell [%s]\r\n", TINNS_VERSION);\r
+ }\r
+\r
+ for(ClientList::iterator i=mClients.begin(); i!=mClients.end();)\r
+ {\r
+ ClientList::iterator j=i;\r
+ PRConClient *cl = *i;\r
+ ++i;\r
+ if(!cl->mSocket->Update() || cl->mSocket->TimeOut())\r
+ {\r
+ Console->Print("RConsole: client disconnected");\r
+ mClients.erase(j);\r
+ delete cl;\r
+ continue;\r
+ }\r
+\r
+ if(cl->mSleep > 0)\r
+ {\r
+ std::clock_t t = std::clock();\r
+ cl->mSleep -= (t-cl->mSleepStart);\r
+ cl->mSleepStart = t;\r
+\r
+ if(cl->mSleep < 0)\r
+ cl->mSleep = 0;\r
+\r
+ // flush socket while sleeping\r
+ int Size=0;\r
+ cl->mSocket->Read(&Size);\r
+\r
+ continue;\r
+ }\r
+\r
+ if(cl->mState==PRConClient::RCCS_AUTH)\r
+ {\r
+ cl->Print("\r\nlogin: ");\r
+ cl->mState = PRConClient::RCCS_AUTH_USER;\r
+ }\r
+\r
+ const uint8_t *Buf = 0;\r
+ int Size=0;\r
+ if((bool)(Buf = cl->mSocket->Read(&Size)))\r
+ {\r
+ for(int i=0; i<Size; i++)\r
+ if(cl->mInputLen < RCON_INPUTLEN)\r
+ {\r
+ switch(Buf[i])\r
+ {\r
+ case 0x08 :\r
+ {\r
+ if(cl->mInputLen > 0)\r
+ {\r
+ if(cl->mEcho)\r
+ cl->mSocket->Write(Buf[i]);\r
+ cl->mInput[cl->mInputLen]=0;\r
+ --cl->mInputLen;\r
+ }\r
+ break;\r
+ }\r
+\r
+ case '\n' :\r
+ {\r
+ if(cl->mEcho)\r
+ cl->mSocket->Write(Buf[i]);\r
+ cl->mInput[cl->mInputLen]=0;\r
+ ProcessClient(cl);\r
+ cl->mInputLen = 0;\r
+ break;\r
+ }\r
+\r
+ default :\r
+ {\r
+ cl->mInput[cl->mInputLen++]=Buf[i];\r
+ if(cl->mEcho)\r
+ cl->mSocket->Write(Buf[i]);\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+}\r
+\r
+void PRConsole::ProcessClient(PRConClient* Client)\r
+{\r
+ Console->Print(">%s", Client->mInput);\r
+ if(Client->mInputLen > 1)\r
+ {\r
+ if(Client->mInput[Client->mInputLen-1] == '\r')\r
+ Client->mInput[Client->mInputLen-1]=0;\r
+\r
+ if(Client->mState == PRConClient::RCCS_AUTH_USER)\r
+ {\r
+ Client->mAccount = Database->GetAccount(Client->mInput);\r
+ Client->mState = PRConClient::RCCS_AUTH_PASS;\r
+ Client->Print("password: ");\r
+ Client->mEcho = false;\r
+ } else\r
+ if(Client->mState == PRConClient::RCCS_AUTH_PASS)\r
+ {\r
+ Client->mEcho = true;\r
+ if((!Client->mAccount) || (Client->mAccount->GetPassword() != Client->mInput) || (!Client->mAccount->IsConsoleAllowed()))\r
+ {\r
+ Client->Print("Invalid user or password\r\n");\r
+ Client->mSleepStart = std::clock();\r
+ ++Client->mNumFailures;\r
+ if(Client->mNumFailures >= 3)\r
+ {\r
+ // sleep 1 minute\r
+ Client->mSleep = 60*CLOCKS_PER_SEC;\r
+ Client->mNumFailures = 0;\r
+ } else\r
+ Client->mSleep = 5*CLOCKS_PER_SEC;\r
+\r
+ Client->mState = PRConClient::RCCS_AUTH;\r
+ } else\r
+ {\r
+ Client->Print("\r\n\nUser %s logged in\r\n", Client->mAccount->GetName().c_str());\r
+ Client->mState = PRConClient::RCCS_VALID;\r
+ // disconnect after 30 minutes lacking socket activity\r
+ Client->mSocket->SetTimeOutValue(1800);\r
+ Prompt(Client);\r
+ }\r
+ }\r
+ }\r
+}\r
+\r
+void PRConsole::Prompt(PRConClient *Client)\r
+{\r
+ Client->Print("$ ", Client->mAccount->GetName().c_str(), Config->GetOption("server_name").c_str());\r
+}\r
+#endif\r
--- /dev/null
+#pragma once\r
+\r
+#if 0\r
+#include <list>\r
+\r
+struct PRConClient;\r
+\r
+class PRConsole {\r
+private :\r
+ typedef std::list<PRConClient *> ClientList;\r
+ ClientList mClients;\r
+\r
+ void ProcessClient(PRConClient* Client);\r
+ void Prompt(PRConClient *Client);\r
+public :\r
+ PRConsole();\r
+ ~PRConsole();\r
+\r
+ void Start();\r
+ void Update();\r
+};\r
+#endif\r
--- /dev/null
+#include "GameServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
+\r
+PServer::PServer()\r
+{\r
+ mNumClients = 0;\r
+ mMaxClients = Config->GetOptionInt("maxclients");\r
+ mGMSlots = Config->GetOptionInt("gm_slots");\r
+ if(mMaxClients==0)\r
+ mMaxClients=1;\r
+ if(mGMSlots==0)\r
+ mGMSlots=1;\r
+ Console->Print("Max clients: %i / GM slots: %i", mMaxClients, mGMSlots);\r
+ mClients.reserve(mMaxClients + mGMSlots);\r
+ for(int i=0; i<mMaxClients+mGMSlots; i++)\r
+ mClients[i]=0;\r
+}\r
+\r
+PServer::~PServer()\r
+{\r
+ for(int i=0; i<mMaxClients+mGMSlots; i++)\r
+ delete mClients[i];\r
+}\r
+\r
+int PServer::NewClient()\r
+{\r
+ if(mNumClients==mMaxClients+mGMSlots)\r
+ return -1;\r
+\r
+ for(int i=0; i<mMaxClients+mGMSlots; i++)\r
+ {\r
+ if(!mClients[i])\r
+ {\r
+ mClients[i]=new PClient(i);\r
+ ++mNumClients;\r
+ return i;\r
+ }\r
+ }\r
+ return -1;\r
+}\r
+\r
+PClient *PServer::GetClient(int Client) const\r
+{\r
+ if(Client < 0 || Client >= mMaxClients+mGMSlots)\r
+ return 0;\r
+\r
+ return mClients[Client];\r
+}\r
+\r
+void PServer::Update()\r
+{\r
+ for(int i=0; i<mMaxClients+mGMSlots; i++)\r
+ {\r
+ if(mClients[i])\r
+ {\r
+ mClients[i]->Update();\r
+ if(mClients[i]->GetConnection()==PCC_NONE && mClients[i]->getTCPConn() == 0)\r
+ {\r
+ Console->Print("Removing client %i...", i);\r
+ delete mClients[i];\r
+ mClients[i]=0;\r
+ --mNumClients;\r
+ }\r
+ }\r
+ }\r
+}\r
+\r
+void PServer::Shutdown()\r
+{\r
+ Console->Print("======================");\r
+ Console->Print("Shutting down Gameserver...");\r
+ for(int i=0; i<mMaxClients+mGMSlots; i++)\r
+ {\r
+ if(mClients[i])\r
+ {\r
+ delete mClients[i];\r
+ mClients[i]=0;\r
+ }\r
+ }\r
+}\r
+\r
+//SELECT `s_name` , NOW( ) , `s_lastupdate` , NOW( ) - `s_lastupdate` FROM `server_list` \r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include <vector>\r
+\r
+class PClient;\r
+\r
+class PServer{\r
+private:\r
+ int32_t mMaxClients;\r
+ int32_t mGMSlots;\r
+ int32_t mNumClients;\r
+ std::vector<PClient*> mClients;\r
+\r
+public:\r
+ PServer();\r
+ ~PServer();\r
+\r
+ inline int32_t GetMaxClients() const { return mMaxClients; }\r
+ inline int32_t GetGMSlots() const { return mGMSlots; }\r
+ inline int32_t GetNumClients() const { return mNumClients; }\r
+ int NewClient();\r
+ PClient *GetClient(int Client) const;\r
+ void Update();\r
+ void Shutdown();\r
+};\r
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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)
{
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
+#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 <cstdint>
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
#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:
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;
int IncreaseSubSkill(SUB_SKILLS Skill);
- unsigned short GetSP(MAIN_SKILLS Skill);
+ uint16_t GetSP(MAIN_SKILLS Skill);
float GetXP(MAIN_SKILLS Skill);
};
-
-#endif
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- sql.cpp - handles all mysql interactions\r
-\r
- Authors:\r
- - Namikon\r
- - bakkdoor\r
-\r
- MODIFIED: 24 Dec 2005 Namikon\r
- REASON: - initial release by Namikon\r
- MODIFIED: 26 Dec 2005 Namikon\r
- REASON: - Fixed Connect and Query function\r
- - Added GetWorldDoorType() for door interaction\r
- - Added GetWorldItemType() for item interaction\r
- - Added GetWorldItemOption() for item interaction\r
- MODIFIED: 30 Dec 2005 bakkdoor\r
- REASON: - changed mysql_init() parameter to null to prevent segfault\r
- - added checking for dbHandle to prevent segfault\r
- MODIFIED: 01 Jan 2006 Namikon\r
- REASON: - Removed 2 Console outputs in ResQuery()\r
- - Added missing "return NULL" to ResQuery\r
- MODIFIED: 06 Jan 2006 Namikon\r
- REASON: - Added color to console outputs\r
- - Changed a few lines on the Get* functions (another std::atoi thing)\r
- MODIFIED: 26 Jul 2006 Hammag\r
- REASON: - Added CheckResCount() for DB Res memory leak tracking (to be done in the main loop)\r
- rather than through Info/GameResQuery()\r
- - fixed InfoDBInuse and GameDBInuse updating\r
- - inhibited Info/GameDBInuse warning message in Info/GameResQuery()\r
- MODIFIED: 27 Sep 2006 Hammag\r
- REASON: - Added GetAptLocation() method\r
- - Modified Apt & Item info methods as they should work, but it doesn't match the DB\r
- So commented out some changes\r
- DB shouln't be used anymore for that soon anyway\r
- MODIFIED: 25 Jun 2007 Hammag\r
- REASON: - Moved all Appartements related methods to PAppartements class\r
-\r
-*/\r
-#include "main.h"\r
+#include <cstring>\r
+#include "GameServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
PMySQL::PMySQL()\r
{\r
Console->Print("PMySQL::FreeGameSQLResult: Nothing to free...");\r
}\r
\r
-u32 PMySQL::EscapeString(const char* nText, char* dText, u32 dMaxLength)\r
+uint32_t PMySQL::EscapeString(const char* nText, char* dText, uint32_t dMaxLength)\r
{\r
- u32 nLength = strlen(nText);\r
- u32 tMax = (dMaxLength - 1)/2;\r
+ uint32_t nLength = strlen(nText);\r
+ uint32_t tMax = (dMaxLength - 1)/2;\r
if(nLength > tMax)\r
{\r
nLength = tMax;\r
}\r
- \r
+\r
return mysql_real_escape_string(game_dbHandle, dText, nText, nLength);\r
}\r
\r
--- /dev/null
+#pragma once\r
+\r
+#include <chrono>\r
+#include <cstdint>\r
+#ifdef MYSQL_INC_DIR\r
+#include <mysql/mysql.h>\r
+#else\r
+#include <mysql.h>\r
+#endif\r
+\r
+// TODO: take all non-pure SQL DB access stuff out of this class\r
+\r
+class PMySQL {\r
+private:\r
+ int info_port;\r
+ char info_host[100];\r
+ char info_userName[100];\r
+ char info_password[100];\r
+ char info_database[100];\r
+ MYSQL *info_dbHandle;\r
+ std::time_t mKeepaliveDelay;\r
+ std::time_t mLastKeepaliveSent;\r
+\r
+ int game_port;\r
+ char game_host[100];\r
+ char game_userName[100];\r
+ char game_password[100];\r
+ char game_database[100];\r
+ MYSQL *game_dbHandle;\r
+\r
+ int GameDBInuse;\r
+ int InfoDBInuse;\r
+\r
+public:\r
+ PMySQL();\r
+ ~PMySQL();\r
+\r
+ void Update();\r
+ void CheckResCount();\r
+\r
+ inline MYSQL *GetInfoHandle() { return info_dbHandle; };\r
+ inline MYSQL *GetGameHandle() { return game_dbHandle; };\r
+\r
+ bool Connect();\r
+\r
+ int InfoQuery(const char *query);\r
+ MYSQL_RES *InfoResQuery(const char *query);\r
+ int GameQuery(const char *query);\r
+ MYSQL_RES *GameResQuery(const char *query);\r
+\r
+ /*int GetWorldItemType(unsigned short ID, int Location);\r
+ int GetWorldItemOption(unsigned short ID, int Location, int option);\r
+ int GetWorldDoorType(unsigned int ID, int Location);*/\r
+\r
+ void ShowInfoSQLError();\r
+ void ShowGameSQLError();\r
+ void FreeGameSQLResult(MYSQL_RES *res);\r
+ void FreeInfoSQLResult(MYSQL_RES *res);\r
+\r
+ inline uint32_t GetLastGameInsertId() { return mysql_insert_id(game_dbHandle); };\r
+ inline uint32_t GetLastInfoInsertId() { return mysql_insert_id(info_dbHandle); };\r
+\r
+ uint32_t EscapeString(const char* nText, char* dText, uint32_t dMaxLength);\r
+};\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- subway.h - subway class\r
-\r
- MODIFIED: 9 Nov 2007 Hammag\r
- REASON: - creation\r
- MODIFIED: 09 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
-*/\r
+#include "GameServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
/*\r
(Real time)\r
Network delay = TBD\r
\r
Offset =MOD(M86-122778+(M85*29896);328860)\r
-\r
*/\r
\r
-\r
-#include "main.h"\r
-\r
-#include "include/subway.h"\r
-#include "include/chars.h" // for PCharCoordinates only\r
-\r
-\r
// Determines relative position of cabs, but how ???\r
-const u16 PSubway::mSubwayInitData [] = {0x4396, 0x4387, 0x4370, 0x4352, 0x4334, 0x4316, 0x42f0, 0x42b4, 0x4270, 0x41f0, 0x0000};\r
-const u32 PSubway::mCabLoopTime = 328860;\r
-const u32 PSubway::mCab0TimeOffset = 122778;\r
-const s32 PSubway::mTimingAdjust = 0;\r
-const u32 PSubway::mCabIntervalTime = 29896;\r
-const u32 PSubway::mOpenDoorOffset [] = { 0, 42500, 83000, 146800, 170700, 226200, 262800, 303200 };\r
-const u32 PSubway::mOpenDoorDuration [] = { 8500, 6900, 12000, 7500, 8800, 9000, 8500, 9300 };\r
+const uint16_t PSubway::mSubwayInitData [] = {0x4396, 0x4387, 0x4370, 0x4352, 0x4334, 0x4316, 0x42f0, 0x42b4, 0x4270, 0x41f0, 0x0000};\r
+const uint32_t PSubway::mCabLoopTime = 328860;\r
+const uint32_t PSubway::mCab0TimeOffset = 122778;\r
+const int32_t PSubway::mTimingAdjust = 0;\r
+const uint32_t PSubway::mCabIntervalTime = 29896;\r
+const uint32_t PSubway::mOpenDoorOffset [] = { 0, 42500, 83000, 146800, 170700, 226200, 262800, 303200 };\r
+const uint32_t PSubway::mOpenDoorDuration [] = { 8500, 6900, 12000, 7500, 8800, 9000, 8500, 9300 };\r
const char* PSubway::mSubwayStationName[] = { "Pla => Oz", "Vr => Oz", "Pp => Oz", "Oz end", "Oz => Pla", "Pp => Pla", "Vr => Pla", "Pla end" };\r
PCharCoordinates PSubway::mCabExitPositions [2][mStationsNumber];\r
\r
\r
PSubway::PSubway()\r
{\r
- for(u8 i=0; i<mCabsNumber; i++)\r
+ for(uint8_t i=0; i<mCabsNumber; i++)\r
{\r
mSubways[i].mVhcId = mCabsBaseId+i;\r
mSubways[i].mPosition = mSubwayInitData[i];\r
mSubways[i].mDoorOpened = 0;\r
- for(u8 j=0; j<4; j++)\r
+ for(uint8_t j=0; j<4; j++)\r
{\r
mSubways[i].mSeatUsersId[j] = 0;\r
}\r
}\r
- \r
+\r
mCabExitPositions[0][0].SetPosition(32000-5205, 32000-608, 32000-4766, 0x80, 0);\r
mCabExitPositions[1][0].SetPosition(32000-5764, 32000-608, 32000-4766, 0x80, 0);\r
\r
mCabExitPositions[0][1].SetPosition(32000+7290, 32000-600, 32000-500, 0x80, 45);\r
- mCabExitPositions[1][1].SetPosition(32000+7290, 32000-600, 32000-0, 0x80, 45); \r
+ mCabExitPositions[1][1].SetPosition(32000+7290, 32000-600, 32000-0, 0x80, 45);\r
\r
mCabExitPositions[0][2].SetPosition(32000-2300, 32000-600, 32000+7985, 0x80, 0);\r
- mCabExitPositions[1][2].SetPosition(32000-2850, 32000-600, 32000+7985, 0x80, 0); \r
+ mCabExitPositions[1][2].SetPosition(32000-2850, 32000-600, 32000+7985, 0x80, 0);\r
\r
mCabExitPositions[0][3].SetPosition(32000-1700, 32000-596, 32000+1840, 0x80, 90);\r
- mCabExitPositions[1][3].SetPosition(32000-1250, 32000-596, 32000+1840, 0x80, 90); \r
+ mCabExitPositions[1][3].SetPosition(32000-1250, 32000-596, 32000+1840, 0x80, 90);\r
\r
mCabExitPositions[0][4].SetPosition(32000-1700, 32000-596, 32000+1570, 0x80, 0);\r
- mCabExitPositions[1][4].SetPosition(32000-1250, 32000-596, 32000+1570, 0x80, 0); \r
- \r
+ mCabExitPositions[1][4].SetPosition(32000-1250, 32000-596, 32000+1570, 0x80, 0);\r
+\r
mCabExitPositions[0][5].SetPosition(32000-2300, 32000-600, 32000+8625, 0x80, 90);\r
- mCabExitPositions[1][5].SetPosition(32000-2850, 32000-600, 32000+8625, 0x80, 90); \r
- \r
+ mCabExitPositions[1][5].SetPosition(32000-2850, 32000-600, 32000+8625, 0x80, 90);\r
+\r
mCabExitPositions[0][6].SetPosition(32000+7815, 32000-600, 32000-500, 0x80, 135);\r
- mCabExitPositions[1][6].SetPosition(32000+7815, 32000-600, 32000-0, 0x80, 135); \r
- \r
+ mCabExitPositions[1][6].SetPosition(32000+7815, 32000-600, 32000-0, 0x80, 135);\r
+\r
mCabExitPositions[0][7].SetPosition(32000-5205, 32000-608, 32000-4092, 0x80, 0);\r
- mCabExitPositions[1][7].SetPosition(32000-5764, 32000-608, 32000-4092, 0x80, 0); \r
+ mCabExitPositions[1][7].SetPosition(32000-5764, 32000-608, 32000-4092, 0x80, 0);\r
}\r
\r
-u32 PSubway::GetTimeOffset(u32 nVhcId, u32 nTime)\r
+uint32_t PSubway::GetTimeOffset(uint32_t nVhcId, uint32_t nTime)\r
{\r
- u8 tIndex;\r
- \r
+ uint8_t tIndex;\r
+\r
if(!GetInfoIndex(nVhcId, &tIndex))\r
{\r
Console->Print(RED, BLACK, "[Error] PSubway::GetTimeOffset : invalid cab VhcId %d", nVhcId);\r
return ((nTime + mCabLoopTime - mCab0TimeOffset + mTimingAdjust + (tIndex * mCabIntervalTime)) % mCabLoopTime);\r
}\r
\r
-u8 PSubway::GetStation(u32 nVhcId, u32 nTime, u32* TimeOffset)\r
-{ \r
- s8 i;\r
- \r
- u32 tTimeOffset = GetTimeOffset(nVhcId, nTime);\r
+uint8_t PSubway::GetStation(uint32_t nVhcId, uint32_t nTime, uint32_t* TimeOffset)\r
+{\r
+ int8_t i;\r
+\r
+ uint32_t tTimeOffset = GetTimeOffset(nVhcId, nTime);\r
if(TimeOffset)\r
{\r
*TimeOffset = tTimeOffset;\r
}\r
- \r
+\r
for(i = mStationsNumber-1; (i >= 0) && (tTimeOffset < mOpenDoorOffset[i]); --i) ;\r
\r
return i;\r
}\r
\r
-bool PSubway::IsDoorOpen(u32 nVhcId, u32 nTime)\r
+bool PSubway::IsDoorOpen(uint32_t nVhcId, uint32_t nTime)\r
{\r
- u32 TimeOffset;\r
- u8 tStation;\r
- \r
+ uint32_t TimeOffset;\r
+ uint8_t tStation;\r
+\r
if(!GetInfoIndex(nVhcId))\r
{\r
Console->Print(RED, BLACK, "[Error] PSubway::IsDoorOpen : invalid cab VhcId %d", nVhcId);\r
- return false; \r
+ return false;\r
}\r
else\r
{\r
}\r
}\r
\r
-std::string* PSubway::GetStationName(u8 nStationId)\r
+std::string* PSubway::GetStationName(uint8_t nStationId)\r
{\r
if(nStationId < mStationsNumber)\r
{\r
}\r
}\r
\r
-bool PSubway::GetStationExitPosition(PCharCoordinates* nPosition, u8 nStationId, f32 nCoef)\r
+bool PSubway::GetStationExitPosition(PCharCoordinates* nPosition, uint8_t nStationId, float nCoef)\r
{\r
if(nStationId < mStationsNumber)\r
{\r
{\r
Console->Print(RED, BLACK, "[Error] PSubway::SetStationExitPosition : invalid subway station %d", nStationId);\r
return false;\r
- } \r
+ }\r
}\r
\r
-bool PSubway::GetInfoIndex(u32 nVhcId, u8 *Index)\r
+bool PSubway::GetInfoIndex(uint32_t nVhcId, uint8_t *Index)\r
{\r
- s32 tIndex = nVhcId - mCabsBaseId;\r
+ int32_t tIndex = nVhcId - mCabsBaseId;\r
if ((tIndex >= 0) && (tIndex < mCabsNumber))\r
{\r
if(Index)\r
{\r
- *Index = (u8)tIndex;\r
+ *Index = (uint8_t)tIndex;\r
}\r
return true;\r
}\r
return false;\r
}\r
\r
-bool PSubway::UpdateInfo(u32 nVhcId, u16 nPosition, u8 nDoorOpened)\r
+bool PSubway::UpdateInfo(uint32_t nVhcId, uint16_t nPosition, uint8_t nDoorOpened)\r
{\r
- u8 tIndex;\r
+ uint8_t tIndex;\r
if(GetInfoIndex(nVhcId, &tIndex))\r
{\r
mSubways[tIndex].mPosition = nPosition;\r
//if(mSubways[tIndex].mDoorOpened != nDoorOpened)\r
// Console->Print("[DEBUG] Subway cab %08x : door now %s ", nVhcId, nDoorOpened ? "opened" : "closed" );\r
- \r
+\r
mSubways[tIndex].mDoorOpened = nDoorOpened;\r
\r
return true;\r
return false;\r
}\r
\r
-u16 PSubway::GetPosition(u32 nVhcId)\r
+uint16_t PSubway::GetPosition(uint32_t nVhcId)\r
{\r
- u8 tIndex;\r
+ uint8_t tIndex;\r
if(GetInfoIndex(nVhcId, &tIndex))\r
{\r
return mSubways[tIndex].mPosition;\r
return 0;\r
}\r
\r
-u8 PSubway::GetFreeSeat(u32 nVhcId)\r
+uint8_t PSubway::GetFreeSeat(uint32_t nVhcId)\r
{\r
- u8 tIndex;\r
- u8 tSeatFound = 0;\r
+ uint8_t tIndex;\r
+ uint8_t tSeatFound = 0;\r
if(GetInfoIndex(nVhcId, &tIndex))\r
{\r
- for(u8 j=0; j<4; j++)\r
+ for(uint8_t j=0; j<4; j++)\r
{\r
if(! mSubways[tIndex].mSeatUsersId[j])\r
{\r
return 0;\r
}\r
\r
-bool PSubway::SetSeatUser(u32 nVhcId, u8 nSeat, u32 nCharId)\r
+bool PSubway::SetSeatUser(uint32_t nVhcId, uint8_t nSeat, uint32_t nCharId)\r
{\r
- u8 tIndex;\r
+ uint8_t tIndex;\r
\r
if(GetInfoIndex(nVhcId, &tIndex) && (nSeat >= 1) && (nSeat <= 4))\r
{\r
return false;\r
}\r
\r
-bool PSubway::UnsetSeatUser(u32 nVhcId, u8 nSeat, u32 nCharId)\r
+bool PSubway::UnsetSeatUser(uint32_t nVhcId, uint8_t nSeat, uint32_t nCharId)\r
{\r
- u8 tIndex;\r
+ uint8_t tIndex;\r
\r
if(GetInfoIndex(nVhcId, &tIndex) && (nSeat >= 1) && (nSeat <= 4))\r
{\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include <string>\r
+\r
+class PSubway {\r
+ friend class PMsgBuilder;\r
+\r
+ struct PSubwayInfo\r
+ {\r
+ uint16_t mVhcId;\r
+ uint16_t mPosition;\r
+ uint8_t mDoorOpened;\r
+ uint32_t mSeatUsersId[4];\r
+ };\r
+\r
+ public:\r
+ static const uint16_t mCabsNumber = 11;\r
+ static const uint32_t mCabsBaseId = 0x03f2;\r
+ static const uint32_t mCabsBaseHealth = 100; //should take that from .def instead...\r
+ static const uint8_t mStationsNumber = 8;\r
+\r
+ private:\r
+ static const uint16_t mSubwayInitData [];\r
+ static const uint32_t mCabLoopTime;\r
+ static const uint32_t mCab0TimeOffset;\r
+ static const int32_t mTimingAdjust;\r
+ static const uint32_t mCabIntervalTime;\r
+ static const uint32_t mOpenDoorOffset [];\r
+ static const uint32_t mOpenDoorDuration [];\r
+ static const char* mSubwayStationName [];\r
+ static PCharCoordinates mCabExitPositions [2][mStationsNumber];\r
+\r
+ PSubwayInfo mSubways[mCabsNumber];\r
+\r
+public:\r
+ bool GetInfoIndex(uint32_t nVhcId, uint8_t *Index = NULL);\r
+\r
+ public:\r
+ PSubway();\r
+ //~PSubway();\r
+\r
+ inline bool IsValidSubwayCab(uint32_t nVhcId) {return GetInfoIndex(nVhcId); }\r
+ bool UpdateInfo(uint32_t nVhcId, uint16_t nPosition, uint8_t nDoorOpened);\r
+ uint16_t GetPosition(uint32_t nVhcId);\r
+\r
+ uint32_t GetTimeOffset(uint32_t nVhcId, uint32_t nTime);\r
+ uint8_t GetStation(uint32_t nVhcId, uint32_t nTime, uint32_t* TimeOffset = NULL);\r
+ bool IsDoorOpen(uint32_t nVhcId, uint32_t nTime);\r
+ std::string* GetStationName(uint8_t nStationId);\r
+ bool GetStationExitPosition(PCharCoordinates* nPosition, uint8_t nStationId, float nCoef = 0.5);\r
+\r
+ uint8_t GetFreeSeat(uint32_t nVhcId);\r
+ bool SetSeatUser(uint32_t nVhcId, uint8_t nSeat, uint32_t nCharId);\r
+ bool UnsetSeatUser(uint32_t nVhcId, uint8_t nSeat, uint32_t nCharId);\r
+};\r
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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 <cstring>
+#include "GameServer/Includes.hxx"
+#include "Common/Includes.hxx"
PTerminal::PTerminal()
{
mResultFields = 0;
}
-u8 PTerminal::GetNewEmailCount(PClient* nClient, bool nNoticeClient)
+uint8_t PTerminal::GetNewEmailCount(PClient* nClient, bool nNoticeClient)
{
MYSQL_RES *result = NULL;
MYSQL_ROW row;
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)
return tRetVal;
}
-
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+\r
+class PTerminal {\r
+private:\r
+ void SendTryAccessAnswer(PClient* nClient, char *nArea, bool nAllowed);\r
+ char mSQLQuery[500];\r
+\r
+ int mResultFields;\r
+ void EraseVars();\r
+\r
+ char mConPrefix[50];\r
+\r
+ inline bool ChkOpt(uint8_t nNumOptions, uint8_t nReqOpt) { if(nNumOptions < nReqOpt) return false; else return true; };\r
+ bool DoStockXCheck(PClient* nClient, int nAmountEntered, int nNewAmount);\r
+\r
+public:\r
+ PTerminal();\r
+ //~PTerminal();\r
+ // Check accesslevel of Player for various Terminal actions\r
+ bool CheckAccess(PClient* nClient, char *nArea, uint16_t nCmdNr, char *nOption1, char *nOption2, char *nOption3);\r
+ uint8_t GetNewEmailCount(PClient* nClient, bool nNoticeClient = true);\r
+ // Handle ReceiveDB queries\r
+ bool HandleQueryDB(PClient* nClient, std::string *nDBCommandName, std::string *nCommandName, std::string *nOptions, uint8_t nNumOptions);\r
+ bool HandleReceiveDB(PClient* nClient, uint16_t mTerminalSessionId, std::string *nCommandName, std::string *nOptions, uint8_t nNumOptions, uint16_t nDBID, uint8_t nUnknown);\r
+ 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);\r
+ bool HandleUpdateDB(PClient* nClient, uint16_t mTerminalSessionId, std::string *nCommandName, std::string *nOptions, uint8_t nNumOptions, uint16_t nDBID, uint8_t nUnknown);\r
+};\r
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
+#include <cstring>
+#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();
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
+#include <cstring>\r
+#include "GameServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- terminal_receivedb.cpp - Management class for Terminal actions (Citycom, keys, vehicledepot, ...)\r
- Sub-File for terminal "ReceiveDB" command\r
-\r
- MODIFIED: 12 Jan 2007 Namikon\r
- REASON: - Created\r
- MODIFIED: 09 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
-*/\r
-\r
-\r
-#include "main.h"\r
-\r
-#include "include/terminal.h"\r
-#include "include/msgbuilder.h"\r
-\r
-bool PTerminal::HandleReceiveDB(PClient* nClient, u16 mTerminalSessionId, std::string *nCommandName, std::string *nOptions, u8 nNumOptions, u16 nDBID, u8 nUnknown)\r
+bool PTerminal::HandleReceiveDB(PClient* nClient, uint16_t mTerminalSessionId, std::string *nCommandName, std::string *nOptions, uint8_t nNumOptions, uint16_t nDBID, uint8_t nUnknown)\r
{\r
EraseVars();\r
int nAccessLevel = nClient->GetAccountLevel();\r
// Loop all result fields and push answers into Message\r
for (int t = 0; t < mResultFields; t++)\r
{\r
- *tDBResult << ( u16 )(strlen(row[t]) + 1);\r
+ *tDBResult << ( uint16_t )(strlen(row[t]) + 1);\r
*tDBResult << row[t];\r
}\r
}\r
- /*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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 <cstring>
+#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);
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?
{
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!
PMessage* tmpMsg = MsgBuilder->BuildTryAccessAnswerMsg(nClient, tCmd, tAllowed);
nClient->SendUDPMessage(tmpMsg);
}
-
+
return tAllowed;
}
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
+#include <cstring>\r
+#include <sstream>\r
+#include "GameServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- terminal_upcatedb.cpp - Management class for Terminal actions (Citycom, keys, vehicledepot, ...)\r
- Sub-File for terminal "UpdateDB" command\r
-\r
- MODIFIED: 12 Jan 2007 Namikon\r
- REASON: - Created\r
- MODIFIED: 09 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
-*/\r
-\r
-\r
-#include "main.h"\r
-#include "include/terminal.h"\r
-#include "include/msgbuilder.h"\r
-\r
-\r
-bool PTerminal::HandleUpdateDB(PClient* nClient, u16 mTerminalSessionId, std::string *nCommandName, std::string *nOptions, u8 nNumOptions, u16 nDBID, u8 nUnknown)\r
+bool PTerminal::HandleUpdateDB(PClient* nClient, uint16_t mTerminalSessionId, std::string *nCommandName, std::string *nOptions, uint8_t nNumOptions, uint16_t nDBID, uint8_t nUnknown)\r
{\r
std::ostringstream tLongSQL; // omg my eyes... Stringstream is one of the worst inventions ever! Stick with printf syntax!!111\r
char tShortSQL[1024]; // Use this for small updates that will not exceed 1kb\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- vehicle.cpp - Vehicle handling\r
-\r
- Authors:\r
- - Namikon\r
- - Akiko\r
-\r
- MODIFIED: 08 Jan 2006 Namikon\r
- REASON: - initial release by Namikon\r
- MODIFIED: 09 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
-*/\r
-\r
-\r
-#include "main.h"\r
-\r
-#include "include/vehicle.h"\r
-#include "include/worlds.h"\r
-\r
+#include "GameServer/Includes.hxx"\r
+#include "GameServer/Definitions/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
// PVhcCoordinates\r
-void PVhcCoordinates::SetInterpolate( const PVhcCoordinates& Pos1, const PVhcCoordinates& Pos2, f32 nCoef )\r
+void PVhcCoordinates::SetInterpolate( const PVhcCoordinates& Pos1, const PVhcCoordinates& Pos2, float nCoef )\r
{\r
if (( nCoef < 0 ) || ( nCoef > 1 ) )\r
{\r
Console->Print( RED, BLACK, "[Error] PVhcCoordinates::Interpolate : Invalid nCoef value: %f", nCoef );\r
nCoef = 0;\r
}\r
- f32 rCoef = 1 - nCoef;\r
-\r
- mY = ( u16 )( rCoef * Pos1.mY + nCoef * Pos2.mY );\r
- mZ = ( u16 )( rCoef * Pos1.mZ + nCoef * Pos2.mZ );\r
- mX = ( u16 )( rCoef * Pos1.mX + nCoef * Pos2.mX );\r
- mUD = ( u8 )( rCoef * Pos1.mUD + nCoef * Pos2.mUD );\r
- mLR = ( u16 )( rCoef * Pos1.mLR + nCoef * Pos2.mLR );\r
- mRoll = ( u16 )( rCoef * Pos1.mRoll + nCoef * Pos2.mRoll );\r
+ float rCoef = 1 - nCoef;\r
+\r
+ mY = ( uint16_t )( rCoef * Pos1.mY + nCoef * Pos2.mY );\r
+ mZ = ( uint16_t )( rCoef * Pos1.mZ + nCoef * Pos2.mZ );\r
+ mX = ( uint16_t )( rCoef * Pos1.mX + nCoef * Pos2.mX );\r
+ mUD = ( uint8_t )( rCoef * Pos1.mUD + nCoef * Pos2.mUD );\r
+ mLR = ( uint16_t )( rCoef * Pos1.mLR + nCoef * Pos2.mLR );\r
+ mRoll = ( uint16_t )( rCoef * Pos1.mRoll + nCoef * Pos2.mRoll );\r
}\r
\r
-void PVhcCoordinates::SetPosition( u16 nY, u16 nZ, u16 nX, u8 nUD, u16 nLR, u16 nRoll, u8 nAct, u16 nUnknown, u8 nFF )\r
+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 )\r
{\r
mY = nY;\r
mZ = nZ;\r
\r
// PVehicleInformation\r
//Tmp\r
-const u8 VhcTypes[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,\r
+const uint8_t VhcTypes[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,\r
11, 12, 13, 50, 60, 62, 64, 65, 70\r
}; // (adv.) assault gliders discarded because not ok\r
#define VHC_DISABLE_NOVULARI\r
#ifndef VHC_DISABLE_NOVULARI\r
-const u8 VhcTypesNum = 19;\r
+const uint8_t VhcTypesNum = 19;\r
#else\r
-const u8 VhcTypesNum = 18;\r
+const uint8_t VhcTypesNum = 18;\r
#endif\r
\r
-bool PVehicleInformation::Load( u32 nVehicleId )\r
+bool PVehicleInformation::Load( uint32_t nVehicleId )\r
{\r
- u8 i;\r
- u8 nVId = nVehicleId % 100; //Tmp\r
+ uint8_t i;\r
+ uint8_t nVId = nVehicleId % 100; //Tmp\r
for ( i = 0; ( i < VhcTypesNum ) && ( VhcTypes[i] < nVId ); i++ ) ; //Tmp\r
if (( i < VhcTypesNum ) && ( VhcTypes[i] == nVId ) ) //Tmp\r
{\r
return false;\r
}\r
\r
-bool PVehicleInformation::SetStatus( u8 nStatus )\r
+bool PVehicleInformation::SetStatus( uint8_t nStatus )\r
{\r
if (( mStatus != 2 ) && ( nStatus <= 2 ) )\r
{\r
}\r
\r
// PSpawnedVehicule\r
-const u8 PSpawnedVehicle::mSeatsFlags[] = { 1, 2, 4, 8, 16, 32, 64, 128 };\r
+const uint8_t PSpawnedVehicle::mSeatsFlags[] = { 1, 2, 4, 8, 16, 32, 64, 128 };\r
\r
-PSpawnedVehicle::PSpawnedVehicle( u32 nLocalId, PVehicleInformation const* nVhcInfo, u32 nLocation, PVhcCoordinates const* nVhcPos )\r
+PSpawnedVehicle::PSpawnedVehicle( uint32_t nLocalId, PVehicleInformation const* nVhcInfo, uint32_t nLocation, PVhcCoordinates const* nVhcPos )\r
{\r
mLocalId = nLocalId;\r
mInfo = *nVhcInfo;\r
}\r
}\r
\r
-void PSpawnedVehicle::SetLocation( u32 nLocation )\r
+void PSpawnedVehicle::SetLocation( uint32_t nLocation )\r
{\r
mLocation = nLocation;\r
}\r
return mVhcDef->GetNumSeats();\r
}\r
\r
-bool PSpawnedVehicle::SetSeatUser( u8 nSeatId, u32 nCharId )\r
+bool PSpawnedVehicle::SetSeatUser( uint8_t nSeatId, uint32_t nCharId )\r
{\r
if ( nSeatId < mVhcDef->GetNumSeats() )\r
{\r
return false;\r
}\r
\r
-bool PSpawnedVehicle::UnsetSeatUser( u8 nSeatId, u32 nCharId )\r
+bool PSpawnedVehicle::UnsetSeatUser( uint8_t nSeatId, uint32_t nCharId )\r
{\r
if ( nSeatId < mVhcDef->GetNumSeats() )\r
{\r
return false;\r
}\r
\r
-bool PSpawnedVehicle::IsCharInside( u32 nCharId ) const\r
+bool PSpawnedVehicle::IsCharInside( uint32_t nCharId ) const\r
{\r
for ( int i = 0; i < mVhcDef->GetNumSeats(); ++i )\r
{\r
return false;\r
}\r
\r
-u8 PSpawnedVehicle::GetFirstFreeSeat() const\r
+uint8_t PSpawnedVehicle::GetFirstFreeSeat() const\r
{\r
for ( int i = 0; i < mVhcDef->GetNumSeats(); ++i )\r
{\r
\r
return 255;\r
}\r
-/*u8 PSpawnedVehicle::GetFreeSeats() const\r
+/*uint8_t PSpawnedVehicle::GetFreeSeats() const\r
{\r
- u8 bitField = 0;\r
+ uint8_t bitField = 0;\r
\r
for(int i = mVhcDef->GetNumSeats() - 1; i >= 0 ; --i)\r
{\r
return Result.second;\r
}\r
\r
-bool PVehicles::UnregisterSpawnedVehicle( u32 nVehicleId )\r
+bool PVehicles::UnregisterSpawnedVehicle( uint32_t nVehicleId )\r
{\r
PSpawnedVhcMap::iterator it = mSpawnedVehicles.find( nVehicleId );\r
if ( it != mSpawnedVehicles.end() )\r
}\r
}\r
\r
-//u32 PVehicles::CreateVehicle(u32 nOwnerChar, u8 mVehicleType) {}\r
-//bool PVehicles::RegisterVehicleOwner(u32 nVehicleId, u32 nOwnerChar) {}\r
-//bool PVehicles::DestroyVehicle(u32 nVehicleId) {}\r
+//uint32_t PVehicles::CreateVehicle(uint32_t nOwnerChar, uint8_t mVehicleType) {}\r
+//bool PVehicles::RegisterVehicleOwner(uint32_t nVehicleId, uint32_t nOwnerChar) {}\r
+//bool PVehicles::DestroyVehicle(uint32_t nVehicleId) {}\r
\r
-bool PVehicles::IsValidVehicle( u32 nVehicleId, bool nCheckOwner, u32 nOwnerId ) const\r
+bool PVehicles::IsValidVehicle( uint32_t nVehicleId, bool nCheckOwner, uint32_t nOwnerId ) const\r
{\r
// Look in DB\r
// tmp\r
- u32 tVehicleId = nVehicleId; tVehicleId = tVehicleId;\r
+ uint32_t tVehicleId = nVehicleId; tVehicleId = tVehicleId;\r
bool tCheckOwner = nCheckOwner; tCheckOwner = tCheckOwner;\r
- u32 tOwnerId = nOwnerId; tOwnerId = tOwnerId;\r
+ uint32_t tOwnerId = nOwnerId; tOwnerId = tOwnerId;\r
return true; // tmp\r
}\r
\r
-PSpawnedVehicle* PVehicles::GetSpawnedVehicle( u32 nVehicleId ) const\r
+PSpawnedVehicle* PVehicles::GetSpawnedVehicle( uint32_t nVehicleId ) const\r
{\r
PSpawnedVhcMap::const_iterator it = mSpawnedVehicles.find( nVehicleId );\r
if ( it != mSpawnedVehicles.end() )\r
}\r
}\r
\r
-bool PVehicles::GetVehicleInfo( u32 nVehicleId, PVehicleInformation* nInfo ) const\r
+bool PVehicles::GetVehicleInfo( uint32_t nVehicleId, PVehicleInformation* nInfo ) const\r
{\r
PSpawnedVehicle* tVhc = GetSpawnedVehicle( nVehicleId );\r
if ( tVhc )\r
}\r
}\r
\r
-PVhcInfoList* PVehicles::GetCharVehicles( u32 nCharId, u16 nMaxCount, u16 nStartIndex )\r
+PVhcInfoList* PVehicles::GetCharVehicles( uint32_t nCharId, uint16_t nMaxCount, uint16_t nStartIndex )\r
{\r
PVhcInfoList* Entries = new PVhcInfoList();\r
PVehicleInformation* InfoEntry;\r
// Tmp implementation\r
- u16 LimitIndex = nStartIndex + nMaxCount;\r
+ uint16_t LimitIndex = nStartIndex + nMaxCount;\r
if ( !nMaxCount || ( VhcTypesNum < LimitIndex ) )\r
{\r
LimitIndex = VhcTypesNum;\r
}\r
\r
- for ( u16 i = nStartIndex; ( i < LimitIndex ) ; ++i )\r
+ for ( uint16_t i = nStartIndex; ( i < LimitIndex ) ; ++i )\r
{\r
InfoEntry = new PVehicleInformation();\r
if ( GetVehicleInfo( nCharId * 100 + VhcTypes[i], InfoEntry ) )\r
return Entries;\r
}\r
\r
-PSpawnedVehicle* PVehicles::SpawnVehicle( u32 nVehicleId, u32 nLocation, PVhcCoordinates const* nVhcPos )\r
+PSpawnedVehicle* PVehicles::SpawnVehicle( uint32_t nVehicleId, uint32_t nLocation, PVhcCoordinates const* nVhcPos )\r
{\r
PSpawnedVehicle* newVhc = NULL;\r
PWorld* cWorld;\r
\r
if ( cWorld && GetVehicleInfo( nVehicleId, &nVhcInfo ) )\r
{\r
- newVhc = cWorld->GetSpawnedVehicules()->SpawnVehicle( &nVhcInfo, nVhcPos );\r
+ newVhc = cWorld->GetSpawnedVehicles()->SpawnVehicle( &nVhcInfo, nVhcPos );\r
if ( newVhc )\r
{\r
if ( !RegisterSpawnedVehicle( newVhc ) )\r
return newVhc;\r
}\r
\r
-bool PVehicles::UnspawnVehicle( u32 nVehicleId )\r
+bool PVehicles::UnspawnVehicle( uint32_t nVehicleId )\r
{\r
PWorld* cWorld;\r
bool Result = false;\r
Console->Print( RED, BLACK, "[Error] PVehicles::UnspawnVehicle : Could not save vhc %d", nVehicleId );\r
}\r
\r
- Result = cWorld->GetSpawnedVehicules()->UnspawnVehicle( it->second->GetLocalId() );\r
+ Result = cWorld->GetSpawnedVehicles()->UnspawnVehicle( it->second->GetLocalId() );\r
if ( Result )\r
{\r
if ( !UnregisterSpawnedVehicle( nVehicleId ) )\r
PSpawnedVehicle* PSpawnedVehicles::SpawnVehicle( PVehicleInformation const* nVhcInfo, PVhcCoordinates const* nVhcPos )\r
{\r
PSpawnedVehicle* newVhc = NULL;\r
- u32 nSize;\r
+ uint32_t nSize;\r
\r
if ( nVhcInfo->GetStatus() == 0 ) // only if in garage\r
{\r
return newVhc;\r
}\r
\r
-PSpawnedVehicle* PSpawnedVehicles::GetVehicle( u32 nLocalId )\r
+PSpawnedVehicle* PSpawnedVehicles::GetVehicle( uint32_t nLocalId )\r
{\r
if (( nLocalId <= mVhcBaseLocalId ) && ( nLocalId > ( mVhcBaseLocalId - mSpawnedVehicles.size() ) ) )\r
{\r
}\r
}\r
\r
-PSpawnedVehicle* PSpawnedVehicles::GetVehicleByGlobalId( u32 nVehicleId ) const\r
+PSpawnedVehicle* PSpawnedVehicles::GetVehicleByGlobalId( uint32_t nVehicleId ) const\r
{\r
for ( PSpawnedVhcVector::const_iterator it = mSpawnedVehicles.begin(); it != mSpawnedVehicles.end(); it++ )\r
{\r
return NULL;\r
}\r
\r
-bool PSpawnedVehicles::UnspawnVehicle( u32 nLocalId )\r
+bool PSpawnedVehicles::UnspawnVehicle( uint32_t nLocalId )\r
{\r
- u16 Index;\r
+ uint16_t Index;\r
PSpawnedVehicle* tVhc;\r
\r
if (( nLocalId <= mVhcBaseLocalId ) && ( nLocalId > ( mVhcBaseLocalId - mSpawnedVehicles.size() ) ) )\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include <map>\r
+#include <queue>\r
+#include <vector>\r
+\r
+class PDefVhc;\r
+\r
+class PVhcCoordinates {\r
+ friend class PSpawnedVehicle;\r
+\r
+ private:\r
+ uint16_t mY; // Y-Position in world\r
+ uint16_t mZ; // Z-Position in world\r
+ uint16_t mX; // X-Position in world\r
+ uint8_t mUD; // Up - Mid - Down (d6 - 80 - 2a) // Pitch\r
+ uint16_t mLR; // Yaw\r
+ uint16_t mRoll;\r
+ uint16_t mUnknown; // Usually 0x0001\r
+ uint8_t mFF; // Usually 0xff ...\r
+ uint8_t mAct; // Last user action state\r
+ // mAct: bit field\r
+ //0x00 = not moving\r
+ //0x01 = Left\r
+ //0x02 = Right\r
+ //0x04 = Forward\r
+ //0x08 = Back\r
+ //0x20 = Pushing down\r
+ //0x40 = Pulling up\r
+\r
+ public:\r
+ inline PVhcCoordinates() { mX = mY = mZ = mAct = 0; mUD = 128; mLR = 34683; mRoll = 32403;}\r
+\r
+ 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 );\r
+ void SetInterpolate( const PVhcCoordinates& Pos1, const PVhcCoordinates& Pos2, float nCoef );\r
+ inline uint16_t GetX() const { return mX; }\r
+ inline uint16_t GetY() const { return mY; }\r
+ inline uint16_t GetZ() const { return mZ; }\r
+ inline uint8_t GetUD() const { return mUD; }\r
+ inline uint16_t GetLR() const { return mLR; }\r
+ inline uint16_t GetRoll() const { return mRoll; }\r
+ inline uint8_t GetAct() const { return mAct; }\r
+ inline uint8_t GetUnknown() const { return mUnknown; }\r
+ inline uint8_t GetFF() const { return mFF; }\r
+};\r
+\r
+class PVehicleInformation\r
+{\r
+ friend class PSpawnedVehicle;\r
+ friend class PVehicles;\r
+\r
+ private:\r
+ uint32_t mVehicleId;\r
+ uint32_t mOwnerCharId;\r
+ uint32_t mHealth; // or float ???\r
+ uint8_t mVehicleType;\r
+ uint8_t mStatus; //vhcStatus 0:parking, 1:in_service, 2:destroyed\r
+\r
+ public:\r
+ inline PVehicleInformation( uint32_t nVehicleId = 0, uint32_t nOwnerCharId = 0, uint32_t nHealth = 0, uint8_t nVehicleType = 0, uint8_t nStatus = 0 ) :\r
+ mVehicleId( nVehicleId ),\r
+ mOwnerCharId( nOwnerCharId ),\r
+ mHealth( nHealth ),\r
+ mVehicleType( nVehicleType ),\r
+ mStatus( nStatus )\r
+ { }\r
+\r
+ inline uint32_t GetVehicleId() const { return mVehicleId; }\r
+ inline uint32_t GetOwnerCharId() const { return mOwnerCharId; }\r
+ inline uint32_t GetHealth() const { return mHealth; } // or float ???\r
+ inline uint8_t GetVehicleType() const { return mVehicleType; }\r
+ inline uint8_t GetStatus() const { return mStatus; }\r
+ bool SetStatus( uint8_t nStatus );\r
+\r
+ bool Load( uint32_t nVehicleId );\r
+ bool Save();\r
+ bool Destroy();\r
+};\r
+\r
+class PSpawnedVehicle\r
+{\r
+ private:\r
+ static const uint8_t mSeatsFlags[];\r
+\r
+ private:\r
+ uint32_t mLocalId;\r
+ PVehicleInformation mInfo;\r
+ uint32_t mLocation;\r
+ PVhcCoordinates mCoords;\r
+ const PDefVhc* mVhcDef;\r
+\r
+ uint32_t mSeatUserId[8];\r
+ uint8_t mFreeSeatsFlags;\r
+ uint8_t mNbFreeSeats;\r
+\r
+ uint16_t minmax[4][2]; //Temp\r
+\r
+ public:\r
+ PSpawnedVehicle( uint32_t nLocalId, PVehicleInformation const* nVhcInfo, uint32_t nLocation, PVhcCoordinates const* nVhcPos );\r
+\r
+ inline uint32_t GetVehicleId() const { return mInfo.mVehicleId; }\r
+ inline uint32_t GetLocalId() const { return mLocalId; }\r
+ inline const PVhcCoordinates& GetPosition() const { return mCoords; }\r
+ inline const PVehicleInformation& GetInformation() const { return mInfo; }\r
+ inline bool SetStatus( uint8_t nStatus ) { return mInfo.SetStatus( nStatus ); }\r
+\r
+ void SetLocation( uint32_t nLocation );\r
+ inline uint32_t GetLocation() const { return mLocation; }\r
+ void SetPosition( PVhcCoordinates const* nVhcPos );\r
+\r
+ inline bool Save() { return mInfo.Save(); }\r
+\r
+ int GetNumSeats() const;\r
+ inline uint32_t GetSeatUser( uint8_t nSeatId ) const { return (( nSeatId < 8 ) ? mSeatUserId[nSeatId] : 0 ); }\r
+ bool SetSeatUser( uint8_t nSeatId, uint32_t nCharId );\r
+ bool UnsetSeatUser( uint8_t nSeatId, uint32_t nCharId );\r
+ bool IsCharInside( uint32_t nCharId ) const;\r
+ inline uint8_t GetFreeSeatsFlags() const { return mFreeSeatsFlags; }\r
+ inline uint8_t GetNbFreeSeats() const { return mNbFreeSeats; }\r
+ uint8_t GetFirstFreeSeat() const;\r
+\r
+ //SetHealth(const uint32_t nHealth);\r
+ //uint32_t DoDamage(const uint32_t nHealthDec);\r
+ //uint32_t DoRepair(const uint32_t nHealthInc);\r
+};\r
+\r
+typedef std::map<uint32_t, PSpawnedVehicle*> PSpawnedVhcMap;\r
+typedef std::queue<PVehicleInformation*> PVhcInfoList;\r
+class PVehicles\r
+{\r
+ private:\r
+ PSpawnedVhcMap mSpawnedVehicles;\r
+\r
+ bool RegisterSpawnedVehicle( PSpawnedVehicle* nSpawnedVehicle );\r
+ bool UnregisterSpawnedVehicle( uint32_t nVehicleId );\r
+\r
+ public:\r
+ PVehicles();\r
+ ~PVehicles();\r
+\r
+ //uint32_t CreateVehicle(uint32_t nOwnerChar, uint8_t mVehicleType);\r
+ //bool RegisterVehicleOwner(uint32_t nVehiculeId, uint32_t nOwnerChar);\r
+ //bool DestroyVehicle(uint32_t nVehiculeId);\r
+ bool IsValidVehicle( uint32_t nVehicleId, bool nCheckOwner = false, uint32_t nOwnerId = 0 ) const;\r
+ inline bool IsSpawned( uint32_t nVehicleId ) const { return ( mSpawnedVehicles.find( nVehicleId ) != mSpawnedVehicles.end() ); }\r
+ PSpawnedVehicle* GetSpawnedVehicle( uint32_t nVehicleId ) const;\r
+ bool GetVehicleInfo( uint32_t nVehicleId, PVehicleInformation* nInfo ) const;\r
+ PSpawnedVehicle* SpawnVehicle( uint32_t nVehicleId, uint32_t nLocation, PVhcCoordinates const* nVhcPos ); // Refuses for subway zone atm\r
+ bool UnspawnVehicle( uint32_t nVehicleId );\r
+\r
+ PVhcInfoList* GetCharVehicles( uint32_t nCharId, uint16_t nMaxCount = 0, uint16_t nStartIndex = 0 );\r
+\r
+};\r
+\r
+typedef std::vector<PSpawnedVehicle*> PSpawnedVhcVector;\r
+typedef std::queue<PSpawnedVehicle*> PSpawnedVhcList;\r
+\r
+class PSpawnedVehicles\r
+{\r
+ friend class PWorld;\r
+\r
+ public:\r
+ 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\r
+ static const uint16_t mMaxLocalVhc = 127;\r
+\r
+ inline static bool IsPotentialSpawnedVehicle( uint32_t nLocalId )\r
+ { return (( nLocalId <= mVhcBaseLocalId ) && (( mVhcBaseLocalId - nLocalId ) < mMaxLocalVhc ) ); }\r
+\r
+ private:\r
+ PSpawnedVhcVector mSpawnedVehicles;\r
+ uint16_t mNextFreeHint;\r
+ uint32_t mLocation;\r
+\r
+ inline void SetLocation( uint32_t nLocation ) { mLocation = nLocation; }\r
+\r
+ public:\r
+ PSpawnedVehicles();\r
+ ~PSpawnedVehicles();\r
+\r
+ inline bool IsSpawned( uint32_t nLocalId ) const { return (( nLocalId <= mVhcBaseLocalId ) && (( mVhcBaseLocalId - nLocalId ) < mSpawnedVehicles.size() ) && mSpawnedVehicles[mVhcBaseLocalId-nLocalId] ); }\r
+ PSpawnedVehicle* SpawnVehicle( PVehicleInformation const* nVhcInfo, PVhcCoordinates const* nVhcPos );\r
+ PSpawnedVehicle* GetVehicle( uint32_t nLocalId );\r
+ PSpawnedVehicle* GetVehicleByGlobalId( uint32_t nVehicleId ) const;\r
+ bool UnspawnVehicle( uint32_t nVehicleId );\r
+\r
+ PSpawnedVhcList* GetSpawnedVehicles() const;\r
+};\r
-/*
- 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()
{
mTimestamp = 0;
}
-PVhcAccessRequest::PVhcAccessRequest( u32 nRequesterCharId, u32 nVhcGlobalId )
+PVhcAccessRequest::PVhcAccessRequest( uint32_t nRequesterCharId, uint32_t nVhcGlobalId )
{
mCharId = nRequesterCharId;
mVhcGlobalId = nVhcGlobalId;
}
/*
-typedef std::map<u32, PVhcAccessRequest> PVhcAccessRequestMap;
+typedef std::map<uint32_t, PVhcAccessRequest> 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)
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 )
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() )
return false;
}
-bool PVhcAccessRequestList::RegisterResponse( u32 nRequestId, bool nStatus )
+bool PVhcAccessRequestList::RegisterResponse( uint32_t nRequestId, bool nStatus )
{
DropTimedOut();
PVhcAccessRequestMap::iterator it = mActiveRequests.find( nRequestId );
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 );
--- /dev/null
+#pragma once
+
+#include <chrono>
+#include <cstdint>
+#include <map>
+
+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<uint32_t, PVhcAccessRequest> 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);
+};
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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()
{
{
}
-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;
}
row = mysql_fetch_row(result);
- u32 newWAid;
+ uint32_t newWAid;
if(mysql_num_rows(result) == 1)
{
newWAid = atoi(row[wa_actor_id]);
{
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];
}
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)
{
// 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()))
{
// 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!");
}
}
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];
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);
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;
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;
return tWAid;
}
-bool PWorldActors::IsDynamicActor(u32 nWAid)
+bool PWorldActors::IsDynamicActor(uint32_t nWAid)
{
MYSQL_RES *result = NULL;
char query[100];
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;
return true;
}
*/
-int PWorldActors::GetWorldActorFunctionID(u32 nWAid)
+int PWorldActors::GetWorldActorFunctionID(uint32_t nWAid)
{
MYSQL_RES *result = NULL;
MYSQL_ROW row;
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);
}
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;
return;
}
-int PWorldActors::GetLinkedObjectID(u32 nWAID)
+int PWorldActors::GetLinkedObjectID(uint32_t nWAID)
{
MYSQL_RES *result = NULL;
MYSQL_ROW row;
return false;
}
-bool PWorldActors::IsValidLinkedObject(PClient *nClient, u16 nOption1, int nFunctionID)
+bool PWorldActors::IsValidLinkedObject(PClient *nClient, uint16_t nOption1, int nFunctionID)
{
/*
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- worldactors.h - Management class for dynamic worldactors\r
+#pragma once\r
\r
- CREATION: 02 Jan 2007 Namikon\r
+#include <cstdint>\r
\r
- MODIFIED:\r
- REASON: -\r
-\r
-*/\r
+class PClient;\r
\r
/*\r
Current known WorldActors:\r
\r
*/\r
\r
-\r
-#ifndef WORLDACTORS_H\r
-#define WORLDACTORS_H\r
-\r
// Start from this offset (00 00 80 00)\r
#define DYNACTORIDSTART 8388608\r
\r
-class PWorldActors\r
-{\r
+class PWorldActors {\r
private:\r
- // SQL Layout\r
+ // SQL Layout\r
enum\r
{\r
wa_id,\r
wa_option3\r
};\r
\r
- void SpawnWA(u32 nWorld, u16 nActorID, u16 nFunctionID, u32 nWOID, u16 nPosX, u16 nPosY, u16 nPosZ, u8 nRotX, u8 nRotY, u8 nRotZ);\r
- void VanishWA(u32 nWorld, u32 nWAid);\r
+ 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);\r
+ void VanishWA(uint32_t nWorld, uint32_t nWAid);\r
\r
// Get next availeable WorldactorID. First, try to find ID in known .dat files, then\r
// Get the currently highest ID from SQL and add +1\r
// select distinct wi_worlditem_id from world_items order by wi_worlditem_id desc limit 1;\r
- u32 GetNextFreeWAID();\r
+ uint32_t GetNextFreeWAID();\r
\r
public:\r
PWorldActors();\r
// Add new worldactor to database and spawn it. Returns created WorldID\r
// Position is taken from nClient, same as the worldID and calls the mainfunction\r
// The function values are optional (used for interactive objects, gogo or genrep)\r
- u32 AddWorldActor(PClient* nClient, u16 nActorID, u16 nFuncID, u16 nOpt1 = 0, u16 nOpt2 = 0, u16 nOpt3 = 0);\r
+ uint32_t AddWorldActor(PClient* nClient, uint16_t nActorID, uint16_t nFuncID, uint16_t nOpt1 = 0, uint16_t nOpt2 = 0, uint16_t nOpt3 = 0);\r
\r
// Add new worldactor to database and spawn it. Returns created WorldID\r
// The function values are optional (used for interactive objects, gogo or genrep)\r
- 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);\r
+ 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);\r
\r
// Remove worldactor in given world from SQL and game\r
- void DelWorldActor(PClient* nClient, u32 nWAid);\r
+ void DelWorldActor(PClient* nClient, uint32_t nWAid);\r
\r
// Get functionvalues for worldactor\r
- void GetWAoption(u32 nWAid, u16 nWorld, u16 &nValue1, u16 &nValue2, u16 &nValue3);\r
+ void GetWAoption(uint32_t nWAid, uint16_t nWorld, uint16_t &nValue1, uint16_t &nValue2, uint16_t &nValue3);\r
\r
// Get SQL ID from world and worldID\r
- int GetWASQLID(u32 nWAid, u32 nWorld);\r
+ int GetWASQLID(uint32_t nWAid, uint32_t nWorld);\r
\r
// Check if actorID is dynamic\r
- bool IsDynamicActor(u32 nWAid);\r
+ bool IsDynamicActor(uint32_t nWAid);\r
\r
// Not needed. Better re-spawn the actor\r
- //bool EditWorldActor(u32 nWorldID, int nOption1 = -1, int nOption2 = -1, int nOption3 = -1);\r
+ //bool EditWorldActor(uint32_t nWorldID, int nOption1 = -1, int nOption2 = -1, int nOption3 = -1);\r
\r
- int GetWorldActorFunctionID(u32 nWAid);\r
+ int GetWorldActorFunctionID(uint32_t nWAid);\r
\r
- void GetFrontPos(u32 nWAID, u16* mX, u16* mY, u16* mZ); // For chairs\r
- int GetLinkedObjectID(u32 nWAID); // OptionValue 1 is used for linked object!\r
+ void GetFrontPos(uint32_t nWAID, uint16_t* mX, uint16_t* mY, uint16_t* mZ); // For chairs\r
+ int GetLinkedObjectID(uint32_t nWAID); // OptionValue 1 is used for linked object!\r
\r
// Check if given functionID does exist\r
bool IsValidWAFunction(int nFunctionID);\r
bool RequiresLinkedObject(int nFunctionID);\r
\r
// Checks if the given worldobjectID is valid for this type of functionID\r
- bool IsValidLinkedObject(PClient *nClient, u16 nOption1, int nFunctionID);\r
+ bool IsValidLinkedObject(PClient *nClient, uint16_t nOption1, int nFunctionID);\r
\r
// Checks for double actor-IDs and deletes them from DB\r
void DoActorCheck();\r
};\r
-\r
-#endif\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-/*\r
- worlddatatemplate.cpp - world data template (from worlds .dat files) class\r
-\r
- MODIFIED: 04 Oct 2006 Hammag\r
- REASON: - creation\r
-\r
- MODIFIED: 21 Jun 2009 Namikon\r
- REASON: - Added NPC Template stuff\r
-\r
-*/\r
-\r
-\r
-#include "main.h"\r
-\r
-#include "include/worlddatatemplate.h"\r
-#include "include/world_datparser.h"\r
-#include "include/furnituretemplate.h"\r
-#include "include/doortemplate.h"\r
-#include "include/npctemplate.h"\r
+#include "GameServer/Includes.hxx"\r
+#include "GameServer/Definitions/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
PWorldDataTemplate::PWorldDataTemplate()\r
{\r
return false;\r
}\r
\r
-u32 PWorldDataTemplate::AddFurnitureItem( PFurnitureItemTemplate* nItem )\r
+uint32_t PWorldDataTemplate::AddFurnitureItem( PFurnitureItemTemplate* nItem )\r
{\r
if ( nItem )\r
{\r
mPositionItems[v] = nItem;\r
/*\r
Console->Print("Position entity %d (id 0x%x) added to world template", v, nItem->GetID());\r
- f32 fpX, fpY, fpZ;\r
- u16 pX, pY, pZ;\r
+ float fpX, fpY, fpZ;\r
+ uint16_t pX, pY, pZ;\r
nItem->GetPos(&fpX, &fpY, &fpZ);\r
- pX = (u16) (fpX + 32000);\r
- pY = (u16) (fpY + 32000);\r
- pZ = (u16) (fpZ + 32000);\r
+ pX = (uint16_t) (fpX + 32000);\r
+ pY = (uint16_t) (fpY + 32000);\r
+ pZ = (uint16_t) (fpZ + 32000);\r
Console->Print("Position Y=%f (0x%04x) Z=%f (0x%04x) X=%f (0x%04x)", fpY, pY, fpZ, pZ, fpX, pX);\r
*/\r
}\r
return 0;\r
}\r
\r
-const PFurnitureItemTemplate* PWorldDataTemplate::GetFurnitureItem( u32 ItemID )\r
+const PFurnitureItemTemplate* PWorldDataTemplate::GetFurnitureItem( uint32_t ItemID )\r
{\r
PFurnitureItemsMap::const_iterator it = mFurnitureItems.find( ItemID );\r
if ( it == mFurnitureItems.end() )\r
return it->second;\r
}\r
\r
-bool PWorldDataTemplate::getPositionItemPosition( u8 PosID, f32* pX, f32* pY, f32* pZ )\r
+bool PWorldDataTemplate::getPositionItemPosition( uint8_t PosID, float* pX, float* pY, float* pZ )\r
{\r
if (( PosID < WORLDDATATEMPLATE_MAXPOSITEMS ) && mPositionItems[PosID] )\r
{\r
return false;\r
}\r
\r
-u32 PWorldDataTemplate::AddDoor( PDoorTemplate* nDoor )\r
+uint32_t PWorldDataTemplate::AddDoor( PDoorTemplate* nDoor )\r
{\r
if ( nDoor )\r
{\r
return 0;\r
}\r
\r
-const PDoorTemplate* PWorldDataTemplate::GetDoor( u32 DoorID )\r
+const PDoorTemplate* PWorldDataTemplate::GetDoor( uint32_t DoorID )\r
{\r
PDoorsMap::const_iterator it = mDoors.find( DoorID );\r
if ( it == mDoors.end() )\r
}\r
\r
\r
-u32 PWorldDataTemplate::AddNPC( PNPCTemplate* nNPC )\r
+uint32_t PWorldDataTemplate::AddNPC( PNPCTemplate* nNPC )\r
{\r
if ( nNPC )\r
{\r
return 0;\r
}\r
\r
-const PNPCTemplate* PWorldDataTemplate::GetNPC( u32 NPCID )\r
+const PNPCTemplate* PWorldDataTemplate::GetNPC( uint32_t NPCID )\r
{\r
PNPCsMap::const_iterator it = mNPCs.find( NPCID );\r
if ( it == mNPCs.end() )\r
\r
void PWorldDataTemplate::SetLinkedObjects()\r
{\r
- f32 xI, yI, zI;\r
- f32 xD, yD, zD;\r
- f32 D2, minD2;\r
- u32 minObjID;\r
- u16 fnctType;\r
- u16 tGROrder = 0;\r
+ float xI, yI, zI;\r
+ float xD, yD, zD;\r
+ float D2, minD2;\r
+ uint32_t minObjID;\r
+ uint16_t fnctType;\r
+ uint16_t tGROrder = 0;\r
\r
for ( PFurnitureItemsMap::iterator it = mFurnitureItems.begin(); it != mFurnitureItems.end(); it++ )\r
{\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include <map>\r
+\r
+#define WORLDDATATEMPLATE_MAXPOSITEMS 11\r
+\r
+class PFurnitureItemTemplate;\r
+typedef std::map<uint32_t, PFurnitureItemTemplate*> PFurnitureItemsMap;\r
+\r
+class PDoorTemplate;\r
+typedef std::map<uint32_t, PDoorTemplate*> PDoorsMap;\r
+\r
+class PNPCTemplate;\r
+typedef std::map<uint32_t, PNPCTemplate*> PNPCsMap;\r
+\r
+class PWorldDataTemplate\r
+{\r
+private:\r
+ std::string mName; // (datfile) relative path+filename without leading ./ or ./worlds/ nor .dat extension\r
+ std::string mBspName; // (bsp file) relative path+filename without leading ./ or ./worlds/ nor .bsp extension\r
+ PFurnitureItemsMap mFurnitureItems;\r
+ PDoorsMap mDoors;\r
+ PNPCsMap mNPCs;\r
+ PFurnitureItemTemplate* mPositionItems[WORLDDATATEMPLATE_MAXPOSITEMS];\r
+\r
+ int mUseCount;\r
+\r
+ void DatFileDataCleanup();\r
+ void SetLinkedObjects(); // This method implements some workarouds for some world objects on which we lack info.\r
+\r
+public:\r
+ PWorldDataTemplate();\r
+ ~PWorldDataTemplate();\r
+\r
+ bool LoadDatFile(const std::string& WorldTemplateName, const std::string& nFilename, const bool nTestAccesOnly = false);\r
+ inline const std::string& GetName()\r
+ {\r
+ return mName;\r
+ }\r
+ inline const std::string& GetBspName()\r
+ {\r
+ return mBspName;\r
+ }\r
+\r
+ inline void IncreaseUseCount()\r
+ {\r
+ ++mUseCount;\r
+ }\r
+ inline int DecreaseUseCount()\r
+ {\r
+ return (mUseCount ? --mUseCount : 0);\r
+ }\r
+ inline int GetUseCount()\r
+ {\r
+ return mUseCount;\r
+ }\r
+\r
+ uint32_t AddFurnitureItem(PFurnitureItemTemplate* nItem);\r
+ const PFurnitureItemTemplate* GetFurnitureItem(uint32_t ItemID);\r
+ bool getPositionItemPosition(uint8_t PosID, float* pX, float* pY, float* pZ);\r
+\r
+ uint32_t AddDoor(PDoorTemplate* nDoor);\r
+ const PDoorTemplate* GetDoor(uint32_t DoorID);\r
+\r
+ uint32_t AddNPC(PNPCTemplate* nNPC);\r
+\r
+ // External functions for NPCManager\r
+ const PNPCTemplate* GetNPC(uint32_t NPCID);\r
+ inline const PNPCsMap *GetNPCMap() const\r
+ {\r
+ return &mNPCs;\r
+ }; // called by class PNPCWorld to get all NPCs for this world\r
+};\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- worlds.cpp - world class and world map class\r
-\r
- MODIFIED: 06 Oct 2006 Hammag\r
- REASON: - creation\r
- MODIFIED: 09 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
-*/\r
-\r
-\r
-#include "main.h"\r
-\r
-#include "common/filesystem.h"\r
-#include "include/def_worlds.h"\r
-#include "include/gamedefs.h"\r
-#include "include/furnituretemplate.h"\r
-#include "include/worlddatatemplate.h"\r
-#include "include/worlds.h"\r
-#include "include/appartements.h"\r
-#include "include/vehicle.h"\r
-\r
#include <set>\r
-\r
+#include "GameServer/Includes.hxx"\r
+#include "GameServer/Definitions/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
/**** PWorld ****/\r
-u16 const PWorld::mZoneOutLimitOffset = 0x100;\r
-u16 const PWorld::mBottomZoneOutLimit = 0x4800 - PWorld::mZoneOutLimitOffset;\r
-u16 const PWorld::mBottomZoneInLimit = 0x4a00;\r
-u16 const PWorld::mTopZoneOutLimit = 0xb200 + PWorld::mZoneOutLimitOffset;\r
-u16 const PWorld::mTopZoneInLimit = 0xb000;\r
+uint16_t const PWorld::mZoneOutLimitOffset = 0x100;\r
+uint16_t const PWorld::mBottomZoneOutLimit = 0x4800 - PWorld::mZoneOutLimitOffset;\r
+uint16_t const PWorld::mBottomZoneInLimit = 0x4a00;\r
+uint16_t const PWorld::mTopZoneOutLimit = 0xb200 + PWorld::mZoneOutLimitOffset;\r
+uint16_t const PWorld::mTopZoneInLimit = 0xb000;\r
+const std::string EmptyString;\r
\r
PWorld::PWorld()\r
{\r
{\r
}\r
\r
-bool PWorld::Load( u32 nWorldID )\r
+bool PWorld::Load( uint32_t nWorldID )\r
{\r
std::string WorldTemplateName;\r
std::string tFileName;\r
return true;\r
}\r
\r
-const PDefWorldModel* PWorld::GetFurnitureItemModel( u32 nItemID )\r
+std::string PWorld::GetName()\r
+{\r
+ return ( mWorldDataTemplate ? mWorldDataTemplate->GetName() : EmptyString );\r
+}\r
+\r
+std::string PWorld::GetBspName()\r
+{\r
+ return ( mWorldDataTemplate ? mWorldDataTemplate->GetBspName() : EmptyString );\r
+}\r
+\r
+bool PWorld::IsAppartment()\r
+{\r
+ return mIsAppartment;\r
+}\r
+\r
+const PFurnitureItemTemplate *PWorld::GetFurnitureItemTemplate( uint32_t nItemID )\r
+{\r
+ return ( mWorldDataTemplate ? mWorldDataTemplate->GetFurnitureItem( nItemID ) : NULL ) ;\r
+}\r
+\r
+const PDefWorldModel *PWorld::GetFurnitureItemModel(uint32_t nItemID)\r
{\r
if ( mWorldDataTemplate )\r
{\r
if ( tFurniture )\r
return tFurniture->GetDefWorldModel();\r
}\r
- return NULL;\r
+ return nullptr;\r
+}\r
+\r
+const PDoorTemplate *PWorld::GetDoor(uint32_t nDoorID)\r
+{\r
+ return (mWorldDataTemplate ? mWorldDataTemplate->GetDoor(nDoorID) : nullptr);\r
+}\r
+\r
+bool PWorld::getPositionItemPosition(uint8_t PosID, float *pX, float *pY, float *pZ)\r
+{\r
+ return (mWorldDataTemplate ? mWorldDataTemplate->getPositionItemPosition(PosID, pX, pY, pZ) : false);\r
}\r
\r
-bool PWorld::CharUseChair( int CharLocalID, u32 nItemID )\r
+bool PWorld::CharUseChair( int CharLocalID, uint32_t nItemID )\r
{\r
PChairsInUseMap::iterator it = mChairsInUseMap.find( nItemID );\r
if ( it == mChairsInUseMap.end() ) // chair is free\r
}\r
}\r
\r
-void PWorld::CharLeaveChair( int CharLocalID, u32 nItemID )\r
+void PWorld::CharLeaveChair( int CharLocalID, uint32_t nItemID )\r
{\r
PChairsInUseMap::iterator it = mChairsInUseMap.find( nItemID );\r
if (( it != mChairsInUseMap.end() ) && ( it->second == CharLocalID ) ) // chair is in use by this char\r
}\r
}\r
\r
-PClient* PWorld::GetClientByCharLocalId( u32 rawObjectId ) const\r
+PClient* PWorld::GetClientByCharLocalId( uint32_t rawObjectId ) const\r
{\r
// Temp implementation\r
return ClientManager->GetClientByCharLocalId( rawObjectId, mID );\r
}\r
\r
+PSpawnedVehicles *PWorld::GetSpawnedVehicles()\r
+{\r
+ return &mSpawnedVehicles;\r
+}\r
+\r
bool PWorld::CheckVhcNeedZoning( PVhcCoordinates const* nPos ) const\r
{\r
if ( ( nPos->GetX() <= mBottomZoneOutLimit ) || ( nPos->GetX() >= mTopZoneOutLimit ) || ( nPos->GetY() <= mBottomZoneOutLimit ) || ( nPos->GetY() >= mTopZoneOutLimit ) )\r
return false;\r
}\r
\r
-u32 PWorld::GetVhcZoningDestination( PSpawnedVehicle const* nVhc, PVhcCoordinates* nPos ) const\r
+uint32_t PWorld::GetVhcZoningDestination( PSpawnedVehicle const* nVhc, PVhcCoordinates* nPos ) const\r
{\r
- u32 destWorldId = 0;\r
- s16 vChange = 0;\r
- s16 hChange = 0;\r
+ uint32_t destWorldId = 0;\r
+ int16_t vChange = 0;\r
+ int16_t hChange = 0;\r
PVhcCoordinates const vhcPos = nVhc->GetPosition();\r
- u16 posX = vhcPos.GetX();\r
- u16 posY = vhcPos.GetY();\r
+ uint16_t posX = vhcPos.GetX();\r
+ uint16_t posY = vhcPos.GetY();\r
\r
if ( posX <= mBottomZoneOutLimit )\r
{\r
if ( vChange || hChange )\r
{\r
//Console->Print( YELLOW, BLACK, "[DEBUG] Limit Reached V:%d H:%d mapId:%d", vChange,hChange,mID );\r
- u8 currH = 0;\r
- u8 currV = 0;\r
- s16 newH, newV;\r
+ uint8_t currH = 0;\r
+ uint8_t currV = 0;\r
+ int16_t newH, newV;\r
\r
if ( Worlds->GetWorldmapFromWorldId( mID, currH, currV ) )\r
{\r
return destWorldId;\r
}\r
\r
+const PNPCsMap *PWorld::GetNPCMap() const\r
+{\r
+ return (mWorldDataTemplate ? mWorldDataTemplate->GetNPCMap() : nullptr);\r
+}\r
+\r
+const PNPCTemplate *PWorld::GetNPCTemplate(uint32_t nNPCID) const\r
+{\r
+ return (mWorldDataTemplate ? mWorldDataTemplate->GetNPC(nNPCID) : nullptr);\r
+}\r
+\r
/**** PWorlds ****/\r
-u32 const PWorlds::mNcSubwayWorldId = 1000;\r
-u32 const PWorlds::mAptBaseWorldId = 100000;\r
-u32 const PWorlds::mOutdoorBaseWorldId = 2001;\r
-u32 const PWorlds::mOutdoorWorldIdVIncrement = 20;\r
-u8 const PWorlds::mOutdoorWorldmapHSize = 16;\r
-u8 const PWorlds::mOutdoorWorldmapVSize = 11;\r
-u32 const PWorlds::mOutdoorMaxWorldId = PWorlds::mOutdoorBaseWorldId + PWorlds::mOutdoorWorldIdVIncrement * ( PWorlds::mOutdoorWorldmapVSize - 1 ) + PWorlds::mOutdoorWorldmapHSize - 1;\r
+uint32_t const PWorlds::mNcSubwayWorldId = 1000;\r
+uint32_t const PWorlds::mAptBaseWorldId = 100000;\r
+uint32_t const PWorlds::mOutdoorBaseWorldId = 2001;\r
+uint32_t const PWorlds::mOutdoorWorldIdVIncrement = 20;\r
+uint8_t const PWorlds::mOutdoorWorldmapHSize = 16;\r
+uint8_t const PWorlds::mOutdoorWorldmapVSize = 11;\r
+uint32_t const PWorlds::mOutdoorMaxWorldId = PWorlds::mOutdoorBaseWorldId + PWorlds::mOutdoorWorldIdVIncrement * ( PWorlds::mOutdoorWorldmapVSize - 1 ) + PWorlds::mOutdoorWorldmapHSize - 1;\r
\r
PWorlds::PWorlds()\r
{\r
return true;\r
}\r
\r
-bool PWorlds::IsValidWorld( u32 nWorldID ) const\r
+bool PWorlds::IsValidWorld( uint32_t nWorldID ) const\r
{\r
if ( nWorldID > PWorlds::mAptBaseWorldId )\r
{\r
}\r
}\r
\r
-PWorld* PWorlds::LeaseWorld( u32 nWorldID, const bool nPreloadPhase )\r
+PWorld* PWorlds::LeaseWorld( uint32_t nWorldID, const bool nPreloadPhase )\r
{\r
PWorldsMap::iterator it;\r
\r
}\r
}\r
\r
-PWorld* PWorlds::GetWorld( u32 nWorldID )\r
+PWorld* PWorlds::GetWorld( uint32_t nWorldID )\r
{\r
PWorldsMap* tMap;\r
PWorldsMap::iterator it;\r
}\r
}\r
\r
-void PWorlds::ReleaseWorld( u32 nWorldID ) // no dynamic unload is performed atm + don't forget spawned vhc !\r
+void PWorlds::ReleaseWorld( uint32_t nWorldID ) // no dynamic unload is performed atm + don't forget spawned vhc !\r
{\r
PWorld* tWorld = GetWorld( nWorldID );\r
if ( tWorld )\r
}\r
}\r
\r
-bool PWorlds::IsAppartment( u32 nWorldID )\r
+bool PWorlds::IsAppartment( uint32_t nWorldID )\r
{\r
return (( nWorldID > PWorlds::mAptBaseWorldId ) && IsValidWorld( nWorldID ) );\r
}\r
void PWorlds::Shutdown()\r
{}\r
\r
-u32 PWorlds::GetWorldIdFromWorldmap( u8 mapH, u8 mapV ) const\r
+uint32_t PWorlds::GetWorldIdFromWorldmap( uint8_t mapH, uint8_t mapV ) const\r
{\r
- u32 loc = 0;\r
+ uint32_t loc = 0;\r
if (( mapH < mOutdoorWorldmapHSize ) && ( mapV < mOutdoorWorldmapVSize ) )\r
{\r
loc = mOutdoorBaseWorldId + mOutdoorWorldIdVIncrement * mapV + mapH;\r
return loc;\r
}\r
\r
-bool PWorlds::GetWorldmapFromWorldId( u32 nWorldId, u8& mapH, u8& mapV ) const\r
+bool PWorlds::GetWorldmapFromWorldId( uint32_t nWorldId, uint8_t& mapH, uint8_t& mapV ) const\r
{\r
if (( nWorldId >= mOutdoorBaseWorldId ) && ( nWorldId <= mOutdoorMaxWorldId ) )\r
{\r
--- /dev/null
+#pragma once
+
+#include <cstdint>
+#include <map>
+#include <string>
+
+class PDefWorldModel;
+
+typedef std::map<uint32_t, PNPCTemplate*> PNPCsMap;
+typedef std::map<uint32_t, int32_t> 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<uint32_t, PWorld*> PWorldsMap;
+typedef std::map<std::string, PWorldDataTemplate*> 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;
+};
--- /dev/null
+#include "GameServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
+\r
+// TODO: Put get the fallback world from config\r
+// Check for file existence before sending info to client to avoid client crash and bad location in char info\r
+\r
+void SendZone(PClient *Client, uint32_t loc)\r
+{\r
+ //TODO : FIX case for worldroute and 5 missing id 505\r
+ std::string worldName;\r
+ ConnectionTCP *Socket = Client->getTCPConn();\r
+ //PChar *Char = Chars->GetChar(Client->GetCharID());\r
+\r
+ Socket->SetTimeOutValue(0xffff);\r
+\r
+ PWorld* CurrentWorld = Worlds->GetWorld(loc);\r
+ if (CurrentWorld)\r
+ {\r
+ worldName = CurrentWorld->GetBspName();\r
+ if (worldName.empty())\r
+ {\r
+ worldName = "plaza/plaza_p1"; // Should be a config entry\r
+ Console->Print("Client %d: Empty name for world %d. Redirecting to %s", Console->ColorText(RED, BLACK, "Warning"), Client->GetID(), loc, worldName.c_str());\r
+ loc = 1;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ worldName = "plaza/plaza_p1"; // Should be a config entry\r
+ Console->Print("Client %d: Invalid or not loaded world %d. Redirecting to %s", Console->ColorText(YELLOW, BLACK, "Warning"), Client->GetID(), loc, worldName.c_str());\r
+ loc = 1;\r
+ }\r
+\r
+ PMessage* cMsg = MsgBuilder->BuildSendZoneTCPMsg(loc, &worldName);\r
+ Client->SendTCPMessage(cMsg);\r
+}\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+\r
+class PClient;\r
+\r
+//void SendZone(PClient *Client, PGameState *State,int loc);\r
+void SendZone(PClient *Client, uint32_t loc);\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- accounts.cpp\r
-\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL\r
- MODIFIED: 26 Dec 2005 Namikon\r
- REASON: - Added SQLLoad to PAccounts. First step in adding MySQL support to accounts\r
- MODIFIED: 01 Jan 2006 Namikon\r
- REASON: - Changed FmtTxt() to sprintf(). It does... uhm, the same :D\r
- MODIFIED: 06 Jan 2006 Namikon\r
- REASON: - Removed the old XML loading functions, and changed the SQL ones to work with the Global Neopolis/TinNS Database\r
- - Added SetBannedStatus(<unix timestamp>) to ban/unban an account (use SetBannedStatus(0) to unban a player)\r
- MODIFIED: 03 Oct 2006 Hammag\r
- REASON: - Fixed an issue in PAccount::SetBannedStatus() that was causing the "can't update banned status" error message.\r
- MODIFIED: 27 May 2007 Hammag\r
- REASON: - Full changes for on-demand account access (no more memory-resident account data)\r
- \r
- \r
- MODIFIED: 02 Feb 2008 Hammag\r
- REASON: - Correction of the account creation/update SQL query (thank to drhawk ;) )\r
-*/\r
-\r
+#include "InfoServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
/*\r
NOTE ABOUT ACCESS LEVELS IN THE MYSQL DATABASE:\r
1 = Online\r
2 = Banned\r
*/\r
-#include "main.h"\r
-#include "accounts.h"\r
\r
/** Static members **/\r
-RegEx* PAccount::mUsernameRegexFilter = NULL;\r
-RegEx* PAccount::mPasswordRegexFilter = NULL;\r
+RegEx* PAccount::mUsernameRegexFilter = nullptr;\r
+RegEx* PAccount::mPasswordRegexFilter = nullptr;\r
\r
bool PAccount::SetUsernameRegexFilter(const char* RegexStr)\r
{\r
delete mUsernameRegexFilter;\r
mUsernameRegexFilter = NULL;\r
}\r
- \r
+\r
if(RegexStr)\r
{\r
try {\r
delete mPasswordRegexFilter;\r
mPasswordRegexFilter = NULL;\r
}\r
- \r
+\r
if(RegexStr)\r
{\r
try {\r
return true;\r
}\r
\r
-/** Instance members **/ \r
+/** Instance members **/\r
PAccount::PAccount()\r
{\r
- mID = 0;\r
- mLevel = PAL_BANNED;\r
+ mID = 0;\r
+ mLevel = PAL_BANNED;\r
mStatus = PAS_OFFLINE;\r
mBannedUntil = 0;\r
}\r
\r
-PAccount::PAccount(const u32 AccountId)\r
+PAccount::PAccount(const uint32_t AccountId)\r
{\r
char query[256];\r
mID = 0;\r
{\r
MYSQL_ROW row = 0;\r
MYSQL_RES *result = 0;\r
- \r
+\r
bool FinalResult = false;\r
\r
//result = MySQL->InfoResQuery(query);\r
{\r
Console->Print(YELLOW, BLACK, "Failed to load AccountData from SQL; Nothing to load...");\r
}\r
- \r
+\r
//MySQL->FreeInfoSQLResult(result);\r
MySQL->FreeSQLResult(result);\r
return FinalResult;\r
}\r
\r
+uint32_t PAccount::GetID() const\r
+{\r
+ return mID;\r
+}\r
+\r
bool PAccount::SetName(const std::string &Username)\r
{\r
if(IsUsernameWellFormed(Username.c_str()))\r
}\r
}\r
\r
+const std::string &PAccount::GetName() const\r
+{\r
+ return mName;\r
+}\r
+\r
bool PAccount::SetPassword(const std::string &Password)\r
{\r
if(IsPasswordWellFormed(Password.c_str()))\r
}\r
}\r
\r
-bool PAccount::SetPasswordEncoded(const u8* PasswordData, int PassLen, const u8* Key)\r
+bool PAccount::SetPasswordEncoded(const uint8_t* PasswordData, int PassLen, const uint8_t* Key)\r
{\r
- char Pass[128];\r
- \r
- if(DecodePassword(PasswordData, PassLen, Key, Pass))\r
+ char Pass[128];\r
+\r
+ if(DecodePassword(PasswordData, PassLen, Key, Pass))\r
{\r
- return SetPassword((std::string)Pass);\r
- }\r
- else\r
- {\r
- Console->Print(RED, BLACK, "[Error]: user %s : malformed auth data (size=%d)", mName.c_str(), PassLen);\r
- return false;\r
- }\r
+ return SetPassword((std::string)Pass);\r
+ }\r
+ else\r
+ {\r
+ Console->Print(RED, BLACK, "[Error]: user %s : malformed auth data (size=%d)", mName.c_str(), PassLen);\r
+ return false;\r
+ }\r
+}\r
+\r
+const std::string &PAccount::GetPassword() const\r
+{\r
+ return mPassword;\r
}\r
\r
bool PAccount::SetLevel(int newLevel)\r
}\r
}\r
\r
+int32_t PAccount::GetLevel() const\r
+{\r
+ return mLevel;\r
+}\r
+\r
std::string PAccount::GetLevelString() const\r
{\r
- switch(mLevel)\r
- {\r
- case PAL_BANNED : return "banned";\r
- case PAL_UNREGPLAYER : return "unregplayer";\r
- case PAL_REGPLAYER : return "regplayer";\r
- case PAL_VOLUNTEER : return "volunteer";\r
- case PAL_GM : return "gm";\r
- case PAL_ADMIN : return "admin";\r
- }\r
-\r
- return "custom";\r
+ switch(mLevel)\r
+ {\r
+ case PAL_BANNED : return "banned";\r
+ case PAL_UNREGPLAYER : return "unregplayer";\r
+ case PAL_REGPLAYER : return "regplayer";\r
+ case PAL_VOLUNTEER : return "volunteer";\r
+ case PAL_GM : return "gm";\r
+ case PAL_ADMIN : return "admin";\r
+ }\r
+\r
+ return "custom";\r
}\r
\r
bool PAccount::SetStatus(PAccountStatus Status)\r
return true;\r
}\r
\r
+PAccountStatus PAccount::GetStatus() const\r
+{\r
+ return mStatus;\r
+}\r
+\r
bool PAccount::SetBannedUntilTime(std::time_t BannedUntil)\r
{\r
if ((BannedUntil == 0) || (BannedUntil > std::time(NULL)))\r
}\r
}\r
\r
-bool PAccount::DecodePassword(const u8* PasswordData, int PassLen, const u8 *Key, char* ClearPassword)\r
+bool PAccount::IsBanned() const\r
+{\r
+ return (mBannedUntil > std::time(nullptr));\r
+}\r
+\r
+bool PAccount::DecodePassword(const uint8_t* PasswordData, int PassLen, const uint8_t *Key, char* ClearPassword)\r
{\r
ClearPassword[0] = 0;\r
- \r
+\r
if(PassLen < 128)\r
- {\r
- if(Key[0]>7) // TODO: >7 correct?\r
- {\r
- for(int i=0; i<PassLen; i+=2)\r
- ClearPassword[i>>1] = (char)(((PasswordData[i]&0xf0)>>4)\r
- +((PasswordData[i+1]&0x0f)<<4)-Key[0]);\r
- ClearPassword[PassLen>>1]=0;\r
- }\r
- else\r
- {\r
- for(int i=0; i<PassLen; i++)\r
- ClearPassword[i] = (char)(PasswordData[i]-Key[0]);\r
- ClearPassword[PassLen]=0;\r
- }\r
- return true;\r
- }\r
- else\r
- return false;\r
+ {\r
+ if(Key[0]>7) // TODO: >7 correct?\r
+ {\r
+ for(int i=0; i<PassLen; i+=2)\r
+ ClearPassword[i>>1] = (char)(((PasswordData[i]&0xf0)>>4)\r
+ +((PasswordData[i+1]&0x0f)<<4)-Key[0]);\r
+ ClearPassword[PassLen>>1]=0;\r
+ }\r
+ else\r
+ {\r
+ for(int i=0; i<PassLen; i++)\r
+ ClearPassword[i] = (char)(PasswordData[i]-Key[0]);\r
+ ClearPassword[PassLen]=0;\r
+ }\r
+ return true;\r
+ }\r
+ else\r
+ return false;\r
}\r
\r
-bool PAccount::Authenticate(const u8* PasswordData, int PassLen, const u8 *Key)\r
+bool PAccount::Authenticate(const uint8_t* PasswordData, int PassLen, const uint8_t *Key)\r
{\r
- char Pass[128];\r
- \r
- if(DecodePassword(PasswordData, PassLen, Key, Pass))\r
+ char Pass[128];\r
+\r
+ if(DecodePassword(PasswordData, PassLen, Key, Pass))\r
{\r
- return Authenticate(Pass);\r
- }\r
- else\r
- {\r
- Console->Print(RED, BLACK, "[Error]: user %s : malformed auth data (size=%d)", mName.c_str(), PassLen);\r
- return false;\r
- }\r
+ return Authenticate(Pass);\r
+ }\r
+ else\r
+ {\r
+ Console->Print(RED, BLACK, "[Error]: user %s : malformed auth data (size=%d)", mName.c_str(), PassLen);\r
+ return false;\r
+ }\r
}\r
\r
bool PAccount::Authenticate(const char *Password) const\r
{\r
- if(mID == 0) // User doesn't exist and that hasn't been checked !\r
- {\r
- Console->Print(RED, BLACK, "[Bug]: user %s doesn't exist and was not checked by code !", mName.c_str());\r
- return false;\r
- }\r
- \r
- return(mPassword == Password);\r
+ if(mID == 0) // User doesn't exist and that hasn't been checked !\r
+ {\r
+ Console->Print(RED, BLACK, "[Bug]: user %s doesn't exist and was not checked by code !", mName.c_str());\r
+ return false;\r
+ }\r
+\r
+ return(mPassword == Password);\r
}\r
\r
bool PAccount::Create()\r
char escPassword[256];\r
MySQL->EscapeString(mName.c_str(), escUsername, 256);\r
MySQL->EscapeString(mPassword.c_str(), escPassword, 256);\r
- \r
+\r
std::string Query;\r
Query = CreateMode ? "INSERT INTO" : "UPDATE";\r
Query += " accounts SET ";\r
Query += Ssprintf(", a_priv = %d, a_status = %d, a_bandate = %d", mLevel, mStatus, mBannedUntil);\r
if(!CreateMode )\r
{\r
- Query += Ssprintf(" a_lastused = NOW()");\r
+ Query += Ssprintf(" a_lastused = NOW()");\r
Query += Ssprintf(" WHERE a_id = %d LIMIT 1", mID);\r
}\r
else\r
- Query += Ssprintf(" a_creationdate = NOW()");\r
+ Query += Ssprintf(" a_creationdate = NOW()");\r
\r
//if(MySQL->InfoQuery(Query.c_str()))\r
if(MySQL->Query(Query.c_str()))\r
std::string PAccount::GetBannedTime() const\r
{\r
const char* unit[5] = {"seconds", "minutes", "hours", "days", "weeks"};\r
- \r
+\r
std::time_t timediff = mBannedUntil - std::time(NULL);\r
if(timediff <=0)\r
{\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include <ctime>\r
+#include <string>\r
+\r
+class RegEx;\r
+\r
+/*\r
+0 = unregistered user\r
+1 = Registered user\r
+30 = volunteer\r
+50 = GM\r
+100 = Admin\r
+*/\r
+\r
+// New way of AccountLevel handling:\r
+// Every level is possible, the following values are only edge values. We need a bit control about that\r
+#define PAL_BANNED -1\r
+#define PAL_UNREGPLAYER 0\r
+#define PAL_REGPLAYER 1\r
+#define PAL_VOLUNTEER 30\r
+#define PAL_GM 50\r
+#define PAL_ADMIN 100\r
+\r
+// Max number of char slots per account\r
+#define MAX_CHARS_PER_ACCOUNT 4\r
+\r
+/*\r
+0 = Offline\r
+1 = Online\r
+2 = Banned\r
+*/\r
+\r
+enum PAccountStatus\r
+{\r
+ PAS_OFFLINE = 0,\r
+ PAS_ONLINE = 1,\r
+ PAS_BANNED = 2\r
+};\r
+\r
+class PAccount\r
+{\r
+ private :\r
+ // SQL Layout\r
+ enum {\r
+ a_id,\r
+ a_username,\r
+ a_password,\r
+ a_priv,\r
+ a_status,\r
+ a_bandate,\r
+ a_emailaddress,\r
+ a_creationdate,\r
+ a_lastused\r
+ };\r
+\r
+ // static members\r
+ static RegEx *mUsernameRegexFilter;\r
+ static RegEx *mPasswordRegexFilter;\r
+\r
+ // instance members\r
+ uint32_t mID;\r
+ std::string mName;\r
+ std::string mPassword;\r
+ int32_t mLevel;\r
+ PAccountStatus mStatus;\r
+ std::time_t mBannedUntil;\r
+\r
+ bool LoadFromQuery(char *query);\r
+ bool DecodePassword(const uint8_t *PasswordData, int32_t PassLen, const uint8_t *Key, char *ClearPassword);\r
+\r
+public:\r
+ PAccount();\r
+ PAccount(const uint32_t AccountId);\r
+ PAccount(const char *Username);\r
+\r
+ static bool SetUsernameRegexFilter(const char *RegexStr);\r
+ static bool SetPasswordRegexFilter(const char *RegexStr);\r
+ static bool IsUsernameWellFormed(const char *Username);\r
+ static bool IsPasswordWellFormed(const char *Password);\r
+\r
+ uint32_t GetID() const;\r
+ bool SetName(const std::string &Pass);\r
+ const std::string &GetName() const;\r
+ bool SetPassword(const std::string &Pass);\r
+ bool SetPasswordEncoded(const uint8_t *PasswordData, int32_t PassLen, const uint8_t *Key);\r
+ const std::string &GetPassword() const;\r
+ bool SetLevel(int32_t newLevel);\r
+ int32_t GetLevel() const;\r
+ std::string GetLevelString() const;\r
+ bool SetStatus(PAccountStatus Status);\r
+ PAccountStatus GetStatus() const;\r
+ bool SetBannedUntilTime(std::time_t BannedUntil);\r
+ bool IsBanned() const;\r
+ std::string GetBannedTime() const;\r
+ bool Authenticate(const uint8_t *PasswordData, int32_t PassLen, const uint8_t *Key);\r
+ bool Authenticate(const char *Password) const;\r
+ bool Create();\r
+ bool Save(bool CreateMode = false);\r
+\r
+ //u32 GetCharIdBySlot(const u32 SlotId);\r
+};\r
--- /dev/null
+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})
--- /dev/null
+#include "InfoServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
+\r
+PClient::PClient(int32_t Index)\r
+{\r
+ mIndex = Index;\r
+ mConnection = PCC_NONE;\r
+ mAccountID = 0;\r
+}\r
+\r
+PClient::~PClient()\r
+{\r
+ if(m_TCPConnection)\r
+ {\r
+ delete m_TCPConnection;\r
+ }\r
+}\r
+\r
+int32_t PClient::GetIndex() const\r
+{\r
+ return mIndex;\r
+}\r
+\r
+void PClient::setTCPConnection(ConnectionTCP *conn)\r
+{\r
+ m_TCPConnection = conn; mConnection = PCC_INFO;\r
+}\r
+\r
+ConnectionTCP *PClient::getTCPConn() const\r
+{\r
+ return m_TCPConnection;\r
+}\r
+\r
+int32_t PClient::GetConnection() const\r
+{\r
+ return mConnection;\r
+}\r
+\r
+const char *PClient::GetAddress() const\r
+{\r
+ return m_TCPConnection->getRemoteAddress();\r
+}\r
+\r
+void PClient::setAccountID(uint32_t nAccountID)\r
+{\r
+ mAccountID = nAccountID;\r
+}\r
+\r
+uint32_t PClient::getAccountID()\r
+{\r
+ return mAccountID;\r
+}\r
+\r
+void PClient::InfoDisconnect()\r
+{\r
+ if(m_TCPConnection)\r
+ {\r
+ delete m_TCPConnection;\r
+ }\r
+ m_TCPConnection = 0;\r
+\r
+ //mConnection &= ~PCC_INFO;\r
+ mConnection = PCC_NONE;\r
+ mAccountID = 0;\r
+}\r
+\r
+void PClient::Update()\r
+{\r
+ if(m_TCPConnection)\r
+ {\r
+ if(m_TCPConnection->timeOut())\r
+ {\r
+ Console->Print("InfoSocket: Client %i: timeout", mIndex);\r
+ InfoServer->ClientDisconnected(this);\r
+ }\r
+ else\r
+ {\r
+ if(!m_TCPConnection->update())\r
+ {\r
+ InfoServer->ClientDisconnected(this);\r
+ }\r
+ }\r
+ }\r
+}\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+\r
+class ConnectionTCP;\r
+\r
+enum PClientConnection\r
+{\r
+ PCC_NONE = 0,\r
+ PCC_INFO = 1\r
+};\r
+\r
+class PClient {\r
+private:\r
+ ConnectionTCP* m_TCPConnection;\r
+ int32_t mIndex;\r
+ int32_t mConnection;\r
+ uint32_t mAccountID;\r
+\r
+public:\r
+ PClient(int32_t Index);\r
+ ~PClient();\r
+\r
+ int32_t GetIndex() const;\r
+ void setTCPConnection(ConnectionTCP *conn);\r
+ ConnectionTCP *getTCPConn() const;\r
+ int32_t GetConnection() const;\r
+ const char *GetAddress() const;\r
+ void setAccountID(uint32_t nAccountID);\r
+ uint32_t getAccountID();\r
+ void InfoDisconnect();\r
+ void Update();\r
+};\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
+#pragma once\r
\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
- Configuration template for infoserver\r
- Used to set available/optional/required options when loading config\r
- with a PConfig object.\r
-*/\r
-\r
-const char* InfoConfigTemplate[][2] = {\r
+static const char *InfoConfigTemplate[][2] = {\r
// {option_name, default_value} if default_value is empty string, it means option is mandatory\r
// List ends with empty string for option_name\r
{"sql_host", "127.0.0.1"}, // should be renanmed to info_sql_host\r
{"password_filter", "^[[:graph:]]{3,15}$"},\r
{"sqlite_databasefile", "infoDB.s3db"},\r
{"database_type", "sqlite"},\r
- \r
- \r
+\r
// For futur use:\r
// {"max_chars_per_account", "4"},\r
\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- MODIFIED: 27 Aug 2006 Hammag\r
- REASON: - Implemented shared Config class use and config template to load conf.\r
- - Added gameserver configtemplate.h include,\r
- - Added new required parameters to Config->LoadOptions()\r
- - Added AdditionnalConfigChecks() local function, called after config loading\r
- taken from inital infoserver's PConfig::VerifyValues\r
- MODIFIED: 10 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
-*/\r
-\r
-\r
-#include "main.h"\r
-#include "configtemplate.h"\r
-\r
-#include "include/version.h"\r
-\r
+#include <cstring>\r
+#include "InfoServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
const char ServerVersion[] = TINNS_INFO_VERSION;\r
const char SVNRevision[] = TINNS_SVN_REVISION;\r
\r
bool Init()\r
{\r
- Console = new PConsole("log/infoserver.log"); // Make that from config file !!!\r
- Console->Print("Starting TinNS Infoserver");\r
- Console->Print(WHITE, BLUE, "/-------------------------------------------------------------------\\");\r
- Console->Print(WHITE, BLUE, "| TinNS (TinNS is not a Neocron Server) |");\r
+ Console = new PConsole("log/infoserver.log"); // Make that from config file !!!\r
+ Console->Print("Starting TinNS Infoserver");\r
+ Console->Print(WHITE, BLUE, "/-------------------------------------------------------------------\\");\r
+ Console->Print(WHITE, BLUE, "| TinNS (TinNS is not a Neocron Server) |");\r
Console->Print(WHITE, BLUE, "| Copyright (C) 2005 Linux Addicted Community |");\r
- Console->Print(WHITE, BLUE, "| maintainer Akiko <akiko@gmx.org> |");\r
- Console->Print(WHITE, BLUE, "| ========================================== |");\r
- Console->Print(WHITE, BLUE, "| Head coders: The packet analyzing team: |");\r
- Console->Print(WHITE, BLUE, "| - Akiko - MaxxJag |");\r
- Console->Print(WHITE, BLUE, "| - bakkdoor - Sting |");\r
- Console->Print(WHITE, BLUE, "| - Namikon - Balm |");\r
- Console->Print(WHITE, BLUE, "| - Hammag |");\r
- Console->Print(WHITE, BLUE, "|-------------------------------------------------------------------|");\r
- Console->Print(WHITE, BLUE, "| This project would'nt be at its current stage without the help |");\r
+ Console->Print(WHITE, BLUE, "| maintainer Akiko <akiko@gmx.org> |");\r
+ Console->Print(WHITE, BLUE, "| ========================================== |");\r
+ Console->Print(WHITE, BLUE, "| Head coders: The packet analyzing team: |");\r
+ Console->Print(WHITE, BLUE, "| - Akiko - MaxxJag |");\r
+ Console->Print(WHITE, BLUE, "| - bakkdoor - Sting |");\r
+ Console->Print(WHITE, BLUE, "| - Namikon - Balm |");\r
+ Console->Print(WHITE, BLUE, "| - Hammag |");\r
+ Console->Print(WHITE, BLUE, "|-------------------------------------------------------------------|");\r
+ Console->Print(WHITE, BLUE, "| This project would'nt be at its current stage without the help |");\r
Console->Print(WHITE, BLUE, "| from the NeoPolis team, special thanks to you guys! |");\r
- Console->Print(WHITE, BLUE, "|-------------------------------------------------------------------|");\r
- Console->Print(WHITE, BLUE, "| This project is under GPL, see any source file for more details |");\r
- Console->Print(WHITE, BLUE, "\\-------------------------------------------------------------------/");\r
-\r
- //char svnrev[10];\r
- //GetSVNRev(svnrev);\r
- Console->LPrint("You are running TinNS Infoserver version");\r
- Console->LPrint(GREEN, BLACK, " %s", ServerVersion);\r
- Console->LPrint(WHITE, BLACK, " - SVN Rev");\r
- Console->LPrint(GREEN, BLACK, " %s", SVNRevision);\r
- Console->LClose();\r
- \r
- Config = new PConfig();\r
- if(!Config->LoadOptions(InfoConfigTemplate, "./conf/infoserver.conf"))\r
- return false; //Shutdown();\r
+ Console->Print(WHITE, BLUE, "|-------------------------------------------------------------------|");\r
+ Console->Print(WHITE, BLUE, "| This project is under GPL, see any source file for more details |");\r
+ Console->Print(WHITE, BLUE, "\\-------------------------------------------------------------------/");\r
+\r
+ //char svnrev[10];\r
+ //GetSVNRev(svnrev);\r
+ Console->LPrint("You are running TinNS Infoserver version");\r
+ Console->LPrint(GREEN, BLACK, " %s", ServerVersion);\r
+ Console->LPrint(WHITE, BLACK, " - SVN Rev");\r
+ Console->LPrint(GREEN, BLACK, " %s", SVNRevision);\r
+ Console->LClose();\r
+\r
+ Config = new PConfig();\r
+ if(!Config->LoadOptions(InfoConfigTemplate, "./conf/infoserver.conf"))\r
+ return false; //Shutdown();\r
if(!AdditionnalConfigChecks())\r
return false; //Shutdown();\r
\r
- ServerSock = new ServerSocket();\r
- Server = new PServer();\r
- \r
- MySQL = new PMySQL();\r
+ ServerSock = new ServerSocket();\r
+ Server = new PServer();\r
+\r
+ MySQL = new PMySQL();\r
if(MySQL->Connect() == false)\r
- return false; //Shutdown();\r
+ return false; //Shutdown();\r
\r
- InfoServer = new PInfoServer();\r
- //Accounts = new PAccounts(); // To be removed\r
+ InfoServer = new PInfoServer();\r
+ //Accounts = new PAccounts(); // To be removed\r
\r
- return true;\r
+ return true;\r
}\r
\r
void Shutdown()\r
{\r
if(Server) Server->Shutdown();\r
- if(InfoServer) delete InfoServer;\r
- if(MySQL) delete MySQL;\r
- if(Config) delete Config;\r
- if(Console) delete Console;\r
- if(ServerSock) delete ServerSock;\r
+ if(InfoServer) delete InfoServer;\r
+ if(MySQL) delete MySQL;\r
+ if(Config) delete Config;\r
+ if(Console) delete Console;\r
+ if(ServerSock) delete ServerSock;\r
exit(0);\r
}\r
\r
bool AdditionnalConfigChecks()\r
{\r
//NOTA: empty config values are never accepted by PConfig objects\r
- \r
+\r
int numErr, numWarn;\r
- \r
+\r
//std::string sqlhost = Config->GetOption("sql_host");\r
std::string sqlusername = Config->GetOption("sql_username");\r
//std::string sqlpassword = Config->GetOption("sql_password");\r
Console->Print("%s Config: minlevel has to be between 0 and 255", Console->ColorText(RED, BLACK, "[Error]"));\r
numErr++;\r
}\r
- \r
+\r
if(maxclients < 1 )\r
{\r
Console->Print("%s Config: maxclients has to be higher or equal to 1", Console->ColorText(RED, BLACK, "[Error]"));\r
numErr++;\r
}\r
- \r
+\r
if(numErr == 0 /*&& numWarn == 0*/)\r
return true;\r
else\r
return false;\r
}\r
-\r
-\r
--- /dev/null
+#pragma once\r
+\r
+#include "InfoServer/Accounts.hxx"\r
+#include "InfoServer/ConfigTemplate.hxx"\r
+#include "InfoServer/Client.hxx"\r
+#include "InfoServer/InfoServer.hxx"\r
+#include "InfoServer/Server.hxx"\r
+#include "InfoServer/Sql.hxx"\r
+\r
+extern class ServerSocket* ServerSock;\r
+extern class PConsole *Console;\r
+extern class PServer *Server;\r
+extern class PConfig *Config;\r
+extern class PInfoServer *InfoServer;\r
+\r
+extern class PMySQL* MySQL;\r
+//extern class PAccounts* Accounts; // To be removed\r
+\r
+extern const char ServerVersion[];\r
+extern const char SVNRevision[];\r
+\r
+bool Init();\r
+void Shutdown();\r
+bool AdditionnalConfigChecks();\r
--- /dev/null
+#include <cstring>\r
+#include "InfoServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
+\r
+struct PInfoState\r
+{\r
+ enum State\r
+ {\r
+ IS_UNKNOWN,\r
+ IS_CONNECTED,\r
+ IS_HANDSHAKE0,\r
+ IS_AUTHENTICATE,\r
+ IS_SERVERLIST\r
+ } mState;\r
+\r
+ bool mWaitSend; // wait-for-completition flag\r
+ PInfoState()\r
+ {\r
+ mState = IS_UNKNOWN;\r
+ mWaitSend = false;\r
+ };\r
+};\r
+\r
+PInfoServer::PInfoServer()\r
+{\r
+ //mNumClients = 1;\r
+ mLivecheckInterval = Config->GetOptionInt("gameserver_livecheck");\r
+}\r
+\r
+PInfoServer::~PInfoServer()\r
+{\r
+ Console->Print("Closing Infoserver...");\r
+\r
+ ServerSock->closeServer();\r
+\r
+ for(InfoStateMap::iterator i=ClientStates.begin(); i!=ClientStates.end(); i++)\r
+ delete i->second;\r
+}\r
+\r
+void PInfoServer::Start()\r
+{\r
+ uint16_t Port = Config->GetOptionInt("infoserver_port");\r
+ Console->LPrint("Starting Infoserver on port %i...", Port);\r
+\r
+ if(ServerSock->open(Port))\r
+ {\r
+ Console->LPrint(GREEN, BLACK, "Success");\r
+ Console->LClose();\r
+ }\r
+ else\r
+ {\r
+ Console->LPrint(RED, BLACK, "Failed");\r
+ Console->LClose();\r
+ }\r
+ ServerSock->settimeout(0, 10000);\r
+ GSLiveCheck();\r
+}\r
+\r
+void PInfoServer::Update()\r
+{\r
+ if(ServerSock->newConnection())\r
+ {\r
+ int32_t clid = Server->NewClient();\r
+ if(clid!=-1)\r
+ {\r
+ Console->Print(GREEN, BLACK, "Infoserver: client [%i] connected", clid);\r
+ PClient *Client = Server->GetClient(clid);\r
+\r
+ ConnectionTCP* tcpConn = ServerSock->getTCPConnection();\r
+ Client->setTCPConnection(tcpConn);\r
+\r
+ Console->Print("Client address: %s", Client->GetAddress());\r
+ //++mNumClients;\r
+\r
+ PInfoState *state = new PInfoState();\r
+ ClientStates.insert(std::make_pair(Client, state));\r
+ state->mState = PInfoState::IS_CONNECTED;\r
+ } else\r
+ {\r
+ Console->Print("Infoserver: Client connection refused (server full?)");\r
+ }\r
+ }\r
+\r
+ for(InfoStateMap::iterator i=ClientStates.begin(); i!=ClientStates.end();)\r
+ {\r
+ PClient *Client = i->first;\r
+ PInfoState *State = i->second;\r
+ // node gets erased in FinalizeClient, increment iterator now\r
+ ++i;\r
+ if(!ProcessClient(Client, State))\r
+ FinalizeClient(Client, State);\r
+ }\r
+}\r
+\r
+void PInfoServer::GSLiveCheck()\r
+{\r
+ MYSQL_ROW row;\r
+ MYSQL_RES *result;\r
+ char query[256];\r
+ snprintf (query, 256, "SELECT *, (NOW()< (`s_lastupdate` + INTERVAL %d SECOND)) FROM `server_list`", mLivecheckInterval);\r
+\r
+ result = MySQL->ResQuery(query);\r
+ if (result == nullptr)\r
+ {\r
+ Console->Print("Livecheck: %s unable to read server list!", Console->ColorText(RED, BLACK, "[Warning]"));\r
+ MySQL->ShowSQLError();\r
+ return;\r
+ }\r
+ if(mysql_num_rows(result) == 0)\r
+ {\r
+ Console->Print("Livecheck: %s no gameserver found!", Console->ColorText(RED, BLACK, "[Warning]"));\r
+ MySQL->FreeSQLResult(result);\r
+ return;\r
+ }\r
+\r
+ ServerMap::iterator it;\r
+ while((row = mysql_fetch_row(result)))\r
+ {\r
+ it = Serverlist.find(atoi(row[s_id]));\r
+ if(it != Serverlist.end())\r
+ {\r
+ strncpy(it->second.mName, row[s_name], MAX_SERVER_NAME_LENGTH);\r
+ it->second.mLanIp = IPStringToDWord(row[s_lanaddr]);\r
+ it->second.mWanIp = IPStringToDWord(row[s_wanaddr]);\r
+ it->second.mPort = atoi(row[s_port]);\r
+ it->second.mPlayers = atoi(row[s_players]);\r
+ /* Prepared for future addon Servers by Accesslevel */\r
+ // it->second.mMinLv = atoi(row[s_minlv]);\r
+ /* ------------------------------------------------ */\r
+\r
+ // ToDo: If statement correct? Maybe GSLiveCheck() has\r
+ // to be called every mLinvecheckInterval seconds.... We'll\r
+ // see when Gameserver has been rewritten\r
+\r
+ if(row[s_timecheck] && (atoi(row[s_timecheck]) == 1))\r
+ {\r
+ it->second.mLasttimestamp = atol(row[s_lastupdate]);\r
+ it->second.mOnline = true;\r
+ }\r
+ else\r
+ {\r
+ it->second.mOnline = false;\r
+ }\r
+\r
+ it->second.mUpdated = true;\r
+ }\r
+ else\r
+ {\r
+ GameServers tmpServer;\r
+\r
+ strncpy(tmpServer.mName, row[s_name], MAX_SERVER_NAME_LENGTH);\r
+ tmpServer.mLanIp = IPStringToDWord(row[s_lanaddr]);\r
+ tmpServer.mWanIp = IPStringToDWord(row[s_wanaddr]);\r
+ tmpServer.mLasttimestamp = atol(row[s_lastupdate]);\r
+ tmpServer.mPlayers = atoi(row[s_players]);\r
+ tmpServer.mPort = atoi(row[s_port]);\r
+ tmpServer.mOnline = true;\r
+ tmpServer.mUpdated = true;\r
+ Console->Print("Added GameServer %s", tmpServer.mName);\r
+ /* Prepared for future addon Servers by Accesslevel */\r
+ // tmpServer.mMinLv = atoi(row[s_minlv]);\r
+ /* ------------------------------------------------ */\r
+\r
+ Serverlist.insert(std::make_pair(atoi(row[s_id]), tmpServer));\r
+ }\r
+ }\r
+ MySQL->FreeSQLResult(result);\r
+\r
+ for(ServerMap::iterator it = Serverlist.begin(); it != Serverlist.end(); it++)\r
+ {\r
+ if(it->second.mUpdated == false)\r
+ Serverlist.erase(it);\r
+ else\r
+ it->second.mUpdated = false;\r
+ }\r
+\r
+}\r
+\r
+void PInfoServer::ClientDisconnected(PClient *Client)\r
+{\r
+ InfoStateMap::iterator node = ClientStates.find(Client);\r
+ if(node == ClientStates.end())\r
+ return;\r
+\r
+ PInfoState *State = node->second;\r
+ FinalizeClient(Client, State);\r
+}\r
+\r
+bool PInfoServer::HandleHandshake(PInfoState *State, const uint8_t *Packet, int32_t PacketSize)\r
+{\r
+ //static const uint8_t HANDSHAKE1A[6]={0xfe, 0x03, 0x00, 0x80, 0x03, 0x68};\r
+\r
+ switch(State->mState)\r
+ {\r
+ case PInfoState::IS_HANDSHAKE0 :\r
+ {\r
+ if(PacketSize==6 && *(uint16_t*)&Packet[3]==0x0080 && Packet[5]==0x78)\r
+ {\r
+ //FIXME: this packet seems to be unnecessary, although it appears in traffic dumps\r
+ // (causes clientside "Wrong protocol" errors)\r
+ //Socket->Write(HANDSHAKE1A, 6);\r
+ State->mState = PInfoState::IS_AUTHENTICATE;\r
+ }\r
+ else\r
+ {\r
+ Console->Print(RED, BLACK, "Infoserver protocol error (IS_HANDSHAKE0): invalid packet [%04x]", *(uint16_t*)&Packet[3]);\r
+ return false;\r
+ }\r
+ break;\r
+ }\r
+ default:\r
+ break;\r
+ }\r
+\r
+ return true;\r
+}\r
+\r
+bool PInfoServer::HandleAuthenticate(PClient *Client, PInfoState *State, const uint8_t *Packet, int32_t PacketSize)\r
+{\r
+ int32_t returnval = 0;\r
+ // ReturnValue values:\r
+ // 0: No error\r
+ // -1: Wrong/Unknown username\r
+ // -2: Wrong Password\r
+ // -3: Malformed Auth Data. Please relog\r
+ // -4: Database error, contact admin\r
+ // -5: No such account, Account created. Please relog\r
+ // -6: Could not create autoaccount, PW too short\r
+ // -7: Could not create autoaccount, Name too short\r
+ // -8: Could not create autoaccount, PW and Name too short\r
+ // -9: Duplicate entry for Username! Contact Admin\r
+ // -10: User is banned\r
+ // -11: Insufficient access rights\r
+ // -12: Account is not yet activated (accesslevel = 0)\r
+ // -99: General fault. Contact admin\r
+ ConnectionTCP *Socket = Client->getTCPConn();\r
+ PAccount* currentAccount = NULL;\r
+\r
+ if (PacketSize > 20 && *(uint16_t *)&Packet[3] == 0x8084)\r
+ {\r
+ const uint8_t *Key = &Packet[5]; // password key\r
+ uint16_t ULen = *(uint16_t *)&Packet[16]; // username length\r
+ uint16_t PLen = *(uint16_t *)&Packet[18]; // password length\r
+ char *UserName = (char *)&Packet[20]; // account name\r
+ const uint8_t *PW = &Packet[20 + ULen]; // encoded password\r
+\r
+ if (UserName[ULen-1]) // Check that string is well terminated\r
+ {\r
+ Console->Print("Infoserver: Client [%d]: Username was not NULL-terminated !", Client->GetIndex());\r
+ returnval = -1;\r
+ }\r
+ else\r
+ {\r
+ currentAccount = new PAccount(UserName);\r
+ if(!currentAccount->GetID())\r
+ {\r
+ if(Config->GetOptionInt("auto_accounts")) // Autoaccount\r
+ {\r
+ delete currentAccount;\r
+ currentAccount = new PAccount();\r
+\r
+ if(!currentAccount->SetName(UserName)) // !!! len\r
+ {\r
+ returnval = -7;\r
+ }\r
+ if(!currentAccount->SetPasswordEncoded(PW, PLen, Key))\r
+ {\r
+ returnval = returnval ? -8 : -6;\r
+ }\r
+\r
+ if(!returnval)\r
+ {\r
+ if(currentAccount->Create())\r
+ {\r
+ returnval = -5;\r
+ }\r
+ else\r
+ {\r
+ returnval = -4;\r
+ }\r
+ }\r
+ }\r
+ else\r
+ {\r
+ returnval = -1;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ if(currentAccount->Authenticate(PW, PLen, Key))\r
+ { // Username & Password correct\r
+ if(currentAccount->IsBanned())\r
+ {\r
+ returnval = -10;\r
+ }\r
+ else if(currentAccount->GetLevel() < Config->GetOptionInt("minlevel")) // insufficient access rights\r
+ {\r
+ returnval = -11;\r
+ }\r
+ else if(Config->GetOptionInt("require_validation") == 1 && currentAccount->GetLevel() == PAL_UNREGPLAYER)\r
+ {\r
+ returnval = -12;\r
+ }\r
+ else\r
+ {\r
+ Client->setAccountID(currentAccount->GetID());\r
+ returnval = 0;\r
+ }\r
+\r
+ }\r
+ else\r
+ {\r
+ returnval = -2;\r
+ }\r
+ }\r
+ }\r
+\r
+ bool Failed = false;\r
+ if(returnval == 0)\r
+ {\r
+ uint8_t AUTHOK[28]={0xfe, 0x19, 0x00, 0x83, 0x81, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,\r
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
+ 0x00, 0x00, 0x00, 0x00, 0x00 };\r
+ *(uint32_t *)&AUTHOK[5] = currentAccount->GetID();\r
+ Socket->write(AUTHOK, 28);\r
+ State->mState = PInfoState::IS_SERVERLIST;\r
+ }\r
+ else\r
+ {\r
+ Console->Print("Infoserver: User '%s': authentication failed. Errorcode %d", UserName, returnval);\r
+ Failed = true; // auth failed\r
+ }\r
+ if(Failed == true)\r
+ {\r
+ std::string errorReason;\r
+ switch(returnval)\r
+ {\r
+ // It seems that the client cuts the line off after 40 chars...\r
+// |1 |10 |20 |30 |40 |50 |60 |70 |80\r
+ case -99:\r
+ {\r
+ //errorReason = "General fault in processing your login request";\r
+ errorReason = "General fault while login request";\r
+ break;\r
+ }\r
+ case -12:\r
+ {\r
+ //errorReason = "Account not activated. Please check your EMails";\r
+ errorReason = "Error: Your account is not activated";\r
+ break;\r
+ }\r
+ case -11:\r
+ {\r
+ //errorReason = "Login rejected. You have to be " + GetAccessString(Config->GetOptionInt("minlevel")) + " or higher";\r
+ errorReason = "Level " + GetAccessString(Config->GetOptionInt("minlevel")) + " or higher required";\r
+ break;\r
+ }\r
+ case -10:\r
+ {\r
+ errorReason = "You are banned for " + currentAccount->GetBannedTime();\r
+ break;\r
+ }\r
+ case -9:\r
+ {\r
+ //errorReason = "Duplicate entry for this login. Contact Admin";\r
+ errorReason = "Duplicate entry found. Contact Admin";\r
+ break;\r
+ }\r
+ case -8:\r
+ {\r
+ //errorReason = "Autoaccount failed, name and password too short";\r
+ errorReason = "AutoAcc failed, name and pwd too short";\r
+ break;\r
+ }\r
+ case -7:\r
+ {\r
+ errorReason = "Autoaccount failed, name is too short";\r
+ break;\r
+ }\r
+ case -6:\r
+ {\r
+ //errorReason = "Autoaccount failed, password is too short";\r
+ errorReason = "Autoaccount failed, pwd is too short";\r
+ break;\r
+ }\r
+ case -5:\r
+ {\r
+ errorReason = "New Account created, please login again";\r
+ break;\r
+ }\r
+ case -4:\r
+ {\r
+ errorReason = "Database error, contact Administrator";\r
+ break;\r
+ }\r
+ case -3:\r
+ {\r
+ errorReason = "Malformed AuthData. Please login again";\r
+ break;\r
+ }\r
+ case -2:\r
+ {\r
+ errorReason = "Wrong password";\r
+ break;\r
+ }\r
+ case -1:\r
+ {\r
+ errorReason = "Unknown username";\r
+ break;\r
+ }\r
+ }\r
+ uint8_t AUTHFAILED_HEADER[] = {0xfe, 0x0c, 0x00, 0x83, 0x86, 0x05, 0x00, 0x06, 0x00};\r
+ uint8_t AUTHFAILED_FOOTER[] = {0x00, 0x40};\r
+ *(uint16_t *)&AUTHFAILED_HEADER[1] = errorReason.size() + 8;\r
+ *(uint16_t *)&AUTHFAILED_HEADER[7] = errorReason.size() + 1;\r
+ //*(uint8_t*)&AUTHFAILED_FOOTER[1] = {0x40};\r
+\r
+ Socket->write(AUTHFAILED_HEADER, sizeof(AUTHFAILED_HEADER));\r
+ Socket->write(errorReason.c_str(), errorReason.size());\r
+ Socket->write(AUTHFAILED_FOOTER, sizeof(AUTHFAILED_FOOTER));\r
+ FinalizeClientDelayed(Client, State);\r
+ State->mState=PInfoState::IS_UNKNOWN;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ Console->Print(RED, BLACK, "Infoserver protocol error (IS_AUTHENTICATE): invalid packet [%04x]",\r
+ *(uint16_t *)&Packet[3]);\r
+ return false;\r
+ }\r
+\r
+ return true;\r
+}\r
+\r
+bool PInfoServer::HandleServerList(PClient *Client, const uint8_t *Packet, int32_t PacketSize)\r
+{\r
+ uint8_t SERVERLIST_HEAD[] = {0xfe, 0x00, 0x00, 0x83, 0x83, 0x01, 0x00, 0x0d, 0x00};\r
+ uint8_t SERVERLIST[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};\r
+ uint8_t SERVERLIST_FOOTER[] = {0x00};\r
+\r
+ ConnectionTCP *Socket = Client->getTCPConn();\r
+\r
+ uint32_t tID = *(uint32_t *)&Packet[5];\r
+ PAccount* currentAccount = new PAccount(Client->getAccountID());\r
+ uint32_t aID = currentAccount->GetID();\r
+\r
+ if(!aID || (aID != tID))\r
+ {\r
+ Console->Print("%s invalid userID %d (auth with id %d)", Console->ColorText(YELLOW, BLACK, "Warning:"), tID, aID);\r
+ delete currentAccount;\r
+ return false;\r
+ }\r
+\r
+ if(currentAccount->GetLevel() < Config->GetOptionInt("minlevel"))\r
+ {\r
+ Console->Print("%s someone tried to bypass the login process! UserID %d", Console->ColorText(RED, BLACK, "Warning:"), aID);\r
+ delete currentAccount;\r
+ return false;\r
+ }\r
+\r
+ if(PacketSize == 31 && *(uint16_t *)&Packet[3]==0x8284)\r
+ {\r
+ GSLiveCheck(); // Perform livecheck to have up-to-date data\r
+\r
+ int32_t len = 0;\r
+ int32_t num = 0;\r
+ for(ServerMap::iterator it = Serverlist.begin(); it != Serverlist.end(); it++)\r
+ {\r
+ num++;\r
+ len += 14 + strlen(it->second.mName);\r
+ }\r
+\r
+ *(uint16_t *)&SERVERLIST_HEAD[1] = len;\r
+ *(uint8_t *)&SERVERLIST_HEAD[5] = num;\r
+ Socket->write(SERVERLIST_HEAD, sizeof(SERVERLIST_HEAD));\r
+\r
+ for(ServerMap::iterator it = Serverlist.begin(); it != Serverlist.end(); it++)\r
+ {\r
+ /* Prepared for future addon Servers by Accesslevel */\r
+// if(accesslevel >= it->second.mMinLv)\r
+// {\r
+ /* ------------------------------------------------ */\r
+ // Todo: Set correct lan/wan IP here!\r
+ *(uint32_t *)&SERVERLIST[0] = it->second.mLanIp;\r
+ *(uint16_t *)&SERVERLIST[4] = it->second.mPort;\r
+ *(uint8_t *)&SERVERLIST[8] = strlen(it->second.mName) + 1;\r
+ *(uint16_t *)&SERVERLIST[9] = it->second.mPlayers;\r
+ if(it->second.mOnline == true)\r
+ {\r
+ Console->Print("Sending server name: %s ip: %s player: %d port: %d online: yes", it->second.mName,\r
+ IPlongToString(it->second.mLanIp), it->second.mPlayers, it->second.mPort);\r
+ *(uint16_t *)&SERVERLIST[11] = 1;\r
+ }\r
+ else if(it->second.mOnline == false)\r
+ {\r
+ Console->Print("Sending server name: %s ip: %s player: %d port: %d online: no", it->second.mName,\r
+ IPlongToString(it->second.mLanIp), it->second.mPlayers, it->second.mPort);\r
+ *(uint16_t *)&SERVERLIST[11] = 0;\r
+ }\r
+ Socket->write(SERVERLIST, sizeof(SERVERLIST));\r
+ Socket->write(it->second.mName, strlen(it->second.mName));\r
+ Socket->write(SERVERLIST_FOOTER, sizeof(SERVERLIST_FOOTER));\r
+ /* Prepared for future addon Servers by Accesslevel */\r
+// }\r
+ /* ------------------------------------------------ */\r
+ }\r
+ }\r
+ else\r
+ {\r
+ Console->Print(RED, BLACK, "Infoserver protocol error (IS_SERVERLIST): invalid packet [%04x]",\r
+ *(uint16_t *)&Packet[3]);\r
+ delete currentAccount;\r
+ return false;\r
+ }\r
+ delete currentAccount;\r
+ return true;\r
+}\r
+\r
+bool PInfoServer::ProcessClient(PClient *Client, PInfoState *State)\r
+{\r
+ static const uint8_t HANDSHAKE0A[6]={0xfe, 0x03, 0x00, 0x80, 0x01, 0x66};\r
+\r
+ if(!State)\r
+ {\r
+ InfoStateMap::iterator node = ClientStates.find(Client);\r
+ if(node == ClientStates.end())\r
+ return false;\r
+\r
+ State = node->second;\r
+ }\r
+\r
+ ConnectionTCP *Socket = Client->getTCPConn();\r
+\r
+ if(State->mWaitSend && Socket->getSendBufferSize()==0)\r
+ return false;\r
+\r
+ if(State->mState==PInfoState::IS_CONNECTED)\r
+ {\r
+ Socket->write(HANDSHAKE0A, 6);\r
+ State->mState = PInfoState::IS_HANDSHAKE0;\r
+ }\r
+\r
+ int32_t PacketSize=0;\r
+ const uint8_t *Packet = Socket->read(&PacketSize);\r
+ if(PacketSize > 0)\r
+ {\r
+ switch(State->mState)\r
+ {\r
+ case PInfoState::IS_HANDSHAKE0:\r
+ return HandleHandshake(State, Packet, PacketSize);\r
+\r
+ case PInfoState::IS_AUTHENTICATE:\r
+ return HandleAuthenticate(Client, State, Packet, PacketSize);\r
+\r
+ case PInfoState::IS_SERVERLIST:\r
+ return HandleServerList(Client, Packet, PacketSize);\r
+ default:\r
+ break;\r
+ }\r
+ }\r
+ return true;\r
+}\r
+\r
+void PInfoServer::FinalizeClient(PClient *Client, PInfoState *State)\r
+{\r
+ Console->Print(RED, BLACK, "Infoserver: client %s disconnected", Client->GetAddress());\r
+ Client->InfoDisconnect();\r
+ ClientStates.erase(Client);\r
+ delete State;\r
+}\r
+\r
+void PInfoServer::FinalizeClientDelayed(PClient *Client, PInfoState *State)\r
+{\r
+ Console->Print("Infoserver: client %i is about to be disconnected", Client->GetIndex());\r
+ State->mWaitSend = true;\r
+}\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include <map>\r
+\r
+class PClient;\r
+struct PInfoState;\r
+\r
+#define MAX_SERVER_NAME_LENGTH 45\r
+struct GameServers {\r
+ char mName[MAX_SERVER_NAME_LENGTH];\r
+ uint32_t mLanIp;\r
+ uint32_t mWanIp;\r
+ int16_t mPort;\r
+ int32_t mPlayers;\r
+ bool mOnline;\r
+ bool mUpdated;\r
+ time_t mLasttimestamp;\r
+/* Prepared for future addon Servers by Accesslevel */\r
+// int mMinLv;\r
+/* ------------------------------------------------ */\r
+};\r
+\r
+class PInfoServer {\r
+private:\r
+ // SQL layout\r
+ enum {\r
+ s_id,\r
+ s_name,\r
+ s_wanaddr,\r
+ s_port,\r
+ s_players,\r
+ s_lastupdate,\r
+ s_lanaddr,\r
+ s_timecheck // computed field, not in table !\r
+ };\r
+ //int mNumClients;\r
+ typedef std::map<PClient *, struct PInfoState *> InfoStateMap;\r
+ InfoStateMap ClientStates;\r
+\r
+ typedef std::map<int32_t, GameServers> ServerMap;\r
+ ServerMap Serverlist;\r
+\r
+ //time_t mLastLivecheck;\r
+ int mLivecheckInterval;\r
+ void GSLiveCheck();\r
+\r
+protected:\r
+ bool ProcessClient(PClient *Client, PInfoState *State = nullptr);\r
+ void FinalizeClient(PClient *Client, PInfoState *State);\r
+ void FinalizeClientDelayed(PClient *Client, PInfoState *State);\r
+\r
+ bool HandleHandshake(PInfoState *State, const uint8_t *Packet, int32_t PacketSize);\r
+ bool HandleAuthenticate(PClient *Client, PInfoState *State, const uint8_t *Packet, int32_t PacketSize);\r
+ bool HandleServerList(PClient *Client, const uint8_t *Packet, int32_t PacketSize);\r
+\r
+public:\r
+ PInfoServer();\r
+ ~PInfoServer();\r
+\r
+ void Start();\r
+ void Update();\r
+ void ClientDisconnected(PClient *Client);\r
+};\r
--- /dev/null
+#include <csignal>\r
+#include "InfoServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
+\r
+void signal_handler(int signal)\r
+{\r
+ if (signal == SIGINT)\r
+ Shutdown();\r
+}\r
+\r
+int main()\r
+{\r
+ signal(SIGINT, signal_handler);\r
+\r
+ if (!Init())\r
+ {\r
+ if(Console)\r
+ Console->Print("%s Aborting startup.", Console->ColorText(RED, BLACK, "[Fatal]"));\r
+ Shutdown(); // exits with 0 ...\r
+ }\r
+\r
+ InfoServer->Start();\r
+ Console->Print("Infoserver is now %s. Waiting for clients...", Console->ColorText(GREEN, BLACK, "Online"));\r
+\r
+ while (true)\r
+ {\r
+ ServerSock->update();\r
+ Server->Update();\r
+ InfoServer->Update();\r
+ MySQL->Update(); // MySQL keepalive\r
+ Console->Update();\r
+ }\r
+\r
+ return 0;\r
+}\r
--- /dev/null
+#include "InfoServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
+\r
+PServer::PServer()\r
+{\r
+ mMaxClients = Config->GetOptionInt("maxclients");\r
+\r
+ mClients.reserve(mMaxClients);\r
+ mNumClients = 0;\r
+ for (int32_t i=0; i<mMaxClients; i++)\r
+ mClients[i]=0;\r
+}\r
+\r
+PServer::~PServer()\r
+{\r
+ for (int32_t i=0; i<mMaxClients; i++)\r
+ delete mClients[i];\r
+}\r
+\r
+int32_t PServer::GetNumClients() const\r
+{\r
+ return mNumClients;\r
+}\r
+\r
+int PServer::NewClient()\r
+{\r
+ if(mNumClients==mMaxClients)\r
+ return -1;\r
+\r
+ for (int32_t i=0; i<mMaxClients; i++)\r
+ {\r
+ if(!mClients[i])\r
+ {\r
+ mClients[i]=new PClient(i);\r
+ ++mNumClients;\r
+ return i;\r
+ }\r
+ }\r
+ return -1;\r
+}\r
+\r
+PClient *PServer::GetClient(int32_t Client) const\r
+{\r
+ if (Client < 0 || Client >= mMaxClients)\r
+ return 0;\r
+\r
+ return mClients[Client];\r
+}\r
+\r
+void PServer::Update()\r
+{\r
+ for (int32_t i=0; i<mMaxClients; i++)\r
+ {\r
+ if(mClients[i])\r
+ {\r
+ mClients[i]->Update();\r
+ if(mClients[i]->GetConnection()==PCC_NONE && mClients[i]->getTCPConn() == 0)\r
+ {\r
+ Console->Print("Removing client ...");\r
+ delete mClients[i];\r
+ mClients[i]=0;\r
+ --mNumClients;\r
+ }\r
+ }\r
+ }\r
+}\r
+\r
+void PServer::Shutdown()\r
+{\r
+ Console->Print("======================");\r
+ Console->Print("Shutting down Infoserver...");\r
+ for (int32_t i=0; i<mMaxClients; i++)\r
+ {\r
+ if(mClients[i])\r
+ {\r
+ delete mClients[i];\r
+ mClients[i]=0;\r
+ }\r
+ }\r
+}\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include <vector>\r
+\r
+class PClient;\r
+\r
+class PServer {\r
+private:\r
+ int32_t mMaxClients;\r
+ int32_t mNumClients;\r
+ std::vector<PClient *> mClients;\r
+\r
+public:\r
+ PServer();\r
+ ~PServer();\r
+\r
+ int32_t GetNumClients() const;\r
+ int32_t NewClient();\r
+ PClient *GetClient(int32_t Client) const;\r
+ void Update();\r
+ void Shutdown();\r
+};\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-#include "main.h"\r
+#include <cstring>\r
+#include "InfoServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
\r
PMySQL::PMySQL()\r
{\r
strncpy(password, Config->GetOption("sql_password").c_str(), 100);\r
strncpy(database, Config->GetOption("global_sql_database").c_str(), 100);\r
\r
- mKeepaliveDelay = (std::time_t) (Config->GetOptionInt("mysql_wait_timeout") * 0.9) ; // we take 90% of the wait_timeout to trigger keepalive\r
+ mKeepaliveDelay = (time_t) (Config->GetOptionInt("mysql_wait_timeout") * 0.9) ; // we take 90% of the wait_timeout to trigger keepalive\r
if (mKeepaliveDelay == 0)\r
{\r
Console->Print("%s MySQL keepalive disabled by config", Console->ColorText(GREEN, BLACK, "[Info]"));\r
}\r
\r
void PMySQL::Update()\r
-{ \r
+{\r
// MySQL keepalive\r
- std::time_t t = std::time(NULL);\r
+ time_t t = std::time(NULL);\r
if ((mKeepaliveDelay > 0) && ((t - mLastKeepaliveSent) > mKeepaliveDelay))\r
{\r
MYSQL_RES *result;\r
return;\r
}\r
else\r
- FreeSQLResult(result); \r
- \r
+ FreeSQLResult(result);\r
+\r
mLastKeepaliveSent = std::time(NULL);\r
//Console->Print("%s MySQL keepalive sent", Console->ColorText(GREEN, BLACK, "[Debug]"));\r
}\r
}\r
\r
+MYSQL *PMySQL::GetHandle()\r
+{\r
+ return dbHandle;\r
+}\r
+\r
bool PMySQL::Connect()\r
{\r
Console->LPrint("Establishing link to MySQL Database...");\r
\r
- dbHandle = mysql_init(NULL);\r
+ dbHandle = mysql_init(NULL);\r
\r
- if(dbHandle)\r
- {\r
- //Console->Print("MySQL-Handle successfully initialized.");\r
- }\r
- else\r
- {\r
- Console->LPrint(RED, BLACK, "[ERROR]");\r
- Console->LClose();\r
- Console->Print(" MySQL-Handle couldn't be created!");\r
- exit(0);\r
- }\r
+ if(dbHandle)\r
+ {\r
+ //Console->Print("MySQL-Handle successfully initialized.");\r
+ }\r
+ else\r
+ {\r
+ Console->LPrint(RED, BLACK, "[ERROR]");\r
+ Console->LClose();\r
+ Console->Print(" MySQL-Handle couldn't be created!");\r
+ exit(0);\r
+ }\r
\r
if(!mysql_real_connect(dbHandle, host, userName, password, database, port, NULL, 0))\r
{\r
- Console->LPrint(RED, BLACK, "[ERROR]");\r
- Console->LClose();\r
+ Console->LPrint(RED, BLACK, "[ERROR]");\r
+ Console->LClose();\r
Console->Print("Unable to connect to MySQL Database. MySQL returned: %s", mysql_error(dbHandle));\r
return false;\r
}\r
\r
MYSQL_RES *PMySQL::ResQuery(const char *query)\r
{\r
- int sql_result = 0;\r
+ int32_t sql_result = 0;\r
MYSQL_RES *result;\r
\r
sql_result = mysql_real_query(dbHandle, query, strlen(query));\r
return result;\r
}\r
\r
-int PMySQL::Query(const char *query)\r
+int32_t PMySQL::Query(const char *query)\r
{\r
- int sql_result = 0;\r
+ int32_t sql_result = 0;\r
sql_result = mysql_real_query(dbHandle, query, strlen(query));\r
\r
return sql_result;\r
mysql_free_result(res);\r
}\r
\r
-u32 PMySQL::EscapeString(const char* nText, char* dText, u32 dMaxLength)\r
+uint32_t PMySQL::GetLastInsertId()\r
{\r
- u32 nLength = strlen(nText);\r
- u32 tMax = (dMaxLength - 1)/2;\r
+ return mysql_insert_id(dbHandle);\r
+}\r
+\r
+uint32_t PMySQL::EscapeString(const char *nText, char *dText, uint32_t dMaxLength)\r
+{\r
+ uint32_t nLength = strlen(nText);\r
+ uint32_t tMax = (dMaxLength - 1)/2;\r
if(nLength > tMax)\r
{\r
nLength = tMax;\r
}\r
- \r
+\r
return mysql_real_escape_string(dbHandle, dText, nText, nLength);\r
}\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#ifdef MYSQL_INC_DIR\r
+#include <mysql/mysql.h>\r
+#else\r
+#include <mysql.h>\r
+#endif\r
+\r
+class PMySQL {\r
+private:\r
+ int32_t port;\r
+ char host[100];\r
+ char userName[100];\r
+ char password[100];\r
+ char database[100];\r
+ MYSQL *dbHandle;\r
+ time_t mKeepaliveDelay;\r
+ time_t mLastKeepaliveSent;\r
+\r
+public:\r
+ PMySQL();\r
+ ~PMySQL();\r
+\r
+ void Update();\r
+ MYSQL *GetHandle();\r
+\r
+ bool Connect();\r
+ int32_t Query(const char *query);\r
+ MYSQL_RES *ResQuery(const char *query);\r
+ void ShowSQLError();\r
+ void FreeSQLResult(MYSQL_RES *res);\r
+ uint32_t GetLastInsertId();\r
+ uint32_t EscapeString(const char *nText, char *dText, uint32_t dMaxLength);\r
+};\r
--- /dev/null
+ADD_EXECUTABLE (PatchServer Client.cxx Includes.cxx PatchServer.cxx Main.cxx Server.cxx)
+TARGET_LINK_LIBRARIES (PatchServer Common ${PCRE_LIBRARY} ${RT_LIBRARY} ${ZLIB_LIBRARY})
--- /dev/null
+#include "PatchServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
+\r
+PClient::PClient(int32_t Index)\r
+{\r
+ mIndex = Index;\r
+ mConnection = PCC_NONE;\r
+}\r
+\r
+PClient::~PClient()\r
+{\r
+ if(m_TCPConnection)\r
+ {\r
+ delete m_TCPConnection;\r
+ }\r
+}\r
+\r
+int32_t PClient::GetIndex() const\r
+{\r
+ return mIndex;\r
+}\r
+\r
+int32_t PClient::GetConnection() const\r
+{\r
+ return mConnection;\r
+}\r
+\r
+const char *PClient::GetAddress() const\r
+{\r
+ return m_TCPConnection->getRemoteAddress();\r
+}\r
+\r
+void PClient::setTCPConnection(ConnectionTCP *conn)\r
+{\r
+ m_TCPConnection = conn;\r
+ mConnection = PCC_PATCH;\r
+}\r
+\r
+ConnectionTCP *PClient::getTCPConn()\r
+{\r
+ return m_TCPConnection;\r
+}\r
+\r
+void PClient::Update()\r
+{\r
+ if(m_TCPConnection)\r
+ {\r
+ if(m_TCPConnection->timeOut())\r
+ {\r
+ Console->Print("Patchsocket: Client %i: timeout", mIndex);\r
+ PatchServer->ClientDisconnected(this);\r
+ }\r
+ else\r
+ {\r
+ if(!m_TCPConnection->update())\r
+ {\r
+ PatchServer->ClientDisconnected(this);\r
+ }\r
+ }\r
+ }\r
+}\r
+\r
+void PClient::PatchDisconnect()\r
+{\r
+ if(m_TCPConnection)\r
+ {\r
+ delete m_TCPConnection;\r
+ }\r
+ mConnection = PCC_NONE;\r
+ m_TCPConnection = 0;\r
+}\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+\r
+class ConnectionTCP;\r
+\r
+enum PClientConnection {\r
+ PCC_NONE = 0,\r
+ PCC_PATCH = 1\r
+};\r
+\r
+class PClient {\r
+private:\r
+ ConnectionTCP *m_TCPConnection;\r
+ int32_t mIndex;\r
+ int32_t mConnection;\r
+\r
+public:\r
+ PClient(int32_t Index);\r
+ ~PClient();\r
+\r
+ int32_t GetIndex() const;\r
+ int32_t GetConnection() const;\r
+ const char *GetAddress() const;\r
+ void setTCPConnection(ConnectionTCP *conn);\r
+ ConnectionTCP *getTCPConn();\r
+ void Update();\r
+ void PatchDisconnect();\r
+};\r
--- /dev/null
+#pragma once\r
+\r
+static const char *PatchConfigTemplate[][2] = {\r
+ // {option_name, default_value} if default_value is empty string, it means option is mandatory\r
+ // List ends with empty string for option_name\r
+ {"server_version", "200"},\r
+ {"patchserver_port", "8040"},\r
+ {"patches_path", "./patches"},\r
+ {"file_path", "./files"},\r
+ {"max_file_xfers", "5"},\r
+ {"patch_packet_size", "512"},\r
+ {"maxclients", "5"},\r
+ {"gm_slots", "2"},\r
+\r
+ {"", ""} // do not change this line (end mark)\r
+};\r
--- /dev/null
+#include "PatchServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
+\r
+const char ServerVersion[] = TINNS_PATCH_VERSION;\r
+const char SVNRevision[] = TINNS_SVN_REVISION;\r
+\r
+ServerSocket* ServerSock = 0;\r
+PConsole *Console = 0;\r
+PServer *Server = 0;\r
+PConfig *Config = 0;\r
+PFileSystem *Filesystem = 0;\r
+PPatchServer *PatchServer = 0;\r
+\r
+bool InitTinNS()\r
+{\r
+ Console = new PConsole("log/patchserver.log"); // Make that from config file !!!\r
+ Console->Print("Starting TinNS Patchserver...");\r
+ Console->Print(WHITE, BLUE, "/-------------------------------------------------------------------\\");\r
+ Console->Print(WHITE, BLUE, "| TinNS (TinNS is not a Neocron Server) |");\r
+ Console->Print(WHITE, BLUE, "| Copyright (C) 2005 Linux Addicted Community |");\r
+ Console->Print(WHITE, BLUE, "| maintainer Akiko <akiko@gmx.org> |");\r
+ Console->Print(WHITE, BLUE, "| ========================================== |");\r
+ Console->Print(WHITE, BLUE, "| Head coders: The packet analyzing team: |");\r
+ Console->Print(WHITE, BLUE, "| - Akiko - MaxxJag |");\r
+ Console->Print(WHITE, BLUE, "| - bakkdoor - Sting |");\r
+ Console->Print(WHITE, BLUE, "| - Namikon - Balm |");\r
+ Console->Print(WHITE, BLUE, "| - Hammag |");\r
+ Console->Print(WHITE, BLUE, "|-------------------------------------------------------------------|");\r
+ Console->Print(WHITE, BLUE, "| This project would'nt be at its current stage without the help |");\r
+ Console->Print(WHITE, BLUE, "| from the NeoPolis team, special thanks to you guys! |");\r
+ Console->Print(WHITE, BLUE, "|-------------------------------------------------------------------|");\r
+ Console->Print(WHITE, BLUE, "| This project is under GPL, see any source file for more details |");\r
+ Console->Print(WHITE, BLUE, "\\-------------------------------------------------------------------/");\r
+\r
+ //char svnrev[10];\r
+ //GetSVNRev(svnrev);\r
+ Console->LPrint("You are running TinNS Patchserver version");\r
+ Console->LPrint(GREEN, BLACK, " %s", ServerVersion);\r
+ Console->LPrint(WHITE, BLACK, " - SVN Rev");\r
+ Console->LPrint(GREEN, BLACK, " %s", SVNRevision);\r
+ Console->LClose();\r
+\r
+ Config = new PConfig();\r
+ if(!Config->LoadOptions(PatchConfigTemplate ,"./conf/patchserver.conf"))\r
+ Shutdown();\r
+\r
+ ServerSock = new ServerSocket();\r
+ Server = new PServer();\r
+ PatchServer = new PPatchServer();\r
+\r
+ return true;\r
+}\r
+\r
+void Shutdown()\r
+{\r
+ if(PatchServer) delete PatchServer;\r
+ if(Config) delete Config;\r
+ if(Console) delete Console;\r
+ if(ServerSock) delete ServerSock;\r
+ exit(0);\r
+}\r
--- /dev/null
+#pragma once\r
+\r
+#include "PatchServer/Client.hxx"\r
+#include "PatchServer/ConfigTemplate.hxx"\r
+#include "PatchServer/PatchServer.hxx"\r
+#include "PatchServer/Server.hxx"\r
+\r
+extern class ServerSocket* ServerSock;\r
+extern class PConsole *Console;\r
+extern class PConfig *Config;\r
+extern class PFileSystem *Filesystem;\r
+extern class PServer *Server;\r
+extern class PPatchServer *PatchServer;\r
+\r
+extern const char ServerVersion[];\r
+extern const char SVNRevision[];\r
+\r
+bool InitTinNS();\r
+void Shutdown();\r
--- /dev/null
+#include <chrono>\r
+#include <csignal>\r
+#include <thread>\r
+#include "PatchServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
+\r
+void signal_handler(int signal)\r
+{\r
+ if (signal == SIGINT)\r
+ Shutdown();\r
+ else\r
+ psignal(signal, "Unkown signal: ");\r
+}\r
+\r
+int main()\r
+{\r
+ signal(SIGINT, signal_handler);\r
+\r
+\r
+ if (!InitTinNS())\r
+ while (true)\r
+ std::this_thread::sleep_for(std::chrono::seconds(1));\r
+\r
+ PatchServer->Start();\r
+ Console->Print("Patchserver is now %s. Waiting for clients...", Console->ColorText(GREEN, BLACK, "Online"));\r
+\r
+ while (true)\r
+ {\r
+ ServerSock->update();\r
+ Server->Update();\r
+ PatchServer->Update();\r
+ // sched_yield();\r
+ }\r
+\r
+ return 0;\r
+}\r
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- patchserver.cpp\r
-\r
- Authors:\r
- - Akiko\r
- - Namikon\r
- - someone else?\r
-\r
- MODIFIED: Unknown date / Unknown author\r
- REASON: - initial release by unknown\r
-\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL\r
- MODIFIED: 06 Jan 2006 Namikon\r
- REASON: - Added color to console outputs\r
- \r
- MODIFIED: 01 Jul 2006 hammag\r
- REASON: - added set timeout to 10 msec (for ReadSetTCP select) in Start()\r
- to avoid useless 100% CPU use\r
- MODIFIED: 11 Dec 2006 hammag\r
- REASON: - Display the client id in Client connection message rather than the always increasing mNumClients\r
- - Removed use of mNumClients in PPatchServer. the count is done in PServer.\r
-\r
- ToDo:\r
- - Take main loop timeout setting from config file\r
-*/\r
-\r
-#include "main.h"\r
-\r
-struct PPatchState\r
-{\r
+#include <cstring>\r
+#include <sstream>\r
+#include "PatchServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
+\r
+const uint16_t PATCH_PORT = 7000;\r
+\r
+struct PPatchState {\r
enum State\r
{\r
PS_UNKNOWN,\r
PS_SENDFILE\r
} mState;\r
\r
- u16 mSerial;\r
+ uint16_t mSerial;\r
\r
- u32 mCurrentPatch;\r
- u32 mPatchOffset;\r
- u32 mPatchSize;\r
+ uint32_t mCurrentPatch;\r
+ uint32_t mPatchOffset;\r
+ uint32_t mPatchSize;\r
std::FILE *mPatchFile;\r
\r
std::string mCurrentFile;\r
- u32 mFileOffset;\r
- u32 mFileSize;\r
+ uint32_t mFileOffset;\r
+ uint32_t mFileSize;\r
PFile *mSendFile;\r
\r
bool mWaitSend; // wait-for-completition flag\r
\r
void PPatchServer::Start()\r
{\r
- u16 Port = Config->GetOptionInt("patchserver_port");\r
+ uint16_t Port = Config->GetOptionInt("patchserver_port");\r
if(Port==0)\r
Port=PATCH_PORT;\r
\r
\r
if(ServerSock->newConnection())\r
{\r
- int clid = Server->NewClient();\r
+ int32_t clid = Server->NewClient();\r
if(clid!=-1)\r
{\r
Console->Print(GREEN, BLACK, "Patchserver: client [%i] connected", clid);\r
FinalizeClient(Client, State);\r
}\r
\r
-bool PPatchServer::HandleHandshake(PClient *Client, PPatchState *State, const u8 *Packet, int PacketSize)\r
+bool PPatchServer::HandleHandshake(PClient *Client, PPatchState *State, const uint8_t *Packet, int32_t PacketSize)\r
{\r
- static const u8 HANDSHAKE1A[6]={0xfe, 0x03, 0x00, 0x80, 0x01, 0x73};\r
+ static const uint8_t HANDSHAKE1A[6]={0xfe, 0x03, 0x00, 0x80, 0x01, 0x73};\r
\r
ConnectionTCP *Socket = Client->getTCPConn();\r
\r
{\r
case PPatchState::PS_HANDSHAKE0 :\r
{\r
- if(PacketSize==6 && *(u16*)&Packet[3]==0x0280 && Packet[5]==0x64)\r
+ if(PacketSize==6 && *(uint16_t*)&Packet[3]==0x0280 && Packet[5]==0x64)\r
{\r
Socket->write(HANDSHAKE1A, sizeof(HANDSHAKE1A));\r
State->mState = PPatchState::PS_HANDSHAKE1;\r
} else\r
{\r
- Console->Print("Patchserver protocol error (PS_HANDSHAKE0): invalid packet [%04x]", *(u16*)&Packet[3]);\r
+ Console->Print("Patchserver protocol error (PS_HANDSHAKE0): invalid packet [%04x]", *(uint16_t*)&Packet[3]);\r
return false;\r
}\r
\r
\r
case PPatchState::PS_HANDSHAKE1 :\r
{\r
- if(PacketSize==6 && *(u16*)&Packet[3]==0x0080 && Packet[5]==0x6c)\r
+ if(PacketSize==6 && *(uint16_t*)&Packet[3]==0x0080 && Packet[5]==0x6c)\r
State->mState = PPatchState::PS_VERSIONREQUEST;\r
else\r
{\r
- Console->Print("Patchserver protocol error (PS_HANDSHAKE1): invalid packet [%04x]", *(u16*)&Packet[3]);\r
+ Console->Print("Patchserver protocol error (PS_HANDSHAKE1): invalid packet [%04x]", *(uint16_t*)&Packet[3]);\r
return false;\r
}\r
break;\r
return true;\r
}\r
\r
-bool PPatchServer::HandleVersionRequest(PClient *Client, PPatchState *State, const u8 *Packet, int PacketSize)\r
+bool PPatchServer::HandleVersionRequest(PClient *Client, PPatchState *State, const uint8_t *Packet, int32_t PacketSize)\r
{\r
- static u8 VERSIONPACKET[13]={0xfe, 0x0a, 0x00, 0x37, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};\r
+ static uint8_t VERSIONPACKET[13]={0xfe, 0x0a, 0x00, 0x37, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};\r
\r
ConnectionTCP *Socket = Client->getTCPConn();\r
- if(PacketSize==9 && *(u16*)&Packet[3]==0x007b)\r
+ if(PacketSize==9 && *(uint16_t*)&Packet[3]==0x007b)\r
{\r
- State->mSerial = *(u16*)&Packet[7];\r
- *(u16*)&VERSIONPACKET[7]=State->mSerial;\r
- u32 ver = Config->GetOptionInt("server_version");\r
- *(u32*)&VERSIONPACKET[9]=ver;\r
+ State->mSerial = *(uint16_t*)&Packet[7];\r
+ *(uint16_t*)&VERSIONPACKET[7]=State->mSerial;\r
+ uint32_t ver = Config->GetOptionInt("server_version");\r
+ *(uint32_t*)&VERSIONPACKET[9]=ver;\r
Socket->write(VERSIONPACKET, 13);\r
State->mState = PPatchState::PS_GETPATCHORFILE;\r
} else\r
{\r
- Console->Print("Patchserver protocol error (PS_VERSIONREQUEST): invalid packet [%04x]", *(u16*)&Packet[3]);\r
+ Console->Print("Patchserver protocol error (PS_VERSIONREQUEST): invalid packet [%04x]", *(uint16_t*)&Packet[3]);\r
return false;\r
}\r
\r
return true;\r
}\r
\r
-bool PPatchServer::HandleFileRequests(PClient *Client, PPatchState *State, const u8 *Packet, int PacketSize)\r
+bool PPatchServer::HandleFileRequests(PClient *Client, PPatchState *State, const uint8_t *Packet, int32_t PacketSize)\r
{\r
- static u8 STARTPATCH[13]={0xfe, 0x0a, 0x00, 0x38, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};\r
- static u8 STARTFILE[13]={0xfe, 0x0a, 0x00, 0x3b, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};\r
- static u8 FILEERROR[9]={0xfe, 0x06, 0x00, 0x3d, 0x02, 0x00, 0x00, 0x00, 0x00};\r
+ static uint8_t STARTPATCH[13]={0xfe, 0x0a, 0x00, 0x38, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};\r
+ static uint8_t STARTFILE[13]={0xfe, 0x0a, 0x00, 0x3b, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};\r
+ static uint8_t FILEERROR[9]={0xfe, 0x06, 0x00, 0x3d, 0x02, 0x00, 0x00, 0x00, 0x00};\r
\r
ConnectionTCP *Socket = Client->getTCPConn();\r
// request patch\r
- if(PacketSize==13 && *(u16*)&Packet[3]==0x007c)\r
+ if(PacketSize==13 && *(uint16_t*)&Packet[3]==0x007c)\r
{\r
- int nmax = Config->GetOptionInt("max_file_xfers");\r
+ int32_t nmax = Config->GetOptionInt("max_file_xfers");\r
if(mNumFileTransfers>=nmax)\r
{\r
Console->Print("Patchserver: max file xfers exceed, killing client %i", Client->GetIndex());\r
State->mSendFile=0;\r
--mNumFileTransfers;\r
}\r
- State->mSerial = *(u16*)&Packet[7];\r
- State->mCurrentPatch = *(u32*)&Packet[9];\r
+ State->mSerial = *(uint16_t*)&Packet[7];\r
+ State->mCurrentPatch = *(uint32_t*)&Packet[9];\r
Console->Print("Patchserver: Patch request from client %i (v%i)", Client->GetIndex(), State->mCurrentPatch);\r
if((bool)(State->mPatchSize = StartPatch(State)))\r
{\r
Console->Print("Patchserver: Patch is available, %d bytes", State->mPatchSize);\r
- *(u16*)&STARTPATCH[7]=State->mSerial;\r
- *(u32*)&STARTPATCH[9]=State->mPatchSize;\r
+ *(uint16_t*)&STARTPATCH[7]=State->mSerial;\r
+ *(uint32_t*)&STARTPATCH[9]=State->mPatchSize;\r
Socket->write(STARTPATCH, 13);\r
State->mState = PPatchState::PS_SENDPATCH;\r
} else\r
{\r
Console->Print("Patchserver: Patch not available");\r
- *(u16*)&FILEERROR[7]=State->mSerial;\r
+ *(uint16_t*)&FILEERROR[7]=State->mSerial;\r
Socket->write(FILEERROR, 9);\r
FinalizeClientDelayed(Client, State);\r
State->mState=PPatchState::PS_UNKNOWN;\r
}\r
} else\r
// request file\r
- if(PacketSize > 9 && *(u16*)&Packet[3]==0x004d)\r
+ if(PacketSize > 9 && *(uint16_t*)&Packet[3]==0x004d)\r
{\r
- int nmax = Config->GetOptionInt("max_file_xfers");\r
+ int32_t nmax = Config->GetOptionInt("max_file_xfers");\r
if(mNumFileTransfers>=nmax)\r
{\r
Console->Print("Patchserver: max file xfers exceed, killing client %i", Client->GetIndex());\r
--mNumFileTransfers;\r
}\r
// request file\r
- State->mSerial = *(u16*)&Packet[7];\r
+ State->mSerial = *(uint16_t*)&Packet[7];\r
char fn[256];\r
strncpy(fn, (const char*)&Packet[10], Packet[9]);\r
fn[Packet[9]]=0;\r
if((bool)(State->mFileSize = StartFile(State)))\r
{\r
Console->Print("Patchserver: File %s is available, %d bytes", State->mCurrentFile.c_str(), State->mFileSize);\r
- *(u16*)&STARTFILE[7]=State->mSerial;\r
- *(u32*)&STARTFILE[9]=State->mFileSize;\r
+ *(uint16_t*)&STARTFILE[7]=State->mSerial;\r
+ *(uint32_t*)&STARTFILE[9]=State->mFileSize;\r
Socket->write(STARTFILE, 13);\r
State->mState = PPatchState::PS_SENDFILE;\r
} else\r
{\r
Console->Print("Patchserver: Requested file %s not available", State->mCurrentFile.c_str());\r
- *(u16*)&FILEERROR[7]=State->mSerial;\r
+ *(uint16_t*)&FILEERROR[7]=State->mSerial;\r
Socket->write(FILEERROR, 9);\r
FinalizeClientDelayed(Client, State);\r
State->mState=PPatchState::PS_UNKNOWN;\r
}\r
} else\r
// send patch data\r
- if(PacketSize==17 && *(u16*)&Packet[3]==0x007d)\r
+ if(PacketSize==17 && *(uint16_t*)&Packet[3]==0x007d)\r
{\r
- State->mSerial = *(u16*)&Packet[7];\r
- State->mCurrentPatch = *(u32*)&Packet[9];\r
- State->mPatchOffset = *(u32*)&Packet[13];\r
+ State->mSerial = *(uint16_t*)&Packet[7];\r
+ State->mCurrentPatch = *(uint32_t*)&Packet[9];\r
+ State->mPatchOffset = *(uint32_t*)&Packet[13];\r
if(!SendPatchData(Client, State))\r
{\r
Console->Print("Patchserver: SendPatchData failed on client %i", Client->GetIndex());\r
}\r
} else\r
// send file data\r
- if(PacketSize > 13 && *(u16*)&Packet[3]==0x00037)\r
+ if(PacketSize > 13 && *(uint16_t*)&Packet[3]==0x00037)\r
{\r
- State->mSerial = *(u16*)&Packet[7];\r
- State->mFileOffset = *(u32*)&Packet[9];\r
+ State->mSerial = *(uint16_t*)&Packet[7];\r
+ State->mFileOffset = *(uint32_t*)&Packet[9];\r
if(!SendFileData(Client, State))\r
{\r
Console->Print("Patchserver: SendFileData failed on client %i", Client->GetIndex());\r
return true;\r
}\r
\r
-u32 PPatchServer::StartPatch(PPatchState *State)\r
+uint32_t PPatchServer::StartPatch(PPatchState *State)\r
{\r
std::stringstream path;\r
char patchname[13];\r
{\r
++mNumFileTransfers;\r
fseek(State->mPatchFile, 0, SEEK_END);\r
- u32 size = ftell(State->mPatchFile);\r
+ uint32_t size = ftell(State->mPatchFile);\r
fseek(State->mPatchFile, 0, SEEK_SET);\r
return size;\r
}\r
if(!State->mPatchFile)\r
return false;\r
\r
- u16 size = Config->GetOptionInt("patch_packet_size");\r
+ uint16_t size = Config->GetOptionInt("patch_packet_size");\r
\r
- const int BUFFERSIZE = 4082;\r
+ const int32_t BUFFERSIZE = 4082;\r
\r
- size = std::min(BUFFERSIZE, std::max((s32)size, 64));\r
- static u8 Buffer[BUFFERSIZE+13];\r
+ size = std::min(BUFFERSIZE, std::max((int32_t)size, 64));\r
+ static uint8_t Buffer[BUFFERSIZE+13];\r
\r
if(fseek(State->mPatchFile, State->mPatchOffset, SEEK_SET)!=0)\r
return false;\r
\r
size = fread(&Buffer[13], 1, size, State->mPatchFile);\r
Buffer[0]=0xfe;\r
- *(u16*)&Buffer[1]=size+10;\r
+ *(uint16_t*)&Buffer[1]=size+10;\r
Buffer[3]=0x39;\r
Buffer[4]=0x02;\r
Buffer[5]=0x00;\r
Buffer[6]=0x00;\r
- *(u16*)&Buffer[7]=State->mSerial;\r
- *(u32*)&Buffer[9]=size;\r
+ *(uint16_t*)&Buffer[7]=State->mSerial;\r
+ *(uint32_t*)&Buffer[9]=size;\r
return Client->getTCPConn()->write(Buffer, size+13)==size+13;\r
}\r
\r
-u32 PPatchServer::StartFile(PPatchState *State)\r
+uint32_t PPatchServer::StartFile(PPatchState *State)\r
{\r
// security checks: reject file paths containing ':', '..' or slashes/backslashes at the beginning\r
if((State->mCurrentFile.find(':') != std::string::npos)\r
if(State->mSendFile)\r
{\r
++mNumFileTransfers;\r
- u32 size = State->mSendFile->GetSize();\r
+ uint32_t size = State->mSendFile->GetSize();\r
return size;\r
}\r
return 0;\r
if(!State->mSendFile)\r
return false;\r
\r
- u16 size = Config->GetOptionInt("patch_packet_size");\r
+ uint16_t size = Config->GetOptionInt("patch_packet_size");\r
\r
- const int BUFFERSIZE = 4082;\r
+ const int32_t BUFFERSIZE = 4082;\r
\r
- size = std::min(BUFFERSIZE, std::max((s32)size, 1));\r
- static u8 Buffer[BUFFERSIZE+13];\r
+ size = std::min(BUFFERSIZE, std::max((int32_t)size, 1));\r
+ static uint8_t Buffer[BUFFERSIZE+13];\r
\r
State->mSendFile->Seek(State->mFileOffset);\r
\r
size = State->mSendFile->Read(&Buffer[13], size);\r
Buffer[0]=0xfe;\r
- *(u16*)&Buffer[1]=size+10;\r
+ *(uint16_t*)&Buffer[1]=size+10;\r
Buffer[3]=0x3c;\r
Buffer[4]=0x02;\r
Buffer[5]=0x00;\r
Buffer[6]=0x00;\r
- *(u16*)&Buffer[7]=State->mSerial;\r
- *(u32*)&Buffer[9]=size;\r
+ *(uint16_t*)&Buffer[7]=State->mSerial;\r
+ *(uint32_t*)&Buffer[9]=size;\r
return Client->getTCPConn()->write(Buffer, size+13)==size+13;\r
}\r
\r
bool PPatchServer::ProcessClient(PClient *Client, PPatchState *State)\r
{\r
- static const u8 HANDSHAKE0A[6]={0xfe, 0x03, 0x00, 0x80, 0x03, 0x6b};\r
+ static const uint8_t HANDSHAKE0A[6]={0xfe, 0x03, 0x00, 0x80, 0x03, 0x6b};\r
\r
if(!State)\r
{\r
Socket->flushSendBuffer();\r
}\r
\r
- int PacketSize=0;\r
- const u8 *Packet = Socket->read(&PacketSize);\r
+ int32_t PacketSize = 0;\r
+ const uint8_t *Packet = Socket->read(&PacketSize);\r
if(PacketSize > 0)\r
{\r
switch(State->mState)\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include <map>\r
+\r
+class PClient;\r
+struct PPatchState;\r
+\r
+class PPatchServer {\r
+private:\r
+ int mNumClients;\r
+ int mNumFileTransfers;\r
+ typedef std::map<PClient *, PPatchState *> PatchStateMap;\r
+ PatchStateMap ClientStates;\r
+\r
+protected:\r
+ bool ProcessClient(PClient *Client, PPatchState *State = nullptr);\r
+// uint32_t StartPatch(PClient *Client, PPatchState *State);\r
+ uint32_t StartPatch(PPatchState *State);\r
+ bool SendPatchData(PClient *Client, PPatchState *State) const;\r
+// u32 StartFile(PClient *Client, PPatchState *State);\r
+ uint32_t StartFile(PPatchState *State);\r
+ bool SendFileData(PClient *Client, PPatchState *State) const;\r
+ void FinalizeClient(PClient *Client, PPatchState *State);\r
+ void FinalizeClientDelayed(PClient *Client, PPatchState *State);\r
+\r
+ bool HandleHandshake(PClient *Client, PPatchState *State, const uint8_t *Packet, int32_t PacketSize);\r
+ bool HandleVersionRequest(PClient *Client, PPatchState *State, const uint8_t *Packet, int32_t PacketSize);\r
+ bool HandleFileRequests(PClient *Client, PPatchState *State, const uint8_t *Packet, int32_t PacketSize);\r
+\r
+public:\r
+ PPatchServer();\r
+ ~PPatchServer();\r
+\r
+ void Start();\r
+ void Update();\r
+ void ClientDisconnected(PClient *Client);\r
+};\r
--- /dev/null
+#include "PatchServer/Includes.hxx"\r
+#include "Common/Includes.hxx"\r
+\r
+PServer::PServer()\r
+{\r
+ mNumClients = 0;\r
+ mMaxClients = Config->GetOptionInt("maxclients");\r
+ mGMSlots = Config->GetOptionInt("gm_slots");\r
+\r
+ if (mMaxClients==0)\r
+ mMaxClients=1;\r
+ if (mGMSlots==0)\r
+ mGMSlots=1;\r
+ mClients.reserve(mMaxClients + mGMSlots);\r
+ for (int32_t i=0; i<mMaxClients+mGMSlots; i++)\r
+ mClients[i]=0;\r
+}\r
+\r
+PServer::~PServer()\r
+{\r
+ for (int32_t i=0; i<mMaxClients+mGMSlots; i++)\r
+ delete mClients[i];\r
+}\r
+\r
+int32_t PServer::GetMaxClients() const\r
+{\r
+ return mMaxClients;\r
+}\r
+\r
+int32_t PServer::GetGMSlots() const\r
+{\r
+ return mGMSlots;\r
+}\r
+\r
+int32_t PServer::GetNumClients() const\r
+{\r
+ return mNumClients;\r
+}\r
+\r
+int PServer::NewClient()\r
+{\r
+//Console->Print("%d %d", mMaxClients, mGMSlots);\r
+ if (mNumClients==mMaxClients+mGMSlots)\r
+ return -1;\r
+ for (int32_t i=0; i<mMaxClients+mGMSlots; i++)\r
+ {\r
+ if(!mClients[i])\r
+ {\r
+ mClients[i]=new PClient(i);\r
+ ++mNumClients;\r
+ return i;\r
+ }\r
+ }\r
+ return -1;\r
+}\r
+\r
+PClient *PServer::GetClient(int32_t Client) const\r
+{\r
+ if (Client < 0 || Client >= mMaxClients+mGMSlots)\r
+ return 0;\r
+\r
+ return mClients[Client];\r
+}\r
+\r
+void PServer::Update()\r
+{\r
+ for (int32_t i=0; i<mMaxClients+mGMSlots; i++)\r
+ {\r
+ if (mClients[i])\r
+ {\r
+ mClients[i]->Update();\r
+ if (mClients[i]->GetConnection()==PCC_NONE && mClients[i]->getTCPConn() == 0)\r
+ {\r
+ Console->Print("Removing client ...");\r
+ delete mClients[i];\r
+ mClients[i]=0;\r
+ --mNumClients;\r
+ }\r
+ }\r
+ }\r
+}\r
+\r
+void PServer::Shutdown()\r
+{\r
+ Console->Print("======================");\r
+ Console->Print("Shutting down Patchserver...");\r
+ for (int32_t i=0; i<mMaxClients+mGMSlots; i++)\r
+ {\r
+ if(mClients[i])\r
+ {\r
+ delete mClients[i];\r
+ mClients[i]=0;\r
+ }\r
+ }\r
+}\r
--- /dev/null
+#pragma once\r
+\r
+#include <cstdint>\r
+#include <vector>\r
+\r
+class PClient;\r
+\r
+class PServer {\r
+private:\r
+ int32_t mMaxClients;\r
+ int32_t mGMSlots;\r
+ int32_t mNumClients;\r
+ std::vector<PClient *> mClients;\r
+\r
+public:\r
+ PServer();\r
+ ~PServer();\r
+\r
+ int32_t GetMaxClients() const;\r
+ int32_t GetGMSlots() const;\r
+ int32_t GetNumClients() const;\r
+ int32_t NewClient();\r
+ PClient *GetClient(int32_t Client) const;\r
+ void Update();\r
+ void Shutdown();\r
+};\r
--- /dev/null
+ADD_SUBDIRECTORY (PakDecompress)
+ADD_SUBDIRECTORY (VFSviewer)
--- /dev/null
+ADD_EXECUTABLE (PakDecompress PakDecompress.cxx)
+TARGET_LINK_LIBRARIES (PakDecompress ${ZLIB_LIBRARY})
--- /dev/null
+#include <iostream>\r
+#include <fstream>\r
+#include <cstdio>\r
+#include <cstring>\r
+#include <cassert>\r
+#include <zlib.h>\r
+\r
+#define CHUNK 262144\r
+\r
+int inf(FILE *source, FILE *dest, bool details)\r
+{\r
+ int ret;\r
+ char check;\r
+ unsigned have;\r
+ z_stream strm;\r
+ unsigned char in[CHUNK];\r
+ unsigned char out[CHUNK];\r
+\r
+ strm.zalloc = Z_NULL;\r
+ strm.zfree = Z_NULL;\r
+ strm.opaque = Z_NULL;\r
+ strm.avail_in = 0;\r
+ strm.next_in = Z_NULL;\r
+ ret = inflateInit(&strm);\r
+\r
+ if (ret != Z_OK)\r
+ return(ret);\r
+\r
+ check = fgetc(source);\r
+ if(check == 'x')\r
+ {\r
+ if(details == true) std::cout << "Found zLibfile" << std::endl;\r
+ fseek(source, 0, SEEK_SET);\r
+ }\r
+ else\r
+ {\r
+ fseek(source, 16, SEEK_SET);\r
+ check = fgetc(source);\r
+ if(check == 'x')\r
+ {\r
+ if(details == true) std::cout << "Found Neocron file" << std::endl;\r
+ fseek(source, 16, SEEK_SET);\r
+ }\r
+ else\r
+ {\r
+ if(details == true) std::cout << "Error: No compatible file!" << std::endl;\r
+ return -3;\r
+ }\r
+ }\r
+\r
+ do {\r
+ strm.avail_in = fread(in, 1, CHUNK, source);\r
+\r
+ if (ferror(source)) {\r
+ (void)inflateEnd(&strm);\r
+\r
+ return(Z_ERRNO);\r
+ }\r
+\r
+ if (strm.avail_in == 0)\r
+ break;\r
+ strm.next_in = in;\r
+\r
+ do {\r
+ strm.avail_out = CHUNK;\r
+ strm.next_out = out;\r
+ ret = inflate(&strm, Z_NO_FLUSH);\r
+ assert(ret != Z_STREAM_ERROR);\r
+\r
+ switch(ret) {\r
+ case Z_NEED_DICT:\r
+ ret = Z_DATA_ERROR;\r
+ case Z_DATA_ERROR:\r
+ case Z_MEM_ERROR:\r
+ (void)inflateEnd(&strm);\r
+ return(ret);\r
+ }\r
+\r
+ have = CHUNK - strm.avail_out;\r
+\r
+ if (fwrite(out, 1, have, dest) != have || ferror(dest)) {\r
+ (void)inflateEnd(&strm);\r
+\r
+ return(Z_ERRNO);\r
+ }\r
+ } while (strm.avail_out == 0);\r
+\r
+ assert(strm.avail_in == 0);\r
+ } while (ret != Z_STREAM_END);\r
+\r
+ (void)inflateEnd(&strm);\r
+\r
+ return(ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR);\r
+}\r
+\r
+void zerr(int ret)\r
+{\r
+ fputs("zpipe: ", stderr);\r
+\r
+ switch(ret) {\r
+ case Z_ERRNO:\r
+ if (ferror(stdin))\r
+ fputs("error reading stdin\n", stderr);\r
+ if (ferror(stdout))\r
+ fputs("error writing stdout\n", stderr);\r
+ break;\r
+ case Z_STREAM_ERROR:\r
+ fputs("invalid compression level\n", stderr);\r
+ break;\r
+ case Z_DATA_ERROR:\r
+ fputs("invalid or incomplete deflate data\n", stderr);\r
+ break;\r
+ case Z_MEM_ERROR:\r
+ fputs("out of memory\n", stderr);\r
+ break;\r
+ case Z_VERSION_ERROR:\r
+ fputs("zlib version mismatch!\n", stderr);\r
+ }\r
+}\r
+\r
+int main(int argc, char **argv) {\r
+ int ret;\r
+ long inSize;\r
+ long outSize;\r
+ bool details = false;\r
+ FILE *inFile;\r
+ FILE *outFile;\r
+ std::string src;\r
+ std::string dst;\r
+\r
+ if(argc == 2) {\r
+ src = argv[1];\r
+ dst = strcat(argv[1], ".decompressed");\r
+ }\r
+ else if(argc > 2 && strcmp(argv[1], argv[2])) {\r
+ src = argv[1];\r
+ dst = argv[2];\r
+ }\r
+ else {\r
+ std::cout << "Usage: pak_decompress source <dest != source> <detailedoutput 1/0>" << std::endl;\r
+ return(0);\r
+ }\r
+ if(argc == 4)\r
+ {\r
+ if(argv[3][0] == '1') details = true;\r
+ else if(argv[3][0] == '0') details = false;\r
+ }\r
+\r
+ inFile = fopen(src.c_str(), "rb");\r
+ outFile = fopen(dst.c_str(), "wb");\r
+\r
+ if(inFile == NULL)\r
+ {\r
+ std::cout << "Cannot open InFile" << std::endl;\r
+ return(-1);\r
+ }\r
+ if(outFile == NULL)\r
+ {\r
+ std::cout << "Cannot open OutFile" << std::endl;\r
+ return(-2);\r
+ }\r
+ ret = inf(inFile, outFile, details);\r
+\r
+ /* just to be sure - we got to the end */\r
+ fseek(inFile, 0, SEEK_END);\r
+ fseek(outFile, 0, SEEK_END);\r
+ inSize = ftell(inFile);\r
+ outSize = ftell(outFile);\r
+\r
+ fclose(outFile);\r
+ fclose(inFile);\r
+\r
+ if(ret == Z_OK && details == true)\r
+ {\r
+ std::cout << "bytes read: " << inSize << std::endl;\r
+ std::cout << "bytes written: " << outSize << std::endl;\r
+ std::cout << "compression ratio: " << (100-((float)inSize/(float)outSize*100)) << "%" << std::endl;\r
+ }\r
+ else if(ret == Z_OK && details == false)\r
+ {\r
+ std::cout << "[OK] " << src.c_str() << std::endl;\r
+ }\r
+ else if(ret != Z_OK && details == false)\r
+ {\r
+ std::cout << "[ERROR] " << src.c_str() << std::endl;\r
+ }\r
+\r
+ return(ret);\r
+}\r
--- /dev/null
+ADD_EXECUTABLE (VFSviewer VfsViewer.c)
+TARGET_LINK_LIBRARIES (VFSviewer ${ZLIB_LIBRARY})
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+
+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 <nc1 vfs file>\n");
+ exit(1);
+ }
+
+ exit(0);
+}
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
+++ /dev/null
-ADD_SUBDIRECTORY (src)
+++ /dev/null
-# 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)
+++ /dev/null
-ADD_LIBRARY (common config.cpp console.cpp filesystem.cpp misc.cpp message.cpp netcode.cpp regex++.cpp)
+++ /dev/null
-#pragma once
-
-#include <iostream>
-
-#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 = "");
-};
+++ /dev/null
-#pragma once
-
-#include <iostream>
-
-#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);
-};
+++ /dev/null
-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})
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- main.h - main include file, contains all needed includes and important definitions\r
-\r
- MODIFIED: 30 Aug 2006 Hammag\r
- REASON: - created\r
- MODIFIED: 09 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
-*/\r
-\r
-\r
-#ifndef MAIN_H\r
-#define MAIN_H\r
-\r
-//#include "version.h"\r
-\r
-//basic includes\r
-#include "include/external.h"\r
-\r
-//tinns includes\r
-#include "include/types.h"\r
-#include "common/config.h"\r
-\r
-#include "common/console.h"\r
-#include "common/misc.h"\r
-\r
-#include "common/netcode.h"\r
-\r
-#include "include/msgdecoder.h"\r
-#include "udpanalyser.h"\r
-\r
-\r
-/*\r
-#include "../gamemonkey/gmMachine.h"\r
-#include "../gamemonkey/gmCall.h"\r
-*/\r
-\r
-#include "common/filesystem.h"\r
-\r
-// MySQL Support // shouldn't be needed as DB-objects access class should do that\r
-#ifdef MYSQL_INC_DIR\r
-#include <mysql/mysql.h>\r
-#else\r
-#include <mysql.h>\r
-#endif\r
-\r
-#include "include/sql.h"\r
-\r
-#include "include/skill.h"\r
-\r
-#include "include/chars.h"\r
-#include "include/accounts.h"\r
-#include "include/defs.h"\r
-#include "include/client.h"\r
-#include "include/server.h"\r
-#include "include/gameserver.h"\r
-#include "include/globals.h"\r
-#include "include/zoning.h"\r
-#include "include/item.h"\r
-#include "include/inventory.h"\r
-\r
-#include "include/chat.h"\r
-#include "include/commands.h"\r
-#include "include/clientmanager.h"\r
-#include "include/msgbuilder.h"\r
-#include "include/worldactors.h"\r
-#include "include/npc.h"\r
-#include "include/outpost.h"\r
-#include "include/multipart.h"\r
-#include "include/terminal.h"\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
-\r
- msgdecoder.cpp - top class for NC messages decoding\r
-\r
- CREATION: 23 Aug 2006 Hammag\r
-\r
- MODIFIED: 09 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
-*/\r
-\r
-\r
-#include "main.h"\r
-\r
-#include "include/msgdecoder.h"\r
-#include "udp_0x13.h"\r
-\r
-\r
-// PUdpMsgDecoder\r
-\r
-/*\r
- PMsgDecodeData mDecodeData;\r
- PUdpMsgAnalyser* mCurrentAnalyser;\r
-*/\r
- \r
-void PUdpMsgDecoder::Init(PMessage* nMessage, PClient* nClient)\r
-{\r
- mDecodeData.mMessage = nMessage;\r
- mDecodeData.mClient = nClient;\r
- mDecodeData.mState = (nMessage && nClient) ? DECODE_MORE : DECODE_UNDEF;\r
- mDecodeData.mUnknownType = 0;\r
- mDecodeData.mHandling0x13Sub = false;\r
- mDecodeData.Sub0x13Start = mDecodeData.Sub0x13StartNext = 0;\r
- mPacketName.erase();\r
- mDecodeData.mName.str(mPacketName);\r
- mDecodeData.mErrorDetail.erase();\r
- mDecodeData.mTraceKnownMsg = false;\r
- mDecodeData.mTraceUnknownMsg = false;\r
- mDecodeData.mTraceDump = false;\r
- if (mCurrentAnalyser)\r
- {\r
- delete mCurrentAnalyser;\r
- mCurrentAnalyser = NULL;\r
- }\r
-\r
-}\r
- \r
-PUdpMsgDecoder::PUdpMsgDecoder()\r
-{\r
- mCurrentAnalyser = NULL;\r
- Reset();\r
-}\r
-\r
-PUdpMsgDecoder::PUdpMsgDecoder(PMessage* nMessage, PClient* nClient)\r
-{\r
- mCurrentAnalyser = NULL;\r
- Init(nMessage, nClient);\r
-}\r
-\r
-PUdpMsgDecoder::~PUdpMsgDecoder()\r
-{\r
- if (mCurrentAnalyser)\r
- {\r
- delete mCurrentAnalyser;\r
- }\r
-}\r
-\r
-bool PUdpMsgDecoder::Analyse()\r
-{\r
- PUdpMsgAnalyser* nextAnalyser;\r
-\r
- if ((mDecodeData.mState & DECODE_MORE) || mDecodeData.mHandling0x13Sub)\r
- {\r
- if (mCurrentAnalyser)\r
- {\r
- delete mCurrentAnalyser;\r
- mCurrentAnalyser = NULL;\r
- }\r
- if (mDecodeData.mHandling0x13Sub)\r
- {\r
- mPacketName.erase();\r
- mDecodeData.mName.str(mPacketName);\r
- mCurrentAnalyser = new PUdp0x13(&mDecodeData);\r
- mDecodeData.mState = DECODE_MORE;\r
- }\r
- else\r
- {\r
- mCurrentAnalyser = new PUdpMsgAnalyser(&mDecodeData);\r
- }\r
-\r
- while (mDecodeData.mState & DECODE_MORE)\r
- {\r
- nextAnalyser = mCurrentAnalyser->Analyse();\r
- if (mCurrentAnalyser != nextAnalyser)\r
- {\r
- delete mCurrentAnalyser;\r
- mCurrentAnalyser = nextAnalyser;\r
- }\r
- }\r
- }\r
- return (!(mDecodeData.mState & (DECODE_MORE | DECODE_ERROR | DECODE_UNKNOWN)));\r
-}\r
-\r
-bool PUdpMsgDecoder::Analyse(PMessage* nMessage, PClient* nClient)\r
-{\r
- Init(nMessage, nClient);\r
- return Analyse();\r
-}\r
-\r
-bool PUdpMsgDecoder::DoAction()\r
-{\r
- if (mDecodeData.mState & DECODE_ACTION_READY)\r
- {\r
- return mCurrentAnalyser->DoAction();\r
- }\r
- else\r
- {\r
- return false;\r
- }\r
-}\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
- udp_0x08.cpp - decoder classes for UDP 0x08 messages\r
-\r
- CREATION: 05 Jan 2007 Namikon\r
-\r
- MODIFIED:\r
- REASON: -\r
-*/\r
-\r
-#include "main.h"\r
-#include "udp_0x08.h"\r
-\r
-\r
-PUdp0x08::PUdp0x08(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData)\r
-{\r
- nDecodeData->mName << "/0x08";\r
-}\r
-\r
-PUdpMsgAnalyser* PUdp0x08::Analyse()\r
-{\r
- mDecodeData->mName << "=Client crash";\r
- mDecodeData->mState = DECODE_ACTION_READY | DECODE_FINISHED;\r
-\r
- return this;\r
-}\r
-\r
-bool PUdp0x08::DoAction()\r
-{\r
- // Client crashed, close connection from our side\r
- GameServer->ClientDisconnected(mDecodeData->mClient);\r
- mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED;\r
-\r
- return true;\r
-}\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- udp_0x08.h - decoder classes for UDP 0x08 messages\r
-\r
- CREATION: 05 Jan 2007 Namikon\r
-\r
- MODIFIED:\r
- REASON: -\r
-*/\r
-\r
-#ifndef UDP0X08_H\r
-#define UDP0X08_H\r
-\r
-class PUdp0x08 : public PUdpMsgAnalyser\r
-{\r
- public:\r
- PUdp0x08(PMsgDecodeData* nDecodeData);\r
- //~PUdp0x08();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- udp_0x13.h - decoder classes for UDP 0x13 messages\r
- \r
- CREATION: 31 Aug 2006 Hammag\r
-\r
- MODIFIED:\r
- REASON: - \r
-\r
-*/\r
-\r
-#ifndef UDP0X13_H\r
-#define UDP0X13_H\r
-\r
-class PUdp0x13 : public PUdpMsgAnalyser\r
-{ \r
- public:\r
- PUdp0x13(PMsgDecodeData* nDecodeData);\r
- //~PUdp0x13();\r
- PUdpMsgAnalyser* Analyse();\r
- //bool DoAction();\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- udp_udp0x1f.h - decoder classes for UDP 0x13x03x1f messages\r
- \r
- CREATION: 6 Sep 2006 Hammag\r
-\r
- MODIFIED:\r
- REASON: - \r
-\r
-*/\r
-\r
-#ifndef UDP0X1F_H\r
-#define UDP0X1F_H\r
-\r
-class PUdp0x1f : public PUdpMsgAnalyser\r
-{\r
- public:\r
- PUdp0x1f(PMsgDecodeData* nDecodeData);\r
- //~PUdp0x1f();\r
- PUdpMsgAnalyser* Analyse();\r
- //bool DoAction();\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- udp_udp0x22.cpp - decoder classes for UDP 0x13x03x22 messages\r
- \r
- CREATION: 6 Sep 2006 Hammag\r
-\r
- MODIFIED:\r
- REASON: - \r
-\r
-*/\r
-\r
-#include "main.h"\r
-#include "udp_0x22.h"\r
-\r
-#include "udp_reqinfo.h"\r
-#include "udp_zoning.h"\r
-#include "udp_entityposreq.h"\r
-\r
-/**** PUdp0x22 ****/\r
-\r
-PUdp0x22::PUdp0x22(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData)\r
-{\r
- nDecodeData->mName << "/0x22";\r
-} \r
-\r
-PUdpMsgAnalyser* PUdp0x22::Analyse()\r
-{\r
- PUdpMsgAnalyser* nextAnalyser = NULL;\r
- mDecodeData->mState = DECODE_MORE; \r
- u8 MsgType = mDecodeData->mMessage->U8Data(mDecodeData->Sub0x13Start + 5); \r
- switch(MsgType) // MsgType is probably u16 rather than u8\r
- {\r
- case 0x03: // Zoning phase 2\r
- { \r
- nextAnalyser = new PUdpZoning2(mDecodeData);\r
- break;\r
- }\r
- case 0x06: // Char/Clan/Rank/Map Info request\r
- { \r
- nextAnalyser = new PUdpReqInfo(mDecodeData);\r
- break;\r
- }\r
- case 0x0b: // Entity position request\r
- {\r
- nextAnalyser = new PUdpEntityPosRequest(mDecodeData);\r
- break;\r
- } \r
- case 0x0d: // Zoning phase 1\r
- { \r
- nextAnalyser = new PUdpZoning1(mDecodeData);\r
- break;\r
- } \r
- default:\r
- {\r
- mDecodeData->mUnknownType = MsgType;\r
- break;\r
- }\r
- }\r
- \r
- if (! nextAnalyser)\r
- {\r
- nextAnalyser = new PUdpMsgUnknown(mDecodeData);\r
- }\r
-\r
- return nextAnalyser;\r
-}\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- udp_udp0x22.h - decoder classes for UDP 0x13x03x22 messages\r
- \r
- CREATION: 6 Sep 2006 Hammag\r
-\r
- MODIFIED:\r
- REASON: - \r
-\r
-*/\r
-\r
-#ifndef UDP0X22_H\r
-#define UDP0X22_H\r
-\r
-class PUdp0x22 : public PUdpMsgAnalyser\r
-{ \r
- public:\r
- PUdp0x22(PMsgDecodeData* nDecodeData);\r
- //~PUdp0x22();\r
- PUdpMsgAnalyser* Analyse();\r
- //bool DoAction();\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- udp_udp0x2b.cpp - decoder classes for UDP 0x13x03x2b messages\r
-\r
- CREATION: 8 Jan 2007 Namikon\r
-\r
- MODIFIED:\r
- REASON: -\r
-\r
-*/\r
-\r
-#include "main.h"\r
-#include "udp_0x2b.h"\r
-#include "udp_terminal.h"\r
-\r
-/**** PUdp0x2b ****/\r
-\r
-PUdp0x2b::PUdp0x2b(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData)\r
-{\r
- nDecodeData->mName << "/0x2b";\r
-}\r
-\r
-PUdpMsgAnalyser* PUdp0x2b::Analyse()\r
-{\r
- PUdpMsgAnalyser* nextAnalyser = NULL;\r
- mDecodeData->mState = DECODE_MORE;\r
- u8 MsgType = mDecodeData->mMessage->U8Data(mDecodeData->Sub0x13Start + 5);\r
- switch(MsgType)\r
- {\r
- case 0x17: // ReceiveDB Terminal Command\r
- {\r
- nextAnalyser = new PUdpReceiveDB(mDecodeData);\r
- break;\r
- }\r
- case 0x18: // UpdateDB Terminal Command\r
- {\r
- nextAnalyser = new PUdpUpdateDB(mDecodeData);\r
- break;\r
- }\r
- case 0x19: // TryAccess Terminal Command\r
- {\r
- nextAnalyser = new PUdpTryAccessDB(mDecodeData);\r
- break;\r
- }\r
- case 0x1b: // DB Query and Command\r
- {\r
- nextAnalyser = new PUdpQueryDB(mDecodeData);\r
- break;\r
- }\r
- case 0x1f: // Citycom?\r
- {\r
- nextAnalyser = new PUdpTeminal0x1f(mDecodeData);\r
- break;\r
- }\r
-\r
- default:\r
- {\r
- mDecodeData->mUnknownType = MsgType;\r
- break;\r
- }\r
- }\r
-\r
- if (! nextAnalyser)\r
- {\r
- nextAnalyser = new PUdpMsgUnknown(mDecodeData);\r
- }\r
-\r
- return nextAnalyser;\r
-}\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- udp_udp0x2b.h - decoder classes for UDP 0x13x03x2b messages\r
-\r
- CREATION: 8 Jan 2007 Namikon\r
-\r
- MODIFIED:\r
- REASON: -\r
-\r
-*/\r
-\r
-#ifndef UDP0X2B_H\r
-#define UDP0X2B_H\r
-\r
-class PUdp0x2b : public PUdpMsgAnalyser\r
-{\r
- public:\r
- PUdp0x2b(PMsgDecodeData* nDecodeData);\r
- //~PUdp0x2b();\r
- PUdpMsgAnalyser* Analyse();\r
- //bool DoAction();\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- udp_OOO.cpp - decoder classe for UDP Out Of Order message\r
-\r
- CREATION: 5 Sep 2006 Hammag\r
-\r
- MODIFIED:\r
- REASON: -\r
-\r
-*/\r
-\r
-#include "main.h"\r
-#include "udp_OOO.h"\r
-\r
-/**** PUdpOOO ****/\r
-\r
-PUdpOOO::PUdpOOO(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData)\r
-{\r
- nDecodeData->mName << "/0x01";\r
-}\r
-\r
-PUdpMsgAnalyser* PUdpOOO::Analyse()\r
-{\r
- mDecodeData->mName << "=Out Of Order";\r
- mDecodeData->mState = DECODE_ACTION_READY | DECODE_FINISHED;\r
-\r
- return this;\r
-}\r
-\r
-bool PUdpOOO::DoAction()\r
-{\r
- u16 MissingUDP_ID = mDecodeData->mMessage->U16Data(mDecodeData->Sub0x13Start+5);\r
-\r
- mDecodeData->mClient->getUDPConn()->ReSendUDPMessage(MissingUDP_ID);\r
- //Console->Print("%s Out of Order packet received ! (Client is missing UDPID %d) ***not managed yet***", Console->ColorText(YELLOW, BLACK, "[Notice]"), MissingUDP_ID);\r
-\r
- mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED;\r
- return true;\r
-}\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- udp_OOO.h - decoder classe for UDP Out Of Order message\r
- \r
- CREATION: 5 Sep 2006 Hammag\r
-\r
- MODIFIED:\r
- REASON: - \r
-\r
-*/\r
-\r
-#ifndef UDPOOO_H\r
-#define UDPOOO_H\r
-\r
-class PUdpOOO : public PUdpMsgAnalyser\r
-{ \r
- public:\r
- PUdpOOO(PMsgDecodeData* nDecodeData);\r
- //~PUdpPing();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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;
-}
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- udp_appartment.h - decoder classes for Navray apt location request messages\r
-\r
- CREATION: 23 Dec 2006 Namikon\r
-\r
- MODIFIED: 13 may 2007 Hammag\r
- REASON: corrected this header\r
-\r
-*/\r
-\r
-#ifndef UDPAPPARTMENT_H\r
-#define UDPAPPARTMENT_H\r
-\r
-class PUdpAptLocInfo : public PUdpMsgAnalyser\r
-{\r
- public:\r
- PUdpAptLocInfo(PMsgDecodeData* nDecodeData);\r
- //~PUdpAptLocInfo();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- udp_charmove.h - decoder classes for UDP char movement messages\r
-\r
- CREATION: 5 Sep 2006 Hammag\r
-\r
- MODIFIED: 09 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
-*/\r
-\r
-#ifndef UDPCHARMOVE_H\r
-#define UDPCHARMOVE_H\r
-\r
-#include "include/msgdecoder.h"\r
-#include "udpanalyser.h"\r
-\r
-class PUdpCharPosUpdate : public PUdpMsgAnalyser\r
-{\r
- private:\r
- u8 mInfoBitfield;\r
- u16 mNewY;\r
- u16 mNewZ;\r
- u16 mNewX;\r
- u8 mNewUD;\r
- u8 mNewLR;\r
- u8 mNewAct;\r
- u8 mNewUnknown;\r
- u32 mChairItemID; // u16 or u32 ???\r
- u8 mChairItemSeat;\r
-\r
- public:\r
- PUdpCharPosUpdate(PMsgDecodeData* nDecodeData);\r
- //~PUdpCharMoves();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-class PUdpCharExitChair : public PUdpMsgAnalyser\r
-{\r
- public:\r
- PUdpCharExitChair(PMsgDecodeData* nDecodeData);\r
- //~PUdpCharExitChair();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-\r
- //nClient is optionnal, nVhc is to limit to that vhc, nForce to force exit event when cab door closed\r
- static bool DoLeaveChair(PChar* nChar, PClient* nClient = NULL, PSpawnedVehicle* nVhc = NULL, bool nForce = false); \r
-};\r
-\r
-class PUdpCharJump : public PUdpMsgAnalyser\r
-{\r
- public:\r
- PUdpCharJump(PMsgDecodeData* nDecodeData);\r
- //~PUdpCharJump();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-class PUdpCharTargeting : public PUdpMsgAnalyser\r
-{\r
- public:\r
- PUdpCharTargeting(PMsgDecodeData* nDecodeData);\r
- //~PUdpCharTargeting();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- udp_chat.h - decoder classes for UDP chat messages\r
- \r
- CREATION: 15 Sep 2006 Hammag\r
-\r
- MODIFIED: 11 Dec 2006 Hammag\r
- REASON: - added PUdpChatChannels\r
-\r
-*/\r
-\r
-#ifndef UDPCHAT_H\r
-#define UDPCHAT_H\r
-\r
-class PUdpChatLocal : public PUdpMsgAnalyser\r
-{ \r
- public:\r
- PUdpChatLocal(PMsgDecodeData* nDecodeData);\r
- //~PUdpChatLocal();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-class PUdpChatGlobal : public PUdpMsgAnalyser\r
-{\r
- private:\r
- \r
- public:\r
- PUdpChatGlobal(PMsgDecodeData* nDecodeData);\r
- //~PUdpChatGlobal();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-class PUdpChatListAdd : public PUdpMsgAnalyser\r
-{\r
- private:\r
- u8 mChatList; // 1 = Direct, 2 = Buddy List\r
- char* mAddedCharname;\r
- \r
- public:\r
- PUdpChatListAdd(PMsgDecodeData* nDecodeData);\r
- //~PUdpChatListAdd();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-class PUdpChatListRemove : public PUdpMsgAnalyser\r
-{\r
- private:\r
- u8 mChatList;\r
- u32 mRemovedCharID;\r
- \r
- public:\r
- PUdpChatListRemove(PMsgDecodeData* nDecodeData);\r
- //~PUdpChatListRemove();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-class PUdpChatChannels : public PUdpMsgAnalyser\r
-{\r
- private:\r
- u32 mChannelFlags; // 1 bit per custom channel, starting from LSB, in same order as in chat i/f\r
- \r
- public:\r
- PUdpChatChannels(PMsgDecodeData* nDecodeData);\r
- //~PUdpChatChannels();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- udp_entityposreq.h - decoder classes for UDP entity position request messages\r
-\r
- CREATION: 8 jun 2007 Hammag\r
-\r
- MODIFIED:\r
- REASON: -\r
-\r
-*/\r
-\r
-#ifndef UDPENTITYPOS_H\r
-#define UDPENTITYPOS_H\r
-\r
-class PUdpEntityPosRequest : public PUdpMsgAnalyser\r
-{\r
- private:\r
- u16 mEntityID; // u16 or u32 ???\r
-\r
-\r
- public:\r
- PUdpEntityPosRequest(PMsgDecodeData* nDecodeData);\r
- //~PUdpEntityPosRequest();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- udp_hack.h - decoder classes for UDP hacking related messages\r
-\r
- CREATION: 30 Dec 2006 Namikon\r
-\r
- MODIFIED:\r
- REASON: -\r
-\r
-*/\r
-\r
-#ifndef UDPHACK_H\r
-#define UDPHACK_H\r
-\r
-class PUdpHackFail : public PUdpMsgAnalyser\r
-{\r
- public:\r
- PUdpHackFail( PMsgDecodeData* nDecodeData );\r
- //~PUdpHackFail();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-class PUdpHackSuccess : public PUdpMsgAnalyser\r
-{\r
- public:\r
- PUdpHackSuccess( PMsgDecodeData* nDecodeData );\r
- //~PUdpHackSuccess();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- udp_itemmove.h - decoder classes for UDP item move related messages\r
-\r
- CREATION: 30 Dec 2006 Namikon\r
-\r
- MODIFIED:\r
- REASON: -\r
-\r
-*/\r
-\r
-#ifndef UDPITEMMOVE_H\r
-#define UDPITEMMOVE_H\r
-\r
-class PUdpItemMove : public PUdpMsgAnalyser\r
-{\r
- private:\r
- u8 mSrcLoc;\r
- u8 mSrcX;\r
- u8 mSrcY;\r
- u8 mDstLoc;\r
- u8 mDstX;\r
- u8 mDstY;\r
- u8 mItemCnt;\r
-\r
- public:\r
- PUdpItemMove(PMsgDecodeData* nDecodeData);\r
- //~PUdpItemMove();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-\r
- static PContainer* GetContainerByLoc(PChar* nChar, u8 nLoc);\r
-};\r
-\r
-class PUdpItemMoveBP : public PUdpMsgAnalyser\r
-{\r
- private:\r
- u8 mSrcSlotId;\r
- u8 mDumb;\r
- u8 mDstX;\r
- u8 mDstY;\r
- \r
- public:\r
- PUdpItemMoveBP(PMsgDecodeData* nDecodeData);\r
- //~PUdpItemMove();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-class PUdpItemDropOnItem : public PUdpMsgAnalyser\r
-{\r
- private:\r
- u8 mSrcLoc;\r
- u8 mSrcX;\r
- u8 mSrcY;\r
- u8 mDstLoc;\r
- u8 mDstX;\r
- u8 mDstY;\r
-\r
- public:\r
- PUdpItemDropOnItem(PMsgDecodeData* nDecodeData);\r
- //~PUdpItemDropOnItem();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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)
- */
-}
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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;
-}
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- udp_packet0.h - decoder classes for UDP "Packet0" messages\r
- \r
- CREATION: 31 Aug 2006 Hammag\r
-\r
- MODIFIED:\r
- REASON: - \r
-\r
-*/\r
-\r
-#ifndef UDPPACKET0_H\r
-#define UDPPACKET0_H\r
-\r
-class PUdpPacket0 : public PUdpMsgAnalyser\r
-{ \r
- public:\r
- PUdpPacket0(PMsgDecodeData* nDecodeData);\r
- //~PUdpPacket0();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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;
-}
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- udp_ping.h - decoder classes for UDP Ping messages\r
-\r
- CREATION: 31 Aug 2006 Hammag\r
-\r
- MODIFIED:\r
- REASON: -\r
-\r
-*/\r
-\r
-#ifndef UDPPING_H\r
-#define UDPPING_H\r
-\r
-class PUdpPing : public PUdpMsgAnalyser\r
-{\r
- private:\r
- u32 mClientTime;\r
-\r
- public:\r
- PUdpPing( PMsgDecodeData* nDecodeData );\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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;
-}
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- udp_quickaccessbelt.h - decoder classes for UDP Quickaccessbelt related messages\r
-\r
- CREATION: 30 Dec 2006 Namikon\r
-\r
- MODIFIED:\r
- REASON: -\r
-\r
-*/\r
-\r
-#ifndef UDPITEMSLOT_H\r
-#define UDPITEMSLOT_H\r
-\r
-class PUdpItemSlotUse : public PUdpMsgAnalyser\r
-{\r
- private:\r
- u8 mTargetSlot;\r
- \r
- public:\r
- PUdpItemSlotUse(PMsgDecodeData* nDecodeData);\r
- //~PUdpItemSlotUse();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- udp_reqinfo.h - decoder classes for UDP Char info request messages\r
- \r
- CREATION: 6 Sep 2006 Hammag\r
-\r
- MODIFIED:\r
- REASON: - \r
-\r
-*/\r
-\r
-#ifndef UDPREQINFO_H\r
-#define UDPREQINFO_H\r
-\r
-class PUdpReqInfo : public PUdpMsgAnalyser\r
-{\r
- private:\r
- u16 mRequestType;\r
- u32 mInfoId;\r
- \r
- public:\r
- PUdpReqInfo(PMsgDecodeData* nDecodeData);\r
- //~PUdpCharInfo();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- udp_subskill.h - decoder classes for UDP subskill increasing messages\r
- \r
- CREATION: 15 Sep 2006 Hammag\r
-\r
- MODIFIED:\r
- REASON: - \r
-\r
-*/\r
-\r
-#ifndef UDPSUBSKILL_H\r
-#define UDPSUBSKILL_H\r
-\r
-class PUdpSubskillInc : public PUdpMsgAnalyser\r
-{\r
- private:\r
- u16 SubskillID;\r
- \r
- public:\r
- PUdpSubskillInc(PMsgDecodeData* nDecodeData);\r
- //~PUdpSubskillInc();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- udp_sync.h - decoder classes for UDP Sync messages\r
-\r
- CREATION: 30 Aug 2006 Hammag\r
-\r
- MODIFIED:\r
- REASON: -\r
-\r
-*/\r
-\r
-#ifndef UDPSYNC_H\r
-#define UDPSYNC_H\r
-\r
-class PUdpSync0 : public PUdpMsgAnalyser\r
-{\r
- public:\r
- PUdpSync0( PMsgDecodeData* nDecodeData );\r
- //~PUdpSync0();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-\r
- static void GetToSync1( PMsgDecodeData* nDecodeData );\r
-};\r
-\r
-class PUdpSync1 : public PUdpMsgAnalyser\r
-{\r
- public:\r
- PUdpSync1( PMsgDecodeData* nDecodeData );\r
- //~PUdpSync1();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-class PUdpSync2 : public PUdpMsgAnalyser\r
-{\r
- private:\r
- u32 mClientTime;\r
-\r
- public:\r
- PUdpSync2( PMsgDecodeData* nDecodeData );\r
- //~PUdpSync2();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- udp_terminal.h - decoder classes for UDP terminal related messages\r
-\r
- CREATION: 8 Jan 2007 Namikon\r
-\r
- MODIFIED:\r
- REASON: -\r
-\r
-*/\r
-\r
-#ifndef UDPTERMINAL_H\r
-#define UDPTERMINAL_H\r
-\r
-\r
-\r
-class PUdpReceiveDB : public PUdpMsgAnalyser\r
-{\r
- private:\r
- static const u8 mMaxOptions = 9; // Largest: forum\forenlist.tsc(21, 114,...)\r
- u16 mTerminalSessionId;\r
- std::string mCommandName;\r
- std::string mOptions[mMaxOptions];\r
- u8 mOptionsCount;\r
- \r
- u16 mUnknown1;\r
- u8 mUnknown2;\r
- u16 mDBId;\r
- \r
- bool ActionVehicleListing();\r
- bool ActionVehicleControl();\r
- \r
- public:\r
- PUdpReceiveDB(PMsgDecodeData* nDecodeData);\r
- //~PUdpReceiveDB();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-class PUdpUpdateDB : public PUdpMsgAnalyser\r
-{\r
- private:\r
- static const u8 mMaxOptions = 7; // Largest: forum\bbcnewthread.tsc(66):\r
- u16 mTerminalSessionId;\r
- std::string mCommandName;\r
- std::string mOptions[mMaxOptions];\r
- u8 mOptionsCount;\r
-\r
- u16 mUnknown1;\r
- u8 mUnknown2;\r
- u16 mDBId;\r
-\r
- public:\r
- PUdpUpdateDB(PMsgDecodeData* nDecodeData);\r
- //~PUdpUpdateDB();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-class PUdpTryAccessDB : public PUdpMsgAnalyser\r
-{\r
- private:\r
- static const u8 mMaxOptions = 9; // Largest: stockx\depot.tsc(227):\r
- u16 mTerminalSessionId;\r
- std::string mCommandName;\r
- std::string mOptions[mMaxOptions];\r
- u8 mOptionsCount;\r
-\r
- u16 mUnknown1;\r
- u8 mUnknown2;\r
- u16 mDBId;\r
-\r
- public:\r
- PUdpTryAccessDB(PMsgDecodeData* nDecodeData);\r
- //~PUdpTryAccessDB();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-class PUdpQueryDB : public PUdpMsgAnalyser // Also called "ServerMessage" in .tsc scripts!\r
-{\r
- private:\r
- static const u8 mMaxOptions = 5; // Largest: politics\transcomment.tsc(36):\r
- u16 mTerminalSessionId;\r
- u16 mDBId;\r
- std::string mDBCommandName;\r
- std::string mCommandName;\r
- std::string mOptions[mMaxOptions];\r
- u8 mOptionsCount;\r
-\r
- bool ActionSpawnVehicle();\r
- bool ActionRepairVehicle();\r
- bool ActionDismissVehicle();\r
- \r
- public:\r
- PUdpQueryDB(PMsgDecodeData* nDecodeData);\r
- //~PUdpQueryDB();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-class PUdpTeminal0x1f : public PUdpMsgAnalyser\r
-{\r
- private:\r
- u16 mTerminalSessionId;\r
- \r
- public:\r
- PUdpTeminal0x1f(PMsgDecodeData* nDecodeData);\r
- //~PUdpTeminal0x1f();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- udp_useobject.h - decoder classes for object use related messages\r
-\r
- CREATION: 17 Sep 2006 Hammag\r
-\r
- MODIFIED:\r
- REASON: -\r
-\r
-*/\r
-\r
-#ifndef UDPUSEOBJECT_H\r
-#define UDPUSEOBJECT_H\r
-\r
-class PUdpUseObject : public PUdpMsgAnalyser\r
-{\r
- private:\r
- u32 mRawItemID;\r
-\r
- void OldHandler(); // Temp during migration only\r
-\r
- public:\r
- PUdpUseObject(PMsgDecodeData* nDecodeData);\r
- //~PUdpUseObject();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-class PUdpCloseItemContainer : public PUdpMsgAnalyser\r
-{\r
- private:\r
-\r
- public:\r
- PUdpCloseItemContainer(PMsgDecodeData* nDecodeData);\r
- //~PUdpCloseItemContainer();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- udp_vhc.h - decoder classes for UDP vehicle related messages\r
-\r
- CREATION: 5 Sep 2006 Hammag\r
-\r
- MODIFIED:\r
- REASON: -\r
-\r
-*/\r
-\r
-#ifndef UDPVHC_H\r
-#define UDPVHC_H\r
-\r
-class PSpawnedVehicle;\r
-class PVhcCoordinates;\r
-\r
-class PUdpVhcMove : public PUdpMsgAnalyser\r
-{\r
- private:\r
- u16 mVhcLocalId;\r
- u16 mNewY;\r
- u16 mNewZ;\r
- u16 mNewX;\r
- u16 mNewLR;\r
- u16 mNewRoll;\r
- u16 mUnk1; // always 0x0001 ?\r
- u8 mMoveType;\r
- u8 mNewUD;\r
- u8 mFF; // always 0xff ?\r
- u8 mAction; // &1 = Left, &2 = Right, &4 = Forward, &8 = Backward\r
- public:\r
- PUdpVhcMove( PMsgDecodeData* nDecodeData );\r
- //~PUdpVhcMove();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
- bool DoVhcZoning( PSpawnedVehicle* currVhc, u32 currWorldId, u32 destWorldId, PVhcCoordinates* destPos );\r
-};\r
-\r
-class PUdpVhcUse : public PUdpMsgAnalyser\r
-{\r
- private:\r
- u32 mVehicleID;\r
- u8 mVehicleSeat;\r
-\r
- public:\r
- PUdpVhcUse( PMsgDecodeData* nDecodeData );\r
- //~PUdpVhcUse();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
- static void DoFreeSitting(PClient* nClient, PSpawnedVehicle* nVhc, u32 nRawVhcLocalId, u8 nSeatId = 254);\r
-};\r
-\r
-class PUdpSubwayUpdate : public PUdpMsgAnalyser\r
-{\r
- private:\r
- u32 mVehicleID;\r
- u16 mPosition;\r
- u8 mDoorOpened;\r
-\r
- public:\r
- PUdpSubwayUpdate( PMsgDecodeData* nDecodeData );\r
- //~PUdpSubwayUpdate();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-class PUdpRequestVhcInfo : public PUdpMsgAnalyser\r
-{\r
- private:\r
- u32 mVehicleID;\r
-\r
- public:\r
- PUdpRequestVhcInfo( PMsgDecodeData* nDecodeData );\r
- //~PUdpRequestVhcInfo();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- udp_zoning.h - decoder classes for UDP Zoning messages\r
-\r
- CREATION: 6 Sep 2006 Hammag\r
-\r
- MODIFIED: 15 Dec 2006 Hammag\r
- REASON: - added PUdpEndOfZoning management class\r
-\r
-*/\r
-\r
-#ifndef UDPZONING_H\r
-#define UDPZONING_H\r
-\r
-class PUdpZoning1 : public PUdpMsgAnalyser\r
-{\r
- private:\r
- u32 mNewLocation;\r
- u16 mNewEntity;\r
- u8 mUnknown;\r
- public:\r
- PUdpZoning1( PMsgDecodeData* nDecodeData );\r
- //~PUdpZoning1();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-class PUdpZoning2 : public PUdpMsgAnalyser\r
-{\r
- public:\r
- PUdpZoning2( PMsgDecodeData* nDecodeData );\r
- //~PUdpZoning2();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-class PUdpGenrepZoning : public PUdpMsgAnalyser\r
-{\r
- private:\r
- u32 mNewLocation;\r
- u16 mNewEntity;\r
-\r
- public:\r
- PUdpGenrepZoning( PMsgDecodeData* nDecodeData );\r
- //~PUdpGenrepZoning();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
- static bool DoEffectiveZoning( PClient* nClient, u32 nNewLocation, u16 nNewEntity );\r
-};\r
-\r
-class PUdpAptGRZoning : public PUdpMsgAnalyser\r
-{\r
- public:\r
- PUdpAptGRZoning( PMsgDecodeData* nDecodeData );\r
- //~PUdpAptGRZoning();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
- static bool DoEffectiveZoning( PClient* nClient );\r
-};\r
-\r
-class PUdpAddGenrepToList : public PUdpMsgAnalyser\r
-{\r
- private:\r
- u32 mLocation;\r
- u16 mEntity;\r
-\r
- public:\r
- PUdpAddGenrepToList( PMsgDecodeData* nDecodeData );\r
- //~PUdpAddGenrepToList();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-class PUdpAppartmentAccess : public PUdpMsgAnalyser\r
-{\r
- private:\r
- u16 mAppartmentPlace;\r
- char* mPassword;\r
-\r
- public:\r
- PUdpAppartmentAccess( PMsgDecodeData* nDecodeData );\r
- //~PUdpAppartmentAccess();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-\r
-class PUdpEndOfZoning : public PUdpMsgAnalyser\r
-{\r
- private:\r
-\r
- public:\r
- PUdpEndOfZoning( PMsgDecodeData* nDecodeData );\r
- //~PUdpEndOfZoning();\r
- PUdpMsgAnalyser* Analyse();\r
- bool DoAction();\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- udpanalyser.h - Analyser class top (used only by PUdpMsgDecoder)\r
- Also includes the PUdpMsgUnknown derived class\r
- and the PUdpMsgIgnore derived class\r
- \r
- CREATION: 23 Aug 2006 Hammag\r
-\r
- MODIFIED: 30 Aug 2006 Hammag\r
- REASON: - moved these two class in file distinct from PUdpMsgDecoder.\r
-\r
-*/\r
-\r
-#ifndef UDPANALYSER_H\r
-#define UDPANALYSER_H\r
-\r
-class PUdpMsgAnalyser\r
-{\r
- friend class PUdpMsgDecoder;\r
- \r
- protected:\r
- PMsgDecodeData* mDecodeData;\r
-\r
- public: \r
- PUdpMsgAnalyser(PMsgDecodeData* nDecodeData);\r
- virtual ~PUdpMsgAnalyser();\r
- \r
- virtual PUdpMsgAnalyser* Analyse();\r
- virtual bool DoAction();\r
- \r
- static int smAnaCount; // temp for check\r
-\r
-};\r
-\r
-class PUdpMsgUnknown : public PUdpMsgAnalyser\r
-{ \r
- public:\r
- PUdpMsgUnknown(PMsgDecodeData* nDecodeData);\r
- //~PUdpMsgUnknown();\r
- \r
- //bool DoAction();\r
-};\r
-\r
-class PUdpMsgIgnore : public PUdpMsgAnalyser\r
-{ \r
- public:\r
- PUdpMsgIgnore(PMsgDecodeData* nDecodeData);\r
- //~PUdpMsgUnknown();\r
- \r
- //bool DoAction();\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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));
-}
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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));
-}
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- def_appartements.cpp\r
-\r
- MODIFIED: 22 Sep 2006 Hammag\r
- REASON: - Creation\r
- \r
-*/\r
-\r
-#include "main.h"\r
-\r
-PDefAppartement::PDefAppartement()\r
-{\r
-}\r
-\r
-bool PDefAppartement::LoadFromDef(PTokenList *Tokens)\r
-{\r
- mFaction = 0;\r
- int Idx=0;\r
- for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++)\r
- {\r
- switch(Idx)\r
- {\r
- case 0: // setentry\r
- continue;\r
-\r
- case 1: // index\r
- mIndex = atoi(i->c_str()); break;\r
-\r
- case 2: // name\r
- mName = *i; break;\r
-\r
- case 3: // world name\r
- mWorldName = *i; break;\r
- \r
- case 4: // value\r
- mValue = atoi(i->c_str()); break;\r
-\r
- case 5: // number of places\r
- mPlaceCount = atoi(i->c_str()); break;\r
- \r
- case 6:\r
- case 7:\r
- case 8:\r
- case 9:\r
- case 10:\r
- case 11:\r
- case 12:\r
- case 13:\r
- mPlace[Idx-6] = atoi(i->c_str()); break;\r
- \r
- case 14: // faction if base appartement\r
- mFaction = atoi(i->c_str()); break; \r
- }\r
- }\r
-//Console->Print("%04d:%s file:%s val:%d places:%d pl1:%d pl2:%d pl8:%d faction:%d",\r
-// mIndex, mName.c_str(), mWorldName.c_str(), mValue, mPlaceCount, mPlace[0], mPlace[1], mPlace[7], mFaction);\r
- return true;\r
-}\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-/*\r
- def_appplaces.cpp\r
-\r
- Created: 21 Sep 2006 Hammag\r
- REASON: -\r
-*/\r
-\r
-#include "main.h"\r
-\r
-PDefAppPlace::PDefAppPlace()\r
-{\r
-}\r
-\r
-bool PDefAppPlace::LoadFromDef(PTokenList *Tokens)\r
-{\r
- int Idx=0;\r
- for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++)\r
- {\r
- switch(Idx)\r
- {\r
- case 0: // setentry\r
- continue;\r
-\r
- case 1: // index\r
- mIndex = atoi(i->c_str()); break;\r
-\r
- case 2: // name\r
- mName = *i; break;\r
-\r
- case 3: // Exit World\r
- mExitWorldID = atoi(i->c_str()); break;\r
- \r
- case 4: // Exit World entity\r
- mExitWorldEntity = atoi(i->c_str()); break;\r
-\r
- case 5: // Sewer level\r
- mSewerLevel = atoi(i->c_str()); break;\r
- }\r
- }\r
-\r
- return true;\r
-}\r
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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 ) );
-}
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- def_characters.cpp\r
-\r
- Authors:\r
- - Akiko\r
- - Namikon\r
- - someone else?\r
-\r
- MODIFIED: Unknown date / Unknown author\r
- REASON: - initial release by unknown\r
-\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL\r
-*/\r
-\r
-#include "main.h"\r
-\r
-// characters.def contains all ingame characters (player types, npc's, monsters)\r
-\r
-PDefCharacter::PDefCharacter()\r
-{\r
- mIndex = -1;\r
- mName = "unknown";\r
- mModel = -1;\r
-}\r
-\r
-bool PDefCharacter::LoadFromDef(PTokenList *Tokens)\r
-{\r
- int Idx=0;\r
- for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++)\r
- {\r
- switch(Idx)\r
- {\r
- case 0 : // setentry\r
- continue;\r
-\r
- case 1 :\r
- mIndex = atoi(i->c_str()); break;\r
-\r
- case 2 :\r
- mName = *i; break;\r
-\r
- case 3 :\r
- mModel = atoi(i->c_str()); break;\r
- \r
- case 4 : // 0\r
- continue;\r
- \r
- case 5 :\r
- mHead = atoi(i->c_str()); break;\r
- \r
- case 6 :\r
- mTorso = atoi(i->c_str()); break;\r
- \r
- case 7 :\r
- mLegs = atoi(i->c_str()); break;\r
- \r
- case 8 :\r
- mColor = atoi(i->c_str()); break;\r
- \r
- case 9 :\r
- mBrightness = atoi(i->c_str()); break;\r
- }\r
-\r
- if(Idx==9)\r
- return true;\r
- }\r
-\r
- return false;\r
-}\r
-\r
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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 ) );
-}
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- def_charkinds.cpp\r
-\r
- Authors:\r
- - Akiko\r
- - Namikon\r
- - someone else?\r
-\r
- MODIFIED: Unknown date / Unknown author\r
- REASON: - initial release by unknown\r
-\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL\r
-*/\r
-\r
-#include "main.h"\r
-\r
-// charkinds are character templates used for player char creation\r
-\r
-PDefCharKind::PDefCharKind()\r
-{\r
- mSkillInfo = 0;\r
- memset(mInventory, 0, sizeof(mInventory));\r
-}\r
-\r
-PDefCharKind::~PDefCharKind()\r
-{\r
- delete [] mSkillInfo;\r
- for(PSkillPtsMap::const_iterator i=mSkillPts.begin(); i!=mSkillPts.end(); i++)\r
- delete i->second;\r
- for(PSubSkillPtsMap::const_iterator i=mSubSkillPts.begin(); i!=mSubSkillPts.end(); i++)\r
- delete i->second;\r
- for(PStartLevelMap::const_iterator i=mStartLevels.begin(); i!=mStartLevels.end(); i++)\r
- delete i->second;\r
-}\r
-\r
-bool PDefCharKind::LoadFromDef(PTokenList *Tokens)\r
-{\r
- int NumSkills = GameDefs->Skills()->GetNumDefs();\r
- //int NumSubSkills = GameDefs->SubSkills()->GetNumDefs();\r
-\r
- int SkillInfoStart = 4;\r
- int TrainPtsStart = SkillInfoStart+NumSkills*3;\r
- int LevelsStart = TrainPtsStart + 32*2;\r
- int MoneyStart = LevelsStart + 16*2;\r
- int InventoryStart = MoneyStart+1;\r
-\r
- mSkillInfo = new PSkillInfo[NumSkills];\r
-\r
- int Idx=0;\r
- for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++)\r
- {\r
- switch(Idx)\r
- {\r
- case 0 : // setentry\r
- continue;\r
-\r
- case 1 :\r
- mIndex = atoi(i->c_str()); break;\r
-\r
- case 2 :\r
- mName = *i; break;\r
-\r
- case 3 :\r
- mType = atoi(i->c_str()); break;\r
-\r
- }\r
-\r
- if((Idx >= SkillInfoStart) && (Idx < TrainPtsStart)) // skill info\r
- {\r
- int SkillIdx = (Idx-SkillInfoStart)/3;\r
- int Value = atoi(i->c_str());\r
-\r
- // start, max, grow per skill\r
- switch((Idx-SkillInfoStart)%3)\r
- {\r
- case 0 : mSkillInfo[SkillIdx].mStart = Value; break;\r
- case 1 : mSkillInfo[SkillIdx].mMax = Value; break;\r
- case 2 : mSkillInfo[SkillIdx].mGrow = Value; break;\r
- }\r
- } else\r
- // 32 skill/subskill train pts\r
- if((Idx >= TrainPtsStart) && (Idx < LevelsStart))\r
- {\r
- static int SkillIndex = 0;\r
- int Index = Idx-TrainPtsStart;\r
- if((Index&1)==0)\r
- {\r
- SkillIndex = atoi(i->c_str());\r
- } else\r
- {\r
- if(SkillIndex >= 1000) // skill\r
- {\r
- const PDefSkill *Skill = GameDefs->Skills()->GetDef(SkillIndex-1000);\r
- if(Skill)\r
- {\r
- int Index = Skill->GetIndex()-1;\r
- PSkillPtsInfo *CurrentSkillPts = new PSkillPtsInfo();\r
- CurrentSkillPts->mSkill = Index;\r
- CurrentSkillPts->mPoints = atoi(i->c_str());\r
- mSkillPts.insert(std::make_pair(Index, CurrentSkillPts));\r
- } else\r
- {\r
- if(SkillIndex-1000 != 0)\r
- Console->Print("Charkind def: invalid skill index %i", SkillIndex-1000);\r
- }\r
- } else // subskill\r
- {\r
- const PDefSubSkill *SubSkill = GameDefs->SubSkills()->GetDef(SkillIndex);\r
- if(SubSkill)\r
- {\r
- int Index = SubSkill->GetIndex()-1;\r
- PSubSkillPtsInfo *CurrentSubSkillPts = new PSubSkillPtsInfo();\r
- CurrentSubSkillPts->mSubSkill = Index;\r
- CurrentSubSkillPts->mPoints = atoi(i->c_str());\r
- mSubSkillPts.insert(std::make_pair(Index, CurrentSubSkillPts));\r
- } else\r
- {\r
- if(SkillIndex != 0)\r
- Console->Print("Charkind def: invalid subskill index %i", SkillIndex);\r
- }\r
- }\r
- }\r
- } else\r
- // 16 subskill start levels\r
- if((Idx >= LevelsStart) && (Idx < MoneyStart))\r
- {\r
- static int LevelIndex = 0;\r
- int Index = Idx-NumSkills*3+4+(32*2);\r
- if((Index&1)==0)\r
- {\r
- LevelIndex = atoi(i->c_str());\r
- } else\r
- {\r
- if(LevelIndex > 0)\r
- {\r
- const PDefSubSkill *SubSkill = GameDefs->SubSkills()->GetDef(LevelIndex);\r
- if(SubSkill)\r
- {\r
- PStartLevelInfo *Level = new PStartLevelInfo();\r
- Level->mSubSkill = SubSkill->GetIndex();\r
- Level->mLevel = atoi(i->c_str());\r
- mStartLevels.insert(std::make_pair(Level->mSubSkill, Level));\r
- } else\r
- {\r
- Console->Print("Charkind def: invalid subskill index %i", LevelIndex);\r
- }\r
- }\r
- }\r
- } else\r
- // money\r
- if((Idx >= MoneyStart) && (Idx < InventoryStart))\r
- {\r
- mMoney = atoi(i->c_str());\r
- } else\r
- // inventory\r
- if((Idx >= InventoryStart) && (Idx < InventoryStart+8))\r
- {\r
- mInventory[Idx-InventoryStart] = atoi(i->c_str());\r
- }\r
- }\r
- \r
- return true;\r
-}\r
-\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- def_factions.cpp\r
-\r
- Authors:\r
- - Akiko\r
- - Namikon\r
- - someone else?\r
-\r
- MODIFIED: Unknown date / Unknown author\r
- REASON: - initial release by unknown\r
-\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL\r
-*/\r
-\r
-#include "main.h"\r
-\r
-PDefFaction::PDefFaction()\r
-{\r
- memset(mRelations, 0, sizeof(mRelations)); // ... array members supposed to by auto-initialized by C++\r
-}\r
-\r
-bool PDefFaction::LoadFromDef(PTokenList *Tokens)\r
-{\r
- int Idx=0;\r
- for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++)\r
- {\r
- // setfracc 19 "Monster" -1024 0 0 -1024 -1024 -1024 -1\r
- switch(Idx)\r
- {\r
- case 0 : // setfrac\r
- continue;\r
-\r
- case 1 :\r
- mIndex = atol(i->c_str()); break;\r
-\r
- case 2 :\r
- mName = *i;\r
- CleanUpString(&mName);\r
- break;\r
-\r
- case 3 :\r
- mStartValue = atol(i->c_str()); break;\r
-\r
- case 4:\r
- mAffected = atol(i->c_str())!=0; break;\r
-\r
- case 5:\r
- mSL = atol(i->c_str()); break;\r
-\r
- default :\r
- {\r
- if(Idx-6 < NUMFACTIONS)\r
- mRelations[Idx-6] = atol(i->c_str()); break;\r
- }\r
- }\r
- }\r
-\r
- return true;\r
-}\r
-\r
-int PDefFaction::GetRelation(int Faction) const\r
-{\r
- // faction 0 has no relations\r
- if(Faction <= 0 || Faction > NUMFACTIONS)\r
- return 0;\r
-\r
- return mRelations[Faction-1];\r
-}\r
-\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- def_hack.cpp\r
-\r
- Authors:\r
- - Akiko\r
- - Namikon\r
- - someone else?\r
-\r
- MODIFIED: Unknown date / Unknown author\r
- REASON: - initial release by unknown\r
-\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL\r
-*/\r
-\r
-#include "main.h"\r
-\r
-PDefHack::PDefHack()\r
-{\r
-}\r
-\r
-bool PDefHack::LoadFromDef(PTokenList *Tokens)\r
-{\r
- int Idx=0;\r
- for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++)\r
- {\r
- switch(Idx)\r
- {\r
- case 0: // setentry\r
- continue ;\r
-\r
-\r
- case 1: // index\r
- mIndex = atoi(i->c_str()); break;\r
-\r
-\r
- }\r
- }\r
-\r
- return true;\r
-}\r
-\r
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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));
-}
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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 );
-}
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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 );
-}
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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 ) );
-}
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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 ) );
-}
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- def_skills.cpp\r
-\r
- Authors:\r
- - Akiko\r
- - Namikon\r
- - someone else?\r
-\r
- MODIFIED: Unknown date / Unknown author\r
- REASON: - initial release by unknown\r
-\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL\r
-*/\r
-\r
-#include "main.h"\r
-\r
-// skill.def includes skill names and skill/subskill mapping\r
-\r
-PDefSkill::PDefSkill()\r
-{\r
- mSubSkills = 0;\r
- mNumSubSkills = 0;\r
-}\r
-\r
-PDefSkill::~PDefSkill()\r
-{\r
- delete [] mSubSkills;\r
-}\r
-\r
-bool PDefSkill::LoadFromDef(PTokenList *Tokens)\r
-{\r
- int Idx=0;\r
- for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++)\r
- {\r
- switch(Idx)\r
- {\r
- case 0 : // setentry\r
- continue;\r
-\r
- case 1 :\r
- mIndex = atol(i->c_str()); break;\r
-\r
- case 2 :\r
- mName = *i; break;\r
-\r
- case 3 :\r
- mShortName = *i; break;\r
-\r
- case 4 :\r
- {\r
- mNumSubSkills = atol(i->c_str());\r
- mSubSkills = new int[mNumSubSkills];\r
- std::memset(mSubSkills, 0, sizeof(int)*mNumSubSkills);\r
- break;\r
- }\r
- }\r
-\r
- if(Idx >= 5)\r
- {\r
- mSubSkills[Idx-5] = atoi(i->c_str());\r
- if(!GameDefs->SubSkills()->GetDef(mSubSkills[Idx-5]))\r
- {\r
- Console->Print("Skill def error: skill %s refers to nonexistant subskill %i", mShortName.c_str(), mSubSkills[Idx-5]);\r
- return false;\r
- }\r
- }\r
- }\r
-\r
- if(Idx-5 != mNumSubSkills)\r
- {\r
- Console->Print("Warning: skill %s has incorrect number of subskills", mShortName.c_str());\r
- Console->Print(" Expected %i, available %i", mNumSubSkills, Idx-5);\r
- }\r
- return true;\r
-}\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- def_subskills.cpp\r
-\r
- Authors:\r
- - Akiko\r
- - Namikon\r
- - someone else?\r
-\r
- MODIFIED: Unknown date / Unknown author\r
- REASON: - initial release by unknown\r
-\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL\r
-*/\r
-\r
-#include "main.h"\r
-\r
-// subskill.def, names and parameters of all subskills\r
-\r
-PDefSubSkill::PDefSubSkill()\r
-{\r
- mActionModifiers = 0;\r
- mNumActionModifiers = 0;\r
-}\r
-\r
-PDefSubSkill::~PDefSubSkill()\r
-{\r
- delete [] mActionModifiers;\r
-}\r
-\r
-bool PDefSubSkill::LoadFromDef(PTokenList *Tokens)\r
-{\r
- int Idx=0;\r
- for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++)\r
- {\r
- switch(Idx)\r
- {\r
- case 0 : // setentry\r
- continue;\r
-\r
- case 1 :\r
- mIndex = atoi(i->c_str()); break;\r
-\r
- case 2 :\r
- mName = *i; break;\r
-\r
- case 3 :\r
- mShortName = *i; break;\r
-\r
- case 4 :\r
- mStrengthenFactor = static_cast<float>(atof(i->c_str())); break;\r
-\r
- case 5 :\r
- {\r
- mNumActionModifiers = atoi(i->c_str());\r
- mActionModifiers = new int[mNumActionModifiers];\r
- std::memset(mActionModifiers, 0, sizeof(int)*mNumActionModifiers);\r
- break;\r
- }\r
- }\r
-\r
- if(Idx>=6)\r
- mActionModifiers[Idx-6] = atoi(i->c_str());\r
- }\r
-\r
- return true;\r
-}\r
-\r
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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));
-}
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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)));
-}
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-/*\r
- def_WorldModels.cpp\r
-\r
- Created: 21 Sep 2006 Hammag\r
- REASON: -\r
-*/\r
-\r
-#include "main.h"\r
-\r
-PDefWorldModel::PDefWorldModel()\r
-{\r
-}\r
-\r
-bool PDefWorldModel::LoadFromDef(PTokenList *Tokens)\r
-{\r
- int Idx=0;\r
- for(PTokenList::iterator i=Tokens->begin(); i!=Tokens->end(); i++, Idx++)\r
- {\r
- switch(Idx)\r
- {\r
- case 0: // setentry\r
- continue;\r
-\r
- case 1: // index\r
- mIndex = atoi(i->c_str()); break;\r
-\r
- case 2: // name\r
- mName = *i; break;\r
-\r
- case 3: // use flag\r
- mUseFlags = atoi(i->c_str()); break;\r
- \r
- case 4: // function type\r
- mFunctionType = atoi(i->c_str()); break;\r
-\r
- case 5: // function value\r
- mFunctionValue = atoi(i->c_str()); break;\r
- \r
- case 6: // hack difficulty\r
- mHackDifficulty = atoi(i->c_str()); break;\r
-\r
- case 7: // hack penalty\r
- mHackPenalty = atoi(i->c_str()); break;\r
- }\r
- }\r
-\r
- return true;\r
-}\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- defparser.cpp\r
-\r
- Authors:\r
- - Akiko\r
- - Namikon\r
- - someone else?\r
-\r
- MODIFIED: Unknown date / Unknown author\r
- REASON: - initial release by unknown\r
-\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL\r
-*/\r
-\r
-#include "main.h"\r
-\r
-PDefParser::PDefParser()\r
-{\r
-}\r
-\r
-PDefParser::~PDefParser()\r
-{\r
- for(PDefTokenList::iterator i=mTokens.begin(); i!=mTokens.end(); i++)\r
- delete *i;\r
-}\r
-\r
-bool PDefParser::Parse(const char *File)\r
-{\r
- PFile *f = Filesystem->Open("", File, Config->GetOption("nc_data_path"));\r
- enum { NOPE, MAYBE, LINE, BLOCK, MAYBE_END } Comment = NOPE;\r
-\r
- if(f)\r
- {\r
- while(!f->Eof())\r
- {\r
- std::string Str = f->ReadString();\r
- int Len = Str.length();\r
- if(Len <= 0)\r
- continue;\r
-\r
- if(Str.substr(0, 3)!="set")\r
- continue;\r
-\r
- //Console->Print("%s", Str.c_str());//NEW was commented , just to be sure of what we are reading\r
-\r
- PTokenList *List = new PTokenList();\r
- int Start=0, Tokens=0;\r
- bool Quote=false;\r
- for(int i=0; i<Len; i++)\r
- {\r
- if(Str[i]=='\r' || Str[i]=='\n' || Str[i]=='|' || Str[i]==';')\r
- {\r
- if(Comment < LINE)\r
- {\r
- int End=i-1;\r
- if(End >= Start)\r
- {\r
- List->push_back(std::string(Str.substr(Start, (End-Start)+1)));\r
- Tokens++;\r
- break;\r
- }\r
- Quote=false;\r
- }\r
- if(Comment != BLOCK)\r
- Comment=NOPE;\r
- break;\r
- }\r
-\r
- if(!Quote)\r
- {\r
- if(Comment < LINE && (Str[i]=='\t' || Str[i]==',' || Str[i]==' ' || Str[i]==';' || Str[i]=='|' || i==Len-1))\r
- {\r
- int End=i-1;\r
- if(End >= Start)\r
- {\r
- List->push_back(std::string(Str.substr(Start, (End-Start)+1)));\r
- Tokens++;\r
- }\r
- Start=i+1;\r
- }\r
-\r
- if(Str[i] <= ' ')\r
- continue;\r
-\r
- if(Str[i]=='*')\r
- {\r
- if(Comment==MAYBE)\r
- Comment=BLOCK;\r
- else\r
- if(Comment==BLOCK)\r
- Comment=MAYBE_END;\r
- } else\r
- if(Str[i]=='/')\r
- {\r
- if(Comment==MAYBE)\r
- {\r
- // second slash, skip rest of line\r
- Comment=LINE;\r
- break;\r
- } else\r
- if(Comment==MAYBE_END)\r
- {\r
- Comment=NOPE; // comment block ends\r
- Start=i+1;\r
- } else\r
- if(Comment != BLOCK)\r
- Comment=MAYBE; // first slash\r
- } else\r
- {\r
- if(Comment==MAYBE)\r
- Comment=NOPE; // stand-alone slash\r
- else\r
- if(Comment==MAYBE_END)\r
- Comment=BLOCK; // comment block did not end\r
- }\r
- }\r
-\r
- if(Str[i]=='"')\r
- Quote ^= true;\r
- }\r
-\r
- if(Tokens > 0)\r
- mTokens.push_back(List);\r
- else\r
- delete List;\r
- }\r
- } else\r
- {\r
- Console->Print("%s PDefParser::Parse: could not open file %s", Console->ColorText( RED, BLACK, "[ERROR]" ), File);\r
- return false;\r
- }\r
-\r
- return true;\r
-}\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- main.h - main include file, contains all needed includes and important definitions\r
-\r
- MODIFIED: 30 Aug 2006 Hammag\r
- REASON: - created \r
- MODIFIED: 21 Sep 2006 Hammag\r
- REASON: - added def_worldmodels related stuff \r
- MODIFIED: 22 Sep 2006 Hammag\r
- REASON: - added def_appartements related stuff\r
- - added def_appplaces related stuff\r
- - added def_respawn related stuff\r
- MODIFIED: 28 Sep 2006 Hammag\r
- REASON: - added def_worldfile (worlds.ini) related stuff \r
- MODIFIED: 10 Jun 2009 Akiko \r
- REASON: - adjusted includes for new buildsystem\r
-*/\r
-\r
-#ifndef MAIN_H\r
-#define MAIN_H\r
-\r
-//#include "version.h"\r
-\r
-//basic includes\r
-#include "include/external.h"\r
-\r
-//tinns includes\r
-#include "include/types.h"\r
-#include "common/config.h"\r
-\r
-#include "common/console.h"\r
-#include "common/misc.h"\r
-\r
-#include "include/globals.h"\r
-\r
-#include "common/filesystem.h"\r
-#include "include/defparser.h"\r
-#include "include/defs.h"\r
-\r
-\r
-// The following defines are NOT used anymore\r
-#define DEF_CHARACTERS "defs/characters.def"\r
-#define DEF_SKILLS "defs/skills.def"\r
-#define DEF_SUBSKILLS "defs/subskill.def"\r
-#define DEF_CHARKINDS "defs/charkinds.def"\r
-#define DEF_WORLDINFO "defs/worldinfo.def"\r
-#define DEF_FRACTIONS "defs/fractions.def"\r
-#define DEF_HACK "defs/hack.def"\r
-#define DEF_ITEMS "defs/items.def"\r
-#define DEF_WORLDMODEL "defs/worldmodel.def"\r
-#define DEF_APPPLACES "defs/appplaces.def"\r
-#define DEF_APPARTEMENTS "defs/appartements.def"\r
-#define DEF_RESPAWN "defs/respawn.def"\r
-#define DEF_WEAPONS "defs/weapons.def"\r
-#define DEF_AMMO "defs/ammo.def"\r
-#define DEF_BLUEPRINTPIECES "defs/blueprintpieces.def"\r
-#define DEF_DAMMAGE "defs/dammage.def"\r
-#define DEF_DRUGS "defs/drugs.def"\r
-#define DEF_IMPLANTS "defs/implants.def"\r
-#define DEF_ITEMMOD "defs/itemmod.def"\r
-#define DEF_ITEMRES "defs/itemres.def"\r
-#define DEF_NPC "defs/npc.def"\r
-#define DEF_NPCARMOR "defs/npcarmor.def"\r
-#define DEF_NPCGROUPSPAWN "defs/npcgroupspawn.def"\r
-#define DEF_NPCLOOT "defs/npcloot.def"\r
-#define DEF_OUTPOSTS "defs/outposts.def"\r
-#define DEF_RECYCLES "defs/recycles.def"\r
-#define DEF_TRADER "defs/trader.def"\r
-#define DEF_VEHICLES "defs/vehicles.def"\r
-#define DEF_VEHICLESEATS "defs/vehiclesits.def"\r
-#define WRLD_WORLDFILE "worlds/worlds.ini"\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-/*\r
- world_datstruct.h\r
- .dat world files internal structures\r
-\r
- MODIFIED: 29 Sep 2006 Hammag\r
- REASON: - Creation\r
-*/\r
-\r
-#ifndef WORLD_DATSTRUCT_H\r
-#define WORLD_DATSTRUCT_H\r
-\r
-struct PWorldFileHeader\r
-{\r
- u32 mHeaderSize; // must be 08 00 00 00, = header size after this field\r
- u32 mHeaderSig; // must be CF CF 0F 00\r
- u32 mSection; // must be 01 00 00 00\r
-};\r
-\r
-struct PSectionHeader\r
-{\r
- u32 mHeaderSize; // must be 0C 00 00 00\r
- u32 mHeaderSig; // must be CF FF 00 00\r
- u32 mSection; // 00 00 00 00 means end\r
- u32 mDataSize;\r
-};\r
-\r
-struct PSec2ElemHeader\r
-{\r
- u32 mHeaderSize; // must be 0C 00 00 00\r
- u32 mHeaderSig; // must be F1 FE FE 0F\r
- u32 mElementType; // 1000003, 1000005 or 1000014\r
- u32 mDataSize;\r
-};\r
-\r
-struct PSec2ElemType3a //static object ?\r
-{\r
- f32 mPosY; //= u16 PosY - 32000\r
- f32 mPosZ;\r
- f32 mPosX;\r
- f32 mRotY;\r
- f32 mRotZ;\r
- f32 mRotX;\r
- f32 mScale; //00 00 80 3F ? = float(1.000000) !!! => scale factor ?????\r
- u32 mUnknown2; //01 00 00 00 ?\r
- u16 mModelID; // points to models.ini\r
- u32 mUnknown3; //00 00 00 00 ?\r
- u32 mUnknown4; //00 00 00 00 ?\r
- u16 mWorldmodelID; // points to worldmodel.def\r
- u16 mUnknown5; //12 00 ?\r
- u32 mObjectID;\r
-};\r
-struct PSec2ElemType3b //this part is optional\r
-{\r
- f32 mBoxLowerY; //Bounding box, for useflag "64 - selfconstructing colisionbox"\r
- f32 mBoxLowerZ; // s32 or u32 ?\r
- f32 mBoxLowerX;\r
- f32 mBoxUpperY;\r
- f32 mBoxUpperZ;\r
- f32 mBoxUpperX;\r
-};\r
-\r
-struct PSec2ElemType5Start //door\r
-{\r
- u16 mUnknown1; //18 00\r
- u16 mUnknown1bis; //00 00 ? varies\r
- f32 mPosY;\r
- f32 mPosZ;\r
- f32 mPosX;\r
- u8 mActorStringSize; //string size with ending 0\r
- u8 mParamStringSize; //string size with ending 0\r
- u16 mUnknown5; //00 00 ? second byte varies\r
- u16 mDoorID; // but what is the link with ObjectID sent in Use message (can't find the base offset .. or 0x80 for doors ???)\r
- u16 mWorldmodelID; //door type from worldmodel.def\r
-};\r
-//Actor As String //null terminated string\r
-//Params As String //null terminated string - for DDOOR, 2nd param is the ID of the other (half)door (*)\r
-//param1 = 2 => simple lateral move ?, 3 => door frontal+lateral move (as at Typherra memorial) ?\r
-//last param = 0/1 for lateral move direction ? no ...\r
-//(*) here is the bug(?) that makes open only one half of a double door\r
-\r
-/*\r
-struct PSec2ElemType6Start //npc\r
-{\r
- u16 mUnknown1; //20 00 ?\r
- u16 mUnknown2; //12 00 ?\r
- f32 mPosY;\r
- f32 mPosZ;\r
- f32 mPosX;\r
- u32 mNPCTypeID; //npc type in npc.def\r
- u8 mActorStringSize; //string size with ending 0\r
- u8 mParamStringSize; //string size with ending 0\r
- u16 mNpcID; // kind of ?\r
- u32 mUnknown3; //01 00 00 00 ?\r
- u16 mUnknown4; //00 00 ?\r
- u16 mUnknown5; //04 00 ?\r
-};\r
- //Actor As String //null terminated string\r
- //Params As String //null terminated string - Seem to be the facing angle in degres\r
-struct PSec2ElemType6End\r
-{\r
- f32 mPosY2; //second position for movement ?\r
- f32 mPosZ2; //\r
- f32 mPosX2; //\r
-};\r
-*/\r
-struct PSec2NPC_EntryPart1\r
-{\r
- u32 mUnknown1; // Is always 0x20001200, in every log. maybe header for NPCs?\r
- f32 mPosY;\r
- f32 mPosZ;\r
- f32 mPosX;\r
- u32 mNPCTypeID; //npc type in npc.def\r
- u8 mActorStringSize; //string size with ending 0\r
- u8 mAngleStringSize; //string size with ending 0\r
- u16 mNpcID;\r
- u8 mHasAdditionalCoords;\r
- u8 mUnknown2a;\r
- u8 mUnknown2b;\r
- u8 mUnknown2c;\r
- u16 mTradeID; //mUnknown3; //00 00 ?\r
- u16 mUnknown4; //04 00 ?\r
-};\r
-\r
-// u8 mActorName[mActorStringSize];\r
-// u8 mAngle[mAngleStringSize];\r
-\r
-struct PSec2NPC_EntryPart2 // Waypoints! or something like that...\r
-{\r
- f32 mPosY;\r
- f32 mPosZ;\r
- f32 mPosX;\r
-};\r
-\r
-\r
-// u16 mStrSize; //non-zero terminated string size\r
-// Name As String //non-zero terminated string\r
-struct PSec2ElemType15End //area definition/sound ?\r
-{\r
- f32 mUnknown1;\r
- f32 mUnknown2;\r
- f32 mUnknown3;\r
- f32 mUnknown4;\r
- f32 mUnknown5;\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-/*\r
- doortemplate.cpp - world door template class\r
-\r
- MODIFIED: 05 Nov 2006 Hammag\r
- REASON: - creation\r
- MODIFIED: 09 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
- \r
- TODO: - mem corruption occurs if mDoorParameters[] is given a size of 6, and that 6 max param can be accepted\r
- This bug occurs in world 105. Reason not found yet :-x\r
-*/\r
-\r
-\r
-#include "main.h"\r
-\r
-#include "include/doortemplate.h"\r
-\r
-PDoorTemplate::PDoorTemplate()\r
-{\r
- mDoorID = 0;\r
- mWorldmodelID = 0;\r
- mDefWorldModel = NULL;\r
- mIsDoubleDoor = false;\r
- mIsTriggeredDoor = false;\r
-}\r
-\r
-PDoorTemplate::~PDoorTemplate()\r
-{\r
- \r
-}\r
-\r
-void PDoorTemplate::SetDoorParameters(char* nDoorParametersString)\r
-{\r
- char* SepPos;\r
- int ParamNum = 0;\r
-//Console->Print("door parameter: %s", nDoorParametersString);\r
- while ( *nDoorParametersString && (SepPos = strchr(nDoorParametersString, ',')) && (ParamNum < 4))\r
- {\r
- *SepPos = 0;\r
- mDoorParameters[ParamNum++] = atoi(nDoorParametersString);\r
- nDoorParametersString = SepPos + 1;\r
- }\r
- if (*nDoorParametersString)\r
- {\r
- if (ParamNum < 4)\r
- mDoorParameters[ParamNum] = atoi(nDoorParametersString);\r
- //else\r
- // Console->Print(RED, BLACK, "[ERROR] More than 4 parameters in Sec2ElemType5 ParamString");\r
- }\r
-}\r
-\r
-void PDoorTemplate::SetDoorTypeName(char* nDoorTypeName)\r
-{\r
- mDoorTypeName = nDoorTypeName;\r
-\r
- if (mDoorTypeName == "DDOOR")\r
- {\r
- mIsDoubleDoor = true;\r
- }\r
- else if (mDoorTypeName == "TRIGDD")\r
- {\r
- mIsDoubleDoor = true;\r
- mIsTriggeredDoor = true;\r
- }\r
- else if (mDoorTypeName == "TRIGDOOR")\r
- {\r
- mIsTriggeredDoor = true;\r
- }\r
- else if (mDoorTypeName == "NBUTTON")\r
- {\r
- mIsTriggeredDoor = false;\r
- }\r
-}\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-/*\r
- furnituretemplate.cpp - world furniture template class\r
-\r
- MODIFIED: 04 Oct 2006 Hammag\r
- REASON: - creation\r
- MODIFIED: 09 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
-*/\r
-\r
-\r
-#include "main.h"\r
-\r
-#include "include/furnituretemplate.h"\r
-\r
-PFurnitureItemTemplate::PFurnitureItemTemplate()\r
-{\r
- mObjectID = 0;\r
- mModelID = 0;\r
- mWorldmodelID = 0;\r
- mDefWorldModel = NULL;\r
- mLinkedObjectID = 0;\r
-}\r
-\r
-PFurnitureItemTemplate::~PFurnitureItemTemplate()\r
-{\r
- \r
-}\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-#include "main.h"\r
-\r
-void PCommands::doCmdbroadcast()\r
-{\r
- if(DumbMade == false)\r
- {\r
- Console->Print("%s Missing packetdumb in PCommands::doCmdbroadcast for declared broadcast function!", Console->ColorText(RED, BLACK, "[PANIC]"));\r
- return;\r
- }\r
-\r
- Chat->sendBroadcast(OrgPacketDumb+11);\r
-}\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-#include "main.h"\r
-\r
-void PCommands::doCmdcolor()\r
-{\r
- bool SyntaxError = false;\r
- if(ArgC < 1)\r
- {\r
- SyntaxError = true;\r
- }\r
-\r
- if(SyntaxError == true)\r
- {\r
- Chat->send(source, CHAT_DIRECT, "Usage", "@color -|<head color: 0..255> [-|<torso color>] [-|<legs color>]");\r
- return;\r
- }\r
-\r
- char tmp_v1[30];\r
- char tmp_v2[30];\r
- char tmp_v3[30];\r
-\r
- GetArgText(1, tmp_v1, 30);\r
- GetArgText(2, tmp_v2, 30);\r
- GetArgText(3, tmp_v3, 30);\r
-\r
- u8 val1, val2, val3, val4, val5, val6;\r
- char effStr[128];\r
- PMessage* tmpMsg;\r
-\r
- source->GetChar()->GetCurrentBodyColor(val1, val2, val3, val4, val5, val6);\r
- if(tmp_v1[0] != '-')\r
- val1 = (u8)(atoi(tmp_v1) & 0xff);\r
- if((tmp_v2[0] != '-') && (tmp_v2[0] != '\0'))\r
- val2 = (u8)(atoi(tmp_v2) & 0xff);\r
- if((tmp_v3[0] != '-') && (tmp_v3[0] != '\0'))\r
- val3 = (u8)(atoi(tmp_v3) & 0xff);\r
- source->GetChar()->SetCurrentBodyColor(val1, val2, val3, val4, val5, val6);\r
-\r
- tmpMsg = MsgBuilder->BuildCharHelloMsg(source);\r
- ClientManager->UDPBroadcast(tmpMsg, source);\r
- snprintf(effStr, 127, "Body color set to values %d %d %d", val1, val2, val3);\r
- effStr[127] = '\0';\r
- Chat->send(source, CHAT_DIRECT, "System", effStr);\r
-}\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-#include "main.h"\r
-\r
-void PCommands::doCmdeffect()\r
-{\r
- bool SyntaxError = false;\r
- if(ArgC < 1)\r
- {\r
- SyntaxError = true;\r
- }\r
-\r
- if(IsArgNumeric(1) == false)\r
- SyntaxError = true;\r
-\r
- if(SyntaxError == true)\r
- {\r
- Chat->send(source, CHAT_DIRECT, "Usage", "@effect <effect: 0=none, 1 .. 17> [<density: 0=max .. 255=min>]");\r
- return;\r
- }\r
-\r
- u8 val1, val2;\r
- char effStr[128];\r
- PMessage* tmpMsg;\r
-\r
- val1 = (u8)(GetArgInt(1) & 0xff);\r
- val2 = (u8)(GetArgInt(2) & 0xff);\r
-\r
- source->GetChar()->SetBodyEffect(val1, val2);\r
-\r
- tmpMsg = MsgBuilder->BuildCharHelloMsg(source);\r
- ClientManager->UDPBroadcast(tmpMsg, source);\r
- snprintf(effStr, 127, "Body effect set to value %d with density %d (but you can see it yourself)", val1, val2);\r
- effStr[127] = '\0';\r
- Chat->send(source, CHAT_DIRECT, "System", effStr);\r
-}\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-#include "main.h"\r
-\r
-void PCommands::doCmdlistbans()\r
-{\r
- Chat->send(source, CHAT_DIRECT, "System", "Sorry, namikon was too lazy to code that ^^");\r
- Chat->send(source, CHAT_DIRECT, "System", "Please wait until the ban is removed automaticly or edit your sqlDB");\r
- return;\r
-}\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- main.h - main include file, contains all needed includes and important definitions\r
-\r
- MODIFIED: 30 Aug 2006 Hammag\r
- REASON: - created\r
- MODIFIED: 10 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
-*/\r
-\r
-#ifndef MAIN_H\r
-#define MAIN_H\r
-\r
-//#include "version.h"\r
-\r
-//basic includes\r
-#include "include/external.h"\r
-\r
-//tinns includes\r
-#include "include/types.h"\r
-#include "common/config.h"\r
-\r
-#include "common/console.h"\r
-#include "common/misc.h"\r
-\r
-#include "common/netcode.h"\r
-\r
-#include "include/globals.h"\r
-\r
-/*\r
-#include "../gamemonkey/gmMachine.h"\r
-#include "../gamemonkey/gmCall.h"\r
-*/\r
-\r
-// MySQL Support // shouldn't be needed as DB-objects access class should do that\r
-#ifdef MYSQL_INC_DIR\r
-#include <mysql/mysql.h>\r
-#else\r
-#include <mysql.h>\r
-#endif\r
-\r
-#include "include/sql.h"\r
-\r
-#include "common/filesystem.h"\r
-#include "include/defparser.h"\r
-\r
-#include "include/skill.h"\r
-\r
-#include "include/chars.h"\r
-#include "include/accounts.h"\r
-#include "include/defs.h"\r
-#include "include/client.h"\r
-#include "include/server.h"\r
-#include "include/gameserver.h"\r
-#include "include/zoning.h"\r
-#include "include/item.h"\r
-#include "include/inventory.h"\r
-\r
-#include "include/chat.h"\r
-#include "include/commands.h"\r
-#include "include/clientmanager.h"\r
-#include "include/msgbuilder.h"\r
-#include "include/worlds.h"\r
-#include "include/worldactors.h"\r
-#include "include/npc.h"\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-#include "main.h"\r
-\r
-void PCommands::doCmdconlist()\r
-{\r
- if (gDevDebug) Console->Print("IngameCommand: Sending connected-player-list to charID %d", source->GetCharID());\r
- Chat->sendConnectedList(source, false);\r
-}\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-#include "main.h"\r
-\r
-void PCommands::doCmdsettime()\r
-{\r
- if(ArgC < 1 && GetArgInt(1) == 0)\r
- {\r
- Chat->send(source, CHAT_DIRECT, "Usage", "@settime <raw timevalue>");\r
- return;\r
- }\r
-\r
- int newtime = 0;\r
- newtime = GetArgInt(1);\r
-\r
- GameServer->SetGameTime(newtime);\r
- Console->Print("IngameCommand: CharID %d set ingametime to %d", source->GetCharID(), newtime);\r
-}\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-#include "main.h"\r
-\r
-void PCommands::doCmdspeed()\r
-{\r
-// Speed override setting.\r
-// Usage: @speed <newspeed> | #\r
-// with <speed> = 0 (no move).. 254 , 255 or # meaning "no speed override"\r
-\r
- bool SyntaxError = false;\r
- if(ArgC < 1)\r
- {\r
- SyntaxError = true;\r
- }\r
-\r
- if(SyntaxError == true)\r
- {\r
- Chat->send(source, CHAT_DIRECT, "Usage", "@speed <newspeed: 0 .. 254 > | 255 | #");\r
- return;\r
- }\r
- char tmpval[30];\r
- GetArgText(1, tmpval, 30);\r
-\r
- u8 val1;\r
- char effStr[128];\r
- PMessage* tmpMsg;\r
-\r
- val1 = ((tmpval[0] == '#') ? 255 : (u8)(atoi(tmpval) & 0xff));\r
- source->GetChar()->SetSpeedOverride(val1);\r
-\r
- tmpMsg = MsgBuilder->BuildCharHelloMsg(source);\r
- ClientManager->UDPBroadcast(tmpMsg, source);\r
- snprintf(effStr, 127, "Speed override set to value %d ", val1);\r
- effStr[127] = '\0';\r
- Chat->send(source, CHAT_DIRECT, "System", effStr);\r
-}\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-#include "main.h"\r
-\r
-void PCommands::doCmdunban()\r
-{\r
- Chat->send(source, CHAT_DIRECT, "System", "Unban is not yet possible, sorry.");\r
-}\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-#include "main.h"\r
-\r
-void PCommands::doCmd_dev_v()\r
-{\r
- if(IsAdmin() == false)\r
- return;\r
- \r
- char Arg1[30];\r
-\r
- Arg1[0] = '\0';\r
-\r
- if(ArgC > 0)\r
- {\r
- GetArgText(1, Arg1, 30);\r
- }\r
-\r
- char tmpStr[128];\r
- int testmode = 1; // change here only for u8/u16/u32 testvalue use\r
-\r
- if(Arg1[0] != '\0')\r
- {\r
- switch(testmode)\r
- {\r
- case 0: source->testval8 = (u8)(atoi(Arg1) & 0xff); break;\r
- case 1: source->testval16 = (u16)(atoi(Arg1) & 0xffff); break;\r
- case 2: source->testval32 = (u32)(atoi(Arg1) & 0xffffffff); break;\r
- }\r
- }\r
- else\r
- {\r
- source->testval8 = 0;\r
- source->testval16 = 0;\r
- source->testval32 = 0;\r
- }\r
-\r
- switch(testmode)\r
- {\r
- case 0: snprintf(tmpStr, 127, "Test value u8 set to 0x%02x (%d)", source->testval8, source->testval8); break;\r
- case 1: snprintf(tmpStr, 127, "Test value u16 set to 0x%04x (%d)", source->testval16, source->testval16); break;\r
- case 2: snprintf(tmpStr, 127, "Test value u32 set to 0x%08x (%d)", source->testval32, source->testval32); break;\r
- default: tmpStr[0] = '\0';\r
- }\r
- tmpStr[127] = '\0';\r
- Chat->send(source, CHAT_DIRECT, "System", tmpStr);\r
-\r
-}\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-#include "main.h"\r
-\r
-void PCommands::doCmdversion()\r
-{\r
- char tmpChatMsg[300];\r
- snprintf(tmpChatMsg, 299, "You are on TinNS server %s runnig version %s - SVN Rev. %s", Config->GetOption("server_name").c_str(), ServerVersion, SVNRevision);\r
- tmpChatMsg[299] = '\0';\r
-\r
- Chat->send(source, CHAT_DIRECT, "System", tmpChatMsg);\r
-}\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- accounts.h\r
-\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL\r
- MODIFIED: 26 Dec 2005 Namikon\r
- REASON: - Added load/save functions for SQL DB\r
- MODIFIED: 01 Jan 2005 Namikon\r
- REASON: - Added bool var for ingame debug outputs for administrators\r
- MODIFIED: 06 Jan 2005 Namikon\r
- REASON: - Added SetBannedStatus(<unix timestamp>) to ban/unban an account (use SetBannedStatus(0) to unban a player)\r
- MODIFIED: 09 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
-*/\r
-\r
-#ifndef ACCOUNTS_H\r
-#define ACCOUNTS_H\r
-\r
-#ifdef _MSC_VER\r
- #pragma once\r
-#endif\r
-\r
-#include "common/regex++.h"\r
-\r
-/*\r
-0 = unregistered user\r
-1 = Registered user\r
-30 = volunteer\r
-50 = GM\r
-100 = Admin\r
-*/\r
-\r
-// New way of AccountLevel handling:\r
-// Every level is possible, the following values are only edge values. We need a bit control about that\r
-#define PAL_BANNED -1\r
-#define PAL_UNREGPLAYER 0\r
-#define PAL_REGPLAYER 1\r
-#define PAL_VOLUNTEER 30 // Special Rank: 50/50\r
-#define PAL_GM 50 // Special Rank: 120/120\r
-#define PAL_ADMIN 100 // Special Rank: 127/127\r
-\r
-// Max number of char slots per account\r
-#define MAX_CHARS_PER_ACCOUNT 4\r
-\r
-/*\r
-0 = Offline\r
-1 = Online\r
-2 = Banned\r
-*/\r
-\r
-enum PAccountStatus\r
-{\r
- PAS_OFFLINE = 0,\r
- PAS_ONLINE = 1,\r
- PAS_BANNED = 2\r
-};\r
- \r
-class PAccount\r
-{\r
- private :\r
- // SQL Layout\r
- enum {\r
- a_id,\r
- a_username,\r
- a_password,\r
- a_priv,\r
- a_status,\r
- a_bandate\r
- };\r
- \r
- // static members\r
- static RegEx* mUsernameRegexFilter;\r
- static RegEx* mPasswordRegexFilter;\r
- \r
- // instance members\r
- u32 mID;\r
- std::string mName;\r
- std::string mPassword;\r
- int mLevel;\r
- PAccountStatus mStatus;\r
- std::time_t mBannedUntil;\r
-\r
- bool LoadFromQuery(char* query);\r
- bool DecodePassword(const u8* PasswordData, int PassLen, const u8 *Key, char* ClearPassword);\r
- \r
- public :\r
- PAccount();\r
- PAccount(const u32 AccountId);\r
- PAccount(const char *Username);\r
- \r
- static bool SetUsernameRegexFilter(const char* RegexStr);\r
- static bool SetPasswordRegexFilter(const char* RegexStr);\r
- static bool IsUsernameWellFormed(const char *Username);\r
- static bool IsPasswordWellFormed(const char *Password);\r
- \r
- inline u32 GetID() const { return mID; }\r
- bool SetName(const std::string &Pass);\r
- inline const std::string &GetName() const { return mName; }\r
- bool SetPassword(const std::string &Pass);\r
- bool SetPasswordEncoded(const u8* PasswordData, int PassLen, const u8 *Key);\r
- inline const std::string &GetPassword() const { return mPassword; }\r
- bool SetLevel(int newLevel);\r
- inline int GetLevel() const { return mLevel; }\r
- std::string GetLevelString() const;\r
- bool SetStatus(PAccountStatus Status);\r
- inline PAccountStatus GetStatus() const { return mStatus; }\r
- bool SetBannedUntilTime(std::time_t BannedUntil);\r
- inline bool IsBanned() const { return (mBannedUntil > std::time(NULL)); }\r
- std::string GetBannedTime() const;\r
-\r
- bool Authenticate(const u8* PasswordData, int PassLen, const u8 *Key);\r
- bool Authenticate(const char *Password) const;\r
- \r
- bool Create();\r
- bool Save(bool CreateMode = false);\r
-\r
- u32 GetCharIdBySlot(const u32 SlotId);\r
-};\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- appartements.h - appartements class\r
-\r
- MODIFIED: 20 Nov 2006 Hammag\r
- REASON: - creation\r
- \r
-*/\r
-\r
-#ifndef APPARTEMENTS_H\r
-#define APPARTEMENTS_H\r
-\r
-class PChar;\r
-\r
-class PAppartements\r
-{\r
- private:\r
- \r
- public:\r
- PAppartements();\r
- //~PAppartements();\r
- \r
- u32 CreateBaseAppartement(u32 nCharID, std::string nPassword, u8 nFactionID);\r
- void DeleteCharAppartements(u32 nCharID);\r
- bool CanFreelyEnter(PChar* nChar, u32 nLocation);\r
- int GetAptID(unsigned int AptLoc, const u8 *pass);\r
- int GetAptType(int AptID);\r
- int GetAptOwner(int loc);\r
- int GetAptLocation(int loc);\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- buddylist.h - classe for chat buddylist\r
-\r
- MODIFIED: 19 Sep 2006 Hammag\r
- REASON: - creation\r
-\r
-*/\r
-\r
-#ifndef BUDDYLIST_H\r
-#define BUDDYLIST_H\r
-\r
-#define BUDDYLIST_ALLOC_SIZE 4 // atomicity of list entries allocation\r
-\r
-class PBuddyList\r
-{\r
- private:\r
- enum { // buddy_list DB Table fields\r
- bud_id = 0,\r
- bud_charid,\r
- bud_buddyid\r
- };\r
-\r
- u32 mOwnerCharID;\r
- u8 mListMaxSize;\r
- u8 mListSize;\r
- u32* mCharIDList;\r
-\r
- void IncreaseMaxSize(u8 nNewMax = 0);\r
- u8 FindEntry(u32 CharID);\r
-\r
- public:\r
- PBuddyList(u32 nOwnerCharID);\r
- ~PBuddyList();\r
- bool AddChar(u32 nBuddyCharID);\r
- bool RemoveChar(u32 nBuddyCharID);\r
- inline u8 Count() { return mListSize; }\r
- u16 GetListDataSize() { return (sizeof(u32) * mListSize); }\r
- const void* GetListData() { return (const void*)mCharIDList; }\r
- bool SQLLoad();\r
-\r
- bool IsInBuddy(u32 CharID);\r
-// bool SQLSave();\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- chars.h - this is the main file with the main function\r
-\r
- Authors:\r
- - Namikon\r
- - Akiko\r
-\r
- MODIFIED: 22 Dec 2005 Namikon\r
- REASON: - Added GPL\r
- MODIFIED: 01 Jan 2006 Namikon\r
- REASON: - Added SQLLoad() function to PChar and PChars\r
- - Added enum for charlist SQL Database\r
- - Added IsOnline var and inline func for Onlinestatus of char\r
- MODIFIED: 26 Jul 2006 Namikon\r
- REASON: - Added Health/MaxHealth, idem for Mana & Stamin\r
- TODO: - fix real current Health vs MaxHealth, also in char load/save\r
-\r
- MODIFIED: 03 Oct 2006 Hammag\r
- REASON: - PChar::CreateNewChar() and moved effective char creation from PChars to PChar\r
- - added PChar::SQLDelete()\r
- This method is put here because we want the char to be loaded when deleted from DB to avoid\r
- any player to use it at the same time.\r
- - added use of auto_save_period config option in PChars::update()\r
- MODIFIED: 09 Jun 2009 Akiko\r
- REASON: - adjusted includes for new build system\r
- - clean ups\r
-*/\r
-\r
-#ifndef CHARS_H\r
-#define CHARS_H\r
-\r
-#ifdef _MSC_VER\r
-#pragma once\r
-#endif\r
-\r
-#define MAXCASH 1000000000\r
-\r
-#include "inventory.h"\r
-#include "buddylist.h"\r
-#include "genreplist.h"\r
-#include "common/regex++.h"\r
-class PVhcAccessRequestList;\r
-\r
-enum PSeatType\r
-{\r
- seat_none = 0,\r
- seat_chair,\r
- seat_subway,\r
- seat_vhc\r
-};\r
-\r
-class PCharCoordinates\r
-{\r
- public:\r
- u16 mY; // Y-Position in world // Y increases when going East\r
- u16 mZ; // Z-Position in world // Z increases when going up\r
- u16 mX; // X-Position in world // X increases when going South\r
- u8 mUD; // Up - Mid - Down (d6 - 80 - 2a)\r
- u8 mLR; // Compass direction (S..E..N..W..S [0-45-90-135-179])\r
- u8 mAct; // Last user action state\r
- u8 mUnknown;// sometime sent by client with value != 0 (usual case)\r
- // mAct:\r
- // 0x00 NC has no focus (player alt+tab'ed out)\r
- // 0x04 Char on ground/dead 00000100\r
- // 0x20 Char does nothing 00100000\r
- // 0x22 kneeing 00100010\r
- // 0x28 left step 00101000\r
- // 0x30 right step 00110000\r
- // 0x40 walking (not running) 01000000 // Seems to mean Running ? - to be verfied, with default walk/run mode !!!\r
- // 0x60 forward 01100000\r
- // 0xA0 backward 10100000\r
- // bits: BFWRL.K.\r
-\r
- u8 mJumpingState;\r
-\r
- //inline PCharCoordinates() { mX = mY = mZ = mUD = mLR = mAct = mUnknown = mJumpingState = 0;}\r
- void SetPosition( u16 nY, u16 nZ, u16 nX, u8 nUD = 0x80, u8 nLR = 0 );\r
- void SetInterpolate( PCharCoordinates& Pos1, PCharCoordinates& Pos2, f32 nCoef );\r
- \r
- //Temp\r
- u16 minPos[3];\r
- u16 maxPos[3];\r
- inline PCharCoordinates() { mX = mY = mZ = mUD = mLR = mAct = mUnknown = mJumpingState = 0; for(int i=0; i<3; ++i) { minPos[i] = 0xffff; maxPos[i] = 0; } }\r
-};\r
-\r
-class PChar\r
-{\r
- private :\r
- // static members\r
- static RegEx* mCharnameRegexFilter;\r
-\r
- // instance members\r
- u32 mID;\r
- u32 mAccount;\r
- u8 mSlot;\r
- std::string mName;\r
- u32 mGender;\r
- u32 mClass;\r
- //u32 mType; // Removed that and only keep GetType()\r
- u32 mProfession;\r
- u32 mFaction;\r
- u32 mRealHead; // Base Skin elements, in complement of (computed) mType\r
- u32 mRealTorso; // " Head shouldn't be changeable, except in case of surgery !!!\r
- u32 mRealLegs; // "\r
- u32 mSkin; // Current Skin elements. *** Not saved in DB atm ***\r
- u32 mHead; // "\r
- u32 mTorso; // "\r
- u32 mLegs; // "\r
- u8 mHeadColor; // "\r
- u8 mTorsoColor; // "\r
- u8 mLegsColor; // "\r
- u8 mHeadDarkness; // " // 0=Bright, 255=dark\r
- u8 mTorsoDarkness; // "\r
- u8 mLegsDarkness; // "\r
- // Skin scale factor setting remain to discover, provided they are somewhere for player chars ...\r
-\r
- bool mLocationLeased; // temp until char on-demand load/unload\r
- u32 mLocation;\r
- u32 mCash;\r
- u32 mStartApt; // set same as PrimaryApt atm\r
- u32 mPrimaryApt;\r
-\r
- // not saved in DB atm\r
- PSeatType mSeatInUseType;\r
- u32 mSeatInUseObjectId;\r
- u8 mSeatInUseSeatId;\r
- PVhcAccessRequestList* mVhcAccessRequestList;\r
-\r
- PContainer* mContainerInExclusiveUse;\r
-\r
- u16 mHealth;\r
- u16 mMana;\r
- u16 mStamina;\r
-\r
- s8 mSoullight;\r
- u8 mCombatRank; // *** Not got/saved from DB atm ***\r
- u8 mSynaptic; // *** Not got/saved from DB atm ***\r
- bool mIsDead; // *** Not got/saved from DB atm ***\r
-\r
- // Only one body effect supported atm. Should be extended later to multiple effects\r
- u8 mBodyEffect; // *** Not got/saved from DB atm ***\r
- u8 mBodyEffectDensity; // *** Not got/saved from DB atm ***\r
-\r
- u8 mSpeedOverride; // a hack to control move speed. Not saved in DB\r
-\r
- u32 mDirectCharID; // for Direct Chat // *** Not got/saved from DB atm ***\r
- PBuddyList* mBuddyList; // For Buddy list Chat\r
- u32 mActiveChatChannels; // Active chat channels flags // *** Not got/saved from DB atm ***\r
-\r
- PGenrepList* mGenrepList; // Character's GR list\r
-\r
- u8 mQuickBeltActiveSlot; // QB SlotID of item "in hand", or INV_WORN_QB_HAND or INV_WORN_QB_NONE\r
-\r
- u16 mLookingAt; // Zone charID of currently targeted player\r
- std::time_t mLookAtTimestamp; // Lifetimer of lookat var\r
- u32 mLastUsedWorldObjectId; // Last world object clicked on\r
-\r
- u8 mClanLevel; // 1-15\r
- u16 mClanID;\r
-\r
- bool mIsOnline;\r
- bool mDirtyFlag;\r
-\r
- bool mShunned;\r
- bool mJailed;\r
-\r
- u32 mDialogNPC; // NPCID the player talks to\r
- u16 mCurrentDialogNode; // Node in .lua file we're at right now\r
-\r
- class PInventory mInventory;\r
-\r
- protected :\r
- friend class PChars;\r
- inline void SetID( u32 ID ) { mID = ID; }\r
- inline void SetAccount( u32 Account ) { mAccount = Account; }\r
- inline void SetCharSlot( u8 Slot ) { if ( Slot < 4 ) mSlot = Slot;} // TODO: set max slot according to server config\r
- inline void SetName( const std::string &Name ) { mName = Name; }\r
- inline void SetGender( u32 Gender ) { mGender = Gender; }\r
- void SetProfession( u32 Profession );\r
- //inline void SetClass(u32 nClass) { mClass = nClass; } // mClass is defined by setting Profession\r
- //inline void SetType(u32 Type) { mType = Type; } // Removed. Type is computed from Gender & Profession (??? is it not Gender + Class ???)\r
- inline void SetFaction( u32 Faction ) { mFaction = Faction; }\r
- //inline void SetModel(u32 Model) { mModel = Model; } // Inhibited for the moment. Base model is deduced from from Gender & Class (Profession)\r
- void SetRealLook( u32 nHead, u32 nTorso, u32 nLegs );\r
- void SetBaseSkills();\r
- void SetBaseSubskills( u8 NZSNb, const char* NonZeroSubskills );\r
- void SetBaseInventory();\r
-\r
- bool SQLCreate();\r
-\r
- public :\r
- PChar();\r
- ~PChar();\r
-\r
- static bool SetCharnameRegexFilter( const char* RegexStr );\r
- static bool IsCharnameWellFormed( const char *Username );\r
-\r
- PSkillHandler *Skill;\r
- PCharCoordinates Coords;\r
-\r
- void SetCurrentLook( u32 nSkin, u32 nHead = 0, u32 nTorso = 0, u32 nLegs = 0 );\r
- void SetCurrentLookFromCharType( u32 nType );\r
- void ResetCurrentLook();\r
-\r
- void SetCurrentBodyColor( u8 nHeadColor, u8 nTorsoColor, u8 nLegsColor, u8 nHeadDarkness = 0, u8 nTorsoDarkness = 0, u8 nLegsDarkness = 0 );\r
- inline void SetBodyEffect( u8 nEffect, u8 nDensity = 0 ) { mBodyEffect = nEffect; mBodyEffectDensity = nDensity; }\r
- inline void SetSpeedOverride( u8 nSpeed = 255 ) { mSpeedOverride = nSpeed; }\r
-\r
- void SetLookingAt( u16 nLocalCharID );\r
- u16 GetLookingAt( u16 nMaxDelaySec = 1 );\r
- inline void SetLastUsedObject ( u32 nRawItemId ) { mLastUsedWorldObjectId = nRawItemId; }\r
- inline u32 GetLastUsedObject () const { return mLastUsedWorldObjectId; }\r
-\r
- inline PInventory* GetInventory() { return &mInventory; }\r
- inline u32 GetID() const { return mID; }\r
- inline u32 GetAccount() const { return mAccount; }\r
- inline const std::string &GetName() const { return mName; }\r
- inline u32 GetGender() const { return mGender; }\r
- inline u32 GetClass() const { return mClass; }\r
- inline u32 GetType() const { return 2 * mClass + mGender; }\r
- u32 GetSkinFromCharType( u32 nType );\r
- void GetRealLook( u32 &nSkin, u32 &nHead, u32 &nTorso, u32 &nLegs );\r
- void GetCurrentLook( u32 &nSkin, u32 &nHead, u32 &nTorso, u32 &nLegs );\r
- inline void GetBodyEffect( u8 &nEffect, u8 &nDensity ) { nEffect = mBodyEffect; nDensity = mBodyEffectDensity; }\r
-\r
- inline u8 GetQuickBeltActiveSlot() { return mQuickBeltActiveSlot; }\r
- bool SetQuickBeltActiveSlot( u8 nSlotID );\r
-\r
- void GetCurrentBodyColor( u8 &nHeadColor, u8 &nTorsoColor, u8 &nLegsColor, u8 &nHeadDarkness, u8 &nTorsoDarkness, u8 &nLegsDarkness );\r
- inline u8 GetSpeedOverride() { return mSpeedOverride; }\r
- inline u32 GetBaseModel();\r
- inline u32 GetProfession() const { return mProfession; }\r
- inline u16 GetMaxHealth() { return mHealth; }\r
- inline u16 GetMaxMana() { return mMana; }\r
- inline u16 GetMaxStamina() { return mStamina; }\r
- inline u16 GetHealth() { return mHealth; }\r
- inline u16 GetMana() { return mMana; }\r
- inline u16 GetStamina() { return mStamina; }\r
- inline u32 GetFaction() const { return mFaction; }\r
- inline u32 GetLocation() const { return mLocation; }\r
-\r
- inline u32 GetCash() const { return mCash; }\r
- u32 SetCash( u32 nCash ); // Does return the new cashvalue, NO udpmessage is sent out!!\r
- u32 AddCash( u32 nAmount );\r
- u32 TakeCash( u32 nAmount );\r
-\r
- inline u32 GetBaseApartment() const { return mPrimaryApt; }\r
-\r
- inline void SetJail( bool val ) { mJailed = val; };\r
- inline void SetShun( bool val ) { mShunned = val; };\r
-\r
- inline bool IsJailed() { return mJailed; };\r
- inline bool IsShunned() { return mShunned; };\r
-\r
- inline void SetDialogNPC( u32 nNPC ) { mDialogNPC = nNPC; };\r
- inline u32 GetDialogNPC() const { return mDialogNPC; };\r
-\r
- inline void SetDialogNode( u16 nNode ) { mCurrentDialogNode = nNode; };\r
- inline u16 GetDialogNode() const { return mCurrentDialogNode; };\r
-\r
- inline u8 GetClanLevel() const { return mClanLevel; };\r
- inline u16 GetClan() const { return mClanID; };\r
- void LoadClanLevel();\r
-\r
- inline s8 GetSoullight() const { return mSoullight; }\r
- u8 GetMainRank();\r
- u8 GetCombatRank();\r
- inline u8 GetSynaptic() const { return mSynaptic; }\r
- inline bool IsDead() const { return mIsDead; }\r
-\r
- inline bool SetDirectChat( u32 nBuddyCharID ) { mDirectCharID = nBuddyCharID; return true; }\r
- inline u32 GetDirectChat() { return mDirectCharID; }\r
- inline void SetActiveChannels( u32 nChannels ) { mActiveChatChannels = nChannels; }\r
- inline u32 GetActiveChannels() { return mActiveChatChannels; }\r
-\r
- inline bool AddBuddy( u32 nBuddyCharID ) { return mBuddyList->AddChar( nBuddyCharID ); }\r
- inline bool RemoveBuddy( u32 nBuddyCharID ) { return mBuddyList->RemoveChar( nBuddyCharID ); }\r
- inline u16 GetBuddyListDataSize() { return mBuddyList->GetListDataSize(); }\r
- inline const void* GetBuddyListData() { return mBuddyList->GetListData(); }\r
- inline u8 GetBuddyCount() { return mBuddyList->Count(); }\r
- inline bool IsBuddy( u32 CharID ) { return mBuddyList->IsInBuddy( CharID ); };\r
-\r
- inline bool AddGenrep( u16 nWorldID, u16 nStationID ) { return mGenrepList->AddGenrep( nWorldID, nStationID ); }\r
- inline u16 GetGenrepListDataSize() { return mGenrepList->GetListDataSize(); }\r
- inline const void* GetGenrepListData() { return mGenrepList->GetListData(); }\r
- inline u8 GetGenrepCount() { return mGenrepList->Count(); }\r
-\r
- inline bool IsDirty() const { return mDirtyFlag; }\r
- inline bool IsAnyDirty() const { return mDirtyFlag || mInventory.IsDirty(); }\r
- inline bool IsOnline() { return mIsOnline; }\r
- void SetOnlineStatus( bool IsOnline );\r
-\r
- bool CreateNewChar( u32 Account, const std::string &Name, u32 Gender, u32 Profession, u32 Faction,\r
- u32 Head, u32 Torso, u32 Legs, u8 NZSNb, const char *NonZeroSubskills, u32 Slot );\r
- bool SQLLoad( int CharID );\r
- bool SQLSave();\r
- inline bool SQLSaveFull() { return SQLSave() && mInventory.SQLSave(); }\r
- bool SQLDelete(); // not implemented yet\r
-\r
- inline void SetLocation( u32 Location ) { mLocation = Location; }\r
- inline void SetDirtyFlag( bool Dirty = true ) { mDirtyFlag = Dirty; }\r
-\r
- // temp until char on-demand load/unload\r
- inline void SetLocationLeased( bool nState = true ) { mLocationLeased = nState; }\r
- inline bool GetLocationLeased() { return mLocationLeased; }\r
-\r
- PSeatType GetSeatInUse( u32* nObjectId = NULL, u8* nSeatId = NULL );\r
- void SetSeatInUse( PSeatType nSeatType, u32 nObjectId = 0, u8 nSeatId = 0 );\r
-\r
- PVhcAccessRequestList* GetVhcAccessRequestList();\r
-\r
- inline PContainer* GetContainerInExclusiveUse() { return mContainerInExclusiveUse; }\r
- inline void SetContainerInExclusiveUse( PContainer* nContainer ) { mContainerInExclusiveUse = nContainer; }\r
-};\r
-\r
-struct PCharProfile\r
-{\r
- u32 CharID;\r
- u16 Type;\r
- u16 Color0;\r
- u16 Unknown1;\r
- u8 Head;\r
- u8 Torso;\r
- u8 Legs;\r
- u32 Location;\r
- u8 NameLen;\r
- u8 Unknown3;\r
- u8 Unknown4;\r
- u8 Unknown5;\r
- u8 Unknown6;\r
- u8 Unknown7;\r
- u8 Unknown8;\r
- u8 Unknown9;\r
- u8 Unknown10;\r
- u8 Unknown11;\r
- u8 Unknown12;\r
- std::string Name;\r
- bool in_use;\r
-};\r
-\r
-class PChars\r
-{\r
- private :\r
- typedef std::map<u32, PChar*> CharMap;\r
- CharMap mChars;\r
- u32 mLastID;\r
-\r
- std::time_t mAutoSavePeriod;\r
- std::time_t mLastSave;\r
-\r
- public :\r
- PChars();\r
- ~PChars();\r
-\r
- bool LoadChar( u32 CharID );\r
- bool AddChar( PChar* nChar );\r
- PChar* RemoveChar( u32 CharID );\r
-\r
- PChar* GetChar( u32 CharID ) const;\r
- PChar* GetChar( const std::string &Name ) const;\r
- bool CharExist( const std::string &Name ) const;\r
-\r
- void SQLSave();\r
- void Update();\r
-\r
- int GetCharProfiles( const u32 AccountID, PCharProfile* CharSlotsArray, const u8 ArraySize ); // return effective entries nb\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- chat.h\r
-\r
- Authors:\r
- - Namikon\r
- - bakkdoor\r
-\r
- MODIFIED: 30 Nov 2005 Namikon/Akiko\r
- REASON: - initial release by Namikon\r
-\r
- MODIFIED: 11 Dec 2005 Namikon\r
- REASON: - Added function SendDChat(Client, <text>, <nick>) to send a Direct to player\r
- - Added Channel IDs for GameMaster (/gm) and Administrator (/admin) chat\r
- - Added channel const's for sending chat packets\r
- - Added function SendChat(Client, <channel>, <text>, <nick>) to send chat messages\r
- For <channel>, use one of the u8 constants listet below\r
-\r
- MODIFIED: 17 Dec 2005 bakkdoor\r
- REASON: - introduced new structure for chatsystem\r
- - -> PChat class\r
-*/\r
-\r
-#ifndef CHAT_H\r
-#define CHAT_H\r
-#define LOCALCHAT_MAXDISTANCE 1433\r
-\r
-class PChat\r
-{\r
- private:\r
-\r
- public:\r
- PChat();\r
- ~PChat();\r
-\r
- // INCOMING CHAT\r
- bool HandleGameChat(PClient *Client, const u8 *Packet);\r
- bool cmpr(const u8 *Array1, const u8 *Array2);\r
-\r
- // this function is called by the other more specific functions and simply sends the data to the receiver-client\r
- bool send(PClient* receiver, const u8* Channel, const char* AuthorNickName, const char* text, bool debugOut=false);\r
-\r
- // this is for debugging and sends the current connected playerlist to the receiver-client\r
- void sendConnectedList(PClient* receiver, bool debugOut=false);\r
-\r
- // specific channel functions:\r
- void sendBuddy(PClient* author, const char* text, bool debugOut=false);\r
- void sendLocal(PClient* author, const char* text, bool debugOut=false);\r
- void sendClan(PClient* author, const char* text, bool debugOut=false);\r
- void sendTeam(PClient* author, const char* text, bool debugOut=false);\r
- void sendDirect(PClient* author, PClient* receiver, const char* text, bool debugOut=false);\r
- void sendZone(PClient* author, const char* text, bool debugOut=false);\r
- void sendFrak(PClient* author, const char* text, bool debugOut=false);\r
- void sendTradeCS(PClient* author, const char* text, bool debugOut=false);\r
- void sendTradeMB(PClient* author, const char* text, bool debugOut=false);\r
- void sendTradeNC(PClient* author, const char* text, bool debugOut=false);\r
- void sendTradeTH(PClient* author, const char* text, bool debugOut=false);\r
- void sendTradeWL(PClient* author, const char* text, bool debugOut=false);\r
- void sendOOC(PClient* author, const char* text, bool debugOut=false);\r
- void sendHelp(PClient* author, const char* text, bool debugOut=false);\r
- void sendClanSearch(PClient* author, const char* text, bool debugOut=false);\r
- void sendServicesCS(PClient* author, const char* text, bool debugOut=false);\r
- void sendServicesMB(PClient* author, const char* text, bool debugOut=false);\r
- void sendServicesNC(PClient* author, const char* text, bool debugOut=false);\r
- void sendServicesTH(PClient* author, const char* text, bool debugOut=false);\r
- void sendServicesWL(PClient* author, const char* text, bool debugOut=false);\r
- void sendTeam10(PClient* author, const char* text, bool debugOut=false);\r
- void sendTeam30(PClient* author, const char* text, bool debugOut=false);\r
- void sendTeam50(PClient* author, const char* text, bool debugOut=false);\r
- void sendTeam70(PClient* author, const char* text, bool debugOut=false);\r
- void sendAdmin(PClient* author, const char* text, bool debugOut=false);\r
- void sendGM(PClient* author, const char* text, bool debugOut=false);\r
- void sendGMAdmin(PClient* author, const char* text, bool debugOut=false);\r
-\r
- void sendBroadcast(const char* text, bool debugOut=false);\r
- void sendOOCBroadcast(const char* text, bool debugOut=false);\r
- void sendPlayerDirect(PClient* author, const char* text, u32 destination, bool debugOut=false);\r
- void sendLocalchat(PClient* receiver, PClient* author, const char* text, bool debugOut=false);\r
- bool chanEnabled(PClient* Client, u32 channel);\r
-\r
-};\r
-\r
-/** A WARNING: DO >N O T< (!!!) CHANGE >ANY< OF THE FOLLOWING VARIABLES UNLESS YOU KNOW EXACT WHAT YOU'RE DOING! **/\r
-/** You can easily mess up the entire chat subsystem. If you're unsure, ask Namikon first! **/\r
-/*\r
-####################\r
- CHANNEL-CODES:\r
- (INCOMING)\r
-####################\r
-*/\r
-static const u32 CHANNEL_BUDDY = 0x00000000; // Buddy\r
-static const u32 CHANNEL_CLAN = 0x00000002; // Clan\r
-static const u32 CHANNEL_TEAM = 0x00000003; // Team\r
-static const u32 CHANNEL_DIRECT = 0xFFFFFFFF; // Direct UNKNOWN YET\r
-static const u32 CHANNEL_CUS_ZONE = 0x00000105; // Custom -> Zone\r
-static const u32 CHANNEL_CUS_FRAKTION = 0x00000205; // Custom -> Fraktion\r
-static const u32 CHANNEL_CUS_TRADE_CANYON = 0x00002005; // Custom -> Trade Canyon\r
-static const u32 CHANNEL_CUS_TRADE_MB = 0x00000805; // Custom -> Trade MB\r
-static const u32 CHANNEL_CUS_TRADE_NC = 0x00000405; // Custom -> Trade NC\r
-static const u32 CHANNEL_CUS_TRADE_TH = 0x00001005; // Custom -> Trade TH\r
-static const u32 CHANNEL_CUS_TRADE_WASTE = 0x00004005; // Custom -> Trade Wastelands\r
-static const u32 CHANNEL_CUS_OOC = 0x04000005; // Custom -> OOC\r
-static const u32 CHANNEL_CUS_PLAYERHELP = 0x02000005; // Custom -> Player 2 Player help\r
-static const u32 CHANNEL_CUS_CLANSEARCH = 0x01000005; // Custom -> Searching Clan\r
-static const u32 CHANNEL_CUS_SERVICES_CANYON = 0x00040005; // Custom -> Runner Services Canyon\r
-static const u32 CHANNEL_CUS_SERVICES_MB = 0x00010005; // Custom -> Runner Services MB\r
-static const u32 CHANNEL_CUS_SERVICES_NC = 0x00008005; // Custom -> Runner Services NC\r
-static const u32 CHANNEL_CUS_SERVICES_TH = 0x00020005; // Custom -> Runner Services TH\r
-static const u32 CHANNEL_CUS_SERVICES_WASTE = 0x00080005; // Custom -> Runner Services Wastelands\r
-static const u32 CHANNEL_CUS_TEAM_10 = 0x00100005; // Custom -> Searching Team ~10\r
-static const u32 CHANNEL_CUS_TEAM_30 = 0x00200005; // Custom -> Searching Team ~30\r
-static const u32 CHANNEL_CUS_TEAM_50 = 0x00400005; // Custom -> Searching Team ~50\r
-static const u32 CHANNEL_CUS_TEAM_70 = 0x00800005; // Custom -> Searching Team ~70\r
-static const u32 CHANNEL_ADMIN = 0x000000FF; // Admin chat\r
-static const u32 CHANNEL_GMADMIN = 0x000000FE; // Admin chat\r
-static const u32 CHANNEL_GMCHAT = 0x000000FD; // GameMaster chat\r
-/*\r
-####################\r
- CHANNEL-CODES:\r
- (OUTGOING)\r
-####################\r
-*/\r
-static const u8 CHAT_BUDDY[] = {0x00, 0x10};\r
-static const u8 CHAT_LOCAL[] = {0x01, 0x10};\r
-static const u8 CHAT_CLAN[] = {0x02, 0x10};\r
-static const u8 CHAT_TEAM[] = {0x03, 0x10};\r
-static const u8 CHAT_DIRECT[] = {0x04, 0x10};\r
-static const u8 CHAT_ZONE[] = {0x05, 0x00};\r
-static const u8 CHAT_FRAK[] = {0x05, 0x01};\r
-static const u8 CHAT_TRADECS[] = {0x05, 0x05};\r
-static const u8 CHAT_TRADEMB[] = {0x05, 0x03};\r
-static const u8 CHAT_TRADENC[] = {0x05, 0x02};\r
-static const u8 CHAT_TRADETH[] = {0x05, 0x04};\r
-static const u8 CHAT_TRADEWL[] = {0x05, 0x06};\r
-static const u8 CHAT_OOC[] = {0x05, 0x12};\r
-static const u8 CHAT_HELP[] = {0x05, 0x11};\r
-static const u8 CHAT_CLANSEARCH[] = {0x05, 0x10};\r
-static const u8 CHAT_SERVICECS[] = {0x05, 0x0A};\r
-static const u8 CHAT_SERVICESMB[] = {0x05, 0x08};\r
-static const u8 CHAT_SERVICESNC[] = {0x05, 0x07};\r
-static const u8 CHAT_SERVICESTH[] = {0x05, 0x09};\r
-static const u8 CHAT_SERVICESWL[] = {0x05, 0x0B};\r
-static const u8 CHAT_TEAM10[] = {0x05, 0x0C};\r
-static const u8 CHAT_TEAM30[] = {0x05, 0x0D};\r
-static const u8 CHAT_TEAM50[] = {0x05, 0x0E};\r
-static const u8 CHAT_TEAM70[] = {0x05, 0x0F};\r
-static const u8 CHAT_ADMIN[] = {0xFF, 0x10};\r
-static const u8 CHAT_GMADMIN[] = {0xFE, 0x10};\r
-static const u8 CHAT_GM[] = {0xFD, 0x10};\r
-\r
-/*\r
-####################\r
- CHANNEL-CODES:\r
-(EN/DISABLE-ABLE CHANNELS)\r
-####################\r
-*/\r
-static const u32 C_ZONE = 1;\r
-static const u32 C_FRAK = 2;\r
-static const u32 C_TRADENC = 4;\r
-static const u32 C_TRADEMB = 8;\r
-static const u32 C_TRADETH = 16;\r
-static const u32 C_TRADECS = 32;\r
-static const u32 C_TRADEWL = 64;\r
-static const u32 C_SERVICENC = 128;\r
-static const u32 C_SERVICEMB = 256;\r
-static const u32 C_SERVICETH = 512;\r
-static const u32 C_SERVICECS = 1024;\r
-static const u32 C_SERVICEWL = 2048;\r
-static const u32 C_TEAM10 = 4096;\r
-static const u32 C_TEAM30 = 8192;\r
-static const u32 C_TEAM50 = 16384;\r
-static const u32 C_TEAM70 = 32768;\r
-static const u32 C_CLANSEARCH = 65536;\r
-static const u32 C_HELP = 131072;\r
-static const u32 C_OOC = 262144;\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- client.h\r
-\r
- Authors:\r
- - v00d00\r
- - Akiko\r
- - Namikon\r
- - bakkdoor\r
-\r
- MODIFIED: 30 Nov 2005 Akiko\r
- REASON: - added GPL\r
- - added stuff from Namikon\r
- MODIFIED: 13 Dec 2005 bakkdoor\r
- REASON: - added multiuser chat\r
- MODIFIED: 27 Jul 2006 Hammag\r
- REASON: - added mTransactionID member\r
- - re-added IncreaseUDP_ID() // but I don't understand well what SetUDP_ID() does ...\r
- MODIFIED: 05 Aug 2006 Hammag\r
- REASON: - changed TMP_UDP_PORT/SetTMPUDPPort()/GetTMPUDPPort() to mRemotePort/SetRemoteUDPPort()/GetRemoteUDPPort()\r
- which corresponds to the real purpose of these members\r
- - added GetID() as an alias os GetIndex() for better coherency with other classes\r
- MODIFIED: 09 Oct 2006 Hammag\r
- REASON: - added GetDebugMode() and SetDebugMode() methods\r
-\r
-\r
- TODO: - check that SetUDP_ID, and the mSessionID(UDP_ID_HIGH) real use,\r
- and if UDP_ID and mSessionID must be synced (like in NeoX) or not\r
-\r
-*/\r
-\r
-#ifndef CLIENT_H\r
-#define CLIENT_H\r
-\r
-enum PClientConnection\r
-{\r
- PCC_NONE = 0,\r
- PCC_GAME = 1\r
-};\r
-\r
-// AccountLevel handling is part of accounts.cpp\r
-/*\r
-enum PClientLevel\r
-{\r
- PCL_BANNED = -1,\r
- PCL_UNREGPLAYER = 0,\r
- PCL_REGPLAYER = 1,\r
- PCL_VOLUNTEER = 30,\r
- PCL_GM = 50,\r
- PCL_ADMIN = 100\r
-};\r
-*/\r
-#define DEBUG_MODES 3\r
-enum PDebugMode\r
-{\r
- DBG_LOCATION = 0,\r
- DBG_ITEMID = 1,\r
- DBG_SUBWAY = 2,\r
- DBG_ALL = DEBUG_MODES // must always be last, with DEBUG_MODES updated as needed\r
-};\r
-\r
-\r
-class PClient\r
-{\r
- private :\r
- ConnectionTCP* m_TCPConnection;\r
- ConnectionUDP* m_UDPConnection;\r
-\r
- u32 mAccountID;\r
- int mAccountLevel;\r
- u32 mIndex;\r
- u32 mCharID;\r
-\r
-// u16 mUDP_ID;\r
-// u16 mSessionID;\r
-// u16 mTransactionID;\r
-\r
- // AccountLevel handling is part of accounts.cpp\r
- //PClientLevel mLevel;\r
- int mConnection;\r
- int mRemotePort;\r
-\r
- bool mDebugMode[DEBUG_MODES];\r
- // new multiuser-chat implementation //\r
- int m_ZoneID;\r
- //int[4] m_IP;\r
-\r
- //*******\r
- bool mActorRemoveMode;\r
- //*******\r
- bool mAwaitingWarpto;\r
- u16 mTargetX;\r
- u16 mTargetY;\r
- u16 mTargetZ;\r
- //*******\r
- bool mAcceptNPCUpdates;\r
- bool mZoning;\r
- bool mVhcZoning;\r
- \r
-\r
- protected :\r
- public :\r
- PClient( int Index );\r
- ~PClient();\r
-\r
- inline bool GetDebugMode( PDebugMode nDebugID ) { return mDebugMode[nDebugID]; }\r
- void SetDebugMode( PDebugMode nDebugID, bool nVal = true );\r
-\r
- inline bool IsAcceptingNPCUpdates() { return mAcceptNPCUpdates; }\r
- inline void SetAcceptNPCUpdates( bool nVal ) { mAcceptNPCUpdates = nVal; }\r
- inline bool IsZoning() { return mZoning; }\r
- inline void SetZoning( bool nVal = true ) { mZoning = nVal; if ( !nVal ) mVhcZoning = false; }\r
- inline bool IsVhcZoning() { return mVhcZoning; }\r
- inline void SetVhcZoning( bool nVal = true ) { mVhcZoning = nVal; }\r
-\r
- inline u32 GetIndex() const { return mIndex; } // better use GetID()\r
- inline u32 GetID() const { return mIndex; } // for better coherency with other classes\r
- inline u32 GetLocalID() const { return mIndex + 1; }\r
- inline u32 GetCharID() const { return mCharID; }\r
- PChar* GetChar() const;\r
- bool ChangeCharLocation( u32 nLocation, bool DoForce = false );\r
-\r
- inline int GetRemoteUDPPort() const { return mRemotePort; } // Temp solution\r
-\r
- inline bool IsInRemoveActorMode() { return mActorRemoveMode; }\r
- inline void SetRemoveActorMode( bool nNewValue ) { mActorRemoveMode = nNewValue; }\r
-\r
- inline void SetRemoteUDPPort( int port ) { mRemotePort = port; } // Temp solution\r
- inline void SetCharID( int id ) { mCharID = id; }//NEW added\r
-\r
- /*\r
- inline u16 GetUDP_ID() const { return mUDP_ID; }\r
- inline u16 GetSessionID() const { return SESSION_UDP_OFFSET + mUDP_ID ; }\r
- inline u16 GetTransactionID() {return mTransactionID; }\r
- void SetUDP_ID(int id);\r
- inline void IncreaseUDP_ID() { SetUDP_ID(mUDP_ID + 1); }\r
- inline void ResetTransactionID() { mTransactionID = 10170; }\r
-\r
- inline void IncreaseTransactionID(u8 nInc = 1) { mTransactionID += nInc; }\r
- */\r
-\r
- // All outgoing ID's and stuff is now part of the ConnectionUDP class itself!\r
- // (which is not so good.... comment from Hammag)\r
- // However, we still have full access to it through these functions\r
- u16 GetUDP_ID();\r
- void SetUDP_ID( int id );\r
- void IncreaseUDP_ID();\r
-\r
- u16 GetSessionID();\r
-\r
- u16 GetTransactionID();\r
- void ResetTransactionID();\r
- void IncreaseTransactionID( u8 nInc = 1 );\r
-\r
- void FillInUDP_ID( PMessage* nMessage );\r
-\r
-// ************************************************************************ //\r
- // AccountLevel handling is part of accounts.cpp\r
- //inline PClientLevel GetLevel() const { return mLevel; }\r
-\r
- inline void setTCPConnection( ConnectionTCP* conn ) { m_TCPConnection = conn; m_UDPConnection = 0; mConnection = PCC_GAME; }\r
- inline void setUDPConnection( ConnectionUDP* conn ) { m_UDPConnection = conn; }\r
-\r
- inline ConnectionTCP* getTCPConn() { return m_TCPConnection; }\r
- inline ConnectionUDP* getUDPConn() { return m_UDPConnection; }\r
-\r
- inline void SendTCPMessage( PMessage* nMessage ) { if ( m_TCPConnection ) { m_TCPConnection->SendMessage( nMessage ); } else { delete nMessage; } }\r
- void FragmentAndSendUDPMessage( PMessage* nMessage, u8 nType );\r
- inline void SendUDPMessage( PMessage* nMessage, bool nVIP = false ) { if ( m_UDPConnection ) { m_UDPConnection->SendMessage( nMessage, nVIP ); } else { delete nMessage; } }\r
-\r
- inline int GetConnection() const { return mConnection; }\r
- inline const char *GetAddress() const { return m_TCPConnection->getRemoteAddress(); }\r
- inline u32 GetAccountID() const { return mAccountID; }\r
- inline int GetAccountLevel() const { return mAccountLevel; }\r
-\r
- void GameDisconnect();\r
-\r
- void RefreshAccountInfo( PAccount* Account );\r
- inline void LoggedIn( PAccount* Account ) { RefreshAccountInfo( Account ); }\r
- void Update();\r
-\r
- // new multiuser-chat implementation //\r
- inline int getZoneID() const { return m_ZoneID; } // example: canyon 650 (for local-channel...every client with same AreaID get the chatmsg)\r
- //inline int* getIP() const { return (int*) m_IP; }\r
-\r
- inline void SetAwaitingWarpto( bool yesno, u16 NewX, u16 NewY, u16 NewZ )\r
- {\r
- mAwaitingWarpto = yesno;\r
- mTargetX = NewX;\r
- mTargetY = NewY;\r
- mTargetZ = NewZ;\r
- }\r
- bool GetCharAwaitingWarpto( u16* PosX = NULL, u16* PosY = NULL, u16* PosZ = NULL );\r
-\r
- // Char broadcasted effects\r
- void InitWarpCircle();\r
- void InitCharVanish();\r
-\r
- // used for dynamic ingame testing\r
- u8 testval8;\r
- u16 testval16;\r
- u32 testval32;\r
-};\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- clientmanager.h\r
-\r
- Authors:\r
- - bakkdoor\r
-\r
- MODIFIED: 13 Dec 2005 bakkdoor\r
- REASON: - introduced\r
- MODIFIED: 29 Jul 2006 Hammag\r
- REASON: - added UDP broadcast fonction\r
- - added "zone players say Hello" fonction\r
- - changed type ClientMap to PClientMap, changed members name prefix m_ to m\r
-\r
- MODIFIED: 12 Aug 2006 Hammag\r
- REASON: - duplicated UDPBroadcast() in two prototypes\r
-\r
-*/\r
-\r
-#ifndef CLIENTMANAGER_H\r
-#define CLIENTMANAGER_H\r
-\r
-typedef std::map<u32, PClient*> PClientMap;\r
-\r
-class PClientManager\r
-{\r
- private:\r
- //int mLastID;\r
- PClientMap mClientList;\r
-\r
- public:\r
- PClientManager();\r
- ~PClientManager();\r
-\r
- PClientMap::iterator getClientListBegin() { return mClientList.begin(); }\r
- PClientMap::iterator getClientListEnd() { return mClientList.end(); }\r
-\r
- bool addClientToList( PClient* newClient );\r
- //void deleteClientFromListByID(int id);\r
- void deleteClientFromList( u32 id );\r
- //bool deleteClientFromList(PClient* delClient); // maybe no use for this...\r
- PClient* getClientByID( u32 u32 ) const; // returns pointer to a client for further use\r
- PClient* getClientByChar( u32 CharID ) const;\r
- PClient* getClientByChar( const std::string &Name ) const;\r
- // int getClientID(PClient* _client); do _client->GetLocalID()\r
- bool IsWorldInUse( u32 nWorldID ) const; // Temp until world content fully managed by world\r
- PClient* GetClientByCharLocalId( u32 rawObjectId, u32 nWorldID ) const; // Temp (called by world) until world content fuly managed by world\r
-\r
- // each function return the number of messages sent.\r
- int UDPBroadcast( PMessage* nMessage, u32 nZoneID, u16 nX = 0, u16 nY = 0, u16 nZ = 0, u16 nMaxDist = 0, u32 nSkipCharId = 0, bool nNPCPing = false );\r
- int UDPBroadcast( PMessage* nMessage, PClient* nClient, u16 nMaxDist = 0, bool nSkipSource = false, bool nNPCPing = false );\r
- int SendUDPZoneWelcomeToClient( PClient* nClient );\r
-\r
-};\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- container.h - base classe for containers\r
- \r
-\r
- MODIFIED: 28 Jul 2008 Hammag\r
- REASON: - creation\r
-\r
-*/\r
-\r
-#ifndef CONTAINER_H\r
-#define CONTAINER_H\r
-\r
-#define CONTAINER_MAX_SIZE 254\r
-\r
-class PItem;\r
-\r
-class PContainerEntry\r
-{\r
- friend class PContainer;\r
- friend class PContainer2D;\r
- friend class PMsgBuilder;\r
- \r
- friend class PContainer2DWorkaround;\r
- \r
- private:\r
- enum {\r
- i_invid = 0,\r
- i_charid,\r
- i_invloc,\r
- i_x,\r
- i_y,\r
- i_itemid,\r
- //i_type,\r
- i_flag,\r
- i_qty,\r
- i_sqty,\r
- i_curdur,\r
- i_dmg,\r
- i_freq,\r
- i_hand,\r
- i_rng,\r
- i_maxdur,\r
- i_slots,\r
- i_slt1,\r
- i_slt2,\r
- i_slt3,\r
- i_slt4,\r
- i_slt5,\r
- i_atype,\r
- i_conatin\r
- };\r
- \r
- PItem* mItem;\r
- u8 mPosX;\r
- u8 mPosY;\r
- u32 mInvID;\r
- bool mDirtyFlag;\r
-\r
- PContainerEntry(PItem* nItem, u8 X, u8 Y, u32 nInvID = 0, bool SetDirty = true);\r
- PContainerEntry(MYSQL_ROW row);\r
- \r
- bool SQLSave(u32 CharID, u32 InvLoc);\r
- bool SQLDelete();\r
- \r
- inline void Set2DPos(u8 nPosX, u8 nPosY) { mDirtyFlag = mDirtyFlag || (mPosX != nPosX) || (mPosY != nPosY) ; mPosX = nPosX; mPosY = nPosY; }\r
- \r
- public:\r
- ~PContainerEntry();\r
- \r
- inline void Get2DPos(u8* oPosX, u8* oPosY) { *oPosX = mPosX; *oPosY = mPosY; }\r
-};\r
-\r
-\r
-\r
-class PContainer // Holes allowed, no autofind free slots\r
-{ \r
- protected:\r
- u8 mMaxSlots;\r
- std::vector< PContainerEntry* >* mContContent;\r
- u32 mCharID;\r
- u32 mInvLoc;\r
- u32 mExclusiveUseCharID;\r
- bool mDirtyFlag;\r
- \r
- inline bool IsSlotAllowed(u8 nSlotId) { return ((nSlotId < CONTAINER_MAX_SIZE) && (!mMaxSlots || (nSlotId < mMaxSlots))); }\r
- virtual bool AddEntry(PContainerEntry* NewEntry, u8 nSlotId = 0);\r
- virtual PContainerEntry* RemoveEntry(u8 nSlotId);\r
- virtual bool GetFreeSlot(u8* nSlotId);\r
- void Compact(u8 startSlotId = 0);\r
- \r
- public:\r
- PContainer(u8 nMaxSlots = 0);\r
- virtual ~PContainer();\r
-\r
- inline void SetInfo(u32 CharID, u32 InvLoc) { mCharID = CharID; mInvLoc = InvLoc; }\r
- inline u32 GetOwnerId() { return mCharID; }\r
- \r
- inline bool IsDirty() { return mDirtyFlag; }\r
- inline void SetDirty() { mDirtyFlag = true; }\r
- \r
- bool StartUse(u32 nExclusiveUseCharID = 0);\r
- virtual bool EndUse(u32 nExclusiveUseCharID = 0);\r
-\r
- bool SQLLoad();\r
- bool SQLSave();\r
- \r
- bool IsSlotFree(u8 nSlotId);\r
- virtual bool AddItem(PItem* NewItem, u32 nInvID = 0, u8 nPosX = 0, u8 nPosY = 0, bool SetDirty = true);\r
- \r
- virtual bool MoveItem(u8 srcSlotId, u8 nCount, u8 dstSlotId);\r
- bool MoveItem(u8 srcSlotId, u8 nCount, PContainer* dstContainer, u8 dstSlotId = 0, u8 nPosX = 0, u8 nPosY = 0);\r
- virtual void SetEntryPosXY(PContainerEntry* nEntry, u8 nSlotId, u8 nPosX = 0, u8 nPosY = 0);\r
-\r
- virtual u8 RandomFill(u8 nItemCount = 0, int nItemContainerDefIndex = -1);\r
- \r
- PContainerEntry* GetEntry(u8 nSlotId);\r
- std::vector< PContainerEntry* >* GetEntries();\r
- PItem* GetItem(u8 nSlotId);\r
- \r
- virtual void Dump();\r
-};\r
-\r
-\r
-class PContainerWithHoles : public PContainer // Holes allowed, no autofind free slots\r
-{ \r
- public:\r
- PContainerWithHoles(u8 nMaxSlots = 0) : PContainer(nMaxSlots){ nMaxSlots = nMaxSlots; }\r
- virtual ~PContainerWithHoles() {}\r
-};\r
-\r
-\r
-class PContainerAutoCompact : public PContainer // No holes allowed, automatic add to end slot (no control on insertion slot)\r
-{\r
- protected:\r
- virtual PContainerEntry* RemoveEntry(u8 nSlotId);\r
- virtual bool GetFreeSlot(u8* nSlotId);\r
- \r
- public:\r
- PContainerAutoCompact(u8 nMaxSlots = 0) : PContainer(nMaxSlots){ nMaxSlots = nMaxSlots; }\r
- virtual ~PContainerAutoCompact() {}\r
- \r
- virtual bool MoveItem(u8 srcSlotId, u8 nCount, u8 dstSlotId); \r
-};\r
-\r
-\r
-class PContainer2D : public PContainerAutoCompact // + slotId not used, non-significant XY used (no XY check yet)\r
-{ \r
- public:\r
- PContainer2D(u8 nMaxSlots = 0) : PContainerAutoCompact(nMaxSlots){ nMaxSlots = nMaxSlots; }\r
- virtual ~PContainer2D() {}\r
-\r
- virtual void SetEntryPosXY(PContainerEntry* nEntry, u8 nSlotId, u8 nPosX = 0, u8 nPosY = 0);\r
-};\r
-\r
-class PContainer2DWorkaround : public PContainerWithHoles // Holes allowed, autofind free slot (always increasing id)\r
-{\r
- private:\r
- u8 mNextFreeSlot;\r
- std::vector< std::vector<bool>* > mContSpace;\r
- u8 mMaxCols;\r
- u8 mMaxRows;\r
- u8 mRows;\r
- \r
- void AddRow();\r
- \r
- inline bool Is2DPosAllowed(u8 PosX, u8 PosY, u8 SizeX, u8 SizeY)\r
- {\r
- return ((PosX < mMaxCols-SizeX+1) && (PosY < mMaxRows-SizeY+1));\r
- }\r
- bool Is2DFree(u8 PosX, u8 PosY, u8 SizeX, u8 SizeY);\r
- bool FindValid2DPos(PContainerEntry* nEntry);\r
- \r
-\r
- protected:\r
- bool AddEntry(PContainerEntry* NewEntry, u8 nSlotId = 0);\r
- PContainerEntry* RemoveEntry(u8 nSlotId);\r
- bool GetFreeSlot(u8* nSlotId);\r
- \r
- public:\r
- PContainer2DWorkaround(u8 nMaxSlots = 0);\r
- ~PContainer2DWorkaround();\r
- \r
- bool MoveItem(u8 srcSlotId, u8 nCount, u8 dstSlotId);\r
- \r
- void Set2DPosMax(u8 MaxPosX, u8 MaxPosY = 254) { mMaxCols = MaxPosX; mMaxRows = MaxPosY; }\r
- void SetEntryPosXY(PContainerEntry* nEntry, u8 nSlotId, u8 nPosX = 0, u8 nPosY = 0);\r
- void SetUsed(PContainerEntry* nEntry, bool Value = true);\r
- void Dump();\r
-};\r
-\r
-class PContainerAutoFindFree : public PContainerWithHoles // No holes kept after EndUse, automatic find first free slots (no control on insertion slot)\r
-{\r
- protected:\r
- virtual bool GetFreeSlot(u8* nSlotId);\r
- \r
- public:\r
- PContainerAutoFindFree(u8 nMaxSlots = 0) : PContainerWithHoles(nMaxSlots){ nMaxSlots = nMaxSlots; }\r
- virtual ~PContainerAutoFindFree() {}\r
-};\r
-\r
-class PContainerAutoCompactOnClose : public PContainerAutoFindFree // No holes kept after EndUse, automatic find first free slots (no control on insertion slot)\r
-{ \r
- public:\r
- PContainerAutoCompactOnClose(u8 nMaxSlots = 0) : PContainerAutoFindFree(nMaxSlots){ nMaxSlots = nMaxSlots; }\r
- virtual ~PContainerAutoCompactOnClose() {}\r
-\r
- virtual bool EndUse(u32 nExclusiveUseCharID = 0);\r
-}; \r
-\r
-#endif\r
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
-
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- def_appartements.h\r
-\r
- MODIFIED: 22 Sep 2006 Hammag\r
- REASON: - Creation\r
- \r
-*/\r
-\r
-#ifndef DEF_APPARTEMENTS_H\r
-#define DEF_APPARTEMENTS_H\r
-\r
-#include "def.h"\r
-\r
-class PDefAppartement : public PDef\r
-{\r
- private :\r
- //int mIndex;\r
- std::string mName;\r
- std::string mWorldName;\r
- int mValue;\r
- int mPlaceCount;\r
- int mPlace[8];\r
- int mFaction;\r
-\r
- public :\r
- PDefAppartement();\r
- //~PDefAppartement();\r
-\r
- bool LoadFromDef(PTokenList *Tokens);\r
-\r
- inline int GetID() const { return mIndex; }\r
- inline const std::string &GetName() const { return mName; }\r
- inline const std::string &GetWorldName() const { return mWorldName; }\r
- inline int GetValue() const { return mValue; }\r
- inline int GetPlaceCount() const { return mPlaceCount; }\r
- inline int GetPlace(int nIdx) const { return ( (nIdx < mPlaceCount) ? mPlace[nIdx] : 0 ); }\r
- inline int GetFaction() const { return mFaction; }\r
-};\r
-\r
-\r
-class PDefAppartementsMap : public PDefMap<PDefAppartement>\r
-{\r
- public:\r
- inline std::map<int, PDefAppartement*>::const_iterator ConstIteratorBegin() const { return mDefs.begin(); }\r
- inline std::map<int, PDefAppartement*>::const_iterator ConstIteratorEnd() const { return mDefs.end(); }\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-/*\r
- def_appplaces.h\r
-\r
- Created: 21 Sep 2006 Hammag\r
- REASON: -\r
-*/\r
-\r
-#ifndef DEF_APPPLACES_H\r
-#define DEF_APPPLACES_H\r
-\r
-#include "def.h"\r
-\r
-class PDefAppPlace : public PDef\r
-{\r
- private :\r
- //int mIndex;\r
- std::string mName;\r
- int mExitWorldID;\r
- int mExitWorldEntity;\r
- int mSewerLevel;\r
- \r
- public :\r
- PDefAppPlace();\r
- //~PDefAppPlace();\r
-\r
- bool LoadFromDef(PTokenList *Tokens);\r
-\r
- inline const std::string &GetName() const { return mName; }\r
- inline int GetExitWorldID() const { return mExitWorldID; }\r
- inline int GetExitWorldEntity() const { return mExitWorldEntity; }\r
- inline int GetSewerLevel() const { return mSewerLevel; }\r
-\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- def_characters.h\r
-\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL\r
- \r
- MODIFIED: 29 Jul 2006 Hammag\r
- REASON: - Added skin modifiers fields\r
-*/\r
-\r
-#ifndef DEF_CHARACTERS_H\r
-#define DEF_CHARACTERS_H\r
-\r
-#include "def.h"\r
-\r
-class PDefCharacter : public PDef\r
-{\r
- private :\r
- //int mIndex;\r
- std::string mName;\r
- int mModel;\r
- int mHead;\r
- int mTorso;\r
- int mLegs;\r
- int mColor;\r
- int mBrightness;\r
- \r
- public :\r
- PDefCharacter();\r
- //~PDefCharacter();\r
-\r
- bool LoadFromDef(PTokenList *Tokens);\r
-\r
- inline const std::string &GetName() const { return mName; }\r
- inline int GetModel() const { return mModel; }\r
- inline int GetHead() const { return mHead; }\r
- inline int GetTorso() const { return mTorso; }\r
- inline int GetLegs() const { return mLegs; }\r
- inline int GetColor() const { return mColor; }\r
- inline int GetBrightness() const { return mBrightness; }\r
-};\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- def_charkinds.h\r
-\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL\r
-*/\r
-\r
-#ifndef DEF_CHARKINDS_H\r
-#define DEF_CHARKINDS_H\r
-\r
-#include "def.h"\r
-\r
-struct PSkillInfo\r
-{\r
- int mStart;\r
- int mMax;\r
- int mGrow;\r
-\r
- inline PSkillInfo()\r
- {\r
- mStart = mMax = mGrow = 0;\r
- }\r
-};\r
-\r
-struct PSkillPtsInfo\r
-{\r
- int mSkill;\r
- int mPoints;\r
-\r
- inline PSkillPtsInfo()\r
- {\r
- mSkill = mPoints = 0;\r
- }\r
-};\r
-\r
-struct PSubSkillPtsInfo\r
-{\r
- int mSubSkill;\r
- int mPoints;\r
-\r
- inline PSubSkillPtsInfo()\r
- {\r
- mSubSkill = mPoints = 0;\r
- }\r
-};\r
-\r
-struct PStartLevelInfo\r
-{\r
- int mSubSkill;\r
- int mLevel;\r
-\r
- inline PStartLevelInfo()\r
- {\r
- mSubSkill = mLevel = 0;\r
- }\r
-\r
-};\r
-\r
-class PDefCharKind : public PDef\r
-{\r
- private :\r
- typedef std::map<int, PSkillPtsInfo*> PSkillPtsMap;\r
- typedef std::map<int, PSubSkillPtsInfo*> PSubSkillPtsMap;\r
- typedef std::map<int, PStartLevelInfo*> PStartLevelMap;\r
-\r
- //int mIndex;\r
- std::string mName;\r
- int mType;\r
-\r
- // TODO: shouldnt this be a map?\r
- PSkillInfo *mSkillInfo;\r
-\r
- PSkillPtsMap mSkillPts;\r
- PSubSkillPtsMap mSubSkillPts;\r
- PStartLevelMap mStartLevels;\r
- int mMoney;\r
- u32 mInventory[8];\r
- public :\r
- PDefCharKind();\r
- ~PDefCharKind();\r
-\r
- bool LoadFromDef(PTokenList *Tokens);\r
-\r
- inline const std::string &GetName() const { return mName; }\r
- inline int GetType() const { return mType; }\r
- inline const PSkillInfo &GetSkillInfo(int Skill) const { return mSkillInfo[Skill-1]; }\r
-\r
- inline int GetStartMoney() const { return mMoney; }\r
- inline u32 GetStartInventory(u8 Index) const { return ((Index < 7) ? mInventory[Index] : 0); }\r
- // TODO: mission get() functions\r
-};\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- def_factions.h\r
-\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL\r
-*/\r
-\r
-#ifndef DEF_FACTIONS_H\r
-#define DEF_FACTIONS_H\r
-\r
-#include "def.h"\r
-\r
-static const int NUMFACTIONS = 20; // for faction relations only\r
-\r
-class PDefFaction : public PDef\r
-{\r
- private :\r
- //int mIndex;\r
- std::string mName;\r
- int mStartValue;\r
- bool mAffected;\r
- int mSL;\r
- int mRelations[NUMFACTIONS];\r
- public :\r
- PDefFaction();\r
- //~PDefFaction();\r
-\r
- bool LoadFromDef(PTokenList *Tokens);\r
-\r
- inline const std::string &GetName() const { return mName; }\r
- inline int GetStartValue() const { return mStartValue; }\r
- inline bool GetAffected() const { return mAffected; }\r
- inline int GetSL() const { return mSL; };\r
- int GetRelation(int Faction) const;\r
-};\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- def_hack.h\r
-\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL\r
-*/\r
-\r
-#ifndef DEF_HACK_H\r
-#define DEF_HACK_H\r
-\r
-#include "def.h"\r
-\r
-class PDefHack : public PDef\r
-{\r
- private :\r
- //int mIndex;\r
- //qui aggiungere valori\r
- public :\r
- PDefHack();\r
- //~PDefHack();\r
-\r
- bool LoadFromDef(PTokenList *Tokens);\r
-\r
- //qui aggiungere funzioni per i gets\r
-};\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- def_items.h\r
-\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL\r
- \r
- MODIFIED: 10 Jul Hammag\r
- REASON: - Full Item Def implementation\r
-*/\r
-\r
-#ifndef DEF_ITEMS_H\r
-#define DEF_ITEMS_H\r
-\r
-#include "def.h"\r
-\r
-class PDefItems : public PDef\r
-{\r
- private :\r
-\r
- //int mIndex;//1\r
- std::string mName;//2\r
- int mModel; // used for IG display\r
- int mType;\r
- int mValue1;\r
- int mValue2;\r
- int mValue3;\r
- // int mBmNum; // used IG for inventory display\r
- // int mmBmNumIndex; // used IG for inventory display\r
- int mSizeX;\r
- int mSizeY; \r
- // int mSmallbmnum; // used IG for inventory display\r
- float mWeight;\r
- int mStackable;\r
- float mFillWeight;\r
- int mQualifier;\r
- int mGfxMods;\r
- int mItemGroupID; \r
- int mTextDescID;\r
- int mBasePrice;\r
- int mTechlevel;\r
- int mItemflags;\r
- // std::mShortname; // used IG for display on inventories Icons\r
-\r
- public :\r
- PDefItems();\r
- //~PDefItems();\r
-\r
- bool LoadFromDef(PTokenList *Tokens);\r
-\r
- inline const std::string &GetName() const { return mName; }\r
- inline int GetModel() const { return mModel; }\r
- inline int GetType() const { return mType; }\r
- inline int GetValue1() const { return mValue1; }\r
- inline int GetValue2() const { return mValue2; }\r
- inline int GetValue3() const { return mValue3; }\r
- inline int GetSizeX() const { return mSizeX; }\r
- inline int GetSizeY() const { return mSizeY; }\r
- inline float GetWeight() const { return mWeight; }\r
- inline bool IsStackable() const { return (mStackable == 1); }\r
- inline float GetFillWeight() const { return mFillWeight; }\r
- inline int GetQualifier() const { return mQualifier; }\r
- inline int GetGfxMods() const { return mGfxMods; }\r
- inline int GetItemGroupID() const { return mItemGroupID; } \r
- inline int GetTextDescID() const { return mTextDescID; }\r
- inline int GetBasePrice() const { return mBasePrice; }\r
- inline int GetTechlevel() const { return mTechlevel; }\r
- inline int GetItemflags() const { return mItemflags; }\r
-};\r
-\r
-\r
-class PDefItemsMap : public PDefMap<PDefItems>\r
-{\r
- private:\r
- std::map<int, PDefItems*>::const_iterator* mMapItCache;\r
- int mMapItCacheCount;\r
- std::map<int, std::vector<int> > mItemGroups;\r
- int mMaxItemGroupId;\r
- void BuildMapItCache();\r
- void BuildItemGroups();\r
-\r
- public:\r
- PDefItemsMap();\r
- ~PDefItemsMap();\r
- bool Load(const char* nName, const char* nFilename);\r
- const PDefItems* GetDefBySeqIndex( int nSeqIndex ) const;\r
- int GetRandomItemIdFromGroup( int nGroupId ) const;\r
-\r
- inline std::map<int, PDefItems*>::const_iterator ConstIteratorBegin() const { return mDefs.begin(); }\r
- inline std::map<int, PDefItems*>::const_iterator ConstIteratorEnd() const { return mDefs.end(); }\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
-
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
-
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
-
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
-
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- def_respawn.h\r
-\r
- MODIFIED: 22 Sep 2006 Hammag\r
- REASON: - Creation\r
- \r
-*/\r
-\r
-#ifndef DEF_RESPAWN_H\r
-#define DEF_RESPAWN_H\r
-\r
-#include "def.h"\r
-\r
-class PDefRespawn : public PDef\r
-{\r
- private :\r
- //int mIndex;\r
- int mWorldID;\r
- int mEntityID; // Station ID\r
- int mHazardLevel;\r
- std::string mName; // Description\r
- std::string mFlag; // ???\r
-\r
- public :\r
- PDefRespawn();\r
- //~PDefRespawn();\r
-\r
- bool LoadFromDef(PTokenList *Tokens);\r
-\r
- inline int GetWorldID() const { return mWorldID; }\r
- inline int GetEntityID() const { return mEntityID; }\r
- inline int GetHazardLevel() const { return mHazardLevel; }\r
- inline const std::string &GetName() const { return mName; }\r
- inline const std::string &GetFlag() const { return mFlag; }\r
-\r
-};\r
-\r
-\r
-class PDefRespawnsMap : public PDefMap<PDefRespawn>\r
-{\r
- public:\r
- int GetRespawnEntity( u32 nWorldID, u16 nGROrder ) const;\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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<PDefScripts>
-{
- public:
- //bool Load(const char* nName, const char* nFilename);
- inline std::map<int, PDefScripts*>::const_iterator ConstIteratorBegin() const { return mDefs.begin(); }
- inline std::map<int, PDefScripts*>::const_iterator ConstIteratorEnd() const { return mDefs.end(); }
-};
-
-#endif
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
-
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- def_skills.h\r
-\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL\r
-*/\r
-\r
-#ifndef DEF_SKILLS_H\r
-#define DEF_SKILLS_H\r
-\r
-#include "def.h"\r
-\r
-class PDefSkill : public PDef\r
-{\r
- private :\r
- //int mIndex;\r
- std::string mName;\r
- std::string mShortName;\r
- int mNumSubSkills;\r
- int *mSubSkills;\r
- public :\r
- PDefSkill();\r
- ~PDefSkill();\r
-\r
- bool LoadFromDef(PTokenList *Tokens);\r
-\r
- inline const std::string &GetName() const { return mName; }\r
- inline const std::string &GetShortName() const { return mShortName; }\r
- inline int GetNumSubSkills() const { return mNumSubSkills; }\r
- inline int GetSubSkill(int Index) const { return mSubSkills[Index]; }\r
-};\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- def_subskill.h\r
-\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL\r
-*/\r
-\r
-#ifndef DEF_SUBSKILLS_H\r
-#define DEF_SUBSKILLS_H\r
-\r
-#include "def.h"\r
-\r
-class PDefSubSkill : public PDef\r
-{\r
- private :\r
- //int mIndex;\r
- std::string mName;\r
- std::string mShortName;\r
- float mStrengthenFactor;\r
- int mNumActionModifiers;\r
- int *mActionModifiers;\r
- public :\r
- PDefSubSkill();\r
- ~PDefSubSkill();\r
-\r
- bool LoadFromDef(PTokenList *Tokens);\r
-\r
- inline const std::string &GetName() const { return mName; }\r
- inline const std::string &GetShortName() const { return mShortName; }\r
- inline float GetStrengthenFactor() const { return mStrengthenFactor; }\r
- inline int GetNumActionModifiers() const { return mNumActionModifiers; }\r
- inline int GetActionModifier(int Index) const { return mActionModifiers[Index]; }\r
-};\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
-
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
-
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
-
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
-
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- def_worldfile.h (infos from worlds/worlds.ini)\r
-\r
- MODIFIED: 28 Sep 2007 Hammag\r
- REASON: - Creation\r
-*/\r
-\r
-#ifndef DEF_WORLDFILE_H\r
-#define DEF_WORLDFILE_H\r
-\r
-#include "def.h"\r
-\r
-class PDefWorldFile : public PDef\r
-{\r
- private :\r
- //int mIndex;\r
- std::string mName; // dat filename with ending extension and starting ./ or ./worlds/ REMOVED\r
- bool mFileInWorldsDir; // TRUE if worlds/ must be appendend before mName to get real file name (dat file at least)\r
- \r
- public :\r
- PDefWorldFile();\r
- //~PDefWorldFile();\r
-\r
- bool LoadFromDef(PTokenList *Tokens);\r
-\r
- inline const std::string &GetName() const { return mName; }\r
- inline const std::string GetBasicFileName() const { return (mFileInWorldsDir ? (std::string("worlds/") + mName) : mName); };\r
-};\r
-\r
-\r
-class PDefWorldFilesMap : public PDefMap<PDefWorldFile>\r
-{\r
- public:\r
- bool Load(const char* nName, const char* nFilename);\r
- inline std::map<int, PDefWorldFile*>::const_iterator ConstIteratorBegin() const { return mDefs.begin(); }\r
- inline std::map<int, PDefWorldFile*>::const_iterator ConstIteratorEnd() const { return mDefs.end(); }\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-/*\r
- def_WorldModels.h\r
-\r
- Created: 21 Sep 2006 Hammag\r
- REASON: -\r
-*/\r
-\r
-#ifndef DEF_WORLDMODELS_H\r
-#define DEF_WORLDMODELS_H\r
-\r
-#include "def.h"\r
-\r
-class PDefWorldModel : public PDef\r
-{\r
- private :\r
- //int mIndex;\r
- std::string mName;\r
- int mUseFlags;\r
- int mFunctionType;\r
- int mFunctionValue;\r
- int mHackDifficulty;\r
- int mHackPenalty;\r
- \r
- public :\r
- PDefWorldModel();\r
- //~PDefWorldModel();\r
-\r
- bool LoadFromDef(PTokenList *Tokens);\r
-\r
- inline int GetID() const { return mIndex; }\r
- inline const std::string &GetName() const { return mName; }\r
- inline int GetUseFlags() const { return mUseFlags; }\r
- inline int GetFunctionType() const { return mFunctionType; }\r
- inline int GetFunctionValue() const { return mFunctionValue; }\r
- inline int GetHackDifficulty() const { return mHackDifficulty; }\r
- inline int GetHackPenalty() const { return mHackPenalty; }\r
-\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- def_worlds.h\r
-\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL\r
-*/\r
-\r
-#ifndef DEF_WORLDS_H\r
-#define DEF_WORLDS_H\r
-\r
-#include "def.h"\r
-\r
-class PDefWorld : public PDef\r
-{\r
- private :\r
- //int mIndex;\r
- std::string mName;\r
- std::string mDatFile;\r
- int mFlags;\r
- public :\r
- PDefWorld();\r
- //~PDefWorld();\r
-\r
- bool LoadFromDef(PTokenList *Tokens);\r
-\r
- inline const std::string &GetName() const { return mName; }\r
- inline const std::string &GetDatFile() const { return mDatFile; }\r
- inline int GetFlags() const { return mFlags; }\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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 T> class PDefMap
-{
- protected:
- std::string mName;
- std::map<int, T*> 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 <class T> PDefMap<T>::~PDefMap()
-{
- Clear();
-}
-
-template <class T> void PDefMap<T>::Clear()
-{
- for ( typename std::map<int, T*>::iterator i = mDefs.begin(); i != mDefs.end(); i++ )
- delete i->second;
- mDefs.clear();
-}
-
-template <class T> bool PDefMap<T>::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 <class T> const T* PDefMap<T>::GetDef( int Index ) const
-{
- T* Result;
-
- typename std::map<int, T*>::const_iterator i = mDefs.find( Index );
- Result = ( ( i != mDefs.end() ) ? i->second : NULL );
-
- return ( Result );
-}
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- defparser.h\r
-\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL\r
-*/\r
-\r
-#ifndef DEFPARSER_H\r
-#define DEFPARSER_H\r
-\r
-#ifdef _MSC_VER\r
- #pragma once\r
-#endif\r
-\r
-typedef std::list<std::string> PTokenList;\r
-typedef std::list<PTokenList*> PDefTokenList;\r
-\r
-class PDefParser\r
-{\r
- private :\r
- PDefTokenList mTokens;\r
- public :\r
- PDefParser();\r
- ~PDefParser();\r
- bool Parse(const char *File);\r
- inline const PDefTokenList &GetTokens() const { return mTokens; }\r
-};\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- defs.h - include file for all def_* files related stuff used by all modules\r
- \r
- MODIFIED: 21 Sep 2006 Hammag\r
- REASON: - created\r
- \r
-*/\r
-\r
-#ifndef DEFS_H\r
-#define DEFS_H\r
-\r
-#include "defparser.h"\r
-#include "defmap.h"\r
-\r
-#include "def_actionmod.h"\r
-#include "def_ammo.h"\r
-#include "def_appartements.h"\r
-#include "def_appplaces.h"\r
-#include "def_blueprintpieces.h"\r
-#include "def_characters.h"\r
-#include "def_charaction.h"\r
-#include "def_charkinds.h"\r
-#include "def_damage.h"\r
-#include "def_drugs.h"\r
-#include "def_factions.h"\r
-#include "def_hack.h"\r
-#include "def_implants.h"\r
-#include "def_itemcontainer.h"\r
-#include "def_itemmod.h"\r
-#include "def_itemres.h"\r
-#include "def_items.h"\r
-#include "def_mission.h"\r
-#include "def_npcarmor.h"\r
-#include "def_npcgroupspawn.h"\r
-#include "def_npc.h"\r
-#include "def_outposts.h"\r
-#include "def_recycles.h"\r
-#include "def_respawn.h"\r
-#include "def_shots.h"\r
-#include "def_skills.h"\r
-#include "def_subskills.h"\r
-#include "def_trader.h"\r
-#include "def_vehicles.h"\r
-#include "def_vehiclesits.h"\r
-#include "def_weapons.h"\r
-#include "def_weather.h"\r
-#include "def_worlds.h"\r
-#include "def_worldfile.h"\r
-#include "def_worldmodels.h"\r
-#include "def_scripts.h"\r
-\r
-#include "gamedefs.h"\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-/*\r
- doortemplate.h - world door template class\r
-\r
- MODIFIED: 05 Nov 2006 Hammag\r
- REASON: - creation\r
- \r
-*/\r
-\r
-\r
-#ifndef DOORTEMPLATE_H\r
-#define DOORTEMPLATE_H\r
-\r
-#include "def_worldmodels.h"\r
-\r
-class PDoorTemplate\r
-{\r
- friend class PWorldDatParser;\r
- \r
- private:\r
- u16 mDoorID;\r
-\r
- // The commented out values are not loaded from dat file atm because they are not used yet.\r
- //u16 mUnknown1; //18 00\r
- //u16 mUnknown1bis; //00 00 ? varies\r
- f32 mPosY;\r
- f32 mPosZ;\r
- f32 mPosX;\r
- //u16 mUnknown5; //00 00 ? second byte varies\r
- u16 mWorldmodelID; //door type from worldmodel.def\r
-\r
- std::string mDoorTypeName; \r
- int mDoorParameters[4];\r
- bool mIsDoubleDoor;\r
- bool mIsTriggeredDoor;\r
- \r
- const PDefWorldModel* mDefWorldModel;\r
-\r
- public:\r
- PDoorTemplate();\r
- ~PDoorTemplate();\r
-\r
- inline u16 GetID() { return mDoorID; }\r
- inline u16 GetUseFlags() { return (mDefWorldModel ? mDefWorldModel->GetUseFlags() : 0); }\r
- inline u16 GetFunctionType() { return (mDefWorldModel ? mDefWorldModel->GetFunctionType() : 0); }\r
- inline int GetFunctionValue() { return (mDefWorldModel ? mDefWorldModel->GetFunctionValue() : 0); }\r
- inline const std::string& GetName() const { return (mDefWorldModel ? mDefWorldModel->GetName() : EmptyString ); } /// !!!!\r
- inline const PDefWorldModel* GetDefWorldModel() const { return mDefWorldModel; }\r
- \r
- inline void GetPos(f32* nPosX, f32* nPosY, f32* nPosZ) const { *nPosY = mPosY; *nPosZ = mPosZ; *nPosX = mPosX;}\r
- inline u16 GetOtherDoorID() { return ( mIsDoubleDoor ? mDoorParameters[1] : 0 ); }\r
- inline bool IsDoubleDoor() const { return mIsDoubleDoor; }\r
- inline bool IsTriggeredDoor() const { return mIsTriggeredDoor; }\r
- \r
- void SetDoorTypeName(char* nDoorTypeName);\r
- void SetDoorParameters(char* nDoorParametersString);\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-/*\r
- furnituretemplate.h - world furniture template class\r
-\r
- MODIFIED: 04 Oct 2006 Hammag\r
- REASON: - creation\r
-\r
-*/\r
-\r
-\r
-#ifndef FURNITURETEMPLATE_H\r
-#define FURNITURETEMPLATE_H\r
-\r
-#include "def_worldmodels.h"\r
-\r
-enum // Furniture Use flags (cumlative)\r
-{\r
- ufTouchable = 1,\r
- ufUsable = 2,\r
- ufNoCollision = 4,\r
- ufChair = 8,\r
- ufToolTarget = 16,\r
- ufSelfCollisionBox = 64,\r
- ufGraphicalEffect = 128,\r
- ufNoSelectionBox = 256\r
-};\r
-\r
-class PFurnitureItemTemplate\r
-{\r
- friend class PWorldDatParser;\r
-\r
- private:\r
- u32 mObjectID;\r
-\r
- // The commented out values are not loaded from dat file atm because they are not used yet.\r
- f32 mPosY; //= mPosY from dat file + 32000, to be coherent with char Pos scale\r
- f32 mPosZ;\r
- f32 mPosX;\r
- //f32 mRotY;\r
- f32 mRotZ;\r
- //f32 mRotX;\r
- //u32 mScale; //00 00 80 3F ? = float(1.0000) scale factor ? // mostly used by holoscreens (passiv object)\r
- //u32 mUnknown2; //01 00 00 00 ?\r
- u16 mModelID; // points to models.ini\r
- //u32 mUnknown3; //00 00 00 00 ?\r
- //u32 mUnknown4; //00 00 00 00 ?\r
- u16 mWorldmodelID; // points to worldmodel.def\r
- //u16 mUnknown5; //12 00 ? // changes sometime (ex: c288 ...)\r
-\r
- //f32 mBoxLowerY; //Bounding box, for use when ufSelfCollisionBox is set in mUseFlags.\r
- //f32 mBoxLowerZ;\r
- //f32 mBoxLowerX;\r
- //f32 mBoxUpperY;\r
- //f32 mBoxUpperZ;\r
- //f32 mBoxUpperX;\r
-\r
- u16 mFrontPosY;\r
- u16 mFrontPosZ;\r
- u16 mFrontPosX;\r
- u8 mFrontLR;\r
-\r
- const PDefWorldModel* mDefWorldModel;\r
-\r
- u32 mLinkedObjectID; // for buttons, stores the corresponding triggered door\r
- // fo GR, stores order of the GR entity (spawn point) to later choose from respawn.def data\r
-\r
- public:\r
- PFurnitureItemTemplate();\r
- ~PFurnitureItemTemplate();\r
-\r
- inline u32 GetID() const { return mObjectID; }\r
- inline u16 GetUseFlags() const { return ( mDefWorldModel ? mDefWorldModel->GetUseFlags() : 0 ); }\r
- inline u16 GetFunctionType() const { return ( mDefWorldModel ? mDefWorldModel->GetFunctionType() : 0 ); }\r
- inline int GetFunctionValue() const{ return ( mDefWorldModel ? mDefWorldModel->GetFunctionValue() : 0 ); }\r
- inline const std::string& GetName() const { return ( mDefWorldModel ? mDefWorldModel->GetName() : EmptyString ); } /// !!!!\r
- inline const PDefWorldModel* GetDefWorldModel() const { return mDefWorldModel; }\r
- inline u8 GetFrontLR() const { return mFrontLR; }\r
- inline void GetFrontPos( u16* nFrontPosX, u16* nFrontPosY, u16* nFrontPosZ ) const { *nFrontPosY = mFrontPosY; *nFrontPosZ = mFrontPosZ; *nFrontPosX = mFrontPosX;}\r
- inline void GetPos( f32* nPosX, f32* nPosY, f32* nPosZ ) const { *nPosY = mPosY; *nPosZ = mPosZ; *nPosX = mPosX;}\r
-\r
- inline void SetLinkedObjectID( u32 nID ) { mLinkedObjectID = nID; }\r
- inline u32 GetLinkedObjectID() const { return mLinkedObjectID; }\r
-\r
-};\r
-\r
-#endif\r
-\r
-// *** from worldmodel.def ***\r
-\r
-//function Type\r
-// 0 - none\r
-// 1 - Itemcontainer\r
-// 2 - Terminal\r
-// 3 - Outfitter\r
-// 4 - Trader\r
-// 5 - Mineral\r
-// 6 - Respawn Station\r
-// 7 - GoGuardian\r
-// 8 - Hackterminal\r
-// 9 - Appartement Eingang\r
-// 10 - Appartement Ein/Ausgang\r
-// 11 - Appartement Klingel/�ffner\r
-// 12 - Standard Button\r
-// 13 - Hack Button\r
-// 14 - HOLOMATCH ENTRANCE\r
-// 15 - HOLOMATCH EXIT\r
-// 16 - HOLOMATCH REFRESH\r
-// 17 - HOLOMATCH HEAL\r
-// 18 - WORLDCHANGEACTOR\r
-// 19 - CLANTERMINAL\r
-// 20 - DATFILE WORLDCHANGE ACTOR\r
-// 21 - LOCATION FOR 20\r
-// 22 -\r
-// 23 - EINTRITTSGELD BUTTON\r
-// 24- TUTORIALEXIT\r
-// 25 - EXPLOSIVE\r
-// 26 - Outpost Switch\r
-// 27 - Old goguardian\r
-// 28 - Fahrzeug Depot Interface\r
-// 29 - Underground Exit\r
-// 30 - Static FX (Value=Type. 1=Fire 2=Smoke 3=Steam 4=Sparkle)\r
-// 31 - Venture Warp Station\r
-// 32 - functionvalue+100 gibt eine Meldung aus der Text.ini [MISC] an.\r
-//\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-#ifndef GAMESCRIPT_H\r
-#define GAMESCRIPT_H\r
-\r
-enum PHookTypes\r
-{\r
- HOOK_CHAT,\r
- HOOK_TRADE,\r
- HOOK_ZONE\r
-};\r
-\r
-class PGameScript\r
-{\r
- private:\r
- typedef std::map<PHookTypes, std::string> HookMap;\r
- HookMap mHooks;\r
-\r
- public:\r
- PGameScript();\r
- ~PGameScript();\r
-\r
- bool LoadScripts();\r
- bool Rehash();\r
- void TriggerHook(PHookTypes hook);\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- genreplist.h - classe for character genrep list\r
-\r
- MODIFIED: 20 Sep 2006 Hammag\r
- REASON: - creation\r
- \r
-*/\r
-\r
-#ifndef GENREPLIST_H\r
-#define GENREPLIST_H\r
-\r
-#define GENREPLIST_ALLOC_SIZE 4 // atomicity of list entries allocation\r
-\r
-class PGenrepList\r
-{\r
- private:\r
- enum { // genrep DB Table fields\r
- g_id = 0,\r
- g_worldid,\r
- g_stationid,\r
- g_charid\r
- };\r
- struct PGenrepEntry\r
- {\r
- u16 mWorldID;\r
- u16 mStationID;\r
- };\r
- \r
- u32 mOwnerCharID;\r
- u8 mListMaxSize;\r
- u8 mListSize;\r
- PGenrepEntry* mGenrepList;\r
- \r
- void IncreaseMaxSize(u8 nNewMax = 0);\r
- u8 FindEntry(u16 nWorldID, u16 nStationID);\r
- \r
- public:\r
- PGenrepList(u32 nOwnerCharID);\r
- ~PGenrepList();\r
- bool AddGenrep(u16 nWorldID, u16 nStationID);\r
- //bool RemoveChar(u32 nBuddyCharID); \r
- inline u8 Count() { return mListSize; }\r
- u16 GetListDataSize() { return (sizeof(PGenrepEntry) * mListSize); }\r
- const void* GetListData() { return (const void*)mGenrepList; }\r
- bool SQLLoad();\r
-// bool SQLSave();\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
- globals.h\r
-\r
- MODIFIED: 12 September 2005 Akiko\r
- REASON: - exchanged Pretender Strings by TinNS\r
- - removed some Windows specific code\r
- MODIFIED: 16 Dec 2005 bakkdoor\r
- REASON: - Added global ClientManager and Chat Interface\r
- MODIFIED: 22 Dec 2005 Namikon\r
- REASON: - Added GPL\r
-\r
-*/\r
-\r
-#ifndef GLOBALS_H\r
-#define GLOBALS_H\r
-\r
-extern class PLuaEngine *LuaEngine;\r
-\r
-extern class ServerSocket *ServerSock;\r
-extern class PConsole *Console;\r
-//extern class PRConsole *RemoteConsole;\r
-extern class PConfig *Config;\r
-extern class PConfig *CmdAccess;\r
-\r
-extern class PGameDefs *GameDefs;\r
-extern class PFileSystem *Filesystem;\r
-extern class PServer *Server;\r
-\r
-extern class PGameServer *GameServer;\r
-extern class PChars *Chars;\r
-\r
-extern class PMsgBuilder *MsgBuilder;\r
-extern class PWorlds *Worlds;\r
-extern class PAppartements* Appartements;\r
-extern class PWorldActors* WorldActors;\r
-extern class PTerminal* Terminal;\r
-//extern class gmMachine machine; // Virtual Machine instance\r
-\r
-//multiuser chat\r
-extern class PClientManager *ClientManager;\r
-extern class PNPCManager* NPCManager;\r
-extern class PChat *Chat;\r
-extern class PCommands *GameCommands;\r
-\r
-extern class POutpost *Outposts;\r
-extern class PMultiPart *MultiPartHandler;\r
-\r
-// Development debug output control\r
-extern bool gDevDebug;\r
-\r
-//MySQL-Support\r
-extern class PMySQL* MySQL;\r
-\r
-//Vehicles\r
-extern class PVehicles *Vehicles;\r
-extern class PSubway* Subway;\r
-\r
-//Infoserver update\r
-extern class PISC *ISC;\r
-\r
-//Empty string\r
-extern const std::string EmptyString;\r
-\r
-extern const char ServerVersion[];\r
-extern const char SVNRevision[];\r
-\r
-bool InitTinNS();\r
-void Shutdown();\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- inventory.h - classes for inventories\r
- (inventory, belt, armor, implants, gogo, processor(?), maybe other containers(?) )\r
-\r
- MODIFIED: 10 Jul 2006 Hammag\r
- REASON: - creation\r
-\r
-\r
-*/\r
-\r
-#ifndef INVENTORY_H\r
-#define INVENTORY_H\r
-\r
-//NC containers message locations\r
-#define INV_LOC_GROUND 1\r
-#define INV_LOC_WORN 2\r
-#define INV_LOC_BACKPACK 3\r
-#define INV_LOC_BOX 4\r
-#define INV_LOC_NPCTRADE 5\r
-#define INV_LOC_GOGO 18\r
-#define INV_LOC_BOX2 255\r
-//PC-Trade window = ?\r
-\r
-//Inventory containers info\r
-#define INV_WORN_QB_START 0\r
-#define INV_WORN_QB_END 9\r
-#define INV_WORN_QB_NONE 99\r
-#define INV_WORN_QB_HAND 11\r
-\r
-#define INV_WORN_PROC_START 12\r
-#define INV_WORN_PROC_END 24\r
-\r
-#define INV_WORN_IMP_START 26\r
-#define INV_WORN_IMP_END 38\r
-\r
-#define INV_WORN_ARMOR_START 39\r
-#define INV_WORN_ARMOR_END 43\r
-\r
-#define INV_WORN_COLS 44\r
-#define INV_WORN_MAXSLOTS 44\r
-\r
-\r
-#define INV_BACKPACK_COLS 10\r
-\r
-#define INV_GOGO_COLS 5\r
-#define INV_GOGO_MAXSLOTS 50\r
-\r
-#define INV_CABINET_COLS 5\r
-#define INV_CABINET_MAXSLOTS 33\r
-\r
-// inv_loc values in database\r
-#define INV_DB_LOC_GOGO 1\r
-#define INV_DB_LOC_WORN 2\r
-#define INV_DB_LOC_BACKPACK 3\r
-\r
-class PItem;\r
-class PContainer;\r
-class PContainerWithHoles;\r
-class PContainer2DWorkaround;\r
-class PContainerAutoFindFree;\r
-\r
-class PInventory\r
-{\r
- private:\r
- PContainerWithHoles* mWorn; // PContainerLinearSlots\r
- PContainer2DWorkaround* mBackpack; // PContainer2DAreas\r
- PContainerAutoFindFree* mGogo; // PContainerLinearSlots\r
- \r
- public:\r
-\r
- PInventory();\r
- ~PInventory();\r
- \r
- void SetCharId(u32 CharID);\r
- bool SQLLoad();\r
- bool SQLSave();\r
- PContainer* GetContainer(u8 nInvLoc);\r
- inline PContainer2DWorkaround* GetBackpackContainer() { return mBackpack; }\r
-\r
- bool IsDirty() const;\r
- \r
- bool AddItem(PItem* NewItem, u8 nInvLoc = INV_LOC_BACKPACK, u32 nInvID = 0, u8 nPosX = 0, u8 nPosY = 0, bool SetDirty = true);\r
- //bool CheckItem(u32 ItemID, u8 StackSize = 1);\r
- //PItem *GetItem(u32 ItemID, u8 StackSize = 1);\r
- //PItem *GetItemByPos(u8 nPosX, u8 nPosY, u8 StackSize = 1);\r
- //bool MoveItem(u8 oPosX, u8 oPosY, u8 dPosX, u8 dPosY);\r
-\r
- //bool QB_IsFree(u8 nSlot);\r
- //void QB_SetSlot(u8 nSlot, u16 nItemID);\r
- //u16 QB_GetSlot(u8 nSlot);\r
- //void QB_Move(u8 nSlotSRC, u8 nSlotDST);\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- item.h - item class\r
-\r
- MODIFIED: 11 Jul 2006 Hammag\r
- REASON: - creation\r
- \r
- TODO: Add CreatorID (for "named" item), CurrentMunitionID, CurrentMunitionNb (for weapons & charge-items: muns, medkit, etc.) to DB, equipped/free slots, & corresponding code\r
-*/\r
-\r
-#ifndef ITEM_H\r
-#define ITEM_H\r
-\r
-#define MAX_ITEMSTACK_SIZE 250\r
-\r
-//Type\r
-#define ITEM_TYPE_VARIOUS 0\r
-#define ITEM_TYPE_WEAPON 1\r
-#define ITEM_TYPE_AMMO 2\r
-#define ITEM_TYPE_HEALTH 3\r
-#define ITEM_TYPE_IMPLANT 4\r
-#define ITEM_TYPE_DRUG 5\r
-#define ITEM_TYPE_MOD 6\r
-#define ITEM_TYPE_GFXMOD 7\r
-#define ITEM_TYPE_BLUEPRINT 8\r
-#define ITEM_TYPE_ARMOR 9\r
-#define ITEM_TYPE_PSIMOD 10\r
-#define ITEM_TYPE_PSIMODREADY 11\r
-#define ITEM_TYPE_REPAIR 12\r
-#define ITEM_TYPE_RECYCLER 13\r
-#define ITEM_TYPE_DATACUBE 14\r
-#define ITEM_TYPE_CONSTRUCTOR 15\r
-#define ITEM_TYPE_RESEARCHER 16\r
-#define ITEM_TYPE_IMPLANTER 17\r
-#define ITEM_TYPE_APARTMENTKEY 18\r
-#define ITEM_TYPE_CLANKEY 19\r
-#define ITEM_TYPE_CASHCUBE 20\r
-#define ITEM_TYPE_AUTOWEAPON 21\r
-#define ITEM_TYPE_VHCKEY 22\r
-#define ITEM_TYPE_UNIDENTPART 24\r
-#define ITEM_TYPE_WRECKEDPART 25\r
-#define ITEM_TYPE_SALVAGE 26\r
-#define ITEM_TYPE_VHCCOMPONENT 27\r
-#define ITEM_TYPE_RECORDABLE 28\r
-\r
- \r
-\r
-// gfxmodflags \r
-#define ITEM_MOD_FLASHLIGHT 1 \r
-#define ITEM_MOD_SCOP 2\r
-#define ITEM_MOD_SILENCER 4\r
-#define ITEM_MOD_LASERPOINTER 8\r
-\r
-// itemflags:\r
-#define ITEM_FLAG_RESEARCHABLE 1\r
-#define ITEM_FLAG_NO_DROP 2\r
-#define ITEM_FLAG_NO_MAX_REPAIRE_DECAY 4\r
-#define ITEM_FLAG_AMMO 8 // for loadable ammo\r
-// not sure for ITEM_FLAG_AMMO\r
-\r
-class PItem\r
-{\r
- friend class PContainerEntry;\r
- friend class PMsgBuilder;\r
-\r
- private:\r
- u32 mItemID;\r
- const PDefItems* mDefItem;\r
- \r
- bool mStackable;\r
- u8 mStackSize;\r
- \r
- u32 mLoadedAmmoId;\r
- u8 mLoadedAmmoNb;\r
-\r
- u8 mPropertiesFlags;\r
- \r
- u8 mCurDuration;\r
- u8 mMaxDuration;\r
- u8 mDamages;\r
- u8 mFrequency;\r
- u8 mHandling;\r
- u8 mRange;\r
- \r
- u8 mUsedSlots;\r
- u8 mMaxSlots;\r
- u8 mSlot[5];\r
- u8 mModificators;\r
- \r
- u32 mConstructorId;\r
- \r
- public:\r
- PItem(u32 ItemID, u8 nStackSize = 1, u8 CurDur = 0, u8 MaxDur = 0, u8 Dmg = 0, u8 Freq = 0, u8 Hand = 0, u8 Rng = 0);\r
- //~PItem();\r
- void MakeItemStandard(u8 GlobalQualityMin = 120, u8 GlobalQualityMax = 180);\r
- \r
- inline u32 GetItemID() {return mItemID; }\r
- \r
- inline int GetType() { return mDefItem->GetType(); }\r
- inline u8 GetItemflags() { return mDefItem->GetItemflags(); }\r
- inline const std::string &GetName() const { return mDefItem->GetName(); }\r
- inline u8 GetSizeX() { return mDefItem->GetSizeX(); }\r
- inline u8 GetSizeY() { return mDefItem->GetSizeY(); }\r
- inline float GetWeight() { return mStackSize * mDefItem->GetWeight(); }\r
- inline float GetSingleUnitWeight() { return mDefItem->GetWeight(); }\r
- inline float GetFillWeight() { return mDefItem->GetFillWeight(); }\r
- inline u32 GetBasePrice() { return mDefItem->GetBasePrice(); }\r
- inline u16 GetTechlevel() { return mDefItem->GetTechlevel(); }\r
- inline int GetValue1() { return mDefItem->GetValue1(); }\r
- inline int GetValue2() { return mDefItem->GetValue2(); }\r
- inline int GetValue3() { return mDefItem->GetValue3(); }\r
- inline int GetQualifier() { return mDefItem->GetQualifier(); } \r
- \r
- inline bool IsStackable() { return mDefItem->IsStackable(); }\r
- inline u8 GetStackSize() { return mStackSize; }\r
- u8 AddToStack(u8 ItemNb); // return the nb of items NOT added\r
- u8 TakeFromStack(u8 ItemNb); // return the nb of retreived items \r
-\r
- //mItemGroupID = def->GetItemGroupID();\r
- \r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*
-TinNS (TinNS is not a Neocron Server)
-Copyright (C) 2005 Linux Addicted Community
-maintainer Akiko <akiko@gmx.org>
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public 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 <lua.h>
- #include <lauxlib.h>
- #include <lualib.h>
-}
-
-#define PLUAENGINE_DEFAULT 0
-#define PLUAENGINE_GETANSWER 4096
-#define PLUAENGINE_EXECUTENODE 8192
-
-class PLuaEngine
-{
- private:
- PClient* mTargetClient;
-
- bool mRunning;
- lua_State *mLua;
-
- std::vector<int> 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
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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);\r
- PMessage* BuildNPCMassAliveMsg( u32 nWorldID, u16 nX, u16 nY, u16 nZ, u8 nActionStatus, u8 nHealth, u8 nAction );\r
- PMessage* BuildNPCMassUpdateMsg( u32 nWorldID, u16 nX, u16 nY, u16 nZ, u8 nActionStatus, u8 nHealth, u16 nTarget, u8 nAction );\r
- // Moved here since its a zone broadcast!\r
- PMessage* BuildNpcCleanupMsg( u32 nNpcId, u8 nCmd = 6 ); // see implementation about nCmd\r
-
-// 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 );\r
- PMessage* BuildTryAccessAnswerMsg(PClient* nClient, char *nArea, bool nAllowed);\r
- PMessage* BuildReceiveDBAnswerMsg( PClient* nClient, PMessage* nResultBuffer, std::string* nCommandName, u16 nNumRows, u16 nNumFields);\r
- PMessage* BuildYouGotEmailsMsg( PClient* nClient, u8 nMailCount );\r
- \r
- PMessage* BuildNPCStartDialogMsg( PClient* nClient, u32 nNPCWorldID, std::string *nDialogScript );\r
- PMessage* BuildNPCDialogReplyMsg( PClient* nClient, u16 nNextNode, std::vector<int>*nResultBuffer);\r
- PMessage* BuildReqNPCScriptAnswerMsg( u32 nInfoId, std::string *nNPCScript );\r
- PMessage* BuildNPCShoppingListMsg( PClient* nClient, PMessage* nContentList, int nWorldID, u8 nItemQuality);\r
- PMessage* BuildNPCBeginAllBuyerTradeMsg( PClient* nClient, int nWorldID );\r
- \r
- 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);\r
- PMessage* BuildNPCSingleAliveMsg( PClient* nClient, u32 nWorldID, u16 nX, u16 nY, u16 nZ, u8 nActionStatus, u8 nHealth, u8 nAction );\r
- PMessage* BuildNPCSingleUpdateMsg( PClient* nClient, u32 nWorldID, u16 nX, u16 nY, u16 nZ, u8 nActionStatus, u8 nHealth, u16 nTarget, u8 nAction );\r
- \r
- // NEW for testing. Combined update message\r
- PMessage* BuildNPCUpdateMsg(u32 nWorldID, u16 nPosY, u16 nPosZ, u16 nPosX, u8 nActionBM, u16 nHealth, u8 nWeaponState, u8 nUnknown, u32 nTargetID = 0);\r
- \r
- 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
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- msgdecoder.h - top class for NC messages decoding\r
-\r
- CREATION: 23 Aug 2006 Hammag\r
-\r
- MODIFIED:\r
- REASON: -\r
-\r
-*/\r
-\r
-#ifndef MSGDECODER_H\r
-#define MSGDECODER_H\r
-\r
-struct PGameState;\r
-class PClient;\r
-class PMessage;\r
-class PUdpMsgAnalyser;\r
-\r
-#define DECODE_UNDEF 0\r
-#define DECODE_ERROR 1 // one error occured on the current decoding step\r
-#define DECODE_UNKNOWN 2 // the current decoded (sub)message is unkown\r
-#define DECODE_MORE 4 // more decoding needed for the (sub)message\r
-#define DECODE_FINISHED 8 // decoding if finished for the whole message\r
-#define DECODE_ACTION_READY 16 // an action is ready to be done\r
-#define DECODE_ACTION_DONE 32 // the action triggered hasn't to be triggered again\r
-#define DECODE_ACTION_IGNORED 64 // the action wasn't performed for some (good) reason (to combine or not with DONE)\r
-#define DECODE_ACTION_FAILED 128 // the action failed totally or partially (to combine or not with DONE)\r
-\r
-\r
-struct PMsgDecodeData\r
-{\r
- PMessage* mMessage;\r
- PClient* mClient;\r
- u8 mState;\r
- u8 mUnknownType;\r
- bool mHandling0x13Sub;\r
- u16 Sub0x13Start;\r
- u16 Sub0x13StartNext;\r
- std::stringstream mName;\r
- std::string mErrorDetail;\r
- bool mTraceKnownMsg;\r
- bool mTraceUnknownMsg;\r
- bool mTraceDump;\r
- PGameState* mClientState; // Temporary until State is put back in Client object\r
-};\r
-\r
-// UDP Message decoder\r
-// boolean methods return true if successful\r
-\r
-class PUdpMsgDecoder\r
-{\r
- private:\r
- PMsgDecodeData mDecodeData;\r
- PUdpMsgAnalyser* mCurrentAnalyser;\r
- std::string mPacketName;\r
- std::string mTmpName;\r
-\r
- void Init(PMessage* nMessage, PClient* nClient);\r
-\r
- public:\r
- PUdpMsgDecoder();\r
- PUdpMsgDecoder(PMessage* nMessage, PClient* nClient);\r
- ~PUdpMsgDecoder();\r
- \r
- bool Analyse();\r
- bool Analyse(PMessage* nMessage, PClient* nClient); // Can be used on non initialized or already used object\r
- // Temporary form until State is put back in Client object\r
- inline void Init(PMessage* nMessage, PClient* nClient, PGameState *nClientState) { mDecodeData.mClientState = nClientState; Init(nMessage, nClient); }\r
- inline u8 GetState() { return mDecodeData.mState; }\r
- inline bool IsError() { return (mDecodeData.mState & DECODE_ERROR); }\r
- inline bool IsKnown() { return (!(mDecodeData.mState & DECODE_UNKNOWN)); }\r
- inline bool MoreSubMsg() { return mDecodeData.mHandling0x13Sub; }\r
- inline bool IsActionReady() { return (mDecodeData.mState & DECODE_ACTION_READY); }\r
- inline bool IsActionDone() { return (mDecodeData.mState & DECODE_ACTION_DONE); }\r
- inline bool IsTraceKnownMsg() { return mDecodeData.mTraceKnownMsg; }\r
- inline bool IsTraceUnknownMsg() { return mDecodeData.mTraceUnknownMsg; }\r
- inline bool IsTraceDump() { return mDecodeData.mTraceDump; }\r
- inline void DumpMsg() { if (mDecodeData.mMessage) mDecodeData.mMessage->Dump(); }\r
- inline std::string const &GetName() { return (mTmpName = mDecodeData.mName.str()); }\r
- inline std::string const &GetError() { return mDecodeData.mErrorDetail; }\r
- bool DoAction();\r
- inline void Reset() { Init(NULL, NULL); }\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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<s_MessageChunk> 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<u8, s_SequenceEntry> PMultipartMap; // Map of all vectors, indexed by sequencenumber <u8>
-
-
-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
+++ /dev/null
-/*
-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<u32, s_f32coords*> 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
+++ /dev/null
-/*
-TinNS (TinNS is not a Neocron Server)
-Copyright (C) 2005 Linux Addicted Community
-maintainer Akiko <akiko@gmx.org>
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public 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
-};
-
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- rconsole.h\r
-\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL\r
-*/\r
-\r
-#ifndef RCONSOLE_H\r
-#define RCONSOLE_H\r
-\r
-#ifdef _MSC_VER\r
- #pragma once\r
-#endif\r
-\r
-class PRConsole\r
-{\r
- private :\r
- typedef std::list<struct PRConClient*> ClientList;\r
- ClientList mClients;\r
-\r
- void ProcessClient(PRConClient* Client);\r
- void Prompt(PRConClient *Client);\r
- public :\r
- PRConsole();\r
- ~PRConsole();\r
-\r
- void Start();\r
- void Update();\r
-};\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- server.h\r
-\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL\r
-*/\r
-\r
-#ifndef SERVER_H\r
-#define SERVER_H\r
-\r
-class PServer\r
-{\r
- private :\r
- int mMaxClients;\r
- int mGMSlots;\r
- int mNumClients;\r
- std::vector<PClient*> mClients;\r
- protected :\r
- public :\r
- PServer();\r
- ~PServer();\r
-\r
- inline int GetMaxClients() const { return mMaxClients; }\r
- inline int GetGMSlots() const { return mGMSlots; }\r
- inline int GetNumClients() const { return mNumClients; }\r
- int NewClient();\r
- PClient *GetClient(int Client) const;\r
- void Update();\r
- void Shutdown();\r
-};\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- sql.h - handles all mysql interactions\r
-\r
- Authors:\r
- - Namikon\r
- - bakkdoor\r
-\r
- MODIFIED: 24 Dec 2005 Namikon\r
- REASON: - initial release by Namikon\r
- MODIFIED: 26 Dec 2005 Namikon\r
- REASON: - Added GetWorldDoorType() for door interaction\r
- - Added GetWorldItemType() for item interaction\r
- - Added FmtTxt() for printf() like parsing of text\r
- - Added GetWorldItemOption() for item interaction\r
- MODIFIED: 30 Dec 2005 bakkdoor\r
- REASON: - changed mysql_init() parameter to null to prevent segfault\r
- - added checking for dbHandle to prevent segfault\r
- MODIFIED: 07 Jul 2006 Hammag \r
- REASON: - Added GetLastGameInsertId() and GetLastInfoInsertId() \r
- MODIFIED: 26 Jul 2006 Hammag \r
- REASON: - Added CheckResCount() for DB Res memory leak tracking (to be done in the main loop)\r
- rather than through Info/GameResQuery()\r
- - fixed InfoDBInuse and GameDBInuse updating\r
- - inhibited Info/GameDBInuse warning message in Info/GameResQuery()\r
- MODIFIED: 27 Sep 2006 Hammag \r
- REASON: - Added GetAptLocation() method\r
- MODIFIED: 12 Oct 2006 Hammag \r
- REASON: - Added Update() method\r
- - added mKeepaliveDelay and mLastKeepaliveSent members\r
- MODIFIED: 25 Jun 2007 Hammag\r
- REASON: - Moved all Appartements related methods to PAppartements class\r
- \r
- TODO: take all non-pure SQL DB access stuff out of this class \r
-*/\r
-\r
-#ifndef MYSQL_H\r
-#define MYSQL_H\r
-\r
-class PMySQL\r
-{\r
- private:\r
- int info_port;\r
- char info_host[100];\r
- char info_userName[100];\r
- char info_password[100];\r
- char info_database[100];\r
- MYSQL *info_dbHandle;\r
- std::time_t mKeepaliveDelay;\r
- std::time_t mLastKeepaliveSent;\r
-\r
- int game_port;\r
- char game_host[100];\r
- char game_userName[100];\r
- char game_password[100];\r
- char game_database[100];\r
- MYSQL *game_dbHandle;\r
-\r
- int GameDBInuse;\r
- int InfoDBInuse;\r
-\r
- public:\r
- PMySQL();\r
- ~PMySQL();\r
-\r
- void Update();\r
- void CheckResCount();\r
- \r
- inline MYSQL *GetInfoHandle() { return info_dbHandle; };\r
- inline MYSQL *GetGameHandle() { return game_dbHandle; };\r
-\r
- bool Connect();\r
-\r
- int InfoQuery(const char *query);\r
- MYSQL_RES *InfoResQuery(const char *query);\r
- int GameQuery(const char *query);\r
- MYSQL_RES *GameResQuery(const char *query);\r
-\r
- /*int GetWorldItemType(unsigned short ID, int Location);\r
- int GetWorldItemOption(unsigned short ID, int Location, int option);\r
- int GetWorldDoorType(unsigned int ID, int Location);*/\r
- \r
- void ShowInfoSQLError();\r
- void ShowGameSQLError();\r
- void FreeGameSQLResult(MYSQL_RES *res);\r
- void FreeInfoSQLResult(MYSQL_RES *res);\r
- \r
- inline u32 GetLastGameInsertId() { return mysql_insert_id(game_dbHandle); };\r
- inline u32 GetLastInfoInsertId() { return mysql_insert_id(info_dbHandle); };\r
- \r
- u32 EscapeString(const char* nText, char* dText, u32 dMaxLength);\r
-};\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- subway.h - subway class\r
-\r
- MODIFIED: 9 Nov 2007 Hammag\r
- REASON: - creation\r
- \r
-*/\r
-\r
-#ifndef SUBWAY_H\r
-#define SUBWAY_H\r
-\r
-class PSubway\r
-{\r
- friend class PMsgBuilder;\r
-\r
- struct PSubwayInfo\r
- {\r
- u16 mVhcId;\r
- u16 mPosition;\r
- u8 mDoorOpened;\r
- u32 mSeatUsersId[4];\r
- };\r
-\r
- public:\r
- static const u16 mCabsNumber = 11;\r
- static const u32 mCabsBaseId = 0x03f2;\r
- static const u32 mCabsBaseHealth = 100; //should take that from .def instead...\r
- static const u8 mStationsNumber = 8;\r
- \r
- private:\r
- static const u16 mSubwayInitData [];\r
- static const u32 mCabLoopTime;\r
- static const u32 mCab0TimeOffset;\r
- static const s32 mTimingAdjust;\r
- static const u32 mCabIntervalTime;\r
- static const u32 mOpenDoorOffset [];\r
- static const u32 mOpenDoorDuration [];\r
- static const char* mSubwayStationName [];\r
- static PCharCoordinates mCabExitPositions [2][mStationsNumber];\r
- \r
- PSubwayInfo mSubways[mCabsNumber];\r
-\r
-public: \r
- bool GetInfoIndex(u32 nVhcId, u8 *Index = NULL);\r
- \r
- public:\r
- PSubway();\r
- //~PSubway();\r
- \r
- inline bool IsValidSubwayCab(u32 nVhcId) {return GetInfoIndex(nVhcId); }\r
- bool UpdateInfo(u32 nVhcId, u16 nPosition, u8 nDoorOpened);\r
- u16 GetPosition(u32 nVhcId);\r
- \r
- u32 GetTimeOffset(u32 nVhcId, u32 nTime);\r
- u8 GetStation(u32 nVhcId, u32 nTime, u32* TimeOffset = NULL);\r
- bool IsDoorOpen(u32 nVhcId, u32 nTime);\r
- std::string* GetStationName(u8 nStationId);\r
- bool GetStationExitPosition(PCharCoordinates* nPosition, u8 nStationId, f32 nCoef = 0.5);\r
- \r
- u8 GetFreeSeat(u32 nVhcId);\r
- bool SetSeatUser(u32 nVhcId, u8 nSeat, u32 nCharId);\r
- bool UnsetSeatUser(u32 nVhcId, u8 nSeat, u32 nCharId);\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- terminal.h - Management class for Terminal actions (Citycom, keys, vehicledepot, ...)\r
-\r
- MODIFIED: 08 Jan 2007 Namikon\r
- REASON: - Created\r
-\r
-*/\r
-\r
-#ifndef TERMINAL_H\r
-#define TERMINAL_H\r
-\r
-class PTerminal\r
-{\r
- private:\r
- void SendTryAccessAnswer(PClient* nClient, char *nArea, bool nAllowed);\r
- char mSQLQuery[500];\r
-\r
- int mResultFields;\r
- void EraseVars();\r
-\r
- char mConPrefix[50];\r
-\r
- inline bool ChkOpt(u8 nNumOptions, u8 nReqOpt) { if(nNumOptions < nReqOpt) return false; else return true; };\r
- bool DoStockXCheck(PClient* nClient, int nAmountEntered, int nNewAmount);\r
-\r
- public:\r
- PTerminal();\r
- //~PTerminal();\r
- // Check accesslevel of Player for various Terminal actions\r
- bool CheckAccess(PClient* nClient, char *nArea, u16 nCmdNr, char *nOption1, char *nOption2, char *nOption3);\r
- u8 GetNewEmailCount(PClient* nClient, bool nNoticeClient = true);\r
- // Handle ReceiveDB queries\r
- bool HandleQueryDB(PClient* nClient, std::string *nDBCommandName, std::string *nCommandName, std::string *nOptions, u8 nNumOptions);\r
- bool HandleReceiveDB(PClient* nClient, u16 mTerminalSessionId, std::string *nCommandName, std::string *nOptions, u8 nNumOptions, u16 nDBID, u8 nUnknown);\r
- bool HandleTryAccess(PClient* nClient, u16 mTerminalSessionId, std::string *nCommandName, std::string *nOptions, u8 nNumOptions, u16 nDBID, u8 nUnknown, bool nCheckOnly = false);\r
- bool HandleUpdateDB(PClient* nClient, u16 mTerminalSessionId, std::string *nCommandName, std::string *nOptions, u8 nNumOptions, u16 nDBID, u8 nUnknown);\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- vehicle.h - Vehicle handling\r
-\r
- Authors:\r
- - Namikon\r
-\r
- MODIFIED: 08 Jan 2006 Namikon\r
- REASON: - initial release by Namikon\r
-*/\r
-\r
-#ifndef VEHICLE_H\r
-#define VEHICLE_H\r
-\r
-class PDefVhc;\r
-\r
-class PVhcCoordinates\r
-{\r
- friend class PSpawnedVehicle;\r
-\r
- private:\r
- u16 mY; // Y-Position in world\r
- u16 mZ; // Z-Position in world\r
- u16 mX; // X-Position in world\r
- u8 mUD; // Up - Mid - Down (d6 - 80 - 2a) // Pitch\r
- u16 mLR; // Yaw\r
- u16 mRoll;\r
- u16 mUnknown; // Usually 0x0001\r
- u8 mFF; // Usually 0xff ...\r
- u8 mAct; // Last user action state\r
- // mAct: bit field\r
- //0x00 = not moving\r
- //0x01 = Left\r
- //0x02 = Right\r
- //0x04 = Forward\r
- //0x08 = Back\r
- //0x20 = Pushing down\r
- //0x40 = Pulling up\r
-\r
- public:\r
- inline PVhcCoordinates() { mX = mY = mZ = mAct = 0; mUD = 128; mLR = 34683; mRoll = 32403;}\r
-\r
- void SetPosition( u16 nY, u16 nZ, u16 nX, u8 nUD, u16 nLR, u16 nRoll, u8 nAct = 0, u16 nUnknown = 1, u8 nFF = 0xff );\r
- void SetInterpolate( const PVhcCoordinates& Pos1, const PVhcCoordinates& Pos2, f32 nCoef );\r
- inline u16 GetX() const { return mX; }\r
- inline u16 GetY() const { return mY; }\r
- inline u16 GetZ() const { return mZ; }\r
- inline u8 GetUD() const { return mUD; }\r
- inline u16 GetLR() const { return mLR; }\r
- inline u16 GetRoll() const { return mRoll; }\r
- inline u8 GetAct() const { return mAct; }\r
- inline u8 GetUnknown() const { return mUnknown; }\r
- inline u8 GetFF() const { return mFF; }\r
-};\r
-\r
-class PVehicleInformation\r
-{\r
- friend class PSpawnedVehicle;\r
- friend class PVehicles;\r
-\r
- private:\r
- u32 mVehicleId;\r
- u32 mOwnerCharId;\r
- u32 mHealth; // or f32 ???\r
- u8 mVehicleType;\r
- u8 mStatus; //vhcStatus 0:parking, 1:in_service, 2:destroyed\r
-\r
- public:\r
- inline PVehicleInformation( u32 nVehicleId = 0, u32 nOwnerCharId = 0, u32 nHealth = 0, u8 nVehicleType = 0, u8 nStatus = 0 ) :\r
- mVehicleId( nVehicleId ),\r
- mOwnerCharId( nOwnerCharId ),\r
- mHealth( nHealth ),\r
- mVehicleType( nVehicleType ),\r
- mStatus( nStatus )\r
- { }\r
-\r
- inline u32 GetVehicleId() const { return mVehicleId; }\r
- inline u32 GetOwnerCharId() const { return mOwnerCharId; }\r
- inline u32 GetHealth() const { return mHealth; } // or f32 ???\r
- inline u8 GetVehicleType() const { return mVehicleType; }\r
- inline u8 GetStatus() const { return mStatus; }\r
- bool SetStatus( u8 nStatus );\r
-\r
- bool Load( u32 nVehicleId );\r
- bool Save();\r
- bool Destroy();\r
-};\r
-\r
-class PSpawnedVehicle\r
-{\r
- private:\r
- static const u8 mSeatsFlags[];\r
-\r
- private:\r
- u32 mLocalId;\r
- PVehicleInformation mInfo;\r
- u32 mLocation;\r
- PVhcCoordinates mCoords;\r
- const PDefVhc* mVhcDef;\r
-\r
- u32 mSeatUserId[8];\r
- u8 mFreeSeatsFlags;\r
- u8 mNbFreeSeats;\r
-\r
- u16 minmax[4][2]; //Temp\r
-\r
- public:\r
- PSpawnedVehicle( u32 nLocalId, PVehicleInformation const* nVhcInfo, u32 nLocation, PVhcCoordinates const* nVhcPos );\r
-\r
- inline u32 GetVehicleId() const { return mInfo.mVehicleId; }\r
- inline u32 GetLocalId() const { return mLocalId; }\r
- inline const PVhcCoordinates& GetPosition() const { return mCoords; }\r
- inline const PVehicleInformation& GetInformation() const { return mInfo; }\r
- inline bool SetStatus( u8 nStatus ) { return mInfo.SetStatus( nStatus ); }\r
-\r
- void SetLocation( u32 nLocation );\r
- inline u32 GetLocation() const { return mLocation; }\r
- void SetPosition( PVhcCoordinates const* nVhcPos );\r
-\r
- inline bool Save() { return mInfo.Save(); }\r
-\r
- int GetNumSeats() const;\r
- inline u32 GetSeatUser( u8 nSeatId ) const { return (( nSeatId < 8 ) ? mSeatUserId[nSeatId] : 0 ); }\r
- bool SetSeatUser( u8 nSeatId, u32 nCharId );\r
- bool UnsetSeatUser( u8 nSeatId, u32 nCharId );\r
- bool IsCharInside( u32 nCharId ) const;\r
- inline u8 GetFreeSeatsFlags() const { return mFreeSeatsFlags; }\r
- inline u8 GetNbFreeSeats() const { return mNbFreeSeats; }\r
- u8 GetFirstFreeSeat() const;\r
-\r
- //SetHealth(const u32 nHealth);\r
- //u32 DoDamage(const u32 nHealthDec);\r
- //u32 DoRepair(const u32 nHealthInc);\r
-};\r
-\r
-typedef std::map<u32, PSpawnedVehicle*> PSpawnedVhcMap;\r
-typedef std::queue<PVehicleInformation*> PVhcInfoList;\r
-class PVehicles\r
-{\r
- private:\r
- PSpawnedVhcMap mSpawnedVehicles;\r
-\r
- bool RegisterSpawnedVehicle( PSpawnedVehicle* nSpawnedVehicle );\r
- bool UnregisterSpawnedVehicle( u32 nVehicleId );\r
-\r
- public:\r
- PVehicles();\r
- ~PVehicles();\r
-\r
- //u32 CreateVehicle(u32 nOwnerChar, u8 mVehicleType);\r
- //bool RegisterVehicleOwner(u32 nVehiculeId, u32 nOwnerChar);\r
- //bool DestroyVehicle(u32 nVehiculeId);\r
- bool IsValidVehicle( u32 nVehicleId, bool nCheckOwner = false, u32 nOwnerId = 0 ) const;\r
- inline bool IsSpawned( u32 nVehicleId ) const { return ( mSpawnedVehicles.find( nVehicleId ) != mSpawnedVehicles.end() ); }\r
- PSpawnedVehicle* GetSpawnedVehicle( u32 nVehicleId ) const;\r
- bool GetVehicleInfo( u32 nVehicleId, PVehicleInformation* nInfo ) const;\r
- PSpawnedVehicle* SpawnVehicle( u32 nVehicleId, u32 nLocation, PVhcCoordinates const* nVhcPos ); // Refuses for subway zone atm\r
- bool UnspawnVehicle( u32 nVehicleId );\r
-\r
- PVhcInfoList* GetCharVehicles( u32 nCharId, u16 nMaxCount = 0, u16 nStartIndex = 0 );\r
-\r
-};\r
-\r
-typedef std::vector<PSpawnedVehicle*> PSpawnedVhcVector;\r
-typedef std::queue<PSpawnedVehicle*> PSpawnedVhcList;\r
-\r
-class PSpawnedVehicles\r
-{\r
- friend class PWorld;\r
-\r
- public:\r
- 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\r
- static const u16 mMaxLocalVhc = 127;\r
-\r
- inline static bool IsPotentialSpawnedVehicle( u32 nLocalId )\r
- { return (( nLocalId <= mVhcBaseLocalId ) && (( mVhcBaseLocalId - nLocalId ) < mMaxLocalVhc ) ); }\r
-\r
- private:\r
- PSpawnedVhcVector mSpawnedVehicles;\r
- u16 mNextFreeHint;\r
- u32 mLocation;\r
-\r
- inline void SetLocation( u32 nLocation ) { mLocation = nLocation; }\r
-\r
- public:\r
- PSpawnedVehicles();\r
- ~PSpawnedVehicles();\r
-\r
- inline bool IsSpawned( u32 nLocalId ) const { return (( nLocalId <= mVhcBaseLocalId ) && (( mVhcBaseLocalId - nLocalId ) < mSpawnedVehicles.size() ) && mSpawnedVehicles[mVhcBaseLocalId-nLocalId] ); }\r
- PSpawnedVehicle* SpawnVehicle( PVehicleInformation const* nVhcInfo, PVhcCoordinates const* nVhcPos );\r
- PSpawnedVehicle* GetVehicle( u32 nLocalId );\r
- PSpawnedVehicle* GetVehicleByGlobalId( u32 nVehicleId ) const;\r
- bool UnspawnVehicle( u32 nVehicleId );\r
-\r
- PSpawnedVhcList* GetSpawnedVehicles() const;\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*
- 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<u32, PVhcAccessRequest> 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
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- world_datparser.h\r
- Class to parse .dat world files\r
-\r
- MODIFIED: 29 Sep 2006 Hammag\r
- REASON: - Creation\r
-*/\r
-\r
-#ifndef WORLD_DATPARSER_H\r
-#define WORLD_DATPARSER_H\r
-\r
-class PFile;\r
-class PWorldDataTemplate;\r
-\r
-class PWorldDatParser\r
-{\r
-private :\r
- PFile* f;\r
- std::string mNCDataPath;\r
-\r
- PWorldDataTemplate* mWorld;\r
- bool mDiscardPassiveObjects;\r
-\r
- bool ProcessSec2ElemType3(u32 nSize);\r
- bool ProcessSec2ElemType5(u32 nSize);\r
- bool ProcessSec2NPCEntry(u32 nSize);\r
-\r
-public :\r
- PWorldDatParser();\r
- ~PWorldDatParser();\r
-\r
- int LoadDatFile(const std::string& nFilename, PWorldDataTemplate* nWorld, const bool nDiscardPassiveObjects = true, const bool nTestAccesOnly = false);\r
-\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-/*\r
- worlddatatemplate.cpp - world data template (from worlds .dat files) class\r
-\r
- MODIFIED: 04 Oct 2006 Hammag\r
- REASON: - creation\r
-\r
- MODIFIED: 21 Jun 2009 Namikon\r
- REASON: - Added NPC Template stuff\r
-\r
-*/\r
-\r
-\r
-#ifndef WORLDDATATEMPLATE_H\r
-#define WORLDDATATEMPLATE_H\r
-\r
-#define WORLDDATATEMPLATE_MAXPOSITEMS 11\r
-\r
-class PFurnitureItemTemplate;\r
-typedef std::map<u32, PFurnitureItemTemplate*> PFurnitureItemsMap;\r
-\r
-class PDoorTemplate;\r
-typedef std::map<u32, PDoorTemplate*> PDoorsMap;\r
-\r
-class PNPCTemplate;\r
-typedef std::map<u32, PNPCTemplate*> PNPCsMap;\r
-\r
-class PWorldDataTemplate\r
-{\r
-private:\r
- std::string mName; // (datfile) relative path+filename without leading ./ or ./worlds/ nor .dat extension\r
- std::string mBspName; // (bsp file) relative path+filename without leading ./ or ./worlds/ nor .bsp extension\r
- PFurnitureItemsMap mFurnitureItems;\r
- PDoorsMap mDoors;\r
- PNPCsMap mNPCs;\r
- PFurnitureItemTemplate* mPositionItems[WORLDDATATEMPLATE_MAXPOSITEMS];\r
-\r
- int mUseCount;\r
-\r
- void DatFileDataCleanup();\r
- void SetLinkedObjects(); // This method implements some workarouds for some world objects on which we lack info.\r
-\r
-public:\r
- PWorldDataTemplate();\r
- ~PWorldDataTemplate();\r
-\r
- bool LoadDatFile(const std::string& WorldTemplateName, const std::string& nFilename, const bool nTestAccesOnly = false);\r
- inline const std::string& GetName()\r
- {\r
- return mName;\r
- }\r
- inline const std::string& GetBspName()\r
- {\r
- return mBspName;\r
- }\r
-\r
- inline void IncreaseUseCount()\r
- {\r
- ++mUseCount;\r
- }\r
- inline int DecreaseUseCount()\r
- {\r
- return (mUseCount ? --mUseCount : 0);\r
- }\r
- inline int GetUseCount()\r
- {\r
- return mUseCount;\r
- }\r
-\r
- u32 AddFurnitureItem(PFurnitureItemTemplate* nItem);\r
- const PFurnitureItemTemplate* GetFurnitureItem(u32 ItemID);\r
- bool getPositionItemPosition(u8 PosID, f32* pX, f32* pY, f32* pZ);\r
-\r
- u32 AddDoor(PDoorTemplate* nDoor);\r
- const PDoorTemplate* GetDoor(u32 DoorID);\r
-\r
- u32 AddNPC(PNPCTemplate* nNPC);\r
-\r
- // External functions for NPCManager\r
- const PNPCTemplate* GetNPC(u32 NPCID);\r
- inline const PNPCsMap *GetNPCMap() const\r
- {\r
- return &mNPCs;\r
- }; // called by class PNPCWorld to get all NPCs for this world\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*
- 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<u32, int> 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<u32, PWorld*> PWorldsMap;
-typedef std::map<std::string, PWorldDataTemplate*> 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
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- zoning.h\r
-\r
- Authors:\r
- - Namikon\r
-\r
- MODIFIED: XX Dec 2005 Namikon\r
- REASON: - Initial Release\r
- MODIFIED: 23 Dec 2005 Namikon\r
- REASON: - Added GPL\r
- MODIFIED: 28 Jul 2005 Hammag\r
- REASON: - changed loc parameter type from int to u32\r
- \r
-*/\r
-\r
-#ifndef ZONING_H\r
-#define ZONING_H\r
-\r
-//void SendZone(PClient *Client, PGameState *State,int loc);\r
-void SendZone(PClient *Client, u32 loc);\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- item.cpp - item class\r
-\r
- MODIFIED: 11 Jul 2006 Hammag\r
- REASON: - creation\r
- MODIFIED: 09 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
-*/\r
-\r
-\r
-#include "main.h"\r
-\r
-#include "include/item.h"\r
-#include "include/gamedefs.h"\r
-#include "include/def_items.h"\r
-\r
-\r
-PItem::PItem(u32 ItemID, u8 nStackSize, u8 CurDur, u8 MaxDur, u8 Dmg, u8 Freq, u8 Hand, u8 Rng)\r
-{\r
- mDefItem = GameDefs->Items()->GetDef(ItemID);\r
- if (mDefItem) {\r
- mItemID = ItemID;\r
- mStackable = mDefItem->IsStackable();\r
- mStackSize = mStackable ? nStackSize : 1;\r
-\r
- mLoadedAmmoId = 0;\r
- mLoadedAmmoNb = 0;\r
-\r
- mPropertiesFlags = 0;\r
-\r
- mUsedSlots = mMaxSlots = 0;\r
- mModificators = 0;\r
- \r
- mConstructorId = 0;\r
- //mType = mDefItem->GetType();\r
- //mValue1 = mDefItem->GetValue1();\r
- //mValue2 = mDefItem->GetValue2();\r
- //mValue3 = mDefItem->GetValue3();\r
- //mSizeX = mDefItem->GetSizeX();\r
- //mSizeY = mDefItem->GetSizeY(); \r
- //mWeight = mDefItem->GetWeight();\r
- //mFillWeight = mDefItem->GetFillWeight();\r
- //mQualifier = mDefItem->GetQualifier();\r
- //mItemGroupID = mDefItem->GetItemGroupID(); \r
- //mBasePrice = mDefItem->GetBasePrice();\r
- //mTechlevel = mDefItem->GetTechlevel();\r
- //mItemflags = mDefItem->GetItemflags();\r
-\r
- //if (!mStackable) // only non-stackable items can have quality stats (?)\r
- //{\r
- // mStackSize = 1;\r
- mCurDuration = CurDur;\r
- mMaxDuration = MaxDur;\r
- mDamages = Dmg;\r
- mFrequency = Freq;\r
- mHandling = Hand;\r
- mRange = Rng;\r
- //}\r
- }\r
- else\r
- {\r
- mItemID = 0;\r
- Console->Print(YELLOW, BLACK, "PItem::PItem: Invalid item ID %d", ItemID);\r
- }\r
-}\r
-\r
-void PItem::MakeItemStandard(u8 GlobalQualityMin, u8 GlobalQualityMax)\r
-{\r
- if(GlobalQualityMin > GlobalQualityMax) GlobalQualityMin = GlobalQualityMax;\r
-\r
- mCurDuration = 255;\r
- mMaxDuration = 255;\r
- if(GlobalQualityMin == GlobalQualityMax)\r
- {\r
- mDamages = GlobalQualityMin;\r
- mFrequency = GlobalQualityMin;\r
- mHandling = GlobalQualityMin;\r
- mRange = GlobalQualityMin;\r
- }\r
- else\r
- {\r
- mDamages = (u8) GetRandom(GlobalQualityMax, GlobalQualityMin);\r
- mFrequency = (u8) GetRandom(GlobalQualityMax, GlobalQualityMin);\r
- mHandling = (u8) GetRandom(GlobalQualityMax, GlobalQualityMin);\r
- mRange = (u8) GetRandom(GlobalQualityMax, GlobalQualityMin);\r
- }\r
- \r
-}\r
-\r
-u8 PItem::AddToStack(u8 ItemNb) // returns nb of items not added\r
-{\r
- u8 addedItems = 0;\r
- if (mStackable)\r
- {\r
- addedItems = (ItemNb <= (MAX_ITEMSTACK_SIZE - mStackSize)) ? ItemNb : (MAX_ITEMSTACK_SIZE - mStackSize);\r
- mStackSize += addedItems;\r
- }\r
- return (ItemNb - addedItems);\r
-}\r
-\r
-u8 PItem::TakeFromStack(u8 ItemNb)\r
-{\r
- u8 retreivedItems = 0;\r
- if (mStackable)\r
- {\r
- retreivedItems = std::min(mStackSize, ItemNb);\r
- mStackSize -= retreivedItems;\r
- }\r
- return retreivedItems; \r
-}\r
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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 <csignal> & 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;
-}
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- main.h - main include file, contains all needed includes and important definitions\r
-\r
- MODIFIED: 31 Aug 2005 Akiko\r
- REASON: - updating def file definitions to match the changes in gamedefs.cpp\r
- - added define for charfiles path\r
- - added define for database path\r
- MODIFIED: 26 Sep 2005 Akiko\r
- REASON: - reformated code\r
- - added GPL\r
- - added infoserver default port as define\r
- - added my threading model (mutex.h, semaphore.h, thread.h)\r
- - added basic includes pthread.h, semaphore.h and errno.h\r
- MODIFIED: 28 Sep 2005 Akiko\r
- REASON: - added define for game server port\r
- MODIFIED: 30 Nov 2005 Akiko\r
- REASON: - added chat.h for the chat part from Namikon\r
- MODIFIED: 02 Dec 2005 Akiko\r
- REASON: - commented out mutex.h, thread.h, semaphore.h\r
- MODIFIED: 22 Dec 2005 Namikon/bakkdoor\r
- REASON: - Added commands.h, skill.h, clientmanager.h\r
- MODIFIED: 23 Dec 2005 bakkdoor\r
- REASON: - Added <csignal> for main.cpp -> catch strg-c and shutdown nicely\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added mysql.h, sql.h for MySQL support\r
- MODIFIED: 01 Jan 2006 Namikon\r
- REASON: - Moved skill.h before chars.h (char.h needs skill.h now)\r
- MODIFIED: 30 May 2006 Namikon\r
- REASON: - Removed all useless includes to complete the server splitup; Also renamed tinns.h to main.h\r
- MODIFIED: 6 Jul 2006 Hammag\r
- REASON: - moved include "types.h" before include "../netcode/main.h" to permit compile\r
- MODIFIED: 10 Jul 2006 Hammag\r
- REASON: - added inventory.h\r
- REASON: - added item.h\r
- MODIFIED: 26 Jul 2006 Hammag\r
- REASON: - removed #define GAME_PORT which is not used anymore (now in config file)\r
- MODIFIED: 09 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
- - cleaned up a bit\r
-*/\r
-\r
-#ifndef MAIN_H\r
-#define MAIN_H\r
-\r
-//#include "version.h"\r
-\r
-//basic includes\r
-#include "include/external.h"\r
-\r
-//tinns includes\r
-#include "include/types.h"\r
-#include "common/netcode.h"\r
-/*\r
-#include "../gamemonkey/gmMachine.h"\r
-#include "../gamemonkey/gmCall.h"\r
-*/\r
-#include "common/console.h"\r
-#include "common/misc.h"\r
-\r
-// MySQL Support\r
-#ifdef MYSQL_INC_DIR\r
-#include <mysql/mysql.h>\r
-#else\r
-#include <mysql.h>\r
-#endif\r
-\r
-#include "include/sql.h"\r
-\r
-#include "common/config.h"\r
-#include "common/filesystem.h"\r
-#include "include/defparser.h"\r
-\r
-#include "include/skill.h"\r
-#include "include/chars.h"\r
-#include "include/accounts.h"\r
-#include "include/client.h"\r
-#include "include/server.h"\r
-#include "include/gameserver.h"\r
-#include "include/globals.h"\r
-#include "include/defs.h"\r
-#include "include/zoning.h"\r
-#include "include/item.h"\r
-#include "include/inventory.h"\r
-#include "include/worldactors.h"\r
-#include "include/npc.h"\r
-#include "include/outpost.h"\r
-#include "include/multipart.h"\r
-#include "include/terminal.h"\r
-\r
-#include "include/lua_engine.h"\r
-#include "include/chat.h"\r
-#include "include/commands.h"\r
-#include "include/clientmanager.h"\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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 )\r
- {\r
- PMessage* tmpMsg;\r
- \r
- tmpMsg = new PMessage();\r
- \r
- *tmpMsg << ( u8 )0x19;\r
- *tmpMsg << ( u16 )0x0006; // InfoQuery\r
- *tmpMsg << ( u16 )0x0003; // NPC Script\r
- *tmpMsg << ( u32 )nInfoId;\r
- *tmpMsg << nNPCScript->c_str();\r
- \r
- return tmpMsg;\r
- \r
- }\r
- \r
-PMessage* PMsgBuilder::BuildYouGotEmailsMsg( PClient* nClient, u8 nMailCount )\r
- {\r
- PMessage* tmpMsg = new PMessage();\r
- nClient->IncreaseUDP_ID();\r
- \r
- *tmpMsg << ( u8 )0x13;\r
- *tmpMsg << ( u16 )nClient->GetUDP_ID();\r
- *tmpMsg << ( u16 )nClient->GetSessionID();\r
- *tmpMsg << ( u8 )0x0c;\r
- *tmpMsg << ( u8 )0x03;\r
- *tmpMsg << ( u16 )nClient->GetUDP_ID();\r
- *tmpMsg << ( u8 )0x1f;\r
- *tmpMsg << ( u16 )nClient->GetLocalID();\r
- *tmpMsg << ( u8 )0x3d;\r
- *tmpMsg << ( u8 )0x0c;\r
- *tmpMsg << ( u8 )0x00;\r
- *tmpMsg << ( u8 )0x00;\r
- *tmpMsg << ( u8 )0x00;\r
- *tmpMsg << ( u8 )nMailCount;\r
- \r
- return tmpMsg;\r
- }\r
- \r
-PMessage* PMsgBuilder::BuildReceiveDBAnswerMsg( PClient* nClient, PMessage* nResultBuffer, std::string *nCommandName, u16 nNumRows, u16 nNumFields)\r
- {\r
- PMessage* tmpMsg = new PMessage();\r
-/* nClient->IncreaseUDP_ID();\r
- \r
- *tmpMsg << ( u8 )0x13;\r
- *tmpMsg << ( u16 )0x0000;\r
- *tmpMsg << ( u16 )0x0000;\r
- *tmpMsg << ( u8 )0x00;\r
- *tmpMsg << ( u8 )0x03;\r
- *tmpMsg << ( u16 )nClient->GetUDP_ID();\r
- *tmpMsg << ( u8 )0x2b;\r
- *tmpMsg << ( u8 )0x1a;\r
- if(nCommandName->length() > 0)\r
- *tmpMsg << ( u8 )0x01;\r
- else\r
- *tmpMsg << ( u8 )0x00;\r
- \r
- *tmpMsg << ( u8 )0x00;\r
- *tmpMsg << ( u8 )0x00;\r
- *tmpMsg << *nCommandName;\r
- ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 );\r
- \r
- // 2nd message\r
- *tmpMsg << ( u16 )(13 + nCommandName->length() + nResultBuffer->GetSize()); // ??\r
- */\r
- nClient->IncreaseUDP_ID();\r
- \r
- *tmpMsg << ( u8 )0x13;\r
- *tmpMsg << ( u16 )nClient->GetUDP_ID();\r
- *tmpMsg << ( u16 )nClient->GetSessionID();\r
- *tmpMsg << ( u8 )0x00;\r
- *tmpMsg << ( u8 )0x03;\r
- *tmpMsg << ( u16 )nClient->GetUDP_ID();\r
- *tmpMsg << ( u8 )0x2b;\r
- *tmpMsg << ( u8 )0x17;\r
- *tmpMsg << ( u16 )(nCommandName->length()+1);\r
- *tmpMsg << ( u16 )nNumRows;\r
- *tmpMsg << ( u16 )nNumFields;\r
- *tmpMsg << *nCommandName;\r
- *tmpMsg << *nResultBuffer;\r
- \r
- ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 );\r
- \r
- \r
- return tmpMsg;\r
- //len = (unsigned int)strlen(DB);\r
- //SendBuffer[0] = 0x13;\r
- //SendBuffer[5] = 11 + len;\r
- //SendBuffer[6] = 0x03;\r
- //Network_IncrementUDP (ClientNum);\r
- //*(unsigned short*)&SendBuffer[7] = Client_Sockets[ClientNum].UDP_ID;\r
- // SendBuffer[9] = 0x2b;\r
- // SendBuffer[10] = 0x1a;\r
- // *(unsigned short*)&SendBuffer[11] = len;\r
- // if (num == 0)\r
- // SendBuffer[13] = 0x00;\r
- // else\r
- // SendBuffer[13] = 0x01;\r
- // SendBuffer[14] = 0x00;\r
- // SendBuffer[15] = 0x00;\r
- // strcpy (SendBuffer+16, DB);\r
- // plen = 17+len;\r
- \r
- // SendBuffer[plen] = 13+len+slen;\r
- // SendBuffer[plen+1] = 0x03;\r
- // Network_IncrementUDP (ClientNum);\r
- // *(unsigned short*)&SendBuffer[plen+2] = Client_Sockets[ClientNum].UDP_ID;\r
- // *(unsigned short*)&SendBuffer[1] = Client_Sockets[ClientNum].UDP_ID;\r
- // *(unsigned short*)&SendBuffer[3] = Client_Sockets[ClientNum].UDP_ID_HIGH;\r
- // SendBuffer[plen+4] = 0x2b;\r
- // SendBuffer[plen+5] = 0x17;\r
- // *(unsigned short*)&SendBuffer[plen+6] = len+1;\r
- // *(unsigned short*)&SendBuffer[plen+8] = num;\r
- // *(unsigned short*)&SendBuffer[plen+10] = Fields;\r
- // //Fieldnum is defined in each DB below\r
- // strcpy (SendBuffer+plen+12, DB);\r
- // plen += 13+len;\r
- \r
- // for (i=0;i<slen;i++)\r
- // SendBuffer[plen+i] = TempBuffer[i];\r
- \r
- \r
- }\r
- \r
- \r
-PMessage* PMsgBuilder::BuildTryAccessAnswerMsg(PClient* nClient, char *nArea, bool nAllowed)\r
- {\r
- PMessage* tmpMsg = new PMessage();\r
- //u8 i = (u8)strlen(nArea);\r
- \r
- nClient->IncreaseUDP_ID();\r
- \r
- *tmpMsg << (u8)0x13;\r
- *tmpMsg << (u16)nClient->GetUDP_ID();\r
- *tmpMsg << (u16)nClient->GetSessionID();\r
- *tmpMsg << (u8)0x00;\r
- *tmpMsg << (u8)0x03;\r
- *tmpMsg << (u16)nClient->GetUDP_ID();\r
- *tmpMsg << (u8)0x2b;\r
- *tmpMsg << (u8)0x1a;\r
- *tmpMsg << (u16)(strlen(nArea)+1);\r
- \r
- if(nAllowed)\r
- *tmpMsg << (u8)0x01;\r
- else\r
- *tmpMsg << (u8)0x00;\r
- \r
- *tmpMsg << (u8)0x00;\r
- *tmpMsg << (u8)0x00;\r
- *tmpMsg << nArea;\r
- \r
- ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 );\r
- return tmpMsg;\r
- }\r
-
-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;i<MAX_INVENTORY;i++)
- {
- for (t=0;t<128;t++)
- {
- if (CurrentChar.QuickBelt[t]-1 != i)
- continue;
- *(unsigned short*)&StatsBuffer[len+plen] = 6; //Data size of item
- *(unsigned short*)&StatsBuffer[len+plen+2] = t; //X position in Inventory
- *(unsigned short*)&StatsBuffer[len+plen+4] = CurrentChar.ItemList[CurrentChar.QuickBelt[t]-1].ItemID; //Item ID
- *(unsigned short*)&StatsBuffer[len+plen+6] = CurrentChar.ItemList[CurrentChar.QuickBelt[t]-1].Qty; //Quantity
- plen += 8;
- *(unsigned short*)&StatsBuffer[len+3] += 1; //Add to item
- break;
- }
- */
- /*if (CurrentChar.Inventory[i].ItemID == 0) //Last Item
- break;
- if (CurrentChar.Inventory[i].Location != 2) //Not Quickbelt, skip it
- continue;
- if (Def_GetItemType(CurrentChar.Inventory[i].ItemID) == 1)
- {
- //18 00 01 00 08 00 63 00 06 ff c8 c8 c8 c8 ff 00 01 00 28 04 00 01 04 ff 01
- //12 00 11 5f 07 23 00 06 eb a4 99 a3 a5 ff 04 00 01 04 ff 01
- //13 00 05 00 03 02 23 00 06 6d c4 c4 c4 c4 ff 04 00 01 04 ff 00
- //17 00 05 9d 01 73 28 06 13 c1 c1 c1 c1 ff 00 01 01 f1 05 04
- //|Size|Slot|ItemID|??? |? |Du| Stats |MD|?????????????????|
- *(unsigned short*)&StatsBuffer[len+plen] = 19; //Size
- *(unsigned short*)&StatsBuffer[len+plen+2] = CurrentChar.Inventory[i].LocX; //Slot
- *(unsigned short*)&StatsBuffer[len+plen+4] = CurrentChar.Inventory[i].ItemID;//Item ID
- StatsBuffer[len+plen+6] = 0x23; //0x73 = Ranged, 0x63 = close/spell
- StatsBuffer[len+plen+7] = CurrentChar.Inventory[i].Qty; //Quantity
- StatsBuffer[len+plen+8] = 0x06; //0x06
- StatsBuffer[len+plen+9] = CurrentChar.Inventory[i].CurDur; //Current Durability
- StatsBuffer[len+plen+10] = CurrentChar.Inventory[i].Damage; //Stats
- StatsBuffer[len+plen+11] = CurrentChar.Inventory[i].Freq; //Stats
- StatsBuffer[len+plen+12] = CurrentChar.Inventory[i].Hand; //Stats
- StatsBuffer[len+plen+13] = CurrentChar.Inventory[i].Rng; //Stats
- StatsBuffer[len+plen+14] = CurrentChar.Inventory[i].MaxDur; //Max Durability
- StatsBuffer[len+plen+15] = 0x04; //Size or part
- StatsBuffer[len+plen+16] = 0x00; //follow or ?
- StatsBuffer[len+plen+17] = 0x01; //Ammo loaded?
- StatsBuffer[len+plen+18] = 0x04; //0x04 if not named, 0x0a if named
- StatsBuffer[len+plen+19] = 0x05; //0x06 if named, 0xff for no ammo needed, no idea otherwise
- StatsBuffer[len+plen+20] = 0x0f; //Binary representation of ammo allowed 0x01 = normal
- plen+=21;
- }
- else
- {
- *(unsigned short*)&StatsBuffer[len+plen] = 6; //Size of Item Data
- *(unsigned short*)&StatsBuffer[len+plen+2] = CurrentChar.Inventory[i].LocX; //Slot
- *(unsigned short*)&StatsBuffer[len+plen+4] = CurrentChar.Inventory[i].ItemID; //Item ID
- *(unsigned short*)&StatsBuffer[len+plen+6] = CurrentChar.Inventory[i].Qty; //Quantity
- plen+= 8;
- }
- StatsBuffer[len+3] += 1;*/
-
- *BaselineMsg << ( u16 )SectionMsg.GetSize();
- *BaselineMsg << SectionMsg;
- SectionMsg.Reset();
-
- // ---- Section 7 ----
- *BaselineMsg << ( u8 )0x07; // section id
-
- SectionMsg << ( u8 )0x00; // ?? // section content at offset 3
-
- *BaselineMsg << ( u16 )SectionMsg.GetSize();
- *BaselineMsg << SectionMsg;
- SectionMsg.Reset();
-
- // ---- Section 0c ----
- *BaselineMsg << ( u8 )0x0c; // section id
-
- ContentList = BuildContainerContentList( nChar->GetInventory()->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;
-}
- */\r
-// NPC Dialog. Start dialog with NPC\r
-PMessage* PMsgBuilder::BuildNPCStartDialogMsg( PClient* nClient, u32 nNPCWorldID, std::string *nDialogScript )\r
- {\r
- PMessage* tmpMsg = new PMessage();\r
- nClient->IncreaseUDP_ID();\r
- \r
- \r
- *tmpMsg << ( u8 )0x13;\r
- *tmpMsg << ( u16 ) 0x0000; // UDP Placeholder\r
- *tmpMsg << ( u16 ) 0x0000; // UDP Placeholder\r
- *tmpMsg << ( u8 )0x00; // Message length\r
- *tmpMsg << ( u8 )0x03;\r
- *tmpMsg << ( u16 )nClient->GetUDP_ID();\r
- *tmpMsg << ( u8 )0x1f;\r
- *tmpMsg << ( u16 )nClient->GetLocalID();\r
- *tmpMsg << ( u8 )0x18;\r
- *tmpMsg << ( u32 ) nNPCWorldID;\r
- \r
- // Todo: is this correct? random u32 value??\r
- *tmpMsg << ( u16 ) GetRandom( 65535, 4369 );\r
- *tmpMsg << ( u16 ) GetRandom( 65535, 4369 );\r
- *tmpMsg << ( u32 ) 0x0000;\r
- *tmpMsg << nDialogScript->c_str();\r
- ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 );\r
- \r
- nClient->IncreaseUDP_ID();\r
- \r
- *tmpMsg << ( u8 )0x0a;\r
- *tmpMsg << ( u8 )0x03;\r
- *tmpMsg << ( u16 )nClient->GetUDP_ID();\r
- *tmpMsg << ( u8 )0x1f;\r
- *tmpMsg << ( u16 )nClient->GetLocalID();\r
- *tmpMsg << ( u8 )0x1a;\r
- *tmpMsg << ( u8 )0x00;\r
- *tmpMsg << ( u8 )0x00;\r
- *tmpMsg << ( u8 )0x00;\r
- \r
- tmpMsg->U16Data( 1 ) = nClient->GetUDP_ID();\r
- tmpMsg->U16Data( 3 ) = nClient->GetSessionID();\r
- \r
- return tmpMsg;\r
- }\r
-// NPC Dialog. Send next node number in lua script to client\r
-PMessage* PMsgBuilder::BuildNPCDialogReplyMsg( PClient* nClient, u16 nNextNode, std::vector<int>*nResultBuffer)\r
- {\r
- PMessage* tmpMsg = new PMessage();\r
- \r
- nClient->IncreaseUDP_ID();\r
- \r
- *tmpMsg << ( u8 )0x13;\r
- *tmpMsg << ( u16 )nClient->GetUDP_ID();;\r
- *tmpMsg << ( u16 )nClient->GetSessionID();;\r
- *tmpMsg << ( u8 )0x00; // SubMessage length;\r
- \r
- *tmpMsg << ( u8 )0x03;\r
- *tmpMsg << ( u16 )nClient->GetUDP_ID();;\r
- *tmpMsg << ( u8 )0x1f;\r
- *tmpMsg << ( u16 )nClient->GetLocalID();\r
- *tmpMsg << ( u8 )0x1a;\r
- *tmpMsg << ( u16 )nNextNode;\r
- //*tmpMsg << ( u8 )nNumResults;\r
- *tmpMsg << ( u8 )nResultBuffer->size();\r
- \r
- std::vector<int>::const_iterator it;\r
- \r
- for(it = nResultBuffer->begin(); it != nResultBuffer->end(); it++)\r
- {\r
- *tmpMsg << ( f32 )*(it);\r
- }\r
- \r
- ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 );\r
- \r
- return tmpMsg;\r
- }\r
-
-PMessage* PMsgBuilder::BuildNPCBeginAllBuyerTradeMsg( PClient* nClient, int nWorldID )\r
- {\r
- PMessage* tmpMsg = new PMessage();\r
- nClient->IncreaseUDP_ID();\r
- \r
- *tmpMsg << ( u8 )0x13;\r
- *tmpMsg << ( u16 )nClient->GetUDP_ID();\r
- *tmpMsg << ( u16 )nClient->GetSessionID();\r
- *tmpMsg << ( u8 )0x00; // Message length\r
- *tmpMsg << ( u8 )0x03;\r
- *tmpMsg << ( u16 )nClient->GetUDP_ID();\r
- *tmpMsg << ( u8 )0x1f;\r
- *tmpMsg << ( u16 )nClient->GetLocalID();\r
- *tmpMsg << ( u8 )0x26;\r
- *tmpMsg << ( u32 ) nWorldID;\r
- *tmpMsg << ( u8 )0x01; // Traders inventory\r
- *tmpMsg << ( u16 )0xFFFF; // Traders inventory\r
- \r
- ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 );\r
- \r
- return tmpMsg;\r
- }\r
- \r
-PMessage* PMsgBuilder::BuildNPCShoppingListMsg( PClient* nClient, PMessage* nContentList, int nWorldID, u8 nItemQuality)\r
- {\r
- PMessage* tmpMsg = new PMessage();\r
- nClient->IncreaseUDP_ID();\r
- \r
- *tmpMsg << ( u8 )0x13;\r
- *tmpMsg << ( u16 )nClient->GetUDP_ID();\r
- *tmpMsg << ( u16 )nClient->GetSessionID();\r
- *tmpMsg << ( u8 )0x00; // Message length\r
- *tmpMsg << ( u8 )0x03;\r
- *tmpMsg << ( u16 )nClient->GetUDP_ID();\r
- *tmpMsg << ( u8 )0x1f;\r
- *tmpMsg << ( u16 )nClient->GetLocalID();\r
- *tmpMsg << ( u8 )0x26;\r
- *tmpMsg << ( u32 ) nWorldID;\r
- *tmpMsg << ( u8 )0x01; // Traders inventory\r
- *tmpMsg << ( u16 )( nContentList->GetSize() / 6 ); // List entries\r
- *tmpMsg << ( u8 )nItemQuality; // Items quality\r
- *tmpMsg << *nContentList;\r
- \r
- ( *tmpMsg )[5] = ( u8 )( tmpMsg->GetSize() - 6 );\r
- \r
- return tmpMsg;\r
- }\r
- \r
-// ==========================\r
-PMessage* PMsgBuilder::BuildNPCSingleInfoMsg( PClient* nClient, u32 nWorldID, u16 nTypeID, u16 nClothing,\r
-u16 nNameID, u16 nPosY, u16 nPosZ, u16 nPosX, u16 nUnknown,\r
-u16 nTraderID, std::string *nAngleStr, std::string *nNpcName, std::string *nCustomName)\r
-// Initial NPC Packet that defines how the NPC look, etc\r
- {\r
-// u8 tMsgLen = 29 + nNpcName->size() + nAngleStr->size() + nCustomName->size();\r
- \r
- PMessage* tmpMsg = new PMessage();\r
- nClient->IncreaseUDP_ID();\r
- \r
- *tmpMsg << ( u8 )0x13; // Begin UDP message\r
- *tmpMsg << ( u16 )nClient->GetUDP_ID();\r
- *tmpMsg << ( u16 )nClient->GetSessionID();\r
- *tmpMsg << ( u8 )0x00;\r
- *tmpMsg << ( u8 )0x03;\r
- *tmpMsg << ( u16 )nClient->GetUDP_ID();\r
- *tmpMsg << ( u8 )0x28;\r
- *tmpMsg << ( u8 )0x00;\r
- *tmpMsg << ( u8 )0x01;\r
- *tmpMsg << ( u32 )nWorldID;\r
- *tmpMsg << ( u16 )nTypeID;\r
- *tmpMsg << ( u16 )nClothing;\r
- *tmpMsg << ( u16 )nNameID;\r
- *tmpMsg << ( u16 )nPosY;\r
- *tmpMsg << ( u16 )nPosZ;\r
- *tmpMsg << ( u16 )nPosX;\r
- *tmpMsg << ( u8 )0x00;\r
- *tmpMsg << ( u16 )nUnknown;\r
- *tmpMsg << ( u16 )nTraderID;\r
- *tmpMsg << nNpcName->c_str();\r
- *tmpMsg << nAngleStr->c_str();\r
- if(nCustomName->length() > 1)\r
- *tmpMsg << nCustomName->c_str();\r
- \r
- (*tmpMsg)[5] = (u8)(tmpMsg->GetSize() - 6);\r
- return tmpMsg;\r
- }\r
- \r
-PMessage* PMsgBuilder::BuildNPCMassInfoMsg( u32 nWorldID, u16 nTypeID, u16 nClothing,\r
-u16 nNameID, u16 nPosY, u16 nPosZ, u16 nPosX, u16 nHealth,\r
-u16 nTraderID, std::string *nAngleStr, std::string *nNpcName, std::string *nCustomName)\r
-// Initial NPC Packet that defines how the NPC look, etc\r
- {\r
-// u8 tMsgLen = 29 + nNpcName->size() + nAngleStr->size() + nCustomName->size();\r
- \r
- PMessage* tmpMsg = new PMessage();\r
- \r
- *tmpMsg << ( u8 )0x13; // Begin UDP message\r
- *tmpMsg << ( u16 )0x0000;\r
- *tmpMsg << ( u16 )0x0000;\r
- *tmpMsg << ( u8 )0x00;\r
- *tmpMsg << ( u8 )0x03;\r
- *tmpMsg << ( u16 )0x0000;\r
- *tmpMsg << ( u8 )0x28;\r
- *tmpMsg << ( u8 )0x00;\r
- *tmpMsg << ( u8 )0x01;\r
- *tmpMsg << ( u32 )nWorldID;\r
- *tmpMsg << ( u16 )nTypeID;\r
- *tmpMsg << ( u16 )nClothing;\r
- *tmpMsg << ( u16 )nNameID;\r
- *tmpMsg << ( u16 )nPosY;\r
- *tmpMsg << ( u16 )nPosZ;\r
- *tmpMsg << ( u16 )nPosX;\r
- *tmpMsg << ( u8 )0x00;\r
- *tmpMsg << ( u16 )nHealth;\r
- *tmpMsg << ( u16 )nTraderID;\r
- *tmpMsg << nNpcName->c_str();\r
- *tmpMsg << nAngleStr->c_str();\r
- if(nCustomName->length() > 1)\r
- *tmpMsg << nCustomName->c_str();\r
- \r
- (*tmpMsg)[5] = (u8)(tmpMsg->GetSize() - 6);\r
- return tmpMsg;\r
- }\r
- \r
-// **************\r
-PMessage* PMsgBuilder::BuildNPCUpdateMsg(u32 nWorldID, u16 nPosY, u16 nPosZ, u16 nPosX, u8 nActionBM, u16 nHealth, u8 nWeaponState, u8 nUnknown, u32 nTargetID)\r
- {\r
- PMessage* tmpMsg = new PMessage();\r
- \r
- *tmpMsg << ( u8 )0x13;\r
- *tmpMsg << ( u16 )0x0000;\r
- *tmpMsg << ( u16 )0x0000;\r
- *tmpMsg << ( u8 )0x00; // len\r
- *tmpMsg << ( u8 )0x1b; // NPC Update\r
- *tmpMsg << ( u32 )nWorldID; // NPCs world ID\r
- *tmpMsg << ( u8 )0x1f; // Parameters\r
- *tmpMsg << ( u16 )nPosY; // Position Y\r
- *tmpMsg << ( u16 )nPosZ; // Position Z\r
- *tmpMsg << ( u16 )nPosX; // Position X\r
- *tmpMsg << ( u8 )nActionBM; // NPCs current action-bitmask\r
- *tmpMsg << ( u16 )nHealth; // Health value\r
- if(nTargetID > 0)\r
- *tmpMsg << ( u32 )nTargetID; // WorldID of NPCs target (if any)\r
- *tmpMsg << ( u8 )nUnknown;\r
- *tmpMsg << ( u8 )nWeaponState;\r
- \r
- (*tmpMsg)[5] = (u8)(tmpMsg->GetSize() - 6);\r
- \r
- return tmpMsg;\r
- }\r
-// **************\r
- \r
-PMessage* PMsgBuilder::BuildNPCSingleAliveMsg( PClient* nClient, u32 nWorldID, u16 nX, u16 nY, u16 nZ, u8 nActionStatus, u8 nHealth, u8 nAction )\r
- {\r
- PMessage* tmpMsg = new PMessage();\r
- \r
- *tmpMsg << ( u8 )0x13; // Begin UDP message\r
- *tmpMsg << ( u16 )nClient->GetUDP_ID();\r
- *tmpMsg << ( u16 )nClient->GetSessionID();\r
- *tmpMsg << ( u8 )0x11;\r
- *tmpMsg << ( u8 )0x1B;\r
- *tmpMsg << ( u32 )nWorldID;\r
- *tmpMsg << ( u8 )0x1F;\r
- *tmpMsg << ( u16 )nY;\r
- *tmpMsg << ( u16 )nZ;\r
- *tmpMsg << ( u16 )nX;\r
- *tmpMsg << ( u8 )nActionStatus;\r
- *tmpMsg << ( u8 )0x00;\r
- *tmpMsg << ( u8 )nHealth;\r
- *tmpMsg << ( u8 )0x00;\r
- *tmpMsg << ( u8 )nAction;\r
- \r
- return tmpMsg;\r
- }\r
- \r
-PMessage* PMsgBuilder::BuildNPCMassAliveMsg( u32 nWorldID, u16 nX, u16 nY, u16 nZ, u8 nActionStatus, u8 nHealth, u8 nAction )\r
- {\r
- PMessage* tmpMsg = new PMessage();\r
- \r
- *tmpMsg << ( u8 )0x13; // Begin UDP message\r
- *tmpMsg << ( u16 )0x0000;\r
- *tmpMsg << ( u16 )0x0000;\r
- *tmpMsg << ( u8 )0x11;\r
- *tmpMsg << ( u8 )0x1B;\r
- *tmpMsg << ( u32 )nWorldID;\r
- *tmpMsg << ( u8 )0x1F;\r
- *tmpMsg << ( u16 )nY;\r
- *tmpMsg << ( u16 )nZ;\r
- *tmpMsg << ( u16 )nX;\r
- *tmpMsg << ( u8 )nActionStatus;\r
- *tmpMsg << ( u8 )0x00;\r
- *tmpMsg << ( u8 )nHealth;\r
- *tmpMsg << ( u8 )0x00;\r
- *tmpMsg << ( u8 )nAction;\r
- \r
- return tmpMsg;\r
- }\r
- \r
-PMessage* PMsgBuilder::BuildNPCMassUpdateMsg( u32 nWorldID, u16 nX, u16 nY, u16 nZ, u8 nActionStatus, u8 nHealth, u16 nTarget, u8 nAction )\r
- {\r
- PMessage* tmpMsg = new PMessage();\r
- \r
- *tmpMsg << ( u8 )0x13; // Begin UDP message\r
- *tmpMsg << ( u16 )0x0000;\r
- *tmpMsg << ( u16 )0x0000;\r
- *tmpMsg << ( u8 )0x15; // Message length\r
- *tmpMsg << ( u8 )0x1b;\r
- *tmpMsg << ( u32 )nWorldID;\r
- *tmpMsg << ( u8 )0x1F;\r
- *tmpMsg << ( u16 )nY;\r
- *tmpMsg << ( u16 )nZ;\r
- *tmpMsg << ( u16 )nX;\r
- *tmpMsg << ( u8 )nActionStatus;\r
- *tmpMsg << ( u8 )0x77; // ?\r
- *tmpMsg << ( u8 )nHealth;\r
- *tmpMsg << ( u16 )nTarget;\r
- *tmpMsg << ( u8 )0x00; // ?\r
- *tmpMsg << ( u8 )0x00; // ?\r
- *tmpMsg << ( u8 )0x00; // ?\r
- *tmpMsg << ( u8 )nAction;\r
- \r
- return tmpMsg;\r
- }\r
- \r
-// ==========================\r
- \r
-PMessage* PMsgBuilder::BuildNPCSingleUpdateMsg( PClient* nClient, u32 nWorldID, u16 nX, u16 nY, u16 nZ, u8 nActionStatus, u8 nHealth, u16 nTarget, u8 nAction )\r
- {\r
- PMessage* tmpMsg = new PMessage();\r
- \r
- *tmpMsg << ( u8 )0x13; // Begin UDP message\r
- *tmpMsg << ( u16 )nClient->GetUDP_ID();\r
- *tmpMsg << ( u16 )nClient->GetSessionID();\r
- *tmpMsg << ( u8 )0x15; // Message length\r
- *tmpMsg << ( u8 )0x1b;\r
- *tmpMsg << ( u32 )nWorldID;\r
- *tmpMsg << ( u8 )0x1F;\r
- *tmpMsg << ( u16 )nY;\r
- *tmpMsg << ( u16 )nZ;\r
- *tmpMsg << ( u16 )nX;\r
- *tmpMsg << ( u8 )nActionStatus;\r
- *tmpMsg << ( u8 )0x77; // ?\r
- *tmpMsg << ( u8 )nHealth;\r
- *tmpMsg << ( u16 )nTarget;\r
- *tmpMsg << ( u8 )0x00; // ?\r
- *tmpMsg << ( u8 )0x00; // ?\r
- *tmpMsg << ( u8 )0x00; // ?\r
- *tmpMsg << ( u8 )nAction;\r
- \r
- return tmpMsg;\r
- }\r
-// ==========================\r
-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; i<PSubway::mCabsNumber; i++)
- {
- nClient->IncreaseUDP_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;
- }\r
- \r
-
-/*
-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 ?
-*/
+++ /dev/null
-/*
- 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 );
-}
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- rconsole.cpp\r
-\r
- Authors:\r
- - Akiko\r
- - Namikon\r
- - someone else?\r
-\r
- MODIFIED: Unknown date / Unknown author\r
- REASON: - initial release by unknown\r
-\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL\r
-*/\r
-\r
-#include "main.h"\r
-\r
-static const int RCON_INPUTLEN = 512;\r
-\r
-struct PRConClient\r
-{\r
- enum\r
- {\r
- RCCS_AUTH,\r
- RCCS_AUTH_USER,\r
- RCCS_AUTH_PASS,\r
- RCCS_VALID,\r
- RCCS_DISCONNECT\r
- } mState;\r
-\r
- PSocket *mSocket;\r
- PAccount *mAccount;\r
- char mInput[RCON_INPUTLEN];\r
- int mInputLen;\r
- bool mEcho;\r
- std::clock_t mSleep, mSleepStart;\r
- int mNumFailures;\r
-\r
- inline PRConClient(NLsocket &Sock)\r
- {\r
- mSocket = new PSocket(Sock);\r
- mAccount = 0;\r
- mInputLen = 0;\r
- mEcho = true;\r
- mSleep = 0;\r
- mSleepStart = 0;\r
- mNumFailures = 0;\r
- }\r
-\r
- inline ~PRConClient()\r
- {\r
- delete mSocket;\r
- }\r
-\r
- inline void Print(const char *Fmt, ...)\r
- {\r
- static char Str[256];\r
- va_list args;\r
- va_start(args, Fmt);\r
- vsnprintf(Str, 255, Fmt, args);\r
- va_end(args);\r
- mSocket->Write(Str);\r
- }\r
-\r
-};\r
-\r
-PRConsole::PRConsole()\r
-{\r
- mListener = NL_INVALID;\r
-}\r
-\r
-PRConsole::~PRConsole()\r
-{\r
- if(mListener != NL_INVALID)\r
- nlClose(mListener);\r
-\r
- for(ClientList::iterator i=mClients.begin(); i!=mClients.end(); i++)\r
- delete *i;\r
-}\r
-\r
-void PRConsole::Start()\r
-{\r
- // CHECK FOR rconsole enabled!!!\r
- Console->LPrint("Starting remote console...");\r
- u16 Port = Config->GetOptionInt("rconsole_port");\r
- mListener = nlOpen(Port, NL_TCP);\r
- if(mListener == NL_INVALID)\r
- {\r
- Console->LPrint(RED, BLACK, "[ERROR]");\r
- Console->LPrint(" Remote console failed");\r
- Console->LClose();\r
- return;\r
- }\r
-\r
- Console->LPrint(GREEN, BLACK, "Success");\r
- Console->LClose();\r
- nlListen(mListener);\r
-}\r
-\r
-void PRConsole::Update()\r
-{\r
- if(mListener==NL_INVALID)\r
- return;\r
-\r
- NLsocket temp = nlAcceptConnection(mListener);\r
- if(temp != NL_INVALID)\r
- {\r
- // TODO: print client ip addr\r
- Console->Print("RConsole: client connected");\r
- PRConClient *cl = new PRConClient(temp);\r
- cl->mState = PRConClient::RCCS_AUTH;\r
- mClients.push_back(cl);\r
- cl->Print("TinNS shell [%s]\r\n", TINNS_VERSION);\r
- }\r
-\r
- for(ClientList::iterator i=mClients.begin(); i!=mClients.end();)\r
- {\r
- ClientList::iterator j=i;\r
- PRConClient *cl = *i;\r
- ++i;\r
- if(!cl->mSocket->Update() || cl->mSocket->TimeOut())\r
- {\r
- Console->Print("RConsole: client disconnected");\r
- mClients.erase(j);\r
- delete cl;\r
- continue;\r
- }\r
-\r
- if(cl->mSleep > 0)\r
- {\r
- std::clock_t t = std::clock();\r
- cl->mSleep -= (t-cl->mSleepStart);\r
- cl->mSleepStart = t;\r
-\r
- if(cl->mSleep < 0)\r
- cl->mSleep = 0;\r
-\r
- // flush socket while sleeping\r
- int Size=0;\r
- cl->mSocket->Read(&Size);\r
-\r
- continue;\r
- }\r
-\r
- if(cl->mState==PRConClient::RCCS_AUTH)\r
- {\r
- cl->Print("\r\nlogin: ");\r
- cl->mState = PRConClient::RCCS_AUTH_USER;\r
- }\r
-\r
- const u8 *Buf = 0;\r
- int Size=0;\r
- if((bool)(Buf = cl->mSocket->Read(&Size)))\r
- {\r
- for(int i=0; i<Size; i++)\r
- if(cl->mInputLen < RCON_INPUTLEN)\r
- {\r
- switch(Buf[i])\r
- {\r
- case 0x08 :\r
- {\r
- if(cl->mInputLen > 0)\r
- {\r
- if(cl->mEcho)\r
- cl->mSocket->Write(Buf[i]);\r
- cl->mInput[cl->mInputLen]=0;\r
- --cl->mInputLen;\r
- }\r
- break;\r
- }\r
-\r
- case '\n' :\r
- {\r
- if(cl->mEcho)\r
- cl->mSocket->Write(Buf[i]);\r
- cl->mInput[cl->mInputLen]=0;\r
- ProcessClient(cl);\r
- cl->mInputLen = 0;\r
- break;\r
- }\r
-\r
- default :\r
- {\r
- cl->mInput[cl->mInputLen++]=Buf[i];\r
- if(cl->mEcho)\r
- cl->mSocket->Write(Buf[i]);\r
- break;\r
- }\r
- }\r
- }\r
- }\r
- }\r
-}\r
-\r
-void PRConsole::ProcessClient(PRConClient* Client)\r
-{\r
- Console->Print(">%s", Client->mInput);\r
- if(Client->mInputLen > 1)\r
- {\r
- if(Client->mInput[Client->mInputLen-1] == '\r')\r
- Client->mInput[Client->mInputLen-1]=0;\r
-\r
- if(Client->mState == PRConClient::RCCS_AUTH_USER)\r
- {\r
- Client->mAccount = Database->GetAccount(Client->mInput);\r
- Client->mState = PRConClient::RCCS_AUTH_PASS;\r
- Client->Print("password: ");\r
- Client->mEcho = false;\r
- } else\r
- if(Client->mState == PRConClient::RCCS_AUTH_PASS)\r
- {\r
- Client->mEcho = true;\r
- if((!Client->mAccount) || (Client->mAccount->GetPassword() != Client->mInput) || (!Client->mAccount->IsConsoleAllowed()))\r
- {\r
- Client->Print("Invalid user or password\r\n");\r
- Client->mSleepStart = std::clock();\r
- ++Client->mNumFailures;\r
- if(Client->mNumFailures >= 3)\r
- {\r
- // sleep 1 minute\r
- Client->mSleep = 60*CLOCKS_PER_SEC;\r
- Client->mNumFailures = 0;\r
- } else\r
- Client->mSleep = 5*CLOCKS_PER_SEC;\r
-\r
- Client->mState = PRConClient::RCCS_AUTH;\r
- } else\r
- {\r
- Client->Print("\r\n\nUser %s logged in\r\n", Client->mAccount->GetName().c_str());\r
- Client->mState = PRConClient::RCCS_VALID;\r
- // disconnect after 30 minutes lacking socket activity\r
- Client->mSocket->SetTimeOutValue(1800);\r
- Prompt(Client);\r
- }\r
- }\r
- }\r
-}\r
-\r
-void PRConsole::Prompt(PRConClient *Client)\r
-{\r
- Client->Print("$ ", Client->mAccount->GetName().c_str(), Config->GetOption("server_name").c_str());\r
-}\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
- server.cpp\r
-\r
- Authors:\r
- - Akiko\r
- - Namikon\r
- - someone else?\r
-\r
- MODIFIED: Unknown date / Unknown author\r
- REASON: - initial release by unknown\r
-\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL\r
-*/\r
-#include "main.h"\r
-\r
-PServer::PServer()\r
-{\r
- mNumClients = 0;\r
- mMaxClients = Config->GetOptionInt("maxclients");\r
- mGMSlots = Config->GetOptionInt("gm_slots");\r
- if(mMaxClients==0)\r
- mMaxClients=1;\r
- if(mGMSlots==0)\r
- mGMSlots=1;\r
- Console->Print("Max clients: %i / GM slots: %i", mMaxClients, mGMSlots);\r
- mClients.reserve(mMaxClients + mGMSlots);\r
- for(int i=0; i<mMaxClients+mGMSlots; i++)\r
- mClients[i]=0;\r
-}\r
-\r
-PServer::~PServer()\r
-{\r
- for(int i=0; i<mMaxClients+mGMSlots; i++)\r
- delete mClients[i];\r
-}\r
-\r
-int PServer::NewClient()\r
-{\r
- if(mNumClients==mMaxClients+mGMSlots)\r
- return -1;\r
-\r
- for(int i=0; i<mMaxClients+mGMSlots; i++)\r
- {\r
- if(!mClients[i])\r
- {\r
- mClients[i]=new PClient(i);\r
- ++mNumClients;\r
- return i;\r
- }\r
- }\r
- return -1;\r
-}\r
-\r
-PClient *PServer::GetClient(int Client) const\r
-{\r
- if(Client < 0 || Client >= mMaxClients+mGMSlots)\r
- return 0;\r
-\r
- return mClients[Client];\r
-}\r
-\r
-void PServer::Update()\r
-{\r
- for(int i=0; i<mMaxClients+mGMSlots; i++)\r
- {\r
- if(mClients[i])\r
- {\r
- mClients[i]->Update();\r
- if(mClients[i]->GetConnection()==PCC_NONE && mClients[i]->getTCPConn() == 0)\r
- {\r
- Console->Print("Removing client %i...", i);\r
- delete mClients[i];\r
- mClients[i]=0;\r
- --mNumClients;\r
- }\r
- }\r
- }\r
-}\r
-\r
-void PServer::Shutdown()\r
-{\r
- Console->Print("======================");\r
- Console->Print("Shutting down Gameserver...");\r
- for(int i=0; i<mMaxClients+mGMSlots; i++)\r
- {\r
- if(mClients[i])\r
- {\r
- delete mClients[i];\r
- mClients[i]=0;\r
- }\r
- }\r
-}\r
-\r
-//SELECT `s_name` , NOW( ) , `s_lastupdate` , NOW( ) - `s_lastupdate` FROM `server_list` \r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- Zoning - makes changing of maps possible ingame\r
-\r
- Authors:\r
- - initial release by unknown person\r
- - Sting\r
- - Akiko <akiko@gmx.org>\r
- - Namikon\r
-\r
- MODIFIED: 23 August 2005 by Sting\r
- REASON: - TO match up with defs/pak_worldinfo.def from patch 200\r
-\r
- MODIFIED: 27 Aug 2005 by Akiko\r
- REASON: - reformated for better reading\r
- - thinking about a way to optimize the case statements\r
- MODIFIED: 28 Aug 2005 by Akiko\r
- REASON: - continued reformating\r
- MODIFIED: 26 Oct 2005 Akiko\r
- REASON: - fixed a bug -> loc is a int, and the location is a 16 bit value\r
- - added GPL\r
- MODIFIED: 27 Nov 2005 Akiko\r
- REASON: - fixed a very stupid bug (loc)\r
- MODIFIED: 04 Dec 2005 Akiko\r
- REASON: - copying int to char array (loc) correctly now\r
- MODIFIED: 07 Jan 2006 Namikon\r
- REASON: - Fixed zoning to / from wastelands to / from city sectors (packet1 was wrong, thanks Maxx!!)\r
- MODIFIED: 08 Jan 2006 Namikon\r
- REASON: - Added appartment handling\r
- - Fixed minimap\r
- MODIFIED: 17 Jan 2006 Namikon\r
- REASON: - File rewritten. Now, only 1 packet is send, like the real servers (that one fixed subway)\r
- - Fixed several worldnames\r
- MODIFIED: 26 Jul 2006 Hammag\r
- REASON: - Fixed world 1086 (area mc5) worldname (from NeoX source)\r
-\r
- MODIFIED: 28 Sep 2006 Hammag\r
- REASON: - Zone filename in now taken from appartments.def (for app zoning) or from worlds.ini (general case)\r
- rather than hardcoded.\r
-\r
- MODIFIED: 09 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
-\r
- TODO: Put get the fallback world from config\r
- Check for file existence before sending info to client to avoid client crash and bad location in char info\r
- \r
-*/\r
-\r
-\r
-#include "main.h"\r
-\r
-#include "include/worlds.h"\r
-#include "include/appartements.h"\r
-#include "include/msgbuilder.h"\r
-\r
-\r
-void SendZone(PClient *Client, u32 loc)\r
-{\r
- //TODO : FIX case for worldroute and 5 missing id 505\r
- std::string worldName;\r
- ConnectionTCP *Socket = Client->getTCPConn();\r
- //PChar *Char = Chars->GetChar(Client->GetCharID());\r
-\r
- Socket->SetTimeOutValue(0xffff);\r
- \r
- PWorld* CurrentWorld = Worlds->GetWorld(loc);\r
- if (CurrentWorld)\r
- {\r
- worldName = CurrentWorld->GetBspName();\r
- if (worldName.empty())\r
- {\r
- worldName = "plaza/plaza_p1"; // Should be a config entry\r
- Console->Print("Client %d: Empty name for world %d. Redirecting to %s", Console->ColorText(RED, BLACK, "Warning"), Client->GetID(), loc, worldName.c_str());\r
- loc = 1;\r
- }\r
- }\r
- else\r
- {\r
- worldName = "plaza/plaza_p1"; // Should be a config entry\r
- Console->Print("Client %d: Invalid or not loaded world %d. Redirecting to %s", Console->ColorText(YELLOW, BLACK, "Warning"), Client->GetID(), loc, worldName.c_str());\r
- loc = 1;\r
- }\r
- \r
- PMessage* cMsg = MsgBuilder->BuildSendZoneTCPMsg(loc, &worldName);\r
- Client->SendTCPMessage(cMsg);\r
-}\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- external.h - include file for all common external standard libs\r
-\r
- MODIFIED: 31 Aug 2005 Akiko\r
- REASON: - updating def file definitions to match the changes in gamedefs.cpp\r
- - added define for charfiles path\r
- - added define for database path\r
- MODIFIED: 26 Sep 2005 Akiko\r
- REASON: - reformated code\r
- - added GPL\r
- - added infoserver default port as define\r
- - added my threading model (mutex.h, semaphore.h, thread.h)\r
- - added basic includes pthread.h, semaphore.h and errno.h\r
- MODIFIED: 28 Sep 2005 Akiko\r
- REASON: - added define for game server port\r
- MODIFIED: 30 Nov 2005 Akiko\r
- REASON: - added chat.h for the chat part from Namikon\r
- MODIFIED: 02 Dec 2005 Akiko\r
- REASON: - commented out mutex.h, thread.h, semaphore.h\r
- MODIFIED: 22 Dec 2005 Namikon/bakkdoor\r
- REASON: - Added commands.h, skill.h, clientmanager.h\r
- MODIFIED: 23 Dec 2005 bakkdoor\r
- REASON: - Added <csignal> for main.cpp -> catch strg-c and shutdown nicely\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added mysql.h, sql.h for MySQL support\r
- MODIFIED: 01 Jan 2006 Namikon\r
- REASON: - Moved skill.h before chars.h (char.h needs skill.h now)\r
- MODIFIED: 30 May 2006 Namikon\r
- REASON: - Removed all useless includes to complete the server splitup; Also renamed tinns.h to main.h\r
- MODIFIED: 6 Jul 2006 Hammag\r
- REASON: - moved include "types.h" before include "../netcode/main.h" to permit compile\r
- MODIFIED: 10 Jul 2006 Hammag\r
- REASON: - added inventory.h\r
- REASON: - added item.h\r
-\r
- MODIFIED: 26 Aug 2006 Hammag\r
- REASON: - splitted from main.h, keeping external includes in this single file\r
- for all source tree\r
-\r
-*/\r
-\r
-#ifndef EXTERNAL_H\r
-#define EXTERNAL_H\r
-\r
-#include <cstdio>\r
-#include <ctime>\r
-#include <cstring>\r
-#include <cctype>\r
-#include <fstream>\r
-#include <vector>\r
-#include <string>\r
-#include <sstream>\r
-#include <map>\r
-#include <list>\r
-#include <queue>\r
-#include <unistd.h>\r
-#include <iostream>\r
-#include <stdarg.h>\r
-#include <string.h>\r
-#include <zlib.h>\r
-#include <pthread.h>\r
-#include <semaphore.h>\r
-#include <errno.h>\r
-#include <stdlib.h>\r
-#include <csignal>\r
-#include <netdb.h>\r
-#include <fcntl.h>\r
-#include <sys/types.h>\r
-#include <algorithm>\r
-\r
-#endif\r
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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
-
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- mutex.h - part of a C++ thread model using the POSIX way\r
-\r
- MODIFIED: 26 Sep 2005 Akiko\r
- REASON: - started the implementaion of a thread model\r
-*/\r
-\r
-\r
-#ifndef MUTEX_H\r
-#define MUTEX_H\r
-\r
-//this class needs pthread.h, but it should come from tinns.h\r
-\r
-class Mutex {\r
- private:\r
- mutable pthread_mutex_t mut;\r
- void operator = (Mutex &mut) {\r
- }\r
- Mutex(const Mutex &mut) {\r
- }\r
-\r
- public:\r
- Mutex() {\r
- pthread_mutexattr_t attr;\r
- pthread_mutexattr_init(&attr);\r
- pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);\r
- pthread_mutex_init(&mut, &attr);\r
- pthread_mutexattr_destroy(&attr);\r
- }\r
-\r
- virtual ~Mutex() {\r
- pthread_mutex_unlock(&mut);\r
- pthread_mutex_destroy(&mut);\r
- }\r
-\r
- int Lock() const {\r
- return(pthread_mutex_lock(&mut));\r
- }\r
-\r
- int TryLock() const {\r
- return(pthread_mutex_trylock(&mut));\r
- }\r
-\r
- int Unlock() const {\r
- return(pthread_mutex_unlock(&mut));\r
- }\r
-};\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- semaphore.h - part of the C++ threading model (an very efficently way\r
- of dealing with threads) - also a POSIX way\r
-\r
- MODIFIED: 26 Sep 2005 Akiko\r
- REASON: - started threading model\r
-*/\r
-\r
-#ifndef SEMAPHORE_H\r
-#define SEMAPHORE_H\r
-\r
-//this class uses semaphore.h, but it should come from tinns.h\r
-\r
-class Semaphore {\r
- private:\r
- sem_t sem;\r
- \r
- public:\r
- Semaphore(int init = 0) {\r
- sem_init(&sem, 0, init);\r
- }\r
-\r
- virtual ~Semaphore() {\r
- sem_destroy(&sem);\r
- }\r
-\r
- void Wait() const {\r
- sem_wait((sem_t *)&sem);\r
- }\r
-\r
- int TryWait() const {\r
- return(sem_trywait((sem_t *)&sem) ? errno : 0);\r
- }\r
-\r
- int Post() const {\r
- return(sem_post((sem_t *)&sem) ? errno : 0);\r
- }\r
-\r
- int GetValue() const {\r
- int val = -1;\r
-\r
- sem_getvalue((sem_t *)&sem, &val);\r
-\r
- return(val);\r
- }\r
-\r
- void Reset(int init = 0) {\r
- sem_destroy(&sem);\r
- sem_init(&sem, 0, init);\r
- }\r
-};\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- types.h\r
-\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL\r
-*/\r
-\r
-#ifndef TYPES_H\r
-#define TYPES_H\r
-\r
-// basic type definitions\r
-\r
-#ifdef WIN32\r
- typedef signed char s8;\r
- typedef unsigned char u8;\r
- typedef signed short s16;\r
- typedef unsigned short u16;\r
- typedef signed int s32;\r
- typedef unsigned int u32;\r
-// #ifdef _MSC_VER\r
-// typedef signed __int64 s64;\r
-// typedef unsigned __int64 u64;\r
-// #endif // _MSC_VER\r
- typedef float f32;\r
- typedef double f64;\r
-#else // no WIN32\r
- typedef signed char s8;\r
- typedef unsigned char u8;\r
- typedef signed short s16;\r
- typedef unsigned short u16;\r
- typedef signed int s32;\r
- typedef unsigned int u32;\r
- //typedef signed int64 s64;\r
- //typedef unsigned int64 u64;\r
- typedef float f32;\r
- typedef double f64;\r
-#endif // LINUX\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-#ifndef VERSION_H\r
-#define VERSION_H\r
-\r
-#include "svnrevision.h"\r
-\r
-#define TINNS_PATCH_VERSION "0.0.2 Dev"\r
-#define TINNS_INFO_VERSION "0.0.2 Dev"\r
-#define TINNS_GAME_VERSION "0.1.38 Dev"\r
-\r
-#endif\r
-\r
+++ /dev/null
-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})
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- accounts.h\r
-\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL\r
- MODIFIED: 26 Dec 2005 Namikon\r
- REASON: - Added load/save functions for SQL DB\r
- MODIFIED: 01 Jan 2005 Namikon\r
- REASON: - Added bool var for ingame debug outputs for administrators\r
- MODIFIED: 06 Jan 2005 Namikon\r
- REASON: - Added SetBannedStatus(<unix timestamp>) to ban/unban an account (use SetBannedStatus(0) to unban a player)\r
- MODIFIED: 10 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
-*/\r
-\r
-#ifndef ACCOUNTS_H\r
-#define ACCOUNTS_H\r
-\r
-#ifdef _MSC_VER\r
- #pragma once\r
-#endif\r
-\r
-#include "common/regex++.h"\r
-\r
-/*\r
-0 = unregistered user\r
-1 = Registered user\r
-30 = volunteer\r
-50 = GM\r
-100 = Admin\r
-*/\r
-\r
-// New way of AccountLevel handling:\r
-// Every level is possible, the following values are only edge values. We need a bit control about that\r
-#define PAL_BANNED -1\r
-#define PAL_UNREGPLAYER 0\r
-#define PAL_REGPLAYER 1\r
-#define PAL_VOLUNTEER 30\r
-#define PAL_GM 50\r
-#define PAL_ADMIN 100\r
-\r
-// Max number of char slots per account\r
-#define MAX_CHARS_PER_ACCOUNT 4\r
-\r
-/*\r
-0 = Offline\r
-1 = Online\r
-2 = Banned\r
-*/\r
-\r
-enum PAccountStatus\r
-{\r
- PAS_OFFLINE = 0,\r
- PAS_ONLINE = 1,\r
- PAS_BANNED = 2\r
-};\r
- \r
-class PAccount\r
-{\r
- private :\r
- // SQL Layout\r
- enum {\r
- a_id,\r
- a_username,\r
- a_password,\r
- a_priv,\r
- a_status,\r
- a_bandate,\r
- a_emailaddress,\r
- a_creationdate,\r
- a_lastused\r
- };\r
- \r
- // static members\r
- static RegEx* mUsernameRegexFilter;\r
- static RegEx* mPasswordRegexFilter;\r
- \r
- // instance members\r
- u32 mID;\r
- std::string mName;\r
- std::string mPassword;\r
- int mLevel;\r
- PAccountStatus mStatus;\r
- std::time_t mBannedUntil;\r
-\r
- bool LoadFromQuery(char* query);\r
- bool DecodePassword(const u8* PasswordData, int PassLen, const u8 *Key, char* ClearPassword);\r
- \r
- public :\r
- PAccount();\r
- PAccount(const u32 AccountId);\r
- PAccount(const char *Username);\r
- \r
- static bool SetUsernameRegexFilter(const char* RegexStr);\r
- static bool SetPasswordRegexFilter(const char* RegexStr);\r
- static bool IsUsernameWellFormed(const char *Username);\r
- static bool IsPasswordWellFormed(const char *Password);\r
- \r
- inline u32 GetID() const { return mID; }\r
- bool SetName(const std::string &Pass);\r
- inline const std::string &GetName() const { return mName; }\r
- bool SetPassword(const std::string &Pass);\r
- bool SetPasswordEncoded(const u8* PasswordData, int PassLen, const u8* Key);\r
- inline const std::string &GetPassword() const { return mPassword; }\r
- bool SetLevel(int newLevel);\r
- inline int GetLevel() const { return mLevel; }\r
- std::string GetLevelString() const;\r
- bool SetStatus(PAccountStatus Status);\r
- inline PAccountStatus GetStatus() const { return mStatus; }\r
- bool SetBannedUntilTime(std::time_t BannedUntil);\r
- inline bool IsBanned() const { return (mBannedUntil > std::time(NULL)); }\r
- std::string GetBannedTime() const;\r
-\r
- bool Authenticate(const u8* PasswordData, int PassLen, const u8 *Key);\r
- bool Authenticate(const char *Password) const;\r
- \r
- bool Create();\r
- bool Save(bool CreateMode = false);\r
-\r
- //u32 GetCharIdBySlot(const u32 SlotId);\r
-};\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-#include "main.h"\r
-\r
-PClient::PClient(int Index)\r
-{\r
- mIndex = Index;\r
- mConnection = PCC_NONE;\r
- mAccountID = 0;\r
-}\r
-\r
-PClient::~PClient()\r
-{\r
- if(m_TCPConnection)\r
- {\r
- delete m_TCPConnection;\r
- }\r
-}\r
-\r
-void PClient::InfoDisconnect()\r
-{\r
- if(m_TCPConnection)\r
- {\r
- delete m_TCPConnection;\r
- }\r
- m_TCPConnection = 0;\r
-\r
- //mConnection &= ~PCC_INFO;\r
- mConnection = PCC_NONE;\r
- mAccountID = 0;\r
-}\r
-\r
-void PClient::Update()\r
-{\r
- if(m_TCPConnection)\r
- {\r
- if(m_TCPConnection->timeOut())\r
- {\r
- Console->Print("InfoSocket: Client %i: timeout", mIndex);\r
- InfoServer->ClientDisconnected(this);\r
- }\r
- else\r
- {\r
- if(!m_TCPConnection->update())\r
- {\r
- InfoServer->ClientDisconnected(this);\r
- }\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-#ifndef CLIENT_H\r
-#define CLIENT_H\r
-\r
-#ifdef _MSC_VER\r
- #pragma once\r
-#endif\r
-\r
-enum PClientConnection\r
-{\r
- PCC_NONE = 0,\r
- PCC_INFO = 1\r
-};\r
-\r
-class PClient\r
-{\r
- private :\r
- ConnectionTCP* m_TCPConnection;\r
- int mIndex;\r
- int mConnection;\r
- u32 mAccountID;\r
-\r
- protected :\r
- public :\r
- PClient(int Index);\r
- ~PClient();\r
-\r
- inline int GetIndex() const { return mIndex; }\r
-\r
- void setTCPConnection(ConnectionTCP* conn) { m_TCPConnection = conn; mConnection = PCC_INFO; }\r
- inline ConnectionTCP* getTCPConn() const { return m_TCPConnection; }\r
-\r
- inline int GetConnection() const { return mConnection; }\r
- inline const char *GetAddress() const { return m_TCPConnection->getRemoteAddress(); }\r
-\r
- inline void setAccountID(u32 nAccountID) { mAccountID = nAccountID; }\r
- inline u32 getAccountID() { return mAccountID; }\r
- \r
- void InfoDisconnect();\r
-\r
- void Update();\r
-};\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
- globals.h\r
-\r
- MODIFIED: 12 September 2005 Akiko\r
- REASON: - exchanged Pretender Strings by TinNS\r
- - removed some Windows specific code\r
- MODIFIED: 16 Dec 2005 bakkdoor\r
- REASON: - Added global ClientManager and Chat Interface\r
- MODIFIED: 22 Dec 2005 Namikon\r
- REASON: - Added GPL\r
- MODIFIED: 27 Aug 2006 Hammag\r
- REASON: - Added AdditionnalConfigChecks() local function\r
-\r
-*/\r
-\r
-#ifndef GLOBALS_H\r
-#define GLOBALS_H\r
-\r
-#ifdef _MSC_VER\r
- #pragma once\r
-#endif\r
-\r
-extern class ServerSocket* ServerSock;\r
-extern class PConsole *Console;\r
-extern class PServer *Server;\r
-extern class PConfig *Config;\r
-extern class PInfoServer *InfoServer;\r
-\r
-extern class PMySQL* MySQL;\r
-//extern class PAccounts* Accounts; // To be removed\r
-\r
-extern const char ServerVersion[];\r
-extern const char SVNRevision[];\r
-\r
-bool Init();\r
-void Shutdown();\r
-bool AdditionnalConfigChecks();\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-/*\r
- MODIFIED: 01 Jul 2006 hammag\r
- REASON: - added set timeout to 10 msec (for ReadSetTCP select) in Start()\r
- to avoid useless 100% CPU use\r
- MODIFIED: 27 Aug 2006 hammag\r
- REASON: - Removed INFO_PORT use as value is available from config\r
- MODIFIED: 27 Aug 2006 hammag\r
- REASON: - Modified GSLiveCheck() to be independant of gameserver time (no time sync needed between servers)\r
- MODIFIED: 27 Aug 2006 hammag\r
- REASON: - Display the client id in Client connection message rather than the always increasing mNumClients\r
- - Removed use of mNumClients in PInfoServer. the count is done in PServer.\r
-\r
- ToDo:\r
- - Take main loop timeout setting from config file\r
-*/\r
-\r
-#include "main.h"\r
-\r
-struct PInfoState\r
-{\r
- enum State\r
- {\r
- IS_UNKNOWN,\r
- IS_CONNECTED,\r
- IS_HANDSHAKE0,\r
- IS_AUTHENTICATE,\r
- IS_SERVERLIST\r
- } mState;\r
-\r
- bool mWaitSend; // wait-for-completition flag\r
- PInfoState()\r
- {\r
- mState = IS_UNKNOWN;\r
- mWaitSend = false;\r
- };\r
-};\r
-\r
-PInfoServer::PInfoServer()\r
-{\r
- //mNumClients = 1;\r
- mLivecheckInterval = Config->GetOptionInt("gameserver_livecheck");\r
-}\r
-\r
-PInfoServer::~PInfoServer()\r
-{\r
- Console->Print("Closing Infoserver...");\r
-\r
- ServerSock->closeServer();\r
-\r
- for(InfoStateMap::iterator i=ClientStates.begin(); i!=ClientStates.end(); i++)\r
- delete i->second;\r
-}\r
-\r
-void PInfoServer::Start()\r
-{\r
- u16 Port = Config->GetOptionInt("infoserver_port");\r
- Console->LPrint("Starting Infoserver on port %i...", Port);\r
-\r
- if(ServerSock->open(Port))\r
- {\r
- Console->LPrint(GREEN, BLACK, "Success");\r
- Console->LClose();\r
- }\r
- else\r
- {\r
- Console->LPrint(RED, BLACK, "Failed");\r
- Console->LClose();\r
- }\r
- ServerSock->settimeout(0, 10000);\r
- GSLiveCheck();\r
-}\r
-\r
-void PInfoServer::Update()\r
-{\r
- if(ServerSock->newConnection())\r
- {\r
- int clid = Server->NewClient();\r
- if(clid!=-1)\r
- {\r
- Console->Print(GREEN, BLACK, "Infoserver: client [%i] connected", clid);\r
- PClient *Client = Server->GetClient(clid);\r
-\r
- ConnectionTCP* tcpConn = ServerSock->getTCPConnection();\r
- Client->setTCPConnection(tcpConn);\r
-\r
- Console->Print("Client address: %s", Client->GetAddress());\r
- //++mNumClients;\r
-\r
- PInfoState *state = new PInfoState();\r
- ClientStates.insert(std::make_pair(Client, state));\r
- state->mState = PInfoState::IS_CONNECTED;\r
- } else\r
- {\r
- Console->Print("Infoserver: Client connection refused (server full?)");\r
- }\r
- }\r
-\r
- for(InfoStateMap::iterator i=ClientStates.begin(); i!=ClientStates.end();)\r
- {\r
- PClient *Client = i->first;\r
- PInfoState *State = i->second;\r
- // node gets erased in FinalizeClient, increment iterator now\r
- ++i;\r
- if(!ProcessClient(Client, State))\r
- FinalizeClient(Client, State);\r
- }\r
-}\r
-\r
-void PInfoServer::GSLiveCheck()\r
-{\r
- MYSQL_ROW row;\r
- MYSQL_RES *result;\r
- char query[256];\r
- snprintf (query, 256, "SELECT *, (NOW()< (`s_lastupdate` + INTERVAL %d SECOND)) FROM `server_list`", mLivecheckInterval);\r
-\r
- result = MySQL->ResQuery(query);\r
- if(result == NULL)\r
- {\r
- Console->Print("Livecheck: %s unable to read server list!", Console->ColorText(RED, BLACK, "[Warning]"));\r
- MySQL->ShowSQLError();\r
- return;\r
- }\r
- if(mysql_num_rows(result) == 0)\r
- {\r
- Console->Print("Livecheck: %s no gameserver found!", Console->ColorText(RED, BLACK, "[Warning]"));\r
- MySQL->FreeSQLResult(result);\r
- return;\r
- }\r
-\r
- ServerMap::iterator it;\r
- while((row = mysql_fetch_row(result)))\r
- {\r
- it = Serverlist.find(atoi(row[s_id]));\r
- if(it != Serverlist.end())\r
- {\r
- strncpy(it->second.mName, row[s_name], MAX_SERVER_NAME_LENGTH);\r
- it->second.mLanIp = IPStringToDWord(row[s_lanaddr]);\r
- it->second.mWanIp = IPStringToDWord(row[s_wanaddr]);\r
- it->second.mPort = atoi(row[s_port]);\r
- it->second.mPlayers = atoi(row[s_players]);\r
- /* Prepared for future addon Servers by Accesslevel */\r
- // it->second.mMinLv = atoi(row[s_minlv]);\r
- /* ------------------------------------------------ */\r
-\r
- // ToDo: If statement correct? Maybe GSLiveCheck() has\r
- // to be called every mLinvecheckInterval seconds.... We'll\r
- // see when Gameserver has been rewritten\r
-\r
- if(row[s_timecheck] && (atoi(row[s_timecheck]) == 1))\r
- {\r
- it->second.mLasttimestamp = atol(row[s_lastupdate]);\r
- it->second.mOnline = true;\r
- }\r
- else\r
- {\r
- it->second.mOnline = false;\r
- }\r
-\r
- it->second.mUpdated = true;\r
- }\r
- else\r
- {\r
- GameServers tmpServer;\r
-\r
- strncpy(tmpServer.mName, row[s_name], MAX_SERVER_NAME_LENGTH);\r
- tmpServer.mLanIp = IPStringToDWord(row[s_lanaddr]);\r
- tmpServer.mWanIp = IPStringToDWord(row[s_wanaddr]);\r
- tmpServer.mLasttimestamp = atol(row[s_lastupdate]);\r
- tmpServer.mPlayers = atoi(row[s_players]);\r
- tmpServer.mPort = atoi(row[s_port]);\r
- tmpServer.mOnline = true;\r
- tmpServer.mUpdated = true;\r
- Console->Print("Added GameServer %s", tmpServer.mName);\r
- /* Prepared for future addon Servers by Accesslevel */\r
- // tmpServer.mMinLv = atoi(row[s_minlv]);\r
- /* ------------------------------------------------ */\r
-\r
- Serverlist.insert(std::make_pair(atoi(row[s_id]), tmpServer));\r
- }\r
- }\r
- MySQL->FreeSQLResult(result);\r
-\r
- for(ServerMap::iterator it = Serverlist.begin(); it != Serverlist.end(); it++)\r
- {\r
- if(it->second.mUpdated == false)\r
- Serverlist.erase(it);\r
- else\r
- it->second.mUpdated = false;\r
- }\r
-\r
-}\r
-\r
-void PInfoServer::ClientDisconnected(PClient *Client)\r
-{\r
- InfoStateMap::iterator node = ClientStates.find(Client);\r
- if(node == ClientStates.end())\r
- return;\r
-\r
- PInfoState *State = node->second;\r
- FinalizeClient(Client, State);\r
-}\r
-\r
-bool PInfoServer::HandleHandshake(PInfoState *State, const u8 *Packet, int PacketSize)\r
-{\r
- //static const u8 HANDSHAKE1A[6]={0xfe, 0x03, 0x00, 0x80, 0x03, 0x68};\r
-\r
- switch(State->mState)\r
- {\r
- case PInfoState::IS_HANDSHAKE0 :\r
- {\r
- if(PacketSize==6 && *(u16*)&Packet[3]==0x0080 && Packet[5]==0x78)\r
- {\r
- //FIXME: this packet seems to be unnecessary, although it appears in traffic dumps\r
- // (causes clientside "Wrong protocol" errors)\r
- //Socket->Write(HANDSHAKE1A, 6);\r
- State->mState = PInfoState::IS_AUTHENTICATE;\r
- }\r
- else\r
- {\r
- Console->Print(RED, BLACK, "Infoserver protocol error (IS_HANDSHAKE0): invalid packet [%04x]", *(u16*)&Packet[3]);\r
- return false;\r
- }\r
- break;\r
- }\r
- default:\r
- break;\r
- }\r
-\r
- return true;\r
-}\r
-\r
-bool PInfoServer::HandleAuthenticate(PClient *Client, PInfoState *State, const u8 *Packet, int PacketSize)\r
-{\r
- int returnval = 0;\r
- // ReturnValue values:\r
- // 0: No error\r
- // -1: Wrong/Unknown username\r
- // -2: Wrong Password\r
- // -3: Malformed Auth Data. Please relog\r
- // -4: Database error, contact admin\r
- // -5: No such account, Account created. Please relog\r
- // -6: Could not create autoaccount, PW too short\r
- // -7: Could not create autoaccount, Name too short\r
- // -8: Could not create autoaccount, PW and Name too short\r
- // -9: Duplicate entry for Username! Contact Admin\r
- // -10: User is banned\r
- // -11: Insufficient access rights\r
- // -12: Account is not yet activated (accesslevel = 0)\r
- // -99: General fault. Contact admin\r
- ConnectionTCP *Socket = Client->getTCPConn();\r
- PAccount* currentAccount = NULL;\r
- \r
- if(PacketSize > 20 && *(u16*)&Packet[3]==0x8084)\r
- {\r
- const u8 *Key = &Packet[5]; // password key\r
- u16 ULen = *(u16*)&Packet[16]; // username length\r
- u16 PLen = *(u16*)&Packet[18]; // password length\r
- char *UserName = (char*)&Packet[20]; // account name\r
- const u8 *PW = &Packet[20+ULen]; // encoded password\r
-\r
- if(UserName[ULen-1]) // Check that string is well terminated\r
- {\r
- Console->Print("Infoserver: Client [%d]: Username was not NULL-terminated !", Client->GetIndex());\r
- returnval = -1;\r
- }\r
- else\r
- {\r
- currentAccount = new PAccount(UserName);\r
- if(!currentAccount->GetID())\r
- {\r
- if(Config->GetOptionInt("auto_accounts")) // Autoaccount\r
- {\r
- delete currentAccount;\r
- currentAccount = new PAccount();\r
- \r
- if(!currentAccount->SetName(UserName)) // !!! len\r
- {\r
- returnval = -7;\r
- }\r
- if(!currentAccount->SetPasswordEncoded(PW, PLen, Key))\r
- {\r
- returnval = returnval ? -8 : -6;\r
- }\r
- \r
- if(!returnval)\r
- {\r
- if(currentAccount->Create())\r
- {\r
- returnval = -5;\r
- }\r
- else\r
- {\r
- returnval = -4;\r
- }\r
- }\r
- }\r
- else\r
- {\r
- returnval = -1;\r
- }\r
- }\r
- else\r
- {\r
- if(currentAccount->Authenticate(PW, PLen, Key))\r
- { // Username & Password correct\r
- if(currentAccount->IsBanned())\r
- {\r
- returnval = -10;\r
- }\r
- else if(currentAccount->GetLevel() < Config->GetOptionInt("minlevel")) // insufficient access rights\r
- {\r
- returnval = -11;\r
- }\r
- else if(Config->GetOptionInt("require_validation") == 1 && currentAccount->GetLevel() == PAL_UNREGPLAYER)\r
- {\r
- returnval = -12;\r
- }\r
- else\r
- {\r
- Client->setAccountID(currentAccount->GetID());\r
- returnval = 0;\r
- }\r
- \r
- }\r
- else\r
- {\r
- returnval = -2;\r
- }\r
- }\r
- }\r
- \r
- bool Failed = false;\r
- if(returnval == 0)\r
- {\r
- u8 AUTHOK[28]={0xfe, 0x19, 0x00, 0x83, 0x81, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,\r
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
- 0x00, 0x00, 0x00, 0x00, 0x00 };\r
- *(u32*)&AUTHOK[5] = currentAccount->GetID();\r
- Socket->write(AUTHOK, 28);\r
- State->mState = PInfoState::IS_SERVERLIST;\r
- }\r
- else\r
- {\r
- Console->Print("Infoserver: User '%s': authentication failed. Errorcode %d", UserName, returnval);\r
- Failed = true; // auth failed\r
- }\r
- if(Failed == true)\r
- {\r
- std::string errorReason;\r
- switch(returnval)\r
- {\r
- // It seems that the client cuts the line off after 40 chars...\r
-// |1 |10 |20 |30 |40 |50 |60 |70 |80\r
- case -99:\r
- {\r
- //errorReason = "General fault in processing your login request";\r
- errorReason = "General fault while login request";\r
- break;\r
- }\r
- case -12:\r
- {\r
- //errorReason = "Account not activated. Please check your EMails";\r
- errorReason = "Error: Your account is not activated";\r
- break;\r
- }\r
- case -11:\r
- {\r
- //errorReason = "Login rejected. You have to be " + GetAccessString(Config->GetOptionInt("minlevel")) + " or higher";\r
- errorReason = "Level " + GetAccessString(Config->GetOptionInt("minlevel")) + " or higher required";\r
- break;\r
- }\r
- case -10:\r
- {\r
- errorReason = "You are banned for " + currentAccount->GetBannedTime();\r
- break;\r
- }\r
- case -9:\r
- {\r
- //errorReason = "Duplicate entry for this login. Contact Admin";\r
- errorReason = "Duplicate entry found. Contact Admin";\r
- break;\r
- }\r
- case -8:\r
- {\r
- //errorReason = "Autoaccount failed, name and password too short";\r
- errorReason = "AutoAcc failed, name and pwd too short";\r
- break;\r
- }\r
- case -7:\r
- {\r
- errorReason = "Autoaccount failed, name is too short";\r
- break;\r
- }\r
- case -6:\r
- {\r
- //errorReason = "Autoaccount failed, password is too short";\r
- errorReason = "Autoaccount failed, pwd is too short";\r
- break;\r
- }\r
- case -5:\r
- {\r
- errorReason = "New Account created, please login again";\r
- break;\r
- }\r
- case -4:\r
- {\r
- errorReason = "Database error, contact Administrator";\r
- break;\r
- }\r
- case -3:\r
- {\r
- errorReason = "Malformed AuthData. Please login again";\r
- break;\r
- }\r
- case -2:\r
- {\r
- errorReason = "Wrong password";\r
- break;\r
- }\r
- case -1:\r
- {\r
- errorReason = "Unknown username";\r
- break;\r
- }\r
- }\r
- u8 AUTHFAILED_HEADER[] = {0xfe, 0x0c, 0x00, 0x83, 0x86, 0x05, 0x00, 0x06, 0x00};\r
- u8 AUTHFAILED_FOOTER[] = {0x00, 0x40};\r
- *(u16*)&AUTHFAILED_HEADER[1] = errorReason.size() + 8;\r
- *(u16*)&AUTHFAILED_HEADER[7] = errorReason.size() + 1;\r
- //*(u8*)&AUTHFAILED_FOOTER[1] = {0x40};\r
-\r
- Socket->write(AUTHFAILED_HEADER, sizeof(AUTHFAILED_HEADER));\r
- Socket->write(errorReason.c_str(), errorReason.size());\r
- Socket->write(AUTHFAILED_FOOTER, sizeof(AUTHFAILED_FOOTER));\r
- FinalizeClientDelayed(Client, State);\r
- State->mState=PInfoState::IS_UNKNOWN;\r
- }\r
- }\r
- else\r
- {\r
- Console->Print(RED, BLACK, "Infoserver protocol error (IS_AUTHENTICATE): invalid packet [%04x]", *(u16*)&Packet[3]);\r
- return false;\r
- }\r
-\r
- return true;\r
-}\r
-\r
-bool PInfoServer::HandleServerList(PClient *Client, const u8 *Packet, int PacketSize)\r
-{\r
- u8 SERVERLIST_HEAD[] = {0xfe, 0x00, 0x00, 0x83, 0x83, 0x01, 0x00, 0x0d, 0x00};\r
- u8 SERVERLIST[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};\r
- u8 SERVERLIST_FOOTER[] = {0x00};\r
-\r
- ConnectionTCP *Socket = Client->getTCPConn();\r
-\r
- u32 tID = *(u32*)&Packet[5];\r
- PAccount* currentAccount = new PAccount(Client->getAccountID());\r
- u32 aID = currentAccount->GetID();\r
-\r
- if(!aID || (aID != tID))\r
- {\r
- Console->Print("%s invalid userID %d (auth with id %d)", Console->ColorText(YELLOW, BLACK, "Warning:"), tID, aID);\r
- delete currentAccount;\r
- return false;\r
- }\r
-\r
- if(currentAccount->GetLevel() < Config->GetOptionInt("minlevel"))\r
- {\r
- Console->Print("%s someone tried to bypass the login process! UserID %d", Console->ColorText(RED, BLACK, "Warning:"), aID);\r
- delete currentAccount;\r
- return false;\r
- }\r
-\r
- if(PacketSize == 31 && *(u16*)&Packet[3]==0x8284)\r
- {\r
- GSLiveCheck(); // Perform livecheck to have up-to-date data\r
-\r
- int len = 0;\r
- int num = 0;\r
- for(ServerMap::iterator it = Serverlist.begin(); it != Serverlist.end(); it++)\r
- {\r
- num++;\r
- len += 14 + strlen(it->second.mName);\r
- }\r
-\r
- *(u16*)&SERVERLIST_HEAD[1] = len;\r
- *(u8*)&SERVERLIST_HEAD[5] = num;\r
- Socket->write(SERVERLIST_HEAD, sizeof(SERVERLIST_HEAD));\r
-\r
- for(ServerMap::iterator it = Serverlist.begin(); it != Serverlist.end(); it++)\r
- {\r
- /* Prepared for future addon Servers by Accesslevel */\r
-// if(accesslevel >= it->second.mMinLv)\r
-// {\r
- /* ------------------------------------------------ */\r
- // Todo: Set correct lan/wan IP here!\r
- *(u32*)&SERVERLIST[0] = it->second.mLanIp;\r
- *(u16*)&SERVERLIST[4] = it->second.mPort;\r
- *(u8*)&SERVERLIST[8] = strlen(it->second.mName) + 1;\r
- *(u16*)&SERVERLIST[9] = it->second.mPlayers;\r
- if(it->second.mOnline == true)\r
- {\r
- 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);\r
- *(u16*)&SERVERLIST[11] = 1;\r
- }\r
- else if(it->second.mOnline == false)\r
- {\r
- 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);\r
- *(u16*)&SERVERLIST[11] = 0;\r
- }\r
- Socket->write(SERVERLIST, sizeof(SERVERLIST));\r
- Socket->write(it->second.mName, strlen(it->second.mName));\r
- Socket->write(SERVERLIST_FOOTER, sizeof(SERVERLIST_FOOTER));\r
- /* Prepared for future addon Servers by Accesslevel */\r
-// }\r
- /* ------------------------------------------------ */\r
- }\r
- }\r
- else\r
- {\r
- Console->Print(RED, BLACK, "Infoserver protocol error (IS_SERVERLIST): invalid packet [%04x]", *(u16*)&Packet[3]);\r
- delete currentAccount;\r
- return false;\r
- }\r
- delete currentAccount;\r
- return true;\r
-}\r
-\r
-bool PInfoServer::ProcessClient(PClient *Client, PInfoState *State)\r
-{\r
- static const u8 HANDSHAKE0A[6]={0xfe, 0x03, 0x00, 0x80, 0x01, 0x66};\r
-\r
- if(!State)\r
- {\r
- InfoStateMap::iterator node = ClientStates.find(Client);\r
- if(node == ClientStates.end())\r
- return false;\r
-\r
- State = node->second;\r
- }\r
-\r
- ConnectionTCP *Socket = Client->getTCPConn();\r
-\r
- if(State->mWaitSend && Socket->getSendBufferSize()==0)\r
- return false;\r
-\r
- if(State->mState==PInfoState::IS_CONNECTED)\r
- {\r
- Socket->write(HANDSHAKE0A, 6);\r
- State->mState = PInfoState::IS_HANDSHAKE0;\r
- }\r
-\r
- int PacketSize=0;\r
- const u8 *Packet = Socket->read(&PacketSize);\r
- if(PacketSize > 0)\r
- {\r
- switch(State->mState)\r
- {\r
- case PInfoState::IS_HANDSHAKE0:\r
- return HandleHandshake(State, Packet, PacketSize);\r
-\r
- case PInfoState::IS_AUTHENTICATE:\r
- return HandleAuthenticate(Client, State, Packet, PacketSize);\r
-\r
- case PInfoState::IS_SERVERLIST:\r
- return HandleServerList(Client, Packet, PacketSize);\r
- default:\r
- break;\r
- }\r
- }\r
- return true;\r
-}\r
-\r
-void PInfoServer::FinalizeClient(PClient *Client, PInfoState *State)\r
-{\r
- Console->Print(RED, BLACK, "Infoserver: client %s disconnected", Client->GetAddress());\r
- Client->InfoDisconnect();\r
- ClientStates.erase(Client);\r
- delete State;\r
-}\r
-\r
-void PInfoServer::FinalizeClientDelayed(PClient *Client, PInfoState *State)\r
-{\r
- Console->Print("Infoserver: client %i is about to be disconnected", Client->GetIndex());\r
- State->mWaitSend = true;\r
-}\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-#ifndef INFOSERVER_H\r
-#define INFOSERVER_H\r
-\r
-#ifdef _MSC_VER\r
- #pragma once\r
-#endif\r
-\r
-#define MAX_SERVER_NAME_LENGTH 45\r
-struct GameServers\r
-{\r
- char mName[MAX_SERVER_NAME_LENGTH];\r
- unsigned int mLanIp;\r
- unsigned int mWanIp;\r
- short mPort;\r
- int mPlayers;\r
- bool mOnline;\r
- bool mUpdated;\r
- long mLasttimestamp;\r
-/* Prepared for future addon Servers by Accesslevel */\r
-// int mMinLv;\r
-/* ------------------------------------------------ */\r
-};\r
-\r
-class PInfoServer\r
-{\r
- private :\r
- // SQL layout\r
- enum {\r
- s_id,\r
- s_name,\r
- s_wanaddr,\r
- s_port,\r
- s_players,\r
- s_lastupdate,\r
- s_lanaddr,\r
- s_timecheck // computed field, not in table !\r
- };\r
- //int mNumClients;\r
- typedef std::map<PClient*, struct PInfoState*> InfoStateMap;\r
- InfoStateMap ClientStates;\r
-\r
- typedef std::map<int, GameServers> ServerMap;\r
- ServerMap Serverlist;\r
-\r
- //time_t mLastLivecheck;\r
- int mLivecheckInterval;\r
- void GSLiveCheck();\r
-\r
- protected :\r
- bool ProcessClient(PClient *Client, PInfoState *State=NULL);\r
- void FinalizeClient(PClient *Client, PInfoState *State);\r
- void FinalizeClientDelayed(PClient *Client, PInfoState *State);\r
-\r
- bool HandleHandshake(PInfoState *State, const u8 *Packet, int PacketSize);\r
- bool HandleAuthenticate(PClient *Client, PInfoState *State, const u8 *Packet, int PacketSize);\r
- bool HandleServerList(PClient *Client, const u8 *Packet, int PacketSize);\r
- public :\r
- PInfoServer();\r
- ~PInfoServer();\r
-\r
- void Start();\r
- void Update();\r
- void ClientDisconnected(PClient *Client);\r
-};\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/* \r
- MODIFIED: 01 Jul 2006 hammag\r
- REASON: - commented out sched_yield() in main loop, as it is\r
- not needed anymore with a right timeout for ReadSetTCP select\r
- \r
-*/\r
-\r
-#include "main.h"\r
-\r
-void signal_handler(int signal)\r
-{\r
- if (signal == SIGINT)\r
- {\r
- Shutdown();\r
- }\r
-}\r
-\r
-int main()\r
-{\r
- signal(SIGINT, signal_handler);\r
-\r
- if(!Init())\r
- {\r
- if(Console)\r
- Console->Print("%s Aborting startup.", Console->ColorText(RED, BLACK, "[Fatal]"));\r
- Shutdown(); // exits with 0 ...\r
- }\r
-\r
- InfoServer->Start();\r
- Console->Print("Infoserver is now %s. Waiting for clients...", Console->ColorText(GREEN, BLACK, "Online"));\r
-\r
- while(1)\r
- {\r
- ServerSock->update();\r
- Server->Update();\r
- InfoServer->Update();\r
- MySQL->Update(); // MySQL keepalive\r
- Console->Update();\r
- }\r
-\r
- return 0;\r
-}\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- MODIFIED: 06 Jul 2006 Hammag\r
- REASON: - moved include "types.h" before include "../netcode/main.h" to enable compile\r
- MODIFIED: 27 Aug 2006 Hammag\r
- REASON: - replaced MAX_INFO_CLIENTS define by config setting\r
- - removed INFO_PORT define not used anymore\r
- MODIFIED: 10 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
-*/\r
-\r
-\r
-#ifndef MAIN_H\r
-#define MAIN_H\r
-\r
-//#include "version.h"\r
-\r
-//basic includes\r
-#include "include/external.h"\r
-\r
-//tinns includes\r
-#include "include/types.h"\r
-#include "common/netcode.h"\r
-\r
-// MySQL Support\r
-#ifdef MYSQL_INC_DIR\r
-#include <mysql/mysql.h>\r
-#else\r
-#include <mysql.h>\r
-#endif\r
-\r
-#include "sql.h"\r
-#include "common/console.h"\r
-#include "common/config.h"\r
-#include "accounts.h"\r
-#include "client.h"\r
-#include "server.h"\r
-#include "infoserver.h"\r
-#include "common/misc.h"\r
-#include "globals.h"\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
-\r
- MODIFIED: 27 Aug 2005 Hammag\r
- REASON: - Use mMaxClient member instead of MAX_INFO_CLIENTS define\r
-\r
-*/\r
-\r
-#include "main.h"\r
-\r
-PServer::PServer()\r
-{\r
- mMaxClients = Config->GetOptionInt("maxclients");\r
- \r
- mClients.reserve(mMaxClients);\r
- mNumClients = 0;\r
- for(int i=0; i<mMaxClients; i++)\r
- mClients[i]=0;\r
-}\r
-\r
-PServer::~PServer()\r
-{\r
- for(int i=0; i<mMaxClients; i++)\r
- delete mClients[i];\r
-}\r
-\r
-int PServer::NewClient()\r
-{\r
- if(mNumClients==mMaxClients)\r
- return -1;\r
-\r
- for(int i=0; i<mMaxClients; i++)\r
- {\r
- if(!mClients[i])\r
- {\r
- mClients[i]=new PClient(i);\r
- ++mNumClients;\r
- return i;\r
- }\r
- }\r
- return -1;\r
-}\r
-\r
-PClient *PServer::GetClient(int Client) const\r
-{\r
- if(Client < 0 || Client >= mMaxClients)\r
- return 0;\r
-\r
- return mClients[Client];\r
-}\r
-\r
-void PServer::Update()\r
-{\r
- for(int i=0; i<mMaxClients; i++)\r
- {\r
- if(mClients[i])\r
- {\r
- mClients[i]->Update();\r
- if(mClients[i]->GetConnection()==PCC_NONE && mClients[i]->getTCPConn() == 0)\r
- {\r
- Console->Print("Removing client ...");\r
- delete mClients[i];\r
- mClients[i]=0;\r
- --mNumClients;\r
- }\r
- }\r
- }\r
-}\r
-\r
-void PServer::Shutdown()\r
-{\r
- Console->Print("======================");\r
- Console->Print("Shutting down Infoserver...");\r
- for(int i=0; i<mMaxClients; i++)\r
- {\r
- if(mClients[i])\r
- {\r
- delete mClients[i];\r
- mClients[i]=0;\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- server.h\r
-\r
- MODIFIED: 25 Dec 2005 Namikon\r
- REASON: - Added GPL \r
- MODIFIED: 27 Aug 2005 Hammag\r
- REASON: - Added mMaxClient member \r
-*/\r
-\r
-#ifndef SERVER_H\r
-#define SERVER_H\r
-\r
-#ifdef _MSC_VER\r
- #pragma once\r
-#endif\r
-\r
-class PServer\r
-{\r
- private :\r
- int mMaxClients;\r
- int mNumClients;\r
- std::vector<PClient*> mClients;\r
- protected :\r
- public :\r
- PServer();\r
- ~PServer();\r
-\r
- inline int GetNumClients() const { return mNumClients; }\r
- int NewClient();\r
- PClient *GetClient(int Client) const;\r
- void Update();\r
- void Shutdown();\r
-};\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-#ifndef SQL_H\r
-#define SQL_H\r
-\r
-#ifdef _MSC_VER\r
- #pragma once\r
-#endif\r
-\r
-class PMySQL\r
-{\r
- private:\r
- int port;\r
- char host[100];\r
- char userName[100];\r
- char password[100];\r
- char database[100];\r
- MYSQL *dbHandle;\r
- std::time_t mKeepaliveDelay;\r
- std::time_t mLastKeepaliveSent;\r
-\r
- public:\r
- PMySQL();\r
- ~PMySQL();\r
-\r
- void Update();\r
- inline MYSQL *GetHandle() { return dbHandle; };\r
-\r
- bool Connect();\r
- int Query(const char *query);\r
- MYSQL_RES *ResQuery(const char *query);\r
- void ShowSQLError();\r
- void FreeSQLResult(MYSQL_RES *res);\r
- inline u32 GetLastInsertId() { return mysql_insert_id(dbHandle); };\r
- \r
- u32 EscapeString(const char* nText, char* dText, u32 dMaxLength);\r
-};\r
-#endif\r
+++ /dev/null
-ADD_EXECUTABLE (patchserver client.cpp globals.cpp patchserver.cpp main.cpp server.cpp)
-TARGET_LINK_LIBRARIES (patchserver common ${PCRE_LIBRARY} ${ZLIB_LIBRARY})
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-#include "main.h"\r
-\r
-PClient::PClient(int Index)\r
-{\r
- mIndex = Index;\r
- mConnection = PCC_NONE;\r
-}\r
-\r
-PClient::~PClient()\r
-{\r
- if(m_TCPConnection)\r
- {\r
- delete m_TCPConnection;\r
- }\r
-}\r
-\r
-void PClient::Update()\r
-{\r
- if(m_TCPConnection)\r
- {\r
- if(m_TCPConnection->timeOut())\r
- {\r
- Console->Print("Patchsocket: Client %i: timeout", mIndex);\r
- PatchServer->ClientDisconnected(this);\r
- }\r
- else\r
- {\r
- if(!m_TCPConnection->update())\r
- {\r
- PatchServer->ClientDisconnected(this);\r
- }\r
- }\r
- }\r
-}\r
-\r
-void PClient::PatchDisconnect()\r
-{\r
- if(m_TCPConnection)\r
- {\r
- delete m_TCPConnection;\r
- }\r
- mConnection = PCC_NONE;\r
- m_TCPConnection = 0;\r
-}\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-#ifndef CLIENT_H\r
-#define CLIENT_H\r
-\r
-enum PClientConnection\r
-{\r
- PCC_NONE = 0,\r
- PCC_PATCH = 1\r
-};\r
-class PClient\r
-{\r
- private :\r
- ConnectionTCP* m_TCPConnection;\r
- int mIndex;\r
- int mConnection;\r
-\r
-\r
- protected :\r
- public :\r
- PClient(int Index);\r
- ~PClient();\r
-\r
- inline int GetIndex() const { return mIndex; }\r
-\r
- inline int GetConnection() const { return mConnection; }\r
- inline const char *GetAddress() const { return m_TCPConnection->getRemoteAddress(); }\r
-\r
- void setTCPConnection(ConnectionTCP* conn) { m_TCPConnection = conn; mConnection = PCC_PATCH; }\r
-\r
- inline ConnectionTCP* getTCPConn() { return m_TCPConnection; }\r
-\r
- void Update();\r
-\r
- void PatchDisconnect();\r
-};\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-/*\r
- Configuration template for patchserver\r
- Used to set available/optional/required options when loading config\r
- with a PConfig object.\r
-*/\r
-\r
-const char* PatchConfigTemplate[][2] = {\r
- // {option_name, default_value} if default_value is empty string, it means option is mandatory\r
- // List ends with empty string for option_name\r
- {"server_version", "200"},\r
- {"patchserver_port", "8040"},\r
- {"patches_path", "./patches"},\r
- {"file_path", "./files"},\r
- {"max_file_xfers", "5"},\r
- {"patch_packet_size", "512"},\r
- {"maxclients", "5"},\r
- {"gm_slots", "2"},\r
- \r
- {"", ""} // do not change this line (end mark)\r
-};\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- MODIFIED: 27 Aug 2006 Hammag\r
- REASON: - Implemented shared Config class use and config template to load conf.\r
- - Added gameserver configtemplate.h include,\r
- - Added new required parameters to Config->LoadOptions()\r
- MODIFIED: 10 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
-\r
- TODO: - Get logfile name from config file \r
-*/\r
-\r
- \r
-#include "main.h"\r
-\r
-#include "configtemplate.h"\r
-\r
-#include "include/version.h"\r
-\r
-\r
-const char ServerVersion[] = TINNS_PATCH_VERSION;\r
-const char SVNRevision[] = TINNS_SVN_REVISION;\r
-\r
-ServerSocket* ServerSock = 0;\r
-PConsole *Console = 0;\r
-PServer *Server = 0;\r
-PConfig *Config = 0;\r
-PFileSystem *Filesystem = 0;\r
-PPatchServer *PatchServer = 0;\r
-\r
-bool InitTinNS()\r
-{\r
- Console = new PConsole("log/patchserver.log"); // Make that from config file !!!\r
- Console->Print("Starting TinNS Patchserver...");\r
- Console->Print(WHITE, BLUE, "/-------------------------------------------------------------------\\");\r
- Console->Print(WHITE, BLUE, "| TinNS (TinNS is not a Neocron Server) |");\r
- Console->Print(WHITE, BLUE, "| Copyright (C) 2005 Linux Addicted Community |");\r
- Console->Print(WHITE, BLUE, "| maintainer Akiko <akiko@gmx.org> |");\r
- Console->Print(WHITE, BLUE, "| ========================================== |");\r
- Console->Print(WHITE, BLUE, "| Head coders: The packet analyzing team: |");\r
- Console->Print(WHITE, BLUE, "| - Akiko - MaxxJag |");\r
- Console->Print(WHITE, BLUE, "| - bakkdoor - Sting |");\r
- Console->Print(WHITE, BLUE, "| - Namikon - Balm |");\r
- Console->Print(WHITE, BLUE, "| - Hammag |");\r
- Console->Print(WHITE, BLUE, "|-------------------------------------------------------------------|");\r
- Console->Print(WHITE, BLUE, "| This project would'nt be at its current stage without the help |");\r
- Console->Print(WHITE, BLUE, "| from the NeoPolis team, special thanks to you guys! |");\r
- Console->Print(WHITE, BLUE, "|-------------------------------------------------------------------|");\r
- Console->Print(WHITE, BLUE, "| This project is under GPL, see any source file for more details |");\r
- Console->Print(WHITE, BLUE, "\\-------------------------------------------------------------------/");\r
-\r
- //char svnrev[10];\r
- //GetSVNRev(svnrev);\r
- Console->LPrint("You are running TinNS Patchserver version");\r
- Console->LPrint(GREEN, BLACK, " %s", ServerVersion);\r
- Console->LPrint(WHITE, BLACK, " - SVN Rev");\r
- Console->LPrint(GREEN, BLACK, " %s", SVNRevision);\r
- Console->LClose();\r
- \r
- Config = new PConfig();\r
- if(!Config->LoadOptions(PatchConfigTemplate ,"./conf/patchserver.conf"))\r
- Shutdown();\r
-\r
- ServerSock = new ServerSocket();\r
- Server = new PServer();\r
- PatchServer = new PPatchServer();\r
-\r
- return true;\r
-}\r
-\r
-void Shutdown()\r
-{\r
- if(PatchServer) delete PatchServer;\r
- if(Config) delete Config;\r
- if(Console) delete Console;\r
- if(ServerSock) delete ServerSock;\r
- exit(0);\r
-}\r
-\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-#ifndef GLOBALS_H\r
-#define GLOBALS_H\r
-\r
-extern class ServerSocket* ServerSock;\r
-extern class PConsole *Console;\r
-extern class PConfig *Config;\r
-extern class PFileSystem *Filesystem;\r
-extern class PServer *Server;\r
-extern class PPatchServer *PatchServer;\r
-\r
-extern const char ServerVersion[];\r
-extern const char SVNRevision[];\r
-\r
-bool InitTinNS();\r
-void Shutdown();\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-\r
-\r
- MODIFIED: 01 Jul 2006 hammag\r
- REASON: - commented out sched_yield() in main loop, as it is\r
- not needed anymore with a right timeout for ReadSetTCP select\r
-\r
-*/ \r
-#include "main.h"\r
-\r
-// for handling strg-c signal to shutdown in correct way\r
-void signal_handler(int signal)\r
-{\r
- if (signal == SIGINT)\r
- {\r
- Shutdown();\r
- }\r
- else\r
- {\r
- psignal(signal, "Unkown signal: ");\r
- }\r
-}\r
-\r
-int main()\r
-{\r
- // Connect signal with handlerfunction\r
- signal(SIGINT, signal_handler);\r
-\r
-\r
- if(!InitTinNS())\r
- while(1)\r
- sleep(1);\r
-\r
- PatchServer->Start();\r
- Console->Print("Patchserver is now %s. Waiting for clients...", Console->ColorText(GREEN, BLACK, "Online"));\r
-\r
- while(1)\r
- {\r
- ServerSock->update();\r
- Server->Update();\r
- PatchServer->Update();\r
- // sched_yield();\r
- }\r
-\r
-\r
- return 0;\r
-}\r
-\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-/*\r
- MODIFIED: 06 Jul 2006 Hammag\r
- REASON: - moved include "types.h" before include "../netcode/main.h" to permit compile\r
- MODIFIED: 10 Jun 2009 Akiko\r
- REASON: - adjusted includes for new buildsystem\r
-*/\r
-\r
-#ifndef MAIN_H\r
-#define MAIN_H\r
-\r
-//#include "version.h"\r
-\r
-#define PATCH_PORT 7000\r
-#define MAX_PATCH_CLIENTS 50\r
-\r
-//basic includes\r
-#include "include/external.h"\r
-\r
-//tinns includes\r
-#include "include/types.h"\r
-#include "common/netcode.h"\r
-\r
-#include "common/console.h"\r
-#include "common/config.h"\r
-#include "common/filesystem.h"\r
-#include "client.h"\r
-#include "server.h"\r
-#include "patchserver.h"\r
-#include "common/misc.h"\r
-#include "globals.h"\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-#ifndef PATCHSERVER_H\r
-#define PATCHSERVER_H\r
-\r
-#ifdef _MSC_VER\r
- #pragma once\r
-#endif\r
-\r
-class PPatchServer\r
-{\r
- private :\r
- int mNumClients;\r
- int mNumFileTransfers;\r
- typedef std::map<PClient*, struct PPatchState*> PatchStateMap;\r
- PatchStateMap ClientStates;\r
- protected :\r
- bool ProcessClient(PClient *Client, PPatchState *State=0);\r
-// u32 StartPatch(PClient *Client, PPatchState *State);\r
- u32 StartPatch(PPatchState *State);\r
- bool SendPatchData(PClient *Client, PPatchState *State) const;\r
-// u32 StartFile(PClient *Client, PPatchState *State);\r
- u32 StartFile(PPatchState *State);\r
- bool SendFileData(PClient *Client, PPatchState *State) const;\r
- void FinalizeClient(PClient *Client, PPatchState *State);\r
- void FinalizeClientDelayed(PClient *Client, PPatchState *State);\r
-\r
- bool HandleHandshake(PClient *Client, PPatchState *State, const u8 *Packet, int PacketSize);\r
- bool HandleVersionRequest(PClient *Client, PPatchState *State, const u8 *Packet, int PacketSize);\r
- bool HandleFileRequests(PClient *Client, PPatchState *State, const u8 *Packet, int PacketSize);\r
- public :\r
- PPatchServer();\r
- ~PPatchServer();\r
-\r
- void Start();\r
- void Update();\r
- void ClientDisconnected(PClient *Client);\r
-};\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-#include "main.h"\r
-\r
-PServer::PServer()\r
-{\r
- mNumClients = 0;\r
- mMaxClients = Config->GetOptionInt("maxclients");\r
- mGMSlots = Config->GetOptionInt("gm_slots");\r
-\r
- if(mMaxClients==0)\r
- mMaxClients=1;\r
- if(mGMSlots==0)\r
- mGMSlots=1;\r
- mClients.reserve(mMaxClients + mGMSlots);\r
- for(int i=0; i<mMaxClients+mGMSlots; i++)\r
- mClients[i]=0;\r
-}\r
-\r
-PServer::~PServer()\r
-{\r
- for(int i=0; i<mMaxClients+mGMSlots; i++)\r
- delete mClients[i];\r
-}\r
-\r
-int PServer::NewClient()\r
-{\r
-//Console->Print("%d %d", mMaxClients, mGMSlots);\r
- if(mNumClients==mMaxClients+mGMSlots)\r
- return -1;\r
- for(int i=0; i<mMaxClients+mGMSlots; i++)\r
- {\r
- if(!mClients[i])\r
- {\r
- mClients[i]=new PClient(i);\r
- ++mNumClients;\r
- return i;\r
- }\r
- }\r
- return -1;\r
-}\r
-\r
-PClient *PServer::GetClient(int Client) const\r
-{\r
- if(Client < 0 || Client >= mMaxClients+mGMSlots)\r
- return 0;\r
-\r
- return mClients[Client];\r
-}\r
-\r
-void PServer::Update()\r
-{\r
- for(int i=0; i<mMaxClients+mGMSlots; i++)\r
- {\r
- if(mClients[i])\r
- {\r
- mClients[i]->Update();\r
- if(mClients[i]->GetConnection()==PCC_NONE && mClients[i]->getTCPConn() == 0)\r
- {\r
- Console->Print("Removing client ...");\r
- delete mClients[i];\r
- mClients[i]=0;\r
- --mNumClients;\r
- }\r
- }\r
- }\r
-}\r
-\r
-void PServer::Shutdown()\r
-{\r
- Console->Print("======================");\r
- Console->Print("Shutting down Patchserver...");\r
- for(int i=0; i<mMaxClients+mGMSlots; i++)\r
- {\r
- if(mClients[i])\r
- {\r
- delete mClients[i];\r
- mClients[i]=0;\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- Copyright (C) 2005 Linux Addicted Community\r
- maintainer Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-#ifndef SERVER_H\r
-#define SERVER_H\r
-\r
-class PServer\r
-{\r
- private :\r
- int mMaxClients;\r
- int mGMSlots;\r
- int mNumClients;\r
- std::vector<PClient*> mClients;\r
- protected :\r
- public :\r
- PServer();\r
- ~PServer();\r
-\r
- inline int GetMaxClients() const { return mMaxClients; }\r
- inline int GetGMSlots() const { return mGMSlots; }\r
- inline int GetNumClients() const { return mNumClients; }\r
- int NewClient();\r
- PClient *GetClient(int Client) const;\r
- void Update();\r
- void Shutdown();\r
-};\r
-\r
-#endif\r
-\r
+++ /dev/null
-ADD_SUBDIRECTORY (pak_decompress)
-ADD_SUBDIRECTORY (vfs_viewer)
+++ /dev/null
-ADD_EXECUTABLE (pak_decompress pak_decompress.cpp)
-TARGET_LINK_LIBRARIES (pak_decompress ${ZLIB_LIBRARY})
+++ /dev/null
-/*\r
- TinNS (TinNS is not a Neocron Server)\r
- pak_decompress - pak file decompression tool\r
- Copyright (C) 2005 Akiko <akiko@gmx.org>\r
-\r
- This program is free software; you can redistribute it and/or\r
- modify it under the terms of the GNU General Public License\r
- as published by the Free Software Foundation; either version 2\r
- of the License, or (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- 02110-1301, USA.\r
-*/\r
-\r
-\r
-\r
-/*\r
- pak_decompress - a decompression tool for single pak files\r
-\r
- MODIFIED: 23 Sep 2005 Akiko\r
- REASON: - started this tool\r
- MODIFIED: 26 Sep 2005 Akiko\r
- REASON: - added printing of some information\r
- MODIFIED: 26 Oct 2005 Akiko\r
- REASON: - fixed an issue belonging to portability\r
- MODIFIED: 06 Dec 2005 Akiko\r
- REASON: - compression ration fixed\r
- MODIFIED: 09 Dec 2005 Akiko\r
- REASON: - fixed typo\r
- - compression ratio\r
- MODIFIED: 21 Dec 2006 Namikon\r
- REASON: - Added errorcheck for in/output file\r
- - Added check for NC and normal zLib files\r
- MODIFIED: 15 Jun 2009 Akiko\r
- REASON: - fixed warning\r
-\r
- TODO: - time needed for decompression\r
- - ideas for a compression tool\r
-*/\r
-\r
-#include <iostream>\r
-#include <fstream>\r
-#include <cstdio>\r
-#include <cstring>\r
-#include <cassert>\r
-#include <zlib.h>\r
-\r
-#define CHUNK 262144\r
-\r
-int inf(FILE *source, FILE *dest, bool details)\r
-{\r
- int ret;\r
- char check;\r
- unsigned have;\r
- z_stream strm;\r
- unsigned char in[CHUNK];\r
- unsigned char out[CHUNK];\r
-\r
- strm.zalloc = Z_NULL;\r
- strm.zfree = Z_NULL;\r
- strm.opaque = Z_NULL;\r
- strm.avail_in = 0;\r
- strm.next_in = Z_NULL;\r
- ret = inflateInit(&strm);\r
-\r
- if (ret != Z_OK)\r
- return(ret);\r
-\r
- check = fgetc(source);\r
- if(check == 'x')\r
- {\r
- if(details == true) std::cout << "Found zLibfile" << std::endl;\r
- fseek(source, 0, SEEK_SET);\r
- }\r
- else\r
- {\r
- fseek(source, 16, SEEK_SET);\r
- check = fgetc(source);\r
- if(check == 'x')\r
- {\r
- if(details == true) std::cout << "Found Neocron file" << std::endl;\r
- fseek(source, 16, SEEK_SET);\r
- }\r
- else\r
- {\r
- if(details == true) std::cout << "Error: No compatible file!" << std::endl;\r
- return -3;\r
- }\r
- }\r
-\r
- do {\r
- strm.avail_in = fread(in, 1, CHUNK, source);\r
-\r
- if (ferror(source)) {\r
- (void)inflateEnd(&strm);\r
-\r
- return(Z_ERRNO);\r
- }\r
-\r
- if (strm.avail_in == 0)\r
- break;\r
- strm.next_in = in;\r
-\r
- do {\r
- strm.avail_out = CHUNK;\r
- strm.next_out = out;\r
- ret = inflate(&strm, Z_NO_FLUSH);\r
- assert(ret != Z_STREAM_ERROR);\r
-\r
- switch(ret) {\r
- case Z_NEED_DICT:\r
- ret = Z_DATA_ERROR;\r
- case Z_DATA_ERROR:\r
- case Z_MEM_ERROR:\r
- (void)inflateEnd(&strm);\r
- return(ret);\r
- }\r
-\r
- have = CHUNK - strm.avail_out;\r
-\r
- if (fwrite(out, 1, have, dest) != have || ferror(dest)) {\r
- (void)inflateEnd(&strm);\r
-\r
- return(Z_ERRNO);\r
- }\r
- } while (strm.avail_out == 0);\r
-\r
- assert(strm.avail_in == 0);\r
- } while (ret != Z_STREAM_END);\r
-\r
- (void)inflateEnd(&strm);\r
- \r
- return(ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR);\r
-}\r
-\r
-void zerr(int ret)\r
-{\r
- fputs("zpipe: ", stderr);\r
-\r
- switch(ret) {\r
- case Z_ERRNO:\r
- if (ferror(stdin))\r
- fputs("error reading stdin\n", stderr);\r
- if (ferror(stdout))\r
- fputs("error writing stdout\n", stderr);\r
- break;\r
- case Z_STREAM_ERROR:\r
- fputs("invalid compression level\n", stderr);\r
- break;\r
- case Z_DATA_ERROR:\r
- fputs("invalid or incomplete deflate data\n", stderr);\r
- break;\r
- case Z_MEM_ERROR:\r
- fputs("out of memory\n", stderr);\r
- break;\r
- case Z_VERSION_ERROR:\r
- fputs("zlib version mismatch!\n", stderr);\r
- }\r
-}\r
-\r
-int main(int argc, char **argv) {\r
- int ret;\r
- long inSize;\r
- long outSize;\r
- bool details = false;\r
- FILE *inFile;\r
- FILE *outFile;\r
- std::string src;\r
- std::string dst;\r
-\r
- if(argc == 2) {\r
- src = argv[1];\r
- dst = strcat(argv[1], ".decompressed");\r
- }\r
- else if(argc > 2 && strcmp(argv[1], argv[2])) {\r
- src = argv[1];\r
- dst = argv[2];\r
- }\r
- else {\r
- std::cout << "Usage: pak_decompress source <dest != source> <detailedoutput 1/0>" << std::endl;\r
- return(0);\r
- }\r
- if(argc == 4)\r
- {\r
- if(argv[3][0] == '1') details = true;\r
- else if(argv[3][0] == '0') details = false;\r
- }\r
-\r
- inFile = fopen(src.c_str(), "rb");\r
- outFile = fopen(dst.c_str(), "wb");\r
-\r
- if(inFile == NULL)\r
- {\r
- std::cout << "Cannot open InFile" << std::endl;\r
- return(-1);\r
- }\r
- if(outFile == NULL)\r
- {\r
- std::cout << "Cannot open OutFile" << std::endl;\r
- return(-2);\r
- }\r
- ret = inf(inFile, outFile, details);\r
-\r
- /* just to be sure - we got to the end */\r
- fseek(inFile, 0, SEEK_END);\r
- fseek(outFile, 0, SEEK_END);\r
- inSize = ftell(inFile);\r
- outSize = ftell(outFile);\r
- \r
- fclose(outFile);\r
- fclose(inFile);\r
- \r
- if(ret == Z_OK && details == true)\r
- {\r
- std::cout << "bytes read: " << inSize << std::endl;\r
- std::cout << "bytes written: " << outSize << std::endl;\r
- std::cout << "compression ratio: " << (100-((float)inSize/(float)outSize*100)) << "%" << std::endl;\r
- }\r
- else if(ret == Z_OK && details == false)\r
- {\r
- std::cout << "[OK] " << src.c_str() << std::endl;\r
- }\r
- else if(ret != Z_OK && details == false)\r
- {\r
- std::cout << "[ERROR] " << src.c_str() << std::endl;\r
- }\r
-\r
- return(ret);\r
-}\r
-\r
-\r
+++ /dev/null
-ADD_EXECUTABLE (vfs_viewer vfs_viewer.c)
-TARGET_LINK_LIBRARIES (vfs_viewer ${ZLIB_LIBRARY})
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- vfs_viewer.c - NC virutal file system decompression/browsing tool
- Copyright (C) 2005 Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public 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 <akiko@gmx.org>
-
- 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 <stdio.h>
-#include <stdlib.h>
-
-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 <nc1 vfs file>\n");
- exit(1);
- }
-
- exit(0);
-}
-