From 8af871ed1861d5f1f11c7953ddc03613da1d7974 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 7 Apr 2021 20:04:10 +0800 Subject: [PATCH] 1 --- server/gameserver/player.cc | 55 ++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index 1208956..9f88ce7 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -687,20 +687,49 @@ void Player::LootInteraction(Loot* entity) add_num = std::min(entity->count, add_num); AddInventory(item_meta->i->_inventory_slot(), add_num); - if (item_meta->i->_inventory_slot() == 5 || - item_meta->i->_inventory_slot() == 6) { - Weapon* weapon = &weapons[3 + (item_meta->i->_inventory_slot() - 5)]; - weapon->weapon_id = entity->item_id; - weapon->weapon_lv = 1; - weapon->ammo += entity->count; - weapon->meta = item_meta; - weapon->Recalc(); - DecInventory(item_meta->i->_inventory_slot(), add_num); - } - if (item_meta->i->_inventory_slot() > 12) { - if (item_meta->i->_inventory_slot() - 12 > curr_scope_idx) { - curr_scope_idx = item_meta->i->_inventory_slot() - 12; + switch (item_meta->i->_inventory_slot()) { + case IS_FRAG: + case IS_SMOKE: + { + Weapon* weapon = &weapons[3 + (item_meta->i->_inventory_slot() - IS_FRAG)]; + weapon->weapon_id = entity->item_id; + weapon->weapon_lv = 1; + weapon->ammo += entity->count; + weapon->meta = item_meta; + weapon->Recalc(); + DecInventory(item_meta->i->_inventory_slot(), add_num); } + break; + case IS_1XSCOPE: + case IS_2XSCOPE: + case IS_4XSCOPE: + case IS_8XSCOPE: + case IS_15XSCOPE: + { + if (item_meta->i->_inventory_slot() - IS_1XSCOPE > curr_scope_idx) { + curr_scope_idx = item_meta->i->_inventory_slot() - IS_1XSCOPE; + } + } + break; + case IS_POSION_GAS_BOMB: + case IS_MOLOTOR_COCKTAIL: + case IS_TRAP: + case IS_MINE: + { + Weapon* weapon = &weapons[5 + (item_meta->i->_inventory_slot() - IS_POSION_GAS_BOMB)]; + weapon->weapon_id = entity->item_id; + weapon->weapon_lv = 1; + weapon->ammo += entity->count; + weapon->meta = item_meta; + weapon->Recalc(); + DecInventory(item_meta->i->_inventory_slot(), add_num); + } + break; + default: + { + abort(); + } + break; } if (add_num < entity->count) { //刷新数量