Skip to content
This repository was archived by the owner on Mar 24, 2018. It is now read-only.

Commit 4d805d7

Browse files
committed
Jove and special systems will not be loaded into base universe
- added sanity check to New Eden to have all systems with gates
1 parent 1eaa3dc commit 4d805d7

File tree

1 file changed

+58
-6
lines changed

1 file changed

+58
-6
lines changed

main.go

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,25 @@ import (
2121
"github.com/dertseha/everoute-web/data"
2222
)
2323

24+
func reachableSystemPredicate() func(data.SolarSystemData) bool {
25+
joveRegion := universe.Id(10000017)
26+
specialSystems := make(map[universe.Id]interface{})
27+
28+
specialSystems[30000377] = nil
29+
specialSystems[30000380] = nil
30+
specialSystems[30000381] = nil
31+
32+
return func(system data.SolarSystemData) bool {
33+
isJoveRegion := system.RegionId == joveRegion
34+
_, isSpecialSystem := specialSystems[system.SolarSystemId]
35+
36+
return !isJoveRegion && !isSpecialSystem
37+
}
38+
}
39+
2440
func buildSolarSystems(builder *universe.UniverseBuilder) {
41+
isSystemReachable := reachableSystemPredicate()
42+
2543
for _, system := range data.SolarSystems {
2644
trueSec := universe.TrueSecurity(system.Security)
2745
galaxyId := universe.NewEdenId
@@ -30,8 +48,10 @@ func buildSolarSystems(builder *universe.UniverseBuilder) {
3048
galaxyId = universe.WSpaceId
3149
}
3250

33-
builder.AddSolarSystem(system.SolarSystemId, system.ConstellationId, system.RegionId, galaxyId,
34-
universe.NewSpecificLocation(system.X, system.Y, system.Z), trueSec)
51+
if isSystemReachable(system) {
52+
builder.AddSolarSystem(system.SolarSystemId, system.ConstellationId, system.RegionId, galaxyId,
53+
universe.NewSpecificLocation(system.X, system.Y, system.Z), trueSec)
54+
}
3555
}
3656
}
3757

@@ -73,13 +93,28 @@ func getJumpGateLocations() map[string]universe.Location {
7393

7494
func buildJumpGates(builder *universe.UniverseBuilder) {
7595
jumpGateLocations := getJumpGateLocations()
96+
ids := builder.SolarSystemIds()
97+
isSystemReachable := func(id universe.Id) bool {
98+
found := false
99+
100+
for _, temp := range ids {
101+
if temp == id {
102+
found = true
103+
}
104+
}
105+
106+
return found
107+
}
76108

77109
for _, jumpData := range data.SolarSystemJumps {
78-
extension := builder.ExtendSolarSystem(jumpData.FromSolarSystemId)
79-
jumpBuilder := extension.BuildJump(jumpgate.JumpType, jumpData.ToSolarSystemId)
80110

81-
jumpBuilder.From(jumpGateLocations[getJumpGateKey(jumpData.FromSolarSystemId, jumpData.ToSolarSystemId)])
82-
jumpBuilder.To(jumpGateLocations[getJumpGateKey(jumpData.ToSolarSystemId, jumpData.FromSolarSystemId)])
111+
if isSystemReachable(jumpData.FromSolarSystemId) && isSystemReachable(jumpData.ToSolarSystemId) {
112+
extension := builder.ExtendSolarSystem(jumpData.FromSolarSystemId)
113+
jumpBuilder := extension.BuildJump(jumpgate.JumpType, jumpData.ToSolarSystemId)
114+
115+
jumpBuilder.From(jumpGateLocations[getJumpGateKey(jumpData.FromSolarSystemId, jumpData.ToSolarSystemId)])
116+
jumpBuilder.To(jumpGateLocations[getJumpGateKey(jumpData.ToSolarSystemId, jumpData.FromSolarSystemId)])
117+
}
83118
}
84119
}
85120

@@ -104,6 +139,22 @@ func prepareUniverse() *universe.UniverseBuilder {
104139
return builder
105140
}
106141

142+
func checkBaseUniverse(verse universe.Universe) {
143+
ids := verse.SolarSystemIds()
144+
145+
for _, id := range ids {
146+
solarSystem := verse.SolarSystem(id)
147+
148+
if solarSystem.GalaxyId() == universe.NewEdenId {
149+
gateJumps := solarSystem.Jumps(jumpgate.JumpType)
150+
151+
if len(gateJumps) == 0 {
152+
log.Printf("Solar System %v has no jump gates!", id)
153+
}
154+
}
155+
}
156+
}
157+
107158
func initRuntime() {
108159
numCpu := runtime.NumCPU()
109160
maxThreads := 250 // Heroku limit: 256
@@ -119,6 +170,7 @@ func main() {
119170
log.Printf("Building universe...")
120171
universeBuilder := prepareUniverse()
121172
universe := universeBuilder.Build()
173+
checkBaseUniverse(universe)
122174

123175
log.Printf("Initializing server...")
124176
rpcServer := rpc.NewServer()

0 commit comments

Comments
 (0)