Yet more function pointers.

This commit is contained in:
jacksonmj 2011-01-08 00:07:10 +00:00
parent 9af0072b21
commit d17758cc08
10 changed files with 242 additions and 225 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
*.*.swp
.directory
powder.def
gmon.out
*.*.orig

View File

@ -221,7 +221,10 @@
#define PROP_RADIOACTIVE 0x2000 //8192 Radioactive
#define FLAG_STAGNANT 1
#define UPDATE_FUNC_ARGS int i, int x, int y, int nx, int ny, float lx, float ly
// TODO: which of these arguments are actually used?
#define UPDATE_FUNC_ARGS int i, int x, int y, int nx, int ny, float lx, float ly, int a
// to call another update function with same arguments:
#define UPDATE_FUNC_SUBCALL_ARGS i, x, y, nx, ny, lx, ly, a
int update_ACID(UPDATE_FUNC_ARGS);
int update_AMTR(UPDATE_FUNC_ARGS);
@ -244,6 +247,7 @@ int update_FUSE(UPDATE_FUNC_ARGS);
int update_FIRW(UPDATE_FUNC_ARGS);
int update_FWRK(UPDATE_FUNC_ARGS);
int update_GLOW(UPDATE_FUNC_ARGS);
int update_GOO(UPDATE_FUNC_ARGS);
int update_HSWC(UPDATE_FUNC_ARGS);
int update_IRON(UPDATE_FUNC_ARGS);
int update_ICEI(UPDATE_FUNC_ARGS);
@ -256,6 +260,7 @@ int update_PIPE(UPDATE_FUNC_ARGS);
int update_PLNT(UPDATE_FUNC_ARGS);
int update_PRTI(UPDATE_FUNC_ARGS);
int update_PRTO(UPDATE_FUNC_ARGS);
int update_PYRO(UPDATE_FUNC_ARGS);
int update_PUMP(UPDATE_FUNC_ARGS);
int update_RIME(UPDATE_FUNC_ARGS);
int update_SHLD1(UPDATE_FUNC_ARGS);
@ -364,15 +369,15 @@ static const part_type ptypes[PT_NUM] =
{"DUST", PIXPACK(0xFFE0A0), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 10, 0, 0, 30, 1, 85, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Very light dust. Flammable.", TYPE_PART, NULL},
{"WATR", PIXPACK(0x2030D0), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 30, SC_LIQUID, R_TEMP-2.0f +273.15f, 29, "Liquid. Conducts electricity. Freezes. Extinguishes fires.", TYPE_LIQUID|PROP_CONDUCTS|PROP_NEUTPENETRATE, &update_WATR},
{"OIL", PIXPACK(0x404010), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 20, 0, 0, 5, 1, 20, SC_LIQUID, R_TEMP+0.0f +273.15f, 42, "Liquid. Flammable.", TYPE_LIQUID, NULL},
{"FIRE", PIXPACK(0xFF1000), 0.9f, 0.04f * CFDS, 0.97f, 0.20f, 0.0f, -0.1f, 0.00f, 0.001f * CFDS, 1, 0, 0, 0, 1, 1, 2, SC_EXPLOSIVE, R_TEMP+400.0f+273.15f, 88, "Ignites flammable materials. Heats air.", TYPE_GAS, NULL},
{"FIRE", PIXPACK(0xFF1000), 0.9f, 0.04f * CFDS, 0.97f, 0.20f, 0.0f, -0.1f, 0.00f, 0.001f * CFDS, 1, 0, 0, 0, 1, 1, 2, SC_EXPLOSIVE, R_TEMP+400.0f+273.15f, 88, "Ignites flammable materials. Heats air.", TYPE_GAS, &update_PYRO},
{"STNE", PIXPACK(0xA0A0A0), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 5, 1, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 150, "Heavy particles. Meltable.", TYPE_PART, NULL},
{"LAVA", PIXPACK(0xE05010), 0.3f, 0.02f * CFDS, 0.95f, 0.80f, 0.0f, 0.15f, 0.00f, 0.0003f * CFDS, 2, 0, 0, 0, 2, 1, 45, SC_LIQUID, R_TEMP+1500.0f+273.15f, 60, "Heavy liquid. Ignites flammable materials. Solidifies when cold.", TYPE_LIQUID, NULL},
{"LAVA", PIXPACK(0xE05010), 0.3f, 0.02f * CFDS, 0.95f, 0.80f, 0.0f, 0.15f, 0.00f, 0.0003f * CFDS, 2, 0, 0, 0, 2, 1, 45, SC_LIQUID, R_TEMP+1500.0f+273.15f, 60, "Heavy liquid. Ignites flammable materials. Solidifies when cold.", TYPE_LIQUID, &update_PYRO},
{"GUN", PIXPACK(0xC0C0D0), 0.7f, 0.02f * CFDS, 0.94f, 0.80f, -0.1f, 0.1f, 0.00f, 0.000f * CFDS, 1, 600, 1, 0, 10, 1, 85, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 97, "Light dust. Explosive.", TYPE_PART, NULL},
{"NITR", PIXPACK(0x20E010), 0.5f, 0.02f * CFDS, 0.92f, 0.97f, 0.0f, 0.2f, 0.00f, 0.000f * CFDS, 2, 1000, 2, 0, 3, 1, 23, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 50, "Liquid. Pressure sensitive explosive.", TYPE_LIQUID, NULL},
{"CLNE", PIXPACK(0xFFD010), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 251, "Solid. Duplicates any particles it touches.", TYPE_SOLID, &update_CLNE},
{"GAS", PIXPACK(0xE0FF20), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 0.75f, 0.001f * CFDS, 0, 600, 0, 0, 1, 1, 1, SC_GAS, R_TEMP+2.0f +273.15f, 42, "Gas. Diffuses. Flammable. Liquifies under pressure.", TYPE_GAS, NULL},
{"C-4", PIXPACK(0xD080E0), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 1000, 2, 50, 1, 1, 100, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 88, "Solid. Pressure sensitive explosive.", TYPE_SOLID | PROP_NEUTPENETRATE, NULL},
{"GOO", PIXPACK(0x804000), 0.1f, 0.00f * CFDS, 0.97f, 0.50f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 12, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 75, "Solid. Deforms and disappears under pressure.", TYPE_SOLID | PROP_NEUTPENETRATE, NULL},
{"GOO", PIXPACK(0x804000), 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_SOLIDS, R_TEMP+0.0f +273.15f, 75, "Solid. Deforms and disappears under pressure.", TYPE_SOLID | PROP_NEUTPENETRATE, &update_GOO},
{"ICE", PIXPACK(0xA0C0FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, -0.0003f* CFDS, 0, 0, 0, 0, 20, 1, 100, SC_SOLIDS, R_TEMP-50.0f+273.15f, 46, "Solid. Freezes water. Crushes under pressure. Cools down air.", TYPE_SOLID, &update_ICEI},
{"METL", PIXPACK(0x404060), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Solid. Conducts electricity. Meltable.", TYPE_SOLID|PROP_CONDUCTS|PROP_HOT_GLOW, NULL},
{"SPRK", PIXPACK(0xFFFF80), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.001f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Electricity. Conducted by metal and water.", TYPE_SOLID, &update_SPRK},
@ -409,7 +414,7 @@ static const part_type ptypes[PT_NUM] =
{"PTCT", PIXPACK(0x405050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Semi-conductor. Only conducts electricity when cold (Less than 120C)", TYPE_SOLID|PROP_CONDUCTS, NULL},
{"BGLA", PIXPACK(0x606060), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 5, 2, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 150, "Broken Glass, Heavy particles. Meltable. Bagels.", TYPE_PART | PROP_HOT_GLOW, NULL},
{"THDR", PIXPACK(0xFFFFA0), 0.0f, 0.00f * CFDS, 1.0f, 0.30f, -0.99f, 0.6f, 0.62f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, SC_ELEC, 9000.0f +273.15f, 251, "Lightning! Very hot, inflicts damage upon most materials, transfers current to metals.", TYPE_ENERGY, &update_THDR},
{"PLSM", PIXPACK(0xBB99FF), 0.9f, 0.04f * CFDS, 0.97f, 0.20f, 0.0f, -0.1f, 0.30f, 0.001f * CFDS, 0, 0, 0, 0, 0, 1, 1, SC_GAS, 9000.0f +273.15f, 115, "Plasma, extremely hot.", TYPE_GAS, NULL},
{"PLSM", PIXPACK(0xBB99FF), 0.9f, 0.04f * CFDS, 0.97f, 0.20f, 0.0f, -0.1f, 0.30f, 0.001f * CFDS, 0, 0, 0, 0, 0, 1, 1, SC_GAS, 9000.0f +273.15f, 115, "Plasma, extremely hot.", TYPE_GAS, &update_PYRO},
{"ETRD", PIXPACK(0x404040), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Electrode. Creates a surface that allows Plasma arcs. (Use sparingly)", TYPE_SOLID|PROP_CONDUCTS, NULL},
{"NICE", PIXPACK(0xC0E0FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, -0.0005f* CFDS, 0, 0, 0, 0, 20, 1, 100, SC_SOLIDS, 35.0f, 46, "Nitrogen Ice.", TYPE_SOLID, NULL},
{"NBLE", PIXPACK(0xEB4917), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 0.75f, 0.001f * CFDS, 0, 0, 0, 0, 1, 1, 1, SC_GAS, R_TEMP+2.0f +273.15f, 106, "Noble Gas. Diffuses. Conductive. Ionizes into plasma when intruduced to electricity", TYPE_GAS|PROP_CONDUCTS, NULL},
@ -453,7 +458,7 @@ static const part_type ptypes[PT_NUM] =
{"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},
{"BCLN", PIXPACK(0xFFD040), 0.1f, 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},
{"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, NULL},
{"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},
{"WARP", PIXPACK(0x000000), 0.8f, 0.00f * CFDS, 0.9f, 0.70f, -0.1f, 0.0f, 3.00f, 0.000f * CFDS, 0, 0, 0, 0, 30, 1, 1, SC_NUCLEAR, R_TEMP +273.15f, 100, "Displaces other elements.",TYPE_GAS, &update_WARP},

View File

@ -1,6 +1,16 @@
#include <powder.h>
int update_BCLN(UPDATE_FUNC_ARGS) {
if (!parts[i].life)
{
if (pv[y/CELL][x/CELL]>4.0f)
{
float advection = 0.1f;
parts[i].vx += advection*vx[y/CELL][x/CELL];
parts[i].vy += advection*vy[y/CELL][x/CELL];
parts[i].life = rand()%40+80;
}
}
if (!parts[i].ctype)
{
for (nx=-1; nx<2; nx++)

View File

@ -1,7 +1,7 @@
#include <powder.h>
int update_FWRK(UPDATE_FUNC_ARGS) {
int r, a;
int r;
if ((parts[i].temp>400&&(9+parts[i].temp/40)>rand()%100000&&parts[i].life==0&&!pmap[y-1][x])||parts[i].ctype==PT_DUST)
{
create_part(-1, x , y-1 , PT_FWRK);
@ -35,16 +35,16 @@ int update_FWRK(UPDATE_FUNC_ARGS) {
{
create_part(-1, x+nx, y+ny , PT_DUST);
pv[y/CELL][x/CELL] += 2.00f*CFDS;
a= pmap[y+ny][x+nx];
if (parts[a>>8].type==PT_DUST)
r = pmap[y+ny][x+nx];
if (parts[r>>8].type==PT_DUST)
{
parts[a>>8].vy = -(rand()%10-1);
parts[a>>8].vx = ((rand()%2)*2-1)*rand()%(5+5)+(parts[i].vx)*2 ;
parts[a>>8].life= rand()%37+18;
parts[a>>8].tmp=q;
parts[a>>8].flags=w;
parts[a>>8].ctype=e;
parts[a>>8].temp= rand()%20+6000;
parts[r>>8].vy = -(rand()%10-1);
parts[r>>8].vx = ((rand()%2)*2-1)*rand()%(5+5)+(parts[i].vx)*2 ;
parts[r>>8].life= rand()%37+18;
parts[r>>8].tmp=q;
parts[r>>8].flags=w;
parts[r>>8].ctype=e;
parts[r>>8].temp= rand()%20+6000;
}
}
}

15
src/elements/goo.c Normal file
View File

@ -0,0 +1,15 @@
#include <powder.h>
int update_GOO(UPDATE_FUNC_ARGS) {
if (!parts[i].life)
{
if (pv[y/CELL][x/CELL]>1.0f)
{
float advection = 0.1f;
parts[i].vx += advection*vx[y/CELL][x/CELL];
parts[i].vy += advection*vy[y/CELL][x/CELL];
parts[i].life = rand()%80+300;
}
}
return 0;
}

View File

@ -1,7 +1,7 @@
#include <powder.h>
int update_NEUT(UPDATE_FUNC_ARGS) {
int r, fe;
int r;
int rt = 3 + (int)pv[y/CELL][x/CELL];
for (nx=-1; nx<2; nx++)
for (ny=-1; ny<2; ny++)
@ -34,7 +34,7 @@ int update_NEUT(UPDATE_FUNC_ARGS) {
parts[r>>8].vy = 0.25f*parts[r>>8].vy + parts[i].vy;
}
pv[y/CELL][x/CELL] += 10.0f * CFDS; //Used to be 2, some people said nukes weren't powerful enough
fe ++;
update_PYRO(UPDATE_FUNC_SUBCALL_ARGS);
}
if ((r&0xFF)==PT_DEUT && (rt+1)>(rand()%1000))
{

View File

@ -1,6 +1,7 @@
#include <powder.h>
int update_PHOT(UPDATE_FUNC_ARGS) {
if (1>rand()%10) update_PYRO(UPDATE_FUNC_SUBCALL_ARGS);
// TODO
return 0;

99
src/elements/pyro.c Normal file
View File

@ -0,0 +1,99 @@
#include <powder.h>
int update_PYRO(UPDATE_FUNC_ARGS) {
int r, rt, lpv, t = parts[i].type;
if (t==PT_PLSM&&parts[i].ctype == PT_NBLE&&parts[i].life <=1)
{
parts[i].type = PT_NBLE;
parts[i].life = 0;
}
if (t==PT_FIRE && parts[i].life <=1 && parts[i].temp<625)
{
t = parts[i].type = PT_SMKE;
parts[i].life = rand()%20+250;
}
for (nx=-2; nx<3; nx++)
for (ny=-2; ny<3; ny++)
if (x+nx>=0 && y+ny>0 &&
x+nx<XRES && y+ny<YRES && (nx || ny))
{
r = pmap[y+ny][x+nx];
if ((r>>8)>=NPART || !r)
continue;
if (bmap[(y+ny)/CELL][(x+nx)/CELL] && bmap[(y+ny)/CELL][(x+nx)/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)) &&
!(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) &&
ptypes[rt].flammable && (ptypes[rt].flammable + (int)(pv[(y+ny)/CELL][(x+nx)/CELL]*10.0f))>(rand()%1000))
{
parts[r>>8].type = PT_FIRE;
parts[r>>8].temp = ptypes[PT_FIRE].heat + (ptypes[rt].flammable/2);
parts[r>>8].life = rand()%80+180;
if (ptypes[rt].explosive)
pv[y/CELL][x/CELL] += 0.25f * CFDS;
continue;
}
lpv = (int)pv[(y+ny)/CELL][(x+nx)/CELL];
if (lpv < 1) lpv = 1;
if (legacy_enable)
{
if (t!=PT_SPRK && ptypes[rt].meltable && ((rt!=PT_RBDM && rt!=PT_LRBD) || t!=PT_SPRK) && ((t!=PT_FIRE&&t!=PT_PLSM) || (rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SALT && rt!=PT_INWR)) &&
ptypes[rt].meltable*lpv>(rand()%1000))
{
if (t!=PT_LAVA || parts[i].life>0)
{
parts[r>>8].ctype = (parts[r>>8].type==PT_BRMT)?PT_BMTL:parts[r>>8].type;
parts[r>>8].ctype = (parts[r>>8].ctype==PT_SAND)?PT_GLAS:parts[r>>8].ctype;
parts[r>>8].type = PT_LAVA;
parts[r>>8].life = rand()%120+240;
}
else
{
parts[i].life = 0;
t = parts[i].type = (parts[i].ctype)?parts[i].ctype:PT_STNE;
parts[i].ctype = PT_NONE;//rt;
return 1;
}
}
if (t!=PT_SPRK && (rt==PT_ICEI || rt==PT_SNOW))
{
parts[r>>8].type = PT_WATR;
if (t==PT_FIRE)
{
parts[i].x = lx;
parts[i].y = ly;
kill_part(i);
return 1;
}
if (t==PT_LAVA)
{
parts[i].life = 0;
t = parts[i].type = PT_STNE;
return 1;
}
}
if (t!=PT_SPRK && (rt==PT_WATR || rt==PT_DSTW || rt==PT_SLTW))
{
kill_part(r>>8);
if (t==PT_FIRE)
{
parts[i].x = lx;
parts[i].y = ly;
kill_part(i);
return 1;
}
if (t==PT_LAVA)
{
parts[i].life = 0;
t = parts[i].type = (parts[i].ctype)?parts[i].ctype:PT_STNE;
parts[i].ctype = PT_NONE;
return 1;
}
}
}
}
return 0;
}

View File

@ -1,6 +1,7 @@
#include <powder.h>
int update_SPRK(UPDATE_FUNC_ARGS) {
update_PYRO(UPDATE_FUNC_SUBCALL_ARGS);
int r, rt, conduct_sprk, nearp, pavg, ct = parts[i].ctype;
if (parts[i].life<=0)
{

View File

@ -1347,7 +1347,7 @@ void update_particles_i(pixel *vid, int start, int inc)
pv[y/CELL+1][x/CELL+1] += ptypes[t].hotair*(3.5f-pv[y/CELL+1][x/CELL+1]);
}
}
else if (ptypes[t].hotair)
else
{
pv[y/CELL][x/CELL] += ptypes[t].hotair;
if (y+CELL<YRES)
@ -1372,49 +1372,30 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[i].vx *= ptypes[t].loss;
parts[i].vy *= ptypes[t].loss;
if ((t==PT_GOO) && !parts[i].life)
//Gravity mode by Moach
switch (gravityMode)
{
if (pv[y/CELL][x/CELL]>1.0f)
{
parts[i].vx += ptypes[t].advection*vx[y/CELL][x/CELL];
parts[i].vy += ptypes[t].advection*vy[y/CELL][x/CELL];
parts[i].life = rand()%80+300;
}
default:
case 0:
pGravX = pGravY = 0.0f;
break;
case 1:
pGravX = 0.0f;
pGravY = ptypes[t].gravity;
break;
case 2:
pGravD = 0.01f - hypotf((x - XCNTR), (y - YCNTR));
pGravX = ptypes[t].gravity * ((float)(x - XCNTR) / pGravD);
pGravY = ptypes[t].gravity * ((float)(y - YCNTR) / pGravD);
}
else if ((t==PT_BCLN) && !parts[i].life)
{
if (pv[y/CELL][x/CELL]>4.0f)
{
parts[i].vx += ptypes[t].advection*vx[y/CELL][x/CELL];
parts[i].vy += ptypes[t].advection*vy[y/CELL][x/CELL];
parts[i].life = rand()%40+80;
}
}
else
{
//Gravity mode by Moach
switch (gravityMode)
{
default:
case 0:
pGravX = pGravY = 0.0f;
break;
case 1:
pGravX = 0.0f;
pGravY = ptypes[t].gravity;
break;
case 2:
pGravD = 0.01f - hypotf((x - XCNTR), (y - YCNTR));
parts[i].vx += ptypes[t].advection*vx[y/CELL][x/CELL] + pGravX;
parts[i].vy += ptypes[t].advection*vy[y/CELL][x/CELL] + pGravY;
pGravX = ptypes[t].gravity * ((float)(x - XCNTR) / pGravD);
pGravY = ptypes[t].gravity * ((float)(y - YCNTR) / pGravD);
}
parts[i].vx += ptypes[t].advection*vx[y/CELL][x/CELL] + pGravX;
parts[i].vy += ptypes[t].advection*vy[y/CELL][x/CELL] + pGravY;
}
if (ptypes[t].diffusion)
{
@ -1478,73 +1459,6 @@ void update_particles_i(pixel *vid, int start, int inc)
if ((pmap[y+ny][x+nx]&0xFF)!=t)
nt = 1;
}
if (legacy_enable)
{
if (t==PT_WTRV && pv[y/CELL][x/CELL]>4.0f)
t = parts[i].type = PT_DSTW;
if (t==PT_OIL && pv[y/CELL][x/CELL]<-6.0f)
t = parts[i].type = PT_GAS;
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;
}
}
s = 1;
if (pv[y/CELL][x/CELL]>ptransitions[t].phv&&ptransitions[t].pht>-1) {
if (ptransitions[t].pht!=PT_NUM)
t = ptransitions[t].pht;
else if (t==PT_BMTL) {
if (pv[y/CELL][x/CELL]>2.5f)
t = PT_BRMT;
else if (pv[y/CELL][x/CELL]>1.0f && parts[i].tmp==1)
t = PT_BRMT;
else s = 0;
}
else s = 0;
} else if (pv[y/CELL][x/CELL]<ptransitions[t].plv&&ptransitions[t].plt>-1) {
if (ptransitions[t].plt!=PT_NUM)
t = ptransitions[t].plt;
else s = 0;
}
else s = 0;
if (s) {
parts[i].type = t;
if (t==PT_FIRE)
parts[i].life = rand()%50+120;
if (t==PT_NONE) {
kill_part(i);
goto killed;
}
}
if (t==PT_GLAS)
{
parts[i].pavg[0] = parts[i].pavg[1];
parts[i].pavg[1] = pv[y/CELL][x/CELL];
if (parts[i].pavg[1]-parts[i].pavg[0] > 0.25f || parts[i].pavg[1]-parts[i].pavg[0] < -0.25f)
{
parts[i].type = PT_BGLA;
}
}
if (t==PT_QRTZ)
{
parts[i].pavg[0] = parts[i].pavg[1];
parts[i].pavg[1] = pv[y/CELL][x/CELL];
if (parts[i].pavg[1]-parts[i].pavg[0] > 0.05*(parts[i].temp/3) || parts[i].pavg[1]-parts[i].pavg[0] < -0.05*(parts[i].temp/3))
{
parts[i].type = PT_PQRT;
}
}
if (t==PT_PLUT && 1>rand()%100 && ((int)(5.0f*pv[y/CELL][x/CELL]))>(rand()%1000))
{
t = PT_NEUT;
create_part(i, x, y, t);
}
if (!legacy_enable)
{
int ctemp = pv[y/CELL][x/CELL]*2;
@ -1726,7 +1640,72 @@ void update_particles_i(pixel *vid, int start, int inc)
if (bmap[ny][nx]==WL_DETECT && emap[ny][nx]<8)
set_emap(nx, ny);
fe = 0;
s = 1;
if (pv[y/CELL][x/CELL]>ptransitions[t].phv&&ptransitions[t].pht>-1) {
if (ptransitions[t].pht!=PT_NUM)
t = ptransitions[t].pht;
else if (t==PT_BMTL) {
if (pv[y/CELL][x/CELL]>2.5f)
t = PT_BRMT;
else if (pv[y/CELL][x/CELL]>1.0f && parts[i].tmp==1)
t = PT_BRMT;
else s = 0;
}
else s = 0;
} else if (pv[y/CELL][x/CELL]<ptransitions[t].plv&&ptransitions[t].plt>-1) {
if (ptransitions[t].plt!=PT_NUM)
t = ptransitions[t].plt;
else s = 0;
}
else s = 0;
if (s) {
parts[i].type = t;
if (t==PT_FIRE)
parts[i].life = rand()%50+120;
if (t==PT_NONE) {
kill_part(i);
goto killed;
}
}
if (legacy_enable)
{
if (t==PT_WTRV && pv[y/CELL][x/CELL]>4.0f)
t = parts[i].type = PT_DSTW;
if (t==PT_OIL && pv[y/CELL][x/CELL]<-6.0f)
t = parts[i].type = PT_GAS;
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_GLAS)
{
parts[i].pavg[0] = parts[i].pavg[1];
parts[i].pavg[1] = pv[y/CELL][x/CELL];
if (parts[i].pavg[1]-parts[i].pavg[0] > 0.25f || parts[i].pavg[1]-parts[i].pavg[0] < -0.25f)
{
parts[i].type = PT_BGLA;
}
}
if (t==PT_QRTZ)
{
parts[i].pavg[0] = parts[i].pavg[1];
parts[i].pavg[1] = pv[y/CELL][x/CELL];
if (parts[i].pavg[1]-parts[i].pavg[0] > 0.05*(parts[i].temp/3) || parts[i].pavg[1]-parts[i].pavg[0] < -0.05*(parts[i].temp/3))
{
parts[i].type = PT_PQRT;
}
}
if (t==PT_PLUT && 1>rand()%100 && ((int)(5.0f*pv[y/CELL][x/CELL]))>(rand()%1000))
{
t = PT_NEUT;
create_part(i, x, y, t);
}
if (t==PT_PHOT)
{
@ -1796,104 +1775,6 @@ void update_particles_i(pixel *vid, int start, int inc)
ISLOLZ=1;
else if (t==PT_GRAV)
ISGRAV=1;
if (t==PT_FIRE || t==PT_PLSM || t==PT_LAVA || t==PT_SPRK || fe || (t==PT_PHOT&&(1>rand()%10)))
{
for (nx=-2; nx<3; nx++)
for (ny=-2; ny<3; ny++)
if (x+nx>=0 && y+ny>0 &&
x+nx<XRES && y+ny<YRES && (nx || ny))
{
r = pmap[y+ny][x+nx];
if ((r>>8)>=NPART || !r)
continue;
if (bmap[(y+ny)/CELL][(x+nx)/CELL] && bmap[(y+ny)/CELL][(x+nx)/CELL]!=WL_STREAM)
continue;
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_QRTZ)) && !(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;
parts[r>>8].temp = ptypes[PT_FIRE].heat + (ptypes[rt].flammable/2);
parts[r>>8].life = rand()%80+180;
if (ptypes[rt].explosive)
pv[y/CELL][x/CELL] += 0.25f * CFDS;
continue;
}
lpv = (int)pv[(y+ny)/CELL][(x+nx)/CELL];
if (lpv < 1) lpv = 1;
if (legacy_enable)
{
if (t!=PT_SPRK && ptypes[rt].meltable && ((rt!=PT_RBDM && rt!=PT_LRBD) || t!=PT_SPRK) && ((t!=PT_FIRE&&t!=PT_PLSM) || (rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SALT && rt!=PT_INWR)) &&
ptypes[rt].meltable*lpv>(rand()%1000))
{
if (t!=PT_LAVA || parts[i].life>0)
{
parts[r>>8].ctype = (parts[r>>8].type==PT_BRMT)?PT_BMTL:parts[r>>8].type;
parts[r>>8].ctype = (parts[r>>8].ctype==PT_SAND)?PT_GLAS:parts[r>>8].ctype;
parts[r>>8].type = PT_LAVA;
parts[r>>8].life = rand()%120+240;
}
else
{
parts[i].life = 0;
t = parts[i].type = (parts[i].ctype)?parts[i].ctype:PT_STNE;
parts[i].ctype = PT_NONE;//rt;
goto killed;
}
}
if (t!=PT_SPRK && (rt==PT_ICEI || rt==PT_SNOW))
{
parts[r>>8].type = PT_WATR;
if (t==PT_FIRE)
{
parts[i].x = lx;
parts[i].y = ly;
kill_part(i);
goto killed;
}
if (t==PT_LAVA)
{
parts[i].life = 0;
t = parts[i].type = PT_STNE;
goto killed;
}
}
if (t!=PT_SPRK && (rt==PT_WATR || rt==PT_DSTW || rt==PT_SLTW))
{
kill_part(r>>8);
if (t==PT_FIRE)
{
parts[i].x = lx;
parts[i].y = ly;
kill_part(i);
goto killed;
}
if (t==PT_LAVA)
{
parts[i].life = 0;
t = parts[i].type = (parts[i].ctype)?parts[i].ctype:PT_STNE;
parts[i].ctype = PT_NONE;
goto killed;
}
}
}
}
killed:
if (parts[i].type == PT_NONE)
continue;
}
if (t==PT_PLSM&&parts[i].ctype == PT_NBLE&&parts[i].life <=1)
{
parts[i].type = PT_NBLE;
parts[i].life = 0;
}
if (t==PT_FIRE && parts[i].life <=1 && parts[i].temp<625)
{
t = parts[i].type = PT_SMKE;
parts[i].life = rand()%20+250;
}
nx = (int)(parts[i].x+0.5f);
ny = (int)(parts[i].y+0.5f);
@ -1909,10 +1790,14 @@ killed:
if (ptypes[t].update_func)
{
if ((*(ptypes[t].update_func))(i,x,y,nx,ny,lx,ly))
if ((*(ptypes[t].update_func))(i,x,y,nx,ny,lx,ly,a))
continue;
}
killed:
if (parts[i].type == PT_NONE)
continue;
if (parts[i].type == PT_PHOT) {
rt = pmap[ny][nx] & 0xFF;