MCPcopy Create free account
hub / github.com/and3rson/raid / Run

Method Run

raid/mapgenerator.go:69–100  ·  view source on GitHub ↗
(ctx context.Context, wg *sync.WaitGroup, errch chan error)

Source from the content-addressed store, hash-verified

67}
68
69func (g *MapGenerator) Run(ctx context.Context, wg *sync.WaitGroup, errch chan error) {
70 defer log.Debug("mapgenerator: exit")
71
72 defer wg.Done()
73 wg.Add(1)
74
75 events := g.updates.Subscribe("mapgenerator", func(u Update) bool {
76 return u.IsFresh
77 })
78 defer g.updates.Unsubscribe(events)
79
80 for {
81 select {
82 case event, ok := <-events:
83 if !ok {
84 return
85 }
86
87 if !event.IsLast {
88 continue
89 }
90
91 if err := g.GenerateMap(g.updaterState, "", true); err != nil {
92 errch <- fmt.Errorf("mapgenerator: regenerate map: %w", err)
93
94 return
95 }
96 case <-ctx.Done():
97 return
98 }
99 }
100}
101
102func (g *MapGenerator) GenerateMap(updaterState *UpdaterState, title string, transparent bool) error {
103 stateAlerts := map[int]bool{}

Callers 1

mainFunction · 0.95

Calls 3

GenerateMapMethod · 0.95
SubscribeMethod · 0.80
UnsubscribeMethod · 0.80

Tested by

no test coverage detected