summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorFedja Beader <fedja@protonmail.ch>2024-08-28 16:54:01 +0000
committerFedja Beader <fedja@protonmail.ch>2024-08-28 16:54:01 +0000
commitf0fb11cdfe92921ac76d6bb34a1da64334a01a17 (patch)
tree41f2b0b238ca9295831d8475e84e94460e80252a /src/net
parent7929b1dc48116522b6ed82b05e864a5b15910de9 (diff)
downloadmv-f0fb11cdfe92921ac76d6bb34a1da64334a01a17.tar.gz
mv-f0fb11cdfe92921ac76d6bb34a1da64334a01a17.tar.bz2
mv-f0fb11cdfe92921ac76d6bb34a1da64334a01a17.tar.xz
mv-f0fb11cdfe92921ac76d6bb34a1da64334a01a17.zip
Further improve skill error handling and messages.
Squashed with: * Appease linters + more reformat * Further improve skill error handling and messages. 24751878 "Improve skill error messages." added trailing dots only on the second branch. This adds missing dots on the first one as well as compacts the logic. **** mana/plus!93
Diffstat (limited to 'src/net')
-rw-r--r--src/net/eathena/skillrecv.cpp98
1 files changed, 41 insertions, 57 deletions
diff --git a/src/net/eathena/skillrecv.cpp b/src/net/eathena/skillrecv.cpp
index 35c19e953..8be8df445 100644
--- a/src/net/eathena/skillrecv.cpp
+++ b/src/net/eathena/skillrecv.cpp
@@ -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))
{
@@ -290,7 +291,8 @@ 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)
@@ -298,129 +300,110 @@ void SkillRecv::processSkillFailed(Net::MessageIn &msg)
{
localPlayer->stopAdvert();
}
-
- const SkillInfo *const info = skillDialog
- ? skillDialog->getSkill(bskill)
- : nullptr;
- 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
- ? skillDialog->getSkill(skillId)
- : nullptr;
- 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;
}
@@ -429,6 +412,7 @@ void SkillRecv::processSkillFailed(Net::MessageIn &msg)
UNIMPLEMENTEDPACKETFIELD(reason);
break;
}
+
if (debugChatTab != nullptr)
debugChatTab->chatLog("SKILL: "
+ txt,