Raised This Month: $12 Target: $400
 3% 

[EXTENSION] Late Downloads


Post New Thread Reply   
 
Thread Tools Display Modes
Backup
Senior Member
Join Date: Jul 2010
Location: Česká Republika
Old 02-16-2018 , 15:05   Re: [EXTENSION] Late Downloads
Reply With Quote #11

Quote:
Originally Posted by GHartmann View Post
Change for latest version to build against TF2:
Code:
257,259c257
<       for ( int i = 0; i < g_BatchDeadlines.Count(); i++ ) {
<               g_BatchDeadlines[i] = 0;
<       }
---
>       g_BatchDeadlines.FillWithValue(0);
...
I've replaced it using the definition for SetCount:
https://github.com/jonatan1024/lated...1596de03d0f808
__________________
Sorry for my english.
Backup is offline
GHartmann
Junior Member
Join Date: Feb 2018
Old 02-24-2018 , 16:28   Re: [EXTENSION] Late Downloads
Reply With Quote #12

I've discovered some sort of memory(?) bug, but I'm not proficient enough with C++ to figure out the cause.

Apologies in advance if there's actually just something wrong on my end I'm not seeing.

The test code:
Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <tf2_stocks>
#include <latedl>

public Plugin myinfo =
{
	name = "Late Downloads Test",
	author = "Hartmann",
	description = "Late downloads testing",
	version = "1.3.2",
	url = "http://www.sourcemod.net/"
};

public void OnPluginStart()
{
	RegAdminCmd("testdl", Command_TestDL, ADMFLAG_SLAY);
	RegAdminCmd("testdl2", Command_TestDL2, ADMFLAG_SLAY);
	RegAdminCmd("testdl2b", Command_TestDL2b, ADMFLAG_SLAY);
	RegAdminCmd("testdl3", Command_TestDL3, ADMFLAG_SLAY);
	RegAdminCmd("testdl4", Command_TestDL4, ADMFLAG_SLAY);
}

public void OnDownloadSuccess(int iClient, char[] filename) {
	PrintToServer("%N downloaded file %s", iClient, filename);
}

public Action Command_TestDL(int client, int args)
{
	if (args > 0)
	{
		char full[128];
		char arg[128];
		
		GetCmdArgString(full, sizeof(full));
		GetCmdArg(1, arg, sizeof(arg));
		
		AddLateDownload(arg, false);
	}

	return Plugin_Handled;
}

public Action Command_TestDL2(int client, int args)
{
	char files[8][128];
	
	files[0] = "test/random_128K_00.bin";
	files[1] = "test/random_128K_01.bin";
	files[2] = "test/random_128K_02.bin";
	files[3] = "test/random_128K_03.bin";
	files[4] = "test/random_128K_04.bin";
	files[5] = "test/random_128K_05.bin";
	files[6] = "test/random_128K_06.bin";
	files[7] = "test/random_128K_07.bin";
	
	AddLateDownloads(files, 8, false);
	
	return Plugin_Handled;
}

public Action Command_TestDL2b(int client, int args)
{
	char files[8][24];
	
	files[0] = "test/random_128K_00.bin";
	files[1] = "test/random_128K_01.bin";
	files[2] = "test/random_128K_02.bin";
	files[3] = "test/random_128K_03.bin";
	files[4] = "test/random_128K_04.bin";
	files[5] = "test/random_128K_05.bin";
	files[6] = "test/random_128K_06.bin";
	files[7] = "test/random_128K_07.bin";
	
	AddLateDownloads(files, 8, false);
	
	return Plugin_Handled;
}

public Action Command_TestDL3(int client, int args)
{
	AddLateDownload("test/random_128K_00.bin", false);
	AddLateDownload("test/random_128K_01.bin", false);
	AddLateDownload("test/random_128K_02.bin", false);
	AddLateDownload("test/random_128K_03.bin", false);
	AddLateDownload("test/random_128K_04.bin", false);
	AddLateDownload("test/random_128K_05.bin", false);
	AddLateDownload("test/random_128K_06.bin", false);
	AddLateDownload("test/random_128K_07.bin", false);

	return Plugin_Handled;
}

public Action Command_TestDL4(int client, int args)
{
	char[] file00 = "test/random_128K_00.bin";
	char[] file01 = "test/random_128K_01.bin";
	char[] file02 = "test/random_128K_02.bin";
	char[] file03 = "test/random_128K_03.bin";
	char[] file04 = "test/random_128K_04.bin";
	char[] file05 = "test/random_128K_05.bin";
	char[] file06 = "test/random_128K_06.bin";
	char[] file07 = "test/random_128K_07.bin";
	
	AddLateDownload(file00, false);
	AddLateDownload(file01, false);
	AddLateDownload(file02, false);
	AddLateDownload(file03, false);
	AddLateDownload(file04, false);
	AddLateDownload(file05, false);
	AddLateDownload(file06, false);
	AddLateDownload(file07, false);
	
	return Plugin_Handled;
}
Running testdl fails to call the forward with the correct data. The files are all uploaded to the client, but the success forward isn't called until the last file is uploaded, and with the incorrect file name.
Code:
testdl test/random_128K_00.bin
testdl test/random_128K_01.bin
testdl test/random_128K_02.bin
testdl test/random_128K_03.bin
testdl test/random_128K_04.bin
testdl test/random_128K_05.bin
testdl test/random_128K_06.bin
testdl test/random_128K_07.bin
Gestalt💙Hartmann downloaded file test/random_128K_07.bin
Console downloaded file test/random_128K_07.bin
Gestalt💙Hartmann downloaded file test/random_128K_07.bin
Console downloaded file test/random_128K_07.bin
Gestalt💙Hartmann downloaded file test/random_128K_07.bin
Console downloaded file test/random_128K_07.bin
Gestalt💙Hartmann downloaded file test/random_128K_07.bin
Console downloaded file test/random_128K_07.bin
Gestalt💙Hartmann downloaded file test/random_128K_07.bin
Console downloaded file test/random_128K_07.bin
Gestalt💙Hartmann downloaded file test/random_128K_07.bin
Console downloaded file test/random_128K_07.bin
Gestalt💙Hartmann downloaded file test/random_128K_07.bin
Console downloaded file test/random_128K_07.bin
Gestalt💙Hartmann downloaded file test/random_128K_07.bin
Console downloaded file test/random_128K_07.bin
Running testdl2 and testdl3 works as expected:
Code:
testdl2
Gestalt💙Hartmann downloaded file test/random_128K_00.bin
Console downloaded file test/random_128K_00.bin
Gestalt💙Hartmann downloaded file test/random_128K_01.bin
Console downloaded file test/random_128K_01.bin
Gestalt💙Hartmann downloaded file test/random_128K_02.bin
Console downloaded file test/random_128K_02.bin
Gestalt💙Hartmann downloaded file test/random_128K_03.bin
Console downloaded file test/random_128K_03.bin
Gestalt💙Hartmann downloaded file test/random_128K_04.bin
Console downloaded file test/random_128K_04.bin
Gestalt💙Hartmann downloaded file test/random_128K_05.bin
Console downloaded file test/random_128K_05.bin
Gestalt💙Hartmann downloaded file test/random_128K_06.bin
Console downloaded file test/random_128K_06.bin
Gestalt💙Hartmann downloaded file test/random_128K_07.bin
Console downloaded file test/random_128K_07.bin
Code:
testdl3
Gestalt💙Hartmann downloaded file test/random_128K_00.bin
Console downloaded file test/random_128K_00.bin
Gestalt💙Hartmann downloaded file test/random_128K_01.bin
Console downloaded file test/random_128K_01.bin
Gestalt💙Hartmann downloaded file test/random_128K_02.bin
Console downloaded file test/random_128K_02.bin
Gestalt💙Hartmann downloaded file test/random_128K_03.bin
Console downloaded file test/random_128K_03.bin
Gestalt💙Hartmann downloaded file test/random_128K_04.bin
Console downloaded file test/random_128K_04.bin
Gestalt💙Hartmann downloaded file test/random_128K_05.bin
Console downloaded file test/random_128K_05.bin
Gestalt💙Hartmann downloaded file test/random_128K_06.bin
Console downloaded file test/random_128K_06.bin
Gestalt💙Hartmann downloaded file test/random_128K_07.bin
Console downloaded file test/random_128K_07.bin
testdl2b works-ish. It reports a failure for "test/ran", and drops off the last file due to it.
Code:
testdl2b
Gestalt💙Hartmann downloaded file test/random_128K_00.bin
Console downloaded file test/random_128K_00.bin
L 02/24/2018 - 16:22:44: [LATEDL] Failed to track progress of sending file 'test/ran' to client 1 ('192.168.1.20:27005', 192.168.1.20:27005)!
L 02/24/2018 - 16:22:44: [LATEDL] Client 1 failed to download file 'test/ran'!
Console downloaded file test/ran
Gestalt💙Hartmann downloaded file test/random_128K_01.bin
Console downloaded file test/random_128K_01.bin
Gestalt💙Hartmann downloaded file test/random_128K_02.bin
Console downloaded file test/random_128K_02.bin
Gestalt💙Hartmann downloaded file test/random_128K_03.bin
Console downloaded file test/random_128K_03.bin
Gestalt💙Hartmann downloaded file test/random_128K_04.bin
Console downloaded file test/random_128K_04.bin
Gestalt💙Hartmann downloaded file test/random_128K_05.bin
Console downloaded file test/random_128K_05.bin
Gestalt💙Hartmann downloaded file test/random_128K_06.bin
Console downloaded file test/random_128K_06.bin
Running testdl4 fails like this:
Code:
testdl4
Gestalt💙Hartmann downloaded file
Console downloaded file
Gestalt💙Hartmann downloaded file test/random_128K_00.bin
Console downloaded file test/random_128K_00.bin
L 02/24/2018 - 16:11:44: [LATEDL] Failed to track progress of sending file 'bin' to client 1 ('192.168.1.20:27005', 192.168.1.20:27005)!
L 02/24/2018 - 16:11:44: [LATEDL] Client 1 failed to download file 'bin'!
Console downloaded file bin
Gestalt💙Hartmann downloaded file test/random_128K_00.bin
Console downloaded file test/random_128K_00.bin
Gestalt💙Hartmann downloaded file test/random_128K_00.bin
Console downloaded file test/random_128K_00.bin
Gestalt💙Hartmann downloaded file test/random_128K_00.bin
Console downloaded file test/random_128K_00.bin
Gestalt💙Hartmann downloaded file test/random_128K_00.bin
Console downloaded file test/random_128K_00.bin
Gestalt💙Hartmann downloaded file test/random_128K_00.bin
Console downloaded file test/random_128K_00.bin
GHartmann is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 02-25-2018 , 04:18   Re: [EXTENSION] Late Downloads
Reply With Quote #13

Compiled with MSVC v14.0 against sdk2013 on windows x64, AddLateDownloads with addAsStatic=true always returns 0. This happens when filled addedFiles is passed to SendFiles function via pointer.
Before sending to SendFiles, FOR_EACH_VEC says it's filled, but within SendFiles FOR_EACH_VEC says it's empty.
__________________
Leonardo is offline
Backup
Senior Member
Join Date: Jul 2010
Location: Česká Republika
Old 02-25-2018 , 09:31   Re: [EXTENSION] Late Downloads
Reply With Quote #14

Quote:
Originally Posted by GHartmann View Post
I've discovered some sort of memory(?) bug, but I'm not proficient enough with C++ to figure out the cause.

Apologies in advance if there's actually just something wrong on my end I'm not seeing.

...
Thanks for the error reports! All problems were on my side, except for the testdl4.
testdl & testdl2b problems were indeed caused by bad memory handling, storing pointers to plugin's stack. I've fixed these in the new release, you can try it out.
testdl4 is a bug in sourcepawn itself, you can try it out just by replacing AddLateDownload by PrintToServer. It is some kind of compiler issue, probably solved by now:
https://github.com/alliedmodders/sou...014969e47f9396
You can work around this issue by moving the brackets behind the variable name. If you look at the attached image, you can clearly see the problem.

Quote:
Originally Posted by Leonardo View Post
Compiled with MSVC v14.0 against sdk2013 on windows x64, AddLateDownloads with addAsStatic=true always returns 0. This happens when filled addedFiles is passed to SendFiles function via pointer.
Before sending to SendFiles, FOR_EACH_VEC says it's filled, but within SendFiles FOR_EACH_VEC says it's empty.
Oops, fixed, try it now please.
Attached Thumbnails
Click image for larger version

Name:	compiler-bug.PNG
Views:	311
Size:	55.2 KB
ID:	168666  
__________________
Sorry for my english.
Backup is offline
GHartmann
Junior Member
Join Date: Feb 2018
Old 02-25-2018 , 12:23   Re: [EXTENSION] Late Downloads
Reply With Quote #15

Quote:
Originally Posted by Backup View Post
You can work around this issue by moving the brackets behind the variable name. If you look at the attached image, you can clearly see the problem.
I was trying to figure out what the problem could be for the longest time, I assumed my code was bugged somehow. Ah well, thanks for the fix!

Another bug:
latedl_minimalbandwidth kicks clients if called within OnClientAuthorized and perhaps other connection stages, I guess since they aren't yet accepting the download.

I modified the extension to add a function to send only to specified clients. Maybe this is a feature that could be added?

The short use case is to cache which players have already downloaded a file to avoid resending.

The longer version is:
The plugin associates a list of files with a server, map, and player, adds those files to a download list for each connected client and has them download it. In order to do this properly, it needs to send files only to specific clients so it can avoid resending to any clients that already have those files.

So for example, a server has:
materials/foo/magic.vtf
sound/foo/neat.wav

The map cp_process_final has:
materials/foo/processthing.vtf

A player has:
materials/foo/superspray.vtf

Another player has:
materials/foo/cooliospray.vtf

It adds all those files to a list and sends them out to all clients that don't already have them. The list changes based on the current map and players in the server.
GHartmann is offline
Backup
Senior Member
Join Date: Jul 2010
Location: Česká Republika
Old 02-25-2018 , 17:14   Re: [EXTENSION] Late Downloads
Reply With Quote #16

Quote:
Originally Posted by GHartmann View Post
Another bug:
latedl_minimalbandwidth kicks clients if called within OnClientAuthorized and perhaps other connection stages, I guess since they aren't yet accepting the download.

I modified the extension to add a function to send only to specified clients. Maybe this is a feature that could be added?
I've modified the code that the connecting clients have additional time. I think that they accept the download, but it is queued and the client is busy exchanging different data. If that is not the case and the client simply drops the download, I'll have to come with a different solution. Please report if you'll find it not working correctly.

I've added another parameter, specifing the target client, zero index means all player as usual.
__________________
Sorry for my english.
Backup is offline
lugui
Senior Member
Join Date: Feb 2016
Location: GetClientAbsOrigin();
Old 02-28-2018 , 13:31   Re: [EXTENSION] Late Downloads
Reply With Quote #17

Is there a way to use a third-party service just like a fastdl server? Or it is restricted to the game server upload?

Last edited by lugui; 02-28-2018 at 13:31.
lugui is offline
Backup
Senior Member
Join Date: Jul 2010
Location: Česká Republika
Old 02-28-2018 , 16:06   Re: [EXTENSION] Late Downloads
Reply With Quote #18

Quote:
Originally Posted by lugui View Post
Is there a way to use a third-party service just like a fastdl server? Or it is restricted to the game server upload?
Nope, it needs to be transfared by the game server directly. The fastdl server can be used only when connecting.

If you're a hardcore hacker, you might find a way how to downgrade client state to force re-download of resources via fastdl; and then upgrade the state back so the client won't get disconnected. If you're able to do the second part, please PM me
__________________
Sorry for my english.
Backup is offline
DJPlaya
Senior Member
Join Date: Nov 2014
Location: Germany
Old 03-01-2018 , 06:02   Re: [EXTENSION] Late Downloads
Reply With Quote #19

This seems to be pretty much the same as >this< with more setting possibilities?
__________________
My biggest Projects: Kigen AC Redux, Forlix Floodcheck Redux

Last edited by DJPlaya; 03-01-2018 at 06:15.
DJPlaya is offline
Send a message via Skype™ to DJPlaya
lugui
Senior Member
Join Date: Feb 2016
Location: GetClientAbsOrigin();
Old 03-01-2018 , 06:40   Re: [EXTENSION] Late Downloads
Reply With Quote #20

Maybe there is a way to redirect the traffic.

Quote:
Originally Posted by DJPlaya View Post
This seems to be pretty much the same as >this< with more setting possibilities?
Is it possible to add the ability to request files from client with this extension? Sinse it is more "polished" than the functions dordnung found.
Also, can it manage the downloads of a single player??

What are the restrictions for the directorye swhere the extension can save files on client and download from (if possible)?

only from /cuntom/* ?

My idea is if it is possible to download demo files from client or even screenshots, to implement some kind of anticheat plugin

Last edited by lugui; 03-01-2018 at 07:10.
lugui is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:31.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode