diff options
Diffstat (limited to 'src/net/tmwa')
117 files changed, 0 insertions, 13514 deletions
diff --git a/src/net/tmwa/adminhandler.cpp b/src/net/tmwa/adminhandler.cpp deleted file mode 100644 index b0d2ebfa3..000000000 --- a/src/net/tmwa/adminhandler.cpp +++ /dev/null @@ -1,299 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/adminhandler.h" - -#include "game.h" - -#include "net/tmwa/messageout.h" -#include "net/tmwa/protocolout.h" - -#include "utils/gmfunctions.h" -#include "utils/stringutils.h" - -#include "debug.h" - -namespace TmwAthena -{ - -AdminHandler::AdminHandler() : - Ea::AdminHandler() -{ - adminHandler = this; -} - -AdminHandler::~AdminHandler() -{ - adminHandler = nullptr; -} - -void AdminHandler::announce(const std::string &text) const -{ - createOutPacket(CMSG_ADMIN_ANNOUNCE); - outMsg.writeInt16(CAST_S16(text.length() + 4), "len"); - outMsg.writeString(text, CAST_S32(text.length()), "message"); -} - -void AdminHandler::localAnnounce(const std::string &text) const -{ - createOutPacket(CMSG_ADMIN_LOCAL_ANNOUNCE); - outMsg.writeInt16(CAST_S16(text.length() + 4), "len"); - outMsg.writeString(text, CAST_S32(text.length()), "message"); -} - -void AdminHandler::hide(const bool h A_UNUSED) const -{ - createOutPacket(CMSG_ADMIN_HIDE); - outMsg.writeInt32(0, "unused"); -} - -void AdminHandler::kick(const BeingId playerId) const -{ - createOutPacket(CMSG_ADMIN_KICK); - outMsg.writeBeingId(playerId, "account id"); -} - -void AdminHandler::kickAll() const -{ -} - -void AdminHandler::warp(const std::string &map, const int x, const int y) const -{ - Gm::runCommand("warp", - strprintf("%s %d %d", map.c_str(), x, y)); -} - -void AdminHandler::resetStats() const -{ -} - -void AdminHandler::resetSkills() const -{ -} - -void AdminHandler::gotoName(const std::string &name) const -{ - Gm::runCommand("goto", name); -} - -void AdminHandler::recallName(const std::string &name) const -{ - Gm::runCommand("recall", name); -} - -void AdminHandler::mute(const Being *const being A_UNUSED, - const int type A_UNUSED, - const int limit A_UNUSED) const -{ -} - -void AdminHandler::muteName(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::requestLogin(const Being *const being A_UNUSED) const -{ -} - -void AdminHandler::setTileType(const int x A_UNUSED, const int y A_UNUSED, - const int type A_UNUSED) const -{ -} - -void AdminHandler::unequipAll(const Being *const being A_UNUSED) const -{ -} - -void AdminHandler::requestStats(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::monsterInfo(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::itemInfo(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::whoDrops(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::mobSearch(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::mobSpawnSearch(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::playerGmCommands(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::playerCharGmCommands(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::showLevel(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::showStats(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::showStorageList(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::showCartList(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::showInventoryList(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::locatePlayer(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::showAccountInfo(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::spawnSlave(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::spawnClone(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::spawnSlaveClone(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::spawnEvilClone(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::savePosition(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::loadPosition(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::randomWarp(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::gotoNpc(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::killer(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::killable(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::heal(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::alive(const std::string &name) const -{ - Gm::runCommand("revive", name); -} - -void AdminHandler::disguise(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::immortal(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::hide(const std::string &name A_UNUSED) const -{ - Gm::runCommand("hide"); -} - -void AdminHandler::nuke(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::kill(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::jail(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::unjail(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::npcMove(const std::string &name A_UNUSED, - const int x A_UNUSED, - const int y A_UNUSED) const -{ -} - -void AdminHandler::hideNpc(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::showNpc(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::changePartyLeader(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::partyRecall(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::breakGuild(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::guildRecall(const std::string &name A_UNUSED) const -{ -} - -void AdminHandler::slide(const int x, const int y) const -{ - warp(Game::instance()->getCurrentMapName(), x, y); -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/adminhandler.h b/src/net/tmwa/adminhandler.h deleted file mode 100644 index 01e7adcac..000000000 --- a/src/net/tmwa/adminhandler.h +++ /dev/null @@ -1,178 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_ADMINHANDLER_H -#define NET_TMWA_ADMINHANDLER_H - -#include "net/ea/adminhandler.h" - -namespace TmwAthena -{ - -class AdminHandler final : public Ea::AdminHandler -{ - public: - AdminHandler(); - - A_DELETE_COPY(AdminHandler) - - ~AdminHandler(); - - void announce(const std::string &text) const override final; - - void localAnnounce(const std::string &text) const override final; - - void hide(const bool h) const override final; - - void kick(const BeingId playerId) const override final; - - void kickAll() const override final A_CONST; - - void warp(const std::string &map, - const int x, const int y) const override final; - - void resetStats() const override final A_CONST; - - void resetSkills() const override final A_CONST; - - void gotoName(const std::string &name) const override final; - - void recallName(const std::string &name) const override final; - - void mute(const Being *const being, - const int type, - const int limit) const override final A_CONST; - - void muteName(const std::string &name) const override final A_CONST; - - void requestLogin(const Being *const being) const override final - A_CONST; - - void setTileType(const int x, const int y, - const int type) const override final A_CONST; - - void unequipAll(const Being *const being) const override final A_CONST; - - void requestStats(const std::string &name) const override final - A_CONST; - - void monsterInfo(const std::string &name) const override final A_CONST; - - void itemInfo(const std::string &name) const override final A_CONST; - - void whoDrops(const std::string &name) const override final A_CONST; - - void mobSearch(const std::string &name) const override final A_CONST; - - void mobSpawnSearch(const std::string &name) const override final - A_CONST; - - void playerGmCommands(const std::string &name) const override final - A_CONST; - - void playerCharGmCommands(const std::string &name) const override final - A_CONST; - - void showLevel(const std::string &name) const override final A_CONST; - - void showStats(const std::string &name) const override final A_CONST; - - void showStorageList(const std::string &name) const override final - A_CONST; - - void showCartList(const std::string &name) const override final - A_CONST; - - void showInventoryList(const std::string &name) const override final - A_CONST; - - void locatePlayer(const std::string &name) const override final - A_CONST; - - void showAccountInfo(const std::string &name) const override final - A_CONST; - - void spawnSlave(const std::string &name) const override final A_CONST; - - void spawnClone(const std::string &name) const override final A_CONST; - - void spawnSlaveClone(const std::string &name) const override final - A_CONST; - - void spawnEvilClone(const std::string &name) const override final - A_CONST; - - void savePosition(const std::string &name) const override final - A_CONST; - - void loadPosition(const std::string &name) const override final - A_CONST; - - void randomWarp(const std::string &name) const override final A_CONST; - - void gotoNpc(const std::string &name) const override final A_CONST; - - void killer(const std::string &name) const override final A_CONST; - - void killable(const std::string &name) const override final A_CONST; - - void heal(const std::string &name) const override final A_CONST; - - void alive(const std::string &name) const override final; - - void disguise(const std::string &name) const override final A_CONST; - - void immortal(const std::string &name) const override final A_CONST; - - void hide(const std::string &name) const override final; - - void nuke(const std::string &name) const override final A_CONST; - - void kill(const std::string &name) const override final A_CONST; - - void jail(const std::string &name) const override final A_CONST; - - void unjail(const std::string &name) const override final A_CONST; - - void npcMove(const std::string &name, - const int x, - const int y) const override final A_CONST; - - void hideNpc(const std::string &name) const override final A_CONST; - - void showNpc(const std::string &name) const override final A_CONST; - - void changePartyLeader(const std::string &name) const override final - A_CONST; - - void partyRecall(const std::string &name) const override final A_CONST; - - void breakGuild(const std::string &name) const override final A_CONST; - - void guildRecall(const std::string &name) const override final A_CONST; - - void slide(const int x, const int y) const override final; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_ADMINHANDLER_H diff --git a/src/net/tmwa/auctionhandler.cpp b/src/net/tmwa/auctionhandler.cpp deleted file mode 100644 index 1a45e4135..000000000 --- a/src/net/tmwa/auctionhandler.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/auctionhandler.h" - -#include "debug.h" - -namespace TmwAthena -{ - -AuctionHandler::AuctionHandler() -{ - auctionHandler = this; -} - -AuctionHandler::~AuctionHandler() -{ - auctionHandler = nullptr; -} - -void AuctionHandler::cancelReg() const -{ -} - -void AuctionHandler::setItem(const Item *const item A_UNUSED, - const int amount A_UNUSED) const -{ -} - -void AuctionHandler::reg(const int currentPrice A_UNUSED, - const int maxPrice A_UNUSED, - const int hours A_UNUSED) const -{ -} - -void AuctionHandler::cancel(const int auctionId A_UNUSED) const -{ -} - -void AuctionHandler::close(const int auctionId A_UNUSED) const -{ -} - -void AuctionHandler::bid(const int auctionId A_UNUSED, - const int money A_UNUSED) const -{ -} - -void AuctionHandler::search(const AuctionSearchTypeT type A_UNUSED, - const int auctionId A_UNUSED, - const std::string &text A_UNUSED, - const int page A_UNUSED) const -{ -} - -void AuctionHandler::buy() const -{ -} - -void AuctionHandler::sell() const -{ -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/auctionhandler.h b/src/net/tmwa/auctionhandler.h deleted file mode 100644 index 9e88e603d..000000000 --- a/src/net/tmwa/auctionhandler.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_AUCTIONHANDLER_H -#define NET_TMWA_AUCTIONHANDLER_H - -#include "net/auctionhandler.h" - -namespace TmwAthena -{ -class AuctionHandler final : public Net::AuctionHandler -{ - public: - AuctionHandler(); - - A_DELETE_COPY(AuctionHandler) - - ~AuctionHandler(); - - void cancelReg() const override final A_CONST; - - void setItem(const Item *const item, - const int amount) const override final A_CONST; - - void reg(const int currentPrice, - const int maxPrice, - const int hours) const override final A_CONST; - - void cancel(const int auctionId) const override final A_CONST; - - void close(const int auctionId) const override final A_CONST; - - void bid(const int auctionId, - const int money) const override final A_CONST; - - void search(const AuctionSearchTypeT type, - const int auctionId, - const std::string &text, - const int page) const override final A_CONST; - - void buy() const override final A_CONST; - - void sell() const override final A_CONST; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_AUCTIONHANDLER_H diff --git a/src/net/tmwa/bankhandler.cpp b/src/net/tmwa/bankhandler.cpp deleted file mode 100644 index cacab379f..000000000 --- a/src/net/tmwa/bankhandler.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/bankhandler.h" - -#include "debug.h" - -namespace TmwAthena -{ - -BankHandler::BankHandler() : - Net::BankHandler() -{ - bankHandler = this; -} - -BankHandler::~BankHandler() -{ - bankHandler = nullptr; -} - -void BankHandler::deposit(const int money A_UNUSED) const -{ -} - -void BankHandler::withdraw(const int money A_UNUSED) const -{ -} - -void BankHandler::check() const -{ -} - -void BankHandler::open() const -{ -} - -void BankHandler::close() const -{ -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/bankhandler.h b/src/net/tmwa/bankhandler.h deleted file mode 100644 index a99b7d50d..000000000 --- a/src/net/tmwa/bankhandler.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_BANKHANDLER_H -#define NET_TMWA_BANKHANDLER_H - -#include "net/bankhandler.h" - -namespace TmwAthena -{ - -class BankHandler final : public Net::BankHandler -{ - public: - BankHandler(); - - A_DELETE_COPY(BankHandler) - - ~BankHandler(); - - void deposit(const int money) const override final A_CONST; - - void withdraw(const int money) const override final A_CONST; - - void check() const override final A_CONST; - - void open() const override final A_CONST; - - void close() const override final A_CONST; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_BANKHANDLER_H diff --git a/src/net/tmwa/battlegroundhandler.cpp b/src/net/tmwa/battlegroundhandler.cpp deleted file mode 100644 index b8631da1b..000000000 --- a/src/net/tmwa/battlegroundhandler.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/battlegroundhandler.h" - -#include "debug.h" - -namespace TmwAthena -{ - -BattleGroundHandler::BattleGroundHandler() -{ - battleGroundHandler = this; -} - -BattleGroundHandler::~BattleGroundHandler() -{ - battleGroundHandler = nullptr; -} - -void BattleGroundHandler::registerBg(const BattleGroundTypeT &type - A_UNUSED, - const std::string &name A_UNUSED) const -{ -} - -void BattleGroundHandler::rekoveRequest(const std::string &name A_UNUSED) const -{ -} - -void BattleGroundHandler::beginAck(const bool result A_UNUSED, - const std::string &bgName A_UNUSED, - const std::string &gameName A_UNUSED) const -{ -} - -void BattleGroundHandler::checkState(const std::string &name A_UNUSED) const -{ -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/battlegroundhandler.h b/src/net/tmwa/battlegroundhandler.h deleted file mode 100644 index 2a1126589..000000000 --- a/src/net/tmwa/battlegroundhandler.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_BATTLEGROUNDHANDLER_H -#define NET_TMWA_BATTLEGROUNDHANDLER_H - -#include "net/battlegroundhandler.h" - -namespace TmwAthena -{ - -class BattleGroundHandler final : public Net::BattleGroundHandler -{ - public: - BattleGroundHandler(); - - A_DELETE_COPY(BattleGroundHandler) - - ~BattleGroundHandler(); - - void registerBg(const BattleGroundTypeT &type, - const std::string &name) const override final A_CONST; - - void rekoveRequest(const std::string &name) const override final - A_CONST; - - void beginAck(const bool result, - const std::string &bgName, - const std::string &gameName) const override final - A_CONST; - - void checkState(const std::string &name) const override final A_CONST; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_BATTLEGROUNDHANDLER_H diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp deleted file mode 100644 index c4e57627e..000000000 --- a/src/net/tmwa/beinghandler.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/beinghandler.h" - -#include "net/tmwa/messageout.h" -#include "net/tmwa/protocolout.h" -#include "net/tmwa/sprite.h" - -#include "debug.h" - -namespace TmwAthena -{ - -BeingHandler::BeingHandler(const bool enableSync) : - Ea::BeingHandler(enableSync) -{ - beingHandler = this; -} - -BeingHandler::~BeingHandler() -{ - beingHandler = nullptr; -} - -void BeingHandler::requestNameById(const BeingId id) const -{ - createOutPacket(CMSG_NAME_REQUEST); - outMsg.writeBeingId(id, "being id"); -} - -void BeingHandler::undress(Being *const being) const -{ - if (being == nullptr) - return; - being->unSetSprite(SPRITE_WEAPON); - being->unSetSprite(SPRITE_HEAD_BOTTOM); - being->unSetSprite(SPRITE_CLOTHES_COLOR); - being->unSetSprite(SPRITE_HAIR); - being->unSetSprite(SPRITE_SHOES); -} - -void BeingHandler::requestRanks(const RankT rank A_UNUSED) const -{ -} - -void BeingHandler::viewPlayerEquipment(const Being *const being A_UNUSED) const -{ -} - -void BeingHandler::requestNameByCharId(const int id A_UNUSED) const -{ -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/beinghandler.h b/src/net/tmwa/beinghandler.h deleted file mode 100644 index 04cced3ed..000000000 --- a/src/net/tmwa/beinghandler.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_BEINGHANDLER_H -#define NET_TMWA_BEINGHANDLER_H - -#include "net/ea/beinghandler.h" - -namespace TmwAthena -{ - -class BeingHandler final : public Ea::BeingHandler -{ - public: - explicit BeingHandler(const bool enableSync); - - A_DELETE_COPY(BeingHandler) - - ~BeingHandler(); - - void requestNameById(const BeingId id) const override final; - - void undress(Being *const being) const override final; - - void requestRanks(const RankT rank A_UNUSED) const override final - A_CONST; - - void viewPlayerEquipment(const Being *const being) const override final - A_CONST; - - void requestNameByCharId(const int id) const override final A_CONST; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_BEINGHANDLER_H diff --git a/src/net/tmwa/beingrecv.cpp b/src/net/tmwa/beingrecv.cpp deleted file mode 100644 index bb165789d..000000000 --- a/src/net/tmwa/beingrecv.cpp +++ /dev/null @@ -1,1517 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/beingrecv.h" - -#include "actormanager.h" -#include "configuration.h" -#include "effectmanager.h" -#include "guild.h" -#include "party.h" - -#include "being/localplayer.h" - -#include "particle/particleengine.h" - -#include "input/keyboardconfig.h" - -#include "gui/windows/okdialog.h" -#include "gui/windows/outfitwindow.h" -#include "gui/windows/socialwindow.h" - -#include "net/beinghandler.h" -#include "net/serverfeatures.h" - -#include "net/messagein.h" - -#include "net/ea/beingrecv.h" - -#include "net/tmwa/guildmanager.h" -#include "net/tmwa/sprite.h" - -#include "resources/iteminfo.h" - -#include "resources/db/itemdb.h" - -#include "utils/timer.h" - -#include "debug.h" - -extern OkDialog *deathNotice; - -namespace TmwAthena -{ - -static void setGm(Being *const dstBeing, - const uint16_t gmstatus) -{ - if (dstBeing != localPlayer) - { - if ((gmstatus & 0x80) != 0) - { - dstBeing->setGroupId(paths.getIntValue("gmDefaultLevel")); - dstBeing->setGM(true); - } - else - { - dstBeing->setGroupId(0); - dstBeing->setGM(false); - } - } - else - { - if ((gmstatus & 0x80) != 0) - dstBeing->setGM(true); - else - dstBeing->setGM(false); - } -} - -void BeingRecv::processBeingChangeLook(Net::MessageIn &msg) -{ - BLOCK_START("BeingRecv::processBeingChangeLook") - if (actorManager == nullptr) - { - BLOCK_END("BeingRecv::processBeingChangeLook") - return; - } - - Being *const dstBeing = actorManager->findBeing( - msg.readBeingId("being id")); - - const uint8_t type = msg.readUInt8("type"); - const int16_t id = CAST_S16(msg.readUInt8("id")); - const int id2 = 1; - - if ((localPlayer == nullptr) || (dstBeing == nullptr)) - { - BLOCK_END("BeingRecv::processBeingChangeLook") - return; - } - processBeingChangeLookContinue(msg, dstBeing, type, id, id2); - BLOCK_END("BeingRecv::processBeingChangeLook") -} - -void BeingRecv::processBeingChangeLook2(Net::MessageIn &msg) -{ - BLOCK_START("BeingRecv::processBeingChangeLook") - if (actorManager == nullptr) - { - BLOCK_END("BeingRecv::processBeingChangeLook") - return; - } - - Being *const dstBeing = actorManager->findBeing( - msg.readBeingId("being id")); - - const uint8_t type = msg.readUInt8("type"); - int id2 = 0; - - const int16_t id = msg.readInt16("id1"); - if (type == 2) - { - id2 = msg.readInt16("id2"); - } - else - { - msg.readInt16("id2"); - id2 = 1; - } - - if ((localPlayer == nullptr) || (dstBeing == nullptr)) - { - BLOCK_END("BeingRecv::processBeingChangeLook") - return; - } - processBeingChangeLookContinue(msg, dstBeing, type, id, id2); - BLOCK_END("BeingRecv::processBeingChangeLook") -} - -void BeingRecv::processBeingChangeLookContinue(const Net::MessageIn &msg, - Being *const dstBeing, - const uint8_t type, - const int id, - const int id2) -{ - if (dstBeing->getType() == ActorType::Player) - dstBeing->setOtherTime(); - - switch (type) - { - case 0: // change race - dstBeing->setSubtype(fromInt(id, BeingTypeId), - dstBeing->getLook()); - break; - case 1: // eAthena LOOK_HAIR - { - const uint16_t look = CAST_U16(id / 256); - const int hair = id % 256; - dstBeing->setHairStyle(SPRITE_HAIR_COLOR, hair * -1); - dstBeing->setLook(look); - break; - } - case 2: // Weapon ID in id, Shield ID in id2 - dstBeing->setSpriteId(SPRITE_BODY, - id); - dstBeing->setWeaponId(id); - dstBeing->setSpriteId(SPRITE_FLOOR, - id2); - localPlayer->imitateOutfit(dstBeing, SPRITE_FLOOR); - break; - case 3: // Change lower headgear for eAthena, pants for us - dstBeing->setSpriteId(SPRITE_WEAPON, - id); - localPlayer->imitateOutfit(dstBeing, SPRITE_WEAPON); - break; - case 4: // Change upper headgear for eAthena, hat for us - dstBeing->setSpriteId(SPRITE_CLOTHES_COLOR, - id); - localPlayer->imitateOutfit(dstBeing, SPRITE_CLOTHES_COLOR); - break; - case 5: // Change middle headgear for eathena, armor for us - dstBeing->setSpriteId(SPRITE_HEAD_BOTTOM, - id); - localPlayer->imitateOutfit(dstBeing, SPRITE_HEAD_BOTTOM); - break; - case 6: // eAthena LOOK_HAIR_COLOR - dstBeing->setHairColor(SPRITE_HAIR_COLOR, - fromInt(id, ItemColor)); - break; - case 7: // Clothes color - // ignoring it - break; - case 8: // eAthena LOOK_SHIELD - dstBeing->setSpriteId(SPRITE_FLOOR, - id); - localPlayer->imitateOutfit(dstBeing, SPRITE_FLOOR); - break; - case 9: // eAthena LOOK_SHOES - dstBeing->setSpriteId(SPRITE_HAIR, - id); - localPlayer->imitateOutfit(dstBeing, SPRITE_HAIR); - break; - case 10: // LOOK_GLOVES - dstBeing->setSpriteId(SPRITE_SHOES, - id); - localPlayer->imitateOutfit(dstBeing, SPRITE_SHOES); - break; - case 11: // LOOK_CAPE - dstBeing->setSpriteId(SPRITE_SHIELD, - id); - localPlayer->imitateOutfit(dstBeing, SPRITE_SHIELD); - break; - case 12: - dstBeing->setSpriteId(SPRITE_HEAD_TOP, - id); - localPlayer->imitateOutfit(dstBeing, SPRITE_HEAD_TOP); - break; - case 13: - dstBeing->setSpriteId(SPRITE_HEAD_MID, - id); - localPlayer->imitateOutfit(dstBeing, SPRITE_HEAD_MID); - break; - case 14: - dstBeing->setSpriteId(SPRITE_ROBE, - id); - localPlayer->imitateOutfit(dstBeing, SPRITE_ROBE); - break; - case 15: - dstBeing->setSpriteId(SPRITE_EVOL2, - id); - localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL2); - break; - case 16: - dstBeing->setLook(CAST_U16(id)); - break; - default: - UNIMPLEMENTEDPACKETFIELD(type); - break; - } -} - -void BeingRecv::processPlayerUpdate1(Net::MessageIn &msg) -{ - BLOCK_START("BeingRecv::processPlayerMoveUpdate") - if ((actorManager == nullptr) || (localPlayer == nullptr)) - { - BLOCK_END("BeingRecv::processPlayerMoveUpdate") - return; - } - - // An update about a player, potentially including movement. - const BeingId id = msg.readBeingId("account id"); - const int16_t speed = msg.readInt16("speed"); - const uint32_t opt1 = msg.readInt16("opt1"); - const uint32_t opt2 = msg.readInt16("opt2"); - const uint32_t option = msg.readInt16("option"); - const int16_t job = msg.readInt16("job"); - int disguiseId = 0; - if (toInt(id, int) < 110000000 && job >= 1000) - disguiseId = job; - - Being *dstBeing = actorManager->findBeing(id); - if (dstBeing == nullptr) - { - if (actorManager->isBlocked(id) == true) - { - BLOCK_END("BeingRecv::processPlayerMoveUpdate") - return; - } - - dstBeing = Ea::BeingRecv::createBeing(id, job); - - if (dstBeing == nullptr) - { - BLOCK_END("BeingRecv::processPlayerMoveUpdate") - return; - } - } - else if (disguiseId != 0) - { - actorManager->undelete(dstBeing); - beingHandler->requestNameById(id); - } - - uint8_t dir = dstBeing->getDirectionDelayed(); - if (dir != 0u) - { - if (dir != dstBeing->getDirection()) - dstBeing->setDirection(dir); - } - - if (Party *const party = localPlayer->getParty()) - { - if (party->isMember(id)) - dstBeing->setParty(party); - } - - dstBeing->setWalkSpeed(speed); - - const uint8_t hairStyle = msg.readUInt8("hair style"); - const uint16_t look = msg.readUInt8("look"); - dstBeing->setSubtype(fromInt(job, BeingTypeId), look); - const uint16_t weapon = msg.readInt16("weapon"); - const uint16_t shield = msg.readInt16("shield"); - const uint16_t headBottom = msg.readInt16("head bottom"); - - const uint16_t headTop = msg.readInt16("head top"); - const uint16_t headMid = msg.readInt16("head mid"); - const ItemColor hairColor = fromInt( - msg.readUInt8("hair color"), ItemColor); - msg.readUInt8("unused"); - msg.readInt32("unused"); - - const int guild = msg.readInt32("guild"); - - if ((guildManager == nullptr) || !GuildManager::getEnableGuildBot()) - { - if (guild == 0) - dstBeing->clearGuilds(); - else - dstBeing->setGuild(Guild::getGuild(CAST_S16(guild))); - } - - msg.readInt16("emblem"); - dstBeing->setManner(msg.readInt16("manner")); - const uint32_t opt3 = msg.readInt16("opt3"); - dstBeing->setKarma(msg.readUInt8("karma")); - // reserving bit for future usage - dstBeing->setGender(Being::intToGender( - CAST_U8(msg.readUInt8("gender") & 3))); - - if (disguiseId == 0) - { - // Set these after the gender, as the sprites may be gender-specific - dstBeing->updateSprite(SPRITE_BODY, - weapon, - ""); - dstBeing->setWeaponId(weapon); - dstBeing->updateSprite(SPRITE_FLOOR, shield); - dstBeing->updateSprite(SPRITE_WEAPON, headBottom); - dstBeing->updateSprite(SPRITE_HEAD_BOTTOM, headMid); - dstBeing->updateSprite(SPRITE_CLOTHES_COLOR, headTop); - if (hairStyle == 0) - { - dstBeing->updateSprite(SPRITE_HAIR_COLOR, - 0, - std::string()); - } - else - { - dstBeing->updateSprite(SPRITE_HAIR_COLOR, - hairStyle * -1, - ItemDB::get(-hairStyle).getDyeColorsString(hairColor)); - } - dstBeing->setHairColor(hairColor); - } - localPlayer->imitateOutfit(dstBeing); - - uint16_t x, y; - msg.readCoordinates(x, y, dir, "position"); - dstBeing->setTileCoords(x, y); - dstBeing->setDirection(dir); - - localPlayer->imitateDirection(dstBeing, dir); - - const uint16_t gmstatus = msg.readInt16("gm status"); - - setGm(dstBeing, gmstatus); - - applyPlayerAction(msg, dstBeing, msg.readUInt8("action type")); - const int level = CAST_S32(msg.readUInt8("level")); - if (level != 0) - dstBeing->setLevel(level); - - msg.readUInt8("unused"); - - dstBeing->setActionTime(tick_time); - - dstBeing->setStatusEffectOpitons(option, - opt1, - opt2, - opt3); - - BLOCK_END("BeingRecv::processPlayerMoveUpdate") -} - -void BeingRecv::processPlayerUpdate2(Net::MessageIn &msg) -{ - BLOCK_START("BeingRecv::processPlayerMoveUpdate") - if ((actorManager == nullptr) || (localPlayer == nullptr)) - { - BLOCK_END("BeingRecv::processPlayerMoveUpdate") - return; - } - - // An update about a player, potentially including movement. - const BeingId id = msg.readBeingId("account id"); - const int16_t speed = msg.readInt16("speed"); - const uint32_t opt1 = msg.readInt16("opt1"); - const uint32_t opt2 = msg.readInt16("opt2"); - const uint32_t option = msg.readInt16("option"); - const int16_t job = msg.readInt16("job"); - int disguiseId = 0; - if (toInt(id, int) < 110000000 && job >= 1000) - disguiseId = job; - - Being *dstBeing = actorManager->findBeing(id); - if (dstBeing == nullptr) - { - if (actorManager->isBlocked(id) == true) - { - BLOCK_END("BeingRecv::processPlayerMoveUpdate") - return; - } - - dstBeing = Ea::BeingRecv::createBeing(id, job); - - if (dstBeing == nullptr) - { - BLOCK_END("BeingRecv::processPlayerMoveUpdate") - return; - } - } - else if (disguiseId != 0) - { - actorManager->undelete(dstBeing); - beingHandler->requestNameById(id); - } - - uint8_t dir = dstBeing->getDirectionDelayed(); - if (dir != 0u) - { - if (dir != dstBeing->getDirection()) - dstBeing->setDirection(dir); - } - - if (Party *const party = localPlayer->getParty()) - { - if (party->isMember(id)) - dstBeing->setParty(party); - } - - dstBeing->setWalkSpeed(speed); - - const uint8_t hairStyle = msg.readUInt8("hair style"); - const uint16_t look = msg.readUInt8("look"); - dstBeing->setSubtype(fromInt(job, BeingTypeId), look); - const uint16_t weapon = msg.readInt16("weapon"); - const uint16_t shield = msg.readInt16("shield"); - const uint16_t headBottom = msg.readInt16("head bottom"); - const uint16_t headTop = msg.readInt16("head top"); - const uint16_t headMid = msg.readInt16("head mid"); - const ItemColor hairColor = fromInt( - msg.readUInt8("hair color"), ItemColor); - msg.readUInt8("unused"); - msg.readInt32("unused"); - - const int guild = msg.readInt32("guild"); - - if ((guildManager == nullptr) || !GuildManager::getEnableGuildBot()) - { - if (guild == 0) - dstBeing->clearGuilds(); - else - dstBeing->setGuild(Guild::getGuild(CAST_S16(guild))); - } - - msg.readInt16("emblem"); - dstBeing->setManner(msg.readInt16("manner")); - const uint32_t opt3 = msg.readInt16("opt3"); - dstBeing->setKarma(msg.readUInt8("karma")); - // reserving bit for future usage - dstBeing->setGender(Being::intToGender( - CAST_U8(msg.readUInt8("gender") & 3))); - - if (disguiseId == 0) - { - // Set these after the gender, as the sprites may be gender-specific - dstBeing->updateSprite(SPRITE_BODY, - weapon, - ""); - dstBeing->setWeaponId(weapon); - dstBeing->updateSprite(SPRITE_FLOOR, shield); - dstBeing->updateSprite(SPRITE_WEAPON, headBottom); - dstBeing->updateSprite(SPRITE_HEAD_BOTTOM, headMid); - dstBeing->updateSprite(SPRITE_CLOTHES_COLOR, headTop); - if (hairStyle == 0) - { - dstBeing->updateSprite(SPRITE_HAIR_COLOR, - 0, - std::string()); - } - else - { - dstBeing->updateSprite(SPRITE_HAIR_COLOR, - hairStyle * -1, - ItemDB::get(-hairStyle).getDyeColorsString(hairColor)); - } - dstBeing->setHairColor(hairColor); - } - localPlayer->imitateOutfit(dstBeing); - - uint16_t x, y; - msg.readCoordinates(x, y, dir, "position"); - dstBeing->setTileCoords(x, y); - dstBeing->setDirection(dir); - - localPlayer->imitateDirection(dstBeing, dir); - - const uint16_t gmstatus = msg.readInt16("gm status"); - - setGm(dstBeing, gmstatus); - - applyPlayerAction(msg, dstBeing, msg.readUInt8("action type")); - const int level = CAST_S32(msg.readUInt8("level")); - if (level != 0) - dstBeing->setLevel(level); - - dstBeing->setActionTime(tick_time); - dstBeing->setStatusEffectOpitons(option, - opt1, - opt2, - opt3); - - BLOCK_END("BeingRecv::processPlayerMoveUpdate") -} - -void BeingRecv::processPlayerMove(Net::MessageIn &msg) -{ - BLOCK_START("BeingRecv::processPlayerMoveUpdate") - if ((actorManager == nullptr) || (localPlayer == nullptr)) - { - BLOCK_END("BeingRecv::processPlayerMoveUpdate") - return; - } - - // An update about a player, potentially including movement. - const BeingId id = msg.readBeingId("account id"); - const int16_t speed = msg.readInt16("speed"); - const uint32_t opt1 = msg.readInt16("opt1"); - const uint32_t opt2 = msg.readInt16("opt2"); - const uint32_t option = msg.readInt16("option"); - const int16_t job = msg.readInt16("job"); - int disguiseId = 0; - if (toInt(id, int) < 110000000 && job >= 1000) - disguiseId = job; - - Being *dstBeing = actorManager->findBeing(id); - if (dstBeing == nullptr) - { - if (actorManager->isBlocked(id) == true) - { - BLOCK_END("BeingRecv::processPlayerMoveUpdate") - return; - } - - dstBeing = Ea::BeingRecv::createBeing(id, job); - - if (dstBeing == nullptr) - { - BLOCK_END("BeingRecv::processPlayerMoveUpdate") - return; - } - } - else if (disguiseId != 0) - { - actorManager->undelete(dstBeing); - beingHandler->requestNameById(id); - } - - const uint8_t dir = dstBeing->getDirectionDelayed(); - if (dir != 0u) - { - if (dir != dstBeing->getDirection()) - dstBeing->setDirection(dir); - } - - if (Party *const party = localPlayer->getParty()) - { - if (party->isMember(id)) - dstBeing->setParty(party); - } - - dstBeing->setWalkSpeed(speed); - - const uint8_t hairStyle = msg.readUInt8("hair style"); - const uint16_t look = msg.readUInt8("look"); - dstBeing->setSubtype(fromInt(job, BeingTypeId), look); - const uint16_t weapon = msg.readInt16("weapon"); - const uint16_t shield = msg.readInt16("shield"); - const uint16_t headBottom = msg.readInt16("head bottom"); - - msg.readInt32("tick"); - - const uint16_t headTop = msg.readInt16("head top"); - const uint16_t headMid = msg.readInt16("head mid"); - const ItemColor hairColor = fromInt( - msg.readUInt8("hair color"), ItemColor); - msg.readUInt8("unused"); - msg.readInt32("unused"); - - const int guild = msg.readInt32("guild"); - - if ((guildManager == nullptr) || !GuildManager::getEnableGuildBot()) - { - if (guild == 0) - dstBeing->clearGuilds(); - else - dstBeing->setGuild(Guild::getGuild(CAST_S16(guild))); - } - - msg.readInt16("emblem"); - dstBeing->setManner(msg.readInt16("manner")); - const uint32_t opt3 = msg.readInt16("opt3"); - dstBeing->setKarma(msg.readUInt8("karma")); - // reserving bit for future usage - dstBeing->setGender(Being::intToGender( - CAST_U8(msg.readUInt8("gender") & 3))); - - if (disguiseId == 0) - { - // Set these after the gender, as the sprites may be gender-specific - dstBeing->updateSprite(SPRITE_BODY, - weapon, - ""); - dstBeing->setWeaponId(weapon); - dstBeing->updateSprite(SPRITE_FLOOR, shield); - dstBeing->updateSprite(SPRITE_WEAPON, headBottom); - dstBeing->updateSprite(SPRITE_HEAD_BOTTOM, headMid); - dstBeing->updateSprite(SPRITE_CLOTHES_COLOR, headTop); - if (hairStyle == 0) - { - dstBeing->updateSprite(SPRITE_HAIR_COLOR, - 0, - std::string()); - } - else - { - dstBeing->updateSprite(SPRITE_HAIR_COLOR, - hairStyle * -1, - ItemDB::get(-hairStyle).getDyeColorsString(hairColor)); - } - dstBeing->setHairColor(hairColor); - } - localPlayer->imitateOutfit(dstBeing); - - uint16_t srcX, srcY, dstX, dstY; - msg.readCoordinatePair(srcX, srcY, dstX, dstY, "moving path"); - - localPlayer->followMoveTo(dstBeing, srcX, srcY, dstX, dstY); - - dstBeing->setTileCoords(srcX, srcY); - dstBeing->setDestination(dstX, dstY); - - // because server don't send direction in move packet, - // we fixing it - - if (srcX != dstX || srcY != dstY) - { - const int d = dstBeing->calcDirection(dstX, dstY); - - if ((d != 0) && dstBeing->getDirection() != d) - dstBeing->setDirectionDelayed(CAST_U8(d)); - } - - if (localPlayer->getCurrentAction() != BeingAction::STAND) - localPlayer->imitateAction(dstBeing, BeingAction::STAND); - if (localPlayer->getDirection() != dstBeing->getDirection()) - { - localPlayer->imitateDirection(dstBeing, - dstBeing->getDirection()); - } - - const uint16_t gmstatus = msg.readInt16("gm status"); - - setGm(dstBeing, gmstatus); - - msg.readUInt8("unused"); - - const int level = CAST_S32(msg.readUInt8("level")); - if (level != 0) - dstBeing->setLevel(level); - - msg.readUInt8("unused"); - - if (dstBeing->getType() != ActorType::Player) - dstBeing->setActionTime(tick_time); - - dstBeing->setStatusEffectOpitons(option, - opt1, - opt2, - opt3); - - if (dstBeing->getType() == ActorType::Player) - dstBeing->setMoveTime(); - BLOCK_END("BeingRecv::processPlayerMoveUpdate") -} - -void BeingRecv::processBeingVisible(Net::MessageIn &msg) -{ - BLOCK_START("BeingRecv::processBeingVisibleOrMove") - if (actorManager == nullptr) - { - BLOCK_END("BeingRecv::processBeingVisibleOrMove") - return; - } - - BeingId spawnId; - - // Information about a being in range - const BeingId id = msg.readBeingId("being id"); - if (id == Ea::BeingRecv::mSpawnId) - spawnId = Ea::BeingRecv::mSpawnId; - else - spawnId = BeingId_zero; - Ea::BeingRecv::mSpawnId = BeingId_zero; - int16_t speed = msg.readInt16("speed"); - const uint32_t opt1 = msg.readInt16("opt1"); - const uint32_t opt2 = msg.readInt16("opt2"); - const uint32_t option = msg.readInt16("option"); - const int16_t job = msg.readInt16("class"); - int disguiseId = 0; - if (id == localPlayer->getId() && job >= 1000) - disguiseId = job; - - Being *dstBeing = actorManager->findBeing(id); - - if ((dstBeing != nullptr) && dstBeing->getType() == ActorType::Monster - && !dstBeing->isAlive()) - { - actorManager->destroy(dstBeing); - actorManager->erase(dstBeing); - dstBeing = nullptr; - } - - if (dstBeing == nullptr) - { - // Being with id >= 110000000 and job 0 are better - // known as ghosts, so don't create those. - if (job == 0 && toInt(id, int) >= 110000000) - { - BLOCK_END("BeingRecv::processBeingVisibleOrMove") - return; - } - - if (actorManager->isBlocked(id) == true) - { - BLOCK_END("BeingRecv::processBeingVisibleOrMove") - return; - } - - dstBeing = Ea::BeingRecv::createBeing(id, job); - - if (dstBeing == nullptr) - { - BLOCK_END("BeingRecv::processBeingVisibleOrMove") - return; - } - } - else - { - if (dstBeing->getType() == ActorType::Npc) - { - actorManager->undelete(dstBeing); - beingHandler->requestNameById(id); - } - } - - if (dstBeing->getType() == ActorType::Player) - dstBeing->setMoveTime(); - - if (spawnId != BeingId_zero) - { - dstBeing->setAction(BeingAction::SPAWN, 0); - } - else - { - dstBeing->clearPath(); - dstBeing->setActionTime(tick_time); - dstBeing->setAction(BeingAction::STAND, 0); - } - - // Prevent division by 0 when calculating frame - if (speed == 0) - speed = 150; - - const uint8_t hairStyle = msg.readUInt8("hair style"); - const uint16_t look = msg.readUInt8("look"); - dstBeing->setSubtype(fromInt(job, BeingTypeId), look); - if (dstBeing->getType() == ActorType::Monster && (localPlayer != nullptr)) - localPlayer->checkNewName(dstBeing); - dstBeing->setWalkSpeed(speed); - const uint16_t weapon = msg.readInt16("weapon"); - const uint16_t headBottom = msg.readInt16("head bottom"); - - const uint16_t shield = msg.readInt16("shield"); - const uint16_t headTop = msg.readInt16("head top"); - const uint16_t headMid = msg.readInt16("head mid"); - const ItemColor hairColor = fromInt(msg.readUInt8("hair color"), - ItemColor); - msg.readUInt8("unused"); - const uint16_t shoes = msg.readInt16("shoes / clothes color"); - - uint16_t gloves; - if (dstBeing->getType() == ActorType::Monster) - { - if (serverFeatures->haveServerHp()) - { - const int hp = msg.readInt32("hp"); - const int maxHP = msg.readInt32("max hp"); - if ((hp != 0) && (maxHP != 0)) - { - dstBeing->setMaxHP(maxHP); - const int oldHP = dstBeing->getHP(); - if ((oldHP == 0) || oldHP > hp) - dstBeing->setHP(hp); - } - } - else - { - msg.readInt32("unused"); - msg.readInt32("unused"); - } - gloves = 0; - } - else - { - gloves = msg.readInt16("gloves / head dir"); - msg.readInt32("guild"); - msg.readInt16("guild emblem"); - } - - dstBeing->setManner(msg.readInt16("manner")); - const uint32_t opt3 = msg.readInt16("opt3"); - if (serverFeatures->haveMonsterAttackRange() - && dstBeing->getType() == ActorType::Monster) - { - const int attackRange = CAST_S32( - msg.readUInt8("attack range (was karma)")); - dstBeing->setAttackRange(attackRange); - } - else - { - dstBeing->setKarma(msg.readUInt8("karma")); - } - uint8_t gender = msg.readUInt8("gender"); - - if ((disguiseId == 0) && dstBeing->getType() == ActorType::Player) - { - // reserving bits for future usage - gender &= 3; - dstBeing->setGender(Being::intToGender(gender)); - // Set these after the gender, as the sprites may be gender-specific - if (hairStyle == 0) - { - dstBeing->updateSprite(SPRITE_HAIR_COLOR, 0); - } - else - { - dstBeing->updateSprite(SPRITE_HAIR_COLOR, - hairStyle * -1, - ItemDB::get(-hairStyle).getDyeColorsString(hairColor)); - } - dstBeing->setHairColor(hairColor); - dstBeing->updateSprite(SPRITE_WEAPON, headBottom); - dstBeing->updateSprite(SPRITE_HEAD_BOTTOM, headMid); - dstBeing->updateSprite(SPRITE_CLOTHES_COLOR, headTop); - dstBeing->updateSprite(SPRITE_HAIR, shoes); - dstBeing->updateSprite(SPRITE_SHOES, gloves); - dstBeing->updateSprite(SPRITE_BODY, weapon); - dstBeing->setWeaponId(weapon); - dstBeing->updateSprite(SPRITE_FLOOR, shield); - } - else if (dstBeing->getType() == ActorType::Npc - && serverFeatures->haveNpcGender()) - { - setServerGender(dstBeing, gender); - } - - uint8_t dir; - uint16_t x, y; - msg.readCoordinates(x, y, dir, "position"); - dstBeing->setTileCoords(x, y); - - if (job == 45 && (socialWindow != nullptr) && (outfitWindow != nullptr)) - { - const int num = socialWindow->getPortalIndex(x, y); - if (num >= 0) - { - dstBeing->setName(KeyboardConfig::getKeyShortString( - OutfitWindow::keyName(num))); - } - else - { - dstBeing->setName(""); - } - } - - dstBeing->setDirection(dir); - - msg.readUInt8("unknown"); - msg.readUInt8("unknown"); - msg.readUInt8("unknown"); - msg.readUInt8("unknown"); - msg.readUInt8("unknown"); - - dstBeing->setStatusEffectOpitons(option, - opt1, - opt2, - opt3); - BLOCK_END("BeingRecv::processBeingVisibleOrMove") -} - -void BeingRecv::processBeingMove(Net::MessageIn &msg) -{ - BLOCK_START("BeingRecv::processBeingVisibleOrMove") - if (actorManager == nullptr) - { - BLOCK_END("BeingRecv::processBeingVisibleOrMove") - return; - } - - BeingId spawnId; - - // Information about a being in range - const BeingId id = msg.readBeingId("being id"); - if (id == Ea::BeingRecv::mSpawnId) - spawnId = Ea::BeingRecv::mSpawnId; - else - spawnId = BeingId_zero; - Ea::BeingRecv::mSpawnId = BeingId_zero; - int16_t speed = msg.readInt16("speed"); - const uint32_t opt1 = msg.readInt16("opt1"); - const uint32_t opt2 = msg.readInt16("opt2"); - const uint32_t option = msg.readInt16("option"); - const int16_t job = msg.readInt16("class"); - int disguiseId = 0; - if (id == localPlayer->getId() && job >= 1000) - disguiseId = job; - - Being *dstBeing = actorManager->findBeing(id); - - if ((dstBeing != nullptr) && dstBeing->getType() == ActorType::Monster - && !dstBeing->isAlive()) - { - actorManager->destroy(dstBeing); - actorManager->erase(dstBeing); - dstBeing = nullptr; - } - - if (dstBeing == nullptr) - { - // Being with id >= 110000000 and job 0 are better - // known as ghosts, so don't create those. - if (job == 0 && toInt(id, int) >= 110000000) - { - BLOCK_END("BeingRecv::processBeingVisibleOrMove") - return; - } - - if (actorManager->isBlocked(id) == true) - { - BLOCK_END("BeingRecv::processBeingVisibleOrMove") - return; - } - - dstBeing = Ea::BeingRecv::createBeing(id, job); - - if (dstBeing == nullptr) - { - BLOCK_END("BeingRecv::processBeingVisibleOrMove") - return; - } - } - else - { - if (dstBeing->getType() == ActorType::Npc) - { - actorManager->undelete(dstBeing); - beingHandler->requestNameById(id); - } - } - - if (dstBeing->getType() == ActorType::Player) - dstBeing->setMoveTime(); - - if (spawnId != BeingId_zero) - dstBeing->setAction(BeingAction::SPAWN, 0); - - // Prevent division by 0 when calculating frame - if (speed == 0) - speed = 150; - - const uint8_t hairStyle = msg.readUInt8("hair style"); - const uint16_t look = msg.readUInt8("look"); - dstBeing->setSubtype(fromInt(job, BeingTypeId), look); - if (dstBeing->getType() == ActorType::Monster && (localPlayer != nullptr)) - localPlayer->checkNewName(dstBeing); - dstBeing->setWalkSpeed(speed); - const uint16_t weapon = msg.readInt16("weapon"); - const uint16_t headBottom = msg.readInt16("head bottom"); - - msg.readInt32("tick"); - - const uint16_t shield = msg.readInt16("shield"); - const uint16_t headTop = msg.readInt16("head top"); - const uint16_t headMid = msg.readInt16("head mid"); - const ItemColor hairColor = fromInt( - msg.readUInt8("hair color"), ItemColor); - msg.readUInt8("unused"); - const uint16_t shoes = msg.readInt16("shoes / clothes color"); - - uint16_t gloves; - if (dstBeing->getType() == ActorType::Monster) - { - if (serverFeatures->haveServerHp()) - { - const int hp = msg.readInt32("hp"); - const int maxHP = msg.readInt32("max hp"); - if ((hp != 0) && (maxHP != 0)) - { - dstBeing->setMaxHP(maxHP); - const int oldHP = dstBeing->getHP(); - if ((oldHP == 0) || oldHP > hp) - dstBeing->setHP(hp); - } - } - else - { - msg.readInt32("unused"); - msg.readInt32("unused"); - } - gloves = 0; - } - else - { - gloves = msg.readInt16("gloves / head dir"); - msg.readInt32("guild"); - msg.readInt16("guild emblem"); - } - - dstBeing->setManner(msg.readInt16("manner")); - const uint32_t opt3 = msg.readInt16("opt3"); - if (serverFeatures->haveMonsterAttackRange() - && dstBeing->getType() == ActorType::Monster) - { - const int attackRange = CAST_S32( - msg.readUInt8("attack range (was karma)")); - dstBeing->setAttackRange(attackRange); - } - else - { - dstBeing->setKarma(msg.readUInt8("karma")); - } - uint8_t gender = msg.readUInt8("gender"); - - if ((disguiseId == 0) && dstBeing->getType() == ActorType::Player) - { - // reserving bits for future usage - gender &= 3; - dstBeing->setGender(Being::intToGender(gender)); - // Set these after the gender, as the sprites may be gender-specific - if (hairStyle == 0) - { - dstBeing->updateSprite(SPRITE_HAIR_COLOR, 0); - } - else - { - dstBeing->updateSprite(SPRITE_HAIR_COLOR, - hairStyle * -1, - ItemDB::get(-hairStyle).getDyeColorsString(hairColor)); - } - dstBeing->setHairColor(hairColor); - dstBeing->updateSprite(SPRITE_WEAPON, headBottom); - dstBeing->updateSprite(SPRITE_HEAD_BOTTOM, headMid); - dstBeing->updateSprite(SPRITE_CLOTHES_COLOR, headTop); - dstBeing->updateSprite(SPRITE_HAIR, shoes); - dstBeing->updateSprite(SPRITE_SHOES, gloves); - dstBeing->updateSprite(SPRITE_BODY, weapon); - dstBeing->setWeaponId(weapon); - dstBeing->updateSprite(SPRITE_FLOOR, shield); - } - else if (dstBeing->getType() == ActorType::Npc - && serverFeatures->haveNpcGender()) - { - setServerGender(dstBeing, gender); - } - - uint16_t srcX, srcY, dstX, dstY; - msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path"); - if (disguiseId == 0) - { - dstBeing->setAction(BeingAction::STAND, 0); - dstBeing->setTileCoords(srcX, srcY); - if (serverFeatures->haveMove3()) - dstBeing->setCachedDestination(dstX, dstY); - else - dstBeing->setDestination(dstX, dstY); - } - - msg.readUInt8("unknown"); - msg.readUInt8("unknown"); - msg.readUInt8("unknown"); - msg.readUInt8("unknown"); - msg.readUInt8("unknown"); - - dstBeing->setStatusEffectOpitons(option, - opt1, - opt2, - opt3); - BLOCK_END("BeingRecv::processBeingVisibleOrMove") -} - -void BeingRecv::processBeingSpawn(Net::MessageIn &msg) -{ - BLOCK_START("BeingRecv::processBeingSpawn") - // skipping this packet - Ea::BeingRecv::mSpawnId = msg.readBeingId("being id"); - msg.readInt16("speed"); - msg.readInt16("opt1"); - msg.readInt16("opt2"); - msg.readInt16("option"); - msg.readInt16("disguise"); - msg.skip(25, "unused"); - BLOCK_END("BeingRecv::processBeingSpawn") -} - -void BeingRecv::processSkillCasting(Net::MessageIn &msg) -{ - msg.readInt32("src id"); - msg.readInt32("dst id"); - msg.readInt16("dst x"); - msg.readInt16("dst y"); - msg.readInt16("skill num"); - msg.readInt32("skill get p1"); - msg.readInt32("cast time"); -} - -void BeingRecv::processBeingStatusChange(Net::MessageIn &msg) -{ - BLOCK_START("BeingRecv::processBeingStatusChange") - if (actorManager == nullptr) - { - BLOCK_END("BeingRecv::processBeingStatusChange") - return; - } - - // Status change - const uint16_t status = msg.readInt16("status"); - const BeingId id = msg.readBeingId("being id"); - const Enable flag = fromBool( - msg.readUInt8("flag: 0: stop, 1: start"), Enable); - - Being *const dstBeing = actorManager->findBeing(id); - if (dstBeing != nullptr) - { - // dont know on legacy servers is effect really started - // or not. Because this always sending IsStart_true - dstBeing->setStatusEffect(status, flag, IsStart_true); - } - BLOCK_END("BeingRecv::processBeingStatusChange") -} - -void BeingRecv::processBeingMove2(Net::MessageIn &msg) -{ - BLOCK_START("BeingRecv::processBeingMove2") - if (actorManager == nullptr) - { - BLOCK_END("BeingRecv::processBeingMove2") - return; - } - - /* - * A simplified movement packet, used by the - * later versions of eAthena for both mobs and - * players - */ - Being *const dstBeing = actorManager->findBeing( - msg.readBeingId("being id")); - - /* - * This packet doesn't have enough info to actually - * create a new being, so if the being isn't found, - * we'll just pretend the packet didn't happen - */ - - if (dstBeing == nullptr) - { - BLOCK_END("BeingRecv::processBeingMove2") - return; - } - - uint16_t srcX, srcY, dstX, dstY; - msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path"); - msg.readInt32("tick"); - - dstBeing->setAction(BeingAction::STAND, 0); - dstBeing->setTileCoords(srcX, srcY); - dstBeing->setDestination(dstX, dstY); - if (dstBeing->getType() == ActorType::Player) - dstBeing->setMoveTime(); - BLOCK_END("BeingRecv::processBeingMove2") -} - -void BeingRecv::processBeingChangeDirection(Net::MessageIn &msg) -{ - BLOCK_START("BeingRecv::processBeingChangeDirection") - if (actorManager == nullptr) - { - BLOCK_END("BeingRecv::processBeingChangeDirection") - return; - } - - Being *const dstBeing = actorManager->findBeing( - msg.readBeingId("being id")); - - if (dstBeing == nullptr) - { - DEBUGLOGSTR("invisible player?"); - msg.readInt16("unused"); - msg.readUInt8("direction"); - BLOCK_END("BeingRecv::processBeingChangeDirection"); - return; - } - - msg.readInt16("unused"); - - const uint8_t dir = Net::MessageIn::fromServerDirection( - CAST_U8(msg.readUInt8("direction") & 0x0FU)); - dstBeing->setDirection(dir); - if (localPlayer != nullptr) - localPlayer->imitateDirection(dstBeing, dir); - BLOCK_END("BeingRecv::processBeingChangeDirection") -} - -void BeingRecv::processPlayerStatusChange(Net::MessageIn &msg) -{ - BLOCK_START("BeingRecv::processPlayerStop") - if (actorManager == nullptr) - { - BLOCK_END("BeingRecv::processPlayerStop") - return; - } - - // Change in players' flags - const BeingId id = msg.readBeingId("account id"); - Being *const dstBeing = actorManager->findBeing(id); - if (dstBeing == nullptr) - { - DEBUGLOGSTR("invisible player?"); - msg.readInt16("stun mode"); - msg.readInt16("status effect"); - msg.readInt16("opt?"); - msg.readUInt8("Unused?"); - return; - } - - const uint32_t opt1 = msg.readInt16("opt1"); - const uint32_t opt2 = msg.readInt16("opt2"); - const uint32_t option = msg.readInt16("option"); - msg.readUInt8("Unused?"); - - dstBeing->setStatusEffectOpitons(option, - opt1, - opt2); - BLOCK_END("BeingRecv::processPlayerStop") -} - -void BeingRecv::processBeingResurrect(Net::MessageIn &msg) -{ - BLOCK_START("BeingRecv::processBeingResurrect") - if (actorManager == nullptr || localPlayer == nullptr) - { - BLOCK_END("BeingRecv::processBeingResurrect") - return; - } - - // A being changed mortality status - - const BeingId id = msg.readBeingId("being id"); - Being *const dstBeing = actorManager->findBeing(id); - if (dstBeing == nullptr) - { - DEBUGLOGSTR("insible player?"); - msg.readInt16("flag?"); - BLOCK_END("BeingRecv::processBeingResurrect") - return; - } - - // If this is player's current target, clear it. - if (dstBeing == localPlayer->getTarget()) - localPlayer->stopAttack(); - if (dstBeing == localPlayer && - deathNotice != nullptr) - { - deathNotice->scheduleDelete(); - deathNotice = nullptr; - } - - if (msg.readInt16("flag?") == 1) - dstBeing->setAction(BeingAction::STAND, 0); - BLOCK_END("BeingRecv::processBeingResurrect") -} - -void BeingRecv::processPlayerGuilPartyInfo(Net::MessageIn &msg) -{ - BLOCK_START("BeingRecv::processPlayerGuilPartyInfo") - if (actorManager == nullptr) - { - BLOCK_END("BeingRecv::processPlayerGuilPartyInfo") - return; - } - - Being *const dstBeing = actorManager->findBeing( - msg.readBeingId("being id")); - - if (dstBeing != nullptr) - { - dstBeing->setPartyName(msg.readString(24, "party name")); - if ((guildManager == nullptr) || !GuildManager::getEnableGuildBot()) - { - dstBeing->setGuildName(msg.readString(24, "guild name")); - dstBeing->setGuildPos(msg.readString(24, "guild pos")); - } - else - { - msg.readString(24, "guild name"); - msg.readString(24, "guild pos"); - } - dstBeing->addToCache(); - msg.readString(24, "?"); - } - else - { - msg.readString(24, "party name"); - msg.readString(24, "guild name"); - msg.readString(24, "guild pos"); - msg.readString(24, "?"); - } - BLOCK_END("BeingRecv::processPlayerGuilPartyInfo") -} - -void BeingRecv::processBeingSelfEffect(Net::MessageIn &msg) -{ - BLOCK_START("BeingRecv::processBeingSelfEffect") - if ((effectManager == nullptr) || (actorManager == nullptr)) - { - BLOCK_END("BeingRecv::processBeingSelfEffect") - return; - } - - const BeingId id = msg.readBeingId("being id"); - Being *const being = actorManager->findBeing(id); - if (being == nullptr) - { - DEBUGLOGSTR("insible player?"); - msg.readInt32("effect type"); - BLOCK_END("BeingRecv::processBeingSelfEffect") - return; - } - - const int effectType = msg.readInt32("effect type"); - - if (ParticleEngine::enabled) - effectManager->trigger(effectType, being); - - // +++ need dehard code effectType == 3 - if (effectType == 3 && being->getType() == ActorType::Player - && (socialWindow != nullptr)) - { // reset received damage - socialWindow->resetDamage(being->getName()); - } - BLOCK_END("BeingRecv::processBeingSelfEffect") -} - -void BeingRecv::processSkillCastCancel(Net::MessageIn &msg) -{ - msg.readInt32("skill id"); -} - -void BeingRecv::processIpResponse(Net::MessageIn &msg) -{ - BLOCK_START("BeingRecv::processIpResponse") - if (actorManager == nullptr) - { - BLOCK_END("BeingRecv::processIpResponse") - return; - } - - Being *const dstBeing = actorManager->findBeing( - msg.readBeingId("being id")); - if (dstBeing != nullptr) - { - const std::string ip = ipToString(msg.readInt32("ip address")); - dstBeing->setIp(ip); - } - else - { - msg.readInt32("ip address"); - DEBUGLOGSTR("invisible player?"); - } - - BLOCK_END("BeingRecv::processIpResponse") -} - -void BeingRecv::processPvpSet(Net::MessageIn &msg) -{ - BLOCK_START("BeingRecv::processPvpSet") - const BeingId id = msg.readBeingId("being id"); - const int rank = msg.readInt32("rank"); - int teamId = 0; - teamId = msg.readInt32("team"); - if (actorManager != nullptr) - { - Being *const dstBeing = actorManager->findBeing(id); - if (dstBeing != nullptr) - { - dstBeing->setPvpRank(rank); - dstBeing->setTeamId(CAST_U16(teamId)); - dstBeing->addToCache(); - } - } - BLOCK_END("BeingRecv::processPvpSet") -} - -void BeingRecv::applyPlayerAction(Net::MessageIn &msg, - Being *const being, - const uint8_t type) -{ - if (being == nullptr) - return; - switch (type) - { - case 0: - being->setAction(BeingAction::STAND, 0); - localPlayer->imitateAction(being, BeingAction::STAND); - break; - - case 1: - if (being->getCurrentAction() != BeingAction::DEAD) - { - being->setAction(BeingAction::DEAD, 0); - being->recalcSpritesOrder(); - } - break; - - case 2: - being->setAction(BeingAction::SIT, 0); - localPlayer->imitateAction(being, BeingAction::SIT); - break; - - default: - UNIMPLEMENTEDPACKETFIELD(type); - break; - } -} - -void BeingRecv::processSkillDamage(Net::MessageIn &msg) -{ - BLOCK_START("BeingRecv::processSkillDamage") - if (actorManager == nullptr) - { - BLOCK_END("BeingRecv::processSkillDamage") - return; - } - - const int id = msg.readInt16("skill id"); - Being *const srcBeing = actorManager->findBeing( - msg.readBeingId("src being id")); - Being *const dstBeing = actorManager->findBeing( - msg.readBeingId("dst being id")); - msg.readInt32("tick"); - msg.readInt32("src speed"); - msg.readInt32("dst speed"); - const int param1 = msg.readInt32("damage"); - const int level = msg.readInt16("skill level"); - msg.readInt16("div"); - msg.readUInt8("skill hit/type?"); - if (srcBeing != nullptr) - srcBeing->handleSkill(dstBeing, param1, id, level); - if (dstBeing != nullptr) - dstBeing->takeDamage(srcBeing, param1, AttackType::SKILL, id, level); - BLOCK_END("BeingRecv::processSkillDamage") -} - -void BeingRecv::setServerGender(Being *const being, - const uint8_t gender) -{ - if (being == nullptr) - return; - switch (gender) - { - case 2: - being->setGender(Gender::FEMALE); - break; - case 3: - being->setGender(Gender::MALE); - break; - case 4: - being->setGender(Gender::OTHER); - break; - default: - being->setGender(Gender::UNSPECIFIED); - break; - } -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/beingrecv.h b/src/net/tmwa/beingrecv.h deleted file mode 100644 index 31e63b2f8..000000000 --- a/src/net/tmwa/beingrecv.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_BEINGRECV_H -#define NET_TMWA_BEINGRECV_H - -#if defined(__GXX_EXPERIMENTAL_CXX0X__) -#if defined(__APPLE__) -#include <tr1/cstdint> -#endif // defined(__APPLE__) -#endif // defined(__GXX_EXPERIMENTAL_CXX0X__) - -#include "localconsts.h" - -namespace Net -{ - class MessageIn; -} // namespace Net - -class Being; - -namespace TmwAthena -{ - namespace BeingRecv - { - void processBeingChangeLook(Net::MessageIn &msg); - void processBeingChangeLook2(Net::MessageIn &msg); - void processBeingVisible(Net::MessageIn &msg); - void processBeingMove(Net::MessageIn &msg); - void processPlayerUpdate1(Net::MessageIn &msg); - void processPlayerUpdate2(Net::MessageIn &msg); - void processPlayerMove(Net::MessageIn &msg); - void processBeingSpawn(Net::MessageIn &msg); - void processSkillCasting(Net::MessageIn &msg); - void processBeingStatusChange(Net::MessageIn &msg); - void processBeingMove2(Net::MessageIn &msg); - void processBeingChangeDirection(Net::MessageIn &msg); - void processBeingChangeLookContinue(const Net::MessageIn &msg, - Being *const dstBeing, - const uint8_t type, - const int id, - const int id2) A_NONNULL(2); - void processPlayerStatusChange(Net::MessageIn &msg); - void processBeingResurrect(Net::MessageIn &msg); - void processPlayerGuilPartyInfo(Net::MessageIn &msg); - void processBeingSelfEffect(Net::MessageIn &msg); - void processSkillCastCancel(Net::MessageIn &msg); - void processIpResponse(Net::MessageIn &msg); - void processPvpSet(Net::MessageIn &msg); - void processSkillDamage(Net::MessageIn &msg); - void applyPlayerAction(Net::MessageIn &msg, - Being *const being, - const uint8_t type); - void setServerGender(Being *const being, - const uint8_t gender); - } // namespace BeingRecv -} // namespace TmwAthena - -#endif // NET_TMWA_BEINGRECV_H diff --git a/src/net/tmwa/buyingstorehandler.cpp b/src/net/tmwa/buyingstorehandler.cpp deleted file mode 100644 index 4d028f918..000000000 --- a/src/net/tmwa/buyingstorehandler.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/buyingstorehandler.h" - -#include "debug.h" - -namespace TmwAthena -{ - -BuyingStoreHandler::BuyingStoreHandler() -{ - buyingStoreHandler = this; -} - -BuyingStoreHandler::~BuyingStoreHandler() -{ - buyingStoreHandler = nullptr; -} - -void BuyingStoreHandler::create(const std::string &name A_UNUSED, - const int maxMoney A_UNUSED, - const bool flag A_UNUSED, - const STD_VECTOR<ShopItem*> &items A_UNUSED) - const -{ -} - -void BuyingStoreHandler::close() const -{ -} - -void BuyingStoreHandler::open(const Being *const being A_UNUSED) const -{ -} - -void BuyingStoreHandler::sell(const Being *const being A_UNUSED, - const int storeId A_UNUSED, - const Item *const item A_UNUSED, - const int amount A_UNUSED) const -{ -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/buyingstorehandler.h b/src/net/tmwa/buyingstorehandler.h deleted file mode 100644 index 584293021..000000000 --- a/src/net/tmwa/buyingstorehandler.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_BUYINGSTOREHANDLER_H -#define NET_TMWA_BUYINGSTOREHANDLER_H - -#include "net/buyingstorehandler.h" - -namespace TmwAthena -{ - -class BuyingStoreHandler final : public Net::BuyingStoreHandler -{ - public: - BuyingStoreHandler(); - - A_DELETE_COPY(BuyingStoreHandler) - - ~BuyingStoreHandler(); - - void create(const std::string &name, - const int maxMoney, - const bool flag, - const STD_VECTOR<ShopItem*> &items) const override final - A_CONST; - - void close() const override final A_CONST; - - void open(const Being *const being) const override final A_CONST; - - void sell(const Being *const being, - const int storeId, - const Item *const item, - const int amount) const override final A_CONST; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_BUYINGSTOREHANDLER_H diff --git a/src/net/tmwa/buysellhandler.cpp b/src/net/tmwa/buysellhandler.cpp deleted file mode 100644 index 7d69c8a7a..000000000 --- a/src/net/tmwa/buysellhandler.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/buysellhandler.h" - -#include "configuration.h" - -#include "gui/windows/chatwindow.h" -#include "gui/windows/shopwindow.h" - -#include "net/chathandler.h" - -#include "net/ea/buysellrecv.h" - -#include "utils/timer.h" - -#include "debug.h" - -namespace TmwAthena -{ - -BuySellHandler::BuySellHandler() : - Ea::BuySellHandler() -{ - buySellHandler = this; - Ea::BuySellRecv::mBuyDialog = nullptr; -} - -BuySellHandler::~BuySellHandler() -{ - buySellHandler = nullptr; -} - -void BuySellHandler::requestSellList(const std::string &nick) const -{ - if (nick.empty() || shopWindow == nullptr) - return; - - const std::string data("!selllist " + toString(tick_time)); - shopWindow->setAcceptPlayer(nick); - if (config.getBoolValue("hideShopMessages")) - { - chatHandler->privateMessage(nick, data); - } - else - { - if (chatWindow != nullptr) - chatWindow->addWhisper(nick, data, ChatMsgType::BY_PLAYER); - } -} - -void BuySellHandler::requestBuyList(const std::string &nick) const -{ - if (nick.empty() || (shopWindow == nullptr)) - return; - - const std::string data("!buylist " + toString(tick_time)); - shopWindow->setAcceptPlayer(nick); - - if (config.getBoolValue("hideShopMessages")) - { - chatHandler->privateMessage(nick, data); - } - else - { - if (chatWindow != nullptr) - chatWindow->addWhisper(nick, data, ChatMsgType::BY_PLAYER); - } -} - -void BuySellHandler::sendBuyRequest(const std::string &nick, - const ShopItem *const item, - const int amount) const -{ - if ((chatWindow == nullptr) || nick.empty() || (item == nullptr) || - amount < 1 || amount > item->getQuantity()) - { - return; - } - const std::string data = strprintf("!buyitem %d %d %d", - item->getId(), item->getPrice(), amount); - - if (config.getBoolValue("hideShopMessages")) - chatHandler->privateMessage(nick, data); - else - chatWindow->addWhisper(nick, data, ChatMsgType::BY_PLAYER); -} - -void BuySellHandler::sendSellRequest(const std::string &nick, - const ShopItem *const item, - const int amount) const -{ - if ((chatWindow == nullptr) || nick.empty() || (item == nullptr) || - amount < 1 || amount > item->getQuantity()) - { - return; - } - - const std::string data = strprintf("!sellitem %d %d %d", - item->getId(), item->getPrice(), amount); - - if (config.getBoolValue("hideShopMessages")) - chatHandler->privateMessage(nick, data); - else - chatWindow->addWhisper(nick, data, ChatMsgType::BY_PLAYER); -} - -void BuySellHandler::close() const -{ -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/buysellhandler.h b/src/net/tmwa/buysellhandler.h deleted file mode 100644 index 461935cda..000000000 --- a/src/net/tmwa/buysellhandler.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_BUYSELLHANDLER_H -#define NET_TMWA_BUYSELLHANDLER_H - -#include "net/ea/buysellhandler.h" - -namespace TmwAthena -{ - -class BuySellHandler final : public Ea::BuySellHandler -{ - public: - BuySellHandler(); - - A_DELETE_COPY(BuySellHandler) - - ~BuySellHandler(); - - void requestSellList(const std::string &nick) - const override final; - - void requestBuyList(const std::string &nick) - const override final; - - void sendBuyRequest(const std::string &nick, - const ShopItem *const item, - const int amount) const override final; - - void sendSellRequest(const std::string &nick, - const ShopItem *const item, - const int amount) const override final; - - void close() const override final A_CONST; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_BUYSELLHANDLER_H diff --git a/src/net/tmwa/buysellrecv.cpp b/src/net/tmwa/buysellrecv.cpp deleted file mode 100644 index 004837e50..000000000 --- a/src/net/tmwa/buysellrecv.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/buysellrecv.h" - -#include "notifymanager.h" - -#include "being/playerinfo.h" - -#include "const/resources/currency.h" - -#include "enums/resources/notifytypes.h" - -#include "gui/windows/buydialog.h" - -#include "gui/widgets/createwidget.h" - -#include "net/messagein.h" - -#include "net/ea/buysellrecv.h" - -#include "debug.h" - -namespace TmwAthena -{ - -void BuySellRecv::processNpcBuy(Net::MessageIn &msg) -{ - msg.readInt16("len"); - const unsigned int n_items = (msg.getLength() - 4U) / 11; - CREATEWIDGETV(Ea::BuySellRecv::mBuyDialog, BuyDialog, - Ea::BuySellRecv::mNpcId, - DEFAULT_CURRENCY); - Ea::BuySellRecv::mBuyDialog->setMoney( - PlayerInfo::getAttribute(Attributes::MONEY)); - - for (unsigned int k = 0; k < n_items; k++) - { - const int value = msg.readInt32("price"); - msg.readInt32("dc value?"); - const ItemTypeT type = static_cast<ItemTypeT>(msg.readUInt8("type")); - const int itemId = msg.readInt16("item id"); - const ItemColor color = ItemColor_one; - Ea::BuySellRecv::mBuyDialog->addItem(itemId, type, color, 0, value); - } - Ea::BuySellRecv::mBuyDialog->sort(); -} - -void BuySellRecv::processNpcSellResponse(Net::MessageIn &msg) -{ - switch (msg.readUInt8("result")) - { - case 0: - NotifyManager::notify(NotifyTypes::SOLD); - break; - case 1: - default: - NotifyManager::notify(NotifyTypes::SELL_FAILED); - break; - case 2: - NotifyManager::notify(NotifyTypes::SELL_TRADE_FAILED); - break; - case 3: - NotifyManager::notify(NotifyTypes::SELL_UNSELLABLE_FAILED); - break; - } -} - -void BuySellRecv::processNpcBuyResponse(Net::MessageIn &msg) -{ - const uint8_t response = msg.readUInt8("response"); - if (response == 0U) - { - NotifyManager::notify(NotifyTypes::BUY_DONE); - return; - } - // Reset player money since buy dialog already assumed purchase - // would go fine - if (Ea::BuySellRecv::mBuyDialog != nullptr) - { - Ea::BuySellRecv::mBuyDialog->setMoney( - PlayerInfo::getAttribute(Attributes::MONEY)); - } - switch (response) - { - case 1: - NotifyManager::notify(NotifyTypes::BUY_FAILED_NO_MONEY); - break; - - case 2: - NotifyManager::notify(NotifyTypes::BUY_FAILED_OVERWEIGHT); - break; - - case 3: - NotifyManager::notify(NotifyTypes::BUY_FAILED_TOO_MANY_ITEMS); - break; - - default: - NotifyManager::notify(NotifyTypes::BUY_FAILED); - break; - }; -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/buysellrecv.h b/src/net/tmwa/buysellrecv.h deleted file mode 100644 index fc1613b5d..000000000 --- a/src/net/tmwa/buysellrecv.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_BUYSELLRECV_H -#define NET_TMWA_BUYSELLRECV_H - -namespace Net -{ - class MessageIn; -} // namespace Net - -namespace TmwAthena -{ - namespace BuySellRecv - { - void processNpcBuy(Net::MessageIn &msg); - void processNpcSellResponse(Net::MessageIn &msg); - void processNpcBuyResponse(Net::MessageIn &msg); - } // namespace BuySellRecv -} // namespace TmwAthena - -#endif // NET_TMWA_BUYSELLRECV_H diff --git a/src/net/tmwa/cashshophandler.cpp b/src/net/tmwa/cashshophandler.cpp deleted file mode 100644 index 9477af1cc..000000000 --- a/src/net/tmwa/cashshophandler.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/cashshophandler.h" - -#include "debug.h" - -namespace TmwAthena -{ - -CashShopHandler::CashShopHandler() : - Net::CashShopHandler() -{ - cashShopHandler = this; -} - -CashShopHandler::~CashShopHandler() -{ - cashShopHandler = nullptr; -} - -void CashShopHandler::buyItem(const int points A_UNUSED, - const int itemId A_UNUSED, - const ItemColor color A_UNUSED, - const int amount A_UNUSED) const -{ -} - -void CashShopHandler::buyItems(const int points A_UNUSED, - const STD_VECTOR<ShopItem*> &items A_UNUSED) - const -{ -} - -void CashShopHandler::close() const -{ -} - -void CashShopHandler::requestPoints() const -{ -} - -void CashShopHandler::requestTab(const int tab A_UNUSED) const -{ -} - -void CashShopHandler::schedule() const -{ -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/cashshophandler.h b/src/net/tmwa/cashshophandler.h deleted file mode 100644 index 31d5872dd..000000000 --- a/src/net/tmwa/cashshophandler.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_CASHSHOPHANDLER_H -#define NET_TMWA_CASHSHOPHANDLER_H - -#include "net/cashshophandler.h" - -namespace TmwAthena -{ - -class CashShopHandler final : public Net::CashShopHandler -{ - public: - CashShopHandler(); - - A_DELETE_COPY(CashShopHandler) - - ~CashShopHandler(); - - void buyItem(const int points, - const int itemId, - const ItemColor color, - const int amount) const override final A_CONST; - - void buyItems(const int points, - const STD_VECTOR<ShopItem*> &items) const override final - A_CONST; - - void close() const override final A_CONST; - - void requestPoints() const override final A_CONST; - - void requestTab(const int tab) const override final A_CONST; - - void schedule() const override final A_CONST; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_CASHSHOPHANDLER_H diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp deleted file mode 100644 index 258c1c163..000000000 --- a/src/net/tmwa/charserverhandler.cpp +++ /dev/null @@ -1,196 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/charserverhandler.h" - -#include "gui/windows/charcreatedialog.h" - -#include "net/character.h" - -#include "net/ea/token.h" - -#include "net/tmwa/loginhandler.h" -#include "net/tmwa/messageout.h" -#include "net/tmwa/network.h" -#include "net/tmwa/protocolout.h" - -#include "resources/db/chardb.h" - -#include "utils/gettext.h" - -#include "debug.h" - -namespace TmwAthena -{ - -extern ServerInfo mapServer; - -extern ServerInfo charServer; - -CharServerHandler::CharServerHandler() : - Ea::CharServerHandler() -{ - charServerHandler = this; -} - -CharServerHandler::~CharServerHandler() -{ - charServerHandler = nullptr; -} - -void CharServerHandler::chooseCharacter(Net::Character *const character) const -{ - if (character == nullptr) - return; - - mSelectedCharacter = character; - mCharSelectDialog = nullptr; - - createOutPacket(CMSG_CHAR_SELECT); - outMsg.writeInt8(CAST_U8(mSelectedCharacter->slot), - "slot"); -} - -void CharServerHandler::newCharacter(const std::string &name, const int slot, - const GenderT gender A_UNUSED, - const int hairstyle, - const int hairColor, - const unsigned char race A_UNUSED, - const uint16_t look A_UNUSED, - const STD_VECTOR<int> &stats) const -{ - createOutPacket(CMSG_CHAR_CREATE); - outMsg.writeString(name, 24, "name"); - for (int i = 0; i < 6; i++) - outMsg.writeInt8(CAST_U8(stats[i]), "stat"); - - outMsg.writeInt8(CAST_U8(slot), "slot"); - outMsg.writeInt8(CAST_S8(hairColor), "hair color"); - outMsg.writeInt8(0, "unused"); - outMsg.writeInt8(CAST_S8(hairstyle), "hair style"); - outMsg.writeInt8(0, "unused"); -} - -void CharServerHandler::deleteCharacter(Net::Character *const character, - const std::string &email A_UNUSED) - const -{ - if (character == nullptr) - return; - - mSelectedCharacter = character; - - createOutPacket(CMSG_CHAR_DELETE); - outMsg.writeBeingId(mSelectedCharacter->dummy->getId(), "id?"); - outMsg.writeString("a@a.com", 40, "email"); -} - -void CharServerHandler::switchCharacter() const -{ - // This is really a map-server packet - createOutPacket(CMSG_PLAYER_RESTART); - outMsg.writeInt8(1, "flag"); -} - -void CharServerHandler::connect() const -{ - const Token &token = - static_cast<LoginHandler*>(loginHandler)->getToken(); - - if (Network::mInstance == nullptr) - return; - - Network::mInstance->disconnect(); - Network::mInstance->connect(charServer); - createOutPacket(CMSG_CHAR_SERVER_CONNECT); - outMsg.writeBeingId(token.account_ID, "account id"); - outMsg.writeInt32(token.session_ID1, "session id1"); - outMsg.writeInt32(token.session_ID2, "session id2"); - // [Fate] The next word is unused by the old char server, so we squeeze in - // mana client version information - outMsg.writeInt16(CLIENT_PROTOCOL_VERSION, - "client protocol version"); - outMsg.writeInt8(Being::genderToInt(token.sex), "gender"); - - // We get 4 useless bytes before the real answer comes in (what are these?) - Network::mInstance->skip(4); -} - -void CharServerHandler::setCharCreateDialog(CharCreateDialog *const window) - const -{ - mCharCreateDialog = window; - - if (mCharCreateDialog == nullptr) - return; - - StringVect attributes; - // TRANSLATORS: playe stat - attributes.push_back(_("Strength:")); - // TRANSLATORS: playe stat - attributes.push_back(_("Agility:")); - // TRANSLATORS: playe stat - attributes.push_back(_("Vitality:")); - // TRANSLATORS: playe stat - attributes.push_back(_("Intelligence:")); - // TRANSLATORS: playe stat - attributes.push_back(_("Dexterity:")); - // TRANSLATORS: playe stat - attributes.push_back(_("Luck:")); - - const Token &token = static_cast<LoginHandler*>(loginHandler)->getToken(); - - int minStat = CharDB::getMinStat(); - if (minStat == 0) - minStat = 1; - int maxStat = CharDB::getMaxStat(); - if (maxStat == 0) - maxStat = 9; - int sumStat = CharDB::getSumStat(); - if (sumStat == 0) - sumStat = 30; - - mCharCreateDialog->setAttributes(attributes, sumStat, minStat, maxStat); - mCharCreateDialog->setDefaultGender(token.sex); -} - -void CharServerHandler::renameCharacter(const BeingId id A_UNUSED, - const std::string &newName A_UNUSED) - const -{ -} - -void CharServerHandler::changeSlot(const int oldSlot A_UNUSED, - const int newSlot A_UNUSED) const -{ -} - -void CharServerHandler::ping() const -{ -} - -unsigned int CharServerHandler::hatSprite() const -{ - return 7; -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/charserverhandler.h b/src/net/tmwa/charserverhandler.h deleted file mode 100644 index e71fdb1b9..000000000 --- a/src/net/tmwa/charserverhandler.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_CHARSERVERHANDLER_H -#define NET_TMWA_CHARSERVERHANDLER_H - -#include "net/ea/charserverhandler.h" - -namespace TmwAthena -{ - -/** - * Deals with incoming messages from the character server. - */ -class CharServerHandler final : public Ea::CharServerHandler -{ - public: - CharServerHandler(); - - A_DELETE_COPY(CharServerHandler) - - ~CharServerHandler(); - - void chooseCharacter(Net::Character *const character) const - override final; - - void newCharacter(const std::string &name, - const int slot, - const GenderT gender, - const int hairstyle, - const int hairColor, - const unsigned char race, - const uint16_t look, - const STD_VECTOR<int> &stats) const override final; - - void deleteCharacter(Net::Character *const character, - const std::string &email) const override final; - - void renameCharacter(const BeingId id, - const std::string &newName) const override final - A_CONST; - - void switchCharacter() const override final; - - void connect() const override final; - - bool isNeedCreatePin() const override final - { return false; } - - void setNewPincode(const std::string &pin A_UNUSED) const - override final - { } - - /** - * Sets the character create dialog. The handler will clean up this - * dialog when a new character is successfully created, and will unlock - * the dialog when a new character failed to be created. - */ - void setCharCreateDialog(CharCreateDialog *const window) const - override final; - - void changeSlot(const int oldSlot, - const int newSlot) const override final A_CONST; - - void ping() const override final A_CONST; - - unsigned int hatSprite() const override final A_CONST A_WARN_UNUSED; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_CHARSERVERHANDLER_H diff --git a/src/net/tmwa/charserverrecv.cpp b/src/net/tmwa/charserverrecv.cpp deleted file mode 100644 index 8b0f960df..000000000 --- a/src/net/tmwa/charserverrecv.cpp +++ /dev/null @@ -1,304 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/charserverrecv.h" - -#include "client.h" -#include "configuration.h" -#include "settings.h" - -#include "gui/windows/charcreatedialog.h" -#include "gui/windows/okdialog.h" - -#include "gui/widgets/createwidget.h" - -#include "net/character.h" -#include "net/charserverhandler.h" -#include "net/messagein.h" -#include "net/serverfeatures.h" - -#include "net/ea/token.h" - -#include "net/tmwa/gamehandler.h" -#include "net/tmwa/loginhandler.h" -#include "net/tmwa/network.h" -#include "net/tmwa/sprite.h" - -#include "resources/iteminfo.h" - -#include "resources/db/itemdb.h" - -#include "utils/dtor.h" -#include "utils/gettext.h" - -#include "debug.h" - -namespace TmwAthena -{ - -extern ServerInfo mapServer; - -extern ServerInfo charServer; - -void CharServerRecv::readPlayerData(Net::MessageIn &msg, - Net::Character *const character) -{ - if (character == nullptr) - return; - - const Token &token = - static_cast<LoginHandler*>(loginHandler)->getToken(); - - LocalPlayer *const tempPlayer = new LocalPlayer( - msg.readBeingId("account id"), BeingTypeId_zero); - - PlayerInfoBackend &data = character->data; - data.mAttributes[Attributes::PLAYER_EXP] = msg.readInt32("base exp"); - data.mAttributes[Attributes::MONEY] = msg.readInt32("money"); - data.mAttributes[Attributes::PLAYER_JOB_EXP] = msg.readInt32("job exp"); - data.mAttributes[Attributes::PLAYER_JOB_LEVEL] = - msg.readInt32("job level"); - - const int shoes = msg.readInt16("shoes"); - const int gloves = msg.readInt16("gloves"); - const int cape = msg.readInt16("cape"); - const int misc1 = msg.readInt16("misc1"); - - msg.readInt32("option"); - tempPlayer->setKarma(msg.readInt32("karma")); - tempPlayer->setManner(msg.readInt32("manner")); - msg.readInt16("character points left"); - - data.mAttributes[Attributes::PLAYER_HP] = msg.readInt16("hp"); - data.mAttributes[Attributes::PLAYER_MAX_HP] = msg.readInt16("max hp"); - data.mAttributes[Attributes::PLAYER_MP] = msg.readInt16("mp"); - data.mAttributes[Attributes::PLAYER_MAX_MP] = msg.readInt16("max mp"); - - msg.readInt16("speed"); - const uint16_t race = msg.readInt16("class"); - const uint8_t hairStyle = msg.readUInt8("hair style"); - const uint16_t look = msg.readUInt8("look"); - tempPlayer->setSubtype(fromInt(race, BeingTypeId), look); - const uint16_t weapon = msg.readInt16("weapon"); - tempPlayer->setSpriteId(SPRITE_BODY, - weapon); - tempPlayer->setWeaponId(weapon); - - data.mAttributes[Attributes::PLAYER_BASE_LEVEL] = msg.readInt16("level"); - - msg.readInt16("skill point"); - const int bottomClothes = msg.readInt16("bottom clothes"); - const int shield = msg.readInt16("shield"); - - const int hat = msg.readInt16("hat"); - const int topClothes = msg.readInt16("top clothes"); - - const ItemColor hairColor = fromInt( - msg.readUInt8("hair color"), ItemColor); - msg.readUInt8("unused"); - if (hairStyle == 0) - { - tempPlayer->unSetSprite(SPRITE_HAIR_COLOR); - } - else - { - tempPlayer->setSpriteColor(SPRITE_HAIR_COLOR, - hairStyle * -1, - ItemDB::get(-hairStyle).getDyeColorsString(hairColor)); - } - tempPlayer->setHairColor(hairColor); - - const int misc2 = msg.readInt16("misc2"); - tempPlayer->setName(msg.readString(24, "name")); - - character->dummy = tempPlayer; - - character->data.mStats[Attributes::PLAYER_STR].base = msg.readUInt8("str"); - character->data.mStats[Attributes::PLAYER_AGI].base = msg.readUInt8("agi"); - character->data.mStats[Attributes::PLAYER_VIT].base = msg.readUInt8("vit"); - character->data.mStats[Attributes::PLAYER_INT].base = msg.readUInt8("int"); - character->data.mStats[Attributes::PLAYER_DEX].base = msg.readUInt8("dex"); - character->data.mStats[Attributes::PLAYER_LUK].base = msg.readUInt8("luk"); - - tempPlayer->setSpriteId(SPRITE_HAIR, - shoes); - tempPlayer->setSpriteId(SPRITE_SHOES, - gloves); - tempPlayer->setSpriteId(SPRITE_SHIELD, - cape); - tempPlayer->setSpriteId(SPRITE_HEAD_TOP, - misc1); - tempPlayer->setSpriteId(SPRITE_WEAPON, - bottomClothes); - tempPlayer->setSpriteId(SPRITE_FLOOR, - shield); - tempPlayer->setSpriteId(SPRITE_CLOTHES_COLOR, - hat); - tempPlayer->setSpriteId(SPRITE_HEAD_BOTTOM, - topClothes); - tempPlayer->setSpriteId(SPRITE_HEAD_MID, - misc2); - - character->slot = msg.readUInt8("slot"); - const uint8_t sex = CAST_U8(msg.readUInt8("gender")); - if (serverFeatures->haveCreateCharGender()) - tempPlayer->setGender(Being::intToGender(sex)); - else - tempPlayer->setGender(token.sex); -} - -void CharServerRecv::processCharLogin(Net::MessageIn &msg) -{ - BLOCK_START("CharServerRecv::processCharLogin") - - msg.readInt16("len"); - const int slots = msg.readInt16("slots"); - if (slots > 0 && slots < 30) - loginData.characterSlots = CAST_U16(slots); - - msg.skip(18, "unused"); - - delete_all(Net::CharServerHandler::mCharacters); - Net::CharServerHandler::mCharacters.clear(); - - // Derive number of characters from message length - const int count = (msg.getLength() - 24) / 106; - - for (int i = 0; i < count; ++i) - { - Net::Character *const character = new Net::Character; - readPlayerData(msg, character); - Net::CharServerHandler::mCharacters.push_back(character); - if (character->dummy != nullptr) - { - logger->log("CharServer: Player: %s (%d)", - character->dummy->getName().c_str(), character->slot); - } - } - - client->setState(State::CHAR_SELECT); - BLOCK_END("CharServerRecv::processCharLogin") -} - -void CharServerRecv::processCharMapInfo(Net::MessageIn &restrict msg) -{ - Network *const network = Network::mInstance; - ServerInfo &server = mapServer; - BLOCK_START("CharServerRecv::processCharMapInfo") - PlayerInfo::setCharId(msg.readInt32("char id?")); - GameHandler::setMap(msg.readString(16, "map name")); - if (config.getBoolValue("usePersistentIP") || settings.persistentIp) - { - msg.readInt32("ip address"); - server.hostname = settings.serverName; - } - else - { - server.hostname = ipToString(msg.readInt32("ip address")); - } - server.port = msg.readInt16("port"); - - // Prevent the selected local player from being deleted - localPlayer = Net::CharServerHandler::mSelectedCharacter->dummy; - PlayerInfo::setBackend(Net::CharServerHandler::mSelectedCharacter->data); - - Net::CharServerHandler::mSelectedCharacter->dummy = nullptr; - - charServerHandler->clear(); - Net::CharServerHandler::updateCharSelectDialog(); - - if (network != nullptr) - network->disconnect(); - client->setState(State::CONNECT_GAME); - BLOCK_END("CharServerRecv::processCharMapInfo") -} - -void CharServerRecv::processChangeMapServer(Net::MessageIn &msg) -{ - Network *const network = Network::mInstance; - ServerInfo &server = mapServer; - BLOCK_START("CharServerRecv::processChangeMapServer") - if (network == nullptr) - { - BLOCK_END("CharServerRecv::processChangeMapServer") - return; - } - GameHandler::setMap(msg.readString(16, "map name")); - const int x = msg.readInt16("x"); - const int y = msg.readInt16("y"); - if (config.getBoolValue("usePersistentIP") || settings.persistentIp) - { - msg.readInt32("ip address"); - server.hostname = settings.serverName; - } - else - { - server.hostname = ipToString(msg.readInt32("ip address")); - } - server.port = msg.readInt16("port"); - - network->disconnect(); - client->setState(State::CHANGE_MAP); - if (localPlayer != nullptr) - { - localPlayer->setTileCoords(x, y); - localPlayer->setMap(nullptr); - } - BLOCK_END("CharServerRecv::processChangeMapServer") -} - -void CharServerRecv::processCharCreate(Net::MessageIn &msg) -{ - BLOCK_START("CharServerRecv::processCharCreate") - Net::Character *const character = new Net::Character; - readPlayerData(msg, character); - Net::CharServerHandler::mCharacters.push_back(character); - - Net::CharServerHandler::updateCharSelectDialog(); - - // Close the character create dialog - Net::CharServerHandler::mCharCreateDialog->scheduleDelete(); - Net::CharServerHandler::mCharCreateDialog = nullptr; - BLOCK_END("CharServerRecv::processCharCreate") -} - -void CharServerRecv::processCharDeleteFailed(Net::MessageIn &msg) -{ - BLOCK_START("CharServerRecv::processCharDeleteFailed") - Net::CharServerHandler::unlockCharSelectDialog(); - msg.readUInt8("error"); - CREATEWIDGET(OkDialog, - // TRANSLATORS: error header - _("Error"), - // TRANSLATORS: error message - _("Failed to delete character."), - // TRANSLATORS: ok dialog button - _("OK"), - DialogType::ERROR, - Modal_true, - ShowCenter_true, - nullptr, - 260); - BLOCK_END("CharServerRecv::processCharDeleteFailed") -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/charserverrecv.h b/src/net/tmwa/charserverrecv.h deleted file mode 100644 index 195c5239c..000000000 --- a/src/net/tmwa/charserverrecv.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_CHARSERVERRECV_H -#define NET_TMWA_CHARSERVERRECV_H - -namespace Net -{ - class MessageIn; - - struct Character; -} // namespace Net - -namespace TmwAthena -{ - namespace CharServerRecv - { - void readPlayerData(Net::MessageIn &msg, - Net::Character *const character); - void processCharCreate(Net::MessageIn &msg); - void processCharDeleteFailed(Net::MessageIn &msg); - void processCharLogin(Net::MessageIn &msg); - void processCharMapInfo(Net::MessageIn &msg); - void processChangeMapServer(Net::MessageIn &msg); - } // namespace CharServerRecv -} // namespace TmwAthena - -#endif // NET_TMWA_CHARSERVERRECV_H diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp deleted file mode 100644 index 2b768ffe2..000000000 --- a/src/net/tmwa/chathandler.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/chathandler.h" - -#include "being/localplayer.h" - -#include "const/gui/chat.h" - -#include "net/ea/chatrecv.h" - -#include "net/tmwa/messageout.h" -#include "net/tmwa/protocolout.h" - -#include "utils/gmfunctions.h" -#include "utils/stringutils.h" - -#include "debug.h" - -extern unsigned int tmwServerVersion; - -namespace TmwAthena -{ - -ChatHandler::ChatHandler() : - Ea::ChatHandler() -{ - chatHandler = this; -} - -ChatHandler::~ChatHandler() -{ - chatHandler = nullptr; -} - -void ChatHandler::talk(const std::string &restrict text, - const std::string &restrict channel A_UNUSED) const -{ - if (localPlayer == nullptr) - return; - - if (tmwServerVersion >= 0x100408) - { - createOutPacket(CMSG_CHAT_MESSAGE); - // Added + 1 in order to let eAthena parse admin commands correctly - outMsg.writeInt16(CAST_S16(text.length() + 4 + 1), "len"); - outMsg.writeString(text, CAST_S32(text.length() + 1), "message"); - } - else - { - const std::string mes = std::string(localPlayer->getName()).append( - " : ").append(text); - - createOutPacket(CMSG_CHAT_MESSAGE); - // Added + 1 in order to let eAthena parse admin commands correctly - outMsg.writeInt16(CAST_S16(mes.length() + 4 + 1), "len"); - outMsg.writeString(mes, CAST_S32(mes.length() + 1), "message"); - } -} - -void ChatHandler::talkRaw(const std::string &mes) const -{ - createOutPacket(CMSG_CHAT_MESSAGE); - outMsg.writeInt16(CAST_S16(mes.length() + 4), "len"); - outMsg.writeString(mes, CAST_S32(mes.length()), "message"); -} - -void ChatHandler::privateMessage(const std::string &restrict recipient, - const std::string &restrict text) const -{ - createOutPacket(CMSG_CHAT_WHISPER); - outMsg.writeInt16(CAST_S16(text.length() + 28), "len"); - outMsg.writeString(recipient, 24, "recipient nick"); - outMsg.writeString(text, CAST_S32(text.length()), "message"); - Ea::ChatRecv::mSentWhispers.push(recipient); -} - -void ChatHandler::channelMessage(const std::string &restrict channel, - const std::string &restrict text) const -{ - if (channel == TRADE_CHANNEL) - talk("\302\202" + text, GENERAL_CHANNEL); - else if (channel == GM_CHANNEL) - Gm::runCommand("wgm", text); -} - -void ChatHandler::who() const -{ - if (tmwServerVersion >= 0x0e0b0b) - return; - - createOutPacket(CMSG_WHO_REQUEST); -} - -void ChatHandler::sendRaw(const std::string &args) const -{ - std::string line = args; - std::string str; - MessageOut *outMsg = nullptr; - - if (line.empty()) - return; - - size_t pos = line.find(' '); - if (pos != std::string::npos) - { - str = line.substr(0, pos); - const int16_t id = CAST_S16(parseNumber(str)); - outMsg = new MessageOut(id); - outMsg->writeInt16(id, "packet id"); - line = line.substr(pos + 1); - pos = line.find(' '); - } - else - { - const int16_t id = CAST_S16(parseNumber(line)); - outMsg = new MessageOut(id); - outMsg->writeInt16(id, "packet id"); - delete outMsg; - return; - } - - while (pos != std::string::npos) - { - str = line.substr(0, pos); - processRaw(*outMsg, str); - line = line.substr(pos + 1); - pos = line.find(' '); - } - if (!line.empty()) - processRaw(*outMsg, line); - delete outMsg; -} - -void ChatHandler::processRaw(MessageOut &restrict outMsg, - const std::string &restrict line) -{ - if (line.size() < 2) - return; - - const uint32_t i = parseNumber(line.substr(1)); - switch (tolower(line[0])) - { - case 'b': - { - outMsg.writeInt8(CAST_U8(i), "raw"); - break; - } - case 'w': - { - outMsg.writeInt16(CAST_S16(i), "raw"); - break; - } - case 'l': - { - outMsg.writeInt32(CAST_S32(i), "raw"); - break; - } - default: - break; - } -} - -void ChatHandler::ignoreAll() const -{ -} - -void ChatHandler::unIgnoreAll() const -{ -} - -void ChatHandler::ignore(const std::string &nick) const -{ - createOutPacket(CMSG_IGNORE_NICK); - outMsg.writeString(nick, 24, "nick"); - outMsg.writeInt8(0, "flag"); -} - -void ChatHandler::unIgnore(const std::string &nick) const -{ - createOutPacket(CMSG_IGNORE_NICK); - outMsg.writeString(nick, 24, "nick"); - outMsg.writeInt8(1, "flag"); -} - -void ChatHandler::requestIgnoreList() const -{ -} - -void ChatHandler::createChatRoom(const std::string &title A_UNUSED, - const std::string &password A_UNUSED, - const int limit A_UNUSED, - const bool isPublic A_UNUSED) const -{ -} - -void ChatHandler::battleTalk(const std::string &text A_UNUSED) const -{ -} - -void ChatHandler::joinChat(const ChatObject *const chat A_UNUSED, - const std::string &password A_UNUSED) const -{ -} - -void ChatHandler::joinChannel(const std::string &channel A_UNUSED) const -{ -} - -void ChatHandler::partChannel(const std::string &channel A_UNUSED) const -{ -} - -void ChatHandler::talkPet(const std::string &restrict text, - const std::string &restrict channel) const -{ - // here need string duplication - std::string action = strprintf("\302\202\303 %s", text.c_str()); - talk(action, channel); -} - -void ChatHandler::leaveChatRoom() const -{ -} - -void ChatHandler::setChatRoomOptions(const int limit A_UNUSED, - const bool isPublict A_UNUSED, - const std::string &passwordt A_UNUSED, - const std::string &titlet A_UNUSED) const -{ -} - -void ChatHandler::setChatRoomOwner(const std::string &nick A_UNUSED) const -{ -} - -void ChatHandler::kickFromChatRoom(const std::string &nick A_UNUSED) const -{ -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/chathandler.h b/src/net/tmwa/chathandler.h deleted file mode 100644 index 12de8067c..000000000 --- a/src/net/tmwa/chathandler.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_CHATHANDLER_H -#define NET_TMWA_CHATHANDLER_H - -#include "net/ea/chathandler.h" - -namespace TmwAthena -{ -class MessageOut; - -class ChatHandler final : public Ea::ChatHandler -{ - public: - ChatHandler(); - - A_DELETE_COPY(ChatHandler) - - ~ChatHandler(); - - void talk(const std::string &restrict text, - const std::string &restrict channel) const override final; - - void talkRaw(const std::string &text) const override final; - - void privateMessage(const std::string &restrict recipient, - const std::string &restrict text) const - override final; - - void channelMessage(const std::string &restrict channel, - const std::string &restrict text) const - override final; - - void joinChannel(const std::string &channel) const override final - A_CONST; - - void who() const override final; - - void sendRaw(const std::string &args) const override final; - - void ignoreAll() const override final; - - void unIgnoreAll() const override final; - - void createChatRoom(const std::string &title, - const std::string &password, - const int limit, - const bool isPublic) const override final A_CONST; - - void ignore(const std::string &nick) const override final; - - void unIgnore(const std::string &nick) const override final; - - void requestIgnoreList() const override final A_CONST; - - void battleTalk(const std::string &text) const override final A_CONST; - - void joinChat(const ChatObject *const chat, - const std::string &password) const override final - A_CONST; - - void partChannel(const std::string &channel) const override final - A_CONST; - - void talkPet(const std::string &restrict text, - const std::string &restrict channel) const override final; - - void leaveChatRoom() const override final A_CONST; - - void setChatRoomOptions(const int limit, - const bool isPublic, - const std::string &password, - const std::string &title) const override final - A_CONST; - - void setChatRoomOwner(const std::string &nick) const override final - A_CONST; - - void kickFromChatRoom(const std::string &nick) const override final - A_CONST; - - protected: - static void processRaw(MessageOut &restrict outMsg, - const std::string &restrict line); -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_CHATHANDLER_H diff --git a/src/net/tmwa/chatrecv.cpp b/src/net/tmwa/chatrecv.cpp deleted file mode 100644 index afa501004..000000000 --- a/src/net/tmwa/chatrecv.cpp +++ /dev/null @@ -1,377 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/chatrecv.h" - -#include "actormanager.h" -#include "configuration.h" - -#include "being/localplayer.h" -#include "being/playerrelation.h" -#include "being/playerrelations.h" - -#include "const/gui/chat.h" - -#include "gui/widgets/tabs/chat/gmtab.h" - -#include "gui/windows/chatwindow.h" -#include "gui/windows/shopwindow.h" - -#include "net/serverfeatures.h" - -#include "net/ea/chatrecv.h" - -#include "net/messagein.h" - -#include "net/tmwa/guildmanager.h" - -#include "debug.h" - -namespace TmwAthena -{ - -void ChatRecv::processChat(Net::MessageIn &msg) -{ - BLOCK_START("ChatRecv::processChat") - const int chatMsgLength = msg.readInt16("len") - 4; - if (chatMsgLength <= 0) - { - BLOCK_END("ChatRecv::processChat") - return; - } - - processChatContinue(msg.readRawString(chatMsgLength, "message"), ""); -} - -void ChatRecv::processChatContinue(std::string chatMsg, - const std::string &channel) -{ - const size_t pos = chatMsg.find(" : ", 0); - - bool allow(true); - if (chatWindow != nullptr) - { - allow = chatWindow->resortChatLog(chatMsg, - ChatMsgType::BY_PLAYER, - channel, - IgnoreRecord_false, - TryRemoveColors_true); - } - - if (channel.empty()) - { - const std::string senseStr("You sense the following: "); - if ((actorManager != nullptr) && (chatMsg.find(senseStr) == 0u)) - { - actorManager->parseLevels( - chatMsg.substr(senseStr.size())); - } - } - - if (pos == std::string::npos && - !Ea::ChatRecv::mShowMotd && - Ea::ChatRecv::mSkipping && - channel.empty()) - { - // skip motd from "new" tmw server - if (Ea::ChatRecv::mMotdTime == 0) - { - Ea::ChatRecv::mMotdTime = cur_time + 1; - } - else if (Ea::ChatRecv::mMotdTime == cur_time || - Ea::ChatRecv::mMotdTime < cur_time) - { - Ea::ChatRecv::mSkipping = false; - } - BLOCK_END("ChatRecv::processChat") - return; - } - - if (pos != std::string::npos) - chatMsg.erase(0, pos + 3); - - trim(chatMsg); - - if (localPlayer != nullptr) - { - if (((chatWindow != nullptr) || Ea::ChatRecv::mShowMotd) && allow) - localPlayer->setSpeech(chatMsg, channel); - } - BLOCK_END("ChatRecv::processChat") -} - -void ChatRecv::processGmChat(Net::MessageIn &msg) -{ - BLOCK_START("ChatRecv::processChat") - const int chatMsgLength = msg.readInt16("len") - 4; - if (chatMsgLength <= 0) - { - BLOCK_END("ChatRecv::processChat") - return; - } - - if (localChatTab != nullptr && - chatWindow != nullptr) - { - std::string chatMsg = msg.readRawString(chatMsgLength, "message"); - chatWindow->addGlobalMessage(chatMsg); - } - else - { - msg.readRawString(chatMsgLength, "message"); - } - BLOCK_END("ChatRecv::processChat") -} - -void ChatRecv::processWhisper(Net::MessageIn &msg) -{ - BLOCK_START("ChatRecv::processWhisper") - const int chatMsgLength = msg.readInt16("len") - 28; - std::string nick = msg.readString(24, "nick"); - - if (chatMsgLength <= 0) - { - BLOCK_END("ChatRecv::processWhisper") - return; - } - - processWhisperContinue(nick, msg.readString(chatMsgLength, "message")); -} - -void ChatRecv::processWhisperResponse(Net::MessageIn &msg) -{ - BLOCK_START("ChatRecv::processWhisperResponse") - - const uint8_t type = msg.readUInt8("response"); - Ea::ChatRecv::processWhisperResponseContinue(msg, type); -} - -void ChatRecv::processWhisperContinue(const std::string &nick, - std::string chatMsg) -{ - // ignoring future whisper messages - if (chatMsg.find("\302\202G") == 0 || chatMsg.find("\302\202A") == 0) - { - BLOCK_END("ChatRecv::processWhisper") - return; - } - // remove first unicode space if this is may be whisper command. - if (chatMsg.find("\302\202!") == 0) - chatMsg = chatMsg.substr(2); - - if (nick != "Server") - { - if ((guildManager != nullptr) && GuildManager::getEnableGuildBot() - && nick == "guild" && guildManager->processGuildMessage(chatMsg)) - { - BLOCK_END("ChatRecv::processWhisper") - return; - } - - if (playerRelations.hasPermission(nick, PlayerRelation::WHISPER)) - { - const bool tradeBot = config.getBoolValue("tradebot"); - const bool showMsg = !config.getBoolValue("hideShopMessages"); - if (playerRelations.hasPermission(nick, PlayerRelation::TRADE)) - { - if (shopWindow != nullptr) - { // commands to shop from player - if (chatMsg.find("!selllist ") == 0) - { - if (tradeBot) - { - if (showMsg && (chatWindow != nullptr)) - chatWindow->addWhisper(nick, chatMsg); - shopWindow->giveList(nick, ShopWindow::SELL); - } - } - else if (chatMsg.find("!buylist ") == 0) - { - if (tradeBot) - { - if (showMsg && (chatWindow != nullptr)) - chatWindow->addWhisper(nick, chatMsg); - shopWindow->giveList(nick, ShopWindow::BUY); - } - } - else if (chatMsg.find("!buyitem ") == 0) - { - if (showMsg && (chatWindow != nullptr)) - chatWindow->addWhisper(nick, chatMsg); - if (tradeBot) - { - shopWindow->processRequest(nick, chatMsg, - ShopWindow::BUY); - } - } - else if (chatMsg.find("!sellitem ") == 0) - { - if (showMsg && (chatWindow != nullptr)) - chatWindow->addWhisper(nick, chatMsg); - if (tradeBot) - { - shopWindow->processRequest(nick, chatMsg, - ShopWindow::SELL); - } - } - else if (chatMsg.length() > 3 - && chatMsg.find("\302\202") == 0) - { - chatMsg = chatMsg.erase(0, 2); - if (showMsg && (chatWindow != nullptr)) - chatWindow->addWhisper(nick, chatMsg); - if (chatMsg.find("B1") == 0 || chatMsg.find("S1") == 0) - ShopWindow::showList(nick, chatMsg); - } - else if (chatWindow != nullptr) - { - chatWindow->addWhisper(nick, chatMsg); - } - } - else if (chatWindow != nullptr) - { - chatWindow->addWhisper(nick, chatMsg); - } - } - else - { - if (chatWindow != nullptr && - (showMsg || - (chatMsg.find("!selllist") != 0 && - chatMsg.find("!buylist") != 0))) - { - chatWindow->addWhisper(nick, chatMsg); - } - } - } - } - else if (localChatTab != nullptr) - { - if ((gmChatTab != nullptr) && strStartWith(chatMsg, "[GM] ")) - { - chatMsg = chatMsg.substr(5); - const size_t pos = chatMsg.find(": ", 0); - if (pos == std::string::npos) - { - gmChatTab->chatLog(chatMsg, ChatMsgType::BY_SERVER); - } - else - { - gmChatTab->chatLog(chatMsg.substr(0, pos), - chatMsg.substr(pos + 2)); - } - } - else - { - localChatTab->chatLog(chatMsg, ChatMsgType::BY_SERVER); - } - } - BLOCK_END("ChatRecv::processWhisper") -} - -void ChatRecv::processBeingChat(Net::MessageIn &msg) -{ - if (actorManager == nullptr) - return; - - BLOCK_START("ChatRecv::processBeingChat") - const int chatMsgLength = msg.readInt16("len") - 8; - const BeingId beingId = msg.readBeingId("being id"); - Being *const being = actorManager->findBeing(beingId); - - if (chatMsgLength <= 0) - { - BLOCK_END("ChatRecv::processBeingChat") - return; - } - - std::string chatMsg = msg.readRawString(chatMsgLength, "message"); - - if ((being != nullptr) && being->getType() == ActorType::Player) - being->setTalkTime(); - - const size_t pos = chatMsg.find(" : ", 0); - std::string sender_name = ((pos == std::string::npos) - ? "" : chatMsg.substr(0, pos)); - - if (serverFeatures->haveIncompleteChatMessages()) - { - // work around for "new" tmw server - if (being != nullptr) - sender_name = being->getName(); - if (sender_name.empty()) - { - sender_name = "?" + toString(CAST_S32(beingId)); - const std::string name = actorManager->getSeenPlayerById(beingId); - if (!name.empty()) - sender_name.append(" ").append(name); - } - } - else if ((being != nullptr) && - sender_name != being->getName() && - being->getType() == ActorType::Player) - { - if (!being->getName().empty()) - sender_name = being->getName(); - } - else - { - chatMsg.erase(0, pos + 3); - } - - trim(chatMsg); - - bool allow(true); - // We use getIgnorePlayer instead of ignoringPlayer here - // because ignorePlayer' side effects are triggered - // right below for Being::IGNORE_SPEECH_FLOAT. - if ((playerRelations.checkPermissionSilently(sender_name, - PlayerRelation::SPEECH_LOG) != 0u) && - (chatWindow != nullptr)) - { - allow = chatWindow->resortChatLog( - removeColors(sender_name).append(" : ").append(chatMsg), - ChatMsgType::BY_OTHER, - GENERAL_CHANNEL, - IgnoreRecord_false, - TryRemoveColors_true); - } - - if (allow && - (being != nullptr) && - playerRelations.hasPermission(sender_name, - PlayerRelation::SPEECH_FLOAT)) - { - being->setSpeech(chatMsg, GENERAL_CHANNEL); - } - BLOCK_END("ChatRecv::processBeingChat") -} - -void ChatRecv::processScriptMessage(Net::MessageIn &msg) -{ - const int sz = msg.readInt16("len") - 5; - msg.readUInt8("message type"); - const std::string message = msg.readString(sz, "message"); - localChatTab->chatLog(message, ChatMsgType::BY_SERVER); -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/chatrecv.h b/src/net/tmwa/chatrecv.h deleted file mode 100644 index 3e7b58b15..000000000 --- a/src/net/tmwa/chatrecv.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_CHATRECV_H -#define NET_TMWA_CHATRECV_H - -#include <string> - -namespace Net -{ - class MessageIn; -} // namespace Net - -namespace TmwAthena -{ - namespace ChatRecv - { - void processChat(Net::MessageIn &msg); - void processChatContinue(std::string chatMsg, - const std::string &channel); - void processGmChat(Net::MessageIn &msg); - void processWhisper(Net::MessageIn &msg); - void processWhisperResponse(Net::MessageIn &msg); - void processWhisperContinue(const std::string &nick, - std::string chatMsg); - void processBeingChat(Net::MessageIn &msg); - void processScriptMessage(Net::MessageIn &msg); - } // namespace ChatRecv -} // namespace TmwAthena - -#endif // NET_TMWA_CHATRECV_H diff --git a/src/net/tmwa/elementalhandler.cpp b/src/net/tmwa/elementalhandler.cpp deleted file mode 100644 index 78230f3df..000000000 --- a/src/net/tmwa/elementalhandler.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/elementalhandler.h" - -#include "debug.h" - -namespace TmwAthena -{ - -ElementalHandler::ElementalHandler() : - Net::ElementalHandler() -{ - elementalHandler = this; -} - -ElementalHandler::~ElementalHandler() -{ - elementalHandler = nullptr; -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/elementalhandler.h b/src/net/tmwa/elementalhandler.h deleted file mode 100644 index 5aea5b5d2..000000000 --- a/src/net/tmwa/elementalhandler.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_ELEMENTALHANDLER_H -#define NET_TMWA_ELEMENTALHANDLER_H - -#include "net/elementalhandler.h" - -namespace TmwAthena -{ - class ElementalHandler final : public Net::ElementalHandler - { - public: - ElementalHandler(); - - A_DELETE_COPY(ElementalHandler) - - ~ElementalHandler(); - }; -} // namespace TmwAthena - -#endif // NET_TMWA_ELEMENTALHANDLER_H diff --git a/src/net/tmwa/familyhandler.cpp b/src/net/tmwa/familyhandler.cpp deleted file mode 100644 index 9f5bb7fe9..000000000 --- a/src/net/tmwa/familyhandler.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/familyhandler.h" - -#include "debug.h" - -namespace TmwAthena -{ - -FamilyHandler::FamilyHandler() : - Net::FamilyHandler() -{ - familyHandler = this; -} - -FamilyHandler::~FamilyHandler() -{ - familyHandler = nullptr; -} - -void FamilyHandler::askForChild(const Being *const being A_UNUSED) const -{ -} - -void FamilyHandler::askForChildReply(const bool accept A_UNUSED) const -{ -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/familyhandler.h b/src/net/tmwa/familyhandler.h deleted file mode 100644 index b2cc6c96a..000000000 --- a/src/net/tmwa/familyhandler.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_FAMILYHANDLER_H -#define NET_TMWA_FAMILYHANDLER_H - -#include "net/familyhandler.h" - -namespace TmwAthena -{ - -class FamilyHandler final : public Net::FamilyHandler -{ - public: - FamilyHandler(); - - A_DELETE_COPY(FamilyHandler) - - ~FamilyHandler(); - - void askForChild(const Being *const being) const override final - A_CONST; - - void askForChildReply(const bool accept) const override final A_CONST; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_FAMILYHANDLER_H diff --git a/src/net/tmwa/friendshandler.cpp b/src/net/tmwa/friendshandler.cpp deleted file mode 100644 index 094952df4..000000000 --- a/src/net/tmwa/friendshandler.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/friendshandler.h" - -#include "debug.h" - -namespace TmwAthena -{ - -FriendsHandler::FriendsHandler() -{ - friendsHandler = this; -} - -FriendsHandler::~FriendsHandler() -{ - friendsHandler = nullptr; -} - -void FriendsHandler::invite(const std::string &name A_UNUSED) const -{ -} - -void FriendsHandler::inviteResponse(const int accountId A_UNUSED, - const int charId A_UNUSED, - const bool accept A_UNUSED) const -{ -} - -void FriendsHandler::remove(const int accountId A_UNUSED, - const int charId A_UNUSED) const -{ -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/friendshandler.h b/src/net/tmwa/friendshandler.h deleted file mode 100644 index ef9d05c60..000000000 --- a/src/net/tmwa/friendshandler.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_FRIENDSHANDLER_H -#define NET_TMWA_FRIENDSHANDLER_H - -#include "net/friendshandler.h" - -namespace TmwAthena -{ -class FriendsHandler final : public Net::FriendsHandler -{ - public: - FriendsHandler(); - - A_DELETE_COPY(FriendsHandler) - - ~FriendsHandler(); - - void invite(const std::string &name) const override final A_CONST; - - void inviteResponse(const int accountId, - const int charId, - const bool accept) const override final A_CONST; - - void remove(const int accountId, - const int charId) const override final A_CONST; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_FRIENDSHANDLER_H diff --git a/src/net/tmwa/gamehandler.cpp b/src/net/tmwa/gamehandler.cpp deleted file mode 100644 index d13c46919..000000000 --- a/src/net/tmwa/gamehandler.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/gamehandler.h" - -#include "client.h" - -#include "being/localplayer.h" - -#include "net/ea/token.h" - -#include "net/ea/gamerecv.h" - -#include "net/tmwa/loginhandler.h" -#include "net/tmwa/messageout.h" -#include "net/tmwa/network.h" -#include "net/tmwa/protocolout.h" - -#include "debug.h" - -namespace TmwAthena -{ - -extern ServerInfo mapServer; - -GameHandler::GameHandler() : - Ea::GameHandler() -{ - gameHandler = this; -} - -GameHandler::~GameHandler() -{ - gameHandler = nullptr; -} - -void GameHandler::mapLoadedEvent() const -{ - createOutPacket(CMSG_MAP_LOADED); -} - -void GameHandler::connect() const -{ - if (Network::mInstance == nullptr) - return; - - BLOCK_START("GameHandler::connect") - Network::mInstance->connect(mapServer); - const Token &token = static_cast<LoginHandler*>(loginHandler)->getToken(); - - if (client->getState() == State::CONNECT_GAME) - { - // Change the player's ID to the account ID to match what eAthena uses - if (localPlayer != nullptr) - { - Ea::GameRecv::mCharID = localPlayer->getId(); - localPlayer->setId(token.account_ID); - } - else - { - Ea::GameRecv::mCharID = BeingId_zero; - } - } - - // Send login infos - createOutPacket(CMSG_MAP_SERVER_CONNECT); - outMsg.writeBeingId(token.account_ID, "account id"); - outMsg.writeBeingId(Ea::GameRecv::mCharID, "char id"); - outMsg.writeInt32(token.session_ID1, "session id1"); - outMsg.writeInt32(token.session_ID2, "session id2"); - outMsg.writeInt8(Being::genderToInt(token.sex), "gender"); - -/* - if (localPlayer) - { - // Change the player's ID to the account ID to match what eAthena uses - localPlayer->setId(token.account_ID); - } -*/ - // We get 4 useless bytes before the real answer comes in (what are these?) - Network::mInstance->skip(4); - BLOCK_END("GameHandler::connect") -} - -bool GameHandler::isConnected() const -{ - if (Network::mInstance == nullptr) - return false; - return Network::mInstance->isConnected(); -} - -void GameHandler::disconnect() const -{ - BLOCK_START("GameHandler::disconnect") - if (Network::mInstance != nullptr) - Network::mInstance->disconnect(); - BLOCK_END("GameHandler::disconnect") -} - -void GameHandler::quit() const -{ - createOutPacket(CMSG_CLIENT_QUIT); -} - -void GameHandler::ping(const int tick) const -{ - createOutPacket(CMSG_MAP_PING); - outMsg.writeInt32(tick, "tick"); -} - -void GameHandler::disconnect2() const -{ - createOutPacket(CMSG_CLIENT_DISCONNECT); -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/gamehandler.h b/src/net/tmwa/gamehandler.h deleted file mode 100644 index 78d30e7e3..000000000 --- a/src/net/tmwa/gamehandler.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_GAMEHANDLER_H -#define NET_TMWA_GAMEHANDLER_H - -#include "net/ea/gamehandler.h" - -namespace TmwAthena -{ - -class GameHandler final : public Ea::GameHandler -{ - public: - GameHandler(); - - A_DELETE_COPY(GameHandler) - - ~GameHandler(); - - void connect() const override final; - - bool isConnected() const override final A_WARN_UNUSED; - - void disconnect() const override final; - - void quit() const override final; - - void ping(const int tick) const override final; - - void disconnect2() const override final; - - void mapLoadedEvent() const override final; - - bool mustPing() const override final A_WARN_UNUSED - { return false; } -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_GAMEHANDLER_H diff --git a/src/net/tmwa/gamerecv.cpp b/src/net/tmwa/gamerecv.cpp deleted file mode 100644 index ab13076fb..000000000 --- a/src/net/tmwa/gamerecv.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/gamerecv.h" - -#include "client.h" -#include "logger.h" - -#include "being/localplayer.h" - -#include "net/messagein.h" - -#include "net/tmwa/network.h" - -#include "debug.h" - -namespace TmwAthena -{ - -extern ServerInfo mapServer; - -void GameRecv::processMapLogin(Net::MessageIn &msg) -{ - unsigned char direction; - uint16_t x, y; - msg.readInt32("tick"); - msg.readCoordinates(x, y, direction, "position"); - msg.readInt16("unknown?"); - logger->log("Protocol: Player start position: (%d, %d)," - " Direction: %d", x, y, direction); - - mLastHost &= 0xffffff; - - Network *const network = Network::mInstance; - if (network != nullptr) - network->pauseDispatch(); - - // Switch now or we'll have problems - client->setState(State::GAME); - if (localPlayer != nullptr) - localPlayer->setTileCoords(x, y); -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/gamerecv.h b/src/net/tmwa/gamerecv.h deleted file mode 100644 index eca251fd2..000000000 --- a/src/net/tmwa/gamerecv.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_GAMERECV_H -#define NET_TMWA_GAMERECV_H - -namespace Net -{ - class MessageIn; -} // namespace Net - -namespace TmwAthena -{ - namespace GameRecv - { - void processMapLogin(Net::MessageIn &msg); - } // namespace GameRecv -} // namespace TmwAthena - -#endif // NET_TMWA_GAMERECV_H diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp deleted file mode 100644 index 0cbaf1c4c..000000000 --- a/src/net/tmwa/generalhandler.cpp +++ /dev/null @@ -1,245 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/generalhandler.h" - -#include "client.h" -#include "configuration.h" - -#include "gui/windows/skilldialog.h" -#include "gui/windows/socialwindow.h" - -#include "gui/widgets/tabs/chat/partytab.h" - -#include "net/tmwa/adminhandler.h" -#include "net/tmwa/beinghandler.h" -#include "net/tmwa/buysellhandler.h" -#include "net/tmwa/chathandler.h" -#include "net/tmwa/charserverhandler.h" -#include "net/tmwa/gamehandler.h" -#include "net/tmwa/guildhandler.h" -#include "net/tmwa/inventoryhandler.h" -#include "net/tmwa/itemhandler.h" -#include "net/tmwa/loginhandler.h" -#include "net/tmwa/network.h" -#include "net/tmwa/npchandler.h" -#include "net/tmwa/partyhandler.h" -#include "net/tmwa/pethandler.h" -#include "net/tmwa/playerhandler.h" -#include "net/tmwa/serverfeatures.h" -#include "net/tmwa/tradehandler.h" -#include "net/tmwa/skillhandler.h" -#include "net/tmwa/questhandler.h" - -#include "net/tmwa/auctionhandler.h" -#include "net/tmwa/bankhandler.h" -#include "net/tmwa/battlegroundhandler.h" -#include "net/tmwa/buyingstorehandler.h" -#include "net/tmwa/cashshophandler.h" -#include "net/tmwa/elementalhandler.h" -#include "net/tmwa/familyhandler.h" -#include "net/tmwa/friendshandler.h" -#include "net/tmwa/homunculushandler.h" -#include "net/tmwa/mail2handler.h" -#include "net/tmwa/mailhandler.h" -#include "net/tmwa/maphandler.h" -#include "net/tmwa/markethandler.h" -#include "net/tmwa/mercenaryhandler.h" -#include "net/tmwa/roulettehandler.h" -#include "net/tmwa/searchstorehandler.h" -#include "net/tmwa/vendinghandler.h" - -#include "utils/delete2.h" -#include "utils/gettext.h" - -#include "debug.h" - -namespace TmwAthena -{ - -GeneralHandler::GeneralHandler() : - mAdminHandler(new AdminHandler), - mBeingHandler(new BeingHandler(config.getBoolValue("EnableSync"))), - mBuySellHandler(new BuySellHandler), - mCharServerHandler(new CharServerHandler), - mChatHandler(new ChatHandler), - mGameHandler(new GameHandler), - mGuildHandler(new GuildHandler), - mInventoryHandler(new InventoryHandler), - mItemHandler(new ItemHandler), - mLoginHandler(new LoginHandler), - mNpcHandler(new NpcHandler), - mPartyHandler(new PartyHandler), - mPetHandler(new PetHandler), - mPlayerHandler(new PlayerHandler), - mSkillHandler(new SkillHandler), - mTradeHandler(new TradeHandler), - mQuestHandler(new QuestHandler), - mServerFeatures(new ServerFeatures), - mAuctionHandler(new AuctionHandler), - mBankHandler(new BankHandler), - mBattleGroundHandler(new BattleGroundHandler), - mBuyingStoreHandler(new BuyingStoreHandler), - mCashShopHandler(new CashShopHandler), - mElementalHandler(new ElementalHandler), - mFamilyHandler(new FamilyHandler), - mFriendsHandler(new FriendsHandler), - mHomunculusHandler(new HomunculusHandler), - mMail2Handler(new Mail2Handler), - mMailHandler(new MailHandler), - mMapHandler(new MapHandler), - mMarketHandler(new MarketHandler), - mMercenaryHandler(new MercenaryHandler), - mRouletteHandler(new RouletteHandler), - mSearchStoreHandler(new SearchStoreHandler), - mVendingHandler(new VendingHandler) -{ - generalHandler = this; -} - -GeneralHandler::~GeneralHandler() -{ - delete2(Network::mInstance); - - delete2(mAdminHandler); - delete2(mBeingHandler); - delete2(mBuySellHandler); - delete2(mCharServerHandler); - delete2(mChatHandler); - delete2(mGameHandler); - delete2(mGuildHandler); - delete2(mInventoryHandler); - delete2(mItemHandler); - delete2(mLoginHandler); - delete2(mNpcHandler); - delete2(mPartyHandler); - delete2(mPetHandler); - delete2(mPlayerHandler); - delete2(mSkillHandler); - delete2(mTradeHandler); - delete2(mQuestHandler); - delete2(mServerFeatures); - delete2(mAuctionHandler); - delete2(mBankHandler); - delete2(mBattleGroundHandler); - delete2(mBuyingStoreHandler); - delete2(mCashShopHandler); - delete2(mElementalHandler); - delete2(mFamilyHandler); - delete2(mFriendsHandler); - delete2(mHomunculusHandler); - delete2(mMail2Handler); - delete2(mMailHandler); - delete2(mMapHandler); - delete2(mMarketHandler); - delete2(mMercenaryHandler); - delete2(mRouletteHandler); - delete2(mSearchStoreHandler); - delete2(mVendingHandler); -} - -void GeneralHandler::load() const -{ - new Network; - Network::mInstance->registerHandlers(); -} - -void GeneralHandler::reload() const -{ - if (Network::mInstance != nullptr) - Network::mInstance->disconnect(); - - static_cast<LoginHandler*>(mLoginHandler)->clearWorlds(); - const CharServerHandler *const charHandler = - static_cast<CharServerHandler*>(mCharServerHandler); - charHandler->setCharCreateDialog(nullptr); - charHandler->setCharSelectDialog(nullptr); - PartyHandler::reload(); -} - -void GeneralHandler::reloadPartially() const -{ - PartyHandler::reload(); -} - -void GeneralHandler::unload() const -{ - clearHandlers(); -} - -void GeneralHandler::flushSend() const -{ - if (Network::mInstance == nullptr) - return; - - Network::mInstance->flush(); -} - -void GeneralHandler::flushNetwork() const -{ - if (Network::mInstance == nullptr) - return; - - BLOCK_START("GeneralHandler::flushNetwork 1") - Network::mInstance->flush(); - BLOCK_END("GeneralHandler::flushNetwork 1") - Network::mInstance->dispatchMessages(); - - BLOCK_START("GeneralHandler::flushNetwork 3") - if (Network::mInstance->getState() == Network::NET_ERROR) - { - if (!Network::mInstance->getError().empty()) - { - errorMessage = Network::mInstance->getError(); - } - else - { - // TRANSLATORS: error message - errorMessage = _("Got disconnected from server!"); - } - - client->setState(State::ERROR); - } - BLOCK_END("GeneralHandler::flushNetwork 3") -} - -void GeneralHandler::clearHandlers() const -{ - if (Network::mInstance != nullptr) - Network::mInstance->clearHandlers(); -} - -void GeneralHandler::gameStarted() const -{ - if (skillDialog != nullptr) - skillDialog->loadSkills(); -} - -void GeneralHandler::gameEnded() const -{ - if (socialWindow != nullptr) - socialWindow->removeTab(Ea::taParty); - - delete2(partyTab); -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/generalhandler.h b/src/net/tmwa/generalhandler.h deleted file mode 100644 index 818cb4be3..000000000 --- a/src/net/tmwa/generalhandler.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_GENERALHANDLER_H -#define NET_TMWA_GENERALHANDLER_H - -#include "net/generalhandler.h" - -namespace TmwAthena -{ -class AdminHandler; -class BeingHandler; -class BuySellHandler; -class CharServerHandler; -class ChatHandler; -class GameHandler; -class GuildHandler; -class InventoryHandler; -class ItemHandler; -class LoginHandler; -class NpcHandler; -class PartyHandler; -class PetHandler; -class PlayerHandler; -class SkillHandler; -class TradeHandler; -class QuestHandler; -class ServerFeatures; -class AuctionHandler; -class BankHandler; -class BattleGroundHandler; -class BuyingStoreHandler; -class CashShopHandler; -class ElementalHandler; -class FamilyHandler; -class FriendsHandler; -class HomunculusHandler; -class Mail2Handler; -class MailHandler; -class MapHandler; -class MarketHandler; -class MercenaryHandler; -class RouletteHandler; -class SearchStoreHandler; -class VendingHandler; - -class GeneralHandler final : public Net::GeneralHandler -{ - public: - GeneralHandler(); - - A_DELETE_COPY(GeneralHandler) - - ~GeneralHandler(); - - void load() const override final; - - void reload() const override final; - - void unload() const override final; - - void flushNetwork() const override final; - - void flushSend() const override final; - - void clearHandlers() const override final; - - void reloadPartially() const override final; - - void gameStarted() const override final; - - void gameEnded() const override final; - - protected: - AdminHandler *mAdminHandler; - BeingHandler *mBeingHandler; - BuySellHandler *mBuySellHandler; - CharServerHandler *mCharServerHandler; - ChatHandler *mChatHandler; - GameHandler *mGameHandler; - GuildHandler *mGuildHandler; - InventoryHandler *mInventoryHandler; - ItemHandler *mItemHandler; - LoginHandler *mLoginHandler; - NpcHandler *mNpcHandler; - PartyHandler *mPartyHandler; - PetHandler *mPetHandler; - PlayerHandler *mPlayerHandler; - SkillHandler *mSkillHandler; - TradeHandler *mTradeHandler; - QuestHandler *mQuestHandler; - ServerFeatures *mServerFeatures; - AuctionHandler *mAuctionHandler; - BankHandler *mBankHandler; - BattleGroundHandler *mBattleGroundHandler; - BuyingStoreHandler *mBuyingStoreHandler; - CashShopHandler *mCashShopHandler; - ElementalHandler *mElementalHandler; - FamilyHandler *mFamilyHandler; - FriendsHandler *mFriendsHandler; - HomunculusHandler *mHomunculusHandler; - Mail2Handler *mMail2Handler; - MailHandler *mMailHandler; - MapHandler *mMapHandler; - MarketHandler *mMarketHandler; - MercenaryHandler *mMercenaryHandler; - RouletteHandler *mRouletteHandler; - SearchStoreHandler *mSearchStoreHandler; - VendingHandler *mVendingHandler; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_GENERALHANDLER_H diff --git a/src/net/tmwa/generalrecv.cpp b/src/net/tmwa/generalrecv.cpp deleted file mode 100644 index 0bc1c6a4c..000000000 --- a/src/net/tmwa/generalrecv.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/generalrecv.h" - -#include "client.h" -#include "logger.h" - -#include "net/messagein.h" - -#include "utils/cast.h" -#include "utils/gettext.h" - -#include "debug.h" - -namespace TmwAthena -{ - -ServerInfo charServer; -ServerInfo mapServer; - -void GeneralRecv::processConnectionProblem(Net::MessageIn &msg) -{ - const uint8_t code = msg.readUInt8("flag"); - logger->log("Connection problem: %u", CAST_U32(code)); - - switch (code) - { - case 0: - // TRANSLATORS: error message - errorMessage = _("Authentication failed."); - break; - case 1: - // TRANSLATORS: error message - errorMessage = _("No servers available."); - break; - case 2: - if (client->getState() == State::GAME) - { - // TRANSLATORS: error message - errorMessage = _("Someone else is trying to use this " - "account."); - } - else - { - // TRANSLATORS: error message - errorMessage = _("This account is already logged in."); - } - break; - case 3: - // TRANSLATORS: error message - errorMessage = _("Speed hack detected."); - break; - case 8: - // TRANSLATORS: error message - errorMessage = _("Duplicated login."); - break; - default: - // TRANSLATORS: error message - errorMessage = _("Unknown connection error."); - break; - } - client->setState(State::ERROR); -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/generalrecv.h b/src/net/tmwa/generalrecv.h deleted file mode 100644 index 92f0e71f8..000000000 --- a/src/net/tmwa/generalrecv.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_GENERALRECV_H -#define NET_TMWA_GENERALRECV_H - -namespace Net -{ - class MessageIn; -} // namespace Net - -namespace TmwAthena -{ - namespace GeneralRecv - { - void processConnectionProblem(Net::MessageIn &msg); - } // namespace GeneralRecv -} // namespace TmwAthena - -#endif // NET_TMWA_GENERALRECV_H diff --git a/src/net/tmwa/guildhandler.cpp b/src/net/tmwa/guildhandler.cpp deleted file mode 100644 index 5b41ef49a..000000000 --- a/src/net/tmwa/guildhandler.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/guildhandler.h" - -#include "debug.h" - -namespace TmwAthena -{ - -GuildHandler::GuildHandler() : - Net::GuildHandler() -{ - guildHandler = this; -} - -GuildHandler::~GuildHandler() -{ - guildHandler = nullptr; -} - -void GuildHandler::clear() const -{ -} - -ChatTab *GuildHandler::getTab() const -{ - return nullptr; -} - -void GuildHandler::create(const std::string &name A_UNUSED) const -{ -} - -void GuildHandler::invite(const std::string &name A_UNUSED) const -{ -} - -void GuildHandler::invite(const Being *const being A_UNUSED) const -{ -} - -void GuildHandler::inviteResponse(const int guildId A_UNUSED, - const bool response A_UNUSED) const -{ -} - -void GuildHandler::leave(const int guildId A_UNUSED) const -{ -} - -void GuildHandler::kick(const GuildMember *restrict const member A_UNUSED, - const std::string &restrict reason A_UNUSED) const -{ -} - -void GuildHandler::chat(const std::string &text A_UNUSED) const -{ -} - -void GuildHandler::memberList() const -{ -} - -void GuildHandler::info() const -{ -} - -void GuildHandler::changeMemberPostion(const GuildMember *const member - A_UNUSED, - const int level A_UNUSED) const -{ -} - -void GuildHandler::changeNotice(const int guildId A_UNUSED, - const std::string &restrict msg1 A_UNUSED, - const std::string &restrict msg2 A_UNUSED) - const -{ -} - -void GuildHandler::checkMaster() const -{ -} - -void GuildHandler::requestAlliance(const Being *const being A_UNUSED) const -{ -} - -void GuildHandler::requestAllianceResponse(const int beingId A_UNUSED, - const bool accept A_UNUSED) const -{ -} - -void GuildHandler::endAlliance(const int guildId A_UNUSED, - const int flag A_UNUSED) const -{ -} - -void GuildHandler::changePostionInfo(const int posId A_UNUSED, - const int mode A_UNUSED, - const int ranking A_UNUSED, - const int payRate A_UNUSED, - const std::string &name A_UNUSED) const -{ -} - -void GuildHandler::requestOpposition(const Being *const being A_UNUSED) const -{ -} - -void GuildHandler::breakGuild(const std::string &name A_UNUSED) const -{ -} - -void GuildHandler::changeEmblem(std::string emblem A_UNUSED) const -{ -} - -void GuildHandler::requestEmblem(const int guildId A_UNUSED) const -{ -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/guildhandler.h b/src/net/tmwa/guildhandler.h deleted file mode 100644 index dcb9d6b7c..000000000 --- a/src/net/tmwa/guildhandler.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_GUILDHANDLER_H -#define NET_TMWA_GUILDHANDLER_H - -#include "net/guildhandler.h" - -namespace TmwAthena -{ - -class GuildHandler final : public Net::GuildHandler -{ - public: - GuildHandler(); - - A_DELETE_COPY(GuildHandler) - - ~GuildHandler(); - - void clear() const override final; - - ChatTab *getTab() const override final; - - void create(const std::string &name) const override final; - - void invite(const std::string &name) const override final; - - void invite(const Being *const being) const override final; - - void inviteResponse(const int guildId, - const bool response) const override final; - - void leave(const int guildId) const override final; - - void kick(const GuildMember *restrict const member, - const std::string &restrict reason) const override final; - - void chat(const std::string &text) const override final; - - void memberList() const override final; - - void info() const override final; - - void changeMemberPostion(const GuildMember *const member, - const int level) const override final; - - void changeNotice(const int guildId, - const std::string &restrict msg1, - const std::string &restrict msg2) - const override final; - - void checkMaster() const override final; - - void requestAlliance(const Being *const being) const override final - A_CONST; - - void requestAllianceResponse(const int beingId, - const bool accept) const override final - A_CONST; - - void endAlliance(const int guildId, - const int flag) const override final A_CONST; - - void changePostionInfo(const int posId, - const int mode, - const int ranking, - const int payRate, - const std::string &name) const override final - A_CONST; - - void requestOpposition(const Being *const being) const override final - A_CONST; - - void breakGuild(const std::string &name) const override final A_CONST; - - void changeEmblem(std::string emblem) const override final A_CONST; - - void requestEmblem(const int guildId) const override final A_CONST; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_GUILDHANDLER_H diff --git a/src/net/tmwa/guildmanager.cpp b/src/net/tmwa/guildmanager.cpp deleted file mode 100644 index 5484f1b51..000000000 --- a/src/net/tmwa/guildmanager.cpp +++ /dev/null @@ -1,543 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifdef TMWA_SUPPORT -#include "net/tmwa/guildmanager.h" - -#include "actormanager.h" -#include "client.h" -#include "configuration.h" -#include "guild.h" -#include "notifymanager.h" - -#include "being/localplayer.h" - -#include "enums/resources/notifytypes.h" - -#include "gui/windows/chatwindow.h" -#include "gui/windows/socialwindow.h" - -#include "gui/widgets/tabs/chat/emulateguildtab.h" - -#include "net/chathandler.h" -#include "net/packetlimiter.h" - -#include "utils/delete2.h" -#include "utils/timer.h" - -#include "debug.h" - -GuildManager *guildManager = nullptr; - -static const int requestTimeout = 5; - -bool GuildManager::mEnableGuildBot = false; - -GuildManager::GuildManager() : - mGotInfo(false), - mGotName(false), - mSentInfoRequest(false), - mSentNameRequest(false), - mHavePower(false), - mTempList(), - mTab(nullptr), - mRequest(false), - mRequestTime(cur_time + 3), - mGotOnlineInfo(false) -{ -} - -GuildManager::~GuildManager() -{ - delete2(mTab); -} - -void GuildManager::init() -{ - int val = serverConfig.getValue("enableGuildBot", -1); - if (val == -1) - { - if (Client::isTmw()) - val = 1; - else - val = 0; - serverConfig.setValue("enableGuildBot", val); - } - mEnableGuildBot = (val != 0); - if (mEnableGuildBot) - { - if (guildManager == nullptr) - guildManager = new GuildManager; - else - guildManager->reload(); - } - else if (guildManager != nullptr) - { - delete2(guildManager); - } -} - -void GuildManager::reload() -{ - mGotInfo = false; - mGotName = false; - mHavePower = false; - mRequest = false; - mSentNameRequest = false; - mSentInfoRequest = false; - mGotOnlineInfo = false; - mRequestTime = 0; - mTempList.clear(); - - if (socialWindow != nullptr) - { - Guild *const guild = Guild::getGuild(1); - if ((guild != nullptr) && (socialWindow != nullptr)) - socialWindow->removeTab(guild); - } - delete2(mTab); -} - -void GuildManager::send(const std::string &msg) -{ - chatHandler->privateMessage("guild", msg); -} - -void GuildManager::chat(const std::string &msg) -{ - if ((localPlayer == nullptr) || (mTab == nullptr)) - return; - - chatHandler->privateMessage("guild", msg); - mTab->chatLog(localPlayer->getName(), msg); -} - -void GuildManager::getNames(StringVect &names) const -{ - const Guild *const guild = createGuild(); - if (guild != nullptr) - guild->getNames(names); -} - -void GuildManager::requestGuildInfo() -{ - if (mRequest && mRequestTime + 15 < cur_time) - return; - - if (!mGotName && !mSentNameRequest) - { - if (!PacketLimiter::limitPackets(PacketType::PACKET_WHISPER)) - return; - send("!info " + toString(tick_time)); - mRequest = true; - mSentNameRequest = true; - mRequestTime = cur_time + requestTimeout; - } - else if (!mGotInfo && !mSentInfoRequest && !mSentNameRequest) - { - if (!PacketLimiter::limitPackets(PacketType::PACKET_WHISPER)) - return; - send("!getonlineinfo " + toString(tick_time)); - mRequest = true; - mSentInfoRequest = true; - mRequestTime = cur_time + requestTimeout; - } -} - -void GuildManager::slowLogic() -{ - if (!mGotOnlineInfo && mGotName && mRequestTime < cur_time) - { - if (!PacketLimiter::limitPackets(PacketType::PACKET_WHISPER)) - return; - send("!getonlineinfo " + toString(tick_time)); - mRequest = true; - mSentInfoRequest = true; - mRequestTime = cur_time + requestTimeout; - } -} - -void GuildManager::updateList() -{ - Guild *const guild = Guild::getGuild(1); - if (guild != nullptr) - { - guild->setServerGuild(false); - StringVectCIter it = mTempList.begin(); - const StringVectCIter it_end = mTempList.end(); - int i = 0; - while (it != it_end) - { - std::string name = *it; - const size_t sz = name.size(); - if (sz > 1) - { - const int status = atoi(name.substr(sz - 1).c_str()); - - name = name.substr(0, sz - 1); - GuildMember *const m = guild->addMember( - fromInt(i, BeingId), 0, name); - if (m != nullptr) - { - m->setOnline((status & 1) != 0); - m->setGender(Gender::UNSPECIFIED); - if ((status & 2) != 0) - m->setPos(10); - else - m->setPos(0); - if (localPlayer != nullptr && - name == localPlayer->getName()) - { - mHavePower = ((status & 2) != 0); - m->setOnline(true); - } - } - } - ++ it; - i ++; - } - guild->sort(); - createTab(guild); - if (actorManager != nullptr) - { - actorManager->updatePlayerGuild(); - actorManager->updatePlayerColors(); - } - if (socialWindow != nullptr) - socialWindow->updateGuildCounter(); - } - mTempList.clear(); - mSentInfoRequest = false; - mGotInfo = true; -} - -void GuildManager::createTab(Guild *const guild) -{ - if (mTab == nullptr) - { - mTab = new EmulateGuildTab(chatWindow); - if (config.getBoolValue("showChatHistory")) - mTab->loadFromLogFile("#Guild"); - if (localPlayer != nullptr) - localPlayer->addGuild(guild); - } -} - -Guild *GuildManager::createGuild() const -{ - Guild *const guild = Guild::getGuild(1); - if (guild == nullptr) - return nullptr; - - guild->setServerGuild(false); - return guild; -} - -bool GuildManager::processGuildMessage(const std::string &msg) -{ - const bool res = process(msg); - - if (!mRequest) - requestGuildInfo(); - - return res; -} - -bool GuildManager::process(std::string msg) -{ - if (msg.size() > 4 && msg[0] == '#' && msg[1] == '#') - msg = msg.substr(3); - - const bool haveNick = (msg.find(": ") != std::string::npos); - - if (!haveNick && findCutLast(msg, " is now Offline.")) - { - Guild *const guild = createGuild(); - if (guild == nullptr) - return false; - if (msg.size() < 4) - return false; - if (msg[0] == '#' && msg[1] == '#') - msg = msg.substr(3); - - GuildMember *const m = guild->addMember(msg); - if (m != nullptr) - m->setOnline(false); - guild->sort(); - mRequest = false; - if (mTab != nullptr) - mTab->showOnline(msg, Online_false); - if (socialWindow != nullptr) - socialWindow->updateGuildCounter(); - return true; - } - else if (!haveNick && findCutLast(msg, " is now Online.")) - { - Guild *const guild = createGuild(); - if (guild == nullptr) - return false; - if (msg.size() < 4) - return false; - if (msg[0] == '#' && msg[1] == '#') - msg = msg.substr(3); - GuildMember *const m = guild->addMember(msg); - if (m != nullptr) - m->setOnline(true); - guild->sort(); - mRequest = false; - if (mTab != nullptr) - mTab->showOnline(msg, Online_true); - if (socialWindow != nullptr) - socialWindow->updateGuildCounter(); - return true; - } - else if (findCutFirst(msg, "Welcome to the ")) - { - Guild *const guild = createGuild(); - if (guild == nullptr) - return false; -// logger->log("welcome message: %s", msg.c_str()); - const size_t pos = msg.find("! ("); - if (pos == std::string::npos) - return false; - msg = msg.substr(0, pos); - guild->setName(msg); - if (localPlayer != nullptr) - localPlayer->setGuildName(msg); - mGotName = true; - mSentNameRequest = false; - mRequest = false; - return true; - } - else if (findCutFirst(msg, "Player name: ")) - { - Guild *const guild = createGuild(); - if (guild == nullptr) - return false; - size_t pos = msg.find("Access Level: "); - if (pos == std::string::npos) - return false; - - msg = msg.substr(pos); - if (!findCutFirst(msg, "Access Level: ")) - return false; - - pos = msg.find(", Guild:"); - if (pos == std::string::npos) - return false; - - const int level = atoi(msg.substr(0, pos).c_str()); - if (level >= 10) - mHavePower = true; - else - mHavePower = false; - - msg = msg.substr(pos + strlen(", Guild:")); - pos = msg.find(", No. Of Online Players: "); - if (pos == std::string::npos) - return false; - - msg = msg.substr(0, pos); -// logger->log("guild name: %s", msg.c_str()); - - guild->setName(msg); - if (localPlayer != nullptr) - localPlayer->setGuildName(msg); - mGotName = true; - mSentNameRequest = false; - mRequest = false; - return true; - } - else if (findCutFirst(msg, "OL#")) - { -// logger->log("OL"); - mTempList.clear(); - splitToStringVector(mTempList, msg, '#'); - if (msg.empty() || msg[msg.size() - 1] != '#') - updateList(); - mRequest = false; - mGotOnlineInfo = true; - return true; - } - else if (findCutFirst(msg, "oL#")) - { -// logger->log("oL"); - splitToStringVector(mTempList, msg, '#'); - if (msg.empty() || msg[msg.size() - 1] != '#') - updateList(); - mRequest = false; - mGotOnlineInfo = true; - return true; - } - else if (msg == "You are currently not in a guild. For more information " - "or to discuss the possibility of adding you own guild " - "please contact Jero.") - { - mRequest = true; - return true; - } - else if (findCutFirst(msg, "You have been invited to the ") - && findCutLast(msg, " guild chat. If you would like to accept " - "this invitation please reply \"yes\" and if not then \"no\" .")) - { - if (socialWindow != nullptr) - socialWindow->showGuildInvite(msg, 1, ""); - return true; - } - else if (!haveNick && (findCutLast(msg, " has been removed " - "from the Guild.") || findCutLast(msg, " has left the Guild."))) - { - Guild *const guild = createGuild(); - if (guild == nullptr) - return false; - if (msg.size() < 4) - return false; - if (msg[0] == '#' && msg[1] == '#') - msg = msg.substr(3); - - if (actorManager != nullptr) - { - Being *const b = actorManager->findBeingByName( - msg, ActorType::Player); - - if (b != nullptr) - { - b->clearGuilds(); - b->setGuildName(""); - b->updateColors(); - } - } - - guild->removeMember(msg); - return true; - } - else if (msg == "You have been removed from the Guild" || - msg == "You have left the Guild") - { - return afterRemove(); - } - Guild *const guild = createGuild(); - if (guild == nullptr) - return false; - if (mTab == nullptr) - { - createTab(guild); - } - if (mTab != nullptr) - { - const size_t pos = msg.find(": ", 0); - if (pos != std::string::npos) - { - const std::string sender_name = msg.substr(0, pos); - if (guild->getMember(sender_name) == nullptr) - { - mTab->chatLog(msg, ChatMsgType::BY_SERVER); - return true; - } - - msg.erase(0, pos + 2); - if (msg.size() > 3 && msg[0] == '#' && msg[1] == '#') - msg.erase(0, 3); - - trim(msg); - mTab->chatLog(sender_name, msg); - } - else - { - mTab->chatLog(msg, ChatMsgType::BY_SERVER); - } - return true; - } - return false; -} - -void GuildManager::kick(const std::string &msg) -{ - send("!remove " + msg); -} - -void GuildManager::invite(const std::string &msg) -{ - send("!invite " + msg); -} - -void GuildManager::leave() -{ - send("!leave"); -} - -void GuildManager::notice(const std::string &msg) -{ - if (msg.empty()) - send("!removemotd"); - else - send("!setmotd " + msg); -} - -void GuildManager::clear() -{ - if (socialWindow != nullptr) - { - Guild *const guild = Guild::getGuild(1); - if (guild != nullptr) - socialWindow->removeTab(guild); - } -} - -void GuildManager::inviteResponse(const bool response) -{ - if (response) - send("yes"); - else - send("no"); -} - -bool GuildManager::afterRemove() -{ - Guild *const guild = createGuild(); - if (guild == nullptr) - return false; - guild->removeFromMembers(); - guild->clearMembers(); - if (localPlayer != nullptr) - { - localPlayer->setGuildName(""); - localPlayer->clearGuilds(); - } - NotifyManager::notify(NotifyTypes::GUILD_LEFT); - delete2(mTab); - - if (socialWindow != nullptr) - socialWindow->removeTab(guild); - if (actorManager != nullptr) - { - actorManager->updatePlayerGuild(); - actorManager->updatePlayerColors(); - } - reload(); - return true; -} - -ChatTab *GuildManager::getTab() -{ - return mTab; -} - -#endif // TMWA_SUPPORT diff --git a/src/net/tmwa/guildmanager.h b/src/net/tmwa/guildmanager.h deleted file mode 100644 index 67f88927d..000000000 --- a/src/net/tmwa/guildmanager.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_GUILDMANAGER_H -#define NET_TMWA_GUILDMANAGER_H - -#ifdef TMWA_SUPPORT - -#include "utils/stringvector.h" - -#include "localconsts.h" - -class ChatTab; -class Guild; -class EmulateGuildTab; - -class GuildManager final -{ - public: - GuildManager(); - - A_DELETE_COPY(GuildManager) - - ~GuildManager(); - - static void init(); - - void chat(const std::string &msg); - - static void send(const std::string &msg); - - void getNames(StringVect &names) const; - - void requestGuildInfo(); - - void updateList(); - - static bool getEnableGuildBot() A_WARN_UNUSED - { return mEnableGuildBot; } - - static void kick(const std::string &msg); - - static void invite(const std::string &msg); - - static void leave(); - - static void notice(const std::string &msg); - - void createTab(Guild *const guild); - - Guild *createGuild() const A_WARN_UNUSED; - - static void clear(); - - void reload(); - - static void inviteResponse(const bool response); - - bool afterRemove(); - - void slowLogic(); - - bool havePower() const A_WARN_UNUSED - { return mHavePower; } - - ChatTab *getTab(); - - bool processGuildMessage(const std::string &msg); - - private: - bool process(std::string msg); - - static bool mEnableGuildBot; - bool mGotInfo; - bool mGotName; - bool mSentInfoRequest; - bool mSentNameRequest; - bool mHavePower; - StringVect mTempList; - EmulateGuildTab *mTab; - bool mRequest; - time_t mRequestTime; - bool mGotOnlineInfo; -}; - -extern GuildManager *guildManager; - -#endif // TMWA_SUPPORT -#endif // NET_TMWA_GUILDMANAGER_H diff --git a/src/net/tmwa/homunculushandler.cpp b/src/net/tmwa/homunculushandler.cpp deleted file mode 100644 index 0d1bb2e62..000000000 --- a/src/net/tmwa/homunculushandler.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/homunculushandler.h" - -#include "debug.h" - -namespace TmwAthena -{ - -HomunculusHandler::HomunculusHandler() -{ - homunculusHandler = this; -} - -HomunculusHandler::~HomunculusHandler() -{ - homunculusHandler = nullptr; -} - -void HomunculusHandler::setName(const std::string &name A_UNUSED) const -{ -} - -void HomunculusHandler::moveToMaster() const -{ -} - -void HomunculusHandler::move(const int x A_UNUSED, const int y A_UNUSED) const -{ -} - -void HomunculusHandler::attack(const BeingId targetId A_UNUSED, - const Keep keep A_UNUSED) const -{ -} - -void HomunculusHandler::feed() const -{ -} - -void HomunculusHandler::fire() const -{ -} - -void HomunculusHandler::talk(const std::string &restrict text A_UNUSED) const -{ -} - -void HomunculusHandler::emote(const uint8_t emoteId A_UNUSED) const -{ -} - -void HomunculusHandler::setDirection(const unsigned char type A_UNUSED) const -{ -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/homunculushandler.h b/src/net/tmwa/homunculushandler.h deleted file mode 100644 index bd00927fa..000000000 --- a/src/net/tmwa/homunculushandler.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_HOMUNCULUSHANDLER_H -#define NET_TMWA_HOMUNCULUSHANDLER_H - -#include "net/homunculushandler.h" - -namespace TmwAthena -{ - -class HomunculusHandler final : public Net::HomunculusHandler -{ - public: - HomunculusHandler(); - - A_DELETE_COPY(HomunculusHandler) - - ~HomunculusHandler(); - - void setName(const std::string &name) const override final A_CONST; - - void moveToMaster() const override final A_CONST; - - void move(const int x, const int y) const override final A_CONST; - - void attack(const BeingId targetId, - const Keep keep) const override final A_CONST; - - void feed() const override final A_CONST; - - void fire() const override final A_CONST; - - void talk(const std::string &restrict text) const override final - A_CONST; - - void emote(const uint8_t emoteId) const override final A_CONST; - - void setDirection(const unsigned char type) const override final - A_CONST; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_HOMUNCULUSHANDLER_H diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp deleted file mode 100644 index 7afbf746e..000000000 --- a/src/net/tmwa/inventoryhandler.cpp +++ /dev/null @@ -1,196 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/inventoryhandler.h" - -#include "const/net/inventory.h" - -#include "enums/equipslot.h" - -#include "net/tmwa/messageout.h" -#include "net/tmwa/protocolout.h" - -#include "resources/item/item.h" - -#include "debug.h" - -// missing EQUIP_RING1_SLOT -const EquipSlot::Type EQUIP_CONVERT[] = -{ - EquipSlot::PROJECTILE_SLOT, // 0 0 - EquipSlot::FEET_SLOT, // 1 SPRITE_HAIR - EquipSlot::LEGS_SLOT, // 2 SPRITE_WEAPON - EquipSlot::TORSO_SLOT, // 3 SPRITE_HEAD_BOTTOM - EquipSlot::PROJECTILE_SLOT, // 4 0 - EquipSlot::NECK_SLOT, // 5 SPRITE_RING - EquipSlot::PROJECTILE_SLOT, // 6 0 - EquipSlot::HEAD_SLOT, // 7 SPRITE_CLOTHES_COLOR - EquipSlot::RING2_SLOT, // 8 0 - EquipSlot::GLOVES_SLOT, // 9 SPRITE_SHOES - EquipSlot::FIGHT1_SLOT, // 10 SPRITE_BODY - EquipSlot::FIGHT2_SLOT, // 11 SPRITE_FLOOR - EquipSlot::EVOL_RING1_SLOT, // 12 SPRITE_ROBE - EquipSlot::EVOL_RING2_SLOT, // 13 SPRITE_EVOL2 -}; - -namespace TmwAthena -{ - -InventoryHandler::InventoryHandler() : - Ea::InventoryHandler() -{ - inventoryHandler = this; -} - -InventoryHandler::~InventoryHandler() -{ - inventoryHandler = nullptr; -} - -void InventoryHandler::equipItem(const Item *const item) const -{ - if (item == nullptr) - return; - - createOutPacket(CMSG_PLAYER_EQUIP); - outMsg.writeInt16(CAST_S16( - item->getInvIndex() + INVENTORY_OFFSET), "index"); - outMsg.writeInt16(0, "unused"); -} - -void InventoryHandler::unequipItem(const Item *const item) const -{ - if (item == nullptr) - return; - - createOutPacket(CMSG_PLAYER_UNEQUIP); - outMsg.writeInt16(CAST_S16( - item->getInvIndex() + INVENTORY_OFFSET), "index"); -} - -void InventoryHandler::useItem(const Item *const item) const -{ - if (item == nullptr) - return; - - createOutPacket(CMSG_PLAYER_INVENTORY_USE); - outMsg.writeInt16(CAST_S16( - item->getInvIndex() + INVENTORY_OFFSET), "index"); - outMsg.writeInt32(item->getId(), "item id"); -} - -void InventoryHandler::useItem(const Item *const item, - const int16_t useType A_UNUSED) const -{ - if (item == nullptr) - return; - - createOutPacket(CMSG_PLAYER_INVENTORY_USE); - outMsg.writeInt16(CAST_S16( - item->getInvIndex() + INVENTORY_OFFSET), "index"); - outMsg.writeInt32(item->getId(), "item id"); -} - -void InventoryHandler::dropItem(const Item *const item, const int amount) const -{ - if (item == nullptr) - return; - - createOutPacket(CMSG_PLAYER_INVENTORY_DROP); - outMsg.writeInt16(CAST_S16( - item->getInvIndex() + INVENTORY_OFFSET), "index"); - outMsg.writeInt16(CAST_S16(amount), "amount"); -} - -void InventoryHandler::closeStorage() const -{ - createOutPacket(CMSG_CLOSE_STORAGE); -} - -void InventoryHandler::moveItem2(const InventoryTypeT source, - const int slot, - const int amount, - const InventoryTypeT destination) const -{ - if (source == InventoryType::Inventory && - destination == InventoryType::Storage) - { - createOutPacket(CMSG_MOVE_TO_STORAGE); - outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), - "index"); - outMsg.writeInt32(amount, "amount"); - } - else if (source == InventoryType::Storage && - destination == InventoryType::Inventory) - { - createOutPacket(CMSG_MOVE_FROM_STORAGE); - outMsg.writeInt16(CAST_S16(slot + STORAGE_OFFSET), - "index"); - outMsg.writeInt32(amount, "amount"); - } -} - -void InventoryHandler::useCard(const Item *const item A_UNUSED) -{ -} - -void InventoryHandler::insertCard(const int cardIndex A_UNUSED, - const int itemIndex A_UNUSED) const -{ -} - -void InventoryHandler::favoriteItem(const Item *const item A_UNUSED, - const bool favorite A_UNUSED) const -{ -} - -void InventoryHandler::selectEgg(const Item *const item A_UNUSED) const -{ -} - -int InventoryHandler::convertFromServerSlot(const int serverSlot) const -{ - if (serverSlot < 0 || serverSlot > 13) - return 0; - - return CAST_S32(EQUIP_CONVERT[serverSlot]); -} - -void InventoryHandler::selectCart(const BeingId accountId A_UNUSED, - const int type A_UNUSED) const -{ -} - -void InventoryHandler::identifyItem(const Item *const item A_UNUSED) const -{ -} - -void InventoryHandler::mergeItemsAck(const STD_VECTOR<Item*> &items A_UNUSED) - const -{ -} - -void InventoryHandler::mergetItemsCancel() const -{ -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h deleted file mode 100644 index 5bf67f9f1..000000000 --- a/src/net/tmwa/inventoryhandler.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_INVENTORYHANDLER_H -#define NET_TMWA_INVENTORYHANDLER_H - -#include "net/ea/inventoryhandler.h" - -namespace TmwAthena -{ - -class InventoryHandler final : public Ea::InventoryHandler -{ - public: - InventoryHandler(); - - A_DELETE_COPY(InventoryHandler) - - ~InventoryHandler(); - - void equipItem(const Item *const item) const override final; - - void unequipItem(const Item *const item) const override final; - - void useItem(const Item *const item) const override final; - - void useItem(const Item *const item, - const int16_t useType) const override final; - - void dropItem(const Item *const item, - const int amount) const override final; - - void closeStorage() const override final; - - void moveItem2(const InventoryTypeT source, - const int slot, - const int amount, - const InventoryTypeT destination) const override final; - - void useCard(const Item *const item) override final A_CONST; - - void insertCard(const int cardIndex, - const int itemIndex) const override final A_CONST; - - void favoriteItem(const Item *const item, - const bool favorite) const override final A_CONST; - - void selectEgg(const Item *const item) const override final A_CONST; - - int convertFromServerSlot(const int serverSlot) - const override final A_WARN_UNUSED; - - void selectCart(const BeingId accountId, - const int type) const override final; - - void identifyItem(const Item *const item) const override final; - - void mergeItemsAck(const STD_VECTOR<Item*> &items) const - override final; - - void mergetItemsCancel() const override final; - - int getProjectileSlot() const override final - { return 10; } - - int getItemIndex() const override final A_WARN_UNUSED - { return 0; } -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_INVENTORYHANDLER_H diff --git a/src/net/tmwa/inventoryrecv.cpp b/src/net/tmwa/inventoryrecv.cpp deleted file mode 100644 index 1dcc445d7..000000000 --- a/src/net/tmwa/inventoryrecv.cpp +++ /dev/null @@ -1,563 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/inventoryrecv.h" - -#include "notifymanager.h" - -#include "being/localplayer.h" - -#include "const/net/inventory.h" - -#include "enums/equipslot.h" - -#include "enums/resources/notifytypes.h" - -#include "listeners/arrowslistener.h" - -#include "net/inventoryhandler.h" -#include "net/messagein.h" - -#include "net/ea/equipbackend.h" -#include "net/ea/inventoryrecv.h" - -#include "debug.h" - -namespace TmwAthena -{ - -namespace InventoryRecv -{ - const EquipSlot::Type EQUIP_POINTS[EquipSlot::VECTOREND] = - { - EquipSlot::LEGS_SLOT, // Lower Headgear - EquipSlot::FIGHT1_SLOT, // Weapon - EquipSlot::GLOVES_SLOT, // Garment - EquipSlot::RING2_SLOT, // Accessory 1 - EquipSlot::RING1_SLOT, // Armor - EquipSlot::FIGHT2_SLOT, // Shield - EquipSlot::FEET_SLOT, // Footgear - EquipSlot::NECK_SLOT, // Accessory 2 - EquipSlot::HEAD_SLOT, // Upper Headgear - EquipSlot::TORSO_SLOT, // Middle Headgear - EquipSlot::EVOL_RING1_SLOT, // Costume Top Headgear - EquipSlot::EVOL_RING2_SLOT, // Costume Mid Headgear - EquipSlot::PROJECTILE_SLOT, // Costume Low Headgear - EquipSlot::COSTUME_ROBE_SLOT, // Costume Garment/Robe - EquipSlot::MISSING1_SLOT, // Missing slot 1 - EquipSlot::MISSING2_SLOT, // Missing slot 2 - EquipSlot::SHADOW_ARMOR_SLOT, // Shadow Armor - EquipSlot::SHADOW_WEAPON_SLOT, // Shadow Weapon - EquipSlot::SHADOW_SHIELD_SLOT, // Shadow Shield - EquipSlot::SHADOW_SHOES_SLOT, // Shadow Shoes - EquipSlot::SHADOW_ACCESSORY2_SLOT, // Shadow Accessory 2 - EquipSlot::SHADOW_ACCESSORY1_SLOT, // Shadow Accessory 1 - }; -} // namespace InventoryRecv - -void InventoryRecv::processPlayerEquipment(Net::MessageIn &msg) -{ - BLOCK_START("InventoryRecv::processPlayerEquipment") - Inventory *const inventory = localPlayer != nullptr - ? PlayerInfo::getInventory() : nullptr; - - msg.readInt16("len"); - Equipment *const equipment = PlayerInfo::getEquipment(); - if ((equipment != nullptr) && (equipment->getBackend() == nullptr)) - { // look like SMSG_PLAYER_INVENTORY was not received - Ea::InventoryRecv::mEquips.clear(); - equipment->setBackend(&Ea::InventoryRecv::mEquips); - } - const int number = (msg.getLength() - 4) / 20; - - for (int loop = 0; loop < number; loop++) - { - const int index = msg.readInt16("index") - INVENTORY_OFFSET; - const int itemId = msg.readInt16("item id"); - const ItemTypeT itemType = static_cast<ItemTypeT>( - msg.readUInt8("item type")); - const uint8_t identified = msg.readUInt8("identify"); - msg.readInt16("equip type?"); - const int equipType = msg.readInt16("equip type"); - msg.readUInt8("attribute"); - const uint8_t refine = msg.readUInt8("refine"); - int cards[maxCards]; - for (int f = 0; f < maxCards; f++) - cards[f] = msg.readUInt16("card"); - - if (Ea::InventoryRecv::mDebugInventory) - { - logger->log("Index: %d, ID: %d, Type: %d, Identified: %d", - index, itemId, CAST_S32(itemType), identified); - } - - if (inventory != nullptr) - { - inventory->setItem(index, - itemId, - itemType, - 1, - refine, - ItemColor_one, - fromBool(identified, Identified), - Damaged_false, - Favorite_false, - Equipm_true, - Equipped_false); - inventory->setCards(index, cards, maxCards); - } - - if (equipType != 0) - { - Ea::InventoryRecv::mEquips.setEquipment( - InventoryRecv::getSlot(equipType), - index); - } - } - BLOCK_END("InventoryRecv::processPlayerEquipment") -} - -void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg) -{ - BLOCK_START("InventoryRecv::processPlayerInventoryAdd") - Inventory *const inventory = localPlayer != nullptr - ? PlayerInfo::getInventory() : nullptr; - - if ((PlayerInfo::getEquipment() != nullptr) - && (PlayerInfo::getEquipment()->getBackend() == nullptr)) - { // look like SMSG_PLAYER_INVENTORY was not received - Ea::InventoryRecv::mEquips.clear(); - PlayerInfo::getEquipment()->setBackend(&Ea::InventoryRecv::mEquips); - } - const int index = msg.readInt16("index") - INVENTORY_OFFSET; - int amount = msg.readInt16("amount"); - const int itemId = msg.readInt16("item id"); - const uint8_t identified = msg.readUInt8("identified"); - msg.readUInt8("attribute"); - const uint8_t refine = msg.readUInt8("refine"); - int cards[maxCards]; - for (int f = 0; f < maxCards; f++) - cards[f] = msg.readUInt16("card"); - const int equipType = msg.readInt16("equip type"); - const ItemTypeT type = static_cast<ItemTypeT>(msg.readUInt8("item type")); - const unsigned char err = msg.readUInt8("status"); - BeingId floorId; - if (Ea::InventoryRecv::mSentPickups.empty()) - { - floorId = BeingId_zero; - } - else - { - floorId = Ea::InventoryRecv::mSentPickups.front(); - Ea::InventoryRecv::mSentPickups.pop(); - } - - if (err != 0u) - { - PickupT pickup; - switch (err) - { - case 1: - pickup = Pickup::BAD_ITEM; - break; - case 2: - pickup = Pickup::TOO_HEAVY; - break; - case 3: - pickup = Pickup::TOO_FAR; - break; - case 4: - pickup = Pickup::INV_FULL; - break; - case 5: - pickup = Pickup::STACK_FULL; - break; - case 6: - pickup = Pickup::DROP_STEAL; - break; - default: - pickup = Pickup::UNKNOWN; - UNIMPLEMENTEDPACKETFIELD(err); - break; - } - if (localPlayer != nullptr) - { - if (itemId == 0) - { - localPlayer->pickedUp(ItemDB::getEmpty(), - 0, - ItemColor_one, - floorId, - pickup); - } - else - { - localPlayer->pickedUp(ItemDB::get(itemId), - 0, - ItemColor_one, - floorId, - pickup); - } - } - } - else - { - if (localPlayer != nullptr) - { - if (itemId == 0) - { - localPlayer->pickedUp(ItemDB::getEmpty(), - amount, - ItemColor_one, - floorId, - Pickup::OKAY); - } - else - { - localPlayer->pickedUp(ItemDB::get(itemId), - amount, - ItemColor_one, - floorId, - Pickup::OKAY); - } - } - - if (inventory != nullptr) - { - const Item *const item = inventory->getItem(index); - - if ((item != nullptr) && item->getId() == itemId) - amount += item->getQuantity(); - - inventory->setItem(index, - itemId, - type, - amount, - refine, - ItemColor_one, - fromBool(identified, Identified), - Damaged_false, - Favorite_false, - fromBool(equipType, Equipm), - Equipped_false); - inventory->setCards(index, cards, maxCards); - } - ArrowsListener::distributeEvent(); - } - BLOCK_END("InventoryRecv::processPlayerInventoryAdd") -} - -void InventoryRecv::processPlayerInventory(Net::MessageIn &msg) -{ - BLOCK_START("InventoryRecv::processPlayerInventory") - Inventory *const inventory = localPlayer != nullptr - ? PlayerInfo::getInventory() : nullptr; - - if (PlayerInfo::getEquipment() != nullptr) - { - // Clear inventory - this will be a complete refresh - Ea::InventoryRecv::mEquips.clear(); - PlayerInfo::getEquipment()->setBackend(&Ea::InventoryRecv::mEquips); - } - - if (inventory != nullptr) - inventory->clear(); - - msg.readInt16("len"); - const int number = (msg.getLength() - 4) / 18; - - for (int loop = 0; loop < number; loop++) - { - int cards[maxCards]; - const int index = msg.readInt16("index") - INVENTORY_OFFSET; - const int itemId = msg.readInt16("item id"); - const ItemTypeT itemType = static_cast<ItemTypeT>( - msg.readUInt8("item type")); - const uint8_t identified = msg.readUInt8("identified"); - const int amount = msg.readInt16("amount"); - const int arrow = msg.readInt16("arrow"); - for (int i = 0; i < maxCards; i++) - cards[i] = msg.readUInt16("card"); - - if (Ea::InventoryRecv::mDebugInventory) - { - logger->log("Index: %d, ID: %d, Type: %d, Identified: %d, " - "Qty: %d, Cards: %d, %d, %d, %d", - index, itemId, CAST_S32(itemType), identified, amount, - cards[0], cards[1], cards[2], cards[3]); - } - - // Trick because arrows are not considered equipment - const bool isEquipment = (arrow & 0x8000) != 0; - - if (inventory != nullptr) - { - inventory->setItem(index, - itemId, - itemType, - amount, - 0, - ItemColor_one, - fromBool(identified, Identified), - Damaged_false, - Favorite_false, - fromBool(isEquipment, Equipm), - Equipped_false); - inventory->setCards(index, cards, maxCards); - } - } - BLOCK_END("InventoryRecv::processPlayerInventory") -} - -void InventoryRecv::processPlayerStorage(Net::MessageIn &msg) -{ - BLOCK_START("InventoryRecv::processPlayerInventory") - Ea::InventoryRecv::mInventoryItems.clear(); - - msg.readInt16("len"); - const int number = (msg.getLength() - 4) / 18; - - for (int loop = 0; loop < number; loop++) - { - int cards[maxCards]; - const int index = msg.readInt16("index") - STORAGE_OFFSET; - const int itemId = msg.readInt16("item id"); - const ItemTypeT itemType = static_cast<ItemTypeT>( - msg.readUInt8("item type")); - const uint8_t identified = msg.readUInt8("identified"); - const int amount = msg.readInt16("amount"); - msg.readInt16("arrow"); - for (int i = 0; i < maxCards; i++) - cards[i] = msg.readUInt16("card"); - - if (Ea::InventoryRecv::mDebugInventory) - { - logger->log("Index: %d, ID: %d, Type: %d, Identified: %d, " - "Qty: %d, Cards: %d, %d, %d, %d", - index, itemId, CAST_S32(itemType), identified, amount, - cards[0], cards[1], cards[2], cards[3]); - } - - Ea::InventoryRecv::mInventoryItems.push_back(Ea::InventoryItem( - index, - itemId, - itemType, - cards, - nullptr, - amount, - 0, - ItemColor_one, - fromBool(identified, Identified), - Damaged_false, - Favorite_false, - Equipm_false)); - } - BLOCK_END("InventoryRecv::processPlayerInventory") -} - -void InventoryRecv::processPlayerEquip(Net::MessageIn &msg) -{ - BLOCK_START("InventoryRecv::processPlayerEquip") - const int index = msg.readInt16("index") - INVENTORY_OFFSET; - const int equipType = msg.readInt16("equip type"); - const uint8_t flag = msg.readUInt8("flag"); - - if (flag == 0u) - { - NotifyManager::notify(NotifyTypes::EQUIP_FAILED); - } - else - { - Ea::InventoryRecv::mEquips.setEquipment( - InventoryRecv::getSlot(equipType), - index); - } - BLOCK_END("InventoryRecv::processPlayerEquip") -} - -void InventoryRecv::processPlayerUnEquip(Net::MessageIn &msg) -{ - BLOCK_START("InventoryRecv::processPlayerUnEquip") - msg.readInt16("index"); - const int equipType = msg.readInt16("equip type"); - const uint8_t flag = msg.readUInt8("flag"); - - if (flag != 0u) - { - Ea::InventoryRecv::mEquips.setEquipment( - InventoryRecv::getSlot(equipType), - -1); - } - if ((equipType & 0x8000) != 0) - ArrowsListener::distributeEvent(); - BLOCK_END("InventoryRecv::processPlayerUnEquip") -} - -void InventoryRecv::processPlayerStorageEquip(Net::MessageIn &msg) -{ - BLOCK_START("InventoryRecv::processPlayerStorageEquip") - msg.readInt16("len"); - const int number = (msg.getLength() - 4) / 20; - - for (int loop = 0; loop < number; loop++) - { - int cards[maxCards]; - const int index = msg.readInt16("index") - STORAGE_OFFSET; - const int itemId = msg.readInt16("item id"); - const ItemTypeT itemType = static_cast<ItemTypeT>( - msg.readUInt8("item type")); - const uint8_t identified = msg.readUInt8("identified"); - const int amount = 1; - msg.readInt16("equip point?"); - msg.readInt16("another equip point?"); - msg.readUInt8("attribute (broken)"); - const uint8_t refine = msg.readUInt8("refine"); - for (int i = 0; i < maxCards; i++) - cards[i] = msg.readUInt16("card"); - - if (Ea::InventoryRecv::mDebugInventory) - { - logger->log("Index: %d, ID: %d, Type: %d, Identified: %u, " - "Qty: %d, Cards: %d, %d, %d, %d, Refine: %u", - index, itemId, CAST_S32(itemType), - CAST_U32(identified), amount, - cards[0], cards[1], cards[2], cards[3], - CAST_U32(refine)); - } - - Ea::InventoryRecv::mInventoryItems.push_back(Ea::InventoryItem( - index, - itemId, - itemType, - cards, - nullptr, - amount, - refine, - ItemColor_one, - fromBool(identified, Identified), - Damaged_false, - Favorite_false, - Equipm_false)); - } - BLOCK_END("InventoryRecv::processPlayerStorageEquip") -} - -void InventoryRecv::processPlayerStorageAdd(Net::MessageIn &msg) -{ - BLOCK_START("InventoryRecv::processPlayerStorageAdd") - // Move an item into storage - const int index = msg.readInt16("index") - STORAGE_OFFSET; - const int amount = msg.readInt32("amount"); - const int itemId = msg.readInt16("item id"); - const unsigned char identified = msg.readUInt8("identified"); - msg.readUInt8("attribute"); - const uint8_t refine = msg.readUInt8("refine"); - int cards[maxCards]; - for (int f = 0; f < maxCards; f++) - cards[f] = msg.readUInt16("card"); - - if (Item *const item = Ea::InventoryRecv::mStorage->getItem(index)) - { - item->setId(itemId, ItemColor_one); - item->increaseQuantity(amount); - } - else - { - if (Ea::InventoryRecv::mStorage != nullptr) - { - Ea::InventoryRecv::mStorage->setItem(index, - itemId, - ItemType::Unknown, - amount, - refine, - ItemColor_one, - fromBool(identified, Identified), - Damaged_false, - Favorite_false, - Equipm_false, - Equipped_false); - Ea::InventoryRecv::mStorage->setCards(index, cards, maxCards); - } - } - BLOCK_END("InventoryRecv::processPlayerStorageAdd") -} - -void InventoryRecv::processPlayerStorageRemove(Net::MessageIn &msg) -{ - BLOCK_START("InventoryRecv::processPlayerStorageRemove") - // Move an item out of storage - const int index = msg.readInt16("index") - STORAGE_OFFSET; - const int amount = msg.readInt32("amount"); - if (Ea::InventoryRecv::mStorage != nullptr) - { - if (Item *const item = Ea::InventoryRecv::mStorage->getItem(index)) - { - item->increaseQuantity(-amount); - if (item->getQuantity() == 0) - Ea::InventoryRecv::mStorage->removeItemAt(index); - } - } - BLOCK_END("InventoryRecv::processPlayerStorageRemove") -} - -void InventoryRecv::processPlayerInventoryRemove(Net::MessageIn &msg) -{ - BLOCK_START("InventoryRecv::processPlayerInventoryRemove") - Inventory *const inventory = localPlayer != nullptr - ? PlayerInfo::getInventory() : nullptr; - - const int index = msg.readInt16("index") - INVENTORY_OFFSET; - const int amount = msg.readInt16("amount"); - if (inventory != nullptr) - { - if (Item *const item = inventory->getItem(index)) - { - item->increaseQuantity(-amount); - if (item->getQuantity() == 0) - inventory->removeItemAt(index); - ArrowsListener::distributeEvent(); - } - } - BLOCK_END("InventoryRecv::processPlayerInventoryRemove") -} - -int InventoryRecv::getSlot(const int eAthenaSlot) -{ - if (eAthenaSlot == 0) - return EquipSlot::VECTOREND; - - if ((eAthenaSlot & 0x8000) != 0) - return inventoryHandler->getProjectileSlot(); - - unsigned int mask = 1; - int position = 0; - while ((eAthenaSlot & mask) == 0u) - { - mask <<= 1; - position++; - } - if (position >= EquipSlot::VECTOREND) - return EquipSlot::VECTOREND; - return CAST_S32(EQUIP_POINTS[position]); -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/inventoryrecv.h b/src/net/tmwa/inventoryrecv.h deleted file mode 100644 index f8e8b8f05..000000000 --- a/src/net/tmwa/inventoryrecv.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_INVENTORYRECV_H -#define NET_TMWA_INVENTORYRECV_H - -#include "localconsts.h" - -namespace Net -{ - class MessageIn; -} // namespace Net - -namespace TmwAthena -{ - namespace InventoryRecv - { - void processPlayerEquipment(Net::MessageIn &msg); - void processPlayerInventoryAdd(Net::MessageIn &msg); - void processPlayerInventory(Net::MessageIn &msg); - void processPlayerStorage(Net::MessageIn &msg); - void processPlayerEquip(Net::MessageIn &msg); - void processPlayerUnEquip(Net::MessageIn &msg); - void processPlayerStorageEquip(Net::MessageIn &msg); - void processPlayerStorageAdd(Net::MessageIn &msg); - void processPlayerStorageRemove(Net::MessageIn &msg); - void processPlayerInventoryRemove(Net::MessageIn &msg); - - int getSlot(const int eAthenaSlot) A_WARN_UNUSED; - } // namespace InventoryRecv -} // namespace TmwAthena - -#endif // NET_TMWA_INVENTORYRECV_H diff --git a/src/net/tmwa/itemhandler.cpp b/src/net/tmwa/itemhandler.cpp deleted file mode 100644 index 69590909e..000000000 --- a/src/net/tmwa/itemhandler.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/itemhandler.h" - -#include "debug.h" - -namespace TmwAthena -{ - -ItemHandler::ItemHandler() : - Ea::ItemHandler() -{ -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/itemhandler.h b/src/net/tmwa/itemhandler.h deleted file mode 100644 index a824f135b..000000000 --- a/src/net/tmwa/itemhandler.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_ITEMHANDLER_H -#define NET_TMWA_ITEMHANDLER_H - -#include "net/ea/itemhandler.h" - -namespace TmwAthena -{ - -class ItemHandler final : public Ea::ItemHandler -{ - public: - ItemHandler(); - - A_DELETE_COPY(ItemHandler) -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_ITEMHANDLER_H diff --git a/src/net/tmwa/itemrecv.cpp b/src/net/tmwa/itemrecv.cpp deleted file mode 100644 index 53d3a19bc..000000000 --- a/src/net/tmwa/itemrecv.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/itemrecv.h" - -#include "actormanager.h" - -#include "net/messagein.h" - -#include "debug.h" - -namespace TmwAthena -{ - -void ItemRecv::processItemDropped(Net::MessageIn &msg) -{ - const BeingId id = msg.readBeingId("item object id"); - const int itemId = msg.readInt16("item id"); - const Identified identify = fromInt(msg.readUInt8("identify"), Identified); - const int x = msg.readInt16("x"); - const int y = msg.readInt16("y"); - const int subX = CAST_S32(msg.readInt8("sub x")); - const int subY = CAST_S32(msg.readInt8("sub y")); - const int amount = msg.readInt16("amount"); - - if (actorManager != nullptr) - { - actorManager->createItem(id, - itemId, - x, y, - ItemType::Unknown, - amount, - 0, - ItemColor_one, - identify, - Damaged_false, - subX, subY, - nullptr); - } -} - -void ItemRecv::processItemVisible(Net::MessageIn &msg) -{ - const BeingId id = msg.readBeingId("item object id"); - const int itemId = msg.readInt16("item id"); - const Identified identified = fromInt( - msg.readUInt8("identify"), Identified); - const int x = msg.readInt16("x"); - const int y = msg.readInt16("y"); - const int amount = msg.readInt16("amount"); - const int subX = CAST_S32(msg.readInt8("sub x")); - const int subY = CAST_S32(msg.readInt8("sub y")); - - if (actorManager != nullptr) - { - actorManager->createItem(id, - itemId, - x, y, - ItemType::Unknown, - amount, - 0, - ItemColor_one, - identified, - Damaged_false, - subX, subY, - nullptr); - } -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/itemrecv.h b/src/net/tmwa/itemrecv.h deleted file mode 100644 index 8fc24b579..000000000 --- a/src/net/tmwa/itemrecv.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_ITEMRECV_H -#define NET_TMWA_ITEMRECV_H - -namespace Net -{ - class MessageIn; -} // namespace Net - -namespace TmwAthena -{ - namespace ItemRecv - { - void processItemDropped(Net::MessageIn &msg); - void processItemVisible(Net::MessageIn &msg); - } // namespace ItemRecv -} // namespace TmwAthena - -#endif // NET_TMWA_ITEMRECV_H diff --git a/src/net/tmwa/loginhandler.cpp b/src/net/tmwa/loginhandler.cpp deleted file mode 100644 index 566cc5b09..000000000 --- a/src/net/tmwa/loginhandler.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/loginhandler.h" - -#include "net/serverfeatures.h" - -#include "net/ea/loginrecv.h" - -#include "net/tmwa/messageout.h" -#include "net/tmwa/network.h" -#include "net/tmwa/protocolout.h" - -#include "debug.h" - -extern unsigned int tmwServerVersion; - -namespace TmwAthena -{ - -extern ServerInfo charServer; - -LoginHandler::LoginHandler() : - Ea::LoginHandler() -{ - loginHandler = this; -} - -LoginHandler::~LoginHandler() -{ - loginHandler = nullptr; -} - -void LoginHandler::connect() const -{ - if (Network::mInstance == nullptr) - return; - - Network::mInstance->connect(mServer); - if (serverFeatures->haveServerVersion()) - { - createOutPacket(CMSG_SERVER_VERSION_REQUEST); - } -} - -bool LoginHandler::isConnected() const -{ - if (Network::mInstance == nullptr) - return false; - - return Ea::LoginRecv::mVersionResponse && - Network::mInstance->isConnected(); -} - -void LoginHandler::disconnect() const -{ - if (Network::mInstance != nullptr && - Network::mInstance->getServer() == mServer) - { - Network::mInstance->disconnect(); - } -} - -void LoginHandler::changePassword(const std::string &restrict oldPassword, - const std::string &restrict newPassword) - const -{ - createOutPacket(CMSG_CHAR_PASSWORD_CHANGE); - outMsg.writeStringNoLog(oldPassword, 24, "old password"); - outMsg.writeStringNoLog(newPassword, 24, "new password"); -} - -void LoginHandler::sendLoginRegister(const std::string &restrict username, - const std::string &restrict password, - const std::string &restrict email - A_UNUSED) const -{ - createOutPacket(CMSG_LOGIN_REGISTER); - if (tmwServerVersion < 0x100408) - { - // hack to avoid bug in tmwa... - outMsg.writeInt32(5, - "client protocol version"); - } - else - { - outMsg.writeInt32(CLIENT_PROTOCOL_VERSION, - "client protocol version"); - } - outMsg.writeString(username, 24, "login"); - outMsg.writeStringNoLog(password, 24, "password"); - - /* - * eAthena calls the last byte "client version 2", but it isn't used at - * at all. We're retasking it, as a bit mask: - * 0 - can handle the 0x63 "update host" packet - * 1 - defaults to the first char-server (instead of the last) - */ - outMsg.writeInt8(0x03, "flags"); -} - -ServerInfo *LoginHandler::getCharServer() const -{ - return &charServer; -} - -void LoginHandler::requestUpdateHosts() -{ -} - -void LoginHandler::sendVersion() const -{ -} - -void LoginHandler::ping() const -{ -} - -void LoginHandler::updatePacketVersion() const -{ -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/loginhandler.h b/src/net/tmwa/loginhandler.h deleted file mode 100644 index dddbd88e9..000000000 --- a/src/net/tmwa/loginhandler.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_LOGINHANDLER_H -#define NET_TMWA_LOGINHANDLER_H - -#include "net/ea/loginhandler.h" - -namespace TmwAthena -{ - -class LoginHandler final : public Ea::LoginHandler -{ - public: - LoginHandler(); - - A_DELETE_COPY(LoginHandler) - - ~LoginHandler(); - - void connect() const override final; - - bool isConnected() const override final A_WARN_UNUSED; - - void disconnect() const override final; - - unsigned int getMaxPasswordLength() const override final A_WARN_UNUSED - { return 24; } - - void changePassword(const std::string &restrict oldPassword, - const std::string &restrict newPassword) - const override final; - - ServerInfo *getCharServer() const override final A_CONST A_WARN_UNUSED; - - void sendVersion() const override final A_CONST; - - void ping() const override final A_CONST; - - void updatePacketVersion() const override final A_CONST; - - static void requestUpdateHosts() A_CONST; - - private: - void sendLoginRegister(const std::string &restrict username, - const std::string &restrict password, - const std::string &restrict email) - const override final; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_LOGINHANDLER_H diff --git a/src/net/tmwa/loginrecv.cpp b/src/net/tmwa/loginrecv.cpp deleted file mode 100644 index 05b4aaba3..000000000 --- a/src/net/tmwa/loginrecv.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/loginrecv.h" - -#include "client.h" -#include "configuration.h" -#include "logger.h" - -#include "being/being.h" - -#include "net/logindata.h" -#include "net/loginhandler.h" -#include "net/messagein.h" - -#include "net/ea/loginrecv.h" - -#include "net/tmwa/updateprotocol.h" - -#include "utils/gettext.h" - -#include "debug.h" - -extern int packetVersion; - -namespace TmwAthena -{ - -extern ServerInfo charServer; - -enum ServerFlags -{ - FLAG_REGISTRATION = 1 -}; - -void LoginRecv::processServerVersion(Net::MessageIn &msg) -{ - packetVersion = 0; - const uint8_t b1 = msg.readUInt8("b1"); // -1 - const uint8_t b2 = msg.readUInt8("b2"); - const uint8_t b3 = msg.readUInt8("b3"); - msg.readUInt8("b4"); - if (b1 == 255) - { // old TMWA - const unsigned int options = msg.readInt32("options"); - Ea::LoginRecv::mRegistrationEnabled = - ((options & FLAG_REGISTRATION) != 0u); - serverVersion = 0; - tmwServerVersion = 0; - } - else if (b1 >= 0x0d) - { // new TMWA - const unsigned int options = msg.readInt32("options"); - Ea::LoginRecv::mRegistrationEnabled = - ((options & FLAG_REGISTRATION) != 0u); - serverVersion = 0; - tmwServerVersion = (b1 << 16) | (b2 << 8) | b3; - } - else - { // eAthena - const unsigned int options = msg.readInt32("options"); - Ea::LoginRecv::mRegistrationEnabled = - ((options & FLAG_REGISTRATION) != 0u); - serverVersion = 0; - tmwServerVersion = 0; - } - if (tmwServerVersion > 0) - logger->log("Tmw server version: x%06x", tmwServerVersion); - else - logger->log("Server without version"); - updateProtocol(); - - if (client->getState() != State::LOGIN) - client->setState(State::LOGIN); - - // Leave this last - Ea::LoginRecv::mVersionResponse = true; -} - -void LoginRecv::processCharPasswordResponse(Net::MessageIn &msg) -{ - // 0: acc not found, 1: success, 2: password mismatch, 3: pass too short - const uint8_t errMsg = msg.readUInt8("result code"); - // Successful pass change - if (errMsg == 1) - { - client->setState(State::CHANGEPASSWORD_SUCCESS); - } - // pass change failed - else - { - switch (errMsg) - { - case 0: - errorMessage = - // TRANSLATORS: error message - _("Account was not found. Please re-login."); - break; - case 2: - // TRANSLATORS: error message - errorMessage = _("Old password incorrect."); - break; - case 3: - // TRANSLATORS: error message - errorMessage = _("New password too short."); - break; - default: - // TRANSLATORS: error message - errorMessage = _("Unknown error."); - break; - } - client->setState(State::ACCOUNTCHANGE_ERROR); - } -} - -void LoginRecv::processLoginData(Net::MessageIn &msg) -{ - msg.readInt16("len"); - - loginHandler->clearWorlds(); - - const int worldCount = (msg.getLength() - 47) / 32; - - Ea::LoginRecv::mToken.session_ID1 = msg.readInt32("session id1"); - Ea::LoginRecv::mToken.account_ID = msg.readBeingId("accound id"); - Ea::LoginRecv::mToken.session_ID2 = msg.readInt32("session id2"); - msg.readInt32("old ip"); - loginData.lastLogin = msg.readString(24, "last login"); - msg.readInt16("unused"); - - // reserve bits for future usage - Ea::LoginRecv::mToken.sex = Being::intToGender(CAST_U8( - msg.readUInt8("gender") & 3U)); - - for (int i = 0; i < worldCount; i++) - { - WorldInfo *const world = new WorldInfo; - - world->address = msg.readInt32("ip address"); - world->port = msg.readInt16("port"); - world->name = msg.readString(20, "name"); - world->online_users = msg.readInt16("online number"); - config.setValue("updatehost", Ea::LoginRecv::mUpdateHost); - world->updateHost = Ea::LoginRecv::mUpdateHost; - msg.readInt16("maintenance"); - msg.readInt16("new"); - - logger->log("Network: Server: %s (%s:%d)", world->name.c_str(), - ipToString(world->address), world->port); - - Ea::LoginRecv::mWorlds.push_back(world); - } - client->setState(State::WORLD_SELECT); -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/loginrecv.h b/src/net/tmwa/loginrecv.h deleted file mode 100644 index fb038da55..000000000 --- a/src/net/tmwa/loginrecv.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_LOGINRECV_H -#define NET_TMWA_LOGINRECV_H - -namespace Net -{ - class MessageIn; -} // namespace Net - -namespace TmwAthena -{ - namespace LoginRecv - { - void processServerVersion(Net::MessageIn &msg); - void processCharPasswordResponse(Net::MessageIn &msg); - void processLoginData(Net::MessageIn &msg); - } // namespace LoginRecv -} // namespace TmwAthena - -#endif // NET_TMWA_LOGINRECV_H diff --git a/src/net/tmwa/mail2handler.cpp b/src/net/tmwa/mail2handler.cpp deleted file mode 100644 index 786a31a6f..000000000 --- a/src/net/tmwa/mail2handler.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/mail2handler.h" - -#include "debug.h" - -namespace TmwAthena -{ - -Mail2Handler::Mail2Handler() -{ - mail2Handler = this; -} - -Mail2Handler::~Mail2Handler() -{ - mail2Handler = nullptr; -} - -void Mail2Handler::openWriteMail(const std::string &receiver A_UNUSED) const -{ -} - -void Mail2Handler::addItem(const Item *const item A_UNUSED, - const int amount A_UNUSED) const -{ -} - -void Mail2Handler::removeItem(const int index A_UNUSED, - const int amount A_UNUSED) const -{ -} - -void Mail2Handler::sendMail(const std::string &to A_UNUSED, - const std::string &title A_UNUSED, - const std::string &body A_UNUSED, - const int64_t &money A_UNUSED) const -{ -} - -void Mail2Handler::queueCheckName(const MailQueueTypeT type A_UNUSED, - const std::string &to A_UNUSED, - const std::string &title A_UNUSED, - const std::string &body A_UNUSED, - const int64_t &money A_UNUSED) const -{ -} - -void Mail2Handler::nextPage(const MailOpenTypeT openType A_UNUSED, - const int64_t mailId A_UNUSED) const -{ -} - -void Mail2Handler::readMail(const MailOpenTypeT openType A_UNUSED, - const int64_t mailId A_UNUSED) const -{ -} - -void Mail2Handler::deleteMail(const MailOpenTypeT openType A_UNUSED, - const int64_t mailId A_UNUSED) const -{ -} - -void Mail2Handler::requestMoney(const MailOpenTypeT openType A_UNUSED, - const int64_t mailId A_UNUSED) const -{ -} - -void Mail2Handler::requestItems(const MailOpenTypeT openType A_UNUSED, - const int64_t mailId A_UNUSED) const -{ -} - -void Mail2Handler::refreshMailList(const MailOpenTypeT openType A_UNUSED, - const int64_t mailId A_UNUSED) const -{ -} - -void Mail2Handler::openMailBox(const MailOpenTypeT openType A_UNUSED) const -{ -} - -void Mail2Handler::closeMailBox() const -{ -} - -void Mail2Handler::cancelWriteMail() const -{ -} - -void Mail2Handler::requestCheckName(const std::string &name A_UNUSED) const -{ -} - -std::string Mail2Handler::getCheckedName() const -{ - return std::string(); -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/mail2handler.h b/src/net/tmwa/mail2handler.h deleted file mode 100644 index 003a29b89..000000000 --- a/src/net/tmwa/mail2handler.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_MAIL2HANDLER_H -#define NET_TMWA_MAIL2HANDLER_H - -#include "net/mail2handler.h" - -namespace TmwAthena -{ - -class Mail2Handler final : public Net::Mail2Handler -{ - public: - Mail2Handler(); - - A_DELETE_COPY(Mail2Handler) - - ~Mail2Handler(); - - void openWriteMail(const std::string &receiver) const override final; - - void addItem(const Item *const item, - const int amount) const override final; - - void removeItem(const int index, - const int amount) const override final; - - void sendMail(const std::string &to, - const std::string &title, - const std::string &body, - const int64_t &money) const override final; - - void queueCheckName(const MailQueueTypeT type, - const std::string &to, - const std::string &title, - const std::string &body, - const int64_t &money) const override final; - - void nextPage(const MailOpenTypeT openType, - const int64_t mailId) const override final; - - void readMail(const MailOpenTypeT openType, - const int64_t mailId) const override final; - - void deleteMail(const MailOpenTypeT openType, - const int64_t mailId) const override final; - - void requestMoney(const MailOpenTypeT openType, - const int64_t mailId) const override final; - - void requestItems(const MailOpenTypeT openType, - const int64_t mailId) const override final; - - void refreshMailList(const MailOpenTypeT openType, - const int64_t mailId) const override final; - - void openMailBox(const MailOpenTypeT openType) const override final; - - void closeMailBox() const override final; - - void cancelWriteMail() const override final; - - void requestCheckName(const std::string &name) const override final; - - std::string getCheckedName() const override final; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_MAIL2HANDLER_H diff --git a/src/net/tmwa/mailhandler.cpp b/src/net/tmwa/mailhandler.cpp deleted file mode 100644 index 2a124e504..000000000 --- a/src/net/tmwa/mailhandler.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/mailhandler.h" - -#include "debug.h" - -namespace TmwAthena -{ - -MailHandler::MailHandler() -{ - mailHandler = this; -} - -MailHandler::~MailHandler() -{ - mailHandler = nullptr; -} - -void MailHandler::refresh() const -{ -} - -void MailHandler::readMessage(const int msgId A_UNUSED) const -{ -} - -void MailHandler::getAttach(const int msgId A_UNUSED) const -{ -} - -void MailHandler::deleteMessage(const int msgId A_UNUSED) const -{ -} - -void MailHandler::returnMessage(const int msgId A_UNUSED) const -{ -} - -void MailHandler::setAttach(const int index A_UNUSED, - const int amount A_UNUSED) const -{ -} - -void MailHandler::setAttachMoney(const int money A_UNUSED) const -{ -} - -void MailHandler::resetAttach(const int flag A_UNUSED) const -{ -} - -void MailHandler::send(const std::string &name A_UNUSED, - const std::string &title A_UNUSED, - std::string message A_UNUSED) const -{ -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/mailhandler.h b/src/net/tmwa/mailhandler.h deleted file mode 100644 index 94867a7a7..000000000 --- a/src/net/tmwa/mailhandler.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_MAILHANDLER_H -#define NET_TMWA_MAILHANDLER_H - -#include "net/mailhandler.h" - -namespace TmwAthena -{ - -class MailHandler final : public Net::MailHandler -{ - public: - MailHandler(); - - A_DELETE_COPY(MailHandler) - - ~MailHandler(); - - void refresh() const override final A_CONST; - - void readMessage(const int msgId) const override final A_CONST; - - void getAttach(const int msgId) const override final A_CONST; - - void deleteMessage(const int msgId) const override final A_CONST; - - void returnMessage(const int msgId) const override final A_CONST; - - void setAttach(const int index, - const int amount) const override final A_CONST; - - void setAttachMoney(const int money) const override final A_CONST; - - void resetAttach(const int flag) const override final A_CONST; - - void send(const std::string &name, - const std::string &title, - std::string message) const override final A_CONST; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_MAILHANDLER_H diff --git a/src/net/tmwa/maphandler.cpp b/src/net/tmwa/maphandler.cpp deleted file mode 100644 index 642480a4d..000000000 --- a/src/net/tmwa/maphandler.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/maphandler.h" - -#include "debug.h" - -namespace TmwAthena -{ - -MapHandler::MapHandler() : - Net::MapHandler() -{ - mapHandler = this; -} - -MapHandler::~MapHandler() -{ - mapHandler = nullptr; -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/maphandler.h b/src/net/tmwa/maphandler.h deleted file mode 100644 index 10382222d..000000000 --- a/src/net/tmwa/maphandler.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_MAPHANDLER_H -#define NET_TMWA_MAPHANDLER_H - -#include "net/maphandler.h" - -namespace TmwAthena -{ - -class MapHandler final : public Net::MapHandler -{ - public: - MapHandler(); - - A_DELETE_COPY(MapHandler) - - ~MapHandler(); -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_MAPHANDLER_H diff --git a/src/net/tmwa/markethandler.cpp b/src/net/tmwa/markethandler.cpp deleted file mode 100644 index 1a2f6b548..000000000 --- a/src/net/tmwa/markethandler.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/markethandler.h" - -#include "debug.h" - -namespace TmwAthena -{ - -MarketHandler::MarketHandler() : - Net::MarketHandler() -{ - marketHandler = this; -} - -MarketHandler::~MarketHandler() -{ - marketHandler = nullptr; -} - -void MarketHandler::close() const -{ -} - -void MarketHandler::buyItem(const int itemId A_UNUSED, - const ItemTypeT type A_UNUSED, - const ItemColor color A_UNUSED, - const int amount A_UNUSED) const -{ -} - -void MarketHandler::buyItems(const STD_VECTOR<ShopItem*> &items A_UNUSED) - const -{ -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/markethandler.h b/src/net/tmwa/markethandler.h deleted file mode 100644 index 923b697c0..000000000 --- a/src/net/tmwa/markethandler.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_MARKETHANDLER_H -#define NET_TMWA_MARKETHANDLER_H - -#include "net/markethandler.h" - -namespace TmwAthena -{ -class MarketHandler final : public Net::MarketHandler -{ - public: - MarketHandler(); - - A_DELETE_COPY(MarketHandler) - - ~MarketHandler(); - - void close() const override final A_CONST; - - void buyItem(const int itemId, - const ItemTypeT type, - const ItemColor color, - const int amount) const override final A_CONST; - - void buyItems(const STD_VECTOR<ShopItem*> &items) const override final - A_CONST; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_MARKETHANDLER_H diff --git a/src/net/tmwa/mercenaryhandler.cpp b/src/net/tmwa/mercenaryhandler.cpp deleted file mode 100644 index 7f824180a..000000000 --- a/src/net/tmwa/mercenaryhandler.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/mercenaryhandler.h" - -#include "debug.h" - -namespace TmwAthena -{ - -MercenaryHandler::MercenaryHandler() -{ - mercenaryHandler = this; -} - -MercenaryHandler::~MercenaryHandler() -{ - mercenaryHandler = nullptr; -} - -void MercenaryHandler::fire() const -{ -} - -void MercenaryHandler::moveToMaster() const -{ -} - -void MercenaryHandler::move(const int x A_UNUSED, const int y A_UNUSED) const -{ -} - -void MercenaryHandler::attack(const BeingId targetId A_UNUSED, - const Keep keep A_UNUSED) const -{ -} - -void MercenaryHandler::talk(const std::string &restrict text A_UNUSED) const -{ -} - -void MercenaryHandler::emote(const uint8_t emoteId A_UNUSED) const -{ -} - -void MercenaryHandler::setDirection(const unsigned char type A_UNUSED) const -{ -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/mercenaryhandler.h b/src/net/tmwa/mercenaryhandler.h deleted file mode 100644 index eaba1f2fd..000000000 --- a/src/net/tmwa/mercenaryhandler.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_MERCENARYHANDLER_H -#define NET_TMWA_MERCENARYHANDLER_H - -#include "net/mercenaryhandler.h" - -namespace TmwAthena -{ - -class MercenaryHandler final : public Net::MercenaryHandler -{ - public: - MercenaryHandler(); - - A_DELETE_COPY(MercenaryHandler) - - ~MercenaryHandler(); - - void fire() const override final A_CONST; - - void moveToMaster() const override final A_CONST; - - void move(const int x, const int y) const override final A_CONST; - - void attack(const BeingId targetId, - const Keep keep) const override final A_CONST; - - void talk(const std::string &restrict text) const override final - A_CONST; - - void emote(const uint8_t emoteId) const override final A_CONST; - - void setDirection(const unsigned char type) const override final - A_CONST; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_MERCENARYHANDLER_H diff --git a/src/net/tmwa/messagein.cpp b/src/net/tmwa/messagein.cpp deleted file mode 100644 index 792f88743..000000000 --- a/src/net/tmwa/messagein.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/messagein.h" - -#include "logger.h" - -#include "net/net.h" -#include "net/packetcounters.h" - -#include "utils/cast.h" -#include "utils/stringutils.h" - -PRAGMA48(GCC diagnostic push) -PRAGMA48(GCC diagnostic ignored "-Wshadow") -#ifndef SDL_BIG_ENDIAN -#include <SDL_endian.h> -#endif // SDL_BYTEORDER -PRAGMA48(GCC diagnostic pop) - -#include "debug.h" - -namespace TmwAthena -{ - -MessageIn::MessageIn(const char *const data, - const unsigned int length) : - Net::MessageIn(data, length) -{ -} - -void MessageIn::postInit(const char *const str) -{ - // Read the message ID - mId = readId(); - IGNOREDEBUGLOG; - DEBUGLOG2("Receive packet", 0, "MessageIn"); - readInt16(str); -} - -uint16_t MessageIn::readId() const -{ - int16_t value = -1; - if (mPos + 2 <= mLength) - { -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - int16_t swap; - memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(int16_t)); - value = SDL_Swap16(swap); -#else // SDL_BYTEORDER == SDL_BIG_ENDIAN - - memcpy(&value, mData + CAST_SIZE(mPos), sizeof(int16_t)); -#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN - } - return value; -} - -int16_t MessageIn::readInt16(const char *const str) -{ - int16_t value = -1; - if (mPos + 2 <= mLength) - { -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - int16_t swap; - memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(int16_t)); - value = SDL_Swap16(swap); -#else // SDL_BYTEORDER == SDL_BIG_ENDIAN - - memcpy(&value, mData + CAST_SIZE(mPos), sizeof(int16_t)); -#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN - } - DEBUGLOG2("readInt16: " + toStringPrint(CAST_U32( - CAST_U16(value))), - mPos, str); - mPos += 2; - PacketCounters::incInBytes(2); - return value; -} - -uint16_t MessageIn::readUInt16(const char *const str) -{ - uint16_t value = 0xffU; - if (mPos + 2 <= mLength) - { -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - uint16_t swap; - memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(uint16_t)); - value = SDL_Swap16(swap); -#else // SDL_BYTEORDER == SDL_BIG_ENDIAN - - memcpy(&value, mData + CAST_SIZE(mPos), sizeof(uint16_t)); -#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN - } - DEBUGLOG2("readUInt16: " + toStringPrint(CAST_U32( - CAST_U16(value))), - mPos, str); - mPos += 2; - PacketCounters::incInBytes(2); - return value; -} - -int32_t MessageIn::readInt32(const char *const str) -{ - int32_t value = -1; - if (mPos + 4 <= mLength) - { -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - int32_t swap; - memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(int32_t)); - value = SDL_Swap32(swap); -#else // SDL_BYTEORDER == SDL_BIG_ENDIAN - - memcpy(&value, mData + CAST_SIZE(mPos), sizeof(int32_t)); -#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN - } - DEBUGLOG2("readInt32: " + toStringPrint(CAST_U32(value)), - mPos, str); - mPos += 4; - PacketCounters::incInBytes(4); - return value; -} - -BeingId MessageIn::readBeingId(const char *const str) -{ - return fromInt(readInt32(str), BeingId); -} - -int64_t MessageIn::readInt64(const char *const str) -{ - int64_t value = -1; - if (mPos + 8 <= mLength) - { -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - int64_t swap; - memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(int64_t)); - value = SDL_Swap64(swap); -#else // SDL_BYTEORDER == SDL_BIG_ENDIAN - - memcpy(&value, mData + CAST_SIZE(mPos), sizeof(int64_t)); -#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN - } - DEBUGLOG2("readInt64: " + toStringPrint(CAST_U32(value)), - mPos, str); - mPos += 8; - PacketCounters::incInBytes(8); - return value; -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/messagein.h b/src/net/tmwa/messagein.h deleted file mode 100644 index aca246cd6..000000000 --- a/src/net/tmwa/messagein.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_MESSAGEIN_H -#define NET_TMWA_MESSAGEIN_H - -#include "net/messagein.h" - -#include "localconsts.h" - -namespace TmwAthena -{ - -/** - * Used for parsing an incoming message. - * - * \ingroup Network - */ -class MessageIn final : public Net::MessageIn -{ - public: - /** - * Constructor. - */ - MessageIn(const char *const data, - const unsigned int length); - - A_DELETE_COPY(MessageIn) - - void postInit(const char *const str); - - /**< Reads a short. */ - int16_t readInt16(const char *const str) override final; - - uint16_t readUInt16(const char *const str) override final; - - /**< Reads a long. */ - int32_t readInt32(const char *const str) override final; - - int64_t readInt64(const char *const str) override final; - - BeingId readBeingId(const char *const str) override final; - - uint16_t readId() const; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_MESSAGEIN_H diff --git a/src/net/tmwa/messageout.cpp b/src/net/tmwa/messageout.cpp deleted file mode 100644 index 64951642d..000000000 --- a/src/net/tmwa/messageout.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/messageout.h" - -#include "net/packetcounters.h" - -#include "net/tmwa/network.h" - -#include "logger.h" - -#include "debug.h" - -#ifndef SDL_BIG_ENDIAN -#error missing SDL_endian.h -#endif // SDL_BYTEORDER - -namespace TmwAthena -{ - -MessageOut::MessageOut(const int16_t id) : - Net::MessageOut(id), - mNetwork(TmwAthena::Network::instance()) -{ - mNetwork->fixSendBuffer(); - mData = mNetwork->mOutBuffer + CAST_SIZE(mNetwork->mOutSize); -} - -MessageOut::~MessageOut() -{ - DEBUGLOG2("writeEnd: ", mPos, "position after end of packet"); -} - -void MessageOut::expand(const size_t bytes) const -{ - mNetwork->mOutSize += CAST_U32(bytes); - PacketCounters::incOutBytes(CAST_S32(bytes)); -} - -void MessageOut::writeInt16(const int16_t value, const char *const str) -{ - DEBUGLOG2("writeInt16: " + toStringPrint(CAST_U32( - CAST_U16(value))), - mPos, str); - expand(2); -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - int16_t swap = SDL_Swap16(value); - memcpy(mData + CAST_SIZE(mPos), &swap, sizeof(int16_t)); -#else // SDL_BYTEORDER == SDL_BIG_ENDIAN - - memcpy(mData + CAST_SIZE(mPos), &value, sizeof(int16_t)); -#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN - - mPos += 2; - PacketCounters::incOutBytes(2); -} - -void MessageOut::writeInt32(const int32_t value, const char *const str) -{ - DEBUGLOG2("writeInt32: " + toStringPrint(CAST_U32(value)), - mPos, str); - expand(4); -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - int32_t swap = SDL_Swap32(value); - memcpy(mData + CAST_SIZE(mPos), &swap, sizeof(int32_t)); -#else // SDL_BYTEORDER == SDL_BIG_ENDIAN - - memcpy(mData + CAST_SIZE(mPos), &value, sizeof(int32_t)); -#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN - - mPos += 4; - PacketCounters::incOutBytes(4); -} - -void MessageOut::writeBeingId(const BeingId value, const char *const str) -{ - writeInt32(toInt(value, int32_t), str); -} - -#define LOBYTE(w) (CAST_U8(w)) -#define HIBYTE(w) (CAST_U8(( \ -CAST_U16(w)) >> 8U)) - -void MessageOut::writeCoordinates(const uint16_t x, - const uint16_t y, - unsigned char direction, - const char *const str) -{ - DEBUGLOG2(strprintf("writeCoordinates: %u,%u %u", - CAST_U32(x), static_cast<unsigned>(y), - CAST_U32(direction)), mPos, str); - unsigned char *const data = reinterpret_cast<unsigned char*>(mData) - + CAST_SIZE(mPos); - mNetwork->mOutSize += 3; - mPos += 3; - - uint16_t temp = x; - temp <<= 6; - data[0] = 0; - data[1] = 1; - data[2] = 2; - data[0] = HIBYTE(temp); - data[1] = CAST_U8(temp); - temp = y; - temp <<= 4; - data[1] |= HIBYTE(temp); - data[2] = LOBYTE(temp); - direction = toServerDirection(direction); - data[2] |= direction; - PacketCounters::incOutBytes(3); -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/messageout.h b/src/net/tmwa/messageout.h deleted file mode 100644 index 18346b690..000000000 --- a/src/net/tmwa/messageout.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_MESSAGEOUT_H -#define NET_TMWA_MESSAGEOUT_H - -#include "net/messageout.h" - -#include "localconsts.h" - -namespace TmwAthena -{ - -class Network; - -/** - * Used for building an outgoing message. - * - * \ingroup Network - */ -class MessageOut final : public Net::MessageOut -{ - public: - /** - * Constructor. - */ - explicit MessageOut(const int16_t id); - - A_DELETE_COPY(MessageOut) - - virtual ~MessageOut(); - - /**< Writes a short. */ - void writeInt16(const int16_t value, - const char *const str) override final; - - /**< Writes a long. */ - void writeInt32(const int32_t value, - const char *const str) override final; - - void writeBeingId(const BeingId value, - const char *const str) override final; - - /** - * Encodes coordinates and direction in 3 bytes. - */ - void writeCoordinates(const uint16_t x, - const uint16_t y, - unsigned char direction, - const char *const str); - - void resetPos() - { mPos = 0; } - - private: - void expand(const size_t size) const override final; - - Network *mNetwork; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_MESSAGEOUT_H diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp deleted file mode 100644 index ebc4db9e6..000000000 --- a/src/net/tmwa/network.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/network.h" - -#include "logger.h" - -#include "net/packetinfo.h" - -#include "net/ea/adminrecv.h" -#include "net/ea/beingrecv.h" -#include "net/ea/buysellrecv.h" -#include "net/ea/charserverrecv.h" -#include "net/ea/chatrecv.h" -#include "net/ea/gamerecv.h" -#include "net/ea/inventoryrecv.h" -#include "net/ea/itemrecv.h" -#include "net/ea/loginrecv.h" -#include "net/ea/maprecv.h" -#include "net/ea/npcrecv.h" -#include "net/ea/partyrecv.h" -#include "net/ea/playerrecv.h" -#include "net/ea/skillrecv.h" -#include "net/ea/traderecv.h" - -#include "net/tmwa/beingrecv.h" -#include "net/tmwa/buysellrecv.h" -#include "net/tmwa/charserverrecv.h" -#include "net/tmwa/chatrecv.h" -#include "net/tmwa/gamerecv.h" -#include "net/tmwa/generalrecv.h" -#include "net/tmwa/inventoryrecv.h" -#include "net/tmwa/itemrecv.h" -#include "net/tmwa/loginrecv.h" -#include "net/tmwa/partyrecv.h" -#include "net/tmwa/playerrecv.h" -#include "net/tmwa/questrecv.h" -#include "net/tmwa/skillrecv.h" -#include "net/tmwa/traderecv.h" - -#include "net/tmwa/messagein.h" - -#include "utils/cast.h" - -#include "debug.h" - -namespace TmwAthena -{ - -static const unsigned int packet_lengths_size = 0xFFFFU; -static const unsigned int messagesSize = 0xFFFFU; -Network *Network::mInstance = nullptr; - -Network::Network() : - Ea::Network() -{ - mInstance = this; - mPackets = new PacketInfo[messagesSize]; -} - -Network::~Network() -{ - clearHandlers(); - mInstance = nullptr; -} - -void Network::registerHandlers() -{ -#include "net/tmwa/recvpackets.inc" - RECVPACKETS_VOID -} - -void Network::clearHandlers() -{ - for (size_t f = 0; f < packet_lengths_size; f ++) - { - mPackets[f].name = ""; - mPackets[f].len = 0; - mPackets[f].func = nullptr; - mPackets[f].version = 0; - } -} - -void Network::dispatchMessages() -{ - BLOCK_START("Network::dispatchMessages 1") - mPauseDispatch = false; - while (messageReady()) - { - SDL_mutexP(mMutexIn); - BLOCK_START("Network::dispatchMessages 2") - const unsigned int msgId = readWord(0); - int len = -1; - if (msgId < packet_lengths_size) - len = mPackets[msgId].len; - - if (len == -1) - len = readWord(2); - - MessageIn msg(mInBuffer, len); - msg.postInit(mPackets[msgId].name); - SDL_mutexV(mMutexIn); - BLOCK_END("Network::dispatchMessages 2") - BLOCK_START("Network::dispatchMessages 3") - - if (len == 0) - { - // need copy data for safty - std::string str = strprintf( - "Wrong packet %u 0x%x received. Exiting.", - msgId, msgId); - logger->safeError(str); - } - - if (msgId < messagesSize) - { - const PacketFuncPtr func = mPackets[msgId].func; - if (func != nullptr) - func(msg); - else - logger->log("Unhandled packet: %u 0x%x", msgId, msgId); - } - - skip(len); - if (mPauseDispatch) - { - BLOCK_END("Network::dispatchMessages 3") - break; - } - BLOCK_END("Network::dispatchMessages 3") - } - BLOCK_END("Network::dispatchMessages 1") -} - -bool Network::messageReady() -{ - int len = -1; - - SDL_mutexP(mMutexIn); - if (mInSize >= 2) - { - const int msgId = readWord(0); - if (msgId >= 0 && CAST_U32(msgId) - < packet_lengths_size) - { - len = mPackets[msgId].len; - } - - if (len == -1 && mInSize > 4) - len = readWord(2); - } - - const bool ret = (mInSize >= CAST_U32(len)); - SDL_mutexV(mMutexIn); - - return ret; -} - -Network *Network::instance() -{ - return mInstance; -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/network.h b/src/net/tmwa/network.h deleted file mode 100644 index 26a2a1650..000000000 --- a/src/net/tmwa/network.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_NETWORK_H -#define NET_TMWA_NETWORK_H - -#include "net/ea/network.h" - -/** - * Protocol version, reported to the tmwa char and mapserver who can adjust - * the protocol accordingly. - */ -#define CLIENT_PROTOCOL_VERSION 7 - -namespace TmwAthena -{ -class Network final : public Ea::Network -{ - public: - Network(); - - A_DELETE_COPY(Network) - - ~Network(); - - void clearHandlers(); - - bool messageReady(); - - void dispatchMessages(); - - void registerHandlers(); - - static Network *mInstance; - - protected: - friend class MessageOut; - - static Network *instance() A_WARN_UNUSED; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_NETWORK_H diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp deleted file mode 100644 index e4a9296fc..000000000 --- a/src/net/tmwa/npchandler.cpp +++ /dev/null @@ -1,246 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/npchandler.h" - -#include "being/localplayer.h" - -#include "const/net/inventory.h" - -#include "gui/windows/npcdialog.h" - -#include "gui/widgets/createwidget.h" - -#include "net/messagein.h" - -#include "net/tmwa/messageout.h" -#include "net/tmwa/protocolout.h" - -#include "net/ea/npcrecv.h" - -#include "debug.h" - -namespace TmwAthena -{ - -NpcHandler::NpcHandler() : - Ea::NpcHandler() -{ - npcHandler = this; -} - -NpcHandler::~NpcHandler() -{ - npcHandler = nullptr; -} - -void NpcHandler::talk(const Being *const being) const -{ - if (being == nullptr) - return; - createOutPacket(CMSG_NPC_TALK); - outMsg.writeBeingId(being->getId(), "npc id"); - outMsg.writeInt8(0, "unused"); -} - -void NpcHandler::nextDialog(const BeingId npcId) const -{ - createOutPacket(CMSG_NPC_NEXT_REQUEST); - outMsg.writeBeingId(npcId, "npc id"); -} - -void NpcHandler::closeDialog(const BeingId npcId) -{ - createOutPacket(CMSG_NPC_CLOSE); - outMsg.writeBeingId(npcId, "npc id"); - - const NpcDialogs::iterator it = NpcDialog::mNpcDialogs.find(npcId); - if (it != NpcDialog::mNpcDialogs.end()) - { - NpcDialog *const dialog = (*it).second; - if (dialog != nullptr) - dialog->close(); - if (dialog == Ea::NpcRecv::mDialog) - Ea::NpcRecv::mDialog = nullptr; - NpcDialog::mNpcDialogs.erase(it); - } -} - -void NpcHandler::listInput(const BeingId npcId, - const unsigned char value) const -{ - createOutPacket(CMSG_NPC_LIST_CHOICE); - outMsg.writeBeingId(npcId, "npc id"); - outMsg.writeInt8(value, "value"); -} - -void NpcHandler::integerInput(const BeingId npcId, - const int value) const -{ - createOutPacket(CMSG_NPC_INT_RESPONSE); - outMsg.writeBeingId(npcId, "npc id"); - outMsg.writeInt32(value, "value"); -} - -void NpcHandler::stringInput(const BeingId npcId, - const std::string &value) const -{ - createOutPacket(CMSG_NPC_STR_RESPONSE); - outMsg.writeInt16(CAST_S16(value.length() + 9), "len"); - outMsg.writeBeingId(npcId, "npc id"); - outMsg.writeString(value, CAST_S32(value.length()), "value"); - outMsg.writeInt8(0, "null byte"); -} - -void NpcHandler::buy(const Being *const being) const -{ - if (being == nullptr) - return; - createOutPacket(CMSG_NPC_BUY_SELL_REQUEST); - outMsg.writeBeingId(being->getId(), "npc id"); - outMsg.writeInt8(0, "action"); -} - -void NpcHandler::buy(const BeingId beingId) const -{ - createOutPacket(CMSG_NPC_BUY_SELL_REQUEST); - outMsg.writeBeingId(beingId, "npc id"); - outMsg.writeInt8(0, "action"); -} - -void NpcHandler::sell(const BeingId beingId) const -{ - createOutPacket(CMSG_NPC_BUY_SELL_REQUEST); - outMsg.writeBeingId(beingId, "npc id"); - outMsg.writeInt8(1, "action"); -} - -void NpcHandler::buyItem(const BeingId beingId A_UNUSED, - const int itemId, - const ItemColor color A_UNUSED, - const int amount) const -{ - createOutPacket(CMSG_NPC_BUY_REQUEST); - outMsg.writeInt16(8, "len"); - outMsg.writeInt16(CAST_S16(amount), "amount"); - outMsg.writeInt16(CAST_S16(itemId), "item id"); -} - -void NpcHandler::buyItems(STD_VECTOR<ShopItem*> &items A_UNUSED) const -{ -} - -void NpcHandler::sellItem(const BeingId beingId A_UNUSED, - const int itemId, - const int amount) const -{ - createOutPacket(CMSG_NPC_SELL_REQUEST); - outMsg.writeInt16(8, "len"); - outMsg.writeInt16(CAST_S16( - itemId + INVENTORY_OFFSET), "index"); - outMsg.writeInt16(CAST_S16(amount), "amount"); -} - -void NpcHandler::sellItems(STD_VECTOR<ShopItem*> &items A_UNUSED) const -{ -} - -void NpcHandler::completeProgressBar() const -{ -} - -void NpcHandler::produceMix(const int nameId A_UNUSED, - const int materialId1 A_UNUSED, - const int materialId2 A_UNUSED, - const int materialId3 A_UNUSED) const -{ -} - -void NpcHandler::cooking(const CookingTypeT type A_UNUSED, - const int nameId A_UNUSED) const -{ -} - -void NpcHandler::repair(const int index A_UNUSED) const -{ -} - -void NpcHandler::refine(const int index A_UNUSED) const -{ -} - -void NpcHandler::identify(const int index A_UNUSED) const -{ -} - -void NpcHandler::selectArrow(const int nameId A_UNUSED) const -{ -} - -void NpcHandler::selectAutoSpell(const int skillId A_UNUSED) const -{ -} - -BeingId NpcHandler::getNpc(Net::MessageIn &msg, - const NpcActionT action) -{ - const BeingId npcId = msg.readBeingId("npc id"); - - const NpcDialogs::const_iterator diag = NpcDialog::mNpcDialogs.find(npcId); - Ea::NpcRecv::mDialog = nullptr; - - if (diag == NpcDialog::mNpcDialogs.end()) - { - // +++ must be removed packet id checks from here - // Empty dialogs don't help - if (action == NpcAction::Close) - { - closeDialog(npcId); - return npcId; - } - else if (action == NpcAction::Next) - { - nextDialog(npcId); - return npcId; - } - else - { - CREATEWIDGETV(Ea::NpcRecv::mDialog, NpcDialog, npcId); - Ea::NpcRecv::mDialog->saveCamera(); - if (localPlayer != nullptr) - localPlayer->stopWalking(false); - NpcDialog::mNpcDialogs[npcId] = Ea::NpcRecv::mDialog; - } - } - else - { - NpcDialog *const dialog = diag->second; - if (Ea::NpcRecv::mDialog != nullptr && Ea::NpcRecv::mDialog != dialog) - Ea::NpcRecv::mDialog->restoreCamera(); - Ea::NpcRecv::mDialog = dialog; - if (Ea::NpcRecv::mDialog != nullptr) - Ea::NpcRecv::mDialog->saveCamera(); - } - return npcId; -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/npchandler.h b/src/net/tmwa/npchandler.h deleted file mode 100644 index 14bfefb66..000000000 --- a/src/net/tmwa/npchandler.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_NPCHANDLER_H -#define NET_TMWA_NPCHANDLER_H - -#include "net/ea/npchandler.h" - -namespace TmwAthena -{ - -class NpcHandler final : public Ea::NpcHandler -{ - public: - NpcHandler(); - - A_DELETE_COPY(NpcHandler) - - ~NpcHandler(); - - void talk(const Being *const being) const override final; - - void nextDialog(const BeingId npcId) const override final; - - void closeDialog(const BeingId npcId) override final; - - void listInput(const BeingId npcId, - const unsigned char value) const override final; - - void integerInput(const BeingId npcId, - const int value) const override final; - - void stringInput(const BeingId npcId, - const std::string &value) const override final; - - void buy(const Being *const being) const override final; - - void buy(const BeingId beingId) const override final; - - void sell(const BeingId beingId) const override final; - - void buyItem(const BeingId beingId, - const int itemId, - const ItemColor color, - const int amount) const override final; - - void buyItems(STD_VECTOR<ShopItem*> &items) const override final - A_CONST; - - void sellItem(const BeingId beingId, - const int itemId, - const int amount) const override final; - - void sellItems(STD_VECTOR<ShopItem*> &items) const override final - A_CONST; - - void completeProgressBar() const override final A_CONST; - - BeingId getNpc(Net::MessageIn &msg, - const NpcActionT action) override final; - - void produceMix(const int nameId, - const int materialId1, - const int materialId2, - const int materialId3) const override final A_CONST; - - void cooking(const CookingTypeT type, - const int nameId) const override final A_CONST; - - void repair(const int index) const override final A_CONST; - - void refine(const int index) const override final A_CONST; - - void identify(const int index) const override final A_CONST; - - void selectArrow(const int nameId) const override final A_CONST; - - void selectAutoSpell(const int skillId) const override final A_CONST; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_NPCHANDLER_H diff --git a/src/net/tmwa/packetsin.inc b/src/net/tmwa/packetsin.inc deleted file mode 100644 index 633c2b1ad..000000000 --- a/src/net/tmwa/packetsin.inc +++ /dev/null @@ -1,147 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -packet(SMSG_ADMIN_KICK_ACK, 0x00cd, 6, &Ea::AdminRecv::processKickAck, 0); -packet(SMSG_BEING_ACTION, 0x008a, 29, &Ea::BeingRecv::processBeingAction, 0); -packet(SMSG_BEING_CHANGE_DIRECTION, 0x009c, 9, &BeingRecv::processBeingChangeDirection, 0); -packet(SMSG_BEING_CHANGE_LOOKS, 0x00c3, 8, &BeingRecv::processBeingChangeLook, 0); -packet(SMSG_BEING_CHANGE_LOOKS2, 0x01d7, 11, &BeingRecv::processBeingChangeLook2, 0); -packet(SMSG_BEING_CHAT, 0x008d, -1, &ChatRecv::processBeingChat, 0); -packet(SMSG_BEING_EMOTION, 0x00c0, 7, &Ea::BeingRecv::processBeingEmotion, 0); -packet(SMSG_BEING_IP_RESPONSE, 0x020c, 10, &BeingRecv::processIpResponse, 0); -packet(SMSG_BEING_MOVE, 0x007b, 60, &BeingRecv::processBeingMove, 0); -packet(SMSG_BEING_MOVE2, 0x0086, 16, &BeingRecv::processBeingMove2, 0); -packet(SMSG_BEING_MOVE3, 0x0225, -1, &Ea::BeingRecv::processBeingMove3, 0); -packet(SMSG_BEING_NAME_RESPONSE, 0x0095, 30, &Ea::BeingRecv::processNameResponse, 0); -packet(SMSG_BEING_REMOVE, 0x0080, 7, &Ea::BeingRecv::processBeingRemove, 0); -packet(SMSG_BEING_RESURRECT, 0x0148, 8, &BeingRecv::processBeingResurrect, 0); -packet(SMSG_BEING_SELFEFFECT, 0x019b, 10, &BeingRecv::processBeingSelfEffect, 0); -packet(SMSG_BEING_SPAWN, 0x007c, 41, &BeingRecv::processBeingSpawn, 0); -packet(SMSG_BEING_STATUS_CHANGE, 0x0196, 9, &BeingRecv::processBeingStatusChange, 0); -packet(SMSG_BEING_VISIBLE, 0x0078, 54, &BeingRecv::processBeingVisible, 0); -packet(SMSG_CHANGE_MAP_SERVER, 0x0092, 28, &CharServerRecv::processChangeMapServer, 0); -packet(SMSG_CHAR_CREATE_FAILED, 0x006e, 3, &Ea::CharServerRecv::processCharCreateFailed, 0); -packet(SMSG_CHAR_CREATE_SUCCEEDED, 0x006d, 108, &CharServerRecv::processCharCreate, 0); -packet(SMSG_CHAR_DELETE_FAILED, 0x0070, 3, &CharServerRecv::processCharDeleteFailed, 0); -packet(SMSG_CHAR_DELETE_SUCCEEDED, 0x006f, 2, &Ea::CharServerRecv::processCharDelete, 0); -packet(SMSG_CHAR_LOGIN, 0x006b, -1, &CharServerRecv::processCharLogin, 0); -packet(SMSG_CHAR_LOGIN_ERROR, 0x006c, 3, &Ea::CharServerRecv::processCharLoginError, 0); -packet(SMSG_CHAR_MAP_INFO, 0x0071, 28, &CharServerRecv::processCharMapInfo, 0); -packet(SMSG_CHAR_PASSWORD_RESPONSE, 0x0062, 3, &LoginRecv::processCharPasswordResponse, 0); -packet(SMSG_CHAR_SWITCH_RESPONSE, 0x00b3, 3, &Ea::GameRecv::processCharSwitchResponse, 0); -packet(SMSG_CONNECTION_PROBLEM, 0x0081, 3, &GeneralRecv::processConnectionProblem, 0); -packet(SMSG_GM_CHAT, 0x009a, -1, &ChatRecv::processGmChat, 0); -packet(SMSG_IGNORE_ALL_RESPONSE, 0x00d2, 4, &Ea::ChatRecv::processIgnoreAllResponse, 0); -packet(SMSG_ITEM_DROPPED, 0x009e, 17, &ItemRecv::processItemDropped, 0); -packet(SMSG_ITEM_REMOVE, 0x00a1, 6, &Ea::ItemRecv::processItemRemove, 0); -packet(SMSG_ITEM_USE_RESPONSE, 0x00a8, 7, &Ea::InventoryRecv::processItemUseResponse, 0); -packet(SMSG_ITEM_VISIBLE, 0x009d, 17, &ItemRecv::processItemVisible, 0); -packet(SMSG_LOGIN_DATA, 0x0069, -1, &LoginRecv::processLoginData, 0); -packet(SMSG_LOGIN_ERROR, 0x006a, 23, &Ea::LoginRecv::processLoginError, 0); -packet(SMSG_MAP_LOGIN_SUCCESS, 0x0073, 11, &GameRecv::processMapLogin, 0); -packet(SMSG_MAP_MUSIC, 0x0227, -1, &Ea::PlayerRecv::processMapMusic, 0); -packet(SMSG_MAP_QUIT_RESPONSE, 0x018b, 4, &Ea::GameRecv::processMapQuitResponse, 0); -packet(SMSG_MVP_EFFECT, 0x010c, 6, &Ea::ChatRecv::processMVPEffect, 0); -packet(SMSG_NPC_BUY, 0x00c6, -1, &BuySellRecv::processNpcBuy, 0); -packet(SMSG_NPC_BUY_RESPONSE, 0x00ca, 3, &BuySellRecv::processNpcBuyResponse, 0); -packet(SMSG_NPC_BUY_SELL_CHOICE, 0x00c4, 6, &Ea::BuySellRecv::processNpcBuySellChoice, 0); -packet(SMSG_NPC_CHANGETITLE, 0x0228, -1, &Ea::NpcRecv::processChangeTitle, 0); -packet(SMSG_NPC_CHOICE, 0x00b7, -1, &Ea::NpcRecv::processNpcChoice, 0); -packet(SMSG_NPC_CLOSE, 0x00b6, 6, &Ea::NpcRecv::processNpcClose, 0); -packet(SMSG_NPC_COMMAND, 0x0212, 16, &Ea::NpcRecv::processNpcCommand, 0); -packet(SMSG_NPC_INT_INPUT, 0x0142, 6, &Ea::NpcRecv::processNpcIntInput, 0); -packet(SMSG_NPC_MESSAGE, 0x00b4, -1, &Ea::NpcRecv::processNpcMessage, 0); -packet(SMSG_NPC_NEXT, 0x00b5, 6, &Ea::NpcRecv::processNpcNext, 0); -packet(SMSG_NPC_SELL, 0x00c7, -1, &Ea::BuySellRecv::processNpcSell, 0); -packet(SMSG_NPC_SELL_RESPONSE, 0x00cb, 3, &BuySellRecv::processNpcSellResponse, 0); -packet(SMSG_NPC_STR_INPUT, 0x01d4, 6, &Ea::NpcRecv::processNpcStrInput, 0); -packet(SMSG_PARTY_CREATE, 0x00fa, 3, &Ea::PartyRecv::processPartyCreate, 0); -packet(SMSG_PARTY_INFO, 0x00fb, -1, &PartyRecv::processPartyInfo, 0); -packet(SMSG_PARTY_INVITED, 0x00fe, 30, &PartyRecv::processPartyInvited, 0); -packet(SMSG_PARTY_INVITE_RESPONSE, 0x00fd, 27, &PartyRecv::processPartyInviteResponse, 0); -packet(SMSG_PARTY_LEAVE, 0x0105, 31, &Ea::PartyRecv::processPartyLeave, 0); -packet(SMSG_PARTY_MESSAGE, 0x0109, -1, &PartyRecv::processPartyMessage, 0); -packet(SMSG_PARTY_MOVE, 0x0104, 79, &PartyRecv::processPartyMove, 0); -packet(SMSG_PARTY_SETTINGS, 0x0101, 6, &PartyRecv::processPartySettings, 0); -packet(SMSG_PARTY_UPDATE_COORDS, 0x0107, 10, &Ea::PartyRecv::processPartyUpdateCoords, 0); -packet(SMSG_PARTY_UPDATE_HP, 0x0106, 10, &PartyRecv::processPartyUpdateHp, 0); -packet(SMSG_PLAYER_ARROW_EQUIP, 0x013c, 4, &Ea::InventoryRecv::processPlayerArrowEquip, 0); -packet(SMSG_PLAYER_ARROW_MESSAGE, 0x013b, 4, &Ea::PlayerRecv::processPlayerArrowMessage, 0); -packet(SMSG_PLAYER_ATTACK_RANGE, 0x013a, 4, &Ea::InventoryRecv::processPlayerAttackRange, 0); -packet(SMSG_PLAYER_CHAT, 0x008e, -1, &ChatRecv::processChat, 0); -packet(SMSG_PLAYER_EQUIP, 0x00aa, 7, &InventoryRecv::processPlayerEquip, 0); -packet(SMSG_PLAYER_EQUIPMENT, 0x00a4, -1, &InventoryRecv::processPlayerEquipment, 0); -packet(SMSG_PLAYER_GUILD_PARTY_INFO, 0x0195, 102, &BeingRecv::processPlayerGuilPartyInfo, 0); -packet(SMSG_PLAYER_INVENTORY, 0x01ee, -1, &InventoryRecv::processPlayerInventory, 0); -packet(SMSG_PLAYER_INVENTORY_ADD, 0x00a0, 23, &InventoryRecv::processPlayerInventoryAdd, 0); -packet(SMSG_PLAYER_INVENTORY_REMOVE, 0x00af, 6, &InventoryRecv::processPlayerInventoryRemove, 0); -packet(SMSG_PLAYER_INVENTORY_USE, 0x01c8, 13, &Ea::InventoryRecv::processPlayerInventoryUse, 0); -packet(SMSG_PLAYER_MOVE, 0x01da, 60, &BeingRecv::processPlayerMove, 0); -packet(SMSG_PLAYER_MOVE_TO_ATTACK, 0x0139, 16, &Ea::BeingRecv::processPlayerMoveToAttack, 0); -packet(SMSG_PLAYER_SKILLS, 0x010f, -1, &SkillRecv::processPlayerSkills, 0); -packet(SMSG_PLAYER_SKILL_UP, 0x010e, 11, &Ea::SkillRecv::processPlayerSkillUp, 0); -packet(SMSG_PLAYER_STATUS_CHANGE, 0x0119, 13, &BeingRecv::processPlayerStatusChange, 0); -packet(SMSG_PLAYER_STAT_UPDATE_1, 0x00b0, 8, &Ea::PlayerRecv::processPlayerStatUpdate1, 0); -packet(SMSG_PLAYER_STAT_UPDATE_2, 0x00b1, 8, &Ea::PlayerRecv::processPlayerStatUpdate2, 0); -packet(SMSG_PLAYER_STAT_UPDATE_3, 0x0141, 14, &Ea::PlayerRecv::processPlayerStatUpdate3, 0); -packet(SMSG_PLAYER_STAT_UPDATE_4, 0x00bc, 6, &Ea::PlayerRecv::processPlayerStatUpdate4, 0); -packet(SMSG_PLAYER_STAT_UPDATE_5, 0x00bd, 44, &PlayerRecv::processPlayerStatUpdate5, 0); -packet(SMSG_PLAYER_STAT_UPDATE_6, 0x00be, 5, &Ea::PlayerRecv::processPlayerStatUpdate6, 0); -packet(SMSG_PLAYER_STOP, 0x0088, 10, &Ea::BeingRecv::processPlayerStop, 0); -packet(SMSG_PLAYER_STORAGE_ADD, 0x00f4, 21, &InventoryRecv::processPlayerStorageAdd, 0); -packet(SMSG_PLAYER_STORAGE_CLOSE, 0x00f8, 2, &Ea::InventoryRecv::processPlayerStorageClose, 0); -packet(SMSG_PLAYER_STORAGE_EQUIP, 0x00a6, -1, &InventoryRecv::processPlayerStorageEquip, 0); -packet(SMSG_PLAYER_STORAGE_ITEMS, 0x01f0, -1, &InventoryRecv::processPlayerStorage, 0); -packet(SMSG_PLAYER_STORAGE_REMOVE, 0x00f6, 8, &InventoryRecv::processPlayerStorageRemove, 0); -packet(SMSG_PLAYER_STORAGE_STATUS, 0x00f2, 6, &Ea::InventoryRecv::processPlayerStorageStatus, 0); -packet(SMSG_PLAYER_UNEQUIP, 0x00ac, 7, &InventoryRecv::processPlayerUnEquip, 0); -packet(SMSG_PLAYER_UPDATE_1, 0x01d8, 54, &BeingRecv::processPlayerUpdate1, 0); -packet(SMSG_PLAYER_UPDATE_2, 0x01d9, 53, &BeingRecv::processPlayerUpdate2, 0); -packet(SMSG_PLAYER_WARP, 0x0091, 22, &Ea::PlayerRecv::processPlayerWarp, 0); -packet(SMSG_PVP_MAP_MODE, 0x0199, 4, &Ea::BeingRecv::processPvpMapMode, 0); -packet(SMSG_PVP_SET, 0x019a, 14, &BeingRecv::processPvpSet, 0); -packet(SMSG_QUEST_PLAYER_VARS, 0x0215, -1, &QuestRecv::processPlayerQuests, 0); -packet(SMSG_QUEST_SET_VAR, 0x0214, 8, &QuestRecv::processSetQuestVar, 0); -packet(SMSG_SCRIPT_MESSAGE, 0x0229, -1, &ChatRecv::processScriptMessage, 0); -packet(SMSG_SERVER_PING, 0x007f, 6, nullptr, 0); -packet(SMSG_SERVER_VERSION_RESPONSE, 0x7531, 10, &LoginRecv::processServerVersion, 0); -packet(SMSG_SKILL_CASTING, 0x013e, 24, &BeingRecv::processSkillCasting, 0); -packet(SMSG_SKILL_CAST_CANCEL, 0x01b9, 6, &BeingRecv::processSkillCastCancel, 0); -packet(SMSG_SKILL_DAMAGE, 0x01de, 33, &BeingRecv::processSkillDamage, 0); -packet(SMSG_SKILL_FAILED, 0x0110, 10, &SkillRecv::processSkillFailed, 0); -packet(SMSG_SKILL_NO_DAMAGE, 0x011a, 15, &Ea::BeingRecv::processSkillNoDamage, 0); -packet(SMSG_SOLVE_CHAR_NAME, 0x0194, 30, nullptr, 0); -packet(SMSG_TRADE_CANCEL, 0x00ee, 2, &Ea::TradeRecv::processTradeCancel, 0); -packet(SMSG_TRADE_COMPLETE, 0x00f0, 3, &Ea::TradeRecv::processTradeComplete, 0); -packet(SMSG_TRADE_ITEM_ADD, 0x00e9, 19, &TradeRecv::processTradeItemAdd, 0); -packet(SMSG_TRADE_ITEM_ADD_RESPONSE, 0x01b1, 7, &TradeRecv::processTradeItemAddResponse, 0); -packet(SMSG_TRADE_OK, 0x00ec, 3, &Ea::TradeRecv::processTradeOk, 0); -packet(SMSG_TRADE_REQUEST, 0x00e5, 26, &TradeRecv::processTradeRequest, 0); -packet(SMSG_TRADE_RESPONSE, 0x00e7, 3, &TradeRecv::processTradeResponse, 0); -packet(SMSG_UPDATE_HOST, 0x0063, -1, &Ea::LoginRecv::processUpdateHost, 0); -packet(SMSG_WALK_RESPONSE, 0x0087, 12, &PlayerRecv::processWalkResponse, 0); -packet(SMSG_WHISPER, 0x0097, -1, &ChatRecv::processWhisper, 0); -packet(SMSG_WHISPER_RESPONSE, 0x0098, 3, &ChatRecv::processWhisperResponse, 0); -packet(SMSG_WHO_ANSWER, 0x00c2, 6, &Ea::GameRecv::processWhoAnswer, 0); -packet(SMSG_MAP_MASK, 0x0226, 10, &Ea::PlayerRecv::processMapMask, 0); -packet(SMSG_PLAYER_CLIENT_COMMAND, 0x0230, -1, &Ea::PlayerRecv::processPlayerClientCommand, 0); -packet(SMSG_MAP_SET_TILES_TYPE, 0x0231, 34, &Ea::MapRecv::processSetTilesType, 0); diff --git a/src/net/tmwa/packetsout.inc b/src/net/tmwa/packetsout.inc deleted file mode 100644 index 4b93150ed..000000000 --- a/src/net/tmwa/packetsout.inc +++ /dev/null @@ -1,110 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#define PACKETSOUT_VOID - -packet(CMSG_SERVER_VERSION_REQUEST, 0x7530, 0, nullptr); - -packet(CMSG_LOGIN_REGISTER, 0x0064, 0, nullptr); - -packet(CMSG_NAME_REQUEST, 0x0094, 0, nullptr); - -packet(CMSG_CHAR_PASSWORD_CHANGE, 0x0061, 0, nullptr); -packet(CMSG_CHAR_SERVER_CONNECT, 0x0065, 0, nullptr); -packet(CMSG_CHAR_SELECT, 0x0066, 0, nullptr); -packet(CMSG_CHAR_CREATE, 0x0067, 0, nullptr); -packet(CMSG_CHAR_DELETE, 0x0068, 0, nullptr); - -packet(CMSG_MAP_SERVER_CONNECT, 0x0072, 0, nullptr); -packet(CMSG_MAP_PING, 0x007e, 0, nullptr); -packet(CMSG_MAP_LOADED, 0x007d, 0, nullptr); -packet(CMSG_CLIENT_QUIT, 0x018A, 0, nullptr); - -packet(CMSG_CHAT_MESSAGE, 0x008c, 0, nullptr); -packet(CMSG_CHAT_WHISPER, 0x0096, 0, nullptr); -packet(CMSG_CHAT_WHO, 0x00c1, 0, nullptr); - -packet(CMSG_SKILL_LEVELUP_REQUEST, 0x0112, 0, nullptr); -packet(CMSG_STAT_UPDATE_REQUEST, 0x00bb, 0, nullptr); -packet(CMSG_SKILL_USE_BEING, 0x0113, 0, nullptr); -packet(CMSG_SKILL_USE_POSITION, 0x0116, 0, nullptr); -packet(CMSG_SKILL_USE_POSITION_MORE, 0x0190, 0, nullptr); -packet(CMSG_SKILL_USE_MAP, 0x011b, 0, nullptr); - -packet(CMSG_PLAYER_INVENTORY_USE, 0x00a7, 0, nullptr); -packet(CMSG_PLAYER_INVENTORY_DROP, 0x00a2, 0, nullptr); -packet(CMSG_PLAYER_EQUIP, 0x00a9, 0, nullptr); -packet(CMSG_PLAYER_UNEQUIP, 0x00ab, 0, nullptr); - -packet(CMSG_ITEM_PICKUP, 0x009f, 0, nullptr); -packet(CMSG_PLAYER_CHANGE_DIR, 0x009b, 0, nullptr); -packet(CMSG_PLAYER_CHANGE_DEST, 0x0085, 0, nullptr); -packet(CMSG_PLAYER_CHANGE_ACT, 0x0089, 0, nullptr); -packet(CMSG_PLAYER_RESTART, 0x00b2, 0, nullptr); -packet(CMSG_PLAYER_EMOTE, 0x00bf, 0, nullptr); -packet(CMSG_PLAYER_STOP_ATTACK, 0x0118, 0, nullptr); -packet(CMSG_WHO_REQUEST, 0x00c1, 0, nullptr); - -packet(CMSG_NPC_TALK, 0x0090, 0, nullptr); -packet(CMSG_NPC_NEXT_REQUEST, 0x00b9, 0, nullptr); -packet(CMSG_NPC_CLOSE, 0x0146, 0, nullptr); -packet(CMSG_NPC_LIST_CHOICE, 0x00b8, 0, nullptr); -packet(CMSG_NPC_INT_RESPONSE, 0x0143, 0, nullptr); -packet(CMSG_NPC_STR_RESPONSE, 0x01d5, 0, nullptr); -packet(CMSG_NPC_BUY_SELL_REQUEST, 0x00c5, 0, nullptr); -packet(CMSG_NPC_BUY_REQUEST, 0x00c8, 0, nullptr); -packet(CMSG_NPC_SELL_REQUEST, 0x00c9, 0, nullptr); - -packet(CMSG_TRADE_REQUEST, 0x00e4, 0, nullptr); -packet(CMSG_TRADE_RESPONSE, 0x00e6, 0, nullptr); -packet(CMSG_TRADE_ITEM_ADD_REQUEST, 0x00e8, 0, nullptr); -packet(CMSG_TRADE_CANCEL_REQUEST, 0x00ed, 0, nullptr); -packet(CMSG_TRADE_ADD_COMPLETE, 0x00eb, 0, nullptr); -packet(CMSG_TRADE_OK, 0x00ef, 0, nullptr); - -packet(CMSG_PARTY_CREATE, 0x00f9, 0, nullptr); -packet(CMSG_PARTY_INVITE, 0x00fc, 0, nullptr); -packet(CMSG_PARTY_INVITED, 0x00ff, 0, nullptr); -packet(CMSG_PARTY_LEAVE, 0x0100, 0, nullptr); -packet(CMSG_PARTY_SETTINGS, 0x0102, 0, nullptr); -packet(CMSG_PARTY_KICK, 0x0103, 0, nullptr); -packet(CMSG_PARTY_MESSAGE, 0x0108, 0, nullptr); - -packet(CMSG_MOVE_TO_STORAGE, 0x00f3, 0, nullptr); -packet(CMSG_MOVE_FROM_STORAGE, 0x00f5, 0, nullptr); -packet(CMSG_CLOSE_STORAGE, 0x00f7, 0, nullptr); - -packet(CMSG_ADMIN_ANNOUNCE, 0x0099, 0, nullptr); -packet(CMSG_ADMIN_LOCAL_ANNOUNCE, 0x019C, 0, nullptr); -packet(CMSG_ADMIN_HIDE, 0x019D, 0, nullptr); -packet(CMSG_ADMIN_KICK, 0x00CC, 0, nullptr); -packet(CMSG_ADMIN_MUTE, 0x0149, 0, nullptr); - -packet(CMSG_SOLVE_CHAR_NAME, 0x0193, 0, nullptr); -packet(CMSG_IGNORE_NICK, 0x00cf, 0, nullptr); - -packet(CMSG_CLIENT_DISCONNECT, 0x7532, 0, nullptr); -packet(CMSG_IGNORE_ALL, 0x00d0, 0, nullptr); - -#ifdef PACKETS_UPDATE -// condition code here -#endif diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp deleted file mode 100644 index cef9588f7..000000000 --- a/src/net/tmwa/partyhandler.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008 Lloyd Bryant <lloyd_bryant@netzero.net> - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/partyhandler.h" - -#include "actormanager.h" -#include "notifymanager.h" -#include "party.h" - -#include "being/localplayer.h" - -#include "enums/resources/notifytypes.h" - -#include "net/ea/partyrecv.h" - -#include "net/tmwa/messageout.h" -#include "net/tmwa/protocolout.h" - -#include "debug.h" - -namespace TmwAthena -{ - -PartyHandler::PartyHandler() : - Ea::PartyHandler() -{ - partyHandler = this; -} - -PartyHandler::~PartyHandler() -{ - partyHandler = nullptr; -} - -void PartyHandler::create(const std::string &name) const -{ - createOutPacket(CMSG_PARTY_CREATE); - outMsg.writeString(name.substr(0, 23), 24, "party name"); -} - -void PartyHandler::invite(const std::string &name) const -{ - if (actorManager == nullptr) - return; - - const Being *const being = actorManager->findBeingByName( - name, ActorType::Player); - if (being != nullptr) - { - createOutPacket(CMSG_PARTY_INVITE); - outMsg.writeBeingId(being->getId(), "account id"); - } -} - -void PartyHandler::inviteResponse(const int partyId A_UNUSED, - const bool accept) const -{ - if (localPlayer != nullptr) - { - createOutPacket(CMSG_PARTY_INVITED); - outMsg.writeBeingId(localPlayer->getId(), "account id"); - outMsg.writeInt32(accept ? 1 : 0, "accept"); - } -} - -void PartyHandler::leave() const -{ - createOutPacket(CMSG_PARTY_LEAVE); -} - -void PartyHandler::kick(const Being *const being) const -{ - if (being != nullptr) - { - createOutPacket(CMSG_PARTY_KICK); - outMsg.writeBeingId(being->getId(), "account id"); - outMsg.writeString("", 24, "unused"); - } -} - -void PartyHandler::kick(const std::string &name) const -{ - if (Ea::taParty == nullptr) - return; - - const PartyMember *const m = Ea::taParty->getMember(name); - if (m == nullptr) - { - NotifyManager::notify(NotifyTypes::PARTY_USER_NOT_IN_PARTY, name); - return; - } - - createOutPacket(CMSG_PARTY_KICK); - outMsg.writeBeingId(m->getID(), "member id"); - outMsg.writeString(name, 24, "unused"); -} - -void PartyHandler::chat(const std::string &text) const -{ - createOutPacket(CMSG_PARTY_MESSAGE); - outMsg.writeInt16(CAST_S16(text.length() + 4), "len"); - outMsg.writeString(text, CAST_S32(text.length()), "text"); -} - -void PartyHandler::setShareExperience(const PartyShareT share) const -{ - if (share == PartyShare::NOT_POSSIBLE) - return; - - createOutPacket(CMSG_PARTY_SETTINGS); - outMsg.writeInt16(CAST_S16(share), "share exp"); - outMsg.writeInt16(CAST_S16(Ea::PartyRecv::mShareItems), - "share items"); -} - -void PartyHandler::setShareItems(const PartyShareT share) const -{ - if (share == PartyShare::NOT_POSSIBLE) - return; - - createOutPacket(CMSG_PARTY_SETTINGS); - outMsg.writeInt16(CAST_S16(Ea::PartyRecv::mShareExp), - "share exp"); - outMsg.writeInt16(CAST_S16(share), "share items"); -} - -void PartyHandler::changeLeader(const std::string &name A_UNUSED) const -{ -} - -void PartyHandler::allowInvite(const bool allow A_UNUSED) const -{ -} - -PartyShareT PartyHandler::getShareAutoItems() const -{ - return PartyShare::NOT_POSSIBLE; -} - -void PartyHandler::setShareAutoItems(const PartyShareT share A_UNUSED) const -{ -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/partyhandler.h b/src/net/tmwa/partyhandler.h deleted file mode 100644 index 4942bfc86..000000000 --- a/src/net/tmwa/partyhandler.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008 Lloyd Bryant <lloyd_bryant@netzero.net> - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_PARTYHANDLER_H -#define NET_TMWA_PARTYHANDLER_H - -#include "net/ea/partyhandler.h" - -namespace TmwAthena -{ - -class PartyHandler final : public Ea::PartyHandler -{ - public: - PartyHandler(); - - A_DELETE_COPY(PartyHandler) - - ~PartyHandler(); - - void create(const std::string &name) const override final; - - void invite(const std::string &name) const override final; - - void inviteResponse(const int partyId, - const bool accept) const override final; - - void leave() const override final; - - void kick(const Being *const being) const override final; - - void kick(const std::string &name) const override final; - - void chat(const std::string &text) const override final; - - void setShareExperience(const PartyShareT share) const override final; - - void setShareItems(const PartyShareT share) const override final; - - void changeLeader(const std::string &name) const override final - A_CONST; - - void allowInvite(const bool allow) const override final A_CONST; - - void setShareAutoItems(const PartyShareT share) const override final; - - PartyShareT getShareAutoItems() const override final A_WARN_UNUSED; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_PARTYHANDLER_H diff --git a/src/net/tmwa/partyrecv.cpp b/src/net/tmwa/partyrecv.cpp deleted file mode 100644 index b25a501c8..000000000 --- a/src/net/tmwa/partyrecv.cpp +++ /dev/null @@ -1,304 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008 Lloyd Bryant <lloyd_bryant@netzero.net> - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/partyrecv.h" - -#include "actormanager.h" -#include "notifymanager.h" -#include "party.h" - -#include "being/localplayer.h" - -#include "enums/resources/notifytypes.h" - -#include "gui/windows/chatwindow.h" -#include "gui/windows/socialwindow.h" - -#include "gui/widgets/tabs/chat/partytab.h" - -#include "net/messagein.h" - -#include "net/ea/partyrecv.h" - -#include "utils/foreach.h" - -#include "debug.h" - -namespace TmwAthena -{ - -void PartyRecv::processPartySettings(Net::MessageIn &msg) -{ - if (partyTab == nullptr) - { - if (chatWindow == nullptr) - return; - - Ea::PartyRecv::createTab(); - } - - // These seem to indicate the sharing mode for exp and items - const PartyShareT exp = static_cast<PartyShareT>( - msg.readInt16("share exp")); - const PartyShareT item = static_cast<PartyShareT>( - msg.readInt16("share items")); - Ea::PartyRecv::processPartyExpSettingsContinue(msg, exp); - Ea::PartyRecv::processPartyItemSettingsContinue(msg, item); -} - -void PartyRecv::processPartyInfo(Net::MessageIn &msg) -{ - bool isOldParty = false; - std::set<std::string> names; - std::set<std::string> onlineNames; - if (Ea::taParty == nullptr) - { - logger->log1("error: party empty in SMSG_PARTY_INFO"); - Ea::taParty = Party::getParty(1); - } - if (Ea::taParty != nullptr) - { - if (Ea::taParty->getNumberOfElements() > 1) - { - isOldParty = true; - Ea::taParty->getNamesSet(names); - const Party::MemberList *const members = Ea::taParty->getMembers(); - FOR_EACHP (Party::MemberList::const_iterator, it, members) - { - if ((*it)->getOnline()) - onlineNames.insert((*it)->getName()); - } - if (localPlayer != nullptr) - onlineNames.insert(localPlayer->getName()); - } - } - - if (localPlayer == nullptr) - logger->log1("error: localPlayer==0 in SMSG_PARTY_INFO"); - - if (Ea::taParty != nullptr) - Ea::taParty->clearMembers(); - - const int length = msg.readInt16("len"); - if (Ea::taParty != nullptr) - Ea::taParty->setName(msg.readString(24, "party name")); - - const int count = (length - 28) / 46; - if ((localPlayer != nullptr) && (Ea::taParty != nullptr)) - { - localPlayer->setParty(Ea::taParty); - localPlayer->setPartyName(Ea::taParty->getName()); - } - - for (int i = 0; i < count; i++) - { - const BeingId id = msg.readBeingId("id"); - std::string nick = msg.readString(24, "nick"); - std::string map = msg.readString(16, "map"); - const bool leader = msg.readUInt8("leader") == 0U; - const bool online = msg.readUInt8("online") == 0U; - - if (Ea::taParty != nullptr) - { - bool joined(false); - - if (isOldParty) - { - if (names.find(nick) == names.end()) - { - NotifyManager::notify(NotifyTypes::PARTY_USER_JOINED, - nick); - joined = true; - } - } - PartyMember *const member = Ea::taParty->addMember(id, nick); - if (member != nullptr) - { - if (!joined && (partyTab != nullptr)) - { - if (!names.empty() && ((onlineNames.find(nick) - == onlineNames.end() && online) - || (onlineNames.find(nick) != onlineNames.end() - && !online))) - { - partyTab->showOnline(nick, fromBool(online, Online)); - } - - member->setLeader(leader); - member->setOnline(online); - member->setMap(map); - } - else - { - member->setLeader(leader); - member->setOnline(online); - member->setMap(map); - } - } - } - } - - if (Ea::taParty != nullptr) - Ea::taParty->sort(); - - if ((localPlayer != nullptr) && (Ea::taParty != nullptr)) - { - localPlayer->setParty(Ea::taParty); - localPlayer->setPartyName(Ea::taParty->getName()); - if (socialWindow != nullptr) - socialWindow->updateParty(); - } -} - -void PartyRecv::processPartyMessage(Net::MessageIn &msg) -{ - const int msgLength = msg.readInt16("len") - 8; - if (msgLength <= 0) - return; - - const BeingId id = msg.readBeingId("id"); - const std::string chatMsg = msg.readString(msgLength, "message"); - - if ((Ea::taParty != nullptr) && (partyTab != nullptr)) - { - const PartyMember *const member = Ea::taParty->getMember(id); - if (member != nullptr) - { - partyTab->chatLog(member->getName(), chatMsg); - } - else - { - NotifyManager::notify(NotifyTypes::PARTY_UNKNOWN_USER_MSG, - chatMsg); - } - } -} - -void PartyRecv::processPartyInviteResponse(Net::MessageIn &msg) -{ - if (partyTab == nullptr) - return; - - const std::string nick = msg.readString(24, "nick"); - - switch (msg.readUInt8("status")) - { - case 0: - NotifyManager::notify(NotifyTypes::PARTY_INVITE_ALREADY_MEMBER, - nick); - break; - case 1: - NotifyManager::notify(NotifyTypes::PARTY_INVITE_REFUSED, nick); - break; - case 2: - NotifyManager::notify(NotifyTypes::PARTY_INVITE_DONE, nick); - break; - case 3: - NotifyManager::notify(NotifyTypes::PARTY_INVITE_PARTY_FULL, - nick); - break; - default: - NotifyManager::notify(NotifyTypes::PARTY_INVITE_ERROR, nick); - break; - } -} - -void PartyRecv::processPartyInvited(Net::MessageIn &msg) -{ - const BeingId id = msg.readBeingId("account id"); - std::string nick; - - if (actorManager != nullptr) - { - const Being *const being = actorManager->findBeing(id); - if (being != nullptr) - { - if (being->getType() == ActorType::Player) - nick = being->getName(); - } - } - - if (socialWindow != nullptr) - { - const std::string partyName = msg.readString(24, "party name"); - socialWindow->showPartyInvite(partyName, nick, 0); - } - else - { - msg.readString(24, "party name"); - } -} - -void PartyRecv::processPartyMove(Net::MessageIn &msg) -{ - const BeingId id = msg.readBeingId("id"); - PartyMember *m = nullptr; - if (Ea::taParty != nullptr) - m = Ea::taParty->getMember(id); - if (m != nullptr) - { - msg.readInt32("unused"); - m->setX(msg.readInt16("x")); - m->setY(msg.readInt16("y")); - const bool online = msg.readUInt8("online") != 0; - if (m->getOnline() != online) - partyTab->showOnline(m->getName(), fromBool(online, Online)); - m->setOnline(online); - msg.readString(24, "party"); - msg.readString(24, "nick"); - m->setMap(msg.readString(16, "map")); - } - else - { - msg.readInt32("unused"); - msg.readInt16("x"); - msg.readInt16("y"); - msg.readUInt8("online"); - msg.readString(24, "party"); - msg.readString(24, "nick"); - msg.readString(16, "map"); - } -} - -void PartyRecv::processPartyUpdateHp(Net::MessageIn &msg) -{ - const BeingId id = msg.readBeingId("id"); - const int hp = msg.readInt16("hp"); - const int maxhp = msg.readInt16("max hp"); - PartyMember *m = nullptr; - if (Ea::taParty != nullptr) - m = Ea::taParty->getMember(id); - if (m != nullptr) - { - m->setHp(hp); - m->setMaxHp(maxhp); - } - - // The server only sends this when the member is in range, so - // lets make sure they get the party hilight. - if ((actorManager != nullptr) && (Ea::taParty != nullptr)) - { - if (Being *const b = actorManager->findBeing(id)) - b->setParty(Ea::taParty); - } -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/partyrecv.h b/src/net/tmwa/partyrecv.h deleted file mode 100644 index 8665df3e8..000000000 --- a/src/net/tmwa/partyrecv.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008 Lloyd Bryant <lloyd_bryant@netzero.net> - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_PARTYRECV_H -#define NET_TMWA_PARTYRECV_H - -namespace Net -{ - class MessageIn; -} // namespace Net - -namespace TmwAthena -{ - namespace PartyRecv - { - void processPartySettings(Net::MessageIn &msg); - void processPartyInfo(Net::MessageIn &msg); - void processPartyMessage(Net::MessageIn &msg); - void processPartyInviteResponse(Net::MessageIn &msg); - void processPartyInvited(Net::MessageIn &msg); - void processPartyMove(Net::MessageIn &msg); - void processPartyUpdateHp(Net::MessageIn &msg); - } // namespace PartyRecv -} // namespace TmwAthena - -#endif // NET_TMWA_PARTYRECV_H diff --git a/src/net/tmwa/pethandler.cpp b/src/net/tmwa/pethandler.cpp deleted file mode 100644 index c10fd5882..000000000 --- a/src/net/tmwa/pethandler.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2013-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/pethandler.h" - -#include "debug.h" - -namespace TmwAthena -{ - -PetHandler::PetHandler() : - mRandCounter(1000) -{ - petHandler = this; -} - -PetHandler::~PetHandler() -{ - petHandler = nullptr; -} - -void PetHandler::move(const int x A_UNUSED, - const int y A_UNUSED) const -{ -} - -void PetHandler::emote(const uint8_t emoteId A_UNUSED) -{ -} - -void PetHandler::catchPet(const Being *const being A_UNUSED) const -{ -} - -void PetHandler::sendPetMessage(const int data A_UNUSED) const -{ -} - -void PetHandler::setName(const std::string &name A_UNUSED) const -{ -} - -void PetHandler::requestStatus() const -{ -} - -void PetHandler::feed() const -{ -} - -void PetHandler::dropLoot() const -{ -} - -void PetHandler::returnToEgg() const -{ -} - -void PetHandler::unequip() const -{ -} - -void PetHandler::setDirection(const unsigned char type A_UNUSED) const -{ -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/pethandler.h b/src/net/tmwa/pethandler.h deleted file mode 100644 index e7a816d21..000000000 --- a/src/net/tmwa/pethandler.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2013-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_PETHANDLER_H -#define NET_TMWA_PETHANDLER_H - -#include "net/pethandler.h" - -namespace TmwAthena -{ - -class PetHandler final : public Net::PetHandler -{ - public: - PetHandler(); - - A_DELETE_COPY(PetHandler) - - ~PetHandler(); - - void move(const int x, - const int y) const override final; - - void emote(const uint8_t emoteId) override final; - - void catchPet(const Being *const being) const override final A_CONST; - - void sendPetMessage(const int data) const override final A_CONST; - - void setName(const std::string &name) const override final A_CONST; - - void requestStatus() const override final A_CONST; - - void feed() const override final A_CONST; - - void dropLoot() const override final A_CONST; - - void returnToEgg() const override final A_CONST; - - void unequip() const override final A_CONST; - - void setDirection(const unsigned char type) const override final; - - protected: - int mRandCounter; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_PETHANDLER_H diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp deleted file mode 100644 index 4d2e5cc33..000000000 --- a/src/net/tmwa/playerhandler.cpp +++ /dev/null @@ -1,422 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/playerhandler.h" - -#include "notifymanager.h" -#include "party.h" - -#include "being/localplayer.h" -#include "being/playerinfo.h" - -#include "const/net/nostat.h" - -#include "enums/resources/notifytypes.h" - -#include "gui/windows/skilldialog.h" -#include "gui/windows/statuswindow.h" - -#include "net/ea/inventoryhandler.h" - -#include "net/tmwa/messageout.h" -#include "net/tmwa/protocolout.h" -#include "net/tmwa/sp.h" - -#include "resources/db/unitsdb.h" - -#include "debug.h" - -namespace TmwAthena -{ - -PlayerHandler::PlayerHandler() : - Ea::PlayerHandler() -{ - playerHandler = this; -} - -PlayerHandler::~PlayerHandler() -{ - playerHandler = nullptr; -} - -void PlayerHandler::attack(const BeingId id, - const Keep keep) const -{ - createOutPacket(CMSG_PLAYER_CHANGE_ACT); - outMsg.writeBeingId(id, "target id"); - if (keep == Keep_true) - outMsg.writeInt8(7, "action"); - else - outMsg.writeInt8(0, "action"); -} - -void PlayerHandler::stopAttack() const -{ - createOutPacket(CMSG_PLAYER_STOP_ATTACK); -} - -void PlayerHandler::emote(const uint8_t emoteId) const -{ - createOutPacket(CMSG_PLAYER_EMOTE); - outMsg.writeInt8(emoteId, "emote id"); -} - -void PlayerHandler::increaseAttribute(const AttributesT attr, - const int amount A_UNUSED) const -{ - if (attr >= Attributes::PLAYER_STR && attr <= Attributes::PLAYER_LUK) - { - createOutPacket(CMSG_STAT_UPDATE_REQUEST); - outMsg.writeInt16(CAST_S16(attr), "attribute id"); - outMsg.writeInt8(1, "increment"); - } -} - -void PlayerHandler::increaseSkill(const uint16_t skillId) const -{ - if (PlayerInfo::getAttribute(Attributes::PLAYER_SKILL_POINTS) <= 0) - return; - - createOutPacket(CMSG_SKILL_LEVELUP_REQUEST); - outMsg.writeInt16(skillId, "skill id"); -} - -void PlayerHandler::pickUp(const FloorItem *const floorItem) const -{ - if (floorItem == nullptr) - return; - - createOutPacket(CMSG_ITEM_PICKUP); - outMsg.writeBeingId(floorItem->getId(), "object id"); - Ea::InventoryHandler::pushPickup(floorItem->getId()); -} - -void PlayerHandler::setDirection(const unsigned char direction) const -{ - createOutPacket(CMSG_PLAYER_CHANGE_DIR); - outMsg.writeInt16(0, "unused"); - outMsg.writeInt8(direction, "direction"); -} - -void PlayerHandler::setDestination(const int x, const int y, - const int direction) const -{ - createOutPacket(CMSG_PLAYER_CHANGE_DEST); - outMsg.writeCoordinates(CAST_U16(x), - CAST_U16(y), - CAST_U8(direction), "destination"); -} - -void PlayerHandler::changeAction(const BeingActionT &action) const -{ - char type; - switch (action) - { - case BeingAction::SIT: - type = 2; - break; - case BeingAction::STAND: - case BeingAction::PRESTAND: - type = 3; - break; - default: - case BeingAction::MOVE: - case BeingAction::ATTACK: - case BeingAction::DEAD: - case BeingAction::HURT: - case BeingAction::SPAWN: - case BeingAction::CAST: - return; - } - - createOutPacket(CMSG_PLAYER_CHANGE_ACT); - outMsg.writeInt32(0, "unused"); - outMsg.writeInt8(type, "action"); -} - -void PlayerHandler::respawn() const -{ - createOutPacket(CMSG_PLAYER_RESTART); - outMsg.writeInt8(0, "action"); -} - -void PlayerHandler::requestOnlineList() const -{ -} - -void PlayerHandler::removeOption() const -{ -} - -void PlayerHandler::changeCart(const int type A_UNUSED) const -{ -} - -void PlayerHandler::setMemo() const -{ -} - -void PlayerHandler::updateStatus(const uint8_t status A_UNUSED) const -{ -} - -void PlayerHandler::setShortcut(const int idx A_UNUSED, - const uint8_t type A_UNUSED, - const int id A_UNUSED, - const int level A_UNUSED) const -{ -} - -void PlayerHandler::doriDori() const -{ -} - -void PlayerHandler::explosionSpirits() const -{ -} - -void PlayerHandler::requestPvpInfo() const -{ -} - -void PlayerHandler::revive() const -{ -} - -void PlayerHandler::shortcutShiftRow(const int row A_UNUSED) const -{ -} - -void PlayerHandler::setViewEquipment(const bool allow A_UNUSED) const -{ -} - -#define setStatComplex(stat) \ - PlayerInfo::setStatBase(stat, base, notify); \ - if (mod != NoStat) \ - PlayerInfo::setStatMod(stat, mod) - -void PlayerHandler::setStat(Net::MessageIn &msg, - const int type, - const int base, - const int mod, - const Notify notify) const -{ - switch (type) - { - case Sp::SPEED: - localPlayer->setWalkSpeed(base); - PlayerInfo::setStatBase(Attributes::PLAYER_WALK_SPEED, base); - PlayerInfo::setStatMod(Attributes::PLAYER_WALK_SPEED, 0); - break; - case Sp::BASEEXP: - PlayerInfo::setAttribute(Attributes::PLAYER_EXP, base); - break; - case Sp::JOBEXP: - PlayerInfo::setAttribute(Attributes::PLAYER_JOB_EXP, base); - break; - case Sp::KARMA: - PlayerInfo::setStatBase(Attributes::PLAYER_KARMA, base); - PlayerInfo::setStatMod(Attributes::PLAYER_KARMA, 0); - break; - case Sp::MANNER: - PlayerInfo::setStatBase(Attributes::PLAYER_MANNER, base); - PlayerInfo::setStatMod(Attributes::PLAYER_MANNER, 0); - break; - case Sp::HP: - PlayerInfo::setAttribute(Attributes::PLAYER_HP, base); - if (localPlayer->isInParty() && (Party::getParty(1) != nullptr)) - { - PartyMember *const m = Party::getParty(1) - ->getMember(localPlayer->getId()); - if (m != nullptr) - { - m->setHp(base); - m->setMaxHp(PlayerInfo::getAttribute( - Attributes::PLAYER_MAX_HP)); - } - } - break; - case Sp::MAXHP: - PlayerInfo::setAttribute(Attributes::PLAYER_MAX_HP, base); - - if (localPlayer->isInParty() && (Party::getParty(1) != nullptr)) - { - PartyMember *const m = Party::getParty(1)->getMember( - localPlayer->getId()); - if (m != nullptr) - { - m->setHp(PlayerInfo::getAttribute(Attributes::PLAYER_HP)); - m->setMaxHp(base); - } - } - break; - case Sp::SP: - PlayerInfo::setAttribute(Attributes::PLAYER_MP, base); - break; - case Sp::MAXSP: - PlayerInfo::setAttribute(Attributes::PLAYER_MAX_MP, base); - break; - case Sp::STATUSPOINT: - PlayerInfo::setAttribute(Attributes::PLAYER_CHAR_POINTS, base); - break; - case Sp::BASELEVEL: - PlayerInfo::setAttribute(Attributes::PLAYER_BASE_LEVEL, base); - if (localPlayer != nullptr) - { - localPlayer->setLevel(base); - localPlayer->updateName(); - } - break; - case Sp::SKILLPOINT: - PlayerInfo::setAttribute(Attributes::PLAYER_SKILL_POINTS, base); - if (skillDialog != nullptr) - skillDialog->update(); - break; - case Sp::STR: - setStatComplex(Attributes::PLAYER_STR); - break; - case Sp::AGI: - setStatComplex(Attributes::PLAYER_AGI); - break; - case Sp::VIT: - setStatComplex(Attributes::PLAYER_VIT); - break; - case Sp::INT: - setStatComplex(Attributes::PLAYER_INT); - break; - case Sp::DEX: - setStatComplex(Attributes::PLAYER_DEX); - break; - case Sp::LUK: - setStatComplex(Attributes::PLAYER_LUK); - break; - case Sp::ZENY: - { - const int oldMoney = PlayerInfo::getAttribute(Attributes::MONEY); - const int newMoney = base; - if (newMoney > oldMoney) - { - NotifyManager::notify(NotifyTypes::MONEY_GET, - UnitsDb::formatCurrency(newMoney - oldMoney)); - } - else if (newMoney < oldMoney) - { - NotifyManager::notify(NotifyTypes::MONEY_SPENT, - UnitsDb::formatCurrency(oldMoney - newMoney).c_str()); - } - - PlayerInfo::setAttribute(Attributes::MONEY, newMoney); - break; - } - case Sp::NEXTBASEEXP: - PlayerInfo::setAttribute(Attributes::PLAYER_EXP_NEEDED, base); - break; - case Sp::JOB_MOD: - PlayerInfo::setAttribute(Attributes::PLAYER_JOB_EXP_NEEDED, base); - break; - case Sp::WEIGHT: - PlayerInfo::setAttribute(Attributes::TOTAL_WEIGHT, base); - break; - case Sp::MAXWEIGHT: - PlayerInfo::setAttribute(Attributes::MAX_WEIGHT, base); - break; - case Sp::USTR: - statusWindow->setPointsNeeded(Attributes::PLAYER_STR, base); - break; - case Sp::UAGI: - statusWindow->setPointsNeeded(Attributes::PLAYER_AGI, base); - break; - case Sp::UVIT: - statusWindow->setPointsNeeded(Attributes::PLAYER_VIT, base); - break; - case Sp::UINT: - statusWindow->setPointsNeeded(Attributes::PLAYER_INT, base); - break; - case Sp::UDEX: - statusWindow->setPointsNeeded(Attributes::PLAYER_DEX, base); - break; - case Sp::ULUK: - statusWindow->setPointsNeeded(Attributes::PLAYER_LUK, base); - break; - - case Sp::ATK1: - PlayerInfo::setStatBase(Attributes::PLAYER_ATK, base); - PlayerInfo::updateAttrs(); - break; - case Sp::ATK2: - PlayerInfo::setStatMod(Attributes::PLAYER_ATK, base); - PlayerInfo::updateAttrs(); - break; - case Sp::MATK1: - PlayerInfo::setStatBase(Attributes::PLAYER_MATK, base); - break; - case Sp::MATK2: - PlayerInfo::setStatMod(Attributes::PLAYER_MATK, base); - break; - case Sp::DEF1: - PlayerInfo::setStatBase(Attributes::PLAYER_DEF, base); - break; - case Sp::DEF2: - PlayerInfo::setStatMod(Attributes::PLAYER_DEF, base); - break; - case Sp::MDEF1: - PlayerInfo::setStatBase(Attributes::PLAYER_MDEF, base); - break; - case Sp::MDEF2: - PlayerInfo::setStatMod(Attributes::PLAYER_MDEF, base); - break; - case Sp::HIT: - PlayerInfo::setStatBase(Attributes::PLAYER_HIT, base); - break; - case Sp::FLEE1: - PlayerInfo::setStatBase(Attributes::PLAYER_FLEE, base); - break; - case Sp::FLEE2: - PlayerInfo::setStatMod(Attributes::PLAYER_FLEE, base); - break; - case Sp::CRITICAL: - PlayerInfo::setStatBase(Attributes::PLAYER_CRIT, base); - break; - case Sp::ASPD: - localPlayer->setAttackSpeed(base); - PlayerInfo::setStatBase(Attributes::PLAYER_ATTACK_DELAY, base); - PlayerInfo::setStatMod(Attributes::PLAYER_ATTACK_DELAY, 0); - PlayerInfo::updateAttrs(); - break; - case Sp::JOBLEVEL: - PlayerInfo::setAttribute(Attributes::PLAYER_JOB_LEVEL, base); - break; - case Sp::GM_LEVEL: - localPlayer->setGroupId(base); - break; - - default: - UNIMPLEMENTEDPACKETFIELD(type); - break; - } -} - -#undef setStatComplex - -} // namespace TmwAthena diff --git a/src/net/tmwa/playerhandler.h b/src/net/tmwa/playerhandler.h deleted file mode 100644 index 898a03057..000000000 --- a/src/net/tmwa/playerhandler.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_PLAYERHANDLER_H -#define NET_TMWA_PLAYERHANDLER_H - -#include "net/ea/playerhandler.h" - -namespace TmwAthena -{ - -class PlayerHandler final : public Ea::PlayerHandler -{ - public: - PlayerHandler(); - - A_DELETE_COPY(PlayerHandler) - - ~PlayerHandler(); - - void attack(const BeingId id, - const Keep keep) const override final; - void stopAttack() const override final; - void emote(const uint8_t emoteId) const override final; - - void increaseAttribute(const AttributesT attr, - const int amount) const override final; - void increaseSkill(const uint16_t skillId) const override final; - - void pickUp(const FloorItem *const floorItem) const override final; - void setDirection(const unsigned char direction) const override final; - void setDestination(const int x, const int y, - const int direction) const override final; - void changeAction(const BeingActionT &action) - const override final; - void requestOnlineList() const override final A_CONST; - void updateStatus(const uint8_t status) const override final A_CONST; - - void respawn() const override final; - - void setShortcut(const int idx, - const uint8_t type, - const int id, - const int level) const override final A_CONST; - - void shortcutShiftRow(const int row) const override final; - - void removeOption() const override final A_CONST; - - void changeCart(const int type) const override final A_CONST; - - void setMemo() const override final A_CONST; - - void doriDori() const override final A_CONST; - - void explosionSpirits() const override final A_CONST; - - void requestPvpInfo() const override final A_CONST; - - void revive() const override final A_CONST; - - void setViewEquipment(const bool allow) const override final A_CONST; - - void setStat(Net::MessageIn &msg, - const int type, - const int base, - const int mod, - const Notify notify) const override final; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_PLAYERHANDLER_H diff --git a/src/net/tmwa/playerrecv.cpp b/src/net/tmwa/playerrecv.cpp deleted file mode 100644 index b6b23403f..000000000 --- a/src/net/tmwa/playerrecv.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/playerrecv.h" - -#include "being/localplayer.h" -#include "being/playerinfo.h" - -#include "gui/windows/statuswindow.h" - -#include "net/messagein.h" - -#include "debug.h" - -namespace TmwAthena -{ - -void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg) -{ - BLOCK_START("PlayerRecv::processPlayerStatUpdate5") - PlayerInfo::setAttribute(Attributes::PLAYER_CHAR_POINTS, - msg.readInt16("char points")); - - unsigned int val = msg.readUInt8("str"); - PlayerInfo::setStatBase(Attributes::PLAYER_STR, val); - if (statusWindow != nullptr) - { - statusWindow->setPointsNeeded(Attributes::PLAYER_STR, - msg.readUInt8("str cost")); - } - else - { - msg.readUInt8("str cost"); - } - - val = msg.readUInt8("agi"); - PlayerInfo::setStatBase(Attributes::PLAYER_AGI, val); - if (statusWindow != nullptr) - { - statusWindow->setPointsNeeded(Attributes::PLAYER_AGI, - msg.readUInt8("agi cost")); - } - else - { - msg.readUInt8("agi cost"); - } - - val = msg.readUInt8("vit"); - PlayerInfo::setStatBase(Attributes::PLAYER_VIT, val); - if (statusWindow != nullptr) - { - statusWindow->setPointsNeeded(Attributes::PLAYER_VIT, - msg.readUInt8("vit cost")); - } - else - { - msg.readUInt8("vit cost"); - } - - val = msg.readUInt8("int"); - PlayerInfo::setStatBase(Attributes::PLAYER_INT, val); - if (statusWindow != nullptr) - { - statusWindow->setPointsNeeded(Attributes::PLAYER_INT, - msg.readUInt8("int cost")); - } - else - { - msg.readUInt8("int cost"); - } - - val = msg.readUInt8("dex"); - PlayerInfo::setStatBase(Attributes::PLAYER_DEX, val); - if (statusWindow != nullptr) - { - statusWindow->setPointsNeeded(Attributes::PLAYER_DEX, - msg.readUInt8("dex cost")); - } - else - { - msg.readUInt8("dex cost"); - } - - val = msg.readUInt8("luk"); - PlayerInfo::setStatBase(Attributes::PLAYER_LUK, val); - if (statusWindow != nullptr) - { - statusWindow->setPointsNeeded(Attributes::PLAYER_LUK, - msg.readUInt8("luk cost")); - } - else - { - msg.readUInt8("luk cost"); - } - - PlayerInfo::setStatBase(Attributes::PLAYER_ATK, - msg.readInt16("atk"), Notify_false); - PlayerInfo::setStatMod(Attributes::PLAYER_ATK, msg.readInt16("atk+")); - PlayerInfo::updateAttrs(); - - val = msg.readInt16("matk"); - PlayerInfo::setStatBase(Attributes::PLAYER_MATK, val, Notify_false); - - val = msg.readInt16("matk+"); - PlayerInfo::setStatMod(Attributes::PLAYER_MATK, val); - - PlayerInfo::setStatBase(Attributes::PLAYER_DEF, - msg.readInt16("def"), Notify_false); - PlayerInfo::setStatMod(Attributes::PLAYER_DEF, msg.readInt16("def+")); - - PlayerInfo::setStatBase(Attributes::PLAYER_MDEF, - msg.readInt16("mdef"), Notify_false); - PlayerInfo::setStatMod(Attributes::PLAYER_MDEF, msg.readInt16("mdef+")); - - PlayerInfo::setStatBase(Attributes::PLAYER_HIT, msg.readInt16("hit")); - - PlayerInfo::setStatBase(Attributes::PLAYER_FLEE, - msg.readInt16("flee"), Notify_false); - PlayerInfo::setStatMod(Attributes::PLAYER_FLEE, msg.readInt16("flee+")); - - PlayerInfo::setStatBase(Attributes::PLAYER_CRIT, msg.readInt16("crit")); - - PlayerInfo::setStatBase(Attributes::PLAYER_MANNER, - msg.readInt16("manner")); - msg.readInt16("unused?"); - BLOCK_END("PlayerRecv::processPlayerStatUpdate5") -} - -void PlayerRecv::processWalkResponse(Net::MessageIn &msg) -{ - BLOCK_START("PlayerRecv::processWalkResponse") - /* - * This client assumes that all walk messages succeed, - * and that the server will send a correction notice - * otherwise. - */ - uint16_t srcX, srcY, dstX, dstY; - msg.readInt32("tick"); - msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path"); - msg.readUInt8("unused"); - if (localPlayer != nullptr) - localPlayer->setRealPos(dstX, dstY); - BLOCK_END("PlayerRecv::processWalkResponse") -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/playerrecv.h b/src/net/tmwa/playerrecv.h deleted file mode 100644 index 626114640..000000000 --- a/src/net/tmwa/playerrecv.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_PLAYERRECV_H -#define NET_TMWA_PLAYERRECV_H - -namespace Net -{ - class MessageIn; -} // namespace Net - -namespace TmwAthena -{ - namespace PlayerRecv - { - void processPlayerStatUpdate5(Net::MessageIn &msg); - void processWalkResponse(Net::MessageIn &msg); - } // namespace PlayerRecv -} // namespace TmwAthena - -#endif // NET_TMWA_PLAYERRECV_H diff --git a/src/net/tmwa/protocolout.cpp b/src/net/tmwa/protocolout.cpp deleted file mode 100644 index 38cee1227..000000000 --- a/src/net/tmwa/protocolout.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2015-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -namespace TmwAthena -{ -#include "net/protocoloutdefine.h" -#include "net/tmwa/packetsout.inc" -#undef packet -PROTOCOLOUT_VOID -PACKETSOUT_VOID -} // namespace TmwAthena - -#include "debug.h" diff --git a/src/net/tmwa/protocolout.h b/src/net/tmwa/protocolout.h deleted file mode 100644 index 08ce043fc..000000000 --- a/src/net/tmwa/protocolout.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2015-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_PROTOCOLOUT_H -#define NET_TMWA_PROTOCOLOUT_H - -#include "net/protocoloutinclude.h" - -#define PROTOCOLOUT_VOID - -namespace TmwAthena -{ -#include "net/tmwa/packetsout.inc" -PACKETSOUT_VOID -} // namespace TmwAthena - -#undef packet -#undef packet2 -#undef startCondition -#undef endCondition -#undef PACKETSOUT_VOID - -#endif // NET_TMWA_PROTOCOLOUT_H diff --git a/src/net/tmwa/questhandler.cpp b/src/net/tmwa/questhandler.cpp deleted file mode 100644 index 1acc60740..000000000 --- a/src/net/tmwa/questhandler.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/questhandler.h" - -#include "debug.h" - -namespace TmwAthena -{ - -QuestHandler::QuestHandler() : - Net::QuestHandler() -{ - questHandler = this; -} - -QuestHandler::~QuestHandler() -{ - questHandler = nullptr; -} - -void QuestHandler::setQeustActiveState(const int questId A_UNUSED, - const bool active A_UNUSED) const -{ -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/questhandler.h b/src/net/tmwa/questhandler.h deleted file mode 100644 index 4c56ef0c9..000000000 --- a/src/net/tmwa/questhandler.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_QUESTHANDLER_H -#define NET_TMWA_QUESTHANDLER_H - -#include "net/questhandler.h" - -namespace TmwAthena -{ - -class QuestHandler final : public Net::QuestHandler -{ - public: - QuestHandler(); - - A_DELETE_COPY(QuestHandler) - - ~QuestHandler(); - - void setQeustActiveState(const int questId, - const bool active) const override final - A_CONST; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_QUESTHANDLER_H diff --git a/src/net/tmwa/questrecv.cpp b/src/net/tmwa/questrecv.cpp deleted file mode 100644 index d38012a69..000000000 --- a/src/net/tmwa/questrecv.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/questrecv.h" - -#include "gui/windows/skilldialog.h" -#include "gui/windows/questswindow.h" - -#include "net/messagein.h" - -#include "const/resources/skill.h" - -#include "debug.h" - -namespace TmwAthena -{ - -void QuestRecv::processSetQuestVar(Net::MessageIn &msg) -{ - const int var = msg.readInt16("variable"); - const int val = msg.readInt32("value"); - if (questsWindow != nullptr) - { - questsWindow->updateQuest(var, val, 0, 0, 0); - questsWindow->rebuild(true); - } - if (skillDialog != nullptr) - { - skillDialog->updateQuest(var, val, 0, 0, 0); - skillDialog->playUpdateEffect(var + SKILL_VAR_MIN_ID); - } -} - -void QuestRecv::processPlayerQuests(Net::MessageIn &msg) -{ - const int count = (msg.readInt16("len") - 4) / 6; - for (int f = 0; f < count; f ++) - { - const int var = msg.readInt16("variable"); - const int val = msg.readInt32("value"); - if (questsWindow != nullptr) - questsWindow->updateQuest(var, val, 0, 0, 0); - if (skillDialog != nullptr) - skillDialog->updateQuest(var, val, 0, 0, 0); - } - if (questsWindow != nullptr) - questsWindow->rebuild(false); -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/questrecv.h b/src/net/tmwa/questrecv.h deleted file mode 100644 index 3e9d958ea..000000000 --- a/src/net/tmwa/questrecv.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_QUESTRECV_H -#define NET_TMWA_QUESTRECV_H - -namespace Net -{ - class MessageIn; -} // namespace Net - -namespace TmwAthena -{ - namespace QuestRecv - { - void processSetQuestVar(Net::MessageIn &msg); - void processPlayerQuests(Net::MessageIn &msg); - } // namespace QuestRecv -} // namespace TmwAthena - -#endif // NET_TMWA_QUESTRECV_H diff --git a/src/net/tmwa/recvpackets.inc b/src/net/tmwa/recvpackets.inc deleted file mode 100644 index 808019018..000000000 --- a/src/net/tmwa/recvpackets.inc +++ /dev/null @@ -1,32 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2015-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_RECVPACKETS_H -#define NET_TMWA_RECVPACKETS_H - -#define RECVPACKETS_VOID - -#include "net/recvpacketdefine.h" - -#include "net/tmwa/packetsin.inc" - -#undef packet - -#endif // NET_TMWA_RECVPACKETS_H diff --git a/src/net/tmwa/roulettehandler.cpp b/src/net/tmwa/roulettehandler.cpp deleted file mode 100644 index 03b1afd8a..000000000 --- a/src/net/tmwa/roulettehandler.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/roulettehandler.h" - -#include "debug.h" - -namespace TmwAthena -{ - -RouletteHandler::RouletteHandler() : - Net::RouletteHandler() -{ - rouletteHandler = this; -} - -RouletteHandler::~RouletteHandler() -{ - rouletteHandler = nullptr; -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/roulettehandler.h b/src/net/tmwa/roulettehandler.h deleted file mode 100644 index b575d3ca3..000000000 --- a/src/net/tmwa/roulettehandler.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_ROULETTEHANDLER_H -#define NET_TMWA_ROULETTEHANDLER_H - -#include "net/roulettehandler.h" - -namespace TmwAthena -{ -class RouletteHandler final : public Net::RouletteHandler -{ - public: - RouletteHandler(); - - A_DELETE_COPY(RouletteHandler) - - ~RouletteHandler(); -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_ROULETTEHANDLER_H diff --git a/src/net/tmwa/searchstorehandler.cpp b/src/net/tmwa/searchstorehandler.cpp deleted file mode 100644 index 34f41fb8a..000000000 --- a/src/net/tmwa/searchstorehandler.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/searchstorehandler.h" - -#include "debug.h" - -namespace TmwAthena -{ - -SearchStoreHandler::SearchStoreHandler() : - Net::SearchStoreHandler() -{ - searchStoreHandler = this; -} - -SearchStoreHandler::~SearchStoreHandler() -{ - searchStoreHandler = nullptr; -} - -void SearchStoreHandler::search(const StoreSearchTypeT type A_UNUSED, - const int minPrice A_UNUSED, - const int maxPrice A_UNUSED, - const int itemId A_UNUSED) const -{ -} - -void SearchStoreHandler::nextPage() const -{ -} - -void SearchStoreHandler::close() const -{ -} - -void SearchStoreHandler::select(const int accountId A_UNUSED, - const int storeId A_UNUSED, - const int itemId A_UNUSED) const -{ -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/searchstorehandler.h b/src/net/tmwa/searchstorehandler.h deleted file mode 100644 index 20112fcb1..000000000 --- a/src/net/tmwa/searchstorehandler.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_SEARCHSTOREHANDLER_H -#define NET_TMWA_SEARCHSTOREHANDLER_H - -#include "net/searchstorehandler.h" - -namespace TmwAthena -{ -class SearchStoreHandler final : public Net::SearchStoreHandler -{ - public: - SearchStoreHandler(); - - A_DELETE_COPY(SearchStoreHandler) - - ~SearchStoreHandler(); - - void search(const StoreSearchTypeT type, - const int minPrice, - const int maxPrice, - const int itemId) const override final A_CONST; - - void nextPage() const override final A_CONST; - - void close() const override final A_CONST; - - void select(const int accountId, - const int storeId, - const int itemId) const override final A_CONST; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_SEARCHSTOREHANDLER_H diff --git a/src/net/tmwa/serverfeatures.cpp b/src/net/tmwa/serverfeatures.cpp deleted file mode 100644 index 5af454314..000000000 --- a/src/net/tmwa/serverfeatures.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/serverfeatures.h" - -#include "debug.h" - -extern unsigned int tmwServerVersion; - -namespace TmwAthena -{ - -ServerFeatures::ServerFeatures() : - Net::ServerFeatures() -{ - serverFeatures = this; -} - -bool ServerFeatures::haveServerOnlineList() const -{ - return false; -} - -bool ServerFeatures::haveServerHp() const -{ - return tmwServerVersion > 0x0f0513; -} - -bool ServerFeatures::havePlayerStatusUpdate() const -{ - return false; -} - -bool ServerFeatures::haveIncompleteChatMessages() const -{ - return tmwServerVersion <= 0x100209; -} - -bool ServerFeatures::haveRaceSelection() const -{ - return false; -} - -bool ServerFeatures::haveLookSelection() const -{ - return false; -} - -bool ServerFeatures::haveMove3() const -{ - return tmwServerVersion >= 0x0f0512 && tmwServerVersion <= 0xf0706; -} - -bool ServerFeatures::haveCharOtherGender() const -{ - return tmwServerVersion > 0x0f0b17; -} - -bool ServerFeatures::haveMonsterAttackRange() const -{ - return tmwServerVersion >= 0x0f0513; -} - -bool ServerFeatures::haveEmailOnRegister() const -{ - return false; -} - -bool ServerFeatures::haveEmailOnDelete() const -{ - return false; -} - -bool ServerFeatures::haveServerVersion() const -{ - return true; -} - -bool ServerFeatures::haveMapServerVersion() const -{ - return false; -} - -bool ServerFeatures::haveNpcGender() const -{ - return tmwServerVersion >= 0x0f0513; -} - -bool ServerFeatures::haveJoinChannel() const -{ - return false; -} - -bool ServerFeatures::haveCreateCharGender() const -{ - return tmwServerVersion > 0x0f0b17; -} - -bool ServerFeatures::haveTalkPet() const -{ - return true; -} - -bool ServerFeatures::haveMovePet() const -{ - return true; -} - -bool ServerFeatures::haveServerWarpNames() const -{ - return false; -} - -bool ServerFeatures::haveExtendedRiding() const -{ - return false; -} - -bool ServerFeatures::haveExtendedDropsPosition() const -{ - return false; -} - -bool ServerFeatures::haveMoveWhileSit() const -{ - return true; -} - -bool ServerFeatures::haveKillerId() const -{ - return false; -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/serverfeatures.h b/src/net/tmwa/serverfeatures.h deleted file mode 100644 index 95371c1b3..000000000 --- a/src/net/tmwa/serverfeatures.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_SERVERFEATURES_H -#define NET_TMWA_SERVERFEATURES_H - -#include "net/serverfeatures.h" - -#include "localconsts.h" - -namespace TmwAthena -{ -class ServerFeatures final : public Net::ServerFeatures -{ - public: - ServerFeatures(); - - A_DELETE_COPY(ServerFeatures) - - bool haveServerOnlineList() const override final A_CONST; - - bool haveServerHp() const override final; - - bool havePlayerStatusUpdate() const override final A_CONST; - - bool haveIncompleteChatMessages() const override final; - - bool haveRaceSelection() const override final A_CONST; - - bool haveLookSelection() const override final A_CONST; - - bool haveMove3() const override final; - - bool haveCharOtherGender() const override final; - - bool haveMonsterAttackRange() const override final; - - bool haveEmailOnRegister() const override final A_CONST; - - bool haveEmailOnDelete() const override final A_CONST; - - bool haveServerVersion() const override final A_CONST; - - bool haveMapServerVersion() const override final A_CONST; - - bool haveNpcGender() const override final; - - bool haveJoinChannel() const override final A_CONST; - - bool haveCreateCharGender() const override final; - - bool haveTalkPet() const override final A_CONST; - - bool haveMovePet() const override final A_CONST; - - bool haveServerWarpNames() const override final A_CONST; - - bool haveExtendedRiding() const override final A_CONST; - - bool haveExtendedDropsPosition() const override final A_CONST; - - bool haveMoveWhileSit() const override final A_CONST; - - bool haveKillerId() const override final A_CONST; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_SERVERFEATURES_H diff --git a/src/net/tmwa/skillhandler.cpp b/src/net/tmwa/skillhandler.cpp deleted file mode 100644 index 9f8de7b2f..000000000 --- a/src/net/tmwa/skillhandler.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/skillhandler.h" - -#include "net/tmwa/messageout.h" -#include "net/tmwa/protocolout.h" - -#include "debug.h" - -namespace TmwAthena -{ - -SkillHandler::SkillHandler() : - Ea::SkillHandler() -{ - skillHandler = this; -} - -SkillHandler::~SkillHandler() -{ - skillHandler = nullptr; -} - -void SkillHandler::useBeing(const int id, const int level, - const BeingId beingId) const -{ - createOutPacket(CMSG_SKILL_USE_BEING); - outMsg.writeInt16(CAST_S16(id), "skill id"); - outMsg.writeInt16(CAST_S16(level), "level"); - outMsg.writeBeingId(beingId, "target id"); -} - -void SkillHandler::usePos(const int id, const int level, - const int x, const int y) const -{ - createOutPacket(CMSG_SKILL_USE_POSITION); - outMsg.writeInt16(CAST_S16(level), "skill level"); - outMsg.writeInt16(CAST_S16(id), "skill id"); - outMsg.writeInt16(CAST_S16(x), "x"); - outMsg.writeInt16(CAST_S16(y), "y"); -} - -void SkillHandler::usePos(const int id, const int level, - const int x, const int y, - const std::string &text) const -{ - createOutPacket(CMSG_SKILL_USE_POSITION_MORE); - outMsg.writeInt16(CAST_S16(level), "skill level"); - outMsg.writeInt16(CAST_S16(id), "skill id"); - outMsg.writeInt16(CAST_S16(x), "x"); - outMsg.writeInt16(CAST_S16(y), "y"); - outMsg.writeString(text, 80, "text"); -} - -void SkillHandler::useMap(const int id, const std::string &map) const -{ - createOutPacket(CMSG_SKILL_USE_MAP); - outMsg.writeInt16(CAST_S16(id), "skill id"); - outMsg.writeString(map, 16, "map name"); -} - -void SkillHandler::getAlchemistRanks() const -{ -} - -void SkillHandler::getBlacksmithRanks() const -{ -} - -void SkillHandler::getPkRanks() const -{ -} - -void SkillHandler::getTaekwonRanks() const -{ -} - -void SkillHandler::feelSaveOk(const int which A_UNUSED) const -{ -} - -void SkillHandler::lessEffects(const bool isLess A_UNUSED) const -{ -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/skillhandler.h b/src/net/tmwa/skillhandler.h deleted file mode 100644 index 324774bea..000000000 --- a/src/net/tmwa/skillhandler.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_SKILLHANDLER_H -#define NET_TMWA_SKILLHANDLER_H - -#include "net/ea/skillhandler.h" - -namespace TmwAthena -{ - -class SkillHandler final : public Ea::SkillHandler -{ - public: - SkillHandler(); - - A_DELETE_COPY(SkillHandler) - - ~SkillHandler(); - - void useBeing(const int id, - const int level, - const BeingId beingId) const override final; - - void usePos(const int id, - const int level, - const int x, const int y) const override final; - - void usePos(const int id, - const int level, - const int x, const int y, - const std::string &text) const override final; - - void useMap(const int id, const std::string &map) const override final; - - void getAlchemistRanks() const override final; - - void getBlacksmithRanks() const override final; - - void getPkRanks() const override final; - - void getTaekwonRanks() const override final; - - void feelSaveOk(const int which) const override final; - - void lessEffects(const bool isLess) const override final; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_SKILLHANDLER_H diff --git a/src/net/tmwa/skillrecv.cpp b/src/net/tmwa/skillrecv.cpp deleted file mode 100644 index faea79059..000000000 --- a/src/net/tmwa/skillrecv.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/skillrecv.h" - -#include "notifymanager.h" - -#include "being/localplayer.h" -#include "being/playerinfo.h" - -#include "const/net/skill.h" - -#include "enums/resources/notifytypes.h" - -#include "gui/windows/skilldialog.h" - -#include "net/messagein.h" - -#include "utils/gettext.h" - -#include "debug.h" - -namespace TmwAthena -{ - -void SkillRecv::processPlayerSkills(Net::MessageIn &msg) -{ - msg.readInt16("len"); - const int skillCount = (msg.getLength() - 4) / 37; - int updateSkill = 0; - - for (int k = 0; k < skillCount; k++) - { - const int skillId = msg.readInt16("skill id"); - const SkillType::SkillType inf = static_cast<SkillType::SkillType>( - msg.readInt16("inf")); - msg.readInt16("skill pool flags"); - const int level = msg.readInt16("skill level"); - const int sp = msg.readInt16("sp"); - const int range = msg.readInt16("range"); - msg.skip(24, "unused"); - const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable); - const int oldLevel = PlayerInfo::getSkillLevel(skillId); - if ((oldLevel != 0) && oldLevel != level) - updateSkill = skillId; - PlayerInfo::setSkillLevel(skillId, level); - if (skillDialog != nullptr) - { - if (!skillDialog->updateSkill(skillId, range, up, inf, sp)) - { - skillDialog->addSkill(SkillOwner::Player, - skillId, "", level, range, up, inf, sp); - } - } - } - if (skillDialog != nullptr) - { - skillDialog->update(); - if (updateSkill != 0) - skillDialog->playUpdateEffect(updateSkill); - } -} - -void SkillRecv::processSkillFailed(Net::MessageIn &msg) -{ - // Action failed (ex. sit because you have not reached the - // right level) - const int skillId = msg.readInt16("skill id"); - const int16_t bskill = msg.readInt16("bskill"); - msg.readInt16("btype"); - 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)) - { - logger->log("Action: %d/%d", bskill, success); - } - - std::string txt; - if (success == CAST_S32(SKILL_FAILED) - && skillId == CAST_S32(SKILL_BASIC)) - { - if ((localPlayer != nullptr) && - bskill == CAST_S32(BSKILL_EMOTE) && - reason == CAST_S32(RFAIL_SKILLDEP)) - { - localPlayer->stopAdvert(); - } - - switch (bskill) - { - case BSKILL_TRADE: - // TRANSLATORS: error message - txt = _("Trade failed!"); - break; - case BSKILL_EMOTE: - // TRANSLATORS: error message - txt = _("Emote failed!"); - break; - case BSKILL_SIT: - // TRANSLATORS: error message - txt = _("Sit failed!"); - break; - case BSKILL_CREATECHAT: - // TRANSLATORS: error message - txt = _("Chat creating failed!"); - break; - case BSKILL_JOINPARTY: - // TRANSLATORS: error message - txt = _("Could not join party!"); - break; - case BSKILL_SHOUT: - // TRANSLATORS: error message - txt = _("Cannot shout!"); - break; - default: - UNIMPLEMENTEDPACKETFIELD(bskill); - break; - } - - txt.append(" "); - - switch (reason) - { - case RFAIL_SKILLDEP: - // TRANSLATORS: error message - txt.append(_("You have not yet reached a high enough lvl!")); - break; - case RFAIL_INSUFHP: - // TRANSLATORS: error message - txt.append(_("Insufficient HP!")); - break; - case RFAIL_INSUFSP: - // TRANSLATORS: error message - txt.append(_("Insufficient SP!")); - break; - case RFAIL_NOMEMO: - // TRANSLATORS: error message - txt.append(_("You have no memos!")); - break; - case RFAIL_SKILLDELAY: - // TRANSLATORS: error message - txt.append(_("You cannot do that right now!")); - break; - case RFAIL_ZENY: - // TRANSLATORS: error message - txt.append(_("Seems you need more money... ;-)")); - break; - case RFAIL_WEAPON: - // TRANSLATORS: error message - txt.append(_("You cannot use this skill with that " - "kind of weapon!")); - break; - case RFAIL_REDGEM: - // TRANSLATORS: error message - txt.append(_("You need another red gem!")); - break; - case RFAIL_BLUEGEM: - // TRANSLATORS: 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!")); - break; - default: - // TRANSLATORS: error message - txt.append(_("Huh? What's that?")); - UNIMPLEMENTEDPACKETFIELD(reason); - break; - } - } - else - { - switch (skillId) - { - case SKILL_WARP : - // TRANSLATORS: error message - txt = _("Warp failed..."); - break; - case SKILL_STEAL : - // TRANSLATORS: error message - txt = _("Could not steal anything..."); - break; - case SKILL_ENVENOM : - // TRANSLATORS: error message - txt = _("Poison had no effect..."); - break; - default: - UNIMPLEMENTEDPACKETFIELD(skillId); - break; - } - } - - NotifyManager::notify(NotifyTypes::SKILL_FAIL_MESSAGE, txt); -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/skillrecv.h b/src/net/tmwa/skillrecv.h deleted file mode 100644 index f63d883c2..000000000 --- a/src/net/tmwa/skillrecv.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_SKILLRECV_H -#define NET_TMWA_SKILLRECV_H - -namespace Net -{ - class MessageIn; -} // namespace Net - -namespace TmwAthena -{ - namespace SkillRecv - { - void processSkillFailed(Net::MessageIn &msg); - void processPlayerSkills(Net::MessageIn &msg); - } // namespace SkillRecv -} // namespace TmwAthena - -#endif // NET_TMWA_SKILLRECV_H diff --git a/src/net/tmwa/sp.h b/src/net/tmwa/sp.h deleted file mode 100644 index 10711bfce..000000000 --- a/src/net/tmwa/sp.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_SP_H -#define NET_TMWA_SP_H - -namespace Sp -{ - enum - { - SPEED = 0, - BASEEXP = 1, - JOBEXP = 2, - KARMA = 3, - MANNER = 4, - HP = 5, - MAXHP = 6, - SP = 7, - MAXSP = 8, - STATUSPOINT = 9, - BASELEVEL = 11, - SKILLPOINT = 12, - STR = 13, - AGI = 14, - VIT = 15, - INT = 16, - DEX = 17, - LUK = 18, - CLASS = 19, - ZENY = 20, - SEX = 21, - NEXTBASEEXP = 22, - JOB_MOD = 23, // SP_NEXTJOBEXP - WEIGHT = 24, - MAXWEIGHT = 25, - USTR = 32, - UAGI = 33, - UVIT = 34, - UINT = 35, - UDEX = 36, - ULUK = 37, - ATK1 = 41, - ATK2 = 42, - MATK1 = 43, - MATK2 = 44, - DEF1 = 45, - DEF2 = 46, - MDEF1 = 47, - MDEF2 = 48, - HIT = 49, - FLEE1 = 50, - FLEE2 = 51, - CRITICAL = 52, - ASPD = 53, - JOBLEVEL = 55, - - GM_LEVEL = 500 - }; -} // namespace Sp - -#endif // NET_TMWA_SP_H diff --git a/src/net/tmwa/sprite.h b/src/net/tmwa/sprite.h deleted file mode 100644 index 97cdada4c..000000000 --- a/src/net/tmwa/sprite.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_SPRITE_H -#define NET_TMWA_SPRITE_H - -enum -{ - SPRITE_BASE = 0, - SPRITE_HAIR, - SPRITE_WEAPON, - SPRITE_HEAD_BOTTOM, - SPRITE_HEAD_TOP, - SPRITE_HEAD_MID, - SPRITE_HAIR_COLOR, - SPRITE_CLOTHES_COLOR, - SPRITE_SHIELD, - SPRITE_SHOES, - SPRITE_BODY, - SPRITE_FLOOR, - SPRITE_ROBE, - SPRITE_EVOL2, - SPRITE_VECTOREND -}; - -#endif // NET_TMWA_SPRITE_H diff --git a/src/net/tmwa/tradehandler.cpp b/src/net/tmwa/tradehandler.cpp deleted file mode 100644 index f82612bd0..000000000 --- a/src/net/tmwa/tradehandler.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/tradehandler.h" - -#include "being/playerinfo.h" - -#include "const/net/inventory.h" - -#include "net/tmwa/messageout.h" -#include "net/tmwa/protocolout.h" - -#include "resources/item/item.h" - -#include "debug.h" - -extern std::string tradePartnerName; - -namespace TmwAthena -{ - -TradeHandler::TradeHandler() : - Ea::TradeHandler() -{ - tradeHandler = this; -} - -TradeHandler::~TradeHandler() -{ - tradeHandler = nullptr; -} - -void TradeHandler::request(const Being *const being) const -{ - if (being == nullptr) - return; - - createOutPacket(CMSG_TRADE_REQUEST); - outMsg.writeBeingId(being->getId(), "player id"); -} - -void TradeHandler::respond(const bool accept) const -{ - if (!accept) - PlayerInfo::setTrading(Trading_false); - - createOutPacket(CMSG_TRADE_RESPONSE); - outMsg.writeInt8(CAST_S8(accept ? 3 : 4), "accept"); -} - -void TradeHandler::addItem(const Item *const item, const int amount) const -{ - if (item == nullptr) - return; - - createOutPacket(CMSG_TRADE_ITEM_ADD_REQUEST); - outMsg.writeInt16(CAST_S16( - item->getInvIndex() + INVENTORY_OFFSET), "index"); - outMsg.writeInt32(amount, "amount"); -} - -void TradeHandler::setMoney(const int amount) const -{ - createOutPacket(CMSG_TRADE_ITEM_ADD_REQUEST); - outMsg.writeInt16(0, "index"); - outMsg.writeInt32(amount, "amount"); -} - -void TradeHandler::confirm() const -{ - createOutPacket(CMSG_TRADE_ADD_COMPLETE); -} - -void TradeHandler::finish() const -{ - createOutPacket(CMSG_TRADE_OK); -} - -void TradeHandler::cancel() const -{ - createOutPacket(CMSG_TRADE_CANCEL_REQUEST); -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/tradehandler.h b/src/net/tmwa/tradehandler.h deleted file mode 100644 index b8538f1bc..000000000 --- a/src/net/tmwa/tradehandler.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_TRADEHANDLER_H -#define NET_TMWA_TRADEHANDLER_H - -#include "net/ea/tradehandler.h" - -namespace TmwAthena -{ - -class TradeHandler final : public Ea::TradeHandler -{ - public: - TradeHandler(); - - A_DELETE_COPY(TradeHandler) - - ~TradeHandler(); - - void request(const Being *const being) const override final; - - void respond(const bool accept) const override final; - - void addItem(const Item *const item, - const int amount) const override final; - - void setMoney(const int amount) const override final; - - void confirm() const override final; - - void finish() const override final; - - void cancel() const override final; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_TRADEHANDLER_H diff --git a/src/net/tmwa/traderecv.cpp b/src/net/tmwa/traderecv.cpp deleted file mode 100644 index d799d9f91..000000000 --- a/src/net/tmwa/traderecv.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/traderecv.h" - -#include "notifymanager.h" - -#include "being/playerinfo.h" -#include "being/playerrelation.h" -#include "being/playerrelations.h" - -#include "const/net/inventory.h" - -#include "enums/resources/notifytypes.h" - -#include "gui/windows/tradewindow.h" - -#include "net/messagein.h" -#include "net/tradehandler.h" - -#include "net/ea/traderecv.h" - -#include "resources/inventory/inventory.h" - -#include "resources/item/item.h" - -#include "utils/stringutils.h" - -#include "debug.h" - -extern std::string tradePartnerName; - -namespace TmwAthena -{ - -void TradeRecv::processTradeRequest(Net::MessageIn &msg) -{ - Ea::TradeRecv::processTradeRequestContinue(msg.readString(24, "name")); -} - -void TradeRecv::processTradeItemAdd(Net::MessageIn &msg) -{ - const int amount = msg.readInt32("amount"); - const int type = msg.readInt16("type"); - const uint8_t identify = msg.readUInt8("identify"); - msg.readUInt8("attribute"); - const uint8_t refine = msg.readUInt8("refine"); - int cards[maxCards]; - for (int f = 0; f < maxCards; f++) - cards[f] = msg.readUInt16("card"); - - if (tradeWindow != nullptr) - { - if (type == 0) - { - tradeWindow->setMoney(amount); - } - else - { - tradeWindow->addItem2(type, - ItemType::Unknown, - cards, - nullptr, - 4, - false, - amount, - refine, - ItemColor_one, - fromBool(identify, Identified), - Damaged_false, - Favorite_false, - Equipm_false); - } - } -} - -void TradeRecv::processTradeItemAddResponse(Net::MessageIn &msg) -{ - // Trade: New Item add response (was 0x00ea, now 01b1) - const int index = msg.readInt16("index") - INVENTORY_OFFSET; - Item *item = nullptr; - if (PlayerInfo::getInventory() != nullptr) - item = PlayerInfo::getInventory()->getItem(index); - - if (item == nullptr) - { - if (tradeWindow != nullptr) - tradeWindow->receivedOk(true); - return; - } - const int quantity = msg.readInt16("amount"); - - const uint8_t res = msg.readUInt8("status"); - switch (res) - { - case 0: - // Successfully added item - if (tradeWindow != nullptr) - { - tradeWindow->addItem2(item->getId(), - item->getType(), - item->getCards(), - nullptr, - 4, - true, - quantity, - item->getRefine(), - item->getColor(), - item->getIdentified(), - item->getDamaged(), - item->getFavorite(), - item->isEquipment()); - } - item->increaseQuantity(-quantity); - break; - case 1: - // Add item failed - player overweighted - NotifyManager::notify(NotifyTypes:: - TRADE_ADD_PARTNER_OVER_WEIGHT); - break; - case 2: - // Add item failed - player has no free slot - NotifyManager::notify(NotifyTypes::TRADE_ADD_PARTNER_NO_SLOTS); - break; - case 3: - // Add item failed - non tradable item - NotifyManager::notify(NotifyTypes::TRADE_ADD_UNTRADABLE_ITEM); - break; - default: - NotifyManager::notify(NotifyTypes::TRADE_ADD_ERROR); - UNIMPLEMENTEDPACKETFIELD(res); - logger->log("QQQ SMSG_TRADE_ITEM_ADD_RESPONSE: " - + toString(res)); - break; - } -} - -void TradeRecv::processTradeResponse(Net::MessageIn &msg) -{ - if (tradePartnerName.empty() || - !playerRelations.hasPermission(tradePartnerName, - PlayerRelation::TRADE)) - { - tradeHandler->respond(false); - return; - } - const uint8_t type = msg.readUInt8("type"); - Ea::TradeRecv::processTradeResponseContinue(type); -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/traderecv.h b/src/net/tmwa/traderecv.h deleted file mode 100644 index 253348dab..000000000 --- a/src/net/tmwa/traderecv.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_TRADERECV_H -#define NET_TMWA_TRADERECV_H - -namespace Net -{ - class MessageIn; -} // namespace Net - -namespace TmwAthena -{ - namespace TradeRecv - { - void processTradeRequest(Net::MessageIn &msg); - void processTradeItemAdd(Net::MessageIn &msg); - void processTradeItemAddResponse(Net::MessageIn &msg); - void processTradeResponse(Net::MessageIn &msg); - } // namespace TradeRecv -} // namespace TmwAthena - -#endif // NET_TMWA_TRADERECV_H diff --git a/src/net/tmwa/updateprotocol.cpp b/src/net/tmwa/updateprotocol.cpp deleted file mode 100644 index 3928cc101..000000000 --- a/src/net/tmwa/updateprotocol.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2015-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/updateprotocol.h" - -#include "net/tmwa/network.h" -#include "net/tmwa/protocolout.h" - -#include "debug.h" - -namespace TmwAthena -{ - -void updateProtocol() -{ -#define PACKETS_UPDATE -#include "net/protocoloutupdate.h" -#include "net/tmwa/packetsout.inc" -#undef packet - Network *const network = Network::mInstance; - if (network != nullptr) - { - network->clearHandlers(); - network->registerHandlers(); - } -} - -PACKETSOUT_VOID -PROTOCOLOUTUPDATE_VOID -PROTOCOLOUT_VOID - -} // namespace TmwAthena diff --git a/src/net/tmwa/updateprotocol.h b/src/net/tmwa/updateprotocol.h deleted file mode 100644 index f460f2c7c..000000000 --- a/src/net/tmwa/updateprotocol.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2015-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_UPDATEPROTOCOL_H -#define NET_TMWA_UPDATEPROTOCOL_H - -namespace TmwAthena -{ - void updateProtocol(); -} // namespace TmwAthena - -#endif // NET_TMWA_UPDATEPROTOCOL_H diff --git a/src/net/tmwa/vendinghandler.cpp b/src/net/tmwa/vendinghandler.cpp deleted file mode 100644 index 30237cb0e..000000000 --- a/src/net/tmwa/vendinghandler.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#include "net/tmwa/vendinghandler.h" - -#include "debug.h" - -namespace TmwAthena -{ - -VendingHandler::VendingHandler() -{ - vendingHandler = this; -} - -VendingHandler::~VendingHandler() -{ - vendingHandler = nullptr; -} - -void VendingHandler::close() const -{ -} - -void VendingHandler::open(const Being *const being A_UNUSED) const -{ -} - -void VendingHandler::buy(const Being *const being A_UNUSED, - const int index A_UNUSED, - const int amount A_UNUSED) const -{ -} - -void VendingHandler::buyItems(const Being *const being A_UNUSED, - const STD_VECTOR<ShopItem*> &items A_UNUSED) - const -{ -} - -void VendingHandler::buy2(const Being *const being A_UNUSED, - const int vendId A_UNUSED, - const int index A_UNUSED, - const int amount A_UNUSED) const -{ -} - -void VendingHandler::createShop(const std::string &name A_UNUSED, - const bool flag A_UNUSED, - const STD_VECTOR<ShopItem*> &items A_UNUSED) - const -{ -} - -} // namespace TmwAthena diff --git a/src/net/tmwa/vendinghandler.h b/src/net/tmwa/vendinghandler.h deleted file mode 100644 index 3af4a110b..000000000 --- a/src/net/tmwa/vendinghandler.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef NET_TMWA_VENDINGHANDLER_H -#define NET_TMWA_VENDINGHANDLER_H - -#include "net/vendinghandler.h" - -namespace TmwAthena -{ - -class VendingHandler final : public Net::VendingHandler -{ - public: - VendingHandler(); - - A_DELETE_COPY(VendingHandler) - - ~VendingHandler(); - - void close() const override final A_CONST; - - void open(const Being *const being) const override final A_CONST; - - void buy(const Being *const being, - const int index, - const int amount) const override final A_CONST; - - void buyItems(const Being *const being, - const STD_VECTOR<ShopItem*> &items) const - override final A_CONST; - - void buy2(const Being *const being, - const int vendId, - const int index, - const int amount) const override final A_CONST; - - void createShop(const std::string &name, - const bool flag, - const STD_VECTOR<ShopItem*> &items) const - override final A_CONST; -}; - -} // namespace TmwAthena - -#endif // NET_TMWA_VENDINGHANDLER_H |