Fix one WPE exploit.

When apply more 6 gems, and after  player logout, server crash, also apply code style and cleanup.

--HG--
branch : trunk
This commit is contained in:
n0n4m3
2010-03-23 14:38:31 -05:00
parent 1e9de7dbd7
commit 5fe2454b24
2 changed files with 101 additions and 96 deletions
+1 -1
View File
@@ -6337,7 +6337,7 @@ void Spell::EffectActivateObject(uint32 effect_idx)
void Spell::EffectApplyGlyph(uint32 i)
{
if(m_caster->GetTypeId() != TYPEID_PLAYER)
if (m_caster->GetTypeId() != TYPEID_PLAYER || m_glyphIndex >= MAX_GLYPH_SLOT_INDEX)
return;
Player *player = (Player*)m_caster;
+41 -36
View File
@@ -51,6 +51,12 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
recvPacket >> bagIndex >> slot >> cast_count >> spellid >> item_guid >> glyphIndex >> unk_flags;
if (glyphIndex >= MAX_GLYPH_SLOT_INDEX)
{
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
return;
}
Item *pItem = pUser->GetUseableItemByPos(bagIndex, slot);
if (!pItem)
{
@@ -88,9 +94,7 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
}
// only allow conjured consumable, bandage, poisons (all should have the 2^21 item flag set in DB)
if( proto->Class == ITEM_CLASS_CONSUMABLE &&
!(proto->Flags & ITEM_FLAGS_USEABLE_IN_ARENA) &&
pUser->InArena())
if (proto->Class == ITEM_CLASS_CONSUMABLE && !(proto->Flags & ITEM_FLAGS_USEABLE_IN_ARENA) && pUser->InArena())
{
pUser->SendEquipError(EQUIP_ERR_NOT_DURING_ARENA_MATCH,pItem,NULL);
return;
@@ -299,8 +303,7 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
return;
}
sLog.outDebug("WORLD: got cast spell packet, spellId - %u, cast_count: %u, unk_flags %u, data length = %i",
spellId, cast_count, unk_flags, (uint32)recvPacket.size());
sLog.outDebug("WORLD: got cast spell packet, spellId - %u, cast_count: %u, unk_flags %u, data length = %i", spellId, cast_count, unk_flags, (uint32)recvPacket.size());
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId );
@@ -464,7 +467,6 @@ void WorldSession::HandlePetCancelAuraOpcode( WorldPacket& recvPacket)
void WorldSession::HandleCancelGrowthAuraOpcode( WorldPacket& /*recvPacket*/)
{
// nothing do
}
void WorldSession::HandleCancelAutoRepeatSpellOpcode( WorldPacket& /*recvPacket*/)
@@ -573,27 +575,28 @@ void WorldSession::HandleMirrrorImageDataRequest( WorldPacket & recv_data )
Unit *unit = ObjectAccessor::GetObjectInWorld(guid, (Unit*)NULL);
if (!unit)
return;
// Get creator of the unit
Unit *creator = ObjectAccessor::GetObjectInWorld(unit->GetCreatorGUID(),(Unit*)NULL);
if (!creator)
return;
WorldPacket data(SMSG_MIRRORIMAGE_DATA, 68);
data << (uint64)guid;
data << (uint32)creator->GetDisplayId();
data << uint64(guid);
data << uint32(creator->GetDisplayId());
if (creator->GetTypeId() == TYPEID_PLAYER)
{
Player * pCreator = creator->ToPlayer();
data << (uint8)pCreator->getRace();
data << (uint8)pCreator->getGender();
data << (uint8)pCreator->getClass();
data << (uint8)pCreator->GetByteValue(PLAYER_BYTES, 0); // skin
data << uint8(pCreator->getRace());
data << uint8(pCreator->getGender());
data << uint8(pCreator->getClass());
data << uint8(pCreator->GetByteValue(PLAYER_BYTES, 0)); // skin
data << uint8(pCreator->GetByteValue(PLAYER_BYTES, 1)); // face
data << uint8(pCreator->GetByteValue(PLAYER_BYTES, 2)); // hair
data << uint8(pCreator->GetByteValue(PLAYER_BYTES, 3)); // haircolor
data << uint8(pCreator->GetByteValue(PLAYER_BYTES_2, 0)); // facialhair
data << uint32(pCreator->GetGuildId()); // unk
data << (uint8)pCreator->GetByteValue(PLAYER_BYTES, 1); // face
data << (uint8)pCreator->GetByteValue(PLAYER_BYTES, 2); // hair
data << (uint8)pCreator->GetByteValue(PLAYER_BYTES, 3); // haircolor
data << (uint8)pCreator->GetByteValue(PLAYER_BYTES_2, 0); // facialhair
data << (uint32)pCreator->GetGuildId(); // unk
static const EquipmentSlots ItemSlots[] =
{
EQUIPMENT_SLOT_HEAD,
@@ -609,36 +612,38 @@ void WorldSession::HandleMirrrorImageDataRequest( WorldPacket & recv_data )
EQUIPMENT_SLOT_TABARD,
EQUIPMENT_SLOT_END
};
// Display items in visible slots
for (EquipmentSlots const* itr = &ItemSlots[0]; *itr!=EQUIPMENT_SLOT_END; ++itr)
{
if (*itr == EQUIPMENT_SLOT_HEAD && pCreator->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM))
data << (uint32)0;
data << uint32(0);
else if (*itr == EQUIPMENT_SLOT_BACK && pCreator->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK))
data << (uint32)0;
data << uint32(0);
else if (Item const *item = pCreator->GetItemByPos(INVENTORY_SLOT_BAG_0, *itr))
data << (uint32)item->GetProto()->DisplayInfoID;
data << uint32(item->GetProto()->DisplayInfoID);
else
data << (uint32)0;
data << uint32(0);
}
}
else
{
// Skip player data for creatures
data << (uint32)0;
data << (uint32)0;
data << (uint32)0;
data << (uint32)0;
data << (uint32)0;
data << (uint32)0;
data << (uint32)0;
data << (uint32)0;
data << (uint32)0;
data << (uint32)0;
data << (uint32)0;
data << (uint32)0;
data << (uint32)0;
data << (uint32)0;
data << uint32(0);
data << uint32(0);
data << uint32(0);
data << uint32(0);
data << uint32(0);
data << uint32(0);
data << uint32(0);
data << uint32(0);
data << uint32(0);
data << uint32(0);
data << uint32(0);
data << uint32(0);
data << uint32(0);
data << uint32(0);
}
SendPacket(&data);
}