From e22f6d0070ea2b0102caf3b738fba703606e6bd4 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 24 Aug 2016 01:28:28 +0300 Subject: First step of removing local pets (tmwa only). --- src/actormanager.cpp | 6 -- src/being/being.cpp | 230 ----------------------------------------- src/being/being.h | 12 --- src/enums/being/actortype.h | 3 - src/game.cpp | 3 - src/gui/popups/popupmenu.cpp | 6 -- src/gui/viewport.cpp | 9 -- src/gui/windows/chatwindow.cpp | 98 +----------------- src/gui/windows/chatwindow.h | 15 --- src/gui/windows/minimap.cpp | 3 - src/net/ea/playerrecv.cpp | 3 - src/net/eathena/beingrecv.cpp | 9 -- src/net/tmwa/pethandler.cpp | 21 +--- 13 files changed, 10 insertions(+), 408 deletions(-) (limited to 'src') diff --git a/src/actormanager.cpp b/src/actormanager.cpp index be9f6e7a6..b995bde47 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -309,9 +309,6 @@ Being *ActorManager::createBeing(const BeingId id, break; default: case ActorType::FloorItem: -#ifdef TMWA_SUPPORT - case ActorType::LocalPet: -#endif case ActorType::Avatar: case ActorType::Unknown: reportAlways("CreateBeing for unknown type %d", CAST_S32(type)); @@ -604,9 +601,6 @@ void ActorManager::findBeingsByPixel(std::vector &beings, case ActorType::Player: case ActorType::Npc: case ActorType::Monster: -#ifdef TMWA_SUPPORT - case ActorType::LocalPet: -#endif case ActorType::Pet: case ActorType::Mercenary: case ActorType::Homunculus: diff --git a/src/being/being.cpp b/src/being/being.cpp index d49c71195..f82fc4dfe 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -294,9 +294,6 @@ Being::Being(const BeingId id, case ActorType::Npc: case ActorType::Monster: case ActorType::FloorItem: -#ifdef TMWA_SUPPORT - case ActorType::LocalPet: -#endif case ActorType::Avatar: break; } @@ -342,15 +339,6 @@ Being::~Being() delete2(mChat); removeHorse(); - if (mOwner) - { -#ifdef TMWA_SUPPORT - if (mType == ActorType::LocalPet) - mOwner->unassignPet(this); -#endif - - mOwner = nullptr; - } FOR_EACH (std::vector::iterator, it, mPets) { Being *pet = *it; @@ -471,29 +459,6 @@ void Being::setSubtype(const BeingTypeId subtype, if (mInfo) setupSpriteDisplay(mInfo->getDisplay(), ForceDisplay_false); break; -#ifdef TMWA_SUPPORT - case ActorType::LocalPet: - mInfo = PETDB::get(fromInt(mId, BeingTypeId)); - if (mInfo) - { - setName(mInfo->getName()); - setupSpriteDisplay(mInfo->getDisplay(), ForceDisplay_false); - mYDiff = mInfo->getSortOffsetY(); - const int speed = mInfo->getWalkSpeed(); - if (!speed) - { - if (playerHandler) - setWalkSpeed(playerHandler->getDefaultWalkSpeed()); - else - setWalkSpeed(1); - } - else - { - setWalkSpeed(speed); - } - } - break; -#endif case ActorType::Player: { int id = -100 - toInt(subtype, int); @@ -2455,13 +2420,6 @@ void Being::updateColors() setDefaultNameColor(UserColorId::SKILLUNIT); mTextColor = &userPalette->getColor(UserColorId::SKILLUNIT); } -#ifdef TMWA_SUPPORT - else if (mType == ActorType::LocalPet) - { - setDefaultNameColor(UserColorId::PET); - mTextColor = &userPalette->getColor(UserColorId::PET); - } -#endif else if (this == localPlayer) { mNameColor = &userPalette->getColor(UserColorId::SELF); @@ -2565,17 +2523,7 @@ void Being::setSpriteId(const unsigned int slot, const int id1 = mSlots[slot].spriteId; if (id1) - { - const ItemInfo &info = ItemDB::get(id1); - if (mMap && - mType == ActorType::Player) - { - const BeingId pet = fromInt(info.getPet(), BeingId); - if (pet != BeingId_zero) - removePet(pet); - } removeItemParticles(id1); - } } else { @@ -2586,15 +2534,6 @@ void Being::setSpriteId(const unsigned int slot, int startTime = 0; AnimatedSprite *restrict equipmentSprite = nullptr; -#ifdef TMWA_SUPPORT - if (mType == ActorType::Player) - { - const BeingId pet = fromInt(info.getPet(), BeingId); - if (pet != BeingId_zero) - addPet(pet); - } -#endif - if (!filename.empty()) { equipmentSprite = AnimatedSprite::delayedLoad( @@ -2652,17 +2591,7 @@ void Being::unSetSprite(const unsigned int slot) restrict2 BeingSlot &beingSlot = mSlots[slot]; const int id1 = beingSlot.spriteId; if (id1) - { - const ItemInfo &info = ItemDB::get(id1); - if (mMap && - mType == ActorType::Player) - { - const BeingId pet = fromInt(info.getPet(), BeingId); - if (pet != BeingId_zero) - removePet(pet); - } removeItemParticles(id1); - } beingSlot.spriteId = 0; beingSlot.color = std::string(); @@ -2699,17 +2628,7 @@ void Being::setSpriteColor(const unsigned int slot, const int id1 = mSlots[slot].spriteId; if (id1) - { - const ItemInfo &info = ItemDB::get(id1); - if (mMap && - mType == ActorType::Player) - { - const BeingId pet = fromInt(info.getPet(), BeingId); - if (pet != BeingId_zero) - removePet(pet); - } removeItemParticles(id1); - } } else { @@ -2720,15 +2639,6 @@ void Being::setSpriteColor(const unsigned int slot, int startTime = 0; AnimatedSprite *restrict equipmentSprite = nullptr; -#ifdef TMWA_SUPPORT - if (mType == ActorType::Player) - { - const BeingId pet = fromInt(info.getPet(), BeingId); - if (pet != BeingId_zero) - addPet(pet); - } -#endif - if (!filename.empty()) { equipmentSprite = AnimatedSprite::delayedLoad( @@ -2797,17 +2707,7 @@ void Being::setSpriteColorId(const unsigned int slot, const int id1 = mSlots[slot].spriteId; if (id1) - { - const ItemInfo &info = ItemDB::get(id1); - if (mMap && - mType == ActorType::Player) - { - const BeingId pet = fromInt(info.getPet(), BeingId); - if (pet != BeingId_zero) - removePet(pet); - } removeItemParticles(id1); - } } else { @@ -2818,15 +2718,6 @@ void Being::setSpriteColorId(const unsigned int slot, int startTime = 0; AnimatedSprite *restrict equipmentSprite = nullptr; -#ifdef TMWA_SUPPORT - if (mType == ActorType::Player) - { - const BeingId pet = fromInt(info.getPet(), BeingId); - if (pet != BeingId_zero) - addPet(pet); - } -#endif - if (!filename.empty()) { color = info.getDyeColorsString(colorId); @@ -2897,17 +2788,7 @@ void Being::setSpriteCards(const unsigned int slot, const int id1 = mSlots[slot].spriteId; if (id1) - { - const ItemInfo &info = ItemDB::get(id1); - if (mMap && - mType == ActorType::Player) - { - const BeingId pet = fromInt(info.getPet(), BeingId); - if (pet != BeingId_zero) - removePet(pet); - } removeItemParticles(id1); - } } else { @@ -2918,15 +2799,6 @@ void Being::setSpriteCards(const unsigned int slot, int startTime = 0; AnimatedSprite *restrict equipmentSprite = nullptr; -#ifdef TMWA_SUPPORT - if (mType == ActorType::Player) - { - const BeingId pet = fromInt(info.getPet(), BeingId); - if (pet != BeingId_zero) - addPet(pet); - } -#endif - if (!cards.isEmpty()) colorId = ItemColorManager::getColorFromCards(cards); @@ -3682,9 +3554,6 @@ void Being::draw(Graphics *restrict const graphics, case ActorType::Unknown: case ActorType::Npc: case ActorType::FloorItem: -#ifdef TMWA_SUPPORT - case ActorType::LocalPet: -#endif case ActorType::Avatar: default: drawOther(graphics, @@ -4531,9 +4400,6 @@ std::string Being::loadComment(const std::string &restrict name, case ActorType::Monster: case ActorType::FloorItem: case ActorType::Portal: -#ifdef TMWA_SUPPORT - case ActorType::LocalPet: -#endif case ActorType::Avatar: case ActorType::Mercenary: case ActorType::Homunculus: @@ -4571,9 +4437,6 @@ void Being::saveComment(const std::string &restrict name, case ActorType::Monster: case ActorType::FloorItem: case ActorType::Portal: -#ifdef TMWA_SUPPORT - case ActorType::LocalPet: -#endif case ActorType::Avatar: case ActorType::Unknown: case ActorType::Pet: @@ -4780,33 +4643,6 @@ void Being::addEffect(const std::string &restrict name) restrict2 paths.getStringValue("sprites") + name); } -#ifdef TMWA_SUPPORT -void Being::addPet(const BeingId id) restrict2 -{ - if (!actorManager || !config.getBoolValue("usepets")) - return; - - Being *restrict const pet = findChildPet(id); - if (pet) - { - pet->incUsage(); - return; - } - - Being *const being = actorManager->createBeing( - id, ActorType::LocalPet, BeingTypeId_zero); - if (being) - { - being->setOwner(this); - mPets.push_back(being); - int dstX = mX; - int dstY = mY; - being->fixPetSpawnPos(dstX, dstY); - being->setTileCoords(dstX, dstY); - } -} -#endif - Being *Being::findChildPet(const BeingId id) restrict2 { FOR_EACH (std::vector::iterator, it, mPets) @@ -4818,72 +4654,6 @@ Being *Being::findChildPet(const BeingId id) restrict2 return nullptr; } -void Being::removePet(const BeingId id) restrict2 -{ - if (!actorManager) - return; - - FOR_EACH (std::vector::iterator, it, mPets) - { - Being *restrict const pet = *it; - if (pet && pet->mId == id) - { - if (!pet->decUsage()) - { - pet->setOwner(nullptr); - actorManager->erase(pet); - mPets.erase(it); - delete pet; - return; - } - } - } -} - -void Being::removeAllPets() restrict2 -{ - FOR_EACH (std::vector::iterator, it, mPets) - { - Being *restrict const pet = *it; - if (pet) - { - pet->setOwner(nullptr); - actorManager->erase(pet); - delete pet; - } - } - mPets.clear(); -} - -#ifdef TMWA_SUPPORT -void Being::updatePets() restrict2 -{ - removeAllPets(); - FOR_EACH (std::vector::const_iterator, it, mSlots) - { - const int id = (*it).spriteId; - if (!id) - continue; - const ItemInfo &restrict info = ItemDB::get(id); - const BeingId pet = fromInt(info.getPet(), BeingId); - if (pet != BeingId_zero) - addPet(pet); - } -} -#endif - -void Being::unassignPet(const Being *restrict const pet1) restrict2 -{ - FOR_EACH (std::vector::iterator, it, mPets) - { - if (*it == pet1) - { - mPets.erase(it); - return; - } - } -} - void Being::fixPetSpawnPos(int &restrict dstX, int &restrict dstY) const { diff --git a/src/being/being.h b/src/being/being.h index 49242a8c4..7a52df675 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -892,14 +892,6 @@ class Being notfinal : public ActorSprite, void addEffect(const std::string &restrict name) restrict2; -#ifdef TMWA_SUPPORT - void addPet(const BeingId id) restrict2; - - void updatePets() restrict2; -#endif - - void removePet(const BeingId id) restrict2; - void fixPetSpawnPos(int &restrict dstX, int &restrict dstY) const restrict2; @@ -915,10 +907,6 @@ class Being notfinal : public ActorSprite, Being *getOwner() const restrict2 noexcept2 { return mOwner; } - void unassignPet(const Being *restrict const pet) restrict2; - - void removeAllPets() restrict2; - Being *findChildPet(const BeingId id) restrict2; void playSfx(const SoundInfo &sound, diff --git a/src/enums/being/actortype.h b/src/enums/being/actortype.h index 949355933..8e2182e77 100644 --- a/src/enums/being/actortype.h +++ b/src/enums/being/actortype.h @@ -32,9 +32,6 @@ enumStart(ActorType) Monster, FloorItem, Portal, -#ifdef TMWA_SUPPORT - LocalPet, -#endif Avatar, Pet, Mercenary, diff --git a/src/game.cpp b/src/game.cpp index 27f4a5e5d..e29eec872 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -433,9 +433,6 @@ Game::Game() : #ifdef TMWA_SUPPORT if (guildManager && GuildManager::getEnableGuildBot()) guildManager->requestGuildInfo(); - - if (localPlayer) - localPlayer->updatePets(); #endif settings.disableLoggingInGame = config.getBoolValue( diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index 28034b9be..16886bb70 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -432,9 +432,6 @@ void PopupMenu::showPopup(const int x, const int y, const Being *const being) case ActorType::FloorItem: case ActorType::Portal: case ActorType::Elemental: -#ifdef TMWA_SUPPORT - case ActorType::LocalPet: -#endif default: break; } @@ -3313,9 +3310,6 @@ void PopupMenu::showGMPopup(const std::string &name) showItemGMCommands(); break; case ActorType::Portal: -#ifdef TMWA_SUPPORT - case ActorType::LocalPet: -#endif case ActorType::Avatar: case ActorType::Elemental: break; diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index d4b160068..ba42ee2a2 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -488,9 +488,6 @@ bool Viewport::leftMouseAction() case ActorType::Elemental: break; case ActorType::Unknown: -#ifdef TMWA_SUPPORT - case ActorType::LocalPet: -#endif case ActorType::Avatar: default: reportAlways("Left click on unknown actor type: %d", @@ -919,9 +916,6 @@ void Viewport::mouseMoved(MouseEvent &event) || type == ActorType::Npc || type == ActorType::Homunculus || type == ActorType::Mercenary -#ifdef TMWA_SUPPORT - || type == ActorType::LocalPet -#endif || type == ActorType::Pet)) { popupManager->hideTextPopup(); @@ -978,9 +972,6 @@ void Viewport::mouseMoved(MouseEvent &event) case ActorType::Npc: case ActorType::Monster: case ActorType::Portal: -#ifdef TMWA_SUPPORT - case ActorType::LocalPet: -#endif case ActorType::Pet: case ActorType::Mercenary: case ActorType::Homunculus: diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 6685852fb..85284d4a2 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -1611,32 +1611,19 @@ bool ChatWindow::resortChatLog(std::string line, { if (line.find(": \302\202\302e") != std::string::npos) { - const std::string nick = line.substr(0, idx2 - 1); - line = line.substr(idx2 + 6); - localPetEmote(nick, CAST_U8( - atoi(line.c_str()))); + // Do nothing. Before was local pet emote } else if (line.find(": \302\202\302m") != std::string::npos) { - const std::string nick = line.substr(0, idx2 - 1); - line = line.substr(idx2 + 6); - int x = 0; - int y = 0; - if (parse2Int(line, x, y)) - localPetMove(nick, x, y); + // Do nothing. Before was local pet move } else if (line.find(": \302\202\302d") != std::string::npos) { - const std::string nick = line.substr(0, idx2 - 1); - line = line.substr(idx2 + 6); - localPetDirection(nick, CAST_U8( - atoi(line.c_str()))); + // Do nothing. Before was local pet direction } else if (line.find(": \302\202\302a") != std::string::npos) { - const std::string nick = line.substr(0, idx2 - 1); - line = line.substr(idx2 + 6); - localPetAi(nick, atoi(line.c_str()) ? true : false); + // Do nothing. Before was local pet ai enable/disable } // ignore other special message formats. return false; @@ -1645,13 +1632,7 @@ bool ChatWindow::resortChatLog(std::string line, // pet talk message detected if (line.find(": \302\202\303 ") != std::string::npos) { - if (actorManager && idx2 > 1) - { - const std::string nick = line.substr(0, idx2 - 1); - line = line.substr(idx2 + 6); - localPetSay(nick, line); - } - + // Do nothing. Before was local pet talk return false; } @@ -1750,75 +1731,6 @@ void ChatWindow::channelChatLog(const std::string &channel, tab->chatLog(line, own, ignoreRecord, tryRemoveColors); } -static Being *getPetForNick(const std::string &nick) -{ - Being *const being = actorManager->findBeingByName( - nick, ActorType::Player); - if (being) - return being->getFirstPet(); - return nullptr; -} - -void ChatWindow::localPetSay(const std::string &nick, const std::string &text) -{ - Being *const pet = getPetForNick(nick); - if (pet) - pet->setSpeech(text, GENERAL_CHANNEL); - - if (!localChatTab) - return; - if (pet) - { - // TRANSLATORS: owners pet name. For example: 4144's pet - localChatTab->chatLog(strprintf(_("%s's pet"), nick.c_str()), text); - } - else - { - localChatTab->chatLog(nick, text); - } -} - -void ChatWindow::localPetEmote(const std::string &nick, const uint8_t emoteId) -{ - Being *const pet = getPetForNick(nick); - if (pet) - pet->setEmote(emoteId, 0); -} - -void ChatWindow::localPetAi(const std::string &nick, const bool start) -{ - Being *const pet = getPetForNick(nick); - if (pet) - { - if (start) - pet->enablePetAi(); - else - pet->disablePetAi(); - } -} - -void ChatWindow::localPetMove(const std::string &nick, - const int x, const int y) -{ - Being *const pet = getPetForNick(nick); - if (pet) - { - pet->setDestination(x, y); - pet->disablePetAi(); - } -} - -void ChatWindow::localPetDirection(const std::string &nick, - uint8_t dir) -{ - Being *const pet = getPetForNick(nick); - if (pet) - { - pet->setDirection(dir); - pet->disablePetAi(); - } -} - void ChatWindow::initTradeFilter() { const std::string tradeListName = settings.serverConfigDir diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h index 5032d337a..78d87eb6d 100644 --- a/src/gui/windows/chatwindow.h +++ b/src/gui/windows/chatwindow.h @@ -302,21 +302,6 @@ class ChatWindow final : public Window, const int oldVal1, const int oldVal2) override final; - static void localPetSay(const std::string &nick, - const std::string &text); - - static void localPetEmote(const std::string &nick, - const uint8_t emoteId); - - static void localPetMove(const std::string &nick, - const int x, const int y); - - static void localPetDirection(const std::string &nick, - uint8_t dir); - - static void localPetAi(const std::string &nick, - const bool start); - void postConnection(); void showGMTab(); diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp index d21700455..24cf57743 100644 --- a/src/gui/windows/minimap.cpp +++ b/src/gui/windows/minimap.cpp @@ -355,9 +355,6 @@ void Minimap::draw2(Graphics *const graphics) type = UserColorId::PORTAL_HIGHLIGHT; break; -#ifdef TMWA_SUPPORT - case ActorType::LocalPet: -#endif case ActorType::Pet: type = UserColorId::PET; break; diff --git a/src/net/ea/playerrecv.cpp b/src/net/ea/playerrecv.cpp index c8ebd6651..8eed1ad4b 100644 --- a/src/net/ea/playerrecv.cpp +++ b/src/net/ea/playerrecv.cpp @@ -120,9 +120,6 @@ void PlayerRecv::processPlayerWarp(Net::MessageIn &msg) localPlayer->setAction(BeingAction::STAND, 0); localPlayer->setTileCoords(x, y); -#ifdef TMWA_SUPPORT - localPlayer->updatePets(); -#endif localPlayer->navigateClean(); localPlayer->reset(); } diff --git a/src/net/eathena/beingrecv.cpp b/src/net/eathena/beingrecv.cpp index 1fc49deaf..cc744e18d 100644 --- a/src/net/eathena/beingrecv.cpp +++ b/src/net/eathena/beingrecv.cpp @@ -451,9 +451,6 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg) case ActorType::Elemental: break; case ActorType::FloorItem: -#ifdef TMWA_SUPPORT - case ActorType::LocalPet: -#endif case ActorType::Avatar: case ActorType::Unknown: reportAlways("Wrong being type detected: %d", @@ -671,9 +668,6 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg) case ActorType::Elemental: break; case ActorType::FloorItem: -#ifdef TMWA_SUPPORT - case ActorType::LocalPet: -#endif case ActorType::Avatar: case ActorType::Unknown: reportAlways("Wrong being type detected: %d", @@ -887,9 +881,6 @@ void BeingRecv::processBeingSpawn(Net::MessageIn &msg) case ActorType::Elemental: break; case ActorType::FloorItem: -#ifdef TMWA_SUPPORT - case ActorType::LocalPet: -#endif case ActorType::Avatar: case ActorType::Unknown: reportAlways("Wrong being type detected: %d", diff --git a/src/net/tmwa/pethandler.cpp b/src/net/tmwa/pethandler.cpp index 7748a4385..4f82a6e59 100644 --- a/src/net/tmwa/pethandler.cpp +++ b/src/net/tmwa/pethandler.cpp @@ -41,10 +41,9 @@ PetHandler::PetHandler() : } void PetHandler::move(const int petId A_UNUSED, - const int x, const int y) const + const int x A_UNUSED, + const int y A_UNUSED) const { - chatHandler->talk(strprintf("\302\202\302m%d,%dg%d", - x, y, tick_time), GENERAL_CHANNEL); } void PetHandler::spawn(const Being *const being A_UNUSED, @@ -53,15 +52,9 @@ void PetHandler::spawn(const Being *const being A_UNUSED, { } -void PetHandler::emote(const uint8_t emoteId, +void PetHandler::emote(const uint8_t emoteId A_UNUSED, const int petId A_UNUSED) { - mRandCounter ++; - if (mRandCounter > 10000) - mRandCounter = 1000; - - chatHandler->talk(strprintf("\302\202\302e%dz%d", - CAST_S32(emoteId), mRandCounter), GENERAL_CHANNEL); } void PetHandler::catchPet(const Being *const being A_UNUSED) const @@ -96,16 +89,12 @@ void PetHandler::unequip() const { } -void PetHandler::setDirection(const unsigned char type) const +void PetHandler::setDirection(const unsigned char type A_UNUSED) const { - chatHandler->talk(strprintf("\302\202\302d%dg%d", - CAST_S32(type), tick_time), GENERAL_CHANNEL); } -void PetHandler::startAi(const bool start) const +void PetHandler::startAi(const bool start A_UNUSED) const { - chatHandler->talk(strprintf("\302\202\302a%dg%d", - start ? 1 : 0, tick_time), GENERAL_CHANNEL); } } // namespace TmwAthena -- cgit v1.2.3-70-g09d2