Extra tools: Difference between revisions

From DDraceNetwork
Add new tool demo_extract_chat from 17.4
Rafaelff (talk | contribs)
Remove "version" from DDNet version X.x to uniformize
 
(3 intermediate revisions by 2 users not shown)
Line 51: Line 51:
Tests connection by setting a client–server connection locally and running ping between them. Reports dropped packets with message <code>dropped packet</code> and successes with <code>cfg = ''number''</code>, where ''number'' varies from 0 to 2.
Tests connection by setting a client–server connection locally and running ping between them. Reports dropped packets with message <code>dropped packet</code> and successes with <code>cfg = ''number''</code>, where ''number'' varies from 0 to 2.


===demo_extract_chat===
===demo_extract_chat=== <!--T:19-->


  demo_extract_chat ''demo_file''
  <!--T:20-->
demo_extract_chat ''demo_file''


<!--T:21-->
Exports all messages from a demo file, output is printed to the console.
Exports all messages from a demo file, output is printed to the console.


<!--T:22-->
  chat: *** 'nameless tee' entered and joined the game
  chat: *** 'nameless tee' entered and joined the game
  chat: nameless tee: Hello!
  chat: nameless tee: Hello!
Line 63: Line 66:
  whisper: -> nameless tee: Hi!
  whisper: -> nameless tee: Hi!


<!--T:23-->
''Available since: DDNet 17.4''
''Available since: DDNet 17.4''


===dilate===<!--T:19-->
===dilate=== <!--T:24-->


  <!--T:20-->
  <!--T:25-->
dilate ''image_file1'' [''image_file2'' ... ]
dilate ''image_file1'' [''image_file2'' ... ]


<!--T:21-->
<!--T:26-->
It is a graphics tool, mainly useful for mappers. It takes care of transparent areas to prevent black/white outlines around your images ingame, therefore avoiding blending and mipmap issues. See [http://wiki.polycount.com/wiki/Edge_padding Edge padding] for more info.
It is a graphics tool, mainly useful for mappers. It takes care of transparent areas to prevent black/white outlines around your images ingame, therefore avoiding blending and mipmap issues. See [http://wiki.polycount.com/wiki/Edge_padding Edge padding] for more info.


<!--T:22-->
<!--T:27-->
Note this works only in RGBA image files (e.g. PNG files). So, it will fail in e.g. JPEG files.
Note this works only in RGBA image files (e.g. PNG files). So, it will fail in e.g. JPEG files.


===dummy_map=== <!--T:23-->
===dummy_map=== <!--T:28-->


  <!--T:24-->
<!--T:29-->
dummy_map
dummy_map


<!--T:25-->
<!--T:30-->
Creates a dummy, small empty map used for vanilla antispoof (<code>sv_vanilla_antispoof</code>). See [https://github.com/ddnet/ddnet/blob/a66379918832e5ad93332bbe0475394b156b5c24/src/engine/shared/network_server.cpp#L371] for more info.
Creates a dummy, small empty map used for vanilla antispoof (<code>sv_vanilla_antispoof</code>). See [https://github.com/ddnet/ddnet/blob/a66379918832e5ad93332bbe0475394b156b5c24/src/engine/shared/network_server.cpp#L371] for more info.


===map_convert_07=== <!--T:29-->
===map_convert_07=== <!--T:31-->


  <!--T:30-->
  <!--T:32-->
map_convert_07 ''src_map_file'' ''dest_map_file''
map_convert_07 ''src_map_file'' ''dest_map_file''


<!--T:31-->
<!--T:33-->
Makes <code>''dest_map_file''</code> compatible with Teeworlds version 7.x that otherwise it would be compatible '''only''' with Teeworlds version 6.x. If successfully, it creates a valid 07-compatible destination map; otherwise, it returns one of the following:
Makes <code>''dest_map_file''</code> compatible with Teeworlds version 7.x that otherwise it would be compatible '''only''' with Teeworlds version 6.x. If successfully, it creates a valid 07-compatible destination map; otherwise, it returns one of the following:


<!--T:32-->
<!--T:34-->
*an usage message if incorrect arguments are provided
*an usage message if incorrect arguments are provided
*<code>failed to open source map</code> if an error happens when opening the source map
*<code>failed to open source map</code> if an error happens when opening the source map
Line 100: Line 104:
*<code>invalid image format</code> if incorrectly formatted PNG.
*<code>invalid image format</code> if incorrectly formatted PNG.


<!--T:33-->
<!--T:35-->
''Available since: DDNet 12.9''
''Available since: DDNet 12.9''


===map_create_pixelart===
===map_create_pixelart=== <!--T:36-->
 
<!--T:37-->
map_create_pixelart <image.png> <img_pixelsize> <input_map> <layergroup_id> <layer_id> <pos_x> <pos_y> <quad_pixelsize> <output_map> [optimize=0|1] [centralize=0|1]
map_create_pixelart <image.png> <img_pixelsize> <input_map> <layergroup_id> <layer_id> <pos_x> <pos_y> <quad_pixelsize> <output_map> [optimize=0|1] [centralize=0|1]


<!--T:38-->
Creates a map with quad-based pixelart from an image.
Creates a map with quad-based pixelart from an image.


<!--T:39-->
Note: use destination layer tiles as a reference for positions and pixels for sizes.
Note: use destination layer tiles as a reference for positions and pixels for sizes.


<!--T:40-->
Note: set img_pixelsize to 0 to consider the largest possible size.
Note: set img_pixelsize to 0 to consider the largest possible size.


<!--T:41-->
Note: set quad_pixelsize to 0 to consider the same value of img_pixelsize.
Note: set quad_pixelsize to 0 to consider the same value of img_pixelsize.


<!--T:42-->
Note: if image.png has not a perfect pixelart grid, result might be unexpected, manually fix img_pixelsize to get it better.
Note: if image.png has not a perfect pixelart grid, result might be unexpected, manually fix img_pixelsize to get it better.


<!--T:43-->
Options: optimize tries to reduce the total number of quads (default: 1).
Options: optimize tries to reduce the total number of quads (default: 1).


<!--T:44-->
Options: centralize places all pivots at the same position (default: 0).
Options: centralize places all pivots at the same position (default: 0).


===map_diff=== <!--T:34-->
===map_diff=== <!--T:45-->


  <!--T:35-->
  <!--T:46-->
map_diff ''map_file1'' ''map_file2''
map_diff ''map_file1'' ''map_file2''


<!--T:36-->
<!--T:47-->
Compares two map files, reporting one of the follow:
Compares two map files, reporting one of the follow:
*no diff output, meaning the maps are the same
*no diff output, meaning the maps are the same
Line 132: Line 145:
*lastly, the index and flags positions that differ.
*lastly, the index and flags positions that differ.


<!--T:37-->
<!--T:48-->
If there is no difference between maps, returns 0; otherwise, returns 1.
If there is no difference between maps, returns 0; otherwise, returns 1.


===map_extract=== <!--T:38-->
===map_extract=== <!--T:49-->


  <!--T:39-->
  <!--T:50-->
map_extract ''map_file'' [''directory'']
map_extract ''map_file'' [''directory'']


<!--T:40-->
<!--T:51-->
Extracts contents from ''map_file'' into the ''directory''. If optional argument ''directory'' is not provided, extracts to the current directory.
Extracts contents from ''map_file'' into the ''directory''. If optional argument ''directory'' is not provided, extracts to the current directory.


===map_find_env===
===map_find_env=== <!--T:52-->
 
<!--T:53-->
map_find_env <input_map> <env_number>
map_find_env <input_map> <env_number>


<!--T:54-->
Finds quads using a specific envelope and prints their index and position to the console.
Finds quads using a specific envelope and prints their index and position to the console.


<!--T:55-->
Note: returned quads positions are relative to their layers.
Note: returned quads positions are relative to their layers.


===map_optimize=== <!--T:41-->
===map_optimize=== <!--T:56-->


  <!--T:42-->
  <!--T:57-->
map_optimize ''source_map_filepath'' [''dest_map_filepath'']
map_optimize ''source_map_filepath'' [''dest_map_filepath'']


<!--T:43-->
<!--T:58-->
Optimizes the map file in the <code>''source_map_filepath''</code> given (see [https://github.com/ddnet/ddnet/pull/3201 how it works]) and stores the output in the given <code>''dest_map_filepath''</code>; if <code>''dest_map_filepath''</code> is unset, output path defaults to <code>out/''source_map_filename''.map</code>, stripping the path and the extension of the source file.
Optimizes the map file in the <code>''source_map_filepath''</code> given (see [https://github.com/ddnet/ddnet/pull/3201 how it works]) and stores the output in the given <code>''dest_map_filepath''</code>; if <code>''dest_map_filepath''</code> is unset, output path defaults to <code>out/''source_map_filename''.map</code>, stripping the path and the extension of the source file.


<!--T:44-->
<!--T:59-->
Note the name of the embedded images optimized is changed from <code>''originalname''</code> to <code>''originalname''_cut_''newSHA256''</code> (where <code>''newSHA256''</code> is the new sha256 of the embedded optimized image). It is renamed is to make clear it was optimized because this tool '''will''' make changes in the mapres used by the map file.
Note the name of the embedded images optimized is changed from <code>''originalname''</code> to <code>''originalname''_cut_''newSHA256''</code> (where <code>''newSHA256''</code> is the new sha256 of the embedded optimized image). It is renamed is to make clear it was optimized because this tool '''will''' make changes in the mapres used by the map file.


<!--T:45-->
<!--T:60-->
If failed to open source or target file, returns -1.
If failed to open source or target file, returns -1.


<!--T:46-->
<!--T:61-->
''Available since:'' DDNet 15.5.4
''Available since:'' DDNet 15.5.4


===map_replace_area===
===map_replace_area=== <!--T:62-->
 
<!--T:63-->
map_replace_area <from_map> <from_x> <from_y> <to_map> <to_x> <to_y> <width> <height> <output_map>
map_replace_area <from_map> <from_x> <from_y> <to_map> <to_x> <to_y> <width> <height> <output_map>


<!--T:64-->
Replaces an area of one map with an area from another map.
Replaces an area of one map with an area from another map.


<!--T:65-->
Note: use game layer tiles as a reference for both coordinates and sizes.
Note: use game layer tiles as a reference for both coordinates and sizes.


===map_replace_image=== <!--T:47-->
===map_replace_image=== <!--T:66-->


  <!--T:48-->
  <!--T:67-->
map_replace_image ''map_file1'' ''map_file2'' ''imagename'' ''image_file''
map_replace_image ''map_file1'' ''map_file2'' ''imagename'' ''image_file''


<!--T:49-->
<!--T:68-->
Replaces the image ''imagename'' currently inside the map filename ''map_file1'' with the image filepath ''image_file'', and save into the map filename ''map_file2.map''.
Replaces the image ''imagename'' currently inside the map filename ''map_file1'' with the image filepath ''image_file'', and save into the map filename ''map_file2.map''.


<!--T:50-->
<!--T:69-->
Please note:
Please note:
*Both map filenames must be relative to user default DDNet folder
*Both map filenames must be relative to user default DDNet folder
*New image filepath can be absolute, or relative to the current directory
*New image filepath can be absolute, or relative to the current directory


===map_resave=== <!--T:51-->
===map_resave=== <!--T:70-->


  <!--T:52-->
  <!--T:71-->
map_resave ''map_file'' ''image_file''
map_resave ''source_map.map'' ''destination_map.map''


<!--T:53-->
<!--T:72-->
Updates the map file ''map_file.map'' with the provided file ''image_file''.
Reads the map ''source_map.map'' and writes it back to ''destination_map.map'' using the latest map format.


<!--T:54-->
===packetgen=== <!--T:73-->
The error status 255 is returned if 1) a number of arguments different from 2 is provided, 2) if the ''map_file.map'' is not valid, or 3) if ''image_file'' is not a valid image file (e.g. it is a text file); otherwise, return 0.


===packetgen=== <!--T:55-->
  <!--T:74-->
 
  <!--T:56-->
packetgen
packetgen


<!--T:57-->
<!--T:75-->
Generates and sends network packets to 127.0.0.1:8303 (localhost, in default server port) to test communication with a local server instance.
Generates and sends network packets to 127.0.0.1:8303 (localhost, in default server port) to test communication with a local server instance.


===stun===
===stun=== <!--T:76-->
 
<!--T:77-->
stun ''address''
stun ''address''


<!--T:78-->
Sends [[wikipedia:STUN|STUN]] request to server and checks response.
Sends [[wikipedia:STUN|STUN]] request to server and checks response.


===twping===
===twping=== <!--T:79-->
twping server[:port] (default port: 8303)
 
<!--T:80-->
twping ''server''[:''port'']


Measures ping to a teeworlds server by requesting the server information.
<!--T:81-->
Measures ping to a teeworlds server by requesting the server information. ''port'' defaults to 8303.


===unicode_confusables=== <!--T:58-->
===unicode_confusables=== <!--T:82-->


  <!--T:59-->
  <!--T:83-->
unicode_confusables ''string1'' ''string2''
unicode_confusables ''string1'' ''string2''


<!--T:60-->
<!--T:84-->
Compares ''string1'' with ''string2'' and report if they are "confusable", i.e. if the characters are "equal" and could cause confusion. For this to work, the characters with accents or other things around them are considered the "confusable" with the base character. Therefore, ''aa'' and ''aá'' are confusable (''á'' was considered as ''a''), while ''aa'' and ''ab'' are not.
Compares ''string1'' with ''string2'' and report if they are "confusable", i.e. if the characters are "equal" and could cause confusion. For this to work, the characters with accents or other things around them are considered the "confusable" with the base character. Therefore, ''aa'' and ''aá'' are confusable (''á'' was considered as ''a''), while ''aa'' and ''ab'' are not.


<!--T:61-->
<!--T:85-->
If they are confusable, it returns <code>not_confusable=0</code>, otherwise, returns <code>not_confusable=1</code>.
If they are confusable, it returns <code>not_confusable=0</code>, otherwise, returns <code>not_confusable=1</code>.


<!--T:62-->
<!--T:86-->
''Available since: DDNet version 10.3.5''
''Available since: DDNet 10.3.5''


<!--T:63-->
<!--T:87-->
''New in DDNet version 12.9:'' Unicode 12.0 support and the tool name was renamed from ''confusables'' to ''unicode_confusables''.
''New in DDNet 12.9:'' Unicode 12.0 support and the tool name was renamed from ''confusables'' to ''unicode_confusables''.


===uuid=== <!--T:64-->
===uuid=== <!--T:88-->


  <!--T:65-->
  <!--T:89-->
uuid ''name''
uuid ''name''


<!--T:66-->
<!--T:90-->
Prints uuid for the provided ''name''.
Prints uuid for the provided ''name''.


<!--T:67-->
<!--T:91-->
The uuid system was implemented to be easily extended by independent authors without collisions, something that the old system – with increasing integers – did not allow. This works for engine and game messages, snapshot items and events.
The uuid system was implemented to be easily extended by independent authors without collisions, something that the old system – with increasing integers – did not allow. This works for engine and game messages, snapshot items and events.


<!--T:68-->
<!--T:92-->
Exits with error status 255 if ''name'' is not provided.
Exits with error status 255 if ''name'' is not provided.


<!--T:69-->
<!--T:93-->
''Available since: DDNet 10.6.1''
''Available since: DDNet 10.6.1''
</translate>
</translate>

Latest revision as of 17:23, 9 February 2024

Extra tools are available for running some non-gaming-related tasks, like map optimization by mappers, or debugging and testing by developers. These tools must be run from command-line interface (e.g. Command Prompt on Windows or Terminal on Linux) either by adding their containing directory to the PATH variable or by running directly from the containing directory.

Getting the extra tools

These tools are not provided in the binary DDNet game in the Downloads page. Having that said, extra tools mapping-related can be download for different platforms in the Downloads page, under the name "Graphics Tools".

These and other extra tools (listed below) can be found on the DDNet source code under src/tools directory.

List of extra tools

See below the list and description of the tools.

config_retrieve

config_retrieve map_file

Retrieves configuration embedded in a DDNet map file map_file and stores it in a DDNet map configuration file with same filename (e.g. "Kobra 4.map" returns "Kobra 4.cfg")

Available since: DDNet 9.0

config_store

config_store map_file

Stores configuration from a map's configuration file into the map_file. Both configuration and map files must have the same filename in the same directory, otherwise the operation will fail.

If there is no difference between the configuration to stored and the configuration embedded in the map, then operation will be canceled with message configs coincide, not updating map.

Available since: DDNet 9.0

crapnet

crapnet

Tests connection by setting a client–server connection locally and running ping between them. Reports dropped packets with message dropped packet and successes with cfg = number, where number varies from 0 to 2.

demo_extract_chat

demo_extract_chat demo_file

Exports all messages from a demo file, output is printed to the console.

chat: *** 'nameless tee' entered and joined the game
chat: nameless tee: Hello!
broadcast: Welcome!
teamchat: brainless tee: Hello team!
whisper: -> nameless tee: Hi!

Available since: DDNet 17.4

dilate

dilate image_file1 [image_file2 ... ]

It is a graphics tool, mainly useful for mappers. It takes care of transparent areas to prevent black/white outlines around your images ingame, therefore avoiding blending and mipmap issues. See Edge padding for more info.

Note this works only in RGBA image files (e.g. PNG files). So, it will fail in e.g. JPEG files.

dummy_map

dummy_map

Creates a dummy, small empty map used for vanilla antispoof (sv_vanilla_antispoof). See [1] for more info.

map_convert_07

map_convert_07 src_map_file dest_map_file

Makes dest_map_file compatible with Teeworlds version 7.x that otherwise it would be compatible only with Teeworlds version 6.x. If successfully, it creates a valid 07-compatible destination map; otherwise, it returns one of the following:

  • an usage message if incorrect arguments are provided
  • failed to open source map if an error happens when opening the source map
  • failed to open destination map if an error happens when opening the destination map
  • error loading storage if failed to open storage for some reason
  • failed to open image file if error happens on opening PNG image
  • invalid image format if incorrectly formatted PNG.

Available since: DDNet 12.9

map_create_pixelart

map_create_pixelart <image.png> <img_pixelsize> <input_map> <layergroup_id> <layer_id> <pos_x> <pos_y> <quad_pixelsize> <output_map> [optimize=0|1] [centralize=0|1]

Creates a map with quad-based pixelart from an image.

Note: use destination layer tiles as a reference for positions and pixels for sizes.

Note: set img_pixelsize to 0 to consider the largest possible size.

Note: set quad_pixelsize to 0 to consider the same value of img_pixelsize.

Note: if image.png has not a perfect pixelart grid, result might be unexpected, manually fix img_pixelsize to get it better.

Options: optimize tries to reduce the total number of quads (default: 1).

Options: centralize places all pivots at the same position (default: 0).

map_diff

map_diff map_file1 map_file2

Compares two map files, reporting one of the follow:

  • no diff output, meaning the maps are the same
  • different layer numbers, if one map has more layers than another
  • different tile layers, if the number of layers is the same, but at least one layer is different
  • lastly, the index and flags positions that differ.

If there is no difference between maps, returns 0; otherwise, returns 1.

map_extract

map_extract map_file [directory]

Extracts contents from map_file into the directory. If optional argument directory is not provided, extracts to the current directory.

map_find_env

map_find_env <input_map> <env_number>

Finds quads using a specific envelope and prints their index and position to the console.

Note: returned quads positions are relative to their layers.

map_optimize

map_optimize source_map_filepath [dest_map_filepath]

Optimizes the map file in the source_map_filepath given (see how it works) and stores the output in the given dest_map_filepath; if dest_map_filepath is unset, output path defaults to out/source_map_filename.map, stripping the path and the extension of the source file.

Note the name of the embedded images optimized is changed from originalname to originalname_cut_newSHA256 (where newSHA256 is the new sha256 of the embedded optimized image). It is renamed is to make clear it was optimized because this tool will make changes in the mapres used by the map file.

If failed to open source or target file, returns -1.

Available since: DDNet 15.5.4

map_replace_area

map_replace_area <from_map> <from_x> <from_y> <to_map> <to_x> <to_y> <width> <height> <output_map>

Replaces an area of one map with an area from another map.

Note: use game layer tiles as a reference for both coordinates and sizes.

map_replace_image

map_replace_image map_file1 map_file2 imagename image_file

Replaces the image imagename currently inside the map filename map_file1 with the image filepath image_file, and save into the map filename map_file2.map.

Please note:

  • Both map filenames must be relative to user default DDNet folder
  • New image filepath can be absolute, or relative to the current directory

map_resave

map_resave source_map.map destination_map.map

Reads the map source_map.map and writes it back to destination_map.map using the latest map format.

packetgen

packetgen

Generates and sends network packets to 127.0.0.1:8303 (localhost, in default server port) to test communication with a local server instance.

stun

stun address

Sends STUN request to server and checks response.

twping

twping server[:port]

Measures ping to a teeworlds server by requesting the server information. port defaults to 8303.

unicode_confusables

unicode_confusables string1 string2

Compares string1 with string2 and report if they are "confusable", i.e. if the characters are "equal" and could cause confusion. For this to work, the characters with accents or other things around them are considered the "confusable" with the base character. Therefore, aa and are confusable (á was considered as a), while aa and ab are not.

If they are confusable, it returns not_confusable=0, otherwise, returns not_confusable=1.

Available since: DDNet 10.3.5

New in DDNet 12.9: Unicode 12.0 support and the tool name was renamed from confusables to unicode_confusables.

uuid

uuid name

Prints uuid for the provided name.

The uuid system was implemented to be easily extended by independent authors without collisions, something that the old system – with increasing integers – did not allow. This works for engine and game messages, snapshot items and events.

Exits with error status 255 if name is not provided.

Available since: DDNet 10.6.1