1 | |
1 | |
2 | /* |
2 | /* |
3 | * static char *rcsid_loop_c = |
3 | * static char *rcsid_loop_c = |
4 | * "$Id: loop.c,v 1.6 2006/04/22 15:02:48 root Exp $"; |
4 | * "$Id: loop.c,v 1.7 2006/04/28 16:24:03 root Exp $"; |
5 | */ |
5 | */ |
6 | |
6 | |
7 | /* |
7 | /* |
8 | CrossFire, A Multiplayer game for X-windows |
8 | CrossFire, A Multiplayer game for X-windows |
9 | |
9 | |
… | |
… | |
112 | { "command", PlayerCmd, 1}, |
112 | { "command", PlayerCmd, 1}, |
113 | { "ncom", (func_uint8_int_pl)NewPlayerCmd, 1}, |
113 | { "ncom", (func_uint8_int_pl)NewPlayerCmd, 1}, |
114 | { "lookat", LookAt, 1}, |
114 | { "lookat", LookAt, 1}, |
115 | { "lock", (func_uint8_int_pl)LockItem, 1}, |
115 | { "lock", (func_uint8_int_pl)LockItem, 1}, |
116 | { "mark", (func_uint8_int_pl)MarkItem, 1}, |
116 | { "mark", (func_uint8_int_pl)MarkItem, 1}, |
117 | { "mapredraw", MapRedrawCmd, 2}, /* Added: phil */ |
117 | { "mapredraw", MapRedrawCmd, 0}, /* Added: phil */ |
118 | { "mapinfo", MapInfoCmd, 2}, /* CF+ */ |
118 | { "mapinfo", MapInfoCmd, 2}, /* CF+ */ |
119 | { NULL, NULL, 0} /* terminator */ |
119 | { NULL, NULL, 0} /* terminator */ |
120 | }; |
120 | }; |
121 | |
121 | |
122 | /** Face-related commands */ |
122 | /** Face-related commands */ |
… | |
… | |
384 | ns->inbuf.buf[ns->inbuf.len]='\0'; /* Terminate buffer - useful for string data */ |
384 | ns->inbuf.buf[ns->inbuf.len]='\0'; /* Terminate buffer - useful for string data */ |
385 | for (i=0; nscommands[i].cmdname !=NULL; i++) { |
385 | for (i=0; nscommands[i].cmdname !=NULL; i++) { |
386 | if (strcmp((char*)ns->inbuf.buf+2,nscommands[i].cmdname)==0) { |
386 | if (strcmp((char*)ns->inbuf.buf+2,nscommands[i].cmdname)==0) { |
387 | nscommands[i].cmdproc((char*)data,len,ns); |
387 | nscommands[i].cmdproc((char*)data,len,ns); |
388 | ns->inbuf.len=0; |
388 | ns->inbuf.len=0; |
389 | return;//D |
389 | return;//D// not doing this causes random memory corruption |
390 | goto next_packet; |
390 | goto next_packet; |
391 | } |
391 | } |
392 | } |
392 | } |
393 | /* Player must be in the playing state or the flag on the |
393 | /* Player must be in the playing state or the flag on the |
394 | * the command must be zero for the user to use the command - |
394 | * the command must be zero for the user to use the command - |
… | |
… | |
400 | if (pl) for (i=0; plcommands[i].cmdname !=NULL; i++) { |
400 | if (pl) for (i=0; plcommands[i].cmdname !=NULL; i++) { |
401 | if (strcmp((char*)ns->inbuf.buf+2,plcommands[i].cmdname)==0) { |
401 | if (strcmp((char*)ns->inbuf.buf+2,plcommands[i].cmdname)==0) { |
402 | if (pl->state == ST_PLAYING || !(plcommands[i].flag & 1)) |
402 | if (pl->state == ST_PLAYING || !(plcommands[i].flag & 1)) |
403 | plcommands[i].cmdproc((char*)data,len,pl); |
403 | plcommands[i].cmdproc((char*)data,len,pl); |
404 | ns->inbuf.len=0; |
404 | ns->inbuf.len=0; |
|
|
405 | //D// not doing this causes random memory corruption |
405 | if (plcommands[i].flag & 2) |
406 | if (plcommands[i].flag & 2) |
406 | goto next_packet; |
407 | goto next_packet; |
407 | return; |
408 | return; |
408 | } |
409 | } |
409 | } |
410 | } |