From 654630c3d31e49b1918e8c72b3f82cb037a2c1bc Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 9 Apr 2021 17:17:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AE=95=E6=9C=BA=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/gameserver/creature.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/server/gameserver/creature.cc b/server/gameserver/creature.cc index a98b590..e0eab1c 100644 --- a/server/gameserver/creature.cc +++ b/server/gameserver/creature.cc @@ -1431,8 +1431,15 @@ Weapon* Creature::ChooseNextWeapon(int curr_weapon_slot_id, int begin_slot_id, i for (int i = 1; i <= (end_slot_id - begin_slot_id); ++i) { int slot_id = begin_slot_id + (i + curr_weapon_slot_id - begin_slot_id) % (end_slot_id - begin_slot_id + 1); - if (weapons[slot_id].weapon_id != 0) { - next_weapon = &weapons[slot_id]; + int idx = -1; + if (slot_id >= SPEC1_IS_BEGIN && slot_id <= SPEC1_IS_END) { + idx = SPEC1_SLOT_BEGIN + (slot_id - SPEC1_IS_BEGIN); + } + if (slot_id >= SPEC2_IS_BEGIN && slot_id <= SPEC2_IS_END) { + idx = SPEC2_SLOT_BEGIN + (slot_id - SPEC2_IS_BEGIN); + } + if (idx != -1 && weapons.at(idx).weapon_id != 0) { + next_weapon = &weapons[idx]; break; } }