Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cube_network.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <enet/enet.h> // for ENetPacket
4 #include <stdarg.h> // for va_list
5 #include <stddef.h> // for size_t
6 #include <algorithm>
7 
8 #include "inexor/network/legacy/buffer_types.hpp" // for ucharbuf, packetbu...
9 #include "inexor/shared/cube_types.hpp" // for uchar
10 #include "inexor/shared/cube_vector.hpp" // for vector
11 
12 struct stream;
13 
14 #define MAXCLIENTS 128 // DO NOT set this any higher
15 #define MAXTRANS 5000 // max amount of data to swallow in 1 go
16 
17 
18 
20 #define DMF 16.0f
21 #define DNF 100.0f
22 #define DVELF 1.0f
23 
24 extern void putint(ucharbuf &p, int n);
25 extern void putint(packetbuf &p, int n);
26 extern void putint(vector<uchar> &p, int n);
27 extern int getint(ucharbuf &p);
28 extern void putuint(ucharbuf &p, int n);
29 extern void putuint(packetbuf &p, int n);
30 extern void putuint(vector<uchar> &p, int n);
31 extern int getuint(ucharbuf &p);
32 extern void putfloat(ucharbuf &p, float f);
33 extern void putfloat(packetbuf &p, float f);
34 extern void putfloat(vector<uchar> &p, float f);
35 extern float getfloat(ucharbuf &p);
36 extern void sendstring(const char *t, ucharbuf &p);
37 extern void sendstring(const char *t, packetbuf &p);
38 extern void sendstring(const char *t, vector<uchar> &p);
39 extern void getstring(char *t, ucharbuf &p, size_t len);
40 template<size_t N> static inline void getstring(char(&t)[N], ucharbuf &p) { getstring(t, p, N); }
41 extern void filtertext(char *dst, const char *src, bool whitespace, bool forcespace, size_t len);
42 template<size_t N> static inline void filtertext(char(&dst)[N], const char *src, bool whitespace = true, bool forcespace = false) { filtertext(dst, src, whitespace, forcespace, N-1); }
43 
45 struct ipmask
46 {
47  enet_uint32 ip, mask;
48 
49  void parse(const char *name);
50  int print(char *buf) const;
51  bool check(enet_uint32 host) const { return (host & mask) == ip; }
52 };
53 
56 extern ENetPacket *make_file_packet(stream *file, const char *format, va_list args);
57 
enet_uint32 ip
Definition: cube_network.hpp:47
void putuint(ucharbuf &p, int n)
Definition: cube_network.cpp:63
void putfloat(ucharbuf &p, float f)
Definition: cube_network.cpp:86
void putint(ucharbuf &p, int n)
Definition: cube_network.cpp:27
void getstring(char *t, ucharbuf &p, size_t len)
Definition: cube_network.cpp:107
template implementation of buffers (networking e.g.).
Definition: buffer_types.hpp:14
enet_uint32 mask
Definition: cube_network.hpp:47
ENetPacket * make_file_packet(stream *file, const char *format, va_list args)
Puts a file into a ENet packet.
Definition: cube_network.cpp:140
int getuint(ucharbuf &p)
Definition: cube_network.cpp:67
int print(char *buf) const
Definition: cube_network.cpp:195
float getfloat(ucharbuf &p)
Definition: cube_network.cpp:90
int getint(ucharbuf &p)
Definition: cube_network.cpp:31
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
Definition: glexts.hpp:299
ICOMMAND * f(float *a, float *b), floatret(*a **b)
void format(tagval *args, int numargs)
Definition: command.cpp:2584
void filtertext(char *dst, const char *src, bool whitespace, bool forcespace, size_t len)
Definition: cube_network.cpp:118
void sendstring(const char *t, ucharbuf &p)
Definition: cube_network.cpp:103
structure to describe IPs
Definition: cube_network.hpp:45
void t(T x, const char *cmp)
Definition: utilTest.cpp:52
Legacy file system streams.
Definition: stream.hpp:22
static aviwriter * file
Definition: movie.cpp:830
network packet buffer
Definition: buffer_types.hpp:132
void parse(const char *name)
Definition: cube_network.cpp:166
bool check(enet_uint32 host) const
Definition: cube_network.hpp:51