mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-04 01:34:07 +00:00
.github
dAuthServer
dChatFilter
dChatServer
dCommon
dDatabase
dGame
dMasterServer
dNavigation
dNet
dPhysics
dScripts
dWorldServer
dZoneManager
docker
docs
migrations
resources
tests
thirdparty
AccountManager
SQLite
cpp-httplib
cpplinq
libbcrypt
mariadb-connector-cpp
raknet
Lib
Source
AsynchronousFileIO.cpp
AsynchronousFileIO.h
AutoRPC.cpp
AutoRPC.h
AutopatcherPatchContext.h
AutopatcherRepositoryInterface.h
BigTypes.h
BitStream.cpp
BitStream.h
BitStream_NoTemplate.cpp
BitStream_NoTemplate.h
CheckSum.cpp
CheckSum.h
ClientContextStruct.h
CommandParserInterface.cpp
CommandParserInterface.h
ConnectionGraph.cpp
ConnectionGraph.h
ConsoleServer.cpp
ConsoleServer.h
DS_BPlusTree.h
DS_BinarySearchTree.h
DS_BytePool.cpp
DS_BytePool.h
DS_ByteQueue.cpp
DS_ByteQueue.h
DS_Heap.h
DS_HuffmanEncodingTree.cpp
DS_HuffmanEncodingTree.h
DS_HuffmanEncodingTreeFactory.h
DS_HuffmanEncodingTreeNode.h
DS_LinkedList.h
DS_List.h
DS_Map.h
DS_MemoryPool.h
DS_OrderedChannelHeap.h
DS_OrderedList.h
DS_Queue.h
DS_QueueLinkedList.h
DS_RangeList.h
DS_Table.cpp
DS_Table.h
DS_Tree.h
DS_WeightedGraph.h
DataBlockEncryptor.cpp
DataBlockEncryptor.h
DataCompressor.cpp
DataCompressor.h
DirectoryDeltaTransfer.cpp
DirectoryDeltaTransfer.h
EmailSender.cpp
EmailSender.h
EncodeClassName.cpp
EpochTimeToString.cpp
EpochTimeToString.h
Export.h
ExtendedOverlappedPool.cpp
ExtendedOverlappedPool.h
FileList.cpp
FileList.h
FileListTransfer.cpp
FileListTransfer.h
FileListTransferCBInterface.h
FileOperations.cpp
FileOperations.h
FormatString.cpp
FormatString.h
FullyConnectedMesh.cpp
FullyConnectedMesh.h
FunctionThread.cpp
FunctionThread.h
Gen_RPC8.cpp
Gen_RPC8.h
GetTime.cpp
GetTime.h
GridSectorizer.cpp
GridSectorizer.h
HTTPConnection.cpp
HTTPConnection.h
InlineFunctor.cpp
InlineFunctor.h
InternalPacket.h
Itoa.cpp
Itoa.h
Kbhit.h
LightweightDatabaseClient.cpp
LightweightDatabaseClient.h
LightweightDatabaseCommon.cpp
LightweightDatabaseCommon.h
LightweightDatabaseServer.cpp
LightweightDatabaseServer.h
LinuxStrings.cpp
LinuxStrings.h
LogCommandParser.cpp
LogCommandParser.h
MTUSize.h
Makefile.am
MessageFilter.cpp
MessageFilter.h
MessageIdentifiers.h
NatPunchthrough.cpp
NatPunchthrough.h
NetworkIDManager.cpp
NetworkIDManager.h
NetworkIDObject.cpp
NetworkIDObject.h
PacketConsoleLogger.cpp
PacketConsoleLogger.h
PacketFileLogger.cpp
PacketFileLogger.h
PacketLogger.cpp
PacketLogger.h
PacketPool.h
PacketPriority.h
PluginInterface.cpp
PluginInterface.h
RPCMap.cpp
RPCMap.h
RPCNode.h
RSACrypt.h
RakAssert.h
RakMemoryOverride.cpp
RakMemoryOverride.h
RakNet.vcproj
RakNet3.0.vcproj
RakNetCommandParser.cpp
RakNetCommandParser.h
RakNetDefines.h
RakNetStatistics.cpp
RakNetStatistics.h
RakNetTransport.cpp
RakNetTransport.h
RakNetTypes.cpp
RakNetTypes.h
RakNetVersion.h
RakNet_vc8.vcproj
RakNetworkFactory.cpp
RakNetworkFactory.h
RakPeer.cpp
RakPeer.h
RakPeerInterface.h
RakSleep.cpp
RakSleep.h
RakString.cpp
RakString.h
RakThread.cpp
RakThread.h
Rand.cpp
Rand.h
ReadyEvent.cpp
ReadyEvent.h
RefCountedObj.h
ReliabilityLayer.cpp
ReliabilityLayer.h
Replica.h
ReplicaEnums.h
ReplicaManager.cpp
ReplicaManager.h
ReplicaManager2.cpp
ReplicaManager2.h
Rijndael-Boxes.h
Rijndael.h
Router.cpp
Router.h
RouterInterface.h
SHA1.cpp
SHA1.h
SimpleMutex.cpp
SimpleMutex.h
SimpleTCPServer.h
SingleProducerConsumer.h
SocketLayer.cpp
SocketLayer.h
StringCompressor.cpp
StringCompressor.h
StringTable.cpp
StringTable.h
SuperFastHash.cpp
SuperFastHash.h
SystemAddressList.cpp
SystemAddressList.h
TCPInterface.cpp
TCPInterface.h
TableSerializer.cpp
TableSerializer.h
TelnetTransport.cpp
TelnetTransport.h
ThreadPool.h
ThreadsafePacketLogger.cpp
ThreadsafePacketLogger.h
TransportInterface.h
Types.h
_FindFirst.cpp
_FindFirst.h
rijndael.cpp
CMakeLists.txt
version.txt
recastnavigation
tinyxml2
CMakeLists.txt
CMakeMariaDBLists.txt
vanity
.dockerignore
.editorconfig
.env.example
.git-blame-ignore-revs
.gitattributes
.gitignore
.gitmodules
CMakeLists.txt
CMakePresets.json
CMakeVariables.txt
CONTRIBUTING.md
Docker.md
Docker_Windows.md
LICENSE
README.md
SECURITY.md
build.sh
docker-compose.yml
logo.png
versions.txt
150 lines
8.3 KiB
C++
150 lines
8.3 KiB
C++
/// \file
|
|
/// \brief Contains CommandParserInterface , from which you derive custom command parsers
|
|
///
|
|
/// This file is part of RakNet Copyright 2003 Kevin Jenkins.
|
|
///
|
|
/// Usage of RakNet is subject to the appropriate license agreement.
|
|
/// Creative Commons Licensees are subject to the
|
|
/// license found at
|
|
/// http://creativecommons.org/licenses/by-nc/2.5/
|
|
/// Single application licensees are subject to the license found at
|
|
/// http://www.jenkinssoftware.com/SingleApplicationLicense.html
|
|
/// Custom license users are subject to the terms therein.
|
|
/// GPL license users are subject to the GNU General Public
|
|
/// License as published by the Free
|
|
/// Software Foundation; either version 2 of the License, or (at your
|
|
/// option) any later version.
|
|
|
|
#ifndef __COMMAND_PARSER_INTERFACE
|
|
#define __COMMAND_PARSER_INTERFACE
|
|
|
|
#include "RakMemoryOverride.h"
|
|
#include "RakNetTypes.h"
|
|
#include "DS_OrderedList.h"
|
|
#include "Export.h"
|
|
|
|
class TransportInterface;
|
|
|
|
/// \internal
|
|
/// Contains the information related to one command registered with RegisterCommand()
|
|
/// Implemented so I can have an automatic help system via SendCommandList()
|
|
struct RAK_DLL_EXPORT RegisteredCommand
|
|
{
|
|
const char *command;
|
|
const char *commandHelp;
|
|
unsigned char parameterCount;
|
|
};
|
|
|
|
/// List of commands registered with RegisterCommand()
|
|
int RAK_DLL_EXPORT RegisteredCommandComp( const char* const & key, const RegisteredCommand &data );
|
|
|
|
/// CommandParserInterface provides a set of functions and interfaces that plug into the ConsoleServer class.
|
|
/// Each CommandParserInterface works at the same time as other interfaces in the system.
|
|
/// \brief The interface used by command parsers.
|
|
class RAK_DLL_EXPORT CommandParserInterface : public RakNet::RakMemoryOverride
|
|
{
|
|
public:
|
|
CommandParserInterface();
|
|
virtual ~CommandParserInterface();
|
|
|
|
/// You are responsible for overriding this function and returning a static string, which will identifier your parser.
|
|
/// This should return a static string
|
|
/// \return The name that you return.
|
|
virtual const char *GetName(void) const=0;
|
|
|
|
/// A callback for when \a systemAddress has connected to us.
|
|
/// \param[in] systemAddress The player that has connected.
|
|
/// \param[in] transport The transport interface that sent us this information. Can be used to send messages to this or other players.
|
|
virtual void OnNewIncomingConnection(SystemAddress systemAddress, TransportInterface *transport);
|
|
|
|
/// A callback for when \a systemAddress has disconnected, either gracefully or forcefully
|
|
/// \param[in] systemAddress The player that has disconnected.
|
|
/// \param[in] transport The transport interface that sent us this information.
|
|
virtual void OnConnectionLost(SystemAddress systemAddress, TransportInterface *transport);
|
|
|
|
/// A callback for when you are expected to send a brief description of your parser to \a systemAddress
|
|
/// \param[in] transport The transport interface we can use to write to
|
|
/// \param[in] systemAddress The player that requested help.
|
|
virtual void SendHelp(TransportInterface *transport, SystemAddress systemAddress)=0;
|
|
|
|
/// Given \a command with parameters \a parameterList , do whatever processing you wish.
|
|
/// \param[in] command The command to process
|
|
/// \param[in] numParameters How many parameters were passed along with the command
|
|
/// \param[in] parameterList The list of parameters. parameterList[0] is the first parameter and so on.
|
|
/// \param[in] transport The transport interface we can use to write to
|
|
/// \param[in] systemAddress The player that sent this command.
|
|
/// \param[in] originalString The string that was actually sent over the network, in case you want to do your own parsing
|
|
virtual bool OnCommand(const char *command, unsigned numParameters, char **parameterList, TransportInterface *transport, SystemAddress systemAddress, const char *originalString)=0;
|
|
|
|
/// This is called every time transport interface is registered. If you want to save a copy of the TransportInterface pointer
|
|
/// This is the place to do it
|
|
/// \param[in] transport The new TransportInterface
|
|
virtual void OnTransportChange(TransportInterface *transport);
|
|
|
|
/// \internal
|
|
/// Scan commandList and return the associated array
|
|
/// \param[in] command The string to find
|
|
/// \param[out] rc Contains the result of this operation
|
|
/// \return True if we found the command, false otherwise
|
|
virtual bool GetRegisteredCommand(const char *command, RegisteredCommand *rc);
|
|
|
|
/// \internal
|
|
/// Goes through str, replacing the delineating character with 0's.
|
|
/// \param[in] str The string sent by the transport interface
|
|
/// \param[in] delineator The character to scan for to use as a delineator
|
|
/// \param[in] delineatorToggle When encountered the delineator replacement is toggled on and off
|
|
/// \param[out] numParameters How many pointers were written to \a parameterList
|
|
/// \param[out] parameterList An array of pointers to characters. Will hold pointers to locations inside \a str
|
|
/// \param[in] parameterListLength How big the \a parameterList array is
|
|
static void ParseConsoleString(char *str, const char delineator, unsigned char delineatorToggle, unsigned *numParameters, char **parameterList, unsigned parameterListLength);
|
|
|
|
/// \internal
|
|
/// Goes through the variable commandList and sends the command portion of each struct
|
|
/// \param[in] transport The transport interface we can use to write to
|
|
/// \param[in] systemAddress The player to write to
|
|
virtual void SendCommandList(TransportInterface *transport, SystemAddress systemAddress);
|
|
|
|
static const unsigned char VARIABLE_NUMBER_OF_PARAMETERS;
|
|
|
|
protected:
|
|
// Currently only takes static strings - doesn't make a copy of what you pass.
|
|
// parameterCount is the number of parameters that the sender has to include with the command.
|
|
// Pass 255 to parameterCount to indicate variable number of parameters
|
|
|
|
/// Registers a command.
|
|
/// \param[in] parameterCount How many parameters your command requires. If you want to accept a variable number of commands, pass CommandParserInterface::VARIABLE_NUMBER_OF_PARAMETERS
|
|
/// \param[in] command A pointer to a STATIC string that has your command. I keep a copy of the pointer here so don't deallocate the string.
|
|
/// \param[in] commandHelp A pointer to a STATIC string that has the help information for your command. I keep a copy of the pointer here so don't deallocate the string.
|
|
virtual void RegisterCommand(unsigned char parameterCount, const char *command, const char *commandHelp);
|
|
|
|
/// Just writes a string to the remote system based on the result ( \a res )of your operation
|
|
/// This is not necessary to call, but makes it easier to return results of function calls
|
|
/// \param[in] res The result to write
|
|
/// \param[in] command The command that this result came from
|
|
/// \param[in] transport The transport interface that will be written to
|
|
/// \param[in] systemAddress The player this result will be sent to
|
|
virtual void ReturnResult(bool res, const char *command, TransportInterface *transport, SystemAddress systemAddress);
|
|
virtual void ReturnResult(char *res, const char *command, TransportInterface *transport, SystemAddress systemAddress);
|
|
virtual void ReturnResult(SystemAddress res, const char *command, TransportInterface *transport, SystemAddress systemAddress);
|
|
virtual void ReturnResult(int res, const char *command,TransportInterface *transport, SystemAddress systemAddress);
|
|
|
|
/// Just writes a string to the remote system when you are calling a function that has no return value
|
|
/// This is not necessary to call, but makes it easier to return results of function calls
|
|
/// \param[in] res The result to write
|
|
/// \param[in] command The command that this result came from
|
|
/// \param[in] transport The transport interface that will be written to
|
|
/// \param[in] systemAddress The player this result will be sent to
|
|
virtual void ReturnResult(const char *command,TransportInterface *transport, SystemAddress systemAddress);
|
|
|
|
|
|
/// Since there's no way to specify a systemAddress directly, the user needs to specify both the binary address and port.
|
|
/// Given those parameters, this returns the corresponding SystemAddress
|
|
/// \param[in] binaryAddress The binaryAddress portion of SystemAddress
|
|
/// \param[in] port The port portion of SystemAddress
|
|
SystemAddress IntegersToSystemAddress(int binaryAddress, int port);
|
|
|
|
DataStructures::OrderedList<const char*, RegisteredCommand, RegisteredCommandComp> commandList;
|
|
};
|
|
|
|
#endif
|