1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-11-04 17:27:16 -05:00
OpenDiablo2/d2common/d2data/d2datadict/map_helper.go
Haashi 5e1725dd7d
385/lintissues (#391)
* camera offset for ui panels :

added maprenderer viewport to be aligned left or right

calling alignement on keyPress in game_controls

* check if already aligned

* fix bugs

-forgot to assign alignement
-defaultScreenRect instead of screenRect because of issue mentionned in original comment

* remove config.json and replace go.mod line

* removing duplicate import of d2common

replacing all dh to d2common

* remove useless breaks from switch statement

* better range when value unused + prettying import

* item_affix rewrite

using return values instead of pointer references in arguments

* ebiten deprecated calls

* small fixes
2020-06-22 11:53:44 -04:00

45 lines
1011 B
Go

package d2datadict
import (
"strings"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
)
func MapHeaders(line string) map[string]int {
m := make(map[string]int)
r := strings.Split(line, "\t")
for index, header := range r {
m[header] = index
}
return m
}
func MapLoadInt(r *[]string, mapping *map[string]int, field string) int {
index, ok := (*mapping)[field]
if ok {
return d2common.StringToInt(d2common.EmptyToZero(d2common.AsterToEmpty((*r)[index])))
}
return 0
}
func MapLoadString(r *[]string, mapping *map[string]int, field string) string {
index, ok := (*mapping)[field]
if ok {
return d2common.AsterToEmpty((*r)[index])
}
return ""
}
func MapLoadBool(r *[]string, mapping *map[string]int, field string) bool {
return MapLoadInt(r, mapping, field) == 1
}
func MapLoadUint8(r *[]string, mapping *map[string]int, field string) uint8 {
index, ok := (*mapping)[field]
if ok {
return d2common.StringToUint8(d2common.EmptyToZero(d2common.AsterToEmpty((*r)[index])))
}
return 0
}