Pass decorations to saving functions (doesn't actually save yet)
This commit is contained in:
parent
cbfc73d8d6
commit
7fe99f3210
@ -187,7 +187,7 @@ extern int sys_pause;
|
|||||||
extern int sys_shortcuts;
|
extern int sys_shortcuts;
|
||||||
extern int legacy_enable; //Used to disable new features such as heat, will be set by commandline or save.
|
extern int legacy_enable; //Used to disable new features such as heat, will be set by commandline or save.
|
||||||
extern int death, death2, framerender;
|
extern int death, death2, framerender;
|
||||||
extern pixel *vid_buf;
|
extern pixel *vid_buf, *decorations;
|
||||||
|
|
||||||
extern unsigned char last_major, last_minor, update_flag;
|
extern unsigned char last_major, last_minor, update_flag;
|
||||||
|
|
||||||
@ -198,8 +198,8 @@ void thumb_cache_inval(char *id);
|
|||||||
void thumb_cache_add(char *id, void *thumb, int size);
|
void thumb_cache_add(char *id, void *thumb, int size);
|
||||||
int thumb_cache_find(char *id, void **thumb, int *size);
|
int thumb_cache_find(char *id, void **thumb, int *size);
|
||||||
void *build_thumb(int *size, int bzip2);
|
void *build_thumb(int *size, int bzip2);
|
||||||
void *build_save(int *size, int x0, int y0, int w, int 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);
|
void *build_save(int *size, int x0, int y0, int w, int 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, pixel *decorations);
|
||||||
int parse_save(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(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], pixel *decorations);
|
||||||
void clear_sim(void);
|
void clear_sim(void);
|
||||||
void del_stamp(int d);
|
void del_stamp(int d);
|
||||||
void sdl_seticon(void);
|
void sdl_seticon(void);
|
||||||
|
@ -3244,7 +3244,7 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
|
|||||||
if (queue_open) {
|
if (queue_open) {
|
||||||
if (info_ready && data_ready) {
|
if (info_ready && data_ready) {
|
||||||
// Do Open!
|
// Do Open!
|
||||||
status = parse_save(data, data_size, 1, 0, 0, bmap, fvx, fvy, signs, parts, pmap);
|
status = parse_save(data, data_size, 1, 0, 0, bmap, fvx, fvy, signs, parts, pmap, decorations);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
//if(svf_last)
|
//if(svf_last)
|
||||||
//free(svf_last);
|
//free(svf_last);
|
||||||
@ -3765,7 +3765,7 @@ void execute_save(pixel *vid_buf)
|
|||||||
plens[0] = strlen(svf_name);
|
plens[0] = strlen(svf_name);
|
||||||
uploadparts[1] = svf_description;
|
uploadparts[1] = svf_description;
|
||||||
plens[1] = strlen(svf_description);
|
plens[1] = strlen(svf_description);
|
||||||
uploadparts[2] = build_save(plens+2, 0, 0, XRES, YRES, bmap, fvx, fvy, signs, parts);
|
uploadparts[2] = build_save(plens+2, 0, 0, XRES, YRES, bmap, fvx, fvy, signs, parts, decorations);
|
||||||
uploadparts[3] = build_thumb(plens+3, 1);
|
uploadparts[3] = build_thumb(plens+3, 1);
|
||||||
uploadparts[4] = (svf_publish==1)?"Public":"Private";
|
uploadparts[4] = (svf_publish==1)?"Public":"Private";
|
||||||
plens[4] = strlen((svf_publish==1)?"Public":"Private");
|
plens[4] = strlen((svf_publish==1)?"Public":"Private");
|
||||||
|
24
src/main.c
24
src/main.c
@ -59,7 +59,7 @@
|
|||||||
#include "pyconsole.h"
|
#include "pyconsole.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pixel *vid_buf;
|
pixel *vid_buf, *decorations;
|
||||||
|
|
||||||
#define NUM_SOUNDS 2
|
#define NUM_SOUNDS 2
|
||||||
struct sample {
|
struct sample {
|
||||||
@ -317,7 +317,7 @@ void *build_thumb(int *size, int bzip2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//the saving function
|
//the saving function
|
||||||
void *build_save(int *size, int x0, int y0, int w, int 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)
|
void *build_save(int *size, int x0, int y0, int w, int 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, pixel *decorations)
|
||||||
{
|
{
|
||||||
unsigned char *d=calloc(1,3*(XRES/CELL)*(YRES/CELL)+(XRES*YRES)*11+MAXSIGNS*262), *c;
|
unsigned char *d=calloc(1,3*(XRES/CELL)*(YRES/CELL)+(XRES*YRES)*11+MAXSIGNS*262), *c;
|
||||||
int i,j,x,y,p=0,*m=calloc(XRES*YRES, sizeof(int));
|
int i,j,x,y,p=0,*m=calloc(XRES*YRES, sizeof(int));
|
||||||
@ -490,7 +490,7 @@ void *build_save(int *size, int x0, int y0, int w, int h, unsigned char bmap[YRE
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
int parse_save(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(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], pixel *decorations)
|
||||||
{
|
{
|
||||||
unsigned char *d=NULL,*c=save;
|
unsigned char *d=NULL,*c=save;
|
||||||
int q,i,j,k,x,y,p=0,*m=NULL, ver, pty, ty, legacy_beta=0;
|
int q,i,j,k,x,y,p=0,*m=NULL, ver, pty, ty, legacy_beta=0;
|
||||||
@ -578,6 +578,7 @@ int parse_save(void *save, int size, int replace, int x0, int y0, unsigned char
|
|||||||
}
|
}
|
||||||
clear_sim();
|
clear_sim();
|
||||||
}
|
}
|
||||||
|
clearrect(decorations, x0, y0, w, h);
|
||||||
m = calloc(XRES*YRES, sizeof(int));
|
m = calloc(XRES*YRES, sizeof(int));
|
||||||
|
|
||||||
// make a catalog of free parts
|
// make a catalog of free parts
|
||||||
@ -1031,7 +1032,7 @@ void stamp_save(int x, int y, int w, int h)
|
|||||||
FILE *f;
|
FILE *f;
|
||||||
int n;
|
int n;
|
||||||
char fn[64], sn[16];
|
char fn[64], sn[16];
|
||||||
void *s=build_save(&n, x, y, w, h, bmap, fvx, fvy, signs, parts);
|
void *s=build_save(&n, x, y, w, h, bmap, fvx, fvy, signs, parts, decorations);
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
_mkdir("stamps");
|
_mkdir("stamps");
|
||||||
@ -1305,8 +1306,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if(load_data && load_size){
|
if(load_data && load_size){
|
||||||
int parsestate = 0;
|
int parsestate = 0;
|
||||||
//parsestate = parse_save(load_data, load_size, 1, 0, 0);
|
parsestate = parse_save(load_data, load_size, 1, 0, 0, bmap, fvx, fvy, signs, parts, pmap, decorations);
|
||||||
parsestate = parse_save(load_data, load_size, 1, 0, 0, bmap, fvx, fvy, signs, parts, pmap);
|
|
||||||
|
|
||||||
for(i=0; i<30; i++){
|
for(i=0; i<30; i++){
|
||||||
memset(vid_buf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
|
memset(vid_buf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
|
||||||
@ -1377,7 +1377,7 @@ int main(int argc, char *argv[])
|
|||||||
PyObject *pname,*pmodule,*pfunc,*pvalue,*pargs,*pstep,*pkey;
|
PyObject *pname,*pmodule,*pfunc,*pvalue,*pargs,*pstep,*pkey;
|
||||||
PyObject *tpt_console_obj;
|
PyObject *tpt_console_obj;
|
||||||
#endif
|
#endif
|
||||||
pixel *decorations = calloc((XRES+BARSIZE)*YRES, PIXELSIZE);
|
decorations = calloc((XRES+BARSIZE)*YRES, PIXELSIZE);
|
||||||
vid_buf = calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE);
|
vid_buf = calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE);
|
||||||
pers_bg = calloc((XRES+BARSIZE)*YRES, PIXELSIZE);
|
pers_bg = calloc((XRES+BARSIZE)*YRES, PIXELSIZE);
|
||||||
GSPEED = 1;
|
GSPEED = 1;
|
||||||
@ -1532,7 +1532,7 @@ int main(int argc, char *argv[])
|
|||||||
if (file_data)
|
if (file_data)
|
||||||
{
|
{
|
||||||
it=0;
|
it=0;
|
||||||
parse_save(file_data, size, 0, 0, 0, bmap, fvx, fvy, signs, parts, pmap);
|
parse_save(file_data, size, 0, 0, 0, bmap, fvx, fvy, signs, parts, pmap, decorations);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2493,7 +2493,7 @@ int main(int argc, char *argv[])
|
|||||||
if (load_y<0) load_y=0;
|
if (load_y<0) load_y=0;
|
||||||
if (bq==1 && !b)
|
if (bq==1 && !b)
|
||||||
{
|
{
|
||||||
parse_save(load_data, load_size, 0, load_x, load_y, bmap, fvx, fvy, signs, parts, pmap);
|
parse_save(load_data, load_size, 0, load_x, load_y, bmap, fvx, fvy, signs, parts, pmap, decorations);
|
||||||
free(load_data);
|
free(load_data);
|
||||||
free(load_img);
|
free(load_img);
|
||||||
load_mode = 0;
|
load_mode = 0;
|
||||||
@ -2535,14 +2535,14 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
if (copy_mode==1)//CTRL-C, copy
|
if (copy_mode==1)//CTRL-C, copy
|
||||||
{
|
{
|
||||||
clipboard_data=build_save(&clipboard_length, save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL, bmap, fvx, fvy, signs, parts);
|
clipboard_data=build_save(&clipboard_length, save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL, bmap, fvx, fvy, signs, parts, decorations);
|
||||||
clipboard_ready = 1;
|
clipboard_ready = 1;
|
||||||
save_mode = 0;
|
save_mode = 0;
|
||||||
copy_mode = 0;
|
copy_mode = 0;
|
||||||
}
|
}
|
||||||
else if (copy_mode==2)//CTRL-X, cut
|
else if (copy_mode==2)//CTRL-X, cut
|
||||||
{
|
{
|
||||||
clipboard_data=build_save(&clipboard_length, save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL, bmap, fvx, fvy, signs, parts);
|
clipboard_data=build_save(&clipboard_length, save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL, bmap, fvx, fvy, signs, parts, decorations);
|
||||||
clipboard_ready = 1;
|
clipboard_ready = 1;
|
||||||
save_mode = 0;
|
save_mode = 0;
|
||||||
copy_mode = 0;
|
copy_mode = 0;
|
||||||
@ -2669,7 +2669,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
if (x>=19 && x<=35 && svf_last && svf_open && !bq) {
|
if (x>=19 && x<=35 && svf_last && svf_open && !bq) {
|
||||||
//int tpval = sys_pause;
|
//int tpval = sys_pause;
|
||||||
parse_save(svf_last, svf_lsize, 1, 0, 0, bmap, fvx, fvy, signs, parts, pmap);
|
parse_save(svf_last, svf_lsize, 1, 0, 0, bmap, fvx, fvy, signs, parts, pmap, decorations);
|
||||||
//sys_pause = tpval;
|
//sys_pause = tpval;
|
||||||
}
|
}
|
||||||
if (x>=(XRES+BARSIZE-(510-476)) && x<=(XRES+BARSIZE-(510-491)) && !bq)
|
if (x>=(XRES+BARSIZE-(510-476)) && x<=(XRES+BARSIZE-(510-491)) && !bq)
|
||||||
|
34
src/powder.c
34
src/powder.c
@ -2542,11 +2542,14 @@ void *transform_save(void *odata, int *size, matrix2d transform, vector2d transl
|
|||||||
float (*fvyo)[XRES/CELL] = calloc((YRES/CELL)*(XRES/CELL), sizeof(float));
|
float (*fvyo)[XRES/CELL] = calloc((YRES/CELL)*(XRES/CELL), sizeof(float));
|
||||||
float (*fvxn)[XRES/CELL] = calloc((YRES/CELL)*(XRES/CELL), sizeof(float));
|
float (*fvxn)[XRES/CELL] = calloc((YRES/CELL)*(XRES/CELL), sizeof(float));
|
||||||
float (*fvyn)[XRES/CELL] = calloc((YRES/CELL)*(XRES/CELL), sizeof(float));
|
float (*fvyn)[XRES/CELL] = calloc((YRES/CELL)*(XRES/CELL), sizeof(float));
|
||||||
|
pixel *decorationso = calloc((XRES+BARSIZE)*YRES, PIXELSIZE);
|
||||||
|
pixel *decorationsn = calloc((XRES+BARSIZE)*YRES, PIXELSIZE);
|
||||||
int i, x, y, nx, ny, w, h, nw, nh;
|
int i, x, y, nx, ny, w, h, nw, nh;
|
||||||
|
pixel px;
|
||||||
vector2d pos, tmp, ctl, cbr;
|
vector2d pos, tmp, ctl, cbr;
|
||||||
vector2d cornerso[4];
|
vector2d cornerso[4];
|
||||||
unsigned char *odatac = odata;
|
unsigned char *odatac = odata;
|
||||||
if (parse_save(odata, *size, 0, 0, 0, bmapo, fvxo, fvyo, signst, partst, pmapt))
|
if (parse_save(odata, *size, 0, 0, 0, bmapo, fvxo, fvyo, signst, partst, pmapt, decorationso))
|
||||||
{
|
{
|
||||||
free(bmapo);
|
free(bmapo);
|
||||||
free(bmapn);
|
free(bmapn);
|
||||||
@ -2557,6 +2560,8 @@ void *transform_save(void *odata, int *size, matrix2d transform, vector2d transl
|
|||||||
free(fvyo);
|
free(fvyo);
|
||||||
free(fvxn);
|
free(fvxn);
|
||||||
free(fvyn);
|
free(fvyn);
|
||||||
|
free(decorationso);
|
||||||
|
free(decorationsn);
|
||||||
return odata;
|
return odata;
|
||||||
}
|
}
|
||||||
w = odatac[6]*CELL;
|
w = odatac[6]*CELL;
|
||||||
@ -2613,26 +2618,21 @@ void *transform_save(void *odata, int *size, matrix2d transform, vector2d transl
|
|||||||
partst[i].x = nx;
|
partst[i].x = nx;
|
||||||
partst[i].y = ny;
|
partst[i].y = ny;
|
||||||
}
|
}
|
||||||
for (y=0; y<YRES/CELL; y++)
|
for (y=0; y<h; y++)
|
||||||
for (x=0; x<XRES/CELL; x++)
|
for (x=0; x<w; x++)
|
||||||
{
|
{
|
||||||
pos = v2d_new(x*CELL+CELL*0.4f, y*CELL+CELL*0.4f);
|
px = decorationso[y*(XRES+BARSIZE)+x];
|
||||||
|
if (!PIXR(px) && !PIXG(px) && !PIXB(px))
|
||||||
|
continue;
|
||||||
|
pos = v2d_new(x, y);
|
||||||
pos = v2d_add(m2d_multiply_v2d(transform,pos),translate);
|
pos = v2d_add(m2d_multiply_v2d(transform,pos),translate);
|
||||||
nx = pos.x/CELL;
|
nx = floor(pos.x+0.5f);
|
||||||
ny = pos.y/CELL;
|
ny = floor(pos.y+0.5f);
|
||||||
if (nx<0 || nx>=nw || ny<0 || ny>=nh)
|
if (nx<0 || nx>=nw || ny<0 || ny>=nh)
|
||||||
continue;
|
continue;
|
||||||
if (bmapo[y][x])
|
decorationsn[ny*(XRES+BARSIZE)+nx] = px;
|
||||||
{
|
|
||||||
bmapn[ny][nx] = bmapo[y][x];
|
|
||||||
if (bmapo[y][x]==WL_FAN)
|
|
||||||
{
|
|
||||||
fvxn[ny][nx] = fvxo[y][x];
|
|
||||||
fvyn[ny][nx] = fvyo[y][x];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ndata = build_save(size,0,0,nw,nh,bmapn,fvxn,fvyn,signst,partst);
|
ndata = build_save(size,0,0,nw,nh,bmapn,fvxn,fvyn,signst,partst,decorationsn);
|
||||||
free(bmapo);
|
free(bmapo);
|
||||||
free(bmapn);
|
free(bmapn);
|
||||||
free(partst);
|
free(partst);
|
||||||
@ -2642,6 +2642,8 @@ void *transform_save(void *odata, int *size, matrix2d transform, vector2d transl
|
|||||||
free(fvyo);
|
free(fvyo);
|
||||||
free(fvxn);
|
free(fvxn);
|
||||||
free(fvyn);
|
free(fvyn);
|
||||||
|
free(decorationso);
|
||||||
|
free(decorationsn);
|
||||||
return ndata;
|
return ndata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user