AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Extensions (https://forums.alliedmods.net/forumdisplay.php?f=134)
-   -   [EXTENSION] Late Downloads (https://forums.alliedmods.net/showthread.php?t=305153)

Backup 02-16-2018 15:05

Re: [EXTENSION] Late Downloads
 
Quote:

Originally Posted by GHartmann (Post 2578447)
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

GHartmann 02-24-2018 16:28

Re: [EXTENSION] Late Downloads
 
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


Leonardo 02-25-2018 04:18

Re: [EXTENSION] Late Downloads
 
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.

Backup 02-25-2018 09:31

Re: [EXTENSION] Late Downloads
 
1 Attachment(s)
Quote:

Originally Posted by GHartmann (Post 2579959)
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 (Post 2580025)
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. :)

GHartmann 02-25-2018 12:23

Re: [EXTENSION] Late Downloads
 
Quote:

Originally Posted by Backup (Post 2580083)
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.

Backup 02-25-2018 17:14

Re: [EXTENSION] Late Downloads
 
Quote:

Originally Posted by GHartmann (Post 2580112)
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.

lugui 02-28-2018 13:31

Re: [EXTENSION] Late Downloads
 
Is there a way to use a third-party service just like a fastdl server? Or it is restricted to the game server upload?

Backup 02-28-2018 16:06

Re: [EXTENSION] Late Downloads
 
Quote:

Originally Posted by lugui (Post 2580659)
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 :D

DJPlaya 03-01-2018 06:02

Re: [EXTENSION] Late Downloads
 
This seems to be pretty much the same as >this< with more setting possibilities?

lugui 03-01-2018 06:40

Re: [EXTENSION] Late Downloads
 
Maybe there is a way to redirect the traffic.

Quote:

Originally Posted by DJPlaya (Post 2580785)
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


All times are GMT -4. The time now is 01:05.

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