2 * Copyright (C) 2005-2010 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 #include "ObjectGuid.h"
25 char const* ObjectGuid::GetTypeName(HighGuid high
)
29 case HIGHGUID_ITEM
: return "Item";
30 case HIGHGUID_PLAYER
: return "Player";
31 case HIGHGUID_GAMEOBJECT
: return "Gameobject";
32 case HIGHGUID_TRANSPORT
: return "Transport";
33 case HIGHGUID_UNIT
: return "Creature";
34 case HIGHGUID_PET
: return "Pet";
35 case HIGHGUID_VEHICLE
: return "Vehicle";
36 case HIGHGUID_DYNAMICOBJECT
:return "DynObject";
37 case HIGHGUID_CORPSE
: return "Corpse";
38 case HIGHGUID_MO_TRANSPORT
: return "MoTransport";
44 std::string
ObjectGuid::GetString() const
46 std::ostringstream str
;
47 str
<< GetTypeName() << " (";
49 str
<< "Entry: " << GetEntry() << " ";
50 str
<< "Guid: " << GetCounter() << ")";
54 template<HighGuid high
>
55 uint32 ObjectGuidGenerator
<high
>::Generate()
57 if (m_nextGuid
>= ObjectGuid::GetMaxCounter(high
)-1)
59 sLog
.outError("%s guid overflow!! Can't continue, shutting down server. ",ObjectGuid::GetTypeName(high
));
60 World::StopNow(ERROR_EXIT_CODE
);
65 ByteBuffer
& operator<< (ByteBuffer
& buf
, ObjectGuid
const& guid
)
67 buf
<< uint64(guid
.GetRawValue());
71 ByteBuffer
&operator>>(ByteBuffer
& buf
, ObjectGuid
& guid
)
73 guid
.Set(buf
.read
<uint64
>());
77 ByteBuffer
& operator<< (ByteBuffer
& buf
, PackedGuid
const& guid
)
79 buf
.append(guid
.m_packedGuid
);
83 ByteBuffer
&operator>>(ByteBuffer
& buf
, PackedGuidReader
const& guid
)
85 guid
.m_guidPtr
->Set(buf
.readPackGUID());
89 template uint32 ObjectGuidGenerator
<HIGHGUID_ITEM
>::Generate();
90 template uint32 ObjectGuidGenerator
<HIGHGUID_PLAYER
>::Generate();
91 template uint32 ObjectGuidGenerator
<HIGHGUID_GAMEOBJECT
>::Generate();
92 template uint32 ObjectGuidGenerator
<HIGHGUID_TRANSPORT
>::Generate();
93 template uint32 ObjectGuidGenerator
<HIGHGUID_UNIT
>::Generate();
94 template uint32 ObjectGuidGenerator
<HIGHGUID_PET
>::Generate();
95 template uint32 ObjectGuidGenerator
<HIGHGUID_VEHICLE
>::Generate();
96 template uint32 ObjectGuidGenerator
<HIGHGUID_DYNAMICOBJECT
>::Generate();
97 template uint32 ObjectGuidGenerator
<HIGHGUID_CORPSE
>::Generate();