]> git.lizzy.rs Git - minetest.git/blob - src/server/serverinventorymgr.h
Settings: Remove unused functions
[minetest.git] / src / server / serverinventorymgr.h
1 /*
2 Minetest
3 Copyright (C) 2010-2020 Minetest core development team
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #pragma once
21
22 #include "inventorymanager.h"
23 #include <functional>
24
25 class ServerEnvironment;
26
27 class ServerInventoryManager : public InventoryManager
28 {
29 public:
30         ServerInventoryManager();
31         virtual ~ServerInventoryManager();
32
33         void setEnv(ServerEnvironment *env)
34         {
35                 assert(!m_env);
36                 m_env = env;
37         }
38
39         Inventory *getInventory(const InventoryLocation &loc);
40         void setInventoryModified(const InventoryLocation &loc);
41
42         // Creates or resets inventory
43         Inventory *createDetachedInventory(const std::string &name, IItemDefManager *idef,
44                         const std::string &player = "");
45         bool removeDetachedInventory(const std::string &name);
46
47         void sendDetachedInventories(const std::string &peer_name, bool incremental,
48                         std::function<void(const std::string &, Inventory *)> apply_cb);
49
50 private:
51         struct DetachedInventory
52         {
53                 Inventory *inventory;
54                 std::string owner;
55         };
56
57         ServerEnvironment *m_env = nullptr;
58
59         std::unordered_map<std::string, DetachedInventory> m_detached_inventories;
60 };