Compare commits

..

35 Commits

Author SHA1 Message Date
David Markowitz
90ac91e0df Use consistent calling
try to always have the first parameter match how you got the script for readability
2024-03-06 03:23:37 -08:00
David Markowitz
946b59f02f fix incorrect script grab for trigger 2024-03-06 03:19:49 -08:00
David Markowitz
e76996f98f Update CMakeLists.txt 2024-03-06 02:12:27 -08:00
David Markowitz
109f556ef7 Merge branch 'main' into remove-multiple-script-syntax-ffffffffff 2024-03-06 02:11:27 -08:00
David Markowitz
e1d176260a Merge branch 'main' into remove-multiple-script-syntax-ffffffffff 2024-03-04 03:12:57 -08:00
David Markowitz
c09f46aadc Update CppScripts.h 2024-03-04 03:12:52 -08:00
David Markowitz
3fa5d4791d Merge branch 'specify-path' into remove-multiple-script-syntax-ffffffffff 2024-03-03 04:42:32 -08:00
David Markowitz
261eb2295d Merge branch 'fix/cmake-libs-2' into remove-multiple-script-syntax-ffffffffff 2024-03-03 04:36:52 -08:00
David Markowitz
da15c6d16b Remove code changes
Will fix in another PR.
2024-03-03 04:32:31 -08:00
David Markowitz
5807dccda7 fix include paths 2024-03-03 04:30:03 -08:00
David Markowitz
247b88dbd5 fix include paths 2024-03-03 04:29:09 -08:00
David Markowitz
9ac922bbaa remove syntax of multiple scripts 2024-03-03 04:18:22 -08:00
David Markowitz
2eadfa2efb Merge branch 'main' into fix/cmake-libs-2 2024-03-03 04:17:27 -08:00
David Markowitz
8907cd467d fix not building on unix 2024-01-25 02:45:47 -08:00
David Markowitz
702dcbb8d2 Merge branch 'main' into fix/cmake-libs-2 2024-01-25 02:43:29 -08:00
Xiphoseer
6b94e7f9ed try: install_name_tool 2024-01-05 23:29:40 +01:00
Xiphoseer
decce5b4c5 fix: macos? 2024-01-05 22:54:07 +01:00
Xiphoseer
a52cfb5b0b fix: macos? 2024-01-05 22:32:27 +01:00
Xiphoseer
4569ea29d5 fix: macos? 2024-01-05 22:18:39 +01:00
Xiphoseer
dab70ac096 fix: macos? 2024-01-05 21:45:50 +01:00
Xiphoseer
94c56e527a fix: macos? 2024-01-05 21:17:44 +01:00
Xiphoseer
7c1c4d7581 fix: Dockerfile 2024-01-05 21:01:13 +01:00
Xiphoseer
cb84dbcc22 fix: macos? 2024-01-05 20:59:52 +01:00
Xiphoseer
6fb88e79a0 fix: dPropertyBehaviors 2024-01-05 20:28:18 +01:00
Xiphoseer
cb065a07af feat: Move scripts to CMAKE_MODULE_PATH 2024-01-05 20:14:07 +01:00
Xiphoseer
17305831a1 fix: mariadb C/C++ on apple 2024-01-05 20:14:07 +01:00
Xiphoseer
259067c64a fix: update dockerfile 2024-01-05 20:14:07 +01:00
Xiphoseer
a166e3ef3f wip: try simplified connector build 2024-01-05 20:14:07 +01:00
Xiphoseer
2ad3cb79d3 fix: bcrypt 2024-01-05 20:14:07 +01:00
Xiphoseer
d6d5cb7515 fix: rebase 2024-01-05 20:14:07 +01:00
Xiphoseer
d67ac7759b fix: object libs 2024-01-05 20:14:07 +01:00
Xiphoseer
4586a0ffea fix: dCommon 2024-01-05 20:14:07 +01:00
Xiphoseer
7509237e69 fix: dDatabase 2024-01-05 20:14:07 +01:00
Xiphoseer
0f1e226960 fix: remove dZoneManager from global include 2024-01-05 20:14:07 +01:00
Xiphoseer
bfe39a919e fix: more include changes 2024-01-05 20:14:07 +01:00
373 changed files with 5495 additions and 8501 deletions

View File

@@ -1,18 +1,9 @@
cmake_minimum_required(VERSION 3.25) cmake_minimum_required(VERSION 3.18)
project(Darkflame) project(Darkflame)
# check if the path to the source directory contains a space
if("${CMAKE_SOURCE_DIR}" MATCHES " ")
message(FATAL_ERROR "The server cannot build in the path (" ${CMAKE_SOURCE_DIR} ") because it contains a space. Please move the server to a path without spaces.")
endif()
include(CTest) include(CTest)
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
set(CXX_STANDARD_REQUIRED ON) set(CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Export the compile commands for debugging
set(CMAKE_POLICY_DEFAULT_CMP0063 NEW) # Set CMAKE visibility policy to NEW on project and subprojects
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) # Set C and C++ symbol visibility to hide inlined functions
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
# Read variables from file # Read variables from file
@@ -79,8 +70,7 @@ if(UNIX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -O2 -fPIC") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -O2 -fPIC")
elseif(MSVC) elseif(MSVC)
# Skip warning for invalid conversion from size_t to uint32_t for all targets below for now # Skip warning for invalid conversion from size_t to uint32_t for all targets below for now
# Also disable non-portable MSVC volatile behavior add_compile_options("/wd4267" "/utf-8")
add_compile_options("/wd4267" "/utf-8" "/volatile:iso")
elseif(WIN32) elseif(WIN32)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS) add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
endif() endif()
@@ -110,7 +100,7 @@ make_directory(${CMAKE_BINARY_DIR}/resServer)
make_directory(${CMAKE_BINARY_DIR}/logs) make_directory(${CMAKE_BINARY_DIR}/logs)
# Copy resource files on first build # Copy resource files on first build
set(RESOURCE_FILES "sharedconfig.ini" "authconfig.ini" "chatconfig.ini" "worldconfig.ini" "masterconfig.ini" "blocklist.dcf") set(RESOURCE_FILES "sharedconfig.ini" "authconfig.ini" "chatconfig.ini" "worldconfig.ini" "masterconfig.ini" "blacklist.dcf")
message(STATUS "Checking resource file integrity") message(STATUS "Checking resource file integrity")
include(Utils) include(Utils)
@@ -221,29 +211,29 @@ if (APPLE)
endif() endif()
# Load all of our third party directories # Load all of our third party directories
add_subdirectory(thirdparty SYSTEM) add_subdirectory(thirdparty)
# Create our list of include directories # Create our list of include directories
include_directories( set(INCLUDED_DIRECTORIES
"dPhysics" "dPhysics"
"dNavigation" "dNavigation"
"dNet" "dNet"
"thirdparty/magic_enum/include/magic_enum"
"thirdparty/raknet/Source"
"thirdparty/tinyxml2"
"thirdparty/recastnavigation"
"thirdparty/SQLite"
"thirdparty/cpplinq"
"thirdparty/cpp-httplib"
"thirdparty/MD5"
"tests" "tests"
"tests/dCommonTests" "tests/dCommonTests"
"tests/dGameTests" "tests/dGameTests"
"tests/dGameTests/dComponentsTests" "tests/dGameTests/dComponentsTests"
SYSTEM "thirdparty/magic_enum/include/magic_enum"
SYSTEM "thirdparty/raknet/Source"
SYSTEM "thirdparty/tinyxml2"
SYSTEM "thirdparty/recastnavigation"
SYSTEM "thirdparty/SQLite"
SYSTEM "thirdparty/cpplinq"
SYSTEM "thirdparty/cpp-httplib"
SYSTEM "thirdparty/MD5"
) )
# Add system specfic includes for Apple, Windows and Other Unix OS' (including Linux) # Add system specfic includes for Apple, Windows and Other Unix OS' (including Linux)
@@ -252,9 +242,14 @@ if(APPLE)
include_directories("/usr/local/include/") include_directories("/usr/local/include/")
endif() endif()
# Actually include the directories from our list
foreach(dir ${INCLUDED_DIRECTORIES})
include_directories(${PROJECT_SOURCE_DIR}/${dir})
endforeach()
# Add linking directories: # Add linking directories:
if (UNIX) if (UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wold-style-cast -Werror") # Warning flags set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
endif() endif()
file( file(
GLOB HEADERS_DZONEMANAGER GLOB HEADERS_DZONEMANAGER

View File

@@ -1,6 +1,6 @@
PROJECT_VERSION_MAJOR=2 PROJECT_VERSION_MAJOR=1
PROJECT_VERSION_MINOR=3 PROJECT_VERSION_MINOR=1
PROJECT_VERSION_PATCH=0 PROJECT_VERSION_PATCH=1
# Debugging # Debugging
# Set DYNAMIC to 1 to enable the -rdynamic flag for the linker, yielding some symbols in crashlogs. # Set DYNAMIC to 1 to enable the -rdynamic flag for the linker, yielding some symbols in crashlogs.

View File

@@ -31,7 +31,7 @@ COPY --from=build /app/build/*Server /app/
# Necessary suplimentary files # Necessary suplimentary files
COPY --from=build /app/build/*.ini /app/configs/ COPY --from=build /app/build/*.ini /app/configs/
COPY --from=build /app/build/vanity/*.* /app/vanity/ COPY --from=build /app/build/vanity/*.* /app/vanity/*
COPY --from=build /app/build/navmeshes /app/navmeshes COPY --from=build /app/build/navmeshes /app/navmeshes
COPY --from=build /app/build/migrations /app/migrations COPY --from=build /app/build/migrations /app/migrations
COPY --from=build /app/build/*.dcf /app/ COPY --from=build /app/build/*.dcf /app/
@@ -39,7 +39,7 @@ COPY --from=build /app/build/*.dcf /app/
# backup of config and vanity files to copy to the host incase # backup of config and vanity files to copy to the host incase
# of a mount clobbering the copy from above # of a mount clobbering the copy from above
COPY --from=build /app/build/*.ini /app/default-configs/ COPY --from=build /app/build/*.ini /app/default-configs/
COPY --from=build /app/build/vanity/*.* /app/default-vanity/ COPY --from=build /app/build/vanity/*.* /app/default-vanity/*
# needed as the container runs with the root user # needed as the container runs with the root user
# and therefore sudo doesn't exist # and therefore sudo doesn't exist

View File

@@ -51,7 +51,7 @@ git clone --recursive https://github.com/DarkflameUniverse/DarkflameServer
### Windows packages ### Windows packages
Ensure that you have either the [MSVC C++ compiler](https://visualstudio.microsoft.com/vs/features/cplusplus/) (recommended) or the [Clang compiler](https://github.com/llvm/llvm-project/releases/) installed. Ensure that you have either the [MSVC C++ compiler](https://visualstudio.microsoft.com/vs/features/cplusplus/) (recommended) or the [Clang compiler](https://github.com/llvm/llvm-project/releases/) installed.
You'll also need to download and install [CMake](https://cmake.org/download/) (version <font size="4">**CMake version 3.25**</font> or later!). You'll also need to download and install [CMake](https://cmake.org/download/) (version <font size="4">**CMake version 3.18**</font> or later!).
### MacOS packages ### MacOS packages
Ensure you have [brew](https://brew.sh) installed. Ensure you have [brew](https://brew.sh) installed.
@@ -73,7 +73,7 @@ sudo apt install build-essential gcc zlib1g-dev libssl-dev openssl mariadb-serve
``` ```
#### Required CMake version #### Required CMake version
This project uses <font size="4">**CMake version 3.25**</font> or higher and as such you will need to ensure you have this version installed. This project uses <font size="4">**CMake version 3.18**</font> or higher and as such you will need to ensure you have this version installed.
You can check your CMake version by using the following command in a terminal. You can check your CMake version by using the following command in a terminal.
```bash ```bash
cmake --version cmake --version

View File

@@ -141,6 +141,6 @@ elseif(APPLE)
endif() endif()
# Add directories to include lists # Add directories to include lists
target_include_directories(MariaDB::ConnCpp SYSTEM INTERFACE ${MARIADB_INCLUDE_DIR}) target_include_directories(MariaDB::ConnCpp INTERFACE ${MARIADB_INCLUDE_DIR})
set(MariaDB_FOUND TRUE) set(MariaDB_FOUND TRUE)

View File

@@ -27,8 +27,8 @@ dChatFilter::dChatFilter(const std::string& filepath, bool dontGenerateDCF) {
ExportWordlistToDCF(filepath + ".dcf", true); ExportWordlistToDCF(filepath + ".dcf", true);
} }
if (BinaryIO::DoesFileExist("blocklist.dcf")) { if (BinaryIO::DoesFileExist("blacklist.dcf")) {
ReadWordlistDCF("blocklist.dcf", false); ReadWordlistDCF("blacklist.dcf", false);
} }
//Read player names that are ok as well: //Read player names that are ok as well:
@@ -44,20 +44,20 @@ dChatFilter::~dChatFilter() {
m_DeniedWords.clear(); m_DeniedWords.clear();
} }
void dChatFilter::ReadWordlistPlaintext(const std::string& filepath, bool allowList) { void dChatFilter::ReadWordlistPlaintext(const std::string& filepath, bool whiteList) {
std::ifstream file(filepath); std::ifstream file(filepath);
if (file) { if (file) {
std::string line; std::string line;
while (std::getline(file, line)) { while (std::getline(file, line)) {
line.erase(std::remove(line.begin(), line.end(), '\r'), line.end()); line.erase(std::remove(line.begin(), line.end(), '\r'), line.end());
std::transform(line.begin(), line.end(), line.begin(), ::tolower); //Transform to lowercase std::transform(line.begin(), line.end(), line.begin(), ::tolower); //Transform to lowercase
if (allowList) m_ApprovedWords.push_back(CalculateHash(line)); if (whiteList) m_ApprovedWords.push_back(CalculateHash(line));
else m_DeniedWords.push_back(CalculateHash(line)); else m_DeniedWords.push_back(CalculateHash(line));
} }
} }
} }
bool dChatFilter::ReadWordlistDCF(const std::string& filepath, bool allowList) { bool dChatFilter::ReadWordlistDCF(const std::string& filepath, bool whiteList) {
std::ifstream file(filepath, std::ios::binary); std::ifstream file(filepath, std::ios::binary);
if (file) { if (file) {
fileHeader hdr; fileHeader hdr;
@@ -70,13 +70,13 @@ bool dChatFilter::ReadWordlistDCF(const std::string& filepath, bool allowList) {
if (hdr.formatVersion == formatVersion) { if (hdr.formatVersion == formatVersion) {
size_t wordsToRead = 0; size_t wordsToRead = 0;
BinaryIO::BinaryRead(file, wordsToRead); BinaryIO::BinaryRead(file, wordsToRead);
if (allowList) m_ApprovedWords.reserve(wordsToRead); if (whiteList) m_ApprovedWords.reserve(wordsToRead);
else m_DeniedWords.reserve(wordsToRead); else m_DeniedWords.reserve(wordsToRead);
size_t word = 0; size_t word = 0;
for (size_t i = 0; i < wordsToRead; ++i) { for (size_t i = 0; i < wordsToRead; ++i) {
BinaryIO::BinaryRead(file, word); BinaryIO::BinaryRead(file, word);
if (allowList) m_ApprovedWords.push_back(word); if (whiteList) m_ApprovedWords.push_back(word);
else m_DeniedWords.push_back(word); else m_DeniedWords.push_back(word);
} }
@@ -90,14 +90,14 @@ bool dChatFilter::ReadWordlistDCF(const std::string& filepath, bool allowList) {
return false; return false;
} }
void dChatFilter::ExportWordlistToDCF(const std::string& filepath, bool allowList) { void dChatFilter::ExportWordlistToDCF(const std::string& filepath, bool whiteList) {
std::ofstream file(filepath, std::ios::binary | std::ios_base::out); std::ofstream file(filepath, std::ios::binary | std::ios_base::out);
if (file) { if (file) {
BinaryIO::BinaryWrite(file, uint32_t(dChatFilterDCF::header)); BinaryIO::BinaryWrite(file, uint32_t(dChatFilterDCF::header));
BinaryIO::BinaryWrite(file, uint32_t(dChatFilterDCF::formatVersion)); BinaryIO::BinaryWrite(file, uint32_t(dChatFilterDCF::formatVersion));
BinaryIO::BinaryWrite(file, size_t(allowList ? m_ApprovedWords.size() : m_DeniedWords.size())); BinaryIO::BinaryWrite(file, size_t(whiteList ? m_ApprovedWords.size() : m_DeniedWords.size()));
for (size_t word : allowList ? m_ApprovedWords : m_DeniedWords) { for (size_t word : whiteList ? m_ApprovedWords : m_DeniedWords) {
BinaryIO::BinaryWrite(file, word); BinaryIO::BinaryWrite(file, word);
} }
@@ -105,10 +105,10 @@ void dChatFilter::ExportWordlistToDCF(const std::string& filepath, bool allowLis
} }
} }
std::vector<std::pair<uint8_t, uint8_t>> dChatFilter::IsSentenceOkay(const std::string& message, eGameMasterLevel gmLevel, bool allowList) { std::vector<std::pair<uint8_t, uint8_t>> dChatFilter::IsSentenceOkay(const std::string& message, eGameMasterLevel gmLevel, bool whiteList) {
if (gmLevel > eGameMasterLevel::FORUM_MODERATOR) return { }; //If anything but a forum mod, return true. if (gmLevel > eGameMasterLevel::FORUM_MODERATOR) return { }; //If anything but a forum mod, return true.
if (message.empty()) return { }; if (message.empty()) return { };
if (!allowList && m_DeniedWords.empty()) return { { 0, message.length() } }; if (!whiteList && m_DeniedWords.empty()) return { { 0, message.length() } };
std::stringstream sMessage(message); std::stringstream sMessage(message);
std::string segment; std::string segment;
@@ -126,16 +126,16 @@ std::vector<std::pair<uint8_t, uint8_t>> dChatFilter::IsSentenceOkay(const std::
size_t hash = CalculateHash(segment); size_t hash = CalculateHash(segment);
if (std::find(m_UserUnapprovedWordCache.begin(), m_UserUnapprovedWordCache.end(), hash) != m_UserUnapprovedWordCache.end() && allowList) { if (std::find(m_UserUnapprovedWordCache.begin(), m_UserUnapprovedWordCache.end(), hash) != m_UserUnapprovedWordCache.end() && whiteList) {
listOfBadSegments.emplace_back(position, originalSegment.length()); listOfBadSegments.emplace_back(position, originalSegment.length());
} }
if (std::find(m_ApprovedWords.begin(), m_ApprovedWords.end(), hash) == m_ApprovedWords.end() && allowList) { if (std::find(m_ApprovedWords.begin(), m_ApprovedWords.end(), hash) == m_ApprovedWords.end() && whiteList) {
m_UserUnapprovedWordCache.push_back(hash); m_UserUnapprovedWordCache.push_back(hash);
listOfBadSegments.emplace_back(position, originalSegment.length()); listOfBadSegments.emplace_back(position, originalSegment.length());
} }
if (std::find(m_DeniedWords.begin(), m_DeniedWords.end(), hash) != m_DeniedWords.end() && !allowList) { if (std::find(m_DeniedWords.begin(), m_DeniedWords.end(), hash) != m_DeniedWords.end() && !whiteList) {
m_UserUnapprovedWordCache.push_back(hash); m_UserUnapprovedWordCache.push_back(hash);
listOfBadSegments.emplace_back(position, originalSegment.length()); listOfBadSegments.emplace_back(position, originalSegment.length());
} }

View File

@@ -21,10 +21,10 @@ public:
dChatFilter(const std::string& filepath, bool dontGenerateDCF); dChatFilter(const std::string& filepath, bool dontGenerateDCF);
~dChatFilter(); ~dChatFilter();
void ReadWordlistPlaintext(const std::string& filepath, bool allowList); void ReadWordlistPlaintext(const std::string& filepath, bool whiteList);
bool ReadWordlistDCF(const std::string& filepath, bool allowList); bool ReadWordlistDCF(const std::string& filepath, bool whiteList);
void ExportWordlistToDCF(const std::string& filepath, bool allowList); void ExportWordlistToDCF(const std::string& filepath, bool whiteList);
std::vector<std::pair<uint8_t, uint8_t>> IsSentenceOkay(const std::string& message, eGameMasterLevel gmLevel, bool allowList = true); std::vector<std::pair<uint8_t, uint8_t>> IsSentenceOkay(const std::string& message, eGameMasterLevel gmLevel, bool whiteList = true);
private: private:
bool m_DontGenerateDCF; bool m_DontGenerateDCF;

View File

@@ -1,6 +1,6 @@
#include "ChatIgnoreList.h" #include "ChatIgnoreList.h"
#include "PlayerContainer.h" #include "PlayerContainer.h"
#include "eChatMessageType.h" #include "eChatInternalMessageType.h"
#include "BitStreamUtils.h" #include "BitStreamUtils.h"
#include "Game.h" #include "Game.h"
#include "Logger.h" #include "Logger.h"
@@ -13,7 +13,7 @@
// The only thing not auto-handled is instance activities force joining the team on the server. // The only thing not auto-handled is instance activities force joining the team on the server.
void WriteOutgoingReplyHeader(RakNet::BitStream& bitStream, const LWOOBJID& receivingPlayer, const ChatIgnoreList::Response type) { void WriteOutgoingReplyHeader(RakNet::BitStream& bitStream, const LWOOBJID& receivingPlayer, const ChatIgnoreList::Response type) {
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::WORLD_ROUTE_PACKET); BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
bitStream.Write(receivingPlayer); bitStream.Write(receivingPlayer);
//portion that will get routed: //portion that will get routed:

View File

@@ -1,5 +1,5 @@
#ifndef CHATIGNORELIST_H #ifndef __CHATIGNORELIST__H__
#define CHATIGNORELIST_H #define __CHATIGNORELIST__H__
struct Packet; struct Packet;
@@ -24,4 +24,4 @@ namespace ChatIgnoreList {
}; };
}; };
#endif //!CHATIGNORELIST_H #endif //!__CHATIGNORELIST__H__

View File

@@ -14,11 +14,11 @@
#include "eObjectBits.h" #include "eObjectBits.h"
#include "eConnectionType.h" #include "eConnectionType.h"
#include "eChatMessageType.h" #include "eChatMessageType.h"
#include "eChatInternalMessageType.h"
#include "eClientMessageType.h" #include "eClientMessageType.h"
#include "eGameMessageType.h" #include "eGameMessageType.h"
#include "StringifiedEnum.h" #include "StringifiedEnum.h"
#include "eGameMasterLevel.h" #include "eGameMasterLevel.h"
#include "ChatPackets.h"
void ChatPacketHandler::HandleFriendlistRequest(Packet* packet) { void ChatPacketHandler::HandleFriendlistRequest(Packet* packet) {
//Get from the packet which player we want to do something with: //Get from the packet which player we want to do something with:
@@ -60,7 +60,7 @@ void ChatPacketHandler::HandleFriendlistRequest(Packet* packet) {
//Now, we need to send the friendlist to the server they came from: //Now, we need to send the friendlist to the server they came from:
CBITSTREAM; CBITSTREAM;
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::WORLD_ROUTE_PACKET); BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
bitStream.Write(playerID); bitStream.Write(playerID);
//portion that will get routed: //portion that will get routed:
@@ -355,67 +355,6 @@ void ChatPacketHandler::HandleGMLevelUpdate(Packet* packet) {
inStream.Read(player.gmLevel); inStream.Read(player.gmLevel);
} }
void ChatPacketHandler::HandleWho(Packet* packet) {
CINSTREAM_SKIP_HEADER;
FindPlayerRequest request;
request.Deserialize(inStream);
const auto& sender = Game::playerContainer.GetPlayerData(request.requestor);
if (!sender) return;
const auto& player = Game::playerContainer.GetPlayerData(request.playerName.GetAsString());
bool online = player;
CBITSTREAM;
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::WORLD_ROUTE_PACKET);
bitStream.Write(request.requestor);
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::WHO_RESPONSE);
bitStream.Write<uint8_t>(online);
bitStream.Write(player.zoneID.GetMapID());
bitStream.Write(player.zoneID.GetInstanceID());
bitStream.Write(player.zoneID.GetCloneID());
bitStream.Write(request.playerName);
SystemAddress sysAddr = sender.sysAddr;
SEND_PACKET;
}
void ChatPacketHandler::HandleShowAll(Packet* packet) {
CINSTREAM_SKIP_HEADER;
ShowAllRequest request;
request.Deserialize(inStream);
const auto& sender = Game::playerContainer.GetPlayerData(request.requestor);
if (!sender) return;
CBITSTREAM;
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::WORLD_ROUTE_PACKET);
bitStream.Write(request.requestor);
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::SHOW_ALL_RESPONSE);
bitStream.Write<uint8_t>(!request.displayZoneData && !request.displayIndividualPlayers);
bitStream.Write(Game::playerContainer.GetPlayerCount());
bitStream.Write(Game::playerContainer.GetSimCount());
bitStream.Write<uint8_t>(request.displayIndividualPlayers);
bitStream.Write<uint8_t>(request.displayZoneData);
if (request.displayZoneData || request.displayIndividualPlayers){
for (auto& [playerID, playerData ]: Game::playerContainer.GetAllPlayers()){
if (!playerData) continue;
bitStream.Write<uint8_t>(0); // structure packing
if (request.displayIndividualPlayers) bitStream.Write(LUWString(playerData.playerName));
if (request.displayZoneData) {
bitStream.Write(playerData.zoneID.GetMapID());
bitStream.Write(playerData.zoneID.GetInstanceID());
bitStream.Write(playerData.zoneID.GetCloneID());
}
}
}
SystemAddress sysAddr = sender.sysAddr;
SEND_PACKET;
}
// the structure the client uses to send this packet is shared in many chat messages // the structure the client uses to send this packet is shared in many chat messages
// that are sent to the server. Because of this, there are large gaps of unused data in chat messages // that are sent to the server. Because of this, there are large gaps of unused data in chat messages
void ChatPacketHandler::HandleChatMessage(Packet* packet) { void ChatPacketHandler::HandleChatMessage(Packet* packet) {
@@ -515,7 +454,7 @@ void ChatPacketHandler::HandlePrivateChatMessage(Packet* packet) {
void ChatPacketHandler::SendPrivateChatMessage(const PlayerData& sender, const PlayerData& receiver, const PlayerData& routeTo, const LUWString& message, const eChatChannel channel, const eChatMessageResponseCode responseCode) { void ChatPacketHandler::SendPrivateChatMessage(const PlayerData& sender, const PlayerData& receiver, const PlayerData& routeTo, const LUWString& message, const eChatChannel channel, const eChatMessageResponseCode responseCode) {
CBITSTREAM; CBITSTREAM;
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::WORLD_ROUTE_PACKET); BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
bitStream.Write(routeTo.playerID); bitStream.Write(routeTo.playerID);
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::PRIVATE_CHAT_MESSAGE); BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::PRIVATE_CHAT_MESSAGE);
@@ -757,7 +696,7 @@ void ChatPacketHandler::HandleTeamStatusRequest(Packet* packet) {
void ChatPacketHandler::SendTeamInvite(const PlayerData& receiver, const PlayerData& sender) { void ChatPacketHandler::SendTeamInvite(const PlayerData& receiver, const PlayerData& sender) {
CBITSTREAM; CBITSTREAM;
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::WORLD_ROUTE_PACKET); BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
bitStream.Write(receiver.playerID); bitStream.Write(receiver.playerID);
//portion that will get routed: //portion that will get routed:
@@ -772,7 +711,7 @@ void ChatPacketHandler::SendTeamInvite(const PlayerData& receiver, const PlayerD
void ChatPacketHandler::SendTeamInviteConfirm(const PlayerData& receiver, bool bLeaderIsFreeTrial, LWOOBJID i64LeaderID, LWOZONEID i64LeaderZoneID, uint8_t ucLootFlag, uint8_t ucNumOfOtherPlayers, uint8_t ucResponseCode, std::u16string wsLeaderName) { void ChatPacketHandler::SendTeamInviteConfirm(const PlayerData& receiver, bool bLeaderIsFreeTrial, LWOOBJID i64LeaderID, LWOZONEID i64LeaderZoneID, uint8_t ucLootFlag, uint8_t ucNumOfOtherPlayers, uint8_t ucResponseCode, std::u16string wsLeaderName) {
CBITSTREAM; CBITSTREAM;
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::WORLD_ROUTE_PACKET); BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
bitStream.Write(receiver.playerID); bitStream.Write(receiver.playerID);
//portion that will get routed: //portion that will get routed:
@@ -799,7 +738,7 @@ void ChatPacketHandler::SendTeamInviteConfirm(const PlayerData& receiver, bool b
void ChatPacketHandler::SendTeamStatus(const PlayerData& receiver, LWOOBJID i64LeaderID, LWOZONEID i64LeaderZoneID, uint8_t ucLootFlag, uint8_t ucNumOfOtherPlayers, std::u16string wsLeaderName) { void ChatPacketHandler::SendTeamStatus(const PlayerData& receiver, LWOOBJID i64LeaderID, LWOZONEID i64LeaderZoneID, uint8_t ucLootFlag, uint8_t ucNumOfOtherPlayers, std::u16string wsLeaderName) {
CBITSTREAM; CBITSTREAM;
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::WORLD_ROUTE_PACKET); BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
bitStream.Write(receiver.playerID); bitStream.Write(receiver.playerID);
//portion that will get routed: //portion that will get routed:
@@ -824,7 +763,7 @@ void ChatPacketHandler::SendTeamStatus(const PlayerData& receiver, LWOOBJID i64L
void ChatPacketHandler::SendTeamSetLeader(const PlayerData& receiver, LWOOBJID i64PlayerID) { void ChatPacketHandler::SendTeamSetLeader(const PlayerData& receiver, LWOOBJID i64PlayerID) {
CBITSTREAM; CBITSTREAM;
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::WORLD_ROUTE_PACKET); BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
bitStream.Write(receiver.playerID); bitStream.Write(receiver.playerID);
//portion that will get routed: //portion that will get routed:
@@ -841,7 +780,7 @@ void ChatPacketHandler::SendTeamSetLeader(const PlayerData& receiver, LWOOBJID i
void ChatPacketHandler::SendTeamAddPlayer(const PlayerData& receiver, bool bIsFreeTrial, bool bLocal, bool bNoLootOnDeath, LWOOBJID i64PlayerID, std::u16string wsPlayerName, LWOZONEID zoneID) { void ChatPacketHandler::SendTeamAddPlayer(const PlayerData& receiver, bool bIsFreeTrial, bool bLocal, bool bNoLootOnDeath, LWOOBJID i64PlayerID, std::u16string wsPlayerName, LWOZONEID zoneID) {
CBITSTREAM; CBITSTREAM;
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::WORLD_ROUTE_PACKET); BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
bitStream.Write(receiver.playerID); bitStream.Write(receiver.playerID);
//portion that will get routed: //portion that will get routed:
@@ -870,7 +809,7 @@ void ChatPacketHandler::SendTeamAddPlayer(const PlayerData& receiver, bool bIsFr
void ChatPacketHandler::SendTeamRemovePlayer(const PlayerData& receiver, bool bDisband, bool bIsKicked, bool bIsLeaving, bool bLocal, LWOOBJID i64LeaderID, LWOOBJID i64PlayerID, std::u16string wsPlayerName) { void ChatPacketHandler::SendTeamRemovePlayer(const PlayerData& receiver, bool bDisband, bool bIsKicked, bool bIsLeaving, bool bLocal, LWOOBJID i64LeaderID, LWOOBJID i64PlayerID, std::u16string wsPlayerName) {
CBITSTREAM; CBITSTREAM;
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::WORLD_ROUTE_PACKET); BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
bitStream.Write(receiver.playerID); bitStream.Write(receiver.playerID);
//portion that will get routed: //portion that will get routed:
@@ -896,7 +835,7 @@ void ChatPacketHandler::SendTeamRemovePlayer(const PlayerData& receiver, bool bD
void ChatPacketHandler::SendTeamSetOffWorldFlag(const PlayerData& receiver, LWOOBJID i64PlayerID, LWOZONEID zoneID) { void ChatPacketHandler::SendTeamSetOffWorldFlag(const PlayerData& receiver, LWOOBJID i64PlayerID, LWOZONEID zoneID) {
CBITSTREAM; CBITSTREAM;
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::WORLD_ROUTE_PACKET); BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
bitStream.Write(receiver.playerID); bitStream.Write(receiver.playerID);
//portion that will get routed: //portion that will get routed:
@@ -930,7 +869,7 @@ void ChatPacketHandler::SendFriendUpdate(const PlayerData& friendData, const Pla
[bool] - is FTP*/ [bool] - is FTP*/
CBITSTREAM; CBITSTREAM;
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::WORLD_ROUTE_PACKET); BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
bitStream.Write(friendData.playerID); bitStream.Write(friendData.playerID);
//portion that will get routed: //portion that will get routed:
@@ -967,7 +906,7 @@ void ChatPacketHandler::SendFriendRequest(const PlayerData& receiver, const Play
} }
CBITSTREAM; CBITSTREAM;
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::WORLD_ROUTE_PACKET); BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
bitStream.Write(receiver.playerID); bitStream.Write(receiver.playerID);
//portion that will get routed: //portion that will get routed:
@@ -981,7 +920,7 @@ void ChatPacketHandler::SendFriendRequest(const PlayerData& receiver, const Play
void ChatPacketHandler::SendFriendResponse(const PlayerData& receiver, const PlayerData& sender, eAddFriendResponseType responseCode, uint8_t isBestFriendsAlready, uint8_t isBestFriendRequest) { void ChatPacketHandler::SendFriendResponse(const PlayerData& receiver, const PlayerData& sender, eAddFriendResponseType responseCode, uint8_t isBestFriendsAlready, uint8_t isBestFriendRequest) {
CBITSTREAM; CBITSTREAM;
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::WORLD_ROUTE_PACKET); BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
bitStream.Write(receiver.playerID); bitStream.Write(receiver.playerID);
// Portion that will get routed: // Portion that will get routed:
@@ -1004,7 +943,7 @@ void ChatPacketHandler::SendFriendResponse(const PlayerData& receiver, const Pla
void ChatPacketHandler::SendRemoveFriend(const PlayerData& receiver, std::string& personToRemove, bool isSuccessful) { void ChatPacketHandler::SendRemoveFriend(const PlayerData& receiver, std::string& personToRemove, bool isSuccessful) {
CBITSTREAM; CBITSTREAM;
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::WORLD_ROUTE_PACKET); BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
bitStream.Write(receiver.playerID); bitStream.Write(receiver.playerID);
//portion that will get routed: //portion that will get routed:

View File

@@ -50,8 +50,6 @@ namespace ChatPacketHandler {
void HandleFriendResponse(Packet* packet); void HandleFriendResponse(Packet* packet);
void HandleRemoveFriend(Packet* packet); void HandleRemoveFriend(Packet* packet);
void HandleGMLevelUpdate(Packet* packet); void HandleGMLevelUpdate(Packet* packet);
void HandleWho(Packet* packet);
void HandleShowAll(Packet* packet);
void HandleChatMessage(Packet* packet); void HandleChatMessage(Packet* packet);
void HandlePrivateChatMessage(Packet* packet); void HandlePrivateChatMessage(Packet* packet);

View File

@@ -17,6 +17,7 @@
#include "PlayerContainer.h" #include "PlayerContainer.h"
#include "ChatPacketHandler.h" #include "ChatPacketHandler.h"
#include "eChatMessageType.h" #include "eChatMessageType.h"
#include "eChatInternalMessageType.h"
#include "eWorldMessageType.h" #include "eWorldMessageType.h"
#include "ChatIgnoreList.h" #include "ChatIgnoreList.h"
#include "StringifiedEnum.h" #include "StringifiedEnum.h"
@@ -179,32 +180,49 @@ int main(int argc, char** argv) {
} }
void HandlePacket(Packet* packet) { void HandlePacket(Packet* packet) {
if (packet->length < 1) return;
if (packet->data[0] == ID_DISCONNECTION_NOTIFICATION || packet->data[0] == ID_CONNECTION_LOST) { if (packet->data[0] == ID_DISCONNECTION_NOTIFICATION || packet->data[0] == ID_CONNECTION_LOST) {
LOG("A server has disconnected, erasing their connected players from the list."); LOG("A server has disconnected, erasing their connected players from the list.");
} else if (packet->data[0] == ID_NEW_INCOMING_CONNECTION) { }
if (packet->data[0] == ID_NEW_INCOMING_CONNECTION) {
LOG("A server is connecting, awaiting user list."); LOG("A server is connecting, awaiting user list.");
} else if (packet->length < 4 || packet->data[0] != ID_USER_PACKET_ENUM) return; // Nothing left to process or not the right packet type }
CINSTREAM; if (packet->length < 4) return; // Nothing left to process. Need 4 bytes to continue.
inStream.SetReadOffset(BYTES_TO_BITS(1));
eConnectionType connection; if (static_cast<eConnectionType>(packet->data[1]) == eConnectionType::CHAT_INTERNAL) {
eChatMessageType chatMessageID; switch (static_cast<eChatInternalMessageType>(packet->data[3])) {
case eChatInternalMessageType::PLAYER_ADDED_NOTIFICATION:
Game::playerContainer.InsertPlayer(packet);
break;
inStream.Read(connection); case eChatInternalMessageType::PLAYER_REMOVED_NOTIFICATION:
if (connection != eConnectionType::CHAT) return; Game::playerContainer.RemovePlayer(packet);
inStream.Read(chatMessageID); break;
switch (chatMessageID) { case eChatInternalMessageType::MUTE_UPDATE:
case eChatMessageType::GM_MUTE:
Game::playerContainer.MuteUpdate(packet); Game::playerContainer.MuteUpdate(packet);
break; break;
case eChatMessageType::CREATE_TEAM: case eChatInternalMessageType::CREATE_TEAM:
Game::playerContainer.CreateTeamServer(packet); Game::playerContainer.CreateTeamServer(packet);
break; break;
case eChatInternalMessageType::ANNOUNCEMENT: {
//we just forward this packet to every connected server
CINSTREAM;
Game::server->Send(inStream, packet->systemAddress, true); //send to everyone except origin
break;
}
default:
LOG("Unknown CHAT_INTERNAL id: %i", int(packet->data[3]));
}
}
if (static_cast<eConnectionType>(packet->data[1]) == eConnectionType::CHAT) {
eChatMessageType chat_message_type = static_cast<eChatMessageType>(packet->data[3]);
switch (chat_message_type) {
case eChatMessageType::GET_FRIENDS_LIST: case eChatMessageType::GET_FRIENDS_LIST:
ChatPacketHandler::HandleFriendlistRequest(packet); ChatPacketHandler::HandleFriendlistRequest(packet);
break; break;
@@ -278,23 +296,6 @@ void HandlePacket(Packet* packet) {
ChatPacketHandler::HandleGMLevelUpdate(packet); ChatPacketHandler::HandleGMLevelUpdate(packet);
break; break;
case eChatMessageType::LOGIN_SESSION_NOTIFY: case eChatMessageType::LOGIN_SESSION_NOTIFY:
Game::playerContainer.InsertPlayer(packet);
break;
case eChatMessageType::GM_ANNOUNCE:{
// we just forward this packet to every connected server
inStream.ResetReadPointer();
Game::server->Send(inStream, packet->systemAddress, true); // send to everyone except origin
}
break;
case eChatMessageType::UNEXPECTED_DISCONNECT:
Game::playerContainer.RemovePlayer(packet);
break;
case eChatMessageType::WHO:
ChatPacketHandler::HandleWho(packet);
break;
case eChatMessageType::SHOW_ALL:
ChatPacketHandler::HandleShowAll(packet);
break;
case eChatMessageType::USER_CHANNEL_CHAT_MESSAGE: case eChatMessageType::USER_CHANNEL_CHAT_MESSAGE:
case eChatMessageType::WORLD_DISCONNECT_REQUEST: case eChatMessageType::WORLD_DISCONNECT_REQUEST:
case eChatMessageType::WORLD_PROXIMITY_RESPONSE: case eChatMessageType::WORLD_PROXIMITY_RESPONSE:
@@ -307,6 +308,7 @@ void HandlePacket(Packet* packet) {
case eChatMessageType::GUILD_KICK: case eChatMessageType::GUILD_KICK:
case eChatMessageType::GUILD_GET_STATUS: case eChatMessageType::GUILD_GET_STATUS:
case eChatMessageType::GUILD_GET_ALL: case eChatMessageType::GUILD_GET_ALL:
case eChatMessageType::SHOW_ALL:
case eChatMessageType::BLUEPRINT_MODERATED: case eChatMessageType::BLUEPRINT_MODERATED:
case eChatMessageType::BLUEPRINT_MODEL_READY: case eChatMessageType::BLUEPRINT_MODEL_READY:
case eChatMessageType::PROPERTY_READY_FOR_APPROVAL: case eChatMessageType::PROPERTY_READY_FOR_APPROVAL:
@@ -321,6 +323,7 @@ void HandlePacket(Packet* packet) {
case eChatMessageType::CSR_REQUEST: case eChatMessageType::CSR_REQUEST:
case eChatMessageType::CSR_REPLY: case eChatMessageType::CSR_REPLY:
case eChatMessageType::GM_KICK: case eChatMessageType::GM_KICK:
case eChatMessageType::GM_ANNOUNCE:
case eChatMessageType::WORLD_ROUTE_PACKET: case eChatMessageType::WORLD_ROUTE_PACKET:
case eChatMessageType::GET_ZONE_POPULATIONS: case eChatMessageType::GET_ZONE_POPULATIONS:
case eChatMessageType::REQUEST_MINIMUM_CHAT_MODE: case eChatMessageType::REQUEST_MINIMUM_CHAT_MODE:
@@ -329,18 +332,33 @@ void HandlePacket(Packet* packet) {
case eChatMessageType::UGCMANIFEST_REPORT_DONE_FILE: case eChatMessageType::UGCMANIFEST_REPORT_DONE_FILE:
case eChatMessageType::UGCMANIFEST_REPORT_DONE_BLUEPRINT: case eChatMessageType::UGCMANIFEST_REPORT_DONE_BLUEPRINT:
case eChatMessageType::UGCC_REQUEST: case eChatMessageType::UGCC_REQUEST:
case eChatMessageType::WHO:
case eChatMessageType::WORLD_PLAYERS_PET_MODERATED_ACKNOWLEDGE: case eChatMessageType::WORLD_PLAYERS_PET_MODERATED_ACKNOWLEDGE:
case eChatMessageType::ACHIEVEMENT_NOTIFY: case eChatMessageType::ACHIEVEMENT_NOTIFY:
case eChatMessageType::GM_CLOSE_PRIVATE_CHAT_WINDOW: case eChatMessageType::GM_CLOSE_PRIVATE_CHAT_WINDOW:
case eChatMessageType::UNEXPECTED_DISCONNECT:
case eChatMessageType::PLAYER_READY: case eChatMessageType::PLAYER_READY:
case eChatMessageType::GET_DONATION_TOTAL: case eChatMessageType::GET_DONATION_TOTAL:
case eChatMessageType::UPDATE_DONATION: case eChatMessageType::UPDATE_DONATION:
case eChatMessageType::PRG_CSR_COMMAND: case eChatMessageType::PRG_CSR_COMMAND:
case eChatMessageType::HEARTBEAT_REQUEST_FROM_WORLD: case eChatMessageType::HEARTBEAT_REQUEST_FROM_WORLD:
case eChatMessageType::UPDATE_FREE_TRIAL_STATUS: case eChatMessageType::UPDATE_FREE_TRIAL_STATUS:
LOG("Unhandled CHAT Message id: %s (%i)", StringifiedEnum::ToString(chatMessageID).data(), chatMessageID); LOG("Unhandled CHAT Message id: %s (%i)", StringifiedEnum::ToString(chat_message_type).data(), chat_message_type);
break; break;
default: default:
LOG("Unknown CHAT Message id: %i", chatMessageID); LOG("Unknown CHAT Message id: %i", chat_message_type);
}
}
if (static_cast<eConnectionType>(packet->data[1]) == eConnectionType::WORLD) {
switch (static_cast<eWorldMessageType>(packet->data[3])) {
case eWorldMessageType::ROUTE_PACKET: {
LOG("Routing packet from world");
break;
}
default:
LOG("Unknown World id: %i", int(packet->data[3]));
}
} }
} }

View File

@@ -9,9 +9,9 @@
#include "BitStreamUtils.h" #include "BitStreamUtils.h"
#include "Database.h" #include "Database.h"
#include "eConnectionType.h" #include "eConnectionType.h"
#include "eChatInternalMessageType.h"
#include "ChatPackets.h" #include "ChatPackets.h"
#include "dConfig.h" #include "dConfig.h"
#include "eChatMessageType.h"
void PlayerContainer::Initialize() { void PlayerContainer::Initialize() {
m_MaxNumberOfBestFriends = m_MaxNumberOfBestFriends =
@@ -36,23 +36,19 @@ void PlayerContainer::InsertPlayer(Packet* packet) {
data.playerID = playerId; data.playerID = playerId;
uint32_t len; uint32_t len;
if (!inStream.Read<uint32_t>(len)) return; inStream.Read<uint32_t>(len);
if (len > 33) { for (int i = 0; i < len; i++) {
LOG("Received a really long player name, probably a fake packet %i.", len); char character; inStream.Read<char>(character);
return; data.playerName += character;
} }
data.playerName.resize(len); inStream.Read(data.zoneID);
inStream.ReadAlignedBytes(reinterpret_cast<unsigned char*>(data.playerName.data()), len); inStream.Read(data.muteExpire);
inStream.Read(data.gmLevel);
if (!inStream.Read(data.zoneID)) return;
if (!inStream.Read(data.muteExpire)) return;
if (!inStream.Read(data.gmLevel)) return;
data.sysAddr = packet->systemAddress; data.sysAddr = packet->systemAddress;
m_Names[data.playerID] = GeneralUtils::UTF8ToUTF16(data.playerName); m_Names[data.playerID] = GeneralUtils::UTF8ToUTF16(data.playerName);
m_PlayerCount++;
LOG("Added user: %s (%llu), zone: %i", data.playerName.c_str(), data.playerID, data.zoneID.GetMapID()); LOG("Added user: %s (%llu), zone: %i", data.playerName.c_str(), data.playerID, data.zoneID.GetMapID());
@@ -91,7 +87,6 @@ void PlayerContainer::RemovePlayer(Packet* packet) {
} }
} }
m_PlayerCount--;
LOG("Removed user: %llu", playerID); LOG("Removed user: %llu", playerID);
m_Players.erase(playerID); m_Players.erase(playerID);
@@ -125,11 +120,6 @@ void PlayerContainer::CreateTeamServer(Packet* packet) {
size_t membersSize = 0; size_t membersSize = 0;
inStream.Read(membersSize); inStream.Read(membersSize);
if (membersSize >= 4) {
LOG("Tried to create a team with more than 4 players");
return;
}
std::vector<LWOOBJID> members; std::vector<LWOOBJID> members;
members.reserve(membersSize); members.reserve(membersSize);
@@ -155,7 +145,7 @@ void PlayerContainer::CreateTeamServer(Packet* packet) {
void PlayerContainer::BroadcastMuteUpdate(LWOOBJID player, time_t time) { void PlayerContainer::BroadcastMuteUpdate(LWOOBJID player, time_t time) {
CBITSTREAM; CBITSTREAM;
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::GM_MUTE); BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::MUTE_UPDATE);
bitStream.Write(player); bitStream.Write(player);
bitStream.Write(time); bitStream.Write(time);
@@ -362,7 +352,7 @@ void PlayerContainer::TeamStatusUpdate(TeamData* team) {
void PlayerContainer::UpdateTeamsOnWorld(TeamData* team, bool deleteTeam) { void PlayerContainer::UpdateTeamsOnWorld(TeamData* team, bool deleteTeam) {
CBITSTREAM; CBITSTREAM;
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::TEAM_GET_STATUS); BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::TEAM_UPDATE);
bitStream.Write(team->teamID); bitStream.Write(team->teamID);
bitStream.Write(deleteTeam); bitStream.Write(deleteTeam);
@@ -400,7 +390,7 @@ LWOOBJID PlayerContainer::GetId(const std::u16string& playerName) {
} }
PlayerData& PlayerContainer::GetPlayerDataMutable(const LWOOBJID& playerID) { PlayerData& PlayerContainer::GetPlayerDataMutable(const LWOOBJID& playerID) {
return m_Players.contains(playerID) ? m_Players[playerID] : m_Players[LWOOBJID_EMPTY]; return m_Players[playerID];
} }
PlayerData& PlayerContainer::GetPlayerDataMutable(const std::string& playerName) { PlayerData& PlayerContainer::GetPlayerDataMutable(const std::string& playerName) {

View File

@@ -71,9 +71,6 @@ public:
const PlayerData& GetPlayerData(const std::string& playerName); const PlayerData& GetPlayerData(const std::string& playerName);
PlayerData& GetPlayerDataMutable(const LWOOBJID& playerID); PlayerData& GetPlayerDataMutable(const LWOOBJID& playerID);
PlayerData& GetPlayerDataMutable(const std::string& playerName); PlayerData& GetPlayerDataMutable(const std::string& playerName);
uint32_t GetPlayerCount() { return m_PlayerCount; };
uint32_t GetSimCount() { return m_SimCount; };
const std::map<LWOOBJID, PlayerData>& GetAllPlayers() { return m_Players; };
TeamData* CreateLocalTeam(std::vector<LWOOBJID> members); TeamData* CreateLocalTeam(std::vector<LWOOBJID> members);
TeamData* CreateTeam(LWOOBJID leader, bool local = false); TeamData* CreateTeam(LWOOBJID leader, bool local = false);
@@ -96,7 +93,5 @@ private:
std::unordered_map<LWOOBJID, std::u16string> m_Names; std::unordered_map<LWOOBJID, std::u16string> m_Names;
uint32_t m_MaxNumberOfBestFriends = 5; uint32_t m_MaxNumberOfBestFriends = 5;
uint32_t m_MaxNumberOfFriends = 50; uint32_t m_MaxNumberOfFriends = 50;
uint32_t m_PlayerCount = 0;
uint32_t m_SimCount = 0;
}; };

View File

@@ -1,5 +1,5 @@
#ifndef AMF3_H #ifndef __AMF3__H__
#define AMF3_H #define __AMF3__H__
#include "dCommonVars.h" #include "dCommonVars.h"
#include "Logger.h" #include "Logger.h"
@@ -377,4 +377,4 @@ private:
AMFDense m_Dense; AMFDense m_Dense;
}; };
#endif //!AMF3_H #endif //!__AMF3__H__

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#ifndef BINARYIO_H #ifndef __BINARYIO__H__
#define BINARYIO_H #define __BINARYIO__H__
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
@@ -71,4 +71,4 @@ namespace BinaryIO {
} }
} }
#endif //!BINARYIO_H #endif //!__BINARYIO__H__

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#ifndef BINARYPATHFINDER_H #ifndef __BINARYPATHFINDER__H__
#define BINARYPATHFINDER_H #define __BINARYPATHFINDER__H__
#include <filesystem> #include <filesystem>
@@ -12,4 +12,4 @@ public:
static std::filesystem::path GetBinaryDir(); static std::filesystem::path GetBinaryDir();
}; };
#endif //!BINARYPATHFINDER_H #endif //!__BINARYPATHFINDER__H__

View File

@@ -1,5 +1,5 @@
#ifndef BRICK_H #ifndef __BRICK__H__
#define BRICK_H #define __BRICK__H__
#include <cstdint> #include <cstdint>
@@ -8,4 +8,4 @@ struct Brick {
uint32_t materialID; uint32_t materialID;
}; };
#endif //!BRICK_H #endif //!__BRICK__H__

View File

@@ -120,8 +120,6 @@ void CatchUnhandled(int sig) {
if (eptr) std::rethrow_exception(eptr); if (eptr) std::rethrow_exception(eptr);
} catch(const std::exception& e) { } catch(const std::exception& e) {
LOG("Caught exception: '%s'", e.what()); LOG("Caught exception: '%s'", e.what());
} catch (...) {
LOG("Caught unknown exception.");
} }
#ifndef INCLUDE_BACKTRACE #ifndef INCLUDE_BACKTRACE
@@ -201,7 +199,7 @@ void OnTerminate() {
} }
void MakeBacktrace() { void MakeBacktrace() {
struct sigaction sigact{}; struct sigaction sigact;
sigact.sa_sigaction = CritErrHdlr; sigact.sa_sigaction = CritErrHdlr;
sigact.sa_flags = SA_RESTART | SA_SIGINFO; sigact.sa_flags = SA_RESTART | SA_SIGINFO;

View File

@@ -1,5 +1,5 @@
#ifndef DLUASSERT_H #ifndef __DLUASSERT__H__
#define DLUASSERT_H #define __DLUASSERT__H__
#include <assert.h> #include <assert.h>
@@ -9,4 +9,4 @@
# define DluAssert(expression) # define DluAssert(expression)
#endif #endif
#endif //!DLUASSERT_H #endif //!__DLUASSERT__H__

View File

@@ -1,5 +1,5 @@
#ifndef FDBTOSQLITE_H #ifndef __FDBTOSQLITE__H__
#define FDBTOSQLITE_H #define __FDBTOSQLITE__H__
#pragma once #pragma once
@@ -142,4 +142,4 @@ namespace FdbToSqlite {
}; //! class FdbToSqlite }; //! class FdbToSqlite
}; //! namespace FdbToSqlite }; //! namespace FdbToSqlite
#endif //!FDBTOSQLITE_H #endif //!__FDBTOSQLITE__H__

View File

@@ -8,23 +8,23 @@
#include <map> #include <map>
template <typename T> template <typename T>
static inline size_t MinSize(const size_t size, const std::basic_string_view<T> string) { inline size_t MinSize(size_t size, const std::basic_string_view<T>& string) {
if (size == SIZE_MAX || size > string.size()) { if (size == size_t(-1) || size > string.size()) {
return string.size(); return string.size();
} else { } else {
return size; return size;
} }
} }
inline bool IsLeadSurrogate(const char16_t c) { inline bool IsLeadSurrogate(char16_t c) {
return (0xD800 <= c) && (c <= 0xDBFF); return (0xD800 <= c) && (c <= 0xDBFF);
} }
inline bool IsTrailSurrogate(const char16_t c) { inline bool IsTrailSurrogate(char16_t c) {
return (0xDC00 <= c) && (c <= 0xDFFF); return (0xDC00 <= c) && (c <= 0xDFFF);
} }
inline void PushUTF8CodePoint(std::string& ret, const char32_t cp) { inline void PushUTF8CodePoint(std::string& ret, char32_t cp) {
if (cp <= 0x007F) { if (cp <= 0x007F) {
ret.push_back(static_cast<uint8_t>(cp)); ret.push_back(static_cast<uint8_t>(cp));
} else if (cp <= 0x07FF) { } else if (cp <= 0x07FF) {
@@ -46,16 +46,16 @@ inline void PushUTF8CodePoint(std::string& ret, const char32_t cp) {
constexpr const char16_t REPLACEMENT_CHARACTER = 0xFFFD; constexpr const char16_t REPLACEMENT_CHARACTER = 0xFFFD;
bool static _IsSuffixChar(const uint8_t c) { bool _IsSuffixChar(uint8_t c) {
return (c & 0xC0) == 0x80; return (c & 0xC0) == 0x80;
} }
bool GeneralUtils::details::_NextUTF8Char(std::string_view& slice, uint32_t& out) { bool GeneralUtils::_NextUTF8Char(std::string_view& slice, uint32_t& out) {
const size_t rem = slice.length(); size_t rem = slice.length();
if (slice.empty()) return false; if (slice.empty()) return false;
const uint8_t* bytes = reinterpret_cast<const uint8_t*>(&slice.front()); const uint8_t* bytes = reinterpret_cast<const uint8_t*>(&slice.front());
if (rem > 0) { if (rem > 0) {
const uint8_t first = bytes[0]; uint8_t first = bytes[0];
if (first < 0x80) { // 1 byte character if (first < 0x80) { // 1 byte character
out = static_cast<uint32_t>(first & 0x7F); out = static_cast<uint32_t>(first & 0x7F);
slice.remove_prefix(1); slice.remove_prefix(1);
@@ -64,7 +64,7 @@ bool GeneralUtils::details::_NextUTF8Char(std::string_view& slice, uint32_t& out
// middle byte, not valid at start, fall through // middle byte, not valid at start, fall through
} else if (first < 0xE0) { // two byte character } else if (first < 0xE0) { // two byte character
if (rem > 1) { if (rem > 1) {
const uint8_t second = bytes[1]; uint8_t second = bytes[1];
if (_IsSuffixChar(second)) { if (_IsSuffixChar(second)) {
out = (static_cast<uint32_t>(first & 0x1F) << 6) out = (static_cast<uint32_t>(first & 0x1F) << 6)
+ static_cast<uint32_t>(second & 0x3F); + static_cast<uint32_t>(second & 0x3F);
@@ -74,8 +74,8 @@ bool GeneralUtils::details::_NextUTF8Char(std::string_view& slice, uint32_t& out
} }
} else if (first < 0xF0) { // three byte character } else if (first < 0xF0) { // three byte character
if (rem > 2) { if (rem > 2) {
const uint8_t second = bytes[1]; uint8_t second = bytes[1];
const uint8_t third = bytes[2]; uint8_t third = bytes[2];
if (_IsSuffixChar(second) && _IsSuffixChar(third)) { if (_IsSuffixChar(second) && _IsSuffixChar(third)) {
out = (static_cast<uint32_t>(first & 0x0F) << 12) out = (static_cast<uint32_t>(first & 0x0F) << 12)
+ (static_cast<uint32_t>(second & 0x3F) << 6) + (static_cast<uint32_t>(second & 0x3F) << 6)
@@ -86,9 +86,9 @@ bool GeneralUtils::details::_NextUTF8Char(std::string_view& slice, uint32_t& out
} }
} else if (first < 0xF8) { // four byte character } else if (first < 0xF8) { // four byte character
if (rem > 3) { if (rem > 3) {
const uint8_t second = bytes[1]; uint8_t second = bytes[1];
const uint8_t third = bytes[2]; uint8_t third = bytes[2];
const uint8_t fourth = bytes[3]; uint8_t fourth = bytes[3];
if (_IsSuffixChar(second) && _IsSuffixChar(third) && _IsSuffixChar(fourth)) { if (_IsSuffixChar(second) && _IsSuffixChar(third) && _IsSuffixChar(fourth)) {
out = (static_cast<uint32_t>(first & 0x07) << 18) out = (static_cast<uint32_t>(first & 0x07) << 18)
+ (static_cast<uint32_t>(second & 0x3F) << 12) + (static_cast<uint32_t>(second & 0x3F) << 12)
@@ -107,7 +107,7 @@ bool GeneralUtils::details::_NextUTF8Char(std::string_view& slice, uint32_t& out
} }
/// See <https://www.ietf.org/rfc/rfc2781.html#section-2.1> /// See <https://www.ietf.org/rfc/rfc2781.html#section-2.1>
bool PushUTF16CodePoint(std::u16string& output, const uint32_t U, const size_t size) { bool PushUTF16CodePoint(std::u16string& output, uint32_t U, size_t size) {
if (output.length() >= size) return false; if (output.length() >= size) return false;
if (U < 0x10000) { if (U < 0x10000) {
// If U < 0x10000, encode U as a 16-bit unsigned integer and terminate. // If U < 0x10000, encode U as a 16-bit unsigned integer and terminate.
@@ -120,7 +120,7 @@ bool PushUTF16CodePoint(std::u16string& output, const uint32_t U, const size_t s
// Let U' = U - 0x10000. Because U is less than or equal to 0x10FFFF, // Let U' = U - 0x10000. Because U is less than or equal to 0x10FFFF,
// U' must be less than or equal to 0xFFFFF. That is, U' can be // U' must be less than or equal to 0xFFFFF. That is, U' can be
// represented in 20 bits. // represented in 20 bits.
const uint32_t Ut = U - 0x10000; uint32_t Ut = U - 0x10000;
// Initialize two 16-bit unsigned integers, W1 and W2, to 0xD800 and // Initialize two 16-bit unsigned integers, W1 and W2, to 0xD800 and
// 0xDC00, respectively. These integers each have 10 bits free to // 0xDC00, respectively. These integers each have 10 bits free to
@@ -141,25 +141,25 @@ bool PushUTF16CodePoint(std::u16string& output, const uint32_t U, const size_t s
} else return false; } else return false;
} }
std::u16string GeneralUtils::UTF8ToUTF16(const std::string_view string, const size_t size) { std::u16string GeneralUtils::UTF8ToUTF16(const std::string_view& string, size_t size) {
const size_t newSize = MinSize(size, string); size_t newSize = MinSize(size, string);
std::u16string output; std::u16string output;
output.reserve(newSize); output.reserve(newSize);
std::string_view iterator = string; std::string_view iterator = string;
uint32_t c; uint32_t c;
while (details::_NextUTF8Char(iterator, c) && PushUTF16CodePoint(output, c, size)) {} while (_NextUTF8Char(iterator, c) && PushUTF16CodePoint(output, c, size)) {}
return output; return output;
} }
//! Converts an std::string (ASCII) to UCS-2 / UTF-16 //! Converts an std::string (ASCII) to UCS-2 / UTF-16
std::u16string GeneralUtils::ASCIIToUTF16(const std::string_view string, const size_t size) { std::u16string GeneralUtils::ASCIIToUTF16(const std::string_view& string, size_t size) {
const size_t newSize = MinSize(size, string); size_t newSize = MinSize(size, string);
std::u16string ret; std::u16string ret;
ret.reserve(newSize); ret.reserve(newSize);
for (size_t i = 0; i < newSize; ++i) { for (size_t i = 0; i < newSize; i++) {
const char c = string[i]; char c = string[i];
// Note: both 7-bit ascii characters and REPLACEMENT_CHARACTER fit in one char16_t // Note: both 7-bit ascii characters and REPLACEMENT_CHARACTER fit in one char16_t
ret.push_back((c > 0 && c <= 127) ? static_cast<char16_t>(c) : REPLACEMENT_CHARACTER); ret.push_back((c > 0 && c <= 127) ? static_cast<char16_t>(c) : REPLACEMENT_CHARACTER);
} }
@@ -169,18 +169,18 @@ std::u16string GeneralUtils::ASCIIToUTF16(const std::string_view string, const s
//! Converts a (potentially-ill-formed) UTF-16 string to UTF-8 //! Converts a (potentially-ill-formed) UTF-16 string to UTF-8
//! See: <http://simonsapin.github.io/wtf-8/#decoding-ill-formed-utf-16> //! See: <http://simonsapin.github.io/wtf-8/#decoding-ill-formed-utf-16>
std::string GeneralUtils::UTF16ToWTF8(const std::u16string_view string, const size_t size) { std::string GeneralUtils::UTF16ToWTF8(const std::u16string_view& string, size_t size) {
const size_t newSize = MinSize(size, string); size_t newSize = MinSize(size, string);
std::string ret; std::string ret;
ret.reserve(newSize); ret.reserve(newSize);
for (size_t i = 0; i < newSize; ++i) { for (size_t i = 0; i < newSize; i++) {
const char16_t u = string[i]; char16_t u = string[i];
if (IsLeadSurrogate(u) && (i + 1) < newSize) { if (IsLeadSurrogate(u) && (i + 1) < newSize) {
const char16_t next = string[i + 1]; char16_t next = string[i + 1];
if (IsTrailSurrogate(next)) { if (IsTrailSurrogate(next)) {
i += 1; i += 1;
const char32_t cp = 0x10000 char32_t cp = 0x10000
+ ((static_cast<char32_t>(u) - 0xD800) << 10) + ((static_cast<char32_t>(u) - 0xD800) << 10)
+ (static_cast<char32_t>(next) - 0xDC00); + (static_cast<char32_t>(next) - 0xDC00);
PushUTF8CodePoint(ret, cp); PushUTF8CodePoint(ret, cp);
@@ -195,40 +195,40 @@ std::string GeneralUtils::UTF16ToWTF8(const std::u16string_view string, const si
return ret; return ret;
} }
bool GeneralUtils::CaseInsensitiveStringCompare(const std::string_view a, const std::string_view b) { bool GeneralUtils::CaseInsensitiveStringCompare(const std::string& a, const std::string& b) {
return std::equal(a.begin(), a.end(), b.begin(), b.end(), [](char a, char b) { return tolower(a) == tolower(b); }); return std::equal(a.begin(), a.end(), b.begin(), b.end(), [](char a, char b) { return tolower(a) == tolower(b); });
} }
// MARK: Bits // MARK: Bits
//! Sets a specific bit in a signed 64-bit integer //! Sets a specific bit in a signed 64-bit integer
int64_t GeneralUtils::SetBit(int64_t value, const uint32_t index) { int64_t GeneralUtils::SetBit(int64_t value, uint32_t index) {
return value |= 1ULL << index; return value |= 1ULL << index;
} }
//! Clears a specific bit in a signed 64-bit integer //! Clears a specific bit in a signed 64-bit integer
int64_t GeneralUtils::ClearBit(int64_t value, const uint32_t index) { int64_t GeneralUtils::ClearBit(int64_t value, uint32_t index) {
return value &= ~(1ULL << index); return value &= ~(1ULL << index);
} }
//! Checks a specific bit in a signed 64-bit integer //! Checks a specific bit in a signed 64-bit integer
bool GeneralUtils::CheckBit(int64_t value, const uint32_t index) { bool GeneralUtils::CheckBit(int64_t value, uint32_t index) {
return value & (1ULL << index); return value & (1ULL << index);
} }
bool GeneralUtils::ReplaceInString(std::string& str, const std::string_view from, const std::string_view to) { bool GeneralUtils::ReplaceInString(std::string& str, const std::string& from, const std::string& to) {
const size_t start_pos = str.find(from); size_t start_pos = str.find(from);
if (start_pos == std::string::npos) if (start_pos == std::string::npos)
return false; return false;
str.replace(start_pos, from.length(), to); str.replace(start_pos, from.length(), to);
return true; return true;
} }
std::vector<std::wstring> GeneralUtils::SplitString(const std::wstring_view str, const wchar_t delimiter) { std::vector<std::wstring> GeneralUtils::SplitString(std::wstring& str, wchar_t delimiter) {
std::vector<std::wstring> vector = std::vector<std::wstring>(); std::vector<std::wstring> vector = std::vector<std::wstring>();
std::wstring current; std::wstring current;
for (const wchar_t c : str) { for (const auto& c : str) {
if (c == delimiter) { if (c == delimiter) {
vector.push_back(current); vector.push_back(current);
current = L""; current = L"";
@@ -237,15 +237,15 @@ std::vector<std::wstring> GeneralUtils::SplitString(const std::wstring_view str,
} }
} }
vector.push_back(std::move(current)); vector.push_back(current);
return vector; return vector;
} }
std::vector<std::u16string> GeneralUtils::SplitString(const std::u16string_view str, const char16_t delimiter) { std::vector<std::u16string> GeneralUtils::SplitString(const std::u16string& str, char16_t delimiter) {
std::vector<std::u16string> vector = std::vector<std::u16string>(); std::vector<std::u16string> vector = std::vector<std::u16string>();
std::u16string current; std::u16string current;
for (const char16_t c : str) { for (const auto& c : str) {
if (c == delimiter) { if (c == delimiter) {
vector.push_back(current); vector.push_back(current);
current = u""; current = u"";
@@ -254,15 +254,17 @@ std::vector<std::u16string> GeneralUtils::SplitString(const std::u16string_view
} }
} }
vector.push_back(std::move(current)); vector.push_back(current);
return vector; return vector;
} }
std::vector<std::string> GeneralUtils::SplitString(const std::string_view str, const char delimiter) { std::vector<std::string> GeneralUtils::SplitString(const std::string& str, char delimiter) {
std::vector<std::string> vector = std::vector<std::string>(); std::vector<std::string> vector = std::vector<std::string>();
std::string current = ""; std::string current = "";
for (const char c : str) { for (size_t i = 0; i < str.length(); i++) {
char c = str[i];
if (c == delimiter) { if (c == delimiter) {
vector.push_back(current); vector.push_back(current);
current = ""; current = "";
@@ -271,7 +273,8 @@ std::vector<std::string> GeneralUtils::SplitString(const std::string_view str, c
} }
} }
vector.push_back(std::move(current)); vector.push_back(current);
return vector; return vector;
} }
@@ -280,7 +283,7 @@ std::u16string GeneralUtils::ReadWString(RakNet::BitStream& inStream) {
inStream.Read<uint32_t>(length); inStream.Read<uint32_t>(length);
std::u16string string; std::u16string string;
for (uint32_t i = 0; i < length; ++i) { for (auto i = 0; i < length; i++) {
uint16_t c; uint16_t c;
inStream.Read(c); inStream.Read(c);
string.push_back(c); string.push_back(c);
@@ -289,35 +292,35 @@ std::u16string GeneralUtils::ReadWString(RakNet::BitStream& inStream) {
return string; return string;
} }
std::vector<std::string> GeneralUtils::GetSqlFileNamesFromFolder(const std::string_view folder) { std::vector<std::string> GeneralUtils::GetSqlFileNamesFromFolder(const std::string& folder) {
// Because we dont know how large the initial number before the first _ is we need to make it a map like so. // Because we dont know how large the initial number before the first _ is we need to make it a map like so.
std::map<uint32_t, std::string> filenames{}; std::map<uint32_t, std::string> filenames{};
for (const auto& t : std::filesystem::directory_iterator(folder)) { for (auto& t : std::filesystem::directory_iterator(folder)) {
auto filename = t.path().filename().string(); auto filename = t.path().filename().string();
const auto index = std::stoi(GeneralUtils::SplitString(filename, '_').at(0)); auto index = std::stoi(GeneralUtils::SplitString(filename, '_').at(0));
filenames.emplace(index, std::move(filename)); filenames.insert(std::make_pair(index, filename));
} }
// Now sort the map by the oldest migration. // Now sort the map by the oldest migration.
std::vector<std::string> sortedFiles{}; std::vector<std::string> sortedFiles{};
auto fileIterator = filenames.cbegin(); auto fileIterator = filenames.begin();
auto oldest = filenames.cbegin(); std::map<uint32_t, std::string>::iterator oldest = filenames.begin();
while (!filenames.empty()) { while (!filenames.empty()) {
if (fileIterator == filenames.cend()) { if (fileIterator == filenames.end()) {
sortedFiles.push_back(oldest->second); sortedFiles.push_back(oldest->second);
filenames.erase(oldest); filenames.erase(oldest);
fileIterator = filenames.cbegin(); fileIterator = filenames.begin();
oldest = filenames.cbegin(); oldest = filenames.begin();
continue; continue;
} }
if (oldest->first > fileIterator->first) oldest = fileIterator; if (oldest->first > fileIterator->first) oldest = fileIterator;
++fileIterator; fileIterator++;
} }
return sortedFiles; return sortedFiles;
} }
#if !(__GNUC__ >= 11 || _MSC_VER >= 1924) #ifdef DARKFLAME_PLATFORM_MACOS
// MacOS floating-point parse function specializations // MacOS floating-point parse function specializations
namespace GeneralUtils::details { namespace GeneralUtils::details {

View File

@@ -3,18 +3,17 @@
// C++ // C++
#include <charconv> #include <charconv>
#include <cstdint> #include <cstdint>
#include <ctime>
#include <functional>
#include <optional>
#include <random> #include <random>
#include <span> #include <ctime>
#include <stdexcept>
#include <string> #include <string>
#include <string_view> #include <string_view>
#include <optional>
#include <functional>
#include <type_traits> #include <type_traits>
#include <stdexcept>
#include "BitStream.h" #include "BitStream.h"
#include "NiPoint3.h" #include "NiPoint3.h"
#include "dPlatforms.h" #include "dPlatforms.h"
#include "Game.h" #include "Game.h"
#include "Logger.h" #include "Logger.h"
@@ -33,31 +32,29 @@ namespace GeneralUtils {
//! Converts a plain ASCII string to a UTF-16 string //! Converts a plain ASCII string to a UTF-16 string
/*! /*!
\param string The string to convert \param string The string to convert
\param size A size to trim the string to. Default is SIZE_MAX (No trimming) \param size A size to trim the string to. Default is -1 (No trimming)
\return An UTF-16 representation of the string \return An UTF-16 representation of the string
*/ */
std::u16string ASCIIToUTF16(const std::string_view string, const size_t size = SIZE_MAX); std::u16string ASCIIToUTF16(const std::string_view& string, size_t size = -1);
//! Converts a UTF-8 String to a UTF-16 string //! Converts a UTF-8 String to a UTF-16 string
/*! /*!
\param string The string to convert \param string The string to convert
\param size A size to trim the string to. Default is SIZE_MAX (No trimming) \param size A size to trim the string to. Default is -1 (No trimming)
\return An UTF-16 representation of the string \return An UTF-16 representation of the string
*/ */
std::u16string UTF8ToUTF16(const std::string_view string, const size_t size = SIZE_MAX); std::u16string UTF8ToUTF16(const std::string_view& string, size_t size = -1);
namespace details { //! Internal, do not use
//! Internal, do not use bool _NextUTF8Char(std::string_view& slice, uint32_t& out);
bool _NextUTF8Char(std::string_view& slice, uint32_t& out);
}
//! Converts a UTF-16 string to a UTF-8 string //! Converts a UTF-16 string to a UTF-8 string
/*! /*!
\param string The string to convert \param string The string to convert
\param size A size to trim the string to. Default is SIZE_MAX (No trimming) \param size A size to trim the string to. Default is -1 (No trimming)
\return An UTF-8 representation of the string \return An UTF-8 representation of the string
*/ */
std::string UTF16ToWTF8(const std::u16string_view string, const size_t size = SIZE_MAX); std::string UTF16ToWTF8(const std::u16string_view& string, size_t size = -1);
/** /**
* Compares two basic strings but does so ignoring case sensitivity * Compares two basic strings but does so ignoring case sensitivity
@@ -65,7 +62,7 @@ namespace GeneralUtils {
* \param b the second string to compare against the first string * \param b the second string to compare against the first string
* @return if the two strings are equal * @return if the two strings are equal
*/ */
bool CaseInsensitiveStringCompare(const std::string_view a, const std::string_view b); bool CaseInsensitiveStringCompare(const std::string& a, const std::string& b);
// MARK: Bits // MARK: Bits
@@ -73,9 +70,9 @@ namespace GeneralUtils {
//! Sets a bit on a numerical value //! Sets a bit on a numerical value
template <typename T> template <typename T>
inline void SetBit(T& value, const eObjectBits bits) { inline void SetBit(T& value, eObjectBits bits) {
static_assert(std::is_arithmetic<T>::value, "Not an arithmetic type"); static_assert(std::is_arithmetic<T>::value, "Not an arithmetic type");
const auto index = static_cast<size_t>(bits); auto index = static_cast<size_t>(bits);
if (index > (sizeof(T) * 8) - 1) { if (index > (sizeof(T) * 8) - 1) {
return; return;
} }
@@ -85,9 +82,9 @@ namespace GeneralUtils {
//! Clears a bit on a numerical value //! Clears a bit on a numerical value
template <typename T> template <typename T>
inline void ClearBit(T& value, const eObjectBits bits) { inline void ClearBit(T& value, eObjectBits bits) {
static_assert(std::is_arithmetic<T>::value, "Not an arithmetic type"); static_assert(std::is_arithmetic<T>::value, "Not an arithmetic type");
const auto index = static_cast<size_t>(bits); auto index = static_cast<size_t>(bits);
if (index > (sizeof(T) * 8 - 1)) { if (index > (sizeof(T) * 8 - 1)) {
return; return;
} }
@@ -100,14 +97,14 @@ namespace GeneralUtils {
\param value The value to set the bit for \param value The value to set the bit for
\param index The index of the bit \param index The index of the bit
*/ */
int64_t SetBit(int64_t value, const uint32_t index); int64_t SetBit(int64_t value, uint32_t index);
//! Clears a specific bit in a signed 64-bit integer //! Clears a specific bit in a signed 64-bit integer
/*! /*!
\param value The value to clear the bit from \param value The value to clear the bit from
\param index The index of the bit \param index The index of the bit
*/ */
int64_t ClearBit(int64_t value, const uint32_t index); int64_t ClearBit(int64_t value, uint32_t index);
//! Checks a specific bit in a signed 64-bit integer //! Checks a specific bit in a signed 64-bit integer
/*! /*!
@@ -115,19 +112,19 @@ namespace GeneralUtils {
\param index The index of the bit \param index The index of the bit
\return Whether or not the bit is set \return Whether or not the bit is set
*/ */
bool CheckBit(int64_t value, const uint32_t index); bool CheckBit(int64_t value, uint32_t index);
bool ReplaceInString(std::string& str, const std::string_view from, const std::string_view to); bool ReplaceInString(std::string& str, const std::string& from, const std::string& to);
std::u16string ReadWString(RakNet::BitStream& inStream); std::u16string ReadWString(RakNet::BitStream& inStream);
std::vector<std::wstring> SplitString(const std::wstring_view str, const wchar_t delimiter); std::vector<std::wstring> SplitString(std::wstring& str, wchar_t delimiter);
std::vector<std::u16string> SplitString(const std::u16string_view str, const char16_t delimiter); std::vector<std::u16string> SplitString(const std::u16string& str, char16_t delimiter);
std::vector<std::string> SplitString(const std::string_view str, const char delimiter); std::vector<std::string> SplitString(const std::string& str, char delimiter);
std::vector<std::string> GetSqlFileNamesFromFolder(const std::string_view folder); std::vector<std::string> GetSqlFileNamesFromFolder(const std::string& folder);
// Concept constraining to enum types // Concept constraining to enum types
template <typename T> template <typename T>
@@ -147,7 +144,7 @@ namespace GeneralUtils {
// If a boolean, present an alias to an intermediate integral type for parsing // If a boolean, present an alias to an intermediate integral type for parsing
template <Numeric T> requires std::same_as<T, bool> template <Numeric T> requires std::same_as<T, bool>
struct numeric_parse<T> { using type = uint8_t; }; struct numeric_parse<T> { using type = uint32_t; };
// Shorthand type alias // Shorthand type alias
template <Numeric T> template <Numeric T>
@@ -159,9 +156,8 @@ namespace GeneralUtils {
* @returns An std::optional containing the desired value if it is equivalent to the string * @returns An std::optional containing the desired value if it is equivalent to the string
*/ */
template <Numeric T> template <Numeric T>
[[nodiscard]] std::optional<T> TryParse(std::string_view str) { [[nodiscard]] std::optional<T> TryParse(const std::string_view str) {
numeric_parse_t<T> result; numeric_parse_t<T> result;
while (!str.empty() && std::isspace(str.front())) str.remove_prefix(1);
const char* const strEnd = str.data() + str.size(); const char* const strEnd = str.data() + str.size();
const auto [parseEnd, ec] = std::from_chars(str.data(), strEnd, result); const auto [parseEnd, ec] = std::from_chars(str.data(), strEnd, result);
@@ -170,7 +166,7 @@ namespace GeneralUtils {
return isParsed ? static_cast<T>(result) : std::optional<T>{}; return isParsed ? static_cast<T>(result) : std::optional<T>{};
} }
#if !(__GNUC__ >= 11 || _MSC_VER >= 1924) #ifdef DARKFLAME_PLATFORM_MACOS
// MacOS floating-point parse helper function specializations // MacOS floating-point parse helper function specializations
namespace details { namespace details {
@@ -185,10 +181,8 @@ namespace GeneralUtils {
* @returns An std::optional containing the desired value if it is equivalent to the string * @returns An std::optional containing the desired value if it is equivalent to the string
*/ */
template <std::floating_point T> template <std::floating_point T>
[[nodiscard]] std::optional<T> TryParse(std::string_view str) noexcept [[nodiscard]] std::optional<T> TryParse(const std::string_view str) noexcept
try { try {
while (!str.empty() && std::isspace(str.front())) str.remove_prefix(1);
size_t parseNum; size_t parseNum;
const T result = details::_parse<T>(str, parseNum); const T result = details::_parse<T>(str, parseNum);
const bool isParsed = str.length() == parseNum; const bool isParsed = str.length() == parseNum;
@@ -208,7 +202,7 @@ namespace GeneralUtils {
* @returns An std::optional containing the desired NiPoint3 if it can be constructed from the string parameters * @returns An std::optional containing the desired NiPoint3 if it can be constructed from the string parameters
*/ */
template <typename T> template <typename T>
[[nodiscard]] std::optional<NiPoint3> TryParse(const std::string_view strX, const std::string_view strY, const std::string_view strZ) { [[nodiscard]] std::optional<NiPoint3> TryParse(const std::string& strX, const std::string& strY, const std::string& strZ) {
const auto x = TryParse<float>(strX); const auto x = TryParse<float>(strX);
if (!x) return std::nullopt; if (!x) return std::nullopt;
@@ -220,17 +214,17 @@ namespace GeneralUtils {
} }
/** /**
* The TryParse overload for handling NiPoint3 by passing a span of three strings * The TryParse overload for handling NiPoint3 by passingn a reference to a vector of three strings
* @param str The string vector representing the X, Y, and Z coordinates * @param str The string vector representing the X, Y, and Xcoordinates
* @returns An std::optional containing the desired NiPoint3 if it can be constructed from the string parameters * @returns An std::optional containing the desired NiPoint3 if it can be constructed from the string parameters
*/ */
template <typename T> template <typename T>
[[nodiscard]] std::optional<NiPoint3> TryParse(const std::span<const std::string> str) { [[nodiscard]] std::optional<NiPoint3> TryParse(const std::vector<std::string>& str) {
return (str.size() == 3) ? TryParse<NiPoint3>(str[0], str[1], str[2]) : std::nullopt; return (str.size() == 3) ? TryParse<NiPoint3>(str[0], str[1], str[2]) : std::nullopt;
} }
template <typename T> template <typename T>
std::u16string to_u16string(const T value) { std::u16string to_u16string(T value) {
return GeneralUtils::ASCIIToUTF16(std::to_string(value)); return GeneralUtils::ASCIIToUTF16(std::to_string(value));
} }
@@ -249,7 +243,7 @@ namespace GeneralUtils {
\param max The maximum to generate to \param max The maximum to generate to
*/ */
template <typename T> template <typename T>
inline T GenerateRandomNumber(const std::size_t min, const std::size_t max) { inline T GenerateRandomNumber(std::size_t min, std::size_t max) {
// Make sure it is a numeric type // Make sure it is a numeric type
static_assert(std::is_arithmetic<T>::value, "Not an arithmetic type"); static_assert(std::is_arithmetic<T>::value, "Not an arithmetic type");
@@ -270,16 +264,16 @@ namespace GeneralUtils {
* @returns The enum entry's value in its underlying type * @returns The enum entry's value in its underlying type
*/ */
template <Enum eType> template <Enum eType>
constexpr std::underlying_type_t<eType> ToUnderlying(const eType entry) noexcept { constexpr typename std::underlying_type_t<eType> CastUnderlyingType(const eType entry) noexcept {
return static_cast<std::underlying_type_t<eType>>(entry); return static_cast<typename std::underlying_type_t<eType>>(entry);
} }
// on Windows we need to undef these or else they conflict with our numeric limits calls // on Windows we need to undef these or else they conflict with our numeric limits calls
// DEVELOPERS DEVELOPERS DEVELOPERS DEVELOPERS DEVELOPERS DEVELOPERS DEVELOPERS DEVELOPERS // DEVELOPERS DEVELOPERS DEVELOPERS DEVELOPERS DEVELOPERS DEVELOPERS DEVELOPERS DEVELOPERS
#ifdef _WIN32 #ifdef _WIN32
#undef min #undef min
#undef max #undef max
#endif #endif
template <typename T> template <typename T>
inline T GenerateRandomNumber() { inline T GenerateRandomNumber() {

View File

@@ -1,5 +1,5 @@
#ifndef LDFFORMAT_H #ifndef __LDFFORMAT__H__
#define LDFFORMAT_H #define __LDFFORMAT__H__
// Custom Classes // Custom Classes
#include "dCommonVars.h" #include "dCommonVars.h"
@@ -31,22 +31,22 @@ public:
virtual ~LDFBaseData() {} virtual ~LDFBaseData() {}
virtual void WriteToPacket(RakNet::BitStream& packet) const = 0; virtual void WriteToPacket(RakNet::BitStream& packet) = 0;
virtual const std::u16string& GetKey() const = 0; virtual const std::u16string& GetKey() = 0;
virtual eLDFType GetValueType() const = 0; virtual eLDFType GetValueType() = 0;
/** Gets a string from the key/value pair /** Gets a string from the key/value pair
* @param includeKey Whether or not to include the key in the data * @param includeKey Whether or not to include the key in the data
* @param includeTypeId Whether or not to include the type id in the data * @param includeTypeId Whether or not to include the type id in the data
* @return The string representation of the data * @return The string representation of the data
*/ */
virtual std::string GetString(bool includeKey = true, bool includeTypeId = true) const = 0; virtual std::string GetString(bool includeKey = true, bool includeTypeId = true) = 0;
virtual std::string GetValueAsString() const = 0; virtual std::string GetValueAsString() = 0;
virtual LDFBaseData* Copy() const = 0; virtual LDFBaseData* Copy() = 0;
/** /**
* Given an input string, return the data as a LDF key. * Given an input string, return the data as a LDF key.
@@ -62,7 +62,7 @@ private:
T value; T value;
//! Writes the key to the packet //! Writes the key to the packet
void WriteKey(RakNet::BitStream& packet) const { void WriteKey(RakNet::BitStream& packet) {
packet.Write<uint8_t>(this->key.length() * sizeof(uint16_t)); packet.Write<uint8_t>(this->key.length() * sizeof(uint16_t));
for (uint32_t i = 0; i < this->key.length(); ++i) { for (uint32_t i = 0; i < this->key.length(); ++i) {
packet.Write<uint16_t>(this->key[i]); packet.Write<uint16_t>(this->key[i]);
@@ -70,7 +70,7 @@ private:
} }
//! Writes the value to the packet //! Writes the value to the packet
void WriteValue(RakNet::BitStream& packet) const { void WriteValue(RakNet::BitStream& packet) {
packet.Write<uint8_t>(this->GetValueType()); packet.Write<uint8_t>(this->GetValueType());
packet.Write(this->value); packet.Write(this->value);
} }
@@ -90,7 +90,7 @@ public:
/*! /*!
\return The value \return The value
*/ */
const T& GetValue(void) const { return this->value; } const T& GetValue(void) { return this->value; }
//! Sets the value //! Sets the value
/*! /*!
@@ -102,13 +102,13 @@ public:
/*! /*!
\return The value string \return The value string
*/ */
std::string GetValueString(void) const { return ""; } std::string GetValueString(void) { return ""; }
//! Writes the data to a packet //! Writes the data to a packet
/*! /*!
\param packet The packet \param packet The packet
*/ */
void WriteToPacket(RakNet::BitStream& packet) const override { void WriteToPacket(RakNet::BitStream& packet) override {
this->WriteKey(packet); this->WriteKey(packet);
this->WriteValue(packet); this->WriteValue(packet);
} }
@@ -117,13 +117,13 @@ public:
/*! /*!
\return The key \return The key
*/ */
const std::u16string& GetKey(void) const override { return this->key; } const std::u16string& GetKey(void) override { return this->key; }
//! Gets the LDF Type //! Gets the LDF Type
/*! /*!
\return The LDF value type \return The LDF value type
*/ */
eLDFType GetValueType(void) const override { return LDF_TYPE_UNKNOWN; } eLDFType GetValueType(void) override { return LDF_TYPE_UNKNOWN; }
//! Gets the string data //! Gets the string data
/*! /*!
@@ -131,7 +131,7 @@ public:
\param includeTypeId Whether or not to include the type id in the data \param includeTypeId Whether or not to include the type id in the data
\return The string representation of the data \return The string representation of the data
*/ */
std::string GetString(const bool includeKey = true, const bool includeTypeId = true) const override { std::string GetString(const bool includeKey = true, const bool includeTypeId = true) override {
if (GetValueType() == -1) { if (GetValueType() == -1) {
return GeneralUtils::UTF16ToWTF8(this->key) + "=-1:<server variable>"; return GeneralUtils::UTF16ToWTF8(this->key) + "=-1:<server variable>";
} }
@@ -154,11 +154,11 @@ public:
return stream.str(); return stream.str();
} }
std::string GetValueAsString() const override { std::string GetValueAsString() override {
return this->GetValueString(); return this->GetValueString();
} }
LDFBaseData* Copy() const override { LDFBaseData* Copy() override {
return new LDFData<T>(key, value); return new LDFData<T>(key, value);
} }
@@ -166,19 +166,19 @@ public:
}; };
// LDF Types // LDF Types
template<> inline eLDFType LDFData<std::u16string>::GetValueType(void) const { return LDF_TYPE_UTF_16; }; template<> inline eLDFType LDFData<std::u16string>::GetValueType(void) { return LDF_TYPE_UTF_16; };
template<> inline eLDFType LDFData<int32_t>::GetValueType(void) const { return LDF_TYPE_S32; }; template<> inline eLDFType LDFData<int32_t>::GetValueType(void) { return LDF_TYPE_S32; };
template<> inline eLDFType LDFData<float>::GetValueType(void) const { return LDF_TYPE_FLOAT; }; template<> inline eLDFType LDFData<float>::GetValueType(void) { return LDF_TYPE_FLOAT; };
template<> inline eLDFType LDFData<double>::GetValueType(void) const { return LDF_TYPE_DOUBLE; }; template<> inline eLDFType LDFData<double>::GetValueType(void) { return LDF_TYPE_DOUBLE; };
template<> inline eLDFType LDFData<uint32_t>::GetValueType(void) const { return LDF_TYPE_U32; }; template<> inline eLDFType LDFData<uint32_t>::GetValueType(void) { return LDF_TYPE_U32; };
template<> inline eLDFType LDFData<bool>::GetValueType(void) const { return LDF_TYPE_BOOLEAN; }; template<> inline eLDFType LDFData<bool>::GetValueType(void) { return LDF_TYPE_BOOLEAN; };
template<> inline eLDFType LDFData<uint64_t>::GetValueType(void) const { return LDF_TYPE_U64; }; template<> inline eLDFType LDFData<uint64_t>::GetValueType(void) { return LDF_TYPE_U64; };
template<> inline eLDFType LDFData<LWOOBJID>::GetValueType(void) const { return LDF_TYPE_OBJID; }; template<> inline eLDFType LDFData<LWOOBJID>::GetValueType(void) { return LDF_TYPE_OBJID; };
template<> inline eLDFType LDFData<std::string>::GetValueType(void) const { return LDF_TYPE_UTF_8; }; template<> inline eLDFType LDFData<std::string>::GetValueType(void) { return LDF_TYPE_UTF_8; };
// The specialized version for std::u16string (UTF-16) // The specialized version for std::u16string (UTF-16)
template<> template<>
inline void LDFData<std::u16string>::WriteValue(RakNet::BitStream& packet) const { inline void LDFData<std::u16string>::WriteValue(RakNet::BitStream& packet) {
packet.Write<uint8_t>(this->GetValueType()); packet.Write<uint8_t>(this->GetValueType());
packet.Write<uint32_t>(this->value.length()); packet.Write<uint32_t>(this->value.length());
@@ -189,7 +189,7 @@ inline void LDFData<std::u16string>::WriteValue(RakNet::BitStream& packet) const
// The specialized version for bool // The specialized version for bool
template<> template<>
inline void LDFData<bool>::WriteValue(RakNet::BitStream& packet) const { inline void LDFData<bool>::WriteValue(RakNet::BitStream& packet) {
packet.Write<uint8_t>(this->GetValueType()); packet.Write<uint8_t>(this->GetValueType());
packet.Write<uint8_t>(this->value); packet.Write<uint8_t>(this->value);
@@ -197,7 +197,7 @@ inline void LDFData<bool>::WriteValue(RakNet::BitStream& packet) const {
// The specialized version for std::string (UTF-8) // The specialized version for std::string (UTF-8)
template<> template<>
inline void LDFData<std::string>::WriteValue(RakNet::BitStream& packet) const { inline void LDFData<std::string>::WriteValue(RakNet::BitStream& packet) {
packet.Write<uint8_t>(this->GetValueType()); packet.Write<uint8_t>(this->GetValueType());
packet.Write<uint32_t>(this->value.length()); packet.Write<uint32_t>(this->value.length());
@@ -206,18 +206,18 @@ inline void LDFData<std::string>::WriteValue(RakNet::BitStream& packet) const {
} }
} }
template<> inline std::string LDFData<std::u16string>::GetValueString() const { template<> inline std::string LDFData<std::u16string>::GetValueString() {
return GeneralUtils::UTF16ToWTF8(this->value, this->value.size()); return GeneralUtils::UTF16ToWTF8(this->value, this->value.size());
} }
template<> inline std::string LDFData<int32_t>::GetValueString() const { return std::to_string(this->value); } template<> inline std::string LDFData<int32_t>::GetValueString() { return std::to_string(this->value); }
template<> inline std::string LDFData<float>::GetValueString() const { return std::to_string(this->value); } template<> inline std::string LDFData<float>::GetValueString() { return std::to_string(this->value); }
template<> inline std::string LDFData<double>::GetValueString() const { return std::to_string(this->value); } template<> inline std::string LDFData<double>::GetValueString() { return std::to_string(this->value); }
template<> inline std::string LDFData<uint32_t>::GetValueString() const { return std::to_string(this->value); } template<> inline std::string LDFData<uint32_t>::GetValueString() { return std::to_string(this->value); }
template<> inline std::string LDFData<bool>::GetValueString() const { return std::to_string(this->value); } template<> inline std::string LDFData<bool>::GetValueString() { return std::to_string(this->value); }
template<> inline std::string LDFData<uint64_t>::GetValueString() const { return std::to_string(this->value); } template<> inline std::string LDFData<uint64_t>::GetValueString() { return std::to_string(this->value); }
template<> inline std::string LDFData<LWOOBJID>::GetValueString() const { return std::to_string(this->value); } template<> inline std::string LDFData<LWOOBJID>::GetValueString() { return std::to_string(this->value); }
template<> inline std::string LDFData<std::string>::GetValueString() const { return this->value; } template<> inline std::string LDFData<std::string>::GetValueString() { return this->value; }
#endif //!LDFFORMAT_H #endif //!__LDFFORMAT__H__

View File

@@ -1,5 +1,5 @@
#ifndef NIPOINT3_H #ifndef __NIPOINT3_H__
#define NIPOINT3_H #define __NIPOINT3_H__
/*! /*!
\file NiPoint3.hpp \file NiPoint3.hpp
@@ -201,4 +201,4 @@ namespace NiPoint3Constant {
// .inl file needed for code organization and to circumvent circular dependency issues // .inl file needed for code organization and to circumvent circular dependency issues
#include "NiPoint3.inl" #include "NiPoint3.inl"
#endif // !NIPOINT3_H #endif // !__NIPOINT3_H__

View File

@@ -1,5 +1,5 @@
#pragma once #pragma once
#ifndef NIPOINT3_H #ifndef __NIPOINT3_H__
#error "This should only be included inline in NiPoint3.h: Do not include directly!" #error "This should only be included inline in NiPoint3.h: Do not include directly!"
#endif #endif

View File

@@ -1,5 +1,5 @@
#ifndef NIQUATERNION_H #ifndef __NIQUATERNION_H__
#define NIQUATERNION_H #define __NIQUATERNION_H__
// Custom Classes // Custom Classes
#include "NiPoint3.h" #include "NiPoint3.h"
@@ -155,4 +155,4 @@ namespace NiQuaternionConstant {
// Include constexpr and inline function definitions in a seperate file for readability // Include constexpr and inline function definitions in a seperate file for readability
#include "NiQuaternion.inl" #include "NiQuaternion.inl"
#endif // !NIQUATERNION_H #endif // !__NIQUATERNION_H__

View File

@@ -1,5 +1,5 @@
#pragma once #pragma once
#ifndef NIQUATERNION_H #ifndef __NIQUATERNION_H__
#error "This should only be included inline in NiQuaternion.h: Do not include directly!" #error "This should only be included inline in NiQuaternion.h: Do not include directly!"
#endif #endif

View File

@@ -1,5 +1,5 @@
#ifndef POSITIONUPDATE_H #ifndef __POSITIONUPDATE__H__
#define POSITIONUPDATE_H #define __POSITIONUPDATE__H__
#include "NiPoint3.h" #include "NiPoint3.h"
#include "NiQuaternion.h" #include "NiQuaternion.h"
@@ -33,4 +33,4 @@ struct PositionUpdate {
RemoteInputInfo remoteInputInfo; RemoteInputInfo remoteInputInfo;
}; };
#endif //!POSITIONUPDATE_H #endif //!__POSITIONUPDATE__H__

View File

@@ -1,5 +1,5 @@
#ifndef CLIENTVERSION_H #ifndef __CLIENTVERSION_H__
#define CLIENTVERSION_H #define __CLIENTVERSION_H__
#include <cstdint> #include <cstdint>
@@ -9,4 +9,4 @@ namespace ClientVersion {
constexpr uint16_t minor = 64; constexpr uint16_t minor = 64;
} }
#endif // !CLIENTVERSION_H #endif // !__CLIENTVERSION_H__

View File

@@ -1,7 +1,6 @@
#include "dConfig.h" #include "dConfig.h"
#include <sstream> #include <sstream>
#include <algorithm>
#include "BinaryPathFinder.h" #include "BinaryPathFinder.h"
#include "GeneralUtils.h" #include "GeneralUtils.h"

View File

@@ -1,5 +1,5 @@
#ifndef STRINGIFIEDENUM_H #ifndef __STRINGIFIEDENUM_H__
#define STRINGIFIEDENUM_H #define __STRINGIFIEDENUM_H__
#include <string> #include <string>
#include "magic_enum.hpp" #include "magic_enum.hpp"
@@ -26,4 +26,4 @@ namespace StringifiedEnum {
} }
} }
#endif // !STRINGIFIEDENUM_H #endif // !__STRINGIFIEDENUM_H__

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#ifndef DCOMMONVARS_H #ifndef __DCOMMONVARS__H__
#define DCOMMONVARS_H #define __DCOMMONVARS__H__
#include <cstdint> #include <cstdint>
#include <string> #include <string>
@@ -158,4 +158,4 @@ public:
} }
}; };
#endif //!DCOMMONVARS_H #endif //!__DCOMMONVARS__H__

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#ifndef EADDFRIENDRESPONSECODE_H #ifndef __EADDFRIENDRESPONSECODE__H__
#define EADDFRIENDRESPONSECODE_H #define __EADDFRIENDRESPONSECODE__H__
#include <cstdint> #include <cstdint>
@@ -12,4 +12,4 @@ enum class eAddFriendResponseCode : uint8_t {
CANCELLED CANCELLED
}; };
#endif //!ADDFRIENDRESPONSECODE_H #endif //!__ADDFRIENDRESPONSECODE__H__

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#ifndef EADDFRIENDRESPONSETYPE_H #ifndef __EADDFRIENDRESPONSETYPE__H__
#define EADDFRIENDRESPONSETYPE_H #define __EADDFRIENDRESPONSETYPE__H__
#include <cstdint> #include <cstdint>
@@ -21,4 +21,4 @@ enum class eAddFriendResponseType : uint8_t {
FRIENDISFREETRIAL FRIENDISFREETRIAL
}; };
#endif //!EADDFRIENDRESPONSETYPE_H #endif //!__EADDFRIENDRESPONSETYPE__H__

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#ifndef EANINMATIONFLAGS_H #ifndef __EANINMATIONFLAGS__H__
#define EANINMATIONFLAGS_H #define __EANINMATIONFLAGS__H__
#include <cstdint> #include <cstdint>
@@ -41,4 +41,4 @@ enum class eAnimationFlags : uint32_t {
IDLE_MISC12 IDLE_MISC12
}; };
#endif //!EANINMATIONFLAGS_H #endif //!__EANINMATIONFLAGS__H__

View File

@@ -1,5 +1,5 @@
#ifndef EAUTHMESSAGETYPE_H #ifndef __EAUTHMESSAGETYPE__H__
#define EAUTHMESSAGETYPE_H #define __EAUTHMESSAGETYPE__H__
#include <cstdint> #include <cstdint>
@@ -12,4 +12,4 @@ enum class eAuthMessageType : uint32_t {
RUNTIME_CONFIG RUNTIME_CONFIG
}; };
#endif //!EAUTHMESSAGETYPE_H #endif //!__EAUTHMESSAGETYPE__H__

View File

@@ -1,5 +1,5 @@
#ifndef EBASICATTACKSUCCESSTYPES_H #ifndef __EBASICATTACKSUCCESSTYPES__H__
#define EBASICATTACKSUCCESSTYPES_H #define __EBASICATTACKSUCCESSTYPES__H__
#include <cstdint> #include <cstdint>
@@ -9,4 +9,4 @@ enum class eBasicAttackSuccessTypes : uint8_t {
FAILIMMUNE FAILIMMUNE
}; };
#endif //!EBASICATTACKSUCCESSTYPES_H #endif //!__EBASICATTACKSUCCESSTYPES__H__

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#ifndef EBLUEPRINTSAVERESPONSETYPE_H #ifndef __EBLUEPRINTSAVERESPONSETYPE__H__
#define EBLUEPRINTSAVERESPONSETYPE_H #define __EBLUEPRINTSAVERESPONSETYPE__H__
#include <cstdint> #include <cstdint>
@@ -23,4 +23,4 @@ enum class eBlueprintSaveResponseType : uint32_t {
FindMatchesFailed FindMatchesFailed
}; };
#endif //!EBLUEPRINTSAVERESPONSETYPE_H #endif //!__EBLUEPRINTSAVERESPONSETYPE__H__

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#ifndef EBUBBLETYPE_H #ifndef __EBUBBLETYPE__H__
#define EBUBBLETYPE_H #define __EBUBBLETYPE__H__
#include <cstdint> #include <cstdint>
@@ -11,4 +11,4 @@ enum class eBubbleType : uint32_t {
SKUNK SKUNK
}; };
#endif //!EBUBBLETYPE_H #endif //!__EBUBBLETYPE__H__

View File

@@ -1,5 +1,5 @@
#ifndef EBUILDTYPE_H #ifndef __EBUILDTYPE__H__
#define EBUILDTYPE_H #define __EBUILDTYPE__H__
#include <cstdint> #include <cstdint>
@@ -9,4 +9,4 @@ enum class eBuildType :uint32_t {
ON_PROPERTY ON_PROPERTY
}; };
#endif //!EBUILDTYPE_H #endif //!__EBUILDTYPE__H__

View File

@@ -1,5 +1,5 @@
#ifndef ECHARACTERCREATIONRESPONSE_H #ifndef __ECHARACTERCREATIONRESPONSE__H__
#define ECHARACTERCREATIONRESPONSE_H #define __ECHARACTERCREATIONRESPONSE__H__
#include <cstdint> #include <cstdint>
@@ -11,4 +11,4 @@ enum class eCharacterCreationResponse : uint8_t {
CUSTOM_NAME_IN_USE CUSTOM_NAME_IN_USE
}; };
#endif //!ECHARACTERCREATIONRESPONSE_H #endif //!__ECHARACTERCREATIONRESPONSE__H__

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#ifndef ECHARACTERVERSION_H #ifndef __ECHARACTERVERSION__H__
#define ECHARACTERVERSION_H #define __ECHARACTERVERSION__H__
#include <cstdint> #include <cstdint>
@@ -18,4 +18,4 @@ enum class eCharacterVersion : uint32_t {
UP_TO_DATE, // will become SPEED_BASE UP_TO_DATE, // will become SPEED_BASE
}; };
#endif //!ECHARACTERVERSION_H #endif //!__ECHARACTERVERSION__H__

View File

@@ -0,0 +1,31 @@
#ifndef __ECHATINTERNALMESSAGETYPE__H__
#define __ECHATINTERNALMESSAGETYPE__H__
#include <cstdint>
enum eChatInternalMessageType : uint32_t {
PLAYER_ADDED_NOTIFICATION = 0,
PLAYER_REMOVED_NOTIFICATION,
ADD_FRIEND,
ADD_BEST_FRIEND,
ADD_TO_TEAM,
ADD_BLOCK,
REMOVE_FRIEND,
REMOVE_BLOCK,
REMOVE_FROM_TEAM,
DELETE_TEAM,
REPORT,
PRIVATE_CHAT,
PRIVATE_CHAT_RESPONSE,
ANNOUNCEMENT,
MAIL_COUNT_UPDATE,
MAIL_SEND_NOTIFY,
REQUEST_USER_LIST,
FRIEND_LIST,
ROUTE_TO_PLAYER,
TEAM_UPDATE,
MUTE_UPDATE,
CREATE_TEAM,
};
#endif //!__ECHATINTERNALMESSAGETYPE__H__

View File

@@ -1,5 +1,5 @@
#ifndef ECHATMESSAGETYPE_H #ifndef __ECHATMESSAGETYPE__H__
#define ECHATMESSAGETYPE_H #define __ECHATMESSAGETYPE__H__
#include <cstdint> #include <cstdint>
@@ -72,9 +72,7 @@ enum class eChatMessageType :uint32_t {
UPDATE_DONATION, UPDATE_DONATION,
PRG_CSR_COMMAND, PRG_CSR_COMMAND,
HEARTBEAT_REQUEST_FROM_WORLD, HEARTBEAT_REQUEST_FROM_WORLD,
UPDATE_FREE_TRIAL_STATUS, UPDATE_FREE_TRIAL_STATUS
// CUSTOM DLU MESSAGE ID FOR INTERNAL USE
CREATE_TEAM,
}; };
#endif //!ECHATMESSAGETYPE_H #endif //!__ECHATMESSAGETYPE__H__

View File

@@ -1,5 +1,5 @@
#ifndef ECINEMATICEVENT_H #ifndef __ECINEMATICEVENT__H__
#define ECINEMATICEVENT_H #define __ECINEMATICEVENT__H__
#include <cstdint> #include <cstdint>
@@ -9,4 +9,4 @@ enum class eCinematicEvent : uint32_t {
ENDED, ENDED,
}; };
#endif //!ECINEMATICEVENT_H #endif //!__ECINEMATICEVENT__H__

View File

@@ -1,5 +1,5 @@
#ifndef ECLIENTMESSAGETYPE_H #ifndef __ECLIENTMESSAGETYPE__H__
#define ECLIENTMESSAGETYPE_H #define __ECLIENTMESSAGETYPE__H__
#include <cstdint> #include <cstdint>
@@ -73,4 +73,4 @@ enum class eClientMessageType : uint32_t {
UGC_DOWNLOAD_FAILED = 120 UGC_DOWNLOAD_FAILED = 120
}; };
#endif //!ECLIENTMESSAGETYPE_H #endif //!__ECLIENTMESSAGETYPE__H__

View File

@@ -1,13 +1,14 @@
#ifndef ECONNECTIONTYPE_H #ifndef __ECONNECTIONTYPE__H__
#define ECONNECTIONTYPE_H #define __ECONNECTIONTYPE__H__
enum class eConnectionType : uint16_t { enum class eConnectionType : uint16_t {
SERVER = 0, SERVER = 0,
AUTH, AUTH,
CHAT, CHAT,
WORLD = 4, CHAT_INTERNAL,
WORLD,
CLIENT, CLIENT,
MASTER MASTER
}; };
#endif //!ECONNECTIONTYPE_H #endif //!__ECONNECTIONTYPE__H__

View File

@@ -1,5 +1,5 @@
#ifndef ECONTROLSCHEME_H #ifndef __ECONTROLSCHEME__H__
#define ECONTROLSCHEME_H #define __ECONTROLSCHEME__H__
#include <cstdint> #include <cstdint>
@@ -15,4 +15,4 @@ enum class eControlScheme : uint32_t {
SCHEME_WEAR_A_ROBOT //== freecam? SCHEME_WEAR_A_ROBOT //== freecam?
}; };
#endif //!ECONTROLSCHEME_H #endif //!__ECONTROLSCHEME__H__

View File

@@ -1,5 +1,5 @@
#ifndef ECYCLINGMODE_H #ifndef __ECYCLINGMODE__H__
#define ECYCLINGMODE_H #define __ECYCLINGMODE__H__
#include <cstdint> #include <cstdint>
@@ -8,4 +8,4 @@ enum class eCyclingMode : uint32_t {
DISALLOW_CYCLING DISALLOW_CYCLING
}; };
#endif //!ECYCLINGMODE_H #endif //!__ECYCLINGMODE__H__

View File

@@ -1,5 +1,5 @@
#ifndef EENDBEHAVIOR_H #ifndef __EENDBEHAVIOR__H__
#define EENDBEHAVIOR_H #define __EENDBEHAVIOR__H__
#include <cstdint> #include <cstdint>
@@ -8,4 +8,4 @@ enum class eEndBehavior : uint32_t {
WAIT WAIT
}; };
#endif //!EENDBEHAVIOR_H #endif //!__EENDBEHAVIOR__H__

View File

@@ -1,5 +1,5 @@
#ifndef EGAMEACTIVITY_H #ifndef __EGAMEACTIVITY__H__
#define EGAMEACTIVITY_H #define __EGAMEACTIVITY__H__
#include <cstdint> #include <cstdint>
@@ -12,4 +12,4 @@ enum class eGameActivity : uint32_t {
PET_TAMING PET_TAMING
}; };
#endif //!EGAMEACTIVITY_H #endif //!__EGAMEACTIVITY__H__

View File

@@ -1,5 +1,5 @@
#ifndef EGAMEMASTERLEVEL_H #ifndef __EGAMEMASTERLEVEL__H__
#define EGAMEMASTERLEVEL_H #define __EGAMEMASTERLEVEL__H__
#include <cstdint> #include <cstdint>
@@ -17,4 +17,4 @@ enum class eGameMasterLevel : uint8_t {
}; };
#endif //!EGAMEMASTERLEVEL_H #endif //!__EGAMEMASTERLEVEL__H__

View File

@@ -1,5 +1,5 @@
#ifndef EGAMEMESSAGETYPE_H #ifndef __EGAMEMESSAGETYPE__H__
#define EGAMEMESSAGETYPE_H #define __EGAMEMESSAGETYPE__H__
#include <cstdint> #include <cstdint>
@@ -790,10 +790,9 @@ enum class eGameMessageType : uint16_t {
GET_MISSION_TYPE_STATES = 853, GET_MISSION_TYPE_STATES = 853,
GET_TIME_PLAYED = 854, GET_TIME_PLAYED = 854,
SET_MISSION_VIEWED = 855, SET_MISSION_VIEWED = 855,
HKX_VEHICLE_LOADED = 856, SLASH_COMMAND_TEXT_FEEDBACK = 856,
SLASH_COMMAND_TEXT_FEEDBACK = 857, HANDLE_SLASH_COMMAND_KORE_DEBUGGER = 857,
BROADCAST_TEXT_TO_CHATBOX = 858, BROADCAST_TEXT_TO_CHATBOX = 858,
HANDLE_SLASH_COMMAND_KORE_DEBUGGER = 859,
OPEN_PROPERTY_MANAGEMENT = 860, OPEN_PROPERTY_MANAGEMENT = 860,
OPEN_PROPERTY_VENDOR = 861, OPEN_PROPERTY_VENDOR = 861,
VOTE_ON_PROPERTY = 862, VOTE_ON_PROPERTY = 862,
@@ -1611,4 +1610,4 @@ struct magic_enum::customize::enum_range<eGameMessageType> {
static constexpr int max = 1772; static constexpr int max = 1772;
}; };
#endif //!EGAMEMESSAGETYPE_H #endif //!__EGAMEMESSAGETYPE__H__

View File

@@ -1,6 +1,6 @@
#ifndef EHELPTYPE_H #ifndef __EHELPTYPE__H__
#define EHELPTYPE_H #define __EHELPTYPE__H__
#include <cstdint> #include <cstdint>
@@ -38,4 +38,4 @@ enum class eHelpType : int32_t {
UI_INVENTORY_FULL_CANNOT_PICKUP_ITEM = 86 UI_INVENTORY_FULL_CANNOT_PICKUP_ITEM = 86
}; };
#endif //!EHELPTYPE_H #endif //!__EHELPTYPE__H__

View File

@@ -1,12 +1,9 @@
#pragma once #pragma once
#ifndef EINVENTORYTYPE_H #ifndef __EINVENTORYTYPE__H__
#define EINVENTORYTYPE_H #define __EINVENTORYTYPE__H__
#include <cstdint> #include <cstdint>
#include "magic_enum.hpp"
static const uint8_t NUMBER_OF_INVENTORIES = 17; static const uint8_t NUMBER_OF_INVENTORIES = 17;
/** /**
* Represents the different types of inventories an entity may have * Represents the different types of inventories an entity may have
@@ -59,10 +56,4 @@ public:
}; };
}; };
template <> #endif //!__EINVENTORYTYPE__H__
struct magic_enum::customize::enum_range<eInventoryType> {
static constexpr int min = 0;
static constexpr int max = 16;
};
#endif //!EINVENTORYTYPE_H

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#ifndef EITEMSETPASSIVEABILITYID_H #ifndef __EITEMSETPASSIVEABILITYID__H__
#define EITEMSETPASSIVEABILITYID_H #define __EITEMSETPASSIVEABILITYID__H__
enum class eItemSetPassiveAbilityID { enum class eItemSetPassiveAbilityID {
EngineerRank1 = 2, EngineerRank1 = 2,
@@ -55,4 +55,4 @@ enum class eItemSetPassiveAbilityID {
LightningSpinjitzu = 52 LightningSpinjitzu = 52
}; };
#endif //!EITEMSETPASSIVEABILITYID_H #endif //!__EITEMSETPASSIVEABILITYID__H__

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#ifndef EITEMTYPE_H #ifndef __EITEMTYPE__H__
#define EITEMTYPE_H #define __EITEMTYPE__H__
#include <cstdint> #include <cstdint>
@@ -33,4 +33,4 @@ enum class eItemType : int32_t {
MOUNT MOUNT
}; };
#endif //!EITEMTYPE_H #endif //!__EITEMTYPE__H__

View File

@@ -1,5 +1,5 @@
#ifndef EKILLTYPE_H #ifndef __EKILLTYPE__H__
#define EKILLTYPE_H #define __EKILLTYPE__H__
#include <cstdint> #include <cstdint>
@@ -8,4 +8,4 @@ enum class eKillType : uint32_t {
SILENT SILENT
}; };
#endif //!EKILLTYPE_H #endif //!__EKILLTYPE__H__

View File

@@ -1,5 +1,5 @@
#ifndef ELOGINRESPONSE_H #ifndef __ELOGINRESPONSE__H__
#define ELOGINRESPONSE_H #define __ELOGINRESPONSE__H__
#include <cstdint> #include <cstdint>
@@ -21,4 +21,4 @@ enum class eLoginResponse : uint8_t {
ACCOUNT_NOT_ACTIVATED ACCOUNT_NOT_ACTIVATED
}; };
#endif //!ELOGINRESPONSE_H #endif //!__ELOGINRESPONSE__H__

View File

@@ -1,5 +1,5 @@
#ifndef ELOOTSOURCETYPE_H #ifndef __ELOOTSOURCETYPE__H__
#define ELOOTSOURCETYPE_H #define __ELOOTSOURCETYPE__H__
#include <cstdint> #include <cstdint>
@@ -28,4 +28,4 @@ enum class eLootSourceType : uint32_t {
RELOCATE RELOCATE
}; };
#endif //!ELOOTSOURCETYPE_H #endif //!__ELOOTSOURCETYPE__H__

View File

@@ -1,5 +1,5 @@
#ifndef EMASTERMESSAGETYPE_H #ifndef __EMASTERMESSAGETYPE__H__
#define EMASTERMESSAGETYPE_H #define __EMASTERMESSAGETYPE__H__
#include <cstdint> #include <cstdint>
@@ -33,4 +33,4 @@ enum class eMasterMessageType : uint32_t {
NEW_SESSION_ALERT NEW_SESSION_ALERT
}; };
#endif //!EMASTERMESSAGETYPE_H #endif //!__EMASTERMESSAGETYPE__H__

View File

@@ -1,5 +1,5 @@
#ifndef EMATCHUPDATE_H #ifndef __EMATCHUPDATE__H__
#define EMATCHUPDATE_H #define __EMATCHUPDATE__H__
#include <cstdint> #include <cstdint>
@@ -14,4 +14,4 @@ enum class eMatchUpdate : int32_t {
PLAYER_UPDATE PLAYER_UPDATE
}; };
#endif //!EMATCHUPDATE_H #endif //!__EMATCHUPDATE__H__

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#ifndef EMISSIONLOCKSTATE_H #ifndef __EMISSIONLOCKSTATE__H__
#define EMISSIONLOCKSTATE_H #define __EMISSIONLOCKSTATE__H__
enum class eMissionLockState : int { enum class eMissionLockState : int {
LOCKED, LOCKED,
@@ -9,4 +9,4 @@ enum class eMissionLockState : int {
UNLOCKED, UNLOCKED,
}; };
#endif //!EMISSIONLOCKSTATE_H #endif //!__EMISSIONLOCKSTATE__H__

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#ifndef MISSIONSTATE_H #ifndef __MISSIONSTATE__H__
#define MISSIONSTATE_H #define __MISSIONSTATE__H__
/** /**
* Represents the possible states a mission can be in * Represents the possible states a mission can be in
@@ -53,4 +53,4 @@ enum class eMissionState : int {
COMPLETE_READY_TO_COMPLETE = 12 COMPLETE_READY_TO_COMPLETE = 12
}; };
#endif //!MISSIONSTATE_H #endif //!__MISSIONSTATE__H__

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#ifndef EMISSIONTASKTYPE_H #ifndef __EMISSIONTASKTYPE__H__
#define EMISSIONTASKTYPE_H #define __EMISSIONTASKTYPE__H__
enum class eMissionTaskType : int { enum class eMissionTaskType : int {
UNKNOWN = -1, UNKNOWN = -1,
@@ -40,4 +40,4 @@ enum class eMissionTaskType : int {
DONATION DONATION
}; };
#endif //!EMISSIONTASKTYPE_H #endif //!__EMISSIONTASKTYPE__H__

View File

@@ -1,5 +1,5 @@
#ifndef EMOVEMENTPLATFORMSTATE_H #ifndef __EMOVEMENTPLATFORMSTATE__H__
#define EMOVEMENTPLATFORMSTATE_H #define __EMOVEMENTPLATFORMSTATE__H__
#include <cstdint> #include <cstdint>
@@ -13,4 +13,4 @@ enum class eMovementPlatformState : uint32_t
Stopped = 0b01100 Stopped = 0b01100
}; };
#endif //!EMOVEMENTPLATFORMSTATE_H #endif //!__EMOVEMENTPLATFORMSTATE__H__

View File

@@ -1,5 +1,5 @@
#ifndef EOBJECTBITS_H #ifndef __EOBJECTBITS__H__
#define EOBJECTBITS_H #define __EOBJECTBITS__H__
#include <cstdint> #include <cstdint>
@@ -10,4 +10,4 @@ enum class eObjectBits : size_t {
CHARACTER = 60 CHARACTER = 60
}; };
#endif //!EOBJECTBITS_H #endif //!__EOBJECTBITS__H__

View File

@@ -1,5 +1,5 @@
#ifndef EOBJECTWORLDSTATE_H #ifndef __EOBJECTWORLDSTATE__H__
#define EOBJECTWORLDSTATE_H #define __EOBJECTWORLDSTATE__H__
#include <cstdint> #include <cstdint>
@@ -9,4 +9,4 @@ enum class eObjectWorldState : uint32_t {
INVENTORY INVENTORY
}; };
#endif //!EOBJECTWORLDSTATE_H #endif //!__EOBJECTWORLDSTATE__H__

View File

@@ -1,5 +1,5 @@
#ifndef EPACKAGETYPE_H #ifndef __EPACKAGETYPE__H__
#define EPACKAGETYPE_H #define __EPACKAGETYPE__H__
enum class ePackageType { enum class ePackageType {
INVALID = -1, INVALID = -1,
@@ -10,4 +10,4 @@ enum class ePackageType {
}; };
#endif //!EPACKAGETYPE_H #endif //!__EPACKAGETYPE__H__

View File

@@ -2,8 +2,8 @@
#include <cstdint> #include <cstdint>
#ifndef EPERMISSIONMAP_H #ifndef __EPERMISSIONMAP__H__
#define EPERMISSIONMAP_H #define __EPERMISSIONMAP__H__
/** /**
* Bitmap of permissions and restrictions for characters. * Bitmap of permissions and restrictions for characters.
@@ -29,4 +29,4 @@ enum class ePermissionMap : uint64_t {
RestrictedChatAccess = 0x1 << 6, RestrictedChatAccess = 0x1 << 6,
}; };
#endif //!EPERMISSIONMAP_H #endif //!__EPERMISSIONMAP__H__

View File

@@ -1,5 +1,5 @@
#ifndef EPETABILITYTYPE_H #ifndef __EPETABILITYTYPE__H__
#define EPETABILITYTYPE_H #define __EPETABILITYTYPE__H__
#include <cstdint> #include <cstdint>
@@ -10,4 +10,4 @@ enum class ePetAbilityType : uint32_t {
DigAtPosition DigAtPosition
}; };
#endif //!EPETABILITYTYPE_H #endif //!__EPETABILITYTYPE__H__

View File

@@ -1,5 +1,5 @@
#ifndef EPETTAMINGNOTIFYTYPE_H #ifndef __EPETTAMINGNOTIFYTYPE__H__
#define EPETTAMINGNOTIFYTYPE_H #define __EPETTAMINGNOTIFYTYPE__H__
#include <cstdint> #include <cstdint>
@@ -12,4 +12,4 @@ enum class ePetTamingNotifyType : uint32_t {
NAMINGPET NAMINGPET
}; };
#endif //!EPETTAMINGNOTIFYTYPE_H #endif //!__EPETTAMINGNOTIFYTYPE__H__

View File

@@ -1,5 +1,5 @@
#ifndef EPHYSICSEFFECTTYPE_H #ifndef __EPHYSICSEFFECTTYPE__H__
#define EPHYSICSEFFECTTYPE_H #define __EPHYSICSEFFECTTYPE__H__
#include <cstdint> #include <cstdint>
@@ -12,4 +12,4 @@ enum class ePhysicsEffectType : uint32_t {
FRICTION FRICTION
}; };
#endif //!EPHYSICSEFFECTTYPE_H #endif //!__EPHYSICSEFFECTTYPE__H__

View File

@@ -1,5 +1,5 @@
#ifndef EPLAYERFLAG_H #ifndef __EPLAYERFLAG__H__
#define EPLAYERFLAG_H #define __EPLAYERFLAG__H__
#include <cstdint> #include <cstdint>
@@ -170,4 +170,4 @@ enum ePlayerFlag : int32_t {
DLU_SKIP_CINEMATICS = 1'000'000, DLU_SKIP_CINEMATICS = 1'000'000,
}; };
#endif //!EPLAYERFLAG_H #endif //!__EPLAYERFLAG__H__

View File

@@ -1,5 +1,5 @@
#ifndef EQUICKBUILDFAILREASON_H #ifndef __EQUICKBUILDFAILREASON__H__
#define EQUICKBUILDFAILREASON_H #define __EQUICKBUILDFAILREASON__H__
#include <cstdint> #include <cstdint>
@@ -10,4 +10,4 @@ enum class eQuickBuildFailReason : uint32_t {
BUILD_ENDED BUILD_ENDED
}; };
#endif //!EQUICKBUILDFAILREASON_H #endif //!__EQUICKBUILDFAILREASON__H__

View File

@@ -1,5 +1,5 @@
#ifndef EQUICKBUILDSTATE_H #ifndef __EQUICKBUILDSTATE__H__
#define EQUICKBUILDSTATE_H #define __EQUICKBUILDSTATE__H__
#include <cstdint> #include <cstdint>
@@ -12,4 +12,4 @@ enum class eQuickBuildState : uint32_t {
}; };
#endif //!EQUICKBUILDSTATE_H #endif //!__EQUICKBUILDSTATE__H__

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#ifndef ERACINGTASKPARAM_H #ifndef __ERACINGTASKPARAM__H__
#define ERACINGTASKPARAM_H #define __ERACINGTASKPARAM__H__
#include <cstdint> #include <cstdint>
@@ -22,4 +22,4 @@ enum class eRacingTaskParam : int32_t {
SMASH_SPECIFIC_SMASHABLE SMASH_SPECIFIC_SMASHABLE
}; };
#endif //!ERACINGTASKPARAM_H #endif //!__ERACINGTASKPARAM__H__

View File

@@ -1,5 +1,5 @@
#ifndef ERENAMERESPONSE_H #ifndef __ERENAMERESPONSE__H__
#define ERENAMERESPONSE_H #define __ERENAMERESPONSE__H__
#include <cstdint> #include <cstdint>
@@ -12,4 +12,4 @@ enum class eRenameResponse : uint8_t {
}; };
#endif //!ERENAMERESPONSE_H #endif //!__ERENAMERESPONSE__H__

View File

@@ -1,5 +1,5 @@
#ifndef EREPLICACOMPONENTTYPE_H #ifndef __EREPLICACOMPONENTTYPE__H__
#define EREPLICACOMPONENTTYPE_H #define __EREPLICACOMPONENTTYPE__H__
#include <cstdint> #include <cstdint>
@@ -124,4 +124,4 @@ enum class eReplicaComponentType : uint32_t {
DESTROYABLE = 1000 // Actually 7 DESTROYABLE = 1000 // Actually 7
}; };
#endif //!EREPLICACOMPONENTTYPE_H #endif //!__EREPLICACOMPONENTTYPE__H__

View File

@@ -1,5 +1,5 @@
#ifndef EREPLICAPACKETTYPE_H #ifndef __EREPLICAPACKETTYPE__H__
#define EREPLICAPACKETTYPE_H #define __EREPLICAPACKETTYPE__H__
#include <cstdint> #include <cstdint>
@@ -9,4 +9,4 @@ enum class eReplicaPacketType : uint8_t {
DESTRUCTION DESTRUCTION
}; };
#endif //!EREPLICAPACKETTYPE_H #endif //!__EREPLICAPACKETTYPE__H__

View File

@@ -1,21 +0,0 @@
#ifndef EREPONSEMOVEITEMBETWEENINVENTORYTYPECODE_H
#define EREPONSEMOVEITEMBETWEENINVENTORYTYPECODE_H
#include <cstdint>
enum class eReponseMoveItemBetweenInventoryTypeCode : int32_t {
SUCCESS,
FAIL_GENERIC,
FAIL_INV_FULL,
FAIL_ITEM_NOT_FOUND,
FAIL_CANT_MOVE_TO_THAT_INV_TYPE,
FAIL_NOT_NEAR_BANK,
FAIL_CANT_SWAP_ITEMS,
FAIL_SOURCE_TYPE,
FAIL_WRONG_DEST_TYPE,
FAIL_SWAP_DEST_TYPE,
FAIL_CANT_MOVE_THINKING_HAT,
FAIL_DISMOUNT_BEFORE_MOVING
};
#endif //!EREPONSEMOVEITEMBETWEENINVENTORYTYPECODE_H

View File

@@ -1,5 +1,5 @@
#ifndef ESERVERDISCONNECTIDENTIFIERS_H #ifndef __ESERVERDISCONNECTIDENTIFIERS__H__
#define ESERVERDISCONNECTIDENTIFIERS_H #define __ESERVERDISCONNECTIDENTIFIERS__H__
#include <cstdint> #include <cstdint>
@@ -21,4 +21,4 @@ enum class eServerDisconnectIdentifiers : uint32_t {
PLAY_SCHEDULE_TIME_DONE PLAY_SCHEDULE_TIME_DONE
}; };
#endif //!ESERVERDISCONNECTIDENTIFIERS_H #endif //!__ESERVERDISCONNECTIDENTIFIERS__H__

View File

@@ -1,5 +1,5 @@
#ifndef ESERVERMESSAGETYPE_H #ifndef __ESERVERMESSAGETYPE__H__
#define ESERVERMESSAGETYPE_H #define __ESERVERMESSAGETYPE__H__
#include <cstdint> #include <cstdint>
//! The Internal Server Packet Identifiers //! The Internal Server Packet Identifiers
@@ -9,4 +9,4 @@ enum class eServerMessageType : uint32_t {
GENERAL_NOTIFY GENERAL_NOTIFY
}; };
#endif //!ESERVERMESSAGETYPE_H #endif //!__ESERVERMESSAGETYPE__H__

View File

@@ -1,5 +1,5 @@
#ifndef ESQLITEDATATYPE_H #ifndef __ESQLITEDATATYPE__H__
#define ESQLITEDATATYPE_H #define __ESQLITEDATATYPE__H__
#include <cstdint> #include <cstdint>
@@ -13,4 +13,4 @@ enum class eSqliteDataType : int32_t {
TEXT_8 = 8 TEXT_8 = 8
}; };
#endif //!ESQLITEDATATYPE_H #endif //!__ESQLITEDATATYPE__H__

View File

@@ -1,5 +1,5 @@
#ifndef ESTATECHANGETYPE_H #ifndef __ESTATECHANGETYPE__H__
#define ESTATECHANGETYPE_H #define __ESTATECHANGETYPE__H__
#include <cstdint> #include <cstdint>
@@ -8,4 +8,4 @@ enum class eStateChangeType : uint32_t {
POP POP
}; };
#endif //!ESTATECHANGETYPE_H #endif //!__ESTATECHANGETYPE__H__

View File

@@ -1,5 +1,5 @@
#ifndef ETERMINATETYPE_H #ifndef __ETERMINATETYPE__H__
#define ETERMINATETYPE_H #define __ETERMINATETYPE__H__
#include <cstdint> #include <cstdint>
@@ -9,4 +9,4 @@ enum class eTerminateType : uint32_t {
FROM_INTERACTION FROM_INTERACTION
}; };
#endif //!ETERMINATETYPE_H #endif //!__ETERMINATETYPE__H__

View File

@@ -1,5 +1,5 @@
#ifndef ETRIGGERCOMMANDTYPE_H #ifndef __ETRIGGERCOMMANDTYPE__H__
#define ETRIGGERCOMMANDTYPE_H #define __ETRIGGERCOMMANDTYPE__H__
// For info about Trigger Command see: // For info about Trigger Command see:
// https://docs.lu-dev.net/en/latest/file-structures/lutriggers.html?highlight=trigger#possible-values-commands // https://docs.lu-dev.net/en/latest/file-structures/lutriggers.html?highlight=trigger#possible-values-commands
@@ -116,4 +116,4 @@ public:
}; };
}; };
#endif //!ETRIGGERCOMMANDTYPE_H #endif //!__ETRIGGERCOMMANDTYPE__H__

View File

@@ -1,5 +1,5 @@
#ifndef ETRIGGEREVENTTYPE_H #ifndef __ETRIGGEREVENTTYPE__H__
#define ETRIGGEREVENTTYPE_H #define __ETRIGGEREVENTTYPE__H__
enum class eTriggerEventType { enum class eTriggerEventType {
INVALID, INVALID,
@@ -50,4 +50,4 @@ public:
}; };
}; };
#endif //!ETRIGGEREVENTTYPE_H #endif //!__ETRIGGEREVENTTYPE__H__

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#ifndef EUNEQUIPPABLEACTIVETYPE_H #ifndef __EUNEQUIPPABLEACTIVETYPE__H__
#define EUNEQUIPPABLEACTIVETYPE_H #define __EUNEQUIPPABLEACTIVETYPE__H__
#include <cstdint> #include <cstdint>
@@ -11,4 +11,4 @@ enum class eUnequippableActiveType : int32_t {
MOUNT MOUNT
}; };
#endif //!EUNEQUIPPABLEACTIVETYPE_H #endif //!__EUNEQUIPPABLEACTIVETYPE__H__

View File

@@ -1,5 +1,5 @@
#ifndef EUSEITEMRESPONSE_H #ifndef __EUSEITEMRESPONSE__H__
#define EUSEITEMRESPONSE_H #define __EUSEITEMRESPONSE__H__
#include <cstdint> #include <cstdint>
@@ -9,4 +9,4 @@ enum class eUseItemResponse : uint32_t {
MountsNotAllowed MountsNotAllowed
}; };
#endif //!EUSEITEMRESPONSE_H #endif //!__EUSEITEMRESPONSE__H__

View File

@@ -1,5 +1,5 @@
#ifndef EVENDORTRANSACTIONRESULT_H #ifndef __EVENDORTRANSACTIONRESULT__
#define EVENDORTRANSACTIONRESULT_H #define __EVENDORTRANSACTIONRESULT__
#include <cstdint> #include <cstdint>
@@ -12,4 +12,4 @@ enum class eVendorTransactionResult : uint32_t {
DONATION_FULL DONATION_FULL
}; };
#endif // !EVENDORTRANSACTIONRESULT_H #endif // !__EVENDORTRANSACTIONRESULT__

View File

@@ -1,59 +0,0 @@
#ifndef EWAYPOINTCOMMANDTYPES_H
#define EWAYPOINTCOMMANDTYPES_H
#include <cstdint>
enum class eWaypointCommandType : uint32_t {
INVALID,
BOUNCE,
STOP,
GROUP_EMOTE,
SET_VARIABLE,
CAST_SKILL,
EQUIP_INVENTORY,
UNEQUIP_INVENTORY,
DELAY,
EMOTE,
TELEPORT,
PATH_SPEED,
REMOVE_NPC,
CHANGE_WAYPOINT,
DELETE_SELF,
KILL_SELF,
SPAWN_OBJECT,
PLAY_SOUND,
};
class WaypointCommandType {
public:
static eWaypointCommandType StringToWaypointCommandType(std::string commandString) {
const std::map<std::string, eWaypointCommandType> WaypointCommandTypeMap = {
{"bounce", eWaypointCommandType::BOUNCE},
{"stop", eWaypointCommandType::STOP},
{"groupemote", eWaypointCommandType::GROUP_EMOTE},
{"setvar", eWaypointCommandType::SET_VARIABLE},
{"castskill", eWaypointCommandType::CAST_SKILL},
{"eqInvent", eWaypointCommandType::EQUIP_INVENTORY},
{"unInvent", eWaypointCommandType::UNEQUIP_INVENTORY},
{"delay", eWaypointCommandType::DELAY},
{"femote", eWaypointCommandType::EMOTE},
{"emote", eWaypointCommandType::EMOTE},
{"teleport", eWaypointCommandType::TELEPORT},
{"pathspeed", eWaypointCommandType::PATH_SPEED},
{"removeNPC", eWaypointCommandType::REMOVE_NPC},
{"changeWP", eWaypointCommandType::CHANGE_WAYPOINT},
{"DeleteSelf", eWaypointCommandType::DELETE_SELF},
{"killself", eWaypointCommandType::KILL_SELF},
{"removeself", eWaypointCommandType::DELETE_SELF},
{"spawnOBJ", eWaypointCommandType::SPAWN_OBJECT},
{"playSound", eWaypointCommandType::PLAY_SOUND},
};
auto intermed = WaypointCommandTypeMap.find(commandString);
return (intermed != WaypointCommandTypeMap.end()) ? intermed->second : eWaypointCommandType::INVALID;
};
};
#endif //!EWAYPOINTCOMMANDTYPES_H

View File

@@ -1,5 +1,5 @@
#ifndef EWORLDMESSAGETYPE_H #ifndef __EWORLDMESSAGETYPE__H__
#define EWORLDMESSAGETYPE_H #define __EWORLDMESSAGETYPE__H__
#include <cstdint> #include <cstdint>
@@ -29,8 +29,8 @@ enum class eWorldMessageType : uint32_t {
ROUTE_PACKET, // Social? ROUTE_PACKET, // Social?
POSITION_UPDATE, POSITION_UPDATE,
MAIL, MAIL,
WORD_CHECK, // AllowList word check WORD_CHECK, // Whitelist word check
STRING_CHECK, // AllowList string check STRING_CHECK, // Whitelist string check
GET_PLAYERS_IN_ZONE, GET_PLAYERS_IN_ZONE,
REQUEST_UGC_MANIFEST_INFO, REQUEST_UGC_MANIFEST_INFO,
BLUEPRINT_GET_ALL_DATA_REQUEST, BLUEPRINT_GET_ALL_DATA_REQUEST,
@@ -48,4 +48,4 @@ struct magic_enum::customize::enum_range<eWorldMessageType> {
static constexpr int max = 91; static constexpr int max = 91;
}; };
#endif //!EWORLDMESSAGETYPE_H #endif //!__EWORLDMESSAGETYPE__H__

View File

@@ -25,7 +25,6 @@
#include "CDScriptComponentTable.h" #include "CDScriptComponentTable.h"
#include "CDSkillBehaviorTable.h" #include "CDSkillBehaviorTable.h"
#include "CDZoneTableTable.h" #include "CDZoneTableTable.h"
#include "CDTamingBuildPuzzleTable.h"
#include "CDVendorComponentTable.h" #include "CDVendorComponentTable.h"
#include "CDActivitiesTable.h" #include "CDActivitiesTable.h"
#include "CDPackageComponentTable.h" #include "CDPackageComponentTable.h"
@@ -42,6 +41,8 @@
#include "CDRewardCodesTable.h" #include "CDRewardCodesTable.h"
#include "CDPetComponentTable.h" #include "CDPetComponentTable.h"
#include <exception>
#ifndef CDCLIENT_CACHE_ALL #ifndef CDCLIENT_CACHE_ALL
// Uncomment this to cache the full cdclient database into memory. This will make the server load faster, but will use more memory. // Uncomment this to cache the full cdclient database into memory. This will make the server load faster, but will use more memory.
// A vanilla CDClient takes about 46MB of memory + the regular world data. // A vanilla CDClient takes about 46MB of memory + the regular world data.
@@ -54,6 +55,13 @@
#define CDCLIENT_DONT_CACHE_TABLE(x) #define CDCLIENT_DONT_CACHE_TABLE(x)
#endif #endif
class CDClientConnectionException : public std::exception {
public:
virtual const char* what() const throw() {
return "CDClientDatabase is not connected!";
}
};
// Using a macro to reduce repetitive code and issues from copy and paste. // Using a macro to reduce repetitive code and issues from copy and paste.
// As a note, ## in a macro is used to concatenate two tokens together. // As a note, ## in a macro is used to concatenate two tokens together.
@@ -100,14 +108,11 @@ DEFINE_TABLE_STORAGE(CDRewardCodesTable);
DEFINE_TABLE_STORAGE(CDRewardsTable); DEFINE_TABLE_STORAGE(CDRewardsTable);
DEFINE_TABLE_STORAGE(CDScriptComponentTable); DEFINE_TABLE_STORAGE(CDScriptComponentTable);
DEFINE_TABLE_STORAGE(CDSkillBehaviorTable); DEFINE_TABLE_STORAGE(CDSkillBehaviorTable);
DEFINE_TABLE_STORAGE(CDTamingBuildPuzzleTable);
DEFINE_TABLE_STORAGE(CDVendorComponentTable); DEFINE_TABLE_STORAGE(CDVendorComponentTable);
DEFINE_TABLE_STORAGE(CDZoneTableTable); DEFINE_TABLE_STORAGE(CDZoneTableTable);
void CDClientManager::LoadValuesFromDatabase() { void CDClientManager::LoadValuesFromDatabase() {
if (!CDClientDatabase::isConnected) { if (!CDClientDatabase::isConnected) throw CDClientConnectionException();
throw std::runtime_error{ "CDClientDatabase is not connected!" };
}
CDActivityRewardsTable::Instance().LoadValuesFromDatabase(); CDActivityRewardsTable::Instance().LoadValuesFromDatabase();
CDActivitiesTable::Instance().LoadValuesFromDatabase(); CDActivitiesTable::Instance().LoadValuesFromDatabase();
@@ -147,7 +152,6 @@ void CDClientManager::LoadValuesFromDatabase() {
CDRewardsTable::Instance().LoadValuesFromDatabase(); CDRewardsTable::Instance().LoadValuesFromDatabase();
CDScriptComponentTable::Instance().LoadValuesFromDatabase(); CDScriptComponentTable::Instance().LoadValuesFromDatabase();
CDSkillBehaviorTable::Instance().LoadValuesFromDatabase(); CDSkillBehaviorTable::Instance().LoadValuesFromDatabase();
CDTamingBuildPuzzleTable::Instance().LoadValuesFromDatabase();
CDVendorComponentTable::Instance().LoadValuesFromDatabase(); CDVendorComponentTable::Instance().LoadValuesFromDatabase();
CDZoneTableTable::Instance().LoadValuesFromDatabase(); CDZoneTableTable::Instance().LoadValuesFromDatabase();
} }

View File

@@ -1,5 +1,5 @@
#ifndef CDCLIENTMANAGER_H #ifndef __CDCLIENTMANAGER__H__
#define CDCLIENTMANAGER_H #define __CDCLIENTMANAGER__H__
#define UNUSED_TABLE(v) #define UNUSED_TABLE(v)
@@ -41,4 +41,4 @@ T* CDClientManager::GetTable() {
return &T::Instance(); return &T::Instance();
}; };
#endif //!CDCLIENTMANAGER_H #endif //!__CDCLIENTMANAGER__H__

View File

@@ -58,7 +58,7 @@ void CDLootTableTable::LoadValuesFromDatabase() {
CDLootTable entry; CDLootTable entry;
uint32_t lootTableIndex = tableData.getIntField("LootTableIndex", -1); uint32_t lootTableIndex = tableData.getIntField("LootTableIndex", -1);
entries[lootTableIndex].emplace_back(ReadRow(tableData)); entries[lootTableIndex].push_back(ReadRow(tableData));
tableData.nextRow(); tableData.nextRow();
} }
for (auto& [id, table] : entries) { for (auto& [id, table] : entries) {
@@ -66,7 +66,7 @@ void CDLootTableTable::LoadValuesFromDatabase() {
} }
} }
const LootTableEntries& CDLootTableTable::GetTable(const uint32_t tableId) { const LootTableEntries& CDLootTableTable::GetTable(uint32_t tableId) {
auto& entries = GetEntriesMutable(); auto& entries = GetEntriesMutable();
auto itr = entries.find(tableId); auto itr = entries.find(tableId);
if (itr != entries.end()) { if (itr != entries.end()) {
@@ -79,7 +79,7 @@ const LootTableEntries& CDLootTableTable::GetTable(const uint32_t tableId) {
while (!tableData.eof()) { while (!tableData.eof()) {
CDLootTable entry; CDLootTable entry;
entries[tableId].emplace_back(ReadRow(tableData)); entries[tableId].push_back(ReadRow(tableData));
tableData.nextRow(); tableData.nextRow();
} }
SortTable(entries[tableId]); SortTable(entries[tableId]);

View File

@@ -3,8 +3,6 @@
// Custom Classes // Custom Classes
#include "CDTable.h" #include "CDTable.h"
#include <cstdint>
struct CDLootTable { struct CDLootTable {
uint32_t itemid; //!< The LOT of the item uint32_t itemid; //!< The LOT of the item
uint32_t LootTableIndex; //!< The Loot Table Index uint32_t LootTableIndex; //!< The Loot Table Index
@@ -22,5 +20,6 @@ private:
public: public:
void LoadValuesFromDatabase(); void LoadValuesFromDatabase();
// Queries the table with a custom "where" clause // Queries the table with a custom "where" clause
const LootTableEntries& GetTable(const uint32_t tableId); const LootTableEntries& GetTable(uint32_t tableId);
}; };

View File

@@ -20,7 +20,7 @@ void CDMissionEmailTable::LoadValuesFromDatabase() {
// Now get the data // Now get the data
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM MissionEmail"); auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM MissionEmail");
while (!tableData.eof()) { while (!tableData.eof()) {
auto& entry = entries.emplace_back(); CDMissionEmail entry;
entry.ID = tableData.getIntField("ID", -1); entry.ID = tableData.getIntField("ID", -1);
entry.messageType = tableData.getIntField("messageType", -1); entry.messageType = tableData.getIntField("messageType", -1);
entry.notificationGroup = tableData.getIntField("notificationGroup", -1); entry.notificationGroup = tableData.getIntField("notificationGroup", -1);
@@ -30,8 +30,11 @@ void CDMissionEmailTable::LoadValuesFromDatabase() {
entry.locStatus = tableData.getIntField("locStatus", -1); entry.locStatus = tableData.getIntField("locStatus", -1);
entry.gate_version = tableData.getStringField("gate_version", ""); entry.gate_version = tableData.getStringField("gate_version", "");
entries.push_back(entry);
tableData.nextRow(); tableData.nextRow();
} }
tableData.finalize();
} }
//! Queries the table with a custom "where" clause //! Queries the table with a custom "where" clause

View File

@@ -3,8 +3,6 @@
// Custom Classes // Custom Classes
#include "CDTable.h" #include "CDTable.h"
#include <cstdint>
struct CDMissionEmail { struct CDMissionEmail {
uint32_t ID; uint32_t ID;
uint32_t messageType; uint32_t messageType;

Some files were not shown because too many files have changed in this diff Show More