RTS: Simulating entire path always, fix bug one off goal
This commit is contained in:
@@ -138,7 +138,6 @@ MAP_RecomputeHistory :: (s: *MAP_Actor)
|
||||
Reset(&s.history)
|
||||
it := GetLast(&s.close_paths)
|
||||
Add(&s.history, *it)
|
||||
Pop(&s.history)
|
||||
for i := 0,,i += 1
|
||||
if it.p.x == s.p.x && it.p.y == s.p.y ;; break
|
||||
if i > 512
|
||||
@@ -172,7 +171,9 @@ MAP_PathFindUpdate :: (map: *MAP_Map)
|
||||
Reset(&s.history)
|
||||
break
|
||||
|
||||
MAP_PathFindStep :: (s: *MAP_Actor)
|
||||
MAP_PathFind(s)
|
||||
|
||||
MAP_PathFindStep :: (s: *MAP_Actor, compute_history: bool = true): bool
|
||||
if s.open_paths.len == 0
|
||||
// Reset if we didnt find solution
|
||||
if s.close_paths.len != 0
|
||||
@@ -189,7 +190,7 @@ MAP_PathFindStep :: (s: *MAP_Actor)
|
||||
last := GetLast(&s.close_paths)
|
||||
reached_target := last.p.x == s.target_p.x && last.p.y == s.target_p.y
|
||||
if reached_target
|
||||
return
|
||||
return true
|
||||
|
||||
it := Pop(&s.open_paths)
|
||||
Add(&s.close_paths, it)
|
||||
@@ -204,4 +205,11 @@ MAP_PathFindStep :: (s: *MAP_Actor)
|
||||
p := V2I{it.p.x + x, it.p.y + y}
|
||||
MAP_InsertOpenPath(s, p, it.p)
|
||||
|
||||
if compute_history ;; MAP_RecomputeHistory(s)
|
||||
return false
|
||||
|
||||
MAP_PathFind :: (s: *MAP_Actor)
|
||||
for i := 0, i < 128, i += 1
|
||||
done := MAP_PathFindStep(s, false)
|
||||
if done ;; break
|
||||
MAP_RecomputeHistory(s)
|
||||
|
||||
Reference in New Issue
Block a user