1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-06-27 01:25:35 +00:00
OpenDiablo2/d2common/d2fileformats/d2mpq/crypto_buff.go
gravestench 6f8b43f8d6
Various lint error fixes and suppressions (#846)
* suppressing the magic number lint errors in mapgen, it will get a heavy refactor soon, hopefully...

* adding string token constants for SkillClass

* adding panic on error to left/right skill select render

* fixed cuddle lint error

* fixed unnecessary conversion, unused func param lint errors in dcc_animation.go

* adding comment for skill class tokens

* fixed typo in comment

* removed unused parameter in dcc/dc6 animations

* supress warning about Object.setMode always being passed direction value of 0

* fixed all invalid golint directives

* fixed a couple gocritic lint errors
2020-10-26 02:04:50 -07:00

33 lines
721 B
Go

package d2mpq
var cryptoBuffer [0x500]uint32 //nolint:gochecknoglobals // will fix later..
var cryptoBufferReady bool //nolint:gochecknoglobals // will fix later..
func cryptoLookup(index uint32) uint32 {
if !cryptoBufferReady {
cryptoInitialize()
cryptoBufferReady = true
}
return cryptoBuffer[index]
}
//nolint:gomnd // magic cryptographic stuff here...
func cryptoInitialize() {
seed := uint32(0x00100001)
for index1 := 0; index1 < 0x100; index1++ {
index2 := index1
for i := 0; i < 5; i++ {
seed = (seed*125 + 3) % 0x2AAAAB
temp1 := (seed & 0xFFFF) << 0x10
seed = (seed*125 + 3) % 0x2AAAAB
temp2 := seed & 0xFFFF
cryptoBuffer[index2] = temp1 | temp2
index2 += 0x100
}
}
}