Jump to content

Extra tools/zh: Difference between revisions

From DDraceNetwork
Darkh (talk | contribs)
Created page with "* 如果提供的参数不正确会显示用法示例; * 如果在打开源文件<code>''src_map_file''</code> 时出错则会显示<code>failed to open source map</code> ; * 如果在打开目标文件<code>''dest_map_file''</code> 时出错则会显示<code>failed to open destination map</code> ; * 如果磁盘空间不足或有其他存储问题则会显示<code>error loading storage</code> ; * 如果在打开PNG图片时出错则会显示<code>failed to open..."
Darkh (talk | contribs)
No edit summary
 
(114 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<languages/>
<languages />
'''额外工具'''用于执行玩家游玩行为之外的其他任务,例如地图作者对地图进行优化,或是开发者进行测试和故障排除。不管是先添加它们的路径到PATH变量还是直接输入路径,这些工具都必须通过命令行(例如Windows的cmd界面或是Linux的Terminal终端)运行。
 
'''附加工具'''用于执行玩家游玩行为之外的其他任务,例如地图作者对地图进行优化,或是开发者进行测试和故障排除。不管是先添加它们的路径到PATH变量还是直接输入路径,这些工具都必须通过命令行(例如Windows的cmd界面或是Linux的Terminal终端)运行。


<span id="Getting_the_extra_tools"></span>
<span id="Getting_the_extra_tools"></span>
== 获取额外工具 ==
== 获取附加工具 ==


这些工具'''不'''会在DDNet游戏内或[https://ddnet.org/downloads/ 游戏下载页]中出现。制图相关工具可以在下载页面的Graphics Tools子页面找到不同平台的版本。
这些工具'''不'''会在DDNet游戏内或[https://ddnet.org/downloads/ 游戏下载页]中出现。制图相关工具可以在下载页面的Graphics Tools子页面找到不同平台的版本。


这些额外工具可以在[https://github.com/ddnet/ddnet DDNet源码]下的[https://github.com/ddnet/ddnet/tree/master/src/tools src/tools]路径内找到。
这些附加工具可以在[https://github.com/ddnet/ddnet DDNet源码]下的[https://github.com/ddnet/ddnet/tree/master/src/tools src/tools]路径内找到。


<span id="List_of_extra_tools"></span>
<span id="List_of_extra_tools"></span>
== 额外工具列表 ==
== 附加工具列表 ==


下面是这些工具的详细说明。
下面是这些工具的详细说明。


<span id="config_retrieve"></span>
=== config_retrieve ===
=== config_retrieve ===


Line 22: Line 24:
* 自DDNet 9.0版本后可用
* 自DDNet 9.0版本后可用


<span id="config_store"></span>
=== config_store ===
=== config_store ===


Line 32: Line 35:
* 自DDNet 9.0版本后可用
* 自DDNet 9.0版本后可用


<span id="crapnet"></span>
=== crapnet ===
=== crapnet ===


Line 38: Line 42:
用于测试客户端和服务器的本地连接和传送请求(ping)。掉包会显示<code>dropped packet</code>,而成功则显示<code>cfg = ''number''</code>,其中''number''取值为0到2。
用于测试客户端和服务器的本地连接和传送请求(ping)。掉包会显示<code>dropped packet</code>,而成功则显示<code>cfg = ''number''</code>,其中''number''取值为0到2。


<span id="demo_extract_chat"></span>
=== demo_extract_chat ===
示例:demo_extract_chat ''demo_file''
将回放demo文件中所有消息输出到控制台。
消息格式如下:
chat: *** 'nameless tee' entered and joined the game
chat: nameless tee: Hello!
broadcast: Welcome!
teamchat: brainless tee: Hello team!
whisper: -> nameless tee: Hi!
* 自DDNet 17.4版本后可用


<span id="dilate"></span>
=== dilate ===
=== dilate ===


Line 47: Line 67:
注意:这只对RGBA格式的图片生效。例如PNG文件可用而JPEG文件不可用。
注意:这只对RGBA格式的图片生效。例如PNG文件可用而JPEG文件不可用。


<span id="dummy_map"></span>
=== dummy_map ===
=== dummy_map ===


  示例:dummy_map
示例:dummy_map
 
创建一个空的分身小地图来启动服务器。更多信息请参阅[https://github.com/ddnet/ddnet/blob/a66379918832e5ad93332bbe0475394b156b5c24/src/engine/shared/network_server.cpp#L371 github]。
 
=== fake_server ===
 
示例:fake_server


为测试创建一个临时虚拟服务器。
创建一个仿制小地图来启动原生反作弊(<code>sv_vanilla_antispoof</code>)服务器。更多信息请参阅[https://github.com/ddnet/ddnet/blob/a66379918832e5ad93332bbe0475394b156b5c24/src/engine/shared/network_server.cpp#L371 github]


<span id="map_convert_07"></span>
=== map_convert_07 ===
=== map_convert_07 ===


  示例:map_convert_07 ''src_map_file'' ''dest_map_file''
  示例:map_convert_07 ''src_map_file'' ''dest_map_file''


对于那些只能兼容Teeworlds的6.x版本的地图文件<code>''src_map_file''</code> ,使用这一命令可以将文件转变为兼容7.x版本并保存为<code>''dest_map_file''</code> 。这一命令在不同情况下执行失败则会有不同回显:
对于那些'''只能'''兼容Teeworlds的6.x版本的地图文件<code>''src_map_file''</code> ,使用这一命令可以将文件转变为兼容7.x版本并保存为<code>''dest_map_file''</code> 。这一命令在不同情况下执行失败则会有不同回显:


* 如果提供的参数不正确会显示用法示例;
* 如果提供的参数不正确会显示用法示例;
Line 72: Line 88:
* 如果图片格式错误则会显示<code>invalid image format</code> 。
* 如果图片格式错误则会显示<code>invalid image format</code> 。


''自DDNet 12.9版本后可用''
* 自DDNet 12.9版本后可用
 
<span id="map_create_pixelart"></span>
=== 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]
 
从图片文件image.png中创建一幅可用作背景的像素画。
 
注1:使用目标图层的方块作为坐标(pos_x、pos_y)的参考,使用像素(pixel)作为尺寸大小。
 
注2:img_pixelsize参数指的是图片文件截取尺寸,单位为像素,将img_pixelsize设置为0将尝试匹配图片的最大截取范围。
 
注3:quad_pixelsize参数指的是图片作为背景时的占用地图的尺寸,单位是像素,设置quad_pixelsize为0时默认使用与img_pixelsize相同的值。
 
注4:如果图片文件image.png没有完整的像素网格,将出现难以预料的后果,尝试手动调整img_pixelsize的大小可能可以解决问题。
 
可选参数optimize:是否自动减少重复或重叠的背景图片(默认为1,即启用)。
 
可选参数centralize:将所有图片的中心移动到同一点(默认为0,即禁用)。


<span id="map_diff"></span>
=== map_diff ===
=== map_diff ===


  示例:map_diff ''map_file1'' ''map_file2''
  示例:map_diff ''map_file1'' ''map_file2''


<div lang="en" dir="ltr" class="mw-content-ltr">
对比两个地图文件 ''map_file1'' 与 ''map_file2'' 并根据对比结果输出报告:
Compares two map files, reporting one of the follow:
* 地图相同则不显示任何消息 ;
* no diff output, meaning the maps are the same
* 如果两个地图的图层数不一样则显示<code>different layer numbers</code>
* <code>different layer numbers</code>, if one map has more layers than another
* 如果层数一致但是层的类型不完全一样则显示<code>different tile layers</code>
* <code>different tile layers</code>, if the number of layers is the same, but at least one layer is different
* 如果层的数量和类型都一致,则输出具体差异,例如指标和旗帜位置的不同。
* lastly, the index and flags positions that differ.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
当地图之间没有差异时返回0,否则返回1。
If there is no difference between maps, returns 0; otherwise, returns 1.
</div>


<span id="map_extract"></span>
=== map_extract ===
=== map_extract ===


  示例:map_extract ''map_file'' [''directory'']
  示例:map_extract ''map_file'' [''directory'']


<div lang="en" dir="ltr" class="mw-content-ltr">
提取地图文件''map_file'' 中的目录到路径参数''directory'',如果没有设置参数''directory'' 则会提取到当前路径。
Extracts contents from ''map_file'' into the ''directory''. If optional argument ''directory'' is not provided, extracts to the current directory.
 
</div>
<span id="map_find_env"></span>
=== map_find_env ===
 
示例:map_find_env <input_map> <env_number>
 
在背景中寻找特定的包络线并输出它们的序号和位置信息到控制台。
 
注意:返回的坐标是所在图层的相对坐标。


<span id="map_optimize"></span>
=== map_optimize ===
=== map_optimize ===


  示例:map_optimize ''source_map_filepath'' [''dest_map_filepath'']
  示例:map_optimize ''source_map_filepath'' [''dest_map_filepath'']


<div lang="en" dir="ltr" class="mw-content-ltr">
优化地图文件<code>''source_map_filepath''</code> (参见[https://github.com/ddnet/ddnet/pull/3201 工作原理(how it works]),然后将输出保存到<code>''dest_map_filepath''</code> 。如果没有设置参数<code>''dest_map_filepath''</code> 则将默认输出保存到路径文件<code>out/''source_map_filename''.map</code>
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.
 
</div>
注意优化后地图中嵌入的图片文件名会从<code>''originalname''</code> 改为<code>''originalname''_cut_''newSHA256''</code> (此处<code>''newSHA256''</code> 是嵌入地图的图片优化时采用的sha256算法)。这一重命名旨在提醒使用者:地图文件中使用的mapres '''会'''在优化时被更改。
 
如果打开源文件或者目标文件出错将返回-1。
 
* 自DDNet 15.5.4版本后可用
 
<span id="map_replace_area"></span>
=== map_replace_area ===


<div lang="en" dir="ltr" class="mw-content-ltr">
示例:map_replace_area <from_map> <from_x> <from_y> <to_map> <to_x> <to_y> <width> <height> <output_map>
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.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
将靶地图的一个区域的内容替换为源地图的一个区域。参数解释如下:
If failed to open source or target file, returns -1.
<from_map>源地图;
</div>
<from_x>区域左上角在源地图中的x坐标;
<from_y>区域左上角在源地图中的y坐标;
<to_map>靶地图;
<to_x>被替换区域的左上角在靶地图中的x坐标;
<to_y>被替换区域的左上角在靶地图中的x坐标;
<width>区域宽度;
<height>区域高度;
<output_map>将结果输出为此地图文件。


<div lang="en" dir="ltr" class="mw-content-ltr">
注意:用游戏层方块作为坐标和尺寸的参照。
''Available since:'' DDNet 15.5.4
</div>


<span id="map_replace_image"></span>
=== map_replace_image ===
=== map_replace_image ===


  示例:map_replace_image ''map_file1'' ''map_file2'' ''imagename'' ''image_file''
  示例:map_replace_image ''map_file1'' ''map_file2'' ''imagename'' ''image_file''


<div lang="en" dir="ltr" class="mw-content-ltr">
使用图片路径''image_file'' 下的文件替换当前存在于地图文件''map_file1'' 中的图片''imagename'' ,然后另存为地图文件''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''.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
注意:
Please note:
* 两个地图文件都必须在使用者的默认DDNet文件夹目录下;
* Both map filenames must be relative to user default DDNet folder
* 新的图片路径可以是绝对路径也可以是当前目录下的相对路径。
* New image filepath can be absolute, or relative to the current directory
</div>


<span id="map_resave"></span>
=== map_resave ===
=== map_resave ===


  示例:map_resave ''map_file'' ''image_file''
  示例:map_resave ''map_file'' ''image_file''


<div lang="en" dir="ltr" class="mw-content-ltr">
用指定的图片文件''image_file'' 更新地图文件''map_file.map''
Updates the map file ''map_file.map'' with the provided file ''image_file''.
</div>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
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.
</div>


<span id="packetgen"></span>
=== packetgen ===
=== packetgen ===


  示例:packetgen
  示例:packetgen


<div lang="en" dir="ltr" class="mw-content-ltr">
生成并发送网络包到端口127.0.0.1:8303(默认的本地服务器端口),用以测试和本地服务器的联络。
Generates and sends network packets to 127.0.0.1:8303 (localhost, in default server port) to test communication with a local server instance.
 
</div>
<span id="stun"></span>
=== stun ===
 
示例:stun ''address''
 
向服务器发送[[wikipedia:STUN|STUN]]请求并检查响应。
 
<span id="twping"></span>
=== twping ===
 
示例:twping ''server''[:''port'']
 
通关请求服务器 ''server'' 信息测试服务器的延迟。端口参数 ''port'' 默认为8303。


<span id="unicode_confusables"></span>
=== unicode_confusables ===
=== unicode_confusables ===


  示例:unicode_confusables ''string1'' ''string2''
  示例:unicode_confusables ''string1'' ''string2''


<div lang="en" dir="ltr" class="mw-content-ltr">
对比两串字符串''string1'' ''string2'' 并报告它们是否容易混淆。例如:如果字母本身相同而差异在于变音符号或者各种角标,例如''aa'' ''aá'' 中的''a'' 有可能与''á'' 混淆。
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.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
如果容易混淆则会返回<code>not_confusable=0</code> ,否则返回<code>not_confusable=1</code>
If they are confusable, it returns <code>not_confusable=0</code>, otherwise, returns <code>not_confusable=1</code>.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
* 自DDNet 10.3.5版本后可用
''Available since: DDNet version 10.3.5''
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
DDNet 12.9版本后更新内容:获得了Unicode 12.0支持,并且工具名称''confusables'' 改为''unicode_confusables''
''New in DDNet version 12.9:'' Unicode 12.0 support and the tool name was renamed from ''confusables'' to ''unicode_confusables''.
</div>


<span id="uuid"></span>
=== uuid ===
=== uuid ===


  示例:uuid ''name''
  示例:uuid ''name''


<div lang="en" dir="ltr" class="mw-content-ltr">
显示指定的''name'' 的uuid。
Prints uuid for the provided ''name''.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
唯一编号识别系统(uuid)旨在独立作者之间无冲突地创作内容,例如说两个作者制作了同名的文件,则系统会通过赋予文件相互不同的编号(id)将它们区分开,这样在提及文件时不会将它们混淆,明显比旧系统中混乱的事物命名要方便合理。此系统可以在引擎、游戏信息、快照和大事件上运作。
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.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
如果没有设置参数''name'' 则会返回错误代码255。
Exits with error status 255 if ''name'' is not provided.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
* 自DDNet 10.6.1版本后可用
''Available since: DDNet 10.6.1''
</div>

Latest revision as of 10:20, 18 January 2025

附加工具用于执行玩家游玩行为之外的其他任务,例如地图作者对地图进行优化,或是开发者进行测试和故障排除。不管是先添加它们的路径到PATH变量还是直接输入路径,这些工具都必须通过命令行(例如Windows的cmd界面或是Linux的Terminal终端)运行。

获取附加工具

这些工具会在DDNet游戏内或游戏下载页中出现。制图相关工具可以在下载页面的Graphics Tools子页面找到不同平台的版本。

这些附加工具可以在DDNet源码下的src/tools路径内找到。

附加工具列表

下面是这些工具的详细说明。

config_retrieve

示例:config_retrieve map_file

检索DDNet地图文件map_file内置的参数,然后写入保存到与地图名字相同的一个配置文件。例如对地图文件Kobra 4.map使用会将它的参数写入到Kobra 4.cfg。

  • 自DDNet 9.0版本后可用

config_store

示例:config_store map_file

从配置文件将参数写入保存到地图文件map_file,如果配置文件和地图文件名字不同或者不在同一路径下将会操作失败。

如果两个文件的参数原本就一致,则不会执行操作并显示configs coincide, not updating map

  • 自DDNet 9.0版本后可用

crapnet

示例:crapnet

用于测试客户端和服务器的本地连接和传送请求(ping)。掉包会显示dropped packet,而成功则显示cfg = number,其中number取值为0到2。

demo_extract_chat

示例:demo_extract_chat demo_file

将回放demo文件中所有消息输出到控制台。

消息格式如下:

chat: *** 'nameless tee' entered and joined the game
chat: nameless tee: Hello!
broadcast: Welcome!
teamchat: brainless tee: Hello team!
whisper: -> nameless tee: Hi!
  • 自DDNet 17.4版本后可用

dilate

示例:dilate image_file1 [image_file2 ... ]

这个图形工具对地图作者比较友好。它可以为游戏内图片描边和锐化,防止混淆不同地图结构。更多信息请查阅Edge padding

注意:这只对RGBA格式的图片生效。例如PNG文件可用而JPEG文件不可用。

dummy_map

示例:dummy_map

创建一个空的仿制小地图来启动原生反作弊(sv_vanilla_antispoof)服务器。更多信息请参阅github

map_convert_07

示例:map_convert_07 src_map_file dest_map_file

对于那些只能兼容Teeworlds的6.x版本的地图文件src_map_file ,使用这一命令可以将文件转变为兼容7.x版本并保存为dest_map_file 。这一命令在不同情况下执行失败则会有不同回显:

  • 如果提供的参数不正确会显示用法示例;
  • 如果在打开源文件src_map_file 时出错则会显示failed to open source map
  • 如果在打开目标文件dest_map_file 时出错则会显示failed to open destination map
  • 如果磁盘空间不足或有其他存储问题则会显示error loading storage
  • 如果在打开PNG图片时出错则会显示failed to open image file
  • 如果图片格式错误则会显示invalid image format
  • 自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]

从图片文件image.png中创建一幅可用作背景的像素画。

注1:使用目标图层的方块作为坐标(pos_x、pos_y)的参考,使用像素(pixel)作为尺寸大小。

注2:img_pixelsize参数指的是图片文件截取尺寸,单位为像素,将img_pixelsize设置为0将尝试匹配图片的最大截取范围。

注3:quad_pixelsize参数指的是图片作为背景时的占用地图的尺寸,单位是像素,设置quad_pixelsize为0时默认使用与img_pixelsize相同的值。

注4:如果图片文件image.png没有完整的像素网格,将出现难以预料的后果,尝试手动调整img_pixelsize的大小可能可以解决问题。

可选参数optimize:是否自动减少重复或重叠的背景图片(默认为1,即启用)。

可选参数centralize:将所有图片的中心移动到同一点(默认为0,即禁用)。

map_diff

示例:map_diff map_file1 map_file2

对比两个地图文件 map_file1map_file2 并根据对比结果输出报告:

  • 地图相同则不显示任何消息 ;
  • 如果两个地图的图层数不一样则显示different layer numbers
  • 如果层数一致但是层的类型不完全一样则显示different tile layers
  • 如果层的数量和类型都一致,则输出具体差异,例如指标和旗帜位置的不同。

当地图之间没有差异时返回0,否则返回1。

map_extract

示例:map_extract map_file [directory]

提取地图文件map_file 中的目录到路径参数directory,如果没有设置参数directory 则会提取到当前路径。

map_find_env

示例:map_find_env <input_map> <env_number>

在背景中寻找特定的包络线并输出它们的序号和位置信息到控制台。

注意:返回的坐标是所在图层的相对坐标。

map_optimize

示例:map_optimize source_map_filepath [dest_map_filepath]

优化地图文件source_map_filepath (参见工作原理(how it works)),然后将输出保存到dest_map_filepath 。如果没有设置参数dest_map_filepath 则将默认输出保存到路径文件out/source_map_filename.map

注意优化后地图中嵌入的图片文件名会从originalname 改为originalname_cut_newSHA256 (此处newSHA256 是嵌入地图的图片优化时采用的sha256算法)。这一重命名旨在提醒使用者:地图文件中使用的mapres 在优化时被更改。

如果打开源文件或者目标文件出错将返回-1。

  • 自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>

将靶地图的一个区域的内容替换为源地图的一个区域。参数解释如下:

<from_map>源地图;
<from_x>区域左上角在源地图中的x坐标;
<from_y>区域左上角在源地图中的y坐标;
<to_map>靶地图;
<to_x>被替换区域的左上角在靶地图中的x坐标;
<to_y>被替换区域的左上角在靶地图中的x坐标;
<width>区域宽度;
<height>区域高度;
<output_map>将结果输出为此地图文件。

注意:用游戏层方块作为坐标和尺寸的参照。

map_replace_image

示例:map_replace_image map_file1 map_file2 imagename image_file

使用图片路径image_file 下的文件替换当前存在于地图文件map_file1 中的图片imagename ,然后另存为地图文件map_file2.map

注意:

  • 两个地图文件都必须在使用者的默认DDNet文件夹目录下;
  • 新的图片路径可以是绝对路径也可以是当前目录下的相对路径。

map_resave

示例:map_resave map_file image_file

用指定的图片文件image_file 更新地图文件map_file.map

packetgen

示例:packetgen

生成并发送网络包到端口127.0.0.1:8303(默认的本地服务器端口),用以测试和本地服务器的联络。

stun

示例:stun address

向服务器发送STUN请求并检查响应。

twping

示例:twping server[:port]

通关请求服务器 server 信息测试服务器的延迟。端口参数 port 默认为8303。

unicode_confusables

示例:unicode_confusables string1 string2

对比两串字符串string1string2 并报告它们是否容易混淆。例如:如果字母本身相同而差异在于变音符号或者各种角标,例如aa 中的a 有可能与á 混淆。

如果容易混淆则会返回not_confusable=0 ,否则返回not_confusable=1

  • 自DDNet 10.3.5版本后可用

DDNet 12.9版本后更新内容:获得了Unicode 12.0支持,并且工具名称confusables 改为unicode_confusables

uuid

示例:uuid name

显示指定的name 的uuid。

唯一编号识别系统(uuid)旨在独立作者之间无冲突地创作内容,例如说两个作者制作了同名的文件,则系统会通过赋予文件相互不同的编号(id)将它们区分开,这样在提及文件时不会将它们混淆,明显比旧系统中混乱的事物命名要方便合理。此系统可以在引擎、游戏信息、快照和大事件上运作。

如果没有设置参数name 则会返回错误代码255。

  • 自DDNet 10.6.1版本后可用