prevent subscript error from occurring by validating eID and pID are both different from ~1, as the PathFinding.start function expects this to be the case
This commit is contained in:
@@ -355,17 +355,25 @@ struct
|
|||||||
(* todo: possibly get pID and eID of player/enemy in a different way *)
|
(* todo: possibly get pID and eID of player/enemy in a different way *)
|
||||||
val pID = getPlatformBelowPlayer (player, platformTree, platforms)
|
val pID = getPlatformBelowPlayer (player, platformTree, platforms)
|
||||||
val eID = getPlatformBelowEnemy (enemy, platformTree, platforms)
|
val eID = getPlatformBelowEnemy (enemy, platformTree, platforms)
|
||||||
|
|
||||||
val bestPath = PathFinding.start (pID, eID, platforms, platformTree)
|
|
||||||
in
|
in
|
||||||
if eID = pID then
|
if eID = pID then
|
||||||
EnemyPatch.W_Y_AXIS FALLING :: acc
|
EnemyPatch.W_Y_AXIS FALLING :: acc
|
||||||
|
else if eID = ~1 orelse pID = ~1 then
|
||||||
|
(* without checking that neither of these are ~1
|
||||||
|
* (which means there is no platform below the enemy/player)
|
||||||
|
* there is a subscript error because the PathFinding.start
|
||||||
|
* function expects neither of these values to be ~1. *)
|
||||||
|
acc
|
||||||
else
|
else
|
||||||
case bestPath of
|
let
|
||||||
nextPlatformID :: _ =>
|
val bestPath = PathFinding.start (pID, eID, platforms, platformTree)
|
||||||
getPathToNextPlatform
|
in
|
||||||
(nextPlatformID, platforms, platformTree, enemy, eID, pID, acc)
|
case bestPath of
|
||||||
| [] => acc
|
nextPlatformID :: _ =>
|
||||||
|
getPathToNextPlatform
|
||||||
|
(nextPlatformID, platforms, platformTree, enemy, eID, pID, acc)
|
||||||
|
| [] => acc
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
fun getFollowPatches
|
fun getFollowPatches
|
||||||
|
|||||||
@@ -168,8 +168,9 @@ struct
|
|||||||
val plat5 = {id = 5, x = 155, y = 811, width = 199}
|
val plat5 = {id = 5, x = 155, y = 811, width = 199}
|
||||||
val plat6 = {id = 6, x = 155, y = 710, width = 199}
|
val plat6 = {id = 6, x = 155, y = 710, width = 199}
|
||||||
val plat7 = {id = 7, x = 301, y = 855, width = 99}
|
val plat7 = {id = 7, x = 301, y = 855, width = 99}
|
||||||
|
val plat8 = {id = 8, x = 950, y = 710, width = 300}
|
||||||
val platforms = Vector.fromList
|
val platforms = Vector.fromList
|
||||||
[plat1, plat2, plat3, plat4, plat5, plat6, plat7]
|
[plat1, plat2, plat3, plat4, plat5, plat6, plat7, plat8]
|
||||||
val platformTree = Platform.generateTree platforms
|
val platformTree = Platform.generateTree platforms
|
||||||
|
|
||||||
val enemy1 =
|
val enemy1 =
|
||||||
|
|||||||
Reference in New Issue
Block a user