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...

#include "gameconfig.h"

GameConfig::GameConfig()
{
    m_arguments
        << ""
        << "--internal"
        << "--landpreview";
}

const char** GameConfig::argv() const
{
    m_argv.resize(m_arguments.size());

    for (int i = 0; i < m_arguments.size(); ++i)
        m_argv[i] = m_arguments[i].data();

    return m_argv.data();
}

int GameConfig::argc() const
{
    return m_arguments.size();
}

void GameConfig::clear()
{
    m_arguments.clear();
    m_cfg.clear();
}

void GameConfig::cmdSeed(const QByteArray& seed)
{
    cfgAppend("eseed " + seed);
}

void GameConfig::cmdMapgen(int mapgen)
{
    cfgAppend("e$mapgen " + QByteArray::number(mapgen));
}

void GameConfig::cfgAppend(const QByteArray& cmd)
{
    quint8 len = cmd.size();
    m_cfg.append(QByteArray::fromRawData(reinterpret_cast<const char*>(&len), 1) + cmd);
}