refactor(Core/Loot): Simplify GetFishLoot with for loop and merge Get… (#21217)
This commit is contained in:
@@ -1001,50 +1001,25 @@ void GameObject::Delete()
|
|||||||
AddObjectToRemoveList();
|
AddObjectToRemoveList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameObject::GetFishLoot(Loot* fishloot, Player* loot_owner)
|
void GameObject::GetFishLoot(Loot* fishLoot, Player* lootOwner, bool junk /*= false*/)
|
||||||
{
|
{
|
||||||
fishloot->clear();
|
fishLoot->clear();
|
||||||
|
|
||||||
uint32 zone, subzone;
|
uint32 zone, area;
|
||||||
uint32 defaultzone = 1;
|
uint32 defaultZone = 1;
|
||||||
GetZoneAndAreaId(zone, subzone);
|
GetZoneAndAreaId(zone, area);
|
||||||
|
|
||||||
// if subzone loot exist use it
|
uint16 lootMode = junk ? LOOT_MODE_JUNK_FISH : LOOT_MODE_DEFAULT;
|
||||||
fishloot->FillLoot(subzone, LootTemplates_Fishing, loot_owner, true, true);
|
// Check to fill loot in the order area - zone - defaultZone.
|
||||||
|
// This is because area and zone is not set in some places, like Off the coast of Storm Peaks.
|
||||||
// isLooted() returns true here if player is e.g. not eligible for any loot due to conditions
|
uint32 lootZones[] = { area, zone, defaultZone };
|
||||||
if (fishloot->empty() || fishloot->isLooted()) //use this becase if zone or subzone has set LOOT_MODE_JUNK_FISH,Even if no normal drop, fishloot->FillLoot return true. it wrong.
|
for (uint32 fillZone : lootZones)
|
||||||
{
|
{
|
||||||
//subzone no result,use zone loot
|
fishLoot->FillLoot(fillZone, LootTemplates_Fishing, lootOwner, true, true, lootMode);
|
||||||
fishloot->FillLoot(zone, LootTemplates_Fishing, loot_owner, true, true);
|
|
||||||
//use zone 1 as default, somewhere fishing got nothing,becase subzone and zone not set, like Off the coast of Storm Peaks.
|
|
||||||
// isLooted() returns true here if player is e.g. not eligible for any loot due to conditions
|
|
||||||
if (fishloot->empty() || fishloot->isLooted())
|
|
||||||
fishloot->FillLoot(defaultzone, LootTemplates_Fishing, loot_owner, true, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameObject::GetFishLootJunk(Loot* fishloot, Player* loot_owner)
|
// If the loot is filled and the loot is eligible, then we break out of the loop.
|
||||||
{
|
if (!fishLoot->empty() && !fishLoot->isLooted())
|
||||||
fishloot->clear();
|
break;
|
||||||
|
|
||||||
uint32 zone, subzone;
|
|
||||||
uint32 defaultzone = 1;
|
|
||||||
GetZoneAndAreaId(zone, subzone);
|
|
||||||
|
|
||||||
// if subzone loot exist use it
|
|
||||||
fishloot->FillLoot(subzone, LootTemplates_Fishing, loot_owner, true, true, LOOT_MODE_JUNK_FISH);
|
|
||||||
|
|
||||||
// isLooted() returns true here if player is e.g. not eligible for any loot due to conditions
|
|
||||||
if (fishloot->empty() || fishloot->isLooted()) //use this becase if zone or subzone has normal mask drop, then fishloot->FillLoot return true.
|
|
||||||
{
|
|
||||||
//use zone loot
|
|
||||||
fishloot->FillLoot(zone, LootTemplates_Fishing, loot_owner, true, true, LOOT_MODE_JUNK_FISH);
|
|
||||||
|
|
||||||
// isLooted() returns true here if player is e.g. not eligible for any loot due to conditions
|
|
||||||
if (fishloot->empty() || fishloot->isLooted())
|
|
||||||
//use zone 1 as default
|
|
||||||
fishloot->FillLoot(defaultzone, LootTemplates_Fishing, loot_owner, true, true, LOOT_MODE_JUNK_FISH);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -198,8 +198,7 @@ public:
|
|||||||
void Refresh();
|
void Refresh();
|
||||||
void DespawnOrUnsummon(Milliseconds delay = 0ms, Seconds forcedRespawnTime = 0s);
|
void DespawnOrUnsummon(Milliseconds delay = 0ms, Seconds forcedRespawnTime = 0s);
|
||||||
void Delete();
|
void Delete();
|
||||||
void GetFishLoot(Loot* loot, Player* loot_owner);
|
void GetFishLoot(Loot* fishLoot, Player* lootOwner, bool junk = false);
|
||||||
void GetFishLootJunk(Loot* loot, Player* loot_owner);
|
|
||||||
[[nodiscard]] GameobjectTypes GetGoType() const { return GameobjectTypes(GetByteValue(GAMEOBJECT_BYTES_1, 1)); }
|
[[nodiscard]] GameobjectTypes GetGoType() const { return GameobjectTypes(GetByteValue(GAMEOBJECT_BYTES_1, 1)); }
|
||||||
void SetGoType(GameobjectTypes type) { SetByteValue(GAMEOBJECT_BYTES_1, 1, type); }
|
void SetGoType(GameobjectTypes type) { SetByteValue(GAMEOBJECT_BYTES_1, 1, type); }
|
||||||
[[nodiscard]] GOState GetGoState() const { return GOState(GetByteValue(GAMEOBJECT_BYTES_1, 0)); }
|
[[nodiscard]] GOState GetGoState() const { return GOState(GetByteValue(GAMEOBJECT_BYTES_1, 0)); }
|
||||||
|
|||||||
@@ -7885,7 +7885,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type)
|
|||||||
if (loot_type == LOOT_FISHING)
|
if (loot_type == LOOT_FISHING)
|
||||||
go->GetFishLoot(loot, this);
|
go->GetFishLoot(loot, this);
|
||||||
else if (loot_type == LOOT_FISHING_JUNK)
|
else if (loot_type == LOOT_FISHING_JUNK)
|
||||||
go->GetFishLootJunk(loot, this);
|
go->GetFishLoot(loot, this, true);
|
||||||
|
|
||||||
if (go->GetGOInfo()->type == GAMEOBJECT_TYPE_CHEST && go->GetGOInfo()->chest.groupLootRules)
|
if (go->GetGOInfo()->type == GAMEOBJECT_TYPE_CHEST && go->GetGOInfo()->chest.groupLootRules)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user