Jump to content
TrinityCore

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


Magnuss
 Share

Recommended Posts

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

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...