Compare commits

..

87 Commits

Author SHA1 Message Date
David Markowitz
9655f0ee45 make include guards standards conforming
fix compile issues
2024-10-30 00:34:25 -07:00
Gie "Max" Vanommeslaeghe
bfe6900c26 Merge pull request #1639 from DarkflameUniverse/FixPetCrash
fix: nullptr crashes in PetComponent AddDrainImaginationTimer and Deactivate
2024-10-27 22:23:49 +01:00
David Markowitz
0d218fc5c7 fix: PetComponent crashing due to nullptr access
Resolves an issue where item is null but is accessed but not doing that code and instead consulting the EntityManager for a valid Entity, alongside nullifying the m_Owner objectID should the pet be destroyed and timer still exist.

Update PetComponent.cpp

Add nullptr check

Add back timer

Update PetComponent.cpp

speculative fix for a different crash

Why are we accessing something before checking if its null
2024-10-26 21:44:19 -07:00
David Markowitz
102e3556cf feat: add millisecond tracking for racing (#1615)
* add millisecond tracking

Update RacingControlComponent.cpp

* remove const ig?

* is this what you wanted
2024-10-26 22:59:50 -05:00
David Markowitz
33a8efdd22 fix slow code, add bounds checks (#1606)
Tested that players with valid names up to the usual 33 character max are still added to the player container
Tested that you can still team with <= 4 players on a team
Tested that chat server no longer crashes with a bad memberSize variable
asserted that InsertPlayer is indeed much faster now and is no longer a slow point of ChatServer
2024-10-26 22:09:32 -05:00
David Markowitz
8d54db7851 Update WorldServer.cpp (#1633) 2024-09-13 09:45:55 -07:00
David Markowitz
6213aed8e5 fix ag navmesh near burtton (#1626)
tested that pets now correctly try to activate the button instead of standing idly by.
2024-09-13 09:45:46 -07:00
wincent
d57c5101f4 Amend preconditions fix 2024-09-12 15:33:09 +02:00
wincent
6be65569de Fixed mission related preconditions 2024-09-10 12:41:38 +02:00
David Markowitz
94b9731a2b Use the correct bit field for checking whether or not to decrement progress (#1631)
Tested that the cooking mission with johnny umami now no longer allows you to lose progress by deleting items.
2024-08-11 10:26:25 -07:00
David Markowitz
aaf446fe6e feat: Add Inventory Brick and Model groups (#1587)
* Added feature grouping logic

* Add saving of brick buckets

* Add edge case check for max group count

* Use vector for storing groups

* Update InventoryComponent.cpp

* Update InventoryComponent.h

* Update InventoryComponent.h

* fix string log format

* Update GameMessages.cpp
2024-08-01 23:38:21 -07:00
Gie "Max" Vanommeslaeghe
2c70f1503c Merge pull request #1616 from DarkflameUniverse/behavior
fix: add larger behavior fields for saving
2024-07-17 22:24:52 +02:00
Gie "Max" Vanommeslaeghe
49b4748ed3 Merge pull request #1614 from DarkflameUniverse/tea
fix: move mission progression location for racing
2024-07-17 22:24:17 +02:00
Gie "Max" Vanommeslaeghe
ffeb0108d0 Merge pull request #1619 from DarkflameUniverse/shield
fix: echo skill cast down to client for some server skills
2024-07-17 22:23:21 +02:00
David Markowitz
c3f6ef5a1d feat: add admin account creation options from cli (GM level) (#1620)
* add admin account creation options from cli

* use actual gm levels

felt under delivered in previous iteration.

* Update dMasterServer/MasterServer.cpp

Co-authored-by: Daniel Seiler <me@xiphoseer.de>

---------

Co-authored-by: Daniel Seiler <me@xiphoseer.de>
2024-07-03 15:37:19 -07:00
David Markowitz
999995b2fb Merge branch 'main' into shield 2024-07-02 03:14:32 -07:00
Gie "Max" Vanommeslaeghe
84fff7c380 Merge pull request #1621 from DarkflameUniverse/EmosewaMC-patch-10
fix: compiler issue on newer gcc versions
2024-07-02 12:12:30 +02:00
David Markowitz
59c4b35479 Update Preconditions.cpp 2024-07-02 01:55:42 -07:00
David Markowitz
f2d72e7ed5 Update Preconditions.cpp 2024-06-25 21:02:40 -07:00
David Markowitz
b648b43c4d ?? 2024-06-25 20:52:46 -07:00
David Markowitz
2628470482 set shield to false, add sync for done 2024-06-18 14:24:03 -07:00
David Markowitz
f82a82f254 Create 16_big_behaviors.sql 2024-06-17 19:41:27 -07:00
Gie "Max" Vanommeslaeghe
9400ee1dc0 Merge pull request #1586 from DarkflameUniverse/property_behavior_saving
feat: Property Behavior Saving
2024-06-16 12:31:21 +02:00
David Markowitz
54b8c25754 Merge branch 'main' into tea 2024-06-12 19:20:44 -07:00
David Markowitz
b984cd6a0b Merge branch 'main' into property_behavior_saving 2024-06-12 19:17:39 -07:00
Gie "Max" Vanommeslaeghe
bcf1058759 Merge pull request #1595 from DarkflameUniverse/issue-462
fix: prevent moving items between inventories under cetain circumsances
2024-06-11 20:48:09 +02:00
David Markowitz
6ad6e930c7 move mission progression
done now as soon as you cross the finish line on the last lap instead of after you click "rewards"
2024-06-11 02:29:25 -07:00
David Markowitz
fee0238e79 fix: master not using table data, remove 2 noisy logs (#1613)
Tested with logs that queries to get soft and hard cap actually succeed now
Logs about slash command handler command registration and vanity NPC creation in mis matched worlds are now removed.
2024-06-09 15:31:57 -07:00
Wincent Holm
1454fcd003 Fix g++ 14 (#1610)
* Fix g++ 14

* Update thirdparty/CMakeLists.txt

Co-authored-by: David Markowitz <39972741+EmosewaMC@users.noreply.github.com>

---------

Co-authored-by: David Markowitz <39972741+EmosewaMC@users.noreply.github.com>
2024-06-06 04:00:44 -05:00
Gie "Max" Vanommeslaeghe
af651f0d63 Merge pull request #1608 from DarkflameUniverse/feat--spectate-command
feat: spectate command
2024-06-04 09:17:18 +02:00
ff38503597 no feedback if empty 2024-06-03 22:51:46 -05:00
3f22bf5cc0 Add an easy way to stop spectating 2024-06-03 22:44:54 -05:00
9d5d2a68ee fix gm serialization 2024-06-03 22:30:57 -05:00
1a14c29c39 add returns, lol 2024-06-03 22:29:21 -05:00
2ef45bd7ee use empty 2024-06-03 22:28:37 -05:00
b56d077892 feat: spectate command 2024-06-03 21:50:12 -05:00
David Markowitz
a54600b41e busting out the multimap ig (#1602) 2024-05-31 13:46:18 -05:00
David Markowitz
342da927f5 fix dimantling items from not the model inventory (#1605) 2024-05-30 23:53:13 -05:00
David Markowitz
01086d05c8 fix: use after free and uninitialized memory (#1603)
* fix use after free and uninitialized memory

* add if check for packet lengths

* move purge down further

Its used in the if check too...
2024-05-30 23:53:03 -05:00
Remco Hofman
cce5755366 Fix Dockerfile vanity COPY (#1604)
Corrected an unintended mistake in the COPY commands for adding the
vanity files to the Docker container, causing only the last file
contents to be added to the file '/app/vanity/*'
2024-05-27 17:46:09 -07:00
TAHuntling
e966d3a644 Chore: split VE script up (#1598)
* Testing Scripts

Testing splitting AgSpaceStuff into AgSpaceStuff and AgShipShake

* fixed inclusions

* Removed DoShake

* cleaning up

* consistent if statements

* Update dScripts/ai/AG/AgShipShake.h

Co-authored-by: David Markowitz <39972741+EmosewaMC@users.noreply.github.com>

---------

Co-authored-by: David Markowitz <39972741+EmosewaMC@users.noreply.github.com>
2024-05-27 01:24:48 -05:00
Gie "Max" Vanommeslaeghe
9328021339 Merge pull request #1600 from DarkflameUniverse/add-missing-scripts
fix: add back missing scripts from scripts refactor
2024-05-26 12:02:12 +02:00
Gie "Max" Vanommeslaeghe
d1134fdd62 Merge pull request #1601 from DarkflameUniverse/fix-using-skill-in-race
fix: players using non-car skills in a race
2024-05-26 12:01:54 +02:00
David Markowitz
efa658bc31 fix players using non-car skills in a race 2024-05-25 19:59:15 -07:00
David Markowitz
e59525d2ae Update CppScripts.cpp 2024-05-25 19:32:18 -07:00
David Markowitz
0348db72a5 fiux mission (#1596) 2024-05-25 12:24:02 -05:00
TAHuntling
debc2a96e2 Update CppScripts exclusion list (#1597) 2024-05-25 01:43:32 -07:00
86f335d64b fix type 2024-05-24 21:43:54 -05:00
8ca05241f2 fix: prevent moving items between inventories under cetain circumsances 2024-05-24 21:35:14 -05:00
David Markowitz
8ae1a8ff7c fix stale reference (#1594) 2024-05-24 09:15:30 -05:00
David Markowitz
f0960d48b2 Add more modular saving of config data for items (#1591)
* stubbing for saving item extra data

* add declaration to header

* modularize loading for all possible extra data

* move logic to Item

* remove extra map
2024-05-22 17:06:52 -07:00
David Markowitz
dc430d9758 Add reputation as a repeatable mission reward (#1590)
This reverts commit 7d1a28b492b263aba2008a5984dc0f5e7348a068.

Add stubbing for abbreviations

Reward reputation always if possible
2024-05-22 16:35:45 -07:00
TAHuntling
dea10c6d56 Client commands implementation (#1592)
* Adding Client Commands

Adding list of client commands provided to me by EmosewaMC

* Finished adding client commands
2024-05-22 08:32:24 -05:00
TAHuntling
ed00551982 feat: Help Command Pagination (#1581)
* Update SlashCommandHandler.cpp

* Update SlashCommandHandler.cpp

* Update SlashCommandHandler.cpp

* Update SlashCommandHandler.cpp

* Update SlashCommandHandler.cpp

* Update SlashCommandHandler.cpp

* Update SlashCommandHandler.cpp

* Update SlashCommandHandler.cpp

* Update SlashCommandHandler.cpp

* Update SlashCommandHandler.cpp

* Update SlashCommandHandler.cpp

* Fixed Comments

Now able to do /command help to see info for said command. Additionally this works for aliases. Fixed serialization missing from merge.

* Update SlashCommandHandler.cpp

* Update SlashCommandHandler.cpp

* Update SlashCommandHandler.cpp

* Update SlashCommandHandler.cpp

* Update SlashCommandHandler.cpp

* Update SlashCommandHandler.cpp

* Update SlashCommandHandler.cpp

* Update SlashCommandHandler.cpp
2024-05-21 20:02:07 -05:00
TAHuntling
d6cac65a8d fix: Falling Off Edge in Pet Puzzle (#1584)
* FloatFix

* game activity setting

* Update dNavMesh.cpp

---------

Co-authored-by: David Markowitz <EmosewaMC@gmail.com>
2024-05-21 20:01:44 -05:00
David Markowitz
d8f079cb1b fix mpc resetting on each world load (#1588) 2024-05-20 02:43:57 -05:00
David Markowitz
db2d4f02b5 preemptive include for windows 2024-05-18 04:16:07 -07:00
David Markowitz
00f36f3f28 missing include for windows 2024-05-18 04:15:07 -07:00
David Markowitz
a50b256689 Update IBehaviors.h 2024-05-18 03:54:09 -07:00
David Markowitz
b3548de7da debug logs and spacing 2024-05-18 03:52:36 -07:00
David Markowitz
387c37505c undo debug changes 2024-05-18 03:39:25 -07:00
David Markowitz
0c4108e730 Add loading from database
yahoo
2024-05-18 03:36:29 -07:00
David Markowitz
fd1c6ab2ea Saving actually works this time 2024-05-18 02:12:23 -07:00
David Markowitz
f2bf9a2a28 Saving to database working 2024-05-18 02:05:55 -07:00
TAHuntling
c8e0bb0db0 feat: Command Sorting (#1580)
* Update SlashCommandHandler.cpp

* Update SlashCommandHandler.cpp

* Update SlashCommandHandler.cpp

* Update SlashCommandHandler.cpp

* Update dGame/dUtilities/SlashCommandHandler.cpp

Co-authored-by: David Markowitz <39972741+EmosewaMC@users.noreply.github.com>

* Update SlashCommandHandler.cpp

* Update SlashCommandHandler.cpp

* Update SlashCommandHandler.cpp

* Update dGame/dUtilities/SlashCommandHandler.cpp

Co-authored-by: David Markowitz <39972741+EmosewaMC@users.noreply.github.com>

* Update SlashCommandHandler.cpp

* Update SlashCommandHandler.cpp

* Update dGame/dUtilities/SlashCommandHandler.cpp

Co-authored-by: David Markowitz <39972741+EmosewaMC@users.noreply.github.com>

* Update dGame/dUtilities/SlashCommandHandler.cpp

Co-authored-by: David Markowitz <39972741+EmosewaMC@users.noreply.github.com>

* Update dGame/dUtilities/SlashCommandHandler.cpp

Co-authored-by: David Markowitz <39972741+EmosewaMC@users.noreply.github.com>

* Update dGame/dUtilities/SlashCommandHandler.cpp

Co-authored-by: David Markowitz <39972741+EmosewaMC@users.noreply.github.com>

* Update dGame/dUtilities/SlashCommandHandler.cpp

Co-authored-by: David Markowitz <39972741+EmosewaMC@users.noreply.github.com>

* Update dGame/dUtilities/SlashCommandHandler.cpp

Co-authored-by: David Markowitz <39972741+EmosewaMC@users.noreply.github.com>

* Update SlashCommandHandler.cpp

* Update dGame/dUtilities/SlashCommandHandler.cpp

Co-authored-by: David Markowitz <39972741+EmosewaMC@users.noreply.github.com>

* Update SlashCommandHandler.cpp

* Update SlashCommandHandler.cpp

---------

Co-authored-by: David Markowitz <39972741+EmosewaMC@users.noreply.github.com>
2024-05-16 22:02:30 -07:00
David Markowitz
d9d262d3f1 prevent building in a folder which contains spaces (#1583) 2024-05-16 08:05:57 -05:00
TAHuntling
d0a5678290 chore: CppScripts refactor (#1579)
* Updating CppScripts

Rewrote file to use a lambda map rather than the massive if else chain. Kept the original comments alongside each of the different scripts they were by before.

* add script tests

* Update names

* More Changes to Scripts

* Update CppScripts.cpp

* Removing Unneeded Files

* Update CppScripts.cpp

* Delete tests/dGameTests/dScriptsTests/CMakeLists.txt

* Delete tests/dGameTests/dScriptsTests/dScriptsTests.cpp

* Delete tests/dGameTests/dScriptsTests/CppScriptsOld.cpp

* Delete tests/dGameTests/dScriptsTests/CppScriptsOld.h

* Update CMakeLists.txt

* finishing up

---------

Co-authored-by: David Markowitz <EmosewaMC@gmail.com>
2024-05-16 04:50:18 -05:00
David Markowitz
35321b22d9 script fixes (#1577)
fixes an issue where the sirens would not be destroyed correctly
fixes undefined behavior in buff station

ok for real this time

actual fix for mermaids

and for general death_behavior 0 skill stuff
2024-05-16 04:30:32 -05:00
David Markowitz
8837b110ab add include guards (#1569) 2024-05-16 04:30:00 -05:00
David Markowitz
09a8c99f3e fix: mail crash from underflow and document variables (#1582)
* fix mail crash and document variables

* const
2024-05-16 04:29:48 -05:00
Terrev
e3b108e00e fv race place atm (#1570) 2024-05-13 06:18:27 -05:00
David Markowitz
9f382aca42 fix: use after free in mission progression after removing item from inventory (#1567)
that method is cursed.

no longer has ub when deleting an item from the inventory
2024-05-12 07:30:03 -05:00
David Markowitz
4d1395e522 Update CheatDetection.cpp (#1559) 2024-05-10 16:20:42 -05:00
9e36510c6b chore: Bump verion to 2.3.0 (#1564)
fix versions.txt, update cmake version
2024-05-10 15:21:10 -05:00
David Markowitz
2ca61c3e57 feat: Dragonmaw (#1562)
* rigid as heck

* abstract physics creation to separate function

* loading

Update FvRacePillarDServer.cpp

consolidate abcd pillar logic

modularization

Update SimplePhysicsComponent.cpp

Update EntityManager.cpp

Update MovingPlatformComponent.cpp

still need another pass

* geiser works

* columns working finally

* consolidate logic

* constiness

* Update PhantomPhysicsComponent.cpp

* Update PhysicsComponent.cpp

* revert testing code

* add versions info

---------

Co-authored-by: Aaron Kimbre <aronwk.aaron@gmail.com>
2024-05-10 09:22:26 -05:00
07cb19cc30 chore: remove json (#1561)
we can't use it currently due to threadsafety issues, so just going to remove it until we actually need it and will re-add it as a vendored file later due to cmake issues pulling in things
2024-05-02 06:35:55 -05:00
David Markowitz
794b254fe7 remove md5 new (#1560)
tested that sqlite hash is still calculated
2024-05-02 06:35:44 -05:00
Gie "Max" Vanommeslaeghe
ab7f6f0b57 Merge pull request #1558 from DarkflameUniverse/swap-update-order
fix: out of order physics updates
2024-05-01 22:33:45 +02:00
David Markowitz
58cc569c75 fix out of order physics updates
fixes an issue where physics entities were not given a chance to be marked as sleeping, causing a initial sleeping calls to be missed and causing objects that collided with one another to not register new collisions since they were sleeping at the time the new collision fired off.

Tested that Brick Fury now corectly aggros the _first_ spawn of enemies near by to him.
Tested that the turrets in crux prime now correctly shoot the _first_ wave of enemies that spawn.
2024-04-30 23:09:35 -07:00
Daniel Seiler
35c463656d Use volume for mariadb persistence (#1555)
I initially used the bind mount because it's arguably easier to back up and move around than a volume, but turns out with https://github.com/DarkflameUniverse/NexusDashboard/issues/92 it's nothing we can recommend for Docker Desktop on WSL, which unfortunately is the primary setup newcomers will try this with. So changing the default to be a volume should address that (presumably by hosting the volume within the WSL Docker VM, as opposed to the host NTFS filesystem)
2024-04-29 22:51:13 +02:00
3801a97722 feat: add nlohmann/json lib (#1552)
* feat: add nlohmann/json lib

* remove build test off
2024-04-24 21:35:45 -05:00
jadebenn
0367c67c85 chore: move the pet minigame table loading logic out of petcomponent (#1551)
* move the pet minigame table loading logic out of petcomponent

* misc fixes

* actually, using paths is dumb here when they're already char strings. why bother? silly me.

* removed unga bunga reference-casting

* add back in puzzle not found error message

* pre-allocate unordered map and make getter const-correct

* Update dDatabase/CDClientDatabase/CDClientTables/CDTamingBuildPuzzleTable.cpp

Co-authored-by: David Markowitz <39972741+EmosewaMC@users.noreply.github.com>

---------

Co-authored-by: David Markowitz <39972741+EmosewaMC@users.noreply.github.com>
2024-04-24 10:09:15 -05:00
jadebenn
8fdc212cda chore: Convert heap allocation to optional (#1553)
* chore: Convert heap allocation to optional

* Update dGame/dComponents/PetComponent.h

Default-initialize
2024-04-24 10:09:04 -05:00
99e7349f6c feat: slashcommands for showall, findplayer, get/openhttpmoninfo, and debug world packet (#1545)
* feat: showall, findplayer, get/openhttpmoninfo

http monitor info is planned to be used later, just putting in info that i've since reverse engineered and don't want lost

Additionally add debug world packet for duture dev use

Tested all new commands and variation of command arguments

* fix missing newline at eofs

* address most feedback

* Compormise and use struct with (de)serialize

* remove httpmoninfo commands
2024-04-17 21:47:28 -05:00
jadebenn
fafe2aefad chore: Nitpicking-utils (#1549)
* nit

* GeneralUtils const-correctness and minor fixes

* use copy instead of reference for char iteration loops

* fix typo and reorganize some functions
2024-04-14 23:14:54 -07:00
David Markowitz
5049f215ba chore: Use string to access SQLite columns (#1535)
* use string to access field name

* Update DEVGMCommands.cpp

* corrected column name

* constexpr array

include <array>

Revert "constexpr array"

This reverts commit 1492e8b1773ed5fbbe767c74466ca263178ecdd4.

Revert "include <array>"

This reverts commit 2b7a67e89ad673d420f496be97f9bc51fd2d5e59.

include <array>

constexpr array

---------

Co-authored-by: jadebenn <jonahbenn@yahoo.com>
2024-04-13 23:41:51 -05:00
David Markowitz
3a6123fe36 fix console sound (#1547) 2024-04-11 10:29:49 -05:00
289 changed files with 3743 additions and 2060 deletions

View File

@@ -1,5 +1,11 @@
cmake_minimum_required(VERSION 3.25)
project(Darkflame)
# check if the path to the source directory contains a space
if("${CMAKE_SOURCE_DIR}" MATCHES " ")
message(FATAL_ERROR "The server cannot build in the path (" ${CMAKE_SOURCE_DIR} ") because it contains a space. Please move the server to a path without spaces.")
endif()
include(CTest)
set(CMAKE_CXX_STANDARD 20)

View File

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

View File

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

View File

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

View File

@@ -18,6 +18,7 @@
#include "eGameMessageType.h"
#include "StringifiedEnum.h"
#include "eGameMasterLevel.h"
#include "ChatPackets.h"
void ChatPacketHandler::HandleFriendlistRequest(Packet* packet) {
//Get from the packet which player we want to do something with:
@@ -354,6 +355,67 @@ void ChatPacketHandler::HandleGMLevelUpdate(Packet* packet) {
inStream.Read(player.gmLevel);
}
void ChatPacketHandler::HandleWho(Packet* packet) {
CINSTREAM_SKIP_HEADER;
FindPlayerRequest request;
request.Deserialize(inStream);
const auto& sender = Game::playerContainer.GetPlayerData(request.requestor);
if (!sender) return;
const auto& player = Game::playerContainer.GetPlayerData(request.playerName.GetAsString());
bool online = player;
CBITSTREAM;
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::WORLD_ROUTE_PACKET);
bitStream.Write(request.requestor);
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::WHO_RESPONSE);
bitStream.Write<uint8_t>(online);
bitStream.Write(player.zoneID.GetMapID());
bitStream.Write(player.zoneID.GetInstanceID());
bitStream.Write(player.zoneID.GetCloneID());
bitStream.Write(request.playerName);
SystemAddress sysAddr = sender.sysAddr;
SEND_PACKET;
}
void ChatPacketHandler::HandleShowAll(Packet* packet) {
CINSTREAM_SKIP_HEADER;
ShowAllRequest request;
request.Deserialize(inStream);
const auto& sender = Game::playerContainer.GetPlayerData(request.requestor);
if (!sender) return;
CBITSTREAM;
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::WORLD_ROUTE_PACKET);
bitStream.Write(request.requestor);
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::SHOW_ALL_RESPONSE);
bitStream.Write<uint8_t>(!request.displayZoneData && !request.displayIndividualPlayers);
bitStream.Write(Game::playerContainer.GetPlayerCount());
bitStream.Write(Game::playerContainer.GetSimCount());
bitStream.Write<uint8_t>(request.displayIndividualPlayers);
bitStream.Write<uint8_t>(request.displayZoneData);
if (request.displayZoneData || request.displayIndividualPlayers){
for (auto& [playerID, playerData ]: Game::playerContainer.GetAllPlayers()){
if (!playerData) continue;
bitStream.Write<uint8_t>(0); // structure packing
if (request.displayIndividualPlayers) bitStream.Write(LUWString(playerData.playerName));
if (request.displayZoneData) {
bitStream.Write(playerData.zoneID.GetMapID());
bitStream.Write(playerData.zoneID.GetInstanceID());
bitStream.Write(playerData.zoneID.GetCloneID());
}
}
}
SystemAddress sysAddr = sender.sysAddr;
SEND_PACKET;
}
// the structure the client uses to send this packet is shared in many chat messages
// that are sent to the server. Because of this, there are large gaps of unused data in chat messages
void ChatPacketHandler::HandleChatMessage(Packet* packet) {

View File

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

View File

@@ -179,6 +179,7 @@ int main(int argc, char** argv) {
}
void HandlePacket(Packet* packet) {
if (packet->length < 1) return;
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.");
} else if (packet->data[0] == ID_NEW_INCOMING_CONNECTION) {
@@ -289,7 +290,11 @@ void HandlePacket(Packet* packet) {
Game::playerContainer.RemovePlayer(packet);
break;
case eChatMessageType::WHO:
ChatPacketHandler::HandleWho(packet);
break;
case eChatMessageType::SHOW_ALL:
ChatPacketHandler::HandleShowAll(packet);
break;
case eChatMessageType::USER_CHANNEL_CHAT_MESSAGE:
case eChatMessageType::WORLD_DISCONNECT_REQUEST:
case eChatMessageType::WORLD_PROXIMITY_RESPONSE:

View File

@@ -36,19 +36,23 @@ void PlayerContainer::InsertPlayer(Packet* packet) {
data.playerID = playerId;
uint32_t len;
inStream.Read<uint32_t>(len);
if (!inStream.Read<uint32_t>(len)) return;
for (int i = 0; i < len; i++) {
char character; inStream.Read<char>(character);
data.playerName += character;
if (len > 33) {
LOG("Received a really long player name, probably a fake packet %i.", len);
return;
}
inStream.Read(data.zoneID);
inStream.Read(data.muteExpire);
inStream.Read(data.gmLevel);
data.playerName.resize(len);
inStream.ReadAlignedBytes(reinterpret_cast<unsigned char*>(data.playerName.data()), len);
if (!inStream.Read(data.zoneID)) return;
if (!inStream.Read(data.muteExpire)) return;
if (!inStream.Read(data.gmLevel)) return;
data.sysAddr = packet->systemAddress;
m_Names[data.playerID] = GeneralUtils::UTF8ToUTF16(data.playerName);
m_PlayerCount++;
LOG("Added user: %s (%llu), zone: %i", data.playerName.c_str(), data.playerID, data.zoneID.GetMapID());
@@ -87,6 +91,7 @@ void PlayerContainer::RemovePlayer(Packet* packet) {
}
}
m_PlayerCount--;
LOG("Removed user: %llu", playerID);
m_Players.erase(playerID);
@@ -120,6 +125,11 @@ void PlayerContainer::CreateTeamServer(Packet* packet) {
size_t membersSize = 0;
inStream.Read(membersSize);
if (membersSize >= 4) {
LOG("Tried to create a team with more than 4 players");
return;
}
std::vector<LWOOBJID> members;
members.reserve(membersSize);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -201,7 +201,7 @@ void OnTerminate() {
}
void MakeBacktrace() {
struct sigaction sigact;
struct sigaction sigact{};
sigact.sa_sigaction = CritErrHdlr;
sigact.sa_flags = SA_RESTART | SA_SIGINFO;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,5 @@
#ifndef __ECHATMESSAGETYPE__H__
#define __ECHATMESSAGETYPE__H__
#ifndef ECHATMESSAGETYPE_H
#define ECHATMESSAGETYPE_H
#include <cstdint>
@@ -77,4 +77,4 @@ enum class eChatMessageType :uint32_t {
CREATE_TEAM,
};
#endif //!__ECHATMESSAGETYPE__H__
#endif //!ECHATMESSAGETYPE_H

View File

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

View File

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

View File

@@ -1,5 +1,5 @@
#ifndef __ECONNECTIONTYPE__H__
#define __ECONNECTIONTYPE__H__
#ifndef ECONNECTIONTYPE_H
#define ECONNECTIONTYPE_H
enum class eConnectionType : uint16_t {
SERVER = 0,
@@ -10,4 +10,4 @@ enum class eConnectionType : uint16_t {
MASTER
};
#endif //!__ECONNECTIONTYPE__H__
#endif //!ECONNECTIONTYPE_H

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,5 @@
#ifndef __EGAMEMESSAGETYPE__H__
#define __EGAMEMESSAGETYPE__H__
#ifndef EGAMEMESSAGETYPE_H
#define EGAMEMESSAGETYPE_H
#include <cstdint>
@@ -1611,4 +1611,4 @@ struct magic_enum::customize::enum_range<eGameMessageType> {
static constexpr int max = 1772;
};
#endif //!__EGAMEMESSAGETYPE__H__
#endif //!EGAMEMESSAGETYPE_H

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,6 +1,6 @@
#ifndef __EWAYPOINTCOMMANDTYPES__H__
#define __EWAYPOINTCOMMANDTYPES__H__
#ifndef EWAYPOINTCOMMANDTYPES_H
#define EWAYPOINTCOMMANDTYPES_H
#include <cstdint>
@@ -56,4 +56,4 @@ public:
};
#endif //!__EWAYPOINTCOMMANDTYPES__H__
#endif //!EWAYPOINTCOMMANDTYPES_H

View File

@@ -1,5 +1,5 @@
#ifndef __EWORLDMESSAGETYPE__H__
#define __EWORLDMESSAGETYPE__H__
#ifndef EWORLDMESSAGETYPE_H
#define EWORLDMESSAGETYPE_H
#include <cstdint>
@@ -48,4 +48,4 @@ struct magic_enum::customize::enum_range<eWorldMessageType> {
static constexpr int max = 91;
};
#endif //!__EWORLDMESSAGETYPE__H__
#endif //!EWORLDMESSAGETYPE_H

View File

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

View File

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

View File

@@ -50,7 +50,7 @@ void CDPetComponentTable::LoadValuesFromDatabase() {
}
void CDPetComponentTable::LoadValuesFromDefaults() {
GetEntriesMutable().insert(std::make_pair(defaultEntry.id, defaultEntry));
GetEntriesMutable().emplace(defaultEntry.id, defaultEntry);
}
CDPetComponent& CDPetComponentTable::GetByID(const uint32_t componentID) {

View File

@@ -0,0 +1,35 @@
#include "CDTamingBuildPuzzleTable.h"
void CDTamingBuildPuzzleTable::LoadValuesFromDatabase() {
// First, get the size of the table
uint32_t size = 0;
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM TamingBuildPuzzles");
while (!tableSize.eof()) {
size = tableSize.getIntField(0, 0);
tableSize.nextRow();
}
// Reserve the size
auto& entries = GetEntriesMutable();
entries.reserve(size);
// Now get the data
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM TamingBuildPuzzles");
while (!tableData.eof()) {
const auto lot = static_cast<LOT>(tableData.getIntField("NPCLot", LOT_NULL));
entries.emplace(lot, CDTamingBuildPuzzle{
.puzzleModelLot = lot,
.validPieces{ tableData.getStringField("ValidPiecesLXF") },
.timeLimit = static_cast<float>(tableData.getFloatField("Timelimit", 30.0f)),
.numValidPieces = tableData.getIntField("NumValidPieces", 6),
.imaginationCost = tableData.getIntField("imagCostPerBuild", 10)
});
tableData.nextRow();
}
}
const CDTamingBuildPuzzle* CDTamingBuildPuzzleTable::GetByLOT(const LOT lot) const {
const auto& entries = GetEntries();
const auto itr = entries.find(lot);
return itr != entries.cend() ? &itr->second : nullptr;
}

View File

@@ -0,0 +1,60 @@
#pragma once
#include "CDTable.h"
/**
* Information for the minigame to be completed
*/
struct CDTamingBuildPuzzle {
UNUSED_COLUMN(uint32_t id = 0;)
// The LOT of the object that is to be created
LOT puzzleModelLot = LOT_NULL;
// The LOT of the NPC
UNUSED_COLUMN(LOT npcLot = LOT_NULL;)
// The .lxfml file that contains the bricks required to build the model
std::string validPieces{};
// The .lxfml file that contains the bricks NOT required to build the model
UNUSED_COLUMN(std::string invalidPieces{};)
// Difficulty value
UNUSED_COLUMN(int32_t difficulty = 1;)
// The time limit to complete the build
float timeLimit = 30.0f;
// The number of pieces required to complete the minigame
int32_t numValidPieces = 6;
// Number of valid pieces
UNUSED_COLUMN(int32_t totalNumPieces = 16;)
// Model name
UNUSED_COLUMN(std::string modelName{};)
// The .lxfml file that contains the full model
UNUSED_COLUMN(std::string fullModel{};)
// The duration of the pet taming minigame
UNUSED_COLUMN(float duration = 45.0f;)
// The imagination cost for the tamer to start the minigame
int32_t imaginationCost = 10;
};
class CDTamingBuildPuzzleTable : public CDTable<CDTamingBuildPuzzleTable, std::unordered_map<LOT, CDTamingBuildPuzzle>> {
public:
/**
* Load values from the CD client database
*/
void LoadValuesFromDatabase();
/**
* Gets the pet ability table corresponding to the pet LOT
* @returns A pointer to the corresponding table, or nullptr if one cannot be found
*/
[[nodiscard]]
const CDTamingBuildPuzzle* GetByLOT(const LOT lot) const;
};

View File

@@ -36,5 +36,6 @@ set(DDATABASE_CDCLIENTDATABASE_CDCLIENTTABLES_SOURCES "CDActivitiesTable.cpp"
"CDRewardsTable.cpp"
"CDScriptComponentTable.cpp"
"CDSkillBehaviorTable.cpp"
"CDTamingBuildPuzzleTable.cpp"
"CDVendorComponentTable.cpp"
"CDZoneTableTable.cpp" PARENT_SCOPE)

View File

@@ -1,5 +1,5 @@
#ifndef __GAMEDATABASE__H__
#define __GAMEDATABASE__H__
#ifndef GAMEDATABASE_H
#define GAMEDATABASE_H
#include <optional>
@@ -23,6 +23,7 @@
#include "IActivityLog.h"
#include "IIgnoreList.h"
#include "IAccountsRewardCodes.h"
#include "IBehaviors.h"
namespace sql {
class Statement;
@@ -40,7 +41,8 @@ class GameDatabase :
public IMail, public ICommandLog, public IPlayerCheatDetections, public IBugReports,
public IPropertyContents, public IProperty, public IPetNames, public ICharXml,
public IMigrationHistory, public IUgc, public IFriends, public ICharInfo,
public IAccounts, public IActivityLog, public IAccountsRewardCodes, public IIgnoreList {
public IAccounts, public IActivityLog, public IAccountsRewardCodes, public IIgnoreList,
public IBehaviors {
public:
virtual ~GameDatabase() = default;
// TODO: These should be made private.
@@ -54,4 +56,4 @@ public:
virtual void DeleteCharacter(const uint32_t characterId) = 0;
};
#endif //!__GAMEDATABASE__H__
#endif //!GAMEDATABASE_H

View File

@@ -1,5 +1,5 @@
#ifndef __IACCOUNTS__H__
#define __IACCOUNTS__H__
#ifndef IACCOUNTS_H
#define IACCOUNTS_H
#include <cstdint>
#include <optional>
@@ -33,6 +33,9 @@ public:
// Add a new account to the database.
virtual void InsertNewAccount(const std::string_view username, const std::string_view bcryptpassword) = 0;
// Update the GameMaster level of an account.
virtual void UpdateAccountGmLevel(const uint32_t accountId, const eGameMasterLevel gmLevel) = 0;
};
#endif //!__IACCOUNTS__H__
#endif //!IACCOUNTS_H

View File

@@ -1,5 +1,5 @@
#ifndef __IACCOUNTSREWARDCODES__H__
#define __IACCOUNTSREWARDCODES__H__
#ifndef IACCOUNTSREWARDCODES_H
#define IACCOUNTSREWARDCODES_H
#include <cstdint>
#include <vector>
@@ -10,4 +10,4 @@ public:
virtual std::vector<uint32_t> GetRewardCodesByAccountID(const uint32_t account_id) = 0;
};
#endif //!__IACCOUNTSREWARDCODES__H__
#endif //!IACCOUNTSREWARDCODES_H

View File

@@ -1,5 +1,5 @@
#ifndef __IACTIVITYLOG__H__
#define __IACTIVITYLOG__H__
#ifndef IACTIVITYLOG_H
#define IACTIVITYLOG_H
#include <cstdint>
@@ -16,4 +16,4 @@ public:
virtual void UpdateActivityLog(const uint32_t characterId, const eActivityType activityType, const LWOMAPID mapId) = 0;
};
#endif //!__IACTIVITYLOG__H__
#endif //!IACTIVITYLOG_H

View File

@@ -0,0 +1,22 @@
#ifndef IBEHAVIORS_H
#define IBEHAVIORS_H
#include <cstdint>
#include "dCommonVars.h"
class IBehaviors {
public:
struct Info {
int32_t behaviorId{};
uint32_t characterId{};
std::string behaviorInfo;
};
// This Add also takes care of updating if it exists.
virtual void AddBehavior(const Info& info) = 0;
virtual std::string GetBehavior(const int32_t behaviorId) = 0;
virtual void RemoveBehavior(const int32_t behaviorId) = 0;
};
#endif //!IBEHAVIORS_H

View File

@@ -1,5 +1,5 @@
#ifndef __IBUGREPORTS__H__
#define __IBUGREPORTS__H__
#ifndef IBUGREPORTS_H
#define IBUGREPORTS_H
#include <cstdint>
#include <string_view>
@@ -17,4 +17,4 @@ public:
// Add a new bug report to the database.
virtual void InsertNewBugReport(const Info& info) = 0;
};
#endif //!__IBUGREPORTS__H__
#endif //!IBUGREPORTS_H

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