# HG changeset patch # User unc0rr # Date 1238086456 0 # Node ID 2a09f7f786a09d22ccbb793d7548706963c2e45d # Parent 302835d554d8780f1826d2fa2bb90bf194591578 - User from localhost is server admin - Some tweaks diff -r 302835d554d8 -r 2a09f7f786a0 QTfrontend/chatwidget.cpp --- a/QTfrontend/chatwidget.cpp Thu Mar 26 16:20:01 2009 +0000 +++ b/QTfrontend/chatwidget.cpp Thu Mar 26 16:54:16 2009 +0000 @@ -167,6 +167,6 @@ if(b) { chatNicks->insertAction(0, acKick); - chatNicks->insertAction(0, acBan); +// chatNicks->insertAction(0, acBan); } } diff -r 302835d554d8 -r 2a09f7f786a0 QTfrontend/gamecfgwidget.cpp --- a/QTfrontend/gamecfgwidget.cpp Thu Mar 26 16:20:01 2009 +0000 +++ b/QTfrontend/gamecfgwidget.cpp Thu Mar 26 16:54:16 2009 +0000 @@ -143,6 +143,8 @@ templateFilterChanged(pMapContainer->getTemplateFilter()); themeChanged(pMapContainer->getCurrentTheme()); + schemeChanged(GameSchemes->currentIndex()); + // map must be the last QString map = pMapContainer->getCurrentMap(); if (map.size()) @@ -166,38 +168,6 @@ pMapContainer->setTheme(value); return; } - if (param == "HEALTH") { -// SB_InitHealth->setValue(value.toUInt()); - return; - } - if (param == "TURNTIME") { -// SB_TurnTime->setValue(value.toUInt()); - return; - } - if (param == "SD_TURNS") { -// SB_SuddenDeath->setValue(value.toUInt()); - return; - } - if (param == "CASEFACTOR") { -// SB_CaseProb->setValue(value.toUInt()); - return; - } - if (param == "FORTSMODE") { -// CB_mode_Forts->setChecked(value.toUInt() != 0); - return; - } - if (param == "DIVIDETEAMS") { -// CB_teamsDivide->setChecked(value.toUInt() != 0); - return; - } - if (param == "SOLIDLAND") { -// CB_solid->setChecked(value.toUInt() != 0); - return; - } - if (param == "BORDER") { -// CB_border->setChecked(value.toUInt() != 0); - return; - } if (param == "TEMPLATE") { pMapContainer->setTemplateFilter(value.toUInt()); return; @@ -211,6 +181,8 @@ return; } } + + qWarning("Got bad config param from net"); } void GameCFGWidget::ammoChanged(int index) diff -r 302835d554d8 -r 2a09f7f786a0 gameServer/Actions.hs --- a/gameServer/Actions.hs Thu Mar 26 16:20:01 2009 +0000 +++ b/gameServer/Actions.hs Thu Mar 26 16:54:16 2009 +0000 @@ -29,8 +29,8 @@ | ByeClient String | KickClient Int -- clID | KickRoomClient Int -- clID + | BanClient String -- nick | RemoveClientTeams Int -- clID - | BanClient String -- nick | ModifyClient (ClientInfo -> ClientInfo) | ModifyRoom (RoomInfo -> RoomInfo) | AddRoom String String @@ -252,7 +252,7 @@ processAction (clID, serverInfo, clients, rooms) (CheckRegistered) = do - writeChan (dbQueries serverInfo) $ CheckAccount clID (nick client) + writeChan (dbQueries serverInfo) $ CheckAccount client return (clID, serverInfo, clients, rooms) where client = clients ! clID @@ -272,6 +272,9 @@ Guest -> do infoM "Clients" $ show clID ++ " is guest" processAction (clID, serverInfo, adjust (\cl -> cl{logonPassed = True}) clID clients, rooms) MoveToLobby + Admin -> do + infoM "Clients" $ show clID ++ " is admin" + foldM processAction (clID, serverInfo, adjust (\cl -> cl{logonPassed = True, isAdministrator = True}) clID clients, rooms) [MoveToLobby, AnswerThisClient ["ADMIN_ACCESS"]] processAction (clID, serverInfo, clients, rooms) (MoveToLobby) = do @@ -290,6 +293,9 @@ processAction (clID, serverInfo, clients, rooms) (KickClient kickID) = do liftM2 replaceID (return clID) (processAction (kickID, serverInfo, clients, rooms) $ ByeClient "Kicked") +processAction (clID, serverInfo, clients, rooms) (BanClient banNick) = do + return (clID, serverInfo, clients, rooms) + processAction (clID, serverInfo, clients, rooms) (KickRoomClient kickID) = do writeChan (sendChan $ clients ! kickID) ["KICKED"] diff -r 302835d554d8 -r 2a09f7f786a0 gameServer/CoreTypes.hs --- a/gameServer/CoreTypes.hs Thu Mar 26 16:20:01 2009 +0000 +++ b/gameServer/CoreTypes.hs Thu Mar 26 16:54:16 2009 +0000 @@ -142,6 +142,7 @@ data AccountInfo = HasAccount String Bool | Guest + | Admin data CoreMessage = Accept ClientInfo @@ -151,7 +152,7 @@ -- | TimerTick data DBQuery = - CheckAccount Int String + CheckAccount ClientInfo type Clients = IntMap.IntMap ClientInfo diff -r 302835d554d8 -r 2a09f7f786a0 gameServer/OfficialServer/DBInteraction.hs --- a/gameServer/OfficialServer/DBInteraction.hs Thu Mar 26 16:20:01 2009 +0000 +++ b/gameServer/OfficialServer/DBInteraction.hs Thu Mar 26 16:54:16 2009 +0000 @@ -15,12 +15,14 @@ ------------------------ import CoreTypes +localAddressList = ["127.0.0.1", "0:0:0:0:0:0:0:1", "0:0:0:0:0:ffff:7f00:1"] fakeDbConnection serverInfo = do q <- readChan $ dbQueries serverInfo case q of - CheckAccount clID name -> do - writeChan (coreChan serverInfo) $ ClientAccountInfo clID Guest + CheckAccount client -> do + writeChan (coreChan serverInfo) $ ClientAccountInfo (clientUID client) $ + if host client `elem` localAddressList then Admin else Guest fakeDbConnection serverInfo @@ -40,21 +42,21 @@ dbInteractionLoop queries coreChan dbConn = do q <- readChan queries case q of - CheckAccount clID name -> do + CheckAccount client -> do statement <- prepare dbConn dbQueryString - execute statement [SqlString name] + execute statement [SqlString $ nick client] passAndRole <- fetchRow statement finish statement if isJust passAndRole then writeChan coreChan $ - ClientAccountInfo clID $ + ClientAccountInfo (clientUID client) $ HasAccount (fromSql $ head $ fromJust $ passAndRole) ((fromSql $ last $ fromJust $ passAndRole) == (3 :: Int)) else - writeChan coreChan $ ClientAccountInfo clID Guest + writeChan coreChan $ ClientAccountInfo (clientUID client) Guest `onException` - (unGetChan queries $ CheckAccount clID name) + (unGetChan queries q) dbInteractionLoop queries coreChan dbConn