1 (edited by Cartman34 2010-09-02 13:58:27)

Topic: [Question] How to Differenciate Map Name from Map Filename ?!

Hi,

My problem require good knowledges in C/C++ and the Teeworlds source.

Currently, the server is using  the filename given in the .cfg as a map name but this is a very bad thing for me because you can't use a filepath (like "directory/mapname.map").
However, i don't want to re-code all the server API, for my use, i just want to seperate filename from the file path to avoid the client error "strange character in map name".

Thanks in advance !

EDIT:
Example: "ctf2_africa.map" in directory "downloaded"
Config: sv_map downloaded/ctf2_africa
Server is ok but client get "downloaded/ctf2_africa" as map name (in server list) and return a "strange character in map name" error when I try to access to my server.

2

Re: [Question] How to Differenciate Map Name from Map Filename ?!

You can fix it this way server-side :
https://github.com/matricks/teeworlds/c … 0598f87b21

3

Re: [Question] How to Differenciate Map Name from Map Filename ?!

Thank you very much !

Solution has changed to:
File: src/engine/server/es_server.c

static void server_send_map(int cid)
{
    //get the name of the map without his path
    char *pMapShortName = &config.sv_map[0];
    int i;
    for( i = 0; i < 128; i++) {
        if( (config.sv_map[i] == '/' || config.sv_map[i] == '\\' ) && i+1 < 128 ) {
            pMapShortName = &config.sv_map[i+1];
        }
    }
    msg_pack_start_system(NETMSG_MAP_CHANGE, MSGFLAG_VITAL|MSGFLAG_FLUSH);
    //msg_pack_string(config.sv_map, 0); //Original
    msg_pack_string(pMapShortName, 0);
    msg_pack_int(current_map_crc);
    msg_pack_end();
    server_send_msg(cid);
}

Based on Choupom's commit.

But map name does not change everywhere...

4

Re: [Question] How to Differenciate Map Name from Map Filename ?!

Here a better solution:

File: src/engine/server/es_server.c

//Add
static char* get_mapname() {
    char* pMapShortName = &config.sv_map[0];
    int i;
    for( i = 0; i < 128; i++) {
        if( (config.sv_map[i] == '/' || config.sv_map[i] == '\\' ) && i+1 < 128 ) {
            pMapShortName = &config.sv_map[i+1];
        }
    }
    return pMapShortName;
}


//Replace
    msg_pack_string(config.sv_map, 0);
//By
    msg_pack_string(get_mapname(), 0);

//Replace
    packer_add_string(&p, config.sv_map, 32);
//By
    packer_add_string(&p, get_mapname(), 32);

It works fine and server name is the same everywhere !