mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-11-14 08:16:06 -05:00
29 lines
570 B
Go
29 lines
570 B
Go
package d2mpq
|
|
|
|
var cryptoBuffer [0x500]uint32
|
|
var cryptoBufferReady bool
|
|
|
|
func cryptoLookup(index uint32) uint32 {
|
|
if !cryptoBufferReady {
|
|
cryptoInitialize()
|
|
cryptoBufferReady = true
|
|
}
|
|
|
|
return cryptoBuffer[index]
|
|
}
|
|
|
|
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
|
|
}
|
|
}
|
|
}
|