diff options
| author | Shocker <none@none> | 2010-09-28 08:21:51 +0300 |
|---|---|---|
| committer | Shocker <none@none> | 2010-09-28 08:21:51 +0300 |
| commit | 78803c9f09feff5213a394a84e28b8245f7e2efa (patch) | |
| tree | 7e58d15fabfb5f3ebbe7364ad6424f548caacf24 /src/server/game/Entities | |
| parent | 192e972a594afb020e6639de7cce617e7f4655ad (diff) | |
Magic numbers cleanup:
- Replace many magic numbers with constants
- Use enum for vehicle flags/seat flags
- Correct structure for ItemRandomSuffixEntry
--HG--
branch : trunk
Diffstat (limited to 'src/server/game/Entities')
| -rw-r--r-- | src/server/game/Entities/Creature/Creature.cpp | 4 | ||||
| -rw-r--r-- | src/server/game/Entities/Creature/Creature.h | 4 | ||||
| -rw-r--r-- | src/server/game/Entities/Creature/GossipDef.cpp | 14 | ||||
| -rw-r--r-- | src/server/game/Entities/GameObject/GameObject.cpp | 2 | ||||
| -rw-r--r-- | src/server/game/Entities/GameObject/GameObject.h | 4 | ||||
| -rw-r--r-- | src/server/game/Entities/Item/Item.cpp | 16 | ||||
| -rw-r--r-- | src/server/game/Entities/Item/Item.h | 2 | ||||
| -rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 38 | ||||
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 6 | ||||
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 4 | ||||
| -rw-r--r-- | src/server/game/Entities/Vehicle/Vehicle.cpp | 8 | ||||
| -rw-r--r-- | src/server/game/Entities/Vehicle/Vehicle.h | 19 |
12 files changed, 73 insertions, 48 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 899782ae2d3..bc9f74ab5ed 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -1678,7 +1678,7 @@ SpellEntry const *Creature::reachWithSpellAttack(Unit *pVictim) } bool bcontinue = true; - for (uint32 j=0; j<3; j++) + for (uint32 j = 0; j < MAX_SPELL_EFFECTS; j++) { if ((spellInfo->Effect[j] == SPELL_EFFECT_SCHOOL_DAMAGE) || (spellInfo->Effect[j] == SPELL_EFFECT_INSTAKILL) || @@ -1728,7 +1728,7 @@ SpellEntry const *Creature::reachWithSpellCure(Unit *pVictim) } bool bcontinue = true; - for (uint32 j=0; j<3; j++) + for (uint32 j = 0; j < MAX_SPELL_EFFECTS; j++) { if ((spellInfo->Effect[j] == SPELL_EFFECT_HEAL)) { diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index 2c997cd8df7..d8a8b13b208 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -68,6 +68,8 @@ enum CreatureFlagsExtra #define MAX_KILL_CREDIT 2 #define CREATURE_REGEN_INTERVAL 2 * IN_MILLISECONDS +#define MAX_CREATURE_QUEST_ITEMS 6 + // from `creature_template` table struct CreatureInfo { @@ -133,7 +135,7 @@ struct CreatureInfo float ModMana; float ModArmor; bool RacialLeader; - uint32 questItems[6]; + uint32 questItems[MAX_CREATURE_QUEST_ITEMS]; uint32 movementId; bool RegenHealth; uint32 equipmentId; diff --git a/src/server/game/Entities/Creature/GossipDef.cpp b/src/server/game/Entities/Creature/GossipDef.cpp index ff93089fcb2..ab59be5ec82 100644 --- a/src/server/game/Entities/Creature/GossipDef.cpp +++ b/src/server/game/Entities/Creature/GossipDef.cpp @@ -240,7 +240,7 @@ void PlayerMenu::SendTalking(uint32 textID) if (!pGossip) { - for (uint32 i = 0; i < 8; ++i) + for (uint32 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i) { data << float(0); data << "Greetings $N"; @@ -256,8 +256,8 @@ void PlayerMenu::SendTalking(uint32 textID) } else { - std::string Text_0[8], Text_1[8]; - for (int i = 0; i < 8; ++i) + std::string Text_0[MAX_LOCALES], Text_1[MAX_LOCALES]; + for (int i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i) { Text_0[i] = pGossip->Options[i].Text_0; Text_1[i] = pGossip->Options[i].Text_1; @@ -267,14 +267,14 @@ void PlayerMenu::SendTalking(uint32 textID) { if (NpcTextLocale const *nl = sObjectMgr.GetNpcTextLocale(textID)) { - for (int i = 0; i < 8; ++i) + for (int i = 0; i < MAX_LOCALES; ++i) { sObjectMgr.GetLocaleString(nl->Text_0[i], loc_idx, Text_0[i]); sObjectMgr.GetLocaleString(nl->Text_1[i], loc_idx, Text_1[i]); } } } - for (int i = 0; i < 8; ++i) + for (int i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i) { data << pGossip->Options[i].Probability; @@ -290,7 +290,7 @@ void PlayerMenu::SendTalking(uint32 textID) data << pGossip->Options[i].Language; - for (int j = 0; j < 3; ++j) + for (int j = 0; j < MAX_GOSSIP_TEXT_EMOTES; ++j) { data << pGossip->Options[i].Emotes[j]._Delay; data << pGossip->Options[i].Emotes[j]._Emote; @@ -306,7 +306,7 @@ void PlayerMenu::SendTalking(char const * title, char const * text) { WorldPacket data(SMSG_NPC_TEXT_UPDATE, 50); // guess size data << uint32(0); - for (uint32 i = 0; i < 8; ++i) + for (uint32 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i) { data << float(0); data << title; diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 4b65fc7aabf..34e2c1d179f 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -1565,7 +1565,7 @@ void GameObject::CastSpell(Unit* target, uint32 spellId) return; bool self = false; - for (uint8 i = 0; i < 3; ++i) + for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) { if (spellInfo->EffectImplicitTargetA[i] == TARGET_UNIT_CASTER) { diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index 6ae7aebd2f0..eb9d1b8c2e7 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -34,6 +34,8 @@ #pragma pack(push,1) #endif +#define MAX_GAMEOBJECT_QUEST_ITEMS 6 + // from `gameobject_template` struct GameObjectInfo { @@ -47,7 +49,7 @@ struct GameObjectInfo uint32 faction; uint32 flags; float size; - uint32 questItems[6]; + uint32 questItems[MAX_GAMEOBJECT_QUEST_ITEMS]; union // different GO types have different data field { //0 GAMEOBJECT_TYPE_DOOR diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp index fee4ce25fe4..df0a0294c19 100644 --- a/src/server/game/Entities/Item/Item.cpp +++ b/src/server/game/Entities/Item/Item.cpp @@ -76,7 +76,7 @@ void AddItemsSetItem(Player*player,Item *item) ++eff->item_count; - for (uint32 x=0; x<8; x++) + for (uint32 x = 0; x < MAX_ITEM_SET_SPELLS; x++) { if (!set->spells [x]) continue; @@ -84,16 +84,16 @@ void AddItemsSetItem(Player*player,Item *item) if (set->items_to_triggerspell[x] > eff->item_count) continue; - uint32 z=0; - for (; z<8; z++) + uint32 z = 0; + for (; z < MAX_ITEM_SET_SPELLS; z++) if (eff->spells[z] && eff->spells[z]->Id == set->spells[x]) break; - if (z < 8) + if (z < MAX_ITEM_SET_SPELLS) continue; //new spell - for (uint32 y=0; y<8; y++) + for (uint32 y = 0; y < MAX_ITEM_SET_SPELLS; y++) { if (!eff->spells[y]) // free slot { @@ -142,7 +142,7 @@ void RemoveItemsSetItem(Player*player,ItemPrototype const *proto) --eff->item_count; - for (uint32 x=0; x<8; x++) + for (uint32 x = 0; x < MAX_ITEM_SET_SPELLS; x++) { if (!set->spells[x]) continue; @@ -151,7 +151,7 @@ void RemoveItemsSetItem(Player*player,ItemPrototype const *proto) if (set->items_to_triggerspell[x] <= eff->item_count) continue; - for (uint32 z=0; z<8; z++) + for (uint32 z = 0; z < MAX_ITEM_SET_SPELLS; z++) { if (eff->spells[z] && eff->spells[z]->Id == set->spells[x]) { @@ -918,7 +918,7 @@ void Item::ClearEnchantment(EnchantmentSlot slot) if (!GetEnchantmentId(slot)) return; - for (uint8 x = 0; x < 3; ++x) + for (uint8 x = 0; x < MAX_ITEM_ENCHANTMENT_EFFECTS; ++x) SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + x, 0); SetState(ITEM_CHANGED, GetOwner()); } diff --git a/src/server/game/Entities/Item/Item.h b/src/server/game/Entities/Item/Item.h index 1caef195262..ba1b5d8788b 100644 --- a/src/server/game/Entities/Item/Item.h +++ b/src/server/game/Entities/Item/Item.h @@ -211,6 +211,8 @@ enum ItemRequiredTargetType #define MAX_ITEM_REQ_TARGET_TYPE 2 +#define MAX_ITEM_SPELLS 5 + struct ItemRequiredTarget { ItemRequiredTarget(ItemRequiredTargetType uiType, uint32 uiTargetEntry) : m_uiType(uiType), m_uiTargetEntry(uiTargetEntry) {} diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index bc0b67f2089..31adb2ddb17 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -7791,7 +7791,7 @@ void Player::UpdateEquipSpellsAtFormChange() if (!eff) continue; - for (uint32 y=0; y<8; ++y) + for (uint32 y = 0; y < MAX_ITEM_SET_SPELLS; ++y) { SpellEntry const* spellInfo = eff->spells[y]; if (!spellInfo) @@ -7844,7 +7844,7 @@ void Player::CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32 if (procVictim & PROC_FLAG_TAKEN_ANY_DAMAGE) //if (damageInfo->procVictim & PROC_FLAG_TAKEN_ANY_DAMAGE) { - for (uint8 i = 0; i < 5; ++i) + for (uint8 i = 0; i < MAX_ITEM_SPELLS; ++i) { _Spell const& spellData = proto->Spells[i]; @@ -7902,7 +7902,7 @@ void Player::CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32 uint32 enchant_id = item->GetEnchantmentId(EnchantmentSlot(e_slot)); SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); if (!pEnchant) continue; - for (uint8 s = 0; s < 3; ++s) + for (uint8 s = 0; s < MAX_ITEM_ENCHANTMENT_EFFECTS; ++s) { if (pEnchant->type[s] != ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL) continue; @@ -8022,7 +8022,7 @@ void Player::CastItemUseSpell(Item *item,SpellCastTargets const& targets,uint8 c SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); if (!pEnchant) continue; - for (uint8 s = 0; s < 3; ++s) + for (uint8 s = 0; s < MAX_ITEM_ENCHANTMENT_EFFECTS; ++s) { if (pEnchant->type[s] != ITEM_ENCHANTMENT_TYPE_USE_SPELL) continue; @@ -13094,7 +13094,7 @@ void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool if (!item->IsBroken()) { - for (int s = 0; s < 3; ++s) + for (int s = 0; s < MAX_ITEM_ENCHANTMENT_EFFECTS; ++s) { uint32 enchant_display_type = pEnchant->type[s]; uint32 enchant_amount = pEnchant->amount[s]; @@ -13128,7 +13128,7 @@ void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool if (item_rand) { // Search enchant_amount - for (int k = 0; k < 3; ++k) + for (int k = 0; k < MAX_ITEM_ENCHANTMENT_EFFECTS; ++k) { if (item_rand->enchant_id[k] == enchant_id) { @@ -13154,7 +13154,7 @@ void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool ItemRandomSuffixEntry const *item_rand = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); if (item_rand) { - for (int k = 0; k < 3; ++k) + for (int k = 0; k < MAX_ITEM_ENCHANTMENT_EFFECTS; ++k) { if (item_rand->enchant_id[k] == enchant_id) { @@ -13174,7 +13174,7 @@ void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool ItemRandomSuffixEntry const *item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); if (item_rand_suffix) { - for (int k = 0; k < 3; ++k) + for (int k = 0; k < MAX_ITEM_ENCHANTMENT_EFFECTS; ++k) { if (item_rand_suffix->enchant_id[k] == enchant_id) { @@ -18637,7 +18637,7 @@ void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent) if (spellInfo) { - for (uint32 i = 0; i < 7; ++i) + for (uint32 i = 0; i < MAX_SPELL_REAGENTS; ++i) { if (spellInfo->Reagent[i] > 0) { @@ -19716,7 +19716,7 @@ inline bool Player::_StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 c if (iece->reqarenapoints) ModifyArenaPoints(- int32(iece->reqarenapoints * count)); - for (uint8 i = 0; i < 5; ++i) + for (uint8 i = 0; i < MAX_ITEM_EXTENDED_COST_REQUIREMENTS; ++i) { if (iece->reqitem[i]) DestroyItemCount(iece->reqitem[i], (iece->reqitemcount[i] * count), true); @@ -19843,7 +19843,7 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32 } // item base price - for (uint8 i = 0; i < 5; ++i) + for (uint8 i = 0; i < MAX_ITEM_EXTENDED_COST_REQUIREMENTS; ++i) { if (iece->reqitem[i] && !HasItemCount(iece->reqitem[i], (iece->reqitemcount[i] * count))) { @@ -20020,7 +20020,7 @@ void Player::AddSpellAndCategoryCooldowns(SpellEntry const* spellInfo, uint32 it { if (ItemPrototype const* proto = ObjectMgr::GetItemPrototype(itemId)) { - for (uint8 idx = 0; idx < 5; ++idx) + for (uint8 idx = 0; idx < MAX_ITEM_SPELLS; ++idx) { if (uint32(proto->Spells[idx].SpellId) == spellInfo->Id) { @@ -20132,7 +20132,7 @@ void Player::UpdatePotionCooldown(Spell* spell) { // spell/item pair let set proper cooldown (except not existed charged spell cooldown spellmods for potions) if (ItemPrototype const* proto = ObjectMgr::GetItemPrototype(m_lastPotionId)) - for (uint8 idx = 0; idx < 5; ++idx) + for (uint8 idx = 0; idx < MAX_ITEM_SPELLS; ++idx) if (proto->Spells[idx].SpellId && proto->Spells[idx].SpellTrigger == ITEM_SPELLTRIGGER_ON_USE) if (SpellEntry const* spellInfo = sSpellStore.LookupEntry(proto->Spells[idx].SpellId)) SendCooldownEvent(spellInfo,m_lastPotionId); @@ -21227,7 +21227,7 @@ void Player::learnQuestRewardedSpells(Quest const* quest) // check learned spells state bool found = false; - for (uint8 i = 0; i < 3; ++i) + for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) { if (spellInfo->Effect[i] == SPELL_EFFECT_LEARN_SPELL && !HasSpell(spellInfo->EffectTriggerSpell[i])) { @@ -23481,7 +23481,7 @@ void Player::BuildPlayerTalentsInfoData(WorldPacket *data) // find class talent tabs (all players have 3 talent tabs) uint32 const* talentTabIds = GetTalentTabPages(getClass()); - for (uint8 i = 0; i < 3; ++i) + for (uint8 i = 0; i < MAX_TALENT_TABS; ++i) { uint32 talentTabId = talentTabIds[i]; @@ -24152,7 +24152,7 @@ void Player::SendRefundInfo(Item *item) data << uint32(item->GetPaidMoney()); // money cost data << uint32(iece->reqhonorpoints); // honor point cost data << uint32(iece->reqarenapoints); // arena point cost - for (uint8 i = 0; i < 5; ++i) // item cost data + for (uint8 i = 0; i < MAX_ITEM_EXTENDED_COST_REQUIREMENTS; ++i) // item cost data { data << uint32(iece->reqitem[i]); data << uint32(iece->reqitemcount[i]); @@ -24218,7 +24218,7 @@ void Player::RefundItem(Item *item) } bool store_error = false; - for (uint8 i = 0; i < 5; ++i) + for (uint8 i = 0; i < MAX_ITEM_EXTENDED_COST_REQUIREMENTS; ++i) { uint32 count = iece->reqitemcount[i]; uint32 itemid = iece->reqitem[i]; @@ -24250,7 +24250,7 @@ void Player::RefundItem(Item *item) data << uint32(item->GetPaidMoney()); // money cost data << uint32(iece->reqhonorpoints); // honor point cost data << uint32(iece->reqarenapoints); // arena point cost - for (uint8 i = 0; i < 5; ++i) // item cost data + for (uint8 i = 0; i < MAX_ITEM_EXTENDED_COST_REQUIREMENTS; ++i) // item cost data { data << iece->reqitem[i]; data << (iece->reqitemcount[i]); @@ -24264,7 +24264,7 @@ void Player::RefundItem(Item *item) DestroyItem(item->GetBagSlot(), item->GetSlot(), true); // Grant back extendedcost items - for (uint8 i = 0; i < 5; ++i) + for (uint8 i = 0; i < MAX_ITEM_EXTENDED_COST_REQUIREMENTS; ++i) { uint32 count = iece->reqitemcount[i]; uint32 itemid = iece->reqitem[i]; diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index c13aa68b825..79e31d3e76e 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -2742,7 +2742,7 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell) if (!IsPositiveSpell(spell->Id)) { bool bNegativeAura = false; - for (uint8 i = 0; i < 3; ++i) + for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) { if (spell->EffectApplyAuraName[i] != 0) { @@ -4191,7 +4191,7 @@ void Unit::RemoveArenaAuras(bool onleave) { AuraApplication const * aurApp = iter->second; Aura const * aura = aurApp->GetBase(); - if (!(aura->GetSpellProto()->AttributesEx4 & (1<<21)) // don't remove stances, shadowform, pally/hunter auras + if (!(aura->GetSpellProto()->AttributesEx4 & SPELL_ATTR_EX4_UNK21) // don't remove stances, shadowform, pally/hunter auras && !aura->IsPassive() // don't remove passive auras && (!(aura->GetSpellProto()->Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) || !(aura->GetSpellProto()->Attributes & SPELL_ATTR_UNK8)) // not unaffected by invulnerability auras or not having that unknown flag (that seemed the most probable) && (aurApp->IsPositive() ^ onleave)) // remove positive buffs on enter, negative buffs on leave @@ -11191,7 +11191,7 @@ bool Unit::IsImmunedToSpell(SpellEntry const* spellInfo) return true; } - for (int i=0;i<3;++i) + for (int i = 0; i < MAX_SPELL_EFFECTS; ++i) { // State/effect immunities applied by aura expect full spell immunity // Ignore effects with mechanic, they are supposed to be checked separately diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index f3ee81cc39d..cb61f498c8b 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -681,8 +681,8 @@ enum MovementFlags enum MovementFlags2 { MOVEMENTFLAG2_NONE = 0x00000000, - MOVEMENTFLAG2_UNK1 = 0x00000001, - MOVEMENTFLAG2_UNK2 = 0x00000002, + MOVEMENTFLAG2_NO_STRAFE = 0x00000001, + MOVEMENTFLAG2_NO_JUMPING = 0x00000002, MOVEMENTFLAG2_UNK3 = 0x00000004, MOVEMENTFLAG2_FULL_SPEED_TURNING = 0x00000008, MOVEMENTFLAG2_FULL_SPEED_PITCHING = 0x00000010, diff --git a/src/server/game/Entities/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp index 16bf80aa8be..ecc50a7b45c 100644 --- a/src/server/game/Entities/Vehicle/Vehicle.cpp +++ b/src/server/game/Entities/Vehicle/Vehicle.cpp @@ -29,7 +29,7 @@ Vehicle::Vehicle(Unit *unit, VehicleEntry const *vehInfo) : me(unit), m_vehicleInfo(vehInfo), m_usableSeatNum(0), m_bonusHP(0) { - for (uint32 i = 0; i < 8; ++i) + for (uint32 i = 0; i < MAX_VEHICLE_SEATS; ++i) { if (uint32 seatId = m_vehicleInfo->m_seatID[i]) if (VehicleSeatEntry const *veSeat = sVehicleSeatStore.LookupEntry(seatId)) @@ -305,7 +305,7 @@ bool Vehicle::AddPassenger(Unit *unit, int8 seatId) } } - if (seat->second.seatInfo->m_flags && !(seat->second.seatInfo->m_flags & 0x400)) + if (seat->second.seatInfo->m_flags && !(seat->second.seatInfo->m_flags & VEHICLE_SEAT_FLAG_UNK11)) unit->addUnitState(UNIT_STAT_ONVEHICLE); unit->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT); @@ -319,7 +319,7 @@ bool Vehicle::AddPassenger(Unit *unit, int8 seatId) if (me->GetTypeId() == TYPEID_UNIT && unit->GetTypeId() == TYPEID_PLAYER - && seat->first == 0 && seat->second.seatInfo->m_flags & 0x800) // not right + && seat->first == 0 && seat->second.seatInfo->m_flags & VEHICLE_SEAT_FLAG_CAN_CONTROL) { if (!me->SetCharmedBy(unit, CHARM_TYPE_VEHICLE)) ASSERT(false); @@ -391,7 +391,7 @@ void Vehicle::RemovePassenger(Unit *unit) if (me->GetTypeId() == TYPEID_UNIT && unit->GetTypeId() == TYPEID_PLAYER - && seat->first == 0 && seat->second.seatInfo->m_flags & 0x800) + && seat->first == 0 && seat->second.seatInfo->m_flags & VEHICLE_SEAT_FLAG_CAN_CONTROL) { me->RemoveCharmedBy(unit); diff --git a/src/server/game/Entities/Vehicle/Vehicle.h b/src/server/game/Entities/Vehicle/Vehicle.h index 23872483637..43c0b114d4f 100644 --- a/src/server/game/Entities/Vehicle/Vehicle.h +++ b/src/server/game/Entities/Vehicle/Vehicle.h @@ -33,6 +33,25 @@ enum PowerType POWER_BLOOD = 141 }; +enum VehicleFlags +{ + VEHICLE_FLAG_ADJUST_AIM_ANGLE = 0x00000400, // Lua_IsVehicleAimAngleAdjustable + VEHICLE_FLAG_ADJUST_AIM_POWER = 0x00000800, // Lua_IsVehicleAimPowerAdjustable + VEHICLE_FLAG_CUSTOM_PITCH = 0x00000040, // If set use pitchMin and pitchMax from DBC, otherwise pitchMin = -pi/2, pitchMax = pi/2 +}; + +enum VehicleSeatFlags +{ + VEHICLE_SEAT_FLAG_HIDE_PASSENGER = 0x00000200, // Passenger is hidden + VEHICLE_SEAT_FLAG_UNK11 = 0x00000400, + VEHICLE_SEAT_FLAG_CAN_CONTROL = 0x00000800, // Lua_UnitInVehicleControlSeat + VEHICLE_SEAT_FLAG_CAN_ATTACK = 0x00004000, // Can attack, cast spells and use items from vehicle? + VEHICLE_SEAT_FLAG_USABLE = 0x02000000, // Lua_CanExitVehicle + VEHICLE_SEAT_FLAG_CAN_SWITCH = 0x04000000, // Lua_CanSwitchVehicleSeats + VEHICLE_SEAT_FLAG_CAN_CAST = 0x20000000, // Lua_UnitHasVehicleUI +}; + + struct VehicleSeat { explicit VehicleSeat(VehicleSeatEntry const *_seatInfo) : seatInfo(_seatInfo), passenger(NULL) {} |
