Example #1
0
void ItemAttributeMgr::Clear(Attr attr) {
    PyRep *oldValue = NULL;
    if(GetNotify() == true && !IsRechargable(attr)) {
        // get old value
        oldValue = PyGet(attr);
    }
    // clear the attribute
    EVEAdvancedAttributeMgr::Clear(attr);
    // delete the attribute from DB (no matter if it really is there)
    if(GetSave() == true) {
        m_factory.db().EraseAttribute(m_item.itemID(), attr);
    }
    if(GetNotify() == true) {
        std::map<Attr, TauCap>::const_iterator i = m_tauCap.find(attr);
        if(i != m_tauCap.end()) {
            // build the special list for rechargables
            PyList *l = new PyList;

            l->AddItem( PyGet( attr ) );
            l->AddItemLong( Win32TimeNow() );
            l->AddItem( _PyGet( GetReal( i->second.tau ) / 5.0 ) );
            l->AddItem( PyGet( i->second.cap ) );

            oldValue = l;
        }
        // send change
        _SendAttributeChange(attr, oldValue, new PyFloat(GetReal(attr)));
    }
}
Example #2
0
void ItemAttributeMgr::SetIntEx(Attr attr, const int_t &v, bool persist) {
    PyRep *oldValue = NULL;
    if(GetNotify() == true && !IsRechargable(attr)) {
        // get old value
        oldValue = PyGet(attr);
    }
    // set the attribute value
    EVEAdvancedAttributeMgr::SetInt(attr, v);
    // check if we shall save to DB
    if(GetSave() == true && (persist || IsPersistent(attr))) {
        // save to DB
        m_factory.db().UpdateAttribute_int(m_item.itemID(), attr, v);
    }
    if(GetNotify() == true) {
        std::map<Attr, TauCap>::const_iterator i = m_tauCap.find(attr);
        if(i != m_tauCap.end()) {
            // build the special list for rechargables
            PyList *l = new PyList;

            l->AddItemInt( v );
            l->AddItemLong( Win32TimeNow() );
            l->AddItem( _PyGet( GetReal( i->second.tau ) / 5.0 ) );
            l->AddItem( PyGet( i->second.cap ) );

            oldValue = l;
        }
        // send change
        _SendAttributeChange(attr, oldValue, new PyFloat(v));
    }
}