74 if (!
sDatabase.RunQuery(res,
"SELECT attributeID, valueInt, valueFloat FROM chrCharacterAttributes WHERE charID=%u",
mItem.
itemID()))
75 _log(DATABASE__ERROR,
"AttributeMap",
"Error in db load query: %s", res.
error.
c_str());
77 if (!
sDatabase.RunQuery(res,
"SELECT attributeID, valueInt, valueFloat FROM entity_attributes WHERE itemID=%u",
mItem.
itemID()))
78 _log(DATABASE__ERROR,
"AttributeMap",
"Error in db load query: %s", res.
error.
c_str());
121 std::vector<Inv::AttrData> attribs;
125 for (; itr !=
end; ++itr) {
126 switch (itr->first) {
148 data.
valueInt = itr->second.get_int();
149 attribs.push_back(data);
154 bool skill(
false),
damage(
false), owner(
false), module(
false);
183 for (; itr !=
end; ++itr) {
199 if (itr->second.isInt()) {
201 data.
valueInt = itr->second.get_int();
206 attribs.push_back(data);
211 if (!attribs.empty())
220 _log(ATTRIBUTE__ERROR,
"AttributeMap::SetAttribute() - Something sent NaN or Inf for Attr %u on %s(%u). Returning without modifying.",\
233 _log(ATTRIBUTE__MISSING,
"Attribute %u not in map. Adding as %.2f for %s(%u)", \
236 _log(ATTRIBUTE__MISSING,
"Attribute %u not in map. Adding as %li for %s(%u)", \
241 _log(ATTRIBUTE__ADD,
"Attribute %u not in map. Adding as %.2f for %s(%u)", \
244 _log(ATTRIBUTE__ADD,
"Attribute %u not in map. Adding as %li for %s(%u)", \
252 if (itr->second == num)
256 Change(attrID, itr->second, num);
258 if (itr->second.isFloat()) {
260 _log(ATTRIBUTE__CHANGE,
"Changing Attribute %u from %.2f to %.2f for %s(%u)", \
263 _log(ATTRIBUTE__CHANGE,
"Changing Attribute %u from %.2f to %li for %s(%u)", \
268 _log(ATTRIBUTE__CHANGE,
"Changing Attribute %u from %li to %.2f for %s(%u)", \
271 _log(ATTRIBUTE__CHANGE,
"Changing Attribute %u from %li to %li for %s(%u)", \
283 _log(ATTRIBUTE__ERROR,
"AttributeMap::MultiplyAttribute() - Something sent NaN or Inf for %u on %s(%u). Returning without modifying.", \
292 _log(ATTRIBUTE__WARNING,
"AttributeMap::MultiplyAttribute() - Something sent 0 for %u on %s(%u). Returning without modifying.", \
305 Change(attrID, oldValue, itr->second);
342 if (old_val == new_val)
357 Notify_OnModuleAttributeChange modChange;
366 modChange.itemKey = itemKey;
371 modChange.attributeID = attrID;
408 Notify_OnModuleAttributeChange modChange;
416 modChange.itemKey = itemKey;
421 modChange.attributeID = attrID;
424 modChange.oldValue =
PyStatic.NewNone();
429 if (attrChange ==
nullptr)
438 sEntityList.Multicast(
"OnItemChange",
"*stationid&corpid", &attrChange, mct);
440 sEntityList.Multicast(
"OnItemChange",
"corpid", &attrChange, mct);
454 if (pClient ==
nullptr) {
455 _log(PLAYER__WARNING,
"AttributeMap::SendChanges() - ownerID for %u not found",
mItem.
itemID() );
465 attrChange->
Dump(ATTRIBUTE__CHANGE,
"");
483 attrMap[cur.first] = cur.second;
488 std::ostringstream Inserts;
490 Inserts <<
"REPLACE INTO entity_attributes ";
491 Inserts <<
" (itemID, attributeID, valueInt, valueFloat) VALUES";
496 Inserts <<
"(" <<
mItem.
itemID() <<
", " << cur->first <<
", ";
498 Inserts << cur->second.get_int() <<
", NULL)";
500 Inserts <<
" NULL, " << cur->second.get_double() <<
")";
508 Inserts <<
"(" <<
mItem.
itemID() <<
", " << cur->first <<
", ";
510 Inserts << cur->second.get_int() <<
", NULL)";
512 Inserts <<
" NULL, " << cur->second.get_double() <<
")";
520 Inserts <<
"(" <<
mItem.
itemID() <<
", " << cur->first <<
", ";
522 Inserts << cur->second.get_int() <<
", NULL)";
524 Inserts <<
" NULL, " << cur->second.get_double() <<
")";
532 Inserts <<
"(" <<
mItem.
itemID() <<
", " << cur->first <<
", ";
534 Inserts << cur->second.get_int() <<
", NULL)";
536 Inserts <<
" NULL, " << cur->second.get_double() <<
")";
544 Inserts <<
"(" <<
mItem.
itemID() <<
", " << cur->first <<
", ";
546 Inserts << cur->second.get_int() <<
", NULL)";
548 Inserts <<
" NULL, " << cur->second.get_double() <<
")";
556 Inserts <<
"(" <<
mItem.
itemID() <<
", " << cur->first <<
", ";
558 Inserts << cur->second.get_int() <<
", NULL)";
560 Inserts <<
" NULL, " << cur->second.get_double() <<
")";
567 _log(DATABASE__ERROR,
"SaveShipState - unable to save attributes for %u - %s",
mItem.
itemID(), err.
c_str());
585 if (!
sDatabase.RunQuery(err,
"DELETE FROM chrCharacterAttributes WHERE charID = %u AND attributeID = %u",
mItem.
itemID(), attrID)) {
586 _log(DATABASE__ERROR,
"DeleteAttribute - unable to delete attribute %u for %u - %s", attrID,
mItem.
itemID(), err.
c_str());
589 if (!
sDatabase.RunQuery(err,
"DELETE FROM entity_attributes WHERE itemID = %u AND attributeID = %u",
mItem.
itemID(), attrID)) {
590 _log(DATABASE__ERROR,
"DeleteAttribute - unable to delete attribute %u for %u - %s", attrID,
mItem.
itemID(), err.
c_str());
594 _log(ATTRIBUTE__WARNING,
"Attribute %u not found in %s(%u) when calling delete ", attrID,
mItem.
name(),
mItem.
itemID());
#define IsStaticItem(itemID)
bool Change(uint16 attrID, EvilNumber &old_val, EvilNumber &new_val)
internal function to handle the change.
void SetAttribute(uint16 attrID, EvilNumber &num, bool notify=true)
std::set< uint32 > corporations
#define _log(type, fmt,...)
PyRep * GetPyObject()
converts the EvilNumber into a python object.
uint32 GetUInt(uint32 index) const
double GetDouble(uint32 index) const
void MultiplyAttribute(uint16 attrID, EvilNumber &num, bool notify=false)
void QueueDestinyEvent(PyTuple **multiEvent)
bool Add(uint16 attrID, EvilNumber &num)
internal function to handle adding attributes.
EvilNumber GetDefaultAttribute(const uint16 attrID) const
AttrMapItr begin()
return the begin iterator of the AttributeMap
this is a class that kinda mimics how python polymorph's numbers.
void DeleteAttribute(uint16 attrID)
void Dump(FILE *into, const char *pfx) const
Dumps object to file.
itemID[count] Create count or of the specified item(from Insider)" ) COMMAND( goto
EvilNumber GetAttribute(const uint16 attrID) const
bool GetRow(DBResultRow &into)
const ItemType & type() const
#define is_log_enabled(type)
const char * c_str() const
void ResetAttribute(uint16 attrID, bool notify=false)
void SetItem(size_t index, PyRep *object)
Stores Python object.
AttrMap::iterator AttrMapItr
uint32 locationID() const
bool HasAttribute(const uint16 attrID) const
bool IsNull(uint32 index) const
#define IsFittingSlot(flag)
#define IsPlayerCorp(itemID)
AttrMap::const_iterator AttrMapConstItr
#define IsCharacterID(itemID)
const void CopyAttributes(InventoryItem &itemRef) const
bool Load(bool reset=false)
EVEItemFlags flag() const
static void SaveAttributes(bool isChar, std::vector< Inv::AttrData > &data)
#define IsTempItem(itemID)
AttributeMap(InventoryItem &item)
AttrMapItr end()
return the end iterator of the AttributeMap
int64 GetInt64(uint32 index) const
std::set< uint32 > locations
void CopyAttributes(std::map< uint16, EvilNumber > &attrMap)
bool SendChanges(PyTuple *attrChange)
queue the attribute changes into the QueueDestinyEvent system.