12858
|
1 |
#include "gameconfig.h"
|
|
2 |
|
12859
|
3 |
GameConfig::GameConfig()
|
12863
|
4 |
: m_isPreview(true)
|
12859
|
5 |
{
|
12863
|
6 |
setPreview(m_isPreview);
|
12859
|
7 |
}
|
|
8 |
|
|
9 |
const char** GameConfig::argv() const
|
|
10 |
{
|
|
11 |
m_argv.resize(m_arguments.size());
|
|
12 |
|
|
13 |
for (int i = 0; i < m_arguments.size(); ++i)
|
|
14 |
m_argv[i] = m_arguments[i].data();
|
|
15 |
|
|
16 |
return m_argv.data();
|
|
17 |
}
|
|
18 |
|
|
19 |
int GameConfig::argc() const
|
12858
|
20 |
{
|
12859
|
21 |
return m_arguments.size();
|
|
22 |
}
|
12858
|
23 |
|
12860
|
24 |
const QList<QByteArray> GameConfig::config() const
|
|
25 |
{
|
|
26 |
QList<QByteArray> cfg = m_cfg;
|
|
27 |
cfg.append("\x01!");
|
|
28 |
return cfg;
|
|
29 |
}
|
|
30 |
|
12859
|
31 |
void GameConfig::clear()
|
|
32 |
{
|
|
33 |
m_arguments.clear();
|
|
34 |
m_cfg.clear();
|
12858
|
35 |
}
|
12859
|
36 |
|
|
37 |
void GameConfig::cmdSeed(const QByteArray& seed)
|
|
38 |
{
|
|
39 |
cfgAppend("eseed " + seed);
|
|
40 |
}
|
|
41 |
|
12863
|
42 |
void GameConfig::cmdTheme(const QByteArray& theme)
|
|
43 |
{
|
|
44 |
cfgAppend("e$theme " + theme);
|
|
45 |
}
|
|
46 |
|
12859
|
47 |
void GameConfig::cmdMapgen(int mapgen)
|
|
48 |
{
|
|
49 |
cfgAppend("e$mapgen " + QByteArray::number(mapgen));
|
|
50 |
}
|
|
51 |
|
12863
|
52 |
void GameConfig::cmdTeam(const Team& team)
|
|
53 |
{
|
|
54 |
cfgAppend("eaddteam <hash> " + team.color + " " + team.name);
|
|
55 |
|
|
56 |
for (const Hedgehog& h : team.hedgehogs()) {
|
|
57 |
cfgAppend("eaddhh " + QByteArray::number(h.level) + " " + QByteArray::number(h.hp) + " " + h.name);
|
|
58 |
cfgAppend("ehat " + h.hat);
|
|
59 |
}
|
|
60 |
cfgAppend("eammloadt 9391929422199121032235111001200000000211100101011111000102");
|
|
61 |
cfgAppend("eammprob 0405040541600655546554464776576666666155510101115411111114");
|
|
62 |
cfgAppend("eammdelay 0000000000000205500000040007004000000000220000000600020000");
|
|
63 |
cfgAppend("eammreinf 1311110312111111123114111111111111111211111111111111111111");
|
|
64 |
cfgAppend("eammstore");
|
|
65 |
}
|
|
66 |
|
|
67 |
bool GameConfig::isPreview() const
|
12861
|
68 |
{
|
12863
|
69 |
return m_isPreview;
|
|
70 |
}
|
|
71 |
|
|
72 |
void GameConfig::setPreview(bool isPreview)
|
|
73 |
{
|
|
74 |
m_isPreview = isPreview;
|
|
75 |
|
|
76 |
m_arguments.clear();
|
|
77 |
|
|
78 |
if (m_isPreview) {
|
|
79 |
m_arguments
|
|
80 |
<< ""
|
|
81 |
<< "--internal"
|
|
82 |
<< "--landpreview";
|
|
83 |
|
|
84 |
} else {
|
|
85 |
m_arguments
|
|
86 |
<< ""
|
|
87 |
<< "--internal"
|
|
88 |
<< "--nomusic";
|
|
89 |
}
|
12861
|
90 |
}
|
|
91 |
|
12859
|
92 |
void GameConfig::cfgAppend(const QByteArray& cmd)
|
|
93 |
{
|
|
94 |
quint8 len = cmd.size();
|
|
95 |
m_cfg.append(QByteArray::fromRawData(reinterpret_cast<const char*>(&len), 1) + cmd);
|
|
96 |
}
|