summaryrefslogtreecommitdiff
path: root/src/simulation
diff options
context:
space:
mode:
authorjacob1 <jfu614@gmail.com>2012-11-04 21:24:31 (GMT)
committer jacksonmj <mj-pt@jacksonmj.co.uk>2012-11-04 22:44:49 (GMT)
commitdc41e46c81d5d21e1ef8c459e4f0bd3670cedb49 (patch)
treef765b1ff913329f8105f0dcdd6588929eff369ce /src/simulation
parent9b8357f822a7c280fa75b5b5ef391a08e9bff5d6 (diff)
downloadpowder-dc41e46c81d5d21e1ef8c459e4f0bd3670cedb49.zip
powder-dc41e46c81d5d21e1ef8c459e4f0bd3670cedb49.tar.gz
fix two red BRAYS not being able to turn off swch from certain angles
Diffstat (limited to 'src/simulation')
-rw-r--r--src/simulation/elements/SWCH.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/simulation/elements/SWCH.cpp b/src/simulation/elements/SWCH.cpp
index fa8e49e..818af27 100644
--- a/src/simulation/elements/SWCH.cpp
+++ b/src/simulation/elements/SWCH.cpp
@@ -46,6 +46,11 @@ Element_SWCH::Element_SWCH()
Graphics = &Element_SWCH::graphics;
}
+bool isRedBRAY(UPDATE_FUNC_ARGS, int xc, int yc)
+{
+ return (pmap[yc][xc]&0xFF) == PT_BRAY && parts[pmap[yc][xc]>>8].tmp == 2;
+}
+
//#TPT-Directive ElementHeader Element_SWCH static int update(UPDATE_FUNC_ARGS)
int Element_SWCH::update(UPDATE_FUNC_ARGS)
{
@@ -78,15 +83,13 @@ int Element_SWCH::update(UPDATE_FUNC_ARGS)
}
}
}
- //turn off SWCH from two red BRAYS
- if (parts[i].life==10 && (!(pmap[y-1][x-1]&0xFF) && ((pmap[y-1][x]&0xFF)==PT_BRAY&&parts[pmap[y-1][x]>>8].tmp==2) && !(pmap[y-1][x+1]&0xFF) && ((pmap[y][x+1]&0xFF)==PT_BRAY&&parts[pmap[y][x+1]>>8].tmp==2)))
- {
- parts[i].life = 9;
- }
- //turn on SWCH from two red BRAYS
- else if (parts[i].life<=5 && (!(pmap[y-1][x-1]&0xFF) && (((pmap[y-1][x]&0xFF)==PT_BRAY&&parts[pmap[y-1][x]>>8].tmp==2) || ((pmap[y+1][x]&0xFF)==PT_BRAY&&parts[pmap[y+1][x]>>8].tmp==2)) && !(pmap[y-1][x+1]&0xFF) && (((pmap[y][x+1]&0xFF)==PT_BRAY&&parts[pmap[y][x+1]>>8].tmp==2) || ((pmap[y][x-1]&0xFF)==PT_BRAY&&parts[pmap[y][x-1]>>8].tmp==2))))
+ //turn SWCH on/off from two red BRAYS. There must be one either above or below, and one either left or right to work, and it can't come from the side, it must be a diagonal beam
+ if (!(pmap[y-1][x-1]&0xFF) && !(pmap[y-1][x+1]&0xFF) && (isRedBRAY(UPDATE_FUNC_SUBCALL_ARGS, x, y-1) || isRedBRAY(UPDATE_FUNC_SUBCALL_ARGS, x, y+1)) && (isRedBRAY(UPDATE_FUNC_SUBCALL_ARGS, x+1, y) || isRedBRAY(UPDATE_FUNC_SUBCALL_ARGS, x-1, y)))
{
- parts[i].life = 14;
+ if (parts[i].life == 10)
+ parts[i].life = 9;
+ else if (parts[i].life <= 5)
+ parts[i].life = 14;
}
return 0;
}