TrinityCore
Loading...
Searching...
No Matches
LootItemStorage.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef __LOOTITEMSTORAGE_H
19#define __LOOTITEMSTORAGE_H
20
21#include "Define.h"
22#include "DatabaseEnvFwd.h"
23
24#include <shared_mutex>
25#include <unordered_map>
26
27class Item;
28class Player;
29struct Loot;
30struct LootItem;
31
48
50{
51 public:
52 typedef std::unordered_multimap<uint32 /*itemId*/, StoredLootItem> StoredLootItemContainer;
53
54 explicit StoredLootContainer(uint32 containerId) : _containerId(containerId), _money(0) { }
55
56 void AddLootItem(LootItem const& lootItem, CharacterDatabaseTransaction trans);
58
59 void RemoveMoney();
60 void RemoveItem(uint32 itemId, uint32 count, uint32 itemIndex);
61
62 uint32 GetContainer() const { return _containerId; }
63 uint32 GetMoney() const { return _money; }
65
66 private:
70};
71
73{
74 public:
75 static LootItemStorage* instance();
76 static std::shared_mutex* GetLock();
77
78 void LoadStorageFromDB();
79 bool LoadStoredLoot(Item* item, Player* player);
80 void RemoveStoredMoneyForContainer(uint32 containerId);
81 void RemoveStoredLootForContainer(uint32 containerId);
82 void RemoveStoredLootItemForContainer(uint32 containerId, uint32 itemId, uint32 count, uint32 itemIndex);
83 void AddNewStoredLoot(Loot* loot, Player* player);
84
85 private:
88};
89
90#define sLootItemStorage LootItemStorage::instance()
91
92#endif
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
Definition Item.h:62
void AddNewStoredLoot(Loot *loot, Player *player)
static LootItemStorage * instance()
void RemoveStoredLootItemForContainer(uint32 containerId, uint32 itemId, uint32 count, uint32 itemIndex)
static std::shared_mutex * GetLock()
void RemoveStoredLootForContainer(uint32 containerId)
void RemoveStoredMoneyForContainer(uint32 containerId)
bool LoadStoredLoot(Item *item, Player *player)
std::unordered_multimap< uint32, StoredLootItem > StoredLootItemContainer
StoredLootContainer(uint32 containerId)
void RemoveItem(uint32 itemId, uint32 count, uint32 itemIndex)
void AddLootItem(LootItem const &lootItem, CharacterDatabaseTransaction trans)
StoredLootItemContainer _lootItems
uint32 const _containerId
uint32 GetContainer() const
void AddMoney(uint32 money, CharacterDatabaseTransaction trans)
StoredLootItemContainer const & GetLootItems() const
uint32 GetMoney() const
Definition Loot.h:207