@@ -388,7 +388,7 @@ pub fn start_guest(room: Room, player: Option<String>, capture: AppStateCapture)
388388 }
389389 logging ! ( "RoomExperiment" , "MC connection is OK." ) ;
390390
391- let local = ProfileSnapshot {
391+ let local_profile = ProfileSnapshot {
392392 machine_id : MACHINE_ID . to_string ( ) ,
393393 name : player. unwrap_or ( "Terracotta Anonymous Guest" . to_string ( ) ) ,
394394 vendor : VENDOR . to_string ( ) ,
@@ -408,7 +408,7 @@ pub fn start_guest(room: Room, player: Option<String>, capture: AppStateCapture)
408408 room,
409409 easytier,
410410 server : FakeServer :: create ( local_port, crate :: MOTD ) ,
411- profiles : vec ! [ local . clone( ) ] ,
411+ profiles : vec ! [ local_profile . clone( ) ] ,
412412 }
413413 } )
414414 } ;
@@ -420,9 +420,9 @@ pub fn start_guest(room: Room, player: Option<String>, capture: AppStateCapture)
420420 {
421421 let Some ( _) = session. send_sync ( ( "c" , "player_ping" ) , |body| {
422422 serde_json:: to_writer ( body, & json ! ( {
423- "machine_id" : local . get_machine_id( ) ,
424- "name" : local . get_name( ) ,
425- "vendor" : local . get_vendor( )
423+ "machine_id" : local_profile . get_machine_id( ) ,
424+ "name" : local_profile . get_name( ) ,
425+ "vendor" : local_profile . get_vendor( )
426426 } ) ) . unwrap ( ) ;
427427 } ) else {
428428 fail ( capture) ;
@@ -431,7 +431,7 @@ pub fn start_guest(room: Room, player: Option<String>, capture: AppStateCapture)
431431 }
432432
433433 {
434- let Some ( mut server_profiles) = session. send_sync ( ( "c" , "player_profiles_list" ) , |_| { } ) . map ( |response| {
434+ let Some ( server_profiles) = session. send_sync ( ( "c" , "player_profiles_list" ) , |_| { } ) . map ( |response| {
435435 let PacketResponse :: Ok { data } = response else {
436436 unreachable ! ( ) ;
437437 } ;
@@ -476,6 +476,9 @@ pub fn start_guest(room: Room, player: Option<String>, capture: AppStateCapture)
476476 logging ! ( "RoomExperiment" , "API c:player_profiles_list invocation failed: No host detected." ) ;
477477 return None ;
478478 }
479+ if !local {
480+ server_players. push ( local_profile. clone ( ) ) ;
481+ }
479482
480483 server_players. sort_by_cached_key ( |profile| profile. get_machine_id ( ) . to_string ( ) ) ;
481484 for profile in server_players. windows ( 2 ) {
@@ -501,10 +504,6 @@ pub fn start_guest(room: Room, player: Option<String>, capture: AppStateCapture)
501504 return ;
502505 }
503506
504- if server_profiles. binary_search_by_key ( & * MACHINE_ID , |profile| profile. get_machine_id ( ) ) . is_err ( ) {
505- server_profiles. push ( local. clone ( ) ) ;
506- }
507-
508507 let mut used = vec ! [ false ; server_profiles. len( ) ] ;
509508 let mut changed = false ;
510509 for i in ( 0 ..profiles. len ( ) ) . rev ( ) {
@@ -549,6 +548,8 @@ pub fn start_guest(room: Room, player: Option<String>, capture: AppStateCapture)
549548 } ,
550549 }
551550 }
551+
552+ let mut server_profiles = server_profiles;
552553 for i in ( 0 ..server_profiles. len ( ) ) . rev ( ) {
553554 let profile = server_profiles. pop ( ) . unwrap ( ) ;
554555 if !used[ i] && * profile. get_kind ( ) != ProfileKind :: LOCAL {
0 commit comments