common

Module for everything in common between all kinds of Terraria save files.

Assuming a save file is not encrypted, as is the case for character files, you can use the items made available by this module to determine the kind of save file you’re dealing with.

Example

from lihzahrd.terraria.utils.packer import Packer
from lihzahrd.terraria.common.file_metadata import FileMetadata

with open("tests/lihzahrd/terraria/world/Honey_of_Privacy.wld") as stream:
    fp = Packer(stream)
    metadata = FileMetadata.read(fp).instance
    print(metadata.kind)
    metadata.revision.value += 1
    print(metadata.revision)

file_metadata

Submodule collecting all parts of the Terraria save file header in a single class.

class lihzahrd.terraria.common.file_metadata.FileMetadata(*args: Pack, **kwargs)

PackComposite for all parts of the Terraria save file header.

version: Field[Self, PackFileVersion]

The version with which the save file was written with.

Type:

PackFileVersion

signature: Field[Self, PackFileSignature]

The signature of the save file.

Type:

PackFileSignature

kind: Field[Self, PackFileKind]

The kind of the save file.

Type:

PackFileKind

revision: Field[Self, PackFileRevision]

The revision of the save file.

The save file revision should increase by 1 each time a save file is saved.

Type:

PackFileRevision

flags: Field[Self, PackFileFlags]

The flags of the save file.

Type:

PackFileFlags

file_version

Submodule for distinguishing between the Terraria game versions with which a save file was written with.

class lihzahrd.terraria.common.file_version.FileVersion(*values)

IntEnum containing all known associations between Terraria version strings and file version numbers.

See also

Desktop version history on the Terraria wiki.

__str__() str

Get the properly-formatted version name.

Example

>>> str(FileVersion["V.1.4.5.5"])
"v1.4.5.5"
Returns:

The properly-formatted version name, such as "v1.4.5.5".

V_1_0_5 = 12

Version 1.0.5.

V_1_0_6 = 20

Version 1.0.6.

V_1_0_6_1 = 22

Version 1.0.6.1.

V_1_1_1 = 37

Version 1.1.1.

V_1_1_2 = 39

Version 1.1.2.

V_1_2 = 67

Version 1.2.

V_1_2_0_3_1 = 71

Version 1.2.0.3.1.

V_1_2_1_1 = 72

Version 1.2.1.1.

V_1_2_1_2 = 73

Version 1.2.1.2.

V_1_2_2 = 77

Version 1.2.2.

V_1_2_3_1 = 94

Version 1.2.3.1.

V_1_2_4 = 101

Version 1.2.4.

V_1_2_4_1 = 102

Version 1.2.4.1.

V_1_3_0_1 = 140

Version 1.3.0.1.

V_1_3_0_2 = 147

Version 1.3.0.2.

V_1_3_0_3 = 149

Version 1.3.0.3.

V_1_3_0_4 = 151

Version 1.3.0.4.

V_1_3_0_5 = 153

Version 1.3.0.5.

V_1_3_0_6 = 154

Version 1.3.0.6.

V_1_3_0_7 = 155

Version 1.3.0.7.

V_1_3_0_8 = 156

Version 1.3.0.8.

V_1_3_1 = 168

Version 1.3.1.

V_1_3_1_1 = 169

Version 1.3.1.1.

V_1_3_2 = 170

Version 1.3.2.

V_1_3_2_1 = 173

Version 1.3.2.1.

V_1_3_3 = 174

Version 1.3.3.

V_1_3_3_1 = 175

Version 1.3.3.1.

V_1_3_3_2 = 176

Version 1.3.3.2.

V_1_3_3_3 = 177

Version 1.3.3.3.

V_1_3_4 = 178

Version 1.3.4.

V_1_3_4_1 = 185

Version 1.3.4.1.

V_1_3_4_2 = 186

Version 1.3.4.2.

V_1_3_4_3 = 187

Version 1.3.4.3.

V_1_3_4_4 = 188

Version 1.3.4.4.

V_1_3_5 = 191

Version 1.3.5.

V_1_3_5_1 = 192

Version 1.3.5.1.

V_1_3_5_2 = 193

Version 1.3.5.2.

V_1_3_5_3 = 194

Version 1.3.5.3.

V_1_4_0_1 = 225

Version 1.4.0.1.

V_1_4_0_2 = 226

Version 1.4.0.2.

V_1_4_0_3 = 227

Version 1.4.0.3.

V_1_4_0_4 = 228

Version 1.4.0.4.

V_1_4_0_5 = 230

Version 1.4.0.5.

V_1_4_2_3 = 238

Version 1.4.2.3.

V_1_4_4_5 = 274

Version 1.4.4.5.

V_1_4_4_8 = 278

Version 1.4.4.8.

V_1_4_4_9 = 279

Version 1.4.4.9.

V_1_4_5_4 = 317

Version 1.4.5.4.

V_1_4_5_5 = 318

Version 1.4.5.5.

class lihzahrd.terraria.common.file_version.PackFileVersion(value: Value)

Pack for FileVersion as represented in the save file metadata header.

ENUM

alias of FileVersion

file_signature

Submodule for distinguishing between the possible file signature that a Terraria save file may have.

class lihzahrd.terraria.common.file_signature.FileSignature(*values)

StrEnum containing all known Terraria save file signatures.

RELOGIC = 'relogic'

Signature of international Terraria save files.

XINDONG = 'xindong'

Signature of some Chinese Terraria save files.

__str__()

Return str(self).

class lihzahrd.terraria.common.file_signature.PackFileSignature(value: Value)

Pack for FileSignature as represented in the save file metadata header.

Validates that the contained signature is exactly 7-characters long.

ENUM

alias of FileSignature

file_kind

Submodule for distinguishing between Terraria save file kinds.

class lihzahrd.terraria.common.file_kind.FileKind(*values)

IntEnum describing a kind of Terraria save file.

INVALID = 0

A specifically-invalid value.

MAP = 1

A minimap.

WORLD = 2

A world save file.

See also

The lihzahrd.terraria.world module.

PLAYER = 3

A player character save file.

Note

Player character save files are usually encrypted with a static key, and must be unencrypted before they can be processed with FileMetadata.

class lihzahrd.terraria.common.file_kind.PackFileKind(value: Value)

Pack for FileKind as represented in the save file metadata header.

ENUM

alias of FileKind

file_revision

Submodule for processing the save file revision number.

class lihzahrd.terraria.common.file_revision.PackFileRevision(value: Value)

Pack for the revision of a Terraria save file.

file_flags

Submodule for distinguishing between Terraria save file kinds.

class lihzahrd.terraria.common.file_flags.FileFlags(*values)

IntFlag representing all possible file flags a Terraria world might have.

FAVORITE = 1

If set, the file is marked as favorite.

class lihzahrd.terraria.common.file_flags.PackFileFlags(value: Value)

Pack for FileFlags as represented in the save file metadata header.

FLAGS

alias of FileFlags