fix two red BRAYS not being able to turn off swch from certain angles

This commit is contained in:
jacob1 2012-11-04 16:24:31 -05:00 committed by jacksonmj
parent 9b8357f822
commit dc41e46c81

View File

@ -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)))
//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 = 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))))
{
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;
}