EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development::Bug Reports (https://www.eqemulator.org/forums/forumdisplay.php?f=591)
-   -   Possible issue using GetItem() in SharedDatabase::SetStartingItems() (https://www.eqemulator.org/forums/showthread.php?t=36041)

Uleat 11-27-2012 05:00 PM

You could create a new character and then look at the inventory entry in the database before clicking enter world. At least you could verify what the initial
save value is.



EDIT: Another thing to look at is how SummonItem modifies its charges:

Code:

        ItemInst* inst = database.CreateItem(item, charges);
                if (inst) {
                        // Custom logic for SummonItem
                        if ((inst->GetCharges()==0))
                                inst->SetCharges(1);
                        if ((inst->GetCharges()>0))
                                inst->SetCharges(inst->GetCharges());
                <...>
                }

It creates the item first, and then goes back and modifies the inst charges.

Tabasco 11-27-2012 05:13 PM

There are already provisions for it in most places, but the loss occurs in Database::StoreCharacter(), which is called right after starting items are populated.

The charges field in the inventory table is unsigned and the item charges are written without any testing.

Code:

            MakeAnyLenString
            (
                &invquery,
                "INSERT INTO inventory SET "
                "charid=%0u, slotid=%0d, itemid=%0u, charges=%0d, color=%0u",
                charid, i, newinv->GetItem()->ID,
                newinv->GetCharges(), newinv->GetColor()
            );


Drajor 11-27-2012 06:12 PM

Quote:

Originally Posted by Caryatis (Post 214765)
Because you did something retarded by removing the table completely instead of say, cleaning it out and just adding the 10 items to it. You think its cleaner to edit the source but that just shows your inexperience.

Hi Caryatis, thanks for your feedback. I have no problems admitting my inexperience with the eqemu source, however I am not inexperienced in software development and design.

Your assumption that "I think it's cleaner" is incorrect. I looked at my requirements and considered the options available. I chose the option that satisfied my requirements and was both simple and pragmatic.

Quote:

Originally Posted by Caryatis (Post 214765)
Ever think of making the charges column signed? Probably wouldn't dissolve your computer if you tried.

If you read through the thread you see we have covered this already, it will not fix the issue. I agree with you though that it probably wont dissolve my computer.

Drajor 02-18-2013 07:52 AM

Necro!

I came across this issue again and the following code now works as a work-around.

Code:

i->PutItem( i->FindFreeSlot(0,0), *pDB->CreateBaseItem( pDB->GetItem( YOUR_ITEM_ID ), 0 ) );
CreateBaseItem must be called, only calling GetItem will result in the item being out of charges.

lerxst2112 02-18-2013 08:59 AM

I'm looking at the current code in SharedDatabase::SetStartingItems, and it does call CreateBaseItem.

The code you posted has a memory leak since the ItemInst* returned from CreateBaseItem is never deleted.

Drajor 02-18-2013 11:17 AM

Good catch, thank you!


All times are GMT -4. The time now is 01:22 AM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.