summaryrefslogtreecommitdiff
path: root/src/base
diff options
context:
space:
mode:
authororoborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-07-06 19:36:04 +0000
committeroroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-07-06 19:36:04 +0000
commitca019ecd6715557a572ac9a56de556434f9b31aa (patch)
tree5e39db57af3433dd7b44162cdf5f388111e091fb /src/base
parent05f2c8aacf46e643b2bd916b7c8139e8a259122a (diff)
- podpora chatu :)
git-svn-id: http://opensvn.csie.org/tuxanci_ng@109 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src/base')
-rw-r--r--src/base/proto.c55
-rw-r--r--src/base/proto.h4
-rw-r--r--src/base/server.c6
3 files changed, 65 insertions, 0 deletions
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];
diff --git a/src/base/proto.h b/src/base/proto.h
index 116562b..bcc8f42 100644
--- a/src/base/proto.h
+++ b/src/base/proto.h
@@ -69,6 +69,10 @@ extern void proto_recv_additem_client(char *msg);
extern void proto_send_shot_server(int type, client_t *client, shot_t *p);
extern void proto_recv_shot_client(char *msg);
extern void proto_send_ping_client();
+extern void proto_send_chat_client(char *s);
+extern void proto_recv_chat_server(client_t *client, char *msg);
+extern void proto_send_chat_server(int type, client_t *client, char *msg);
+extern void proto_recv_chat_client(char *msg);
extern void proto_recv_ping_server(client_t *client, char *msg);
extern void proto_send_ping_server(int type, client_t *client);
extern void proto_recv_ping_client(char *msg);
diff --git a/src/base/server.c b/src/base/server.c
index 9132a46..3c1148a 100644
--- a/src/base/server.c
+++ b/src/base/server.c
@@ -613,6 +613,12 @@ static void eventClientBuffer(client_t *client)
continue;
}
+ if( strncmp(line, "chat", 4) == 0 )
+ {
+ proto_recv_chat_server(client, line);
+ continue;
+ }
+
if( strncmp(line, "ping", 4) == 0 )
{
proto_recv_ping_server(client, line);