@@ -1316,15 +1316,18 @@ static void TeleportToZone(Player player, CommandReader cmd) {
13161316 return ;
13171317 }
13181318
1319- Vector3I P = player . World . map . HighestFreeSpace ( zone . Bounds . XCentre ,
1320- zone . Bounds . YCentre , zone . Bounds . ZCentre ) ;
1321- Position zPos = new Position ( P . X * 32 + 16 , P . Y * 32 + 16 , P . Z * 32 + Player . CharacterHeight ) ;
1319+ int x = zone . Bounds . XCentre , y = zone . Bounds . YCentre ;
1320+ int z = player . WorldMap . HighestFreeSpace ( x , y , zone . Bounds . ZCentre ) ;
1321+
13221322 if ( player . World != null ) {
13231323 player . LastWorld = player . World ;
13241324 player . LastPosition = player . Position ;
13251325 }
13261326
1327- player . TeleportTo ( ( zPos ) ) ;
1327+ Position pos = new Position ( x , y , z ) ;
1328+ pos . R = player . Position . R ;
1329+ pos . L = player . Position . L ;
1330+ player . TeleportTo ( pos ) ;
13281331 player . Message ( "Teleporting you to zone " + zone . ClassyName ) ;
13291332 }
13301333
@@ -1333,20 +1336,18 @@ static void TeleportToRandom(Player player, CommandReader cmd) {
13331336 Random rand = new Random ( ) ;
13341337 int x = rand . Next ( 0 , player . WorldMap . Width ) ;
13351338 int y = rand . Next ( 0 , player . WorldMap . Length ) ;
1336- int z = ( player . Position . Z - Player . CharacterHeight ) / 32 ;
1337- Vector3I P = player . WorldMap . HighestFreeSpace ( x , y , z ) ;
1339+ int z = player . Position . BlockFeetZ ;
1340+ z = player . WorldMap . HighestFreeSpace ( x , y , z ) ;
13381341
13391342 if ( player . World != null ) {
13401343 player . LastWorld = player . World ;
13411344 player . LastPosition = player . Position ;
13421345 }
1343- player . TeleportTo ( new Position {
1344- X = ( P . X * 32 + 16 ) ,
1345- Y = ( P . Y * 32 + 16 ) ,
1346- Z = ( P . Z * 32 + Player . CharacterHeight ) ,
1347- R = player . Position . R ,
1348- L = player . Position . L
1349- } ) ;
1346+
1347+ Position pos = new Position ( x , y , z ) ;
1348+ pos . R = player . Position . R ;
1349+ pos . L = player . Position . L ;
1350+ player . TeleportTo ( pos ) ;
13501351 player . Message ( "Teleported to: ({0}, {1}, {2})" , x , y , z ) ;
13511352 }
13521353
@@ -1376,13 +1377,11 @@ static void TeleportToCoords(Player player, CommandReader cmd) {
13761377 player . LastWorld = player . World ;
13771378 player . LastPosition = player . Position ;
13781379 }
1379- player . TeleportTo ( new Position {
1380- X = ( x * 32 + 16 ) ,
1381- Y = ( y * 32 + 16 ) ,
1382- Z = ( z * 32 + Player . CharacterHeight ) ,
1383- R = ( byte ) rot ,
1384- L = ( byte ) lot
1385- } ) ;
1380+
1381+ Position pos = new Position ( x , y , z ) ;
1382+ pos . R = ( byte ) rot ;
1383+ pos . L = ( byte ) lot ;
1384+ player . TeleportTo ( pos ) ;
13861385 } else {
13871386 CdTeleport . PrintUsage ( player ) ;
13881387 }
@@ -1552,16 +1551,12 @@ static void TeleportPHandler(Player player, CommandReader cmd) {
15521551 static void TopHandler ( Player player , CommandReader cmd ) {
15531552 int x = player . Position . BlockX ;
15541553 int y = player . Position . BlockY ;
1555- int z = ( player . Position . Z - Player . CharacterHeight ) / 32 ;
1556- Vector3I P = player . World . map . HighestFreeSpace ( x , y , z ) ;
1557-
1558- player . TeleportTo ( new Position {
1559- X = ( P . X * 32 + 16 ) ,
1560- Y = ( P . Y * 32 + 16 ) ,
1561- Z = ( P . Z * 32 + Player . CharacterHeight ) ,
1562- R = player . Position . R ,
1563- L = player . Position . L
1564- } ) ;
1554+ int z = player . WorldMap . HighestFreeZ ( x , y ) ;
1555+
1556+ Position pos = new Position ( x , y , z ) ;
1557+ pos . R = player . Position . R ;
1558+ pos . L = player . Position . L ;
1559+ player . TeleportTo ( pos ) ;
15651560 player . Message ( "Teleported to top" ) ;
15661561 }
15671562
0 commit comments