@@ -869,8 +869,8 @@ static bool ExpandFilename(Player player, CommandReader cmd, ref string fileName
869869 if ( fileName . CaselessStarts ( "pw_" ) && player . Info . Rank != RankManager . HighestRank ) {
870870 player . Message ( "You cannot make fake personal worlds" ) ;
871871 return false ;
872- }
873-
872+ }
873+
874874 // saving to file
875875 fileName = fileName . Replace ( Path . AltDirectorySeparatorChar , Path . DirectorySeparatorChar ) ;
876876 if ( ! fileName . CaselessEnds ( ".fcm" ) ) fileName += ".fcm" ;
@@ -953,7 +953,7 @@ private static void GenHMHandler(Player player, CommandReader cmd) {
953953 "GenHM: Asked {0} to confirm replacing the map of world {1} (\" this map\" )." ,
954954 player . Name , playerWorld . Name ) ;
955955
956- player . Confirm ( cmd , "Replace THIS MAP with a generated one (HeightMap: &9{0}&S)?" , url ) ;
956+ player . Confirm ( cmd , "Replace THIS MAP with a generated one (HeightMap: &9{0}&S)?" , url ) ;
957957 return ;
958958 }
959959
@@ -3444,19 +3444,34 @@ static void MWDelete(Player player, CommandReader cmd) {
34443444 }
34453445
34463446 static void MWJoin ( Player player , CommandReader cmd ) {
3447+ PlayerInfo info = player . Info ;
3448+ // Args are supposed to be "<map number> <player>", but handle if user provides <player> first
3449+ if ( cmd . HasNext ) {
3450+ string name = cmd . Next ( ) ;
3451+ int temp = 0 ;
3452+
3453+ if ( ! int . TryParse ( name , out temp ) ) {
3454+ info = PlayerDB . FindPlayerInfoOrPrintMatches ( player , name , SearchOptions . Default ) ;
3455+ if ( info == null ) return ;
3456+ } else {
3457+ cmd . Rewind ( ) ; // user provided number, rewind
3458+ cmd . Next ( ) ; // Skip 'join' arg
3459+ }
3460+ }
3461+
34473462 int num = 0 ; ReadMWNumber ( cmd , out num ) ;
3448- string name = cmd . Next ( ) ;
3449- PlayerInfo info = null ;
3450- if ( name != null ) {
3451- info = PlayerDB . FindPlayerInfoOrPrintMatches ( player , name , SearchOptions . Default ) ;
3463+ if ( info == player . Info && cmd . HasNext ) {
3464+ info = PlayerDB . FindPlayerInfoOrPrintMatches ( player , cmd . Next ( ) , SearchOptions . Default ) ;
3465+ if ( info == null ) return ;
34523466 }
3453- string mapName = "PW_" + ( ( info == null ) ? player . Name : info . Name ) + "_" + num ;
3454- string map = WorldManager . FindMapFile ( Player . Console , mapName ) ;
34553467
3468+ string mapName = "PW_" + info . Name + "_" + num ;
3469+ string map = WorldManager . FindMapFile ( Player . Console , mapName ) ;
34563470 if ( map == null ) {
3457- player . Message ( "{0} no personal worlds by that number: {1}" , ( info == null ) ? "You have" : "There are" , num ) ;
3471+ player . Message ( "{0} no personal worlds by that number: {1}" , ( info == player . Info ) ? "You have" : "There are" , num ) ;
34583472 return ;
34593473 }
3474+
34603475 World world = WorldManager . FindWorldExact ( mapName ) ;
34613476 if ( world != null && player . CanJoin ( world ) ) {
34623477 player . JoinWorld ( world , WorldChangeReason . ManualJoin ) ;
0 commit comments