MCPcopy Create free account
hub / github.com/TASEmulators/fceux / NetplayUpdate

Function NetplayUpdate

src/netplay.cpp:201–329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199}
200
201void NetplayUpdate(uint8 *joyp)
202{
203 static uint8 buf[5]; /* 4 play states, + command/extra byte */
204 static uint8 joypb[4];
205
206 memcpy(joypb,joyp,4);
207
208 /* This shouldn't happen, but just in case. 0xFF is used as a command escape elsewhere. */
209 if(joypb[0] == 0xFF)
210 joypb[0] = 0xF;
211 if(!netdcount)
212 if(!FCEUD_SendData(joypb,numlocal))
213 {
214 NetError();
215 return;
216 }
217
218 if(!netdcount)
219 {
220 do
221 {
222 if(!FCEUD_RecvData(buf,5))
223 {
224 NetError();
225 return;
226 }
227
228 switch(buf[4])
229 {
230 default: FCEU_DoSimpleCommand(buf[4]);break;
231 case FCEUNPCMD_TEXT:
232 {
233 uint8 *tbuf;
234 uint32 len = FCEU_de32lsb(buf);
235
236 if(len > 100000) // Insanity check!
237 {
238 NetError();
239 return;
240 }
241 tbuf = (uint8*)malloc(len + 1); //mbg merge 7/17/06 added cast
242 tbuf[len] = 0;
243 if(!FCEUD_RecvData(tbuf, len))
244 {
245 NetError();
246 free(tbuf);
247 return;
248 }
249 FCEUD_NetplayText(tbuf);
250 free(tbuf);
251 }
252 break;
253 case FCEUNPCMD_SAVESTATE:
254 {
255 //mbg todo netplay
256 //char *fn;
257 //FILE *fp;
258

Callers 1

FCEU_UpdateInputFunction · 0.85

Calls 9

NetErrorFunction · 0.85
FCEU_DoSimpleCommandFunction · 0.85
FCEU_de32lsbFunction · 0.85
FetchFileFunction · 0.85
FCEU_FlushGameCheatsFunction · 0.85
FCEU_LoadGameCheatsFunction · 0.85
FCEUD_SendDataFunction · 0.50
FCEUD_RecvDataFunction · 0.50
FCEUD_NetplayTextFunction · 0.50

Tested by

no test coverage detected