diff options
| author | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-08-03 14:17:06 +0000 |
|---|---|---|
| committer | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-08-03 14:17:06 +0000 |
| commit | 00c9cebac684c42741e924d11038d5591e87dacd (patch) | |
| tree | a2056cbbf8ae0512ff15e9eb8868ceab29877073 /src/base/server.c | |
| parent | 1a592767c6e34bdeb7f30fa063b5e24c57d45894 (diff) | |
- trochu rozsirena konfiguracvia, viz http://www.tuxanci.org/server/howto
- moznost logovat so suboru
git-svn-id: http://opensvn.csie.org/tuxanci_ng@188 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src/base/server.c')
| -rw-r--r-- | src/base/server.c | 176 |
1 files changed, 1 insertions, 175 deletions
diff --git a/src/base/server.c b/src/base/server.c index fe01b5f..ad057a2 100644 --- a/src/base/server.c +++ b/src/base/server.c @@ -31,6 +31,7 @@ #include "protect.h" #include "index.h" #include "serverSelect.h" +#include "serverSendMsg.h" #ifndef PUBLIC_SERVER #include "screen_world.h" @@ -47,20 +48,6 @@ static list_t *listServerTimer; static time_t timeUpdate; static int maxClients; -/* - TRAFFIC - - za 5 sekund : - - up : COUNT_PLAYERS * ( COUNT_PLAYERS - 1 ) * 1KB - down : COUNT_PLAYERS * 0.2KB - - za 1 sekund : - - up : COUNT_PLAYERS * ( COUNT_PLAYERS - 1 ) * 1/5 KB - down : COUNT_PLAYERS * 1/25 KB -*/ - typedef struct proto_cmd_server_struct { char *name; @@ -344,167 +331,6 @@ void sendClient(client_t *p, char *msg) } } -static void addMsgClient(client_t *p, char *msg, int type, int id) -{ - assert( p != NULL ); - assert( msg != NULL ); - - if( p->status != NET_STATUS_ZOMBIE ) - { - addMsgInCheckFront(p->listSendMsg, msg, type, id); - } -} - -static void addMsgAllClientBut(char *msg, client_t *p, int type, int id) -{ - client_t *thisClient; - int i; - - assert( msg != NULL ); - - for( i = 0 ; i < listClient->count; i++) - { - thisClient = (client_t *) listClient->list[i]; - - if( thisClient->tux != NULL && thisClient != p ) - { - addMsgClient(thisClient, msg, type, id); - } - } -} - -static void addMsgAllClient(char *msg, int type, int id) -{ - assert( msg != NULL ); - - addMsgAllClientBut(msg, NULL, type, id); -} - -static void addMsgAllClientSeesTux(char *msg, tux_t *tux, int type, int id) -{ - list_t *listHelp; - arena_t *arena; - space_t *space; - int x, y, w, h; - int i; - - assert( msg != NULL ); - - arena = getCurrentArena(); - space = arena->spaceTux; - - x = tux->x - WINDOW_SIZE_X; - y = tux->y - WINDOW_SIZE_Y; - - w = 2 * WINDOW_SIZE_X; - h = 2 * WINDOW_SIZE_Y; - - if( x < 0 )x = 0; - if( y < 0 )y = 0; - if( w+x >= arena->w )w = arena->w - (x+1); - if( h+y >= arena->h )h = arena->h - (y+1); - - listHelp = newList(); - - getObjectFromSpace(space, x, y, w, h, listHelp); - //printf("%d %d %d %d %d\n", x, y, w, h, listHelp->count); - - for( i = 0 ; i < listHelp->count ; i++ ) - { - tux_t *thisTux; - client_t *thisClient; - - thisTux = (tux_t *)listHelp->list[i]; - - if( thisTux == tux ) - { - continue; - } - - thisClient = thisTux->client; - - if( thisClient != NULL ) - { - addMsgClient(thisClient, msg, type, id); - } - } - - destroyList(listHelp); -} - -void protoSendClient(int type, client_t *client, char *msg, int type2, int id) -{ - assert( msg != NULL ); - - switch( type ) - { - case PROTO_SEND_ONE : - assert( client != NULL ); - addMsgClient(client, msg, type2, id); - break; - case PROTO_SEND_ALL : - assert( client == NULL ); - addMsgAllClient(msg, type2, id); - break; - case PROTO_SEND_BUT : - assert( client != NULL ); - addMsgAllClientBut(msg, client, type2, id); - break; - case PROTO_SEND_ALL_SEES_TUX : -#ifndef PUBLIC_SERVER - if( client != NULL ) - { - addMsgAllClientSeesTux(msg, client->tux, type2, id); - } - else - { - addMsgAllClientSeesTux(msg, getControlTux(TUX_CONTROL_KEYBOARD_RIGHT), type2, id); - } -#endif -#ifdef PUBLIC_SERVER - addMsgAllClientSeesTux(msg, client->tux, type2, id); -#endif - break; - default : - assert( ! "Premenna type ma zlu hodnotu !" ); - break; - } -} - -void sendInfoCreateClient(client_t *client) -{ - client_t *thisClient; - tux_t *thisTux; - item_t *thisItem; - int i; - - assert( client != NULL ); - - proto_send_init_server(PROTO_SEND_ONE, client, client); - -#ifndef PUBLIC_SERVER - proto_send_newtux_server(PROTO_SEND_ONE, client, getControlTux(TUX_CONTROL_KEYBOARD_RIGHT) ); -#endif - - for( i = 0 ; i < listClient->count; i++) - { - thisClient = (client_t *) listClient->list[i]; - thisTux = thisClient->tux; - - if( thisTux != NULL && thisTux != client->tux ) - { - proto_send_newtux_server(PROTO_SEND_ONE, thisClient, client->tux); - proto_send_newtux_server(PROTO_SEND_ONE, client, thisTux); - } - } - - for( i = 0 ; i < getCurrentArena()->spaceItem->list->count; i++) - { - thisItem = (item_t *) getCurrentArena()->spaceItem->list->list[i]; - proto_send_additem_server(PROTO_SEND_ONE, client, thisItem); - } -} - static void eventClientBuffer(client_t *client) { proto_cmd_server_t* protoCmd; |