diff options
| author | jacksonmj <mj-pt@jacksonmj.co.uk> | 2011-07-22 21:06:07 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2011-07-24 12:10:43 (GMT) |
| commit | 89cc8d4ded6cf96941520e5d0097224f60b79929 (patch) | |
| tree | 31adc041d90200bdc0e0a93e3a39aa882142026e /src/elements | |
| parent | 7ed0255f04f494e914b724cf5614f4f1d343069a (diff) | |
| download | powder-89cc8d4ded6cf96941520e5d0097224f60b79929.zip powder-89cc8d4ded6cf96941520e5d0097224f60b79929.tar.gz | |
Fix life cloning
Diffstat (limited to 'src/elements')
| -rw-r--r-- | src/elements/bcln.c | 11 | ||||
| -rw-r--r-- | src/elements/clne.c | 11 | ||||
| -rw-r--r-- | src/elements/pbcn.c | 22 | ||||
| -rw-r--r-- | src/elements/pcln.c | 12 |
4 files changed, 37 insertions, 19 deletions
diff --git a/src/elements/bcln.c b/src/elements/bcln.c index 6ecacac..062c85f 100644 --- a/src/elements/bcln.c +++ b/src/elements/bcln.c @@ -9,7 +9,7 @@ int update_BCLN(UPDATE_FUNC_ARGS) { parts[i].vx += advection*vx[y/CELL][x/CELL]; parts[i].vy += advection*vy[y/CELL][x/CELL]; } - if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM) + if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOLALT))) { int r, rx, ry; for (rx=-1; rx<2; rx++) @@ -25,11 +25,16 @@ int update_BCLN(UPDATE_FUNC_ARGS) { (r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_STKM && (r&0xFF)!=PT_STKM2 && (r&0xFF)!=PT_PBCN && (r&0xFF)<PT_NUM) - parts[i].ctype = r&0xFF; + { + parts[i].ctype = r&0xFF; + if ((r&0xFF)==PT_LIFE) + parts[i].tmp = parts[r>>8].ctype; + } } } else { - create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype); + if (parts[i].ctype==PT_LIFE) create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype|(parts[i].tmp<<8)); + else create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype); } return 0; } diff --git a/src/elements/clne.c b/src/elements/clne.c index 850a3ae..41f27e3 100644 --- a/src/elements/clne.c +++ b/src/elements/clne.c @@ -1,7 +1,7 @@ #include <element.h> int update_CLNE(UPDATE_FUNC_ARGS) { - if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM) + if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOLALT))) { int r, rx, ry; for (rx=-1; rx<2; rx++) @@ -17,11 +17,16 @@ int update_CLNE(UPDATE_FUNC_ARGS) { (r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_STKM && (r&0xFF)!=PT_PBCN && (r&0xFF)!=PT_STKM2 && (r&0xFF)<PT_NUM) - parts[i].ctype = r&0xFF; + { + parts[i].ctype = r&0xFF; + if ((r&0xFF)==PT_LIFE) + parts[i].tmp = parts[r>>8].ctype; + } } } else { - create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype); + if (parts[i].ctype==PT_LIFE) create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype|(parts[i].tmp<<8)); + else create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype); } return 0; } diff --git a/src/elements/pbcn.c b/src/elements/pbcn.c index 3c41820..3f40628 100644 --- a/src/elements/pbcn.c +++ b/src/elements/pbcn.c @@ -4,20 +4,20 @@ int update_PBCN(UPDATE_FUNC_ARGS) { int r, rx, ry; if (parts[i].life>0 && parts[i].life!=10) parts[i].life--; - if (!parts[i].tmp && pv[y/CELL][x/CELL]>4.0f) - parts[i].tmp = rand()%40+80; - if (parts[i].tmp) + if (!parts[i].tmp2 && pv[y/CELL][x/CELL]>4.0f) + parts[i].tmp2 = rand()%40+80; + if (parts[i].tmp2) { float advection = 0.1f; parts[i].vx += advection*vx[y/CELL][x/CELL]; parts[i].vy += advection*vy[y/CELL][x/CELL]; - parts[i].tmp--; - if(!parts[i].tmp){ + parts[i].tmp2--; + if(!parts[i].tmp2){ kill_part(i); return 1; } } - if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM) + if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOLALT))) 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) @@ -32,7 +32,11 @@ int update_PBCN(UPDATE_FUNC_ARGS) { (r&0xFF)!=PT_NSCN && (r&0xFF)!=PT_PSCN && (r&0xFF)!=PT_STKM && (r&0xFF)!=PT_STKM2 && (r&0xFF)!=PT_PBCN && (r&0xFF)<PT_NUM) - parts[i].ctype = r&0xFF; + { + parts[i].ctype = r&0xFF; + if ((r&0xFF)==PT_LIFE) + parts[i].tmp = parts[r>>8].ctype; + } } if (parts[i].life==10) { @@ -65,10 +69,10 @@ int update_PBCN(UPDATE_FUNC_ARGS) { } } } - else if (ptypes[parts[i].ctype].properties&PROP_LIFE) {//create life a different way + else if (parts[i].ctype==PT_LIFE) {//create life a different way for (rx=-1; rx<2; rx++) { for (ry=-1; ry<2; ry++) { - create_part(-1, x+rx, y+ry, parts[i].ctype); + create_part(-1, x+rx, y+ry, parts[i].ctype|(parts[i].tmp<<8)); } } } else { diff --git a/src/elements/pcln.c b/src/elements/pcln.c index 3f785bb..45cfc79 100644 --- a/src/elements/pcln.c +++ b/src/elements/pcln.c @@ -26,7 +26,7 @@ int update_PCLN(UPDATE_FUNC_ARGS) { parts[i].life = 10; } } - if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM) + if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOLALT))) 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) @@ -41,7 +41,11 @@ int update_PCLN(UPDATE_FUNC_ARGS) { (r&0xFF)!=PT_NSCN && (r&0xFF)!=PT_PSCN && (r&0xFF)!=PT_STKM && (r&0xFF)!=PT_STKM2 && (r&0xFF)!=PT_PBCN && (r&0xFF)<PT_NUM) - parts[i].ctype = r&0xFF; + { + parts[i].ctype = r&0xFF; + if ((r&0xFF)==PT_LIFE) + parts[i].tmp = parts[r>>8].ctype; + } } if (parts[i].ctype>0 && parts[i].ctype<PT_NUM && parts[i].life==10) { if (parts[i].ctype==PT_PHOT) {//create photons a different way @@ -55,10 +59,10 @@ int update_PCLN(UPDATE_FUNC_ARGS) { } } } - else if (ptypes[parts[i].ctype].properties&PROP_LIFE) {//create life a different way + else if (parts[i].ctype==PT_LIFE) {//create life a different way for (rx=-1; rx<2; rx++) { for (ry=-1; ry<2; ry++) { - create_part(-1, x+rx, y+ry, parts[i].ctype); + create_part(-1, x+rx, y+ry, parts[i].ctype|(parts[i].tmp<<8)); } } } else { |
