mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-11-19 08:30:21 +01:00
Map content in DecodedBlock.Content() thru the index map to pull this logic out of the renderer.
This commit is contained in:
parent
e145779ca0
commit
cb5b6461a3
@ -144,21 +144,26 @@ func NewDecodedBlock(data []byte, nameIndex map[string]int) (db *DecodedBlock, e
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *DecodedBlock) Content(x, y, z int) int {
|
func (db *DecodedBlock) Content(x, y, z int) (content int, found bool) {
|
||||||
pos := z<<8 + y<<4 + x
|
pos := z<<8 + y<<4 + x
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case db.Version >= 24:
|
case db.Version >= 24:
|
||||||
pos <<= 1
|
pos <<= 1
|
||||||
return int(db.MapContent[pos])<<8 | int(db.MapContent[pos+1])
|
content = int(db.MapContent[pos])<<8 | int(db.MapContent[pos+1])
|
||||||
case db.Version >= 20:
|
case db.Version >= 20:
|
||||||
if db.MapContent[pos] <= 0x80 {
|
if db.MapContent[pos] <= 0x80 {
|
||||||
return int(db.MapContent[pos])
|
content = int(db.MapContent[pos])
|
||||||
|
} else {
|
||||||
|
content = int(db.MapContent[pos])<<4 | int(db.MapContent[pos+0x2000])>>4
|
||||||
}
|
}
|
||||||
return int(db.MapContent[pos])<<4 | int(db.MapContent[pos+0x2000])>>4
|
|
||||||
default:
|
default:
|
||||||
return db.IgnoreId
|
return
|
||||||
}
|
}
|
||||||
|
if content != db.AirId && content != db.IgnoreId {
|
||||||
|
content, found = db.IndexMap[content]
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPosBuf(data []byte) *PosBuf {
|
func NewPosBuf(data []byte) *PosBuf {
|
||||||
|
Loading…
Reference in New Issue
Block a user