本文整理汇总了C++中Map::GetId方法的典型用法代码示例。如果您正苦于以下问题:C++ Map::GetId方法的具体用法?C++ Map::GetId怎么用?C++ Map::GetId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Map
的用法示例。
在下文中一共展示了Map::GetId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleGameObjectAddCommand
//spawn go
static bool HandleGameObjectAddCommand (ChatHandler* handler, const char* args)
{
if (!*args)
return false;
// number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r
char* cId = handler->extractKeyFromLink((char*) args, "Hgameobject_entry");
if (!cId)
return false;
uint32 id = atol(cId);
if (!id)
return false;
char* spawntimeSecs = strtok(NULL, " ");
const GameObjectInfo *gInfo = sObjectMgr->GetGameObjectInfo(id);
if (!gInfo)
{
handler->PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST, id);
handler->SetSentErrorMessage(true);
return false;
}
if (gInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(gInfo->displayId))
{
// report to DB errors log as in loading case
sLog->outErrorDb("Gameobject (Entry %u GoType: %u) have invalid displayId (%u), not spawned.", id, gInfo->type, gInfo->displayId);
handler->PSendSysMessage(LANG_GAMEOBJECT_HAVE_INVALID_DATA, id);
handler->SetSentErrorMessage(true);
return false;
}
Player *chr = handler->GetSession()->GetPlayer();
float x = float(chr->GetPositionX());
float y = float(chr->GetPositionY());
float z = float(chr->GetPositionZ());
float o = float(chr->GetOrientation());
Map *map = chr->GetMap();
GameObject* pGameObj = new GameObject;
uint32 db_lowGUID = sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT);
if (!pGameObj->Create(db_lowGUID, gInfo->id, map, chr->GetPhaseMaskForSpawn(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY))
{
delete pGameObj;
return false;
}
if (spawntimeSecs)
{
uint32 value = atoi((char*) spawntimeSecs);
pGameObj->SetRespawnTime(value);
//sLog->outDebug(LOG_FILTER_TSCR, "*** spawntimeSecs: %d", value);
}
// fill the gameobject data and save to the db
pGameObj->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
// this will generate a new guid if the object is in an instance
if (!pGameObj->LoadFromDB(db_lowGUID, map))
{
delete pGameObj;
return false;
}
map->Add(pGameObj);
// TODO: is it really necessary to add both the real and DB table guid here ?
sObjectMgr->AddGameobjectToGrid(db_lowGUID, sObjectMgr->GetGOData(db_lowGUID));
handler->PSendSysMessage(LANG_GAMEOBJECT_ADD, id, gInfo->name, db_lowGUID, x, y, z);
sLog->outSQLDev("INSERT INTO gameobject ('%u', '%u', 1, '%u', '%u', '%u', '%u', '%u', 0, 0, 0, 1, 1, 60, 100, '%u');", db_lowGUID, gInfo->id, map, chr->GetPhaseMaskForSpawn(), x, y, z, GO_STATE_READY);
return true;
}
示例2: Update
void IdleState::Update(Map& map, NGridType& grid, GridInfo&, uint32) const
{
map.ResetGridExpiry(grid);
grid.SetGridState(GRID_STATE_REMOVAL);
TC_LOG_DEBUG("maps", "Grid[%u, %u] on map %u moved to REMOVAL state", grid.getX(), grid.getY(), map.GetId());
}
示例3:
void
RemovalState::Update(Map &m, NGridType &grid, GridInfo &info, const uint32 &x, const uint32 &y, const uint32 &t_diff) const
{
if (!info.getUnloadLock())
{
info.UpdateTimeTracker(t_diff);
if (info.getTimeTracker().Passed())
{
if (!m.UnloadGrid(x, y, false))
{
sLog->outDebug(LOG_FILTER_MAPS, "Grid[%u, %u] for map %u differed unloading due to players or active objects nearby", x, y, m.GetId());
m.ResetGridExpiry(grid);
}
}
}
}
示例4: HandleGameObjectAddCommand
//spawn go
static bool HandleGameObjectAddCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
// number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r
char* id = handler->extractKeyFromLink((char*)args, "Hgameobject_entry");
if (!id)
return false;
uint32 objectId = atoul(id);
if (!objectId)
return false;
char* spawntimeSecs = strtok(NULL, " ");
const GameObjectTemplate* objectInfo = sObjectMgr->GetGameObjectTemplate(objectId);
if (!objectInfo)
{
handler->PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST, objectId);
handler->SetSentErrorMessage(true);
return false;
}
if (objectInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(objectInfo->displayId))
{
// report to DB errors log as in loading case
TC_LOG_ERROR("sql.sql", "Gameobject (Entry %u GoType: %u) have invalid displayId (%u), not spawned.", objectId, objectInfo->type, objectInfo->displayId);
handler->PSendSysMessage(LANG_GAMEOBJECT_HAVE_INVALID_DATA, objectId);
handler->SetSentErrorMessage(true);
return false;
}
Player* player = handler->GetSession()->GetPlayer();
float x = float(player->GetPositionX());
float y = float(player->GetPositionY());
float z = float(player->GetPositionZ());
float o = float(player->GetOrientation());
Map* map = player->GetMap();
GameObject* object = new GameObject;
if (!object->Create(objectInfo->entry, map, 0, x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY))
{
delete object;
return false;
}
object->CopyPhaseFrom(player);
if (spawntimeSecs)
{
uint32 value = atoi((char*)spawntimeSecs);
object->SetRespawnTime(value);
}
// fill the gameobject data and save to the db
object->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), player->GetPhaseMask());
ObjectGuid::LowType spawnId = object->GetSpawnId();
// delete the old object and do a clean load from DB with a fresh new GameObject instance.
// this is required to avoid weird behavior and memory leaks
delete object;
object = new GameObject();
// this will generate a new guid if the object is in an instance
if (!object->LoadGameObjectFromDB(spawnId, map))
{
delete object;
return false;
}
/// @todo is it really necessary to add both the real and DB table guid here ?
sObjectMgr->AddGameobjectToGrid(spawnId, ASSERT_NOTNULL(sObjectMgr->GetGOData(spawnId)));
handler->PSendSysMessage(LANG_GAMEOBJECT_ADD, objectId, objectInfo->name.c_str(), spawnId, x, y, z);
return true;
}
示例5: HandleWpShowCommand
//.........这里部分代码省略.........
if (hasError)
{
handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR1);
handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR2);
handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR3);
}
}
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 = handler->GetSession()->GetPlayer();
Map *map = chr->GetMap();
float o = chr->GetOrientation();
Creature* wpCreature = new Creature;
if (!wpCreature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, 0, x, y, z, o))
{
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id);
delete wpCreature;
return false;
}
// set "wpguid" column to the visual waypoint
WorldDatabase.PExecute("UPDATE waypoint_data SET wpguid = '%u' WHERE id = '%u' and point = '%u'", wpCreature->GetGUIDLow(), pathid, point);
wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
wpCreature->LoadFromDB(wpCreature->GetDBTableGUIDLow(), map);
map->AddToMap(wpCreature);
if (target)
{
wpCreature->SetDisplayId(target->GetDisplayId());
wpCreature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5);
wpCreature->SetLevel(point > STRONG_MAX_LEVEL ? STRONG_MAX_LEVEL : point);
}
}
while (result->NextRow());
handler->SendSysMessage("|cff00ff00Showing the current creature's path.|r");
return true;
}
if (show == "first")
{
handler->PSendSysMessage("|cff00ff00DEBUG: wp first, GUID: %u|r", pathid);
QueryResult result = WorldDatabase.PQuery("SELECT position_x, position_y, position_z FROM waypoint_data WHERE point='1' AND id = '%u'", pathid);
if (!result)
{
handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUND, pathid);
handler->SetSentErrorMessage(true);
return false;
}
Field* fields = result->Fetch();
float x = fields[0].GetFloat();
float y = fields[1].GetFloat();
示例6: stoper
void
ActiveState::Update(Map &m, NGridType &grid, GridInfo & info, const uint32 &x, const uint32 &y, const uint32 &t_diff) const
{
// Only check grid activity every (grid_expiry/10) ms, because it's really useless to do it every cycle
info.UpdateTimeTracker(t_diff);
if (info.getTimeTracker().Passed())
{
if (grid.ActiveObjectsInGrid() == 0 && !m.ActiveObjectsNearGrid(x, y))
{
ObjectGridStoper stoper(grid);
stoper.StopN();
grid.SetGridState(GRID_STATE_IDLE);
sLog->outDebug(LOG_FILTER_MAPS, "Grid[%u, %u] on map %u moved to IDLE state", x, y, m.GetId());
}
else
{
m.ResetGridExpiry(grid, 0.1f);
}
}
}
示例7: HandleWpModifyCommand
//.........这里部分代码省略.........
}
if (show == "del")
{
handler->PSendSysMessage("|cff00ff00DEBUG: wp modify del, PathID: |r|cff00ffff%u|r", pathid);
if (wpGuid != 0)
if (Creature* wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(ObjectGuid(HighGuid::Unit, VISUAL_WAYPOINT, wpGuid)))
{
wpCreature->CombatStop();
wpCreature->DeleteFromDB();
wpCreature->AddObjectToRemoveList();
}
stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_WAYPOINT_DATA);
stmt->setUInt32(0, pathid);
stmt->setUInt32(1, point);
WorldDatabase.Execute(stmt);
stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_DATA_POINT);
stmt->setUInt32(0, pathid);
stmt->setUInt32(1, point);
WorldDatabase.Execute(stmt);
handler->PSendSysMessage(LANG_WAYPOINT_REMOVED);
return true;
} // del
if (show == "move")
{
handler->PSendSysMessage("|cff00ff00DEBUG: wp move, PathID: |r|cff00ffff%u|r", pathid);
Player* chr = handler->GetSession()->GetPlayer();
Map* map = chr->GetMap();
{
// What to do:
// Move the visual spawnpoint
// Respawn the owner of the waypoints
if (wpGuid != 0)
{
if (Creature* wpCreature = map->GetCreature(ObjectGuid(HighGuid::Unit, VISUAL_WAYPOINT, wpGuid)))
{
wpCreature->CombatStop();
wpCreature->DeleteFromDB();
wpCreature->AddObjectToRemoveList();
}
// re-create
Creature* wpCreature2 = new Creature();
if (!wpCreature2->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation()))
{
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
delete wpCreature2;
wpCreature2 = NULL;
return false;
}
wpCreature2->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
/// @todo Should we first use "Create" then use "LoadFromDB"?
if (!wpCreature2->LoadCreatureFromDB(wpCreature2->GetSpawnId(), map))
{
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
delete wpCreature2;
wpCreature2 = NULL;
return false;
}
//sMapMgr->GetMap(npcCreature->GetMapId())->Add(wpCreature2);
}
stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_DATA_POSITION);
stmt->setFloat(0, chr->GetPositionX());
stmt->setFloat(1, chr->GetPositionY());
stmt->setFloat(2, chr->GetPositionZ());
stmt->setUInt32(3, pathid);
stmt->setUInt32(4, point);
WorldDatabase.Execute(stmt);
handler->PSendSysMessage(LANG_WAYPOINT_CHANGED);
}
return true;
} // move
const char *text = arg_str;
if (text == 0)
{
// show_str check for present in list of correct values, no sql injection possible
WorldDatabase.PExecute("UPDATE waypoint_data SET %s=NULL WHERE id='%u' AND point='%u'", show_str, pathid, point); // Query can't be a prepared statement
}
else
{
// show_str check for present in list of correct values, no sql injection possible
std::string text2 = text;
WorldDatabase.EscapeString(text2);
WorldDatabase.PExecute("UPDATE waypoint_data SET %s='%s' WHERE id='%u' AND point='%u'", show_str, text2.c_str(), pathid, point); // Query can't be a prepared statement
}
handler->PSendSysMessage(LANG_WAYPOINT_CHANGED_NO, show_str);
return true;
}
示例8: HandleWpShowCommand
//.........这里部分代码省略.........
handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR3);
}
}
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 = handler->GetSession()->GetPlayer();
Map* map = chr->GetMap();
float o = chr->GetOrientation();
Creature* wpCreature = new Creature();
if (!wpCreature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, chr->GetPhaseMaskForSpawn(), id, x, y, z, o))
{
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id);
delete wpCreature;
return false;
}
// Set "wpguid" column to the visual waypoint
stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_DATA_WPGUID);
stmt->setInt32(0, int32(wpCreature->GetGUID().GetCounter()));
stmt->setUInt32(1, pathid);
stmt->setUInt32(2, point);
WorldDatabase.Execute(stmt);
wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
if (!wpCreature->LoadCreatureFromDB(wpCreature->GetSpawnId(), map))
{
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id);
delete wpCreature;
return false;
}
if (target)
{
wpCreature->SetDisplayId(target->GetDisplayId());
wpCreature->SetObjectScale(0.5f);
wpCreature->SetLevel(std::min<uint32>(point, STRONG_MAX_LEVEL));
}
}
while (result->NextRow());
handler->SendSysMessage("|cff00ff00Showing the current creature's path.|r");
return true;
}
if (show == "first")
{
handler->PSendSysMessage("|cff00ff00DEBUG: wp first, GUID: %u|r", pathid);
stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_POS_FIRST_BY_ID);
stmt->setUInt32(0, pathid);
PreparedQueryResult result = WorldDatabase.Query(stmt);
if (!result)
{
handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUND, pathid);
示例9: place
static GameObject* place(Player* player, float x, float y, float z, float o, uint32 phase, uint32 guid)
{
// e = !move && entry or move && guid (entryorguid
if (!player || !guid)
return NULL;
phase = 1;
const GameObjectTemplate* objectInfo = sObjectMgr->GetGameObjectTemplate(guid);
if(player->GetDistance(x, y, z) > 20)
{
ChatHandler(player->GetSession()).PSendSysMessage("You cant place that object so far away.");
ChatHandler(player->GetSession()).SetSentErrorMessage(true);
return NULL;
}
if (!objectInfo)
{
ChatHandler(player->GetSession()).PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST, guid);
ChatHandler(player->GetSession()).SetSentErrorMessage(true);
return NULL;
}
if (objectInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(objectInfo->displayId))
{
// sLog->outErrorDb("Gameobject (Entry %u GoType: %u) have invalid displayId (%u), not spawned.", e, objectInfo->type, objectInfo->displayId);
ChatHandler(player->GetSession()).PSendSysMessage(LANG_GAMEOBJECT_HAVE_INVALID_DATA, guid);
ChatHandler(player->GetSession()).SetSentErrorMessage(true);
return NULL;
}
Map* map = player->GetMap();
if(player->GetMapId() == 608)
{
ChatHandler(player->GetSession()).PSendSysMessage("Stop! Not so fast. No placing APTs in here.");
ChatHandler(player->GetSession()).SetSentErrorMessage(true);
return NULL;
}
GameObject* object = new GameObject;
uint32 guidLow = sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT);
if (!object->Create(guidLow, objectInfo->entry, map, phase, x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY))
{
delete object;
return NULL;
}
object->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), phase);
if (!object->LoadGameObjectFromDB(guidLow, map))
{
delete object;
return NULL;
}
// STORE THE ITEM_INSTANCE THAT WAS USED TO SPAWN THIS ITEM!!!
sObjectMgr->AddGameobjectToGrid(guidLow, sObjectMgr->GetGOData(guidLow));
uint32 sec = time(NULL);
QueryResult result = WorldDatabase.PQuery("INSERT INTO apt_placed_objects VALUES('%u', '%u')", item_script_apt::itemGuid, guidLow);
result = WorldDatabase.PQuery("INSERT INTO legacy_gameobject VALUES ('%u', '1', '0', '%u')", guidLow, player->GetGUIDLow());
return object;
}
示例10: HandleNpcBotSpawnCommand
//.........这里部分代码省略.........
if (!creInfo)
{
handler->PSendSysMessage("creature %u does not exist!", id);
handler->SetSentErrorMessage(true);
return false;
}
if (!(creInfo->flags_extra & CREATURE_FLAG_EXTRA_NPCBOT))
{
handler->PSendSysMessage("creature %u is not a npcbot!", id);
handler->SetSentErrorMessage(true);
return false;
}
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_NPCBOT_OWNER);
//"SELECT owner FROM character_npcbot WHERE entry = ?", CONNECTION_SYNCH
stmt->setUInt32(0, id);
PreparedQueryResult res1 = CharacterDatabase.Query(stmt);
if (res1)
{
handler->PSendSysMessage("Npcbot %u already exists in `characters_npcbot` table!", id);
handler->SendSysMessage("If you want to replace this bot to new location use '.npc move' command");
handler->SetSentErrorMessage(true);
return false;
}
stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_CREATURE_BY_ID);
//"SELECT guid FROM creature WHERE id = ?", CONNECTION_SYNCH
stmt->setUInt32(0, id);
PreparedQueryResult res2 = WorldDatabase.Query(stmt);
if (res2)
{
handler->PSendSysMessage("Npcbot %u already exists in `creature` table!", id);
handler->SetSentErrorMessage(true);
return false;
}
Player* chr = handler->GetSession()->GetPlayer();
if (chr->GetTransport())
{
handler->SendSysMessage("Cannot spawn bots on transport!");
handler->SetSentErrorMessage(true);
return false;
}
float x = chr->GetPositionX();
float y = chr->GetPositionY();
float z = chr->GetPositionZ();
float o = chr->GetOrientation();
Map* map = chr->GetMap();
if (map->Instanceable())
{
handler->SendSysMessage("Cannot spawn bots in instances!");
handler->SetSentErrorMessage(true);
return false;
}
Creature* creature = new Creature();
if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMgr().GetPhaseMaskForSpawn(), id, 0, 0, x, y, z, o, 0))
{
delete creature;
return false;
}
uint8 roleMask = BOT_ROLE_DPS;
uint8 m_class = creature->GetCreatureTemplate()->trainer_class;
if (!(m_class == CLASS_WARRIOR || m_class == CLASS_ROGUE ||
m_class == CLASS_PALADIN || m_class == CLASS_DEATH_KNIGHT ||
m_class == CLASS_SHAMAN || m_class == BOT_CLASS_BM))
roleMask |= BOT_ROLE_RANGED;
if (m_class == CLASS_PRIEST || m_class == CLASS_DRUID ||
m_class == CLASS_SHAMAN || m_class == CLASS_PALADIN)
roleMask |= BOT_ROLE_HEAL;
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_NPCBOT);
//"INSERT INTO characters_npcbot (entry, roles) VALUES (?, ?)", CONNECTION_SYNCH
stmt->setUInt32(0, id);
stmt->setUInt8(1, roleMask);
CharacterDatabase.DirectExecute(stmt);
creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMgr().GetPhaseMaskForSpawn());
uint32 db_guid = creature->GetDBTableGUIDLow();
if (!creature->LoadBotCreatureFromDB(db_guid, map))
{
handler->SendSysMessage("Cannot load npcbot from DB!");
handler->SetSentErrorMessage(true);
//return false;
delete creature;
return false;
}
sObjectMgr->AddCreatureToGrid(db_guid, sObjectMgr->GetCreatureData(db_guid));
handler->SendSysMessage("Npcbot successfully spawned.");
return true;
}
示例11: HandleMoveWorldportAckOpcode
void WorldSession::HandleMoveWorldportAckOpcode()
{
// ignore unexpected far teleports
if (!GetPlayer()->IsBeingTeleportedFar())
return;
// get the teleport destination
WorldLocation const& loc = GetPlayer()->GetTeleportDest();
// possible errors in the coordinate validity check
if (!MapManager::IsValidMapCoord(loc))
{
sLog.outError("WorldSession::HandleMoveWorldportAckOpcode: player %s (%d) was teleported far to a not valid location. (map:%u, x:%f, y:%f, "
"z:%f) We port him to his homebind instead..", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), loc.GetMapId(), loc.GetPositionX(), loc.GetPositionY(), loc.GetPositionZ());
// stop teleportation else we would try this again and again in LogoutPlayer...
GetPlayer()->SetSemaphoreTeleportFar(false);
// and teleport the player to a valid place
GetPlayer()->TeleportToHomebind();
return;
}
// get the destination map entry, not the current one, this will fix homebind and reset greeting
MapEntry const* mEntry = sMapStore.LookupEntry(loc.GetMapId());
InstanceTemplate const* mInstance = sObjectMgr.GetInstanceTemplate(loc.GetMapId());
// reset instance validity, except if going to an instance inside an instance
if (GetPlayer()->m_InstanceValid == false && !mInstance)
GetPlayer()->m_InstanceValid = true;
GetPlayer()->SetSemaphoreTeleportFar(false);
Map* oldMap = GetPlayer()->GetMap();
ASSERT(oldMap);
if (GetPlayer()->IsInWorld())
{
sLog.outError("Crash alert! Player is still in world when teleported from map %u! to new map %u", oldMap->GetId(), loc.GetMapId());
oldMap->RemoveFromMap(GetPlayer(), false);
}
// relocate the player to the teleport destination
Map* newMap = MapManager::Instance().CreateMap(loc.GetMapId(), GetPlayer(), 0);
// the CanEnter checks are done in TeleporTo but conditions may change
// while the player is in transit, for example the map may get full
if (!newMap || !newMap->CanEnter(GetPlayer()))
{
sLog.outError("Map %d could not be created for player %d, porting player to homebind", loc.GetMapId(), GetPlayer()->GetGUIDLow());
GetPlayer()->TeleportToHomebind();
return;
}
else
GetPlayer()->Relocate(&loc);
GetPlayer()->ResetMap();
GetPlayer()->SetMap(newMap);
// check this before Map::AddToMap(player), because that will create the instance save!
bool reset_notify = (GetPlayer()->GetBoundInstance(GetPlayer()->GetMapId(), GetPlayer()->GetDifficulty()) == NULL);
GetPlayer()->SendInitialPacketsBeforeAddToMap();
if (!GetPlayer()->GetMap()->AddToMap(GetPlayer()))
{
sLog.outError("WORLD: failed to teleport player %s (%d) to map %d because of unknown reason!", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), loc.GetMapId());
GetPlayer()->ResetMap();
GetPlayer()->SetMap(oldMap);
GetPlayer()->TeleportToHomebind();
return;
}
// battleground state prepare (in case join to BG), at relogin/tele player not invited
// only add to bg group and object, if the player was invited (else he entered through command)
if (GetPlayer()->InBattleGround())
{
// cleanup setting if outdated
if (!mEntry->IsBattleGroundOrArena())
{
// We're not in BG
GetPlayer()->SetBattleGroundId(0); // We're not in BG.
// reset destination bg team
GetPlayer()->SetBGTeam(0);
}
// join to bg case
else if (BattleGround* bg = GetPlayer()->GetBattleGround())
{
if (GetPlayer()->IsInvitedForBattleGroundInstance(GetPlayer()->GetBattleGroundId()))
bg->AddPlayer(GetPlayer());
}
}
GetPlayer()->SendInitialPacketsAfterAddToMap();
// flight fast teleport case
if (GetPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE)
{
if (!GetPlayer()->InBattleGround())
{
// short preparations to continue flight
FlightPathMovementGenerator* flight = (FlightPathMovementGenerator*)(GetPlayer()->GetMotionMaster()->top());
flight->Initialize(*GetPlayer());
return;
}
//.........这里部分代码省略.........
示例12:
void
IdleState::Update(Map &m, NGridType &grid, GridInfo &, const uint32) const
{
m.ResetGridExpiry(grid);
grid.SetGridState(GRID_STATE_REMOVAL);
sLog.outDebug("Grid[%u, %u] on map %u moved to REMOVAL state", grid.getX(), grid.getY(), m.GetId());
}
示例13: HandleNpcAddCommand
//add spawn of creature
static bool HandleNpcAddCommand(ChatHandler* handler, const char* args)
{
if (!*args)
return false;
char* charID = handler->extractKeyFromLink((char*)args, "Hcreature_entry");
if (!charID)
return false;
char* team = strtok(NULL, " ");
int32 teamval = 0;
if (team) { teamval = atoi(team); }
if (teamval < 0) { teamval = 0; }
uint32 id = atoi(charID);
Player* chr = handler->GetSession()->GetPlayer();
float x = chr->GetPositionX();
float y = chr->GetPositionY();
float z = chr->GetPositionZ();
float o = chr->GetOrientation();
Map* map = chr->GetMap();
if (chr->GetTransport())
{
uint32 tguid = chr->GetTransport()->AddNPCPassenger(0, id, chr->GetTransOffsetX(), chr->GetTransOffsetY(), chr->GetTransOffsetZ(), chr->GetTransOffsetO());
if (tguid > 0)
{
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_CREATURE_TRANSPORT);
stmt->setInt32(0, int32(tguid));
stmt->setInt32(1, int32(id));
stmt->setInt32(2, int32(chr->GetTransport()->GetEntry()));
stmt->setFloat(3, chr->GetTransOffsetX());
stmt->setFloat(4, chr->GetTransOffsetY());
stmt->setFloat(5, chr->GetTransOffsetZ());
stmt->setFloat(6, chr->GetTransOffsetO());
WorldDatabase.Execute(stmt);
}
return true;
}
Creature* creature = new Creature();
if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, (uint32)teamval, x, y, z, o))
{
delete creature;
return false;
}
creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
uint32 db_guid = creature->GetDBTableGUIDLow();
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
if (!creature->LoadCreatureFromDB(db_guid, map))
{
delete creature;
return false;
}
sObjectMgr->AddCreatureToGrid(db_guid, sObjectMgr->GetCreatureData(db_guid));
return true;
}
示例14: TeleportPlayer
void LfgGroup::TeleportPlayer(Player *plr, DungeonInfo *dungeonInfo, uint32 originalDungeonId, bool newPlr)
{
if(newPlr)
{
plr->m_lookingForGroup.queuedDungeons.clear(); // must be before remove grom group
if (Group *group = plr->GetGroup())
{
if (!group->isLfgGroup())
{
group->RemoveMember(plr->GetGUID(), 0);
if (group->GetMembersCount() == 0)
group->Disband(true);
}
plr->SetGroup(NULL);
}
plr->UnbindInstance(dungeonInfo->start_map, m_dungeonInfo->isHeroic() ? DUNGEON_DIFFICULTY_HEROIC : DUNGEON_DIFFICULTY_NORMAL);
plr->ResetInstances(INSTANCE_RESET_GROUP_JOIN,false);
plr->ResetInstances(INSTANCE_RESET_GROUP_JOIN,true);
plr->ResetInstances(INSTANCE_RESET_ALL, true);
plr->ResetInstances(INSTANCE_RESET_ALL, false);
if (plr->getLevel() >= LEVELREQUIREMENT_HEROIC)
{
if (plr->GetDungeonDifficulty() != GetDungeonDifficulty())
plr->SetDungeonDifficulty(GetDungeonDifficulty());
if (plr->GetRaidDifficulty() != GetRaidDifficulty())
plr->SetRaidDifficulty(GetRaidDifficulty());
}
plr->SetGroup(this, 0);
plr->SetGroupInvite(NULL);
uint32 taxi_start = 0;
uint32 taxi_end = 0;
uint32 mount_spell = 0;
WorldLocation joinLoc;
if (!plr->m_taxi.empty())
{
taxi_start = plr->m_taxi.GetTaxiSource();
taxi_end = plr->m_taxi.GetTaxiDestination();
joinLoc = WorldLocation(plr->GetMapId(), plr->GetPositionX(), plr->GetPositionY(), plr->GetPositionZ(), plr->GetOrientation());
}
else
{
// Mount spell id storing
if (plr->IsMounted())
{
Unit::AuraList const& auras = plr->GetAurasByType(SPELL_AURA_MOUNTED);
if (!auras.empty())
mount_spell = (*auras.begin())->GetId();
}
if(!mount_spell && plr->getClass() == CLASS_DRUID)
{
Unit::AuraList const& auras = plr->GetAurasByType(SPELL_AURA_MOD_SHAPESHIFT);
if (!auras.empty())
mount_spell = (*auras.begin())->GetId();
}
//Nearest graveyard if in dungeon
if (plr->GetMap()->IsDungeon())
{
if (const WorldSafeLocsEntry* entry = sObjectMgr.GetClosestGraveYard(plr->GetPositionX(), plr->GetPositionY(), plr->GetPositionZ(), plr->GetMapId(), plr->GetTeam()))
joinLoc = WorldLocation(entry->map_id, entry->x, entry->y, entry->z, 0.f);
else
joinLoc = plr->GetLocation();
}
else
joinLoc = plr->GetLocation();
}
CharacterDatabase.PExecute("DELETE FROM group_member WHERE memberGuid='%u'", GUID_LOPART(plr->GetGUID()));
CharacterDatabase.PExecute("INSERT INTO group_member(groupId,memberGuid,assistant,subgroup,lfg_join_x,lfg_join_y,lfg_join_z,lfg_join_o,lfg_join_map,taxi_start,taxi_end,mount_spell) "
"VALUES('%u','%u','%u','%u','%f','%f','%f','%f','%u','%u','%u','%u')",
m_Id, GUID_LOPART(plr->GetGUID()), 0, 1, joinLoc.x(), joinLoc.y(), joinLoc.z(), joinLoc.orientation, joinLoc.mapid, taxi_start, taxi_end, mount_spell);
//Set info to player
plr->m_lookingForGroup.joinLoc = joinLoc;
plr->m_lookingForGroup.taxi_start = taxi_start;
plr->m_lookingForGroup.taxi_end = taxi_end;
plr->m_lookingForGroup.mount_spell = mount_spell;
plr->m_lookingForGroup.roles = GetPlayerRole(plr->GetGUID());
if (IsRandom())
plr->CastSpell(plr, LFG_RANDOM_COOLDOWN, true);
}
// resurrect the player
if (!plr->isAlive())
{
plr->ResurrectPlayer(1.0f);
plr->SpawnCorpseBones();
}
// stop taxi flight at port
if (plr->isInFlight())
{
plr->GetMotionMaster()->MovementExpired(false);
plr->GetMotionMaster()->Clear(false, true);
plr->GetMotionMaster()->MoveIdle();
plr->m_taxi.ClearTaxiDestinations();
}
plr->ScheduleDelayedOperation(DELAYED_LFG_ENTER_DUNGEON);
//.........这里部分代码省略.........
示例15: HandleNpcAddCommand
//add spawn of creature
static bool HandleNpcAddCommand (ChatHandler* handler, const char* args)
{
if (!*args)
return false;
char* charID = handler->extractKeyFromLink((char*) args, "Hcreature_entry");
if (!charID)
return false;
char* team = strtok(NULL, " ");
int32 teamval = 0;
if (team)
{
teamval = atoi(team);
}
if (teamval < 0)
{
teamval = 0;
}
uint32 id = atoi(charID);
Player *chr = handler->GetSession()->GetPlayer();
float x = chr->GetPositionX();
float y = chr->GetPositionY();
float z = chr->GetPositionZ();
float o = chr->GetOrientation();
Map *map = chr->GetMap();
if (chr->GetTransport())
{
if (!map->ToInstanceMap())
{
if (chr->GetTransport()->AddNPCPassenger(0, id, chr->GetTransOffsetX(), chr->GetTransOffsetY(), chr->GetTransOffsetZ(), chr->GetTransOffsetO()))
{
WorldDatabase.PQuery("INSERT INTO creature_transport (guid, transport_entry, npc_entry, TransOffsetX, TransOffsetY, TransOffsetZ, TransOffsetO, emote) values (%u, %u, %u, %f, %f, %f, %f, 0)", 0, chr->GetTransport()->GetEntry(), id, chr->GetTransOffsetX(), chr->GetTransOffsetY(), chr->GetTransOffsetZ(), chr->GetTransOffsetO());
}
}
else
{
chr->GetTransport()->AddNPCPassengerInInstance(0, id, chr->GetTransOffsetX(), chr->GetTransOffsetY(), chr->GetTransOffsetZ(), chr->GetTransOffsetO());
WorldDatabase.PQuery("INSERT INTO creature_transport (guid, transport_entry, npc_entry, TransOffsetX, TransOffsetY, TransOffsetZ, TransOffsetO, emote) values (%u, %u, %u, %f, %f, %f, %f, 0)", 0, chr->GetTransport()->GetEntry(), id, chr->GetTransOffsetX(), chr->GetTransOffsetY(), chr->GetTransOffsetZ(), chr->GetTransOffsetO());
}
return true;
}
Creature* pCreature = new Creature;
if (!pCreature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, (uint32)teamval, x, y, z, o))
{
delete pCreature;
return false;
}
pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
uint32 db_guid = pCreature->GetDBTableGUIDLow();
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
pCreature->LoadFromDB(db_guid, map);
map->Add(pCreature);
sObjectMgr->AddCreatureToGrid(db_guid, sObjectMgr->GetCreatureData(db_guid));
return true;
}