summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjacksonmj <mj-pt@jacksonmj.co.uk>2011-12-13 09:16:17 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-12-18 14:04:48 (GMT)
commit33271ce3e29a0cea246e32e823388db7a8f39abc (patch)
treee1f98b88831e8ad0f103f6ae74b2bb8d36df89d3 /src
parent46068833d130eecc95942613cd8cc9c4cb6188fe (diff)
downloadpowder-33271ce3e29a0cea246e32e823388db7a8f39abc.zip
powder-33271ce3e29a0cea246e32e823388db7a8f39abc.tar.gz
Fix creating particles in autorun.lua
Diffstat (limited to 'src')
-rw-r--r--src/main.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index 097ba98..96ccfb3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -545,7 +545,6 @@ int parse_save(void *save, int size, int replace, int x0, int y0, unsigned char
int nf=0, new_format = 0, ttv = 0;
particle *parts = partsptr;
int *fp = malloc(NPART*sizeof(int));
- parts_lastActiveIndex = NPART-1;
//New file header uses PSv, replacing fuC. This is to detect if the client uses a new save format for temperatures
//This creates a problem for old clients, that display and "corrupt" error instead of a "newer version" error
@@ -630,6 +629,7 @@ int parse_save(void *save, int size, int replace, int x0, int y0, unsigned char
}
clear_sim();
}
+ parts_lastActiveIndex = NPART-1;
m = calloc(XRES*YRES, sizeof(int));
// make a catalog of free parts
@@ -1124,13 +1124,16 @@ corrupt:
void clear_sim(void)
{
- int x, y;
+ int i, x, y;
memset(bmap, 0, sizeof(bmap));
memset(emap, 0, sizeof(emap));
memset(signs, 0, sizeof(signs));
memset(parts, 0, sizeof(particle)*NPART);
- pfree = -1;
- parts_lastActiveIndex = NPART-1;
+ for (i=0; i<NPART-1; i++)
+ parts[i].life = i+1;
+ parts[NPART-1].life = -1;
+ pfree = 0;
+ parts_lastActiveIndex = 0;
memset(pmap, 0, sizeof(pmap));
memset(pv, 0, sizeof(pv));
memset(vx, 0, sizeof(vx));