mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-25 23:17:28 +00:00
Merge branch 'main' into fix/cmake-libs-2
This commit is contained in:
commit
702dcbb8d2
@ -1,9 +1,7 @@
|
|||||||
# Full path to the LEGO Universe client
|
# Full path to the LEGO Universe client
|
||||||
CLIENT_PATH=/Users/someuser/LEGO Universe
|
CLIENT_PATH=./client
|
||||||
# Can improve build time
|
|
||||||
BUILD_THREADS=1
|
|
||||||
# Updates NET_VERSION in CMakeVariables.txt
|
# Updates NET_VERSION in CMakeVariables.txt
|
||||||
BUILD_VERSION=171022
|
NET_VERSION=171022
|
||||||
# make sure this is a long random string
|
# make sure this is a long random string
|
||||||
# grab a "SHA 256-bit Key" from here: https://keygen.io/
|
# grab a "SHA 256-bit Key" from here: https://keygen.io/
|
||||||
ACCOUNT_MANAGER_SECRET=
|
ACCOUNT_MANAGER_SECRET=
|
||||||
@ -12,6 +10,5 @@ EXTERNAL_IP=localhost
|
|||||||
# Database values
|
# Database values
|
||||||
# Be careful with special characters here. It is more safe to use normal characters and/or numbers.
|
# Be careful with special characters here. It is more safe to use normal characters and/or numbers.
|
||||||
MARIADB_USER=darkflame
|
MARIADB_USER=darkflame
|
||||||
MARIADB_PASSWORD=SECRET_VALUE_CHANGE_ME
|
MARIADB_PASSWORD=
|
||||||
MARIADB_ROOT_PASSWORD=SECRET_VALUE_CHANGE_ME
|
|
||||||
MARIADB_DATABASE=darkflame
|
MARIADB_DATABASE=darkflame
|
||||||
|
2
.github/workflows/build-and-test.yml
vendored
2
.github/workflows/build-and-test.yml
vendored
@ -13,7 +13,7 @@ jobs:
|
|||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ windows-2022, ubuntu-20.04, macos-11 ]
|
os: [ windows-2022, ubuntu-22.04, macos-11 ]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
@ -51,7 +51,7 @@ set(RECASTNAVIGATION_EXAMPLES OFF CACHE BOOL "" FORCE)
|
|||||||
# Disabled no-register
|
# Disabled no-register
|
||||||
# Disabled unknown pragmas because Linux doesn't understand Windows pragmas.
|
# Disabled unknown pragmas because Linux doesn't understand Windows pragmas.
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++17 -O2 -Wuninitialized -fPIC")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wuninitialized -fPIC")
|
||||||
add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0 _GLIBCXX_USE_CXX17_ABI=0)
|
add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0 _GLIBCXX_USE_CXX17_ABI=0)
|
||||||
|
|
||||||
if(NOT APPLE)
|
if(NOT APPLE)
|
||||||
@ -249,7 +249,9 @@ endforeach()
|
|||||||
|
|
||||||
# Add linking directories:
|
# Add linking directories:
|
||||||
# link_directories(${PROJECT_BINARY_DIR})
|
# link_directories(${PROJECT_BINARY_DIR})
|
||||||
|
if (UNIX)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
||||||
|
endif()
|
||||||
file(
|
file(
|
||||||
GLOB HEADERS_DZONEMANAGER
|
GLOB HEADERS_DZONEMANAGER
|
||||||
LIST_DIRECTORIES false
|
LIST_DIRECTORIES false
|
||||||
@ -281,6 +283,7 @@ add_subdirectory(dGame)
|
|||||||
add_subdirectory(dZoneManager)
|
add_subdirectory(dZoneManager)
|
||||||
add_subdirectory(dNavigation)
|
add_subdirectory(dNavigation)
|
||||||
add_subdirectory(dPhysics)
|
add_subdirectory(dPhysics)
|
||||||
|
add_subdirectory(dServer)
|
||||||
|
|
||||||
# Create a list of common libraries shared between all binaries
|
# Create a list of common libraries shared between all binaries
|
||||||
set(COMMON_LIBRARIES "dCommon" "dDatabase" "dNet" "raknet" "MariaDB::ConnCpp" "magic_enum")
|
set(COMMON_LIBRARIES "dCommon" "dDatabase" "dNet" "raknet" "MariaDB::ConnCpp" "magic_enum")
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
"generator": "Unix Makefiles"
|
"generator": "Unix Makefiles"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "ci-ubuntu-20.04",
|
"name": "ci-ubuntu-22.04",
|
||||||
"displayName": "CI configure step for Ubuntu",
|
"displayName": "CI configure step for Ubuntu",
|
||||||
"description": "Same as default, Used in GitHub actions workflow",
|
"description": "Same as default, Used in GitHub actions workflow",
|
||||||
"inherits": "default"
|
"inherits": "default"
|
||||||
@ -67,8 +67,8 @@
|
|||||||
"jobs": 2
|
"jobs": 2
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "ci-ubuntu-20.04",
|
"name": "ci-ubuntu-22.04",
|
||||||
"configurePreset": "ci-ubuntu-20.04",
|
"configurePreset": "ci-ubuntu-22.04",
|
||||||
"displayName": "Linux CI Build",
|
"displayName": "Linux CI Build",
|
||||||
"description": "This preset is used by the CI build on linux",
|
"description": "This preset is used by the CI build on linux",
|
||||||
"jobs": 2
|
"jobs": 2
|
||||||
@ -83,8 +83,8 @@
|
|||||||
],
|
],
|
||||||
"testPresets": [
|
"testPresets": [
|
||||||
{
|
{
|
||||||
"name": "ci-ubuntu-20.04",
|
"name": "ci-ubuntu-22.04",
|
||||||
"configurePreset": "ci-ubuntu-20.04",
|
"configurePreset": "ci-ubuntu-22.04",
|
||||||
"displayName": "CI Tests on Linux",
|
"displayName": "CI Tests on Linux",
|
||||||
"description": "Runs all tests on a linux configuration",
|
"description": "Runs all tests on a linux configuration",
|
||||||
"execution": {
|
"execution": {
|
||||||
|
42
README.md
42
README.md
@ -348,12 +348,40 @@ certutil -hashfile <file> SHA1
|
|||||||
Known good *SHA1* checksum of the Darkflame Universe client:
|
Known good *SHA1* checksum of the Darkflame Universe client:
|
||||||
- `91498e09b83ce69f46baf9e521d48f23fe502985` (packed client, zip compressed)
|
- `91498e09b83ce69f46baf9e521d48f23fe502985` (packed client, zip compressed)
|
||||||
|
|
||||||
|
|
||||||
# Docker
|
# Docker
|
||||||
|
|
||||||
## Standalone
|
The Darkflame Server is automatically built and published as a Docker Container / [OCI](https://opencontainers.org/) Image to the GitHub Container Registry at:
|
||||||
|
[`ghcr.io/darkflameuniverse/darkflameserver`](https://github.com/DarkflameUniverse/DarkflameServer/pkgs/container/darkflameserver).
|
||||||
|
|
||||||
For standalone deployment, you can use the image provided via Github's Container Repository:
|
## Compose
|
||||||
`ghcr.io/darkflameuniverse/darkflameserver`
|
|
||||||
|
You can use the `docker-compose` tool to [setup a MariaDB database](#database-setup), run the Darkflame Server and manage it with [Nexus Dashboard](https://github.com/DarkflameUniverse/NexusDashboard) all
|
||||||
|
at once. For that:
|
||||||
|
|
||||||
|
- [Install Docker Desktop](https://docs.docker.com/get-docker/)
|
||||||
|
- Open the directory that contains your LU Client
|
||||||
|
- If the `legouniverse.exe` is in a subfolder called `client`, you're good to go. There may also be a folder `versions`.
|
||||||
|
- Otherwise, create a new `client` folder and move the exe and everything else (e.g. `res` and `locale`) in there. This is necessary to work around a bug in the client that will prevent that you to log back in after getting disconnected.
|
||||||
|
- Download the [docker-compose.yml](docker-compose.yml) file and place it next to `client`.
|
||||||
|
- Download the [.env.example](.env.example) file and place it next to `client` with the file name `.env`
|
||||||
|
- You may get warnings that this name starts with a dot, acknowledge those, this is intentional. Depending on your operating system, you may need to activate showing hidden files (e.g. Ctrl-H in Gnome on Linux) and/or file extensions ("File name extensions" in the "View" tab on Windows).
|
||||||
|
- Update the `ACCOUNT_MANAGER_SECRET` and `MARIADB_PASSWORD` with strong random passwords.
|
||||||
|
- Use a password generator like <https://keygen.io>
|
||||||
|
- Avoid `:` and `@` characters
|
||||||
|
- Once the database user is created, changing the password will not update it, so the server will just fail to connect.
|
||||||
|
- Set `EXTERNAL_IP` to your LAN IP or public IP if you want to host the game for friends & family
|
||||||
|
- Open a terminal in the folder with the `docker-compose.yml` and `client`
|
||||||
|
- Run `docker compose up -d`
|
||||||
|
- This might require `sudo` on Linux, and a recent version of [docker compose](https://docs.docker.com/compose/install/)
|
||||||
|
- Run `docker exec -it dlu-darkflameserver-1 /app/MasterServer -a` and follow the instructions to create the initial admin account
|
||||||
|
- Open <http://localhost:8000> to access Nexus Dashboard with the admin account to create normal users
|
||||||
|
- Set `AUTHSERVERIP=0:localhost` in `client/boot.cfg`
|
||||||
|
- Replace `localhost` with the value of `EXTERNAL_IP` if you changed that earlier.
|
||||||
|
- Also make sure `UGCUSE3DSERVICES=7:` is set to `0`
|
||||||
|
- Launch `legouniverse.exe`
|
||||||
|
|
||||||
|
## Standalone
|
||||||
|
|
||||||
This assumes that you have a database deployed to your host or in another docker container.
|
This assumes that you have a database deployed to your host or in another docker container.
|
||||||
|
|
||||||
@ -376,14 +404,6 @@ You will need to replace the `/path/to/`'s to reflect the paths on your host.
|
|||||||
|
|
||||||
Any config option in the `.ini`'s can be overridden with environmental variables: Ex: `log_to_console=1` from `shared_config.ini` would be overidden like `-e LOG_TO_CONSOLE=0`
|
Any config option in the `.ini`'s can be overridden with environmental variables: Ex: `log_to_console=1` from `shared_config.ini` would be overidden like `-e LOG_TO_CONSOLE=0`
|
||||||
|
|
||||||
## Compose
|
|
||||||
|
|
||||||
See the [compose](docker-compose.yml) file in the root of the repo.
|
|
||||||
|
|
||||||
This compose file is for a full deployment: MariaDB, DarkflameServer, and Nexus Dashboard.
|
|
||||||
|
|
||||||
All of the environmental options are listed in the compose file so the can be pass through, or you can edit the compose file to suit your specific needs
|
|
||||||
|
|
||||||
# Development Documentation
|
# Development Documentation
|
||||||
This is a Work in Progress, but below are some quick links to documentaion for systems and structs in the server
|
This is a Work in Progress, but below are some quick links to documentaion for systems and structs in the server
|
||||||
[Networked message structs](https://lcdruniverse.org/lu_packets/lu_packets/index.html)
|
[Networked message structs](https://lcdruniverse.org/lu_packets/lu_packets/index.html)
|
||||||
|
@ -25,6 +25,9 @@
|
|||||||
#include "eAuthMessageType.h"
|
#include "eAuthMessageType.h"
|
||||||
|
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
|
#include "Server.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Game {
|
namespace Game {
|
||||||
Logger* logger = nullptr;
|
Logger* logger = nullptr;
|
||||||
dServer* server = nullptr;
|
dServer* server = nullptr;
|
||||||
@ -33,7 +36,6 @@ namespace Game {
|
|||||||
std::mt19937 randomEngine;
|
std::mt19937 randomEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger* SetupLogger();
|
|
||||||
void HandlePacket(Packet* packet);
|
void HandlePacket(Packet* packet);
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
@ -46,14 +48,11 @@ int main(int argc, char** argv) {
|
|||||||
std::signal(SIGINT, Game::OnSignal);
|
std::signal(SIGINT, Game::OnSignal);
|
||||||
std::signal(SIGTERM, Game::OnSignal);
|
std::signal(SIGTERM, Game::OnSignal);
|
||||||
|
|
||||||
//Create all the objects we need to run our service:
|
|
||||||
Game::logger = SetupLogger();
|
|
||||||
if (!Game::logger) return EXIT_FAILURE;
|
|
||||||
|
|
||||||
//Read our config:
|
|
||||||
Game::config = new dConfig("authconfig.ini");
|
Game::config = new dConfig("authconfig.ini");
|
||||||
Game::logger->SetLogToConsole(Game::config->GetValue("log_to_console") != "0");
|
|
||||||
Game::logger->SetLogDebugStatements(Game::config->GetValue("log_debug_statements") == "1");
|
//Create all the objects we need to run our service:
|
||||||
|
Server::SetupLogger("AuthServer");
|
||||||
|
if (!Game::logger) return EXIT_FAILURE;
|
||||||
|
|
||||||
LOG("Starting Auth server...");
|
LOG("Starting Auth server...");
|
||||||
LOG("Version: %s", PROJECT_VERSION);
|
LOG("Version: %s", PROJECT_VERSION);
|
||||||
@ -162,18 +161,6 @@ int main(int argc, char** argv) {
|
|||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger* SetupLogger() {
|
|
||||||
std::string logPath = (BinaryPathFinder::GetBinaryDir() / ("logs/AuthServer_" + std::to_string(time(nullptr)) + ".log")).string();
|
|
||||||
bool logToConsole = false;
|
|
||||||
bool logDebugStatements = false;
|
|
||||||
#ifdef _DEBUG
|
|
||||||
logToConsole = true;
|
|
||||||
logDebugStatements = true;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return new Logger(logPath, logToConsole, logDebugStatements);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HandlePacket(Packet* packet) {
|
void HandlePacket(Packet* packet) {
|
||||||
if (packet->length < 4) return;
|
if (packet->length < 4) return;
|
||||||
|
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
add_executable(AuthServer "AuthServer.cpp")
|
add_executable(AuthServer "AuthServer.cpp")
|
||||||
target_link_libraries(AuthServer ${COMMON_LIBRARIES})
|
|
||||||
|
target_link_libraries(AuthServer ${COMMON_LIBRARIES} dServer)
|
||||||
|
|
||||||
|
target_include_directories(AuthServer PRIVATE ${PROJECT_SOURCE_DIR}/dServer)
|
||||||
|
|
||||||
add_compile_definitions(AuthServer PRIVATE PROJECT_VERSION="\"${PROJECT_VERSION}\"")
|
add_compile_definitions(AuthServer PRIVATE PROJECT_VERSION="\"${PROJECT_VERSION}\"")
|
||||||
|
@ -6,7 +6,9 @@ set(DCHATSERVER_SOURCES
|
|||||||
|
|
||||||
add_executable(ChatServer "ChatServer.cpp")
|
add_executable(ChatServer "ChatServer.cpp")
|
||||||
add_library(dChatServer ${DCHATSERVER_SOURCES})
|
add_library(dChatServer ${DCHATSERVER_SOURCES})
|
||||||
|
target_include_directories(dChatServer PRIVATE ${PROJECT_SOURCE_DIR}/dServer)
|
||||||
add_compile_definitions(ChatServer PRIVATE PROJECT_VERSION="\"${PROJECT_VERSION}\"")
|
add_compile_definitions(ChatServer PRIVATE PROJECT_VERSION="\"${PROJECT_VERSION}\"")
|
||||||
|
|
||||||
target_link_libraries(dChatServer ${COMMON_LIBRARIES} dChatFilter)
|
target_link_libraries(dChatServer ${COMMON_LIBRARIES} dChatFilter)
|
||||||
target_link_libraries(ChatServer ${COMMON_LIBRARIES} dChatFilter dChatServer)
|
target_link_libraries(ChatServer ${COMMON_LIBRARIES} dChatFilter dChatServer dServer)
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#include "PlayerContainer.h"
|
#include "PlayerContainer.h"
|
||||||
#include "eChatInternalMessageType.h"
|
#include "eChatInternalMessageType.h"
|
||||||
#include "BitStreamUtils.h"
|
#include "BitStreamUtils.h"
|
||||||
#include "PacketUtils.h"
|
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "eObjectBits.h"
|
#include "eObjectBits.h"
|
||||||
@ -26,37 +25,36 @@ void ChatIgnoreList::GetIgnoreList(Packet* packet) {
|
|||||||
LWOOBJID playerId;
|
LWOOBJID playerId;
|
||||||
inStream.Read(playerId);
|
inStream.Read(playerId);
|
||||||
|
|
||||||
auto* receiver = Game::playerContainer.GetPlayerData(playerId);
|
auto& receiver = Game::playerContainer.GetPlayerDataMutable(playerId);
|
||||||
if (!receiver) {
|
if (!receiver) {
|
||||||
LOG("Tried to get ignore list, but player %llu not found in container", playerId);
|
LOG("Tried to get ignore list, but player %llu not found in container", playerId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!receiver->ignoredPlayers.empty()) {
|
if (!receiver.ignoredPlayers.empty()) {
|
||||||
LOG_DEBUG("Player %llu already has an ignore list", playerId);
|
LOG_DEBUG("Player %llu already has an ignore list, but is requesting it again.", playerId);
|
||||||
return;
|
} else {
|
||||||
}
|
auto ignoreList = Database::Get()->GetIgnoreList(static_cast<uint32_t>(playerId));
|
||||||
|
if (ignoreList.empty()) {
|
||||||
|
LOG_DEBUG("Player %llu has no ignores", playerId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto ignoreList = Database::Get()->GetIgnoreList(static_cast<uint32_t>(playerId));
|
for (auto& ignoredPlayer : ignoreList) {
|
||||||
if (ignoreList.empty()) {
|
receiver.ignoredPlayers.emplace_back(ignoredPlayer.name, ignoredPlayer.id);
|
||||||
LOG_DEBUG("Player %llu has no ignores", playerId);
|
GeneralUtils::SetBit(receiver.ignoredPlayers.back().playerId, eObjectBits::CHARACTER);
|
||||||
return;
|
GeneralUtils::SetBit(receiver.ignoredPlayers.back().playerId, eObjectBits::PERSISTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& ignoredPlayer : ignoreList) {
|
|
||||||
receiver->ignoredPlayers.push_back(IgnoreData{ ignoredPlayer.id, ignoredPlayer.name });
|
|
||||||
GeneralUtils::SetBit(receiver->ignoredPlayers.back().playerId, eObjectBits::CHARACTER);
|
|
||||||
GeneralUtils::SetBit(receiver->ignoredPlayers.back().playerId, eObjectBits::PERSISTENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CBITSTREAM;
|
CBITSTREAM;
|
||||||
WriteOutgoingReplyHeader(bitStream, receiver->playerID, ChatIgnoreList::Response::GET_IGNORE);
|
WriteOutgoingReplyHeader(bitStream, receiver.playerID, ChatIgnoreList::Response::GET_IGNORE);
|
||||||
|
|
||||||
bitStream.Write<uint8_t>(false); // Probably is Is Free Trial, but we don't care about that
|
bitStream.Write<uint8_t>(false); // Probably is Is Free Trial, but we don't care about that
|
||||||
bitStream.Write<uint16_t>(0); // literally spacing due to struct alignment
|
bitStream.Write<uint16_t>(0); // literally spacing due to struct alignment
|
||||||
|
|
||||||
bitStream.Write<uint16_t>(receiver->ignoredPlayers.size());
|
bitStream.Write<uint16_t>(receiver.ignoredPlayers.size());
|
||||||
for (const auto& ignoredPlayer : receiver->ignoredPlayers) {
|
for (const auto& ignoredPlayer : receiver.ignoredPlayers) {
|
||||||
bitStream.Write(ignoredPlayer.playerId);
|
bitStream.Write(ignoredPlayer.playerId);
|
||||||
bitStream.Write(LUWString(ignoredPlayer.playerName, 36));
|
bitStream.Write(LUWString(ignoredPlayer.playerName, 36));
|
||||||
}
|
}
|
||||||
@ -69,40 +67,40 @@ void ChatIgnoreList::AddIgnore(Packet* packet) {
|
|||||||
LWOOBJID playerId;
|
LWOOBJID playerId;
|
||||||
inStream.Read(playerId);
|
inStream.Read(playerId);
|
||||||
|
|
||||||
auto* receiver = Game::playerContainer.GetPlayerData(playerId);
|
auto& receiver = Game::playerContainer.GetPlayerDataMutable(playerId);
|
||||||
if (!receiver) {
|
if (!receiver) {
|
||||||
LOG("Tried to get ignore list, but player %llu not found in container", playerId);
|
LOG("Tried to get ignore list, but player %llu not found in container", playerId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr int32_t MAX_IGNORES = 32;
|
constexpr int32_t MAX_IGNORES = 32;
|
||||||
if (receiver->ignoredPlayers.size() > MAX_IGNORES) {
|
if (receiver.ignoredPlayers.size() > MAX_IGNORES) {
|
||||||
LOG_DEBUG("Player %llu has too many ignores", playerId);
|
LOG_DEBUG("Player %llu has too many ignores", playerId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
inStream.IgnoreBytes(4); // ignore some garbage zeros idk
|
inStream.IgnoreBytes(4); // ignore some garbage zeros idk
|
||||||
|
|
||||||
LUWString toIgnoreName(33);
|
LUWString toIgnoreName;
|
||||||
inStream.Read(toIgnoreName);
|
inStream.Read(toIgnoreName);
|
||||||
std::string toIgnoreStr = toIgnoreName.GetAsString();
|
std::string toIgnoreStr = toIgnoreName.GetAsString();
|
||||||
|
|
||||||
CBITSTREAM;
|
CBITSTREAM;
|
||||||
WriteOutgoingReplyHeader(bitStream, receiver->playerID, ChatIgnoreList::Response::ADD_IGNORE);
|
WriteOutgoingReplyHeader(bitStream, receiver.playerID, ChatIgnoreList::Response::ADD_IGNORE);
|
||||||
|
|
||||||
// Check if the player exists
|
// Check if the player exists
|
||||||
LWOOBJID ignoredPlayerId = LWOOBJID_EMPTY;
|
LWOOBJID ignoredPlayerId = LWOOBJID_EMPTY;
|
||||||
if (toIgnoreStr == receiver->playerName || toIgnoreStr.find("[GM]") == 0) {
|
if (toIgnoreStr == receiver.playerName || toIgnoreStr.find("[GM]") == 0) {
|
||||||
LOG_DEBUG("Player %llu tried to ignore themselves", playerId);
|
LOG_DEBUG("Player %llu tried to ignore themselves", playerId);
|
||||||
|
|
||||||
bitStream.Write(ChatIgnoreList::AddResponse::GENERAL_ERROR);
|
bitStream.Write(ChatIgnoreList::AddResponse::GENERAL_ERROR);
|
||||||
} else if (std::count(receiver->ignoredPlayers.begin(), receiver->ignoredPlayers.end(), toIgnoreStr) > 0) {
|
} else if (std::count(receiver.ignoredPlayers.begin(), receiver.ignoredPlayers.end(), toIgnoreStr) > 0) {
|
||||||
LOG_DEBUG("Player %llu is already ignoring %s", playerId, toIgnoreStr.c_str());
|
LOG_DEBUG("Player %llu is already ignoring %s", playerId, toIgnoreStr.c_str());
|
||||||
|
|
||||||
bitStream.Write(ChatIgnoreList::AddResponse::ALREADY_IGNORED);
|
bitStream.Write(ChatIgnoreList::AddResponse::ALREADY_IGNORED);
|
||||||
} else {
|
} else {
|
||||||
// Get the playerId falling back to query if not online
|
// Get the playerId falling back to query if not online
|
||||||
auto* playerData = Game::playerContainer.GetPlayerData(toIgnoreStr);
|
const auto& playerData = Game::playerContainer.GetPlayerData(toIgnoreStr);
|
||||||
if (!playerData) {
|
if (!playerData) {
|
||||||
// Fall back to query
|
// Fall back to query
|
||||||
auto player = Database::Get()->GetCharacterInfo(toIgnoreStr);
|
auto player = Database::Get()->GetCharacterInfo(toIgnoreStr);
|
||||||
@ -112,7 +110,7 @@ void ChatIgnoreList::AddIgnore(Packet* packet) {
|
|||||||
ignoredPlayerId = player->id;
|
ignoredPlayerId = player->id;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ignoredPlayerId = playerData->playerID;
|
ignoredPlayerId = playerData.playerID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ignoredPlayerId != LWOOBJID_EMPTY) {
|
if (ignoredPlayerId != LWOOBJID_EMPTY) {
|
||||||
@ -120,7 +118,7 @@ void ChatIgnoreList::AddIgnore(Packet* packet) {
|
|||||||
GeneralUtils::SetBit(ignoredPlayerId, eObjectBits::CHARACTER);
|
GeneralUtils::SetBit(ignoredPlayerId, eObjectBits::CHARACTER);
|
||||||
GeneralUtils::SetBit(ignoredPlayerId, eObjectBits::PERSISTENT);
|
GeneralUtils::SetBit(ignoredPlayerId, eObjectBits::PERSISTENT);
|
||||||
|
|
||||||
receiver->ignoredPlayers.push_back(IgnoreData{ ignoredPlayerId, toIgnoreStr });
|
receiver.ignoredPlayers.emplace_back(toIgnoreStr, ignoredPlayerId);
|
||||||
LOG_DEBUG("Player %llu is ignoring %s", playerId, toIgnoreStr.c_str());
|
LOG_DEBUG("Player %llu is ignoring %s", playerId, toIgnoreStr.c_str());
|
||||||
|
|
||||||
bitStream.Write(ChatIgnoreList::AddResponse::SUCCESS);
|
bitStream.Write(ChatIgnoreList::AddResponse::SUCCESS);
|
||||||
@ -141,7 +139,7 @@ void ChatIgnoreList::RemoveIgnore(Packet* packet) {
|
|||||||
LWOOBJID playerId;
|
LWOOBJID playerId;
|
||||||
inStream.Read(playerId);
|
inStream.Read(playerId);
|
||||||
|
|
||||||
auto* receiver = Game::playerContainer.GetPlayerData(playerId);
|
auto& receiver = Game::playerContainer.GetPlayerDataMutable(playerId);
|
||||||
if (!receiver) {
|
if (!receiver) {
|
||||||
LOG("Tried to get ignore list, but player %llu not found in container", playerId);
|
LOG("Tried to get ignore list, but player %llu not found in container", playerId);
|
||||||
return;
|
return;
|
||||||
@ -149,21 +147,21 @@ void ChatIgnoreList::RemoveIgnore(Packet* packet) {
|
|||||||
|
|
||||||
inStream.IgnoreBytes(4); // ignore some garbage zeros idk
|
inStream.IgnoreBytes(4); // ignore some garbage zeros idk
|
||||||
|
|
||||||
LUWString removedIgnoreName(33);
|
LUWString removedIgnoreName;
|
||||||
inStream.Read(removedIgnoreName);
|
inStream.Read(removedIgnoreName);
|
||||||
std::string removedIgnoreStr = removedIgnoreName.GetAsString();
|
std::string removedIgnoreStr = removedIgnoreName.GetAsString();
|
||||||
|
|
||||||
auto toRemove = std::remove(receiver->ignoredPlayers.begin(), receiver->ignoredPlayers.end(), removedIgnoreStr);
|
auto toRemove = std::remove(receiver.ignoredPlayers.begin(), receiver.ignoredPlayers.end(), removedIgnoreStr);
|
||||||
if (toRemove == receiver->ignoredPlayers.end()) {
|
if (toRemove == receiver.ignoredPlayers.end()) {
|
||||||
LOG_DEBUG("Player %llu is not ignoring %s", playerId, removedIgnoreStr.c_str());
|
LOG_DEBUG("Player %llu is not ignoring %s", playerId, removedIgnoreStr.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Database::Get()->RemoveIgnore(static_cast<uint32_t>(playerId), static_cast<uint32_t>(toRemove->playerId));
|
Database::Get()->RemoveIgnore(static_cast<uint32_t>(playerId), static_cast<uint32_t>(toRemove->playerId));
|
||||||
receiver->ignoredPlayers.erase(toRemove, receiver->ignoredPlayers.end());
|
receiver.ignoredPlayers.erase(toRemove, receiver.ignoredPlayers.end());
|
||||||
|
|
||||||
CBITSTREAM;
|
CBITSTREAM;
|
||||||
WriteOutgoingReplyHeader(bitStream, receiver->playerID, ChatIgnoreList::Response::REMOVE_IGNORE);
|
WriteOutgoingReplyHeader(bitStream, receiver.playerID, ChatIgnoreList::Response::REMOVE_IGNORE);
|
||||||
|
|
||||||
bitStream.Write<int8_t>(0);
|
bitStream.Write<int8_t>(0);
|
||||||
LUWString playerNameSend(removedIgnoreStr, 33);
|
LUWString playerNameSend(removedIgnoreStr, 33);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -4,16 +4,56 @@
|
|||||||
#include "BitStream.h"
|
#include "BitStream.h"
|
||||||
|
|
||||||
struct PlayerData;
|
struct PlayerData;
|
||||||
|
|
||||||
enum class eAddFriendResponseType : uint8_t;
|
enum class eAddFriendResponseType : uint8_t;
|
||||||
|
|
||||||
|
enum class eChatChannel : uint8_t {
|
||||||
|
SYSTEMNOTIFY = 0,
|
||||||
|
SYSTEMWARNING,
|
||||||
|
SYSTEMERROR,
|
||||||
|
BROADCAST,
|
||||||
|
LOCAL,
|
||||||
|
LOCALNOANIM,
|
||||||
|
EMOTE,
|
||||||
|
PRIVATE_CHAT,
|
||||||
|
TEAM,
|
||||||
|
TEAMLOCAL,
|
||||||
|
GUILD,
|
||||||
|
GUILDNOTIFY,
|
||||||
|
PROPERTY,
|
||||||
|
ADMIN,
|
||||||
|
COMBATDAMAGE,
|
||||||
|
COMBATHEALING,
|
||||||
|
COMBATLOOT,
|
||||||
|
COMBATEXP,
|
||||||
|
COMBATDEATH,
|
||||||
|
GENERAL,
|
||||||
|
TRADE,
|
||||||
|
LFG,
|
||||||
|
USER
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
enum class eChatMessageResponseCode : uint8_t {
|
||||||
|
SENT = 0,
|
||||||
|
NOTONLINE,
|
||||||
|
GENERALERROR,
|
||||||
|
RECEIVEDNEWWHISPER,
|
||||||
|
NOTFRIENDS,
|
||||||
|
SENDERFREETRIAL,
|
||||||
|
RECEIVERFREETRIAL,
|
||||||
|
};
|
||||||
|
|
||||||
namespace ChatPacketHandler {
|
namespace ChatPacketHandler {
|
||||||
void HandleFriendlistRequest(Packet* packet);
|
void HandleFriendlistRequest(Packet* packet);
|
||||||
void HandleFriendRequest(Packet* packet);
|
void HandleFriendRequest(Packet* packet);
|
||||||
void HandleFriendResponse(Packet* packet);
|
void HandleFriendResponse(Packet* packet);
|
||||||
void HandleRemoveFriend(Packet* packet);
|
void HandleRemoveFriend(Packet* packet);
|
||||||
|
void HandleGMLevelUpdate(Packet* packet);
|
||||||
|
|
||||||
void HandleChatMessage(Packet* packet);
|
void HandleChatMessage(Packet* packet);
|
||||||
void HandlePrivateChatMessage(Packet* packet);
|
void HandlePrivateChatMessage(Packet* packet);
|
||||||
|
void SendPrivateChatMessage(const PlayerData& sender, const PlayerData& receiver, const PlayerData& routeTo, const LUWString& message, const eChatChannel channel, const eChatMessageResponseCode responseCode);
|
||||||
|
|
||||||
void HandleTeamInvite(Packet* packet);
|
void HandleTeamInvite(Packet* packet);
|
||||||
void HandleTeamInviteResponse(Packet* packet);
|
void HandleTeamInviteResponse(Packet* packet);
|
||||||
@ -23,18 +63,18 @@ namespace ChatPacketHandler {
|
|||||||
void HandleTeamLootOption(Packet* packet);
|
void HandleTeamLootOption(Packet* packet);
|
||||||
void HandleTeamStatusRequest(Packet* packet);
|
void HandleTeamStatusRequest(Packet* packet);
|
||||||
|
|
||||||
void SendTeamInvite(PlayerData* receiver, PlayerData* sender);
|
void SendTeamInvite(const PlayerData& receiver, const PlayerData& sender);
|
||||||
void SendTeamInviteConfirm(PlayerData* receiver, bool bLeaderIsFreeTrial, LWOOBJID i64LeaderID, LWOZONEID i64LeaderZoneID, uint8_t ucLootFlag, uint8_t ucNumOfOtherPlayers, uint8_t ucResponseCode, std::u16string wsLeaderName);
|
void SendTeamInviteConfirm(const PlayerData& receiver, bool bLeaderIsFreeTrial, LWOOBJID i64LeaderID, LWOZONEID i64LeaderZoneID, uint8_t ucLootFlag, uint8_t ucNumOfOtherPlayers, uint8_t ucResponseCode, std::u16string wsLeaderName);
|
||||||
void SendTeamStatus(PlayerData* receiver, LWOOBJID i64LeaderID, LWOZONEID i64LeaderZoneID, uint8_t ucLootFlag, uint8_t ucNumOfOtherPlayers, std::u16string wsLeaderName);
|
void SendTeamStatus(const PlayerData& receiver, LWOOBJID i64LeaderID, LWOZONEID i64LeaderZoneID, uint8_t ucLootFlag, uint8_t ucNumOfOtherPlayers, std::u16string wsLeaderName);
|
||||||
void SendTeamSetLeader(PlayerData* receiver, LWOOBJID i64PlayerID);
|
void SendTeamSetLeader(const PlayerData& receiver, LWOOBJID i64PlayerID);
|
||||||
void SendTeamAddPlayer(PlayerData* receiver, bool bIsFreeTrial, bool bLocal, bool bNoLootOnDeath, LWOOBJID i64PlayerID, std::u16string wsPlayerName, LWOZONEID zoneID);
|
void SendTeamAddPlayer(const PlayerData& receiver, bool bIsFreeTrial, bool bLocal, bool bNoLootOnDeath, LWOOBJID i64PlayerID, std::u16string wsPlayerName, LWOZONEID zoneID);
|
||||||
void SendTeamRemovePlayer(PlayerData* receiver, bool bDisband, bool bIsKicked, bool bIsLeaving, bool bLocal, LWOOBJID i64LeaderID, LWOOBJID i64PlayerID, std::u16string wsPlayerName);
|
void SendTeamRemovePlayer(const PlayerData& receiver, bool bDisband, bool bIsKicked, bool bIsLeaving, bool bLocal, LWOOBJID i64LeaderID, LWOOBJID i64PlayerID, std::u16string wsPlayerName);
|
||||||
void SendTeamSetOffWorldFlag(PlayerData* receiver, LWOOBJID i64PlayerID, LWOZONEID zoneID);
|
void SendTeamSetOffWorldFlag(const PlayerData& receiver, LWOOBJID i64PlayerID, LWOZONEID zoneID);
|
||||||
|
|
||||||
//FriendData is the player we're SENDING this stuff to. Player is the friend that changed state.
|
//FriendData is the player we're SENDING this stuff to. Player is the friend that changed state.
|
||||||
void SendFriendUpdate(PlayerData* friendData, PlayerData* playerData, uint8_t notifyType, uint8_t isBestFriend);
|
void SendFriendUpdate(const PlayerData& friendData, const PlayerData& playerData, uint8_t notifyType, uint8_t isBestFriend);
|
||||||
|
|
||||||
void SendFriendRequest(PlayerData* receiver, PlayerData* sender);
|
void SendFriendRequest(const PlayerData& receiver, const PlayerData& sender);
|
||||||
void SendFriendResponse(PlayerData* receiver, PlayerData* sender, eAddFriendResponseType responseCode, uint8_t isBestFriendsAlready = 0U, uint8_t isBestFriendRequest = 0U);
|
void SendFriendResponse(const PlayerData& receiver, const PlayerData& sender, eAddFriendResponseType responseCode, uint8_t isBestFriendsAlready = 0U, uint8_t isBestFriendRequest = 0U);
|
||||||
void SendRemoveFriend(PlayerData* receiver, std::string& personToRemove, bool isSuccessful);
|
void SendRemoveFriend(const PlayerData& receiver, std::string& personToRemove, bool isSuccessful);
|
||||||
};
|
};
|
||||||
|
@ -20,8 +20,10 @@
|
|||||||
#include "eChatInternalMessageType.h"
|
#include "eChatInternalMessageType.h"
|
||||||
#include "eWorldMessageType.h"
|
#include "eWorldMessageType.h"
|
||||||
#include "ChatIgnoreList.h"
|
#include "ChatIgnoreList.h"
|
||||||
|
#include "StringifiedEnum.h"
|
||||||
|
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
|
#include "Server.h"
|
||||||
|
|
||||||
//RakNet includes:
|
//RakNet includes:
|
||||||
#include "RakNetDefines.h"
|
#include "RakNetDefines.h"
|
||||||
@ -38,7 +40,6 @@ namespace Game {
|
|||||||
PlayerContainer playerContainer;
|
PlayerContainer playerContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger* SetupLogger();
|
|
||||||
void HandlePacket(Packet* packet);
|
void HandlePacket(Packet* packet);
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
@ -51,14 +52,13 @@ int main(int argc, char** argv) {
|
|||||||
std::signal(SIGINT, Game::OnSignal);
|
std::signal(SIGINT, Game::OnSignal);
|
||||||
std::signal(SIGTERM, Game::OnSignal);
|
std::signal(SIGTERM, Game::OnSignal);
|
||||||
|
|
||||||
|
Game::config = new dConfig("chatconfig.ini");
|
||||||
|
|
||||||
//Create all the objects we need to run our service:
|
//Create all the objects we need to run our service:
|
||||||
Game::logger = SetupLogger();
|
Server::SetupLogger("ChatServer");
|
||||||
if (!Game::logger) return EXIT_FAILURE;
|
if (!Game::logger) return EXIT_FAILURE;
|
||||||
|
|
||||||
//Read our config:
|
//Read our config:
|
||||||
Game::config = new dConfig("chatconfig.ini");
|
|
||||||
Game::logger->SetLogToConsole(Game::config->GetValue("log_to_console") != "0");
|
|
||||||
Game::logger->SetLogDebugStatements(Game::config->GetValue("log_debug_statements") == "1");
|
|
||||||
|
|
||||||
LOG("Starting Chat server...");
|
LOG("Starting Chat server...");
|
||||||
LOG("Version: %s", PROJECT_VERSION);
|
LOG("Version: %s", PROJECT_VERSION);
|
||||||
@ -182,18 +182,6 @@ int main(int argc, char** argv) {
|
|||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger* SetupLogger() {
|
|
||||||
std::string logPath = (BinaryPathFinder::GetBinaryDir() / ("logs/ChatServer_" + std::to_string(time(nullptr)) + ".log")).string();
|
|
||||||
bool logToConsole = false;
|
|
||||||
bool logDebugStatements = false;
|
|
||||||
#ifdef _DEBUG
|
|
||||||
logToConsole = true;
|
|
||||||
logDebugStatements = true;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return new Logger(logPath, logToConsole, logDebugStatements);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HandlePacket(Packet* packet) {
|
void HandlePacket(Packet* packet) {
|
||||||
if (packet->data[0] == ID_DISCONNECTION_NOTIFICATION || packet->data[0] == ID_CONNECTION_LOST) {
|
if (packet->data[0] == ID_DISCONNECTION_NOTIFICATION || packet->data[0] == ID_CONNECTION_LOST) {
|
||||||
LOG("A server has disconnected, erasing their connected players from the list.");
|
LOG("A server has disconnected, erasing their connected players from the list.");
|
||||||
@ -236,7 +224,8 @@ void HandlePacket(Packet* packet) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (static_cast<eConnectionType>(packet->data[1]) == eConnectionType::CHAT) {
|
if (static_cast<eConnectionType>(packet->data[1]) == eConnectionType::CHAT) {
|
||||||
switch (static_cast<eChatMessageType>(packet->data[3])) {
|
eChatMessageType chat_message_type = static_cast<eChatMessageType>(packet->data[3]);
|
||||||
|
switch (chat_message_type) {
|
||||||
case eChatMessageType::GET_FRIENDS_LIST:
|
case eChatMessageType::GET_FRIENDS_LIST:
|
||||||
ChatPacketHandler::HandleFriendlistRequest(packet);
|
ChatPacketHandler::HandleFriendlistRequest(packet);
|
||||||
break;
|
break;
|
||||||
@ -306,9 +295,61 @@ void HandlePacket(Packet* packet) {
|
|||||||
case eChatMessageType::TEAM_SET_LOOT:
|
case eChatMessageType::TEAM_SET_LOOT:
|
||||||
ChatPacketHandler::HandleTeamLootOption(packet);
|
ChatPacketHandler::HandleTeamLootOption(packet);
|
||||||
break;
|
break;
|
||||||
|
case eChatMessageType::GMLEVEL_UPDATE:
|
||||||
|
ChatPacketHandler::HandleGMLevelUpdate(packet);
|
||||||
|
break;
|
||||||
|
case eChatMessageType::LOGIN_SESSION_NOTIFY:
|
||||||
|
case eChatMessageType::USER_CHANNEL_CHAT_MESSAGE:
|
||||||
|
case eChatMessageType::WORLD_DISCONNECT_REQUEST:
|
||||||
|
case eChatMessageType::WORLD_PROXIMITY_RESPONSE:
|
||||||
|
case eChatMessageType::WORLD_PARCEL_RESPONSE:
|
||||||
|
case eChatMessageType::TEAM_MISSED_INVITE_CHECK:
|
||||||
|
case eChatMessageType::GUILD_CREATE:
|
||||||
|
case eChatMessageType::GUILD_INVITE:
|
||||||
|
case eChatMessageType::GUILD_INVITE_RESPONSE:
|
||||||
|
case eChatMessageType::GUILD_LEAVE:
|
||||||
|
case eChatMessageType::GUILD_KICK:
|
||||||
|
case eChatMessageType::GUILD_GET_STATUS:
|
||||||
|
case eChatMessageType::GUILD_GET_ALL:
|
||||||
|
case eChatMessageType::SHOW_ALL:
|
||||||
|
case eChatMessageType::BLUEPRINT_MODERATED:
|
||||||
|
case eChatMessageType::BLUEPRINT_MODEL_READY:
|
||||||
|
case eChatMessageType::PROPERTY_READY_FOR_APPROVAL:
|
||||||
|
case eChatMessageType::PROPERTY_MODERATION_CHANGED:
|
||||||
|
case eChatMessageType::PROPERTY_BUILDMODE_CHANGED:
|
||||||
|
case eChatMessageType::PROPERTY_BUILDMODE_CHANGED_REPORT:
|
||||||
|
case eChatMessageType::MAIL:
|
||||||
|
case eChatMessageType::WORLD_INSTANCE_LOCATION_REQUEST:
|
||||||
|
case eChatMessageType::REPUTATION_UPDATE:
|
||||||
|
case eChatMessageType::SEND_CANNED_TEXT:
|
||||||
|
case eChatMessageType::CHARACTER_NAME_CHANGE_REQUEST:
|
||||||
|
case eChatMessageType::CSR_REQUEST:
|
||||||
|
case eChatMessageType::CSR_REPLY:
|
||||||
|
case eChatMessageType::GM_KICK:
|
||||||
|
case eChatMessageType::GM_ANNOUNCE:
|
||||||
|
case eChatMessageType::WORLD_ROUTE_PACKET:
|
||||||
|
case eChatMessageType::GET_ZONE_POPULATIONS:
|
||||||
|
case eChatMessageType::REQUEST_MINIMUM_CHAT_MODE:
|
||||||
|
case eChatMessageType::MATCH_REQUEST:
|
||||||
|
case eChatMessageType::UGCMANIFEST_REPORT_MISSING_FILE:
|
||||||
|
case eChatMessageType::UGCMANIFEST_REPORT_DONE_FILE:
|
||||||
|
case eChatMessageType::UGCMANIFEST_REPORT_DONE_BLUEPRINT:
|
||||||
|
case eChatMessageType::UGCC_REQUEST:
|
||||||
|
case eChatMessageType::WHO:
|
||||||
|
case eChatMessageType::WORLD_PLAYERS_PET_MODERATED_ACKNOWLEDGE:
|
||||||
|
case eChatMessageType::ACHIEVEMENT_NOTIFY:
|
||||||
|
case eChatMessageType::GM_CLOSE_PRIVATE_CHAT_WINDOW:
|
||||||
|
case eChatMessageType::UNEXPECTED_DISCONNECT:
|
||||||
|
case eChatMessageType::PLAYER_READY:
|
||||||
|
case eChatMessageType::GET_DONATION_TOTAL:
|
||||||
|
case eChatMessageType::UPDATE_DONATION:
|
||||||
|
case eChatMessageType::PRG_CSR_COMMAND:
|
||||||
|
case eChatMessageType::HEARTBEAT_REQUEST_FROM_WORLD:
|
||||||
|
case eChatMessageType::UPDATE_FREE_TRIAL_STATUS:
|
||||||
|
LOG("Unhandled CHAT Message id: %s (%i)", StringifiedEnum::ToString(chat_message_type).data(), chat_message_type);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
LOG("Unknown CHAT id: %i", int(packet->data[3]));
|
LOG("Unknown CHAT Message id: %i", chat_message_type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "Database.h"
|
#include "Database.h"
|
||||||
#include "eConnectionType.h"
|
#include "eConnectionType.h"
|
||||||
#include "eChatInternalMessageType.h"
|
#include "eChatInternalMessageType.h"
|
||||||
|
#include "eGameMasterLevel.h"
|
||||||
#include "ChatPackets.h"
|
#include "ChatPackets.h"
|
||||||
#include "dConfig.h"
|
#include "dConfig.h"
|
||||||
|
|
||||||
@ -22,33 +23,43 @@ PlayerContainer::~PlayerContainer() {
|
|||||||
m_Players.clear();
|
m_Players.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlayerData::PlayerData() {
|
||||||
|
gmLevel = eGameMasterLevel::CIVILIAN;
|
||||||
|
}
|
||||||
|
|
||||||
TeamData::TeamData() {
|
TeamData::TeamData() {
|
||||||
lootFlag = Game::config->GetValue("default_team_loot") == "0" ? 0 : 1;
|
lootFlag = Game::config->GetValue("default_team_loot") == "0" ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerContainer::InsertPlayer(Packet* packet) {
|
void PlayerContainer::InsertPlayer(Packet* packet) {
|
||||||
CINSTREAM_SKIP_HEADER;
|
CINSTREAM_SKIP_HEADER;
|
||||||
PlayerData* data = new PlayerData();
|
LWOOBJID playerId;
|
||||||
inStream.Read(data->playerID);
|
if (!inStream.Read(playerId)) {
|
||||||
|
LOG("Failed to read player ID");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& data = m_Players[playerId];
|
||||||
|
data.playerID = playerId;
|
||||||
|
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
inStream.Read<uint32_t>(len);
|
inStream.Read<uint32_t>(len);
|
||||||
|
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
char character; inStream.Read<char>(character);
|
char character; inStream.Read<char>(character);
|
||||||
data->playerName += character;
|
data.playerName += character;
|
||||||
}
|
}
|
||||||
|
|
||||||
inStream.Read(data->zoneID);
|
inStream.Read(data.zoneID);
|
||||||
inStream.Read(data->muteExpire);
|
inStream.Read(data.muteExpire);
|
||||||
data->sysAddr = packet->systemAddress;
|
inStream.Read(data.gmLevel);
|
||||||
|
data.sysAddr = packet->systemAddress;
|
||||||
|
|
||||||
m_Names[data->playerID] = GeneralUtils::UTF8ToUTF16(data->playerName);
|
m_Names[data.playerID] = GeneralUtils::UTF8ToUTF16(data.playerName);
|
||||||
|
|
||||||
m_Players.insert(std::make_pair(data->playerID, data));
|
LOG("Added user: %s (%llu), zone: %i", data.playerName.c_str(), data.playerID, data.zoneID.GetMapID());
|
||||||
LOG("Added user: %s (%llu), zone: %i", data->playerName.c_str(), data->playerID, data->zoneID.GetMapID());
|
|
||||||
|
|
||||||
Database::Get()->UpdateActivityLog(data->playerID, eActivityType::PlayerLoggedIn, data->zoneID.GetMapID());
|
Database::Get()->UpdateActivityLog(data.playerID, eActivityType::PlayerLoggedIn, data.zoneID.GetMapID());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerContainer::RemovePlayer(Packet* packet) {
|
void PlayerContainer::RemovePlayer(Packet* packet) {
|
||||||
@ -57,26 +68,27 @@ void PlayerContainer::RemovePlayer(Packet* packet) {
|
|||||||
inStream.Read(playerID);
|
inStream.Read(playerID);
|
||||||
|
|
||||||
//Before they get kicked, we need to also send a message to their friends saying that they disconnected.
|
//Before they get kicked, we need to also send a message to their friends saying that they disconnected.
|
||||||
std::unique_ptr<PlayerData> player(this->GetPlayerData(playerID));
|
const auto& player = GetPlayerData(playerID);
|
||||||
|
|
||||||
if (player == nullptr) {
|
if (!player) {
|
||||||
|
LOG("Failed to find user: %llu", playerID);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& fr : player->friends) {
|
for (const auto& fr : player.friends) {
|
||||||
auto fd = this->GetPlayerData(fr.friendID);
|
const auto& fd = this->GetPlayerData(fr.friendID);
|
||||||
if (fd) ChatPacketHandler::SendFriendUpdate(fd, player.get(), 0, fr.isBestFriend);
|
if (fd) ChatPacketHandler::SendFriendUpdate(fd, player, 0, fr.isBestFriend);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* team = GetTeam(playerID);
|
auto* team = GetTeam(playerID);
|
||||||
|
|
||||||
if (team != nullptr) {
|
if (team != nullptr) {
|
||||||
const auto memberName = GeneralUtils::UTF8ToUTF16(std::string(player->playerName.c_str()));
|
const auto memberName = GeneralUtils::UTF8ToUTF16(player.playerName);
|
||||||
|
|
||||||
for (const auto memberId : team->memberIDs) {
|
for (const auto memberId : team->memberIDs) {
|
||||||
auto* otherMember = GetPlayerData(memberId);
|
const auto& otherMember = GetPlayerData(memberId);
|
||||||
|
|
||||||
if (otherMember == nullptr) continue;
|
if (!otherMember) continue;
|
||||||
|
|
||||||
ChatPacketHandler::SendTeamSetOffWorldFlag(otherMember, playerID, { 0, 0, 0 });
|
ChatPacketHandler::SendTeamSetOffWorldFlag(otherMember, playerID, { 0, 0, 0 });
|
||||||
}
|
}
|
||||||
@ -85,7 +97,7 @@ void PlayerContainer::RemovePlayer(Packet* packet) {
|
|||||||
LOG("Removed user: %llu", playerID);
|
LOG("Removed user: %llu", playerID);
|
||||||
m_Players.erase(playerID);
|
m_Players.erase(playerID);
|
||||||
|
|
||||||
Database::Get()->UpdateActivityLog(playerID, eActivityType::PlayerLoggedOut, player->zoneID.GetMapID());
|
Database::Get()->UpdateActivityLog(playerID, eActivityType::PlayerLoggedOut, player.zoneID.GetMapID());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerContainer::MuteUpdate(Packet* packet) {
|
void PlayerContainer::MuteUpdate(Packet* packet) {
|
||||||
@ -95,15 +107,15 @@ void PlayerContainer::MuteUpdate(Packet* packet) {
|
|||||||
time_t expire = 0;
|
time_t expire = 0;
|
||||||
inStream.Read(expire);
|
inStream.Read(expire);
|
||||||
|
|
||||||
auto* player = this->GetPlayerData(playerID);
|
auto& player = this->GetPlayerDataMutable(playerID);
|
||||||
|
|
||||||
if (player == nullptr) {
|
if (!player) {
|
||||||
LOG("Failed to find user: %llu", playerID);
|
LOG("Failed to find user: %llu", playerID);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
player->muteExpire = expire;
|
player.muteExpire = expire;
|
||||||
|
|
||||||
BroadcastMuteUpdate(playerID, expire);
|
BroadcastMuteUpdate(playerID, expire);
|
||||||
}
|
}
|
||||||
@ -201,11 +213,11 @@ TeamData* PlayerContainer::GetTeam(LWOOBJID playerID) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PlayerContainer::AddMember(TeamData* team, LWOOBJID playerID) {
|
void PlayerContainer::AddMember(TeamData* team, LWOOBJID playerID) {
|
||||||
if (team->memberIDs.size() >= 4){
|
if (team->memberIDs.size() >= 4) {
|
||||||
LOG("Tried to add player to team that already had 4 players");
|
LOG("Tried to add player to team that already had 4 players");
|
||||||
auto* player = GetPlayerData(playerID);
|
const auto& player = GetPlayerData(playerID);
|
||||||
if (!player) return;
|
if (!player) return;
|
||||||
ChatPackets::SendSystemMessage(player->sysAddr, u"The teams is full! You have not been added to a team!");
|
ChatPackets::SendSystemMessage(player.sysAddr, u"The teams is full! You have not been added to a team!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,18 +227,18 @@ void PlayerContainer::AddMember(TeamData* team, LWOOBJID playerID) {
|
|||||||
|
|
||||||
team->memberIDs.push_back(playerID);
|
team->memberIDs.push_back(playerID);
|
||||||
|
|
||||||
auto* leader = GetPlayerData(team->leaderID);
|
const auto& leader = GetPlayerData(team->leaderID);
|
||||||
auto* member = GetPlayerData(playerID);
|
const auto& member = GetPlayerData(playerID);
|
||||||
|
|
||||||
if (leader == nullptr || member == nullptr) return;
|
if (!leader || !member) return;
|
||||||
|
|
||||||
const auto leaderName = GeneralUtils::UTF8ToUTF16(leader->playerName);
|
const auto leaderName = GeneralUtils::UTF8ToUTF16(leader.playerName);
|
||||||
const auto memberName = GeneralUtils::UTF8ToUTF16(member->playerName);
|
const auto memberName = GeneralUtils::UTF8ToUTF16(member.playerName);
|
||||||
|
|
||||||
ChatPacketHandler::SendTeamInviteConfirm(member, false, leader->playerID, leader->zoneID, team->lootFlag, 0, 0, leaderName);
|
ChatPacketHandler::SendTeamInviteConfirm(member, false, leader.playerID, leader.zoneID, team->lootFlag, 0, 0, leaderName);
|
||||||
|
|
||||||
if (!team->local) {
|
if (!team->local) {
|
||||||
ChatPacketHandler::SendTeamSetLeader(member, leader->playerID);
|
ChatPacketHandler::SendTeamSetLeader(member, leader.playerID);
|
||||||
} else {
|
} else {
|
||||||
ChatPacketHandler::SendTeamSetLeader(member, LWOOBJID_EMPTY);
|
ChatPacketHandler::SendTeamSetLeader(member, LWOOBJID_EMPTY);
|
||||||
}
|
}
|
||||||
@ -234,16 +246,16 @@ void PlayerContainer::AddMember(TeamData* team, LWOOBJID playerID) {
|
|||||||
UpdateTeamsOnWorld(team, false);
|
UpdateTeamsOnWorld(team, false);
|
||||||
|
|
||||||
for (const auto memberId : team->memberIDs) {
|
for (const auto memberId : team->memberIDs) {
|
||||||
auto* otherMember = GetPlayerData(memberId);
|
const auto& otherMember = GetPlayerData(memberId);
|
||||||
|
|
||||||
if (otherMember == member) continue;
|
if (otherMember == member) continue;
|
||||||
|
|
||||||
const auto otherMemberName = GetName(memberId);
|
const auto otherMemberName = GetName(memberId);
|
||||||
|
|
||||||
ChatPacketHandler::SendTeamAddPlayer(member, false, team->local, false, memberId, otherMemberName, otherMember != nullptr ? otherMember->zoneID : LWOZONEID(0, 0, 0));
|
ChatPacketHandler::SendTeamAddPlayer(member, false, team->local, false, memberId, otherMemberName, otherMember ? otherMember.zoneID : LWOZONEID(0, 0, 0));
|
||||||
|
|
||||||
if (otherMember != nullptr) {
|
if (otherMember) {
|
||||||
ChatPacketHandler::SendTeamAddPlayer(otherMember, false, team->local, false, member->playerID, memberName, member->zoneID);
|
ChatPacketHandler::SendTeamAddPlayer(otherMember, false, team->local, false, member.playerID, memberName, member.zoneID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -253,9 +265,9 @@ void PlayerContainer::RemoveMember(TeamData* team, LWOOBJID playerID, bool disba
|
|||||||
|
|
||||||
if (index == team->memberIDs.end()) return;
|
if (index == team->memberIDs.end()) return;
|
||||||
|
|
||||||
auto* member = GetPlayerData(playerID);
|
const auto& member = GetPlayerData(playerID);
|
||||||
|
|
||||||
if (member != nullptr && !silent) {
|
if (member && !silent) {
|
||||||
ChatPacketHandler::SendTeamSetLeader(member, LWOOBJID_EMPTY);
|
ChatPacketHandler::SendTeamSetLeader(member, LWOOBJID_EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,9 +278,9 @@ void PlayerContainer::RemoveMember(TeamData* team, LWOOBJID playerID, bool disba
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* otherMember = GetPlayerData(memberId);
|
const auto& otherMember = GetPlayerData(memberId);
|
||||||
|
|
||||||
if (otherMember == nullptr) continue;
|
if (!otherMember) continue;
|
||||||
|
|
||||||
ChatPacketHandler::SendTeamRemovePlayer(otherMember, disband, kicked, leaving, false, team->leaderID, playerID, memberName);
|
ChatPacketHandler::SendTeamRemovePlayer(otherMember, disband, kicked, leaving, false, team->leaderID, playerID, memberName);
|
||||||
}
|
}
|
||||||
@ -290,9 +302,9 @@ void PlayerContainer::PromoteMember(TeamData* team, LWOOBJID newLeader) {
|
|||||||
team->leaderID = newLeader;
|
team->leaderID = newLeader;
|
||||||
|
|
||||||
for (const auto memberId : team->memberIDs) {
|
for (const auto memberId : team->memberIDs) {
|
||||||
auto* otherMember = GetPlayerData(memberId);
|
const auto& otherMember = GetPlayerData(memberId);
|
||||||
|
|
||||||
if (otherMember == nullptr) continue;
|
if (!otherMember) continue;
|
||||||
|
|
||||||
ChatPacketHandler::SendTeamSetLeader(otherMember, newLeader);
|
ChatPacketHandler::SendTeamSetLeader(otherMember, newLeader);
|
||||||
}
|
}
|
||||||
@ -304,14 +316,14 @@ void PlayerContainer::DisbandTeam(TeamData* team) {
|
|||||||
if (index == mTeams.end()) return;
|
if (index == mTeams.end()) return;
|
||||||
|
|
||||||
for (const auto memberId : team->memberIDs) {
|
for (const auto memberId : team->memberIDs) {
|
||||||
auto* otherMember = GetPlayerData(memberId);
|
const auto& otherMember = GetPlayerData(memberId);
|
||||||
|
|
||||||
if (otherMember == nullptr) continue;
|
if (!otherMember) continue;
|
||||||
|
|
||||||
const auto memberName = GeneralUtils::UTF8ToUTF16(otherMember->playerName);
|
const auto memberName = GeneralUtils::UTF8ToUTF16(otherMember.playerName);
|
||||||
|
|
||||||
ChatPacketHandler::SendTeamSetLeader(otherMember, LWOOBJID_EMPTY);
|
ChatPacketHandler::SendTeamSetLeader(otherMember, LWOOBJID_EMPTY);
|
||||||
ChatPacketHandler::SendTeamRemovePlayer(otherMember, true, false, false, team->local, team->leaderID, otherMember->playerID, memberName);
|
ChatPacketHandler::SendTeamRemovePlayer(otherMember, true, false, false, team->local, team->leaderID, otherMember.playerID, memberName);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateTeamsOnWorld(team, true);
|
UpdateTeamsOnWorld(team, true);
|
||||||
@ -326,19 +338,19 @@ void PlayerContainer::TeamStatusUpdate(TeamData* team) {
|
|||||||
|
|
||||||
if (index == mTeams.end()) return;
|
if (index == mTeams.end()) return;
|
||||||
|
|
||||||
auto* leader = GetPlayerData(team->leaderID);
|
const auto& leader = GetPlayerData(team->leaderID);
|
||||||
|
|
||||||
if (leader == nullptr) return;
|
if (!leader) return;
|
||||||
|
|
||||||
const auto leaderName = GeneralUtils::UTF8ToUTF16(leader->playerName);
|
const auto leaderName = GeneralUtils::UTF8ToUTF16(leader.playerName);
|
||||||
|
|
||||||
for (const auto memberId : team->memberIDs) {
|
for (const auto memberId : team->memberIDs) {
|
||||||
auto* otherMember = GetPlayerData(memberId);
|
const auto& otherMember = GetPlayerData(memberId);
|
||||||
|
|
||||||
if (otherMember == nullptr) continue;
|
if (!otherMember) continue;
|
||||||
|
|
||||||
if (!team->local) {
|
if (!team->local) {
|
||||||
ChatPacketHandler::SendTeamStatus(otherMember, team->leaderID, leader->zoneID, team->lootFlag, 0, leaderName);
|
ChatPacketHandler::SendTeamStatus(otherMember, team->leaderID, leader.zoneID, team->lootFlag, 0, leaderName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -364,23 +376,42 @@ void PlayerContainer::UpdateTeamsOnWorld(TeamData* team, bool deleteTeam) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::u16string PlayerContainer::GetName(LWOOBJID playerID) {
|
std::u16string PlayerContainer::GetName(LWOOBJID playerID) {
|
||||||
const auto& pair = m_Names.find(playerID);
|
const auto iter = m_Names.find(playerID);
|
||||||
|
|
||||||
if (pair == m_Names.end()) return u"";
|
if (iter == m_Names.end()) return u"";
|
||||||
|
|
||||||
return pair->second;
|
return iter->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
LWOOBJID PlayerContainer::GetId(const std::u16string& playerName) {
|
LWOOBJID PlayerContainer::GetId(const std::u16string& playerName) {
|
||||||
for (const auto& pair : m_Names) {
|
LWOOBJID toReturn = LWOOBJID_EMPTY;
|
||||||
if (pair.second == playerName) {
|
|
||||||
return pair.first;
|
for (const auto& [id, name] : m_Names) {
|
||||||
|
if (name == playerName) {
|
||||||
|
toReturn = id;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return LWOOBJID_EMPTY;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlayerContainer::GetIsMuted(PlayerData* data) {
|
PlayerData& PlayerContainer::GetPlayerDataMutable(const LWOOBJID& playerID) {
|
||||||
return data->muteExpire == 1 || data->muteExpire > time(NULL);
|
return m_Players[playerID];
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerData& PlayerContainer::GetPlayerDataMutable(const std::string& playerName) {
|
||||||
|
for (auto& [id, player] : m_Players) {
|
||||||
|
if (!player) continue;
|
||||||
|
if (player.playerName == playerName) return player;
|
||||||
|
}
|
||||||
|
return m_Players[LWOOBJID_EMPTY];
|
||||||
|
}
|
||||||
|
|
||||||
|
const PlayerData& PlayerContainer::GetPlayerData(const LWOOBJID& playerID) {
|
||||||
|
return GetPlayerDataMutable(playerID);
|
||||||
|
}
|
||||||
|
|
||||||
|
const PlayerData& PlayerContainer::GetPlayerData(const std::string& playerName) {
|
||||||
|
return GetPlayerDataMutable(playerName);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,10 @@
|
|||||||
#include "dServer.h"
|
#include "dServer.h"
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
enum class eGameMasterLevel : uint8_t;
|
||||||
|
|
||||||
struct IgnoreData {
|
struct IgnoreData {
|
||||||
|
IgnoreData(const std::string& name, const LWOOBJID& id) : playerName(name), playerId(id) {}
|
||||||
inline bool operator==(const std::string& other) const noexcept {
|
inline bool operator==(const std::string& other) const noexcept {
|
||||||
return playerName == other;
|
return playerName == other;
|
||||||
}
|
}
|
||||||
@ -16,19 +19,34 @@ struct IgnoreData {
|
|||||||
return playerId == other;
|
return playerId == other;
|
||||||
}
|
}
|
||||||
|
|
||||||
LWOOBJID playerId;
|
LWOOBJID playerId = LWOOBJID_EMPTY;
|
||||||
std::string playerName;
|
std::string playerName;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PlayerData {
|
struct PlayerData {
|
||||||
LWOOBJID playerID;
|
PlayerData();
|
||||||
|
operator bool() const noexcept {
|
||||||
|
return playerID != LWOOBJID_EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const PlayerData& other) const noexcept {
|
||||||
|
return playerID == other.playerID;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GetIsMuted() const {
|
||||||
|
return muteExpire == 1 || muteExpire > time(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
SystemAddress sysAddr{};
|
||||||
|
LWOZONEID zoneID{};
|
||||||
|
LWOOBJID playerID = LWOOBJID_EMPTY;
|
||||||
|
time_t muteExpire = 0;
|
||||||
|
uint8_t countOfBestFriends = 0;
|
||||||
std::string playerName;
|
std::string playerName;
|
||||||
SystemAddress sysAddr;
|
|
||||||
LWOZONEID zoneID;
|
|
||||||
std::vector<FriendData> friends;
|
std::vector<FriendData> friends;
|
||||||
std::vector<IgnoreData> ignoredPlayers;
|
std::vector<IgnoreData> ignoredPlayers;
|
||||||
time_t muteExpire;
|
eGameMasterLevel gmLevel;
|
||||||
uint8_t countOfBestFriends = 0;
|
bool isFTP = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TeamData {
|
struct TeamData {
|
||||||
@ -52,22 +70,10 @@ public:
|
|||||||
void CreateTeamServer(Packet* packet);
|
void CreateTeamServer(Packet* packet);
|
||||||
void BroadcastMuteUpdate(LWOOBJID player, time_t time);
|
void BroadcastMuteUpdate(LWOOBJID player, time_t time);
|
||||||
|
|
||||||
PlayerData* GetPlayerData(const LWOOBJID& playerID) {
|
const PlayerData& GetPlayerData(const LWOOBJID& playerID);
|
||||||
auto it = m_Players.find(playerID);
|
const PlayerData& GetPlayerData(const std::string& playerName);
|
||||||
if (it != m_Players.end()) return it->second;
|
PlayerData& GetPlayerDataMutable(const LWOOBJID& playerID);
|
||||||
return nullptr;
|
PlayerData& GetPlayerDataMutable(const std::string& playerName);
|
||||||
}
|
|
||||||
|
|
||||||
PlayerData* GetPlayerData(const std::string& playerName) {
|
|
||||||
for (auto player : m_Players) {
|
|
||||||
if (player.second) {
|
|
||||||
std::string pn = player.second->playerName.c_str();
|
|
||||||
if (pn == playerName) return player.second;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
TeamData* CreateLocalTeam(std::vector<LWOOBJID> members);
|
TeamData* CreateLocalTeam(std::vector<LWOOBJID> members);
|
||||||
TeamData* CreateTeam(LWOOBJID leader, bool local = false);
|
TeamData* CreateTeam(LWOOBJID leader, bool local = false);
|
||||||
@ -80,15 +86,12 @@ public:
|
|||||||
void UpdateTeamsOnWorld(TeamData* team, bool deleteTeam);
|
void UpdateTeamsOnWorld(TeamData* team, bool deleteTeam);
|
||||||
std::u16string GetName(LWOOBJID playerID);
|
std::u16string GetName(LWOOBJID playerID);
|
||||||
LWOOBJID GetId(const std::u16string& playerName);
|
LWOOBJID GetId(const std::u16string& playerName);
|
||||||
bool GetIsMuted(PlayerData* data);
|
|
||||||
uint32_t GetMaxNumberOfBestFriends() { return m_MaxNumberOfBestFriends; }
|
uint32_t GetMaxNumberOfBestFriends() { return m_MaxNumberOfBestFriends; }
|
||||||
uint32_t GetMaxNumberOfFriends() { return m_MaxNumberOfFriends; }
|
uint32_t GetMaxNumberOfFriends() { return m_MaxNumberOfFriends; }
|
||||||
|
|
||||||
std::map<LWOOBJID, PlayerData*>& GetAllPlayerData() { return m_Players; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LWOOBJID m_TeamIDCounter = 0;
|
LWOOBJID m_TeamIDCounter = 0;
|
||||||
std::map<LWOOBJID, PlayerData*> m_Players;
|
std::map<LWOOBJID, PlayerData> m_Players;
|
||||||
std::vector<TeamData*> mTeams;
|
std::vector<TeamData*> mTeams;
|
||||||
std::unordered_map<LWOOBJID, std::u16string> m_Names;
|
std::unordered_map<LWOOBJID, std::u16string> m_Names;
|
||||||
uint32_t m_MaxNumberOfBestFriends = 5;
|
uint32_t m_MaxNumberOfBestFriends = 5;
|
||||||
|
@ -20,6 +20,12 @@ set(DCOMMON_SOURCES
|
|||||||
"FdbToSqlite.cpp"
|
"FdbToSqlite.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Workaround for compiler bug where the optimized code could result in a memcpy of 0 bytes, even though that isnt possible.
|
||||||
|
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97185
|
||||||
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
|
set_source_files_properties("FdbToSqlite.cpp" PROPERTIES COMPILE_FLAGS "-Wno-stringop-overflow")
|
||||||
|
endif()
|
||||||
|
|
||||||
add_subdirectory(dClient)
|
add_subdirectory(dClient)
|
||||||
|
|
||||||
foreach(file ${DCOMMON_DCLIENT_SOURCES})
|
foreach(file ${DCOMMON_DCLIENT_SOURCES})
|
||||||
|
50
dCommon/PositionUpdate.h
Normal file
50
dCommon/PositionUpdate.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#ifndef __POSITIONUPDATE__H__
|
||||||
|
#define __POSITIONUPDATE__H__
|
||||||
|
|
||||||
|
#include "NiPoint3.h"
|
||||||
|
#include "NiQuaternion.h"
|
||||||
|
|
||||||
|
|
||||||
|
struct RemoteInputInfo {
|
||||||
|
RemoteInputInfo() {
|
||||||
|
m_RemoteInputX = 0;
|
||||||
|
m_RemoteInputY = 0;
|
||||||
|
m_IsPowersliding = false;
|
||||||
|
m_IsModified = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void operator=(const RemoteInputInfo& other) {
|
||||||
|
m_RemoteInputX = other.m_RemoteInputX;
|
||||||
|
m_RemoteInputY = other.m_RemoteInputY;
|
||||||
|
m_IsPowersliding = other.m_IsPowersliding;
|
||||||
|
m_IsModified = other.m_IsModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const RemoteInputInfo& other) {
|
||||||
|
return m_RemoteInputX == other.m_RemoteInputX && m_RemoteInputY == other.m_RemoteInputY && m_IsPowersliding == other.m_IsPowersliding && m_IsModified == other.m_IsModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
float m_RemoteInputX;
|
||||||
|
float m_RemoteInputY;
|
||||||
|
bool m_IsPowersliding;
|
||||||
|
bool m_IsModified;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct LocalSpaceInfo {
|
||||||
|
LWOOBJID objectId = LWOOBJID_EMPTY;
|
||||||
|
NiPoint3 position = NiPoint3::ZERO;
|
||||||
|
NiPoint3 linearVelocity = NiPoint3::ZERO;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PositionUpdate {
|
||||||
|
NiPoint3 position = NiPoint3::ZERO;
|
||||||
|
NiQuaternion rotation = NiQuaternion::IDENTITY;
|
||||||
|
bool onGround = false;
|
||||||
|
bool onRail = false;
|
||||||
|
NiPoint3 velocity = NiPoint3::ZERO;
|
||||||
|
NiPoint3 angularVelocity = NiPoint3::ZERO;
|
||||||
|
LocalSpaceInfo localSpaceInfo;
|
||||||
|
RemoteInputInfo remoteInputInfo;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //!__POSITIONUPDATE__H__
|
@ -9,15 +9,15 @@ namespace StringifiedEnum {
|
|||||||
const std::string_view ToString(const T e) {
|
const std::string_view ToString(const T e) {
|
||||||
static_assert(std::is_enum_v<T>, "Not an enum"); // Check type
|
static_assert(std::is_enum_v<T>, "Not an enum"); // Check type
|
||||||
|
|
||||||
constexpr auto sv = &magic_enum::enum_entries<T>();
|
constexpr auto& sv = magic_enum::enum_entries<T>();
|
||||||
|
|
||||||
const auto it = std::lower_bound(
|
const auto it = std::lower_bound(
|
||||||
sv->begin(), sv->end(), e,
|
sv.begin(), sv.end(), e,
|
||||||
[&](const std::pair<T, std::string_view>& lhs, const T rhs) { return lhs.first < rhs; }
|
[&](const std::pair<T, std::string_view>& lhs, const T rhs) { return lhs.first < rhs; }
|
||||||
);
|
);
|
||||||
|
|
||||||
std::string_view output;
|
std::string_view output;
|
||||||
if (it != sv->end() && it->first == e) {
|
if (it != sv.end() && it->first == e) {
|
||||||
output = it->second;
|
output = it->second;
|
||||||
} else {
|
} else {
|
||||||
output = "UNKNOWN";
|
output = "UNKNOWN";
|
||||||
|
@ -130,7 +130,7 @@ public:
|
|||||||
LWOOBJID friendID;
|
LWOOBJID friendID;
|
||||||
std::string friendName;
|
std::string friendName;
|
||||||
|
|
||||||
void Serialize(RakNet::BitStream& bitStream) {
|
void Serialize(RakNet::BitStream& bitStream) const {
|
||||||
bitStream.Write<uint8_t>(isOnline);
|
bitStream.Write<uint8_t>(isOnline);
|
||||||
bitStream.Write<uint8_t>(isBestFriend);
|
bitStream.Write<uint8_t>(isBestFriend);
|
||||||
bitStream.Write<uint8_t>(isFTP);
|
bitStream.Write<uint8_t>(isFTP);
|
||||||
|
@ -629,7 +629,7 @@ enum class eGameMessageType : uint16_t {
|
|||||||
GET_INSTRUCTION_COUNT = 676,
|
GET_INSTRUCTION_COUNT = 676,
|
||||||
GET_IS_NPC = 677,
|
GET_IS_NPC = 677,
|
||||||
ACTIVATE_BUBBLE_BUFF = 678,
|
ACTIVATE_BUBBLE_BUFF = 678,
|
||||||
DECTIVATE_BUBBLE_BUFF = 679, // thanks netdevil
|
DECTIVATE_BUBBLE_BUFF = 679, // This is spelled wrong in the client, so we misspell it here.
|
||||||
EXHIBIT_VOTE = 680,
|
EXHIBIT_VOTE = 680,
|
||||||
ADD_PET_TO_PLAYER = 681,
|
ADD_PET_TO_PLAYER = 681,
|
||||||
REMOVE_PET_FROM_PLAYER = 682,
|
REMOVE_PET_FROM_PLAYER = 682,
|
||||||
|
13
dCommon/dEnums/ePetAbilityType.h
Normal file
13
dCommon/dEnums/ePetAbilityType.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#ifndef __EPETABILITYTYPE__H__
|
||||||
|
#define __EPETABILITYTYPE__H__
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
enum class ePetAbilityType : uint32_t {
|
||||||
|
Invalid,
|
||||||
|
GoToObject,
|
||||||
|
JumpOnObject,
|
||||||
|
DigAtPosition
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //!__EPETABILITYTYPE__H__
|
@ -4,9 +4,13 @@
|
|||||||
// Static Variables
|
// Static Variables
|
||||||
static CppSQLite3DB* conn = new CppSQLite3DB();
|
static CppSQLite3DB* conn = new CppSQLite3DB();
|
||||||
|
|
||||||
|
// Status Variables
|
||||||
|
bool CDClientDatabase::isConnected = false;
|
||||||
|
|
||||||
//! Opens a connection with the CDClient
|
//! Opens a connection with the CDClient
|
||||||
void CDClientDatabase::Connect(const std::string& filename) {
|
void CDClientDatabase::Connect(const std::string& filename) {
|
||||||
conn->open(filename.c_str());
|
conn->open(filename.c_str());
|
||||||
|
isConnected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Queries the CDClient
|
//! Queries the CDClient
|
||||||
|
@ -15,6 +15,10 @@
|
|||||||
|
|
||||||
//! The CDClient Database namespace
|
//! The CDClient Database namespace
|
||||||
namespace CDClientDatabase {
|
namespace CDClientDatabase {
|
||||||
|
/**
|
||||||
|
* Boolean defining the connection status of CDClient
|
||||||
|
*/
|
||||||
|
extern bool isConnected;
|
||||||
|
|
||||||
//! Opens a connection with the CDClient
|
//! Opens a connection with the CDClient
|
||||||
/*!
|
/*!
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "CDAnimationsTable.h"
|
#include "CDAnimationsTable.h"
|
||||||
#include "CDBehaviorParameterTable.h"
|
#include "CDBehaviorParameterTable.h"
|
||||||
#include "CDBehaviorTemplateTable.h"
|
#include "CDBehaviorTemplateTable.h"
|
||||||
|
#include "CDClientDatabase.h"
|
||||||
#include "CDComponentsRegistryTable.h"
|
#include "CDComponentsRegistryTable.h"
|
||||||
#include "CDCurrencyTableTable.h"
|
#include "CDCurrencyTableTable.h"
|
||||||
#include "CDDestructibleComponentTable.h"
|
#include "CDDestructibleComponentTable.h"
|
||||||
@ -39,6 +40,8 @@
|
|||||||
#include "CDRailActivatorComponent.h"
|
#include "CDRailActivatorComponent.h"
|
||||||
#include "CDRewardCodesTable.h"
|
#include "CDRewardCodesTable.h"
|
||||||
|
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
#ifndef CDCLIENT_CACHE_ALL
|
#ifndef CDCLIENT_CACHE_ALL
|
||||||
// Uncomment this to cache the full cdclient database into memory. This will make the server load faster, but will use more memory.
|
// Uncomment this to cache the full cdclient database into memory. This will make the server load faster, but will use more memory.
|
||||||
// A vanilla CDClient takes about 46MB of memory + the regular world data.
|
// A vanilla CDClient takes about 46MB of memory + the regular world data.
|
||||||
@ -51,7 +54,16 @@
|
|||||||
#define CDCLIENT_DONT_CACHE_TABLE(x)
|
#define CDCLIENT_DONT_CACHE_TABLE(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CDClientManager::CDClientManager() {
|
class CDClientConnectionException : public std::exception {
|
||||||
|
public:
|
||||||
|
virtual const char* what() const throw() {
|
||||||
|
return "CDClientDatabase is not connected!";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void CDClientManager::LoadValuesFromDatabase() {
|
||||||
|
if (!CDClientDatabase::isConnected) throw CDClientConnectionException();
|
||||||
|
|
||||||
CDActivityRewardsTable::Instance().LoadValuesFromDatabase();
|
CDActivityRewardsTable::Instance().LoadValuesFromDatabase();
|
||||||
CDActivitiesTable::Instance().LoadValuesFromDatabase();
|
CDActivitiesTable::Instance().LoadValuesFromDatabase();
|
||||||
CDCLIENT_DONT_CACHE_TABLE(CDAnimationsTable::Instance().LoadValuesFromDatabase());
|
CDCLIENT_DONT_CACHE_TABLE(CDAnimationsTable::Instance().LoadValuesFromDatabase());
|
||||||
@ -79,6 +91,7 @@ CDClientManager::CDClientManager() {
|
|||||||
CDCLIENT_DONT_CACHE_TABLE(CDObjectsTable::Instance().LoadValuesFromDatabase());
|
CDCLIENT_DONT_CACHE_TABLE(CDObjectsTable::Instance().LoadValuesFromDatabase());
|
||||||
CDPhysicsComponentTable::Instance().LoadValuesFromDatabase();
|
CDPhysicsComponentTable::Instance().LoadValuesFromDatabase();
|
||||||
CDPackageComponentTable::Instance().LoadValuesFromDatabase();
|
CDPackageComponentTable::Instance().LoadValuesFromDatabase();
|
||||||
|
CDPetComponentTable::Instance().LoadValuesFromDatabase();
|
||||||
CDProximityMonitorComponentTable::Instance().LoadValuesFromDatabase();
|
CDProximityMonitorComponentTable::Instance().LoadValuesFromDatabase();
|
||||||
CDPropertyEntranceComponentTable::Instance().LoadValuesFromDatabase();
|
CDPropertyEntranceComponentTable::Instance().LoadValuesFromDatabase();
|
||||||
CDPropertyTemplateTable::Instance().LoadValuesFromDatabase();
|
CDPropertyTemplateTable::Instance().LoadValuesFromDatabase();
|
||||||
@ -92,3 +105,9 @@ CDClientManager::CDClientManager() {
|
|||||||
CDVendorComponentTable::Instance().LoadValuesFromDatabase();
|
CDVendorComponentTable::Instance().LoadValuesFromDatabase();
|
||||||
CDZoneTableTable::Instance().LoadValuesFromDatabase();
|
CDZoneTableTable::Instance().LoadValuesFromDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CDClientManager::LoadValuesFromDefaults() {
|
||||||
|
LOG("Loading default CDClient tables!");
|
||||||
|
|
||||||
|
CDPetComponentTable::Instance().LoadValuesFromDefaults();
|
||||||
|
}
|
||||||
|
@ -11,7 +11,10 @@
|
|||||||
*/
|
*/
|
||||||
class CDClientManager : public Singleton<CDClientManager> {
|
class CDClientManager : public Singleton<CDClientManager> {
|
||||||
public:
|
public:
|
||||||
CDClientManager();
|
CDClientManager() = default;
|
||||||
|
|
||||||
|
void LoadValuesFromDatabase();
|
||||||
|
void LoadValuesFromDefaults();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch a table from CDClient
|
* Fetch a table from CDClient
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
void CDActivitiesTable::LoadValuesFromDatabase() {
|
void CDActivitiesTable::LoadValuesFromDatabase() {
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
uint32_t size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM Activities");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM Activities");
|
||||||
while (!tableSize.eof()) {
|
while (!tableSize.eof()) {
|
||||||
size = tableSize.getIntField(0, 0);
|
size = tableSize.getIntField(0, 0);
|
||||||
|
@ -4,22 +4,22 @@
|
|||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
struct CDActivities {
|
struct CDActivities {
|
||||||
unsigned int ActivityID;
|
uint32_t ActivityID;
|
||||||
unsigned int locStatus;
|
uint32_t locStatus;
|
||||||
unsigned int instanceMapID;
|
uint32_t instanceMapID;
|
||||||
unsigned int minTeams;
|
uint32_t minTeams;
|
||||||
unsigned int maxTeams;
|
uint32_t maxTeams;
|
||||||
unsigned int minTeamSize;
|
uint32_t minTeamSize;
|
||||||
unsigned int maxTeamSize;
|
uint32_t maxTeamSize;
|
||||||
unsigned int waitTime;
|
uint32_t waitTime;
|
||||||
unsigned int startDelay;
|
uint32_t startDelay;
|
||||||
bool requiresUniqueData;
|
bool requiresUniqueData;
|
||||||
unsigned int leaderboardType;
|
uint32_t leaderboardType;
|
||||||
bool localize;
|
bool localize;
|
||||||
int optionalCostLOT;
|
int32_t optionalCostLOT;
|
||||||
int optionalCostCount;
|
int32_t optionalCostCount;
|
||||||
bool showUIRewards;
|
bool showUIRewards;
|
||||||
unsigned int CommunityActivityFlagID;
|
uint32_t CommunityActivityFlagID;
|
||||||
std::string gate_version;
|
std::string gate_version;
|
||||||
bool noTeamLootOnDeath;
|
bool noTeamLootOnDeath;
|
||||||
float optionalPercentage;
|
float optionalPercentage;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
void CDActivityRewardsTable::LoadValuesFromDatabase() {
|
void CDActivityRewardsTable::LoadValuesFromDatabase() {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
uint32_t size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ActivityRewards");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ActivityRewards");
|
||||||
while (!tableSize.eof()) {
|
while (!tableSize.eof()) {
|
||||||
size = tableSize.getIntField(0, 0);
|
size = tableSize.getIntField(0, 0);
|
||||||
|
@ -4,12 +4,12 @@
|
|||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
struct CDActivityRewards {
|
struct CDActivityRewards {
|
||||||
unsigned int objectTemplate; //!< The object template (?)
|
uint32_t objectTemplate; //!< The object template (?)
|
||||||
unsigned int ActivityRewardIndex; //!< The activity reward index
|
uint32_t ActivityRewardIndex; //!< The activity reward index
|
||||||
int activityRating; //!< The activity rating
|
int32_t activityRating; //!< The activity rating
|
||||||
unsigned int LootMatrixIndex; //!< The loot matrix index
|
uint32_t LootMatrixIndex; //!< The loot matrix index
|
||||||
unsigned int CurrencyIndex; //!< The currency index
|
uint32_t CurrencyIndex; //!< The currency index
|
||||||
unsigned int ChallengeRating; //!< The challenge rating
|
uint32_t ChallengeRating; //!< The challenge rating
|
||||||
std::string description; //!< The description
|
std::string description; //!< The description
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4,13 +4,13 @@
|
|||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
struct CDAnimation {
|
struct CDAnimation {
|
||||||
// unsigned int animationGroupID;
|
// uint32_t animationGroupID;
|
||||||
// std::string animation_type;
|
// std::string animation_type;
|
||||||
// The above two are a pair to represent a primary key in the map.
|
// The above two are a pair to represent a primary key in the map.
|
||||||
std::string animation_name; //!< The animation name
|
std::string animation_name; //!< The animation name
|
||||||
float chance_to_play; //!< The chance to play the animation
|
float chance_to_play; //!< The chance to play the animation
|
||||||
UNUSED_COLUMN(unsigned int min_loops;) //!< The minimum number of loops
|
UNUSED_COLUMN(uint32_t min_loops;) //!< The minimum number of loops
|
||||||
UNUSED_COLUMN(unsigned int max_loops;) //!< The maximum number of loops
|
UNUSED_COLUMN(uint32_t max_loops;) //!< The maximum number of loops
|
||||||
float animation_length; //!< The animation length
|
float animation_length; //!< The animation length
|
||||||
UNUSED_COLUMN(bool hideEquip;) //!< Whether or not to hide the equip
|
UNUSED_COLUMN(bool hideEquip;) //!< Whether or not to hide the equip
|
||||||
UNUSED_COLUMN(bool ignoreUpperBody;) //!< Whether or not to ignore the upper body
|
UNUSED_COLUMN(bool ignoreUpperBody;) //!< Whether or not to ignore the upper body
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
void CDBehaviorTemplateTable::LoadValuesFromDatabase() {
|
void CDBehaviorTemplateTable::LoadValuesFromDatabase() {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
uint32_t size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM BehaviorTemplate");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM BehaviorTemplate");
|
||||||
while (!tableSize.eof()) {
|
while (!tableSize.eof()) {
|
||||||
size = tableSize.getIntField(0, 0);
|
size = tableSize.getIntField(0, 0);
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
struct CDBehaviorTemplate {
|
struct CDBehaviorTemplate {
|
||||||
unsigned int behaviorID; //!< The Behavior ID
|
uint32_t behaviorID; //!< The Behavior ID
|
||||||
unsigned int templateID; //!< The Template ID (LOT)
|
uint32_t templateID; //!< The Template ID (LOT)
|
||||||
unsigned int effectID; //!< The Effect ID attached
|
uint32_t effectID; //!< The Effect ID attached
|
||||||
std::unordered_set<std::string>::iterator effectHandle; //!< The effect handle
|
std::unordered_set<std::string>::iterator effectHandle; //!< The effect handle
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
void CDBrickIDTableTable::LoadValuesFromDatabase() {
|
void CDBrickIDTableTable::LoadValuesFromDatabase() {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
uint32_t size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM BrickIDTable");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM BrickIDTable");
|
||||||
while (!tableSize.eof()) {
|
while (!tableSize.eof()) {
|
||||||
size = tableSize.getIntField(0, 0);
|
size = tableSize.getIntField(0, 0);
|
||||||
|
@ -10,8 +10,8 @@
|
|||||||
|
|
||||||
//! BrickIDTable Entry Struct
|
//! BrickIDTable Entry Struct
|
||||||
struct CDBrickIDTable {
|
struct CDBrickIDTable {
|
||||||
unsigned int NDObjectID;
|
uint32_t NDObjectID;
|
||||||
unsigned int LEGOBrickID;
|
uint32_t LEGOBrickID;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
|
|
||||||
enum class eReplicaComponentType : uint32_t;
|
enum class eReplicaComponentType : uint32_t;
|
||||||
struct CDComponentsRegistry {
|
struct CDComponentsRegistry {
|
||||||
unsigned int id; //!< The LOT is used as the ID
|
uint32_t id; //!< The LOT is used as the ID
|
||||||
eReplicaComponentType component_type; //!< See ComponentTypes enum for values
|
eReplicaComponentType component_type; //!< See ComponentTypes enum for values
|
||||||
unsigned int component_id; //!< The ID used within the component's table (0 may either mean it's non-networked, or that the ID is actually 0
|
uint32_t component_id; //!< The ID used within the component's table (0 may either mean it's non-networked, or that the ID is actually 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
void CDCurrencyTableTable::LoadValuesFromDatabase() {
|
void CDCurrencyTableTable::LoadValuesFromDatabase() {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
uint32_t size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM CurrencyTable");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM CurrencyTable");
|
||||||
while (!tableSize.eof()) {
|
while (!tableSize.eof()) {
|
||||||
size = tableSize.getIntField(0, 0);
|
size = tableSize.getIntField(0, 0);
|
||||||
|
@ -10,11 +10,11 @@
|
|||||||
|
|
||||||
//! CurrencyTable Struct
|
//! CurrencyTable Struct
|
||||||
struct CDCurrencyTable {
|
struct CDCurrencyTable {
|
||||||
unsigned int currencyIndex; //!< The Currency Index
|
uint32_t currencyIndex; //!< The Currency Index
|
||||||
unsigned int npcminlevel; //!< The minimum level of the npc
|
uint32_t npcminlevel; //!< The minimum level of the npc
|
||||||
unsigned int minvalue; //!< The minimum currency
|
uint32_t minvalue; //!< The minimum currency
|
||||||
unsigned int maxvalue; //!< The maximum currency
|
uint32_t maxvalue; //!< The maximum currency
|
||||||
unsigned int id; //!< The ID of the currency index
|
uint32_t id; //!< The ID of the currency index
|
||||||
};
|
};
|
||||||
|
|
||||||
//! CurrencyTable table
|
//! CurrencyTable table
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
void CDDestructibleComponentTable::LoadValuesFromDatabase() {
|
void CDDestructibleComponentTable::LoadValuesFromDatabase() {
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
uint32_t size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM DestructibleComponent");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM DestructibleComponent");
|
||||||
while (!tableSize.eof()) {
|
while (!tableSize.eof()) {
|
||||||
size = tableSize.getIntField(0, 0);
|
size = tableSize.getIntField(0, 0);
|
||||||
|
@ -4,20 +4,20 @@
|
|||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
struct CDDestructibleComponent {
|
struct CDDestructibleComponent {
|
||||||
unsigned int id; //!< The component ID from the ComponentsRegistry Table
|
uint32_t id; //!< The component ID from the ComponentsRegistry Table
|
||||||
int faction; //!< The Faction ID of the object
|
int32_t faction; //!< The Faction ID of the object
|
||||||
std::string factionList; //!< A list of the faction IDs
|
std::string factionList; //!< A list of the faction IDs
|
||||||
int life; //!< The amount of life of the object
|
int32_t life; //!< The amount of life of the object
|
||||||
unsigned int imagination; //!< The amount of imagination of the object
|
uint32_t imagination; //!< The amount of imagination of the object
|
||||||
int LootMatrixIndex; //!< The Loot Matrix Index
|
int32_t LootMatrixIndex; //!< The Loot Matrix Index
|
||||||
int CurrencyIndex; //!< The Currency Index
|
int32_t CurrencyIndex; //!< The Currency Index
|
||||||
unsigned int level; //!< ???
|
uint32_t level; //!< ???
|
||||||
float armor; //!< The amount of armor of the object
|
float armor; //!< The amount of armor of the object
|
||||||
unsigned int death_behavior; //!< The behavior ID of the death behavior
|
uint32_t death_behavior; //!< The behavior ID of the death behavior
|
||||||
bool isnpc; //!< Whether or not the object is an NPC
|
bool isnpc; //!< Whether or not the object is an NPC
|
||||||
unsigned int attack_priority; //!< ???
|
uint32_t attack_priority; //!< ???
|
||||||
bool isSmashable; //!< Whether or not the object is smashable
|
bool isSmashable; //!< Whether or not the object is smashable
|
||||||
int difficultyLevel; //!< ???
|
int32_t difficultyLevel; //!< ???
|
||||||
};
|
};
|
||||||
|
|
||||||
class CDDestructibleComponentTable : public CDTable<CDDestructibleComponentTable> {
|
class CDDestructibleComponentTable : public CDTable<CDDestructibleComponentTable> {
|
||||||
|
@ -20,7 +20,7 @@ void CDEmoteTableTable::LoadValuesFromDatabase() {
|
|||||||
tableData.finalize();
|
tableData.finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
CDEmoteTable* CDEmoteTableTable::GetEmote(int id) {
|
CDEmoteTable* CDEmoteTableTable::GetEmote(int32_t id) {
|
||||||
auto itr = entries.find(id);
|
auto itr = entries.find(id);
|
||||||
return itr != entries.end() ? &itr->second : nullptr;
|
return itr != entries.end() ? &itr->second : nullptr;
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,11 @@ struct CDEmoteTable {
|
|||||||
gateVersion = "";
|
gateVersion = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
int ID;
|
int32_t ID;
|
||||||
std::string animationName;
|
std::string animationName;
|
||||||
std::string iconFilename;
|
std::string iconFilename;
|
||||||
int locState;
|
int32_t locState;
|
||||||
int channel;
|
int32_t channel;
|
||||||
bool locked;
|
bool locked;
|
||||||
bool localize;
|
bool localize;
|
||||||
std::string gateVersion;
|
std::string gateVersion;
|
||||||
@ -33,5 +33,5 @@ private:
|
|||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
void LoadValuesFromDatabase();
|
||||||
// Returns an emote by ID
|
// Returns an emote by ID
|
||||||
CDEmoteTable* GetEmote(int id);
|
CDEmoteTable* GetEmote(int32_t id);
|
||||||
};
|
};
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
void CDFeatureGatingTable::LoadValuesFromDatabase() {
|
void CDFeatureGatingTable::LoadValuesFromDatabase() {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
uint32_t size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM FeatureGating");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM FeatureGating");
|
||||||
while (!tableSize.eof()) {
|
while (!tableSize.eof()) {
|
||||||
size = tableSize.getIntField(0, 0);
|
size = tableSize.getIntField(0, 0);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
void CDInventoryComponentTable::LoadValuesFromDatabase() {
|
void CDInventoryComponentTable::LoadValuesFromDatabase() {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
uint32_t size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM InventoryComponent");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM InventoryComponent");
|
||||||
while (!tableSize.eof()) {
|
while (!tableSize.eof()) {
|
||||||
size = tableSize.getIntField(0, 0);
|
size = tableSize.getIntField(0, 0);
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
struct CDInventoryComponent {
|
struct CDInventoryComponent {
|
||||||
unsigned int id; //!< The component ID for this object
|
uint32_t id; //!< The component ID for this object
|
||||||
unsigned int itemid; //!< The LOT of the object
|
uint32_t itemid; //!< The LOT of the object
|
||||||
unsigned int count; //!< The count of the items the object has
|
uint32_t count; //!< The count of the items the object has
|
||||||
bool equip; //!< Whether or not to equip the item
|
bool equip; //!< Whether or not to equip the item
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ CDItemComponent CDItemComponentTable::Default = {};
|
|||||||
|
|
||||||
void CDItemComponentTable::LoadValuesFromDatabase() {
|
void CDItemComponentTable::LoadValuesFromDatabase() {
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
uint32_t size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ItemComponent");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ItemComponent");
|
||||||
while (!tableSize.eof()) {
|
while (!tableSize.eof()) {
|
||||||
size = tableSize.getIntField(0, 0);
|
size = tableSize.getIntField(0, 0);
|
||||||
@ -69,7 +69,7 @@ void CDItemComponentTable::LoadValuesFromDatabase() {
|
|||||||
tableData.finalize();
|
tableData.finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
const CDItemComponent& CDItemComponentTable::GetItemComponentByID(unsigned int skillID) {
|
const CDItemComponent& CDItemComponentTable::GetItemComponentByID(uint32_t skillID) {
|
||||||
const auto& it = this->entries.find(skillID);
|
const auto& it = this->entries.find(skillID);
|
||||||
if (it != this->entries.end()) {
|
if (it != this->entries.end()) {
|
||||||
return it->second;
|
return it->second;
|
||||||
|
@ -5,60 +5,60 @@
|
|||||||
#include "dCommonVars.h"
|
#include "dCommonVars.h"
|
||||||
|
|
||||||
struct CDItemComponent {
|
struct CDItemComponent {
|
||||||
unsigned int id; //!< The Component ID
|
uint32_t id; //!< The Component ID
|
||||||
std::string equipLocation; //!< The equip location
|
std::string equipLocation; //!< The equip location
|
||||||
unsigned int baseValue; //!< The monetary base value of the item
|
uint32_t baseValue; //!< The monetary base value of the item
|
||||||
bool isKitPiece; //!< Whether or not the item belongs to a kit
|
bool isKitPiece; //!< Whether or not the item belongs to a kit
|
||||||
unsigned int rarity; //!< The rarity of the item
|
uint32_t rarity; //!< The rarity of the item
|
||||||
unsigned int itemType; //!< The item type
|
uint32_t itemType; //!< The item type
|
||||||
int64_t itemInfo; //!< The item info
|
int64_t itemInfo; //!< The item info
|
||||||
bool inLootTable; //!< Whether or not the item is in a loot table
|
bool inLootTable; //!< Whether or not the item is in a loot table
|
||||||
bool inVendor; //!< Whether or not the item is in a vendor inventory
|
bool inVendor; //!< Whether or not the item is in a vendor inventory
|
||||||
bool isUnique; //!< ???
|
bool isUnique; //!< ???
|
||||||
bool isBOP; //!< ???
|
bool isBOP; //!< ???
|
||||||
bool isBOE; //!< ???
|
bool isBOE; //!< ???
|
||||||
unsigned int reqFlagID; //!< User must have completed this flag to get the item
|
uint32_t reqFlagID; //!< User must have completed this flag to get the item
|
||||||
unsigned int reqSpecialtyID; //!< ???
|
uint32_t reqSpecialtyID; //!< ???
|
||||||
unsigned int reqSpecRank; //!< ???
|
uint32_t reqSpecRank; //!< ???
|
||||||
unsigned int reqAchievementID; //!< The required achievement must be completed
|
uint32_t reqAchievementID; //!< The required achievement must be completed
|
||||||
unsigned int stackSize; //!< The stack size of the item
|
uint32_t stackSize; //!< The stack size of the item
|
||||||
unsigned int color1; //!< Something to do with item color...
|
uint32_t color1; //!< Something to do with item color...
|
||||||
unsigned int decal; //!< The decal of the item
|
uint32_t decal; //!< The decal of the item
|
||||||
unsigned int offsetGroupID; //!< Something to do with group IDs
|
uint32_t offsetGroupID; //!< Something to do with group IDs
|
||||||
unsigned int buildTypes; //!< Something to do with building
|
uint32_t buildTypes; //!< Something to do with building
|
||||||
std::string reqPrecondition; //!< The required precondition
|
std::string reqPrecondition; //!< The required precondition
|
||||||
unsigned int animationFlag; //!< The Animation Flag
|
uint32_t animationFlag; //!< The Animation Flag
|
||||||
unsigned int equipEffects; //!< The effect played when the item is equipped
|
uint32_t equipEffects; //!< The effect played when the item is equipped
|
||||||
bool readyForQA; //!< ???
|
bool readyForQA; //!< ???
|
||||||
unsigned int itemRating; //!< ???
|
uint32_t itemRating; //!< ???
|
||||||
bool isTwoHanded; //!< Whether or not the item is double handed
|
bool isTwoHanded; //!< Whether or not the item is double handed
|
||||||
unsigned int minNumRequired; //!< Maybe the minimum number required for a mission, or to own this object?
|
uint32_t minNumRequired; //!< Maybe the minimum number required for a mission, or to own this object?
|
||||||
unsigned int delResIndex; //!< ???
|
uint32_t delResIndex; //!< ???
|
||||||
unsigned int currencyLOT; //!< ???
|
uint32_t currencyLOT; //!< ???
|
||||||
unsigned int altCurrencyCost; //!< ???
|
uint32_t altCurrencyCost; //!< ???
|
||||||
std::string subItems; //!< A comma seperate string of sub items (maybe for multi-itemed things like faction test gear set)
|
std::string subItems; //!< A comma seperate string of sub items (maybe for multi-itemed things like faction test gear set)
|
||||||
UNUSED(std::string audioEventUse); //!< ???
|
UNUSED(std::string audioEventUse); //!< ???
|
||||||
bool noEquipAnimation; //!< Whether or not there is an equip animation
|
bool noEquipAnimation; //!< Whether or not there is an equip animation
|
||||||
unsigned int commendationLOT; //!< The commendation LOT
|
uint32_t commendationLOT; //!< The commendation LOT
|
||||||
unsigned int commendationCost; //!< The commendation cost
|
uint32_t commendationCost; //!< The commendation cost
|
||||||
UNUSED(std::string audioEquipMetaEventSet); //!< ???
|
UNUSED(std::string audioEquipMetaEventSet); //!< ???
|
||||||
std::string currencyCosts; //!< Used for crafting
|
std::string currencyCosts; //!< Used for crafting
|
||||||
UNUSED(std::string ingredientInfo); //!< Unused
|
UNUSED(std::string ingredientInfo); //!< Unused
|
||||||
unsigned int locStatus; //!< ???
|
uint32_t locStatus; //!< ???
|
||||||
unsigned int forgeType; //!< Forge Type
|
uint32_t forgeType; //!< Forge Type
|
||||||
float SellMultiplier; //!< Something to do with early vendors perhaps (but replaced)
|
float SellMultiplier; //!< Something to do with early vendors perhaps (but replaced)
|
||||||
};
|
};
|
||||||
|
|
||||||
class CDItemComponentTable : public CDTable<CDItemComponentTable> {
|
class CDItemComponentTable : public CDTable<CDItemComponentTable> {
|
||||||
private:
|
private:
|
||||||
std::map<unsigned int, CDItemComponent> entries;
|
std::map<uint32_t, CDItemComponent> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
void LoadValuesFromDatabase();
|
||||||
static std::map<LOT, uint32_t> ParseCraftingCurrencies(const CDItemComponent& itemComponent);
|
static std::map<LOT, uint32_t> ParseCraftingCurrencies(const CDItemComponent& itemComponent);
|
||||||
|
|
||||||
// Gets an entry by ID
|
// Gets an entry by ID
|
||||||
const CDItemComponent& GetItemComponentByID(unsigned int skillID);
|
const CDItemComponent& GetItemComponentByID(uint32_t skillID);
|
||||||
|
|
||||||
static CDItemComponent Default;
|
static CDItemComponent Default;
|
||||||
};
|
};
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
void CDItemSetSkillsTable::LoadValuesFromDatabase() {
|
void CDItemSetSkillsTable::LoadValuesFromDatabase() {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
uint32_t size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ItemSetSkills");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ItemSetSkills");
|
||||||
while (!tableSize.eof()) {
|
while (!tableSize.eof()) {
|
||||||
size = tableSize.getIntField(0, 0);
|
size = tableSize.getIntField(0, 0);
|
||||||
@ -44,7 +44,7 @@ const std::vector<CDItemSetSkills>& CDItemSetSkillsTable::GetEntries() const {
|
|||||||
return this->entries;
|
return this->entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<CDItemSetSkills> CDItemSetSkillsTable::GetBySkillID(unsigned int SkillSetID) {
|
std::vector<CDItemSetSkills> CDItemSetSkillsTable::GetBySkillID(uint32_t SkillSetID) {
|
||||||
std::vector<CDItemSetSkills> toReturn;
|
std::vector<CDItemSetSkills> toReturn;
|
||||||
|
|
||||||
for (CDItemSetSkills entry : this->entries) {
|
for (CDItemSetSkills entry : this->entries) {
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
struct CDItemSetSkills {
|
struct CDItemSetSkills {
|
||||||
unsigned int SkillSetID; //!< The skill set ID
|
uint32_t SkillSetID; //!< The skill set ID
|
||||||
unsigned int SkillID; //!< The skill ID
|
uint32_t SkillID; //!< The skill ID
|
||||||
unsigned int SkillCastType; //!< The skill cast type
|
uint32_t SkillCastType; //!< The skill cast type
|
||||||
};
|
};
|
||||||
|
|
||||||
class CDItemSetSkillsTable : public CDTable<CDItemSetSkillsTable> {
|
class CDItemSetSkillsTable : public CDTable<CDItemSetSkillsTable> {
|
||||||
@ -20,5 +20,5 @@ public:
|
|||||||
|
|
||||||
const std::vector<CDItemSetSkills>& GetEntries() const;
|
const std::vector<CDItemSetSkills>& GetEntries() const;
|
||||||
|
|
||||||
std::vector<CDItemSetSkills> GetBySkillID(unsigned int SkillSetID);
|
std::vector<CDItemSetSkills> GetBySkillID(uint32_t SkillSetID);
|
||||||
};
|
};
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
void CDItemSetsTable::LoadValuesFromDatabase() {
|
void CDItemSetsTable::LoadValuesFromDatabase() {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
uint32_t size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ItemSets");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ItemSets");
|
||||||
while (!tableSize.eof()) {
|
while (!tableSize.eof()) {
|
||||||
size = tableSize.getIntField(0, 0);
|
size = tableSize.getIntField(0, 0);
|
||||||
|
@ -4,20 +4,20 @@
|
|||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
struct CDItemSets {
|
struct CDItemSets {
|
||||||
unsigned int setID; //!< The item set ID
|
uint32_t setID; //!< The item set ID
|
||||||
unsigned int locStatus; //!< The loc status
|
uint32_t locStatus; //!< The loc status
|
||||||
std::string itemIDs; //!< THe item IDs
|
std::string itemIDs; //!< THe item IDs
|
||||||
unsigned int kitType; //!< The item kit type
|
uint32_t kitType; //!< The item kit type
|
||||||
unsigned int kitRank; //!< The item kit rank
|
uint32_t kitRank; //!< The item kit rank
|
||||||
unsigned int kitImage; //!< The item kit image
|
uint32_t kitImage; //!< The item kit image
|
||||||
unsigned int skillSetWith2; //!< The skill set with 2
|
uint32_t skillSetWith2; //!< The skill set with 2
|
||||||
unsigned int skillSetWith3; //!< The skill set with 3
|
uint32_t skillSetWith3; //!< The skill set with 3
|
||||||
unsigned int skillSetWith4; //!< The skill set with 4
|
uint32_t skillSetWith4; //!< The skill set with 4
|
||||||
unsigned int skillSetWith5; //!< The skill set with 5
|
uint32_t skillSetWith5; //!< The skill set with 5
|
||||||
unsigned int skillSetWith6; //!< The skill set with 6
|
uint32_t skillSetWith6; //!< The skill set with 6
|
||||||
bool localize; //!< Whether or localize
|
bool localize; //!< Whether or localize
|
||||||
std::string gate_version; //!< The gate version
|
std::string gate_version; //!< The gate version
|
||||||
unsigned int kitID; //!< The kit ID
|
uint32_t kitID; //!< The kit ID
|
||||||
float priority; //!< The priority
|
float priority; //!< The priority
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
void CDLevelProgressionLookupTable::LoadValuesFromDatabase() {
|
void CDLevelProgressionLookupTable::LoadValuesFromDatabase() {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
uint32_t size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM LevelProgressionLookup");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM LevelProgressionLookup");
|
||||||
while (!tableSize.eof()) {
|
while (!tableSize.eof()) {
|
||||||
size = tableSize.getIntField(0, 0);
|
size = tableSize.getIntField(0, 0);
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
struct CDLevelProgressionLookup {
|
struct CDLevelProgressionLookup {
|
||||||
unsigned int id; //!< The Level ID
|
uint32_t id; //!< The Level ID
|
||||||
unsigned int requiredUScore; //!< The required LEGO Score
|
uint32_t requiredUScore; //!< The required LEGO Score
|
||||||
std::string BehaviorEffect; //!< The behavior effect attached to this
|
std::string BehaviorEffect; //!< The behavior effect attached to this
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ CDLootMatrix CDLootMatrixTable::ReadRow(CppSQLite3Query& tableData) const {
|
|||||||
void CDLootMatrixTable::LoadValuesFromDatabase() {
|
void CDLootMatrixTable::LoadValuesFromDatabase() {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
uint32_t size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM LootMatrix");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM LootMatrix");
|
||||||
while (!tableSize.eof()) {
|
while (!tableSize.eof()) {
|
||||||
size = tableSize.getIntField(0, 0);
|
size = tableSize.getIntField(0, 0);
|
||||||
|
@ -4,12 +4,12 @@
|
|||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
struct CDLootMatrix {
|
struct CDLootMatrix {
|
||||||
unsigned int LootTableIndex; //!< The Loot Table Index
|
uint32_t LootTableIndex; //!< The Loot Table Index
|
||||||
unsigned int RarityTableIndex; //!< The Rarity Table Index
|
uint32_t RarityTableIndex; //!< The Rarity Table Index
|
||||||
float percent; //!< The percent that this matrix is used?
|
float percent; //!< The percent that this matrix is used?
|
||||||
unsigned int minToDrop; //!< The minimum amount of loot from this matrix to drop
|
uint32_t minToDrop; //!< The minimum amount of loot from this matrix to drop
|
||||||
unsigned int maxToDrop; //!< The maximum amount of loot from this matrix to drop
|
uint32_t maxToDrop; //!< The maximum amount of loot from this matrix to drop
|
||||||
unsigned int flagID; //!< ???
|
uint32_t flagID; //!< ???
|
||||||
UNUSED(std::string gate_version); //!< The Gate Version
|
UNUSED(std::string gate_version); //!< The Gate Version
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ CDLootTable CDLootTableTable::ReadRow(CppSQLite3Query& tableData) const {
|
|||||||
void CDLootTableTable::LoadValuesFromDatabase() {
|
void CDLootTableTable::LoadValuesFromDatabase() {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
uint32_t size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM LootTable");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM LootTable");
|
||||||
while (!tableSize.eof()) {
|
while (!tableSize.eof()) {
|
||||||
size = tableSize.getIntField(0, 0);
|
size = tableSize.getIntField(0, 0);
|
||||||
|
@ -4,10 +4,10 @@
|
|||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
struct CDLootTable {
|
struct CDLootTable {
|
||||||
unsigned int itemid; //!< The LOT of the item
|
uint32_t itemid; //!< The LOT of the item
|
||||||
unsigned int LootTableIndex; //!< The Loot Table Index
|
uint32_t LootTableIndex; //!< The Loot Table Index
|
||||||
bool MissionDrop; //!< Whether or not this loot table is a mission drop
|
bool MissionDrop; //!< Whether or not this loot table is a mission drop
|
||||||
unsigned int sortPriority; //!< The sorting priority
|
uint32_t sortPriority; //!< The sorting priority
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef uint32_t LootTableIndex;
|
typedef uint32_t LootTableIndex;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
void CDMissionEmailTable::LoadValuesFromDatabase() {
|
void CDMissionEmailTable::LoadValuesFromDatabase() {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
uint32_t size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM MissionEmail");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM MissionEmail");
|
||||||
while (!tableSize.eof()) {
|
while (!tableSize.eof()) {
|
||||||
size = tableSize.getIntField(0, 0);
|
size = tableSize.getIntField(0, 0);
|
||||||
|
@ -4,13 +4,13 @@
|
|||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
struct CDMissionEmail {
|
struct CDMissionEmail {
|
||||||
unsigned int ID;
|
uint32_t ID;
|
||||||
unsigned int messageType;
|
uint32_t messageType;
|
||||||
unsigned int notificationGroup;
|
uint32_t notificationGroup;
|
||||||
unsigned int missionID;
|
uint32_t missionID;
|
||||||
unsigned int attachmentLOT;
|
uint32_t attachmentLOT;
|
||||||
bool localize;
|
bool localize;
|
||||||
unsigned int locStatus;
|
uint32_t locStatus;
|
||||||
std::string gate_version;
|
std::string gate_version;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
void CDMissionNPCComponentTable::LoadValuesFromDatabase() {
|
void CDMissionNPCComponentTable::LoadValuesFromDatabase() {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
uint32_t size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM MissionNPCComponent");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM MissionNPCComponent");
|
||||||
while (!tableSize.eof()) {
|
while (!tableSize.eof()) {
|
||||||
size = tableSize.getIntField(0, 0);
|
size = tableSize.getIntField(0, 0);
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
struct CDMissionNPCComponent {
|
struct CDMissionNPCComponent {
|
||||||
unsigned int id; //!< The ID
|
uint32_t id; //!< The ID
|
||||||
unsigned int missionID; //!< The Mission ID
|
uint32_t missionID; //!< The Mission ID
|
||||||
bool offersMission; //!< Whether or not this NPC offers a mission
|
bool offersMission; //!< Whether or not this NPC offers a mission
|
||||||
bool acceptsMission; //!< Whether or not this NPC accepts a mission
|
bool acceptsMission; //!< Whether or not this NPC accepts a mission
|
||||||
std::string gate_version; //!< The gate version
|
std::string gate_version; //!< The gate version
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
void CDMissionTasksTable::LoadValuesFromDatabase() {
|
void CDMissionTasksTable::LoadValuesFromDatabase() {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
uint32_t size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM MissionTasks");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM MissionTasks");
|
||||||
while (!tableSize.eof()) {
|
while (!tableSize.eof()) {
|
||||||
size = tableSize.getIntField(0, 0);
|
size = tableSize.getIntField(0, 0);
|
||||||
|
@ -4,17 +4,17 @@
|
|||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
struct CDMissionTasks {
|
struct CDMissionTasks {
|
||||||
unsigned int id; //!< The Mission ID that the task belongs to
|
uint32_t id; //!< The Mission ID that the task belongs to
|
||||||
UNUSED(unsigned int locStatus); //!< ???
|
UNUSED(uint32_t locStatus); //!< ???
|
||||||
unsigned int taskType; //!< The task type
|
uint32_t taskType; //!< The task type
|
||||||
unsigned int target; //!< The mission target
|
uint32_t target; //!< The mission target
|
||||||
std::string targetGroup; //!< The mission target group
|
std::string targetGroup; //!< The mission target group
|
||||||
int targetValue; //!< The target value
|
int32_t targetValue; //!< The target value
|
||||||
std::string taskParam1; //!< The task param 1
|
std::string taskParam1; //!< The task param 1
|
||||||
UNUSED(std::string largeTaskIcon); //!< ???
|
UNUSED(std::string largeTaskIcon); //!< ???
|
||||||
UNUSED(unsigned int IconID); //!< ???
|
UNUSED(uint32_t IconID); //!< ???
|
||||||
unsigned int uid; //!< ???
|
uint32_t uid; //!< ???
|
||||||
UNUSED(unsigned int largeTaskIconID); //!< ???
|
UNUSED(uint32_t largeTaskIconID); //!< ???
|
||||||
UNUSED(bool localize); //!< Whether or not the task should be localized
|
UNUSED(bool localize); //!< Whether or not the task should be localized
|
||||||
UNUSED(std::string gate_version); //!< ???
|
UNUSED(std::string gate_version); //!< ???
|
||||||
};
|
};
|
||||||
|
@ -5,7 +5,7 @@ CDMissions CDMissionsTable::Default = {};
|
|||||||
void CDMissionsTable::LoadValuesFromDatabase() {
|
void CDMissionsTable::LoadValuesFromDatabase() {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
uint32_t size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM Missions");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM Missions");
|
||||||
while (!tableSize.eof()) {
|
while (!tableSize.eof()) {
|
||||||
size = tableSize.getIntField(0, 0);
|
size = tableSize.getIntField(0, 0);
|
||||||
|
@ -6,58 +6,58 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
struct CDMissions {
|
struct CDMissions {
|
||||||
int id; //!< The Mission ID
|
int32_t id; //!< The Mission ID
|
||||||
std::string defined_type; //!< The type of mission
|
std::string defined_type; //!< The type of mission
|
||||||
std::string defined_subtype; //!< The subtype of the mission
|
std::string defined_subtype; //!< The subtype of the mission
|
||||||
int UISortOrder; //!< The UI Sort Order for the mission
|
int32_t UISortOrder; //!< The UI Sort Order for the mission
|
||||||
int offer_objectID; //!< The LOT of the mission giver
|
int32_t offer_objectID; //!< The LOT of the mission giver
|
||||||
int target_objectID; //!< The LOT of the mission's target
|
int32_t target_objectID; //!< The LOT of the mission's target
|
||||||
int64_t reward_currency; //!< The amount of currency to reward the player
|
int64_t reward_currency; //!< The amount of currency to reward the player
|
||||||
int LegoScore; //!< The amount of LEGO Score to reward the player
|
int32_t LegoScore; //!< The amount of LEGO Score to reward the player
|
||||||
int64_t reward_reputation; //!< The reputation to award the player
|
int64_t reward_reputation; //!< The reputation to award the player
|
||||||
bool isChoiceReward; //!< Whether or not the user has the option to choose their loot
|
bool isChoiceReward; //!< Whether or not the user has the option to choose their loot
|
||||||
int reward_item1; //!< The first rewarded item
|
int32_t reward_item1; //!< The first rewarded item
|
||||||
int reward_item1_count; //!< The count of the first item to be rewarded
|
int32_t reward_item1_count; //!< The count of the first item to be rewarded
|
||||||
int reward_item2; //!< The second rewarded item
|
int32_t reward_item2; //!< The second rewarded item
|
||||||
int reward_item2_count; //!< The count of the second item to be rewarded
|
int32_t reward_item2_count; //!< The count of the second item to be rewarded
|
||||||
int reward_item3; //!< The third rewarded item
|
int32_t reward_item3; //!< The third rewarded item
|
||||||
int reward_item3_count; //!< The count of the third item to be rewarded
|
int32_t reward_item3_count; //!< The count of the third item to be rewarded
|
||||||
int reward_item4; //!< The fourth rewarded item
|
int32_t reward_item4; //!< The fourth rewarded item
|
||||||
int reward_item4_count; //!< The count of the fourth item to be rewarded
|
int32_t reward_item4_count; //!< The count of the fourth item to be rewarded
|
||||||
int reward_emote; //!< The first emote to be rewarded
|
int32_t reward_emote; //!< The first emote to be rewarded
|
||||||
int reward_emote2; //!< The second emote to be rewarded
|
int32_t reward_emote2; //!< The second emote to be rewarded
|
||||||
int reward_emote3; //!< The third emote to be rewarded
|
int32_t reward_emote3; //!< The third emote to be rewarded
|
||||||
int reward_emote4; //!< The fourth emote to be rewarded
|
int32_t reward_emote4; //!< The fourth emote to be rewarded
|
||||||
int reward_maximagination; //!< The amount of max imagination to reward
|
int32_t reward_maximagination; //!< The amount of max imagination to reward
|
||||||
int reward_maxhealth; //!< The amount of max health to reward
|
int32_t reward_maxhealth; //!< The amount of max health to reward
|
||||||
int reward_maxinventory; //!< The amount of max inventory to reward
|
int32_t reward_maxinventory; //!< The amount of max inventory to reward
|
||||||
int reward_maxmodel; //!< ???
|
int32_t reward_maxmodel; //!< ???
|
||||||
int reward_maxwidget; //!< ???
|
int32_t reward_maxwidget; //!< ???
|
||||||
int reward_maxwallet; //!< ???
|
int32_t reward_maxwallet; //!< ???
|
||||||
bool repeatable; //!< Whether or not this mission can be repeated (for instance, is it a daily mission)
|
bool repeatable; //!< Whether or not this mission can be repeated (for instance, is it a daily mission)
|
||||||
int64_t reward_currency_repeatable; //!< The repeatable reward
|
int64_t reward_currency_repeatable; //!< The repeatable reward
|
||||||
int reward_item1_repeatable; //!< The first rewarded item
|
int32_t reward_item1_repeatable; //!< The first rewarded item
|
||||||
int reward_item1_repeat_count; //!< The count of the first item to be rewarded
|
int32_t reward_item1_repeat_count; //!< The count of the first item to be rewarded
|
||||||
int reward_item2_repeatable; //!< The second rewarded item
|
int32_t reward_item2_repeatable; //!< The second rewarded item
|
||||||
int reward_item2_repeat_count; //!< The count of the second item to be rewarded
|
int32_t reward_item2_repeat_count; //!< The count of the second item to be rewarded
|
||||||
int reward_item3_repeatable; //!< The third rewarded item
|
int32_t reward_item3_repeatable; //!< The third rewarded item
|
||||||
int reward_item3_repeat_count; //!< The count of the third item to be rewarded
|
int32_t reward_item3_repeat_count; //!< The count of the third item to be rewarded
|
||||||
int reward_item4_repeatable; //!< The fourth rewarded item
|
int32_t reward_item4_repeatable; //!< The fourth rewarded item
|
||||||
int reward_item4_repeat_count; //!< The count of the fourth item to be rewarded
|
int32_t reward_item4_repeat_count; //!< The count of the fourth item to be rewarded
|
||||||
int time_limit; //!< The time limit of the mission
|
int32_t time_limit; //!< The time limit of the mission
|
||||||
bool isMission; //!< Maybe to differentiate between missions and achievements?
|
bool isMission; //!< Maybe to differentiate between missions and achievements?
|
||||||
int missionIconID; //!< The mission icon ID
|
int32_t missionIconID; //!< The mission icon ID
|
||||||
std::string prereqMissionID; //!< A '|' seperated list of prerequisite missions
|
std::string prereqMissionID; //!< A '|' seperated list of prerequisite missions
|
||||||
bool localize; //!< Whether or not to localize the mission
|
bool localize; //!< Whether or not to localize the mission
|
||||||
bool inMOTD; //!< In Match of the Day(?)
|
bool inMOTD; //!< In Match of the Day(?)
|
||||||
int64_t cooldownTime; //!< The mission cooldown time
|
int64_t cooldownTime; //!< The mission cooldown time
|
||||||
bool isRandom; //!< ???
|
bool isRandom; //!< ???
|
||||||
std::string randomPool; //!< ???
|
std::string randomPool; //!< ???
|
||||||
int UIPrereqID; //!< ???
|
int32_t UIPrereqID; //!< ???
|
||||||
UNUSED(std::string gate_version); //!< The gate version
|
UNUSED(std::string gate_version); //!< The gate version
|
||||||
UNUSED(std::string HUDStates); //!< ???
|
UNUSED(std::string HUDStates); //!< ???
|
||||||
UNUSED(int locStatus); //!< ???
|
UNUSED(int32_t locStatus); //!< ???
|
||||||
int reward_bankinventory; //!< The amount of bank space this mission rewards
|
int32_t reward_bankinventory; //!< The amount of bank space this mission rewards
|
||||||
};
|
};
|
||||||
|
|
||||||
class CDMissionsTable : public CDTable<CDMissionsTable> {
|
class CDMissionsTable : public CDTable<CDMissionsTable> {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
void CDMovementAIComponentTable::LoadValuesFromDatabase() {
|
void CDMovementAIComponentTable::LoadValuesFromDatabase() {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
uint32_t size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM MovementAIComponent");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM MovementAIComponent");
|
||||||
while (!tableSize.eof()) {
|
while (!tableSize.eof()) {
|
||||||
size = tableSize.getIntField(0, 0);
|
size = tableSize.getIntField(0, 0);
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
struct CDMovementAIComponent {
|
struct CDMovementAIComponent {
|
||||||
unsigned int id;
|
uint32_t id;
|
||||||
std::string MovementType;
|
std::string MovementType;
|
||||||
float WanderChance;
|
float WanderChance;
|
||||||
float WanderDelayMin;
|
float WanderDelayMin;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
void CDObjectSkillsTable::LoadValuesFromDatabase() {
|
void CDObjectSkillsTable::LoadValuesFromDatabase() {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
uint32_t size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ObjectSkills");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ObjectSkills");
|
||||||
while (!tableSize.eof()) {
|
while (!tableSize.eof()) {
|
||||||
size = tableSize.getIntField(0, 0);
|
size = tableSize.getIntField(0, 0);
|
||||||
|
@ -4,10 +4,10 @@
|
|||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
struct CDObjectSkills {
|
struct CDObjectSkills {
|
||||||
unsigned int objectTemplate; //!< The LOT of the item
|
uint32_t objectTemplate; //!< The LOT of the item
|
||||||
unsigned int skillID; //!< The Skill ID of the object
|
uint32_t skillID; //!< The Skill ID of the object
|
||||||
unsigned int castOnType; //!< ???
|
uint32_t castOnType; //!< ???
|
||||||
unsigned int AICombatWeight; //!< ???
|
uint32_t AICombatWeight; //!< ???
|
||||||
};
|
};
|
||||||
|
|
||||||
class CDObjectSkillsTable : public CDTable<CDObjectSkillsTable> {
|
class CDObjectSkillsTable : public CDTable<CDObjectSkillsTable> {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
void CDObjectsTable::LoadValuesFromDatabase() {
|
void CDObjectsTable::LoadValuesFromDatabase() {
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
uint32_t size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM Objects");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM Objects");
|
||||||
while (!tableSize.eof()) {
|
while (!tableSize.eof()) {
|
||||||
size = tableSize.getIntField(0, 0);
|
size = tableSize.getIntField(0, 0);
|
||||||
@ -40,7 +40,7 @@ void CDObjectsTable::LoadValuesFromDatabase() {
|
|||||||
m_default.id = 0;
|
m_default.id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CDObjects& CDObjectsTable::GetByID(unsigned int LOT) {
|
const CDObjects& CDObjectsTable::GetByID(uint32_t LOT) {
|
||||||
const auto& it = this->entries.find(LOT);
|
const auto& it = this->entries.find(LOT);
|
||||||
if (it != this->entries.end()) {
|
if (it != this->entries.end()) {
|
||||||
return it->second;
|
return it->second;
|
||||||
|
@ -4,30 +4,30 @@
|
|||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
struct CDObjects {
|
struct CDObjects {
|
||||||
unsigned int id; //!< The LOT of the object
|
uint32_t id; //!< The LOT of the object
|
||||||
std::string name; //!< The internal name of the object
|
std::string name; //!< The internal name of the object
|
||||||
UNUSED(unsigned int placeable); //!< Whether or not the object is placable
|
UNUSED(uint32_t placeable); //!< Whether or not the object is placable
|
||||||
std::string type; //!< The object type
|
std::string type; //!< The object type
|
||||||
UNUSED(std::string description); //!< An internal description of the object
|
UNUSED(std::string description); //!< An internal description of the object
|
||||||
UNUSED(unsigned int localize); //!< Whether or not the object should localize
|
UNUSED(uint32_t localize); //!< Whether or not the object should localize
|
||||||
UNUSED(unsigned int npcTemplateID); //!< Something related to NPCs...
|
UNUSED(uint32_t npcTemplateID); //!< Something related to NPCs...
|
||||||
UNUSED(std::string displayName); //!< The display name of the object
|
UNUSED(std::string displayName); //!< The display name of the object
|
||||||
float interactionDistance; //!< The interaction distance of the object
|
float interactionDistance; //!< The interaction distance of the object
|
||||||
UNUSED(unsigned int nametag); //!< ???
|
UNUSED(uint32_t nametag); //!< ???
|
||||||
UNUSED(std::string _internalNotes); //!< Some internal notes (rarely used)
|
UNUSED(std::string _internalNotes); //!< Some internal notes (rarely used)
|
||||||
UNUSED(unsigned int locStatus); //!< ???
|
UNUSED(uint32_t locStatus); //!< ???
|
||||||
UNUSED(std::string gate_version); //!< The gate version for the object
|
UNUSED(std::string gate_version); //!< The gate version for the object
|
||||||
UNUSED(unsigned int HQ_valid); //!< Probably used for the Nexus HQ database on LEGOUniverse.com
|
UNUSED(uint32_t HQ_valid); //!< Probably used for the Nexus HQ database on LEGOUniverse.com
|
||||||
};
|
};
|
||||||
|
|
||||||
class CDObjectsTable : public CDTable<CDObjectsTable> {
|
class CDObjectsTable : public CDTable<CDObjectsTable> {
|
||||||
private:
|
private:
|
||||||
std::map<unsigned int, CDObjects> entries;
|
std::map<uint32_t, CDObjects> entries;
|
||||||
CDObjects m_default;
|
CDObjects m_default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
void LoadValuesFromDatabase();
|
||||||
// Gets an entry by ID
|
// Gets an entry by ID
|
||||||
const CDObjects& GetByID(unsigned int LOT);
|
const CDObjects& GetByID(uint32_t LOT);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
void CDPackageComponentTable::LoadValuesFromDatabase() {
|
void CDPackageComponentTable::LoadValuesFromDatabase() {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
uint32_t size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM PackageComponent");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM PackageComponent");
|
||||||
while (!tableSize.eof()) {
|
while (!tableSize.eof()) {
|
||||||
size = tableSize.getIntField(0, 0);
|
size = tableSize.getIntField(0, 0);
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
struct CDPackageComponent {
|
struct CDPackageComponent {
|
||||||
unsigned int id;
|
uint32_t id;
|
||||||
unsigned int LootMatrixIndex;
|
uint32_t LootMatrixIndex;
|
||||||
unsigned int packageType;
|
uint32_t packageType;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CDPackageComponentTable : public CDTable<CDPackageComponentTable> {
|
class CDPackageComponentTable : public CDTable<CDPackageComponentTable> {
|
||||||
|
@ -0,0 +1,61 @@
|
|||||||
|
#include "CDPetComponentTable.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
// Default entries for fallback
|
||||||
|
CDPetComponent defaultEntry{
|
||||||
|
.id = 0,
|
||||||
|
UNUSED_ENTRY(.minTameUpdateTime = 60.0f,)
|
||||||
|
UNUSED_ENTRY(.maxTameUpdateTime = 300.0f,)
|
||||||
|
UNUSED_ENTRY(.percentTameChance = 101.0f,)
|
||||||
|
UNUSED_ENTRY(.tameability = 100.0f,)
|
||||||
|
UNUSED_ENTRY(.elementType = 1,)
|
||||||
|
.walkSpeed = 2.5f,
|
||||||
|
.runSpeed = 5.0f,
|
||||||
|
.sprintSpeed = 10.0f,
|
||||||
|
UNUSED_ENTRY(.idleTimeMin = 60.0f,)
|
||||||
|
UNUSED_ENTRY(.idleTimeMax = 300.0f,)
|
||||||
|
UNUSED_ENTRY(.petForm = 0,)
|
||||||
|
.imaginationDrainRate = 60.0f,
|
||||||
|
UNUSED_ENTRY(.AudioMetaEventSet = "",)
|
||||||
|
UNUSED_ENTRY(.buffIDs = "",)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDPetComponentTable::LoadValuesFromDatabase() {
|
||||||
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM PetComponent");
|
||||||
|
while (!tableData.eof()) {
|
||||||
|
const uint32_t componentID = tableData.getIntField("id", defaultEntry.id);
|
||||||
|
|
||||||
|
auto& entry = m_Entries[componentID];
|
||||||
|
entry.id = componentID;
|
||||||
|
UNUSED_COLUMN(entry.minTameUpdateTime = tableData.getFloatField("minTameUpdateTime", defaultEntry.minTameUpdateTime));
|
||||||
|
UNUSED_COLUMN(entry.maxTameUpdateTime = tableData.getFloatField("maxTameUpdateTime", defaultEntry.maxTameUpdateTime));
|
||||||
|
UNUSED_COLUMN(entry.percentTameChance = tableData.getFloatField("percentTameChance", defaultEntry.percentTameChance));
|
||||||
|
UNUSED_COLUMN(entry.tameability = tableData.getFloatField("tamability", defaultEntry.tameability)); // Mispelled as "tamability" in CDClient
|
||||||
|
UNUSED_COLUMN(entry.elementType = tableData.getIntField("elementType", defaultEntry.elementType));
|
||||||
|
entry.walkSpeed = static_cast<float>(tableData.getFloatField("walkSpeed", defaultEntry.walkSpeed));
|
||||||
|
entry.runSpeed = static_cast<float>(tableData.getFloatField("runSpeed", defaultEntry.runSpeed));
|
||||||
|
entry.sprintSpeed = static_cast<float>(tableData.getFloatField("sprintSpeed", defaultEntry.sprintSpeed));
|
||||||
|
UNUSED_COLUMN(entry.idleTimeMin = tableData.getFloatField("idleTimeMin", defaultEntry.idleTimeMin));
|
||||||
|
UNUSED_COLUMN(entry.idleTimeMax = tableData.getFloatField("idleTimeMax", defaultEntry.idleTimeMax));
|
||||||
|
UNUSED_COLUMN(entry.petForm = tableData.getIntField("petForm", defaultEntry.petForm));
|
||||||
|
entry.imaginationDrainRate = static_cast<float>(tableData.getFloatField("imaginationDrainRate", defaultEntry.imaginationDrainRate));
|
||||||
|
UNUSED_COLUMN(entry.AudioMetaEventSet = tableData.getStringField("AudioMetaEventSet", defaultEntry.AudioMetaEventSet));
|
||||||
|
UNUSED_COLUMN(entry.buffIDs = tableData.getStringField("buffIDs", defaultEntry.buffIDs));
|
||||||
|
|
||||||
|
tableData.nextRow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDPetComponentTable::LoadValuesFromDefaults() {
|
||||||
|
m_Entries.insert(std::make_pair(defaultEntry.id, defaultEntry));
|
||||||
|
}
|
||||||
|
|
||||||
|
CDPetComponent& CDPetComponentTable::GetByID(const uint32_t componentID) {
|
||||||
|
auto itr = m_Entries.find(componentID);
|
||||||
|
if (itr == m_Entries.end()) {
|
||||||
|
LOG("Unable to load pet component (ID %i) values from database! Using default values instead.", componentID);
|
||||||
|
return defaultEntry;
|
||||||
|
}
|
||||||
|
return itr->second;
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "CDTable.h"
|
||||||
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
struct CDPetComponent {
|
||||||
|
uint32_t id;
|
||||||
|
UNUSED_COLUMN(float minTameUpdateTime;)
|
||||||
|
UNUSED_COLUMN(float maxTameUpdateTime;)
|
||||||
|
UNUSED_COLUMN(float percentTameChance;)
|
||||||
|
UNUSED_COLUMN(float tameability;) // Mispelled as "tamability" in CDClient
|
||||||
|
UNUSED_COLUMN(uint32_t elementType;)
|
||||||
|
float walkSpeed;
|
||||||
|
float runSpeed;
|
||||||
|
float sprintSpeed;
|
||||||
|
UNUSED_COLUMN(float idleTimeMin;)
|
||||||
|
UNUSED_COLUMN(float idleTimeMax;)
|
||||||
|
UNUSED_COLUMN(uint32_t petForm;)
|
||||||
|
float imaginationDrainRate;
|
||||||
|
UNUSED_COLUMN(std::string AudioMetaEventSet;)
|
||||||
|
UNUSED_COLUMN(std::string buffIDs;)
|
||||||
|
};
|
||||||
|
|
||||||
|
class CDPetComponentTable : public CDTable<CDPetComponentTable> {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load values from the CD client database
|
||||||
|
*/
|
||||||
|
void LoadValuesFromDatabase();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the default values into memory instead of attempting to connect to the CD client database
|
||||||
|
*/
|
||||||
|
void LoadValuesFromDefaults();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the pet component table corresponding to the pet component ID
|
||||||
|
* @returns A reference to the corresponding table, or the default if one could not be found
|
||||||
|
*/
|
||||||
|
CDPetComponent& GetByID(const uint32_t componentID);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::map<uint32_t, CDPetComponent> m_Entries;
|
||||||
|
};
|
@ -28,7 +28,7 @@ void CDPhysicsComponentTable::LoadValuesFromDatabase() {
|
|||||||
tableData.finalize();
|
tableData.finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
CDPhysicsComponent* CDPhysicsComponentTable::GetByID(unsigned int componentID) {
|
CDPhysicsComponent* CDPhysicsComponentTable::GetByID(uint32_t componentID) {
|
||||||
auto itr = m_entries.find(componentID);
|
auto itr = m_entries.find(componentID);
|
||||||
return itr != m_entries.end() ? &itr->second : nullptr;
|
return itr != m_entries.end() ? &itr->second : nullptr;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
struct CDPhysicsComponent {
|
struct CDPhysicsComponent {
|
||||||
int id;
|
int32_t id;
|
||||||
bool bStatic;
|
bool bStatic;
|
||||||
std::string physicsAsset;
|
std::string physicsAsset;
|
||||||
UNUSED(bool jump);
|
UNUSED(bool jump);
|
||||||
@ -12,8 +12,8 @@ struct CDPhysicsComponent {
|
|||||||
UNUSED(float rotSpeed);
|
UNUSED(float rotSpeed);
|
||||||
float playerHeight;
|
float playerHeight;
|
||||||
float playerRadius;
|
float playerRadius;
|
||||||
int pcShapeType;
|
int32_t pcShapeType;
|
||||||
int collisionGroup;
|
int32_t collisionGroup;
|
||||||
UNUSED(float airSpeed);
|
UNUSED(float airSpeed);
|
||||||
UNUSED(std::string boundaryAsset);
|
UNUSED(std::string boundaryAsset);
|
||||||
UNUSED(float jumpAirSpeed);
|
UNUSED(float jumpAirSpeed);
|
||||||
@ -26,8 +26,8 @@ public:
|
|||||||
void LoadValuesFromDatabase();
|
void LoadValuesFromDatabase();
|
||||||
|
|
||||||
static const std::string GetTableName() { return "PhysicsComponent"; };
|
static const std::string GetTableName() { return "PhysicsComponent"; };
|
||||||
CDPhysicsComponent* GetByID(unsigned int componentID);
|
CDPhysicsComponent* GetByID(uint32_t componentID);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<unsigned int, CDPhysicsComponent> m_entries;
|
std::map<uint32_t, CDPhysicsComponent> m_entries;
|
||||||
};
|
};
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
void CDProximityMonitorComponentTable::LoadValuesFromDatabase() {
|
void CDProximityMonitorComponentTable::LoadValuesFromDatabase() {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
uint32_t size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ProximityMonitorComponent");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ProximityMonitorComponent");
|
||||||
while (!tableSize.eof()) {
|
while (!tableSize.eof()) {
|
||||||
size = tableSize.getIntField(0, 0);
|
size = tableSize.getIntField(0, 0);
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
struct CDProximityMonitorComponent {
|
struct CDProximityMonitorComponent {
|
||||||
unsigned int id;
|
uint32_t id;
|
||||||
std::string Proximities;
|
std::string Proximities;
|
||||||
bool LoadOnClient;
|
bool LoadOnClient;
|
||||||
bool LoadOnServer;
|
bool LoadOnServer;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
void CDRarityTableTable::LoadValuesFromDatabase() {
|
void CDRarityTableTable::LoadValuesFromDatabase() {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
uint32_t size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM RarityTable");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM RarityTable");
|
||||||
while (!tableSize.eof()) {
|
while (!tableSize.eof()) {
|
||||||
size = tableSize.getIntField(0, 0);
|
size = tableSize.getIntField(0, 0);
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
struct CDRarityTable {
|
struct CDRarityTable {
|
||||||
float randmax;
|
float randmax;
|
||||||
unsigned int rarity;
|
uint32_t rarity;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<CDRarityTable> RarityTable;
|
typedef std::vector<CDRarityTable> RarityTable;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
void CDRebuildComponentTable::LoadValuesFromDatabase() {
|
void CDRebuildComponentTable::LoadValuesFromDatabase() {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
uint32_t size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM RebuildComponent");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM RebuildComponent");
|
||||||
while (!tableSize.eof()) {
|
while (!tableSize.eof()) {
|
||||||
size = tableSize.getIntField(0, 0);
|
size = tableSize.getIntField(0, 0);
|
||||||
|
@ -4,15 +4,15 @@
|
|||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
struct CDRebuildComponent {
|
struct CDRebuildComponent {
|
||||||
unsigned int id; //!< The component Id
|
uint32_t id; //!< The component Id
|
||||||
float reset_time; //!< The reset time
|
float reset_time; //!< The reset time
|
||||||
float complete_time; //!< The complete time
|
float complete_time; //!< The complete time
|
||||||
unsigned int take_imagination; //!< The amount of imagination it costs
|
uint32_t take_imagination; //!< The amount of imagination it costs
|
||||||
bool interruptible; //!< Whether or not the rebuild is interruptible
|
bool interruptible; //!< Whether or not the rebuild is interruptible
|
||||||
bool self_activator; //!< Whether or not the rebuild is a rebuild activator itself
|
bool self_activator; //!< Whether or not the rebuild is a rebuild activator itself
|
||||||
std::string custom_modules; //!< The custom modules
|
std::string custom_modules; //!< The custom modules
|
||||||
unsigned int activityID; //!< The activity ID
|
uint32_t activityID; //!< The activity ID
|
||||||
unsigned int post_imagination_cost; //!< The post imagination cost
|
uint32_t post_imagination_cost; //!< The post imagination cost
|
||||||
float time_before_smash; //!< The time before smash
|
float time_before_smash; //!< The time before smash
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
void CDRewardCodesTable::LoadValuesFromDatabase() {
|
void CDRewardCodesTable::LoadValuesFromDatabase() {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
uint32_t size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM RewardCodes");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM RewardCodes");
|
||||||
while (!tableSize.eof()) {
|
while (!tableSize.eof()) {
|
||||||
size = tableSize.getIntField(0, 0);
|
size = tableSize.getIntField(0, 0);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
void CDScriptComponentTable::LoadValuesFromDatabase() {
|
void CDScriptComponentTable::LoadValuesFromDatabase() {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
uint32_t size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ScriptComponent");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ScriptComponent");
|
||||||
while (!tableSize.eof()) {
|
while (!tableSize.eof()) {
|
||||||
size = tableSize.getIntField(0, 0);
|
size = tableSize.getIntField(0, 0);
|
||||||
@ -28,8 +28,8 @@ void CDScriptComponentTable::LoadValuesFromDatabase() {
|
|||||||
tableData.finalize();
|
tableData.finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
const CDScriptComponent& CDScriptComponentTable::GetByID(unsigned int id) {
|
const CDScriptComponent& CDScriptComponentTable::GetByID(uint32_t id) {
|
||||||
std::map<unsigned int, CDScriptComponent>::iterator it = this->entries.find(id);
|
std::map<uint32_t, CDScriptComponent>::iterator it = this->entries.find(id);
|
||||||
if (it != this->entries.end()) {
|
if (it != this->entries.end()) {
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
@ -4,19 +4,19 @@
|
|||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
struct CDScriptComponent {
|
struct CDScriptComponent {
|
||||||
unsigned int id; //!< The component ID
|
uint32_t id; //!< The component ID
|
||||||
std::string script_name; //!< The script name
|
std::string script_name; //!< The script name
|
||||||
std::string client_script_name; //!< The client script name
|
std::string client_script_name; //!< The client script name
|
||||||
};
|
};
|
||||||
|
|
||||||
class CDScriptComponentTable : public CDTable<CDScriptComponentTable> {
|
class CDScriptComponentTable : public CDTable<CDScriptComponentTable> {
|
||||||
private:
|
private:
|
||||||
std::map<unsigned int, CDScriptComponent> entries;
|
std::map<uint32_t, CDScriptComponent> entries;
|
||||||
CDScriptComponent m_ToReturnWhenNoneFound;
|
CDScriptComponent m_ToReturnWhenNoneFound;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
void LoadValuesFromDatabase();
|
||||||
// Gets an entry by scriptID
|
// Gets an entry by scriptID
|
||||||
const CDScriptComponent& GetByID(unsigned int id);
|
const CDScriptComponent& GetByID(uint32_t id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ void CDSkillBehaviorTable::LoadValuesFromDatabase() {
|
|||||||
m_empty = CDSkillBehavior();
|
m_empty = CDSkillBehavior();
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
uint32_t size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM SkillBehavior");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM SkillBehavior");
|
||||||
while (!tableSize.eof()) {
|
while (!tableSize.eof()) {
|
||||||
size = tableSize.getIntField(0, 0);
|
size = tableSize.getIntField(0, 0);
|
||||||
@ -49,8 +49,8 @@ void CDSkillBehaviorTable::LoadValuesFromDatabase() {
|
|||||||
tableData.finalize();
|
tableData.finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
const CDSkillBehavior& CDSkillBehaviorTable::GetSkillByID(unsigned int skillID) {
|
const CDSkillBehavior& CDSkillBehaviorTable::GetSkillByID(uint32_t skillID) {
|
||||||
std::map<unsigned int, CDSkillBehavior>::iterator it = this->entries.find(skillID);
|
std::map<uint32_t, CDSkillBehavior>::iterator it = this->entries.find(skillID);
|
||||||
if (it != this->entries.end()) {
|
if (it != this->entries.end()) {
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
@ -4,36 +4,36 @@
|
|||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
struct CDSkillBehavior {
|
struct CDSkillBehavior {
|
||||||
unsigned int skillID; //!< The Skill ID of the skill
|
uint32_t skillID; //!< The Skill ID of the skill
|
||||||
UNUSED(unsigned int locStatus); //!< ??
|
UNUSED(uint32_t locStatus); //!< ??
|
||||||
unsigned int behaviorID; //!< The Behavior ID of the skill
|
uint32_t behaviorID; //!< The Behavior ID of the skill
|
||||||
unsigned int imaginationcost; //!< The imagination cost of the skill
|
uint32_t imaginationcost; //!< The imagination cost of the skill
|
||||||
unsigned int cooldowngroup; //!< The cooldown group ID of the skill
|
uint32_t cooldowngroup; //!< The cooldown group ID of the skill
|
||||||
float cooldown; //!< The cooldown time of the skill
|
float cooldown; //!< The cooldown time of the skill
|
||||||
UNUSED(bool isNpcEditor); //!< ???
|
UNUSED(bool isNpcEditor); //!< ???
|
||||||
UNUSED(unsigned int skillIcon); //!< The Skill Icon ID
|
UNUSED(uint32_t skillIcon); //!< The Skill Icon ID
|
||||||
UNUSED(std::string oomSkillID); //!< ???
|
UNUSED(std::string oomSkillID); //!< ???
|
||||||
UNUSED(unsigned int oomBehaviorEffectID); //!< ???
|
UNUSED(uint32_t oomBehaviorEffectID); //!< ???
|
||||||
UNUSED(unsigned int castTypeDesc); //!< The cast type description(?)
|
UNUSED(uint32_t castTypeDesc); //!< The cast type description(?)
|
||||||
UNUSED(unsigned int imBonusUI); //!< The imagination bonus of the skill
|
UNUSED(uint32_t imBonusUI); //!< The imagination bonus of the skill
|
||||||
UNUSED(nsigned int lifeBonusUI); //!< The life bonus of the skill
|
UNUSED(nint32_t lifeBonusUI); //!< The life bonus of the skill
|
||||||
UNUSED(unsigned int armorBonusUI); //!< The armor bonus of the skill
|
UNUSED(uint32_t armorBonusUI); //!< The armor bonus of the skill
|
||||||
UNUSED(unsigned int damageUI); //!< ???
|
UNUSED(uint32_t damageUI); //!< ???
|
||||||
UNUSED(bool hideIcon); //!< Whether or not to show the icon
|
UNUSED(bool hideIcon); //!< Whether or not to show the icon
|
||||||
UNUSED(bool localize); //!< ???
|
UNUSED(bool localize); //!< ???
|
||||||
UNUSED(std::string gate_version); //!< ???
|
UNUSED(std::string gate_version); //!< ???
|
||||||
UNUSED(unsigned int cancelType); //!< The cancel type (?)
|
UNUSED(uint32_t cancelType); //!< The cancel type (?)
|
||||||
};
|
};
|
||||||
|
|
||||||
class CDSkillBehaviorTable : public CDTable<CDSkillBehaviorTable> {
|
class CDSkillBehaviorTable : public CDTable<CDSkillBehaviorTable> {
|
||||||
private:
|
private:
|
||||||
std::map<unsigned int, CDSkillBehavior> entries;
|
std::map<uint32_t, CDSkillBehavior> entries;
|
||||||
CDSkillBehavior m_empty;
|
CDSkillBehavior m_empty;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
void LoadValuesFromDatabase();
|
||||||
|
|
||||||
// Gets an entry by skillID
|
// Gets an entry by skillID
|
||||||
const CDSkillBehavior& GetSkillByID(unsigned int skillID);
|
const CDSkillBehavior& GetSkillByID(uint32_t skillID);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,6 +23,9 @@
|
|||||||
// Enable this to skip some unused columns in some tables
|
// Enable this to skip some unused columns in some tables
|
||||||
#define UNUSED_COLUMN(v)
|
#define UNUSED_COLUMN(v)
|
||||||
|
|
||||||
|
// Use this to skip unused defaults for unused entries in some tables
|
||||||
|
#define UNUSED_ENTRY(v, x)
|
||||||
|
|
||||||
#pragma warning (disable : 4244) //Disable double to float conversion warnings
|
#pragma warning (disable : 4244) //Disable double to float conversion warnings
|
||||||
#pragma warning (disable : 4715) //Disable "not all control paths return a value"
|
#pragma warning (disable : 4715) //Disable "not all control paths return a value"
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
void CDVendorComponentTable::LoadValuesFromDatabase() {
|
void CDVendorComponentTable::LoadValuesFromDatabase() {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
uint32_t size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM VendorComponent");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM VendorComponent");
|
||||||
while (!tableSize.eof()) {
|
while (!tableSize.eof()) {
|
||||||
size = tableSize.getIntField(0, 0);
|
size = tableSize.getIntField(0, 0);
|
||||||
|
@ -4,11 +4,11 @@
|
|||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
struct CDVendorComponent {
|
struct CDVendorComponent {
|
||||||
unsigned int id; //!< The Component ID
|
uint32_t id; //!< The Component ID
|
||||||
float buyScalar; //!< Buy Scalar (what does that mean?)
|
float buyScalar; //!< Buy Scalar (what does that mean?)
|
||||||
float sellScalar; //!< Sell Scalar (what does that mean?)
|
float sellScalar; //!< Sell Scalar (what does that mean?)
|
||||||
float refreshTimeSeconds; //!< The refresh time
|
float refreshTimeSeconds; //!< The refresh time
|
||||||
unsigned int LootMatrixIndex; //!< LootMatrixIndex of the vendor's items
|
uint32_t LootMatrixIndex; //!< LootMatrixIndex of the vendor's items
|
||||||
};
|
};
|
||||||
|
|
||||||
class CDVendorComponentTable : public CDTable<CDVendorComponentTable> {
|
class CDVendorComponentTable : public CDTable<CDVendorComponentTable> {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
void CDZoneTableTable::LoadValuesFromDatabase() {
|
void CDZoneTableTable::LoadValuesFromDatabase() {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
uint32_t size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ZoneTable");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ZoneTable");
|
||||||
while (!tableSize.eof()) {
|
while (!tableSize.eof()) {
|
||||||
size = tableSize.getIntField(0, 0);
|
size = tableSize.getIntField(0, 0);
|
||||||
@ -53,7 +53,7 @@ void CDZoneTableTable::LoadValuesFromDatabase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Queries the table with a zoneID to find.
|
//! Queries the table with a zoneID to find.
|
||||||
const CDZoneTable* CDZoneTableTable::Query(unsigned int zoneID) {
|
const CDZoneTable* CDZoneTableTable::Query(uint32_t zoneID) {
|
||||||
const auto& iter = m_Entries.find(zoneID);
|
const auto& iter = m_Entries.find(zoneID);
|
||||||
|
|
||||||
if (iter != m_Entries.end()) {
|
if (iter != m_Entries.end()) {
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
struct CDZoneTable {
|
struct CDZoneTable {
|
||||||
unsigned int zoneID; //!< The Zone ID of the object
|
uint32_t zoneID; //!< The Zone ID of the object
|
||||||
unsigned int locStatus; //!< The Locale Status(?)
|
uint32_t locStatus; //!< The Locale Status(?)
|
||||||
std::string zoneName; //!< The name of the zone
|
std::string zoneName; //!< The name of the zone
|
||||||
unsigned int scriptID; //!< The Script ID of the zone (ScriptsTable)
|
uint32_t scriptID; //!< The Script ID of the zone (ScriptsTable)
|
||||||
float ghostdistance_min; //!< The minimum ghosting distance
|
float ghostdistance_min; //!< The minimum ghosting distance
|
||||||
float ghostdistance; //!< The ghosting distance
|
float ghostdistance; //!< The ghosting distance
|
||||||
unsigned int population_soft_cap; //!< The "soft cap" on the world population
|
uint32_t population_soft_cap; //!< The "soft cap" on the world population
|
||||||
unsigned int population_hard_cap; //!< The "hard cap" on the world population
|
uint32_t population_hard_cap; //!< The "hard cap" on the world population
|
||||||
UNUSED(std::string DisplayDescription); //!< The display description of the world
|
UNUSED(std::string DisplayDescription); //!< The display description of the world
|
||||||
UNUSED(std::string mapFolder); //!< ???
|
UNUSED(std::string mapFolder); //!< ???
|
||||||
float smashableMinDistance; //!< The minimum smashable distance?
|
float smashableMinDistance; //!< The minimum smashable distance?
|
||||||
@ -19,9 +19,9 @@ struct CDZoneTable {
|
|||||||
UNUSED(std::string mixerProgram); //!< ???
|
UNUSED(std::string mixerProgram); //!< ???
|
||||||
UNUSED(std::string clientPhysicsFramerate); //!< The client physics framerate
|
UNUSED(std::string clientPhysicsFramerate); //!< The client physics framerate
|
||||||
std::string serverPhysicsFramerate; //!< The server physics framerate
|
std::string serverPhysicsFramerate; //!< The server physics framerate
|
||||||
unsigned int zoneControlTemplate; //!< The Zone Control template
|
uint32_t zoneControlTemplate; //!< The Zone Control template
|
||||||
unsigned int widthInChunks; //!< The width of the world in chunks
|
uint32_t widthInChunks; //!< The width of the world in chunks
|
||||||
unsigned int heightInChunks; //!< The height of the world in chunks
|
uint32_t heightInChunks; //!< The height of the world in chunks
|
||||||
bool petsAllowed; //!< Whether or not pets are allowed in the world
|
bool petsAllowed; //!< Whether or not pets are allowed in the world
|
||||||
bool localize; //!< Whether or not the world should be localized
|
bool localize; //!< Whether or not the world should be localized
|
||||||
float fZoneWeight; //!< ???
|
float fZoneWeight; //!< ???
|
||||||
@ -35,11 +35,11 @@ struct CDZoneTable {
|
|||||||
|
|
||||||
class CDZoneTableTable : public CDTable<CDZoneTableTable> {
|
class CDZoneTableTable : public CDTable<CDZoneTableTable> {
|
||||||
private:
|
private:
|
||||||
std::map<unsigned int, CDZoneTable> m_Entries;
|
std::map<uint32_t, CDZoneTable> m_Entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
void LoadValuesFromDatabase();
|
||||||
|
|
||||||
// Queries the table with a zoneID to find.
|
// Queries the table with a zoneID to find.
|
||||||
const CDZoneTable* Query(unsigned int zoneID);
|
const CDZoneTable* Query(uint32_t zoneID);
|
||||||
};
|
};
|
||||||
|
@ -23,6 +23,7 @@ set(DDATABASE_CDCLIENTDATABASE_CDCLIENTTABLES_SOURCES "CDActivitiesTable.cpp"
|
|||||||
"CDMovementAIComponentTable.cpp"
|
"CDMovementAIComponentTable.cpp"
|
||||||
"CDObjectSkillsTable.cpp"
|
"CDObjectSkillsTable.cpp"
|
||||||
"CDObjectsTable.cpp"
|
"CDObjectsTable.cpp"
|
||||||
|
"CDPetComponentTable.cpp"
|
||||||
"CDPackageComponentTable.cpp"
|
"CDPackageComponentTable.cpp"
|
||||||
"CDPhysicsComponentTable.cpp"
|
"CDPhysicsComponentTable.cpp"
|
||||||
"CDPropertyEntranceComponentTable.cpp"
|
"CDPropertyEntranceComponentTable.cpp"
|
||||||
|
@ -3,6 +3,7 @@ set(DGAME_SOURCES "Character.cpp"
|
|||||||
"EntityManager.cpp"
|
"EntityManager.cpp"
|
||||||
"LeaderboardManager.cpp"
|
"LeaderboardManager.cpp"
|
||||||
"Player.cpp"
|
"Player.cpp"
|
||||||
|
"PlayerManager.cpp"
|
||||||
"TeamManager.cpp"
|
"TeamManager.cpp"
|
||||||
"TradingManager.cpp"
|
"TradingManager.cpp"
|
||||||
"User.cpp"
|
"User.cpp"
|
||||||
|
192
dGame/Entity.cpp
192
dGame/Entity.cpp
@ -3,7 +3,6 @@
|
|||||||
#include "CDClientManager.h"
|
#include "CDClientManager.h"
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "PacketUtils.h"
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include "CDDestructibleComponentTable.h"
|
#include "CDDestructibleComponentTable.h"
|
||||||
#include "CDClientDatabase.h"
|
#include "CDClientDatabase.h"
|
||||||
@ -25,6 +24,8 @@
|
|||||||
#include "eMissionTaskType.h"
|
#include "eMissionTaskType.h"
|
||||||
#include "eTriggerEventType.h"
|
#include "eTriggerEventType.h"
|
||||||
#include "eObjectBits.h"
|
#include "eObjectBits.h"
|
||||||
|
#include "PositionUpdate.h"
|
||||||
|
#include "eChatMessageType.h"
|
||||||
|
|
||||||
//Component includes:
|
//Component includes:
|
||||||
#include "Component.h"
|
#include "Component.h"
|
||||||
@ -80,6 +81,7 @@
|
|||||||
#include "RacingStatsComponent.h"
|
#include "RacingStatsComponent.h"
|
||||||
#include "CollectibleComponent.h"
|
#include "CollectibleComponent.h"
|
||||||
#include "ItemComponent.h"
|
#include "ItemComponent.h"
|
||||||
|
#include "GhostComponent.h"
|
||||||
|
|
||||||
// Table includes
|
// Table includes
|
||||||
#include "CDComponentsRegistryTable.h"
|
#include "CDComponentsRegistryTable.h"
|
||||||
@ -436,6 +438,8 @@ void Entity::Initialize() {
|
|||||||
AddComponent<PlayerForcedMovementComponent>();
|
AddComponent<PlayerForcedMovementComponent>();
|
||||||
|
|
||||||
AddComponent<CharacterComponent>(m_Character)->LoadFromXml(m_Character->GetXMLDoc());
|
AddComponent<CharacterComponent>(m_Character)->LoadFromXml(m_Character->GetXMLDoc());
|
||||||
|
|
||||||
|
AddComponent<GhostComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::INVENTORY) > 0 || m_Character) {
|
if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::INVENTORY) > 0 || m_Character) {
|
||||||
@ -855,9 +859,20 @@ void Entity::SetGMLevel(eGameMasterLevel value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CharacterComponent* character = GetComponent<CharacterComponent>();
|
CharacterComponent* character = GetComponent<CharacterComponent>();
|
||||||
if (character) character->SetGMLevel(value);
|
if (!character) return;
|
||||||
|
character->SetGMLevel(value);
|
||||||
|
|
||||||
GameMessages::SendGMLevelBroadcast(m_ObjectID, value);
|
GameMessages::SendGMLevelBroadcast(m_ObjectID, value);
|
||||||
|
|
||||||
|
// Update the chat server of our GM Level
|
||||||
|
{
|
||||||
|
CBITSTREAM;
|
||||||
|
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::GMLEVEL_UPDATE);
|
||||||
|
bitStream.Write(m_ObjectID);
|
||||||
|
bitStream.Write(m_GMLevel);
|
||||||
|
|
||||||
|
Game::chatServer->Send(&bitStream, SYSTEM_PRIORITY, RELIABLE, 0, Game::chatSysAddr, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacketType packetType) {
|
void Entity::WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacketType packetType) {
|
||||||
@ -1222,39 +1237,56 @@ void Entity::UpdateXMLDoc(tinyxml2::XMLDocument* doc) {
|
|||||||
|
|
||||||
void Entity::Update(const float deltaTime) {
|
void Entity::Update(const float deltaTime) {
|
||||||
uint32_t timerPosition;
|
uint32_t timerPosition;
|
||||||
timerPosition = 0;
|
for (timerPosition = 0; timerPosition < m_Timers.size();) {
|
||||||
while (timerPosition < m_Timers.size()) {
|
auto& timer = m_Timers[timerPosition];
|
||||||
m_Timers[timerPosition]->Update(deltaTime);
|
timer.Update(deltaTime);
|
||||||
if (m_Timers[timerPosition]->GetTime() <= 0) {
|
// If the timer is expired, erase it and dont increment the position because the next timer will be at the same position.
|
||||||
const auto timerName = m_Timers[timerPosition]->GetName();
|
// Before: [0, 1, 2, 3, ..., n]
|
||||||
|
// timerPosition ^
|
||||||
delete m_Timers[timerPosition];
|
// After: [0, 1, 3, ..., n]
|
||||||
|
// timerPosition ^
|
||||||
|
if (timer.GetTime() <= 0) {
|
||||||
|
// Remove the timer from the list of timers first so that scripts and events can remove timers without causing iterator invalidation
|
||||||
|
auto timerName = timer.GetName();
|
||||||
m_Timers.erase(m_Timers.begin() + timerPosition);
|
m_Timers.erase(m_Timers.begin() + timerPosition);
|
||||||
|
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
||||||
script->OnTimerDone(this, timerName);
|
script->OnTimerDone(this, timerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
TriggerEvent(eTriggerEventType::TIMER_DONE, this);
|
TriggerEvent(eTriggerEventType::TIMER_DONE, this);
|
||||||
|
} else {
|
||||||
|
// If the timer isnt expired, go to the next timer.
|
||||||
|
timerPosition++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (timerPosition = 0; timerPosition < m_CallbackTimers.size(); ) {
|
||||||
|
// If the timer is expired, erase it and dont increment the position because the next timer will be at the same position.
|
||||||
|
// Before: [0, 1, 2, 3, ..., n]
|
||||||
|
// timerPosition ^
|
||||||
|
// After: [0, 1, 3, ..., n]
|
||||||
|
// timerPosition ^
|
||||||
|
auto& callbackTimer = m_CallbackTimers[timerPosition];
|
||||||
|
callbackTimer.Update(deltaTime);
|
||||||
|
if (callbackTimer.GetTime() <= 0) {
|
||||||
|
// Remove the timer from the list of timers first so that callbacks can remove timers without causing iterator invalidation
|
||||||
|
auto callback = callbackTimer.GetCallback();
|
||||||
|
m_CallbackTimers.erase(m_CallbackTimers.begin() + timerPosition);
|
||||||
|
callback();
|
||||||
} else {
|
} else {
|
||||||
timerPosition++;
|
timerPosition++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < m_CallbackTimers.size(); i++) {
|
// Add pending timers to the list of timers so they start next tick.
|
||||||
m_CallbackTimers[i]->Update(deltaTime);
|
if (!m_PendingTimers.empty()) {
|
||||||
if (m_CallbackTimers[i]->GetTime() <= 0) {
|
m_Timers.insert(m_Timers.end(), m_PendingTimers.begin(), m_PendingTimers.end());
|
||||||
m_CallbackTimers[i]->GetCallback()();
|
m_PendingTimers.clear();
|
||||||
delete m_CallbackTimers[i];
|
|
||||||
m_CallbackTimers.erase(m_CallbackTimers.begin() + i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add pending timers to the list of timers so they start next tick.
|
if (!m_PendingCallbackTimers.empty()) {
|
||||||
if (m_PendingTimers.size() > 0) {
|
m_CallbackTimers.insert(m_CallbackTimers.end(), m_PendingCallbackTimers.begin(), m_PendingCallbackTimers.end());
|
||||||
for (auto namedTimer : m_PendingTimers) {
|
m_PendingCallbackTimers.clear();
|
||||||
m_Timers.push_back(namedTimer);
|
|
||||||
}
|
|
||||||
m_PendingTimers.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsSleeping()) {
|
if (IsSleeping()) {
|
||||||
@ -1692,31 +1724,20 @@ void Entity::RemoveParent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Entity::AddTimer(std::string name, float time) {
|
void Entity::AddTimer(std::string name, float time) {
|
||||||
EntityTimer* timer = new EntityTimer(name, time);
|
m_PendingTimers.emplace_back(name, time);
|
||||||
m_PendingTimers.push_back(timer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::AddCallbackTimer(float time, std::function<void()> callback) {
|
void Entity::AddCallbackTimer(float time, std::function<void()> callback) {
|
||||||
EntityCallbackTimer* timer = new EntityCallbackTimer(time, callback);
|
m_PendingCallbackTimers.emplace_back(time, callback);
|
||||||
m_CallbackTimers.push_back(timer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Entity::HasTimer(const std::string& name) {
|
bool Entity::HasTimer(const std::string& name) {
|
||||||
for (auto* timer : m_Timers) {
|
return std::find(m_Timers.begin(), m_Timers.end(), name) != m_Timers.end();
|
||||||
if (timer->GetName() == name) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::CancelCallbackTimers() {
|
void Entity::CancelCallbackTimers() {
|
||||||
for (auto* callback : m_CallbackTimers) {
|
|
||||||
delete callback;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_CallbackTimers.clear();
|
m_CallbackTimers.clear();
|
||||||
|
m_PendingCallbackTimers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::ScheduleKillAfterUpdate(Entity* murderer) {
|
void Entity::ScheduleKillAfterUpdate(Entity* murderer) {
|
||||||
@ -1728,8 +1749,8 @@ void Entity::ScheduleKillAfterUpdate(Entity* murderer) {
|
|||||||
|
|
||||||
void Entity::CancelTimer(const std::string& name) {
|
void Entity::CancelTimer(const std::string& name) {
|
||||||
for (int i = 0; i < m_Timers.size(); i++) {
|
for (int i = 0; i < m_Timers.size(); i++) {
|
||||||
if (m_Timers[i]->GetName() == name) {
|
auto& timer = m_Timers[i];
|
||||||
delete m_Timers[i];
|
if (timer == name) {
|
||||||
m_Timers.erase(m_Timers.begin() + i);
|
m_Timers.erase(m_Timers.begin() + i);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1737,21 +1758,10 @@ void Entity::CancelTimer(const std::string& name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Entity::CancelAllTimers() {
|
void Entity::CancelAllTimers() {
|
||||||
/*for (auto timer : m_Timers) {
|
|
||||||
if (timer) delete timer;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
for (auto* timer : m_Timers) {
|
|
||||||
delete timer;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_Timers.clear();
|
m_Timers.clear();
|
||||||
|
m_PendingTimers.clear();
|
||||||
for (auto* callBackTimer : m_CallbackTimers) {
|
|
||||||
delete callBackTimer;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_CallbackTimers.clear();
|
m_CallbackTimers.clear();
|
||||||
|
m_PendingCallbackTimers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Entity::IsPlayer() const {
|
bool Entity::IsPlayer() const {
|
||||||
@ -1884,7 +1894,7 @@ const NiQuaternion& Entity::GetRotation() const {
|
|||||||
return NiQuaternion::IDENTITY;
|
return NiQuaternion::IDENTITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::SetPosition(NiPoint3 position) {
|
void Entity::SetPosition(const NiPoint3& position) {
|
||||||
auto* controllable = GetComponent<ControllablePhysicsComponent>();
|
auto* controllable = GetComponent<ControllablePhysicsComponent>();
|
||||||
|
|
||||||
if (controllable != nullptr) {
|
if (controllable != nullptr) {
|
||||||
@ -1912,7 +1922,7 @@ void Entity::SetPosition(NiPoint3 position) {
|
|||||||
Game::entityManager->SerializeEntity(this);
|
Game::entityManager->SerializeEntity(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::SetRotation(NiQuaternion rotation) {
|
void Entity::SetRotation(const NiQuaternion& rotation) {
|
||||||
auto* controllable = GetComponent<ControllablePhysicsComponent>();
|
auto* controllable = GetComponent<ControllablePhysicsComponent>();
|
||||||
|
|
||||||
if (controllable != nullptr) {
|
if (controllable != nullptr) {
|
||||||
@ -2061,3 +2071,75 @@ uint8_t Entity::GetCollectibleID() const {
|
|||||||
auto* collectible = GetComponent<CollectibleComponent>();
|
auto* collectible = GetComponent<CollectibleComponent>();
|
||||||
return collectible ? collectible->GetCollectibleId() : 0;
|
return collectible ? collectible->GetCollectibleId() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Entity::ProcessPositionUpdate(PositionUpdate& update) {
|
||||||
|
if (!IsPlayer()) return;
|
||||||
|
auto* controllablePhysicsComponent = GetComponent<ControllablePhysicsComponent>();
|
||||||
|
if (!controllablePhysicsComponent) return;
|
||||||
|
|
||||||
|
auto* possessorComponent = GetComponent<PossessorComponent>();
|
||||||
|
bool updateChar = true;
|
||||||
|
|
||||||
|
if (possessorComponent) {
|
||||||
|
auto* possassableEntity = Game::entityManager->GetEntity(possessorComponent->GetPossessable());
|
||||||
|
|
||||||
|
if (possassableEntity) {
|
||||||
|
auto* possessableComponent = possassableEntity->GetComponent<PossessableComponent>();
|
||||||
|
|
||||||
|
// While possessing something, only update char if we are attached to the thing we are possessing
|
||||||
|
updateChar = possessableComponent && possessableComponent->GetPossessionType() == ePossessionType::ATTACHED_VISIBLE;
|
||||||
|
|
||||||
|
auto* havokVehiclePhysicsComponent = possassableEntity->GetComponent<HavokVehiclePhysicsComponent>();
|
||||||
|
if (havokVehiclePhysicsComponent) {
|
||||||
|
havokVehiclePhysicsComponent->SetPosition(update.position);
|
||||||
|
havokVehiclePhysicsComponent->SetRotation(update.rotation);
|
||||||
|
havokVehiclePhysicsComponent->SetIsOnGround(update.onGround);
|
||||||
|
havokVehiclePhysicsComponent->SetIsOnRail(update.onRail);
|
||||||
|
havokVehiclePhysicsComponent->SetVelocity(update.velocity);
|
||||||
|
havokVehiclePhysicsComponent->SetDirtyVelocity(update.velocity != NiPoint3::ZERO);
|
||||||
|
havokVehiclePhysicsComponent->SetAngularVelocity(update.angularVelocity);
|
||||||
|
havokVehiclePhysicsComponent->SetDirtyAngularVelocity(update.angularVelocity != NiPoint3::ZERO);
|
||||||
|
havokVehiclePhysicsComponent->SetRemoteInputInfo(update.remoteInputInfo);
|
||||||
|
} else {
|
||||||
|
// Need to get the mount's controllable physics
|
||||||
|
auto* possessedControllablePhysicsComponent = possassableEntity->GetComponent<ControllablePhysicsComponent>();
|
||||||
|
if (!possessedControllablePhysicsComponent) return;
|
||||||
|
possessedControllablePhysicsComponent->SetPosition(update.position);
|
||||||
|
possessedControllablePhysicsComponent->SetRotation(update.rotation);
|
||||||
|
possessedControllablePhysicsComponent->SetIsOnGround(update.onGround);
|
||||||
|
possessedControllablePhysicsComponent->SetIsOnRail(update.onRail);
|
||||||
|
possessedControllablePhysicsComponent->SetVelocity(update.velocity);
|
||||||
|
possessedControllablePhysicsComponent->SetDirtyVelocity(update.velocity != NiPoint3::ZERO);
|
||||||
|
possessedControllablePhysicsComponent->SetAngularVelocity(update.angularVelocity);
|
||||||
|
possessedControllablePhysicsComponent->SetDirtyAngularVelocity(update.angularVelocity != NiPoint3::ZERO);
|
||||||
|
}
|
||||||
|
Game::entityManager->SerializeEntity(possassableEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!updateChar) {
|
||||||
|
update.velocity = NiPoint3::ZERO;
|
||||||
|
update.angularVelocity = NiPoint3::ZERO;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle statistics
|
||||||
|
auto* characterComponent = GetComponent<CharacterComponent>();
|
||||||
|
if (characterComponent) {
|
||||||
|
characterComponent->TrackPositionUpdate(update.position);
|
||||||
|
}
|
||||||
|
|
||||||
|
controllablePhysicsComponent->SetPosition(update.position);
|
||||||
|
controllablePhysicsComponent->SetRotation(update.rotation);
|
||||||
|
controllablePhysicsComponent->SetIsOnGround(update.onGround);
|
||||||
|
controllablePhysicsComponent->SetIsOnRail(update.onRail);
|
||||||
|
controllablePhysicsComponent->SetVelocity(update.velocity);
|
||||||
|
controllablePhysicsComponent->SetDirtyVelocity(update.velocity != NiPoint3::ZERO);
|
||||||
|
controllablePhysicsComponent->SetAngularVelocity(update.angularVelocity);
|
||||||
|
controllablePhysicsComponent->SetDirtyAngularVelocity(update.angularVelocity != NiPoint3::ZERO);
|
||||||
|
|
||||||
|
auto* ghostComponent = GetComponent<GhostComponent>();
|
||||||
|
if (ghostComponent) ghostComponent->SetGhostReferencePoint(update.position);
|
||||||
|
Game::entityManager->QueueGhostUpdate(GetObjectID());
|
||||||
|
|
||||||
|
if (updateChar) Game::entityManager->SerializeEntity(this);
|
||||||
|
}
|
||||||
|
@ -31,6 +31,7 @@ class Component;
|
|||||||
class Item;
|
class Item;
|
||||||
class Character;
|
class Character;
|
||||||
class EntityCallbackTimer;
|
class EntityCallbackTimer;
|
||||||
|
class PositionUpdate;
|
||||||
enum class eTriggerEventType;
|
enum class eTriggerEventType;
|
||||||
enum class eGameMasterLevel : uint8_t;
|
enum class eGameMasterLevel : uint8_t;
|
||||||
enum class eReplicaComponentType : uint32_t;
|
enum class eReplicaComponentType : uint32_t;
|
||||||
@ -105,7 +106,7 @@ public:
|
|||||||
|
|
||||||
virtual User* GetParentUser() const;
|
virtual User* GetParentUser() const;
|
||||||
|
|
||||||
virtual SystemAddress GetSystemAddress() const { return UNASSIGNED_SYSTEM_ADDRESS; };
|
virtual const SystemAddress& GetSystemAddress() const { return UNASSIGNED_SYSTEM_ADDRESS; };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setters
|
* Setters
|
||||||
@ -123,13 +124,13 @@ public:
|
|||||||
|
|
||||||
void SetNetworkId(uint16_t id);
|
void SetNetworkId(uint16_t id);
|
||||||
|
|
||||||
void SetPosition(NiPoint3 position);
|
void SetPosition(const NiPoint3& position);
|
||||||
|
|
||||||
void SetRotation(NiQuaternion rotation);
|
void SetRotation(const NiQuaternion& rotation);
|
||||||
|
|
||||||
virtual void SetRespawnPos(NiPoint3 position) {}
|
virtual void SetRespawnPos(const NiPoint3& position) {}
|
||||||
|
|
||||||
virtual void SetRespawnRot(NiQuaternion rotation) {}
|
virtual void SetRespawnRot(const NiQuaternion& rotation) {}
|
||||||
|
|
||||||
virtual void SetSystemAddress(const SystemAddress& value) {};
|
virtual void SetSystemAddress(const SystemAddress& value) {};
|
||||||
|
|
||||||
@ -160,6 +161,8 @@ public:
|
|||||||
void AddChild(Entity* child);
|
void AddChild(Entity* child);
|
||||||
void RemoveChild(Entity* child);
|
void RemoveChild(Entity* child);
|
||||||
void RemoveParent();
|
void RemoveParent();
|
||||||
|
|
||||||
|
// Adds a timer to start next frame with the given name and time.
|
||||||
void AddTimer(std::string name, float time);
|
void AddTimer(std::string name, float time);
|
||||||
void AddCallbackTimer(float time, std::function<void()> callback);
|
void AddCallbackTimer(float time, std::function<void()> callback);
|
||||||
bool HasTimer(const std::string& name);
|
bool HasTimer(const std::string& name);
|
||||||
@ -226,8 +229,8 @@ public:
|
|||||||
void TriggerEvent(eTriggerEventType event, Entity* optionalTarget = nullptr);
|
void TriggerEvent(eTriggerEventType event, Entity* optionalTarget = nullptr);
|
||||||
void ScheduleDestructionAfterUpdate() { m_ShouldDestroyAfterUpdate = true; }
|
void ScheduleDestructionAfterUpdate() { m_ShouldDestroyAfterUpdate = true; }
|
||||||
|
|
||||||
virtual NiPoint3 GetRespawnPosition() const { return NiPoint3::ZERO; }
|
virtual const NiPoint3& GetRespawnPosition() const { return NiPoint3::ZERO; }
|
||||||
virtual NiQuaternion GetRespawnRotation() const { return NiQuaternion::IDENTITY; }
|
virtual const NiQuaternion& GetRespawnRotation() const { return NiQuaternion::IDENTITY; }
|
||||||
|
|
||||||
void Sleep();
|
void Sleep();
|
||||||
void Wake();
|
void Wake();
|
||||||
@ -294,6 +297,8 @@ public:
|
|||||||
|
|
||||||
Entity* GetScheduledKiller() { return m_ScheduleKiller; }
|
Entity* GetScheduledKiller() { return m_ScheduleKiller; }
|
||||||
|
|
||||||
|
void ProcessPositionUpdate(PositionUpdate& update);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
LWOOBJID m_ObjectID;
|
LWOOBJID m_ObjectID;
|
||||||
|
|
||||||
@ -324,9 +329,10 @@ protected:
|
|||||||
std::vector<std::function<void(Entity* target)>> m_PhantomCollisionCallbacks;
|
std::vector<std::function<void(Entity* target)>> m_PhantomCollisionCallbacks;
|
||||||
|
|
||||||
std::unordered_map<eReplicaComponentType, Component*> m_Components;
|
std::unordered_map<eReplicaComponentType, Component*> m_Components;
|
||||||
std::vector<EntityTimer*> m_Timers;
|
std::vector<EntityTimer> m_Timers;
|
||||||
std::vector<EntityTimer*> m_PendingTimers;
|
std::vector<EntityTimer> m_PendingTimers;
|
||||||
std::vector<EntityCallbackTimer*> m_CallbackTimers;
|
std::vector<EntityCallbackTimer> m_CallbackTimers;
|
||||||
|
std::vector<EntityCallbackTimer> m_PendingCallbackTimers;
|
||||||
|
|
||||||
bool m_ShouldDestroyAfterUpdate = false;
|
bool m_ShouldDestroyAfterUpdate = false;
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
#include "SkillComponent.h"
|
#include "SkillComponent.h"
|
||||||
#include "SwitchComponent.h"
|
#include "SwitchComponent.h"
|
||||||
#include "UserManager.h"
|
#include "UserManager.h"
|
||||||
#include "PacketUtils.h"
|
|
||||||
#include "Metrics.hpp"
|
#include "Metrics.hpp"
|
||||||
#include "dZoneManager.h"
|
#include "dZoneManager.h"
|
||||||
#include "MissionComponent.h"
|
#include "MissionComponent.h"
|
||||||
@ -24,6 +23,8 @@
|
|||||||
#include "eGameMasterLevel.h"
|
#include "eGameMasterLevel.h"
|
||||||
#include "eReplicaComponentType.h"
|
#include "eReplicaComponentType.h"
|
||||||
#include "eReplicaPacketType.h"
|
#include "eReplicaPacketType.h"
|
||||||
|
#include "PlayerManager.h"
|
||||||
|
#include "GhostComponent.h"
|
||||||
|
|
||||||
// Configure which zones have ghosting disabled, mostly small worlds.
|
// Configure which zones have ghosting disabled, mostly small worlds.
|
||||||
std::vector<LWOMAPID> EntityManager::m_GhostingExcludedZones = {
|
std::vector<LWOMAPID> EntityManager::m_GhostingExcludedZones = {
|
||||||
@ -188,8 +189,9 @@ void EntityManager::SerializeEntities() {
|
|||||||
entity->WriteComponents(&stream, eReplicaPacketType::SERIALIZATION);
|
entity->WriteComponents(&stream, eReplicaPacketType::SERIALIZATION);
|
||||||
|
|
||||||
if (entity->GetIsGhostingCandidate()) {
|
if (entity->GetIsGhostingCandidate()) {
|
||||||
for (auto* player : Player::GetAllPlayers()) {
|
for (auto* player : PlayerManager::GetAllPlayers()) {
|
||||||
if (player->IsObserved(toSerialize)) {
|
auto* ghostComponent = player->GetComponent<GhostComponent>();
|
||||||
|
if (ghostComponent && ghostComponent->IsObserved(toSerialize)) {
|
||||||
Game::server->Send(&stream, player->GetSystemAddress(), false);
|
Game::server->Send(&stream, player->GetSystemAddress(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -377,11 +379,12 @@ void EntityManager::ConstructEntity(Entity* entity, const SystemAddress& sysAddr
|
|||||||
if (skipChecks) {
|
if (skipChecks) {
|
||||||
Game::server->Send(&stream, UNASSIGNED_SYSTEM_ADDRESS, true);
|
Game::server->Send(&stream, UNASSIGNED_SYSTEM_ADDRESS, true);
|
||||||
} else {
|
} else {
|
||||||
for (auto* player : Player::GetAllPlayers()) {
|
for (auto* player : PlayerManager::GetAllPlayers()) {
|
||||||
if (player->GetPlayerReadyForUpdates()) {
|
if (player->GetPlayerReadyForUpdates()) {
|
||||||
Game::server->Send(&stream, player->GetSystemAddress(), false);
|
Game::server->Send(&stream, player->GetSystemAddress(), false);
|
||||||
} else {
|
} else {
|
||||||
player->AddLimboConstruction(entity->GetObjectID());
|
auto* ghostComponent = player->GetComponent<GhostComponent>();
|
||||||
|
if (ghostComponent) ghostComponent->AddLimboConstruction(entity->GetObjectID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -389,8 +392,6 @@ void EntityManager::ConstructEntity(Entity* entity, const SystemAddress& sysAddr
|
|||||||
Game::server->Send(&stream, sysAddr, false);
|
Game::server->Send(&stream, sysAddr, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// PacketUtils::SavePacket("[24]_"+std::to_string(entity->GetObjectID()) + "_" + std::to_string(m_SerializationCounter) + ".bin", (char*)stream.GetData(), stream.GetNumberOfBytesUsed());
|
|
||||||
|
|
||||||
if (entity->IsPlayer()) {
|
if (entity->IsPlayer()) {
|
||||||
if (entity->GetGMLevel() > eGameMasterLevel::CIVILIAN) {
|
if (entity->GetGMLevel() > eGameMasterLevel::CIVILIAN) {
|
||||||
GameMessages::SendToggleGMInvis(entity->GetObjectID(), true, sysAddr);
|
GameMessages::SendToggleGMInvis(entity->GetObjectID(), true, sysAddr);
|
||||||
@ -408,7 +409,7 @@ void EntityManager::ConstructAllEntities(const SystemAddress& sysAddr) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateGhosting(Player::GetPlayer(sysAddr));
|
UpdateGhosting(PlayerManager::GetPlayer(sysAddr));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityManager::DestructEntity(Entity* entity, const SystemAddress& sysAddr) {
|
void EntityManager::DestructEntity(Entity* entity, const SystemAddress& sysAddr) {
|
||||||
@ -421,9 +422,10 @@ void EntityManager::DestructEntity(Entity* entity, const SystemAddress& sysAddr)
|
|||||||
|
|
||||||
Game::server->Send(&stream, sysAddr, sysAddr == UNASSIGNED_SYSTEM_ADDRESS);
|
Game::server->Send(&stream, sysAddr, sysAddr == UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
|
|
||||||
for (auto* player : Player::GetAllPlayers()) {
|
for (auto* player : PlayerManager::GetAllPlayers()) {
|
||||||
if (!player->GetPlayerReadyForUpdates()) {
|
if (!player->GetPlayerReadyForUpdates()) {
|
||||||
player->RemoveLimboConstruction(entity->GetObjectID());
|
auto* ghostComponent = player->GetComponent<GhostComponent>();
|
||||||
|
if (ghostComponent) ghostComponent->RemoveLimboConstruction(entity->GetObjectID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -434,8 +436,6 @@ void EntityManager::SerializeEntity(Entity* entity) {
|
|||||||
if (std::find(m_EntitiesToSerialize.begin(), m_EntitiesToSerialize.end(), entity->GetObjectID()) == m_EntitiesToSerialize.end()) {
|
if (std::find(m_EntitiesToSerialize.begin(), m_EntitiesToSerialize.end(), entity->GetObjectID()) == m_EntitiesToSerialize.end()) {
|
||||||
m_EntitiesToSerialize.push_back(entity->GetObjectID());
|
m_EntitiesToSerialize.push_back(entity->GetObjectID());
|
||||||
}
|
}
|
||||||
|
|
||||||
//PacketUtils::SavePacket(std::to_string(m_SerializationCounter) + "_[27]_"+std::to_string(entity->GetObjectID()) + ".bin", (char*)stream.GetData(), stream.GetNumberOfBytesUsed());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityManager::DestructAllEntities(const SystemAddress& sysAddr) {
|
void EntityManager::DestructAllEntities(const SystemAddress& sysAddr) {
|
||||||
@ -470,7 +470,7 @@ void EntityManager::QueueGhostUpdate(LWOOBJID playerID) {
|
|||||||
|
|
||||||
void EntityManager::UpdateGhosting() {
|
void EntityManager::UpdateGhosting() {
|
||||||
for (const auto playerID : m_PlayersToUpdateGhosting) {
|
for (const auto playerID : m_PlayersToUpdateGhosting) {
|
||||||
auto* player = Player::GetPlayer(playerID);
|
auto* player = PlayerManager::GetPlayer(playerID);
|
||||||
|
|
||||||
if (player == nullptr) {
|
if (player == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
@ -488,13 +488,14 @@ void EntityManager::UpdateGhosting(Player* player) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto* missionComponent = player->GetComponent<MissionComponent>();
|
auto* missionComponent = player->GetComponent<MissionComponent>();
|
||||||
|
auto* ghostComponent = player->GetComponent<GhostComponent>();
|
||||||
|
|
||||||
if (missionComponent == nullptr) {
|
if (missionComponent == nullptr || !ghostComponent) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& referencePoint = player->GetGhostReferencePoint();
|
const auto& referencePoint = ghostComponent->GetGhostReferencePoint();
|
||||||
const auto isOverride = player->GetGhostOverride();
|
const auto isOverride = ghostComponent->GetGhostOverride();
|
||||||
|
|
||||||
for (auto* entity : m_EntitiesToGhost) {
|
for (auto* entity : m_EntitiesToGhost) {
|
||||||
const auto isAudioEmitter = entity->GetLOT() == 6368;
|
const auto isAudioEmitter = entity->GetLOT() == 6368;
|
||||||
@ -503,7 +504,7 @@ void EntityManager::UpdateGhosting(Player* player) {
|
|||||||
|
|
||||||
const int32_t id = entity->GetObjectID();
|
const int32_t id = entity->GetObjectID();
|
||||||
|
|
||||||
const auto observed = player->IsObserved(id);
|
const auto observed = ghostComponent->IsObserved(id);
|
||||||
|
|
||||||
const auto distance = NiPoint3::DistanceSquared(referencePoint, entityPoint);
|
const auto distance = NiPoint3::DistanceSquared(referencePoint, entityPoint);
|
||||||
|
|
||||||
@ -515,7 +516,7 @@ void EntityManager::UpdateGhosting(Player* player) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (observed && distance > ghostingDistanceMax && !isOverride) {
|
if (observed && distance > ghostingDistanceMax && !isOverride) {
|
||||||
player->GhostEntity(id);
|
ghostComponent->GhostEntity(id);
|
||||||
|
|
||||||
DestructEntity(entity, player->GetSystemAddress());
|
DestructEntity(entity, player->GetSystemAddress());
|
||||||
|
|
||||||
@ -532,7 +533,7 @@ void EntityManager::UpdateGhosting(Player* player) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
player->ObserveEntity(id);
|
ghostComponent->ObserveEntity(id);
|
||||||
|
|
||||||
ConstructEntity(entity, player->GetSystemAddress());
|
ConstructEntity(entity, player->GetSystemAddress());
|
||||||
|
|
||||||
@ -553,23 +554,26 @@ void EntityManager::CheckGhosting(Entity* entity) {
|
|||||||
|
|
||||||
const auto isAudioEmitter = entity->GetLOT() == 6368;
|
const auto isAudioEmitter = entity->GetLOT() == 6368;
|
||||||
|
|
||||||
for (auto* player : Player::GetAllPlayers()) {
|
for (auto* player : PlayerManager::GetAllPlayers()) {
|
||||||
const auto& entityPoint = player->GetGhostReferencePoint();
|
auto* ghostComponent = player->GetComponent<GhostComponent>();
|
||||||
|
if (!ghostComponent) continue;
|
||||||
|
|
||||||
|
const auto& entityPoint = ghostComponent->GetGhostReferencePoint();
|
||||||
|
|
||||||
const int32_t id = entity->GetObjectID();
|
const int32_t id = entity->GetObjectID();
|
||||||
|
|
||||||
const auto observed = player->IsObserved(id);
|
const auto observed = ghostComponent->IsObserved(id);
|
||||||
|
|
||||||
const auto distance = NiPoint3::DistanceSquared(referencePoint, entityPoint);
|
const auto distance = NiPoint3::DistanceSquared(referencePoint, entityPoint);
|
||||||
|
|
||||||
if (observed && distance > ghostingDistanceMax) {
|
if (observed && distance > ghostingDistanceMax) {
|
||||||
player->GhostEntity(id);
|
ghostComponent->GhostEntity(id);
|
||||||
|
|
||||||
DestructEntity(entity, player->GetSystemAddress());
|
DestructEntity(entity, player->GetSystemAddress());
|
||||||
|
|
||||||
entity->SetObservers(entity->GetObservers() - 1);
|
entity->SetObservers(entity->GetObservers() - 1);
|
||||||
} else if (!observed && ghostingDistanceMin > distance) {
|
} else if (!observed && ghostingDistanceMin > distance) {
|
||||||
player->ObserveEntity(id);
|
ghostComponent->ObserveEntity(id);
|
||||||
|
|
||||||
ConstructEntity(entity, player->GetSystemAddress());
|
ConstructEntity(entity, player->GetSystemAddress());
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "Singleton.h"
|
|
||||||
#include "dCommonVars.h"
|
#include "dCommonVars.h"
|
||||||
#include "LDFFormat.h"
|
#include "LDFFormat.h"
|
||||||
|
|
||||||
|
279
dGame/Player.cpp
279
dGame/Player.cpp
@ -3,22 +3,33 @@
|
|||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
#include "Character.h"
|
#include "Character.h"
|
||||||
#include "Database.h"
|
|
||||||
#include "MissionComponent.h"
|
|
||||||
#include "UserManager.h"
|
#include "UserManager.h"
|
||||||
#include "EntityManager.h"
|
#include "EntityManager.h"
|
||||||
|
#include "Game.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "ZoneInstanceManager.h"
|
|
||||||
#include "WorldPackets.h"
|
|
||||||
#include "dZoneManager.h"
|
#include "dZoneManager.h"
|
||||||
#include "CharacterComponent.h"
|
|
||||||
#include "Mail.h"
|
|
||||||
#include "User.h"
|
#include "User.h"
|
||||||
#include "CppScripts.h"
|
#include "CppScripts.h"
|
||||||
#include "Loot.h"
|
#include "Loot.h"
|
||||||
#include "eReplicaComponentType.h"
|
#include "eReplicaComponentType.h"
|
||||||
|
#include "PlayerManager.h"
|
||||||
|
|
||||||
std::vector<Player*> Player::m_Players = {};
|
void Player::SetRespawnPos(const NiPoint3& position) {
|
||||||
|
if (!m_Character) return;
|
||||||
|
|
||||||
|
m_respawnPos = position;
|
||||||
|
|
||||||
|
m_Character->SetRespawnPoint(Game::zoneManager->GetZone()->GetWorldID(), position);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::SetRespawnRot(const NiQuaternion& rotation) {
|
||||||
|
m_respawnRot = rotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::SetSystemAddress(const SystemAddress& value) {
|
||||||
|
m_SystemAddress = value;
|
||||||
|
}
|
||||||
|
|
||||||
Player::Player(const LWOOBJID& objectID, const EntityInfo info, User* user, Entity* parentEntity) : Entity(objectID, info, parentEntity) {
|
Player::Player(const LWOOBJID& objectID, const EntityInfo info, User* user, Entity* parentEntity) : Entity(objectID, info, parentEntity) {
|
||||||
m_ParentUser = user;
|
m_ParentUser = user;
|
||||||
@ -26,263 +37,19 @@ Player::Player(const LWOOBJID& objectID, const EntityInfo info, User* user, Enti
|
|||||||
m_ParentUser->SetLoggedInChar(objectID);
|
m_ParentUser->SetLoggedInChar(objectID);
|
||||||
m_GMLevel = m_Character->GetGMLevel();
|
m_GMLevel = m_Character->GetGMLevel();
|
||||||
m_SystemAddress = m_ParentUser->GetSystemAddress();
|
m_SystemAddress = m_ParentUser->GetSystemAddress();
|
||||||
m_DroppedLoot = {};
|
|
||||||
m_DroppedCoins = 0;
|
m_DroppedCoins = 0;
|
||||||
|
|
||||||
m_GhostReferencePoint = NiPoint3::ZERO;
|
|
||||||
m_GhostOverridePoint = NiPoint3::ZERO;
|
|
||||||
m_GhostOverride = false;
|
|
||||||
m_ObservedEntitiesLength = 256;
|
|
||||||
m_ObservedEntitiesUsed = 0;
|
|
||||||
m_ObservedEntities.resize(m_ObservedEntitiesLength);
|
|
||||||
|
|
||||||
m_Character->SetEntity(this);
|
m_Character->SetEntity(this);
|
||||||
|
|
||||||
const auto& iter = std::find(m_Players.begin(), m_Players.end(), this);
|
PlayerManager::AddPlayer(this);
|
||||||
|
|
||||||
if (iter != m_Players.end()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_Players.push_back(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
User* Player::GetParentUser() const {
|
|
||||||
return m_ParentUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
SystemAddress Player::GetSystemAddress() const {
|
|
||||||
return m_SystemAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::SetSystemAddress(const SystemAddress& value) {
|
|
||||||
m_SystemAddress = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::SetRespawnPos(const NiPoint3 position) {
|
|
||||||
if (!m_Character) return;
|
|
||||||
|
|
||||||
m_respawnPos = position;
|
|
||||||
|
|
||||||
m_Character->SetRespawnPoint(Game::zoneManager->GetZone()->GetWorldID(), position);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::SetRespawnRot(const NiQuaternion rotation) {
|
|
||||||
m_respawnRot = rotation;
|
|
||||||
}
|
|
||||||
|
|
||||||
NiPoint3 Player::GetRespawnPosition() const {
|
|
||||||
return m_respawnPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
NiQuaternion Player::GetRespawnRotation() const {
|
|
||||||
return m_respawnRot;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::SendMail(const LWOOBJID sender, const std::string& senderName, const std::string& subject, const std::string& body, LOT attachment, uint16_t attachmentCount) const {
|
|
||||||
Mail::SendMail(sender, senderName, this, subject, body, attachment, attachmentCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::SendToZone(LWOMAPID zoneId, LWOCLONEID cloneId) {
|
|
||||||
const auto objid = GetObjectID();
|
|
||||||
|
|
||||||
ZoneInstanceManager::Instance()->RequestZoneTransfer(Game::server, zoneId, cloneId, false, [objid](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string serverIP, uint16_t serverPort) {
|
|
||||||
auto* entity = Game::entityManager->GetEntity(objid);
|
|
||||||
|
|
||||||
if (entity == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto sysAddr = entity->GetSystemAddress();
|
|
||||||
|
|
||||||
auto* character = entity->GetCharacter();
|
|
||||||
auto* characterComponent = entity->GetComponent<CharacterComponent>();
|
|
||||||
|
|
||||||
if (character != nullptr && characterComponent != nullptr) {
|
|
||||||
character->SetZoneID(zoneID);
|
|
||||||
character->SetZoneInstance(zoneInstance);
|
|
||||||
character->SetZoneClone(zoneClone);
|
|
||||||
|
|
||||||
characterComponent->SetLastRocketConfig(u"");
|
|
||||||
|
|
||||||
character->SaveXMLToDatabase();
|
|
||||||
}
|
|
||||||
|
|
||||||
WorldPackets::SendTransferToWorld(sysAddr, serverIP, serverPort, mythranShift);
|
|
||||||
|
|
||||||
Game::entityManager->DestructEntity(entity);
|
|
||||||
return;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::AddLimboConstruction(LWOOBJID objectId) {
|
|
||||||
const auto& iter = std::find(m_LimboConstructions.begin(), m_LimboConstructions.end(), objectId);
|
|
||||||
|
|
||||||
if (iter != m_LimboConstructions.end()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_LimboConstructions.push_back(objectId);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::RemoveLimboConstruction(LWOOBJID objectId) {
|
|
||||||
const auto& iter = std::find(m_LimboConstructions.begin(), m_LimboConstructions.end(), objectId);
|
|
||||||
|
|
||||||
if (iter == m_LimboConstructions.end()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_LimboConstructions.erase(iter);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::ConstructLimboEntities() {
|
|
||||||
for (const auto objectId : m_LimboConstructions) {
|
|
||||||
auto* entity = Game::entityManager->GetEntity(objectId);
|
|
||||||
|
|
||||||
if (entity == nullptr) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Game::entityManager->ConstructEntity(entity, m_SystemAddress);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_LimboConstructions.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::map<LWOOBJID, Loot::Info>& Player::GetDroppedLoot() {
|
|
||||||
return m_DroppedLoot;
|
|
||||||
}
|
|
||||||
|
|
||||||
const NiPoint3& Player::GetGhostReferencePoint() const {
|
|
||||||
return m_GhostOverride ? m_GhostOverridePoint : m_GhostReferencePoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
const NiPoint3& Player::GetOriginGhostReferencePoint() const {
|
|
||||||
return m_GhostReferencePoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::SetGhostReferencePoint(const NiPoint3& value) {
|
|
||||||
m_GhostReferencePoint = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::SetGhostOverridePoint(const NiPoint3& value) {
|
|
||||||
m_GhostOverridePoint = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
const NiPoint3& Player::GetGhostOverridePoint() const {
|
|
||||||
return m_GhostOverridePoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::SetGhostOverride(bool value) {
|
|
||||||
m_GhostOverride = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Player::GetGhostOverride() const {
|
|
||||||
return m_GhostOverride;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::ObserveEntity(int32_t id) {
|
|
||||||
for (int32_t i = 0; i < m_ObservedEntitiesUsed; i++) {
|
|
||||||
if (m_ObservedEntities[i] == 0 || m_ObservedEntities[i] == id) {
|
|
||||||
m_ObservedEntities[i] = id;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto index = m_ObservedEntitiesUsed++;
|
|
||||||
|
|
||||||
if (m_ObservedEntitiesUsed > m_ObservedEntitiesLength) {
|
|
||||||
m_ObservedEntities.resize(m_ObservedEntitiesLength + m_ObservedEntitiesLength);
|
|
||||||
|
|
||||||
m_ObservedEntitiesLength = m_ObservedEntitiesLength + m_ObservedEntitiesLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_ObservedEntities[index] = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Player::IsObserved(int32_t id) {
|
|
||||||
for (int32_t i = 0; i < m_ObservedEntitiesUsed; i++) {
|
|
||||||
if (m_ObservedEntities[i] == id) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::GhostEntity(int32_t id) {
|
|
||||||
for (int32_t i = 0; i < m_ObservedEntitiesUsed; i++) {
|
|
||||||
if (m_ObservedEntities[i] == id) {
|
|
||||||
m_ObservedEntities[i] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Player* Player::GetPlayer(const SystemAddress& sysAddr) {
|
|
||||||
auto* entity = UserManager::Instance()->GetUser(sysAddr)->GetLastUsedChar()->GetEntity();
|
|
||||||
|
|
||||||
return static_cast<Player*>(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
Player* Player::GetPlayer(const std::string& name) {
|
|
||||||
const auto characters = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::CHARACTER);
|
|
||||||
|
|
||||||
for (auto* character : characters) {
|
|
||||||
if (!character->IsPlayer()) continue;
|
|
||||||
|
|
||||||
if (GeneralUtils::CaseInsensitiveStringCompare(name, character->GetCharacter()->GetName())) {
|
|
||||||
return dynamic_cast<Player*>(character);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player* Player::GetPlayer(LWOOBJID playerID) {
|
|
||||||
for (auto* player : m_Players) {
|
|
||||||
if (player->GetObjectID() == playerID) {
|
|
||||||
return player;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::vector<Player*>& Player::GetAllPlayers() {
|
|
||||||
return m_Players;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t Player::GetDroppedCoins() {
|
|
||||||
return m_DroppedCoins;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::SetDroppedCoins(uint64_t value) {
|
|
||||||
m_DroppedCoins = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Player::~Player() {
|
Player::~Player() {
|
||||||
LOG("Deleted player");
|
LOG("Deleted player");
|
||||||
|
|
||||||
for (int32_t i = 0; i < m_ObservedEntitiesUsed; i++) {
|
// Make sure the player exists first. Remove afterwards to prevent the OnPlayerExist functions from not being able to find the player.
|
||||||
const auto id = m_ObservedEntities[i];
|
if (!PlayerManager::RemovePlayer(this)) {
|
||||||
|
LOG("Unable to find player to remove from manager.");
|
||||||
if (id == 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto* entity = Game::entityManager->GetGhostCandidate(id);
|
|
||||||
|
|
||||||
if (entity != nullptr) {
|
|
||||||
entity->SetObservers(entity->GetObservers() - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_LimboConstructions.clear();
|
|
||||||
|
|
||||||
const auto& iter = std::find(m_Players.begin(), m_Players.end(), this);
|
|
||||||
|
|
||||||
if (iter == m_Players.end()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,6 +68,4 @@ Player::~Player() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Players.erase(iter);
|
|
||||||
}
|
}
|
||||||
|
@ -18,92 +18,34 @@ public:
|
|||||||
* Getters
|
* Getters
|
||||||
*/
|
*/
|
||||||
|
|
||||||
User* GetParentUser() const override;
|
User* GetParentUser() const override { return m_ParentUser; };
|
||||||
|
|
||||||
SystemAddress GetSystemAddress() const override;
|
const SystemAddress& GetSystemAddress() const override { return m_SystemAddress; };
|
||||||
|
|
||||||
NiPoint3 GetRespawnPosition() const override;
|
const NiPoint3& GetRespawnPosition() const override { return m_respawnPos; };
|
||||||
|
|
||||||
NiQuaternion GetRespawnRotation() const override;
|
const NiQuaternion& GetRespawnRotation() const override { return m_respawnRot; };
|
||||||
|
|
||||||
const NiPoint3& GetGhostReferencePoint() const;
|
std::map<LWOOBJID, Loot::Info>& GetDroppedLoot() { return m_DroppedLoot; };
|
||||||
|
|
||||||
const NiPoint3& GetOriginGhostReferencePoint() const;
|
uint64_t GetDroppedCoins() const { return m_DroppedCoins; };
|
||||||
|
|
||||||
const NiPoint3& GetGhostOverridePoint() const;
|
|
||||||
|
|
||||||
bool GetGhostOverride() const;
|
|
||||||
|
|
||||||
std::map<LWOOBJID, Loot::Info>& GetDroppedLoot();
|
|
||||||
|
|
||||||
uint64_t GetDroppedCoins();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setters
|
* Setters
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
void SetDroppedCoins(const uint64_t value) { m_DroppedCoins = value; };
|
||||||
|
|
||||||
void SetSystemAddress(const SystemAddress& value) override;
|
void SetSystemAddress(const SystemAddress& value) override;
|
||||||
|
|
||||||
void SetRespawnPos(NiPoint3 position) override;
|
void SetRespawnPos(const NiPoint3& position) override;
|
||||||
|
|
||||||
void SetRespawnRot(NiQuaternion rotation) override;
|
void SetRespawnRot(const NiQuaternion& rotation) override;
|
||||||
|
|
||||||
void SetGhostReferencePoint(const NiPoint3& value);
|
|
||||||
|
|
||||||
void SetGhostOverridePoint(const NiPoint3& value);
|
|
||||||
|
|
||||||
void SetGhostOverride(bool value);
|
|
||||||
|
|
||||||
void SetDroppedCoins(uint64_t value);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wrapper for sending an in-game mail.
|
|
||||||
*
|
|
||||||
* @param sender id of the sender. LWOOBJID_EMPTY for system mail
|
|
||||||
* @param senderName name of the sender. Max 32 characters.
|
|
||||||
* @param subject mail subject. Max 50 characters.
|
|
||||||
* @param body mail body. Max 400 characters.
|
|
||||||
* @param attachment LOT of the attached item. LOT_NULL if no attachment.
|
|
||||||
* @param attachmentCount stack size for attachment.
|
|
||||||
*/
|
|
||||||
void SendMail(LWOOBJID sender, const std::string& senderName, const std::string& subject, const std::string& body, LOT attachment, uint16_t attachmentCount) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wrapper for transfering the player to another instance.
|
|
||||||
*
|
|
||||||
* @param zoneId zoneID for the new instance.
|
|
||||||
* @param cloneId cloneID for the new instance.
|
|
||||||
*/
|
|
||||||
void SendToZone(LWOMAPID zoneId, LWOCLONEID cloneId = 0);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ghosting
|
* Ghosting
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void AddLimboConstruction(LWOOBJID objectId);
|
|
||||||
|
|
||||||
void RemoveLimboConstruction(LWOOBJID objectId);
|
|
||||||
|
|
||||||
void ConstructLimboEntities();
|
|
||||||
|
|
||||||
void ObserveEntity(int32_t id);
|
|
||||||
|
|
||||||
bool IsObserved(int32_t id);
|
|
||||||
|
|
||||||
void GhostEntity(int32_t id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Static methods
|
|
||||||
*/
|
|
||||||
|
|
||||||
static Player* GetPlayer(const SystemAddress& sysAddr);
|
|
||||||
|
|
||||||
static Player* GetPlayer(const std::string& name);
|
|
||||||
|
|
||||||
static Player* GetPlayer(LWOOBJID playerID);
|
|
||||||
|
|
||||||
static const std::vector<Player*>& GetAllPlayers();
|
|
||||||
|
|
||||||
~Player() override;
|
~Player() override;
|
||||||
private:
|
private:
|
||||||
SystemAddress m_SystemAddress;
|
SystemAddress m_SystemAddress;
|
||||||
@ -114,23 +56,7 @@ private:
|
|||||||
|
|
||||||
User* m_ParentUser;
|
User* m_ParentUser;
|
||||||
|
|
||||||
NiPoint3 m_GhostReferencePoint;
|
|
||||||
|
|
||||||
NiPoint3 m_GhostOverridePoint;
|
|
||||||
|
|
||||||
bool m_GhostOverride;
|
|
||||||
|
|
||||||
std::vector<int32_t> m_ObservedEntities;
|
|
||||||
|
|
||||||
int32_t m_ObservedEntitiesLength;
|
|
||||||
|
|
||||||
int32_t m_ObservedEntitiesUsed;
|
|
||||||
|
|
||||||
std::vector<LWOOBJID> m_LimboConstructions;
|
|
||||||
|
|
||||||
std::map<LWOOBJID, Loot::Info> m_DroppedLoot;
|
std::map<LWOOBJID, Loot::Info> m_DroppedLoot;
|
||||||
|
|
||||||
uint64_t m_DroppedCoins;
|
uint64_t m_DroppedCoins;
|
||||||
|
|
||||||
static std::vector<Player*> m_Players;
|
|
||||||
};
|
};
|
||||||
|
68
dGame/PlayerManager.cpp
Normal file
68
dGame/PlayerManager.cpp
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
#include "PlayerManager.h"
|
||||||
|
|
||||||
|
#include "Character.h"
|
||||||
|
#include "Player.h"
|
||||||
|
#include "User.h"
|
||||||
|
#include "UserManager.h"
|
||||||
|
#include "eReplicaComponentType.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
std::vector<Player*> m_Players;
|
||||||
|
};
|
||||||
|
|
||||||
|
const std::vector<Player*>& PlayerManager::GetAllPlayers() {
|
||||||
|
return m_Players;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PlayerManager::AddPlayer(Player* player) {
|
||||||
|
const auto& iter = std::find(m_Players.begin(), m_Players.end(), player);
|
||||||
|
|
||||||
|
if (iter == m_Players.end()) {
|
||||||
|
m_Players.push_back(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PlayerManager::RemovePlayer(Player* player) {
|
||||||
|
const auto iter = std::find(m_Players.begin(), m_Players.end(), player);
|
||||||
|
|
||||||
|
const bool toReturn = iter != m_Players.end();
|
||||||
|
if (toReturn) {
|
||||||
|
m_Players.erase(iter);
|
||||||
|
}
|
||||||
|
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player* PlayerManager::GetPlayer(const SystemAddress& sysAddr) {
|
||||||
|
auto* entity = UserManager::Instance()->GetUser(sysAddr)->GetLastUsedChar()->GetEntity();
|
||||||
|
|
||||||
|
return static_cast<Player*>(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
Player* PlayerManager::GetPlayer(const std::string& name) {
|
||||||
|
const auto characters = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::CHARACTER);
|
||||||
|
|
||||||
|
Player* player = nullptr;
|
||||||
|
for (auto* character : characters) {
|
||||||
|
if (!character->IsPlayer()) continue;
|
||||||
|
|
||||||
|
if (GeneralUtils::CaseInsensitiveStringCompare(name, character->GetCharacter()->GetName())) {
|
||||||
|
player = dynamic_cast<Player*>(character);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player* PlayerManager::GetPlayer(LWOOBJID playerID) {
|
||||||
|
Player* playerToReturn = nullptr;
|
||||||
|
for (auto* player : m_Players) {
|
||||||
|
if (player->GetObjectID() == playerID) {
|
||||||
|
playerToReturn = player;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return playerToReturn;
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user