FANDOM



獨立伺服器是一個設計來用以長久執行饑荒聯機(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 ]

Command Line Options编辑

Command line options override settings.ini options.

Force the server to use a specific port

-port [1024 .. 65535]

Force the server to run at a specific tick rate

-tick [15 .. 60]

Force the maximum number of players allowed in the server.

-players [1 .. 64]

Enable a command line console input mechanism. Allows you to execute privileged lua directly in the server window.

-console

Force the server into lan mode. The server will not require token authentication, and will not appear in the server listings. Only users on the same network will be able to join.

-lan

Force the server to load save and settings data from an alternative directory. Note that this is the directory name, not the path. For example, a directory name of "DoNotStarveServerDirectory" would translate into a path of ~/.klei/DoNotStarveServerDirectory.

-conf_dir DoNotStarveServerDirectory

Setting the root directory of persistent storage. E.g. on Windows this defaults to your user documents folder / klei. This is used in conjunction with conf_dir to generate the path where files are stored.

-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 servers support mods now too, and can be automatically installed via dedicated_server_mods_setup.lua in the main mods directory. (Note: this file is currently missing from the build and has to be created manually. It should appear after the next update). This file is run on boot and will download any mods or collection of mods that are setup in the file. An example of this file would be.

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

The mods only update when the version changes on the Workshop, so server boot times should be reasonable and only pickup mod changes as they get posted to the Workshop. These mods will be downloaded and installed to your mod folder, but they aren't enabled by default.

To enable mods on dedicated servers, there are two ways. The first is to force enable the mods. To do this you will need to modify the file modsettings.lua to force enable the mods you desire. For example this would enable three mods from the workshop.

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

To ensure that clients will be able to download the corresponding mods from the Workshop, you must not change the mod directory names.

The second option is using a modoverrides.lua file. Dedicated servers can now enable mods and set mod configurations via a file in the configuration directory named 「modoverrides.lua」 (\Documents\Klei\DoNotStarveTogether\modoverrides.lua). An example of the contents of this file is

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

Note, dedicated servers (and normal clients) can override the mod config options to non-valid options using this method. In this example, 6 is not a normal option for the hunt_time in the Hunt game mode mod.

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.

您使用了广告屏蔽软件!


Wikia通过广告运营为用户提供免费的服务。我们对用户通过嵌入广告屏蔽软件访问网站进行了使用调整。

如果您使用了广告屏蔽软件,将无法使用我们的服务。请您移除广告屏蔽软件,以确保页面正常加载。