ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/network.h
(Generate patch)

Comparing deliantra/server/include/network.h (file contents):
Revision 1.32 by root, Tue Jan 3 11:25:32 2012 UTC vs.
Revision 1.36 by root, Wed Nov 14 23:24:27 2018 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2018 Marc Alexander Lehmann / the Deliantra team
4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 5 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team 6 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992 Frank Tore Johansen 7 * Copyright (©) 1992 Frank Tore Johansen
7 * 8 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 9 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 10 * the terms of the Affero GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your 11 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version. 12 * option) any later version.
12 * 13 *
13 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 17 * GNU General Public License for more details.
17 * 18 *
18 * You should have received a copy of the Affero GNU General Public License 19 * You should have received a copy of the Affero GNU General Public License
19 * and the GNU General Public License along with this program. If not, see 20 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>. 21 * <http://www.gnu.org/licenses/>.
21 * 22 *
22 * The authors can be reached via e-mail to <support@deliantra.net> 23 * The authors can be reached via e-mail to <support@deliantra.net>
23 */ 24 */
24 25
25/* This file defines various flags that both the new client and 26/* This file defines various flags that both the new client and
26 * newserver uses. These should never be changed, only expanded. 27 * newserver uses. These should never be changed, only expanded.
58 59
59#define CS_QUERY_YESNO 0x1 /* Yes/no question */ 60#define CS_QUERY_YESNO 0x1 /* Yes/no question */
60#define CS_QUERY_SINGLECHAR 0x2 /* Single character response expected */ 61#define CS_QUERY_SINGLECHAR 0x2 /* Single character response expected */
61#define CS_QUERY_HIDEINPUT 0x4 /* Hide input being entered */ 62#define CS_QUERY_HIDEINPUT 0x4 /* Hide input being entered */
62 63
63/* These are multiplication values that should be used when changing 64/* These are multiplication values that should be used when changing
64 * floats to ints, and vice version. MULTI is integer representatin 65 * floats to ints, and vice version. MULTI is integer representatin
65 * (float to int), MULTF is float, for going from int to float. 66 * (float to int), MULTF is float, for going from int to float.
66 */ 67 */
67#define FLOAT_MULTI 100000 68#define FLOAT_MULTI 100000
68#define FLOAT_MULTF 100000.0 69#define FLOAT_MULTF 100000.0
183#define SOUND_NORMAL 0 184#define SOUND_NORMAL 0
184#define SOUND_SPELL 1 185#define SOUND_SPELL 1
185 186
186//-GPL 187//-GPL
187 188
189template<int unique>
188struct data 190struct databuf
189{ 191{
190 unsigned int len; 192 unsigned int len;
191 const void *ptr; 193 const void *ptr;
192 194
193 data (const void *ptr, int len) : len (len), ptr (ptr) { } 195 databuf (const void *ptr, int len) : len (len), ptr (ptr) { }
194 data (const char *str) : len (strlen (str ? str : 0)), ptr ((void *)str) { } 196 databuf (const char *str) : len (strlen (str ? str : 0)), ptr ((void *)str) { }
195 data (shstr_tmp sh) : len (sh.length ()), ptr ((void *)&sh) { } 197 databuf (shstr_tmp sh) : len (sh.length ()), ptr ((void *)&sh) { }
196 data (dynbuf &buf) : len (buf.size ()), ptr (buf.linearise ()) { } 198 databuf (dynbuf &buf) : len (buf.size ()), ptr (buf.linearise ()) { }
197}; 199};
198 200
199struct data8 201using data_n = databuf<0>;
200{ 202using data8 = databuf<1>;
201 unsigned int len; 203using data16 = databuf<2>;
202 const void *ptr;
203
204 data8 (const void *ptr, int len) : len (len), ptr (ptr) { }
205 data8 (const char *str) : len (strlen (str ? str : 0)), ptr ((void *)str) { }
206 data8 (shstr_tmp sh) : len (sh.length ()), ptr ((void *)&sh) { }
207 data8 (dynbuf &buf) : len (buf.size ()), ptr (buf.linearise ()) { }
208};
209
210struct data16
211{
212 unsigned int len;
213 const void *ptr;
214
215 data16 (const void *ptr, int len) : len (len), ptr (ptr) { }
216 data16 (const char *str) : len (strlen (str ? str : 0)), ptr ((void *)str) { }
217 data16 (shstr_tmp sh) : len (sh.length ()), ptr ((void *)&sh) { }
218 data16 (dynbuf &buf) : len (buf.size ()), ptr (buf.linearise ()) { }
219};
220 204
221struct ber32 205struct ber32
222{ 206{
223 enum { size = 5 }; // maximum length of an encoded ber32 207 enum { size = 5 }; // maximum length of an encoded ber32
224 uint32 val; 208 uint32 val;
276 packet &operator <<(sint64 v) { return *this << (uint64)v; } 260 packet &operator <<(sint64 v) { return *this << (uint64)v; }
277 261
278 // checked 262 // checked
279 packet &operator <<(const ber32 v); 263 packet &operator <<(const ber32 v);
280 264
281 packet &operator <<(const data &v); 265 packet &operator <<(const data_n &v);
282 packet &operator <<(const data8 &v); 266 packet &operator <<(const data8 &v);
283 packet &operator <<(const data16 &v); 267 packet &operator <<(const data16 &v);
284 268
285 packet &operator <<(const char *v); 269 packet &operator <<(const char *v);
286 packet &operator <<(shstr_tmp sh) { return *this << data (sh); } 270 packet &operator <<(shstr_tmp sh) { return *this << data_n (sh); }
287 packet &operator <<(const std::string &s) { return *this << data (s.data (), s.size ()); } 271 packet &operator <<(const std::string &s) { return *this << data_n (s.data (), s.size ()); }
288 272
289 void vprintf (const char *format, va_list ap); 273 void vprintf (const char *format, va_list ap);
290 274
291 void printf (const char *format, ...) attribute ((format (printf, 2, 3))) 275 void printf (const char *format, ...) attribute ((format (printf, 2, 3)))
292 { 276 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines