Exaggerate convection, misc rearrangement + fixes

This commit is contained in:
jacksonmj 2011-01-13 13:12:21 +00:00
parent daa6af0cc2
commit def10c41ae
5 changed files with 95 additions and 91 deletions

View File

@ -222,9 +222,9 @@
#define PROP_RADIOACTIVE 0x2000 //8192 Radioactive
#define FLAG_STAGNANT 1
#define UPDATE_FUNC_ARGS int i, int x, int y, int a
#define UPDATE_FUNC_ARGS int i, int x, int y, int surround_space
// to call another update function with same arguments:
#define UPDATE_FUNC_SUBCALL_ARGS i, x, y, a
#define UPDATE_FUNC_SUBCALL_ARGS i, x, y, surround_space
int update_ACID(UPDATE_FUNC_ARGS);
int update_AMTR(UPDATE_FUNC_ARGS);
@ -461,8 +461,8 @@ static const part_type ptypes[PT_NUM] =
{"LLIF", PIXPACK(0x505050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Long Life! B345/S5", TYPE_SOLID|PROP_LIFE, NULL},
{"STAN", PIXPACK(0x5000FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Stains! B3678/S235678", TYPE_SOLID|PROP_LIFE, NULL},
{"SPNG", PIXPACK(0xFFBE30), 0.00f, 0.00f * CFDS, 0.00f, 1.00f, 0.00f, 0.0f, 0.00f, 0.000f * CFDS, 0, 20, 0, 1, 30, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "A sponge, absorbs water.",TYPE_SOLID, &update_SPNG},
{"RIME", PIXPACK(0xCCCCCC), 0.00f, 0.00f * CFDS, 0.00f, 1.00f, 0.00f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 30, 1, 100, SC_CRACKER2, 243.15f, 100, "Not quite Ice",TYPE_SOLID, &update_FOG},
{"FOG", PIXPACK(0xAAAAAA), 0.8f, 0.00f * CFDS, 0.4f, 0.70f, -0.1f, 0.0f, 0.99f, 0.000f * CFDS, 0, 0, 0, 0, 30, 1, 1, SC_CRACKER2, 243.15f, 100, "Not quite Steam",TYPE_GAS, &update_RIME},
{"RIME", PIXPACK(0xCCCCCC), 0.00f, 0.00f * CFDS, 0.00f, 1.00f, 0.00f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 30, 1, 100, SC_CRACKER2, 243.15f, 100, "Not quite Ice",TYPE_SOLID, &update_RIME},
{"FOG", PIXPACK(0xAAAAAA), 0.8f, 0.00f * CFDS, 0.4f, 0.70f, -0.1f, 0.0f, 0.99f, 0.000f * CFDS, 0, 0, 0, 0, 30, 1, 1, SC_CRACKER2, 243.15f, 100, "Not quite Steam",TYPE_GAS, &update_FOG},
{"BCLN", PIXPACK(0xFFD040), 0.0f, 0.00f * CFDS, 0.97f, 0.50f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 12, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 251, "Breakable Clone.", TYPE_SOLID, &update_BCLN},
{"LOVE", PIXPACK(0xFF30FF), 0.0f, 0.00f * CFDS, 0.00f, 0.00f, 0.0f, 0.0f, 0.0f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_CRACKER2, 373.0f, 40, "Love...", TYPE_SOLID, &update_MISC},
{"DEUT", PIXPACK(0x00153F), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 31, SC_NUCLEAR, R_TEMP-2.0f +273.15f, 251, "Deuterium oxide. Volume changes with temp, radioactive with neutrons.", TYPE_LIQUID|PROP_NEUTPENETRATE, &update_DEUT},

View File

@ -33,6 +33,52 @@ void update_air(void)
{
int x, y, i, j;
float dp, dx, dy, f, tx, ty;
for (i=0; i<YRES/CELL; i++)
{
pv[i][0] = pv[i][0]*0.8f;
pv[i][1] = pv[i][1]*0.8f;
pv[i][2] = pv[i][2]*0.8f;
pv[i][XRES/CELL-2] = pv[i][XRES/CELL-2]*0.8f;
pv[i][XRES/CELL-1] = pv[i][XRES/CELL-1]*0.8f;
vx[i][0] = vx[i][1]*0.9f;
vx[i][1] = vx[i][2]*0.9f;
vx[i][XRES/CELL-2] = vx[i][XRES/CELL-3]*0.9f;
vx[i][XRES/CELL-1] = vx[i][XRES/CELL-2]*0.9f;
vy[i][0] = vy[i][1]*0.9f;
vy[i][1] = vy[i][2]*0.9f;
vy[i][XRES/CELL-2] = vy[i][XRES/CELL-3]*0.9f;
vy[i][XRES/CELL-1] = vy[i][XRES/CELL-2]*0.9f;
}
for (i=0; i<XRES/CELL; i++)
{
pv[0][i] = pv[0][i]*0.8f;
pv[1][i] = pv[1][i]*0.8f;
pv[2][i] = pv[2][i]*0.8f;
pv[YRES/CELL-2][i] = pv[YRES/CELL-2][i]*0.8f;
pv[YRES/CELL-1][i] = pv[YRES/CELL-1][i]*0.8f;
vx[0][i] = vx[1][i]*0.9f;
vx[1][i] = vx[2][i]*0.9f;
vx[YRES/CELL-2][i] = vx[YRES/CELL-3][i]*0.9f;
vx[YRES/CELL-1][i] = vx[YRES/CELL-2][i]*0.9f;
vy[0][i] = vy[1][i]*0.9f;
vy[1][i] = vy[2][i]*0.9f;
vy[YRES/CELL-2][i] = vy[YRES/CELL-3][i]*0.9f;
vy[YRES/CELL-1][i] = vy[YRES/CELL-2][i]*0.9f;
}
for (j=1; j<YRES/CELL; j++)
{
for (i=1; i<XRES/CELL; i++)
{
if (bmap[j][i]==WL_WALL || bmap[j][i]==WL_WALLELEC || (bmap[j][i]==WL_EWALL && !emap[j][i]))
{
vx[j][i] = 0.0f;
vx[j][i-1] = 0.0f;
vy[j][i] = 0.0f;
vy[j-1][i] = 0.0f;
}
}
}
for (y=1; y<YRES/CELL; y++)
for (x=1; x<XRES/CELL; x++)

View File

@ -24,7 +24,7 @@ int update_PYRO(UPDATE_FUNC_ARGS) {
if (bmap[(y+ry)/CELL][(x+rx)/CELL] && bmap[(y+ry)/CELL][(x+rx)/CELL]!=WL_STREAM)
continue;
rt = parts[r>>8].type;
if ((a || ptypes[rt].explosive) && (t!=PT_SPRK || (rt!=PT_RBDM && rt!=PT_LRBD && rt!=PT_INSL && rt!=PT_SWCH)) &&
if ((surround_space || ptypes[rt].explosive) && (t!=PT_SPRK || (rt!=PT_RBDM && rt!=PT_LRBD && rt!=PT_INSL && rt!=PT_SWCH)) &&
!(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_QRTZ))
&& !(rt==PT_SPNG && parts[r>>8].life>0) &&

View File

@ -1192,53 +1192,6 @@ int main(int argc, char *argv[])
while (!sdl_poll())
{
for (i=0; i<YRES/CELL; i++)
{
pv[i][0] = pv[i][0]*0.8f;
pv[i][1] = pv[i][1]*0.8f;
pv[i][2] = pv[i][2]*0.8f;
pv[i][XRES/CELL-2] = pv[i][XRES/CELL-2]*0.8f;
pv[i][XRES/CELL-1] = pv[i][XRES/CELL-1]*0.8f;
vx[i][0] = vx[i][1]*0.9f;
vx[i][1] = vx[i][2]*0.9f;
vx[i][XRES/CELL-2] = vx[i][XRES/CELL-3]*0.9f;
vx[i][XRES/CELL-1] = vx[i][XRES/CELL-2]*0.9f;
vy[i][0] = vy[i][1]*0.9f;
vy[i][1] = vy[i][2]*0.9f;
vy[i][XRES/CELL-2] = vy[i][XRES/CELL-3]*0.9f;
vy[i][XRES/CELL-1] = vy[i][XRES/CELL-2]*0.9f;
}
for (i=0; i<XRES/CELL; i++)
{
pv[0][i] = pv[0][i]*0.8f;
pv[1][i] = pv[1][i]*0.8f;
pv[2][i] = pv[2][i]*0.8f;
pv[YRES/CELL-2][i] = pv[YRES/CELL-2][i]*0.8f;
pv[YRES/CELL-1][i] = pv[YRES/CELL-1][i]*0.8f;
vx[0][i] = vx[1][i]*0.9f;
vx[1][i] = vx[2][i]*0.9f;
vx[YRES/CELL-2][i] = vx[YRES/CELL-3][i]*0.9f;
vx[YRES/CELL-1][i] = vx[YRES/CELL-2][i]*0.9f;
vy[0][i] = vy[1][i]*0.9f;
vy[1][i] = vy[2][i]*0.9f;
vy[YRES/CELL-2][i] = vy[YRES/CELL-3][i]*0.9f;
vy[YRES/CELL-1][i] = vy[YRES/CELL-2][i]*0.9f;
}
for (j=1; j<YRES/CELL; j++)
{
for (i=1; i<XRES/CELL; i++)
{
if (bmap[j][i]==WL_WALL || bmap[j][i]==WL_WALLELEC || (bmap[j][i]==WL_EWALL && !emap[j][i]))
{
vx[j][i] = 0.0f;
vx[j][i-1] = 0.0f;
vy[j][i] = 0.0f;
vy[j-1][i] = 0.0f;
}
}
}
if (!sys_pause||framerender)
{
update_air();

View File

@ -1094,14 +1094,14 @@ int nearest_part(int ci, int t)
void update_particles_i(pixel *vid, int start, int inc)
{
int i, j, x, y, t, nx, ny, r, a, s, lt, rt, fe, nt, lpv, nearp, pavg, nnx, nny, q, golnum, goldelete, z, ctype, temp, trade, docontinue, nxx, nyy, nxi, nyi, ct, conduct_sprk;
float mv, dx, dy, ix, iy, lx, ly, d, pp, nrx, nry, dp, rr, rrr;
int i, j, x, y, t, nx, ny, r, surround_space, s, lt, rt, nt, nnx, nny, q, golnum, goldelete, z;
float mv, dx, dy, ix, iy, lx, ly, nrx, nry, dp;
float nn, ct1, ct2;
float pt = R_TEMP;
float c_heat = 0.0f;
int h_count = 0;
int starti = (start*-1);
int surround[24];
int surround[8];
int surround_hconduct[8];
float pGravX, pGravY, pGravD;
@ -1341,7 +1341,8 @@ void update_particles_i(pixel *vid, int start, int inc)
if (x<CELL || y<CELL || x>=XRES-CELL || y>=YRES-CELL ||
((bmap[y/CELL][x/CELL]==WL_WALL ||
(bmap[y/CELL][x/CELL] &&
(bmap[y/CELL][x/CELL]==WL_WALL ||
bmap[y/CELL][x/CELL]==WL_WALLELEC ||
bmap[y/CELL][x/CELL]==WL_ALLOWAIR ||
(bmap[y/CELL][x/CELL]==WL_DESTROYALL) ||
@ -1387,19 +1388,6 @@ void update_particles_i(pixel *vid, int start, int inc)
}
}
if ((ptypes[t].explosive&2) && pv[y/CELL][x/CELL]>2.5f)
{
parts[i].life = rand()%80+180;
parts[i].temp = restrict_flt(ptypes[PT_FIRE].heat + (ptypes[t].flammable/2), MIN_TEMP, MAX_TEMP);
t = PT_FIRE;
part_change_type(i,x,y,t);
pv[y/CELL][x/CELL] += 0.25f * CFDS;
}
parts[i].vx *= ptypes[t].loss;
parts[i].vy *= ptypes[t].loss;
//Gravity mode by Moach
switch (gravityMode)
{
@ -1420,6 +1408,9 @@ void update_particles_i(pixel *vid, int start, int inc)
}
parts[i].vx *= ptypes[t].loss;
parts[i].vy *= ptypes[t].loss;
parts[i].vx += ptypes[t].advection*vx[y/CELL][x/CELL] + pGravX;
parts[i].vy += ptypes[t].advection*vy[y/CELL][x/CELL] + pGravY;
@ -1430,7 +1421,7 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[i].vy += ptypes[t].diffusion*(rand()/(0.5f*RAND_MAX)-1.0f);
}
j = a = nt = 0;
j = surround_space = nt = 0;
for (nx=-1; nx<2; nx++)
for (ny=-1; ny<2; ny++) {
if (nx||ny) {
@ -1439,7 +1430,7 @@ void update_particles_i(pixel *vid, int start, int inc)
if (!bmap[(y+ny)/CELL][(x+nx)/CELL] || bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_STREAM)
{
if (!(r&0xFF))
a = 1;
surround_space = 1;
if ((r&0xFF)!=t)
nt = 1;
}
@ -1448,13 +1439,25 @@ void update_particles_i(pixel *vid, int start, int inc)
if (!legacy_enable)
{
if (y-2 >= 0 && y-2 < YRES && (ptypes[t].properties&TYPE_LIQUID)) {
float swappage;
r = pmap[y-2][x];
if (!((r>>8)>=NPART || !r || parts[i].type != (r&0xFF))) {
if (parts[i].temp>parts[r>>8].temp) {
swappage = parts[i].temp;
parts[i].temp = parts[r>>8].temp;
parts[r>>8].temp = swappage;
}
}
}
c_heat = 0.0f;
h_count = 0;
if (t&&(t!=PT_HSWC||parts[i].life==10)&&ptypes[t].hconduct>(rand()%250))
{
for (j=0; j<8; j++)
{
surround_hconduct[j] = -1;
surround_hconduct[j] = i;
r = surround[j];
if ((r>>8)>=NPART || !r)
continue;
@ -1472,24 +1475,12 @@ void update_particles_i(pixel *vid, int start, int inc)
pt = parts[i].temp = (c_heat+parts[i].temp)/(h_count+1);
for (j=0; j<8; j++)
{
if (surround_hconduct[j]>=0)
parts[surround_hconduct[j]].temp = pt;
}
if (y-2 >= 0 && y-2 < YRES && ptypes[t].properties&TYPE_LIQUID) {
float swappage;
r = pmap[y-2][x];
if (!((r>>8)>=NPART || !r || parts[i].type != (r&0xFF))) {
if (parts[i].temp>parts[r>>8].temp) {
swappage = parts[i].temp;
parts[i].temp = parts[r>>8].temp;
parts[r>>8].temp = swappage;
}
}
parts[surround_hconduct[j]].temp = pt;
}
s = 1;
if (pt>ptransitions[t].thv&&ptransitions[t].tht>-1) {
// particle type change due to high temperature
if (ptransitions[t].tht!=PT_NUM)
t = ptransitions[t].tht;
else if (t==PT_ICEI) {
@ -1510,6 +1501,7 @@ void update_particles_i(pixel *vid, int start, int inc)
}
else s = 0;
} else if (pt<ptransitions[t].tlv&&ptransitions[t].tlt>-1) {
// particle type change due to low temperature
if (ptransitions[t].tlt!=PT_NUM)
t = ptransitions[t].tlt;
else if (t==PT_WTRV) {
@ -1541,7 +1533,7 @@ void update_particles_i(pixel *vid, int start, int inc)
if (s) parts[i].life = 0;
}
else s = 0;
if (s) {
if (s) { // particle type change occurred
if (t==PT_ICEI||t==PT_LAVA)
parts[i].ctype = parts[i].type;
if (pstates[t].state==ST_GAS&&pstates[parts[i].type].state!=ST_GAS)
@ -1617,8 +1609,20 @@ void update_particles_i(pixel *vid, int start, int inc)
}
}
if ((ptypes[t].explosive&2) && pv[y/CELL][x/CELL]>2.5f)
{
parts[i].life = rand()%80+180;
parts[i].temp = restrict_flt(ptypes[PT_FIRE].heat + (ptypes[t].flammable/2), MIN_TEMP, MAX_TEMP);
t = PT_FIRE;
part_change_type(i,x,y,t);
pv[y/CELL][x/CELL] += 0.25f * CFDS;
}
s = 1;
if (pv[y/CELL][x/CELL]>ptransitions[t].phv&&ptransitions[t].pht>-1) {
// particle type change due to high pressure
if (ptransitions[t].pht!=PT_NUM)
t = ptransitions[t].pht;
else if (t==PT_BMTL) {
@ -1630,12 +1634,13 @@ void update_particles_i(pixel *vid, int start, int inc)
}
else s = 0;
} else if (pv[y/CELL][x/CELL]<ptransitions[t].plv&&ptransitions[t].plt>-1) {
// particle type change due to low pressure
if (ptransitions[t].plt!=PT_NUM)
t = ptransitions[t].plt;
else s = 0;
}
else s = 0;
if (s) {
if (s) { // particle type change occurred
parts[i].type = t;
if (t==PT_FIRE)
parts[i].life = rand()%50+120;
@ -1647,11 +1652,11 @@ void update_particles_i(pixel *vid, int start, int inc)
if (ptypes[t].update_func)
{
if ((*(ptypes[t].update_func))(i,x,y,a))
if ((*(ptypes[t].update_func))(i,x,y,surround_space))
continue;
}
if (legacy_enable)
update_legacy_all(i,x,y,a);
update_legacy_all(i,x,y,surround_space);
killed:
if (parts[i].type == PT_NONE)
@ -1752,7 +1757,7 @@ killed:
}
}
// TODO: some particles use flags for unrelated purposes
// TODO: some particles (pipe, fwrk) use flags for unrelated purposes
rt = parts[i].flags & FLAG_STAGNANT;
parts[i].flags &= ~FLAG_STAGNANT;
if (!try_move(i, x, y, nx, ny))