diff --git a/server/gameserver/creature.cc b/server/gameserver/creature.cc index 2ef63330..a3a2a46c 100644 --- a/server/gameserver/creature.cc +++ b/server/gameserver/creature.cc @@ -1413,31 +1413,53 @@ void Creature::DecInventory(int slot_id, int num) void Creature::CheckSpecObject() { - long long old_cell_flags = cell_flags_; - cell_flags_ = 0; - int ext_flags = 0; + int old_poly_ext_flags = poly_ext_flags_; + poly_ext_flags_ = 0; { int poly_idx = 0; dtPoly* poly = room->map_instance->GetPoly(GetPos().ToGlmVec3(), poly_idx); if (poly) { - ext_flags = room->GetPolyExtFlag(poly_idx); - #if 0 - if ((poly->flags & SAMPLE_POLYFLAGS_SWIM) == SAMPLE_POLYFLAGS_SWIM) { - a8::SetBitFlag(cell_flags_, kColliderTag_Water); - } - #endif + poly_ext_flags_ = room->GetPolyExtFlag(poly_idx); } } - if (old_cell_flags != cell_flags_) { - #if 0 - if (!a8::SameBitFlag(old_cell_flags, cell_flags_, kColliderTag_Water)) { - if (a8::HasBitFlag(cell_flags_, kColliderTag_Water)) { - TryAddBuff(this, kInWater1BuffId); - } else { - RemoveBuffByEffectId(kBET_InWater); + if (old_poly_ext_flags != poly_ext_flags_) { + for (int i = 0; i < sizeof(poly_ext_flags_) * 8; ++i) { + if (!a8::SameBitFlag(old_poly_ext_flags, poly_ext_flags_, i)) { + switch (i) { + case kWater1ExtFlag: + { + if (a8::HasBitFlag(poly_ext_flags_, i)) { + TryAddBuff(this, kInWater1BuffId); + } else { + RemoveBuffByEffectId(kBET_InWater); + } + } + break; + case kWater2ExtFlag: + { + if (a8::HasBitFlag(poly_ext_flags_, i)) { + TryAddBuff(this, kInWater2BuffId); + } else { + RemoveBuffByEffectId(kBET_InWater); + } + } + break; + case kWater3ExtFlag: + { + if (a8::HasBitFlag(poly_ext_flags_, i)) { + TryAddBuff(this, kInWater3BuffId); + } else { + RemoveBuffByEffectId(kBET_InWater); + } + } + break; + default: + { + } + break; + } } } - #endif } } diff --git a/server/gameserver/creature.h b/server/gameserver/creature.h index bd9c200e..17d35d1c 100644 --- a/server/gameserver/creature.h +++ b/server/gameserver/creature.h @@ -323,7 +323,7 @@ protected: int action_item_id = 0; int action_target_id = 0; - long long cell_flags_ = 0; + int poly_ext_flags_ = 0; std::array buff_inventory_ = {}; int camouflage_move_addition_ = 0;