Skip to content

Commit

Permalink
Add experimental scala linter
Browse files Browse the repository at this point in the history
  • Loading branch information
Martomate committed Jul 11, 2024
1 parent debd593 commit c5a7665
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
8 changes: 5 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import scala.util.Properties.isMac

ThisBuild / organization := "com.martomate"
ThisBuild / version := "0.14"
ThisBuild / scalaVersion := "3.4.0"
ThisBuild / scalaVersion := "3.4.2"
ThisBuild / publishArtifact := false
ThisBuild / logBuffered := false
ThisBuild / fork := true
Expand All @@ -14,7 +14,8 @@ val commonSettings: scala.Seq[Def.Setting[?]] = Defaults.coreDefaultSettings ++
module.organization + "." + module.name + "-" + module.revision + "." + artifact.extension
},
scalacOptions ++= Seq("-deprecation", "-unchecked", "-feature"),
javacOptions ++= Seq("-release", "11")
javacOptions ++= Seq("-release", "11"),
libraryDependencies += "org.scala-lang" %% "scala2-library-tasty-experimental" % scalaVersion.value
)

lazy val hexacraft = project
Expand Down Expand Up @@ -99,5 +100,6 @@ lazy val game = project
),
packJarNameConvention := "full",
packGenerateMakefile := false,
packArchiveExcludes := Seq("VERSION", "bin/hexacraft-mac.bat")
packArchiveExcludes := Seq("VERSION", "bin/hexacraft-mac.bat"),
packExcludeJars := Seq(".*scala2-library-tasty.*\\.jar")
)
2 changes: 1 addition & 1 deletion common/src/main/scala/hexacraft/util/UniquePQ.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import scala.collection.mutable.ArrayBuffer
class UniquePQ[S](func: S => Double, ord: Ordering[Double]) { // PQ with fast lookup and resorting
private type DS = (Double, S)

private val pq: mutable.PriorityQueue[DS] = mutable.PriorityQueue.empty(ord.on(_._1))
private val pq: mutable.PriorityQueue[DS] = mutable.PriorityQueue.empty(using ord.on(_._1))
private val set: mutable.Set[S] = mutable.HashSet.empty

def enqueue(elem: S): Unit = {
Expand Down
10 changes: 5 additions & 5 deletions common/src/main/scala/hexacraft/util/segments.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ case class Segment(start: Int, length: Int) {

class SegmentSet extends mutable.Iterable[Segment] {

private val segments: mutable.TreeSet[Segment] = mutable.TreeSet.empty { (s1, s2) =>
private val segments: mutable.TreeSet[Segment] = mutable.TreeSet.empty(using { (s1, s2) =>
if (s1.overlaps(s2)) 0
else s1.start - s2.start
}
private val segmentsContain: mutable.TreeMap[Segment, Segment] = mutable.TreeMap.empty { (s1, s2) =>
})
private val segmentsContain: mutable.TreeMap[Segment, Segment] = mutable.TreeMap.empty(using { (s1, s2) =>
if (s2.contains(s1)) 0
else s1.start - s2.start
}
})
private var _totalLength = 0

protected def _add(seg: Segment): Unit = {
Expand Down Expand Up @@ -121,7 +121,7 @@ class KeyedSegmentSet[T] extends SegmentSet {
}
}

private val invMap: mutable.TreeMap[Segment, T] = mutable.TreeMap.empty(invMapOrder)
private val invMap: mutable.TreeMap[Segment, T] = mutable.TreeMap.empty(using invMapOrder)
private val segmentsPerKey: mutable.HashMap[T, Int] = mutable.HashMap.empty

override protected def _add(seg: Segment): Unit = {
Expand Down
2 changes: 1 addition & 1 deletion game/src/main/scala/hexacraft/world/gen/tree/parts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ case class BlobGenerator(
override def generate(): Seq[Offset] = {
val seen = mutable.HashSet.empty[Offset]
val result = mutable.HashSet.empty[Offset]
val edge = mutable.PriorityQueue.empty[(Float, Offset)](Ordering.by(-_._1))
val edge = mutable.PriorityQueue.empty[(Float, Offset)](using Ordering.by(-_._1))
var time = 0.0f

val start = Offset(0, 0, 0)
Expand Down
4 changes: 2 additions & 2 deletions game/src/main/scala/hexacraft/world/loader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class ChunkLoadingPrioritizer(maxDist: Double)(using CylinderSize) {
private val furthestFirst: Ordering[ChunkRelWorld] = Ordering.by(c => distSq(origin, c))
private val closestFirst: Ordering[ChunkRelWorld] = Ordering.by(c => -distSq(origin, c))

private val addableChunks: mutable.PriorityQueue[ChunkRelWorld] = mutable.PriorityQueue.empty(closestFirst)
private val removableChunks: mutable.PriorityQueue[ChunkRelWorld] = mutable.PriorityQueue.empty(furthestFirst)
private val addableChunks: mutable.PriorityQueue[ChunkRelWorld] = mutable.PriorityQueue.empty(using closestFirst)
private val removableChunks: mutable.PriorityQueue[ChunkRelWorld] = mutable.PriorityQueue.empty(using furthestFirst)

private val maxDistSqInBlocks: Double = (maxDist * 16) * (maxDist * 16)

Expand Down

0 comments on commit c5a7665

Please sign in to comment.