author | alfadur |
Mon, 25 Mar 2024 16:05:11 +0300 | |
changeset 16000 | d9f1b239b6d7 |
parent 15983 | 2c92499daa67 |
permissions | -rw-r--r-- |
10460
8dcea9087d75
Added copyrights to gameServer directory
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
10212
diff
changeset
|
1 |
{- |
8dcea9087d75
Added copyrights to gameServer directory
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
10212
diff
changeset
|
2 |
* Hedgewars, a free turn based strategy game |
11046 | 3 |
* Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
10460
8dcea9087d75
Added copyrights to gameServer directory
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
10212
diff
changeset
|
4 |
* |
8dcea9087d75
Added copyrights to gameServer directory
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
10212
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
8dcea9087d75
Added copyrights to gameServer directory
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
10212
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
8dcea9087d75
Added copyrights to gameServer directory
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
10212
diff
changeset
|
7 |
* the Free Software Foundation; version 2 of the License |
8dcea9087d75
Added copyrights to gameServer directory
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
10212
diff
changeset
|
8 |
* |
8dcea9087d75
Added copyrights to gameServer directory
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
10212
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
8dcea9087d75
Added copyrights to gameServer directory
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
10212
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
8dcea9087d75
Added copyrights to gameServer directory
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
10212
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
8dcea9087d75
Added copyrights to gameServer directory
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
10212
diff
changeset
|
12 |
* GNU General Public License for more details. |
8dcea9087d75
Added copyrights to gameServer directory
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
10212
diff
changeset
|
13 |
* |
8dcea9087d75
Added copyrights to gameServer directory
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
10212
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
8dcea9087d75
Added copyrights to gameServer directory
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
10212
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
8dcea9087d75
Added copyrights to gameServer directory
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
10212
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
8dcea9087d75
Added copyrights to gameServer directory
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
10212
diff
changeset
|
17 |
\-} |
8dcea9087d75
Added copyrights to gameServer directory
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
10212
diff
changeset
|
18 |
|
4295
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
19 |
{-# LANGUAGE OverloadedStrings #-} |
1804 | 20 |
module HWProtoCore where |
21 |
||
15983 | 22 |
import Control.Monad |
4612 | 23 |
import Control.Monad.Reader |
4295
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
24 |
import Data.Maybe |
4612 | 25 |
import qualified Data.ByteString.Char8 as B |
1804 | 26 |
-------------------------------------- |
27 |
import CoreTypes |
|
28 |
import HWProtoNEState |
|
29 |
import HWProtoLobbyState |
|
30 |
import HWProtoInRoomState |
|
8479
8d71109b04d2
Some work on loading replay and interaction with checker
unc0rr
parents:
8478
diff
changeset
|
31 |
import HWProtoChecker |
4295
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
32 |
import HandlerUtils |
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
33 |
import RoomsAndClients |
4612 | 34 |
import Utils |
13696
d732ca5dcab9
GameServer: Refactor fake nick names into Consts
Wuzzy <Wuzzy2@mail.ru>
parents:
13694
diff
changeset
|
35 |
import Consts |
1804 | 36 |
|
13845
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
37 |
handleCmd, handleCmd_loggedin, handleCmd_lobbyOnly, handleCmd_roomOnly :: CmdHandler |
1804 | 38 |
|
4295
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
39 |
|
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
40 |
handleCmd ["PING"] = answerClient ["PONG"] |
1804 | 41 |
|
42 |
||
4295
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
43 |
handleCmd ("QUIT" : xs) = return [ByeClient msg] |
2867
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2706
diff
changeset
|
44 |
where |
13846 | 45 |
-- "bye" is a special string (do not translate!) when the user quits manually, |
46 |
-- otherwise there will be an additional server message |
|
47 |
msg = if not $ null xs then (head xs) else "bye" |
|
1804 | 48 |
|
4568 | 49 |
|
4612 | 50 |
handleCmd ["PONG"] = do |
51 |
cl <- thisClient |
|
52 |
if pingsQueue cl == 0 then |
|
8897
d6c310c65c91
- Revert server workaround over desync from r98e2dbdda8c0
unc0rr
parents:
8547
diff
changeset
|
53 |
return [ProtocolError "Protocol violation"] |
4612 | 54 |
else |
55 |
return [ModifyClient (\c -> c{pingsQueue = pingsQueue c - 1})] |
|
4568 | 56 |
|
11054
6e575b29881c
Check for CMD message a bit further down the control flow
unc0rr
parents:
11046
diff
changeset
|
57 |
handleCmd cmd = do |
6e575b29881c
Check for CMD message a bit further down the control flow
unc0rr
parents:
11046
diff
changeset
|
58 |
(ci, irnc) <- ask |
6e575b29881c
Check for CMD message a bit further down the control flow
unc0rr
parents:
11046
diff
changeset
|
59 |
let cl = irnc `client` ci |
6e575b29881c
Check for CMD message a bit further down the control flow
unc0rr
parents:
11046
diff
changeset
|
60 |
if logonPassed cl then |
6e575b29881c
Check for CMD message a bit further down the control flow
unc0rr
parents:
11046
diff
changeset
|
61 |
if isChecker cl then |
6e575b29881c
Check for CMD message a bit further down the control flow
unc0rr
parents:
11046
diff
changeset
|
62 |
handleCmd_checker cmd |
6e575b29881c
Check for CMD message a bit further down the control flow
unc0rr
parents:
11046
diff
changeset
|
63 |
else |
6e575b29881c
Check for CMD message a bit further down the control flow
unc0rr
parents:
11046
diff
changeset
|
64 |
handleCmd_loggedin cmd |
6e575b29881c
Check for CMD message a bit further down the control flow
unc0rr
parents:
11046
diff
changeset
|
65 |
else |
6e575b29881c
Check for CMD message a bit further down the control flow
unc0rr
parents:
11046
diff
changeset
|
66 |
handleCmd_NotEntered cmd |
6e575b29881c
Check for CMD message a bit further down the control flow
unc0rr
parents:
11046
diff
changeset
|
67 |
|
13845
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
68 |
handleCmd_lobbyOnly cmd = do |
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
69 |
(ci, rnc) <- ask |
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
70 |
if (clientRoom rnc ci) == lobbyId then |
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
71 |
handleCmd cmd |
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
72 |
else |
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
73 |
return [Warning $ loc "This command is only available in the lobby."] |
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
74 |
|
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
75 |
handleCmd_roomOnly cmd = do |
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
76 |
(ci, rnc) <- ask |
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
77 |
if (clientRoom rnc ci) == lobbyId then |
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
78 |
return [Warning $ loc "This command is only available in rooms."] |
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
79 |
else |
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
80 |
handleCmd cmd |
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
81 |
|
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
82 |
-- Chat command handling |
13827
28a86816dc01
gameServer: Handle empty chat command (partially)
Wuzzy <Wuzzy2@mail.ru>
parents:
13825
diff
changeset
|
83 |
unknownCmdWarningText :: B.ByteString |
28a86816dc01
gameServer: Handle empty chat command (partially)
Wuzzy <Wuzzy2@mail.ru>
parents:
13825
diff
changeset
|
84 |
unknownCmdWarningText = loc "Unknown command or invalid parameters. Say '/help' in chat for a list of commands." |
28a86816dc01
gameServer: Handle empty chat command (partially)
Wuzzy <Wuzzy2@mail.ru>
parents:
13825
diff
changeset
|
85 |
|
28a86816dc01
gameServer: Handle empty chat command (partially)
Wuzzy <Wuzzy2@mail.ru>
parents:
13825
diff
changeset
|
86 |
handleCmd_loggedin ["CMD"] = return [Warning unknownCmdWarningText] |
11054
6e575b29881c
Check for CMD message a bit further down the control flow
unc0rr
parents:
11046
diff
changeset
|
87 |
|
6e575b29881c
Check for CMD message a bit further down the control flow
unc0rr
parents:
11046
diff
changeset
|
88 |
handleCmd_loggedin ["CMD", parameters] = uncurry h $ extractParameters parameters |
8396 | 89 |
where |
13845
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
90 |
-- room-only commands |
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
91 |
h "DELEGATE" n | not $ B.null n = handleCmd_roomOnly ["DELEGATE", n] |
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
92 |
h "SAVEROOM" n | not $ B.null n = handleCmd_roomOnly ["SAVEROOM", n] |
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
93 |
h "LOADROOM" n | not $ B.null n = handleCmd_roomOnly ["LOADROOM", n] |
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
94 |
h "SAVE" n | not $ B.null n = let (sn, ln) = B.break (== ' ') n in if B.null ln then return [Warning unknownCmdWarningText] else handleCmd_roomOnly ["SAVE", sn, B.tail ln] |
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
95 |
h "DELETE" n | not $ B.null n = handleCmd_roomOnly ["DELETE", n] |
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
96 |
h "FIX" _ = handleCmd_roomOnly ["FIX"] |
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
97 |
h "UNFIX" _ = handleCmd_roomOnly ["UNFIX"] |
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
98 |
h "GREETING" msg = handleCmd_roomOnly ["GREETING", msg] |
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
99 |
h "CALLVOTE" msg | B.null msg = handleCmd_roomOnly ["CALLVOTE"] |
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
100 |
| otherwise = let (c, p) = extractParameters msg in |
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
101 |
if B.null p then handleCmd_roomOnly ["CALLVOTE", c] else handleCmd_roomOnly ["CALLVOTE", c, p] |
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
102 |
h "VOTE" msg | not $ B.null msg = handleCmd_roomOnly ["VOTE", upperCase msg] |
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
103 |
| otherwise = handleCmd_roomOnly ["VOTE", ""] |
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
104 |
h "FORCE" msg | not $ B.null msg = handleCmd_roomOnly ["VOTE", upperCase msg, "FORCE"] |
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
105 |
| otherwise = handleCmd_roomOnly ["VOTE", "", "FORCE"] |
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
106 |
h "MAXTEAMS" n | not $ B.null n = handleCmd_roomOnly ["MAXTEAMS", n] |
14118
589a752c01ca
GameServer: Print syntax help if calling /maxteams without argument
Wuzzy <Wuzzy2@mail.ru>
parents:
13846
diff
changeset
|
107 |
| otherwise = handleCmd_roomOnly ["MAXTEAMS"] |
13845
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
108 |
|
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
109 |
-- lobby-only commands |
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
110 |
h "STATS" _ = handleCmd_lobbyOnly ["STATS"] |
14381
32e8c81ca35c
Add reminder to call /restart_server with "yes"
Wuzzy <Wuzzy2@mail.ru>
parents:
14380
diff
changeset
|
111 |
h "RESTART_SERVER" p = handleCmd_lobbyOnly ["RESTART_SERVER", upperCase p] |
13845
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
112 |
|
1a1fb597da8f
gameServer: Add user warning if got chat command not suitable for current state (lobby/room); fix protocol errors
Wuzzy <Wuzzy2@mail.ru>
parents:
13831
diff
changeset
|
113 |
-- room and lobby commands |
13846 | 114 |
h "QUIT" _ = handleCmd ["QUIT"] |
9105 | 115 |
h "RND" p = handleCmd ("RND" : B.words p) |
11467
f2c36df8c7b1
Allow server admins to join passworded/restricted rooms when it is really needed
unc0rr
parents:
11466
diff
changeset
|
116 |
h "GLOBAL" p = serverAdminOnly $ do |
8547
6898be8aa261
Global notice with /global command. Can now warn users when doing server restart.
unc0rr
parents:
8519
diff
changeset
|
117 |
rnc <- liftM snd ask |
6898be8aa261
Global notice with /global command. Can now warn users when doing server restart.
unc0rr
parents:
8519
diff
changeset
|
118 |
let chans = map (sendChan . client rnc) $ allClients rnc |
13696
d732ca5dcab9
GameServer: Refactor fake nick names into Consts
Wuzzy <Wuzzy2@mail.ru>
parents:
13694
diff
changeset
|
119 |
return [AnswerClients chans ["CHAT", nickGlobal, p]] |
9448 | 120 |
h "WATCH" f = return [QueryReplay f] |
10882
ed7717f659ae
- Fix ping timeouts after incorrect "/vote" commands (protocol violation)
unc0rr
parents:
10881
diff
changeset
|
121 |
h "INFO" n | not $ B.null n = handleCmd ["INFO", n] |
13508
da59012fbd7a
Add /help command for lobby and rooms too
Wuzzy <Wuzzy2@mail.ru>
parents:
11974
diff
changeset
|
122 |
h "HELP" _ = handleCmd ["HELP"] |
11467
f2c36df8c7b1
Allow server admins to join passworded/restricted rooms when it is really needed
unc0rr
parents:
11466
diff
changeset
|
123 |
h "REGISTERED_ONLY" _ = serverAdminOnly $ do |
14380
8ad85859dd3f
/registered_only now tells in chat whether the state is on or off
Wuzzy <Wuzzy2@mail.ru>
parents:
14118
diff
changeset
|
124 |
rnc <- liftM snd ask |
8ad85859dd3f
/registered_only now tells in chat whether the state is on or off
Wuzzy <Wuzzy2@mail.ru>
parents:
14118
diff
changeset
|
125 |
let chans = map (sendChan . client rnc) $ allClients rnc |
11467
f2c36df8c7b1
Allow server admins to join passworded/restricted rooms when it is really needed
unc0rr
parents:
11466
diff
changeset
|
126 |
return |
11466
4b5c7a5c49fd
Defer kicking to the time when everything is in consistent state
unc0rr
parents:
11465
diff
changeset
|
127 |
[ModifyServerInfo(\s -> s{isRegisteredUsersOnly = not $ isRegisteredUsersOnly s}) |
14380
8ad85859dd3f
/registered_only now tells in chat whether the state is on or off
Wuzzy <Wuzzy2@mail.ru>
parents:
14118
diff
changeset
|
128 |
, ShowRegisteredOnlyState chans |
11465
0ae2e4c13bd1
Allow toggling registration requirement on live server
unc0rr
parents:
11054
diff
changeset
|
129 |
] |
13694
91fe09213abc
Tweak response messages to /super_power and /registered_only
Wuzzy <Wuzzy2@mail.ru>
parents:
13693
diff
changeset
|
130 |
h "SUPER_POWER" _ = serverAdminOnly $ do |
91fe09213abc
Tweak response messages to /super_power and /registered_only
Wuzzy <Wuzzy2@mail.ru>
parents:
13693
diff
changeset
|
131 |
cl <- thisClient |
91fe09213abc
Tweak response messages to /super_power and /registered_only
Wuzzy <Wuzzy2@mail.ru>
parents:
13693
diff
changeset
|
132 |
return |
91fe09213abc
Tweak response messages to /super_power and /registered_only
Wuzzy <Wuzzy2@mail.ru>
parents:
13693
diff
changeset
|
133 |
[ModifyClient (\c -> c{hasSuperPower = True}) |
13696
d732ca5dcab9
GameServer: Refactor fake nick names into Consts
Wuzzy <Wuzzy2@mail.ru>
parents:
13694
diff
changeset
|
134 |
, AnswerClients [sendChan cl] ["CHAT", nickServer, loc "Super power activated."] |
13694
91fe09213abc
Tweak response messages to /super_power and /registered_only
Wuzzy <Wuzzy2@mail.ru>
parents:
13693
diff
changeset
|
135 |
] |
13827
28a86816dc01
gameServer: Handle empty chat command (partially)
Wuzzy <Wuzzy2@mail.ru>
parents:
13825
diff
changeset
|
136 |
h _ _ = return [Warning unknownCmdWarningText] |
13510
60bcc20e6ab0
Improve some replies for chat commands on server
Wuzzy <Wuzzy2@mail.ru>
parents:
13508
diff
changeset
|
137 |
|
8396 | 138 |
|
10039 | 139 |
extractParameters p = let (a, b) = B.break (== ' ') p in (upperCase a, B.dropWhile (== ' ') b) |
140 |
||
4612 | 141 |
handleCmd_loggedin ["INFO", asknick] = do |
142 |
(_, rnc) <- ask |
|
4614 | 143 |
maybeClientId <- clientByNick asknick |
5060
7d0f6e5b1c1c
Hide last two octets of IP address from usual users
unc0rr
parents:
5030
diff
changeset
|
144 |
isAdminAsking <- liftM isAdministrator thisClient |
4612 | 145 |
let noSuchClient = isNothing maybeClientId |
146 |
let clientId = fromJust maybeClientId |
|
147 |
let cl = rnc `client` fromJust maybeClientId |
|
148 |
let roomId = clientRoom rnc clientId |
|
149 |
let clRoom = room rnc roomId |
|
9061 | 150 |
let roomMasterSign = if isMaster cl then "+" else "" |
4612 | 151 |
let adminSign = if isAdministrator cl then "@" else "" |
13510
60bcc20e6ab0
Improve some replies for chat commands on server
Wuzzy <Wuzzy2@mail.ru>
parents:
13508
diff
changeset
|
152 |
let rInfo = if roomId /= lobbyId then B.concat [adminSign, roomMasterSign, loc "room", " ", name clRoom] else adminSign `B.append` (loc "lobby") |
5996
2c72fe81dd37
Convert boolean variable + a bunch of fields which make sense only while game is going on into Maybe + structure
unc0rr
parents:
5060
diff
changeset
|
153 |
let roomStatus = if isJust $ gameInfo clRoom then |
13510
60bcc20e6ab0
Improve some replies for chat commands on server
Wuzzy <Wuzzy2@mail.ru>
parents:
13508
diff
changeset
|
154 |
if teamsInGame cl > 0 then (loc "(playing)") else (loc "(spectating)") |
4612 | 155 |
else |
156 |
"" |
|
10061
b7161f00a6ca
hide complete IP of other users, when non-admin requests player info. showing the first two parts of the IP was kinda pointless to begin with (what for?) and has recently lead to increased abuse and lobby flooding due to bots collecting/posting IP tracking information
sheepluva
parents:
10039
diff
changeset
|
157 |
let hostStr = if isAdminAsking then host cl else B.empty |
2867
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2706
diff
changeset
|
158 |
if noSuchClient then |
13696
d732ca5dcab9
GameServer: Refactor fake nick names into Consts
Wuzzy <Wuzzy2@mail.ru>
parents:
13694
diff
changeset
|
159 |
answerClient [ "CHAT", nickServer, loc "Player is not online." ] |
4612 | 160 |
else |
161 |
answerClient [ |
|
162 |
"INFO", |
|
163 |
nick cl, |
|
5060
7d0f6e5b1c1c
Hide last two octets of IP address from usual users
unc0rr
parents:
5030
diff
changeset
|
164 |
B.concat ["[", hostStr, "]"], |
4612 | 165 |
protoNumber2ver $ clientProto cl, |
7766 | 166 |
B.concat ["[", rInfo, "]", roomStatus] |
4612 | 167 |
] |
1862 | 168 |
|
169 |
||
4295
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
170 |
handleCmd_loggedin cmd = do |
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
171 |
(ci, rnc) <- ask |
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
172 |
if clientRoom rnc ci == lobbyId then |
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
173 |
handleCmd_lobby cmd |
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
174 |
else |
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
175 |
handleCmd_inRoom cmd |