mirror of
				https://github.com/DarkflameUniverse/DarkflameServer.git
				synced 2025-10-31 04:32:06 +00:00 
			
		
		
		
	Add deleteinven slash command
This commit is contained in:
		| @@ -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 { | ||||
|   | ||||
| @@ -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__ | ||||
							
								
								
									
										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, | ||||
| 	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__ | ||||
| @@ -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; | ||||
|   | ||||
| @@ -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" | ||||
|   | ||||
| @@ -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" | ||||
|   | ||||
| @@ -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; | ||||
|   | ||||
| @@ -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; | ||||
|   | ||||
| @@ -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; | ||||
|  | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 EmosewaMC
					EmosewaMC