From b84b59153c587248ca8a6a94a6d93977e851233f Mon Sep 17 00:00:00 2001 From: oroborus Date: Sat, 15 Mar 2008 18:35:48 +0000 Subject: - moznost skompilovat public server bez GUI ( pomocou Makefile-publicServer ) port sa nastavuje ako ./publicserver --port - jeto iba prvotna verzia treba to este odladit a zostabilnit git-svn-id: http://opensvn.csie.org/tuxanci_ng@18 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e --- src/proto.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 71 insertions(+), 7 deletions(-) (limited to 'src/proto.c') diff --git a/src/proto.c b/src/proto.c index ddfc51c..01a4ad2 100644 --- a/src/proto.c +++ b/src/proto.c @@ -2,19 +2,29 @@ #include #include +#include "main.h" #include "list.h" #include "tux.h" #include "item.h" +#include "arenaFile.h" +#include "myTimer.h" +#include "server.h" +#include "proto.h" +#include "net_multiplayer.h" + +#ifndef BUBLIC_SERVER #include "network.h" -#include "string_length.h" #include "screen_world.h" #include "screen_setting.h" #include "screen_choiceArena.h" -#include "arenaFile.h" -#include "net_multiplayer.h" #include "client.h" -#include "server.h" -#include "proto.h" +#endif + +#ifdef BUBLIC_SERVER +#include "publicServer.h" +#endif + +#ifndef BUBLIC_SERVER void proto_send_hello_client() { @@ -24,18 +34,24 @@ void proto_send_hello_client() sendServer(msg); } +#endif + void proto_recv_hello_server(client_t *client, char *msg) { } + void proto_send_init_server(client_t *client) { char msg[STR_SIZE]; - int n; + int n = 9999; assert( client != NULL ); +#ifndef BUBLIC_SERVER getSettingCountRound(&n); +#endif + sprintf(msg, "init %d %d %d %d %s\n", client->tux->id, client->tux->x, client->tux->y, @@ -44,6 +60,8 @@ void proto_send_init_server(client_t *client) sendClient(client, msg); } +#ifndef BUBLIC_SERVER + void proto_recv_init_client(char *msg) { char cmd[STR_SIZE]; @@ -71,6 +89,8 @@ void proto_recv_init_client(char *msg) addList(getWorldArena()->listTux, tux); } +#endif + void proto_send_event_server(tux_t *tux, int action, client_t *client) { char msg[STR_SIZE]; @@ -82,6 +102,8 @@ void proto_send_event_server(tux_t *tux, int action, client_t *client) sendAllClientBut(msg, client); } +#ifndef BUBLIC_SERVER + void proto_recv_event_client(char *msg) { char cmd[STR_SIZE]; @@ -100,6 +122,10 @@ void proto_recv_event_client(char *msg) } } +#endif + +#ifndef BUBLIC_SERVER + void proto_send_event_client(int action) { char msg[STR_SIZE]; @@ -109,6 +135,8 @@ void proto_send_event_client(int action) sendServer(msg); } +#endif + void proto_recv_event_server(client_t *client, char *msg) { char cmd[STR_SIZE]; @@ -147,6 +175,8 @@ void proto_send_newtux_server(client_t *client, tux_t *tux) } } +#ifndef BUBLIC_SERVER + void proto_recv_newtux_client(char *msg) { char cmd[STR_SIZE]; @@ -193,6 +223,8 @@ void proto_recv_newtux_client(char *msg) tux->status = TUX_STATUS_ALIVE; } +#endif + void proto_send_kill_server(tux_t *tux) { char msg[STR_SIZE]; @@ -204,6 +236,8 @@ void proto_send_kill_server(tux_t *tux) sendAllClient(msg); } +#ifndef BUBLIC_SERVER + void proto_recv_kill_client(char *msg) { char cmd[STR_SIZE]; @@ -222,6 +256,8 @@ void proto_recv_kill_client(char *msg) } } +#endif + void proto_send_score_server(tux_t *tux) { char msg[STR_SIZE]; @@ -233,6 +269,8 @@ void proto_send_score_server(tux_t *tux) sendAllClient(msg); } +#ifndef BUBLIC_SERVER + void proto_recv_score_client(char *msg) { char cmd[STR_SIZE]; @@ -253,6 +291,8 @@ void proto_recv_score_client(char *msg) countRoundInc(); } +#endif + void proto_send_deltux_server(client_t *client) { char msg[STR_SIZE]; @@ -264,6 +304,8 @@ void proto_send_deltux_server(client_t *client) sendAllClientBut(msg, client); } +#ifndef BUBLIC_SERVER + void proto_recv_deltux_client(char *msg) { char cmd[STR_SIZE]; @@ -285,6 +327,8 @@ void proto_recv_deltux_client(char *msg) } } +#endif + void proto_send_additem_server(item_t *p) { char msg[STR_SIZE]; @@ -303,6 +347,8 @@ void proto_send_additem_server(item_t *p) sendAllClient(msg); } +#ifndef BUBLIC_SERVER + void proto_recv_additem_client(char *msg) { char cmd[STR_SIZE]; @@ -327,6 +373,10 @@ void proto_recv_additem_client(char *msg) addList(getWorldArena()->listItem, item); } +#endif + +#ifndef BUBLIC_SERVER + void proto_send_context_client(tux_t *tux) { char msg[STR_SIZE]; @@ -338,6 +388,8 @@ void proto_send_context_client(tux_t *tux) sendServer(msg); } +#endif + void proto_recv_context_server(client_t *client, char *msg) { char cmd[STR_SIZE]; @@ -353,6 +405,8 @@ void proto_recv_context_server(client_t *client, char *msg) proto_send_newtux_server(NULL, client->tux); } +#ifndef BUBLIC_SERVER + void proto_send_ping_client() { char msg[STR_SIZE]; @@ -360,14 +414,18 @@ void proto_send_ping_client() sendServer(msg); } +#endif + void proto_recv_ping_server(client_t *client, char *msg) { assert( msg != NULL ); assert( client != NULL ); - client->lastPing = SDL_GetTicks(); + client->lastPing = getMyTime(); } +#ifndef BUBLIC_SERVER + void proto_send_end_client() { char msg[STR_SIZE]; @@ -375,6 +433,8 @@ void proto_send_end_client() sendServer(msg); } +#endif + void proto_recv_end_server(client_t *client, char *msg) { assert( msg != NULL ); @@ -390,6 +450,9 @@ void proto_send_end_server() sendAllClient(msg); } + +#ifndef BUBLIC_SERVER + void proto_recv_end_client(char *msg) { assert( msg != NULL ); @@ -397,3 +460,4 @@ void proto_recv_end_client(char *msg) setWorldEnd(); } +#endif -- cgit v1.2.3