Skip to content

Commit

Permalink
Merge branch 'DarkflameUniverse:main' into PetFixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jadebenn authored Jan 5, 2024
2 parents 384083e + 2804dc3 commit 0f365e0
Show file tree
Hide file tree
Showing 55 changed files with 259 additions and 337 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ set(INCLUDED_DIRECTORIES
"thirdparty/recastnavigation"
"thirdparty/SQLite"
"thirdparty/cpplinq"
"thirdparty/cpp-httplib"

"tests"
"tests/dCommonTests"
Expand Down
13 changes: 8 additions & 5 deletions dAuthServer/AuthServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

//RakNet includes:
#include "RakNetDefines.h"
#include <MessageIdentifiers.h>
#include "MessageIdentifiers.h"

//Auth includes:
#include "AuthPackets.h"
Expand Down Expand Up @@ -83,12 +83,15 @@ int main(int argc, char** argv) {
Game::randomEngine = std::mt19937(time(0));

//It's safe to pass 'localhost' here, as the IP is only used as the external IP.
uint32_t maxClients = 50;
uint32_t maxClients = 999;
uint32_t ourPort = 1001; //LU client is hardcoded to use this for auth port, so I'm making it the default.
if (Game::config->GetValue("max_clients") != "") maxClients = std::stoi(Game::config->GetValue("max_clients"));
if (Game::config->GetValue("auth_server_port") != "") ourPort = std::atoi(Game::config->GetValue("auth_server_port").c_str());
std::string ourIP = "localhost";
GeneralUtils::TryParse(Game::config->GetValue("max_clients"), maxClients);
GeneralUtils::TryParse(Game::config->GetValue("auth_server_port"), ourPort);
const auto externalIPString = Game::config->GetValue("external_ip");
if (!externalIPString.empty()) ourIP = externalIPString;

Game::server = new dServer(Game::config->GetValue("external_ip"), ourPort, 0, maxClients, false, true, Game::logger, masterIP, masterPort, ServerType::Auth, Game::config, &Game::lastSignal);
Game::server = new dServer(ourIP, ourPort, 0, maxClients, false, true, Game::logger, masterIP, masterPort, ServerType::Auth, Game::config, &Game::lastSignal);

//Run it until server gets a kill message from Master:
auto t = std::chrono::high_resolution_clock::now();
Expand Down
17 changes: 11 additions & 6 deletions dChatServer/ChatServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

//RakNet includes:
#include "RakNetDefines.h"
#include <MessageIdentifiers.h>
#include "MessageIdentifiers.h"

namespace Game {
Logger* logger = nullptr;
Expand Down Expand Up @@ -99,14 +99,19 @@ int main(int argc, char** argv) {
masterPort = masterInfo->port;
}
//It's safe to pass 'localhost' here, as the IP is only used as the external IP.
uint32_t maxClients = 50;
uint32_t maxClients = 999;
uint32_t ourPort = 1501;
if (Game::config->GetValue("max_clients") != "") maxClients = std::stoi(Game::config->GetValue("max_clients"));
if (Game::config->GetValue("chat_server_port") != "") ourPort = std::atoi(Game::config->GetValue("chat_server_port").c_str());
std::string ourIP = "localhost";
GeneralUtils::TryParse(Game::config->GetValue("max_clients"), maxClients);
GeneralUtils::TryParse(Game::config->GetValue("chat_server_port"), ourPort);
const auto externalIPString = Game::config->GetValue("external_ip");
if (!externalIPString.empty()) ourIP = externalIPString;

Game::server = new dServer(Game::config->GetValue("external_ip"), ourPort, 0, maxClients, false, true, Game::logger, masterIP, masterPort, ServerType::Chat, Game::config, &Game::lastSignal);
Game::server = new dServer(ourIP, ourPort, 0, maxClients, false, true, Game::logger, masterIP, masterPort, ServerType::Chat, Game::config, &Game::lastSignal);

Game::chatFilter = new dChatFilter(Game::assetManager->GetResPath().string() + "/chatplus_en_us", bool(std::stoi(Game::config->GetValue("dont_generate_dcf"))));
bool dontGenerateDCF = false;
GeneralUtils::TryParse(Game::config->GetValue("dont_generate_dcf"), dontGenerateDCF);
Game::chatFilter = new dChatFilter(Game::assetManager->GetResPath().string() + "/chatplus_en_us", dontGenerateDCF);

Game::randomEngine = std::mt19937(time(0));

Expand Down
2 changes: 1 addition & 1 deletion dCommon/AmfSerialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "Amf3.h"

// RakNet
#include <BitStream.h>
#include "BitStream.h"

/*!
\file AmfSerialize.h
Expand Down
2 changes: 1 addition & 1 deletion dCommon/GeneralUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <functional>
#include <type_traits>
#include <stdexcept>
#include <BitStream.h>
#include "BitStream.h"
#include "NiPoint3.h"

#include "Game.h"
Expand Down
2 changes: 1 addition & 1 deletion dCommon/ZCompression.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "ZCompression.h"

#include <zlib.h>
#include "zlib.h"

namespace ZCompression {
int32_t GetMaxCompressedLength(int32_t nLenSrc) {
Expand Down
2 changes: 1 addition & 1 deletion dCommon/dClient/AssetManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "Game.h"
#include "Logger.h"

#include <zlib.h>
#include "zlib.h"

AssetManager::AssetManager(const std::filesystem::path& path) {
if (!std::filesystem::is_directory(path)) {
Expand Down
2 changes: 1 addition & 1 deletion dGame/Character.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "dCommonVars.h"
#include <vector>
#include "../thirdparty/tinyxml2/tinyxml2.h"
#include "tinyxml2.h"
#include <unordered_map>
#include <map>

Expand Down
2 changes: 1 addition & 1 deletion dGame/Entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "CDClientManager.h"
#include "Game.h"
#include "Logger.h"
#include <PacketUtils.h>
#include "PacketUtils.h"
#include <functional>
#include "CDDestructibleComponentTable.h"
#include "CDClientDatabase.h"
Expand Down
4 changes: 2 additions & 2 deletions dGame/EntityManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "RakNetTypes.h"
#include "Game.h"
#include "User.h"
#include "../dWorldServer/ObjectIDManager.h"
#include "ObjectIDManager.h"
#include "Character.h"
#include "GeneralUtils.h"
#include "dServer.h"
Expand Down Expand Up @@ -89,7 +89,7 @@ Entity* EntityManager::CreateEntity(EntityInfo info, User* user, Entity* parentE

// Entities with no ID already set, often spawned entities, we'll generate a new sequencial ID
if (info.id == 0) {
id = ObjectIDManager::Instance()->GenerateObjectID();
id = ObjectIDManager::GenerateObjectID();
}

// Entities with an ID already set, often level entities, we'll use that ID as a base
Expand Down
4 changes: 2 additions & 2 deletions dGame/TradingManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "EntityManager.h"
#include "GameMessages.h"
#include "InventoryComponent.h"
#include "../dWorldServer/ObjectIDManager.h"
#include "ObjectIDManager.h"
#include "Game.h"
#include "Logger.h"
#include "Item.h"
Expand Down Expand Up @@ -273,7 +273,7 @@ void TradingManager::CancelTrade(LWOOBJID tradeId) {
}

Trade* TradingManager::NewTrade(LWOOBJID participantA, LWOOBJID participantB) {
const LWOOBJID tradeId = ObjectIDManager::Instance()->GenerateObjectID();
const LWOOBJID tradeId = ObjectIDManager::GenerateObjectID();

auto* trade = new Trade(tradeId, participantA, participantB);

Expand Down
2 changes: 1 addition & 1 deletion dGame/User.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <string>
#include <vector>
#include "../thirdparty/raknet/Source/RakNetTypes.h"
#include "RakNetTypes.h"
#include "dCommonVars.h"

#include <unordered_map>
Expand Down
8 changes: 4 additions & 4 deletions dGame/UserManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
#include "Game.h"
#include "Logger.h"
#include "User.h"
#include <WorldPackets.h>
#include "WorldPackets.h"
#include "Character.h"
#include <BitStream.h>
#include "BitStream.h"
#include "PacketUtils.h"
#include "../dWorldServer/ObjectIDManager.h"
#include "ObjectIDManager.h"
#include "Logger.h"
#include "GeneralUtils.h"
#include "ZoneInstanceManager.h"
Expand Down Expand Up @@ -263,7 +263,7 @@ void UserManager::CreateCharacter(const SystemAddress& sysAddr, Packet* packet)
}

//Now that the name is ok, we can get an objectID from Master:
ObjectIDManager::Instance()->RequestPersistentID([=, this](uint32_t objectID) {
ObjectIDManager::RequestPersistentID([=, this](uint32_t objectID) {
if (Database::Get()->GetCharacterInfo(objectID)) {
LOG("Character object id unavailable, check object_id_tracker!");
WorldPackets::SendCharacterCreationResponse(sysAddr, eCharacterCreationResponse::OBJECT_ID_UNAVAILABLE);
Expand Down
4 changes: 2 additions & 2 deletions dGame/dBehaviors/ProjectileAttackBehavior.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "Game.h"
#include "Logger.h"
#include "SkillComponent.h"
#include "../dWorldServer/ObjectIDManager.h"
#include "ObjectIDManager.h"
#include "eObjectBits.h"

void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
Expand Down Expand Up @@ -106,7 +106,7 @@ void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitSt
const auto maxTime = this->m_maxDistance / this->m_projectileSpeed;

for (auto i = 0u; i < this->m_projectileCount; ++i) {
auto id = static_cast<LWOOBJID>(ObjectIDManager::Instance()->GenerateObjectID());
auto id = static_cast<LWOOBJID>(ObjectIDManager::GenerateObjectID());

GeneralUtils::SetBit(id, eObjectBits::SPAWNED);

Expand Down
2 changes: 1 addition & 1 deletion dGame/dComponents/ActivityComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "ZoneInstanceManager.h"
#include "Game.h"
#include "Logger.h"
#include <WorldPackets.h>
#include "WorldPackets.h"
#include "EntityManager.h"
#include "ChatPackets.h"
#include "Player.h"
Expand Down
2 changes: 1 addition & 1 deletion dGame/dComponents/BaseCombatAIComponent.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "BaseCombatAIComponent.h"
#include <BitStream.h>
#include "BitStream.h"

#include "Entity.h"
#include "EntityManager.h"
Expand Down
2 changes: 1 addition & 1 deletion dGame/dComponents/BouncerComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "Game.h"
#include "Logger.h"
#include "GameMessages.h"
#include <BitStream.h>
#include "BitStream.h"
#include "eTriggerEventType.h"

BouncerComponent::BouncerComponent(Entity* parent) : Component(parent) {
Expand Down
2 changes: 1 addition & 1 deletion dGame/dComponents/BuffComponent.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "BuffComponent.h"
#include <BitStream.h>
#include "BitStream.h"
#include "CDClientDatabase.h"
#include <stdexcept>
#include "DestroyableComponent.h"
Expand Down
2 changes: 1 addition & 1 deletion dGame/dComponents/CharacterComponent.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "CharacterComponent.h"
#include <BitStream.h>
#include "BitStream.h"
#include "tinyxml2.h"
#include "Game.h"
#include "Logger.h"
Expand Down
2 changes: 1 addition & 1 deletion dGame/dComponents/Component.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "../thirdparty/tinyxml2/tinyxml2.h"
#include "tinyxml2.h"

class Entity;

Expand Down
2 changes: 1 addition & 1 deletion dGame/dComponents/DestroyableComponent.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "DestroyableComponent.h"
#include <BitStream.h>
#include "BitStream.h"
#include "Logger.h"
#include "Game.h"
#include "dConfig.h"
Expand Down
8 changes: 4 additions & 4 deletions dGame/dComponents/InventoryComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "Game.h"
#include "Logger.h"
#include "CDClientManager.h"
#include "../dWorldServer/ObjectIDManager.h"
#include "ObjectIDManager.h"
#include "MissionComponent.h"
#include "GameMessages.h"
#include "SkillComponent.h"
Expand Down Expand Up @@ -68,7 +68,7 @@ InventoryComponent::InventoryComponent(Entity* parent, tinyxml2::XMLDocument* do
continue;
}

const LWOOBJID id = ObjectIDManager::Instance()->GenerateObjectID();
const LWOOBJID id = ObjectIDManager::GenerateObjectID();

const auto& info = Inventory::FindItemComponent(item.itemid);

Expand All @@ -86,7 +86,7 @@ InventoryComponent::InventoryComponent(Entity* parent, tinyxml2::XMLDocument* do
const auto proxyLOT = static_cast<LOT>(std::stoi(proxyLotAsString));

const auto& proxyInfo = Inventory::FindItemComponent(proxyLOT);
const LWOOBJID proxyId = ObjectIDManager::Instance()->GenerateObjectID();
const LWOOBJID proxyId = ObjectIDManager::GenerateObjectID();

// Use item.count since we equip item.count number of the item this is a requested proxy of
UpdateSlot(proxyInfo.equipLocation, { proxyId, proxyLOT, item.count, slot++ });
Expand Down Expand Up @@ -1341,7 +1341,7 @@ void InventoryComponent::SetNPCItems(const std::vector<LOT>& items) {
auto slot = 0u;

for (const auto& item : items) {
const LWOOBJID id = ObjectIDManager::Instance()->GenerateObjectID();
const LWOOBJID id = ObjectIDManager::GenerateObjectID();

const auto& info = Inventory::FindItemComponent(item);

Expand Down
4 changes: 2 additions & 2 deletions dGame/dComponents/PetComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "DestroyableComponent.h"
#include "dpWorld.h"
#include "PetDigServer.h"
#include "../dWorldServer/ObjectIDManager.h"
#include "ObjectIDManager.h"
#include "eUnequippableActiveType.h"
#include "eTerminateType.h"
#include "ePetTamingNotifyType.h"
Expand Down Expand Up @@ -460,7 +460,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) {
auto* inventoryComponent = tamer->GetComponent<InventoryComponent>();
if (!inventoryComponent) return;

LWOOBJID petSubKey = ObjectIDManager::Instance()->GenerateRandomObjectID();
LWOOBJID petSubKey = ObjectIDManager::GenerateRandomObjectID();

GeneralUtils::SetBit(petSubKey, eObjectBits::CHARACTER);
GeneralUtils::SetBit(petSubKey, eObjectBits::PERSISTENT);
Expand Down
2 changes: 1 addition & 1 deletion dGame/dComponents/PropertyEntranceComponent.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "PropertyEntranceComponent.h"

#include <CDPropertyEntranceComponentTable.h>
#include "CDPropertyEntranceComponentTable.h"

#include "Character.h"
#include "Database.h"
Expand Down
4 changes: 2 additions & 2 deletions dGame/dComponents/PropertyManagementComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "Game.h"
#include "Item.h"
#include "Database.h"
#include "../dWorldServer/ObjectIDManager.h"
#include "ObjectIDManager.h"
#include "Player.h"
#include "RocketLaunchpadControlComponent.h"
#include "PropertyEntranceComponent.h"
Expand Down Expand Up @@ -334,7 +334,7 @@ void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const N
node->position = position;
node->rotation = rotation;

ObjectIDManager::Instance()->RequestPersistentID([this, node, modelLOT, entity, position, rotation, originalRotation](uint32_t persistentId) {
ObjectIDManager::RequestPersistentID([this, node, modelLOT, entity, position, rotation, originalRotation](uint32_t persistentId) {
SpawnerInfo info{};

info.templateID = modelLOT;
Expand Down
2 changes: 1 addition & 1 deletion dGame/dComponents/QuickBuildComponent.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef QUICKBUILDCOMPONENT_H
#define QUICKBUILDCOMPONENT_H

#include <BitStream.h>
#include "BitStream.h"
#include <vector>
#include <string>
#include "dCommonVars.h"
Expand Down
2 changes: 1 addition & 1 deletion dGame/dComponents/RenderComponent.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef RENDERCOMPONENT_H
#define RENDERCOMPONENT_H

#include <BitStream.h>
#include "BitStream.h"
#include <vector>
#include <string>
#include <unordered_map>
Expand Down
2 changes: 1 addition & 1 deletion dGame/dGameMessages/GameMessageHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "MissionComponent.h"
#include "BitStreamUtils.h"
#include "dServer.h"
#include "../thirdparty/raknet/Source/RakNetworkFactory.h"
#include "RakNetworkFactory.h"
#include <future>
#include "User.h"
#include "UserManager.h"
Expand Down
Loading

0 comments on commit 0f365e0

Please sign in to comment.