New temp saving system, only loads from saves it makes right now, but it allows for much more temp accuracy, less than 1 degree.

This commit is contained in:
Phil 2010-09-10 22:18:59 -04:00
parent 6d70d1fdee
commit a20e247674
3 changed files with 76 additions and 38 deletions

View File

@ -1431,9 +1431,9 @@ void draw_parts(pixel *vid)
if(cmode == 3||cmode==4 || cmode==6)
{
vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(parts[i].tmp,parts[i].ctype,parts[i].flags);
cg = parts[i].tmp/5;
cb = parts[i].ctype/5;
cr = parts[i].flags/5;
cg = parts[i].tmp/4;
cb = parts[i].ctype/4;
cr = parts[i].flags/4;
x = nx/CELL;
y = ny/CELL;
cg += fire_g[y][x];

48
main.c
View File

@ -310,11 +310,31 @@ void *build_save(int *size, int x0, int y0, int w, int h)
{
i = m[j];
if(i)
{
if(cracker)
{
int z;
int temp1 = 0;
int temp = parts[i-1].temp;
int temp2 = temp;
for(z = 15;z>=8;z--)
{
if(temp>0&&temp>=powf(2,z))
{
temp1 += powf(2,z-8);
temp -= powf(2,z);
}
}
d[p++] = (char)temp1;
d[p++] = (char)temp2;
}
else
{
unsigned char tttemp = (unsigned char)((parts[i-1].temp+(-MIN_TEMP))/((MAX_TEMP+(-MIN_TEMP))/255));
d[p++] = tttemp;
}
//if(tttemp<0) tttemp=0;
//if(tttemp>255) tttemp=255;
d[p++] = tttemp;
}
}
for(j=0; j<w*h; j++)
@ -362,6 +382,7 @@ void *build_save(int *size, int x0, int y0, int w, int h)
c[10] = p >> 16;
c[11] = p >> 24;
i -= 12;
if(BZ2_bzBuffToBuffCompress((char *)(c+12), (unsigned *)&i, (char *)d, p, 9, 0, 0) != BZ_OK)
@ -468,7 +489,7 @@ int parse_save(void *save, int size, int replace, int x0, int y0)
if(d[p])
{
bmap[y][x] = d[p];
if(cracker)
if(!cracker)
{
if(bmap[y][x]==1)
bmap[y][x]=11;
@ -621,15 +642,32 @@ int parse_save(void *save, int size, int replace, int x0, int y0)
}
if(i <= NPART)
{
if(ver>=42){
if(cracker)
{
int z;
int q = 0;
int temp1 = d[p++];
int temp2 = d[p++];
for(z = 7;z>=0;z--)
{
if(temp1>0&&temp1>=powf(2,z))
{
q += powf(2,z+8);
temp1 -= powf(2,z);
}
}
parts[i-1].temp = temp2 + q + 0.15;
}
else if(ver>=42){
parts[i-1].temp = (d[p++]*((MAX_TEMP+(-MIN_TEMP))/255))+MIN_TEMP;
} else {
parts[i-1].temp = ((d[p++]*((O_MAX_TEMP+(-O_MIN_TEMP))/255))+O_MIN_TEMP)+273;
parts[i-1].temp = ((d[p++]*((O_MAX_TEMP+(-O_MIN_TEMP))/255))+O_MIN_TEMP)+273.15;
}
}
else
{
p++;
p += 2;
}
}
else