Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static bool HandleGoXYZCommand(ChatHandler* handler, char const* args)
- {
- if (!*args)
- return false;
- Player* player = handler->GetSession()->GetPlayer();
- char* goX = strtok((char*)args, " ");
- char* goY = strtok(NULL, " ");
- char* goZ = strtok(NULL, " ");
- char* id = strtok(NULL, " ");
- char* port = strtok(NULL, " ");
- if (!goX || !goY)
- return false;
- float x = (float)atof(goX);
- float y = (float)atof(goY);
- float z;
- float ort = port ? (float)atof(port) : player->GetOrientation();
- uint32 mapId = id ? atoul(id) : player->GetMapId();
- if (goZ)
- {
- z = (float)atof(goZ);
- if (!MapManager::IsValidMapCoord(mapId, x, y, z))
- {
- handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
- handler->SetSentErrorMessage(true);
- return false;
- }
- }
- else
- {
- if (!MapManager::IsValidMapCoord(mapId, x, y))
- {
- handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
- handler->SetSentErrorMessage(true);
- return false;
- }
- Map const* map = sMapMgr->CreateBaseMap(mapId);
- z = std::max(map->GetStaticHeight(PhasingHandler::GetEmptyPhaseShift(), x, y, MAX_HEIGHT), map->GetWaterLevel(PhasingHandler::GetEmptyPhaseShift(), x, y));
- }
- // stop flight if need
- if (player->IsInFlight())
- {
- player->GetMotionMaster()->MovementExpired();
- player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
- else
- player->SaveRecallPosition();
- player->TeleportTo(mapId, x, y, z, ort);
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement