Redo some list foreach loops

This commit is contained in:
Stefan Bühler 2009-08-11 19:13:18 +02:00
parent 8a8afdf56e
commit 5e908b9936

22
game.c
View File

@ -521,14 +521,11 @@ static void killplayer(player *pl) {
} }
static void processgenerics(void) { static void processgenerics(void) {
generic *gen,*gen2; generic *gen, *next;
gen = (generic*) activegeneric.next; foreach_list_safe(&activegeneric, gen, next) {
while ((listhead*) gen != &activegeneric) { ++(gen->timer);
gen2 = gen; gen->process(gen);
gen = (generic*) gen->list.next;
++(gen2->timer);
gen2->process(gen2);
} }
} }
@ -765,13 +762,10 @@ static void doplayer(player *pl) {
} }
static void processplayers(void) { static void processplayers(void) {
player *pl, *pl2; player *pl, *next;
pl = (player*) activeplayers.next; foreach_list_safe(&activeplayers, pl, next) {
while ((listhead*) pl != &activeplayers) { doplayer(pl);
pl2 = pl;
pl = (player*) pl->list.next;
doplayer(pl2);
} }
} }
@ -858,7 +852,7 @@ static int iterate(void) {
drawplayers(); drawplayers();
plotsprites(); plotsprites();
copyup(); copyup();
if (activegeneric.next == &activegeneric) { if (list_empty(&activegeneric)) {
player *pl; player *pl;
int deadplayers = 0; int deadplayers = 0;