summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authororoborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-03-30 16:51:15 +0000
committeroroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-03-30 16:51:15 +0000
commit617ba439aab5f1798eb02618dfcfbed80a5baf28 (patch)
tree13df71c96bd302f066406644f20ddd0e58490ded
parentb4db5fe1a7c0145c2437cb2f117a2ae59d4e8025 (diff)
- polozky casovaca sa nachadzaju v zozname list_t , ktory he sucastou arena_t
- pri bonuse neviditelnost sa neda podvadzat modifikovanim clienta - o vystreli sa stara server, ich suradnicu a dalsie info posiela server clientom - parametre sa pisu vo forme --env=val git-svn-id: http://opensvn.csie.org/tuxanci_ng@38 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
-rw-r--r--config.h3
-rw-r--r--include/arena.h1
-rw-r--r--include/main.h4
-rw-r--r--include/myTimer.h11
-rw-r--r--include/server.h2
-rw-r--r--include/udp.h2
-rw-r--r--src/arena.c8
-rw-r--r--src/arenaFile.c12
-rw-r--r--src/client.c4
-rw-r--r--src/gun.c25
-rw-r--r--src/main.c17
-rw-r--r--src/myTimer.c48
-rw-r--r--src/net_multiplayer.c2
-rw-r--r--src/proto.c15
-rw-r--r--src/publicServer.c22
-rw-r--r--src/screen_world.c8
-rw-r--r--src/sdl_udp.c6
-rw-r--r--src/server.c11
-rw-r--r--src/tux.c19
-rw-r--r--src/udp.c13
20 files changed, 137 insertions, 96 deletions
diff --git a/config.h b/config.h
index aa8c687..5f78ee3 100644
--- a/config.h
+++ b/config.h
@@ -6,7 +6,8 @@
#define DEBUG_CLIENT_RECV
*/
-#define TUXANCI_NG_VERSION "svn37"
+#define TUXANCI_NG_VERSION "svn38"
#define DESTDIR "/usr/local/"
#define SUPPORT_NET_SDL_UDP
+//#define DEBUG_LOST_PACKET 2
diff --git a/include/arena.h b/include/arena.h
index 551c2c2..f133c14 100644
--- a/include/arena.h
+++ b/include/arena.h
@@ -17,6 +17,7 @@ typedef struct arena_struct
SDL_Surface *background;
#endif
+ list_t *listTimer;
list_t *listTux;
list_t *listShot;
list_t *listWall;
diff --git a/include/main.h b/include/main.h
index f0b15c1..0b96144 100644
--- a/include/main.h
+++ b/include/main.h
@@ -5,9 +5,11 @@
#include "../config.h"
-#if defined SUPPORT_NET_UNIX_UDP && defined SUPPORT_NET_SDL_UDP
+#if defined PUBLIC_SERVER
+#undef DESTDIR
#undef SUPPORT_NET_SDL_UDP
+#undef SUPPORT_NET_UNIX_TCP
#endif
diff --git a/include/myTimer.h b/include/myTimer.h
index fbb83a8..21738bb 100644
--- a/include/myTimer.h
+++ b/include/myTimer.h
@@ -15,12 +15,11 @@ typedef struct my_timer_struct
my_time_t time;
} my_timer_t;
-extern bool_t isMyTimerInit();
-extern void initTimer();
+extern list_t* newTimer();
extern my_time_t getMyTime();
-extern int addTimer(void (*fce)(void *p), void *arg, my_time_t my_time);
-extern void eventTimer();
-extern void delTimer(int id);
-extern void quitTimer();
+extern int addTimer(list_t *listTimer, void (*fce)(void *p), void *arg, my_time_t my_time);
+extern void eventTimer(list_t *listTimer);
+extern void delTimer(list_t *listTimer, int id);
+extern void destroyTimer(list_t *listTimer);
#endif
diff --git a/include/server.h b/include/server.h
index 397eb41..066c170 100644
--- a/include/server.h
+++ b/include/server.h
@@ -67,7 +67,7 @@ extern void quitTcpServer();
#endif
#ifdef SUPPORT_NET_UNIX_UDP
-extern int initUdpServer(int port);
+extern int initUdpServer(char *ip, int port);
extern client_t* newUdpClient(sock_udp_t *sock_udp);
extern void selectServerUdpSocket();
extern void quitUdpServer();
diff --git a/include/udp.h b/include/udp.h
index 9d7be85..ce89c53 100644
--- a/include/udp.h
+++ b/include/udp.h
@@ -15,7 +15,7 @@ typedef struct struct_sock_udp_t
extern sock_udp_t* newSockUdp();
extern void destroySockUdp(sock_udp_t *p);
-extern sock_udp_t* bindUdpSocket(int port);
+extern sock_udp_t* bindUdpSocket(char *address, int port);
extern sock_udp_t* connectUdpSocket(char *address, int port);
extern int readUdpSocket(sock_udp_t *src, sock_udp_t *dst, void *address, int len);
extern int writeUdpSocket(sock_udp_t *src, sock_udp_t *dst, void *address, int len);
diff --git a/src/arena.c b/src/arena.c
index 5e7d1bf..760c51b 100644
--- a/src/arena.c
+++ b/src/arena.c
@@ -12,6 +12,7 @@
#include "item.h"
#include "teleport.h"
#include "pipe.h"
+#include "myTimer.h"
#ifndef PUBLIC_SERVER
#include "layer.h"
@@ -39,12 +40,13 @@ arena_t* newArena()
strcpy(new->music, "");
#endif
+ new->listTimer = newList();
new->listTux = newList();
new->listShot = newList();
new->listWall = newList();
new->listItem = newList();
new->listTeleport = newList();
- new->listPipe = newList();
+ new->listPipe = newTimer();
return new;
}
@@ -133,6 +135,8 @@ void eventArena(arena_t *arena)
eventListItem(arena->listItem);
eventListTux(arena->listTux);
+
+ eventTimer(arena->listTimer);
}
void destroyArena(arena_t *p)
@@ -143,6 +147,6 @@ void destroyArena(arena_t *p)
destroyListItem(p->listItem, destroyItem);
destroyListItem(p->listTeleport, destroyItem);
destroyListItem(p->listPipe, destroyItem);
-
+ destroyTimer(p->listTimer);
free(p);
}
diff --git a/src/arenaFile.c b/src/arenaFile.c
index 5c89476..fdf80fb 100644
--- a/src/arenaFile.c
+++ b/src/arenaFile.c
@@ -296,13 +296,7 @@ void initArenaFile()
isArenaFileInit = TRUE;
listArenaFile = newList();
-#ifndef PUBLIC_SERVER
p = loadDirector(PATH_ARENA);
-#endif
-
-#ifdef PUBLIC_SERVER
- p = loadDirector(PUBLIC_SERVER_PATH_ARENA);
-#endif
for( i = 0 ; i < p->list->count ; i++ )
{
@@ -314,12 +308,8 @@ void initArenaFile()
{
char path[STR_PATH_SIZE];
-#ifndef PUBLIC_SERVER
sprintf(path, PATH_ARENA "%s", line);
-#endif
-#ifdef PUBLIC_SERVER
- sprintf(path, PUBLIC_SERVER_PATH_ARENA "%s", line);
-#endif
+
printf("load map %s\n", line);
addList(listArenaFile, loadTextFile(path));
}
diff --git a/src/client.c b/src/client.c
index f942b60..8e5aae3 100644
--- a/src/client.c
+++ b/src/client.c
@@ -202,9 +202,9 @@ void eventServerBuffer()
while ( getBufferLine(clientBuffer, line, STR_PROTO_SIZE) >= 0 )
{
-//#ifdef DEBUG_CLIENT_RECV
+#ifdef DEBUG_CLIENT_RECV
printf("recv server msg->%s", line);
-//#endif
+#endif
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);
diff --git a/src/gun.c b/src/gun.c
index 1a9ae9b..9433b4c 100644
--- a/src/gun.c
+++ b/src/gun.c
@@ -60,6 +60,11 @@ static void addShotTrivial(tux_t *tux, int x, int y, int px, int py, int gun)
int dest_px = 0, dest_py = 0;
shot_t *shot;
+ if( getNetTypeGame() == NET_GAME_TYPE_CLIENT )
+ {
+ return;
+ }
+
modificiationCopuse(tux->position, px, py, &dest_px, &dest_py);
modificiationCopuse(tux->position, x, y, &dest_x, &dest_y);
@@ -79,6 +84,12 @@ static void addShotTrivial(tux_t *tux, int x, int y, int px, int py, int gun)
shot = newShot(tux->x + dest_x, tux->y + dest_y, dest_px, dest_py, gun, tux);
addList( getCurrentArena()->listShot, shot );
+
+ if( getNetTypeGame() == NET_GAME_TYPE_SERVER )
+ {
+ proto_send_shot_server(PROTO_SEND_ALL, NULL, shot);
+ }
+
}
static void addShot(tux_t *tux,int x, int y, int px, int py)
@@ -156,6 +167,8 @@ static void timer_addShotTimer(void *p)
if( tux == NULL )return;
+ if( tux->status != TUX_STATUS_ALIVE )return;
+
gun = tux->gun;
tux->gun = GUN_SIMPLE;
addShot(tux, 0, 0, +6, 0);
@@ -168,7 +181,7 @@ static void shotInGunTommy(tux_t *tux)
for( i = 0 ; i < 10 ; i++ )
{
- addTimer(timer_addShotTimer, newInt(tux->id), i * 100 );
+ addTimer(getCurrentArena()->listTimer, timer_addShotTimer, newInt(tux->id), i * 100 );
}
}
@@ -185,6 +198,7 @@ static void timer_addLaserTimer(void *p)
if( tux == NULL )return;
+ if( tux->status != TUX_STATUS_ALIVE )return;
gun = tux->gun;
tux->gun = GUN_LASSER;
@@ -198,7 +212,7 @@ static void shotInGunLasser(tux_t *tux)
for( i = 0 ; i < 50 ; i++ )
{
- addTimer(timer_addLaserTimer, newInt(tux->id), i * 10 );
+ addTimer(getCurrentArena()->listTimer, timer_addLaserTimer, newInt(tux->id), i * 10 );
}
}
@@ -245,7 +259,12 @@ static void putInGunMine(tux_t *tux)
if( getNetTypeGame() != NET_GAME_TYPE_CLIENT )
{
item = newItem(x, y, ITEM_MINE, tux);
- proto_send_additem_server(PROTO_SEND_ALL, NULL, item);
+
+ if( getNetTypeGame() == NET_GAME_TYPE_SERVER )
+ {
+ proto_send_additem_server(PROTO_SEND_ALL, NULL, item);
+ }
+
addList(arena->listItem, item );
}
}
diff --git a/src/main.c b/src/main.c
index e0e13d4..27d89aa 100644
--- a/src/main.c
+++ b/src/main.c
@@ -100,18 +100,29 @@ void quit()
char* getParam(char *s)
{
int i;
+ int len;
- for( i = 0 ; i < my_argc - 1 ; i++ )
+ len = strlen(s);
+
+ for( i = 1 ; i < my_argc ; i++ )
{
- if( strcmp(s, my_argv[i]) == 0 )
+ //printf("%s %s\n", s, my_argv[i]);
+
+ if( strlen(my_argv[i]) < len )
+ {
+ continue;
+ }
+
+ if( strncmp(s, my_argv[i], len) == 0 )
{
- return my_argv[i+1];
+ return strchr(my_argv[i], '=')+1;
}
}
return NULL;
}
+
char* getParamElse(char *s1, char *s2)
{
char *ret;
diff --git a/src/myTimer.c b/src/myTimer.c
index b513835..a9393dd 100644
--- a/src/myTimer.c
+++ b/src/myTimer.c
@@ -13,19 +13,10 @@
#include "interface.h"
#endif
-static list_t *listTime;
-static bool_t isTimerInit = FALSE;
-
-bool_t isMyTimerInicialized()
-{
- return isTimerInit;
-}
-
-void initTimer()
+list_t* newTimer()
{
- listTime = newList();
- isTimerInit = TRUE;
+ return newList();
}
my_time_t getMyTime()
@@ -46,7 +37,7 @@ my_time_t getMyTime()
return ticks;
}
-int addTimer(void (*fce)(void *p), void *arg, my_time_t my_time)
+int addTimer(list_t *listTimer, void (*fce)(void *p), void *arg, my_time_t my_time)
{
static int new_id = 0;
my_timer_t *new;
@@ -62,12 +53,12 @@ int addTimer(void (*fce)(void *p), void *arg, my_time_t my_time)
new->arg = arg;
new->time = currentTime + my_time;
- addList(listTime, new);
+ addList(listTimer, new);
return new->id;
}
-void eventTimer()
+void eventTimer(list_t *listTimer)
{
int i;
my_timer_t *thisTimer;
@@ -75,39 +66,34 @@ void eventTimer()
currentTime = getMyTime();
- for( i = 0 ; i < listTime->count ; i++ )
+ for( i = 0 ; i < listTimer->count ; i++ )
{
- thisTimer = (my_timer_t *)listTime->list[i];
+ thisTimer = (my_timer_t *)listTimer->list[i];
assert( thisTimer != NULL );
if( currentTime >= thisTimer->time )
{
thisTimer->fce(thisTimer->arg);
- if( isTimerInit == FALSE )
- {
- return;
- }
-
- delListItem(listTime, i, free);
+ delListItem(listTimer, i, free);
i--;
}
}
}
-void delTimer(int id)
+void delTimer(list_t *listTimer, int id)
{
int i;
my_timer_t *thisTimer;
- for( i = 0 ; i < listTime->count ; i++ )
+ for( i = 0 ; i < listTimer->count ; i++ )
{
- thisTimer = (my_timer_t *)listTime->list[i];
+ thisTimer = (my_timer_t *)listTimer->list[i];
assert( thisTimer != NULL );
if( thisTimer->id == id )
{
- delListItem(listTime, i, free);
+ delListItem(listTimer, i, free);
return;
}
}
@@ -115,14 +101,8 @@ void delTimer(int id)
assert( ! "Uloha s id nenajdena !" );
}
-void delAllItemTimer()
-{
- quitTimer();
- initTimer();
-}
-void quitTimer()
+void destroyTimer(list_t *listTimer)
{
- destroyListItem(listTime, free);
- isTimerInit = FALSE;
+ destroyListItem(listTimer, free);
}
diff --git a/src/net_multiplayer.c b/src/net_multiplayer.c
index 29d8872..87538c1 100644
--- a/src/net_multiplayer.c
+++ b/src/net_multiplayer.c
@@ -51,7 +51,7 @@ int initNetMuliplayer(int type, char *ip, int port)
}
#endif
#ifdef SUPPORT_NET_UNIX_UDP
- if( initUdpServer(port) != 0 )
+ if( initUdpServer(ip, port) != 0 )
{
fprintf(stderr, "Neomzem inicalizovat sietovu hru pre server !\n");
netGameType = NET_GAME_TYPE_NONE;
diff --git a/src/proto.c b/src/proto.c
index 38f8ee0..bb1a14c 100644
--- a/src/proto.c
+++ b/src/proto.c
@@ -265,11 +265,23 @@ 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_PROTO_SIZE];
+ int x, y;
assert( tux != NULL );
+ if( tux->bonus == BONUS_HIDDEN )
+ {
+ x = -100;
+ y = -100;
+ }
+ else
+ {
+ x = tux->x;
+ y = tux->y;
+ }
+
sprintf(msg, "newtux %d %d %d %d %d %d %d %s %d %d %d %d %d %d %d %d %d %d %d\n",
- tux->id ,tux->x, tux->y, tux->status, tux->position ,tux->frame, tux->score, tux->name,
+ tux->id ,x, y, tux->status, tux->position ,tux->frame, tux->score, tux->name,
tux->gun, tux->bonus, tux->shot[GUN_SIMPLE], tux->shot[GUN_DUAL_SIMPLE],
tux->shot[GUN_SCATTER], tux->shot[GUN_TOMMY], tux->shot[GUN_LASSER],
tux->shot[GUN_MINE], tux->shot[GUN_BOMBBALL],
@@ -310,6 +322,7 @@ void proto_recv_newtux_client(char *msg)
}
tux->id = id;
+
tux->x = x;
tux->y = y;
tux->status = status;
diff --git a/src/publicServer.c b/src/publicServer.c
index ff7a080..1f74ce1 100644
--- a/src/publicServer.c
+++ b/src/publicServer.c
@@ -38,7 +38,6 @@ int initPublicServer()
initTux();
initItem();
initShot();
- initTimer();
arenaId = getArenaIdFormNetName( getParamElse("--arena", "FAGN") );
arena = getArena(arenaId);
@@ -47,7 +46,8 @@ int initPublicServer()
addNewItem(arena->listItem, NULL);
isSignalEnd = FALSE;
- if( initNetMuliplayer(NET_GAME_TYPE_SERVER, NULL, atoi( getParamElse("--port", "2200") ) ) < 0 )
+ if( initNetMuliplayer(NET_GAME_TYPE_SERVER,
+ getParamElse("--ip", "127.0.0.1") , atoi( getParamElse("--port", "2200") ) ) < 0 )
{
printf("Nemozem inicalizovat sietovy socket !\n");
return -1;
@@ -93,7 +93,6 @@ void eventPublicServer()
lastActive = getMyTime();
eventArena(arena);
- eventTimer();
}
void my_handler_quit(int n)
@@ -108,19 +107,28 @@ void quitPublicServer()
quitNetMultiplayer();
destroyArena(arena);
quitArenaFile();
- quitTimer();
exit(0);
}
char* getParam(char *s)
{
int i;
+ int len;
- for( i = 0 ; i < my_argc - 1 ; i++ )
+ len = strlen(s);
+
+ for( i = 1 ; i < my_argc ; i++ )
{
- if( strcmp(s, my_argv[i]) == 0 )
+ //printf("%s %s\n", s, my_argv[i]);
+
+ if( strlen(my_argv[i]) < len )
+ {
+ continue;
+ }
+
+ if( strncmp(s, my_argv[i], len) == 0 )
{
- return my_argv[i+1];
+ return strchr(my_argv[i], '=')+1;
}
}
diff --git a/src/screen_world.c b/src/screen_world.c
index ebaaa20..571b10e 100644
--- a/src/screen_world.c
+++ b/src/screen_world.c
@@ -98,7 +98,7 @@ void countRoundInc()
{
printf("count %d ending\n", count);
playSound("end", SOUND_GROUP_BASE);
- addTimer(timer_endArena, NULL, TIMER_END_ARENA);
+ addTimer(getCurrentArena()->listTimer, timer_endArena, NULL, TIMER_END_ARENA);
}
}
@@ -214,7 +214,7 @@ static void control_keyboard_right(tux_t *tux)
actionTux(tux, TUX_DOWN);
}
- if( mapa[(SDLKey)SDLK_KP0] == SDL_PRESSED )
+ if( mapa[(SDLKey)SDLK_KP0] == SDL_PRESSED && tux->isCanShot == TRUE )
{
netAction(tux, TUX_SHOT);
actionTux(tux, TUX_SHOT);
@@ -314,7 +314,6 @@ void eventWorld()
eventNetMultiplayer();
eventArena(arena);
- eventTimer();
eventTerm();
eventEnd();
@@ -331,7 +330,6 @@ void startWorld()
setGameType();
initTerm();
prepareArena();
- initTimer();
}
static void setAnalyze()
@@ -392,8 +390,6 @@ void stoptWorld()
stopMusic();
delAllImageInGroup(IMAGE_GROUP_USER);
delAllMusicInGroup(MUSIC_GROUP_USER);
- quitTimer();
- quitTerm();
}
void initWorld()
diff --git a/src/sdl_udp.c b/src/sdl_udp.c
index f4888ad..175ac6c 100644
--- a/src/sdl_udp.c
+++ b/src/sdl_udp.c
@@ -125,7 +125,11 @@ int writeSdlUdpSocket(sock_sdl_udp_t *src, sock_sdl_udp_t *dst, void *address, i
assert( address != NULL );
#ifdef DEBUG_LOST_PACKET
- if( rand() % DEBUG_LOST_PACKET == 0 )return size;
+ if( rand() % DEBUG_LOST_PACKET == 0 )
+ {
+ printf("debug lost packet %s\n", address);
+ return size;
+ }
#endif
memcpy(dst->packet->data, address, len);
diff --git a/src/server.c b/src/server.c
index 4add211..92c60cf 100644
--- a/src/server.c
+++ b/src/server.c
@@ -74,9 +74,9 @@ int initTcpServer(int port)
#endif
#ifdef SUPPORT_NET_UNIX_UDP
-int initUdpServer(int port)
+int initUdpServer(char *ip, int port)
{
- sock_server_udp = bindUdpSocket(port);
+ sock_server_udp = bindUdpSocket(ip, port);
if( sock_server_udp == NULL )
{
@@ -85,7 +85,7 @@ int initUdpServer(int port)
initServer();
- printf("server listen UDP port %d\n", port);
+ printf("server listen UDP port %s %d\n", ip, port);
return 0;
}
@@ -144,10 +144,13 @@ client_t* newTcpClient(sock_tcp_t *sock_tcp)
client_t* newUdpClient(sock_udp_t *sock_udp)
{
client_t *new;
+ char str_ip[STR_IP_SIZE];
assert( sock_udp != NULL );
- printf("new client from %d\n", getSockUdpPort(sock_udp));
+ getSockUdpIp(sock_udp, str_ip);
+ printf("new client from %s:%d\n", str_ip, getSockUdpPort(sock_udp));
+
new = newAnyClient();
new->lastPing = getMyTime();
new->socket_udp = sock_udp;
diff --git a/src/tux.c b/src/tux.c
index 0a48812..07691a4 100644
--- a/src/tux.c
+++ b/src/tux.c
@@ -87,7 +87,7 @@ tux_t* newTux()
new->gun = GUN_SIMPLE;
new->shot[ new->gun ] = GUN_MAX_SHOT;
- sprintf(new->name, "no_name_id_%d", new->id);
+ sprintf(new->name, "no_name_id_%dde", new->id);
new->score = 0;
new->frame = 0;
@@ -155,14 +155,14 @@ void drawTux(tux_t *tux)
SDL_Surface *g_image = NULL;
assert( tux != NULL );
-
- if( tux->bonus == BONUS_HIDDEN &&
+/*
+ if( tux->bonus == BONUS_HIDDEN &&
getNetTypeGame() != NET_GAME_TYPE_NONE &&
tux->control == TUX_CONTROL_NET )
{
return;
}
-
+*/
switch( tux->position )
{
case TUX_UP :
@@ -391,7 +391,7 @@ void eventTuxIsDead(tux_t *tux)
if( getNetTypeGame() != NET_GAME_TYPE_CLIENT )
{
- addTimer(timer_spawnTux, newInt(tux->id), TUX_TIME_SPAWN );
+ addTimer(getCurrentArena()->listTimer, timer_spawnTux, newInt(tux->id), TUX_TIME_SPAWN );
}
if( getNetTypeGame() == NET_GAME_TYPE_SERVER )
@@ -609,7 +609,8 @@ void switchTuxGun(tux_t *tux)
{
tux->gun = i;
tux->isCanSwitchGun = FALSE;
- addTimer(timer_tuxCanSwitchGun, newInt(tux->id), TUX_TIME_CAN_SWITCH_GUN );
+ addTimer(getCurrentArena()->listTimer, timer_tuxCanSwitchGun,
+ newInt(tux->id), TUX_TIME_CAN_SWITCH_GUN );
#ifndef PUBLIC_SERVER
playSound("switch_gun", SOUND_GROUP_BASE);
sprintf(msg, "tux with id %d switch gun\n", tux->id);
@@ -625,7 +626,8 @@ void switchTuxGun(tux_t *tux)
{
tux->gun = i;
tux->isCanSwitchGun = FALSE;
- addTimer(timer_tuxCanSwitchGun, newInt(tux->id), TUX_TIME_CAN_SWITCH_GUN );
+ addTimer(getCurrentArena()->listTimer, timer_tuxCanSwitchGun,
+ newInt(tux->id), TUX_TIME_CAN_SWITCH_GUN );
#ifndef PUBLIC_SERVER
playSound("switch_gun", SOUND_GROUP_BASE);
@@ -655,7 +657,8 @@ void shotTux(tux_t *tux)
shotInGun(tux);
tux->isCanShot = FALSE;
- addTimer(timer_tuxCanShot, newInt(tux->id), TUX_TIME_CAN_SHOT );
+ addTimer(getCurrentArena()->listTimer, timer_tuxCanShot,
+ newInt(tux->id), TUX_TIME_CAN_SHOT );
if( tux->shot[tux->gun] == 0 )
{
diff --git a/src/udp.c b/src/udp.c
index e3dc6ff..af254de 100644
--- a/src/udp.c
+++ b/src/udp.c
@@ -37,7 +37,7 @@ void destroySockUdp(sock_udp_t *p)
free(p);
}
-sock_udp_t* bindUdpSocket(int port)
+sock_udp_t* bindUdpSocket(char *address, int port)
{
sock_udp_t *new;
@@ -56,7 +56,7 @@ sock_udp_t* bindUdpSocket(int port)
new->sockAddr.sin_family = AF_INET;
new->sockAddr.sin_port = htons(port);
- new->sockAddr.sin_addr.s_addr = INADDR_ANY;
+ new->sockAddr.sin_addr.s_addr = inet_addr(address);
if( bind(new->sock, (struct sockaddr *)&(new->sockAddr), sizeof(new->sockAddr)) < 0 )
{
@@ -122,7 +122,11 @@ int writeUdpSocket(sock_udp_t *src, sock_udp_t *dst, void *address, int len)
int size;
#ifdef DEBUG_LOST_PACKET
- if( rand() % DEBUG_LOST_PACKET == 0 )return size;
+ if( rand() % DEBUG_LOST_PACKET == 0 )
+ {
+ printf("debug lost packet %s\n", address);
+ return size;
+ }
#endif
addrlen = sizeof(src->sockAddr);
@@ -197,6 +201,7 @@ static int myWait(sock_udp_t *p)
return 0;
}
+#if 0
int test_udp_main(int argc, char *argv[])
{
sock_udp_t *sock;
@@ -238,3 +243,5 @@ int test_udp_main(int argc, char *argv[])
return 0;
}
+#endif
+