@@ -170,6 +170,8 @@ pub fn start_host(room: Room, port: u16, player: Option<String>, capture: AppSta
170170 thread:: spawn ( move || {
171171 let mut counter = 0 ;
172172 loop {
173+ thread:: sleep ( Duration :: from_secs ( 5 ) ) ;
174+
173175 if legacy:: check_mc_conn ( port) {
174176 counter = 0 ;
175177 } else {
@@ -282,8 +284,8 @@ pub fn start_guest(room: Room, player: Option<String>, capture: AppStateCapture)
282284 }
283285
284286 let mut session = ' session: {
285- for timeout in [ 4 , 4 , 8 , 4 , 8 , 16 ] {
286- thread:: sleep ( Duration :: from_secs ( timeout ) ) ;
287+ for _ in 0 .. 60 {
288+ thread:: sleep ( Duration :: from_secs ( 4 ) ) ;
287289
288290 const FINGERPRINT : [ u8 ; 16 ] = [ 0x41 , 0x57 , 0x48 , 0x44 , 0x86 , 0x37 , 0x40 , 0x59 , 0x57 , 0x44 , 0x92 , 0x43 , 0x96 , 0x99 , 0x85 , 0x01 ] ;
289291 if let Ok ( mut session) = ClientSession :: open ( IpAddr :: V4 ( Ipv4Addr :: LOCALHOST ) , scaffolding_port)
@@ -386,7 +388,7 @@ pub fn start_guest(room: Room, player: Option<String>, capture: AppStateCapture)
386388 }
387389 logging ! ( "RoomExperiment" , "MC connection is OK." ) ;
388390
389- let local = ProfileSnapshot {
391+ let local_profile = ProfileSnapshot {
390392 machine_id : MACHINE_ID . to_string ( ) ,
391393 name : player. unwrap_or ( "Terracotta Anonymous Guest" . to_string ( ) ) ,
392394 vendor : VENDOR . to_string ( ) ,
@@ -406,7 +408,7 @@ pub fn start_guest(room: Room, player: Option<String>, capture: AppStateCapture)
406408 room,
407409 easytier,
408410 server : FakeServer :: create ( local_port, crate :: MOTD ) ,
409- profiles : vec ! [ local . clone( ) ] ,
411+ profiles : vec ! [ local_profile . clone( ) ] ,
410412 }
411413 } )
412414 } ;
@@ -418,9 +420,9 @@ pub fn start_guest(room: Room, player: Option<String>, capture: AppStateCapture)
418420 {
419421 let Some ( _) = session. send_sync ( ( "c" , "player_ping" ) , |body| {
420422 serde_json:: to_writer ( body, & json ! ( {
421- "machine_id" : local . get_machine_id( ) ,
422- "name" : local . get_name( ) ,
423- "vendor" : local . get_vendor( )
423+ "machine_id" : local_profile . get_machine_id( ) ,
424+ "name" : local_profile . get_name( ) ,
425+ "vendor" : local_profile . get_vendor( )
424426 } ) ) . unwrap ( ) ;
425427 } ) else {
426428 fail ( capture) ;
@@ -429,7 +431,7 @@ pub fn start_guest(room: Room, player: Option<String>, capture: AppStateCapture)
429431 }
430432
431433 {
432- 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| {
433435 let PacketResponse :: Ok { data } = response else {
434436 unreachable ! ( ) ;
435437 } ;
@@ -474,6 +476,9 @@ pub fn start_guest(room: Room, player: Option<String>, capture: AppStateCapture)
474476 logging ! ( "RoomExperiment" , "API c:player_profiles_list invocation failed: No host detected." ) ;
475477 return None ;
476478 }
479+ if !local {
480+ server_players. push ( local_profile. clone ( ) ) ;
481+ }
477482
478483 server_players. sort_by_cached_key ( |profile| profile. get_machine_id ( ) . to_string ( ) ) ;
479484 for profile in server_players. windows ( 2 ) {
@@ -499,10 +504,6 @@ pub fn start_guest(room: Room, player: Option<String>, capture: AppStateCapture)
499504 return ;
500505 }
501506
502- if server_profiles. binary_search_by_key ( & * MACHINE_ID , |profile| profile. get_machine_id ( ) ) . is_err ( ) {
503- server_profiles. push ( local. clone ( ) ) ;
504- }
505-
506507 let mut used = vec ! [ false ; server_profiles. len( ) ] ;
507508 let mut changed = false ;
508509 for i in ( 0 ..profiles. len ( ) ) . rev ( ) {
@@ -547,6 +548,8 @@ pub fn start_guest(room: Room, player: Option<String>, capture: AppStateCapture)
547548 } ,
548549 }
549550 }
551+
552+ let mut server_profiles = server_profiles;
550553 for i in ( 0 ..server_profiles. len ( ) ) . rev ( ) {
551554 let profile = server_profiles. pop ( ) . unwrap ( ) ;
552555 if !used[ i] && * profile. get_kind ( ) != ProfileKind :: LOCAL {
@@ -563,7 +566,7 @@ pub fn start_guest(room: Room, player: Option<String>, capture: AppStateCapture)
563566}
564567
565568fn compute_arguments ( room : & Room , public_servers : PublicServers ) -> Vec < Argument > {
566- static DEFAULT_ARGUMENTS : [ Argument ; 7 ] = [
569+ static DEFAULT_ARGUMENTS : [ Argument ; 8 ] = [
567570 Argument :: NoTun ,
568571 Argument :: Compression ( Cow :: Borrowed ( "zstd" ) ) ,
569572 Argument :: MultiThread ,
@@ -577,6 +580,7 @@ fn compute_arguments(room: &Room, public_servers: PublicServers) -> Vec<Argument
577580 address : SocketAddrV4 :: new ( Ipv4Addr :: UNSPECIFIED , 0 ) . into ( ) ,
578581 proto : Proto :: TCP ,
579582 } ,
583+ Argument :: P2POnly
580584 ] ;
581585
582586 let mut args: Vec < Argument > = Vec :: with_capacity ( 32 ) ;
0 commit comments