Skip to content
Snippets Groups Projects
Commit 4b7e7c21 authored by DarkGod's avatar DarkGod
Browse files

Merge branch 'master' of git.net-core.org:tome/t-engine4

parents 28959b03 26da8cc4
No related branches found
No related tags found
No related merge requests found
...@@ -986,8 +986,9 @@ void thread_particle_init(particle_thread *pt, plist *l) ...@@ -986,8 +986,9 @@ void thread_particle_init(particle_thread *pt, plist *l)
ps->init = TRUE; ps->init = TRUE;
} }
void thread_particle_die(particle_thread *pt, plist *l) plist * thread_particle_die(particle_thread *pt, plist *l)
{ {
plist *lnext = l->next;
lua_State *L = pt->L; lua_State *L = pt->L;
particles_type *ps = l->ps; particles_type *ps = l->ps;
...@@ -1022,9 +1023,15 @@ void thread_particle_die(particle_thread *pt, plist *l) ...@@ -1022,9 +1023,15 @@ void thread_particle_die(particle_thread *pt, plist *l)
if (ps->vertices) { free(ps->vertices); ps->vertices = NULL; } if (ps->vertices) { free(ps->vertices); ps->vertices = NULL; }
if (ps->colors) { free(ps->colors); ps->colors = NULL; } if (ps->colors) { free(ps->colors); ps->colors = NULL; }
if (ps->particles) { free(ps->particles); ps->particles = NULL; } if (ps->particles) { free(ps->particles); ps->particles = NULL; }
if (ps->args) { free(ps->args); ps->args = NULL; }
if (ps->name_def) { free(ps->name_def); ps->name_def = NULL; }
ps->init = FALSE; ps->init = FALSE;
ps->alive = FALSE; ps->alive = FALSE;
ps->l = NULL;
} }
free(l);
return lnext;
} }
// Runs on particles thread // Runs on particles thread
...@@ -1083,13 +1090,13 @@ int thread_particles(void *data) ...@@ -1083,13 +1090,13 @@ int thread_particles(void *data)
} }
else else
{ {
thread_particle_die(pt, l); plist *lnext = thread_particle_die(pt, l);
// Remove dead ones // Remove dead ones
if (!prev) pt->list = l->next; if (!prev) pt->list = lnext;
else prev->next = l->next; else prev->next = lnext;
l = l->next; l = lnext;
} }
nb++; nb++;
} }
...@@ -1103,10 +1110,7 @@ int thread_particles(void *data) ...@@ -1103,10 +1110,7 @@ int thread_particles(void *data)
SDL_mutexP(pt->lock); SDL_mutexP(pt->lock);
l = pt->list; l = pt->list;
while (l) while (l)
{ l = thread_particle_die(pt, l);
thread_particle_die(pt, l);
l = l->next;
}
SDL_mutexV(pt->lock); SDL_mutexV(pt->lock);
lua_close(L); lua_close(L);
...@@ -1139,6 +1143,9 @@ void thread_add(particles_type *ps) ...@@ -1139,6 +1143,9 @@ void thread_add(particles_type *ps)
plist *l = malloc(sizeof(plist)); plist *l = malloc(sizeof(plist));
l->pt = pt; l->pt = pt;
l->ps = ps; l->ps = ps;
l->generator_ref = LUA_NOREF;
l->updator_ref = LUA_NOREF;
l->emit_ref = LUA_NOREF;
l->next = pt->list; l->next = pt->list;
pt->list = l; pt->list = l;
ps->l = l; ps->l = l;
......
...@@ -210,6 +210,7 @@ int thread_save(void *data) ...@@ -210,6 +210,7 @@ int thread_save(void *data)
free(q->payload); free(q->payload);
free(q->zfname); free(q->zfname);
free(q->filename); free(q->filename);
free(q);
} }
if (zf) { if (zf) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment