From a1e9bc7430ca827808a502f455b20a23ba15e31a Mon Sep 17 00:00:00 2001 From: oroborus Date: Thu, 22 May 2008 20:13:25 +0000 Subject: - dopisany skutocny ID manager - objekt wall je ako modul - oprava chyby, pri prepinani screenov sa nevyprazdnoval layer - oprava chyby, pri odstraneni vsetkych obrazkov zo skupiny sa odstrani iba prvy obrazok - oprava chyby, pri odstraneni vsetkej hudby zo skupiny sa odstrani iba prva hudba PS: (asi) zajtra ten kod trochu esteticky upravim git-svn-id: http://opensvn.csie.org/tuxanci_ng@53 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e --- src/tux.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'src/tux.c') diff --git a/src/tux.c b/src/tux.c index c0b6f22..ce9a249 100644 --- a/src/tux.c +++ b/src/tux.c @@ -19,6 +19,7 @@ #include "dynamicInt.h" #include "proto.h" #include "modules.h" +#include "idManager.h" #ifndef PUBLIC_SERVER #include "image.h" @@ -43,6 +44,8 @@ static SDL_Surface *g_cross; #endif +static list_t *listID; + static bool_t isTuxInit = FALSE; bool_t isTuxInicialized() @@ -64,12 +67,13 @@ void initTux() g_cross = addImageData("cross.png", IMAGE_ALPHA, "cross", IMAGE_GROUP_BASE); #endif + listID = newListID(); + isTuxInit = TRUE; } tux_t* newTux() { - static int last_id = 0; int x, y; tux_t *new; @@ -78,7 +82,7 @@ tux_t* newTux() memset(new, 0, sizeof(tux_t) ); - new->id = last_id++; + new->id = getNewID(listID); new->status = TUX_STATUS_ALIVE; new->control = TUX_CONTROL_NONE; @@ -246,6 +250,12 @@ tux_t* getTuxID(list_t *listTux, int id) return NULL; } +void replaceTuxID(tux_t *tux, int id) +{ + replaceID(listID, tux->id, id); + tux->id = id; +} + tux_t* isConflictWithListTux(list_t *listTux, int x, int y, int w, int h) { tux_t *thisTux; @@ -626,7 +636,6 @@ void moveTux(tux_t *tux, int n) if( tux->bonus != BONUS_GHOST && ( isConflictTuxWithListTux(tux, arena->listTux) || - isConflictWithListWall(arena->listWall, x, y, w, h) || isConflictModule(x, y, w, h) ) ) { tux->x = zal_x; @@ -797,9 +806,8 @@ static void eventBonus(tux_t *tux) tux->bonus = BONUS_NONE; - if ( isConflictWithListWall(getCurrentArena()->listWall, x, y, w, h) || - isConflictModule(x, y, w, h) || - isConflictTuxWithListTux(tux, getCurrentArena()->listTux) ) + if( isConflictTuxWithListTux(tux, getCurrentArena()->listTux) || + isConflictModule(x, y, w, h) ) { tux->bonus = BONUS_GHOST; return; @@ -865,11 +873,12 @@ void setTuxProportion(tux_t *tux, int x, int y) void destroyTux(tux_t *tux) { assert( tux != NULL ); + delID(listID, tux->id); free(tux); } void quitTux() { + destroyListID(listID); isTuxInit = FALSE; } - -- cgit v1.2.3