Separate loop for updating life, and add SPRK life checks to most electronics
This commit is contained in:
parent
a4ad6ee428
commit
6bdc05cc40
@ -11,7 +11,7 @@ int update_ARAY(UPDATE_FUNC_ARGS) {
|
|||||||
r = pmap[y+ry][x+rx];
|
r = pmap[y+ry][x+rx];
|
||||||
if (!r)
|
if (!r)
|
||||||
continue;
|
continue;
|
||||||
if ((r&0xFF)==PT_SPRK) {
|
if ((r&0xFF)==PT_SPRK && parts[r>>8].life<4) {
|
||||||
int destroy = (parts[r>>8].ctype==PT_PSCN)?1:0;
|
int destroy = (parts[r>>8].ctype==PT_PSCN)?1:0;
|
||||||
int nostop = (parts[r>>8].ctype==PT_INST)?1:0;
|
int nostop = (parts[r>>8].ctype==PT_INST)?1:0;
|
||||||
for (docontinue = 1, nxx = 0, nyy = 0, nxi = rx*-1, nyi = ry*-1; docontinue; nyy+=nyi, nxx+=nxi) {
|
for (docontinue = 1, nxx = 0, nyy = 0, nxi = rx*-1, nyi = ry*-1; docontinue; nyy+=nyi, nxx+=nxi) {
|
||||||
|
@ -19,7 +19,7 @@ int update_DLAY(UPDATE_FUNC_ARGS) {
|
|||||||
r = pmap[y+ry][x+rx];
|
r = pmap[y+ry][x+rx];
|
||||||
if (!r)
|
if (!r)
|
||||||
continue;
|
continue;
|
||||||
if ((r&0xFF)==PT_SPRK && parts[i].life==0 && parts[r>>8].ctype==PT_PSCN)
|
if ((r&0xFF)==PT_SPRK && parts[i].life==0 && parts[r>>8].life<4 && parts[r>>8].ctype==PT_PSCN)
|
||||||
{
|
{
|
||||||
parts[i].life = (int)(parts[i].temp-273.15);
|
parts[i].life = (int)(parts[i].temp-273.15);
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ int update_EMP(UPDATE_FUNC_ARGS) {
|
|||||||
r = pmap[y+ry][x+rx];
|
r = pmap[y+ry][x+rx];
|
||||||
if (!r)
|
if (!r)
|
||||||
continue;
|
continue;
|
||||||
if ((r&0xFF)==PT_SPRK)
|
if ((r&0xFF)==PT_SPRK && parts[r>>8].life<4)
|
||||||
{
|
{
|
||||||
ok=1;
|
ok=1;
|
||||||
break;
|
break;
|
||||||
|
@ -11,7 +11,7 @@ int update_PCLN(UPDATE_FUNC_ARGS) {
|
|||||||
r = pmap[y+ry][x+rx];
|
r = pmap[y+ry][x+rx];
|
||||||
if (!r)
|
if (!r)
|
||||||
continue;
|
continue;
|
||||||
if ((r&0xFF)==PT_SPRK)
|
if ((r&0xFF)==PT_SPRK && parts[r>>8].life<4)
|
||||||
{
|
{
|
||||||
if (parts[r>>8].ctype==PT_PSCN)
|
if (parts[r>>8].ctype==PT_PSCN)
|
||||||
parts[i].life = 10;
|
parts[i].life = 10;
|
||||||
|
@ -11,7 +11,7 @@ int update_PVOD(UPDATE_FUNC_ARGS) {
|
|||||||
r = pmap[y+ry][x+rx];
|
r = pmap[y+ry][x+rx];
|
||||||
if (!r)
|
if (!r)
|
||||||
continue;
|
continue;
|
||||||
if ((r&0xFF)==PT_SPRK)
|
if ((r&0xFF)==PT_SPRK && parts[r>>8].life<4)
|
||||||
{
|
{
|
||||||
if (parts[r>>8].ctype==PT_PSCN)
|
if (parts[r>>8].ctype==PT_PSCN)
|
||||||
parts[i].life = 10;
|
parts[i].life = 10;
|
||||||
|
@ -119,7 +119,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) {
|
|||||||
|
|
||||||
|
|
||||||
pavg = parts_avg(r>>8, i,PT_INSL);
|
pavg = parts_avg(r>>8, i,PT_INSL);
|
||||||
if ((rt==PT_SWCH||(rt==PT_SPRK&&parts[r>>8].ctype==PT_SWCH)) && pavg!=PT_INSL) // make sparked SWCH turn off correctly
|
if ((rt==PT_SWCH||(rt==PT_SPRK&&parts[r>>8].ctype==PT_SWCH)) && pavg!=PT_INSL && parts[i].life<4) // make sparked SWCH turn off correctly
|
||||||
{
|
{
|
||||||
if (rt==PT_SWCH&&ct==PT_PSCN&&parts[r>>8].life<10) {
|
if (rt==PT_SWCH&&ct==PT_PSCN&&parts[r>>8].life<10) {
|
||||||
parts[r>>8].life = 10;
|
parts[r>>8].life = 10;
|
||||||
@ -130,12 +130,12 @@ int update_SPRK(UPDATE_FUNC_ARGS) {
|
|||||||
parts[r>>8].life = 9;
|
parts[r>>8].life = 9;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((ct==PT_PSCN||ct==PT_NSCN) && (rt==PT_PUMP||rt==PT_GPMP||rt==PT_HSWC||rt==PT_PBCN)) // PROP_PTOGGLE, Maybe? We seem to use 2 different methods for handling actived elements, this one seems better. Yes, use this one for new elements, PCLN is different for compatibility with existing saves
|
else if ((ct==PT_PSCN||ct==PT_NSCN) && (rt==PT_PUMP||rt==PT_GPMP||rt==PT_HSWC||rt==PT_PBCN) && parts[i].life<4) // PROP_PTOGGLE, Maybe? We seem to use 2 different methods for handling actived elements, this one seems better. Yes, use this one for new elements, PCLN is different for compatibility with existing saves
|
||||||
{
|
{
|
||||||
if (ct==PT_PSCN) parts[r>>8].life = 10;
|
if (ct==PT_PSCN) parts[r>>8].life = 10;
|
||||||
else if (ct==PT_NSCN && parts[r>>8].life>=10) parts[r>>8].life = 9;
|
else if (ct==PT_NSCN && parts[r>>8].life>=10) parts[r>>8].life = 9;
|
||||||
}
|
}
|
||||||
else if ((ct==PT_PSCN||ct==PT_NSCN) && (rt==PT_LCRY&&abs(rx)<2&&abs(ry)<2))
|
else if ((ct==PT_PSCN||ct==PT_NSCN) && (rt==PT_LCRY&&abs(rx)<2&&abs(ry)<2) && parts[i].life<4)
|
||||||
{
|
{
|
||||||
if (ct==PT_PSCN && parts[r>>8].tmp == 0) parts[r>>8].tmp = 2;
|
if (ct==PT_PSCN && parts[r>>8].tmp == 0) parts[r>>8].tmp = 2;
|
||||||
else if (ct==PT_NSCN && parts[r>>8].tmp == 3) parts[r>>8].tmp = 1;
|
else if (ct==PT_NSCN && parts[r>>8].tmp == 3) parts[r>>8].tmp = 1;
|
||||||
@ -150,7 +150,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) {
|
|||||||
conduct_sprk = 0;
|
conduct_sprk = 0;
|
||||||
|
|
||||||
|
|
||||||
if (ct==PT_METL && (rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR||(rt==PT_SPRK&&(parts[r>>8].ctype==PT_NTCT||parts[r>>8].ctype==PT_PTCT))) && pavg!=PT_INSL)
|
if (ct==PT_METL && (rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR||(rt==PT_SPRK&&(parts[r>>8].ctype==PT_NTCT||parts[r>>8].ctype==PT_PTCT))) && pavg!=PT_INSL && parts[i].life<4)
|
||||||
{
|
{
|
||||||
parts[r>>8].temp = 473.0f;
|
parts[r>>8].temp = 473.0f;
|
||||||
if (rt==PT_NTCT||rt==PT_PTCT)
|
if (rt==PT_NTCT||rt==PT_PTCT)
|
||||||
@ -182,7 +182,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) {
|
|||||||
|
|
||||||
if (conduct_sprk) {
|
if (conduct_sprk) {
|
||||||
if (rt==PT_WATR||rt==PT_SLTW) {
|
if (rt==PT_WATR||rt==PT_SLTW) {
|
||||||
if (parts[r>>8].life==0 && (parts[i].life<2 || ((r>>8)<i && parts[i].life<3)))
|
if (parts[r>>8].life==0 && parts[i].life<3)
|
||||||
{
|
{
|
||||||
part_change_type(r>>8,x+rx,y+ry,PT_SPRK);
|
part_change_type(r>>8,x+rx,y+ry,PT_SPRK);
|
||||||
if (rt==PT_WATR) parts[r>>8].life = 6;
|
if (rt==PT_WATR) parts[r>>8].life = 6;
|
||||||
@ -191,12 +191,12 @@ int update_SPRK(UPDATE_FUNC_ARGS) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (rt==PT_INST) {
|
else if (rt==PT_INST) {
|
||||||
if (parts[i].life>=3&&parts[r>>8].life==0)
|
if (parts[r>>8].life==0 && parts[i].life<4)
|
||||||
{
|
{
|
||||||
flood_parts(x+rx,y+ry,PT_SPRK,PT_INST,-1, 0);//spark the wire
|
flood_parts(x+rx,y+ry,PT_SPRK,PT_INST,-1, 0);//spark the wire
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (parts[r>>8].life==0 && (parts[i].life<3 || ((r>>8)<i && parts[i].life<4))) {
|
else if (parts[r>>8].life==0 && parts[i].life<4) {
|
||||||
parts[r>>8].life = 4;
|
parts[r>>8].life = 4;
|
||||||
parts[r>>8].ctype = rt;
|
parts[r>>8].ctype = rt;
|
||||||
part_change_type(r>>8,x+rx,y+ry,PT_SPRK);
|
part_change_type(r>>8,x+rx,y+ry,PT_SPRK);
|
||||||
|
@ -20,7 +20,7 @@ int update_STOR(UPDATE_FUNC_ARGS) {
|
|||||||
parts[i].pavg[1] = parts[r>>8].ctype;
|
parts[i].pavg[1] = parts[r>>8].ctype;
|
||||||
kill_part(r>>8);
|
kill_part(r>>8);
|
||||||
}
|
}
|
||||||
if(parts[i].tmp && (r&0xFF)==PT_SPRK && parts[r>>8].ctype==PT_PSCN)
|
if(parts[i].tmp && (r&0xFF)==PT_SPRK && parts[r>>8].ctype==PT_PSCN && parts[r>>8].life<4)
|
||||||
{
|
{
|
||||||
for(ry1 = 1; ry1 >= -1; ry1--){
|
for(ry1 = 1; ry1 >= -1; ry1--){
|
||||||
for(rx1 = 0; rx1 >= -1 && rx1 <= 1; rx1 = -rx1-rx1+1){ // Oscilate the X starting at 0, 1, -1, 3, -5, etc (Though stop at -1)
|
for(rx1 = 0; rx1 >= -1 && rx1 <= 1; rx1 = -rx1-rx1+1){ // Oscilate the X starting at 0, 1, -1, 3, -5, etc (Though stop at -1)
|
||||||
|
@ -29,7 +29,12 @@ int update_WIRE(UPDATE_FUNC_ARGS) {
|
|||||||
r = pmap[y+ry][x+rx];
|
r = pmap[y+ry][x+rx];
|
||||||
if (!r)
|
if (!r)
|
||||||
continue;
|
continue;
|
||||||
if((r&0xFF)==PT_SPRK && parts[r>>8].ctype==PT_PSCN){parts[i].ctype=1; parts[r>>8].life=0; return 0;}
|
if((r&0xFF)==PT_SPRK && parts[r>>8].life<4 && parts[r>>8].ctype==PT_PSCN)
|
||||||
|
{
|
||||||
|
parts[i].ctype=1;
|
||||||
|
parts[r>>8].life=0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
else if((r&0xFF)==PT_NSCN && parts[i].tmp==1){create_part(-1, x+rx, y+ry, PT_SPRK);}
|
else if((r&0xFF)==PT_NSCN && parts[i].tmp==1){create_part(-1, x+rx, y+ry, PT_SPRK);}
|
||||||
else if((r&0xFF)==PT_WIRE && parts[r>>8].tmp==1 && !parts[i].tmp){count++;}
|
else if((r&0xFF)==PT_WIRE && parts[r>>8].tmp==1 && !parts[i].tmp){count++;}
|
||||||
}
|
}
|
||||||
|
18
src/powder.c
18
src/powder.c
@ -1432,6 +1432,7 @@ void update_particles_i(pixel *vid, int start, int inc)
|
|||||||
int surround[8];
|
int surround[8];
|
||||||
int surround_hconduct[8];
|
int surround_hconduct[8];
|
||||||
int lighting_ok=1;
|
int lighting_ok=1;
|
||||||
|
unsigned int elem_properties;
|
||||||
float pGravX, pGravY, pGravD;
|
float pGravX, pGravY, pGravD;
|
||||||
|
|
||||||
if (sys_pause&&lighting_recreate>0)
|
if (sys_pause&&lighting_recreate>0)
|
||||||
@ -1706,7 +1707,6 @@ void update_particles_i(pixel *vid, int start, int inc)
|
|||||||
else
|
else
|
||||||
wireless[q][1] = 0;
|
wireless[q][1] = 0;
|
||||||
}
|
}
|
||||||
//the main particle loop function, goes over all particles.
|
|
||||||
for (i=0; i<=parts_lastActiveIndex; i++)
|
for (i=0; i<=parts_lastActiveIndex; i++)
|
||||||
if (parts[i].type)
|
if (parts[i].type)
|
||||||
{
|
{
|
||||||
@ -1716,26 +1716,30 @@ void update_particles_i(pixel *vid, int start, int inc)
|
|||||||
kill_part(i);
|
kill_part(i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//printf("parts[%d].type: %d\n", i, parts[i].type);
|
elem_properties = ptypes[t].properties;
|
||||||
|
if (parts[i].life>0 && (elem_properties&PROP_LIFE_DEC))
|
||||||
if (parts[i].life>0 && (ptypes[t].properties&PROP_LIFE_DEC))
|
|
||||||
{
|
{
|
||||||
// automatically decrease life
|
// automatically decrease life
|
||||||
parts[i].life--;
|
parts[i].life--;
|
||||||
if (parts[i].life<=0 && (ptypes[t].properties&(PROP_LIFE_KILL_DEC|PROP_LIFE_KILL)))
|
if (parts[i].life<=0 && (elem_properties&(PROP_LIFE_KILL_DEC|PROP_LIFE_KILL)))
|
||||||
{
|
{
|
||||||
// kill on change to no life
|
// kill on change to no life
|
||||||
kill_part(i);
|
kill_part(i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (parts[i].life<=0 && (ptypes[t].properties&PROP_LIFE_KILL))
|
else if (parts[i].life<=0 && (elem_properties&PROP_LIFE_KILL))
|
||||||
{
|
{
|
||||||
// kill if no life
|
// kill if no life
|
||||||
kill_part(i);
|
kill_part(i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
//the main particle loop function, goes over all particles.
|
||||||
|
for (i=0; i<=parts_lastActiveIndex; i++)
|
||||||
|
if (parts[i].type)
|
||||||
|
{
|
||||||
|
t = parts[i].type;
|
||||||
x = (int)(parts[i].x+0.5f);
|
x = (int)(parts[i].x+0.5f);
|
||||||
y = (int)(parts[i].y+0.5f);
|
y = (int)(parts[i].y+0.5f);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user