--- deliantra/server/socket/lowlevel.C 2006/12/17 19:14:00 1.25 +++ deliantra/server/socket/lowlevel.C 2006/12/19 04:58:05 1.26 @@ -42,14 +42,13 @@ # include # include # include -# define TCP_HZ 1000 // sorry... # include #endif // use a really low timeout, as it doesn't cost any bandwidth, and you can // easily die in 20 seconds... -#define SOCKET_TIMEOUT1 10 -#define SOCKET_TIMEOUT2 20 +#define SOCKET_TIMEOUT1 10 * 1000 +#define SOCKET_TIMEOUT2 20 * 1000 void client::flush () @@ -66,8 +65,8 @@ rtt = tcpi.tcpi_rtt; rttvar = tcpi.tcpi_rttvar; - if (tcpi.tcpi_unacked && SOCKET_TIMEOUT1 * TCP_HZ < diff && diff < 0x80000000UL // ack delayed for 20s - && SOCKET_TIMEOUT2 * TCP_HZ < tcpi.tcpi_last_data_sent) // no data sent for 10s + if (tcpi.tcpi_unacked && SOCKET_TIMEOUT1 < diff && diff < 0x80000000UL // ack delayed for 20s + && SOCKET_TIMEOUT2 < tcpi.tcpi_last_data_sent) // no data sent for 10s { LOG (llevDebug, "Connection on fd %d closed due to ack timeout (%u/%u/%u)\n", fd, (unsigned) tcpi.tcpi_last_ack_recv, (unsigned) tcpi.tcpi_last_data_sent, (unsigned) tcpi.tcpi_unacked); @@ -190,26 +189,26 @@ {"examine", PC(ExamineCmd) PF_PLAYING }, {"apply", PC(ApplyCmd) PF_PLAYING }, - {"reply", PC(ReplyCmd) PF_IMMEDIATE }, + {"reply", PC(ReplyCmd) 0 }, {"lookat", PC(LookAt) PF_PLAYING }, {"lock", PC(LockItem) PF_PLAYING }, {"mark", PC(MarkItem) PF_PLAYING }, {"move", PC(MoveCmd) PF_PLAYING }, - {"exti", PC(ExtCmd) PF_IMMEDIATE }, /* CF+ */ {"ext", PC(ExtCmd) 0 }, /* CF+ */ - {"mapredraw", PC(MapRedrawCmd) PF_IMMEDIATE }, /* Added: phil */ + {"mapredraw", PC(MapRedrawCmd) 0 }, /* Added: phil */ {"mapinfo", PC(MapInfoCmd) 0 }, /* CF+ */ - {"addme", SC(AddMeCmd) PF_IMMEDIATE }, - {"askface", SC(SendFaceCmd) PF_IMMEDIATE }, /* Added: phil */ - {"requestinfo", SC(RequestInfo) PF_IMMEDIATE }, - {"setfacemode", SC(SetFaceMode) PF_IMMEDIATE }, - {"setsound", SC(SetSound) PF_IMMEDIATE }, - {"setup", SC(SetUp) PF_IMMEDIATE }, - {"version", SC(VersionCmd) PF_IMMEDIATE }, - {"toggleextendedinfos", SC(ToggleExtendedInfos) PF_IMMEDIATE }, /*Added: tchize */ - {"toggleextendedtext", SC(ToggleExtendedText) PF_IMMEDIATE }, /*Added: tchize */ - {"asksmooth", SC(AskSmooth) PF_IMMEDIATE }, /*Added: tchize (smoothing technologies) */ + {"exti", SC(ExtiCmd) 0 }, /* CF+ */ + {"addme", SC(AddMeCmd) 0 }, + {"askface", SC(SendFaceCmd) 0 }, /* Added: phil */ + {"requestinfo", SC(RequestInfo) 0 }, + {"setfacemode", SC(SetFaceMode) 0 }, + {"setsound", SC(SetSound) 0 }, + {"setup", SC(SetUp) 0 }, + {"version", SC(VersionCmd) 0 }, + {"toggleextendedinfos", SC(ToggleExtendedInfos) 0 }, /*Added: tchize */ + {"toggleextendedtext", SC(ToggleExtendedText) 0 }, /*Added: tchize */ + {"asksmooth", SC(AskSmooth) 0 }, /*Added: tchize (smoothing technologies) */ }; bool @@ -273,18 +272,15 @@ for (packet_type *pkt = packets; pkt < packets + (sizeof (packets) / sizeof (packets[0])); ++pkt) if (!strcmp ((char *)inbuf + 2, pkt->name)) { - if (pkt->flags & PF_IMMEDIATE) - execute (pkt, data, datalen); - else + if (pkt->flags & PF_PLAYER) queue_command (pkt, data, datalen); + else + execute (pkt, data, datalen); goto next_packet; } - /* If we get here, we didn't find a valid command. Logging - * this might be questionable, because a broken client/malicious - * user could certainly send a whole bunch of invalid commands. - */ + // If we get here, we didn't find a valid command. send_packet_printf ("drawinfo %d ERROR: command '%s' not supported.", NDI_RED, (char *)inbuf + 2); next_packet: skip_packet (pkt_len); @@ -361,7 +357,7 @@ void client::cmd_cb (iw &w) { - if (handle_packet () || handle_command ()) + if (handle_packet ()) w.start (); else flush ();