View Single Post
  #2  
Old 09-17-2011, 01:00 AM
Tabasco's Avatar
Tabasco
Discordant
 
Join Date: Sep 2009
Posts: 269
Default

I don't see any existing function that will do what you want.
With DBI installed you could query the tiems table, but that doesn't guarantee that the item actually exists in the shared memory block.

You could try this though:

questmgr.h (somewhere under public
Code:
bool IsValidItem(int32 itemid);
questmgr.cpp
Code:
bool QuestManager::IsValidItem(int32 itemid)
{
    return(database.GetItem(itemid));
}
perlparser.cpp
Code:
XS(XS__IsValidItem);
XS(XS__IsValidItem)
{
    dXSARGS;
    if (items != 1)
        Perl_croak(aTHX_ "Usage: IsValidItem(itemid)");

    int32       itemid = (int32)SvUV(ST(0));
    bool        RETVAL;
    dXSTARG;


    RETVAL = quest_manager.IsValidItem(itemid);
    XSprePUSH; PUSHu((IV)RETVAL);

    XSRETURN(1);
}
Then add to the boot_quest function in perlparser.cpp
Code:
newXS(strcpy(buf, "IsValidItem"), XS__IsValidItem, file);
I can test it fully in the morning, but for now I can at least tell you that it compiles.
Reply With Quote