Put ifs into switch in create_part. Delete useless PSv saving function.
This commit is contained in:
parent
7f5408f196
commit
29f3500ba3
@ -36,8 +36,6 @@ int parse_save_OPS(void *save, int size, int replace, int x0, int y0, unsigned c
|
|||||||
//Old save parsers, readers
|
//Old save parsers, readers
|
||||||
pixel *prerender_save_PSv(void *save, int size, int *width, int *height);
|
pixel *prerender_save_PSv(void *save, int size, int *width, int *height);
|
||||||
|
|
||||||
void *build_save_PSv(int *size, int orig_x0, int orig_y0, int orig_w, int orig_h, unsigned char bmap[YRES/CELL][XRES/CELL], float fvx[YRES/CELL][XRES/CELL], float fvy[YRES/CELL][XRES/CELL], sign signs[MAXSIGNS], void* partsptr);
|
|
||||||
|
|
||||||
int parse_save_PSv(void *save, int size, int replace, int x0, int y0, unsigned char bmap[YRES/CELL][XRES/CELL], float fvx[YRES/CELL][XRES/CELL], float fvy[YRES/CELL][XRES/CELL], sign signs[MAXSIGNS], void* partsptr, unsigned pmap[YRES][XRES]);
|
int parse_save_PSv(void *save, int size, int replace, int x0, int y0, unsigned char bmap[YRES/CELL][XRES/CELL], float fvx[YRES/CELL][XRES/CELL], float fvy[YRES/CELL][XRES/CELL], sign signs[MAXSIGNS], void* partsptr, unsigned pmap[YRES][XRES]);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
197
src/powder.c
197
src/powder.c
@ -905,7 +905,17 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a
|
|||||||
parts[i].tmp = 0;
|
parts[i].tmp = 0;
|
||||||
parts[i].tmp2 = 0;
|
parts[i].tmp2 = 0;
|
||||||
}
|
}
|
||||||
if (t==PT_LIGH && p==-2)
|
//now set various properties that we want at spawn.
|
||||||
|
/*if (ptypes[t].properties&PROP_LIFE) {
|
||||||
|
int r;
|
||||||
|
for (r = 0; r<NGOL; r++)
|
||||||
|
if (t==goltype[r])
|
||||||
|
parts[i].tmp = grule[r+1][9] - 1;
|
||||||
|
}*/
|
||||||
|
switch (t)
|
||||||
|
{
|
||||||
|
case PT_LIGH:
|
||||||
|
if (p==-2)
|
||||||
{
|
{
|
||||||
switch (gravityMode)
|
switch (gravityMode)
|
||||||
{
|
{
|
||||||
@ -921,120 +931,98 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a
|
|||||||
}
|
}
|
||||||
parts[i].tmp2 = 4;
|
parts[i].tmp2 = 4;
|
||||||
}
|
}
|
||||||
if (t==PT_SOAP)
|
break;
|
||||||
{
|
case PT_SOAP:
|
||||||
parts[i].tmp = -1;
|
parts[i].tmp = -1;
|
||||||
parts[i].tmp2 = -1;
|
parts[i].tmp2 = -1;
|
||||||
}
|
break;
|
||||||
//now set various properties that we want at spawn.
|
case PT_ACID: case PT_CAUS:
|
||||||
if (t==PT_ACID || t==PT_CAUS)
|
|
||||||
{
|
|
||||||
parts[i].life = 75;
|
parts[i].life = 75;
|
||||||
}
|
break;
|
||||||
/*Testing
|
/*Testing
|
||||||
if(t==PT_WOOD){
|
case PT_WOOD:
|
||||||
parts[i].life = 150;
|
parts[i].life = 150;
|
||||||
}
|
break;
|
||||||
End Testing*/
|
End Testing*/
|
||||||
if (t==PT_WARP) {
|
case PT_WARP:
|
||||||
parts[i].life = rand()%95+70;
|
parts[i].life = rand()%95+70;
|
||||||
}
|
break;
|
||||||
if (t==PT_FUSE) {
|
case PT_FUSE:
|
||||||
parts[i].life = 50;
|
parts[i].life = 50;
|
||||||
parts[i].tmp = 50;
|
parts[i].tmp = 50;
|
||||||
}
|
break;
|
||||||
/*if (ptypes[t].properties&PROP_LIFE) {
|
case PT_LIFE:
|
||||||
int r;
|
if (v<NGOLALT)
|
||||||
for (r = 0; r<NGOL; r++)
|
|
||||||
if (t==goltype[r])
|
|
||||||
parts[i].tmp = grule[r+1][9] - 1;
|
|
||||||
}*/
|
|
||||||
if (t==PT_LIFE && v<NGOLALT)
|
|
||||||
{
|
{
|
||||||
parts[i].tmp = grule[v+1][9] - 1;
|
parts[i].tmp = grule[v+1][9] - 1;
|
||||||
parts[i].ctype = v;
|
parts[i].ctype = v;
|
||||||
}
|
}
|
||||||
if (t==PT_TRON)
|
break;
|
||||||
{
|
case PT_DEUT:
|
||||||
int randhue = rand()%360;
|
|
||||||
int randomdir = rand()%4;
|
|
||||||
parts[i].tmp = 1|(randomdir<<5)|(randhue<<7);//set as a head and a direction
|
|
||||||
parts[i].tmp2 = 4;//tail
|
|
||||||
parts[i].life = 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (t==PT_DEUT)
|
|
||||||
parts[i].life = 10;
|
parts[i].life = 10;
|
||||||
if (t==PT_MERC)
|
break;
|
||||||
|
case PT_MERC:
|
||||||
parts[i].tmp = 10;
|
parts[i].tmp = 10;
|
||||||
if (t==PT_BRAY)
|
break;
|
||||||
|
case PT_BRAY:
|
||||||
parts[i].life = 30;
|
parts[i].life = 30;
|
||||||
if (t==PT_PUMP || t==PT_GPMP)
|
break;
|
||||||
parts[i].life= 10;
|
case PT_GPMP: case PT_PUMP:
|
||||||
if (t==PT_SING)
|
parts[i].life = 10;
|
||||||
|
break;
|
||||||
|
case PT_SING:
|
||||||
parts[i].life = rand()%50+60;
|
parts[i].life = rand()%50+60;
|
||||||
if (t==PT_QRTZ)
|
break;
|
||||||
|
case PT_QRTZ:
|
||||||
parts[i].tmp = (rand()%11);
|
parts[i].tmp = (rand()%11);
|
||||||
if (t==PT_PQRT)
|
break;
|
||||||
|
case PT_PQRT:
|
||||||
parts[i].tmp = (rand()%11);
|
parts[i].tmp = (rand()%11);
|
||||||
if (t==PT_CLST)
|
break;
|
||||||
|
case PT_CLST:
|
||||||
parts[i].tmp = (rand()%7);
|
parts[i].tmp = (rand()%7);
|
||||||
if (t==PT_FSEP)
|
break;
|
||||||
|
case PT_FSEP:
|
||||||
parts[i].life = 50;
|
parts[i].life = 50;
|
||||||
if (t==PT_COAL) {
|
break;
|
||||||
|
case PT_COAL:
|
||||||
parts[i].life = 110;
|
parts[i].life = 110;
|
||||||
parts[i].tmp = 50;
|
parts[i].tmp = 50;
|
||||||
}
|
break;
|
||||||
if (t==PT_IGNT) {
|
case PT_IGNT:
|
||||||
parts[i].life = 3;
|
parts[i].life = 3;
|
||||||
}
|
break;
|
||||||
if (t==PT_FRZW)
|
case PT_FRZW:
|
||||||
parts[i].life = 100;
|
parts[i].life = 100;
|
||||||
if (t==PT_PIPE)
|
break;
|
||||||
|
case PT_PIPE:
|
||||||
parts[i].life = 60;
|
parts[i].life = 60;
|
||||||
if (t==PT_BCOL)
|
break;
|
||||||
|
case PT_BCOL:
|
||||||
parts[i].life = 110;
|
parts[i].life = 110;
|
||||||
if (t==PT_FIRE)
|
break;
|
||||||
|
case PT_FIRE:
|
||||||
parts[i].life = rand()%50+120;
|
parts[i].life = rand()%50+120;
|
||||||
if (t==PT_PLSM)
|
break;
|
||||||
|
case PT_PLSM:
|
||||||
parts[i].life = rand()%150+50;
|
parts[i].life = rand()%150+50;
|
||||||
if (t==PT_HFLM)
|
break;
|
||||||
|
case PT_HFLM:
|
||||||
parts[i].life = rand()%150+50;
|
parts[i].life = rand()%150+50;
|
||||||
if (t==PT_LAVA)
|
break;
|
||||||
|
case PT_LAVA:
|
||||||
parts[i].life = rand()%120+240;
|
parts[i].life = rand()%120+240;
|
||||||
if (t==PT_NBLE)
|
break;
|
||||||
|
case PT_NBLE:
|
||||||
parts[i].life = 0;
|
parts[i].life = 0;
|
||||||
if (t==PT_ICEI)
|
break;
|
||||||
|
case PT_ICEI:
|
||||||
parts[i].ctype = PT_WATR;
|
parts[i].ctype = PT_WATR;
|
||||||
if (t==PT_NEUT)
|
break;
|
||||||
{
|
case PT_MORT:
|
||||||
float r = (rand()%128+128)/127.0f;
|
|
||||||
float a = (rand()%360)*3.14159f/180.0f;
|
|
||||||
parts[i].life = rand()%480+480;
|
|
||||||
parts[i].vx = r*cosf(a);
|
|
||||||
parts[i].vy = r*sinf(a);
|
|
||||||
}
|
|
||||||
if (t==PT_MORT)
|
|
||||||
{
|
|
||||||
parts[i].vx = 2;
|
parts[i].vx = 2;
|
||||||
}
|
break;
|
||||||
if (t==PT_PHOT)
|
case PT_STKM:
|
||||||
{
|
|
||||||
float a = (rand()%8) * 0.78540f;
|
|
||||||
parts[i].life = 680;
|
|
||||||
parts[i].ctype = 0x3FFFFFFF;
|
|
||||||
parts[i].vx = 3.0f*cosf(a);
|
|
||||||
parts[i].vy = 3.0f*sinf(a);
|
|
||||||
}
|
|
||||||
if (t==PT_ELEC)
|
|
||||||
{
|
|
||||||
float a = (rand()%360)*3.14159f/180.0f;
|
|
||||||
parts[i].life = 680;
|
|
||||||
parts[i].vx = 2.0f*cosf(a);
|
|
||||||
parts[i].vy = 2.0f*sinf(a);
|
|
||||||
}
|
|
||||||
if (t==PT_STKM)
|
|
||||||
{
|
|
||||||
if (player.spwn==0)
|
if (player.spwn==0)
|
||||||
{
|
{
|
||||||
parts[i].x = (float)x;
|
parts[i].x = (float)x;
|
||||||
@ -1058,9 +1046,8 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a
|
|||||||
}
|
}
|
||||||
create_part(-1,x,y,PT_SPAWN);
|
create_part(-1,x,y,PT_SPAWN);
|
||||||
ISSPAWN1 = 1;
|
ISSPAWN1 = 1;
|
||||||
}
|
break;
|
||||||
if (t==PT_STKM2)
|
case PT_STKM2:
|
||||||
{
|
|
||||||
if (player2.spwn==0)
|
if (player2.spwn==0)
|
||||||
{
|
{
|
||||||
parts[i].x = (float)x;
|
parts[i].x = (float)x;
|
||||||
@ -1084,7 +1071,13 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a
|
|||||||
}
|
}
|
||||||
create_part(-1,x,y,PT_SPAWN2);
|
create_part(-1,x,y,PT_SPAWN2);
|
||||||
ISSPAWN2 = 1;
|
ISSPAWN2 = 1;
|
||||||
}
|
break;
|
||||||
|
case PT_FIGH:
|
||||||
|
break;
|
||||||
|
case PT_BIZR: case PT_BIZRG: case PT_BIZRS:
|
||||||
|
parts[i].ctype = 0x47FFFF;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
if (t==PT_FIGH)
|
if (t==PT_FIGH)
|
||||||
{
|
{
|
||||||
unsigned char fcount = 0;
|
unsigned char fcount = 0;
|
||||||
@ -1113,8 +1106,38 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a
|
|||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (t==PT_BIZR||t==PT_BIZRG||t==PT_BIZRS)
|
if (t==PT_PHOT)
|
||||||
parts[i].ctype = 0x47FFFF;
|
{
|
||||||
|
float a = (rand()%8) * 0.78540f;
|
||||||
|
parts[i].life = 680;
|
||||||
|
parts[i].ctype = 0x3FFFFFFF;
|
||||||
|
parts[i].vx = 3.0f*cosf(a);
|
||||||
|
parts[i].vy = 3.0f*sinf(a);
|
||||||
|
}
|
||||||
|
if (t==PT_ELEC)
|
||||||
|
{
|
||||||
|
float a = (rand()%360)*3.14159f/180.0f;
|
||||||
|
parts[i].life = 680;
|
||||||
|
parts[i].vx = 2.0f*cosf(a);
|
||||||
|
parts[i].vy = 2.0f*sinf(a);
|
||||||
|
}
|
||||||
|
if (t==PT_NEUT)
|
||||||
|
{
|
||||||
|
float r = (rand()%128+128)/127.0f;
|
||||||
|
float a = (rand()%360)*3.14159f/180.0f;
|
||||||
|
parts[i].life = rand()%480+480;
|
||||||
|
parts[i].vx = r*cosf(a);
|
||||||
|
parts[i].vy = r*sinf(a);
|
||||||
|
}
|
||||||
|
if (t==PT_TRON)
|
||||||
|
{
|
||||||
|
int randhue = rand()%360;
|
||||||
|
int randomdir = rand()%4;
|
||||||
|
parts[i].tmp = 1|(randomdir<<5)|(randhue<<7);//set as a head and a direction
|
||||||
|
parts[i].tmp2 = 4;//tail
|
||||||
|
parts[i].life = 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
//and finally set the pmap/photon maps to the newly created particle
|
//and finally set the pmap/photon maps to the newly created particle
|
||||||
if (ptypes[t].properties & TYPE_ENERGY)
|
if (ptypes[t].properties & TYPE_ENERGY)
|
||||||
photons[y][x] = t|(i<<8);
|
photons[y][x] = t|(i<<8);
|
||||||
|
219
src/save.c
219
src/save.c
@ -44,11 +44,7 @@ pixel *prerender_save(void *save, int size, int *width, int *height)
|
|||||||
|
|
||||||
void *build_save(int *size, int orig_x0, int orig_y0, int orig_w, int orig_h, unsigned char bmap[YRES/CELL][XRES/CELL], float vx[YRES/CELL][XRES/CELL], float vy[YRES/CELL][XRES/CELL], float pv[YRES/CELL][XRES/CELL], float fvx[YRES/CELL][XRES/CELL], float fvy[YRES/CELL][XRES/CELL], sign signs[MAXSIGNS], void* partsptr)
|
void *build_save(int *size, int orig_x0, int orig_y0, int orig_w, int orig_h, unsigned char bmap[YRES/CELL][XRES/CELL], float vx[YRES/CELL][XRES/CELL], float vy[YRES/CELL][XRES/CELL], float pv[YRES/CELL][XRES/CELL], float fvx[YRES/CELL][XRES/CELL], float fvy[YRES/CELL][XRES/CELL], sign signs[MAXSIGNS], void* partsptr)
|
||||||
{
|
{
|
||||||
#ifdef SAVE_OPS
|
|
||||||
return build_save_OPS(size, orig_x0, orig_y0, orig_w, orig_h, bmap, vx, vy, pv, fvx, fvy, signs, partsptr);
|
return build_save_OPS(size, orig_x0, orig_y0, orig_w, orig_h, bmap, vx, vy, pv, fvx, fvy, signs, partsptr);
|
||||||
#else
|
|
||||||
return build_save_PSv(size, orig_x0, orig_y0, orig_w, orig_h, bmap, fvx, fvy, signs, partsptr);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int parse_save(void *save, int size, int replace, int x0, int y0, unsigned char bmap[YRES/CELL][XRES/CELL], float vx[YRES/CELL][XRES/CELL], float vy[YRES/CELL][XRES/CELL], float pv[YRES/CELL][XRES/CELL], float fvx[YRES/CELL][XRES/CELL], float fvy[YRES/CELL][XRES/CELL], sign signs[MAXSIGNS], void* partsptr, unsigned pmap[YRES][XRES])
|
int parse_save(void *save, int size, int replace, int x0, int y0, unsigned char bmap[YRES/CELL][XRES/CELL], float vx[YRES/CELL][XRES/CELL], float vy[YRES/CELL][XRES/CELL], float pv[YRES/CELL][XRES/CELL], float fvx[YRES/CELL][XRES/CELL], float fvy[YRES/CELL][XRES/CELL], sign signs[MAXSIGNS], void* partsptr, unsigned pmap[YRES][XRES])
|
||||||
@ -1610,221 +1606,6 @@ corrupt:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *build_save_PSv(int *size, int orig_x0, int orig_y0, int orig_w, int orig_h, unsigned char bmap[YRES/CELL][XRES/CELL], float fvx[YRES/CELL][XRES/CELL], float fvy[YRES/CELL][XRES/CELL], sign signs[MAXSIGNS], void* partsptr)
|
|
||||||
{
|
|
||||||
unsigned char *d=calloc(1,3*(XRES/CELL)*(YRES/CELL)+(XRES*YRES)*15+MAXSIGNS*262), *c;
|
|
||||||
int i,j,x,y,p=0,*m=calloc(XRES*YRES, sizeof(int));
|
|
||||||
int x0, y0, w, h, bx0=orig_x0/CELL, by0=orig_y0/CELL, bw, bh;
|
|
||||||
particle *parts = partsptr;
|
|
||||||
bw=(orig_w+orig_x0-bx0*CELL+CELL-1)/CELL;
|
|
||||||
bh=(orig_h+orig_y0-by0*CELL+CELL-1)/CELL;
|
|
||||||
|
|
||||||
// normalize coordinates
|
|
||||||
x0 = bx0*CELL;
|
|
||||||
y0 = by0*CELL;
|
|
||||||
w = bw *CELL;
|
|
||||||
h = bh *CELL;
|
|
||||||
|
|
||||||
// save the required air state
|
|
||||||
for (y=by0; y<by0+bh; y++)
|
|
||||||
for (x=bx0; x<bx0+bw; x++)
|
|
||||||
d[p++] = bmap[y][x];
|
|
||||||
for (y=by0; y<by0+bh; y++)
|
|
||||||
for (x=bx0; x<bx0+bw; x++)
|
|
||||||
if (bmap[y][x]==WL_FAN||bmap[y][x]==4)
|
|
||||||
{
|
|
||||||
i = (int)(fvx[y][x]*64.0f+127.5f);
|
|
||||||
if (i<0) i=0;
|
|
||||||
if (i>255) i=255;
|
|
||||||
d[p++] = i;
|
|
||||||
}
|
|
||||||
for (y=by0; y<by0+bh; y++)
|
|
||||||
for (x=bx0; x<bx0+bw; x++)
|
|
||||||
if (bmap[y][x]==WL_FAN||bmap[y][x]==4)
|
|
||||||
{
|
|
||||||
i = (int)(fvy[y][x]*64.0f+127.5f);
|
|
||||||
if (i<0) i=0;
|
|
||||||
if (i>255) i=255;
|
|
||||||
d[p++] = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
// save the particle map
|
|
||||||
for (i=0; i<NPART; i++)
|
|
||||||
if (parts[i].type)
|
|
||||||
{
|
|
||||||
x = (int)(parts[i].x+0.5f);
|
|
||||||
y = (int)(parts[i].y+0.5f);
|
|
||||||
if (x>=orig_x0 && x<orig_x0+orig_w && y>=orig_y0 && y<orig_y0+orig_h) {
|
|
||||||
if (!m[(x-x0)+(y-y0)*w] ||
|
|
||||||
parts[m[(x-x0)+(y-y0)*w]-1].type == PT_PHOT ||
|
|
||||||
parts[m[(x-x0)+(y-y0)*w]-1].type == PT_NEUT)
|
|
||||||
m[(x-x0)+(y-y0)*w] = i+1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (j=0; j<w*h; j++)
|
|
||||||
{
|
|
||||||
i = m[j];
|
|
||||||
if (i)
|
|
||||||
d[p++] = parts[i-1].type;
|
|
||||||
else
|
|
||||||
d[p++] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// save particle properties
|
|
||||||
for (j=0; j<w*h; j++)
|
|
||||||
{
|
|
||||||
i = m[j];
|
|
||||||
if (i)
|
|
||||||
{
|
|
||||||
i--;
|
|
||||||
x = (int)(parts[i].vx*16.0f+127.5f);
|
|
||||||
y = (int)(parts[i].vy*16.0f+127.5f);
|
|
||||||
if (x<0) x=0;
|
|
||||||
if (x>255) x=255;
|
|
||||||
if (y<0) y=0;
|
|
||||||
if (y>255) y=255;
|
|
||||||
d[p++] = x;
|
|
||||||
d[p++] = y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (j=0; j<w*h; j++)
|
|
||||||
{
|
|
||||||
i = m[j];
|
|
||||||
if (i) {
|
|
||||||
//Everybody loves a 16bit int
|
|
||||||
//d[p++] = (parts[i-1].life+3)/4;
|
|
||||||
int ttlife = (int)parts[i-1].life;
|
|
||||||
d[p++] = ((ttlife&0xFF00)>>8);
|
|
||||||
d[p++] = (ttlife&0x00FF);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (j=0; j<w*h; j++)
|
|
||||||
{
|
|
||||||
i = m[j];
|
|
||||||
if (i) {
|
|
||||||
//Now saving tmp!
|
|
||||||
//d[p++] = (parts[i-1].life+3)/4;
|
|
||||||
int tttmp = (int)parts[i-1].tmp;
|
|
||||||
d[p++] = ((tttmp&0xFF00)>>8);
|
|
||||||
d[p++] = (tttmp&0x00FF);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (j=0; j<w*h; j++)
|
|
||||||
{
|
|
||||||
i = m[j];
|
|
||||||
if (i && (parts[i-1].type==PT_PBCN || parts[i-1].type==PT_TRON)) {
|
|
||||||
//Save tmp2
|
|
||||||
d[p++] = parts[i-1].tmp2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (j=0; j<w*h; j++)
|
|
||||||
{
|
|
||||||
i = m[j];
|
|
||||||
if (i) {
|
|
||||||
//Save colour (ALPHA)
|
|
||||||
d[p++] = (parts[i-1].dcolour&0xFF000000)>>24;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (j=0; j<w*h; j++)
|
|
||||||
{
|
|
||||||
i = m[j];
|
|
||||||
if (i) {
|
|
||||||
//Save colour (RED)
|
|
||||||
d[p++] = (parts[i-1].dcolour&0x00FF0000)>>16;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (j=0; j<w*h; j++)
|
|
||||||
{
|
|
||||||
i = m[j];
|
|
||||||
if (i) {
|
|
||||||
//Save colour (GREEN)
|
|
||||||
d[p++] = (parts[i-1].dcolour&0x0000FF00)>>8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (j=0; j<w*h; j++)
|
|
||||||
{
|
|
||||||
i = m[j];
|
|
||||||
if (i) {
|
|
||||||
//Save colour (BLUE)
|
|
||||||
d[p++] = (parts[i-1].dcolour&0x000000FF);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (j=0; j<w*h; j++)
|
|
||||||
{
|
|
||||||
i = m[j];
|
|
||||||
if (i)
|
|
||||||
{
|
|
||||||
//New Temperature saving uses a 16bit unsigned int for temperatures, giving a precision of 1 degree versus 36 for the old format
|
|
||||||
int tttemp = (int)parts[i-1].temp;
|
|
||||||
d[p++] = ((tttemp&0xFF00)>>8);
|
|
||||||
d[p++] = (tttemp&0x00FF);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (j=0; j<w*h; j++)
|
|
||||||
{
|
|
||||||
i = m[j];
|
|
||||||
if (i && (parts[i-1].type==PT_CLNE || parts[i-1].type==PT_PCLN || parts[i-1].type==PT_BCLN || parts[i-1].type==PT_SPRK || parts[i-1].type==PT_LAVA || parts[i-1].type==PT_PIPE || parts[i-1].type==PT_LIFE || parts[i-1].type==PT_PBCN || parts[i-1].type==PT_WIRE || parts[i-1].type==PT_STOR || parts[i-1].type==PT_CONV))
|
|
||||||
d[p++] = parts[i-1].ctype;
|
|
||||||
}
|
|
||||||
|
|
||||||
j = 0;
|
|
||||||
for (i=0; i<MAXSIGNS; i++)
|
|
||||||
if (signs[i].text[0] &&
|
|
||||||
signs[i].x>=orig_x0 && signs[i].x<orig_x0+orig_w &&
|
|
||||||
signs[i].y>=orig_y0 && signs[i].y<orig_y0+orig_h)
|
|
||||||
j++;
|
|
||||||
d[p++] = j;
|
|
||||||
for (i=0; i<MAXSIGNS; i++)
|
|
||||||
if (signs[i].text[0] &&
|
|
||||||
signs[i].x>=orig_x0 && signs[i].x<orig_x0+orig_w &&
|
|
||||||
signs[i].y>=orig_y0 && signs[i].y<orig_y0+orig_h)
|
|
||||||
{
|
|
||||||
d[p++] = (signs[i].x-x0);
|
|
||||||
d[p++] = (signs[i].x-x0)>>8;
|
|
||||||
d[p++] = (signs[i].y-y0);
|
|
||||||
d[p++] = (signs[i].y-y0)>>8;
|
|
||||||
d[p++] = signs[i].ju;
|
|
||||||
x = strlen(signs[i].text);
|
|
||||||
d[p++] = x;
|
|
||||||
memcpy(d+p, signs[i].text, x);
|
|
||||||
p+=x;
|
|
||||||
}
|
|
||||||
|
|
||||||
i = (p*101+99)/100 + 612;
|
|
||||||
c = malloc(i);
|
|
||||||
|
|
||||||
//New file header uses PSv, replacing fuC. This is to detect if the client uses a new save format for temperatures
|
|
||||||
//This creates a problem for old clients, that display and "corrupt" error instead of a "newer version" error
|
|
||||||
|
|
||||||
c[0] = 0x50; //0x66;
|
|
||||||
c[1] = 0x53; //0x75;
|
|
||||||
c[2] = 0x76; //0x43;
|
|
||||||
c[3] = legacy_enable|((sys_pause<<1)&0x02)|((gravityMode<<2)&0x0C)|((airMode<<4)&0x70)|((ngrav_enable<<7)&0x80);
|
|
||||||
c[4] = SAVE_VERSION;
|
|
||||||
c[5] = CELL;
|
|
||||||
c[6] = bw;
|
|
||||||
c[7] = bh;
|
|
||||||
c[8] = p;
|
|
||||||
c[9] = p >> 8;
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
free(d);
|
|
||||||
free(c);
|
|
||||||
free(m);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
free(d);
|
|
||||||
free(m);
|
|
||||||
|
|
||||||
*size = i+12;
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
int parse_save_PSv(void *save, int size, int replace, int x0, int y0, unsigned char bmap[YRES/CELL][XRES/CELL], float fvx[YRES/CELL][XRES/CELL], float fvy[YRES/CELL][XRES/CELL], sign signs[MAXSIGNS], void* partsptr, unsigned pmap[YRES][XRES])
|
int parse_save_PSv(void *save, int size, int replace, int x0, int y0, unsigned char bmap[YRES/CELL][XRES/CELL], float fvx[YRES/CELL][XRES/CELL], float fvy[YRES/CELL][XRES/CELL], sign signs[MAXSIGNS], void* partsptr, unsigned pmap[YRES][XRES])
|
||||||
{
|
{
|
||||||
unsigned char *d=NULL,*c=save;
|
unsigned char *d=NULL,*c=save;
|
||||||
|
Loading…
Reference in New Issue
Block a user