mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[11244] Collect in CreatureCreatePos data for delayed pos setup into Creature::Create.
* CreatureCreatePos work in 3 modes:
- exactly provided coordinates/orientation/map/phasemask
- exactly object + orientation as coordinates/map/phasemask
- delayed position calculation near provided object at specific dist/angle.
* Use in similar way and for Pet/Vehicle Create functions.
For Totem created new Totem::Create function with some moved in to it totem specific code.
* This let resolve recent problems with creature spawn and preserve fix for cases when
Creature::Create addon/script code expected known correct possition for creature.
This commit is contained in:
parent
44915f6f13
commit
2b65cdb3bb
13 changed files with 223 additions and 362 deletions
|
|
@ -1551,24 +1551,12 @@ bool ChatHandler::HandleNpcAddCommand(char* args)
|
|||
return false;
|
||||
|
||||
Player *chr = m_session->GetPlayer();
|
||||
float x = chr->GetPositionX();
|
||||
float y = chr->GetPositionY();
|
||||
float z = chr->GetPositionZ();
|
||||
float o = chr->GetOrientation();
|
||||
CreatureCreatePos pos(chr, chr->GetOrientation());
|
||||
Map *map = chr->GetMap();
|
||||
|
||||
Creature* pCreature = new Creature;
|
||||
|
||||
pCreature->Relocate(x,y,z,o);
|
||||
|
||||
if (!pCreature->IsPositionValid())
|
||||
{
|
||||
sLog.outError("Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY());
|
||||
delete pCreature;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!pCreature->Create(map->GenerateLocalLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id))
|
||||
if (!pCreature->Create(map->GenerateLocalLowGuid(HIGHGUID_UNIT), pos, id))
|
||||
{
|
||||
delete pCreature;
|
||||
return false;
|
||||
|
|
@ -3141,16 +3129,9 @@ bool ChatHandler::HandleWpModifyCommand(char* args)
|
|||
wpGuid = 0;
|
||||
Creature* wpCreature = new Creature;
|
||||
|
||||
wpCreature->Relocate(chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation());
|
||||
CreatureCreatePos pos(chr, chr->GetOrientation());
|
||||
|
||||
if (!wpCreature->IsPositionValid())
|
||||
{
|
||||
sLog.outError("Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",wpCreature->GetGUIDLow(),wpCreature->GetEntry(),wpCreature->GetPositionX(),wpCreature->GetPositionY());
|
||||
delete wpCreature;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!wpCreature->Create(map->GenerateLocalLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT))
|
||||
if (!wpCreature->Create(map->GenerateLocalLowGuid(HIGHGUID_UNIT), pos, VISUAL_WAYPOINT))
|
||||
{
|
||||
PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
|
||||
delete wpCreature;
|
||||
|
|
@ -3260,16 +3241,9 @@ bool ChatHandler::HandleWpModifyCommand(char* args)
|
|||
// re-create
|
||||
Creature* wpCreature2 = new Creature;
|
||||
|
||||
wpCreature2->Relocate(chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation());
|
||||
CreatureCreatePos pos(chr, chr->GetOrientation());
|
||||
|
||||
if (!wpCreature2->IsPositionValid())
|
||||
{
|
||||
sLog.outError("Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",wpCreature2->GetGUIDLow(),wpCreature2->GetEntry(),wpCreature2->GetPositionX(),wpCreature2->GetPositionY());
|
||||
delete wpCreature2;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!wpCreature2->Create(map->GenerateLocalLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT))
|
||||
if (!wpCreature2->Create(map->GenerateLocalLowGuid(HIGHGUID_UNIT), pos, VISUAL_WAYPOINT))
|
||||
{
|
||||
PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
|
||||
delete wpCreature2;
|
||||
|
|
@ -3551,33 +3525,18 @@ bool ChatHandler::HandleWpShowCommand(char* args)
|
|||
|
||||
do
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
uint32 point = fields[0].GetUInt32();
|
||||
float x = fields[1].GetFloat();
|
||||
float y = fields[2].GetFloat();
|
||||
float z = fields[3].GetFloat();
|
||||
|
||||
uint32 id = VISUAL_WAYPOINT;
|
||||
|
||||
Player *chr = m_session->GetPlayer();
|
||||
Map *map = chr->GetMap();
|
||||
float o = chr->GetOrientation();
|
||||
|
||||
Field *fields = result->Fetch();
|
||||
uint32 point = fields[0].GetUInt32();
|
||||
CreatureCreatePos pos(map, fields[1].GetFloat(), fields[2].GetFloat(), fields[3].GetFloat(), chr->GetOrientation(), chr->GetPhaseMaskForSpawn());
|
||||
|
||||
Creature* wpCreature = new Creature;
|
||||
|
||||
wpCreature->Relocate(x, y, z, o);
|
||||
|
||||
if (!wpCreature->IsPositionValid())
|
||||
if (!wpCreature->Create(map->GenerateLocalLowGuid(HIGHGUID_UNIT), pos, VISUAL_WAYPOINT))
|
||||
{
|
||||
sLog.outError("Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",wpCreature->GetGUIDLow(),wpCreature->GetEntry(),wpCreature->GetPositionX(),wpCreature->GetPositionY());
|
||||
delete wpCreature;
|
||||
delete result;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!wpCreature->Create(map->GenerateLocalLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id))
|
||||
{
|
||||
PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id);
|
||||
PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
|
||||
delete wpCreature;
|
||||
delete result;
|
||||
return false;
|
||||
|
|
@ -3612,31 +3571,17 @@ bool ChatHandler::HandleWpShowCommand(char* args)
|
|||
return false;
|
||||
}
|
||||
|
||||
Field *fields = result->Fetch();
|
||||
float x = fields[0].GetFloat();
|
||||
float y = fields[1].GetFloat();
|
||||
float z = fields[2].GetFloat();
|
||||
uint32 id = VISUAL_WAYPOINT;
|
||||
|
||||
Player *chr = m_session->GetPlayer();
|
||||
float o = chr->GetOrientation();
|
||||
Map *map = chr->GetMap();
|
||||
|
||||
Field *fields = result->Fetch();
|
||||
CreatureCreatePos pos(map, fields[0].GetFloat(), fields[1].GetFloat(), fields[2].GetFloat(), chr->GetOrientation(), chr->GetPhaseMaskForSpawn());
|
||||
|
||||
Creature* pCreature = new Creature;
|
||||
|
||||
pCreature->Relocate(x, y, z, o);
|
||||
|
||||
if (!pCreature->IsPositionValid())
|
||||
if (!pCreature->Create(map->GenerateLocalLowGuid(HIGHGUID_UNIT), pos, VISUAL_WAYPOINT))
|
||||
{
|
||||
sLog.outError("Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY());
|
||||
delete pCreature;
|
||||
delete result;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!pCreature->Create(map->GenerateLocalLowGuid(HIGHGUID_UNIT),map, chr->GetPhaseMaskForSpawn(), id))
|
||||
{
|
||||
PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id);
|
||||
PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
|
||||
delete pCreature;
|
||||
delete result;
|
||||
return false;
|
||||
|
|
@ -3673,31 +3618,18 @@ bool ChatHandler::HandleWpShowCommand(char* args)
|
|||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
Field *fields = result->Fetch();
|
||||
float x = fields[0].GetFloat();
|
||||
float y = fields[1].GetFloat();
|
||||
float z = fields[2].GetFloat();
|
||||
uint32 id = VISUAL_WAYPOINT;
|
||||
|
||||
Player *chr = m_session->GetPlayer();
|
||||
float o = chr->GetOrientation();
|
||||
Map *map = chr->GetMap();
|
||||
|
||||
Field *fields = result->Fetch();
|
||||
CreatureCreatePos pos(map, fields[0].GetFloat(), fields[1].GetFloat(), fields[2].GetFloat(), chr->GetOrientation(), chr->GetPhaseMaskForSpawn());
|
||||
|
||||
Creature* pCreature = new Creature;
|
||||
|
||||
pCreature->Relocate(x, y, z, o);
|
||||
|
||||
if (!pCreature->IsPositionValid())
|
||||
if (!pCreature->Create(map->GenerateLocalLowGuid(HIGHGUID_UNIT), pos, VISUAL_WAYPOINT))
|
||||
{
|
||||
sLog.outError("Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY());
|
||||
delete pCreature;
|
||||
delete result;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!pCreature->Create(map->GenerateLocalLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id))
|
||||
{
|
||||
PSendSysMessage(LANG_WAYPOINT_NOTCREATED, id);
|
||||
PSendSysMessage(LANG_WAYPOINT_NOTCREATED, VISUAL_WAYPOINT);
|
||||
delete pCreature;
|
||||
delete result;
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue