mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-06-16 04:25:23 +00:00
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
This commit is contained in:
parent
711cae2d69
commit
5e1725dd7d
|
@ -246,7 +246,7 @@ func adjustTree(newNode *linkedNode) {
|
||||||
var prev *linkedNode
|
var prev *linkedNode
|
||||||
// Go backwards thru the list looking for the insertion point
|
// Go backwards thru the list looking for the insertion point
|
||||||
insertpoint = current
|
insertpoint = current
|
||||||
for true {
|
for {
|
||||||
prev = insertpoint.Prev
|
prev = insertpoint.Prev
|
||||||
if prev == nil {
|
if prev == nil {
|
||||||
break
|
break
|
||||||
|
@ -347,23 +347,19 @@ func HuffmanDecompress(data []byte) []byte {
|
||||||
outputstream := d2common.CreateStreamWriter()
|
outputstream := d2common.CreateStreamWriter()
|
||||||
bitstream := d2common.CreateBitStream(data[1:])
|
bitstream := d2common.CreateBitStream(data[1:])
|
||||||
var decoded int
|
var decoded int
|
||||||
for true {
|
Loop:
|
||||||
|
for {
|
||||||
node := decode(bitstream, head)
|
node := decode(bitstream, head)
|
||||||
decoded = node.DecompressedValue
|
decoded = node.DecompressedValue
|
||||||
switch decoded {
|
switch decoded {
|
||||||
case 256:
|
case 256:
|
||||||
break
|
break Loop
|
||||||
case 257:
|
case 257:
|
||||||
newvalue := bitstream.ReadBits(8)
|
newvalue := bitstream.ReadBits(8)
|
||||||
outputstream.PushByte(byte(newvalue))
|
outputstream.PushByte(byte(newvalue))
|
||||||
tail = insertNode(tail, newvalue)
|
tail = insertNode(tail, newvalue)
|
||||||
break
|
|
||||||
default:
|
default:
|
||||||
outputstream.PushByte(byte(decoded))
|
outputstream.PushByte(byte(decoded))
|
||||||
break
|
|
||||||
}
|
|
||||||
if decoded == 256 {
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,6 @@ func WavDecompress(data []byte, channelCount int) []byte {
|
||||||
Array1[channel]--
|
Array1[channel]--
|
||||||
}
|
}
|
||||||
output.PushInt16(int16(Array2[channel]))
|
output.PushInt16(int16(Array2[channel]))
|
||||||
break
|
|
||||||
case 1:
|
case 1:
|
||||||
Array1[channel] += 8
|
Array1[channel] += 8
|
||||||
if Array1[channel] > 0x58 {
|
if Array1[channel] > 0x58 {
|
||||||
|
@ -66,9 +65,7 @@ func WavDecompress(data []byte, channelCount int) []byte {
|
||||||
if channelCount == 2 {
|
if channelCount == 2 {
|
||||||
channel = 1 - channel
|
channel = 1 - channel
|
||||||
}
|
}
|
||||||
break
|
|
||||||
case 2:
|
case 2:
|
||||||
break
|
|
||||||
default:
|
default:
|
||||||
Array1[channel] -= 8
|
Array1[channel] -= 8
|
||||||
if Array1[channel] < 0 {
|
if Array1[channel] < 0 {
|
||||||
|
@ -77,7 +74,6 @@ func WavDecompress(data []byte, channelCount int) []byte {
|
||||||
if channelCount == 2 {
|
if channelCount == 2 {
|
||||||
channel = 1 - channel
|
channel = 1 - channel
|
||||||
}
|
}
|
||||||
break
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
temp1 := sLookup[Array1[channel]]
|
temp1 := sLookup[Array1[channel]]
|
||||||
|
|
|
@ -92,7 +92,7 @@ func LoadCharStats(file []byte) {
|
||||||
d := d2common.LoadDataDictionary(string(file))
|
d := d2common.LoadDataDictionary(string(file))
|
||||||
CharStats = make(map[d2enum.Hero]*CharStatsRecord, len(d.Data))
|
CharStats = make(map[d2enum.Hero]*CharStatsRecord, len(d.Data))
|
||||||
|
|
||||||
for idx, _ := range d.Data {
|
for idx := range d.Data {
|
||||||
record := &CharStatsRecord{
|
record := &CharStatsRecord{
|
||||||
Class: charStringMap[d.GetString("class", idx)],
|
Class: charStringMap[d.GetString("class", idx)],
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ func LoadDifficultyLevels(file []byte) {
|
||||||
|
|
||||||
DifficultyLevels = make(map[string]*DifficultyLevelRecord, numRows)
|
DifficultyLevels = make(map[string]*DifficultyLevelRecord, numRows)
|
||||||
|
|
||||||
for idx, _ := range dict.Data {
|
for idx := range dict.Data {
|
||||||
record := &DifficultyLevelRecord{
|
record := &DifficultyLevelRecord{
|
||||||
Name: dict.GetString("Name", idx),
|
Name: dict.GetString("Name", idx),
|
||||||
ResistancePenalty: dict.GetNumber("ResistPenalty", idx),
|
ResistancePenalty: dict.GetNumber("ResistPenalty", idx),
|
||||||
|
|
|
@ -77,7 +77,7 @@ func LoadExperienceBreakpoints(file []byte) {
|
||||||
// we skip the second row because that describes max level of char classes
|
// we skip the second row because that describes max level of char classes
|
||||||
ExperienceBreakpoints = make([]*ExperienceBreakpointsRecord, len(d.Data)-1)
|
ExperienceBreakpoints = make([]*ExperienceBreakpointsRecord, len(d.Data)-1)
|
||||||
|
|
||||||
for idx, _ := range d.Data {
|
for idx := range d.Data {
|
||||||
if idx == 0 {
|
if idx == 0 {
|
||||||
// max levels are a special case
|
// max levels are a special case
|
||||||
maxLevels = map[d2enum.Hero]int{
|
maxLevels = map[d2enum.Hero]int{
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package d2datadict
|
package d2datadict
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GemsRecord struct {
|
type GemsRecord struct {
|
||||||
|
@ -52,7 +53,7 @@ type GemsRecord struct {
|
||||||
func LoadGems(file []byte) {
|
func LoadGems(file []byte) {
|
||||||
d := d2common.LoadDataDictionary(string(file))
|
d := d2common.LoadDataDictionary(string(file))
|
||||||
var Gems []*GemsRecord
|
var Gems []*GemsRecord
|
||||||
for idx, _ := range d.Data {
|
for idx := range d.Data {
|
||||||
if d.GetString("name", idx) != "Expansion" {
|
if d.GetString("name", idx) != "Expansion" {
|
||||||
/*
|
/*
|
||||||
"Expansion" is the only field in line 36 of /data/global/excel/gems.txt and is only used to visually
|
"Expansion" is the only field in line 36 of /data/global/excel/gems.txt and is only used to visually
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package d2datadict
|
package d2datadict
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
||||||
)
|
)
|
||||||
|
|
||||||
type HirelingRecord struct {
|
type HirelingRecord struct {
|
||||||
|
@ -83,7 +84,7 @@ type HirelingRecord struct {
|
||||||
func LoadHireling(file []byte) {
|
func LoadHireling(file []byte) {
|
||||||
d := d2common.LoadDataDictionary(string(file))
|
d := d2common.LoadDataDictionary(string(file))
|
||||||
var Hirelings []*HirelingRecord
|
var Hirelings []*HirelingRecord
|
||||||
for idx, _ := range d.Data {
|
for idx := range d.Data {
|
||||||
hireling := &HirelingRecord{
|
hireling := &HirelingRecord{
|
||||||
Hireling: d.GetString("Hireling", idx),
|
Hireling: d.GetString("Hireling", idx),
|
||||||
SubType: d.GetString("SubType", idx),
|
SubType: d.GetString("SubType", idx),
|
||||||
|
|
|
@ -22,13 +22,13 @@ var subType d2enum.ItemAffixSubType
|
||||||
func LoadMagicPrefix(file []byte) {
|
func LoadMagicPrefix(file []byte) {
|
||||||
superType = d2enum.ItemAffixPrefix
|
superType = d2enum.ItemAffixPrefix
|
||||||
subType = d2enum.ItemAffixMagic
|
subType = d2enum.ItemAffixMagic
|
||||||
loadDictionary(file, MagicPrefixDictionary, superType, subType)
|
MagicPrefixDictionary, MagicPrefixRecords = loadDictionary(file, superType, subType)
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadMagicSuffix(file []byte) {
|
func LoadMagicSuffix(file []byte) {
|
||||||
superType = d2enum.ItemAffixSuffix
|
superType = d2enum.ItemAffixSuffix
|
||||||
subType = d2enum.ItemAffixMagic
|
subType = d2enum.ItemAffixMagic
|
||||||
loadDictionary(file, MagicSuffixDictionary, superType, subType)
|
MagicSuffixDictionary, MagicSuffixRecords = loadDictionary(file, superType, subType)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getAffixString(t1 d2enum.ItemAffixSuperType, t2 d2enum.ItemAffixSubType) string {
|
func getAffixString(t1 d2enum.ItemAffixSuperType, t2 d2enum.ItemAffixSubType) string {
|
||||||
|
@ -52,16 +52,14 @@ func getAffixString(t1 d2enum.ItemAffixSuperType, t2 d2enum.ItemAffixSubType) st
|
||||||
|
|
||||||
func loadDictionary(
|
func loadDictionary(
|
||||||
file []byte,
|
file []byte,
|
||||||
dict *d2common.DataDictionary,
|
|
||||||
superType d2enum.ItemAffixSuperType,
|
superType d2enum.ItemAffixSuperType,
|
||||||
subType d2enum.ItemAffixSubType,
|
subType d2enum.ItemAffixSubType,
|
||||||
) {
|
) (*d2common.DataDictionary, []*ItemAffixCommonRecord) {
|
||||||
dict = d2common.LoadDataDictionary(string(file))
|
dict := d2common.LoadDataDictionary(string(file))
|
||||||
records := make([]*ItemAffixCommonRecord, 0)
|
records := createItemAffixRecords(dict, superType, subType)
|
||||||
|
|
||||||
createItemAffixRecords(dict, records, superType, subType)
|
|
||||||
name := getAffixString(superType, subType)
|
name := getAffixString(superType, subType)
|
||||||
log.Printf("Loaded %d %s records", len(dict.Data), name)
|
log.Printf("Loaded %d %s records", len(dict.Data), name)
|
||||||
|
return dict, records
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- column names from d2exp.mpq:/data/globa/excel/MagicPrefix.txt
|
// --- column names from d2exp.mpq:/data/globa/excel/MagicPrefix.txt
|
||||||
|
@ -109,11 +107,11 @@ func loadDictionary(
|
||||||
|
|
||||||
func createItemAffixRecords(
|
func createItemAffixRecords(
|
||||||
d *d2common.DataDictionary,
|
d *d2common.DataDictionary,
|
||||||
r []*ItemAffixCommonRecord,
|
|
||||||
superType d2enum.ItemAffixSuperType,
|
superType d2enum.ItemAffixSuperType,
|
||||||
subType d2enum.ItemAffixSubType,
|
subType d2enum.ItemAffixSubType,
|
||||||
) {
|
) []*ItemAffixCommonRecord {
|
||||||
for index, _ := range d.Data {
|
records := make([]*ItemAffixCommonRecord, 0)
|
||||||
|
for index := range d.Data {
|
||||||
|
|
||||||
affix := &ItemAffixCommonRecord{
|
affix := &ItemAffixCommonRecord{
|
||||||
Name: d.GetString("Name", index),
|
Name: d.GetString("Name", index),
|
||||||
|
@ -179,8 +177,9 @@ func createItemAffixRecords(
|
||||||
group := ItemAffixGroups[affix.GroupID]
|
group := ItemAffixGroups[affix.GroupID]
|
||||||
group.AddMember(affix)
|
group.AddMember(affix)
|
||||||
|
|
||||||
r = append(r, affix)
|
records = append(records, affix)
|
||||||
}
|
}
|
||||||
|
return records
|
||||||
}
|
}
|
||||||
|
|
||||||
var ItemAffixGroups map[int]*ItemAffixCommonGroup
|
var ItemAffixGroups map[int]*ItemAffixCommonGroup
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
package d2datadict
|
package d2datadict
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
||||||
"log"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// refer to https://d2mods.info/forum/kb/viewarticle?a=448
|
// refer to https://d2mods.info/forum/kb/viewarticle?a=448
|
||||||
|
@ -245,7 +246,7 @@ func LoadItemStatCosts(file []byte) {
|
||||||
numRecords := len(d.Data)
|
numRecords := len(d.Data)
|
||||||
ItemStatCosts = make(map[string]*ItemStatCostRecord, numRecords)
|
ItemStatCosts = make(map[string]*ItemStatCostRecord, numRecords)
|
||||||
|
|
||||||
for idx, _ := range d.Data {
|
for idx := range d.Data {
|
||||||
record := &ItemStatCostRecord{
|
record := &ItemStatCostRecord{
|
||||||
Name: d.GetString("Stat", idx),
|
Name: d.GetString("Stat", idx),
|
||||||
Index: d.GetNumber("ID", idx),
|
Index: d.GetNumber("ID", idx),
|
||||||
|
|
|
@ -40,7 +40,7 @@ func LoadLevelMazeDetails(file []byte) {
|
||||||
dict := d2common.LoadDataDictionary(string(file))
|
dict := d2common.LoadDataDictionary(string(file))
|
||||||
numRecords := len(dict.Data)
|
numRecords := len(dict.Data)
|
||||||
LevelMazeDetails = make(map[int]*LevelMazeDetailsRecord, numRecords)
|
LevelMazeDetails = make(map[int]*LevelMazeDetailsRecord, numRecords)
|
||||||
for idx, _ := range dict.Data {
|
for idx := range dict.Data {
|
||||||
record := &LevelMazeDetailsRecord{
|
record := &LevelMazeDetailsRecord{
|
||||||
Name: dict.GetString("Name", idx),
|
Name: dict.GetString("Name", idx),
|
||||||
LevelId: dict.GetNumber("Level", idx),
|
LevelId: dict.GetNumber("Level", idx),
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
dh "github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
||||||
)
|
)
|
||||||
|
|
||||||
type LevelPresetRecord struct {
|
type LevelPresetRecord struct {
|
||||||
|
@ -39,21 +39,21 @@ func createLevelPresetRecord(props []string) LevelPresetRecord {
|
||||||
}
|
}
|
||||||
result := LevelPresetRecord{
|
result := LevelPresetRecord{
|
||||||
Name: props[inc()],
|
Name: props[inc()],
|
||||||
DefinitionId: dh.StringToInt(props[inc()]),
|
DefinitionId: d2common.StringToInt(props[inc()]),
|
||||||
LevelId: dh.StringToInt(props[inc()]),
|
LevelId: d2common.StringToInt(props[inc()]),
|
||||||
Populate: dh.StringToUint8(props[inc()]) == 1,
|
Populate: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
Logicals: dh.StringToUint8(props[inc()]) == 1,
|
Logicals: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
Outdoors: dh.StringToUint8(props[inc()]) == 1,
|
Outdoors: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
Animate: dh.StringToUint8(props[inc()]) == 1,
|
Animate: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
KillEdge: dh.StringToUint8(props[inc()]) == 1,
|
KillEdge: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
FillBlanks: dh.StringToUint8(props[inc()]) == 1,
|
FillBlanks: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
SizeX: dh.StringToInt(props[inc()]),
|
SizeX: d2common.StringToInt(props[inc()]),
|
||||||
SizeY: dh.StringToInt(props[inc()]),
|
SizeY: d2common.StringToInt(props[inc()]),
|
||||||
AutoMap: dh.StringToUint8(props[inc()]) == 1,
|
AutoMap: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
Scan: dh.StringToUint8(props[inc()]) == 1,
|
Scan: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
Pops: dh.StringToInt(props[inc()]),
|
Pops: d2common.StringToInt(props[inc()]),
|
||||||
PopPad: dh.StringToInt(props[inc()]),
|
PopPad: d2common.StringToInt(props[inc()]),
|
||||||
FileCount: dh.StringToInt(props[inc()]),
|
FileCount: d2common.StringToInt(props[inc()]),
|
||||||
Files: [6]string{
|
Files: [6]string{
|
||||||
props[inc()],
|
props[inc()],
|
||||||
props[inc()],
|
props[inc()],
|
||||||
|
@ -62,9 +62,9 @@ func createLevelPresetRecord(props []string) LevelPresetRecord {
|
||||||
props[inc()],
|
props[inc()],
|
||||||
props[inc()],
|
props[inc()],
|
||||||
},
|
},
|
||||||
Dt1Mask: dh.StringToUint(props[inc()]),
|
Dt1Mask: d2common.StringToUint(props[inc()]),
|
||||||
Beta: dh.StringToUint8(props[inc()]) == 1,
|
Beta: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
Expansion: dh.StringToUint8(props[inc()]) == 1,
|
Expansion: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ func LoadLevelSubstitutions(file []byte) {
|
||||||
numRecords := len(dict.Data)
|
numRecords := len(dict.Data)
|
||||||
LevelSubstitutions = make(map[int]*LevelSubstitutionRecord, numRecords)
|
LevelSubstitutions = make(map[int]*LevelSubstitutionRecord, numRecords)
|
||||||
|
|
||||||
for idx, _ := range dict.Data {
|
for idx := range dict.Data {
|
||||||
|
|
||||||
record := &LevelSubstitutionRecord{
|
record := &LevelSubstitutionRecord{
|
||||||
Name: dict.GetString("Name", idx),
|
Name: dict.GetString("Name", idx),
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
dh "github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
||||||
)
|
)
|
||||||
|
|
||||||
type LevelTypeRecord struct {
|
type LevelTypeRecord struct {
|
||||||
|
@ -36,7 +36,7 @@ func LoadLevelTypes(file []byte) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
LevelTypes[j].Name = parts[inc()]
|
LevelTypes[j].Name = parts[inc()]
|
||||||
LevelTypes[j].Id = dh.StringToInt(parts[inc()])
|
LevelTypes[j].Id = d2common.StringToInt(parts[inc()])
|
||||||
for fileIdx := range LevelTypes[i].Files {
|
for fileIdx := range LevelTypes[i].Files {
|
||||||
LevelTypes[j].Files[fileIdx] = parts[inc()]
|
LevelTypes[j].Files[fileIdx] = parts[inc()]
|
||||||
if LevelTypes[j].Files[fileIdx] == "0" {
|
if LevelTypes[j].Files[fileIdx] == "0" {
|
||||||
|
@ -45,7 +45,7 @@ func LoadLevelTypes(file []byte) {
|
||||||
|
|
||||||
}
|
}
|
||||||
LevelTypes[j].Beta = parts[inc()] != "1"
|
LevelTypes[j].Beta = parts[inc()] != "1"
|
||||||
LevelTypes[j].Act = dh.StringToInt(parts[inc()])
|
LevelTypes[j].Act = d2common.StringToInt(parts[inc()])
|
||||||
LevelTypes[j].Expansion = parts[inc()] != "1"
|
LevelTypes[j].Expansion = parts[inc()] != "1"
|
||||||
}
|
}
|
||||||
log.Printf("Loaded %d LevelType records", len(LevelTypes))
|
log.Printf("Loaded %d LevelType records", len(LevelTypes))
|
||||||
|
|
|
@ -382,7 +382,7 @@ func LoadLevelDetails(file []byte) {
|
||||||
numRecords := len(dict.Data)
|
numRecords := len(dict.Data)
|
||||||
LevelDetails = make(map[int]*LevelDetailsRecord, numRecords)
|
LevelDetails = make(map[int]*LevelDetailsRecord, numRecords)
|
||||||
|
|
||||||
for idx, _ := range dict.Data {
|
for idx := range dict.Data {
|
||||||
record := &LevelDetailsRecord{
|
record := &LevelDetailsRecord{
|
||||||
Name: dict.GetString("Name ", idx),
|
Name: dict.GetString("Name ", idx),
|
||||||
Id: dict.GetNumber("Id", idx),
|
Id: dict.GetNumber("Id", idx),
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
dh "github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func MapHeaders(line string) map[string]int {
|
func MapHeaders(line string) map[string]int {
|
||||||
|
@ -18,7 +18,7 @@ func MapHeaders(line string) map[string]int {
|
||||||
func MapLoadInt(r *[]string, mapping *map[string]int, field string) int {
|
func MapLoadInt(r *[]string, mapping *map[string]int, field string) int {
|
||||||
index, ok := (*mapping)[field]
|
index, ok := (*mapping)[field]
|
||||||
if ok {
|
if ok {
|
||||||
return dh.StringToInt(dh.EmptyToZero(dh.AsterToEmpty((*r)[index])))
|
return d2common.StringToInt(d2common.EmptyToZero(d2common.AsterToEmpty((*r)[index])))
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ func MapLoadInt(r *[]string, mapping *map[string]int, field string) int {
|
||||||
func MapLoadString(r *[]string, mapping *map[string]int, field string) string {
|
func MapLoadString(r *[]string, mapping *map[string]int, field string) string {
|
||||||
index, ok := (*mapping)[field]
|
index, ok := (*mapping)[field]
|
||||||
if ok {
|
if ok {
|
||||||
return dh.AsterToEmpty((*r)[index])
|
return d2common.AsterToEmpty((*r)[index])
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ func MapLoadBool(r *[]string, mapping *map[string]int, field string) bool {
|
||||||
func MapLoadUint8(r *[]string, mapping *map[string]int, field string) uint8 {
|
func MapLoadUint8(r *[]string, mapping *map[string]int, field string) uint8 {
|
||||||
index, ok := (*mapping)[field]
|
index, ok := (*mapping)[field]
|
||||||
if ok {
|
if ok {
|
||||||
return dh.StringToUint8(dh.EmptyToZero(dh.AsterToEmpty((*r)[index])))
|
return d2common.StringToUint8(d2common.EmptyToZero(d2common.AsterToEmpty((*r)[index])))
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
||||||
dh "github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type MissileCalcParam struct {
|
type MissileCalcParam struct {
|
||||||
|
@ -197,16 +196,16 @@ func createMissileRecord(line string) MissileRecord {
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
// note: in this file, empties are equivalent to zero, so all numerical conversions should
|
// note: in this file, empties are equivalent to zero, so all numerical conversions should
|
||||||
// be wrapped in an dh.EmptyToZero transform
|
// be wrapped in an d2common.EmptyToZero transform
|
||||||
result := MissileRecord{
|
result := MissileRecord{
|
||||||
Name: r[inc()],
|
Name: r[inc()],
|
||||||
Id: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
Id: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
|
|
||||||
ClientMovementFunc: dh.StringToInt(dh.EmptyToZero(dh.AsterToEmpty(r[inc()]))),
|
ClientMovementFunc: d2common.StringToInt(d2common.EmptyToZero(d2common.AsterToEmpty(r[inc()]))),
|
||||||
ClientCollisionFunc: dh.StringToInt(dh.EmptyToZero(dh.AsterToEmpty(r[inc()]))),
|
ClientCollisionFunc: d2common.StringToInt(d2common.EmptyToZero(d2common.AsterToEmpty(r[inc()]))),
|
||||||
ServerMovementFunc: dh.StringToInt(dh.EmptyToZero(dh.AsterToEmpty(r[inc()]))),
|
ServerMovementFunc: d2common.StringToInt(d2common.EmptyToZero(d2common.AsterToEmpty(r[inc()]))),
|
||||||
ServerCollisionFunc: dh.StringToInt(dh.EmptyToZero(dh.AsterToEmpty(r[inc()]))),
|
ServerCollisionFunc: d2common.StringToInt(d2common.EmptyToZero(d2common.AsterToEmpty(r[inc()]))),
|
||||||
ServerDamageFunc: dh.StringToInt(dh.EmptyToZero(dh.AsterToEmpty(r[inc()]))),
|
ServerDamageFunc: d2common.StringToInt(d2common.EmptyToZero(d2common.AsterToEmpty(r[inc()]))),
|
||||||
|
|
||||||
ServerMovementCalc: loadMissileCalc(&r, inc, 5),
|
ServerMovementCalc: loadMissileCalc(&r, inc, 5),
|
||||||
ClientMovementCalc: loadMissileCalc(&r, inc, 5),
|
ClientMovementCalc: loadMissileCalc(&r, inc, 5),
|
||||||
|
@ -214,12 +213,12 @@ func createMissileRecord(line string) MissileRecord {
|
||||||
ClientCollisionCalc: loadMissileCalc(&r, inc, 3),
|
ClientCollisionCalc: loadMissileCalc(&r, inc, 3),
|
||||||
ServerDamageCalc: loadMissileCalc(&r, inc, 2),
|
ServerDamageCalc: loadMissileCalc(&r, inc, 2),
|
||||||
|
|
||||||
Velocity: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
Velocity: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
MaxVelocity: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
MaxVelocity: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
LevelVelocityBonus: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
LevelVelocityBonus: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
Accel: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
Accel: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
Range: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
Range: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
LevelRangeBonus: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
LevelRangeBonus: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
|
|
||||||
Light: loadMissileLight(&r, inc),
|
Light: loadMissileLight(&r, inc),
|
||||||
|
|
||||||
|
@ -227,54 +226,54 @@ func createMissileRecord(line string) MissileRecord {
|
||||||
|
|
||||||
Collision: loadMissileCollision(&r, inc),
|
Collision: loadMissileCollision(&r, inc),
|
||||||
|
|
||||||
XOffset: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
XOffset: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
YOffset: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
YOffset: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
ZOffset: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
ZOffset: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
Size: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
Size: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
|
|
||||||
DestroyedByTP: dh.StringToInt(dh.EmptyToZero(r[inc()])) == 1,
|
DestroyedByTP: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
||||||
DestroyedByTPFrame: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
DestroyedByTPFrame: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
CanDestroy: dh.StringToInt(dh.EmptyToZero(r[inc()])) == 1,
|
CanDestroy: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
||||||
|
|
||||||
UseAttackRating: dh.StringToInt(dh.EmptyToZero(r[inc()])) == 1,
|
UseAttackRating: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
||||||
AlwaysExplode: dh.StringToInt(dh.EmptyToZero(r[inc()])) == 1,
|
AlwaysExplode: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
||||||
|
|
||||||
ClientExplosion: dh.StringToInt(dh.EmptyToZero(r[inc()])) == 1,
|
ClientExplosion: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
||||||
TownSafe: dh.StringToInt(dh.EmptyToZero(r[inc()])) == 1,
|
TownSafe: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
||||||
IgnoreBossModifiers: dh.StringToInt(dh.EmptyToZero(r[inc()])) == 1,
|
IgnoreBossModifiers: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
||||||
IgnoreMultishot: dh.StringToInt(dh.EmptyToZero(r[inc()])) == 1,
|
IgnoreMultishot: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
||||||
HolyFilterType: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
HolyFilterType: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
CanBeSlowed: dh.StringToInt(dh.EmptyToZero(r[inc()])) == 1,
|
CanBeSlowed: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
||||||
TriggersHitEvents: dh.StringToInt(dh.EmptyToZero(r[inc()])) == 1,
|
TriggersHitEvents: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
||||||
TriggersGetHit: dh.StringToInt(dh.EmptyToZero(r[inc()])) == 1,
|
TriggersGetHit: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
||||||
SoftHit: dh.StringToInt(dh.EmptyToZero(r[inc()])) == 1,
|
SoftHit: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
||||||
KnockbackPercent: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
KnockbackPercent: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
|
|
||||||
TransparencyMode: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
TransparencyMode: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
|
|
||||||
UseQuantity: dh.StringToInt(dh.EmptyToZero(r[inc()])) == 1,
|
UseQuantity: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
||||||
AffectedByPierce: dh.StringToInt(dh.EmptyToZero(r[inc()])) == 1,
|
AffectedByPierce: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
||||||
SpecialSetup: dh.StringToInt(dh.EmptyToZero(r[inc()])) == 1,
|
SpecialSetup: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
||||||
|
|
||||||
MissileSkill: dh.StringToInt(dh.EmptyToZero(r[inc()])) == 1,
|
MissileSkill: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
||||||
SkillName: r[inc()],
|
SkillName: r[inc()],
|
||||||
|
|
||||||
ResultFlags: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
ResultFlags: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
HitFlags: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
HitFlags: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
|
|
||||||
HitShift: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
HitShift: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
ApplyMastery: dh.StringToInt(dh.EmptyToZero(r[inc()])) == 1,
|
ApplyMastery: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
||||||
SourceDamage: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
SourceDamage: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
HalfDamageForTwoHander: dh.StringToInt(dh.EmptyToZero(r[inc()])) == 1,
|
HalfDamageForTwoHander: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
||||||
SourceMissDamage: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
SourceMissDamage: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
|
|
||||||
Damage: loadMissileDamage(&r, inc),
|
Damage: loadMissileDamage(&r, inc),
|
||||||
ElementalDamage: loadMissileElementalDamage(&r, inc),
|
ElementalDamage: loadMissileElementalDamage(&r, inc),
|
||||||
|
|
||||||
HitClass: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
HitClass: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
NumDirections: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
NumDirections: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
LocalBlood: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
LocalBlood: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
DamageReductionRate: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
DamageReductionRate: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
|
|
||||||
TravelSound: r[inc()],
|
TravelSound: r[inc()],
|
||||||
HitSound: r[inc()],
|
HitSound: r[inc()],
|
||||||
|
@ -307,7 +306,7 @@ func LoadMissiles(file []byte) {
|
||||||
|
|
||||||
func loadMissileCalcParam(r *[]string, inc func() int) MissileCalcParam {
|
func loadMissileCalcParam(r *[]string, inc func() int) MissileCalcParam {
|
||||||
result := MissileCalcParam{
|
result := MissileCalcParam{
|
||||||
Param: dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
Param: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
Desc: (*r)[inc()],
|
Desc: (*r)[inc()],
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
@ -327,64 +326,64 @@ func loadMissileCalc(r *[]string, inc func() int, params int) MissileCalc {
|
||||||
|
|
||||||
func loadMissileLight(r *[]string, inc func() int) MissileLight {
|
func loadMissileLight(r *[]string, inc func() int) MissileLight {
|
||||||
result := MissileLight{
|
result := MissileLight{
|
||||||
Diameter: dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
Diameter: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
Flicker: dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
Flicker: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
Red: dh.StringToUint8(dh.EmptyToZero((*r)[inc()])),
|
Red: d2common.StringToUint8(d2common.EmptyToZero((*r)[inc()])),
|
||||||
Green: dh.StringToUint8(dh.EmptyToZero((*r)[inc()])),
|
Green: d2common.StringToUint8(d2common.EmptyToZero((*r)[inc()])),
|
||||||
Blue: dh.StringToUint8(dh.EmptyToZero((*r)[inc()])),
|
Blue: d2common.StringToUint8(d2common.EmptyToZero((*r)[inc()])),
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadMissileAnimation(r *[]string, inc func() int) MissileAnimation {
|
func loadMissileAnimation(r *[]string, inc func() int) MissileAnimation {
|
||||||
result := MissileAnimation{
|
result := MissileAnimation{
|
||||||
StepsBeforeVisible: dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
StepsBeforeVisible: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
StepsBeforeActive: dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
StepsBeforeActive: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
LoopAnimation: dh.StringToInt(dh.EmptyToZero((*r)[inc()])) == 1,
|
LoopAnimation: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])) == 1,
|
||||||
CelFileName: (*r)[inc()],
|
CelFileName: (*r)[inc()],
|
||||||
AnimationRate: dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
AnimationRate: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
AnimationLength: dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
AnimationLength: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
AnimationSpeed: dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
AnimationSpeed: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
StartingFrame: dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
StartingFrame: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
HasSubLoop: dh.StringToInt(dh.EmptyToZero((*r)[inc()])) == 1,
|
HasSubLoop: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])) == 1,
|
||||||
SubStartingFrame: dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
SubStartingFrame: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
SubEndingFrame: dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
SubEndingFrame: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadMissileCollision(r *[]string, inc func() int) MissileCollision {
|
func loadMissileCollision(r *[]string, inc func() int) MissileCollision {
|
||||||
result := MissileCollision{
|
result := MissileCollision{
|
||||||
CollisionType: dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
CollisionType: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
DestroyedUponCollision: dh.StringToInt(dh.EmptyToZero((*r)[inc()])) == 1,
|
DestroyedUponCollision: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])) == 1,
|
||||||
FriendlyFire: dh.StringToInt(dh.EmptyToZero((*r)[inc()])) == 1,
|
FriendlyFire: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])) == 1,
|
||||||
LastCollide: dh.StringToInt(dh.EmptyToZero((*r)[inc()])) == 1,
|
LastCollide: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])) == 1,
|
||||||
Collision: dh.StringToInt(dh.EmptyToZero((*r)[inc()])) == 1,
|
Collision: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])) == 1,
|
||||||
ClientCollision: dh.StringToInt(dh.EmptyToZero((*r)[inc()])) == 1,
|
ClientCollision: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])) == 1,
|
||||||
ClientSend: dh.StringToInt(dh.EmptyToZero((*r)[inc()])) == 1,
|
ClientSend: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])) == 1,
|
||||||
UseCollisionTimer: dh.StringToInt(dh.EmptyToZero((*r)[inc()])) == 1,
|
UseCollisionTimer: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])) == 1,
|
||||||
TimerFrames: dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
TimerFrames: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadMissileDamage(r *[]string, inc func() int) MissileDamage {
|
func loadMissileDamage(r *[]string, inc func() int) MissileDamage {
|
||||||
result := MissileDamage{
|
result := MissileDamage{
|
||||||
MinDamage: dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
MinDamage: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
MinLevelDamage: [5]int{
|
MinLevelDamage: [5]int{
|
||||||
dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
},
|
},
|
||||||
MaxDamage: dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
MaxDamage: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
MaxLevelDamage: [5]int{
|
MaxLevelDamage: [5]int{
|
||||||
dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
},
|
},
|
||||||
DamageSynergyPerCalc: d2common.CalcString((*r)[inc()]),
|
DamageSynergyPerCalc: d2common.CalcString((*r)[inc()]),
|
||||||
}
|
}
|
||||||
|
@ -395,11 +394,11 @@ func loadMissileElementalDamage(r *[]string, inc func() int) MissileElementalDam
|
||||||
result := MissileElementalDamage{
|
result := MissileElementalDamage{
|
||||||
ElementType: (*r)[inc()],
|
ElementType: (*r)[inc()],
|
||||||
Damage: loadMissileDamage(r, inc),
|
Damage: loadMissileDamage(r, inc),
|
||||||
Duration: dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
Duration: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
LevelDuration: [3]int{
|
LevelDuration: [3]int{
|
||||||
dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package d2datadict
|
package d2datadict
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
||||||
)
|
)
|
||||||
|
|
||||||
// https://d2mods.info/forum/kb/viewarticle?a=360
|
// https://d2mods.info/forum/kb/viewarticle?a=360
|
||||||
|
@ -796,7 +797,7 @@ func LoadMonStats(file []byte) {
|
||||||
dict := d2common.LoadDataDictionary(string(file))
|
dict := d2common.LoadDataDictionary(string(file))
|
||||||
numRecords := len(dict.Data)
|
numRecords := len(dict.Data)
|
||||||
MonStats = make(map[string]*MonStatsRecord, numRecords)
|
MonStats = make(map[string]*MonStatsRecord, numRecords)
|
||||||
for idx, _ := range dict.Data {
|
for idx := range dict.Data {
|
||||||
record := &MonStatsRecord{
|
record := &MonStatsRecord{
|
||||||
Key: dict.GetString("Id", idx),
|
Key: dict.GetString("Id", idx),
|
||||||
Id: dict.GetString("hcIdx", idx),
|
Id: dict.GetString("hcIdx", idx),
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
dh "github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
||||||
)
|
)
|
||||||
|
|
||||||
// An ObjectRecord represents the settings for one type of object from objects.txt
|
// An ObjectRecord represents the settings for one type of object from objects.txt
|
||||||
|
@ -129,206 +129,206 @@ func createObjectRecord(props []string) ObjectRecord {
|
||||||
result := ObjectRecord{
|
result := ObjectRecord{
|
||||||
Name: props[inc()],
|
Name: props[inc()],
|
||||||
Description: props[inc()],
|
Description: props[inc()],
|
||||||
Id: dh.StringToInt(props[inc()]),
|
Id: d2common.StringToInt(props[inc()]),
|
||||||
Token: props[inc()],
|
Token: props[inc()],
|
||||||
|
|
||||||
SpawnMax: dh.StringToInt(props[inc()]),
|
SpawnMax: d2common.StringToInt(props[inc()]),
|
||||||
Selectable: [8]bool{
|
Selectable: [8]bool{
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
},
|
},
|
||||||
TrapProbability: dh.StringToInt(props[inc()]),
|
TrapProbability: d2common.StringToInt(props[inc()]),
|
||||||
|
|
||||||
SizeX: dh.StringToInt(props[inc()]),
|
SizeX: d2common.StringToInt(props[inc()]),
|
||||||
SizeY: dh.StringToInt(props[inc()]),
|
SizeY: d2common.StringToInt(props[inc()]),
|
||||||
|
|
||||||
NTgtFX: dh.StringToInt(props[inc()]),
|
NTgtFX: d2common.StringToInt(props[inc()]),
|
||||||
NTgtFY: dh.StringToInt(props[inc()]),
|
NTgtFY: d2common.StringToInt(props[inc()]),
|
||||||
NTgtBX: dh.StringToInt(props[inc()]),
|
NTgtBX: d2common.StringToInt(props[inc()]),
|
||||||
NTgtBY: dh.StringToInt(props[inc()]),
|
NTgtBY: d2common.StringToInt(props[inc()]),
|
||||||
|
|
||||||
FrameCount: [8]int{
|
FrameCount: [8]int{
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
},
|
},
|
||||||
FrameDelta: [8]int{
|
FrameDelta: [8]int{
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
},
|
},
|
||||||
CycleAnimation: [8]bool{
|
CycleAnimation: [8]bool{
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
},
|
},
|
||||||
LightDiameter: [8]int{
|
LightDiameter: [8]int{
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
},
|
},
|
||||||
BlocksLight: [8]bool{
|
BlocksLight: [8]bool{
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
},
|
},
|
||||||
HasCollision: [8]bool{
|
HasCollision: [8]bool{
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
},
|
},
|
||||||
IsAttackable: dh.StringToUint8(props[inc()]) == 1,
|
IsAttackable: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
StartFrame: [8]int{
|
StartFrame: [8]int{
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
},
|
},
|
||||||
|
|
||||||
EnvEffect: dh.StringToUint8(props[inc()]) == 1,
|
EnvEffect: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
IsDoor: dh.StringToUint8(props[inc()]) == 1,
|
IsDoor: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
BlockVisibility: dh.StringToUint8(props[inc()]) == 1,
|
BlockVisibility: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
Orientation: dh.StringToInt(props[inc()]),
|
Orientation: d2common.StringToInt(props[inc()]),
|
||||||
Trans: dh.StringToInt(props[inc()]),
|
Trans: d2common.StringToInt(props[inc()]),
|
||||||
|
|
||||||
OrderFlag: [8]int{
|
OrderFlag: [8]int{
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
},
|
},
|
||||||
PreOperate: dh.StringToUint8(props[inc()]) == 1,
|
PreOperate: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
HasAnimationMode: [8]bool{
|
HasAnimationMode: [8]bool{
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
},
|
},
|
||||||
|
|
||||||
XOffset: dh.StringToInt(props[inc()]),
|
XOffset: d2common.StringToInt(props[inc()]),
|
||||||
YOffset: dh.StringToInt(props[inc()]),
|
YOffset: d2common.StringToInt(props[inc()]),
|
||||||
Draw: dh.StringToUint8(props[inc()]) == 1,
|
Draw: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
|
|
||||||
LightRed: dh.StringToUint8(props[inc()]),
|
LightRed: d2common.StringToUint8(props[inc()]),
|
||||||
LightGreen: dh.StringToUint8(props[inc()]),
|
LightGreen: d2common.StringToUint8(props[inc()]),
|
||||||
LightBlue: dh.StringToUint8(props[inc()]),
|
LightBlue: d2common.StringToUint8(props[inc()]),
|
||||||
|
|
||||||
SelHD: dh.StringToUint8(props[inc()]) == 1,
|
SelHD: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
SelTR: dh.StringToUint8(props[inc()]) == 1,
|
SelTR: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
SelLG: dh.StringToUint8(props[inc()]) == 1,
|
SelLG: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
SelRA: dh.StringToUint8(props[inc()]) == 1,
|
SelRA: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
SelLA: dh.StringToUint8(props[inc()]) == 1,
|
SelLA: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
SelRH: dh.StringToUint8(props[inc()]) == 1,
|
SelRH: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
SelLH: dh.StringToUint8(props[inc()]) == 1,
|
SelLH: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
SelSH: dh.StringToUint8(props[inc()]) == 1,
|
SelSH: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
SelS: [8]bool{
|
SelS: [8]bool{
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
dh.StringToUint8(props[inc()]) == 1,
|
d2common.StringToUint8(props[inc()]) == 1,
|
||||||
},
|
},
|
||||||
|
|
||||||
TotalPieces: dh.StringToInt(props[inc()]),
|
TotalPieces: d2common.StringToInt(props[inc()]),
|
||||||
SubClass: dh.StringToInt(props[inc()]),
|
SubClass: d2common.StringToInt(props[inc()]),
|
||||||
|
|
||||||
XSpace: dh.StringToInt(props[inc()]),
|
XSpace: d2common.StringToInt(props[inc()]),
|
||||||
YSpace: dh.StringToInt(props[inc()]),
|
YSpace: d2common.StringToInt(props[inc()]),
|
||||||
|
|
||||||
NameOffset: dh.StringToInt(props[inc()]),
|
NameOffset: d2common.StringToInt(props[inc()]),
|
||||||
|
|
||||||
MonsterOk: dh.StringToUint8(props[inc()]) == 1,
|
MonsterOk: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
OperateRange: dh.StringToInt(props[inc()]),
|
OperateRange: d2common.StringToInt(props[inc()]),
|
||||||
ShrineFunction: dh.StringToInt(props[inc()]),
|
ShrineFunction: d2common.StringToInt(props[inc()]),
|
||||||
Restore: dh.StringToUint8(props[inc()]) == 1,
|
Restore: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
|
|
||||||
Parm: [8]int{
|
Parm: [8]int{
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
dh.StringToInt(props[inc()]),
|
d2common.StringToInt(props[inc()]),
|
||||||
},
|
},
|
||||||
Act: dh.StringToInt(props[inc()]),
|
Act: d2common.StringToInt(props[inc()]),
|
||||||
Lockable: dh.StringToUint8(props[inc()]) == 1,
|
Lockable: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
Gore: dh.StringToUint8(props[inc()]) == 1,
|
Gore: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
Sync: dh.StringToUint8(props[inc()]) == 1,
|
Sync: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
Flicker: dh.StringToUint8(props[inc()]) == 1,
|
Flicker: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
Damage: dh.StringToInt(props[inc()]),
|
Damage: d2common.StringToInt(props[inc()]),
|
||||||
Beta: dh.StringToUint8(props[inc()]) == 1,
|
Beta: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
Overlay: dh.StringToUint8(props[inc()]) == 1,
|
Overlay: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
CollisionSubst: dh.StringToUint8(props[inc()]) == 1,
|
CollisionSubst: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
|
|
||||||
Left: dh.StringToInt(props[inc()]),
|
Left: d2common.StringToInt(props[inc()]),
|
||||||
Top: dh.StringToInt(props[inc()]),
|
Top: d2common.StringToInt(props[inc()]),
|
||||||
Width: dh.StringToInt(props[inc()]),
|
Width: d2common.StringToInt(props[inc()]),
|
||||||
Height: dh.StringToInt(props[inc()]),
|
Height: d2common.StringToInt(props[inc()]),
|
||||||
|
|
||||||
OperateFn: dh.StringToInt(props[inc()]),
|
OperateFn: d2common.StringToInt(props[inc()]),
|
||||||
PopulateFn: dh.StringToInt(props[inc()]),
|
PopulateFn: d2common.StringToInt(props[inc()]),
|
||||||
InitFn: dh.StringToInt(props[inc()]),
|
InitFn: d2common.StringToInt(props[inc()]),
|
||||||
ClientFn: dh.StringToInt(props[inc()]),
|
ClientFn: d2common.StringToInt(props[inc()]),
|
||||||
|
|
||||||
RestoreVirgins: dh.StringToUint8(props[inc()]) == 1,
|
RestoreVirgins: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
BlockMissile: dh.StringToUint8(props[inc()]) == 1,
|
BlockMissile: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
DrawUnder: dh.StringToUint8(props[inc()]) == 1,
|
DrawUnder: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
OpenWarp: dh.StringToUint8(props[inc()]) == 1,
|
OpenWarp: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
|
|
||||||
AutoMap: dh.StringToInt(props[inc()]),
|
AutoMap: d2common.StringToInt(props[inc()]),
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
dh "github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SoundEntry represents a sound entry
|
// SoundEntry represents a sound entry
|
||||||
|
@ -46,30 +46,30 @@ func createSoundEntry(soundLine string) SoundEntry {
|
||||||
}
|
}
|
||||||
result := SoundEntry{
|
result := SoundEntry{
|
||||||
Handle: props[inc()],
|
Handle: props[inc()],
|
||||||
Index: dh.StringToInt(props[inc()]),
|
Index: d2common.StringToInt(props[inc()]),
|
||||||
FileName: props[inc()],
|
FileName: props[inc()],
|
||||||
Volume: dh.StringToUint8(props[inc()]),
|
Volume: d2common.StringToUint8(props[inc()]),
|
||||||
GroupSize: dh.StringToUint8(props[inc()]),
|
GroupSize: d2common.StringToUint8(props[inc()]),
|
||||||
Loop: dh.StringToUint8(props[inc()]) == 1,
|
Loop: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
FadeIn: dh.StringToUint8(props[inc()]),
|
FadeIn: d2common.StringToUint8(props[inc()]),
|
||||||
FadeOut: dh.StringToUint8(props[inc()]),
|
FadeOut: d2common.StringToUint8(props[inc()]),
|
||||||
DeferInst: dh.StringToUint8(props[inc()]),
|
DeferInst: d2common.StringToUint8(props[inc()]),
|
||||||
StopInst: dh.StringToUint8(props[inc()]),
|
StopInst: d2common.StringToUint8(props[inc()]),
|
||||||
Duration: dh.StringToUint8(props[inc()]),
|
Duration: d2common.StringToUint8(props[inc()]),
|
||||||
Compound: dh.StringToInt8(props[inc()]),
|
Compound: d2common.StringToInt8(props[inc()]),
|
||||||
Reverb: dh.StringToUint8(props[inc()]) == 1,
|
Reverb: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
Falloff: dh.StringToUint8(props[inc()]),
|
Falloff: d2common.StringToUint8(props[inc()]),
|
||||||
Cache: dh.StringToUint8(props[inc()]),
|
Cache: d2common.StringToUint8(props[inc()]),
|
||||||
AsyncOnly: dh.StringToUint8(props[inc()]) == 1,
|
AsyncOnly: d2common.StringToUint8(props[inc()]) == 1,
|
||||||
Priority: dh.StringToUint8(props[inc()]),
|
Priority: d2common.StringToUint8(props[inc()]),
|
||||||
Stream: dh.StringToUint8(props[inc()]),
|
Stream: d2common.StringToUint8(props[inc()]),
|
||||||
Stereo: dh.StringToUint8(props[inc()]),
|
Stereo: d2common.StringToUint8(props[inc()]),
|
||||||
Tracking: dh.StringToUint8(props[inc()]),
|
Tracking: d2common.StringToUint8(props[inc()]),
|
||||||
Solo: dh.StringToUint8(props[inc()]),
|
Solo: d2common.StringToUint8(props[inc()]),
|
||||||
MusicVol: dh.StringToUint8(props[inc()]),
|
MusicVol: d2common.StringToUint8(props[inc()]),
|
||||||
Block1: dh.StringToInt(props[inc()]),
|
Block1: d2common.StringToInt(props[inc()]),
|
||||||
Block2: dh.StringToInt(props[inc()]),
|
Block2: d2common.StringToInt(props[inc()]),
|
||||||
Block3: dh.StringToInt(props[inc()]),
|
Block3: d2common.StringToInt(props[inc()]),
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
||||||
|
|
||||||
dh "github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type UniqueItemRecord struct {
|
type UniqueItemRecord struct {
|
||||||
|
@ -58,22 +56,22 @@ func createUniqueItemRecord(r []string) UniqueItemRecord {
|
||||||
}
|
}
|
||||||
result := UniqueItemRecord{
|
result := UniqueItemRecord{
|
||||||
Name: r[inc()],
|
Name: r[inc()],
|
||||||
Version: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
Version: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
Enabled: dh.StringToInt(dh.EmptyToZero(r[inc()])) == 1,
|
Enabled: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
||||||
|
|
||||||
Ladder: dh.StringToInt(dh.EmptyToZero(r[inc()])) == 1,
|
Ladder: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
||||||
Rarity: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
Rarity: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
NoLimit: dh.StringToInt(dh.EmptyToZero(r[inc()])) == 1,
|
NoLimit: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
||||||
|
|
||||||
Level: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
Level: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
RequiredLevel: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
RequiredLevel: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
Code: r[inc()],
|
Code: r[inc()],
|
||||||
|
|
||||||
TypeDescription: r[inc()],
|
TypeDescription: r[inc()],
|
||||||
UberDescription: r[inc()],
|
UberDescription: r[inc()],
|
||||||
SingleCopy: dh.StringToInt(dh.EmptyToZero(r[inc()])) == 1,
|
SingleCopy: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
||||||
CostMultiplier: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
CostMultiplier: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
CostAdd: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
CostAdd: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
|
|
||||||
CharacterGfxTransform: r[inc()],
|
CharacterGfxTransform: r[inc()],
|
||||||
InventoryGfxTransform: r[inc()],
|
InventoryGfxTransform: r[inc()],
|
||||||
|
@ -81,7 +79,7 @@ func createUniqueItemRecord(r []string) UniqueItemRecord {
|
||||||
InventoryFile: r[inc()],
|
InventoryFile: r[inc()],
|
||||||
|
|
||||||
DropSound: r[inc()],
|
DropSound: r[inc()],
|
||||||
DropSfxFrame: dh.StringToInt(dh.EmptyToZero(r[inc()])),
|
DropSfxFrame: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
||||||
UseSound: r[inc()],
|
UseSound: r[inc()],
|
||||||
|
|
||||||
Properties: [12]UniqueItemProperty{
|
Properties: [12]UniqueItemProperty{
|
||||||
|
@ -108,8 +106,8 @@ func createUniqueItemProperty(r *[]string, inc func() int) UniqueItemProperty {
|
||||||
result := UniqueItemProperty{
|
result := UniqueItemProperty{
|
||||||
Property: (*r)[inc()],
|
Property: (*r)[inc()],
|
||||||
Parameter: d2common.CalcString((*r)[inc()]),
|
Parameter: d2common.CalcString((*r)[inc()]),
|
||||||
Min: dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
Min: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
Max: dh.StringToInt(dh.EmptyToZero((*r)[inc()])),
|
Max: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ func LoadCOF(fileData []byte) (*COF, error) {
|
||||||
result.Speed = int(streamReader.GetByte())
|
result.Speed = int(streamReader.GetByte())
|
||||||
streamReader.SkipBytes(3)
|
streamReader.SkipBytes(3)
|
||||||
result.CofLayers = make([]CofLayer, result.NumberOfLayers)
|
result.CofLayers = make([]CofLayer, result.NumberOfLayers)
|
||||||
result.CompositeLayers = make(map[d2enum.CompositeType]int, 0)
|
result.CompositeLayers = make(map[d2enum.CompositeType]int)
|
||||||
for i := 0; i < result.NumberOfLayers; i++ {
|
for i := 0; i < result.NumberOfLayers; i++ {
|
||||||
layer := CofLayer{}
|
layer := CofLayer{}
|
||||||
layer.Type = d2enum.CompositeType(streamReader.GetByte())
|
layer.Type = d2enum.CompositeType(streamReader.GetByte())
|
||||||
|
|
|
@ -25,7 +25,7 @@ func LoadDT1(fileData []byte) (*DT1, error) {
|
||||||
ver1 := br.GetInt32()
|
ver1 := br.GetInt32()
|
||||||
ver2 := br.GetInt32()
|
ver2 := br.GetInt32()
|
||||||
if ver1 != 7 || ver2 != 6 {
|
if ver1 != 7 || ver2 != 6 {
|
||||||
return nil, fmt.Errorf("Expected to have a version of 7.6, but got %d.%d instead", ver1, ver2)
|
return nil, fmt.Errorf("expected to have a version of 7.6, but got %d.%d instead", ver1, ver2)
|
||||||
}
|
}
|
||||||
br.SkipBytes(260)
|
br.SkipBytes(260)
|
||||||
numberOfTiles := br.GetInt32()
|
numberOfTiles := br.GetInt32()
|
||||||
|
|
|
@ -78,12 +78,10 @@ func getLocalConfigPath() string {
|
||||||
|
|
||||||
func load(configPath string) error {
|
func load(configPath string) error {
|
||||||
configFile, err := os.Open(configPath)
|
configFile, err := os.Open(configPath)
|
||||||
defer configFile.Close()
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer configFile.Close()
|
||||||
data, err := ioutil.ReadAll(configFile)
|
data, err := ioutil.ReadAll(configFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -103,10 +101,10 @@ func save(configPath string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
configFile, err := os.Create(configPath)
|
configFile, err := os.Create(configPath)
|
||||||
defer configFile.Close()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer configFile.Close()
|
||||||
|
|
||||||
data, err := json.MarshalIndent(singleton, "", " ")
|
data, err := json.MarshalIndent(singleton, "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -87,7 +87,6 @@ func createButton(text string, buttonStyle ButtonStyle) (*Button, error) {
|
||||||
case buttonStatePressed, buttonStatePressedToggled:
|
case buttonStatePressed, buttonStatePressedToggled:
|
||||||
textOffsetX = -2
|
textOffsetX = -2
|
||||||
textOffsetY = 2
|
textOffsetY = 2
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
|
||||||
surface.PushTranslation(textX+textOffsetX, textY+textOffsetY)
|
surface.PushTranslation(textX+textOffsetX, textY+textOffsetY)
|
||||||
|
|
|
@ -205,15 +205,12 @@ func (l *Layout) getContentSize() (int, int) {
|
||||||
case PositionTypeVertical:
|
case PositionTypeVertical:
|
||||||
width = d2common.MaxInt(width, w)
|
width = d2common.MaxInt(width, w)
|
||||||
height += h
|
height += h
|
||||||
break
|
|
||||||
case PositionTypeHorizontal:
|
case PositionTypeHorizontal:
|
||||||
width += w
|
width += w
|
||||||
height = d2common.MaxInt(height, h)
|
height = d2common.MaxInt(height, h)
|
||||||
break
|
|
||||||
case PositionTypeAbsolute:
|
case PositionTypeAbsolute:
|
||||||
width = d2common.MaxInt(width, x+w)
|
width = d2common.MaxInt(width, x+w)
|
||||||
height = d2common.MaxInt(height, y+h)
|
height = d2common.MaxInt(height, y+h)
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,10 +301,8 @@ func (l *Layout) adjustEntryPlacement() {
|
||||||
switch l.positionType {
|
switch l.positionType {
|
||||||
case PositionTypeVertical:
|
case PositionTypeVertical:
|
||||||
expanderHeight = (height - contentHeight) / expanderCount
|
expanderHeight = (height - contentHeight) / expanderCount
|
||||||
break
|
|
||||||
case PositionTypeHorizontal:
|
case PositionTypeHorizontal:
|
||||||
expanderWidth = (width - contentWidth) / expanderCount
|
expanderWidth = (width - contentWidth) / expanderCount
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
|
||||||
expanderWidth = d2common.MaxInt(0, expanderWidth)
|
expanderWidth = d2common.MaxInt(0, expanderWidth)
|
||||||
|
@ -333,33 +328,24 @@ func (l *Layout) adjustEntryPlacement() {
|
||||||
switch l.horizontalAlign {
|
switch l.horizontalAlign {
|
||||||
case HorizontalAlignLeft:
|
case HorizontalAlignLeft:
|
||||||
entry.x = 0
|
entry.x = 0
|
||||||
break
|
|
||||||
case HorizontalAlignCenter:
|
case HorizontalAlignCenter:
|
||||||
entry.x = width/2 - entry.width/2
|
entry.x = width/2 - entry.width/2
|
||||||
break
|
|
||||||
case HorizontalAlignRight:
|
case HorizontalAlignRight:
|
||||||
entry.x = width - entry.width
|
entry.x = width - entry.width
|
||||||
break
|
|
||||||
}
|
}
|
||||||
break
|
|
||||||
case PositionTypeHorizontal:
|
case PositionTypeHorizontal:
|
||||||
entry.x = offsetX
|
entry.x = offsetX
|
||||||
offsetX += entry.width
|
offsetX += entry.width
|
||||||
switch l.verticalAlign {
|
switch l.verticalAlign {
|
||||||
case VerticalAlignTop:
|
case VerticalAlignTop:
|
||||||
entry.y = 0
|
entry.y = 0
|
||||||
break
|
|
||||||
case VerticalAlignMiddle:
|
case VerticalAlignMiddle:
|
||||||
entry.y = height/2 - entry.height/2
|
entry.y = height/2 - entry.height/2
|
||||||
break
|
|
||||||
case VerticalAlignBottom:
|
case VerticalAlignBottom:
|
||||||
entry.y = height - entry.height
|
entry.y = height - entry.height
|
||||||
break
|
|
||||||
}
|
}
|
||||||
break
|
|
||||||
case PositionTypeAbsolute:
|
case PositionTypeAbsolute:
|
||||||
entry.x, entry.y = entry.widget.getPosition()
|
entry.x, entry.y = entry.widget.getPosition()
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -330,22 +330,17 @@ func loadPaletteForAct(levelType d2enum.RegionIdType) (*d2dat.DATPalette, error)
|
||||||
d2enum.RegionAct1Monestary, d2enum.RegionAct1Courtyard, d2enum.RegionAct1Barracks,
|
d2enum.RegionAct1Monestary, d2enum.RegionAct1Courtyard, d2enum.RegionAct1Barracks,
|
||||||
d2enum.RegionAct1Jail, d2enum.RegionAct1Cathedral, d2enum.RegionAct1Catacombs, d2enum.RegionAct1Tristram:
|
d2enum.RegionAct1Jail, d2enum.RegionAct1Cathedral, d2enum.RegionAct1Catacombs, d2enum.RegionAct1Tristram:
|
||||||
palettePath = d2resource.PaletteAct1
|
palettePath = d2resource.PaletteAct1
|
||||||
break
|
|
||||||
case d2enum.RegionAct2Town, d2enum.RegionAct2Sewer, d2enum.RegionAct2Harem, d2enum.RegionAct2Basement,
|
case d2enum.RegionAct2Town, d2enum.RegionAct2Sewer, d2enum.RegionAct2Harem, d2enum.RegionAct2Basement,
|
||||||
d2enum.RegionAct2Desert, d2enum.RegionAct2Tomb, d2enum.RegionAct2Lair, d2enum.RegionAct2Arcane:
|
d2enum.RegionAct2Desert, d2enum.RegionAct2Tomb, d2enum.RegionAct2Lair, d2enum.RegionAct2Arcane:
|
||||||
palettePath = d2resource.PaletteAct2
|
palettePath = d2resource.PaletteAct2
|
||||||
break
|
|
||||||
case d2enum.RegionAct3Town, d2enum.RegionAct3Jungle, d2enum.RegionAct3Kurast, d2enum.RegionAct3Spider,
|
case d2enum.RegionAct3Town, d2enum.RegionAct3Jungle, d2enum.RegionAct3Kurast, d2enum.RegionAct3Spider,
|
||||||
d2enum.RegionAct3Dungeon, d2enum.RegionAct3Sewer:
|
d2enum.RegionAct3Dungeon, d2enum.RegionAct3Sewer:
|
||||||
palettePath = d2resource.PaletteAct3
|
palettePath = d2resource.PaletteAct3
|
||||||
break
|
|
||||||
case d2enum.RegionAct4Town, d2enum.RegionAct4Mesa, d2enum.RegionAct4Lava, d2enum.RegionAct5Lava:
|
case d2enum.RegionAct4Town, d2enum.RegionAct4Mesa, d2enum.RegionAct4Lava, d2enum.RegionAct5Lava:
|
||||||
palettePath = d2resource.PaletteAct4
|
palettePath = d2resource.PaletteAct4
|
||||||
break
|
|
||||||
case d2enum.RegonAct5Town, d2enum.RegionAct5Siege, d2enum.RegionAct5Barricade, d2enum.RegionAct5Temple,
|
case d2enum.RegonAct5Town, d2enum.RegionAct5Siege, d2enum.RegionAct5Barricade, d2enum.RegionAct5Temple,
|
||||||
d2enum.RegionAct5IceCaves, d2enum.RegionAct5Baal:
|
d2enum.RegionAct5IceCaves, d2enum.RegionAct5Baal:
|
||||||
palettePath = d2resource.PaletteAct5
|
palettePath = d2resource.PaletteAct5
|
||||||
break
|
|
||||||
default:
|
default:
|
||||||
return nil, errors.New("failed to find palette for region")
|
return nil, errors.New("failed to find palette for region")
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,9 @@ func CreateRenderer() (*Renderer, error) {
|
||||||
|
|
||||||
config := d2config.Get()
|
config := d2config.Get()
|
||||||
|
|
||||||
ebiten.SetCursorVisible(false)
|
ebiten.SetCursorMode(ebiten.CursorModeHidden)
|
||||||
ebiten.SetFullscreen(config.FullScreen)
|
ebiten.SetFullscreen(config.FullScreen)
|
||||||
ebiten.SetRunnableInBackground(config.RunInBackground)
|
ebiten.SetRunnableOnUnfocused(config.RunInBackground)
|
||||||
ebiten.SetVsyncEnabled(config.VsyncEnabled)
|
ebiten.SetVsyncEnabled(config.VsyncEnabled)
|
||||||
ebiten.SetMaxTPS(config.TicksPerSecond)
|
ebiten.SetMaxTPS(config.TicksPerSecond)
|
||||||
|
|
||||||
|
|
|
@ -429,7 +429,6 @@ func (t *terminal) bindAction(name, description string, action interface{}) erro
|
||||||
case reflect.Uint:
|
case reflect.Uint:
|
||||||
case reflect.Float64:
|
case reflect.Float64:
|
||||||
case reflect.Bool:
|
case reflect.Bool:
|
||||||
break
|
|
||||||
default:
|
default:
|
||||||
return errors.New("action has unsupported arguments")
|
return errors.New("action has unsupported arguments")
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ import (
|
||||||
"github.com/hajimehoshi/ebiten"
|
"github.com/hajimehoshi/ebiten"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
||||||
dh "github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2resource"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2resource"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset"
|
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset"
|
||||||
|
@ -68,17 +67,17 @@ func (v *CharacterSelect) OnLoad() error {
|
||||||
v.background, _ = d2ui.LoadSprite(animation)
|
v.background, _ = d2ui.LoadSprite(animation)
|
||||||
v.background.SetPosition(0, 0)
|
v.background.SetPosition(0, 0)
|
||||||
|
|
||||||
v.newCharButton = d2ui.CreateButton(d2ui.ButtonTypeTall, d2common.CombineStrings(dh.SplitIntoLinesWithMaxWidth("CREATE NEW CHARACTER", 15)))
|
v.newCharButton = d2ui.CreateButton(d2ui.ButtonTypeTall, d2common.CombineStrings(d2common.SplitIntoLinesWithMaxWidth("CREATE NEW CHARACTER", 15)))
|
||||||
v.newCharButton.SetPosition(33, 468)
|
v.newCharButton.SetPosition(33, 468)
|
||||||
v.newCharButton.OnActivated(func() { v.onNewCharButtonClicked() })
|
v.newCharButton.OnActivated(func() { v.onNewCharButtonClicked() })
|
||||||
d2ui.AddWidget(&v.newCharButton)
|
d2ui.AddWidget(&v.newCharButton)
|
||||||
|
|
||||||
v.convertCharButton = d2ui.CreateButton(d2ui.ButtonTypeTall, d2common.CombineStrings(dh.SplitIntoLinesWithMaxWidth("CONVERT TO EXPANSION", 15)))
|
v.convertCharButton = d2ui.CreateButton(d2ui.ButtonTypeTall, d2common.CombineStrings(d2common.SplitIntoLinesWithMaxWidth("CONVERT TO EXPANSION", 15)))
|
||||||
v.convertCharButton.SetPosition(233, 468)
|
v.convertCharButton.SetPosition(233, 468)
|
||||||
v.convertCharButton.SetEnabled(false)
|
v.convertCharButton.SetEnabled(false)
|
||||||
d2ui.AddWidget(&v.convertCharButton)
|
d2ui.AddWidget(&v.convertCharButton)
|
||||||
|
|
||||||
v.deleteCharButton = d2ui.CreateButton(d2ui.ButtonTypeTall, d2common.CombineStrings(dh.SplitIntoLinesWithMaxWidth("DELETE CHARACTER", 15)))
|
v.deleteCharButton = d2ui.CreateButton(d2ui.ButtonTypeTall, d2common.CombineStrings(d2common.SplitIntoLinesWithMaxWidth("DELETE CHARACTER", 15)))
|
||||||
v.deleteCharButton.OnActivated(func() { v.onDeleteCharButtonClicked() })
|
v.deleteCharButton.OnActivated(func() { v.onDeleteCharButtonClicked() })
|
||||||
v.deleteCharButton.SetPosition(433, 468)
|
v.deleteCharButton.SetPosition(433, 468)
|
||||||
d2ui.AddWidget(&v.deleteCharButton)
|
d2ui.AddWidget(&v.deleteCharButton)
|
||||||
|
@ -110,7 +109,7 @@ func (v *CharacterSelect) OnLoad() error {
|
||||||
v.d2HeroTitle.Alignment = d2ui.LabelAlignCenter
|
v.d2HeroTitle.Alignment = d2ui.LabelAlignCenter
|
||||||
|
|
||||||
v.deleteCharConfirmLabel = d2ui.CreateLabel(d2resource.Font16, d2resource.PaletteUnits)
|
v.deleteCharConfirmLabel = d2ui.CreateLabel(d2resource.Font16, d2resource.PaletteUnits)
|
||||||
lines := dh.SplitIntoLinesWithMaxWidth("Are you sure that you want to delete this character? Take note: this will delete all versions of this Character.", 29)
|
lines := d2common.SplitIntoLinesWithMaxWidth("Are you sure that you want to delete this character? Take note: this will delete all versions of this Character.", 29)
|
||||||
v.deleteCharConfirmLabel.SetText(strings.Join(lines, "\n"))
|
v.deleteCharConfirmLabel.SetText(strings.Join(lines, "\n"))
|
||||||
v.deleteCharConfirmLabel.Alignment = d2ui.LabelAlignCenter
|
v.deleteCharConfirmLabel.Alignment = d2ui.LabelAlignCenter
|
||||||
v.deleteCharConfirmLabel.SetPosition(400, 185)
|
v.deleteCharConfirmLabel.SetPosition(400, 185)
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
dh "github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2resource"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2resource"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset"
|
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset"
|
||||||
|
@ -78,7 +78,7 @@ func (v *Credits) OnLoad() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
creditData, _ := dh.Utf16BytesToString(fileData[2:])
|
creditData, _ := d2common.Utf16BytesToString(fileData[2:])
|
||||||
v.creditsText = strings.Split(creditData, "\r\n")
|
v.creditsText = strings.Split(creditData, "\r\n")
|
||||||
for i := range v.creditsText {
|
for i := range v.creditsText {
|
||||||
v.creditsText[i] = strings.Trim(v.creditsText[i], " ")
|
v.creditsText[i] = strings.Trim(v.creditsText[i], " ")
|
||||||
|
|
|
@ -357,7 +357,6 @@ func (v *MainMenu) Advance(tickTime float64) error {
|
||||||
} else {
|
} else {
|
||||||
v.leftButtonHeld = false
|
v.leftButtonHeld = false
|
||||||
}
|
}
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -10,7 +10,6 @@ import (
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2networking/d2client/d2clientconnectiontype"
|
"github.com/OpenDiablo2/OpenDiablo2/d2networking/d2client/d2clientconnectiontype"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
||||||
dh "github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2resource"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2resource"
|
||||||
|
|
||||||
|
@ -619,7 +618,7 @@ func (v *SelectHeroClass) updateHeroText() {
|
||||||
|
|
||||||
func (v *SelectHeroClass) setDescLabels(descKey string) {
|
func (v *SelectHeroClass) setDescLabels(descKey string) {
|
||||||
heroDesc := d2common.TranslateString(descKey)
|
heroDesc := d2common.TranslateString(descKey)
|
||||||
parts := dh.SplitIntoLinesWithMaxWidth(heroDesc, 37)
|
parts := d2common.SplitIntoLinesWithMaxWidth(heroDesc, 37)
|
||||||
if len(parts) > 1 {
|
if len(parts) > 1 {
|
||||||
v.heroDesc1Label.SetText(parts[0])
|
v.heroDesc1Label.SetText(parts[0])
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -46,7 +46,7 @@ func Create() *RemoteClientConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *RemoteClientConnection) Open(connectionString string, saveFilePath string) error {
|
func (l *RemoteClientConnection) Open(connectionString string, saveFilePath string) error {
|
||||||
if strings.Index(connectionString, ":") == -1 {
|
if !strings.Contains(connectionString, ":") {
|
||||||
connectionString += ":6669"
|
connectionString += ":6669"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ type GameClient struct {
|
||||||
func Create(connectionType d2clientconnectiontype.ClientConnectionType) (*GameClient, error) {
|
func Create(connectionType d2clientconnectiontype.ClientConnectionType) (*GameClient, error) {
|
||||||
result := &GameClient{
|
result := &GameClient{
|
||||||
MapEngine: d2mapengine.CreateMapEngine(), // TODO: Mapgen - Needs levels.txt stuff
|
MapEngine: d2mapengine.CreateMapEngine(), // TODO: Mapgen - Needs levels.txt stuff
|
||||||
Players: make(map[string]*d2mapentity.Player, 0),
|
Players: make(map[string]*d2mapentity.Player),
|
||||||
connectionType: connectionType,
|
connectionType: connectionType,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,20 +71,17 @@ func (g *GameClient) OnPacketReceived(packet d2netpacket.NetPacket) error {
|
||||||
d2mapgen.GenerateAct1Overworld(g.MapEngine)
|
d2mapgen.GenerateAct1Overworld(g.MapEngine)
|
||||||
}
|
}
|
||||||
g.RegenMap = true
|
g.RegenMap = true
|
||||||
break
|
|
||||||
case d2netpackettype.UpdateServerInfo:
|
case d2netpackettype.UpdateServerInfo:
|
||||||
serverInfo := packet.PacketData.(d2netpacket.UpdateServerInfoPacket)
|
serverInfo := packet.PacketData.(d2netpacket.UpdateServerInfoPacket)
|
||||||
g.MapEngine.SetSeed(serverInfo.Seed)
|
g.MapEngine.SetSeed(serverInfo.Seed)
|
||||||
g.PlayerId = serverInfo.PlayerId
|
g.PlayerId = serverInfo.PlayerId
|
||||||
g.Seed = serverInfo.Seed
|
g.Seed = serverInfo.Seed
|
||||||
log.Printf("Player id set to %s", serverInfo.PlayerId)
|
log.Printf("Player id set to %s", serverInfo.PlayerId)
|
||||||
break
|
|
||||||
case d2netpackettype.AddPlayer:
|
case d2netpackettype.AddPlayer:
|
||||||
player := packet.PacketData.(d2netpacket.AddPlayerPacket)
|
player := packet.PacketData.(d2netpacket.AddPlayerPacket)
|
||||||
newPlayer := d2mapentity.CreatePlayer(player.Id, player.Name, player.X, player.Y, 0, player.HeroType, player.Equipment)
|
newPlayer := d2mapentity.CreatePlayer(player.Id, player.Name, player.X, player.Y, 0, player.HeroType, player.Equipment)
|
||||||
g.Players[newPlayer.Id] = newPlayer
|
g.Players[newPlayer.Id] = newPlayer
|
||||||
g.MapEngine.AddEntity(newPlayer)
|
g.MapEngine.AddEntity(newPlayer)
|
||||||
break
|
|
||||||
case d2netpackettype.MovePlayer:
|
case d2netpackettype.MovePlayer:
|
||||||
movePlayer := packet.PacketData.(d2netpacket.MovePlayerPacket)
|
movePlayer := packet.PacketData.(d2netpacket.MovePlayerPacket)
|
||||||
player := g.Players[movePlayer.PlayerId]
|
player := g.Players[movePlayer.PlayerId]
|
||||||
|
@ -104,7 +101,6 @@ func (g *GameClient) OnPacketReceived(packet d2netpacket.NetPacket) error {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
break
|
|
||||||
default:
|
default:
|
||||||
log.Fatalf("Invalid packet type: %d", packet.PacketType)
|
log.Fatalf("Invalid packet type: %d", packet.PacketType)
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,7 +190,6 @@ func OnPacketReceived(client ClientConnection, packet d2netpacket.NetPacket) err
|
||||||
for _, player := range singletonServer.clientConnections {
|
for _, player := range singletonServer.clientConnections {
|
||||||
player.SendPacketToClient(packet)
|
player.SendPacketToClient(packet)
|
||||||
}
|
}
|
||||||
break
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
2
main.go
2
main.go
|
@ -306,11 +306,9 @@ func renderCapture(target d2render.Surface) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("saved frame to %s", singleton.capturePath)
|
log.Printf("saved frame to %s", singleton.capturePath)
|
||||||
break
|
|
||||||
case captureStateGif:
|
case captureStateGif:
|
||||||
screenshot := target.Screenshot()
|
screenshot := target.Screenshot()
|
||||||
singleton.captureFrames = append(singleton.captureFrames, screenshot)
|
singleton.captureFrames = append(singleton.captureFrames, screenshot)
|
||||||
break
|
|
||||||
case captureStateNone:
|
case captureStateNone:
|
||||||
if len(singleton.captureFrames) > 0 {
|
if len(singleton.captureFrames) > 0 {
|
||||||
defer cleanupCapture()
|
defer cleanupCapture()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user