Don't Starve 中文維基
Advertisement
Don't Starve 中文維基


獨立伺服器是一個設計來用以長久執行饑荒聯機(DST,Don't Starve Together)的最佳化版本,不含任何圖形化介面所需的電腦資源消耗成本。使用者可以透過自行架設伺服器或從遊戲伺服器提供商承租伺服器,來成為饑荒聯機的遊戲伺服器管理員(GSAs,Game Server Administrators)。



伺服器可透過 Windows 和 Linux 作業系統上的 Steam 和 SteamCMD 平台取得。



透過一般個人電腦 Steam 平台架設獨立伺服器相關問題請見簡易獨立伺服器架設指南,本文件將介紹非個人電腦伺服器架設方式。


伺服器基本需求

伺服器管理員(GSAs)必須擁有饑荒聯機帳號才能架設線上獨立伺服器,單一帳號即可架設多個獨立伺服器。

獨立伺服器沒有使用DST遊戲內建立伺服器的路由穿透技術,伺服器必須為遊戲客戶端開放一個合適的端口,伺服器默認通訊方式:UDP協議,端口号:10999

運行一個穩定的伺服器,你的系統必須滿足以下條件:

  • 網路(上傳)=8K Bytes / 玩家 / 秒
  • 記憶體(RAM)=約 65M Bytes / 玩家
  • 處理器(CPU)=N/A
  • VCRedist_2008 (x86)

安裝

目前 Klei 提供兩種方法下載伺服器:

透過 SteamCMD 下載

關於 SteamCMD 的更多資訊可以請至: https://developer.valvesoftware.com/wiki/SteamCMD

Windows系統:

login anonymous
force_install_dir C:\path\to\directory
app_update 343050 validate

Linux (Debian)系统:

sudo dpkg—add-architecture i386 # If running a 64bit OS
sudo apt-get update
sudo apt-get install lib32gcc1    # If running a 64bit OS
sudo apt-get install lib32stdc++6 # If running a 64bit OS
sudo apt-get install libgcc1      # If running a 32bit OS
sudo apt-get install libcurl4-gnutls-dev:i386
sudo useradd -m steam
chmod a+rw `tty`  # Note those are backticks, not single quotes
sudo su - steam
mkdir ~/steamcmd
cd ~/steamcmd
wget http://media.steampowered.com/installer/steamcmd_linux.tar.gz
tar -xvzf steamcmd_linux.tar.gz
./steamcmd.sh
login anonymous
force_install_dir /home/steam/steamapps/DST (or whatever absolute path you want)
app_update 343050 validate
quit
cd /home/steam/steamapps/DST/bin/
screen -S "DST Server" ./dontstarve_dedicated_server_nullrenderer

/!\ 如果你的系统是debian 7 / Debian Wheezy, 你会因为libc的版本问题不能运行. 错误提示如下 :

./dontstarve_dedicated_server_nullrenderer: /lib/i386-linux-gnu/i686/cmov/libc.so.6: version `GLIBC_2.15' not found (required by ./dontstarve_dedicated_server_nullrenderer)

下面是一种解决方法 (using the git repo https://github.com/dgibbs64/linuxgameservers/tree/master/Insurgency/dependencies )

mkdir ~/dst_lib && cd ~/dst_lib
wget https://github.com/dgibbs64/linuxgameservers/raw/master/Insurgency/dependencies/libc.so.6
wget https://github.com/dgibbs64/linuxgameservers/raw/master/Insurgency/dependencies/libpthread.so.0
wget https://github.com/dgibbs64/linuxgameservers/raw/master/Insurgency/dependencies/librt.so.1

在服务器上运行 :

cd /home/steam/steamapps/DST/bin/
screen -S "DST Server" bash -c 'LD_LIBRARY_PATH=~/dst_lib ./dontstarve_dedicated_server_nullrenderer'

服务器就开始运行,然后你按 CTRL-A D将它转入后台. 如果你要重新将此程序转入前台,请输入:

screen -x DST

通过Steam下载 (只适用于Windows系统和安装了桌面的Linux系统):

如果你拥有Don’t Starve Together, 你可以在你库中的工具标签中下载服务器程序.

更新服务器(译者注:以下为linux命令)

创建更新脚本,你必须停止服务器输入下列命令:

$ vim /home/steam/steamcmd/update.sh

把下列命令添加进去,如果你的游戏目录与命令中的不符需在命令里一同更改:

#!/bin/sh
./steamcmd.sh +@ShutdownOnFailedCommand 1 +@NoPromptForPassword 1 +login anonymous +force_install_dir /home/steam/steamapps/DST +app_update 343050 validate +quit

给脚本加可执行权限:

$ cd /home/steam/steamcmd
$ chmod +x update.sh

当你需要更新服务器程序时,输入下列命令 (当处于 /home/steam/steamcmd/目录下时):

$ ./update.sh

服务器的验证文件(Token)

为了运行公共的服务器,GSA需要一个"server token"文件,这个文件提供了饥荒的所有权,并且允许Klei公司改善那些违反了条款的服务器。

为了生成token文件,要做下列事:

运行饥荒联机版游戏,点击多人游戏.

按下 (~) (or ù on Azerty keyboards)来打开开发者控制台,并输入:

TheNet:GenerateServerToken()

这条命令会生成 token 文件,名字为 server_token.txt。这个文件的目录在: 

On Windows:

/My Documents/Klei/DoNotStarveTogether /server_token.txt

On Linux:

 ~/.klei/DoNotStarveTogether/server_token.txt

把token文件加入到配置目录下,以便于自动认证信息。 

不要把文字在不同的机器上直接复制粘贴。移动整个文件!!! 

If the file contains a carriage return or line ending at the file, you will receive an authentication error.

运行

Windows:

dontstarve_dedicated_server_nullrenderer.exe [-conf_dir <AlternativeDirectory>]

Linux:

./dontstarve_dedicated_server_nullrenderer [-conf_dir <AlternativeDirectory>]

请注意linux必须改变为正确的路径,以让服务器正确执行。

配置

配置服务器的主要方法就是通过修改settings.ini文件。

On Windows:

Documents/Klei/DoNotStarveTogether/Settings.ini

On Linux:

~/.klei/DoNotStarveTogether/settings.ini

设置被划分为不同的類,请确认在对应的類下面进行修改:

[network]

default_server_name = Your unique server name
default_server_description = A very nice server description
server_port = 10999
server_password = password
max_players = 1 .. 64
pvp = true | false
game_mode = endless | survival | wilderness

快照(snapshots)允许GSA回滚到之前的状态, 这个新特性可能导致一些服务器发生一些问题。 我在大多数服务器中禁用此选项。

 enable_snapshots = [true | false]

自动保存(auto saver)在每天开始时备份存档,如果服务器down机后会从次存档开始。

 enable_autosaver = [true | false]

自动保存(auto saver)在每天开始时备份存档,如果服务器down机后会从次存档开始。 

Tick rate 决定服务器的质量。 一个更高的 tick rate 会消耗更多的带宽和CPU,但是游戏会更流畅。 

tick_rate = 30 [ 10 | 15 | 30 | 60 ]

定义了服务器应该等待客户端进入的毫秒数。

connection_timeout = 8000

Which save slot should the dedicated server load

server_save_slot = 1..5

当管理员不在时,允许投票踢出破坏游戏的玩家。 

enable_vote_kick = [true | false]

当服务器无人时,暂停游戏。这个对于私人服务器很有用,比如想从上次离开时恢复游戏。默认为 false。 

pause_when_empty = [ true | false ]

[account]

只启动局域网服务器:

dedicated_lan_server = [ true | false ]

命令行选项:

命令行选项覆盖设置. ini选项

强制服务器使用特定端口

-port [1024 .. 65535]

强制服务器以特定的滴答速率运行

-tick [15 .. 60]

强制服务器中允许的最大播放机数

-players [1 .. 64]

启用命令行控制台输入机制。允许您直接在服务器窗口中执行特权Lua.

-console

强制服务器进入局域网模式。服务器将不需要令牌身份验证,也不会出现在服务器列表中。只有同一网络上的用户才能加入.

-lan

强制服务器从备用目录加载保存和设置数据。请注意,这是目录名称,而不是路径。例如,“DoNotStarveServerDirectory”的目录名将转换为~/。克莱/多诺塔尔维斯服务器公司.

-conf_dir DoNotStarveServerDirectory

设置永久存储的根目录。例如,在Windows上,这默认为用户文档文件夹/ klei。它与conf _ dir结合使用,以生成存储文件的路径。

-persistent_storage_root <AltPersistentStorageRoot>

Multiple Servers on the Same Machine

If you wish to run multiple servers on the same machine, or have your server co-exist with the client, you will want to launch your server with an alternative configuration directory using the -conf_dir command line parameter.

To use an alternative configuration directory, you can launch the server (or client) with this command line argument (on Steam you can do this under Properties -> Set Launch Options):

-conf_dir DoNotStarveServerDirectory

This would change your configuration directory to "Documents/Klei/DoNotStarveServerDirectory/" (or "~/.klei/DoNotStarveServerDirectory" on Linux). You will then have a unique set of save slots, log.txt and settings.ini files.

自定义地图内容

To generate a custom map with a dedicated server, you have to create a lua file in your configuration directory named "worldgenoverride.lua". This file should return a table containing a key "override_enabled" assigned to true or false, and other keys containing tables of settings. An example of this is:

return {
	override_enabled = true,
	misc = { season="shortboth", world_size="huge", season_start="summer" },
	resources = { flint="never", grass="never", sapling="never", trees="never" }
}

Here is the table of options and their potential settings

animals={ --options are "never", "rare", "default", "often", "always"
	alternatehunt="default",
	angrybees="default",
	beefalo="default",
	beefaloheat="default",
	bees="default",
	birds="default",
	butterfly="default",
	frogs="default",
	hunt="default",
	penguins="default",
	perd="default",
	pigs="default",
	rabbits="default",
	tallbirds="default" 
},
misc={
	boons="default", --options are "never", "rare", "default", "often", "always"
	branching="default", --options are "never", "least", "default", "most"
	day="default", --options are "onlyday", "onlydusk", "onlynight", "default", "longday", "longdusk", "longnight"
	lightning="default", --options are "never", "rare", "default", "often", "always"
	loop="default", --options are "never", "default", "always"
	season="default", --options are "onlysummer", "onlywinter", "default", "longsummer", "longwinter", "longboth", "shortboth"
	season_start="summer", --options are "winter", "summer"
	touchstone="default", --options are "never", "rare", "default", "often", "always"
	weather="default", --options are "never", "rare", "default", "often", "always"
	world_size="default"—options are "default", "medium", "large", "huge"
},
monsters={ --options are "never", "rare", "default", "often", "always"
	chess="default",
	deerclops="default",
	hounds="default",
	krampus="default",
	liefs="default",
	lureplants="default",
	merm="default",
	spiders="default",
	tentacles="default",
	walrus="default" 
},
resources={ --options are "never", "rare", "default", "often", "always"
	flint="default",
	flowers="default",
	grass="default",
	marshbush="default",
	meteorshowers="default",
	meteorspawner="default",
	reeds="default",
	rock="default",
	rocks="default",
	sapling="default",
	trees="default" 
},
unprepared={ --options are "never", "rare", "default", "often", "always"
	berrybush="default",
	carrot="default",
	mushroom="default"
}

To customize the world from the Don't Starve Together graphical client for your dedicated server, you can follow the following steps. This is the legacy method.

Creating the Map

To create a custom map for a dedicated server, launch the Don't Starve Together client and select the option to Host Server on the server selection screen. Select a New Server save slot on the left side, noting the slot number (1 through 5, 1 on the top). If you have no New Server save slots, you must delete a server first. Once you have selected a slot, select the option to Edit World on the right.

On the Edit World options screen, select the world options for the new world you wish to run as a dedicated server. It is not necessary to save your settings as a preset, though you may do so if you wish to reuse the settings later. When finished, select the option to Apply the settings.

Back on the server creation screen, enter a world name and description. This is required, but note that these settings are overridden in the persistent server's settings.ini file, so enter any legal values. The server will briefly appear in Klei's server selection screen, so please do not choose a vulgar or obscene name. Once ready, select the Create Server option on the left.

You will then see the Generating World screen while the map is generated, and next be placed on the character selection screen. At this point, the map is generated and there is no need to actually play on it, so select the option to Disconnect and confirm the option to shut down the server (Do it!) when prompted. You may now exit the Don't Starve Together graphical client.

In your Don't Starve Together directory, which is Documents\Klei\DoNotStarveTogether\save on Windows, or ~/.klei/DoNotStarveTogether/save on Linux, there will now be a file named survival_<slot #>, where <slot #> is the save slot number noted above (for example, survival_2 for the second save slot).

Using your Custom Map on the Dedicated Server

There are several files in addition to the map that must be created or modified for the dedicated server to launch correctly. The easiest way to ensure that everything is appropriately set up is to first modify the settings.ini file to ensure that the save slot is set correctly, let the dedicated server generate a map, and then overwrite the map and restart the server.

In settings.ini, ensure that the server_save_slot parameter in the [Network] section matches up with the save slot number in the name of the world file. For example, if you are using survival_2, you should have this in your settings.ini file:

[Network]
server_save_slot = 2

Launch the Don't Starve Together dedicated server as you normally would, and once the server is running, stop it. In your configuration directory there should now be a save subdirectory that contains several file, including a survival_<slot #> file, where <slot #> is the slot number configured in settings.ini.

Copy the survival_<slot #> file to your dedicated server configuration directory overwriting the new generated file, renaming it if necessary, then relaunch the server. The dedicated server should now load your custom map.

If your custom configuration map doesn't display correctly in "View World", copy the saveindex file to your dedicated server configuration directory in addition to survival_<slot #> file as well, both files are in the same directory.

Mods

专用服务器现在也支持模组了,可以通过主目录的 `dedicated_server_mods_setup.lua` 脚本自动安装模组。(注意:这个文件默认不存在,需要手动创建,会在下次更新后出现)。该文件在启动的时候运行,并下载任何在该文件中设置的模组或者模组集。下面是一个文件示例:

ServerModSetup("345692228")
ServerModSetup("346968521")
ServerModSetup("352373173")
ServerModCollectionSetup("379114180")


只有当创意工坊上的 mod (模组)版本发生变化时,才会自动更新模组,因此,服务器的启动时间应该是有意义的——启动时间应该选在模组更新到创意工坊后。这些 mods 都将被下载并自动安装到 mods 目录下。但是,默认情况下并没有开启。

为了在专用服务器上启用 mods,通常有两种方法。第一种是强制使用 mods。你可以通过修改 `modsettings.lua` 来强制启动你想用的模组。以下样例讲启用来自创意工坊的三个 mods.

ForceEnableMod("workshop-345692228")
ForceEnableMod("workshop-346968521")
ForceEnableMod("workshop-352373173")


为了确保客户端可以从创意工坊上下载到对应的 mods,你不能修改 mod 目录名称。

第二种可选方案是使用 `modoverrides.lua` 文件。专用服务器现在可以通过在配置文件夹 (\Documents\Klei\DoNotStarveTogether\modoverrides.lua)下名为 `modoverrides.lua` 的文件启用 mods 并设置模组。该文件内容的示例如下:

return {
    ["workshop-350811795"] = { enabled = true },
    ["workshop-387028143"] = { enabled = true },
    ["workshop-361336115"] = { enabled = true,
        configuration_options =
        {
            hunt_time = 6,
        }
    },
    ["workshop-336882447"] = { enabled = true }
}


注意,专用服务器(和普通客户端)可以通过使用本方法将模组配置选项覆盖为非有效选项。比如在上例中,6 在狩猎模式模组中,不是正常的狩猎时间。

Administration

Dedicated servers can be remotely administered through the game client.   

The user who generated the server token is automatically granted administrator privileges.

An administrator has the ability to kick and ban users in the game, as well as to execute arbitrary lua on the server.    

WARNING: Only grant administrator rights to those who you would trust with full access to your server / machine.  We may add a moderator mode with reduced powers in the future.  

If you wish to provide administrator to additional users, you need to add an adminlist.txt file to your save directory:

On Windows:

Documents/Klei/DoNotStarveTogether/Save/

On Linux:

~/.klei/DoNotStarveTogether/Save/

In this directory add the user identifiers for the users you wish to grant admin to.    List the KU_’s one per line.

As an admin, you may issue a remote command to your server by doing the following:

  • connect to the world through the game client
  • open the developer console (~)
  • press left CTRL to enter remote execution mode (REMOTE: appears to the left)
  • The command you enter will be executed on the server, assuming you have sufficient administrator rights
c_reset(true) - Deletes the current world and regenerates a new one.   Pass false to reload the current world/
c_shutdown(true) - Saves and terminates the server application.  Pass false to skip saving the world.
c_spawn(“prefab name”) - Spawn something at the mouse position.
c_give(“item name”) - Give an item to you.

FAQ

Is it possible to run my dedicated server in LAN mode?

Yes,  LAN mode can be configured in settings.ini by adding this line under the [account] heading:

dedicated_lan_server = true

Please remember LAN servers do not appear in the online server listings.

Is it possible to host multiple servers on a single (powerful) machine?

Yes, in order to host multiple servers you will want to have multiple configurations.

You can launch a server with a different configuration directory by passing in this command line option:  

 -conf_dir <NewDirectoryName>

For example, if you enter "-conf_dir MyDedi" then it will use the folder "Documents/Klei/MyDedi" for all saving, loading, and configuration that is normally stored in "Documents/Klei/DoNotStarveTogether". === Which save slot does the dedicated server use?''''=== By default, 1. You can override the slot through the settings.ini option:

[network]
server_save_slot = [1..5]

Troubleshooting

  • If you ran the dedicated server before you put a token in the settings.ini you may need to delete your world data.  Shutdown the server or client,

In C:\Users\Mark\Documents\Klei\DoNotStarveTogether\save\ delete survival_1.   When you restart a new world will be generated

  • If your server is running correctly, but you still can’t see it.  Confirm it’s listing here:

===== http://my.jacklul.com/dstservers/ You will have to manually update the listing at the bottom of the page ===== If it’s still not visible from inside the game client, it’s because the client can’t ping your server.  Did you make sure to forward UDP traffic on port 10999 to your machine

If you get the error Account Failed (6): "E_EXPIRED_TOKEN" you’ll want to verify that you saved the settings.ini file with the server token after you closed the game client, or your change will get overwritten. Also, make sure that there are no extra characters at the end of the file, even invisible ones.

Advertisement