From def10c41ae4d77803527eb5490214f2893215adb Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Thu, 13 Jan 2011 13:12:21 +0000 Subject: [PATCH] Exaggerate convection, misc rearrangement + fixes --- includes/powder.h | 8 ++--- src/air.c | 46 +++++++++++++++++++++++++ src/elements/pyro.c | 2 +- src/main.c | 47 ------------------------- src/powder.c | 83 ++++++++++++++++++++++++--------------------- 5 files changed, 95 insertions(+), 91 deletions(-) diff --git a/includes/powder.h b/includes/powder.h index d3255eff4..55327bbca 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -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}, diff --git a/src/air.c b/src/air.c index b4ec97f8c..33a491376 100644 --- a/src/air.c +++ b/src/air.c @@ -33,6 +33,52 @@ void update_air(void) { int x, y, i, j; float dp, dx, dy, f, tx, ty; + for (i=0; i>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) && diff --git a/src/main.c b/src/main.c index fc0254627..55739afc5 100644 --- a/src/main.c +++ b/src/main.c @@ -1192,53 +1192,6 @@ int main(int argc, char *argv[]) while (!sdl_poll()) { - for (i=0; i=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-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]-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))