mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-13 19:58:21 +00:00
Development inventory command improvements (#1022)
This commit is contained in:
parent
c3723371cf
commit
2bcf862f93
@ -552,21 +552,42 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((chatCommand == "setinventorysize" || chatCommand == "setinvsize") && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) {
|
if ((chatCommand == "setinventorysize" || chatCommand == "setinvsize") && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER && args.size() >= 1) {
|
||||||
if (args.size() != 1) return;
|
|
||||||
|
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[0], size)) {
|
if (!GeneralUtils::TryParse(args.at(0), size)) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid size.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid size.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
InventoryComponent* inventory = static_cast<InventoryComponent*>(entity->GetComponent(eReplicaComponentType::INVENTORY));
|
eInventoryType selectedInventory = eInventoryType::ITEMS;
|
||||||
if (inventory) {
|
|
||||||
auto* items = inventory->GetInventory(ITEMS);
|
|
||||||
|
|
||||||
items->SetSize(size);
|
// a possible inventory was provided if we got more than 1 argument
|
||||||
|
if (args.size() >= 2) {
|
||||||
|
selectedInventory = eInventoryType::INVALID;
|
||||||
|
if (!GeneralUtils::TryParse(args.at(1), selectedInventory)) {
|
||||||
|
// In this case, we treat the input as a string and try to find it in the reflection list
|
||||||
|
std::transform(args.at(1).begin(), args.at(1).end(), args.at(1).begin(), ::toupper);
|
||||||
|
for (uint32_t index = 0; index < NUMBER_OF_INVENTORIES; index++) {
|
||||||
|
if (std::string_view(args.at(1)) == std::string_view(InventoryType::InventoryTypeToString(static_cast<eInventoryType>(index)))) selectedInventory = static_cast<eInventoryType>(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (selectedInventory == eInventoryType::INVALID) {
|
||||||
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid inventory.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ChatPackets::SendSystemMessage(sysAddr, u"Setting inventory " +
|
||||||
|
GeneralUtils::ASCIIToUTF16(args.at(1)) +
|
||||||
|
u" to size " +
|
||||||
|
GeneralUtils::to_u16string(size));
|
||||||
|
} else ChatPackets::SendSystemMessage(sysAddr, u"Setting inventory ITEMS to size " + GeneralUtils::to_u16string(size));
|
||||||
|
|
||||||
|
auto* inventoryComponent = entity->GetComponent<InventoryComponent>();
|
||||||
|
if (inventoryComponent) {
|
||||||
|
auto* inventory = inventoryComponent->GetInventory(selectedInventory);
|
||||||
|
|
||||||
|
inventory->SetSize(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -1331,8 +1352,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
eLootSourceType lootType = eLootSourceType::LOOT_SOURCE_MODERATION;
|
eLootSourceType lootType = eLootSourceType::LOOT_SOURCE_MODERATION;
|
||||||
|
|
||||||
int32_t type;
|
int32_t type;
|
||||||
if (args.size() >= 2 && GeneralUtils::TryParse(args[1], type))
|
if (args.size() >= 2 && GeneralUtils::TryParse(args[1], type)) {
|
||||||
{
|
|
||||||
lootType = (eLootSourceType)type;
|
lootType = (eLootSourceType)type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ These commands are primarily for development and testing. The usage of many of t
|
|||||||
|setcontrolscheme|`/setcontrolscheme <scheme number>`|Sets the character control scheme to the specified number.|8|
|
|setcontrolscheme|`/setcontrolscheme <scheme number>`|Sets the character control scheme to the specified number.|8|
|
||||||
|setcurrency|`/setcurrency <coins>`|Sets your coins.|8|
|
|setcurrency|`/setcurrency <coins>`|Sets your coins.|8|
|
||||||
|setflag|`/setflag (value) <flag id>`|Sets the given inventory or health flag to the given value, where value can be one of "on" or "off". If no value is given, by default this adds the flag to your character (equivalent of calling `/setflag on <flag id>`).|8|
|
|setflag|`/setflag (value) <flag id>`|Sets the given inventory or health flag to the given value, where value can be one of "on" or "off". If no value is given, by default this adds the flag to your character (equivalent of calling `/setflag on <flag id>`).|8|
|
||||||
|setinventorysize|`/setinventorysize <size>`|Sets your inventory size to the given size. Alias: `/setinvsize`|8|
|
|setinventorysize|`/setinventorysize <size> (inventory)`|Sets your inventory size to the given size. If `inventory` is provided, the number or string will be used to set that inventory to the requested size. Alias: `/setinvsize`|8|
|
||||||
|setuistate|`/setuistate <ui state>`|Changes UI state.|8|
|
|setuistate|`/setuistate <ui state>`|Changes UI state.|8|
|
||||||
|spawn|`/spawn <id>`|Spawns an object at your location by id.|8|
|
|spawn|`/spawn <id>`|Spawns an object at your location by id.|8|
|
||||||
|speedboost|`/speedboost <amount>`|Sets the speed multiplier to the given amount. `/speedboost 1.5` will set the speed multiplier to 1.5x the normal speed.|8|
|
|speedboost|`/speedboost <amount>`|Sets the speed multiplier to the given amount. `/speedboost 1.5` will set the speed multiplier to 1.5x the normal speed.|8|
|
||||||
|
Loading…
Reference in New Issue
Block a user