1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
//
// network.c
// Duke3D
//
// Created by fabien sanglard on 12-12-22.
// Copyright (c) 2012 fabien sanglard. All rights reserved.
//
#include "network.h"
int nNetMode = 0;
//#include "mmulti_stable.h"
void Setup_UnstableNetworking()
{
nNetMode = 0;
}
void Setup_StableNetworking()
{
nNetMode = 1;
}
//TODO ( "[Fix this horrible networking mess. Function pointers not happy]" )
// I do not like this one bit.
// Figure out what was causing the problems with the function pointers.
// This mess is a direct result of my lack of time.. bleh
// This mess shouldn't even be in this file. /slap /slap
void callcommit(void)
{
#ifndef USER_DUMMY_NETWORK
switch(nNetMode)
{
case 0:
unstable_callcommit();
break;
case 1:
stable_callcommit();
break;
}
#endif
}
void initcrc(void)
{
#ifndef USER_DUMMY_NETWORK
switch(nNetMode)
{
case 0:
unstable_initcrc();
break;
case 1:
stable_initcrc();
break;
}
#endif
}
int32_t getcrc(uint8_t *buffer, short bufleng)
{
#ifndef USER_DUMMY_NETWORK
switch(nNetMode)
{
case 0:
return unstable_getcrc(buffer, bufleng);
case 1:
return stable_getcrc(buffer, bufleng);
}
#endif
return 0;
}
void initmultiplayers(uint8_t damultioption, uint8_t dacomrateoption, uint8_t dapriority)
{
#ifndef USER_DUMMY_NETWORK
switch(nNetMode)
{
case 0:
unstable_initmultiplayers(damultioption, dacomrateoption, dapriority);
break;
case 1:
stable_initmultiplayers(damultioption, dacomrateoption, dapriority);
break;
}
#endif
}
void sendpacket(int32_t other, uint8_t *bufptr, int32_t messleng)
{
#ifndef USER_DUMMY_NETWORK
switch(nNetMode)
{
case 0:
unstable_sendpacket(other, bufptr, messleng);
break;
case 1:
stable_sendpacket(other, bufptr, messleng);
break;
}
#endif
}
void setpackettimeout(int32_t datimeoutcount, int32_t daresendagaincount)
{
#ifndef USER_DUMMY_NETWORK
switch(nNetMode)
{
case 0:
unstable_setpackettimeout(datimeoutcount, daresendagaincount);
break;
case 1:
stable_setpackettimeout(datimeoutcount, daresendagaincount);
break;
}
#endif
}
void uninitmultiplayers(void)
{
#ifndef USER_DUMMY_NETWORK
switch(nNetMode)
{
case 0:
unstable_uninitmultiplayers();
break;
case 1:
stable_uninitmultiplayers();
break;
}
#endif
}
void sendlogon(void)
{
#ifndef USER_DUMMY_NETWORK
switch(nNetMode)
{
case 0:
unstable_sendlogon();
break;
case 1:
unstable_sendlogon();
break;
}
#endif
}
void sendlogoff(void)
{
#ifndef USER_DUMMY_NETWORK
switch(nNetMode)
{
case 0:
unstable_sendlogoff();
break;
case 1:
stable_sendlogoff();
break;
}
#endif
}
int getoutputcirclesize(void)
{
#ifndef USER_DUMMY_NETWORK
switch(nNetMode)
{
case 0:
return unstable_getoutputcirclesize();
case 1:
return stable_getoutputcirclesize();
}
#endif
return 0;
}
void setsocket(short newsocket)
{
#ifndef USER_DUMMY_NETWORK
switch(nNetMode)
{
case 0:
unstable_setsocket(newsocket);
break;
case 1:
stable_setsocket(newsocket);
break;
}
#endif
}
short getpacket(short *other, uint8_t *bufptr)
{
#ifndef USER_DUMMY_NETWORK
switch(nNetMode)
{
case 0:
return unstable_getpacket(other, bufptr); // default
case 1:
return stable_getpacket(other, bufptr);
}
#endif
return 0;
}
void flushpackets(void)
{
#ifndef USER_DUMMY_NETWORK
switch(nNetMode)
{
case 0:
unstable_flushpackets();
break;
case 1:
stable_flushpackets();
break;
}
#endif
}
void genericmultifunction(int32_t other, char *bufptr, int32_t messleng, int32_t command)
{
#ifndef USER_DUMMY_NETWORK
switch(nNetMode)
{
case 0:
unstable_genericmultifunction(other, bufptr, messleng, command);
break;
case 1:
stable_genericmultifunction(other, bufptr, messleng, command);
break;
}
#endif
}
|