prevnext   » SZS: Wiimms SZS Toolset » wlect: Wiimms LE-CODE Tool » wlect distribution

wlect distribution

This command manages data for LE-CODE track distributions. It reads any number of source files with different file types, collects the data and creates any number of files with different file types. Wildcards are accepted.

Use the command without keyword to get an extended description.

Contents

1.   Syntax

wlect DISTRIBUTION [argument]...

2.   Options

Options
Option Param Description
--load-prefix file Read in a PREFIX file and replace the internal prefix database with the content. https://ct.wiimm.de/export/prefix is the authoritative source for this.
--load-category file Read in a CATEGORY file and replace the internal category database with the content. https://ct.wiimm.de/export/category is the authoritative source for this.
--plus chars If a name begins with a plus sign, then all characters up to the first space are recognized as a plus prefix. The first part consists of all the plus signs followed by any other characters. The first character of the second part is used to determine the sort value. If the second part is empty, then the last plus sign is used instead.

The higher sorting value is now calculated from the number of plus signs in the first part, the more plus signs, the smaller the value. The first character from the second part determines the lower value. If it is in parameter CHARS then the position determines the value, otherwise the ASCII value to which 500 is added.

--track-dir directory Define a destination directory, where track files are copied, moved or linked to. Usually it is .../Race/Course/.

Files are searched in directories defined by --copy-tracks, --move-tracks, --move1-tracks and --link-tracks in definition order. Already existing files are removed before operation.

--copy-tracks directory Define a search directory for all included tracks. Files found in this directory are copied to the directory specified by option --track-dir.
--move-tracks directory Define a search directory for all included tracks. Files found in this directory are moved to the directory specified by option --track-dir. If moving fails, the file is copied and the source removed.
--move1-tracks directory Define a search directory for all included tracks. Files found in this directory are moved to the directory specified by option --track-dir, but only if a file has not more than one hard link. This guarantees an unique version of the file. If the file has more hard links or moving fails, the file is copied and the source removed.
--szs-mode mode If a track is inserted via the SZS file, then the associated directory is automatically included in the list of search directories for option --track-dir. This option now sets the transfer mode. OFF turns this feature off. The values COPY, MOVE, MOVE1 and LINK define one of the 4 modes. Default mode is LINK.
-i --ignore Ignore non existing source files without warning.
-H --no-header Suppress the syntax information section in LE text files.
-B --brief Suppress cross reference comments.
-X --export Enable the export mode and create small and machine readable text files for easy post processing.
-d --dest path Define a destination path (directory/file). The destination - means: write to standard output.

The path may contain escape sequences: %Q is replaced by the fully qualified source name. %P and %F are replaced by the source path or by the filename. %N and %E are replaced by source filename without extension or by the source extension. Finally, %T is replaced by the default extension of the destination format.

A '?' direct behind '%' in %E and %T conversions avoid that the same extension is used twice in row.

-D --DEST path Like --dest, but create the directory path automatically.
-E --esc char Define an alternative escape character for destination files. The default is '%'. For Windows batch files it is a good choice to set '-E$'.
-o --overwrite Overwrite already existing files without warning and ignore option --number.
--number If a file already exist, append a number directly before the file extension to make the filename unique. If other numbered files already exist (ignoring case), use the maximum existing index+1. --num is a short cut.
-r --remove-dest Remove already existing files before creating it. If set, --overwrite is ignored. --rm-dest is a short cut.
-u --update Update only existing files and don't create new files. If set, --overwrite and --remove-dest are ignored.
-p --preserve Preserve file times (atime+mtime) while converting or copying files.

3.   Description

This new command was created to handle all aspects related to LE-CODE based distributions. To do this, it reads in any number of sources with different file formats to create a holistic model. Any number of files with different file formats can then be generated from this model. It's all controlled by processing options. After writing some files, other files can also be loaded, e.g. with alternative names, in order to then generate alternative output files.

In order to make all this possible, a sometimes very long command line is entered. This is then processed step by step from left to right. Each argument is either a processing option, an instruction (e.g. write a file) or a filename to read a file.

This command replaces commands like wlect patch ... to patch a LE-CODE binary file or wszst distribution ... to prepare a file for ct.wiimm.de.

For more details read the built-in help.

4.   Built-in Help

Below is a copy of the built-in help which can be displayed by wlect distribution or shorter by wlect dis as colored text. It is also available as text file.

Command »wlect DISTRIBUTION«

  This command manages data for LE-CODE track distributions. It reads any number of
  source files with different file types, collects the data and creates any number of
  files with different file types.

  »wlect DISTRIBUTION« is a very powerful tool when dealing with distributions. Because
  of the complexity, the input line offers many possibilities. First, the default options
  (arguments beginning with 1 or 2 minus signs like -B or --brief) are evaluated. Then
  the remaining arguments of the command line are evaluated step by step from left to
  right. There are input files that change the internal model. The instructions are used
  to change the data or to write data to files. The processing options affect both
  reading and writing.

  Syntax:

    wlect DISTRIBUTION
    wlect DISTRIBUTION option... argument...

  »DIS« and »DISTRIB« are well defined shortcuts for »DISTRIBUTION«. Without arguments,
  this help is printed.


Arguments:

  Arguments are divided into 3 groups: processing options, instructions and filenames.

  If an argument beginns with a plus sign (+), then is is scanned as a comma-separated
  list of processing options. To use a filename that starts with a plus sign (e.g.
  »+file.txt«), precede it with »./« (e.g. »./+file.txt«).

  Otherwise, if the argument is of the form COMMAND=PARAMETER, then it is a instruction.
  COMMAND is a keyword (case-insenitive) and starts with a letter followed by any number
  of letters, digits and minus signs. PARAMETER must consist of at least one character.
  If PARAMETER is empty, then the next argument is used as PARAMETER. This also allows
  the syntax COMMAND= PARAMETER (2 arguments), which is helpful for the automatic
  completion of filenames.

  Otherwise it is a filename of an input file. The file is read and generally overwrites
  existing content. This means that the file last read in has the highest priority.
  However, this can be influenced by the processing options. Arguments beginning with »/«
  or »./« are always recognized as filenames.

  All arguments are executed in the order in which they were entered without any logging.
  Only error messages are displayed. With option --verbose (short: -v),  at least one log
  line for each argument is printed.

  It is possible to store arguments into a file (e.g. into file »param.txt«) and to
  include those file by option -@FILENAME (e.g. by »-@param.txt«). This option can be
  used multiple times and is evaluated before the actual analysis of the command line.
  Command »wlect argtest ...« is suitable for tests.


Input Files:

  Input files are processed in the order in which they were entered. They supplement or
  overwrite the internal data structure with its diverse data.

  If a file does not exist but the associated filename contains wildcards (any of »*?[«),
  then all matching files are loaded as source. So it's possible to keep the command line
  small if using »'*.szs'« (with apostrophs) instead of »*.szs«.

  The following file types are recognized and processed. The names used here are the same
  as those given out by the command FILETYPE for identification:

    LEDIS:   A distribution dump created by write instruction »DUMP=…«. Such a dump
	     usually contains all relevant data of the internal model, which is restored
	     by reading it in.

    LEDEF:   A distribution definition file. This new format replaces the old CTTEXT
	     format. It supports all LE-CODE properties and will be further developed to
	     match LE-CODE. Templates can be created with instruction »LEDEF=…« or with
	     command »wlect CREATE LEDEF«.

    LEREF:   A track reference list created by write instruction »REF=…«.

    SHA1REF: A SHA1 reference list created by write instruction »SHA1=…«. Only checksum
	     and track slot are used.

    LE-BIN:  A LE-CODE binary file (e.g. »lecode-PAL.bin«). Usually settings and LPAR are
	     imported. Option IN-LECODE decides if the file is used as template for the
	     specifig region if a binary is created.

    PREFIX:  Replace the internal prefix list by the content of the file.
	     https://ct.wiimm.de/export/prefix is the authoritative source for this.

    MTCAT:   Replace the internal track category list by the content of the file.
	     https://ct.wiimm.de/export/category is the authoritative source for this.

    LPAR:    A LE-CODE parameter file (e.g. »lpar.txt«).

    BMG and BMGTXT:
	     Any BMG (binary or text). See section »Processing Options« for more details.

    DISTRIB: A distribution file created by write instruction »DISTRIB=…« or by command
	     »wszst DISTRIBUTION«. Such files are imported by ct.wiimm.de to display
	     information about distributions.

    CTTEXT:  A CT-CODE or LE-CODE definition file. The file is scanned by the CT-CODE
	     scanner and then imported.

    *.szs:   Track files are added to 2 different internal track tracks lists, one for
	     racing tracks and one for battle areans. I the argument is quoted then wlect
	     will resolve the wildcards by itself.
  All file types that are accepted by option --le-define (BRRES, TEX0, CT-CODE, ...) are
  also possible.


Instructions:

  Instructions are of the form COMMAND=PARAMETER (1 argument) or COMMAND= PARAMETER (2
  arguments). Commands are case-insenitive. The use of keywords without the minus sign
  and unique abbreviations are permitted. Any number of write instructions can be used.
  And these can be mixed with input files at will.

  Most commands, but not all, are write instructions. They write the current contents of
  the internal model to a file. In these cases, PARAMETER is a filename. If a filename is
  a minus sign only, then stdout is used. Existing files are only overwritten if at least
  one of the options --overwrite (short: -o) or --remove-dest (short: -r) is set.

  If a filename beginns with a plus sign, the plus sign is removed and the output file is
  opened in append mode. If a file is to be created with a plus sign at the beginning,
  then »./« should be put in front. If an output file is opened for the second time, then
  it is automatically opened in append mode.


  Create human readable information files:

    NAMES:    Create a human readable reference file with cup info and track names. Only
	      tracks with known name (not empty) are printed. The tracks are ordered by
	      cups.
    XNAMES:   Same as NAMES, but use extended names if available.

    INFO:     Create a human readable reference file with cup info slots, flags and track
	      names. Only tracks with known name (not empty) are printed. The tracks are
	      ordered by cups.
    XINFO:    Same as INFO, but use extended names if available.

    RATING:   Same as INFO, but with additional first column »()« to rate the tracks. The
	      tracks are ordered by cups.
    XRATING:  Same as RATING, but use extended names if available.

    PREFIX:   Print a machine readable prefix list. https://ct.wiimm.de/export/prefix is
	      the authoritative source for this.

  Create human and machine readable definition files (usually input files):

    LE-DEF:   Create a LE-CODE definition file of format »#LE-DEF1«, that is usually used
	      to declare tracks for a LE-CODE distributions. This new format replaces the
	      old format created by CTDEF=. It supports all LE-CODE properties and will
	      be further developed to match future LE-CODE.

    CT-DEF:   Create a definition file of format »#CT-CODE«, that is usually used to
	      declare tracks for a CT-CODE or LE-CODE distributions. Only simple layouts
	      are supported, so that the track arrangement can be distorted when
	      importing again. In addition, a file is created that can only be read by
	      the tools since version 2.28a.

  Generate machine-readable files that can also be used as input files:

    SHA1:     Create a SHA1 list file that can be used on Wiimmfi to limit the tracks
	      that can be used in a region. Only tracks with known SHA1 are printed. The
	      output can be used as input file to restore the checksums.
    XSHA1:    Same as SHA1, but use extended names if available.

    DISTRIB:  Create a distribution file like command »wszst DISTRIBUTION« does. However,
	      this variant only supports tracks with a known track slot. The output can
	      be used as input file.
    XDISTRIB: Same as DISTRIB, but use extended names for the track list if available.

    LPAR:     Create a LPAR file. Use --brief (-b) to suppress comments.

    BMG:      Create a BMG binary file. BMG options are recognized. But if the output
	      goes to a terminal, then use instruction BMGTXT instead. If no BMG selector
	      is defined, then MKW,LE-CODE (all except CT-CODE) is used.
    BMGTXT:   Create a BMG text file. Global BMG options are recognized.

    REF:      Create a machine readable track reference (type LEREF), that can be used as
	      input file for other commands. One line is printed for each defined track.

    DUMP:     Create a dump of the complete internal model to a distribution file (type
	      LE-DIS). This file can be used as source to restore the internal model.

  Analyze and report:

    REPORT:   Analyse the current distribution and print a report. Therefor count track
	      and arena types and find duplicate names, tracks, families and clans.

		Syntax: REPORT '=' [OPTIONS] '=' FILE

	      OPTIONS is a comma separated list of keywords to select the kind of
	      analysis. If no option is set, all are enabled. To list by classes and to
	      find duplicate tracks, families or clans, the definition file must support
	      SHA1 checksums and a SHA1 reference file must be loaded. You can get the
	      reference file from https://ct.wiimm.de/export/sha1ref/view.

		 @varname:   Use another predefined string instead of 'name' as source
			     for option names. See section »Processing Options: Storage«
			     for details.
		 [key]:      Like @varname, but use a user defined string as source.
		 counters:   Count track and arena types in different ways.
		 classes:    List tracks by track class, except classes SELECT and
			     NINTENDO.
		 xclasses:   List tracks by track class without exceptions.This option is
			     excluded from default.
		 names:      Find track names that are used by two or more distinct
			     tracks or arenas.
		 tracks:     Find tracks that are used two or more times and list them.
		 families:   Find tracks that are in the same family and list them.
		 clans:      Find track families that are in the same clan and list them.
		 duplicates: Short cut for »names,tracks,families,clans«.
		 all:        Short cut for all lists of above. To exclude something, you
			     can write e.g. »all,-clans«, or shorter »-clans«.
		 default:    Select all standard analyses. This option is used
			     automatically if no other option is specified. At the moment
			     it is the same as »all,-xclasses«.

    DEBUG:     Print some statistics for debugging. The current state is analysed without
	       updating cups.

    LE-INFO:   Print information about current LE-CODE binaries.

  Cup-Icon support:

    CUP-ICONS: Create an image file with cup icons.

		 Syntax: CUP-ICON '=' [OPTIONS] '=' FILE

	       If the output goes to a terminal, then use instruction CUP-INFO instead.
	       To determine the file type, the file extension is analyzed. Examples are
	       »*.tpl« or »*.png«.

	       The generic icons consist of a red cup index at the top-right and the
	       first 5 characters of the name without a prefix, shown in blue at the
	       bottom. If a name is wider than 128 pixels, than it is horizontal shrinked
	       to 128 pixels.

	       OPTIONS is a comma separated list of keywords:
		 @varname: Use another predefined string instead of 'name' as source. See
			   section »Processing Options: Storage« for details.
		 [key]:    Like @varname, but use a user defined string as source.
		 original: Use the original cup icons for the first 8 cups.
		 swapped:  Use the original cup icons for the first 8 cups, but in sapped
			   order. This is recommended for LE-CODE if using the 32
			   original tracks.
		 1wiimm:   Use Wiimms avatar for the first cup, but only if original
			   icons are not used.
		 9wiimm:   Use Wiimms avatar for the ninth cup.
		 xwiimm:   Use Wiimms avatar for the last cup.
		 plus:     If a plus prefix exists, then insert it and an additional
			   space.
		 xplus:    Same as option plus, but append an underline character instead
			   of a space after the plus prefix. Underline characters are
			   printed like spaces, but they are ignored by option space.
		 game:     If a game prefix exists, then insert it and an additional
			   space.
		 xgame:    Same as option game, but append an underline character instead
			   of a space after the game prefix.
		 space:    Finish the name part at first space. Ignore tabulators and
			   underline characters for this.
		 0 .. 15:  Define the maximum number of characters for the name part to
			   any value between 0 and 15. The default is 5 characters.

    CUP-INFO:  Same as CUP-ICONS, but create a text file with a job list for tool wimgt
	       and its generic file :cup-file=FILE. The output is machine and human
	       readable.

  Create LE-CODE binary files:

    LECODE:   Create 4 LE-CODE binary files, one for each region. The filename must
	      contain at least one »@« character. The last »@« character is replaced by
	      PAL, USA, JAP and KOR in sequence. The binary data embedded in the SZS
	      tools is usually used as a template. At the moment it is build 36
	      (2022-12-15). Other templates can be used with the IN-LECODE processing
	      option.

    PAL:      Like instruction LECODE, but only the PAL version is created. The »@«
	      character has no special meaning here.
    USA:      Like instruction PAL, but the USA version is created.
    JAP:      Like instruction PAL, but the JAP version is created.
    KOR:      Like instruction PAL, but the KOR version is created.

  String functions:

    SEPARATOR: Define a separator string that is used by other commands. The default is a
	      space.
		Syntax: SEPARATOR '=' STRING  or  SEP '=' STRING

    COPY:     This instruction copies the texts of 1 or more sources to a destination.
		Syntax of PARAMETER: DEST '=' SRC [ '+' SRC ]...

	      DEST and SRC are storage indicators explained in section »Processing
	      Options: Storage«. The sources are joined textually, with a separator
	      (defined by instruction SEPARATOR, see above) inserted between the sources.

	      Example: copy=[result]=sha1+[size]

    SPLIT:    This instruction analyses the SOURCE like command wszst split does it. Then
	      the directives of FORMAT create a string that is copied to DESTINATION.
		Syntax of PARAMETER: DESTINATION ',' SOURCE ',' FORMAT
	      Visit https://szs.wiimm.de/opt/printf for more details.

    SUBST:    This instruction searches for text passages using a regular expression and
	      replaces the found passages with another text.
		Syntax of PARAMETER: STORAGE ',' SEP REGEXP SEP REPLACEMENT SEP OPTIONS

	      STORAGE is a storage indicator explained in section »Processing Options:
	      Storage«. SEP is the very first character behind the comma. It must occur
	      exactly 3 times and separates the 3 parts from each other. REGEXP is the
	      extended regular expression used for searching. If successful, replace that
	      portion matched with REPLACEMENT. The replacement may contain the special
	      string »$0« to refer to that portion of the pattern space which matched,
	      and the special string1 »$1« through »$9« to refer to the corresponding
	      matching sub-expressions in the regexp. The two characters »g« for global
	      (replace all occurrences) and »i« for ignore case are recognized as
	      OPTIONS.

	      Examples: subst=name,+abc+xyz+
			subst=[key],/search ([0-9])/replace $1/gi

  Copy, move or link track files:

    TRACKS: Copy, move or links files following the options --copy-tracks, --move-tracks,
	    --move1-tracks, --link-tracks and --track-dir. PARAMETER is a keyword that
	    specifies the options for execution:

	      NO-LOG: Transfer the tracks without logging.
	      LOG:    Transfer the tracks with logging.
	      TEST:   Log planned actions only and don't touch any file.


Processing Options:

  Processing Options are inserted as comma separated list. A list always begins with a
  plus sign to distinguish it from filenames and instructions. Option names are
  case-insenitive. Unique abbreviations are allowed. Names with a minus sign in their
  name can also be specified without the minus sign.

  Most option names can be preeceded by a minus sign or a slash to negate its meaning.
  Processing Options are only valid for subsequent arguments. This makes it possible to
  use different filters for different input or output files. The keywords are divided
  into several functional groups.

  Managment Options:

    HELP:       Stop execution and print this help.
    RESET:      Reset the filter to its default.

    CUT-ALL:    Remove all tracks and their settings.
    CUT-STD:    Remove tracks and their settings, that are not needed for a standard
		distribution with 32 tracks and 10 battle arenas.
    CUT-CTCODE: Remove tracks and their settings, that are not needed for a CT-CODE
		distribution. Arenas are also removed.

  BMG selector:

    Define which BMG strings are used as input. Multiple source can be selected. If none
    is selected, then all are used. MKW1 has the lowest priority and LE-CODE the highest.

    MKW1:       Use the first set of orignal names starting from message id 0x2454
		(racing tracks) and 0x2490 (battle arenas).
    MKW2:       Use the second set of orignal names starting from message id 0x24b8
		(racing tracks) and 0x24cc (battle arenas).
    MKW:        Short cut for »+MKW1,MKW2«.
    CT-CODE:    Use the CT-CODE names starting from message id 0x4000.
    LE-CODE:    Use the LE-CODE names starting from message id 0x7000.

  Input filters:

    Define the type of character identifiers accepted as source. Empty character strings
    and character strings that only consist of a minus sign are considered invalid.

    IN-EMPTY:   Empty strings are also considered valid. IEMPTY is a short cut for this
		keyword.
    IN-MINUS:   Strings consisting only of a minus sign are also considered valid. IMINUS
		is a short cut for this keyword.
    IN-ALL:     Short cut for »+IN-EMPTY,IN-MINUS«. IALL is a short cut for this keyword.

  Input operation:

    Define how already existing strings are overwritten.

    OVERWRITE:  Insert all valid BMG strings and overwrite already existing strings. This
		is the default.
    INSERT:     Insert only valid BMG strings, that are empty in the track list.
    REPLACE:    Replace only valid BMG strings that are already defined in the track
		list. Other strings are ignored.

  Storage:

    Define the string type being processed. This is used for BMG input and output files
    only.

    The storge names are also used as a reference in other instructions. In this case,
    the reference can be preceded by an at symbol (@). This is mandatory if the storage
    can be specified optionally and does not begin with a bracket ([).

    IDENT:      Define a new identfication string. If it is a valid SHA1 or DB64 string,
		then update SHA1 too. If reading, then get the identfication string.
    SHA1:       Same as IDENT if writing. If reading, then get the SHA1 string.
    FILE:       Define a new or get the filename.
    NAME:       Define a new or get the standard name.
    XNAME:      Define a new or get the extended name.
    X2NAME:     Define a new standard and a new extended name. If reading, then get the
		extended name, if valid, or the standard name as fallback.

    TEMP1:      A temporary variable with no specific purpose. Access is much faster than
		for dynamic strings by [key]. They are therefore intended for multi-level
		string manipulations.
    TEMP2:      A second temporary variable.

    [key]:      For each track there is a set of character strings at the user's
		disposal. The character strings are addressed via KEY. The KEY itself can
		consist of any character and are case-sensitive. This type of square
		bracket option can only be used directly after the leading plus sign.
		More processing options may follow.

  Output filters:

    Select tracks for the output by their features.

    VERSUS|VS:  Select versus tracks only.
    BATTLE|BT:  Select battle tracks (arenas) only. If neither or both of VERSUS and
		BATTLE set, both types are selected.

    CUSTOM:     Select custom tracks. An original track in the wrong slot will also be
		considered CUSTOM.
    ORIGINAL:   Select original tracks at correct track slot only. Original tracks are
		detected by their SHA1. If neither or both of CUSTOM and ORIGINAL set,
		both types are selected.

    NO-D:       This option suppresses information about so-called '_d' files. This
		affects 2 sub-commands: With the REF sub-command, the data fields
		relating to '_d' files remain empty, and with SHA1, no lines are output
		for '_d' tracks.

  Empty output strings:

    For sub-commands (X)NAMES and (X)INFO, only tracks that have a valid name are output.
    Empty character strings and character strings that only consist of a minus sign are
    considered invalid.

    OUT-EMPTY:  Empty strings are also considered valid. OEMPTY is a short cut for this
		keyword.
    OUT-MINUS:  Strings consisting only of a minus sign are also considered valid. OMINUS
		is a short cut for this keyword.
    OUT-DUMMY:  Dummy names are considered valid (default). A dummy name consists of an
		underscore followed by a three-digit hex number (lower case only). This
		name is assigned when importing a LE-CODE binary file due to a lack of
		alternatives. ODUMMY is a short cut for this keyword.
    /OUT-DUMMY: Switch option OUT-DUMMY off so that dummy names are considered invalid.
    OUT-ALL:    Short cut for »+OUT-EMPTY,OUT-MINUS,OUT-DUMMY«. OALL is a short cut for
		this keyword.


  More options:

    IN-LECODE:  When reading a LE-CODE binaray file (e.g. »lecode-PAL.bin«), only the
		settings are imported, but not the binary itself. So if writing a LE-CODE
		binary then the region dependent built-in binary is used. If this option
		set, then binaries are imported to override the built-in versions. One
		reason to activate this option is to use more recent LE-CODE versions.
		ILECODE is a short cut for this keyword.
    /IN-LECODE: Switch option IN-LECODE off.

    NO-SLOT:    Suppress »SLOT <index&rt;« lines when creating a LE-CODE defintion file
		(LE-DEF). NOSLOT is a short cut for this keyword.
    /NO-SLOT:   Switch option NO-SLOT off.

    BRIEF:      When creating text files, detailed descriptions are suppressed. The
		default is based on the global options --no-header and --brief.
    /BRIEF:     Switch option BRIEF off.


Built-in LE-CODE binaries:

  PAL v5, build 36 (2022-12-15 05:09:25 UTC), 78400 bytes
  USA v5, build 36 (2022-12-15 05:09:25 UTC), 78400 bytes
  JAP v5, build 36 (2022-12-15 05:09:25 UTC), 78400 bytes
  KOR v5, build 36 (2022-12-15 05:09:25 UTC), 78400 bytes