… | |
… | |
232 | #define UPD_SP_DAMAGE 0x04 |
232 | #define UPD_SP_DAMAGE 0x04 |
233 | |
233 | |
234 | #define SOUND_NORMAL 0 |
234 | #define SOUND_NORMAL 0 |
235 | #define SOUND_SPELL 1 |
235 | #define SOUND_SPELL 1 |
236 | |
236 | |
|
|
237 | struct data |
|
|
238 | { |
|
|
239 | const void *ptr; |
|
|
240 | unsigned int len; |
|
|
241 | |
|
|
242 | data (const void *ptr, int len) : len (len), ptr (ptr) { } |
|
|
243 | data (const char *str) : len (strlen (str ? str : 0)), ptr ((void *)str) { } |
|
|
244 | data (const shstr &sh) : len (sh.length ()), ptr ((void *)&sh) { } |
|
|
245 | }; |
|
|
246 | |
237 | struct data8 |
247 | struct data8 |
238 | { |
248 | { |
239 | void *data; |
249 | const void *ptr; |
240 | int len; |
250 | unsigned int len; |
241 | |
251 | |
242 | data8 (int len, void *data) : len (len), data (data) { } |
252 | data8 (const void *ptr, int len) : len (len), ptr (ptr) { } |
243 | data8 (const char *str) : len (strlen (str ? str : 0)), data ((void *)str) { } |
253 | data8 (const char *str) : len (strlen (str ? str : 0)), ptr ((void *)str) { } |
244 | data8 (const shstr &sh) : len (sh.length ()), data ((void *)&sh) { } |
254 | data8 (const shstr &sh) : len (sh.length ()), ptr ((void *)&sh) { } |
245 | }; |
255 | }; |
246 | |
256 | |
247 | struct data16 |
257 | struct data16 |
248 | { |
258 | { |
249 | void *data; |
259 | const void *ptr; |
250 | int len; |
260 | unsigned int len; |
251 | |
261 | |
252 | data16 (int len, void *data) : len (len), data (data) { } |
262 | data16 (const void *ptr, int len) : len (len), ptr (ptr) { } |
253 | data16 (const char *str) : len (strlen (str ? str : 0)), data ((void *)str) { } |
263 | data16 (const char *str) : len (strlen (str ? str : 0)), ptr ((void *)str) { } |
254 | data16 (const shstr &sh) : len (sh.length ()), data ((void *)&sh) { } |
264 | data16 (const shstr &sh) : len (sh.length ()), ptr ((void *)&sh) { } |
255 | }; |
265 | }; |
256 | |
266 | |
257 | /* Contains the base information we use to make up a packet we want to send. */ |
267 | /* Contains the base information we use to make up a packet we want to send. */ |
258 | struct SockList |
268 | struct SockList |
259 | { |
269 | { |
… | |
… | |
271 | SockList &operator <<(sint8 v) { return *this << (uint8 )v; } |
281 | SockList &operator <<(sint8 v) { return *this << (uint8 )v; } |
272 | SockList &operator <<(sint16 v) { return *this << (uint16)v; } |
282 | SockList &operator <<(sint16 v) { return *this << (uint16)v; } |
273 | SockList &operator <<(sint32 v) { return *this << (uint32)v; } |
283 | SockList &operator <<(sint32 v) { return *this << (uint32)v; } |
274 | SockList &operator <<(sint64 v) { return *this << (uint64)v; } |
284 | SockList &operator <<(sint64 v) { return *this << (uint64)v; } |
275 | |
285 | |
|
|
286 | SockList &operator <<(const data &v); |
276 | SockList &operator <<(const data8 &v); |
287 | SockList &operator <<(const data8 &v); |
277 | SockList &operator <<(const data16 &v); |
288 | SockList &operator <<(const data16 &v); |
278 | |
289 | |
279 | SockList &operator <<(const char *v); |
290 | SockList &operator <<(const char *v); |
|
|
291 | SockList &operator <<(const shstr &sh) { return *this << data (&sh, sh.length ()); } |
|
|
292 | |
|
|
293 | void printf (const char *format, ...); |
280 | |
294 | |
281 | void free () { ::free (buf); } |
295 | void free () { ::free (buf); } |
282 | |
296 | |
283 | public: |
297 | public: |
284 | uint8 *buf; |
298 | uint8 *buf; |
285 | int len; |
299 | int len; |
286 | }; |
300 | }; |
287 | |
301 | |
288 | inline void SockList_AddChar (SockList *sl, uint8 data) { *sl << data; } |
302 | inline void SockList_AddChar (SockList *sl, uint8 data) { *sl << data; } |
289 | inline void SockList_AddShort(SockList *sl, uint16 data) { *sl << data; } |
303 | inline void SockList_AddShort (SockList *sl, uint16 data) { *sl << data; } |
290 | inline void SockList_AddInt (SockList *sl, uint32 data) { *sl << data; } |
304 | inline void SockList_AddInt (SockList *sl, uint32 data) { *sl << data; } |
291 | inline void SockList_AddInt64(SockList *sl, uint64 data) { *sl << data; } |
305 | inline void SockList_AddInt64 (SockList *sl, uint64 data) { *sl << data; } |
292 | |
306 | |
293 | struct CS_Stats |
307 | struct CS_Stats |
294 | { |
308 | { |
295 | int ibytes; /* ibytes, obytes are bytes in, out */ |
309 | int ibytes; /* ibytes, obytes are bytes in, out */ |
296 | int obytes; |
310 | int obytes; |