diff options
| author | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-05-22 20:13:25 +0000 |
|---|---|---|
| committer | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-05-22 20:13:25 +0000 |
| commit | a1e9bc7430ca827808a502f455b20a23ba15e31a (patch) | |
| tree | 0f5367068425be881657840c08756662510adf39 /src/item.c | |
| parent | 7055882c93022da3a6a1cf74cebf3d17c44ce6c4 (diff) | |
- 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
Diffstat (limited to 'src/item.c')
| -rw-r--r-- | src/item.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -8,6 +8,7 @@ #include "item.h" #include "shot.h" #include "proto.h" +#include "idManager.h" #include "net_multiplayer.h" #ifndef PUBLIC_SERVER @@ -30,6 +31,7 @@ static SDL_Surface *g_item[ITEM_COUNT]; #endif static bool_t isItemInit = FALSE; +static list_t *listID; bool_t isItemInicialized() { @@ -57,12 +59,12 @@ void initItem() g_item[BONUS_4X] = addImageData("item.bonus.4x.png", IMAGE_ALPHA, "item_4x_speed", IMAGE_GROUP_BASE); g_item[BONUS_HIDDEN] = addImageData("item.bonus.hidden.png", IMAGE_ALPHA, "item_hidden_speed", IMAGE_GROUP_BASE); #endif + listID = newListID(); isItemInit = TRUE; } item_t* newItem(int x, int y, int type, int author_id) { - static unsigned int last_id = 0; item_t *new; new = malloc( sizeof(item_t) ); @@ -70,7 +72,7 @@ item_t* newItem(int x, int y, int type, int author_id) new->type = type; - new->id = last_id++; + new->id = getNewID(listID); new->x = x; new->y = y; new->frame = 0; @@ -149,6 +151,12 @@ item_t* getItemID(list_t *listItem, int id) return NULL; } +void replaceItemID(item_t *item, int id) +{ + replaceID(listID, item->id, id); + item->id = id; +} + void addNewItem(list_t *listItem, int author_id) { #ifndef PUBLIC_SERVER @@ -614,10 +622,12 @@ void eventGiveTuxListItem(tux_t *tux, list_t *listItem) void destroyItem(item_t *p) { assert( p != NULL ); + delID(listID, p->id); free(p); } void quitItem() { + destroyListID(listID); isItemInit = FALSE; } |