aboutsummaryrefslogtreecommitdiff
path: root/src/objects.hh
blob: 84801e37cd41c87084a2ac94dc80fa153aa6c90f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#ifndef TIBIA_OBJECTS_HH_
#define TIBIA_OBJECTS_HH_ 1

#include "common.hh"
#include "enums.hh"

enum : int{
	TYPEID_MAP_CONTAINER		= 0,
	TYPEID_HEAD_CONTAINER		= 1,
	TYPEID_NECK_CONTAINER		= 2,
	TYPEID_BACKPACK_CONTAINER	= 3,
	TYPEID_TORSO_CONTAINER		= 4,
	TYPEID_RIGHTHAND_CONTAINER	= 5,
	TYPEID_LEFTHAND_CONTAINER	= 6,
	TYPEID_LEGS_CONTAINER		= 7,
	TYPEID_FEET_CONTAINER		= 8,
	TYPEID_FINGER_CONTAINER		= 9,
	TYPEID_AMMO_CONTAINER		= 10,
	TYPEID_CREATURE_CONTAINER	= 99,
};

struct ObjectType {
	// REGULAR FUNCTIONS
	// =========================================================================
	ObjectType(void) { this->setTypeID(0); }
	ObjectType(int TypeID) { this->setTypeID(TypeID); }
	void setTypeID(int TypeID);
	bool getFlag(FLAG Flag);
	uint32 getAttribute(TYPEATTRIBUTE Attribute);
	int getAttributeOffset(INSTANCEATTRIBUTE Attribute);
	const char *getName(int Count);
	const char *getDescription(void);

	bool isMapContainer(void) const {
		return this->TypeID == TYPEID_MAP_CONTAINER;
	}

	bool isBodyContainer(void) const {
		return this->TypeID == TYPEID_HEAD_CONTAINER
			|| this->TypeID == TYPEID_NECK_CONTAINER
			|| this->TypeID == TYPEID_BACKPACK_CONTAINER
			|| this->TypeID == TYPEID_TORSO_CONTAINER
			|| this->TypeID == TYPEID_RIGHTHAND_CONTAINER
			|| this->TypeID == TYPEID_LEFTHAND_CONTAINER
			|| this->TypeID == TYPEID_LEGS_CONTAINER
			|| this->TypeID == TYPEID_FEET_CONTAINER
			|| this->TypeID == TYPEID_FINGER_CONTAINER
			|| this->TypeID == TYPEID_AMMO_CONTAINER;
	}

	bool isCreatureContainer(void) const {
		return this->TypeID == TYPEID_CREATURE_CONTAINER;
	}

	bool operator==(const ObjectType &Other) const {
		return this->TypeID == Other.TypeID;
	}

	bool operator!=(const ObjectType &Other) const {
		return this->TypeID != Other.TypeID;
	}

	// DATA
	// =========================================================================
	int TypeID;
};

struct TObjectType {
	const char *Name;
	const char *Description;
	uint8 Flags[9];
	uint32 Attributes[62];
	int AttributeOffsets[18];
};

int GetFlagByName(const char *Name);
int GetTypeAttributeByName(const char *Name);
int GetInstanceAttributeByName(const char *Name);
const char *GetFlagName(int Flag);
const char *GetTypeAttributeName(int Attribute);
const char *GetInstanceAttributeName(int Attribute);
bool ObjectTypeExists(int TypeID);
bool ObjectTypeExists(uint8 Group, uint8 Number);
ObjectType GetNewObjectType(uint8 Group, uint8 Number);
void GetOldObjectType(ObjectType Type, uint8 *Group, uint8 *Number);
ObjectType GetSpecialObject(SPECIALMEANING Meaning);
ObjectType GetObjectTypeByName(const char *SearchName, bool Movable);
void InitObjects(void);
void ExitObjects(void);

#endif //TIBIA_OBJECTS_HH_