summaryrefslogtreecommitdiff
path: root/src/elements/clne.c
diff options
context:
space:
mode:
authorjacksonmj <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)
commit89cc8d4ded6cf96941520e5d0097224f60b79929 (patch)
tree31adc041d90200bdc0e0a93e3a39aa882142026e /src/elements/clne.c
parent7ed0255f04f494e914b724cf5614f4f1d343069a (diff)
downloadpowder-89cc8d4ded6cf96941520e5d0097224f60b79929.zip
powder-89cc8d4ded6cf96941520e5d0097224f60b79929.tar.gz
Fix life cloning
Diffstat (limited to 'src/elements/clne.c')
-rw-r--r--src/elements/clne.c11
1 files changed, 8 insertions, 3 deletions
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;
}