mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-12 19:28:21 +00:00
Merge remote-tracking branch 'origin/main' into grim-lu
This commit is contained in:
commit
2097dbfff1
@ -14,4 +14,4 @@ EXTERNAL_IP=localhost
|
||||
MARIADB_USER=darkflame
|
||||
MARIADB_PASSWORD=SECRET_VALUE_CHANGE_ME
|
||||
MARIADB_ROOT_PASSWORD=SECRET_VALUE_CHANGE_ME
|
||||
MARIADB_DATABASE=darkflame
|
||||
MARIADB_DATABASE=darkflame
|
||||
|
@ -97,15 +97,56 @@ make_directory(${CMAKE_BINARY_DIR}/logs)
|
||||
|
||||
# Copy resource files on first build
|
||||
set(RESOURCE_FILES "sharedconfig.ini" "authconfig.ini" "chatconfig.ini" "worldconfig.ini" "masterconfig.ini" "blacklist.dcf")
|
||||
foreach(resource_file ${RESOURCE_FILES})
|
||||
if (NOT EXISTS ${PROJECT_BINARY_DIR}/${resource_file})
|
||||
message(STATUS "Checking resource file integrity")
|
||||
foreach (resource_file ${RESOURCE_FILES})
|
||||
set(file_size 0)
|
||||
if (EXISTS ${PROJECT_BINARY_DIR}/${resource_file})
|
||||
file(SIZE ${PROJECT_BINARY_DIR}/${resource_file} file_size)
|
||||
endif()
|
||||
if (${file_size} EQUAL 0)
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/resources/${resource_file} ${PROJECT_BINARY_DIR}/${resource_file}
|
||||
COPYONLY
|
||||
)
|
||||
message("Moved ${resource_file} to project binary directory")
|
||||
message(STATUS "Moved " ${resource_file} " to project binary directory")
|
||||
elseif (resource_file MATCHES ".ini")
|
||||
message(STATUS "Checking " ${resource_file} " for missing config options")
|
||||
file(READ ${PROJECT_BINARY_DIR}/${resource_file} current_file_contents)
|
||||
string(REPLACE "\\\n" "" current_file_contents ${current_file_contents})
|
||||
string(REPLACE "\n" ";" current_file_contents ${current_file_contents})
|
||||
set(parsed_current_file_contents "")
|
||||
# Remove comment lines so they do not interfere with the variable parsing
|
||||
foreach (line ${current_file_contents})
|
||||
string(FIND ${line} "#" is_comment)
|
||||
if (NOT ${is_comment} EQUAL 0)
|
||||
string(APPEND parsed_current_file_contents ${line})
|
||||
endif()
|
||||
endforeach()
|
||||
file(READ ${CMAKE_SOURCE_DIR}/resources/${resource_file} depot_file_contents)
|
||||
string(REPLACE "\\\n" "" depot_file_contents ${depot_file_contents})
|
||||
string(REPLACE "\n" ";" depot_file_contents ${depot_file_contents})
|
||||
set(line_to_add "")
|
||||
foreach (line ${depot_file_contents})
|
||||
string(FIND ${line} "#" is_comment)
|
||||
if (NOT ${is_comment} EQUAL 0)
|
||||
string(REPLACE "=" ";" line_split ${line})
|
||||
list(GET line_split 0 variable_name)
|
||||
if (NOT ${parsed_current_file_contents} MATCHES ${variable_name})
|
||||
message(STATUS "Adding missing config option " ${variable_name} " to " ${resource_file})
|
||||
set(line_to_add ${line_to_add} ${line})
|
||||
foreach (line_to_append ${line_to_add})
|
||||
file(APPEND ${PROJECT_BINARY_DIR}/${resource_file} "\n" ${line_to_append})
|
||||
endforeach()
|
||||
file(APPEND ${PROJECT_BINARY_DIR}/${resource_file} "\n")
|
||||
endif()
|
||||
set(line_to_add "")
|
||||
else()
|
||||
set(line_to_add ${line_to_add} ${line})
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endforeach()
|
||||
message(STATUS "Resource file integrity check complete")
|
||||
|
||||
# Copy navmesh data on first build and extract it
|
||||
if (NOT EXISTS ${PROJECT_BINARY_DIR}/navmeshes/)
|
||||
|
@ -1,12 +1,8 @@
|
||||
PROJECT_VERSION_MAJOR=1
|
||||
PROJECT_VERSION_MINOR=0
|
||||
PROJECT_VERSION_PATCH=4
|
||||
PROJECT_VERSION_MINOR=1
|
||||
PROJECT_VERSION_PATCH=1
|
||||
# LICENSE
|
||||
LICENSE=AGPL-3.0
|
||||
# The network version.
|
||||
# 171023 - Darkflame Universe client
|
||||
# 171022 - Unmodded client
|
||||
NET_VERSION=171022
|
||||
# Debugging
|
||||
# Set __dynamic to 1 to enable the -rdynamic flag for the linker, yielding some symbols in crashlogs.
|
||||
__dynamic=1
|
||||
@ -22,3 +18,5 @@ __maria_db_connector_compile_jobs__=1
|
||||
__enable_testing__=1
|
||||
# The path to OpenSSL. Change this if your OpenSSL install path is different than the default.
|
||||
OPENSSL_ROOT_DIR=/usr/local/opt/openssl@3/
|
||||
# Uncomment the below line to cache the entire CDClient into memory
|
||||
# CDCLIENT_CACHE_ALL=1
|
||||
|
@ -179,7 +179,7 @@ If you would like to build the server faster, append `-j<number>` where number i
|
||||
### Notes
|
||||
Depending on your operating system, you may need to adjust some pre-processor defines in [CMakeVariables.txt](./CMakeVariables.txt) before building:
|
||||
* If you are on MacOS, ensure OPENSSL_ROOT_DIR is pointing to the openssl root directory.
|
||||
* If you are using a Darkflame Universe client, ensure NET_VERSION is changed to 171023.
|
||||
* If you are using a Darkflame Universe client, ensure `client_net_version` in `build/sharedconfig.ini` is changed to 171023.
|
||||
|
||||
## Configuring your server
|
||||
This server has a few steps that need to be taken to configure the server for your use case.
|
||||
@ -338,7 +338,7 @@ This is a Work in Progress, but below are some quick links to documentaion for s
|
||||
## Former Contributors
|
||||
* TheMachine
|
||||
* Matthew
|
||||
* [Raine](https://github.com/Rainebannister)
|
||||
* [Raine](https://github.com/uwainium)
|
||||
* Bricknave
|
||||
|
||||
## Special Thanks
|
||||
|
@ -29,6 +29,7 @@ namespace Game {
|
||||
dServer* server = nullptr;
|
||||
dConfig* config = nullptr;
|
||||
bool shouldShutdown = false;
|
||||
std::mt19937 randomEngine;
|
||||
}
|
||||
|
||||
dLogger* SetupLogger();
|
||||
@ -83,6 +84,8 @@ int main(int argc, char** argv) {
|
||||
delete res;
|
||||
delete stmt;
|
||||
|
||||
Game::randomEngine = std::mt19937(time(0));
|
||||
|
||||
//It's safe to pass 'localhost' here, as the IP is only used as the external IP.
|
||||
uint32_t maxClients = 50;
|
||||
uint32_t ourPort = 1001; //LU client is hardcoded to use this for auth port, so I'm making it the default.
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "Database.h"
|
||||
#include <vector>
|
||||
#include "PacketUtils.h"
|
||||
#include "BitStreamUtils.h"
|
||||
#include "Game.h"
|
||||
#include "dServer.h"
|
||||
#include "GeneralUtils.h"
|
||||
@ -75,11 +76,11 @@ void ChatPacketHandler::HandleFriendlistRequest(Packet* packet) {
|
||||
|
||||
//Now, we need to send the friendlist to the server they came from:
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
bitStream.Write(playerID);
|
||||
|
||||
//portion that will get routed:
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::GET_FRIENDS_LIST_RESPONSE);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::GET_FRIENDS_LIST_RESPONSE);
|
||||
bitStream.Write<uint8_t>(0);
|
||||
bitStream.Write<uint16_t>(1); //Length of packet -- just writing one as it doesn't matter, client skips it.
|
||||
bitStream.Write((uint16_t)friends.size());
|
||||
@ -412,21 +413,21 @@ void ChatPacketHandler::HandleChatMessage(Packet* packet) {
|
||||
const auto otherName = std::string(otherMember->playerName.c_str());
|
||||
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
bitStream.Write(otherMember->playerID);
|
||||
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::PRIVATE_CHAT_MESSAGE);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::PRIVATE_CHAT_MESSAGE);
|
||||
bitStream.Write(otherMember->playerID);
|
||||
bitStream.Write<uint8_t>(8);
|
||||
bitStream.Write<unsigned int>(69);
|
||||
PacketUtils::WritePacketWString(senderName, 33, &bitStream);
|
||||
bitStream.Write(LUWString(senderName));
|
||||
bitStream.Write(sender->playerID);
|
||||
bitStream.Write<uint16_t>(0);
|
||||
bitStream.Write<uint8_t>(0); //not mythran nametag
|
||||
PacketUtils::WritePacketWString(otherName, 33, &bitStream);
|
||||
bitStream.Write(LUWString(otherName));
|
||||
bitStream.Write<uint8_t>(0); //not mythran for receiver
|
||||
bitStream.Write<uint8_t>(0); //teams?
|
||||
PacketUtils::WritePacketWString(message, 512, &bitStream);
|
||||
bitStream.Write(LUWString(message, 512));
|
||||
|
||||
SystemAddress sysAddr = otherMember->sysAddr;
|
||||
SEND_PACKET;
|
||||
@ -434,7 +435,7 @@ void ChatPacketHandler::HandleChatMessage(Packet* packet) {
|
||||
}
|
||||
|
||||
void ChatPacketHandler::HandlePrivateChatMessage(Packet* packet) {
|
||||
LWOOBJID senderID = PacketUtils::ReadPacketS64(0x08, packet);
|
||||
LWOOBJID senderID = PacketUtils::ReadS64(0x08, packet);
|
||||
std::string receiverName = PacketUtils::ReadString(0x66, packet, true);
|
||||
std::string message = PacketUtils::ReadString(0xAA, packet, true, 512);
|
||||
|
||||
@ -451,21 +452,21 @@ void ChatPacketHandler::HandlePrivateChatMessage(Packet* packet) {
|
||||
//To the sender:
|
||||
{
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
bitStream.Write(goonA->playerID);
|
||||
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::PRIVATE_CHAT_MESSAGE);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::PRIVATE_CHAT_MESSAGE);
|
||||
bitStream.Write(goonA->playerID);
|
||||
bitStream.Write<uint8_t>(7);
|
||||
bitStream.Write<unsigned int>(69);
|
||||
PacketUtils::WritePacketWString(goonAName, 33, &bitStream);
|
||||
bitStream.Write(LUWString(goonAName));
|
||||
bitStream.Write(goonA->playerID);
|
||||
bitStream.Write<uint16_t>(0);
|
||||
bitStream.Write<uint8_t>(0); //not mythran nametag
|
||||
PacketUtils::WritePacketWString(goonBName, 33, &bitStream);
|
||||
bitStream.Write(LUWString(goonBName));
|
||||
bitStream.Write<uint8_t>(0); //not mythran for receiver
|
||||
bitStream.Write<uint8_t>(0); //success
|
||||
PacketUtils::WritePacketWString(message, 512, &bitStream);
|
||||
bitStream.Write(LUWString(message, 512));
|
||||
|
||||
SystemAddress sysAddr = goonA->sysAddr;
|
||||
SEND_PACKET;
|
||||
@ -474,21 +475,21 @@ void ChatPacketHandler::HandlePrivateChatMessage(Packet* packet) {
|
||||
//To the receiver:
|
||||
{
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
bitStream.Write(goonB->playerID);
|
||||
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::PRIVATE_CHAT_MESSAGE);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::PRIVATE_CHAT_MESSAGE);
|
||||
bitStream.Write(goonA->playerID);
|
||||
bitStream.Write<uint8_t>(7);
|
||||
bitStream.Write<unsigned int>(69);
|
||||
PacketUtils::WritePacketWString(goonAName, 33, &bitStream);
|
||||
bitStream.Write(LUWString(goonAName));
|
||||
bitStream.Write(goonA->playerID);
|
||||
bitStream.Write<uint16_t>(0);
|
||||
bitStream.Write<uint8_t>(0); //not mythran nametag
|
||||
PacketUtils::WritePacketWString(goonBName, 33, &bitStream);
|
||||
bitStream.Write(LUWString(goonBName));
|
||||
bitStream.Write<uint8_t>(0); //not mythran for receiver
|
||||
bitStream.Write<uint8_t>(3); //new whisper
|
||||
PacketUtils::WritePacketWString(message, 512, &bitStream);
|
||||
bitStream.Write(LUWString(message, 512));
|
||||
|
||||
SystemAddress sysAddr = goonB->sysAddr;
|
||||
SEND_PACKET;
|
||||
@ -709,13 +710,13 @@ void ChatPacketHandler::HandleTeamStatusRequest(Packet* packet) {
|
||||
|
||||
void ChatPacketHandler::SendTeamInvite(PlayerData* receiver, PlayerData* sender) {
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
bitStream.Write(receiver->playerID);
|
||||
|
||||
//portion that will get routed:
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::TEAM_INVITE);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::TEAM_INVITE);
|
||||
|
||||
PacketUtils::WritePacketWString(sender->playerName.c_str(), 33, &bitStream);
|
||||
bitStream.Write(LUWString(sender->playerName.c_str()));
|
||||
bitStream.Write(sender->playerID);
|
||||
|
||||
SystemAddress sysAddr = receiver->sysAddr;
|
||||
@ -724,7 +725,7 @@ void ChatPacketHandler::SendTeamInvite(PlayerData* receiver, PlayerData* sender)
|
||||
|
||||
void ChatPacketHandler::SendTeamInviteConfirm(PlayerData* receiver, bool bLeaderIsFreeTrial, LWOOBJID i64LeaderID, LWOZONEID i64LeaderZoneID, uint8_t ucLootFlag, uint8_t ucNumOfOtherPlayers, uint8_t ucResponseCode, std::u16string wsLeaderName) {
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
bitStream.Write(receiver->playerID);
|
||||
|
||||
//portion that will get routed:
|
||||
@ -751,7 +752,7 @@ void ChatPacketHandler::SendTeamInviteConfirm(PlayerData* receiver, bool bLeader
|
||||
|
||||
void ChatPacketHandler::SendTeamStatus(PlayerData* receiver, LWOOBJID i64LeaderID, LWOZONEID i64LeaderZoneID, uint8_t ucLootFlag, uint8_t ucNumOfOtherPlayers, std::u16string wsLeaderName) {
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
bitStream.Write(receiver->playerID);
|
||||
|
||||
//portion that will get routed:
|
||||
@ -776,7 +777,7 @@ void ChatPacketHandler::SendTeamStatus(PlayerData* receiver, LWOOBJID i64LeaderI
|
||||
|
||||
void ChatPacketHandler::SendTeamSetLeader(PlayerData* receiver, LWOOBJID i64PlayerID) {
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
bitStream.Write(receiver->playerID);
|
||||
|
||||
//portion that will get routed:
|
||||
@ -793,7 +794,7 @@ void ChatPacketHandler::SendTeamSetLeader(PlayerData* receiver, LWOOBJID i64Play
|
||||
|
||||
void ChatPacketHandler::SendTeamAddPlayer(PlayerData* receiver, bool bIsFreeTrial, bool bLocal, bool bNoLootOnDeath, LWOOBJID i64PlayerID, std::u16string wsPlayerName, LWOZONEID zoneID) {
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
bitStream.Write(receiver->playerID);
|
||||
|
||||
//portion that will get routed:
|
||||
@ -822,7 +823,7 @@ void ChatPacketHandler::SendTeamAddPlayer(PlayerData* receiver, bool bIsFreeTria
|
||||
|
||||
void ChatPacketHandler::SendTeamRemovePlayer(PlayerData* receiver, bool bDisband, bool bIsKicked, bool bIsLeaving, bool bLocal, LWOOBJID i64LeaderID, LWOOBJID i64PlayerID, std::u16string wsPlayerName) {
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
bitStream.Write(receiver->playerID);
|
||||
|
||||
//portion that will get routed:
|
||||
@ -848,7 +849,7 @@ void ChatPacketHandler::SendTeamRemovePlayer(PlayerData* receiver, bool bDisband
|
||||
|
||||
void ChatPacketHandler::SendTeamSetOffWorldFlag(PlayerData* receiver, LWOOBJID i64PlayerID, LWOZONEID zoneID) {
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
bitStream.Write(receiver->playerID);
|
||||
|
||||
//portion that will get routed:
|
||||
@ -882,16 +883,16 @@ void ChatPacketHandler::SendFriendUpdate(PlayerData* friendData, PlayerData* pla
|
||||
[bool] - is FTP*/
|
||||
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
bitStream.Write(friendData->playerID);
|
||||
|
||||
//portion that will get routed:
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::UPDATE_FRIEND_NOTIFY);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::UPDATE_FRIEND_NOTIFY);
|
||||
bitStream.Write<uint8_t>(notifyType);
|
||||
|
||||
std::string playerName = playerData->playerName.c_str();
|
||||
|
||||
PacketUtils::WritePacketWString(playerName, 33, &bitStream);
|
||||
bitStream.Write(LUWString(playerName));
|
||||
|
||||
bitStream.Write(playerData->zoneID.GetMapID());
|
||||
bitStream.Write(playerData->zoneID.GetInstanceID());
|
||||
@ -921,12 +922,12 @@ void ChatPacketHandler::SendFriendRequest(PlayerData* receiver, PlayerData* send
|
||||
}
|
||||
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
bitStream.Write(receiver->playerID);
|
||||
|
||||
//portion that will get routed:
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::ADD_FRIEND_REQUEST);
|
||||
PacketUtils::WritePacketWString(sender->playerName.c_str(), 33, &bitStream);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::ADD_FRIEND_REQUEST);
|
||||
bitStream.Write(LUWString(sender->playerName.c_str()));
|
||||
bitStream.Write<uint8_t>(0); // This is a BFF flag however this is unused in live and does not have an implementation client side.
|
||||
|
||||
SystemAddress sysAddr = receiver->sysAddr;
|
||||
@ -937,16 +938,16 @@ void ChatPacketHandler::SendFriendResponse(PlayerData* receiver, PlayerData* sen
|
||||
if (!receiver || !sender) return;
|
||||
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
bitStream.Write(receiver->playerID);
|
||||
|
||||
// Portion that will get routed:
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::ADD_FRIEND_RESPONSE);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::ADD_FRIEND_RESPONSE);
|
||||
bitStream.Write(responseCode);
|
||||
// For all requests besides accepted, write a flag that says whether or not we are already best friends with the receiver.
|
||||
bitStream.Write<uint8_t>(responseCode != eAddFriendResponseType::ACCEPTED ? isBestFriendsAlready : sender->sysAddr != UNASSIGNED_SYSTEM_ADDRESS);
|
||||
// Then write the player name
|
||||
PacketUtils::WritePacketWString(sender->playerName.c_str(), 33, &bitStream);
|
||||
bitStream.Write(LUWString(sender->playerName.c_str()));
|
||||
// Then if this is an acceptance code, write the following extra info.
|
||||
if (responseCode == eAddFriendResponseType::ACCEPTED) {
|
||||
bitStream.Write(sender->playerID);
|
||||
@ -962,13 +963,13 @@ void ChatPacketHandler::SendRemoveFriend(PlayerData* receiver, std::string& pers
|
||||
if (!receiver) return;
|
||||
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
bitStream.Write(receiver->playerID);
|
||||
|
||||
//portion that will get routed:
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::REMOVE_FRIEND_RESPONSE);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::REMOVE_FRIEND_RESPONSE);
|
||||
bitStream.Write<uint8_t>(isSuccessful); //isOnline
|
||||
PacketUtils::WritePacketWString(personToRemove, 33, &bitStream);
|
||||
bitStream.Write(LUWString(personToRemove));
|
||||
|
||||
SystemAddress sysAddr = receiver->sysAddr;
|
||||
SEND_PACKET;
|
||||
|
@ -33,6 +33,7 @@ namespace Game {
|
||||
dChatFilter* chatFilter = nullptr;
|
||||
AssetManager* assetManager = nullptr;
|
||||
bool shouldShutdown = false;
|
||||
std::mt19937 randomEngine;
|
||||
}
|
||||
|
||||
|
||||
@ -114,6 +115,8 @@ int main(int argc, char** argv) {
|
||||
Game::server = new dServer(Game::config->GetValue("external_ip"), ourPort, 0, maxClients, false, true, Game::logger, masterIP, masterPort, ServerType::Chat, Game::config, &Game::shouldShutdown);
|
||||
|
||||
Game::chatFilter = new dChatFilter(Game::assetManager->GetResPath().string() + "/chatplus_en_us", bool(std::stoi(Game::config->GetValue("dont_generate_dcf"))));
|
||||
|
||||
Game::randomEngine = std::mt19937(time(0));
|
||||
|
||||
//Run it until server gets a kill message from Master:
|
||||
auto t = std::chrono::high_resolution_clock::now();
|
||||
|
@ -6,10 +6,11 @@
|
||||
#include "dLogger.h"
|
||||
#include "ChatPacketHandler.h"
|
||||
#include "GeneralUtils.h"
|
||||
#include "PacketUtils.h"
|
||||
#include "BitStreamUtils.h"
|
||||
#include "Database.h"
|
||||
#include "eConnectionType.h"
|
||||
#include "eChatInternalMessageType.h"
|
||||
#include "ChatPackets.h"
|
||||
|
||||
PlayerContainer::PlayerContainer() {
|
||||
}
|
||||
@ -146,7 +147,7 @@ void PlayerContainer::CreateTeamServer(Packet* packet) {
|
||||
|
||||
void PlayerContainer::BroadcastMuteUpdate(LWOOBJID player, time_t time) {
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::MUTE_UPDATE);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::MUTE_UPDATE);
|
||||
|
||||
bitStream.Write(player);
|
||||
bitStream.Write(time);
|
||||
@ -207,6 +208,14 @@ TeamData* PlayerContainer::GetTeam(LWOOBJID playerID) {
|
||||
}
|
||||
|
||||
void PlayerContainer::AddMember(TeamData* team, LWOOBJID playerID) {
|
||||
if (team->memberIDs.size() >= 4){
|
||||
Game::logger->Log("PlayerContainer", "Tried to add player to team that already had 4 players");
|
||||
auto* player = GetPlayerData(playerID);
|
||||
if (!player) return;
|
||||
ChatPackets::SendSystemMessage(player->sysAddr, u"The teams is full! You have not been added to a team!");
|
||||
return;
|
||||
}
|
||||
|
||||
const auto index = std::find(team->memberIDs.begin(), team->memberIDs.end(), playerID);
|
||||
|
||||
if (index != team->memberIDs.end()) return;
|
||||
@ -345,7 +354,7 @@ void PlayerContainer::TeamStatusUpdate(TeamData* team) {
|
||||
|
||||
void PlayerContainer::UpdateTeamsOnWorld(TeamData* team, bool deleteTeam) {
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::TEAM_UPDATE);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::TEAM_UPDATE);
|
||||
|
||||
bitStream.Write(team->teamID);
|
||||
bitStream.Write(deleteTeam);
|
||||
|
@ -10,6 +10,8 @@ class dConfig;
|
||||
class RakPeerInterface;
|
||||
class AssetManager;
|
||||
struct SystemAddress;
|
||||
class EntityManager;
|
||||
class dZoneManager;
|
||||
|
||||
namespace Game {
|
||||
extern dLogger* logger;
|
||||
@ -22,4 +24,6 @@ namespace Game {
|
||||
extern AssetManager* assetManager;
|
||||
extern SystemAddress chatSysAddr;
|
||||
extern bool shouldShutdown;
|
||||
extern EntityManager* entityManager;
|
||||
extern dZoneManager* zoneManager;
|
||||
}
|
||||
|
@ -111,29 +111,6 @@ namespace GeneralUtils {
|
||||
*/
|
||||
bool CheckBit(int64_t value, uint32_t index);
|
||||
|
||||
// MARK: Random Number Generation
|
||||
|
||||
//! Generates a random number
|
||||
/*!
|
||||
\param min The minimum the generate from
|
||||
\param max The maximum to generate to
|
||||
*/
|
||||
template <typename T>
|
||||
inline T GenerateRandomNumber(std::size_t min, std::size_t max) {
|
||||
// Make sure it is a numeric type
|
||||
static_assert(std::is_arithmetic<T>::value, "Not an arithmetic type");
|
||||
|
||||
if constexpr (std::is_integral_v<T>) { // constexpr only necessary on first statement
|
||||
std::uniform_int_distribution<T> distribution(min, max);
|
||||
return distribution(Game::randomEngine);
|
||||
} else if (std::is_floating_point_v<T>) {
|
||||
std::uniform_real_distribution<T> distribution(min, max);
|
||||
return distribution(Game::randomEngine);
|
||||
}
|
||||
|
||||
return T();
|
||||
}
|
||||
|
||||
bool ReplaceInString(std::string& str, const std::string& from, const std::string& to);
|
||||
|
||||
std::u16string ReadWString(RakNet::BitStream* inStream);
|
||||
@ -223,4 +200,42 @@ namespace GeneralUtils {
|
||||
std::hash<T> h;
|
||||
s ^= h(v) + 0x9e3779b9 + (s << 6) + (s >> 2);
|
||||
}
|
||||
|
||||
// MARK: Random Number Generation
|
||||
|
||||
//! Generates a random number
|
||||
/*!
|
||||
\param min The minimum the generate from
|
||||
\param max The maximum to generate to
|
||||
*/
|
||||
template <typename T>
|
||||
inline T GenerateRandomNumber(std::size_t min, std::size_t max) {
|
||||
// Make sure it is a numeric type
|
||||
static_assert(std::is_arithmetic<T>::value, "Not an arithmetic type");
|
||||
|
||||
if constexpr (std::is_integral_v<T>) { // constexpr only necessary on first statement
|
||||
std::uniform_int_distribution<T> distribution(min, max);
|
||||
return distribution(Game::randomEngine);
|
||||
} else if (std::is_floating_point_v<T>) {
|
||||
std::uniform_real_distribution<T> distribution(min, max);
|
||||
return distribution(Game::randomEngine);
|
||||
}
|
||||
|
||||
return T();
|
||||
}
|
||||
|
||||
// on Windows we need to undef these or else they conflict with our numeric limits calls
|
||||
// DEVELOPERS DEVELOPERS DEVELOPERS DEVELOPERS DEVELOPERS DEVELOPERS DEVELOPERS DEVELOPERS
|
||||
#ifdef _WIN32
|
||||
#undef min
|
||||
#undef max
|
||||
#endif
|
||||
|
||||
template <typename T>
|
||||
inline T GenerateRandomNumber() {
|
||||
// Make sure it is a numeric type
|
||||
static_assert(std::is_arithmetic<T>::value, "Not an arithmetic type");
|
||||
|
||||
return GenerateRandomNumber<T>(std::numeric_limits<T>::min(), std::numeric_limits<T>::max());
|
||||
}
|
||||
}
|
||||
|
@ -129,10 +129,19 @@ NiPoint3 NiPoint3::operator+(const NiPoint3& point) const {
|
||||
}
|
||||
|
||||
//! Operator for addition of vectors
|
||||
NiPoint3 NiPoint3::operator+=(const NiPoint3& point) const {
|
||||
return NiPoint3(this->x + point.x, this->y + point.y, this->z + point.z);
|
||||
NiPoint3& NiPoint3::operator+=(const NiPoint3& point) {
|
||||
this->x += point.x;
|
||||
this->y += point.y;
|
||||
this->z += point.z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
NiPoint3& NiPoint3::operator*=(const float scalar) {
|
||||
this->x *= scalar;
|
||||
this->y *= scalar;
|
||||
this->z *= scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! Operator for subtraction of vectors
|
||||
NiPoint3 NiPoint3::operator-(const NiPoint3& point) const {
|
||||
|
@ -136,7 +136,9 @@ public:
|
||||
NiPoint3 operator+(const NiPoint3& point) const;
|
||||
|
||||
//! Operator for addition of vectors
|
||||
NiPoint3 operator+=(const NiPoint3& point) const;
|
||||
NiPoint3& operator+=(const NiPoint3& point);
|
||||
|
||||
NiPoint3& operator*=(const float scalar);
|
||||
|
||||
//! Operator for subtraction of vectors
|
||||
NiPoint3 operator-(const NiPoint3& point) const;
|
||||
|
@ -42,7 +42,7 @@ struct AssetMemoryBuffer : std::streambuf {
|
||||
}
|
||||
|
||||
void close() {
|
||||
delete m_Base;
|
||||
free(m_Base);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "BitStream.h"
|
||||
#include "eConnectionType.h"
|
||||
#include "eClientMessageType.h"
|
||||
#include "BitStreamUtils.h"
|
||||
|
||||
#pragma warning (disable:4251) //Disables SQL warnings
|
||||
|
||||
@ -32,7 +33,7 @@ constexpr uint32_t lowFrameDelta = FRAMES_TO_MS(lowFramerate);
|
||||
#define CBITSTREAM RakNet::BitStream bitStream;
|
||||
#define CINSTREAM RakNet::BitStream inStream(packet->data, packet->length, false);
|
||||
#define CINSTREAM_SKIP_HEADER CINSTREAM if (inStream.GetNumberOfUnreadBits() >= BYTES_TO_BITS(HEADER_SIZE)) inStream.IgnoreBytes(HEADER_SIZE); else inStream.IgnoreBits(inStream.GetNumberOfUnreadBits());
|
||||
#define CMSGHEADER PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::GAME_MSG);
|
||||
#define CMSGHEADER BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::GAME_MSG);
|
||||
#define SEND_PACKET Game::server->Send(&bitStream, sysAddr, false);
|
||||
#define SEND_PACKET_BROADCAST Game::server->Send(&bitStream, UNASSIGNED_SYSTEM_ADDRESS, true);
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -101,7 +101,7 @@ enum class eReplicaComponentType : uint32_t {
|
||||
TRADE,
|
||||
USER_CONTROL,
|
||||
IGNORE_LIST,
|
||||
ROCKET_LAUNCH_LUP,
|
||||
MULTI_ZONE_ENTRANCE,
|
||||
BUFF_REAL, // the real buff component, should just be name BUFF
|
||||
INTERACTION_MANAGER,
|
||||
DONATION_VENDOR,
|
||||
|
@ -13,15 +13,7 @@
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
|
||||
// Enable this to cache all entries in each table for fast access, comes with more memory cost
|
||||
//#define CDCLIENT_CACHE_ALL
|
||||
|
||||
/*!
|
||||
\file CDClientDatabase.hpp
|
||||
\brief An interface between the CDClient.sqlite file and the server
|
||||
*/
|
||||
|
||||
//! The CDClient Database namespace
|
||||
//! The CDClient Database namespace
|
||||
namespace CDClientDatabase {
|
||||
|
||||
//! Opens a connection with the CDClient
|
||||
|
@ -38,43 +38,53 @@
|
||||
#include "CDFeatureGatingTable.h"
|
||||
#include "CDRailActivatorComponent.h"
|
||||
|
||||
// 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.
|
||||
// #define CDCLIENT_CACHE_ALL
|
||||
|
||||
#ifdef CDCLIENT_CACHE_ALL
|
||||
#define CDCLIENT_DONT_CACHE_TABLE(x) x
|
||||
#else
|
||||
#define CDCLIENT_DONT_CACHE_TABLE(x)
|
||||
#endif
|
||||
|
||||
CDClientManager::CDClientManager() {
|
||||
CDActivityRewardsTable::Instance();
|
||||
CDAnimationsTable::Instance();
|
||||
CDBehaviorParameterTable::Instance();
|
||||
CDBehaviorTemplateTable::Instance();
|
||||
CDComponentsRegistryTable::Instance();
|
||||
CDCurrencyTableTable::Instance();
|
||||
CDDestructibleComponentTable::Instance();
|
||||
CDEmoteTableTable::Instance();
|
||||
CDInventoryComponentTable::Instance();
|
||||
CDItemComponentTable::Instance();
|
||||
CDItemSetsTable::Instance();
|
||||
CDItemSetSkillsTable::Instance();
|
||||
CDLevelProgressionLookupTable::Instance();
|
||||
CDLootMatrixTable::Instance();
|
||||
CDLootTableTable::Instance();
|
||||
CDMissionNPCComponentTable::Instance();
|
||||
CDMissionTasksTable::Instance();
|
||||
CDMissionsTable::Instance();
|
||||
CDObjectSkillsTable::Instance();
|
||||
CDObjectsTable::Instance();
|
||||
CDPhysicsComponentTable::Instance();
|
||||
CDRebuildComponentTable::Instance();
|
||||
CDScriptComponentTable::Instance();
|
||||
CDSkillBehaviorTable::Instance();
|
||||
CDZoneTableTable::Instance();
|
||||
CDVendorComponentTable::Instance();
|
||||
CDActivitiesTable::Instance();
|
||||
CDPackageComponentTable::Instance();
|
||||
CDProximityMonitorComponentTable::Instance();
|
||||
CDMovementAIComponentTable::Instance();
|
||||
CDBrickIDTableTable::Instance();
|
||||
CDRarityTableTable::Instance();
|
||||
CDMissionEmailTable::Instance();
|
||||
CDRewardsTable::Instance();
|
||||
CDPropertyEntranceComponentTable::Instance();
|
||||
CDPropertyTemplateTable::Instance();
|
||||
CDFeatureGatingTable::Instance();
|
||||
CDRailActivatorComponentTable::Instance();
|
||||
CDActivityRewardsTable::Instance().LoadValuesFromDatabase();
|
||||
CDActivitiesTable::Instance().LoadValuesFromDatabase();
|
||||
CDCLIENT_DONT_CACHE_TABLE(CDAnimationsTable::Instance().LoadValuesFromDatabase());
|
||||
CDBehaviorParameterTable::Instance().LoadValuesFromDatabase();
|
||||
CDBehaviorTemplateTable::Instance().LoadValuesFromDatabase();
|
||||
CDBrickIDTableTable::Instance().LoadValuesFromDatabase();
|
||||
CDComponentsRegistryTable::Instance().LoadValuesFromDatabase();
|
||||
CDCurrencyTableTable::Instance().LoadValuesFromDatabase();
|
||||
CDDestructibleComponentTable::Instance().LoadValuesFromDatabase();
|
||||
CDEmoteTableTable::Instance().LoadValuesFromDatabase();
|
||||
CDFeatureGatingTable::Instance().LoadValuesFromDatabase();
|
||||
CDInventoryComponentTable::Instance().LoadValuesFromDatabase();
|
||||
CDCLIENT_DONT_CACHE_TABLE(CDItemComponentTable::Instance().LoadValuesFromDatabase());
|
||||
CDItemSetSkillsTable::Instance().LoadValuesFromDatabase();
|
||||
CDItemSetsTable::Instance().LoadValuesFromDatabase();
|
||||
CDLevelProgressionLookupTable::Instance().LoadValuesFromDatabase();
|
||||
CDLootMatrixTable::Instance().LoadValuesFromDatabase();
|
||||
CDLootTableTable::Instance().LoadValuesFromDatabase();
|
||||
CDMissionEmailTable::Instance().LoadValuesFromDatabase();
|
||||
CDMissionNPCComponentTable::Instance().LoadValuesFromDatabase();
|
||||
CDMissionTasksTable::Instance().LoadValuesFromDatabase();
|
||||
CDMissionsTable::Instance().LoadValuesFromDatabase();
|
||||
CDMovementAIComponentTable::Instance().LoadValuesFromDatabase();
|
||||
CDObjectSkillsTable::Instance().LoadValuesFromDatabase();
|
||||
CDCLIENT_DONT_CACHE_TABLE(CDObjectsTable::Instance().LoadValuesFromDatabase());
|
||||
CDPhysicsComponentTable::Instance().LoadValuesFromDatabase();
|
||||
CDPackageComponentTable::Instance().LoadValuesFromDatabase();
|
||||
CDProximityMonitorComponentTable::Instance().LoadValuesFromDatabase();
|
||||
CDPropertyEntranceComponentTable::Instance().LoadValuesFromDatabase();
|
||||
CDPropertyTemplateTable::Instance().LoadValuesFromDatabase();
|
||||
CDRailActivatorComponentTable::Instance().LoadValuesFromDatabase();
|
||||
CDRarityTableTable::Instance().LoadValuesFromDatabase();
|
||||
CDRebuildComponentTable::Instance().LoadValuesFromDatabase();
|
||||
CDRewardsTable::Instance().LoadValuesFromDatabase();
|
||||
CDScriptComponentTable::Instance().LoadValuesFromDatabase();
|
||||
CDSkillBehaviorTable::Instance().LoadValuesFromDatabase();
|
||||
CDVendorComponentTable::Instance().LoadValuesFromDatabase();
|
||||
CDZoneTableTable::Instance().LoadValuesFromDatabase();
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "CDActivitiesTable.h"
|
||||
|
||||
CDActivitiesTable::CDActivitiesTable(void) {
|
||||
|
||||
void CDActivitiesTable::LoadValuesFromDatabase() {
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM Activities");
|
||||
@ -55,8 +54,3 @@ std::vector<CDActivities> CDActivitiesTable::Query(std::function<bool(CDActiviti
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
std::vector<CDActivities> CDActivitiesTable::GetEntries(void) const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
@ -30,9 +30,10 @@ private:
|
||||
std::vector<CDActivities> entries;
|
||||
|
||||
public:
|
||||
CDActivitiesTable();
|
||||
void LoadValuesFromDatabase();
|
||||
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDActivities> Query(std::function<bool(CDActivities)> predicate);
|
||||
|
||||
std::vector<CDActivities> GetEntries(void) const;
|
||||
const std::vector<CDActivities>& GetEntries() const { return this->entries; }
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "CDActivityRewardsTable.h"
|
||||
|
||||
CDActivityRewardsTable::CDActivityRewardsTable(void) {
|
||||
void CDActivityRewardsTable::LoadValuesFromDatabase() {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@ -43,8 +43,3 @@ std::vector<CDActivityRewards> CDActivityRewardsTable::Query(std::function<bool(
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
std::vector<CDActivityRewards> CDActivityRewardsTable::GetEntries(void) const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
@ -18,10 +18,10 @@ private:
|
||||
std::vector<CDActivityRewards> entries;
|
||||
|
||||
public:
|
||||
CDActivityRewardsTable();
|
||||
void LoadValuesFromDatabase();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDActivityRewards> Query(std::function<bool(CDActivityRewards)> predicate);
|
||||
|
||||
std::vector<CDActivityRewards> GetEntries(void) const;
|
||||
std::vector<CDActivityRewards> GetEntries() const;
|
||||
|
||||
};
|
||||
|
@ -2,6 +2,35 @@
|
||||
#include "GeneralUtils.h"
|
||||
#include "Game.h"
|
||||
|
||||
|
||||
void CDAnimationsTable::LoadValuesFromDatabase() {
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Animations");
|
||||
while (!tableData.eof()) {
|
||||
std::string animation_type = tableData.getStringField("animation_type", "");
|
||||
DluAssert(!animation_type.empty());
|
||||
AnimationGroupID animationGroupID = tableData.getIntField("animationGroupID", -1);
|
||||
DluAssert(animationGroupID != -1);
|
||||
|
||||
CDAnimation entry;
|
||||
entry.animation_name = tableData.getStringField("animation_name", "");
|
||||
entry.chance_to_play = tableData.getFloatField("chance_to_play", 1.0f);
|
||||
UNUSED_COLUMN(entry.min_loops = tableData.getIntField("min_loops", 0);)
|
||||
UNUSED_COLUMN(entry.max_loops = tableData.getIntField("max_loops", 0);)
|
||||
entry.animation_length = tableData.getFloatField("animation_length", 0.0f);
|
||||
UNUSED_COLUMN(entry.hideEquip = tableData.getIntField("hideEquip", 0) == 1;)
|
||||
UNUSED_COLUMN(entry.ignoreUpperBody = tableData.getIntField("ignoreUpperBody", 0) == 1;)
|
||||
UNUSED_COLUMN(entry.restartable = tableData.getIntField("restartable", 0) == 1;)
|
||||
UNUSED_COLUMN(entry.face_animation_name = tableData.getStringField("face_animation_name", "");)
|
||||
UNUSED_COLUMN(entry.priority = tableData.getFloatField("priority", 0.0f);)
|
||||
UNUSED_COLUMN(entry.blendTime = tableData.getFloatField("blendTime", 0.0f);)
|
||||
|
||||
this->animations[CDAnimationKey(animation_type, animationGroupID)].push_back(entry);
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
tableData.finalize();
|
||||
}
|
||||
|
||||
bool CDAnimationsTable::CacheData(CppSQLite3Statement& queryToCache) {
|
||||
auto tableData = queryToCache.execQuery();
|
||||
// If we received a bad lookup, cache it anyways so we do not run the query again.
|
||||
|
@ -27,6 +27,7 @@ class CDAnimationsTable : public CDTable<CDAnimationsTable> {
|
||||
typedef std::string AnimationID;
|
||||
typedef std::pair<std::string, AnimationGroupID> CDAnimationKey;
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
/**
|
||||
* Given an animationType and the previousAnimationName played, return the next animationType to play.
|
||||
* If there are more than 1 animationTypes that can be played, one is selected at random but also does not allow
|
||||
|
@ -1,26 +1,30 @@
|
||||
#include "CDBehaviorParameterTable.h"
|
||||
#include "GeneralUtils.h"
|
||||
|
||||
CDBehaviorParameterTable::CDBehaviorParameterTable(void) {
|
||||
uint64_t GetKey(const uint32_t behaviorID, const uint32_t parameterID) {
|
||||
uint64_t key = behaviorID;
|
||||
key <<= 31U;
|
||||
key |= parameterID;
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
void CDBehaviorParameterTable::LoadValuesFromDatabase() {
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM BehaviorParameter");
|
||||
uint32_t uniqueParameterId = 0;
|
||||
uint64_t hash = 0;
|
||||
while (!tableData.eof()) {
|
||||
CDBehaviorParameter entry;
|
||||
entry.behaviorID = tableData.getIntField("behaviorID", -1);
|
||||
uint32_t behaviorID = tableData.getIntField("behaviorID", -1);
|
||||
auto candidateStringToAdd = std::string(tableData.getStringField("parameterID", ""));
|
||||
auto parameter = m_ParametersList.find(candidateStringToAdd);
|
||||
uint32_t parameterId;
|
||||
if (parameter != m_ParametersList.end()) {
|
||||
entry.parameterID = parameter;
|
||||
parameterId = parameter->second;
|
||||
} else {
|
||||
entry.parameterID = m_ParametersList.insert(std::make_pair(candidateStringToAdd, uniqueParameterId)).first;
|
||||
uniqueParameterId++;
|
||||
parameterId = m_ParametersList.insert(std::make_pair(candidateStringToAdd, m_ParametersList.size())).first->second;
|
||||
}
|
||||
hash = entry.behaviorID;
|
||||
hash = (hash << 31U) | entry.parameterID->second;
|
||||
entry.value = tableData.getFloatField("value", -1.0f);
|
||||
uint64_t hash = GetKey(behaviorID, parameterId);
|
||||
float value = tableData.getFloatField("value", -1.0f);
|
||||
|
||||
m_Entries.insert(std::make_pair(hash, entry));
|
||||
m_Entries.insert(std::make_pair(hash, value));
|
||||
|
||||
tableData.nextRow();
|
||||
}
|
||||
@ -30,27 +34,22 @@ CDBehaviorParameterTable::CDBehaviorParameterTable(void) {
|
||||
float CDBehaviorParameterTable::GetValue(const uint32_t behaviorID, const std::string& name, const float defaultValue) {
|
||||
auto parameterID = this->m_ParametersList.find(name);
|
||||
if (parameterID == this->m_ParametersList.end()) return defaultValue;
|
||||
|
||||
uint64_t hash = behaviorID;
|
||||
|
||||
hash = (hash << 31U) | parameterID->second;
|
||||
auto hash = GetKey(behaviorID, parameterID->second);
|
||||
|
||||
// Search for specific parameter
|
||||
const auto& it = m_Entries.find(hash);
|
||||
return it != m_Entries.end() ? it->second.value : defaultValue;
|
||||
auto it = m_Entries.find(hash);
|
||||
return it != m_Entries.end() ? it->second : defaultValue;
|
||||
}
|
||||
|
||||
std::map<std::string, float> CDBehaviorParameterTable::GetParametersByBehaviorID(uint32_t behaviorID) {
|
||||
uint64_t hashBase = behaviorID;
|
||||
std::map<std::string, float> returnInfo;
|
||||
uint64_t hash;
|
||||
for (auto& parameterCandidate : m_ParametersList) {
|
||||
hash = (hashBase << 31U) | parameterCandidate.second;
|
||||
for (auto& [parameterString, parameterId] : m_ParametersList) {
|
||||
uint64_t hash = GetKey(hashBase, parameterId);
|
||||
auto infoCandidate = m_Entries.find(hash);
|
||||
if (infoCandidate != m_Entries.end()) {
|
||||
returnInfo.insert(std::make_pair(infoCandidate->second.parameterID->first, infoCandidate->second.value));
|
||||
returnInfo.insert(std::make_pair(parameterString, infoCandidate->second));
|
||||
}
|
||||
}
|
||||
return returnInfo;
|
||||
}
|
||||
|
||||
|
@ -5,18 +5,15 @@
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
struct CDBehaviorParameter {
|
||||
unsigned int behaviorID; //!< The Behavior ID
|
||||
std::unordered_map<std::string, uint32_t>::iterator parameterID; //!< The Parameter ID
|
||||
float value; //!< The value of the behavior template
|
||||
};
|
||||
|
||||
class CDBehaviorParameterTable : public CDTable<CDBehaviorParameterTable> {
|
||||
private:
|
||||
std::unordered_map<uint64_t, CDBehaviorParameter> m_Entries;
|
||||
typedef uint64_t BehaviorParameterHash;
|
||||
typedef float BehaviorParameterValue;
|
||||
std::unordered_map<BehaviorParameterHash, BehaviorParameterValue> m_Entries;
|
||||
std::unordered_map<std::string, uint32_t> m_ParametersList;
|
||||
public:
|
||||
CDBehaviorParameterTable();
|
||||
void LoadValuesFromDatabase();
|
||||
|
||||
float GetValue(const uint32_t behaviorID, const std::string& name, const float defaultValue = 0);
|
||||
|
||||
std::map<std::string, float> GetParametersByBehaviorID(uint32_t behaviorID);
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "CDBehaviorTemplateTable.h"
|
||||
|
||||
CDBehaviorTemplateTable::CDBehaviorTemplateTable(void) {
|
||||
void CDBehaviorTemplateTable::LoadValuesFromDatabase() {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@ -48,7 +48,7 @@ std::vector<CDBehaviorTemplate> CDBehaviorTemplateTable::Query(std::function<boo
|
||||
return data;
|
||||
}
|
||||
|
||||
std::vector<CDBehaviorTemplate> CDBehaviorTemplateTable::GetEntries(void) const {
|
||||
const std::vector<CDBehaviorTemplate>& CDBehaviorTemplateTable::GetEntries() const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
@ -64,4 +64,3 @@ const CDBehaviorTemplate CDBehaviorTemplateTable::GetByBehaviorID(uint32_t behav
|
||||
return entry->second;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,11 +19,12 @@ private:
|
||||
std::unordered_map<uint32_t, CDBehaviorTemplate> entriesMappedByBehaviorID;
|
||||
std::unordered_set<std::string> m_EffectHandles;
|
||||
public:
|
||||
CDBehaviorTemplateTable();
|
||||
void LoadValuesFromDatabase();
|
||||
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDBehaviorTemplate> Query(std::function<bool(CDBehaviorTemplate)> predicate);
|
||||
|
||||
std::vector<CDBehaviorTemplate> GetEntries(void) const;
|
||||
const std::vector<CDBehaviorTemplate>& GetEntries(void) const;
|
||||
|
||||
const CDBehaviorTemplate GetByBehaviorID(uint32_t behaviorID);
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "CDBrickIDTableTable.h"
|
||||
|
||||
CDBrickIDTableTable::CDBrickIDTableTable(void) {
|
||||
void CDBrickIDTableTable::LoadValuesFromDatabase() {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@ -39,7 +39,7 @@ std::vector<CDBrickIDTable> CDBrickIDTableTable::Query(std::function<bool(CDBric
|
||||
return data;
|
||||
}
|
||||
|
||||
std::vector<CDBrickIDTable> CDBrickIDTableTable::GetEntries(void) const {
|
||||
const std::vector<CDBrickIDTable>& CDBrickIDTableTable::GetEntries() const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
@ -21,9 +21,9 @@ private:
|
||||
std::vector<CDBrickIDTable> entries;
|
||||
|
||||
public:
|
||||
CDBrickIDTableTable();
|
||||
void LoadValuesFromDatabase();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDBrickIDTable> Query(std::function<bool(CDBrickIDTable)> predicate);
|
||||
|
||||
std::vector<CDBrickIDTable> GetEntries(void) const;
|
||||
const std::vector<CDBrickIDTable>& GetEntries() const;
|
||||
};
|
||||
|
@ -1,27 +1,37 @@
|
||||
#include "CDComponentsRegistryTable.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
|
||||
#define CDCLIENT_CACHE_ALL
|
||||
|
||||
CDComponentsRegistryTable::CDComponentsRegistryTable(void) {
|
||||
|
||||
#ifdef CDCLIENT_CACHE_ALL
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ComponentsRegistry");
|
||||
while (!tableSize.eof()) {
|
||||
size = tableSize.getIntField(0, 0);
|
||||
|
||||
tableSize.nextRow();
|
||||
}
|
||||
|
||||
tableSize.finalize();
|
||||
|
||||
// Reserve the size
|
||||
//this->entries.reserve(size);
|
||||
|
||||
void CDComponentsRegistryTable::LoadValuesFromDatabase() {
|
||||
// Now get the data
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM ComponentsRegistry");
|
||||
while (!tableData.eof()) {
|
||||
CDComponentsRegistry entry;
|
||||
entry.id = tableData.getIntField("id", -1);
|
||||
entry.component_type = static_cast<eReplicaComponentType>(tableData.getIntField("component_type", 0));
|
||||
entry.component_id = tableData.getIntField("component_id", -1);
|
||||
|
||||
this->mappedEntries.insert_or_assign(((uint64_t)entry.component_type) << 32 | ((uint64_t)entry.id), entry.component_id);
|
||||
this->mappedEntries.insert_or_assign(entry.id, 0);
|
||||
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
tableData.finalize();
|
||||
}
|
||||
|
||||
int32_t CDComponentsRegistryTable::GetByIDAndType(uint32_t id, eReplicaComponentType componentType, int32_t defaultValue) {
|
||||
auto exists = mappedEntries.find(id);
|
||||
if (exists != mappedEntries.end()) {
|
||||
auto iter = mappedEntries.find(((uint64_t)componentType) << 32 | ((uint64_t)id));
|
||||
return iter == mappedEntries.end() ? defaultValue : iter->second;
|
||||
}
|
||||
|
||||
// Now get the data. Get all components of this entity so we dont do a query for each component
|
||||
auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM ComponentsRegistry WHERE id = ?;");
|
||||
query.bind(1, static_cast<int32_t>(id));
|
||||
|
||||
auto tableData = query.execQuery();
|
||||
|
||||
while (!tableData.eof()) {
|
||||
CDComponentsRegistry entry;
|
||||
entry.id = tableData.getIntField("id", -1);
|
||||
@ -33,61 +43,10 @@ CDComponentsRegistryTable::CDComponentsRegistryTable(void) {
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
tableData.finalize();
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t CDComponentsRegistryTable::GetByIDAndType(uint32_t id, eReplicaComponentType componentType, int32_t defaultValue) {
|
||||
const auto& iter = this->mappedEntries.find(((uint64_t)componentType) << 32 | ((uint64_t)id));
|
||||
|
||||
if (iter == this->mappedEntries.end()) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
return iter->second;
|
||||
|
||||
#ifndef CDCLIENT_CACHE_ALL
|
||||
// Now get the data
|
||||
std::stringstream query;
|
||||
|
||||
query << "SELECT * FROM ComponentsRegistry WHERE id = " << std::to_string(id);
|
||||
|
||||
auto tableData = CDClientDatabase::ExecuteQuery(query.str());
|
||||
while (!tableData.eof()) {
|
||||
CDComponentsRegistry entry;
|
||||
entry.id = tableData.getIntField("id", -1);
|
||||
entry.component_type = tableData.getIntField("component_type", -1);
|
||||
entry.component_id = tableData.getIntField("component_id", -1);
|
||||
|
||||
//this->entries.push_back(entry);
|
||||
|
||||
//Darwin's stuff:
|
||||
const auto& it = this->mappedEntries.find(entry.id);
|
||||
if (it != mappedEntries.end()) {
|
||||
const auto& iter = it->second.find(entry.component_type);
|
||||
if (iter == it->second.end()) {
|
||||
it->second.insert(std::make_pair(entry.component_type, entry.component_id));
|
||||
}
|
||||
} else {
|
||||
std::map<unsigned int, unsigned int> map;
|
||||
map.insert(std::make_pair(entry.component_type, entry.component_id));
|
||||
this->mappedEntries.insert(std::make_pair(entry.id, map));
|
||||
}
|
||||
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
tableData.finalize();
|
||||
|
||||
const auto& it2 = this->mappedEntries.find(id);
|
||||
if (it2 != mappedEntries.end()) {
|
||||
const auto& iter = it2->second.find(componentType);
|
||||
if (iter != it2->second.end()) {
|
||||
return iter->second;
|
||||
}
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
#endif
|
||||
mappedEntries.insert_or_assign(id, 0);
|
||||
|
||||
auto iter = this->mappedEntries.find(((uint64_t)componentType) << 32 | ((uint64_t)id));
|
||||
|
||||
return iter == this->mappedEntries.end() ? defaultValue : iter->second;
|
||||
}
|
||||
|
||||
|
@ -13,9 +13,9 @@ struct CDComponentsRegistry {
|
||||
|
||||
class CDComponentsRegistryTable : public CDTable<CDComponentsRegistryTable> {
|
||||
private:
|
||||
std::map<uint64_t, uint32_t> mappedEntries; //id, component_type, component_id
|
||||
std::unordered_map<uint64_t, uint32_t> mappedEntries; //id, component_type, component_id
|
||||
|
||||
public:
|
||||
CDComponentsRegistryTable();
|
||||
void LoadValuesFromDatabase();
|
||||
int32_t GetByIDAndType(uint32_t id, eReplicaComponentType componentType, int32_t defaultValue = 0);
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "CDCurrencyTableTable.h"
|
||||
|
||||
//! Constructor
|
||||
CDCurrencyTableTable::CDCurrencyTableTable(void) {
|
||||
void CDCurrencyTableTable::LoadValuesFromDatabase() {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@ -43,7 +43,7 @@ std::vector<CDCurrencyTable> CDCurrencyTableTable::Query(std::function<bool(CDCu
|
||||
return data;
|
||||
}
|
||||
|
||||
std::vector<CDCurrencyTable> CDCurrencyTableTable::GetEntries(void) const {
|
||||
const std::vector<CDCurrencyTable>& CDCurrencyTableTable::GetEntries() const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
@ -23,9 +23,9 @@ private:
|
||||
std::vector<CDCurrencyTable> entries;
|
||||
|
||||
public:
|
||||
CDCurrencyTableTable();
|
||||
void LoadValuesFromDatabase();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDCurrencyTable> Query(std::function<bool(CDCurrencyTable)> predicate);
|
||||
|
||||
std::vector<CDCurrencyTable> GetEntries(void) const;
|
||||
const std::vector<CDCurrencyTable>& GetEntries() const;
|
||||
};
|
||||
|
@ -1,8 +1,6 @@
|
||||
#include "CDDestructibleComponentTable.h"
|
||||
|
||||
//! Constructor
|
||||
CDDestructibleComponentTable::CDDestructibleComponentTable(void) {
|
||||
|
||||
void CDDestructibleComponentTable::LoadValuesFromDatabase() {
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM DestructibleComponent");
|
||||
@ -52,7 +50,7 @@ std::vector<CDDestructibleComponent> CDDestructibleComponentTable::Query(std::fu
|
||||
return data;
|
||||
}
|
||||
|
||||
std::vector<CDDestructibleComponent> CDDestructibleComponentTable::GetEntries(void) const {
|
||||
const std::vector<CDDestructibleComponent>& CDDestructibleComponentTable::GetEntries() const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
@ -25,9 +25,9 @@ private:
|
||||
std::vector<CDDestructibleComponent> entries;
|
||||
|
||||
public:
|
||||
CDDestructibleComponentTable();
|
||||
void LoadValuesFromDatabase();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDDestructibleComponent> Query(std::function<bool(CDDestructibleComponent)> predicate);
|
||||
|
||||
std::vector<CDDestructibleComponent> GetEntries(void) const;
|
||||
const std::vector<CDDestructibleComponent>& GetEntries(void) const;
|
||||
};
|
||||
|
@ -1,40 +1,26 @@
|
||||
#include "CDEmoteTable.h"
|
||||
|
||||
//! Constructor
|
||||
CDEmoteTableTable::CDEmoteTableTable(void) {
|
||||
void CDEmoteTableTable::LoadValuesFromDatabase() {
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Emotes");
|
||||
while (!tableData.eof()) {
|
||||
CDEmoteTable* entry = new CDEmoteTable();
|
||||
entry->ID = tableData.getIntField("id", -1);
|
||||
entry->animationName = tableData.getStringField("animationName", "");
|
||||
entry->iconFilename = tableData.getStringField("iconFilename", "");
|
||||
entry->channel = tableData.getIntField("channel", -1);
|
||||
entry->locked = tableData.getIntField("locked", -1) != 0;
|
||||
entry->localize = tableData.getIntField("localize", -1) != 0;
|
||||
entry->locState = tableData.getIntField("locStatus", -1);
|
||||
entry->gateVersion = tableData.getStringField("gate_version", "");
|
||||
CDEmoteTable entry;
|
||||
entry.ID = tableData.getIntField("id", -1);
|
||||
entry.animationName = tableData.getStringField("animationName", "");
|
||||
entry.iconFilename = tableData.getStringField("iconFilename", "");
|
||||
entry.channel = tableData.getIntField("channel", -1);
|
||||
entry.locked = tableData.getIntField("locked", -1) != 0;
|
||||
entry.localize = tableData.getIntField("localize", -1) != 0;
|
||||
entry.locState = tableData.getIntField("locStatus", -1);
|
||||
entry.gateVersion = tableData.getStringField("gate_version", "");
|
||||
|
||||
entries.insert(std::make_pair(entry->ID, entry));
|
||||
entries.insert(std::make_pair(entry.ID, entry));
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
tableData.finalize();
|
||||
}
|
||||
|
||||
//! Destructor
|
||||
CDEmoteTableTable::~CDEmoteTableTable(void) {
|
||||
for (auto e : entries) {
|
||||
if (e.second) delete e.second;
|
||||
}
|
||||
|
||||
entries.clear();
|
||||
}
|
||||
|
||||
CDEmoteTable* CDEmoteTableTable::GetEmote(int id) {
|
||||
for (auto e : entries) {
|
||||
if (e.first == id) return e.second;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
auto itr = entries.find(id);
|
||||
return itr != entries.end() ? &itr->second : nullptr;
|
||||
}
|
||||
|
||||
|
@ -28,11 +28,10 @@ struct CDEmoteTable {
|
||||
|
||||
class CDEmoteTableTable : public CDTable<CDEmoteTableTable> {
|
||||
private:
|
||||
std::map<int, CDEmoteTable*> entries;
|
||||
std::map<int, CDEmoteTable> entries;
|
||||
|
||||
public:
|
||||
CDEmoteTableTable();
|
||||
~CDEmoteTableTable();
|
||||
void LoadValuesFromDatabase();
|
||||
// Returns an emote by ID
|
||||
CDEmoteTable* GetEmote(int id);
|
||||
};
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "CDFeatureGatingTable.h"
|
||||
|
||||
//! Constructor
|
||||
CDFeatureGatingTable::CDFeatureGatingTable(void) {
|
||||
void CDFeatureGatingTable::LoadValuesFromDatabase() {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@ -53,7 +52,7 @@ bool CDFeatureGatingTable::FeatureUnlocked(const std::string& feature) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<CDFeatureGating> CDFeatureGatingTable::GetEntries(void) const {
|
||||
const std::vector<CDFeatureGating>& CDFeatureGatingTable::GetEntries() const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
@ -16,11 +16,12 @@ private:
|
||||
std::vector<CDFeatureGating> entries;
|
||||
|
||||
public:
|
||||
CDFeatureGatingTable();
|
||||
void LoadValuesFromDatabase();
|
||||
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDFeatureGating> Query(std::function<bool(CDFeatureGating)> predicate);
|
||||
|
||||
bool FeatureUnlocked(const std::string& feature) const;
|
||||
|
||||
std::vector<CDFeatureGating> GetEntries(void) const;
|
||||
const std::vector<CDFeatureGating>& GetEntries(void) const;
|
||||
};
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "CDInventoryComponentTable.h"
|
||||
|
||||
//! Constructor
|
||||
CDInventoryComponentTable::CDInventoryComponentTable(void) {
|
||||
void CDInventoryComponentTable::LoadValuesFromDatabase() {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@ -42,7 +41,7 @@ std::vector<CDInventoryComponent> CDInventoryComponentTable::Query(std::function
|
||||
return data;
|
||||
}
|
||||
|
||||
std::vector<CDInventoryComponent> CDInventoryComponentTable::GetEntries(void) const {
|
||||
const std::vector<CDInventoryComponent>& CDInventoryComponentTable::GetEntries() const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
@ -15,9 +15,9 @@ private:
|
||||
std::vector<CDInventoryComponent> entries;
|
||||
|
||||
public:
|
||||
CDInventoryComponentTable();
|
||||
void LoadValuesFromDatabase();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDInventoryComponent> Query(std::function<bool(CDInventoryComponent)> predicate);
|
||||
|
||||
std::vector<CDInventoryComponent> GetEntries(void) const;
|
||||
const std::vector<CDInventoryComponent>& GetEntries() const;
|
||||
};
|
||||
|
@ -3,11 +3,7 @@
|
||||
|
||||
CDItemComponent CDItemComponentTable::Default = {};
|
||||
|
||||
//! Constructor
|
||||
CDItemComponentTable::CDItemComponentTable(void) {
|
||||
Default = CDItemComponent();
|
||||
|
||||
#ifdef CDCLIENT_CACHE_ALL
|
||||
void CDItemComponentTable::LoadValuesFromDatabase() {
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ItemComponent");
|
||||
@ -55,13 +51,13 @@ CDItemComponentTable::CDItemComponentTable(void) {
|
||||
entry.currencyLOT = tableData.getIntField("currencyLOT", -1);
|
||||
entry.altCurrencyCost = tableData.getIntField("altCurrencyCost", -1);
|
||||
entry.subItems = tableData.getStringField("subItems", "");
|
||||
entry.audioEventUse = tableData.getStringField("audioEventUse", "");
|
||||
UNUSED_COLUMN(entry.audioEventUse = tableData.getStringField("audioEventUse", ""));
|
||||
entry.noEquipAnimation = tableData.getIntField("noEquipAnimation", -1) == 1 ? true : false;
|
||||
entry.commendationLOT = tableData.getIntField("commendationLOT", -1);
|
||||
entry.commendationCost = tableData.getIntField("commendationCost", -1);
|
||||
entry.audioEquipMetaEventSet = tableData.getStringField("audioEquipMetaEventSet", "");
|
||||
UNUSED_COLUMN(entry.audioEquipMetaEventSet = tableData.getStringField("audioEquipMetaEventSet", ""));
|
||||
entry.currencyCosts = tableData.getStringField("currencyCosts", "");
|
||||
entry.ingredientInfo = tableData.getStringField("ingredientInfo", "");
|
||||
UNUSED_COLUMN(entry.ingredientInfo = tableData.getStringField("ingredientInfo", ""));
|
||||
entry.locStatus = tableData.getIntField("locStatus", -1);
|
||||
entry.forgeType = tableData.getIntField("forgeType", -1);
|
||||
entry.SellMultiplier = tableData.getFloatField("SellMultiplier", -1.0f);
|
||||
@ -71,7 +67,6 @@ CDItemComponentTable::CDItemComponentTable(void) {
|
||||
}
|
||||
|
||||
tableData.finalize();
|
||||
#endif
|
||||
}
|
||||
|
||||
const CDItemComponent& CDItemComponentTable::GetItemComponentByID(unsigned int skillID) {
|
||||
@ -80,12 +75,10 @@ const CDItemComponent& CDItemComponentTable::GetItemComponentByID(unsigned int s
|
||||
return it->second;
|
||||
}
|
||||
|
||||
#ifndef CDCLIENT_CACHE_ALL
|
||||
std::stringstream query;
|
||||
auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM ItemComponent WHERE id = ?;");
|
||||
query.bind(1, static_cast<int32_t>(skillID));
|
||||
|
||||
query << "SELECT * FROM ItemComponent WHERE id = " << std::to_string(skillID);
|
||||
|
||||
auto tableData = CDClientDatabase::ExecuteQuery(query.str());
|
||||
auto tableData = query.execQuery();
|
||||
if (tableData.eof()) {
|
||||
entries.insert(std::make_pair(skillID, Default));
|
||||
return Default;
|
||||
@ -144,7 +137,6 @@ const CDItemComponent& CDItemComponentTable::GetItemComponentByID(unsigned int s
|
||||
if (it2 != this->entries.end()) {
|
||||
return it2->second;
|
||||
}
|
||||
#endif
|
||||
|
||||
return Default;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ private:
|
||||
std::map<unsigned int, CDItemComponent> entries;
|
||||
|
||||
public:
|
||||
CDItemComponentTable();
|
||||
void LoadValuesFromDatabase();
|
||||
static std::map<LOT, uint32_t> ParseCraftingCurrencies(const CDItemComponent& itemComponent);
|
||||
|
||||
// Gets an entry by ID
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "CDItemSetSkillsTable.h"
|
||||
|
||||
//! Constructor
|
||||
CDItemSetSkillsTable::CDItemSetSkillsTable(void) {
|
||||
void CDItemSetSkillsTable::LoadValuesFromDatabase() {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@ -41,7 +40,7 @@ std::vector<CDItemSetSkills> CDItemSetSkillsTable::Query(std::function<bool(CDIt
|
||||
return data;
|
||||
}
|
||||
|
||||
std::vector<CDItemSetSkills> CDItemSetSkillsTable::GetEntries(void) const {
|
||||
const std::vector<CDItemSetSkills>& CDItemSetSkillsTable::GetEntries() const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
@ -14,11 +14,11 @@ private:
|
||||
std::vector<CDItemSetSkills> entries;
|
||||
|
||||
public:
|
||||
CDItemSetSkillsTable();
|
||||
void LoadValuesFromDatabase();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDItemSetSkills> Query(std::function<bool(CDItemSetSkills)> predicate);
|
||||
|
||||
std::vector<CDItemSetSkills> GetEntries(void) const;
|
||||
const std::vector<CDItemSetSkills>& GetEntries() const;
|
||||
|
||||
std::vector<CDItemSetSkills> GetBySkillID(unsigned int SkillSetID);
|
||||
};
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "CDItemSetsTable.h"
|
||||
|
||||
//! Constructor
|
||||
CDItemSetsTable::CDItemSetsTable(void) {
|
||||
void CDItemSetsTable::LoadValuesFromDatabase() {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@ -53,7 +52,7 @@ std::vector<CDItemSets> CDItemSetsTable::Query(std::function<bool(CDItemSets)> p
|
||||
return data;
|
||||
}
|
||||
|
||||
std::vector<CDItemSets> CDItemSetsTable::GetEntries(void) const {
|
||||
const std::vector<CDItemSets>& CDItemSetsTable::GetEntries() const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
@ -26,10 +26,10 @@ private:
|
||||
std::vector<CDItemSets> entries;
|
||||
|
||||
public:
|
||||
CDItemSetsTable();
|
||||
void LoadValuesFromDatabase();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDItemSets> Query(std::function<bool(CDItemSets)> predicate);
|
||||
|
||||
std::vector<CDItemSets> GetEntries(void) const;
|
||||
const std::vector<CDItemSets>& GetEntries(void) const;
|
||||
};
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "CDLevelProgressionLookupTable.h"
|
||||
|
||||
//! Constructor
|
||||
CDLevelProgressionLookupTable::CDLevelProgressionLookupTable(void) {
|
||||
void CDLevelProgressionLookupTable::LoadValuesFromDatabase() {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@ -32,7 +31,6 @@ CDLevelProgressionLookupTable::CDLevelProgressionLookupTable(void) {
|
||||
tableData.finalize();
|
||||
}
|
||||
|
||||
//! Queries the table with a custom "where" clause
|
||||
std::vector<CDLevelProgressionLookup> CDLevelProgressionLookupTable::Query(std::function<bool(CDLevelProgressionLookup)> predicate) {
|
||||
|
||||
std::vector<CDLevelProgressionLookup> data = cpplinq::from(this->entries)
|
||||
@ -42,8 +40,7 @@ std::vector<CDLevelProgressionLookup> CDLevelProgressionLookupTable::Query(std::
|
||||
return data;
|
||||
}
|
||||
|
||||
//! Gets all the entries in the table
|
||||
std::vector<CDLevelProgressionLookup> CDLevelProgressionLookupTable::GetEntries(void) const {
|
||||
const std::vector<CDLevelProgressionLookup>& CDLevelProgressionLookupTable::GetEntries() const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
@ -14,10 +14,10 @@ private:
|
||||
std::vector<CDLevelProgressionLookup> entries;
|
||||
|
||||
public:
|
||||
CDLevelProgressionLookupTable();
|
||||
void LoadValuesFromDatabase();
|
||||
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDLevelProgressionLookup> Query(std::function<bool(CDLevelProgressionLookup)> predicate);
|
||||
|
||||
// Gets all the entries in the table
|
||||
std::vector<CDLevelProgressionLookup> GetEntries(void) const;
|
||||
const std::vector<CDLevelProgressionLookup>& GetEntries() const;
|
||||
};
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "CDLootMatrixTable.h"
|
||||
|
||||
//! Constructor
|
||||
CDLootMatrixTable::CDLootMatrixTable(void) {
|
||||
void CDLootMatrixTable::LoadValuesFromDatabase() {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@ -47,7 +46,7 @@ std::vector<CDLootMatrix> CDLootMatrixTable::Query(std::function<bool(CDLootMatr
|
||||
return data;
|
||||
}
|
||||
|
||||
const std::vector<CDLootMatrix>& CDLootMatrixTable::GetEntries(void) const {
|
||||
const std::vector<CDLootMatrix>& CDLootMatrixTable::GetEntries() const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
@ -20,10 +20,10 @@ private:
|
||||
std::vector<CDLootMatrix> entries;
|
||||
|
||||
public:
|
||||
CDLootMatrixTable();
|
||||
void LoadValuesFromDatabase();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDLootMatrix> Query(std::function<bool(CDLootMatrix)> predicate);
|
||||
|
||||
const std::vector<CDLootMatrix>& GetEntries(void) const;
|
||||
const std::vector<CDLootMatrix>& GetEntries() const;
|
||||
};
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "CDLootTableTable.h"
|
||||
|
||||
//! Constructor
|
||||
CDLootTableTable::CDLootTableTable(void) {
|
||||
void CDLootTableTable::LoadValuesFromDatabase() {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@ -46,7 +45,7 @@ std::vector<CDLootTable> CDLootTableTable::Query(std::function<bool(CDLootTable)
|
||||
}
|
||||
|
||||
//! Gets all the entries in the table
|
||||
const std::vector<CDLootTable>& CDLootTableTable::GetEntries(void) const {
|
||||
const std::vector<CDLootTable>& CDLootTableTable::GetEntries() const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
@ -16,10 +16,10 @@ private:
|
||||
std::vector<CDLootTable> entries;
|
||||
|
||||
public:
|
||||
CDLootTableTable();
|
||||
void LoadValuesFromDatabase();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDLootTable> Query(std::function<bool(CDLootTable)> predicate);
|
||||
|
||||
const std::vector<CDLootTable>& GetEntries(void) const;
|
||||
const std::vector<CDLootTable>& GetEntries() const;
|
||||
};
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "CDMissionEmailTable.h"
|
||||
|
||||
//! Constructor
|
||||
CDMissionEmailTable::CDMissionEmailTable(void) {
|
||||
void CDMissionEmailTable::LoadValuesFromDatabase() {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@ -48,7 +47,7 @@ std::vector<CDMissionEmail> CDMissionEmailTable::Query(std::function<bool(CDMiss
|
||||
}
|
||||
|
||||
//! Gets all the entries in the table
|
||||
std::vector<CDMissionEmail> CDMissionEmailTable::GetEntries(void) const {
|
||||
const std::vector<CDMissionEmail>& CDMissionEmailTable::GetEntries() const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
@ -20,9 +20,9 @@ private:
|
||||
std::vector<CDMissionEmail> entries;
|
||||
|
||||
public:
|
||||
CDMissionEmailTable();
|
||||
void LoadValuesFromDatabase();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDMissionEmail> Query(std::function<bool(CDMissionEmail)> predicate);
|
||||
|
||||
std::vector<CDMissionEmail> GetEntries(void) const;
|
||||
const std::vector<CDMissionEmail>& GetEntries() const;
|
||||
};
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "CDMissionNPCComponentTable.h"
|
||||
|
||||
//! Constructor
|
||||
CDMissionNPCComponentTable::CDMissionNPCComponentTable(void) {
|
||||
void CDMissionNPCComponentTable::LoadValuesFromDatabase() {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@ -45,7 +44,7 @@ std::vector<CDMissionNPCComponent> CDMissionNPCComponentTable::Query(std::functi
|
||||
}
|
||||
|
||||
//! Gets all the entries in the table
|
||||
std::vector<CDMissionNPCComponent> CDMissionNPCComponentTable::GetEntries(void) const {
|
||||
const std::vector<CDMissionNPCComponent>& CDMissionNPCComponentTable::GetEntries() const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
@ -16,12 +16,12 @@ private:
|
||||
std::vector<CDMissionNPCComponent> entries;
|
||||
|
||||
public:
|
||||
CDMissionNPCComponentTable();
|
||||
void LoadValuesFromDatabase();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDMissionNPCComponent> Query(std::function<bool(CDMissionNPCComponent)> predicate);
|
||||
|
||||
// Gets all the entries in the table
|
||||
std::vector<CDMissionNPCComponent> GetEntries(void) const;
|
||||
const std::vector<CDMissionNPCComponent>& GetEntries() const;
|
||||
|
||||
};
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "CDMissionTasksTable.h"
|
||||
|
||||
//! Constructor
|
||||
CDMissionTasksTable::CDMissionTasksTable(void) {
|
||||
void CDMissionTasksTable::LoadValuesFromDatabase() {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@ -56,16 +55,14 @@ std::vector<CDMissionTasks*> CDMissionTasksTable::GetByMissionID(uint32_t missio
|
||||
|
||||
for (auto& entry : this->entries) {
|
||||
if (entry.id == missionID) {
|
||||
CDMissionTasks* task = const_cast<CDMissionTasks*>(&entry);
|
||||
|
||||
tasks.push_back(task);
|
||||
tasks.push_back(&entry);
|
||||
}
|
||||
}
|
||||
|
||||
return tasks;
|
||||
}
|
||||
|
||||
const std::vector<CDMissionTasks>& CDMissionTasksTable::GetEntries(void) const {
|
||||
const std::vector<CDMissionTasks>& CDMissionTasksTable::GetEntries() const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
@ -24,12 +24,12 @@ private:
|
||||
std::vector<CDMissionTasks> entries;
|
||||
|
||||
public:
|
||||
CDMissionTasksTable();
|
||||
void LoadValuesFromDatabase();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDMissionTasks> Query(std::function<bool(CDMissionTasks)> predicate);
|
||||
|
||||
std::vector<CDMissionTasks*> GetByMissionID(uint32_t missionID);
|
||||
|
||||
const std::vector<CDMissionTasks>& GetEntries(void) const;
|
||||
const std::vector<CDMissionTasks>& GetEntries() const;
|
||||
};
|
||||
|
||||
|
@ -2,8 +2,7 @@
|
||||
|
||||
CDMissions CDMissionsTable::Default = {};
|
||||
|
||||
//! Constructor
|
||||
CDMissionsTable::CDMissionsTable(void) {
|
||||
void CDMissionsTable::LoadValuesFromDatabase() {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
|
@ -65,12 +65,12 @@ private:
|
||||
std::vector<CDMissions> entries;
|
||||
|
||||
public:
|
||||
CDMissionsTable();
|
||||
void LoadValuesFromDatabase();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDMissions> Query(std::function<bool(CDMissions)> predicate);
|
||||
|
||||
// Gets all the entries in the table
|
||||
const std::vector<CDMissions>& GetEntries(void) const;
|
||||
const std::vector<CDMissions>& GetEntries() const;
|
||||
|
||||
const CDMissions* GetPtrByMissionID(uint32_t missionID) const;
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "CDMovementAIComponentTable.h"
|
||||
|
||||
//! Constructor
|
||||
CDMovementAIComponentTable::CDMovementAIComponentTable(void) {
|
||||
void CDMovementAIComponentTable::LoadValuesFromDatabase() {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@ -37,7 +36,6 @@ CDMovementAIComponentTable::CDMovementAIComponentTable(void) {
|
||||
tableData.finalize();
|
||||
}
|
||||
|
||||
//! Queries the table with a custom "where" clause
|
||||
std::vector<CDMovementAIComponent> CDMovementAIComponentTable::Query(std::function<bool(CDMovementAIComponent)> predicate) {
|
||||
|
||||
std::vector<CDMovementAIComponent> data = cpplinq::from(this->entries)
|
||||
@ -47,8 +45,7 @@ std::vector<CDMovementAIComponent> CDMovementAIComponentTable::Query(std::functi
|
||||
return data;
|
||||
}
|
||||
|
||||
//! Gets all the entries in the table
|
||||
std::vector<CDMovementAIComponent> CDMovementAIComponentTable::GetEntries(void) const {
|
||||
const std::vector<CDMovementAIComponent>& CDMovementAIComponentTable::GetEntries(void) const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
@ -19,10 +19,10 @@ private:
|
||||
std::vector<CDMovementAIComponent> entries;
|
||||
|
||||
public:
|
||||
CDMovementAIComponentTable();
|
||||
void LoadValuesFromDatabase();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDMovementAIComponent> Query(std::function<bool(CDMovementAIComponent)> predicate);
|
||||
|
||||
// Gets all the entries in the table
|
||||
std::vector<CDMovementAIComponent> GetEntries(void) const;
|
||||
const std::vector<CDMovementAIComponent>& GetEntries() const;
|
||||
};
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "CDObjectSkillsTable.h"
|
||||
|
||||
//! Constructor
|
||||
CDObjectSkillsTable::CDObjectSkillsTable(void) {
|
||||
void CDObjectSkillsTable::LoadValuesFromDatabase() {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@ -33,7 +32,6 @@ CDObjectSkillsTable::CDObjectSkillsTable(void) {
|
||||
tableData.finalize();
|
||||
}
|
||||
|
||||
//! Queries the table with a custom "where" clause
|
||||
std::vector<CDObjectSkills> CDObjectSkillsTable::Query(std::function<bool(CDObjectSkills)> predicate) {
|
||||
|
||||
std::vector<CDObjectSkills> data = cpplinq::from(this->entries)
|
||||
@ -43,7 +41,6 @@ std::vector<CDObjectSkills> CDObjectSkillsTable::Query(std::function<bool(CDObje
|
||||
return data;
|
||||
}
|
||||
|
||||
//! Gets all the entries in the table
|
||||
std::vector<CDObjectSkills> CDObjectSkillsTable::GetEntries(void) const {
|
||||
const std::vector<CDObjectSkills>& CDObjectSkillsTable::GetEntries() const {
|
||||
return this->entries;
|
||||
}
|
||||
|
@ -15,12 +15,12 @@ private:
|
||||
std::vector<CDObjectSkills> entries;
|
||||
|
||||
public:
|
||||
CDObjectSkillsTable();
|
||||
void LoadValuesFromDatabase();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDObjectSkills> Query(std::function<bool(CDObjectSkills)> predicate);
|
||||
|
||||
// Gets all the entries in the table
|
||||
std::vector<CDObjectSkills> GetEntries(void) const;
|
||||
const std::vector<CDObjectSkills>& GetEntries() const;
|
||||
|
||||
};
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
#include "CDObjectsTable.h"
|
||||
|
||||
//! Constructor
|
||||
CDObjectsTable::CDObjectsTable(void) {
|
||||
#ifdef CDCLIENT_CACHE_ALL
|
||||
void CDObjectsTable::LoadValuesFromDatabase() {
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM Objects");
|
||||
@ -20,25 +18,24 @@ CDObjectsTable::CDObjectsTable(void) {
|
||||
CDObjects entry;
|
||||
entry.id = tableData.getIntField("id", -1);
|
||||
entry.name = tableData.getStringField("name", "");
|
||||
entry.placeable = tableData.getIntField("placeable", -1);
|
||||
UNUSED_COLUMN(entry.placeable = tableData.getIntField("placeable", -1);)
|
||||
entry.type = tableData.getStringField("type", "");
|
||||
entry.description = tableData.getStringField("description", "");
|
||||
entry.localize = tableData.getIntField("localize", -1);
|
||||
entry.npcTemplateID = tableData.getIntField("npcTemplateID", -1);
|
||||
entry.displayName = tableData.getStringField("displayName", "");
|
||||
UNUSED_COLUMN(entry.description = tableData.getStringField("description", "");)
|
||||
UNUSED_COLUMN(entry.localize = tableData.getIntField("localize", -1);)
|
||||
UNUSED_COLUMN(entry.npcTemplateID = tableData.getIntField("npcTemplateID", -1);)
|
||||
UNUSED_COLUMN(entry.displayName = tableData.getStringField("displayName", "");)
|
||||
entry.interactionDistance = tableData.getFloatField("interactionDistance", -1.0f);
|
||||
entry.nametag = tableData.getIntField("nametag", -1);
|
||||
entry._internalNotes = tableData.getStringField("_internalNotes", "");
|
||||
entry.locStatus = tableData.getIntField("locStatus", -1);
|
||||
entry.gate_version = tableData.getStringField("gate_version", "");
|
||||
entry.HQ_valid = tableData.getIntField("HQ_valid", -1);
|
||||
UNUSED_COLUMN(entry.nametag = tableData.getIntField("nametag", -1);)
|
||||
UNUSED_COLUMN(entry._internalNotes = tableData.getStringField("_internalNotes", "");)
|
||||
UNUSED_COLUMN(entry.locStatus = tableData.getIntField("locStatus", -1);)
|
||||
UNUSED_COLUMN(entry.gate_version = tableData.getStringField("gate_version", "");)
|
||||
UNUSED_COLUMN(entry.HQ_valid = tableData.getIntField("HQ_valid", -1);)
|
||||
|
||||
this->entries.insert(std::make_pair(entry.id, entry));
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
tableData.finalize();
|
||||
#endif
|
||||
|
||||
m_default.id = 0;
|
||||
}
|
||||
@ -49,12 +46,10 @@ const CDObjects& CDObjectsTable::GetByID(unsigned int LOT) {
|
||||
return it->second;
|
||||
}
|
||||
|
||||
#ifndef CDCLIENT_CACHE_ALL
|
||||
std::stringstream query;
|
||||
auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM Objects WHERE id = ?;");
|
||||
query.bind(1, static_cast<int32_t>(LOT));
|
||||
|
||||
query << "SELECT * FROM Objects WHERE id = " << std::to_string(LOT);
|
||||
|
||||
auto tableData = CDClientDatabase::ExecuteQuery(query.str());
|
||||
auto tableData = query.execQuery();
|
||||
if (tableData.eof()) {
|
||||
this->entries.insert(std::make_pair(LOT, m_default));
|
||||
return m_default;
|
||||
@ -88,7 +83,6 @@ const CDObjects& CDObjectsTable::GetByID(unsigned int LOT) {
|
||||
if (it2 != entries.end()) {
|
||||
return it2->second;
|
||||
}
|
||||
#endif
|
||||
|
||||
return m_default;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ private:
|
||||
CDObjects m_default;
|
||||
|
||||
public:
|
||||
CDObjectsTable();
|
||||
void LoadValuesFromDatabase();
|
||||
// Gets an entry by ID
|
||||
const CDObjects& GetByID(unsigned int LOT);
|
||||
};
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "CDPackageComponentTable.h"
|
||||
|
||||
//! Constructor
|
||||
CDPackageComponentTable::CDPackageComponentTable(void) {
|
||||
void CDPackageComponentTable::LoadValuesFromDatabase() {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@ -43,7 +42,7 @@ std::vector<CDPackageComponent> CDPackageComponentTable::Query(std::function<boo
|
||||
}
|
||||
|
||||
//! Gets all the entries in the table
|
||||
std::vector<CDPackageComponent> CDPackageComponentTable::GetEntries(void) const {
|
||||
const std::vector<CDPackageComponent>& CDPackageComponentTable::GetEntries() const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
@ -14,9 +14,9 @@ private:
|
||||
std::vector<CDPackageComponent> entries;
|
||||
|
||||
public:
|
||||
CDPackageComponentTable(void);
|
||||
void LoadValuesFromDatabase();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDPackageComponent> Query(std::function<bool(CDPackageComponent)> predicate);
|
||||
|
||||
std::vector<CDPackageComponent> GetEntries(void) const;
|
||||
const std::vector<CDPackageComponent>& GetEntries() const;
|
||||
};
|
||||
|
@ -1,46 +1,35 @@
|
||||
#include "CDPhysicsComponentTable.h"
|
||||
|
||||
CDPhysicsComponentTable::CDPhysicsComponentTable(void) {
|
||||
void CDPhysicsComponentTable::LoadValuesFromDatabase() {
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM PhysicsComponent");
|
||||
while (!tableData.eof()) {
|
||||
CDPhysicsComponent* entry = new CDPhysicsComponent();
|
||||
entry->id = tableData.getIntField("id", -1);
|
||||
entry->bStatic = tableData.getIntField("static", -1) != 0;
|
||||
entry->physicsAsset = tableData.getStringField("physics_asset", "");
|
||||
CDPhysicsComponent entry;
|
||||
entry.id = tableData.getIntField("id", -1);
|
||||
entry.bStatic = tableData.getIntField("static", -1) != 0;
|
||||
entry.physicsAsset = tableData.getStringField("physics_asset", "");
|
||||
UNUSED(entry->jump = tableData.getIntField("jump", -1) != 0);
|
||||
UNUSED(entry->doublejump = tableData.getIntField("doublejump", -1) != 0);
|
||||
entry->speed = tableData.getFloatField("speed", -1);
|
||||
entry.speed = tableData.getFloatField("speed", -1);
|
||||
UNUSED(entry->rotSpeed = tableData.getFloatField("rotSpeed", -1));
|
||||
entry->playerHeight = tableData.getFloatField("playerHeight");
|
||||
entry->playerRadius = tableData.getFloatField("playerRadius");
|
||||
entry->pcShapeType = tableData.getIntField("pcShapeType");
|
||||
entry->collisionGroup = tableData.getIntField("collisionGroup");
|
||||
entry.playerHeight = tableData.getFloatField("playerHeight");
|
||||
entry.playerRadius = tableData.getFloatField("playerRadius");
|
||||
entry.pcShapeType = tableData.getIntField("pcShapeType");
|
||||
entry.collisionGroup = tableData.getIntField("collisionGroup");
|
||||
UNUSED(entry->airSpeed = tableData.getFloatField("airSpeed"));
|
||||
UNUSED(entry->boundaryAsset = tableData.getStringField("boundaryAsset"));
|
||||
UNUSED(entry->jumpAirSpeed = tableData.getFloatField("jumpAirSpeed"));
|
||||
UNUSED(entry->friction = tableData.getFloatField("friction"));
|
||||
UNUSED(entry->gravityVolumeAsset = tableData.getStringField("gravityVolumeAsset"));
|
||||
|
||||
m_entries.insert(std::make_pair(entry->id, entry));
|
||||
m_entries.insert(std::make_pair(entry.id, entry));
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
tableData.finalize();
|
||||
}
|
||||
|
||||
CDPhysicsComponentTable::~CDPhysicsComponentTable() {
|
||||
for (auto e : m_entries) {
|
||||
if (e.second) delete e.second;
|
||||
}
|
||||
|
||||
m_entries.clear();
|
||||
}
|
||||
|
||||
CDPhysicsComponent* CDPhysicsComponentTable::GetByID(unsigned int componentID) {
|
||||
for (auto e : m_entries) {
|
||||
if (e.first == componentID) return e.second;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
auto itr = m_entries.find(componentID);
|
||||
return itr != m_entries.end() ? &itr->second : nullptr;
|
||||
}
|
||||
|
||||
|
@ -23,12 +23,11 @@ struct CDPhysicsComponent {
|
||||
|
||||
class CDPhysicsComponentTable : public CDTable<CDPhysicsComponentTable> {
|
||||
public:
|
||||
CDPhysicsComponentTable();
|
||||
~CDPhysicsComponentTable();
|
||||
void LoadValuesFromDatabase();
|
||||
|
||||
static const std::string GetTableName() { return "PhysicsComponent"; };
|
||||
CDPhysicsComponent* GetByID(unsigned int componentID);
|
||||
|
||||
private:
|
||||
std::map<unsigned int, CDPhysicsComponent*> m_entries;
|
||||
std::map<unsigned int, CDPhysicsComponent> m_entries;
|
||||
};
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "CDPropertyEntranceComponentTable.h"
|
||||
|
||||
CDPropertyEntranceComponentTable::CDPropertyEntranceComponentTable() {
|
||||
void CDPropertyEntranceComponentTable::LoadValuesFromDatabase() {
|
||||
|
||||
// First, get the size of the table
|
||||
size_t size = 0;
|
||||
|
@ -11,12 +11,12 @@ struct CDPropertyEntranceComponent {
|
||||
|
||||
class CDPropertyEntranceComponentTable : public CDTable<CDPropertyEntranceComponentTable> {
|
||||
public:
|
||||
CDPropertyEntranceComponentTable();
|
||||
void LoadValuesFromDatabase();
|
||||
// Queries the table with a custom "where" clause
|
||||
CDPropertyEntranceComponent GetByID(uint32_t id);
|
||||
|
||||
// Gets all the entries in the table
|
||||
[[nodiscard]] std::vector<CDPropertyEntranceComponent> GetEntries() const { return entries; }
|
||||
[[nodiscard]] const std::vector<CDPropertyEntranceComponent>& GetEntries() const { return entries; }
|
||||
private:
|
||||
std::vector<CDPropertyEntranceComponent> entries{};
|
||||
CDPropertyEntranceComponent defaultEntry{};
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "CDPropertyTemplateTable.h"
|
||||
|
||||
CDPropertyTemplateTable::CDPropertyTemplateTable() {
|
||||
void CDPropertyTemplateTable::LoadValuesFromDatabase() {
|
||||
|
||||
// First, get the size of the table
|
||||
size_t size = 0;
|
||||
|
@ -10,7 +10,7 @@ struct CDPropertyTemplate {
|
||||
|
||||
class CDPropertyTemplateTable : public CDTable<CDPropertyTemplateTable> {
|
||||
public:
|
||||
CDPropertyTemplateTable();
|
||||
void LoadValuesFromDatabase();
|
||||
|
||||
static const std::string GetTableName() { return "PropertyTemplate"; };
|
||||
CDPropertyTemplate GetByMapID(uint32_t mapID);
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "CDProximityMonitorComponentTable.h"
|
||||
|
||||
//! Constructor
|
||||
CDProximityMonitorComponentTable::CDProximityMonitorComponentTable(void) {
|
||||
void CDProximityMonitorComponentTable::LoadValuesFromDatabase() {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@ -33,7 +32,6 @@ CDProximityMonitorComponentTable::CDProximityMonitorComponentTable(void) {
|
||||
tableData.finalize();
|
||||
}
|
||||
|
||||
//! Queries the table with a custom "where" clause
|
||||
std::vector<CDProximityMonitorComponent> CDProximityMonitorComponentTable::Query(std::function<bool(CDProximityMonitorComponent)> predicate) {
|
||||
|
||||
std::vector<CDProximityMonitorComponent> data = cpplinq::from(this->entries)
|
||||
@ -43,8 +41,7 @@ std::vector<CDProximityMonitorComponent> CDProximityMonitorComponentTable::Query
|
||||
return data;
|
||||
}
|
||||
|
||||
//! Gets all the entries in the table
|
||||
std::vector<CDProximityMonitorComponent> CDProximityMonitorComponentTable::GetEntries(void) const {
|
||||
const std::vector<CDProximityMonitorComponent>& CDProximityMonitorComponentTable::GetEntries() const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
@ -15,9 +15,9 @@ private:
|
||||
std::vector<CDProximityMonitorComponent> entries;
|
||||
|
||||
public:
|
||||
CDProximityMonitorComponentTable(void);
|
||||
void LoadValuesFromDatabase();
|
||||
//! Queries the table with a custom "where" clause
|
||||
std::vector<CDProximityMonitorComponent> Query(std::function<bool(CDProximityMonitorComponent)> predicate);
|
||||
|
||||
std::vector<CDProximityMonitorComponent> GetEntries(void) const;
|
||||
const std::vector<CDProximityMonitorComponent>& GetEntries() const;
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "CDRailActivatorComponent.h"
|
||||
#include "GeneralUtils.h"
|
||||
|
||||
CDRailActivatorComponentTable::CDRailActivatorComponentTable() {
|
||||
void CDRailActivatorComponentTable::LoadValuesFromDatabase() {
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM RailActivatorComponent;");
|
||||
while (!tableData.eof()) {
|
||||
CDRailActivatorComponent entry;
|
||||
@ -52,7 +52,7 @@ CDRailActivatorComponent CDRailActivatorComponentTable::GetEntryByID(int32_t id)
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<CDRailActivatorComponent> CDRailActivatorComponentTable::GetEntries() const {
|
||||
const std::vector<CDRailActivatorComponent>& CDRailActivatorComponentTable::GetEntries() const {
|
||||
return m_Entries;
|
||||
}
|
||||
|
||||
|
@ -22,10 +22,10 @@ struct CDRailActivatorComponent {
|
||||
|
||||
class CDRailActivatorComponentTable : public CDTable<CDRailActivatorComponentTable> {
|
||||
public:
|
||||
CDRailActivatorComponentTable();
|
||||
void LoadValuesFromDatabase();
|
||||
static const std::string GetTableName() { return "RailActivatorComponent"; };
|
||||
[[nodiscard]] CDRailActivatorComponent GetEntryByID(int32_t id) const;
|
||||
[[nodiscard]] std::vector<CDRailActivatorComponent> GetEntries() const;
|
||||
[[nodiscard]] const std::vector<CDRailActivatorComponent>& GetEntries() const;
|
||||
private:
|
||||
static std::pair<uint32_t, std::u16string> EffectPairFromString(std::string& str);
|
||||
std::vector<CDRailActivatorComponent> m_Entries{};
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "CDRarityTableTable.h"
|
||||
|
||||
//! Constructor
|
||||
CDRarityTableTable::CDRarityTableTable(void) {
|
||||
void CDRarityTableTable::LoadValuesFromDatabase() {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@ -44,7 +43,7 @@ std::vector<CDRarityTable> CDRarityTableTable::Query(std::function<bool(CDRarity
|
||||
}
|
||||
|
||||
//! Gets all the entries in the table
|
||||
const std::vector<CDRarityTable>& CDRarityTableTable::GetEntries(void) const {
|
||||
const std::vector<CDRarityTable>& CDRarityTableTable::GetEntries() const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ private:
|
||||
std::vector<CDRarityTable> entries;
|
||||
|
||||
public:
|
||||
CDRarityTableTable();
|
||||
void LoadValuesFromDatabase();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDRarityTable> Query(std::function<bool(CDRarityTable)> predicate);
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "CDRebuildComponentTable.h"
|
||||
|
||||
//! Constructor
|
||||
CDRebuildComponentTable::CDRebuildComponentTable(void) {
|
||||
void CDRebuildComponentTable::LoadValuesFromDatabase() {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@ -39,7 +38,6 @@ CDRebuildComponentTable::CDRebuildComponentTable(void) {
|
||||
tableData.finalize();
|
||||
}
|
||||
|
||||
//! Queries the table with a custom "where" clause
|
||||
std::vector<CDRebuildComponent> CDRebuildComponentTable::Query(std::function<bool(CDRebuildComponent)> predicate) {
|
||||
|
||||
std::vector<CDRebuildComponent> data = cpplinq::from(this->entries)
|
||||
@ -49,8 +47,7 @@ std::vector<CDRebuildComponent> CDRebuildComponentTable::Query(std::function<boo
|
||||
return data;
|
||||
}
|
||||
|
||||
//! Gets all the entries in the table
|
||||
std::vector<CDRebuildComponent> CDRebuildComponentTable::GetEntries(void) const {
|
||||
const std::vector<CDRebuildComponent>& CDRebuildComponentTable::GetEntries() const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
@ -21,10 +21,10 @@ private:
|
||||
std::vector<CDRebuildComponent> entries;
|
||||
|
||||
public:
|
||||
CDRebuildComponentTable();
|
||||
void LoadValuesFromDatabase();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDRebuildComponent> Query(std::function<bool(CDRebuildComponent)> predicate);
|
||||
|
||||
std::vector<CDRebuildComponent> GetEntries() const;
|
||||
const std::vector<CDRebuildComponent>& GetEntries() const;
|
||||
};
|
||||
|
||||
|
@ -1,35 +1,27 @@
|
||||
#include "CDRewardsTable.h"
|
||||
|
||||
CDRewardsTable::CDRewardsTable(void) {
|
||||
void CDRewardsTable::LoadValuesFromDatabase() {
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Rewards");
|
||||
while (!tableData.eof()) {
|
||||
CDRewards* entry = new CDRewards();
|
||||
entry->id = tableData.getIntField("id", -1);
|
||||
entry->levelID = tableData.getIntField("LevelID", -1);
|
||||
entry->missionID = tableData.getIntField("MissionID", -1);
|
||||
entry->rewardType = tableData.getIntField("RewardType", -1);
|
||||
entry->value = tableData.getIntField("value", -1);
|
||||
entry->count = tableData.getIntField("count", -1);
|
||||
CDRewards entry;
|
||||
entry.id = tableData.getIntField("id", -1);
|
||||
entry.levelID = tableData.getIntField("LevelID", -1);
|
||||
entry.missionID = tableData.getIntField("MissionID", -1);
|
||||
entry.rewardType = tableData.getIntField("RewardType", -1);
|
||||
entry.value = tableData.getIntField("value", -1);
|
||||
entry.count = tableData.getIntField("count", -1);
|
||||
|
||||
m_entries.insert(std::make_pair(entry->id, entry));
|
||||
m_entries.insert(std::make_pair(entry.id, entry));
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
tableData.finalize();
|
||||
}
|
||||
|
||||
CDRewardsTable::~CDRewardsTable(void) {
|
||||
for (auto e : m_entries) {
|
||||
if (e.second) delete e.second;
|
||||
}
|
||||
|
||||
m_entries.clear();
|
||||
}
|
||||
|
||||
std::vector<CDRewards*> CDRewardsTable::GetByLevelID(uint32_t levelID) {
|
||||
std::vector<CDRewards*> result{};
|
||||
std::vector<CDRewards> CDRewardsTable::GetByLevelID(uint32_t levelID) {
|
||||
std::vector<CDRewards> result{};
|
||||
for (const auto& e : m_entries) {
|
||||
if (e.second->levelID == levelID) result.push_back(e.second);
|
||||
if (e.second.levelID == levelID) result.push_back(e.second);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -13,12 +13,11 @@ struct CDRewards {
|
||||
|
||||
class CDRewardsTable : public CDTable<CDRewardsTable> {
|
||||
public:
|
||||
CDRewardsTable();
|
||||
~CDRewardsTable();
|
||||
void LoadValuesFromDatabase();
|
||||
|
||||
static const std::string GetTableName() { return "Rewards"; };
|
||||
std::vector<CDRewards*> GetByLevelID(uint32_t levelID);
|
||||
std::vector<CDRewards> GetByLevelID(uint32_t levelID);
|
||||
|
||||
private:
|
||||
std::map<uint32_t, CDRewards*> m_entries;
|
||||
std::map<uint32_t, CDRewards> m_entries;
|
||||
};
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "CDScriptComponentTable.h"
|
||||
|
||||
//! Constructor
|
||||
CDScriptComponentTable::CDScriptComponentTable(void) {
|
||||
void CDScriptComponentTable::LoadValuesFromDatabase() {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
|
@ -15,7 +15,7 @@ private:
|
||||
CDScriptComponent m_ToReturnWhenNoneFound;
|
||||
|
||||
public:
|
||||
CDScriptComponentTable();
|
||||
void LoadValuesFromDatabase();
|
||||
// Gets an entry by scriptID
|
||||
const CDScriptComponent& GetByID(unsigned int id);
|
||||
};
|
||||
|
@ -1,8 +1,6 @@
|
||||
#include "CDSkillBehaviorTable.h"
|
||||
//#include "Logger.hpp"
|
||||
|
||||
//! Constructor
|
||||
CDSkillBehaviorTable::CDSkillBehaviorTable(void) {
|
||||
void CDSkillBehaviorTable::LoadValuesFromDatabase() {
|
||||
m_empty = CDSkillBehavior();
|
||||
|
||||
// First, get the size of the table
|
||||
@ -51,13 +49,6 @@ CDSkillBehaviorTable::CDSkillBehaviorTable(void) {
|
||||
tableData.finalize();
|
||||
}
|
||||
|
||||
//! Queries the table with a custom "where" clause
|
||||
std::vector<CDSkillBehavior> CDSkillBehaviorTable::Query(std::function<bool(CDSkillBehavior)> predicate) {
|
||||
std::vector<CDSkillBehavior> data; //So MSVC shuts up
|
||||
return data;
|
||||
}
|
||||
|
||||
//! Gets an entry by ID
|
||||
const CDSkillBehavior& CDSkillBehaviorTable::GetSkillByID(unsigned int skillID) {
|
||||
std::map<unsigned int, CDSkillBehavior>::iterator it = this->entries.find(skillID);
|
||||
if (it != this->entries.end()) {
|
||||
|
@ -31,9 +31,7 @@ private:
|
||||
CDSkillBehavior m_empty;
|
||||
|
||||
public:
|
||||
CDSkillBehaviorTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDSkillBehavior> Query(std::function<bool(CDSkillBehavior)> predicate);
|
||||
void LoadValuesFromDatabase();
|
||||
|
||||
// Gets an entry by skillID
|
||||
const CDSkillBehavior& GetSkillByID(unsigned int skillID);
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "CDVendorComponentTable.h"
|
||||
|
||||
//! Constructor
|
||||
CDVendorComponentTable::CDVendorComponentTable(void) {
|
||||
void CDVendorComponentTable::LoadValuesFromDatabase() {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@ -22,7 +21,7 @@ CDVendorComponentTable::CDVendorComponentTable(void) {
|
||||
while (!tableData.eof()) {
|
||||
CDVendorComponent entry;
|
||||
entry.id = tableData.getIntField("id", -1);
|
||||
entry.buyScalar = tableData.getFloatField("buyScalar", -1.0f);
|
||||
entry.buyScalar = tableData.getFloatField("buyScalar", 0.0f);
|
||||
entry.sellScalar = tableData.getFloatField("sellScalar", -1.0f);
|
||||
entry.refreshTimeSeconds = tableData.getFloatField("refreshTimeSeconds", -1.0f);
|
||||
entry.LootMatrixIndex = tableData.getIntField("LootMatrixIndex", -1);
|
||||
@ -45,7 +44,7 @@ std::vector<CDVendorComponent> CDVendorComponentTable::Query(std::function<bool(
|
||||
}
|
||||
|
||||
//! Gets all the entries in the table
|
||||
std::vector<CDVendorComponent> CDVendorComponentTable::GetEntries(void) const {
|
||||
const std::vector<CDVendorComponent>& CDVendorComponentTable::GetEntries() const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
@ -16,10 +16,10 @@ private:
|
||||
std::vector<CDVendorComponent> entries;
|
||||
|
||||
public:
|
||||
CDVendorComponentTable();
|
||||
void LoadValuesFromDatabase();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDVendorComponent> Query(std::function<bool(CDVendorComponent)> predicate);
|
||||
|
||||
std::vector<CDVendorComponent> GetEntries(void) const;
|
||||
const std::vector<CDVendorComponent>& GetEntries(void) const;
|
||||
};
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "CDZoneTableTable.h"
|
||||
|
||||
//! Constructor
|
||||
CDZoneTableTable::CDZoneTableTable(void) {
|
||||
void CDZoneTableTable::LoadValuesFromDatabase() {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
|
@ -38,7 +38,7 @@ private:
|
||||
std::map<unsigned int, CDZoneTable> m_Entries;
|
||||
|
||||
public:
|
||||
CDZoneTableTable();
|
||||
void LoadValuesFromDatabase();
|
||||
|
||||
// Queries the table with a zoneID to find.
|
||||
const CDZoneTable* Query(unsigned int zoneID);
|
||||
|
@ -241,7 +241,7 @@ void Character::DoQuickXMLDataParse() {
|
||||
//To try and fix the AG landing into:
|
||||
if (m_ZoneID == 1000 && Game::server->GetZoneID() == 1100) {
|
||||
//sneakily insert our position:
|
||||
auto pos = dZoneManager::Instance()->GetZone()->GetSpawnPos();
|
||||
auto pos = Game::zoneManager->GetZone()->GetSpawnPos();
|
||||
character->SetAttribute("lzx", pos.x);
|
||||
character->SetAttribute("lzy", pos.y);
|
||||
character->SetAttribute("lzz", pos.z);
|
||||
@ -290,13 +290,13 @@ void Character::DoQuickXMLDataParse() {
|
||||
|
||||
void Character::UnlockEmote(int emoteID) {
|
||||
m_UnlockedEmotes.push_back(emoteID);
|
||||
GameMessages::SendSetEmoteLockState(EntityManager::Instance()->GetEntity(m_ObjectID), false, emoteID);
|
||||
GameMessages::SendSetEmoteLockState(Game::entityManager->GetEntity(m_ObjectID), false, emoteID);
|
||||
}
|
||||
|
||||
void Character::SetBuildMode(bool buildMode) {
|
||||
m_BuildMode = buildMode;
|
||||
|
||||
auto* controller = dZoneManager::Instance()->GetZoneControlObject();
|
||||
auto* controller = Game::zoneManager->GetZoneControlObject();
|
||||
|
||||
controller->OnFireEventServerSide(m_OurEntity, buildMode ? "OnBuildModeEnter" : "OnBuildModeLeave");
|
||||
}
|
||||
@ -312,7 +312,7 @@ void Character::SaveXMLToDatabase() {
|
||||
character->SetAttribute("gm", static_cast<uint32_t>(m_GMLevel));
|
||||
character->SetAttribute("cc", m_Coins);
|
||||
|
||||
auto zoneInfo = dZoneManager::Instance()->GetZone()->GetZoneID();
|
||||
auto zoneInfo = Game::zoneManager->GetZone()->GetZoneID();
|
||||
// lzid garbage, binary concat of zoneID, zoneInstance and zoneClone
|
||||
if (zoneInfo.GetMapID() != 0 && zoneInfo.GetCloneID() == 0) {
|
||||
uint64_t lzidConcat = zoneInfo.GetCloneID();
|
||||
@ -418,13 +418,13 @@ void Character::WriteToDatabase() {
|
||||
delete printer;
|
||||
}
|
||||
|
||||
void Character::SetPlayerFlag(const int32_t flagId, const bool value) {
|
||||
void Character::SetPlayerFlag(const uint32_t flagId, const bool value) {
|
||||
// If the flag is already set, we don't have to recalculate it
|
||||
if (GetPlayerFlag(flagId) == value) return;
|
||||
|
||||
if (value) {
|
||||
// Update the mission component:
|
||||
auto* player = EntityManager::Instance()->GetEntity(m_ObjectID);
|
||||
auto* player = Game::entityManager->GetEntity(m_ObjectID);
|
||||
|
||||
if (player != nullptr) {
|
||||
auto* missionComponent = player->GetComponent<MissionComponent>();
|
||||
@ -465,7 +465,7 @@ void Character::SetPlayerFlag(const int32_t flagId, const bool value) {
|
||||
GameMessages::SendNotifyClientFlagChange(m_ObjectID, flagId, value, m_ParentUser->GetSystemAddress());
|
||||
}
|
||||
|
||||
bool Character::GetPlayerFlag(const int32_t flagId) const {
|
||||
bool Character::GetPlayerFlag(const uint32_t flagId) const {
|
||||
// Calculate the index first
|
||||
const auto flagIndex = uint32_t(std::floor(flagId / 64));
|
||||
|
||||
@ -602,7 +602,7 @@ void Character::SetCoins(int64_t newCoins, eLootSourceType lootSource) {
|
||||
|
||||
m_Coins = newCoins;
|
||||
|
||||
GameMessages::SendSetCurrency(EntityManager::Instance()->GetEntity(m_ObjectID), m_Coins, 0, 0, 0, 0, true, lootSource);
|
||||
GameMessages::SendSetCurrency(Game::entityManager->GetEntity(m_ObjectID), m_Coins, 0, 0, 0, 0, true, lootSource);
|
||||
}
|
||||
|
||||
bool Character::HasBeenToWorld(LWOMAPID mapID) const {
|
||||
|
@ -415,14 +415,14 @@ public:
|
||||
* @param flagId the ID of the flag to set
|
||||
* @param value the value to set for the flag
|
||||
*/
|
||||
void SetPlayerFlag(int32_t flagId, bool value);
|
||||
void SetPlayerFlag(uint32_t flagId, bool value);
|
||||
|
||||
/**
|
||||
* Gets the value for a certain character flag
|
||||
* @param flagId the ID of the flag to get a value for
|
||||
* @return the value of the flag given the ID (the default is false, obviously)
|
||||
*/
|
||||
bool GetPlayerFlag(int32_t flagId) const;
|
||||
bool GetPlayerFlag(uint32_t flagId) const;
|
||||
|
||||
/**
|
||||
* Notifies the character that they're now muted
|
||||
|
142
dGame/Entity.cpp
142
dGame/Entity.cpp
@ -31,7 +31,7 @@
|
||||
#include "Component.h"
|
||||
#include "ControllablePhysicsComponent.h"
|
||||
#include "RenderComponent.h"
|
||||
#include "RocketLaunchLupComponent.h"
|
||||
#include "MultiZoneEntranceComponent.h"
|
||||
#include "CharacterComponent.h"
|
||||
#include "DestroyableComponent.h"
|
||||
#include "BuffComponent.h"
|
||||
@ -52,6 +52,7 @@
|
||||
#include "BuildBorderComponent.h"
|
||||
#include "MovementAIComponent.h"
|
||||
#include "VendorComponent.h"
|
||||
#include "DonationVendorComponent.h"
|
||||
#include "RocketLaunchpadControlComponent.h"
|
||||
#include "PropertyComponent.h"
|
||||
#include "BaseCombatAIComponent.h"
|
||||
@ -71,6 +72,7 @@
|
||||
#include "ShootingGalleryComponent.h"
|
||||
#include "RailActivatorComponent.h"
|
||||
#include "LUPExhibitComponent.h"
|
||||
#include "RacingSoundTriggerComponent.h"
|
||||
#include "TriggerComponent.h"
|
||||
#include "eGameMasterLevel.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
@ -264,17 +266,17 @@ void Entity::Initialize() {
|
||||
NiQuaternion rot;
|
||||
|
||||
const auto& targetSceneName = m_Character->GetTargetScene();
|
||||
auto* targetScene = EntityManager::Instance()->GetSpawnPointEntity(targetSceneName);
|
||||
auto* targetScene = Game::entityManager->GetSpawnPointEntity(targetSceneName);
|
||||
|
||||
if (m_Character->HasBeenToWorld(mapID) && targetSceneName.empty()) {
|
||||
pos = m_Character->GetRespawnPoint(mapID);
|
||||
rot = dZoneManager::Instance()->GetZone()->GetSpawnRot();
|
||||
rot = Game::zoneManager->GetZone()->GetSpawnRot();
|
||||
} else if (targetScene != nullptr) {
|
||||
pos = targetScene->GetPosition();
|
||||
rot = targetScene->GetRotation();
|
||||
} else {
|
||||
pos = dZoneManager::Instance()->GetZone()->GetSpawnPos();
|
||||
rot = dZoneManager::Instance()->GetZone()->GetSpawnRot();
|
||||
pos = Game::zoneManager->GetZone()->GetSpawnPos();
|
||||
rot = Game::zoneManager->GetZone()->GetSpawnRot();
|
||||
}
|
||||
|
||||
controllablePhysics->SetPosition(pos);
|
||||
@ -318,6 +320,9 @@ void Entity::Initialize() {
|
||||
if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::SOUND_TRIGGER, -1) != -1) {
|
||||
auto* comp = new SoundTriggerComponent(this);
|
||||
m_Components.insert(std::make_pair(eReplicaComponentType::SOUND_TRIGGER, comp));
|
||||
} else if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::RACING_SOUND_TRIGGER, -1) != -1) {
|
||||
auto* comp = new RacingSoundTriggerComponent(this);
|
||||
m_Components.insert(std::make_pair(eReplicaComponentType::RACING_SOUND_TRIGGER, comp));
|
||||
}
|
||||
|
||||
//Also check for the collectible id:
|
||||
@ -468,9 +473,9 @@ void Entity::Initialize() {
|
||||
m_Components.insert(std::make_pair(eReplicaComponentType::INVENTORY, comp));
|
||||
}
|
||||
// if this component exists, then we initialize it. it's value is always 0
|
||||
if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::ROCKET_LAUNCH_LUP, -1) != -1) {
|
||||
auto comp = new RocketLaunchLupComponent(this);
|
||||
m_Components.insert(std::make_pair(eReplicaComponentType::ROCKET_LAUNCH_LUP, comp));
|
||||
if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::MULTI_ZONE_ENTRANCE, -1) != -1) {
|
||||
auto comp = new MultiZoneEntranceComponent(this);
|
||||
m_Components.insert(std::make_pair(eReplicaComponentType::MULTI_ZONE_ENTRANCE, comp));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -527,7 +532,7 @@ void Entity::Initialize() {
|
||||
// ZoneControl script
|
||||
if (m_TemplateID == 2365) {
|
||||
CDZoneTableTable* zoneTable = CDClientManager::Instance().GetTable<CDZoneTableTable>();
|
||||
const auto zoneID = dZoneManager::Instance()->GetZoneID();
|
||||
const auto zoneID = Game::zoneManager->GetZoneID();
|
||||
const CDZoneTable* zoneData = zoneTable->Query(zoneID.GetMapID());
|
||||
|
||||
if (zoneData != nullptr) {
|
||||
@ -600,6 +605,9 @@ void Entity::Initialize() {
|
||||
if ((compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::VENDOR) > 0)) {
|
||||
VendorComponent* comp = new VendorComponent(this);
|
||||
m_Components.insert(std::make_pair(eReplicaComponentType::VENDOR, comp));
|
||||
} else if ((compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::DONATION_VENDOR, -1) != -1)) {
|
||||
DonationVendorComponent* comp = new DonationVendorComponent(this);
|
||||
m_Components.insert(std::make_pair(eReplicaComponentType::DONATION_VENDOR, comp));
|
||||
}
|
||||
|
||||
if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::PROPERTY_VENDOR, -1) != -1) {
|
||||
@ -713,7 +721,7 @@ void Entity::Initialize() {
|
||||
}
|
||||
|
||||
std::string pathName = GetVarAsString(u"attached_path");
|
||||
const Path* path = dZoneManager::Instance()->GetZone()->GetPath(pathName);
|
||||
const Path* path = Game::zoneManager->GetZone()->GetPath(pathName);
|
||||
|
||||
//Check to see if we have an attached path and add the appropiate component to handle it:
|
||||
if (path){
|
||||
@ -757,7 +765,7 @@ void Entity::Initialize() {
|
||||
}
|
||||
});
|
||||
|
||||
if (!m_Character && EntityManager::Instance()->GetGhostingEnabled()) {
|
||||
if (!m_Character && Game::entityManager->GetGhostingEnabled()) {
|
||||
// Don't ghost what is likely large scene elements
|
||||
if (HasComponent(eReplicaComponentType::SIMPLE_PHYSICS) && HasComponent(eReplicaComponentType::RENDER) && (m_Components.size() == 2 || (HasComponent(eReplicaComponentType::TRIGGER) && m_Components.size() == 3))) {
|
||||
goto no_ghosting;
|
||||
@ -1034,57 +1042,60 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType
|
||||
*/
|
||||
|
||||
bool destroyableSerialized = false;
|
||||
bool bIsInitialUpdate = false;
|
||||
if (packetType == eReplicaPacketType::CONSTRUCTION) bIsInitialUpdate = true;
|
||||
unsigned int flags = 0;
|
||||
bool bIsInitialUpdate = packetType == eReplicaPacketType::CONSTRUCTION;
|
||||
|
||||
PossessableComponent* possessableComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::POSSESSABLE, possessableComponent)) {
|
||||
possessableComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
possessableComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
|
||||
ModuleAssemblyComponent* moduleAssemblyComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::MODULE_ASSEMBLY, moduleAssemblyComponent)) {
|
||||
moduleAssemblyComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
moduleAssemblyComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
|
||||
ControllablePhysicsComponent* controllablePhysicsComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS, controllablePhysicsComponent)) {
|
||||
controllablePhysicsComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
controllablePhysicsComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
|
||||
SimplePhysicsComponent* simplePhysicsComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::SIMPLE_PHYSICS, simplePhysicsComponent)) {
|
||||
simplePhysicsComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
simplePhysicsComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
|
||||
RigidbodyPhantomPhysicsComponent* rigidbodyPhantomPhysics;
|
||||
if (TryGetComponent(eReplicaComponentType::RIGID_BODY_PHANTOM_PHYSICS, rigidbodyPhantomPhysics)) {
|
||||
rigidbodyPhantomPhysics->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
rigidbodyPhantomPhysics->Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
|
||||
VehiclePhysicsComponent* vehiclePhysicsComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::VEHICLE_PHYSICS, vehiclePhysicsComponent)) {
|
||||
vehiclePhysicsComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
vehiclePhysicsComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
|
||||
PhantomPhysicsComponent* phantomPhysicsComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::PHANTOM_PHYSICS, phantomPhysicsComponent)) {
|
||||
phantomPhysicsComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
phantomPhysicsComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
|
||||
SoundTriggerComponent* soundTriggerComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::SOUND_TRIGGER, soundTriggerComponent)) {
|
||||
soundTriggerComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
soundTriggerComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
|
||||
RacingSoundTriggerComponent* racingSoundTriggerComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::RACING_SOUND_TRIGGER, racingSoundTriggerComponent)) {
|
||||
racingSoundTriggerComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
|
||||
BuffComponent* buffComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::BUFF, buffComponent)) {
|
||||
buffComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
buffComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
|
||||
DestroyableComponent* destroyableComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent)) {
|
||||
destroyableComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
destroyableComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
destroyableSerialized = true;
|
||||
}
|
||||
@ -1092,7 +1103,7 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType
|
||||
if (HasComponent(eReplicaComponentType::COLLECTIBLE)) {
|
||||
DestroyableComponent* destroyableComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent) && !destroyableSerialized) {
|
||||
destroyableComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
destroyableComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
destroyableSerialized = true;
|
||||
outBitStream->Write(m_CollectibleID); // Collectable component
|
||||
@ -1100,7 +1111,7 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType
|
||||
|
||||
PetComponent* petComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::PET, petComponent)) {
|
||||
petComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
petComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
|
||||
CharacterComponent* characterComponent;
|
||||
@ -1108,7 +1119,7 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType
|
||||
|
||||
PossessorComponent* possessorComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::POSSESSOR, possessorComponent)) {
|
||||
possessorComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
possessorComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
} else {
|
||||
// Should never happen, but just to be safe
|
||||
outBitStream->Write0();
|
||||
@ -1116,7 +1127,7 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType
|
||||
|
||||
LevelProgressionComponent* levelProgressionComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::LEVEL_PROGRESSION, levelProgressionComponent)) {
|
||||
levelProgressionComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
levelProgressionComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
} else {
|
||||
// Should never happen, but just to be safe
|
||||
outBitStream->Write0();
|
||||
@ -1124,13 +1135,13 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType
|
||||
|
||||
PlayerForcedMovementComponent* playerForcedMovementComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::PLAYER_FORCED_MOVEMENT, playerForcedMovementComponent)) {
|
||||
playerForcedMovementComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
playerForcedMovementComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
} else {
|
||||
// Should never happen, but just to be safe
|
||||
outBitStream->Write0();
|
||||
}
|
||||
|
||||
characterComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
characterComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
|
||||
if (HasComponent(eReplicaComponentType::ITEM)) {
|
||||
@ -1139,88 +1150,93 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType
|
||||
|
||||
InventoryComponent* inventoryComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::INVENTORY, inventoryComponent)) {
|
||||
inventoryComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
inventoryComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
|
||||
ScriptComponent* scriptComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::SCRIPT, scriptComponent)) {
|
||||
scriptComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
scriptComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
|
||||
SkillComponent* skillComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::SKILL, skillComponent)) {
|
||||
skillComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
skillComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
|
||||
BaseCombatAIComponent* baseCombatAiComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::BASE_COMBAT_AI, baseCombatAiComponent)) {
|
||||
baseCombatAiComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
baseCombatAiComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
|
||||
RebuildComponent* rebuildComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::QUICK_BUILD, rebuildComponent)) {
|
||||
DestroyableComponent* destroyableComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent) && !destroyableSerialized) {
|
||||
destroyableComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
destroyableComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
destroyableSerialized = true;
|
||||
rebuildComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
rebuildComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
|
||||
MovingPlatformComponent* movingPlatformComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::MOVING_PLATFORM, movingPlatformComponent)) {
|
||||
movingPlatformComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
movingPlatformComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
|
||||
SwitchComponent* switchComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::SWITCH, switchComponent)) {
|
||||
switchComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
switchComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
|
||||
VendorComponent* vendorComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::VENDOR, vendorComponent)) {
|
||||
vendorComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
vendorComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
|
||||
DonationVendorComponent* donationVendorComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::DONATION_VENDOR, donationVendorComponent)) {
|
||||
donationVendorComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
|
||||
BouncerComponent* bouncerComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::BOUNCER, bouncerComponent)) {
|
||||
bouncerComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
bouncerComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
|
||||
ScriptedActivityComponent* scriptedActivityComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::SCRIPTED_ACTIVITY, scriptedActivityComponent)) {
|
||||
scriptedActivityComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
scriptedActivityComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
|
||||
ShootingGalleryComponent* shootingGalleryComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::SHOOTING_GALLERY, shootingGalleryComponent)) {
|
||||
shootingGalleryComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
shootingGalleryComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
|
||||
RacingControlComponent* racingControlComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::RACING_CONTROL, racingControlComponent)) {
|
||||
racingControlComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
racingControlComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
|
||||
LUPExhibitComponent* lupExhibitComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::LUP_EXHIBIT, lupExhibitComponent)) {
|
||||
lupExhibitComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
lupExhibitComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
|
||||
ModelComponent* modelComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::MODEL, modelComponent)) {
|
||||
modelComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
modelComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
|
||||
RenderComponent* renderComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::RENDER, renderComponent)) {
|
||||
renderComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
renderComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
|
||||
if (modelComponent) {
|
||||
DestroyableComponent* destroyableComponent;
|
||||
if (TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent) && !destroyableSerialized) {
|
||||
destroyableComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
destroyableComponent->Serialize(outBitStream, bIsInitialUpdate);
|
||||
destroyableSerialized = true;
|
||||
}
|
||||
}
|
||||
@ -1235,10 +1251,6 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType
|
||||
outBitStream->Write0();
|
||||
}
|
||||
|
||||
void Entity::ResetFlags() {
|
||||
// Unused
|
||||
}
|
||||
|
||||
void Entity::UpdateXMLDoc(tinyxml2::XMLDocument* doc) {
|
||||
//This function should only ever be called from within Character, meaning doc should always exist when this is called.
|
||||
//Naturally, we don't include any non-player components in this update function.
|
||||
@ -1306,12 +1318,12 @@ void Entity::Update(const float deltaTime) {
|
||||
}
|
||||
|
||||
if (m_ShouldDestroyAfterUpdate) {
|
||||
EntityManager::Instance()->DestroyEntity(this->GetObjectID());
|
||||
Game::entityManager->DestroyEntity(this->GetObjectID());
|
||||
}
|
||||
}
|
||||
|
||||
void Entity::OnCollisionProximity(LWOOBJID otherEntity, const std::string& proxName, const std::string& status) {
|
||||
Entity* other = EntityManager::Instance()->GetEntity(otherEntity);
|
||||
Entity* other = Game::entityManager->GetEntity(otherEntity);
|
||||
if (!other) return;
|
||||
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
||||
@ -1325,7 +1337,7 @@ void Entity::OnCollisionProximity(LWOOBJID otherEntity, const std::string& proxN
|
||||
}
|
||||
|
||||
void Entity::OnCollisionPhantom(const LWOOBJID otherEntity) {
|
||||
auto* other = EntityManager::Instance()->GetEntity(otherEntity);
|
||||
auto* other = Game::entityManager->GetEntity(otherEntity);
|
||||
if (!other) return;
|
||||
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
||||
@ -1372,7 +1384,7 @@ void Entity::OnCollisionPhantom(const LWOOBJID otherEntity) {
|
||||
}
|
||||
|
||||
void Entity::OnCollisionLeavePhantom(const LWOOBJID otherEntity) {
|
||||
auto* other = EntityManager::Instance()->GetEntity(otherEntity);
|
||||
auto* other = Game::entityManager->GetEntity(otherEntity);
|
||||
if (!other) return;
|
||||
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
||||
@ -1526,13 +1538,13 @@ void Entity::Smash(const LWOOBJID source, const eKillType killType, const std::u
|
||||
|
||||
auto* destroyableComponent = GetComponent<DestroyableComponent>();
|
||||
if (destroyableComponent == nullptr) {
|
||||
Kill(EntityManager::Instance()->GetEntity(source));
|
||||
Kill(Game::entityManager->GetEntity(source));
|
||||
return;
|
||||
}
|
||||
auto* possessorComponent = GetComponent<PossessorComponent>();
|
||||
if (possessorComponent) {
|
||||
if (possessorComponent->GetPossessable() != LWOOBJID_EMPTY) {
|
||||
auto* mount = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable());
|
||||
auto* mount = Game::entityManager->GetEntity(possessorComponent->GetPossessable());
|
||||
if (mount) possessorComponent->Dismount(mount, true);
|
||||
}
|
||||
}
|
||||
@ -1560,20 +1572,20 @@ void Entity::Kill(Entity* murderer) {
|
||||
}
|
||||
|
||||
if (!IsPlayer()) {
|
||||
EntityManager::Instance()->DestroyEntity(this);
|
||||
Game::entityManager->DestroyEntity(this);
|
||||
}
|
||||
|
||||
const auto& grpNameQBShowBricks = GetVar<std::string>(u"grpNameQBShowBricks");
|
||||
|
||||
if (!grpNameQBShowBricks.empty()) {
|
||||
auto spawners = dZoneManager::Instance()->GetSpawnersByName(grpNameQBShowBricks);
|
||||
auto spawners = Game::zoneManager->GetSpawnersByName(grpNameQBShowBricks);
|
||||
|
||||
Spawner* spawner = nullptr;
|
||||
|
||||
if (!spawners.empty()) {
|
||||
spawner = spawners[0];
|
||||
} else {
|
||||
spawners = dZoneManager::Instance()->GetSpawnersInGroup(grpNameQBShowBricks);
|
||||
spawners = Game::zoneManager->GetSpawnersInGroup(grpNameQBShowBricks);
|
||||
|
||||
if (!spawners.empty()) {
|
||||
spawner = spawners[0];
|
||||
@ -1741,7 +1753,7 @@ void Entity::CancelCallbackTimers() {
|
||||
|
||||
void Entity::ScheduleKillAfterUpdate(Entity* murderer) {
|
||||
//if (m_Info.spawner) m_Info.spawner->ScheduleKill(this);
|
||||
EntityManager::Instance()->ScheduleForKill(this);
|
||||
Game::entityManager->ScheduleForKill(this);
|
||||
|
||||
if (murderer) m_ScheduleKiller = murderer;
|
||||
}
|
||||
@ -1785,7 +1797,7 @@ void Entity::TriggerEvent(eTriggerEventType event, Entity* optionalTarget) {
|
||||
|
||||
Entity* Entity::GetOwner() const {
|
||||
if (m_OwnerOverride != LWOOBJID_EMPTY) {
|
||||
auto* other = EntityManager::Instance()->GetEntity(m_OwnerOverride);
|
||||
auto* other = Game::entityManager->GetEntity(m_OwnerOverride);
|
||||
|
||||
if (other != nullptr) {
|
||||
return other->GetOwner();
|
||||
@ -1929,7 +1941,7 @@ void Entity::SetPosition(NiPoint3 position) {
|
||||
vehicel->SetPosition(position);
|
||||
}
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(this);
|
||||
Game::entityManager->SerializeEntity(this);
|
||||
}
|
||||
|
||||
void Entity::SetRotation(NiQuaternion rotation) {
|
||||
@ -1957,7 +1969,7 @@ void Entity::SetRotation(NiQuaternion rotation) {
|
||||
vehicel->SetRotation(rotation);
|
||||
}
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(this);
|
||||
Game::entityManager->SerializeEntity(this);
|
||||
}
|
||||
|
||||
bool Entity::GetBoolean(const std::u16string& name) const {
|
||||
@ -2009,7 +2021,7 @@ std::vector<LWOOBJID>& Entity::GetTargetsInPhantom() {
|
||||
for (auto i = 0u; i < m_TargetsInPhantom.size(); ++i) {
|
||||
const auto id = m_TargetsInPhantom.at(i);
|
||||
|
||||
auto* entity = EntityManager::Instance()->GetEntity(id);
|
||||
auto* entity = Game::entityManager->GetEntity(id);
|
||||
|
||||
if (entity == nullptr) {
|
||||
continue;
|
||||
|
@ -85,6 +85,7 @@ public:
|
||||
bool GetPlayerReadyForUpdates() const { return m_PlayerIsReadyForUpdates; }
|
||||
|
||||
bool GetIsGhostingCandidate() const;
|
||||
void SetIsGhostingCandidate(bool value) { m_IsGhostingCandidate = value; };
|
||||
|
||||
int8_t GetObservers() const;
|
||||
|
||||
@ -173,7 +174,6 @@ public:
|
||||
|
||||
void WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacketType packetType);
|
||||
void WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType packetType);
|
||||
void ResetFlags();
|
||||
void UpdateXMLDoc(tinyxml2::XMLDocument* doc);
|
||||
void Update(float deltaTime);
|
||||
|
||||
|
@ -25,8 +25,6 @@
|
||||
#include "eReplicaComponentType.h"
|
||||
#include "eReplicaPacketType.h"
|
||||
|
||||
EntityManager* EntityManager::m_Address = nullptr;
|
||||
|
||||
// Configure which zones have ghosting disabled, mostly small worlds.
|
||||
std::vector<LWOMAPID> EntityManager::m_GhostingExcludedZones = {
|
||||
// Small zones
|
||||
@ -62,7 +60,7 @@ void EntityManager::Initialize() {
|
||||
m_GhostingEnabled = std::find(
|
||||
m_GhostingExcludedZones.begin(),
|
||||
m_GhostingExcludedZones.end(),
|
||||
dZoneManager::Instance()->GetZoneID().GetMapID()
|
||||
Game::zoneManager->GetZoneID().GetMapID()
|
||||
) == m_GhostingExcludedZones.end();
|
||||
|
||||
// grab hardcore mode settings and load them with sane defaults
|
||||
@ -77,10 +75,7 @@ void EntityManager::Initialize() {
|
||||
|
||||
// If cloneID is not zero, then hardcore mode is disabled
|
||||
// aka minigames and props
|
||||
if (dZoneManager::Instance()->GetZoneID().GetCloneID() != 0) m_HardcoreMode = false;
|
||||
}
|
||||
|
||||
EntityManager::~EntityManager() {
|
||||
if (Game::zoneManager->GetZoneID().GetCloneID() != 0) m_HardcoreMode = false;
|
||||
}
|
||||
|
||||
Entity* EntityManager::CreateEntity(EntityInfo info, User* user, Entity* parentEntity, const bool controller, const LWOOBJID explicitId) {
|
||||
@ -588,12 +583,6 @@ bool EntityManager::GetGhostingEnabled() const {
|
||||
return m_GhostingEnabled;
|
||||
}
|
||||
|
||||
void EntityManager::ResetFlags() {
|
||||
for (const auto& e : m_Entities) {
|
||||
e.second->ResetFlags();
|
||||
}
|
||||
}
|
||||
|
||||
void EntityManager::ScheduleForKill(Entity* entity) {
|
||||
// Deactivate switches if they die
|
||||
if (!entity)
|
||||
|
@ -1,12 +1,13 @@
|
||||
#ifndef ENTITYMANAGER_H
|
||||
#define ENTITYMANAGER_H
|
||||
|
||||
#include "dCommonVars.h"
|
||||
#include <map>
|
||||
#include <stack>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "dCommonVars.h"
|
||||
|
||||
class Entity;
|
||||
class EntityInfo;
|
||||
class Player;
|
||||
@ -17,19 +18,8 @@ struct SystemAddress;
|
||||
|
||||
class EntityManager {
|
||||
public:
|
||||
static EntityManager* Instance() {
|
||||
if (!m_Address) {
|
||||
m_Address = new EntityManager();
|
||||
m_Address->Initialize();
|
||||
}
|
||||
|
||||
return m_Address;
|
||||
}
|
||||
|
||||
void Initialize();
|
||||
|
||||
~EntityManager();
|
||||
|
||||
void UpdateEntities(float deltaTime);
|
||||
Entity* CreateEntity(EntityInfo info, User* user = nullptr, Entity* parentEntity = nullptr, bool controller = false, LWOOBJID explicitId = LWOOBJID_EMPTY);
|
||||
void DestroyEntity(const LWOOBJID& objectID);
|
||||
@ -69,8 +59,6 @@ public:
|
||||
Entity* GetGhostCandidate(int32_t id);
|
||||
bool GetGhostingEnabled() const;
|
||||
|
||||
void ResetFlags();
|
||||
|
||||
void ScheduleForKill(Entity* entity);
|
||||
|
||||
void ScheduleForDeletion(LWOOBJID entity);
|
||||
@ -89,7 +77,6 @@ private:
|
||||
void KillEntities();
|
||||
void DeleteEntities();
|
||||
|
||||
static EntityManager* m_Address; //For singleton method
|
||||
static std::vector<LWOMAPID> m_GhostingExcludedZones;
|
||||
static std::vector<LOT> m_GhostingExcludedLOTs;
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user