fix loading of old GoL saves, and fix wall crash

This commit is contained in:
Cracker64 2011-01-16 13:54:36 -05:00
parent b1e09d4216
commit db5bb618c1
2 changed files with 7 additions and 2 deletions

View File

@ -405,7 +405,7 @@ int parse_save(void *save, int size, int replace, int x0, int y0)
{ {
unsigned char *d,*c=save; unsigned char *d,*c=save;
int i,j,k,x,y,p=0,*m=calloc(XRES*YRES, sizeof(int)), ver, pty, ty, legacy_beta=0; int i,j,k,x,y,p=0,*m=calloc(XRES*YRES, sizeof(int)), ver, pty, ty, legacy_beta=0;
int bx0=x0/CELL, by0=y0/CELL, bw, bh, w, h; int bx0=x0/CELL, by0=y0/CELL, bw, bh, w, h, q;
int fp[NPART], nf=0, new_format = 0, ttv = 0; int fp[NPART], nf=0, new_format = 0, ttv = 0;
//New file header uses PSv, replacing fuC. This is to detect if the client uses a new save format for temperatures //New file header uses PSv, replacing fuC. This is to detect if the client uses a new save format for temperatures
@ -707,6 +707,11 @@ int parse_save(void *save, int size, int replace, int x0, int y0)
ttv = (d[p++])<<8; ttv = (d[p++])<<8;
ttv |= (d[p++]); ttv |= (d[p++]);
parts[i-1].tmp = ttv; parts[i-1].tmp = ttv;
if(ptypes[parts[i-1].type].properties&PROP_LIFE && !parts[i-1].tmp)
for(q = 1; q<NGOL ; q++){
if(parts[i-1].type==goltype[q-1] && grule[q][9]==2)
parts[i-1].tmp = grule[q][9]-1;
}
} else { } else {
p+=2; p+=2;
} }

View File

@ -1297,7 +1297,7 @@ void update_particles_i(pixel *vid, int start, int inc)
{ {
r = pmap[ny][nx]; r = pmap[ny][nx];
int neighbors = gol2[nx][ny][0]; int neighbors = gol2[nx][ny][0];
if(neighbors==0 || !(ptypes[r&0xFF].properties&PROP_LIFE || !r&0xFF)) if(neighbors==0 || !(ptypes[r&0xFF].properties&PROP_LIFE || !r&0xFF) || (r>>8)>=NPART)
continue; continue;
for( golnum = 1;golnum<NGOL;golnum++) for( golnum = 1;golnum<NGOL;golnum++)
for( goldelete = 0;goldelete<9;goldelete++) for( goldelete = 0;goldelete<9;goldelete++)