uakfdotb / ghostpp

GHost++, the Warcraft III game hosting bot
https://www.ghostpp.com
Other
67 stars 51 forks source link

MapGameType question #13

Closed marciii closed 6 years ago

marciii commented 6 years ago

Hi,

this one is not really an issue, more like a question regarding the mapgametype: The game list is overloaded. But there's a certain reserved value (49161), which only works for officially signed blizzard maps and which makes the game visible on top of the list. So far so good. But I still have a problem: When I use this value in the ghost.cfg, it doesn't make any difference (I also tried some debug output, the function GetMapGameType() in the map.cpp overwrites this value). My second try was to hardcode it (at the end of the GetMapGameType()-function) and just use "GameType = 49161;". However this results in a "failed to authorize the map" error in the wc3 client. Is there any workaround to fix that?

Cheers

uakfdotb commented 6 years ago

Overridden map game type -- are you setting bot_mapgametype in ghost.cfg? It shouldn't be overridden, the code looks like this (bnet.cpp):

uint32_t MapGameType = map->GetMapGameType( );
MapGameType |= MAPGAMETYPE_UNKNOWN0;
//Apply overwrite if not equal to 0
MapGameType = ( m_GHost->m_MapGameType != 0 ) ? MapGameType : m_GHost->m_MapGameType;

if( state == GAME_PRIVATE )
    MapGameType |= MAPGAMETYPE_PRIVATEGAME;

So initially MapGameType is set based on the map, but if m_GHost->m_MapGameType is nonzero, then m_GHost->m_MapGameType is used.

It might be useful to debug a bit what caused the overriding problem since that may be related to the second issue. You could add a CONSOLE_Print statement after the code above to print MapGameType, m_GHost->m_MapGameType, and map->GetMapGameType( ).

Note: you may want to convert the number to binary so you can see exactly what flags are getting set. You can just google "XYZ in binary".

For map authorized error, one way to debug it would be to see what the map game type reported by actual WC3 client is. So you run Wireshark, host the map in WC3 client, and then look for the SID_STARTADVEX3 TCP packets, which should start with 0xFF (header constant) and then 0x1C (SID_STARTADVEX3).

Another thing to check is map_path should be something like Maps(2)BootyBay.w3m; it should not be in Maps\Download, and should use backslashes.

Also, do you get "failed to authorize the map" if you use a map configuration file like this, without overriding the map game type?

map_path = Maps\(2)BootyBay.w3m
map_localpath = (2)BootyBay.w3m
map_options = 4

# blizzard maker
map_filter_maker = 2

# melee map
map_filter_type = 1

Note that the map_filter_maker option makes GHost++ automatically compute a map game type that includes the (1 << 14) MAPGAMETYPE_MAKERBLIZZARD flag, which is probably the flag in the map game type that makes it show up more often (perhaps gets put in a different bucket of games, and shows up just because so few games with Blizzard maps are being hosted).

marciii commented 6 years ago

Hi,

first of all: thanks for your great work! I'm a little bit busy at the moment, but i try to answer as fast as possible.

I think I found the bug which causes the overwriting of the mapgametype: https://github.com/uakfdotb/ghostpp/blob/6a8be0af5ead3d1b6755157053aad7fc24e98560/ghost/bnet.cpp#L2281 This line checks if m_GHost->m_MapGameType is NOT zero. And if thats true (so if it doesnt equal zero) it will be overwritten by the MapGameType (which is the return value from the GetMapGameType Function). However if it's zero, it will remain zero - which doesn't make sense, does it? I think it should be the other way around, like this: MapGameType = ( m_GHost->m_MapGameType != 0 ) ? m_GHost->m_MapGameType : MapGameType; Thats probably the reason the bot doesn't apply the mapgametype from the config file.

Also I tried the mapconfig details you provided: One can join the games, so there's no issue. But it's not really visible then.

I also tried sniffing out the packet, but I don't really know how to read it out properly. Should be this one: https://pastebin.com/1jUzM1XP "test1212" is the gamename. But where can I readout the mapgametype?

Again: Thank you!

marciii commented 6 years ago

Okay it is solved now. My issue was the structure of the maps directory. Apparently it has to be the exact same as it is in the wc3 installation directory. Then the players are able to join and stay - the "failed to authorize the map" error doesn't appear anymore. But it's probably still useful to swap the parameters in line 2281, then the bot applies what is written in the ghost.cfg.

uakfdotb commented 6 years ago

Ah oops... thanks for the fix (I committed it)!