summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.h2
-rw-r--r--include/server.h2
-rwxr-xr-xsrc/Makefile5
-rwxr-xr-xsrc/Makefile-publicServer5
-rw-r--r--src/client.c20
-rw-r--r--src/screen_gameType.c22
-rw-r--r--src/server.c29
7 files changed, 44 insertions, 41 deletions
diff --git a/config.h b/config.h
index 14e7014..21a71fd 100644
--- a/config.h
+++ b/config.h
@@ -6,7 +6,7 @@
#define DEBUG_CLIENT_RECV
*/
-#define TUXANCI_NG_VERSION "svn71"
+#define TUXANCI_NG_VERSION "svn72"
#define DESTDIR "/usr/local/"
#define SUPPORT_NET_UNIX_UDP
diff --git a/include/server.h b/include/server.h
index 247b836..5942a78 100644
--- a/include/server.h
+++ b/include/server.h
@@ -48,7 +48,7 @@ typedef struct client_struct
tux_t *tux;
my_time_t lastPing;
list_t *listCheck;
- buffer_t *buffer;
+ list_t *buffer;
} client_t;
#ifdef PUBLIC_SERVER
diff --git a/src/Makefile b/src/Makefile
index 5a2a84d..9ff8aa6 100755
--- a/src/Makefile
+++ b/src/Makefile
@@ -12,7 +12,7 @@ LIBS = `sdl-config --libs` -lSDL_image -lSDL_ttf -lSDL_mixer -lSDL_net
FILES = interface.o space.o idManager.o storage.o font.o list.o modules.o\
image.o layer.o director.o configFile.o tux.o main.o checkFront.o\
screen.o screen_world.o shot.o myTimer.o panel.o net_multiplayer.o \
- buffer.o arena.o arenaFile.o textFile.o audio.o sound.o music.o gun.o \
+ arena.o arenaFile.o textFile.o audio.o sound.o music.o gun.o \
item.o widget_label.o screen_mainMenu.o widget_button.o screen_analyze.o widget_textfield.o \
widget_check.o widget_image.o widget_select.o screen_setting.o screen_gameType.o screen_choiceArena.o \
widget_buttonimage.o screen_credits.o homeDirector.o screen_table.o \
@@ -84,9 +84,6 @@ myTimer.o: myTimer.c ../include/myTimer.h
panel.o: panel.c ../include/panel.h
$(CC) $(CFLAGS) -o $(BUILD_DIR)/panel.o -c panel.c
-buffer.o: buffer.c ../include/buffer.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/buffer.o -c buffer.c
-
tcp.o: tcp.c ../include/tcp.h
$(CC) $(CFLAGS) -o $(BUILD_DIR)/tcp.o -c tcp.c
diff --git a/src/Makefile-publicServer b/src/Makefile-publicServer
index 0b4f1fe..437e989 100755
--- a/src/Makefile-publicServer
+++ b/src/Makefile-publicServer
@@ -11,7 +11,7 @@ BUILD_DIR = ../build-server
LIBS = -ldl
FILES = list.o space.o heightScore.o modules.o director.o configFile.o tux.o shot.o myTimer.o \
- buffer.o arena.o arenaFile.o textFile.o gun.o item.o idManager.o checkFront.o\
+ arena.o arenaFile.o textFile.o gun.o item.o idManager.o checkFront.o\
udp.o proto.o server.o publicServer.o net_multiplayer.o serverConfigFile.o main.o
$(BUILD_DIR)/publicserver: mkdir_build $(FILES)
@@ -59,9 +59,6 @@ shot.o: shot.c ../include/shot.h
myTimer.o: myTimer.c ../include/myTimer.h
$(CC) $(CFLAGS) -o $(BUILD_DIR)/myTimer.o -c myTimer.c
-buffer.o: buffer.c ../include/buffer.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/buffer.o -c buffer.c
-
tcp.o: tcp.c ../include/tcp.h
$(CC) $(CFLAGS) -o $(BUILD_DIR)/tcp.o -c tcp.c
diff --git a/src/client.c b/src/client.c
index 138caa0..912b1b0 100644
--- a/src/client.c
+++ b/src/client.c
@@ -26,7 +26,7 @@ static sock_udp_t *sock_server_udp;
static sock_sdl_udp_t *sock_server_sdl_udp;
#endif
-static buffer_t *clientBuffer;
+static list_t *clientBuffer;
static my_time_t lastPing;
static my_time_t lastPingServerAlive;
@@ -34,7 +34,7 @@ static void initClient()
{
char name[STR_NAME_SIZE];
- clientBuffer = newBuffer( LIMIT_BUFFER );
+ clientBuffer = newList();
lastPing = getMyTime();
lastPingServerAlive = getMyTime();
@@ -126,26 +126,31 @@ static int eventServerSelect()
}
#endif
+ addList(clientBuffer, strdup(buffer) );
+/*
if( addBuffer(clientBuffer, buffer, ret) != 0 )
{
fprintf(stderr, "chyba, nemozem zapisovat do mojho buffera !\n");
setWorldEnd();
return ret;
}
-
+*/
return ret;
}
void eventServerBuffer()
{
- char line[STR_PROTO_SIZE];
+ char *line;
+ int i;
/* obsluha udalosti od servera */
assert( clientBuffer != NULL );
- while ( getBufferLine(clientBuffer, line, STR_PROTO_SIZE) >= 0 )
+ for( i = 0 ; i < clientBuffer->count ; i++ )
{
+ line = (char *)clientBuffer->list[i];
+
#ifndef PUBLIC_SERVER
if( isParamFlag("--recv") )
{
@@ -165,6 +170,9 @@ void eventServerBuffer()
lastPingServerAlive = getMyTime();
}
+
+ destroyListItem(clientBuffer, free);
+ clientBuffer = newList();
}
void eventPingServer()
@@ -258,7 +266,7 @@ static void quitClient()
{
proto_send_end_client();
assert( clientBuffer != NULL );
- destroyBuffer(clientBuffer);
+ destroyListItem(clientBuffer, free);
}
#ifdef SUPPORT_NET_UNIX_UDP
diff --git a/src/screen_gameType.c b/src/screen_gameType.c
index 814c9c8..38cdbf8 100644
--- a/src/screen_gameType.c
+++ b/src/screen_gameType.c
@@ -32,7 +32,6 @@ static widget_button_t *button_play;
static widget_label_t *label_none;
static widget_label_t *label_server;
static widget_label_t *label_client;
-static widget_label_t *label_ipv6;
static widget_label_t *label_ip;
static widget_label_t *label_port;
@@ -41,8 +40,6 @@ static widget_check_t *check_none;
static widget_check_t *check_server;
static widget_check_t *check_client;
-static widget_check_t *check_ipv6;
-
static widget_textfield_t *textfield_ip;
static widget_textfield_t *textfield_port;
@@ -65,8 +62,6 @@ void drawScreenGameType()
drawWidgetTextfield(textfield_port);
drawWidgetLabel(label_ip);
drawWidgetTextfield(textfield_ip);
- drawWidgetCheck(check_ipv6);
- drawWidgetLabel(label_ipv6);
}
drawWidgetCheck(check_none);
@@ -82,7 +77,6 @@ void eventScreenGameType()
eventWidgetCheck(check_none);
eventWidgetCheck(check_server);
eventWidgetCheck(check_client);
- eventWidgetCheck(check_ipv6);
eventWidgetTextfield(textfield_ip);
eventWidgetTextfield(textfield_port);
@@ -182,9 +176,6 @@ void initScreenGameType()
textfield_ip = newWidgetTextfield(getParamElse("--ip", "127.0.0.1"), 300, 180);
textfield_port = newWidgetTextfield(getParamElse("--port", "2200"), 300, 280);
- check_ipv6 = newWidgetCheck(300, 330, FALSE, eventWidget);
- label_ipv6 = newWidgetLabel("support IPv6", 330, 325, WIDGET_LABEL_LEFT);
-
registerScreen( newScreen("gameType", startScreenGameType, eventScreenGameType,
drawScreenGameType, stopScreenGameType) );
}
@@ -223,7 +214,18 @@ int getSettingPort()
int getSettingProto()
{
- return ( check_ipv6->status == TRUE ? PROTO_UDPv6 : PROTO_UDPv4 );
+ if( strstr(textfield_ip->text, ".") != NULL )
+ {
+ return PROTO_UDPv4;
+ }
+
+ if( strstr(textfield_ip->text, ":") != NULL )
+ {
+ return PROTO_UDPv6;
+ }
+
+ printf("IP protokol unknown !\n");
+ return -1;
}
void quitScreenGameType()
diff --git a/src/server.c b/src/server.c
index 4575381..2480f4b 100644
--- a/src/server.c
+++ b/src/server.c
@@ -258,7 +258,7 @@ static client_t* newAnyClient()
memset(new, 0, sizeof(client_t));
new->status = NET_STATUS_OK;
- new->buffer = newBuffer(LIMIT_BUFFER);
+ new->buffer = newList();
new->lastPing = getMyTime();
new->listCheck = newCheckFront();
@@ -317,7 +317,7 @@ void destroyClient(client_t *p)
closeSdlUdpSocket(p->socket_sdl_udp);
#endif
- destroyBuffer(p->buffer);
+ destroyListItem(p->buffer, free);
destroyCheckFront(p->listCheck);
if( p->tux != NULL )
@@ -583,14 +583,18 @@ static void eventCreateNewSdlUdpClient(sock_sdl_udp_t *socket_sdl_udp)
static void eventClientBuffer(client_t *client)
{
- char line[STR_PROTO_SIZE];
+ char *line;
+ int i;
assert( client != NULL );
/* obsluha udalosti od clientov */
- while( getBufferLine(client->buffer, line, STR_PROTO_SIZE) >= 0 )
+ //while( getBufferLine(client->buffer, line, STR_PROTO_SIZE) >= 0 )
+ for( i = 0 ; i < client->buffer->count ; i++ )
{
+ line = (char *)client->buffer->list[i];
+
#ifndef PUBLIC_SERVER
if( isParamFlag("--recv") )
{
@@ -651,6 +655,9 @@ static void eventClientBuffer(client_t *client)
proto_send_error_server(PROTO_SEND_ONE, client, PROTO_ERROR_CODE_BAD_COMMAND);
}
}
+
+ destroyListItem(client->buffer, free);
+ client->buffer = newList();
}
void eventClientListBuffer()
@@ -735,11 +742,8 @@ static void eventClientUdpSelect(sock_udp_t *sock_server)
return;
}
- if( addBuffer(client->buffer, buffer, ret) != 0 )
- {
- client->status = NET_STATUS_ZOMBIE;
- return;
- }
+ //printf("add packet >>%s<<\n", buffer);
+ addList(client->buffer, strdup(buffer) );
}
void selectServerUdpSocket()
@@ -904,12 +908,7 @@ void selectServerSdlUdpSocket()
return;
}
- if( addBuffer(client->buffer, buffer, ret) != 0 )
- {
- client->status = NET_STATUS_ZOMBIE;
- return;
- }
-
+ addList(client->buffer, strdup(buffer) );
}while( ret > 0 );
}