summaryrefslogtreecommitdiff
path: root/src/item.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/item.c')
-rw-r--r--src/item.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/item.c b/src/item.c
index 6123c55..2ca4875 100644
--- a/src/item.c
+++ b/src/item.c
@@ -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;
}