From 9358727075e52682c201479253d4de584d8c9db7 Mon Sep 17 00:00:00 2001 From: Raum0x2A Date: Wed, 5 May 2021 18:42:00 -0600 Subject: [PATCH] added RndPoral func to create Random Portal code --- nmslib_test.go | 7 ++++++- rpcg.go | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 rpcg.go diff --git a/nmslib_test.go b/nmslib_test.go index 65ad014..a256f6b 100644 --- a/nmslib_test.go +++ b/nmslib_test.go @@ -5,6 +5,11 @@ import ( "testing" ) +func TestRndPortal(t *testing.T) { + fmt.Printf("\nRandom Portal Code: ") + fmt.Println(RndPortal()) +} + func TestPortal2Galactic(t *testing.T) { want, err := P2gc("006afa556c30") if err != nil { @@ -51,7 +56,7 @@ func TestGalactic2portal(t *testing.T) { func TestCreateBanner(t *testing.T) { fmt.Printf("\nTesting CreateBanner: ") - CreateBanner("006afa556c30", "/tmp/Test.png", 0) + CreateBanner(RndPortal(), "/tmp/Test.png", 0) } func TestTranslate(t *testing.T) { diff --git a/rpcg.go b/rpcg.go new file mode 100644 index 0000000..c9b5beb --- /dev/null +++ b/rpcg.go @@ -0,0 +1,41 @@ +package nmslib + +import ( + "fmt" + "math/rand" + "time" +) + +/* + [P][SSS][YY][ZZZ][XXX] – (P = Planet Index / S = Star System Index / Y = Height / Z = Width / X = Length) + + `Solar System Index + A Solar System Index is assigned to each star system in a region. It always begins at SolarSystemIndex=001 + and counts up by one for every star system. The number of star systems in a region is variable so the + maximum value of the Solar System Index is also variable, though the two correspond directly. To date there + is no discovered value that is higher than SolarSystemIndex=243 (Mamundi-Kate in the Baadossm Anomaly of + Euclid galaxy), meaning that 579 is the maximum number of star systems yet discovered in a region. Based + on the evidence that every region has a SolarSystemIndex=079 and SolarSystemIndex=07A (with the former + always having a Black Hole and the latter always having an Atlas Station), it is known that every region has + at least 122 star systems. SolarSystemIndex=000 always leads to the region's first system, just like + PlanetIndex=0 always leads to the first portal of a system due to the error proximity mechanic.` + Source https://nomanssky.fandom.com/wiki/Portal_address#Solar_System_Index + +*/ + +func RndPortal() (final string) { + rand.Seed(time.Now().UnixNano()) + min := 0x1 + ymax := 0xFF + xzmax := 0xFFF + ssimax := 0x242 // set this low to lower chances of an invalid address + + x := rand.Intn(xzmax-min+1) + min + z := rand.Intn(xzmax-min+1) + min + y := rand.Intn(ymax-min+1) + min + ssi := rand.Intn(ssimax-min+1) + min + + final = fmt.Sprintf("%00X%03X%02X%03X%03X", 1, ssi, y, z, x) + + return +}