@@ -808,6 +808,8 @@ pub unsafe fn load_deferred_mods(device: DevicePointer, callbacks: interop::Mana
808808 let pre_rc = device. get_ref_count ( ) ;
809809
810810 let mut cnt = 0 ;
811+ let can_load_in_thread = ( * DEVICE_STATE ) . multithreaded ( ) ;
812+
811813 for nmd in to_load. iter ( ) {
812814 let mut nmod =
813815 get_mod_by_name ( & nmd, & mut GLOBAL_STATE . loaded_mods ) ;
@@ -822,6 +824,12 @@ pub unsafe fn load_deferred_mods(device: DevicePointer, callbacks: interop::Mana
822824 }
823825 if let ModD3DState :: Loaded ( _) = nmod. d3d_data {
824826 write_log_file ( & format ! ( "load_deferred_mods: mod already loaded: {}" , nmod. name) ) ;
827+ // this block gets hit when using the threaded d3d loader and is the only way we know that thread finished its work,
828+ // since it doesn't communicate anything back to this thread but rather just updates the d3d data on the mod.
829+ // As I now want to reset log limits after each mod loads (as done below for the non-threaded case),
830+ // use this opportunity to do that. (this _usually_ gets hit if the game is drawing fast enough, but it
831+ // may not _always_ get hit - in particular test.nativelaunch doesn't seem to always trigger this due to its lower draw rate)
832+ reset_log_counts ( ) ;
825833 continue ;
826834 }
827835 if !nmod. mod_data . data_available {
@@ -860,8 +868,6 @@ pub unsafe fn load_deferred_mods(device: DevicePointer, callbacks: interop::Mana
860868 }
861869 }
862870
863- let can_load_in_thread = ( * DEVICE_STATE ) . multithreaded ( ) ;
864-
865871 match device {
866872 DevicePointer :: D3D9 ( device) => {
867873 load_d3d_data9 ( device, callbacks, nmod. midx , nmod) ;
@@ -911,6 +917,7 @@ pub unsafe fn load_deferred_mods(device: DevicePointer, callbacks: interop::Mana
911917 // otherwise when loading a lot of mods and if there are errors,
912918 // some of the error messages get suppressed,
913919 // others don't, which causes me to get confused.
920+ // note in the threaded loading case we do this above, because in that case cnt will typically be zero here
914921 reset_log_counts ( ) ;
915922 }
916923 } ;
0 commit comments