All pastes #269748 Raw Edit

Miscellany

public text v1 · immutable
·published 2006-12-06 20:02 UTC
rendered paste body
// ---- BUILD ITEM HEADER ----
unsigned short CWorldServer::BuildItemHead( CItem thisitem )
{
    if (thisitem.count==0) return 0;
    return thisitem.itemnum << 5 | ( thisitem.itemtype & 0x1f );
}

// ---- BUILD ITEM DATA ----
unsigned CWorldServer::BuildItemData( CItem thisitem )
{
    if (thisitem.count==0) return 0;
    if ( thisitem.itemtype >= 10 && thisitem.itemtype <= 13 ) {
        return thisitem.count;
        } else {
        unsigned retval = 0;
        retval |= (thisitem.refine>>4) << 28;
        retval |= (thisitem.appraised?1:0) << 27;
        retval |= (thisitem.slot?1:0) << 26;
        retval |= (thisitem.lifespan*10) << 16;
        retval |= thisitem.durability << 9;
        retval |= thisitem.stats;
        return retval;
    }
}

struct CItem {
    unsigned short itemnum;
    unsigned short itemtype;
    unsigned short refine;
    unsigned short durability;
    unsigned short lifespan;
    unsigned short count;
    unsigned short slot;
    unsigned short gem;
    bool     appraised;
    unsigned    stats;
};