aboutsummaryrefslogtreecommitdiff
path: root/src/server/init.cc
blob: 31dca466fb4fbaa4acc3f43cc2eafc043c6c60ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "server/init.hh"

namespace server {

const shared::args_t& get_options() {
    static shared::args_t ret{
        {.name = "seed", .desc = "manually set the worldseed", .val = "S:"},
        {.name = "directory",
         .desc = "manually set the directory",
         .val = "d:"},
        {.name = "tickrate",
         .desc = "override the default tickrate",
         .val = "t:"},
        {.name = "distance",
         .desc = "limit the max chunk distance the server provides",
         .val = "D:"},
    };
    return ret;
}

bool parse_arg(const int& c, const char* const arg) {
    switch (c) {
    case 'S':
        server::state.seed =
            boost::lexical_cast<decltype(server::state.seed)>(arg);
        break;
    case 'd':
        server::state.directory =
            boost::lexical_cast<decltype(server::state.directory)>(arg);
        break;
    case 't':
        server::state.tickrate =
            boost::lexical_cast<decltype(server::state.tickrate)>(arg);
        break;
    case 'D':
        server::state.draw_distance =
            boost::lexical_cast<decltype(server::state.draw_distance)>(arg);
        break;
    default:
        return false;
    }
    return true;
}

} // namespace server