diff options
Diffstat (limited to 'src/simulation/elements/SPRK.cpp')
| -rw-r--r-- | src/simulation/elements/SPRK.cpp | 70 |
1 files changed, 38 insertions, 32 deletions
diff --git a/src/simulation/elements/SPRK.cpp b/src/simulation/elements/SPRK.cpp index 09638ff..cedbaa9 100644 --- a/src/simulation/elements/SPRK.cpp +++ b/src/simulation/elements/SPRK.cpp @@ -78,29 +78,35 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS) { Element_NTCT::update(UPDATE_FUNC_SUBCALL_ARGS); } - else if (ct==PT_ETRD&&parts[i].life==1) + else if (ct==PT_ETRD) { - nearp = sim->nearest_part(i, PT_ETRD, -1); - if (nearp!=-1 && sim->parts_avg(i, nearp, PT_INSL)!=PT_INSL) + if (parts[i].life==1) { - sim->CreateLine(x, y, (int)(parts[nearp].x+0.5f), (int)(parts[nearp].y+0.5f), 0, 0, PT_PLSM, 0); - sim->part_change_type(i,x,y,ct); - ct = parts[i].ctype = PT_NONE; - parts[i].life = 20; - sim->part_change_type(nearp,(int)(parts[nearp].x+0.5f),(int)(parts[nearp].y+0.5f),PT_SPRK); - parts[nearp].life = 9; - parts[nearp].ctype = PT_ETRD; + nearp = sim->nearest_part(i, PT_ETRD, -1); + if (nearp!=-1 && sim->parts_avg(i, nearp, PT_INSL)!=PT_INSL) + { + sim->CreateLine(x, y, (int)(parts[nearp].x+0.5f), (int)(parts[nearp].y+0.5f), 0, 0, PT_PLSM, 0); + sim->part_change_type(i,x,y,ct); + ct = parts[i].ctype = PT_NONE; + parts[i].life = 20; + sim->part_change_type(nearp,(int)(parts[nearp].x+0.5f),(int)(parts[nearp].y+0.5f),PT_SPRK); + parts[nearp].life = 9; + parts[nearp].ctype = PT_ETRD; + } } } - else if (ct==PT_NBLE&&parts[i].life<=1&&parts[i].tmp!=1) + else if (ct==PT_NBLE) { - parts[i].life = rand()%150+50; - sim->part_change_type(i,x,y,PT_PLSM); - parts[i].ctype = PT_NBLE; - if (parts[i].temp > 5273.15) - parts[i].tmp |= 4; - parts[i].temp = 3500; - sim->pv[y/CELL][x/CELL] += 1; + if (parts[i].life<=1&&parts[i].tmp!=1) + { + parts[i].life = rand()%150+50; + sim->part_change_type(i,x,y,PT_PLSM); + parts[i].ctype = PT_NBLE; + if (parts[i].temp > 5273.15) + parts[i].tmp |= 4; + parts[i].temp = 3500; + sim->pv[y/CELL][x/CELL] += 1; + } } else if (ct==PT_TESC) // tesla coil code { @@ -162,7 +168,7 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - rt = parts[r>>8].type; + rt = r&0xFF; conduct_sprk = 1; @@ -211,28 +217,28 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS) } if (ct==PT_NTCT && !(rt==PT_PSCN || rt==PT_NTCT || (rt==PT_NSCN&&parts[i].temp>373.0f))) conduct_sprk = 0; - if (ct==PT_PTCT && !(rt==PT_PSCN || rt==PT_PTCT || (rt==PT_NSCN&&parts[i].temp<373.0f))) + else if (ct==PT_PTCT && !(rt==PT_PSCN || rt==PT_PTCT || (rt==PT_NSCN&&parts[i].temp<373.0f))) conduct_sprk = 0; - if (ct==PT_INWR && !(rt==PT_NSCN || rt==PT_INWR || rt==PT_PSCN)) + else if (ct==PT_INWR && !(rt==PT_NSCN || rt==PT_INWR || rt==PT_PSCN)) conduct_sprk = 0; - if (ct==PT_NSCN && rt==PT_PSCN) + else if (ct==PT_NSCN && rt==PT_PSCN) conduct_sprk = 0; - if (ct==PT_ETRD && !(rt==PT_METL||rt==PT_ETRD||rt==PT_BMTL||rt==PT_BRMT||rt==PT_LRBD||rt==PT_RBDM||rt==PT_PSCN||rt==PT_NSCN)) + else if (ct==PT_ETRD && !(rt==PT_METL||rt==PT_ETRD||rt==PT_BMTL||rt==PT_BRMT||rt==PT_LRBD||rt==PT_RBDM||rt==PT_PSCN||rt==PT_NSCN)) conduct_sprk = 0; - if (ct==PT_INST&&rt!=PT_NSCN) conduct_sprk = 0; - if (ct==PT_SWCH && (rt==PT_PSCN||rt==PT_NSCN||rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR)) + else if (ct==PT_INST && rt!=PT_NSCN) conduct_sprk = 0; + else if (ct==PT_SWCH && (rt==PT_PSCN||rt==PT_NSCN||rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR)) conduct_sprk = 0; - if (rt==PT_QRTZ && !((ct==PT_NSCN||ct==PT_METL||ct==PT_PSCN||ct==PT_QRTZ) && (parts[r>>8].temp<173.15||sim->pv[(y+ry)/CELL][(x+rx)/CELL]>8))) + else if (rt==PT_QRTZ && !((ct==PT_NSCN||ct==PT_METL||ct==PT_PSCN||ct==PT_QRTZ) && (parts[r>>8].temp<173.15||sim->pv[(y+ry)/CELL][(x+rx)/CELL]>8))) conduct_sprk = 0; - if (rt==PT_NTCT && !(ct==PT_NSCN || ct==PT_NTCT || (ct==PT_PSCN&&parts[r>>8].temp>373.0f))) + else if (rt==PT_NTCT && !(ct==PT_NSCN || ct==PT_NTCT || (ct==PT_PSCN&&parts[r>>8].temp>373.0f))) conduct_sprk = 0; - if (rt==PT_PTCT && !(ct==PT_NSCN || ct==PT_PTCT || (ct==PT_PSCN&&parts[r>>8].temp<373.0f))) + else if (rt==PT_PTCT && !(ct==PT_NSCN || ct==PT_PTCT || (ct==PT_PSCN&&parts[r>>8].temp<373.0f))) conduct_sprk = 0; - if (rt==PT_INWR && !(ct==PT_NSCN || ct==PT_INWR || ct==PT_PSCN)) + else if (rt==PT_INWR && !(ct==PT_NSCN || ct==PT_INWR || ct==PT_PSCN)) conduct_sprk = 0; - if (rt==PT_INST&&ct!=PT_PSCN) + else if (rt==PT_INST && ct!=PT_PSCN) conduct_sprk = 0; - if (rt == PT_NBLE && parts[r>>8].tmp == 1) + else if (rt==PT_NBLE && parts[r>>8].tmp == 1) conduct_sprk = 0; if (conduct_sprk) { @@ -287,4 +293,4 @@ int Element_SPRK::graphics(GRAPHICS_FUNC_ARGS) } -Element_SPRK::~Element_SPRK() {}
\ No newline at end of file +Element_SPRK::~Element_SPRK() {} |
