summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/arena.c104
-rw-r--r--src/gun.c13
-rw-r--r--src/item.c4
-rw-r--r--src/proto.c41
-rw-r--r--src/publicServer.c58
-rw-r--r--src/screen_world.c88
-rw-r--r--src/sdl_udp.c4
-rw-r--r--src/server.c26
-rw-r--r--src/teleport.c3
-rw-r--r--src/tux.c23
-rw-r--r--src/udp.c4
11 files changed, 182 insertions, 186 deletions
diff --git a/src/arena.c b/src/arena.c
index 7f17f57..5e7d1bf 100644
--- a/src/arena.c
+++ b/src/arena.c
@@ -10,6 +10,24 @@
#include "shot.h"
#include "wall.h"
#include "item.h"
+#include "teleport.h"
+#include "pipe.h"
+
+#ifndef PUBLIC_SERVER
+#include "layer.h"
+#endif
+
+static arena_t *currentArena;
+
+void setCurrentArena(arena_t *p)
+{
+ currentArena = p;
+}
+
+arena_t* getCurrentArena()
+{
+ return currentArena;
+}
arena_t* newArena()
{
@@ -31,6 +49,92 @@ arena_t* newArena()
return new;
}
+int conflictSpace(int x1,int y1,int w1,int h1,int x2,int y2,int w2,int h2)
+{
+ return (x1<x2+w2 && x2<x1+w1 && y1<y2+h2 && y2<y1+h1);
+}
+
+int isFreeSpace(arena_t *arena, int x, int y, int w, int h)
+{
+ if ( isConflictWithListTux(arena->listTux, x, y, w, h) )return 0;
+ if ( isConflictWithListWall(arena->listWall, x, y, w, h) )return 0;
+ if ( isConflictWithListShot(arena->listShot, x, y, w, h) )return 0;
+ if ( isConflictWithListItem(arena->listItem, x, y, w, h) )return 0;
+ if ( isConflictWithListTeleport(arena->listTeleport, x, y, w, h) )return 0;
+ if ( isConflictWithListPipe(arena->listPipe, x, y, w, h) )return 0;
+
+ return 1;
+}
+
+void findFreeSpace(arena_t *arena, int *x, int *y, int w, int h)
+{
+ int z_x;
+ int z_y;
+
+ assert( x != NULL );
+ assert( y != NULL );
+
+ do{
+ z_x = random() % WINDOW_SIZE_X;
+ z_y = random() % (WINDOW_SIZE_Y-200);
+ }while( isFreeSpace(arena, z_x, z_y ,w ,h) == 0 );
+
+ *x = z_x;
+ *y = z_y;
+}
+
+#ifndef PUBLIC_SERVER
+
+void drawArena(arena_t *arena)
+{
+ tux_t *tux = NULL;
+
+ addLayer(arena->background, 0, 0, 0, 0, WINDOW_SIZE_X, WINDOW_SIZE_Y, -100);
+
+ drawListTux(arena->listTux);
+ drawListWall(arena->listWall);
+ drawListTeleport(arena->listTeleport);
+ drawListPipe(arena->listPipe);
+ drawListShot(arena->listShot);
+ drawListItem(arena->listItem);
+
+/*
+ tux = getControlTux( TUX_CONTROL_KEYBOARD_RIGHT );
+*/
+
+ if( tux == NULL )
+ {
+ drawLayerCenter(WINDOW_SIZE_X/2, WINDOW_SIZE_Y/2);
+ }
+ else
+ {
+ drawLayerCenter(tux->x, tux->y);
+ }
+}
+
+#endif
+
+void eventArena(arena_t *arena)
+{
+ int i;
+
+ eventConflictTuxWithTeleport(arena->listTux, arena->listTeleport);
+ eventConflictTuxWithShot(arena->listTux, arena->listShot);
+
+ for( i = 0 ; i < 4 ; i++)
+ {
+ eventMoveListShot(arena->listShot);
+ eventConflictShotWithWall(arena->listWall, arena->listShot);
+ eventConflictShotWithTeleport(arena->listTeleport, arena->listShot);
+ eventConflictShotWithPipe(arena->listPipe, arena->listShot);
+ eventConflictShotWithItem(arena->listItem, arena->listShot);
+ }
+
+ eventListItem(arena->listItem);
+
+ eventListTux(arena->listTux);
+}
+
void destroyArena(arena_t *p)
{
destroyListItem(p->listTux, destroyTux);
diff --git a/src/gun.c b/src/gun.c
index 6964394..1a9ae9b 100644
--- a/src/gun.c
+++ b/src/gun.c
@@ -58,11 +58,8 @@ static void addShotTrivial(tux_t *tux, int x, int y, int px, int py, int gun)
{
int dest_x = 0, dest_y = 0;
int dest_px = 0, dest_py = 0;
- arena_t *arena;
shot_t *shot;
- arena = getWorldArena();
-
modificiationCopuse(tux->position, px, py, &dest_px, &dest_py);
modificiationCopuse(tux->position, x, y, &dest_x, &dest_y);
@@ -81,7 +78,7 @@ 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( arena->listShot, shot );
+ addList( getCurrentArena()->listShot, shot );
}
static void addShot(tux_t *tux,int x, int y, int px, int py)
@@ -155,7 +152,7 @@ static void timer_addShotTimer(void *p)
id = * ((int *)p);
free(p);
- tux = getTuxID(getWorldArena()->listTux, id);
+ tux = getTuxID(getCurrentArena()->listTux, id);
if( tux == NULL )return;
@@ -184,7 +181,7 @@ static void timer_addLaserTimer(void *p)
id = * ((int *)p);
free(p);
- tux = getTuxID(getWorldArena()->listTux, id);
+ tux = getTuxID(getCurrentArena()->listTux, id);
if( tux == NULL )return;
@@ -229,9 +226,9 @@ static void putInGunMine(tux_t *tux)
break;
}
- arena = getWorldArena();
+ arena = getCurrentArena();
- if( isFreeSpace(x, y, ITEM_MINE_WIDTH, ITEM_MINE_HEIGHT) )
+ if( isFreeSpace(getCurrentArena(), x, y, ITEM_MINE_WIDTH, ITEM_MINE_HEIGHT) )
{
item_t *item;
diff --git a/src/item.c b/src/item.c
index 4717671..77f2ffd 100644
--- a/src/item.c
+++ b/src/item.c
@@ -162,8 +162,8 @@ void addNewItem(list_t *listItem, tux_t *author)
}
#endif
- arena = getWorldArena();
- findFreeSpace(&new_x, &new_y, ITEM_GUN_WIDTH, ITEM_GUN_HEIGHT);
+ arena = getCurrentArena();
+ findFreeSpace(getCurrentArena(), &new_x, &new_y, ITEM_GUN_WIDTH, ITEM_GUN_HEIGHT);
type = GUN_DUAL_SIMPLE;
diff --git a/src/proto.c b/src/proto.c
index 07a496d..38f8ee0 100644
--- a/src/proto.c
+++ b/src/proto.c
@@ -121,7 +121,7 @@ void proto_recv_hello_server(client_t *client, char *msg)
client->tux = newTux();
client->tux->control = TUX_CONTROL_NET;
- addList(getWorldArena()->listTux, client->tux);
+ addList(getCurrentArena()->listTux, client->tux);
if( strlen(name) > STR_NAME_SIZE-1 )
{
@@ -140,7 +140,7 @@ void proto_send_status_server(int type, client_t *client)
"clients: %d\n"
"maxclients: %d\n"
"uptime: %d\n",
- TUXANCI_NG_VERSION, getWorldArena()->listTux->count,
+ TUXANCI_NG_VERSION, getCurrentArena()->listTux->count,
getServerMaxClients(), getMyTime() );
proto_send(type, client, msg);
@@ -195,7 +195,7 @@ void proto_recv_init_client(char *msg)
getSettingNameRight(tux->name);
- addList(getWorldArena()->listTux, tux);
+ addList(getCurrentArena()->listTux, tux);
}
#endif
@@ -223,7 +223,7 @@ void proto_recv_event_client(char *msg)
sscanf(msg, "%s %d %d", cmd, &id, &action);
- tux = getTuxID(getWorldArena()->listTux, id);
+ tux = getTuxID(getCurrentArena()->listTux, id);
if( tux != NULL )
{
@@ -296,7 +296,7 @@ void proto_recv_newtux_client(char *msg)
cmd, &id, &x, &y, &status, &position, &frame, &score, name,
&myGun, &myBonus, &gun1, &gun2, &gun3, &gun4, &gun5, &gun6, &gun7, &time1, &time2);
- tux = getTuxID(getWorldArena()->listTux, id);
+ tux = getTuxID(getCurrentArena()->listTux, id);
if( tux == NULL )
{
@@ -306,7 +306,7 @@ void proto_recv_newtux_client(char *msg)
tux = newTux();
tux->control = TUX_CONTROL_NET;
- addList(getWorldArena()->listTux, tux);
+ addList(getCurrentArena()->listTux, tux);
}
tux->id = id;
@@ -355,7 +355,7 @@ void proto_recv_kill_client(char *msg)
sscanf(msg, "%s %d", cmd, &id);
- tux = getTuxID(getWorldArena()->listTux, id);
+ tux = getTuxID(getCurrentArena()->listTux, id);
if( tux != NULL )
{
@@ -388,7 +388,7 @@ void proto_recv_score_client(char *msg)
sscanf(msg, "%s %d %d", cmd, &id, &score);
- tux = getTuxID(getWorldArena()->listTux, id);
+ tux = getTuxID(getCurrentArena()->listTux, id);
if( tux != NULL )
{
@@ -427,7 +427,7 @@ void proto_recv_deltux_client(char *msg)
sscanf(msg, "%s %d", cmd, &id);
- tux = getTuxID(getWorldArena()->listTux, id);
+ tux = getTuxID(getCurrentArena()->listTux, id);
if( tux != NULL )
{
@@ -437,8 +437,8 @@ void proto_recv_deltux_client(char *msg)
sprintf(term_msg, "tux with id %d is disconnect\n", tux->id);
appendTextInTerm(term_msg);
- index = searchListItem(getWorldArena()->listTux, tux);
- delListItem(getWorldArena()->listTux, index, destroyTux);
+ index = searchListItem(getCurrentArena()->listTux, tux);
+ delListItem(getCurrentArena()->listTux, index, destroyTux);
}
}
@@ -475,19 +475,24 @@ void proto_recv_additem_client(char *msg)
sscanf(msg, "%s %d %d %d %d %d %d %d", cmd, &id, &type, &x, &y, &count, &frame, &author_id);
- item = newItem(x, y, type, getTuxID(getWorldArena()->listTux, author_id));
+ if( getItemID(getCurrentArena()->listItem, id) != NULL )
+ {
+ return;
+ }
- if( isConflictWithListItem(getWorldArena()->listItem, item->x, item->y, item->w, item->h) )
+ item = newItem(x, y, type, getTuxID(getCurrentArena()->listTux, author_id));
+/*
+ if( isConflictWithListItem(getCurrentArena()->listItem, item->x, item->y, item->w, item->h) )
{
destroyItem(item);
return;
}
-
+*/
item->id = id;
item->count = count;
item->frame = frame;
- addList(getWorldArena()->listItem, item);
+ addList(getCurrentArena()->listItem, item);
sprintf(term_msg, "in arena is new item\n");
appendTextInTerm(term_msg);
@@ -529,7 +534,7 @@ void proto_recv_item_client(char *msg)
sscanf(msg, "%s %d %d", cmd, &tux_id, &item_id);
- arena = getWorldArena();
+ arena = getCurrentArena();
item = getItemID(arena->listItem, item_id);
tux = getTuxID(arena->listTux, tux_id);
@@ -582,7 +587,7 @@ void proto_recv_shot_client(char *msg)
sscanf(msg, "%s %d %d %d %d %d %d %d %d",
cmd, &x, &y, &px, &py, &position, &gun, &id, &isCanKillAuthor);
- shot = newShot(x, y, px, py, gun, getTuxID(getWorldArena()->listTux, id));
+ shot = newShot(x, y, px, py, gun, getTuxID(getCurrentArena()->listTux, id));
shot->isCanKillAuthor = isCanKillAuthor;
shot->position = position;
@@ -593,7 +598,7 @@ void proto_recv_shot_client(char *msg)
transformOnlyLasser(shot);
}
- addList(getWorldArena()->listShot, shot);
+ addList(getCurrentArena()->listShot, shot);
}
#endif
diff --git a/src/publicServer.c b/src/publicServer.c
index 204cdba..ff7a080 100644
--- a/src/publicServer.c
+++ b/src/publicServer.c
@@ -28,11 +28,6 @@ static bool_t isSignalEnd;
static int my_argc;
static char **my_argv;
-arena_t* getWorldArena()
-{
- return arena;
-}
-
void countRoundInc()
{
}
@@ -47,6 +42,8 @@ int initPublicServer()
arenaId = getArenaIdFormNetName( getParamElse("--arena", "FAGN") );
arena = getArena(arenaId);
+ setCurrentArena(arena);
+
addNewItem(arena->listItem, NULL);
isSignalEnd = FALSE;
@@ -66,45 +63,10 @@ int getChoiceArenaId()
return arenaId;
}
-int conflictSpace(int x1,int y1,int w1,int h1,int x2,int y2,int w2,int h2)
-{
- return (x1<x2+w2 && x2<x1+w1 && y1<y2+h2 && y2<y1+h1);
-}
-
-int isFreeSpace(int x, int y, int w, int h)
-{
- if ( isConflictWithListTux(arena->listTux, x, y, w, h) )return 0;
- if ( isConflictWithListWall(arena->listWall, x, y, w, h) )return 0;
- if ( isConflictWithListShot(arena->listShot, x, y, w, h) )return 0;
- if ( isConflictWithListItem(arena->listItem, x, y, w, h) )return 0;
- if ( isConflictWithListTeleport(arena->listTeleport, x, y, w, h) )return 0;
- if ( isConflictWithListPipe(arena->listPipe, x, y, w, h) )return 0;
-
- return 1;
-}
-
-void findFreeSpace(int *x, int *y, int w, int h)
-{
- int z_x;
- int z_y;
-
- assert( x != NULL );
- assert( y != NULL );
-
- do{
- z_x = random() % WINDOW_SIZE_X;
- z_y = random() % (WINDOW_SIZE_Y-200);
- }while( isFreeSpace(z_x, z_y ,w ,h) == 0 );
-
- *x = z_x;
- *y = z_y;
-}
-
void eventPublicServer()
{
static my_time_t lastActive = 0;
my_time_t interval;
- int i;
eventNetMultiplayer();
@@ -130,21 +92,7 @@ void eventPublicServer()
*/
lastActive = getMyTime();
- eventConflictTuxWithTeleport(arena->listTux, arena->listTeleport);
- eventConflictTuxWithShot(arena->listTux, arena->listShot);
-
- for( i = 0 ; i < 4 ; i++)
- {
- eventMoveListShot(arena->listShot);
- eventConflictShotWithWall(arena->listWall, arena->listShot);
- eventConflictShotWithTeleport(arena->listTeleport, arena->listShot);
- eventConflictShotWithPipe(arena->listPipe, arena->listShot);
- eventConflictShotWithItem(arena->listItem, arena->listShot);
- }
-
- eventListItem(arena->listItem);
- eventListTux(arena->listTux);
-
+ eventArena(arena);
eventTimer();
}
diff --git a/src/screen_world.c b/src/screen_world.c
index 6bd1b9d..f61677f 100644
--- a/src/screen_world.c
+++ b/src/screen_world.c
@@ -58,15 +58,11 @@ void setGameType()
}
}
-arena_t* getWorldArena()
-{
- return arena;
-}
-
void setWorldArena(int id)
{
arena = getArena(id);
playMusic(arena->music, MUSIC_GROUP_USER);
+ setCurrentArena(arena);
}
void setMaxCountRound(int n)
@@ -165,73 +161,15 @@ void prepareArena()
void drawWorld()
{
- tux_t *tux = NULL;
-
- if( arena == NULL )
- {
- return;
- }
-
- addLayer(arena->background, 0, 0, 0, 0, WINDOW_SIZE_X, WINDOW_SIZE_Y, -100);
-
- drawListTux(arena->listTux);
- drawListWall(arena->listWall);
- drawListTeleport(arena->listTeleport);
- drawListPipe(arena->listPipe);
- drawListShot(arena->listShot);
- drawListItem(arena->listItem);
-
-/*
- tux = getControlTux( TUX_CONTROL_KEYBOARD_RIGHT );
-*/
-
- if( tux == NULL )
- {
- drawLayerCenter(WINDOW_SIZE_X/2, WINDOW_SIZE_Y/2);
- }
- else
+ if( arena != NULL )
{
- drawLayerCenter(tux->x, tux->y);
+ drawArena(arena);
+ drawPanel(arena->listTux);
}
- drawPanel(arena->listTux);
drawTerm();
}
-int conflictSpace(int x1,int y1,int w1,int h1,int x2,int y2,int w2,int h2)
-{
- return (x1<x2+w2 && x2<x1+w1 && y1<y2+h2 && y2<y1+h1);
-}
-
-int isFreeSpace(int x, int y, int w, int h)
-{
- if ( isConflictWithListTux(arena->listTux, x, y, w, h) )return 0;
- if ( isConflictWithListWall(arena->listWall, x, y, w, h) )return 0;
- if ( isConflictWithListShot(arena->listShot, x, y, w, h) )return 0;
- if ( isConflictWithListItem(arena->listItem, x, y, w, h) )return 0;
- if ( isConflictWithListTeleport(arena->listTeleport, x, y, w, h) )return 0;
- if ( isConflictWithListPipe(arena->listPipe, x, y, w, h) )return 0;
-
- return 1;
-}
-
-void findFreeSpace(int *x, int *y, int w, int h)
-{
- int z_x;
- int z_y;
-
- assert( x != NULL );
- assert( y != NULL );
-
- do{
- z_x = random() % WINDOW_SIZE_X;
- z_y = random() % (WINDOW_SIZE_Y-200);
- }while( isFreeSpace(z_x, z_y ,w ,h) == 0 );
-
- *x = z_x;
- *y = z_y;
-}
-
static void netAction(tux_t *tux, int action)
{
if( getSettingGameType() == NET_GAME_TYPE_SERVER )
@@ -366,8 +304,6 @@ void tuxControl(tux_t *p)
void eventWorld()
{
- int i;
-
if( arena == NULL )
{
eventNetMultiplayer();
@@ -378,21 +314,7 @@ void eventWorld()
eventNetMultiplayer();
- eventConflictTuxWithTeleport(arena->listTux, arena->listTeleport);
- eventConflictTuxWithShot(arena->listTux, arena->listShot);
-
- for( i = 0 ; i < 4 ; i++)
- {
- eventMoveListShot(arena->listShot);
- eventConflictShotWithWall(arena->listWall, arena->listShot);
- eventConflictShotWithTeleport(arena->listTeleport, arena->listShot);
- eventConflictShotWithPipe(arena->listPipe, arena->listShot);
- eventConflictShotWithItem(arena->listItem, arena->listShot);
- }
-
- eventListItem(arena->listItem);
-
- eventListTux(arena->listTux);
+ eventArena(arena);
eventTimer();
eventTerm();
diff --git a/src/sdl_udp.c b/src/sdl_udp.c
index e6b669a..f4888ad 100644
--- a/src/sdl_udp.c
+++ b/src/sdl_udp.c
@@ -124,6 +124,10 @@ int writeSdlUdpSocket(sock_sdl_udp_t *src, sock_sdl_udp_t *dst, void *address, i
assert( src != NULL );
assert( address != NULL );
+#ifdef DEBUG_LOST_PACKET
+ if( rand() % DEBUG_LOST_PACKET == 0 )return size;
+#endif
+
memcpy(dst->packet->data, address, len);
dst->packet->len = len;
diff --git a/src/server.c b/src/server.c
index bf99659..4add211 100644
--- a/src/server.c
+++ b/src/server.c
@@ -18,6 +18,7 @@
#include "server.h"
#include "assert.h"
#include "myTimer.h"
+#include "arena.h"
#include "net_multiplayer.h"
#ifndef PUBLIC_SERVER
@@ -193,8 +194,8 @@ void destroyClient(client_t *p)
if( p->tux != NULL )
{
- index = searchListItem(getWorldArena()->listTux, p->tux);
- delListItem(getWorldArena()->listTux, index, destroyTux);
+ index = searchListItem(getCurrentArena()->listTux, p->tux);
+ delListItem(getCurrentArena()->listTux, index, destroyTux);
}
free(p);
@@ -288,7 +289,7 @@ void sendInfoCreateClient(client_t *client)
#ifndef PUBLIC_SERVER
proto_send_newtux_server(PROTO_SEND_ONE, client,
- (tux_t *)(getWorldArena()->listTux->list[SERVER_INDEX_ROOT_TUX]) );
+ (tux_t *)(getCurrentArena()->listTux->list[SERVER_INDEX_ROOT_TUX]) );
#endif
for( i = 0 ; i < listClient->count; i++)
@@ -303,9 +304,9 @@ void sendInfoCreateClient(client_t *client)
}
}
- for( i = 0 ; i < getWorldArena()->listItem->count; i++)
+ for( i = 0 ; i < getCurrentArena()->listItem->count; i++)
{
- thisItem = (item_t *) getWorldArena()->listItem->list[i];
+ thisItem = (item_t *) getCurrentArena()->listItem->list[i];
proto_send_additem_server(PROTO_SEND_ONE, client, thisItem);
}
}
@@ -402,7 +403,11 @@ static void eventClientBuffer(client_t *client)
continue;
}
- if( strncmp(line, "status", 6) == 0 )proto_recv_status_server(client, line);
+ if( strncmp(line, "status", 6) == 0 )
+ {
+ proto_recv_status_server(client, line);
+ continue;
+ }
if( client->tux != NULL )
{
@@ -425,7 +430,10 @@ static void eventClientBuffer(client_t *client)
}
}
- proto_send_error_server(PROTO_SEND_ONE, client, PROTO_ERROR_CODE_BAD_COMMAND);
+ if( client->tux != NULL )
+ {
+ proto_send_error_server(PROTO_SEND_ONE, client, PROTO_ERROR_CODE_BAD_COMMAND);
+ }
}
}
@@ -555,7 +563,7 @@ void eventPeriodicSyncClient()
#ifndef PUBLIC_SERVER
proto_send_newtux_server(PROTO_SEND_ONE, thisClientSend,
- (tux_t *)(getWorldArena()->listTux->list[SERVER_INDEX_ROOT_TUX]));
+ (tux_t *)(getCurrentArena()->listTux->list[SERVER_INDEX_ROOT_TUX]));
#endif
}
@@ -622,7 +630,7 @@ static void eventClientUdpSelect(sock_udp_t *sock_server)
if( client == NULL )
{
- if( getWorldArena()->listTux->count+1 > maxClients )
+ if( getCurrentArena()->listTux->count+1 > maxClients )
{
destroySockUdp(sock_client);
return;
diff --git a/src/teleport.c b/src/teleport.c
index da7b740..6348c57 100644
--- a/src/teleport.c
+++ b/src/teleport.c
@@ -8,6 +8,7 @@
#include "shot.h"
#include "net_multiplayer.h"
#include "proto.h"
+#include "arena.h"
#ifndef PUBLIC_SERVER
#include "layer.h"
@@ -214,7 +215,7 @@ void eventTeleportTux(list_t *listTeleport, teleport_t *teleport, tux_t *tux)
break;
}
- if( isFreeSpace(dist_x, dist_y, TUX_WIDTH, TUX_HEIGHT) )
+ if( isFreeSpace(getCurrentArena(), dist_x, dist_y, TUX_WIDTH, TUX_HEIGHT) )
{
setTuxProportion(tux, dist_x, dist_y);
#ifndef PUBLIC_SERVER
diff --git a/src/tux.c b/src/tux.c
index 589e5af..0a48812 100644
--- a/src/tux.c
+++ b/src/tux.c
@@ -6,6 +6,7 @@
#include "main.h"
#include "tux.h"
+#include "arena.h"
#include "shot.h"
#include "gun.h"
#include "wall.h"
@@ -79,7 +80,7 @@ tux_t* newTux()
new->status = TUX_STATUS_ALIVE;
new->control = TUX_CONTROL_NONE;
- findFreeSpace(&x, &y, TUX_WIDTH, TUX_HEIGHT);
+ findFreeSpace(getCurrentArena(), &x, &y, TUX_WIDTH, TUX_HEIGHT);
setTuxProportion(new, x, y);
new->position = TUX_DOWN;
@@ -311,13 +312,13 @@ static void timer_spawnTux(void *p)
id = * ((int *)p);
free(p);
- arena = getWorldArena();
+ arena = getCurrentArena();
tux = getTuxID(arena->listTux, id);
if( tux == NULL )return;
tux->status = TUX_STATUS_ALIVE;
- findFreeSpace(&x, &y, TUX_WIDTH, TUX_HEIGHT);
+ findFreeSpace(getCurrentArena(), &x, &y, TUX_WIDTH, TUX_HEIGHT);
setTuxProportion(tux, x, y);
tux->gun = GUN_SIMPLE;
@@ -337,7 +338,7 @@ static void timer_tuxCanShot(void *p)
id = * ((int *)p);
free(p);
- tux = getTuxID(getWorldArena()->listTux, id);
+ tux = getTuxID(getCurrentArena()->listTux, id);
if( tux == NULL )return;
@@ -352,7 +353,7 @@ static void timer_tuxCanSwitchGun(void *p)
id = * ((int *)p);
free(p);
- tux = getTuxID(getWorldArena()->listTux, id);
+ tux = getTuxID(getCurrentArena()->listTux, id);
if( tux == NULL )return;
@@ -438,7 +439,7 @@ void tuxTeleport(tux_t *tux)
if( getNetTypeGame() != NET_GAME_TYPE_CLIENT )
{
- findFreeSpace(&x, &y, TUX_WIDTH, TUX_HEIGHT);
+ findFreeSpace(getCurrentArena(), &x, &y, TUX_WIDTH, TUX_HEIGHT);
setTuxProportion(tux, x, y);
}
@@ -555,7 +556,7 @@ void moveTux(tux_t *tux, int n)
return;
}
- arena = getWorldArena();
+ arena = getCurrentArena();
getCourse(tux->position, &px, &py);
zal_x = tux->x;
@@ -583,7 +584,7 @@ void moveTux(tux_t *tux, int n)
}
else
{
- eventGiveTuxListItem(tux, getWorldArena()->listItem);
+ eventGiveTuxListItem(tux, getCurrentArena()->listItem);
tux->frame++;
if( tux->frame == TUX_KEY * TUX_MAX_ANIMATION_FRAME ) tux->frame = 0;
}
@@ -731,7 +732,7 @@ static void eventBonus(tux_t *tux)
int x, y, w, h;
getTuxProportion(tux, &x, &y, &w, &h);
- if ( isConflictWithListWall(getWorldArena()->listWall, x, y, w, h) )
+ if ( isConflictWithListWall(getCurrentArena()->listWall, x, y, w, h) )
{
return;
}
@@ -755,9 +756,11 @@ static void eventBonus(tux_t *tux)
void eventListTux(list_t *listTux)
{
tux_t *thisTux;
+ arena_t *arena;
int i;
assert( listTux != NULL );
+ arena = getCurrentArena();
for( i = 0 ; i < listTux->count ; i++ )
{
@@ -769,7 +772,7 @@ void eventListTux(list_t *listTux)
#endif
pickUpGun(thisTux);
eventBonus(thisTux);
- eventGiveTuxListItem(thisTux, getWorldArena()->listItem);
+ eventGiveTuxListItem(thisTux, arena->listItem);
}
}
diff --git a/src/udp.c b/src/udp.c
index 58e7637..e3dc6ff 100644
--- a/src/udp.c
+++ b/src/udp.c
@@ -121,6 +121,10 @@ int writeUdpSocket(sock_udp_t *src, sock_udp_t *dst, void *address, int len)
int addrlen;
int size;
+#ifdef DEBUG_LOST_PACKET
+ if( rand() % DEBUG_LOST_PACKET == 0 )return size;
+#endif
+
addrlen = sizeof(src->sockAddr);
assert( src != NULL );