1

Topic: [HELP] Verify map files?!

Hi!

I implemented a map-uploader in my Java-tool. The user can choose a map file and upload it.
Is there any way to verify map files, so real teeworlds maps get uploaded only?!

They all start with 44 41 54 41 @ Address 00000000 (44 41 54 41 = "DATA") but I don't think that this is enough to recognize a file as a teeworlds map file,...

Can someone help me?

2

Re: [HELP] Verify map files?!

Yes, I want to know it too.
BTW: You are having nice page, mccae, it works!

Goodbye all. Account inactive since March 2011.

3

Re: [HELP] Verify map files?!

khubajsn wrote:

BTW: You are having nice page, mccae, it works!

tongue

This is the standard page after installing apache.

I just bought the domain, and it's linked to the wrong webspace big_smile

4 (edited by lxde 2009-07-08 18:11:51)

Re: [HELP] Verify map files?!

Can you also program C++?
If yes, then have a look into the teeworlds source code and  there file "src/engine/e_datafile.c".
Especially look at the function "datafile_load()", line  92 - 99:

    /* TODO: change this header */
    io_read(file, &header, sizeof(header));
    if(header.id[0] != 'A' || header.id[1] != 'T' || header.id[2] != 'A' || header.id[3] != 'D')
    {
        if(header.id[0] != 'D' || header.id[1] != 'A' || header.id[2] != 'T' || header.id[3] != 'A')
        {
            dbg_msg("datafile", "wrong signature. %x %x %x %x"
                 ,header.id[0], header.id[1], header.id[2], header.id[3]);
            return 0;
        }
    }

As it seems to me, teeworlds mainly recognizes teeworlds through this,
and additionally through the header version:

#if defined(CONF_ARCH_ENDIAN_BIG)
    swap_endian(&header, sizeof(int), sizeof(header)/sizeof(int));    
#endif
    if(header.version != 3 && header.version != 4)
    {
        dbg_msg("datafile", "wrong version. version=%x", header.version);
        return 0;
    }

Edit: Sorry for my bad English...

5

Re: [HELP] Verify map files?!

lxde wrote:

Can you also program C++?
If yes, then have a look into the teeworlds source code and  there file "src/engine/e_datafile.c".
Especially look at the function "datafile_load()", line  92 - 99:

    /* TODO: change this header */
    io_read(file, &header, sizeof(header));
    if(header.id[0] != 'A' || header.id[1] != 'T' || header.id[2] != 'A' || header.id[3] != 'D')
    {
        if(header.id[0] != 'D' || header.id[1] != 'A' || header.id[2] != 'T' || header.id[3] != 'A')
        {
            dbg_msg("datafile", "wrong signature. %x %x %x %x"
                 ,header.id[0], header.id[1], header.id[2], header.id[3]);
            return 0;
        }
    }

As it seems to me, teeworlds mainly recognizes teeworlds through this,
and additionally through the header version:

#if defined(CONF_ARCH_ENDIAN_BIG)
    swap_endian(&header, sizeof(int), sizeof(header)/sizeof(int));    
#endif
    if(header.version != 3 && header.version != 4)
    {
        dbg_msg("datafile", "wrong version. version=%x", header.version);
        return 0;
    }

Edit: Sorry for my bad English...

So the header should start with D A T A
DATA is followed by the version id which should be 3 or 4 (03 or 04 at index 4 @ Address 00000000)

So 44 41 54 41 04 @ Address 00000000 is valid, and 44 41 54 41 03 @Address 00000000 is valid too.

Thank you!