author | unc0rr |
Sat, 14 Feb 2009 16:44:50 +0000 | |
changeset 1793 | 3e8caf5fee58 |
parent 1791 | 7c9d645d2591 |
child 1797 | fedd8649fdd9 |
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" |
1790 | 20 |
#include <QDebug> |
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 |
||
486 | 30 |
void HWMap::getImage(std::string seed) |
164 | 31 |
{ |
32 |
m_seed=seed; |
|
33 |
Start(); |
|
34 |
} |
|
35 |
||
177 | 36 |
QStringList HWMap::setArguments() |
37 |
{ |
|
38 |
QStringList arguments; |
|
497 | 39 |
arguments << cfgdir->absolutePath(); |
291 | 40 |
arguments << QString("%1").arg(ipc_port); |
177 | 41 |
arguments << "landpreview"; |
42 |
return arguments; |
|
43 |
} |
|
44 |
||
45 |
void HWMap::onClientDisconnect() |
|
164 | 46 |
{ |
1790 | 47 |
if (readbuffer.size() == 128 * 32 + 1) |
48 |
{ |
|
49 |
quint8 *buf = (quint8*) readbuffer.constData(); |
|
50 |
QImage im(buf, 256, 128, QImage::Format_Mono); |
|
51 |
im.setNumColors(2); |
|
1791
7c9d645d2591
Fix passing hedgehogs number from engine to frontend
unc0rr
parents:
1790
diff
changeset
|
52 |
emit HHLimitReceived(buf[128 * 32]); |
1790 | 53 |
emit ImageReceived(im); |
54 |
} |
|
164 | 55 |
} |
56 |
||
57 |
void HWMap::SendToClientFirst() |
|
58 |
{ |
|
59 |
std::string toSend=std::string("eseed ")+m_seed; |
|
180
ea83b9e9057f
tcp sockets are incapsulated in TCPBase class now
displacer
parents:
177
diff
changeset
|
60 |
SendIPC(toSend.c_str()); |
ea83b9e9057f
tcp sockets are incapsulated in TCPBase class now
displacer
parents:
177
diff
changeset
|
61 |
SendIPC("!"); |
164 | 62 |
} |