summaryrefslogtreecommitdiff
path: root/src/shot.c
diff options
context:
space:
mode:
authororoborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-05-22 20:13:25 +0000
committeroroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-05-22 20:13:25 +0000
commita1e9bc7430ca827808a502f455b20a23ba15e31a (patch)
tree0f5367068425be881657840c08756662510adf39 /src/shot.c
parent7055882c93022da3a6a1cf74cebf3d17c44ce6c4 (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/shot.c')
-rw-r--r--src/shot.c15
1 files changed, 13 insertions, 2 deletions
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;
}