Jump to content

ObjectGuid Future?


cyberium

Recommended Posts

Hi,

I have some question about ObjectGuid usage.

If i look to player class there is today lot of way to get unique id (guid) of an instance.

[ code=cpp ]
Player * plr;
//Direct access
uint64 guid = plr->GetGUID();
uint32 guid = plr->GetGUIDLow(); //only low part
ObjectGuid guid = plr->GetGuidValue(index); //index of what?

//We can add some redundant things if we use
ObjectGuid guid = plr->GetObjectGuid();
uint32 guid.GetCounter(); // What? Low part of the guid?
uint32 guid.GetEntry(); // Yes i see there is entry encoded in guid but for what it is used?
uint32 guid.GetHigh(); // High guid part is used to tell what kind of guid is, ok.
uint32 guid.GetMaxCounter(); // Huhh?
uint64 guid.GetRawValue(); Complete guid?[ /code ]

So, the best is to use ObjectGuid or the direct access method? (do you will remove direct access in the future?)

If i wich to create a good guid list what is the best approach?

If i wich to compare 2 ObjectGuid what i have to use? (i know i can comapre directly 2 objectguid "guid1==guid2" but apparently is deprecated approach)

Greetings.

Link to comment
Share on other sites

If long way converting will completed then

uint64 guid = plr->GetGUID();

uint32 guid = plr->GetGUIDLow(); //only low part

will removed

for GetObjectGuid() use

About

int32 guid.GetCounter();

uint32 guid.GetEntry();

uint32 guid.GetMaxCounter();

Diff guids types can have or not have entry part. and then have different max value for low part, for object counter

Convertion hard do in one step because sometime crazy type cast rules in C/C++ that easy lost some cases and in result

have broken code with hard detected place of errors.

Link to comment
Share on other sites

  • 4 weeks later...

Hi,

In deep of the code when i whant use some player method and have only his ObjectGuid, i was doing something like

name = sObjectMgr.GetPlayer(Guid)->GetName();

This is helpfull but... Not safe!

I must do

if (Player* plr = sObjectMgr.GetPlayer(Guid))
         name = plr->GetName();
else
         name = "";

Do this test must be used as much as possible? Any other possibility to avoid this test?

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use