fix neutron cloning

This commit is contained in:
Simon Robertshaw 2011-05-14 13:34:06 +01:00
parent c23124e0d7
commit 73f2f9f57f
5 changed files with 46 additions and 39 deletions

View File

@ -11,18 +11,21 @@ int update_BCLN(UPDATE_FUNC_ARGS) {
} }
if (!parts[i].ctype) if (!parts[i].ctype)
{ {
int rx, ry; int r, rx, ry;
for (rx=-1; rx<2; rx++) for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++) for (ry=-1; 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)
pmap[y+ry][x+rx] && {
(pmap[y+ry][x+rx]&0xFF)!=PT_CLNE && r = photons[y+ry][x+rx];
(pmap[y+ry][x+rx]&0xFF)!=PT_BCLN && if (!r || (r>>8)>=NPART)
(pmap[y+ry][x+rx]&0xFF)!=PT_PCLN && r = pmap[y+ry][x+rx];
(pmap[y+ry][x+rx]&0xFF)!=PT_STKM && if (!r || (r>>8)>=NPART)
(pmap[y+ry][x+rx]&0xFF)!=PT_STKM2 && continue;
(pmap[y+ry][x+rx]&0xFF)!=0xFF) if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN &&
parts[i].ctype = pmap[y+ry][x+rx]&0xFF; (r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_STKM &&
(r&0xFF)!=PT_STKM2 && (r&0xFF)<PT_NUM)
parts[i].ctype = r&0xFF;
}
} }
else { else {
create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype); create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype);

View File

@ -3,18 +3,21 @@
int update_CLNE(UPDATE_FUNC_ARGS) { int update_CLNE(UPDATE_FUNC_ARGS) {
if (!parts[i].ctype) if (!parts[i].ctype)
{ {
int rx, ry; int r, rx, ry;
for (rx=-1; rx<2; rx++) for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++) for (ry=-1; 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)
pmap[y+ry][x+rx] && {
(pmap[y+ry][x+rx]&0xFF)!=PT_CLNE && r = photons[y+ry][x+rx];
(pmap[y+ry][x+rx]&0xFF)!=PT_BCLN && if (!r || (r>>8)>=NPART)
(pmap[y+ry][x+rx]&0xFF)!=PT_PCLN && r = pmap[y+ry][x+rx];
(pmap[y+ry][x+rx]&0xFF)!=PT_STKM && if (!r || (r>>8)>=NPART)
(pmap[y+ry][x+rx]&0xFF)!=PT_STKM2 && continue;
(pmap[y+ry][x+rx]&0xFF)!=0xFF) if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN &&
parts[i].ctype = pmap[y+ry][x+rx]&0xFF; (r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_STKM &&
(r&0xFF)!=PT_STKM2 && (r&0xFF)<PT_NUM)
parts[i].ctype = r&0xFF;
}
} }
else { else {
create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype); create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype);

View File

@ -132,11 +132,5 @@ int update_NEUT(UPDATE_FUNC_ARGS) {
ptypes[parts[r>>8].type-1].menusection==SC_POWDERS) && 15>(rand()%1000)) ptypes[parts[r>>8].type-1].menusection==SC_POWDERS) && 15>(rand()%1000))
parts[r>>8].type--;*/ 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; return 0;
} }

View File

@ -27,18 +27,20 @@ int update_PCLN(UPDATE_FUNC_ARGS) {
if (!parts[i].ctype) if (!parts[i].ctype)
for (rx=-1; rx<2; rx++) for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++) for (ry=-1; 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)
pmap[y+ry][x+rx] && {
(pmap[y+ry][x+rx]&0xFF)!=PT_CLNE && r = photons[y+ry][x+rx];
(pmap[y+ry][x+rx]&0xFF)!=PT_PCLN && if (!r || (r>>8)>=NPART)
(pmap[y+ry][x+rx]&0xFF)!=PT_BCLN && r = pmap[y+ry][x+rx];
(pmap[y+ry][x+rx]&0xFF)!=PT_SPRK && if (!r || (r>>8)>=NPART)
(pmap[y+ry][x+rx]&0xFF)!=PT_NSCN && continue;
(pmap[y+ry][x+rx]&0xFF)!=PT_PSCN && if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN &&
(pmap[y+ry][x+rx]&0xFF)!=PT_STKM && (r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_SPRK &&
(pmap[y+ry][x+rx]&0xFF)!=PT_STKM2 && (r&0xFF)!=PT_NSCN && (r&0xFF)!=PT_PSCN &&
(pmap[y+ry][x+rx]&0xFF)!=0xFF) (r&0xFF)!=PT_STKM && (r&0xFF)!=PT_STKM2 &&
parts[i].ctype = pmap[y+ry][x+rx]&0xFF; (r&0xFF)<PT_NUM)
parts[i].ctype = r&0xFF;
}
if (parts[i].ctype && parts[i].life==10) { if (parts[i].ctype && parts[i].life==10) {
if (parts[i].ctype==PT_PHOT) {//create photons a different way if (parts[i].ctype==PT_PHOT) {//create photons a different way
for (rx=-1; rx<2; rx++) { for (rx=-1; rx<2; rx++) {

View File

@ -168,6 +168,10 @@ int try_move(int i, int x, int y, int nx, int ny)
if ((r & 0xFF) < PT_NUM && ptypes[r&0xFF].hconduct) if ((r & 0xFF) < PT_NUM && ptypes[r&0xFF].hconduct)
parts[i].temp = parts[r>>8].temp = restrict_flt((parts[r>>8].temp+parts[i].temp)/2, MIN_TEMP, MAX_TEMP); parts[i].temp = parts[r>>8].temp = restrict_flt((parts[r>>8].temp+parts[i].temp)/2, MIN_TEMP, MAX_TEMP);
} }
if (parts[i].type==PT_NEUT && ((r&0xFF)==PT_CLNE || (r&0xFF)==PT_PCLN || (r&0xFF)==PT_BCLN)) {
if (!parts[r>>8].ctype)
parts[r>>8].ctype = PT_NEUT;
}
return 0; return 0;
} }
@ -250,7 +254,8 @@ int try_move(int i, int x, int y, int nx, int ny)
return 0; return 0;
} }
if ((r&0xFF)==PT_CNCT)//stops CNCT being displaced by other particles
if ((pmap[ny][nx]&0xFF)==PT_CNCT)//stops CNCT being displaced by other particles
return 0; return 0;
if (parts[i].type==PT_CNCT && y<ny && (pmap[y+1][x]&0xFF)==PT_CNCT)//check below CNCT for another CNCT if (parts[i].type==PT_CNCT && y<ny && (pmap[y+1][x]&0xFF)==PT_CNCT)//check below CNCT for another CNCT
return 0; return 0;