Skip to content

Commit

Permalink
Use separate enum for internal loot type and sended to client loot ty…
Browse files Browse the repository at this point in the history
…pe id.
  • Loading branch information
Cyberium committed Sep 23, 2015
1 parent b7ce58d commit 40ea4de
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 28 deletions.
39 changes: 21 additions & 18 deletions src/game/LootMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,7 @@ void Loot::ShowContentTo(Player* plr)

WorldPacket data(SMSG_LOOT_RESPONSE);
data << m_guidTarget;
data << uint8(m_lootType);
data << uint8(m_clientLootType);

if (GetLootContentFor(plr, data))
SetPlayerIsLooting(plr);
Expand Down Expand Up @@ -1430,7 +1430,7 @@ void Loot::SetGroupLootRight(Player* player)
}

Loot::Loot(Player* player, Creature* creature, LootType type) :
m_lootType(LOOT_NONE), m_lootMethod(NOT_GROUP_TYPE_LOOT), m_threshold(ITEM_QUALITY_UNCOMMON),
m_lootType(type), m_lootMethod(NOT_GROUP_TYPE_LOOT), m_threshold(ITEM_QUALITY_UNCOMMON), m_clientLootType(CLIENT_LOOT_CORPSE),
m_gold(0), m_maxEnchantSkill(0), m_maxSlot(0), m_isReleased(false), m_isChest(false), m_isChanged(false),
m_haveItemOverThreshold(false), m_isChecked(false), m_lootTarget(NULL)
{
Expand All @@ -1451,14 +1451,13 @@ Loot::Loot(Player* player, Creature* creature, LootType type) :
m_guidTarget = creature->GetObjectGuid();
CreatureInfo const* creatureInfo = creature->GetCreatureInfo();

m_lootType = type;

switch (type)
{
case LOOT_CORPSE:
{
// setting loot right
SetGroupLootRight(player);
m_clientLootType = CLIENT_LOOT_CORPSE;

if ((creatureInfo->LootId && FillLoot(creatureInfo->LootId, LootTemplates_Creature, player, false)) || creatureInfo->MaxLootGold > 0)
{
Expand All @@ -1477,7 +1476,9 @@ Loot::Loot(Player* player, Creature* creature, LootType type) :
}
case LOOT_PICKPOCKETING:
{
if (!creature->isAlive() || player->getClass() != CLASS_ROGUE) // TODO add a flag to creature to check if already pickpocketed
m_clientLootType = CLIENT_LOOT_PICKPOCKETING;

if (!creature->isAlive() || player->getClass() != CLASS_ROGUE)
return;

if (!creatureInfo->LootId || !FillLoot(creatureInfo->PickpocketLootId, LootTemplates_Pickpocketing, player, false))
Expand All @@ -1498,6 +1499,7 @@ Loot::Loot(Player* player, Creature* creature, LootType type) :
}
case LOOT_SKINNING:
{
m_clientLootType = CLIENT_LOOT_PICKPOCKETING;
if (!creatureInfo->SkinningLootId || !FillLoot(creatureInfo->SkinningLootId, LootTemplates_Skinning, player, false))
{
sLog.outError("Loot::CreateLoot> cannot create skinning loot, FillLoot failed with loot id(%u)!", creatureInfo->SkinningLootId);
Expand All @@ -1511,15 +1513,14 @@ Loot::Loot(Player* player, Creature* creature, LootType type) :
}
default:
sLog.outError("Loot::CreateLoot> Cannot create loot for %s with invalid LootType(%u)", creature->GetGuidStr().c_str(), uint32(type));
m_lootType = LOOT_NONE;
break;
}

return;
}

Loot::Loot(Player* player, GameObject* gameObject, LootType type) :
m_lootType(LOOT_NONE), m_lootMethod(NOT_GROUP_TYPE_LOOT), m_threshold(ITEM_QUALITY_UNCOMMON),
m_lootType(type), m_lootMethod(NOT_GROUP_TYPE_LOOT), m_threshold(ITEM_QUALITY_UNCOMMON), m_clientLootType(CLIENT_LOOT_CORPSE),
m_gold(0), m_maxEnchantSkill(0), m_maxSlot(0), m_isReleased(false), m_isChest(false), m_isChanged(false),
m_haveItemOverThreshold(false), m_isChecked(false), m_lootTarget(NULL)
{
Expand Down Expand Up @@ -1549,8 +1550,6 @@ Loot::Loot(Player* player, GameObject* gameObject, LootType type) :
return;
}

m_lootType = type;

// generate loot only if ready for open and spawned in world
if (gameObject->getLootState() == GO_READY && gameObject->isSpawned())
{
Expand All @@ -1575,7 +1574,7 @@ Loot::Loot(Player* player, GameObject* gameObject, LootType type) :
// setting loot right
m_ownerSet.insert(player->GetObjectGuid());
m_lootMethod = NOT_GROUP_TYPE_LOOT;
m_lootType = LOOT_FISHING;
m_clientLootType = CLIENT_LOOT_FISHING;
break;
}
case LOOT_FISHING:
Expand All @@ -1590,6 +1589,7 @@ Loot::Loot(Player* player, GameObject* gameObject, LootType type) :
// setting loot right
m_ownerSet.insert(player->GetObjectGuid());
m_lootMethod = NOT_GROUP_TYPE_LOOT;
m_clientLootType = CLIENT_LOOT_FISHING;
break;
}
default:
Expand All @@ -1605,7 +1605,9 @@ Loot::Loot(Player* player, GameObject* gameObject, LootType type) :
GenerateMoneyLoot(gameObject->GetGOInfo()->MinMoneyLoot, gameObject->GetGOInfo()->MaxMoneyLoot);

if (m_lootType == LOOT_FISHINGHOLE)
m_lootType = LOOT_FISHING;
m_clientLootType = CLIENT_LOOT_FISHING;
else
m_clientLootType = CLIENT_LOOT_PICKPOCKETING;
}
break;
}
Expand All @@ -1617,7 +1619,7 @@ Loot::Loot(Player* player, GameObject* gameObject, LootType type) :
}

Loot::Loot(Player* player, Corpse* corpse, LootType type) :
m_lootType(LOOT_NONE), m_lootMethod(NOT_GROUP_TYPE_LOOT), m_threshold(ITEM_QUALITY_UNCOMMON),
m_lootType(type), m_lootMethod(NOT_GROUP_TYPE_LOOT), m_threshold(ITEM_QUALITY_UNCOMMON), m_clientLootType(CLIENT_LOOT_CORPSE),
m_gold(0), m_maxEnchantSkill(0), m_maxSlot(0), m_isReleased(false), m_isChest(false), m_isChanged(false),
m_haveItemOverThreshold(false), m_isChecked(false), m_lootTarget(NULL)
{
Expand All @@ -1636,7 +1638,6 @@ Loot::Loot(Player* player, Corpse* corpse, LootType type) :

m_lootTarget = corpse;
m_guidTarget = corpse->GetObjectGuid();
m_lootType = type;

if (type != LOOT_INSIGNIA || corpse->GetType() == CORPSE_BONES)
return;
Expand All @@ -1658,11 +1659,12 @@ Loot::Loot(Player* player, Corpse* corpse, LootType type) :
}
m_ownerSet.insert(player->GetObjectGuid());
m_lootMethod = NOT_GROUP_TYPE_LOOT;
m_clientLootType = CLIENT_LOOT_CORPSE;
return;
}

Loot::Loot(Player* player, Item* item, LootType type) :
m_lootType(LOOT_NONE), m_lootMethod(NOT_GROUP_TYPE_LOOT), m_threshold(ITEM_QUALITY_UNCOMMON),
m_lootType(type), m_lootMethod(NOT_GROUP_TYPE_LOOT), m_threshold(ITEM_QUALITY_UNCOMMON), m_clientLootType(CLIENT_LOOT_CORPSE),
m_gold(0), m_maxEnchantSkill(0), m_maxSlot(0), m_isReleased(false), m_isChest(false), m_isChanged(false),
m_haveItemOverThreshold(false), m_isChecked(false), m_lootTarget(NULL)
{
Expand All @@ -1682,8 +1684,6 @@ Loot::Loot(Player* player, Item* item, LootType type) :
m_itemTarget = item;
m_guidTarget = item->GetObjectGuid();

m_lootType = type;

switch (type)
{
case LOOT_DISENCHANTING:
Expand All @@ -1706,11 +1706,12 @@ Loot::Loot(Player* player, Item* item, LootType type) :
}
m_ownerSet.insert(player->GetObjectGuid());
m_lootMethod = NOT_GROUP_TYPE_LOOT;
m_clientLootType = CLIENT_LOOT_PICKPOCKETING;
return;
}

Loot::Loot(Unit* unit, Item* item) :
m_lootType(LOOT_SKINNING), m_lootMethod(NOT_GROUP_TYPE_LOOT), m_threshold(ITEM_QUALITY_UNCOMMON),
m_lootType(LOOT_SKINNING), m_lootMethod(NOT_GROUP_TYPE_LOOT), m_threshold(ITEM_QUALITY_UNCOMMON), m_clientLootType(CLIENT_LOOT_PICKPOCKETING),
m_gold(0), m_maxEnchantSkill(0), m_maxSlot(0), m_isReleased(false), m_isChest(false), m_isChanged(false),
m_haveItemOverThreshold(false), m_isChecked(false), m_lootTarget(NULL), m_itemTarget(item)
{
Expand All @@ -1719,17 +1720,19 @@ Loot::Loot(Unit* unit, Item* item) :
}

Loot::Loot(Player* player, uint32 id, LootType type) :
m_lootType(type), m_lootMethod(NOT_GROUP_TYPE_LOOT), m_threshold(ITEM_QUALITY_UNCOMMON),
m_lootType(type), m_lootMethod(NOT_GROUP_TYPE_LOOT), m_threshold(ITEM_QUALITY_UNCOMMON), m_clientLootType(CLIENT_LOOT_CORPSE),
m_gold(0), m_maxEnchantSkill(0), m_maxSlot(0), m_isReleased(false), m_isChest(false), m_isChanged(false),
m_haveItemOverThreshold(false), m_isChecked(false), m_lootTarget(NULL)
{
switch (type)
{
case LOOT_MAIL:
FillLoot(id, LootTemplates_Mail, player, true, true);
m_clientLootType = CLIENT_LOOT_PICKPOCKETING;
break;
case LOOT_SKINNING:
FillLoot(id, LootTemplates_Skinning, player, true, true);
m_clientLootType = CLIENT_LOOT_PICKPOCKETING;
break;
default:
sLog.outError("Loot::Loot> invalid loot type passed to loot constructor.");
Expand Down
13 changes: 12 additions & 1 deletion src/game/LootMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ enum LootItemType
LOOTITEM_TYPE_CONDITIONNAL = 3
};

// loot type sent to clients
enum ClientLootType
{
CLIENT_LOOT_CORPSE = 1,
CLIENT_LOOT_PICKPOCKETING = 2,
CLIENT_LOOT_FISHING = 3,
CLIENT_LOOT_DISENCHANTING = 4
};


struct PlayerRollVote
{
PlayerRollVote() : vote(ROLL_NOT_VALID), number(0) {}
Expand Down Expand Up @@ -313,7 +323,8 @@ class Loot
LootItemList m_lootItems; // store of the items contained in loot
uint32 m_gold; // amount of money contained in loot
uint32 m_maxSlot; // used to increment slot index and get total items count
LootType m_lootType; // required for achievement system
LootType m_lootType; // internal loot type
ClientLootType m_clientLootType; // client loot type
LootMethod m_lootMethod; // used to know what kind of check must be done at loot time
ItemQualities m_threshold; // group threshold for items
ObjectGuid m_masterOwnerGuid; // master loot player or round robin owner
Expand Down
15 changes: 6 additions & 9 deletions src/game/SharedDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -3104,24 +3104,21 @@ enum LootMethod
NOT_GROUP_TYPE_LOOT = 5 // internal use only
};

// internal loot type
enum LootType
{
LOOT_NONE = 0, // for internal use only
LOOT_CORPSE = 1,
LOOT_PICKPOCKETING = 2,
LOOT_FISHING = 3,
LOOT_DISENCHANTING = 4,

// ignored always by client
LOOT_SKINNING = 6,
LOOT_PROSPECTING = 7,
LOOT_MILLING = 8,

LOOT_FISHINGHOLE = 20, // unsupported by client, sending LOOT_FISHING instead
LOOT_FISHING_FAIL = 21, // unsupported by client, sending LOOT_FISHING instead
LOOT_INSIGNIA = 22, // unsupported by client, sending LOOT_CORPSE instead
LOOT_MAIL = 23, // unsupported by client, not send at all (only used to generate loot)
LOOT_SPELL = 24, // unsupported by client, not send at all (only used to generate loot)
LOOT_FISHINGHOLE = 20,
LOOT_FISHING_FAIL = 21,
LOOT_INSIGNIA = 22,
LOOT_MAIL = 23,
LOOT_SPELL = 24,
};

#endif

0 comments on commit 40ea4de

Please sign in to comment.