View Single Post
Kushfield
Member
Join Date: Jan 2017
Location: Estonia
Old 06-21-2018 , 11:12   Re: WRBot Segmentation fault (Server crash on map load)
Reply With Quote #2

It seems like the module used for extracting .RAR archives only supports some types of them. When it fails to extract, the failure never gets passed to the plugin which continues trying to handle the newly extracted files (that don't exist).

To prevent this from happening, you'd need to add a check to make sure the files actually exist after extraction.

Changing this:
PHP Code:
public bool:is_valid_demo_filefile )
{
    
fseekfile0SEEK_END );
    new 
header_size ftellfile );


    if ( 
header_size 544 )
    {
        return(
false);
    }

    
fseekfile0SEEK_SET );
    new 
signature[6];

    
fread_blocksfilesignaturesizeof(signature), BLOCK_CHAR );

    if ( !
contain"HLDEMO"signature ) )
    {
        return(
false);
    }

    return(
true);

... to this:
PHP Code:
public bool:is_valid_demo_filefile )
{
    if ( !
file )
    {
        return(
false);
    }
    
    
fseekfile0SEEK_END );
    new 
header_size ftellfile );


    if ( 
header_size 544 )
    {
        return(
false);
    }

    
fseekfile0SEEK_SET );
    new 
signature[6];

    
fread_blocksfilesignaturesizeof(signature), BLOCK_CHAR );

    if ( !
contain"HLDEMO"signature ) )
    {
        return(
false);
    }

    return(
true);

should do the job.

If your goal is to make the bot work for all maps though, I'm afraid it's much more complicated than that, since AFAIK there are no other modules for extracting archives, so you'd need to develop one that works for all RAR types yourself. Either that, or repackage all the bad demos into the default RAR format.

Last edited by Kushfield; 06-21-2018 at 12:17.
Kushfield is offline