- 0
[Mangos Zero] Segfault calling Player::CanStoreNewItem against offline Player instance
-
Recently Browsing 0 members
- No registered users viewing this page.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use
Question
mangolassi
Hello and hope you're all having a great holiday season!
I'm attempting to write a HandleCharacterAddItemCommand method in Level2.cpp which is capable of adding items to characters not currently logged in (accessible via CLI/SOAP).
In order to do this, I added an argument before the HItem/link/id is specified which takes the character name and attempts to fetch the appropriate instance of Player:
The rest of the method works nearly identically to the HandleAddItemCommand method in Level3.cpp.
problem:
When this line is executed, a segfault occurs:
So I looked at the code for CanStoreNewItem in Player.h:
So then it's back to Player.cpp to look at "InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item* pItem, bool swap, uint32* no_space_count) const". Near the bottom of the method, the crash is happening when the call to _CanStoreItem_InInventorySlots is made:
So I look there near the top of the method and find the call to GetItemByPos where the crash seems to originate from:
So I look in GetItemByPos:
GetItemByPos segfaults when attempting to access m_items[slot] in the following code (conditions within if statement evaluate to true and the "return m_items[slot]" line is where the segfault occurs:
Have I missed something while trying to fetch the player instance? Is it simply impossible to check player inventory when the player is not logged in? If not, is there a reasonable way to fake the player login for this purpose?
Thanks!
EDIT: This is based on the develop21 branch.
3 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.