summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authororoborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-07-17 10:29:56 +0000
committeroroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-07-17 10:29:56 +0000
commit7efb51e2cb64a417d9d18ba0064c84abad265dad (patch)
tree012c15bf21b226770ad1e1c5e67cb8e7e69307d4
parentd5ae032d2b251a1604042f68a9cd3215c233792e (diff)
- oprava hrozostrasnej chyby s itemami na revery, ktora zadzovala clientov
- ak sa item zobere novy sa automaticky vytovri git-svn-id: http://opensvn.csie.org/tuxanci_ng@151 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
-rw-r--r--config.h2
-rw-r--r--src/base/arena.c2
-rw-r--r--src/base/item.c117
-rw-r--r--src/base/proto.c8
-rw-r--r--src/base/tux.c36
5 files changed, 81 insertions, 84 deletions
diff --git a/config.h b/config.h
index 5970e49..5308a87 100644
--- a/config.h
+++ b/config.h
@@ -1 +1 @@
-#define TUXANCI_NG_VERSION "svn150"
+#define TUXANCI_NG_VERSION "svn151"
diff --git a/src/base/arena.c b/src/base/arena.c
index b90c650..5b069f1 100644
--- a/src/base/arena.c
+++ b/src/base/arena.c
@@ -46,7 +46,7 @@ arena_t* newArena(int w, int h)
new->listTimer = newList();
- if( w > 800 || h > 600)
+ if( w > 800 || h > 600 )
{
zone_w = 320;
zone_h = 240;
diff --git a/src/base/item.c b/src/base/item.c
index 08651fd..d5ca081 100644
--- a/src/base/item.c
+++ b/src/base/item.c
@@ -86,11 +86,6 @@ item_t* newItem(int x, int y, int type, int author_id)
#endif
new->author_id = author_id;
- if( author_id != ID_UNKNOWN )
- {
- incID(author_id);
- }
-
switch( type )
{
case GUN_DUAL_SIMPLE :
@@ -268,74 +263,68 @@ void drawListItem(list_t *listItem)
#endif
-void eventListItem(space_t *spaceItem)
+static void action_itemevent(space_t *space, item_t *item, void *p)
{
my_time_t currentTime;
- item_t *thisItem;
- int i;
currentTime = getMyTime();
- assert( spaceItem != NULL );
-
- for( i = 0 ; i < spaceItem->list->count ; i++ )
- {
- thisItem = (item_t *)spaceItem->list->list[i];
- assert( thisItem != NULL );
-
- thisItem->count++;
+ item->count++;
- if( thisItem->count == ITEM_MAX_COUNT )
- {
- thisItem->count = 0;
- thisItem->frame++;
- }
+ if( item->count == ITEM_MAX_COUNT )
+ {
+ item->count = 0;
+ item->frame++;
+ }
- switch( thisItem->type )
- {
- case GUN_TOMMY :
- case GUN_DUAL_SIMPLE :
- case GUN_SCATTER :
- case GUN_LASSER :
- case GUN_MINE :
- case GUN_BOMBBALL :
- if( thisItem->frame == ITEM_GUN_MAX_FRAME )
- {
- thisItem->frame = 0;
- }
- break;
+ switch( item->type )
+ {
+ case GUN_TOMMY :
+ case GUN_DUAL_SIMPLE :
+ case GUN_SCATTER :
+ case GUN_LASSER :
+ case GUN_MINE :
+ case GUN_BOMBBALL :
+ if( item->frame == ITEM_GUN_MAX_FRAME )
+ {
+ item->frame = 0;
+ }
+ break;
- case ITEM_MINE :
- if( thisItem->frame == ITEM_MINE_MAX_FRAME )
- {
- thisItem->frame = 0;
- }
- break;
+ case ITEM_MINE :
+ if( item->frame == ITEM_MINE_MAX_FRAME )
+ {
+ item->frame = 0;
+ }
+ break;
- case ITEM_EXPLOSION :
- case ITEM_BIG_EXPLOSION :
- if( thisItem->frame == ITEM_EXPLOSION_MAX_FRAME )
- {
- delObjectFromSpaceWithObject(spaceItem, thisItem, destroyItem);
- i--;
- }
- break;
+ case ITEM_EXPLOSION :
+ case ITEM_BIG_EXPLOSION :
+ if( item->frame == ITEM_EXPLOSION_MAX_FRAME )
+ {
+ delObjectFromSpaceWithObject(space, item, destroyItem);
+ }
+ break;
- case BONUS_SPEED :
- case BONUS_SHOT :
- case BONUS_TELEPORT :
- case BONUS_GHOST :
- case BONUS_4X :
- case BONUS_HIDDEN :
- if( thisItem->frame == ITEM_GUN_MAX_FRAME )
- {
- thisItem->frame = 0;
- }
- break;
- }
+ case BONUS_SPEED :
+ case BONUS_SHOT :
+ case BONUS_TELEPORT :
+ case BONUS_GHOST :
+ case BONUS_4X :
+ case BONUS_HIDDEN :
+ if( item->frame == ITEM_GUN_MAX_FRAME )
+ {
+ item->frame = 0;
+ }
+ break;
}
}
+void eventListItem(space_t *spaceItem)
+{
+ actionSpace(spaceItem, action_itemevent, NULL);
+}
+
static void mineExplosion(space_t *spaceItem, item_t *item)
{
if( getNetTypeGame() != NET_GAME_TYPE_CLIENT )
@@ -548,6 +537,8 @@ static void action_giveitem(space_t *space, item_t *item, tux_t *tux)
delObjectFromSpaceWithObject(space, item, destroyItem);
break;
}
+
+ addNewItem(space, ID_UNKNOWN);
}
void eventGiveTuxListItem(tux_t *tux, space_t *spaceItem)
@@ -577,12 +568,6 @@ void destroyItem(item_t *p)
assert( p != NULL );
delID(p->id);
-
- if( p->author_id != ID_UNKNOWN )
- {
- delID(p->author_id);
- }
-
free(p);
}
diff --git a/src/base/proto.c b/src/base/proto.c
index af8a9f7..1de5ad4 100644
--- a/src/base/proto.c
+++ b/src/base/proto.c
@@ -618,6 +618,14 @@ void proto_recv_additem_client(char *msg)
sscanf(msg, "%s %d %d %d %d %d %d %d %d",
cmd, &id, &type, &x, &y, &count, &frame, &author_id, &check_id);
+#if FUCKED_PATCH
+ if( author_id != ID_UNKNOWN &&
+ getObjectFromSpaceWithID(getCurrentArena()->spaceTux, author_id) == NULL )
+ {
+ return;
+ }
+#endif
+
proto_send_check_client(check_id);
if( ( item = getObjectFromSpaceWithID(getCurrentArena()->spaceItem, id) ) != NULL )
diff --git a/src/base/tux.c b/src/base/tux.c
index 94a7666..cfaaddf 100644
--- a/src/base/tux.c
+++ b/src/base/tux.c
@@ -474,22 +474,10 @@ void moveTux(tux_t *tux, int n)
return;
}
- if( n == TUX_LEFT && tux->x-TUX_STEP <= 0 )
- {
- return;
- }
-
- if( n == TUX_RIGHT && tux->x+TUX_STEP >= arena->w )
- {
- return;
- }
-
- if( n == TUX_UP && tux->y-TUX_STEP <= 0 )
- {
- return;
- }
-
- if( n == TUX_DOWN && tux->y+TUX_STEP >= arena->h )
+ if( ( n == TUX_LEFT && tux->x-TUX_STEP <= 0 ) ||
+ ( n == TUX_RIGHT && tux->x+TUX_STEP >= arena->w ) ||
+ ( n == TUX_UP && tux->y-TUX_STEP <= 0 ) ||
+ ( n == TUX_DOWN && tux->y+TUX_STEP >= arena->h ) )
{
return;
}
@@ -769,10 +757,26 @@ void setStatusTux(void *p, int x, int y, int w, int h)
setTuxProportion(tux, x, y);
}
+static void action_checkMine(space_t *space, item_t *item, tux_t *tux)
+{
+ if( item->type == ITEM_MINE && item->author_id == tux->id )
+ {
+ item->author_id = ID_UNKNOWN;
+ }
+}
+
void destroyTux(tux_t *tux)
{
+ arena_t *arena;
+
+ arena = getCurrentArena();
+
assert( tux != NULL );
+
delID(tux->id);
+
+ actionSpace(arena->spaceItem, action_checkMine, tux);
+
free(tux);
}