From a914abf01ddc6c4b1fd47a5c3eb468fe2892e2c4 Mon Sep 17 00:00:00 2001 From: ac_stef Date: Wed, 15 Apr 2009 14:58:07 +0000 Subject: [PATCH] ask to download different map versions from server git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@4337 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clients2c.cpp | 21 ++++++++++++++++----- source/src/server.cpp | 8 ++++---- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index af48a2b7..84c7e5b1 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -25,15 +25,26 @@ void neterr(const char *s) VARP(autogetmap, 0, 1, 1); -void changemapserv(char *name, int mode, bool download) // forced map change from the server +void changemapserv(char *name, int mode, int download) // forced map change from the server { gamemode = mode; if(m_demo) return; - if(!load_world(name) && download) + bool loaded = load_world(name); + if(download > 0) { if(securemapcheck(name, false)) return; - if(autogetmap) getmap(); - else conoutf("\"getmap\" to download the current map from the server"); + bool sizematch = maploaded == download || download < 10; + if(loaded && sizematch) return; + if(autogetmap) + { + if(!loaded) getmap(); // no need to ask + else showmenu("getmap"); + } + else + { + if(!loaded || download < 10) conoutf("\"getmap\" to download the current map from the server"); + else conoutf("\"getmap\" to download a different version of the current map from the server"); + } } } @@ -256,7 +267,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) { getstring(text, p); int mode = getint(p); - bool downloadable = getint(p) > 0; + int downloadable = getint(p); changemapserv(text, mode, downloadable); if(m_arena && joining>2) deathstate(player1); mapchanged = true; diff --git a/source/src/server.cpp b/source/src/server.cpp index d9399a13..eb1ff80c 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -21,7 +21,7 @@ void disconnect_client(int n, int reason = -1); int clienthasflag(int cn); bool refillteams(bool now = false, bool notify = true); void changeclientrole(int client, int role, char *pwd = NULL, bool force=false); -bool mapavailable(const char *mapname); +int mapavailable(const char *mapname); void getservermap(void); mapstats *getservermapstats(const char *mapname, bool getlayout = false); @@ -2198,7 +2198,7 @@ void resetmap(const char *newname, int newmode, int newtime, bool notify) if(notify) { // change map - sendf(-1, 1, "risii", SV_MAPCHANGE, smapname, smode, mapavailable(smapname) ? 1 : 0); + sendf(-1, 1, "risii", SV_MAPCHANGE, smapname, smode, mapavailable(smapname)); if(smode>1 || (smode==0 && numnonlocalclients()>0)) sendf(-1, 1, "ri2", SV_TIMEUP, minremain); } if(newname[0]) @@ -2475,7 +2475,7 @@ string copyname; int copysize, copymapsize, copycfgsize, copycfgsizegz; uchar *copydata = NULL; -bool mapavailable(const char *mapname) { return copydata && !strcmp(copyname, behindpath(mapname)); } +int mapavailable(const char *mapname) { return copydata && !strcmp(copyname, behindpath(mapname)) ? copymapsize : 0; } bool sendmapserv(int n, string mapname, int mapsize, int cfgsize, int cfgsizegz, uchar *data) { @@ -2658,7 +2658,7 @@ void welcomepacket(ucharbuf &p, int n, ENetPacket *packet, bool forcedeath) putint(p, SV_MAPCHANGE); sendstring(smapname, p); putint(p, smode); - putint(p, mapavailable(smapname) ? 1 : 0); + putint(p, mapavailable(smapname)); if(smode>1 || (smode==0 && numnonlocalclients()>0)) { putint(p, SV_TIMEUP);