[7921] Set pet and for creature owner in Spell::EffectSummon similar other summon...
[getmangos.git] / src / game / ObjectDefines.h
blobc092f10992a056c693a95fe9d367bd16aaac1487
1 /*
2 * Copyright (C) 2005-2009 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) & UI64LIT(0x00000000FFFFFFFF))
27 #define PAIR64_LOPART(x) (uint32)(uint64(x) & UI64LIT(0x00000000FFFFFFFF))
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_VEHICLE = 0xF150, // blizz F550
43 HIGHGUID_DYNAMICOBJECT = 0xF100, // blizz F100
44 HIGHGUID_CORPSE = 0xF101, // blizz F100
45 HIGHGUID_MO_TRANSPORT = 0x1FC0, // blizz 1FC0 (for GAMEOBJECT_TYPE_MO_TRANSPORT)
48 #define IS_EMPTY_GUID(Guid) ( Guid == 0 )
50 #define IS_CREATURE_GUID(Guid) ( GUID_HIPART(Guid) == HIGHGUID_UNIT )
51 #define IS_PET_GUID(Guid) ( GUID_HIPART(Guid) == HIGHGUID_PET )
52 #define IS_VEHICLE_GUID(Guid) ( GUID_HIPART(Guid) == HIGHGUID_VEHICLE )
53 #define IS_CREATURE_OR_PET_GUID(Guid)( IS_CREATURE_GUID(Guid) || IS_PET_GUID(Guid) )
54 #define IS_PLAYER_GUID(Guid) ( GUID_HIPART(Guid) == HIGHGUID_PLAYER && Guid!=0 )
55 #define IS_UNIT_GUID(Guid) ( IS_CREATURE_OR_PET_GUID(Guid) || IS_PLAYER_GUID(Guid) )
56 // special case for empty guid need check
57 #define IS_ITEM_GUID(Guid) ( GUID_HIPART(Guid) == HIGHGUID_ITEM )
58 #define IS_GAMEOBJECT_GUID(Guid) ( GUID_HIPART(Guid) == HIGHGUID_GAMEOBJECT )
59 #define IS_DYNAMICOBJECT_GUID(Guid) ( GUID_HIPART(Guid) == HIGHGUID_DYNAMICOBJECT )
60 #define IS_CORPSE_GUID(Guid) ( GUID_HIPART(Guid) == HIGHGUID_CORPSE )
61 #define IS_TRANSPORT(Guid) ( GUID_HIPART(Guid) == HIGHGUID_TRANSPORT )
62 #define IS_MO_TRANSPORT(Guid) ( GUID_HIPART(Guid) == HIGHGUID_MO_TRANSPORT )
64 // l - OBJECT_FIELD_GUID
65 // e - OBJECT_FIELD_ENTRY for GO (except GAMEOBJECT_TYPE_MO_TRANSPORT) and creatures or UNIT_FIELD_PETNUMBER for pets
66 // h - OBJECT_FIELD_GUID + 1
67 #define MAKE_NEW_GUID(l, e, h) uint64( uint64(l) | ( uint64(e) << 24 ) | ( uint64(h) << 48 ) )
69 #define GUID_HIPART(x) (uint32)((uint64(x) >> 48) & 0x0000FFFF)
71 // We have different low and middle part size for different guid types
72 #define _GUID_ENPART_2(x) 0
73 #define _GUID_ENPART_3(x) (uint32)((uint64(x) >> 24) & UI64LIT(0x0000000000FFFFFF))
74 #define _GUID_LOPART_2(x) (uint32)(uint64(x) & UI64LIT(0x00000000FFFFFFFF))
75 #define _GUID_LOPART_3(x) (uint32)(uint64(x) & UI64LIT(0x0000000000FFFFFF))
77 inline bool IsGuidHaveEnPart(uint64 const& guid)
79 switch(GUID_HIPART(guid))
81 case HIGHGUID_ITEM:
82 case HIGHGUID_PLAYER:
83 case HIGHGUID_DYNAMICOBJECT:
84 case HIGHGUID_CORPSE:
85 return false;
86 case HIGHGUID_GAMEOBJECT:
87 case HIGHGUID_TRANSPORT:
88 case HIGHGUID_UNIT:
89 case HIGHGUID_PET:
90 case HIGHGUID_VEHICLE:
91 case HIGHGUID_MO_TRANSPORT:
92 default:
93 return true;
97 #define GUID_ENPART(x) (IsGuidHaveEnPart(x) ? _GUID_ENPART_3(x) : _GUID_ENPART_2(x))
98 #define GUID_LOPART(x) (IsGuidHaveEnPart(x) ? _GUID_LOPART_3(x) : _GUID_LOPART_2(x))
100 inline char const* GetLogNameForGuid(uint64 guid)
102 switch(GUID_HIPART(guid))
104 case HIGHGUID_ITEM: return "item";
105 case HIGHGUID_PLAYER: return guid ? "player" : "none";
106 case HIGHGUID_GAMEOBJECT: return "gameobject";
107 case HIGHGUID_TRANSPORT: return "transport";
108 case HIGHGUID_UNIT: return "creature";
109 case HIGHGUID_PET: return "pet";
110 case HIGHGUID_VEHICLE: return "vehicle";
111 case HIGHGUID_DYNAMICOBJECT:return "dynobject";
112 case HIGHGUID_CORPSE: return "corpse";
113 case HIGHGUID_MO_TRANSPORT: return "mo_transport";
114 default:
115 return "<unknown>";
118 #endif