Results 1 to 10 of 10

Thread: IWD check in download

  1. #1
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 451 Times in 305 Posts

    IWD check in download

    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
    PHP Code:
    void SV_BeginDownload_fint a1 ) {
        
    char file Cmd_Argv(1);
        
    int len;

        if((
    len strlen(file)) > && !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 
    PHP Code:
    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/com...9ef0a8cb70d2c1
    http://znation.nl/libcod
    Last edited by Mitch; 14th February 2014 at 13:56.

  2. The Following 2 Users Say Thank You to Mitch For This Useful Post:

    kung foo man (14th February 2014),RobsoN (14th February 2014)

  3. #2
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    Can you explain it a little bit?

  4. #3
    Private First Class RobsoN's Avatar
    Join Date
    Jan 2013
    Location
    /home/cod2/
    Posts
    230
    Thanks
    119
    Thanked 95 Times in 64 Posts
    Quote Originally Posted by Ni3ls View Post
    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.
    "Don't worry if your code doesn't work correctly - if everything worked, you would not work" ~Mosher's right

  5. The Following User Says Thank You to RobsoN For This Useful Post:

    Ni3ls (14th February 2014)

  6. #4
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,725
    Thanks
    17
    Thanked 1,080 Times in 682 Posts
    Can you add a check for issubstr("_svr_") or issubstr("svr")?
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  7. #5
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 451 Times in 305 Posts
    Quote Originally Posted by Ni3ls View Post
    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.

    Quote Originally Posted by IzNoGoD View Post
    Can you add a check for issubstr("_svr_") or issubstr("svr")?
    PHP Code:
    char pch strstr (s"_svr_");
    if(
    pch != NULL// found _svr_ 

  8. The Following User Says Thank You to Mitch For This Useful Post:

    Ni3ls (14th February 2014)

  9. #6
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 451 Times in 305 Posts
    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/com...e81b96dbf6e2a5

    Edit: i still should do some testing to check if it works correctly
    Last edited by Mitch; 18th September 2014 at 20:25.

  10. The Following User Says Thank You to Mitch For This Useful Post:

    kung foo man (19th September 2014)

  11. #7
    Deleter/Deleted
    Join Date
    Jan 2023
    Posts
    76
    Thanks
    40
    Thanked 9 Times in 9 Posts
    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.

  12. #8
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 451 Times in 305 Posts
    Quote Originally Posted by raphael View Post
    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/blo...ibcod.cpp#L403)

  13. #9
    Deleter/Deleted
    Join Date
    Jan 2023
    Posts
    76
    Thanks
    40
    Thanked 9 Times in 9 Posts
    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

  14. #10
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 451 Times in 305 Posts
    See the manymaps thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •