Skip to content

Commit

Permalink
fix edge case where region detected but not in daily dump
Browse files Browse the repository at this point in the history
  • Loading branch information
NotAName320 committed Apr 13, 2024
1 parent c8aa993 commit ed6bcad
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func main() {
endoCountString = strings.ToLower(scanner.Text())
time.Sleep(50 * time.Millisecond)
}
log.Printf("Endo count set to %d\n", maxEndoCount)
log.Printf("Endo count set to %d!\n", maxEndoCount)
time.Sleep(500 * time.Millisecond)

for minTrigString := ""; err != nil || minimumTrigger < 1; minimumTrigger, err = strconv.Atoi(minTrigString) {
Expand All @@ -117,7 +117,8 @@ func main() {
minTrigString = strings.ToLower(scanner.Text())
time.Sleep(50 * time.Millisecond)
}
log.Printf("Minimum trigger %d\n", minimumTrigger)
log.Printf("Minimum trigger set to %d!\n", minimumTrigger)
time.Sleep(500 * time.Millisecond)

getNewDump := true
if _, err := os.Stat("regions.xml"); err == nil {
Expand Down Expand Up @@ -186,6 +187,11 @@ func main() {
}
time.Sleep(1500 * time.Millisecond) //courtesy sleep even though we have ratelimiting
}
if len(hittable) == 0 {
log.Print("No regions are hittable! Press enter to exit...")
scanner.Scan()
}

log.Printf("Checks done! %d regions are hittable!\n", len(hittable))

//sort hittable targets by update time
Expand Down Expand Up @@ -240,6 +246,11 @@ func main() {
updateTimes[regionUpdate] = canonName
}

//edge case where region doesn't exit in daily dump
if hitIndex != len(hittable)-1 && canonName == hittable[hitIndex+1].Name {
hitIndex++
}

if canonName == hittable[hitIndex].Name {
hittable[hitIndex].UpdateTime = regionUpdate
for i := 0; true; i++ {
Expand Down Expand Up @@ -298,5 +309,6 @@ func main() {
log.Fatal(err)
}

log.Println("Files created! Exiting...")
log.Print("Files created! Press enter to exit...")
scanner.Scan()
}

0 comments on commit ed6bcad

Please sign in to comment.