|
|
|
@ -679,8 +679,15 @@ static void manageEquipmentEvent(color_ostream& out) {
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
auto oldEquipment = equipmentLog.find(unit->id);
|
|
|
|
|
if ( oldEquipment != equipmentLog.end() ) {
|
|
|
|
|
vector<InventoryItem>& v = (*oldEquipment).second;
|
|
|
|
|
bool hadEquipment = oldEquipment != equipmentLog.end();
|
|
|
|
|
vector<InventoryItem>* temp;
|
|
|
|
|
if ( hadEquipment ) {
|
|
|
|
|
temp = &((*oldEquipment).second);
|
|
|
|
|
} else {
|
|
|
|
|
temp = new vector<InventoryItem>;
|
|
|
|
|
}
|
|
|
|
|
//vector<InventoryItem>& v = (*oldEquipment).second;
|
|
|
|
|
vector<InventoryItem>& v = *temp;
|
|
|
|
|
for ( auto b = v.begin(); b != v.end(); b++ ) {
|
|
|
|
|
InventoryItem& i = *b;
|
|
|
|
|
itemIdToInventoryItem[i.itemId] = i;
|
|
|
|
@ -713,6 +720,8 @@ static void manageEquipmentEvent(color_ostream& out) {
|
|
|
|
|
handle.eventHandler(out, (void*)&data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ( !hadEquipment )
|
|
|
|
|
delete temp;
|
|
|
|
|
//check for dropped items
|
|
|
|
|
for ( auto b = v.begin(); b != v.end(); b++ ) {
|
|
|
|
|
InventoryItem i = *b;
|
|
|
|
@ -725,7 +734,6 @@ static void manageEquipmentEvent(color_ostream& out) {
|
|
|
|
|
handle.eventHandler(out, (void*)&data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//update equipment
|
|
|
|
|
vector<InventoryItem>& equipment = equipmentLog[unit->id];
|
|
|
|
|