diff options
| author | jacksonmj <mj-pt@jacksonmj.co.uk> | 2011-05-27 14:05:41 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2011-05-28 10:51:57 (GMT) |
| commit | 6e9cbfdb4a1cec1ab1a400bc5f6c30ecb61c84b3 (patch) | |
| tree | bee0d04422a362d5595cd888063ba0750eff53cf /src/elements | |
| parent | 5919cefa85db406f1777df2231f20d78fde73c44 (diff) | |
| download | powder-6e9cbfdb4a1cec1ab1a400bc5f6c30ecb61c84b3.zip powder-6e9cbfdb4a1cec1ab1a400bc5f6c30ecb61c84b3.tar.gz | |
Fix STKM always going through walls
Now behaves as normal, i.e. only occasionally goes through walls.
Walls which completely block all particles are in the pmap with type
0xFF. ptypes[] doesn't go up to 0xFF, so ptypes[0xFF].state will not
necessarily result in an answer that gives correct behaviour for walls.
Diffstat (limited to 'src/elements')
| -rw-r--r-- | src/elements/stkm.c | 32 | ||||
| -rw-r--r-- | src/elements/stkm2.c | 32 |
2 files changed, 38 insertions, 26 deletions
diff --git a/src/elements/stkm.c b/src/elements/stkm.c index fc6dc55..9a8a1ff 100644 --- a/src/elements/stkm.c +++ b/src/elements/stkm.c @@ -85,10 +85,11 @@ int update_STKM(UPDATE_FUNC_ARGS) { player[26] = 0; //Go left - if (((int)(player[0])&0x01) == 0x01 && ptypes[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_GAS) + r = pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]; + if (((int)(player[0])&0x01) == 0x01 && ((r&0xFF>=PT_NUM) || ptypes[r&0xFF].state != ST_GAS)) { - if (ptypes[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_LIQUID - && (pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF) != PT_LNTG) + if (r>=PT_NUM || (ptypes[r&0xFF].state != ST_LIQUID + && (r&0xFF) != PT_LNTG)) { if (pmap[(int)(player[8]-1)][(int)(player[7])]) { @@ -123,10 +124,11 @@ int update_STKM(UPDATE_FUNC_ARGS) { } //Go right - if (((int)(player[0])&0x02) == 0x02 && ptypes[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_GAS) + r = pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]; + if (((int)(player[0])&0x02) == 0x02 && ((r&0xFF>=PT_NUM) || ptypes[r&0xFF].state != ST_GAS)) { - if (ptypes[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_LIQUID - && (pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF) != PT_LNTG) + if (r>=PT_NUM || (ptypes[r&0xFF].state != ST_LIQUID + && (r&0xFF) != PT_LNTG)) { if (pmap[(int)(player[8]-1)][(int)(player[7])]) { @@ -162,7 +164,11 @@ int update_STKM(UPDATE_FUNC_ARGS) { } //Jump - if (((int)(player[0])&0x04) == 0x04 && (ptypes[pmap[(int)(player[8]-0.5)][(int)(player[7])]&0xFF].state != ST_GAS || ptypes[pmap[(int)(player[16]-0.5)][(int)(player[15])]&0xFF].state != ST_GAS)) + if (((int)(player[0])&0x04) == 0x04 && ( + (pmap[(int)(player[8]-0.5)][(int)(player[7])]&0xFF)>=PT_NUM || + ptypes[pmap[(int)(player[8]-0.5)][(int)(player[7])]&0xFF].state != ST_GAS || + (pmap[(int)(player[16]-0.5)][(int)(player[15])]&0xFF)>=PT_NUM || + ptypes[pmap[(int)(player[16]-0.5)][(int)(player[15])]&0xFF].state != ST_GAS)) { if (pmap[(int)(player[8]-0.5)][(int)(player[7])] || pmap[(int)(player[16]-0.5)][(int)(player[15])]) { @@ -284,11 +290,11 @@ int update_STKM(UPDATE_FUNC_ARGS) { for (rx = -3; rx <= 3; rx++) { r = pmap[(int)(player[16]-2)][(int)(player[15]+rx)]; - if (r && ptypes[r&0xFF].state != ST_GAS && ptypes[r&0xFF].state != ST_LIQUID) + if (r && ((r&0xFF)>=PT_NUM || (ptypes[r&0xFF].state != ST_GAS && ptypes[r&0xFF].state != ST_LIQUID))) player[15] -= rx; r = pmap[(int)(player[8]-2)][(int)(player[7]+rx)]; - if (r && ptypes[r&0xFF].state != ST_GAS && ptypes[r&0xFF].state != ST_LIQUID) + if (r && ((r&0xFF)>=PT_NUM || (ptypes[r&0xFF].state != ST_GAS && ptypes[r&0xFF].state != ST_LIQUID))) player[7] -= rx; } @@ -300,7 +306,7 @@ int update_STKM(UPDATE_FUNC_ARGS) { //For left leg if (r && (r&0xFF)!=PT_STKM) { - if (ptypes[r&0xFF].state == ST_LIQUID || (r&0xFF) == PT_LNTG) //Liquid checks + if ((r&0xFF)<PT_NUM && (ptypes[r&0xFF].state == ST_LIQUID || (r&0xFF) == PT_LNTG)) //Liquid checks { if (parts[i].y<(player[8]-10)) parts[i].vy = 1*dt; @@ -311,7 +317,7 @@ int update_STKM(UPDATE_FUNC_ARGS) { } else { - if (ptypes[r&0xFF].state != ST_GAS) + if ((r&0xFF)>=PT_NUM || ptypes[r&0xFF].state != ST_GAS) { player[8] += ry-1; parts[i].vy -= 0.5*parts[i].vy*dt; @@ -325,7 +331,7 @@ int update_STKM(UPDATE_FUNC_ARGS) { //For right leg if (r && (r&0xFF)!=PT_STKM) { - if (ptypes[r&0xFF].state == ST_LIQUID || (r&0xFF) == PT_LNTG) + if ((r&0xFF)<PT_NUM && (ptypes[r&0xFF].state == ST_LIQUID || (r&0xFF) == PT_LNTG)) { if (parts[i].y<(player[16]-10)) parts[i].vy = 1*dt; @@ -336,7 +342,7 @@ int update_STKM(UPDATE_FUNC_ARGS) { } else { - if (ptypes[r&0xFF].state != ST_GAS) + if ((r&0xFF)>=PT_NUM || ptypes[r&0xFF].state != ST_GAS) { player[16] += ry-1; parts[i].vy -= 0.5*parts[i].vy*dt; diff --git a/src/elements/stkm2.c b/src/elements/stkm2.c index 79dbbdf..4498060 100644 --- a/src/elements/stkm2.c +++ b/src/elements/stkm2.c @@ -85,10 +85,11 @@ int update_STKM2(UPDATE_FUNC_ARGS) { player2[26] = 0; //Go left - if (((int)(player2[0])&0x01) == 0x01 && ptypes[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_GAS) + r = pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]; + if (((int)(player2[0])&0x01) == 0x01 && ((r&0xFF>=PT_NUM) || ptypes[r&0xFF].state != ST_GAS)) { - if (ptypes[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_LIQUID - && (pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF) != PT_LNTG) + if (r>=PT_NUM || ptypes[r&0xFF].state != ST_LIQUID + && (r&0xFF) != PT_LNTG) { if (pmap[(int)(player2[8]-1)][(int)(player2[7])]) { @@ -123,10 +124,11 @@ int update_STKM2(UPDATE_FUNC_ARGS) { } //Go right - if (((int)(player2[0])&0x02) == 0x02 && ptypes[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_GAS) + r = pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]; + if (((int)(player2[0])&0x02) == 0x02 && ((r&0xFF>=PT_NUM) || ptypes[r&0xFF].state != ST_GAS)) { - if (ptypes[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_LIQUID - && (pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF) != PT_LNTG) + if (r>=PT_NUM || (ptypes[r&0xFF].state != ST_LIQUID + && (r&0xFF) != PT_LNTG)) { if (pmap[(int)(player2[8]-1)][(int)(player2[7])]) { @@ -162,7 +164,11 @@ int update_STKM2(UPDATE_FUNC_ARGS) { } //Jump - if (((int)(player2[0])&0x04) == 0x04 && (ptypes[pmap[(int)(player2[8]-0.5)][(int)(player2[7])]&0xFF].state != ST_GAS || ptypes[pmap[(int)(player2[16]-0.5)][(int)(player2[15])]&0xFF].state != ST_GAS)) + if (((int)(player2[0])&0x04) == 0x04 && ( + (pmap[(int)(player2[8]-0.5)][(int)(player2[7])]&0xFF)>=PT_NUM || + ptypes[pmap[(int)(player2[8]-0.5)][(int)(player2[7])]&0xFF].state != ST_GAS || + (pmap[(int)(player2[16]-0.5)][(int)(player2[15])]&0xFF)>=PT_NUM || + ptypes[pmap[(int)(player2[16]-0.5)][(int)(player2[15])]&0xFF].state != ST_GAS)) { if (pmap[(int)(player2[8]-0.5)][(int)(player2[7])] || pmap[(int)(player2[16]-0.5)][(int)(player2[15])]) { @@ -284,11 +290,11 @@ int update_STKM2(UPDATE_FUNC_ARGS) { for (rx = -3; rx <= 3; rx++) { r = pmap[(int)(player2[16]-2)][(int)(player2[15]+rx)]; - if (r && ptypes[r&0xFF].state != ST_GAS && ptypes[r&0xFF].state != ST_LIQUID) + if (r && ((r&0xFF)>=PT_NUM || (ptypes[r&0xFF].state != ST_GAS && ptypes[r&0xFF].state != ST_LIQUID))) player2[15] -= rx; r = pmap[(int)(player2[8]-2)][(int)(player2[7]+rx)]; - if (r && ptypes[r&0xFF].state != ST_GAS && ptypes[r&0xFF].state != ST_LIQUID) + if (r && ((r&0xFF)>=PT_NUM || (ptypes[r&0xFF].state != ST_GAS && ptypes[r&0xFF].state != ST_LIQUID))) player2[7] -= rx; } @@ -300,7 +306,7 @@ int update_STKM2(UPDATE_FUNC_ARGS) { //For left leg if (r && (r&0xFF)!=PT_STKM) { - if (ptypes[r&0xFF].state == ST_LIQUID || (r&0xFF) == PT_LNTG) //Liquid checks + if ((r&0xFF)<PT_NUM && (ptypes[r&0xFF].state == ST_LIQUID || (r&0xFF) == PT_LNTG)) //Liquid checks { if (parts[i].y<(player2[8]-10)) parts[i].vy = 1*dt; @@ -311,7 +317,7 @@ int update_STKM2(UPDATE_FUNC_ARGS) { } else { - if (ptypes[r&0xFF].state != ST_GAS) + if ((r&0xFF)>=PT_NUM || ptypes[r&0xFF].state != ST_GAS) { player2[8] += ry-1; parts[i].vy -= 0.5*parts[i].vy*dt; @@ -325,7 +331,7 @@ int update_STKM2(UPDATE_FUNC_ARGS) { //For right leg if (r && (r&0xFF)!=PT_STKM) { - if (ptypes[r&0xFF].state == ST_LIQUID || (r&0xFF) == PT_LNTG) + if ((r&0xFF)<PT_NUM && (ptypes[r&0xFF].state == ST_LIQUID || (r&0xFF) == PT_LNTG)) { if (parts[i].y<(player2[16]-10)) parts[i].vy = 1*dt; @@ -336,7 +342,7 @@ int update_STKM2(UPDATE_FUNC_ARGS) { } else { - if (ptypes[r&0xFF].state != ST_GAS) + if ((r&0xFF)>=PT_NUM || ptypes[r&0xFF].state != ST_GAS) { player2[16] += ry-1; parts[i].vy -= 0.5*parts[i].vy*dt; |
