summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Wallin <nibbler.v1@gmail.com>2010-09-18 07:52:14 (GMT)
committer Felix Wallin <nibbler.v1@gmail.com>2010-09-18 07:52:14 (GMT)
commit99ae022d5544ecc252ff943f83dba3aa6614ec57 (patch)
tree6787ea4c4ed830f14aeb69f8fb8449d631d157df
parentfa099338bb87d25ea660e74b16811d18256e7d51 (diff)
downloadpowder-99ae022d5544ecc252ff943f83dba3aa6614ec57.zip
powder-99ae022d5544ecc252ff943f83dba3aa6614ec57.tar.gz
astyle
-rw-r--r--graphics.c6
-rw-r--r--interface.c114
-rw-r--r--main.c70
-rw-r--r--misc.c2
-rw-r--r--powder.c32
5 files changed, 112 insertions, 112 deletions
diff --git a/graphics.c b/graphics.c
index 47c843f..7f9cf8c 100644
--- a/graphics.c
+++ b/graphics.c
@@ -2121,9 +2121,9 @@ pixel *prerender_save(void *save, int size, int *width, int *height)
return NULL;
if(!(c[2]==0x43 && c[1]==0x75 && c[0]==0x66) && !(c[2]==0x76 && c[1]==0x53 && c[0]==0x50))
return NULL;
- if(c[2]==0x43 && c[1]==0x75 && c[0]==0x66){
- new_format = 1;
- }
+ if(c[2]==0x43 && c[1]==0x75 && c[0]==0x66) {
+ new_format = 1;
+ }
if(c[4]>SAVE_VERSION)
return NULL;
diff --git a/interface.c b/interface.c
index 1f972b3..7bbde73 100644
--- a/interface.c
+++ b/interface.c
@@ -1789,7 +1789,7 @@ int search_ui(pixel *vid_buf)
memset(img_id, 0, sizeof(img_id));
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_scoreup, 0, sizeof(search_scoreup));
memset(search_scoredown, 0, sizeof(search_scoredown));
@@ -2004,8 +2004,8 @@ int search_ui(pixel *vid_buf)
dp = pos;
}
}
- 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);
+ 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+((YRES/GRID_S+3)/2), 6, 1+(YRES/GRID_S+3)/2, 107, 10, 0, 255);
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-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);
}
}
@@ -2162,17 +2162,17 @@ int search_ui(pixel *vid_buf)
fillrect(vid_buf, 0, 0, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 255);
info_box(vid_buf, "Loading...");
- if(search_dates[mp]){
- uri = malloc(strlen(search_ids[mp])*3+strlen(search_dates[mp])*3+strlen(SERVER)+71);
- strcpy(uri, "http://" SERVER "/Get.api?Op=save&ID=");
- strcaturl(uri, search_ids[mp]);
- strappend(uri, "&Date=");
- strcaturl(uri, search_dates[mp]);
- } else {
- uri = malloc(strlen(search_ids[mp])*3+strlen(SERVER)+64);
- strcpy(uri, "http://" SERVER "/Get.api?Op=save&ID=");
- strcaturl(uri, search_ids[mp]);
- }
+ if(search_dates[mp]) {
+ uri = malloc(strlen(search_ids[mp])*3+strlen(search_dates[mp])*3+strlen(SERVER)+71);
+ strcpy(uri, "http://" SERVER "/Get.api?Op=save&ID=");
+ strcaturl(uri, search_ids[mp]);
+ strappend(uri, "&Date=");
+ strcaturl(uri, search_dates[mp]);
+ } else {
+ uri = malloc(strlen(search_ids[mp])*3+strlen(SERVER)+64);
+ strcpy(uri, "http://" SERVER "/Get.api?Op=save&ID=");
+ strcaturl(uri, search_ids[mp]);
+ }
data = http_simple_get(uri, &status, &dlen);
free(uri);
@@ -2384,22 +2384,22 @@ int search_ui(pixel *vid_buf)
thlen = 4;
}
thumb_cache_add(img_id[i], thumb, thlen);
- for(pos=0; pos<GRID_X*GRID_Y; pos++){
- if(search_dates[pos]){
- char *id_d_temp = malloc(strlen(search_ids[pos])+strlen(search_dates[pos])+1);
- strcpy(id_d_temp, search_ids[pos]);
- strappend(id_d_temp, "_");
- strappend(id_d_temp, search_dates[pos]);
- //img_id[i] = mystrdup(id_d_temp);
- if(id_d_temp && !strcmp(id_d_temp, img_id[i])){
- break;
- }
- } else {
- if(search_ids[pos] && !strcmp(search_ids[pos], img_id[i])){
- break;
- }
- }
- }
+ for(pos=0; pos<GRID_X*GRID_Y; pos++) {
+ if(search_dates[pos]) {
+ char *id_d_temp = malloc(strlen(search_ids[pos])+strlen(search_dates[pos])+1);
+ strcpy(id_d_temp, search_ids[pos]);
+ strappend(id_d_temp, "_");
+ strappend(id_d_temp, search_dates[pos]);
+ //img_id[i] = mystrdup(id_d_temp);
+ if(id_d_temp && !strcmp(id_d_temp, img_id[i])) {
+ break;
+ }
+ } else {
+ if(search_ids[pos] && !strcmp(search_ids[pos], img_id[i])) {
+ break;
+ }
+ }
+ }
if(pos<GRID_X*GRID_Y)
{
search_thumbs[pos] = thumb;
@@ -2424,25 +2424,25 @@ int search_ui(pixel *vid_buf)
}
if(pos<GRID_X*GRID_Y)
{
- if(search_dates[pos]){
- 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);
- strcpy(uri, "http://" SERVER "/Get.api?Op=thumb&ID=");
- strcaturl(uri, search_ids[pos]);
- strappend(uri, "&Date=");
- strcaturl(uri, search_dates[pos]);
-
- strcpy(id_d_temp, search_ids[pos]);
- strappend(id_d_temp, "_");
- strappend(id_d_temp, search_dates[pos]);
- img_id[i] = mystrdup(id_d_temp);
- } else {
- uri = malloc(strlen(search_ids[pos])*3+strlen(SERVER)+64);
- strcpy(uri, "http://" SERVER "/Get.api?Op=thumb&ID=");
- strcaturl(uri, search_ids[pos]);
- img_id[i] = mystrdup(search_ids[pos]);
- }
-
+ if(search_dates[pos]) {
+ 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);
+ strcpy(uri, "http://" SERVER "/Get.api?Op=thumb&ID=");
+ strcaturl(uri, search_ids[pos]);
+ strappend(uri, "&Date=");
+ strcaturl(uri, search_dates[pos]);
+
+ strcpy(id_d_temp, search_ids[pos]);
+ strappend(id_d_temp, "_");
+ strappend(id_d_temp, search_dates[pos]);
+ img_id[i] = mystrdup(id_d_temp);
+ } else {
+ uri = malloc(strlen(search_ids[pos])*3+strlen(SERVER)+64);
+ strcpy(uri, "http://" SERVER "/Get.api?Op=thumb&ID=");
+ strcaturl(uri, search_ids[pos]);
+ img_id[i] = mystrdup(search_ids[pos]);
+ }
+
img_http[i] = http_async_req_start(img_http[i], uri, NULL, 0, 1);
free(uri);
}
@@ -2484,7 +2484,7 @@ int search_results(char *str, int votes)
if(search_ids[i])
{
free(search_ids[i]);
- search_ids[i] = NULL;
+ search_ids[i] = NULL;
}
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);
i++;
}
- else if(!strncmp(str, "HISTORY ", 8))
+ else if(!strncmp(str, "HISTORY ", 8))
{
if(i>=GRID_X*GRID_Y)
break;
if(votes)
{
sd = strchr(str+8, ' ');
- if(!sd)
+ if(!sd)
return i;
*(sd++) = 0;
- pu = strchr(sd, ' ');
+ pu = strchr(sd, ' ');
if(!pu)
return i;
*(pu++) = 0;
@@ -2624,10 +2624,10 @@ int search_results(char *str, int votes)
else
{
sd = strchr(str+8, ' ');
- if(!sd)
+ if(!sd)
return i;
*(sd++) = 0;
- pu = strchr(sd, ' ');
+ pu = strchr(sd, ' ');
if(!pu)
return i;
*(pu++) = 0;
@@ -2650,7 +2650,7 @@ int search_results(char *str, int votes)
*(r++) = 0;
search_ids[i] = mystrdup(str+8);
- search_dates[i] = mystrdup(sd);
+ search_dates[i] = mystrdup(sd);
search_publish[i] = atoi(pu);
search_scoreup[i] = atoi(vu);
diff --git a/main.c b/main.c
index f8e11f6..51fe3b0 100644
--- a/main.c
+++ b/main.c
@@ -310,10 +310,10 @@ void *build_save(int *size, int x0, int y0, int w, int h)
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);
+ //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++)
@@ -349,8 +349,8 @@ void *build_save(int *size, int x0, int y0, int w, int h)
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
+ //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;
@@ -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 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
- //This creates a problem for old clients, that display and "corrupt" error instead of a "newer version" error
+ //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
if(size<16)
return 1;
if(!(c[2]==0x43 && c[1]==0x75 && c[0]==0x66) && !(c[2]==0x76 && c[1]==0x53 && c[0]==0x50))
return 1;
- if(c[2]==0x76 && c[1]==0x53 && c[0]==0x50){
- new_format = 1;
- }
+ if(c[2]==0x76 && c[1]==0x53 && c[0]==0x50) {
+ new_format = 1;
+ }
if(c[4]>SAVE_VERSION)
return 2;
ver = c[4];
@@ -600,13 +600,13 @@ int parse_save(void *save, int size, int replace, int x0, int y0)
if(i <= NPART)
{
if(ver>=42) {
- if(new_format){
- ttv = (d[p++])<<8;
- ttv |= (d[p++]);
- parts[i-1].temp = ttv;
- } else {
- parts[i-1].temp = (d[p++]*((MAX_TEMP+(-MIN_TEMP))/255))+MIN_TEMP;
- }
+ if(new_format) {
+ ttv = (d[p++])<<8;
+ ttv |= (d[p++]);
+ parts[i-1].temp = ttv;
+ } else {
+ 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;
}
@@ -614,9 +614,9 @@ int parse_save(void *save, int size, int replace, int x0, int y0)
else
{
p++;
- if(new_format){
- p++;
- }
+ if(new_format) {
+ p++;
+ }
}
}
else
@@ -1253,8 +1253,8 @@ int main(int argc, char *argv[])
{
set_cmode(6);
}
- if(sdl_key==SDLK_LEFTBRACKET){
- if(sdl_zoom_trig==1)
+ if(sdl_key==SDLK_LEFTBRACKET) {
+ if(sdl_zoom_trig==1)
{
ZSIZE -= 1;
if(ZSIZE>32)
@@ -1265,18 +1265,18 @@ int main(int argc, char *argv[])
}
else
{
- if(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))
- bs -= 1;
- else
- bs -= ceil((bs/5)+0.5f);
+ if(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))
+ bs -= 1;
+ else
+ bs -= ceil((bs/5)+0.5f);
if(bs>1224)
bs = 1224;
if(bs<0)
bs = 0;
}
- }
- if(sdl_key==SDLK_RIGHTBRACKET){
- if(sdl_zoom_trig==1)
+ }
+ if(sdl_key==SDLK_RIGHTBRACKET) {
+ if(sdl_zoom_trig==1)
{
ZSIZE += 1;
if(ZSIZE>32)
@@ -1287,16 +1287,16 @@ int main(int argc, char *argv[])
}
else
{
- if(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))
- bs += 1;
- else
- bs += ceil((bs/5)+0.5f);
+ if(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))
+ bs += 1;
+ else
+ bs += ceil((bs/5)+0.5f);
if(bs>1224)
bs = 1224;
if(bs<0)
bs = 0;
}
- }
+ }
if(sdl_key==SDLK_SPACE)
sys_pause = !sys_pause;
if(sdl_key=='h')
diff --git a/misc.c b/misc.c
index 2eac7b2..7c551e2 100644
--- a/misc.c
+++ b/misc.c
@@ -228,7 +228,7 @@ void strappend(char *dst, char *src)
for(s=(unsigned char *)src; *s; s++)
{
- *(d++) = *s;
+ *(d++) = *s;
}
*d = 0;
}
diff --git a/powder.c b/powder.c
index ae7ba8f..b147392 100644
--- a/powder.c
+++ b/powder.c
@@ -237,7 +237,7 @@ inline int create_part(int p, int x, int y, int t)
parts[i].life = 150;
}
End Testing*/
- if(t==PT_COAL)
+ if(t==PT_COAL)
parts[i].life = 110;
if(t==PT_FIRE)
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]==3 && ptypes[t].falldown!=2) ||
(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]==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;
c_heat = 0.0f;
h_count = 0;
- if(t==PT_ICEI && !parts[i].ctype)
- parts[i].ctype = PT_WATR;
+ if(t==PT_ICEI && !parts[i].ctype)
+ parts[i].ctype = PT_WATR;
if(ptypes[t].hconduct>(rand()%250))
{
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)
{
- if(parts[i].life<=0){
- t = PT_NONE;
- kill_part(i);
- create_part(-1, x, y, PT_FIRE);
- goto killed;
- } else if(parts[i].life < 100){
- parts[i].life--;
- create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE);
- }
+ if(parts[i].life<=0) {
+ t = PT_NONE;
+ kill_part(i);
+ create_part(-1, x, y, PT_FIRE);
+ goto killed;
+ } else if(parts[i].life < 100) {
+ parts[i].life--;
+ create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE);
+ }
for(nx=-2; nx<3; nx++)
for(ny=-2; ny<3; ny++)
@@ -957,9 +957,9 @@ void update_particles_i(pixel *vid, int start, int inc)
continue;
if(((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) && 1>(rand()%500))
{
- if(parts[i].life>100){
- parts[i].life = 99;
- }
+ if(parts[i].life>100) {
+ parts[i].life = 99;
+ }
}
}
}