diff options
| author | Phil <cracker642@gmail.com> | 2010-09-11 02:18:59 (GMT) |
|---|---|---|
| committer | Phil <cracker642@gmail.com> | 2010-09-11 02:18:59 (GMT) |
| commit | a20e247674b7ceb210c2d9e1335cd90d8d4a547c (patch) | |
| tree | e113ffa9987c9e2ea5412c1a54f3b62d6100be7d /main.c | |
| parent | 6d70d1fdee6d6ffabbc5393af13afeabd0ac2d9c (diff) | |
| download | powder-a20e247674b7ceb210c2d9e1335cd90d8d4a547c.zip powder-a20e247674b7ceb210c2d9e1335cd90d8d4a547c.tar.gz | |
New temp saving system, only loads from saves it makes right now, but it allows for much more temp accuracy, less than 1 degree.
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 52 |
1 files changed, 45 insertions, 7 deletions
@@ -311,10 +311,30 @@ void *build_save(int *size, int x0, int y0, int w, int h) i = m[j]; if(i) { - unsigned char tttemp = (unsigned char)((parts[i-1].temp+(-MIN_TEMP))/((MAX_TEMP+(-MIN_TEMP))/255)); + 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; @@ -620,16 +641,33 @@ int parse_save(void *save, int size, int replace, int x0, int y0) goto corrupt; } 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 |
