diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2011-05-14 12:34:06 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2011-05-14 12:34:06 (GMT) |
| commit | 73f2f9f57fd6efa4ed386a86f5a8d118d879a629 (patch) | |
| tree | e38f378c20c7107f178efae736465aebd27dae83 /src/elements | |
| parent | c23124e0d7f072e40701e1250618b295fb2117dc (diff) | |
| download | powder-73f2f9f57fd6efa4ed386a86f5a8d118d879a629.zip powder-73f2f9f57fd6efa4ed386a86f5a8d118d879a629.tar.gz | |
fix neutron cloning
Diffstat (limited to 'src/elements')
| -rw-r--r-- | src/elements/bcln.c | 23 | ||||
| -rw-r--r-- | src/elements/clne.c | 23 | ||||
| -rw-r--r-- | src/elements/neut.c | 6 | ||||
| -rw-r--r-- | src/elements/pcln.c | 26 |
4 files changed, 40 insertions, 38 deletions
diff --git a/src/elements/bcln.c b/src/elements/bcln.c index 36ad347..aaf4afc 100644 --- a/src/elements/bcln.c +++ b/src/elements/bcln.c @@ -11,18 +11,21 @@ int update_BCLN(UPDATE_FUNC_ARGS) { } if (!parts[i].ctype) { - int rx, ry; + int r, rx, ry; for (rx=-1; rx<2; rx++) for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && - pmap[y+ry][x+rx] && - (pmap[y+ry][x+rx]&0xFF)!=PT_CLNE && - (pmap[y+ry][x+rx]&0xFF)!=PT_BCLN && - (pmap[y+ry][x+rx]&0xFF)!=PT_PCLN && - (pmap[y+ry][x+rx]&0xFF)!=PT_STKM && - (pmap[y+ry][x+rx]&0xFF)!=PT_STKM2 && - (pmap[y+ry][x+rx]&0xFF)!=0xFF) - parts[i].ctype = pmap[y+ry][x+rx]&0xFF; + if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES) + { + r = photons[y+ry][x+rx]; + if (!r || (r>>8)>=NPART) + r = pmap[y+ry][x+rx]; + if (!r || (r>>8)>=NPART) + continue; + if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && + (r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_STKM && + (r&0xFF)!=PT_STKM2 && (r&0xFF)<PT_NUM) + parts[i].ctype = r&0xFF; + } } else { create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype); diff --git a/src/elements/clne.c b/src/elements/clne.c index 173bd0a..295974a 100644 --- a/src/elements/clne.c +++ b/src/elements/clne.c @@ -3,18 +3,21 @@ int update_CLNE(UPDATE_FUNC_ARGS) { if (!parts[i].ctype) { - int rx, ry; + int r, rx, ry; for (rx=-1; rx<2; rx++) for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && - pmap[y+ry][x+rx] && - (pmap[y+ry][x+rx]&0xFF)!=PT_CLNE && - (pmap[y+ry][x+rx]&0xFF)!=PT_BCLN && - (pmap[y+ry][x+rx]&0xFF)!=PT_PCLN && - (pmap[y+ry][x+rx]&0xFF)!=PT_STKM && - (pmap[y+ry][x+rx]&0xFF)!=PT_STKM2 && - (pmap[y+ry][x+rx]&0xFF)!=0xFF) - parts[i].ctype = pmap[y+ry][x+rx]&0xFF; + if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES) + { + r = photons[y+ry][x+rx]; + if (!r || (r>>8)>=NPART) + r = pmap[y+ry][x+rx]; + if (!r || (r>>8)>=NPART) + continue; + if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && + (r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_STKM && + (r&0xFF)!=PT_STKM2 && (r&0xFF)<PT_NUM) + parts[i].ctype = r&0xFF; + } } else { create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype); diff --git a/src/elements/neut.c b/src/elements/neut.c index 789a033..3207534 100644 --- a/src/elements/neut.c +++ b/src/elements/neut.c @@ -132,11 +132,5 @@ int update_NEUT(UPDATE_FUNC_ARGS) { ptypes[parts[r>>8].type-1].menusection==SC_POWDERS) && 15>(rand()%1000)) parts[r>>8].type--;*/ } - r = pmap[y][x]; - rt = r&0xFF; - if (rt==PT_CLNE || rt==PT_PCLN || rt==PT_BCLN) { - if (!parts[r>>8].ctype) - parts[r>>8].ctype = PT_PHOT; - } return 0; } diff --git a/src/elements/pcln.c b/src/elements/pcln.c index e1c688e..5abe33f 100644 --- a/src/elements/pcln.c +++ b/src/elements/pcln.c @@ -27,18 +27,20 @@ int update_PCLN(UPDATE_FUNC_ARGS) { if (!parts[i].ctype) for (rx=-1; rx<2; rx++) for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && - pmap[y+ry][x+rx] && - (pmap[y+ry][x+rx]&0xFF)!=PT_CLNE && - (pmap[y+ry][x+rx]&0xFF)!=PT_PCLN && - (pmap[y+ry][x+rx]&0xFF)!=PT_BCLN && - (pmap[y+ry][x+rx]&0xFF)!=PT_SPRK && - (pmap[y+ry][x+rx]&0xFF)!=PT_NSCN && - (pmap[y+ry][x+rx]&0xFF)!=PT_PSCN && - (pmap[y+ry][x+rx]&0xFF)!=PT_STKM && - (pmap[y+ry][x+rx]&0xFF)!=PT_STKM2 && - (pmap[y+ry][x+rx]&0xFF)!=0xFF) - parts[i].ctype = pmap[y+ry][x+rx]&0xFF; + if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES) + { + r = photons[y+ry][x+rx]; + if (!r || (r>>8)>=NPART) + r = pmap[y+ry][x+rx]; + if (!r || (r>>8)>=NPART) + continue; + if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && + (r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_SPRK && + (r&0xFF)!=PT_NSCN && (r&0xFF)!=PT_PSCN && + (r&0xFF)!=PT_STKM && (r&0xFF)!=PT_STKM2 && + (r&0xFF)<PT_NUM) + parts[i].ctype = r&0xFF; + } if (parts[i].ctype && parts[i].life==10) { if (parts[i].ctype==PT_PHOT) {//create photons a different way for (rx=-1; rx<2; rx++) { |
