Fix LCRY/ELEC infinite loop, BIZR turns photons into electrons, SING explodes with electrons, electrons react with deut.

This commit is contained in:
Simon Robertshaw 2011-11-21 00:48:39 +00:00
parent 8c6e7caaff
commit 876c861c42
7 changed files with 62 additions and 19 deletions

View File

@ -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; return 0;
} }

View File

@ -5,6 +5,10 @@ int update_ELEC(UPDATE_FUNC_ARGS) {
float rr, rrr; float rr, rrr;
parts[i].pavg[0] = x; parts[i].pavg[0] = x;
parts[i].pavg[1] = y; 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 (rx=-2; rx<=2; rx++)
for (ry=-2; ry<=2; ry++) for (ry=-2; ry<=2; ry++)
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES) { 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) 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) 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].life = 0;
parts[r>>8].ctype = 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) if (ptypes[r&0xFF].properties & PROP_CONDUCTS)
{ {
create_part(-1, x+rx, y+ry, PT_SPRK); create_part(-1, x+rx, y+ry, PT_SPRK);

View File

@ -14,6 +14,7 @@ int update_LCRY(UPDATE_FUNC_ARGS)
parts[i].life-=2; parts[i].life-=2;
if(parts[i].life < 0) if(parts[i].life < 0)
parts[i].life = 0; parts[i].life = 0;
parts[i].tmp2 = parts[i].life;
} }
} }
for (rx=-1; rx<2; rx++) for (rx=-1; rx<2; rx++)
@ -40,6 +41,7 @@ int update_LCRY(UPDATE_FUNC_ARGS)
parts[i].life+=2; parts[i].life+=2;
if(parts[i].life > 10) if(parts[i].life > 10)
parts[i].life = 10; parts[i].life = 10;
parts[i].tmp2 = parts[i].life;
} }
} }
for (rx=-1; rx<2; rx++) for (rx=-1; rx<2; rx++)
@ -55,6 +57,5 @@ int update_LCRY(UPDATE_FUNC_ARGS)
} }
} }
} }
parts[i].tmp = parts[i].tmp;
return 0; return 0;
} }

View File

@ -355,7 +355,7 @@ int graphics_GLOW(GRAPHICS_FUNC_ARGS)
} }
int graphics_LCRY(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; *colr += lifemod;
*colg += lifemod; *colg += lifemod;
*colb += lifemod; *colb += lifemod;

View File

@ -40,10 +40,17 @@ int update_SING(UPDATE_FUNC_ARGS) {
spawncount = spawncount*spawncount*M_PI; spawncount = spawncount*spawncount*M_PI;
for (j=0;j<spawncount;j++) for (j=0;j<spawncount;j++)
{ {
if (rand()%2) { switch(rand()%3)
{
case 0:
nb = create_part(-3, x, y, PT_PHOT); nb = create_part(-3, x, y, PT_PHOT);
} else { break;
case 1:
nb = create_part(-3, x, y, PT_NEUT); nb = create_part(-3, x, y, PT_NEUT);
break;
case 2:
nb = create_part(-3, x, y, PT_ELEC);
break;
} }
if (nb!=-1) { if (nb!=-1) {
parts[nb].life = (rand()%300); parts[nb].life = (rand()%300);

View File

@ -1035,16 +1035,20 @@ int parse_save(void *save, int size, int replace, int x0, int y0, unsigned char
} }
} }
} }
if(ver<67 && (ty==PT_LCRY)){ if(ty==PT_LCRY){
if(ver<67)
{
//New LCRY uses TMP not life //New LCRY uses TMP not life
if(parts[i-1].life>=10) if(parts[i-1].life>=10)
{ {
parts[i-1].life = 10; parts[i-1].life = 10;
parts[i-1].tmp2 = 10;
parts[i-1].tmp = 3; parts[i-1].tmp = 3;
} }
else if(parts[i-1].life<=0) else if(parts[i-1].life<=0)
{ {
parts[i-1].life = 0; parts[i-1].life = 0;
parts[i-1].tmp2 = 0;
parts[i-1].tmp = 0; parts[i-1].tmp = 0;
} }
else if(parts[i-1].life < 10 && parts[i-1].life > 0) else if(parts[i-1].life < 10 && parts[i-1].life > 0)
@ -1052,6 +1056,11 @@ int parse_save(void *save, int size, int replace, int x0, int y0, unsigned char
parts[i-1].tmp = 1; parts[i-1].tmp = 1;
} }
} }
else
{
parts[i-1].tmp2 = parts[i-1].life;
}
}
if (!ptypes[parts[i-1].type].enabled) if (!ptypes[parts[i-1].type].enabled)
parts[i-1].type = PT_NONE; parts[i-1].type = PT_NONE;
} }

View File

@ -143,6 +143,14 @@ void init_can_move()
} }
can_move[PT_ELEC][PT_LCRY] = 2; can_move[PT_ELEC][PT_LCRY] = 2;
can_move[PT_PHOT][PT_LCRY] = 3;//varies according to LCRY life can_move[PT_PHOT][PT_LCRY] = 3;//varies according to LCRY life
can_move[PT_PHOT][PT_BIZR] = 2;
can_move[PT_ELEC][PT_BIZR] = 2;
can_move[PT_PHOT][PT_BIZRG] = 2;
can_move[PT_ELEC][PT_BIZRG] = 2;
can_move[PT_PHOT][PT_BIZRS] = 2;
can_move[PT_ELEC][PT_BIZRS] = 2;
can_move[PT_NEUT][PT_INVIS] = 2; can_move[PT_NEUT][PT_INVIS] = 2;
//whol eats anar //whol eats anar
can_move[PT_ANAR][PT_WHOL] = 1; can_move[PT_ANAR][PT_WHOL] = 1;