VOID, VACU, and BHOL eat LIGH as it moves

This commit is contained in:
jacob1
2013-01-05 22:29:33 -05:00
parent 8f4d936de8
commit 0cf027c529

View File

@@ -285,14 +285,33 @@ int Element_LIGH::contact_part(Simulation * sim, int i, int tp)
return -1; return -1;
} }
//#TPT-Directive ElementHeader Element_LIGH static bool create_LIGH(Simulation * sim, int x, int y, int c, int temp, int life, int tmp, int tmp2)
bool Element_LIGH::create_LIGH(Simulation * sim, int x, int y, int c, int temp, int life, int tmp, int tmp2)
{
int p = sim->create_part(-1, x, y,c);
if (p != -1)
{
sim->parts[p].life = life;
sim->parts[p].temp = temp;
sim->parts[p].tmp = tmp;
sim->parts[p].tmp2 = tmp2;
}
else
{
int r = sim->pmap[y][x];
if ((((r&0xFF)==PT_VOID || ((r&0xFF)==PT_PVOD && sim->parts[r>>8].life >= 10)) && (!sim->parts[r>>8].ctype || (sim->parts[r>>8].ctype==c)!=(sim->parts[r>>8].tmp&1))) || (r&0xFF)==PT_BHOL || (r&0xFF)==PT_NBHL) // VOID, PVOD, VACU, and BHOL eat LIGH here
return true;
}
return false;
}
//#TPT-Directive ElementHeader Element_LIGH static void create_line_par(Simulation * sim, int x1, int y1, int x2, int y2, int c, int temp, int life, int tmp, int tmp2) //#TPT-Directive ElementHeader Element_LIGH static void create_line_par(Simulation * sim, int x1, int y1, int x2, int y2, int c, int temp, int life, int tmp, int tmp2)
void Element_LIGH::create_line_par(Simulation * sim, int x1, int y1, int x2, int y2, int c, int temp, int life, int tmp, int tmp2) void Element_LIGH::create_line_par(Simulation * sim, int x1, int y1, int x2, int y2, int c, int temp, int life, int tmp, int tmp2)
{ {
int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy; bool reverseXY = abs(y2-y1) > abs(x2-x1), back = false;
float e, de; int x, y, dx, dy, Ystep;
if (c==WL_EHOLE || c==WL_ALLOWGAS || c==WL_ALLOWALLELEC || c==WL_ALLOWSOLID || c==WL_ALLOWAIR || c==WL_WALL || c==WL_DESTROYALL || c==WL_ALLOWLIQUID || c==WL_FAN || c==WL_STREAM || c==WL_DETECT || c==WL_EWALL || c==WL_WALLELEC) float e = 0.0f, de;
return; // this function only for particles, no walls if (reverseXY)
if (cp)
{ {
y = x1; y = x1;
x1 = y1; x1 = y1;
@@ -302,44 +321,55 @@ void Element_LIGH::create_line_par(Simulation * sim, int x1, int y1, int x2, int
y2 = y; y2 = y;
} }
if (x1 > x2) if (x1 > x2)
{ back = 1;
y = x1;
x1 = x2;
x2 = y;
y = y1;
y1 = y2;
y2 = y;
}
dx = x2 - x1; dx = x2 - x1;
dy = abs(y2 - y1); dy = abs(y2 - y1);
e = 0.0f;
if (dx) if (dx)
de = dy/(float)dx; de = dy/(float)dx;
else else
de = 0.0f; de = 0.0f;
y = y1; y = y1;
sy = (y1<y2) ? 1 : -1; Ystep = (y1<y2) ? 1 : -1;
for (x=x1; x<=x2; x++) if (!back)
{ {
int p; for (x = x1; x <= x2; x++)
if (cp) {
p = sim->create_part(-1, y, x, c); bool ret;
if (reverseXY)
ret = create_LIGH(sim, y, x, c, temp, life, tmp, tmp2);
else else
p = sim->create_part(-1, x, y,c); ret = create_LIGH(sim, x, y, c, temp, life, tmp, tmp2);
if (p!=-1) if (ret)
{ return;
sim->parts[p].life = life;
sim->parts[p].temp = temp;
sim->parts[p].tmp = tmp;
sim->parts[p].tmp2 = tmp2;
}
e += de; e += de;
if (e >= 0.5f) if (e >= 0.5f)
{ {
y += sy; y += Ystep;
e -= 1.0f; e -= 1.0f;
} }
} }
}
else
{
for (x = x1; x >= x2; x--)
{
bool ret;
if (reverseXY)
ret = create_LIGH(sim, y, x, c, temp, life, tmp, tmp2);
else
ret = create_LIGH(sim, x, y, c, temp, life, tmp, tmp2);
if (ret)
return;
e += de;
if (e <= -0.5f)
{
y += Ystep;
e += 1.0f;
}
}
}
} }