PDA

View Full Version : IWD check in download



Mitch
14th February 2014, 14:53
Valid iwd: test/gob_aim.iwd
clientDownload: 0 : begining "test/gob_aim.iwd"
clientDownload: 0 : file "test/gob_aim.iwd" completed
Not a valid iwd: test/server.cfg




void SV_BeginDownload_f( int a1 ) {
char * file = Cmd_Argv(1);
int len;

if((len = strlen(file)) > 3 && !strcmp(file + len - 4, ".iwd"))
{
printf("Valid iwd: %s\n", file);
typedef int (*SV_BeginDownload_f_t)(int a1);
SV_BeginDownload_f_t SV_BeginDownload_f = (SV_BeginDownload_f_t)0x0808E508;
SV_BeginDownload_f(a1);
}
else
printf("Not a valid iwd: %s\n", file);
}

#if COD_VERSION == COD2_1_0
int * addressToDownloadPointer = (int *)0x0815D584;
*addressToDownloadPointer = (int)SV_BeginDownload_f;
#endif




typedef char * (*Cmd_Argv_t)(int arg);
#if COD_VERSION == COD2_1_0
static Cmd_Argv_t Cmd_Argv = (Cmd_Argv_t)0x0806001C;
#elif COD_VERSION == COD2_1_2
static Cmd_Argv_t Cmd_Argv = (Cmd_Argv_t)0x08060228;
#elif COD_VERSION == COD2_1_3
static Cmd_Argv_t Cmd_Argv = (Cmd_Argv_t)0x08060220;
#else
#warning static Cmd_Argv_t Cmd_Argv = (Cmd_Argv_t)NULL;
static Cmd_Argv_t Cmd_Argv = (Cmd_Argv_t)NULL;
#endif

https://github.com/M-itch/libcod/commit/46f9a0cf71f48be20051f94eaf9ef0a8cb70d2c1
http://znation.nl/libcod

Ni3ls
14th February 2014, 15:03
Can you explain it a little bit?

RobsoN
14th February 2014, 15:40
Can you explain it a little bit?

I think it works like subStr - script gets only 4 last file name chars. If this doesnt equal ".iwd" that means client tried to download non-iwd file.

IzNoGoD
14th February 2014, 15:59
Can you add a check for issubstr("_svr_") or issubstr("svr")?

Mitch
14th February 2014, 16:14
Can you explain it a little bit?

the address 0x0815D584 points to SV_BeginDownload_f that you call when you type /download.
I set it to my own function and inside this function i check if it is a valid iwd. When the iwd is valid then it calls the original function.

file + len - 4 gets the pointer to '.' in the file text. So you basically skip the first x chars.


Can you add a check for issubstr("_svr_") or issubstr("svr")?



char * pch = strstr (s, "_svr_");
if(pch != NULL) // found _svr_

Mitch
18th September 2014, 21:21
I added a iwd / ff check to cod4 now too. I had some trouble with the query limiter version. (some differences with functions addresses)


Invalid download attempt: main/server.cfg
clientDownload: 0 : beginning "fail.iwd"
clientDownload: 0 : "fail.iwd" file not found on server

https://github.com/M-itch/libcod/commit/cfe654ff0f7eb949c7c3233365e81b96dbf6e2a5

Edit: i still should do some testing to check if it works correctly

raphael
5th July 2023, 22:03
If printf("Not a valid iwd: %s\n", file) gets triggered, then the client gets stuck starting the download of this file and the next ones don't start right?

Could someone suggest a way for the process to go try the next files when this happens please.

Mitch
16th July 2023, 11:11
If printf("Not a valid iwd: %s\n", file) gets triggered, then the client gets stuck starting the download of this file and the next ones don't start right?

Could someone suggest a way for the process to go try the next files when this happens please.

No, because you are not supposed to download any non iwd files.

And the current libcod uses voron's custom_SV_WriteDownloadToClient function (https://github.com/M-itch/libcod/blob/master/libcod.cpp#L403)

raphael
16th July 2023, 11:57
I meant I want to make some clients to ignore some iwd files, but to download the rest and be able to join the server anyway.

I think I should take control of SV_SendClientGameState to achieve this...

i'm doing this on cod1, actually codextended public repo doesn't take control of this function, i tried a bit to do it without success for the moment

Thanks for having replied Mitch

Mitch
16th July 2023, 13:20
See the manymaps thread