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 MAXSETS 8
|
||||||
#define MAXSPRITES 256
|
#define MAXSPRITES 256
|
||||||
#define MAXDAMAGES 512
|
#define MAXDAMAGES 512
|
||||||
#define MAXBOMBSDETONATED 32
|
|
||||||
|
|
||||||
extern char exitflag;
|
extern char exitflag;
|
||||||
|
|
||||||
|
83
game.c
83
game.c
@ -15,11 +15,7 @@ static listhead activebombs;
|
|||||||
static listhead activedecays;
|
static listhead activedecays;
|
||||||
static listhead activebonus;
|
static listhead activebonus;
|
||||||
static listhead activegeneric;
|
static listhead activegeneric;
|
||||||
|
static listhead detonatebombs;
|
||||||
static bomb *detonated[MAXBOMBSDETONATED];
|
|
||||||
static int detonateput=0;
|
|
||||||
static int detonatetake=0;
|
|
||||||
|
|
||||||
static listhead activeflames;
|
static listhead activeflames;
|
||||||
static listhead activeplayers;
|
static listhead activeplayers;
|
||||||
|
|
||||||
@ -124,14 +120,13 @@ static void initgame() {
|
|||||||
gameframe=0;
|
gameframe=0;
|
||||||
allocthings();
|
allocthings();
|
||||||
initheader(&activebombs);
|
initheader(&activebombs);
|
||||||
|
initheader(&detonatebombs);
|
||||||
initheader(&activeflames);
|
initheader(&activeflames);
|
||||||
initheader(&activedecays);
|
initheader(&activedecays);
|
||||||
initheader(&activebonus);
|
initheader(&activebonus);
|
||||||
initheader(&activeplayers);
|
initheader(&activeplayers);
|
||||||
initheader(&activegeneric);
|
initheader(&activegeneric);
|
||||||
|
|
||||||
detonateput=detonatetake=0;
|
|
||||||
|
|
||||||
p=bonuschances;
|
p=bonuschances;
|
||||||
bonustotal=0;
|
bonustotal=0;
|
||||||
for(;;) {
|
for(;;) {
|
||||||
@ -226,37 +221,6 @@ static void dropbomb(player *pl,int px,int py,int type){
|
|||||||
bmb->owner=pl;
|
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) {
|
static void adddecay(int px,int py) {
|
||||||
brickdecay *bd;
|
brickdecay *bd;
|
||||||
int xpos,ypos;
|
int xpos,ypos;
|
||||||
@ -316,6 +280,38 @@ static void deletebonus(bonustile *bonus) {
|
|||||||
delink(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) {
|
static void flameshaft(player *owner,int px,int py,int dx,int dy,int power) {
|
||||||
int there;
|
int there;
|
||||||
bomb *bmb;
|
bomb *bmb;
|
||||||
@ -371,11 +367,12 @@ static void detonatebomb(bomb *bmb) {
|
|||||||
|
|
||||||
static void dodetonations(void) {
|
static void dodetonations(void) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
bomb *bmb;
|
||||||
|
|
||||||
while(detonatetake!=detonateput) {
|
while (!list_empty(&detonatebombs)) {
|
||||||
|
bmb = (bomb*) detonatebombs.next;
|
||||||
++i;
|
++i;
|
||||||
detonatebomb(detonated[detonatetake]);
|
detonatebomb(bmb);
|
||||||
detonatetake=(detonatetake+1) % MAXBOMBSDETONATED;
|
|
||||||
}
|
}
|
||||||
if(i) playsound((myrand()&1) ? 0 : 4);
|
if(i) playsound((myrand()&1) ? 0 : 4);
|
||||||
}
|
}
|
||||||
@ -477,9 +474,9 @@ static void drawplayers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void detonatecontrolled(player *pl) {
|
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)
|
if(bmb->owner==pl && bmb->type==BOMB_CONTROLLED)
|
||||||
adddetonate(bmb);
|
adddetonate(bmb);
|
||||||
}
|
}
|
||||||
|
15
list.c
15
list.c
@ -34,9 +34,7 @@ void *allocentry(void) {
|
|||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void freeentry(void *_entry) {
|
void _freeentry(listhead *entry) {
|
||||||
listhead *entry = _entry;
|
|
||||||
|
|
||||||
entry->next = free_things;
|
entry->next = free_things;
|
||||||
entry->prev = NULL;
|
entry->prev = NULL;
|
||||||
free_things = entry;
|
free_things = entry;
|
||||||
@ -49,13 +47,16 @@ void _addtail(listhead *head, listhead *entry) {
|
|||||||
head->prev = entry;
|
head->prev = entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _removeitem(listhead *entry) {
|
||||||
|
entry->next->prev = entry->prev;
|
||||||
|
entry->prev->next = entry->next;
|
||||||
|
}
|
||||||
|
|
||||||
listhead* delinkhead(listhead *entry) {
|
listhead* delinkhead(listhead *entry) {
|
||||||
listhead *result = entry->prev;
|
listhead *result = entry->prev;
|
||||||
|
|
||||||
entry->next->prev = entry->prev;
|
_removeitem(entry);
|
||||||
entry->prev->next = entry->next;
|
_freeentry(entry);
|
||||||
|
|
||||||
freeentry(entry);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
9
list.h
9
list.h
@ -3,11 +3,17 @@
|
|||||||
|
|
||||||
void allocthings(void);
|
void allocthings(void);
|
||||||
void *allocentry(void);
|
void *allocentry(void);
|
||||||
|
void _freeentry(listhead *entry);
|
||||||
|
#define freeentry(entry) _freeentry(&(entry->list));
|
||||||
|
|
||||||
void _addtail(listhead *header, listhead *entry);
|
void _addtail(listhead *header, listhead *entry);
|
||||||
#define addtail(head, entry) _addtail(head, &(entry->list));
|
#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);
|
listhead* delinkhead(listhead *entry);
|
||||||
#define delink(entry) delinkhead(&(entry->list));
|
#define delink(entry) delinkhead(&(entry->list));
|
||||||
|
|
||||||
@ -22,5 +28,6 @@ void initheader(listhead *head);
|
|||||||
#define foreach_list_safe(head, item, next) \
|
#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)
|
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
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user