summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2021-05-14 20:13:31 +0200
committerAki <please@ignore.pl>2021-05-14 20:13:31 +0200
commitebfa9e1a72b10f15ff30329bf31697eaeb71ad5e (patch)
tree5254f3c74311e93e628aff975981313c40cf7405
parentf49a11e686addcd8e3ce5160a0170c7bdb01f4bd (diff)
downloadfield-ebfa9e1a72b10f15ff30329bf31697eaeb71ad5e.zip
field-ebfa9e1a72b10f15ff30329bf31697eaeb71ad5e.tar.gz
field-ebfa9e1a72b10f15ff30329bf31697eaeb71ad5e.tar.bz2
Switched to int32 as esi scheme dictates
-rw-r--r--esi.go2
-rw-r--r--models.go19
-rw-r--r--storage.go4
3 files changed, 14 insertions, 11 deletions
diff --git a/esi.go b/esi.go
index f50eb4d..4eaa682 100644
--- a/esi.go
+++ b/esi.go
@@ -6,7 +6,7 @@ import (
"net/http"
)
-func GetKillmail(id uint64, hash string) (EsiKillmail, error) {
+func GetKillmail(id int32, hash string) (EsiKillmail, error) {
r, err := http.Get(fmt.Sprintf("https://esi.evetech.net/latest/killmails/%d/%s/", id, hash))
if err != nil {
return EsiKillmail{}, err
diff --git a/models.go b/models.go
index d79850b..7119fa9 100644
--- a/models.go
+++ b/models.go
@@ -4,12 +4,18 @@ import (
"time"
)
+type Vector3 struct {
+ X float64 `json:"x"`
+ Y float64 `json:"y"`
+ Z float64 `json:"z"`
+}
+
type Killmail struct {
- Id uint64 `json:"id"`
+ Id int32 `json:"id"`
Hash string `json:"hash"`
}
-type Team []uint32
+type Team []int32
type Battle struct {
Id string `json:"-"`
@@ -24,11 +30,10 @@ type Battle struct {
type EsiKillmail struct {
SolarSystemId int32 `json:"solar_system_id"`
Victim struct {
- Position struct {
- X float64 `json:"x"`
- Y float64 `json:"y"`
- Z float64 `json:"z"`
- } `json:"position"`
+ Position Vector3 `json:"position"`
+ ShipTypeId int32 `json:"ship_type_id"`
+ CorporationId int32 `json:"corporation_id"`
+ AllianceId int32 `json:"alliance_id"`
} `json:"victim"`
Time time.Time `json:"killmail_time"`
}
diff --git a/storage.go b/storage.go
index 738826e..ee3489a 100644
--- a/storage.go
+++ b/storage.go
@@ -6,13 +6,11 @@ import (
"encoding/json"
"errors"
"fmt"
- "io"
"io/ioutil"
"net/http"
"os"
"regexp"
"sort"
- "strconv"
)
type Storage struct {
@@ -45,7 +43,7 @@ func (b *Battle) CalculateHash() {
return killmails[lhs].Id < killmails[rhs].Id
})
for _, km := range killmails {
- io.WriteString(hash, strconv.FormatUint(km.Id, 10))
+ fmt.Fprint(hash, km.Id)
}
sum := hash.Sum(nil)
b.Id = hex.EncodeToString(sum[:])