ominous scanning info

pull/5/head
Jordan Orelli 10 years ago
parent 4f45c203f7
commit d85872b0a2

@ -150,19 +150,47 @@ func randomSystem() (*System, error) {
return planet, nil
}
type scanResults struct {
life bool
}
func (r *scanResults) negative() bool {
return !r.life
}
func (r *scanResults) String() string {
if r.negative() {
return "negative"
}
if r.life {
return "life detected"
}
return "(none)"
}
func scanSystem(id int, reply int) {
system := index[id]
source := index[reply]
delay := system.TimeTo(source)
log_info("scan hit %s from %s after traveling for %v", system.name, source.name, delay)
system.EachConn(func(conn *Connection) {
fmt.Fprintf(conn, "scan detected from %s\n", source.name)
})
results := &scanResults{
life: len(system.players) > 0,
}
After(delay, func() {
deliverReply(source.id, system.id)
deliverReply(source.id, system.id, results)
})
}
func deliverReply(id int, echo int) {
func deliverReply(id int, echo int, results *scanResults) {
system := index[id]
source := index[echo]
delay := system.TimeTo(source)
log_info("echo received at %s reflected from %s after traveling for %v", system.name, source.name, delay)
system.EachConn(func(conn *Connection) {
fmt.Fprintf(conn, "scan results from %s (%v away): %v\n", source.name, delay, results)
})
}

@ -68,7 +68,6 @@ func RunQueue() {
if future.ts.After(time.Now()) {
time.Sleep(future.ts.Sub(time.Now()))
}
log_info("performing work")
future.work()
}
}

Loading…
Cancel
Save