This commit is contained in:
aozhiwei 2023-03-07 15:21:43 +08:00
parent c7c137de9a
commit a4afec4b0c

View File

@ -1608,6 +1608,7 @@ void Human::DeadDrop()
room->DropItem(drop_pos.ToGlmVec3(), equip_meta->id(), drop_num, 1); room->DropItem(drop_pos.ToGlmVec3(), equip_meta->id(), drop_num, 1);
} }
DecInventory(slot, GetInventory(slot)); DecInventory(slot, GetInventory(slot));
SyncVolume(slot);
} }
} }
break; break;
@ -1627,6 +1628,7 @@ void Human::DeadDrop()
#endif #endif
} }
DecInventory(slot, GetInventory(slot)); DecInventory(slot, GetInventory(slot));
SyncVolume(slot);
} }
} }
break; break;
@ -2122,12 +2124,14 @@ void Human::ProcReloadAction()
add_num = 1; add_num = 1;
} }
DecInventory(bullet_meta->_inventory_slot(), add_num); DecInventory(bullet_meta->_inventory_slot(), add_num);
SyncVolume(bullet_meta->_inventory_slot());
} else { } else {
add_num = p_weapon->GetClipVolume(this) - ammo; add_num = p_weapon->GetClipVolume(this) - ammo;
if (p_weapon->meta->reloadtype() == 1) { if (p_weapon->meta->reloadtype() == 1) {
add_num = 1; add_num = 1;
} }
DecInventory(bullet_meta->_inventory_slot(), add_num); DecInventory(bullet_meta->_inventory_slot(), add_num);
SyncVolume(bullet_meta->_inventory_slot());
} }
p_weapon->ammo += add_num; p_weapon->ammo += add_num;
MarkSyncActivePlayer(__FILE__, __LINE__, __func__); MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
@ -2139,7 +2143,9 @@ void Human::ProcReloadAction()
[this, weapon_idx, weapon_id] [this, weapon_idx, weapon_id]
(int event, const a8::Args* args) (int event, const a8::Args* args)
{ {
NextReload(weapon_id, weapon_idx); if (a8::TIMER_EXEC_EVENT == event) {
NextReload(weapon_id, weapon_idx);
}
}, },
&xtimer_attacher); &xtimer_attacher);
} }
@ -2190,6 +2196,7 @@ void Human::ProcUseItemAction()
break; break;
} }
DecInventory(item_meta->_inventory_slot(), 1); DecInventory(item_meta->_inventory_slot(), 1);
SyncVolume(item_meta->_inventory_slot());
GetTrigger()->UseItemAction(item_meta->_inventory_slot()); GetTrigger()->UseItemAction(item_meta->_inventory_slot());
} }
break; break;
@ -2255,6 +2262,7 @@ void Human::ProcUseItemAction()
} }
} }
DecInventory(item_meta->_inventory_slot(), 1); DecInventory(item_meta->_inventory_slot(), 1);
SyncVolume(item_meta->_inventory_slot());
MarkSyncActivePlayer(__FILE__, __LINE__, __func__); MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
GetTrigger()->UseItemAction(item_meta->_inventory_slot()); GetTrigger()->UseItemAction(item_meta->_inventory_slot());
} }
@ -2289,6 +2297,7 @@ void Human::ProcUseItemAction()
} }
} }
DecInventory(item_meta->_inventory_slot(), 1); DecInventory(item_meta->_inventory_slot(), 1);
SyncVolume(item_meta->_inventory_slot());
MarkSyncActivePlayer(__FILE__, __LINE__, __func__); MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
GetTrigger()->UseItemAction(item_meta->_inventory_slot()); GetTrigger()->UseItemAction(item_meta->_inventory_slot());
} }
@ -2736,6 +2745,7 @@ void Human::ProcLootSpecItem(AddItemDTO& dto)
add_num = std::min(dto.count, add_num); add_num = std::min(dto.count, add_num);
AddInventory(dto.item_meta->_inventory_slot(), add_num); AddInventory(dto.item_meta->_inventory_slot(), add_num);
SyncVolume(dto.item_meta->_inventory_slot());
switch (dto.item_meta->_inventory_slot()) { switch (dto.item_meta->_inventory_slot()) {
case IS_FRAG: case IS_FRAG:
case IS_SMOKE: case IS_SMOKE:
@ -3087,6 +3097,7 @@ void Human::DropWeapon(int weapon_idx, int num)
weapon->ammo = std::max(0, weapon->ammo - weapon_ammo); weapon->ammo = std::max(0, weapon->ammo - weapon_ammo);
int slot_id = weapon->meta->_inventory_slot(); int slot_id = weapon->meta->_inventory_slot();
DecInventory(slot_id, weapon_ammo); DecInventory(slot_id, weapon_ammo);
SyncVolume(slot_id);
if (weapon->ammo <= 0) { if (weapon->ammo <= 0) {
*weapon = Weapon(); *weapon = Weapon();
weapon->weapon_idx = weapon_idx; weapon->weapon_idx = weapon_idx;
@ -3111,6 +3122,7 @@ void Human::DropWeapon(int weapon_idx, int num)
weapon->ammo = std::max(0, weapon->ammo - weapon_ammo); weapon->ammo = std::max(0, weapon->ammo - weapon_ammo);
int slot_id = weapon->meta->_inventory_slot(); int slot_id = weapon->meta->_inventory_slot();
DecInventory(slot_id, weapon_ammo); DecInventory(slot_id, weapon_ammo);
SyncVolume(slot_id);
if (weapon->ammo <= 0) { if (weapon->ammo <= 0) {
*weapon = Weapon(); *weapon = Weapon();
weapon->weapon_idx = weapon_idx; weapon->weapon_idx = weapon_idx;
@ -3135,6 +3147,7 @@ void Human::DropWeapon(int weapon_idx, int num)
weapon->ammo = std::max(0, weapon->ammo - weapon_ammo); weapon->ammo = std::max(0, weapon->ammo - weapon_ammo);
int slot_id = weapon->meta->_inventory_slot(); int slot_id = weapon->meta->_inventory_slot();
DecInventory(slot_id, weapon_ammo); DecInventory(slot_id, weapon_ammo);
SyncVolume(slot_id);
if (weapon->ammo <= 0) { if (weapon->ammo <= 0) {
*weapon = Weapon(); *weapon = Weapon();
weapon->weapon_idx = weapon_idx; weapon->weapon_idx = weapon_idx;