summaryrefslogtreecommitdiff
path: root/src/net/eathena/skillrecv.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/eathena/skillrecv.cpp')
-rw-r--r--src/net/eathena/skillrecv.cpp101
1 files changed, 45 insertions, 56 deletions
diff --git a/src/net/eathena/skillrecv.cpp b/src/net/eathena/skillrecv.cpp
index 3f3e8efb1..10ab5f9c3 100644
--- a/src/net/eathena/skillrecv.cpp
+++ b/src/net/eathena/skillrecv.cpp
@@ -1,11 +1,11 @@
/*
- * The ManaPlus Client
+ * The ManaVerse Client
* Copyright (C) 2004-2009 The Mana World Development Team
* Copyright (C) 2009-2010 The Mana Developers
* Copyright (C) 2011-2020 The ManaPlus Developers
- * Copyright (C) 2020-2023 The ManaVerse Developers
+ * Copyright (C) 2020-2025 The ManaVerse Developers
*
- * This file is part of The ManaPlus Client.
+ * This file is part of The ManaVerse Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -281,6 +281,7 @@ void SkillRecv::processSkillFailed(Net::MessageIn &msg)
const int itemId = msg.readItemId("item id");
const signed char success = msg.readUInt8("success");
const signed char reason = msg.readUInt8("reason");
+
if (success != CAST_S32(SKILL_FAILED)
&& bskill == CAST_S32(BSKILL_EMOTE))
{
@@ -289,7 +290,9 @@ void SkillRecv::processSkillFailed(Net::MessageIn &msg)
if (localPlayer != nullptr)
localPlayer->stopCast(true);
- std::string txt;
+
+ int skillErrorCode = skillId;
+
if (success == CAST_S32(SKILL_FAILED) && bskill != 0)
{
if ((localPlayer != nullptr) && bskill == CAST_S32(BSKILL_EMOTE)
@@ -297,125 +300,110 @@ void SkillRecv::processSkillFailed(Net::MessageIn &msg)
{
localPlayer->stopAdvert();
}
-
- const SkillInfo *const info = skillDialog->getSkill(bskill);
- if (info != nullptr)
- {
- txt = info->errorText;
- }
- else
- {
- // TRANSLATORS: skill error message
- txt = strprintf(_("Unknown skill error: %d"), bskill);
- }
+ skillErrorCode = bskill;
}
+
+ const SkillInfo *const info = skillDialog ? skillDialog->getSkill(skillId)
+ : nullptr;
+
+ std::string txt;
+ if (info != nullptr)
+ txt = info->errorText + ".";
else
{
- const SkillInfo *const info = skillDialog->getSkill(skillId);
- if (info != nullptr)
- {
- txt = info->errorText + ".";
- }
- else
- {
- // TRANSLATORS: skill error message
- txt = strprintf(_("Unknown skill error: %d."), skillId);
- }
+ // TRANSLATORS: skill fail error message
+ txt = strprintf(_("Unknown skill error: %d."), skillErrorCode);
}
txt.append(" ");
switch (reason)
{
case RFAIL_SKILLDEP:
- // TRANSLATORS: error message
+ // TRANSLATORS: skill fail error message
txt.append(_("You have not yet reached a high enough lvl!"));
break;
case RFAIL_INSUFHP:
- // TRANSLATORS: error message
+ // TRANSLATORS: skill fail error message
txt.append(_("Insufficient HP!"));
break;
case RFAIL_INSUFSP:
- // TRANSLATORS: error message
+ // TRANSLATORS: skill fail error message
txt.append(_("Insufficient SP!"));
break;
case RFAIL_NOMEMO:
- // TRANSLATORS: error message
+ // TRANSLATORS: skill fail error message
txt.append(_("You have no memos!"));
break;
case RFAIL_SKILLDELAY:
- // TRANSLATORS: error message
+ // TRANSLATORS: skill fail error message
txt.append(_("You cannot do that right now!"));
break;
case RFAIL_ZENY:
- // TRANSLATORS: error message
+ // TRANSLATORS: skill fail error message
txt.append(_("Seems you need more money... ;-)"));
break;
case RFAIL_WEAPON:
- // TRANSLATORS: error message
+ // TRANSLATORS: skill fail error message
txt.append(_("You cannot use this skill with that "
- "kind of weapon!"));
+ "kind of weapon!"));
break;
case RFAIL_REDGEM:
- // TRANSLATORS: error message
+ // TRANSLATORS: skill fail error message
txt.append(_("You need another red gem!"));
break;
case RFAIL_BLUEGEM:
- // TRANSLATORS: error message
+ // TRANSLATORS: skill fail error message
txt.append(_("You need another blue gem!"));
break;
case RFAIL_OVERWEIGHT:
- // TRANSLATORS: error message
- txt.append(_("You're carrying to much to do this!"));
+ // TRANSLATORS: skill fail error message
+ txt.append(_("You're carrying too much to do this!"));
break;
case RFAIL_SUMMON:
- // TRANSLATORS: error message
+ // TRANSLATORS: skill fail error message
txt.append(_("Fail summon."));
break;
case RFAIL_SPIRITS:
- // TRANSLATORS: error message
+ // TRANSLATORS: skill fail error message
txt.append(_("Need spirits."));
break;
case RFAIL_NEED_EQUIPMENT:
{
const int amount = bskill;
- const ItemInfo &info = ItemDB::get(itemId);
+ const char* const link = ItemDB::get(itemId).getLink().c_str();
if (amount == 1)
{
- // TRANSLATORS: skill error message
- txt.append(strprintf(_("Need equipment %s."),
- info.getLink().c_str()));
+ // TRANSLATORS: skill fail error message
+ txt.append(strprintf(_("Need equipment %s."), link));
}
else
{
- // TRANSLATORS: skill error message
- txt.append(strprintf(_("Need equipment %s and amount %d"),
- info.getLink().c_str(),
- amount));
+ // TRANSLATORS: skill fail error message
+ txt.append(strprintf(_("Need %d of equipment %s"),
+ amount, link));
}
break;
}
case RFAIL_NEED_ITEM:
{
const int amount = bskill;
- const ItemInfo &info = ItemDB::get(itemId);
+ const char* const link = ItemDB::get(itemId).getLink().c_str();
if (amount == 1)
{
- // TRANSLATORS: skill error message
- txt.append(strprintf(_("Need item %s."),
- info.getLink().c_str()));
+ // TRANSLATORS: skill fail error message
+ txt.append(strprintf(_("Need item %s."), link));
}
else
{
- // TRANSLATORS: skill error message
- txt.append(strprintf(_("Need item %s and amount %d"),
- info.getLink().c_str(),
- amount));
+ // TRANSLATORS: skill fail error message
+ txt.append(strprintf(_("Need %d of item %s"),
+ amount, link));
}
break;
}
case RFAIL:
{
- // TRANSLATORS: error message
+ // TRANSLATORS: skill fail error message
txt.append(_("Skill failed!"));
break;
}
@@ -424,6 +412,7 @@ void SkillRecv::processSkillFailed(Net::MessageIn &msg)
UNIMPLEMENTEDPACKETFIELD(reason);
break;
}
+
if (debugChatTab != nullptr)
debugChatTab->chatLog("SKILL: "
+ txt,