本文整理汇总了C++中Relocate函数的典型用法代码示例。如果您正苦于以下问题:C++ Relocate函数的具体用法?C++ Relocate怎么用?C++ Relocate使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Relocate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetMap
void Transport::TeleportTransport(uint32 newMapid, float x, float y, float z)
{
Map* oldMap = GetMap();
Relocate(x, y, z);
for(PlayerSet::iterator itr = m_passengers.begin(); itr != m_passengers.end();)
{
PlayerSet::iterator it2 = itr;
++itr;
Player *plr = *it2;
if(!plr)
{
m_passengers.erase(it2);
continue;
}
if (plr->isDead() && !plr->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
{
plr->ResurrectPlayer(1.0);
}
plr->TeleportTo(newMapid, x, y, z, GetOrientation(), TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NODELAY);
//WorldPacket data(SMSG_811, 4);
//data << uint32(0);
//plr->GetSession()->SendPacket(&data);
}
//we need to create and save new Map object with 'newMapid' because if not done -> lead to invalid Map object reference...
//player far teleport would try to create same instance, but we need it NOW for transport...
//correct me if I'm wrong O.o
Map* newMap = sMapMgr.CreateMap(newMapid, this);
SetMap(newMap);
if (oldMap != newMap)
{
UpdateForMap(oldMap);
oldMap->EraseObject(this);
UpdateForMap(newMap);
newMap->InsertObject(this);
}
}
示例2: GetMap
void Transport::DelayedTeleportTransport()
{
if (!_delayedTeleport)
return;
_delayedTeleport = false;
Map* newMap = sMapMgr->CreateBaseMap(_nextFrame->Node->ContinentID);
GetMap()->RemoveFromMap<Transport>(this, false);
SetMap(newMap);
float x = _nextFrame->Node->Loc.X,
y = _nextFrame->Node->Loc.Y,
z = _nextFrame->Node->Loc.Z,
o =_nextFrame->InitialOrientation;
for (_passengerTeleportItr = _passengers.begin(); _passengerTeleportItr != _passengers.end();)
{
WorldObject* obj = (*_passengerTeleportItr++);
float destX, destY, destZ, destO;
obj->m_movementInfo.transport.pos.GetPosition(destX, destY, destZ, destO);
TransportBase::CalculatePassengerPosition(destX, destY, destZ, &destO, x, y, z, o);
switch (obj->GetTypeId())
{
case TYPEID_PLAYER:
if (!obj->ToPlayer()->TeleportTo(_nextFrame->Node->ContinentID, destX, destY, destZ, destO, TELE_TO_NOT_LEAVE_TRANSPORT))
RemovePassenger(obj);
break;
case TYPEID_DYNAMICOBJECT:
case TYPEID_AREATRIGGER:
obj->AddObjectToRemoveList();
break;
default:
RemovePassenger(obj);
break;
}
}
Relocate(x, y, z, o);
GetMap()->AddToMap<Transport>(this);
}
示例3: UpdateNPCPositions
void Transport::Update (uint32 p_diff)
{
UpdateNPCPositions();
if (!AI())
{
if (!AIM_Initialize())
sLog->outError("Could not initialize GameObjectAI for Transport");
}
else
AI()->UpdateAI(p_diff);
if (m_WayPoints.size() <= 1)
return;
m_timer = getMSTime() % m_period;
while (((m_timer - m_curr->first) % m_pathTime) > ((m_next->first - m_curr->first) % m_pathTime))
{
DoEventIfAny(*m_curr, true);
m_curr = GetNextWayPoint();
m_next = GetNextWayPoint();
DoEventIfAny(*m_curr, false);
// first check help in case client-server transport coordinates de-synchronization
if (m_curr->second.mapid != GetMapId() || m_curr->second.teleport)
TeleportTransport(m_curr->second.mapid, m_curr->second.x, m_curr->second.y, m_curr->second.z);
else
Relocate(m_curr->second.x, m_curr->second.y, m_curr->second.z, GetAngle(m_next->second.x, m_next->second.y) + float(M_PI));
sScriptMgr->OnRelocate(this, m_curr->first, m_curr->second.mapid, m_curr->second.x, m_curr->second.y, m_curr->second.z);
m_nextNodeTime = m_curr->first;
if (m_curr == m_WayPoints.begin())
sLog->outDebug(LOG_FILTER_TRANSPORTS, " ************ BEGIN ************** %s", m_name.c_str());
sLog->outDebug(LOG_FILTER_TRANSPORTS, "%s moved to %d %f %f %f %d", m_name.c_str(), m_curr->second.id, m_curr->second.x, m_curr->second.y, m_curr->second.z, m_curr->second.mapid);
}
sScriptMgr->OnTransportUpdate(this, p_diff);
}
示例4: SetMap
bool DynamicObject::CreateDynamicObject(uint32 guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, DynamicObjectType type)
{
SetMap(caster->GetMap());
Relocate(pos);
if (!IsPositionValid())
{
sLog->outError(LOG_FILTER_GENERAL, "DynamicObject (spell %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)", spellId, GetPositionX(), GetPositionY());
return false;
}
WorldObject::_Create(guidlow, HIGHGUID_DYNAMICOBJECT, caster->GetPhaseMask());
SetEntry(spellId);
SetObjectScale(1.0f);
SetUInt64Value(DYNAMICOBJECT_CASTER, caster->GetGUID());
// The lower word of DYNAMICOBJECT_BYTES must be 0x0001. This value means that the visual radius will be overriden
// by client for most of the "ground patch" visual effect spells and a few "skyfall" ones like Hurricane.
// If any other value is used, the client will _always_ use the radius provided in DYNAMICOBJECT_RADIUS, but
// precompensation is necessary (eg radius *= 2) for many spells. Anyway, blizz sends 0x0001 for all the spells
// I saw sniffed...
// Blizz set visual spell Id in 3 first byte of DYNAMICOBJECT_BYTES after 5.X
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
if (spellInfo)
{
uint32 visual = spellInfo->SpellVisual[0] ? spellInfo->SpellVisual[0] : spellInfo->SpellVisual[1];
SetUInt32Value(DYNAMICOBJECT_BYTES, 0x10000000 | visual);
}
SetUInt32Value(DYNAMICOBJECT_SPELLID, spellId);
SetFloatValue(DYNAMICOBJECT_RADIUS, radius);
SetUInt32Value(DYNAMICOBJECT_CASTTIME, getMSTime());
if (IsWorldObject())
setActive(true); //must before add to map to be put in world container
if (!GetMap()->AddToMap(this))
return false;
return true;
}
示例5: while
void Transport::Update(uint32 update_diff, uint32 /*p_time*/)
{
if (m_WayPoints.size() <= 1)
return;
m_timer = WorldTimer::getMSTime() % m_period;
while (((m_timer - m_curr->first) % m_pathTime) > ((m_next->first - m_curr->first) % m_pathTime))
{
DoEventIfAny(*m_curr, true);
MoveToNextWayPoint();
DoEventIfAny(*m_curr, false);
// first check help in case client-server transport coordinates de-synchronization
if (m_curr->second.mapid != GetMapId() || m_curr->second.teleport)
{
TeleportTransport(m_curr->second.mapid, m_curr->second.x, m_curr->second.y, m_curr->second.z);
}
else
{
Relocate(m_curr->second.x, m_curr->second.y, m_curr->second.z);
}
/*
for(PlayerSet::const_iterator itr = m_passengers.begin(); itr != m_passengers.end();)
{
PlayerSet::const_iterator it2 = itr;
++itr;
//(*it2)->SetPosition( m_curr->second.x + (*it2)->GetTransOffsetX(), m_curr->second.y + (*it2)->GetTransOffsetY(), m_curr->second.z + (*it2)->GetTransOffsetZ(), (*it2)->GetTransOffsetO() );
}
*/
m_nextNodeTime = m_curr->first;
if (m_curr == m_WayPoints.begin())
DETAIL_FILTER_LOG(LOG_FILTER_TRANSPORT_MOVES, " ************ BEGIN ************** %s", GetName());
DETAIL_FILTER_LOG(LOG_FILTER_TRANSPORT_MOVES, "%s moved to %f %f %f %d", GetName(), m_curr->second.x, m_curr->second.y, m_curr->second.z, m_curr->second.mapid);
}
}
示例6: getMSTime
void Transport::Update(uint32 /*p_time*/)
{
if (m_WayPoints.size() <= 1)
return;
m_timer = getMSTime() % m_period;
while (((m_timer - m_curr->first) % m_pathTime) > ((m_next->first - m_curr->first) % m_pathTime))
{
m_curr = GetNextWayPoint();
m_next = GetNextWayPoint();
// first check help in case client-server transport coordinates de-synchronization
if (m_curr->second.mapid != GetMapId() || m_curr->second.teleport)
{
TeleportTransport(m_curr->second.mapid, m_curr->second.x, m_curr->second.y, m_curr->second.z);
}
else
{
Relocate(m_curr->second.x, m_curr->second.y, m_curr->second.z);
}
/*
for (PlayerSet::iterator itr = m_passengers.begin(); itr != m_passengers.end();)
{
PlayerSet::iterator it2 = itr;
++itr;
//(*it2)->SetPosition(m_curr->second.x + (*it2)->GetTransOffsetX(), m_curr->second.y + (*it2)->GetTransOffsetY(), m_curr->second.z + (*it2)->GetTransOffsetZ(), (*it2)->GetTransOffsetO());
}
*/
m_nextNodeTime = m_curr->first;
if (m_curr == m_WayPoints.begin() && (sLog.getLogFilter() & LOG_FILTER_TRANSPORT_MOVES) == 0)
DEBUG_LOG(" ************ BEGIN ************** %s", this->m_name.c_str());
if ((sLog.getLogFilter() & LOG_FILTER_TRANSPORT_MOVES) == 0)
DEBUG_LOG("%s moved to %d %f %f %f %d", this->m_name.c_str(), m_curr->second.id, m_curr->second.x, m_curr->second.y, m_curr->second.z, m_curr->second.mapid);
//Transport Event System
CheckForEvent(this->GetEntry(), m_curr->second.id);
}
}
示例7: Relocate
bool Transport::Create(uint32 guidlow, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress)
{
Relocate(x, y, z, ang);
if (!IsPositionValid())
{
sLog.outError("Transport (GUID: %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)",
guidlow, x, y);
return false;
}
Object::_Create(guidlow, 0, HIGHGUID_MO_TRANSPORT);
GameObjectInfo const* goinfo = ObjectMgr::GetGameObjectInfo(guidlow);
if (!goinfo)
{
sLog.outErrorDb("Transport not created: entry in `gameobject_template` not found, guidlow: %u map: %u (X: %f Y: %f Z: %f) ang: %f", guidlow, mapid, x, y, z, ang);
return false;
}
m_goInfo = goinfo;
SetObjectScale(goinfo->size);
SetUInt32Value(GAMEOBJECT_FACTION, goinfo->faction);
SetUInt32Value(GAMEOBJECT_FLAGS, goinfo->flags);
SetEntry(goinfo->id);
SetDisplayId(goinfo->displayId);
SetGoState(GO_STATE_READY);
SetGoType(GameobjectTypes(goinfo->type));
SetGoAnimProgress(animprogress);
SetName(goinfo->name);
return true;
}
示例8: SetMap
bool DynamicObject::Create( uint32 guidlow, Unit *caster, uint32 spellId, SpellEffectIndex effIndex, float x, float y, float z, int32 duration, float radius )
{
WorldObject::_Create(ObjectGuid(HIGHGUID_DYNAMICOBJECT, guidlow), caster->GetPhaseMask());
SetMap(caster->GetMap());
Relocate(x, y, z, 0);
if(!IsPositionValid())
{
sLog.outError("DynamicObject (spell %u eff %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)",spellId,effIndex,GetPositionX(),GetPositionY());
return false;
}
SetEntry(spellId);
SetObjectScale(DEFAULT_OBJECT_SCALE);
SetGuidValue(DYNAMICOBJECT_CASTER, caster->GetObjectGuid());
/* Bytes field, so it's really 4 bit fields. These flags are unknown, but we do know that 0x00000001 is set for most.
Farsight for example, does not have this flag, instead it has 0x80000002.
Flags are set dynamically with some conditions, so one spell may have different flags set, depending on those conditions.
The size of the visual may be controlled to some degree with these flags.
uint32 bytes = 0x00000000;
bytes |= 0x01;
bytes |= 0x00 << 8;
bytes |= 0x00 << 16;
bytes |= 0x00 << 24;
*/
SetUInt32Value(DYNAMICOBJECT_BYTES, 0x00000001);
SetUInt32Value(DYNAMICOBJECT_SPELLID, spellId);
SetFloatValue(DYNAMICOBJECT_RADIUS, radius);
SetUInt32Value(DYNAMICOBJECT_CASTTIME, getMSTime()); // new 2.4.0
m_aliveDuration = duration;
m_radius = radius;
m_effIndex = effIndex;
m_spellId = spellId;
return true;
}
示例9: SetObjectScale
bool Corpse::LoadCorpseFromDB(ObjectGuid::LowType guid, Field* fields)
{
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
// SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, flags, dynFlags, time, corpseType, instanceId, guid FROM corpse WHERE mapId = ? AND instanceId = ?
float posX = fields[0].GetFloat();
float posY = fields[1].GetFloat();
float posZ = fields[2].GetFloat();
float o = fields[3].GetFloat();
uint32 mapId = fields[4].GetUInt16();
Object::_Create(ObjectGuid::Create<HighGuid::Corpse>(mapId, 0, guid));
SetObjectScale(1.0f);
SetUInt32Value(CORPSE_FIELD_DISPLAY_ID, fields[5].GetUInt32());
_LoadIntoDataField(fields[6].GetCString(), CORPSE_FIELD_ITEM, EQUIPMENT_SLOT_END);
SetUInt32Value(CORPSE_FIELD_BYTES_1, fields[7].GetUInt32());
SetUInt32Value(CORPSE_FIELD_BYTES_2, fields[8].GetUInt32());
SetUInt32Value(CORPSE_FIELD_FLAGS, fields[9].GetUInt8());
SetUInt32Value(CORPSE_FIELD_DYNAMIC_FLAGS, fields[10].GetUInt8());
SetGuidValue(CORPSE_FIELD_OWNER, ObjectGuid::Create<HighGuid::Player>(fields[14].GetUInt64()));
m_time = time_t(fields[11].GetUInt32());
uint32 instanceId = fields[13].GetUInt32();
// place
SetLocationInstanceId(instanceId);
SetLocationMapId(mapId);
Relocate(posX, posY, posZ, o);
if (!IsPositionValid())
{
TC_LOG_ERROR("entities.player", "Corpse (%s, owner: %s) is not created, given coordinates are not valid (X: %f, Y: %f, Z: %f)",
GetGUID().ToString().c_str(), GetOwnerGUID().ToString().c_str(), posX, posY, posZ);
return false;
}
_cellCoord = Trinity::ComputeCellCoord(GetPositionX(), GetPositionY());
return true;
}
示例10: SetMap
bool DynamicObject::Create(uint32 guidlow, Unit *caster, uint32 spellId, uint32 effIndex, const Position &pos, int32 duration, float radius)
{
SetMap(caster->GetMap());
Relocate(pos);
if (!IsPositionValid())
{
sLog->outError("DynamicObject (spell %u eff %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)", spellId, effIndex, GetPositionX(), GetPositionY());
return false;
}
WorldObject::_Create(guidlow, HIGHGUID_DYNAMICOBJECT, caster->GetPhaseMask());
SetEntry(spellId);
SetFloatValue(OBJECT_FIELD_SCALE_X, 1);
SetUInt64Value(DYNAMICOBJECT_CASTER, caster->GetGUID());
// The lower word of DYNAMICOBJECT_BYTES must be 0x0001. This value means that the visual radius will be overriden
// by client for most of the "ground patch" visual effect spells and a few "skyfall" ones like Hurricane.
// If any other value is used, the client will _always_ use the radius provided in DYNAMICOBJECT_RADIUS, but
// precompensation is necessary (eg radius *= 2) for many spells. Anyway, blizz sends 0x0001 for all the spells
// I saw sniffed...
SetUInt32Value(DYNAMICOBJECT_BYTES, 0x00000001);
SetUInt32Value(DYNAMICOBJECT_SPELLID, spellId);
SetFloatValue(DYNAMICOBJECT_RADIUS, radius);
SetFloatValue(DYNAMICOBJECT_POS_X, pos.m_positionX);
SetFloatValue(DYNAMICOBJECT_POS_Y, pos.m_positionY);
SetFloatValue(DYNAMICOBJECT_POS_Z, pos.m_positionZ);
SetUInt32Value(DYNAMICOBJECT_CASTTIME, getMSTime());
m_aliveDuration = duration;
m_radius = radius;
m_effIndex = effIndex;
m_spellId = spellId;
m_casterGuid = caster->GetGUID();
m_updateTimer = 0;
if (m_effIndex == 4)
m_isWorldObject = true;
return true;
}
示例11: GetMap
void Transport::TeleportTransport(uint32 newMapid, float x, float y, float z)
{
Map const* oldMap = GetMap();
SetMapId(newMapid);
Relocate(x, y, z);
for (PlayerSet::iterator itr = m_passengers.begin(); itr != m_passengers.end();)
{
PlayerSet::iterator it2 = itr;
++itr;
Player *plr = *it2;
if (!plr)
{
m_passengers.erase(it2);
continue;
}
if (plr->isDead() && !plr->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
{
plr->ResurrectPlayer(1.0);
}
plr->TeleportTo(newMapid, x, y, z, GetOrientation(), TELE_TO_NOT_LEAVE_TRANSPORT);
//WorldPacket data(SMSG_811, 4);
//data << uint32(0);
//plr->BroadcastPacketToSelf(&data);
}
Map* newMap = sMapMgr.CreateMap(newMapid, this);
SetMap(newMap);
if (oldMap != newMap)
{
UpdateForMap(oldMap);
UpdateForMap(newMap);
}
}
示例12: GetMap
void Transport::TeleportTransport(uint32 newMapid, float x, float y, float z)
{
Map const* oldMap = GetMap();
Relocate(x, y, z);
// we need to create and save new Map object with 'newMapid' because if not done -> lead to invalid Map object reference...
// player far teleport would try to create same instance, but we need it NOW for transport...
RemoveFromWorld();
ResetMap();
Map* newMap = sMapMgr->CreateBaseMap(newMapid);
SetMap(newMap);
ASSERT(GetMap());
AddToWorld();
for (UnitSet::iterator itr = _passengers.begin(); itr != _passengers.end();)
{
Unit* passenger = *itr;
++itr;
switch (passenger->GetTypeId())
{
case TYPEID_UNIT:
passenger->ToCreature()->FarTeleportTo(newMap, x, y, z, passenger->GetOrientation());
break;
case TYPEID_PLAYER:
if (passenger->isDead() && !passenger->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
passenger->ToPlayer()->ResurrectPlayer(1.0f);
passenger->ToPlayer()->TeleportTo(newMapid, x, y, z, GetOrientation(), TELE_TO_NOT_LEAVE_TRANSPORT);
break;
}
}
if (oldMap != newMap)
{
UpdateForMap(oldMap);
UpdateForMap(newMap);
}
MoveToNextWayPoint();
}
示例13: makedllbin
void makedllbin(char *dllfile, char *bootfile, char *binfile, DWORD base)
{
char bootsector[512];
FILE *boot=fopen(bootfile, "rb");
fread(bootsector, 512, 1, boot);
fclose(boot);
printf("Relocate %s at 0x%0x\n", dllfile, base);
LoadImage(dllfile);
Relocate(base);
*((int *)&bootsector[504])=1;
*((short *)&bootsector[508])=(short)(optional_header.SizeOfImage+511)/512;
DWORD r;
HANDLE fp=CreateFile(binfile,GENERIC_READ|GENERIC_WRITE,0, NULL, OPEN_ALWAYS, 0, NULL);
WriteFile(fp, bootsector, 512, &r, NULL);
WriteFile(fp, image, optional_header.SizeOfImage, &r, NULL);
CloseHandle(fp);
printf("The Bootable Image at %s\n", binfile);
return;
}
示例14: GetMap
void Transport::UpdatePosition(float x, float y, float z, float o)
{
bool newActive = GetMap()->IsGridLoaded(x, y);
Relocate(x, y, z, o);
UpdatePassengerPositions(_passengers);
/* There are four possible scenarios that trigger loading/unloading passengers:
1. transport moves from inactive to active grid
2. the grid that transport is currently in becomes active
3. transport moves from active to inactive grid
4. the grid that transport is currently in unloads
*/
if (_staticPassengers.empty() && newActive) // 1. and 2.
LoadStaticPassengers();
else if (!_staticPassengers.empty() && !newActive && Cell(x, y).DiffGrid(Cell(GetPositionX(), GetPositionY()))) // 3.
UnloadStaticPassengers();
else
UpdatePassengerPositions(_staticPassengers);
// 4. is handed by grid unload
}
示例15: SetMap
bool DynamicObject::Create(uint32 guidlow, Unit* caster, uint32 spellId, SpellEffectIndex effIndex, float x, float y, float z, int32 duration, float radius, DynamicObjectType type)
{
WorldObject::_Create(guidlow, GUIDTYPE_DYNAMICOBJECT, caster->GetPhaseMask());
SetMap(caster->GetMap());
Relocate(x, y, z, 0);
if (!IsPositionValid())
{
sLog.outError("DynamicObject (spell %u eff %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)", spellId, effIndex, GetPositionX(), GetPositionY());
return false;
}
SpellEntry const* spellProto = sSpellStore.LookupEntry(spellId);
if (!spellProto)
{
sLog.outError("DynamicObject (spell %u) not created. Spell not exist!", spellId);
return false;
}
SetEntry(spellId);
SetObjectScale(DEFAULT_OBJECT_SCALE);
SetGuidValue(DYNAMICOBJECT_CASTER, caster->GetObjectGuid());
SetUInt32Value(DYNAMICOBJECT_BYTES, spellProto->SpellVisual[0] | (type << 28));
SetUInt32Value(DYNAMICOBJECT_SPELLID, spellId);
SetFloatValue(DYNAMICOBJECT_RADIUS, radius);
SetUInt32Value(DYNAMICOBJECT_CASTTIME, WorldTimer::getMSTime()); // new 2.4.0
m_aliveDuration = duration;
m_radius = radius;
m_effIndex = effIndex;
m_spellId = spellId;
m_positive = IsPositiveEffect(spellProto, m_effIndex);
return true;
}