# HG changeset patch # User unc0rr # Date 1298919850 -10800 # Node ID 53411a26df7e1dd2d602af749157ed6f40654e6d # Parent 2f9c8a12edce83b7d20cae4a384e9698089f23e7 Add server version (which is separate from protocol version) and a check in frontend for a new enough server (currently only qWarning) diff -r 2f9c8a12edce -r 53411a26df7e QTfrontend/hwconsts.cpp.in --- a/QTfrontend/hwconsts.cpp.in Sun Feb 27 18:55:34 2011 -0500 +++ b/QTfrontend/hwconsts.cpp.in Mon Feb 28 22:04:10 2011 +0300 @@ -35,6 +35,7 @@ bool custom_data = false; int cMaxTeams = 6; +int cMinServerVersion = 0; QString * cDefaultAmmoStore = new QString( "93919294221991210322351110012010000002111101010111299" diff -r 2f9c8a12edce -r 53411a26df7e QTfrontend/hwconsts.h --- a/QTfrontend/hwconsts.h Sun Feb 27 18:55:34 2011 -0500 +++ b/QTfrontend/hwconsts.h Mon Feb 28 22:04:10 2011 +0300 @@ -35,6 +35,7 @@ extern bool custom_data; extern int cMaxTeams; +extern int cMinServerVersion; extern QStringList * Themes; extern QStringList * mapList; diff -r 2f9c8a12edce -r 53411a26df7e QTfrontend/mapContainer.cpp --- a/QTfrontend/mapContainer.cpp Sun Feb 27 18:55:34 2011 -0500 +++ b/QTfrontend/mapContainer.cpp Mon Feb 28 22:04:10 2011 +0300 @@ -616,7 +616,6 @@ void HWMapContainer::updatePreview() { - qDebug("updating a preview"); int curIndex = chooseMap->currentIndex(); switch(curIndex) diff -r 2f9c8a12edce -r 53411a26df7e QTfrontend/newnetclient.cpp --- a/QTfrontend/newnetclient.cpp Sun Feb 27 18:55:34 2011 -0500 +++ b/QTfrontend/newnetclient.cpp Mon Feb 28 22:04:10 2011 +0300 @@ -240,6 +240,12 @@ } if (lst[0] == "CONNECTED") { + if(lst.size() < 3 || lst[2].toInt() < cMinServerVersion) + { + // TODO: Warn user, disconnect + qWarning() << "Server too old"; + } + RawSendNet(QString("NICK%1%2").arg(delimeter).arg(mynick)); RawSendNet(QString("PROTO%1%2").arg(delimeter).arg(*cProtoVer)); netClientState = 1; diff -r 2f9c8a12edce -r 53411a26df7e gameServer/Actions.hs --- a/gameServer/Actions.hs Sun Feb 27 18:55:34 2011 -0500 +++ b/gameServer/Actions.hs Mon Feb 28 22:04:10 2011 +0300 @@ -20,6 +20,7 @@ import Utils import ClientIO import ServerState +import Consts data Action = AnswerClients ![ClientChan] ![B.ByteString] @@ -381,7 +382,7 @@ return ci modify (\s -> s{clientIndex = Just newClId}) - processAction $ AnswerClients [sendChan cl] ["CONNECTED", "Hedgewars server http://www.hedgewars.org/"] + processAction $ AnswerClients [sendChan cl] ["CONNECTED", "Hedgewars server http://www.hedgewars.org/", serverVersion] let newLogins = takeWhile (\(_ , (time, _)) -> connectTime cl `diffUTCTime` time <= 0) $ lastLogins si let info = host cl `Prelude.lookup` newLogins diff -r 2f9c8a12edce -r 53411a26df7e gameServer/Consts.hs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gameServer/Consts.hs Mon Feb 28 22:04:10 2011 +0300 @@ -0,0 +1,7 @@ +{-# LANGUAGE OverloadedStrings #-} +module Consts where + +import qualified Data.ByteString.Char8 as B + +serverVersion :: B.ByteString +serverVersion = "0" diff -r 2f9c8a12edce -r 53411a26df7e gameServer/hedgewars-server.hs --- a/gameServer/hedgewars-server.hs Sun Feb 27 18:55:34 2011 -0500 +++ b/gameServer/hedgewars-server.hs Mon Feb 28 22:04:10 2011 +0300 @@ -8,7 +8,9 @@ import qualified Control.Exception as E import System.Log.Logger import System.Process +#if defined(OFFICIAL_SERVER) import Control.Monad +#endif ----------------------------------- import Opts import CoreTypes