1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-09-27 05:35:57 -04:00

common: use inc closure to handle indices of SoundEntry props (#109)

This commit is contained in:
Robin Eklind 2019-11-07 22:33:10 -06:00 committed by Tim Sarbin
parent e26946bd35
commit d04f07606b

View File

@ -39,32 +39,37 @@ type SoundEntry struct {
// CreateSoundEntry creates a sound entry based on a sound row on sounds.txt // CreateSoundEntry creates a sound entry based on a sound row on sounds.txt
func createSoundEntry(soundLine string) SoundEntry { func createSoundEntry(soundLine string) SoundEntry {
props := strings.Split(soundLine, "\t") props := strings.Split(soundLine, "\t")
i := -1
inc := func() int {
i++
return i
}
result := SoundEntry{ result := SoundEntry{
Handle: props[0], Handle: props[inc()],
Index: StringToInt(props[1]), Index: StringToInt(props[inc()]),
FileName: props[2], FileName: props[inc()],
Volume: StringToUint8(props[3]), Volume: StringToUint8(props[inc()]),
GroupSize: StringToUint8(props[4]), GroupSize: StringToUint8(props[inc()]),
Loop: StringToUint8(props[5]) == 1, Loop: StringToUint8(props[inc()]) == 1,
FadeIn: StringToUint8(props[6]), FadeIn: StringToUint8(props[inc()]),
FadeOut: StringToUint8(props[7]), FadeOut: StringToUint8(props[inc()]),
DeferInst: StringToUint8(props[8]), DeferInst: StringToUint8(props[inc()]),
StopInst: StringToUint8(props[9]), StopInst: StringToUint8(props[inc()]),
Duration: StringToUint8(props[10]), Duration: StringToUint8(props[inc()]),
Compound: StringToInt8(props[11]), Compound: StringToInt8(props[inc()]),
Reverb: StringToUint8(props[12]) == 1, Reverb: StringToUint8(props[inc()]) == 1,
Falloff: StringToUint8(props[13]), Falloff: StringToUint8(props[inc()]),
Cache: StringToUint8(props[14]), Cache: StringToUint8(props[inc()]),
AsyncOnly: StringToUint8(props[15]) == 1, AsyncOnly: StringToUint8(props[inc()]) == 1,
Priority: StringToUint8(props[16]), Priority: StringToUint8(props[inc()]),
Stream: StringToUint8(props[17]), Stream: StringToUint8(props[inc()]),
Stereo: StringToUint8(props[18]), Stereo: StringToUint8(props[inc()]),
Tracking: StringToUint8(props[19]), Tracking: StringToUint8(props[inc()]),
Solo: StringToUint8(props[20]), Solo: StringToUint8(props[inc()]),
MusicVol: StringToUint8(props[21]), MusicVol: StringToUint8(props[inc()]),
Block1: StringToInt(props[22]), Block1: StringToInt(props[inc()]),
Block2: StringToInt(props[23]), Block2: StringToInt(props[inc()]),
Block3: StringToInt(props[24]), Block3: StringToInt(props[inc()]),
} }
return result return result
} }