Packages

  • package root
    Definition Classes
    root
  • package io
    Definition Classes
    root
  • package github
    Definition Classes
    io
  • package memo33
    Definition Classes
    github
  • package scdbpf

    Provides methods for accessing and modifying the contents of DBPF formatted files.

    Provides methods for accessing and modifying the contents of DBPF formatted files. Currently, only DBPF version 1.0 is supported (used by SimCity 4).

    DBPF files are accessed via DbpfFiles, a container of DbpfEntries. The content of a DbpfEntry can be accessed from BufferedEntries in decoded form as DbpfType, such as Exemplar, Fsh or Sc4Path.

    This package object provides additional type aliases for DbpfExceptions.

    Examples

    To get started, it is easiest to start the REPL via sbt console, which loads all the dependencies and useful initial import statements. Reading a DBPF file, sorting its entries by TGI and writing back to the same file could be achieved like this:

    val dbpf = DbpfFile.read(new File("foobar.dat"))
    dbpf.write(dbpf.entries.sortBy(_.tgi))

    This example shifts the GIDs of all LTexts by +3:

    dbpf.write(dbpf.entries.map { e =>
      if (e.tgi matches Tgi.LText)
        e.copy(e.tgi.copy(gid = e.tgi.gid + 3))
      else
        e
    })

    Another example: This decodes all the Sc4Path entries and rotates them by 90 degree.

    val writeList = for (e <- dbpf.entries) yield {
      if (e.tgi matches Tgi.Sc4Path) {
        val be = e.toBufferedEntry.convertContentTo(Sc4Path)
        be.copy(content = be.content * RotFlip.R1F0)
      } else {
        e
      }
    }
    dbpf.write(writeList)

    The following example finds the first entry that is an exemplar and contains a property with a specific ID. (Note the view to avoid unnecessary decoding if the exemplar is already among the first entries.)

    val id = UInt(0x12345678)
    dbpf.entries.view.
      filter(_.tgi matches Tgi.Exemplar).
      map(_.toBufferedEntry.convertContentTo(Exemplar)).
      find(_.content.properties.contains(id))
    Definition Classes
    memo33
  • package compat
    Definition Classes
    scdbpf
  • BufferedEntry
  • DbpfEntry
  • DbpfExceptions
  • DbpfFile
  • DbpfPackager
  • DbpfProperty
  • DbpfType
  • DbpfTypeCompanion
  • DbpfUtil
  • Exemplar
  • Experimental
  • Fsh
  • LText
  • RawEntry
  • RawType
  • S3d
  • Sc4Path
  • StreamedEntry
  • Tgi
  • TgiMask
  • WithContentConverter
c

io.github.memo33.scdbpf

BufferedEntry

final case class BufferedEntry[+A <: DbpfType](tgi: Tgi, content: A, compressed: Boolean) extends DbpfEntry with Product with Serializable

A buffered entry whose data is held in memory in uncompressed form. The actual data will be held by the content type. As such, this entry will be immutable, if its content is immutable.

A

the type of the content

tgi

the TGI of this entry

content

the actual content of this entry

compressed

true, if the input should try to return the data in compressed form. If compression fails (if the compressed data would be larger than the compressed one, for instance), the data may be uncompressed nevertheless.

Source
entries.scala
See also

RawEntry

StreamedEntry

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. BufferedEntry
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. DbpfEntry
  7. AnyRef
  8. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new BufferedEntry(tgi: Tgi, content: A, compressed: Boolean)

    tgi

    the TGI of this entry

    content

    the actual content of this entry

    compressed

    true, if the input should try to return the data in compressed form. If compression fails (if the compressed data would be larger than the compressed one, for instance), the data may be uncompressed nevertheless.

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  6. val compressed: Boolean
  7. val content: A
  8. def convert[B <: DbpfType](implicit eh: ExceptionHandler, conv: Converter[BufferedEntry[A], BufferedEntry[B]]): ![BufferedEntry[B], DbpfDecodeFailedException]

    Deprecated: Prefer convertContentTo instead.

    Deprecated: Prefer convertContentTo instead.

    Creates a new BufferedEntry, with this entry's content converted to B. Usually this delegates to the convert method of content, but in some cases this is not possible, like for Exemplar, which requires the tgi for conversion.

  9. def convertContentTo[B <: DbpfType](dbpfType: WithContentConverter[B])(implicit eh: ExceptionHandler): ![BufferedEntry[B], DbpfDecodeFailedException]

    Creates a new BufferedEntry, with this entry's content converted to B.

    Creates a new BufferedEntry, with this entry's content converted to B. Usually this delegates to the convert method of content, but in some cases this is not possible, like for Exemplar, which requires the tgi for conversion.

  10. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  11. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  13. def input(): Input[Byte]

    the byte input that provides the raw byte data that gets written to DBPF files

    the byte input that provides the raw byte data that gets written to DBPF files

    It is tried to respect the compressed flag, as long as this reduces the data size.

    Definition Classes
    BufferedEntryDbpfEntry
  14. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  15. def map[B <: DbpfType](f: (A) ⇒ B): BufferedEntry[B]

    Maps the content of this buffered entry and returns a new BufferedEntry with the content replaced by the image of the map.

  16. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  17. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  18. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  19. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  20. val tgi: Tgi

    the TGI of this entry

    the TGI of this entry

    Definition Classes
    BufferedEntryDbpfEntry
  21. def toBufferedEntry(implicit eh: ExceptionHandler): ![BufferedEntry[DbpfType], DbpfIoException]

    Converts this entry to a BufferedEntry.

    Converts this entry to a BufferedEntry.

    An ExceptionHandler needs to be brought into scope via imports (either strategy.throwExceptions or strategy.captureExceptions from the scdbpf package).

    Definition Classes
    BufferedEntryDbpfEntry
  22. def toRawEntry(implicit eh: ExceptionHandler): ![RawEntry, DbpfIoException]

    Converts this entry to a RawEntry.

    Converts this entry to a RawEntry.

    An ExceptionHandler needs to be brought into scope via imports (either strategy.throwExceptions or strategy.captureExceptions from the scdbpf package).

    Definition Classes
    BufferedEntryDbpfEntry
  23. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  24. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  25. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from DbpfEntry

Inherited from AnyRef

Inherited from Any

Ungrouped