qmlfrontend/gameconfig.cpp
author unc0rr
Sun, 24 Dec 2017 16:56:22 +0100
branchqmlfrontend
changeset 12859 a03f245243b0
parent 12858 0c6fb706f747
child 12860 e33bcb9d5e9c
permissions -rw-r--r--
And more refactoring...
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12858
0c6fb706f747 More refactoring in attempt to move away from frontlib
unc0rr
parents:
diff changeset
     1
#include "gameconfig.h"
0c6fb706f747 More refactoring in attempt to move away from frontlib
unc0rr
parents:
diff changeset
     2
12859
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
     3
GameConfig::GameConfig()
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
     4
{
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
     5
    m_arguments
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
     6
        << ""
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
     7
        << "--internal"
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
     8
        << "--landpreview";
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
     9
}
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    10
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    11
const char** GameConfig::argv() const
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    12
{
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    13
    m_argv.resize(m_arguments.size());
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    14
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    15
    for (int i = 0; i < m_arguments.size(); ++i)
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    16
        m_argv[i] = m_arguments[i].data();
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    17
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    18
    return m_argv.data();
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    19
}
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    20
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    21
int GameConfig::argc() const
12858
0c6fb706f747 More refactoring in attempt to move away from frontlib
unc0rr
parents:
diff changeset
    22
{
12859
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    23
    return m_arguments.size();
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    24
}
12858
0c6fb706f747 More refactoring in attempt to move away from frontlib
unc0rr
parents:
diff changeset
    25
12859
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    26
void GameConfig::clear()
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    27
{
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    28
    m_arguments.clear();
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    29
    m_cfg.clear();
12858
0c6fb706f747 More refactoring in attempt to move away from frontlib
unc0rr
parents:
diff changeset
    30
}
12859
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    31
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    32
void GameConfig::cmdSeed(const QByteArray& seed)
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    33
{
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    34
    cfgAppend("eseed " + seed);
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    35
}
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    36
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    37
void GameConfig::cmdMapgen(int mapgen)
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    38
{
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    39
    cfgAppend("e$mapgen " + QByteArray::number(mapgen));
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    40
}
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    41
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    42
void GameConfig::cfgAppend(const QByteArray& cmd)
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    43
{
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    44
    quint8 len = cmd.size();
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    45
    m_cfg.append(QByteArray::fromRawData(reinterpret_cast<const char*>(&len), 1) + cmd);
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    46
}