From 12475ef9c26e71396026c2a803b648050030db9a Mon Sep 17 00:00:00 2001 From: Flerp Date: Sat, 1 Nov 2025 17:17:33 -0700 Subject: [PATCH] reverting to base module --- src/mod_autofish.cpp | 50 ++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/src/mod_autofish.cpp b/src/mod_autofish.cpp index c19c4fb..4f2eebf 100644 --- a/src/mod_autofish.cpp +++ b/src/mod_autofish.cpp @@ -2,19 +2,16 @@ #include "Player.h" #include "GameObject.h" #include "ObjectAccessor.h" +#include "GridNotifiers.h" +#include "CellImpl.h" #include "Config.h" -#include "LootMgr.h" -#include -#include -#include -#include namespace { + std::vector sBobberEntries; bool sEnabled = true; uint32 sTickMs = 200; float sScanRange = 30.0f; - std::vector sBobberEntries; std::vector ParseEntryList(std::string const& csv) { @@ -23,48 +20,47 @@ namespace std::string item; while (std::getline(ss, item, ',')) { - item.erase(0, item.find_first_not_of(" \t\r\n")); - item.erase(item.find_last_not_of(" \t\r\n") + 1); + auto trim = [](std::string& s) + { + s.erase(0, s.find_first_not_of(" \t\r\n")); + s.erase(s.find_last_not_of(" \t\r\n") + 1); + }; + trim(item); if (!item.empty()) - out.push_back(uint32(std::stoul(item))); + out.push_back(static_cast(std::stoul(item))); } return out; } - void TryAutoFish(Player* plr) + void TryAutoLootNearbyBobber(Player* plr) { if (!plr || !plr->IsInWorld()) return; - std::list nearList; - for (auto entry : sBobberEntries) - plr->GetGameObjectListWithEntryInGrid(nearList, entry, sScanRange); + std::list goList; + Acore::AllGameObjectsMatchingOneEntryInRange check(plr, sBobberEntries, sScanRange); + Acore::GameObjectListSearcher searcher(plr, goList, check); + Cell::VisitObjects(plr, searcher, sScanRange); - for (GameObject* go : nearList) + for (GameObject* go : goList) { - if (!go || go->GetOwnerGUID() != plr->GetGUID()) + if (!go) + continue; + if (go->GetOwnerGUID() != plr->GetGUID()) continue; - if (go->getLootState() == GO_READY) { plr->SendLoot(go->GetGUID(), LOOT_FISHING); - - Loot* loot = &go->loot; - for (uint32 i = 0; i < loot->items.size(); ++i) - plr->StoreLootItem(i, loot); - - plr->SendLootRelease(go->GetGUID()); - go->SetLootState(GO_JUST_DEACTIVATED); return; } } } } -class AutoFish_WorldScript : public WorldScript +class AutoFish_WorldUpdate : public WorldScript { public: - AutoFish_WorldScript() : WorldScript("AutoFish_WorldScript") {} + AutoFish_WorldUpdate() : WorldScript("AutoFish_WorldUpdate") {} void OnAfterConfigLoad(bool) override { @@ -91,12 +87,12 @@ public: Player* plr = kv.second; if (!plr || !plr->IsInWorld() || plr->IsGameMaster()) continue; - TryAutoFish(plr); + TryAutoLootNearbyBobber(plr); } } }; void AddSC_autofish_world() { - new AutoFish_WorldScript(); + new AutoFish_WorldUpdate(); }