@@ -8400,6 +8400,31 @@ static bool netplay_should_skip(netplay_t *netplay)
84008400 netplay -> self_mode >= NETPLAY_CONNECTION_CONNECTED ;
84018401}
84028402
8403+ static size_t retrieve_client_count (netplay_t * netplay ,
8404+ unsigned * players , unsigned * spectators )
8405+ {
8406+ size_t i , r = 0 ;
8407+
8408+ for (i = 0 ; i < netplay -> connections_size ; i ++ )
8409+ {
8410+ struct netplay_connection * connection = & netplay -> connections [i ];
8411+
8412+ /* We only want info from already connected clients. */
8413+ if ( (connection -> flags & NETPLAY_CONN_FLAG_ACTIVE )
8414+ && (connection -> mode >= NETPLAY_CONNECTION_CONNECTED ))
8415+ {
8416+ r ++ ;
8417+ if (connection -> mode == NETPLAY_CONNECTION_SPECTATING )
8418+ (* spectators )++ ;
8419+ else if (connection -> mode == NETPLAY_CONNECTION_PLAYING
8420+ || connection -> mode == NETPLAY_CONNECTION_SLAVE )
8421+ (* players )++ ;
8422+ }
8423+ }
8424+
8425+ return r ;
8426+ }
8427+
84038428bool init_netplay_deferred (const char * server , unsigned port , const char * mitm_session )
84048429{
84058430 net_driver_state_t * net_st = & networking_driver_st ;
@@ -8600,6 +8625,8 @@ static void netplay_announce(netplay_t *netplay)
86008625 int mitm_custom_port = 0 ;
86018626 int is_mitm = 0 ;
86028627 uint32_t content_crc = 0 ;
8628+ unsigned players = 0 ;
8629+ unsigned spectators = 0 ;
86038630 net_driver_state_t * net_st = & networking_driver_st ;
86048631 struct netplay_room * host_room = & net_st -> host_room ;
86058632 struct retro_system_info * system = & runloop_state_get_ptr ()-> system .info ;
@@ -8678,6 +8705,15 @@ static void netplay_announce(netplay_t *netplay)
86788705 else
86798706 net_http_urlencode (& mitm_custom_addr , "" );
86808707
8708+ /* Purely informational, should not be used to guess if a host is full. */
8709+ retrieve_client_count (netplay , & players , & spectators );
8710+
8711+ if (netplay -> self_mode == NETPLAY_CONNECTION_SPECTATING )
8712+ spectators ++ ;
8713+ if (netplay -> self_mode == NETPLAY_CONNECTION_PLAYING
8714+ || netplay -> self_mode == NETPLAY_CONNECTION_SLAVE )
8715+ players ++ ;
8716+
86818717 /* Estimated to a maximum of 3062 bytes. */
86828718 snprintf (buf , sizeof (buf ),
86838719 "username=%s&"
@@ -8695,7 +8731,9 @@ static void netplay_announce(netplay_t *netplay)
86958731 "subsystem_name=%s&"
86968732 "mitm_session=%s&"
86978733 "mitm_custom_addr=%s&"
8698- "mitm_custom_port=%d" ,
8734+ "mitm_custom_port=%d&"
8735+ "player_count=%d&"
8736+ "spectator_count=%d" ,
86998737 username ,
87008738 corename ,
87018739 coreversion ,
@@ -8711,7 +8749,9 @@ static void netplay_announce(netplay_t *netplay)
87118749 subsystemname ,
87128750 mitm_session ,
87138751 mitm_custom_addr ,
8714- mitm_custom_port );
8752+ mitm_custom_port ,
8753+ players ,
8754+ spectators );
87158755
87168756 if (task_push_http_post_transfer (FILE_PATH_LOBBY_LIBRETRO_URL "add" , buf ,
87178757 true, NULL , netplay_announce_cb , NULL ))
0 commit comments