From 2fd0c9d50f1eb83d46080fb114cba5465e8c4506 Mon Sep 17 00:00:00 2001 From: oroborus Date: Tue, 3 Jun 2008 21:26:17 +0000 Subject: - zaciatok podpory FR jazyka - server podporuje socre ( treb este zdokumentovat protokol ) - prelozene dve chybove hlasky pre siete - odosielam to na rychlo git-svn-id: http://opensvn.csie.org/tuxanci_ng@59 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e --- src/proto.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'src/proto.c') diff --git a/src/proto.c b/src/proto.c index d925011..a31e640 100644 --- a/src/proto.c +++ b/src/proto.c @@ -18,15 +18,18 @@ #include "idManager.h" #ifndef PUBLIC_SERVER +#include "language.h" #include "network.h" #include "screen_world.h" #include "screen_setting.h" #include "screen_choiceArena.h" +#include "screen_analyze.h" #include "client.h" #include "term.h" #endif #ifdef PUBLIC_SERVER +#include "heightScore.h" #include "publicServer.h" #endif @@ -100,6 +103,14 @@ void proto_recv_error_client(char *msg) cmd, &errorcode); printf("proto error code %d\n", errorcode); + + switch(errorcode) + { + case PROTO_ERROR_CODE_BAD_VERSION : + setMsgToAnalyze(getMyText("ERROR_BAD_VERSION")); + setWorldEnd(); + break; + } } #endif @@ -170,6 +181,55 @@ void proto_recv_status_server(client_t *client, char *msg) proto_send_status_server(PROTO_SEND_ONE, client); } +#ifdef PUBLIC_SERVER + +void proto_send_listscore_server(int type, client_t *client, int max) +{ + char *str; + char *msg; + int i; + + msg = malloc( (max * 24) * sizeof(char) ); + strcpy(msg, ""); + + for( i = 0 ; i < max ; i++ ) + { + str = getTableItem(i); + + if( str == NULL ) + { + break; + } + + strcat(msg, str); + strcat(msg, "\n"); + } + + proto_send(type, client, msg); + free(msg); +} + +void proto_recv_listscore_server(client_t *client, char *msg) +{ + char cmd[STR_PROTO_SIZE]; + int max; + int ret; + + assert( msg != NULL ); + + ret = sscanf(msg, "%s %d", + cmd, &max); + + if( ret != 2 ) + { + max = HEIGHTSCORE_MAX_PLAYERS; + } + + proto_send_listscore_server(PROTO_SEND_ONE, client, max); +} + +#endif + #ifndef PUBLIC_SERVER void proto_send_check_client(int id) -- cgit v1.2.3