diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-10-10 22:14:45 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-10-10 22:15:57 +0300 |
commit | aa3f63fd497558a02feb3ddbc44f31eac091f39b (patch) | |
tree | 0e28b9b1f0501dd8be9e1a38db4ec1777fa3fbfa /src/net/ea | |
parent | 7c10a6b61e9d06a4ae9cc9f942dfacb6fcfd9d3d (diff) | |
download | plus-aa3f63fd497558a02feb3ddbc44f31eac091f39b.tar.gz plus-aa3f63fd497558a02feb3ddbc44f31eac091f39b.tar.bz2 plus-aa3f63fd497558a02feb3ddbc44f31eac091f39b.tar.xz plus-aa3f63fd497558a02feb3ddbc44f31eac091f39b.zip |
Remove most unused files.
Diffstat (limited to 'src/net/ea')
64 files changed, 0 insertions, 5810 deletions
diff --git a/src/net/ea/adminhandler.cpp b/src/net/ea/adminhandler.cpp deleted file mode 100644 index 4188fc803..000000000 --- a/src/net/ea/adminhandler.cpp +++ /dev/null @@ -1,76 +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/ea/adminhandler.h" - -#include "utils/gmfunctions.h" -#include "utils/stringutils.h" - -#include "debug.h" - -namespace Ea -{ - -void AdminHandler::kickName(const std::string &name) const -{ - Gm::runCommand("kick", name); -} - -void AdminHandler::ban(const int playerId A_UNUSED) const -{ - // Not supported -} - -void AdminHandler::banName(const std::string &name) const -{ - Gm::runCommand("ban", name); -} - -void AdminHandler::unban(const int playerId A_UNUSED) const -{ - // Not supported -} - -void AdminHandler::unbanName(const std::string &name) const -{ - Gm::runCommand("unban", name); -} - -void AdminHandler::ipcheckName(const std::string &name) const -{ - Gm::runCommand("ipcheck", name); -} - -void AdminHandler::createItems(const int id, - const ItemColor color A_UNUSED, - const int amount) const -{ - Gm::runCommand("item", - strprintf("%d %d", id, amount)); -} - -void AdminHandler::spawn(const std::string &name) const -{ - Gm::runCommand("spawn", name); -} - -} // namespace Ea diff --git a/src/net/ea/adminhandler.h b/src/net/ea/adminhandler.h deleted file mode 100644 index f300fda55..000000000 --- a/src/net/ea/adminhandler.h +++ /dev/null @@ -1,65 +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_EA_ADMINHANDLER_H -#define NET_EA_ADMINHANDLER_H - -#include "net/adminhandler.h" - -#include "localconsts.h" - -namespace Ea -{ - -class AdminHandler notfinal : public Net::AdminHandler -{ - public: - AdminHandler() - { } - - A_DELETE_COPY(AdminHandler) - - virtual ~AdminHandler() - { } - - void kickName(const std::string &name) const override final; - - void ban(const int playerId) const override final A_CONST; - - void banName(const std::string &name) const override final; - - void unban(const int playerId) const override final A_CONST; - - void unbanName(const std::string &name) const override final; - - void ipcheckName(const std::string &name) const override final; - - void createItems(const int id, - const ItemColor color, - const int amount) const override final; - - void spawn(const std::string &name) const override final; -}; - -} // namespace Ea - -#endif // NET_EA_ADMINHANDLER_H diff --git a/src/net/ea/adminrecv.cpp b/src/net/ea/adminrecv.cpp deleted file mode 100644 index a083ed78d..000000000 --- a/src/net/ea/adminrecv.cpp +++ /dev/null @@ -1,44 +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/ea/adminrecv.h" - -#include "notifymanager.h" - -#include "enums/resources/notifytypes.h" - -#include "net/messagein.h" - -#include "debug.h" - -namespace Ea -{ - -void AdminRecv::processKickAck(Net::MessageIn &msg) -{ - if (msg.readInt32("flag") == 0) - NotifyManager::notify(NotifyTypes::KICK_FAIL); - else - NotifyManager::notify(NotifyTypes::KICK_SUCCEED); -} - -} // namespace Ea diff --git a/src/net/ea/adminrecv.h b/src/net/ea/adminrecv.h deleted file mode 100644 index 71451aa21..000000000 --- a/src/net/ea/adminrecv.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_EA_ADMINRECV_H -#define NET_EA_ADMINRECV_H - -#include "localconsts.h" - -namespace Net -{ - class MessageIn; -} // namespace Net - -namespace Ea -{ - namespace AdminRecv - { - void processKickAck(Net::MessageIn &msg); - } // namespace AdminRecv -} // namespace Ea - -#endif // NET_EA_ADMINRECV_H diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp deleted file mode 100644 index 4f62175c3..000000000 --- a/src/net/ea/beinghandler.cpp +++ /dev/null @@ -1,39 +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/ea/beinghandler.h" - -#include "net/ea/beingrecv.h" - -#include "debug.h" - -namespace Ea -{ - -BeingHandler::BeingHandler(const bool enableSync) : - Net::BeingHandler() -{ - BeingRecv::mSync = enableSync; - BeingRecv::mSpawnId = BeingId_zero; -} - -} // namespace Ea diff --git a/src/net/ea/beinghandler.h b/src/net/ea/beinghandler.h deleted file mode 100644 index 625077855..000000000 --- a/src/net/ea/beinghandler.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_EA_BEINGHANDLER_H -#define NET_EA_BEINGHANDLER_H - -#include "net/beinghandler.h" - -namespace Ea -{ - -class BeingHandler notfinal : public Net::BeingHandler -{ - public: - A_DELETE_COPY(BeingHandler) - - protected: - explicit BeingHandler(const bool enableSync); -}; - -} // namespace Ea - -#endif // NET_EA_BEINGHANDLER_H diff --git a/src/net/ea/beingrecv.cpp b/src/net/ea/beingrecv.cpp deleted file mode 100644 index b2859d76f..000000000 --- a/src/net/ea/beingrecv.cpp +++ /dev/null @@ -1,520 +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/ea/beingrecv.h" - -#include "actormanager.h" -#include "configuration.h" -#include "game.h" -#include "notifymanager.h" -#include "party.h" - -#include "being/localplayer.h" -#include "being/playerrelation.h" -#include "being/playerrelations.h" - -#include "enums/resources/notifytypes.h" - -#include "enums/resources/map/mapitemtype.h" - -#include "gui/viewport.h" - -#include "gui/windows/socialwindow.h" - -#include "utils/foreach.h" - -#include "resources/map/map.h" - -#include "net/messagein.h" -#include "net/serverfeatures.h" - -#include "debug.h" - -namespace Ea -{ - -namespace BeingRecv -{ - bool mSync = false; - BeingId mSpawnId = BeingId_zero; -} // namespace BeingRecv - -void BeingRecv::processBeingRemove(Net::MessageIn &msg) -{ - BLOCK_START("BeingRecv::processBeingRemove") - if ((actorManager == nullptr) || (localPlayer == nullptr)) - { - BLOCK_END("BeingRecv::processBeingRemove") - return; - } - - // A being should be removed or has died - - const BeingId id = msg.readBeingId("being id"); - const uint8_t type = msg.readUInt8("remove flag"); - Being *const dstBeing = actorManager->findBeing(id); - if (dstBeing == nullptr) - { - BLOCK_END("BeingRecv::processBeingRemove") - return; - } - - localPlayer->followMoveTo(dstBeing, localPlayer->getNextDestX(), - localPlayer->getNextDestY()); - - // If this is player's current target, clear it. - if (dstBeing == localPlayer->getTarget()) - localPlayer->stopAttack(true); - - if (type == 1U) - { - if (dstBeing->getCurrentAction() != BeingAction::DEAD) - { - dstBeing->setAction(BeingAction::DEAD, 0); - dstBeing->recalcSpritesOrder(); - } - } - else if (type == 0U && dstBeing->getType() == ActorType::Npc) - { - const BeingInfo *const info = dstBeing->getInfo(); - if ((info == nullptr) || (info->getAllowDelete() != 0)) - actorManager->destroy(dstBeing); - } - else - { - if (dstBeing->getType() == ActorType::Player) - { - if (socialWindow != nullptr) - socialWindow->updateActiveList(); - const std::string name = dstBeing->getName(); - if (!name.empty() && config.getBoolValue("logPlayerActions")) - { - switch (type) - { - case 0: - dstBeing->serverRemove(); - break; - case 1: - NotifyManager::notify( - NotifyTypes::BEING_REMOVE_DIED, - name); - break; - case 2: - NotifyManager::notify( - NotifyTypes::BEING_REMOVE_LOGGED_OUT, - name); - break; - case 3: - NotifyManager::notify( - NotifyTypes::BEING_REMOVE_WARPED, - name); - break; - case 4: - NotifyManager::notify( - NotifyTypes::BEING_REMOVE_TRICK_DEAD, - name); - break; - default: - NotifyManager::notify( - NotifyTypes::BEING_REMOVE_UNKNOWN, - name); - break; - } - } - } - actorManager->destroy(dstBeing); - } - BLOCK_END("BeingRecv::processBeingRemove") -} - -void BeingRecv::processBeingAction(Net::MessageIn &msg) -{ - BLOCK_START("BeingRecv::processBeingAction") - if (actorManager == nullptr) - { - BLOCK_END("BeingRecv::processBeingAction") - return; - } - - Being *const srcBeing = actorManager->findBeing( - msg.readBeingId("src being id")); - Being *const dstBeing = actorManager->findBeing( - msg.readBeingId("dst being id")); - - msg.readInt32("tick"); - const int srcSpeed = msg.readInt32("src speed"); - msg.readInt32("dst speed"); - const int param1 = msg.readInt16("param1"); - msg.readInt16("param 2"); - const AttackTypeT type = static_cast<AttackTypeT>( - msg.readUInt8("type")); - msg.readInt16("param 3"); - - switch (type) - { - case AttackType::HIT: // Damage - case AttackType::CRITICAL: // Critical Damage - case AttackType::MULTI: // Critical Damage - case AttackType::REFLECT: // Reflected Damage - case AttackType::FLEE: // Lucky Dodge - if (srcBeing != nullptr) - { - if (srcSpeed != 0 && srcBeing->getType() == ActorType::Player) - srcBeing->setAttackDelay(srcSpeed); - // attackid=1, type - srcBeing->handleAttack(dstBeing, param1, 1); - if (srcBeing->getType() == ActorType::Player) - srcBeing->setAttackTime(); - } - if (dstBeing != nullptr) - { - // level not present, using 1 - dstBeing->takeDamage(srcBeing, param1, - static_cast<AttackTypeT>(type), 1); - } - break; - - case AttackType::PICKUP: - break; - // tmw server can send here garbage? -// if (srcBeing) -// srcBeing->setAction(BeingAction::DEAD, 0); - - case AttackType::SIT: - if (srcBeing != nullptr) - { - srcBeing->setAction(BeingAction::SIT, 0); - if (srcBeing->getType() == ActorType::Player) - { - srcBeing->setMoveTime(); - if (localPlayer != nullptr) - localPlayer->imitateAction(srcBeing, BeingAction::SIT); - } - } - break; - - case AttackType::STAND: - if (srcBeing != nullptr) - { - srcBeing->setAction(BeingAction::STAND, 0); - if (srcBeing->getType() == ActorType::Player) - { - srcBeing->setMoveTime(); - if (localPlayer != nullptr) - { - localPlayer->imitateAction(srcBeing, - BeingAction::STAND); - } - } - } - break; - default: - case AttackType::SPLASH: - case AttackType::SKILL: - case AttackType::REPEATE: - case AttackType::MULTI_REFLECT: - case AttackType::TOUCH_SKILL: - case AttackType::MISS: - case AttackType::SKILLMISS: - UNIMPLEMENTEDPACKETFIELD(CAST_S32(type)); - break; - } - BLOCK_END("BeingRecv::processBeingAction") -} - -void BeingRecv::processBeingEmotion(Net::MessageIn &msg) -{ - BLOCK_START("BeingRecv::processBeingEmotion") - if ((localPlayer == nullptr) || (actorManager == nullptr)) - { - BLOCK_END("BeingRecv::processBeingEmotion") - return; - } - - Being *const dstBeing = actorManager->findBeing( - msg.readBeingId("being id")); - if (dstBeing == nullptr) - { - DEBUGLOGSTR("invisible player?"); - msg.readUInt8("emote"); - BLOCK_END("BeingRecv::processBeingEmotion") - return; - } - - const uint8_t emote = msg.readUInt8("emote"); - if ((emote != 0u) && - playerRelations.hasPermission(dstBeing, PlayerRelation::EMOTE)) - { - dstBeing->setEmote(emote, 0); - localPlayer->imitateEmote(dstBeing, emote); - } - if (dstBeing->getType() == ActorType::Player) - dstBeing->setOtherTime(); - BLOCK_END("BeingRecv::processBeingEmotion") -} - -void BeingRecv::processNameResponse(Net::MessageIn &msg) -{ - BLOCK_START("BeingRecv::processNameResponse") - if ((localPlayer == nullptr) || (actorManager == nullptr)) - { - BLOCK_END("BeingRecv::processNameResponse") - return; - } - - const BeingId beingId = msg.readBeingId("being id"); - const std::string name = msg.readString(24, "name"); - Being *const dstBeing = actorManager->findBeing(beingId); - - actorManager->updateNameId(name, beingId); - - if (dstBeing != nullptr) - { - if (beingId == localPlayer->getId()) - { - localPlayer->pingResponse(); - } - else - { - if (dstBeing->getType() != ActorType::Portal) - { - dstBeing->setName(name); - } - else if (viewport != nullptr) - { - Map *const map = viewport->getMap(); - if (map != nullptr) - { - map->addPortalTile(name, MapItemType::PORTAL, - dstBeing->getTileX(), dstBeing->getTileY()); - } - } - dstBeing->updateGuild(); - dstBeing->addToCache(); - - if (dstBeing->getType() == ActorType::Player) - dstBeing->updateColors(); - - if (localPlayer != nullptr) - { - const Party *const party = localPlayer->getParty(); - if (party != nullptr && party->isMember(dstBeing->getId())) - { - PartyMember *const member = party->getMember( - dstBeing->getId()); - - if (member != nullptr) - member->setName(dstBeing->getName()); - } - localPlayer->checkNewName(dstBeing); - } - BLOCK_END("BeingRecv::processNameResponse") - return; - } - } - BLOCK_END("BeingRecv::processNameResponse") -} - -void BeingRecv::processPlayerStop(Net::MessageIn &msg) -{ - BLOCK_START("BeingRecv::processPlayerStop") - if ((actorManager == nullptr) || (localPlayer == nullptr)) - { - BLOCK_END("BeingRecv::processPlayerStop") - return; - } - - const BeingId id = msg.readBeingId("account id"); - - if (mSync || id != localPlayer->getId()) - { - Being *const dstBeing = actorManager->findBeing(id); - if (dstBeing != nullptr) - { - const uint16_t x = msg.readInt16("x"); - const uint16_t y = msg.readInt16("y"); - dstBeing->setTileCoords(x, y); - if (dstBeing->getCurrentAction() == BeingAction::MOVE) - dstBeing->setAction(BeingAction::STAND, 0); - BLOCK_END("BeingRecv::processPlayerStop") - return; - } - } - msg.readInt16("x"); - msg.readInt16("y"); - BLOCK_END("BeingRecv::processPlayerStop") -} - -void BeingRecv::processPlayerMoveToAttack(Net::MessageIn &msg) -{ - BLOCK_START("BeingRecv::processPlayerStop") - msg.readInt32("target id"); - msg.readInt16("target x"); - msg.readInt16("target y"); - msg.readInt16("x"); - msg.readInt16("y"); - msg.readInt16("attack range"); - - if (localPlayer != nullptr) - localPlayer->fixAttackTarget(); - BLOCK_END("BeingRecv::processPlayerStop") -} - -void BeingRecv::processSkillNoDamage(Net::MessageIn &msg) -{ - const int id = msg.readInt16("skill id"); - int heal; - if (msg.getVersion() >= 20131223) - heal = msg.readInt32("heal"); - else - heal = msg.readInt16("heal"); - Being *const dstBeing = actorManager->findBeing( - msg.readBeingId("dst being id")); - Being *const srcBeing = actorManager->findBeing( - msg.readBeingId("src being id")); - msg.readUInt8("fail"); - - if (srcBeing != nullptr) - srcBeing->handleSkill(dstBeing, heal, id, 1); -} - -void BeingRecv::processPvpMapMode(Net::MessageIn &msg) -{ - BLOCK_START("BeingRecv::processPvpMapMode") - const Game *const game = Game::instance(); - if (game == nullptr) - { - BLOCK_END("BeingRecv::processPvpMapMode") - return; - } - - Map *const map = game->getCurrentMap(); - if (map != nullptr) - map->setPvpMode(msg.readInt16("pvp mode")); - BLOCK_END("BeingRecv::processPvpMapMode") -} - -void BeingRecv::processBeingMove3(Net::MessageIn &msg) -{ - BLOCK_START("BeingRecv::processBeingMove3") - if ((actorManager == nullptr) || !serverFeatures->haveMove3()) - { - BLOCK_END("BeingRecv::processBeingMove3") - return; - } - - static const int16_t dirx[8] = {0, -1, -1, -1, 0, 1, 1, 1}; - static const int16_t diry[8] = {1, 1, 0, -1, -1, -1, 0, 1}; - - const int len = msg.readInt16("len") - 14; - Being *const dstBeing = actorManager->findBeing( - msg.readBeingId("being id")); - if (dstBeing == nullptr || - dstBeing == localPlayer) - { - DEBUGLOGSTR("invisible player?"); - msg.readInt16("speed"); - msg.readInt16("x"); - msg.readInt16("y"); - unsigned char *bytes = msg.readBytes(len, "moving path"); - delete [] bytes; - BLOCK_END("BeingRecv::processBeingMove3") - return; - } - const int16_t speed = msg.readInt16("speed"); - dstBeing->setWalkSpeed(speed); - const int16_t x = msg.readInt16("x"); - const int16_t y = msg.readInt16("y"); - const unsigned char *moves = msg.readBytes(len, "moving path"); - - Path path; - if (moves != nullptr) - { - int x2 = dstBeing->getCachedX(); - int y2 = dstBeing->getCachedY(); - Path path2; - path2.push_back(Position(x2, y2)); - for (int f = len - 1; f >= 0; f --) - { - const unsigned char dir = moves[f]; - if (dir <= 7) - { - x2 -= dirx[dir]; - y2 -= diry[dir]; - path2.push_back(Position(x2, y2)); - if (x2 == x && y2 == y) - break; - } - else - { - logger->log("bad move packet: %d", dir); - } - } - - if (!path2.empty()) - { - const Position &pos = path2.back(); - if (x != pos.x || - y != pos.y) - { - dstBeing->setTileCoords(pos.x, pos.y); - } - } - - path2.pop_back(); - FOR_EACHR (PathRIterator, it, path2) - { - path.push_back(*it); - } - delete [] moves; - } - - if (path.empty()) - return; - - dstBeing->setAction(BeingAction::STAND, 0); - dstBeing->setTileCoords(x, y); - dstBeing->setPath(path); - BLOCK_END("BeingRecv::processBeingMove3") -} - -Being *BeingRecv::createBeing(const BeingId id, - const int job) -{ - if (actorManager == nullptr) - return nullptr; - - ActorTypeT type = ActorType::Unknown; - if (job <= 25 || (job >= 4001 && job <= 4049)) - type = ActorType::Player; - else if (job >= 46 && job <= 1000) - type = ActorType::Npc; - else if (job > 1000 && job <= 2000) - type = ActorType::Monster; - else if (job == 45) - type = ActorType::Portal; - - return actorManager->createBeing( - id, type, fromInt(job, BeingTypeId)); -} - -} // namespace Ea diff --git a/src/net/ea/beingrecv.h b/src/net/ea/beingrecv.h deleted file mode 100644 index 878d53fb6..000000000 --- a/src/net/ea/beingrecv.h +++ /dev/null @@ -1,56 +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_EA_BEINGRECV_H -#define NET_EA_BEINGRECV_H - -#include "enums/simpletypes/beingid.h" - -namespace Net -{ - class MessageIn; -} // namespace Net - -class Being; - -namespace Ea -{ - namespace BeingRecv - { - extern bool mSync; - extern BeingId mSpawnId; - - void processBeingRemove(Net::MessageIn &msg); - void processBeingAction(Net::MessageIn &msg); - void processBeingEmotion(Net::MessageIn &msg); - void processNameResponse(Net::MessageIn &msg); - void processPlayerStop(Net::MessageIn &msg); - void processPlayerMoveToAttack(Net::MessageIn &msg); - void processSkillNoDamage(Net::MessageIn &msg); - void processPvpMapMode(Net::MessageIn &msg); - void processBeingMove3(Net::MessageIn &msg); - Being *createBeing(const BeingId id, - const int job); - } // namespace BeingRecv -} // namespace Ea - -#endif // NET_EA_BEINGRECV_H diff --git a/src/net/ea/buysellhandler.cpp b/src/net/ea/buysellhandler.cpp deleted file mode 100644 index 21769cef4..000000000 --- a/src/net/ea/buysellhandler.cpp +++ /dev/null @@ -1,44 +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/ea/buysellhandler.h" - -#include "net/ea/buysellrecv.h" - -#include "debug.h" - -namespace Ea -{ - -BuySellHandler::BuySellHandler() -{ - BuySellRecv::mNpcId = BeingId_zero; - BuySellRecv::mBuyDialog = nullptr; -} - -void BuySellHandler::cleanDialogReference(const BuyDialog *const dialog) const -{ - if (BuySellRecv::mBuyDialog == dialog) - BuySellRecv::mBuyDialog = nullptr; -} - -} // namespace Ea diff --git a/src/net/ea/buysellhandler.h b/src/net/ea/buysellhandler.h deleted file mode 100644 index 2c5e1caad..000000000 --- a/src/net/ea/buysellhandler.h +++ /dev/null @@ -1,44 +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_EA_BUYSELLHANDLER_H -#define NET_EA_BUYSELLHANDLER_H - -#include "net/buysellhandler.h" - -namespace Ea -{ - -class BuySellHandler notfinal : public Net::BuySellHandler -{ - public: - BuySellHandler(); - - A_DELETE_COPY(BuySellHandler) - - void cleanDialogReference(const BuyDialog *const dialog) const - override final; -}; - -} // namespace Ea - -#endif // NET_EA_BUYSELLHANDLER_H diff --git a/src/net/ea/buysellrecv.cpp b/src/net/ea/buysellrecv.cpp deleted file mode 100644 index 95f69129f..000000000 --- a/src/net/ea/buysellrecv.cpp +++ /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/>. - */ - -#include "net/ea/buysellrecv.h" - -#include "notifymanager.h" - -#include "being/playerinfo.h" - -#include "const/net/inventory.h" - -#include "enums/resources/notifytypes.h" - -#include "gui/windows/buyselldialog.h" -#include "gui/windows/npcselldialog.h" - -#include "gui/widgets/createwidget.h" - -#include "net/messagein.h" - -#include "resources/inventory/inventory.h" - -#include "resources/item/item.h" - -#include "debug.h" - -namespace Ea -{ - -namespace BuySellRecv -{ - BeingId mNpcId = BeingId_zero; - BuyDialog *mBuyDialog = nullptr; -} // namespace BuySellRecv - -void BuySellRecv::processNpcBuySellChoice(Net::MessageIn &msg) -{ - if (!BuySellDialog::isActive()) - { - mNpcId = msg.readBeingId("npc id"); - CREATEWIDGET(BuySellDialog, mNpcId); - } -} - -void BuySellRecv::processNpcSell(Net::MessageIn &msg) -{ - msg.readInt16("len"); - const int n_items = (msg.getLength() - 4) / 10; - if (n_items > 0) - { - SellDialog *const dialog = CREATEWIDGETR(NpcSellDialog, mNpcId); - dialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY)); - - for (int k = 0; k < n_items; k++) - { - const int index = msg.readInt16("index") - INVENTORY_OFFSET; - const int value = msg.readInt32("value"); - msg.readInt32("value?"); - - const Item *const item = PlayerInfo::getInventory() - ->getItem(index); - - if ((item != nullptr) && item->isEquipped() == Equipped_false) - dialog->addItem(item, value); - } - } - else - { - NotifyManager::notify(NotifyTypes::SELL_LIST_EMPTY); - } -} - -} // namespace Ea diff --git a/src/net/ea/buysellrecv.h b/src/net/ea/buysellrecv.h deleted file mode 100644 index 7d70044fe..000000000 --- a/src/net/ea/buysellrecv.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_EA_BUYSELLRECV_H -#define NET_EA_BUYSELLRECV_H - -#include "enums/simpletypes/beingid.h" - -namespace Net -{ - class MessageIn; -} // namespace Net - -class BuyDialog; - -namespace Ea -{ - namespace BuySellRecv - { - extern BeingId mNpcId; - extern BuyDialog *mBuyDialog; - - void processNpcBuySellChoice(Net::MessageIn &msg); - void processNpcSell(Net::MessageIn &msg); - } // namespace BuySellRecv -} // namespace Ea - -#endif // NET_EA_BUYSELLRECV_H diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp deleted file mode 100644 index ae8da9e4a..000000000 --- a/src/net/ea/charserverhandler.cpp +++ /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/>. - */ - -#include "net/ea/charserverhandler.h" - -#include "net/character.h" -#include "net/serverinfo.h" - -#include "net/ea/eaprotocol.h" - -#include "utils/dtor.h" - -#include "debug.h" - -namespace Ea -{ - -extern ServerInfo mapServer; - -CharServerHandler::CharServerHandler() : - Net::CharServerHandler() -{ -} - -CharServerHandler::~CharServerHandler() -{ - clear(); -} - -void CharServerHandler::setCharSelectDialog(CharSelectDialog *const window) - const -{ - mCharSelectDialog = window; - updateCharSelectDialog(); -} - -void CharServerHandler::requestCharacters() const -{ - connect(); -} - -unsigned int CharServerHandler::baseSprite() const -{ - return EA_SPRITE_BASE; -} - -unsigned int CharServerHandler::hairSprite() const -{ - return EA_SPRITE_HAIR_COLOR; -} - -unsigned int CharServerHandler::maxSprite() const -{ - return EA_SPRITE_VECTOREND; -} - -void CharServerHandler::clear() const -{ - delete_all(mCharacters); - mCharacters.clear(); -} - -} // namespace Ea diff --git a/src/net/ea/charserverhandler.h b/src/net/ea/charserverhandler.h deleted file mode 100644 index 1faa59403..000000000 --- a/src/net/ea/charserverhandler.h +++ /dev/null @@ -1,62 +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_EA_CHARSERVERHANDLER_H -#define NET_EA_CHARSERVERHANDLER_H - -#include "net/charserverhandler.h" - -namespace Ea -{ - -/** - * Deals with incoming messages from the character server. - */ -class CharServerHandler notfinal : public Net::CharServerHandler -{ - public: - A_DELETE_COPY(CharServerHandler) - - ~CharServerHandler(); - - void setCharSelectDialog(CharSelectDialog *const window) const - override final; - - void requestCharacters() const override final; - - unsigned int baseSprite() const override final A_CONST A_WARN_UNUSED; - - unsigned int hairSprite() const override final A_CONST A_WARN_UNUSED; - - unsigned int maxSprite() const override final A_CONST A_WARN_UNUSED; - - virtual void connect() const = 0; - - void clear() const override final; - - protected: - CharServerHandler(); -}; - -} // namespace Ea - -#endif // NET_EA_CHARSERVERHANDLER_H diff --git a/src/net/ea/charserverrecv.cpp b/src/net/ea/charserverrecv.cpp deleted file mode 100644 index d058dfe6d..000000000 --- a/src/net/ea/charserverrecv.cpp +++ /dev/null @@ -1,143 +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/ea/charserverrecv.h" - -#include "client.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 "utils/gettext.h" - -#include "debug.h" - -namespace Ea -{ - -void CharServerRecv::processCharLoginError(Net::MessageIn &msg) -{ - BLOCK_START("CharServerRecv::processCharLoginError") - switch (msg.readUInt8("error")) - { - case 0: - // TRANSLATORS: error message - errorMessage = _("Access denied. Most likely, there are " - "too many players on this server."); - break; - case 1: - // TRANSLATORS: error message - errorMessage = _("Cannot use this ID."); - break; - default: - // TRANSLATORS: error message - errorMessage = _("Unknown char-server failure."); - break; - } - client->setState(State::ERROR); - BLOCK_END("CharServerRecv::processCharLoginError") -} - -void CharServerRecv::processCharCreateFailed(Net::MessageIn &msg) -{ - BLOCK_START("CharServerRecv::processCharCreateFailed") - switch (msg.readUInt8("error")) - { - case 1: - case 0: - default: - // TRANSLATORS: error message - errorMessage = _("Failed to create character. Most " - "likely the name is already taken."); - break; - case 2: - // TRANSLATORS: error message - errorMessage = _("Wrong name."); - break; - case 3: - // TRANSLATORS: error message - errorMessage = _("Incorrect stats."); - break; - case 4: - // TRANSLATORS: error message - errorMessage = _("Incorrect hair."); - break; - case 5: - // TRANSLATORS: error message - errorMessage = _("Incorrect slot."); - break; - case 6: - // TRANSLATORS: error message - errorMessage = _("Incorrect race."); - break; - case 7: - // TRANSLATORS: error message - errorMessage = _("Incorrect look."); - break; - } - CREATEWIDGET(OkDialog, - // TRANSLATORS: error message header - _("Error"), - errorMessage, - // TRANSLATORS: ok dialog button - _("OK"), - DialogType::ERROR, - Modal_true, - ShowCenter_true, - nullptr, - 260); - if (Net::CharServerHandler::mCharCreateDialog != nullptr) - Net::CharServerHandler::mCharCreateDialog->unlock(); - BLOCK_END("CharServerRecv::processCharCreateFailed") -} - -void CharServerRecv::processCharDelete(Net::MessageIn &msg A_UNUSED) -{ - BLOCK_START("CharServerRecv::processCharDelete") - delete Net::CharServerHandler::mSelectedCharacter; - Net::CharServerHandler::mCharacters.remove( - Net::CharServerHandler::mSelectedCharacter); - Net::CharServerHandler::mSelectedCharacter = nullptr; - Net::CharServerHandler::updateCharSelectDialog(); - Net::CharServerHandler::unlockCharSelectDialog(); - CREATEWIDGET(OkDialog, - // TRANSLATORS: info message header - _("Info"), - // TRANSLATORS: info message - _("Character deleted."), - // TRANSLATORS: ok dialog button - _("OK"), - DialogType::OK, - Modal_true, - ShowCenter_true, - nullptr, - 260); - BLOCK_END("CharServerRecv::processCharDelete") -} - -} // namespace Ea diff --git a/src/net/ea/charserverrecv.h b/src/net/ea/charserverrecv.h deleted file mode 100644 index 5e105210c..000000000 --- a/src/net/ea/charserverrecv.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_EA_CHARSERVERRECV_H -#define NET_EA_CHARSERVERRECV_H - -namespace Net -{ - class MessageIn; -} // namespace Net - -namespace Ea -{ - namespace CharServerRecv - { - void processCharLoginError(Net::MessageIn &msg); - void processCharCreateFailed(Net::MessageIn &msg); - void processCharDelete(Net::MessageIn &msg); - } // namespace CharServerRecv -} // namespace Ea - -#endif // NET_EA_CHARSERVERRECV_H diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp deleted file mode 100644 index 8937852c6..000000000 --- a/src/net/ea/chathandler.cpp +++ /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/>. - */ - -#include "net/ea/chathandler.h" - -#include "configuration.h" - -#include "net/ea/chatrecv.h" - -#include "debug.h" - -namespace Ea -{ - -ChatHandler::ChatHandler() -{ - if (!ChatRecv::mSentWhispers.empty()) - ChatRecv::mSentWhispers.pop(); - ChatRecv::mMotdTime = 0; - ChatRecv::mShowAllLang = (serverConfig.getValue("showAllLang", 0) != 0); - ChatRecv::mShowMotd = config.getBoolValue("showmotd"); - ChatRecv::mSkipping = true; -} - -ChatHandler::~ChatHandler() -{ - clear(); -} - -void ChatHandler::clear() const -{ - ChatRecv::mShowMotd = config.getBoolValue("showmotd"); - ChatRecv::mSkipping = true; -} - -void ChatHandler::me(const std::string &restrict text, - const std::string &restrict channel) const -{ - // here need string duplication - std::string action = strprintf("*%s*", text.c_str()); - talk(action, channel); -} - -} // namespace Ea diff --git a/src/net/ea/chathandler.h b/src/net/ea/chathandler.h deleted file mode 100644 index b19105193..000000000 --- a/src/net/ea/chathandler.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_EA_CHATHANDLER_H -#define NET_EA_CHATHANDLER_H - -#include "net/chathandler.h" - -#include <queue> - -namespace Ea -{ - -typedef std::queue<std::string> WhisperQueue; - -class ChatHandler notfinal : public Net::ChatHandler -{ - public: - ChatHandler(); - - A_DELETE_COPY(ChatHandler) - - ~ChatHandler(); - - void me(const std::string &restrict text, - const std::string &restrict channel) const override final; - - void clear() const override final; -}; - -} // namespace Ea - -#endif // NET_EA_CHATHANDLER_H diff --git a/src/net/ea/chatrecv.cpp b/src/net/ea/chatrecv.cpp deleted file mode 100644 index 87db3fa98..000000000 --- a/src/net/ea/chatrecv.cpp +++ /dev/null @@ -1,192 +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/ea/chatrecv.h" - -#include "actormanager.h" -#include "configuration.h" -#include "notifymanager.h" - -#include "being/being.h" - -#include "enums/resources/notifytypes.h" - -#include "gui/windows/chatwindow.h" - -#include "gui/widgets/tabs/chat/chattab.h" - -#include "net/messagein.h" - -#include "utils/gettext.h" - -#include "debug.h" - -namespace Ea -{ - -namespace ChatRecv -{ - WhisperQueue mSentWhispers; - time_t mMotdTime = 0; - bool mShowAllLang = false; - bool mShowMotd = false; - bool mSkipping = true; -} // namespace ChatRecv - -std::string ChatRecv::getPopLastWhisperNick() -{ - std::string nick; - if (mSentWhispers.empty()) - { - nick = "user"; - } - else - { - nick = mSentWhispers.front(); - mSentWhispers.pop(); - } - return nick; -} - -std::string ChatRecv::getLastWhisperNick() -{ - std::string nick; - if (mSentWhispers.empty()) - nick = "user"; - else - nick = mSentWhispers.front(); - return nick; -} - -void ChatRecv::processWhisperResponseContinue(Net::MessageIn &msg, - const uint8_t type) -{ - const std::string nick = getPopLastWhisperNick(); - switch (type) - { - case 0x00: - // Success (don't need to report) - break; - case 0x01: - if (chatWindow != nullptr) - { - chatWindow->addWhisper(nick, - // TRANSLATORS: chat message - strprintf(_("Whisper could not be sent, %s is offline."), - nick.c_str()), - ChatMsgType::BY_SERVER); - } - break; - case 0x02: - if (chatWindow != nullptr) - { - chatWindow->addWhisper(nick, - // TRANSLATORS: chat message - strprintf(_("Whisper could not " - "be sent, ignored by %s."), nick.c_str()), - ChatMsgType::BY_SERVER); - } - break; - case 0x03: - if (chatWindow != nullptr) - { - chatWindow->addWhisper(nick, - // TRANSLATORS: chat message - _("Whisper could not " - "be sent, you ignored by all players."), - ChatMsgType::BY_SERVER); - } - break; - default: - UNIMPLEMENTEDPACKETFIELD(type); - break; - } - BLOCK_END("ChatRecv::processWhisperResponse") -} - -void ChatRecv::processMVPEffect(Net::MessageIn &msg) -{ - BLOCK_START("ChatRecv::processMVPEffect") - // Display MVP player - const BeingId id = msg.readBeingId("being id"); - if (localChatTab != nullptr && - actorManager != nullptr && - config.getBoolValue("showMVP")) - { - const Being *const being = actorManager->findBeing(id); - if (being == nullptr) - NotifyManager::notify(NotifyTypes::MVP_PLAYER, ""); - else - NotifyManager::notify(NotifyTypes::MVP_PLAYER, being->getName()); - } - BLOCK_END("ChatRecv::processMVPEffect") -} - -void ChatRecv::processIgnoreAllResponse(Net::MessageIn &msg) -{ - BLOCK_START("ChatRecv::processIgnoreAllResponse") - const uint8_t action = msg.readUInt8("action"); - const uint8_t fail = msg.readUInt8("result"); - if (localChatTab == nullptr) - { - BLOCK_END("ChatRecv::processIgnoreAllResponse") - return; - } - - switch (action) - { - case 0: - { - switch (fail) - { - case 0: - NotifyManager::notify(NotifyTypes::WHISPERS_IGNORED); - break; - default: - NotifyManager::notify(NotifyTypes:: - WHISPERS_IGNORE_FAILED); - break; - } - break; - } - case 1: - { - switch (fail) - { - case 0: - NotifyManager::notify(NotifyTypes::WHISPERS_UNIGNORED); - break; - default: - NotifyManager::notify(NotifyTypes:: - WHISPERS_UNIGNORE_FAILED); - break; - } - break; - } - default: - // unknown result - break; - } - BLOCK_END("ChatRecv::processIgnoreAllResponse") -} - -} // namespace Ea diff --git a/src/net/ea/chatrecv.h b/src/net/ea/chatrecv.h deleted file mode 100644 index 4a8427ea7..000000000 --- a/src/net/ea/chatrecv.h +++ /dev/null @@ -1,66 +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_EA_CHATRECV_H -#define NET_EA_CHATRECV_H - -#if defined(__GXX_EXPERIMENTAL_CXX0X__) -#if defined(__APPLE__) -#include <tr1/cstdint> -#endif // defined(__APPLE__) -#else // defined(__GXX_EXPERIMENTAL_CXX0X__) -#include <stdint.h> -#endif // defined(__GXX_EXPERIMENTAL_CXX0X__) - -#include <string> -#include <queue> -#ifndef __time_t_defined -#include <sys/time.h> -#endif // __time_t_defined - -namespace Net -{ - class MessageIn; -} // namespace Net - -namespace Ea -{ - typedef std::queue<std::string> WhisperQueue; - - namespace ChatRecv - { - void processMVPEffect(Net::MessageIn &msg); - void processIgnoreAllResponse(Net::MessageIn &msg); - void processWhisperResponseContinue(Net::MessageIn &msg, - const uint8_t type); - std::string getPopLastWhisperNick(); - std::string getLastWhisperNick(); - - extern WhisperQueue mSentWhispers; - extern time_t mMotdTime; - extern bool mShowAllLang; - extern bool mShowMotd; - extern bool mSkipping; - } // namespace ChatRecv -} // namespace Ea - -#endif // NET_EA_CHATRECV_H diff --git a/src/net/ea/eaprotocol.h b/src/net/ea/eaprotocol.h deleted file mode 100644 index 2a8831a24..000000000 --- a/src/net/ea/eaprotocol.h +++ /dev/null @@ -1,57 +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_EA_EAPROTOCOL_H -#define NET_EA_EAPROTOCOL_H - -enum -{ - EA_SPRITE_BASE = 0, - EA_SPRITE_HAIR = 1, - EA_SPRITE_WEAPON = 2, - EA_SPRITE_HEAD_BOTTOM = 3, - EA_SPRITE_HEAD_TOP = 4, - EA_SPRITE_HEAD_MID = 5, - EA_SPRITE_HAIR_COLOR = 6, - EA_SPRITE_CLOTHES_COLOR = 7, - EA_SPRITE_SHIELD = 8, - EA_SPRITE_SHOES = 9, - EA_SPRITE_BODY = 10, - EA_SPRITE_FLOOR = 11, - EA_SPRITE_ROBE = 12, - EA_SPRITE_EVOL2 = 13, - EA_SPRITE_EVOL3 = 14, - EA_SPRITE_EVOL4 = 15, - EA_SPRITE_EVOL5 = 16, - EA_SPRITE_EVOL6 = 17, - EA_SPRITE_EVOL7 = 18, - EA_SPRITE_EVOL8 = 19, - EA_SPRITE_EVOL9 = 20, - EA_SPRITE_EVOL10 = 21, - EA_SPRITE_EVOL11 = 22, - EA_SPRITE_EVOL12 = 23, - EA_SPRITE_EVOL13 = 24, - EA_SPRITE_EVOL14 = 25, - EA_SPRITE_VECTOREND -}; - -#endif // NET_EA_EAPROTOCOL_H diff --git a/src/net/ea/equipbackend.h b/src/net/ea/equipbackend.h deleted file mode 100644 index 15aeb93fb..000000000 --- a/src/net/ea/equipbackend.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_EA_EQUIPBACKEND_H -#define NET_EA_EQUIPBACKEND_H - -#include "resources/item/item.h" - -#include "being/playerinfo.h" - -#include "const/equipment.h" - -#include "gui/windows/inventorywindow.h" - -namespace Ea -{ - -class EquipBackend final : public Equipment::Backend -{ - public: - EquipBackend() - { - memset(mEquipment, -1, sizeof(mEquipment)); - } - - A_DELETE_COPY(EquipBackend) - - Item *getEquipment(const int index) const override final A_WARN_UNUSED - { - int invyIndex = mEquipment[index]; - if (invyIndex == -1) - return nullptr; - - const Inventory *const inv = PlayerInfo::getInventory(); - if (inv != nullptr) - return inv->getItem(invyIndex); - return nullptr; - } - - void clear() override final - { - Inventory *const inv = PlayerInfo::getInventory(); - if (inv == nullptr) - return; - for (int i = 0; i < EQUIPMENT_SIZE; i++) - { - if (mEquipment[i] != -1) - { - Item* item = inv->getItem(i); - if (item != nullptr) - item->setEquipped(Equipped_false); - } - - mEquipment[i] = -1; - } - } - - void setEquipment(const int index, const int inventoryIndex) - { - Inventory *const inv = PlayerInfo::getInventory(); - if (inv == nullptr) - return; - - if (index < 0 || index >= EQUIPMENT_SIZE) - return; - - // Unequip existing item - Item *item = inv->getItem(mEquipment[index]); - - if (item != nullptr) - item->setEquipped(Equipped_false); - - // not checking index because it must be safe - mEquipment[index] = inventoryIndex; - - item = inv->getItem(inventoryIndex); - if (item != nullptr) - item->setEquipped(Equipped_true); - - if (inventoryWindow != nullptr) - inventoryWindow->updateButtons(); - } - - private: - int mEquipment[EQUIPMENT_SIZE]; -}; - -} // namespace Ea - -#endif // NET_EA_EQUIPBACKEND_H diff --git a/src/net/ea/gamehandler.cpp b/src/net/ea/gamehandler.cpp deleted file mode 100644 index 3fe6a4e51..000000000 --- a/src/net/ea/gamehandler.cpp +++ /dev/null @@ -1,62 +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/ea/gamehandler.h" - -#include "game.h" - -#include "net/ea/gamerecv.h" - -#include "debug.h" - -namespace Ea -{ - -GameHandler::GameHandler() : - Net::GameHandler() -{ - GameRecv::mMap.clear(); - GameRecv::mCharID = BeingId_zero; -} - -void GameHandler::who() const -{ -} - -void GameHandler::setMap(const std::string &map) -{ - GameRecv::mMap = map.substr(0, map.rfind('.')); -} - -void GameHandler::clear() const -{ - GameRecv::mMap.clear(); - GameRecv::mCharID = BeingId_zero; -} - -void GameHandler::initEngines() const -{ - if (!GameRecv::mMap.empty()) - Game::instance()->changeMap(GameRecv::mMap); -} - -} // namespace Ea diff --git a/src/net/ea/gamehandler.h b/src/net/ea/gamehandler.h deleted file mode 100644 index b64d5cf25..000000000 --- a/src/net/ea/gamehandler.h +++ /dev/null @@ -1,52 +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_EA_GAMEHANDLER_H -#define NET_EA_GAMEHANDLER_H - -#include "net/gamehandler.h" - -namespace Ea -{ - -class GameHandler notfinal : public Net::GameHandler -{ - public: - GameHandler(); - - A_DELETE_COPY(GameHandler) - - void who() const override final A_CONST; - - bool removeDeadBeings() const override final A_WARN_UNUSED - { return true; } - - static void setMap(const std::string &map); - - void clear() const override final; - - void initEngines() const override final; -}; - -} // namespace Ea - -#endif // NET_EA_GAMEHANDLER_H diff --git a/src/net/ea/gamerecv.cpp b/src/net/ea/gamerecv.cpp deleted file mode 100644 index 230e3e012..000000000 --- a/src/net/ea/gamerecv.cpp +++ /dev/null @@ -1,80 +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/ea/gamerecv.h" - -#include "client.h" -#include "notifymanager.h" - -#include "enums/resources/notifytypes.h" - -#include "gui/windows/okdialog.h" - -#include "gui/widgets/createwidget.h" - -#include "net/messagein.h" - -#include "utils/gettext.h" - -#include "debug.h" - -namespace Ea -{ - -namespace GameRecv -{ - std::string mMap; - BeingId mCharID = BeingId_zero; -} // namespace GameRecv - -void GameRecv::processWhoAnswer(Net::MessageIn &msg) -{ - NotifyManager::notify(NotifyTypes::ONLINE_USERS, - msg.readInt32("users count")); -} - -void GameRecv::processCharSwitchResponse(Net::MessageIn &msg) -{ - if (msg.readUInt8("response") != 0u) - client->setState(State::SWITCH_CHARACTER); -} - -void GameRecv::processMapQuitResponse(Net::MessageIn &msg) -{ - if (msg.readInt16("response") != 0) - { - CREATEWIDGET(OkDialog, - // TRANSLATORS: error header - _("Game"), - // TRANSLATORS: error message - _("Request to quit denied!"), - // TRANSLATORS: ok dialog button - _("OK"), - DialogType::ERROR, - Modal_true, - ShowCenter_true, - nullptr, - 260); - } -} - -} // namespace Ea diff --git a/src/net/ea/gamerecv.h b/src/net/ea/gamerecv.h deleted file mode 100644 index f0c5d8f41..000000000 --- a/src/net/ea/gamerecv.h +++ /dev/null @@ -1,48 +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_EA_GAMERECV_H -#define NET_EA_GAMERECV_H - -#include "enums/simpletypes/beingid.h" - -#include <string> - -namespace Net -{ - class MessageIn; -} // namespace Net - -namespace Ea -{ - namespace GameRecv - { - extern std::string mMap; - extern BeingId mCharID; // < Saved for map-server switching - - void processWhoAnswer(Net::MessageIn &msg); - void processCharSwitchResponse(Net::MessageIn &msg); - void processMapQuitResponse(Net::MessageIn &msg); - } // namespace GameRecv -} // namespace Ea - -#endif // NET_EA_GAMERECV_H diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp deleted file mode 100644 index 1f816f7c1..000000000 --- a/src/net/ea/inventoryhandler.cpp +++ /dev/null @@ -1,128 +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/ea/inventoryhandler.h" - -#include "net/ea/equipbackend.h" -#include "net/ea/inventoryrecv.h" - -#include "utils/delete2.h" - -#include "debug.h" - -namespace Ea -{ - -InventoryHandler::InventoryHandler() : - Net::InventoryHandler() -{ - InventoryRecv::mEquips.clear(); - InventoryRecv::mInventoryItems.clear(); - InventoryRecv::mStorage = nullptr; - storageWindow = nullptr; - while (!InventoryRecv::mSentPickups.empty()) - InventoryRecv::mSentPickups.pop(); - InventoryRecv::mDebugInventory = true; -} - -InventoryHandler::~InventoryHandler() -{ - if (storageWindow != nullptr) - { - storageWindow->close(); - storageWindow = nullptr; - } - - delete2(InventoryRecv::mStorage); -} - -void InventoryHandler::clear() const -{ - delete2(InventoryRecv::mStorage); -} - -bool InventoryHandler::canSplit(const Item *const item A_UNUSED) const -{ - return false; -} - -void InventoryHandler::splitItem(const Item *const item A_UNUSED, - const int amount A_UNUSED) const -{ - // Not implemented for eAthena (possible?) -} - -void InventoryHandler::moveItem(const int oldIndex A_UNUSED, - const int newIndex A_UNUSED) const -{ - // Not implemented for eAthena (possible?) -} - -size_t InventoryHandler::getSize(const InventoryTypeT type) const -{ - switch (type) - { - case InventoryType::Inventory: - case InventoryType::MailEdit: - return 100; - case InventoryType::Storage: - return 0; // Comes from server after items - case InventoryType::Trade: - return 12; - case InventoryType::Npc: - case InventoryType::Cart: - case InventoryType::Vending: - case InventoryType::Craft: - case InventoryType::TypeEnd: - case InventoryType::MailView: - default: - return 0; - } -} -void InventoryHandler::destroyStorage() const -{ - BLOCK_START("InventoryHandler::closeStorage") - if (storageWindow != nullptr) - { - InventoryWindow *const inv = storageWindow; - storageWindow->close(); - inv->unsetInventory(); - } - BLOCK_END("InventoryHandler::closeStorage") -} - -void InventoryHandler::forgotStorage() const -{ - storageWindow = nullptr; -} - -void InventoryHandler::pushPickup(const BeingId floorId) -{ - InventoryRecv::mSentPickups.push(floorId); -} - -Inventory *InventoryHandler::getStorage() const -{ - return InventoryRecv::mStorage; -} - -} // namespace Ea diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h deleted file mode 100644 index f968a3216..000000000 --- a/src/net/ea/inventoryhandler.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_EA_INVENTORYHANDLER_H -#define NET_EA_INVENTORYHANDLER_H - -#include "localconsts.h" - -#include "net/inventoryhandler.h" - -#include <queue> - -namespace Ea -{ - -typedef std::queue<BeingId> PickupQueue; - -class InventoryHandler notfinal : public Net::InventoryHandler -{ - public: - A_DELETE_COPY(InventoryHandler) - - virtual ~InventoryHandler(); - - void clear() const override final; - - bool canSplit(const Item *const item) const - override final A_CONST A_WARN_UNUSED; - - void splitItem(const Item *const item, - const int amount) const override final A_CONST; - - void moveItem(const int oldIndex, - const int newIndex) const override final A_CONST; - - size_t getSize(const InventoryTypeT type) const override final - A_CONST A_WARN_UNUSED; - - static void pushPickup(const BeingId floorId); - - void destroyStorage() const override final; - - void forgotStorage() const override final; - - Inventory *getStorage() const override final; - - protected: - InventoryHandler(); -}; - -} // namespace Ea - -#endif // NET_EA_INVENTORYHANDLER_H diff --git a/src/net/ea/inventoryitem.h b/src/net/ea/inventoryitem.h deleted file mode 100644 index daf5cd65e..000000000 --- a/src/net/ea/inventoryitem.h +++ /dev/null @@ -1,125 +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_EA_INVENTORYITEM_H -#define NET_EA_INVENTORYITEM_H - -#include "const/resources/item/cards.h" - -#include "enums/resources/item/itemtype.h" - -#include "enums/simpletypes/damaged.h" -#include "enums/simpletypes/equipm.h" -#include "enums/simpletypes/favorite.h" -#include "enums/simpletypes/identified.h" -#include "enums/simpletypes/itemcolor.h" - -#include "utils/vector.h" - -#include "resources/item/itemoptionslist.h" - -#include "localconsts.h" - -namespace Ea -{ - -/** - * Used to cache storage data until we get size data for it. - */ -class InventoryItem final -{ - public: - int slot; - int id; - ItemTypeT type; - int cards[maxCards]; - ItemOptionsList *options; - int quantity; - uint8_t refine; - ItemColor color; - Identified identified; - Damaged damaged; - Favorite favorite; - Equipm equip; - - InventoryItem(const int slot0, - const int id0, - const ItemTypeT type0, - const int *const cards0, - ItemOptionsList *options0, - const int quantity0, - const uint8_t refine0, - const ItemColor color0, - const Identified identified0, - const Damaged damaged0, - const Favorite favorite0, - Equipm equip0) : - slot(slot0), - id(id0), - type(type0), - cards(), - options(ItemOptionsList::copy(options0)), - quantity(quantity0), - refine(refine0), - color(color0), - identified(identified0), - damaged(damaged0), - favorite(favorite0), - equip(equip0) - { - if (cards0 == nullptr) - return; - for (int f = 0; f < 4; f ++) - cards[f] = cards0[f]; - } - - InventoryItem(const InventoryItem &c) : - slot(c.slot), - id(c.id), - type(c.type), - cards(), - options(ItemOptionsList::copy(c.options)), - quantity(c.quantity), - refine(c.refine), - color(c.color), - identified(c.identified), - damaged(c.damaged), - favorite(c.favorite), - equip(c.equip) - { - for (int f = 0; f < 4; f ++) - cards[f] = c.cards[f]; - } - - A_DEFAULT_COPY(InventoryItem) - - ~InventoryItem() - { - delete options; - } -}; - -typedef STD_VECTOR<InventoryItem> InventoryItems; - -} // namespace Ea - -#endif // NET_EA_INVENTORYITEM_H diff --git a/src/net/ea/inventoryrecv.cpp b/src/net/ea/inventoryrecv.cpp deleted file mode 100644 index 3e8c239e9..000000000 --- a/src/net/ea/inventoryrecv.cpp +++ /dev/null @@ -1,193 +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/ea/inventoryrecv.h" - -#include "notifymanager.h" - -#include "being/localplayer.h" - -#include "const/net/inventory.h" - -#include "enums/resources/notifytypes.h" - -#include "gui/widgets/createwidget.h" - -#include "net/inventoryhandler.h" -#include "net/messagein.h" - -#include "net/ea/equipbackend.h" - -#include "utils/delete2.h" -#include "utils/foreach.h" - -#include "listeners/arrowslistener.h" - -#include "debug.h" - -namespace Ea -{ - -namespace InventoryRecv -{ - EquipBackend mEquips; - InventoryItems mInventoryItems; - Inventory *mStorage = nullptr; - PickupQueue mSentPickups; - bool mDebugInventory = true; -} // namespace InventoryRecv - -void InventoryRecv::processPlayerInventoryUse(Net::MessageIn &msg) -{ - BLOCK_START("InventoryRecv::processPlayerInventoryUse") - Inventory *const inventory = localPlayer != nullptr - ? PlayerInfo::getInventory() : nullptr; - - const int index = msg.readInt16("index") - INVENTORY_OFFSET; - msg.readInt16("item id"); - msg.readInt32("id?"); - const int amount = msg.readInt16("amount"); - msg.readUInt8("type"); - - if (inventory != nullptr) - { - if (Item *const item = inventory->getItem(index)) - { - if (amount != 0) - item->setQuantity(amount); - else - inventory->removeItemAt(index); - } - } - BLOCK_END("InventoryRecv::processPlayerInventoryUse") -} - -void InventoryRecv::processItemUseResponse(Net::MessageIn &msg) -{ - BLOCK_START("InventoryRecv::processItemUseResponse") - Inventory *const inventory = localPlayer != nullptr - ? PlayerInfo::getInventory() : nullptr; - - const int index = msg.readInt16("index") - INVENTORY_OFFSET; - const int amount = msg.readInt16("amount"); - - if (msg.readUInt8("result") == 0) - { - NotifyManager::notify(NotifyTypes::USE_FAILED); - } - else - { - if (inventory != nullptr) - { - if (Item *const item = inventory->getItem(index)) - { - if (amount != 0) - item->setQuantity(amount); - else - inventory->removeItemAt(index); - } - } - } - BLOCK_END("InventoryRecv::processItemUseResponse") -} - -void InventoryRecv::processPlayerStorageStatus(Net::MessageIn &msg) -{ - BLOCK_START("InventoryRecv::processPlayerStorageStatus") - /* - * This is the closest we get to an "Open Storage" packet from the - * server. It always comes after the two SMSG_PLAYER_STORAGE_... - * packets that update storage contents. - */ - msg.readInt16("used count"); - const int size = msg.readInt16("max size"); - - if (mStorage == nullptr) - mStorage = new Inventory(InventoryType::Storage, size); - - FOR_EACH (Ea::InventoryItems::const_iterator, it, mInventoryItems) - { - mStorage->setItem((*it).slot, - (*it).id, - (*it).type, - (*it).quantity, - (*it).refine, - (*it).color, - (*it).identified, - (*it).damaged, - (*it).favorite, - (*it).equip, - Equipped_false); - } - mInventoryItems.clear(); - - if (storageWindow == nullptr) - { - CREATEWIDGETV(storageWindow, InventoryWindow, mStorage); - } - BLOCK_END("InventoryRecv::processPlayerStorageStatus") -} - -void InventoryRecv::processPlayerStorageClose(Net::MessageIn &msg A_UNUSED) -{ - BLOCK_START("InventoryRecv::processPlayerStorageClose") - // Storage access has been closed - // Storage window deletes itself - if (storageWindow != nullptr) - { - storageWindow->unsetInventory(); - storageWindow->close(); - } - storageWindow = nullptr; - - if (mStorage != nullptr) - mStorage->clear(); - - delete2(mStorage); - BLOCK_END("InventoryRecv::processPlayerStorageClose") -} - -void InventoryRecv::processPlayerAttackRange(Net::MessageIn &msg) -{ - BLOCK_START("InventoryRecv::processPlayerAttackRange") - const int range = msg.readInt16("range"); - if (localPlayer != nullptr) - localPlayer->setAttackRange(range); - PlayerInfo::setStatBase(Attributes::PLAYER_ATTACK_RANGE, range); - PlayerInfo::setStatMod(Attributes::PLAYER_ATTACK_RANGE, 0); - BLOCK_END("InventoryRecv::processPlayerAttackRange") -} - -void InventoryRecv::processPlayerArrowEquip(Net::MessageIn &msg) -{ - BLOCK_START("InventoryRecv::processPlayerArrowEquip") - int index = msg.readInt16("index"); - if (index <= 1) - return; - - index -= INVENTORY_OFFSET; - mEquips.setEquipment(inventoryHandler->getProjectileSlot(), index); - ArrowsListener::distributeEvent(); - BLOCK_END("InventoryRecv::processPlayerArrowEquip") -} - -} // namespace Ea diff --git a/src/net/ea/inventoryrecv.h b/src/net/ea/inventoryrecv.h deleted file mode 100644 index 33c4f4682..000000000 --- a/src/net/ea/inventoryrecv.h +++ /dev/null @@ -1,64 +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_EA_INVENTORYRECV_H -#define NET_EA_INVENTORYRECV_H - -#include "localconsts.h" - -#include "enums/simpletypes/beingid.h" - -#include "net/ea/inventoryitem.h" - -#include <queue> - -namespace Net -{ - class MessageIn; -} // namespace Net - -class Inventory; - -namespace Ea -{ - typedef std::queue<BeingId> PickupQueue; - - class EquipBackend; - - namespace InventoryRecv - { - extern EquipBackend mEquips; - extern InventoryItems mInventoryItems; - extern Inventory *mStorage; - extern PickupQueue mSentPickups; - extern bool mDebugInventory; - - void processPlayerInventoryUse(Net::MessageIn &msg); - void processItemUseResponse(Net::MessageIn &msg); - void processPlayerStorageStatus(Net::MessageIn &msg); - void processPlayerStorageClose(Net::MessageIn &msg); - void processPlayerAttackRange(Net::MessageIn &msg); - void processPlayerArrowEquip(Net::MessageIn &msg); - } // namespace InventoryRecv -} // namespace Ea - -#endif // NET_EA_INVENTORYRECV_H diff --git a/src/net/ea/itemhandler.cpp b/src/net/ea/itemhandler.cpp deleted file mode 100644 index b5a676cb7..000000000 --- a/src/net/ea/itemhandler.cpp +++ /dev/null @@ -1,38 +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/ea/itemhandler.h" - -#include "debug.h" - -namespace Ea -{ - -ItemHandler::ItemHandler() -{ -} - -ItemHandler::~ItemHandler() -{ -} - -} // namespace Ea diff --git a/src/net/ea/itemhandler.h b/src/net/ea/itemhandler.h deleted file mode 100644 index 405886b4a..000000000 --- a/src/net/ea/itemhandler.h +++ /dev/null @@ -1,43 +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_EA_ITEMHANDLER_H -#define NET_EA_ITEMHANDLER_H - -#include "localconsts.h" - -namespace Ea -{ - -class ItemHandler notfinal -{ - public: - ItemHandler(); - - A_DELETE_COPY(ItemHandler) - - virtual ~ItemHandler(); -}; - -} // namespace Ea - -#endif // NET_EA_ITEMHANDLER_H diff --git a/src/net/ea/itemrecv.cpp b/src/net/ea/itemrecv.cpp deleted file mode 100644 index 59256535d..000000000 --- a/src/net/ea/itemrecv.cpp +++ /dev/null @@ -1,48 +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/ea/itemrecv.h" - -#include "actormanager.h" - -#include "being/flooritem.h" - -#include "net/messagein.h" - -#include "debug.h" - -namespace Ea -{ - -void ItemRecv::processItemRemove(Net::MessageIn &msg) -{ - if (actorManager != nullptr) - { - if (FloorItem *const item = actorManager - ->findItem(msg.readBeingId("floor item id"))) - { - actorManager->destroy(item); - } - } -} - -} // namespace Ea diff --git a/src/net/ea/itemrecv.h b/src/net/ea/itemrecv.h deleted file mode 100644 index 5e159b791..000000000 --- a/src/net/ea/itemrecv.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_EA_ITEMRECV_H -#define NET_EA_ITEMRECV_H - -#include "localconsts.h" - -namespace Net -{ - class MessageIn; -} // namespace Net - -namespace Ea -{ - namespace ItemRecv - { - void processItemRemove(Net::MessageIn &msg); - } // namespace ItemRecv -} // namespace Ea - -#endif // NET_EA_ITEMRECV_H diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp deleted file mode 100644 index 28aefef7a..000000000 --- a/src/net/ea/loginhandler.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/ea/loginhandler.h" - -#include "client.h" -#include "configuration.h" -#include "logger.h" -#include "settings.h" - -#include "utils/cast.h" -#include "utils/dtor.h" - -#include "net/logindata.h" - -#include "net/ea/loginrecv.h" - -#include "debug.h" - -namespace Ea -{ - -LoginHandler::LoginHandler() : - Net::LoginHandler() -{ - LoginRecv::mVersionResponse = false; - LoginRecv::mRegistrationEnabled = true; - LoginRecv::mUpdateHost.clear(); - LoginRecv::mWorlds.clear(); - LoginRecv::mToken.clear(); -} - -LoginHandler::~LoginHandler() -{ - delete_all(LoginRecv::mWorlds); -} - -bool LoginHandler::isRegistrationEnabled() const -{ - return LoginRecv::mRegistrationEnabled; -} - -void LoginHandler::getRegistrationDetails() const -{ - // Not supported, so move on - client->setState(State::REGISTER); -} - -void LoginHandler::loginAccount(LoginData *const loginData1) const -{ - if (loginData1 != nullptr) - { - loginData1->resetCharacterSlots(); - sendLoginRegister(loginData1->username, loginData1->password, ""); - } -} - -void LoginHandler::chooseServer(const unsigned int server, - const bool persistentIp) const -{ - if (CAST_SIZE(server) >= LoginRecv::mWorlds.size() || - (LoginRecv::mWorlds[server] == nullptr)) - { - return; - } - - ServerInfo *const charServer = getCharServer(); - if (charServer != nullptr) - { - if (config.getBoolValue("usePersistentIP") || persistentIp) - { - charServer->hostname = settings.serverName; - } - else - { - charServer->hostname = ipToString( - LoginRecv::mWorlds[server]->address); - } - charServer->port = LoginRecv::mWorlds[server]->port; - } - - client->setState(State::UPDATE); -} - -void LoginHandler::registerAccount(const LoginData *const loginData1) const -{ - if (loginData1 == nullptr) - return; - - std::string username = loginData1->username; - switch (loginData1->gender) - { - case Gender::FEMALE: - username.append("_F"); - break; - case Gender::MALE: - username.append("_M"); - break; - case Gender::OTHER: - username.append("_O"); - break; - case Gender::UNSPECIFIED: - default: - break; - } - - sendLoginRegister(username, loginData1->password, loginData1->email); -} - -const Worlds &LoginHandler::getWorlds() const -{ - return LoginRecv::mWorlds; -} - -void LoginHandler::clearWorlds() const -{ - delete_all(LoginRecv::mWorlds); - LoginRecv::mWorlds.clear(); -} - -void LoginHandler::loginOrRegister(LoginData *const data) const -{ - if (data == nullptr) - return; - - logger->log("Username is %s", data->username.c_str()); - - // Send login infos - if (data->registerLogin) - registerAccount(data); - else - loginAccount(data); - - // Clear the password, avoids auto login when returning to login - data->password.clear(); - - const bool remember = data->remember; - if (remember) - serverConfig.setValue("username", data->username); - else - serverConfig.setValue("username", ""); - serverConfig.setValue("remember", remember); -} - -void LoginHandler::logout() const -{ -} - -void LoginHandler::changeEmail(const std::string &email A_UNUSED) const -{ -} - -void LoginHandler::unregisterAccount(const std::string &username A_UNUSED, - const std::string &password - A_UNUSED) const -{ -} - -const Token &LoginHandler::getToken() const -{ - return LoginRecv::mToken; -} - -} // namespace Ea diff --git a/src/net/ea/loginhandler.h b/src/net/ea/loginhandler.h deleted file mode 100644 index d475fc184..000000000 --- a/src/net/ea/loginhandler.h +++ /dev/null @@ -1,86 +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_EA_LOGINHANDLER_H -#define NET_EA_LOGINHANDLER_H - -#include "net/loginhandler.h" - -class LoginData; - -struct Token; - -namespace Ea -{ - -class LoginHandler notfinal : public Net::LoginHandler -{ - public: - A_DELETE_COPY(LoginHandler) - - virtual ~LoginHandler(); - - bool isRegistrationEnabled() const override final A_WARN_UNUSED; - - void getRegistrationDetails() const override final; - - unsigned int getMaxPasswordLength() const override A_WARN_UNUSED - { return 24; } - - void loginAccount(LoginData *const loginData) const override final; - - void chooseServer(const unsigned int server, - const bool persistentIp) const override; - - void registerAccount(const LoginData *const loginData) - const override final; - - const Worlds &getWorlds() const override final A_CONST A_WARN_UNUSED; - - void clearWorlds() const override final; - - virtual ServerInfo *getCharServer() const A_WARN_UNUSED = 0; - - const Token &getToken() const A_CONST A_WARN_UNUSED; - - void logout() const override final A_CONST; - - void changeEmail(const std::string &email) const - override final A_CONST; - - void unregisterAccount(const std::string &username, - const std::string &password) - const override final A_CONST; - - void loginOrRegister(LoginData *const data) const override final; - - protected: - LoginHandler(); - - virtual void sendLoginRegister(const std::string &username, - const std::string &password, - const std::string &email) const = 0; -}; - -} // namespace Ea - -#endif // NET_EA_LOGINHANDLER_H diff --git a/src/net/ea/loginrecv.cpp b/src/net/ea/loginrecv.cpp deleted file mode 100644 index 2591a417c..000000000 --- a/src/net/ea/loginrecv.cpp +++ /dev/null @@ -1,135 +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/ea/loginrecv.h" - -#include "client.h" - -#include "fs/paths.h" - -#include "gui/windows/logindialog.h" - -#include "utils/gettext.h" - -#include "net/logindata.h" -#include "net/messagein.h" - -#include "debug.h" - -namespace Ea -{ - -namespace LoginRecv -{ - std::string mUpdateHost; - Worlds mWorlds; - Token mToken; - bool mVersionResponse = false; - bool mRegistrationEnabled = true; -} // namespace LoginRecv - -void LoginRecv::processUpdateHost(Net::MessageIn &msg) -{ - const int len = msg.readInt16("len") - 4; - mUpdateHost = msg.readString(len, "update host"); - - if (!checkPath(mUpdateHost)) - { - mUpdateHost.clear(); - logger->log1("Warning: incorrect update server name"); - } - loginData.updateHost = mUpdateHost; - - logger->log("Received update host \"%s\" from login server.", - mUpdateHost.c_str()); -} - -void LoginRecv::processLoginError(Net::MessageIn &msg) -{ - const uint8_t code = msg.readUInt8("error"); - logger->log("Login::error code: %u", CAST_U32(code)); - std::string date = msg.readString(20, "date"); - - switch (code) - { - case 0: - // TRANSLATORS: error message - errorMessage = _("Unregistered ID."); - break; - case 1: - // TRANSLATORS: error message - errorMessage = _("Wrong password."); - LoginDialog::savedPassword.clear(); - break; - case 2: - // TRANSLATORS: error message - errorMessage = _("Account expired."); - break; - case 3: - // TRANSLATORS: error message - errorMessage = _("Rejected from server."); - break; - case 4: - // TRANSLATORS: error message - errorMessage = _("You have been permanently banned from " - "the game. Please contact the GM team."); - break; - case 5: - // TRANSLATORS: error message - errorMessage = _("Client too old or wrong server type.\n" - "Please update client on http://manaplus.org"); - break; - case 6: - // TRANSLATORS: error message - errorMessage = strprintf(_("You have been temporarily " - "banned from the game until %s.\nPlease contact the GM " - "team via the forums."), date.c_str()); - break; - case 7: - // TRANSLATORS: error message - errorMessage = _("Server overpopulated."); - break; - case 9: - // TRANSLATORS: error message - errorMessage = _("This user name is already taken."); - break; - case 10: - // TRANSLATORS: error message - errorMessage = _("Wrong name."); - break; - case 11: - // TRANSLATORS: error message - errorMessage = _("Incorrect email."); - break; - case 99: - // TRANSLATORS: error message - errorMessage = _("Username permanently erased."); - break; - default: - // TRANSLATORS: error message - errorMessage = _("Unknown error."); - break; - } - client->setState(State::ERROR); -} - -} // namespace Ea diff --git a/src/net/ea/loginrecv.h b/src/net/ea/loginrecv.h deleted file mode 100644 index 80ac08e44..000000000 --- a/src/net/ea/loginrecv.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_EA_LOGINRECV_H -#define NET_EA_LOGINRECV_H - -#include "net/worldinfo.h" - -#include "net/ea/token.h" - -namespace Net -{ - class MessageIn; -} // namespace Net - -namespace Ea -{ - namespace LoginRecv - { - extern std::string mUpdateHost; - extern Worlds mWorlds; - extern Token mToken; - extern bool mVersionResponse; - extern bool mRegistrationEnabled; - - void processUpdateHost(Net::MessageIn &msg); - void processLoginError(Net::MessageIn &msg); - } // namespace LoginRecv -} // namespace Ea - -#endif // NET_EA_LOGINRECV_H diff --git a/src/net/ea/maprecv.cpp b/src/net/ea/maprecv.cpp deleted file mode 100644 index dbe9d4559..000000000 --- a/src/net/ea/maprecv.cpp +++ /dev/null @@ -1,59 +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/ea/maprecv.h" - -#include "gui/viewport.h" - -#include "resources/map/map.h" - -#include "net/messagein.h" - -#include "debug.h" - -namespace Ea -{ - -void MapRecv::processSetTilesType(Net::MessageIn &msg) -{ - const int x1 = msg.readInt16("x1"); - const int y1 = msg.readInt16("y1"); - const int x2 = msg.readInt16("x2"); - const int y2 = msg.readInt16("y2"); - const BlockTypeT mask = static_cast<BlockTypeT>(msg.readInt32("mask")); - const int layer = msg.readInt32("layer"); - const std::string name = msg.readString(16, "map name"); - if (layer != 0) - return; - Map *const map = viewport->getMap(); - if ((map != nullptr) && map->getGatName() == name) - { - for (int y = y1; y <= y2; y ++) - { - for (int x = x1; x <= x2; x ++) - map->setBlockMask(x, y, mask); - } - map->updateConditionLayers(); - map->preCacheLayers(); - } -} - -} // namespace Ea diff --git a/src/net/ea/maprecv.h b/src/net/ea/maprecv.h deleted file mode 100644 index 48c19d158..000000000 --- a/src/net/ea/maprecv.h +++ /dev/null @@ -1,40 +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_EA_MAPRECV_H -#define NET_EA_MAPRECV_H - -#include "localconsts.h" - -namespace Net -{ - class MessageIn; -} // namespace Net - -namespace Ea -{ - namespace MapRecv - { - void processSetTilesType(Net::MessageIn &msg); - } // namespace MapRecv -} // namespace Ea - -#endif // NET_EA_MAPRECV_H diff --git a/src/net/ea/network.cpp b/src/net/ea/network.cpp deleted file mode 100644 index 1ae4d2323..000000000 --- a/src/net/ea/network.cpp +++ /dev/null @@ -1,372 +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/ea/network.h" - -#include "configuration.h" -#include "logger.h" - -#include "net/packetinfo.h" - -#include "utils/cast.h" -#include "utils/delete2.h" -#include "utils/gettext.h" -#include "utils/sdlhelper.h" - -#include <sstream> - -#include "debug.h" - -#ifndef SDL_BIG_ENDIAN -#error missing SDL_endian.h -#endif // SDL_BYTEORDER - -extern unsigned int mLastHost; - -namespace Ea -{ - -const unsigned int BUFFER_SIZE = 1000000; -const unsigned int BUFFER_LIMIT = 930000; - -int networkThread(void *data) -{ - Network *const network = static_cast<Network *>(data); - - if ((network == nullptr) || !network->realConnect()) - return -1; - - network->receive(); - - return 0; -} - -Network::Network() : - mSocket(nullptr), - mServer(), - mPackets(nullptr), - mInBuffer(new char[BUFFER_SIZE]), - mOutBuffer(new char[BUFFER_SIZE]), - mInSize(0), - mOutSize(0), - mToSkip(0), - mState(IDLE), - mError(), - mWorkerThread(nullptr), - mMutexIn(SDL_CreateMutex()), - mMutexOut(SDL_CreateMutex()), - mSleep(config.getIntValue("networksleep")), - mPauseDispatch(false) -{ - TcpNet::init(); -} - -Network::~Network() -{ - if (mState != IDLE && mState != NET_ERROR) - disconnect(); - - SDL_DestroyMutex(mMutexIn); - mMutexIn = nullptr; - SDL_DestroyMutex(mMutexOut); - mMutexOut = nullptr; - - delete2Arr(mInBuffer); - delete2Arr(mOutBuffer); - delete2Arr(mPackets); - - TcpNet::quit(); -} - -bool Network::connect(const ServerInfo &server) -{ - if (mState != IDLE && mState != NET_ERROR) - { - logger->log1("Tried to connect an already connected socket!"); - return false; - } - - if (server.hostname.empty()) - { - // TRANSLATORS: error message - setError(_("Empty address given to Network::connect()!")); - return false; - } - - logger->log("Network::Connecting to %s:%i", - server.hostname.c_str(), server.port); - - mServer.hostname = server.hostname; - mServer.althostname = server.althostname; - mServer.port = server.port; - - // Reset to sane values - mOutSize = 0; - mInSize = 0; - mToSkip = 0; - - mState = CONNECTING; - mWorkerThread = SDL::createThread(&networkThread, "network", this); - if (mWorkerThread == nullptr) - { - setError("Unable to create network worker thread"); - return false; - } - - return true; -} - -void Network::disconnect() -{ - BLOCK_START("Network::disconnect") - mState = IDLE; - - SDL::WaitThread(mWorkerThread); - mWorkerThread = nullptr; - - if (mSocket != nullptr) - { - TcpNet::closeSocket(mSocket); - mSocket = nullptr; - if (mSleep > 0) - SDL_Delay(mSleep); - } - BLOCK_END("Network::disconnect") -} - -void Network::flush() -{ - if ((mOutSize == 0u) || mState != CONNECTED) - return; - - SDL_mutexP(mMutexOut); - const int ret = TcpNet::send(mSocket, mOutBuffer, mOutSize); -/* - if (logger) - { - logger->dlog(std::string("Send ").append( - toString(mOutSize)).append(" bytes")); - } -*/ - if (ret < CAST_S32(mOutSize)) - { - SDL_mutexV(mMutexOut); - setError("Error in TcpNet::send(): " + - std::string(TcpNet::getError())); - } - mOutSize = 0; - SDL_mutexV(mMutexOut); -} - -void Network::skip(const int len) -{ - SDL_mutexP(mMutexIn); - mToSkip += len; - if (mInSize == 0u) - { - SDL_mutexV(mMutexIn); - return; - } - - if (mInSize >= mToSkip) - { - mInSize -= mToSkip; - memmove(mInBuffer, mInBuffer + CAST_SIZE(mToSkip), mInSize); - mToSkip = 0; - } - else - { - mToSkip -= mInSize; - mInSize = 0; - } - SDL_mutexV(mMutexIn); -} - -bool Network::realConnect() -{ - IPaddress ipAddress; - - if (TcpNet::resolveHost(&ipAddress, mServer.hostname.c_str(), - mServer.port) == -1) - { - if (mServer.althostname.empty() || TcpNet::resolveHost(&ipAddress, - mServer.althostname.c_str(), mServer.port) == -1) - { - const std::string errorMessage = std::string( - // TRANSLATORS: error message - _("Unable to resolve host \"")).append( - mServer.hostname).append("\"."); - setError(errorMessage); - logger->log_r("TcpNet::ResolveHost: %s", errorMessage.c_str()); - return false; - } - logger->log_r("using alt host name: %s", mServer.althostname.c_str()); - } - - mState = CONNECTING; - - mSocket = TcpNet::open(&ipAddress); - if (mSocket == nullptr) - { - logger->log_r("Error in TcpNet::open(): %s", TcpNet::getError()); - setError(TcpNet::getError()); - return false; - } - - mLastHost = ipAddress.host; - logger->log_r("Network::Started session with %s:%i", - ipToString(ipAddress.host), ipAddress.port); - - mState = CONNECTED; - return true; -} - -void Network::receive() -{ - TcpNet::SocketSet set; - - if ((set = TcpNet::allocSocketSet(1)) == nullptr) - { - setError("Error in TcpNet::allocSocketSet(): " + - std::string(TcpNet::getError())); - return; - } - - if (TcpNet::addSocket(set, mSocket) == -1) - { - setError("Error in TcpNet::addSocket(): " + - std::string(TcpNet::getError())); - } - - while (mState == CONNECTED) - { - const int numReady = TcpNet::checkSockets( - set, (CAST_U32(500))); - switch (numReady) - { - case -1: - logger->log_r("Error: TcpNet::checkSockets"); - break; - // FALLTHROUGH - case 0: - break; - - case 1: - { - // Receive data from the socket - SDL_mutexP(mMutexIn); - if (mInSize > BUFFER_LIMIT) - { - SDL_mutexV(mMutexIn); - SDL_Delay(100); - continue; - } - - const int ret = TcpNet::recv(mSocket, - mInBuffer + CAST_SIZE(mInSize), - BUFFER_SIZE - mInSize); - - if (ret == 0) - { - // We got disconnected - mState = IDLE; - logger->log_r("Disconnected."); - } - else if (ret < 0) - { - // TRANSLATORS: error message - setError(_("Connection to server terminated. ") + - std::string(TcpNet::getError())); - } - else - { -// DEBUGLOG("Receive " + toString(ret) + " bytes"); - mInSize += ret; - if (mToSkip != 0u) - { - if (mInSize >= mToSkip) - { - mInSize -= mToSkip; - memmove(mInBuffer, - mInBuffer + CAST_SIZE(mToSkip), - mInSize); - mToSkip = 0; - } - else - { - mToSkip -= mInSize; - mInSize = 0; - } - } - } - SDL_mutexV(mMutexIn); - break; - } - - default: - // more than one socket is ready.. - // this should not happen since we only listen once socket. - std::stringstream errorStream; - errorStream << "Error in TcpNet::recv(), " << numReady - << " sockets are ready: " << TcpNet::getError(); - setError(errorStream.str()); - break; - } - } - - if (TcpNet::delSocket(set, mSocket) == -1) - logger->log_r("Error in TcpNet::delSocket(): %s", TcpNet::getError()); - - TcpNet::freeSocketSet(set); -} - -void Network::setError(const std::string &error) -{ - logger->log_r("Network error: %s", error.c_str()); - mError = error; - mState = NET_ERROR; -} - -uint16_t Network::readWord(const int pos) const -{ -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - return SDL_Swap16(*reinterpret_cast<uint16_t*>( - mInBuffer + CAST_SIZE(pos))); -#else // SDL_BYTEORDER == SDL_BIG_ENDIAN - - return (*reinterpret_cast<uint16_t*>( - mInBuffer + CAST_SIZE(pos))); -#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN -} - -void Network::fixSendBuffer() -{ - if (mOutSize > BUFFER_LIMIT) - { - if (mState != CONNECTED) - mOutSize = 0; - else - flush(); - } -} - -} // namespace Ea diff --git a/src/net/ea/network.h b/src/net/ea/network.h deleted file mode 100644 index cd5be69e3..000000000 --- a/src/net/ea/network.h +++ /dev/null @@ -1,121 +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_EA_NETWORK_H -#define NET_EA_NETWORK_H - -#include "net/serverinfo.h" - -PRAGMACLANG6GCC(GCC diagnostic push) -PRAGMACLANG6GCC(GCC diagnostic ignored "-Wold-style-cast") -#include "net/sdltcpnet.h" -PRAGMACLANG6GCC(GCC diagnostic pop) - -struct PacketInfo; - -namespace Ea -{ - -class Network notfinal -{ - public: - Network(); - - A_DELETE_COPY(Network) - - virtual ~Network(); - - bool connect(const ServerInfo &server); - - void disconnect(); - - ServerInfo getServer() const A_WARN_UNUSED - { return mServer; } - - int getState() const A_WARN_UNUSED - { return mState; } - - const std::string &getError() const A_WARN_UNUSED - { return mError; } - - bool isConnected() const A_WARN_UNUSED - { return mState == CONNECTED; } - - int getInSize() const A_WARN_UNUSED - { return mInSize; } - - void skip(const int len); - - void flush(); - - void fixSendBuffer(); - - void pauseDispatch() - { mPauseDispatch = true; } - - // ERROR replaced by NET_ERROR because already defined in Windows - enum - { - IDLE = 0, - CONNECTED, - CONNECTING, - DATA, - NET_ERROR - }; - - protected: - friend int networkThread(void *data); - - void setError(const std::string &error); - - uint16_t readWord(const int pos) const A_WARN_UNUSED; - - bool realConnect(); - - void receive(); - - TcpNet::Socket mSocket; - - ServerInfo mServer; - - PacketInfo *mPackets; - - char *mInBuffer; - char *mOutBuffer; - unsigned int mInSize; - unsigned int mOutSize; - - unsigned int mToSkip; - - int mState; - std::string mError; - - SDL_Thread *mWorkerThread; - SDL_mutex *mMutexIn; - SDL_mutex *mMutexOut; - int mSleep; - bool mPauseDispatch; -}; - -} // namespace Ea - -#endif // NET_EA_NETWORK_H diff --git a/src/net/ea/npchandler.cpp b/src/net/ea/npchandler.cpp deleted file mode 100644 index e7ac6fa65..000000000 --- a/src/net/ea/npchandler.cpp +++ /dev/null @@ -1,43 +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/ea/npchandler.h" - -#include "net/ea/npcrecv.h" - -#include "debug.h" - -namespace Ea -{ - -NpcHandler::NpcHandler() -{ - NpcRecv::mDialog = nullptr; - NpcRecv::mRequestLang = false; -} - -NpcDialog *NpcHandler::getCurrentNpcDialog() const -{ - return NpcRecv::mDialog; -} - -} // namespace Ea diff --git a/src/net/ea/npchandler.h b/src/net/ea/npchandler.h deleted file mode 100644 index 2f3503957..000000000 --- a/src/net/ea/npchandler.h +++ /dev/null @@ -1,46 +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_EA_NPCHANDLER_H -#define NET_EA_NPCHANDLER_H - -#include "net/npchandler.h" - -#include "localconsts.h" - -namespace Ea -{ - -class NpcHandler notfinal : public Net::NpcHandler -{ - public: - A_DELETE_COPY(NpcHandler) - - NpcDialog *getCurrentNpcDialog() const override final; - - protected: - NpcHandler(); -}; - -} // namespace Ea - -#endif // NET_EA_NPCHANDLER_H diff --git a/src/net/ea/npcrecv.cpp b/src/net/ea/npcrecv.cpp deleted file mode 100644 index 098f07e79..000000000 --- a/src/net/ea/npcrecv.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/ea/npcrecv.h" - -#include "gui/viewport.h" - -#include "gui/windows/npcdialog.h" - -#include "net/messagein.h" -#include "net/npchandler.h" - -#include "utils/langs.h" - -#include "debug.h" - -namespace Ea -{ - -namespace NpcRecv -{ - NpcDialog *mDialog = nullptr; - bool mRequestLang = false; -} // namespace NpcRecv - -void NpcRecv::processNpcChoice(Net::MessageIn &msg) -{ - msg.readInt16("len"); - npcHandler->getNpc(msg, NpcAction::Other); - mRequestLang = false; - - if (mDialog != nullptr) - { - mDialog->choiceRequest(); - mDialog->parseListItems(msg.readString(msg.getLength() - 8, - "select items")); - } - else - { - msg.readString(msg.getLength() - 8, "select items"); - } -} - -void NpcRecv::processNpcMessage(Net::MessageIn &msg) -{ - msg.readInt16("len"); - npcHandler->getNpc(msg, NpcAction::Other); - mRequestLang = false; - - const std::string message = msg.readString(msg.getLength() - 8, "message"); - // ignore future legacy npc commands. - if (message.size() > 3 && message.substr(0, 3) == "###") - return; - if (mDialog != nullptr) - mDialog->addText(message); -} - -void NpcRecv::processNpcClose(Net::MessageIn &msg) -{ - // Show the close button - npcHandler->getNpc(msg, NpcAction::Close); - mRequestLang = false; - if (mDialog != nullptr) - mDialog->showCloseButton(); -} - -void NpcRecv::processNpcNext(Net::MessageIn &msg) -{ - // Show the next button - npcHandler->getNpc(msg, NpcAction::Next); - mRequestLang = false; - if (mDialog != nullptr) - mDialog->showNextButton(); -} - -void NpcRecv::processNpcIntInput(Net::MessageIn &msg) -{ - // Request for an integer - npcHandler->getNpc(msg, NpcAction::Other); - mRequestLang = false; - if (mDialog != nullptr) - mDialog->integerRequest(0); -} - -void NpcRecv::processNpcStrInput(Net::MessageIn &msg) -{ - // Request for a string - BeingId npcId = npcHandler->getNpc(msg, NpcAction::Other); - if (mRequestLang) - { - mRequestLang = false; - npcHandler->stringInput(npcId, getLangSimple()); - } - else if (mDialog != nullptr) - { - mDialog->textRequest(""); - } -} - -void NpcRecv::processNpcCommand(Net::MessageIn &msg) -{ - const BeingId npcId = npcHandler->getNpc(msg, NpcAction::Other); - mRequestLang = false; - - const int cmd = msg.readInt16("cmd"); - const BeingId id = msg.readBeingId("id"); - const int x = msg.readInt16("x"); - const int y = msg.readInt16("y"); - switch (cmd) - { - case 0: - mRequestLang = true; - break; - - case 1: - if (viewport != nullptr) - viewport->moveCameraToActor(npcId); - break; - - case 2: - if (viewport != nullptr) - { - if (id == BeingId_zero) - viewport->moveCameraToPosition(x, y); - else - viewport->moveCameraToActor(id, x, y); - } - break; - - case 3: - if (viewport != nullptr) - viewport->returnCamera(); - break; - - case 4: - if (viewport != nullptr) - { - viewport->moveCameraRelative(x, y); - } - break; - case 5: // close dialog - if (mDialog != nullptr) - mDialog->restoreCamera(); - npcHandler->closeDialog(npcId); - break; - case 6: // show avatar - if (mDialog != nullptr) - { - mDialog->showAvatar(fromInt(id, BeingTypeId)); - } - break; - case 7: // set avatar direction - if (mDialog != nullptr) - { - mDialog->setAvatarDirection( - Net::MessageIn::fromServerDirection( - CAST_U8(id))); - } - break; - case 8: // set avatar action - if (mDialog != nullptr) - mDialog->setAvatarAction(toInt(id, int)); - break; - case 9: // clear npc dialog - if (mDialog != nullptr) - mDialog->clearRows(); - break; - case 10: // send selected item id - { - int invSize = toInt(id, int); - if (invSize == 0) - invSize = 1; - if (mDialog != nullptr) - mDialog->itemRequest(invSize); - break; - } - case 11: // send selected item index - { - int invSize = toInt(id, int); - if (invSize == 0) - invSize = 1; - if (mDialog != nullptr) - mDialog->itemIndexRequest(invSize); - break; - } - case 12: // send complex items - { - int invSize = toInt(id, int); - if (invSize == 0) - invSize = 1; - if (mDialog != nullptr) - mDialog->itemCraftRequest(invSize); - break; - } - case 14: - { - 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); - } - break; - } - default: - UNIMPLEMENTEDPACKETFIELD(cmd); - break; - } -} - -void NpcRecv::processChangeTitle(Net::MessageIn &msg) -{ - msg.readInt16("len"); - npcHandler->getNpc(msg, NpcAction::Other); - mRequestLang = false; - if (mDialog != nullptr) - { - const std::string str = msg.readString(-1, "title"); - mDialog->setCaption(str); - } -} - -} // namespace Ea diff --git a/src/net/ea/npcrecv.h b/src/net/ea/npcrecv.h deleted file mode 100644 index 1cf7fa058..000000000 --- a/src/net/ea/npcrecv.h +++ /dev/null @@ -1,53 +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_EA_NPCRECV_H -#define NET_EA_NPCRECV_H - -#include "localconsts.h" - -class NpcDialog; - -namespace Net -{ - class MessageIn; -} // namespace Net - -namespace Ea -{ - namespace NpcRecv - { - extern NpcDialog *mDialog; - extern bool mRequestLang; - - void processNpcChoice(Net::MessageIn &msg); - void processNpcMessage(Net::MessageIn &msg); - void processNpcClose(Net::MessageIn &msg); - void processNpcNext(Net::MessageIn &msg); - void processNpcIntInput(Net::MessageIn &msg); - void processNpcStrInput(Net::MessageIn &msg); - void processNpcCommand(Net::MessageIn &msg); - void processChangeTitle(Net::MessageIn &msg); - } // namespace NpcRecv -} // namespace Ea - -#endif // NET_EA_NPCRECV_H diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp deleted file mode 100644 index 23f7347b9..000000000 --- a/src/net/ea/partyhandler.cpp +++ /dev/null @@ -1,80 +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/ea/partyhandler.h" - -#include "party.h" - -#include "net/ea/partyrecv.h" - -#include "gui/widgets/tabs/chat/partytab.h" - -#include "utils/delete2.h" - -#include "debug.h" - -namespace Ea -{ - -PartyHandler::PartyHandler() : - Net::PartyHandler() -{ - PartyRecv::mShareExp = PartyShare::UNKNOWN; - PartyRecv::mShareItems = PartyShare::UNKNOWN; - taParty = Party::getParty(1); -} - -PartyHandler::~PartyHandler() -{ - delete2(partyTab); - taParty = nullptr; -} - -void PartyHandler::join(const int partyId A_UNUSED) const -{ -} - -void PartyHandler::reload() -{ - taParty = Party::getParty(1); -} - -void PartyHandler::clear() const -{ - taParty = nullptr; -} - -ChatTab *PartyHandler::getTab() const -{ - return partyTab; -} - -PartyShareT PartyHandler::getShareExperience() const -{ - return PartyRecv::mShareExp; -} - -PartyShareT PartyHandler::getShareItems() const -{ - return PartyRecv::mShareItems; -} - -} // namespace Ea diff --git a/src/net/ea/partyhandler.h b/src/net/ea/partyhandler.h deleted file mode 100644 index 2be323d85..000000000 --- a/src/net/ea/partyhandler.h +++ /dev/null @@ -1,57 +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_EA_PARTYHANDLER_H -#define NET_EA_PARTYHANDLER_H - -#include "net/partyhandler.h" - -class Party; - -namespace Ea -{ -class PartyHandler notfinal : public Net::PartyHandler -{ - public: - PartyHandler(); - - A_DELETE_COPY(PartyHandler) - - virtual ~PartyHandler(); - - void join(const int partyId) const override final A_CONST; - - PartyShareT getShareExperience() const override final A_WARN_UNUSED; - - PartyShareT getShareItems() const override final A_WARN_UNUSED; - - static void reload(); - - void clear() const override final; - - ChatTab *getTab() const override final; -}; - -extern Party *taParty; - -} // namespace Ea - -#endif // NET_EA_PARTYHANDLER_H diff --git a/src/net/ea/partyrecv.cpp b/src/net/ea/partyrecv.cpp deleted file mode 100644 index d81bb4295..000000000 --- a/src/net/ea/partyrecv.cpp +++ /dev/null @@ -1,232 +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/ea/partyrecv.h" - -#include "actormanager.h" -#include "configuration.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 "net/messagein.h" - -#include "gui/widgets/tabs/chat/partytab.h" - -#include "utils/delete2.h" - -#include "debug.h" - -namespace Ea -{ - -Party *taParty = nullptr; - -namespace PartyRecv -{ - PartyShareT mShareExp = PartyShare::UNKNOWN; - PartyShareT mShareItems = PartyShare::UNKNOWN; -} // namespace PartyRecv - -void PartyRecv::processPartyCreate(Net::MessageIn &msg) -{ - if (msg.readUInt8("flag") != 0u) - NotifyManager::notify(NotifyTypes::PARTY_CREATE_FAILED); - else - NotifyManager::notify(NotifyTypes::PARTY_CREATED); -} - -void PartyRecv::processPartyExpSettingsContinue(Net::MessageIn &msg, - const PartyShareT exp) -{ - switch (exp) - { - case PartyShare::YES: - if (mShareExp == PartyShare::YES) - break; - mShareExp = PartyShare::YES; - NotifyManager::notify(NotifyTypes::PARTY_EXP_SHARE_ON); - break; - case PartyShare::NO: - if (mShareExp == PartyShare::NO) - break; - mShareExp = PartyShare::NO; - NotifyManager::notify(NotifyTypes::PARTY_EXP_SHARE_OFF); - break; - case PartyShare::NOT_POSSIBLE: - if (mShareExp == PartyShare::NOT_POSSIBLE) - break; - mShareExp = PartyShare::NOT_POSSIBLE; - NotifyManager::notify(NotifyTypes::PARTY_EXP_SHARE_ERROR); - break; - default: - case PartyShare::UNKNOWN: - UNIMPLEMENTEDPACKETFIELD(CAST_S32(exp)); - break; - } -} - -void PartyRecv::processPartyItemSettingsContinue(Net::MessageIn &msg, - const PartyShareT item) -{ - switch (item) - { - case PartyShare::YES: - if (mShareItems == PartyShare::YES) - break; - mShareItems = PartyShare::YES; - NotifyManager::notify(NotifyTypes::PARTY_ITEM_SHARE_ON); - break; - case PartyShare::NO: - if (mShareItems == PartyShare::NO) - break; - mShareItems = PartyShare::NO; - NotifyManager::notify(NotifyTypes::PARTY_ITEM_SHARE_OFF); - break; - case PartyShare::NOT_POSSIBLE: - if (mShareItems == PartyShare::NOT_POSSIBLE) - break; - mShareItems = PartyShare::NOT_POSSIBLE; - NotifyManager::notify(NotifyTypes::PARTY_ITEM_SHARE_ERROR); - break; - default: - case PartyShare::UNKNOWN: - UNIMPLEMENTEDPACKETFIELD(CAST_S32(item)); - break; - } -} - -void PartyRecv::processPartyLeave(Net::MessageIn &msg) -{ - const BeingId id = msg.readBeingId("account id"); - const std::string nick = msg.readString(24, "nick"); - const int reason = msg.readUInt8("flag"); - if (localPlayer == nullptr) - return; - - if (id == localPlayer->getId()) - { - switch (reason) - { - case 0: - default: - NotifyManager::notify(NotifyTypes::PARTY_LEFT); - break; - - case 1: - NotifyManager::notify(NotifyTypes::PARTY_KICKED); - break; - - case 2: - NotifyManager::notify(NotifyTypes::PARTY_LEFT_DENY); - break; - - case 3: - NotifyManager::notify(NotifyTypes::PARTY_KICK_DENY); - break; - } - - if (reason >= 2) - return; - - if (Ea::taParty != nullptr) - { - Ea::taParty->removeFromMembers(); - Ea::taParty->clearMembers(); - } - - delete2(partyTab) - - if ((socialWindow != nullptr) && (Ea::taParty != nullptr)) - socialWindow->removeTab(Ea::taParty); - localPlayer->setPartyName(""); - } - else - { - switch (reason) - { - case 0: - default: - NotifyManager::notify(NotifyTypes::PARTY_USER_LEFT, nick); - break; - - case 1: - NotifyManager::notify(NotifyTypes::PARTY_USER_KICKED, nick); - break; - - case 2: - NotifyManager::notify(NotifyTypes::PARTY_USER_LEFT_DENY, nick); - break; - - case 3: - NotifyManager::notify(NotifyTypes::PARTY_USER_KICK_DENY, nick); - break; - } - - if (reason >= 2) - return; - - if (actorManager != nullptr) - { - Being *const b = actorManager->findBeing(id); - if ((b != nullptr) && b->getType() == ActorType::Player) - { - b->setParty(nullptr); - b->setPartyName(""); - } - } - if (Ea::taParty != nullptr) - Ea::taParty->removeMember(id); - } -} - -void PartyRecv::processPartyUpdateCoords(Net::MessageIn &msg) -{ - const BeingId id = msg.readBeingId("account id"); - PartyMember *m = nullptr; - if (Ea::taParty != nullptr) - m = Ea::taParty->getMember(id); - if (m != nullptr) - { - m->setX(msg.readInt16("x")); - m->setY(msg.readInt16("y")); - } - else - { - msg.readInt16("x"); - msg.readInt16("y"); - } -} - -void PartyRecv::createTab() -{ - partyTab = new PartyTab(chatWindow); - if (config.getBoolValue("showChatHistory")) - partyTab->loadFromLogFile("#Party"); -} - -} // namespace Ea diff --git a/src/net/ea/partyrecv.h b/src/net/ea/partyrecv.h deleted file mode 100644 index 07629567d..000000000 --- a/src/net/ea/partyrecv.h +++ /dev/null @@ -1,54 +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_EA_PARTYRECV_H -#define NET_EA_PARTYRECV_H - -#include "enums/net/partyshare.h" - -class Party; - -namespace Net -{ - class MessageIn; -} // namespace Net - -namespace Ea -{ - namespace PartyRecv - { - extern PartyShareT mShareExp; - extern PartyShareT mShareItems; - - void processPartyCreate(Net::MessageIn &msg); - void processPartyLeave(Net::MessageIn &msg); - void processPartyUpdateCoords(Net::MessageIn &msg); - void processPartyExpSettingsContinue(Net::MessageIn &msg, - const PartyShareT exp); - void processPartyItemSettingsContinue(Net::MessageIn &msg, - const PartyShareT item); - - void createTab(); - } // namespace PartyRecv - extern Party *taParty; -} // namespace Ea - -#endif // NET_EA_PARTYRECV_H diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp deleted file mode 100644 index 3300c5c8d..000000000 --- a/src/net/ea/playerhandler.cpp +++ /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/>. - */ - -#include "net/ea/playerhandler.h" - -#include "being/playerinfo.h" - -#include "debug.h" - -namespace Ea -{ - -PlayerHandler::PlayerHandler() -{ -} - -void PlayerHandler::ignorePlayer(const std::string &player A_UNUSED, - const bool ignore A_UNUSED) const -{ -} - -void PlayerHandler::ignoreAll(const bool ignore A_UNUSED) const -{ -} - -int PlayerHandler::getDefaultWalkSpeed() const -{ - return 150; -} - -bool PlayerHandler::canUseMagic() const -{ - return PlayerInfo::getStatEffective(Attributes::PLAYER_MATK) > 0; -} - -} // namespace Ea diff --git a/src/net/ea/playerhandler.h b/src/net/ea/playerhandler.h deleted file mode 100644 index d852d1086..000000000 --- a/src/net/ea/playerhandler.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_EA_PLAYERHANDLER_H -#define NET_EA_PLAYERHANDLER_H - -#include "net/playerhandler.h" - -namespace Ea -{ - -class PlayerHandler notfinal : public Net::PlayerHandler -{ - public: - PlayerHandler(); - - A_DELETE_COPY(PlayerHandler) - - void ignorePlayer(const std::string &player, - const bool ignore) const override final A_CONST; - - void ignoreAll(const bool ignore) const override final A_CONST; - - bool canUseMagic() const override final; - - int getDefaultWalkSpeed() const override final A_WARN_UNUSED; -}; - -} // namespace Ea - -#endif // NET_EA_PLAYERHANDLER_H diff --git a/src/net/ea/playerrecv.cpp b/src/net/ea/playerrecv.cpp deleted file mode 100644 index edc604907..000000000 --- a/src/net/ea/playerrecv.cpp +++ /dev/null @@ -1,266 +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/ea/playerrecv.h" - -#include "game.h" -#include "notifymanager.h" -#include "settings.h" -#include "soundmanager.h" - -#include "being/localplayer.h" -#include "being/playerinfo.h" - -#include "const/net/nostat.h" - -#include "enums/resources/notifytypes.h" - -#include "gui/viewport.h" - -#include "gui/windows/statuswindow.h" - -#include "input/inputmanager.h" - -#include "resources/map/map.h" - -#include "net/playerhandler.h" - -#include "utils/stdmove.h" -#include "utils/stringutils.h" - -#include "debug.h" - -// Max. distance we are willing to scroll after a teleport; -// everything beyond will reset the port hard. -static const int MAP_TELEPORT_SCROLL_DISTANCE = 8; - -namespace Ea -{ - -void PlayerRecv::processPlayerWarp(Net::MessageIn &msg) -{ - BLOCK_START("PlayerRecv::processPlayerWarp") - std::string mapPath = msg.readString(16, "map name"); - int x = msg.readInt16("x"); - int y = msg.readInt16("y"); - - logger->log("Warping to %s (%d, %d)", mapPath.c_str(), x, y); - - if (localPlayer == nullptr) - logger->log1("SMSG_PLAYER_WARP localPlayer null"); - - /* - * We must clear the local player's target *before* the call - * to changeMap, as it deletes all beings. - */ - if (localPlayer != nullptr) - localPlayer->stopAttack(); - - Game *const game = Game::instance(); - if (game == nullptr) - { - BLOCK_END("PlayerRecv::processPlayerWarp") - return; - } - - const std::string ¤tMapName = game->getCurrentMapName(); - const bool sameMap = (currentMapName == mapPath); - - // Switch the actual map, deleting the previous one if necessary - mapPath = mapPath.substr(0, mapPath.rfind('.')); - game->changeMap(mapPath); - - int scrollOffsetX = 0; - int scrollOffsetY = 0; - - if (localPlayer != nullptr) - { - const Map *const map = game->getCurrentMap(); - if (map != nullptr) - { - if (x >= map->getWidth()) - x = map->getWidth() - 1; - if (y >= map->getHeight()) - y = map->getHeight() - 1; - if (x < 0) - x = 0; - if (y < 0) - y = 0; - /* Scroll if neccessary */ - if (!sameMap - || (abs(x - localPlayer->getTileX()) - > MAP_TELEPORT_SCROLL_DISTANCE) - || (abs(y - localPlayer->getTileY()) - > MAP_TELEPORT_SCROLL_DISTANCE)) - { - scrollOffsetX = (x - localPlayer->getTileX()) - * map->getTileWidth(); - scrollOffsetY = (y - localPlayer->getTileY()) - * map->getTileHeight(); - } - } - - localPlayer->setAction(BeingAction::STAND, 0); - localPlayer->setTileCoords(x, y); - localPlayer->navigateClean(); - localPlayer->reset(); - } - - logger->log("Adjust scrolling by %d:%d", scrollOffsetX, scrollOffsetY); - - if (viewport != nullptr) - { - viewport->returnCamera(); - viewport->scrollBy(scrollOffsetX, scrollOffsetY); - } - BLOCK_END("PlayerRecv::processPlayerWarp") -} - -void PlayerRecv::processPlayerStatUpdate1(Net::MessageIn &msg) -{ - BLOCK_START("PlayerRecv::processPlayerStatUpdate1") - const int type = msg.readInt16("type"); - const int value = msg.readInt32("value"); - if (localPlayer == nullptr) - { - BLOCK_END("PlayerRecv::processPlayerStatUpdate1") - return; - } - - playerHandler->setStat(msg, type, value, NoStat, Notify_true); - BLOCK_END("PlayerRecv::processPlayerStatUpdate1") -} - -void PlayerRecv::processPlayerStatUpdate2(Net::MessageIn &msg) -{ - BLOCK_START("PlayerRecv::processPlayerStatUpdate2") - const int type = msg.readInt16("type"); - const int value = msg.readInt32("value"); - playerHandler->setStat(msg, type, value, NoStat, Notify_true); - BLOCK_END("PlayerRecv::processPlayerStatUpdate2") -} - -void PlayerRecv::processPlayerStatUpdate3(Net::MessageIn &msg) -{ - BLOCK_START("PlayerRecv::processPlayerStatUpdate3") - const int type = msg.readInt32("type"); - const int base = msg.readInt32("base"); - const int bonus = msg.readInt32("bonus"); - - playerHandler->setStat(msg, type, base, bonus, Notify_false); - BLOCK_END("PlayerRecv::processPlayerStatUpdate3") -} - -void PlayerRecv::processPlayerStatUpdate4(Net::MessageIn &msg) -{ - BLOCK_START("PlayerRecv::processPlayerStatUpdate4") - const uint16_t type = msg.readInt16("type"); - const uint8_t ok = msg.readUInt8("flag"); - const int value = msg.readUInt8("value"); - - if (ok != 1) - { - const int oldValue = PlayerInfo::getStatBase( - static_cast<AttributesT>(type)); - const int points = PlayerInfo::getAttribute( - Attributes::PLAYER_CHAR_POINTS) + oldValue - value; - PlayerInfo::setAttribute(Attributes::PLAYER_CHAR_POINTS, points); - NotifyManager::notify(NotifyTypes::SKILL_RAISE_ERROR); - } - - playerHandler->setStat(msg, type, value, NoStat, Notify_true); - BLOCK_END("PlayerRecv::processPlayerStatUpdate4") -} - -void PlayerRecv::processPlayerStatUpdate6(Net::MessageIn &msg) -{ - BLOCK_START("PlayerRecv::processPlayerStatUpdate6") - const int type = msg.readInt16("type"); - const int value = msg.readUInt8("value"); - if (statusWindow != nullptr) - playerHandler->setStat(msg, type, value, NoStat, Notify_true); - BLOCK_END("PlayerRecv::processPlayerStatUpdate6") -} - -void PlayerRecv::processPlayerArrowMessage(Net::MessageIn &msg) -{ - BLOCK_START("PlayerRecv::processPlayerArrowMessage") - const int type = msg.readInt16("type"); - switch (type) - { - case 0: - NotifyManager::notify(NotifyTypes::ARROWS_EQUIP_NEEDED); - break; - case 3: - // arrows equiped - break; - default: - UNIMPLEMENTEDPACKETFIELD(type); - break; - } - BLOCK_END("PlayerRecv::processPlayerArrowMessage") -} - -void PlayerRecv::processMapMusic(Net::MessageIn &msg) -{ - const int size = msg.readInt16("len") - 4; - const std::string music = msg.readString(size, "name"); - soundManager.playMusic(music, - SkipError_false); - - Map *const map = viewport->getMap(); - if (map != nullptr) - map->setMusicFile(music); -} - -void PlayerRecv::processMapMask(Net::MessageIn &msg) -{ - const int mask = msg.readInt32("mask"); - msg.readInt32("unused"); - Map *const map = Game::instance()->getCurrentMap(); - if (map != nullptr) - map->setMask(mask); -} - -void PlayerRecv::processPlayerClientCommand(Net::MessageIn &msg) -{ - const int sz = msg.readInt16("len") - 4; - std::string command = msg.readString(sz, "command"); - std::string cmd; - std::string args; - - if (settings.awayMode || - settings.pseudoAwayMode || - !settings.enableRemoteCommands) - { - return; - } - - if (!parse2Str(command, cmd, args)) - { - cmd = STD_MOVE(command); - args.clear(); - } - inputManager.executeRemoteChatCommand(cmd, args, nullptr); -} - -} // namespace Ea diff --git a/src/net/ea/playerrecv.h b/src/net/ea/playerrecv.h deleted file mode 100644 index 8c0913b09..000000000 --- a/src/net/ea/playerrecv.h +++ /dev/null @@ -1,48 +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_EA_PLAYERRECV_H -#define NET_EA_PLAYERRECV_H - -namespace Net -{ - class MessageIn; -} // namespace Net - -namespace Ea -{ - namespace PlayerRecv - { - void processPlayerWarp(Net::MessageIn &msg); - void processPlayerStatUpdate1(Net::MessageIn &msg); - void processPlayerStatUpdate2(Net::MessageIn &msg); - void processPlayerStatUpdate3(Net::MessageIn &msg); - void processPlayerStatUpdate4(Net::MessageIn &msg); - void processPlayerStatUpdate6(Net::MessageIn &msg); - void processPlayerArrowMessage(Net::MessageIn &msg); - void processPlayerClientCommand(Net::MessageIn &msg); - void processMapMusic(Net::MessageIn &msg); - void processMapMask(Net::MessageIn &msg); - } // namespace PlayerRecv -} // namespace Ea - -#endif // NET_EA_PLAYERRECV_H diff --git a/src/net/ea/skillhandler.cpp b/src/net/ea/skillhandler.cpp deleted file mode 100644 index e44bc5609..000000000 --- a/src/net/ea/skillhandler.cpp +++ /dev/null @@ -1,34 +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/ea/skillhandler.h" - -#include "debug.h" - -namespace Ea -{ - -SkillHandler::SkillHandler() -{ -} - -} // namespace Ea diff --git a/src/net/ea/skillhandler.h b/src/net/ea/skillhandler.h deleted file mode 100644 index acda5e7ad..000000000 --- a/src/net/ea/skillhandler.h +++ /dev/null @@ -1,43 +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_EA_SKILLHANDLER_H -#define NET_EA_SKILLHANDLER_H - -#include "net/skillhandler.h" - -#include "localconsts.h" - -namespace Ea -{ - -class SkillHandler notfinal : public Net::SkillHandler -{ - public: - SkillHandler(); - - A_DELETE_COPY(SkillHandler) -}; - -} // namespace Ea - -#endif // NET_EA_SKILLHANDLER_H diff --git a/src/net/ea/skillrecv.cpp b/src/net/ea/skillrecv.cpp deleted file mode 100644 index 58a083478..000000000 --- a/src/net/ea/skillrecv.cpp +++ /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/>. - */ - -#include "net/ea/skillrecv.h" - -#include "being/playerinfo.h" - -#include "gui/windows/skilldialog.h" - -#include "net/messagein.h" - -#include "debug.h" - -namespace Ea -{ - -void SkillRecv::processPlayerSkillUp(Net::MessageIn &msg) -{ - const int skillId = msg.readInt16("skill id"); - const int level = msg.readInt16("skill level"); - const int sp = msg.readInt16("sp"); - const int range = msg.readInt16("range"); - const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable); - - if (skillDialog != nullptr && PlayerInfo::getSkillLevel(skillId) != level) - skillDialog->playUpdateEffect(skillId); - PlayerInfo::setSkillLevel(skillId, level); - if (skillDialog != nullptr) - { - if (!skillDialog->updateSkill(skillId, range, - up, SkillType::Unknown, sp)) - { - skillDialog->addSkill(SkillOwner::Player, - skillId, "", level, - range, up, SkillType::Unknown, sp); - } - } -} - -} // namespace Ea diff --git a/src/net/ea/skillrecv.h b/src/net/ea/skillrecv.h deleted file mode 100644 index de4fe1112..000000000 --- a/src/net/ea/skillrecv.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_EA_SKILLRECV_H -#define NET_EA_SKILLRECV_H - -#include "localconsts.h" - -namespace Net -{ - class MessageIn; -} // namespace Net - -namespace Ea -{ - namespace SkillRecv - { - void processPlayerSkillUp(Net::MessageIn &msg); - } // namespace SkillRecv -} // namespace Ea - -#endif // NET_EA_SKILLRECV_H diff --git a/src/net/ea/token.h b/src/net/ea/token.h deleted file mode 100644 index 1e8f72c8d..000000000 --- a/src/net/ea/token.h +++ /dev/null @@ -1,54 +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_EA_TOKEN_H -#define NET_EA_TOKEN_H - -#include "enums/simpletypes/beingid.h" -#include "enums/being/gender.h" - -struct Token final -{ - Token() : - account_ID(BeingId_zero), - session_ID1(0), - session_ID2(0), - sex(Gender::UNSPECIFIED) - { } - - A_DELETE_COPY(Token) - - BeingId account_ID; - int session_ID1; - int session_ID2; - GenderT sex; - - void clear() - { - account_ID = BeingId_zero; - session_ID1 = 0; - session_ID2 = 0; - sex = Gender::UNSPECIFIED; - } -}; - -#endif // NET_EA_TOKEN_H diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp deleted file mode 100644 index a56136b3d..000000000 --- a/src/net/ea/tradehandler.cpp +++ /dev/null @@ -1,51 +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/ea/tradehandler.h" - -#include "listeners/requesttradelistener.h" - -#include "debug.h" - -/** - * Listener for request trade dialogs - */ -namespace -{ - RequestTradeListener listener; -} // namespace - -namespace Ea -{ - -TradeHandler::TradeHandler() : - Net::TradeHandler() -{ - confirmDlg = nullptr; -} - -void TradeHandler::removeItem(const int slotNum A_UNUSED, - const int amount A_UNUSED) const -{ -} - -} // namespace Ea diff --git a/src/net/ea/tradehandler.h b/src/net/ea/tradehandler.h deleted file mode 100644 index 0a350bd46..000000000 --- a/src/net/ea/tradehandler.h +++ /dev/null @@ -1,44 +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_EA_TRADEHANDLER_H -#define NET_EA_TRADEHANDLER_H - -#include "net/tradehandler.h" - -namespace Ea -{ - -class TradeHandler notfinal : public Net::TradeHandler -{ - public: - TradeHandler(); - - A_DELETE_COPY(TradeHandler) - - void removeItem(const int slotNum, - const int amount) const override final A_CONST; -}; - -} // namespace Ea - -#endif // NET_EA_TRADEHANDLER_H diff --git a/src/net/ea/traderecv.cpp b/src/net/ea/traderecv.cpp deleted file mode 100644 index d47fc256b..000000000 --- a/src/net/ea/traderecv.cpp +++ /dev/null @@ -1,184 +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/ea/traderecv.h" - -#include "notifymanager.h" - -#include "being/playerinfo.h" -#include "being/playerrelation.h" - -#include "enums/resources/notifytypes.h" - -#include "gui/windows/tradewindow.h" - -#include "gui/widgets/createwidget.h" - -#include "net/messagein.h" - -#include "utils/gettext.h" -#include "utils/stringutils.h" - -#include "listeners/requesttradelistener.h" - -#include "debug.h" - - -ConfirmDialog *confirmDlg = nullptr; - -/** - * Listener for request trade dialogs - */ -namespace -{ - RequestTradeListener listener; -} // namespace - -namespace Ea -{ - -void TradeRecv::processTradeResponseContinue(const uint8_t type) -{ - switch (type) - { - case 0: // Too far away - NotifyManager::notify(NotifyTypes::TRADE_FAIL_FAR_AWAY, - tradePartnerName); - break; - case 1: // Character doesn't exist - NotifyManager::notify(NotifyTypes::TRADE_FAIL_CHAR_NOT_EXISTS, - tradePartnerName); - break; - case 2: // Invite request check failed... - NotifyManager::notify(NotifyTypes::TRADE_CANCELLED_ERROR); - break; - case 3: // Trade accepted - if (tradeWindow != nullptr) - { - tradeWindow->reset(); - // TRANSLATORS: trade header - tradeWindow->setCaption(strprintf(_("Trade: You and %s"), - tradePartnerName.c_str())); - tradeWindow->initTrade(tradePartnerName); - tradeWindow->setVisible(Visible_true); - } - break; - case 4: // Trade cancelled - if (playerRelations.hasPermission(tradePartnerName, - PlayerRelation::SPEECH_LOG)) - { - NotifyManager::notify(NotifyTypes::TRADE_CANCELLED_NAME, - tradePartnerName); - } - // otherwise ignore silently - - if (tradeWindow != nullptr) - { - tradeWindow->setVisible(Visible_false); -// tradeWindow->clear(); - } - PlayerInfo::setTrading(Trading_false); - break; - case 5: - NotifyManager::notify(NotifyTypes::TRADE_CANCELLED_BUSY, - tradePartnerName); - break; - default: // Shouldn't happen as well, but to be sure - NotifyManager::notify(NotifyTypes::TRADE_ERROR_UNKNOWN, - tradePartnerName); - if (tradeWindow != nullptr) - tradeWindow->clear(); - break; - } -} - -void TradeRecv::processTradeOk(Net::MessageIn &msg) -{ - // 0 means ok from myself, 1 means ok from other; - if (tradeWindow != nullptr) - tradeWindow->receivedOk(msg.readUInt8("status") == 0U); - else - msg.readUInt8("status"); -} - -void TradeRecv::processTradeCancel(Net::MessageIn &msg A_UNUSED) -{ - NotifyManager::notify(NotifyTypes::TRADE_CANCELLED); - if (tradeWindow != nullptr) - { - tradeWindow->setVisible(Visible_false); - tradeWindow->reset(); - } - PlayerInfo::setTrading(Trading_false); -} - -void TradeRecv::processTradeComplete(Net::MessageIn &msg A_UNUSED) -{ - NotifyManager::notify(NotifyTypes::TRADE_COMPLETE); - if (tradeWindow != nullptr) - tradeWindow->completeTrade(); - PlayerInfo::setTrading(Trading_false); -} - -void TradeRecv::processTradeRequestContinue(const std::string &partner) -{ - if (playerRelations.hasPermission(partner, - PlayerRelation::TRADE)) - { - if (PlayerInfo::isTrading() == Trading_true || (confirmDlg != nullptr)) - { - tradeHandler->respond(false); - return; - } - - tradePartnerName = partner; - PlayerInfo::setTrading(Trading_true); - if (tradeWindow != nullptr) - { - if (tradePartnerName.empty() || tradeWindow->getAutoTradeNick() - != tradePartnerName) - { - tradeWindow->clear(); - CREATEWIDGETV(confirmDlg, ConfirmDialog, - // TRANSLATORS: trade message - _("Request for Trade"), - // TRANSLATORS: trade message - strprintf(_("%s wants to trade with you, do" - " you accept?"), tradePartnerName.c_str()), - SOUND_REQUEST, - true); - confirmDlg->addActionListener(&listener); - } - else - { - tradeHandler->respond(true); - } - } - } - else - { - tradeHandler->respond(false); - return; - } -} - -} // namespace Ea diff --git a/src/net/ea/traderecv.h b/src/net/ea/traderecv.h deleted file mode 100644 index ce8176bf3..000000000 --- a/src/net/ea/traderecv.h +++ /dev/null @@ -1,53 +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_EA_TRADERECV_H -#define NET_EA_TRADERECV_H - -#if defined(__GXX_EXPERIMENTAL_CXX0X__) -#if defined(__APPLE__) -#include <tr1/cstdint> -#endif // defined(__APPLE__) -#else // defined(__GXX_EXPERIMENTAL_CXX0X__) -#include <stdint.h> -#endif // defined(__GXX_EXPERIMENTAL_CXX0X__) - -#include <string> - -namespace Net -{ - class MessageIn; -} // namespace Net - -namespace Ea -{ - namespace TradeRecv - { - void processTradeOk(Net::MessageIn &msg); - void processTradeCancel(Net::MessageIn &msg); - void processTradeComplete(Net::MessageIn &msg); - void processTradeRequestContinue(const std::string &partner); - void processTradeResponseContinue(const uint8_t type); - } // namespace TradeRecv -} // namespace Ea - -#endif // NET_EA_TRADERECV_H |