qmlfrontend/gameconfig.cpp
author unc0rr
Mon, 25 Dec 2017 00:58:47 +0100
branchqmlfrontend
changeset 12860 e33bcb9d5e9c
parent 12859 a03f245243b0
child 12861 488782d9aba9
permissions -rw-r--r--
Preview rendering seems to work now
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
12860
e33bcb9d5e9c Preview rendering seems to work now
unc0rr
parents: 12859
diff changeset
    26
const QList<QByteArray> GameConfig::config() const
e33bcb9d5e9c Preview rendering seems to work now
unc0rr
parents: 12859
diff changeset
    27
{
e33bcb9d5e9c Preview rendering seems to work now
unc0rr
parents: 12859
diff changeset
    28
    QList<QByteArray> cfg = m_cfg;
e33bcb9d5e9c Preview rendering seems to work now
unc0rr
parents: 12859
diff changeset
    29
    cfg.append("\x01!");
e33bcb9d5e9c Preview rendering seems to work now
unc0rr
parents: 12859
diff changeset
    30
    return cfg;
e33bcb9d5e9c Preview rendering seems to work now
unc0rr
parents: 12859
diff changeset
    31
}
e33bcb9d5e9c Preview rendering seems to work now
unc0rr
parents: 12859
diff changeset
    32
12859
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    33
void GameConfig::clear()
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    34
{
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    35
    m_arguments.clear();
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    36
    m_cfg.clear();
12858
0c6fb706f747 More refactoring in attempt to move away from frontlib
unc0rr
parents:
diff changeset
    37
}
12859
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    38
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    39
void GameConfig::cmdSeed(const QByteArray& seed)
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    40
{
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    41
    cfgAppend("eseed " + seed);
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    42
}
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    43
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    44
void GameConfig::cmdMapgen(int mapgen)
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    45
{
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    46
    cfgAppend("e$mapgen " + QByteArray::number(mapgen));
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    47
}
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    48
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    49
void GameConfig::cfgAppend(const QByteArray& cmd)
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    50
{
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    51
    quint8 len = cmd.size();
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    52
    m_cfg.append(QByteArray::fromRawData(reinterpret_cast<const char*>(&len), 1) + cmd);
a03f245243b0 And more refactoring...
unc0rr
parents: 12858
diff changeset
    53
}