converted all tabs to 4 spaces

This commit is contained in:
Yehonal
2016-06-26 19:23:57 +02:00
parent 52f305111c
commit f6eefedcd5
717 changed files with 132388 additions and 132388 deletions

View File

@@ -15,27 +15,27 @@ LootItemStorage::~LootItemStorage()
void LootItemStorage::LoadStorageFromDB()
{
uint32 oldMSTime = getMSTime();
lootItemStore.clear();
lootItemStore.clear();
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ITEMCONTAINER_ITEMS);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (!result)
{
sLog->outString(">> Loaded 0 stored items!");
sLog->outString();
sLog->outString();
return;
}
uint32 count = 0;
uint32 count = 0;
do
{
Field* fields = result->Fetch();
StoredLootItemList& itemList = lootItemStore[fields[0].GetUInt32()];
itemList.push_back(StoredLootItem(fields[1].GetUInt32(), fields[2].GetUInt32(), fields[3].GetInt32(), fields[4].GetUInt32()));
StoredLootItemList& itemList = lootItemStore[fields[0].GetUInt32()];
itemList.push_back(StoredLootItem(fields[1].GetUInt32(), fields[2].GetUInt32(), fields[3].GetInt32(), fields[4].GetUInt32()));
++count;
} while (result->NextRow());
++count;
} while (result->NextRow());
sLog->outString(">> Loaded %d stored items in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
@@ -43,101 +43,101 @@ void LootItemStorage::LoadStorageFromDB()
void LootItemStorage::RemoveEntryFromDB(uint32 containerId, uint32 itemid, uint32 count)
{
SQLTransaction trans = CharacterDatabase.BeginTransaction();
SQLTransaction trans = CharacterDatabase.BeginTransaction();
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_SINGLE_ITEM);
stmt->setUInt32(0, containerId);
stmt->setUInt32(1, itemid);
stmt->setUInt32(2, count);
trans->Append(stmt);
stmt->setUInt32(1, itemid);
stmt->setUInt32(2, count);
trans->Append(stmt);
CharacterDatabase.CommitTransaction(trans);
}
void LootItemStorage::AddNewStoredLoot(Loot* loot, Player* player)
{
if (lootItemStore.find(loot->containerId) != lootItemStore.end())
{
sLog->outMisc("LootItemStorage::AddNewStoredLoot (A1) - %u!", loot->containerId);
return;
}
if (lootItemStore.find(loot->containerId) != lootItemStore.end())
{
sLog->outMisc("LootItemStorage::AddNewStoredLoot (A1) - %u!", loot->containerId);
return;
}
SQLTransaction trans = CharacterDatabase.BeginTransaction();
PreparedStatement* stmt = NULL;
SQLTransaction trans = CharacterDatabase.BeginTransaction();
PreparedStatement* stmt = NULL;
StoredLootItemList& itemList = lootItemStore[loot->containerId];
StoredLootItemList& itemList = lootItemStore[loot->containerId];
// Gold at first
if (loot->gold)
{
itemList.push_back(StoredLootItem(0, loot->gold, 0, 0));
// Gold at first
if (loot->gold)
{
itemList.push_back(StoredLootItem(0, loot->gold, 0, 0));
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ITEMCONTAINER_SINGLE_ITEM);
stmt->setUInt32(0, loot->containerId);
stmt->setUInt32(1, 0);
stmt->setUInt32(2, loot->gold);
stmt->setInt32(3, 0);
stmt->setUInt32(4, 0);
trans->Append(stmt);
}
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ITEMCONTAINER_SINGLE_ITEM);
stmt->setUInt32(0, loot->containerId);
stmt->setUInt32(1, 0);
stmt->setUInt32(2, loot->gold);
stmt->setInt32(3, 0);
stmt->setUInt32(4, 0);
trans->Append(stmt);
}
// And normal items
if (!loot->isLooted())
for (LootItemList::const_iterator li = loot->items.begin(); li != loot->items.end(); li++)
{
if (!li->AllowedForPlayer(player))
continue;
// And normal items
if (!loot->isLooted())
for (LootItemList::const_iterator li = loot->items.begin(); li != loot->items.end(); li++)
{
if (!li->AllowedForPlayer(player))
continue;
const ItemTemplate* itemTemplate = sObjectMgr->GetItemTemplate(li->itemid);
if (!itemTemplate || itemTemplate->IsCurrencyToken())
continue;
const ItemTemplate* itemTemplate = sObjectMgr->GetItemTemplate(li->itemid);
if (!itemTemplate || itemTemplate->IsCurrencyToken())
continue;
itemList.push_back(StoredLootItem(li->itemid, li->count, li->randomPropertyId, li->randomSuffix));
itemList.push_back(StoredLootItem(li->itemid, li->count, li->randomPropertyId, li->randomSuffix));
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ITEMCONTAINER_SINGLE_ITEM);
stmt->setUInt32(0, loot->containerId);
stmt->setUInt32(1, li->itemid);
stmt->setUInt32(2, li->count);
stmt->setInt32 (3, li->randomPropertyId);
stmt->setUInt32(4, li->randomSuffix);
trans->Append(stmt);
}
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ITEMCONTAINER_SINGLE_ITEM);
stmt->setUInt32(0, loot->containerId);
stmt->setUInt32(1, li->itemid);
stmt->setUInt32(2, li->count);
stmt->setInt32 (3, li->randomPropertyId);
stmt->setUInt32(4, li->randomSuffix);
trans->Append(stmt);
}
CharacterDatabase.CommitTransaction(trans);
}
bool LootItemStorage::LoadStoredLoot(Item* item)
{
Loot* loot = &item->loot;
LootItemContainer::iterator itr = lootItemStore.find(loot->containerId);
if (itr == lootItemStore.end())
return false;
Loot* loot = &item->loot;
LootItemContainer::iterator itr = lootItemStore.find(loot->containerId);
if (itr == lootItemStore.end())
return false;
StoredLootItemList& itemList = itr->second;
for (StoredLootItemList::iterator it2 = itemList.begin(); it2 != itemList.end(); ++it2)
{
if (it2->itemid == 0)
{
loot->gold = it2->count;
continue;
}
StoredLootItemList& itemList = itr->second;
for (StoredLootItemList::iterator it2 = itemList.begin(); it2 != itemList.end(); ++it2)
{
if (it2->itemid == 0)
{
loot->gold = it2->count;
continue;
}
LootItem li;
li.itemid = it2->itemid;
li.count = it2->count;
li.follow_loot_rules = false;
li.freeforall = false;
li.is_blocked = false;
li.is_counted = false;
li.is_underthreshold = false;
li.is_looted = false;
li.needs_quest = false;
li.randomPropertyId = it2->randomPropertyId;
li.randomSuffix = it2->randomSuffix;
li.rollWinnerGUID = 0;
LootItem li;
li.itemid = it2->itemid;
li.count = it2->count;
li.follow_loot_rules = false;
li.freeforall = false;
li.is_blocked = false;
li.is_counted = false;
li.is_underthreshold = false;
li.is_looted = false;
li.needs_quest = false;
li.randomPropertyId = it2->randomPropertyId;
li.randomSuffix = it2->randomSuffix;
li.rollWinnerGUID = 0;
loot->items.push_back(li);
loot->unlootedCount++;
}
loot->items.push_back(li);
loot->unlootedCount++;
}
// Mark the item if it has loot so it won't be generated again on open
item->m_lootGenerated = true;
@@ -146,50 +146,50 @@ bool LootItemStorage::LoadStoredLoot(Item* item)
void LootItemStorage::RemoveStoredLootItem(uint32 containerId, uint32 itemid, uint32 count)
{
LootItemContainer::iterator itr = lootItemStore.find(containerId);
if (itr == lootItemStore.end())
return;
LootItemContainer::iterator itr = lootItemStore.find(containerId);
if (itr == lootItemStore.end())
return;
StoredLootItemList& itemList = itr->second;
for (StoredLootItemList::iterator it2 = itemList.begin(); it2 != itemList.end(); ++it2)
if (it2->itemid == itemid && it2->count == count)
{
RemoveEntryFromDB(containerId, itemid, count);
itemList.erase(it2);
break;
}
StoredLootItemList& itemList = itr->second;
for (StoredLootItemList::iterator it2 = itemList.begin(); it2 != itemList.end(); ++it2)
if (it2->itemid == itemid && it2->count == count)
{
RemoveEntryFromDB(containerId, itemid, count);
itemList.erase(it2);
break;
}
if (itemList.empty())
lootItemStore.erase(itr);
if (itemList.empty())
lootItemStore.erase(itr);
}
void LootItemStorage::RemoveStoredLootMoney(uint32 containerId)
{
LootItemContainer::iterator itr = lootItemStore.find(containerId);
if (itr == lootItemStore.end())
return;
LootItemContainer::iterator itr = lootItemStore.find(containerId);
if (itr == lootItemStore.end())
return;
StoredLootItemList& itemList = itr->second;
for (StoredLootItemList::iterator it2 = itemList.begin(); it2 != itemList.end(); ++it2)
if (it2->itemid == 0)
{
RemoveEntryFromDB(containerId, 0, it2->count);
itemList.erase(it2);
break;
}
StoredLootItemList& itemList = itr->second;
for (StoredLootItemList::iterator it2 = itemList.begin(); it2 != itemList.end(); ++it2)
if (it2->itemid == 0)
{
RemoveEntryFromDB(containerId, 0, it2->count);
itemList.erase(it2);
break;
}
if (itemList.empty())
lootItemStore.erase(itr);
if (itemList.empty())
lootItemStore.erase(itr);
}
void LootItemStorage::RemoveStoredLoot(uint32 containerId)
{
lootItemStore.erase(containerId);
lootItemStore.erase(containerId);
SQLTransaction trans = CharacterDatabase.BeginTransaction();
SQLTransaction trans = CharacterDatabase.BeginTransaction();
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_CONTAINER);
stmt->setUInt32(0, containerId);
trans->Append(stmt);
trans->Append(stmt);
CharacterDatabase.CommitTransaction(trans);
}

View File

@@ -10,14 +10,14 @@ Xinef
struct StoredLootItem
{
StoredLootItem(uint32 i, uint32 c, int32 ri, uint32 rs) :
itemid(i), count(c), randomPropertyId(ri), randomSuffix(rs) { }
StoredLootItem(uint32 i, uint32 c, int32 ri, uint32 rs) :
itemid(i), count(c), randomPropertyId(ri), randomSuffix(rs) { }
// If itemid == 0 - money amount is stored in count value
uint32 itemid;
uint32 count;
int32 randomPropertyId;
uint32 randomSuffix;
// If itemid == 0 - money amount is stored in count value
uint32 itemid;
uint32 count;
int32 randomPropertyId;
uint32 randomSuffix;
};
typedef std::list<StoredLootItem> StoredLootItemList;
@@ -27,23 +27,23 @@ class LootItemStorage
{
friend class ACE_Singleton<LootItemStorage, ACE_Thread_Mutex>;
private:
LootItemStorage();
~LootItemStorage();
private:
LootItemStorage();
~LootItemStorage();
public:
void LoadStorageFromDB();
void RemoveEntryFromDB(uint32 containerId, uint32 itemid, uint32 count);
public:
void LoadStorageFromDB();
void RemoveEntryFromDB(uint32 containerId, uint32 itemid, uint32 count);
void AddNewStoredLoot(Loot* loot, Player* player);
bool LoadStoredLoot(Item* item);
void AddNewStoredLoot(Loot* loot, Player* player);
bool LoadStoredLoot(Item* item);
void RemoveStoredLootItem(uint32 containerId, uint32 itemid, uint32 count);
void RemoveStoredLootMoney(uint32 containerId);
void RemoveStoredLoot(uint32 containerId);
void RemoveStoredLootItem(uint32 containerId, uint32 itemid, uint32 count);
void RemoveStoredLootMoney(uint32 containerId);
void RemoveStoredLoot(uint32 containerId);
private:
LootItemContainer lootItemStore;
private:
LootItemContainer lootItemStore;
};
#define sLootItemStorage ACE_Singleton<LootItemStorage, ACE_Thread_Mutex>::instance()

View File

@@ -62,9 +62,9 @@ struct LootGroupInvalidSelector : public std::unary_function<LootStoreItem*, boo
if (!(item->lootmode & _lootMode))
return true;
ItemTemplate const* _proto = sObjectMgr->GetItemTemplate(item->itemid);
if (!_proto)
return true;
ItemTemplate const* _proto = sObjectMgr->GetItemTemplate(item->itemid);
if (!_proto)
return true;
uint8 foundDuplicates = 0;
for (std::vector<LootItem>::const_iterator itr = _loot.items.begin(); itr != _loot.items.end(); ++itr)
@@ -167,11 +167,11 @@ uint32 LootStore::LoadLootTable()
continue; // error already printed to log/console.
}
if (lootmode == 0)
{
sLog->outError("Table '%s' entry %d item %d: lootmode is equal to 0, item will never drop - setting mode 1", GetName(), entry, item);
lootmode = 1;
}
if (lootmode == 0)
{
sLog->outError("Table '%s' entry %d item %d: lootmode is equal to 0, item will never drop - setting mode 1", GetName(), entry, item);
lootmode = 1;
}
LootStoreItem* storeitem = new LootStoreItem(item, chanceOrQuestChance, lootmode, group, mincountOrRef, maxcount);
@@ -384,7 +384,7 @@ LootItem::LootItem(LootStoreItem const& li)
is_blocked = 0;
is_underthreshold = 0;
is_counted = 0;
rollWinnerGUID = 0;
rollWinnerGUID = 0;
}
// Basic checks for player/item compatibility - if false no chance to see the item in the loot
@@ -907,13 +907,13 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv)
continue;
}
}
else if (l.items[i].rollWinnerGUID)
{
if (l.items[i].rollWinnerGUID == lv.viewer->GetGUID())
slot_type = LOOT_SLOT_TYPE_OWNER;
else
continue;
}
else if (l.items[i].rollWinnerGUID)
{
if (l.items[i].rollWinnerGUID == lv.viewer->GetGUID())
slot_type = LOOT_SLOT_TYPE_OWNER;
else
continue;
}
else if (l.roundRobinPlayer == 0 || lv.viewer->GetGUID() == l.roundRobinPlayer || !l.items[i].is_underthreshold)
{
// no round robin owner or he has released the loot
@@ -1028,7 +1028,7 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv)
{
b << uint8(fi->index);
b << item;
// Xinef: Here are FFA items, so dont use owner permision
// Xinef: Here are FFA items, so dont use owner permision
b << uint8(LOOT_SLOT_TYPE_ALLOW_LOOT /*slotType*/);
++itemsShown;
}

View File

@@ -155,7 +155,7 @@ struct LootItem
int32 randomPropertyId;
ConditionList conditions; // additional loot condition
AllowedLooterSet allowedGUIDs;
uint64 rollWinnerGUID; // Stores the guid of person who won loot, if his bags are full only he can see the item in loot list!
uint64 rollWinnerGUID; // Stores the guid of person who won loot, if his bags are full only he can see the item in loot list!
uint8 count : 8;
bool is_looted : 1;
bool is_blocked : 1;
@@ -169,7 +169,7 @@ struct LootItem
// Should be called for non-reference LootStoreItem entries only (mincountOrRef > 0)
explicit LootItem(LootStoreItem const& li);
LootItem() {}
LootItem() {}
// Basic checks for player/item compatibility - if false no chance to see the item in the loot
bool AllowedForPlayer(Player const* player) const;