Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Make dedicated GetFish function for fishing #5704

Merged
merged 1 commit into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/map/utils/fishingutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,7 @@ namespace fishingutils

if (PChar->getStorage(LOC_INVENTORY)->GetFreeSlotsCount() != 0)
{
CItemFish* Fish = dynamic_cast<CItemFish*>(itemutils::GetItem(FishID));
CItemFish* Fish = GetFish(FishID);

if (Fish == nullptr)
{
Expand Down Expand Up @@ -2885,6 +2885,18 @@ namespace fishingutils
}
}

CItemFish* GetFish(uint16 itemid)
{
CItem* PItem = itemutils::GetItemPointer(itemid);

if (PItem && FishList[itemid])
{
// CItemFish constructor uses `const CItem&` input so this is ok
return new CItemFish(*PItem);
}
return nullptr;
}

/************************************************************************
* *
* INITIALIZATION *
Expand Down
1 change: 1 addition & 0 deletions src/map/utils/fishingutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,7 @@ namespace fishingutils
fishresponse_t* FishingCheck(CCharEntity* PChar, uint8 fishingSkill, rod_t* rod, bait_t* bait, fishingarea_t* area);
catchresponse_t* ReelCheck(CCharEntity* PChar, fishresponse_t* response, rod_t* rod);
void FishingAction(CCharEntity* PChar, FISHACTION action, uint16 stamina, uint32 special);
CItemFish* GetFish(uint16 itemid); // creates a `new` CItemFish if possible

// Initialization
void LoadFishingMessages();
Expand Down
Loading