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 | |
| 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.
| -rw-r--r-- | graphics.c | 6 | ||||
| -rw-r--r-- | main.c | 52 | ||||
| -rw-r--r-- | powder.c | 56 |
3 files changed, 76 insertions, 38 deletions
@@ -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]; @@ -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 @@ -1936,32 +1936,32 @@ player[23] = 1; int w = (rand()%255+1); int e = (rand()%255+1); for(nx=-1; nx<2; nx++) - for(ny=-2; ny<3; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx<XRES && y+ny<YRES) - { - if(5>=rand()%8) + for(ny=-2; ny<3; ny++) + if(x+nx>=0 && y+ny>0 && + x+nx<XRES && y+ny<YRES) { - if(!pmap[y+ny][x+nx]) - { - create_part(-1, x+nx, y+ny , PT_DUST); - pv[y/CELL][x/CELL] += 2.00f*CFDS; - a= pmap[y+ny][x+nx]; - if(parts[a>>8].type==PT_DUST) + if(5>=rand()%8) { - parts[a>>8].vy = -(rand()%10-1); - parts[a>>8].vx = ((rand()%2)*2-1)*rand()%(5+5)+(parts[i].vx)*2 ; - parts[a>>8].life= rand()%75+35; - parts[a>>8].tmp=q; - parts[a>>8].flags=w; - parts[a>>8].ctype=e; - parts[a>>8].temp= rand()%20+600; - } + if(!pmap[y+ny][x+nx]) + { + create_part(-1, x+nx, y+ny , PT_DUST); + pv[y/CELL][x/CELL] += 2.00f*CFDS; + a= pmap[y+ny][x+nx]; + if(parts[a>>8].type==PT_DUST) + { + parts[a>>8].vy = -(rand()%10-1); + parts[a>>8].vx = ((rand()%2)*2-1)*rand()%(5+5)+(parts[i].vx)*2 ; + parts[a>>8].life= rand()%75+35; + parts[a>>8].tmp=q; + parts[a>>8].flags=w; + parts[a>>8].ctype=e; + parts[a>>8].temp= rand()%20+600; + } + } } + } - - } - parts[i].type=PT_NONE; + parts[i].type=PT_NONE; } } if(t==PT_DUST&&!parts[i].life==0) @@ -2450,12 +2450,12 @@ void update_particles(pixel *vid) for(j=0; j<CELL; j+=2) for(i=(j>>1)&1; i<CELL; i+=2) vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080); - if(bmap[y][x]==8) - { - for(j=0; j<CELL; j++) - for(i=0; i<CELL; i++) - if(!((y*CELL+j)%2) && !((x*CELL+i)%2)) - vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0xC0C0C0); + if(bmap[y][x]==8) + { + for(j=0; j<CELL; j++) + for(i=0; i<CELL; i++) + if(!((y*CELL+j)%2) && !((x*CELL+i)%2)) + vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0xC0C0C0); if(emap[y][x]) { cr = cg = cb = 16; |
