author | unc0rr |
Mon, 13 Apr 2009 09:27:21 +0000 | |
changeset 1978 | 8ab9949c8775 |
parent 1797 | fedd8649fdd9 |
child 2948 | 3f21a9dc93d0 |
permissions | -rw-r--r-- |
172 | 1 |
/* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
486 | 3 |
* Copyright (c) 2006, 2007 Igor Ulyanov <iulyanov@gmail.com> |
172 | 4 |
* |
184 | 5 |
* This program is free software; you can redistribute it and/or modify |
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
172 | 8 |
* |
184 | 9 |
* This program is distributed in the hope that it will be useful, |
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
172 | 13 |
* |
184 | 14 |
* You should have received a copy of the GNU General Public License |
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ |
|
172 | 17 |
|
497 | 18 |
#include "hwconsts.h" |
164 | 19 |
#include "hwmap.h" |
1797 | 20 |
|
180
ea83b9e9057f
tcp sockets are incapsulated in TCPBase class now
displacer
parents:
177
diff
changeset
|
21 |
HWMap::HWMap() : |
ea83b9e9057f
tcp sockets are incapsulated in TCPBase class now
displacer
parents:
177
diff
changeset
|
22 |
TCPBase(false) |
164 | 23 |
{ |
24 |
} |
|
25 |
||
168 | 26 |
HWMap::~HWMap() |
27 |
{ |
|
28 |
} |
|
29 |
||
1797 | 30 |
void HWMap::getImage(std::string seed, int filter) |
164 | 31 |
{ |
1797 | 32 |
m_seed = seed; |
33 |
templateFilter = filter; |
|
34 |
Start(); |
|
164 | 35 |
} |
36 |
||
177 | 37 |
QStringList HWMap::setArguments() |
38 |
{ |
|
1797 | 39 |
QStringList arguments; |
40 |
arguments << cfgdir->absolutePath(); |
|
41 |
arguments << QString("%1").arg(ipc_port); |
|
42 |
arguments << "landpreview"; |
|
43 |
return arguments; |
|
177 | 44 |
} |
45 |
||
46 |
void HWMap::onClientDisconnect() |
|
164 | 47 |
{ |
1790 | 48 |
if (readbuffer.size() == 128 * 32 + 1) |
49 |
{ |
|
50 |
quint8 *buf = (quint8*) readbuffer.constData(); |
|
51 |
QImage im(buf, 256, 128, QImage::Format_Mono); |
|
52 |
im.setNumColors(2); |
|
1791
7c9d645d2591
Fix passing hedgehogs number from engine to frontend
unc0rr
parents:
1790
diff
changeset
|
53 |
emit HHLimitReceived(buf[128 * 32]); |
1790 | 54 |
emit ImageReceived(im); |
55 |
} |
|
164 | 56 |
} |
57 |
||
58 |
void HWMap::SendToClientFirst() |
|
59 |
{ |
|
1797 | 60 |
SendIPC(QString("eseed %1").arg(m_seed.c_str()).toLatin1()); |
61 |
SendIPC(QString("e$template_filter %1").arg(templateFilter).toLatin1()); |
|
62 |
SendIPC("!"); |
|
164 | 63 |
} |