From 0cb47ab93cb7474f24c867ec0b9b9c9ac2dbf487 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Wed, 13 Jun 2012 01:37:32 +0100 Subject: [PATCH] TPT: Remember ctype when cloning lava --- src/simulation/elements/BCLN.cpp | 16 ++++++++++++---- src/simulation/elements/CLNE.cpp | 14 +++++++++++--- src/simulation/elements/PBCN.cpp | 15 +++++++++++---- src/simulation/elements/PCLN.cpp | 15 +++++++++++---- 4 files changed, 45 insertions(+), 15 deletions(-) diff --git a/src/simulation/elements/BCLN.cpp b/src/simulation/elements/BCLN.cpp index 3db065426..281ecb24e 100644 --- a/src/simulation/elements/BCLN.cpp +++ b/src/simulation/elements/BCLN.cpp @@ -71,21 +71,29 @@ int Element_BCLN::update(UPDATE_FUNC_ARGS) 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_PBCN && + (r&0xFF)!=PT_PBCN && (r&0xFF)!=PT_STKM2 && (r&0xFF)>8].ctype; } } } else { if (parts[i].ctype==PT_LIFE) sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype|(parts[i].tmp<<8)); - else sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype); + else + { + int np = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype); + if (np>=0) + { + if (parts[i].ctype==PT_LAVA && parts[i].tmp>0 && parts[i].tmpelements[parts[i].tmp].HighTemperatureTransition==PT_LAVA) + parts[np].ctype = parts[i].tmp; + } + } } return 0; } -Element_BCLN::~Element_BCLN() {} \ No newline at end of file +Element_BCLN::~Element_BCLN() {} diff --git a/src/simulation/elements/CLNE.cpp b/src/simulation/elements/CLNE.cpp index 56839f07a..939feb0f8 100644 --- a/src/simulation/elements/CLNE.cpp +++ b/src/simulation/elements/CLNE.cpp @@ -67,17 +67,25 @@ int Element_CLNE::update(UPDATE_FUNC_ARGS) (r&0xFF)>8].ctype; } } } else { if (parts[i].ctype==PT_LIFE) sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype|(parts[i].tmp<<8)); - else sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype); + else + { + int np = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype); + if (np>=0) + { + if (parts[i].ctype==PT_LAVA && parts[i].tmp>0 && parts[i].tmpelements[parts[i].tmp].HighTemperatureTransition==PT_LAVA) + parts[np].ctype = parts[i].tmp; + } + } } return 0; } -Element_CLNE::~Element_CLNE() {} \ No newline at end of file +Element_CLNE::~Element_CLNE() {} diff --git a/src/simulation/elements/PBCN.cpp b/src/simulation/elements/PBCN.cpp index 270bfb5ad..af37a5966 100644 --- a/src/simulation/elements/PBCN.cpp +++ b/src/simulation/elements/PBCN.cpp @@ -82,7 +82,7 @@ int Element_PBCN::update(UPDATE_FUNC_ARGS) (r&0xFF)!=PT_PBCN && (r&0xFF)>8].ctype; } } @@ -135,8 +135,15 @@ int Element_PBCN::update(UPDATE_FUNC_ARGS) sim->create_part(-1, x+rx, y+ry, parts[i].ctype|(parts[i].tmp<<8)); } } - } else { - sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype); + } + else + { + int np = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype); + if (np>=0) + { + if (parts[i].ctype==PT_LAVA && parts[i].tmp>0 && parts[i].tmpelements[parts[i].tmp].HighTemperatureTransition==PT_LAVA) + parts[np].ctype = parts[i].tmp; + } } } return 0; @@ -154,4 +161,4 @@ int Element_PBCN::graphics(GRAPHICS_FUNC_ARGS) } -Element_PBCN::~Element_PBCN() {} \ No newline at end of file +Element_PBCN::~Element_PBCN() {} diff --git a/src/simulation/elements/PCLN.cpp b/src/simulation/elements/PCLN.cpp index 14991b5ad..41701bc86 100644 --- a/src/simulation/elements/PCLN.cpp +++ b/src/simulation/elements/PCLN.cpp @@ -91,7 +91,7 @@ int Element_PCLN::update(UPDATE_FUNC_ARGS) (r&0xFF)!=PT_PBCN && (r&0xFF)>8].ctype; } } @@ -125,8 +125,15 @@ int Element_PCLN::update(UPDATE_FUNC_ARGS) sim->create_part(-1, x+rx, y+ry, parts[i].ctype|(parts[i].tmp<<8)); } } - } else { - sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype); + } + else + { + int np = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype); + if (np>=0) + { + if (parts[i].ctype==PT_LAVA && parts[i].tmp>0 && parts[i].tmpelements[parts[i].tmp].HighTemperatureTransition==PT_LAVA) + parts[np].ctype = parts[i].tmp; + } } } return 0; @@ -144,4 +151,4 @@ int Element_PCLN::graphics(GRAPHICS_FUNC_ARGS) } -Element_PCLN::~Element_PCLN() {} \ No newline at end of file +Element_PCLN::~Element_PCLN() {}