QTfrontend/hwmap.cpp
author displacer
Sat, 25 Nov 2006 17:08:39 +0000
changeset 277 04a613bab65c
parent 184 f97a7a3dc8f6
child 291 afa378f1e961
permissions -rw-r--r--
rollback to main.cpp.in
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
172
5294ada3910b working map preview
displacer
parents: 171
diff changeset
     1
/*
5294ada3910b working map preview
displacer
parents: 171
diff changeset
     2
 * Hedgewars, a worms-like game
5294ada3910b working map preview
displacer
parents: 171
diff changeset
     3
 * Copyright (c) 2006 Igor Ulyanov <iulyanov@gmail.com>
5294ada3910b working map preview
displacer
parents: 171
diff changeset
     4
 *
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 180
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 180
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 180
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
172
5294ada3910b working map preview
displacer
parents: 171
diff changeset
     8
 *
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 180
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 180
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 180
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 180
diff changeset
    12
 * GNU General Public License for more details.
172
5294ada3910b working map preview
displacer
parents: 171
diff changeset
    13
 *
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 180
diff changeset
    14
 * You should have received a copy of the GNU General Public License
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 180
diff changeset
    15
 * along with this program; if not, write to the Free Software
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 180
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */
172
5294ada3910b working map preview
displacer
parents: 171
diff changeset
    17
164
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    18
#include "hwmap.h"
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    19
180
ea83b9e9057f tcp sockets are incapsulated in TCPBase class now
displacer
parents: 177
diff changeset
    20
HWMap::HWMap() :
ea83b9e9057f tcp sockets are incapsulated in TCPBase class now
displacer
parents: 177
diff changeset
    21
  TCPBase(false)
164
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    22
{
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    23
}
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    24
168
679e9b8912f5 multiple server starting improved
displacer
parents: 164
diff changeset
    25
HWMap::~HWMap()
679e9b8912f5 multiple server starting improved
displacer
parents: 164
diff changeset
    26
{
679e9b8912f5 multiple server starting improved
displacer
parents: 164
diff changeset
    27
}
679e9b8912f5 multiple server starting improved
displacer
parents: 164
diff changeset
    28
164
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    29
void HWMap::getImage(std::string seed) 
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    30
{
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    31
  m_seed=seed;
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    32
  Start();
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    33
}
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    34
177
c67c15e6fae3 prepare uniting tcp classes
displacer
parents: 172
diff changeset
    35
QStringList HWMap::setArguments()
c67c15e6fae3 prepare uniting tcp classes
displacer
parents: 172
diff changeset
    36
{
c67c15e6fae3 prepare uniting tcp classes
displacer
parents: 172
diff changeset
    37
  QStringList arguments;
c67c15e6fae3 prepare uniting tcp classes
displacer
parents: 172
diff changeset
    38
  arguments << "46631";
c67c15e6fae3 prepare uniting tcp classes
displacer
parents: 172
diff changeset
    39
  arguments << "landpreview";
c67c15e6fae3 prepare uniting tcp classes
displacer
parents: 172
diff changeset
    40
  return arguments;
c67c15e6fae3 prepare uniting tcp classes
displacer
parents: 172
diff changeset
    41
}
c67c15e6fae3 prepare uniting tcp classes
displacer
parents: 172
diff changeset
    42
c67c15e6fae3 prepare uniting tcp classes
displacer
parents: 172
diff changeset
    43
void HWMap::onClientDisconnect()
164
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    44
{
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    45
  QImage im((uchar*)(const char*)readbuffer, 256, 128, QImage::Format_Mono);
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    46
  im.setNumColors(2);
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    47
  emit ImageReceived(im);
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    48
}
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    49
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    50
void HWMap::SendToClientFirst()
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    51
{
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    52
  std::string toSend=std::string("eseed ")+m_seed;
180
ea83b9e9057f tcp sockets are incapsulated in TCPBase class now
displacer
parents: 177
diff changeset
    53
  SendIPC(toSend.c_str());
ea83b9e9057f tcp sockets are incapsulated in TCPBase class now
displacer
parents: 177
diff changeset
    54
  SendIPC("!");
164
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    55
}