Sat, 23 Jul 2016 12:28:52 +0300
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
73
07dda51a7a8e
Update license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
1 | /* |
109 | 2 | Copyright 2014 - 2016 Teemu Piippo |
73
07dda51a7a8e
Update license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
3 | All rights reserved. |
07dda51a7a8e
Update license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
4 | |
07dda51a7a8e
Update license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
5 | Redistribution and use in source and binary forms, with or without |
07dda51a7a8e
Update license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
6 | modification, are permitted provided that the following conditions |
07dda51a7a8e
Update license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
7 | are met: |
07dda51a7a8e
Update license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
8 | |
07dda51a7a8e
Update license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
9 | 1. Redistributions of source code must retain the above copyright |
07dda51a7a8e
Update license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
10 | notice, this list of conditions and the following disclaimer. |
07dda51a7a8e
Update license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
11 | 2. Redistributions in binary form must reproduce the above copyright |
07dda51a7a8e
Update license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
12 | notice, this list of conditions and the following disclaimer in the |
07dda51a7a8e
Update license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
13 | documentation and/or other materials provided with the distribution. |
07dda51a7a8e
Update license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
14 | 3. Neither the name of the copyright holder nor the names of its |
07dda51a7a8e
Update license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
15 | contributors may be used to endorse or promote products derived from |
07dda51a7a8e
Update license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
16 | this software without specific prior written permission. |
07dda51a7a8e
Update license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
17 | |
07dda51a7a8e
Update license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
07dda51a7a8e
Update license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
07dda51a7a8e
Update license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
20 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
07dda51a7a8e
Update license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER |
07dda51a7a8e
Update license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
22 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
07dda51a7a8e
Update license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
23 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
07dda51a7a8e
Update license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
24 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
07dda51a7a8e
Update license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
07dda51a7a8e
Update license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
07dda51a7a8e
Update license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
07dda51a7a8e
Update license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
07dda51a7a8e
Update license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
29 | */ |
07dda51a7a8e
Update license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
30 | |
81
a18aaf460648
Allow compilation on Windows/MinGW
Teemu Piippo <crimsondusk64@gmail.com>
parents:
73
diff
changeset
|
31 | #include <time.h> |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | #include "rconsession.h" |
23
f7221183a994
- the prompt is now colored
Teemu Piippo <crimsondusk64@gmail.com>
parents:
22
diff
changeset
|
33 | #include "../interface.h" |
88
08ccaf26cffd
Now works with MSVC 2010/pdcurses-win32a
Teemu Piippo <tsapii@utu.fi>
parents:
83
diff
changeset
|
34 | BEGIN_ZFC_NAMESPACE |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | |
167
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
36 | struct PacketHeader |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
37 | { |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
38 | int32_t header; |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
39 | int sequenceNumber; |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
40 | }; |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
41 | |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | // ------------------------------------------------------------------------------------------------- |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | // |
92 | 44 | RCONSession::RCONSession() : |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
45 | m_state(RCON_DISCONNECTED), |
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
46 | m_lastPing(0), |
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
47 | m_adminCount(0), |
167
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
48 | m_lastMissingPacketRequest(0), |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
49 | m_interface(nullptr) |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | { |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
51 | if (not m_socket.set_blocking(false)) |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
52 | { |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
53 | fprintf(stderr, "unable to set socket as non-blocking: %s\n", |
58
d175243ad169
- rcon sessions are no longer allocated on the heap
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
54 | m_socket.error_string().chars()); |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
55 | exit(EXIT_FAILURE); |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
56 | } |
24
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
57 | } |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
58 | |
24
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
59 | // ------------------------------------------------------------------------------------------------- |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
60 | // |
58
d175243ad169
- rcon sessions are no longer allocated on the heap
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
61 | RCONSession::~RCONSession() {} |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
62 | |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
63 | // ------------------------------------------------------------------------------------------------- |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
64 | // |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
65 | void RCONSession::connect(IPAddress address) |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | { |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
67 | m_address = address; |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
68 | m_state = RCON_CONNECTING; |
138
c909c38ca886
Restyled Interface's public method names
Teemu Piippo <teemu@compsta2.com>
parents:
137
diff
changeset
|
69 | m_interface->updateStatusBar(); |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
70 | sendHello(); |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
71 | } |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
72 | |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | // ------------------------------------------------------------------------------------------------- |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
74 | // |
72 | 75 | void RCONSession::disconnect() |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
76 | { |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
77 | if (m_state > RCON_CONNECTING) |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
78 | { |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
79 | // Say goodbye to remote |
157
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
80 | send({CLRC_DISCONNECT}); |
111
51c93a0cc317
Now disconnects properly without instantly quitting
Teemu Piippo <crimsondusk64@gmail.com>
parents:
109
diff
changeset
|
81 | m_interface->disconnected(); |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
82 | } |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
83 | |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
84 | m_state = RCON_DISCONNECTED; |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
85 | } |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
86 | |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
87 | // ------------------------------------------------------------------------------------------------- |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
88 | // |
158
de7574d292ad
Added the ByteArray typedef for Vector<unsigned char>
Teemu Piippo <teemu@compsta2.com>
parents:
157
diff
changeset
|
89 | void RCONSession::send(const ByteArray& packet) |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
90 | { |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
91 | m_socket.send(m_address, packet); |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
92 | } |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
93 | |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
94 | // ------------------------------------------------------------------------------------------------- |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
95 | // |
72 | 96 | void RCONSession::tick() |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
97 | { |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
98 | if (m_state == RCON_DISCONNECTED) |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
99 | return; |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
100 | |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
101 | time_t now; |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
102 | time(&now); |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
103 | |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
104 | if (m_lastPing < now) |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
105 | { |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
106 | if (m_state == RCON_CONNECTING) |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
107 | { |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
108 | sendHello(); |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
109 | } |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
110 | else if (m_state == RCON_AUTHENTICATING) |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
111 | { |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
112 | sendPassword(); |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
113 | } |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
114 | else if (m_state == RCON_CONNECTED and m_lastPing + 5 < now) |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
115 | { |
157
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
116 | send({CLRC_PONG}); |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
117 | bumpLastPing(); |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
118 | } |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
119 | } |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
120 | |
167
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
121 | // Check for new packets in our socket |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
122 | for (Datagram datagram; m_socket.read(datagram);) |
167
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
123 | { |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
124 | // Packet came from the wrong address, ignore |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
125 | if (datagram.address != m_address) |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
126 | continue; |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
127 | |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
128 | // Parse and cut off the header. |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
129 | PacketHeader header; |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
130 | { |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
131 | // Read the header, and find the sequence number |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
132 | Bytestream stream(datagram.message); |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
133 | header.header = stream.readLong(); |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
134 | header.sequenceNumber = (header.header != 0) ? stream.readLong() : -1; |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
135 | datagram.message = datagram.message.splice(stream.position(), datagram.message.size()); |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
136 | } |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
137 | |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
138 | // Try to store this packet into the queue. However, do not try to store packets without a sequence number. |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
139 | bool stored = false; |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
140 | |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
141 | if (header.sequenceNumber != -1) |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
142 | stored = m_packetQueue.addPacket(header.sequenceNumber, datagram.message); |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
143 | |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
144 | // If the packet was not stored, we are to just process it right away. |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
145 | if (stored == false) |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
146 | handlePacket(datagram.message); |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
147 | } |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
148 | |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
149 | // Check if we can now also process some packets from the queue. |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
150 | if (m_packetQueue.hasPacketsToPop()) |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
151 | { |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
152 | ByteArray message; |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
153 | while (m_packetQueue.popNextPacket(message)) |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
154 | handlePacket(message); |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
155 | } |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
156 | |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
157 | // Check whether there are packets stuck in the queue. If this is the case, we have lost some packets and need to |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
158 | // ask the game server to re-send them. |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
159 | if (m_packetQueue.isStuck() and m_lastMissingPacketRequest + 1 < time(NULL)) |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
160 | { |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
161 | m_interface->printWarning("Missing packets detected. Packets currently in queue:\n"); |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
162 | |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
163 | for (int packetNumber : m_packetQueue.getWaitingPackets()) |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
164 | m_interface->printWarning("- %d:\n", packetNumber); |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
165 | |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
166 | m_lastMissingPacketRequest = time(NULL); |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
167 | ByteArray message; |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
168 | Bytestream stream(message); |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
169 | stream.writeByte(CLRC_MISSINGPACKET); |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
170 | |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
171 | for (int packetNumber : m_packetQueue.getLostPackets()) |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
172 | { |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
173 | m_interface->printWarning("Requesting lost packet %d\n", packetNumber); |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
174 | stream.writeLong(packetNumber); |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
175 | } |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
176 | |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
177 | send(message); |
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
178 | } |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
179 | } |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
180 | |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
181 | // ------------------------------------------------------------------------------------------------- |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
182 | // |
167
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
183 | void RCONSession::handlePacket(ByteArray& message) |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
184 | { |
167
0150f86e68f0
Added the PacketQueue class to make use of the sequence numbering to process packets in the correct order, and the ZFC9000 end of packet recovery protocol.
Teemu Piippo <teemu@compsta2.com>
parents:
166
diff
changeset
|
185 | Bytestream stream(message); |
157
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
186 | |
13
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
187 | try |
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
188 | { |
157
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
189 | while (stream.bytesLeft() > 0) |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
190 | { |
157
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
191 | int header = stream.readByte(); |
13
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
192 | |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
193 | switch (ServerResponse(header)) |
13
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
194 | { |
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
195 | case SVRC_OLDPROTOCOL: |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
196 | m_interface->printError("Your RCON client is using outdated protocol.\n"); |
13
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
197 | m_state = RCON_DISCONNECTED; |
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
198 | break; |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
199 | |
13
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
200 | case SVRC_BANNED: |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
201 | m_interface->printError("You have been banned from the server.\n"); |
13
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
202 | m_state = RCON_DISCONNECTED; |
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
203 | break; |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
204 | |
13
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
205 | case SVRC_SALT: |
157
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
206 | m_salt = stream.readString(); |
32
ee770597a281
- added support for in-game colors
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
207 | m_state = RCON_AUTHENTICATING; |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
208 | sendPassword(); |
13
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
209 | break; |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
210 | |
13
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
211 | case SVRC_INVALIDPASSWORD: |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
212 | m_interface->printError("Login failed.\n"); |
13
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
213 | m_state = RCON_DISCONNECTED; |
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
214 | break; |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
215 | |
13
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
216 | case SVRC_MESSAGE: |
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
217 | { |
157
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
218 | String message = stream.readString(); |
32
ee770597a281
- added support for in-game colors
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
219 | message.normalize(); |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
220 | m_interface->printText("%s\n", message.chars()); |
13
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
221 | } |
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
222 | break; |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
223 | |
13
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
224 | case SVRC_LOGGEDIN: |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
225 | m_interface->print("Login successful!\n"); |
157
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
226 | m_serverProtocol = stream.readByte(); |
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
227 | m_hostname = stream.readString(); |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
228 | m_interface->setTitle(m_hostname); |
13
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
229 | m_state = RCON_CONNECTED; |
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
230 | |
157
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
231 | for (int i = stream.readByte(); i > 0; --i) |
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
232 | processServerUpdates(stream); |
12
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
233 | |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
234 | m_interface->print("Previous messages:\n"); |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
235 | |
157
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
236 | for (int i = stream.readByte(); i > 0; --i) |
13
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
237 | { |
157
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
238 | String message = stream.readString(); |
13
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
239 | message.normalize(); |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
240 | m_interface->printText("--- %s\n", message.chars()); |
13
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
241 | } |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
242 | |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
243 | m_interface->print("End of previous messages.\n"); |
104
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
244 | |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
245 | // Watch sv_hostname so that we can update the titlebar when it changes. |
160
cf514fa0f1cc
Fixed compilation problems.
Teemu Piippo <teemu@compsta2.com>
parents:
159
diff
changeset
|
246 | requestWatch("sv_hostname"); |
130
9f54db6f9922
Commit ZFC's end of reliable RCON streams
Teemu Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
247 | m_interface->print ("Watch requested.\n"); |
13
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
248 | break; |
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
249 | |
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
250 | case SVRC_UPDATE: |
157
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
251 | processServerUpdates(stream); |
13
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
252 | break; |
41
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
253 | |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
254 | case SVRC_TOOMANYTABCOMPLETES: |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
255 | { |
157
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
256 | unsigned int numCompletions = stream.readShort(); |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
257 | m_interface->print("%d completions for '%s'.\n", |
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
258 | int(numCompletions), m_lastTabComplete.chars()); |
41
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
259 | } |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
260 | break; |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
261 | |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
262 | case SVRC_TABCOMPLETE: |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
263 | { |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
264 | StringList completes; |
157
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
265 | completes.resize(stream.readByte()); |
41
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
266 | |
137
485cb6d6b98c
Made Range not include the 'max' parameter, replaced a lot of for()-loops with C++11-style range-for-loops
Teemu Piippo <teemu@compsta2.com>
parents:
115
diff
changeset
|
267 | for (String& completion : completes) |
157
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
268 | completion = stream.readString(); |
41
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
269 | |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
270 | if (completes.size() == 1) |
72 | 271 | { |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
272 | m_interface->tabComplete(m_lastTabComplete, completes[0]); |
72 | 273 | } |
41
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
274 | else if (not completes.is_empty()) |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
275 | { |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
276 | m_interface->print("Completions for '%s':\n", m_lastTabComplete.chars()); |
41
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
277 | |
137
485cb6d6b98c
Made Range not include the 'max' parameter, replaced a lot of for()-loops with C++11-style range-for-loops
Teemu Piippo <teemu@compsta2.com>
parents:
115
diff
changeset
|
278 | for (int i : range(0, completes.size(), 8)) |
41
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
279 | { |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
280 | Range<int> spliceRange(i, min(i + 8, completes.size())); |
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
281 | StringList splice(completes.splice(spliceRange)); |
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
282 | m_interface->print("- %s\n", splice.join(", ").chars()); |
41
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
283 | } |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
284 | } |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
285 | } |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
286 | break; |
103
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
287 | |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
288 | case SVRC_WATCHINGCVAR: |
160
cf514fa0f1cc
Fixed compilation problems.
Teemu Piippo <teemu@compsta2.com>
parents:
159
diff
changeset
|
289 | m_interface->print ("You are now watching %s\n", stream.readString().chars()); |
cf514fa0f1cc
Fixed compilation problems.
Teemu Piippo <teemu@compsta2.com>
parents:
159
diff
changeset
|
290 | m_interface->print ("Its value is: %s\n", stream.readString().chars()); |
103
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
291 | break; |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
292 | |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
293 | case SVRC_ALREADYWATCHINGCVAR: |
160
cf514fa0f1cc
Fixed compilation problems.
Teemu Piippo <teemu@compsta2.com>
parents:
159
diff
changeset
|
294 | m_interface->print ("You are already watching %s\n", stream.readString().chars()); |
103
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
295 | break; |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
296 | |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
297 | case SVRC_WATCHCVARNOTFOUND: |
160
cf514fa0f1cc
Fixed compilation problems.
Teemu Piippo <teemu@compsta2.com>
parents:
159
diff
changeset
|
298 | m_interface->print ("CVar %s not found\n", stream.readString().chars()); |
103
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
299 | break; |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
300 | |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
301 | case SVRC_CVARCHANGED: |
104
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
302 | { |
160
cf514fa0f1cc
Fixed compilation problems.
Teemu Piippo <teemu@compsta2.com>
parents:
159
diff
changeset
|
303 | String name = stream.readString(); |
cf514fa0f1cc
Fixed compilation problems.
Teemu Piippo <teemu@compsta2.com>
parents:
159
diff
changeset
|
304 | String value = stream.readString(); |
104
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
305 | m_interface->print ("The value of CVar %s", name.chars()); |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
306 | m_interface->print (" is now %s\n", value.chars()); |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
307 | |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
308 | // If sv_hostname changes, update the titlebar |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
309 | if (name == "sv_hostname") |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
310 | { |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
311 | m_hostname = value; |
151
267ef11bd3ba
Fixed complation problems.
Teemu Piippo <teemu@compsta2.com>
parents:
150
diff
changeset
|
312 | m_interface->setTitle(m_hostname); |
104
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
313 | } |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
314 | } |
103
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
315 | break; |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
316 | |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
317 | case SVRC_YOUREDISCONNECTED: |
160
cf514fa0f1cc
Fixed compilation problems.
Teemu Piippo <teemu@compsta2.com>
parents:
159
diff
changeset
|
318 | m_interface->print ("You have been disconnected: %s\n", stream.readString().chars()); |
103
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
319 | m_interface->disconnected(); |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
320 | break; |
12
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
321 | } |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
322 | } |
13
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
323 | } |
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
324 | catch (std::exception& e) |
09dcaeaa216b
- to hell with that 'ok' field. now throws an exception if attempts to read past the end
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
325 | { |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
326 | m_interface->printWarning("Couldn't process packet: %s\n", e.what()); |
163
5948441a1951
Added the ByteArray::quote() method to return a string representation of the byte array, and used it to print out the contents of unparseable packets.
Teemu Piippo <teemu@compsta2.com>
parents:
158
diff
changeset
|
327 | m_interface->printWarning("Packet contents was: %s\n", message.quote().chars()); |
5948441a1951
Added the ByteArray::quote() method to return a string representation of the byte array, and used it to print out the contents of unparseable packets.
Teemu Piippo <teemu@compsta2.com>
parents:
158
diff
changeset
|
328 | m_interface->printWarning("Stream position in payload was: %d\n", stream.position()); |
12
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
329 | } |
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
330 | } |
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
331 | |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
332 | void RCONSession::processServerUpdates(Bytestream& packet) |
12
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
333 | { |
157
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
334 | int header = packet.readByte(); |
70 | 335 | |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
336 | switch (RCONUpdateType(header)) |
12
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
337 | { |
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
338 | case SVRCU_PLAYERDATA: |
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
339 | { |
47 | 340 | StringList players; |
341 | ||
157
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
342 | for (int i = packet.readByte(); i > 0; --i) |
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
343 | players.append(packet.readString()); |
47 | 344 | |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
345 | m_interface->setPlayerNames(players); |
12
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
346 | } |
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
347 | break; |
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
348 | |
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
349 | case SVRCU_ADMINCOUNT: |
157
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
350 | m_adminCount = packet.readByte(); |
138
c909c38ca886
Restyled Interface's public method names
Teemu Piippo <teemu@compsta2.com>
parents:
137
diff
changeset
|
351 | m_interface->updateStatusBar(); |
12
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
352 | break; |
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
353 | |
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
354 | case SVRCU_MAP: |
157
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
355 | m_level = packet.readString(); |
138
c909c38ca886
Restyled Interface's public method names
Teemu Piippo <teemu@compsta2.com>
parents:
137
diff
changeset
|
356 | m_interface->updateStatusBar(); |
12
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
357 | break; |
70 | 358 | |
359 | default: | |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
360 | m_interface->printWarning("Unknown server update type: %d\n", header); |
70 | 361 | break; |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
362 | } |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
363 | } |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
364 | |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
365 | // ------------------------------------------------------------------------------------------------- |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
366 | // |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
367 | UDPSocket* RCONSession::getSocket() |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
368 | { |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
369 | return &m_socket; |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
370 | } |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
371 | |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
372 | // ------------------------------------------------------------------------------------------------- |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
373 | // |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
374 | void RCONSession::sendHello() |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
375 | { |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
376 | m_interface->print("Connecting to %s...\n", m_address.to_string(IPAddress::WITH_PORT).chars()); |
157
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
377 | send({CLRC_BEGINCONNECTION, RCON_PROTOCOL_VERSION}); |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
378 | bumpLastPing(); |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
379 | } |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
380 | |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
381 | // ------------------------------------------------------------------------------------------------- |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
382 | // |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
383 | void RCONSession::sendPassword() |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
384 | { |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
385 | m_interface->print("Authenticating...\n"); |
158
de7574d292ad
Added the ByteArray typedef for Vector<unsigned char>
Teemu Piippo <teemu@compsta2.com>
parents:
157
diff
changeset
|
386 | ByteArray message; |
157
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
387 | Bytestream stream(message); |
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
388 | stream.writeByte(CLRC_PASSWORD); |
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
389 | stream.writeString((m_salt + m_password).md5()); |
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
390 | send(message); |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
391 | bumpLastPing(); |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
392 | } |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
393 | |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
394 | // ------------------------------------------------------------------------------------------------- |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
395 | // |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
396 | void RCONSession::setPassword(const String& password) |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
397 | { |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
398 | m_password = password; |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
399 | } |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
400 | |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
401 | // ------------------------------------------------------------------------------------------------- |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
402 | // |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
403 | void RCONSession::bumpLastPing() |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
404 | { |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
405 | time_t now; |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
406 | time(&now); |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
407 | m_lastPing = now; |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
408 | } |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
409 | |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
410 | // ------------------------------------------------------------------------------------------------- |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
411 | // |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
412 | bool RCONSession::isActive() const |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
413 | { |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
414 | return getState() != RCON_DISCONNECTED; |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
415 | } |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
416 | |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
417 | // ------------------------------------------------------------------------------------------------- |
17
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
418 | // Returns true if the message was successfully sent. |
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
419 | // |
157
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
420 | bool RCONSession::sendCommand(const String& commandString) |
17
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
421 | { |
157
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
422 | if (m_state != RCON_CONNECTED or commandString.isEmpty()) |
17
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
423 | return false; |
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
424 | |
158
de7574d292ad
Added the ByteArray typedef for Vector<unsigned char>
Teemu Piippo <teemu@compsta2.com>
parents:
157
diff
changeset
|
425 | ByteArray message; |
157
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
426 | Bytestream stream(message); |
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
427 | stream.writeByte(CLRC_COMMAND); |
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
428 | stream.writeString(commandString); |
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
429 | send(message); |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
430 | bumpLastPing(); |
17
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
431 | return true; |
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
432 | } |
24
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
433 | |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
434 | // ------------------------------------------------------------------------------------------------- |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
435 | // |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
436 | RCONSessionState RCONSession::getState() const |
24
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
437 | { |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
438 | return m_state; |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
439 | } |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
440 | |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
441 | // ------------------------------------------------------------------------------------------------- |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
442 | // |
72 | 443 | const IPAddress& RCONSession::address() const |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
444 | { |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
445 | return m_address; |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
446 | } |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
447 | |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
448 | // ------------------------------------------------------------------------------------------------- |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
449 | // |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
450 | int RCONSession::getAdminCount() const |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
451 | { |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
452 | return m_adminCount; |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
453 | } |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
454 | |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
455 | // ------------------------------------------------------------------------------------------------- |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
456 | // |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
457 | const String& RCONSession::getLevel() const |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
458 | { |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
459 | return m_level; |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
460 | } |
41
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
461 | |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
462 | // ------------------------------------------------------------------------------------------------- |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
463 | // |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
464 | void RCONSession::requestTabCompletion(const String& part) |
41
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
465 | { |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
466 | if (m_serverProtocol >= 4) |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
467 | { |
158
de7574d292ad
Added the ByteArray typedef for Vector<unsigned char>
Teemu Piippo <teemu@compsta2.com>
parents:
157
diff
changeset
|
468 | ByteArray message; |
157
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
469 | Bytestream stream(message); |
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
470 | stream.writeByte(CLRC_TABCOMPLETE); |
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
471 | stream.writeString(part); |
42bb29924218
Bytestream now behaves more like a cursor. It does not store the data anymore, rather it leaves the user to specify a vector to use for storage.
Teemu Piippo <teemu@compsta2.com>
parents:
156
diff
changeset
|
472 | send(message); |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
473 | bumpLastPing(); |
41
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
474 | m_lastTabComplete = part; |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
475 | } |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
476 | else |
83
08bfc3d9d2ae
Removed format.cpp and format.h, use built-in formatting instead
Teemu Piippo <crimsondusk64@gmail.com>
parents:
81
diff
changeset
|
477 | { |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
478 | m_interface->print("This server does not support tab-completion\n", m_serverProtocol); |
83
08bfc3d9d2ae
Removed format.cpp and format.h, use built-in formatting instead
Teemu Piippo <crimsondusk64@gmail.com>
parents:
81
diff
changeset
|
479 | } |
88
08ccaf26cffd
Now works with MSVC 2010/pdcurses-win32a
Teemu Piippo <tsapii@utu.fi>
parents:
83
diff
changeset
|
480 | } |
08ccaf26cffd
Now works with MSVC 2010/pdcurses-win32a
Teemu Piippo <tsapii@utu.fi>
parents:
83
diff
changeset
|
481 | |
92 | 482 | // ------------------------------------------------------------------------------------------------- |
483 | // | |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
484 | void RCONSession::setInterface(Interface* interface) |
92 | 485 | { |
156
ce66d7e374bf
Restyled RCONSession method names and paren style
Teemu Piippo <teemu@compsta2.com>
parents:
152
diff
changeset
|
486 | m_interface = interface; |
92 | 487 | } |
488 | ||
106 | 489 | // ------------------------------------------------------------------------------------------------- |
490 | // | |
160
cf514fa0f1cc
Fixed compilation problems.
Teemu Piippo <teemu@compsta2.com>
parents:
159
diff
changeset
|
491 | void RCONSession::requestWatch(const String& cvar) |
104
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
492 | { |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
493 | StringList cvars; |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
494 | cvars.append(cvar); |
160
cf514fa0f1cc
Fixed compilation problems.
Teemu Piippo <teemu@compsta2.com>
parents:
159
diff
changeset
|
495 | requestWatch(cvars); |
104
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
496 | } |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
497 | |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
498 | // ------------------------------------------------------------------------------------------------- |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
499 | // |
160
cf514fa0f1cc
Fixed compilation problems.
Teemu Piippo <teemu@compsta2.com>
parents:
159
diff
changeset
|
500 | void RCONSession::requestWatch(const StringList& cvars) |
104
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
501 | { |
166
af5fa8c43ca8
Fixed compilation problem
Teemu Piippo <teemu@compsta2.com>
parents:
165
diff
changeset
|
502 | ByteArray message; |
160
cf514fa0f1cc
Fixed compilation problems.
Teemu Piippo <teemu@compsta2.com>
parents:
159
diff
changeset
|
503 | Bytestream stream(message); |
cf514fa0f1cc
Fixed compilation problems.
Teemu Piippo <teemu@compsta2.com>
parents:
159
diff
changeset
|
504 | stream.writeByte(CLRC_WATCHCVAR); |
104
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
505 | |
160
cf514fa0f1cc
Fixed compilation problems.
Teemu Piippo <teemu@compsta2.com>
parents:
159
diff
changeset
|
506 | for (const String& cvar : cvars) |
cf514fa0f1cc
Fixed compilation problems.
Teemu Piippo <teemu@compsta2.com>
parents:
159
diff
changeset
|
507 | stream.writeString(cvar.normalized()); |
104
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
508 | |
160
cf514fa0f1cc
Fixed compilation problems.
Teemu Piippo <teemu@compsta2.com>
parents:
159
diff
changeset
|
509 | stream.writeString(""); |
cf514fa0f1cc
Fixed compilation problems.
Teemu Piippo <teemu@compsta2.com>
parents:
159
diff
changeset
|
510 | send(message); |
104
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
511 | } |
106 | 512 | |
105
b4466472aecd
Added some basic IRC-like commands that can be used to do what keystrokes can do without actually using keystrokes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
513 | END_ZFC_NAMESPACE |