mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2025-01-14 21:36:40 -05:00
4938ec1f44
* adding comments to d2interface for linter * moved d2render renderer interfaces and types into d2interface * fixed most lint errors for monstats loader * de-lint d2data wip * d2data: resolve linting errors
50 lines
1009 B
Go
50 lines
1009 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
|
|
}
|