Merge branch 'master' into hotfix

This commit is contained in:
gucio321 2021-03-03 20:17:34 +01:00 committed by GitHub
commit 5d78275bbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 81 additions and 8 deletions

View File

@ -5,7 +5,7 @@ version: 2
jobs:
build:
docker:
- image: circleci/golang:1.15.6
- image: circleci/golang:1.16
working_directory: /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}}
steps:
- checkout

View File

@ -5,7 +5,7 @@
# License: GNU GPLv3
version="0.0.8"
go_version="1.13.4"
go_version="1.16"
echo "OpenDiablo 2 Build Script $version"
#=================================================

View File

@ -13,11 +13,21 @@ func (r *AnimationDataRecord) FramesPerDirection() int {
return int(r.framesPerDirection)
}
// SetFramesPerDirection sets frames per direction value
func (r *AnimationDataRecord) SetFramesPerDirection(fpd uint32) {
r.framesPerDirection = fpd
}
// Speed returns animation's speed
func (r *AnimationDataRecord) Speed() int {
return int(r.speed)
}
// SetSpeed sets record's speed
func (r *AnimationDataRecord) SetSpeed(s uint16) {
r.speed = s
}
// FPS returns the frames per second for this animation record
func (r *AnimationDataRecord) FPS() float64 {
speedf := float64(r.speed)
@ -31,3 +41,23 @@ func (r *AnimationDataRecord) FPS() float64 {
func (r *AnimationDataRecord) FrameDurationMS() float64 {
return milliseconds / r.FPS()
}
// Events returns events map
func (r *AnimationDataRecord) Events() map[int]AnimationEvent {
return r.events
}
// Event returns specific event
func (r *AnimationDataRecord) Event(idx int) AnimationEvent {
event, found := r.events[idx]
if found {
return event
}
return AnimationEventNone
}
// SetEvent sets event on specific index to given
func (r *AnimationDataRecord) SetEvent(index int, event AnimationEvent) {
r.events[index] = event
}

View File

@ -185,7 +185,12 @@ func (td *TextDictionary) Marshal() []byte {
sw.PushUint16(0)
sw.PushInt32(int32(len(*td)))
keys := make([]string, 0)
for key := range *td {
keys = append(keys, key)
}
sw.PushInt32(int32(len(keys)))
// version (always 0)
sw.PushBytes(0)
@ -205,7 +210,8 @@ func (td *TextDictionary) Marshal() []byte {
// dataPos is a position, when we're placing data stream
dataPos := len(sw.GetBytes()) + 17*len(*td)
for key, value := range *td {
for _, key := range keys {
value := (*td)[key]
// non-zero if record is used (for us, every record is used ;-)
sw.PushBytes(1)
@ -218,7 +224,13 @@ func (td *TextDictionary) Marshal() []byte {
sw.PushUint32(0)
sw.PushUint32(uint32(dataPos))
dataPos += len(key) + 1
if key[0] == '#' {
// 1 for X, and 1 for separator
dataPos += 2
} else {
dataPos += len(key) + 1
}
sw.PushUint32(uint32(dataPos))
dataPos += len(value) + 1
@ -227,7 +239,13 @@ func (td *TextDictionary) Marshal() []byte {
}
// data stream: put all data in appropriate order
for key, value := range *td {
for _, key := range keys {
value := (*td)[key]
if key[0] == '#' {
key = "x"
}
for _, i := range key {
sw.PushBytes(byte(i))
}

View File

@ -8,7 +8,7 @@ func exampleData() *TextDictionary {
result := &TextDictionary{
"abc": "def",
"someStr": "Some long string",
"teststring": "TeSt",
"teststring": "TeStxwsas123 long strin122*8:wq",
}
return result
@ -27,7 +27,32 @@ func TestTBL_Marshal(t *testing.T) {
newValue, ok := newTbl[key]
if !ok {
t.Fatal("string wasn't encoded to table")
t.Fatalf("string %s wasn't encoded to table", key)
}
if newValue != value {
t.Fatal("unexpected value set")
}
}
}
func TestTBL_MarshalNoNameString(t *testing.T) {
tbl := &TextDictionary{
"#0": "OKEY",
}
data := tbl.Marshal()
newTbl, err := LoadTextDictionary(data)
if err != nil {
t.Error(err)
}
for key, value := range *tbl {
newValue, ok := newTbl[key]
if !ok {
t.Fatalf("string %s wasn't encoded to table", key)
}
if newValue != value {