1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-11-14 08:16:06 -05:00

Merge pull request #1055 from gucio321/hotfix2

hotfix: cof encoder: coding weapon class
This commit is contained in:
Tim Sarbin 2021-02-10 11:49:18 -05:00 committed by GitHub
commit d981ae49a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 9 deletions

View File

@ -121,7 +121,6 @@ func (c *COF) Unmarshal(fileData []byte) error {
layer.Transparent = b[layerTransparent] > 0
layer.DrawEffect = d2enum.DrawEffect(b[layerDrawEffect])
layer.weaponClassByte = b[layerWeaponClass:]
layer.WeaponClass = d2enum.WeaponClassFromString(strings.TrimSpace(strings.ReplaceAll(
string(b[layerWeaponClass:]), badCharacter, "")))
@ -193,7 +192,22 @@ func (c *COF) Marshal() []byte {
sw.PushBytes(byte(c.CofLayers[i].DrawEffect))
sw.PushBytes(c.CofLayers[i].weaponClassByte...)
const (
maxCodeLength = 3 // we assume item codes to look like 'hax' or 'kit'
terminator = 0
)
weaponCode := c.CofLayers[i].WeaponClass.String()
for idx, letter := range weaponCode {
if idx > maxCodeLength {
break
}
sw.PushBytes(byte(letter))
}
sw.PushBytes(terminator)
}
for _, i := range c.AnimationFrames {

View File

@ -4,11 +4,10 @@ import "github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
// CofLayer is a structure that represents a single layer in a COF file.
type CofLayer struct {
Type d2enum.CompositeType
Shadow byte
Selectable bool
Transparent bool
DrawEffect d2enum.DrawEffect
WeaponClass d2enum.WeaponClass
weaponClassByte []byte
Type d2enum.CompositeType
Shadow byte
Selectable bool
Transparent bool
DrawEffect d2enum.DrawEffect
WeaponClass d2enum.WeaponClass
}