This commit is contained in:
Felix Wallin 2010-09-18 09:52:14 +02:00
parent fa099338bb
commit 99ae022d55
5 changed files with 112 additions and 112 deletions

View File

@ -2121,9 +2121,9 @@ pixel *prerender_save(void *save, int size, int *width, int *height)
return NULL; return NULL;
if(!(c[2]==0x43 && c[1]==0x75 && c[0]==0x66) && !(c[2]==0x76 && c[1]==0x53 && c[0]==0x50)) if(!(c[2]==0x43 && c[1]==0x75 && c[0]==0x66) && !(c[2]==0x76 && c[1]==0x53 && c[0]==0x50))
return NULL; return NULL;
if(c[2]==0x43 && c[1]==0x75 && c[0]==0x66){ if(c[2]==0x43 && c[1]==0x75 && c[0]==0x66) {
new_format = 1; new_format = 1;
} }
if(c[4]>SAVE_VERSION) if(c[4]>SAVE_VERSION)
return NULL; return NULL;

View File

@ -1789,7 +1789,7 @@ int search_ui(pixel *vid_buf)
memset(img_id, 0, sizeof(img_id)); memset(img_id, 0, sizeof(img_id));
memset(search_ids, 0, sizeof(search_ids)); memset(search_ids, 0, sizeof(search_ids));
memset(search_dates, 0, sizeof(search_dates)); memset(search_dates, 0, sizeof(search_dates));
memset(search_names, 0, sizeof(search_names)); memset(search_names, 0, sizeof(search_names));
memset(search_scoreup, 0, sizeof(search_scoreup)); memset(search_scoreup, 0, sizeof(search_scoreup));
memset(search_scoredown, 0, sizeof(search_scoredown)); memset(search_scoredown, 0, sizeof(search_scoredown));
@ -2004,8 +2004,8 @@ int search_ui(pixel *vid_buf)
dp = pos; dp = pos;
} }
} }
drawrect(vid_buf, gx-2+(XRES/GRID_S)+5, gy-2, 6, YRES/GRID_S+3, 128, 128, 128, 255); drawrect(vid_buf, gx-2+(XRES/GRID_S)+5, gy-2, 6, YRES/GRID_S+3, 128, 128, 128, 255);
fillrect(vid_buf, gx-2+(XRES/GRID_S)+5, gy-2, 6, 1+(YRES/GRID_S+3)/2, 0, 107, 10, 255); fillrect(vid_buf, gx-2+(XRES/GRID_S)+5, gy-2, 6, 1+(YRES/GRID_S+3)/2, 0, 107, 10, 255);
fillrect(vid_buf, gx-2+(XRES/GRID_S)+5, gy-2+((YRES/GRID_S+3)/2), 6, 1+(YRES/GRID_S+3)/2, 107, 10, 0, 255); fillrect(vid_buf, gx-2+(XRES/GRID_S)+5, gy-2+((YRES/GRID_S+3)/2), 6, 1+(YRES/GRID_S+3)/2, 107, 10, 0, 255);
if(mp==pos && !st) if(mp==pos && !st)
@ -2069,7 +2069,7 @@ int search_ui(pixel *vid_buf)
fillrect(vid_buf, gx-1+(XRES/GRID_S)+5, gy-1+((YRES/GRID_S+3)/2)-nyu, 4, nyu, 57, 187, 57, 255); fillrect(vid_buf, gx-1+(XRES/GRID_S)+5, gy-1+((YRES/GRID_S+3)/2)-nyu, 4, nyu, 57, 187, 57, 255);
fillrect(vid_buf, gx-1+(XRES/GRID_S)+5, gy-2+((YRES/GRID_S+3)/2), 4, nyd, 187, 57, 57, 255); fillrect(vid_buf, gx-1+(XRES/GRID_S)+5, gy-2+((YRES/GRID_S+3)/2), 4, nyd, 187, 57, 57, 255);
//drawrect(vid_buf, gx-2+(XRES/GRID_S)+5, gy-2+((YRES/GRID_S+3)/2)-nyu, 4, nyu, 0, 107, 10, 255); //drawrect(vid_buf, gx-2+(XRES/GRID_S)+5, gy-2+((YRES/GRID_S+3)/2)-nyu, 4, nyu, 0, 107, 10, 255);
//drawrect(vid_buf, gx-2+(XRES/GRID_S)+5, gy-2+((YRES/GRID_S+3)/2)+1, 4, nyd, 107, 10, 0, 255); //drawrect(vid_buf, gx-2+(XRES/GRID_S)+5, gy-2+((YRES/GRID_S+3)/2)+1, 4, nyd, 107, 10, 0, 255);
} }
} }
@ -2162,17 +2162,17 @@ int search_ui(pixel *vid_buf)
fillrect(vid_buf, 0, 0, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 255); fillrect(vid_buf, 0, 0, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 255);
info_box(vid_buf, "Loading..."); info_box(vid_buf, "Loading...");
if(search_dates[mp]){ if(search_dates[mp]) {
uri = malloc(strlen(search_ids[mp])*3+strlen(search_dates[mp])*3+strlen(SERVER)+71); uri = malloc(strlen(search_ids[mp])*3+strlen(search_dates[mp])*3+strlen(SERVER)+71);
strcpy(uri, "http://" SERVER "/Get.api?Op=save&ID="); strcpy(uri, "http://" SERVER "/Get.api?Op=save&ID=");
strcaturl(uri, search_ids[mp]); strcaturl(uri, search_ids[mp]);
strappend(uri, "&Date="); strappend(uri, "&Date=");
strcaturl(uri, search_dates[mp]); strcaturl(uri, search_dates[mp]);
} else { } else {
uri = malloc(strlen(search_ids[mp])*3+strlen(SERVER)+64); uri = malloc(strlen(search_ids[mp])*3+strlen(SERVER)+64);
strcpy(uri, "http://" SERVER "/Get.api?Op=save&ID="); strcpy(uri, "http://" SERVER "/Get.api?Op=save&ID=");
strcaturl(uri, search_ids[mp]); strcaturl(uri, search_ids[mp]);
} }
data = http_simple_get(uri, &status, &dlen); data = http_simple_get(uri, &status, &dlen);
free(uri); free(uri);
@ -2384,22 +2384,22 @@ int search_ui(pixel *vid_buf)
thlen = 4; thlen = 4;
} }
thumb_cache_add(img_id[i], thumb, thlen); thumb_cache_add(img_id[i], thumb, thlen);
for(pos=0; pos<GRID_X*GRID_Y; pos++){ for(pos=0; pos<GRID_X*GRID_Y; pos++) {
if(search_dates[pos]){ if(search_dates[pos]) {
char *id_d_temp = malloc(strlen(search_ids[pos])+strlen(search_dates[pos])+1); char *id_d_temp = malloc(strlen(search_ids[pos])+strlen(search_dates[pos])+1);
strcpy(id_d_temp, search_ids[pos]); strcpy(id_d_temp, search_ids[pos]);
strappend(id_d_temp, "_"); strappend(id_d_temp, "_");
strappend(id_d_temp, search_dates[pos]); strappend(id_d_temp, search_dates[pos]);
//img_id[i] = mystrdup(id_d_temp); //img_id[i] = mystrdup(id_d_temp);
if(id_d_temp && !strcmp(id_d_temp, img_id[i])){ if(id_d_temp && !strcmp(id_d_temp, img_id[i])) {
break; break;
} }
} else { } else {
if(search_ids[pos] && !strcmp(search_ids[pos], img_id[i])){ if(search_ids[pos] && !strcmp(search_ids[pos], img_id[i])) {
break; break;
} }
} }
} }
if(pos<GRID_X*GRID_Y) if(pos<GRID_X*GRID_Y)
{ {
search_thumbs[pos] = thumb; search_thumbs[pos] = thumb;
@ -2424,24 +2424,24 @@ int search_ui(pixel *vid_buf)
} }
if(pos<GRID_X*GRID_Y) if(pos<GRID_X*GRID_Y)
{ {
if(search_dates[pos]){ if(search_dates[pos]) {
char *id_d_temp = malloc(strlen(search_ids[pos])+strlen(search_dates[pos])+1); char *id_d_temp = malloc(strlen(search_ids[pos])+strlen(search_dates[pos])+1);
uri = malloc(strlen(search_ids[pos])*3+strlen(search_dates[pos])*3+strlen(SERVER)+71); uri = malloc(strlen(search_ids[pos])*3+strlen(search_dates[pos])*3+strlen(SERVER)+71);
strcpy(uri, "http://" SERVER "/Get.api?Op=thumb&ID="); strcpy(uri, "http://" SERVER "/Get.api?Op=thumb&ID=");
strcaturl(uri, search_ids[pos]); strcaturl(uri, search_ids[pos]);
strappend(uri, "&Date="); strappend(uri, "&Date=");
strcaturl(uri, search_dates[pos]); strcaturl(uri, search_dates[pos]);
strcpy(id_d_temp, search_ids[pos]); strcpy(id_d_temp, search_ids[pos]);
strappend(id_d_temp, "_"); strappend(id_d_temp, "_");
strappend(id_d_temp, search_dates[pos]); strappend(id_d_temp, search_dates[pos]);
img_id[i] = mystrdup(id_d_temp); img_id[i] = mystrdup(id_d_temp);
} else { } else {
uri = malloc(strlen(search_ids[pos])*3+strlen(SERVER)+64); uri = malloc(strlen(search_ids[pos])*3+strlen(SERVER)+64);
strcpy(uri, "http://" SERVER "/Get.api?Op=thumb&ID="); strcpy(uri, "http://" SERVER "/Get.api?Op=thumb&ID=");
strcaturl(uri, search_ids[pos]); strcaturl(uri, search_ids[pos]);
img_id[i] = mystrdup(search_ids[pos]); img_id[i] = mystrdup(search_ids[pos]);
} }
img_http[i] = http_async_req_start(img_http[i], uri, NULL, 0, 1); img_http[i] = http_async_req_start(img_http[i], uri, NULL, 0, 1);
free(uri); free(uri);
@ -2484,7 +2484,7 @@ int search_results(char *str, int votes)
if(search_ids[i]) if(search_ids[i])
{ {
free(search_ids[i]); free(search_ids[i]);
search_ids[i] = NULL; search_ids[i] = NULL;
} }
if(search_names[i]) if(search_names[i])
{ {
@ -2593,17 +2593,17 @@ int search_results(char *str, int votes)
thumb_cache_find(str+5, search_thumbs+i, search_thsizes+i); thumb_cache_find(str+5, search_thumbs+i, search_thsizes+i);
i++; i++;
} }
else if(!strncmp(str, "HISTORY ", 8)) else if(!strncmp(str, "HISTORY ", 8))
{ {
if(i>=GRID_X*GRID_Y) if(i>=GRID_X*GRID_Y)
break; break;
if(votes) if(votes)
{ {
sd = strchr(str+8, ' '); sd = strchr(str+8, ' ');
if(!sd) if(!sd)
return i; return i;
*(sd++) = 0; *(sd++) = 0;
pu = strchr(sd, ' '); pu = strchr(sd, ' ');
if(!pu) if(!pu)
return i; return i;
*(pu++) = 0; *(pu++) = 0;
@ -2624,10 +2624,10 @@ int search_results(char *str, int votes)
else else
{ {
sd = strchr(str+8, ' '); sd = strchr(str+8, ' ');
if(!sd) if(!sd)
return i; return i;
*(sd++) = 0; *(sd++) = 0;
pu = strchr(sd, ' '); pu = strchr(sd, ' ');
if(!pu) if(!pu)
return i; return i;
*(pu++) = 0; *(pu++) = 0;
@ -2650,7 +2650,7 @@ int search_results(char *str, int votes)
*(r++) = 0; *(r++) = 0;
search_ids[i] = mystrdup(str+8); search_ids[i] = mystrdup(str+8);
search_dates[i] = mystrdup(sd); search_dates[i] = mystrdup(sd);
search_publish[i] = atoi(pu); search_publish[i] = atoi(pu);
search_scoreup[i] = atoi(vu); search_scoreup[i] = atoi(vu);

70
main.c
View File

@ -310,10 +310,10 @@ void *build_save(int *size, int x0, int y0, int w, int h)
i = m[j]; i = m[j];
if(i) if(i)
{ {
//New Temperature saving uses a 16bit unsigned int for temperatures, giving a precision of 1 degree versus 36 for the old format //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; int tttemp = (int)parts[i-1].temp;
d[p++] = ((tttemp&0xFF00)>>8); d[p++] = ((tttemp&0xFF00)>>8);
d[p++] = (tttemp&0x00FF); d[p++] = (tttemp&0x00FF);
} }
} }
for(j=0; j<w*h; j++) for(j=0; j<w*h; j++)
@ -349,8 +349,8 @@ void *build_save(int *size, int x0, int y0, int w, int h)
i = (p*101+99)/100 + 612; i = (p*101+99)/100 + 612;
c = malloc(i); c = malloc(i);
//New file header uses PSv, replacing fuC. This is to detect if the client uses a new save format for temperatures //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 //This creates a problem for old clients, that display and "corrupt" error instead of a "newer version" error
c[0] = 0x50; //0x66; c[0] = 0x50; //0x66;
c[1] = 0x53; //0x75; c[1] = 0x53; //0x75;
@ -386,16 +386,16 @@ int parse_save(void *save, int size, int replace, int x0, int y0)
int bx0=x0/CELL, by0=y0/CELL, bw, bh, w, h; int bx0=x0/CELL, by0=y0/CELL, bw, bh, w, h;
int fp[NPART], nf=0, new_format = 0, ttv = 0; int fp[NPART], nf=0, new_format = 0, ttv = 0;
//New file header uses PSv, replacing fuC. This is to detect if the client uses a new save format for temperatures //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 //This creates a problem for old clients, that display and "corrupt" error instead of a "newer version" error
if(size<16) if(size<16)
return 1; return 1;
if(!(c[2]==0x43 && c[1]==0x75 && c[0]==0x66) && !(c[2]==0x76 && c[1]==0x53 && c[0]==0x50)) if(!(c[2]==0x43 && c[1]==0x75 && c[0]==0x66) && !(c[2]==0x76 && c[1]==0x53 && c[0]==0x50))
return 1; return 1;
if(c[2]==0x76 && c[1]==0x53 && c[0]==0x50){ if(c[2]==0x76 && c[1]==0x53 && c[0]==0x50) {
new_format = 1; new_format = 1;
} }
if(c[4]>SAVE_VERSION) if(c[4]>SAVE_VERSION)
return 2; return 2;
ver = c[4]; ver = c[4];
@ -600,13 +600,13 @@ int parse_save(void *save, int size, int replace, int x0, int y0)
if(i <= NPART) if(i <= NPART)
{ {
if(ver>=42) { if(ver>=42) {
if(new_format){ if(new_format) {
ttv = (d[p++])<<8; ttv = (d[p++])<<8;
ttv |= (d[p++]); ttv |= (d[p++]);
parts[i-1].temp = ttv; parts[i-1].temp = ttv;
} else { } else {
parts[i-1].temp = (d[p++]*((MAX_TEMP+(-MIN_TEMP))/255))+MIN_TEMP; parts[i-1].temp = (d[p++]*((MAX_TEMP+(-MIN_TEMP))/255))+MIN_TEMP;
} }
} else { } 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;
} }
@ -614,9 +614,9 @@ int parse_save(void *save, int size, int replace, int x0, int y0)
else else
{ {
p++; p++;
if(new_format){ if(new_format) {
p++; p++;
} }
} }
} }
else else
@ -1253,8 +1253,8 @@ int main(int argc, char *argv[])
{ {
set_cmode(6); set_cmode(6);
} }
if(sdl_key==SDLK_LEFTBRACKET){ if(sdl_key==SDLK_LEFTBRACKET) {
if(sdl_zoom_trig==1) if(sdl_zoom_trig==1)
{ {
ZSIZE -= 1; ZSIZE -= 1;
if(ZSIZE>32) if(ZSIZE>32)
@ -1265,18 +1265,18 @@ int main(int argc, char *argv[])
} }
else else
{ {
if(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)) if(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))
bs -= 1; bs -= 1;
else else
bs -= ceil((bs/5)+0.5f); bs -= ceil((bs/5)+0.5f);
if(bs>1224) if(bs>1224)
bs = 1224; bs = 1224;
if(bs<0) if(bs<0)
bs = 0; bs = 0;
} }
} }
if(sdl_key==SDLK_RIGHTBRACKET){ if(sdl_key==SDLK_RIGHTBRACKET) {
if(sdl_zoom_trig==1) if(sdl_zoom_trig==1)
{ {
ZSIZE += 1; ZSIZE += 1;
if(ZSIZE>32) if(ZSIZE>32)
@ -1287,16 +1287,16 @@ int main(int argc, char *argv[])
} }
else else
{ {
if(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)) if(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))
bs += 1; bs += 1;
else else
bs += ceil((bs/5)+0.5f); bs += ceil((bs/5)+0.5f);
if(bs>1224) if(bs>1224)
bs = 1224; bs = 1224;
if(bs<0) if(bs<0)
bs = 0; bs = 0;
} }
} }
if(sdl_key==SDLK_SPACE) if(sdl_key==SDLK_SPACE)
sys_pause = !sys_pause; sys_pause = !sys_pause;
if(sdl_key=='h') if(sdl_key=='h')

2
misc.c
View File

@ -228,7 +228,7 @@ void strappend(char *dst, char *src)
for(s=(unsigned char *)src; *s; s++) for(s=(unsigned char *)src; *s; s++)
{ {
*(d++) = *s; *(d++) = *s;
} }
*d = 0; *d = 0;
} }

View File

@ -237,7 +237,7 @@ inline int create_part(int p, int x, int y, int t)
parts[i].life = 150; parts[i].life = 150;
} }
End Testing*/ End Testing*/
if(t==PT_COAL) if(t==PT_COAL)
parts[i].life = 110; parts[i].life = 110;
if(t==PT_FIRE) if(t==PT_FIRE)
parts[i].life = rand()%50+120; parts[i].life = rand()%50+120;
@ -518,7 +518,7 @@ void update_particles_i(pixel *vid, int start, int inc)
(bmap[y/CELL][x/CELL]==2) || (bmap[y/CELL][x/CELL]==2) ||
(bmap[y/CELL][x/CELL]==3 && ptypes[t].falldown!=2) || (bmap[y/CELL][x/CELL]==3 && ptypes[t].falldown!=2) ||
(bmap[y/CELL][x/CELL]==10 && ptypes[t].falldown!=1) || (bmap[y/CELL][x/CELL]==10 && ptypes[t].falldown!=1) ||
(bmap[y/CELL][x/CELL]==13 && ptypes[t].falldown!=0 && parts[i].type!=PT_FIRE && parts[i].type!=PT_SMKE) || (bmap[y/CELL][x/CELL]==13 && ptypes[t].falldown!=0 && parts[i].type!=PT_FIRE && parts[i].type!=PT_SMKE) ||
(bmap[y/CELL][x/CELL]==6 && (t==PT_METL || t==PT_SPRK)) || (bmap[y/CELL][x/CELL]==6 && (t==PT_METL || t==PT_SPRK)) ||
(bmap[y/CELL][x/CELL]==7 && !emap[y/CELL][x/CELL])) && (t!=PT_STKM))) (bmap[y/CELL][x/CELL]==7 && !emap[y/CELL][x/CELL])) && (t!=PT_STKM)))
{ {
@ -705,8 +705,8 @@ void update_particles_i(pixel *vid, int start, int inc)
int ctemp = pv[y/CELL][x/CELL]*2; int ctemp = pv[y/CELL][x/CELL]*2;
c_heat = 0.0f; c_heat = 0.0f;
h_count = 0; h_count = 0;
if(t==PT_ICEI && !parts[i].ctype) if(t==PT_ICEI && !parts[i].ctype)
parts[i].ctype = PT_WATR; parts[i].ctype = PT_WATR;
if(ptypes[t].hconduct>(rand()%250)) if(ptypes[t].hconduct>(rand()%250))
{ {
for(nx=-1; nx<2; nx++) for(nx=-1; nx<2; nx++)
@ -937,15 +937,15 @@ void update_particles_i(pixel *vid, int start, int inc)
} }
else if(t==PT_COAL) else if(t==PT_COAL)
{ {
if(parts[i].life<=0){ if(parts[i].life<=0) {
t = PT_NONE; t = PT_NONE;
kill_part(i); kill_part(i);
create_part(-1, x, y, PT_FIRE); create_part(-1, x, y, PT_FIRE);
goto killed; goto killed;
} else if(parts[i].life < 100){ } else if(parts[i].life < 100) {
parts[i].life--; parts[i].life--;
create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE); create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE);
} }
for(nx=-2; nx<3; nx++) for(nx=-2; nx<3; nx++)
for(ny=-2; ny<3; ny++) for(ny=-2; ny<3; ny++)
@ -957,9 +957,9 @@ void update_particles_i(pixel *vid, int start, int inc)
continue; continue;
if(((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) && 1>(rand()%500)) if(((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) && 1>(rand()%500))
{ {
if(parts[i].life>100){ if(parts[i].life>100) {
parts[i].life = 99; parts[i].life = 99;
} }
} }
} }
} }