@@ -65,6 +65,22 @@ public ObjectType GetObjectType()
6565 }
6666 }
6767
68+ public StoreNameType GetStoreNameType ( )
69+ {
70+ return GetHighType ( ) switch
71+ {
72+ HighGuidType . Player => StoreNameType . Player ,
73+ HighGuidType . Item => StoreNameType . Item ,
74+ HighGuidType . Transport => StoreNameType . GameObject ,
75+ HighGuidType . Creature => StoreNameType . Unit ,
76+ HighGuidType . Vehicle => StoreNameType . Unit ,
77+ HighGuidType . Pet => StoreNameType . Unit ,
78+ HighGuidType . GameObject => StoreNameType . GameObject ,
79+ HighGuidType . Cast => StoreNameType . Spell ,
80+ _ => StoreNameType . None
81+ } ;
82+ }
83+
6884 public static bool operator == ( WowGuid first , WowGuid other )
6985 {
7086 if ( ReferenceEquals ( first , other ) )
@@ -157,49 +173,35 @@ public override ulong GetLow()
157173
158174 public override string ToString ( )
159175 {
160- if ( Low == 0 && High == 0 )
161- return "Full: 0x0" ;
162-
163- string baseGuidPart = $ "TypeName: { GetHighType ( ) } ; Full: 0x{ High : X16} { Low : X16} ";
164- string endString = $ "Low: { GetLow ( ) } ";
165176 switch ( GetHighType ( ) )
166177 {
167- case HighGuidType . Housing :
168- {
169- var subType = ( HousingGuidType ) ( ( High >> 53 ) & 0x1F ) ;
170- return subType switch
171- {
172- HousingGuidType . Decor => $ "{ baseGuidPart } ; SubType: { subType } ; RealmID: { ( High >> 32 ) & 0xFFFF } ; DecorID: { High & 0xFFFFFFFF } ; { endString } ",
173- HousingGuidType . Neighborhood => $ "{ baseGuidPart } ; SubType: { subType } ; NeighborhoodMapID: { ( High >> 32 ) & 0xFFFF } ; Arg2: { High & 0xFFFFFFFF } ; { endString } ",
174- HousingGuidType . RoomComponent => $ "{ baseGuidPart } ; SubType: { subType } ; HouseRoomID: { High & 0xFFFFFFFF } ; { endString } ",
175- HousingGuidType . House => $ "{ baseGuidPart } ; SubType: { subType } ; NeighborhoodMapID: { Low & 0x7FFF } ; Arg2: { ( Low >> 15 ) & 0x3F } ; { endString } ",
176- _ => $ "{ baseGuidPart } ; SubType: Unknown({ ( byte ) subType } ); { endString } ",
177- } ;
178- }
179- }
180-
181- if ( HasEntry ( ) )
182- {
183- StoreNameType type = StoreNameType . None ;
184- if ( GetHighType ( ) == HighGuidType . Cast )
185- type = StoreNameType . Spell ;
186- else
187- type = Utilities . ObjectTypeToStore ( GetObjectType ( ) ) ;
188-
189- // ReSharper disable once UseStringInterpolation
190- return string . Format ( "Full: 0x{0}{1} {2}/{3} R{4}/S{5} Map: {6} Entry: {7} Low: {8}" , High . ToString ( "X16" ) , Low . ToString ( "X16" ) ,
191- GetHighType ( ) , GetSubType ( ) , GetRealmId ( ) , GetServerId ( ) , StoreGetters . GetName ( StoreNameType . Map , GetMapId ( ) ) ,
192- StoreGetters . GetName ( type , ( int ) GetEntry ( ) ) , GetLow ( ) ) ;
178+ case HighGuidType . Null : return "Full: 0x0" ;
179+ case HighGuidType . Housing : return FormatHousing ( ) ;
180+ default :
181+ break ;
193182 }
194183
195- // TODO: Implement extra format for battleground, see WowGuid64.ToString()
184+ if ( HasEntry ( ) )
185+ return $ "Full: 0x{ High : X16} { Low : X16} { GetHighType ( ) } /{ GetSubType ( ) } R{ GetRealmId ( ) } /S{ GetServerId ( ) } Map: { StoreGetters . GetName ( StoreNameType . Map , GetMapId ( ) ) } Entry: { StoreGetters . GetName ( GetStoreNameType ( ) , ( int ) GetEntry ( ) ) } Low: { GetLow ( ) } ";
196186
197- string name = StoreGetters . GetName ( this ) ;
187+ var name = StoreGetters . GetName ( this ) ;
188+ return $ "Full: 0x{ High : X16} { Low : X16} { GetHighType ( ) } /{ GetSubType ( ) } R{ GetRealmId ( ) } /S{ GetServerId ( ) } Map: { StoreGetters . GetName ( StoreNameType . Map , GetMapId ( ) ) } Low: { GetLow ( ) + ( string . IsNullOrEmpty ( name ) ? string . Empty : ( " Name: " + name ) ) } ";
189+ }
198190
199- // ReSharper disable once UseStringInterpolation
200- return string . Format ( "Full: 0x{0}{1} {2}/{3} R{4}/S{5} Map: {6} Low: {7}" , High . ToString ( "X16" ) , Low . ToString ( "X16" ) ,
201- GetHighType ( ) , GetSubType ( ) , GetRealmId ( ) , GetServerId ( ) , StoreGetters . GetName ( StoreNameType . Map , GetMapId ( ) ) ,
202- GetLow ( ) + ( String . IsNullOrEmpty ( name ) ? String . Empty : ( " Name: " + name ) ) ) ;
191+ private string FormatHousing ( )
192+ {
193+ var subType = ( HousingGuidType ) ( ( High >> 53 ) & 0x1F ) ;
194+ var formatted = $ "Full: 0x{ High : X16} { Low : X16} { GetHighType ( ) } /{ subType } ";
195+ formatted += subType switch
196+ {
197+ HousingGuidType . Decor => $ "Arg1: { ( High >> 32 ) & 0xFFFF } DecorID: { High & 0xFFFFFFFF } ",
198+ HousingGuidType . RoomComponent => $ "HouseRoomID: { High & 0xFFFFFFFF } ",
199+ HousingGuidType . House => $ "Arg1: { Low & 0x7FFF } Arg2: { ( Low >> 15 ) & 0x3F } ",
200+ HousingGuidType . Neighborhood => $ "NeighborhoodMapID: { ( High >> 32 ) & 0xFFFF } Arg2: { High & 0xFFFFFFFF } ",
201+ _ => $ "SubType: Unknown({ ( byte ) subType } ) ",
202+ } ;
203+ formatted += $ "Low: { GetLow ( ) } ";
204+ return formatted ;
203205 }
204206 }
205207
@@ -278,7 +280,7 @@ public override string ToString()
278280 // name next to the entry (from a database, if enabled)
279281 if ( HasEntry ( ) )
280282 {
281- var type = Utilities . ObjectTypeToStore ( GetObjectType ( ) ) ;
283+ var type = GetStoreNameType ( ) ;
282284
283285 return "Full: 0x" + Low . ToString ( "X8" ) + " Type: " + GetHighType ( )
284286 + " Entry: " + StoreGetters . GetName ( type , ( int ) GetEntry ( ) ) + " Low: " + GetLow ( ) ;
0 commit comments