# HG changeset patch # User unc0rr # Date 1223567649 0 # Node ID b0b0510eb82da2082770e4b37104454cfc2ebf4e # Parent 19ff9bf7d69e03ce29ee3b68c7b6f318c2e63222 - Fix a bug with chosen map (new clinet gets wrong information) - Fix mapContainer bug when switching quickly from random map to a painted one diff -r 19ff9bf7d69e -r b0b0510eb82d QTfrontend/mapContainer.cpp --- a/QTfrontend/mapContainer.cpp Thu Oct 09 13:57:18 2008 +0000 +++ b/QTfrontend/mapContainer.cpp Thu Oct 09 15:54:09 2008 +0000 @@ -35,7 +35,9 @@ #include "igbox.h" HWMapContainer::HWMapContainer(QWidget * parent) : - QWidget(parent), mainLayout(this) + QWidget(parent), + mainLayout(this), + pMap(0) { #if QT_VERSION >= 0x040300 mainLayout.setContentsMargins(QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin), @@ -111,12 +113,14 @@ imageButt->setIcon(pxres); imageButt->setIconSize(QSize(256, 128)); chooseMap->setCurrentIndex(0); + pMap = 0; } void HWMapContainer::mapChanged(int index) { if(!index) { changeImage(); + emit mapChanged("+rnd+"); return; } @@ -185,10 +189,18 @@ void HWMapContainer::setMap(const QString & map) { + if(map == "+rnd+") + { + changeImage(); + return; + } + int id = chooseMap->findText(map); - if(id >= 0) { + if(id > 0) { chooseMap->setCurrentIndex(id); loadMap(id); + if (pMap) + disconnect(pMap, 0, this, SLOT(setImage(const QImage))); } } diff -r 19ff9bf7d69e -r b0b0510eb82d QTfrontend/newnetclient.cpp --- a/QTfrontend/newnetclient.cpp Thu Oct 09 13:57:18 2008 +0000 +++ b/QTfrontend/newnetclient.cpp Thu Oct 09 15:54:09 2008 +0000 @@ -299,7 +299,6 @@ return; } - if (lst[0] == "TEAM_ACCEPTED") { if (lst.size() != 2) { @@ -310,6 +309,17 @@ return; } + if (lst[0] == "MAP") { + if (lst.size() != 2) + { + qWarning("Net: Bad MAP message"); + return; + } + emit mapChanged(lst[1]); + return; + } + + if (lst[0] == "CONFIG_PARAM") { if(lst.size() < 3) { @@ -320,10 +330,6 @@ emit seedChanged(lst[2]); return; } - if (lst[1] == "MAP") { - emit mapChanged(lst[2]); - return; - } if (lst[1] == "THEME") { emit themeChanged(lst[2]); return; @@ -433,7 +439,7 @@ void HWNewNet::onMapChanged(const QString & map) { - if (isChief) RawSendNet(QString("CONFIG_PARAM%1MAP%1%2").arg(delimeter).arg(map)); + if (isChief) RawSendNet(QString("MAP%1%2").arg(delimeter).arg(map)); } void HWNewNet::onThemeChanged(const QString & theme) diff -r 19ff9bf7d69e -r b0b0510eb82d netserver/HWProto.hs --- a/netserver/HWProto.hs Thu Oct 09 13:57:18 2008 +0000 +++ b/netserver/HWProto.hs Thu Oct 09 15:54:09 2008 +0000 @@ -30,7 +30,7 @@ answerWrongPassword = [(clientOnly, ["WARNING", "Wrong password"])] answerChatString nick msg = [(othersInRoom, ["CHAT_STRING", nick, msg])] answerConfigParam paramName paramStrs = [(othersInRoom, "CONFIG_PARAM" : paramName : paramStrs)] -answerFullConfig room = map toAnswer (Map.toList $ params room) +answerFullConfig room = map toAnswer (Map.toList $ params room) ++ [(clientOnly, ["MAP", gamemap room])] where toAnswer (paramName, paramStrs) = (clientOnly, "CONFIG_PARAM" : paramName : paramStrs) @@ -47,6 +47,7 @@ [(clientOnly, teamToNet team), (clientOnly, ["TEAM_COLOR", teamname team, teamcolor team]), (clientOnly, ["HH_NUM", teamname team, show $ hhnum team])] +answerMap mapName = [(othersInRoom, ["MAP", mapName])] -- Main state-independent cmd handler handleCmd :: CmdHandler @@ -103,7 +104,7 @@ if haveSameRoom then (noChangeClients, noChangeRooms, answerRoomExists) else - (modifyClient client{room = newRoom, isMaster = True}, addRoom (RoomInfo newRoom roomPassword (protocol client) [] Map.empty), answerJoined $ nick client) + (modifyClient client{room = newRoom, isMaster = True}, addRoom (RoomInfo newRoom roomPassword (protocol client) [] "+rnd+" Map.empty), answerJoined $ nick client) where haveSameRoom = isJust $ find (\room -> newRoom == name room) rooms @@ -141,6 +142,14 @@ where clRoom = roomByName (room client) rooms +handleCmd_inRoom client _ rooms ["MAP", mapName] = + if isMaster client then + (noChangeClients, modifyRoom clRoom{gamemap = mapName}, answerMap mapName) + else + (noChangeClients, noChangeRooms, answerNotMaster) + where + clRoom = roomByName (room client) rooms + handleCmd_inRoom client _ rooms ("ADD_TEAM" : name : color : grave : fort : difStr : hhsInfo) | length hhsInfo == 16 = if length (teams clRoom) == 6 || canAddNumber <= 0 || isJust findTeam then diff -r 19ff9bf7d69e -r b0b0510eb82d netserver/Miscutils.hs --- a/netserver/Miscutils.hs Thu Oct 09 13:57:18 2008 +0000 +++ b/netserver/Miscutils.hs Thu Oct 09 15:54:09 2008 +0000 @@ -45,6 +45,7 @@ password :: String, roomProto :: Word16, teams :: [TeamInfo], + gamemap :: String, params :: Map.Map String [String] }