]> git.lizzy.rs Git - mt.git/blob - mapblk.go
Add WaitGroup to SerializePkt
[mt.git] / mapblk.go
1 package mt
2
3 type MapBlkFlags uint8
4
5 const (
6         BlkIsUnderground MapBlkFlags = 1 << iota
7         BlkDayNightDiff
8         BlkLightExpired
9         BlkNotGenerated
10 )
11
12 type LitFromBlks uint16
13
14 const AlwaysLitFrom LitFromBlks = 0xf000
15
16 func LitFrom(d Dir, b LightBank) LitFromBlks {
17         return 1 << (uint8(d) + uint8(6*b))
18 }
19
20 type MapBlk struct {
21         Flags   MapBlkFlags
22         LitFrom LitFromBlks
23
24         //mt:const uint8(2)     // Size of param0 in bytes.
25         //mt:const uint8(1 + 1) // Size of param1 and param2 combined, in bytes.
26
27         Param0 [4096]Content
28         Param1 [4096]uint8
29         Param2 [4096]uint8
30
31         NodeMetas map[uint16]*NodeMeta
32
33         // net info
34         // mt:const uint8(2) // version
35 }
36
37 // Pos2BlkPos converts a node position to a MapBlk position and index.
38 func Pos2Blkpos(pos [3]int16) (blkpos [3]int16, i uint16) {
39         for j := range pos {
40                 blkpos[j] = pos[j] >> 4
41                 i |= uint16(pos[j]&0xf) << (4 * j)
42         }
43
44         return
45 }
46
47 // BlkPos2Pos converts a MapBlk position and index to a node position.
48 func Blkpos2Pos(blkpos [3]int16, i uint16) (pos [3]int16) {
49         for j := range pos {
50                 pos[j] = blkpos[j]<<4 | int16(i>>(4*j)&0xf)
51         }
52
53         return
54 }