Magnuss Posted September 17, 2016 Report Share Posted September 17, 2016 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: 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); 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: Player* player = handler->GetSession()->GetPlayer(); Map* map = player->GetMap(); GameObject* object = new GameObject(); ObjectGuid::LowType guidLow = map->GenerateLowGuid<HighGuid::GameObject>(); 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; } 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. Link to comment Share on other sites More sharing options...
Nay Posted September 17, 2016 Report Share Posted September 17, 2016 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. Link to comment Share on other sites More sharing options...
jackpoz Posted September 19, 2016 Report Share Posted September 19, 2016 Just press F12 (in Visual Studio) on Player type to walk down the inheritance chain and you'll end up in Position Link to comment Share on other sites More sharing options...
Magnuss Posted September 20, 2016 Author Report Share Posted September 20, 2016 Thanks for the answers. Now it's more clear for me. Link to comment Share on other sites More sharing options...
Nay Posted September 22, 2016 Report Share Posted September 22, 2016 --- 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 --- Link to comment Share on other sites More sharing options...
Recommended Posts