mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-09 10:04:05 +09:00
making room for larger tile ID to accomodate subtiling
This commit is contained in:
@@ -3,17 +3,17 @@ package net.torvald.unsafe
|
||||
/**
|
||||
* Created by minjaesong on 2024-07-22.
|
||||
*/
|
||||
class UnsafeInt2D(width: Int, height: Int) {
|
||||
class UnsafeLong2D(width: Int, height: Int) {
|
||||
|
||||
val width = width.toLong()
|
||||
val height = height.toLong()
|
||||
|
||||
private val ptr = UnsafeHelper.allocate(4L * width * height)
|
||||
private val ptr = UnsafeHelper.allocate(8L * width * height)
|
||||
|
||||
private inline fun toIndex(y: Int, x: Int) = width * y + x
|
||||
|
||||
operator fun set(y: Int, x: Int, value: Int) = ptr.setInt(toIndex(y, x), value)
|
||||
operator fun get(y: Int, x: Int) = ptr.getInt(toIndex(y, x))
|
||||
operator fun set(y: Int, x: Int, value: Long) = ptr.setLong(toIndex(y, x), value)
|
||||
operator fun get(y: Int, x: Int) = ptr.getLong(toIndex(y, x))
|
||||
|
||||
fun destroy() = ptr.destroy()
|
||||
val destroyed: Boolean
|
||||
Reference in New Issue
Block a user