3838#include "../content.h"
3939#include "../runloop.h"
4040
41+ #ifndef HAVE_DYNAMIC
42+ #include "../retroarch.h"
43+ #include "../frontend/frontend_driver.h"
44+ #endif
45+
4146#include "task_content.h"
4247#include "tasks_internal.h"
4348
@@ -445,6 +450,59 @@ static void task_netplay_crc_scan_handler(retro_task_t *task)
445450 task_set_finished (task , true);
446451}
447452
453+ #ifndef HAVE_DYNAMIC
454+ static void static_load (const char * core , const char * subsystem ,
455+ const void * content , const char * hostname )
456+ {
457+ char buf [512 ];
458+ char args [PATH_MAX_LENGTH ];
459+
460+ path_set (RARCH_PATH_CORE , core );
461+
462+ netplay_driver_ctl (RARCH_NETPLAY_CTL_CLEAR_FORK_ARGS , NULL );
463+
464+ if (string_is_empty (hostname ))
465+ {
466+ strlcpy (args , "-H" , sizeof (args ));
467+ }
468+ else
469+ {
470+ strlcpy (args , "-C " , sizeof (args ));
471+ strlcat (args , hostname , sizeof (args ));
472+ }
473+
474+ if (!string_is_empty (subsystem ))
475+ {
476+ snprintf (buf , sizeof (buf ), "\"%s\"" , subsystem );
477+ strlcat (args , " --subsystem " , sizeof (args ));
478+ strlcat (args , buf , sizeof (args ));
479+
480+ if (content )
481+ {
482+ size_t i ;
483+ const struct string_list * subsystem_content =
484+ (const struct string_list * )content ;
485+
486+ for (i = 0 ; i < subsystem_content -> size ; i ++ )
487+ {
488+ snprintf (buf , sizeof (buf ), " \"%s\"" ,
489+ subsystem_content -> elems [i ].data );
490+ strlcat (args , buf , sizeof (args ));
491+ }
492+ }
493+ }
494+ else if (content )
495+ {
496+ snprintf (buf , sizeof (buf ), " \"%s\"" , (const char * )content );
497+ strlcat (args , buf , sizeof (args ));
498+ }
499+
500+ netplay_driver_ctl (RARCH_NETPLAY_CTL_SET_FORK_ARGS , args );
501+ frontend_driver_set_fork (FRONTEND_FORK_CORE_WITH_ARGS );
502+ retroarch_ctl (RARCH_CTL_SET_SHUTDOWN , NULL );
503+ }
504+ #endif
505+
448506static void task_netplay_crc_scan_callback (retro_task_t * task ,
449507 void * task_data , void * user_data , const char * error )
450508{
@@ -457,14 +515,13 @@ static void task_netplay_crc_scan_callback(retro_task_t *task,
457515 {
458516 case STATE_LOAD :
459517 {
460- content_ctx_info_t content_info = {0 };
461518 const char * content_path = (state -> state & STATE_RELOAD ) ?
462519 data -> current .content_path : data -> content_paths .elems [0 ].data ;
463-
464520#ifdef HAVE_DYNAMIC
521+ content_ctx_info_t content_info = {0 };
522+
465523 if (data -> current .core_loaded )
466524 command_event (CMD_EVENT_UNLOAD_CORE , NULL );
467- #endif
468525
469526 RARCH_LOG ("[Lobby] Loading core '%s' with content file '%s'.\n" ,
470527 data -> core , content_path );
@@ -486,6 +543,10 @@ static void task_netplay_crc_scan_callback(retro_task_t *task,
486543 NULL , NULL , CORE_TYPE_PLAIN , NULL , NULL );
487544 task_push_load_content_with_core (content_path ,
488545 & content_info , CORE_TYPE_PLAIN , NULL , NULL );
546+ #else
547+
548+ static_load (data -> core , NULL , content_path , data -> hostname );
549+ #endif
489550 }
490551 break ;
491552
@@ -494,11 +555,6 @@ static void task_netplay_crc_scan_callback(retro_task_t *task,
494555 const char * subsystem ;
495556 struct string_list * subsystem_content ;
496557
497- #ifdef HAVE_DYNAMIC
498- if (data -> current .core_loaded )
499- command_event (CMD_EVENT_UNLOAD_CORE , NULL );
500- #endif
501-
502558 if (state -> state & STATE_RELOAD )
503559 {
504560 subsystem = data -> current .subsystem ;
@@ -510,6 +566,10 @@ static void task_netplay_crc_scan_callback(retro_task_t *task,
510566 subsystem_content = & data -> content_paths ;
511567 }
512568
569+ #ifdef HAVE_DYNAMIC
570+ if (data -> current .core_loaded )
571+ command_event (CMD_EVENT_UNLOAD_CORE , NULL );
572+
513573 RARCH_LOG ("[Lobby] Loading core '%s' with subsystem '%s'.\n" ,
514574 data -> core , subsystem );
515575
@@ -547,21 +607,22 @@ static void task_netplay_crc_scan_callback(retro_task_t *task,
547607 /* Disable netplay if we don't have the subsystem. */
548608 netplay_driver_ctl (RARCH_NETPLAY_CTL_DISABLE , NULL );
549609
550- #ifdef HAVE_DYNAMIC
551610 command_event (CMD_EVENT_UNLOAD_CORE , NULL );
552- #endif
553611 }
612+ #else
613+ static_load (data -> core , subsystem , subsystem_content ,
614+ data -> hostname );
615+ #endif
554616 }
555617 break ;
556618
557619 case STATE_LOAD_CONTENTLESS :
558620 {
621+ #ifdef HAVE_DYNAMIC
559622 content_ctx_info_t content_info = {0 };
560623
561- #ifdef HAVE_DYNAMIC
562624 if (data -> current .core_loaded )
563625 command_event (CMD_EVENT_UNLOAD_CORE , NULL );
564- #endif
565626
566627 RARCH_LOG ("[Lobby] Loading contentless core '%s'.\n" , data -> core );
567628
@@ -581,6 +642,9 @@ static void task_netplay_crc_scan_callback(retro_task_t *task,
581642 task_push_load_new_core (data -> core ,
582643 NULL , NULL , CORE_TYPE_PLAIN , NULL , NULL );
583644 task_push_start_current_core (& content_info );
645+ #else
646+ static_load (data -> core , NULL , NULL , data -> hostname );
647+ #endif
584648 }
585649 break ;
586650
@@ -590,7 +654,6 @@ static void task_netplay_crc_scan_callback(retro_task_t *task,
590654 {
591655#ifdef HAVE_DYNAMIC
592656 command_event (CMD_EVENT_UNLOAD_CORE , NULL );
593- #endif
594657
595658 command_event (CMD_EVENT_NETPLAY_DEINIT , NULL );
596659
@@ -613,6 +676,10 @@ static void task_netplay_crc_scan_callback(retro_task_t *task,
613676 content_clear_subsystem ();
614677 content_set_subsystem_by_name (data -> current .subsystem );
615678 }
679+ #else
680+ static_load (data -> core , data -> current .subsystem , NULL ,
681+ data -> hostname );
682+ #endif
616683
617684 runloop_msg_queue_push (
618685 msg_hash_to_str (MENU_ENUM_LABEL_VALUE_NETPLAY_START_WHEN_LOADED ),
0 commit comments