alaingilbert/ogame

GetPlanetByCoord

eperdeme opened this issue · 8 comments

Hello,

Am I doing something wrong, or does GetPlanetByCoord not return any data ?

Really basic but;

mp := bot.GetPlanets()
fmt.Println(mp)

p, err := bot.GetPlanetByCoord(ogame.Coordinate{Galaxy: int(1), System: int(207), Position: int(10)})
fmt.Println(p)

"fmt.Println(mp)" outputs my planets, so it's logged in and targetting the right universe, but the "fmt.Println(p)" outputs the below.
{ 0 0 [0:0:0:0] {0 0} {0 0} }

But a planet exists in 1,207,10 in the galaxy.

I also tried the HTTP services and that also seems to find no planets but other functions work fine.

Ah, it all started from;

curl -v 127.0.0.1:8080/bot/galaxy-infos/1/120
{"Status":"ok","Code":200,"Message":"","Result":{}}%

Adding debug to the services I see;
{1 120 [ 0xc00035e210 0xc00035e2c0 0xc0001ec000 0xc0001ec0b0 0xc0001ec160 0xc0001ec210 0xc0001ec2c0 ]}

So I guess it's the services not returning things correctly as it finds galaxy-infos, I'll er go see if I can debug it.

Oh, interesting, I'll give a look

I'm curious what version of ogamed are you using ? and server language ?
ogamed -v

master branch, compiled it myself to try and debug it.
➜ ogamed git:(master) ✗ ./main -v
ogamed version 0.0.0

Also just tried the binary edition;
➜ ogamed git:(master) ✗ ./ogamed --version
ogamed version 7.2.6

➜ ogamed git:(master) ✗ curl -v 127.0.0.1:8080/bot/galaxy-infos/1/200

  • Trying 127.0.0.1...
  • Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)

GET /bot/galaxy-infos/1/200 HTTP/1.1
Host: 127.0.0.1:8080
User-Agent: curl/7.49.0
Accept: /

< HTTP/1.1 200 OK
< Content-Type: application/json; charset=UTF-8
< Date: Sun, 18 Nov 2018 14:51:07 GMT
< Content-Length: 51
<

  • Connection #0 to host 127.0.0.1 left intact
    {"Status":"ok","Code":200,"Message":"","Result":{}}%

Other stuff works;

➜ ogamed git:(master) ✗ curl 127.0.0.1:8080/bot/planets
{"Status":"ok","Code":200,"Message":"","Result":[{"Img":"https://gf2.geo.gfsrv.net/cdn46/dDD22k2o2.png","ID":33621869,"Name":"MrCows","Diameter":12800,"Coordinate":{"Galaxy":1,"System":123,"Position":6,"Type":1},"Fields":{"Bui

Tried several random versions, seems to work on ogamed_1.2.10_darwin_amd64 and did not work on ogamed_2.0.1_darwin_amd64+++ so something between them editions.

I fixed the issue.
Basically, unexported fields are not json serialized in Go.
6119cca

I also added a test to ensure it keeps working.
be13117

So it should work from V7.2.7

Looks good to me. Thank you for your help.