mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-09 09:48:20 +00:00
Merge remote-tracking branch 'upstream/main' into MoreImprovements
This commit is contained in:
commit
9f47b1f0bb
@ -14,6 +14,8 @@
|
||||
#include "Game.h"
|
||||
#include "dLogger.h"
|
||||
|
||||
enum eInventoryType : uint32_t;
|
||||
|
||||
/*!
|
||||
\file GeneralUtils.hpp
|
||||
\brief A namespace containing general utility functions
|
||||
@ -174,6 +176,11 @@ namespace GeneralUtils {
|
||||
return std::stoull(value);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline eInventoryType Parse(const char* value) {
|
||||
return static_cast<eInventoryType>(std::stoul(value));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool TryParse(const char* value, T& dst) {
|
||||
try {
|
||||
|
@ -437,26 +437,6 @@ enum class UseItemResponse : uint32_t {
|
||||
MountsNotAllowed
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents the different types of inventories an entity may have
|
||||
*/
|
||||
enum eInventoryType : uint32_t {
|
||||
ITEMS = 0,
|
||||
VAULT_ITEMS,
|
||||
BRICKS,
|
||||
MODELS_IN_BBB,
|
||||
TEMP_ITEMS = 4,
|
||||
MODELS,
|
||||
TEMP_MODELS,
|
||||
BEHAVIORS,
|
||||
PROPERTY_DEEDS,
|
||||
VENDOR_BUYBACK = 11,
|
||||
HIDDEN = 12, //Used for missional items
|
||||
VAULT_MODELS = 14,
|
||||
ITEM_SETS, //internal
|
||||
INVALID // made up, for internal use!!!
|
||||
};
|
||||
|
||||
enum eRebuildState : uint32_t {
|
||||
REBUILD_OPEN,
|
||||
REBUILD_COMPLETED = 2,
|
||||
|
59
dCommon/dEnums/eInventoryType.h
Normal file
59
dCommon/dEnums/eInventoryType.h
Normal file
@ -0,0 +1,59 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef __EINVENTORYTYPE__H__
|
||||
#define __EINVENTORYTYPE__H__
|
||||
|
||||
#include <cstdint>
|
||||
static const uint8_t NUMBER_OF_INVENTORIES = 17;
|
||||
/**
|
||||
* Represents the different types of inventories an entity may have
|
||||
*/
|
||||
enum eInventoryType : uint32_t {
|
||||
ITEMS = 0,
|
||||
VAULT_ITEMS,
|
||||
BRICKS,
|
||||
MODELS_IN_BBB,
|
||||
TEMP_ITEMS,
|
||||
MODELS,
|
||||
TEMP_MODELS,
|
||||
BEHAVIORS,
|
||||
PROPERTY_DEEDS,
|
||||
BRICKS_IN_BBB,
|
||||
VENDOR,
|
||||
VENDOR_BUYBACK,
|
||||
QUEST, //Used for mission items
|
||||
DONATION,
|
||||
VAULT_MODELS,
|
||||
ITEM_SETS, //internal, technically this is BankBehaviors.
|
||||
INVALID // made up, for internal use!!!, Technically this called the ALL inventory.
|
||||
};
|
||||
|
||||
class InventoryType {
|
||||
public:
|
||||
static const char* InventoryTypeToString(eInventoryType inventory) {
|
||||
const char* eInventoryTypeTable[NUMBER_OF_INVENTORIES] = {
|
||||
"ITEMS",
|
||||
"VAULT_ITEMS",
|
||||
"BRICKS",
|
||||
"MODELS_IN_BBB",
|
||||
"TEMP_ITEMS",
|
||||
"MODELS",
|
||||
"TEMP_MODELS",
|
||||
"BEHAVIORS",
|
||||
"PROPERTY_DEEDS",
|
||||
"BRICKS_IN_BBB",
|
||||
"VENDOR",
|
||||
"VENDOR_BUYBACK",
|
||||
"QUEST", //Used for mission items
|
||||
"DONATION",
|
||||
"VAULT_MODELS",
|
||||
"ITEM_SETS", //internal, technically this is BankBehaviors.
|
||||
"INVALID" // made up, for internal use!!!, Technically this called the ALL inventory.
|
||||
};
|
||||
|
||||
if (inventory > NUMBER_OF_INVENTORIES - 1) return nullptr;
|
||||
return eInventoryTypeTable[inventory];
|
||||
};
|
||||
};
|
||||
|
||||
#endif //!__EINVENTORYTYPE__H__
|
@ -15,6 +15,7 @@
|
||||
#include "Zone.h"
|
||||
#include "ChatPackets.h"
|
||||
#include "Inventory.h"
|
||||
#include "InventoryComponent.h"
|
||||
|
||||
Character::Character(uint32_t id, User* parentUser) {
|
||||
//First load the name, etc:
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "GameMessages.h"
|
||||
#include "dLogger.h"
|
||||
#include "dConfig.h"
|
||||
#include "CDClientManager.h"
|
||||
|
||||
Leaderboard::Leaderboard(uint32_t gameID, uint32_t infoType, bool weekly, std::vector<LeaderboardEntry> entries,
|
||||
LWOOBJID relatedPlayer, LeaderboardType leaderboardType) {
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "EntityManager.h"
|
||||
#include "SkillComponent.h"
|
||||
#include "AssetManager.h"
|
||||
#include "CDClientDatabase.h"
|
||||
|
||||
UserManager* UserManager::m_Address = nullptr;
|
||||
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include "EntityManager.h"
|
||||
#include "SkillComponent.h"
|
||||
#include "DestroyableComponent.h"
|
||||
#include "CDClientDatabase.h"
|
||||
#include "CDClientManager.h"
|
||||
|
||||
void OverTimeBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
const auto originator = context->originator;
|
||||
|
@ -14,6 +14,7 @@ void SwitchMultipleBehavior::Handle(BehaviorContext* context, RakNet::BitStream*
|
||||
|
||||
if (!bitStream->Read(value)) {
|
||||
Game::logger->Log("SwitchMultipleBehavior", "Unable to read value from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
||||
return;
|
||||
};
|
||||
|
||||
uint32_t trigger = 0;
|
||||
|
@ -22,6 +22,7 @@ void TacArcBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre
|
||||
|
||||
if (!bitStream->Read(hit)) {
|
||||
Game::logger->Log("TacArcBehavior", "Unable to read hit from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
||||
return;
|
||||
};
|
||||
|
||||
if (this->m_checkEnv) {
|
||||
@ -29,6 +30,7 @@ void TacArcBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre
|
||||
|
||||
if (!bitStream->Read(blocked)) {
|
||||
Game::logger->Log("TacArcBehavior", "Unable to read blocked from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
||||
return;
|
||||
};
|
||||
|
||||
if (blocked) {
|
||||
@ -43,6 +45,7 @@ void TacArcBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre
|
||||
|
||||
if (!bitStream->Read(count)) {
|
||||
Game::logger->Log("TacArcBehavior", "Unable to read count from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
||||
return;
|
||||
};
|
||||
|
||||
if (count > m_maxTargets && m_maxTargets > 0) {
|
||||
@ -56,6 +59,7 @@ void TacArcBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre
|
||||
|
||||
if (!bitStream->Read(id)) {
|
||||
Game::logger->Log("TacArcBehavior", "Unable to read id from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
||||
return;
|
||||
};
|
||||
|
||||
targets.push_back(id);
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "SkillComponent.h"
|
||||
#include "ControllablePhysicsComponent.h"
|
||||
#include "EntityManager.h"
|
||||
#include "CDClientManager.h"
|
||||
|
||||
std::unordered_map<int32_t, std::vector<BuffParameter>> BuffComponent::m_Cache{};
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "CharacterComponent.h"
|
||||
#include "PossessableComponent.h"
|
||||
#include "PossessorComponent.h"
|
||||
#include "InventoryComponent.h"
|
||||
#include "dZoneManager.h"
|
||||
|
||||
DestroyableComponent::DestroyableComponent(Entity* parent) : Component(parent) {
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "ItemSetPassiveAbility.h"
|
||||
#include "ItemSetPassiveAbilityID.h"
|
||||
#include "PossessorComponent.h"
|
||||
#include "eInventoryType.h"
|
||||
|
||||
class Entity;
|
||||
class ItemSet;
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "dpWorld.h"
|
||||
#include "EntityManager.h"
|
||||
#include "SimplePhysicsComponent.h"
|
||||
#include "CDClientManager.h"
|
||||
|
||||
std::map<LOT, float> MovementAIComponent::m_PhysicsSpeedCache = {};
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "Player.h"
|
||||
#include "RocketLaunchpadControlComponent.h"
|
||||
#include "PropertyEntranceComponent.h"
|
||||
#include "InventoryComponent.h"
|
||||
|
||||
#include <vector>
|
||||
#include "CppScripts.h"
|
||||
@ -717,7 +718,7 @@ void PropertyManagementComponent::Save() {
|
||||
insertion->setDouble(9, rotation.y);
|
||||
insertion->setDouble(10, rotation.z);
|
||||
insertion->setDouble(11, rotation.w);
|
||||
insertion->setString(12, "Objects_" + std::to_string(entity->GetLOT()) + "_name"); // Model name. TODO make this customizable
|
||||
insertion->setString(12, ("Objects_" + std::to_string(entity->GetLOT()) + "_name").c_str()); // Model name. TODO make this customizable
|
||||
insertion->setString(13, ""); // Model description. TODO implement this.
|
||||
insertion->setDouble(14, 0); // behavior 1. TODO implement this.
|
||||
insertion->setDouble(15, 0); // behavior 2. TODO implement this.
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "GeneralUtils.h"
|
||||
#include "dZoneManager.h"
|
||||
#include "dConfig.h"
|
||||
#include "InventoryComponent.h"
|
||||
#include "DestroyableComponent.h"
|
||||
|
||||
ScriptedActivityComponent::ScriptedActivityComponent(Entity* parent, int activityID) : Component(parent) {
|
||||
|
@ -49,6 +49,7 @@
|
||||
#include "ScriptComponent.h"
|
||||
#include "RebuildComponent.h"
|
||||
#include "VendorComponent.h"
|
||||
#include "InventoryComponent.h"
|
||||
#include "RocketLaunchpadControlComponent.h"
|
||||
#include "PropertyEntranceComponent.h"
|
||||
#include "MovingPlatformComponent.h"
|
||||
@ -5735,16 +5736,16 @@ void GameMessages::HandleClientItemConsumed(RakNet::BitStream* inStream, Entity*
|
||||
}
|
||||
|
||||
auto* item = inventory->FindItemById(itemConsumed);
|
||||
|
||||
if (item == nullptr) {
|
||||
return;
|
||||
}
|
||||
LOT itemLot = item->GetLot();
|
||||
|
||||
item->Consume();
|
||||
|
||||
auto* missions = static_cast<MissionComponent*>(entity->GetComponent(COMPONENT_TYPE_MISSION));
|
||||
if (missions != nullptr) {
|
||||
missions->Progress(MissionTaskType::MISSION_TASK_TYPE_FOOD, item->GetLot());
|
||||
missions->Progress(MissionTaskType::MISSION_TASK_TYPE_FOOD, itemLot);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include "dCommonVars.h"
|
||||
#include "RakNetTypes.h"
|
||||
#include <string>
|
||||
#include "InventoryComponent.h"
|
||||
#include "dMessageIdentifiers.h"
|
||||
#include "AMFFormat.h"
|
||||
#include "AMFFormat_BitStream.h"
|
||||
@ -21,6 +20,8 @@ class User;
|
||||
class Entity;
|
||||
class NiPoint3;
|
||||
enum class eUnequippableActiveType;
|
||||
enum eInventoryType : uint32_t;
|
||||
class Item;
|
||||
|
||||
namespace GameMessages {
|
||||
class PropertyDataMessage;
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "GameMessages.h"
|
||||
#include "Game.h"
|
||||
#include "Item.h"
|
||||
#include "InventoryComponent.h"
|
||||
#include "eItemType.h"
|
||||
|
||||
std::vector<LOT> Inventory::m_GameMasterRestrictedItems = {
|
||||
@ -266,7 +267,7 @@ eInventoryType Inventory::FindInventoryTypeForLot(const LOT lot) {
|
||||
case eItemType::ITEM_TYPE_QUEST_OBJECT:
|
||||
case eItemType::ITEM_TYPE_UNKNOWN:
|
||||
default:
|
||||
return HIDDEN;
|
||||
return QUEST;
|
||||
}
|
||||
}
|
||||
|
||||
@ -300,6 +301,12 @@ const std::vector<LOT>& Inventory::GetAllGMItems() {
|
||||
return m_GameMasterRestrictedItems;
|
||||
}
|
||||
|
||||
void Inventory::DeleteAllItems() {
|
||||
while (!this->items.empty()) {
|
||||
if (items.begin()->second) items.begin()->second->SetCount(0);
|
||||
}
|
||||
}
|
||||
|
||||
Inventory::~Inventory() {
|
||||
for (auto item : items) {
|
||||
delete item.second;
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "CDClientManager.h"
|
||||
#include "dCommonVars.h"
|
||||
|
||||
enum eInventoryType : uint32_t;
|
||||
class Item;
|
||||
class InventoryComponent;
|
||||
|
||||
@ -152,6 +153,11 @@ public:
|
||||
*/
|
||||
static const std::vector<LOT>& GetAllGMItems();
|
||||
|
||||
/**
|
||||
* Remove ALL Items from this inventory.
|
||||
*/
|
||||
void DeleteAllItems();
|
||||
|
||||
~Inventory();
|
||||
|
||||
private:
|
||||
|
@ -14,9 +14,7 @@
|
||||
#include "CharacterComponent.h"
|
||||
#include "eItemType.h"
|
||||
#include "AssetManager.h"
|
||||
|
||||
class Inventory;
|
||||
|
||||
#include "InventoryComponent.h"
|
||||
|
||||
Item::Item(const LWOOBJID id, const LOT lot, Inventory* inventory, const uint32_t slot, const uint32_t count, const bool bound, const std::vector<LDFBaseData*>& config, const LWOOBJID parent, LWOOBJID subKey, eLootSourceType lootSourceType) {
|
||||
if (!Inventory::IsValidItem(lot)) {
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "CDClientManager.h"
|
||||
#include "dLogger.h"
|
||||
#include "Preconditions.h"
|
||||
#include "eInventoryType.h"
|
||||
|
||||
/**
|
||||
* An item that can be stored in an inventory and optionally consumed or equipped
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "dLogger.h"
|
||||
#include "dServer.h"
|
||||
#include "dZoneManager.h"
|
||||
#include "InventoryComponent.h"
|
||||
#include "Database.h"
|
||||
|
||||
Mission::Mission(MissionComponent* missionComponent, const uint32_t missionId) {
|
||||
@ -424,7 +425,7 @@ void Mission::YieldRewards() {
|
||||
for (const auto target : task->GetAllTargets()) {
|
||||
// This is how live did it. ONLY remove item collection items from the items and hidden inventories and none of the others.
|
||||
inventoryComponent->RemoveItem(target, task->GetClientInfo().targetValue, eInventoryType::ITEMS);
|
||||
inventoryComponent->RemoveItem(target, task->GetClientInfo().targetValue, eInventoryType::HIDDEN);
|
||||
inventoryComponent->RemoveItem(target, task->GetClientInfo().targetValue, eInventoryType::QUEST);
|
||||
|
||||
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_ITEM_COLLECTION, target, LWOOBJID_EMPTY, "", -task->GetClientInfo().targetValue);
|
||||
}
|
||||
|
@ -11,9 +11,9 @@
|
||||
#include "ScriptedActivityComponent.h"
|
||||
#include "GameMessages.h"
|
||||
#include "dZoneManager.h"
|
||||
#include "InventoryComponent.h"
|
||||
#include "MissionComponent.h"
|
||||
|
||||
|
||||
MissionTask::MissionTask(Mission* mission, CDMissionTasks* info, uint32_t mask) {
|
||||
this->info = info;
|
||||
this->mission = mission;
|
||||
|
@ -74,12 +74,12 @@ void Mail::SendMail(const LWOOBJID sender, const std::string& senderName, LWOOBJ
|
||||
auto* ins = Database::CreatePreppedStmt("INSERT INTO `mail`(`sender_id`, `sender_name`, `receiver_id`, `receiver_name`, `time_sent`, `subject`, `body`, `attachment_id`, `attachment_lot`, `attachment_subkey`, `attachment_count`, `was_read`) VALUES (?,?,?,?,?,?,?,?,?,?,?,0)");
|
||||
|
||||
ins->setUInt(1, sender);
|
||||
ins->setString(2, senderName);
|
||||
ins->setString(2, senderName.c_str());
|
||||
ins->setUInt(3, recipient);
|
||||
ins->setString(4, recipientName.c_str());
|
||||
ins->setUInt64(5, time(nullptr));
|
||||
ins->setString(6, subject);
|
||||
ins->setString(7, body);
|
||||
ins->setString(6, subject.c_str());
|
||||
ins->setString(7, body.c_str());
|
||||
ins->setUInt(8, 0);
|
||||
ins->setInt(9, attachment);
|
||||
ins->setInt(10, 0);
|
||||
|
@ -1803,6 +1803,33 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
ChatPackets::SendSystemMessage(sysAddr, message);
|
||||
}
|
||||
|
||||
if (chatCommand == "deleteinven" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER && args.size() >= 1) {
|
||||
eInventoryType inventoryType = eInventoryType::INVALID;
|
||||
if (!GeneralUtils::TryParse(args[0], inventoryType)) {
|
||||
// In this case, we treat the input as a string and try to find it in the reflection list
|
||||
std::transform(args[0].begin(), args[0].end(),args[0].begin(), ::toupper);
|
||||
Game::logger->Log("SlashCommandHandler", "looking for inventory %s", args[0].c_str());
|
||||
for (uint32_t index = 0; index < NUMBER_OF_INVENTORIES; index++) {
|
||||
if (std::string_view(args[0]) == std::string_view(InventoryType::InventoryTypeToString(static_cast<eInventoryType>(index)))) inventoryType = static_cast<eInventoryType>(index);
|
||||
}
|
||||
}
|
||||
|
||||
if (inventoryType == eInventoryType::INVALID || inventoryType >= NUMBER_OF_INVENTORIES) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid inventory provided.");
|
||||
return;
|
||||
}
|
||||
|
||||
auto* inventoryComponent = entity->GetComponent<InventoryComponent>();
|
||||
if (!inventoryComponent) return;
|
||||
|
||||
auto* inventoryToDelete = inventoryComponent->GetInventory(inventoryType);
|
||||
if (!inventoryToDelete) return;
|
||||
|
||||
inventoryToDelete->DeleteAllItems();
|
||||
Game::logger->Log("SlashCommandHandler", "Deleted inventory %s for user %llu", args[0].c_str(), entity->GetObjectID());
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Deleted inventory " + GeneralUtils::UTF8ToUTF16(args[0]));
|
||||
}
|
||||
|
||||
if (chatCommand == "inspect" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER && args.size() >= 1) {
|
||||
Entity* closest = nullptr;
|
||||
|
||||
|
@ -223,7 +223,7 @@ int main(int argc, char** argv) {
|
||||
//Create account
|
||||
|
||||
auto* statement = Database::CreatePreppedStmt("INSERT INTO accounts (name, password, ""gm_level) VALUES (?, ?, ?);");
|
||||
statement->setString(1, username);
|
||||
statement->setString(1, username.c_str());
|
||||
statement->setString(2, std::string(hash, BCRYPT_HASHSIZE).c_str());
|
||||
statement->setInt(3, 9);
|
||||
|
||||
|
@ -68,7 +68,7 @@ dServer::dServer(const std::string& ip, int port, int instanceID, int maxConnect
|
||||
} else { mLogger->Log("dServer", "FAILED TO START SERVER ON IP/PORT: %s:%i", ip.c_str(), port); return; }
|
||||
|
||||
mLogger->SetLogToConsole(prevLogSetting);
|
||||
|
||||
mPeer->SetMTUSize(1228); // This is hard coded by lu for some reason.
|
||||
//Connect to master if we are not master:
|
||||
if (serverType != ServerType::Master) {
|
||||
SetupForMasterConnection();
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "QbEnemyStunner.h"
|
||||
#include "SkillComponent.h"
|
||||
#include "CDClientManager.h"
|
||||
#include "DestroyableComponent.h"
|
||||
|
||||
void QbEnemyStunner::OnRebuildComplete(Entity* self, Entity* target) {
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "SkillComponent.h"
|
||||
#include "CDClientDatabase.h"
|
||||
#include "CDObjectSkillsTable.h"
|
||||
#include "CDClientManager.h"
|
||||
|
||||
void FireFirstSkillonStartup::OnStartup(Entity* self) {
|
||||
auto skillComponent = self->GetComponent<SkillComponent>();
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "MovementAIComponent.h"
|
||||
#include "../dWorldServer/ObjectIDManager.h"
|
||||
#include "MissionComponent.h"
|
||||
#include "InventoryComponent.h"
|
||||
|
||||
void SGCannon::OnStartup(Entity* self) {
|
||||
Game::logger->Log("SGCannon", "OnStartup");
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "EntityManager.h"
|
||||
#include "RebuildComponent.h"
|
||||
#include "SoundTriggerComponent.h"
|
||||
#include "InventoryComponent.h"
|
||||
#include "MissionComponent.h"
|
||||
|
||||
// Constants are at the bottom
|
||||
|
Loading…
Reference in New Issue
Block a user