Crate twmap[][src]

This crate provides a library for safe parsing, editing and saving of Teeworlds and DDNet maps. Goals of this library are:

  • performance
  • reasonable map standards
  • compatibility with all Teeworlds maps (0.7) and DDNet (0.6) maps

In the very center of this library is the TwMap struct. For more information and the complete list of its available methods, check out its documentation page.

Note that library is a aware of the origin of the map (Teeworlds 0.7 or DDNet 0.6). On parsing a map it will store its Version in the version field, which in turn is used to perform the appropriate checks and save in the correct version.

Examples:

Note that for better readability, some lines of code are left out in the examples, most notably use twmap::*; at the top.

Loading a binary map, accessing its version and image names and saving it again in the binary format:

let mut map = TwMap::parse_file(dm1_path)?;

assert_eq!(map.version, Version::Teeworlds07);
assert_eq!(map.images[0].name(), "bg_cloud1");
assert_eq!(map.images[6].name(), "sun");

map.save_file(output_path)?;

Loading a MapDir or binary map, removing unused envelopes, layers, groups, images, sounds and saving it again in the MapDir format:

let mut map = TwMap::parse_path(map_path)?;

map.remove_everything_unused();

map.save_dir(output_path)?;

Loading a MapDir map, flipping it upside down and saving the map data into a vector:

let mut map = TwMap::parse_dir(map_path)?;

map.rotate_right();
map.rotate_right();
map.mirror();

let mut map_data = Vec::new();
map.save(&mut map_data)?;

Modules

compression
constants
datafile_parse
datafile_save
map_checks
map_dir
map_edit
map_impl
map_parse
map_save

Structs

AutoMapper
BezierCurve
Color
EmbeddedImage
Env
EnvPoint
ExternalImage
FrontLayer
GameLayer
GameTile
Group
I16
I32Color
ImageLoadInfo
Info
OutdatedTileVersion
Point
Position
Quad
QuadsLayer
Sound
SoundSource
SoundsLayer
Speedup
SpeedupLayer
Switch
SwitchLayer
Tele
TeleLayer
Tile
TileFlags
TilesLayer
TilesLoadInfo
Tune
TuneLayer
TwMap

The TwMap struct represents a Teeworlds 0.7 map or a DDNet 0.6 map. Which one of those it is will always be determined during the parsing process and is stored in the version field.

Enums

CompressedData
CurveKind
Envelope
Error
Image
InvalidLayerKind
ItemType
Layer
LayerKind
SoundShape
Version

Traits

AnyLayer
AnyTile
Load
LoadMultiple
TileMapLayer