From 7682094f1303dc2a7a64888a397394953f326697 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Tue, 17 Apr 2012 17:42:09 +0100 Subject: [PATCH] TPT: Fix stationary photons being created by PCLN/PBCN 91163c44ab --- src/elements/pbcn.cpp | 19 +++++++++++++------ src/elements/pcln.cpp | 19 +++++++++++++------ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/elements/pbcn.cpp b/src/elements/pbcn.cpp index a6bbe5acc..aa4c33678 100644 --- a/src/elements/pbcn.cpp +++ b/src/elements/pbcn.cpp @@ -59,12 +59,19 @@ int update_PBCN(UPDATE_FUNC_ARGS) { } if (parts[i].ctype>0 && parts[i].ctypecreate_part(-1, x+rx, y+ry, parts[i].ctype); - if (r!=-1) { - parts[r].vx = rx*3; - parts[r].vy = ry*3; + for (rx=-1; rx<2; rx++) + { + for (ry = -1; ry < 2; ry++) + { + if (rx || ry) + { + int r = sim->create_part(-1, x + rx, y + ry, + parts[i].ctype); + if (r != -1) + { + parts[r].vx = rx * 3; + parts[r].vy = ry * 3; + } } } } diff --git a/src/elements/pcln.cpp b/src/elements/pcln.cpp index 86d67f65b..4fdffb6cf 100644 --- a/src/elements/pcln.cpp +++ b/src/elements/pcln.cpp @@ -49,12 +49,19 @@ int update_PCLN(UPDATE_FUNC_ARGS) { } if (parts[i].ctype>0 && parts[i].ctypecreate_part(-1, x+rx, y+ry, parts[i].ctype); - if (r!=-1) { - parts[r].vx = rx*3; - parts[r].vy = ry*3; + for (rx=-1; rx<2; rx++) + { + for (ry = -1; ry < 2; ry++) + { + if (rx || ry) + { + int r = sim->create_part(-1, x + rx, y + ry, + parts[i].ctype); + if (r != -1) + { + parts[r].vx = rx * 3; + parts[r].vy = ry * 3; + } } } }