mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-09 20:24:16 +00:00
Welp, ended up doing client as well since world and client are in the wroing places.
This commit is contained in:
@@ -6,6 +6,139 @@
|
||||
#include "ClientPackets.h"
|
||||
#include "dCommonVars.h"
|
||||
#include "PositionUpdate.h"
|
||||
#include "LDFFormat.h"
|
||||
#include "ZCompression.h"
|
||||
|
||||
namespace ClientPackets {
|
||||
void LoadStaticZone::Serialize(RakNet::BitStream &bitStream) const {
|
||||
bitStream.Write<uint16_t>(zoneID.GetMapID());
|
||||
bitStream.Write<uint16_t>(zoneID.GetInstanceID());
|
||||
bitStream.Write<uint32_t>(checksum);
|
||||
bitStream.Write<uint8_t>(editorEnabled);
|
||||
bitStream.Write<uint8_t>(editorLevel);
|
||||
bitStream.Write(position.x);
|
||||
bitStream.Write(position.y);
|
||||
bitStream.Write(position.z);
|
||||
bitStream.Write<uint32_t>(instanceType);
|
||||
}
|
||||
void CharacterCreationResponse::Serialize(RakNet::BitStream &bitStream) const {
|
||||
bitStream.Write(response);
|
||||
}
|
||||
|
||||
void CharacterRenameResponse::Serialize(RakNet::BitStream &bitStream) const {
|
||||
bitStream.Write(response);
|
||||
}
|
||||
|
||||
void CharacterDeleteResponse::Serialize(RakNet::BitStream &bitStream) const {
|
||||
bitStream.Write<uint8_t>(success);
|
||||
}
|
||||
|
||||
void TransferToWorld::Serialize(RakNet::BitStream &bitStream) const {
|
||||
bitStream.Write(LUString(serverIP));
|
||||
bitStream.Write<uint16_t>(serverPort);
|
||||
bitStream.Write<uint8_t>(mythranShift);
|
||||
}
|
||||
|
||||
void ServerState::Serialize(RakNet::BitStream &bitStream) const {
|
||||
bitStream.Write<uint8_t>(serverReady);
|
||||
}
|
||||
void CreateCharacter::Serialize(RakNet::BitStream &bitStream) const {
|
||||
|
||||
RakNet::BitStream data;
|
||||
|
||||
data.Write<uint32_t>(7); //LDF key count
|
||||
std::unique_ptr<LDFData<LWOOBJID>> objidLDF(new LDFData<LWOOBJID>(u"objid", objid));
|
||||
objidLDF->WriteToPacket(data);
|
||||
|
||||
std::unique_ptr<LDFData<LOT>> templateIDLDF(new LDFData<LOT>(u"template", templateID));
|
||||
templateIDLDF->WriteToPacket(data);
|
||||
|
||||
std::unique_ptr<LDFData<std::u16string>> nameLDF(new LDFData<std::u16string>(u"name", name));
|
||||
nameLDF->WriteToPacket(data);
|
||||
|
||||
std::unique_ptr<LDFData<int32_t>> gmlevelLDF(new LDFData<int32_t>(u"gmlevel", static_cast<int32_t>(gmLevel)));
|
||||
gmlevelLDF->WriteToPacket(data);
|
||||
|
||||
std::unique_ptr<LDFData<int32_t>> chatModeLDF(new LDFData<int32_t>(u"chatmode", static_cast<int32_t>(chatMode)));
|
||||
chatModeLDF->WriteToPacket(data);
|
||||
|
||||
std::unique_ptr<LDFData<std::string>> xmlConfigData(new LDFData<std::string>(u"xmlData", xmlData));
|
||||
xmlConfigData->WriteToPacket(data);
|
||||
|
||||
std::unique_ptr<LDFData<int64_t>> reputationLdf(new LDFData<int64_t>(u"reputation", reputation));
|
||||
reputationLdf->WriteToPacket(data);
|
||||
|
||||
//Compress the data before sending:
|
||||
const uint32_t reservedSize = ZCompression::GetMaxCompressedLength(data.GetNumberOfBytesUsed());
|
||||
uint8_t* compressedData = new uint8_t[reservedSize];
|
||||
|
||||
if (!compressedData) {
|
||||
throw std::runtime_error("Failed to allocate memory for compressed data");
|
||||
}
|
||||
|
||||
size_t size = ZCompression::Compress(data.GetData(), data.GetNumberOfBytesUsed(), compressedData, reservedSize);
|
||||
|
||||
assert(size <= reservedSize);
|
||||
|
||||
bitStream.Write<uint32_t>(size + 9); //size of data + header bytes (8)
|
||||
bitStream.Write<uint8_t>(1); //compressed boolean, true
|
||||
bitStream.Write<uint32_t>(data.GetNumberOfBytesUsed());
|
||||
bitStream.Write<uint32_t>(size);
|
||||
|
||||
/**
|
||||
* In practice, this warning serves no purpose for us. We allocate the max memory needed on the heap
|
||||
* and then compress the data. In the off chance that the compression actually increases the size,
|
||||
* an assertion is done to prevent bad data from being saved or sent.
|
||||
*/
|
||||
#pragma warning(disable:6385) // C6385 Reading invalid data from 'compressedData'.
|
||||
bitStream.WriteAlignedBytes(compressedData, size);
|
||||
#pragma warning(default:6385)
|
||||
delete[] compressedData;
|
||||
};
|
||||
|
||||
void ChatModerationString::Serialize(RakNet::BitStream &bitStream) const {
|
||||
bitStream.Write<uint8_t>(rejectedWords.empty()); // Accepted
|
||||
bitStream.Write<uint16_t>(0); // padding
|
||||
|
||||
bitStream.Write(chatChannel);
|
||||
bitStream.Write(chatMode);
|
||||
|
||||
bitStream.Write(LUWString(receiver, 42));
|
||||
|
||||
for (auto it : rejectedWords) {
|
||||
bitStream.Write<uint8_t>(it.first); // start index
|
||||
bitStream.Write<uint8_t>(it.second); // length
|
||||
}
|
||||
|
||||
// Pad out the rest of the packet
|
||||
// The client expects 64 items, so we need to write 64 - rejectedWords.size() empty items
|
||||
for (int i = rejectedWords.size(); 64 > i; i++) {
|
||||
bitStream.Write<uint16_t>(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void GMLevelChange::Serialize(RakNet::BitStream &bitStream) const {
|
||||
bitStream.Write<uint8_t>(success);
|
||||
bitStream.Write(static_cast<uint16_t>(highestLevel));
|
||||
bitStream.Write(static_cast<uint16_t>(prevLevel));
|
||||
bitStream.Write(static_cast<uint16_t>(newLevel));
|
||||
}
|
||||
|
||||
void DebugOutput::Serialize(RakNet::BitStream &bitStream) const {
|
||||
bitStream.Write<uint32_t>(data.size());
|
||||
bitStream.Write(data);
|
||||
}
|
||||
|
||||
void HTTPMonitorInfoResponse::Serialize(RakNet::BitStream &bitStream) const {
|
||||
bitStream.Write<uint16_t>(port);
|
||||
bitStream.Write<uint8_t>(openWeb);
|
||||
bitStream.Write<uint8_t>(supportsSum);
|
||||
bitStream.Write<uint8_t>(supportsDetail);
|
||||
bitStream.Write<uint8_t>(supportsWho);
|
||||
bitStream.Write<uint8_t>(supportsObjects);
|
||||
}
|
||||
}
|
||||
|
||||
ChatMessage ClientPackets::HandleChatMessage(Packet* packet) {
|
||||
CINSTREAM_SKIP_HEADER;
|
||||
@@ -114,10 +247,3 @@ ChatModerationRequest ClientPackets::HandleChatModerationRequest(Packet* packet)
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
int32_t ClientPackets::SendTop5HelpIssues(Packet* packet) {
|
||||
CINSTREAM_SKIP_HEADER;
|
||||
int32_t language = 0;
|
||||
inStream.Read(language);
|
||||
return language;
|
||||
}
|
||||
|
@@ -8,6 +8,10 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include "BitStreamUtils.h"
|
||||
#include "eGameMasterLevel.h"
|
||||
#include "eChatChannel.h"
|
||||
#include "dCommonVars.h"
|
||||
|
||||
class PositionUpdate;
|
||||
|
||||
@@ -26,11 +30,118 @@ struct ChatModerationRequest {
|
||||
std::string message;
|
||||
};
|
||||
|
||||
|
||||
class User;
|
||||
struct SystemAddress;
|
||||
enum class eCharacterCreationResponse : uint8_t;
|
||||
enum class eRenameResponse : uint8_t;
|
||||
|
||||
namespace ClientPackets {
|
||||
ChatMessage HandleChatMessage(Packet* packet);
|
||||
PositionUpdate HandleClientPositionUpdate(Packet* packet);
|
||||
ChatModerationRequest HandleChatModerationRequest(Packet* packet);
|
||||
int32_t SendTop5HelpIssues(Packet* packet);
|
||||
|
||||
struct LoadStaticZone : public LUBitStream {
|
||||
LWOZONEID zoneID;
|
||||
uint32_t checksum = 0;
|
||||
bool editorEnabled = false;
|
||||
uint8_t editorLevel = 0;
|
||||
NiPoint3 position = NiPoint3Constant::ZERO;
|
||||
uint32_t instanceType = 0;
|
||||
|
||||
LoadStaticZone() : LUBitStream(eConnectionType::CLIENT, MessageType::Client::LOAD_STATIC_ZONE) {};
|
||||
void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
|
||||
};
|
||||
|
||||
struct CharacterCreationResponse : public LUBitStream {
|
||||
eCharacterCreationResponse response;
|
||||
|
||||
CharacterCreationResponse() : LUBitStream(eConnectionType::CLIENT, MessageType::Client::CHARACTER_CREATE_RESPONSE) {};
|
||||
void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
};
|
||||
|
||||
struct CharacterRenameResponse : public LUBitStream {
|
||||
eRenameResponse response;
|
||||
|
||||
CharacterRenameResponse() : LUBitStream(eConnectionType::CLIENT, MessageType::Client::CHARACTER_RENAME_RESPONSE) {};
|
||||
void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
};
|
||||
|
||||
struct CharacterDeleteResponse : public LUBitStream {
|
||||
bool success;
|
||||
|
||||
CharacterDeleteResponse() : LUBitStream(eConnectionType::CLIENT, MessageType::Client::DELETE_CHARACTER_RESPONSE) {};
|
||||
void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
};
|
||||
|
||||
struct TransferToWorld : public LUBitStream {
|
||||
std::string serverIP;
|
||||
uint32_t serverPort = 0;
|
||||
bool mythranShift = false;
|
||||
|
||||
TransferToWorld() : LUBitStream(eConnectionType::CLIENT, MessageType::Client::TRANSFER_TO_WORLD) {};
|
||||
void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
};
|
||||
|
||||
struct ServerState : public LUBitStream {
|
||||
bool serverReady = false;
|
||||
|
||||
ServerState() : LUBitStream(eConnectionType::CLIENT, MessageType::Client::SERVER_STATES) {};
|
||||
void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
};
|
||||
|
||||
struct CreateCharacter : public LUBitStream {
|
||||
LWOOBJID objid = 0;
|
||||
LOT templateID = 1;
|
||||
std::u16string name;
|
||||
eGameMasterLevel gmLevel = eGameMasterLevel::CIVILIAN;
|
||||
int32_t chatMode = 0;
|
||||
std::string xmlData;
|
||||
int64_t reputation = 0;
|
||||
|
||||
CreateCharacter() : LUBitStream(eConnectionType::CLIENT, MessageType::Client::CREATE_CHARACTER) {};
|
||||
void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
};
|
||||
|
||||
struct ChatModerationString : public LUBitStream {
|
||||
eChatChannel chatChannel = eChatChannel::SYSTEMNOTIFY;
|
||||
uint8_t chatMode = 0;
|
||||
std::string receiver;
|
||||
std::set<std::pair<uint8_t, uint8_t>> rejectedWords;
|
||||
|
||||
ChatModerationString() : LUBitStream(eConnectionType::CLIENT, MessageType::Client::CHAT_MODERATION_STRING) {};
|
||||
void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
};
|
||||
|
||||
struct GMLevelChange : public LUBitStream {
|
||||
bool success = false;
|
||||
eGameMasterLevel highestLevel = eGameMasterLevel::CIVILIAN;
|
||||
eGameMasterLevel prevLevel = eGameMasterLevel::CIVILIAN;
|
||||
eGameMasterLevel newLevel = eGameMasterLevel::CIVILIAN;
|
||||
|
||||
GMLevelChange() : LUBitStream(eConnectionType::CLIENT, MessageType::Client::MAKE_GM_RESPONSE) {};
|
||||
void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
};
|
||||
|
||||
struct DebugOutput : public LUBitStream {
|
||||
std::string data;
|
||||
|
||||
DebugOutput() : LUBitStream(eConnectionType::CLIENT, MessageType::Client::DEBUG_OUTPUT) {};
|
||||
void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
};
|
||||
|
||||
struct HTTPMonitorInfoResponse : public LUBitStream {
|
||||
uint16_t port = 80;
|
||||
bool openWeb = false;
|
||||
bool supportsSum = false;
|
||||
bool supportsDetail = false;
|
||||
bool supportsWho = false;
|
||||
bool supportsObjects = false;
|
||||
|
||||
HTTPMonitorInfoResponse() : LUBitStream(eConnectionType::CLIENT, MessageType::Client::HTTP_MONITOR_INFO_RESPONSE) {};
|
||||
void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
};
|
||||
};
|
||||
|
||||
#endif // CLIENTPACKETS_H
|
||||
|
@@ -1,186 +1,42 @@
|
||||
#include "WorldPackets.h"
|
||||
#include "dCommonVars.h"
|
||||
#include "BitStream.h"
|
||||
#include "GeneralUtils.h"
|
||||
#include "Logger.h"
|
||||
#include "Game.h"
|
||||
#include "LDFFormat.h"
|
||||
#include "dServer.h"
|
||||
#include "ZCompression.h"
|
||||
#include "eConnectionType.h"
|
||||
#include "BitStreamUtils.h"
|
||||
#include "Amf3.h"
|
||||
#include "dConfig.h"
|
||||
#include "GameMessages.h"
|
||||
#include "Entity.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
void HTTPMonitorInfo::Serialize(RakNet::BitStream &bitStream) const {
|
||||
bitStream.Write(port);
|
||||
bitStream.Write<uint8_t>(openWeb);
|
||||
bitStream.Write<uint8_t>(supportsSum);
|
||||
bitStream.Write<uint8_t>(supportsDetail);
|
||||
bitStream.Write<uint8_t>(supportsWho);
|
||||
bitStream.Write<uint8_t>(supportsObjects);
|
||||
}
|
||||
|
||||
void WorldPackets::SendLoadStaticZone(const SystemAddress& sysAddr, float x, float y, float z, uint32_t checksum, LWOZONEID zone) {
|
||||
RakNet::BitStream bitStream;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, MessageType::Client::LOAD_STATIC_ZONE);
|
||||
|
||||
bitStream.Write<uint16_t>(zone.GetMapID());
|
||||
bitStream.Write<uint16_t>(zone.GetInstanceID());
|
||||
//bitStream.Write<uint32_t>(zone.GetCloneID());
|
||||
bitStream.Write(0);
|
||||
|
||||
bitStream.Write(checksum);
|
||||
bitStream.Write<uint16_t>(0); // ??
|
||||
|
||||
bitStream.Write(x);
|
||||
bitStream.Write(y);
|
||||
bitStream.Write(z);
|
||||
|
||||
bitStream.Write<uint32_t>(0); // Change this to eventually use 4 on activity worlds
|
||||
|
||||
SEND_PACKET;
|
||||
}
|
||||
|
||||
void WorldPackets::SendCharacterCreationResponse(const SystemAddress& sysAddr, eCharacterCreationResponse response) {
|
||||
RakNet::BitStream bitStream;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, MessageType::Client::CHARACTER_CREATE_RESPONSE);
|
||||
bitStream.Write(response);
|
||||
SEND_PACKET;
|
||||
}
|
||||
|
||||
void WorldPackets::SendCharacterRenameResponse(const SystemAddress& sysAddr, eRenameResponse response) {
|
||||
RakNet::BitStream bitStream;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, MessageType::Client::CHARACTER_RENAME_RESPONSE);
|
||||
bitStream.Write(response);
|
||||
SEND_PACKET;
|
||||
}
|
||||
|
||||
void WorldPackets::SendCharacterDeleteResponse(const SystemAddress& sysAddr, bool response) {
|
||||
RakNet::BitStream bitStream;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, MessageType::Client::DELETE_CHARACTER_RESPONSE);
|
||||
bitStream.Write<uint8_t>(response);
|
||||
SEND_PACKET;
|
||||
}
|
||||
|
||||
void WorldPackets::SendTransferToWorld(const SystemAddress& sysAddr, const std::string& serverIP, uint32_t serverPort, bool mythranShift) {
|
||||
RakNet::BitStream bitStream;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, MessageType::Client::TRANSFER_TO_WORLD);
|
||||
|
||||
bitStream.Write(LUString(serverIP));
|
||||
bitStream.Write<uint16_t>(serverPort);
|
||||
bitStream.Write<uint8_t>(mythranShift);
|
||||
|
||||
SEND_PACKET;
|
||||
}
|
||||
|
||||
void WorldPackets::SendServerState(const SystemAddress& sysAddr) {
|
||||
RakNet::BitStream bitStream;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, MessageType::Client::SERVER_STATES);
|
||||
bitStream.Write<uint8_t>(1); //If the server is receiving this request, it probably is ready anyway.
|
||||
SEND_PACKET;
|
||||
}
|
||||
|
||||
void WorldPackets::SendCreateCharacter(const SystemAddress& sysAddr, int64_t reputation, LWOOBJID player, const std::string& xmlData, const std::u16string& username, eGameMasterLevel gm) {
|
||||
RakNet::BitStream bitStream;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, MessageType::Client::CREATE_CHARACTER);
|
||||
|
||||
RakNet::BitStream data;
|
||||
data.Write<uint32_t>(7); //LDF key count
|
||||
|
||||
std::unique_ptr<LDFData<LWOOBJID>> objid(new LDFData<LWOOBJID>(u"objid", player));
|
||||
std::unique_ptr<LDFData<LOT>> lot(new LDFData<LOT>(u"template", 1));
|
||||
std::unique_ptr<LDFData<std::string>> xmlConfigData(new LDFData<std::string>(u"xmlData", xmlData));
|
||||
std::unique_ptr<LDFData<std::u16string>> name(new LDFData<std::u16string>(u"name", username));
|
||||
std::unique_ptr<LDFData<int32_t>> gmlevel(new LDFData<int32_t>(u"gmlevel", static_cast<int32_t>(gm)));
|
||||
std::unique_ptr<LDFData<int32_t>> chatmode(new LDFData<int32_t>(u"chatmode", static_cast<int32_t>(gm)));
|
||||
std::unique_ptr<LDFData<int64_t>> reputationLdf(new LDFData<int64_t>(u"reputation", reputation));
|
||||
|
||||
objid->WriteToPacket(data);
|
||||
lot->WriteToPacket(data);
|
||||
name->WriteToPacket(data);
|
||||
gmlevel->WriteToPacket(data);
|
||||
chatmode->WriteToPacket(data);
|
||||
xmlConfigData->WriteToPacket(data);
|
||||
reputationLdf->WriteToPacket(data);
|
||||
|
||||
//Compress the data before sending:
|
||||
const uint32_t reservedSize = ZCompression::GetMaxCompressedLength(data.GetNumberOfBytesUsed());
|
||||
uint8_t* compressedData = new uint8_t[reservedSize];
|
||||
|
||||
// TODO There should be better handling here for not enough memory...
|
||||
if (!compressedData) return;
|
||||
|
||||
size_t size = ZCompression::Compress(data.GetData(), data.GetNumberOfBytesUsed(), compressedData, reservedSize);
|
||||
|
||||
assert(size <= reservedSize);
|
||||
|
||||
bitStream.Write<uint32_t>(size + 9); //size of data + header bytes (8)
|
||||
bitStream.Write<uint8_t>(1); //compressed boolean, true
|
||||
bitStream.Write<uint32_t>(data.GetNumberOfBytesUsed());
|
||||
bitStream.Write<uint32_t>(size);
|
||||
|
||||
/**
|
||||
* In practice, this warning serves no purpose for us. We allocate the max memory needed on the heap
|
||||
* and then compress the data. In the off chance that the compression actually increases the size,
|
||||
* an assertion is done to prevent bad data from being saved or sent.
|
||||
*/
|
||||
#pragma warning(disable:6385) // C6385 Reading invalid data from 'compressedData'.
|
||||
bitStream.WriteAlignedBytes(compressedData, size);
|
||||
#pragma warning(default:6385)
|
||||
|
||||
SEND_PACKET;
|
||||
delete[] compressedData;
|
||||
LOG("Sent CreateCharacter for ID: %llu", player);
|
||||
}
|
||||
|
||||
void WorldPackets::SendChatModerationResponse(const SystemAddress& sysAddr, bool requestAccepted, uint32_t requestID, const std::string& receiver, std::set<std::pair<uint8_t, uint8_t>> unacceptedItems) {
|
||||
CBITSTREAM;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, MessageType::Client::CHAT_MODERATION_STRING);
|
||||
|
||||
bitStream.Write<uint8_t>(unacceptedItems.empty()); // Is sentence ok?
|
||||
bitStream.Write<uint16_t>(0x16); // Source ID, unknown
|
||||
|
||||
bitStream.Write<uint8_t>(requestID); // request ID
|
||||
bitStream.Write<char>(0); // chat mode
|
||||
|
||||
bitStream.Write(LUWString(receiver, 42)); // receiver name
|
||||
|
||||
for (auto it : unacceptedItems) {
|
||||
bitStream.Write<uint8_t>(it.first); // start index
|
||||
bitStream.Write<uint8_t>(it.second); // length
|
||||
namespace WorldPackets {
|
||||
|
||||
bool UIHelpTop5::Deserialize(RakNet::BitStream& bitStream) {
|
||||
VALIDATE_READ(bitStream.Read(languageCode));
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int i = unacceptedItems.size(); 64 > i; i++) {
|
||||
bitStream.Write<uint16_t>(0);
|
||||
void UIHelpTop5::Handle() {
|
||||
AMFArrayValue data;
|
||||
switch (languageCode) {
|
||||
case eLanguageCodeID::EN_US:
|
||||
// Summaries
|
||||
data.Insert("Summary0", Game::config->GetValue("help_0_summary"));
|
||||
data.Insert("Summary1", Game::config->GetValue("help_1_summary"));
|
||||
data.Insert("Summary2", Game::config->GetValue("help_2_summary"));
|
||||
data.Insert("Summary3", Game::config->GetValue("help_3_summary"));
|
||||
data.Insert("Summary4", Game::config->GetValue("help_4_summary"));
|
||||
|
||||
// Descriptions
|
||||
data.Insert("Description0", Game::config->GetValue("help_0_description"));
|
||||
data.Insert("Description1", Game::config->GetValue("help_1_description"));
|
||||
data.Insert("Description2", Game::config->GetValue("help_2_description"));
|
||||
data.Insert("Description3", Game::config->GetValue("help_3_description"));
|
||||
data.Insert("Description4", Game::config->GetValue("help_4_description"));
|
||||
break;
|
||||
case eLanguageCodeID::PL_US:
|
||||
case eLanguageCodeID::DE_DE:
|
||||
case eLanguageCodeID::EN_GB:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
GameMessages::SendUIMessageServerToSingleClient(player, sysAddr, "UIHelpTop5", data);
|
||||
}
|
||||
|
||||
|
||||
SEND_PACKET;
|
||||
}
|
||||
|
||||
void WorldPackets::SendGMLevelChange(const SystemAddress& sysAddr, bool success, eGameMasterLevel highestLevel, eGameMasterLevel prevLevel, eGameMasterLevel newLevel) {
|
||||
CBITSTREAM;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, MessageType::Client::MAKE_GM_RESPONSE);
|
||||
|
||||
bitStream.Write<uint8_t>(success);
|
||||
bitStream.Write(static_cast<uint16_t>(highestLevel));
|
||||
bitStream.Write(static_cast<uint16_t>(prevLevel));
|
||||
bitStream.Write(static_cast<uint16_t>(newLevel));
|
||||
|
||||
SEND_PACKET;
|
||||
}
|
||||
|
||||
void WorldPackets::SendHTTPMonitorInfo(const SystemAddress& sysAddr, const HTTPMonitorInfo& info) {
|
||||
CBITSTREAM;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, MessageType::Client::HTTP_MONITOR_INFO_RESPONSE);
|
||||
info.Serialize(bitStream);
|
||||
SEND_PACKET;
|
||||
}
|
||||
|
||||
void WorldPackets::SendDebugOuput(const SystemAddress& sysAddr, const std::string& data){
|
||||
CBITSTREAM;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, MessageType::Client::DEBUG_OUTPUT);
|
||||
bitStream.Write<uint32_t>(data.size());
|
||||
bitStream.Write(data);
|
||||
SEND_PACKET;
|
||||
}
|
||||
|
@@ -2,40 +2,30 @@
|
||||
#define WORLDPACKETS_H
|
||||
|
||||
#include "dCommonVars.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "BitStreamUtils.h"
|
||||
#include "MessageType/World.h"
|
||||
|
||||
class User;
|
||||
struct SystemAddress;
|
||||
enum class eGameMasterLevel : uint8_t;
|
||||
enum class eCharacterCreationResponse : uint8_t;
|
||||
enum class eRenameResponse : uint8_t;
|
||||
namespace RakNet {
|
||||
class BitStream;
|
||||
};
|
||||
|
||||
struct HTTPMonitorInfo {
|
||||
uint16_t port = 80;
|
||||
bool openWeb = false;
|
||||
bool supportsSum = false;
|
||||
bool supportsDetail = false;
|
||||
bool supportsWho = false;
|
||||
bool supportsObjects = false;
|
||||
void Serialize(RakNet::BitStream &bitstream) const;
|
||||
class Entity;
|
||||
enum class eLanguageCodeID : int32_t {
|
||||
EN_US = 0,
|
||||
PL_US = 1,
|
||||
DE_DE = 2,
|
||||
EN_GB = 3
|
||||
};
|
||||
|
||||
namespace WorldPackets {
|
||||
void SendLoadStaticZone(const SystemAddress& sysAddr, float x, float y, float z, uint32_t checksum, LWOZONEID zone);
|
||||
void SendCharacterCreationResponse(const SystemAddress& sysAddr, eCharacterCreationResponse response);
|
||||
void SendCharacterRenameResponse(const SystemAddress& sysAddr, eRenameResponse response);
|
||||
void SendCharacterDeleteResponse(const SystemAddress& sysAddr, bool response);
|
||||
void SendTransferToWorld(const SystemAddress& sysAddr, const std::string& serverIP, uint32_t serverPort, bool mythranShift);
|
||||
void SendServerState(const SystemAddress& sysAddr);
|
||||
void SendCreateCharacter(const SystemAddress& sysAddr, int64_t reputation, LWOOBJID player, const std::string& xmlData, const std::u16string& username, eGameMasterLevel gm);
|
||||
void SendChatModerationResponse(const SystemAddress& sysAddr, bool requestAccepted, uint32_t requestID, const std::string& receiver, std::set<std::pair<uint8_t, uint8_t>> unacceptedItems);
|
||||
void SendGMLevelChange(const SystemAddress& sysAddr, bool success, eGameMasterLevel highestLevel, eGameMasterLevel prevLevel, eGameMasterLevel newLevel);
|
||||
void SendHTTPMonitorInfo(const SystemAddress& sysAddr, const HTTPMonitorInfo& info);
|
||||
void SendDebugOuput(const SystemAddress& sysAddr, const std::string& data);
|
||||
|
||||
struct UIHelpTop5: public LUBitStream {
|
||||
eLanguageCodeID languageCode = eLanguageCodeID::EN_US;
|
||||
|
||||
// should these be shoved up to the base class?
|
||||
SystemAddress sysAddr = UNASSIGNED_SYSTEM_ADDRESS;
|
||||
Entity* player = nullptr;
|
||||
|
||||
UIHelpTop5() : LUBitStream(eConnectionType::WORLD, MessageType::World::UI_HELP_TOP_5) {};
|
||||
bool Deserialize(RakNet::BitStream& bitStream) override;
|
||||
void Handle() override;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // WORLDPACKETS_H
|
||||
|
Reference in New Issue
Block a user