remove limit of detonating bombs
This commit is contained in:
parent
e280118e3d
commit
8a8afdf56e
1
bomber.h
1
bomber.h
@ -220,7 +220,6 @@ enum tile_types {
|
||||
#define MAXSETS 8
|
||||
#define MAXSPRITES 256
|
||||
#define MAXDAMAGES 512
|
||||
#define MAXBOMBSDETONATED 32
|
||||
|
||||
extern char exitflag;
|
||||
|
||||
|
85
game.c
85
game.c
@ -15,11 +15,7 @@ static listhead activebombs;
|
||||
static listhead activedecays;
|
||||
static listhead activebonus;
|
||||
static listhead activegeneric;
|
||||
|
||||
static bomb *detonated[MAXBOMBSDETONATED];
|
||||
static int detonateput=0;
|
||||
static int detonatetake=0;
|
||||
|
||||
static listhead detonatebombs;
|
||||
static listhead activeflames;
|
||||
static listhead activeplayers;
|
||||
|
||||
@ -124,14 +120,13 @@ static void initgame() {
|
||||
gameframe=0;
|
||||
allocthings();
|
||||
initheader(&activebombs);
|
||||
initheader(&detonatebombs);
|
||||
initheader(&activeflames);
|
||||
initheader(&activedecays);
|
||||
initheader(&activebonus);
|
||||
initheader(&activeplayers);
|
||||
initheader(&activegeneric);
|
||||
|
||||
detonateput=detonatetake=0;
|
||||
|
||||
p=bonuschances;
|
||||
bonustotal=0;
|
||||
for(;;) {
|
||||
@ -226,37 +221,6 @@ static void dropbomb(player *pl,int px,int py,int type){
|
||||
bmb->owner=pl;
|
||||
}
|
||||
|
||||
static void adddetonate(bomb *bmb) {
|
||||
if(bmb->type==BOMB_OFF) return;
|
||||
|
||||
bmb->type=BOMB_OFF;
|
||||
field[bmb->py][bmb->px]=FIELD_EXPLODING;
|
||||
info[bmb->py][bmb->px]=0;
|
||||
detonated[detonateput++]=bmb;
|
||||
detonateput%=MAXBOMBSDETONATED;
|
||||
}
|
||||
|
||||
static void processbombs() {
|
||||
bomb *bmb, *next;
|
||||
|
||||
foreach_list_safe(&activebombs, bmb, next) {
|
||||
++(bmb->figcount);
|
||||
++bmb->timer;
|
||||
switch(bmb->type) {
|
||||
case BOMB_NORMAL:
|
||||
if (bmb->timer == BOMBLIFE)
|
||||
adddetonate(bmb);
|
||||
break;
|
||||
case BOMB_CONTROLLED:
|
||||
if (bmb->timer == BOMB_CONTROLLED_LIFE) {
|
||||
bmb->timer = 0;
|
||||
bmb->type = BOMB_NORMAL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void adddecay(int px,int py) {
|
||||
brickdecay *bd;
|
||||
int xpos,ypos;
|
||||
@ -316,6 +280,38 @@ static void deletebonus(bonustile *bonus) {
|
||||
delink(bonus);
|
||||
}
|
||||
|
||||
static void adddetonate(bomb *bmb) {
|
||||
if (bmb->type==BOMB_OFF) return;
|
||||
|
||||
bmb->type = BOMB_OFF;
|
||||
field[bmb->py][bmb->px] = FIELD_EXPLODING;
|
||||
info[bmb->py][bmb->px] = 0;
|
||||
|
||||
removeitem(bmb);
|
||||
addtail(&detonatebombs, bmb);
|
||||
}
|
||||
|
||||
static void processbombs() {
|
||||
bomb *bmb, *next;
|
||||
|
||||
foreach_list_safe(&activebombs, bmb, next) {
|
||||
++(bmb->figcount);
|
||||
++bmb->timer;
|
||||
switch(bmb->type) {
|
||||
case BOMB_NORMAL:
|
||||
if (bmb->timer == BOMBLIFE)
|
||||
adddetonate(bmb);
|
||||
break;
|
||||
case BOMB_CONTROLLED:
|
||||
if (bmb->timer == BOMB_CONTROLLED_LIFE) {
|
||||
bmb->timer = 0;
|
||||
bmb->type = BOMB_NORMAL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void flameshaft(player *owner,int px,int py,int dx,int dy,int power) {
|
||||
int there;
|
||||
bomb *bmb;
|
||||
@ -370,12 +366,13 @@ static void detonatebomb(bomb *bmb) {
|
||||
}
|
||||
|
||||
static void dodetonations(void) {
|
||||
int i=0;
|
||||
int i = 0;
|
||||
bomb *bmb;
|
||||
|
||||
while(detonatetake!=detonateput) {
|
||||
while (!list_empty(&detonatebombs)) {
|
||||
bmb = (bomb*) detonatebombs.next;
|
||||
++i;
|
||||
detonatebomb(detonated[detonatetake]);
|
||||
detonatetake=(detonatetake+1) % MAXBOMBSDETONATED;
|
||||
detonatebomb(bmb);
|
||||
}
|
||||
if(i) playsound((myrand()&1) ? 0 : 4);
|
||||
}
|
||||
@ -477,9 +474,9 @@ static void drawplayers() {
|
||||
}
|
||||
|
||||
static void detonatecontrolled(player *pl) {
|
||||
bomb *bmb;
|
||||
bomb *bmb, *next;
|
||||
|
||||
foreach_list_fast(&activebombs, bmb) {
|
||||
foreach_list_safe(&activebombs, bmb, next) {
|
||||
if(bmb->owner==pl && bmb->type==BOMB_CONTROLLED)
|
||||
adddetonate(bmb);
|
||||
}
|
||||
|
15
list.c
15
list.c
@ -34,9 +34,7 @@ void *allocentry(void) {
|
||||
return entry;
|
||||
}
|
||||
|
||||
static void freeentry(void *_entry) {
|
||||
listhead *entry = _entry;
|
||||
|
||||
void _freeentry(listhead *entry) {
|
||||
entry->next = free_things;
|
||||
entry->prev = NULL;
|
||||
free_things = entry;
|
||||
@ -49,13 +47,16 @@ void _addtail(listhead *head, listhead *entry) {
|
||||
head->prev = entry;
|
||||
}
|
||||
|
||||
void _removeitem(listhead *entry) {
|
||||
entry->next->prev = entry->prev;
|
||||
entry->prev->next = entry->next;
|
||||
}
|
||||
|
||||
listhead* delinkhead(listhead *entry) {
|
||||
listhead *result = entry->prev;
|
||||
|
||||
entry->next->prev = entry->prev;
|
||||
entry->prev->next = entry->next;
|
||||
|
||||
freeentry(entry);
|
||||
_removeitem(entry);
|
||||
_freeentry(entry);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
9
list.h
9
list.h
@ -3,11 +3,17 @@
|
||||
|
||||
void allocthings(void);
|
||||
void *allocentry(void);
|
||||
void _freeentry(listhead *entry);
|
||||
#define freeentry(entry) _freeentry(&(entry->list));
|
||||
|
||||
void _addtail(listhead *header, listhead *entry);
|
||||
#define addtail(head, entry) _addtail(head, &(entry->list));
|
||||
|
||||
/* returns previous entry */
|
||||
/* remove entry from list */
|
||||
void _removeitem(listhead *entry);
|
||||
#define removeitem(entry) _removeitem(&(entry->list));
|
||||
|
||||
/* returns previous entry, deletes entry */
|
||||
listhead* delinkhead(listhead *entry);
|
||||
#define delink(entry) delinkhead(&(entry->list));
|
||||
|
||||
@ -22,5 +28,6 @@ void initheader(listhead *head);
|
||||
#define foreach_list_safe(head, item, next) \
|
||||
for (item = (void*) (head)->next, next = (void*) ((listhead*)item)->next; (listhead*) item != (head); item = next, next = (void*) ((listhead*)item)->next)
|
||||
|
||||
#define list_empty(head) ((head) == (head)->next)
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user