Updates and Features
This commit is contained in:
30
convert.go
30
convert.go
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
Xainesworld Video: https://www.youtube.com/watch?v=xmZbkTahw4w
|
||||
Fandom Wiki: https://nomanssky.fandom.com/wiki/Portal_address
|
||||
*/
|
||||
|
||||
package nmslib
|
||||
|
||||
import (
|
||||
@@ -7,18 +12,11 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
/*
|
||||
Xainesworld Video: https://www.youtube.com/watch?v=xmZbkTahw4w
|
||||
Fandom Wiki: https://nomanssky.fandom.com/wiki/Portal_address
|
||||
*/
|
||||
|
||||
/*
|
||||
P2gc - Portal code to galactic coordinates
|
||||
Requires 1 var and returns 1 var string and an error
|
||||
var p string
|
||||
Portal Glyph hex string 12 chars in len (ex. 006afa556c30)
|
||||
Return var string
|
||||
Galactic address (ex. 042F:0079:0D55:006A)
|
||||
var p string: Portal Glyph hex string 12 chars in len (ex. 006afa556c30)
|
||||
Returns var string: Galactic address (ex. 042F:0079:0D55:006A)
|
||||
*/
|
||||
func P2gc(p string) (gc string, err error) {
|
||||
if len(p) == 12 { // Test if length of provided string is 12 chars long
|
||||
@@ -68,12 +66,9 @@ func P2gc(p string) (gc string, err error) {
|
||||
/*
|
||||
Gc2p - Galactic coordinates to portal code
|
||||
Requires 1 string and 1 int returns a string and error
|
||||
var gc string
|
||||
Galactic address (ex. 042F:0079:0D55:006A)
|
||||
var p int
|
||||
Planet ID [1-6]
|
||||
Return portalcode string
|
||||
Portal Glyph hex string 12 chars in len (ex. 006afa556c30)
|
||||
var gc string: Galactic address (ex. 042F:0079:0D55:006A)
|
||||
var p int: Planet ID [1-6]
|
||||
Returns portalcode string: Portal Glyph hex string 12 chars in len (ex. 006afa556c30)
|
||||
*/
|
||||
func Gc2p(gc string, p int) (portalcode string, err error) {
|
||||
// split and store string
|
||||
@@ -114,6 +109,10 @@ func Gc2p(gc string, p int) (portalcode string, err error) {
|
||||
}
|
||||
|
||||
// Apply shifts to Handle the shape/boundaries of the galaxy
|
||||
/*Note:
|
||||
[P][SSS][YY][ZZZ][XXX] len == 12
|
||||
* SSS == SSI
|
||||
*/
|
||||
hexCoords[2] = hexCoords[2] + 0x81 // Y ->> shift
|
||||
hexCoords[3] = hexCoords[3] + 0x801 // Z ->> shift
|
||||
hexCoords[4] = hexCoords[4] + 0x801 // X ->> shift
|
||||
@@ -125,6 +124,7 @@ func Gc2p(gc string, p int) (portalcode string, err error) {
|
||||
}
|
||||
|
||||
// Assemble padded values as a string
|
||||
|
||||
portalcode = fmt.Sprintf("%00X%03X", hexCoords[0], hexCoords[1])
|
||||
for n := 2; n < len(hexCoords); n++ {
|
||||
if n == 2 {
|
||||
|
||||
Reference in New Issue
Block a user