@@ -80,7 +80,7 @@ methodmap CNetChan
8080public Plugin myinfo =
8181{
8282 name = " File Network" ,
83- author = " Batfoxkid" ,
83+ author = " Batfoxkid, Artvin " ,
8484 description = " But what if, no loading screen" ,
8585 version = PLUGIN_VERSION ,
8686 url = " github.com/Batfoxkid/File-Network"
@@ -211,6 +211,8 @@ public void OnPluginStart()
211211 failed = true ;
212212 }
213213
214+ //THIS ONLY WORKS ON WINDOWS!!!!!!
215+ //linux uses a different solution, timeout logic.
214216 detour = DynamicDetour .FromConf (gamedata , " CGameClient::FileDenied" );
215217 if (detour )
216218 {
@@ -357,33 +359,6 @@ public MRESReturn OnFileReceived(Address address, DHookParam param)
357359 return MRES_Ignored ;
358360}
359361
360- public MRESReturn OnFileDenied (Address address , DHookParam param )
361- {
362- int id = param .Get (2 );
363- CNetChan chan = SDKCall (SDKGetNetChannel , address );
364-
365- int length = RequestListing .Length ;
366- for (int i ; i < length ; i ++ )
367- {
368- static FileEnum info ;
369- RequestListing .GetArray (i , info );
370- if (info .Id == id && chan == CNetChan (info .Client ))
371- {
372- if (CurrentlyRequesting [info .Client ] == id )
373- CurrentlyRequesting [info .Client ] = - 1 ;
374-
375- RequestListing .Erase (i );
376- CallRequestFileFinish (info , false );
377-
378- if (RequestingTimer [info .Client ])
379- TriggerTimer (RequestingTimer [info .Client ]);
380-
381- break ;
382- }
383- }
384- return MRES_Ignored ;
385- }
386-
387362void StartRequestingClient (int client )
388363{
389364 if (! RequestingTimer [client ])
@@ -433,6 +408,13 @@ public Action Timer_RequestingClient(Handle timer, int client)
433408
434409 CurrentlyRequesting [client ] = info .Id ;
435410 StartedRequestingAt [client ] = GetTime ();
411+ float CurrentClientPing = GetClientAvgLatency (client , NetFlow_Outgoing );
412+ CurrentClientPing *= 2.0 ; //beacuse it has to go bothways.
413+ CurrentClientPing += 0.2 ; //Little buffer for ping issues and differences
414+ Handle pack ;
415+ CreateDataTimer (CurrentClientPing , Timer_DeniedFileCheck , pack );
416+ WritePackCell (pack , client ); //Client
417+ WritePackCell (pack , info .Id ); //The id that we ask for
436418 return Plugin_Continue ;
437419 }
438420 }
@@ -442,6 +424,46 @@ public Action Timer_RequestingClient(Handle timer, int client)
442424 return Plugin_Stop ;
443425}
444426
427+ public Action Timer_DeniedFileCheck (Handle timer , DataPack pack )
428+ {
429+ pack .Reset ();
430+ int client = pack .ReadCell ();
431+ int id = pack .ReadCell ();
432+ //We can presume the client didnt recieve the file if recieving didnt work out.
433+ OnFileDeniedInternal (CNetChan (client ), id );
434+ return Plugin_Stop ;
435+ }
436+
437+ public MRESReturn OnFileDenied (Address address , DHookParam param )
438+ {
439+ int id = param .Get (2 );
440+ CNetChan chan = SDKCall (SDKGetNetChannel , address );
441+ OnFileDeniedInternal (chan , id );
442+ return MRES_Ignored ;
443+ }
444+
445+ void OnFileDeniedInternal (CNetChan chan , int id )
446+ {
447+ int length = RequestListing .Length ;
448+ for (int i ; i < length ; i ++ )
449+ {
450+ static FileEnum info ;
451+ RequestListing .GetArray (i , info );
452+ if (info .Id == id && chan == CNetChan (info .Client ))
453+ {
454+ if (CurrentlyRequesting [info .Client ] == id )
455+ CurrentlyRequesting [info .Client ] = - 1 ;
456+
457+ RequestListing .Erase (i );
458+ CallRequestFileFinish (info , false );
459+
460+ if (RequestingTimer [info .Client ])
461+ TriggerTimer (RequestingTimer [info .Client ]);
462+
463+ break ;
464+ }
465+ }
466+ }
445467static void CallRequestFileFinish (const FileEnum info , bool success )
446468{
447469 if (info .Func && info .Func != INVALID_FUNCTION )
0 commit comments