diff options
| author | Jacob1 <jfu614@gmail.com> | 2012-01-18 00:20:52 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-01-26 14:15:57 (GMT) |
| commit | 35270d1e37eec4976e7ad654917908ed3b8d2367 (patch) | |
| tree | e9de5f29dd784762facb74c9b7ba766da3c2f4e2 /src | |
| parent | eaf2af6d405f715c60ab28b8725d44b4e4a68539 (diff) | |
| download | powder-35270d1e37eec4976e7ad654917908ed3b8d2367.zip powder-35270d1e37eec4976e7ad654917908ed3b8d2367.tar.gz | |
save tmp2, show decoration color on stamps
Diffstat (limited to 'src')
| -rw-r--r-- | src/save.c | 37 |
1 files changed, 30 insertions, 7 deletions
@@ -226,7 +226,7 @@ pixel *prerender_save_OPS(void *save, int size, int *width, int *height) goto fail; } if(partsData[i] >= PT_NUM) - partsData[i] = PT_DMND; //Replace all invalid powders with diamond + partsData[i] = PT_DMND; //Replace all invalid elements with diamond //Draw type vidBuf[(fullY+y)*fullW+(fullX+x)] = ptypes[partsData[i]].pcolors; @@ -273,24 +273,33 @@ pixel *prerender_save_OPS(void *save, int size, int *width, int *height) } } - //Skip dcolour + //Read dcolour if(fieldDescriptor & 0x40) { if(i+3 >= partsDataLen) goto fail; - i+=4; + i++; //vidBuf[(fullY+y)*fullW+(fullX+x)] = (unsigned)partsData[i++]<<24; + vidBuf[(fullY+y)*fullW+(fullX+x)] = (unsigned)partsData[i++]<<16; + vidBuf[(fullY+y)*fullW+(fullX+x)] |= (unsigned)partsData[i++]<<8; + vidBuf[(fullY+y)*fullW+(fullX+x)] |= (unsigned)partsData[i++]; } - //Read vx + //Skip vx if(fieldDescriptor & 0x80) { if(i++ >= partsDataLen) goto fail; } - //Read vy + //Skip vy if(fieldDescriptor & 0x100) { if(i++ >= partsDataLen) goto fail; } + + //Skip tmp2 + if(fieldDescriptor & 0x400) + { + if(i++ >= partsDataLen) goto fail; + } } } } @@ -424,7 +433,7 @@ void *build_save_OPS(int *size, int orig_x0, int orig_y0, int orig_w, int orig_h //Copy parts data /* Field descriptor format: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | - | vy | vx | dcololour | ctype | tmp[2] | tmp[1] | life[2] | life[1] | temp dbl len| + | tmp2 | ctype[2] | vy | vx | dcololour | ctype[1] | tmp[2] | tmp[1] | life[2] | life[1] | temp dbl len| life[2] means a second byte (for a 16 bit field) if life[1] is present */ partsData = malloc(NPART * (sizeof(particle)+1)); @@ -534,6 +543,13 @@ void *build_save_OPS(int *size, int orig_x0, int orig_y0, int orig_w, int orig_h if (vTemp>255) vTemp=255; partsData[partsDataLen++] = vTemp; } + + //Tmp2 (optional), 1 byte + if(partsptr[i].tmp2) + { + fieldDesc |= 1 << 10; + partsData[partsDataLen++] = partsptr[i].tmp2; + } //Write the field descriptor; partsData[fieldDescLoc] = fieldDesc; @@ -1004,7 +1020,7 @@ int parse_save_OPS(void *save, int size, int replace, int x0, int y0, unsigned c goto fail; } if(partsData[i] >= PT_NUM) - partsData[i] = PT_DMND; //Replace all invalid powders with diamond + partsData[i] = PT_DMND; //Replace all invalid elements with diamond if(pmap[y][x]) { //Replace existing particle or allocated block @@ -1111,6 +1127,13 @@ int parse_save_OPS(void *save, int size, int replace, int x0, int y0, unsigned c if(i >= partsDataLen) goto fail; partsptr[newIndex].vy = (partsData[i++]-127.0f)/16.0f; } + + //Read tmp2 + if(fieldDescriptor & 0x400) + { + if(i >= partsDataLen) goto fail; + partsptr[newIndex].tmp2 = partsData[i++]; + } } } } |
