summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.h4
-rw-r--r--control6
-rwxr-xr-xinclude/interface.h2
-rw-r--r--include/proto.h4
-rw-r--r--include/server.h8
-rw-r--r--include/string_length.h12
-rwxr-xr-xsrc/Makefile3
-rw-r--r--src/client.c20
-rw-r--r--src/proto.c98
-rw-r--r--src/publicServer.c2
-rw-r--r--src/screen_world.c8
-rw-r--r--src/server.c117
-rw-r--r--src/tux.c4
13 files changed, 190 insertions, 98 deletions
diff --git a/config.h b/config.h
index 3127862..577e846 100644
--- a/config.h
+++ b/config.h
@@ -1,8 +1,12 @@
+
/*
#define DEBUG_SERVER_SEND
#define DEBUG_SERVER_RECV
#define DEBUG_CLIENT_SEND
#define DEBUG_CLIENT_RECV
*/
+
+#define TUXANCI_NG_VERSION "svn27"
+
#define DESTDIR "/usr/local/"
#define SUPPORT_NET_SDL_UDP
diff --git a/control b/control
index 869ea82..b2ab100 100644
--- a/control
+++ b/control
@@ -1,12 +1,12 @@
Package: tuxanci-ng
-Version: svn25
+Version: svn27
Section: Game
Priority: optional
Depends: libc6 (>= 2.2.4-4), libsdl1.2debian (>= 1.2), libsdl-image1.2 (>= 1.2), libsdl-mixer1.2 (>= 1.2), libsdl-net1.2 (>= 1.2), libsdl-ttf2.0-0 (>= 2.0)
Architecture: i386
Installed-Size: 4510
Maintainer: Dušan Ďurech <dusan.d@centrum.sk>
-Description: Game tuxanci next generation SVN revision 13
- Game tuxanci next generation SVN revision 13
+Description: Game tuxanci next generation SVN revision 27
+ Game tuxanci next generation SVN revision 27
.
http://www.tuxanci.org
diff --git a/include/interface.h b/include/interface.h
index bcb2a17..e0a7893 100755
--- a/include/interface.h
+++ b/include/interface.h
@@ -19,7 +19,7 @@
#define SDL_SUBSYSTEMS SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_DOUBLEBUF
//napis na okne
-#define WINDOW_TITLE "Tuxanci next generation SVN revision 27"
+#define WINDOW_TITLE "Tuxanci next generation " TUXANCI_NG_VERSION
#define WIN_BPP 0
#define USR_EVT_TIMER 0
diff --git a/include/proto.h b/include/proto.h
index 37595fe..f91b60b 100644
--- a/include/proto.h
+++ b/include/proto.h
@@ -41,8 +41,10 @@
#include "publicServer.h"
#endif
-extern void proto_send_hello_client();
+extern void proto_send_hello_client(char *name);
extern void proto_recv_hello_server(client_t *client, char *msg);
+extern void proto_send_status_server(int type, client_t *client);
+extern void proto_recv_status_server(client_t *client, char *msg);
extern void proto_send_init_server(int type, client_t *client, client_t *client2);
extern void proto_recv_init_client(char *msg);
extern void proto_send_event_server(int type, client_t *client, tux_t *tux, int action);
diff --git a/include/server.h b/include/server.h
index 623a12e..3ee1933 100644
--- a/include/server.h
+++ b/include/server.h
@@ -22,6 +22,7 @@
#define SERVER_TIMEOUT 5000
#define SERVER_TIME_SYNC 1000
+#define SERVER_MAX_CLIENTS 100
#endif
@@ -31,6 +32,7 @@
#define SERVER_TIMEOUT 5000
#define SERVER_TIME_SYNC 1000
+#define SERVER_MAX_CLIENTS 100
#endif
@@ -79,10 +81,16 @@ extern void quitSdlUdpServer();
#endif
extern void destroyClient(client_t *p);
+
+extern list_t* getListServerClient();
+extern int getServerMaxClients();
+extern void setServerMaxClients(int n);
+
extern void sendClient(client_t *p, char *msg);
extern void sendAllClientBut(char *msg, client_t *p);
extern void sendAllClient(char *msg);
extern void eventClientListBuffer();
+extern void sendInfoCreateClient(client_t *client);
extern void eventPeriodicSyncClient();
#endif
diff --git a/include/string_length.h b/include/string_length.h
index 7f1c8a7..243cb69 100644
--- a/include/string_length.h
+++ b/include/string_length.h
@@ -5,10 +5,12 @@
#include "main.h"
-#define STR_SIZE 128
-#define STR_NUM_SIZE 8
-#define STR_NAME_SIZE 32
-#define STR_PATH_SIZE 4096
-#define STR_IP_SIZE 24
+#define STR_SIZE 128
+#define STR_PROTO_SIZE 128
+#define STR_NUM_SIZE 8
+#define STR_NAME_SIZE 32
+#define STR_PATH_SIZE 4096
+#define STR_FILE_NAME_SIZE 256
+#define STR_IP_SIZE 24
#endif
diff --git a/src/Makefile b/src/Makefile
index 7160cb5..405812f 100755
--- a/src/Makefile
+++ b/src/Makefile
@@ -3,7 +3,7 @@
CC = gcc
#CFLAGS = -O2 -DSUPPORT_NET_SDL_UDP -I../include -Wall `sdl-config --cflags`
-CFLAGS = -O2 -I../include -Wall `sdl-config --cflags`
+CFLAGS = -g -O0 -I../include -Wall `sdl-config --cflags`
#CFLAGS = -O2 -DDESTDIR=\"$(DESTDIR)\" `sdl-config --cflags` -I../include -Wall
LIBS = `sdl-config --libs` -lSDL_image -lSDL_ttf -lSDL_mixer -lSDL_net
@@ -84,6 +84,7 @@ server.o: server.c ../include/server.h
client.o: client.c ../include/client.h
$(CC) $(CFLAGS) -o client.o -c client.c
+
network.o: network.c ../include/network.h
$(CC) $(CFLAGS) -o network.o -c network.c
diff --git a/src/client.c b/src/client.c
index 8ca55e1..f525cfe 100644
--- a/src/client.c
+++ b/src/client.c
@@ -36,10 +36,14 @@ static my_time_t lastPingServerAlive;
static void initClient()
{
+ char name[STR_NAME_SIZE];
+
clientBuffer = newBuffer( LIMIT_BUFFER );
lastPing = getMyTime();
lastPingServerAlive = getMyTime();
- proto_send_hello_client();
+
+ getSettingNameRight(name);
+ proto_send_hello_client(name);
}
#ifdef SUPPORT_NET_UNIX_TCP
@@ -142,13 +146,13 @@ void sendServer(char *msg)
static int eventServerSelect()
{
- char buffer[STR_SIZE];
+ char buffer[STR_PROTO_SIZE];
int ret;
- memset(buffer,0 ,STR_SIZE);
+ memset(buffer,0 ,STR_PROTO_SIZE);
#ifdef SUPPORT_NET_UNIX_TCP
- ret = readTcpSocket(sock_server_tcp, buffer, STR_SIZE-1);
+ ret = readTcpSocket(sock_server_tcp, buffer, STR_PROTO_SIZE-1);
if( ret == 0 )
{
@@ -166,11 +170,11 @@ static int eventServerSelect()
#endif
#ifdef SUPPORT_NET_UNIX_UDP
- ret = readUdpSocket(sock_server_udp, sock_server_udp, buffer, STR_SIZE-1);
+ ret = readUdpSocket(sock_server_udp, sock_server_udp, buffer, STR_PROTO_SIZE-1);
#endif
#ifdef SUPPORT_NET_SDL_UDP
- ret = readSdlUdpSocket(sock_server_sdl_udp, sock_server_sdl_udp, buffer, STR_SIZE-1);
+ ret = readSdlUdpSocket(sock_server_sdl_udp, sock_server_sdl_udp, buffer, STR_PROTO_SIZE-1);
if( ret < 0 )
{
@@ -190,13 +194,13 @@ static int eventServerSelect()
void eventServerBuffer()
{
- char line[STR_SIZE];
+ char line[STR_PROTO_SIZE];
/* obsluha udalosti od servera */
assert( clientBuffer != NULL );
- while ( getBufferLine(clientBuffer, line, STR_SIZE) >= 0 )
+ while ( getBufferLine(clientBuffer, line, STR_PROTO_SIZE) >= 0 )
{
#ifdef DEBUG_CLIENT_RECV
printf("recv server msg->%s", line);
diff --git a/src/proto.c b/src/proto.c
index 77ce16f..e2ade65 100644
--- a/src/proto.c
+++ b/src/proto.c
@@ -62,11 +62,11 @@ static void proto_send(int type, client_t *client, char *msg)
#ifndef BUBLIC_SERVER
-void proto_send_hello_client()
+void proto_send_hello_client(char *name)
{
- char msg[STR_SIZE];
+ char msg[STR_PROTO_SIZE];
- strcpy(msg, "hello\n");
+ sprintf(msg, "hello %s\n", name);
sendServer(msg);
}
@@ -74,11 +74,48 @@ void proto_send_hello_client()
void proto_recv_hello_server(client_t *client, char *msg)
{
+ char cmd[STR_PROTO_SIZE];
+ char name[STR_NAME_SIZE];
+
+ assert( client != NULL );
+
+ sscanf(msg, "%s %s\n", cmd, name);
+
+ client->tux = newTux();
+ client->tux->control = TUX_CONTROL_NET;
+ addList(getWorldArena()->listTux, client->tux);
+
+ if( strlen(name) > STR_NAME_SIZE-1 )
+ {
+ name[STR_NAME_SIZE-1] = '\0';
+ }
+
+ strcpy(client->tux->name, name);
+ sendInfoCreateClient(client);
+}
+
+void proto_send_status_server(int type, client_t *client)
+{
+ char msg[STR_PROTO_SIZE];
+
+ sprintf(msg, "version: %s\n"
+ "clients: %d\n"
+ "maxclients: %d\n"
+ "uptime: %d\n",
+ TUXANCI_NG_VERSION, getListServerClient()->count,
+ getServerMaxClients(), getMyTime() );
+
+ proto_send(type, client, msg);
+}
+
+void proto_recv_status_server(client_t *client, char *msg)
+{
+ proto_send_status_server(PROTO_SEND_ONE, client);
}
void proto_send_init_server(int type, client_t *client, client_t *client2)
{
- char msg[STR_SIZE];
+ char msg[STR_PROTO_SIZE];
int n = 9999;
assert( client2 != NULL );
@@ -98,8 +135,8 @@ void proto_send_init_server(int type, client_t *client, client_t *client2)
void proto_recv_init_client(char *msg)
{
- char cmd[STR_SIZE];
- char arena_name[STR_SIZE];
+ char cmd[STR_PROTO_SIZE];
+ char arena_name[STR_PROTO_SIZE];
tux_t *tux;
int id;
int x, y, n;
@@ -117,9 +154,10 @@ void proto_recv_init_client(char *msg)
tux->x = x;
tux->y = y;
tux->control = TUX_CONTROL_KEYBOARD_RIGHT;
+
getSettingNameRight(tux->name);
- proto_send_context_client(tux);
+// proto_send_context_client(tux);
addList(getWorldArena()->listTux, tux);
}
@@ -127,7 +165,7 @@ void proto_recv_init_client(char *msg)
void proto_send_event_server(int type, client_t *client, tux_t *tux, int action)
{
- char msg[STR_SIZE];
+ char msg[STR_PROTO_SIZE];
assert( tux != NULL );
@@ -140,7 +178,7 @@ void proto_send_event_server(int type, client_t *client, tux_t *tux, int action)
void proto_recv_event_client(char *msg)
{
- char cmd[STR_SIZE];
+ char cmd[STR_PROTO_SIZE];
int id, action;
tux_t *tux;
@@ -162,7 +200,7 @@ void proto_recv_event_client(char *msg)
void proto_send_event_client(int action)
{
- char msg[STR_SIZE];
+ char msg[STR_PROTO_SIZE];
sprintf(msg, "event %d\n", action);
@@ -173,7 +211,7 @@ void proto_send_event_client(int action)
void proto_recv_event_server(client_t *client, char *msg)
{
- char cmd[STR_SIZE];
+ char cmd[STR_PROTO_SIZE];
int action;
assert( client != NULL );
@@ -188,7 +226,7 @@ void proto_recv_event_server(client_t *client, char *msg)
void proto_send_newtux_server(int type, client_t *client, tux_t *tux)
{
- char msg[STR_SIZE];
+ char msg[STR_PROTO_SIZE];
assert( tux != NULL );
@@ -206,7 +244,7 @@ void proto_send_newtux_server(int type, client_t *client, tux_t *tux)
void proto_recv_newtux_client(char *msg)
{
- char cmd[STR_SIZE];
+ char cmd[STR_PROTO_SIZE];
char name[STR_NAME_SIZE];
int id, x, y, status, position, frame, score;
int myGun, myBonus;
@@ -254,7 +292,7 @@ void proto_recv_newtux_client(char *msg)
void proto_send_kill_server(int type, client_t *client, tux_t *tux)
{
- char msg[STR_SIZE];
+ char msg[STR_PROTO_SIZE];
assert( tux != NULL );
@@ -267,7 +305,7 @@ void proto_send_kill_server(int type, client_t *client, tux_t *tux)
void proto_recv_kill_client(char *msg)
{
- char cmd[STR_SIZE];
+ char cmd[STR_PROTO_SIZE];
int id;
tux_t *tux;
@@ -287,7 +325,7 @@ void proto_recv_kill_client(char *msg)
void proto_send_score_server(int type, client_t *client, tux_t *tux)
{
- char msg[STR_SIZE];
+ char msg[STR_PROTO_SIZE];
assert( tux != NULL );
@@ -300,7 +338,7 @@ void proto_send_score_server(int type, client_t *client, tux_t *tux)
void proto_recv_score_client(char *msg)
{
- char cmd[STR_SIZE];
+ char cmd[STR_PROTO_SIZE];
int id, score;
tux_t *tux;
@@ -322,7 +360,7 @@ void proto_recv_score_client(char *msg)
void proto_send_deltux_server(int type, client_t *client, client_t *client2)
{
- char msg[STR_SIZE];
+ char msg[STR_PROTO_SIZE];
assert( client2 != NULL );
@@ -335,7 +373,7 @@ void proto_send_deltux_server(int type, client_t *client, client_t *client2)
void proto_recv_deltux_client(char *msg)
{
- char cmd[STR_SIZE];
+ char cmd[STR_PROTO_SIZE];
int id;
tux_t *tux;
@@ -358,7 +396,7 @@ void proto_recv_deltux_client(char *msg)
void proto_send_additem_server(int type, client_t *client, item_t *p)
{
- char msg[STR_SIZE];
+ char msg[STR_PROTO_SIZE];
int id = -1;
assert( p != NULL );
@@ -378,7 +416,7 @@ void proto_send_additem_server(int type, client_t *client, item_t *p)
void proto_recv_additem_client(char *msg)
{
- char cmd[STR_SIZE];
+ char cmd[STR_PROTO_SIZE];
int type, x, y, count, frame, id;
item_t *item;
@@ -404,7 +442,7 @@ void proto_recv_additem_client(char *msg)
void proto_send_shot_server(int type, client_t *client, shot_t *p)
{
- char msg[STR_SIZE];
+ char msg[STR_PROTO_SIZE];
int id = -1;
assert( p != NULL );
@@ -424,7 +462,7 @@ void proto_send_shot_server(int type, client_t *client, shot_t *p)
void proto_recv_shot_client(char *msg)
{
- char cmd[STR_SIZE];
+ char cmd[STR_PROTO_SIZE];
int x, y, px, py, position, gun, id, isCanKillAuthor;
shot_t *shot;
@@ -449,11 +487,12 @@ void proto_recv_shot_client(char *msg)
#endif
+/*
#ifndef BUBLIC_SERVER
void proto_send_context_client(tux_t *tux)
{
- char msg[STR_SIZE];
+ char msg[STR_PROTO_SIZE];
assert( tux != NULL );
@@ -466,7 +505,7 @@ void proto_send_context_client(tux_t *tux)
void proto_recv_context_server(client_t *client, char *msg)
{
- char cmd[STR_SIZE];
+ char cmd[STR_PROTO_SIZE];
char name[STR_NAME_SIZE];
assert( client != NULL );
@@ -478,12 +517,13 @@ 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];
+ char msg[STR_PROTO_SIZE];
strcpy(msg, "ping\n");
sendServer(msg);
}
@@ -504,7 +544,7 @@ void proto_recv_ping_server(client_t *client, char *msg)
void proto_send_end_client()
{
- char msg[STR_SIZE];
+ char msg[STR_PROTO_SIZE];
strcpy(msg, "end\n");
sendServer(msg);
}
@@ -521,7 +561,7 @@ void proto_recv_end_server(client_t *client, char *msg)
void proto_send_ping_server(int type, client_t *client)
{
- char msg[STR_SIZE];
+ char msg[STR_PROTO_SIZE];
strcpy(msg, "ping\n");
proto_send(type, client, msg);
}
@@ -541,7 +581,7 @@ void proto_recv_ping_client(char *msg)
void proto_send_end_server(int type, client_t *client)
{
- char msg[STR_SIZE];
+ char msg[STR_PROTO_SIZE];
strcpy(msg, "end\n");
proto_send(type, client, msg);
}
diff --git a/src/publicServer.c b/src/publicServer.c
index 0ba1fc6..2f07b3d 100644
--- a/src/publicServer.c
+++ b/src/publicServer.c
@@ -51,6 +51,8 @@ int initPublicServer()
return -1;
}
+ setServerMaxClients( atoi( getParamElse("--maxclients", "100") ));
+
return 0;
}
diff --git a/src/screen_world.c b/src/screen_world.c
index f9ef868..d4540b1 100644
--- a/src/screen_world.c
+++ b/src/screen_world.c
@@ -282,13 +282,13 @@ static void control_keyboard_right(tux_t *tux)
actionTux(tux, TUX_DOWN);
}
- if( mapa[(SDLKey)SDLK_LCTRL] == SDL_PRESSED )
+ if( mapa[(SDLKey)SDLK_KP0] == SDL_PRESSED )
{
netAction(tux, TUX_SHOT);
actionTux(tux, TUX_SHOT);
}
- if( mapa[(SDLKey)SDLK_LSHIFT] == SDL_PRESSED )
+ if( mapa[(SDLKey)SDLK_KP1] == SDL_PRESSED )
{
if( tux->isCanSwitchGun == TRUE )
{
@@ -389,10 +389,10 @@ void eventWorld()
eventMoveListShot(arena->listShot);
eventListItem(arena->listItem);
- eventListTux(arena->listTux);
- eventTimer();
eventNetMultiplayer();
+ eventListTux(arena->listTux);
+ eventTimer();
eventEnd();
eventEsc();
diff --git a/src/server.c b/src/server.c
index b66d97e..91e26c0 100644
--- a/src/server.c
+++ b/src/server.c
@@ -28,8 +28,6 @@
#include "publicServer.h"
#endif
-static int protocolType;
-
#ifdef SUPPORT_NET_UNIX_TCP
#include "tcp.h"
static sock_tcp_t *sock_server_tcp;
@@ -47,18 +45,18 @@ static sock_sdl_udp_t *sock_server_sdl_udp;
static list_t *listClient;
static my_time_t lastSyncClient;
+static int maxClients;
void static initServer()
{
listClient = newList();
lastSyncClient = getMyTime();
+ setServerMaxClients(SERVER_MAX_CLIENTS);
}
#ifdef SUPPORT_NET_UNIX_TCP
int initTcpServer(int port)
{
- protocolType = NET_PROTOCOL_TYPE_TCP;
-
sock_server_tcp = bindTcpSocket(port);
if( sock_server_tcp == NULL )
@@ -77,8 +75,6 @@ int initTcpServer(int port)
#ifdef SUPPORT_NET_UNIX_UDP
int initUdpServer(int port)
{
- protocolType = NET_PROTOCOL_TYPE_UDP;
-
sock_server_udp = bindUdpSocket(port);
if( sock_server_udp == NULL )
@@ -97,8 +93,6 @@ int initUdpServer(int port)
#ifdef SUPPORT_NET_SDL_UDP
int initSdlUdpServer(int port)
{
- protocolType = NET_PROTOCOL_TYPE_UDP;
-
sock_server_sdl_udp = bindSdlUdpSocket(port);
if( sock_server_sdl_udp == NULL )
@@ -123,9 +117,6 @@ static client_t* newAnyClient()
new->status = NET_STATUS_OK;
new->buffer = newBuffer(LIMIT_BUFFER);
- new->tux = newTux();
- new->tux->control = TUX_CONTROL_NET;
- addList(getWorldArena()->listTux, new->tux);
return new;
}
@@ -199,18 +190,37 @@ void destroyClient(client_t *p)
#endif
destroyBuffer(p->buffer);
- index = searchListItem(getWorldArena()->listTux, p->tux);
- delListItem(getWorldArena()->listTux, index, destroyTux);
+
+ if( p->tux != NULL )
+ {
+ index = searchListItem(getWorldArena()->listTux, p->tux);
+ delListItem(getWorldArena()->listTux, index, destroyTux);
+ }
free(p);
}
+list_t* getListServerClient()
+{
+ return listClient;
+}
+
+int getServerMaxClients()
+{
+ return maxClients;
+}
+
+void setServerMaxClients(int n)
+{
+ maxClients = n;
+}
+
void sendClient(client_t *p, char *msg)
{
assert( p != NULL );
assert( msg != NULL );
- if( p->status == NET_STATUS_OK )
+ if( p->status != NET_STATUS_ZOMBIE )
{
int ret;
@@ -265,7 +275,7 @@ void sendAllClient(char *msg)
sendAllClientBut(msg, NULL);
}
-static void eventCreateClient(client_t *client)
+void sendInfoCreateClient(client_t *client)
{
client_t *thisClient;
tux_t *thisTux;
@@ -310,8 +320,6 @@ static void eventCreateNewTcpClient(sock_tcp_t *socket_tcp)
client = newTcpClient( getTcpNewClient(socket_tcp) );
addList(listClient, client);
-
- eventCreateClient(client);
}
#endif
@@ -326,8 +334,6 @@ static void eventCreateNewUdpClient(sock_udp_t *socket_udp)
client = newUdpClient( socket_udp );
addList(listClient, client);
-
- eventCreateClient(client);
}
#endif
@@ -342,8 +348,6 @@ static void eventCreateNewSdlUdpClient(sock_sdl_udp_t *socket_sdl_udp)
client = newSdlUdpClient( socket_sdl_udp );
addList(listClient, client);
-
- eventCreateClient(client);
}
#endif
@@ -352,13 +356,13 @@ static void eventCreateNewSdlUdpClient(sock_sdl_udp_t *socket_sdl_udp)
static void eventClientTcpSelect(client_t *client)
{
- char buffer[STR_SIZE];
+ char buffer[STR_PROTO_SIZE];
int ret;
assert( client != NULL );
memset(buffer, 0, STR_SIZE);
- ret = readTcpSocket(client->socket_tcp, buffer, STR_SIZE-1);
+ ret = readTcpSocket(client->socket_tcp, buffer, STR_PROTO_SIZE-1);
if( ret <= 0 )
{
@@ -377,23 +381,27 @@ static void eventClientTcpSelect(client_t *client)
static void eventClientBuffer(client_t *client)
{
- char line[STR_SIZE];
+ char line[STR_PROTO_SIZE];
assert( client != NULL );
/* obsluha udalosti od clientov */
- while( getBufferLine(client->buffer, line, STR_SIZE) >= 0 )
+ while( getBufferLine(client->buffer, line, STR_PROTO_SIZE) >= 0 )
{
#ifdef DEBUG_SERVER_RECV
printf("recv client msg->%s", line);
#endif
if( strncmp(line, "hello", 5) == 0 )proto_recv_hello_server(client, line);
- if( strncmp(line, "event", 5) == 0 )proto_recv_event_server(client, line);
- if( strncmp(line, "context", 7) == 0 )proto_recv_context_server(client, line);
- if( strncmp(line, "ping", 4) == 0 )proto_recv_ping_server(client, line);
- if( strncmp(line, "end", 3) == 0 )proto_recv_end_server(client, line);
+ if( strncmp(line, "status", 6) == 0 )proto_recv_status_server(client, line);
+
+ if( client->tux != NULL )
+ {
+ if( strncmp(line, "event", 5) == 0 )proto_recv_event_server(client, line);
+ if( strncmp(line, "ping", 4) == 0 )proto_recv_ping_server(client, line);
+ if( strncmp(line, "end", 3) == 0 )proto_recv_end_server(client, line);
+ }
}
}
@@ -456,7 +464,11 @@ void selectServerTcpSocket()
if( thisClient->status == NET_STATUS_ZOMBIE )
{
- proto_send_deltux_server(PROTO_SEND_ALL, NULL, thisClient);
+ if( thisClient->tux != NULL )
+ {
+ proto_send_deltux_server(PROTO_SEND_ALL, NULL, thisClient);
+ }
+
delListItem(listClient, i, destroyClient);
}
}
@@ -486,7 +498,11 @@ static void delZombieCLient()
if( thisClient->status == NET_STATUS_ZOMBIE )
{
- proto_send_deltux_server(PROTO_SEND_ALL, NULL, thisClient);
+ if( thisClient->tux != NULL )
+ {
+ proto_send_deltux_server(PROTO_SEND_ALL, NULL, thisClient);
+ }
+
delListItem(listClient, i, destroyClient);
}
}
@@ -504,26 +520,33 @@ void eventPeriodicSyncClient()
client_t *thisClientSend;
tux_t *thisTux;
int i, j;
-
- proto_send_ping_server(PROTO_SEND_ALL, NULL);
-#ifndef BUBLIC_SERVER
- proto_send_newtux_server(PROTO_SEND_ALL, NULL,
- (tux_t *)(getWorldArena()->listTux->list[SERVER_INDEX_ROOT_TUX]));
-#endif
for( i = 0 ; i < listClient->count; i++)
{
- thisClientInfo = (client_t *) listClient->list[i];
+ thisClientSend = (client_t *) listClient->list[i];
+
+ if( thisClientSend->tux != NULL )
+ {
+ proto_send_ping_server(PROTO_SEND_ONE, thisClientSend);
+
+#ifndef BUBLIC_SERVER
+ proto_send_newtux_server(PROTO_SEND_ONE, thisClientSend,
+ (tux_t *)(getWorldArena()->listTux->list[SERVER_INDEX_ROOT_TUX]));
+#endif
+ }
for( j = 0 ; j < listClient->count; j++)
{
- thisClientSend = (client_t *) listClient->list[j];
+ thisClientInfo = (client_t *) listClient->list[j];
thisTux = thisClientInfo->tux;
- if( thisClientSend != thisClientInfo &&
+ if( thisTux != NULL &&
+ thisClientSend->tux != NULL &&
+ thisClientSend != thisClientInfo &&
thisTux->status == TUX_STATUS_ALIVE )
{
- proto_send_newtux_server(PROTO_SEND_ONE, thisClientSend, thisTux);
+ proto_send_newtux_server(PROTO_SEND_ONE,
+ thisClientSend, thisTux);
}
}
}
@@ -575,6 +598,12 @@ static void eventClientUdpSelect(sock_udp_t *sock_server)
if( client == NULL )
{
+ if( listClient->count+1 > maxClients )
+ {
+ destroySockUdp(sock_client);
+ return;
+ }
+
eventCreateNewUdpClient(sock_client);
client = findUdpClient(sock_client);
isCreateNewClient = TRUE;
@@ -666,7 +695,7 @@ void selectServerSdlUdpSocket()
{
sock_sdl_udp_t *sock_client;
client_t *client;
- char buffer[STR_SIZE];
+ char buffer[STR_PROTO_SIZE];
bool_t isCreateNewClient;
int ret;
@@ -678,9 +707,9 @@ void selectServerSdlUdpSocket()
sock_client = newSdlSockUdp();
isCreateNewClient = FALSE;
- memset(buffer, 0, STR_SIZE);
+ memset(buffer, 0, STR_PROTO_SIZE);
- ret = readSdlUdpSocket(sock_server_sdl_udp, sock_client, buffer, STR_SIZE-1);
+ ret = readSdlUdpSocket(sock_server_sdl_udp, sock_client, buffer, STR_PROTO_SIZE-1);
if( ret < 0 )
{
diff --git a/src/tux.c b/src/tux.c
index 2c9c6a0..9672f28 100644
--- a/src/tux.c
+++ b/src/tux.c
@@ -679,8 +679,8 @@ static void eventBonus(tux_t *tux)
tux->bonus_time--;
}
- if( tux->bonus_time == 0 )
- {
+ if( tux->bonus_time == 0 && getNetTypeGame() != NET_GAME_TYPE_CLIENT )
+ {
if( tux->bonus == BONUS_GHOST )
{
int x, y, w, h;