Otclient  14/8/2020
thingstype.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2020 OTClient <https://github.com/edubart/otclient>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  * THE SOFTWARE.
21  */
22 
23 #ifndef DATMANAGER_H
24 #define DATMANAGER_H
25 
26 #include <framework/global.h>
28 #include "thingtype.h"
29 
30 //@bindsingleton g_thingsType
32 {
33 public:
34 
35  enum Categories {
36  Item = 0,
41  };
42 
43  bool load(const std::string& file);
44  void unload();
45 
46  bool parseThingType(const FileStreamPtr& fin, ThingType& thingType);
47 
48  ThingType *getEmptyThingType() { return &m_emptyThingType; }
49  ThingType *getThingType(uint16 id, Categories category);
50 
51  uint32 getSignature() { return m_signature; }
52  bool isLoaded() { return m_loaded; }
53 
54  uint16 getFirstItemId() { return 100; }
55  uint16 getMaxItemid() { return m_things[Item].size() + 99; }
56  bool isValidItemId(int id) { return id >= getFirstItemId() && id <= getMaxItemid(); }
57 
58 private:
59  uint32 m_signature;
60  stdext::boolean<false> m_loaded;
61  ThingTypeList m_things[LastCategory];
62  static ThingType m_emptyThingType;
63 };
64 
66 
67 #endif
ThingsType::parseThingType
bool parseThingType(const FileStreamPtr &fin, ThingType &thingType)
ThingsType::load
bool load(const std::string &file)
ThingsType::Missile
@ Missile
Definition: thingstype.h:39
ThingsType::isValidItemId
bool isValidItemId(int id)
Definition: thingstype.h:56
uint32
uint32_t uint32
Definition: types.h:35
ThingsType::Categories
Categories
Definition: thingstype.h:35
ThingsType::getSignature
uint32 getSignature()
Definition: thingstype.h:51
ThingsType::getThingType
ThingType * getThingType(uint16 id, Categories category)
stdext::boolean< false >
uint16
uint16_t uint16
Definition: types.h:36
ThingsType::getFirstItemId
uint16 getFirstItemId()
Definition: thingstype.h:54
ThingsType::Creature
@ Creature
Definition: thingstype.h:37
declarations.h
ThingsType::Item
@ Item
Definition: thingstype.h:36
ThingsType::unload
void unload()
ThingsType::getEmptyThingType
ThingType * getEmptyThingType()
Definition: thingstype.h:48
ThingType
Definition: thingtype.h:123
ThingsType::Effect
@ Effect
Definition: thingstype.h:38
ThingsType::getMaxItemid
uint16 getMaxItemid()
Definition: thingstype.h:55
ThingsType::isLoaded
bool isLoaded()
Definition: thingstype.h:52
Item
Definition: item.h:76
stdext::shared_object_ptr< FileStream >
ThingTypeList
std::vector< ThingTypePtr > ThingTypeList
Definition: declarations.h:81
ThingsType
Definition: thingstype.h:31
ThingsType::LastCategory
@ LastCategory
Definition: thingstype.h:40
g_thingsType
ThingsType g_thingsType
thingtype.h
global.h