summaryrefslogtreecommitdiff
path: root/src/elements
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2011-11-21 00:48:39 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-11-21 00:48:39 (GMT)
commit876c861c425ad424ffc5af4bf39b2a3441b50f9a (patch)
tree2140759c599a763e9887bd3a0ee119fbeb37ef33 /src/elements
parent8c6e7caaff883f9c7df111df65737547bd280c7a (diff)
downloadpowder-876c861c425ad424ffc5af4bf39b2a3441b50f9a.zip
powder-876c861c425ad424ffc5af4bf39b2a3441b50f9a.tar.gz
Fix LCRY/ELEC infinite loop, BIZR turns photons into electrons, SING explodes with electrons, electrons react with deut.
Diffstat (limited to 'src/elements')
-rw-r--r--src/elements/bizr.c5
-rw-r--r--src/elements/elec.c15
-rw-r--r--src/elements/lcry.c3
-rw-r--r--src/elements/newgraphics.c2
-rw-r--r--src/elements/sing.c15
5 files changed, 33 insertions, 7 deletions
diff --git a/src/elements/bizr.c b/src/elements/bizr.c
index d8a59cf..a49aa20 100644
--- a/src/elements/bizr.c
+++ b/src/elements/bizr.c
@@ -35,5 +35,10 @@ int update_BIZR(UPDATE_FUNC_ARGS) {
}
}
}
+ if(((r = photons[y][x])&0xFF)==PT_PHOT || ((r = pmap[y][x])&0xFF)==PT_PHOT)
+ {
+ part_change_type(r>>8, x, y, PT_ELEC);
+ parts[r>>8].ctype = 0;
+ }
return 0;
}
diff --git a/src/elements/elec.c b/src/elements/elec.c
index 014c162..4c3232e 100644
--- a/src/elements/elec.c
+++ b/src/elements/elec.c
@@ -5,6 +5,10 @@ int update_ELEC(UPDATE_FUNC_ARGS) {
float rr, rrr;
parts[i].pavg[0] = x;
parts[i].pavg[1] = y;
+ if(pmap[y][x]==PT_GLOW)
+ {
+ part_change_type(i, x, y, PT_PHOT);
+ }
for (rx=-2; rx<=2; rx++)
for (ry=-2; ry<=2; ry++)
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES) {
@@ -39,7 +43,7 @@ int update_ELEC(UPDATE_FUNC_ARGS) {
}
if ((r&0xFF)==PT_LCRY)
{
- parts[r>>8].life = 5+rand()%5;
+ parts[r>>8].tmp2 = 5+rand()%5;
}
if ((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW || (r&0xFF)==PT_SLTW || (r&0xFF)==PT_CBNW)
{
@@ -66,6 +70,15 @@ int update_ELEC(UPDATE_FUNC_ARGS) {
parts[r>>8].life = 0;
parts[r>>8].ctype = 0;
}
+ if ((r&0xFF)==PT_DEUT)
+ {
+ if(parts[r>>8].life < 6000)
+ parts[r>>8].life += 1;
+ parts[r>>8].temp = 0;
+ parts[i].temp = 0;
+ kill_part(i);
+ return 1;
+ }
if (ptypes[r&0xFF].properties & PROP_CONDUCTS)
{
create_part(-1, x+rx, y+ry, PT_SPRK);
diff --git a/src/elements/lcry.c b/src/elements/lcry.c
index 9d15c00..b3c529f 100644
--- a/src/elements/lcry.c
+++ b/src/elements/lcry.c
@@ -14,6 +14,7 @@ int update_LCRY(UPDATE_FUNC_ARGS)
parts[i].life-=2;
if(parts[i].life < 0)
parts[i].life = 0;
+ parts[i].tmp2 = parts[i].life;
}
}
for (rx=-1; rx<2; rx++)
@@ -40,6 +41,7 @@ int update_LCRY(UPDATE_FUNC_ARGS)
parts[i].life+=2;
if(parts[i].life > 10)
parts[i].life = 10;
+ parts[i].tmp2 = parts[i].life;
}
}
for (rx=-1; rx<2; rx++)
@@ -55,6 +57,5 @@ int update_LCRY(UPDATE_FUNC_ARGS)
}
}
}
- parts[i].tmp = parts[i].tmp;
return 0;
}
diff --git a/src/elements/newgraphics.c b/src/elements/newgraphics.c
index 59161b9..8af0f45 100644
--- a/src/elements/newgraphics.c
+++ b/src/elements/newgraphics.c
@@ -355,7 +355,7 @@ int graphics_GLOW(GRAPHICS_FUNC_ARGS)
}
int graphics_LCRY(GRAPHICS_FUNC_ARGS)
{
- int lifemod = ((cpart->life>10?10:cpart->life)*10);
+ int lifemod = ((cpart->tmp2>10?10:cpart->tmp2)*10);
*colr += lifemod;
*colg += lifemod;
*colb += lifemod;
diff --git a/src/elements/sing.c b/src/elements/sing.c
index 1f463bf..d6fc273 100644
--- a/src/elements/sing.c
+++ b/src/elements/sing.c
@@ -40,10 +40,17 @@ int update_SING(UPDATE_FUNC_ARGS) {
spawncount = spawncount*spawncount*M_PI;
for (j=0;j<spawncount;j++)
{
- if (rand()%2) {
- nb = create_part(-3, x, y, PT_PHOT);
- } else {
- nb = create_part(-3, x, y, PT_NEUT);
+ switch(rand()%3)
+ {
+ case 0:
+ nb = create_part(-3, x, y, PT_PHOT);
+ break;
+ case 1:
+ nb = create_part(-3, x, y, PT_NEUT);
+ break;
+ case 2:
+ nb = create_part(-3, x, y, PT_ELEC);
+ break;
}
if (nb!=-1) {
parts[nb].life = (rand()%300);