Add deleteinven slash command

This commit is contained in:
EmosewaMC 2022-12-02 06:03:47 -08:00
parent a0310f6ffd
commit cf44028665
26 changed files with 129 additions and 33 deletions

View File

@ -13,6 +13,8 @@
#include "Game.h"
enum eInventoryType : uint32_t;
/*!
\file GeneralUtils.hpp
\brief A namespace containing general utility functions
@ -173,6 +175,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 {

View File

@ -1,26 +0,0 @@
#ifndef __DINVENTORYTYPE__H__
#define __DINVENTORYTYPE__H__
#include <cstdint>
/**
* 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!!!
};
#endif //!__DINVENTORYTYPE__H__

View 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,
BRICKINBBB,
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",
"BRICKINBBB",
"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__

View File

@ -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:

View File

@ -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) {

View File

@ -21,6 +21,7 @@
#include "EntityManager.h"
#include "SkillComponent.h"
#include "AssetManager.h"
#include "CDClientDatabase.h"
UserManager* UserManager::m_Address = nullptr;

View File

@ -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;

View File

@ -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{};

View File

@ -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) {

View File

@ -19,6 +19,7 @@
#include "ItemSetPassiveAbility.h"
#include "ItemSetPassiveAbilityID.h"
#include "PossessorComponent.h"
#include "eInventoryType.h"
class Entity;
class ItemSet;

View File

@ -9,6 +9,7 @@
#include "dpWorld.h"
#include "EntityManager.h"
#include "SimplePhysicsComponent.h"
#include "CDClientManager.h"
std::map<LOT, float> MovementAIComponent::m_PhysicsSpeedCache = {};

View File

@ -17,6 +17,7 @@
#include "Player.h"
#include "RocketLaunchpadControlComponent.h"
#include "PropertyEntranceComponent.h"
#include "InventoryComponent.h"
#include <vector>
#include "CppScripts.h"

View File

@ -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) {

View File

@ -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"

View File

@ -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"
@ -20,6 +19,8 @@ class User;
class Entity;
class NiPoint3;
enum class eUnequippableActiveType;
enum eInventoryType : uint32_t;
class Item;
namespace GameMessages {
class PropertyDataMessage;

View File

@ -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;

View File

@ -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:

View File

@ -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)) {

View File

@ -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

View File

@ -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);
}

View File

@ -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;

View File

@ -1752,6 +1752,32 @@ 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 (strcmp(args[0].c_str(), InventoryType::InventoryTypeToString(static_cast<eInventoryType>(index))) == 0) 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();
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;

View File

@ -1,5 +1,6 @@
#include "QbEnemyStunner.h"
#include "SkillComponent.h"
#include "CDClientManager.h"
#include "DestroyableComponent.h"
void QbEnemyStunner::OnRebuildComplete(Entity* self, Entity* target) {

View File

@ -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>();

View File

@ -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");

View File

@ -5,6 +5,7 @@
#include "EntityManager.h"
#include "RebuildComponent.h"
#include "SoundTriggerComponent.h"
#include "InventoryComponent.h"
#include "MissionComponent.h"
// Constants are at the bottom