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/shot.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/shot.c') diff --git a/src/shot.c b/src/shot.c index 7a7d55a..f5da8a9 100644 --- a/src/shot.c +++ b/src/shot.c @@ -10,6 +10,7 @@ #include "pipe.h" #include "net_multiplayer.h" #include "proto.h" +#include "idManager.h" #ifndef PUBLIC_SERVER #include "image.h" @@ -31,6 +32,7 @@ static SDL_Surface *g_shot_bombball; #endif static bool_t isShotInit = FALSE; +static list_t *listID; bool_t isShotInicialized() { @@ -52,6 +54,8 @@ void initShot() #endif + listID = newListID(); + isShotInit = TRUE; } @@ -59,12 +63,11 @@ shot_t* newShot(int x,int y, int px, int py, int gun, int author_id) { shot_t *new; tux_t *author; - static int last_id = 0; new = malloc( sizeof(shot_t) ); memset(new, 0, sizeof(shot_t) ); - new->id = ++last_id; + new->id = getNewID(listID); new->x = x; new->y = y; new->px = px; @@ -153,6 +156,12 @@ shot_t* getShotID(list_t *listShot, int id) return NULL; } +void replaceShotID(shot_t *shot, int id) +{ + replaceID(listID, shot->id, id); + shot->id = id; +} + #ifndef PUBLIC_SERVER @@ -404,11 +413,13 @@ void moveShot(shot_t *shot, int position, int src_x, int src_y, void destroyShot(shot_t *p) { assert( p != NULL ); + delID(listID, p->id); free(p); } void quitShot() { + destroyListID(listID); isShotInit = FALSE; } -- cgit v1.2.3