From ca019ecd6715557a572ac9a56de556434f9b31aa Mon Sep 17 00:00:00 2001 From: oroborus Date: Sun, 6 Jul 2008 19:36:04 +0000 Subject: - podpora chatu :) git-svn-id: http://opensvn.csie.org/tuxanci_ng@109 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e --- src/base/proto.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'src/base/proto.c') diff --git a/src/base/proto.c b/src/base/proto.c index 722d443..b5f8d39 100644 --- a/src/base/proto.c +++ b/src/base/proto.c @@ -27,6 +27,7 @@ #include "client.h" #include "term.h" #include "radar.h" +#include "chat.h" #endif #ifdef PUBLIC_SERVER @@ -687,6 +688,60 @@ void proto_recv_shot_client(char *msg) #ifndef PUBLIC_SERVER +void proto_send_chat_client(char *s) +{ + char msg[STR_PROTO_SIZE]; + sprintf(msg, "chat %s\n", s); + sendServer(msg); +} + +#endif + +void proto_recv_chat_server(client_t *client, char *msg) +{ + char out[STR_PROTO_SIZE]; + int len; + + if( client->tux == NULL ) + { + return; + } + + len = strlen(msg); + msg[len-1] = '\0'; + + snprintf(out, STR_PROTO_SIZE, "chat %s:%s\n", client->tux->name, msg+5); + + proto_send_chat_server(PROTO_SEND_ALL, NULL, out); +} + +void proto_send_chat_server(int type, client_t *client, char *msg) +{ + protoSendClient(type, client, msg, CHECK_FORNT_TYPE_SIMPLE, CHECK_FRONT_ID_NONE); + +#ifndef PUBLIC_SERVER + proto_recv_chat_client(msg); +#endif +} + +#ifndef PUBLIC_SERVER + +void proto_recv_chat_client(char *msg) +{ + int len; + + assert( msg != NULL ); + + len = strlen(msg); + msg[len-1] = '\0'; + + addToChat(msg+5); +} + +#endif + +#ifndef PUBLIC_SERVER + void proto_send_ping_client() { char msg[STR_PROTO_SIZE]; -- cgit v1.2.3