Wed, 20 Jul 2016 13:21:46 +0300
Removed duplicate ColoredLine::add_string definition
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 | |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | // ------------------------------------------------------------------------------------------------- |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | // |
92 | 38 | RCONSession::RCONSession() : |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | m_state (RCON_DISCONNECTED), |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
40 | m_lastPing (0), |
72 | 41 | m_numAdmins (0), |
96 | 42 | m_interface (nullptr) |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | { |
58
d175243ad169
- rcon sessions are no longer allocated on the heap
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
44 | 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
|
45 | { |
83
08bfc3d9d2ae
Removed format.cpp and format.h, use built-in formatting instead
Teemu Piippo <crimsondusk64@gmail.com>
parents:
81
diff
changeset
|
46 | 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
|
47 | m_socket.error_string().chars()); |
d175243ad169
- rcon sessions are no longer allocated on the heap
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
48 | exit (EXIT_FAILURE); |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
49 | } |
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
|
50 | } |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
51 | |
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
|
52 | // ------------------------------------------------------------------------------------------------- |
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
|
53 | // |
58
d175243ad169
- rcon sessions are no longer allocated on the heap
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
54 | RCONSession::~RCONSession() {} |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | // ------------------------------------------------------------------------------------------------- |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | // |
72 | 58 | void RCONSession::connect (IPAddress address) |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | { |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | m_address = address; |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | m_state = RCON_CONNECTING; |
72 | 62 | m_interface->update_statusbar(); |
57
a2f41245e387
- restructured rconsession constructor a bit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
47
diff
changeset
|
63 | send_hello(); |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
64 | } |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
65 | |
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 | // |
72 | 68 | void RCONSession::disconnect() |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
69 | { |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
70 | if (m_state > RCON_CONNECTING) |
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 | // Say goodbye to remote |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | Bytestream packet; |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
74 | packet.write_byte (CLRC_DISCONNECT); |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
75 | this->send (packet); |
111
51c93a0cc317
Now disconnects properly without instantly quitting
Teemu Piippo <crimsondusk64@gmail.com>
parents:
109
diff
changeset
|
76 | m_interface->disconnected(); |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
77 | } |
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 | m_state = RCON_DISCONNECTED; |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
80 | } |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
81 | |
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 | // |
72 | 84 | void RCONSession::send (const Bytestream& packet) |
10
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 | m_socket.send (m_address, packet); |
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 | |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
89 | // ------------------------------------------------------------------------------------------------- |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
90 | // |
72 | 91 | void RCONSession::tick() |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
92 | { |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
93 | if (m_state == RCON_DISCONNECTED) |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
94 | return; |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
95 | |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
96 | time_t now; |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
97 | time (&now); |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
98 | |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
99 | if (m_lastPing < now) |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
100 | { |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
101 | if (m_state == RCON_CONNECTING) |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
102 | { |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
103 | send_hello(); |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
104 | } |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
105 | else if (m_state == RCON_AUTHENTICATING) |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
106 | { |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
107 | send_password(); |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
108 | } |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
109 | 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
|
110 | { |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
111 | Bytestream packet; |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
112 | packet.write_byte (CLRC_PONG); |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
113 | send (packet); |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
114 | bump_last_ping(); |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
115 | } |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
116 | } |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
117 | |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
118 | for (Datagram datagram; m_socket.read (datagram);) |
130
9f54db6f9922
Commit ZFC's end of reliable RCON streams
Teemu Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
119 | handle_packet (datagram); |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
120 | } |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
121 | |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
122 | // ------------------------------------------------------------------------------------------------- |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
123 | // |
130
9f54db6f9922
Commit ZFC's end of reliable RCON streams
Teemu Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
124 | void RCONSession::handle_packet (Datagram& datagram) |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
125 | { |
130
9f54db6f9922
Commit ZFC's end of reliable RCON streams
Teemu Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
126 | if (datagram.from != m_address) |
29
e534f2f78196
- handle the 'from' argument in RCONSession::handle_packet to filter out packets from foreign hosts
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
127 | return; |
e534f2f78196
- handle the 'from' argument in RCONSession::handle_packet to filter out packets from foreign hosts
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
128 | |
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
|
129 | 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
|
130 | { |
130
9f54db6f9922
Commit ZFC's end of reliable RCON streams
Teemu Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
131 | Bytestream& packet = datagram.data; |
9f54db6f9922
Commit ZFC's end of reliable RCON streams
Teemu Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
132 | int32_t header = packet.read_long(); |
9f54db6f9922
Commit ZFC's end of reliable RCON streams
Teemu Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
133 | int32_t sequenceNumber = (header != 0) ? packet.read_long() : 0; |
9f54db6f9922
Commit ZFC's end of reliable RCON streams
Teemu Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
134 | m_interface->print("Recieved packet with header 0x%x and sequence number #%d\n", header, sequenceNumber); |
9f54db6f9922
Commit ZFC's end of reliable RCON streams
Teemu Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
135 | |
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
|
136 | while (packet.bytes_left() > 0) |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
137 | { |
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
|
138 | int header = packet.read_byte(); |
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
|
139 | |
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
|
140 | switch (ServerResponse (header)) |
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
|
141 | { |
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
|
142 | case SVRC_OLDPROTOCOL: |
72 | 143 | m_interface->print_error ("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
|
144 | 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
|
145 | break; |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
146 | |
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
|
147 | case SVRC_BANNED: |
72 | 148 | m_interface->print_error ("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
|
149 | 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
|
150 | break; |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
151 | |
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
|
152 | case SVRC_SALT: |
32
ee770597a281
- added support for in-game colors
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
153 | m_salt = packet.read_string(); |
ee770597a281
- added support for in-game colors
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
154 | m_state = RCON_AUTHENTICATING; |
ee770597a281
- added support for in-game colors
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
155 | send_password(); |
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
|
156 | break; |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
157 | |
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
|
158 | case SVRC_INVALIDPASSWORD: |
72 | 159 | m_interface->print_error ("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
|
160 | 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
|
161 | break; |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
162 | |
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
|
163 | 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
|
164 | { |
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
|
165 | String message = packet.read_string(); |
32
ee770597a281
- added support for in-game colors
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
166 | message.normalize(); |
115
bb7ef7c33dad
ZFC's own messages are now printed in blue to distinguish them from messages from the server.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
111
diff
changeset
|
167 | m_interface->print_text ("%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
|
168 | } |
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
|
169 | break; |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
170 | |
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
|
171 | case SVRC_LOGGEDIN: |
72 | 172 | m_interface->print ("Login successful!\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
|
173 | m_serverProtocol = packet.read_byte(); |
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
|
174 | m_hostname = packet.read_string(); |
72 | 175 | m_interface->set_title (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
|
176 | 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
|
177 | |
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
|
178 | for (int i = packet.read_byte(); i > 0; --i) |
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
|
179 | process_server_updates (packet); |
12
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
180 | |
72 | 181 | 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
|
182 | |
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
|
183 | for (int i = packet.read_byte(); i > 0; --i) |
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
|
184 | { |
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
|
185 | String message = packet.read_string(); |
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
|
186 | message.normalize(); |
115
bb7ef7c33dad
ZFC's own messages are now printed in blue to distinguish them from messages from the server.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
111
diff
changeset
|
187 | m_interface->print_text ("--- %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
|
188 | } |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
189 | |
72 | 190 | 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
|
191 | |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
192 | // Watch sv_hostname so that we can update the titlebar when it changes. |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
193 | request_watch("sv_hostname"); |
130
9f54db6f9922
Commit ZFC's end of reliable RCON streams
Teemu Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
194 | 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
|
195 | 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
|
196 | |
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 | case SVRC_UPDATE: |
12
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
198 | process_server_updates (packet); |
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
|
199 | break; |
41
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
200 | |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
201 | case SVRC_TOOMANYTABCOMPLETES: |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
202 | { |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
203 | unsigned int numCompletions = packet.read_short(); |
83
08bfc3d9d2ae
Removed format.cpp and format.h, use built-in formatting instead
Teemu Piippo <crimsondusk64@gmail.com>
parents:
81
diff
changeset
|
204 | m_interface->print ("%d completions for '%s'.\n", |
08bfc3d9d2ae
Removed format.cpp and format.h, use built-in formatting instead
Teemu Piippo <crimsondusk64@gmail.com>
parents:
81
diff
changeset
|
205 | int (numCompletions), m_lastTabComplete.chars()); |
41
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
206 | } |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
207 | break; |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
208 | |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
209 | case SVRC_TABCOMPLETE: |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
210 | { |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
211 | StringList completes; |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
212 | |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
213 | for (signed int i = packet.read_byte(); i > 0; --i) |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
214 | completes << packet.read_string(); |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
215 | |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
216 | if (completes.size() == 1) |
72 | 217 | { |
218 | m_interface->tab_complete (m_lastTabComplete, completes[0]); | |
219 | } | |
41
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
220 | else if (not completes.is_empty()) |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
221 | { |
83
08bfc3d9d2ae
Removed format.cpp and format.h, use built-in formatting instead
Teemu Piippo <crimsondusk64@gmail.com>
parents:
81
diff
changeset
|
222 | 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
|
223 | |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
224 | for (int i = 0; i < completes.size(); i += 8) |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
225 | { |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
226 | Range<int> spliceRange (i, min (i + 8, completes.size() - 1)); |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
227 | StringList splice (completes.splice (spliceRange)); |
83
08bfc3d9d2ae
Removed format.cpp and format.h, use built-in formatting instead
Teemu Piippo <crimsondusk64@gmail.com>
parents:
81
diff
changeset
|
228 | m_interface->print ("- %s\n", splice.join (", ").chars()); |
41
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
229 | } |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
230 | } |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
231 | } |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
232 | break; |
103
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
233 | |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
234 | case SVRC_WATCHINGCVAR: |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
235 | m_interface->print ("You are now watching %s\n", packet.read_string().chars()); |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
236 | m_interface->print ("Its value is: %s\n", packet.read_string().chars()); |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
237 | break; |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
238 | |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
239 | case SVRC_ALREADYWATCHINGCVAR: |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
240 | m_interface->print ("You are already watching %s\n", packet.read_string().chars()); |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
241 | break; |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
242 | |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
243 | case SVRC_WATCHCVARNOTFOUND: |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
244 | m_interface->print ("CVar %s not found\n", packet.read_string().chars()); |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
245 | break; |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
246 | |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
247 | case SVRC_CVARCHANGED: |
104
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
248 | { |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
249 | String name = packet.read_string(); |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
250 | String value = packet.read_string(); |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
251 | 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
|
252 | 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
|
253 | |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
254 | // If sv_hostname changes, update the titlebar |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
255 | if (name == "sv_hostname") |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
256 | { |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
257 | m_hostname = value; |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
258 | m_interface->set_title(m_hostname); |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
259 | } |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
260 | } |
103
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
261 | break; |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
262 | |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
263 | case SVRC_YOUREDISCONNECTED: |
130
9f54db6f9922
Commit ZFC's end of reliable RCON streams
Teemu Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
264 | m_interface->print ("You have been disconnected: %s\n", packet.read_string().chars()); |
103
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
265 | m_interface->disconnected(); |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
266 | break; |
12
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
267 | } |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
268 | } |
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
|
269 | } |
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
|
270 | 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
|
271 | { |
83
08bfc3d9d2ae
Removed format.cpp and format.h, use built-in formatting instead
Teemu Piippo <crimsondusk64@gmail.com>
parents:
81
diff
changeset
|
272 | m_interface->print_warning ("Couldn't process packet: %s\n", e.what()); |
12
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
273 | } |
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
274 | } |
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
275 | |
72 | 276 | void RCONSession::process_server_updates (Bytestream& packet) |
12
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
277 | { |
70 | 278 | int header = packet.read_byte(); |
279 | ||
280 | switch (RCONUpdateType (header)) | |
12
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
281 | { |
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
282 | case SVRCU_PLAYERDATA: |
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
283 | { |
47 | 284 | StringList players; |
285 | ||
12
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
286 | for (int i = packet.read_byte(); i > 0; --i) |
70 | 287 | players.append (packet.read_string()); |
47 | 288 | |
72 | 289 | m_interface->set_player_names (players); |
12
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
290 | } |
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
291 | break; |
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
292 | |
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
293 | case SVRCU_ADMINCOUNT: |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
294 | m_numAdmins = packet.read_byte(); |
72 | 295 | m_interface->update_statusbar(); |
12
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
296 | break; |
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
297 | |
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
298 | case SVRCU_MAP: |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
299 | m_level = packet.read_string(); |
72 | 300 | m_interface->update_statusbar(); |
12
8d0d1b368de0
- rcon session now works! woo!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
301 | break; |
70 | 302 | |
303 | default: | |
72 | 304 | m_interface->print_warning ("Unknown server update type: %d\n", header); |
70 | 305 | break; |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
306 | } |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
307 | } |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
308 | |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
309 | // ------------------------------------------------------------------------------------------------- |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
310 | // |
72 | 311 | UDPSocket* RCONSession::socket() |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
312 | { |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
313 | return &m_socket; |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
314 | } |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
315 | |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
316 | // ------------------------------------------------------------------------------------------------- |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
317 | // |
72 | 318 | void RCONSession::send_hello() |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
319 | { |
88
08ccaf26cffd
Now works with MSVC 2010/pdcurses-win32a
Teemu Piippo <tsapii@utu.fi>
parents:
83
diff
changeset
|
320 | m_interface->print ("Connecting to %s...\n", |
08ccaf26cffd
Now works with MSVC 2010/pdcurses-win32a
Teemu Piippo <tsapii@utu.fi>
parents:
83
diff
changeset
|
321 | m_address.to_string (IPAddress::WITH_PORT).chars()); |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
322 | Bytestream packet; |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
323 | packet.write_byte (CLRC_BEGINCONNECTION); |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
324 | packet.write_byte (RCON_PROTOCOL_VERSION); |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
325 | send (packet); |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
326 | bump_last_ping(); |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
327 | } |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
328 | |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
329 | // ------------------------------------------------------------------------------------------------- |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
330 | // |
72 | 331 | void RCONSession::send_password() |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
332 | { |
72 | 333 | m_interface->print ("Authenticating...\n"); |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
334 | Bytestream packet; |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
335 | packet.write_byte (CLRC_PASSWORD); |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
336 | packet.write_string ((m_salt + m_password).md5()); |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
337 | send (packet); |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
338 | bump_last_ping(); |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
339 | } |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
340 | |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
341 | // ------------------------------------------------------------------------------------------------- |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
342 | // |
72 | 343 | void RCONSession::set_password (const String& password) |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
344 | { |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
345 | m_password = password; |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
346 | } |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
347 | |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
348 | // ------------------------------------------------------------------------------------------------- |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
349 | // |
72 | 350 | void RCONSession::bump_last_ping() |
10
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
351 | { |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
352 | time_t now; |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
353 | time (&now); |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
354 | m_lastPing = now; |
3874575d924d
- begin work on rcon sessions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
355 | } |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
356 | |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
357 | // ------------------------------------------------------------------------------------------------- |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
358 | // |
72 | 359 | bool RCONSession::is_active() const |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
360 | { |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
361 | return state() != RCON_DISCONNECTED; |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
362 | } |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
363 | |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
364 | // ------------------------------------------------------------------------------------------------- |
17
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
365 | // Returns true if the message was successfully sent. |
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
366 | // |
72 | 367 | bool RCONSession::send_command (const String& message) |
17
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
368 | { |
22
77d02446edf0
- don't send empty messages
Teemu Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
369 | if (m_state != RCON_CONNECTED or message.is_empty()) |
17
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
370 | return false; |
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
371 | |
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
372 | Bytestream packet; |
103
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
373 | |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
374 | // Let's hardcode a /watch for CVar watching testing purposes |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
375 | if (message.starts_with ("/watch ")) |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
376 | { |
104
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
377 | request_watch(message.mid(String("/watch ").length(), -1).split(',')); |
103
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
378 | } |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
379 | else |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
380 | { |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
381 | packet.write_byte (CLRC_COMMAND); |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
382 | packet.write_string (message); |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
383 | } |
b78c0ca832a9
CVar watching stuff works now, fixed compilation
Teemu Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
384 | |
17
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
385 | send (packet); |
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
386 | bump_last_ping(); |
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
387 | return true; |
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
388 | } |
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
|
389 | |
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
|
390 | // ------------------------------------------------------------------------------------------------- |
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
|
391 | // |
72 | 392 | RCONSessionState RCONSession::state() 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
|
393 | { |
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
|
394 | 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
|
395 | } |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
396 | |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
397 | // ------------------------------------------------------------------------------------------------- |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
398 | // |
72 | 399 | const IPAddress& RCONSession::address() const |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
400 | { |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
401 | return m_address; |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
402 | } |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
403 | |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
404 | // ------------------------------------------------------------------------------------------------- |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
405 | // |
72 | 406 | int RCONSession::num_admins() const |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
407 | { |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
408 | return m_numAdmins; |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
409 | } |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
410 | |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
411 | // ------------------------------------------------------------------------------------------------- |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
412 | // |
72 | 413 | const String& RCONSession::level() const |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
414 | { |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
415 | return m_level; |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
416 | } |
41
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
417 | |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
418 | // ------------------------------------------------------------------------------------------------- |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
419 | // |
72 | 420 | void RCONSession::request_tab_complete (const String& part) |
41
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
421 | { |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
422 | if (m_serverProtocol >= 4) |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
423 | { |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
424 | Bytestream packet; |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
425 | packet.write_byte (CLRC_TABCOMPLETE); |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
426 | packet.write_string (part); |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
427 | send (packet); |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
428 | bump_last_ping(); |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
429 | m_lastTabComplete = part; |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
430 | } |
9ab869656b9e
- re-commit tab-complete
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
431 | else |
83
08bfc3d9d2ae
Removed format.cpp and format.h, use built-in formatting instead
Teemu Piippo <crimsondusk64@gmail.com>
parents:
81
diff
changeset
|
432 | { |
08bfc3d9d2ae
Removed format.cpp and format.h, use built-in formatting instead
Teemu Piippo <crimsondusk64@gmail.com>
parents:
81
diff
changeset
|
433 | m_interface->print ("This server does not support tab-completion\n", m_serverProtocol); |
08bfc3d9d2ae
Removed format.cpp and format.h, use built-in formatting instead
Teemu Piippo <crimsondusk64@gmail.com>
parents:
81
diff
changeset
|
434 | } |
88
08ccaf26cffd
Now works with MSVC 2010/pdcurses-win32a
Teemu Piippo <tsapii@utu.fi>
parents:
83
diff
changeset
|
435 | } |
08ccaf26cffd
Now works with MSVC 2010/pdcurses-win32a
Teemu Piippo <tsapii@utu.fi>
parents:
83
diff
changeset
|
436 | |
92 | 437 | // ------------------------------------------------------------------------------------------------- |
438 | // | |
439 | void RCONSession::set_interface (Interface* iface) | |
440 | { | |
441 | m_interface = iface; | |
442 | } | |
443 | ||
106 | 444 | // ------------------------------------------------------------------------------------------------- |
445 | // | |
104
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
446 | void RCONSession::request_watch (const String& cvar) |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
447 | { |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
448 | StringList cvars; |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
449 | cvars.append(cvar); |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
450 | request_watch(cvars); |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
451 | } |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
452 | |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
453 | // ------------------------------------------------------------------------------------------------- |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
454 | // |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
455 | void RCONSession::request_watch (const StringList& cvars) |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
456 | { |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
457 | Bytestream packet; |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
458 | packet.write_byte(CLRC_WATCHCVAR); |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
459 | |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
460 | for (int i = 0; i < cvars.size(); ++i) |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
461 | packet.write_string(cvars[i].normalized()); |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
462 | |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
463 | packet.write_string(""); |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
464 | send(packet); |
a76af67a3a4b
Update the titlebar when sv_hostname changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
103
diff
changeset
|
465 | } |
106 | 466 | |
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
|
467 | END_ZFC_NAMESPACE |