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