From 6705f5937223931f35527f865110cf728f8e4f79 Mon Sep 17 00:00:00 2001 From: Elson Costa Date: Thu, 22 Feb 2024 18:52:01 -0300 Subject: [PATCH] feature: add new error messages (#2304) Co-authored-by: Gtravisani <160722972+Gtravisani@users.noreply.github.com> --- src/game/game.cpp | 14 +++++++------- src/items/items_definitions.hpp | 3 +++ src/lua/functions/core/game/lua_enums.cpp | 3 +++ src/utils/tools.cpp | 9 +++++++++ 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/game/game.cpp b/src/game/game.cpp index 6e731f78feb..ddccb42dbcf 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -1619,7 +1619,7 @@ void Game::playerMoveItem(std::shared_ptr player, const Position &fromPo auto toHouseTile = map.getTile(mapToPos)->dynamic_self_cast(); auto fromHouseTile = map.getTile(mapFromPos)->dynamic_self_cast(); if (fromHouseTile && (!toHouseTile || toHouseTile->getHouse()->getId() != fromHouseTile->getHouse()->getId())) { - player->sendCancelMessage("You can't move this item outside a house."); + player->sendCancelMessage("You cannot move this item out of this house."); return; } } @@ -1666,12 +1666,12 @@ ReturnValue Game::checkMoveItemToCylinder(std::shared_ptr player, std::s bool allowAnything = g_configManager().getBoolean(TOGGLE_GOLD_POUCH_ALLOW_ANYTHING, __FUNCTION__); if (!allowAnything && item->getID() != ITEM_GOLD_COIN && item->getID() != ITEM_PLATINUM_COIN && item->getID() != ITEM_CRYSTAL_COIN) { - return RETURNVALUE_CONTAINERNOTENOUGHROOM; + return RETURNVALUE_ITEMCANNOTBEMOVEDPOUCH; } - // prevent move up + // prevent move up from ponch to store inbox. if (!item->canBeMovedToStore() && fromCylinder->getContainer() && fromCylinder->getContainer()->getID() == ITEM_GOLD_POUCH) { - return RETURNVALUE_CONTAINERNOTENOUGHROOM; + return RETURNVALUE_NOTBOUGHTINSTORE; } return RETURNVALUE_NOERROR; @@ -1681,7 +1681,7 @@ ReturnValue Game::checkMoveItemToCylinder(std::shared_ptr player, std::s const auto parentContainer = topParentContainer->getParent() ? topParentContainer->getParent()->getContainer() : nullptr; auto isStoreInbox = parentContainer && parentContainer->isStoreInbox(); if (!item->canBeMovedToStore() && (containerID == ITEM_STORE_INBOX || isStoreInbox)) { - return RETURNVALUE_CONTAINERNOTENOUGHROOM; + return RETURNVALUE_NOTBOUGHTINSTORE; } if (item->isStoreItem()) { @@ -1705,7 +1705,7 @@ ReturnValue Game::checkMoveItemToCylinder(std::shared_ptr player, std::s } if (!isValidMoveItem) { - return RETURNVALUE_NOTPOSSIBLE; + return RETURNVALUE_ITEMCANNOTBEMOVEDTHERE; } if (item->hasOwner() && !item->isOwner(player)) { @@ -1738,7 +1738,7 @@ ReturnValue Game::checkMoveItemToCylinder(std::shared_ptr player, std::s } if (item->isStoreItem() && !house) { - return RETURNVALUE_NOTPOSSIBLE; + return RETURNVALUE_ITEMCANNOTBEMOVEDTHERE; } } } diff --git a/src/items/items_definitions.hpp b/src/items/items_definitions.hpp index f6b5f9f86ae..3bf8fc8b52a 100644 --- a/src/items/items_definitions.hpp +++ b/src/items/items_definitions.hpp @@ -35,6 +35,9 @@ enum Attr_ReadValue { enum ReturnValue { RETURNVALUE_NOERROR, + RETURNVALUE_NOTBOUGHTINSTORE, + RETURNVALUE_ITEMCANNOTBEMOVEDTHERE, + RETURNVALUE_ITEMCANNOTBEMOVEDPOUCH, RETURNVALUE_NOTPOSSIBLE, RETURNVALUE_NOTENOUGHROOM, RETURNVALUE_PLAYERISPZLOCKED, diff --git a/src/lua/functions/core/game/lua_enums.cpp b/src/lua/functions/core/game/lua_enums.cpp index 69978ed3066..66b7cf1feec 100644 --- a/src/lua/functions/core/game/lua_enums.cpp +++ b/src/lua/functions/core/game/lua_enums.cpp @@ -1125,6 +1125,9 @@ void LuaEnums::initMapMarkEnums(lua_State* L) { // Use with Game.getReturnMessage void LuaEnums::initReturnValueEnums(lua_State* L) { registerEnum(L, RETURNVALUE_NOERROR); + registerEnum(L, RETURNVALUE_NOTBOUGHTINSTORE); + registerEnum(L, RETURNVALUE_ITEMCANNOTBEMOVEDTHERE); + registerEnum(L, RETURNVALUE_ITEMCANNOTBEMOVEDPOUCH); registerEnum(L, RETURNVALUE_NOTPOSSIBLE); registerEnum(L, RETURNVALUE_NOTENOUGHROOM); registerEnum(L, RETURNVALUE_PLAYERISPZLOCKED); diff --git a/src/utils/tools.cpp b/src/utils/tools.cpp index 83f9ba84ace..004bfdbc87a 100644 --- a/src/utils/tools.cpp +++ b/src/utils/tools.cpp @@ -1203,6 +1203,15 @@ const char* getReturnMessage(ReturnValue value) { case RETURNVALUE_NOERROR: return "No error."; + case RETURNVALUE_NOTBOUGHTINSTORE: + return "You cannot move this item into your store inbox as it was not bought in the store."; + + case RETURNVALUE_ITEMCANNOTBEMOVEDPOUCH: + return "This item cannot be moved there. You can only place gold, platinum and crystal coins in your gold pouch."; + + case RETURNVALUE_ITEMCANNOTBEMOVEDTHERE: + return "This item cannot be moved there."; + case RETURNVALUE_REWARDCHESTISEMPTY: return "The chest is currently empty. You did not take part in any battles in the last seven days or already claimed your reward.";