--- deliantra/server/socket/lowlevel.C 2007/03/01 12:28:17 1.34 +++ deliantra/server/socket/lowlevel.C 2007/04/24 00:42:03 1.40 @@ -192,19 +192,20 @@ {"command", PC(PlayerCmd) PF_PLAYING | PF_COMMAND0 }, {"examine", PC(ExamineCmd) PF_PLAYING }, + {"ex", PC(ExCmd) PF_PLAYING }, {"apply", PC(ApplyCmd) PF_PLAYING }, {"lookat", PC(LookAt) PF_PLAYING }, {"lock", PC(LockItem) PF_PLAYING }, {"mark", PC(MarkItem) PF_PLAYING }, {"move", PC(MoveCmd) PF_PLAYING }, - {"ext", PC(ExtCmd) 0 }, /* CF+ */ - {"mapredraw", PC(MapRedrawCmd) 0 }, /* Added: phil */ - {"mapinfo", PC(MapInfoCmd) 0 }, /* CF+ */ + {"ext", PC(ExtCmd) 0 }, // CF+ + {"mapredraw", PC(MapRedrawCmd) 0 }, + {"mapinfo", PC(MapInfoCmd) 0 }, // CF+ {"reply", SC(ReplyCmd) 0 }, - {"exti", SC(ExtiCmd) 0 }, /* CF+ */ + {"exti", SC(ExtiCmd) 0 }, // CF+ {"addme", SC(AddMeCmd) 0 }, - {"askface", SC(SendFaceCmd) 0 }, /* Added: phil */ + {"askface", SC(AskFaceCmd) 0 }, {"requestinfo", SC(RequestInfo) 0 }, {"setfacemode", SC(SetFaceMode) 0 }, {"setsound", SC(SetSound) 0 }, @@ -418,7 +419,9 @@ if (len + outputbuffer.len > SOCKETBUFSIZE) { LOG (llevDebug, "socket on fd %d has overrun internal buffer - marking as dead\n", fd); - destroy (); + // shutdown the socket, this is safer than destroying it immediately + // as lots of code in the callchain might still access the map etc. + shutdown (fd, SHUT_RDWR); return; } @@ -504,6 +507,28 @@ send_packet (sl); } +void +client::send_drawinfo (const char *msg, int flags) +{ + send_packet_printf ("drawinfo %d %s", flags, msg); +} + +void +client::send_msg (int color, const char *type, const char *msg) +{ + if (can_msg) + send_packet_printf ("msg %d %s %s", color, type, msg); + else if (color < 0) + return; // client cannot handle this + else if (strchr (msg, '<') || strchr (msg, '&')) + { + //TODO: should escape/modify to old syntax + send_packet_printf ("drawinfo %d %s", color, msg); + } + else + send_packet_printf ("drawinfo %d %s", color, msg); +} + /*********************************************************************** * * packet functions/utilities @@ -519,6 +544,24 @@ *cur++ = ' '; } +packet &packet::operator <<(const ber32 v) +{ + enum { maxlen = 32 / 7 + 1}; + uint8 buf[maxlen]; + uint8 *p = buf + maxlen; + uint32 val = v.val; + + *--p = val & 0x7F; + + while (val > 0x7F) + { + val >>= 7; + *--p = (val & 0x7F) | 0x80; + } + + return *this << data (p, buf + maxlen - p); +} + packet &packet::operator <<(const data &v) { if (room () < v.len)