File: player.cpp

package info (click to toggle)
boson 0.13-4
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 12,992 kB
  • ctags: 29,287
  • sloc: cpp: 203,902; ansic: 9,959; makefile: 75; sh: 64; sed: 47
file content (98 lines) | stat: -rw-r--r-- 2,714 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
    This file is part of the Boson game
    Copyright (C) 2005 Rivo Laks (rivolaks@hot.ee)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include "player.h"
#include "player.moc"

#include "bodebug.h"

#include <qcolor.h>

#include <kgame/kgamepropertyhandler.h>


Player::Player() : KPlayer()
{
  setAsyncInput(true);
  connect(this, SIGNAL(signalNetworkData(int, const QByteArray&, Q_UINT32, KPlayer*)),
      this, SLOT(slotNetworkData(int, const QByteArray&, Q_UINT32, KPlayer*)));

  KGamePropertyBase* propName = dataHandler()->find(KGamePropertyBase::IdName);
  if(propName)
  {
    propName->setPolicy(KGamePropertyBase::PolicyClean);
  }
  else
  {
    boError() << k_funcinfo << "can't find name property" << endl;
  }
  // TODO d->mFogged.registerData() or something like this
  mOutOfGame.registerData(IdOutOfGame, dataHandler(),
      KGamePropertyBase::PolicyLocal, "OutOfGame");
  mHasLost.registerData(IdHasLost, dataHandler(),
      KGamePropertyBase::PolicyLocal, "HasLost");
  mHasWon.registerData(IdHasWon, dataHandler(),
      KGamePropertyBase::PolicyLocal, "HasWon");
  mMinerals.registerData(IdMinerals, dataHandler(),
      KGamePropertyBase::PolicyLocal, "Minerals");
  mOil.registerData(IdOil, dataHandler(),
      KGamePropertyBase::PolicyLocal, "Oil");
  mIsNeutralPlayer.registerData(IdIsNeutralPlayer, dataHandler(),
      KGamePropertyBase::PolicyLocal, "IsNeutralPlayer");

  mUnitCount = 0;
}

Player::~Player()
{
}

void Player::slotNetworkData(int msgid, const QByteArray& msg, Q_UINT32 sender, KPlayer*)
{
}

bool Player::load(QDataStream& stream)
{
  boDebug() << k_funcinfo << endl;
  if (!KPlayer::load(stream))
  {
    boError() << k_funcinfo << "Couldn't load KPlayer" << endl;
    return false;
  }

  // Load speciestheme
  QString themeIdentifier;
  QColor teamColor;
  stream >> themeIdentifier;
  stream >> teamColor;

  // Load unitpropID
  Q_UINT32 unitPropId;
  stream >> unitPropId;

  return true;
}

bool Player::save(QDataStream& stream)
{
  boError() << k_funcinfo << endl;
  return true;
}