summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCracker64 <cracker642@gmail.com>2010-12-05 04:29:41 (GMT)
committer Cracker64 <cracker642@gmail.com>2010-12-05 04:29:41 (GMT)
commit2cf25c8a6aad84b2f86060e791948a0aed307192 (patch)
tree223a496850225a5acfd8c66c7cf47dad8aaf950c /src
parentd56684312dd9429da8be8666206ad1656d3185a9 (diff)
downloadpowder-2cf25c8a6aad84b2f86060e791948a0aed307192.zip
powder-2cf25c8a6aad84b2f86060e791948a0aed307192.tar.gz
FILT, a photon color filter, not really a filter right now, but it changes the color. Other small changes
Diffstat (limited to 'src')
-rw-r--r--src/graphics.c24
-rw-r--r--src/interface.c17
-rw-r--r--src/main.c34
-rw-r--r--src/powder.c31
4 files changed, 83 insertions, 23 deletions
diff --git a/src/graphics.c b/src/graphics.c
index 1af3f9b..5476bf7 100644
--- a/src/graphics.c
+++ b/src/graphics.c
@@ -1765,6 +1765,30 @@ void draw_parts(pixel *vid)
}
}
}
+ else if(t==PT_FILT)
+ {
+ int temp_bin = (int)((parts[i].temp-273.0f)*0.025f);
+ if(temp_bin < 0) temp_bin = 0;
+ if(temp_bin > 25) temp_bin = 25;
+ parts[i].ctype = 0x1F << temp_bin;
+ cg = 0;
+ cb = 0;
+ cr = 0;
+ for(x=0; x<12; x++) {
+ cr += (parts[i].ctype >> (x+18)) & 1;
+ cb += (parts[i].ctype >> x) & 1;
+ }
+ for(x=0; x<14; x++)
+ cg += (parts[i].ctype >> (x+9)) & 1;
+ x = 624/(cr+cg+cb+1);
+ cr *= x;
+ cg *= x;
+ cb *= x;
+ cr = cr>255?255:cr;
+ cg = cg>255?255:cg;
+ cb = cb>255?255:cb;
+ blendpixel(vid, nx, ny, cr, cg, cb, 127);
+ }
else if(t==PT_PHOT)
{
if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)
diff --git a/src/interface.c b/src/interface.c
index 3937ec8..4925211 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -2796,12 +2796,14 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
ccy = 0;
for(cc=0; cc<info->comment_count; cc++) {
- drawtext(vid_buf, 60+(XRES/2)+1, ccy+60, info->commentauthors[cc], 255, 255, 255, 255);
- ccy += 12;
- ccy += drawtextwrap(vid_buf, 60+(XRES/2)+1, ccy+60, XRES+BARSIZE-100-((XRES/2)+1)-20, info->comments[cc], 255, 255, 255, 185);
- ccy += 10;
- if(ccy+52<YRES+MENUSIZE){ //Try not to draw off the screen.
- draw_line(vid_buf, 50+(XRES/2)+2, ccy+52, XRES+BARSIZE-50, ccy+52, 100, 100, 100, XRES+BARSIZE);
+ if((ccy + 72 + ((textwidth(info->comments[cc])/(XRES+BARSIZE-100-((XRES/2)+1)-20)))*12)<(YRES+MENUSIZE-50)){
+ drawtext(vid_buf, 60+(XRES/2)+1, ccy+60, info->commentauthors[cc], 255, 255, 255, 255);
+ ccy += 12;
+ ccy += drawtextwrap(vid_buf, 60+(XRES/2)+1, ccy+60, XRES+BARSIZE-100-((XRES/2)+1)-20, info->comments[cc], 255, 255, 255, 185);
+ ccy += 10;
+ if(ccy+52<YRES+MENUSIZE-50){ //Try not to draw off the screen.
+ draw_line(vid_buf, 50+(XRES/2)+2, ccy+52, XRES+BARSIZE-50, ccy+52, 100, 100, 100, XRES+BARSIZE);
+ }
}
}
hasdrawninfo = 1;
@@ -2927,9 +2929,10 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192);
info_box(vid_buf, "Submitting Comment...");
execute_submit(vid_buf, save_id, ed.str);
+ ed.str[0] = 0;
}
}
- if(!(mx>50 && my>50 && mx<XRES+BARSIZE-100 && my<YRES+MENUSIZE-100) && b && !queue_open){
+ if(!(mx>50 && my>50 && mx<XRES+BARSIZE-50 && my<YRES+MENUSIZE-50) && b && !queue_open){
retval = 0;
break;
}
diff --git a/src/main.c b/src/main.c
index 6fd5bf5..c7818fc 100644
--- a/src/main.c
+++ b/src/main.c
@@ -308,8 +308,13 @@ void *build_save(int *size, int x0, int y0, int w, int h)
for(j=0; j<w*h; j++)
{
i = m[j];
- if(i)
- d[p++] = (parts[i-1].life+3)/4;
+ 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++)
{
@@ -623,12 +628,25 @@ int parse_save(void *save, int size, int replace, int x0, int y0)
i = m[j];
if(i)
{
- if(p >= size)
- goto corrupt;
- if(i <= NPART)
- parts[i-1].life = d[p++]*4;
- else
- p++;
+ if(ver>=44){
+ if(p >= size) {
+ goto corrupt;
+ }
+ if(i <= NPART) {
+ ttv = (d[p++])<<8;
+ ttv |= (d[p++]);
+ parts[i-1].life = ttv;
+ } else {
+ p+=2;
+ }
+ } else {
+ if(p >= size)
+ goto corrupt;
+ if(i <= NPART)
+ parts[i-1].life = d[p++]*4;
+ else
+ p++;
+ }
}
}
for(j=0; j<w*h; j++)
diff --git a/src/powder.c b/src/powder.c
index ff5b926..f6cc143 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -77,6 +77,7 @@ static int eval_move(int pt, int nx, int ny, unsigned *rr)
(r&0xFF)==PT_GLOW || (r&0xFF)==PT_WATR ||
(r&0xFF)==PT_DSTW || (r&0xFF)==PT_SLTW ||
(r&0xFF)==PT_ISOZ || (r&0xFF)==PT_ISZS ||
+ (r&0xFF)==PT_FILT ||
((r&0xFF)==PT_LCRY&&parts[r>>8].life > 5)))
return 2;
@@ -157,7 +158,13 @@ int try_move(int i, int x, int y, int nx, int ny)
parts[r>>8].life = 120;
create_gain_photon(i);
}
-
+ if(parts[i].type == PT_PHOT && (r&0xFF)==PT_FILT)
+ {
+ int temp_bin = (int)((parts[r>>8].temp-273.0f)*0.025f);
+ if(temp_bin < 0) temp_bin = 0;
+ if(temp_bin > 25) temp_bin = 25;
+ parts[i].ctype = 0x1F << temp_bin;
+ }
if(parts[i].type == PT_NEUT && (r&0xFF)==PT_GLAS) {
if(rand() < RAND_MAX/10)
create_cherenkov_photon(i);
@@ -1451,7 +1458,7 @@ void update_particles_i(pixel *vid, int start, int inc)
r = pmap[y+ny][x+nx];
if((r>>8)>=NPART || !r)
continue;
- if(parts[r>>8].type!=PT_NONE&&parts[i].type!=PT_NONE&&ptypes[parts[r>>8].type].hconduct>0&&!(parts[r>>8].type==PT_HSWC&&parts[r>>8].life!=10))
+ if(parts[r>>8].type!=PT_NONE&&parts[i].type!=PT_NONE&&ptypes[parts[r>>8].type].hconduct>0&&!(parts[r>>8].type==PT_HSWC&&parts[r>>8].life!=10)&&!(parts[i].type==PT_PHOT&&parts[r>>8].type==PT_FILT))
{
h_count++;
c_heat += parts[r>>8].temp;
@@ -1469,7 +1476,7 @@ void update_particles_i(pixel *vid, int start, int inc)
r = pmap[y+ny][x+nx];
if((r>>8)>=NPART || !r)
continue;
- if(parts[r>>8].type!=PT_NONE&&parts[i].type!=PT_NONE&&ptypes[parts[r>>8].type].hconduct>0&&!(parts[r>>8].type==PT_HSWC&&parts[r>>8].life!=10))
+ if(parts[r>>8].type!=PT_NONE&&parts[i].type!=PT_NONE&&ptypes[parts[r>>8].type].hconduct>0&&!(parts[r>>8].type==PT_HSWC&&parts[r>>8].life!=10)&&!(parts[i].type==PT_PHOT&&parts[r>>8].type==PT_FILT))
{
parts[r>>8].temp = parts[i].temp;
}
@@ -4892,15 +4899,23 @@ int flood_parts(int x, int y, int c, int cm, int bm)
while(x1>=CELL)
{
if((pmap[y][x1-1]&0xFF)!=cm || bmap[y/CELL][(x1-1)/CELL]!=bm)
- if(((pmap[y][x1-1]&0xFF)!=PT_INST2&&(pmap[y][x1-1]&0xFF)!=PT_INST3))
- break;
+ {
+ if(cm!=PT_INST)
+ break;
+ else if((pmap[y][x1-1]&0xFF)!=PT_INST2&&(pmap[y][x1-1]&0xFF)!=PT_INST3)
+ break;
+ }
x1--;
}
while(x2<XRES-CELL)
{
if((pmap[y][x2+1]&0xFF)!=cm || bmap[y/CELL][(x2+1)/CELL]!=bm)
- if(((pmap[y][x2+1]&0xFF)!=PT_INST2&&(pmap[y][x2+1]&0xFF)!=PT_INST3))
- break;
+ {
+ if(cm!=PT_INST)
+ break;
+ else if((pmap[y][x1+1]&0xFF)!=PT_INST2&&(pmap[y][x1+1]&0xFF)!=PT_INST3)
+ break;
+ }
x2++;
}
@@ -4911,7 +4926,7 @@ int flood_parts(int x, int y, int c, int cm, int bm)
return 0;
}
// fill children
- if(cm==PT_INST&&(co==PT_INST2||co==PT_INST3))
+ if(cm==PT_INST&&(co==PT_INST2||co==PT_INST3))//crossings for inst wire, same as walls
{
if(y>=CELL+dy && x1==x2 &&
((pmap[y-1][x1-1]&0xFF)==PT_INST||((pmap[y-1][x1-1]&0xFF)==PT_INST3||(pmap[y-1][x1-1]&0xFF)==PT_INST2)) && ((pmap[y-1][x1]&0xFF)==PT_INST||((pmap[y-1][x1]&0xFF)==PT_INST3||(pmap[y-1][x1]&0xFF)==PT_INST2)) && ((pmap[y-1][x1+1]&0xFF)==PT_INST || ((pmap[y-1][x1+1]&0xFF)==PT_INST3||(pmap[y-1][x1+1]&0xFF)==PT_INST2)) &&