summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCracker64 <cracker642@gmail.com>2010-12-14 22:23:27 (GMT)
committer Cracker64 <cracker642@gmail.com>2010-12-14 22:23:27 (GMT)
commit5b2c6893941cc04bbe80f74b8ea35a744b0164cc (patch)
treeb18eeb273faf4ad6329e4183c1e16381b304f53b /src
parent23f828135a21831adeb5511eb59b6dd2105baf27 (diff)
downloadpowder-5b2c6893941cc04bbe80f74b8ea35a744b0164cc.zip
powder-5b2c6893941cc04bbe80f74b8ea35a744b0164cc.tar.gz
another swch fix, desl fire fix, shift-g will make grid go down, BIZR glows from velocity in FIRE,ect. METL/BRMT/BMTL change color when heated in heat gradient view. other small changes.
Diffstat (limited to 'src')
-rw-r--r--src/graphics.c76
-rw-r--r--src/interface.c4
-rw-r--r--src/main.c22
-rw-r--r--src/powder.c60
4 files changed, 124 insertions, 38 deletions
diff --git a/src/graphics.c b/src/graphics.c
index 8dfea36..54ca233 100644
--- a/src/graphics.c
+++ b/src/graphics.c
@@ -1432,27 +1432,50 @@ void draw_parts(pixel *vid)
blendpixel(vid, nx, ny, cr, cg, cb, 255);
}
}
- else if(cmode==CM_GRAD)//forgot to put else, broke nothing view
+ else if(cmode==CM_GRAD)
{
- float frequency = 0.05;
- int q = parts[i].temp;
- cr = sin(frequency*q) * 16 + PIXR(ptypes[t].pcolors);
- cg = sin(frequency*q) * 16 + PIXG(ptypes[t].pcolors);
- cb = sin(frequency*q) * 16 + PIXB(ptypes[t].pcolors);
- if(cr>=255)
+ if((t==PT_METL||t==PT_BRMT||t==PT_BMTL)&&parts[i].temp>473&&parts[i].temp<1370)
+ {
+ float frequency = 0.00146;
+ int q = parts[i].temp-473;
+ cr = sin(frequency*q) * 226 + PIXR(ptypes[t].pcolors);
+ cg = sin(frequency*q*4.55 +3.14) * 34 + PIXG(ptypes[t].pcolors);
+ cb = sin(frequency*q*2.22 +3.14) * 64 + PIXB(ptypes[t].pcolors);
+ if(cr>=255)
cr = 255;
- if(cg>=255)
+ if(cg>=255)
cg = 255;
- if(cb>=255)
+ if(cb>=255)
cb = 255;
- if(cr<=0)
+ if(cr<=0)
cr = 0;
- if(cg<=0)
+ if(cg<=0)
cg = 0;
- if(cb<=0)
+ if(cb<=0)
cb = 0;
- blendpixel(vid, nx, ny, cr, cg, cb, 255);
-
+ blendpixel(vid, nx, ny, cr, cg, cb, 255);
+ }
+ else
+ {
+ float frequency = 0.05;
+ int q = parts[i].temp-40;
+ cr = sin(frequency*q) * 16 + PIXR(ptypes[t].pcolors);
+ cg = sin(frequency*q) * 16 + PIXG(ptypes[t].pcolors);
+ cb = sin(frequency*q) * 16 + PIXB(ptypes[t].pcolors);
+ if(cr>=255)
+ cr = 255;
+ if(cg>=255)
+ cg = 255;
+ if(cb>=255)
+ cb = 255;
+ if(cr<=0)
+ cr = 0;
+ if(cg<=0)
+ cg = 0;
+ if(cb<=0)
+ cb = 0;
+ blendpixel(vid, nx, ny, cr, cg, cb, 255);
+ }
}
else if(t==PT_MWAX&&cmode == CM_FANCY)
@@ -1471,7 +1494,7 @@ void draw_parts(pixel *vid)
}
}
- else if(t==PT_CRAC)
+ else if(t==PT_SPNG)
{
cr = PIXR(ptypes[t].pcolors) - parts[i].life*15;
cg = PIXG(ptypes[t].pcolors) - parts[i].life*15;
@@ -1623,7 +1646,28 @@ void draw_parts(pixel *vid)
cr = cr>255?255:cr;
cg = cg>255?255:cg;
cb = cb>255?255:cb;
- blendpixel(vid, nx, ny, cr, cg, cb, 255);
+ if(fabs(parts[i].vx)+fabs(parts[i].vy)>0 &&(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)) {
+ fg = 0;
+ fb = 0;
+ fr = 0;
+ fg = cg/40 * fabs(parts[i].vx)+fabs(parts[i].vy);
+ fb = cb/40 * fabs(parts[i].vx)+fabs(parts[i].vy);
+ fr = cr/40 * fabs(parts[i].vx)+fabs(parts[i].vy);
+ vid[ny*(XRES+BARSIZE)+nx] = PIXRGB((int)restrict_flt(cr, 0, 255), (int)restrict_flt(cg, 0, 255), (int)restrict_flt(cb, 0, 255));
+ x = nx/CELL;
+ y = ny/CELL;
+ fg += fire_g[y][x];
+ if(fg > 255) fg = 255;
+ fire_g[y][x] = fg;
+ fb += fire_b[y][x];
+ if(fb > 255) fb = 255;
+ fire_b[y][x] = fb;
+ fr += fire_r[y][x];
+ if(fr > 255) fr = 255;
+ fire_r[y][x] = fr;
+ }
+ else
+ blendpixel(vid, nx, ny, cr, cg, cb, 255);
}
else if(t==PT_PIPE)
{
diff --git a/src/interface.c b/src/interface.c
index 1052a22..d531929 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -147,6 +147,7 @@ void add_sign_ui(pixel *vid_buf, int mx, int my)
ed.focus = 1;
ed.hide = 0;
ed.cursor = strlen(signs[i].text);
+ ed.multiline = 0;
strcpy(ed.str, signs[i].text);
ju = signs[i].ju;
@@ -763,6 +764,7 @@ void login_ui(pixel *vid_buf)
ed1.def = "[user name]";
ed1.focus = 1;
ed1.hide = 0;
+ ed1.multiline = 0;
ed1.cursor = strlen(svf_user);
strcpy(ed1.str, svf_user);
ed2.x = x0+25;
@@ -773,6 +775,7 @@ void login_ui(pixel *vid_buf)
ed2.focus = 0;
ed2.hide = 1;
ed2.cursor = 0;
+ ed2.multiline = 0;
strcpy(ed2.str, "");
fillrect(vid_buf, -1, -1, XRES, YRES+MENUSIZE, 0, 0, 0, 192);
@@ -1024,6 +1027,7 @@ void tag_list_ui(pixel *vid_buf)
ed.focus = 0;
ed.hide = 0;
ed.cursor = 0;
+ ed.multiline = 0;
strcpy(ed.str, "");
fillrect(vid_buf, -1, -1, XRES, YRES+MENUSIZE, 0, 0, 0, 192);
diff --git a/src/main.c b/src/main.c
index eaba83b..92caf3a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1481,7 +1481,12 @@ int main(int argc, char *argv[])
if(sdl_key==SDLK_INSERT)
REPLACE_MODE = !REPLACE_MODE;
if(sdl_key=='g')
- GRID_MODE = (GRID_MODE+1)%10;
+ {
+ if(sdl_mod & (KMOD_SHIFT))
+ GRID_MODE = (GRID_MODE+9)%10;
+ else
+ GRID_MODE = (GRID_MODE+1)%10;
+ }
if(sdl_key=='t')
VINE_MODE = !VINE_MODE;
if(sdl_key==SDLK_SPACE)
@@ -1630,14 +1635,15 @@ int main(int argc, char *argv[])
sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life);
#else
if(DEBUG_MODE)
- {
- int tctype = parts[cr>>8].ctype;
- if(tctype>=PT_NUM)
- tctype = 0;
- sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life);
- }
- else
+ {
+ int tctype = parts[cr>>8].ctype;
+ if(tctype>=PT_NUM)
+ tctype = 0;
+ sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life);
+ //sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[parts[cr>>8].ctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life);
+ } else {
sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C", ptypes[cr&0xFF].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f);
+ }
#endif
}
else
diff --git a/src/powder.c b/src/powder.c
index 70bb269..1ba31f9 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -467,11 +467,25 @@ inline int create_part(int p, int x, int y, int t)
pmap[y][x] = (pmap[y][x]&~0xFF) | PT_SPRK;
return pmap[y][x]>>8;
}
-
- if(p==-1)
+ if(p==-1)//creating from anything but brush
+ {
+ if(pmap[y][x])
+ return -1;
+ if(pfree == -1)
+ return -1;
+ i = pfree;
+ pfree = parts[i].life;
+ }
+ else if(p==-2)//creating from brush
{
if(pmap[y][x])
+ {
+ if(((pmap[y][x]&0xFF)==PT_CLNE||(pmap[y][x]&0xFF)==PT_BCLN||(pmap[y][x]&0xFF)==PT_PCLN)&&(t!=PT_CLNE&&t!=PT_PCLN&&t!=PT_BCLN))
+ {
+ parts[pmap[y][x]>>8].ctype = t;
+ }
return -1;
+ }
if(pfree == -1)
return -1;
i = pfree;
@@ -562,7 +576,8 @@ inline int create_part(int p, int x, int y, int t)
parts[i].vx = 3.0f*cosf(a);
parts[i].vy = 3.0f*sinf(a);
}
-
+ if(t==PT_BIZR||t==PT_BIZRG)
+ parts[i].ctype = 0x47FFFF;
if(t!=PT_STKM)// && t!=PT_PHOT && t!=PT_NEUT) is this needed? it breaks floodfill
pmap[y][x] = t|(i<<8);
else if(t==PT_STKM)
@@ -1141,7 +1156,7 @@ void update_particles_i(pixel *vid, int start, int inc)
ly = parts[i].y;
t = parts[i].type;
- if(parts[i].life && t!=PT_ACID && t!=PT_COAL && t!=PT_WOOD && t!=PT_NBLE && t!=PT_SWCH && t!=PT_STKM && t!=PT_FUSE && t!=PT_FSEP && t!=PT_BCOL && t!=PT_GOL && t!=PT_CRAC && t!=PT_DEUT)
+ if(parts[i].life && t!=PT_ACID && t!=PT_COAL && t!=PT_WOOD && t!=PT_NBLE && t!=PT_SWCH && t!=PT_STKM && t!=PT_FUSE && t!=PT_FSEP && t!=PT_BCOL && t!=PT_GOL && t!=PT_SPNG && t!=PT_DEUT)
{
if(!(parts[i].life==10&&(parts[i].type==PT_LCRY||parts[i].type==PT_PCLN||parts[i].type==PT_HSWC||parts[i].type==PT_PUMP)))
parts[i].life--;
@@ -1368,12 +1383,18 @@ void update_particles_i(pixel *vid, int start, int inc)
if(t==PT_GAS && pv[y/CELL][x/CELL]>6.0f)
t = parts[i].type = PT_OIL;
if(t==PT_DESL && pv[y/CELL][x/CELL]>12.0f)
+ {
t = parts[i].type = PT_FIRE;
+ parts[i].life = rand()%50+120;
+ }
}
if(t==PT_GAS && pv[y/CELL][x/CELL]<-6.0f)
t = parts[i].type = PT_OIL;
- if(t==PT_DESL && pv[y/CELL][x/CELL]>5.0f) // Only way I know to make it
- t = parts[i].type = PT_FIRE; // combust under pressure.
+ if(t==PT_DESL && pv[y/CELL][x/CELL]>5.0f)
+ { // Only way I know to make it
+ t = parts[i].type = PT_FIRE; // combust under pressure.
+ parts[i].life = rand()%50+120;
+ }
if(t==PT_GAS && pv[y/CELL][x/CELL]>6.0f)
t = parts[i].type = PT_OIL;
if(t==PT_BMTL && pv[y/CELL][x/CELL]>2.5f)
@@ -1555,9 +1576,15 @@ void update_particles_i(pixel *vid, int start, int inc)
}
else
{
- t = parts[i].type = pstates[t].gas;
- if(t!=PT_BIZRS)
+ if((t==PT_BIZR||t==PT_BIZRG||t==PT_BIZRS)&&pt>=pstates[t].gtemp)
+ {
+ t = parts[i].type = pstates[t].gas;
+ }
+ else{
+ t = parts[i].type = pstates[t].gas;
pv[y/CELL][x/CELL] += 0.50f;
+ }
+
if(t==PT_FIRE)
parts[i].life = rand()%50+120;
if(t==PT_HFLM)
@@ -2381,7 +2408,7 @@ void update_particles_i(pixel *vid, int start, int inc)
ISLOLZ=1;
else if(t==PT_GRAV)
ISGRAV=1;
- else if(t==PT_CRAC)
+ else if(t==PT_SPNG)
{
if(pv[y/CELL][x/CELL]<=3&&pv[y/CELL][x/CELL]>=-3)
{
@@ -3262,7 +3289,7 @@ void update_particles_i(pixel *vid, int start, int inc)
if((r>>8)>=NPART || !r)
continue;
rt = parts[r>>8].type;
- if((r&0xFF)!=PT_AMTR && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_NONE && (r&0xFF)!=PT_PHOT && (r&0xFF)!=PT_VOID && (r&0xFF)!=PT_BHOL)
+ if((r&0xFF)!=PT_AMTR && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_NONE && (r&0xFF)!=PT_PHOT && (r&0xFF)!=PT_VOID && (r&0xFF)!=PT_BHOL && (r&0xFF)!=PT_PRTI && (r&0xFF)!=PT_PRTO)
{
t = parts[i].life++;
if(parts[i].life==3)
@@ -3388,6 +3415,11 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[i].life = 10;
}
}
+ else if(parts[r>>8].type == PT_SPRK && parts[r>>8].ctype==PT_SWCH && parts[i].life<10&&parts_avg(i,r>>8,PT_INSL)!=PT_INSL)
+ {
+ parts[r>>8].type = parts[r>>8].ctype;
+ parts[r>>8].life = 9;
+ }
}
}
if(t==PT_SWCH)
@@ -3410,7 +3442,7 @@ void update_particles_i(pixel *vid, int start, int inc)
rt = parts[r>>8].type;
if((a || ptypes[rt].explosive) && ((rt!=PT_RBDM && rt!=PT_LRBD && rt!=PT_INSL && rt!=PT_SWCH) || t!=PT_SPRK) &&
!(t==PT_PHOT && rt==PT_INSL) &&
- (t!=PT_LAVA || parts[i].life>0 || (rt!=PT_STNE && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SWCH && rt!=PT_INWR)) && !(rt==PT_CRAC && parts[r>>8].life>0) &&
+ (t!=PT_LAVA || parts[i].life>0 || (rt!=PT_STNE && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SWCH && rt!=PT_INWR)) && !(rt==PT_SPNG && parts[r>>8].life>0) &&
ptypes[rt].flammable && (ptypes[rt].flammable + (int)(pv[(y+ny)/CELL][(x+nx)/CELL]*10.0f))>(rand()%1000))
{
parts[r>>8].type = PT_FIRE;
@@ -5120,7 +5152,7 @@ int create_parts(int x, int y, int rx, int ry, int c)
for(j=-ry; j<=ry; j++)
for(i=-rx; i<=rx; i++)
if((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx))
- create_part(-1, x+i, y+j, c);
+ create_part(-2, x+i, y+j, c);
return 1;
}
@@ -5147,7 +5179,7 @@ int create_parts(int x, int y, int rx, int ry, int c)
{
delete_part(x+i, y+j);
if(c!=0)
- create_part(-1, x+i, y+j, c);
+ create_part(-2, x+i, y+j, c);
}
}
return 1;
@@ -5156,7 +5188,7 @@ int create_parts(int x, int y, int rx, int ry, int c)
for(j=-ry; j<=ry; j++)
for(i=-rx; i<=rx; i++)
if((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx))
- if(create_part(-1, x+i, y+j, c)==-1)
+ if(create_part(-2, x+i, y+j, c)==-1)
f = 1;
return !f;
}