From 5dcba0dec84d73a02b08bde21388535a80e94c56 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Mon, 19 Aug 2024 15:29:15 +0200 Subject: Renamed specials to abilities To match mana/manaserv@9ff69160ea1c3c64ea7012cd70a3b50ff4373264. --- src/net/abilityhandler.h | 42 +++++++ src/net/manaserv/abilityhandler.cpp | 75 +++++++++++ src/net/manaserv/abilityhandler.h | 46 +++++++ src/net/manaserv/generalhandler.cpp | 4 +- src/net/manaserv/generalhandler.h | 2 +- src/net/manaserv/manaserv_protocol.h | 8 +- src/net/manaserv/playerhandler.cpp | 10 +- src/net/manaserv/specialhandler.cpp | 75 ----------- src/net/manaserv/specialhandler.h | 46 ------- src/net/net.cpp | 8 +- src/net/net.h | 4 +- src/net/specialhandler.h | 42 ------- src/net/tmwa/abilityhandler.cpp | 238 +++++++++++++++++++++++++++++++++++ src/net/tmwa/abilityhandler.h | 47 +++++++ src/net/tmwa/generalhandler.cpp | 6 +- src/net/tmwa/generalhandler.h | 2 +- src/net/tmwa/specialhandler.cpp | 238 ----------------------------------- src/net/tmwa/specialhandler.h | 47 ------- 18 files changed, 470 insertions(+), 470 deletions(-) create mode 100644 src/net/abilityhandler.h create mode 100644 src/net/manaserv/abilityhandler.cpp create mode 100644 src/net/manaserv/abilityhandler.h delete mode 100644 src/net/manaserv/specialhandler.cpp delete mode 100644 src/net/manaserv/specialhandler.h delete mode 100644 src/net/specialhandler.h create mode 100644 src/net/tmwa/abilityhandler.cpp create mode 100644 src/net/tmwa/abilityhandler.h delete mode 100644 src/net/tmwa/specialhandler.cpp delete mode 100644 src/net/tmwa/specialhandler.h (limited to 'src/net') diff --git a/src/net/abilityhandler.h b/src/net/abilityhandler.h new file mode 100644 index 00000000..6e3526bb --- /dev/null +++ b/src/net/abilityhandler.h @@ -0,0 +1,42 @@ +/* + * The Mana Client + * Copyright (C) 2009 The Mana World Development Team + * Copyright (C) 2009-2012 The Mana Developers + * + * This file is part of The Mana 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 + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include + +namespace Net { + +class AbilityHandler +{ + public: + virtual ~AbilityHandler () {} + + virtual void use(int id) = 0; + + virtual void use(int id, int level, int beingId) = 0; + + virtual void use(int id, int level, int x, int y) = 0; + + virtual void use(int id, const std::string &map) = 0; +}; + +} // namespace Net diff --git a/src/net/manaserv/abilityhandler.cpp b/src/net/manaserv/abilityhandler.cpp new file mode 100644 index 00000000..b5ce9d2e --- /dev/null +++ b/src/net/manaserv/abilityhandler.cpp @@ -0,0 +1,75 @@ +/* + * The Mana Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2012 The Mana Developers + * + * This file is part of The Mana 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 + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "net/manaserv/abilityhandler.h" + +#include "net/manaserv/connection.h" +#include "net/manaserv/messagein.h" +#include "net/manaserv/messageout.h" +#include "net/manaserv/manaserv_protocol.h" + +extern Net::AbilityHandler *abilityHandler; + +namespace ManaServ { + +extern Connection *gameServerConnection; + +AbilityHandler::AbilityHandler() +{ + abilityHandler = this; +} + +void AbilityHandler::handleMessage(MessageIn &msg) +{ + // TODO +} + +void AbilityHandler::use(int id) +{ + MessageOut msg(PGMSG_USE_ABILITY_ON_BEING); + msg.writeInt8(id); + msg.writeInt16(0); + gameServerConnection->send(msg); +} + +void AbilityHandler::use(int id, int level, int beingId) +{ + MessageOut msg(PGMSG_USE_ABILITY_ON_BEING); + msg.writeInt8(id); + msg.writeInt16(beingId); + gameServerConnection->send(msg); +} + +void AbilityHandler::use(int id, int level, int x, int y) +{ + MessageOut msg(PGMSG_USE_ABILITY_ON_POINT); + msg.writeInt8(id); + msg.writeInt16(x); + msg.writeInt16(y); + gameServerConnection->send(msg); +} + +void AbilityHandler::use(int id, const std::string &map) +{ + // TODO +} + +} // namespace ManaServ diff --git a/src/net/manaserv/abilityhandler.h b/src/net/manaserv/abilityhandler.h new file mode 100644 index 00000000..69ab9c2b --- /dev/null +++ b/src/net/manaserv/abilityhandler.h @@ -0,0 +1,46 @@ +/* + * The Mana Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2012 The Mana Developers + * + * This file is part of The Mana 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 + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include "net/abilityhandler.h" + +#include "net/manaserv/messagehandler.h" + +namespace ManaServ { + +class AbilityHandler final : public MessageHandler, public Net::AbilityHandler +{ + public: + AbilityHandler(); + + void handleMessage(MessageIn &msg) override; + + void use(int id) override; + + void use(int id, int level, int beingId) override; + + void use(int id, int level, int x, int y) override; + + void use(int id, const std::string &map) override; +}; + +} // namespace ManaServ diff --git a/src/net/manaserv/generalhandler.cpp b/src/net/manaserv/generalhandler.cpp index 0692ee82..1e443c66 100644 --- a/src/net/manaserv/generalhandler.cpp +++ b/src/net/manaserv/generalhandler.cpp @@ -42,7 +42,7 @@ #include "net/manaserv/npchandler.h" #include "net/manaserv/partyhandler.h" #include "net/manaserv/playerhandler.h" -#include "net/manaserv/specialhandler.h" +#include "net/manaserv/abilityhandler.h" #include "net/manaserv/tradehandler.h" #include "resources/attributes.h" @@ -76,7 +76,7 @@ GeneralHandler::GeneralHandler(): mPartyHandler(new PartyHandler), mPlayerHandler(new PlayerHandler), mTradeHandler(new TradeHandler), - mSpecialHandler(new SpecialHandler) + mAbilityHandler(new AbilityHandler) { initialize(); diff --git a/src/net/manaserv/generalhandler.h b/src/net/manaserv/generalhandler.h index b9eb9df0..865bbd0d 100644 --- a/src/net/manaserv/generalhandler.h +++ b/src/net/manaserv/generalhandler.h @@ -63,7 +63,7 @@ class GeneralHandler : public Net::GeneralHandler, public EventListener MessageHandlerPtr mPartyHandler; MessageHandlerPtr mPlayerHandler; MessageHandlerPtr mTradeHandler; - MessageHandlerPtr mSpecialHandler; + MessageHandlerPtr mAbilityHandler; }; } // namespace ManaServ diff --git a/src/net/manaserv/manaserv_protocol.h b/src/net/manaserv/manaserv_protocol.h index b30bf20b..01632215 100644 --- a/src/net/manaserv/manaserv_protocol.h +++ b/src/net/manaserv/manaserv_protocol.h @@ -25,7 +25,7 @@ namespace ManaServ { enum { PROTOCOL_VERSION = 3, - SUPPORTED_DB_VERSION = 21 + SUPPORTED_DB_VERSION = 22 }; /** @@ -138,9 +138,9 @@ enum { GPMSG_ITEMS = 0x0281, // { W item id, W*2 position }* PGMSG_ATTACK = 0x0290, // W being id GPMSG_BEING_ATTACK = 0x0291, // W being id, B direction, B attack Id - PGMSG_USE_SPECIAL_ON_BEING = 0x0292, // B specialID, W being id - GPMSG_SPECIAL_STATUS = 0x0293, // { B specialID, D current, D max, D recharge } - PGMSG_USE_SPECIAL_ON_POINT = 0x0294, // B specialID, W*2 position + PGMSG_USE_ABILITY_ON_BEING = 0x0292, // B abilityID, W being id + GPMSG_ABILITY_STATUS = 0x0293, // { B abilityID, D current, D max, D recharge } + PGMSG_USE_ABILITY_ON_POINT = 0x0294, // B abilityID, W*2 position PGMSG_SAY = 0x02A0, // S text GPMSG_SAY = 0x02A1, // W being id, S text GPMSG_NPC_CHOICE = 0x02B0, // W being id, { S text }* diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp index bf5694c6..335546be 100644 --- a/src/net/manaserv/playerhandler.cpp +++ b/src/net/manaserv/playerhandler.cpp @@ -75,7 +75,7 @@ PlayerHandler::PlayerHandler() GPMSG_LEVEL_PROGRESS, GPMSG_RAISE_ATTRIBUTE_RESPONSE, GPMSG_LOWER_ATTRIBUTE_RESPONSE, - GPMSG_SPECIAL_STATUS, + GPMSG_ABILITY_STATUS, 0 }; handledMessages = _messages; @@ -243,17 +243,17 @@ void PlayerHandler::handleMessage(MessageIn &msg) } break; - case GPMSG_SPECIAL_STATUS : + case GPMSG_ABILITY_STATUS: { - PlayerInfo::clearSpecialStatus(); + PlayerInfo::clearAbilityStatus(); while (msg.getUnreadLength()) { - // { B specialID, L current, L max, L recharge } + // { B abilityID, L current, L max, L recharge } int id = msg.readInt8(); int current = msg.readInt32(); int max = msg.readInt32(); int recharge = msg.readInt32(); - PlayerInfo::setSpecialStatus(id, current, max, recharge); + PlayerInfo::setAbilityStatus(id, current, max, recharge); } } break; /* diff --git a/src/net/manaserv/specialhandler.cpp b/src/net/manaserv/specialhandler.cpp deleted file mode 100644 index 0a477ff8..00000000 --- a/src/net/manaserv/specialhandler.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * The Mana Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2012 The Mana Developers - * - * This file is part of The Mana 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 - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "net/manaserv/specialhandler.h" - -#include "net/manaserv/connection.h" -#include "net/manaserv/messagein.h" -#include "net/manaserv/messageout.h" -#include "net/manaserv/manaserv_protocol.h" - -extern Net::SpecialHandler *specialHandler; - -namespace ManaServ { - -extern Connection *gameServerConnection; - -SpecialHandler::SpecialHandler() -{ - specialHandler = this; -} - -void SpecialHandler::handleMessage(MessageIn &msg) -{ - // TODO -} - -void SpecialHandler::use(int id) -{ - MessageOut msg(PGMSG_USE_SPECIAL_ON_BEING); - msg.writeInt8(id); - msg.writeInt16(0); - gameServerConnection->send(msg); -} - -void SpecialHandler::use(int id, int level, int beingId) -{ - MessageOut msg(PGMSG_USE_SPECIAL_ON_BEING); - msg.writeInt8(id); - msg.writeInt16(beingId); - gameServerConnection->send(msg); -} - -void SpecialHandler::use(int id, int level, int x, int y) -{ - MessageOut msg(PGMSG_USE_SPECIAL_ON_POINT); - msg.writeInt8(id); - msg.writeInt16(x); - msg.writeInt16(y); - gameServerConnection->send(msg); -} - -void SpecialHandler::use(int id, const std::string &map) -{ - // TODO -} - -} // namespace ManaServ diff --git a/src/net/manaserv/specialhandler.h b/src/net/manaserv/specialhandler.h deleted file mode 100644 index 45793b62..00000000 --- a/src/net/manaserv/specialhandler.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * The Mana Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2012 The Mana Developers - * - * This file is part of The Mana 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 - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include "net/specialhandler.h" - -#include "net/manaserv/messagehandler.h" - -namespace ManaServ { - -class SpecialHandler final : public MessageHandler, public Net::SpecialHandler -{ - public: - SpecialHandler(); - - void handleMessage(MessageIn &msg) override; - - void use(int id) override; - - void use(int id, int level, int beingId) override; - - void use(int id, int level, int x, int y) override; - - void use(int id, const std::string &map) override; -}; - -} // namespace ManaServ diff --git a/src/net/net.cpp b/src/net/net.cpp index 3a389db2..93003280 100644 --- a/src/net/net.cpp +++ b/src/net/net.cpp @@ -34,7 +34,7 @@ #include "net/npchandler.h" #include "net/partyhandler.h" #include "net/playerhandler.h" -#include "net/specialhandler.h" +#include "net/abilityhandler.h" #include "net/tradehandler.h" #include "net/tmwa/generalhandler.h" @@ -54,7 +54,7 @@ Net::GuildHandler *guildHandler = nullptr; Net::NpcHandler *npcHandler = nullptr; Net::PartyHandler *partyHandler = nullptr; Net::PlayerHandler *playerHandler = nullptr; -Net::SpecialHandler *specialHandler = nullptr; +Net::AbilityHandler *abilityHandler = nullptr; Net::TradeHandler *tradeHandler = nullptr; Net::AdminHandler *Net::getAdminHandler() @@ -112,9 +112,9 @@ Net::PlayerHandler *Net::getPlayerHandler() return playerHandler; } -Net::SpecialHandler *Net::getSpecialHandler() +Net::AbilityHandler *Net::getAbilityHandler() { - return specialHandler; + return abilityHandler; } Net::TradeHandler *Net::getTradeHandler() diff --git a/src/net/net.h b/src/net/net.h index 216c2048..ced0f7ba 100644 --- a/src/net/net.h +++ b/src/net/net.h @@ -44,7 +44,7 @@ class LoginHandler; class NpcHandler; class PartyHandler; class PlayerHandler; -class SpecialHandler; +class AbilityHandler; class TradeHandler; AdminHandler *getAdminHandler(); @@ -58,7 +58,7 @@ LoginHandler *getLoginHandler(); NpcHandler *getNpcHandler(); PartyHandler *getPartyHandler(); PlayerHandler *getPlayerHandler(); -SpecialHandler *getSpecialHandler(); +AbilityHandler *getAbilityHandler(); TradeHandler *getTradeHandler(); ServerType getNetworkType(); diff --git a/src/net/specialhandler.h b/src/net/specialhandler.h deleted file mode 100644 index df09087d..00000000 --- a/src/net/specialhandler.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * The Mana Client - * Copyright (C) 2009 The Mana World Development Team - * Copyright (C) 2009-2012 The Mana Developers - * - * This file is part of The Mana 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 - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include - -namespace Net { - -class SpecialHandler -{ - public: - virtual ~SpecialHandler () {} - - virtual void use(int id) = 0; - - virtual void use(int id, int level, int beingId) = 0; - - virtual void use(int id, int level, int x, int y) = 0; - - virtual void use(int id, const std::string &map) = 0; -}; - -} // namespace Net diff --git a/src/net/tmwa/abilityhandler.cpp b/src/net/tmwa/abilityhandler.cpp new file mode 100644 index 00000000..e221039c --- /dev/null +++ b/src/net/tmwa/abilityhandler.cpp @@ -0,0 +1,238 @@ +/* + * The Mana Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2012 The Mana Developers + * + * This file is part of The Mana 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 + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "net/tmwa/abilityhandler.h" + +#include "event.h" +#include "log.h" +#include "playerinfo.h" + +#include "gui/skilldialog.h" + +#include "net/tmwa/messagein.h" +#include "net/tmwa/protocol.h" + +#include "utils/gettext.h" + +/** job dependend identifiers (?) */ +#define SKILL_BASIC 0x0001 +#define SKILL_WARP 0x001b +#define SKILL_STEAL 0x0032 +#define SKILL_ENVENOM 0x0034 + +/** basic skills identifiers */ +#define BSKILL_TRADE 0x0000 +#define BSKILL_EMOTE 0x0001 +#define BSKILL_SIT 0x0002 +#define BSKILL_CREATECHAT 0x0003 +#define BSKILL_JOINPARTY 0x0004 +#define BSKILL_SHOUT 0x0005 +#define BSKILL_PK 0x0006 // ?? +#define BSKILL_SETALLIGN 0x0007 // ?? + +/** reasons why action failed */ +#define RFAIL_SKILLDEP 0x00 +#define RFAIL_INSUFSP 0x01 +#define RFAIL_INSUFHP 0x02 +#define RFAIL_NOMEMO 0x03 +#define RFAIL_SKILLDELAY 0x04 +#define RFAIL_ZENY 0x05 +#define RFAIL_WEAPON 0x06 +#define RFAIL_REDGEM 0x07 +#define RFAIL_BLUEGEM 0x08 +#define RFAIL_OVERWEIGHT 0x09 +#define RFAIL_GENERIC 0x0a + +/** should always be zero if failed */ +#define SKILL_FAILED 0x00 + +extern Net::AbilityHandler *abilityHandler; + +namespace TmwAthena { + +AbilityHandler::AbilityHandler() +{ + static const Uint16 _messages[] = { + SMSG_PLAYER_SKILLS, + SMSG_SKILL_FAILED, + SMSG_PLAYER_SKILL_UP, + 0 + }; + handledMessages = _messages; + abilityHandler = this; +} + +void AbilityHandler::handleMessage(MessageIn &msg) +{ + int skillCount; + int skillId; + + switch (msg.getId()) + { + case SMSG_PLAYER_SKILLS: + msg.readInt16(); // length + skillCount = (msg.getLength() - 4) / 37; + + for (int k = 0; k < skillCount; k++) + { + skillId = msg.readInt16(); + msg.readInt16(); // target type + msg.skip(2); // unused + int level = msg.readInt16(); + msg.readInt16(); // sp + msg.readInt16(); // range + msg.skip(24); // unused + int up = msg.readInt8(); + + PlayerInfo::setStatBase(skillId, level); + if (skillDialog) + skillDialog->setModifiable(skillId, up); + } + break; + + case SMSG_PLAYER_SKILL_UP: + { + skillId = msg.readInt16(); + int level = msg.readInt16(); + msg.readInt16(); // sp + msg.readInt16(); // range + int up = msg.readInt8(); + + PlayerInfo::setStatBase(skillId, level); + skillDialog->setModifiable(skillId, up); + } + break; + + case SMSG_SKILL_FAILED: + // Action failed (ex. sit because you have not reached the + // right level) + skillId = msg.readInt16(); + short bskill = msg.readInt16(); + msg.readInt16(); // unknown + char success = msg.readInt8(); + char reason = msg.readInt8(); + if (success != SKILL_FAILED && bskill == BSKILL_EMOTE) + { + logger->log("Action: %d/%d", bskill, success); + } + + std::string msg; + if (success == SKILL_FAILED && skillId == SKILL_BASIC) + { + switch (bskill) + { + case BSKILL_TRADE: + msg = _("Trade failed!"); + break; + case BSKILL_EMOTE: + msg = _("Emote failed!"); + break; + case BSKILL_SIT: + msg = _("Sit failed!"); + break; + case BSKILL_CREATECHAT: + msg = _("Chat creating failed!"); + break; + case BSKILL_JOINPARTY: + msg = _("Could not join party!"); + break; + case BSKILL_SHOUT: + msg = _("Cannot shout!"); + break; + } + + msg += " "; + + switch (reason) + { + case RFAIL_SKILLDEP: + msg += _("You have not yet reached a high enough lvl!"); + break; + case RFAIL_INSUFHP: + msg += _("Insufficient HP!"); + break; + case RFAIL_INSUFSP: + msg += _("Insufficient SP!"); + break; + case RFAIL_NOMEMO: + msg += _("You have no memos!"); + break; + case RFAIL_SKILLDELAY: + msg += _("You cannot do that right now!"); + break; + case RFAIL_ZENY: + msg += _("Seems you need more money... ;-)"); + break; + case RFAIL_WEAPON: + msg += _("You cannot use this skill with that kind of weapon!"); + break; + case RFAIL_REDGEM: + msg += _("You need another red gem!"); + break; + case RFAIL_BLUEGEM: + msg += _("You need another blue gem!"); + break; + case RFAIL_OVERWEIGHT: + msg += _("You're carrying to much to do this!"); + break; + default: + msg += _("Huh? What's that?"); + break; + } + } + else + { + switch (skillId) + { + case SKILL_WARP: + msg = _("Warp failed..."); + break; + case SKILL_STEAL: + msg = _("Could not steal anything..."); + break; + case SKILL_ENVENOM: + msg = _("Poison had no effect..."); + break; + } + } + + serverNotice(msg); + break; + } +} + +void AbilityHandler::use(int id) +{ +} + +void AbilityHandler::use(int id, int level, int beingId) +{ +} + +void AbilityHandler::use(int id, int level, int x, int y) +{ +} + +void AbilityHandler::use(int id, const std::string &map) +{ +} + +} // namespace TmwAthena diff --git a/src/net/tmwa/abilityhandler.h b/src/net/tmwa/abilityhandler.h new file mode 100644 index 00000000..822ed737 --- /dev/null +++ b/src/net/tmwa/abilityhandler.h @@ -0,0 +1,47 @@ +/* + * The Mana Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2012 The Mana Developers + * + * This file is part of The Mana 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 + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include "net/net.h" +#include "net/abilityhandler.h" + +#include "net/tmwa/messagehandler.h" + +namespace TmwAthena { + +class AbilityHandler final : public MessageHandler, public Net::AbilityHandler +{ + public: + AbilityHandler(); + + void handleMessage(MessageIn &msg) override; + + void use(int id) override; + + void use(int id, int level, int beingId) override; + + void use(int id, int level, int x, int y) override; + + void use(int id, const std::string &map) override; +}; + +} // namespace TmwAthena diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp index e1b1a9ea..2a8afb4e 100644 --- a/src/net/tmwa/generalhandler.cpp +++ b/src/net/tmwa/generalhandler.cpp @@ -49,7 +49,7 @@ #include "net/tmwa/playerhandler.h" #include "net/tmwa/protocol.h" #include "net/tmwa/tradehandler.h" -#include "net/tmwa/specialhandler.h" +#include "net/tmwa/abilityhandler.h" #include "net/tmwa/gui/guildtab.h" #include "net/tmwa/gui/partytab.h" @@ -84,7 +84,7 @@ GeneralHandler::GeneralHandler(): mNpcHandler(new NpcHandler), mPartyHandler(new PartyHandler), mPlayerHandler(new PlayerHandler), - mSpecialHandler(new SpecialHandler), + mAbilityHandler(new AbilityHandler), mTradeHandler(new TradeHandler) { static const Uint16 _messages[] = { @@ -169,7 +169,7 @@ void GeneralHandler::load() mNetwork->registerHandler(mLoginHandler.get()); mNetwork->registerHandler(mNpcHandler.get()); mNetwork->registerHandler(mPlayerHandler.get()); - mNetwork->registerHandler(mSpecialHandler.get()); + mNetwork->registerHandler(mAbilityHandler.get()); mNetwork->registerHandler(mTradeHandler.get()); mNetwork->registerHandler(mPartyHandler.get()); } diff --git a/src/net/tmwa/generalhandler.h b/src/net/tmwa/generalhandler.h index 26c6fe27..529c1661 100644 --- a/src/net/tmwa/generalhandler.h +++ b/src/net/tmwa/generalhandler.h @@ -66,7 +66,7 @@ class GeneralHandler final : public MessageHandler, public Net::GeneralHandler, MessageHandlerPtr mNpcHandler; MessageHandlerPtr mPartyHandler; MessageHandlerPtr mPlayerHandler; - MessageHandlerPtr mSpecialHandler; + MessageHandlerPtr mAbilityHandler; MessageHandlerPtr mTradeHandler; }; diff --git a/src/net/tmwa/specialhandler.cpp b/src/net/tmwa/specialhandler.cpp deleted file mode 100644 index 2e22b00a..00000000 --- a/src/net/tmwa/specialhandler.cpp +++ /dev/null @@ -1,238 +0,0 @@ -/* - * The Mana Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2012 The Mana Developers - * - * This file is part of The Mana 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 - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "net/tmwa/specialhandler.h" - -#include "event.h" -#include "log.h" -#include "playerinfo.h" - -#include "gui/skilldialog.h" - -#include "net/tmwa/messagein.h" -#include "net/tmwa/protocol.h" - -#include "utils/gettext.h" - -/** job dependend identifiers (?) */ -#define SKILL_BASIC 0x0001 -#define SKILL_WARP 0x001b -#define SKILL_STEAL 0x0032 -#define SKILL_ENVENOM 0x0034 - -/** basic skills identifiers */ -#define BSKILL_TRADE 0x0000 -#define BSKILL_EMOTE 0x0001 -#define BSKILL_SIT 0x0002 -#define BSKILL_CREATECHAT 0x0003 -#define BSKILL_JOINPARTY 0x0004 -#define BSKILL_SHOUT 0x0005 -#define BSKILL_PK 0x0006 // ?? -#define BSKILL_SETALLIGN 0x0007 // ?? - -/** reasons why action failed */ -#define RFAIL_SKILLDEP 0x00 -#define RFAIL_INSUFSP 0x01 -#define RFAIL_INSUFHP 0x02 -#define RFAIL_NOMEMO 0x03 -#define RFAIL_SKILLDELAY 0x04 -#define RFAIL_ZENY 0x05 -#define RFAIL_WEAPON 0x06 -#define RFAIL_REDGEM 0x07 -#define RFAIL_BLUEGEM 0x08 -#define RFAIL_OVERWEIGHT 0x09 -#define RFAIL_GENERIC 0x0a - -/** should always be zero if failed */ -#define SKILL_FAILED 0x00 - -extern Net::SpecialHandler *specialHandler; - -namespace TmwAthena { - -SpecialHandler::SpecialHandler() -{ - static const Uint16 _messages[] = { - SMSG_PLAYER_SKILLS, - SMSG_SKILL_FAILED, - SMSG_PLAYER_SKILL_UP, - 0 - }; - handledMessages = _messages; - specialHandler = this; -} - -void SpecialHandler::handleMessage(MessageIn &msg) -{ - int skillCount; - int skillId; - - switch (msg.getId()) - { - case SMSG_PLAYER_SKILLS: - msg.readInt16(); // length - skillCount = (msg.getLength() - 4) / 37; - - for (int k = 0; k < skillCount; k++) - { - skillId = msg.readInt16(); - msg.readInt16(); // target type - msg.skip(2); // unused - int level = msg.readInt16(); - msg.readInt16(); // sp - msg.readInt16(); // range - msg.skip(24); // unused - int up = msg.readInt8(); - - PlayerInfo::setStatBase(skillId, level); - if (skillDialog) - skillDialog->setModifiable(skillId, up); - } - break; - - case SMSG_PLAYER_SKILL_UP: - { - skillId = msg.readInt16(); - int level = msg.readInt16(); - msg.readInt16(); // sp - msg.readInt16(); // range - int up = msg.readInt8(); - - PlayerInfo::setStatBase(skillId, level); - skillDialog->setModifiable(skillId, up); - } - break; - - case SMSG_SKILL_FAILED: - // Action failed (ex. sit because you have not reached the - // right level) - skillId = msg.readInt16(); - short bskill = msg.readInt16(); - msg.readInt16(); // unknown - char success = msg.readInt8(); - char reason = msg.readInt8(); - if (success != SKILL_FAILED && bskill == BSKILL_EMOTE) - { - logger->log("Action: %d/%d", bskill, success); - } - - std::string msg; - if (success == SKILL_FAILED && skillId == SKILL_BASIC) - { - switch (bskill) - { - case BSKILL_TRADE: - msg = _("Trade failed!"); - break; - case BSKILL_EMOTE: - msg = _("Emote failed!"); - break; - case BSKILL_SIT: - msg = _("Sit failed!"); - break; - case BSKILL_CREATECHAT: - msg = _("Chat creating failed!"); - break; - case BSKILL_JOINPARTY: - msg = _("Could not join party!"); - break; - case BSKILL_SHOUT: - msg = _("Cannot shout!"); - break; - } - - msg += " "; - - switch (reason) - { - case RFAIL_SKILLDEP: - msg += _("You have not yet reached a high enough lvl!"); - break; - case RFAIL_INSUFHP: - msg += _("Insufficient HP!"); - break; - case RFAIL_INSUFSP: - msg += _("Insufficient SP!"); - break; - case RFAIL_NOMEMO: - msg += _("You have no memos!"); - break; - case RFAIL_SKILLDELAY: - msg += _("You cannot do that right now!"); - break; - case RFAIL_ZENY: - msg += _("Seems you need more money... ;-)"); - break; - case RFAIL_WEAPON: - msg += _("You cannot use this skill with that kind of weapon!"); - break; - case RFAIL_REDGEM: - msg += _("You need another red gem!"); - break; - case RFAIL_BLUEGEM: - msg += _("You need another blue gem!"); - break; - case RFAIL_OVERWEIGHT: - msg += _("You're carrying to much to do this!"); - break; - default: - msg += _("Huh? What's that?"); - break; - } - } - else - { - switch (skillId) - { - case SKILL_WARP: - msg = _("Warp failed..."); - break; - case SKILL_STEAL: - msg = _("Could not steal anything..."); - break; - case SKILL_ENVENOM: - msg = _("Poison had no effect..."); - break; - } - } - - serverNotice(msg); - break; - } -} - -void SpecialHandler::use(int id) -{ -} - -void SpecialHandler::use(int id, int level, int beingId) -{ -} - -void SpecialHandler::use(int id, int level, int x, int y) -{ -} - -void SpecialHandler::use(int id, const std::string &map) -{ -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/specialhandler.h b/src/net/tmwa/specialhandler.h deleted file mode 100644 index 2448b7e0..00000000 --- a/src/net/tmwa/specialhandler.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * The Mana Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2012 The Mana Developers - * - * This file is part of The Mana 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 - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include "net/net.h" -#include "net/specialhandler.h" - -#include "net/tmwa/messagehandler.h" - -namespace TmwAthena { - -class SpecialHandler final : public MessageHandler, public Net::SpecialHandler -{ - public: - SpecialHandler(); - - void handleMessage(MessageIn &msg) override; - - void use(int id) override; - - void use(int id, int level, int beingId) override; - - void use(int id, int level, int x, int y) override; - - void use(int id, const std::string &map) override; -}; - -} // namespace TmwAthena -- cgit v1.2.3-70-g09d2