Skip to content

Commit ae8a4ac

Browse files
committed
[Prot] Try some things to avoid multi-threading test failure
Will enable mana regen when a solution has been found
1 parent f3ca8b8 commit ae8a4ac

4 files changed

Lines changed: 3170 additions & 24 deletions

File tree

sim/core/sim.go

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -608,20 +608,18 @@ func (sim *Simulation) AddPendingAction(pa *PendingAction) {
608608
// panic(fmt.Sprintf("Cant add action in the past: %s", pa.NextActionAt))
609609
//}
610610
pa.consumed = false
611-
if len(sim.pendingActions) > 0 {
612-
for index, v := range sim.pendingActions[1:] {
613-
if v.NextActionAt < pa.NextActionAt || (v.NextActionAt == pa.NextActionAt && v.Priority >= pa.Priority) {
614-
//if sim.Log != nil {
615-
// sim.Log("Adding action at index %d for time %s", index - len(sim.pendingActions), pa.NextActionAt)
616-
// for i := index; i < len(sim.pendingActions); i++ {
617-
// sim.Log("Upcoming action at %s", sim.pendingActions[i].NextActionAt)
618-
// }
619-
//}
620-
sim.pendingActions = append(sim.pendingActions, pa)
621-
copy(sim.pendingActions[index+2:], sim.pendingActions[index+1:])
622-
sim.pendingActions[index+1] = pa
623-
return
624-
}
611+
for index, v := range sim.pendingActions[1:] {
612+
if v.NextActionAt < pa.NextActionAt || (v.NextActionAt == pa.NextActionAt && v.Priority >= pa.Priority) {
613+
//if sim.Log != nil {
614+
// sim.Log("Adding action at index %d for time %s", index - len(sim.pendingActions), pa.NextActionAt)
615+
// for i := index; i < len(sim.pendingActions); i++ {
616+
// sim.Log("Upcoming action at %s", sim.pendingActions[i].NextActionAt)
617+
// }
618+
//}
619+
sim.pendingActions = append(sim.pendingActions, pa)
620+
copy(sim.pendingActions[index+2:], sim.pendingActions[index+1:])
621+
sim.pendingActions[index+1] = pa
622+
return
625623
}
626624
}
627625
//if sim.Log != nil {

0 commit comments

Comments
 (0)