Merge branch 'zsense'
This commit is contained in:
commit
c1d9ce89c3
2 changed files with 26 additions and 7 deletions
20
src/list.c
20
src/list.c
|
@ -19,13 +19,21 @@ typedef struct {
|
|||
void *_FREEREF;
|
||||
|
||||
void *create_element(void **dest, int size) {
|
||||
void *e = malloc(size);
|
||||
List *e = malloc(size);
|
||||
List **d = (List **)dest;
|
||||
|
||||
e->next = NULL;
|
||||
e->prev = *d;
|
||||
|
||||
if(*d != NULL) {
|
||||
e->next = (*d)->next;
|
||||
if((*d)->next)
|
||||
((List *)(*d)->next)->prev = e;
|
||||
|
||||
((List *)e)->prev = NULL;
|
||||
((List *)e)->next = *dest;
|
||||
if(*dest != NULL)
|
||||
((List *)(*dest))->prev = e;
|
||||
*dest = e;
|
||||
(*d)->next = e;
|
||||
} else {
|
||||
*d = e;
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,18 @@ Projectile *create_projectile4c(char *name, complex pos, Color *clr, ProjRule ru
|
|||
|
||||
Projectile *create_projectile_p(Projectile **dest, Texture *tex, complex pos, Color *clr,
|
||||
ProjDRule draw, ProjRule rule, complex a1, complex a2, complex a3, complex a4) {
|
||||
Projectile *p = create_element((void **)dest, sizeof(Projectile));
|
||||
Projectile *p, *e, **d;
|
||||
|
||||
for(e = *dest; e && e->next; e = e->next)
|
||||
if(e->prev && tex->w*tex->h > e->tex->w*e->tex->h)
|
||||
break;
|
||||
|
||||
if(e == NULL)
|
||||
d = dest;
|
||||
else
|
||||
d = &e;
|
||||
|
||||
p = create_element((void **)d, sizeof(Projectile));
|
||||
|
||||
p->birthtime = global.frames;
|
||||
p->pos = pos;
|
||||
|
|
Loading…
Reference in a new issue