[6844] Daily quest fixes.
[getmangos.git] / src / game / ObjectDefines.h
blobc7dbc54c03460e77097e4490fd1cd542b1cb7a77
1 /*
2 * Copyright (C) 2005-2008 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef MANGOS_OBJECTDEFINES_H
20 #define MANGOS_OBJECTDEFINES_H
22 #include "Platform/Define.h"
24 // used for creating values for respawn for example
25 #define MAKE_PAIR64(l, h) uint64( uint32(l) | ( uint64(h) << 32 ) )
26 #define PAIR64_HIPART(x) (uint32)((uint64(x) >> 32) & 0x00000000FFFFFFFFLL)
27 #define PAIR64_LOPART(x) (uint32)(uint64(x) & 0x00000000FFFFFFFFLL)
29 #define MAKE_PAIR32(l, h) uint32( uint16(l) | ( uint32(h) << 16 ) )
30 #define PAIR32_HIPART(x) (uint16)((uint32(x) >> 16) & 0x0000FFFF)
31 #define PAIR32_LOPART(x) (uint16)(uint32(x) & 0x0000FFFF)
33 enum HighGuid
35 HIGHGUID_ITEM = 0x4000, // blizz 4000
36 HIGHGUID_CONTAINER = 0x4000, // blizz 4000
37 HIGHGUID_PLAYER = 0x0000, // blizz 0000
38 HIGHGUID_GAMEOBJECT = 0xF110, // blizz F110
39 HIGHGUID_TRANSPORT = 0xF120, // blizz F120 (for GAMEOBJECT_TYPE_TRANSPORT)
40 HIGHGUID_UNIT = 0xF130, // blizz F130
41 HIGHGUID_PET = 0xF140, // blizz F140
42 HIGHGUID_DYNAMICOBJECT = 0xF100, // blizz F100
43 HIGHGUID_CORPSE = 0xF101, // blizz F100
44 HIGHGUID_MO_TRANSPORT = 0x1FC0, // blizz 1FC0 (for GAMEOBJECT_TYPE_MO_TRANSPORT)
47 #define IS_EMPTY_GUID(Guid) ( Guid == 0 )
49 #define IS_CREATURE_GUID(Guid) ( GUID_HIPART(Guid) == HIGHGUID_UNIT )
50 #define IS_PET_GUID(Guid) ( GUID_HIPART(Guid) == HIGHGUID_PET )
51 #define IS_CREATURE_OR_PET_GUID(Guid)( IS_CREATURE_GUID(Guid) || IS_PET_GUID(Guid) )
52 #define IS_PLAYER_GUID(Guid) ( GUID_HIPART(Guid) == HIGHGUID_PLAYER && Guid!=0 )
53 #define IS_UNIT_GUID(Guid) ( IS_CREATURE_OR_PET_GUID(Guid) || IS_PLAYER_GUID(Guid) )
54 // special case for empty guid need check
55 #define IS_ITEM_GUID(Guid) ( GUID_HIPART(Guid) == HIGHGUID_ITEM )
56 #define IS_GAMEOBJECT_GUID(Guid) ( GUID_HIPART(Guid) == HIGHGUID_GAMEOBJECT )
57 #define IS_DYNAMICOBJECT_GUID(Guid) ( GUID_HIPART(Guid) == HIGHGUID_DYNAMICOBJECT )
58 #define IS_CORPSE_GUID(Guid) ( GUID_HIPART(Guid) == HIGHGUID_CORPSE )
59 #define IS_TRANSPORT(Guid) ( GUID_HIPART(Guid) == HIGHGUID_TRANSPORT )
60 #define IS_MO_TRANSPORT(Guid) ( GUID_HIPART(Guid) == HIGHGUID_MO_TRANSPORT )
62 // l - OBJECT_FIELD_GUID
63 // e - OBJECT_FIELD_ENTRY for GO (except GAMEOBJECT_TYPE_MO_TRANSPORT) and creatures or UNIT_FIELD_PETNUMBER for pets
64 // h - OBJECT_FIELD_GUID + 1
65 #define MAKE_NEW_GUID(l, e, h) uint64( uint64(l) | ( uint64(e) << 24 ) | ( uint64(h) << 48 ) )
67 #define GUID_HIPART(x) (uint32)((uint64(x) >> 48) & 0x0000FFFF)
69 // We have different low and middle part size for different guid types
70 #define _GUID_ENPART_2(x) 0
71 #define _GUID_ENPART_3(x) (uint32)((uint64(x) >> 24) & 0x0000000000FFFFFFLL)
72 #define _GUID_LOPART_2(x) (uint32)(uint64(x) & 0x00000000FFFFFFFFLL)
73 #define _GUID_LOPART_3(x) (uint32)(uint64(x) & 0x0000000000FFFFFFLL)
75 inline bool IsGuidHaveEnPart(uint64 const& guid)
77 switch(GUID_HIPART(guid))
79 case HIGHGUID_ITEM:
80 case HIGHGUID_PLAYER:
81 case HIGHGUID_DYNAMICOBJECT:
82 case HIGHGUID_CORPSE:
83 return false;
84 case HIGHGUID_GAMEOBJECT:
85 case HIGHGUID_TRANSPORT:
86 case HIGHGUID_UNIT:
87 case HIGHGUID_PET:
88 case HIGHGUID_MO_TRANSPORT:
89 default:
90 return true;
94 #define GUID_ENPART(x) (IsGuidHaveEnPart(x) ? _GUID_ENPART_3(x) : _GUID_ENPART_2(x))
95 #define GUID_LOPART(x) (IsGuidHaveEnPart(x) ? _GUID_LOPART_3(x) : _GUID_LOPART_2(x))
97 inline char const* GetLogNameForGuid(uint64 guid)
99 switch(GUID_HIPART(guid))
101 case HIGHGUID_ITEM: return "item";
102 case HIGHGUID_PLAYER: return guid ? "player" : "none";
103 case HIGHGUID_GAMEOBJECT: return "gameobject";
104 case HIGHGUID_TRANSPORT: return "transport";
105 case HIGHGUID_UNIT: return "creature";
106 case HIGHGUID_PET: return "pet";
107 case HIGHGUID_DYNAMICOBJECT:return "dynobject";
108 case HIGHGUID_CORPSE: return "corpse";
109 case HIGHGUID_MO_TRANSPORT: return "mo_transport";
110 default:
111 return "<unknown>";
114 #endif