[SOLVED]gobject create - How does this work in c++ ?

My knowledge of c++ is limited and I would like to ask how that works:

The declaration of creating a gameobject is in GameObject.h (line 687) like that:

[FONT=‘Courier New’]bool Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, uint32 phaseMask, Position const& pos, G3D::Quat const& rotation, uint32 animprogress, GOState go_state, uint32 artKit = 0);[/FONT]

After phasemask the function is asking for a struct Position.

But in the script for spawning gameobjects (cs_gobject.cpp, ) there is a piece of code like that:

[FONT=‘Courier New’] Player* player = handler->GetSession()->GetPlayer();
Map* map = player->GetMap();[/FONT]

[FONT=‘Courier New’] GameObject* object = new GameObject();
ObjectGuid::LowType guidLow = map->GenerateLowGuidHighGuid::GameObject();[/FONT]

[FONT=‘Courier New’] G3D::Quat rot = G3D::Matrix3::fromEulerAnglesZYX(player->GetOrientation(), 0.f, 0.f);
if (!object->Create(guidLow, objectInfo->entry, map, player->GetPhaseMaskForSpawn(), *player, rot, 255, GO_STATE_READY))
{
delete object;
return false;
}[/FONT]

As you see instead to send a position struct there is a pointer to player.

How does this trick work ? There is no compiler complaint and I also couldn’t find an overload.

Because Player inherits Unit → WorldObject → WorldLocation → Position

http://trinitycore.github.io/data/symbol.html?root=…/codebrowser/&ref=Player#graph

Imo this should be composition but due to whatever (old) reasons it’s inheritance.

Just press F12 (in Visual Studio) on Player type to walk down the inheritance chain and you’ll end up in Position

Thanks for the answers. Now it’s more clear for me.

— Canned message start —
It appears the issue in the original post was solved, so this thread shall be closed.
Should you encounter any other difficulties, please open a new thread.
— Canned message end —