summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authororoborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-05-30 17:03:33 +0000
committeroroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-05-30 17:03:33 +0000
commit6f8cef248e1467595a932707eb9a9c53af2e8839 (patch)
tree14beaef0e6253ab3657b59a90231d2788806307a
parent13cb3930e9989aba57f0301a821f64ceed29af20 (diff)
- opravene memory leaky pomocou vlagrindu
- sietovy protokol je navrhnuty tal aby client odsiselal info o tom, ze obdrzal spravu git-svn-id: http://opensvn.csie.org/tuxanci_ng@57 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
-rw-r--r--config.h2
-rw-r--r--include/checkFront.h18
-rw-r--r--include/item.h1
-rw-r--r--include/proto.h2
-rw-r--r--include/server.h8
-rwxr-xr-xsrc/Makefile6
-rwxr-xr-xsrc/Makefile-publicServer5
-rw-r--r--src/checkFront.c121
-rw-r--r--src/client.c20
-rw-r--r--src/idManager.c10
-rw-r--r--src/item.c16
-rw-r--r--src/language.c2
-rw-r--r--src/main.c2
-rw-r--r--src/proto.c130
-rw-r--r--src/screen_analyze.c12
-rw-r--r--src/screen_gameType.c4
-rw-r--r--src/screen_world.c1
-rw-r--r--src/server.c66
18 files changed, 353 insertions, 73 deletions
diff --git a/config.h b/config.h
index cb4dc60..4b3ab74 100644
--- a/config.h
+++ b/config.h
@@ -6,7 +6,7 @@
#define DEBUG_CLIENT_RECV
*/
-#define TUXANCI_NG_VERSION "svn55"
+#define TUXANCI_NG_VERSION "svn57"
#define DESTDIR "/usr/local/"
#define SUPPORT_NET_SDL_UDP
diff --git a/include/checkFront.h b/include/checkFront.h
new file mode 100644
index 0000000..84f6906
--- /dev/null
+++ b/include/checkFront.h
@@ -0,0 +1,18 @@
+
+#ifndef CHECK_FRONT_H
+
+#define CHECK_FRONT_H
+
+#include "list.h"
+#include "server.h"
+
+#define CHECK_FRONT_SEND_TIME_INTERVAL 100
+#define CHECK_FRONT_MAX_COUNT_SEND 30
+
+extern list_t* newCheckFront();
+extern void addMsgInCheckFront(list_t *list, char *msg, int id);
+extern void eventMsgInCheckFront(client_t *client);
+extern void delMsgInCheckFront(list_t *listCheckFront, int id);
+extern void destroyCheckFront(list_t *p);
+
+#endif
diff --git a/include/item.h b/include/item.h
index 423b813..dd67765 100644
--- a/include/item.h
+++ b/include/item.h
@@ -28,7 +28,6 @@ typedef struct item_struct
int frame; //poradove cislo animacie
int count;
- my_time_t lastSync;
int author_id;
#ifndef PUBLIC_SERVER
diff --git a/include/proto.h b/include/proto.h
index 8838a60..5a097a6 100644
--- a/include/proto.h
+++ b/include/proto.h
@@ -53,6 +53,8 @@ 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_check_client(int id);
+extern void proto_recv_check_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 3a07b43..08a8af2 100644
--- a/include/server.h
+++ b/include/server.h
@@ -47,8 +47,7 @@ typedef struct client_struct
int status;
tux_t *tux;
my_time_t lastPing;
- my_time_t lastEvent;
-
+ list_t *listCheck;
buffer_t *buffer;
} client_t;
@@ -77,6 +76,11 @@ 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 addMsgClient(client_t *p, char *msg, int id);
+extern void addMsgAllClientBut(char *msg, client_t *p, int id);
+extern void addMsgAllClient(char *msg, int id);
+
extern void eventClientListBuffer();
extern void sendInfoCreateClient(client_t *client);
extern void eventServer();
diff --git a/src/Makefile b/src/Makefile
index cfc9478..2b66261 100755
--- a/src/Makefile
+++ b/src/Makefile
@@ -10,7 +10,7 @@ BUILD_DIR = .
LIBS = `sdl-config --libs` -lSDL_image -lSDL_ttf -lSDL_mixer -lSDL_net
FILES = interface.o idManager.o font.o list.o modules.o image.o layer.o director.o\
- configFile.o tux.o main.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 \
item.o widget_label.o screen_mainMenu.o widget_button.o screen_analyze.o widget_textfield.o \
@@ -33,8 +33,8 @@ modules.o: modules.c ../include/modules.h
idManager.o: idManager.c ../include/idManager.h
$(CC) $(CFLAGS) -o $(BUILD_DIR)/idManager.o -c idManager.c
-#checkFront.o: checkFront.c ../include/checkFront.h
-# $(CC) $(CFLAGS) -o $(BUILD_DIR)/checkFront.o -c checkFront.c
+checkFront.o: checkFront.c ../include/checkFront.h
+ $(CC) $(CFLAGS) -o $(BUILD_DIR)/checkFront.o -c checkFront.c
font.o: font.c ../include/font.h
$(CC) $(CFLAGS) -o $(BUILD_DIR)/font.o -c font.c
diff --git a/src/Makefile-publicServer b/src/Makefile-publicServer
index 69edffd..f81d845 100755
--- a/src/Makefile-publicServer
+++ b/src/Makefile-publicServer
@@ -11,7 +11,7 @@ BUILD_DIR = ../build-server
LIBS = -ldl
FILES = list.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\
+ buffer.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)
@@ -29,6 +29,9 @@ idManager.o: idManager.c ../include/idManager.h
modules.o: modules.c
$(CC) $(CFLAGS) -o $(BUILD_DIR)/modules.o -c modules.c
+checkFront.o: checkFront.c ../include/checkFront.h
+ $(CC) $(CFLAGS) -o $(BUILD_DIR)/checkFront.o -c checkFront.c
+
publicServer.o: publicServer.c
$(CC) $(CFLAGS) -o $(BUILD_DIR)/publicServer.o -c publicServer.c
diff --git a/src/checkFront.c b/src/checkFront.c
new file mode 100644
index 0000000..340a8d8
--- /dev/null
+++ b/src/checkFront.c
@@ -0,0 +1,121 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "main.h"
+#include "list.h"
+#include "myTimer.h"
+#include "checkFront.h"
+#include "idManager.h"
+#include "server.h"
+
+typedef struct struct_checkfront_t
+{
+ char *msg;
+ my_time_t time;
+ int id;
+ int count;
+} checkfront_t;
+
+static checkfront_t* newCheck(char *s, int id)
+{
+ checkfront_t *new;
+
+ assert( s != NULL );
+
+ new = malloc( sizeof(checkfront_t) );
+ memset(new, 0, sizeof(checkfront_t));
+
+ new->msg = strdup(s);
+ new->time = getMyTime();
+ new->id = id;
+ new->count = 0;
+
+ return new;
+}
+
+static void destroyCheck(checkfront_t *p)
+{
+ assert( p != NULL );
+
+ free(p->msg);
+ free(p);
+}
+
+
+list_t* newCheckFront()
+{
+ return newList();
+}
+
+void addMsgInCheckFront(list_t *list, char *msg, int id)
+{
+ addList(list, newCheck(msg, id) );
+}
+
+
+void eventMsgInCheckFront(client_t *client)
+{
+ my_time_t currentTime;
+ int i;
+
+ currentTime = getMyTime();
+
+ for( i = 0 ; i < client->listCheck->count ; i++ )
+ {
+ checkfront_t *this;
+
+ this = (checkfront_t *)client->listCheck->list[i];
+
+ if( this->count == 0 || currentTime - this->time > CHECK_FRONT_SEND_TIME_INTERVAL )
+ {
+ sendClient(client, this->msg);
+ this->time = currentTime;
+ this->count++;
+ }
+
+ if( this->count > CHECK_FRONT_MAX_COUNT_SEND )
+ {
+ if( isRegisterID(this->id) != -1 )
+ {
+ delID(this->id);
+ }
+
+ delListItem(client->listCheck, i, destroyCheck);
+ i--;
+ }
+ }
+}
+
+void delMsgInCheckFront(list_t *listCheckFront, int id)
+{
+ int i;
+
+ for( i = 0 ; i < listCheckFront->count ; i++ )
+ {
+ checkfront_t *this;
+
+ this = (checkfront_t *)listCheckFront->list[i];
+
+ if( this->id == id )
+ {
+ if( isRegisterID(this->id) != -1 )
+ {
+ delID(this->id);
+ }
+
+ delListItem(listCheckFront, i, destroyCheck);
+ return;
+ }
+ }
+}
+
+void destroyCheckFront(list_t *p)
+{
+ assert( p != NULL );
+
+ destroyListItem(p, destroyCheck);
+}
+
diff --git a/src/client.c b/src/client.c
index c770f3c..2d98790 100644
--- a/src/client.c
+++ b/src/client.c
@@ -88,6 +88,13 @@ void sendServer(char *msg)
assert( msg != NULL );
+#ifndef PUBLIC_SERVER
+ if( isParamFlag("--send") )
+ {
+ printf("send -> %s", msg);
+ }
+#endif
+
#ifdef SUPPORT_NET_UNIX_UDP
ret = writeUdpSocket(sock_server_udp, sock_server_udp, msg, strlen(msg));
#endif
@@ -95,10 +102,6 @@ void sendServer(char *msg)
#ifdef SUPPORT_NET_SDL_UDP
ret = writeSdlUdpSocket(sock_server_sdl_udp, sock_server_sdl_udp, msg, strlen(msg));
#endif
-
-#ifdef DEBUG_CLIENT_SEND
- printf("send server msg->%s", msg);
-#endif
}
static int eventServerSelect()
@@ -141,10 +144,12 @@ void eventServerBuffer()
while ( getBufferLine(clientBuffer, line, STR_PROTO_SIZE) >= 0 )
{
-#ifdef DEBUG_CLIENT_RECV
+#ifndef PUBLIC_SERVER
+ if( isParamFlag("--recv") )
+ {
+ printf("recv -> %s", line);
+ }
#endif
- printf("recv server msg->%s", line);
-
if( strncmp(line, "error", 5) == 0 )proto_recv_error_client(line);
if( strncmp(line, "init", 4) == 0 )proto_recv_init_client(line);
if( strncmp(line, "event", 5) == 0 )proto_recv_event_client(line);
@@ -163,7 +168,6 @@ void eventServerBuffer()
}
}
-
void eventPingServer()
{
my_time_t currentTime;
diff --git a/src/idManager.c b/src/idManager.c
index ef46433..9c866c9 100644
--- a/src/idManager.c
+++ b/src/idManager.c
@@ -8,10 +8,12 @@
#include "idManager.h"
static list_t *listID;
+static int lastID;
void initListID()
{
listID = newList();
+ lastID = 0;
printf("init ID manger..\n");
}
@@ -43,7 +45,13 @@ int getNewID()
assert( listID != NULL );
do{
- ret = random() % MAX_ID + 1;
+ ret = ++lastID;
+
+ if( lastID > MAX_ID )
+ {
+ lastID = 0;
+ }
+
}while( isRegisterID(ret) != -1 );
addList(listID, newInt(ret) );
diff --git a/src/item.c b/src/item.c
index 63e7890..9a05601 100644
--- a/src/item.c
+++ b/src/item.c
@@ -80,7 +80,6 @@ item_t* newItem(int x, int y, int type, int author_id)
new->img = g_item[type];
#endif
new->author_id = author_id;
- new->lastSync = getMyTime();
switch( type )
{
@@ -270,16 +269,6 @@ void eventListItem(list_t *listItem)
thisItem = (item_t *)listItem->list[i];
assert( thisItem != NULL );
- if( getNetTypeGame() == NET_GAME_TYPE_CLIENT )
- {
- if( currentTime - thisItem->lastSync > ITEM_SYNC_TIMEOUT )
- {
- delListItem(listItem, i, destroyItem);
- i--;
- continue;
- }
- }
-
thisItem->count++;
if( thisItem->count == ITEM_MAX_COUNT )
@@ -361,7 +350,7 @@ void mineExplosion(list_t *listItem, item_t *item)
index = searchListItem(listItem, item);
- assert( index != -1 );
+ if( index == -1 )return;
/*
x = ( item->x + item->w/2 ) - ITEM_BIG_EXPLOSION_WIDTH/2;
@@ -390,7 +379,6 @@ void mineExplosion(list_t *listItem, item_t *item)
delListItem(listItem, index, destroyItem);
}
-
void eventConflictShotWithItem(list_t *listItem, list_t *listShot)
{
shot_t *thisShot;
@@ -532,7 +520,7 @@ int eventGiveTuxItem(tux_t *tux, list_t *listItem, item_t *item)
index = searchListItem(listItem, item);
- assert( index != -1 );
+ if( index == -1 ) return -1;
switch( item->type )
{
diff --git a/src/language.c b/src/language.c
index ee9b18c..d1b20e8 100644
--- a/src/language.c
+++ b/src/language.c
@@ -70,6 +70,8 @@ int initLanguage()
printf("select lang %s\n", lang);
sprintf(path, PATH_LANG "%s.lang", lang);
+
+ destroyTextFile(languageTypeFile);
accessExistFile(path);
languageFile = loadTextFile(path);
diff --git a/src/main.c b/src/main.c
index 193148a..7e98938 100644
--- a/src/main.c
+++ b/src/main.c
@@ -93,7 +93,7 @@ void accessExistFile(const char *s)
{
if( access(s, F_OK) != 0 )
{
- fprintf(stderr, "File %s not fount !\nProgram shutdown !\n", s);
+ fprintf(stderr, "File %s not found !\nProgram shutdown !\n", s);
exit(-1);
}
}
diff --git a/src/proto.c b/src/proto.c
index 508a56c..d925011 100644
--- a/src/proto.c
+++ b/src/proto.c
@@ -14,6 +14,8 @@
#include "server.h"
#include "proto.h"
#include "net_multiplayer.h"
+#include "checkFront.h"
+#include "idManager.h"
#ifndef PUBLIC_SERVER
#include "network.h"
@@ -37,23 +39,38 @@ static void proto_send(int type, client_t *client, char *msg)
case PROTO_SEND_ONE :
assert( client != NULL );
sendClient(client, msg);
-#ifdef DEBUG_SERVER_SEND
- printf("send one client msg->%s\n", msg);
-#endif
break;
case PROTO_SEND_ALL :
assert( client == NULL );
sendAllClient(msg);
-#ifdef DEBUG_SERVER_SEND
- printf("send all clients msg->%s\n", msg);
-#endif
break;
case PROTO_SEND_BUT :
assert( client != NULL );
sendAllClientBut(msg, client);
-#ifdef DEBUG_SERVER_SEND
- printf("send but client msg->%s\n", msg);
-#endif
+ break;
+ default :
+ assert( ! "Premenna type ma zlu hodnotu !" );
+ break;
+ }
+}
+
+static void proto_check(int type, client_t *client, char *msg, int id)
+{
+ assert( msg != NULL );
+
+ switch( type )
+ {
+ case PROTO_SEND_ONE :
+ assert( client != NULL );
+ addMsgClient(client, msg, id);
+ break;
+ case PROTO_SEND_ALL :
+ assert( client == NULL );
+ addMsgAllClient(msg, id);
+ break;
+ case PROTO_SEND_BUT :
+ assert( client != NULL );
+ addMsgAllClientBut(msg, client, id);
break;
default :
assert( ! "Premenna type ma zlu hodnotu !" );
@@ -153,6 +170,31 @@ void proto_recv_status_server(client_t *client, char *msg)
proto_send_status_server(PROTO_SEND_ONE, client);
}
+#ifndef PUBLIC_SERVER
+
+void proto_send_check_client(int id)
+{
+ char msg[STR_PROTO_SIZE];
+
+ sprintf(msg, "check %d\n", id);
+ sendServer(msg);
+}
+
+#endif
+
+void proto_recv_check_server(client_t *client, char *msg)
+{
+ char cmd[STR_PROTO_SIZE];
+ int id;
+
+ assert( msg != NULL );
+
+ sscanf(msg, "%s %d",
+ cmd, &id);
+
+ delMsgInCheckFront(client->listCheck, id);
+}
+
void proto_send_init_server(int type, client_t *client, client_t *client2)
{
char msg[STR_PROTO_SIZE];
@@ -467,13 +509,17 @@ void proto_recv_deltux_client(char *msg)
void proto_send_additem_server(int type, client_t *client, item_t *p)
{
char msg[STR_PROTO_SIZE];
+ int check_id;
assert( p != NULL );
- sprintf(msg, "additem %d %d %d %d %d %d %d\n",
- p->id, p->type, p->x, p->y, p->count, p->frame, p->author_id);
+ check_id = getNewID();
- proto_send(type, client, msg);
+ sprintf(msg, "additem %d %d %d %d %d %d %d %d\n",
+ p->id, p->type, p->x, p->y, p->count, p->frame, p->author_id, check_id);
+
+ //proto_send(type, client, msg);
+ proto_check(type, client, msg, check_id);
}
#ifndef PUBLIC_SERVER
@@ -481,7 +527,7 @@ void proto_send_additem_server(int type, client_t *client, item_t *p)
void proto_recv_additem_client(char *msg)
{
char cmd[STR_PROTO_SIZE];
- int id, type, x, y, count, frame, author_id;
+ int id, type, x, y, count, frame, author_id, check_id;
item_t *item;
assert( msg != NULL );
@@ -491,11 +537,13 @@ void proto_recv_additem_client(char *msg)
return;
}
- sscanf(msg, "%s %d %d %d %d %d %d %d", cmd, &id, &type, &x, &y, &count, &frame, &author_id);
+ sscanf(msg, "%s %d %d %d %d %d %d %d %d",
+ cmd, &id, &type, &x, &y, &count, &frame, &author_id, &check_id);
+
+ proto_send_check_client(check_id);
if( ( item = getItemID(getCurrentArena()->listItem, id) ) != NULL )
{
- item->lastSync = getMyTime();
return;
}
@@ -510,7 +558,6 @@ void proto_recv_additem_client(char *msg)
replaceItemID(item, id);
item->count = count;
item->frame = frame;
- item->lastSync = getMyTime();
addList(getCurrentArena()->listItem, item);
}
@@ -521,6 +568,7 @@ void proto_send_item_server(int type, client_t *client, tux_t *tux, item_t *item
{
char msg[STR_PROTO_SIZE];
int tux_id = -1;
+ int check_id;
assert( item != NULL );
@@ -529,10 +577,13 @@ void proto_send_item_server(int type, client_t *client, tux_t *tux, item_t *item
tux_id = tux->id;
}
- sprintf(msg, "item %d %d\n",
- tux_id, item->id);
+ check_id = getNewID();
- proto_send(type, client, msg);
+ sprintf(msg, "item %d %d %d\n",
+ tux_id, item->id, check_id);
+
+ //proto_send(type, client, msg);
+ proto_check(type, client, msg, check_id);
}
#ifndef PUBLIC_SERVER
@@ -540,7 +591,7 @@ void proto_send_item_server(int type, client_t *client, tux_t *tux, item_t *item
void proto_recv_item_client(char *msg)
{
char cmd[STR_PROTO_SIZE];
- int tux_id, item_id;
+ int tux_id, item_id, check_id;
arena_t *arena;
item_t *item;
@@ -548,7 +599,10 @@ void proto_recv_item_client(char *msg)
assert( msg != NULL );
- sscanf(msg, "%s %d %d", cmd, &tux_id, &item_id);
+ sscanf(msg, "%s %d %d %d",
+ cmd, &tux_id, &item_id, &check_id);
+
+ proto_send_check_client(check_id);
arena = getCurrentArena();
@@ -575,13 +629,16 @@ void proto_recv_item_client(char *msg)
void proto_send_shot_server(int type, client_t *client, shot_t *p)
{
char msg[STR_PROTO_SIZE];
+ int check_id;
assert( p != NULL );
-
- sprintf(msg, "shot %d %d %d %d %d %d %d %d %d\n",
- p->id, p->x, p->y, p->px, p->py, p->position, p->gun, p->author_id, p->isCanKillAuthor);
- proto_send(type, client, msg);
+ check_id = getNewID();
+ sprintf(msg, "shot %d %d %d %d %d %d %d %d %d %d\n",
+ p->id, p->x, p->y, p->px, p->py, p->position, p->gun, p->author_id, p->isCanKillAuthor, check_id);
+
+ //proto_send(type, client, msg);
+ proto_check(type, client, msg, check_id);
}
#ifndef PUBLIC_SERVER
@@ -589,14 +646,15 @@ void proto_send_shot_server(int type, client_t *client, shot_t *p)
void proto_recv_shot_client(char *msg)
{
char cmd[STR_PROTO_SIZE];
- int x, y, px, py, position, gun, shot_id, author_id, isCanKillAuthor;
+ int x, y, px, py, position, gun, shot_id, author_id, isCanKillAuthor, check_id;
shot_t *shot;
assert( msg != NULL );
- sscanf(msg, "%s %d %d %d %d %d %d %d %d %d",
- cmd, &shot_id, &x, &y, &px, &py, &position, &gun, &author_id, &isCanKillAuthor);
+ sscanf(msg, "%s %d %d %d %d %d %d %d %d %d %d",
+ cmd, &shot_id, &x, &y, &px, &py, &position, &gun, &author_id, &isCanKillAuthor, &check_id);
+ proto_send_check_client(check_id);
if( ( shot = getShotID(getCurrentArena()->listShot, shot_id) ) != NULL )
{
@@ -625,12 +683,16 @@ void proto_recv_shot_client(char *msg)
void proto_send_delshot_server(int type, client_t *client, shot_t *shot)
{
char msg[STR_PROTO_SIZE];
+ int check_id;
assert( shot != NULL );
- sprintf(msg, "delshot %d\n", shot->id);
+ check_id = getNewID();
- proto_send(type, client, msg);
+ sprintf(msg, "delshot %d %d\n",
+ shot->id, check_id);
+
+ proto_check(type, client, msg, check_id);
}
#ifndef PUBLIC_SERVER
@@ -639,12 +701,14 @@ void proto_recv_delshot_client(char *msg)
{
char cmd[STR_PROTO_SIZE];
shot_t *shot;
- int id;
+ int id, check_id;
assert( msg != NULL );
- sscanf(msg, "%s %d",
- cmd, &id);
+ sscanf(msg, "%s %d %d",
+ cmd, &id, &check_id);
+
+ proto_send_check_client(check_id);
shot = getShotID(getCurrentArena()->listShot, id);
diff --git a/src/screen_analyze.c b/src/screen_analyze.c
index 6cb92a1..c223677 100644
--- a/src/screen_analyze.c
+++ b/src/screen_analyze.c
@@ -108,18 +108,24 @@ void addAnalyze(char *name, int score)
void endAnalyze()
{
- analyze_t *this;
int i;
for( i = 0 ; i < listAnalyze->count ; i++ )
{
+ analyze_t *this;
+ char *str;
+
this = (analyze_t *)(listAnalyze->list[i]);
addList(listWidgetLabelName, newWidgetLabel(this->name,
100, 200 + 20*i, WIDGET_LABEL_LEFT) );
- addList(listWidgetLabelScore, newWidgetLabel(getString(this->score),
+ str = getString(this->score);
+
+ addList(listWidgetLabelScore, newWidgetLabel(str,
WINDOW_SIZE_X - 100, 200 + 20*i, WIDGET_LABEL_RIGHT) );
+
+ free(str);
}
}
@@ -148,5 +154,7 @@ void quitScreenAnalyze()
destroyListItem(listWidgetLabelName, destroyWidgetLabel);
destroyListItem(listWidgetLabelScore, destroyWidgetLabel);
destroyListItem(listAnalyze, destroyAnalyze);
+
+ destroyWidgetButton(button_ok);
}
diff --git a/src/screen_gameType.c b/src/screen_gameType.c
index def7fc1..da0e73e 100644
--- a/src/screen_gameType.c
+++ b/src/screen_gameType.c
@@ -233,5 +233,9 @@ void quitScreenGameType()
destroyWidgetButton(button_back);
destroyWidgetButton(button_play);
+
+ destroyWidgetCheck(check_none);
+ destroyWidgetCheck(check_server);
+ destroyWidgetCheck(check_client);
}
diff --git a/src/screen_world.c b/src/screen_world.c
index c1211f3..907f659 100644
--- a/src/screen_world.c
+++ b/src/screen_world.c
@@ -422,6 +422,7 @@ void stoptWorld()
delAllImageInGroup(IMAGE_GROUP_USER);
delAllMusicInGroup(MUSIC_GROUP_USER);
quitModule();
+ quitTerm();
quitListID();
}
diff --git a/src/server.c b/src/server.c
index 905ca4b..ab45fef 100644
--- a/src/server.c
+++ b/src/server.c
@@ -19,6 +19,7 @@
#include "myTimer.h"
#include "arena.h"
#include "net_multiplayer.h"
+#include "checkFront.h"
#ifndef PUBLIC_SERVER
#include "screen_world.h"
@@ -88,10 +89,9 @@ static void eventPeriodicSyncClient(void *p_nothink)
{
client_t *thisClientInfo;
client_t *thisClientSend;
- item_t *thisItem;
tux_t *thisTux;
int i, j;
-
+/*
for( i = 0 ; i < getCurrentArena()->listItem->count; i++)
{
thisItem = (item_t *) getCurrentArena()->listItem->list[i];
@@ -101,7 +101,7 @@ static void eventPeriodicSyncClient(void *p_nothink)
proto_send_additem_server(PROTO_SEND_ALL, NULL, thisItem);
}
}
-
+*/
for( i = 0 ; i < listClient->count; i++)
{
thisClientSend = (client_t *) listClient->list[i];
@@ -227,7 +227,7 @@ static client_t* newAnyClient()
new->status = NET_STATUS_OK;
new->buffer = newBuffer(LIMIT_BUFFER);
new->lastPing = getMyTime();
- new->lastEvent = getMyTime();
+ new->listCheck = newCheckFront();
return new;
}
@@ -280,6 +280,7 @@ void destroyClient(client_t *p)
#endif
destroyBuffer(p->buffer);
+ destroyCheckFront(p->listCheck);
if( p->tux != NULL )
{
@@ -314,6 +315,13 @@ void sendClient(client_t *p, char *msg)
{
int ret;
+#ifndef PUBLIC_SERVER
+ if( isParamFlag("--send") )
+ {
+ printf("send -> %s", msg);
+ }
+#endif
+
#ifdef SUPPORT_NET_UNIX_UDP
ret = writeUdpSocket(sock_server_udp, p->socket_udp, msg, strlen(msg));
#endif
@@ -349,6 +357,42 @@ void sendAllClient(char *msg)
sendAllClientBut(msg, NULL);
}
+void addMsgClient(client_t *p, char *msg, int id)
+{
+ assert( p != NULL );
+ assert( msg != NULL );
+
+ if( p->status != NET_STATUS_ZOMBIE )
+ {
+ addMsgInCheckFront(p->listCheck, msg, id);
+ }
+}
+
+void addMsgAllClientBut(char *msg, client_t *p, 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, id);
+ }
+ }
+}
+
+void addMsgAllClient(char *msg, int id)
+{
+ assert( msg != NULL );
+
+ addMsgAllClientBut(msg, NULL, id);
+}
+
void sendInfoCreateClient(client_t *client)
{
client_t *thisClient;
@@ -422,8 +466,11 @@ static void eventClientBuffer(client_t *client)
while( getBufferLine(client->buffer, line, STR_PROTO_SIZE) >= 0 )
{
-#ifdef DEBUG_SERVER_RECV
- printf("recv client msg->%s", line);
+#ifndef PUBLIC_SERVER
+ if( isParamFlag("--recv") )
+ {
+ printf("recv -> %s", line);
+ }
#endif
client->lastPing = getMyTime();
@@ -447,6 +494,12 @@ static void eventClientBuffer(client_t *client)
continue;
}
+ if( strncmp(line, "check", 5) == 0 )
+ {
+ proto_recv_check_server(client, line);
+ continue;
+ }
+
if( strncmp(line, "ping", 4) == 0 )
{
proto_recv_ping_server(client, line);
@@ -476,6 +529,7 @@ void eventClientListBuffer()
{
thisClient = (client_t *) listClient->list[i];
eventClientBuffer(thisClient);
+ eventMsgInCheckFront(thisClient);
}
}