[9455] Check glyph index send by client at glyph adding to prevent cheating.

This commit is contained in:
VladimirMangos 2010-02-26 01:26:30 +03:00
parent 73eeac234f
commit 62726741d6
2 changed files with 15 additions and 8 deletions

View file

@ -47,14 +47,21 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
recvPacket >> bagIndex >> slot >> cast_count >> spellid >> item_guid >> glyphIndex >> unk_flags; recvPacket >> bagIndex >> slot >> cast_count >> spellid >> item_guid >> glyphIndex >> unk_flags;
Item *pItem = pUser->GetItemByPos(bagIndex, slot); // reject fake data
if(!pItem) if (glyphIndex >= MAX_GLYPH_SLOT_INDEX)
{ {
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL ); pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL );
return; return;
} }
if(pItem->GetGUID() != item_guid) Item *pItem = pUser->GetItemByPos(bagIndex, slot);
if (!pItem)
{
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL );
return;
}
if (pItem->GetGUID() != item_guid)
{ {
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL ); pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL );
return; return;
@ -63,28 +70,28 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
sLog.outDetail("WORLD: CMSG_USE_ITEM packet, bagIndex: %u, slot: %u, cast_count: %u, spellid: %u, Item: %u, glyphIndex: %u, unk_flags: %u, data length = %i", bagIndex, slot, cast_count, spellid, pItem->GetEntry(), glyphIndex, unk_flags, (uint32)recvPacket.size()); sLog.outDetail("WORLD: CMSG_USE_ITEM packet, bagIndex: %u, slot: %u, cast_count: %u, spellid: %u, Item: %u, glyphIndex: %u, unk_flags: %u, data length = %i", bagIndex, slot, cast_count, spellid, pItem->GetEntry(), glyphIndex, unk_flags, (uint32)recvPacket.size());
ItemPrototype const *proto = pItem->GetProto(); ItemPrototype const *proto = pItem->GetProto();
if(!proto) if (!proto)
{ {
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, pItem, NULL ); pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, pItem, NULL );
return; return;
} }
// some item classes can be used only in equipped state // some item classes can be used only in equipped state
if(proto->InventoryType != INVTYPE_NON_EQUIP && !pItem->IsEquipped()) if (proto->InventoryType != INVTYPE_NON_EQUIP && !pItem->IsEquipped())
{ {
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, pItem, NULL ); pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, pItem, NULL );
return; return;
} }
uint8 msg = pUser->CanUseItem(pItem); uint8 msg = pUser->CanUseItem(pItem);
if( msg != EQUIP_ERR_OK ) if (msg != EQUIP_ERR_OK)
{ {
pUser->SendEquipError( msg, pItem, NULL ); pUser->SendEquipError( msg, pItem, NULL );
return; return;
} }
// only allow conjured consumable, bandage, poisons (all should have the 2^21 item flag set in DB) // only allow conjured consumable, bandage, poisons (all should have the 2^21 item flag set in DB)
if( proto->Class == ITEM_CLASS_CONSUMABLE && if (proto->Class == ITEM_CLASS_CONSUMABLE &&
!(proto->Flags & ITEM_FLAGS_USEABLE_IN_ARENA) && !(proto->Flags & ITEM_FLAGS_USEABLE_IN_ARENA) &&
pUser->InArena()) pUser->InArena())
{ {

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "9454" #define REVISION_NR "9455"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__